diff --git a/src/ApplicationFramework/TKBin/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx b/src/ApplicationFramework/TKBin/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx index e02ca924c5..e8ddfba591 100644 --- a/src/ApplicationFramework/TKBin/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx @@ -100,16 +100,22 @@ void BinDrivers_DocumentRetrievalDriver::EnableQuickPartReading( bool theValue) { if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(theMessageDriver); + } if (myDrivers.IsNull()) + { return; + } occ::handle aDriver; myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver); occ::handle aShapesDriver = occ::down_cast(aDriver); if (aShapesDriver.IsNull()) + { throw Standard_NotImplemented("Internal Error - TNaming_NamedShape is not found!"); + } aShapesDriver->EnableQuickPart(theValue); } diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_ConstraintDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_ConstraintDriver.cxx index 641b4f6276..93b970f1c5 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_ConstraintDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_ConstraintDriver.cxx @@ -53,12 +53,16 @@ bool BinMDataXtd_ConstraintDriver::Paste(const BinObjMgt_Persistent& theSo // value if (!(theSource >> aNb)) + { return false; + } if (aNb > 0) { occ::handle aTValue; if (theRelocTable.IsBound(aNb)) + { aTValue = occ::down_cast(theRelocTable.Find(aNb)); + } else { aTValue = new TDataStd_Real; @@ -70,17 +74,23 @@ bool BinMDataXtd_ConstraintDriver::Paste(const BinObjMgt_Persistent& theSo // geometries int NbGeom; if (!(theSource >> NbGeom)) + { return false; + } int iG = 1; while (iG <= NbGeom) { if (!(theSource >> aNb)) + { return false; + } if (aNb > 0) { occ::handle aG; if (theRelocTable.IsBound(aNb)) + { aG = occ::down_cast(theRelocTable.Find(aNb)); + } else { aG = new TNaming_NamedShape; @@ -92,12 +102,16 @@ bool BinMDataXtd_ConstraintDriver::Paste(const BinObjMgt_Persistent& theSo // plane if (!(theSource >> aNb)) + { return false; + } if (aNb > 0) { occ::handle aTPlane; if (theRelocTable.IsBound(aNb)) + { aTPlane = occ::down_cast(theRelocTable.Find(aNb)); + } else { aTPlane = new TNaming_NamedShape; @@ -109,13 +123,17 @@ bool BinMDataXtd_ConstraintDriver::Paste(const BinObjMgt_Persistent& theSo // constraint type int aType; if (!(theSource >> aType)) + { return false; + } aC->SetType((TDataXtd_ConstraintEnum)aType); // flags int flags; if (!(theSource >> flags)) + { return false; + } aC->Verified((flags & 1) != 0); aC->Inverted((flags & 2) != 0); aC->Reversed((flags & 4) != 0); @@ -137,9 +155,13 @@ void BinMDataXtd_ConstraintDriver::Paste( // value occ::handle aValue = aC->GetValue(); if (!aValue.IsNull()) + { aNb = theRelocTable.Add(aValue); // create and/or get index + } else + { aNb = -1; + } theTarget << aNb; // geometries @@ -150,18 +172,26 @@ void BinMDataXtd_ConstraintDriver::Paste( { occ::handle aG = aC->GetGeometry(iG); if (!aG.IsNull()) + { aNb = theRelocTable.Add(aG); + } else + { aNb = -1; + } theTarget << aNb; } // plane occ::handle aTPlane = aC->GetPlane(); if (!aTPlane.IsNull()) + { aNb = theRelocTable.Add(aTPlane); + } else + { aNb = -1; + } theTarget << aNb; // constraint type @@ -170,10 +200,16 @@ void BinMDataXtd_ConstraintDriver::Paste( // flags int flags = 0; if (aC->Verified()) + { flags |= 1; + } if (aC->Inverted()) + { flags |= 2; + } if (aC->Reversed()) + { flags |= 4; + } theTarget << flags; } diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_GeometryDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_GeometryDriver.cxx index fb27ec3c7f..a0e2ded894 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_GeometryDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_GeometryDriver.cxx @@ -50,7 +50,9 @@ bool BinMDataXtd_GeometryDriver::Paste(const BinObjMgt_Persistent& theSour int aType; bool ok = theSource >> aType; if (ok) + { aT->SetType((TDataXtd_GeometryEnum)aType); + } return ok; } diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PatternStdDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PatternStdDriver.cxx index bdc451b06d..d0a18ed36f 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PatternStdDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PatternStdDriver.cxx @@ -53,15 +53,21 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // signature int signature; if (!(theSource >> signature)) + { return false; + } if (signature == 0) + { return true; + } aP->Signature(signature); // reversed flags int revFlags; if (!(theSource >> revFlags)) + { return false; + } aP->Axis1Reversed((revFlags & 1) != 0); aP->Axis2Reversed((revFlags & 2) != 0); @@ -71,9 +77,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo if (signature == 5) // mirror { if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -88,9 +98,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // axis 1 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -100,9 +114,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // value 1 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TReal = occ::down_cast(theRelocTable.Find(aNb)); + } else { TReal = new TDataStd_Real; @@ -112,9 +130,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // number of instances 1 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TInt = occ::down_cast(theRelocTable.Find(aNb)); + } else { TInt = new TDataStd_Integer; @@ -126,9 +148,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo { // axis 2 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -138,9 +164,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // real value 2 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TReal = occ::down_cast(theRelocTable.Find(aNb)); + } else { TReal = new TDataStd_Real; @@ -150,9 +180,13 @@ bool BinMDataXtd_PatternStdDriver::Paste(const BinObjMgt_Persistent& theSo // number of instances 2 if (!(theSource >> aNb)) + { return false; + } if (theRelocTable.IsBound(aNb)) + { TInt = occ::down_cast(theRelocTable.Find(aNb)); + } else { TInt = new TDataStd_Integer; @@ -177,17 +211,25 @@ void BinMDataXtd_PatternStdDriver::Paste( // signature int signature = aP->Signature(); if (signature < 1 || signature > 5) + { signature = 0; + } theTarget << signature; if (signature == 0) + { return; + } // reversed flags int revFlags = 0; if (aP->Axis1Reversed()) + { revFlags |= 1; + } if (aP->Axis2Reversed()) + { revFlags |= 2; + } theTarget << revFlags; int aNb; diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PositionDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PositionDriver.cxx index 346c878df6..4d8c35e066 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PositionDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PositionDriver.cxx @@ -49,18 +49,24 @@ bool BinMDataXtd_PositionDriver::Paste(const BinObjMgt_Persistent& theSour double aValue; bool ok = theSource >> aValue; if (!ok) + { return ok; + } gp_Pnt aPosition(0., 0., 0.); aPosition.SetX(aValue); ok = theSource >> aValue; if (!ok) + { return ok; + } aPosition.SetY(aValue); ok = theSource >> aValue; if (!ok) + { return ok; + } aPosition.SetZ(aValue); anAtt->SetPosition(aPosition); diff --git a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PresentationDriver.cxx b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PresentationDriver.cxx index bdcea4709a..5619194b42 100644 --- a/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PresentationDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMDataXtd/BinMDataXtd_PresentationDriver.cxx @@ -50,20 +50,26 @@ bool BinMDataXtd_PresentationDriver::Paste(const BinObjMgt_Persistent& the int aValue; ok = theSource >> aValue; if (!ok) + { return ok; + } anAttribute->SetDisplayed(aValue != 0); // GUID Standard_GUID aGUID; ok = theSource >> aGUID; if (!ok) + { return ok; + } anAttribute->SetDriverGUID(aGUID); // Color ok = theSource >> aValue; if (!ok) + { return ok; + } if (aValue != -1) { Quantity_NameOfColor aNameOfColor = TDataXtd_Presentation::getColorNameFromOldEnum(aValue); @@ -80,39 +86,63 @@ bool BinMDataXtd_PresentationDriver::Paste(const BinObjMgt_Persistent& the // Material ok = theSource >> aValue; if (!ok) + { return ok; + } if (aValue != -1) + { anAttribute->SetMaterialIndex(aValue); + } else + { anAttribute->UnsetMaterial(); + } // Transparency double aRValue; ok = theSource >> aRValue; if (!ok) + { return ok; + } if (aRValue != -1.) + { anAttribute->SetTransparency(aRValue); + } else + { anAttribute->UnsetTransparency(); + } // Width ok = theSource >> aRValue; if (!ok) + { return ok; + } if (aRValue != -1.) + { anAttribute->SetWidth(aRValue); + } else + { anAttribute->UnsetWidth(); + } // Mode ok = theSource >> aValue; if (!ok) + { return ok; + } if (aValue != -1) + { anAttribute->SetMode(aValue); + } else + { anAttribute->UnsetMode(); + } return true; } @@ -145,25 +175,41 @@ void BinMDataXtd_PresentationDriver::Paste( // Material if (anAttribute->HasOwnMaterial()) + { theTarget.PutInteger(anAttribute->MaterialIndex()); + } else + { theTarget.PutInteger(-1); + } // Transparency if (anAttribute->HasOwnTransparency()) + { theTarget.PutReal(anAttribute->Transparency()); + } else + { theTarget.PutReal(-1.); + } // Width if (anAttribute->HasOwnWidth()) + { theTarget.PutReal(anAttribute->Width()); + } else + { theTarget.PutReal(-1.); + } // Mode if (anAttribute->HasOwnMode()) + { theTarget.PutInteger(anAttribute->Mode()); + } else + { theTarget.PutInteger(-1); + } } diff --git a/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamedShapeDriver.cxx b/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamedShapeDriver.cxx index 9c4d1ff772..bc3881886d 100644 --- a/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamedShapeDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamedShapeDriver.cxx @@ -149,16 +149,24 @@ static int TranslateFrom(const BinObjMgt_Persistent& theSource, char aCharOrient; bool Ok = theSource >> aShapeID; // TShapeID; if (!Ok) + { return 1; + } // Read TShape and Orientation if (aShapeID <= 0 || aShapeID > theShapeSet->NbShapes()) + { return 1; + } Ok = theSource >> aLocID; if (!Ok) + { return 1; + } Ok = theSource >> aCharOrient; if (!Ok) + { return 1; + } TopAbs_Orientation anOrient = CharToOrientation(aCharOrient); theResult.TShape(theShapeSet->Shape(aShapeID).TShape()); // TShape @@ -200,19 +208,25 @@ bool BinMNaming_NamedShapeDriver::Paste(const BinObjMgt_Persistent& theSou int aVer; bool ok = theSource >> aVer; if (!ok) + { return false; + } aTAtt->SetVersion(aVer); // Version char aCharEvol; ok = theSource >> aCharEvol; if (!ok) + { return false; + } TNaming_Evolution anEvol = EvolutionToEnum(aCharEvol); // Evolution aTAtt->SetVersion(anEvol); BinTools_ShapeSetBase* aShapeSet = const_cast(this)->ShapeSet(true); Standard_IStream* aDirectStream = nullptr; - if (myIsQuickPart) // enables direct reading of shapes from the stream + if (myIsQuickPart) + { // enables direct reading of shapes from the stream aDirectStream = const_cast(&theSource)->GetIStream(); + } NCollection_List anOldShapes, aNewShapes; for (int i = 1; i <= aNbShapes; i++) @@ -222,17 +236,25 @@ bool BinMNaming_NamedShapeDriver::Paste(const BinObjMgt_Persistent& theSou if (anEvol != TNaming_PRIMITIVE) { if (myIsQuickPart) + { aShapeSet->Read(*aDirectStream, anOldShape); + } else if (TranslateFrom(theSource, anOldShape, static_cast(aShapeSet))) + { return false; + } } if (anEvol != TNaming_DELETE) { if (myIsQuickPart) + { aShapeSet->Read(*aDirectStream, aNewShape); + } else if (TranslateFrom(theSource, aNewShape, static_cast(aShapeSet))) + { return false; + } } // Here we add shapes in reverse order because TNaming_Builder also adds them in reverse order. @@ -285,7 +307,9 @@ void BinMNaming_NamedShapeDriver::Paste( //-------------------------------------------------------------- int NbShapes = 0; for (TNaming_Iterator SItr(aSAtt); SItr.More(); SItr.Next()) + { NbShapes++; + } //-------------------------------------------------------------- BinTools_ShapeSetBase* aShapeSet = @@ -297,8 +321,10 @@ void BinMNaming_NamedShapeDriver::Paste( theTarget << EvolutionToChar(anEvol); Standard_OStream* aDirectStream = nullptr; - if (myIsQuickPart) // enables direct writing of shapes to the stream + if (myIsQuickPart) + { // enables direct writing of shapes to the stream aDirectStream = theTarget.GetOStream(); + } for (TNaming_Iterator SIterator(aSAtt); SIterator.More(); SIterator.Next()) { @@ -308,17 +334,25 @@ void BinMNaming_NamedShapeDriver::Paste( if (anEvol != TNaming_PRIMITIVE) { if (myIsQuickPart) + { aShapeSet->Write(anOldShape, *aDirectStream); + } else + { TranslateTo(anOldShape, theTarget, static_cast(aShapeSet)); + } } if (anEvol != TNaming_DELETE) { if (myIsQuickPart) + { aShapeSet->Write(aNewShape, *aDirectStream); + } else + { TranslateTo(aNewShape, theTarget, static_cast(aShapeSet)); + } } } } @@ -373,7 +407,9 @@ void BinMNaming_NamedShapeDriver::ReadShapeSection(Standard_IStream& aShapeSet->Read(theIS, theRange); } else + { theIS.seekg(aPos); // no shape section is present, try to return to initial point + } } //================================================================================================= @@ -385,12 +421,18 @@ BinTools_ShapeSetBase* BinMNaming_NamedShapeDriver::ShapeSet(const bool theReadi if (myIsQuickPart) { if (theReading) + { myShapeSet = new BinTools_ShapeReader(); + } else + { myShapeSet = new BinTools_ShapeWriter(); + } } else + { myShapeSet = new BinTools_ShapeSet(); + } myShapeSet->SetWithTriangles(myWithTriangles); myShapeSet->SetWithNormals(myWithNormals); } diff --git a/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamingDriver.cxx b/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamingDriver.cxx index 91ec5683e2..e77c1deff7 100644 --- a/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamingDriver.cxx +++ b/src/ApplicationFramework/TKBin/BinMNaming/BinMNaming_NamingDriver.cxx @@ -184,7 +184,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, { occ::handle anAtt = occ::down_cast(theTarget); if (anAtt.IsNull()) + { return false; + } TNaming_Name& aName = anAtt->ChangeName(); TCollection_ExtendedString aMsg; @@ -199,7 +201,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, aNewF = true; ok = theSource >> aValue; // skip the sign & get NameType if (!ok) + { return ok; + } } aName.Type(CharTypeToName(aValue)); @@ -224,15 +228,20 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, for (i = 1; i <= aNbArgs; i++) { // clang-format off - if(!aNewF && i > OBSOLETE_NUM) break;//interrupt reading as old format can have only 4 items + if(!aNewF && i > OBSOLETE_NUM) { break;//interrupt reading as old format can have only 4 items +} // clang-format on ok = theSource >> anIndx; if (!ok) + { break; + } else { if (theRelocTable.IsBound(anIndx)) + { aNS = occ::down_cast(theRelocTable.Find(anIndx)); + } else { aNS = new TNaming_NamedShape; @@ -245,7 +254,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, if (!aNewF && aNbArgs < OBSOLETE_NUM) { for (i = aNbArgs + 1; i <= OBSOLETE_NUM; i++) + { theSource >> anIndx; + } } } // 4. StopNS @@ -255,7 +266,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, if (anIndx > 0) { if (theRelocTable.IsBound(anIndx)) + { aNS = occ::down_cast(theRelocTable.Find(anIndx)); + } else { aNS = new TNaming_NamedShape; @@ -267,7 +280,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, // 5. Index ok = theSource >> anIndx; if (ok) + { aName.Index(anIndx); + } else { aMsg = TCollection_ExtendedString("BinMNaming_NamingDriver: " @@ -309,7 +324,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, TDF_Label tLab; // Null label. TDF_Tool::Label(anAtt->Label().Data(), entry, tLab, true); if (!tLab.IsNull()) + { aName.ContextLabel(tLab); + } } } if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() @@ -327,7 +344,9 @@ bool BinMNaming_NamingDriver::Paste(const BinObjMgt_Persistent& theSource, { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) + { continue; + } if (aNShape->Evolution() == TNaming_SELECTED) { if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX @@ -410,7 +429,9 @@ void BinMNaming_NamingDriver::Paste( { anIndx = theRelocTable.FindIndex(anArg); if (anIndx == 0) + { anIndx = theRelocTable.Add(anArg); + } } anArray.SetValue(i, anIndx); } @@ -424,10 +445,14 @@ void BinMNaming_NamingDriver::Paste( { anIndx = theRelocTable.FindIndex(aStopNS); if (anIndx == 0) + { anIndx = theRelocTable.Add(aStopNS); + } } else + { anIndx = 0; + } theTarget << anIndx; // 5. keep Index @@ -436,7 +461,9 @@ void BinMNaming_NamingDriver::Paste( // 6. keep context label TCollection_AsciiString entry(NULL_ENTRY); if (!aName.ContextLabel().IsNull()) + { TDF_Tool::Entry(aName.ContextLabel(), entry); + } theTarget << entry; // 7. keep Orientation diff --git a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentRetrievalDriver.cxx b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentRetrievalDriver.cxx index 5fc0f70847..8e69f9f1fa 100644 --- a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentRetrievalDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentRetrievalDriver.cxx @@ -177,9 +177,13 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& { TCollection_AsciiString aStr = aUserInfo(i); if (aStr == START_TYPES) + { begin = true; + } else if (aStr == END_TYPES) + { break; + } else if (begin) { if (aFileVer < TDocStd_FormatVersion_VERSION_8) @@ -202,14 +206,20 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& } } if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(myMsgDriver); + } myDrivers->AssignIds(aTypeNames); // recognize types not supported by drivers myMapUnsupported.Clear(); for (i = 1; i <= aTypeNames.Length(); i++) + { if (myDrivers->GetDriver(i).IsNull()) + { myMapUnsupported.Add(i); + } + } if (!myMapUnsupported.IsEmpty()) { myMsgDriver->Send(aMethStr @@ -217,8 +227,12 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& "the following attributes have no driver:", Message_Warning); for (i = 1; i <= aTypeNames.Length(); i++) + { if (myMapUnsupported.Contains(i)) + { myMsgDriver->Send(aTypeNames(i), Message_Warning); + } + } } // 2. Read document contents @@ -240,7 +254,9 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& do { if (!BinLDrivers_DocumentSection::ReadTOC(aSection, theIStream, aFileVer)) + { break; + } mySections.Append(aSection); } while (!aSection.Name().IsEqual(aQuickPart ? ENDSECTION_POS : SHAPESECTION_POS) && !theIStream.eof()); @@ -275,7 +291,9 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& } } else if (!aCurSection.Name().IsEqual(ENDSECTION_POS)) + { ReadSection(aCurSection, theDoc, theIStream); + } } } theIStream.seekg(aDocumentPos); @@ -337,12 +355,16 @@ void BinLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& theIStream.read(reinterpret_cast(&aTag), sizeof(int)); if (aQuickPart) + { myPAtt.SetIStream(theIStream); // for reading shapes data from the stream directly + } EnableQuickPartReading(myMsgDriver, aQuickPart); // read sub-tree of the root label if (!theFilter.IsNull()) + { theFilter->StartIteration(); + } const auto aStreamStartPosition = theIStream.tellg(); int nbRead = ReadSubTree(theIStream, aData->Root(), theFilter, aQuickPart, false, aPS.Next()); if (!myUnresolvedLinks.IsEmpty()) @@ -412,7 +434,9 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( bool aSkipAttrs = false; if (!theFilter.IsNull() && theFilter->IsPartTree()) + { aSkipAttrs = !theFilter->IsPassed(); + } if (theQuickPart) { @@ -427,7 +451,9 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( aLabelSize -= sizeof(uint64_t); theIS.seekg(aLabelSize, std::ios_base::cur); if (!theFilter.IsNull()) + { theFilter->Up(); + } return 0; } } @@ -475,9 +501,13 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( occ::handle tAtt; bool isBound = myRelocTable.IsBound(anID); if (isBound) + { tAtt = occ::down_cast(myRelocTable.Find(anID)); + } else + { tAtt = aDriver->NewEmpty(); + } if (!theFilter.IsNull() && !theFilter->IsPassed(tAtt->DynamicType())) { @@ -498,9 +528,13 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( && theLabel.IsAttribute(tAtt->ID())) { if (theFilter->Mode() == PCDM_ReaderFilter::AppendMode_Protect) + { continue; // do not overwrite the existing attribute + } if (theFilter->Mode() == PCDM_ReaderFilter::AppendMode_Overwrite) + { theLabel.ForgetAttribute(tAtt->ID()); // forget old attribute to write a new one + } } try { @@ -518,9 +552,11 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( } } else + { myMsgDriver->Send(aMethStr + "warning: attempt to attach attribute " + aDriver->TypeName() + " to a second label", Message_Warning); + } bool ok = aDriver->Paste(myPAtt, tAtt, myRelocTable); if (!ok) @@ -544,8 +580,10 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( } } else if (!myMapUnsupported.Contains(myPAtt.TypeId())) + { myMsgDriver->Send(aMethStr + "warning: type ID not registered in header: " + myPAtt.TypeId(), Message_Warning); + } } if (!theIS || myPAtt.TypeId() != BinLDrivers_ENDATTRLIST) { @@ -575,11 +613,15 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( // read sub-tree if (!theFilter.IsNull()) + { theFilter->Down(aTag); + } int nbSubRead = ReadSubTree(theIS, aLab, theFilter, theQuickPart, theReadMissing, aPS.Next()); // check for error if (nbSubRead == -1) + { return -1; + } nbRead += nbSubRead; // read the tag of the next child @@ -597,7 +639,9 @@ int BinLDrivers_DocumentRetrievalDriver::ReadSubTree( return -1; } if (!theFilter.IsNull()) + { theFilter->Up(); + } return nbRead; } diff --git a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentSection.cxx b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentSection.cxx index 2c4d48096b..a1ec0fe258 100644 --- a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentSection.cxx +++ b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentSection.cxx @@ -99,7 +99,9 @@ void BinLDrivers_DocumentSection::WriteTOC(Standard_OStream& theStream const size_t aLen = strlen(&aBuf[sizeof(int)]); size_t aBufSize = (aLen / sizeof(int)) * sizeof(int); if (aBufSize < aLen) + { aBufSize += sizeof(int); + } // Write the buffer: size + string #ifdef DO_INVERSE @@ -143,8 +145,10 @@ void BinLDrivers_DocumentSection::Write(Standard_OStream& theStream, { // Check the limits for a 4-bytes integer. if (myValue[0] > INT_MAX || myValue[1] > INT_MAX) + { throw Standard_OutOfRange( "BinLDrivers_DocumentSection::Write : file size is too big, needs int64."); + } // Old documents stored file position as 4-bytes values. int32_t aValInt[3] = {int32_t(myValue[0]), int32_t(myValue[1]), int32_t(myIsPostRead ? 1 : 0)}; @@ -180,7 +184,9 @@ bool BinLDrivers_DocumentSection::ReadTOC(BinLDrivers_DocumentSection& theSectio int aNameBufferSize; theStream.read(reinterpret_cast(&aNameBufferSize), sizeof(int)); if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE) + { return false; + } #ifdef DO_INVERSE aNameBufferSize = InverseSize(aNameBufferSize); #endif diff --git a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx index dc8b09f32e..c1b40b9ad2 100644 --- a/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx @@ -92,11 +92,15 @@ void BinLDrivers_DocumentStorageDriver::Write(const occ::handle& t { // First pass: collect empty labels, assign IDs to the types if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(myMsgDriver); + } occ::handle aData = aDoc->GetData(); FirstPass(aData->Root()); if (aDoc->EmptyLabelsSavingMode()) + { myEmptyLabels.Clear(); // + } // 1. Write info section (including types table) WriteInfoSection(aDoc, theOStream); @@ -112,7 +116,9 @@ void BinLDrivers_DocumentStorageDriver::Write(const occ::handle& t const TDocStd_FormatVersion aDocVer = aDoc->StorageFormatVersion(); NCollection_DynamicArray::Iterator anIterS(mySections); for (; anIterS.More(); anIterS.Next()) + { anIterS.ChangeValue().WriteTOC(theOStream, aDocVer); + } EnableQuickPartWriting(myMsgDriver, IsQuickPart(aDocVer)); BinLDrivers_DocumentSection* aShapesSection = nullptr; @@ -135,7 +141,9 @@ void BinLDrivers_DocumentStorageDriver::Write(const occ::handle& t myRelocTable.Clear(); myPAtt.Init(); if (aQuickPart) + { myPAtt.SetOStream(theOStream); // for writing shapes data into the stream directly + } Message_ProgressScope aPS(theRange, "Writing document", 3); @@ -155,7 +163,9 @@ void BinLDrivers_DocumentStorageDriver::Write(const occ::handle& t delete aShapesSection; } else + { Clear(); + } if (!aPS.More()) { @@ -175,7 +185,9 @@ void BinLDrivers_DocumentStorageDriver::Write(const occ::handle& t // 5. Write sizes along the file where it is needed for quick part mode if (aQuickPart) + { WriteSizes(theOStream); + } // End of processing: close structures and check the status myPAtt.Destroy(); // free buffer @@ -330,7 +342,9 @@ void BinLDrivers_DocumentStorageDriver::WriteSubTree(const TDF_Label& #endif theOS.write(reinterpret_cast(&anEndLabel), sizeof(anEndLabel)); if (theQuickPart) + { aPosition->StoreSize(theOS); + } } //================================================================================================= @@ -374,15 +388,21 @@ bool BinLDrivers_DocumentStorageDriver::FirstPassSubTree(const TDF_Label& for (; itChld.More(); itChld.Next()) { if (FirstPassSubTree(itChld.Value(), emptyChildrenList)) + { emptyChildrenList.Append(itChld.Value()); + } else + { hasChildAttr = true; + } } bool isEmpty = !(hasAttr || hasChildAttr); if (!isEmpty) + { ListOfEmptyL.Append(emptyChildrenList); + } return isEmpty; } @@ -395,7 +415,9 @@ void BinLDrivers_DocumentStorageDriver::FirstPass(const TDF_Label& theRoot) myEmptyLabels.Clear(); if (FirstPassSubTree(theRoot, myEmptyLabels)) + { myEmptyLabels.Append(theRoot); + } myDrivers->AssignIds(myTypesMap); } @@ -582,6 +604,8 @@ void BinLDrivers_DocumentStorageDriver::WriteSizes(Standard_OStream& theOS) { NCollection_List>::Iterator anIter(mySizesToWrite); for (; anIter.More() && theOS; anIter.Next()) + { anIter.Value()->WriteSize(theOS); + } mySizesToWrite.Clear(); } diff --git a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ADriver.cxx b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ADriver.cxx index 71d1d94b1c..5536a44c05 100644 --- a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ADriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ADriver.cxx @@ -24,7 +24,9 @@ BinMDF_ADriver::BinMDF_ADriver(const occ::handle& theMsgDrive : myMessageDriver(theMsgDriver) { if (theName) + { myTypeName = theName; + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ReferenceDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ReferenceDriver.cxx index 199849be25..8135ec22cd 100644 --- a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ReferenceDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_ReferenceDriver.cxx @@ -49,7 +49,9 @@ bool BinMDF_ReferenceDriver::Paste(const BinObjMgt_Persistent& theSource, TDF_Label tLab; // Null label. if (!theSource.GetLabel(aRef->Label().Data(), tLab)) + { return false; + } // set referenced label aRef->Set(tLab); diff --git a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_TagSourceDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_TagSourceDriver.cxx index 84ac3aafa1..98e1ea7d09 100644 --- a/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_TagSourceDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDF/BinMDF_TagSourceDriver.cxx @@ -48,7 +48,9 @@ bool BinMDF_TagSourceDriver::Paste(const BinObjMgt_Persistent& theSource, int aValue; bool ok = theSource >> aValue; if (ok) + { aTag->Set(aValue); + } return ok; } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_AsciiStringDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_AsciiStringDriver.cxx index 87e1468831..2880aead15 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_AsciiStringDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_AsciiStringDriver.cxx @@ -54,7 +54,9 @@ bool BinMDataStd_AsciiStringDriver::Paste(const BinObjMgt_Persistent& Sour TCollection_AsciiString aString; bool ok = Source >> aString; if (ok) + { aStrAtt->Set(aString); + } if (RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid @@ -73,7 +75,9 @@ bool BinMDataStd_AsciiStringDriver::Paste(const BinObjMgt_Persistent& Sour } } else + { aStrAtt->SetID(TDataStd_AsciiString::GetID()); + } return ok; } @@ -91,5 +95,7 @@ void BinMDataStd_AsciiStringDriver::Paste( Target << anAtt->Get(); // process user defined guid if (anAtt->ID() != TDataStd_AsciiString::GetID()) + { Target << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanArrayDriver.cxx index 052aaeb210..20b14dd353 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanArrayDriver.cxx @@ -48,9 +48,13 @@ bool BinMDataStd_BooleanArrayDriver::Paste(const BinObjMgt_Persistent& the { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } if (aLastInd < aFirstInd) + { return false; + } NCollection_Array1 aTargetArray(0, (aLastInd - aFirstInd + 1) >> 3); theSource.GetByteArray(&aTargetArray(0), aTargetArray.Length()); @@ -84,7 +88,9 @@ void BinMDataStd_BooleanArrayDriver::Paste( const int aFirstInd = anAtt->Lower(); const int aLastInd = anAtt->Upper(); if (aLastInd < aFirstInd) + { return; + } theTarget << aFirstInd << aLastInd; const occ::handle>& bytes = anAtt->InternalArray(); @@ -99,5 +105,7 @@ void BinMDataStd_BooleanArrayDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_BooleanArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanListDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanListDriver.cxx index 25fadfd802..7dadb96462 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanListDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_BooleanListDriver.cxx @@ -50,7 +50,9 @@ bool BinMDataStd_BooleanListDriver::Paste(const BinObjMgt_Persistent& theS { int aIndex, aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); if (aLastInd > 0) @@ -88,10 +90,14 @@ void BinMDataStd_BooleanListDriver::Paste( const int aLastInd(anAtt->Extent()); const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return; + } theTarget << aFirstInd << aLastInd; if (aLastInd == 0) + { return; + } NCollection_Array1 aSourceArray(aFirstInd, aLastInd); NCollection_List::Iterator itr(anAtt->List()); for (int i = 1; itr.More(); itr.Next(), i++) @@ -103,5 +109,7 @@ void BinMDataStd_BooleanListDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_BooleanList::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ByteArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ByteArrayDriver.cxx index 46e62d989d..ca694810c3 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ByteArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ByteArrayDriver.cxx @@ -49,9 +49,13 @@ bool BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent& theSou { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } if (aLastInd < aFirstInd) + { return false; + } NCollection_Array1 aTargetArray(aFirstInd, aLastInd); theSource.GetByteArray(&aTargetArray(aFirstInd), aTargetArray.Length()); @@ -71,9 +75,13 @@ bool BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent& theSou { uint8_t aDeltaValue; if (!(theSource >> aDeltaValue)) + { return false; + } else + { aDelta = (aDeltaValue != 0); + } } anAtt->SetDelta(aDelta); @@ -96,7 +104,9 @@ void BinMDataStd_ByteArrayDriver::Paste( const int aFirstInd = anAtt->Lower(); const int aLastInd = anAtt->Upper(); if (aLastInd < aFirstInd) + { return; + } theTarget << aFirstInd << aLastInd; const occ::handle>& bytes = anAtt->InternalArray(); @@ -112,5 +122,7 @@ void BinMDataStd_ByteArrayDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_ByteArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExpressionDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExpressionDriver.cxx index 3a6024837e..dd3bc652c7 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExpressionDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExpressionDriver.cxx @@ -52,18 +52,24 @@ bool BinMDataStd_ExpressionDriver::Paste(const BinObjMgt_Persistent& theSo // variables int nbvar; if (!(theSource >> nbvar) || nbvar < 0) + { return false; + } NCollection_List>& aList = aC->GetVariables(); for (; nbvar > 0; nbvar--) { occ::handle aV; int aNb; if (!(theSource >> aNb)) + { return false; + } if (aNb > 0) { if (theRelocTable.IsBound(aNb)) + { aV = occ::down_cast(theRelocTable.Find(aNb)); + } else { aV = new TDataStd_Variable; @@ -76,7 +82,9 @@ bool BinMDataStd_ExpressionDriver::Paste(const BinObjMgt_Persistent& theSo // expression TCollection_ExtendedString aString; if (!(theSource >> aString)) + { return false; + } aC->SetExpression(aString); return true; @@ -103,9 +111,13 @@ void BinMDataStd_ExpressionDriver::Paste( const occ::handle& TV = it.Value(); int aNb; if (!TV.IsNull()) + { aNb = theRelocTable.Add(TV); + } else + { aNb = -1; + } theTarget << aNb; } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringArrayDriver.cxx index 7f7adfb821..f3f486ad3b 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringArrayDriver.cxx @@ -50,10 +50,14 @@ bool BinMDataStd_ExtStringArrayDriver::Paste(const BinObjMgt_Persistent& t { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } occ::handle anAtt = occ::down_cast(theTarget); anAtt->Init(aFirstInd, aLastInd); @@ -82,7 +86,9 @@ bool BinMDataStd_ExtStringArrayDriver::Paste(const BinObjMgt_Persistent& t return false; } else + { aDelta = (aDeltaValue != 0); + } } anAtt->SetDelta(aDelta); } @@ -110,11 +116,15 @@ void BinMDataStd_ExtStringArrayDriver::Paste( const int aLastInd = aSourceArray.Upper(); theTarget << aFirstInd << aLastInd; for (int i = aFirstInd; i <= aLastInd; i++) + { theTarget << anAtt->Value(i); + } theTarget << (uint8_t)(anAtt->GetDelta() ? 1 : 0); // process user defined guid if (anAtt->ID() != TDataStd_ExtStringArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringListDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringListDriver.cxx index 5020facb54..c6eec8e0ae 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringListDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ExtStringListDriver.cxx @@ -51,7 +51,9 @@ bool BinMDataStd_ExtStringListDriver::Paste(const BinObjMgt_Persistent& th { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); @@ -59,7 +61,9 @@ bool BinMDataStd_ExtStringListDriver::Paste(const BinObjMgt_Persistent& th { const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } for (int i = aFirstInd; i <= aLastInd; i++) { TCollection_ExtendedString aStr; @@ -99,5 +103,7 @@ void BinMDataStd_ExtStringListDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_ExtStringList::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_GenericExtStringDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_GenericExtStringDriver.cxx index 37e40c1588..f9dc15715d 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_GenericExtStringDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_GenericExtStringDriver.cxx @@ -56,7 +56,9 @@ bool BinMDataStd_GenericExtStringDriver::Paste(const BinObjMgt_Persistent& TCollection_ExtendedString aStr; bool ok = Source >> aStr; if (ok) + { aStrAttr->Set(aStr); + } if (RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntPackedMapDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntPackedMapDriver.cxx index 826be6a193..4cfd31bd09 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntPackedMapDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntPackedMapDriver.cxx @@ -80,7 +80,9 @@ bool BinMDataStd_IntPackedMapDriver::Paste(const BinObjMgt_Persistent& Sou return false; } if (!aHMap->ChangeMap().Add(aKey)) + { return false; + } } aTagAtt->ChangeMap(aHMap); } @@ -91,9 +93,13 @@ bool BinMDataStd_IntPackedMapDriver::Paste(const BinObjMgt_Persistent& Sou { uint8_t aDeltaValue; if (!(Source >> aDeltaValue)) + { return false; + } else + { aDelta = (aDeltaValue != 0); + } } aTagAtt->SetDelta(aDelta); return true; @@ -121,7 +127,9 @@ void BinMDataStd_IntPackedMapDriver::Paste( { TColStd_PackedMapOfInteger::Iterator anIt(anAtt->GetMap()); for (; anIt.More(); anIt.Next()) + { Target << anIt.Key(); + } } Target << (uint8_t)(anAtt->GetDelta() ? 1 : 0); } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerArrayDriver.cxx index 4519447acc..45ab105d45 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerArrayDriver.cxx @@ -50,25 +50,35 @@ bool BinMDataStd_IntegerArrayDriver::Paste(const BinObjMgt_Persistent& the { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); anAtt->Init(aFirstInd, aLastInd); NCollection_Array1& aTargetArray = anAtt->Array()->ChangeArray1(); if (!theSource.GetIntArray(&aTargetArray(aFirstInd), aLength)) + { return false; + } bool aDelta(false); if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) { uint8_t aDeltaValue; if (!(theSource >> aDeltaValue)) + { return false; + } else + { aDelta = (aDeltaValue != 0); + } } #ifdef OCCT_DEBUG // std::cout << "Current Document Format Version = " << @@ -104,5 +114,7 @@ void BinMDataStd_IntegerArrayDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_IntegerArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerDriver.cxx index b5c1ad5b01..291b00fb83 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerDriver.cxx @@ -50,7 +50,9 @@ bool BinMDataStd_IntegerDriver::Paste(const BinObjMgt_Persistent& theSourc int aValue; bool ok = theSource >> aValue; if (ok) + { anAtt->Set(aValue); + } if (theRT.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid const int& aPos = theSource.Position(); @@ -67,7 +69,9 @@ bool BinMDataStd_IntegerDriver::Paste(const BinObjMgt_Persistent& theSourc } } else + { anAtt->SetID(TDataStd_Integer::GetID()); + } return ok; } @@ -85,5 +89,7 @@ void BinMDataStd_IntegerDriver::Paste( theTarget << anAtt->Get(); // process user defined guid if (anAtt->ID() != TDataStd_Integer::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerListDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerListDriver.cxx index 4a1a18f06a..8b2699813c 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerListDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_IntegerListDriver.cxx @@ -50,7 +50,9 @@ bool BinMDataStd_IntegerListDriver::Paste(const BinObjMgt_Persistent& theS { int aIndex, aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); if (aLastInd > 0) { @@ -60,7 +62,9 @@ bool BinMDataStd_IntegerListDriver::Paste(const BinObjMgt_Persistent& theS NCollection_Array1 aTargetArray(aFirstInd, aLastInd); theSource.GetIntArray(&aTargetArray(aFirstInd), aLength); for (aIndex = aFirstInd; aIndex <= aLastInd; aIndex++) + { anAtt->Append(aTargetArray.Value(aIndex)); + } } } @@ -84,10 +88,14 @@ void BinMDataStd_IntegerListDriver::Paste( const int aLastInd(anAtt->Extent()); const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return; + } theTarget << aFirstInd << aLastInd; if (aLastInd == 0) + { return; + } NCollection_Array1 aSourceArray(aFirstInd, aLastInd); if (aLastInd >= 1) { @@ -102,5 +110,7 @@ void BinMDataStd_IntegerListDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_IntegerList::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_NamedDataDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_NamedDataDriver.cxx index 5f339d43a8..4d8bfac621 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_NamedDataDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_NamedDataDriver.cxx @@ -49,13 +49,19 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou occ::handle T = occ::down_cast(theTarget); if (T.IsNull()) + { return false; + } int aLower, anUpper, i; if (!(theSource >> aLower >> anUpper)) + { return false; + } // const int aLength = anUpper - aLower + 1; if (anUpper < aLower) + { return false; + } if (anUpper | aLower) { NCollection_DataMap anIntegers; @@ -64,16 +70,22 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou TCollection_ExtendedString aKey; int aValue; if (!(theSource >> aKey >> aValue)) + { return false; + } anIntegers.Bind(aKey, aValue); } T->ChangeIntegers(anIntegers); } if (!(theSource >> aLower >> anUpper)) + { return false; + } if (anUpper < aLower) + { return false; + } if (anUpper | aLower) { NCollection_DataMap aReals; @@ -82,7 +94,9 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou TCollection_ExtendedString aKey; double aValue; if (!(theSource >> aKey >> aValue)) + { return false; + } aReals.Bind(aKey, aValue); } T->ChangeReals(aReals); @@ -90,9 +104,13 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou // strings if (!(theSource >> aLower >> anUpper)) + { return false; + } if (anUpper < aLower) + { return false; + } if (anUpper | aLower) { NCollection_DataMap aStrings; @@ -101,7 +119,9 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou TCollection_ExtendedString aKey; TCollection_ExtendedString aValue; if (!(theSource >> aKey >> aValue)) + { return false; + } aStrings.Bind(aKey, aValue); } T->ChangeStrings(aStrings); @@ -109,9 +129,13 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou // Bytes if (!(theSource >> aLower >> anUpper)) + { return false; + } if (anUpper < aLower) + { return false; + } if (anUpper | aLower) { NCollection_DataMap aBytes; @@ -120,7 +144,9 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou TCollection_ExtendedString aKey; uint8_t aValue; if (!(theSource >> aKey >> aValue)) + { return false; + } aBytes.Bind(aKey, (uint8_t)aValue); } T->ChangeBytes(aBytes); @@ -128,9 +154,13 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou // arrays of integers if (!(theSource >> aLower >> anUpper)) + { return false; + } if (anUpper < aLower) + { return false; + } bool aResult = false; if (anUpper | aLower) { @@ -140,31 +170,45 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou { TCollection_ExtendedString aKey; if (!(theSource >> aKey)) + { return false; + } int low, up; if (!(theSource >> low >> up)) + { return false; + } if (up < low) + { return false; + } if (up | low) { occ::handle> aTargetArray = new NCollection_HArray1(low, up); if (!theSource.GetIntArray(&(aTargetArray->ChangeArray1())(low), up - low + 1)) + { return false; + } bool Ok = anIntArrays.Bind(aKey, aTargetArray); aResult |= Ok; } } if (aResult) + { T->ChangeArraysOfIntegers(anIntArrays); + } } // arrays of reals if (!(theSource >> aLower >> anUpper)) + { return false; + } if (anUpper < aLower) + { return false; + } aResult = false; if (anUpper | aLower) { @@ -174,24 +218,34 @@ bool BinMDataStd_NamedDataDriver::Paste(const BinObjMgt_Persistent& theSou { TCollection_ExtendedString aKey; if (!(theSource >> aKey)) + { return false; + } int low, up; if (!(theSource >> low >> up)) + { return false; + } if (up < low) + { return false; + } if (low | up) { occ::handle> aTargetArray = new NCollection_HArray1(low, up); if (!theSource.GetRealArray(&(aTargetArray->ChangeArray1())(low), up - low + 1)) + { return false; + } bool Ok = aRealArrays.Bind(aKey, aTargetArray); aResult |= Ok; } } if (aResult) + { T->ChangeArraysOfReals(aRealArrays); + } } return true; } @@ -207,7 +261,9 @@ void BinMDataStd_NamedDataDriver::Paste( { occ::handle S = occ::down_cast(theSource); if (S.IsNull()) + { return; + } // int i=0; S->LoadDeferredData(); diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealArrayDriver.cxx index c00d88d1fe..39f0c24ba6 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealArrayDriver.cxx @@ -49,16 +49,22 @@ bool BinMDataStd_RealArrayDriver::Paste(const BinObjMgt_Persistent& theSou { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); anAtt->Init(aFirstInd, aLastInd); NCollection_Array1& aTargetArray = anAtt->Array()->ChangeArray1(); if (!theSource.GetRealArray(&aTargetArray(aFirstInd), aLength)) + { return false; + } bool aDelta(false); if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() @@ -66,9 +72,13 @@ bool BinMDataStd_RealArrayDriver::Paste(const BinObjMgt_Persistent& theSou { uint8_t aDeltaValue; if (!(theSource >> aDeltaValue)) + { return false; + } else + { aDelta = (aDeltaValue != 0); + } } anAtt->SetDelta(aDelta); @@ -99,5 +109,7 @@ void BinMDataStd_RealArrayDriver::Paste( theTarget << (uint8_t)(anAtt->GetDelta() ? 1 : 0); // process user defined guid if (anAtt->ID() != TDataStd_RealArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealDriver.cxx index 330c1356c1..79caab58b7 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealDriver.cxx @@ -49,7 +49,9 @@ bool BinMDataStd_RealDriver::Paste(const BinObjMgt_Persistent& theSource, double aValue; bool ok = theSource >> aValue; if (ok) + { anAtt->Set(aValue); + } if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid @@ -68,7 +70,9 @@ bool BinMDataStd_RealDriver::Paste(const BinObjMgt_Persistent& theSource, } } else + { anAtt->SetID(TDataStd_Real::GetID()); + } return ok; } @@ -85,5 +89,7 @@ void BinMDataStd_RealDriver::Paste(const occ::handle& theSource, theTarget << anAtt->Get(); // process user defined guid if (anAtt->ID() != TDataStd_Real::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealListDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealListDriver.cxx index d5df366f46..5679faf757 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealListDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_RealListDriver.cxx @@ -49,7 +49,9 @@ bool BinMDataStd_RealListDriver::Paste(const BinObjMgt_Persistent& theSour { int aIndex, aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); if (aLastInd > 0) @@ -60,7 +62,9 @@ bool BinMDataStd_RealListDriver::Paste(const BinObjMgt_Persistent& theSour NCollection_Array1 aTargetArray(aFirstInd, aLastInd); theSource.GetRealArray(&aTargetArray(aFirstInd), aLength); for (aIndex = aFirstInd; aIndex <= aLastInd; aIndex++) + { anAtt->Append(aTargetArray.Value(aIndex)); + } } } @@ -84,10 +88,14 @@ void BinMDataStd_RealListDriver::Paste( const int aLastInd(anAtt->Extent()); const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return; + } theTarget << aFirstInd << aLastInd; if (aLastInd == 0) + { return; + } NCollection_Array1 aSourceArray(aFirstInd, aLastInd); if (aLastInd >= 1) { @@ -102,5 +110,7 @@ void BinMDataStd_RealListDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_RealList::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceArrayDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceArrayDriver.cxx index 77fc7649e0..feccf005aa 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceArrayDriver.cxx @@ -50,10 +50,14 @@ bool BinMDataStd_ReferenceArrayDriver::Paste(const BinObjMgt_Persistent& t { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); @@ -62,11 +66,15 @@ bool BinMDataStd_ReferenceArrayDriver::Paste(const BinObjMgt_Persistent& t { TCollection_AsciiString entry; if (!(theSource >> entry)) + { return false; + } TDF_Label L; TDF_Tool::Label(anAtt->Label().Data(), entry, L, true); if (!L.IsNull()) + { anAtt->SetValue(i, L); + } } BinMDataStd::SetAttributeID(theSource, @@ -87,7 +95,9 @@ void BinMDataStd_ReferenceArrayDriver::Paste( occ::handle anAtt = occ::down_cast(theSource); int aFirstInd = anAtt->Lower(), aLastInd = anAtt->Upper(), i = aFirstInd; if (aFirstInd > aLastInd) + { return; + } theTarget << aFirstInd << aLastInd; for (; i <= aLastInd; i++) { @@ -102,5 +112,7 @@ void BinMDataStd_ReferenceArrayDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_ReferenceArray::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceListDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceListDriver.cxx index 62c39dbdb1..c228d20ca3 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceListDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_ReferenceListDriver.cxx @@ -51,7 +51,9 @@ bool BinMDataStd_ReferenceListDriver::Paste(const BinObjMgt_Persistent& th { int aFirstInd, aLastInd; if (!(theSource >> aFirstInd >> aLastInd)) + { return false; + } const occ::handle anAtt = occ::down_cast(theTarget); @@ -60,16 +62,22 @@ bool BinMDataStd_ReferenceListDriver::Paste(const BinObjMgt_Persistent& th const int aLength = aLastInd - aFirstInd + 1; if (aLength <= 0) + { return false; + } for (int i = aFirstInd; i <= aLastInd; i++) { TCollection_AsciiString entry; if (!(theSource >> entry)) + { return false; + } TDF_Label L; TDF_Tool::Label(anAtt->Label().Data(), entry, L, true); if (!L.IsNull()) + { anAtt->Append(L); + } } } @@ -91,12 +99,16 @@ void BinMDataStd_ReferenceListDriver::Paste( const occ::handle anAtt = occ::down_cast(theSource); if (anAtt.IsNull()) + { return; + } const int aFirstInd = (anAtt->Extent() > 0) ? 1 : 0; const int aLastInd(anAtt->Extent()); theTarget << aFirstInd << aLastInd; if (aLastInd == 0) + { return; + } NCollection_List::Iterator itr(anAtt->List()); for (int i = aFirstInd; itr.More(); itr.Next(), i++) { @@ -111,5 +123,7 @@ void BinMDataStd_ReferenceListDriver::Paste( // process user defined guid if (anAtt->ID() != TDataStd_ReferenceList::GetID()) + { theTarget << anAtt->ID(); + } } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_TreeNodeDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_TreeNodeDriver.cxx index 485a3db568..bf67a7e88b 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_TreeNodeDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_TreeNodeDriver.cxx @@ -50,13 +50,19 @@ bool BinMDataStd_TreeNodeDriver::Paste(const BinObjMgt_Persistent& theSour for (i = 0; i < 4; ++i) { if (!(theSource >> aNb)) + { return false; + } if (aNb < 0) + { continue; + } occ::handle aNode; if (theRelocTable.IsBound(aNb)) + { aNode = occ::down_cast(theRelocTable.Find(aNb)); + } else { aNode = occ::down_cast(aT->NewEmpty()); // already with tree ID @@ -84,7 +90,9 @@ bool BinMDataStd_TreeNodeDriver::Paste(const BinObjMgt_Persistent& theSour // tree id Standard_GUID aGUID; if (!(theSource >> aGUID)) + { return false; + } aT->SetTreeID(aGUID); return true; @@ -122,9 +130,13 @@ void BinMDataStd_TreeNodeDriver::Paste( continue; } if (aNode.IsNull()) + { aNb = -1; + } else + { aNb = theRelocTable.Add(aNode); // create and/or get index + } theTarget.PutInteger(aNb); } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_UAttributeDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_UAttributeDriver.cxx index 372893b839..c9e6e2b6c1 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_UAttributeDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_UAttributeDriver.cxx @@ -47,7 +47,9 @@ bool BinMDataStd_UAttributeDriver::Paste(const BinObjMgt_Persistent& theSo Standard_GUID aGUID; bool ok = theSource >> aGUID; if (ok) + { anUAttr->SetID(aGUID); + } return ok; } diff --git a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_VariableDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_VariableDriver.cxx index 1b1fd8de32..00b9794ffc 100644 --- a/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_VariableDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDataStd/BinMDataStd_VariableDriver.cxx @@ -48,12 +48,16 @@ bool BinMDataStd_VariableDriver::Paste(const BinObjMgt_Persistent& theSour bool isConstant; if (!(theSource >> isConstant)) + { return false; + } aV->Constant(isConstant); TCollection_AsciiString anStr; if (!(theSource >> anStr)) + { return false; + } aV->Unit(anStr); return true; diff --git a/src/ApplicationFramework/TKBinL/BinMDocStd/BinMDocStd_XLinkDriver.cxx b/src/ApplicationFramework/TKBinL/BinMDocStd/BinMDocStd_XLinkDriver.cxx index d8ea7501ce..27c3fe24d5 100644 --- a/src/ApplicationFramework/TKBinL/BinMDocStd/BinMDocStd_XLinkDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMDocStd/BinMDocStd_XLinkDriver.cxx @@ -58,7 +58,9 @@ bool BinMDocStd_XLinkDriver::Paste(const BinObjMgt_Persistent& theSource, aStr.Clear(); ok = theSource >> aStr; if (ok) + { anAtt->LabelEntry(aStr); + } } return ok; } diff --git a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_FunctionDriver.cxx b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_FunctionDriver.cxx index 9f1bc6cea9..b2ec7fcf67 100644 --- a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_FunctionDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_FunctionDriver.cxx @@ -60,7 +60,9 @@ bool BinMFunction_FunctionDriver::Paste(const BinObjMgt_Persistent& theSou int aValue; ok = theSource >> aValue; if (ok) + { anAtt->SetFailure(aValue); + } } return ok; } diff --git a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_GraphNodeDriver.cxx b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_GraphNodeDriver.cxx index fe3366df77..d9591019b9 100644 --- a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_GraphNodeDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_GraphNodeDriver.cxx @@ -56,7 +56,9 @@ bool BinMFunction_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSo int intStatus, nb_previous, nb_next; if (!(theSource >> intStatus >> nb_previous >> nb_next)) + { return false; + } // Execution status GN->SetStatus((TFunction_ExecutionStatus)intStatus); diff --git a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_ScopeDriver.cxx b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_ScopeDriver.cxx index 2ff218a7d6..08f8240ead 100644 --- a/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_ScopeDriver.cxx +++ b/src/ApplicationFramework/TKBinL/BinMFunction/BinMFunction_ScopeDriver.cxx @@ -58,9 +58,13 @@ bool BinMFunction_ScopeDriver::Paste(const BinObjMgt_Persistent& theSource int nb; if (!(theSource >> nb)) + { return false; + } if (!nb) + { return true; + } NCollection_DoubleMap& map = S->ChangeFunctions(); @@ -74,14 +78,18 @@ bool BinMFunction_ScopeDriver::Paste(const BinObjMgt_Persistent& theSource { TCollection_AsciiString entry; if (!(theSource >> entry)) + { return false; + } TDF_Label L; TDF_Tool::Label(S->Label().Data(), entry, L, true); if (!L.IsNull()) { map.Bind(IDs.Value(i), L); if (IDs.Value(i) > freeID) + { freeID = IDs.Value(i); + } } } @@ -108,7 +116,9 @@ void BinMFunction_ScopeDriver::Paste(const occ::handle& theSource // Number of functions theTarget << nb; if (!nb) + { return; + } // IDs { diff --git a/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Persistent.cxx b/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Persistent.cxx index 029b6ed5ae..1d5f26fe05 100644 --- a/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Persistent.cxx +++ b/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Persistent.cxx @@ -92,7 +92,9 @@ Standard_OStream& BinObjMgt_Persistent::Write(Standard_OStream& theOS, const boo // update data length aData[2] = mySize - BP_HEADSIZE; if (theDirectStream) + { aData[1] = -aData[1]; + } #if DO_INVERSE aData[0] = InverseInt(aData[0]); aData[1] = InverseInt(aData[1]); @@ -145,7 +147,9 @@ Standard_IStream& BinObjMgt_Persistent::Read(Standard_IStream& theIS) #endif myDirectWritingIsEnabled = aData[1] < 0; if (myDirectWritingIsEnabled) + { aData[1] = -aData[1]; + } if (theIS && aData[2] > 0) { mySize += aData[2]; @@ -166,14 +170,18 @@ Standard_IStream& BinObjMgt_Persistent::Read(Standard_IStream& theIS) // 1st piece: reduce the number of bytes by header size ptr += BP_HEADSIZE; if (nbToRead == BP_PIECESIZE) + { nbToRead -= BP_HEADSIZE; + } } theIS.read(ptr, nbToRead); nbRead += nbToRead; } } else + { aData[2] = 0; + } } return theIS; } @@ -547,7 +555,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetCharacter(char& theValue) c { alignOffset(1); if (noMoreData(1)) + { return *this; + } char* aData = (char*)myData(myIndex) + myOffset; theValue = *aData; ((BinObjMgt_Persistent*)this)->myOffset++; @@ -560,7 +570,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetByte(uint8_t& theValue) con { alignOffset(1); if (noMoreData(1)) + { return *this; + } uint8_t* aData = (uint8_t*)myData(myIndex) + myOffset; theValue = *aData; ((BinObjMgt_Persistent*)this)->myOffset++; @@ -573,7 +585,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetExtCharacter(char16_t& theV { alignOffset(BP_EXTCHARSIZE); if (noMoreData(BP_EXTCHARSIZE)) + { return *this; + } char16_t* aData = (char16_t*)((char*)myData(myIndex) + myOffset); #ifdef DO_INVERSE theValue = InverseExtChar(*aData); @@ -590,7 +604,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetInteger(int& theValue) cons { alignOffset(BP_INTSIZE); if (noMoreData(BP_INTSIZE)) + { return *this; + } int* aData = (int*)((char*)myData(myIndex) + myOffset); #ifdef DO_INVERSE theValue = InverseInt(*aData); @@ -607,7 +623,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetReal(double& theValue) cons { alignOffset(BP_INTSIZE); if (noMoreData(BP_REALSIZE)) + { return *this; + } int nbPieces = (myOffset + BP_REALSIZE - 1) / BP_PIECESIZE; if (nbPieces > 0) { @@ -633,7 +651,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetShortReal(float& theValue) { alignOffset(BP_INTSIZE); if (noMoreData(BP_SHORTREALSIZE)) + { return *this; + } float* aData = (float*)((char*)myData(myIndex) + myOffset); #ifdef DO_INVERSE theValue = InverseShortReal(*aData); @@ -755,7 +775,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetLabel(const occ::handlemyOffset += BP_INTSIZE; if (noMoreData(aLen * BP_INTSIZE)) + { return *this; + } if (aLen > 0) { @@ -799,7 +823,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetGUID(Standard_GUID& theValu { alignOffset(BP_INTSIZE); if (noMoreData(BP_UUIDSIZE)) + { return *this; + } BinObjMgt_UUID anUUID; getArray(&anUUID, BP_UUIDSIZE); #ifdef DO_INVERSE @@ -832,7 +858,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetCharArray(const BinObjMgt_P { alignOffset(1); if (noMoreData(theLength)) + { return *this; + } getArray(theArray, theLength); return *this; } @@ -849,7 +877,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetByteArray(const BinObjMgt_P { alignOffset(1); if (noMoreData(theLength)) + { return *this; + } getArray(theArray, theLength); return *this; } @@ -867,7 +897,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetExtCharArray(const BinObjMg alignOffset(BP_EXTCHARSIZE, true); int aSize = theLength * BP_EXTCHARSIZE; if (noMoreData(aSize)) + { return *this; + } getArray(theArray, aSize); #ifdef DO_INVERSE for (int i = 0; i < theLength; i++) @@ -889,7 +921,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetIntArray(const BinObjMgt_PI alignOffset(BP_INTSIZE, true); int aSize = theLength * BP_INTSIZE; if (noMoreData(aSize)) + { return *this; + } getArray(theArray, aSize); #ifdef DO_INVERSE for (int i = 0; i < theLength; i++) @@ -911,7 +945,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetRealArray(const BinObjMgt_P alignOffset(BP_INTSIZE, true); int aSize = theLength * BP_REALSIZE; if (noMoreData(aSize)) + { return *this; + } getArray(theArray, aSize); #ifdef DO_INVERSE for (int i = 0; i < theLength; i++) @@ -934,7 +970,9 @@ const BinObjMgt_Persistent& BinObjMgt_Persistent::GetShortRealArray( alignOffset(BP_INTSIZE, true); int aSize = theLength * BP_SHORTREALSIZE; if (noMoreData(aSize)) + { return *this; + } getArray(theArray, aSize); #ifdef DO_INVERSE for (int i = 0; i < theLength; i++) @@ -1011,7 +1049,9 @@ void BinObjMgt_Persistent::inverseExtCharData(const int theIndex, int aLenInPiece = std::min(aLen, BP_PIECESIZE - anOffset); char16_t* aData = (char16_t*)((char*)myData(anIndex) + anOffset); for (int i = 0; i < aLenInPiece / BP_EXTCHARSIZE; i++) + { aData[i] = FSD_BinaryFile::InverseExtChar(aData[i]); + } aLen -= aLenInPiece; anOffset += aLenInPiece; if (anOffset >= BP_PIECESIZE) @@ -1039,7 +1079,9 @@ void BinObjMgt_Persistent::inverseIntData(const int theIndex, int aLenInPiece = std::min(aLen, BP_PIECESIZE - anOffset); int* aData = (int*)((char*)myData(anIndex) + anOffset); for (int i = 0; i < aLenInPiece / BP_INTSIZE; i++) + { aData[i] = FSD_BinaryFile::InverseInt(aData[i]); + } aLen -= aLenInPiece; anOffset += aLenInPiece; if (anOffset >= BP_PIECESIZE) @@ -1085,9 +1127,13 @@ void BinObjMgt_Persistent::inverseRealData(const int theIndex, aPrevPtr = nullptr; } for (int i = 0; i < aLenInPiece / BP_REALSIZE; i++) + { aWrapUnion.aRealData[i] = FSD_BinaryFile::InverseReal(aWrapUnion.aRealData[i]); + } if (aLenInPiece % BP_REALSIZE) + { aPrevPtr = &aWrapUnion.aRealData[aLenInPiece / BP_REALSIZE]; + } aLen -= aLenInPiece; anOffset += aLenInPiece; if (anOffset >= BP_PIECESIZE) @@ -1115,7 +1161,9 @@ void BinObjMgt_Persistent::inverseShortRealData(const int theIndex, int aLenInPiece = std::min(aLen, BP_PIECESIZE - anOffset); float* aData = (float*)((char*)myData(anIndex) + anOffset); for (int i = 0; i < aLenInPiece / BP_INTSIZE; i++) + { aData[i] = FSD_BinaryFile::InverseShortReal(aData[i]); + } aLen -= aLenInPiece; anOffset += aLenInPiece; if (anOffset >= BP_PIECESIZE) diff --git a/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Position.cxx b/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Position.cxx index bfa84a93b0..a9743a4df3 100644 --- a/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Position.cxx +++ b/src/ApplicationFramework/TKBinL/BinObjMgt/BinObjMgt_Position.cxx @@ -35,7 +35,9 @@ void BinObjMgt_Position::StoreSize(Standard_OStream& theStream) void BinObjMgt_Position::WriteSize(Standard_OStream& theStream, const bool theDummy) { if (!theDummy && theStream.tellp() != myPosition) + { theStream.seekp(myPosition); + } uint64_t aSize = theDummy ? 0 : mySize; #if DO_INVERSE aSize = FSD_BinaryFile::InverseUint64(aSize); diff --git a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_IntSparseArrayDriver.cxx b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_IntSparseArrayDriver.cxx index 53bc5309a5..6acda3aba3 100644 --- a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_IntSparseArrayDriver.cxx +++ b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_IntSparseArrayDriver.cxx @@ -50,12 +50,16 @@ bool BinTObjDrivers_IntSparseArrayDriver::Paste(const BinObjMgt_Persistent& // get pairs (ID, value) while ID != 0 int anId; if (!(theSource >> anId) || anId < 0) + { return false; + } while (anId) { int aValue; if (!(theSource >> aValue) || aValue <= 0) + { return false; + } // store the value in the target array aTarget->SetDoBackup(false); @@ -64,7 +68,9 @@ bool BinTObjDrivers_IntSparseArrayDriver::Paste(const BinObjMgt_Persistent& // get next ID if (!(theSource >> anId) || anId < 0) + { return false; + } } return true; } @@ -85,7 +91,9 @@ void BinTObjDrivers_IntSparseArrayDriver::Paste( { int aValue = anIt.Value(); if (aValue == 0) + { continue; + } // store ID and value theTarget << (int)anIt.Index() << aValue; diff --git a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ModelDriver.cxx b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ModelDriver.cxx index f4bcac66cb..5307e65ead 100644 --- a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ModelDriver.cxx +++ b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ModelDriver.cxx @@ -50,11 +50,15 @@ bool BinTObjDrivers_ModelDriver::Paste(const BinObjMgt_Persistent& theSour { Standard_GUID aGUID; if (!(theSource >> aGUID)) + { return false; + } occ::handle aCurrentModel = TObj_Assistant::GetCurrentModel(); if (aCurrentModel.IsNull()) + { return false; + } if (aGUID != aCurrentModel->GetGUID()) { diff --git a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ObjectDriver.cxx b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ObjectDriver.cxx index d92bc928f5..37c12c780d 100644 --- a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ObjectDriver.cxx +++ b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ObjectDriver.cxx @@ -52,7 +52,9 @@ bool BinTObjDrivers_ObjectDriver::Paste(const BinObjMgt_Persistent& theSou // first try to get the type as an integer ID int anID; if (!(theSource >> anID)) + { return false; + } occ::handle anObject; if ((unsigned)anID > 0xffff) { @@ -61,7 +63,9 @@ bool BinTObjDrivers_ObjectDriver::Paste(const BinObjMgt_Persistent& theSou theSource.SetPosition(aSavedPos); TCollection_AsciiString aName; if (!(theSource >> aName)) + { return false; + } anObject = TObj_Persistence::CreateNewObject(aName.ToCString(), theTarget->Label()); if (anObject.IsNull()) { @@ -82,7 +86,9 @@ bool BinTObjDrivers_ObjectDriver::Paste(const BinObjMgt_Persistent& theSou // use anID to get the type from earlier registered ones occ::handle aType = TObj_Assistant::FindType(anID); if (!aType.IsNull()) + { anObject = TObj_Persistence::CreateNewObject(aType->Name(), theTarget->Label()); + } else { return false; @@ -102,7 +108,9 @@ void BinTObjDrivers_ObjectDriver::Paste( occ::handle aTObj = occ::down_cast(theSource); occ::handle anIObject = aTObj->Get(); if (anIObject.IsNull()) + { return; + } occ::handle aType = anIObject->DynamicType(); diff --git a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx index fc977cc26f..9a5ecfeaff 100644 --- a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx +++ b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx @@ -50,19 +50,25 @@ bool BinTObjDrivers_ReferenceDriver::Paste(const BinObjMgt_Persistent& the TDF_Label aMasterLabel; occ::handle aDS = theTarget->Label().Data(); if (!theSource.GetLabel(aDS, aMasterLabel)) + { return false; + } // isSameDoc flag bool isSameDoc = false; if (!(theSource >> isSameDoc)) + { return false; + } // DS for referred label if (!isSameDoc) { TCollection_AsciiString aName; if (!(theSource >> aName)) + { return false; + } occ::handle aModel = TObj_Assistant::FindModel(aName.ToCString()); if (aModel.IsNull()) { @@ -78,7 +84,9 @@ bool BinTObjDrivers_ReferenceDriver::Paste(const BinObjMgt_Persistent& the // referred label TDF_Label aLabel; if (!theSource.GetLabel(aDS, aLabel)) + { return false; + } // set reference attribute fields occ::handle aTarget = occ::down_cast(theTarget); @@ -98,7 +106,9 @@ void BinTObjDrivers_ReferenceDriver::Paste( occ::handle aLObject = aSource->Get(); if (aLObject.IsNull()) + { return; + } // labels TDF_Label aLabel = aLObject->GetLabel(); diff --git a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_XYZDriver.cxx b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_XYZDriver.cxx index 0a4fa585f3..e39e60c379 100644 --- a/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_XYZDriver.cxx +++ b/src/ApplicationFramework/TKBinTObj/BinTObjDrivers/BinTObjDrivers_XYZDriver.cxx @@ -47,7 +47,9 @@ bool BinTObjDrivers_XYZDriver::Paste(const BinObjMgt_Persistent& theSource occ::handle aTarget = occ::down_cast(theTarget); double aX, aY, aZ; if (!(theSource >> aX >> aY >> aZ)) + { return false; + } aTarget->Set(gp_XYZ(aX, aY, aZ)); return true; } diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Axis.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Axis.cxx index 3a8e40e869..b15e4fc73f 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Axis.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Axis.cxx @@ -61,6 +61,7 @@ occ::handle TDataXtd_Axis::Set(const TDF_Label& L, const gp_Lin& if (L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { if (!aNS->Get().IsNull()) + { if (aNS->Get().ShapeType() == TopAbs_EDGE) { TopoDS_Edge anEdge = TopoDS::Edge(aNS->Get()); @@ -74,9 +75,12 @@ occ::handle TDataXtd_Axis::Set(const TDF_Label& L, const gp_Lin& && anOldLine.Location().X() == line.Location().X() && anOldLine.Location().Y() == line.Location().Y() && anOldLine.Location().Z() == line.Location().Z()) + { return A; + } } } + } } TNaming_Builder B(L); B.Generated(BRepBuilderAPI_MakeEdge(line)); diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Constraint.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Constraint.cxx index e631ab44f9..a42f22704e 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Constraint.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Constraint.cxx @@ -71,8 +71,12 @@ void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type, { occ::handle aShape = occ::down_cast(myGeometries[0]); if (!aShape.IsNull() && !G1.IsNull()) + { if (aShape->Get() == G1->Get()) + { return; + } + } } Backup(); @@ -92,8 +96,12 @@ void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type, occ::handle aShape1 = occ::down_cast(myGeometries[0]); occ::handle aShape2 = occ::down_cast(myGeometries[1]); if (!aShape1.IsNull() && !G1.IsNull() && !aShape2.IsNull() && !G2.IsNull()) + { if (aShape1->Get() == G1->Get() && aShape2->Get() == G2->Get()) + { return; + } + } } Backup(); @@ -117,8 +125,12 @@ void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type, occ::handle aShape3 = occ::down_cast(myGeometries[2]); if (!aShape1.IsNull() && !G1.IsNull() && !aShape2.IsNull() && !G2.IsNull() && !aShape3.IsNull() && !G3.IsNull()) + { if (aShape1->Get() == G1->Get() && aShape2->Get() == G2->Get() && aShape3->Get() == G3->Get()) + { return; + } + } } Backup(); @@ -145,9 +157,13 @@ void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type, occ::handle aShape4 = occ::down_cast(myGeometries[3]); if (!aShape1.IsNull() && !G1.IsNull() && !aShape2.IsNull() && !G2.IsNull() && !aShape3.IsNull() && !G3.IsNull() && !aShape4.IsNull() && !G4.IsNull()) + { if (aShape1->Get() == G1->Get() && aShape2->Get() == G2->Get() && aShape3->Get() == G3->Get() && aShape3->Get() == G4->Get()) + { return; + } + } } Backup(); @@ -164,7 +180,9 @@ void TDataXtd_Constraint::SetPlane(const occ::handle& plane) { // OCC2932 correction if (!myPlane.IsNull() && !plane.IsNull() && myPlane->Get() == plane->Get()) + { return; + } Backup(); myPlane = plane; @@ -183,7 +201,9 @@ void TDataXtd_Constraint::SetType(const TDataXtd_ConstraintEnum CTR) { // OCC2932 correction if (myType == CTR) + { return; + } Backup(); myType = CTR; @@ -203,7 +223,9 @@ void TDataXtd_Constraint::ClearGeometries() // OCC2932 correction if (myGeometries[0].IsNull() && myGeometries[1].IsNull() && myGeometries[2].IsNull() && myGeometries[3].IsNull()) + { return; + } Backup(); (myGeometries[0]).Nullify(); @@ -220,8 +242,12 @@ void TDataXtd_Constraint::SetGeometry(const int Index, const occ::handle aGeom = occ::down_cast(myGeometries[Index - 1]); if (!aGeom.IsNull() && !G.IsNull()) + { if (aGeom->Get() == G->Get()) + { return; + } + } Backup(); myGeometries[Index - 1] = G; @@ -266,8 +292,12 @@ void TDataXtd_Constraint::SetValue(const occ::handle& V) { // OCC2932 correction if (!myValue.IsNull() && !V.IsNull()) + { if (myValue->Get() == V->Get()) + { return; + } + } Backup(); myValue = V; @@ -349,20 +379,30 @@ void TDataXtd_Constraint::References(const occ::handle& DS) const // l attribut placement devrait oriente vers les contraintes de placement en dehors int Lim; if (myType >= TDataXtd_MATE && myType <= TDataXtd_FACES_ANGLE) + { Lim = 1; + } else + { Lim = 3; + } for (int i = 0; i <= Lim; i++) { if (!myGeometries[i].IsNull()) + { DS->AddAttribute(myGeometries[i]); + } } if (!myValue.IsNull()) + { DS->AddAttribute(myValue); + } if (!myPlane.IsNull()) + { DS->AddAttribute(myPlane); + } } //================================================================================================= @@ -371,7 +411,9 @@ void TDataXtd_Constraint::Verified(const bool status) { // OCC2932 correction if (myIsVerified == status) + { return; + } Backup(); myIsVerified = status; @@ -390,7 +432,9 @@ void TDataXtd_Constraint::Reversed(const bool status) { // OCC2932 correction if (myIsReversed == status) + { return; + } Backup(); myIsReversed = status; @@ -409,7 +453,9 @@ void TDataXtd_Constraint::Inverted(const bool status) { // OCC2932 correction if (myIsInverted == status) + { return; + } Backup(); myIsInverted = status; diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Geometry.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Geometry.cxx index c76bb7f830..3de6fa55cf 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Geometry.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Geometry.cxx @@ -81,7 +81,9 @@ bool TDataXtd_Geometry::Point(const occ::handle& NS, gp_Pnt& { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_VERTEX) { const TopoDS_Vertex& vertex = TopoDS::Vertex(shape); @@ -134,7 +136,9 @@ bool TDataXtd_Geometry::Line(const occ::handle& NS, gp_Lin& { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_EDGE) { const TopoDS_Edge& edge = TopoDS::Edge(shape); @@ -144,7 +148,9 @@ bool TDataXtd_Geometry::Line(const occ::handle& NS, gp_Lin& if (!curve.IsNull()) { if (curve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { curve = (occ::down_cast(curve))->BasisCurve(); + } occ::handle C = occ::down_cast(curve); if (!C.IsNull()) { @@ -174,7 +180,9 @@ bool TDataXtd_Geometry::Circle(const occ::handle& NS, gp_Cir { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_EDGE) { const TopoDS_Edge& edge = TopoDS::Edge(shape); @@ -184,7 +192,9 @@ bool TDataXtd_Geometry::Circle(const occ::handle& NS, gp_Cir if (!curve.IsNull()) { if (curve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { curve = (occ::down_cast(curve))->BasisCurve(); + } occ::handle C = occ::down_cast(curve); if (!C.IsNull()) { @@ -214,7 +224,9 @@ bool TDataXtd_Geometry::Ellipse(const occ::handle& NS, gp_El { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_EDGE) { const TopoDS_Edge& edge = TopoDS::Edge(shape); @@ -223,7 +235,9 @@ bool TDataXtd_Geometry::Ellipse(const occ::handle& NS, gp_El if (!curve.IsNull()) { if (curve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { curve = (occ::down_cast(curve))->BasisCurve(); + } occ::handle C = occ::down_cast(curve); if (!C.IsNull()) { @@ -253,7 +267,9 @@ bool TDataXtd_Geometry::Plane(const occ::handle& NS, gp_Pln& { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_FACE) { const TopoDS_Face& face = TopoDS::Face(shape); @@ -261,7 +277,9 @@ bool TDataXtd_Geometry::Plane(const occ::handle& NS, gp_Pln& if (!surface.IsNull()) { if (surface->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { surface = occ::down_cast(surface)->BasisSurface(); + } occ::handle S = occ::down_cast(surface); if (!S.IsNull()) { @@ -291,7 +309,9 @@ bool TDataXtd_Geometry::Cylinder(const occ::handle& NS, gp_C { const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS); if (shape.IsNull()) + { return false; + } if (shape.ShapeType() == TopAbs_FACE) { const TopoDS_Face& face = TopoDS::Face(shape); @@ -299,7 +319,9 @@ bool TDataXtd_Geometry::Cylinder(const occ::handle& NS, gp_C if (!surface.IsNull()) { if (surface->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { surface = occ::down_cast(surface)->BasisSurface(); + } occ::handle S = occ::down_cast(surface); if (!S.IsNull()) { @@ -419,7 +441,9 @@ void TDataXtd_Geometry::SetType(const TDataXtd_GeometryEnum G) { // OCC2932 correction if (myType == G) + { return; + } Backup(); myType = G; diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_PatternStd.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_PatternStd.cxx index c017c3c572..c74046263b 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_PatternStd.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_PatternStd.cxx @@ -68,7 +68,9 @@ void TDataXtd_PatternStd::Signature(const int signature) { // OCC2932 correction if (mySignature == signature) + { return; + } Backup(); mySignature = signature; @@ -80,8 +82,12 @@ void TDataXtd_PatternStd::Axis1(const occ::handle& Axis1) { // OCC2932 correction if (!myAxis1.IsNull()) + { if (myAxis1->Get() == Axis1->Get()) + { return; + } + } Backup(); myAxis1 = Axis1; @@ -93,8 +99,12 @@ void TDataXtd_PatternStd::Axis2(const occ::handle& Axis2) { // OCC2932 correction if (!myAxis2.IsNull()) + { if (myAxis2->Get() == Axis2->Get()) + { return; + } + } Backup(); myAxis2 = Axis2; @@ -106,7 +116,9 @@ void TDataXtd_PatternStd::Axis1Reversed(const bool Axis1Reversed) { // OCC2932 correction if (myAxis1Reversed == Axis1Reversed) + { return; + } Backup(); myAxis1Reversed = Axis1Reversed; @@ -118,7 +130,9 @@ void TDataXtd_PatternStd::Axis2Reversed(const bool Axis2Reversed) { // OCC2932 correction if (myAxis2Reversed == Axis2Reversed) + { return; + } Backup(); myAxis2Reversed = Axis2Reversed; @@ -130,8 +144,12 @@ void TDataXtd_PatternStd::Value1(const occ::handle& value) { // OCC2932 correction if (!myValue1.IsNull()) + { if (myValue1->Get() == value->Get()) + { return; + } + } Backup(); myValue1 = value; @@ -143,8 +161,12 @@ void TDataXtd_PatternStd::Value2(const occ::handle& value) { // OCC2932 correction if (!myValue2.IsNull()) + { if (myValue2->Get() == value->Get()) + { return; + } + } Backup(); myValue2 = value; @@ -156,8 +178,12 @@ void TDataXtd_PatternStd::NbInstances1(const occ::handle& NbIn { // OCC2932 correction if (!myNb1.IsNull()) + { if (myNb1->Get() == NbInstances1->Get()) + { return; + } + } Backup(); myNb1 = NbInstances1; @@ -169,8 +195,12 @@ void TDataXtd_PatternStd::NbInstances2(const occ::handle& NbIn { // OCC2932 correction if (!myNb2.IsNull()) + { if (myNb2->Get() == NbInstances2->Get()) + { return; + } + } Backup(); myNb2 = NbInstances2; @@ -184,7 +214,9 @@ void TDataXtd_PatternStd::Mirror(const occ::handle& plane) if (!myMirror.IsNull()) { if (myMirror->Get() == plane->Get()) + { return; + } } Backup(); @@ -199,9 +231,13 @@ int TDataXtd_PatternStd::NbTrsfs() const if (mySignature < 5) { if (!myNb1.IsNull()) + { nb = myNb1->Get(); + } if (!myNb2.IsNull()) + { nb = nb * myNb2->Get(); + } nb--; } return nb; @@ -221,7 +257,9 @@ void TDataXtd_PatternStd::ComputeTrsfs(NCollection_Array1& Trsfs) const gp_Ax1 axis1; TDataXtd_Geometry::Axis(myAxis1, axis1); if (myAxis1Reversed) + { axis1.Reverse(); + } double value1 = myValue1->Get(); @@ -246,7 +284,9 @@ void TDataXtd_PatternStd::ComputeTrsfs(NCollection_Array1& Trsfs) const gp_Ax1 axis2; TDataXtd_Geometry::Axis(myAxis2, axis2); if (myAxis2Reversed) + { axis2.Reverse(); + } double value2 = myValue2->Get(); diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Plane.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Plane.cxx index 1b7de6c1b8..6e580654f0 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Plane.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Plane.cxx @@ -62,6 +62,7 @@ occ::handle TDataXtd_Plane::Set(const TDF_Label& L, const gp_Pln if (L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { if (!aNS->Get().IsNull()) + { if (aNS->Get().ShapeType() == TopAbs_FACE) { TopoDS_Face aFace = TopoDS::Face(aNS->Get()); @@ -78,9 +79,12 @@ occ::handle TDataXtd_Plane::Set(const TDF_Label& L, const gp_Pln && aPlane.Axis().Direction().X() == P.Axis().Direction().X() && aPlane.Axis().Direction().Y() == P.Axis().Direction().Y() && aPlane.Axis().Direction().Z() == P.Axis().Direction().Z()) + { return A; + } } } + } } TNaming_Builder B(L); diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Point.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Point.cxx index 9672f66b72..ae18a5f33e 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Point.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Point.cxx @@ -61,12 +61,16 @@ occ::handle TDataXtd_Point::Set(const TDF_Label& L, const gp_Pnt if (L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { if (!aNS->Get().IsNull()) + { if (aNS->Get().ShapeType() == TopAbs_VERTEX) { gp_Pnt anOldPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNS->Get())); if (anOldPnt.X() == P.X() && anOldPnt.Y() == P.Y() && anOldPnt.Z() == P.Z()) + { return A; + } } + } } TNaming_Builder B(L); diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Position.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Position.cxx index 4e7a93ada3..30725d5c90 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Position.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Position.cxx @@ -90,7 +90,9 @@ void TDataXtd_Position::SetPosition(const gp_Pnt& aPos) { // OCC2932 correction if (myPosition.X() == aPos.X() && myPosition.Y() == aPos.Y() && myPosition.Z() == aPos.Z()) + { return; + } Backup(); myPosition = aPos; diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Presentation.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Presentation.cxx index 6e5e8b499f..cc0c64fab7 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Presentation.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Presentation.cxx @@ -303,7 +303,9 @@ void TDataXtd_Presentation::Unset(const TDF_Label& theLabel) { occ::handle aPresentation; if (theLabel.FindAttribute(TDataXtd_Presentation::GetID(), aPresentation)) + { theLabel.ForgetAttribute(aPresentation); + } } //================================================================================================= @@ -474,7 +476,9 @@ void TDataXtd_Presentation::SetSelectionMode(const int theSelectionMode, const b || (GetNbSelectionModes() > 0 && mySelectionModes.First() != theSelectionMode)) { if (theTransaction) + { Backup(); + } mySelectionModes.Clear(); mySelectionModes.Append(theSelectionMode); myHasOwnSelectionMode = true; @@ -488,7 +492,9 @@ void TDataXtd_Presentation::AddSelectionMode(const int theSelectionMode, const b if (!myHasOwnSelectionMode || !HasSelectionMode(theSelectionMode)) { if (theTransaction) + { Backup(); + } mySelectionModes.Append(theSelectionMode); myHasOwnSelectionMode = true; } @@ -538,7 +544,9 @@ int TDataXtd_Presentation::SelectionMode(const int index) const for (int i = 1; itr.More() && i <= index; itr.Next(), i++) { if (i == index) + { aSelectionMode = itr.Value(); + } } return aSelectionMode; } @@ -753,7 +761,9 @@ bool TDataXtd_Presentation::HasSelectionMode(const int theSelectionMode) const for (; itr.More(); itr.Next()) { if (theSelectionMode == itr.Value()) + { ret = true; + } } return ret; } diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Shape.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Shape.cxx index 8650e688a8..9b59d9a460 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Shape.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Shape.cxx @@ -34,14 +34,20 @@ bool TDataXtd_Shape::Find(const TDF_Label& current, occ::handle& TDF_Label L = current; occ::handle SA; if (L.IsNull()) + { return false; + } for (;;) { if (L.FindAttribute(TDataXtd_Shape::GetID(), SA)) + { break; + } L = L.Father(); if (L.IsNull()) + { break; + } } if (!SA.IsNull()) @@ -79,8 +85,12 @@ occ::handle TDataXtd_Shape::Set(const TDF_Label& label, const To if (label.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { if (!aNS->Get().IsNull()) + { if (aNS->Get() == shape) + { return A; + } + } } TNaming_Builder B(label); diff --git a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Triangulation.cxx b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Triangulation.cxx index fb241b37b2..b39562fe24 100644 --- a/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Triangulation.cxx +++ b/src/ApplicationFramework/TKCAF/TDataXtd/TDataXtd_Triangulation.cxx @@ -211,7 +211,9 @@ void TDataXtd_Triangulation::Restore(const occ::handle& theAttrib { occ::handle T = M->myTriangulation->Copy(); if (!T.IsNull()) + { myTriangulation = T; + } } } @@ -226,7 +228,9 @@ void TDataXtd_Triangulation::Paste(const occ::handle& theIntoAttr { occ::handle T = myTriangulation->Copy(); if (!T.IsNull()) + { M->myTriangulation = T; + } } } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming.cxx index c433796c8e..65a111c9c9 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming.cxx @@ -59,7 +59,9 @@ static void MapShapes(const TopoDS_Shape& SCible, while (icible.More()) { if (!M.IsBound(icible.Value())) + { MapShapes(icible.Value(), isource.Value(), M); + } icible.Next(); isource.Next(); } @@ -78,12 +80,16 @@ static void MapShapes(const TDF_Label& LCible, if (!icible.OldShape().IsNull()) { if (!M.IsBound(icible.OldShape())) + { MapShapes(icible.OldShape(), isource.OldShape(), M); + } } if (!icible.NewShape().IsNull()) { if (!M.IsBound(icible.NewShape())) + { MapShapes(icible.NewShape(), isource.NewShape(), M); + } } icible.Next(); isource.Next(); @@ -108,7 +114,7 @@ static void SubstituteShape( { if (oldShape.IsSame(newShape)) { - std::cout << "import_tool::Substitute : oldShape IsSame newShape" << std::endl; + std::cout << "import_tool::Substitute : oldShape IsSame newShape" << '\n'; } if (!amap.IsBound(oldShape)) @@ -177,11 +183,15 @@ bool TNaming::SubstituteSShape(const TDF_Label& Lab, const TopoDS_Shape& From, T Lab.Root().FindAttribute(TNaming_UsedShapes::GetID(), US); NCollection_DataMap& amap = US->Map(); if (!amap.IsBound(To)) + { return false; + } TNaming_RefShape* pos; pos = amap.ChangeFind(To); if (!amap.UnBind(To)) + { return false; + } // update shape To.Orientation(From.Orientation()); pos->Shape(To); @@ -195,7 +205,9 @@ static bool Rebuild(const TopoDS_Shape& { bool IsModified = false; if (M.IsBound(S)) + { return IsModified; + } BRep_Builder B; TopoDS_Iterator iteS(S.Oriented(TopAbs_FORWARD)); @@ -205,7 +217,9 @@ static bool Rebuild(const TopoDS_Shape& { const TopoDS_Shape& SS = iteS.Value(); if (Rebuild(SS, M)) + { IsModified = true; + } } if (!IsModified) { @@ -252,14 +266,18 @@ void TNaming::Update(const TDF_Label& { const TopoDS_Shape& S = it.OldShape(); if (!M.IsBound(S)) + { Rebuild(S, M); + } SubstituteShape(S, M(S), amap); } if (!it.NewShape().IsNull()) { const TopoDS_Shape& S = it.NewShape(); if (!M.IsBound(S)) + { Rebuild(S, M); + } SubstituteShape(S, M(S), amap); } } @@ -386,9 +404,13 @@ void TNaming::Displace(const TDF_Label& L, const TopLoc_Location& Loc, const boo const TopoDS_Shape& SN = itNews.Value(); OS = SO; if (WithOld && !SO.IsNull()) + { OS = SO.Moved(Loc); + } if (!SN.IsNull()) + { NS = SN.Moved(Loc); + } LoadNamedShape(B, Evol, OS, NS); } @@ -410,7 +432,9 @@ static void Replace( TNaming_Iterator it(L); if (!it.More()) + { return; + } Evol = it.Evolution(); TNaming_Builder B(L); @@ -423,13 +447,17 @@ static void Replace( { OS = it.OldShape(); if (M.IsBound(OS)) + { OS = M(OS); + } } if (!it.NewShape().IsNull()) { NS = it.NewShape(); if (M.IsBound(NS)) + { NS = M(NS); + } } LoadNamedShape(B, Evol, OS, NS); } @@ -509,7 +537,9 @@ void TNaming::Replicate(const TopoDS_Shape& SH, const gp_Trsf& T, const TDF_Labe // sub shape TopAbs_ShapeEnum SST = TopAbs_FACE; if (SH.ShapeType() == TopAbs_FACE || SH.ShapeType() == TopAbs_WIRE) + { SST = TopAbs_EDGE; + } TNaming_Builder Builder2(L.FindChild(1, true)); for (TopExp_Explorer exp(SH, SST); exp.More(); exp.Next()) @@ -527,9 +557,13 @@ static TopoDS_Shape ShapeCopy( NCollection_DataMap& M) { if (S.IsNull()) + { return S; + } if (M.IsBound(S)) + { return M(S); + } //---------------------------- // construction de la copie. // 1- copie des sous shapes. @@ -731,9 +765,13 @@ static void BuildMapIn(const TopoDS_Shape& Context, TopAbs_ShapeEnum aType; if ((Context.ShapeType() == TopAbs_SOLID || Context.ShapeType() == TopAbs_FACE) && (StopType - Context.ShapeType()) != 1) + { aType = (TopAbs_ShapeEnum)(Context.ShapeType() + 2); + } else + { aType = (TopAbs_ShapeEnum)(Context.ShapeType() + 1); + } for (TopExp_Explorer exp(Context, aType); exp.More(); exp.Next()) { #ifdef OCCT_DEBUG @@ -791,7 +829,9 @@ static void BuildMapC0(const TopoDS_Shape& Context, BuildMapC0(aKey, Context, StopType, Map); } else + { BuildMapIn(aKey, StopType, Map); + } } anIt.Next(); } @@ -818,9 +858,13 @@ static void BuildMap(const TopoDS_Shape& Context, if (aKey.ShapeType() < StopType) { if (aKey.ShapeType() < TopAbs_SOLID) + { BuildMapC0(aKey, Context, StopType, Map); + } else + { BuildMapIn(aKey, StopType, Map); + } } anIt.Next(); } @@ -845,7 +889,9 @@ TopoDS_Shape TNaming::FindUniqueContext(const TopoDS_Shape& Selection, const Top } #endif if (aMap.IsBound(Selection)) + { return aMap.Find(Selection); + } return TopoDS_Shape(); } @@ -868,16 +914,24 @@ TopoDS_Shape TNaming::FindUniqueContextSet(const TopoDS_Shape& Selection, { const TopoDS_Shape& aS = anIter.Value(); if (aS.ShapeType() > aStopType) + { aStopType = aS.ShapeType(); + } Up++; } if (Up > 0) + { Arr = new NCollection_HArray1(1, Up); + } if (aStopType == TopAbs_SHAPE) + { aStopType = Selection.ShapeType(); + } BuildMap(Context, aStopType, aMap); if (aMap.IsBound(Selection)) + { return aMap.Find(Selection); + } else if (Selection.ShapeType() == TopAbs_COMPOUND) { int num1(0), num2(0); @@ -895,14 +949,20 @@ TopoDS_Shape TNaming::FindUniqueContextSet(const TopoDS_Shape& Selection, B.Add(CompShape, aMap.Find(it.Value())); } if (!Arr.IsNull()) + { Arr->SetValue(num1 + 1, aMap.Find(it.Value())); + } if (aMap.Find(it.Value()) == Context) + { num2++; + } } } if (num1 == num2 && num2) + { return Context; + } else { TopoDS_Iterator anIt(CompShape); @@ -949,7 +1009,9 @@ bool TNaming::OuterWire(const TopoDS_Face& theFace, TopoDS_Wire& theWire) aFC.Init(aFx, aTol); bFlag = aFC.IsHole(); if (!bFlag) + { break; + } } theWire = aWx; return !bFlag; // if bFlag == True - not found @@ -991,9 +1053,13 @@ bool TNaming::OuterShell(const TopoDS_Solid& theSolid, TopoDS_Shell& theShell) const TopoDS_Shape& aSx = aIt.Value(); if (aSx.ShapeType() != TopAbs_SHELL) + { continue; + } if (IsInternal(aSx)) + { continue; + } // aSHx = *((TopoDS_Shell*)&aSx); // diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_CopyShape.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_CopyShape.cxx index 0a15026131..d5915b4552 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_CopyShape.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_CopyShape.cxx @@ -42,7 +42,9 @@ void TNaming_CopyShape::Translate(const TopoDS_Shape& aShape, aResult.Nullify(); if (aShape.IsNull()) + { return; + } if (aMap.Contains(aShape.TShape())) { @@ -151,7 +153,9 @@ static occ::handle TranslateDatum3D( { occ::handle TD; if (aMap.Contains(D)) + { TD = occ::down_cast(aMap.FindFromKey(D)); + } else { TD = new TopLoc_Datum3D(D->Transformation()); diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_DeltaOnModification.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_DeltaOnModification.cxx index 00d2e1c6cf..a4312d62ed 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_DeltaOnModification.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_DeltaOnModification.cxx @@ -36,7 +36,9 @@ TNaming_DeltaOnModification::TNaming_DeltaOnModification(const occ::handleEvolution(); int i = 1; @@ -122,7 +124,9 @@ void TNaming_DeltaOnModification::Apply() } if (myOld.IsNull() && myNew.IsNull()) + { return; + } else if (myOld.IsNull()) { // TNaming_Builder B(Ins); diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Identifier.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Identifier.cxx index d2bf89c586..6d55c1105a 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Identifier.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Identifier.cxx @@ -183,9 +183,13 @@ bool TNaming_Identifier::ArgIsFeature() const void TNaming_Identifier::NextArg() { if (!myPrimitiveArgs.IsEmpty()) + { myPrimitiveArgs.RemoveFirst(); + } else if (!myShapeArgs.IsEmpty()) + { myShapeArgs.RemoveFirst(); + } } //================================================================================================= @@ -242,7 +246,9 @@ void TNaming_Identifier::AncestorIdentification(TNaming_Localizer& Localizer, myType = TNaming_INTERSECTION; NCollection_Map::Iterator itS(AncInFeature); for (; itS.More(); itS.Next()) + { myShapeArgs.Append(itS.Key()); + } myDone = true; } @@ -255,12 +261,16 @@ bool IsImported(const occ::handle& NS) for (TDF_ChildIterator cit(Father); cit.More(); cit.Next()) { if (cit.Value() != Lab) + { return false; + } } TNaming_Iterator it(NS); if (!it.More()) + { return false; + } it.Next(); return it.More(); } @@ -315,10 +325,14 @@ void TNaming_Identifier::Identification(TNaming_Localizer& L myType = TNaming_INTERSECTION; NCollection_Map>::Iterator itP(Primitives); for (; itP.More(); itP.Next()) + { myPrimitiveArgs.Append(itP.Key()); + } NCollection_Map::Iterator itS(Shapes); for (; itS.More(); itS.Next()) + { myShapeArgs.Append(itS.Key()); + } if (myPrimitiveArgs.Extent() == 1 && myShapeArgs.IsEmpty()) { diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Localizer.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Localizer.cxx index e2ac61da70..eb0d45aee4 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Localizer.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Localizer.cxx @@ -242,9 +242,13 @@ const NCollection_IndexedDataMap= In.ShapeType()) { TopExp::MapShapesAndAncestors(In, TS, TA, Anc); @@ -270,11 +274,17 @@ const NCollection_IndexedDataMap= In.ShapeType()) { TopExp::MapShapesAndAncestors(In, TS, TA, myAncestors.First()); @@ -330,7 +340,9 @@ void TNaming_Localizer::GoBack(const TopoDS_Shape& const TDF_Label& Father = Lab.Father(); TNaming_Iterator itLab(Father); if (itLab.More()) + { Sol = itLab.OldShape(); + } //------------------------------------------- // Recherche des ancetres dans des features. //------------------------------------------- @@ -559,16 +571,24 @@ void TNaming_Localizer::FindNeighbourg( NCollection_Map& Neighbourg) { if (Sol.IsNull() || S.IsNull()) + { return; + } TopAbs_ShapeEnum TA = S.ShapeType(); TopAbs_ShapeEnum TS = TopAbs_COMPOUND; if (TA == TopAbs_FACE) + { TS = TopAbs_EDGE; + } if (TA == TopAbs_EDGE) + { TS = TopAbs_VERTEX; + } if (TA == TopAbs_VERTEX) + { TS = TopAbs_VERTEX; // szy 30.03.10 + } const NCollection_IndexedDataMap, TopTools_ShapeMapHasher>& Anc = Ancestors(Sol, TS); @@ -664,7 +684,9 @@ void TNaming_Localizer::FindShapeContext(const occ::handle& LWrite(SC, "FSC_OldShape.brep"); #endif if (SC.IsNull()) + { continue; + } else { if (SC.ShapeType() < S.ShapeType()) @@ -682,7 +704,9 @@ void TNaming_Localizer::FindShapeContext(const occ::handle& } } if (found) + { break; + } } } } @@ -707,10 +731,14 @@ void TNaming_Localizer::FindShapeContext(const occ::handle& { aShape = anIter.NewShape(); if (!aShape.IsNull()) + { break; + } } if (!aShape.IsNull()) + { SC = aShape; + } } } } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Name.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Name.cxx index a280522e01..0f845d8799 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Name.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Name.cxx @@ -244,7 +244,9 @@ static TopoDS_Shape MakeShape( BRep_Builder B; B.MakeCompound(C); for (int anIt = 1; anIt <= MS.Extent(); ++anIt) + { B.Add(C, MS(anIt)); + } return C; } } @@ -256,29 +258,43 @@ static TopoDS_Shape MakeShape( static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) { if (theShape.IsNull() || theType == TopAbs_SHAPE) + { return theShape; + } int aType = theShape.ShapeType(); if (aType == theType) + { return theShape; + } NCollection_List aShapes; if (aType == TopAbs_COMPOUND) { TopoDS_Iterator anIter(theShape); if (anIter.More()) + { aType = anIter.Value().ShapeType(); + } for (; anIter.More(); anIter.Next()) + { aShapes.Append(anIter.Value()); + } if (aType == theType) { if (aShapes.Extent() == 1) + { return aShapes.First(); + } else + { return theShape; + } } } else + { aShapes.Append(theShape); + } TopoDS_Shape aResult; NCollection_List::Iterator aListIter(aShapes); @@ -296,12 +312,16 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha aResult = anExp.Current(); aCount++; if (aCount > 1) + { return theShape; + } } } } if (aCount == 1) + { return aResult; + } } else { // if the shape type more complex than shapes from aShapes list, try make it @@ -312,13 +332,19 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha case TopAbs_EDGE: { // make wire from edges if (theType <= TopAbs_SOLID) + { break; + } BRepBuilderAPI_MakeWire aMakeWire; aMakeWire.Add(aShapes); if (!aMakeWire.IsDone()) + { return theShape; + } if (theType == TopAbs_WIRE) + { return aMakeWire.Wire(); + } aShapes.Clear(); // don't break: we can do something more of it aShapes.Append(aMakeWire.Wire()); aListIter.Initialize(aShapes); @@ -327,18 +353,24 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha case TopAbs_WIRE: { // make faceS from wires (one per one) if (theType < TopAbs_SOLID) + { break; + } NCollection_List aFaces; for (; aListIter.More(); aListIter.Next()) { BRepBuilderAPI_MakeFace aMakeFace(TopoDS::Wire(aListIter.Value())); if (!aMakeFace.IsDone()) + { aFaces.Append(aMakeFace.Face()); + } } if (theType == TopAbs_FACE) { if (aFaces.Extent() == 1) + { return aFaces.First(); + } return theShape; } aShapes.Assign(aFaces); // don't break: we can do something more of it @@ -348,15 +380,21 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha case TopAbs_FACE: { // make shell from faces if (theType < TopAbs_SOLID) + { break; + } BRep_Builder aShellBuilder; TopoDS_Shell aShell; aShellBuilder.MakeShell(aShell); for (; aListIter.More(); aListIter.Next()) + { aShellBuilder.Add(aShell, TopoDS::Face(aListIter.Value())); + } aShell.Closed(BRep_Tool::IsClosed(aShell)); if (theType == TopAbs_SHELL) + { return aShell; + } aShapes.Clear(); // don't break: we can do something more of it aShapes.Append(aShell); aListIter.Initialize(aShapes); @@ -369,12 +407,16 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha { BRepBuilderAPI_MakeSolid aMakeSolid(TopoDS::Shell(aListIter.Value())); if (aMakeSolid.IsDone()) + { aSolids.Append(aMakeSolid.Solid()); + } } if (theType == TopAbs_SOLID) { if (aSolids.Extent() == 1) + { return aSolids.First(); + } return theShape; } aShapes.Assign(aSolids); // don't break: we can do something more of it @@ -387,9 +429,13 @@ static TopoDS_Shape ShapeWithType(const TopoDS_Shape& theShape, const TopAbs_Sha TopoDS_CompSolid aCompSolid; aCompBuilder.MakeCompSolid(aCompSolid); for (; aListIter.More(); aListIter.Next()) + { aCompBuilder.Add(aCompSolid, TopoDS::Solid(aListIter.Value())); + } if (theType == TopAbs_COMPSOLID) + { return aCompSolid; + } } } } @@ -480,7 +526,9 @@ static bool ModifUntil(const TDF_Label& NCollection_IndexedMap MS; NCollection_Map Forbiden; if (!ValidArgs(Args)) + { return false; + } TNaming_NamingTool::BuildDescendants(Stop, Forbiden); // fills Forbidden from Stop // all last modifications of the last argument TNaming_NamingTool::CurrentShape(Valid, Forbiden, Args.Last(), MS); @@ -509,7 +557,9 @@ static bool ConstShape(const TDF_Label& NCollection_IndexedMap MS; NCollection_Map Forbiden; if (!ValidArgs(Args)) + { return false; + } TNaming_NamingTool::BuildDescendants(Stop, Forbiden); TopoDS_Shape S; @@ -523,7 +573,9 @@ static bool ConstShape(const TDF_Label& } } if (S.IsNull()) + { return false; + } TNaming_NamingTool::CurrentShapeFromShape(Valid, Forbiden, L, S, MS); @@ -557,9 +609,13 @@ static bool Intersection(const TDF_Label& const int Index) { if (Args.IsEmpty()) + { return false; + } if (!ValidArgs(Args)) + { return false; + } NCollection_List>::Iterator it(Args); NCollection_IndexedMap MS; NCollection_Map Forbiden; @@ -607,9 +663,13 @@ static bool Intersection(const TDF_Label& int aCaseW(0); int aNbW = aS.NbChildren(); if (aNbW == nbW) + { aCaseW = 1; // exact solution for wire (nb of wires is kept) + } else + { aCaseW = 2; // indefinite description ==> compound which can include expected wire + } if (aCaseW == 1) { TopoDS_Shape aWire; @@ -625,9 +685,13 @@ static bool Intersection(const TDF_Label& int aCaseE(0); int aNbE = aWire.NbChildren(); if (aNbE == nbE) + { aCaseE = 1; // exact solution for edge + } else + { aCaseE = 2; + } if (aCaseE == 1) { i = 1; @@ -667,7 +731,9 @@ static void KeepInList(const TopoDS_Shape& CS, NCollection_List& aList) { if (CS.IsNull()) + { return; + } if (Type == TopAbs_SHAPE) { @@ -714,9 +780,13 @@ static bool Union(const TDF_Label& L, const TDF_Label& ContextLabel) { if (Args.IsEmpty()) + { return false; + } if (!ValidArgs(Args)) + { return false; + } // temporary solution for Orientation name bool isOr(true); /* not completed @@ -755,8 +825,9 @@ static bool Union(const TDF_Label& L, TopoDS_Shape CS = MakeShape(MS); NCollection_List aListS; - if(isOr) + if(isOr) { KeepInList(CS,ShapeType,aListS); +} TNaming_ShapesSet S(CS,ShapeType);//fill internal map of shapeset by shapes of the specified type // clang-format on it.Next(); @@ -768,7 +839,9 @@ static bool Union(const TDF_Label& L, // clang-format on CS = MakeShape(MS); if (isOr) + { KeepInList(CS, ShapeType, aListS); + } TNaming_ShapesSet OS(CS, ShapeType); S.Add(OS); // concatenate both shapesets } @@ -789,7 +862,9 @@ static bool Union(const TDF_Label& L, } NCollection_List aList; for (TopExp_Explorer anExpl(aContext, ShapeType); anExpl.More(); anExpl.Next()) + { aList.Append(anExpl.Current()); + } NCollection_List::Iterator itl(aList); for (; itl.More(); itl.Next()) { @@ -800,7 +875,9 @@ static bool Union(const TDF_Label& L, anExpl.Next()) { if (S.Map().Contains(anExpl.Current())) + { num--; + } } if (num == 0) { @@ -813,24 +890,30 @@ static bool Union(const TDF_Label& L, TNaming_Builder B(L); if (found) + { B.Select(aCand, aCand); + } else { BRep_Builder aCompoundBuilder; TopoDS_Compound aCompound; aCompoundBuilder.MakeCompound(aCompound); if (!isOr) + { for (NCollection_Map::Iterator itM(S.Map()); itM.More(); itM.Next()) { aCompoundBuilder.Add(aCompound, itM.Key()); } + } else + { for (NCollection_List::Iterator itL(aListS); itL.More(); itL.Next()) { aCompoundBuilder.Add(aCompound, itL.Value()); } + } TopoDS_Shape aShape = ShapeWithType(aCompound, ShapeType); B.Select(aShape, aShape); } @@ -845,7 +928,9 @@ static TopoDS_Shape FindShape( TopoDS_Shape aResult; int aNum = DM.Extent(); if (aNum < 1) + { return aResult; + } NCollection_List List; NCollection_DataMap>::Iterator it(DM); if (it.More()) @@ -863,19 +948,29 @@ static TopoDS_Shape FindShape( { const TopoDS_Shape& aKey2 = it2.Key(); if (aKey2 == aKey1) + { continue; + } const NCollection_Map& aMap2 = it2.Value(); if (!aMap2.Contains(aS)) + { isCand = false; + } } if (isCand) + { List.Append(aS); + } } } if (List.IsEmpty()) + { return aResult; + } if (List.Extent() == 1) + { return List.First(); + } NCollection_List::Iterator itl(List); TopoDS_Compound Compound; BRep_Builder B; @@ -904,7 +999,9 @@ static bool Generated(const TDF_Label& L // Next arguments : generators. if (!ValidArgs(Args)) + { return false; + } TDF_Label LabelOfGeneration = Args.First()->Label(); // Nouvell valeurs des generateurs dans l attribut de generation @@ -917,12 +1014,16 @@ static bool Generated(const TDF_Label& L TopoDS_Shape aSelection; L.FindAttribute(TNaming_Naming::GetID(), aNaming); if (!aNaming.IsNull()) + { aSelection = aNaming->GetName().Shape(); + } occ::handle anOldNS; int aVer = -1; // Initial build of name L.FindAttribute(TNaming_NamedShape::GetID(), anOldNS); if (!anOldNS.IsNull()) + { aVer = anOldNS->Version(); + } TNaming_Builder B(L); // NS NCollection_List aList; NCollection_DataMap> aDM; @@ -931,13 +1032,17 @@ static bool Generated(const TDF_Label& L const TopoDS_Shape& OS = aMS(anItMS); NCollection_Map aMapDM; for (TNaming_NewShapeIterator itNew(OS, L); itNew.More(); itNew.Next()) + { if (itNew.Label() == LabelOfGeneration) { aMapDM.Add(itNew.Shape()); aList.Append(itNew.Shape()); // szy 21.10.03 } + } if (aMapDM.Extent()) + { aDM.Bind(OS, aMapDM); + } } if (aVer == -1) @@ -960,7 +1065,9 @@ static bool Generated(const TDF_Label& L else { // Selection == Null for (; it.More(); it.Next()) + { B.Select(it.Value(), it.Value()); + } } } else @@ -978,16 +1085,22 @@ static bool Generated(const TDF_Label& L NCollection_List::Iterator it(aList); for (; it.More(); it.Next()) { - if (it.Value().ShapeType() == aType) // collect only the same type + if (it.Value().ShapeType() == aType) + { // collect only the same type aList2.Append(it.Value()); + } } if (!aList2.Extent()) + { return false; // Empty + } bool found = false; TopoDS_Shape aShape = FindShape(aDM); if (!aShape.IsNull()) + { found = true; + } if (found) { NCollection_List aLM; @@ -1001,7 +1114,9 @@ static bool Generated(const TDF_Label& L itg.Next()) { if (!aMS.Contains(itg.Value()->Get())) + { aLM.Append(itg.Value()->Get()); + } } if (aLM.Extent() == 1) { // lost 1 @@ -1055,18 +1170,24 @@ static bool Generated(const TDF_Label& L // } } } - if (!aHas) // all arguments were kept + if (!aHas) + { // all arguments were kept B.Select(aShape, aShape); // only this case is correct on 100% + } else { - if (a1NB) // Has, but may be ... + if (a1NB) + { // Has, but may be ... B.Select(aShape, aShape); + } else { // put Compound, may be if possible processed later in Sel. Driver NCollection_List::Iterator it1(aList2); for (; it1.More(); it1.Next()) + { B.Select(it1.Value(), it1.Value()); + } } } } @@ -1074,7 +1195,9 @@ static bool Generated(const TDF_Label& L { // not found NCollection_List::Iterator it2(aList2); for (; it2.More(); it2.Next()) + { B.Select(it2.Value(), it2.Value()); + } } } } @@ -1095,7 +1218,9 @@ static bool Identity(const TDF_Label& L, throw Standard_ConstructionError("TNaming_Name::Solve"); } if (!ValidArgs(Args)) + { return false; + } const occ::handle& A = Args.First(); NCollection_IndexedMap MS; NCollection_Map Forbiden; @@ -1124,12 +1249,16 @@ static bool FilterByNeighbourgs(const TDF_Label& NCollection_Map Forbiden; if (!ValidArgs(Args)) + { return false; + } // clang-format off TNaming_NamingTool::BuildDescendants (Stop, Forbiden); //all descendants of Stop (New shapes) are forbidden // clang-format on if (!Stop.IsNull()) + { Forbiden.Remove(Stop->Label()); + } //---------------------------------------- // First argument: collection has to be filtered. //---------------------------------------- @@ -1146,35 +1275,46 @@ static bool FilterByNeighbourgs(const TDF_Label& //------------------------------------------------------------ TopAbs_ShapeEnum TC = TopAbs_EDGE; if (ShapeType == TopAbs_EDGE) + { TC = TopAbs_VERTEX; + } // clang-format off - if (ShapeType == TopAbs_VERTEX) TC = TopAbs_VERTEX; // szy 31.03.10 - to process case when Candidate is of type Vertex + if (ShapeType == TopAbs_VERTEX) { TC = TopAbs_VERTEX; // szy 31.03.10 - to process case when Candidate is of type Vertex +} // clang-format on bool isDone = false; if (SCand.Extent() == 1) { // check if a collection is inside TopoDS_Shape aS = SCand(1); if (!aS.IsNull()) + { if (aS.ShapeType() == TopAbs_COMPOUND && aS.ShapeType() != ShapeType) { SCand.Clear(); TopoDS_Iterator itt(aS); for (; itt.More(); itt.Next()) + { SCand.Add(itt.Value()); + } } + } } for (int anItSCand = 1; anItSCand <= SCand.Extent(); ++anItSCand) { // 1 const TopoDS_Shape& S = SCand(anItSCand); NCollection_Map Boundaries; - if (S.ShapeType() == TopAbs_VERTEX) // # szy 31.03.10 - Boundaries.Add(S); // # - else // # - // clang-format off + if (S.ShapeType() == TopAbs_VERTEX) + { // # szy 31.03.10 + Boundaries.Add(S); // # + } + else + { // # + // clang-format off for (TopExp_Explorer exp(S,TC); exp.More(); exp.Next()) { //put boundaries of each candidate (from SCand) to the Boundaries map // clang-format on Boundaries.Add(exp.Current()); } + } NCollection_List>::Iterator it(Args); it.Next(); @@ -1205,7 +1345,9 @@ static bool FilterByNeighbourgs(const TDF_Label& } } // 7 if (Connected) + { break; + } } // 6 if (!Connected) { @@ -1231,7 +1373,9 @@ static const TopoDS_Shape FindSubShapeInAncestor(const TopoDS_Shape& Selection, for (TopExp_Explorer anExpl(Context, Selection.ShapeType()); anExpl.More(); anExpl.Next()) { if (anExpl.Current().IsSame(Selection)) + { return anExpl.Current(); + } } } @@ -1257,7 +1401,9 @@ static int Aggregation(const TopoDS_Shape& S, const TopoDS_Shape& AS, TNaming_Bu } } else + { N += Aggregation(sel, AS, B); + } } return N; } @@ -1274,7 +1420,9 @@ static bool ORientation(const TDF_Label& { if (!ValidArgs(Args)) + { return false; + } const occ::handle& A = Args.First(); NCollection_IndexedMap MS; @@ -1299,7 +1447,9 @@ static bool ORientation(const TDF_Label& TNaming_Builder B(L); if (aShape.IsNull()) + { return false; + } NCollection_List aSList; // tmp. solution @@ -1307,7 +1457,9 @@ static bool ORientation(const TDF_Label& { TopoDS_Iterator it(aShape); for (; it.More(); it.Next()) + { aSList.Append(it.Value()); + } } // NCollection_IndexedMap MSC; @@ -1340,11 +1492,15 @@ static bool ORientation(const TDF_Label& } } if (found) + { break; + } } } else + { CS = FindSubShapeInAncestor(aShape, AS); + } if (!CS.IsNull()) { B.Select(CS, CS); @@ -1352,7 +1508,9 @@ static bool ORientation(const TDF_Label& else { if (!Aggregation(aShape, AS, B)) + { return false; + } } } } @@ -1367,7 +1525,9 @@ static bool ORientation(const TDF_Label& else { if (!Aggregation(aShape, AS, B)) + { return false; + } } } } @@ -1409,7 +1569,9 @@ static bool ORientation(const TDF_Label& B.Select(CS, CS); } else + { return false; + } } else { @@ -1433,7 +1595,9 @@ static bool ORientation(const TDF_Label& B.Select(CS, CS); } else + { return false; + } } else { @@ -1459,15 +1623,21 @@ static bool WireIN(const TDF_Label& L, { bool aResult(false); if (!ValidArgs(Args)) + { return aResult; + } NCollection_IndexedMap aMapOfSh; NCollection_Map aForbiden; if (Args.Extent() < 1) + { throw Standard_ConstructionError("TNaming_Name::Solve"); + } const occ::handle& A = Args.First(); TNaming_NamingTool::CurrentShape(Valid, aForbiden, A, aMapOfSh); if (aMapOfSh.Extent() != 1) + { return aResult; + } const TopoDS_Shape& aCF = aMapOfSh(1); TNaming_Builder B(L); if (Index == 1) @@ -1520,7 +1690,9 @@ static bool WireIN(const TDF_Label& L, NCollection_Map aView; int aNum(0x7FFFFFFF); for (TopoDS_Iterator it(S); it.More(); it.Next()) + { aView.Add(it.Value()); // edges of wire of the face in map + } NCollection_Map::Iterator it(aSet.Map()); aNum = aView.Extent(); @@ -1556,7 +1728,9 @@ static bool WireIN(const TDF_Label& L, if (!S.IsNull() && S.ShapeType() == TopAbs_WIRE) { if (S.IsEqual(anOuterWire)) + { continue; + } B.Select(S, S); } } @@ -1578,15 +1752,21 @@ static bool ShellIN(const TDF_Label& L, { bool aResult(false); if (!ValidArgs(Args)) + { return aResult; + } NCollection_IndexedMap aMapOfSh; NCollection_Map aForbiden; if (Args.Extent() < 1) + { throw Standard_ConstructionError("TNaming_Name::Solve"); + } const occ::handle& A = Args.First(); TNaming_NamingTool::CurrentShape(Valid, aForbiden, A, aMapOfSh); if (aMapOfSh.Extent() != 1) + { return aResult; + } const TopoDS_Shape& aCSO = aMapOfSh(1); TNaming_Builder B(L); if (Index == 1) @@ -1639,7 +1819,9 @@ static bool ShellIN(const TDF_Label& L, NCollection_Map aView; int aNum(0x7FFFFFFF); for (TopoDS_Iterator it(S); it.More(); it.Next()) + { aView.Add(it.Value()); // faces of shell of the solid in map + } aNum = aView.Extent(); if (aNum == aSet.Map().Extent()) @@ -1675,7 +1857,9 @@ static bool ShellIN(const TDF_Label& L, if (!S.IsNull() && S.ShapeType() == TopAbs_SHELL) { if (S.IsEqual(anOuterShell)) + { continue; + } B.Select(S, S); } } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamedShape.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamedShape.cxx index 171bb42b7a..8ba5b5b457 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamedShape.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamedShape.cxx @@ -102,9 +102,13 @@ public: TNaming_Node* TNaming_Node::NextSameShape(TNaming_RefShape* prs) { if (myOld == prs) + { return nextSameOld; + } if (myNew == prs) + { return nextSameNew; + } return nextSameNew; } @@ -177,12 +181,16 @@ static void RemoveNode( { TNaming_Node* nextOld = N->nextSameOld; if (nextOld != nullptr) + { pos->FirstUse(nextOld); + } else { // le shape disparait if (MapExist) + { M.UnBind(pos->Shape()); + } N->myOld = nullptr; if (pos != N->myNew) { @@ -200,9 +208,13 @@ static void RemoveNode( if (pdn->NextSameShape(pos) == N) { if (pdn->myOld == pos) + { pdn->nextSameOld = N->nextSameOld; + } else + { pdn->nextSameNew = N->nextSameOld; + } break; } pdn = pdn->NextSameShape(pos); @@ -217,12 +229,16 @@ static void RemoveNode( { TNaming_Node* nextNew = N->nextSameNew; if (nextNew != nullptr) + { pns->FirstUse(nextNew); + } else { // le shape disparait if (MapExist) + { M.UnBind(pns->Shape()); + } pns->FirstUse(nullptr); delete pns; @@ -239,9 +255,13 @@ static void RemoveNode( if (pdn->NextSameShape(pns) == N) { if (pdn->myOld == pns) + { pdn->nextSameOld = N->nextSameNew; + } else + { pdn->nextSameNew = N->nextSameNew; + } break; } pdn = pdn->NextSameShape(pns); @@ -271,7 +291,9 @@ void TNaming_NamedShape::Clear() bool MapExist = Label().Root().FindAttribute(TNaming_UsedShapes::GetID(), US); if (MapExist) + { M = &(US->Map()); + } TNaming_Node* p = myNode; while (p != nullptr) @@ -328,7 +350,9 @@ bool TNaming_NamedShape::AfterUndo(const occ::handle& anAttD bool MapExist = anAttDelta->Label().Root().FindAttribute(TNaming_UsedShapes::GetID(), US); if (MapExist) + { M = &(US->Map()); + } TNaming_Node* p = myNode; while (p != nullptr) @@ -451,13 +475,21 @@ void TNaming_NamedShape::Paste(const occ::handle& into, // Modification_1 24.06.99 (szy) TopoDS_Shape copOS, copNS; if (aStatus != TNaming_PRIMITIVE) + { TNaming_CopyShape::CopyTool(OS, Tab->TransientTable(), copOS); + } else + { copOS.Nullify(); + } if (aStatus != TNaming_DELETE) + { TNaming_CopyShape::CopyTool(NS, Tab->TransientTable(), copNS); + } else + { copNS.Nullify(); + } switch (aStatus) { @@ -601,9 +633,13 @@ static void UpdateFirstUseOrNextSameShape(TNaming_RefShape*& prs, TNaming_Node*& if (ldn != pdn) { if (ldn->myOld == prs) + { ldn->nextSameOld = pdn; + } if (ldn->myNew == prs) + { ldn->nextSameNew = pdn; + } } } } @@ -613,11 +649,15 @@ static void UpdateFirstUseOrNextSameShape(TNaming_RefShape*& prs, TNaming_Node*& void TNaming_Builder::Generated(const TopoDS_Shape& newShape) { if (myAtt->myNode == nullptr) + { myAtt->myEvolution = TNaming_PRIMITIVE; + } else { if (myAtt->myEvolution != TNaming_PRIMITIVE) + { throw Standard_ConstructionError("TNaming_Builder : not same evolution"); + } } TNaming_RefShape* pos = nullptr; @@ -652,18 +692,24 @@ void TNaming_Builder::Generated(const TopoDS_Shape& newShape) void TNaming_Builder::Delete(const TopoDS_Shape& oldShape) { if (myAtt->myNode == nullptr) + { myAtt->myEvolution = TNaming_DELETE; + } else { if (myAtt->myEvolution != TNaming_DELETE) + { throw Standard_ConstructionError("TNaming_Builder : not same evolution"); + } } TNaming_RefShape* pns; TNaming_RefShape* pos; if (myShapes->myMap.IsBound(oldShape)) + { pos = myShapes->myMap.ChangeFind(oldShape); + } else { #ifdef OCCT_DEBUG_BUILDER @@ -688,11 +734,15 @@ void TNaming_Builder::Delete(const TopoDS_Shape& oldShape) void TNaming_Builder::Generated(const TopoDS_Shape& oldShape, const TopoDS_Shape& newShape) { if (myAtt->myNode == nullptr) + { myAtt->myEvolution = TNaming_GENERATED; + } else { if (myAtt->myEvolution != TNaming_GENERATED) + { throw Standard_ConstructionError("TNaming_Builder : not same evolution"); + } } if (oldShape.IsSame(newShape)) @@ -709,7 +759,9 @@ void TNaming_Builder::Generated(const TopoDS_Shape& oldShape, const TopoDS_Shape myShapes->myMap.Bind(oldShape, pos); } else + { pos = myShapes->myMap.ChangeFind(oldShape); + } TNaming_RefShape* pns; if (!myShapes->myMap.IsBound(newShape)) @@ -718,7 +770,9 @@ void TNaming_Builder::Generated(const TopoDS_Shape& oldShape, const TopoDS_Shape myShapes->myMap.Bind(newShape, pns); } else + { pns = myShapes->myMap.ChangeFind(newShape); + } TNaming_Node* pdn = new TNaming_Node(pos, pns); myAtt->Add(pdn); @@ -731,11 +785,15 @@ void TNaming_Builder::Generated(const TopoDS_Shape& oldShape, const TopoDS_Shape void TNaming_Builder::Modify(const TopoDS_Shape& oldShape, const TopoDS_Shape& newShape) { if (myAtt->myNode == nullptr) + { myAtt->myEvolution = TNaming_MODIFY; + } else { if (myAtt->myEvolution != TNaming_MODIFY) + { throw Standard_ConstructionError("TNaming_Builder : not same evolution"); + } } if (oldShape.IsSame(newShape)) @@ -752,7 +810,9 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape, const TopoDS_Shape& n myShapes->myMap.Bind(oldShape, pos); } else + { pos = myShapes->myMap.ChangeFind(oldShape); + } TNaming_RefShape* pns; if (!myShapes->myMap.IsBound(newShape)) @@ -761,7 +821,9 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape, const TopoDS_Shape& n myShapes->myMap.Bind(newShape, pns); } else + { pns = myShapes->myMap.ChangeFind(newShape); + } TNaming_Node* pdn = new TNaming_Node(pos, pns); myAtt->Add(pdn); @@ -774,11 +836,15 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape, const TopoDS_Shape& n void TNaming_Builder::Select(const TopoDS_Shape& S, const TopoDS_Shape& InS) { if (myAtt->myNode == nullptr) + { myAtt->myEvolution = TNaming_SELECTED; + } else { if (myAtt->myEvolution != TNaming_SELECTED) + { throw Standard_ConstructionError("TNaming_Builder : not same evolution"); + } } TNaming_RefShape* pos; @@ -788,7 +854,9 @@ void TNaming_Builder::Select(const TopoDS_Shape& S, const TopoDS_Shape& InS) myShapes->myMap.Bind(InS, pos); } else + { pos = myShapes->myMap.ChangeFind(InS); + } TNaming_RefShape* pns; if (!myShapes->myMap.IsBound(S)) @@ -797,7 +865,9 @@ void TNaming_Builder::Select(const TopoDS_Shape& S, const TopoDS_Shape& InS) myShapes->myMap.Bind(S, pns); } else + { pns = myShapes->myMap.ChangeFind(S); + } TNaming_Node* pdn = new TNaming_Node(pos, pns); myAtt->Add(pdn); @@ -920,9 +990,13 @@ static void SelectSameShape(TNaming_Node*& myNode, { bool Valid; if (Trans < 0) + { Valid = pdn->myAtt->IsValid(); + } else + { Valid = pdn->IsValidInTrans(Trans); + } if (Valid) { @@ -990,7 +1064,9 @@ TNaming_NewShapeIterator::TNaming_NewShapeIterator(const TNaming_Iterator& anIte myNode = anIterator.myNode; TNaming_RefShape* RS = myNode->myNew; if (RS == nullptr) + { myNode = nullptr; // No descendant + } else { // il faut repartir de la premiere utilisation. @@ -1042,7 +1118,9 @@ TNaming_NewShapeIterator::TNaming_NewShapeIterator(const TNaming_NewShapeIterato myNode = anIterator.myNode; TNaming_RefShape* RS = myNode->myNew; if (RS == nullptr) + { myNode = nullptr; // No descendant + } else { // il faut repartir de la premiere utilisation. @@ -1175,7 +1253,9 @@ TNaming_OldShapeIterator::TNaming_OldShapeIterator(const TNaming_Iterator& anIte myNode = anIterator.myNode; TNaming_RefShape* RS = myNode->myNew; if (RS == nullptr) + { myNode = nullptr; // No descendant + } else { // il faut repartir de la premiere utilisation. @@ -1195,7 +1275,9 @@ TNaming_OldShapeIterator::TNaming_OldShapeIterator(const TNaming_OldShapeIterato myNode = anIterator.myNode; TNaming_RefShape* RS = myNode->myOld; if (RS == nullptr) + { myNode = nullptr; // No descendant + } else { // il faut repartir de la premiere utilisation. @@ -1220,7 +1302,9 @@ void TNaming_OldShapeIterator::Next() TDF_Label TNaming_OldShapeIterator::Label() const { if (myNode == nullptr) + { throw Standard_NoSuchObject("TNaming_OldShapeIterator::Label"); + } return myNode->Label(); } @@ -1229,7 +1313,9 @@ TDF_Label TNaming_OldShapeIterator::Label() const occ::handle TNaming_OldShapeIterator::NamedShape() const { if (myNode == nullptr) + { throw Standard_NoSuchObject("TNaming_OldShapeIterator::Label"); + } return myNode->myAtt; } @@ -1238,7 +1324,9 @@ occ::handle TNaming_OldShapeIterator::NamedShape() const const TopoDS_Shape& TNaming_OldShapeIterator::Shape() const { if (myNode == nullptr) + { throw Standard_NoSuchObject("TNaming_OldShapeIterator::Shape"); + } return myNode->myOld->Shape(); } @@ -1285,13 +1373,19 @@ void TNaming_SameShapeIterator::Next() { TNaming_RefShape* prs; if (myIsNew) + { prs = myNode->myNew; + } else + { prs = myNode->myOld; + } myNode = myNode->NextSameShape(prs); if (myNode != nullptr) + { myIsNew = (myNode->myNew == prs); + } } //================================================================================================= @@ -1390,7 +1484,9 @@ TDF_Label TNaming_Tool::Label(const occ::handle& Shapes, pdn = pdn->NextSameShape(prs); } if (pdn == nullptr) + { pdn = prs->FirstUse(); + } TDF_Label L = pdn->Label(); Trans = pdn->myAtt->Transaction(); @@ -1435,7 +1531,9 @@ occ::handle TNaming_Tool::NamedShape(const TopoDS_Shape& S, } if (res == nullptr) + { return NS; + } // VERUE EN ATTENDANT DE REVOIR ABORT 03/11/98 // Protection pour eviter de renvoyer un attribut backuped @@ -1462,7 +1560,9 @@ int TNaming_Tool::ValidUntil(const TopoDS_Shape& S, const occ::handlemyAtt->UntilTransaction(); if (Cur > Until) + { Until = Cur; + } } Node = Node->NextSameShape(RS); } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Naming.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Naming.cxx index 9a7f1826cb..459c590c83 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Naming.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Naming.cxx @@ -168,7 +168,9 @@ bool TNaming_Naming::Solve(NCollection_Map& Valid) if (Regenerate(Valid)) { if (!Valid.IsEmpty()) + { Valid.Add(Label()); + } return true; } return false; @@ -222,7 +224,9 @@ static int FindIndex(const occ::handle& NS, const TopoDS_Sha for (TNaming_Iterator itNS(NS); itNS.More(); itNS.Next(), Index++) { if (IS.IsSame(itNS.NewShape())) + { break; + } } return Index; } @@ -234,7 +238,9 @@ static bool CompareInGeneration(const occ::handle& NS, const for (TNaming_Iterator it(NS); it.More(); it.Next()) { if (!it.NewShape().IsSame(S)) + { return false; + } } return true; } @@ -259,11 +265,14 @@ static bool GetShapeEvolutions( WriteNSOnLabel(aTarget, aNam); #endif // clang-format off - if (aTarget->Label() == theSource->Label()) return true; // check if target is in the source + if (aTarget->Label() == theSource->Label()) { return true; // check if target is in the source +} // clang-format on } else + { return false; + } TNaming_Iterator anIter(aTarget); for (; anIter.More(); anIter.Next()) @@ -281,9 +290,13 @@ static bool GetShapeEvolutions( } #endif if (anIter.OldShape().IsNull() || anIter.NewShape().IsNull()) + { continue; + } if (!anIter.NewShape().IsSame(theTarget)) + { continue; + } if (GetShapeEvolutions(anIter.OldShape(), theSource, aList)) { // recursion: now target is old shape // clang-format off @@ -303,7 +316,9 @@ static occ::handle CompareInModification( { occ::handle aResult; if (S.IsNull() || NS.IsNull()) + { return aResult; + } #ifdef OCCT_DEBUG_71 std::cout << "CompareInModification: parent NS = "; Print_Entry(NS->Label()); @@ -355,12 +370,16 @@ static occ::handle CompareInModification( for (; aNIter2.More(); aNIter2.Next()) { if (aNIter2.NewShape().IsSame(anIter.Value())) + { continue; + } if (aMap.Contains(aNIter2.OldShape())) { // if one shape was modified to the two at the shared label, return this one aResult = TNaming_Tool::NamedShape(aNIter2.OldShape(), NS->Label()); if (!aResult.IsNull()) + { return aResult; + } } } } @@ -374,7 +393,9 @@ static bool FillSMap(const TopoDS_Shape& S, NCollection_Map& MS) { if (S.IsNull()) + { return false; + } bool isHomogen(true); TopAbs_ShapeEnum aPrevType(TopAbs_SHAPE); TopoDS_Iterator it(S); @@ -389,12 +410,18 @@ static bool FillSMap(const TopoDS_Shape& S, { MS.Add(it.Value()); if (aPrevType == TopAbs_SHAPE) + { aPrevType = aType; + } else if (aPrevType != aType) + { isHomogen = false; + } } else if (!FillSMap(it.Value(), MS)) + { isHomogen = false; + } } return isHomogen; } @@ -409,7 +436,9 @@ static bool Compare(const occ::handle& NS, NCollection_Map Forbiden; NCollection_IndexedMap MS; if (!Stop.IsNull()) + { TNaming_NamingTool::BuildDescendants(Stop, Forbiden); + } TNaming_NamingTool::CurrentShape(MDF.GetValid(), Forbiden, NS, MS); #ifdef OCCT_DEBUG_NBS Write(S, "Compare_S.brep"); @@ -434,10 +463,14 @@ static bool TestSolution(const TNaming_Scope& MDF, { if (NS.IsNull()) + { return false; + } TopoDS_Shape Res = MDF.CurrentShape(NS); // last modification of NS taken into account Valid map if (S.IsNull() || Res.IsNull()) + { return false; + } #ifdef OCCT_DEBUG_CC Write(S, "TSol_S.brep"); Write(Res, "TSol_Res.brep"); @@ -464,7 +497,9 @@ static bool TestSolution(const TNaming_Scope& MDF, aMS.Remove(exp.Current()); } else + { return false; + } } return aMS.IsEmpty(); } @@ -480,21 +515,28 @@ static bool TestSolution(const TNaming_Scope& MDF, { aType = itm.Key().ShapeType(); if (isHom) + { break; + } else + { aView.Add(itm.Key().ShapeType()); + } } if (MS.Contains(Res)) { MS.Remove(Res); if (MS.IsEmpty()) + { return true; + } } if (Res.ShapeType() == TopAbs_SOLID || Res.ShapeType() == TopAbs_COMPSOLID || Res.ShapeType() == TopAbs_COMPOUND) { if (isHom) + { for (TopExp_Explorer exp(Res, aType); exp.More(); exp.Next()) { if (MS.Contains(exp.Current())) @@ -502,6 +544,7 @@ static bool TestSolution(const TNaming_Scope& MDF, MS.Remove(exp.Current()); } } + } else { NCollection_Map::Iterator aMapIter(aView); @@ -521,7 +564,9 @@ static bool TestSolution(const TNaming_Scope& MDF, else { if (S.IsSame(Res)) + { return true; + } TopoDS_Iterator it(Res); for (; it.More(); it.Next()) { // content of MS and Res should be the same @@ -530,7 +575,9 @@ static bool TestSolution(const TNaming_Scope& MDF, MS.Remove(it.Value()); } else + { return false; + } } } return MS.IsEmpty(); @@ -544,7 +591,9 @@ static void FindNewShapeInFather(const occ::handle& NS, Topo const TDF_Label& Father = NS->Label().Father(); TNaming_Iterator itLab(Father); if (itLab.More()) + { SC = itLab.NewShape(); + } } //================================================================================================= @@ -556,7 +605,9 @@ static occ::handle NextModif(const occ::handle GenS = TNaming_Tool::NamedShape(S, NS->Label()); if (GenS.IsNull()) + { return false; + } TDF_Label Father = (GenS->Label()).Father(); Father.FindAttribute(TNaming_NamedShape::GetID(), GenS); TopoDS_Shape GoodContext = TNaming_Tool::GetShape(GenS); @@ -742,7 +803,9 @@ static bool Filter(const TDF_Label& F, // std::cout <<"Filter: Lev = " << aLev << std::endl; } if (aLev > 3) + { return false; + } #ifdef ALLOW_CHILD_NBS occ::handle aFNaming; TopoDS_Shape aFatherCandSh; @@ -759,6 +822,7 @@ static bool Filter(const TDF_Label& F, { // check the applicability if (!NS.IsNull() && !NS->Get().IsNull() && NS->Get().ShapeType() == TopAbs_COMPOUND) + { if (IsMultipleCase(S, Context, Neighbourg)) { // std::cout << "Filter: ==> MultipleCase!" << std::endl; @@ -824,7 +888,9 @@ static bool Filter(const TDF_Label& F, TNaming_Tool::NamedShape(Context, NS->Label()); occ::handle Stop = NextModif(Until); if (Compare(NS, MDF, Stop, S)) + { return true; + } break; } } @@ -832,6 +898,7 @@ static bool Filter(const TDF_Label& F, } return false; } + } } #endif @@ -886,7 +953,9 @@ static bool Filter(const TDF_Label& F, const TopoDS_Shape aSNS = aNS->Get(); // allow child level bool allowChild(true); if (!aSNS.IsNull() && aSNS.ShapeType() == TopAbs_COMPOUND && !aFatherCandSh.IsNull()) + { allowChild = !IsContSame(aFatherCandSh, aSNS); + } if (allowChild && !aSNS.IsNull() && aS.ShapeType() != aSNS.ShapeType() && aSNS.ShapeType() == TopAbs_COMPOUND) { // aLev < 3 @@ -903,13 +972,17 @@ static bool Filter(const TDF_Label& F, { const TNaming_Name& aName = aNaming->GetName(); if (aName.Type() == TNaming_GENERATION) + { StandardFilter = false; + } if (StandardFilter) + { if (!Compare(aNS, MDF, Stop, aS)) { TNaming_Localizer aLocalizer; Filter(NF->Label(), MDF, aS, Context, aLocalizer, aNS, aLev); } + } } } theName.Append(aNS); @@ -1012,9 +1085,13 @@ static occ::handle BuildName(const TDF_Label& // Deja Nomme //------------- if (!OnlyOne) + { return Ident.FeatureArg(); + } else + { NS = Ident.FeatureArg(); + } } else { @@ -1088,14 +1165,18 @@ static occ::handle BuildName(const TDF_Label& Write(Ident.ShapeArg(), "BName_ShapeArg.brep"); #endif if (theName.Type() == TNaming_GENERATION) + { theName.Append(BuildNameInNS(Naming->Label(), MDF, Ident.ShapeArg(), Ident.NamedShapeOfGeneration(), Stop, Geom)); + } else + { theName.Append(BuildName(Naming->Label(), MDF, Ident.ShapeArg(), Context, Stop, Geom)); + } } } @@ -1110,9 +1191,13 @@ static occ::handle BuildName(const TDF_Label& #endif Naming->Label().FindAttribute(TNaming_NamedShape::GetID(), NS); if (NS.IsNull()) + { return NS; + } if (MDF.WithValid()) + { MDF.Valid(NS->Label()); + } #ifdef OCCT_DEBUG_MOD if (!NS.IsNull()) { @@ -1131,7 +1216,9 @@ static occ::handle BuildName(const TDF_Label& //------------------------------------------------- if (NS.IsNull()) + { return NS; + } TNaming_Localizer Localizer; TNaming_Iterator itNS(NS); @@ -1188,14 +1275,18 @@ static occ::handle BuildName(const TDF_Label& } } if (StandardFilter) + { if (!Compare(NS, MDF, Stop, Selection)) { Filter(F, MDF, Selection, Context, Localizer, NS, 0); } + } } } if (MDF.WithValid()) + { MDF.Valid(NS->Label()); + } #ifdef OCCT_DEBUG_MOD if (!NS.IsNull()) { @@ -1287,7 +1378,9 @@ static bool HasAncFace(const TopoDS_Shape& Context, { bool hasFace(false); if (W.ShapeType() != TopAbs_WIRE) + { return hasFace; + } TopExp_Explorer exp(Context, TopAbs_FACE); for (; exp.More(); exp.Next()) { @@ -1311,7 +1404,9 @@ static bool HasAncFace(const TopoDS_Shape& Context, } } if (hasFace) + { break; + } } return hasFace; } @@ -1372,16 +1467,22 @@ static occ::handle BuildNameWire(const TDF_Label& F, for (TopExp_Explorer exp(Selection, TopAbs_EDGE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) + { continue; + } theName.Append( TNaming_Naming::Name(Naming->Label(), exp.Current(), Context, Geom, true, false)); } } } else + { return BuildNS(F, Selection, TNaming_UNKNOWN); + } } else { // context is not Face @@ -1395,9 +1496,13 @@ static occ::handle BuildNameWire(const TDF_Label& F, for (TopExp_Explorer exp(Selection, TopAbs_EDGE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) + { continue; + } theName.Append( TNaming_Naming::Name(Naming->Label(), exp.Current(), Context, Geom, true, false)); } @@ -1410,9 +1515,13 @@ static occ::handle BuildNameWire(const TDF_Label& F, for (TopExp_Explorer exp(Selection, TopAbs_EDGE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) + { continue; + } theName.Append(BuildName(Naming->Label(), MDF, exp.Current(), Context, Stop, Geom)); } } @@ -1426,7 +1535,9 @@ static bool IsOneIn(const TopoDS_Shape& S, const TopoDS_Shape& Context) { bool found(false); if (S.IsNull() || Context.IsNull()) + { return found; + } for (TopExp_Explorer exp(Context, S.ShapeType()); exp.More(); exp.Next()) { if (exp.Current().IsEqual(S)) @@ -1446,7 +1557,9 @@ static bool IsAllIn(const TopoDS_Shape& S, const TopoDS_Shape& Context) #endif bool found(false); if (S.IsNull() || Context.IsNull()) + { return found; + } int num1(0), num2(0); for (TopoDS_Iterator it(S); it.More(); it.Next(), num1++) { @@ -1455,6 +1568,7 @@ static bool IsAllIn(const TopoDS_Shape& S, const TopoDS_Shape& Context) Write(it.Value(), "Sel_ItValue.brep"); #endif if (it.Value().ShapeType() != TopAbs_COMPOUND) + { for (TopExp_Explorer exp(Context, it.Value().ShapeType()); exp.More(); exp.Next()) { #ifdef OCCT_DEBUG_CC @@ -1467,15 +1581,20 @@ static bool IsAllIn(const TopoDS_Shape& S, const TopoDS_Shape& Context) break; } } + } else { bool isAll = IsAllIn(it.Value(), Context); if (isAll) + { num2++; + } } } if (num1 == num2) + { found = true; + } #ifdef OCCT_DEBUG_CC else std::cout << "Compound case : selected num1 = " << num1 << " context contains num2 = " << num2 @@ -1500,7 +1619,9 @@ static int RepeatabilityInContext(const TopoDS_Shape& Selection, const TopoDS_Sh for (TopExp_Explorer exp(Context, Selection.ShapeType()); exp.More(); exp.Next()) { if (exp.Current().IsSame(Selection)) + { aNum++; + } } } } @@ -1518,7 +1639,9 @@ static int RepeatabilityInContext(const TopoDS_Shape& Selection, const TopoDS_Sh } } if (n > aNum) + { aNum = n; + } } } } @@ -1535,7 +1658,9 @@ static bool HasAncSolid(const TopoDS_Shape& Context, { bool hasSolid(false); if (Sh.ShapeType() != TopAbs_SHELL) + { return hasSolid; + } TopExp_Explorer exp(Context, TopAbs_SOLID); for (; exp.More(); exp.Next()) { @@ -1560,7 +1685,9 @@ static bool HasAncSolid(const TopoDS_Shape& Context, } } if (hasSolid) + { break; + } } return hasSolid; } @@ -1613,7 +1740,9 @@ static occ::handle BuildNameShell(const TDF_Label& F, // solid => aSolid which is also a context occ::handle aNS = TNaming_Tool::NamedShape(Context, F); if (!aNS.IsNull()) + { theName.ContextLabel(aNS->Label()); + } theName.Append(aNS); if (isOuter) { @@ -1625,13 +1754,17 @@ static occ::handle BuildNameShell(const TDF_Label& F, for (TopExp_Explorer exp(Selection, TopAbs_FACE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } theName.Append(BuildName(Naming->Label(), MDF, exp.Current(), Context, Stop, Geom)); } } } else + { return BuildNS(F, Selection, TNaming_UNKNOWN); + } } else { @@ -1650,9 +1783,13 @@ static occ::handle BuildNameShell(const TDF_Label& F, theNameSo.Type(TNaming_UNION); occ::handle aNS = TNaming_Tool::NamedShape(Context, F); if (!aNS.IsNull()) + { theNameSo.ContextLabel(aNS->Label()); + } for (TopExp_Explorer exp(aSolid, TopAbs_FACE); exp.More(); exp.Next()) + { theNameSo.Append(BuildName(NamingSo->Label(), MDF, exp.Current(), Context, Stop, Geom)); + } NamingSo->GetName().Solve(NamingSo->Label(), MDF.GetValid()); aNS.Nullify(); NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS); @@ -1669,9 +1806,13 @@ static occ::handle BuildNameShell(const TDF_Label& F, theNameSo.Type(TNaming_UNION); occ::handle aNS = TNaming_Tool::NamedShape(Context, F); if (!aNS.IsNull()) + { theNameSo.ContextLabel(aNS->Label()); + } for (TopExp_Explorer exp(aSolid, TopAbs_FACE); exp.More(); exp.Next()) + { theNameSo.Append(BuildName(NamingSo->Label(), MDF, exp.Current(), Context, Stop, Geom)); + } NamingSo->GetName().Solve(NamingSo->Label(), MDF.GetValid()); aNS.Nullify(); NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS); @@ -1680,7 +1821,9 @@ static occ::handle BuildNameShell(const TDF_Label& F, for (TopExp_Explorer exp(Selection, TopAbs_FACE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } theName.Append(BuildName(Naming->Label(), MDF, exp.Current(), Context, Stop, Geom)); } } @@ -1691,11 +1834,15 @@ static occ::handle BuildNameShell(const TDF_Label& F, theName.Type(TNaming_UNION); occ::handle aNS = TNaming_Tool::NamedShape(Context, F); if (!aNS.IsNull()) + { theName.ContextLabel(aNS->Label()); + } for (TopExp_Explorer exp(Selection, TopAbs_FACE); exp.More(); exp.Next()) { if (exp.Current().IsNull()) + { continue; + } theName.Append(BuildName(Naming->Label(), MDF, exp.Current(), Context, Stop, Geom)); } } @@ -1769,7 +1916,9 @@ static void BuildAggregationName(const TDF_Label& F, aNS = BuildNameWire(aNaming->Label(), MDF, aS, Context, Stop, Geom); } else if (aS.ShapeType() == TopAbs_SHELL) + { aNS = BuildNameShell(aNaming->Label(), MDF, aS, Context, Stop, Geom); + } else { for (TopExp_Explorer exp(aS, atomTyp); exp.More(); exp.Next()) @@ -1789,15 +1938,19 @@ static void BuildAggregationName(const TDF_Label& F, { aNS = TNaming_Tool::NamedShape(Context, F); if (!aNS.IsNull()) + { aNaming->ChangeName().ContextLabel(aNS->Label()); + } } aNaming->GetName().Solve(aNaming->Label(), MDF.GetValid()); if (aNaming->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) + { if (!Geom && TestSolution(MDF, aNS, aS)) { theName.Append(aNS); } + } } } } @@ -1855,7 +2008,9 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, theName.Orientation(S.Orientation()); if (!TNaming_Selector::IsIdentified(F, S, aNamedShape, Geom)) + { aNamedShape = TNaming_Naming::Name(Naming->Label(), S, Context, Geom, false); + } theName.Append(aNamedShape); #ifdef MDTV_OR std::cout << " Sel Label ==> "; @@ -1886,7 +2041,9 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, } } if (found) + { break; + } } } } @@ -1917,23 +2074,29 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, Naming->Label().FindAttribute(TNaming_NamedShape::GetID(), aNamedShape); theName.ContextLabel(aNamedShape->Label()); if (Geom) + { return aNamedShape; + } if (aNamedShape.IsNull()) { - std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << std::endl; + std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << '\n'; return BuildNS(F, S, TNaming_UNKNOWN); } if (!Geom && TestSolution(MDF, aNamedShape, S)) + { return aNamedShape; - std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << std::endl; + } + std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << '\n'; // Naming n is unsatisfactory return BuildNS(F, S, TNaming_UNKNOWN); } } else if (TNaming_Selector::IsIdentified(F, S, aNamedShape, Geom)) + { return aNamedShape; + } } //------------------------------------------------------------ @@ -1956,9 +2119,13 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, //--------------------------------------- occ::handle NS = BuildName(F, MDF, S, Context, Stop, Geom); if (Geom) + { return NS; + } if (!Geom && TestSolution(MDF, NS, S)) + { return NS; + } } else { @@ -1973,7 +2140,9 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, theName.Shape(S); theName.Orientation(S.Orientation()); if (S.ShapeType() != TopAbs_WIRE) + { theName.Type(TNaming_UNION); + } TopAbs_ShapeEnum atomType; switch (S.ShapeType()) @@ -1993,12 +2162,16 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, if (!Context.IsNull()) { if (Context.ShapeType() < S.ShapeType()) + { found = IsOneIn(S, Context); + } if (found) { NS = TNaming_Tool::NamedShape(Context, F); if (!NS.IsNull()) + { theName.ContextLabel(NS->Label()); + } } } if (atomType == TopAbs_SHAPE) @@ -2018,7 +2191,9 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, else { if (S.ShapeType() == TopAbs_WIRE) + { NS = BuildNameWire(Naming->Label(), MDF, S, Context, Stop, Geom); + } else if (S.ShapeType() == TopAbs_SHELL) { NS = BuildNameShell(Naming->Label(), MDF, S, Context, Stop, Geom); @@ -2037,16 +2212,22 @@ occ::handle TNaming_Naming::Name(const TDF_Label& F, Naming->GetName().Solve(Naming->Label(), MDF.GetValid()); Naming->Label().FindAttribute(TNaming_NamedShape::GetID(), NS); if (Geom) + { return NS; + } if (NS.IsNull()) + { return BuildNS(F, S, TNaming_UNKNOWN); + } if (!Geom && TestSolution(MDF, NS, S)) + { return NS; + } } - std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << std::endl; + std::cout << " %%% WARNING: TNaming_Naming::Name: FAILED" << '\n'; // Naming n is not satisfactory return BuildNS(F, S, TNaming_UNKNOWN); @@ -2123,9 +2304,13 @@ void TNaming_Naming::References(const occ::handle& DataSet) const // Iteration on NamedShape of the name NCollection_List>::Iterator it(myName.Arguments()); for (; it.More(); it.Next()) + { DataSet->AddAttribute(it.Value()); + } if (!myName.StopNamedShape().IsNull()) + { DataSet->AddAttribute(myName.StopNamedShape()); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamingTool.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamingTool.cxx index d60d490123..b4c3afa109 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamingTool.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_NamingTool.cxx @@ -64,7 +64,9 @@ static bool IsForbiden(const NCollection_Map& Forbiden, const TDF_Lab return false; } if (Forbiden.Contains(Lab)) + { return true; + } else { return IsForbiden(Forbiden, Lab.Father()); @@ -89,9 +91,13 @@ static void LastModif(TNaming_NewShapeIterator& std::cout << "NamingTool:: LastModif LabelEntry = " << entry << std::endl; #endif if (!Updated.IsEmpty() && !Updated.Contains(Lab)) + { continue; + } if (IsForbiden(Forbiden, Lab)) + { continue; + } if (it.IsModification()) { YaModif = true; @@ -102,11 +108,15 @@ static void LastModif(TNaming_NewShapeIterator& MS.Add(aS); // Modified } else + { LastModif(it2, it.Shape(), MS, Updated, Forbiden); + } } } if (!YaModif) + { MS.Add(S); + } } //======================================================================= @@ -159,7 +169,9 @@ void TNaming_NamingTool::CurrentShape( { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) + { continue; + } #ifdef OCCT_DEBUG_DESC WriteS(S, "CS_NewShape.brep"); if (itL.OldShape().IsNull()) @@ -200,7 +212,9 @@ void TNaming_NamingTool::CurrentShape( } } if (OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + { YaOrientationToApply = true; + } } } // } @@ -208,9 +222,13 @@ void TNaming_NamingTool::CurrentShape( if (!it.More()) { if (YaOrientationToApply) + { MS.Add(S.Oriented(OrientationToApply)); + } else + { MS.Add(S); + } } else { @@ -218,10 +236,13 @@ void TNaming_NamingTool::CurrentShape( NCollection_IndexedMap MS2; LastModif(it, S, MS2, Valid, Forbiden); // clang-format off - if (YaOrientationToApply) ApplyOrientation (MS2, OrientationToApply);//the solution to be refined + if (YaOrientationToApply) { ApplyOrientation (MS2, OrientationToApply);//the solution to be refined +} // clang-format on for (int anItMS2 = 1; anItMS2 <= MS2.Extent(); ++anItMS2) + { MS.Add(MS2(anItMS2)); + } } } } @@ -239,13 +260,19 @@ void TNaming_NamingTool::CurrentShapeFromShape( occ::handle NS = it.NamedShape(); if (!NS.IsNull() && NS->Evolution() == TNaming_SELECTED) + { MS.Add(TNaming_Tool::GetShape(NS)); + } else { if (!it.More()) + { MS.Add(S); + } else + { LastModif(it, S, MS, Valid, Forbiden); + } } } @@ -275,7 +302,9 @@ void BuildDescendants2(const occ::handle& NS, NCollection_Map& Descendants) { if (NS.IsNull()) + { return; + } TNaming_NewShapeIterator it(NS); for (; it.More(); it.Next()) { @@ -287,7 +316,9 @@ void BuildDescendants2(const occ::handle& NS, std::cout << "MakeDescendants2: Label = " << entry << std::endl; #endif if (ForbLab == it.Label()) + { continue; + } Descendants.Add(it.Label()); TNaming_NewShapeIterator it2(it); MakeDescendants(it2, Descendants); @@ -301,7 +332,9 @@ void TNaming_NamingTool::BuildDescendants(const occ::handle& NCollection_Map& Descendants) { if (NS.IsNull()) + { return; + } Descendants.Add(NS->Label()); TNaming_NewShapeIterator it(NS); #ifdef OCCT_DEBUG_DESC diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Scope.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Scope.cxx index 906afef581..be0e1b4981 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Scope.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Scope.cxx @@ -78,10 +78,14 @@ void TNaming_Scope::ValidChildren(const TDF_Label& L, const bool withroot) { TDF_ChildIterator itc(L, true); for (; itc.More(); itc.Next()) + { myValid.Add(itc.Value()); + } } if (withroot) + { myValid.Add(L); + } } //================================================================================================= @@ -99,10 +103,14 @@ void TNaming_Scope::UnvalidChildren(const TDF_Label& L, const bool withroot) { TDF_ChildIterator itc(L, true); for (; itc.More(); itc.Next()) + { myValid.Remove(itc.Value()); + } } if (withroot) + { myValid.Remove(L); + } } //================================================================================================= @@ -110,7 +118,9 @@ void TNaming_Scope::UnvalidChildren(const TDF_Label& L, const bool withroot) bool TNaming_Scope::IsValid(const TDF_Label& L) const { if (myWithValid) + { return myValid.Contains(L); + } return true; } @@ -133,6 +143,8 @@ NCollection_Map& TNaming_Scope::ChangeValid() TopoDS_Shape TNaming_Scope::CurrentShape(const occ::handle& NS) const { if (myWithValid) + { return TNaming_Tool::CurrentShape(NS, myValid); + } return TNaming_Tool::CurrentShape(NS); } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Selector.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Selector.cxx index 4a29d7767c..6df29dfedc 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Selector.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Selector.cxx @@ -56,14 +56,20 @@ inline static void MapOfOrientedShapes(const TopoDS_Shape& S, NCollection_Map& M) { if (S.ShapeType() > TopAbs_COMPSOLID) + { return; + } TopoDS_Iterator it(S); for (; it.More(); it.Next()) { if (it.Value().ShapeType() > TopAbs_COMPSOLID) + { M.Add(it.Value()); + } else + { BuildAtomicMap(it.Value(), M); + } } } @@ -108,7 +114,9 @@ static bool IsSpecificCase(const TDF_Label& F, const TopoDS_Shape& Context) cit.Initialize(aNS->Label(), TNaming_NamedShape::GetID(), false); } else + { return true; + } } for (; cit.More(); cit.Next()) @@ -118,7 +126,9 @@ static bool IsSpecificCase(const TDF_Label& F, const TopoDS_Shape& Context) { TopoDS_Shape aS = TNaming_Tool::CurrentShape(NS); if (aS.IsNull()) + { continue; + } if (aS.ShapeType() != TopAbs_COMPOUND) { // single shape at the child label if (!shapesOfContext.Contains(aS)) @@ -140,7 +150,9 @@ static bool IsSpecificCase(const TDF_Label& F, const TopoDS_Shape& Context) break; } if (isFound) + { break; + } } } } @@ -201,7 +213,9 @@ bool TNaming_Selector::IsIdentified(const TDF_Label& L, if (Ident.IsFeature()) { if (!OnlyOne) + { return false; + } else { NS = Ident.FeatureArg(); @@ -239,7 +253,9 @@ bool TNaming_Selector::IsIdentified(const TDF_Label& L, for (; itl.More(); itl.Next()) { if (itl.Value() == aC) + { isEq = true; + } else { isEq = false; @@ -250,7 +266,9 @@ bool TNaming_Selector::IsIdentified(const TDF_Label& L, } } else + { return false; + } } return false; } @@ -277,13 +295,17 @@ bool TNaming_Selector::Select(const TopoDS_Shape& Selection, bool isVertex(true); TopoDS_Iterator it(Selection); for (; it.More(); it.Next()) + { if (it.Value().ShapeType() != TopAbs_VERTEX) { isVertex = false; break; } + } if (isVertex) + { aKeepOrientation = false; + } } if (aKeepOrientation) @@ -301,7 +323,9 @@ bool TNaming_Selector::Select(const TopoDS_Shape& Selection, NS = TNaming_Naming::Name(myLabel, Selection, Context, Geometry, aKeepOrientation); } if (NS.IsNull()) + { return false; + } // // namedshape with SELECTED Evolution // @@ -310,9 +334,13 @@ bool TNaming_Selector::Select(const TopoDS_Shape& Selection, // then naming structure becomes more complex, can be cycles const TopoDS_Shape& aSelection = TNaming_Tool::CurrentShape(NS); // szy if (aSelection.ShapeType() == TopAbs_COMPOUND && aSelection.ShapeType() != Selection.ShapeType()) + { B.Select(aSelection, aSelection); // type migration + } else + { B.Select(Selection, Selection); + } // // naming with IDENTITY NameType // diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_ShapesSet.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_ShapesSet.cxx index bebd65ab81..96c2910b77 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_ShapesSet.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_ShapesSet.cxx @@ -26,7 +26,9 @@ TNaming_ShapesSet::TNaming_ShapesSet(const TopoDS_Shape& CS, const TopAbs_ShapeEnum Type) { if (CS.IsNull()) + { return; + } if (Type == TopAbs_SHAPE) { if (CS.ShapeType() == TopAbs_SOLID || CS.ShapeType() == TopAbs_FACE diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Tool.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Tool.cxx index 2e548c8f34..5d32536365 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_Tool.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_Tool.cxx @@ -46,7 +46,9 @@ static void LastModif(TNaming_NewShapeIterator& { const TDF_Label& Lab = it.Label(); if (!Updated.Contains(Lab)) + { continue; + } if (it.IsModification()) { @@ -65,11 +67,15 @@ static void LastModif(TNaming_NewShapeIterator& } } else + { LastModif(it2, it.Shape(), MS, Updated, Deleted); + } } } if (!YaModif) + { MS.Add(S); + } } //================================================================================================= @@ -100,11 +106,15 @@ static void LastModif(TNaming_NewShapeIterator& } } else + { LastModif(it2, MS, it.Shape(), Deleted); + } } } if (!YaModif) + { MS.Add(S); + } } //================================================================================================= @@ -180,22 +190,32 @@ TopoDS_Shape TNaming_Tool::GetShape(const occ::handle& NS) MS.Add(aS); } else + { MS.Add(itL.NewShape()); + } } else + { MS.Add(itL.NewShape()); + } } // else + { MS.Add(itL.NewShape()); + } } } } else + { for (; itL.More(); itL.Next()) { if (!itL.NewShape().IsNull()) + { MS.Add(itL.NewShape()); + } } + } return MakeShape(MS); } @@ -234,7 +254,9 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) + { continue; + } // OR-N bool YaOrientationToApply(false); TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); @@ -269,7 +291,9 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A } } if (OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + { YaOrientationToApply = true; + } } } } // @@ -284,9 +308,13 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A NCollection_IndexedMap MS2; // to be optimized later LastModif(it, MS2, S, Deleted); if (YaOrientationToApply) + { ApplyOrientation(MS2, OrientationToApply); + } for (int anItMS2 = 1; anItMS2 <= MS2.Extent(); ++anItMS2) + { MS.Add(MS2(anItMS2)); + } } } return MakeShape(MS); @@ -312,7 +340,9 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) + { continue; + } // OR-N bool YaOrientationToApply(false); TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); @@ -347,7 +377,9 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A } } if (OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + { YaOrientationToApply = true; + } } } } // @@ -362,9 +394,13 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const occ::handle& A NCollection_IndexedMap MS2; // to be optimized later LastModif(it, S, MS2, Updated, Deleted); if (YaOrientationToApply) + { ApplyOrientation(MS2, OrientationToApply); + } for (int anItMS2 = 1; anItMS2 <= MS2.Extent(); ++anItMS2) + { MS.Add(MS2(anItMS2)); + } } } return MakeShape(MS); @@ -477,7 +513,9 @@ void TNaming_Tool::FirstOlds(const occ::handle& } } if (!YaModif) + { MS.Add(S); + } } //================================================================================================= @@ -491,7 +529,9 @@ TopoDS_Shape TNaming_Tool::InitialShape(const TopoDS_Shape& S, TopoDS_Shape Res; if (!TNaming_Tool::HasLabel(US, S)) + { return Res; + } int Transdef; Label(US, S, Transdef); @@ -516,7 +556,9 @@ static void Back(const occ::handle& NS, for (TNaming_Iterator it(NS); it.More(); it.Next()) { if (it.NewShape().IsNull()) + { continue; + } for (TNaming_OldShapeIterator Oldit(it); Oldit.More(); Oldit.Next()) { const TopoDS_Shape& OS = Oldit.Shape(); @@ -527,7 +569,9 @@ static void Back(const occ::handle& NS, if (!NOS.IsNull()) { if (MNS.Add(NOS)) + { Back(NOS, MNS); + } } } } @@ -546,7 +590,9 @@ void TNaming_Tool::Collect(const occ::handle& NS, for (TNaming_Iterator it(NS); it.More(); it.Next()) { if (it.NewShape().IsNull()) + { continue; + } for (TNaming_NewShapeIterator NewIt(it); NewIt.More(); NewIt.Next()) { if (!OnlyModif || NewIt.IsModification()) @@ -589,9 +635,13 @@ void TNaming_Tool::FindShape(const NCollection_Map& Valid, TopoDS_Shape& S) { if (!Valid.IsEmpty() && !Valid.Contains(Arg->Label())) + { return; + } if (Arg.IsNull() || Arg->IsEmpty()) + { return; + } // Which type of shape is being expected? occ::handle aNaming; @@ -608,7 +658,9 @@ void TNaming_Tool::FindShape(const NCollection_Map& Valid, NCollection_Map subShapes; TopExp_Explorer anExpl(Arg->Get(), (TopAbs_ShapeEnum)((int)(aNaming->GetName().ShapeType()) + 1)); for (; anExpl.More(); anExpl.Next()) + { subShapes.Add(anExpl.Current()); + } #ifdef OCCT_DEBUG // std::cout<<"TNaming_Tool::FindShape(): Nb of sub shapes = "<& Valid, const occ::handle& aCurrentExtArg = TNaming_Tool::CurrentNamedShape(anExtArg); if (!aCurrentExtArg.IsNull() && !aCurrentExtArg->IsEmpty()) + { extArgs.Append(aCurrentExtArg); + } #ifdef OCCT_DEBUG // if (extArgs.Extent() - 1 == nbExtArgs) { // std::cout<<"TNaming_Tool::FindShape(): An external reference has been found at "; @@ -684,7 +738,9 @@ void TNaming_Tool::FindShape(const NCollection_Map& Valid, subShapesOfResult.Add(explSubC.Current()); } if (subShapesOfResult.Extent() != subShapes.Extent()) + { continue; + } for (NCollection_Map::Iterator itrR(subShapesOfResult); itrR.More(); itrR.Next()) @@ -711,7 +767,9 @@ void TNaming_Tool::FindShape(const NCollection_Map& Valid, } if (!S.IsNull()) + { break; + } #ifdef OCCT_DEBUG // std::cout<> Idex = " << i - << " Type = " << (myMap.FindKey(i))->DynamicType() << std::endl; + << " Type = " << (myMap.FindKey(i))->DynamicType() << '\n'; continue; } } diff --git a/src/ApplicationFramework/TKCAF/TNaming/TNaming_UsedShapes.cxx b/src/ApplicationFramework/TKCAF/TNaming/TNaming_UsedShapes.cxx index c112bf3c30..e9c996b870 100644 --- a/src/ApplicationFramework/TKCAF/TNaming/TNaming_UsedShapes.cxx +++ b/src/ApplicationFramework/TKCAF/TNaming/TNaming_UsedShapes.cxx @@ -116,7 +116,7 @@ void TNaming_UsedShapes::Paste(const occ::handle&, Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const { - anOS << "The content of UsedShapes attribute:" << std::endl; + anOS << "The content of UsedShapes attribute:" << '\n'; NCollection_DataMap::Iterator itr( myMap); for (; itr.More(); itr.Next()) @@ -125,7 +125,7 @@ Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const { anOS << "Empty Shape at label ="; itr.Value()->Label().EntryDump(anOS); - anOS << std::endl; + anOS << '\n'; continue; } anOS << " "; @@ -134,7 +134,7 @@ Standard_OStream& TNaming_UsedShapes::Dump(Standard_OStream& anOS) const itr.Value()->Label().EntryDump(anOS); anOS << " Key_TShape = " << itr.Key().TShape()->This(); anOS << " Value_TShape = " << itr.Value()->Shape().TShape()->This(); - anOS << std::endl; + anOS << '\n'; } return anOS; } diff --git a/src/ApplicationFramework/TKCDF/CDF/CDF_Application.cxx b/src/ApplicationFramework/TKCDF/CDF/CDF_Application.cxx index b733adbf7c..3496b7ec30 100644 --- a/src/ApplicationFramework/TKCDF/CDF/CDF_Application.cxx +++ b/src/ApplicationFramework/TKCDF/CDF/CDF_Application.cxx @@ -110,9 +110,13 @@ occ::handle CDF_Application::Retrieve(const TCollection_ExtendedSt occ::handle theMetaData; if (aVersion.Length() == 0) + { theMetaData = myMetaDataDriver->MetaData(aFolder, aName); + } else + { theMetaData = myMetaDataDriver->MetaData(aFolder, aName, aVersion); + } CDF_TypeOfActivation theTypeOfActivation = TypeOfActivation(theMetaData); occ::handle theDocument = @@ -144,9 +148,13 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& { if (!myMetaDataDriver->Find(theFolder, theName, theVersion)) + { return PCDM_RS_UnknownDocument; + } else if (!myMetaDataDriver->HasReadPermission(theFolder, theName, theVersion)) + { return PCDM_RS_PermissionDenied; + } else { occ::handle theMetaData = @@ -174,7 +182,9 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& theFormat = UTL::Value(Resources(), ResourceName); } else + { return PCDM_RS_UnrecognizedFileFormat; + } } // check actual availability of the driver @@ -182,7 +192,9 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& { occ::handle aReader = ReaderFromFormat(theFormat); if (aReader.IsNull()) + { return PCDM_RS_NoDriver; + } } catch (Standard_Failure const&) { @@ -216,7 +228,9 @@ bool CDF_Application::SetDefaultFolder(const char16_t* const aFolder) { bool found = myMetaDataDriver->FindFolder(aFolder); if (found) + { myDefaultFolder = aFolder; + } return found; } @@ -250,28 +264,34 @@ occ::handle CDF_Application::Retrieve(const occ::handlePath() << "; not found." - << (char)0 << std::endl; + << (char)0 << '\n'; break; case PCDM_RS_PermissionDenied: aMsg << "Could not find the referenced document: " << aMetaData->Path() - << "; permission denied. " << (char)0 << std::endl; + << "; permission denied. " << (char)0 << '\n'; break; case PCDM_RS_NoDocument: - aMsg << "Document for appending is not defined." << (char)0 << std::endl; + aMsg << "Document for appending is not defined." << (char)0 << '\n'; break; default: myRetrievableStatus = PCDM_RS_OK; } if (myRetrievableStatus != PCDM_RS_OK) + { throw Standard_Failure(aMsg.str().c_str()); + } myRetrievableStatus = PCDM_RS_DriverFailure; } bool AlreadyRetrieved = aMetaData->IsRetrieved(); if (AlreadyRetrieved) + { myRetrievableStatus = PCDM_RS_AlreadyRetrieved; + } bool Modified = AlreadyRetrieved && aMetaData->Document()->IsModified(); if (Modified) + { myRetrievableStatus = PCDM_RS_AlreadyRetrievedAndModified; + } if (!AlreadyRetrieved || Modified || isAppendMode) { TCollection_ExtendedString aFormat; @@ -289,7 +309,9 @@ occ::handle CDF_Application::Retrieve(const occ::handleDocument(); if (!isAppendMode) + { aDocument->RemoveAllReferences(); + } } else { @@ -313,7 +335,7 @@ occ::handle CDF_Application::Retrieve(const occ::handle PCDM_RS_AlreadyRetrieved) { Standard_SStream aMsg; - aMsg << anException << std::endl; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -327,7 +349,9 @@ occ::handle CDF_Application::Retrieve(const occ::handleDocument(); + } return theDocumentToReturn; } @@ -351,13 +375,19 @@ CDF_TypeOfActivation CDF_Application::TypeOfActivation(const occ::handleIsOpened()) { if (theDocument->IsModified()) + { return CDF_TOA_Modified; + } else + { return CDF_TOA_Unchanged; + } } else + { return CDF_TOA_New; + } } return CDF_TOA_New; } @@ -384,7 +414,7 @@ void CDF_Application::Read(Standard_IStream& theIStream, myRetrievableStatus = PCDM_RS_FormatFailure; Standard_SStream aMsg; - aMsg << anException << std::endl; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } @@ -429,7 +459,7 @@ void CDF_Application::Read(Standard_IStream& theIStream, if (myRetrievableStatus > PCDM_RS_AlreadyRetrieved) { Standard_SStream aMsg; - aMsg << anException << std::endl; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -445,7 +475,9 @@ occ::handle CDF_Application::ReaderFromFormat( // check map of readers occ::handle aReader; if (myReaders.FindFromKey(theFormat, aReader)) + { return aReader; + } // support of legacy method of loading reader as plugin TCollection_ExtendedString aResourceName = theFormat; @@ -463,7 +495,9 @@ occ::handle CDF_Application::ReaderFromFormat( // If the GUID (as a string) contains blanks, remove them. if (strPluginId.Search(' ') != -1) + { strPluginId.RemoveAll(' '); + } // Convert to GUID. Standard_GUID aPluginId = UTL::GUID(strPluginId); @@ -500,7 +534,9 @@ occ::handle CDF_Application::WriterFromFormat( // check map of writers occ::handle aDriver; if (myWriters.FindFromKey(theFormat, aDriver)) + { return aDriver; + } // support of legacy method of loading reader as plugin TCollection_ExtendedString aResourceName = theFormat; @@ -518,7 +554,9 @@ occ::handle CDF_Application::WriterFromFormat( // If the GUID (as a string) contains blanks, remove them. if (strPluginId.Search(' ') != -1) + { strPluginId.RemoveAll(' '); + } // Convert to GUID. Standard_GUID aPluginId = UTL::GUID(strPluginId); @@ -567,7 +605,9 @@ bool CDF_Application::Format(const TCollection_ExtendedString& aFileName, theFormat = UTL::Value(Resources(), ResourceName); } else + { return false; + } } return true; } @@ -578,9 +618,13 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const occ::handle& const bool theAppendMode) { if (aMetaData->HasVersion()) + { return CanRetrieve(aMetaData->Folder(), aMetaData->Name(), aMetaData->Version(), theAppendMode); + } else + { return CanRetrieve(aMetaData->Folder(), aMetaData->Name(), theAppendMode); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKCDF/CDF/CDF_Directory.cxx b/src/ApplicationFramework/TKCDF/CDF/CDF_Directory.cxx index 6ab8739639..24276d23ea 100644 --- a/src/ApplicationFramework/TKCDF/CDF/CDF_Directory.cxx +++ b/src/ApplicationFramework/TKCDF/CDF/CDF_Directory.cxx @@ -28,7 +28,9 @@ CDF_Directory::CDF_Directory() = default; void CDF_Directory::Add(const occ::handle& aDocument) { if (!Contains(aDocument)) + { myDocuments.Append(aDocument); + } } void CDF_Directory::Remove(const occ::handle& aDocument) @@ -48,7 +50,9 @@ bool CDF_Directory::Contains(const occ::handle& aDocument) const for (NCollection_List>::Iterator it(myDocuments); it.More(); it.Next()) { if (aDocument == it.Value()) + { return true; + } } return false; } diff --git a/src/ApplicationFramework/TKCDF/CDF/CDF_FWOSDriver.cxx b/src/ApplicationFramework/TKCDF/CDF/CDF_FWOSDriver.cxx index af420b38b8..1d992174e7 100644 --- a/src/ApplicationFramework/TKCDF/CDF/CDF_FWOSDriver.cxx +++ b/src/ApplicationFramework/TKCDF/CDF/CDF_FWOSDriver.cxx @@ -175,9 +175,13 @@ TCollection_ExtendedString CDF_FWOSDriver::DefaultFolder() #else TCollection_ExtendedString home = UTL::xgetenv("HOME"); if (home.Length() != 0) + { theDefaultFolder = home; + } else + { theDefaultFolder = TCollection_ExtendedString("/tmp"); + } #endif } return theDefaultFolder; @@ -227,7 +231,9 @@ TCollection_ExtendedString CDF_FWOSDriver::SetName(const occ::handle CDF_Store::Folder() const { if (myCurrentDocument->HasRequestedFolder()) + { return new TCollection_HExtendedString(myCurrentDocument->RequestedFolder()); + } return blank; } @@ -92,7 +94,9 @@ bool CDF_Store::SetFolder(const TCollection_ExtendedString& aFolder) // if the last character is the folder separator, remove it. if (aLen > 1 && (theFolder.Value(aLen) == '/' || theFolder.Value(aLen) == '\\')) + { theFolder.Trunc(aLen - 1); + } if (theMetaDataDriver->FindFolder(theFolder)) { @@ -115,7 +119,9 @@ CDF_StoreSetNameStatus CDF_Store::SetName(const TCollection_ExtendedString& aNam { occ::handle E = myCurrentDocument->MetaData(); if (E->Folder() == myCurrentDocument->RequestedFolder() && E->Name() == theName) + { return CDF_SSNS_OK; + } } if (myCurrentDocument->HasRequestedFolder()) @@ -123,7 +129,9 @@ CDF_StoreSetNameStatus CDF_Store::SetName(const TCollection_ExtendedString& aNam if (theMetaDataDriver->Find(myCurrentDocument->RequestedFolder(), theName)) { if (theMetaDataDriver->MetaData(myCurrentDocument->RequestedFolder(), theName)->IsRetrieved()) + { return CDF_SSNS_OpenDocument; + } else { myCurrentDocument->SetRequestedName(theName); @@ -148,7 +156,9 @@ void CDF_Store::Realize(const Message_ProgressRange& theRange) myText = ""; myStatus = myList->Store(m, myText, theRange); if (myStatus == PCDM_SS_OK) + { myPath = m->Path(); + } } const char16_t* CDF_Store::Path() const @@ -159,14 +169,18 @@ const char16_t* CDF_Store::Path() const occ::handle CDF_Store::MetaDataPath() const { if (myCurrentDocument->IsStored()) + { return new TCollection_HExtendedString(myCurrentDocument->MetaData()->Path()); + } return blank; } occ::handle CDF_Store::Description() const { if (myMainDocument->FindDescription()) + { return new TCollection_HExtendedString(myMainDocument->Description()); + } return blank; } @@ -183,7 +197,9 @@ bool CDF_Store::IsModified() const bool CDF_Store::CurrentIsConsistent() const { if (!myCurrentDocument->IsStored()) + { return myCurrentDocument->HasRequestedFolder(); + } return true; } @@ -200,7 +216,9 @@ bool CDF_Store::HasAPreviousVersion() const occ::handle CDF_Store::PreviousVersion() const { if (myCurrentDocument->HasRequestedPreviousVersion()) + { return new TCollection_HExtendedString(myCurrentDocument->RequestedPreviousVersion()); + } return blank; } @@ -219,10 +237,14 @@ bool CDF_Store::SetPreviousVersion(const char16_t* const aPreviousVersion) return true; } else + { return false; + } } else + { return false; + } } return true; } diff --git a/src/ApplicationFramework/TKCDF/CDF/CDF_StoreList.cxx b/src/ApplicationFramework/TKCDF/CDF/CDF_StoreList.cxx index b37059140c..4da470b753 100644 --- a/src/ApplicationFramework/TKCDF/CDF/CDF_StoreList.cxx +++ b/src/ApplicationFramework/TKCDF/CDF/CDF_StoreList.cxx @@ -44,14 +44,18 @@ void CDF_StoreList::Add(const occ::handle& aDocument) { if (!myItems.Contains(aDocument) && aDocument != myMainDocument) + { myItems.Add(aDocument); + } myStack.Prepend(aDocument); CDM_ReferenceIterator it(aDocument); for (; it.More(); it.Next()) { if (it.Document()->IsModified()) + { Add(it.Document()); + } } } @@ -144,10 +148,12 @@ PCDM_StoreStatus CDF_StoreList::Store(occ::handle& aMetaData, CDM_ReferenceIterator it(theDocument); for (; it.More(); it.Next()) + { theMetaDataDriver->CreateReference(aMetaData, it.Document()->MetaData(), it.ReferenceIdentifier(), it.DocumentVersion()); + } } } } diff --git a/src/ApplicationFramework/TKCDF/CDM/CDM_Application.cxx b/src/ApplicationFramework/TKCDF/CDM/CDM_Application.cxx index cae67604fa..e2f48bc1b0 100644 --- a/src/ApplicationFramework/TKCDF/CDM/CDM_Application.cxx +++ b/src/ApplicationFramework/TKCDF/CDM/CDM_Application.cxx @@ -80,9 +80,13 @@ void CDM_Application::EndOfUpdate(const occ::handle& /*aDocument*/ { TCollection_ExtendedString message; if (theStatus) + { message = "Updated: "; + } else + { message = "Error during updating: "; + } message += "Document"; Write(message.ToExtString()); diff --git a/src/ApplicationFramework/TKCDF/CDM/CDM_Document.cxx b/src/ApplicationFramework/TKCDF/CDM/CDM_Document.cxx index a02c940e15..5da830306a 100644 --- a/src/ApplicationFramework/TKCDF/CDM/CDM_Document.cxx +++ b/src/ApplicationFramework/TKCDF/CDM/CDM_Document.cxx @@ -57,7 +57,9 @@ CDM_Document::CDM_Document() CDM_Document::~CDM_Document() { if (!myMetaData.IsNull()) + { myMetaData->UnsetDocument(); + } } //================================================================================================= @@ -106,7 +108,9 @@ int CDM_Document::CreateReference(const occ::handle& anOtherDocume for (; it.More(); it.Next()) { if (anOtherDocument == it.Value()->Document()) + { return it.Value()->ReferenceIdentifier(); + } } occ::handle r = new CDM_Reference(this, @@ -155,13 +159,16 @@ occ::handle CDM_Document::Document(const int aReferenceIdentifier) occ::handle theDocument; if (aReferenceIdentifier == 0) + { theDocument = this; - + } else { occ::handle theReference = Reference(aReferenceIdentifier); if (!theReference.IsNull()) + { theDocument = theReference->ToDocument(); + } } return theDocument; } @@ -180,7 +187,9 @@ occ::handle CDM_Document::Reference(const int aReferenceIdentifie { found = aReferenceIdentifier == it.Value()->ReferenceIdentifier(); if (found) + { theReference = it.Value(); + } } return theReference; } @@ -190,11 +199,15 @@ occ::handle CDM_Document::Reference(const int aReferenceIdentifie bool CDM_Document::IsInSession(const int aReferenceIdentifier) const { if (aReferenceIdentifier == 0) + { return true; + } occ::handle theReference = Reference(aReferenceIdentifier); if (theReference.IsNull()) + { throw Standard_NoSuchObject("CDM_Document::IsInSession: " "invalid reference identifier"); + } return theReference->IsInSession(); } @@ -203,11 +216,15 @@ bool CDM_Document::IsInSession(const int aReferenceIdentifier) const bool CDM_Document::IsStored(const int aReferenceIdentifier) const { if (aReferenceIdentifier == 0) + { return IsStored(); + } occ::handle theReference = Reference(aReferenceIdentifier); if (theReference.IsNull()) + { throw Standard_NoSuchObject("CDM_Document::IsInSession: " "invalid reference identifier"); + } return theReference->IsStored(); } @@ -216,10 +233,14 @@ bool CDM_Document::IsStored(const int aReferenceIdentifier) const TCollection_ExtendedString CDM_Document::Name(const int aReferenceIdentifier) const { if (!IsStored(aReferenceIdentifier)) + { throw Standard_DomainError("CDM_Document::Name: document is not stored"); + } if (aReferenceIdentifier == 0) + { return myMetaData->Name(); + } return Reference(aReferenceIdentifier)->MetaData()->Name(); } @@ -238,7 +259,9 @@ void CDM_Document::UpdateFromDocuments(void* const aModifContext) const for (; itUpdate.More(); itUpdate.Next()) { if (itUpdate.Value() == theFromDocument) + { break; + } if (itUpdate.Value()->ShallowReferences(theFromDocument)) { @@ -247,7 +270,9 @@ void CDM_Document::UpdateFromDocuments(void* const aModifContext) const } } if (!itUpdate.More()) + { aListOfDocumentsToUpdate.Append(theFromDocument); + } theFromDocument->Update(this, it.Value()->ReferenceIdentifier(), aModifContext); } @@ -294,7 +319,9 @@ bool CDM_Document::ShallowReferences(const occ::handle& aDocument) for (; it.More(); it.Next()) { if (it.Value()->Document() == aDocument) + { return true; + } } return false; } @@ -310,9 +337,13 @@ bool CDM_Document::DeepReferences(const occ::handle& aDocument) co if (!theToDocument.IsNull()) { if (theToDocument == aDocument) + { return true; + } if (theToDocument->DeepReferences(aDocument)) + { return true; + } } } return false; @@ -332,10 +363,12 @@ int CDM_Document::CopyReference(const occ::handle& /*aFromDocument return CreateReference(theDocument); } else + { return CreateReference(theReference->MetaData(), theReference->Application(), theReference->DocumentVersion(), theReference->UseStorageConfiguration()); + } } return 0; // for NT ... } @@ -416,7 +449,9 @@ void CDM_Document::Comments(NCollection_Sequence& aC const char16_t* CDM_Document::Comment() const { if (myComments.Length() < 1) + { return nullptr; + } return myComments(1).ToExtString(); } @@ -471,7 +506,9 @@ void CDM_Document::SetMetaData(const occ::handle& aMetaData) SetRequestedFolder(aMetaData->Folder()); if (aMetaData->HasVersion()) + { SetRequestedPreviousVersion(aMetaData->Version()); + } } //================================================================================================= @@ -489,8 +526,10 @@ void CDM_Document::UnsetIsStored() occ::handle CDM_Document::MetaData() const { if (myMetaData.IsNull()) + { throw Standard_NoSuchObject("cannot furnish the MetaData of an object " "which is not stored"); + } return myMetaData; } @@ -513,8 +552,10 @@ TCollection_ExtendedString CDM_Document::RequestedComment() const TCollection_ExtendedString CDM_Document::Folder() const { if (myMetaData.IsNull()) + { throw Standard_NoSuchObject("cannot furnish the folder of an object " "which is not stored"); + } return myMetaData->Folder(); } @@ -561,9 +602,13 @@ TCollection_ExtendedString CDM_Document::RequestedName() if (!myRequestedNameIsDefined) { if (!myMetaData.IsNull()) + { myRequestedName = myMetaData->Name(); + } else + { myRequestedName = "Document_"; + } } myRequestedNameIsDefined = true; return myRequestedName; @@ -616,7 +661,9 @@ bool CDM_Document::IsOpened(const int aReferenceIdentifier) const for (; it.More(); it.Next()) { if (aReferenceIdentifier == it.Value()->ReferenceIdentifier()) + { return it.Value()->IsOpened(); + } } return false; } @@ -669,20 +716,28 @@ void CDM_Document::Close() CDM_CanCloseStatus CDM_Document::CanClose() const { if (!IsOpened()) + { return CDM_CCS_NotOpen; + } if (FromReferencesNumber() != 0) { if (!IsStored()) + { return CDM_CCS_UnstoredReferenced; + } if (IsModified()) + { return CDM_CCS_ModifiedReferenced; + } NCollection_List>::Iterator it(myFromReferences); for (; it.More(); it.Next()) { if (!it.Value()->FromDocument()->CanCloseReference(this, it.Value()->ReferenceIdentifier())) + { return CDM_CCS_ReferenceRejection; + } } } return CDM_CCS_OK; @@ -708,8 +763,10 @@ void CDM_Document::CloseReference(const occ::handle& /*aDocument*/ const occ::handle& CDM_Document::Application() const { if (!IsOpened()) + { throw Standard_Failure("this document has not yet been opened " "by any application"); + } return myApplication; } @@ -768,7 +825,9 @@ int CDM_Document::CreateReference(const occ::handle& aMetaData, for (; it.More(); it.Next()) { if (aMetaData == it.Value()->MetaData()) + { return it.Value()->ReferenceIdentifier(); + } } occ::handle r = new CDM_Reference(this, aMetaData, @@ -829,7 +888,9 @@ static void FIND(const occ::handle& theDocumentResource, { IsDef = UTL::Find(theDocumentResource, theResourceName); if (IsDef) + { theValue = UTL::Value(theDocumentResource, theResourceName); + } } //================================================================================================= @@ -840,7 +901,7 @@ occ::handle CDM_Document::StorageResource() { Standard_SStream aMsg; aMsg << "this document of format " << StorageFormat() - << " has not yet been opened by any application. " << std::endl; + << " has not yet been opened by any application. " << '\n'; throw Standard_Failure(aMsg.str().c_str()); } return myApplication->Resources(); @@ -871,7 +932,6 @@ void CDM_Document::LoadResources() // std::cout << "resource Loaded: Format: " << theFormat << ", FileExtension:" << // myFileExtension << ", Description:" << myDescription << std::endl; } - return; } //================================================================================================= @@ -911,7 +971,9 @@ TCollection_ExtendedString CDM_Document::Description() bool CDM_Document::IsReadOnly() const { if (IsStored()) + { return myMetaData->IsReadOnly(); + } return false; } @@ -927,7 +989,9 @@ bool CDM_Document::IsReadOnly(const int aReferenceIdentifier) const void CDM_Document::SetIsReadOnly() { if (IsStored()) + { myMetaData->SetIsReadOnly(); + } } //================================================================================================= @@ -935,7 +999,9 @@ void CDM_Document::SetIsReadOnly() void CDM_Document::UnsetIsReadOnly() { if (IsStored()) + { myMetaData->UnsetIsReadOnly(); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKCDF/CDM/CDM_MetaData.cxx b/src/ApplicationFramework/TKCDF/CDM/CDM_MetaData.cxx index 3637d9d424..5986056caa 100644 --- a/src/ApplicationFramework/TKCDF/CDM/CDM_MetaData.cxx +++ b/src/ApplicationFramework/TKCDF/CDM/CDM_MetaData.cxx @@ -170,10 +170,12 @@ Standard_OStream& CDM_MetaData::Print(Standard_OStream& anOStream) const anOStream << "*CDM_MetaData*"; anOStream << myFolder << "," << myName; if (HasVersion()) + { anOStream << "," << myVersion; + } anOStream << "; Physical situation: "; anOStream << myFileName; - anOStream << std::endl; + anOStream << '\n'; return anOStream; } @@ -185,7 +187,9 @@ Standard_OStream& CDM_MetaData::operator<<(Standard_OStream& anOStream) int CDM_MetaData::DocumentVersion(const occ::handle& anApplication) { if (myDocumentVersion == 0) + { myDocumentVersion = anApplication->DocumentVersion(this); + } return myDocumentVersion; } diff --git a/src/ApplicationFramework/TKCDF/CDM/CDM_Reference.cxx b/src/ApplicationFramework/TKCDF/CDM/CDM_Reference.cxx index 4d38659697..343cddb2d8 100644 --- a/src/ApplicationFramework/TKCDF/CDM/CDM_Reference.cxx +++ b/src/ApplicationFramework/TKCDF/CDM/CDM_Reference.cxx @@ -87,9 +87,13 @@ bool CDM_Reference::IsUpToDate() const { int theActualDocumentVersion; if (myToDocument.IsNull()) + { theActualDocumentVersion = myMetaData->DocumentVersion(myApplication); + } else + { theActualDocumentVersion = myToDocument->Modifications(); + } return myDocumentVersion == theActualDocumentVersion; } @@ -99,12 +103,18 @@ void CDM_Reference::SetIsUpToDate() int theActualDocumentVersion; if (myToDocument.IsNull()) + { theActualDocumentVersion = myMetaData->DocumentVersion(myApplication); + } else + { theActualDocumentVersion = myToDocument->Modifications(); + } if (theActualDocumentVersion != -1) + { myDocumentVersion = theActualDocumentVersion; + } } void CDM_Reference::UnsetToDocument(const occ::handle& aMetaData, @@ -123,14 +133,18 @@ int CDM_Reference::DocumentVersion() const bool CDM_Reference::IsOpened() const { if (myToDocument.IsNull()) + { return false; + } return myToDocument->IsOpened(); } bool CDM_Reference::IsReadOnly() const { if (myToDocument.IsNull()) + { return myMetaData->IsReadOnly(); + } return myToDocument->IsReadOnly(); } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOMBasicString.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOMBasicString.cxx index 4cee3747a9..baf8268eb2 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOMBasicString.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOMBasicString.cxx @@ -127,7 +127,9 @@ LDOMBasicString::~LDOMBasicString() LDOMBasicString& LDOMBasicString::operator=(const LDOM_NullPtr*) { if (myType == LDOM_AsciiFree) + { delete[] (char*)myVal.ptr; + } myType = LDOM_NULL; myVal.ptr = nullptr; return *this; @@ -142,7 +144,9 @@ LDOMBasicString& LDOMBasicString::operator=(const LDOMBasicString& anOther) return *this; } if (myType == LDOM_AsciiFree) + { delete[] (char*)myVal.ptr; + } myType = anOther.Type(); switch (myType) { @@ -254,13 +258,17 @@ LDOMBasicString::operator TCollection_ExtendedString() const errno = 0; // Check if ptr is ascii string if (ptr[0] != '#' || ptr[1] != '#') + { return TCollection_ExtendedString(ptr); + } buf[0] = ptr[2]; buf[1] = ptr[3]; buf[2] = ptr[4]; buf[3] = ptr[5]; if (strtol(&buf[0], nullptr, 16) != aUnicodeHeader) + { return TCollection_ExtendedString(ptr); + } // convert Unicode to Extended String ptr += 2; @@ -308,7 +316,9 @@ bool LDOMBasicString::GetInteger(int& aResult) const errno = 0; long aValue = strtol((const char*)myVal.ptr, &ptr, 10); if (ptr == myVal.ptr || errno == ERANGE || errno == EINVAL) + { return false; + } aResult = int(aValue); break; } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOMParser.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOMParser.cxx index 199f51c7d0..9de461d7d2 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOMParser.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOMParser.cxx @@ -131,7 +131,9 @@ const TCollection_AsciiString& LDOMParser::GetError(TCollection_AsciiString& aDa LDOM_OSStream::BOMType LDOMParser::GetBOM() const { if (myReader) + { return myReader->GetBOM(); + } return LDOM_OSStream::BOM_UNDEFINED; } @@ -256,7 +258,9 @@ bool LDOMParser::ParseDocument(std::istream& theIStream, const bool theWithoutRo } isError = ParseElement(theIStream, aDocStart); if (isError) + { break; + } continue; } isError = true; @@ -358,10 +362,14 @@ bool LDOMParser::ParseElement(Standard_IStream& theIStream, bool& theDocStart) if (IsDigit(aTextStr[0])) { if (LDOM_XmlReader::getInteger(aTextValue, aTextStr, aTextStr + aTextLen)) + { aTextValue = LDOMBasicString(aTextStr, aTextLen, myDocument); + } } else + { aTextValue = LDOMBasicString(aTextStr, aTextLen, myDocument); + } } goto create_text_node; case LDOM_XmlReader::XML_COMMENT: @@ -389,7 +397,9 @@ bool LDOMParser::ParseElement(Standard_IStream& theIStream, bool& theDocStart) default:; } if (isError) + { break; + } } return isError; } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicElement.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicElement.cxx index 013df94086..bd26874d05 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicElement.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicElement.cxx @@ -123,14 +123,20 @@ const LDOM_BasicNode* LDOM_BasicElement::GetLastChild() const if (aNode) { if (aNode->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { aNode = nullptr; + } else + { while (aNode->mySibling) { if (aNode->mySibling->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { break; + } aNode = aNode->mySibling; } + } } return aNode; } @@ -142,9 +148,13 @@ const LDOM_BasicAttribute& LDOM_BasicElement::GetAttribute(const LDOMBasicString { const LDOM_BasicNode* aNode; if (aLastCh) + { aNode = aLastCh->GetSibling(); + } else + { aNode = myFirstChild; + } const char* aNameStr = aName.GetString(); while (aNode) { @@ -152,7 +162,9 @@ const LDOM_BasicAttribute& LDOM_BasicElement::GetAttribute(const LDOMBasicString { const LDOM_BasicAttribute* anAttr = (const LDOM_BasicAttribute*)aNode; if (!strcmp(aNameStr, anAttr->GetName())) + { return *anAttr; + } } aNode = aNode->mySibling; } @@ -176,7 +188,9 @@ const LDOM_BasicAttribute* LDOM_BasicElement::GetFirstAttribute( while (aFirstAttr) { if (aFirstAttr->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { break; + } aPrevNode = (const LDOM_BasicNode**)&(aFirstAttr->mySibling); aFirstAttr = aFirstAttr->mySibling; } @@ -188,9 +202,13 @@ const LDOM_BasicAttribute* LDOM_BasicElement::GetFirstAttribute( while (aFirstAttr) { if (aFirstAttr->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { break; + } if (!aFirstAttr->isNull()) + { theLastCh = aFirstAttr; + } aPrevNode = (const LDOM_BasicNode**)&(aFirstAttr->mySibling); aFirstAttr = aFirstAttr->mySibling; } @@ -236,11 +254,13 @@ const LDOM_BasicNode* LDOM_BasicElement::AddAttribute(const LDOMBasicString& anA while (aCurrentAttr) { if (aCurrentAttr->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { if (LDOM_MemManager::CompareStrings(aNameStr, aHash, aCurrentAttr->GetName())) { aCurrentAttr->SetValue(anAttrValue, aDocument); break; } + } aCurrentAttr = (LDOM_BasicAttribute*)aCurrentAttr->mySibling; } if (aCurrentAttr == nullptr) @@ -280,11 +300,13 @@ const LDOM_BasicNode* LDOM_BasicElement::RemoveAttribute(const LDOMBasicString& while (anAttr) { if (anAttr->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { if (LDOM_MemManager::CompareStrings(aNameStr, aHash, anAttr->GetName())) { anAttr = nullptr; break; } + } anAttr = (const LDOM_BasicAttribute*)anAttr->mySibling; } } @@ -300,7 +322,9 @@ void LDOM_BasicElement::RemoveChild(const LDOM_BasicNode* aChild) const while (aNode) { if (aNode->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { break; + } if (aNode == aChild) { *aPrevNode = aNode->GetSibling(); @@ -355,13 +379,17 @@ void LDOM_BasicElement::AddElementsByTagName(LDOM_NodeList& aList, while (aNode) { if (aNode->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { break; + } if (aNode->getNodeType() == LDOM_Node::ELEMENT_NODE) { LDOM_BasicElement& anElement = *(LDOM_BasicElement*)aNode; // if (anElement.GetTagName().equals(aTagName)) if (strcmp(anElement.GetTagName(), aTagString) == 0) + { aList.Append(anElement); + } anElement.AddElementsByTagName(aList, aTagName); } aNode = aNode->GetSibling(); @@ -374,13 +402,19 @@ void LDOM_BasicElement::AddAttributes(LDOM_NodeList& aList, const LDOM_BasicNode { const LDOM_BasicNode* aBNode; if (aLastChild) + { aBNode = aLastChild->GetSibling(); + } else + { aBNode = GetFirstChild(); + } while (aBNode) { if (aBNode->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) + { aList.Append(*aBNode); + } aBNode = aBNode->GetSibling(); } } @@ -404,7 +438,9 @@ void LDOM_BasicElement::ReplaceElement(const LDOM_BasicElement& anOth for (; aBNode != nullptr; aBNode = aBNode->GetSibling()) { if (aBNode->isNull()) + { continue; + } LDOM_BasicNode* aNewBNode; const LDOM_Node::NodeType aNewNodeType = aBNode->getNodeType(); switch (aNewNodeType) @@ -433,9 +469,13 @@ void LDOM_BasicElement::ReplaceElement(const LDOM_BasicElement& anOth continue; } if (GetFirstChild()) + { (const LDOM_BasicNode*&)aLastChild->mySibling = aNewBNode; + } else + { (const LDOM_BasicNode*&)myFirstChild = aNewBNode; + } (const LDOM_BasicNode*&)aLastChild = aNewBNode; } @@ -446,15 +486,21 @@ loop_attr: { int aHash; if (aBNode->isNull()) + { continue; + } const LDOM_BasicAttribute* aBNodeAtt = (const LDOM_BasicAttribute*)aBNode; LDOM_BasicAttribute* aNewAtt = &LDOM_BasicAttribute::Create(aBNodeAtt->GetName(), aDocument, aHash); aNewAtt->SetValue(aBNodeAtt->myValue, aDocument); if (aLastAttr) + { aLastAttr->SetSibling(aNewAtt); + } else + { myFirstChild = aNewAtt; + } aLastAttr = aNewAtt; } } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicNode.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicNode.cxx index 2a76b6431c..9a8735a7ec 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicNode.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_BasicNode.cxx @@ -33,10 +33,16 @@ LDOM_BasicNode& LDOM_BasicNode::operator=(const LDOM_BasicNode& anOther) const LDOM_BasicNode* LDOM_BasicNode::GetSibling() const { while (mySibling) + { if (mySibling->isNull()) + { (const LDOM_BasicNode*&)mySibling = mySibling->mySibling; + } else + { break; + } + } return mySibling; } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharReference.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharReference.cxx index 3cea1ed8ee..715c63d275 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharReference.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharReference.cxx @@ -68,7 +68,9 @@ char* LDOM_CharReference::Decode(char* theSrc, int& theLen) // End of the loop aPtr = strchr(aSrcPtr, '\0'); if (anIncrCount == 0) + { theLen = (int)(aPtr - theSrc); + } else { int aByteCount = (int)(aPtr - aSrcPtr); @@ -79,7 +81,9 @@ char* LDOM_CharReference::Decode(char* theSrc, int& theLen) } int aByteCount = (int)(aPtr - aSrcPtr); if (aByteCount > 0 && aDstPtr != aSrcPtr) + { memmove(aDstPtr, aSrcPtr, aByteCount); + } aSrcPtr = aPtr; if (aSrcPtr[1] == '#') { @@ -87,12 +91,18 @@ char* LDOM_CharReference::Decode(char* theSrc, int& theLen) char* aNewPtr; aDstPtr = aSrcPtr - anIncrCount + 1; if (aSrcPtr[2] == 'x') + { aChar = strtoul(&aSrcPtr[3], &aNewPtr, 16); // hex encoding + } else + { aChar = strtoul(&aSrcPtr[2], &aNewPtr, 10); // decimal encoding + } if (aNewPtr[0] != ';' || aChar == 0 || aChar > 255UL) + { // Error reading an XML string return nullptr; + } aDstPtr[-1] = (char)aChar; anIncrCount += (int)(aNewPtr - aSrcPtr); aSrcPtr = &aNewPtr[1]; @@ -174,13 +184,19 @@ char* LDOM_CharReference::Encode(const char* theSrc, int& theLen, const bool isA break; } if (myTab[iSrc] != NORMAL_C) + { if (isAttribute || myTab[iSrc] != ENTI_QUOT) + { aCount++; + } + } ptrSrc++; } // If there are such, copy the string with replacements if (!aCount) + { theLen = (int)(endSrc - theSrc); + } else { char* ptrDest = new char[(endSrc - theSrc) + aCount * 5 + 1]; @@ -189,8 +205,10 @@ char* LDOM_CharReference::Encode(const char* theSrc, int& theLen, const bool isA { const unsigned int iSrc = (unsigned int)*(const unsigned char*)ptrSrc; const int aCode = myTab[iSrc]; - if (aCode == NORMAL_C) // normal (regular) character + if (aCode == NORMAL_C) + { // normal (regular) character *ptrDest++ = *ptrSrc; + } else if (aCode == CHAR_REF) { // character reference Sprintf(ptrDest, "&#x%02x;", iSrc); @@ -198,7 +216,9 @@ char* LDOM_CharReference::Encode(const char* theSrc, int& theLen, const bool isA } else // predefined entity reference if (!isAttribute && aCode == ENTI_QUOT) + { *ptrDest++ = *ptrSrc; + } else { memcpy(ptrDest, entity_ref[aCode].name, entity_ref[aCode].length + 1); diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharacterData.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharacterData.cxx index f433b0964c..b5d23724e3 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharacterData.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_CharacterData.cxx @@ -52,6 +52,8 @@ void LDOM_CharacterData::setData(const LDOMString& theValue) int LDOM_CharacterData::getLength() const { if (myLength < 0) + { (int&)myLength = (int)strlen(getNodeValue().GetString()); + } return myLength; } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Document.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Document.cxx index 830ca38d94..c8d92ee123 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Document.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Document.cxx @@ -47,7 +47,9 @@ bool LDOM_Document::isNull() const { const LDOM_BasicElement* const aRootElement = myMemManager->RootElement(); if (aRootElement == nullptr) + { return true; + } return aRootElement->isNull(); } @@ -69,7 +71,9 @@ LDOM_NodeList LDOM_Document::getElementsByTagName(const LDOMString& theTagName) { // if (anElem -> GetTagName().equals(theTagName)) if (strcmp(anElem->GetTagName(), aTagString) == 0) + { aList.Append(*anElem); + } anElem->AddElementsByTagName(aList, theTagName); } return aList; @@ -82,7 +86,9 @@ LDOM_Document LDOM_Document::createDocument(const LDOMString& theQualifiedName) LDOM_Document aDoc; const char* aString = theQualifiedName.GetString(); if (strlen(aString) == 0) + { aString = "document"; + } aDoc.myMemManager->myRootElement = &LDOM_BasicElement::Create(aString, (int)strlen(aString), aDoc.myMemManager); return aDoc; diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Element.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Element.cxx index 63543d86c1..1cdc506d9c 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Element.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Element.cxx @@ -35,16 +35,21 @@ LDOMString LDOM_Element::getAttribute(const LDOMString& aName) const { const LDOM_BasicElement& anElem = (const LDOM_BasicElement&)Origin(); if (anElem.isNull()) + { return LDOMString(); + } if (myLastChild == nullptr) { const LDOM_BasicNode* aNode = anElem.GetFirstChild(); if (aNode && aNode->getNodeType() != LDOM_Node::ATTRIBUTE_NODE) + { for (;;) { const LDOM_BasicNode* aSibling = aNode->GetSibling(); if (aSibling == nullptr) + { return LDOMString(); + } if (aSibling->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) { (const LDOM_BasicNode*&)myLastChild = aNode; @@ -52,10 +57,13 @@ LDOMString LDOM_Element::getAttribute(const LDOMString& aName) const } aNode = aSibling; } + } } const LDOM_BasicAttribute& anAttr = anElem.GetAttribute(aName, myLastChild); if (anAttr.isNull()) + { return LDOMString(); + } return LDOMString(anAttr.GetValue(), myDocument->Self()); } @@ -65,16 +73,21 @@ LDOM_Attr LDOM_Element::getAttributeNode(const LDOMString& aName) const { const LDOM_BasicElement& anElem = (const LDOM_BasicElement&)Origin(); if (anElem.isNull()) + { return LDOM_Attr(); + } if (myLastChild == nullptr) { const LDOM_BasicNode* aNode = anElem.GetFirstChild(); if (aNode && aNode->getNodeType() != LDOM_Node::ATTRIBUTE_NODE) + { for (;;) { const LDOM_BasicNode* aSibling = aNode->GetSibling(); if (aSibling == nullptr) + { return LDOM_Attr(); + } if (aSibling->getNodeType() == LDOM_Node::ATTRIBUTE_NODE) { (const LDOM_BasicNode*&)myLastChild = aSibling; @@ -82,6 +95,7 @@ LDOM_Attr LDOM_Element::getAttributeNode(const LDOMString& aName) const } aNode = aSibling; } + } } const LDOM_BasicAttribute& anAttr = anElem.GetAttribute(aName, myLastChild); return LDOM_Attr(anAttr, myDocument); @@ -97,7 +111,9 @@ LDOM_NodeList LDOM_Element::getElementsByTagName(const LDOMString& theTagName) c const LDOM_BasicElement& anElem = (const LDOM_BasicElement&)Origin(); // if (anElem.GetTagName().equals(theTagName)) if (strcmp(anElem.GetTagName(), theTagName.GetString()) == 0) + { aList.Append(anElem); + } anElem.AddElementsByTagName(aList, theTagName); } return aList; @@ -109,7 +125,9 @@ void LDOM_Element::setAttribute(const LDOMString& aName, const LDOMString& aVal) { LDOM_BasicElement& anElem = (LDOM_BasicElement&)Origin(); if (anElem.isNull()) + { return; + } myLastChild = anElem.AddAttribute(aName, LDOMString(aVal, myDocument), myDocument, myLastChild); } @@ -127,7 +145,9 @@ void LDOM_Element::removeAttribute(const LDOMString& aName) { const LDOM_BasicElement& anElem = (const LDOM_BasicElement&)Origin(); if (anElem.isNull()) + { return; + } anElem.RemoveAttribute(aName, myLastChild); } @@ -138,7 +158,9 @@ LDOM_Element LDOM_Element::GetChildByTagName(const LDOMString& aTagName) const // Verify preconditions LDOM_Element aVoidElement; if (isNull() || aTagName == nullptr) + { return aVoidElement; + } // Take the first child. If it doesn't match look for other ones in a loop LDOM_Node aChildNode = getFirstChild(); @@ -146,7 +168,9 @@ LDOM_Element LDOM_Element::GetChildByTagName(const LDOMString& aTagName) const { const LDOM_Node::NodeType aNodeType = aChildNode.getNodeType(); if (aNodeType == LDOM_Node::ATTRIBUTE_NODE) + { break; + } if (aNodeType == LDOM_Node::ELEMENT_NODE) { LDOMString @@ -156,7 +180,9 @@ LDOM_Element LDOM_Element::GetChildByTagName(const LDOMString& aTagName) const #endif aNodeName = aChildNode.getNodeName(); // use DOM1 if (aNodeName.equals(aTagName)) + { return (LDOM_Element&)aChildNode; // a match has been found + } } aChildNode = aChildNode.getNextSibling(); } @@ -170,7 +196,9 @@ LDOM_Element LDOM_Element::GetSiblingByTagName() const // Verify preconditions LDOM_Element aVoidElement; if (isNull()) + { return aVoidElement; + } LDOMString aTagName = getTagName(); @@ -180,12 +208,16 @@ LDOM_Element LDOM_Element::GetSiblingByTagName() const { const LDOM_Node::NodeType aNodeType = aNextNode.getNodeType(); if (aNodeType == LDOM_Node::ATTRIBUTE_NODE) + { break; + } if (aNodeType == LDOM_Node::ELEMENT_NODE) { LDOM_Element aNextElement = (LDOM_Element&)aNextNode; if (aNextElement.getTagName().equals(aTagName)) + { return aNextElement; // a match has been found + } } aNextNode = aNextNode.getNextSibling(); } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_MemManager.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_MemManager.cxx index 551f84996f..00744be0da 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_MemManager.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_MemManager.cxx @@ -35,7 +35,9 @@ inline bool compareStrings(char* const str, const char* theString, const int the // memcmp (str, theString, theLength) == 0); // ** This is a more stable (less performant) solution if (memcmp(str, theString, theLength)) + { return false; + } return (str[theLength] == '\0'); } @@ -77,10 +79,14 @@ void* LDOM_MemManager::MemBlock::AllocateAndCheck( if (aRoom < MINIMAL_ROOM) { if (aFirstWithoutRoom == nullptr) + { aFirstWithoutRoom = this; + } } else + { aFirstWithoutRoom = nullptr; + } return aResult; } @@ -188,7 +194,9 @@ const char* LDOM_MemManager::HashTable::AddString(const char* theString, { const char* aResult = nullptr; if (theString == nullptr) + { return nullptr; + } int aHashIndex = Hash(theString, theLen); TableItem* aNode = &myTable[aHashIndex]; if (aNode->str == nullptr) @@ -204,8 +212,11 @@ const char* LDOM_MemManager::HashTable::AddString(const char* theString, else { if (compareStrings(aNode->str, theString, theLen)) + { aResult = aNode->str; + } else + { while (aNode->next) { aNode = aNode->next; @@ -215,6 +226,7 @@ const char* LDOM_MemManager::HashTable::AddString(const char* theString, break; } } + } if (aResult == nullptr) { // Attention!!! We can make this allocation in a separate pool @@ -276,14 +288,18 @@ void* LDOM_MemManager::Allocate(const int theSize) } aResult = aBlock->Allocate(aSize); if (aResult) + { return aResult; + } aBlock = aBlock->Next(); const MemBlock* aFirstWithoutRoom = nullptr; while (aBlock != myFirstWithoutRoom) { aResult = aBlock->AllocateAndCheck(aSize, aFirstWithoutRoom); if (aResult) + { break; + } aBlock = aBlock->Next(); } myFirstWithoutRoom = (MemBlock*&)aFirstWithoutRoom; @@ -305,7 +321,9 @@ void* LDOM_MemManager::Allocate(const int theSize) const char* LDOM_MemManager::HashedAllocate(const char* theString, const int theLen, int& theHash) { if (myHashTable == nullptr) + { myHashTable = new HashTable(*this); + } return myHashTable->AddString(theString, theLen, theHash); } @@ -323,7 +341,9 @@ void LDOM_MemManager::HashedAllocate(const char* aString, int aDummy; const char* aHashedString = HashedAllocate(aString, theLen, aDummy); if (aHashedString != nullptr) + { theResult.myVal.ptr = (void*)aHashedString; + } } //================================================================================================= @@ -333,7 +353,11 @@ bool LDOM_MemManager::CompareStrings(const char* theString, const char* theHashedStr) { if (((LDOM_HashValue*)theHashedStr)[-1] == LDOM_HashValue(theHashValue)) + { if (!strcmp(theString, theHashedStr)) + { return true; + } + } return false; } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Node.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Node.cxx index bd782d7818..92a20c424e 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_Node.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_Node.cxx @@ -62,7 +62,9 @@ bool LDOM_Node::isNull() const bool LDOM_Node::operator==(const LDOM_Node& anOther) const { if (isNull()) + { return anOther.isNull(); + } return myOrigin == anOther.myOrigin; } @@ -74,7 +76,9 @@ bool LDOM_Node::operator==(const LDOM_Node& anOther) const bool LDOM_Node::operator!=(const LDOM_Node& anOther) const { if (isNull()) + { return !anOther.isNull(); + } return myOrigin != anOther.myOrigin; } @@ -135,8 +139,12 @@ LDOM_Node LDOM_Node::getFirstChild() const const LDOM_BasicElement& anElement = *(const LDOM_BasicElement*)myOrigin; const LDOM_BasicNode* aChild = anElement.GetFirstChild(); if (aChild) + { if (aChild->getNodeType() != LDOM_Node::ATTRIBUTE_NODE) + { return LDOM_Node(*aChild, myDocument); + } + } } return LDOM_Node(); } @@ -164,8 +172,12 @@ LDOM_Node LDOM_Node::getNextSibling() const { const LDOM_BasicNode* aSibling = myOrigin->mySibling; if (aSibling) + { if (aSibling->getNodeType() != ATTRIBUTE_NODE) + { return LDOM_Node(*aSibling, myDocument); + } + } return LDOM_Node(); } @@ -178,10 +190,14 @@ void LDOM_Node::removeChild(const LDOM_Node& aChild) { const LDOM_BasicElement& anElement = *(LDOM_BasicElement*)myOrigin; if (aChild != nullptr) + { anElement.RemoveChild(aChild.myOrigin); + } if (aChild.myOrigin == myLastChild) + { // myLastChild = anElement.GetLastChild(); myLastChild = nullptr; + } } } @@ -216,7 +232,9 @@ bool LDOM_Node::hasChildNodes() const const LDOM_BasicElement& anElement = *(const LDOM_BasicElement*)myOrigin; const LDOM_BasicNode* aChild = anElement.GetFirstChild(); if (aChild) + { return !aChild->isNull(); + } } return false; } @@ -244,5 +262,7 @@ void LDOM_Node::SetValueClear() const return; } if (aValue->Type() == LDOMBasicString::LDOM_AsciiDoc) + { aValue->myType = LDOMBasicString::LDOM_AsciiDocClear; + } } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_NodeList.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_NodeList.cxx index 52930cec0e..38ad1976db 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_NodeList.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_NodeList.cxx @@ -100,7 +100,9 @@ bool LDOM_NodeList::operator!=(const LDOM_NullPtr*) const LDOM_Node LDOM_NodeList::item(const int anIndex) const { if (myDoc.IsNull() || anIndex < 0 || anIndex >= mySeq->Length()) + { return LDOM_Node(); + } return LDOM_Node(*mySeq->Value(anIndex + 1), myDoc); } diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlReader.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlReader.cxx index 77abfe5e39..2d65e97d66 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlReader.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlReader.cxx @@ -103,7 +103,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre if (myEOF) { if (aBytesRest <= 0) + { break; // END of processing + } } else if (myTagPerStep && aHasRead) { @@ -116,7 +118,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre if (aStartData /* && aState != STATE_WAITING */) { if (myPtr > aStartData) + { theData.rdbuf()->sputn(aStartData, myPtr - aStartData); + } aStartData = &myBuffer[0]; } // Copy the rest of file data to the beginning of buffer @@ -206,9 +210,13 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre { myBOM = LDOM_OSStream::BOM_UTF7; if (myPtr[3] == 56 && myPtr[4] == 45) + { myPtr += 5; + } else + { myPtr += 4; + } } break; case 0xF7: @@ -249,7 +257,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre break; } if (myBOM != LDOM_OSStream::BOM_UNDEFINED) + { continue; + } } // Check the character data @@ -291,7 +301,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre { char ch = myPtr[9]; if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') + { break; + } aState = STATE_DOCTYPE; myPtr += 10; } @@ -301,7 +313,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre myPtr += 9; } else + { break; // ERROR + } aStartData = myPtr; continue; default: @@ -318,7 +332,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre aStartData = nullptr; } else + { aState = STATE_ELEMENT; + } continue; } // otherwise ERROR } // end of switch @@ -327,7 +343,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre return XML_UNKNOWN; case '\0': if (myEOF) + { continue; + } [[fallthrough]]; default: // Limitation: we do not treat '&' as special character @@ -419,9 +437,13 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre { aPtr = (const char*)memchr(aPtr, '-', (myEndPtr - 2) - aPtr); if (aPtr == nullptr) + { break; + } if (aPtr[1] != '-') + { ++aPtr; + } else { if (aPtr[2] != '>') @@ -461,7 +483,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre { aPtr = (const char*)memchr(aPtr, ']', (myEndPtr - 1) - aStartData); if (aPtr == nullptr) + { break; + } if (aPtr[1] != ']') { // ERROR myError = "Characters \']]\' are expected in the end of CDATA"; @@ -479,11 +503,13 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ case STATE_ELEMENT: if (!::isName(myPtr, myEndPtr, aNameEnd)) + { if (theData.Length() == 0 || aNameEnd != myPtr) { myError = "Invalid tag name"; return XML_UNKNOWN; } + } { theData.rdbuf()->sputn(aStartData, aNameEnd - aStartData); char* aDataString = (char*)theData.str(); @@ -506,14 +532,20 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre case '\n': case '\r': if (aStartData) + { goto attr_name; + } ++myPtr; continue; case '/': if (aStartData) + { myError = "Inexpected end of attribute"; + } else if (myPtr[1] != '>') + { myError = "Improper element tag termination"; + } else { myPtr += 2; @@ -538,17 +570,23 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre return XML_START_ELEMENT; default: if (!::isName(myPtr, myEndPtr, aNameEnd)) + { if (theData.Length() == 0 || aNameEnd != myPtr) { myError = "Invalid attribute name"; return XML_UNKNOWN; } + } if (aNameEnd >= myEndPtr) + { aStartData = myPtr; + } else { if (theData.Length() == 0) + { anAttrName = LDOMBasicString(myPtr, (int)(aNameEnd - myPtr), myDocument); + } else { theData.rdbuf()->sputn(myPtr, aNameEnd - myPtr); @@ -629,10 +667,14 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord(Standard_IStream& theIStre if (IsDigit(aDataString[0])) { if (getInteger(anAttrValue, aDataString, ePtr)) + { anAttrValue = LDOMBasicString(aDataString, aDataLen, myDocument); + } } else + { anAttrValue = LDOMBasicString(aDataString, aDataLen, myDocument); + } if (theData.Length() > 0) { diff --git a/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlWriter.cxx b/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlWriter.cxx index e618a1b14d..d3d24827f0 100644 --- a/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlWriter.cxx +++ b/src/ApplicationFramework/TKCDF/LDOM/LDOM_XmlWriter.cxx @@ -152,7 +152,9 @@ static char* getEncodingName(const char* theEncodingName) int aLen = 0; while (anEncoding[aLen++] != chNull) + { ; + } char* aResult = new char[aLen]; memcpy(aResult, anEncoding, aLen * sizeof(char)); @@ -315,7 +317,7 @@ void LDOM_XmlWriter::Write(Standard_OStream& theOStream, const LDOM_Node& theNod } default: #ifndef _MSC_VER - std::cerr << "Unrecognized node type = " << (long)theNode.getNodeType() << std::endl + std::cerr << "Unrecognized node type = " << (long)theNode.getNodeType() << '\n' #endif ; } diff --git a/src/ApplicationFramework/TKCDF/PCDM/PCDM_DOMHeaderParser.cxx b/src/ApplicationFramework/TKCDF/PCDM/PCDM_DOMHeaderParser.cxx index 8fba4afa44..ea653c36d7 100644 --- a/src/ApplicationFramework/TKCDF/PCDM/PCDM_DOMHeaderParser.cxx +++ b/src/ApplicationFramework/TKCDF/PCDM/PCDM_DOMHeaderParser.cxx @@ -40,7 +40,9 @@ void PCDM_DOMHeaderParser::SetEndElementName(const TCollection_AsciiString& anEn bool PCDM_DOMHeaderParser::startElement() { if (myStartElementName == nullptr) + { return false; + } myElement = getCurrentElement(); return (myElement.getTagName().equals(myStartElementName)); } @@ -50,7 +52,9 @@ bool PCDM_DOMHeaderParser::startElement() bool PCDM_DOMHeaderParser::endElement() { if (myEndElementName == nullptr) + { return false; + } myElement = getCurrentElement(); return (myElement.getTagName().equals(myEndElementName)); } diff --git a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter.cxx b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter.cxx index 02962fa61c..0f2f93ae77 100644 --- a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter.cxx +++ b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter.cxx @@ -103,7 +103,9 @@ TCollection_ExtendedString PCDM_ReadWriter::FileFormat(const TCollection_Extende // conversion to UTF-8 is done inside TCollection_AsciiString theFileName(aFileName); if (PCDM::FileDriverType(theFileName, theFileDriver) == PCDM_TOFD_Unknown) + { return ::TryXmlDriverType(theFileName); + } bool theFileIsOpen(false); try @@ -194,7 +196,9 @@ static TCollection_ExtendedString TryXmlDriverType(const TCollection_AsciiString { const LDOM_Element& anElement = aParser.GetElement(); if (anElement.getTagName().equals(LDOMString(aDocumentElementName))) + { theFormat = anElement.getAttribute("format"); + } } return theFormat; } @@ -219,7 +223,9 @@ static TCollection_ExtendedString TryXmlDriverType(Standard_IStream& theIStream) { const LDOM_Element& anElement = aParser.GetElement(); if (anElement.getTagName().equals(LDOMString(aDocumentElementName))) + { theFormat = anElement.getAttribute("format"); + } } } diff --git a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx index cdf3ae32f6..bd55e9404f 100644 --- a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx +++ b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx @@ -63,12 +63,18 @@ static int RemoveExtraSeparator(TCollection_AsciiString& aString) char c = aString.Value(j); aString.SetValue(i, c); if (c == '/') + { while (j < len && aString.Value(j + 1) == '/') + { j++; + } + } } len = i - 1; if (aString.Value(len) == '/') + { len--; + } aString.Trunc(len); return len; } @@ -80,20 +86,26 @@ static TCollection_AsciiString AbsolutePath(const TCollection_AsciiString& aDirP #ifdef _WIN32 if (aRelFilePath.Search(":") == 2 || (aRelFilePath.Search("\\") == 1 && aRelFilePath.Value(2) == '\\')) + { #else if (aRelFilePath.Search("/") == 1) + { #endif return aRelFilePath; + } TCollection_AsciiString DirPath = aDirPath, RelFilePath = aRelFilePath; int i, len; #ifdef _WIN32 if (DirPath.Search(":") != 2 && (DirPath.Search("\\") != 1 || DirPath.Value(2) != '\\')) + { #else if (DirPath.Search("/") != 1) + { #endif return EmptyString; + } #ifdef _WIN32 DirPath.ChangeAll('\\', '/'); @@ -106,14 +118,20 @@ static TCollection_AsciiString AbsolutePath(const TCollection_AsciiString& aDirP while (RelFilePath.Search("../") == 1) { if (len == 3) + { return EmptyString; + } RelFilePath = RelFilePath.SubString(4, len); len -= 3; if (DirPath.IsEmpty()) + { return EmptyString; + } i = DirPath.SearchFromEnd("/"); if (i < 0) + { return EmptyString; + } DirPath.Trunc(i - 1); } TCollection_AsciiString retx; @@ -134,7 +152,9 @@ static TCollection_AsciiString GetDirFromFile(const TCollection_ExtendedString& i = theCFile.SearchFromEnd("\\"); #endif if (i != -1) + { theDirectory = theCFile.SubString(1, i); + } return theDirectory; } @@ -188,7 +208,9 @@ void PCDM_ReadWriter_1::WriteReferences( { theRelativePath = OSD_Path::RelativePath(theAbsoluteDirectory, thePath); if (!theRelativePath.IsEmpty()) + { thePath = theRelativePath; + } } ligne += TCollection_ExtendedString(thePath); UTL::AddToUserInfo(aData, ligne); @@ -240,7 +262,9 @@ int PCDM_ReadWriter_1::ReadReferenceCounter( occ::handle theFileDriver; TCollection_AsciiString aFileNameU(aFileName); if (PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown) + { return theReferencesCounter; + } bool theFileIsOpen(false); try @@ -268,7 +292,9 @@ int PCDM_ReadWriter_1::ReadReferenceCounter( TCollection_ExtendedString aMsg("Warning: "); aMsg = aMsg.Cat("could not read the reference counter in ").Cat(aFileName).Cat("\0"); if (!theMsgDriver.IsNull()) + { theMsgDriver->Send(aMsg.ToExtString()); + } } } } @@ -321,7 +347,9 @@ void PCDM_ReadWriter_1::ReadReferences(const TCollection_ExtendedString& aFi { theAbsolutePath = AbsolutePath(theAbsoluteDirectory, thePath); if (!theAbsolutePath.IsEmpty()) + { thePath = theAbsolutePath; + } } if (!theMsgDriver.IsNull()) { @@ -366,7 +394,9 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& occ::handle theFileDriver; TCollection_AsciiString aFileNameU(aFileName); if (PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown) + { return; + } PCDM_ReadWriter::Open(theFileDriver, aFileName, Storage_VSRead); occ::handle s = new Storage_Schema; @@ -380,9 +410,13 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& { TCollection_ExtendedString theLine = refUserInfo(i); if (refUserInfo(i) == Start) + { debut = i; + } if (refUserInfo(i) == End) + { fin = i; + } } if (debut != 0) { @@ -405,7 +439,9 @@ int PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_ExtendedString& occ::handle theFileDriver; TCollection_AsciiString aFileNameU(aFileName); if (PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown) + { return theVersion; + } bool theFileIsOpen(false); @@ -434,7 +470,9 @@ int PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_ExtendedString& TCollection_ExtendedString aMsg("Warning: "); aMsg = aMsg.Cat("could not read the version in ").Cat(aFileName).Cat("\0"); if (!theMsgDriver.IsNull()) + { theMsgDriver->Send(aMsg.ToExtString()); + } } } } diff --git a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReaderFilter.cxx b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReaderFilter.cxx index 8bfa558965..ab1bf9e9f4 100644 --- a/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReaderFilter.cxx +++ b/src/ApplicationFramework/TKCDF/PCDM/PCDM_ReaderFilter.cxx @@ -57,16 +57,19 @@ bool PCDM_ReaderFilter::IsPassedAttr(const TCollection_AsciiString& theAttribute bool PCDM_ReaderFilter::IsPassed(const TCollection_AsciiString& theEntry) const { if (mySubTrees.IsEmpty()) + { return true; + } for (NCollection_List::Iterator anEntry(mySubTrees); anEntry.More(); anEntry.Next()) { if (theEntry.StartsWith(anEntry.Value())) { if (theEntry.Length() > anEntry.Value().Length() - && theEntry.Value(anEntry.Value().Length() + 1) - != ':') // case when theEntry="0:10" should not match "0:1" + && theEntry.Value(anEntry.Value().Length() + 1) != ':') + { // case when theEntry="0:10" should not match "0:1" continue; + } return true; } } @@ -75,8 +78,10 @@ bool PCDM_ReaderFilter::IsPassed(const TCollection_AsciiString& theEntry) const bool PCDM_ReaderFilter::IsSubPassed(const TCollection_AsciiString& theEntry) const { - if (mySubTrees.IsEmpty() || theEntry.Length() == 2) // root is always passed if any sub is defined + if (mySubTrees.IsEmpty() || theEntry.Length() == 2) + { // root is always passed if any sub is defined return true; + } for (NCollection_List::Iterator anEntry(mySubTrees); anEntry.More(); anEntry.Next()) { @@ -84,7 +89,9 @@ bool PCDM_ReaderFilter::IsSubPassed(const TCollection_AsciiString& theEntry) con && anEntry.Value().Value(theEntry.Length() + 1) == ':' && // case when theEntry="0:1" should not match "0:10" anEntry.Value().StartsWith(theEntry)) + { return true; + } } return false; } @@ -101,7 +108,9 @@ void PCDM_ReaderFilter::StartIteration() ClearTree(); myTree.Bind(-1, nullptr); if (mySubTrees.IsEmpty()) + { return; + } // create an iteration-tree by the mySubTrees entries for (NCollection_List::Iterator aTreeIter(mySubTrees); aTreeIter.More(); aTreeIter.Next()) @@ -112,7 +121,9 @@ void PCDM_ReaderFilter::StartIteration() { aTagStr = anEntry.Token(":", aTagIndex); if (aTagStr.IsEmpty()) + { break; + } int aTag = aTagStr.IntegerValue(); if (aMap->IsBound(aTag)) { @@ -133,9 +144,13 @@ void PCDM_ReaderFilter::StartIteration() void PCDM_ReaderFilter::Up() { if (myCurrentDepth == 0) + { myCurrent = (TagTree*)myCurrent->Find(-1); + } else + { myCurrentDepth--; + } } void PCDM_ReaderFilter::Down(const int& theTag) @@ -143,12 +158,18 @@ void PCDM_ReaderFilter::Down(const int& theTag) if (myCurrentDepth == 0) { if (myCurrent->IsBound(theTag)) + { myCurrent = (TagTree*)myCurrent->Find(theTag); + } else + { ++myCurrentDepth; + } } else + { ++myCurrentDepth; + } } bool PCDM_ReaderFilter::IsPassed() const @@ -167,8 +188,12 @@ void PCDM_ReaderFilter::ClearSubTree(void* const theMap) { TagTree* aMap = (TagTree*)theMap; for (TagTree::Iterator aTagIter(*aMap); aTagIter.More(); aTagIter.Next()) + { if (aTagIter.Key() != -1) + { ClearSubTree(aTagIter.Value()); + } + } delete aMap; } } @@ -176,7 +201,11 @@ void PCDM_ReaderFilter::ClearSubTree(void* const theMap) void PCDM_ReaderFilter::ClearTree() { for (TagTree::Iterator aTagIter(myTree); aTagIter.More(); aTagIter.Next()) + { if (aTagIter.Key() != -1) + { ClearSubTree(aTagIter.Value()); + } + } myTree.Clear(); } diff --git a/src/ApplicationFramework/TKCDF/PCDM/PCDM_StorageDriver.cxx b/src/ApplicationFramework/TKCDF/PCDM/PCDM_StorageDriver.cxx index 230c608e03..11561cba25 100644 --- a/src/ApplicationFramework/TKCDF/PCDM/PCDM_StorageDriver.cxx +++ b/src/ApplicationFramework/TKCDF/PCDM/PCDM_StorageDriver.cxx @@ -60,7 +60,9 @@ void PCDM_StorageDriver::Write(const occ::handle& aDocument, } if (Failure) + { throw PCDM_DriverError(aMsg.str().c_str()); + } if (thePersistentDocuments.IsEmpty()) { @@ -100,7 +102,9 @@ void PCDM_StorageDriver::Write(const occ::handle& aDocument, theFile->Close(); if (theData->ErrorStatus() != Storage_VSOk) + { throw PCDM_DriverError(theData->ErrorStatusExtension().ToCString()); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKCDF/UTL/UTL.cxx b/src/ApplicationFramework/TKCDF/UTL/UTL.cxx index 3023b8c91a..dffa11e160 100644 --- a/src/ApplicationFramework/TKCDF/UTL/UTL.cxx +++ b/src/ApplicationFramework/TKCDF/UTL/UTL.cxx @@ -35,7 +35,9 @@ TCollection_ExtendedString UTL::xgetenv(const char* const aCString) OSD_Environment theEnv(aCString); TCollection_AsciiString theValue = theEnv.Value(); if (!theValue.IsEmpty()) + { x = TCollection_ExtendedString(theValue); + } return x; } @@ -45,7 +47,9 @@ TCollection_ExtendedString UTL::Extension(const TCollection_ExtendedString& aFil OSD_Path p = OSD_Path(aFileNameU); TCollection_AsciiString theExtension = p.Extension(); if (theExtension.Value(1) == '.') + { theExtension.Remove(1, 1); + } return TCollection_ExtendedString(theExtension); } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Attribute.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Attribute.cxx index 4c4a1af005..ec96433e52 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Attribute.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Attribute.cxx @@ -107,7 +107,9 @@ void TDF_Attribute::Forget(const int aTransaction) myFlags = (myFlags | TDF_AttributeForgottenMsk); #ifdef TDF_DATA_COMMIT_OPTIMIZED if (myLabelNode) + { myLabelNode->AttributesModified(true); + } #endif Validate(false); } @@ -127,11 +129,17 @@ void TDF_Attribute::Resume() int TDF_Attribute::UntilTransaction() const { if (IsForgotten()) + { return myTransaction; + } else if (IsBackuped()) + { return myNext->myTransaction - 1; + } else if (IsValid()) + { return myLabelNode->Data()->Transaction(); + } throw Standard_DomainError("The attribute structure is wrong."); } @@ -238,7 +246,9 @@ void TDF_Attribute::RemoveBackup() myBackup->myNext.Nullify(); // Absolutely necessary! myBackup = myBackup->myBackup; if (!myBackup.IsNull()) + { myBackup->myNext = this; // New back reference. + } } //================================================================================================= @@ -295,17 +305,23 @@ Standard_OStream& TDF_Attribute::Dump(Standard_OStream& anOS) const { anOS << "\t" << DynamicType()->Name() << "\tTrans. " << myTransaction << ";"; if (IsValid()) + { anOS << " Valid"; + } if (IsBackuped()) + { anOS << " Backuped"; + } if (IsForgotten()) + { anOS << " Forgotten"; + } char toto[45]; Standard_PCharacter pStr; // pStr = toto; ID().ToCString(pStr); - anOS << ";\tID = " << toto << std::endl; + anOS << ";\tID = " << toto << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeIterator.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeIterator.cxx index 556c98e994..7821017488 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeIterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeIterator.cxx @@ -37,7 +37,9 @@ TDF_AttributeIterator::TDF_AttributeIterator(const TDF_Label& aLabel, const bool { const occ::handle& aFirstAttribute = aLabel.myLabelNode->FirstAttribute(); if (!aFirstAttribute.IsNull()) + { goToNext(aFirstAttribute); + } } //================================================================================================= @@ -49,7 +51,9 @@ TDF_AttributeIterator::TDF_AttributeIterator(const TDF_LabelNodePtr aLabelNode, { const occ::handle& aFirstAttribute = aLabelNode->FirstAttribute(); if (!aFirstAttribute.IsNull()) + { goToNext(aFirstAttribute); + } } //================================================================================================= @@ -59,9 +63,13 @@ void TDF_AttributeIterator::Initialize(const TDF_Label& aLabel, const bool witho myWithoutForgotten = withoutForgotten; const occ::handle& aFirstAttribute = aLabel.myLabelNode->FirstAttribute(); if (aFirstAttribute.IsNull()) + { myValue = nullptr; + } else + { goToNext(aFirstAttribute); + } } //================================================================================================= @@ -74,9 +82,13 @@ void TDF_AttributeIterator::Next() { const occ::handle& anAttribute = myValue->myNext; if (anAttribute.IsNull()) + { myValue = nullptr; + } else + { goToNext(anAttribute); + } } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIDIterator.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIDIterator.cxx index 6f92dc45dd..13100ce2a0 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIDIterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIDIterator.cxx @@ -77,6 +77,8 @@ void TDF_ChildIDIterator::NextBrother() { myItr.NextBrother(); while (myItr.More() && !myItr.Value().FindAttribute(myID, myAtt)) + { myItr.NextBrother(); + } } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIterator.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIterator.cxx index ad0b1115ed..ffd89bace4 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_ChildIterator.cxx @@ -67,7 +67,9 @@ void TDF_ChildIterator::Next() else { if (myNode->FirstChild()) + { myNode = myNode->FirstChild(); + } else ChildIterator_UpToBrother; } @@ -78,7 +80,9 @@ void TDF_ChildIterator::Next() void TDF_ChildIterator::NextBrother() { if ((myFirstLevel == -1) || myNode->Brother()) + { myNode = myNode->Brother(); + } else ChildIterator_UpToBrother; } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_ClosureTool.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_ClosureTool.cxx index bcf0d0f165..29c04e54d2 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_ClosureTool.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_ClosureTool.cxx @@ -52,7 +52,9 @@ void TDF_ClosureTool::Closure(const occ::handle& aDataSet, rootLst.Clear(); NCollection_Map::Iterator labMItr(labMap); for (; labMItr.More(); labMItr.Next()) + { rootLst.Append(labMItr.Key()); + } // Iterates on roots. NCollection_List::Iterator labLItr(rootLst); @@ -60,9 +62,13 @@ void TDF_ClosureTool::Closure(const occ::handle& aDataSet, { const TDF_Label& lab = labLItr.Value(); if (lab.HasAttribute()) + { TDF_ClosureTool::LabelAttributes(lab, labMap, attMap, aFilter, aMode); + } if (aMode.Descendants()) + { TDF_ClosureTool::Closure(lab, labMap, attMap, aFilter, aMode); + } } } @@ -85,7 +91,9 @@ void TDF_ClosureTool::Closure(const TDF_Label& aLabe aLabMap.Add(locLab); upLab = locLab.Father(); while (aLabMap.Add(upLab)) + { upLab = upLab.Father(); + } TDF_ClosureTool::LabelAttributes(locLab, aLabMap, anAttMap, aFilter, aMode); } } @@ -139,7 +147,9 @@ void TDF_ClosureTool::LabelAttributes(const TDF_Label& { // 1.1 - A referenced attribute has a label. if (aLabMap.Add(locLab2)) + { TDF_ClosureTool::Closure(locLab2, aLabMap, anAttMap, aFilter, aMode); + } } else { @@ -156,7 +166,9 @@ void TDF_ClosureTool::LabelAttributes(const TDF_Label& { const TDF_Label& locLab1 = labMItr.Key(); if (aLabMap.Add(locLab1)) + { TDF_ClosureTool::Closure(locLab1, aLabMap, anAttMap, aFilter, aMode); + } } } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_ComparisonTool.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_ComparisonTool.cxx index 82c7e0edcb..7ea6d0b436 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_ComparisonTool.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_ComparisonTool.cxx @@ -36,7 +36,9 @@ void TDF_ComparisonTool::Compare(const occ::handle& aSource const occ::handle& aRelocationTable) { if (aSourceDataSet->IsEmpty() || aTargetDataSet->IsEmpty()) + { return; + } const NCollection_List& srcRoots = aSourceDataSet->Roots(); NCollection_List::Iterator srcRootItr(srcRoots); @@ -97,7 +99,9 @@ void TDF_ComparisonTool::Compare(const TDF_Label& aSrcLab if (aTrgLabel.FindAttribute(sAtt->ID(), tAtt)) { if (aTargetDataSet->ContainsAttribute(tAtt)) + { the2AttMap.Bind(sAtt, tAtt); + } } } } @@ -140,9 +144,13 @@ bool TDF_ComparisonTool::SourceUnbound(const occ::handle& a const int anOption) { if (aRefDataSet->IsEmpty()) + { return false; + } else + { return Unbound(aRefDataSet, aRelocationTable, aFilter, aDiffDataSet, anOption, true); + } } //================================================================================================= @@ -154,9 +162,13 @@ bool TDF_ComparisonTool::TargetUnbound(const occ::handle& a const int anOption) { if (aRefDataSet->IsEmpty()) + { return false; + } else + { return Unbound(aRefDataSet, aRelocationTable, aFilter, aDiffDataSet, anOption, false); + } } //================================================================================================= @@ -178,13 +190,17 @@ bool TDF_ComparisonTool::Unbound(const occ::handle& aRefDat const NCollection_DataMap& the2LabMap = aRelocationTable->LabelTable(); NCollection_Map theTLabMap; if (!theSource) + { aRelocationTable->TargetLabelMap(theTLabMap); + } for (NCollection_Map::Iterator refLabMItr(refLabs); refLabMItr.More(); refLabMItr.Next()) { const TDF_Label& refLab = refLabMItr.Key(); if (!(theSource ? the2LabMap.IsBound(refLab) : theTLabMap.Contains(refLab))) + { diffLabs.Add(refLab); + } } hasDiff = (diffLabs.Extent() > 0); } @@ -198,7 +214,9 @@ bool TDF_ComparisonTool::Unbound(const occ::handle& aRefDat aRelocationTable->AttributeTable(); NCollection_Map> theTAttMap; if (!theSource) + { aRelocationTable->TargetAttributeMap(theTAttMap); + } for (NCollection_Map>::Iterator refAttMItr(refAtts); refAttMItr.More(); refAttMItr.Next()) @@ -207,7 +225,9 @@ bool TDF_ComparisonTool::Unbound(const occ::handle& aRefDat if (aFilter.IsKept(refAtt)) { if (!(theSource ? the2AttMap.IsBound(refAtt) : theTAttMap.Contains(refAtt))) + { diffAtts.Add(refAtt); + } } } hasDiff = (hasDiff || diffAtts.Extent() > 0); @@ -221,7 +241,9 @@ bool TDF_ComparisonTool::Unbound(const occ::handle& aRefDat void TDF_ComparisonTool::Cut(const occ::handle& aDataSet) { if (aDataSet->IsEmpty()) + { return; + } const NCollection_Map>& refAtts = aDataSet->Attributes(); @@ -246,7 +268,9 @@ bool TDF_ComparisonTool::IsSelfContained(const TDF_Label& aLabel, refLabMItr.Next()) { if (!refLabMItr.Key().IsDescendant(aLabel)) + { return false; + } } } return true; diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyLabel.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyLabel.cxx index ee6052fd26..457be960a9 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyLabel.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyLabel.cxx @@ -153,7 +153,8 @@ void TDF_CopyLabel::Perform() myIsDone = false; if (mySL.Data()->Root().IsDifferent(myTL.Data()->Root()) && // TDF_Data is not the same // clang-format off - !TDF_Tool::IsSelfContained(mySL, myFilter)) return; //source label isn't self-contained + !TDF_Tool::IsSelfContained(mySL, myFilter)) { return; //source label isn't self-contained +} // clang-format on bool extReferers = ExternalReferences(mySL, myMapOfExt, myFilter); diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyTool.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyTool.cxx index fed0cfba12..efeaac2401 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyTool.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_CopyTool.cxx @@ -59,7 +59,9 @@ void TDF_CopyTool::Copy(const occ::handle& aSourceDataSet, const bool /* setSelfContained */) { if (aSourceDataSet->IsEmpty()) + { return; + } NCollection_Map& srcLabs = aSourceDataSet->Labels(); NCollection_Map>& srcAtts = aSourceDataSet->Attributes(); @@ -106,7 +108,9 @@ void TDF_CopyTool::Copy(const occ::handle& aSourceDataSet, // 2 - The target attribute is present BUT its privilege over the // source one must be ignored. The source attribute can be copied. if ((sAtt != tAtt) && aPrivilegeFilter.IsIgnored(tAtt->ID())) + { sAtt->Paste(tAtt, aRelocationTable); + } } } } @@ -171,7 +175,9 @@ void TDF_CopyTool::CopyAttributes( { tAtt = sAtt->NewEmpty(); if (tAtt->ID() != id) + { tAtt->SetID(id); // + } aTargetLabel.AddAttribute(tAtt, true); aAttMap.Bind(sAtt, tAtt); } @@ -180,9 +186,13 @@ void TDF_CopyTool::CopyAttributes( // Some attributes have the same ID, but are different and // exclusive. This obliged to test the dynamic type identity. if (tAtt->IsInstance(sAtt->DynamicType())) + { aAttMap.Bind(sAtt, tAtt); + } else + { throw Standard_TypeMismatch("TDF_CopyTool: Cannot paste to a different type attribute."); + } } } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Data.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Data.cxx index d3061afcae..cca9c7ba73 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Data.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Data.cxx @@ -142,18 +142,24 @@ occ::handle TDF_Data::CommitTransaction(const bool withDelta) if (myTransaction > 0) { if (withDelta) + { delta = new TDF_Delta(); + } #ifdef OCCT_DEBUG_DELTA std::cout << "TDF_Data::Begin Commit #" << myTransaction << std::endl; #endif #ifdef TDF_DATA_COMMIT_OPTIMIZED myNbTouchedAtt = 0; if (Root().myLabelNode->MayBeModified()) + { #endif myNbTouchedAtt = TDF_Data::CommitTransaction(Root(), delta, withDelta); + } if (myNbTouchedAtt && !(withDelta && delta->IsEmpty())) + { ++myTime; + } --myTransaction; if (withDelta) { @@ -178,6 +184,7 @@ occ::handle TDF_Data::CommitTransaction(const bool withDelta) } myTimes.RemoveFirst(); } + TDF_Data_DebugModified("COMMIT"); return delta; } @@ -255,7 +262,9 @@ int TDF_Data::CommitTransaction(const TDF_Label& aLabel, { TDF_Data_DeltaCreation("Removal(1)", currentAtt->DeltaOnRemoval()); if (myNotUndoMode) + { currentAtt->BeforeRemoval(); + } aLabel.myLabelNode->RemoveAttribute(lastAtt, currentAtt); currentIsRemoved = true; attMod = true; @@ -273,7 +282,9 @@ int TDF_Data::CommitTransaction(const TDF_Label& aLabel, { TDF_Data_DeltaCreation("Removal(2)", currentAtt->DeltaOnRemoval()); if (myNotUndoMode) + { currentAtt->BeforeRemoval(); + } aLabel.myLabelNode->RemoveAttribute(lastAtt, currentAtt); currentIsRemoved = true; } @@ -313,17 +324,25 @@ int TDF_Data::CommitTransaction(const TDF_Label& aLabel, const TDF_Attribute* anAttrPtr = aPtrCurrentAtt.operator->(); // to avoid ambiguity TDF_Data_DeltaCreation("Modification", anAttrPtr->DeltaOnModification(backupAtt)); if (aPtrCurrentAtt->myTransaction == backupAtt->myTransaction) + { aPtrCurrentAtt->RemoveBackup(); + } attMod = attMod || (aPtrCurrentAtt->myTransaction > 0); } } else + { attMod = attMod || (aPtrCurrentAtt->myTransaction > 0); + } if (currentIsRemoved) + { currentIsRemoved = false; + } else + { lastAtt = aPtrCurrentAtt; + } } aLabel.myLabelNode->AttributesModified(attMod); } @@ -334,8 +353,10 @@ int TDF_Data::CommitTransaction(const TDF_Label& aLabel, { #ifdef TDF_DATA_COMMIT_OPTIMIZED if (itr2.Value().myLabelNode->MayBeModified()) + { #endif nbTouchedAtt += TDF_Data::CommitTransaction(itr2.Value(), aDelta, withDelta); + } } return nbTouchedAtt; @@ -349,7 +370,9 @@ int TDF_Data::CommitTransaction(const TDF_Label& aLabel, void TDF_Data::AbortTransaction() { if (myTransaction > 0) + { Undo(TDF_Data::CommitTransaction(true), false); + } TDF_Data_DebugModified("New ABORT"); } @@ -361,7 +384,9 @@ void TDF_Data::AbortTransaction() void TDF_Data::AbortUntilTransaction(const int untilTransaction) { if (untilTransaction > 0) + { Undo(TDF_Data::CommitUntilTransaction(untilTransaction, true), false); + } } //================================================================================================= @@ -413,7 +438,9 @@ occ::handle TDF_Data::Undo(const occ::handle& aDelta, cons if (aDelta->IsApplicable(myTime)) { if (withDelta) + { OpenTransaction(); + } #ifdef OCCT_DEBUG_DELTA std::cout << "TDF_Data::Undo applies this delta:" << std::endl; aDelta->Dump(std::cout); @@ -478,9 +505,9 @@ void TDF_Data::RegisterLabel(const TDF_Label& aLabel) Standard_OStream& TDF_Data::Dump(Standard_OStream& anOS) const { - anOS << "Dump of a TDF_Data." << std::endl; + anOS << "Dump of a TDF_Data." << '\n'; anOS << "Current transaction: " << myTransaction; - anOS << "; Current tick: " << myTime << ";" << std::endl; + anOS << "; Current tick: " << myTime << ";" << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_DataSet.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_DataSet.cxx index 194c0889a7..fb1daf82fe 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_DataSet.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_DataSet.cxx @@ -44,28 +44,28 @@ void TDF_DataSet::Clear() Standard_OStream& TDF_DataSet::Dump(Standard_OStream& anOS) const { - anOS << "\t\t=====< TDF_DataSet dump >=====" << std::endl; - anOS << "Root Labels :" << std::endl << "=============" << std::endl; + anOS << "\t\t=====< TDF_DataSet dump >=====" << '\n'; + anOS << "Root Labels :" << '\n' << "=============" << '\n'; for (NCollection_List::Iterator itr1(myRootLabels); itr1.More(); itr1.Next()) { itr1.Value().EntryDump(anOS); anOS << " | "; } - anOS << std::endl << "Labels :" << std::endl << "========" << std::endl; + anOS << '\n' << "Labels :" << '\n' << "========" << '\n'; for (NCollection_Map::Iterator itr2(myLabelMap); itr2.More(); itr2.Next()) { itr2.Key().EntryDump(anOS); anOS << " | "; } - anOS << std::endl << "Attributes :" << std::endl << "============" << std::endl << std::endl; + anOS << '\n' << "Attributes :" << '\n' << "============" << '\n' << '\n'; for (NCollection_Map>::Iterator itr3(myAttributeMap); itr3.More(); itr3.Next()) { itr3.Key()->Label().EntryDump(anOS); anOS << " \t"; itr3.Key()->Dump(anOS); - anOS << std::endl; + anOS << '\n'; } - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_DefaultDeltaOnModification.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_DefaultDeltaOnModification.cxx index 70914233a5..106f8cde97 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_DefaultDeltaOnModification.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_DefaultDeltaOnModification.cxx @@ -40,5 +40,7 @@ void TDF_DefaultDeltaOnModification::Apply() const occ::handle& savAtt = Attribute(); occ::handle refAtt; if (Label().FindAttribute(savAtt->ID(), refAtt)) + { refAtt->DeltaOnModification(this); + } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Delta.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Delta.cxx index 246e2835f2..07be33f8bc 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Delta.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Delta.cxx @@ -56,7 +56,9 @@ void TDF_Delta::Validity(const int aBeginTime, const int anEndTime) void TDF_Delta::AddAttributeDelta(const occ::handle& anAttributeDelta) { if (!anAttributeDelta.IsNull()) + { myAttDeltaList.Append(anAttributeDelta); + } } //================================================================================================= @@ -67,7 +69,9 @@ void TDF_Delta::BeforeOrAfterApply(const bool before) const // for (NCollection_List>::Iterator itr(myAttDeltaList); NCollection_List>::Iterator itr(myAttDeltaList); for (; itr.More(); itr.Next()) + { ADlist.Append(itr.Value()); + } occ::handle attDelta; occ::handle att; @@ -84,14 +88,22 @@ void TDF_Delta::BeforeOrAfterApply(const bool before) const attDelta = itr.Value(); att = attDelta->Attribute(); if (before) + { next = !att->BeforeUndo(attDelta); + } else + { next = !att->AfterUndo(attDelta); + } if (next) + { itr.Next(); + } else + { ADlist.Remove(itr); + } } noDeadLock = (nbAD > ADlist.Extent()); nbAD = ADlist.Extent(); @@ -121,9 +133,13 @@ void TDF_Delta::BeforeOrAfterApply(const bool before) const attDelta = itr.Value(); att = attDelta->Attribute(); if (before) + { att->BeforeUndo(attDelta, true); + } else + { att->AfterUndo(attDelta, true); + } } } } @@ -201,19 +217,21 @@ void TDF_Delta::Labels(NCollection_List& aLabelList) const void TDF_Delta::Dump(Standard_OStream& OS) const { - OS << "DELTA available from time \t#" << myBeginTime << " to time \t#" << myEndTime << std::endl; + OS << "DELTA available from time \t#" << myBeginTime << " to time \t#" << myEndTime << '\n'; int n = 0; // for (NCollection_List>::Iterator itr(myAttDeltaList); NCollection_List>::Iterator itr(myAttDeltaList); for (; itr.More(); itr.Next()) + { ++n; - OS << "Nb Attribute Delta(s): " << n << std::endl; + } + OS << "Nb Attribute Delta(s): " << n << '\n'; for (itr.Initialize(myAttDeltaList); itr.More(); itr.Next()) { const occ::handle& attDelta = itr.Value(); OS << "| "; attDelta->Dump(OS); - OS << std::endl; + OS << '\n'; } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_IDFilter.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_IDFilter.cxx index 336985715f..d7edb1d356 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_IDFilter.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_IDFilter.cxx @@ -47,9 +47,13 @@ void TDF_IDFilter::IgnoreAll(const bool ignore) void TDF_IDFilter::Keep(const Standard_GUID& anID) { if (myIgnore) + { myIDMap.Add(anID); + } else + { myIDMap.Remove(anID); + } } //================================================================================================= @@ -64,12 +68,16 @@ void TDF_IDFilter::Keep(const NCollection_List& anIDList) const size_t aMapSize = static_cast(anIDList.Extent()) + myIDMap.NbBuckets() + 1; myIDMap.ReSize(aMapSize); for (; itr.More(); itr.Next()) + { myIDMap.Add(itr.Value()); + } } else { for (; itr.More(); itr.Next()) + { myIDMap.Remove(itr.Value()); + } } } } @@ -79,9 +87,13 @@ void TDF_IDFilter::Keep(const NCollection_List& anIDList) void TDF_IDFilter::Ignore(const Standard_GUID& anID) { if (myIgnore) + { myIDMap.Remove(anID); + } else + { myIDMap.Add(anID); + } } //================================================================================================= @@ -94,14 +106,18 @@ void TDF_IDFilter::Ignore(const NCollection_List& anIDList) if (myIgnore) { for (; itr.More(); itr.Next()) + { myIDMap.Remove(itr.Value()); + } } else { const size_t aMapSize = static_cast(anIDList.Extent()) + myIDMap.NbBuckets() + 1; myIDMap.ReSize(aMapSize); for (; itr.More(); itr.Next()) + { myIDMap.Add(itr.Value()); + } } } } @@ -112,7 +128,9 @@ void TDF_IDFilter::IDList(NCollection_List& anIDList) const { anIDList.Clear(); for (NCollection_Map::Iterator itr(myIDMap); itr.More(); itr.Next()) + { anIDList.Append(itr.Key()); + } } //================================================================================================= @@ -123,9 +141,13 @@ void TDF_IDFilter::Copy(const TDF_IDFilter& fromFilter) NCollection_List idl; fromFilter.IDList(idl); if (myIgnore) + { Keep(idl); + } else + { Ignore(idl); + } } //================================================================================================= @@ -133,24 +155,32 @@ void TDF_IDFilter::Copy(const TDF_IDFilter& fromFilter) void TDF_IDFilter::Dump(Standard_OStream& anOS) const { if (myIgnore) + { anOS << "EX"; + } else + { anOS << "IN"; + } anOS << "CLUSIVE filter: "; if (myIgnore) + { anOS << "ignores"; + } else + { anOS << "keeps "; + } anOS << " all IDs"; NCollection_Map::Iterator itr(myIDMap); if (itr.More()) { - anOS << " BUT:" << std::endl; + anOS << " BUT:" << '\n'; for (; itr.More(); itr.Next()) { const Standard_GUID& guid = itr.Key(); guid.ShallowDump(anOS); - anOS << std::endl; + anOS << '\n'; } } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.cxx index e565832b3b..8292e0b174 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.cxx @@ -31,12 +31,16 @@ void TDF_Label::Imported(const bool aStatus) const { if (IsNull()) + { throw Standard_NullObject("A null Label has no status."); + } if (myLabelNode->IsImported() != aStatus) { myLabelNode->Imported(aStatus); for (TDF_ChildIterator itr(*this, true); itr.More(); itr.Next()) + { itr.Value().myLabelNode->Imported(aStatus); + } } } @@ -46,7 +50,9 @@ bool TDF_Label::FindAttribute(const Standard_GUID& anID, occ::handle& anAttribute) const { if (IsNull()) + { throw Standard_NullObject("A null Label has no attribute."); + } TDF_AttributeIterator itr(myLabelNode); // Without removed attributes. for (; itr.More(); itr.Next()) { @@ -69,7 +75,9 @@ bool TDF_Label::FindAttribute(const Standard_GUID& anID, if (FindAttribute(anID, locAtt)) { while ((!locAtt.IsNull()) && (locAtt->myTransaction > aTransaction)) + { locAtt = locAtt->myBackup; + } if (!locAtt.IsNull()) { anAttribute = locAtt; @@ -86,7 +94,9 @@ bool TDF_Label::FindAttribute(const Standard_GUID& anID, int TDF_Label::Depth() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no depth."); + } return myLabelNode->Depth(); } @@ -123,7 +133,9 @@ bool TDF_Label::IsDescendant(const TDF_Label& aLabel) const const TDF_Label TDF_Label::Root() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no root."); + } return myLabelNode->RootNode(); } @@ -132,11 +144,17 @@ const TDF_Label TDF_Label::Root() const int TDF_Label::NbChildren() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no children."); + } int n = 0; if (myLabelNode->FirstChild() != nullptr) + { for (TDF_ChildIterator itr(*this); itr.More(); itr.Next()) + { ++n; + } + } return n; } @@ -145,9 +163,13 @@ int TDF_Label::NbChildren() const TDF_Label TDF_Label::FindChild(const int aTag, const bool create) const { if (IsNull()) + { throw Standard_NullObject("A null Label has no child."); + } if (create && ((Depth() + 1) & TDF_LabelNodeFlagsMsk)) + { throw Standard_OutOfRange("Depth value out of range"); + } return FindOrAddChild(aTag, create); } @@ -175,7 +197,9 @@ bool TDF_Label::IsAttribute(const Standard_GUID& anID) const bool TDF_Label::HasAttribute() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no attribute."); + } if (!myLabelNode->FirstAttribute().IsNull()) { @@ -190,11 +214,17 @@ bool TDF_Label::HasAttribute() const int TDF_Label::NbAttributes() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no attribute."); + } int n = 0; if (!myLabelNode->FirstAttribute().IsNull()) + { for (TDF_AttributeIterator itr(myLabelNode); itr.More(); itr.Next()) + { ++n; + } + } return n; } @@ -205,7 +235,9 @@ int TDF_Label::NbAttributes() const int TDF_Label::Transaction() const { if (IsNull()) + { throw Standard_NullObject("A null Label has no transaction."); + } return myLabelNode->Data()->Transaction(); } @@ -291,17 +323,25 @@ TDF_LabelNode* TDF_Label::FindOrAddChild(const int aTag, const bool create) cons childLabelNode->myBrother = currentLnp; // May be NULL. childLabelNode->Imported(IsImported()); // Inserts the label: - if (lastLnp == nullptr) // ... at beginning. + if (lastLnp == nullptr) + { // ... at beginning. myLabelNode->myFirstChild = childLabelNode; - else // ... somewhere. + } + else + { // ... somewhere. lastLnp->myBrother = childLabelNode; + } // Update table for fast access to the labels. if (myLabelNode->Data()->IsAccessByEntries()) + { myLabelNode->Data()->RegisterLabel(childLabelNode); + } } - if (lastLnp) // agv 14.07.2010 + if (lastLnp) + { // agv 14.07.2010 myLabelNode->myLastFoundChild = lastLnp; // jfa 10.01.2003 + } return childLabelNode; } @@ -323,27 +363,41 @@ void TDF_Label::InternalDump(Standard_OStream& TDF_Tool::Entry(*this, entry); anOS << entry << "\t"; if (IsImported()) + { anOS << "IS "; + } else + { anOS << "NOT"; + } anOS << " imported; "; if (MayBeModified()) + { anOS << "MAYBE"; + } else + { anOS << "NOT"; + } anOS << " modified; "; if (AttributesModified()) + { anOS << "HAS attributes"; + } else + { anOS << "NO attribute"; + } anOS << " modified; "; if (HasAttribute()) { int nba = NbAttributes(); anOS << "has " << nba << " attribute"; if (nba > 1) + { anOS << "s"; - anOS << "." << std::endl; + } + anOS << "." << '\n'; for (TDF_AttributeIterator itr(myLabelNode); itr.More(); itr.Next()) { // CLE @@ -351,13 +405,15 @@ void TDF_Label::InternalDump(Standard_OStream& occ::handle att = itr.Value(); // ENDCLE if (extended && aFilter.IsKept(att)) + { anOS << "\t# " << aMap.Add(att); + } att->TDF_Attribute::Dump(anOS); } } else { - anOS << " has no attribute" << std::endl; + anOS << " has no attribute" << '\n'; } } } @@ -455,10 +511,12 @@ void TDF_Label::ForgetAllAttributes(const bool clearChildren) const // itr1.Next(); // } if (clearChildren) + { for (TDF_ChildIterator itr2(myLabelNode); itr2.More(); itr2.Next()) { itr2.Value().ForgetAllAttributes(clearChildren); } + } } //================================================================================================= @@ -490,11 +548,15 @@ void TDF_Label::AddToNode(const TDF_LabelNodePtr& toNode, } if (!anAttribute->Label().IsNull()) + { throw Standard_DomainError("Attribute to add is already attached to a label."); + } occ::handle dummyAtt; // if (Find(anAttribute->ID(),dummyAtt)) if (FindAttribute(anAttribute->ID(), dummyAtt)) + { throw Standard_DomainError("This label has already such an attribute."); + } anAttribute->myTransaction = toNode->Data()->Transaction(); /// myData->Transaction(); anAttribute->mySavedTransaction = 0; @@ -504,14 +566,18 @@ void TDF_Label::AddToNode(const TDF_LabelNodePtr& toNode, if (append) { for (TDF_AttributeIterator itr(toNode); itr.More(); itr.Next()) + { dummyAtt = itr.Value(); + } } toNode->AddAttribute(dummyAtt, anAttribute); toNode->AttributesModified(anAttribute->myTransaction != 0); // if (myData->NotUndoMode()) anAttribute->AfterAddition(); if (toNode->Data()->NotUndoMode()) + { anAttribute->AfterAddition(); + } } //================================================================================================= @@ -530,7 +596,9 @@ void TDF_Label::ForgetFromNode(const TDF_LabelNodePtr& fromNode, } if (fromNode != anAttribute->Label().myLabelNode) + { throw Standard_DomainError("Attribute to forget not attached to my label."); + } int curTrans = fromNode->Data()->Transaction(); if (!anAttribute->IsForgotten()) @@ -568,7 +636,9 @@ void TDF_Label::ForgetFromNode(const TDF_LabelNodePtr& fromNode, // version before forgetting. It may generated a strange behaviour // in case of forgetting, committing, aborting... if (fromNode->Data()->NotUndoMode()) + { anAttribute->BeforeForget(); + } anAttribute->Forget(fromNode->Data()->Transaction()); } } @@ -580,16 +650,24 @@ void TDF_Label::ResumeToNode(const TDF_LabelNodePtr& toNode, const occ::handle& anAttribute) const { if (anAttribute.IsNull()) + { throw Standard_NullObject("The attribute is a null handle."); + } if (!anAttribute->Label().IsNull()) + { throw Standard_NullObject("Cannot resume an attribute already attached to a label."); + } if (!anAttribute->IsForgotten()) + { throw Standard_DomainError("Cannot resume an unforgotten attribute."); + } AddToNode(toNode, anAttribute, false); anAttribute->Resume(); if (toNode->Data()->NotUndoMode()) + { anAttribute->AfterResume(); + } } //////////////////end from insertor /////////////////////////////////////////////////// diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_LabelNode.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_LabelNode.cxx index 4f56b01429..ee5794fe59 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_LabelNode.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_LabelNode.cxx @@ -171,5 +171,7 @@ void TDF_LabelNode::AllMayBeModified() { MayBeModified(true); if (myFather && !myFather->MayBeModified()) + { myFather->AllMayBeModified(); + } } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Reference.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Reference.cxx index cf79709e0d..2e5dd3c9ca 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Reference.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Reference.cxx @@ -58,7 +58,9 @@ void TDF_Reference::Set(const TDF_Label& Origin) { // OCC2932 correction if (myOrigin == Origin) + { return; + } Backup(); myOrigin = Origin; @@ -101,7 +103,9 @@ void TDF_Reference::Paste(const occ::handle& Into, if (!myOrigin.IsNull()) { if (!RT->HasRelocation(myOrigin, tLab)) + { tLab = myOrigin; + } } occ::down_cast(Into)->Set(tLab); } @@ -111,7 +115,8 @@ void TDF_Reference::Paste(const occ::handle& Into, void TDF_Reference::References(const occ::handle& aDataSet) const { // clang-format off - if (!Label().IsImported()) aDataSet->AddLabel( myOrigin); //pour real et entier mais surtout pas les parts ... + if (!Label().IsImported()) { aDataSet->AddLabel( myOrigin); //pour real et entier mais surtout pas les parts ... +} // clang-format on } diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_RelocationTable.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_RelocationTable.cxx index b487be18f8..e549fbb92e 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_RelocationTable.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_RelocationTable.cxx @@ -65,7 +65,9 @@ void TDF_RelocationTable::SetRelocation(const TDF_Label& aSourceLabel, const TDF_Label& aTargetLabel) { if (!myLabelTable.IsBound(aSourceLabel)) + { myLabelTable.Bind(aSourceLabel, aTargetLabel); + } } //================================================================================================= @@ -93,7 +95,9 @@ void TDF_RelocationTable::SetRelocation(const occ::handle& aSourc const occ::handle& aTargetAttribute) { if (!myAttributeTable.IsBound(aSourceAttribute)) + { myAttributeTable.Bind(aSourceAttribute, aTargetAttribute); + } } //================================================================================================= @@ -122,7 +126,9 @@ void TDF_RelocationTable::SetTransientRelocation( const occ::handle& aTargetTransient) { if (!myTransientTable.Contains(aSourceTransient)) + { myTransientTable.Add(aSourceTransient, aTargetTransient); + } } //================================================================================================= @@ -160,7 +166,9 @@ void TDF_RelocationTable::TargetLabelMap(NCollection_Map& aLabelMap) { for (NCollection_DataMap::Iterator itr(myLabelTable); itr.More(); itr.Next()) + { aLabelMap.Add(itr.Value()); + } } //================================================================================================= @@ -172,7 +180,9 @@ void TDF_RelocationTable::TargetAttributeMap( myAttributeTable); itr.More(); itr.Next()) + { anAttributeMap.Add(itr.Value()); + } } //================================================================================================= @@ -207,23 +217,31 @@ Standard_OStream& TDF_RelocationTable::Dump(const bool dumpLabels, { anOS << "Relocation Table "; if (mySelfRelocate) + { anOS << "IS"; + } else + { anOS << "NOT"; + } anOS << " self relocate "; if (myAfterRelocate) + { anOS << "WITH"; + } else + { anOS << "WITHOUT"; - anOS << " after relocate" << std::endl; + } + anOS << " after relocate" << '\n'; anOS << "Nb labels=" << myLabelTable.Extent(); anOS << " Nb attributes=" << myAttributeTable.Extent(); - anOS << " Nb transients=" << myTransientTable.Extent() << std::endl; + anOS << " Nb transients=" << myTransientTable.Extent() << '\n'; int nb = 0; if (dumpLabels) { - anOS << "Label Table:" << std::endl; + anOS << "Label Table:" << '\n'; for (NCollection_DataMap::Iterator itr(myLabelTable); itr.More(); itr.Next()) { @@ -234,13 +252,13 @@ Standard_OStream& TDF_RelocationTable::Dump(const bool dumpLabels, itr.Value().EntryDump(anOS); anOS << "| "; } - std::cout << std::endl; + std::cout << '\n'; } nb = 0; if (dumpAttributes) { - anOS << "Attribute Table:" << std::endl; + anOS << "Attribute Table:" << '\n'; for (NCollection_DataMap, occ::handle>::Iterator itr( myAttributeTable); itr.More(); @@ -252,14 +270,13 @@ Standard_OStream& TDF_RelocationTable::Dump(const bool dumpLabels, anOS << "<=>"; itr.Value()->Dump(anOS); anOS << "| "; - anOS << std::endl; + anOS << '\n'; } } if (dumpTransients) { - anOS << "Transient Table:" << myTransientTable.Extent() << " transient(s) in table." - << std::endl; + anOS << "Transient Table:" << myTransientTable.Extent() << " transient(s) in table." << '\n'; } return anOS; diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_TagSource.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_TagSource.cxx index 26a9886c42..26d0eeeab3 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_TagSource.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_TagSource.cxx @@ -97,7 +97,9 @@ void TDF_TagSource::Set(const int T) { // OCC2932 correction if (myTag == T) + { return; + } Backup(); // FID 02/07/98 myTag = T; diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Tool.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Tool.cxx index aa3bec6e23..10cd26ba91 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Tool.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Tool.cxx @@ -63,7 +63,9 @@ int TDF_Tool::NbLabels(const TDF_Label& aLabel) { int n = 1; for (TDF_ChildIterator itr(aLabel, true); itr.More(); itr.Next()) + { ++n; + } return n; } @@ -73,7 +75,9 @@ int TDF_Tool::NbAttributes(const TDF_Label& aLabel) { int n = aLabel.NbAttributes(); for (TDF_ChildIterator itr(aLabel, true); itr.More(); itr.Next()) + { n += itr.Value().NbAttributes(); + } return n; } @@ -84,12 +88,22 @@ int TDF_Tool::NbAttributes(const TDF_Label& aLabel, const TDF_IDFilter& aFilter) int n = 0; TDF_AttributeIterator it2; for (it2.Initialize(aLabel, true); it2.More(); it2.Next()) + { if (aFilter.IsKept(it2.Value())) + { ++n; + } + } for (TDF_ChildIterator it1(aLabel, true); it1.More(); it1.Next()) + { for (it2.Initialize(it1.Value(), true); it2.More(); it2.Next()) + { if (aFilter.IsKept(it2.Value())) + { ++n; + } + } + } return n; } @@ -108,12 +122,16 @@ bool TDF_Tool::IsSelfContained(const TDF_Label& aLabel, const TDF_IDFilter& aFil occ::handle ds = new TDF_DataSet(); if (!TDF_Tool_DescendantRef(aLabel, aLabel, aFilter, ds)) + { return false; + } for (TDF_ChildIterator itr(aLabel, true); itr.More(); itr.Next()) { if (!TDF_Tool_DescendantRef(aLabel, itr.Value(), aFilter, ds)) + { return false; + } } return true; } @@ -140,7 +158,9 @@ static bool TDF_Tool_DescendantRef(const TDF_Label& aRefLabel, for (NCollection_Map::Iterator labMItr(labMap); labMItr.More(); labMItr.Next()) { if (!labMItr.Key().IsDescendant(aRefLabel)) + { return false; + } } // Then the referenced attributes. const NCollection_Map>& attMap = ds->Attributes(); @@ -154,7 +174,9 @@ static bool TDF_Tool_DescendantRef(const TDF_Label& aRefLabel, { // ENDCLE if (aFilter.IsKept(att) && !att->Label().IsDescendant(aRefLabel)) + { return false; + } } } ds->Clear(); @@ -202,7 +224,9 @@ static void TDF_Tool_OutReferers(const TDF_Label& aR { if (!aFilterForReferers.IsKept(itr.Value())) + { continue; + } itr.Value()->References(ds); const NCollection_Map>& attMap = ds->Attributes(); @@ -276,7 +300,9 @@ static void TDF_Tool_OutReferences(const TDF_Label& for (TDF_AttributeIterator itr(aLabel); itr.More(); itr.Next()) { if (!aFilterForReferers.IsKept(itr.Value())) + { continue; + } itr.Value()->References(ds); const NCollection_Map>& attMap = ds->Attributes(); for (NCollection_Map>::Iterator attMItr(attMap); attMItr.More(); @@ -317,14 +343,18 @@ void TDF_Tool::RelocateLabel(const TDF_Label& aSourceLabel, const bool create) { if (!aSourceLabel.IsDescendant(fromRoot)) + { return; + } aTargetLabel.Nullify(); NCollection_List labelTags; TDF_Tool::TagList(aSourceLabel, labelTags); NCollection_List toTags; TDF_Tool::TagList(toRoot, toTags); for (int i = fromRoot.Depth(); i >= 0; --i) + { labelTags.RemoveFirst(); + } labelTags.Prepend(toTags); TDF_Tool::Label(toRoot.Data(), labelTags, aTargetLabel, create); } @@ -340,7 +370,9 @@ void TDF_Tool::Entry(const TDF_Label& aLabel, TCollection_AsciiString& anEntry) for (; !aLab.IsRoot(); aLab = aLab.Father()) { for (int aTag = aLab.Tag(); aTag > 9; aTag /= 10) + { ++aStrLen; + } aStrLen += 2; // one digit and separator } @@ -359,7 +391,9 @@ void TDF_Tool::Entry(const TDF_Label& aLabel, TCollection_AsciiString& anEntry) { int aTag = aLab.Tag(); for (; aTag > 9; --aPtr, aTag /= 10) + { *aPtr = char(aTag % 10) + '0'; + } *aPtr = char(aTag) + '0'; aPtr -= 2; } @@ -367,7 +401,9 @@ void TDF_Tool::Entry(const TDF_Label& aLabel, TCollection_AsciiString& anEntry) } } else + { anEntry.Clear(); + } } //================================================================================================= @@ -382,7 +418,9 @@ void TDF_Tool::TagList(const TDF_Label& aLabel, NCollection_List& aTagList) { aTagList.Prepend(Label.Tag()); if (Label.IsRoot()) + { break; + } Label = Label.Father(); } } @@ -407,7 +445,9 @@ void TDF_Tool::TagList(const TCollection_AsciiString& anEntry, NCollection_List< aTagList.Append(n); n = 0; if (*cc != '\0') + { ++cc; + } } else { // Not an entry! @@ -426,10 +466,14 @@ void TDF_Tool::Label(const occ::handle& aDF, { bool isFound = false; if (aDF->IsAccessByEntries()) + { isFound = aDF->GetLabel(anEntry, aLabel); + } if (!isFound) + { TDF_Tool::Label(aDF, anEntry.ToCString(), aLabel, create); + } } //================================================================================================= @@ -441,7 +485,9 @@ void TDF_Tool::Label(const occ::handle& aDF, { bool isFound = false; if (aDF->IsAccessByEntries()) + { isFound = aDF->GetLabel(anEntry, aLabel); + } if (!isFound) { @@ -466,7 +512,9 @@ void TDF_Tool::Label(const occ::handle& aDF, { aLabel = aDF->Root(); if (aTagList.Extent() == 1 && aTagList.First() == 0) + { return; + } else { NCollection_List::Iterator tagItr(aTagList); @@ -485,7 +533,9 @@ void TDF_Tool::CountLabels(NCollection_List& aLabelList, NCollection_DataMap& aLabelMap) { if (aLabelList.IsEmpty()) + { return; + } bool next = true; NCollection_List::Iterator itr(aLabelList); while (itr.More()) @@ -503,7 +553,9 @@ void TDF_Tool::CountLabels(NCollection_List& aLabelList, next = itr.More(); } if (next && !aLabelList.IsEmpty()) + { itr.Next(); + } } } @@ -513,7 +565,9 @@ void TDF_Tool::DeductLabels(NCollection_List& aLabelList, NCollection_DataMap& aLabelMap) { if (aLabelList.IsEmpty()) + { return; + } bool next = true; NCollection_List::Iterator itr(aLabelList); while (itr.More()) @@ -530,9 +584,13 @@ void TDF_Tool::DeductLabels(NCollection_List& aLabelList, } } else + { next = itr.More(); + } if (next && !aLabelList.IsEmpty()) + { itr.Next(); + } } } @@ -578,10 +636,12 @@ void TDF_Tool::ExtendedDeepDump(Standard_OStream& anOS, anOS << map.Extent() << " attribute"; if (map.Extent() > 1) + { anOS << "s"; - anOS << " referenced by the label structure." << std::endl; + } + anOS << " referenced by the label structure." << '\n'; - anOS << std::endl << "Extended dump of filtered attribute(s):" << std::endl; + anOS << '\n' << "Extended dump of filtered attribute(s):" << '\n'; int nba = 0; TCollection_AsciiString entry; int i; @@ -594,21 +654,23 @@ void TDF_Tool::ExtendedDeepDump(Standard_OStream& anOS, anOS << "# " << i; if (att->Label().IsNull()) { - anOS << " (no label)" << std::endl; + anOS << " (no label)" << '\n'; } else { TDF_Tool::Entry(att->Label(), entry); - anOS << " (label: " << entry << ")" << std::endl; + anOS << " (label: " << entry << ")" << '\n'; } att->ExtendedDump(anOS, aFilter, map); - anOS << std::endl; + anOS << '\n'; } } - anOS << std::endl << nba << " attribute"; + anOS << '\n' << nba << " attribute"; if (nba > 1) + { anOS << "s"; - anOS << " dumped between " << --i << std::endl; + } + anOS << " dumped between " << --i << '\n'; } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Transaction.cxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Transaction.cxx index 6a3808a53b..8931d8acbf 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Transaction.cxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Transaction.cxx @@ -57,7 +57,9 @@ TDF_Transaction::TDF_Transaction(const occ::handle& aDF, void TDF_Transaction::Initialize(const occ::handle& aDF) { if (IsOpen()) + { myDF->AbortUntilTransaction(myUntilTransaction); + } myDF = aDF; myUntilTransaction = 0; } @@ -70,9 +72,13 @@ int TDF_Transaction::Open() std::cout << "Transaction " << myName << " opens #" << myDF->Transaction() + 1 << std::endl; #endif if (IsOpen()) + { throw Standard_DomainError("This transaction is already open."); + } if (myDF.IsNull()) + { throw Standard_NullObject("Null TDF_Data."); + } return myUntilTransaction = myDF->OpenTransaction(); } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_AsciiString.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_AsciiString.cxx index 9a3bd38c3d..e642b68357 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_AsciiString.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_AsciiString.cxx @@ -89,7 +89,9 @@ occ::handle TDataStd_AsciiString::Set( void TDataStd_AsciiString::Set(const TCollection_AsciiString& theAsciiString) { if (myString == theAsciiString) + { return; + } Backup(); myString = theAsciiString; } @@ -106,7 +108,9 @@ const TCollection_AsciiString& TDataStd_AsciiString::Get() const void TDataStd_AsciiString::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; @@ -162,7 +166,7 @@ Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const anOS << " Name=|" << myString << "|"; char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); - anOS << sguid << "|" << std::endl; + anOS << sguid << "|" << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanArray.cxx index dd7908fa99..62274e1f2b 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanArray.cxx @@ -123,13 +123,17 @@ void TDataStd_BooleanArray::SetValue(const int index, const bool value) { if (myValues.IsNull()) + { return; + } int byte_index = (index - myLower) >> 3; int degree = index - (byte_index << 3) - myLower; int byte_value = DegreeOf2(degree); if ((value != 0) == ((myValues->Value(byte_index) & byte_value) > 0)) + { return; + } Backup(); @@ -148,9 +152,13 @@ void TDataStd_BooleanArray::SetValue(const int index, const bool value) bool TDataStd_BooleanArray::Value(const int index) const { if (myValues.IsNull()) + { return false; + } if (index < myLower || index > myUpper) + { return false; + } int byte_index = (index - myLower) >> 3; int degree = index - (byte_index << 3) - myLower; @@ -207,7 +215,9 @@ const Standard_GUID& TDataStd_BooleanArray::ID() const void TDataStd_BooleanArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -279,7 +289,7 @@ Standard_OStream& TDataStd_BooleanArray::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanList.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanList.cxx index 21e43ef3b7..c14b200a03 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanList.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_BooleanList.cxx @@ -201,7 +201,9 @@ const Standard_GUID& TDataStd_BooleanList::ID() const void TDataStd_BooleanList::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -258,7 +260,7 @@ Standard_OStream& TDataStd_BooleanList::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ByteArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ByteArray.cxx index 55dda04149..91f4b1e266 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ByteArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ByteArray.cxx @@ -102,9 +102,13 @@ occ::handle TDataStd_ByteArray::Set(const TDF_Label& lab void TDataStd_ByteArray::SetValue(const int index, const uint8_t value) { if (myValue.IsNull()) + { return; + } if (value == myValue->Value(index)) + { return; + } Backup(); myValue->SetValue(index, value); @@ -122,7 +126,9 @@ uint8_t TDataStd_ByteArray::Value(const int index) const int TDataStd_ByteArray::Lower() const { if (myValue.IsNull()) + { return 0; + } return myValue->Lower(); } @@ -131,7 +137,9 @@ int TDataStd_ByteArray::Lower() const int TDataStd_ByteArray::Upper() const { if (myValue.IsNull()) + { return -1; + } return myValue->Upper(); } @@ -140,7 +148,9 @@ int TDataStd_ByteArray::Upper() const int TDataStd_ByteArray::Length() const { if (myValue.IsNull()) + { return 0; + } return myValue->Length(); } @@ -170,17 +180,23 @@ void TDataStd_ByteArray::ChangeArray(const occ::handle(aLower, anUpper); + } for (i = aLower; i <= anUpper; i++) + { myValue->SetValue(i, newArray->Value(i)); + } } //================================================================================================= @@ -195,7 +211,9 @@ const Standard_GUID& TDataStd_ByteArray::ID() const void TDataStd_ByteArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -226,12 +244,16 @@ void TDataStd_ByteArray::Restore(const occ::handle& With) int lower = with_array.Lower(), i = lower, upper = with_array.Upper(); myValue = new NCollection_HArray1(lower, upper); for (; i <= upper; i++) + { myValue->SetValue(i, with_array.Value(i)); + } myIsDelta = anArray->myIsDelta; myID = anArray->ID(); } else + { myValue.Nullify(); + } } //================================================================================================= @@ -258,7 +280,7 @@ Standard_OStream& TDataStd_ByteArray::Dump(Standard_OStream& anOS) const anOS << "\nByteArray: "; char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); - anOS << sguid << std::endl; + anOS << sguid << '\n'; return anOS; } @@ -268,10 +290,14 @@ occ::handle TDataStd_ByteArray::DeltaOnModification( const occ::handle& OldAttribute) const { if (myIsDelta) + { return new TDataStd_DeltaOnModificationOfByteArray( occ::down_cast(OldAttribute)); + } else + { return new TDF_DefaultDeltaOnModification(OldAttribute); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ChildNodeIterator.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ChildNodeIterator.cxx index 5003737000..8f99142032 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ChildNodeIterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ChildNodeIterator.cxx @@ -64,7 +64,9 @@ void TDataStd_ChildNodeIterator::Next() else { if (myNode->myFirst != nullptr) + { myNode = myNode->myFirst; + } else ChildNodeIterator_UpToBrother; } @@ -75,7 +77,9 @@ void TDataStd_ChildNodeIterator::Next() void TDataStd_ChildNodeIterator::NextBrother() { if (myNode->myNext != nullptr) + { myNode = myNode->myNext; + } else ChildNodeIterator_UpToBrother; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Comment.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Comment.cxx index fc2528ecf8..83fed39bc9 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Comment.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Comment.cxx @@ -70,7 +70,9 @@ void TDataStd_Comment::Set(const TCollection_ExtendedString& S) { // OCC2932 correction if (myString == S) + { return; + } Backup(); myString = S; @@ -81,7 +83,9 @@ void TDataStd_Comment::Set(const TCollection_ExtendedString& S) void TDataStd_Comment::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Current.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Current.cxx index 34b3a33e32..0f626d8031 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Current.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Current.cxx @@ -80,7 +80,9 @@ void TDataStd_Current::SetLabel(const TDF_Label& current) { // OCC2932 correction if (myLabel == current) + { return; + } Backup(); myLabel = current; @@ -123,7 +125,9 @@ void TDataStd_Current::Paste(const occ::handle& Into, if (!myLabel.IsNull()) { if (!RT->HasRelocation(myLabel, tLab)) + { tLab = myLabel; + } } occ::down_cast(Into)->SetLabel(tLab); } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfByteArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfByteArray.cxx index 1a5cfcf2a0..01b88e3bb8 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfByteArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfByteArray.cxx @@ -52,7 +52,9 @@ TDataStd_DeltaOnModificationOfByteArray::TDataStd_DeltaOnModificationOfByteArray #endif if (Arr1.IsNull() || Arr2.IsNull()) + { return; + } if (Arr1 != Arr2) { myUp1 = Arr1->Upper(); @@ -76,12 +78,18 @@ TDataStd_DeltaOnModificationOfByteArray::TDataStd_DeltaOnModificationOfByteArray NCollection_List aList; for (i = Arr1->Lower(); i <= N; i++) + { if (Arr1->Value(i) != Arr2->Value(i)) + { aList.Append(i); + } + } if (aCase == 3) { for (i = N + 1; i <= myUp1; i++) + { aList.Append(i); + } } if (aList.Extent()) @@ -135,35 +143,57 @@ void TDataStd_DeltaOnModificationOfByteArray::Apply() return; } else + { aCurAtt->Backup(); + } int aCase; if (myUp1 == myUp2) + { aCase = 1; + } else if (myUp1 < myUp2) + { aCase = 2; + } else + { aCase = 3; // Up1 > Up2 + } if (aCase == 1 && (myIndxes.IsNull() || myValues.IsNull())) + { return; + } int i; occ::handle> BArr = aCurAtt->InternalArray(); if (BArr.IsNull()) + { return; + } if (aCase == 1) + { for (i = 1; i <= myIndxes->Upper(); i++) + { BArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } else if (aCase == 2) { occ::handle> byteArr = new NCollection_HArray1(BArr->Lower(), myUp1); for (i = BArr->Lower(); i <= myUp1 && i <= BArr->Upper(); i++) + { byteArr->SetValue(i, BArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) + { byteArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } aCurAtt->myValue = byteArr; } else @@ -172,8 +202,11 @@ void TDataStd_DeltaOnModificationOfByteArray::Apply() occ::handle> byteArr = new NCollection_HArray1(low, myUp1); for (i = BArr->Lower(); i <= myUp2 && i <= BArr->Upper(); i++) + { byteArr->SetValue(i, BArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) { #ifdef OCCT_DEBUG @@ -183,6 +216,7 @@ void TDataStd_DeltaOnModificationOfByteArray::Apply() #endif byteArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); } + } aCurAtt->myValue = byteArr; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfExtStringArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfExtStringArray.cxx index dfb6a199b8..d41ea368e7 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfExtStringArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfExtStringArray.cxx @@ -53,7 +53,9 @@ TDataStd_DeltaOnModificationOfExtStringArray::TDataStd_DeltaOnModificationOfExtS #endif if (Arr1.IsNull() || Arr2.IsNull()) + { return; + } if (Arr1 != Arr2) { myUp1 = Arr1->Upper(); @@ -77,12 +79,18 @@ TDataStd_DeltaOnModificationOfExtStringArray::TDataStd_DeltaOnModificationOfExtS NCollection_List aList; for (i = Arr1->Lower(); i <= N; i++) + { if (Arr1->Value(i) != Arr2->Value(i)) + { aList.Append(i); + } + } if (aCase == 3) { for (i = N + 1; i <= myUp1; i++) + { aList.Append(i); + } } if (aList.Extent()) @@ -137,36 +145,58 @@ void TDataStd_DeltaOnModificationOfExtStringArray::Apply() return; } else + { aCurAtt->Backup(); + } int aCase; if (myUp1 == myUp2) + { aCase = 1; + } else if (myUp1 < myUp2) + { aCase = 2; + } else + { aCase = 3; // Up1 > Up2 + } if (aCase == 1 && (myIndxes.IsNull() || myValues.IsNull())) + { return; + } int i; occ::handle> aStrArr = aCurAtt->Array(); if (aStrArr.IsNull()) + { return; + } if (aCase == 1) + { for (i = 1; i <= myIndxes->Upper(); i++) + { aStrArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } else if (aCase == 2) { occ::handle> strArr = new NCollection_HArray1(aStrArr->Lower(), myUp1); for (i = aStrArr->Lower(); i <= myUp1 && i <= aStrArr->Upper(); i++) + { strArr->SetValue(i, aStrArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) + { strArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } aCurAtt->myValue = strArr; } else @@ -175,8 +205,11 @@ void TDataStd_DeltaOnModificationOfExtStringArray::Apply() occ::handle> strArr = new NCollection_HArray1(low, myUp1); for (i = aStrArr->Lower(); i <= myUp2 && i <= aStrArr->Upper(); i++) + { strArr->SetValue(i, aStrArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) { #ifdef OCCT_DEBUG @@ -186,6 +219,7 @@ void TDataStd_DeltaOnModificationOfExtStringArray::Apply() #endif strArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); } + } aCurAtt->myValue = strArr; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntArray.cxx index b53f27f91a..823df73f92 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntArray.cxx @@ -52,7 +52,9 @@ TDataStd_DeltaOnModificationOfIntArray::TDataStd_DeltaOnModificationOfIntArray( #endif if (Arr1.IsNull() || Arr2.IsNull()) + { return; + } if (Arr1 != Arr2) { myUp1 = Arr1->Upper(); @@ -76,12 +78,18 @@ TDataStd_DeltaOnModificationOfIntArray::TDataStd_DeltaOnModificationOfIntArray( NCollection_List aList; for (i = Arr1->Lower(); i <= N; i++) + { if (Arr1->Value(i) != Arr2->Value(i)) + { aList.Append(i); + } + } if (aCase == 3) { for (i = N + 1; i <= myUp1; i++) + { aList.Append(i); + } } if (aList.Extent()) { @@ -134,35 +142,57 @@ void TDataStd_DeltaOnModificationOfIntArray::Apply() return; } else + { aCurAtt->Backup(); + } int aCase; if (myUp1 == myUp2) + { aCase = 1; + } else if (myUp1 < myUp2) + { aCase = 2; + } else + { aCase = 3; // Up1 > Up2 + } //// if (aCase == 1 && (myIndxes.IsNull() || myValues.IsNull())) + { return; + } int i; occ::handle> IntArr = aCurAtt->Array(); if (IntArr.IsNull()) + { return; + } if (aCase == 1) + { for (i = 1; i <= myIndxes->Upper(); i++) + { IntArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } else if (aCase == 2) { occ::handle> intArr = new NCollection_HArray1(IntArr->Lower(), myUp1); for (i = IntArr->Lower(); i <= myUp1 && i <= IntArr->Upper(); i++) + { intArr->SetValue(i, IntArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) + { intArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } aCurAtt->myValue = intArr; } else @@ -170,8 +200,11 @@ void TDataStd_DeltaOnModificationOfIntArray::Apply() int low = IntArr->Lower(); occ::handle> intArr = new NCollection_HArray1(low, myUp1); for (i = IntArr->Lower(); i <= myUp2 && i <= IntArr->Upper(); i++) + { intArr->SetValue(i, IntArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) { #ifdef OCCT_DEBUG @@ -181,6 +214,7 @@ void TDataStd_DeltaOnModificationOfIntArray::Apply() #endif intArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); } + } aCurAtt->myValue = intArr; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntPackedMap.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntPackedMap.cxx index 39d26e4b63..6fdd295ffa 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntPackedMap.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfIntPackedMap.cxx @@ -46,7 +46,9 @@ TDataStd_DeltaOnModificationOfIntPackedMap::TDataStd_DeltaOnModificationOfIntPac #endif if (aMap1.IsNull() || aMap2.IsNull()) + { return; + } if (aMap1 != aMap2) { const TColStd_PackedMapOfInteger& map1 = aMap1->Map(); @@ -108,24 +110,34 @@ void TDataStd_DeltaOnModificationOfIntPackedMap::Apply() return; } else + { aCurAtt->Backup(); + } occ::handle IntMap = aCurAtt->GetHMap(); if (IntMap.IsNull()) + { return; + } if (myDeletion.IsNull() && myAddition.IsNull()) + { return; + } if (!myDeletion.IsNull()) { if (myDeletion->Map().Extent()) + { NCollection_PackedMapAlgo::Subtract(IntMap->ChangeMap(), myDeletion->Map()); + } } if (!myAddition.IsNull()) { if (myAddition->Map().Extent()) + { NCollection_PackedMapAlgo::Unite(IntMap->ChangeMap(), myAddition->Map()); + } } #ifdef OCCT_DEBUG_disable diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfRealArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfRealArray.cxx index 8a077f2975..f494449369 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfRealArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_DeltaOnModificationOfRealArray.cxx @@ -51,7 +51,9 @@ TDataStd_DeltaOnModificationOfRealArray::TDataStd_DeltaOnModificationOfRealArray #endif if (Arr1.IsNull() || Arr2.IsNull()) + { return; + } if (Arr1 != Arr2) { myUp1 = Arr1->Upper(); @@ -75,12 +77,18 @@ TDataStd_DeltaOnModificationOfRealArray::TDataStd_DeltaOnModificationOfRealArray NCollection_List aList; for (i = Arr1->Lower(); i <= N; i++) + { if (Arr1->Value(i) != Arr2->Value(i)) + { aList.Append(i); + } + } if (aCase == 3) { for (i = N + 1; i <= myUp1; i++) + { aList.Append(i); + } } if (aList.Extent()) { @@ -132,35 +140,57 @@ void TDataStd_DeltaOnModificationOfRealArray::Apply() return; } else + { aCurAtt->Backup(); + } int aCase; if (myUp1 == myUp2) + { aCase = 1; + } else if (myUp1 < myUp2) + { aCase = 2; + } else + { aCase = 3; // Up1 > Up2 + } if (aCase == 1 && (myIndxes.IsNull() || myValues.IsNull())) + { return; + } int i; occ::handle> aRealArr = aCurAtt->Array(); if (aRealArr.IsNull()) + { return; + } if (aCase == 1) + { for (i = 1; i <= myIndxes->Upper(); i++) + { aRealArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } else if (aCase == 2) { occ::handle> realArr = new NCollection_HArray1(aRealArr->Lower(), myUp1); for (i = aRealArr->Lower(); i <= myUp1 && i <= aRealArr->Upper(); i++) + { realArr->SetValue(i, aRealArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) + { realArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); + } + } aCurAtt->myValue = realArr; } else @@ -168,8 +198,11 @@ void TDataStd_DeltaOnModificationOfRealArray::Apply() int low = aRealArr->Lower(); occ::handle> realArr = new NCollection_HArray1(low, myUp1); for (i = aRealArr->Lower(); i <= myUp2 && i <= aRealArr->Upper(); i++) + { realArr->SetValue(i, aRealArr->Value(i)); + } if (!myIndxes.IsNull() && !myValues.IsNull()) + { for (i = 1; i <= myIndxes->Upper(); i++) { #ifdef OCCT_DEBUG @@ -179,6 +212,7 @@ void TDataStd_DeltaOnModificationOfRealArray::Apply() #endif realArr->ChangeArray1().SetValue(myIndxes->Value(i), myValues->Value(i)); } + } aCurAtt->myValue = realArr; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Directory.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Directory.cxx index b75028ae11..a0fa1ffc73 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Directory.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Directory.cxx @@ -33,15 +33,21 @@ bool TDataStd_Directory::Find(const TDF_Label& current, occ::handle dir; if (L.IsNull()) + { return false; + } for (;;) { if (L.FindAttribute(TDataStd_Directory::GetID(), dir)) + { break; + } L = L.Father(); if (L.IsNull()) + { break; + } } if (!dir.IsNull()) diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Expression.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Expression.cxx index 06cd50634e..330b5604cf 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Expression.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Expression.cxx @@ -67,7 +67,9 @@ void TDataStd_Expression::SetExpression(const TCollection_ExtendedString& E) { // OCC2932 correction if (myExpression == E) + { return; + } Backup(); myExpression = E; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringArray.cxx index 1d04835953..f26048211d 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringArray.cxx @@ -105,9 +105,13 @@ occ::handle TDataStd_ExtStringArray::Set(const TDF_Labe void TDataStd_ExtStringArray::SetValue(const int index, const TCollection_ExtendedString& value) { if (myValue.IsNull()) + { return; + } if (myValue->Value(index) == value) + { return; + } Backup(); myValue->SetValue(index, value); @@ -129,7 +133,9 @@ const TCollection_ExtendedString& TDataStd_ExtStringArray::Value(const int index int TDataStd_ExtStringArray::Lower() const { if (myValue.IsNull()) + { return 0; + } return myValue->Lower(); } @@ -138,7 +144,9 @@ int TDataStd_ExtStringArray::Lower() const int TDataStd_ExtStringArray::Upper() const { if (myValue.IsNull()) + { return 0; + } return myValue->Upper(); } @@ -147,7 +155,9 @@ int TDataStd_ExtStringArray::Upper() const int TDataStd_ExtStringArray::Length() const { if (myValue.IsNull()) + { return 0; + } return myValue->Length(); } @@ -177,7 +187,9 @@ void TDataStd_ExtStringArray::ChangeArray( } } if (isEqual) + { return; + } } } @@ -185,10 +197,14 @@ void TDataStd_ExtStringArray::ChangeArray( // Handles of myValue of current and backuped attributes will be different!!! if (myValue.IsNull() || !aDimEqual) + { myValue = new NCollection_HArray1(aLower, anUpper); + } for (i = aLower; i <= anUpper; i++) + { myValue->SetValue(i, newArray->Value(i)); + } } //================================================================================================= @@ -203,7 +219,9 @@ const Standard_GUID& TDataStd_ExtStringArray::ID() const void TDataStd_ExtStringArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -235,12 +253,16 @@ void TDataStd_ExtStringArray::Restore(const occ::handle& With) upper = anArray->Upper(); myValue = new NCollection_HArray1(lower, upper); for (i = lower; i <= upper; i++) + { myValue->SetValue(i, anArray->Value(i)); + } myIsDelta = anArray->myIsDelta; myID = anArray->ID(); } else + { myValue.Nullify(); + } } //================================================================================================= @@ -271,13 +293,15 @@ Standard_OStream& TDataStd_ExtStringArray::Dump(Standard_OStream& anOS) const lower = myValue->Lower(); upper = myValue->Upper(); for (i = lower; i <= upper; i++) - anOS << "\t" << myValue->Value(i) << std::endl; + { + anOS << "\t" << myValue->Value(i) << '\n'; + } } anOS << " Delta is " << (myIsDelta ? "ON" : "OFF"); char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } @@ -287,10 +311,14 @@ occ::handle TDataStd_ExtStringArray::DeltaOnModificatio const occ::handle& OldAttribute) const { if (myIsDelta) + { return new TDataStd_DeltaOnModificationOfExtStringArray( occ::down_cast(OldAttribute)); + } else + { return new TDF_DefaultDeltaOnModification(OldAttribute); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringList.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringList.cxx index 60d5e68caf..f3a18ca3b9 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringList.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ExtStringList.cxx @@ -257,7 +257,9 @@ const Standard_GUID& TDataStd_ExtStringList::ID() const void TDataStd_ExtStringList::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -314,7 +316,7 @@ Standard_OStream& TDataStd_ExtStringList::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_GenericExtString.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_GenericExtString.cxx index be7238335c..99a34eda42 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_GenericExtString.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_GenericExtString.cxx @@ -21,7 +21,9 @@ IMPLEMENT_STANDARD_RTTIEXT(TDataStd_GenericExtString, TDF_Attribute) void TDataStd_GenericExtString::Set(const TCollection_ExtendedString& S) { if (myString == S) + { return; + } Backup(); myString = S; @@ -39,7 +41,9 @@ const TCollection_ExtendedString& TDataStd_GenericExtString::Get() const void TDataStd_GenericExtString::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntPackedMap.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntPackedMap.cxx index 27371ecaf3..f602f70c14 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntPackedMap.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntPackedMap.cxx @@ -66,7 +66,9 @@ TDataStd_IntPackedMap::TDataStd_IntPackedMap() bool TDataStd_IntPackedMap::ChangeMap(const occ::handle& theMap) { if (theMap.IsNull()) + { return false; + } if (myMap != theMap) { if (!NCollection_PackedMapAlgo::IsEqual(myMap->Map(), theMap->Map())) @@ -151,7 +153,9 @@ void TDataStd_IntPackedMap::Restore(const occ::handle& theWith) { occ::handle aWith = occ::down_cast(theWith); if (aWith->myMap.IsNull()) + { myMap.Nullify(); + } else { myMap = new TColStd_HPackedMapOfInteger; @@ -187,7 +191,7 @@ Standard_OStream& TDataStd_IntPackedMap::Dump(Standard_OStream& theOS) const Standard_OStream& anOS = TDF_Attribute::Dump(theOS); anOS << "IntPackedMap size = " << Extent(); anOS << " Delta is " << (myIsDelta ? "ON" : "OFF"); - anOS << std::endl; + anOS << '\n'; return anOS; } @@ -197,10 +201,14 @@ occ::handle TDataStd_IntPackedMap::DeltaOnModification( const occ::handle& OldAttribute) const { if (myIsDelta) + { return new TDataStd_DeltaOnModificationOfIntPackedMap( occ::down_cast(OldAttribute)); + } else + { return new TDF_DefaultDeltaOnModification(OldAttribute); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Integer.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Integer.cxx index ad9fc08a6b..500b061981 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Integer.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Integer.cxx @@ -82,7 +82,9 @@ void TDataStd_Integer::Set(const int v) { // OCC2932 correction if (myValue == v) + { return; + } Backup(); myValue = v; @@ -115,7 +117,9 @@ const Standard_GUID& TDataStd_Integer::ID() const void TDataStd_Integer::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerArray.cxx index 3fc0801df7..a7c4f978d4 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerArray.cxx @@ -105,9 +105,13 @@ occ::handle TDataStd_IntegerArray::Set(const TDF_Label& void TDataStd_IntegerArray::SetValue(const int index, const int value) { if (myValue.IsNull()) + { return; + } if (myValue->Value(index) == value) + { return; + } Backup(); myValue->SetValue(index, value); } @@ -117,7 +121,9 @@ void TDataStd_IntegerArray::SetValue(const int index, const int value) int TDataStd_IntegerArray::Value(const int index) const { if (myValue.IsNull()) + { return 0; + } return myValue->Value(index); } @@ -126,7 +132,9 @@ int TDataStd_IntegerArray::Value(const int index) const int TDataStd_IntegerArray::Lower() const { if (myValue.IsNull()) + { return 0; + } return myValue->Lower(); } @@ -135,7 +143,9 @@ int TDataStd_IntegerArray::Lower() const int TDataStd_IntegerArray::Upper() const { if (myValue.IsNull()) + { return 0; + } return myValue->Upper(); } @@ -144,7 +154,9 @@ int TDataStd_IntegerArray::Upper() const int TDataStd_IntegerArray::Length() const { if (myValue.IsNull()) + { return 0; + } return myValue->Length(); } @@ -173,17 +185,23 @@ void TDataStd_IntegerArray::ChangeArray(const occ::handle(aLower, anUpper); + } for (i = aLower; i <= anUpper; i++) + { myValue->SetValue(i, newArray->Value(i)); + } } //================================================================================================= @@ -198,7 +216,9 @@ const Standard_GUID& TDataStd_IntegerArray::ID() const void TDataStd_IntegerArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -230,12 +250,16 @@ void TDataStd_IntegerArray::Restore(const occ::handle& With) upper = anArray->Upper(); myValue = new NCollection_HArray1(lower, upper); for (i = lower; i <= upper; i++) + { myValue->SetValue(i, anArray->Value(i)); + } myIsDelta = anArray->myIsDelta; myID = anArray->ID(); } else + { myValue.Nullify(); + } } //================================================================================================= @@ -267,13 +291,15 @@ Standard_OStream& TDataStd_IntegerArray::Dump(Standard_OStream& anOS) const lower = myValue->Lower(); upper = myValue->Upper(); for (i = lower; i <= upper; i++) + { anOS << " " << myValue->Value(i); + } } anOS << " Delta is " << (myIsDelta ? "ON" : "OFF"); char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; // anOS <<"\nAttribute fields: "; // anOS << TDF_Attribute::Dump(anOS); @@ -287,10 +313,14 @@ occ::handle TDataStd_IntegerArray::DeltaOnModification( const occ::handle& OldAttribute) const { if (myIsDelta) + { return new TDataStd_DeltaOnModificationOfIntArray( occ::down_cast(OldAttribute)); + } else + { return new TDF_DefaultDeltaOnModification(OldAttribute); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerList.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerList.cxx index 344a2c0571..a06b7554be 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerList.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_IntegerList.cxx @@ -253,7 +253,9 @@ const Standard_GUID& TDataStd_IntegerList::ID() const void TDataStd_IntegerList::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -310,7 +312,7 @@ Standard_OStream& TDataStd_IntegerList::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Name.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Name.cxx index e42747a4be..a44b932ea7 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Name.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Name.cxx @@ -73,7 +73,9 @@ TDataStd_Name::TDataStd_Name() void TDataStd_Name::Set(const TCollection_ExtendedString& S) { if (myString == S) + { return; + } Backup(); myString = S; @@ -84,7 +86,9 @@ void TDataStd_Name::Set(const TCollection_ExtendedString& S) void TDataStd_Name::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; @@ -107,6 +111,6 @@ Standard_OStream& TDataStd_Name::Dump(Standard_OStream& anOS) const anOS << " Name=|" << myString << "|"; char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); - anOS << sguid << std::endl; + anOS << sguid << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NamedData.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NamedData.cxx index 5de72ad0a5..575bd972d2 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NamedData.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NamedData.cxx @@ -85,7 +85,9 @@ bool TDataStd_NamedData::HasIntegers() const bool TDataStd_NamedData::HasInteger(const TCollection_ExtendedString& theName) const { if (!HasIntegers()) + { return false; + } return myIntegers->Map().IsBound(theName); } @@ -161,7 +163,9 @@ void TDataStd_NamedData::ChangeIntegers( myIntegers = new TDataStd_HDataMapOfStringInteger(aMap); }; if (&myIntegers->Map() == &theIntegers) + { return; + } Backup(); myIntegers->ChangeMap().Assign(theIntegers); } @@ -181,7 +185,9 @@ bool TDataStd_NamedData::HasReals() const bool TDataStd_NamedData::HasReal(const TCollection_ExtendedString& theName) const { if (!HasReals()) + { return false; + } return myReals->Map().IsBound(theName); } @@ -256,7 +262,9 @@ void TDataStd_NamedData::ChangeReals( myReals = new TDataStd_HDataMapOfStringReal(aMap); } if (&myReals->Map() == &theReals) + { return; + } Backup(); myReals->ChangeMap().Assign(theReals); } @@ -276,7 +284,9 @@ bool TDataStd_NamedData::HasStrings() const bool TDataStd_NamedData::HasString(const TCollection_ExtendedString& theName) const { if (!HasStrings()) + { return false; + } return myStrings->Map().IsBound(theName); } @@ -357,7 +367,9 @@ void TDataStd_NamedData::ChangeStrings( myStrings = new TDataStd_HDataMapOfStringString(aMap); } if (&myStrings->Map() == &theStrings) + { return; + } Backup(); myStrings->ChangeMap().Assign(theStrings); } @@ -377,7 +389,9 @@ bool TDataStd_NamedData::HasBytes() const bool TDataStd_NamedData::HasByte(const TCollection_ExtendedString& theName) const { if (!HasBytes()) + { return false; + } return myBytes->Map().IsBound(theName); } @@ -454,7 +468,9 @@ void TDataStd_NamedData::ChangeBytes( myBytes = new TDataStd_HDataMapOfStringByte(aMap); } if (&myBytes->Map() == &theBytes) + { return; + } Backup(); myBytes->ChangeMap().Assign(theBytes); } @@ -474,7 +490,9 @@ bool TDataStd_NamedData::HasArraysOfIntegers() const bool TDataStd_NamedData::HasArrayOfIntegers(const TCollection_ExtendedString& theName) const { if (!HasArraysOfIntegers()) + { return false; + } return myArraysOfIntegers->Map().IsBound(theName); } @@ -542,7 +560,9 @@ void TDataStd_NamedData::ChangeArraysOfIntegers( myArraysOfIntegers = new TDataStd_HDataMapOfStringHArray1OfInteger(aMap); } if (&myArraysOfIntegers->Map() == &theIntegers) + { return; + } Backup(); myArraysOfIntegers->ChangeMap().Assign(theIntegers); } @@ -562,7 +582,9 @@ bool TDataStd_NamedData::HasArraysOfReals() const bool TDataStd_NamedData::HasArrayOfReals(const TCollection_ExtendedString& theName) const { if (!HasArraysOfReals()) + { return false; + } return myArraysOfReals->Map().IsBound(theName); } @@ -630,7 +652,9 @@ void TDataStd_NamedData::ChangeArraysOfReals( myArraysOfReals = new TDataStd_HDataMapOfStringHArray1OfReal(aMap); } if (&myArraysOfReals->Map() == &theReals) + { return; + } Backup(); myArraysOfReals->ChangeMap().Assign(theReals); } @@ -656,7 +680,9 @@ void TDataStd_NamedData::Restore(const occ::handle& With) occ::handle ND = occ::down_cast(With); if (ND.IsNull()) + { return; + } // Integers if (!ND->GetIntegersContainer().IsEmpty()) { @@ -767,7 +793,9 @@ void TDataStd_NamedData::Paste(const occ::handle& Into, { occ::handle ND = occ::down_cast(Into); if (ND.IsNull()) + { return; + } // Integers if (HasIntegers() && !myIntegers->Map().IsEmpty()) diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NoteBook.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NoteBook.cxx index 6577fb2be0..18f17a9076 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NoteBook.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_NoteBook.cxx @@ -33,15 +33,21 @@ bool TDataStd_NoteBook::Find(const TDF_Label& current, occ::handle NB; if (L.IsNull()) + { return false; + } for (;;) { if (L.FindAttribute(TDataStd_NoteBook::GetID(), NB)) + { break; + } L = L.Father(); if (L.IsNull()) + { break; + } } if (!NB.IsNull()) diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Real.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Real.cxx index df93f1bf9e..5348db554c 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Real.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Real.cxx @@ -98,7 +98,9 @@ void TDataStd_Real::Set(const double v) { // OCC2932 correction if (myValue == v) + { return; + } Backup(); myValue = v; @@ -117,7 +119,9 @@ void TDataStd_Real::SetDimension(const TDataStd_RealEnum DIM) { // OCC2932 correction if (myDimension == DIM) + { return; + } Backup(); myDimension = DIM; @@ -142,7 +146,9 @@ const Standard_GUID& TDataStd_Real::ID() const void TDataStd_Real::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealArray.cxx index f8ba026aff..a2b8e20b12 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealArray.cxx @@ -104,9 +104,13 @@ void TDataStd_RealArray::SetValue(const int index, const double value) { // OCC2932 correction if (myValue.IsNull()) + { return; + } if (myValue->Value(index) == value) + { return; + } Backup(); myValue->SetValue(index, value); } @@ -116,7 +120,9 @@ void TDataStd_RealArray::SetValue(const int index, const double value) double TDataStd_RealArray::Value(const int index) const { if (myValue.IsNull()) + { return RealFirst(); + } return myValue->Value(index); } @@ -125,7 +131,9 @@ double TDataStd_RealArray::Value(const int index) const int TDataStd_RealArray::Lower() const { if (myValue.IsNull()) + { return 0; + } return myValue->Lower(); } @@ -134,7 +142,9 @@ int TDataStd_RealArray::Lower() const int TDataStd_RealArray::Upper() const { if (myValue.IsNull()) + { return 0; + } return myValue->Upper(); } @@ -143,7 +153,9 @@ int TDataStd_RealArray::Upper() const int TDataStd_RealArray::Length() const { if (myValue.IsNull()) + { return 0; + } return myValue->Length(); } @@ -174,7 +186,9 @@ void TDataStd_RealArray::ChangeArray(const occ::handle(aLower, anUpper); + } for (i = aLower; i <= anUpper; i++) + { myValue->SetValue(i, newArray->Value(i)); + } } //================================================================================================= @@ -200,7 +218,9 @@ const Standard_GUID& TDataStd_RealArray::ID() const void TDataStd_RealArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -233,11 +253,15 @@ void TDataStd_RealArray::Restore(const occ::handle& With) myIsDelta = anArray->myIsDelta; myValue = new NCollection_HArray1(lower, upper); for (i = lower; i <= upper; i++) + { myValue->SetValue(i, anArray->Value(i)); + } myID = anArray->ID(); } else + { myValue.Nullify(); + } } //================================================================================================= @@ -268,13 +292,15 @@ Standard_OStream& TDataStd_RealArray::Dump(Standard_OStream& anOS) const lower = myValue->Lower(); upper = myValue->Upper(); for (i = lower; i <= upper; i++) + { anOS << " " << myValue->Value(i); + } } anOS << " Delta is " << (myIsDelta ? "ON" : "OFF"); char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } @@ -284,9 +310,13 @@ occ::handle TDataStd_RealArray::DeltaOnModification( const occ::handle& OldAtt) const { if (myIsDelta) + { return new TDataStd_DeltaOnModificationOfRealArray(occ::down_cast(OldAtt)); + } else + { return new TDF_DefaultDeltaOnModification(OldAtt); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealList.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealList.cxx index f97a339802..4f8496cb1b 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealList.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_RealList.cxx @@ -251,7 +251,9 @@ const Standard_GUID& TDataStd_RealList::ID() const void TDataStd_RealList::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -308,7 +310,7 @@ Standard_OStream& TDataStd_RealList::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceArray.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceArray.cxx index 0395ec4db8..ec06c18a98 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceArray.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceArray.cxx @@ -96,9 +96,13 @@ occ::handle TDataStd_ReferenceArray::Set(const TDF_Labe void TDataStd_ReferenceArray::SetValue(const int index, const TDF_Label& value) { if (myArray.IsNull()) + { return; + } if (value == myArray->Value(index)) + { return; + } Backup(); myArray->SetValue(index, value); @@ -116,7 +120,9 @@ TDF_Label TDataStd_ReferenceArray::Value(const int index) const int TDataStd_ReferenceArray::Lower() const { if (myArray.IsNull()) + { return 0; + } return myArray->Lower(); } @@ -125,7 +131,9 @@ int TDataStd_ReferenceArray::Lower() const int TDataStd_ReferenceArray::Upper() const { if (myArray.IsNull()) + { return -1; + } return myArray->Upper(); } @@ -134,7 +142,9 @@ int TDataStd_ReferenceArray::Upper() const int TDataStd_ReferenceArray::Length() const { if (myArray.IsNull()) + { return 0; + } return myArray->Length(); } @@ -181,10 +191,14 @@ void TDataStd_ReferenceArray::SetInternalArray( Backup(); if (myArray.IsNull() || !aDimEqual) + { myArray = new NCollection_HArray1(aLower, anUpper); + } for (i = aLower; i <= anUpper; i++) + { myArray->SetValue(i, values->Value(i)); + } } //================================================================================================= @@ -199,7 +213,9 @@ const Standard_GUID& TDataStd_ReferenceArray::ID() const void TDataStd_ReferenceArray::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -255,14 +271,18 @@ void TDataStd_ReferenceArray::Paste(const occ::handle& Into const NCollection_Array1& arr = myArray->Array1(); int lower = arr.Lower(), i = lower, upper = arr.Upper(); if (lower != anArray->Lower() || upper != anArray->Upper()) + { anArray->Init(lower, upper); + } for (; i <= upper; i++) { TDF_Label L = arr.Value(i), rL; if (!L.IsNull()) { if (!RT->HasRelocation(L, rL)) + { rL = L; + } anArray->myArray->SetValue(i, rL); } } @@ -280,7 +300,9 @@ void TDataStd_ReferenceArray::References(const occ::handle& aDataSe for (; i <= upper; i++) { if (!arr.Value(i).IsNull()) + { aDataSet->AddLabel(arr.Value(i)); + } } } } @@ -292,7 +314,7 @@ Standard_OStream& TDataStd_ReferenceArray::Dump(Standard_OStream& anOS) const anOS << "\nReferenceArray: "; char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); - anOS << sguid << std::endl; + anOS << sguid << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceList.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceList.cxx index 3615c5895b..55eed40fa0 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceList.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_ReferenceList.cxx @@ -253,7 +253,9 @@ const Standard_GUID& TDataStd_ReferenceList::ID() const void TDataStd_ReferenceList::SetID(const Standard_GUID& theGuid) { if (myID == theGuid) + { return; + } Backup(); myID = theGuid; } @@ -301,7 +303,9 @@ void TDataStd_ReferenceList::Paste(const occ::handle& Into, if (!L.IsNull()) { if (!RT->HasRelocation(L, rL)) + { rL = L; + } aList->Append(rL); } } @@ -330,7 +334,7 @@ Standard_OStream& TDataStd_ReferenceList::Dump(Standard_OStream& anOS) const char sguid[Standard_GUID_SIZE_ALLOC]; myID.ToCString(sguid); anOS << sguid; - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_TreeNode.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_TreeNode.cxx index 3746adca27..e549ca41d5 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_TreeNode.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_TreeNode.cxx @@ -94,7 +94,9 @@ TDataStd_TreeNode::TDataStd_TreeNode() bool TDataStd_TreeNode::Append(const occ::handle& TN) { if (!(TN->ID() == myTreeID)) + { throw Standard_DomainError("TDataStd_TreeNode::Append : uncompatible GUID"); + } occ::handle bid; TN->SetNext(bid); // Deconnects from next. @@ -122,7 +124,9 @@ bool TDataStd_TreeNode::Append(const occ::handle& TN) bool TDataStd_TreeNode::Prepend(const occ::handle& TN) { if (!(TN->ID() == myTreeID)) + { throw Standard_DomainError("TDataStd_TreeNode::Prepend : uncompatible GUID"); + } occ::handle bid; TN->SetPrevious(bid); @@ -146,16 +150,22 @@ bool TDataStd_TreeNode::Prepend(const occ::handle& TN) bool TDataStd_TreeNode::InsertBefore(const occ::handle& TN) { if (!(TN->ID() == myTreeID)) + { throw Standard_DomainError("TDataStd_TreeNode::InsertBefore : uncompatible GUID"); + } TN->SetFather(Father()); TN->SetPrevious(Previous()); TN->SetNext(this); if (!HasPrevious()) + { Father()->SetFirst(TN); + } else + { Previous()->SetNext(TN); + } SetPrevious(TN); return !TN.IsNull(); @@ -166,17 +176,23 @@ bool TDataStd_TreeNode::InsertBefore(const occ::handle& TN) bool TDataStd_TreeNode::InsertAfter(const occ::handle& TN) { if (!(TN->ID() == myTreeID)) + { throw Standard_DomainError("TDataStd_TreeNode::InsertAfter : uncompatible GUID"); + } if (HasFather() && !HasNext()) + { Father()->SetLast(TN); + } TN->SetFather(Father()); TN->SetPrevious(this); TN->SetNext(Next()); if (HasNext()) + { Next()->SetPrevious(TN); + } SetNext(TN); return !TN.IsNull(); @@ -187,25 +203,37 @@ bool TDataStd_TreeNode::InsertAfter(const occ::handle& TN) bool TDataStd_TreeNode::Remove() { if (IsRoot()) + { return true; + } occ::handle bid; if (!HasPrevious()) + { Father()->SetFirst(Next()); + } else + { Previous()->SetNext(Next()); + } if (HasNext()) { if (HasPrevious()) + { Next()->SetPrevious(Previous()); + } else + { Next()->SetPrevious(bid); + } } else { if (HasPrevious()) + { Previous()->SetNext(bid); + } } if (Father()->HasFirst()) @@ -217,7 +245,9 @@ bool TDataStd_TreeNode::Remove() Father()->SetFirst(Next()); } else + { Father()->SetFirst(bid); + } } } @@ -288,7 +318,9 @@ bool TDataStd_TreeNode::IsDescendant(const occ::handle& ofTN) while (O->myFather != nullptr) { if (O->myFather == ofTN) + { return true; + } O = O->myFather; } return false; @@ -364,10 +396,14 @@ occ::handle TDataStd_TreeNode::First() const occ::handle TDataStd_TreeNode::Last() { if (myLast && !myLast->IsChild(this)) + { myLast = nullptr; + } if (myLast == nullptr) + { return FindLast(); + } return myLast; } @@ -377,7 +413,9 @@ occ::handle TDataStd_TreeNode::Last() occ::handle TDataStd_TreeNode::FindLast() { if (myFirst == nullptr) + { return myFirst; + } TDataStd_TreeNode* L = myFirst; while (L->myNext != nullptr) { @@ -392,9 +430,13 @@ void TDataStd_TreeNode::SetFather(const occ::handle& F) { Backup(); if (F.IsNull()) + { myFather = nullptr; + } else + { myFather = F.operator->(); + } myLast = nullptr; } @@ -404,9 +446,13 @@ void TDataStd_TreeNode::SetNext(const occ::handle& F) { Backup(); if (F.IsNull()) + { myNext = nullptr; + } else + { myNext = F.operator->(); + } myLast = nullptr; } @@ -416,9 +462,13 @@ void TDataStd_TreeNode::SetPrevious(const occ::handle& F) { Backup(); if (F.IsNull()) + { myPrevious = nullptr; + } else + { myPrevious = F.operator->(); + } myLast = nullptr; } @@ -428,9 +478,13 @@ void TDataStd_TreeNode::SetFirst(const occ::handle& F) { Backup(); if (F.IsNull()) + { myFirst = nullptr; + } else + { myFirst = F.operator->(); + } myLast = nullptr; } @@ -440,9 +494,13 @@ void TDataStd_TreeNode::SetLast(const occ::handle& F) { Backup(); if (F.IsNull()) + { myLast = nullptr; + } else + { myLast = F.operator->(); + } } //================================================================================================= @@ -452,11 +510,17 @@ void TDataStd_TreeNode::AfterAddition() if (!IsBackuped()) { if (myPrevious) + { myPrevious->SetNext(this); + } else if (myFather) + { myFather->SetFirst(this); + } if (myNext) + { myNext->SetPrevious(this); + } } } @@ -468,7 +532,9 @@ void TDataStd_TreeNode::BeforeForget() { Remove(); while (HasFirst()) + { First()->Remove(); + } } } @@ -485,7 +551,9 @@ bool TDataStd_TreeNode::BeforeUndo(const occ::handle& anAttD const bool /*forceIt*/) { if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) + { BeforeForget(); // Disconnect. + } return true; } @@ -495,7 +563,9 @@ bool TDataStd_TreeNode::AfterUndo(const occ::handle& anAttDe const bool /*forceIt*/) { if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnRemoval))) + { AfterAddition(); // Reconnect. + } return true; } @@ -573,33 +643,43 @@ Standard_OStream& TDataStd_TreeNode::Dump(Standard_OStream& anOS) const { anOS << " Father="; if (!myFather->Label().IsNull()) + { myFather->Label().EntryDump(anOS); + } } if (myPrevious) { anOS << " Previous="; if (!myPrevious->Label().IsNull()) + { myPrevious->Label().EntryDump(anOS); + } } if (myNext) { anOS << " Next="; if (!myNext->Label().IsNull()) + { myNext->Label().EntryDump(anOS); + } } if (myFirst) { anOS << " First="; if (!myFirst->Label().IsNull()) + { myFirst->Label().EntryDump(anOS); + } } if (myLast) { anOS << " Last="; if (!myLast->Label().IsNull()) + { myLast->Label().EntryDump(anOS); + } } - anOS << std::endl; + anOS << '\n'; return anOS; } diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_UAttribute.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_UAttribute.cxx index 0613c92abb..ab1e163e78 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_UAttribute.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_UAttribute.cxx @@ -59,7 +59,9 @@ void TDataStd_UAttribute::SetID(const Standard_GUID& guid) { // OCC2932 correction if (myID == guid) + { return; + } Backup(); myID = guid; diff --git a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Variable.cxx b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Variable.cxx index ddaaa20f0d..966ec2c920 100644 --- a/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Variable.cxx +++ b/src/ApplicationFramework/TKLCAF/TDataStd/TDataStd_Variable.cxx @@ -191,7 +191,9 @@ void TDataStd_Variable::Constant(const bool status) { // OCC2932 correction if (isConstant == status) + { return; + } Backup(); isConstant = status; @@ -203,7 +205,9 @@ void TDataStd_Variable::Unit(const TCollection_AsciiString& unit) { // OCC2932 correction if (myUnit == unit) + { return; + } Backup(); myUnit = unit; diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Application.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Application.cxx index 0ad3ec0936..176ddba394 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Application.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Application.cxx @@ -43,7 +43,9 @@ TDocStd_Application::TDocStd_Application() : myIsDriverLoaded(true) { if (myMetaDataDriver.IsNull()) + { myIsDriverLoaded = false; + } } //================================================================================================= @@ -88,9 +90,13 @@ void TDocStd_Application::DefineFormat(const TCollection_AsciiString& // set format ID in the drivers to allow them putting it in // the OCAF documents opened by these drivers if (!theReader.IsNull()) + { theReader->SetFormat(theFormat); + } if (!theWriter.IsNull()) + { theWriter->SetFormat(theFormat); + } // register drivers myReaders.Add(theFormat, theReader); @@ -231,7 +237,9 @@ int TDocStd_Application::IsInSession(const TCollection_ExtendedString& path) con unifiedDocPath.ChangeAll('\\', '|'); if (unifiedPath == unifiedDocPath) + { return i; + } } } return 0; @@ -263,7 +271,9 @@ PCDM_ReaderStatus TDocStd_Application::Open(const TCollection_ExtendedString& occ::handle D = occ::down_cast(Retrieve(directory, file, true, theFilter, theRange)); if (theFilter.IsNull() || !theFilter->IsAppendMode()) + { CDF_Application::Open(D); + } theDoc = D; } catch (Standard_Failure const& anException) @@ -337,7 +347,9 @@ PCDM_StoreStatus TDocStd_Application::SaveAs(const occ::handle aMsg += directory; aMsg += " does not exist"; if (!MessageDriver().IsNull()) + { MessageDriver()->Send(aMsg.ToExtString(), Message_Fail); + } return storer.StoreStatus(); // CDF_SS_Failure; } storer.SetName(file); @@ -355,9 +367,13 @@ PCDM_StoreStatus TDocStd_Application::SaveAs(const occ::handle } } if (storer.StoreStatus() == PCDM_SS_OK) + { theDoc->SetSaved(); + } else if (!MessageDriver().IsNull()) + { MessageDriver()->Send(storer.AssociatedStatusText(), Message_Fail); + } #ifdef OCCT_DEBUG std::cout << "TDocStd_Application::SaveAs(): The status = " << storer.StoreStatus() << std::endl; #endif @@ -423,7 +439,9 @@ PCDM_StoreStatus TDocStd_Application::Save(const occ::handle& } } if (storer.StoreStatus() == PCDM_SS_OK) + { D->SetSaved(); + } status = storer.StoreStatus(); } else @@ -473,7 +491,9 @@ PCDM_StoreStatus TDocStd_Application::SaveAs(const occ::handle } } if (storer.StoreStatus() == PCDM_SS_OK) + { D->SetSaved(); + } theStatusMessage = storer.AssociatedStatusText(); aStatus = storer.StoreStatus(); } @@ -549,7 +569,9 @@ PCDM_StoreStatus TDocStd_Application::Save(const occ::handle& } } if (storer.StoreStatus() == PCDM_SS_OK) + { D->SetSaved(); + } status = storer.StoreStatus(); theStatusMessage = storer.AssociatedStatusText(); } diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Document.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Document.cxx index 35e5846b5c..773601f5ea 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Document.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_Document.cxx @@ -311,7 +311,9 @@ bool TDocStd_Document::CommitTransaction() myFromRedo.Nullify(); } else + { myFromUndo = myUndos.First(); + } } #endif } @@ -330,7 +332,9 @@ bool TDocStd_Document::CommitTransaction() const occ::handle anAppli = occ::down_cast(Application()); if (!anAppli.IsNull()) + { anAppli->OnCommitTransaction(this); + } } return isDone; } @@ -342,16 +346,24 @@ void TDocStd_Document::AbortTransaction() myData->AllowModification(true); if (myUndoTransaction.IsOpen()) + { if (myUndoLimit != 0) + { myUndoTransaction.Abort(); + } + } if (myIsNestedTransactionMode && myUndoFILO.Extent()) { if (!myUndoFILO.First()->IsEmpty()) + { myData->Undo(myUndoFILO.First(), true); + } myUndoFILO.RemoveFirst(); if (myUndoFILO.Extent()) + { myUndoTransaction.Open(); + } } // deny or allow modifications according to transaction state if (myOnlyTransactionModification) @@ -364,7 +376,9 @@ void TDocStd_Document::AbortTransaction() const occ::handle anAppli = occ::down_cast(Application()); if (!anAppli.IsNull()) + { anAppli->OnAbortTransaction(this); + } } } @@ -387,14 +401,18 @@ void TDocStd_Document::OpenTransaction() } int aLastTime = myData->Time(); if (myUndoFILO.Extent()) + { aLastTime = myUndoFILO.First()->EndTime(); + } occ::handle aCompoundDelta = new TDocStd_CompoundDelta; aCompoundDelta->Validity(aLastTime, aLastTime); myUndoFILO.Prepend(aCompoundDelta); } if (myUndoLimit != 0) + { myUndoTransaction.Open(); + } // deny or allow modifications according to transaction state if (myOnlyTransactionModification) @@ -407,7 +425,9 @@ void TDocStd_Document::OpenTransaction() const occ::handle anAppli = occ::down_cast(Application()); if (!anAppli.IsNull()) + { anAppli->OnOpenTransaction(this); + } } } @@ -490,7 +510,9 @@ bool TDocStd_Document::Undo() // only for nested transaction mode while (myIsNestedTransactionMode && myUndoFILO.Extent()) + { AbortTransaction(); + } // allow modifications myData->AllowModification(true); @@ -515,7 +537,9 @@ bool TDocStd_Document::Undo() } if (isOpened && undoDone) + { OpenTransaction(); + } // deny or allow modifications according to transaction state if (myOnlyTransactionModification) @@ -548,7 +572,9 @@ bool TDocStd_Document::Redo() // only for nested transaction mode while (myIsNestedTransactionMode && myUndoFILO.Extent()) + { AbortTransaction(); + } // allow modifications myData->AllowModification(true); @@ -572,7 +598,9 @@ bool TDocStd_Document::Redo() } if (isOpened && undoDone) + { OpenTransaction(); + } // deny or allow modifications according to transaction state if (myOnlyTransactionModification) @@ -636,7 +664,9 @@ bool TDocStd_Document::InitDeltaCompaction() myFromUndo = myUndos.Last(); if (myRedos.Extent() > 0) + { myFromRedo = myRedos.First(); + } #endif return true; } @@ -647,7 +677,9 @@ bool TDocStd_Document::PerformDeltaCompaction() { #ifdef SRN_DELTA_COMPACT if (myFromUndo.IsNull()) + { return false; // Redo can be Null for this operation + } NCollection_List> aList; occ::handle aCompoundDelta = new TDocStd_CompoundDelta; @@ -663,7 +695,9 @@ bool TDocStd_Document::PerformDeltaCompaction() if (!isFound) { if (myFromUndo == anIterator.Value()) + { isFound = true; + } aList.Append(anIterator.Value()); // Fill the list of deltas that precede compound delta continue; } @@ -683,11 +717,10 @@ bool TDocStd_Document::PerformDeltaCompaction() aMap.Bind(aDeltasIterator.Value()->Label(), *pIDMap); delete pIDMap; } - if (aMap(aDeltasIterator.Value()->Label()) - .Add(aDeltasIterator.Value()->ID())) // The attribute is not - // clang-format off - aCompoundDelta->AddAttributeDelta(aDeltasIterator.Value()); //already in the delta - // clang-format on + if (aMap(aDeltasIterator.Value()->Label()).Add(aDeltasIterator.Value()->ID())) + { // The attribute is not already in the delta + aCompoundDelta->AddAttributeDelta(aDeltasIterator.Value()); + } } } @@ -709,7 +742,9 @@ bool TDocStd_Document::PerformDeltaCompaction() { aList.Append(anIterator.Value()); if (anIterator.Value() == myFromRedo) + { break; + } } myRedos.Clear(); @@ -742,7 +777,9 @@ void TDocStd_Document::ChangeStorageFormat(const TCollection_ExtendedString& new void TDocStd_Document::Recompute() { if (IsValid()) + { return; + } // find the top function and execute it // occ::handle F; // if (Main().FindAttribute(TDesign_Function::GetID(),F)) { @@ -758,7 +795,9 @@ void TDocStd_Document::AppendDeltaToTheFirst(const occ::handle& theDelta2) { if (theDelta2->IsEmpty()) + { return; + } NCollection_DataMap> aMap; NCollection_List>::Iterator aDeltasIterator1( @@ -787,7 +826,9 @@ void TDocStd_Document::AppendDeltaToTheFirst(const occ::handle& anIDMap = aMap.Find(aLabel); if (anIDMap.Contains(anID)) + { continue; + } } theDelta1->AddAttributeDelta(aDeltasIterator2.Value()); } @@ -798,7 +839,9 @@ void TDocStd_Document::AppendDeltaToTheFirst(const occ::handleIsEmpty(); + } } //================================================================================================= @@ -61,7 +63,9 @@ bool TDocStd_Modified::Remove(const TDF_Label& alabel) return true; } else + { return MDF->RemoveLabel(alabel); + } } //================================================================================================= @@ -98,7 +102,9 @@ void TDocStd_Modified::Clear(const TDF_Label& access) return; } else + { MDF->Clear(); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_MultiTransactionManager.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_MultiTransactionManager.cxx index d222f15807..0d2c5d7efd 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_MultiTransactionManager.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_MultiTransactionManager.cxx @@ -49,7 +49,9 @@ void TDocStd_MultiTransactionManager::SetUndoLimit(const int theLimit) int i; for (i = myDocuments.Length(); i > 0; i--) + { myDocuments.Value(i)->SetUndoLimit(myUndoLimit); + } } //================================================================================================= @@ -57,14 +59,18 @@ void TDocStd_MultiTransactionManager::SetUndoLimit(const int theLimit) void TDocStd_MultiTransactionManager::Undo() { if (myUndos.IsEmpty()) + { return; + } const NCollection_Sequence>& docs = myUndos.First()->GetDocuments(); int i; for (i = docs.Length(); i > 0; i--) { occ::handle doc = docs.Value(i); if (doc.IsNull() || doc->GetAvailableUndos() == 0) + { continue; + } doc->Undo(); } myRedos.Prepend(myUndos.First()); @@ -77,14 +83,18 @@ void TDocStd_MultiTransactionManager::Undo() void TDocStd_MultiTransactionManager::Redo() { if (myRedos.IsEmpty()) + { return; + } const NCollection_Sequence>& docs = myRedos.First()->GetDocuments(); int i; for (i = docs.Length(); i > 0; i--) { occ::handle doc = docs.Value(i); if (doc.IsNull() || doc->GetAvailableRedos() == 0) + { continue; + } doc->Redo(); } myUndos.Prepend(myRedos.First()); @@ -112,7 +122,9 @@ void TDocStd_MultiTransactionManager::OpenCommand() for (i = myDocuments.Length(); i > 0; i--) { while (myDocuments.Value(i)->HasOpenCommand()) + { myDocuments.Value(i)->AbortCommand(); + } myDocuments.Value(i)->OpenCommand(); } } @@ -126,7 +138,9 @@ void TDocStd_MultiTransactionManager::AbortCommand() for (i = myDocuments.Length(); i > 0; i--) { while (myDocuments.Value(i)->HasOpenCommand()) + { myDocuments.Value(i)->AbortCommand(); + } } } @@ -141,8 +155,12 @@ bool TDocStd_MultiTransactionManager::CommitCommand() { isCommited = false; while (myDocuments.Value(i)->HasOpenCommand()) + { if (myDocuments.Value(i)->CommitCommand()) + { isCommited = true; + } + } if (isCommited) { aDelta->GetDocuments().Append(myDocuments.Value(i)); @@ -169,7 +187,9 @@ bool TDocStd_MultiTransactionManager::CommitCommand(const TCollection_ExtendedSt { bool isCommited = CommitCommand(); if (isCommited && myUndos.Length()) + { myUndos.First()->SetName(theName); + } return isCommited; } @@ -179,27 +199,37 @@ void TDocStd_MultiTransactionManager::DumpTransaction(Standard_OStream& anOS) co { int i; if (myDocuments.Length() == 0) - anOS << "Manager is empty" << std::endl; + { + anOS << "Manager is empty" << '\n'; + } else { if (myDocuments.Length() == 1) + { anOS << "There is one document ( "; + } else + { anOS << "There are " << myDocuments.Length() << " documents ( "; + } for (i = 1; i <= myDocuments.Length(); i++) { occ::handle aDoc(myDocuments.Value(i)); anOS << "\"" << aDoc.get(); anOS << "\" "; } - anOS << ") in the manager " << std::endl; + anOS << ") in the manager " << '\n'; if (myIsNestedTransactionMode) - anOS << "Nested transaction mode is on" << std::endl; + { + anOS << "Nested transaction mode is on" << '\n'; + } else - anOS << "Nested transaction mode is off" << std::endl; + { + anOS << "Nested transaction mode is off" << '\n'; + } - anOS << " " << std::endl; + anOS << " " << '\n'; } for (i = myUndos.Length(); i > 0; i--) @@ -209,11 +239,11 @@ void TDocStd_MultiTransactionManager::DumpTransaction(Standard_OStream& anOS) co delta->Dump(anOS); if (i == 1) { - anOS << " < Last action" << std::endl; + anOS << " < Last action" << '\n'; } else { - anOS << std::endl; + anOS << '\n'; } } for (i = 1; i <= myRedos.Length(); i++) @@ -221,7 +251,7 @@ void TDocStd_MultiTransactionManager::DumpTransaction(Standard_OStream& anOS) co occ::handle delta = myRedos.Value(i); anOS << " Redo: "; delta->Dump(anOS); - anOS << std::endl; + anOS << '\n'; } } @@ -230,7 +260,9 @@ void TDocStd_MultiTransactionManager::DumpTransaction(Standard_OStream& anOS) co void TDocStd_MultiTransactionManager::RemoveLastUndo() { if (myUndos.Length() == 0) + { return; + } const NCollection_Sequence>& docs = myUndos.Last()->GetDocuments(); int i; for (i = 1; i <= docs.Length(); i++) @@ -246,11 +278,17 @@ void TDocStd_MultiTransactionManager::AddDocument(const occ::handle 0; i--) + { if (myDocuments.Value(i) == theDoc) + { return; // the document is already added to the list + } + } if (theDoc->IsNestedTransactionMode() != myIsNestedTransactionMode) + { theDoc->SetNestedTransactionMode(myIsNestedTransactionMode); + } theDoc->SetModificationMode(myOnlyTransactionModification); @@ -259,12 +297,16 @@ void TDocStd_MultiTransactionManager::AddDocument(const occ::handleHasOpenCommand()) + { theDoc->OpenCommand(); + } } else { if (theDoc->HasOpenCommand()) + { theDoc->CommitCommand(); + } } theDoc->ClearUndos(); theDoc->ClearRedos(); @@ -278,7 +320,9 @@ void TDocStd_MultiTransactionManager::RemoveDocument(const occ::handle 0; i--) { if (myDocuments.Value(i) == theDoc) + { myDocuments.Remove(i); + } } for (i = myUndos.Length(); i > 0; i--) { @@ -290,7 +334,9 @@ void TDocStd_MultiTransactionManager::RemoveDocument(const occ::handle 0; i--) { if (myDocuments.Value(i)->IsNestedTransactionMode() != myIsNestedTransactionMode) + { myDocuments.Value(i)->SetNestedTransactionMode(myIsNestedTransactionMode); + } } } diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_PathParser.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_PathParser.cxx index f878535191..b97b412dd1 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_PathParser.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_PathParser.cxx @@ -29,9 +29,13 @@ void TDocStd_PathParser::Parse() TCollection_ExtendedString temp = myPath; int PointPosition = myPath.SearchFromEnd(TCollection_ExtendedString(".")); if (PointPosition > 0) + { myExtension = temp.Split(PointPosition); + } else + { return; + } temp.Trunc(PointPosition - 1); bool isFileName = (temp.Length()) != 0; bool isTrek = true; @@ -54,7 +58,9 @@ void TDocStd_PathParser::Parse() #else PointPosition = temp.SearchFromEnd(TCollection_ExtendedString("/")); if (PointPosition > 0) + { myName = temp.Split(PointPosition); + } else { if (isFileName) @@ -63,7 +69,9 @@ void TDocStd_PathParser::Parse() isTrek = false; } else + { return; + } } #endif //_WIN32 if (isTrek) @@ -72,10 +80,13 @@ void TDocStd_PathParser::Parse() myTrek = temp; } else + { #ifdef _WIN32 myTrek = ".\\"; + } #else myTrek = "./"; + } #endif } diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkIterator.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkIterator.cxx index 63015477db..069d03af03 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkIterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkIterator.cxx @@ -53,9 +53,13 @@ void TDocStd_XLinkIterator::Initialize(const occ::handle& DOC) void TDocStd_XLinkIterator::Next() { if (myValue == nullptr) + { throw Standard_NoMoreObject("TDocStd_XLinkIterator::Next() - no more values available"); + } else + { myValue = myValue->Next(); + } } //================================================================================================= @@ -64,5 +68,7 @@ void TDocStd_XLinkIterator::Init(const occ::handle& DOC) { occ::handle xRefRoot; if (DOC->GetData()->Root().FindAttribute(TDocStd_XLinkRoot::GetID(), xRefRoot)) + { myValue = xRefRoot->First(); + } } diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkRoot.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkRoot.cxx index c27e50898a..ee88864d63 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkRoot.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkRoot.cxx @@ -81,7 +81,9 @@ void TDocStd_XLinkRoot::Remove(const TDocStd_XLinkPtr& anXLinkPtr) else { while (previous != nullptr && previous->Next() != anXLinkPtr) + { previous = previous->Next(); + } if (previous != nullptr) { previous->Next(anXLinkPtr->Next()); diff --git a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkTool.cxx b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkTool.cxx index 71437d0f26..6a689f0671 100644 --- a/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkTool.cxx +++ b/src/ApplicationFramework/TKLCAF/TDocStd/TDocStd_XLinkTool.cxx @@ -87,13 +87,17 @@ void TDocStd_XLinkTool::Copy(const TDF_Label& target, const TDF_Label& source) if (!aNode.IsNull()) { if (!aPrev.IsNull()) + { aPrev->InsertAfter(aNode); + } else if (!aNext.IsNull()) { aNext->InsertBefore(aNode); } else if (!aFather.IsNull()) + { aNode->SetFather(aFather); + } } if (!anOldNode.IsNull()) @@ -101,13 +105,17 @@ void TDocStd_XLinkTool::Copy(const TDF_Label& target, const TDF_Label& source) if (TDataStd_TreeNode::Find(target, anOldNode)) { if (!anOldPrev.IsNull()) + { anOldPrev->InsertAfter(anOldNode); + } else if (!anOldNext.IsNull()) { anOldNext->InsertBefore(anOldNode); } else if (!anOldFather.IsNull()) + { anOldNode->SetFather(anOldFather); + } } } @@ -132,7 +140,9 @@ void TDocStd_XLinkTool::CopyWithLink(const TDF_Label& target, const TDF_Label& s occ::handle aTargetD = TDocStd_Document::Get(target); int aDocEntry = 0; if (aSourceD != aTargetD) + { aDocEntry = aTargetD->CreateReference(aSourceD); + } xdocentry = aDocEntry; occ::handle X = TDocStd_XLink::Set(target); diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Driver.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Driver.cxx index cedacc0e50..f6d157fb1c 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Driver.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Driver.cxx @@ -56,7 +56,9 @@ bool TFunction_Driver::MustExecute(const occ::handle& log) co for (; itr.More(); itr.Next()) { if (log->IsModified(itr.Value())) + { return true; + } } return false; } diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_DriverTable.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_DriverTable.cxx index 71b963563e..0a9b08908b 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_DriverTable.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_DriverTable.cxx @@ -31,7 +31,9 @@ static occ::handle DT; occ::handle TFunction_DriverTable::Get() { if (DT.IsNull()) + { DT = new TFunction_DriverTable; + } return DT; } @@ -46,7 +48,9 @@ bool TFunction_DriverTable::AddDriver(const Standard_GUID& guid, const int thread) { if (thread == 0) + { return myDrivers.Bind(guid, driver); + } else if (thread > 0) { if (myThreadDrivers.IsNull()) @@ -88,9 +92,13 @@ bool TFunction_DriverTable::AddDriver(const Standard_GUID& guid, bool TFunction_DriverTable::HasDriver(const Standard_GUID& guid, const int thread) const { if (thread == 0) + { return myDrivers.IsBound(guid); + } else if (thread > 0 && !myThreadDrivers.IsNull() && myThreadDrivers->Upper() >= thread) + { return myThreadDrivers->Value(thread).IsBound(guid); + } return false; } @@ -140,9 +148,13 @@ Standard_OStream& TFunction_DriverTable::Dump(Standard_OStream& anOS) const bool TFunction_DriverTable::RemoveDriver(const Standard_GUID& guid, const int thread) { if (thread == 0) + { return myDrivers.UnBind(guid); + } else if (thread > 0 && !myThreadDrivers.IsNull() && myThreadDrivers->Upper() >= thread) + { myThreadDrivers->ChangeValue(thread).UnBind(guid); + } return false; } @@ -152,5 +164,7 @@ void TFunction_DriverTable::Clear() { myDrivers.Clear(); if (!myThreadDrivers.IsNull()) + { myThreadDrivers.Nullify(); + } } diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Function.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Function.cxx index 9f99a74940..b18d996a33 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Function.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Function.cxx @@ -90,7 +90,9 @@ void TFunction_Function::SetDriverGUID(const Standard_GUID& guid) { // OCC2932 correction if (myDriverGUID == guid) + { return; + } Backup(); myDriverGUID = guid; @@ -102,7 +104,9 @@ void TFunction_Function::SetFailure(const int mode) { // OCC2932 correction if (myFailure == mode) + { return; + } Backup(); myFailure = mode; diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_GraphNode.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_GraphNode.cxx index f33d2a00db..588b13ecca 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_GraphNode.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_GraphNode.cxx @@ -63,7 +63,9 @@ TFunction_GraphNode::TFunction_GraphNode() bool TFunction_GraphNode::AddPrevious(const int funcID) { if (myPrevious.Contains(funcID)) + { return false; + } Backup(); @@ -76,7 +78,9 @@ bool TFunction_GraphNode::AddPrevious(const TDF_Label& func) { occ::handle scope = TFunction_Scope::Set(func); if (!scope->GetFunctions().IsBound2(func)) + { return false; + } int funcID = scope->GetFunctions().Find2(func); return AddPrevious(funcID); } @@ -86,7 +90,9 @@ bool TFunction_GraphNode::AddPrevious(const TDF_Label& func) bool TFunction_GraphNode::RemovePrevious(const int funcID) { if (!myPrevious.Contains(funcID)) + { return false; + } Backup(); @@ -99,7 +105,9 @@ bool TFunction_GraphNode::RemovePrevious(const TDF_Label& func) { occ::handle scope = TFunction_Scope::Set(func); if (!scope->GetFunctions().IsBound2(func)) + { return false; + } int funcID = scope->GetFunctions().Find2(func); return RemovePrevious(funcID); } @@ -116,7 +124,9 @@ const NCollection_Map& TFunction_GraphNode::GetPrevious() const void TFunction_GraphNode::RemoveAllPrevious() { if (myPrevious.IsEmpty()) + { return; + } Backup(); @@ -128,7 +138,9 @@ void TFunction_GraphNode::RemoveAllPrevious() bool TFunction_GraphNode::AddNext(const int funcID) { if (myNext.Contains(funcID)) + { return false; + } Backup(); @@ -141,7 +153,9 @@ bool TFunction_GraphNode::AddNext(const TDF_Label& func) { occ::handle scope = TFunction_Scope::Set(func); if (!scope->GetFunctions().IsBound2(func)) + { return false; + } int funcID = scope->GetFunctions().Find2(func); return AddNext(funcID); } @@ -151,7 +165,9 @@ bool TFunction_GraphNode::AddNext(const TDF_Label& func) bool TFunction_GraphNode::RemoveNext(const int funcID) { if (!myNext.Contains(funcID)) + { return false; + } Backup(); @@ -164,7 +180,9 @@ bool TFunction_GraphNode::RemoveNext(const TDF_Label& func) { occ::handle scope = TFunction_Scope::Set(func); if (!scope->GetFunctions().IsBound2(func)) + { return false; + } int funcID = scope->GetFunctions().Find2(func); return RemoveNext(funcID); } @@ -181,7 +199,9 @@ const NCollection_Map& TFunction_GraphNode::GetNext() const void TFunction_GraphNode::RemoveAllNext() { if (myNext.IsEmpty()) + { return; + } Backup(); @@ -200,7 +220,9 @@ TFunction_ExecutionStatus TFunction_GraphNode::GetStatus() const void TFunction_GraphNode::SetStatus(const TFunction_ExecutionStatus status) { if (myStatus == status) + { return; + } Backup(); diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_IFunction.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_IFunction.cxx index 91614de9c7..adc9ed0cf7 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_IFunction.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_IFunction.cxx @@ -48,7 +48,9 @@ bool TFunction_IFunction::DeleteFunction(const TDF_Label& L) // Delete Function occ::handle func; if (L.FindAttribute(TFunction_Function::GetID(), func)) + { L.ForgetAttribute(func); + } // Take the scope of functions occ::handle scope = TFunction_Scope::Set(L); @@ -144,7 +146,9 @@ bool TFunction_IFunction::UpdateDependencies(const TDF_Label& Access) NCollection_Map argsMap; NCollection_List::Iterator itrl(args); for (; itrl.More(); itrl.Next()) + { argsMap.Add(itrl.Value()); + } // ID of the function const int funcID = itrm.Key1(); @@ -154,7 +158,9 @@ bool TFunction_IFunction::UpdateDependencies(const TDF_Label& Access) { const TDF_Label& anotherL = itrd.Key(); if (L == anotherL) + { continue; + } const NCollection_List& anotherRes = itrd.Value(); for (itrl.Initialize(anotherRes); itrl.More(); itrl.Next()) @@ -227,7 +233,9 @@ bool TFunction_IFunction::UpdateDependencies() const { const TDF_Label& L = itrm.Key2(); if (L == myLabel) + { continue; + } TFunction_IFunction iFunc(L); D = iFunc.GetDriver(); @@ -356,11 +364,15 @@ occ::handle TFunction_IFunction::GetDriver(const int thread) c occ::handle driver; occ::handle func; if (!myLabel.FindAttribute(TFunction_Function::GetID(), func)) + { throw Standard_NoSuchObject( "TFunction_IFunction::GetDriver(): A Function is not found attached to this label"); + } if (!TFunction_DriverTable::Get()->FindDriver(func->GetDriverGUID(), driver, thread)) + { throw Standard_NoSuchObject( "TFunction_IFunction::GetDriver(): A driver is not found for this ID"); + } driver->Init(myLabel); return driver; } @@ -371,7 +383,9 @@ occ::handle TFunction_IFunction::GetGraphNode() const { occ::handle graphNode; if (!myLabel.FindAttribute(TFunction_GraphNode::GetID(), graphNode)) + { throw Standard_NoSuchObject( "TFunction_IFunction::GetStatus(): A graph node is not found attached to this label"); + } return graphNode; } diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Iterator.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Iterator.cxx index 5f71bd3e2c..e932f32777 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Iterator.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Iterator.cxx @@ -59,17 +59,23 @@ void TFunction_Iterator::Init(const TDF_Label& Access) // Check whether the function is a root function if (!graphNode->GetPrevious().IsEmpty()) + { continue; + } // In execution mode we consider only "not executed" functions. if (myUsageOfExecutionStatus && status != TFunction_ES_NotExecuted) + { continue; + } myCurrent.Append(L); // Register already passed functions if (!myUsageOfExecutionStatus) + { myPassedFunctions.Add(L); + } } } @@ -107,7 +113,9 @@ int TFunction_Iterator::GetMaxNbThreads() const { const NCollection_List& current = fIterator.Current(); if (nb_threads < current.Extent()) + { nb_threads = current.Extent(); + } fIterator.Next(); } @@ -132,7 +140,9 @@ bool TFunction_Iterator::More() const { const TDF_Label& L = itrm.Key2(); if (GetStatus(L) == TFunction_ES_NotExecuted) + { return true; + } } return false; } @@ -216,13 +226,17 @@ void TFunction_Iterator::Next() // Ignore already passed functions (for the mode of ignoring the execution status). if (!myUsageOfExecutionStatus && myPassedFunctions.Contains(Lnext)) + { continue; + } next_current.Add(Lnext); // Register already passed functions if (!myUsageOfExecutionStatus) + { myPassedFunctions.Add(Lnext); + } } } @@ -255,10 +269,12 @@ void TFunction_Iterator::SetStatus(const TDF_Label& func, Standard_OStream& TFunction_Iterator::Dump(Standard_OStream& anOS) const { - anOS << "Functions:" << std::endl; + anOS << "Functions:" << '\n'; if (myCurrent.IsEmpty()) + { return anOS; + } // Memorize the status of each function // in order to recover it after iteration. @@ -306,7 +322,7 @@ Standard_OStream& TFunction_Iterator::Dump(Standard_OStream& anOS) const fIterator.Next(); - anOS << std::endl; + anOS << '\n'; } // Recover the status of functions diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Logbook.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Logbook.cxx index 51accc48b0..d214a4403e 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Logbook.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Logbook.cxx @@ -84,9 +84,13 @@ bool TFunction_Logbook::IsEmpty() const bool TFunction_Logbook::IsModified(const TDF_Label& L, const bool WithChildren) const { if (myTouched.Contains(L)) + { return true; + } if (myImpacted.Contains(L)) + { return true; + } if (WithChildren) { TDF_ChildIterator itr(L); @@ -204,9 +208,13 @@ void TFunction_Logbook::Paste(const occ::handle& into, { TDF_Label relocL; if (RT->HasRelocation(L, relocL)) + { logbook->myTouched.Add(relocL); + } else + { logbook->myTouched.Add(L); + } } } @@ -220,9 +228,13 @@ void TFunction_Logbook::Paste(const occ::handle& into, { TDF_Label relocL; if (RT->HasRelocation(L, relocL)) + { logbook->myImpacted.Add(relocL); + } else + { logbook->myImpacted.Add(L); + } } } @@ -236,9 +248,13 @@ void TFunction_Logbook::Paste(const occ::handle& into, { TDF_Label relocL; if (RT->HasRelocation(L, relocL)) + { logbook->myValid.Add(relocL); + } else + { logbook->myValid.Add(L); + } } } } @@ -257,24 +273,24 @@ Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const NCollection_Map::Iterator itr; TCollection_AsciiString as; - stream << "Done = " << isDone << std::endl; - stream << "Touched labels: " << std::endl; + stream << "Done = " << isDone << '\n'; + stream << "Touched labels: " << '\n'; for (itr.Initialize(myTouched); itr.More(); itr.Next()) { TDF_Tool::Entry(itr.Key(), as); - stream << as << std::endl; + stream << as << '\n'; } - stream << "Impacted labels: " << std::endl; + stream << "Impacted labels: " << '\n'; for (itr.Initialize(myImpacted); itr.More(); itr.Next()) { TDF_Tool::Entry(itr.Key(), as); - stream << as << std::endl; + stream << as << '\n'; } - stream << "Valid labels: " << std::endl; + stream << "Valid labels: " << '\n'; for (itr.Initialize(myValid); itr.More(); itr.Next()) { TDF_Tool::Entry(itr.Key(), as); - stream << as << std::endl; + stream << as << '\n'; } return stream; diff --git a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Scope.cxx b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Scope.cxx index 26b2e2dfdc..b960f1eb20 100644 --- a/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Scope.cxx +++ b/src/ApplicationFramework/TKLCAF/TFunction/TFunction_Scope.cxx @@ -61,7 +61,9 @@ TFunction_Scope::TFunction_Scope() bool TFunction_Scope::AddFunction(const TDF_Label& L) { if (myFunctions.IsBound2(L)) + { return false; + } Backup(); @@ -74,7 +76,9 @@ bool TFunction_Scope::AddFunction(const TDF_Label& L) bool TFunction_Scope::RemoveFunction(const TDF_Label& L) { if (!myFunctions.IsBound2(L)) + { return false; + } Backup(); @@ -86,7 +90,9 @@ bool TFunction_Scope::RemoveFunction(const TDF_Label& L) bool TFunction_Scope::RemoveFunction(const int ID) { if (!myFunctions.IsBound1(ID)) + { return false; + } Backup(); @@ -98,7 +104,9 @@ bool TFunction_Scope::RemoveFunction(const int ID) void TFunction_Scope::RemoveAllFunctions() { if (myFunctions.IsEmpty()) + { return; + } Backup(); @@ -195,7 +203,9 @@ NCollection_DoubleMap& TFunction_Scope::ChangeFunctions() void TFunction_Scope::SetFreeID(const int ID) { if (myFreeID == ID) + { return; + } Backup(); diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_BRep.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_BRep.cxx index 025f429c98..08371643bd 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_BRep.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_BRep.cxx @@ -73,7 +73,9 @@ void ShapePersistent_BRep::PointRepresentation::Import( thePoints.Clear(); occ::handle aPoint = this; for (; aPoint; aPoint = aPoint->myNext) + { thePoints.Prepend(aPoint->import()); + } } occ::handle ShapePersistent_BRep::PointRepresentation::import() const @@ -107,7 +109,9 @@ occ::handle ShapePersistent_BRep::PointOnCurve::import { occ::handle aCurve; if (myCurve) + { aCurve = myCurve->Import(); + } return new BRep_PointOnCurve(myParameter, aCurve, myLocation.Import()); } @@ -160,11 +164,15 @@ occ::handle ShapePersistent_BRep::PointOnCurveOnSurfac { occ::handle aPCurve; if (myPCurve) + { aPCurve = myPCurve->Import(); + } occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } return new BRep_PointOnCurveOnSurface(myParameter, aPCurve, aSurface, myLocation.Import()); } @@ -188,7 +196,9 @@ occ::handle ShapePersistent_BRep::PointOnSurface::impo { occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } return new BRep_PointOnSurface(myParameter, myParameter2, aSurface, myLocation.Import()); } @@ -219,7 +229,9 @@ void ShapePersistent_BRep::CurveRepresentation::Import( theCurves.Clear(); occ::handle aCurve = this; for (; aCurve; aCurve = aCurve->myNext) + { theCurves.Prepend(aCurve->import()); + } } occ::handle ShapePersistent_BRep::CurveRepresentation::import() const @@ -268,7 +280,9 @@ occ::handle ShapePersistent_BRep::Curve3D::import() co { occ::handle aCurve3D; if (myCurve3D) + { aCurve3D = myCurve3D->Import(); + } occ::handle aRepresentation = new BRep_Curve3D(aCurve3D, myLocation.Import()); @@ -303,11 +317,15 @@ occ::handle ShapePersistent_BRep::CurveOnSurface::impo { occ::handle aPCurve; if (myPCurve) + { aPCurve = myPCurve->Import(); + } occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } occ::handle aRepresentation = new BRep_CurveOnSurface(aPCurve, aSurface, myLocation.Import()); @@ -344,15 +362,21 @@ occ::handle ShapePersistent_BRep::CurveOnClosedSurface { occ::handle aPCurve; if (myPCurve) + { aPCurve = myPCurve->Import(); + } occ::handle aPCurve2; if (myPCurve2) + { aPCurve2 = myPCurve2->Import(); + } occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } GeomAbs_Shape aContinuity = static_cast(myContinuity); @@ -392,7 +416,9 @@ occ::handle ShapePersistent_BRep::Polygon3D::import() { occ::handle aPolygon3D; if (myPolygon3D) + { aPolygon3D = myPolygon3D->Import(); + } return new BRep_Polygon3D(aPolygon3D, myLocation.Import()); } @@ -424,11 +450,15 @@ occ::handle ShapePersistent_BRep::PolygonOnTriangulati { occ::handle aPolygon; if (myPolygon) + { aPolygon = myPolygon->Import(); + } occ::handle aTriangulation; if (myTriangulation) + { aTriangulation = myTriangulation->Import(); + } return new BRep_PolygonOnTriangulation(aPolygon, aTriangulation, myLocation.Import()); } @@ -461,15 +491,21 @@ occ::handle ShapePersistent_BRep::PolygonOnClosedTrian { occ::handle aPolygon; if (myPolygon) + { aPolygon = myPolygon->Import(); + } occ::handle aPolygon2; if (myPolygon2) + { aPolygon2 = myPolygon2->Import(); + } occ::handle aTriangulation; if (myTriangulation) + { aTriangulation = myTriangulation->Import(); + } return new BRep_PolygonOnClosedTriangulation(aPolygon, aPolygon2, @@ -504,11 +540,15 @@ occ::handle ShapePersistent_BRep::PolygonOnSurface::im { occ::handle aPolygon2D; if (myPolygon2D) + { aPolygon2D = myPolygon2D->Import(); + } occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } return new BRep_PolygonOnSurface(aPolygon2D, aSurface, myLocation.Import()); } @@ -539,15 +579,21 @@ occ::handle ShapePersistent_BRep::PolygonOnClosedSurfa { occ::handle aPolygon2D; if (myPolygon2D) + { aPolygon2D = myPolygon2D->Import(); + } occ::handle aPolygon2; if (myPolygon2) + { aPolygon2 = myPolygon2->Import(); + } occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } return new BRep_PolygonOnClosedSurface(aPolygon2D, aPolygon2, aSurface, myLocation.Import()); } @@ -580,11 +626,15 @@ occ::handle ShapePersistent_BRep::CurveOn2Surfaces::im { occ::handle aSurface; if (mySurface) + { aSurface = mySurface->Import(); + } occ::handle aSurface2; if (mySurface2) + { aSurface2 = mySurface2->Import(); + } GeomAbs_Shape aContinuity = static_cast(myContinuity); @@ -605,7 +655,9 @@ occ::handle ShapePersistent_BRep::pTVertex::createTShape() const aTVertex->Pnt(myPnt); if (myPoints) + { myPoints->Import(aTVertex->ChangePoints()); + } return aTVertex; } @@ -622,7 +674,9 @@ occ::handle ShapePersistent_BRep::pTEdge::createTShape() const aTEdge->Degenerated((myFlags & DegeneratedMask) != 0); if (myCurves) + { myCurves->Import(aTEdge->ChangeCurves()); + } return aTEdge; } @@ -638,10 +692,14 @@ occ::handle ShapePersistent_BRep::pTFace::createTShape() const aTFace->Location(myLocation.Import()); if (mySurface) + { aTFace->Surface(mySurface->Import()); + } if (myTriangulation) + { aTFace->Triangulation(myTriangulation->Import()); + } return aTFace; } @@ -707,11 +765,17 @@ Handle(ShapePersistent_BRep::TEdge::pTObjectT) ShapePersistent_BRep::Translate( PTE->myTolerance = TTE->Tolerance(); if (TTE->SameParameter()) + { PTE->myFlags |= ParameterMask; + } if (TTE->SameRange()) + { PTE->myFlags |= RangeMask; + } if (TTE->Degenerated()) + { PTE->myFlags |= DegeneratedMask; + } // Representations NCollection_List>::Iterator itcr(TTE->Curves()); diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom.cxx index e0bdd4b60c..d6f172991b 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom.cxx @@ -38,7 +38,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = occ::down_cast(theMap.Find(theCurve)); + } else { occ::handle aCT = theCurve->DynamicType(); @@ -104,7 +106,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = occ::down_cast(theMap.Find(theSurf)); + } else { occ::handle aST = theSurf->DynamicType(); diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d.cxx index 9c64231fb8..fa8afe9019 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d.cxx @@ -114,7 +114,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aCT = theCurve->DynamicType(); diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx index 7e8f02ca3a..edbd6aaf29 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx @@ -23,27 +23,37 @@ occ::handle ShapePersistent_Geom2d_Curve::pBezier::Import() const { if (myPoles.IsNull()) + { return nullptr; + } if (myRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom2d_BezierCurve(*myPoles->Array(), *myWeights->Array()); } else + { return new Geom2d_BezierCurve(*myPoles->Array()); + } } occ::handle ShapePersistent_Geom2d_Curve::pBSpline::Import() const { if (myPoles.IsNull() || myKnots.IsNull() || myMultiplicities.IsNull()) + { return nullptr; + } if (myRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom2d_BSplineCurve(*myPoles->Array(), *myWeights->Array(), @@ -53,17 +63,21 @@ occ::handle ShapePersistent_Geom2d_Curve::pBSpline::Import() const myPeriodic); } else + { return new Geom2d_BSplineCurve(*myPoles->Array(), *myKnots->Array(), *myMultiplicities->Array(), mySpineDegree, myPeriodic); + } } occ::handle ShapePersistent_Geom2d_Curve::pTrimmed::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom2d_TrimmedCurve(myBasisCurve->Import(), myFirstU, myLastU); } @@ -71,7 +85,9 @@ occ::handle ShapePersistent_Geom2d_Curve::pTrimmed::Import() const occ::handle ShapePersistent_Geom2d_Curve::pOffset::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom2d_OffsetCurve(myBasisCurve->Import(), myOffsetValue); } @@ -102,7 +118,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Line; @@ -150,7 +168,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Circle; @@ -188,7 +208,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Ellipse; @@ -226,7 +248,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Hyperbola; @@ -264,7 +288,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Parabola; @@ -286,7 +312,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPBC = new Bezier; @@ -318,7 +346,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPBSC = new BSpline; @@ -356,7 +386,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPTC = new Trimmed; @@ -382,7 +414,9 @@ Handle(ShapePersistent_Geom2d::Curve) ShapePersistent_Geom2d_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPOC = new Offset; diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Curve.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Curve.cxx index 65db81482a..fecc76a9b8 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Curve.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Curve.cxx @@ -24,27 +24,37 @@ occ::handle ShapePersistent_Geom_Curve::pBezier::Import() const { if (myPoles.IsNull()) + { return nullptr; + } if (myRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom_BezierCurve(*myPoles->Array(), *myWeights->Array()); } else + { return new Geom_BezierCurve(*myPoles->Array()); + } } occ::handle ShapePersistent_Geom_Curve::pBSpline::Import() const { if (myPoles.IsNull() || myKnots.IsNull() || myMultiplicities.IsNull()) + { return nullptr; + } if (myRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom_BSplineCurve(*myPoles->Array(), *myWeights->Array(), @@ -54,17 +64,21 @@ occ::handle ShapePersistent_Geom_Curve::pBSpline::Import() const myPeriodic); } else + { return new Geom_BSplineCurve(*myPoles->Array(), *myKnots->Array(), *myMultiplicities->Array(), mySpineDegree, myPeriodic); + } } occ::handle ShapePersistent_Geom_Curve::pTrimmed::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom_TrimmedCurve(myBasisCurve->Import(), myFirstU, myLastU); } @@ -72,7 +86,9 @@ occ::handle ShapePersistent_Geom_Curve::pTrimmed::Import() const occ::handle ShapePersistent_Geom_Curve::pOffset::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom_OffsetCurve(myBasisCurve->Import(), myOffsetValue, myOffsetDirection); } @@ -103,7 +119,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Line; @@ -149,7 +167,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Circle; @@ -186,7 +206,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Ellipse; @@ -223,7 +245,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Hyperbola; @@ -260,7 +284,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPT = new Parabola; @@ -282,7 +308,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPBC = new Bezier; @@ -314,7 +342,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPBSC = new BSpline; @@ -352,7 +382,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPTC = new Trimmed; @@ -378,7 +410,9 @@ Handle(ShapePersistent_Geom::Curve) ShapePersistent_Geom_Curve::Translate( if (!theCurve.IsNull()) { if (theMap.IsBound(theCurve)) + { aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve)); + } else { occ::handle aPOC = new Offset; diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Surface.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Surface.cxx index 4a26be93f2..7950791e07 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Surface.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Geom_Surface.cxx @@ -27,7 +27,9 @@ occ::handle ShapePersistent_Geom_Surface::pLinearExtrusion::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom_SurfaceOfLinearExtrusion(myBasisCurve->Import(), myDirection); } @@ -35,7 +37,9 @@ occ::handle ShapePersistent_Geom_Surface::pLinearExtrusion::Import occ::handle ShapePersistent_Geom_Surface::pRevolution::Import() const { if (myBasisCurve.IsNull()) + { return nullptr; + } return new Geom_SurfaceOfRevolution(myBasisCurve->Import(), gp_Ax1(myLocation, myDirection)); } @@ -43,28 +47,38 @@ occ::handle ShapePersistent_Geom_Surface::pRevolution::Import() co occ::handle ShapePersistent_Geom_Surface::pBezier::Import() const { if (myPoles.IsNull()) + { return nullptr; + } if (myURational || myVRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom_BezierSurface(*myPoles->Array(), *myWeights->Array()); } else + { return new Geom_BezierSurface(*myPoles->Array()); + } } occ::handle ShapePersistent_Geom_Surface::pBSpline::Import() const { if (myPoles.IsNull() || myUKnots.IsNull() || myVKnots.IsNull() || myUMultiplicities.IsNull() || myVMultiplicities.IsNull()) + { return nullptr; + } if (myURational || myVRational) { if (myWeights.IsNull()) + { return nullptr; + } return new Geom_BSplineSurface(*myPoles->Array(), *myWeights->Array(), @@ -78,6 +92,7 @@ occ::handle ShapePersistent_Geom_Surface::pBSpline::Import() const myVPeriodic); } else + { return new Geom_BSplineSurface(*myPoles->Array(), *myUKnots->Array(), *myVKnots->Array(), @@ -87,12 +102,15 @@ occ::handle ShapePersistent_Geom_Surface::pBSpline::Import() const myVSpineDegree, myUPeriodic, myVPeriodic); + } } occ::handle ShapePersistent_Geom_Surface::pRectangularTrimmed::Import() const { if (myBasisSurface.IsNull()) + { return nullptr; + } return new Geom_RectangularTrimmedSurface(myBasisSurface->Import(), myFirstU, @@ -104,7 +122,9 @@ occ::handle ShapePersistent_Geom_Surface::pRectangularTrimmed::Imp occ::handle ShapePersistent_Geom_Surface::pOffset::Import() const { if (myBasisSurface.IsNull()) + { return nullptr; + } return new Geom_OffsetSurface(myBasisSurface->Import(), myOffsetValue); } @@ -148,7 +168,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPP = new Plane; @@ -189,7 +211,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPCon = new Conical; @@ -231,7 +255,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPCyl = new Cylindrical; @@ -272,7 +298,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPSph = new Spherical; @@ -313,7 +341,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPTor = new Toroidal; @@ -335,7 +365,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPLE = new LinearExtrusion; @@ -360,7 +392,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPR = new Revolution; @@ -386,7 +420,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPB = new Bezier; @@ -419,7 +455,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPBS = new BSpline; @@ -465,7 +503,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPRT = new RectangularTrimmed; @@ -490,7 +530,9 @@ Handle(ShapePersistent_Geom::Surface) ShapePersistent_Geom_Surface::Translate( if (!theSurf.IsNull()) { if (theMap.IsBound(theSurf)) + { aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf)); + } else { occ::handle aPO = new Offset; diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_HSequence.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_HSequence.cxx index 14643365aa..e16a3d60ee 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_HSequence.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_HSequence.cxx @@ -45,7 +45,9 @@ occ::handle ShapePersistent_HSequence::instance::I occ::handle aSequence = new SequenceClass; for (occ::handle aNode = myFirst; aNode; aNode = aNode->Next()) + { aSequence->Append(aNode->Item()); + } return aSequence; } diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Poly.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Poly.cxx index 29c102fcd0..64644ad821 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Poly.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_Poly.cxx @@ -28,7 +28,9 @@ void ShapePersistent_Poly::pPolygon2D::PChildren( occ::handle ShapePersistent_Poly::pPolygon2D::Import() const { if (myNodes.IsNull()) + { return nullptr; + } occ::handle aPolygon = new Poly_Polygon2D(*myNodes->Array()); aPolygon->Deflection(myDeflection); @@ -45,7 +47,9 @@ void ShapePersistent_Poly::pPolygon3D::PChildren( occ::handle ShapePersistent_Poly::pPolygon3D::Import() const { if (myNodes.IsNull() || myParameters.IsNull()) + { return nullptr; + } occ::handle aPolygon = new Poly_Polygon3D(*myNodes->Array(), *myParameters->Array()); @@ -68,9 +72,13 @@ occ::handle ShapePersistent_Poly::pPolygonOnTriangu if (myNodes) { if (myParameters) + { aPolygon = new Poly_PolygonOnTriangulation(*myNodes->Array(), *myParameters->Array()); + } else + { aPolygon = new Poly_PolygonOnTriangulation(*myNodes->Array()); + } aPolygon->Deflection(myDeflection); } @@ -94,10 +102,14 @@ occ::handle ShapePersistent_Poly::pTriangulation::Import() c if (myNodes && myTriangles) { if (myUVNodes) + { aTriangulation = new Poly_Triangulation(*myNodes->Array(), *myUVNodes->Array(), *myTriangles->Array()); + } else + { aTriangulation = new Poly_Triangulation(*myNodes->Array(), *myTriangles->Array()); + } aTriangulation->Deflection(myDeflection); } @@ -113,7 +125,9 @@ Handle(ShapePersistent_Poly::Polygon2D) ShapePersistent_Poly::Translate( if (!thePoly.IsNull()) { if (theMap.IsBound(thePoly)) + { aPP = occ::down_cast(theMap.Find(thePoly)); + } else { aPP = new Polygon2D; @@ -136,7 +150,9 @@ Handle(ShapePersistent_Poly::Polygon3D) ShapePersistent_Poly::Translate( if (!thePoly.IsNull()) { if (theMap.IsBound(thePoly)) + { aPP = occ::down_cast(theMap.Find(thePoly)); + } else { aPP = new Polygon3D; @@ -164,7 +180,9 @@ Handle(ShapePersistent_Poly::PolygonOnTriangulation) ShapePersistent_Poly::Trans if (!thePolyOnTriang.IsNull()) { if (theMap.IsBound(thePolyOnTriang)) + { aPPonT = occ::down_cast(theMap.Find(thePolyOnTriang)); + } else { aPPonT = new PolygonOnTriangulation; @@ -192,7 +210,9 @@ Handle(ShapePersistent_Poly::Triangulation) ShapePersistent_Poly::Translate( if (!thePolyTriang.IsNull()) { if (theMap.IsBound(thePolyTriang)) + { aPT = occ::down_cast(theMap.Find(thePolyTriang)); + } else { aPT = new Triangulation; diff --git a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_TopoDS.cxx b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_TopoDS.cxx index a55d909b4c..af1e19c2ba 100644 --- a/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_TopoDS.cxx +++ b/src/ApplicationFramework/TKStd/ShapePersistent/ShapePersistent_TopoDS.cxx @@ -69,7 +69,9 @@ static inline void AddShape(TopoDS_Shape& theParent, Handle(ShapePersistent_TopoDS::HShape)::DownCast(theRef); if (aShape) + { BRep_Builder().Add(theParent, aShape->Import()); + } } static inline void AddShape(TopoDS_Shape& theParent, const StdObject_Shape& theShape) @@ -85,7 +87,9 @@ void ShapePersistent_TopoDS::pTBase::addShapesT(TopoDS_Shape& theParent) const { typename ShapesArray::Iterator anIter(*aShapes->Array()); for (; anIter.More(); anIter.Next()) + { AddShape(theParent, anIter.Value()); + } } } @@ -117,7 +121,9 @@ Handle(ShapePersistent_TopoDS::HShape) ShapePersistent_TopoDS::Translate( occ::handle pHShape; if (theShape.IsNull()) + { return pHShape; + } pHShape = new HShape; @@ -204,17 +210,29 @@ Handle(ShapePersistent_TopoDS::HShape) ShapePersistent_TopoDS::Translate( // Shape flags int aFlags = 0; if (theShape.Modified()) + { aFlags |= ModifiedMask; + } if (theShape.Checked()) + { aFlags |= CheckedMask; + } if (theShape.Orientable()) + { aFlags |= OrientableMask; + } if (theShape.Closed()) + { aFlags |= ClosedMask; + } if (theShape.Infinite()) + { aFlags |= InfiniteMask; + } if (theShape.Convex()) + { aFlags |= ConvexMask; + } aPTShape->myFlags = aFlags; // Copy current Shape diff --git a/src/ApplicationFramework/TKStd/StdObject/StdObject_Location.cxx b/src/ApplicationFramework/TKStd/StdObject/StdObject_Location.cxx index 94b093c953..b9029578af 100644 --- a/src/ApplicationFramework/TKStd/StdObject/StdObject_Location.cxx +++ b/src/ApplicationFramework/TKStd/StdObject/StdObject_Location.cxx @@ -22,7 +22,9 @@ StdObject_Location StdObject_Location::Translate( { StdObject_Location aLoc; if (!theLoc.IsIdentity()) + { aLoc.myData = StdPersistent_TopLoc::Translate(theLoc, theMap); + } return aLoc; } diff --git a/src/ApplicationFramework/TKStd/StdObject/StdObject_Shape.cxx b/src/ApplicationFramework/TKStd/StdObject/StdObject_Shape.cxx index ad09fc3b12..3a1e15d74d 100644 --- a/src/ApplicationFramework/TKStd/StdObject/StdObject_Shape.cxx +++ b/src/ApplicationFramework/TKStd/StdObject/StdObject_Shape.cxx @@ -20,7 +20,9 @@ TopoDS_Shape StdObject_Shape::Import() const TopoDS_Shape aShape; if (myTShape) + { aShape.TShape(myTShape->Import()); + } aShape.Location(myLocation.Import()); aShape.Orientation(static_cast(myOrient)); diff --git a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_Naming.cxx b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_Naming.cxx index 2b09684d35..785f0b5ff7 100644 --- a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_Naming.cxx +++ b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_Naming.cxx @@ -26,7 +26,9 @@ void StdPersistent_Naming::NamedShape::Import( theAttribute->SetVersion(myVersion); if (myOldShapes.IsNull() || myNewShapes.IsNull()) + { return; + } TNaming_Builder aBuilder(theAttribute->Label()); @@ -128,7 +130,9 @@ void StdPersistent_Naming::Name_1::Import(TNaming_Name& theName, { Name::Import(theName, theDF); if (myContextLabel) + { theName.ContextLabel(myContextLabel->Label(theDF)); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_PPrsStd.cxx b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_PPrsStd.cxx index 21a09f62d5..5be0c7e8bc 100644 --- a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_PPrsStd.cxx +++ b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_PPrsStd.cxx @@ -22,27 +22,45 @@ void StdPersistent_PPrsStd::AISPresentation::Import( occ::handle aDriverGUID = myDriverGUID->ExtString(); if (aDriverGUID) + { theAttribute->SetDriverGUID(Standard_GUID(aDriverGUID->String().ToExtString())); + } if (myColor != -1) + { theAttribute->SetColor(static_cast((int)myColor)); + } else + { theAttribute->UnsetColor(); + } if (myMaterial != -1) + { theAttribute->SetMaterialIndex(myMaterial); + } else + { theAttribute->UnsetMaterial(); + } if (myTransparency != -1.) + { theAttribute->SetTransparency(myTransparency); + } else + { theAttribute->UnsetTransparency(); + } if (myWidth != -1.) + { theAttribute->SetWidth(myWidth); + } else + { theAttribute->UnsetWidth(); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_TopLoc.cxx b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_TopLoc.cxx index d9a929e3f3..793e3d33b3 100644 --- a/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_TopLoc.cxx +++ b/src/ApplicationFramework/TKStd/StdPersistent/StdPersistent_TopLoc.cxx @@ -59,9 +59,13 @@ TopLoc_Location StdPersistent_TopLoc::ItemLocation::Import() const { TopLoc_Location aNext = myNext.Import(); if (myDatum) + { return aNext * TopLoc_Location(myDatum->Import()).Powered(myPower); + } else + { return aNext; + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKStd/StdStorage/StdStorage.cxx b/src/ApplicationFramework/TKStd/StdStorage/StdStorage.cxx index 3a21267d9b..96c7155045 100644 --- a/src/ApplicationFramework/TKStd/StdStorage/StdStorage.cxx +++ b/src/ApplicationFramework/TKStd/StdStorage/StdStorage.cxx @@ -56,7 +56,9 @@ Storage_Error StdStorage::Read(const TCollection_AsciiString& theFileName, // Create a driver appropriate for the given file occ::handle aDriver; if (PCDM::FileDriverType(theFileName, aDriver) == PCDM_TOFD_Unknown) + { return Storage_VSWrongFileDriver; + } // Try to open the file try @@ -80,9 +82,13 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, occ::handle& theData) { if (theData.IsNull()) + { theData = new StdStorage_Data; + } else + { theData->Clear(); + } occ::handle aHeaderData = theData->HeaderData(); occ::handle aTypeData = theData->TypeData(); @@ -90,11 +96,15 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, // Read header section if (!aHeaderData->Read(theDriver)) + { return aHeaderData->ErrorStatus(); + } // Read types section if (!aTypeData->Read(theDriver)) + { return aTypeData->ErrorStatus(); + } // Select instantiators for the used types NCollection_Array1 anInstantiators( @@ -104,14 +114,20 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, { StdObjMgt_Persistent::Instantiator anInstantiator = aTypeData->Instantiator(i); if (anInstantiator) + { anInstantiators(i) = anInstantiator; + } else + { return Storage_VSUnknownType; + } } // Read root section if (!aRootData->Read(theDriver)) + { return aRootData->ErrorStatus(); + } Storage_Error anError; @@ -120,7 +136,9 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, anError = theDriver->BeginReadRefSection(); if (anError != Storage_VSOk) + { return anError; + } int aNbRefs = theDriver->RefSectionSize(); for (int i = 1; i <= aNbRefs; i++) @@ -138,19 +156,25 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, } if (anError != Storage_VSOk) + { return anError; + } aReadData.CreatePersistentObject(aRef, anInstantiators(aType)); } anError = theDriver->EndReadRefSection(); if (anError != Storage_VSOk) + { return anError; + } // Read and parse data section anError = theDriver->BeginReadDataSection(); if (anError != Storage_VSOk) + { return anError; + } for (int i = 1; i <= aHeaderData->NumberOfObjects(); i++) { @@ -174,12 +198,16 @@ Storage_Error StdStorage::Read(const occ::handle& theDriver, } if (anError != Storage_VSOk) + { return anError; + } } anError = theDriver->EndReadDataSection(); if (anError != Storage_VSOk) + { return anError; + } occ::handle>> aRoots = aRootData->Roots(); if (!aRoots.IsNull()) @@ -277,51 +305,69 @@ Storage_Error StdStorage::Write(const occ::handle& theDriver { // Write header section if (!aHeaderData->Write(theDriver)) + { return aHeaderData->ErrorStatus(); + } // Write types section if (!aTypeData->Write(theDriver)) + { return aTypeData->ErrorStatus(); + } // Write root section if (!aRootData->Write(theDriver)) + { return aRootData->ErrorStatus(); + } Storage_Error anError; // Write reference section anError = theDriver->BeginWriteRefSection(); if (anError != Storage_VSOk) + { return anError; + } theDriver->SetRefSectionSize(aPObjs.Length()); for (StdStorage_BucketIterator anIt(&aPObjs); anIt.More(); anIt.Next()) { occ::handle aPObj = anIt.Value(); if (!aPObj.IsNull()) + { theDriver->WriteReferenceType(aPObj->RefNum(), aPObj->TypeNum()); + } } anError = theDriver->EndWriteRefSection(); if (anError != Storage_VSOk) + { return anError; + } // Write data section anError = theDriver->BeginWriteDataSection(); if (anError != Storage_VSOk) + { return anError; + } StdObjMgt_WriteData aWriteData(theDriver); for (StdStorage_BucketIterator anIt(&aPObjs); anIt.More(); anIt.Next()) { occ::handle aPObj = anIt.Value(); if (!aPObj.IsNull()) + { aWriteData.WritePersistentObject(aPObj); + } } anError = theDriver->EndWriteDataSection(); if (anError != Storage_VSOk) + { return anError; + } } catch (Storage_StreamWriteError const&) { diff --git a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_BacketOfPersistent.cxx b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_BacketOfPersistent.cxx index 2915ee6da6..d8344d94e7 100644 --- a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_BacketOfPersistent.cxx +++ b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_BacketOfPersistent.cxx @@ -68,7 +68,9 @@ void StdStorage_BucketOfPersistent::Clear() int i; for (i = 1; i < myNumberOfBucket; i++) + { delete myBuckets[i]; + } myNumberOfBucket = 1; myCurrentBucket = myBuckets[0]; myCurrentBucket->Clear(); @@ -141,7 +143,9 @@ StdStorage_BucketIterator::StdStorage_BucketIterator(StdStorage_BucketOfPersiste myMoreObject = true; } else + { myMoreObject = false; + } } //================================================================================================= @@ -157,7 +161,9 @@ void StdStorage_BucketIterator::Reset() myMoreObject = true; } else + { myMoreObject = false; + } } //================================================================================================= @@ -174,7 +180,9 @@ void StdStorage_BucketIterator::Init(StdStorage_BucketOfPersistent* aBucketManag myMoreObject = true; } else + { myMoreObject = false; + } } //================================================================================================= @@ -182,7 +190,9 @@ void StdStorage_BucketIterator::Init(StdStorage_BucketOfPersistent* aBucketManag void StdStorage_BucketIterator::Next() { if (!myMoreObject) + { return; + } if (myCurrentIndex < myCurrentBucket->myCurrentSpace) { diff --git a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_RootData.cxx b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_RootData.cxx index 86b9d92907..6309f593eb 100644 --- a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_RootData.cxx +++ b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_RootData.cxx @@ -177,7 +177,9 @@ void StdStorage_RootData::RemoveRoot(const TCollection_AsciiString& aName) anIt(myObjects); anIt.More(); anIt.Next(), ++aRef) + { anIt.ChangeValue()->myRef = aRef; + } } } @@ -187,7 +189,9 @@ void StdStorage_RootData::Clear() anIt(myObjects); anIt.More(); anIt.Next()) + { anIt.ChangeValue()->myRef = 0; + } myObjects.Clear(); } diff --git a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_TypeData.cxx b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_TypeData.cxx index b7828c28a2..f8c435e65b 100644 --- a/src/ApplicationFramework/TKStd/StdStorage/StdStorage_TypeData.cxx +++ b/src/ApplicationFramework/TKStd/StdStorage/StdStorage_TypeData.cxx @@ -155,7 +155,9 @@ int StdStorage_TypeData::AddType(const occ::handle& aPObj) { TCollection_AsciiString aTypeName = aPObj->PName(); if (IsType(aTypeName)) + { return Type(aTypeName); + } if (!myMapOfPInst.IsBound(aTypeName)) { @@ -175,7 +177,9 @@ TCollection_AsciiString StdStorage_TypeData::Type(const int aTypeNum) const TCollection_AsciiString r; if (aTypeNum <= myPt.Extent() && aTypeNum > 0) + { r = myPt.FindKey(aTypeNum); + } else { Standard_SStream aSS; @@ -191,7 +195,9 @@ int StdStorage_TypeData::Type(const TCollection_AsciiString& aTypeName) const int r = 0; if (myPt.Contains(aTypeName)) + { r = myPt.FindFromKey(aTypeName); + } else { Standard_SStream aSS; @@ -207,7 +213,9 @@ StdObjMgt_Persistent::Instantiator StdStorage_TypeData::Instantiator(const int a TCollection_AsciiString aTypeName = Type(aTypeNum); StdObjMgt_Persistent::Instantiator anInstantiator = nullptr; if (!myMapOfPInst.Find(aTypeName, anInstantiator)) + { return nullptr; + } return anInstantiator; } diff --git a/src/ApplicationFramework/TKStdL/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx b/src/ApplicationFramework/TKStdL/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx index dc95596bd6..bd12953420 100644 --- a/src/ApplicationFramework/TKStdL/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx +++ b/src/ApplicationFramework/TKStdL/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx @@ -50,7 +50,9 @@ void StdLDrivers_DocumentRetrievalDriver::Read(const TCollection_ExtendedString& Storage_HeaderData aHeaderData; occ::handle aPDocument = read(theFileName, aHeaderData); if (aPDocument.IsNull()) + { return; + } // Import transient document from the persistent one aPDocument->ImportDocument(occ::down_cast(theNewDocument)); @@ -89,30 +91,36 @@ occ::handle StdLDrivers_DocumentRetrievalDriver::read( myReaderStatus = PCDM_RS_OpenError; Standard_SStream aMsg; - aMsg << anException << std::endl; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } // Read header section if (!theHeaderData.Read(aFileDriver)) + { raiseOnStorageError(theHeaderData.ErrorStatus()); + } // Read type section Storage_TypeData aTypeData; if (!aTypeData.Read(aFileDriver)) + { raiseOnStorageError(aTypeData.ErrorStatus()); + } // Read root section Storage_RootData aRootData; if (!aRootData.Read(aFileDriver)) + { raiseOnStorageError(aRootData.ErrorStatus()); + } if (aRootData.NumberOfRoots() < 1) { myReaderStatus = PCDM_RS_NoDocument; Standard_SStream aMsg; - aMsg << "could not find any document in this file" << std::endl; + aMsg << "could not find any document in this file" << '\n'; throw Standard_Failure(aMsg.str().c_str()); } @@ -145,9 +153,13 @@ occ::handle StdLDrivers_DocumentRetrievalDriver::read( } StdObjMgt_Persistent::Instantiator anInstantiator; if (aMapOfInst.Find(aCurTypeName, anInstantiator)) + { anInstantiators(aCurTypeNum) = anInstantiator; + } else + { anUnknownTypes.Append(aCurTypeName); + } } if (!anUnknownTypes.IsEmpty()) @@ -161,9 +173,13 @@ occ::handle StdLDrivers_DocumentRetrievalDriver::read( { aMsg << anUnknownTypes(i); if (i < anUnknownTypes.Length()) + { aMsg << ","; + } else - aMsg << std::endl; + { + aMsg << '\n'; + } } throw Standard_Failure(aMsg.str().c_str()); @@ -264,37 +280,37 @@ void StdLDrivers_DocumentRetrievalDriver::raiseOnStorageError(Storage_Error theE case Storage_VSNotOpen: case Storage_VSAlreadyOpen: myReaderStatus = PCDM_RS_OpenError; - aMsg << "Stream Open Error" << std::endl; + aMsg << "Stream Open Error" << '\n'; throw Standard_Failure(aMsg.str().c_str()); case Storage_VSModeError: myReaderStatus = PCDM_RS_WrongStreamMode; - aMsg << "Stream is opened with a wrong mode for operation" << std::endl; + aMsg << "Stream is opened with a wrong mode for operation" << '\n'; throw Standard_Failure(aMsg.str().c_str()); case Storage_VSSectionNotFound: myReaderStatus = PCDM_RS_FormatFailure; - aMsg << "Section is not found" << std::endl; + aMsg << "Section is not found" << '\n'; throw Standard_Failure(aMsg.str().c_str()); case Storage_VSFormatError: myReaderStatus = PCDM_RS_FormatFailure; - aMsg << "Wrong format error" << std::endl; + aMsg << "Wrong format error" << '\n'; throw Standard_Failure(aMsg.str().c_str()); case Storage_VSUnknownType: myReaderStatus = PCDM_RS_TypeFailure; - aMsg << "Try to read an unknown type" << std::endl; + aMsg << "Try to read an unknown type" << '\n'; throw Standard_Failure(aMsg.str().c_str()); case Storage_VSTypeMismatch: myReaderStatus = PCDM_RS_TypeFailure; - aMsg << "Try to read a wrong primitive type" << std::endl; + aMsg << "Try to read a wrong primitive type" << '\n'; throw Standard_Failure(aMsg.str().c_str()); default: myReaderStatus = PCDM_RS_DriverFailure; - aMsg << "Retrieval Driver Failure" << std::endl; + aMsg << "Retrieval Driver Failure" << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Collection.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Collection.cxx index 70d0431f9d..064431dc18 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Collection.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Collection.cxx @@ -49,7 +49,9 @@ struct StdLPersistent_Collection::stringConverter const occ::handle& theValue) const { if (theValue.IsNull()) + { return TCollection_ExtendedString::EmptyString(); + } occ::handle aString = theValue->ExtString(); return aString ? aString->String() : TCollection_ExtendedString::EmptyString(); @@ -81,7 +83,9 @@ void StdLPersistent_Collection::booleanArrayBase::import(const ArrayHandle new NCollection_HArray1(theArray->Lower(), theArray->Upper()); for (int i = theArray->Lower(); i <= theArray->Upper(); i++) + { aByteArray->SetValue(i, theConverter(theArray->Value(i))); + } this->myTransient->Init(myLower, myUpper); this->myTransient->SetInternalArray(aByteArray); @@ -102,7 +106,9 @@ void StdLPersistent_Collection::arrayBase::import(const ArrayHandle& theAr { this->myTransient->Init(theArray->Lower(), theArray->Upper()); for (int i = theArray->Lower(); i <= theArray->Upper(); i++) + { this->myTransient->SetValue(i, theConverter(theArray->Value(i))); + } } template @@ -111,7 +117,9 @@ void StdLPersistent_Collection::listBase::import(const ArrayHandle& theArr Converter theConverter) const { for (int i = theArray->Lower(); i <= theArray->Upper(); i++) + { this->myTransient->Append(theConverter(theArray->Value(i))); + } } template @@ -121,7 +129,9 @@ void StdLPersistent_Collection::mapBase::import(const ArrayHandle& theArra { occ::handle anHMap = new TColStd_HPackedMapOfInteger; for (int i = theArray->Lower(); i <= theArray->Upper(); i++) + { anHMap->ChangeMap().Add(theConverter(theArray->Value(i))); + } this->myTransient->ChangeMap(anHMap); } @@ -138,7 +148,9 @@ void StdLPersistent_Collection::instanceArray(); if (anArray) + { this->import(anArray, Converter(this->myTransient->Label().Data())); + } this->myData.Nullify(); } } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Data.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Data.cxx index 6e6b2950c8..3e537427ff 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Data.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Data.cxx @@ -101,7 +101,9 @@ void StdLPersistent_Data::Write(StdObjMgt_WriteData& theWriteData) const occ::handle StdLPersistent_Data::Import() const { if (myLabels.IsNull() || myAttributes.IsNull()) + { return nullptr; + } // Create tree of labels and add empty transient attributes to them occ::handle aData = new TDF_Data; @@ -114,7 +116,9 @@ occ::handle StdLPersistent_Data::Import() const { occ::handle& aPAttrib = anAttribIter.ChangeValue(); if (aPAttrib) + { aPAttrib->ImportAttribute(); + } } return aData; diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Dependency.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Dependency.cxx index c24218fbc3..7945d3d199 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Dependency.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Dependency.cxx @@ -34,7 +34,9 @@ void StdLPersistent_Dependency::instance::Import( const occ::handle& theAttribute) const { if (myName) + { ImportName(theAttribute, myName->Value()->String()); + } if (myVariables) { @@ -43,7 +45,9 @@ void StdLPersistent_Dependency::instance::Import( { const occ::handle& aPersistent = anIter.Value(); if (aPersistent) + { theAttribute->GetVariables().Append(aPersistent->GetAttribute()); + } } } } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Document.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Document.cxx index 97dec7d21b..b8e7ba367a 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Document.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Document.cxx @@ -52,11 +52,15 @@ void StdLPersistent_Document::PChildren( void StdLPersistent_Document::ImportDocument(const occ::handle& theDocument) const { if (theDocument.IsNull() || myData.IsNull()) + { return; + } occ::handle aData = myData->Import(); if (aData.IsNull()) + { return; + } theDocument->SetData(aData); TDocStd_Owner::SetDocument(aData, theDocument); diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray1.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray1.cxx index 469e60bf6d..447d7fb199 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray1.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray1.cxx @@ -29,7 +29,9 @@ void StdLPersistent_HArray1::base::Read(StdObjMgt_ReadData& theReadData) theReadData >> aSize; for (int i = aLowerBound; i <= anUpperBound; i++) + { readValue(theReadData, i); + } } //======================================================================= @@ -47,5 +49,7 @@ void StdLPersistent_HArray1::base::Write(StdObjMgt_WriteData& theWriteData) cons theWriteData << aSize; for (int i = aLowerBound; i <= anUpperBound; i++) + { writeValue(theWriteData, i); + } } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray2.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray2.cxx index 80593f7fa4..156b0646a3 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray2.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HArray2.cxx @@ -29,8 +29,12 @@ void StdLPersistent_HArray2::base::Read(StdObjMgt_ReadData& theReadData) theReadData >> aSize; for (int aRow = aLowerRow; aRow <= anUpperRow; aRow++) + { for (int aCol = aLowerCol; aCol <= anUpperCol; aCol++) + { readValue(theReadData, aRow, aCol); + } + } } //======================================================================= @@ -50,6 +54,10 @@ void StdLPersistent_HArray2::base::Write(StdObjMgt_WriteData& theWriteData) cons theWriteData << aSize; for (int aRow = aLowerRow; aRow <= anUpperRow; aRow++) + { for (int aCol = aLowerCol; aCol <= anUpperCol; aCol++) + { writeValue(theWriteData, aRow, aCol); + } + } } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HString.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HString.cxx index 5192cb04c3..90db7ea3e1 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HString.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_HString.cxx @@ -69,7 +69,9 @@ TDF_Label StdLPersistent_HString::instance::Label( TDF_Label aLabel; if (!myValue.IsNull()) + { TDF_Tool::Label(theDF, myValue->String(), aLabel, true); + } return aLabel; } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_NamedData.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_NamedData.cxx index cae73c3f21..0bac781d45 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_NamedData.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_NamedData.cxx @@ -22,7 +22,9 @@ static const TCollection_ExtendedString& String(const occ::handle& theValue) { if (theValue) + { return theValue->ExtString()->String(); + } return TCollection_ExtendedString::EmptyString(); } @@ -41,13 +43,17 @@ static typename HArray::ArrayHandle Array(const occ::handle& theAttribute) const { if (myDimensions.IsNull()) + { return; + } if (myInts) { NCollection_DataMap aMap; for (int i = lower(0); i <= upper(0); i++) + { aMap.Bind(myInts.Key(i), myInts.Value(i)); + } theAttribute->ChangeIntegers(aMap); } @@ -56,7 +62,9 @@ void StdLPersistent_NamedData::Import(const occ::handle& the { NCollection_DataMap aMap; for (int i = lower(1); i <= upper(1); i++) + { aMap.Bind(myReals.Key(i), myReals.Value(i)); + } theAttribute->ChangeReals(aMap); } @@ -65,7 +73,9 @@ void StdLPersistent_NamedData::Import(const occ::handle& the { NCollection_DataMap aMap; for (int i = lower(2); i <= upper(2); i++) + { aMap.Bind(myStrings.Key(i), String(myStrings.Value(i))); + } theAttribute->ChangeStrings(aMap); } @@ -74,7 +84,9 @@ void StdLPersistent_NamedData::Import(const occ::handle& the { NCollection_DataMap aMap; for (int i = lower(3); i <= upper(3); i++) + { aMap.Bind(myBytes.Key(i), myBytes.Value(i)); + } theAttribute->ChangeBytes(aMap); } @@ -83,7 +95,9 @@ void StdLPersistent_NamedData::Import(const occ::handle& the { NCollection_DataMap>> aMap; for (int i = lower(4); i <= upper(4); i++) + { aMap.Bind(myIntArrays.Key(i), Array(myIntArrays.Value(i))); + } theAttribute->ChangeArraysOfIntegers(aMap); } @@ -92,7 +106,9 @@ void StdLPersistent_NamedData::Import(const occ::handle& the { NCollection_DataMap>> aMap; for (int i = lower(5); i <= upper(5); i++) + { aMap.Bind(myRealArrays.Key(i), Array(myRealArrays.Value(i))); + } theAttribute->ChangeArraysOfReals(aMap); } diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_TreeNode.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_TreeNode.cxx index 492a74939d..8ac14ac5ec 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_TreeNode.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_TreeNode.cxx @@ -39,7 +39,9 @@ void StdLPersistent_TreeNode::PChildren( { theChildren.Append(myNext); if (!myDynamicData.IsNull()) + { theChildren.Append(myDynamicData->First); + } } //======================================================================= @@ -65,7 +67,9 @@ void StdLPersistent_TreeNode::ImportAttribute() while (aChild) { if (aChild->myTransient) + { myTransient->Append(aChild->myTransient); + } StdLPersistent_TreeNode* aCurr = aChild.get(); aChild = aChild->myNext; aCurr->myNext.Nullify(); // this reference is no longer needed diff --git a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Value.cxx b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Value.cxx index 58dbfe5f9b..82de2d7fa0 100644 --- a/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Value.cxx +++ b/src/ApplicationFramework/TKStdL/StdLPersistent/StdLPersistent_Value.cxx @@ -52,7 +52,9 @@ void StdLPersistent_Value::string::ImportAttribute() { TDF_Label aLabel = myData->Label(this->myTransient->Label().Data()); if (!aLabel.IsNull()) + { this->myTransient->Set(aLabel); + } this->myData.Nullify(); } } @@ -78,7 +80,9 @@ occ::handle StdLPersistent_Value::UAttribute::CreateAttribute() { occ::handle aString = this->myData->ExtString(); if (aString) + { this->myTransient->SetID(Standard_GUID(aString->String().ToExtString())); + } this->myData.Nullify(); } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Application.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Application.cxx index d8ff59194a..5ae3c7cdb7 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Application.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Application.cxx @@ -72,7 +72,9 @@ bool TObj_Application::SaveDocument(const occ::handle& theSour const PCDM_StoreStatus aStatus = SaveAs(theSourceDoc, theTargetFile); myIsError = (aStatus != PCDM_SS_OK); if (myIsError) + { SetError(aStatus, theTargetFile); + } // Release free memory Standard::Purge(); @@ -90,7 +92,9 @@ bool TObj_Application::SaveDocument(const occ::handle& theSour const PCDM_StoreStatus aStatus = SaveAs(theSourceDoc, theOStream); myIsError = (aStatus != PCDM_SS_OK); if (myIsError) + { SetError(aStatus, ""); + } // Release free memory Standard::Purge(); @@ -118,7 +122,9 @@ bool TObj_Application::LoadDocument(const TCollection_ExtendedString& theSourceF } myIsError = (aStatus != PCDM_RS_OK); if (myIsError) + { SetError(aStatus, theSourceFile); + } // Release free memory Standard::Purge(); @@ -149,7 +155,9 @@ bool TObj_Application::LoadDocument(Standard_IStream& theIStream, } myIsError = (aStatus != PCDM_RS_OK); if (myIsError) + { SetError(aStatus, ""); + } // Release free memory Standard::Purge(); diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Assistant.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Assistant.cxx index f7f9df7715..85f0cd67c9 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Assistant.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Assistant.cxx @@ -67,10 +67,14 @@ occ::handle TObj_Assistant::FindModel(const char* const theName) { aModel = occ::down_cast(getModels().Value(i)); if (aName == aModel->GetModelName()->String()) + { break; + } } if (i == 0) + { aModel.Nullify(); + } return aModel; } @@ -94,7 +98,9 @@ void TObj_Assistant::ClearModelMap() occ::handle TObj_Assistant::FindType(const int theTypeIndex) { if (theTypeIndex > 0 && theTypeIndex <= getTypes().Extent()) + { return occ::down_cast(getTypes().FindKey(theTypeIndex)); + } return nullptr; } @@ -104,7 +110,9 @@ occ::handle TObj_Assistant::FindType(const int theTypeIndex) int TObj_Assistant::FindTypeIndex(const occ::handle& theType) { if (!getTypes().Contains(theType)) + { return 0; + } return getTypes().FindIndex(theType); } @@ -174,7 +182,9 @@ int TObj_Assistant::GetAppVersion() { occ::handle& aModel = getCurrentModel(); if (!aModel.IsNull()) + { aVersion = aModel->GetFormatVersion(); + } } return aVersion; } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_CheckModel.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_CheckModel.cxx index ffc5276048..a0c0d882e1 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_CheckModel.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_CheckModel.cxx @@ -64,13 +64,21 @@ bool TObj_CheckModel::checkReferences() // check availability of corresponding back reference occ::handle aBackIter = aReferred->GetBackReferences(); if (aBackIter.IsNull()) + { continue; // object does not support back references + } for (; aBackIter->More(); aBackIter->Next()) + { if (aBackIter->Value() == anObj) + { break; + } + } if (aBackIter->More()) + { continue; // ok, back reference found + } if (IsToFix()) { @@ -78,13 +86,17 @@ bool TObj_CheckModel::checkReferences() aReferred->AddBackReference(anObj); } else + { SetStatus(Message_Alarm4, anObj->GetName()); + } } // Checking back references aRefIter = anObj->GetBackReferences(); if (aRefIter.IsNull()) + { continue; // object does not support back references + } NCollection_Sequence> aBadBackRefs; for (; aRefIter->More(); aRefIter->Next()) { @@ -97,10 +109,16 @@ bool TObj_CheckModel::checkReferences() occ::handle aForwIter = aReferring->GetReferences(); for (; aForwIter->More(); aForwIter->Next()) + { if (aForwIter->Value() == anObj) + { break; + } + } if (aForwIter->More()) + { continue; // ok, reference found + } if (IsToFix()) { @@ -108,12 +126,16 @@ bool TObj_CheckModel::checkReferences() aBadBackRefs.Append(aReferring); } else + { SetStatus(Message_Alarm5, anObj->GetName()); + } } // remove back references to objects that are not referenced actually for (int i = 1; i <= aBadBackRefs.Length(); i++) + { anObj->RemoveBackReference(aBadBackRefs(i)); + } } return !GetStatus().IsAlarm() && !GetStatus().IsFail(); diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Model.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Model.cxx index 14989c7f7b..ffb4baced4 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Model.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Model.cxx @@ -73,7 +73,9 @@ void TObj_Model::CloseDocument(const occ::handle& theDoc) // prevent Abort of the following modifs at document destruction if // a transaction is open: see theDoc->myUndoTransaction.~() if (theDoc->HasOpenCommand()) + { theDoc->AbortCommand(); + } // Application const occ::handle anApplication = GetApplication(); @@ -143,7 +145,9 @@ bool TObj_Model::Load(const TCollection_ExtendedString& theFile) if (!isValid) { if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); Messenger()->Send(Message_Msg("TObj_M_WrongFile") << theFile, Message_Alarm); aStatus = false; @@ -154,7 +158,9 @@ bool TObj_Model::Load(const TCollection_ExtendedString& theFile) // release document from session // no message is needed as it has been put in anApplication->LoadDocument() if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); } } @@ -181,7 +187,9 @@ bool TObj_Model::Load(const TCollection_ExtendedString& theFile) if (!isInitOk) { if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); aStatus = false; } @@ -228,7 +236,9 @@ bool TObj_Model::Load(Standard_IStream& theIStream) if (!isValid) { if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); Messenger()->Send(Message_Msg("TObj_M_WrongFile"), Message_Alarm); aStatus = false; @@ -240,7 +250,9 @@ bool TObj_Model::Load(Standard_IStream& theIStream) // release document from session // no message is needed as it has been put in anApplication->LoadDocument() if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); aStatus = anApplication->CreateNewDocument(aDoc, GetFormat()); @@ -276,7 +288,9 @@ bool TObj_Model::Load(Standard_IStream& theIStream) if (!isInitOk) { if (!aDoc.IsNull()) + { CloseDocument(aDoc); + } myLabel.Nullify(); aStatus = false; } @@ -315,10 +329,14 @@ bool TObj_Model::Save() { occ::handle aDoc = TDocStd_Document::Get(GetLabel()); if (aDoc.IsNull()) + { return false; + } if (!aDoc->GetPath().IsEmpty()) + { return SaveAs(aDoc->GetPath()); + } return true; } @@ -330,7 +348,9 @@ bool TObj_Model::SaveAs(const TCollection_ExtendedString& theFile) // OCAF document occ::handle aDoc = TDocStd_Document::Get(GetLabel()); if (aDoc.IsNull()) + { return false; + } // checking that file is present on disk is not needed because could try to save as new // document to existent file @@ -342,7 +362,9 @@ bool TObj_Model::SaveAs(const TCollection_ExtendedString& theFile) return false; } else + { fclose(aF); + } // store transaction mode bool aTrMode = aDoc->ModificationMode(); @@ -353,7 +375,9 @@ bool TObj_Model::SaveAs(const TCollection_ExtendedString& theFile) { occ::handle anOCAFObj = anIterator->Value(); if (anOCAFObj.IsNull()) + { continue; + } anOCAFObj->BeforeStoring(); } // end of for(anIterator = ...) // set transaction mode back @@ -377,7 +401,9 @@ bool TObj_Model::SaveAs(Standard_OStream& theOStream) // OCAF document occ::handle aDoc = TDocStd_Document::Get(GetLabel()); if (aDoc.IsNull()) + { return false; + } // store transaction mode bool aTrMode = aDoc->ModificationMode(); @@ -388,7 +414,9 @@ bool TObj_Model::SaveAs(Standard_OStream& theOStream) { occ::handle anOCAFObj = anIterator->Value(); if (anOCAFObj.IsNull()) + { continue; + } anOCAFObj->BeforeStoring(); } // end of for(anIterator = ...) // set transaction mode back @@ -410,10 +438,14 @@ bool TObj_Model::Close() // OCAF document TDF_Label aLabel = GetLabel(); if (aLabel.IsNull()) + { return false; + } occ::handle aDoc = TDocStd_Document::Get(aLabel); if (aDoc.IsNull()) + { return false; + } CloseDocument(aDoc); @@ -431,24 +463,34 @@ occ::handle TObj_Model::GetDocumentModel(const TDF_Label& theLabel) { occ::handle aModel; if (theLabel.IsNull()) + { return aModel; + } occ::handle aDoc; occ::handle aData = theLabel.Data(); TDF_Label aRootL = aData->Root(); if (aRootL.IsNull()) + { return aModel; + } occ::handle aDocOwnerAtt; if (aRootL.FindAttribute(TDocStd_Owner::GetID(), aDocOwnerAtt)) + { aDoc = aDocOwnerAtt->GetDocument(); + } if (aDoc.IsNull()) + { return aModel; + } TDF_Label aLabel = aDoc->Main(); occ::handle anAttr; if (aLabel.FindAttribute(TObj_TModel::GetID(), anAttr)) + { aModel = anAttr->Model(); + } return aModel; } @@ -467,7 +509,9 @@ occ::handle TObj_Model::GetChildren() const { occ::handle aMainPartition = GetMainPartition(); if (aMainPartition.IsNull()) + { return nullptr; + } return aMainPartition->GetChildren(); } @@ -479,7 +523,9 @@ occ::handle TObj_Model::FindObject( { occ::handle aDictionary = theDictionary; if (aDictionary.IsNull()) + { aDictionary = GetDictionary(); + } occ::handle aResult; // Check is object with given name is present in model if (IsRegisteredName(theName, aDictionary)) @@ -513,11 +559,15 @@ void TObj_Model::SetNewName(const occ::handle& theObject) // sets name if partition is found if (aPartition.IsNull()) + { return; + } occ::handle name = aPartition->GetNewName(); if (!name.IsNull()) + { theObject->SetName(name); + } } //================================================================================================= @@ -527,10 +577,14 @@ bool TObj_Model::IsRegisteredName(const occ::handle { occ::handle aDictionary = theDictionary; if (aDictionary.IsNull()) + { aDictionary = GetDictionary(); + } if (aDictionary.IsNull()) + { return false; + } return aDictionary->IsRegistered(theName); } @@ -542,10 +596,14 @@ void TObj_Model::RegisterName(const occ::handle& th { occ::handle aDictionary = theDictionary; if (aDictionary.IsNull()) + { aDictionary = GetDictionary(); + } if (!aDictionary.IsNull()) + { aDictionary->RecordName(theName, theLabel); + } } //================================================================================================= @@ -555,10 +613,14 @@ void TObj_Model::UnRegisterName(const occ::handle& { occ::handle aDictionary = theDictionary; if (aDictionary.IsNull()) + { aDictionary = GetDictionary(); + } if (!aDictionary.IsNull()) + { aDictionary->RemoveName(theName); + } } //================================================================================================= @@ -568,7 +630,9 @@ occ::handle TObj_Model::GetDictionary() const occ::handle A; TDF_Label aLabel = GetLabel(); if (!aLabel.IsNull()) + { aLabel.FindAttribute(TObj_TNameContainer::GetID(), A); + } return A; } @@ -579,18 +643,26 @@ occ::handle TObj_Model::getPartition(const TDF_Label& theLabel, { occ::handle aPartition; if (theLabel.IsNull()) + { return aPartition; + } occ::handle A; if (!theLabel.FindAttribute(TObj_TObject::GetID(), A)) { if (theHidden) + { aPartition = new TObj_HiddenPartition(theLabel); + } else + { aPartition = TObj_Partition::Create(theLabel); + } } else + { aPartition = occ::down_cast(A->Get()); + } return aPartition; } @@ -604,7 +676,9 @@ occ::handle TObj_Model::getPartition(const TDF_Label& { occ::handle aPartition; if (theLabel.IsNull()) + { return aPartition; + } TDF_Label aLabel = theLabel.FindChild(theIndex, false); bool isNew = false; @@ -619,7 +693,9 @@ occ::handle TObj_Model::getPartition(const TDF_Label& // setting name to new partition if (isNew) + { aPartition->SetName(new TCollection_HExtendedString(theName)); + } return aPartition; } @@ -648,7 +724,9 @@ bool TObj_Model::initNewModel(const bool IsNew) { occ::handle anOCAFObj = anIterator->Value(); if (anOCAFObj.IsNull()) + { continue; + } anOCAFObj->AfterRetrieval(); } // end of for(anIterator = ...) // update back references for loaded model by references @@ -673,7 +751,9 @@ void TObj_Model::updateBackReferences(const occ::handle& theObject) { // recursive update back references if (theObject.IsNull()) + { return; + } occ::handle aChildren = theObject->GetChildren(); for (; aChildren->More(); aChildren->Next()) { @@ -684,8 +764,10 @@ void TObj_Model::updateBackReferences(const occ::handle& theObject) occ::handle anIter = occ::down_cast(theObject->GetReferences()); - if (anIter.IsNull()) // to avoid exception + if (anIter.IsNull()) + { // to avoid exception return; + } // LH3D15722. Remove all back references to make sure there will be no unnecessary // duplicates, since some back references may already exist after model upgrading. @@ -695,17 +777,23 @@ void TObj_Model::updateBackReferences(const occ::handle& theObject) { occ::handle anObject = anIter->Value(); if (!anObject.IsNull()) + { anObject->RemoveBackReference(theObject, false); + } } // and at last create back references anIter = occ::down_cast(theObject->GetReferences()); if (!anIter.IsNull()) + { for (; anIter->More(); anIter->Next()) { occ::handle anObject = anIter->Value(); if (!anObject.IsNull()) + { anObject->AddBackReference(theObject); + } } + } } //================================================================================================= @@ -715,7 +803,9 @@ occ::handle TObj_Model::GetDocument() const occ::handle D; TDF_Label aLabel = GetLabel(); if (!aLabel.IsNull()) + { D = TDocStd_Document::Get(aLabel); + } return D; } @@ -764,7 +854,9 @@ void TObj_Model::SetModified(const bool theModified) { int aSavedTime = aDoc->GetData()->Time(); if (theModified) + { --aSavedTime; + } aDoc->SetSavedTime(aSavedTime); } } @@ -777,12 +869,16 @@ void TObj_Model::SetModified(const bool theModified) bool TObj_Model::checkDocumentEmpty(const TCollection_ExtendedString& theFile) { if (theFile.IsEmpty()) + { return true; + } OSD_Path aPath(theFile); OSD_File osdfile(aPath); if (!osdfile.Exists()) + { return true; + } FILE* f = OSD_OpenFile(theFile, "r"); if (f) @@ -790,7 +886,9 @@ bool TObj_Model::checkDocumentEmpty(const TCollection_ExtendedString& theFile) bool isZeroLengh = false; fseek(f, 0, SEEK_END); if (ftell(f) == 0) + { isZeroLengh = true; + } fclose(f); return isZeroLengh; @@ -819,13 +917,19 @@ int TObj_Model::GetFormatVersion() const { TDF_Label aLabel = GetDataLabel().FindChild(DataTag_FormatVersion, false); if (aLabel.IsNull()) + { return -1; + } occ::handle aNum; if (!aLabel.FindAttribute(TDataStd_Integer::GetID(), aNum)) + { return -1; + } else + { return aNum->Get(); + } } //================================================================================================= @@ -849,7 +953,9 @@ bool TObj_Model::Paste(occ::handle theModel, occ::handle theRelocTable) { if (theModel.IsNull()) + { return false; + } // clearing dictionary of objects names // theModel->GetDictionary()->NewEmpty()->Paste(theModel->GetDictionary(), // new TDF_RelocationTable); diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_ModelIterator.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_ModelIterator.cxx index 85ba1c0d24..d32ee58679 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_ModelIterator.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_ModelIterator.cxx @@ -27,7 +27,9 @@ TObj_ModelIterator::TObj_ModelIterator(const occ::handle& theModel) { myObject = theModel->GetRoot(); if (!myObject.IsNull()) + { addIterator(myObject); + } } //================================================================================================= @@ -36,7 +38,9 @@ void TObj_ModelIterator::addIterator(const occ::handle& theObj) { occ::handle anIter = theObj->GetChildren(); if (anIter.IsNull()) + { return; // object has no children. + } myIterSeq.Append(anIter); } @@ -69,6 +73,8 @@ void TObj_ModelIterator::Next() return; } else + { myIterSeq.Remove(myIterSeq.Length()); + } } } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Object.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Object.cxx index 9643f0986f..a94566be25 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Object.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Object.cxx @@ -63,7 +63,9 @@ TObj_Object::TObj_Object(const TDF_Label& theLabel, const bool theSetName) occ::handle aMe = this; TObj_TObject::Set(myLabel, aMe); if (theSetName) + { TObj_Model::SetNewName(aMe); + } } //================================================================================================= @@ -73,27 +75,37 @@ occ::handle TObj_Object::GetModel() const occ::handle aModel; // if object label is null object is not alive if (myLabel.IsNull()) + { return aModel; + } // TDF_Label aLabel = TDocStd_Document::Get(myLabel)->Main(); occ::handle aData = myLabel.Data(); if (aData.IsNull()) + { return aModel; + } // try get the document from owner attribute manually TDF_Label aLabel = aData->Root(); occ::handle anOwnerAttr; occ::handle aTDoc; if (!aLabel.IsNull() && aLabel.FindAttribute(TDocStd_Owner::GetID(), anOwnerAttr)) + { aTDoc = anOwnerAttr->GetDocument(); + } if (aTDoc.IsNull()) + { return aModel; + } // use main label of the document to find TObj model attribute aLabel = aTDoc->Main(); occ::handle aModelAttr; if (!aLabel.IsNull() && aLabel.FindAttribute(TObj_TModel::GetID(), aModelAttr)) + { aModel = aModelAttr->Model(); + } return aModel; } @@ -162,7 +174,9 @@ occ::handle TObj_Object::GetChildren( occ::handle anItr = new TObj_OcafObjectIterator(GetChildLabel(), theType, true); if (!TestFlags(ObjectState_Ordered)) + { return anItr; + } // return object according to their order int aLastIndex = 0; int aLastOrder = 0; @@ -172,7 +186,9 @@ occ::handle TObj_Object::GetChildren( { occ::handle anObj = anItr->Value(); if (anObj.IsNull()) + { continue; + } int anOrder = anObj->GetOrder(); if (!aLastIndex) { @@ -181,12 +197,14 @@ occ::handle TObj_Object::GetChildren( aLastOrder = anOrder; } else + { addObjToOrderSequence(anObj, anOrder, aHSeqOfObj, aHSeqOfObj->Length(), aLastIndex, aLastOrder); + } } return new TObj_SequenceIterator(aHSeqOfObj); } @@ -227,7 +245,9 @@ TDF_Label TObj_Object::getChildLabel(const int theRank) const { TDF_Label aLabel = GetChildLabel(); if (theRank > 0) + { aLabel = aLabel.FindChild(theRank, true); + } return aLabel; } @@ -245,19 +265,27 @@ bool TObj_Object::SetName(const occ::handle& theNam // check if the name is exactly the same occ::handle anOldName = GetName(); if (!anOldName.IsNull() && theName->String().IsEqual(anOldName->String())) + { return true; + } // check if name is already registered and do nothing in that case const occ::handle aDictionary = GetDictionary(); occ::handle aModel = GetModel(); if (aModel->IsRegisteredName(theName, aDictionary)) + { return false; + } // change name and update registry if (!anOldName.IsNull()) + { aModel->UnRegisterName(anOldName, aDictionary); + } if (theName.IsNull()) + { GetLabel().ForgetAttribute(TDataStd_Name::GetID()); + } else { aModel->RegisterName(theName, GetLabel(), aDictionary); @@ -289,9 +317,13 @@ occ::handle TObj_Object::GetName() const occ::handle aName; occ::handle A; if (GetLabel().FindAttribute(TDataStd_Name::GetID(), A)) + { aName = new TCollection_HExtendedString(A->Get()); + } else + { aName = new TCollection_HExtendedString(""); + } return aName; } @@ -310,7 +342,9 @@ bool TObj_Object::GetName(TCollection_AsciiString& theName) const { occ::handle aName = GetName(); if (aName.IsNull()) + { return false; + } theName = TCollection_AsciiString(aName->String()); return theName.Length() != 0; } @@ -320,13 +354,21 @@ bool TObj_Object::GetName(TCollection_AsciiString& theName) const bool TObj_Object::HasReference(const occ::handle& theObject) const { if (theObject.IsNull()) + { return false; + } occ::handle anItr = GetReferences(theObject->DynamicType()); if (anItr.IsNull() || !anItr->More()) + { return false; + } for (; anItr->More(); anItr->Next()) + { if (anItr->Value() == theObject) + { return true; + } + } return false; } @@ -352,7 +394,9 @@ void TObj_Object::RemoveAllReferences() void TObj_Object::AddBackReference(const occ::handle& theObject) { if (myHSeqBackRef.IsNull()) + { myHSeqBackRef = new NCollection_HSequence>; + } myHSeqBackRef->Append(theObject); } @@ -362,20 +406,28 @@ void TObj_Object::AddBackReference(const occ::handle& theObject) void TObj_Object::RemoveBackReference(const occ::handle& theObject, const bool theSingleOnly) { - if (myHSeqBackRef.IsNull()) // to avoid exception. + if (myHSeqBackRef.IsNull()) + { // to avoid exception. return; + } for (int i = 1; i <= myHSeqBackRef->Length(); i++) { if (theObject != myHSeqBackRef->Value(i)) + { continue; + } myHSeqBackRef->Remove(i--); if (theSingleOnly) + { break; + } } if (myHSeqBackRef->Length() < 1) + { myHSeqBackRef.Nullify(); // do not need to store empty sequence. + } } //================================================================================================= @@ -421,19 +473,27 @@ void TObj_Object::RemoveReference(const occ::handle& theObject) bool TObj_Object::CanDetach(const TObj_DeletingMode theMode) { if (!IsAlive()) + { return false; + } occ::handle aRefs = GetBackReferences(); // Free Object can be deleted in any Mode if (aRefs.IsNull() || !aRefs->More()) + { return true; + } if (theMode == TObj_FreeOnly) + { return false; + } if (theMode == TObj_Forced) + { return true; + } // check the last KeepDepending mode occ::handle aMe = this; @@ -441,7 +501,9 @@ bool TObj_Object::CanDetach(const TObj_DeletingMode theMode) { occ::handle anObject = aRefs->Value(); if (!anObject->CanRemoveReference(aMe)) + { return false; // one of objects could not be unlinked + } } return true; @@ -452,11 +514,15 @@ bool TObj_Object::CanDetach(const TObj_DeletingMode theMode) bool TObj_Object::Detach(const TObj_DeletingMode theMode) { if (!IsAlive()) + { return false; + } // if object can not be deleted returns False if (!RemoveBackReferences(theMode)) + { return false; + } occ::handle anOldName = GetName(); @@ -464,7 +530,9 @@ bool TObj_Object::Detach(const TObj_DeletingMode theMode) occ::handle aChildren = GetChildren(); for (; aChildren->More(); aChildren->Next()) + { aChildren->Value()->Detach(theMode); + } // Clearing its own data GetReferenceLabel().ForgetAllAttributes(); @@ -481,7 +549,9 @@ bool TObj_Object::Detach(const TObj_DeletingMode theMode) { TDF_Label aRegisteredLabel = aDictionary->Get().Find(anOldName); if (!aRegisteredLabel.IsNull() && aRegisteredLabel == GetLabel()) + { aDictionary->RemoveName(anOldName); + } } } GetLabel().ForgetAllAttributes(); @@ -495,7 +565,9 @@ bool TObj_Object::Detach(const TDF_Label& theLabel, const TObj_DeletingMode theM { occ::handle anObject; if (GetObj(theLabel, anObject)) + { return anObject->Detach(theMode); + } return true; } @@ -506,20 +578,28 @@ bool TObj_Object::GetObj(const TDF_Label& theLabel, const bool isSuper) { if (theLabel.IsNull()) + { return false; + } occ::handle A; // find on the current label if (theLabel.FindAttribute(TObj_TObject::GetID(), A)) + { theResult = A->Get(); + } else + { theResult.Nullify(); + } if (!theResult.IsNull()) { if (!theResult->myLabel.IsNull()) + { return true; + } // if the object is not allive then it is a wrong data in the Data Model theResult.Nullify(); @@ -545,13 +625,17 @@ occ::handle TObj_Object::GetFatherObject( occ::handle aFather; if (myLabel.IsNull()) + { return aFather; + } occ::handle aSon(this); while (aSon->GetObj(aSon->GetLabel().Father(), aFather, true)) { if (theType.IsNull() || aFather->IsKind(theType)) + { break; + } else { aSon = aFather; @@ -569,7 +653,9 @@ void TObj_Object::AfterRetrieval() // Register the name occ::handle aModel = GetModel(); if (!aModel.IsNull()) + { aModel->RegisterName(GetName(), GetLabel(), GetDictionary()); + } } //================================================================================================= @@ -607,7 +693,9 @@ TDF_Label TObj_Object::getDataLabel(const int theRank1, const int theRank2) cons { aLabel = GetDataLabel().FindChild(theRank1, true); if (theRank2 > 0) + { aLabel = aLabel.FindChild(theRank2, true); + } } return aLabel; } @@ -621,7 +709,9 @@ TDF_Label TObj_Object::getReferenceLabel(const int theRank1, const int theRank2) { aLabel = GetReferenceLabel().FindChild(theRank1, true); if (theRank2 > 0) + { aLabel = aLabel.FindChild(theRank2, true); + } } return aLabel; } @@ -665,7 +755,9 @@ bool TObj_Object::setReal(const double theValue, // check that value is actually changed occ::handle A; if (aLabel.FindAttribute(TDataStd_Real::GetID(), A) && fabs(A->Get() - theValue) <= theTolerance) + { return false; + } TDataStd_Real::Set(aLabel, theValue); return true; @@ -691,9 +783,13 @@ void TObj_Object::setExtString(const occ::handle& t { TDF_Label aLabel = getDataLabel(theRank1, theRank2); if (!theValue.IsNull()) + { TDataStd_Name::Set(aLabel, theValue->String()); + } else + { aLabel.ForgetAttribute(TDataStd_Name::GetID()); + } } //================================================================================================= @@ -716,9 +812,13 @@ void TObj_Object::setAsciiString(const occ::handle& th { TDF_Label aLabel = getDataLabel(theRank1, theRank2); if (!theValue.IsNull()) + { TDataStd_AsciiString::Set(aLabel, theValue->String()); + } else + { aLabel.ForgetAttribute(TDataStd_AsciiString::GetID()); + } } //================================================================================================= @@ -741,7 +841,9 @@ bool TObj_Object::setInteger(const int theValue, const int theRank1, const int t // check that value is actually changed occ::handle A; if (aLabel.FindAttribute(TDataStd_Integer::GetID(), A) && A->Get() == theValue) + { return false; + } TDataStd_Integer::Set(aLabel, theValue); return true; @@ -767,12 +869,16 @@ bool TObj_Object::setReference(const occ::handle& theObject, TDF_Label aLabel = getReferenceLabel(theRank1, theRank2); if (theObject.IsNull()) + { return aLabel.ForgetAttribute(TObj_TReference::GetID()); + } // check that reference is actually changed occ::handle A; if (aLabel.FindAttribute(TObj_TReference::GetID(), A) && A->Get() == theObject) + { return false; + } // 27.07.05, PTv: remove reference attribute before create new reference (for Undo/Redo) aLabel.ForgetAttribute(TObj_TReference::GetID()); @@ -788,7 +894,9 @@ TDF_Label TObj_Object::addReference(const int theRank1, const occ::handle 0) + { aRefLabel = aRefLabel.FindChild(theRank1, true); + } TDF_TagSource aTag; TDF_Label aLabel = TDF_TagSource::NewChild(aRefLabel); @@ -818,14 +926,18 @@ occ::handle> TObj_Object::getRealArray( TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), anArrAttribute)) + { if (theLength > 0) { anArrAttribute = TDataStd_RealArray::Set(aLabel, 1, theLength); anArrAttribute->Array()->Init(theInitialValue); } + } occ::handle> anArr; if (!anArrAttribute.IsNull()) + { anArr = anArrAttribute->Array(); + } return anArr; } @@ -848,14 +960,18 @@ occ::handle> TObj_Object::getIntegerArray(const int the TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anArrAttribute)) + { if (theLength > 0) { anArrAttribute = TDataStd_IntegerArray::Set(aLabel, 1, theLength); anArrAttribute->Array()->Init(theInitialValue); } + } occ::handle> anArr; if (!anArrAttribute.IsNull()) + { anArr = anArrAttribute->Array(); + } return anArr; } @@ -878,12 +994,18 @@ occ::handle> TObj_Object::getExt TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), anArrAttribute)) + { if (theLength > 0) + { anArrAttribute = TDataStd_ExtStringArray::Set(aLabel, 1, theLength); + } + } occ::handle> anArr; if (!anArrAttribute.IsNull()) + { anArr = anArrAttribute->Array(); + } return anArr; } @@ -901,19 +1023,25 @@ void TObj_Object::setArray(const occ::handle>& theAr TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), anArrAttribute) && !theArray.IsNull()) + { anArrAttribute = TDataStd_RealArray::Set(aLabel, 1, 1); + } if (theArray.IsNull()) { // deletion mode if (!anArrAttribute.IsNull()) + { aLabel.ForgetAttribute(anArrAttribute); + } return; } if (anArrAttribute->Array() == theArray) + { // Backup wont happen but we want it anArrAttribute->Init(1, 1); + } anArrAttribute->ChangeArray(theArray); } @@ -932,19 +1060,25 @@ void TObj_Object::setArray(const occ::handle>& theArray TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anArrAttribute) && !theArray.IsNull()) + { anArrAttribute = TDataStd_IntegerArray::Set(aLabel, 1, 1); + } if (theArray.IsNull()) { // deletion mode if (!anArrAttribute.IsNull()) + { aLabel.ForgetAttribute(anArrAttribute); + } return; } if (anArrAttribute->Array() == theArray) + { // Backup wont happen but we want it anArrAttribute->Init(1, 1); + } anArrAttribute->ChangeArray(theArray); } @@ -964,19 +1098,25 @@ void TObj_Object::setArray( TDF_Label aLabel = getDataLabel(theRank1, theRank2); occ::handle anArrAttribute; if (!aLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), anArrAttribute) && !theArray.IsNull()) + { anArrAttribute = TDataStd_ExtStringArray::Set(aLabel, 1, 1); + } if (theArray.IsNull()) { // deletion mode if (!anArrAttribute.IsNull()) + { aLabel.ForgetAttribute(anArrAttribute); + } return; } if (anArrAttribute->Array() == theArray) + { // Backup wont happen but we want it anArrAttribute->Init(1, 1); + } anArrAttribute->ChangeArray(theArray); } @@ -1004,7 +1144,9 @@ static void copyTagSources(const TDF_Label& theSourceLabel, const TDF_Label& the { TDF_Label aSourceLabel = theSourceLabel.FindChild(aLI.Value().Tag(), false); if (!aSourceLabel.IsNull()) + { copyTagSources(aSourceLabel, aLI.Value()); + } } } @@ -1015,7 +1157,9 @@ occ::handle TObj_Object::Clone(const TDF_Label& the { occ::handle aRelocTable = theRelocTable; if (theRelocTable.IsNull()) + { aRelocTable = new TDF_RelocationTable; + } occ::handle aNewObj; // take current model for restoring it after creating object. const occ::handle& aCurrentModel = TObj_Assistant::GetCurrentModel(); @@ -1025,10 +1169,14 @@ occ::handle TObj_Object::Clone(const TDF_Label& the TDF_Label aLabel = TDocStd_Document::Get(theTargetLabel)->Main(); occ::handle aModelAttr; if (aLabel.FindAttribute(TObj_TModel::GetID(), aModelAttr)) + { aTargetModel = aModelAttr->Model(); + } if (aCurrentModel != aTargetModel) + { TObj_Assistant::SetCurrentModel(aTargetModel); + } // crete new object aNewObj = TObj_Persistence::CreateNewObject(DynamicType()->Name(), theTargetLabel); @@ -1042,7 +1190,9 @@ occ::handle TObj_Object::Clone(const TDF_Label& the // now set name of object. const occ::handle aCloneName = GetNameForClone(aNewObj); if (!aCloneName.IsNull() && !aCloneName->IsEmpty()) + { aNewObj->SetName(new TCollection_HExtendedString(aCloneName)); + } // copy the data copyData(aNewObj); @@ -1056,12 +1206,16 @@ occ::handle TObj_Object::Clone(const TDF_Label& the // copy the references if (theRelocTable.IsNull()) + { CopyReferences(aNewObj, aRelocTable); + } } // restore the model for persistence. if (aCurrentModel != aTargetModel) + { TObj_Assistant::SetCurrentModel(aCurrentModel); + } return aNewObj; } @@ -1072,13 +1226,17 @@ bool TObj_Object::copyData(const occ::handle& theTargetObject) { bool IsDone = false; if (!theTargetObject->DynamicType()->SubType(DynamicType())) + { return IsDone; + } // init the copier by labels. TDF_Label aDataLabel = GetDataLabel(); TDF_Label aNewDataLabel = theTargetObject->GetDataLabel(); // check if object has any data. if (aDataLabel.IsNull() || aNewDataLabel.IsNull()) + { return IsDone; + } TDF_CopyLabel aCopier(aDataLabel, aNewDataLabel); aCopier.Perform(); @@ -1111,7 +1269,9 @@ void TObj_Object::CopyChildren(TDF_Label& theTarget } TDF_Label aChildLabel = theTargetLabel; for (int i = aTags.Length(); i > 0; i--) + { aChildLabel = aChildLabel.FindChild(aTags.Value(i), true); + } aChild->Clone(aChildLabel, theRelocTable); } @@ -1134,13 +1294,19 @@ void TObj_Object::CopyReferences(const occ::handle& theTarg TDF_Label aSrcL = aSrcChild->GetLabel(); TDF_Label aDestLabel; if (!theRelocTable->HasRelocation(aSrcL, aDestLabel)) + { continue; + } occ::handle aDstChild; if (!TObj_Object::GetObj(aDestLabel, aDstChild)) + { continue; + } if (aDstChild.IsNull() || !aDstChild->IsAlive() || aSrcChild->DynamicType() != aDstChild->DynamicType()) + { continue; // should not be with relocation table + } aSrcChild->CopyReferences(aDstChild, theRelocTable); } @@ -1180,13 +1346,17 @@ void TObj_Object::ReplaceReference(const occ::handle& theOldObject, { occ::handle anItr = occ::down_cast(GetReferences()); if (anItr.IsNull()) + { return; + } // iterates on references. for (; anItr->More(); anItr->Next()) { occ::handle anObj = anItr->Value(); if (anObj != theOldObject) + { continue; + } TDF_Label aRefLabel = anItr->LabelValue(); // if new object is null then simple remove reference. @@ -1207,7 +1377,9 @@ void TObj_Object::ReplaceReference(const occ::handle& theOldObject, bool TObj_Object::IsAlive() const { if (myLabel.IsNull()) + { return false; + } occ::handle anObj; return GetObj(myLabel, anObj); @@ -1254,10 +1426,14 @@ bool TObj_Object::RemoveBackReferences(const TObj_DeletingMode theMode) // Free Object can be deleted in any Mode if (aRefs.IsNull() || !aRefs->More()) + { return true; + } if (theMode == TObj_FreeOnly) + { return false; + } // Defining the sequence of objects which are referenced to this one. The // first sequence stores containers the second one object with strong @@ -1271,15 +1447,23 @@ bool TObj_Object::RemoveBackReferences(const TObj_DeletingMode theMode) { occ::handle anObject = aRefs->Value(); if (anObject.IsNull() || !anObject->IsAlive()) + { continue; + } if (anObject->CanRemoveReference(aMe)) + { aContainers.Append(anObject); + } else + { aStrongs.Append(anObject); + } } // Can not be removed without deletion of referenced objects mode if (theMode == TObj_KeepDepending && aStrongs.Length() > 0) + { return false; + } // Delete or link off the referencing objects int i; occ::handle anOwnData = GetLabel().Data(); @@ -1287,14 +1471,20 @@ bool TObj_Object::RemoveBackReferences(const TObj_DeletingMode theMode) { occ::handle anObj = aContainers(i); if (anObj.IsNull() || anObj->GetLabel().IsNull()) + { continue; // undead object on dead label + } occ::handle aData = anObj->GetLabel().Data(); bool aModifMode = aData->IsModificationAllowed(); if (anOwnData != aData) + { aData->AllowModification(true); + } anObj->RemoveReference(aMe); if (anOwnData != aData) + { aData->AllowModification(aModifMode); + } } /* PTv 21.11.2006 object from other document refers to current object and must be killed @@ -1306,14 +1496,20 @@ bool TObj_Object::RemoveBackReferences(const TObj_DeletingMode theMode) { occ::handle anObj = aStrongs(i); if (anObj.IsNull() || anObj->GetLabel().IsNull()) + { continue; // undead object on dead label + } occ::handle aData = anObj->GetLabel().Data(); bool aModifMode = aData->IsModificationAllowed(); if (anOwnData != aData) + { aData->AllowModification(true); + } anObj->Detach(theMode); if (anOwnData != aData) + { aData->AllowModification(aModifMode); + } } return true; @@ -1344,11 +1540,15 @@ bool TObj_Object::RelocateReferences(const TDF_Label& theFromRoot, TDF_Label aNewLabel, aLabel = aRef->GetLabel(); if (aLabel.Data() != theFromRoot.Data() || aLabel.IsDescendant(theToRoot)) + { continue; // need not to relocate + } TDF_Tool::RelocateLabel(aLabel, theFromRoot, theToRoot, aNewLabel); if (aNewLabel.IsNull() || !TObj_Object::GetObj(aNewLabel, anObj)) + { return false; + } // care of back references if (theUpdateBackRefs) @@ -1359,7 +1559,9 @@ bool TObj_Object::RelocateReferences(const TDF_Label& theFromRoot, // an old object anObj = aRef->Get(); if (!anObj.IsNull()) + { anObj->RemoveBackReference(me); + } } aRef->Set(aNewLabel, aRef->GetMasterLabel()); @@ -1402,7 +1604,9 @@ occ::handle TObj_Object::GetDictionary() const { occ::handle aModel = GetModel(); if (!aModel.IsNull()) + { return aModel->GetDictionary(); + } return nullptr; } @@ -1420,7 +1624,9 @@ int TObj_Object::GetOrder() const { int order = getInteger(DataTag_Order); if (!order) + { order = GetLabel().Tag(); + } return order; } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_OcafObjectIterator.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_OcafObjectIterator.cxx index bdc2ba8b19..dd44393482 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_OcafObjectIterator.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_OcafObjectIterator.cxx @@ -51,6 +51,8 @@ void TObj_OcafObjectIterator::MakeStep() myAllSubChildren ? myIterator.Next() : myIterator.NextBrother(); } else + { myIterator.Next(); + } } } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Partition.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Partition.cxx index d200c3bef9..126edf7a51 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Partition.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Partition.cxx @@ -63,7 +63,9 @@ void TObj_Partition::SetNamePrefix(const occ::handle TObj_Partition::GetNewName(const bool theIsToChangeCount) { if (myPrefix.IsNull()) + { return nullptr; + } int aRank = GetLastIndex() + 1; int saveRank = aRank; @@ -77,7 +79,9 @@ occ::handle TObj_Partition::GetNewName(const bool t // actually set; the name requested by the current operation can be // dropped later and this will not cause index to be increased if (theIsToChangeCount && --aRank > saveRank) + { SetLastIndex(aRank); + } return aName; } @@ -95,10 +99,14 @@ occ::handle TObj_Partition::GetPartition(const occ::handle anObject; if (TObj_Object::GetObj(aLabel, anObject, true)) + { aPartition = occ::down_cast(anObject); + } if (aPartition.IsNull()) + { aLabel = aLabel.Father(); + } } } return aPartition; @@ -145,7 +153,9 @@ bool TObj_Partition::SetName(const occ::handle& the { occ::handle anOldName = GetName(); if (!anOldName.IsNull() && theName->String().IsEqual(anOldName->String())) + { return true; + } TDataStd_Name::Set(GetLabel(), theName->String()); return true; diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_Persistence.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_Persistence.cxx index c02eba3a6d..afd75d0089 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_Persistence.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_Persistence.cxx @@ -53,7 +53,9 @@ occ::handle TObj_Persistence::CreateNewObject(const char* const the { TObj_Persistence* tool = (TObj_Persistence*)getMapOfTypes().Find(theType); if (tool) + { return tool->New(theLabel); + } } return nullptr; } @@ -65,6 +67,6 @@ void TObj_Persistence::DumpTypes(Standard_OStream& theOs) NCollection_DataMap::Iterator it(getMapOfTypes()); for (; it.More(); it.Next()) { - theOs << it.Key() << std::endl; + theOs << it.Key() << '\n'; } } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_ReferenceIterator.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_ReferenceIterator.cxx index a3ddf61495..3a9ec9d677 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_ReferenceIterator.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_ReferenceIterator.cxx @@ -44,7 +44,9 @@ void TObj_ReferenceIterator::MakeStep() { myObject = A->Get(); if (!myType.IsNull() && !myObject.IsNull() && !myObject->IsKind(myType)) + { continue; + } myNode = L; } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_TIntSparseArray.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_TIntSparseArray.cxx index ad7e8846bd..ba770f3a00 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_TIntSparseArray.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_TIntSparseArray.cxx @@ -66,10 +66,14 @@ void TObj_TIntSparseArray::SetValue(const size_t theId, const int theValue) { // check that modification is allowed if (!Label().Data()->IsModificationAllowed()) + { throw Standard_ImmutableObject("Attribute TObj_TIntSparseArray is changed outside transaction"); + } if (theId < 1 || theValue < 1) + { throw Standard_OutOfRange("TObj_TIntSparseArray::SetValue"); + } int anOld = AbsentValue; bool isOld = myVector.HasValue(theId); @@ -77,8 +81,10 @@ void TObj_TIntSparseArray::SetValue(const size_t theId, const int theValue) { int& aData = myVector(theId); if (aData == theValue) + { // no actual modification return; + } anOld = aData; // set new value aData = theValue; @@ -97,7 +103,9 @@ void TObj_TIntSparseArray::SetValue(const size_t theId, const int theValue) int aMyTransaction = Transaction(); if (myDoBackup && aMyTransaction < aCurrentTransaction) + { backupValue(theId, anOld, theValue); + } } } @@ -107,10 +115,14 @@ void TObj_TIntSparseArray::UnsetValue(const size_t theId) { // check that modification is allowed if (!Label().Data()->IsModificationAllowed()) + { throw Standard_ImmutableObject("Attribute TObj_TIntSparseArray is changed outside transaction"); + } if (theId < 1) + { throw Standard_OutOfRange("TObj_TIntSparseArray::UnsetValue"); + } int anOld = AbsentValue; bool isOld = myVector.HasValue(theId); @@ -121,8 +133,10 @@ void TObj_TIntSparseArray::UnsetValue(const size_t theId) myVector.UnsetValue(theId); } else + { // no actual modification return; + } TDF_Label aLabel = Label(); if (!aLabel.IsNull()) @@ -132,7 +146,9 @@ void TObj_TIntSparseArray::UnsetValue(const size_t theId) int aMyTransaction = Transaction(); if (myDoBackup && aMyTransaction < aCurrentTransaction) + { backupValue(theId, anOld, AbsentValue); + } } } @@ -170,13 +186,17 @@ void TObj_TIntSparseArray::backupValue(const size_t theId, { // save the current value if it has not been saved in previous time if (!myOldMap.IsBound(theId)) + { myOldMap.Bind(theId, theCurrValue); + } else { // if value in Undo is the same as the new one, the item in Undo map may be cleared int aUData = myOldMap.Value(theId); if (aUData == theNewValue) + { myOldMap.UnBind(theId); + } } } @@ -198,7 +218,9 @@ occ::handle TObj_TIntSparseArray::BackupCopy() const // save delta data in a copy if (!myOldMap.IsEmpty()) + { aCopy->myOldMap.Exchange((NCollection_SparseArray&)myOldMap); + } return aCopy; } @@ -212,7 +234,9 @@ void TObj_TIntSparseArray::Restore(const occ::handle& theDelta) { occ::handle aDelta = occ::down_cast(theDelta); if (aDelta.IsNull()) + { return; + } // restore the values from aDelta->myOldMap if (!aDelta->myOldMap.IsEmpty()) @@ -223,9 +247,13 @@ void TObj_TIntSparseArray::Restore(const occ::handle& theDelta) size_t anId = anIt.Key(); int anOld = anIt.Value(); if (anOld == AbsentValue) + { UnsetValue(anId); + } else + { SetValue(anId, anOld); + } } } } @@ -237,7 +265,9 @@ void TObj_TIntSparseArray::Paste(const occ::handle& theInto, { occ::handle aInto = occ::down_cast(theInto); if (aInto.IsNull()) + { return; + } aInto->myVector.Assign(myVector); } diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_TObject.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_TObject.cxx index da029c5da4..472a883aeb 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_TObject.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_TObject.cxx @@ -116,7 +116,9 @@ void TObj_TObject::BeforeForget() { aSubLabel = aLI.Value(); if (!aSubLabel.IsNull()) + { aSubLabel.ForgetAllAttributes(true); + } } } // remove back references before document die @@ -143,10 +145,14 @@ bool TObj_TObject::AfterUndo(const occ::handle& anAttDelta, occ::handle me; me = this; if (!aLabel.IsNull() && aLabel.FindAttribute(GetID(), anAttr)) + { aTObject = occ::down_cast(anAttr); + } if (!aTObject.IsNull() && aTObject->Get() == myElem) + { myElem->myLabel = aLabel; + } else { TDF_Label aNullLabel; diff --git a/src/ApplicationFramework/TKTObj/TObj/TObj_TReference.cxx b/src/ApplicationFramework/TKTObj/TObj/TObj_TReference.cxx index 2579ec3709..b6ba0e63ab 100644 --- a/src/ApplicationFramework/TKTObj/TObj/TObj_TReference.cxx +++ b/src/ApplicationFramework/TKTObj/TObj/TObj_TReference.cxx @@ -61,11 +61,15 @@ occ::handle TObj_TReference::Set(const TDF_Label& { occ::handle anObj = A->Get(); if (!anObj.IsNull()) + { anObj->RemoveBackReference(theMaster); + } } A->Set(theObject, theMaster->GetLabel()); if (!theObject.IsNull()) + { theObject->AddBackReference(theMaster); + } return A; } @@ -75,9 +79,13 @@ void TObj_TReference::Set(const occ::handle& theElem, const TDF_Lab { Backup(); if (theElem.IsNull()) + { myLabel.Nullify(); + } else + { myLabel = theElem->GetLabel(); + } myMasterLabel = theMasterLabel; } @@ -139,27 +147,37 @@ void TObj_TReference::Paste(const occ::handle& theInto, // get new referenced object TDF_Label aRefLabel = myLabel; if (!RT->HasRelocation(myLabel, aRefLabel)) + { aRefLabel = myLabel; + } aRefLabel.FindAttribute(TObj_TObject::GetID(), aObject); occ::handle anIObject; if (!aObject.IsNull()) + { anIObject = aObject->Get(); + } // find correct master label occ::handle aMasterObj; TObj_Object::GetObj(aReference->Label(), aMasterObj, true); TDF_Label aMasterLabel; if (!aMasterObj.IsNull()) + { aMasterLabel = aMasterObj->GetLabel(); + } if (aMasterLabel.IsNull() || !aMasterLabel.FindAttribute(TObj_TObject::GetID(), aMasterTObj)) + { return; + } // set master and referenced label aReference->Set(anIObject, aMasterLabel); // update back references if (!anIObject.IsNull()) + { anIObject->AddBackReference(aMasterTObj->Get()); + } } //======================================================================= @@ -171,18 +189,24 @@ void TObj_TReference::BeforeForget() { // check if master object exist if (myMasterLabel.IsNull()) + { return; + } // removing back reference occ::handle aMasterObject; occ::handle aTObject; if (!myMasterLabel.FindAttribute(TObj_TObject::GetID(), aTObject)) + { return; + } aMasterObject = aTObject->Get(); occ::handle anObj = Get(); if (anObj.IsNull()) + { return; + } aMasterObject->BeforeForgetReference(GetLabel()); anObj->RemoveBackReference(aMasterObject); @@ -194,23 +218,33 @@ bool TObj_TReference::BeforeUndo(const occ::handle& theDelta const bool /*isForced*/) { if (!theDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) + { return true; + } if (myMasterLabel.IsNull()) + { return true; + } occ::handle anObject = Get(); if (anObject.IsNull()) + { return true; + } occ::handle aMasterObject; occ::handle aTObject; if (!myMasterLabel.FindAttribute(TObj_TObject::GetID(), aTObject)) + { return true; + } aMasterObject = aTObject->Get(); if (!anObject.IsNull()) + { anObject->RemoveBackReference(aMasterObject); + } return true; } @@ -221,24 +255,34 @@ bool TObj_TReference::AfterUndo(const occ::handle& theDelta, const bool /*isForced*/) { if (!theDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnRemoval))) + { return true; + } if (myMasterLabel.IsNull()) + { return true; + } occ::handle anObject = Get(); if (anObject.IsNull()) + { return true; + } occ::handle aMasterObject; occ::handle aTObject; if (!myMasterLabel.FindAttribute(TObj_TObject::GetID(), aTObject)) + { return true; + } aMasterObject = aTObject->Get(); if (!anObject.IsNull()) + { anObject->AddBackReference(aMasterObject); + } return true; } @@ -248,17 +292,23 @@ bool TObj_TReference::AfterUndo(const occ::handle& theDelta, void TObj_TReference::AfterResume() { if (myMasterLabel.IsNull()) + { return; + } occ::handle aMasterObject; occ::handle aTObject; if (!myMasterLabel.FindAttribute(TObj_TObject::GetID(), aTObject)) + { return; + } aMasterObject = aTObject->Get(); occ::handle anObject = Get(); if (!anObject.IsNull()) + { anObject->AddBackReference(aMasterObject); + } } //================================================================================================= @@ -266,17 +316,23 @@ void TObj_TReference::AfterResume() bool TObj_TReference::AfterRetrieval(const bool /*forceIt*/) { if (myMasterLabel.IsNull()) + { return true; + } occ::handle anObject = Get(); occ::handle aMasterObject; occ::handle aTObject; if (!myMasterLabel.FindAttribute(TObj_TObject::GetID(), aTObject)) + { return false; + } aMasterObject = aTObject->Get(); if (!anObject.IsNull()) + { anObject->AddBackReference(aMasterObject); + } return true; } diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISPresentation.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISPresentation.cxx index fee145b6a5..2da6bd050f 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISPresentation.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISPresentation.cxx @@ -49,7 +49,9 @@ occ::handle TPrsStd_AISPresentation::Set(const TDF_Labe // create associated data (unless already there) occ::handle aData = TDataXtd_Presentation::Set(theLabel, theDriver); if (aData.IsNull()) + { throw Standard_NoMoreObject(NO_MORE_OBJECT); + } if (!theLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation)) { aPresentation = new TPrsStd_AISPresentation(); @@ -73,7 +75,9 @@ void TPrsStd_AISPresentation::Unset(const TDF_Label& theLabel) { occ::handle aPresentation; if (theLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation)) + { theLabel.ForgetAttribute(aPresentation); + } // remove associated data TDataXtd_Presentation::Unset(theLabel); @@ -85,7 +89,9 @@ occ::handle TPrsStd_AISPresentation::getData() const { occ::handle aData; if (!Label().FindAttribute(TDataXtd_Presentation::GetID(), aData)) + { throw Standard_NoMoreObject(NO_MORE_OBJECT); + } return aData; } @@ -102,7 +108,9 @@ const Standard_GUID& TPrsStd_AISPresentation::GetID() void TPrsStd_AISPresentation::Display(const bool theIsUpdate) { if (theIsUpdate || myAIS.IsNull()) + { AISUpdate(); + } AISDisplay(); } @@ -175,21 +183,29 @@ bool TPrsStd_AISPresentation::HasOwnMaterial() const void TPrsStd_AISPresentation::UnsetMaterial() { if (!getData()->HasOwnMaterial() && !myAIS.IsNull() && !myAIS->HasMaterial()) + { return; + } getData()->UnsetMaterial(); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull() && myAIS->HasMaterial()) { occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->UnsetMaterial(myAIS, false); + } else + { myAIS->UnsetMaterial(); + } } } @@ -199,25 +215,37 @@ void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial theName { Backup(); if (getData()->HasOwnMode() && getData()->MaterialIndex() == theName) + { if (!myAIS.IsNull() && myAIS->HasMaterial() && myAIS->Material() == theName) + { return; + } + } getData()->SetMaterialIndex(theName); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull()) { if (myAIS->HasMaterial() && myAIS->Material() == theName) + { return; // AIS has already had that material + } occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->SetMaterial(myAIS, theName, false); + } else + { myAIS->SetMaterial(theName); + } } } @@ -234,25 +262,37 @@ void TPrsStd_AISPresentation::SetTransparency(const double theValue) { Backup(); if (getData()->HasOwnTransparency() && getData()->Transparency() == theValue) + { if (!myAIS.IsNull() && myAIS->Transparency() == theValue) + { return; + } + } getData()->SetTransparency(theValue); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull()) { if (myAIS->Transparency() == theValue) + { return; // AIS has already had that transparency + } occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->SetTransparency(myAIS, theValue, false); + } else + { myAIS->SetTransparency(theValue); + } } } @@ -261,21 +301,29 @@ void TPrsStd_AISPresentation::SetTransparency(const double theValue) void TPrsStd_AISPresentation::UnsetTransparency() { if (!getData()->HasOwnTransparency()) + { return; + } getData()->UnsetTransparency(); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull()) { occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->UnsetTransparency(myAIS, false); + } else + { myAIS->UnsetTransparency(); + } } } @@ -305,20 +353,28 @@ bool TPrsStd_AISPresentation::HasOwnColor() const void TPrsStd_AISPresentation::UnsetColor() { if (!getData()->HasOwnColor() && !myAIS.IsNull() && !myAIS->HasColor()) + { return; + } getData()->UnsetColor(); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull() && myAIS->HasColor()) { occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->UnsetColor(myAIS, false); + } else + { myAIS->UnsetColor(); + } } } @@ -343,7 +399,9 @@ void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor theColor) getData()->SetColor(theColor); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull()) { @@ -360,9 +418,13 @@ void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor theColor) occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->SetColor(myAIS, theColor, false); + } else + { myAIS->SetColor(theColor); + } } } @@ -386,22 +448,32 @@ void TPrsStd_AISPresentation::SetWidth(const double theWidth) { Backup(); if (getData()->HasOwnWidth() && getData()->Width() == theWidth) + { if (!myAIS.IsNull() && myAIS->HasWidth() && myAIS->Width() == theWidth) + { return; + } + } getData()->SetWidth(theWidth); if (!myAIS.IsNull()) { if (myAIS->HasWidth() && myAIS->Width() == theWidth) + { return; // AIS has already had that width + } occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->SetWidth(myAIS, theWidth, false); + } else + { myAIS->SetWidth(theWidth); + } } } @@ -410,22 +482,32 @@ void TPrsStd_AISPresentation::SetWidth(const double theWidth) void TPrsStd_AISPresentation::UnsetWidth() { if (!getData()->HasOwnWidth()) + { if (!myAIS.IsNull() && !myAIS->HasWidth()) + { return; + } + } getData()->UnsetWidth(); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull() && myAIS->HasWidth()) { occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->UnsetWidth(myAIS, false); + } else + { myAIS->UnsetWidth(); + } } } @@ -449,25 +531,37 @@ void TPrsStd_AISPresentation::SetMode(const int theMode) { Backup(); if (getData()->HasOwnMode() && getData()->Mode() == theMode) + { if (!myAIS.IsNull() && myAIS->DisplayMode() == theMode) + { return; + } + } getData()->SetMode(theMode); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull()) { if (myAIS->DisplayMode() == theMode) + { return; // AIS has already had that mode + } occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->SetDisplayMode(myAIS, theMode, false); + } else + { myAIS->SetDisplayMode(theMode); + } } } @@ -476,22 +570,32 @@ void TPrsStd_AISPresentation::SetMode(const int theMode) void TPrsStd_AISPresentation::UnsetMode() { if (!getData()->HasOwnMode()) + { if (!myAIS.IsNull() && !myAIS->HasDisplayMode()) + { return; + } + } getData()->UnsetMode(); if (myAIS.IsNull()) + { AISUpdate(); + } if (!myAIS.IsNull() && myAIS->HasDisplayMode()) { occ::handle aContext = getAISContext(); if (!aContext.IsNull()) + { aContext->UnsetDisplayMode(myAIS, false); + } else + { myAIS->UnsetDisplayMode(); + } } } @@ -522,13 +626,19 @@ void TPrsStd_AISPresentation::SetSelectionMode(const int theSelectionMode, const bool theTransaction) { if (theTransaction) + { Backup(); + } getData()->SetSelectionMode(theSelectionMode, theTransaction); if (myAIS.IsNull()) + { AISUpdate(); + } else + { ActivateSelectionMode(); + } } //================================================================================================= @@ -537,13 +647,19 @@ void TPrsStd_AISPresentation::AddSelectionMode(const int theSelectionMode, const bool theTransaction) { if (theTransaction) + { Backup(); + } getData()->AddSelectionMode(theSelectionMode, theTransaction); if (myAIS.IsNull()) + { AISUpdate(); + } else + { ActivateSelectionMode(); + } } //================================================================================================= @@ -598,7 +714,9 @@ void TPrsStd_AISPresentation::Paste(const occ::handle& theInto, anInto->AISErase(true); // Restore the displayed flag. if (displayed) + { anInto->SetDisplayed(displayed); + } } // Nullify the interactive object. // It will be restored on the next call to AISUpdate(). @@ -640,7 +758,9 @@ void TPrsStd_AISPresentation::AfterResume() AISDisplay(); } else + { AISErase(); + } } //================================================================================================= @@ -653,7 +773,9 @@ bool TPrsStd_AISPresentation::BeforeUndo(const occ::handle& if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) { if (!P.IsNull()) + { P->BeforeForget(); + } } else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) { @@ -661,7 +783,9 @@ bool TPrsStd_AISPresentation::BeforeUndo(const occ::handle& else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) { if (!P.IsNull()) + { P->BeforeForget(); + } } return true; @@ -680,12 +804,16 @@ bool TPrsStd_AISPresentation::AfterUndo(const occ::handle& A else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) { if (!P.IsNull()) + { P->AfterAddition(); + } } else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) { if (!P.IsNull()) + { P->AfterResume(); + } } return true; @@ -719,20 +847,26 @@ void TPrsStd_AISPresentation::AISUpdate() { occ::handle anObj = myAIS; if (aDriver->Update(Label(), anObj)) + { if (!(anObj == myAIS)) { if (!aContext.IsNull()) + { aContext->Remove(myAIS, false); + } // Driver has built new AIS. myAIS = anObj; anObj->SetOwner(this); } + } } } } else + { return; + } // Apply the visualization settings. if (!myAIS.IsNull()) @@ -745,9 +879,13 @@ void TPrsStd_AISPresentation::AISUpdate() if (!(myAIS->HasColor()) || (myAIS->HasColor() && aPrsColor.Name() != aColor)) { if (!aContext.IsNull()) + { aContext->SetColor(myAIS, aColor, false); + } else + { myAIS->SetColor(aColor); + } } } @@ -757,9 +895,13 @@ void TPrsStd_AISPresentation::AISUpdate() if (!(myAIS->HasMaterial()) || (myAIS->HasMaterial() && myAIS->Material() != aMaterial)) { if (!aContext.IsNull()) + { aContext->SetMaterial(myAIS, aMaterial, false); + } else + { myAIS->SetMaterial(aMaterial); + } } } @@ -769,9 +911,13 @@ void TPrsStd_AISPresentation::AISUpdate() if (myAIS->Transparency() != aTransparency) { if (!aContext.IsNull()) + { aContext->SetTransparency(myAIS, aTransparency, false); + } else + { myAIS->SetTransparency(aTransparency); + } } } @@ -781,9 +927,13 @@ void TPrsStd_AISPresentation::AISUpdate() if (!(myAIS->HasWidth()) || (myAIS->HasWidth() && myAIS->Width() != aWidth)) { if (!aContext.IsNull()) + { aContext->SetWidth(myAIS, aWidth, false); + } else + { myAIS->SetWidth(aWidth); + } } } @@ -791,14 +941,18 @@ void TPrsStd_AISPresentation::AISUpdate() { const int aMode = Mode(); if (myAIS->DisplayMode() != aMode) + { myAIS->SetDisplayMode(aMode); + } } ActivateSelectionMode(); } if (IsDisplayed() && !aContext.IsNull()) + { aContext->Redisplay(myAIS, false); + } } //================================================================================================= @@ -810,20 +964,28 @@ void TPrsStd_AISPresentation::AISDisplay() occ::handle aContext = getAISContext(); if (aContext.IsNull()) + { return; + } if (!myAIS.IsNull()) { if (!(myAIS->GetContext()).IsNull() && (myAIS->GetContext()) != aContext) + { myAIS->GetContext()->Remove(myAIS, false); + } if (IsDisplayed() && aContext->IsDisplayed(myAIS)) + { return; + } aContext->Display(myAIS, false); if (aContext->IsDisplayed(myAIS)) + { SetDisplayed(true); + } } } } @@ -840,29 +1002,41 @@ void TPrsStd_AISPresentation::AISErase(const bool theIsRemove) if (!Label().IsNull()) { if (IsAttribute(TDataXtd_Presentation::GetID())) + { SetDisplayed(false); + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(Label(), viewer)) + { return; + } anOwnContext = myAIS->GetContext(); aContext = viewer->GetInteractiveContext(); if (theIsRemove) { if (!aContext.IsNull()) + { aContext->Remove(myAIS, false); + } if (!anOwnContext.IsNull() && anOwnContext != aContext) + { anOwnContext->Remove(myAIS, false); + } myAIS.Nullify(); } else { if (!aContext.IsNull()) + { aContext->Erase(myAIS, false); + } if (!anOwnContext.IsNull() && anOwnContext != aContext) + { anOwnContext->Erase(myAIS, false); + } } } else @@ -876,7 +1050,9 @@ void TPrsStd_AISPresentation::AISErase(const bool theIsRemove) } } else if (!anOwnContext.IsNull()) + { anOwnContext->Erase(myAIS, false); + } } } } @@ -894,7 +1070,9 @@ occ::handle TPrsStd_AISPresentation::getAISContext() con { occ::handle aViewer; if (TPrsStd_AISViewer::Find(Label(), aViewer)) + { return aViewer->GetInteractiveContext(); + } return occ::handle(); } @@ -931,10 +1109,12 @@ void TPrsStd_AISPresentation::ActivateSelectionMode() } } if (!isActivated) + { aContext->SetSelectionModeActive(myAIS, aSelectionMode, true, AIS_SelectionModesConcurrency_Multiple); + } } } else diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISViewer.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISViewer.cxx index 6a710394a2..cee632a408 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISViewer.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AISViewer.cxx @@ -135,7 +135,9 @@ void TPrsStd_AISViewer::Update(const TDF_Label& acces) { occ::handle viewer; if (Find(acces, viewer)) + { viewer->Update(); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AxisDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AxisDriver.cxx index d9cd30fbd9..6e4e97b9a4 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AxisDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_AxisDriver.cxx @@ -59,12 +59,16 @@ bool TPrsStd_AxisDriver::Update(const TDF_Label& aLabel, // Update de l'AIS if (anAISObject.IsNull()) + { aistrihed = new AIS_Axis(apt); + } else { aistrihed = occ::down_cast(anAISObject); if (aistrihed.IsNull()) + { aistrihed = new AIS_Axis(apt); + } else { aistrihed->SetComponent(apt); diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintDriver.cxx index c317aff7f0..5512a0f942 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintDriver.cxx @@ -147,7 +147,9 @@ bool TPrsStd_ConstraintDriver::Update(const TDF_Label& aLabel } } if (anAIS.IsNull()) + { return false; + } anAIS->ResetTransformation(); anAIS->SetToUpdate(); @@ -168,15 +170,21 @@ bool TPrsStd_ConstraintDriver::Update(const TDF_Label& aLabel if (!apConstraint->Verified()) { if (originColor.Name() != Quantity_NOC_RED) + { anAISObject->SetColor(Quantity_NOC_RED); + } } else if (apConstraint->IsDimension() && apConstraint->GetValue()->IsCaptured()) { if (originColor.Name() != Quantity_NOC_PURPLE) + { anAISObject->SetColor(Quantity_NOC_PURPLE); + } } else if (!apConstraint->IsPlanar() && (originColor.Name() != Quantity_NOC_YELLOW)) + { anAISObject->SetColor(Quantity_NOC_YELLOW); + } } else { @@ -189,7 +197,9 @@ bool TPrsStd_ConstraintDriver::Update(const TDF_Label& aLabel anAISObject->SetColor(Quantity_NOC_PURPLE); } else if (!apConstraint->IsPlanar()) + { anAISObject->SetColor(Quantity_NOC_YELLOW); + } } return true; } diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintTools.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintTools.cxx index b65f3ddc23..6f4e415d00 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintTools.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_ConstraintTools.cxx @@ -91,7 +91,9 @@ static bool CheckShapesPair(const TopoDS_Shape&, const TopoDS_Shape&); // ota static void NullifyAIS(occ::handle& anais) { if (anais.IsNull()) + { return; + } anais.Nullify(); } @@ -102,9 +104,13 @@ static void FindExternalShape(const occ::handle& aConst, in extShape = 0; const TDF_Label& L = aConst->Label(); if (!aConst->GetGeometry(1)->Label().IsDescendant(L)) + { extShape = 1; + } else if (!aConst->GetGeometry(2)->Label().IsDescendant(L)) + { extShape = 2; + } } //================================================================================================= @@ -142,7 +148,9 @@ static bool IsFace(const TopoDS_Shape& S) bool findface = false; TopExp_Explorer EXP(S, TopAbs_FACE); if (EXP.More()) + { findface = true; + } return findface; } @@ -151,7 +159,9 @@ static TopoDS_Face GetFace(const TopoDS_Shape& S) TopoDS_Face F; TopExp_Explorer EXP(S, TopAbs_FACE); if (EXP.More()) + { F = TopoDS::Face(EXP.Current()); + } return F; } @@ -160,7 +170,9 @@ static TopoDS_Edge GetEdge(const TopoDS_Shape& S) TopoDS_Edge E; TopExp_Explorer EXP(S, TopAbs_EDGE); if (EXP.More()) + { E = TopoDS::Edge(EXP.Current()); + } return E; } @@ -201,7 +213,9 @@ void TPrsStd_ConstraintTools::ComputeTextAndValue(const occ::handleGet() + TCollection_ExtendedString(".") + name->Get(); } else + { fullname = name->Get(); + } txt = fullname + TCollection_ExtendedString("=") + txt; } } @@ -213,9 +227,13 @@ void TPrsStd_ConstraintTools::UpdateOnlyValue(const occ::handle& anAIS) { if (anAIS.IsNull()) + { return; + } if (!aConst->IsDimension()) + { return; + } double val; TCollection_ExtendedString txt; TPrsStd_ConstraintTools::ComputeTextAndValue(aConst, @@ -224,7 +242,9 @@ void TPrsStd_ConstraintTools::UpdateOnlyValue(const occ::handleGetType() == TDataXtd_ANGLE); occ::handle rel = occ::down_cast(anAIS); if (!rel.IsNull()) + { rel->SetText(txt); + } } //================================================================================================= @@ -515,9 +535,13 @@ void TPrsStd_ConstraintTools::computePerpendicularImpl( bool is_planar(aConst->IsPlanar()); if (is_planar) + { GetShapesAndGeom(aConst, shape1, shape2, ageom3); + } else + { GetTwoShapes(aConst, shape1, shape2); + } if (shape1.IsNull() || shape2.IsNull()) { #ifdef OCCT_DEBUG @@ -531,7 +555,9 @@ void TPrsStd_ConstraintTools::computePerpendicularImpl( // Update de l'AIS occ::handle ais; if (anAIS.IsNull()) + { ais = new PrsDim_PerpendicularRelation(shape1, shape2); + } else { ais = occ::down_cast(anAIS); @@ -632,7 +658,9 @@ void TPrsStd_ConstraintTools::computeParallelImpl(const occ::handle ais; if (anAIS.IsNull()) + { ais = new PrsDim_ParallelRelation(shape1, shape2, aplane); + } else { ais = occ::down_cast(anAIS); @@ -722,7 +750,9 @@ void TPrsStd_ConstraintTools::computeSymmetryImpl(const occ::handle ais; if (anAIS.IsNull()) + { ais = new PrsDim_SymmetricRelation(shape3, shape1, shape2, aplane); + } else { ais = occ::down_cast(anAIS); @@ -815,7 +845,9 @@ void TPrsStd_ConstraintTools::computeMidPointImpl(const occ::handle ais; if (anAIS.IsNull()) + { ais = new PrsDim_MidPointRelation(shape3, shape1, shape2, aplane); + } else { ais = occ::down_cast(anAIS); @@ -1083,7 +1115,9 @@ void TPrsStd_ConstraintTools::computeAngleImpl(const occ::handleIsKind(STANDARD_TYPE(Geom_Plane))) + { isplan = true; + } else if (ageom3->IsKind(STANDARD_TYPE(Geom_Line))) + { isplan = false; + } else { #ifdef OCCT_DEBUG @@ -1290,7 +1330,9 @@ void TPrsStd_ConstraintTools::computeAngleImpl(const occ::handleSetMeasuredGeometry(TopoDS::Face(shape1), TopoDS::Face(shape2)); if (isplan) + { ais->SetCustomPlane(occ::down_cast(ageom3)->Pln()); + } else if (!isCurvilinear) { gp_Pln aPlane; @@ -1457,7 +1499,9 @@ void TPrsStd_ConstraintTools::computeRadiusImpl(const occ::handleIsPlanar()); if (isplanar) + { GetGoodShape(shape1); + } occ::handle ais; if (!anAIS.IsNull()) @@ -1482,7 +1528,9 @@ void TPrsStd_ConstraintTools::computeRadiusImpl(const occ::handleIsPlanar()); if (isplanar) + { GetGoodShape(shape1); + } occ::handle ais; if (!anAIS.IsNull()) @@ -1587,7 +1639,9 @@ void TPrsStd_ConstraintTools::computeMinRadiusImpl(const occ::handleIsPlanar()); if (isplanar) + { GetGoodShape(shape1); + } occ::handle ais; if (!anAIS.IsNull()) @@ -1691,7 +1749,9 @@ void TPrsStd_ConstraintTools::computeMaxRadiusImpl(const occ::handleIsPlanar()); occ::handle aPlane; if (IsPlanar) + { aPlane = occ::down_cast(aGeom); + } if (!IsPlanar || aPlane.IsNull()) { @@ -1797,8 +1859,9 @@ void TPrsStd_ConstraintTools::computeEqualDistanceImpl( ais = occ::down_cast(anAIS); if (ais.IsNull()) + { ais = new PrsDim_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane); - + } else { ais->SetFirstShape(aShape1); @@ -1810,11 +1873,11 @@ void TPrsStd_ConstraintTools::computeEqualDistanceImpl( } } else + { ais = new PrsDim_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane); + } anAIS = ais; - - return; } //================================================================================================= @@ -1943,7 +2006,9 @@ void TPrsStd_ConstraintTools::computeEqualRadiusImpl(const occ::handle aplane; if (IsPlanar) + { aplane = occ::down_cast(ageom3); + } if (!IsPlanar || aplane.IsNull()) { @@ -1970,7 +2035,9 @@ void TPrsStd_ConstraintTools::computeEqualRadiusImpl(const occ::handleIsPlanar()); if (IsPlanar) + { GetGoodShape(shape1); + } occ::handle ais; if (!anAIS.IsNull()) { @@ -2072,7 +2141,9 @@ void TPrsStd_ConstraintTools::computeDiameterImpl(const occ::handleNbGeometries(); if (nbgeom < 2) + { throw Standard_ProgramError( "TPrsStd_ConstraintTools::ComputePlacement: at leat two constraints are needed"); + } TopoDS_Shape shape1, shape2; GetTwoShapes(aConst, shape1, shape2); @@ -2457,7 +2534,9 @@ void TPrsStd_ConstraintTools::computePlacementImpl(const occ::handle { const occ::handle& ageom1 = aConst->GetGeometry(1); if (!ageom1.IsNull()) + { aShape = TNaming_Tool::CurrentShape(ageom1); + } } //================================================================================================= @@ -2504,10 +2585,14 @@ void TPrsStd_ConstraintTools::GetTwoShapes(const occ::handle& ageom1 = aConst->GetGeometry(1); if (!ageom1.IsNull()) + { aShape1 = TNaming_Tool::CurrentShape(aConst->GetGeometry(1)); + } const occ::handle& ageom2 = aConst->GetGeometry(2); if (!ageom2.IsNull()) + { aShape2 = TNaming_Tool::CurrentShape(aConst->GetGeometry(2)); + } } //================================================================================================= @@ -2532,7 +2617,9 @@ void TPrsStd_ConstraintTools::GetShapesAndGeom(const occ::handle& ageom3 = aConst->GetGeometry(3); // ota: GetGeometry(2) was if (!ageom3.IsNull()) + { aShape3 = TNaming_Tool::CurrentShape(aConst->GetGeometry(3)); + } GetGeom(aConst, aGeom); } @@ -2548,10 +2635,14 @@ void TPrsStd_ConstraintTools::GetShapesAndGeom(const occ::handle& ageom3 = aConst->GetGeometry(3); if (!ageom3.IsNull()) + { aShape3 = TNaming_Tool::CurrentShape(aConst->GetGeometry(3)); + } const occ::handle& ageom4 = aConst->GetGeometry(4); if (!ageom4.IsNull()) + { aShape4 = TNaming_Tool::CurrentShape(aConst->GetGeometry(4)); + } GetGeom(aConst, aGeom); } @@ -2626,7 +2717,9 @@ void TPrsStd_ConstraintTools::computeCoincidentImpl(const occ::handle ais; if (anAIS.IsNull()) + { ais = new PrsDim_IdenticRelation(shape1, shape2, aplane); + } else { ais = occ::down_cast(anAIS); @@ -2700,7 +2793,9 @@ void TPrsStd_ConstraintTools::computeRoundImpl(const occ::handle(anAIS); @@ -2746,15 +2841,23 @@ void TPrsStd_ConstraintTools::GetGeom(const occ::handle& aC { TopoDS_Shape s = TNaming_Tool::GetShape(NS); if (s.IsNull()) + { return; + } } if (TDataXtd_Geometry::Plane(label, aplane)) + { aGeom = new Geom_Plane(aplane); + } else if (TDataXtd_Geometry::Line(label, anaxis)) + { aGeom = new Geom_Line(anaxis); + } else if (TDataXtd_Geometry::Point(label, apoint)) + { aGeom = new Geom_CartesianPoint(apoint); + } #ifdef OCCT_DEBUG else { diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_DriverTable.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_DriverTable.cxx index 1b605416cd..1509e5003b 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_DriverTable.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_DriverTable.cxx @@ -63,7 +63,9 @@ TPrsStd_DriverTable::TPrsStd_DriverTable() void TPrsStd_DriverTable::InitStandardDrivers() { if (myDrivers.Extent() > 0) + { return; + } occ::handle axisdrv = new TPrsStd_AxisDriver; occ::handle cnstrdrv = new TPrsStd_ConstraintDriver; diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_GeometryDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_GeometryDriver.cxx index 16d9befc10..0b24617155 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_GeometryDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_GeometryDriver.cxx @@ -71,16 +71,22 @@ bool TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, case TDataXtd_POINT: { gp_Pnt pt; if (!TDataXtd_Geometry::Point(aLabel, pt)) + { return false; + } occ::handle apt = new Geom_CartesianPoint(pt); occ::handle ais1; if (anAISObject.IsNull()) + { ais1 = new AIS_Point(apt); + } else { ais1 = occ::down_cast(anAISObject); if (ais1.IsNull()) + { ais1 = new AIS_Point(apt); + } else { ais1->SetComponent(apt); @@ -96,16 +102,22 @@ bool TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, case TDataXtd_LINE: { gp_Lin ln; if (!TDataXtd_Geometry::Line(aLabel, ln)) + { return false; + } occ::handle aln = new Geom_Line(ln); occ::handle ais2; if (anAISObject.IsNull()) + { ais2 = new AIS_Line(aln); + } else { ais2 = occ::down_cast(anAISObject); if (ais2.IsNull()) + { ais2 = new AIS_Line(aln); + } else { ais2->SetLine(aln); @@ -123,16 +135,22 @@ bool TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, occ::handle ais2; gp_Circ cir; if (!TDataXtd_Geometry::Circle(aLabel, cir)) + { return false; + } occ::handle acir = new Geom_Circle(cir); occ::handle ais3; if (anAISObject.IsNull()) + { ais3 = new AIS_Circle(acir); + } else { ais3 = occ::down_cast(anAISObject); if (ais3.IsNull()) + { ais3 = new AIS_Circle(acir); + } else { ais3->SetCircle(acir); @@ -148,18 +166,26 @@ bool TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel, case TDataXtd_ELLIPSE: { gp_Elips elp; if (!TDataXtd_Geometry::Ellipse(aLabel, elp)) + { return false; + } BRepBuilderAPI_MakeEdge mkEdge(elp); if (!mkEdge.IsDone()) + { return false; + } occ::handle ais; if (anAISObject.IsNull()) + { ais = new AIS_Shape(mkEdge); + } else { ais = occ::down_cast(anAISObject); if (ais.IsNull()) + { ais = new AIS_Shape(mkEdge); + } else { ais->ResetTransformation(); diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_NamedShapeDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_NamedShapeDriver.cxx index 6b632014d2..1f52c03233 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_NamedShapeDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_NamedShapeDriver.cxx @@ -66,7 +66,9 @@ bool TPrsStd_NamedShapeDriver::Update(const TDF_Label& aLabel occ::handle AISShape; if (AIS.IsNull()) + { AISShape = new AIS_Shape(S); + } else { AISShape = occ::down_cast(AIS); diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PlaneDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PlaneDriver.cxx index 93b1751855..19cbc31fd8 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PlaneDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PlaneDriver.cxx @@ -52,12 +52,16 @@ bool TPrsStd_PlaneDriver::Update(const TDF_Label& aLabel, // Update AIS occ::handle aisplane; if (anAISObject.IsNull()) + { aisplane = new AIS_Plane(apt, pln.Location()); + } else { aisplane = occ::down_cast(anAISObject); if (aisplane.IsNull()) + { aisplane = new AIS_Plane(apt, pln.Location()); + } else { aisplane->SetComponent(apt); diff --git a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PointDriver.cxx b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PointDriver.cxx index 85f04c559c..9e8c32e045 100644 --- a/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PointDriver.cxx +++ b/src/ApplicationFramework/TKVCAF/TPrsStd/TPrsStd_PointDriver.cxx @@ -51,12 +51,16 @@ bool TPrsStd_PointDriver::Update(const TDF_Label& aLabel, // Update de l'AIS occ::handle aistrihed; if (anAISObject.IsNull()) + { aistrihed = new AIS_Point(apt); + } else { aistrihed = occ::down_cast(anAISObject); if (aistrihed.IsNull()) + { aistrihed = new AIS_Point(apt); + } else { aistrihed->SetComponent(apt); diff --git a/src/ApplicationFramework/TKXml/XmlDrivers/XmlDrivers_DocumentRetrievalDriver.cxx b/src/ApplicationFramework/TKXml/XmlDrivers/XmlDrivers_DocumentRetrievalDriver.cxx index 2ba5ae64a9..e7080fb018 100644 --- a/src/ApplicationFramework/TKXml/XmlDrivers/XmlDrivers_DocumentRetrievalDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlDrivers/XmlDrivers_DocumentRetrievalDriver.cxx @@ -46,7 +46,9 @@ occ::handle XmlDrivers_DocumentRetrievalDriver::ReadShapeSection const Message_ProgressRange& theRange) { if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(theMsgDriver); + } occ::handle aDriver; if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver)) { @@ -67,5 +69,7 @@ void XmlDrivers_DocumentRetrievalDriver::ShapeSetCleaning( occ::handle aNamedShapeDriver = occ::down_cast(theDriver); if (!aNamedShapeDriver.IsNull()) + { aNamedShapeDriver->Clear(); + } } diff --git a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_ConstraintDriver.cxx b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_ConstraintDriver.cxx index 506af5e352..b1b3b7275a 100644 --- a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_ConstraintDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_ConstraintDriver.cxx @@ -106,7 +106,9 @@ bool XmlMDataXtd_ConstraintDriver::Paste(const XmlObjMgt_Persistent& theSo if (aNb > 0) { if (theRelocTable.IsBound(aNb)) + { aTValue = occ::down_cast(theRelocTable.Find(aNb)); + } else { aTValue = new TDataStd_Real; @@ -137,7 +139,9 @@ bool XmlMDataXtd_ConstraintDriver::Paste(const XmlObjMgt_Persistent& theSo { occ::handle aG; if (theRelocTable.IsBound(aNb)) + { aG = occ::down_cast(theRelocTable.Find(aNb)); + } else { aG = new TNaming_NamedShape; @@ -147,7 +151,9 @@ bool XmlMDataXtd_ConstraintDriver::Paste(const XmlObjMgt_Persistent& theSo // next geometry if (!XmlObjMgt::GetInteger(aGs, aNb)) + { aNb = 0; + } i++; } } @@ -168,7 +174,9 @@ bool XmlMDataXtd_ConstraintDriver::Paste(const XmlObjMgt_Persistent& theSo if (aNb > 0) { if (theRelocTable.IsBound(aNb)) + { aTPlane = occ::down_cast(theRelocTable.Find(aNb)); + } else { aTPlane = new TNaming_NamedShape; @@ -236,7 +244,9 @@ void XmlMDataXtd_ConstraintDriver::Paste(const occ::handle& theSo aGsStr += TCollection_AsciiString(aNb) + " "; } else + { aGsStr += "0 "; + } } anElem.setAttribute(::GeometriesString(), aGsStr.ToCString()); } @@ -260,19 +270,31 @@ void XmlMDataXtd_ConstraintDriver::Paste(const occ::handle& theSo TCollection_AsciiString aStatusStr; if (aC->Verified()) + { aStatusStr += "+"; + } else + { aStatusStr += "-"; + } if (aC->Inverted()) + { aStatusStr += "+"; + } else + { aStatusStr += "-"; + } if (aC->Reversed()) + { aStatusStr += "+"; + } else + { aStatusStr += "-"; + } anElem.setAttribute(::StatusString(), aStatusStr.ToCString()); } @@ -286,59 +308,111 @@ static TDataXtd_ConstraintEnum ConstraintTypeEnum(const XmlObjMgt_DOMString& the if (!theString.equals(::ConRadiusString())) { if (theString.equals(::ConDiameterString())) + { aResult = TDataXtd_DIAMETER; + } else if (theString.equals(::ConMinRadiusString())) + { aResult = TDataXtd_MINOR_RADIUS; + } else if (theString.equals(::ConMajRadiusString())) + { aResult = TDataXtd_MAJOR_RADIUS; + } else if (theString.equals(::ConTangentString())) + { aResult = TDataXtd_TANGENT; + } else if (theString.equals(::ConParallelString())) + { aResult = TDataXtd_PARALLEL; + } else if (theString.equals(::ConPerpendicularString())) + { aResult = TDataXtd_PERPENDICULAR; + } else if (theString.equals(::ConConcentricString())) + { aResult = TDataXtd_CONCENTRIC; + } else if (theString.equals(::ConCoincidentString())) + { aResult = TDataXtd_COINCIDENT; + } else if (theString.equals(::ConDistanceString())) + { aResult = TDataXtd_DISTANCE; + } else if (theString.equals(::ConAngleString())) + { aResult = TDataXtd_ANGLE; + } else if (theString.equals(::ConEqualRadiusString())) + { aResult = TDataXtd_EQUAL_RADIUS; + } else if (theString.equals(::ConSymmetryString())) + { aResult = TDataXtd_SYMMETRY; + } else if (theString.equals(::ConMidPointString())) + { aResult = TDataXtd_MIDPOINT; + } else if (theString.equals(::ConEqualDistanceString())) + { aResult = TDataXtd_EQUAL_DISTANCE; + } else if (theString.equals(::ConFixString())) + { aResult = TDataXtd_FIX; + } else if (theString.equals(::ConRigidString())) + { aResult = TDataXtd_RIGID; - // placement constraints + // placement constraints + } else if (theString.equals(::ConFromString())) + { aResult = TDataXtd_FROM; + } else if (theString.equals(::ConAxisString())) + { aResult = TDataXtd_AXIS; + } else if (theString.equals(::ConMateString())) + { aResult = TDataXtd_MATE; + } else if (theString.equals(::ConAlignFacesString())) + { aResult = TDataXtd_ALIGN_FACES; + } else if (theString.equals(::ConAlignAxesString())) + { aResult = TDataXtd_ALIGN_AXES; + } else if (theString.equals(::ConAxesAngleString())) + { aResult = TDataXtd_AXES_ANGLE; + } else if (theString.equals(::ConFacesAngleString())) + { aResult = TDataXtd_FACES_ANGLE; + } else if (theString.equals(::ConRoundString())) + { aResult = TDataXtd_ROUND; + } else if (theString.equals(::ConOffsetString())) + { aResult = TDataXtd_OFFSET; + } else + { throw Standard_DomainError( "TDataXtd_ConstraintEnum; string value without enum term equivalence"); + } } return aResult; } diff --git a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_GeometryDriver.cxx b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_GeometryDriver.cxx index c7b2165e12..18057e721f 100644 --- a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_GeometryDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_GeometryDriver.cxx @@ -92,21 +92,37 @@ static bool GeometryTypeEnum(const XmlObjMgt_DOMString& theString, TDataXtd_Geom if (!theString.equals(::GeomAnyString())) { if (theString.equals(::GeomPointString())) + { aResult = TDataXtd_POINT; + } else if (theString.equals(::GeomLineString())) + { aResult = TDataXtd_LINE; + } else if (theString.equals(::GeomCircleString())) + { aResult = TDataXtd_CIRCLE; + } else if (theString.equals(::GeomEllipseString())) + { aResult = TDataXtd_ELLIPSE; + } else if (theString.equals(::GeomSplineString())) + { aResult = TDataXtd_SPLINE; + } else if (theString.equals(::GeomPlaneString())) + { aResult = TDataXtd_PLANE; + } else if (theString.equals(::GeomCylinderString())) + { aResult = TDataXtd_CYLINDER; + } else + { return false; + } } theResult = aResult; return true; diff --git a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PatternStdDriver.cxx b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PatternStdDriver.cxx index 1dcd77d6db..433deafd6e 100644 --- a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PatternStdDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PatternStdDriver.cxx @@ -99,7 +99,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -116,7 +118,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TReal = occ::down_cast(theRelocTable.Find(aNb)); + } else { TReal = new TDataStd_Real; @@ -133,7 +137,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TInt = occ::down_cast(theRelocTable.Find(aNb)); + } else { TInt = new TDataStd_Integer; @@ -152,7 +158,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -169,7 +177,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TReal = occ::down_cast(theRelocTable.Find(aNb)); + } else { TReal = new TDataStd_Real; @@ -186,7 +196,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TInt = occ::down_cast(theRelocTable.Find(aNb)); + } else { TInt = new TDataStd_Integer; @@ -206,7 +218,9 @@ bool XmlMDataXtd_PatternStdDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (theRelocTable.IsBound(aNb)) + { TNS = occ::down_cast(theRelocTable.Find(aNb)); + } else { TNS = new TNaming_NamedShape; @@ -230,9 +244,13 @@ void XmlMDataXtd_PatternStdDriver::Paste(const occ::handle& theSo anElem.setAttribute(::SignatureString(), signature); if (aP->Axis1Reversed()) + { anElem.setAttribute(::Axis1RevString(), ::TrueString()); + } if (aP->Axis2Reversed()) + { anElem.setAttribute(::Axis2RevString(), ::TrueString()); + } occ::handle TNS; occ::handle TReal; diff --git a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PresentationDriver.cxx b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PresentationDriver.cxx index 81ff4af8af..e85abe6d24 100644 --- a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PresentationDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_PresentationDriver.cxx @@ -183,7 +183,9 @@ void XmlMDataXtd_PresentationDriver::Paste(const occ::handle& the { occ::handle aTPrs = occ::down_cast(theSource); if (aTPrs.IsNull()) + { return; + } // convert GUID into attribute value char aGuidStr[40]; @@ -194,7 +196,9 @@ void XmlMDataXtd_PresentationDriver::Paste(const occ::handle& the // is displayed if (aTPrs->IsDisplayed()) + { theTarget.Element().setAttribute(::IsDisplayedString(), ::DisplayedString()); + } int aNb; diff --git a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_TriangulationDriver.cxx b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_TriangulationDriver.cxx index 099e8323cd..9dd58412e1 100644 --- a/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_TriangulationDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMDataXtd/XmlMDataXtd_TriangulationDriver.cxx @@ -102,9 +102,13 @@ bool XmlMDataXtd_TriangulationDriver::Paste(const XmlObjMgt_Persistent& th occ::handle PT; if (hasUV) + { PT = new Poly_Triangulation(Nodes, UVNodes, Triangles); + } else + { PT = new Poly_Triangulation(Nodes, Triangles); + } PT->Deflection(deflection); attribute->Set(PT); @@ -121,7 +125,9 @@ void XmlMDataXtd_TriangulationDriver::Paste(const occ::handle& th const occ::handle attribute = occ::down_cast(theSource); if (attribute->Get().IsNull()) + { theTarget.Element().setAttribute(::TriangString(), ::NullString()); + } else { theTarget.Element().setAttribute(::TriangString(), ::ExistString()); @@ -136,13 +142,16 @@ void XmlMDataXtd_TriangulationDriver::Paste(const occ::handle& th int size = PT->NbNodes(); // clang-format off size *= 3 * 25; // 3 coordinates for a node * 25 characters are used to represent a coordinate (double) in XML - if (PT->HasUVNodes()) + if (PT->HasUVNodes()) { size += 2 * 25 * nbNodes; // 2 coordinates for a 2D node * 25 characters are used to represent a coordinate (double) in XML +} // clang-format on size += 3 * 10 * nbTriangles; // space for triangles size *= 2; // just in case :-) if (!size) + { size = 1; + } // Allocate a string stream. LDOM_OSStream stream(size); @@ -191,7 +200,9 @@ void XmlMDataXtd_TriangulationDriver::GetReal(Standard_IStream& IS, double& theV { theValue = 0.; if (IS.eof()) + { return; + } char buffer[256]; buffer[0] = '\0'; diff --git a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx index c3a857d28b..6d5a137cce 100644 --- a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx @@ -84,7 +84,9 @@ bool XmlMNaming_NamedShapeDriver::Paste(const XmlObjMgt_Persistent& theSou const XmlObjMgt_Element& anElement = theSource; XmlObjMgt_DOMString aVerString = anElement.getAttribute(::VersionString()); if (aVerString != nullptr) + { aVerString.GetInteger(aVersion); + } // Get Evolution status XmlObjMgt_DOMString aStatus = anElement.getAttribute(::StatusString()); @@ -95,7 +97,9 @@ bool XmlMNaming_NamedShapeDriver::Paste(const XmlObjMgt_Persistent& theSou const XmlObjMgt_Array1 OldPShapes(anElement, ::OldsString()); const XmlObjMgt_Array1 NewPShapes(anElement, ::NewsString()); if (NewPShapes.Length() == 0 && OldPShapes.Length() == 0) + { return true; + } TopoDS_Shape anOldShape; TopoDS_Shape aNewShape; @@ -103,11 +107,15 @@ bool XmlMNaming_NamedShapeDriver::Paste(const XmlObjMgt_Persistent& theSou int lower = NewPShapes.Lower(); if (OldPShapes.Lower() < lower) + { lower = OldPShapes.Lower(); + } int upper = NewPShapes.Upper(); if (OldPShapes.Upper() > upper) + { upper = OldPShapes.Upper(); + } for (int i = upper; i >= lower; --i) { @@ -220,7 +228,9 @@ void XmlMNaming_NamedShapeDriver::Paste(const occ::handle& theSou theTarget.Element().setAttribute(::StatusString(), EvolutionString(evol)); int aVersion = aNamedShape->Version(); if (aVersion != 0) + { theTarget.Element().setAttribute(::VersionString(), aVersion); + } } //================================================================================================= @@ -255,17 +265,29 @@ static TNaming_Evolution EvolutionEnum(const XmlObjMgt_DOMString& theString) if (!theString.equals(::EvolPrimitiveString())) { if (theString.equals(::EvolGeneratedString())) + { aResult = TNaming_GENERATED; + } else if (theString.equals(::EvolModifyString())) + { aResult = TNaming_MODIFY; + } else if (theString.equals(::EvolDeleteString())) + { aResult = TNaming_DELETE; + } else if (theString.equals(::EvolSelectedString())) + { aResult = TNaming_SELECTED; + } else if (theString.equals(::EvolReplaceString())) + { aResult = TNaming_MODIFY; // for compatibility //TNaming_REPLACE; + } else + { throw Standard_DomainError("TNaming_Evolution; string value without enum term equivalence"); + } } return aResult; } @@ -278,7 +300,9 @@ static void doTranslate(const TopoDS_Shape& theShape, { // Check for empty shape if (theShape.IsNull()) + { return; + } // Add to shape set both TShape and Location contained in theShape const int aTShapeId = theShapeSet.Add(theShape); @@ -303,7 +327,9 @@ static int doTranslate(const XmlMNaming_Shape1& thePShape, // Read TShape and Orientation if (aShapeId <= 0 || aShapeId > theShapeSet.NbShapes()) + { return 1; + } theResult.TShape(theShapeSet.Shape(aShapeId).TShape()); theResult.Orientation(thePShape.Orientation()); theResult.Location(theShapeSet.Locations().Location(thePShape.LocId()), false); @@ -363,7 +389,9 @@ void XmlMNaming_NamedShapeDriver::WriteShapeSection(XmlObjMgt_Element& theEle Message_ProgressScope aPS(theRange, "Writing shape section", 2); myShapeSet.Write(aStream, aPS.Next()); if (!aPS.More()) + { return; + } aStream << std::ends; char* aStr = const_cast(aStream.str()); @@ -376,7 +404,9 @@ void XmlMNaming_NamedShapeDriver::WriteShapeSection(XmlObjMgt_Element& theEle BRepTools_ShapeSet& aShapeSet = (BRepTools_ShapeSet&)myShapeSet; aShapeSet.Clear(); if (!aPS.More()) + { return; + } aPS.Next(); } } diff --git a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamingDriver.cxx b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamingDriver.cxx index 298292432e..02cc33a0ba 100644 --- a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamingDriver.cxx +++ b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_NamingDriver.cxx @@ -113,7 +113,9 @@ bool XmlMNaming_NamingDriver::Paste(const XmlObjMgt_Persistent& theSource, while (aNb > 0) { if (theRelocTable.IsBound(aNb)) + { NS = occ::down_cast(theRelocTable.Find(aNb)); + } else { NS = new TNaming_NamedShape; @@ -123,7 +125,9 @@ bool XmlMNaming_NamingDriver::Paste(const XmlObjMgt_Persistent& theSource, // next argument if (!XmlObjMgt::GetInteger(aGs, aNb)) + { aNb = 0; + } } } @@ -142,7 +146,9 @@ bool XmlMNaming_NamingDriver::Paste(const XmlObjMgt_Persistent& theSource, if (aNb > 0) { if (theRelocTable.IsBound(aNb)) + { NS = occ::down_cast(theRelocTable.Find(aNb)); + } else { NS = new TNaming_NamedShape; @@ -210,7 +216,9 @@ bool XmlMNaming_NamingDriver::Paste(const XmlObjMgt_Persistent& theSource, { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) + { continue; + } if (aNS->Evolution() == TNaming_SELECTED) { if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX @@ -284,7 +292,9 @@ void XmlMNaming_NamingDriver::Paste(const occ::handle& theSource, anArgsStr += TCollection_AsciiString(aNb) + " "; } else + { anArgsStr += "0 "; + } } anElem.setAttribute(::ArgumentsString(), anArgsStr.ToCString()); } @@ -307,7 +317,9 @@ void XmlMNaming_NamingDriver::Paste(const occ::handle& theSource, // context label TCollection_AsciiString anEntry; if (!aNgName.ContextLabel().IsNull()) + { TDF_Tool::Entry(aNgName.ContextLabel(), anEntry); + } XmlObjMgt_DOMString aDOMString; XmlObjMgt::SetTagEntryString(aDOMString, anEntry); anElem.setAttribute(::ContextLabelString(), aDOMString); @@ -398,23 +410,41 @@ static TopAbs_ShapeEnum ShapeEnumFromString(const XmlObjMgt_DOMString& theString if (!theString.equals(::ShShapeString())) { if (theString.equals(::ShCompoundString())) + { aResult = TopAbs_COMPOUND; + } else if (theString.equals(::ShCompsolidString())) + { aResult = TopAbs_COMPSOLID; + } else if (theString.equals(::ShSolidString())) + { aResult = TopAbs_SOLID; + } else if (theString.equals(::ShShellString())) + { aResult = TopAbs_SHELL; + } else if (theString.equals(::ShFaceString())) + { aResult = TopAbs_FACE; + } else if (theString.equals(::ShWireString())) + { aResult = TopAbs_WIRE; + } else if (theString.equals(::ShEdgeString())) + { aResult = TopAbs_EDGE; + } else if (theString.equals(::ShVertexString())) + { aResult = TopAbs_VERTEX; + } else + { throw Standard_DomainError("TopAbs_ShapeEnum; string value without enum term equivalence"); + } } return aResult; } @@ -427,29 +457,53 @@ static TNaming_NameType NameTypeFromString(const XmlObjMgt_DOMString& theString) if (!theString.equals(::NTUnknownString())) { if (theString.equals(::NTIdentityString())) + { aResult = TNaming_IDENTITY; + } else if (theString.equals(::NTModifUntilString())) + { aResult = TNaming_MODIFUNTIL; + } else if (theString.equals(::NTGenerationString())) + { aResult = TNaming_GENERATION; + } else if (theString.equals(::NTIntersectionString())) + { aResult = TNaming_INTERSECTION; + } else if (theString.equals(::NTUnionString())) + { aResult = TNaming_UNION; + } else if (theString.equals(::NTSubtractionString())) + { aResult = TNaming_SUBSTRACTION; + } else if (theString.equals(::NTConstShapeString())) + { aResult = TNaming_CONSTSHAPE; + } else if (theString.equals(::NTFilterByNeighString())) + { aResult = TNaming_FILTERBYNEIGHBOURGS; + } else if (theString.equals(::NTOrientationString())) + { aResult = TNaming_ORIENTATION; + } else if (theString.equals(::NTWireInString())) + { aResult = TNaming_WIREIN; + } else if (theString.equals(::NTShellInString())) + { aResult = TNaming_SHELLIN; + } else + { throw Standard_DomainError("TNaming_NameType; string value without enum term equivalence"); + } } return aResult; } diff --git a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_Shape1.cxx b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_Shape1.cxx index 14c27f6fe6..2668dfa062 100644 --- a/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_Shape1.cxx +++ b/src/ApplicationFramework/TKXml/XmlMNaming/XmlMNaming_Shape1.cxx @@ -72,8 +72,10 @@ XmlMNaming_Shape1::XmlMNaming_Shape1(const XmlObjMgt_Element& theEl) } const char* anIntPtr = (const char*)&aPtr[1]; if (!XmlObjMgt::GetInteger(anIntPtr, myTShapeID)) + { throw Standard_DomainError( "XmlMNaming_Shape1; tshape value cannot be initialised by integer"); + } } } @@ -144,7 +146,9 @@ void XmlMNaming_Shape1::SetShape(const int theID, Sprintf(aBuffer, "%c%i", anOr, theID); Element().setAttribute(::TShapeString(), aBuffer); if (theLocID > 0) + { Element().setAttribute(::LocationString(), theLocID); + } } //================================================================================================= diff --git a/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentRetrievalDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentRetrievalDriver.cxx index c21f39dcf7..37753a500f 100644 --- a/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentRetrievalDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentRetrievalDriver.cxx @@ -76,12 +76,18 @@ static int RemoveExtraSeparator(TCollection_AsciiString& aString) char c = aString.Value(j); aString.SetValue(i, c); if (c == '/') + { while (j < len && aString.Value(j + 1) == '/') + { j++; + } + } } len = i - 1; if (aString.Value(len) == '/') + { len--; + } aString.Trunc(len); return len; } @@ -97,7 +103,9 @@ static TCollection_AsciiString GetDirFromFile(const TCollection_ExtendedString& i = theCFile.SearchFromEnd("\\"); #endif if (i != -1) + { theDirectory = theCFile.SubString(1, i); + } return theDirectory; } @@ -108,20 +116,25 @@ static TCollection_AsciiString AbsolutePath(const TCollection_AsciiString& aDirP #ifdef _WIN32 if (aRelFilePath.Search(":") == 2 || (aRelFilePath.Search("\\") == 1 && aRelFilePath.Value(2) == '\\')) + { #else if (aRelFilePath.Search("/") == 1) + { #endif return aRelFilePath; - + } TCollection_AsciiString DirPath = aDirPath, RelFilePath = aRelFilePath; int i, len; #ifdef _WIN32 if (DirPath.Search(":") != 2 && (DirPath.Search("\\") != 1 || DirPath.Value(2) != '\\')) + { #else if (DirPath.Search("/") != 1) + { #endif return EmptyString; + } #ifdef _WIN32 DirPath.ChangeAll('\\', '/'); @@ -134,14 +147,20 @@ static TCollection_AsciiString AbsolutePath(const TCollection_AsciiString& aDirP while (RelFilePath.Search("../") == 1) { if (len == 3) + { return EmptyString; + } RelFilePath = RelFilePath.SubString(4, len); len -= 3; if (DirPath.IsEmpty()) + { return EmptyString; + } i = DirPath.SearchFromEnd("/"); if (i < 0) + { return EmptyString; + } DirPath.Trunc(i - 1); } TCollection_AsciiString retx; @@ -210,7 +229,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read(Standard_IStream& theIStream, if (aParser.parse(theIStream, false, aWithoutRoot)) { TCollection_AsciiString aData; - std::cout << aParser.GetError(aData) << ": " << aData << std::endl; + std::cout << aParser.GetError(aData) << ": " << aData << '\n'; myReaderStatus = PCDM_RS_FormatFailure; return; } @@ -271,7 +290,9 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( + TDocStd_Document::CurrentStorageFormatVersion(); myReaderStatus = PCDM_RS_NoVersion; if (!aMsgDriver.IsNull()) + { aMsgDriver->Send(aMsg.ToExtString(), Message_Fail); + } return; } @@ -301,7 +322,9 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( TCollection_ExtendedString aMsg("Warning: "); aMsg = aMsg.Cat("could not read the reference counter").Cat("\0"); if (!aMsgDriver.IsNull()) + { aMsgDriver->Send(aMsg.ToExtString(), Message_Warning); + } } } else if (anInfo.Search(MODIFICATION_COUNTER) != -1) @@ -318,12 +341,16 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( { TCollection_ExtendedString aMsg("Warning: could not read the modification counter\0"); if (!aMsgDriver.IsNull()) + { aMsgDriver->Send(aMsg.ToExtString(), Message_Warning); + } } } if (anInfo == END_REF) + { isRef = false; + } if (isRef) { // Process References @@ -349,7 +376,9 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( { anAbsolutePath = AbsolutePath(anAbsoluteDirectory, aPath); if (!anAbsolutePath.IsEmpty()) + { aPath = anAbsolutePath; + } } if (!aMsgDriver.IsNull()) { @@ -428,7 +457,9 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( } } if (anInfo == START_REF) + { isRef = true; + } } } } @@ -454,11 +485,15 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( Message_ProgressScope aPS(theRange, "Reading document", 2); // 2. Read Shapes section if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(aMsgDriver); + } const occ::handle aNSDriver = ReadShapeSection(theElement, aMsgDriver, aPS.Next()); if (!aNSDriver.IsNull()) + { ::take_time(0, " +++++ Fin reading Shapes : ", aMsgDriver); + } if (!aPS.More()) { @@ -481,9 +516,13 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument( aMsgDriver->Send(aMessage.ToExtString(), Message_Trace); #endif if (!MakeDocument(theElement, theNewDocument, aPS.Next())) + { myReaderStatus = PCDM_RS_MakeFailure; + } else + { myReaderStatus = PCDM_RS_OK; + } } catch (Standard_Failure const& anException) { diff --git a/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx index 155bb33f1c..3d64a514b4 100644 --- a/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx @@ -72,8 +72,12 @@ void XmlLDrivers_DocumentStorageDriver::AddNamespace(const TCollection_AsciiStri const TCollection_AsciiString& theURI) { for (int i = 1; i <= mySeqOfNS.Length(); i++) + { if (thePrefix == mySeqOfNS(i).Prefix()) + { return; + } + } mySeqOfNS.Append(XmlLDrivers_NamespaceDef(thePrefix, theURI)); } @@ -277,7 +281,9 @@ bool XmlLDrivers_DocumentStorageDriver::WriteToDomDocument( // User info with Copyright NCollection_Sequence aUserInfo; if (myCopyright.Length() > 0) + { aUserInfo.Append(TCollection_AsciiString(myCopyright, '?')); + } occ::handle theData = new Storage_Data; // PCDM_ReadWriter::WriteFileFormat( theData, theDocument ); @@ -288,7 +294,9 @@ bool XmlLDrivers_DocumentStorageDriver::WriteToDomDocument( const NCollection_Sequence& aRefs = theData->UserInfo(); for (i = 1; i <= aRefs.Length(); i++) + { aUserInfo.Append(aRefs.Value(i)); + } // Keep format version in Reloc. table occ::handle aHeaderData = theData->HeaderData(); @@ -358,7 +366,9 @@ bool XmlLDrivers_DocumentStorageDriver::WriteToDomDocument( // 4. Write Shapes section if (WriteShapeSection(theElement, aFormatVersion, aPS.Next())) + { ::take_time(0, " +++ Fin DOM data for Shapes : ", aMessageDriver); + } if (!aPS.More()) { SetIsError(true); @@ -390,9 +400,13 @@ int XmlLDrivers_DocumentStorageDriver::MakeDocument(const occ::handleChangePrinters().Clear(); } else + { aMessageDriver = anApplication->MessageDriver(); + } if (myDrivers.IsNull()) + { myDrivers = AttributeDrivers(aMessageDriver); + } // Retrieve from DOM_Document XmlMDF::FromTo(aTDF, theElement, myRelocTable, myDrivers, theRange); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF.cxx b/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF.cxx index 190e75e2b5..45189af4b1 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF.cxx @@ -162,7 +162,9 @@ bool XmlMDF::FromTo(const XmlObjMgt_Element& theElement, int subcount = ReadSubTree(anElem, aRootLab, theRelocTable, aDriverMap, theRange); // check for error if (subcount < 0) + { return false; + } (void)count; // unused but set for debug count += subcount; @@ -214,7 +216,9 @@ int XmlMDF::ReadSubTree( int subcount = ReadSubTree(anElem, aLab, theRelocTable, theDriverMap, aPS.Next()); // check for error if (subcount == -1) + { return -1; + } count += subcount; } else @@ -252,9 +256,13 @@ int XmlMDF::ReadSubTree( occ::handle tAtt; bool isBound = theRelocTable.IsBound(anID); if (isBound) + { tAtt = occ::down_cast(theRelocTable.Find(anID)); + } else + { tAtt = driver->NewEmpty(); + } if (tAtt->Label().IsNull()) { @@ -274,10 +282,12 @@ int XmlMDF::ReadSubTree( } } else + { driver->myMessageDriver->Send(TCollection_ExtendedString("XmlDriver warning: ") + "attempt to attach attribute " + aName + " to a second label", Message_Warning); + } if (!driver->Paste(pAtt, tAtt, theRelocTable)) { @@ -287,7 +297,9 @@ int XmlMDF::ReadSubTree( Message_Warning); } else if (!isBound) + { theRelocTable.Bind(anID, tAtt); + } } #ifdef OCCT_DEBUG else @@ -304,7 +316,9 @@ int XmlMDF::ReadSubTree( anElem = (const XmlObjMgt_Element&)theNode1; if (!aPS.More()) + { return -1; + } } // AfterRetrieval diff --git a/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF_ADriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF_ADriver.cxx index 5bd40a4b82..bd98780e7c 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF_ADriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDF/XmlMDF_ADriver.cxx @@ -32,13 +32,17 @@ XmlMDF_ADriver::XmlMDF_ADriver(const occ::handle& theMsgDrive myMessageDriver(theMsgDriver) { if (theNS != nullptr) + { if (theNS[0] != '\0') { myTypeName = theNS; myTypeName += ':'; } + } if (theName != nullptr) + { myTypeName += theName; + } } //================================================================================================= @@ -61,6 +65,8 @@ const TCollection_AsciiString& XmlMDF_ADriver::TypeName() const { const char* const aString = myTypeName.ToCString(); if (myTypeName.Length() == 0 || aString[myTypeName.Length() - 1] == ':') + { (TCollection_AsciiString&)myTypeName += SourceType()->Name(); + } return myTypeName; } diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_AsciiStringDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_AsciiStringDriver.cxx index a435ceffc6..b77c11efc2 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_AsciiStringDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_AsciiStringDriver.cxx @@ -56,9 +56,13 @@ bool XmlMDataStd_AsciiStringDriver::Paste(const XmlObjMgt_Persistent& theS const XmlObjMgt_Element& anElement = theSource; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_AsciiString::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } occ::down_cast(theTarget)->SetID(aGUID); return true; @@ -75,7 +79,9 @@ void XmlMDataStd_AsciiStringDriver::Paste(const occ::handle& theS { occ::handle aS = occ::down_cast(theSource); if (aS.IsNull()) + { return; + } XmlObjMgt_DOMString aString = aS->Get().ToCString(); XmlObjMgt::SetStringValue(theTarget, aString); if (aS->ID() != TDataStd_AsciiString::GetID()) diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanArrayDriver.cxx index b8f8b652ba..f160df3175 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanArrayDriver.cxx @@ -54,7 +54,9 @@ bool XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persistent& the // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -91,9 +93,13 @@ bool XmlMDataStd_BooleanArrayDriver::Paste(const XmlObjMgt_Persistent& the Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_BooleanArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aBooleanArray->SetID(aGUID); aBooleanArray->Init(aFirstInd, aLastInd); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanListDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanListDriver.cxx index 231e632d49..7453ffb754 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanListDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_BooleanListDriver.cxx @@ -55,7 +55,9 @@ bool XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent& theS // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -84,14 +86,20 @@ bool XmlMDataStd_BooleanListDriver::Paste(const XmlObjMgt_Persistent& theS Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_BooleanList::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aBooleanList->SetID(aGUID); if (aLastInd == 0) + { aFirstInd = 0; + } if (aFirstInd == aLastInd && aLastInd > 0) { if (!XmlObjMgt::GetStringValue(anElement).GetInteger(aValue)) @@ -140,7 +148,9 @@ void XmlMDataStd_BooleanListDriver::Paste(const occ::handle& theS // Allocation of 1 char for each boolean value + a space. NCollection_LocalArray str(2 * anU + 1); if (anU == 0) + { str[0] = 0; + } else if (anU >= 1) { int iChar(0); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ByteArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ByteArrayDriver.cxx index 1275d376c7..8ca56bed16 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ByteArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ByteArrayDriver.cxx @@ -58,7 +58,9 @@ bool XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent& theSou // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -95,9 +97,13 @@ bool XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent& theSou Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_ByteArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aByteArray->SetID(aGUID); @@ -139,7 +145,9 @@ bool XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent& theSou return false; } else + { aDelta = aDeltaValue != 0; + } } #ifdef OCCT_DEBUG std::cout << "Current Document Format Version = " diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExpressionDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExpressionDriver.cxx index df6f2788c8..447f072f09 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExpressionDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExpressionDriver.cxx @@ -83,7 +83,9 @@ bool XmlMDataStd_ExpressionDriver::Paste(const XmlObjMgt_Persistent& theSo { occ::handle aV; if (theRelocTable.IsBound(aNb)) + { aV = occ::down_cast(theRelocTable.Find(aNb)); + } else { aV = new TDataStd_Variable; @@ -93,7 +95,9 @@ bool XmlMDataStd_ExpressionDriver::Paste(const XmlObjMgt_Persistent& theSo // next variable if (!XmlObjMgt::GetInteger(aVs, aNb)) + { aNb = 0; + } } } @@ -134,7 +138,9 @@ void XmlMDataStd_ExpressionDriver::Paste(const occ::handle& theSo aGsStr += TCollection_AsciiString(aNb) + " "; } else + { aGsStr += "0 "; + } } anElem.setAttribute(::VariablesString(), aGsStr.ToCString()); } diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringArrayDriver.cxx index 45e0a4c08a..fbfae2f297 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringArrayDriver.cxx @@ -76,7 +76,9 @@ bool XmlMDataStd_ExtStringArrayDriver::Paste(const XmlObjMgt_Persistent& t // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -102,7 +104,9 @@ bool XmlMDataStd_ExtStringArrayDriver::Paste(const XmlObjMgt_Persistent& t TCollection_ExtendedString separator; XmlObjMgt_DOMString aSeparator = anElement.getAttribute(::Separator()); if (aSeparator.Type() != XmlObjMgt_DOMString::LDOM_NULL) + { separator = aSeparator.GetString(); + } occ::handle aExtStringArray = occ::down_cast(theTarget); @@ -112,9 +116,13 @@ bool XmlMDataStd_ExtStringArrayDriver::Paste(const XmlObjMgt_Persistent& t Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_ExtStringArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aExtStringArray->SetID(aGUID); @@ -201,7 +209,9 @@ bool XmlMDataStd_ExtStringArrayDriver::Paste(const XmlObjMgt_Persistent& t return false; } else + { aDelta = aDeltaValue != 0; + } } aExtStringArray->SetDelta(aDelta); @@ -223,7 +233,9 @@ void XmlMDataStd_ExtStringArrayDriver::Paste(const occ::handle& t XmlObjMgt_Element& anElement = theTarget; if (aL != 1) + { anElement.setAttribute(::FirstIndexString(), aL); + } anElement.setAttribute(::LastIndexString(), anU); anElement.setAttribute(::IsDeltaOn(), aExtStringArray->GetDelta() ? 1 : 0); @@ -299,7 +311,9 @@ void XmlMDataStd_ExtStringArrayDriver::Paste(const occ::handle& t len++; // for separator or ending \0 symbol } if (!len) + { len++; // for end of line \0 symbol + } // Merge all strings of the array into one extended string separated by the "separator". int isym(1); @@ -314,7 +328,9 @@ void XmlMDataStd_ExtStringArrayDriver::Paste(const occ::handle& t xstr.SetValue(isym++, c); } if (xstr.SearchFromEnd(c) == isym - 1) + { isym--; // replace the last separator by '\0' + } xstr.SetValue(isym, u'\0'); #ifdef _DEBUG TCollection_AsciiString cstr(xstr, '?'); // deb diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringListDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringListDriver.cxx index c35f4f8a00..61a2170434 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringListDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ExtStringListDriver.cxx @@ -57,7 +57,9 @@ bool XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persistent& th // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -85,9 +87,13 @@ bool XmlMDataStd_ExtStringListDriver::Paste(const XmlObjMgt_Persistent& th Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_ExtStringList::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } anExtStringList->SetID(aGUID); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_GenericExtStringDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_GenericExtStringDriver.cxx index c6247401da..200d0ef180 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_GenericExtStringDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_GenericExtStringDriver.cxx @@ -82,7 +82,9 @@ void XmlMDataStd_GenericExtStringDriver::Paste(const occ::handle& occ::handle aStr = occ::down_cast(theSource); if (aStr.IsNull()) + { return; + } XmlObjMgt::SetExtendedString(theTarget, aStr->Get()); // convert GUID char aGuidStr[Standard_GUID_SIZE_ALLOC]; diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntPackedMapDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntPackedMapDriver.cxx index 5ab4fdc21e..7ee77cc2aa 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntPackedMapDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntPackedMapDriver.cxx @@ -60,7 +60,9 @@ bool XmlMDataStd_IntPackedMapDriver::Paste(const XmlObjMgt_Persistent& the const XmlObjMgt_Element& anElement = theSource; XmlObjMgt_DOMString aSizeDStr = anElement.getAttribute(::IntPackedMapSize()); if (aSizeDStr == nullptr) + { aSize = 0; + } else if (!aSizeDStr.GetInteger(aSize)) { TCollection_ExtendedString aMessageString = @@ -101,7 +103,9 @@ bool XmlMDataStd_IntPackedMapDriver::Paste(const XmlObjMgt_Persistent& the return false; } if (aPackedMap->ChangeMap(aHMap)) + { Ok = true; + } } if (Ok) { @@ -121,7 +125,9 @@ bool XmlMDataStd_IntPackedMapDriver::Paste(const XmlObjMgt_Persistent& the return false; } else + { aDelta = aDeltaValue != 0; + } } aPackedMap->SetDelta(aDelta); return true; diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerArrayDriver.cxx index fa1cf9a791..e051efc5de 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerArrayDriver.cxx @@ -59,7 +59,9 @@ bool XmlMDataStd_IntegerArrayDriver::Paste(const XmlObjMgt_Persistent& the // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -88,9 +90,13 @@ bool XmlMDataStd_IntegerArrayDriver::Paste(const XmlObjMgt_Persistent& the Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_IntegerArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } anIntArray->SetID(aGUID); if (aFirstInd == aLastInd) @@ -141,7 +147,9 @@ bool XmlMDataStd_IntegerArrayDriver::Paste(const XmlObjMgt_Persistent& the return false; } else + { aDelta = aDeltaValue != 0; + } } anIntArray->SetDelta(aDelta); @@ -161,7 +169,9 @@ void XmlMDataStd_IntegerArrayDriver::Paste(const occ::handle& the int aL = intArray.Lower(), anU = intArray.Upper(); if (aL != 1) + { theTarget.Element().setAttribute(::FirstIndexString(), aL); + } theTarget.Element().setAttribute(::LastIndexString(), anU); theTarget.Element().setAttribute(::IsDeltaOn(), anIntArray->GetDelta() ? 1 : 0); @@ -170,14 +180,18 @@ void XmlMDataStd_IntegerArrayDriver::Paste(const occ::handle& the int iChar = 0; NCollection_LocalArray str; if (intArray.Length()) + { str.Allocate(12 * intArray.Length() + 1); + } int i = aL; for (;;) { iChar += Sprintf(&(str[iChar]), "%d ", intArray.Value(i)); if (i >= anU) + { break; + } ++i; } diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerListDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerListDriver.cxx index b25eb53eb0..1f4bc016c3 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerListDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_IntegerListDriver.cxx @@ -54,7 +54,9 @@ bool XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent& theS // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -83,14 +85,20 @@ bool XmlMDataStd_IntegerListDriver::Paste(const XmlObjMgt_Persistent& theS Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_IntegerList::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } anIntList->SetID(aGUID); if (aLastInd == 0) + { aFirstInd = 0; + } if (aFirstInd == aLastInd && aLastInd > 0) { if (!XmlObjMgt::GetStringValue(anElement).GetInteger(aValue)) @@ -138,7 +146,9 @@ void XmlMDataStd_IntegerListDriver::Paste(const occ::handle& theS theTarget.Element().setAttribute(::LastIndexString(), anU); NCollection_LocalArray str(12 * anU + 1); if (anU == 0) + { str[0] = 0; + } else if (anU >= 1) { // Allocation of 12 chars for each integer including the space. diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_NamedDataDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_NamedDataDriver.cxx index e993ee7aea..148f54eee7 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_NamedDataDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_NamedDataDriver.cxx @@ -66,7 +66,9 @@ static TCollection_ExtendedString SplitItemFromEnd(TCollection_ExtendedString& K TCollection_ExtendedString aValue; const int aPos = Key.SearchFromEnd(" "); if (aPos == -1) + { return aValue; + } aValue = Key.Split(aPos - 1); aValue.Remove(1, 1); return aValue; @@ -78,7 +80,9 @@ static TCollection_ExtendedString SplitItemFromStart(TCollection_ExtendedString& TCollection_ExtendedString aValue; const int aPos = Key.Search(" "); if (aPos == -1) + { return aValue; + } aValue = Key.Split(aPos); Key.Remove(Key.Length(), 1); return aValue; @@ -90,13 +94,17 @@ occ::handle> BuildIntArray(const TCollection_AsciiStrin { occ::handle> anArr; if (ValString.Length() == 0 || !theLen) + { return anArr; + } anArr = new NCollection_HArray1(1, theLen, 0); for (int i = 1; i <= theLen; i++) { const TCollection_AsciiString& aSVal = ValString.Token(" ", i); if (aSVal.Length()) + { anArr->SetValue(i, aSVal.IntegerValue()); + } } return anArr; } @@ -107,13 +115,17 @@ occ::handle> BuildRealArray(const TCollection_AsciiS { occ::handle> anArr; if (ValString.Length() == 0 || !theLen) + { return anArr; + } anArr = new NCollection_HArray1(1, theLen, .0); for (int i = 1; i <= theLen; i++) { const TCollection_AsciiString& aSVal = ValString.Token(" ", i); if (aSVal.Length()) + { anArr->SetValue(i, aSVal.RealValue()); + } } return anArr; } @@ -130,7 +142,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringInteger: Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIntegerIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -210,7 +224,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringReal aFirstIndex = anElement.getAttribute(::FirstRealIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -250,9 +266,13 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou const LDOM_Element* aCurElement; if (aCurNode.isNull()) + { aCurNode = anElement.getFirstChild(); + } else + { aCurNode = static_cast(&aCurNode)->getNextSibling(); + } aCurElement = static_cast(&aCurNode); TCollection_ExtendedString aValueStr, aKey; @@ -292,7 +312,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringString aFirstIndex = anElement.getAttribute(::FirstStringIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -329,9 +351,13 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou } const LDOM_Element* aCurElement; if (aCurNode.isNull()) + { aCurNode = anElement.getFirstChild(); + } else + { aCurNode = static_cast(&aCurNode)->getNextSibling(); + } aCurElement = static_cast(&aCurNode); TCollection_ExtendedString aValue, aKey; @@ -368,7 +394,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringByte aFirstIndex = anElement.getAttribute(::FirstByteIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -408,9 +436,13 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou const LDOM_Element* aCurElement; if (aCurNode.isNull()) + { aCurNode = anElement.getFirstChild(); + } else + { aCurNode = static_cast(&aCurNode)->getNextSibling(); + } aCurElement = static_cast(&aCurNode); TCollection_ExtendedString aValueStr, aKey; @@ -453,7 +485,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringHArray1OfInteger aFirstIndex = anElement.getAttribute(::FirstIntArrIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -492,9 +526,13 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou } const LDOM_Element* aCurElement; if (aCurNode.isNull()) + { aCurNode = anElement.getFirstChild(); + } else + { aCurNode = static_cast(&aCurNode)->getNextSibling(); + } aCurElement = static_cast(&aCurNode); TCollection_ExtendedString aKey, aValueStr; @@ -556,7 +594,9 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou // DataMapOfStringHArray1OfReal aFirstIndex = anElement.getAttribute(::FirstRealArrIndex()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -596,9 +636,13 @@ bool XmlMDataStd_NamedDataDriver::Paste(const XmlObjMgt_Persistent& theSou const LDOM_Element* aCurElement; if (aCurNode.isNull()) + { aCurNode = anElement.getFirstChild(); + } else + { aCurNode = static_cast(&aCurNode)->getNextSibling(); + } aCurElement = static_cast(&aCurNode); TCollection_ExtendedString aKey, aValueStr; @@ -775,7 +819,9 @@ void XmlMDataStd_NamedDataDriver::Paste(const occ::handle& theSou { aValueStr2 += TCollection_AsciiString(anArr1.Value(j)); if (j >= anArr1.Upper()) + { break; + } aValueStr2 += ' '; j++; } @@ -813,7 +859,9 @@ void XmlMDataStd_NamedDataDriver::Paste(const occ::handle& theSou TCollection_AsciiString aValueStr3(aValueChar); aValueStr2 += aValueStr3; if (j >= anArr1.Upper()) + { break; + } aValueStr2 += ' '; j++; } diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealArrayDriver.cxx index d1cb234b65..16486ec6c2 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealArrayDriver.cxx @@ -63,9 +63,13 @@ bool XmlMDataStd_RealArrayDriver::Paste(const XmlObjMgt_Persistent& theSou Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_RealArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aRealArray->SetID(aGUID); int aFirstInd, aLastInd, ind; @@ -73,7 +77,9 @@ bool XmlMDataStd_RealArrayDriver::Paste(const XmlObjMgt_Persistent& theSou // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -105,7 +111,9 @@ bool XmlMDataStd_RealArrayDriver::Paste(const XmlObjMgt_Persistent& theSou { int anIntValue; if (aString.GetInteger(anIntValue)) + { aRealArray->SetValue(aFirstInd, double(anIntValue)); + } } else { @@ -132,10 +140,14 @@ bool XmlMDataStd_RealArrayDriver::Paste(const XmlObjMgt_Persistent& theSou myMessageDriver->Send(aMessageString, Message_Warning); // skip the first space, if exists while (*aValueStr != 0 && IsSpace(*aValueStr)) + { ++aValueStr; + } // skip to the next space separator while (*aValueStr != 0 && !IsSpace(*aValueStr)) + { ++aValueStr; + } } aRealArray->SetValue(ind, aValue); } @@ -156,7 +168,9 @@ bool XmlMDataStd_RealArrayDriver::Paste(const XmlObjMgt_Persistent& theSou return false; } else + { aDelta = aDeltaValue != 0; + } } aRealArray->SetDelta(aDelta); @@ -175,7 +189,9 @@ void XmlMDataStd_RealArrayDriver::Paste(const occ::handle& theSou int aL = realArray.Lower(), anU = realArray.Upper(); if (aL != 1) + { theTarget.Element().setAttribute(::FirstIndexString(), aL); + } theTarget.Element().setAttribute(::LastIndexString(), anU); theTarget.Element().setAttribute(::IsDeltaOn(), aRealArray->GetDelta() ? 1 : 0); @@ -203,7 +219,9 @@ void XmlMDataStd_RealArrayDriver::Paste(const occ::handle& theSou nbChars += Sprintf(buf, "%.17g ", realArray.Value(i++)) + 1 /*a space*/; } if (nbChars) + { str.Allocate(nbChars); + } } } @@ -212,7 +230,9 @@ void XmlMDataStd_RealArrayDriver::Paste(const occ::handle& theSou { iChar += Sprintf(&(str[iChar]), "%.17g ", realArray.Value(i)); if (i >= anU) + { break; + } ++i; } diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealDriver.cxx index 019fc2ae05..746b97b2c9 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealDriver.cxx @@ -52,9 +52,13 @@ bool XmlMDataStd_RealDriver::Paste(const XmlObjMgt_Persistent& theSource, const XmlObjMgt_Element& anElement = theSource; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_Real::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } occ::down_cast(theTarget)->SetID(aGUID); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealListDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealListDriver.cxx index 8d8ae56e2e..b8c8ccb3d1 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealListDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_RealListDriver.cxx @@ -55,16 +55,22 @@ bool XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent& theSour Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_RealList::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aRealList->SetID(aGUID); // Read the FirstIndex; if the attribute is absent initialize to 1 int aFirstInd, aLastInd, ind; XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -89,14 +95,18 @@ bool XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent& theSour // Check the type of LDOMString const XmlObjMgt_DOMString& aString = XmlObjMgt::GetStringValue(anElement); if (aLastInd == 0) + { aFirstInd = 0; + } if (aString.Type() == LDOMBasicString::LDOM_Integer) { if (aFirstInd == aLastInd && aLastInd > 0) { int anIntValue; if (aString.GetInteger(anIntValue)) + { aRealList->Append(double(anIntValue)); + } } else { @@ -123,10 +133,14 @@ bool XmlMDataStd_RealListDriver::Paste(const XmlObjMgt_Persistent& theSour myMessageDriver->Send(aMessageString, Message_Warning); // skip the first space, if exists while (*aValueStr != 0 && IsSpace(*aValueStr)) + { ++aValueStr; + } // skip to the next space separator while (*aValueStr != 0 && !IsSpace(*aValueStr)) + { ++aValueStr; + } } aRealList->Append(aValue); } @@ -149,7 +163,9 @@ void XmlMDataStd_RealListDriver::Paste(const occ::handle& theSour // An example: -3.1512678732195273e+020 NCollection_LocalArray str(25 * anU + 1); if (anU == 0) + { str[0] = 0; + } else if (anU >= 1) { int iChar = 0; diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceArrayDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceArrayDriver.cxx index 810ace860e..81be94b22a 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceArrayDriver.cxx @@ -57,7 +57,9 @@ bool XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persistent& t // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -87,9 +89,13 @@ bool XmlMDataStd_ReferenceArrayDriver::Paste(const XmlObjMgt_Persistent& t Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_ReferenceArray::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aReferenceArray->SetID(aGUID); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceListDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceListDriver.cxx index 30587f185c..05cb972001 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceListDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_ReferenceListDriver.cxx @@ -58,7 +58,9 @@ bool XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persistent& th // Read the FirstIndex; if the attribute is absent initialize to 1 XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString = @@ -86,9 +88,13 @@ bool XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persistent& th Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_ReferenceList::GetID(); // default case + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); // user defined case + } aReferenceList->SetID(aGUID); if (aLastInd > 0) @@ -123,7 +129,9 @@ bool XmlMDataStd_ReferenceListDriver::Paste(const XmlObjMgt_Persistent& th // Find label by entry TDF_Label tLab; // Null label. if (anEntry.Length() > 0) + { TDF_Tool::Label(aReferenceList->Label().Data(), anEntry, tLab, true); + } aReferenceList->Append(tLab); aCurNode = aCurElement->getNextSibling(); @@ -176,7 +184,9 @@ void XmlMDataStd_ReferenceListDriver::Paste(const occ::handle& th XmlObjMgt_Element& anElement = theTarget; anElement.setAttribute(::LastIndexString(), anU); if (anU == 0) + { return; + } XmlObjMgt_Document aDoc(anElement.getOwnerDocument()); NCollection_List::Iterator itr(aReferenceList->List()); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_TreeNodeDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_TreeNodeDriver.cxx index 55a4536688..5733387e57 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_TreeNodeDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_TreeNodeDriver.cxx @@ -55,9 +55,13 @@ bool XmlMDataStd_TreeNodeDriver::Paste(const XmlObjMgt_Persistent& theSour Standard_GUID aGUID; XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::TreeIdString()); if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL) + { aGUID = TDataStd_TreeNode::GetDefaultTreeID(); + } else + { aGUID = Standard_GUID(static_cast(aGUIDStr.GetString())); + } aT->SetTreeID(aGUID); // children @@ -69,7 +73,9 @@ bool XmlMDataStd_TreeNodeDriver::Paste(const XmlObjMgt_Persistent& theSour const char* aChildren = static_cast(aChildrenStr.GetString()); int aNb = 0; if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { return false; + } while (aNb > 0) { @@ -78,7 +84,9 @@ bool XmlMDataStd_TreeNodeDriver::Paste(const XmlObjMgt_Persistent& theSour { aTChild = occ::down_cast(theRelocTable.Find(aNb)); if (aTChild.IsNull()) + { return false; + } } else { @@ -92,7 +100,9 @@ bool XmlMDataStd_TreeNodeDriver::Paste(const XmlObjMgt_Persistent& theSour // Get next child ID if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { aNb = 0; + } } } return true; @@ -125,7 +135,9 @@ void XmlMDataStd_TreeNodeDriver::Paste(const occ::handle& theSour int iChar = 0; NCollection_LocalArray str; if (nbChildren) + { str.Allocate(11 * nbChildren + 1); + } // form the string of numbers for the list of children occ::handle aF = aS->First(); diff --git a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_VariableDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_VariableDriver.cxx index 2dee92908b..b3fdfae4d0 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_VariableDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMDataStd/XmlMDataStd_VariableDriver.cxx @@ -64,6 +64,8 @@ void XmlMDataStd_VariableDriver::Paste(const occ::handle& theSour { occ::handle aV = occ::down_cast(theSource); if (aV->IsConstant()) + { theTarget.Element().setAttribute(::IsConstString(), ::ConstString()); + } theTarget.Element().setAttribute(::UnitString(), aV->Unit().ToCString()); } diff --git a/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx index 357fb47d89..5941735498 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx @@ -138,7 +138,9 @@ bool XmlMFunction_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSo return false; } if (ind < aFirstIndNext) + { continue; + } G->AddNext(aValue); } diff --git a/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_ScopeDriver.cxx b/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_ScopeDriver.cxx index 7b74a4a814..802678bf2e 100644 --- a/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_ScopeDriver.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlMFunction/XmlMFunction_ScopeDriver.cxx @@ -204,7 +204,9 @@ bool XmlMFunction_ScopeDriver::Paste(const XmlObjMgt_Persistent& theSource { int ID = itri.Value(); if (ID > freeID) + { freeID = ID; + } S->ChangeFunctions().Bind(ID, itrl.Value()); } freeID++; diff --git a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt.cxx b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt.cxx index ce759683d5..81d2c9a9a5 100644 --- a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt.cxx @@ -44,7 +44,9 @@ void XmlObjMgt::SetStringValue(XmlObjMgt_Element& theElement, XmlObjMgt_Document aDocument = theElement.getOwnerDocument(); LDOM_Text aText = aDocument.createTextNode(theData); if (isClearText) + { aText.SetValueClear(); + } theElement.appendChild(aText); } @@ -80,9 +82,13 @@ void SprintfExtStr(char* out, const TCollection_ExtendedString& theString) unsigned short v = *(p + i) & mask[j]; // x000 v = (unsigned short)(v >> (4 * k)); if (v < 10) + { v |= 0x30; + } else + { v += 87; + } out[4 * i + j] = (char)v; } i++; @@ -146,7 +152,9 @@ bool XmlObjMgt::GetTagEntryString(const XmlObjMgt_DOMString& theSource, const size_t aPrefixSize = sizeof(aRefPrefix) - 1; const char* aSource = theSource.GetString(); if (strncmp(aSource, aRefPrefix, aPrefixSize)) + { return false; + } // Begin aTagEntry string char* aTagEntry = (char*)Standard::Allocate(strlen(aSource) / 2); // quite enough to hold it @@ -161,11 +169,15 @@ bool XmlObjMgt::GetTagEntryString(const XmlObjMgt_DOMString& theSource, { // Check the first part of individual tag: "/label[@tag=" if (strncmp(aSource, aRefElem1, anElem1Size)) + { return false; + } aSource += anElem1Size; const char aQuote = aSource[0]; if (aQuote != '\'' && aQuote != '\"') + { return false; + } // Check the integer value of the tag errno = 0; @@ -173,14 +185,18 @@ bool XmlObjMgt::GetTagEntryString(const XmlObjMgt_DOMString& theSource, long aTagValue = strtol(&aSource[1], &aPtr, 10); int aLen = (int)(aPtr - &aSource[1]); if (aTagValue < 0 || aLen == 0 || aPtr[0] != aQuote || errno == ERANGE || errno == EINVAL) + { return false; + } aTagEntryPtr[0] = ':'; memcpy(&aTagEntryPtr[1], &aSource[1], aLen); aTagEntryPtr += (aLen + 1); // Check the final part of individual tag : "]" if (strncmp(aPtr + 1, aRefElem2, anElem2Size)) + { return false; + } aSource = aPtr + 1 + anElem2Size; } aTagEntryPtr[0] = '\0'; @@ -197,14 +213,20 @@ void XmlObjMgt::SetTagEntryString(XmlObjMgt_DOMString& theTarget, // Begin parsing theTagEntry const char* aTagEntry = (const char*)theTagEntry.ToCString() + 1; if (aTagEntry[-1] != '0') + { return; + } // Count the number of tags in the label entry string const char* aPtr = aTagEntry; int aTagCount = 0; while (*aPtr) + { if (*aPtr++ == ':') + { aTagCount++; + } + } // Create a buffer to accumulate the XPath reference const size_t anElem1Size = sizeof(aRefElem1) - 1; @@ -219,7 +241,9 @@ void XmlObjMgt::SetTagEntryString(XmlObjMgt_DOMString& theTarget, // Check for the end-of-string; find the delimiter ':' aPtr = strchr(aTagEntry, ':'); if (aPtr == nullptr) + { break; + } aTagEntry = aPtr + 1; // Find the range of characters for an integer number @@ -228,7 +252,9 @@ void XmlObjMgt::SetTagEntryString(XmlObjMgt_DOMString& theTarget, long aTagValue = strtol(aTagEntry, &ptr, 10); int aTagSize = (int)(ptr - aTagEntry); if (aTagValue < 0 || aTagSize == 0 || errno == ERANGE || errno == EINVAL) + { return; // error + } // Add one XPath level to the expression in aTarget memcpy(&aTargetPtr[0], aRefElem1, anElem1Size); @@ -255,8 +281,12 @@ XmlObjMgt_Element XmlObjMgt::FindChildElement(const XmlObjMgt_Element& theSource { LDOM_Element anElem = (LDOM_Element&)aNode; if (anElem.getAttribute(IdString()).GetInteger(anId)) + { if (anId == theId) + { return anElem; + } + } } aNode = aNode.getNextSibling(); } @@ -274,7 +304,9 @@ XmlObjMgt_Element XmlObjMgt::FindChildByRef(const XmlObjMgt_Element& theSource { int anID; if (theSource.getAttribute(theRefName).GetInteger(anID)) + { return FindChildElement(theSource, anID); + } return LDOM_Element(); } @@ -294,7 +326,9 @@ bool XmlObjMgt::GetInteger(const char*& theString, int& theValue) errno = 0; long aValue = strtol(theString, &ptr, 10); if (ptr == theString || errno == ERANGE || errno == EINVAL) + { return false; + } theValue = int(aValue); theString = ptr; return true; @@ -308,7 +342,9 @@ bool XmlObjMgt::GetReal(const char*& theString, double& theValue) errno = 0; theValue = Strtod(theString, &ptr); if (ptr == theString || errno == ERANGE || errno == EINVAL) + { return false; + } theString = ptr; @@ -330,7 +366,9 @@ bool XmlObjMgt::GetReal(const char*& theString, double& theValue) return true; } else + { return false; + } } else if (*ptr && !IsSpace(*ptr)) { diff --git a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Array1.cxx b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Array1.cxx index fa70a4b5ab..5ab48ca02b 100644 --- a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Array1.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Array1.cxx @@ -35,9 +35,13 @@ XmlObjMgt_Array1::XmlObjMgt_Array1(const XmlObjMgt_Element& theParent, if (myElement != nullptr) { if (!myElement.getAttribute(::LowerString()).GetInteger(myFirst)) + { myFirst = 1; + } if (!myElement.getAttribute(::UpperString()).GetInteger(myLast)) + { myLast = 1; + } } } @@ -65,7 +69,9 @@ void XmlObjMgt_Array1::CreateArrayElement(XmlObjMgt_Element& theParent, { myElement.setAttribute(::UpperString(), myLast); if (myFirst != 1) + { myElement.setAttribute(::LowerString(), myFirst); + } } } } @@ -94,8 +100,12 @@ XmlObjMgt_Element XmlObjMgt_Array1::Value(const int theIndex) const { anElem = (XmlObjMgt_Element&)aNode; if (anElem.getAttribute(::IndString()).GetInteger(ind)) + { if (ind == theIndex) + { break; + } + } } aNode = aNode.getNextSibling(); } diff --git a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_GP.cxx b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_GP.cxx index 5fadbcfe52..837a6537b8 100644 --- a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_GP.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_GP.cxx @@ -119,7 +119,9 @@ static const char* Translate(const char* theStr, gp_Mat& M) M.SetRow(2, aC); theStr = Translate(theStr, aC); if (theStr) + { M.SetRow(3, aC); + } } } return theStr; @@ -150,13 +152,19 @@ static const char* Translate(const char* theStr, gp_XYZ& P) theStr = ptr; } else + { theStr = nullptr; + } } else + { theStr = nullptr; + } } else + { theStr = nullptr; + } } return theStr; } diff --git a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Persistent.cxx b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Persistent.cxx index 2f64d49e04..3191a6cbaa 100644 --- a/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Persistent.cxx +++ b/src/ApplicationFramework/TKXmlL/XmlObjMgt/XmlObjMgt_Persistent.cxx @@ -33,7 +33,9 @@ XmlObjMgt_Persistent::XmlObjMgt_Persistent(const XmlObjMgt_Element& theElement) myID(0) { if (theElement != nullptr) + { theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID); + } } //================================================================================================= @@ -49,7 +51,9 @@ XmlObjMgt_Persistent::XmlObjMgt_Persistent(const XmlObjMgt_Element& theElement { myElement = XmlObjMgt::FindChildElement(theElement, aRefID); if (myElement != nullptr) + { myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID); + } } } } diff --git a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_IntSparseArrayDriver.cxx b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_IntSparseArrayDriver.cxx index defb6feaf0..fa69fda400 100644 --- a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_IntSparseArrayDriver.cxx +++ b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_IntSparseArrayDriver.cxx @@ -89,7 +89,9 @@ void XmlTObjDrivers_IntSparseArrayDriver::Paste(const occ::handle { int aValue = anIt.Value(); if (aValue == 0) + { continue; + } TCollection_AsciiString anIdStr = TCollection_AsciiString(ITEM_ID) + TCollection_AsciiString(i); TCollection_AsciiString aStrIndex = TCollection_AsciiString(ITEM_VALUE) + TCollection_AsciiString(i); diff --git a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx index 5fed481098..b3ca1d24ec 100644 --- a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx +++ b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx @@ -68,7 +68,9 @@ bool XmlTObjDrivers_ReferenceDriver::Paste(const XmlObjMgt_Persistent& Sou TDF_Tool::Label(Target->Label().Data(), MasterEntry, aMasterLabel); // referred label if (InHolderEntry.IsEmpty()) + { TDF_Tool::Label(Target->Label().Data(), RefEntry, aLabel, true); + } else { occ::handle aModel = TObj_Assistant::FindModel(InHolderEntry.ToCString()); @@ -90,7 +92,9 @@ void XmlTObjDrivers_ReferenceDriver::Paste(const occ::handle& Sou occ::handle aLObject = aSource->Get(); if (aLObject.IsNull()) + { return; + } // referred entry TCollection_AsciiString entry; @@ -106,7 +110,9 @@ void XmlTObjDrivers_ReferenceDriver::Paste(const occ::handle& Sou // is reference to other document if (aLabel.Root() == aMasterLabel.Root()) + { return; + } occ::handle aModel = aLObject->GetModel(); TCollection_AsciiString aModelName(aModel->GetModelName()->String()); diff --git a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_XYZDriver.cxx b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_XYZDriver.cxx index 5f75931e37..ed11ed6663 100644 --- a/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_XYZDriver.cxx +++ b/src/ApplicationFramework/TKXmlTObj/XmlTObjDrivers/XmlTObjDrivers_XYZDriver.cxx @@ -65,17 +65,23 @@ bool XmlTObjDrivers_XYZDriver::Paste(const XmlObjMgt_Persistent& Source, aStr = CoordX.ToCString(); if (!XmlObjMgt::GetReal(aStr, aCoord)) + { return false; + } aXYZ.SetX(aCoord); aStr = CoordY.ToCString(); if (!XmlObjMgt::GetReal(aStr, aCoord)) + { return false; + } aXYZ.SetY(aCoord); aStr = CoordZ.ToCString(); if (!XmlObjMgt::GetReal(aStr, aCoord)) + { return false; + } aXYZ.SetZ(aCoord); // setting gp_XYZ @@ -94,7 +100,9 @@ void XmlTObjDrivers_XYZDriver::Paste(const occ::handle& Source, occ::handle aSource = occ::down_cast(Source); if (aSource.IsNull()) + { return; + } gp_XYZ aXYZ = aSource->Get(); diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_AssemblyItemRefDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_AssemblyItemRefDriver.cxx index 825e53ce04..24adfc2e7b 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_AssemblyItemRefDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_AssemblyItemRefDriver.cxx @@ -44,23 +44,31 @@ bool BinMXCAFDoc_AssemblyItemRefDriver::Paste(const BinObjMgt_Persistent& { occ::handle aThis = occ::down_cast(theTarget); if (aThis.IsNull()) + { return false; + } TCollection_AsciiString aPathStr; if (!(theSource >> aPathStr)) + { return false; + } aThis->SetItem(aPathStr); int anExtraRef = 0; if (!(theSource >> anExtraRef)) + { return false; + } if (anExtraRef == 1) { Standard_GUID aGUID; if (!(theSource >> aGUID)) + { return false; + } aThis->SetGUID(aGUID); } @@ -68,7 +76,9 @@ bool BinMXCAFDoc_AssemblyItemRefDriver::Paste(const BinObjMgt_Persistent& { int aSubshapeIndex; if (!(theSource >> aSubshapeIndex)) + { return false; + } aThis->SetSubshapeIndex(aSubshapeIndex); } @@ -98,6 +108,8 @@ void BinMXCAFDoc_AssemblyItemRefDriver::Paste( theTarget << aThis->GetSubshapeIndex(); } else + { theTarget << int(0); + } } } diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_ColorDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_ColorDriver.cxx index 94b03f473f..4c3c3824a8 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_ColorDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_ColorDriver.cxx @@ -50,7 +50,9 @@ bool BinMXCAFDoc_ColorDriver::Paste(const BinObjMgt_Persistent& theSource, { bool isRGBA = theSource >> alpha; if (!isRGBA) + { alpha = 1.0; + } anAtt->Set(R, G, B, alpha); } return isOk; diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DatumDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DatumDriver.cxx index e6af1348a2..d82c7220b5 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DatumDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DatumDriver.cxx @@ -48,7 +48,9 @@ bool BinMXCAFDoc_DatumDriver::Paste(const BinObjMgt_Persistent& theSource, occ::handle anAtt = occ::down_cast(theTarget); TCollection_AsciiString aName, aDescr, anId; if (!(theSource >> aName >> aDescr >> anId)) + { return false; + } anAtt->Set(new TCollection_HAsciiString(aName), new TCollection_HAsciiString(aDescr), @@ -65,17 +67,29 @@ void BinMXCAFDoc_DatumDriver::Paste( { occ::handle anAtt = occ::down_cast(theSource); if (!anAtt->GetName().IsNull()) + { theTarget << anAtt->GetName()->String(); + } else + { theTarget << TCollection_AsciiString(""); + } if (!anAtt->GetDescription().IsNull()) + { theTarget << anAtt->GetDescription()->String(); + } else + { theTarget << TCollection_AsciiString(""); + } if (!anAtt->GetIdentification().IsNull()) + { theTarget << anAtt->GetIdentification()->String(); + } else + { theTarget << TCollection_AsciiString(""); + } } diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DimTolDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DimTolDriver.cxx index 326cc358fb..40916a88c9 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DimTolDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_DimTolDriver.cxx @@ -48,7 +48,9 @@ bool BinMXCAFDoc_DimTolDriver::Paste(const BinObjMgt_Persistent& theSource int aKind, aFirstInd, aLastInd; TCollection_AsciiString aName, aDescr; if (!(theSource >> aKind >> aName >> aDescr >> aFirstInd >> aLastInd)) + { return false; + } occ::handle> aHArr; const int aLength = aLastInd - aFirstInd + 1; @@ -58,7 +60,9 @@ bool BinMXCAFDoc_DimTolDriver::Paste(const BinObjMgt_Persistent& theSource NCollection_Array1& aTargetArray = aHArr->ChangeArray1(); if (!theSource.GetRealArray(&aTargetArray(aFirstInd), aLength)) + { return false; + } } anAtt->Set(aKind, aHArr, @@ -77,13 +81,21 @@ void BinMXCAFDoc_DimTolDriver::Paste( occ::handle anAtt = occ::down_cast(theSource); theTarget << anAtt->GetKind(); if (!anAtt->GetName().IsNull()) + { theTarget << anAtt->GetName()->String(); + } else + { theTarget << TCollection_AsciiString(""); + } if (!anAtt->GetDescription().IsNull()) + { theTarget << anAtt->GetDescription()->String(); + } else + { theTarget << TCollection_AsciiString(""); + } occ::handle> aHArr = anAtt->GetVal(); int aFirstInd = 1, aLastInd = 0; diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_GraphNodeDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_GraphNodeDriver.cxx index 6e65490176..42569d1cdd 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_GraphNodeDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_GraphNodeDriver.cxx @@ -48,7 +48,9 @@ bool BinMXCAFDoc_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSou // Read Fathers if (!(theSource >> anID)) + { return false; + } while (anID != -1) { occ::handle aNode; @@ -64,12 +66,16 @@ bool BinMXCAFDoc_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSou aT->SetFather(aNode); if (!(theSource >> anID)) + { return false; + } } // Read Children if (!(theSource >> anID)) + { return false; + } while (anID != -1) { occ::handle aNode; @@ -85,13 +91,17 @@ bool BinMXCAFDoc_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSou aT->SetChild(aNode); if (!(theSource >> anID)) + { return false; + } } // Graph id Standard_GUID aGUID; if (!(theSource >> aGUID)) + { return false; + } aT->SetGraphID(aGUID); return true; diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_LocationDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_LocationDriver.cxx index 228595cb75..e88567419d 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_LocationDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_LocationDriver.cxx @@ -128,7 +128,9 @@ bool BinMXCAFDoc_LocationDriver::Translate(const BinObjMgt_Persistent& theSource aDatum = occ::down_cast(theMap.Find(aDatumID)); } else + { return false; + } } else { @@ -146,12 +148,14 @@ bool BinMXCAFDoc_LocationDriver::Translate(const BinObjMgt_Persistent& theSource int R, C; gp_Mat& aMat = (gp_Mat&)aTrsf.HVectorialPart(); for (R = 1; R <= 3; R++) + { for (C = 1; C <= 3; C++) { double aVal; theSource >> aVal; aMat.SetValue(R, C, aVal); } + } double x, y, z; theSource >> x >> y >> z; diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_MaterialDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_MaterialDriver.cxx index ccacd0e4b4..4c6f9749c6 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_MaterialDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_MaterialDriver.cxx @@ -48,7 +48,9 @@ bool BinMXCAFDoc_MaterialDriver::Paste(const BinObjMgt_Persistent& theSour double aDensity; TCollection_AsciiString aName, aDescr, aDensName, aDensValType; if (!(theSource >> aName >> aDescr >> aDensity >> aDensName >> aDensValType)) + { return false; + } anAtt->Set(new TCollection_HAsciiString(aName), new TCollection_HAsciiString(aDescr), @@ -62,9 +64,13 @@ static void pasteString(BinObjMgt_Persistent& theTarget, const occ::handle& theStr) { if (!theStr.IsNull()) + { theTarget << theStr->String(); + } else + { theTarget << TCollection_AsciiString(""); + } } //================================================================================================= diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx index 73ad9df965..041c38a929 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx @@ -45,17 +45,23 @@ bool BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent& theS BinObjMgt_RRelocationTable& theRelocTable) const { if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable)) + { return false; + } occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } TCollection_ExtendedString aTitle; TCollection_AsciiString aMIMEtype; int nbSize; if (!(theSource >> aTitle >> aMIMEtype >> nbSize)) + { return false; + } occ::handle> aData; if (nbSize > 0) @@ -83,6 +89,8 @@ void BinMXCAFDoc_NoteBinDataDriver::Paste( { theTarget << aNote->Title() << aNote->MIMEtype() << aNote->Size(); if (aNote->Size() > 0) + { theTarget.PutByteArray(&aNote->Data()->ChangeFirst(), aNote->Size()); + } } } diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx index cb303e1312..f6328194fd 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx @@ -43,15 +43,21 @@ bool BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent& theS BinObjMgt_RRelocationTable& theRelocTable) const { if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable)) + { return false; + } occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } TCollection_ExtendedString aComment; if (!(theSource >> aComment)) + { return false; + } aNote->Set(aComment); @@ -69,7 +75,9 @@ void BinMXCAFDoc_NoteCommentDriver::Paste( occ::handle aNote = occ::down_cast(theSource); if (!aNote.IsNull()) + { theTarget << aNote->Comment(); + } } //================================================================================================= diff --git a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx index d218a5fc82..5a62735627 100644 --- a/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx +++ b/src/DataExchange/TKBinXCAF/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx @@ -37,11 +37,15 @@ bool BinMXCAFDoc_NoteDriver::Paste(const BinObjMgt_Persistent& theSource, { occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } TCollection_ExtendedString aUserName, aTimeStamp; if (!(theSource >> aUserName >> aTimeStamp)) + { return false; + } aNote->Set(aUserName, aTimeStamp); @@ -57,5 +61,7 @@ void BinMXCAFDoc_NoteDriver::Paste( { occ::handle aNote = occ::down_cast(theSource); if (!aNote.IsNull()) + { theTarget << aNote->UserName() << aNote->TimeStamp(); + } } diff --git a/src/DataExchange/TKDE/DE/DE_ConfigurationContext.cxx b/src/DataExchange/TKDE/DE/DE_ConfigurationContext.cxx index b62c6ce7aa..aa3b36e2dd 100644 --- a/src/DataExchange/TKDE/DE/DE_ConfigurationContext.cxx +++ b/src/DataExchange/TKDE/DE/DE_ConfigurationContext.cxx @@ -95,7 +95,9 @@ static DE_ConfigurationContext_KindOfLine WhatKindOfLine(const TCollection_Ascii } for (aPos = aPos2 - 1; aLine.Value(aPos) == '\t' || aLine.Value(aPos) == ' '; aPos--) + { ; + } theToken1 = aLine.SubString(aPos1, aPos); if (aPos2 != aLine.Length()) @@ -209,7 +211,9 @@ bool DE_ConfigurationContext::LoadStr(const TCollection_AsciiString& theResource { const char aChar = theResource.Value(anInd); if (aChar != '\n') + { aLine += aChar; + } if ((aChar == '\n' || anInd == aLength) && !aLine.IsEmpty()) { if (!load(aLine)) diff --git a/src/DataExchange/TKDE/DE/DE_Wrapper.cxx b/src/DataExchange/TKDE/DE/DE_Wrapper.cxx index e948e43973..588d9b932e 100644 --- a/src/DataExchange/TKDE/DE/DE_Wrapper.cxx +++ b/src/DataExchange/TKDE/DE/DE_Wrapper.cxx @@ -689,7 +689,9 @@ Standard_EXPORT void DE_Wrapper::UpdateLoad(const bool theToForceUpdate) const aNode->UpdateLoad(true, true); aNode->UpdateLoad(false, true); if (!theToForceUpdate) + { continue; + } aNode->SetEnabled(aNode->IsExportSupported() || aNode->IsImportSupported()); } } diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx index a1470e29c4..fea83b322a 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx @@ -2474,7 +2474,9 @@ void RWGltf_CafWriter::writeExtrasAttributes(const occ::handleLoadDeferredData(); if (theNamedData->HasIntegers()) { diff --git a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx index fd2f0e27d9..b27d1fd19e 100644 --- a/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx +++ b/src/DataExchange/TKDEGLTF/RWGltf/RWGltf_GltfJsonParser.cxx @@ -1697,7 +1697,9 @@ bool RWGltf_GltfJsonParser::gltfParseSceneNode(TopoDS_Shape& th aBuilder.Add(aNodeShape, aMeshShape); ++aNbSubShapes; if (aHasScale) + { myShapeScaleMap->Bind(aMeshShape, aScale); + } } } diff --git a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BREntity.cxx b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BREntity.cxx index ddf470e0ba..0c19121fc6 100644 --- a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BREntity.cxx +++ b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BREntity.cxx @@ -72,7 +72,9 @@ void BRepToIGES_BREntity::SetModel(const occ::handle& model) TheModel = model; double unitfactor = TheModel->GlobalSection().UnitValue(); if (unitfactor != 1.) + { TheUnitFactor = unitfactor; + } } //================================================================================================= @@ -114,7 +116,9 @@ occ::handle BRepToIGES_BREntity::TransferShape( // int Nb = 1; //szv#4:S4163:12Mar99 not needed if (start.IsNull()) + { return res; + } if (start.ShapeType() == TopAbs_VERTEX) { @@ -231,7 +235,9 @@ bool BRepToIGES_BREntity::HasShapeResult(const TopoDS_Shape& start) const occ::handle Mapper = new TransferBRep_ShapeMapper(start); DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper)); if (binder.IsNull()) + { return false; + } return binder->HasResult(); } @@ -244,9 +250,13 @@ occ::handle BRepToIGES_BREntity::GetShapeResult(const TopoDS occ::handle Mapper = new TransferBRep_ShapeMapper(start); DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper)); if (binder.IsNull()) + { return res; + } if (binder->HasResult()) + { res = binder->Result(); + } return res; } @@ -268,7 +278,9 @@ bool BRepToIGES_BREntity::HasShapeResult(const occ::handle& occ::handle Mapper = new Transfer_TransientMapper(start); DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper)); if (binder.IsNull()) + { return false; + } return binder->HasResult(); } @@ -282,9 +294,13 @@ occ::handle BRepToIGES_BREntity::GetShapeResult( occ::handle Mapper = new Transfer_TransientMapper(start); DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper)); if (binder.IsNull()) + { return res; + } if (binder->HasResult()) + { res = binder->Result(); + } return res; } diff --git a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRShell.cxx b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRShell.cxx index b67a4dcaba..addb8f7758 100644 --- a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRShell.cxx +++ b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRShell.cxx @@ -82,7 +82,9 @@ occ::handle BRepToIGES_BRShell ::TransferShell( occ::handle res; if (start.IsNull()) + { return res; + } if (start.ShapeType() == TopAbs_FACE) { @@ -184,8 +186,10 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ TopoDS_Edge aCopyEdge = TopoDS::Edge(aCopy.ModifiedShape(anOrigEdge)); aCopyEdge = TopoDS::Edge(aCopyEdge.Oriented(anOrigEdge.Orientation())); if (!aMap.Add(aCopyEdge)) + { // seam edge has been already updated continue; + } double f, l; occ::handle aCurve1, aCurve2; aCurve1 = @@ -275,11 +279,17 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ occ::handle ICurve3d = BW.TransferWire(Outer, aFace, aShapeShapeMap, ICurve2d, Length); if ((!ICurve3d.IsNull()) && (!ICurve2d.IsNull())) + { Iprefer = 3; + } if ((!ICurve3d.IsNull()) && (ICurve2d.IsNull())) + { Iprefer = 2; + } if ((ICurve3d.IsNull()) && (!ICurve2d.IsNull())) + { Iprefer = 1; + } IOuter->Init(Imode, ISurf, ICurve2d, ICurve3d, Iprefer); } @@ -301,14 +311,22 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ occ::handle ICurve3d = BW.TransferWire(W, aFace, aShapeShapeMap, ICurve2d, Length); if ((!ICurve3d.IsNull()) && (!ICurve2d.IsNull())) + { Iprefer = 3; + } if ((!ICurve3d.IsNull()) && (ICurve2d.IsNull())) + { Iprefer = 2; + } if ((ICurve3d.IsNull()) && (!ICurve2d.IsNull())) + { Iprefer = 1; + } Curve->Init(Imode, ISurf, ICurve2d, ICurve3d, Iprefer); if (!Curve.IsNull()) + { Seq->Append(Curve); + } } } @@ -327,14 +345,22 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ occ::handle newICurve2d = BW.TransferEdge(E, aFace, aShapeShapeMap, Length, false); if ((!ICurve3d.IsNull()) && (!newICurve2d.IsNull())) + { Iprefer = 3; + } if ((!ICurve3d.IsNull()) && (newICurve2d.IsNull())) + { Iprefer = 2; + } if ((ICurve3d.IsNull()) && (!newICurve2d.IsNull())) + { Iprefer = 1; + } Curve->Init(Imode, ISurf, newICurve2d, ICurve3d, Iprefer); if (!Curve.IsNull()) + { Seq->Append(Curve); + } } } @@ -357,7 +383,9 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ || Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || Surf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) && !IOuter.IsNull()) + { isWholeSurface = false; + } // returns the TrimmedSurface // -------------------------- occ::handle TrimmedSurf = new IGESGeom_TrimmedSurface; @@ -367,7 +395,9 @@ occ::handle BRepToIGES_BRShell ::TransferFace(const TopoDS_ TrimmedSurf->Init(ISurf, false, nullptr, Tab); } else + { TrimmedSurf->Init(ISurf, true, IOuter, Tab); + } res = TrimmedSurf; SetShapeResult(start, res); @@ -384,7 +414,9 @@ occ::handle BRepToIGES_BRShell::TransferShell( { occ::handle res; if (start.IsNull()) + { return res; + } TopExp_Explorer Ex; occ::handle IGroup = new IGESBasic_Group; @@ -394,7 +426,9 @@ occ::handle BRepToIGES_BRShell::TransferShell( int nbshapes = 0; for (Ex.Init(start, TopAbs_FACE); Ex.More(); Ex.Next()) + { nbshapes++; + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (Ex.Init(start, TopAbs_FACE); Ex.More() && aPS.More(); Ex.Next()) { @@ -408,7 +442,9 @@ occ::handle BRepToIGES_BRShell::TransferShell( { IFace = TransferFace(F, aRange); if (!IFace.IsNull()) + { Seq->Append(IFace); + } } } diff --git a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRSolid.cxx b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRSolid.cxx index 940ca0d3dc..24d4dc01b6 100644 --- a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRSolid.cxx +++ b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRSolid.cxx @@ -68,7 +68,9 @@ occ::handle BRepToIGES_BRSolid ::TransferSolid( occ::handle res; if (start.IsNull()) + { return res; + } if (start.ShapeType() == TopAbs_SOLID) { @@ -103,7 +105,9 @@ occ::handle BRepToIGES_BRSolid ::TransferSolid( { occ::handle res; if (start.IsNull()) + { return res; + } TopExp_Explorer Ex; occ::handle IShell; @@ -113,7 +117,9 @@ occ::handle BRepToIGES_BRSolid ::TransferSolid( int nbshapes = 0; for (Ex.Init(start, TopAbs_SHELL); Ex.More(); Ex.Next()) + { nbshapes++; + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (Ex.Init(start, TopAbs_SHELL); Ex.More() && aPS.More(); Ex.Next()) { @@ -127,7 +133,9 @@ occ::handle BRepToIGES_BRSolid ::TransferSolid( { IShell = BS.TransferShell(S, aRange); if (!IShell.IsNull()) + { Seq->Append(IShell); + } } } @@ -169,7 +177,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompSolid( { occ::handle res; if (start.IsNull()) + { return res; + } TopExp_Explorer Ex; occ::handle ISolid; @@ -178,7 +188,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompSolid( int nbshapes = 0; for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbshapes++; + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (Ex.Init(start, TopAbs_SOLID); Ex.More() && aPS.More(); Ex.Next()) { @@ -192,7 +204,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompSolid( { ISolid = TransferSolid(S, aRange); if (!ISolid.IsNull()) + { Seq->Append(ISolid); + } } } @@ -234,7 +248,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { occ::handle res; if (start.IsNull()) + { return res; + } TopExp_Explorer Ex; occ::handle IShape; @@ -246,17 +262,29 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( // count numbers of subshapes int nbshapes = 0; for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) + { nbshapes++; + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); // take all Solids @@ -272,7 +300,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { IShape = TransferSolid(S, aRange); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -289,7 +319,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { IShape = BS.TransferShell(S, aRange); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -306,7 +338,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { IShape = BS.TransferFace(S, aRange); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -322,7 +356,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { IShape = BW.TransferWire(S); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -339,7 +375,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( NCollection_DataMap anEmptyMap; IShape = BW.TransferEdge(S, anEmptyMap, false); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -355,7 +393,9 @@ occ::handle BRepToIGES_BRSolid ::TransferCompound( { IShape = BW.TransferVertex(S); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } diff --git a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRWire.cxx b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRWire.cxx index fd9096ba23..03dce624ef 100644 --- a/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRWire.cxx +++ b/src/DataExchange/TKDEIGES/BRepToIGES/BRepToIGES_BRWire.cxx @@ -91,7 +91,9 @@ occ::handle BRepToIGES_BRWire ::TransferWire(const TopoDS_S occ::handle res; if (start.IsNull()) + { return res; + } if (start.ShapeType() == TopAbs_VERTEX) { @@ -125,7 +127,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS { occ::handle res; if (myvertex.IsNull()) + { return res; + } occ::handle Point; Point = new Geom_CartesianPoint(BRep_Tool::Pnt(myvertex)); @@ -138,7 +142,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS } if (!IVertex.IsNull()) + { res = IVertex; + } return res; } @@ -153,7 +159,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS { occ::handle res; if (myvertex.IsNull()) + { return res; + } occ::handle IVertex = TransferVertex(myvertex); @@ -161,7 +169,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS parameter = BRep_Tool::Parameter(myvertex, myedge); if (!IVertex.IsNull()) + { res = IVertex; + } return res; } @@ -177,7 +187,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS { occ::handle res; if (myvertex.IsNull()) + { return res; + } occ::handle IVertex = TransferVertex(myvertex); @@ -185,7 +197,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS parameter = BRep_Tool::Parameter(myvertex, myedge, myface); if (!IVertex.IsNull()) + { res = IVertex; + } return res; } @@ -203,7 +217,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex( { occ::handle res; if (myvertex.IsNull()) + { return res; + } occ::handle IVertex = TransferVertex(myvertex); @@ -211,7 +227,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex( parameter = BRep_Tool::Parameter(myvertex, myedge, mysurface, myloc); if (!IVertex.IsNull()) + { res = IVertex; + } return res; } @@ -226,7 +244,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS { occ::handle res; if (myvertex.IsNull()) + { return res; + } occ::handle IVertex = TransferVertex(myvertex); @@ -234,7 +254,9 @@ occ::handle BRepToIGES_BRWire ::TransferVertex(const TopoDS mypoint = BRep_Tool::Parameters(myvertex, myface); if (!IVertex.IsNull()) + { res = IVertex; + } return res; } @@ -249,7 +271,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( { occ::handle res; if (theEdge.IsNull()) + { return res; + } // returns the 3d curve of the edge and the parameter range TopLoc_Location L; @@ -268,9 +292,13 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( { gp_Trsf Tr = L.Transformation(); if (Tr.Form() != gp_Identity) + { Curve3d = occ::down_cast(Curve3d->Transformed(Tr)); + } else + { Curve3d = occ::down_cast(Curve3d->Copy()); + } if (theEdge.Orientation() == TopAbs_REVERSED && !theIsBRepMode) { @@ -294,7 +322,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( // the model if (!ICurve.IsNull()) + { res = ICurve; + } // In the reverted face's case find an origin by the reverted TopoDS_Edge anEdge = !theOriginMap.IsEmpty() ? TopoDS::Edge(theOriginMap.Find(theEdge)) : theEdge; @@ -317,7 +347,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( occ::handle res; if (theEdge.IsNull() || GetPCurveMode() == 0 || (!theIsBRepMode && BRep_Tool::Degenerated(theEdge))) + { return res; + } // S4181 pdn 23.04.99 adjusting length factor according to analytic mode. double myLen = theLength; @@ -353,7 +385,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( Surf = rectang->BasisSurface(); } else + { Surf = st; + } //: abv 19.06.02: writing (loopback) on file offseted_sphere.rle in BRep mode if (st->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) @@ -382,7 +416,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( curve = tc->BasisCurve(); } if (curve->IsKind(STANDARD_TYPE(Geom_Line))) + { needShift = true; + } } if (needShift) { @@ -391,7 +427,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( Curve2d = occ::down_cast(Curve2d->Transformed(TR)); } else + { Curve2d = occ::down_cast(Curve2d->Copy()); + } // shift pcurves on periodic BSpline surfaces (issue 26138) if (Surf->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) @@ -438,7 +476,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( if (analyticMode && (Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || Surf->IsKind(STANDARD_TYPE(Geom_ConicalSurface)))) + { myLen = M_PI / 180.; + } if (analyticMode && (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) @@ -471,7 +511,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( { double aDiv = myLen; if (aDiv < gp::Resolution()) + { aDiv = 1.; + } // emv: changed for bug OCC22126 17.12.2010 trans.SetScale(gp_Pnt2d(0, 0), 1. / (Vlast - Vfirst)); // uFact = myLen; @@ -531,7 +573,9 @@ occ::handle BRepToIGES_BRWire ::TransferEdge( // the model if (!ICurve2d.IsNull()) + { res = ICurve2d; + } // In the reverted face's case find an origin by the reverted TopoDS_Edge anEdge = !theOriginMap.IsEmpty() ? TopoDS::Edge(theOriginMap.Find(theEdge)) : theEdge; @@ -548,7 +592,9 @@ occ::handle BRepToIGES_BRWire ::TransferWire(const TopoDS_W { occ::handle res; if (mywire.IsNull()) + { return res; + } // A composite curve is defined as an ordered list of entities // consisting of a point, connect point and parametrised curve @@ -574,12 +620,16 @@ occ::handle BRepToIGES_BRWire ::TransferWire(const TopoDS_W NCollection_DataMap anEmptyMap; ent = TransferEdge(E, anEmptyMap, false); if (!ent.IsNull()) + { Seq->Append(ent); + } } } } else + { AddWarning(mywire, " no Vertex associated to the Wire"); + } int nbedges = Seq->Length(); occ::handle>> Tab; @@ -618,7 +668,9 @@ occ::handle BRepToIGES_BRWire ::TransferWire( { occ::handle res; if (theWire.IsNull()) + { return res; + } occ::handle ent3d; occ::handle ent2d; @@ -662,16 +714,22 @@ occ::handle BRepToIGES_BRWire ::TransferWire( { ent3d = TransferEdge(E, theOriginMap, false); if (!ent3d.IsNull()) + { Seq3d->Append(ent3d); + } ent2d = TransferEdge(E, theFace, theOriginMap, theLength, false); if (!ent2d.IsNull()) + { Seq2d->Append(ent2d); + } } } // OCC908 end of workaround } else + { AddWarning(theWire, " no Vertex associated to the Wire"); + } // Composite Curve 3D int nb3d = Seq3d->Length(); diff --git a/src/DataExchange/TKDEIGES/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx b/src/DataExchange/TKDEIGES/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx index 147d8a4d1e..1e6658769d 100644 --- a/src/DataExchange/TKDEIGES/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx +++ b/src/DataExchange/TKDEIGES/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx @@ -81,9 +81,13 @@ BRepToIGESBRep_Entity::BRepToIGESBRep_Entity() { Init(); if (myEdgeList.IsNull()) + { myEdgeList = new IGESSolid_EdgeList; + } if (myVertexList.IsNull()) + { myVertexList = new IGESSolid_VertexList; + } } //================================================================================================= @@ -105,7 +109,9 @@ void BRepToIGESBRep_Entity::TransferVertexList() int nbvertices = myVertices.Extent(); if (!nbvertices) + { return; + } occ::handle> vertices = new NCollection_HArray1(1, nbvertices); double Unit = GetUnit(); @@ -140,7 +146,9 @@ int BRepToIGESBRep_Entity::IndexVertex(const TopoDS_Vertex& myvertex) const int BRepToIGESBRep_Entity::AddVertex(const TopoDS_Vertex& myvertex) { if (myvertex.IsNull()) + { return 0; + } const TopoDS_Shape& V = myvertex; int index = myVertices.FindIndex(V); @@ -169,7 +177,9 @@ void BRepToIGESBRep_Entity::TransferEdgeList() int nbedges = myEdges.Extent(); if (!nbedges) + { return; + } occ::handle>> Curves = new NCollection_HArray1>(1, nbedges); occ::handle>> startVertexList = @@ -218,7 +228,9 @@ int BRepToIGESBRep_Entity::AddEdge(const TopoDS_Edge& myedg const occ::handle& mycurve3d) { if (myedge.IsNull()) + { return 0; + } const TopoDS_Shape& E = myedge; occ::handle C = mycurve3d; @@ -242,7 +254,9 @@ occ::handle BRepToIGESBRep_Entity::TransferShape( // TopoDS_Shape theShape; if (start.IsNull()) + { return res; + } if (start.ShapeType() == TopAbs_VERTEX) { @@ -306,7 +320,9 @@ occ::handle BRepToIGESBRep_Entity::TransferShape( } } if (res.IsNull()) + { return res; + } TransferVertexList(); TransferEdgeList(); @@ -325,7 +341,9 @@ occ::handle BRepToIGESBRep_Entity::TransferEdge(const TopoD occ::handle ICurve3d = occ::down_cast(myCurves(anInd)); if (!ICurve3d.IsNull()) + { return ICurve3d; + } } BRepToIGES_BRWire BR(*this); BR.SetModel(GetModel()); @@ -344,7 +362,9 @@ occ::handle BRepToIGESBRep_Entity::TransferEdge(const TopoD occ::handle ICurve3d; occ::handle ICurve2d; if (myedge.IsNull()) + { return ICurve2d; + } BRepToIGES_BRWire BR(*this); BR.SetModel(GetModel()); @@ -378,7 +398,9 @@ occ::handle BRepToIGESBRep_Entity::TransferWire(const TopoDS_Wir { occ::handle myLoop = new IGESSolid_Loop; if (mywire.IsNull()) + { return myLoop; + } occ::handle Pointeur; NCollection_Sequence Seqindex; @@ -431,14 +453,20 @@ occ::handle BRepToIGESBRep_Entity::TransferWire(const TopoDS_Wir } Seqindex.Append(myindex); if (E.Orientation() == TopAbs_FORWARD) + { Seqorient.Append(1); + } if (E.Orientation() == TopAbs_REVERSED) + { Seqorient.Append(0); + } } } } else + { AddWarning(mywire, " no Vertex associated to the Wire"); + } int nbedges = Seq2d->Length(); occ::handle> types = new NCollection_HArray1(1, nbedges); @@ -466,9 +494,13 @@ occ::handle BRepToIGESBRep_Entity::TransferWire(const TopoDS_Wir mytype = Seqtype.Value(itab); types->SetValue(itab, mytype); if (mytype == 0) + { Pointeur = myEdgeList; + } else + { Pointeur = myVertexList; + } edges->SetValue(itab, Pointeur); myindex = Seqindex.Value(itab); index->SetValue(itab, myindex); @@ -504,7 +536,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferFace(const TopoDS_Fa { occ::handle myent = new IGESSolid_Face; if (start.IsNull()) + { return myent; + } occ::handle ISurf; double Length = 1.; @@ -528,7 +562,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferFace(const TopoDS_Fa st = rectang->BasisSurface(); } else + { st = Surf; + } // S4181 pdn 17.04.99 Geom_Plane translated into GeomToIGES_GeomSurface ISurf = GS.TransferSurface(st, U1, U2, V1, V2); @@ -580,7 +616,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferFace(const TopoDS_Fa { InnerLoop = TransferWire(W, myface, Length); if (!InnerLoop.IsNull()) + { Seq->Append(InnerLoop); + } } } @@ -609,7 +647,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferFace(const TopoDS_Fa myent->Init(ISurf, OuterLoopFlag, TabLoop); if (IsReversed) + { myface.Reverse(); + } SetShapeResult(start, myent); @@ -626,7 +666,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferShell( { occ::handle myshell = new IGESSolid_Shell; if (start.IsNull()) + { return myshell; + } TopExp_Explorer Ex; occ::handle>> Seq = @@ -636,13 +678,16 @@ occ::handle BRepToIGESBRep_Entity ::TransferShell( int nbf = 0; for (Ex.Init(start, TopAbs_FACE); Ex.More(); Ex.Next()) + { nbf++; + } Message_ProgressScope aPS(theProgress, nullptr, nbf); for (Ex.Init(start, TopAbs_FACE); Ex.More() && aPS.More(); Ex.Next(), aPS.Next()) { TopoDS_Face F = TopoDS::Face(Ex.Current()); // clang-format off - if ( start.Orientation() == TopAbs_REVERSED ) F.Reverse(); //:l4 abv 12 Jan 99: CTS22022-2: writing reversed shells + if ( start.Orientation() == TopAbs_REVERSED ) { F.Reverse(); //:l4 abv 12 Jan 99: CTS22022-2: writing reversed shells +} // clang-format on if (F.IsNull()) { @@ -655,9 +700,13 @@ occ::handle BRepToIGESBRep_Entity ::TransferShell( { Seq->Append(IFace); if (F.Orientation() == TopAbs_FORWARD) + { SeqFlag.Append(1); + } if (F.Orientation() == TopAbs_REVERSED) + { SeqFlag.Append(0); + } } } } @@ -692,7 +741,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferSolid( { occ::handle mysol = new IGESSolid_ManifoldSolid; if (start.IsNull()) + { return mysol; + } TopExp_Explorer Ex; occ::handle IShell, FirstShell; @@ -703,7 +754,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferSolid( int nbs = 0; for (Ex.Init(start, TopAbs_SHELL); Ex.More(); Ex.Next()) + { nbs++; + } Message_ProgressScope aPS(theProgress, nullptr, nbs); for (Ex.Init(start, TopAbs_SHELL); Ex.More() && aPS.More(); Ex.Next()) { @@ -720,9 +773,13 @@ occ::handle BRepToIGESBRep_Entity ::TransferSolid( { Seq->Append(IShell); if (S.Orientation() == TopAbs_FORWARD) + { SeqFlag.Append(1); + } if (S.Orientation() == TopAbs_REVERSED) + { SeqFlag.Append(0); + } } } } @@ -764,7 +821,9 @@ occ::handle BRepToIGESBRep_Entity ::TransferSolid( mysol->Init(FirstShell, ShellFlag != 0, Tab, TabFlag); } else + { AddWarning(start, " no Result "); + } SetShapeResult(start, mysol); @@ -782,7 +841,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompSolid( { occ::handle myent; if (start.IsNull()) + { return myent; + } TopExp_Explorer Ex; occ::handle ISolid = new IGESSolid_ManifoldSolid; @@ -791,7 +852,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompSolid( int nbs = 0; for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbs++; + } Message_ProgressScope aPS(theProgress, nullptr, nbs); for (Ex.Init(start, TopAbs_SOLID); Ex.More() && aPS.More(); Ex.Next()) { @@ -805,7 +868,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompSolid( { ISolid = TransferSolid(S, aRange); if (!ISolid.IsNull()) + { Seq->Append(ISolid); + } } } @@ -848,7 +913,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( { occ::handle res; if (start.IsNull()) + { return res; + } TopExp_Explorer Ex; occ::handle IShape; @@ -858,17 +925,29 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( // count numbers of subshapes int nbshapes = 0; for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) + { nbshapes++; + } for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) + { nbshapes++; + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); // take all Solids @@ -884,7 +963,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( { IShape = TransferSolid(S, aRange); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -901,7 +982,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( { IShape = TransferShell(S, aRange); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -917,7 +1000,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( { IShape = TransferFace(S); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } } @@ -930,7 +1015,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( BW.SetModel(GetModel()); IShape = BW.TransferWire(S); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } // take all isolated Edges @@ -943,7 +1030,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( NCollection_DataMap anEmptyMap; IShape = BW.TransferEdge(S, anEmptyMap, false); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } // take all isolated Vertices @@ -955,7 +1044,9 @@ occ::handle BRepToIGESBRep_Entity::TransferCompound( BW.SetModel(GetModel()); IShape = BW.TransferVertex(S); if (!IShape.IsNull()) + { Seq->Append(IShape); + } } // construct the group diff --git a/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx b/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx index e6ef5a7088..299813b4bd 100644 --- a/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx +++ b/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx @@ -38,15 +38,21 @@ TEST(IGESExportTest, SharedCurvesBRepMode) occ::handle aBinder = occ::down_cast(aFP->MapItem(i)); if (aBinder.IsNull()) + { continue; + } occ::handle anEnt = occ::down_cast(aBinder->Result()); if (anEnt.IsNull()) + { continue; + } occ::handle aLine = occ::down_cast(anEnt); if (aLine.IsNull()) + { continue; + } // Check that all the entities are in the model. EXPECT_TRUE(aModel->DNum(anEnt) != 0); diff --git a/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomCurve.cxx b/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomCurve.cxx index f19cb300cb..2250f441ed 100644 --- a/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomCurve.cxx +++ b/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomCurve.cxx @@ -169,15 +169,21 @@ static gp_XYZ GetAnyNormal(gp_XYZ orig) { gp_XYZ Norm; if (std::abs(orig.Z()) < Precision::Confusion()) + { Norm.SetCoord(0, 0, 1); + } else { Norm.SetCoord(orig.Z(), 0, -orig.X()); double nrm = Norm.Modulus(); if (nrm < Precision::Confusion()) + { Norm.SetCoord(0, 0, 1); + } else + { Norm = Norm / nrm; + } } return Norm; } @@ -198,7 +204,9 @@ static bool ArePolesPlanar(const NCollection_Array1& Poles, gp_XYZ& Norm Normal = Poles(Poles.Length()).XYZ() ^ Poles(1).XYZ(); int i; // svv Jan 10 2000 : porting on DEC for (i = 1; i < Poles.Length(); i++) + { Normal += Poles(i).XYZ() ^ Poles(i + 1).XYZ(); + } constexpr double tol = Precision::Confusion(); double nrm = Normal.Modulus(); @@ -211,8 +219,12 @@ static bool ArePolesPlanar(const NCollection_Array1& Poles, gp_XYZ& Norm double scl = Poles(1).XYZ() * Normal; for (i = 2; i <= Poles.Length(); i++) + { if (std::abs(Poles(i).XYZ() * Normal - scl) > tol) + { return false; + } + } return true; } @@ -297,18 +309,26 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double Umin = Udeb; double Umax = Ufin; if (Precision::IsNegativeInfinite(Udeb)) + { Umin = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Ufin)) + { Umax = Precision::Infinite(); + } //%12 pdn: cut curve for E3 double First = mycurve->FirstParameter(); double Last = mycurve->LastParameter(); //: l5 abv 14 Jan 99: protect against exceptions in Segment() if (Umin - First < Precision::PConfusion()) + { Umin = First; + } if (Last - Umax < Precision::PConfusion()) + { Umax = Last; + } if (Umin - First > Precision::PConfusion() || Last - Umax > Precision::PConfusion()) { try @@ -318,7 +338,9 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( if (!bspl.IsNull()) { if (std::abs(Umax - Umin) > Precision::PConfusion()) + { bspl->Segment(Umin, Umax); + } mycurve = bspl; } } @@ -391,7 +413,9 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( //%11 pdn 13.01.98 computing planar flag and normal IPlan = IsPlanar(start, Norm); if (Norm.Z() < 0) + { Norm.Reverse(); + } BSplineC->Init(Index, Deg, IPlan, IClos, IPolyn, IPerio, Knots, Weights, Poles, Umin, Umax, Norm); res = BSplineC; @@ -523,7 +547,9 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (std::abs(Udeb) <= gp::Resolution()) + { U1 = 0.0; + } // creation du "CircularArc" (#100) // -------------------------------- @@ -543,9 +569,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( gp_Pnt pfirst, plast; start->D0(U1, pfirst); if (std::abs(Ufin - Udeb - 2 * M_PI) <= Precision::PConfusion()) + { plast = pfirst; + } else + { start->D0(U2, plast); + } // Build.EvalXYZ(((start->Circ()).Location()).XYZ(), Xc, Yc, Zc); Build.EvalXYZ(pfirst.XYZ(), Xs, Ys, Zs); @@ -601,9 +631,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( const occ::handle& aCopy = copystart; // to avoid ambiguity GeomConvert_ApproxCurve approx(aCopy, Precision::Approximation(), GeomAbs_C1, 100, 6); if (approx.HasResult()) + { Bspline = approx.Curve(); + } if (Bspline.IsNull()) + { Bspline = GeomConvert::CurveToBSplineCurve(copystart, Convert_QuasiAngular); + } NCollection_Array1 Knots(Bspline->Knots()); BSplCLib::Reparametrize(Udeb, Udeb + 2 * M_PI, Knots); Bspline->SetKnots(Knots); @@ -615,7 +649,9 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (std::abs(Udeb) <= gp::Resolution()) + { U1 = 0.0; + } // creation du "ConicArc" (#104) // ----------------------------- @@ -684,9 +720,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (Precision::IsNegativeInfinite(Udeb)) + { U1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Ufin)) + { U2 = Precision::Infinite(); + } // creation du "ConicArc" (#104) // ----------------------------- @@ -753,9 +793,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (Precision::IsNegativeInfinite(Udeb)) + { U1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Ufin)) + { U2 = Precision::Infinite(); + } // creation du "ConicArc" (#104) // ----------------------------- @@ -820,9 +864,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (Precision::IsNegativeInfinite(Udeb)) + { U1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Ufin)) + { U2 = Precision::Infinite(); + } // creation du "Line" (#110) // ------------------------- @@ -857,9 +905,13 @@ occ::handle GeomToIGES_GeomCurve::TransferCurve( double U1 = Udeb; double U2 = Ufin; if (Precision::IsNegativeInfinite(Udeb)) + { U1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Ufin)) + { U2 = Precision::Infinite(); + } if (Interface_Static::IVal("write.iges.offset.mode") == 0) { diff --git a/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomSurface.cxx b/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomSurface.cxx index 7a9329f03a..1c7ee23c6b 100644 --- a/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomSurface.cxx +++ b/src/DataExchange/TKDEIGES/GeomToIGES/GeomToIGES_GeomSurface.cxx @@ -245,40 +245,60 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( if (!PeriodU) { if (Umin < U0) + { Umin = U0; + } if (U1 < Umax) + { Umax = U1; + } } else { if (std::abs(Umin - U0) < Precision::PConfusion()) + { Umin = U0; + } if (std::abs(Umax - U1) < Precision::PConfusion()) + { Umax = U1; + } uShift = ShapeAnalysis::AdjustToPeriod(Umin, U0, U1); Umin += uShift; Umax += uShift; if (Umax - Umin > U1 - U0) + { Umax = Umin + (U1 - U0); + } } if (!PeriodV) { if (Vmin < V0) + { Vmin = V0; + } if (V1 < Vmax) + { Vmax = V1; + } } else { if (std::abs(Vmin - V0) < Precision::PConfusion()) + { Vmin = V0; + } if (std::abs(Vmax - V1) < Precision::PConfusion()) + { Vmax = V1; + } vShift = ShapeAnalysis::AdjustToPeriod(Vmin, V0, V1); Vmin += vShift; Vmax += vShift; if (Vmax - Vmin > V1 - V0) + { Vmax = Vmin + (V1 - V0); + } } // unperiodize surface to get necessary for IGES standard number of knots and mults if (mysurface->IsUPeriodic()) @@ -376,7 +396,9 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( for (iw = 1; iw <= IndexU + 1; iw++) { for (jw = 1; jw <= IndexV + 1; jw++) + { Weights->SetValue(WeightRow, WeightCol++, mysurface->Weight(iw, jw)); + } WeightRow++; WeightCol = Weights->LowerCol(); } @@ -386,7 +408,9 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( for (iw = 1; iw <= IndexU + 1; iw++) { for (jw = 1; jw <= IndexV + 1; jw++) + { Weights->SetValue(WeightRow, WeightCol++, 1.0); + } WeightRow++; WeightCol = Weights->LowerCol(); } @@ -517,41 +541,61 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( { DeclareAndCast(Geom_Plane, Plane, start); if (myBRepMode) + { res = TransferPlaneSurface(Plane, Udeb, Ufin, Vdeb, Vfin); + } else + { res = TransferSurface(Plane, Udeb, Ufin, Vdeb, Vfin); + } } else if (start->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { DeclareAndCast(Geom_CylindricalSurface, Cylindrical, start); if (myBRepMode && myAnalytic) + { res = TransferCylindricalSurface(Cylindrical, Udeb, Ufin, Vdeb, Vfin); + } else + { res = TransferSurface(Cylindrical, Udeb, Ufin, Vdeb, Vfin); + } } else if (start->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) { DeclareAndCast(Geom_ConicalSurface, Conical, start); if (myBRepMode && myAnalytic) + { res = TransferConicalSurface(Conical, Udeb, Ufin, Vdeb, Vfin); + } else + { res = TransferSurface(Conical, Udeb, Ufin, Vdeb, Vfin); + } } else if (start->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { DeclareAndCast(Geom_SphericalSurface, Spherical, start); if (myBRepMode && myAnalytic) + { res = TransferSphericalSurface(Spherical, Udeb, Ufin, Vdeb, Vfin); + } else + { res = TransferSurface(Spherical, Udeb, Ufin, Vdeb, Vfin); + } } else if (start->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) { DeclareAndCast(Geom_ToroidalSurface, Toroidal, start); if (myBRepMode && myAnalytic) + { res = TransferToroidalSurface(Toroidal, Udeb, Ufin, Vdeb, Vfin); + } else + { res = TransferSurface(Toroidal, Udeb, Ufin, Vdeb, Vfin); + } } return res; @@ -679,9 +723,13 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( double V1 = Vdeb; double V2 = Vfin; if (Precision::IsNegativeInfinite(Vdeb)) + { V1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Vfin)) + { V2 = Precision::Infinite(); + } // creation of the generatrix : Generatrix occ::handle Ligne = @@ -756,9 +804,13 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( double V1 = Vdeb; double V2 = Vfin; if (Precision::IsNegativeInfinite(Vdeb)) + { V1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Vfin)) + { V2 = Precision::Infinite(); + } // creation of the generatrix : Generatrix occ::handle Ligne = @@ -1004,9 +1056,13 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( double V1 = Vdeb; double V2 = Vfin; if (Precision::IsNegativeInfinite(Vdeb)) + { V1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Vfin)) + { V2 = Precision::Infinite(); + } // added by skl 18.07.2005 for OCC9490 double UF, UL, VF, VL; @@ -1085,9 +1141,13 @@ occ::handle GeomToIGES_GeomSurface::TransferSurface( double V1 = Vdeb; double V2 = Vfin; if (Precision::IsNegativeInfinite(Vdeb)) + { V1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(Vfin)) + { V2 = Precision::Infinite(); + } // creation of the generatrix : Generatrix occ::handle Curve = start->BasisCurve(); diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ElementResults.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ElementResults.cxx index 7a535a5361..fec47ea947 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ElementResults.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ElementResults.cxx @@ -54,15 +54,21 @@ void IGESAppli_ElementResults::Init( || allDataLayerFlags->Upper() != num || allnbResDataLocs->Lower() != 1 || allnbResDataLocs->Upper() != num || allResDataLocs->Lower() != 1 || allResDataLocs->Upper() != num || allResults->Lower() != 1 || allResults->Upper() != num) + { throw Standard_DimensionMismatch("IGESAppli_ElementsResults : Init"); + } for (int i = 1; i <= num; i++) { int nl = nbLayers->Value(i); int nrl = allnbResDataLocs->Value(i); if (allResDataLocs->Value(i)->Lower() != 1 || allResDataLocs->Value(i)->Upper() != nrl) + { throw Standard_DimensionMismatch("IGESAppli_ElementsResults : DataLoc"); + } if (allResults->Value(i)->Lower() != 1 || allResults->Value(i)->Upper() != nl * nrl * nbResults) + { throw Standard_DimensionMismatch("IGESAppli_ElementsResults : Results"); + } } theNote = aNote; @@ -85,7 +91,9 @@ void IGESAppli_ElementResults::Init( void IGESAppli_ElementResults::SetFormNumber(const int form) { if (form < 0 || form > 34) + { throw Standard_OutOfRange("IGESAppli_ElementResults : SetFormNumber"); + } InitTypeAndForm(148, form); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FiniteElement.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FiniteElement.cxx index 70a73c59bc..bf345e600b 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FiniteElement.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FiniteElement.cxx @@ -33,7 +33,9 @@ void IGESAppli_FiniteElement::Init( const occ::handle& aName) { if (allNodes->Lower() != 1) + { throw Standard_DimensionMismatch("IGESAppli_FiniteElement : Init"); + } theTopology = aType; theNodes = allNodes; theName = aName; diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Flow.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Flow.cxx index 2bc3fbfa29..9d11f3e43a 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Flow.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Flow.cxx @@ -53,7 +53,9 @@ void IGESAppli_Flow::Init( bool IGESAppli_Flow::OwnCorrect() { if (theNbContextFlags == 2) + { return false; + } theNbContextFlags = 2; return true; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FlowLineSpec.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FlowLineSpec.cxx index adeb9e8e64..35c2235101 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FlowLineSpec.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_FlowLineSpec.cxx @@ -29,7 +29,9 @@ void IGESAppli_FlowLineSpec::Init( const occ::handle>>& allProperties) { if (allProperties->Lower() != 1) + { throw Standard_DimensionMismatch("IGESAppli_FlowLineSpec : Init"); + } theNameAndModifiers = allProperties; InitTypeAndForm(406, 14); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_GeneralModule.cxx index 74bb57efd3..edf1cee024 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_GeneralModule.cxx @@ -77,7 +77,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolDrilledHole tool; tool.OwnShared(anent, iter); } @@ -85,7 +87,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolElementResults tool; tool.OwnShared(anent, iter); } @@ -93,7 +97,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFiniteElement tool; tool.OwnShared(anent, iter); } @@ -101,7 +107,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlow tool; tool.OwnShared(anent, iter); } @@ -109,7 +117,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlowLineSpec tool; tool.OwnShared(anent, iter); } @@ -117,7 +127,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelFunction tool; tool.OwnShared(anent, iter); } @@ -125,7 +137,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelToPWBLayerMap tool; tool.OwnShared(anent, iter); } @@ -133,7 +147,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLineWidening tool; tool.OwnShared(anent, iter); } @@ -141,7 +157,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalConstraint tool; tool.OwnShared(anent, iter); } @@ -149,7 +167,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalDisplAndRot tool; tool.OwnShared(anent, iter); } @@ -157,7 +177,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalResults tool; tool.OwnShared(anent, iter); } @@ -165,7 +187,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNode tool; tool.OwnShared(anent, iter); } @@ -173,7 +197,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBArtworkStackup tool; tool.OwnShared(anent, iter); } @@ -181,7 +207,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBDrilledHole tool; tool.OwnShared(anent, iter); } @@ -189,7 +217,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPartNumber tool; tool.OwnShared(anent, iter); } @@ -197,7 +227,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPinNumber tool; tool.OwnShared(anent, iter); } @@ -205,7 +237,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPipingFlow tool; tool.OwnShared(anent, iter); } @@ -213,7 +247,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolReferenceDesignator tool; tool.OwnShared(anent, iter); } @@ -221,7 +257,9 @@ void IGESAppli_GeneralModule::OwnSharedCase(const int case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolRegionRestriction tool; tool.OwnShared(anent, iter); } @@ -240,133 +278,171 @@ IGESData_DirChecker IGESAppli_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolDrilledHole tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolElementResults tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolFiniteElement tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolFlow tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolFlowLineSpec tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolLevelFunction tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolLevelToPWBLayerMap tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolLineWidening tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolNodalConstraint tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolNodalDisplAndRot tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolNodalResults tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolNode tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPWBArtworkStackup tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPWBDrilledHole tool; return tool.DirChecker(anent); } case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPartNumber tool; return tool.DirChecker(anent); } case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPinNumber tool; return tool.DirChecker(anent); } case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPipingFlow tool; return tool.DirChecker(anent); } case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolReferenceDesignator tool; return tool.DirChecker(anent); } case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolRegionRestriction tool; return tool.DirChecker(anent); } @@ -386,7 +462,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolDrilledHole tool; tool.OwnCheck(anent, shares, ach); } @@ -394,7 +472,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolElementResults tool; tool.OwnCheck(anent, shares, ach); } @@ -402,7 +482,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFiniteElement tool; tool.OwnCheck(anent, shares, ach); } @@ -410,7 +492,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlow tool; tool.OwnCheck(anent, shares, ach); } @@ -418,7 +502,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlowLineSpec tool; tool.OwnCheck(anent, shares, ach); } @@ -426,7 +512,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelFunction tool; tool.OwnCheck(anent, shares, ach); } @@ -434,7 +522,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelToPWBLayerMap tool; tool.OwnCheck(anent, shares, ach); } @@ -442,7 +532,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLineWidening tool; tool.OwnCheck(anent, shares, ach); } @@ -450,7 +542,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalConstraint tool; tool.OwnCheck(anent, shares, ach); } @@ -458,7 +552,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalDisplAndRot tool; tool.OwnCheck(anent, shares, ach); } @@ -466,7 +562,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalResults tool; tool.OwnCheck(anent, shares, ach); } @@ -474,7 +572,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNode tool; tool.OwnCheck(anent, shares, ach); } @@ -482,7 +582,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBArtworkStackup tool; tool.OwnCheck(anent, shares, ach); } @@ -490,7 +592,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBDrilledHole tool; tool.OwnCheck(anent, shares, ach); } @@ -498,7 +602,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPartNumber tool; tool.OwnCheck(anent, shares, ach); } @@ -506,7 +612,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPinNumber tool; tool.OwnCheck(anent, shares, ach); } @@ -514,7 +622,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPipingFlow tool; tool.OwnCheck(anent, shares, ach); } @@ -522,7 +632,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolReferenceDesignator tool; tool.OwnCheck(anent, shares, ach); } @@ -530,7 +642,9 @@ void IGESAppli_GeneralModule::OwnCheckCase(const int case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolRegionRestriction tool; tool.OwnCheck(anent, shares, ach); } @@ -757,8 +871,12 @@ int IGESAppli_GeneralModule::CategoryNumber(const int CN, const Interface_ShareTool&) const { if (CN == 4 || CN == 5 || CN == 17) + { return Interface_Category::Number("Piping"); + } if (CN == 2 || CN == 3 || (CN >= 9 && CN <= 12)) + { return Interface_Category::Number("FEA"); + } return Interface_Category::Number("Professional"); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_LevelToPWBLayerMap.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_LevelToPWBLayerMap.cxx index 56d83bfea6..f804739709 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_LevelToPWBLayerMap.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_LevelToPWBLayerMap.cxx @@ -37,7 +37,9 @@ void IGESAppli_LevelToPWBLayerMap::Init( || (allNativeLevels->Lower() != 1 || allNativeLevels->Length() != num) || (allPhysLevels->Lower() != 1 || allPhysLevels->Length() != num) || (allExchIdents->Lower() != 1 || allExchIdents->Length() != num)) + { throw Standard_DimensionMismatch("IGESAppli_LevelToPWBLayerMap: Init"); + } theNbPropertyValues = nbPropVal; theExchangeFileLevelNumber = allExchLevels; theNativeLevel = allNativeLevels; diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalConstraint.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalConstraint.cxx index 38ddad68e1..f10e719e1c 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalConstraint.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalConstraint.cxx @@ -32,7 +32,9 @@ void IGESAppli_NodalConstraint::Init( const occ::handle>>& allTabData) { if (allTabData->Lower() != 1) + { throw Standard_DimensionMismatch("IGESAppli_NodalConstraint : Init"); + } theType = aType; theNode = aNode; theTabularDataProps = allTabData; diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalDisplAndRot.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalDisplAndRot.cxx index 946c74afd5..89dd2cc9b7 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalDisplAndRot.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalDisplAndRot.cxx @@ -41,8 +41,10 @@ void IGESAppli_NodalDisplAndRot::Init( || (allIdentifiers->Lower() != 1 || allIdentifiers->Length() != allNodes->Length()) || (allTransParams->Lower() != 1 || allTransParams->Length() != allNodes->Length()) || (allRotParams->Lower() != 1 || allRotParams->Length() != allNodes->Length())) + { throw Standard_DimensionMismatch( "IGESAppli_NodalDisplAndRot : Init(Lengths of arrays inconsistent)"); + } for (int i = 1; i <= allNodes->Length(); i++) { @@ -50,8 +52,10 @@ void IGESAppli_NodalDisplAndRot::Init( occ::handle> temp2 = allRotParams->Value(i); if ((temp1->Lower() != 1 || temp1->Length() != allNotes->Length()) || (temp2->Lower() != 1 || temp2->Length() != allNotes->Length())) + { throw Standard_DimensionMismatch( "IGESAppli_NodalDisplAndRot: Init(No. of Param per Node != Nbcases)"); + } } theNotes = allNotes; diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalResults.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalResults.cxx index 75fe90e1e7..5c315b92ed 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalResults.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_NodalResults.cxx @@ -40,7 +40,9 @@ void IGESAppli_NodalResults::Init( if (allNodes->Lower() != 1 || allNodeIdentifiers->Lower() != 1 || allNodes->Length() != allNodeIdentifiers->Length() || allData->LowerCol() != 1 || allData->LowerRow() != 1 || allNodes->Length() != allData->UpperRow()) + { throw Standard_DimensionMismatch("IGESAppli_NodalResults : Init"); + } theNote = aNote; theSubCaseNum = aNumber; theTime = aTime; @@ -54,7 +56,9 @@ void IGESAppli_NodalResults::Init( void IGESAppli_NodalResults::SetFormNumber(const int form) { if (form < 0 || form > 34) + { throw Standard_OutOfRange("IGESAppli_NodalResults : SetFormNumber"); + } InitTypeAndForm(146, form); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Node.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Node.cxx index 95da790229..46170ed2d7 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Node.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Node.cxx @@ -49,7 +49,9 @@ occ::handle IGESAppli_Node::System() const int IGESAppli_Node::SystemType() const { if (theSystem.IsNull()) - return 0; // 0 Global Cartesien + { + return 0; // 0 Global Cartesien + } return (theSystem->FormNumber() - 9); // 1 Cartesien, 2 Cylind. 3 Spher. } @@ -58,6 +60,8 @@ gp_Pnt IGESAppli_Node::TransformedNodalCoord() const gp_XYZ tempCoord = Coord().XYZ(); occ::handle temp = System(); if (!temp.IsNull()) + { temp->Value().Transforms(tempCoord); + } return gp_Pnt(tempCoord); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PWBArtworkStackup.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PWBArtworkStackup.cxx index 71120f6583..64fbaad1a9 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PWBArtworkStackup.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PWBArtworkStackup.cxx @@ -30,7 +30,9 @@ void IGESAppli_PWBArtworkStackup::Init(const int const occ::handle>& allLevelNums) { if (allLevelNums->Lower() != 1) + { throw Standard_DimensionMismatch("IGESAppli_PWBArtworkStackup : Init"); + } theNbPropertyValues = nbPropVal; theArtworkStackupIdent = anArtIdent; theLevelNumbers = allLevelNums; diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PipingFlow.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PipingFlow.cxx index 57b40cd07c..10d91ee86f 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PipingFlow.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_PipingFlow.cxx @@ -43,7 +43,9 @@ void IGESAppli_PipingFlow::Init( || allConnectPoints->Length() != num || allJoins->Lower() != 1 || allJoins->Length() != num || allFlowNames->Lower() != 1 || allFlowNames->Length() != num || allContFlowAssocs->Lower() != 1 || allContFlowAssocs->Length() != num) + { throw Standard_DimensionMismatch("IGESAppli_PipingFlow : Init"); + } theNbContextFlags = nbContextFlags; theTypeOfFlow = aFlowType; theFlowAssociativities = allFlowAssocs; @@ -58,7 +60,9 @@ void IGESAppli_PipingFlow::Init( bool IGESAppli_PipingFlow::OwnCorrect() { if (theNbContextFlags == 1) + { return false; + } theNbContextFlags = 1; return true; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Protocol.cxx index 9973ae0081..a1e0372bd4 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_Protocol.cxx @@ -52,51 +52,93 @@ occ::handle IGESAppli_Protocol::Resource(const int num) cons { occ::handle res; if (num == 1) + { res = IGESDefs::Protocol(); + } if (num == 2) + { res = IGESDraw::Protocol(); + } return res; } int IGESAppli_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESAppli_DrilledHole)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESAppli_ElementResults)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESAppli_FiniteElement)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESAppli_Flow)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESAppli_FlowLineSpec)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESAppli_LevelFunction)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESAppli_LevelToPWBLayerMap)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESAppli_LineWidening)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESAppli_NodalConstraint)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESAppli_NodalDisplAndRot)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESAppli_NodalResults)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESAppli_Node)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESAppli_PWBArtworkStackup)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESAppli_PWBDrilledHole)) + { return 14; + } else if (atype == STANDARD_TYPE(IGESAppli_PartNumber)) + { return 15; + } else if (atype == STANDARD_TYPE(IGESAppli_PinNumber)) + { return 16; + } else if (atype == STANDARD_TYPE(IGESAppli_PipingFlow)) + { return 17; + } else if (atype == STANDARD_TYPE(IGESAppli_ReferenceDesignator)) + { return 18; + } else if (atype == STANDARD_TYPE(IGESAppli_RegionRestriction)) + { return 19; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ReadWriteModule.cxx index 575606ee38..e6ceaab71a 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ReadWriteModule.cxx @@ -136,7 +136,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolDrilledHole tool; tool.ReadOwnParams(anent, IR, PR); } @@ -144,7 +146,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolElementResults tool; tool.ReadOwnParams(anent, IR, PR); } @@ -152,7 +156,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFiniteElement tool; tool.ReadOwnParams(anent, IR, PR); } @@ -160,7 +166,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlow tool; tool.ReadOwnParams(anent, IR, PR); } @@ -168,7 +176,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlowLineSpec tool; tool.ReadOwnParams(anent, IR, PR); } @@ -176,7 +186,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelFunction tool; tool.ReadOwnParams(anent, IR, PR); } @@ -184,7 +196,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelToPWBLayerMap tool; tool.ReadOwnParams(anent, IR, PR); } @@ -192,7 +206,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLineWidening tool; tool.ReadOwnParams(anent, IR, PR); } @@ -200,7 +216,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalConstraint tool; tool.ReadOwnParams(anent, IR, PR); } @@ -208,7 +226,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalDisplAndRot tool; tool.ReadOwnParams(anent, IR, PR); } @@ -216,7 +236,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalResults tool; tool.ReadOwnParams(anent, IR, PR); } @@ -224,7 +246,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNode tool; tool.ReadOwnParams(anent, IR, PR); } @@ -232,7 +256,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBArtworkStackup tool; tool.ReadOwnParams(anent, IR, PR); } @@ -240,7 +266,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBDrilledHole tool; tool.ReadOwnParams(anent, IR, PR); } @@ -248,7 +276,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPartNumber tool; tool.ReadOwnParams(anent, IR, PR); } @@ -256,7 +286,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPinNumber tool; tool.ReadOwnParams(anent, IR, PR); } @@ -264,7 +296,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPipingFlow tool; tool.ReadOwnParams(anent, IR, PR); } @@ -272,7 +306,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolReferenceDesignator tool; tool.ReadOwnParams(anent, IR, PR); } @@ -280,7 +316,9 @@ void IGESAppli_ReadWriteModule::ReadOwnParams(const int case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolRegionRestriction tool; tool.ReadOwnParams(anent, IR, PR); } @@ -299,7 +337,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolDrilledHole tool; tool.WriteOwnParams(anent, IW); } @@ -307,7 +347,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolElementResults tool; tool.WriteOwnParams(anent, IW); } @@ -315,7 +357,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFiniteElement tool; tool.WriteOwnParams(anent, IW); } @@ -323,7 +367,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlow tool; tool.WriteOwnParams(anent, IW); } @@ -331,7 +377,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlowLineSpec tool; tool.WriteOwnParams(anent, IW); } @@ -339,7 +387,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelFunction tool; tool.WriteOwnParams(anent, IW); } @@ -347,7 +397,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelToPWBLayerMap tool; tool.WriteOwnParams(anent, IW); } @@ -355,7 +407,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLineWidening tool; tool.WriteOwnParams(anent, IW); } @@ -363,7 +417,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalConstraint tool; tool.WriteOwnParams(anent, IW); } @@ -371,7 +427,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalDisplAndRot tool; tool.WriteOwnParams(anent, IW); } @@ -379,7 +437,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalResults tool; tool.WriteOwnParams(anent, IW); } @@ -387,7 +447,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNode tool; tool.WriteOwnParams(anent, IW); } @@ -395,7 +457,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBArtworkStackup tool; tool.WriteOwnParams(anent, IW); } @@ -403,7 +467,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBDrilledHole tool; tool.WriteOwnParams(anent, IW); } @@ -411,7 +477,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPartNumber tool; tool.WriteOwnParams(anent, IW); } @@ -419,7 +487,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPinNumber tool; tool.WriteOwnParams(anent, IW); } @@ -427,7 +497,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPipingFlow tool; tool.WriteOwnParams(anent, IW); } @@ -435,7 +507,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolReferenceDesignator tool; tool.WriteOwnParams(anent, IW); } @@ -443,7 +517,9 @@ void IGESAppli_ReadWriteModule::WriteOwnParams(const int case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolRegionRestriction tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_SpecificModule.cxx index ec2fb89370..34beb040ca 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_SpecificModule.cxx @@ -74,7 +74,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolDrilledHole tool; tool.OwnDump(anent, dumper, S, own); } @@ -82,7 +84,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 2: { DeclareAndCast(IGESAppli_ElementResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolElementResults tool; tool.OwnDump(anent, dumper, S, own); } @@ -90,7 +94,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 3: { DeclareAndCast(IGESAppli_FiniteElement, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFiniteElement tool; tool.OwnDump(anent, dumper, S, own); } @@ -98,7 +104,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlow tool; tool.OwnDump(anent, dumper, S, own); } @@ -106,7 +114,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 5: { DeclareAndCast(IGESAppli_FlowLineSpec, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolFlowLineSpec tool; tool.OwnDump(anent, dumper, S, own); } @@ -114,7 +124,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelFunction tool; tool.OwnDump(anent, dumper, S, own); } @@ -122,7 +134,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 7: { DeclareAndCast(IGESAppli_LevelToPWBLayerMap, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLevelToPWBLayerMap tool; tool.OwnDump(anent, dumper, S, own); } @@ -130,7 +144,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolLineWidening tool; tool.OwnDump(anent, dumper, S, own); } @@ -138,7 +154,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 9: { DeclareAndCast(IGESAppli_NodalConstraint, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalConstraint tool; tool.OwnDump(anent, dumper, S, own); } @@ -146,7 +164,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 10: { DeclareAndCast(IGESAppli_NodalDisplAndRot, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalDisplAndRot tool; tool.OwnDump(anent, dumper, S, own); } @@ -154,7 +174,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 11: { DeclareAndCast(IGESAppli_NodalResults, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNodalResults tool; tool.OwnDump(anent, dumper, S, own); } @@ -162,7 +184,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 12: { DeclareAndCast(IGESAppli_Node, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolNode tool; tool.OwnDump(anent, dumper, S, own); } @@ -170,7 +194,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 13: { DeclareAndCast(IGESAppli_PWBArtworkStackup, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBArtworkStackup tool; tool.OwnDump(anent, dumper, S, own); } @@ -178,7 +204,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPWBDrilledHole tool; tool.OwnDump(anent, dumper, S, own); } @@ -186,7 +214,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPartNumber tool; tool.OwnDump(anent, dumper, S, own); } @@ -194,7 +224,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPinNumber tool; tool.OwnDump(anent, dumper, S, own); } @@ -202,7 +234,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolPipingFlow tool; tool.OwnDump(anent, dumper, S, own); } @@ -210,7 +244,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolReferenceDesignator tool; tool.OwnDump(anent, dumper, S, own); } @@ -218,7 +254,9 @@ void IGESAppli_SpecificModule::OwnDump(const int C case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { return; + } IGESAppli_ToolRegionRestriction tool; tool.OwnDump(anent, dumper, S, own); } @@ -237,70 +275,90 @@ bool IGESAppli_SpecificModule::OwnCorrect(const int case 1: { DeclareAndCast(IGESAppli_DrilledHole, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolDrilledHole tool; return tool.OwnCorrect(anent); } case 4: { DeclareAndCast(IGESAppli_Flow, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolFlow tool; return tool.OwnCorrect(anent); } case 6: { DeclareAndCast(IGESAppli_LevelFunction, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolLevelFunction tool; return tool.OwnCorrect(anent); } case 8: { DeclareAndCast(IGESAppli_LineWidening, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolLineWidening tool; return tool.OwnCorrect(anent); } case 14: { DeclareAndCast(IGESAppli_PWBDrilledHole, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPWBDrilledHole tool; return tool.OwnCorrect(anent); } case 15: { DeclareAndCast(IGESAppli_PartNumber, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPartNumber tool; return tool.OwnCorrect(anent); } case 16: { DeclareAndCast(IGESAppli_PinNumber, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPinNumber tool; return tool.OwnCorrect(anent); } case 17: { DeclareAndCast(IGESAppli_PipingFlow, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolPipingFlow tool; return tool.OwnCorrect(anent); } case 18: { DeclareAndCast(IGESAppli_ReferenceDesignator, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolReferenceDesignator tool; return tool.OwnCorrect(anent); } case 19: { DeclareAndCast(IGESAppli_RegionRestriction, anent, ent); if (anent.IsNull()) + { break; + } IGESAppli_ToolRegionRestriction tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolDrilledHole.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolDrilledHole.cxx index 8e43522dee..5dac3d7001 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolDrilledHole.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolDrilledHole.cxx @@ -92,12 +92,14 @@ bool IGESAppli_ToolDrilledHole::OwnCorrect(const occ::handleNbPropertyValues() != 5); if (res) + { ent->Init(5, ent->DrillDiaSize(), ent->FinishDiaSize(), (ent->IsPlating() ? 1 : 0), ent->NbLowerLayer(), ent->NbHigherLayer()); + } if (ent->SubordinateStatus() != 0) { occ::handle nulevel; @@ -124,10 +126,16 @@ void IGESAppli_ToolDrilledHole::OwnCheck(const occ::handle& ach) const { if (ent->SubordinateStatus() != 0) + { if (ent->DefLevel() != IGESData_DefOne && ent->DefLevel() != IGESData_DefSeveral) + { ach->AddFail("Level type : Not value/reference"); + } + } if (ent->NbPropertyValues() != 5) + { ach->AddFail("Number of Property Values != 5"); + } } void IGESAppli_ToolDrilledHole::OwnDump(const occ::handle& ent, @@ -135,16 +143,20 @@ void IGESAppli_ToolDrilledHole::OwnDump(const occ::handle Standard_OStream& S, const int /*level*/) const { - S << "IGESAppli_DrilledHole" << std::endl; + S << "IGESAppli_DrilledHole" << '\n'; - S << "Number of property values : " << ent->NbPropertyValues() << std::endl; + S << "Number of property values : " << ent->NbPropertyValues() << '\n'; S << "Drill diameter size :" << ent->DrillDiaSize() << " "; - S << "Finish diameter size : " << ent->FinishDiaSize() << std::endl; + S << "Finish diameter size : " << ent->FinishDiaSize() << '\n'; S << "Plating indication flag : "; if (!ent->IsPlating()) + { S << "NO" << " - "; + } else + { S << "YES - "; + } S << "Lower Numbered Layer : " << ent->NbLowerLayer() << " "; - S << "Higher Numbered Layer : " << ent->NbHigherLayer() << std::endl; + S << "Higher Numbered Layer : " << ent->NbHigherLayer() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolElementResults.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolElementResults.cxx index c0fc39d317..4daddfce89 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolElementResults.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolElementResults.cxx @@ -83,7 +83,9 @@ void IGESAppli_ToolElementResults::ReadOwnParams(const occ::handle> vres; // szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "FEM Element Identifier", ival)) + { allElementIdentifiers->SetValue(nume, ival); + } if (PR.ReadEntity(IR, PR.Current(), "FEM Element Entity", STANDARD_TYPE(IGESAppli_FiniteElement), aFEM)) + { allElements->SetValue(nume, aFEM); + } if (PR.ReadInteger(PR.Current(), "FEM Element Topology Type", ival)) + { allElementTopologyType->SetValue(nume, ival); + } if (PR.ReadInteger(PR.Current(), "Nb. of layers", nl)) + { allNbLayers->SetValue(nume, nl); + } if (PR.ReadInteger(PR.Current(), "Data Layer Flag", ival)) + { allDataLayerFlag->SetValue(nume, ival); + } if (PR.ReadInteger(PR.Current(), "Nb. of result data locations", nrl)) + { allNbResultDataLocs->SetValue(nume, nrl); + } if (PR.ReadInts(PR.CurrentList(nrl), "Result data locations", rdrl)) + { allResultDataLoc->SetValue(nume, rdrl); + } // clang-format off PR.ReadInteger (PR.Current(), "Nb. of result data locations", numv); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on if (PR.ReadReals(PR.CurrentList(numv), "Result Data", vres)) + { allResultData->SetValue(nume, vres); + } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -157,10 +175,14 @@ void IGESAppli_ToolElementResults::WriteOwnParams(const occ::handleDataLayerFlag(i)); IW.Send(nrl); for (j = 1; j <= nrl; j++) + { IW.Send(ent->ResultDataLoc(i, j)); + } IW.Send(numv); for (j = 1; j <= numv; j++) + { IW.Send(ent->ResultData(i, j)); + } } } @@ -171,7 +193,9 @@ void IGESAppli_ToolElementResults::OwnShared(const occ::handleNbElements(); iter.GetOneItem(ent->Note()); for (i = 1; i <= num; i++) + { iter.GetOneItem(ent->Element(i)); + } } void IGESAppli_ToolElementResults::OwnCopy(const occ::handle& another, @@ -220,11 +244,15 @@ void IGESAppli_ToolElementResults::OwnCopy(const occ::handle> rdrl = new NCollection_HArray1(1, nrl); allResultDataLoc->SetValue(i, rdrl); for (j = 1; j <= nrl; j++) + { rdrl->SetValue(j, another->ResultDataLoc(i, j)); + } numv = another->NbResults(i); occ::handle> vres = new NCollection_HArray1(1, numv); for (j = 1; j <= numv; j++) + { vres->SetValue(j, another->ResultData(i, j)); + } allResultData->SetValue(i, vres); } ent->Init(aNote, @@ -265,157 +293,231 @@ void IGESAppli_ToolElementResults::OwnCheck(const occ::handleResultReportFlag(); if (rrf < 0 || rrf > 3) + { ach->AddFail("Result Report Flag not in [0-3]"); + } int nv = ent->NbResultValues(); bool OK = true; switch (ent->FormNumber()) { case 0: if (nv < 0) + { OK = false; + } break; case 1: if (nv != 1) + { OK = false; + } break; case 2: if (nv != 1) + { OK = false; + } break; case 3: if (nv != 3) + { OK = false; + } break; case 4: if (nv != 6) + { OK = false; + } break; case 5: if (nv != 3) + { OK = false; + } break; case 6: if (nv != 3) + { OK = false; + } break; case 7: if (nv != 3) + { OK = false; + } break; case 8: if (nv != 3) + { OK = false; + } break; case 9: if (nv != 3) + { OK = false; + } break; case 10: if (nv != 1) + { OK = false; + } break; case 11: if (nv != 1) + { OK = false; + } break; case 12: if (nv != 3) + { OK = false; + } break; case 13: if (nv != 1) + { OK = false; + } break; case 14: if (nv != 1) + { OK = false; + } break; case 15: if (nv != 3) + { OK = false; + } break; case 16: if (nv != 1) + { OK = false; + } break; case 17: if (nv != 3) + { OK = false; + } break; case 18: if (nv != 3) + { OK = false; + } break; case 19: if (nv != 3) + { OK = false; + } break; case 20: if (nv != 3) + { OK = false; + } break; case 21: if (nv != 3) + { OK = false; + } break; case 22: if (nv != 3) + { OK = false; + } break; case 23: if (nv != 6) + { OK = false; + } break; case 24: if (nv != 6) + { OK = false; + } break; case 25: if (nv != 6) + { OK = false; + } break; case 26: if (nv != 6) + { OK = false; + } break; case 27: if (nv != 6) + { OK = false; + } break; case 28: if (nv != 6) + { OK = false; + } break; case 29: if (nv != 9) + { OK = false; + } break; case 30: if (nv != 9) + { OK = false; + } break; case 31: if (nv != 9) + { OK = false; + } break; case 32: if (nv != 9) + { OK = false; + } break; case 33: if (nv != 9) + { OK = false; + } break; case 34: if (nv != 9) + { OK = false; + } break; default: ach->AddFail("Incorrect Form Number"); break; } if (!OK) + { ach->AddFail("Incorrect count of real values in array V for FEM node"); + } int ne = ent->NbElements(); for (int i = 1; i <= ne; i++) { @@ -424,18 +526,22 @@ void IGESAppli_ToolElementResults::OwnCheck(const occ::handleNbLayers(i); int nrl = ent->NbResultDataLocs(i); if (dlf < 0 || dlf > 4) + { ach->AddFail("One of the Data Layer Flags not in [0-4]"); + } if (dlf < 4 && ent->NbLayers(i) != 1) { Sprintf(mess, "Nb. of Layers n0.%d not ONE while Data Layer Flag is in [0-3]", i); ach->AddFail(mess); } if (rrf == 1 || rrf == 2) + { if (nrl != 1 || ent->ResultDataLoc(i, 1) != 0) { Sprintf(mess, "Result Data Locs n0.%d incorrect for Result Report = 1 or 2", i); ach->AddFail(mess); } + } if (ent->NbResults(i) != (nv * nl * nrl)) { Sprintf(mess, "Nb. of results for Element n0.%d incorrect, should be %d", i, nv * nl * nrl); @@ -476,7 +582,9 @@ void IGESAppli_ToolElementResults::OwnDump(const occ::handle 4 for more, > 5 for complete ]\n"; + } else { int i; // svv Jan 10 2000 : porting on DEC @@ -485,7 +593,9 @@ void IGESAppli_ToolElementResults::OwnDump(const occ::handleNbResultDataLocs(i); S << " [" << i << ":NbLoc=" << nloc << "]:"; for (int j = 1; j <= nloc; j++) + { S << " " << ent->ResultDataLoc(i, j); + } S << "\n"; } S << "Result Data : "; @@ -495,11 +605,15 @@ void IGESAppli_ToolElementResults::OwnDump(const occ::handleNbResults(i); S << " [" << i << ":NbRes=" << nres << "]:"; if (level <= 5) + { S << " [ ask level > 5 for complete Data ]\n"; + } else { for (int j = 1; j <= nres; j++) + { S << " " << ent->ResultData(i, j); // ?? is it all ?? UNFINISHED + } } } } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFiniteElement.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFiniteElement.cxx index 15878c594c..acd5475eea 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFiniteElement.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFiniteElement.cxx @@ -60,7 +60,9 @@ void IGESAppli_ToolFiniteElement::ReadOwnParams(const occ::handleSetValue(i, tempNode); + } } PR.ReadText(PR.Current(), "Element type name", tempName); // szv#4:S4163:12Mar99 `st=` not needed @@ -75,7 +77,9 @@ void IGESAppli_ToolFiniteElement::WriteOwnParams(const occ::handleTopology()); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Node(i)); + } IW.Send(ent->Name()); } @@ -84,7 +88,9 @@ void IGESAppli_ToolFiniteElement::OwnShared(const occ::handleNbNodes(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Node(i)); + } } void IGESAppli_ToolFiniteElement::OwnCopy(const occ::handle& another, @@ -136,5 +142,5 @@ void IGESAppli_ToolFiniteElement::OwnDump(const occ::handleNbNodes(), ent->Node); S << "\nElement Name : " << ent->Name()->String(); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlow.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlow.cxx index 9d35990692..55bccad18c 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlow.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlow.cxx @@ -57,69 +57,119 @@ void IGESAppli_ToolFlow::ReadOwnParams(const occ::handle& // szv#4:S4163:12Mar99 `st=` not needed if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Number of Context Flags", tempNbContextFlags); + } else + { tempNbContextFlags = 2; + } // szv#4:S4163:12Mar99 moved in if if (!PR.ReadInteger(PR.Current(), "Number of Flow Associativities", nf)) + { nf = 0; + } if (nf > 0) + { tempFlowAssocs = new NCollection_HArray1>(1, nf); + } else + { PR.AddFail("Number of Flow Associativities: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", nc)) + { nc = 0; + } if (nc > 0) + { tempConnectPoints = new NCollection_HArray1>(1, nc); + } else + { PR.AddFail("Number of Connect Points: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Joins", nj)) + { nj = 0; + } if (nj > 0) + { tempJoins = new NCollection_HArray1>(1, nj); + } else + { PR.AddFail("Number of Joins: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", nn)) + { nn = 0; + } if (nn > 0) + { tempFlowNames = new NCollection_HArray1>(1, nn); + } else + { PR.AddFail("Number of Flow Names: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", nt)) + { nt = 0; + } if (nt > 0) + { tempTextDisplayTemplates = new NCollection_HArray1>(1, nt); + } else + { PR.AddFail("Number of Text Displays: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", np)) + { np = 0; + } if (np > 0) + { tempContFlowAssocs = new NCollection_HArray1>(1, np); + } else + { PR.AddFail("Number of Continuation Flows Not Positive"); + } if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow); + } else + { tempTypeOfFlow = 0; + } if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Function Flag", tempFunctionFlag); + } else + { tempFunctionFlag = 0; + } for (i = 1; i <= nf; i++) { occ::handle tempEntity; if (PR.ReadEntity(IR, PR.Current(), "Flow Associativity", tempEntity)) + { tempFlowAssocs->SetValue(i, tempEntity); + } } for (i = 1; i <= nc; i++) @@ -130,21 +180,27 @@ void IGESAppli_ToolFlow::ReadOwnParams(const occ::handle& "Connect Point", STANDARD_TYPE(IGESDraw_ConnectPoint), tempEntity)) + { tempConnectPoints->SetValue(i, tempEntity); + } } for (i = 1; i <= nj; i++) { occ::handle tempEntity; if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity)) + { tempJoins->SetValue(i, tempEntity); + } } for (i = 1; i <= nn; i++) { occ::handle tempString; if (PR.ReadText(PR.Current(), "Flow Name", tempString)) + { tempFlowNames->SetValue(i, tempString); + } } for (i = 1; i <= nt; i++) @@ -155,14 +211,18 @@ void IGESAppli_ToolFlow::ReadOwnParams(const occ::handle& "Text Display Template", STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempEntity)) + { tempTextDisplayTemplates->SetValue(i, tempEntity); + } } for (i = 1; i <= np; i++) { occ::handle tempEntity; if (PR.ReadEntity(IR, PR.Current(), "Continuation Flow Associativities", tempEntity)) + { tempContFlowAssocs->SetValue(i, tempEntity); + } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -191,17 +251,29 @@ void IGESAppli_ToolFlow::WriteOwnParams(const occ::handle& ent, IW.Send(ent->TypeOfFlow()); IW.Send(ent->FunctionFlag()); for (num = ent->NbFlowAssociativities(), i = 1; i <= num; i++) + { IW.Send(ent->FlowAssociativity(i)); + } for (num = ent->NbConnectPoints(), i = 1; i <= num; i++) + { IW.Send(ent->ConnectPoint(i)); + } for (num = ent->NbJoins(), i = 1; i <= num; i++) + { IW.Send(ent->Join(i)); + } for (num = ent->NbFlowNames(), i = 1; i <= num; i++) + { IW.Send(ent->FlowName(i)); + } for (num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++) + { IW.Send(ent->TextDisplayTemplate(i)); + } for (num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++) + { IW.Send(ent->ContFlowAssociativity(i)); + } } void IGESAppli_ToolFlow::OwnShared(const occ::handle& ent, @@ -209,15 +281,25 @@ void IGESAppli_ToolFlow::OwnShared(const occ::handle& ent, { int i, num; for (num = ent->NbFlowAssociativities(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->FlowAssociativity(i)); + } for (num = ent->NbConnectPoints(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->ConnectPoint(i)); + } for (num = ent->NbJoins(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->Join(i)); + } for (num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->TextDisplayTemplate(i)); + } for (num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->ContFlowAssociativity(i)); + } } void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, @@ -232,7 +314,9 @@ void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, num = another->NbFlowAssociativities(); occ::handle>> tempFlowAssocs; if (num > 0) + { tempFlowAssocs = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESData_IGESEntity, new_item, TC.Transferred(another->FlowAssociativity(i))); @@ -242,7 +326,9 @@ void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, num = another->NbConnectPoints(); occ::handle>> tempConnectPoints; if (num > 0) + { tempConnectPoints = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESDraw_ConnectPoint, new_item, TC.Transferred(another->ConnectPoint(i))); @@ -252,7 +338,9 @@ void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, num = another->NbJoins(); occ::handle>> tempJoins; if (num > 0) + { tempJoins = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESData_IGESEntity, new_item, TC.Transferred(another->Join(i))); @@ -262,16 +350,22 @@ void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, num = another->NbFlowNames(); occ::handle>> tempFlowNames; if (num > 0) + { tempFlowNames = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) + { tempFlowNames->SetValue(i, new TCollection_HAsciiString(another->FlowName(i))); + } num = another->NbTextDisplayTemplates(); occ::handle>> tempTextDisplayTemplates; if (num > 0) + { tempTextDisplayTemplates = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESGraph_TextDisplayTemplate, @@ -283,7 +377,9 @@ void IGESAppli_ToolFlow::OwnCopy(const occ::handle& another, num = another->NbContFlowAssociativities(); occ::handle>> tempContFlowAssocs; if (num > 0) + { tempContFlowAssocs = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESData_IGESEntity, @@ -328,11 +424,17 @@ void IGESAppli_ToolFlow::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->NbContextFlags() != 2) + { ach->AddFail("Number of Context Flags != 2"); + } if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2)) + { ach->AddFail("Type of Flow != 0,1,2"); + } if ((ent->FunctionFlag() < 0) || (ent->FunctionFlag() > 2)) + { ach->AddFail("Function Flag != 0,1,2"); + } } void IGESAppli_ToolFlow::OwnDump(const occ::handle& ent, @@ -345,19 +447,31 @@ void IGESAppli_ToolFlow::OwnDump(const occ::handle& ent, int tf = ent->TypeOfFlow(); S << "Type of Flow : " << tf; if (tf == 1) + { S << " (logical)\n"; + } else if (tf == 2) + { S << " (physical)\n"; + } else + { S << " (not specified)\n"; + } tf = ent->FunctionFlag(); S << "Function Flag : " << tf; if (tf == 1) + { S << " (electrical signal)\n"; + } else if (tf == 2) + { S << " (fluid flow path)\n"; + } else + { S << " (not specified)\n"; + } S << "Flow Associativities : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbFlowAssociativities(), ent->FlowAssociativity); S << "\nConnect Points : "; @@ -380,5 +494,5 @@ void IGESAppli_ToolFlow::OwnDump(const occ::handle& ent, 1, ent->NbContFlowAssociativities(), ent->ContFlowAssociativity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlowLineSpec.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlowLineSpec.cxx index 0fcf6629ab..6992844215 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlowLineSpec.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolFlowLineSpec.cxx @@ -42,14 +42,22 @@ void IGESAppli_ToolFlowLineSpec::ReadOwnParams(const occ::handle>> tempNameAndModifiers; if (!PR.ReadInteger(PR.Current(), "Number of property values", num)) + { num = 0; + } if (num > 0) + { tempNameAndModifiers = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of property values: Not Positive"); + } // szv#4:S4163:12Mar99 `st=` not needed if (!tempNameAndModifiers.IsNull()) + { PR.ReadTexts(PR.CurrentList(num), "Name and Modifiers", tempNameAndModifiers); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNameAndModifiers); @@ -61,7 +69,9 @@ void IGESAppli_ToolFlowLineSpec::WriteOwnParams(const occ::handleNbPropertyValues()); for (num = ent->NbPropertyValues(), i = 1; i <= num; i++) + { IW.Send(ent->Modifier(i)); + } } void IGESAppli_ToolFlowLineSpec::OwnShared(const occ::handle& /* ent */, @@ -77,7 +87,9 @@ void IGESAppli_ToolFlowLineSpec::OwnCopy(const occ::handle>> tempNameAndModifiers = new NCollection_HArray1>(1, num); for (int i = 1; i <= num; i++) + { tempNameAndModifiers->SetValue(i, new TCollection_HAsciiString(another->Modifier(i))); + } ent->Init(tempNameAndModifiers); } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelFunction.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelFunction.cxx index c69ee707ef..d6aae21680 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelFunction.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelFunction.cxx @@ -46,12 +46,18 @@ void IGESAppli_ToolLevelFunction::ReadOwnParams( PR.ReadInteger(PR.Current(), "No. of Property values", tempNbPropertyValues); if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Function description code", tempFuncDescripCode); + } else + { tempFuncDescripCode = 0; + } if (PR.DefinedElseSkip()) + { PR.ReadText(PR.Current(), "Function description", tempFuncDescrip); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNbPropertyValues, tempFuncDescripCode, tempFuncDescrip); @@ -63,9 +69,13 @@ void IGESAppli_ToolLevelFunction::WriteOwnParams(const occ::handleNbPropertyValues()); IW.Send(ent->FuncDescriptionCode()); if (ent->FuncDescription().IsNull()) + { IW.SendVoid(); + } else + { IW.Send(ent->FuncDescription()); + } } void IGESAppli_ToolLevelFunction::OwnShared(const occ::handle& /* ent */, @@ -80,7 +90,9 @@ void IGESAppli_ToolLevelFunction::OwnCopy(const occ::handle descrip; if (!another->FuncDescription().IsNull()) + { descrip = new TCollection_HAsciiString(another->FuncDescription()); + } code = another->FuncDescriptionCode(); aNbPropertyValues = another->NbPropertyValues(); @@ -91,7 +103,9 @@ bool IGESAppli_ToolLevelFunction::OwnCorrect(const occ::handleNbPropertyValues() != 2); if (res) + { ent->Init(2, ent->FuncDescriptionCode(), ent->FuncDescription()); + } return res; // nbpropertyvalues = 2 } @@ -113,7 +127,9 @@ void IGESAppli_ToolLevelFunction::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 2) + { ach->AddFail("Number of Property Values != 2"); + } } void IGESAppli_ToolLevelFunction::OwnDump(const occ::handle& ent, diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelToPWBLayerMap.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelToPWBLayerMap.cxx index c3104607c1..21d9a5647f 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelToPWBLayerMap.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLevelToPWBLayerMap.cxx @@ -53,7 +53,9 @@ void IGESAppli_ToolLevelToPWBLayerMap::ReadOwnParams( // szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "Number of property values", tempNbPropertyValues); if (!PR.ReadInteger(PR.Current(), "Number of definitions", num)) + { num = 0; + } if (num > 0) { tempExchangeFileLevelNumber = new NCollection_HArray1(1, num); @@ -63,26 +65,38 @@ void IGESAppli_ToolLevelToPWBLayerMap::ReadOwnParams( new NCollection_HArray1>(1, num); } else + { PR.AddFail("Number of definitions: Not Positive"); + } if (!tempExchangeFileLevelNumber.IsNull() && !tempNativeLevel.IsNull() && !tempPhysicalLayerNumber.IsNull() && !tempExchangeFileLevelIdent.IsNull()) + { for (i = 1; i <= num; i++) { int tempEFLN; // szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Exchange File Level Number", tempEFLN)) + { tempExchangeFileLevelNumber->SetValue(i, tempEFLN); + } occ::handle tempNL; if (PR.ReadText(PR.Current(), "Native Level Identification", tempNL)) + { tempNativeLevel->SetValue(i, tempNL); + } int tempPLN; if (PR.ReadInteger(PR.Current(), "Physical Layer Number", tempPLN)) + { tempPhysicalLayerNumber->SetValue(i, tempPLN); + } occ::handle tempEFLI; if (PR.ReadText(PR.Current(), "Exchange File Level Identification", tempEFLI)) + { tempExchangeFileLevelIdent->SetValue(i, tempEFLI); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNbPropertyValues, tempExchangeFileLevelNumber, @@ -182,6 +196,7 @@ void IGESAppli_ToolLevelToPWBLayerMap::OwnDump(const occ::handleNbLevelToLayerDefs(), ent->ExchangeFileLevelIdent); S << "\n"; if (level > 4) + { for (num = ent->NbLevelToLayerDefs(), i = 1; i <= num; i++) { S << "[" << i << "]:\n"; @@ -194,4 +209,5 @@ void IGESAppli_ToolLevelToPWBLayerMap::OwnDump(const occ::handleExchangeFileLevelIdent(i)); S << "\n"; } + } } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLineWidening.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLineWidening.cxx index f5834b1181..6f9bd2537d 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLineWidening.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolLineWidening.cxx @@ -50,9 +50,13 @@ void IGESAppli_ToolLineWidening::ReadOwnParams(const occ::handleInit(tempNbPropertyValues, @@ -95,12 +99,14 @@ bool IGESAppli_ToolLineWidening::OwnCorrect(const occ::handleNbPropertyValues() != 5); if (res) + { ent->Init(5, ent->WidthOfMetalization(), ent->CorneringCode(), ent->ExtensionFlag(), ent->JustificationFlag(), ent->ExtensionValue()); + } if (ent->SubordinateStatus() != 0) { occ::handle nulevel; @@ -127,16 +133,28 @@ void IGESAppli_ToolLineWidening::OwnCheck(const occ::handle& ach) const { if (ent->SubordinateStatus() != 0) + { if (ent->DefLevel() == IGESData_DefOne || ent->DefLevel() == IGESData_DefSeveral) + { ach->AddWarning("Level type: defined while ignored"); + } + } if (ent->NbPropertyValues() != 5) + { ach->AddFail("Number of Property Values != 5"); + } if (ent->CorneringCode() != 0 && ent->CorneringCode() != 1) + { ach->AddFail("Cornering Code incorrect"); + } if (ent->ExtensionFlag() < 0 || ent->ExtensionFlag() > 2) + { ach->AddFail("Extension Flag value incorrect"); + } if (ent->JustificationFlag() < 0 || ent->JustificationFlag() > 2) + { ach->AddFail("Justification Flag value incorrect"); + } } void IGESAppli_ToolLineWidening::OwnDump(const occ::handle& ent, @@ -150,34 +168,60 @@ void IGESAppli_ToolLineWidening::OwnDump(const occ::handleWidthOfMetalization() << "\n"; S << "Cornering Code : "; if (ent->CorneringCode() == 0) + { S << "0 (rounded)\n"; + } else if (ent->CorneringCode() == 1) + { S << "1 (squared)\n"; + } else + { S << "incorrect value\n"; + } S << "Extension Flag : "; if (ent->ExtensionFlag() == 0) + { S << "0 (No Extension)\n"; + } else if (ent->ExtensionFlag() == 1) + { S << "1 (One-half width extension)\n"; + } else if (ent->ExtensionFlag() == 2) + { S << "2 (Extension set by ExtensionValue)\n"; + } else + { S << "incorrect value\n"; + } S << "Justification Flag : "; if (ent->JustificationFlag() == 0) + { S << "0 (Centre justified)\n"; + } else if (ent->JustificationFlag() == 1) + { S << "1 (left justified)\n"; + } else if (ent->JustificationFlag() == 2) + { S << "2 (right justified)\n"; + } else + { S << "incorrect value\n"; + } if (ent->ExtensionFlag() == 2) - S << "Extension Value : " << ent->ExtensionValue() << std::endl; + { + S << "Extension Value : " << ent->ExtensionValue() << '\n'; + } else - S << "No Extension Value (Extension Flag != 2)" << std::endl; + { + S << "No Extension Value (Extension Flag != 2)" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalConstraint.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalConstraint.cxx index 1394a992fe..dc442226a0 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalConstraint.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalConstraint.cxx @@ -47,16 +47,23 @@ void IGESAppli_ToolNodalConstraint::ReadOwnParams(const occ::handle tempNode; occ::handle>> tempTabularDataProps; if (!PR.ReadInteger(PR.Current(), "Number of cases", num)) + { num = 0; + } if (num > 0) + { tempTabularDataProps = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of cases: Not Positive"); + } // szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "Type of Constraint", tempType); PR.ReadEntity(IR, PR.Current(), "Node", STANDARD_TYPE(IGESAppli_Node), tempNode); if (!tempTabularDataProps.IsNull()) + { for (i = 1; i <= num; i++) { occ::handle tempEntity; @@ -66,8 +73,11 @@ void IGESAppli_ToolNodalConstraint::ReadOwnParams(const occ::handleSetValue(i, tempEntity); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempType, tempNode, tempTabularDataProps); } @@ -81,7 +91,9 @@ void IGESAppli_ToolNodalConstraint::WriteOwnParams( IW.Send(ent->Type()); IW.Send(ent->NodeEntity()); for (num = ent->NbCases(), i = 1; i <= num; i++) + { IW.Send(ent->TabularData(i)); + } } void IGESAppli_ToolNodalConstraint::OwnShared(const occ::handle& ent, @@ -90,7 +102,9 @@ void IGESAppli_ToolNodalConstraint::OwnShared(const occ::handleNodeEntity()); for (num = ent->NbCases(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->TabularData(i)); + } } void IGESAppli_ToolNodalConstraint::OwnCopy(const occ::handle& another, @@ -128,7 +142,9 @@ void IGESAppli_ToolNodalConstraint::OwnCheck(const occ::handle& ach) const { if ((ent->Type() != 1) && (ent->Type() != 2)) + { ach->AddFail("Type of Constraint != 1,2"); + } } void IGESAppli_ToolNodalConstraint::OwnDump(const occ::handle& ent, @@ -144,5 +160,5 @@ void IGESAppli_ToolNodalConstraint::OwnDump(const occ::handleNbCases(), ent->TabularData); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalDisplAndRot.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalDisplAndRot.cxx index bdb2f40f4b..f5e59a22d3 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalDisplAndRot.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNodalDisplAndRot.cxx @@ -68,7 +68,9 @@ void IGESAppli_ToolNodalDisplAndRot::ReadOwnParams( "General Note", STANDARD_TYPE(IGESDimen_GeneralNote), anentity)) + { tempNotes->SetValue(i, anentity); + } } } // szv#4:S4163:12Mar99 moved in if @@ -83,13 +85,17 @@ void IGESAppli_ToolNodalDisplAndRot::ReadOwnParams( occ::handle aNode = new IGESAppli_Node(); int nodeno; if (PR.ReadInteger(PR.Current(), "Node number", nodeno)) + { tempNodeIdentifiers->SetValue(j, nodeno); + } if (PR.ReadEntity(IR, PR.Current(), "Node Directory Entry", STANDARD_TYPE(IGESAppli_Node), aNode)) + { tempNodes->SetValue(j, aNode); + } occ::handle> tempArray1; occ::handle> tempArray; @@ -102,9 +108,13 @@ void IGESAppli_ToolNodalDisplAndRot::ReadOwnParams( { gp_XYZ atrans, arot; if (PR.ReadXYZ(PR.CurrentList(1, 3), "Translation XYZ", atrans)) + { tempArray->SetValue(k, atrans); + } if (PR.ReadXYZ(PR.CurrentList(1, 3), "Rotational XYZ", arot)) + { tempArray1->SetValue(k, arot); + } } } tempTransParam->SetValue(j, tempArray); @@ -125,7 +135,9 @@ void IGESAppli_ToolNodalDisplAndRot::WriteOwnParams( IW.Send(nbcases); for (int i = 1; i <= nbcases; i++) + { IW.Send(ent->Note(i)); + } IW.Send(nbnodes); for (int j = 1; j <= nbnodes; j++) { @@ -150,9 +162,13 @@ void IGESAppli_ToolNodalDisplAndRot::OwnShared(const occ::handleNbNodes(); for (int i = 1; i <= nbcases; i++) + { iter.GetOneItem(ent->Note(i)); + } for (int j = 1; j <= nbnodes; j++) + { iter.GetOneItem(ent->Node(j)); + } } void IGESAppli_ToolNodalDisplAndRot::OwnCopy(const occ::handle& another, @@ -245,7 +261,7 @@ void IGESAppli_ToolNodalDisplAndRot::OwnDump(const occ::handleTranslationParameter,loca); S << "Rotational Parameters : "; // IGESData_DumpListXYZL(S,-level,1,nbcases,ent->RotationalParameter,loca); - S << " TO BE DONE" << std::endl; + S << " TO BE DONE" << '\n'; break; case 5: case 6: { @@ -253,7 +269,7 @@ void IGESAppli_ToolNodalDisplAndRot::OwnDump(const occ::handleNote(i), S, 1); - S << std::endl; + S << '\n'; } S << "Nodes :\n"; S << "Node Identifiers :\n"; @@ -277,7 +293,9 @@ void IGESAppli_ToolNodalDisplAndRot::OwnDump(const occ::handle aNode; if (PR.ReadInteger(PR.Current(), "Node no. identifier", aitem)) + { tempNodeIdentifiers->SetValue(i, aitem); + } if (PR.ReadEntity(IR, PR.Current(), "FEM Node", STANDARD_TYPE(IGESAppli_Node), aNode)) + { tempNodes->SetValue(i, aNode); + } if (tempFlag) + { // Check whether nbval properly read or not. for (int j = 1; j <= nbval; j++) { double aval; if (PR.ReadReal(PR.Current(), "Value", aval)) + { tempData->SetValue(i, j, aval); + } } + } } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -106,7 +114,9 @@ void IGESAppli_ToolNodalResults::WriteOwnParams(const occ::handleNodeIdentifier(i)); IW.Send(ent->Node(i)); for (int j = 1; j <= nbdata; j++) + { IW.Send(ent->Data(i, j)); + } } } @@ -116,7 +126,9 @@ void IGESAppli_ToolNodalResults::OwnShared(const occ::handleNbNodes(); iter.GetOneItem(ent->Note()); for (int i = 1; i <= nbnodes; i++) + { iter.GetOneItem(ent->Node(i)); + } } void IGESAppli_ToolNodalResults::OwnCopy(const occ::handle& another, @@ -141,7 +153,9 @@ void IGESAppli_ToolNodalResults::OwnCopy(const occ::handleNode(i))); aNodes->SetValue(i, anentity); for (int j = 1; j <= nbval; j++) + { aData->SetValue(i, j, another->Data(i, j)); + } } ent->Init(aNote, aSubCaseNum, aTime, aNodeIdentifiers, aNodes, aData); @@ -173,150 +187,222 @@ void IGESAppli_ToolNodalResults::OwnCheck(const occ::handleAddFail("Incorrect Form Number"); break; } if (!OK) + { ach->AddFail("Incorrect count of real values in array V for FEM node"); + } } void IGESAppli_ToolNodalResults::OwnDump(const occ::handle& ent, @@ -339,7 +425,9 @@ void IGESAppli_ToolNodalResults::OwnDump(const occ::handle 5]"; + } // IGESData_DumpRectVals(S ,-level,1, ent->NbData(),ent->Data); S << "\n"; if (level > 4) @@ -352,10 +440,14 @@ void IGESAppli_ToolNodalResults::OwnDump(const occ::handleNode(i), S, 1); S << "\n"; if (level < 6) + { continue; + } S << "Data : [ "; for (int j = 1; j <= ent->NbData(); j++) + { S << " " << ent->Data(i, j); + } S << " ]\n"; } } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNode.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNode.cxx index fac89f9c23..0350de9a38 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNode.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolNode.cxx @@ -47,12 +47,14 @@ void IGESAppli_ToolNode::ReadOwnParams(const occ::handle& PR.ReadXYZ(PR.CurrentList(1, 3), "Coordinates of Node (XYZ)", tempCoordinates); if (PR.DefinedElseSkip()) + { PR.ReadEntity(IR, PR.Current(), "Transformation Matrix", STANDARD_TYPE(IGESGeom_TransformationMatrix), tempSystem, true); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempCoordinates, tempSystem); @@ -99,12 +101,20 @@ void IGESAppli_ToolNode::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (!ent->HasSubScriptNumber()) + { ach->AddFail("SubScript Number expected (for Node Number) not present"); + } if (!ent->HasTransf()) + { ach->AddFail("Transformation Matrix expected, not present"); + } if (!ent->System().IsNull()) + { if (ent->System()->FormNumber() < 10) + { ach->AddFail("System : Incorrect FormNumber (not 10-11-12)"); + } + } } void IGESAppli_ToolNode::OwnDump(const occ::handle& ent, @@ -117,8 +127,12 @@ void IGESAppli_ToolNode::OwnDump(const occ::handle& ent, << " 3rd : " << ent->Coord().Z() << "\n"; S << "Nodal Displacement Coordinate System : "; if (!ent->System().IsNull()) + { dumper.Dump(ent->System(), S, level); + } else + { S << "Global Cartesian Coordinate System (default)"; - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBArtworkStackup.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBArtworkStackup.cxx index 58d46dff24..c761fb5a4a 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBArtworkStackup.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBArtworkStackup.cxx @@ -49,13 +49,21 @@ void IGESAppli_ToolPWBArtworkStackup::ReadOwnParams( PR.ReadInteger(PR.Current(), "Number of property values", tempNbPropertyValues); PR.ReadText(PR.Current(), "Artwork Stackup Identification", tempArtworkStackupIdent); if (!PR.ReadInteger(PR.Current(), "Number of level numbers", num)) + { num = 0; + } if (num > 0) + { tempLevelNumbers = new NCollection_HArray1(1, num); + } else + { PR.AddFail("Number of level numbers: Not Positive"); + } if (!tempLevelNumbers.IsNull()) + { PR.ReadInts(PR.CurrentList(num), "Level Numbers", tempLevelNumbers); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNbPropertyValues, tempArtworkStackupIdent, tempLevelNumbers); @@ -70,7 +78,9 @@ void IGESAppli_ToolPWBArtworkStackup::WriteOwnParams( IW.Send(ent->Identification()); IW.Send(ent->NbLevelNumbers()); for (num = ent->NbLevelNumbers(), i = 1; i <= num; i++) + { IW.Send(ent->LevelNumber(i)); + } } void IGESAppli_ToolPWBArtworkStackup::OwnShared( @@ -90,7 +100,9 @@ void IGESAppli_ToolPWBArtworkStackup::OwnCopy( new TCollection_HAsciiString(another->Identification()); occ::handle> tempLevelNumbers = new NCollection_HArray1(1, num); for (int i = 1; i <= num; i++) + { tempLevelNumbers->SetValue(i, another->LevelNumber(i)); + } ent->Init(tempNbPropertyValues, tempArtworkStackupIdent, tempLevelNumbers); } @@ -128,5 +140,5 @@ void IGESAppli_ToolPWBArtworkStackup::OwnDump(const occ::handleNbLevelNumbers(), ent->LevelNumber); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBDrilledHole.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBDrilledHole.cxx index 52c044d0be..6b47c73811 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBDrilledHole.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPWBDrilledHole.cxx @@ -42,9 +42,13 @@ void IGESAppli_ToolPWBDrilledHole::ReadOwnParams(const occ::handleNbPropertyValues() != 3); if (res) + { ent->Init(3, ent->DrillDiameterSize(), ent->FinishDiameterSize(), ent->FunctionCode()); + } // nbpropertyvalues=3 return res; } @@ -107,10 +113,14 @@ void IGESAppli_ToolPWBDrilledHole::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 3) + { ach->AddFail("Number of property values != 3"); + } if ((ent->FunctionCode() < 1) || ((ent->FunctionCode() > 5) && (ent->FunctionCode() < 5001)) || (ent->FunctionCode() > 9999)) + { ach->AddFail("Drilled Hole Function Code != 1-5,5001-9999"); + } } void IGESAppli_ToolPWBDrilledHole::OwnDump(const occ::handle& ent, @@ -122,5 +132,5 @@ void IGESAppli_ToolPWBDrilledHole::OwnDump(const occ::handleNbPropertyValues() << "\n" << "Drill Diameter Size : " << ent->DrillDiameterSize() << "\n" << "Finish Diameter Size : " << ent->FinishDiameterSize() << "\n" - << "Drilled Hole Function Code : " << ent->FunctionCode() << std::endl; + << "Drilled Hole Function Code : " << ent->FunctionCode() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPartNumber.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPartNumber.cxx index 0a80dc910a..320a03c40e 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPartNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPartNumber.cxx @@ -45,9 +45,13 @@ void IGESAppli_ToolPartNumber::ReadOwnParams(const occ::handleNbPropertyValues() != 4); if (res) + { ent->Init(4, ent->GenericNumber(), ent->MilitaryNumber(), ent->VendorNumber(), ent->InternalNumber()); // nbpropertyvalues= 4 + } return res; } @@ -128,7 +134,9 @@ void IGESAppli_ToolPartNumber::OwnCheck(const occ::handle& occ::handle& ach) const { if (ent->NbPropertyValues() != 4) + { ach->AddFail("Number of property values != 4"); + } } void IGESAppli_ToolPartNumber::OwnDump(const occ::handle& ent, @@ -150,5 +158,5 @@ void IGESAppli_ToolPartNumber::OwnDump(const occ::handle& S << "\n"; S << "Internal Number or Name : "; IGESData_DumpString(S, ent->InternalNumber()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPinNumber.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPinNumber.cxx index 22f7500239..b37f85126a 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPinNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPinNumber.cxx @@ -100,10 +100,16 @@ void IGESAppli_ToolPinNumber::OwnCheck(const occ::handle& e occ::handle& ach) const { if (ent->SubordinateStatus() != 0) + { if (ent->DefLevel() != IGESData_DefOne && ent->DefLevel() != IGESData_DefSeveral) + { ach->AddFail("Level type: Incorrect"); + } + } if (ent->NbPropertyValues() != 1) + { ach->AddFail("Number of Property Values != 1"); + } // UNFINISHED // Level to be ignored if the property is subordinate -- queried } @@ -117,5 +123,5 @@ void IGESAppli_ToolPinNumber::OwnDump(const occ::handle& en S << "Number of Property Values : " << ent->NbPropertyValues() << "\n"; S << "PinNumber : "; IGESData_DumpString(S, ent->PinNumberVal()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPipingFlow.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPipingFlow.cxx index d3c18935d9..eedc92a13d 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPipingFlow.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolPipingFlow.cxx @@ -58,59 +58,104 @@ void IGESAppli_ToolPipingFlow::ReadOwnParams(const occ::handle 0) + { tempFlowAssocs = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Flow Associativities: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", num)) + { num = 0; + } if (num > 0) + { tempConnectPoints = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Connect Points: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Joins", num)) + { num = 0; + } if (num > 0) + { tempJoins = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Joins: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", num)) + { num = 0; + } if (num > 0) + { tempFlowNames = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Flow Names: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", num)) + { num = 0; + } if (num > 0) + { tempTextDisplayTemplates = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Text Displays: Not Positive"); + } if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", num)) + { num = 0; + } if (num > 0) + { tempContFlowAssocs = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of Continuation Flows: Not Positive"); + } if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow); + } else + { tempTypeOfFlow = 0; + } if (!tempFlowAssocs.IsNull()) + { for (num = tempFlowAssocs->Length(), i = 1; i <= num; i++) { occ::handle tempEntity; @@ -120,10 +165,14 @@ void IGESAppli_ToolPipingFlow::ReadOwnParams(const occ::handleSetValue(i, tempEntity); + } } + } if (!tempConnectPoints.IsNull()) + { for (num = tempConnectPoints->Length(), i = 1; i <= num; i++) { occ::handle tempEntity; @@ -132,26 +181,38 @@ void IGESAppli_ToolPipingFlow::ReadOwnParams(const occ::handleSetValue(i, tempEntity); + } } + } if (!tempJoins.IsNull()) + { for (num = tempJoins->Length(), i = 1; i <= num; i++) { occ::handle tempEntity; if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity)) + { tempJoins->SetValue(i, tempEntity); + } } + } if (!tempFlowNames.IsNull()) + { for (num = tempFlowNames->Length(), i = 1; i <= num; i++) { occ::handle tempString; if (PR.ReadText(PR.Current(), "Flow Name", tempString)) + { tempFlowNames->SetValue(i, tempString); + } } + } if (!tempTextDisplayTemplates.IsNull()) + { for (num = tempTextDisplayTemplates->Length(), i = 1; i <= num; i++) { occ::handle tempEntity; @@ -160,16 +221,23 @@ void IGESAppli_ToolPipingFlow::ReadOwnParams(const occ::handleSetValue(i, tempEntity); + } } + } if (!tempContFlowAssocs.IsNull()) + { for (num = tempContFlowAssocs->Length(), i = 1; i <= num; i++) { occ::handle tempEntity; if (PR.ReadEntity(IR, PR.Current(), "Continuation Flow Assocs", tempEntity)) + { tempContFlowAssocs->SetValue(i, tempEntity); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNbContextFlags, @@ -195,17 +263,29 @@ void IGESAppli_ToolPipingFlow::WriteOwnParams(const occ::handleNbContFlowAssociativities()); IW.Send(ent->TypeOfFlow()); for (num = ent->NbFlowAssociativities(), i = 1; i <= num; i++) + { IW.Send(ent->FlowAssociativity(i)); + } for (num = ent->NbConnectPoints(), i = 1; i <= num; i++) + { IW.Send(ent->ConnectPoint(i)); + } for (num = ent->NbJoins(), i = 1; i <= num; i++) + { IW.Send(ent->Join(i)); + } for (num = ent->NbFlowNames(), i = 1; i <= num; i++) + { IW.Send(ent->FlowName(i)); + } for (num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++) + { IW.Send(ent->TextDisplayTemplate(i)); + } for (num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++) + { IW.Send(ent->ContFlowAssociativity(i)); + } } void IGESAppli_ToolPipingFlow::OwnShared(const occ::handle& ent, @@ -213,15 +293,25 @@ void IGESAppli_ToolPipingFlow::OwnShared(const occ::handle { int i, num; for (num = ent->NbFlowAssociativities(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->FlowAssociativity(i)); + } for (num = ent->NbConnectPoints(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->ConnectPoint(i)); + } for (num = ent->NbJoins(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->Join(i)); + } for (num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->TextDisplayTemplate(i)); + } for (num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->ContFlowAssociativity(i)); + } } void IGESAppli_ToolPipingFlow::OwnCopy(const occ::handle& another, @@ -259,7 +349,9 @@ void IGESAppli_ToolPipingFlow::OwnCopy(const occ::handle& occ::handle>> tempFlowNames = new NCollection_HArray1>(1, num); for (i = 1; i <= num; i++) + { tempFlowNames->SetValue(i, new TCollection_HAsciiString(another->FlowName(i))); + } num = another->NbTextDisplayTemplates(); occ::handle>> tempTextDisplayTemplates = @@ -316,9 +408,13 @@ void IGESAppli_ToolPipingFlow::OwnCheck(const occ::handle& occ::handle& ach) const { if (ent->NbContextFlags() != 1) + { ach->AddFail("Number of Context Flags != 1"); + } if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2)) + { ach->AddFail("Type of Flow != 0,1,2"); + } } void IGESAppli_ToolPipingFlow::OwnDump(const occ::handle& ent, @@ -351,5 +447,5 @@ void IGESAppli_ToolPipingFlow::OwnDump(const occ::handle& 1, ent->NbContFlowAssociativities(), ent->ContFlowAssociativity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolReferenceDesignator.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolReferenceDesignator.cxx index 83050a9f15..834036b7e9 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolReferenceDesignator.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolReferenceDesignator.cxx @@ -81,7 +81,9 @@ bool IGESAppli_ToolReferenceDesignator::OwnCorrect( { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->RefDesignatorText()); + } // nbpropertyvalues=1 if (ent->SubordinateStatus() != 0) { @@ -111,11 +113,17 @@ void IGESAppli_ToolReferenceDesignator::OwnCheck( occ::handle& ach) const { if (ent->SubordinateStatus() != 0) + { // the level is ignored if this property is subordinate if (ent->DefLevel() != IGESData_DefOne && ent->DefLevel() != IGESData_DefSeveral) + { ach->AddFail("Level type: Not value/reference"); + } + } if (ent->NbPropertyValues() != 1) + { ach->AddFail("Number of Property Values != 1"); + } // UNFINISHED // the level is ignored if this property is subordinate -- queried } @@ -130,5 +138,5 @@ void IGESAppli_ToolReferenceDesignator::OwnDump( S << "Number of Property Values : " << ent->NbPropertyValues() << "\n"; S << "ReferenceDesignator : "; IGESData_DumpString(S, ent->RefDesignatorText()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolRegionRestriction.cxx b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolRegionRestriction.cxx index f1232b507a..767cd8df01 100644 --- a/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolRegionRestriction.cxx +++ b/src/DataExchange/TKDEIGES/IGESAppli/IGESAppli_ToolRegionRestriction.cxx @@ -85,10 +85,12 @@ bool IGESAppli_ToolRegionRestriction::OwnCorrect( { bool res = (ent->NbPropertyValues() != 3); if (res) + { ent->Init(3, ent->ElectricalViasRestriction(), ent->ElectricalComponentRestriction(), ent->ElectricalCktRestriction()); // nbprops = 3 + } if (ent->SubordinateStatus() != 0) { occ::handle nulevel; @@ -115,16 +117,28 @@ void IGESAppli_ToolRegionRestriction::OwnCheck(const occ::handle& ach) const { if (ent->SubordinateStatus() != 0) + { if (ent->DefLevel() != IGESData_DefOne && ent->DefLevel() != IGESData_DefSeveral) + { ach->AddFail("Level type: Not value/reference"); + } + } if (ent->NbPropertyValues() != 3) + { ach->AddFail("Number of Property Values != 3"); + } if (ent->ElectricalViasRestriction() < 0 || ent->ElectricalViasRestriction() > 2) + { ach->AddFail("Incorrect value for Electrical Vias Restriction"); + } if (ent->ElectricalComponentRestriction() < 0 || ent->ElectricalComponentRestriction() > 2) + { ach->AddFail("Incorrect value for Electrical Component Restriction"); + } if (ent->ElectricalCktRestriction() < 0 || ent->ElectricalCktRestriction() > 2) + { ach->AddFail("Incorrect value for Electrical Circuit Restriction"); + } // UNFINISHED // level ignored if this property is subordinate -- queried } @@ -138,5 +152,5 @@ void IGESAppli_ToolRegionRestriction::OwnDump(const occ::handleNbPropertyValues() << "\n" << "Electrical vias restriction : " << ent->ElectricalViasRestriction() << "\n" << "Electrical components restriction : " << ent->ElectricalComponentRestriction() << "\n" - << "Electrical circuitary restriction : " << ent->ElectricalCktRestriction() << std::endl; + << "Electrical circuitary restriction : " << ent->ElectricalCktRestriction() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalRefFileIndex.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalRefFileIndex.cxx index 12c5b761e5..7cb1d7b7ff 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalRefFileIndex.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalRefFileIndex.cxx @@ -32,7 +32,9 @@ void IGESBasic_ExternalRefFileIndex::Init( { if (aNameArray->Lower() != 1 || allEntities->Lower() != 1 || aNameArray->Length() != allEntities->Length()) + { throw Standard_DimensionMismatch("IGESBasic_ExternalRefFileIndex: Init"); + } theNames = aNameArray; theEntities = allEntities; diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalReferenceFile.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalReferenceFile.cxx index 380ac17331..8be2574c50 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalReferenceFile.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ExternalReferenceFile.cxx @@ -29,7 +29,9 @@ void IGESBasic_ExternalReferenceFile::Init( const occ::handle>>& aNameArray) { if (aNameArray->Lower() != 1) + { throw Standard_DimensionMismatch("IGESBasic_ExternalReferenceFile : Init"); + } theNames = aNameArray; InitTypeAndForm(406, 12); } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_GeneralModule.cxx index 942cb323a5..73cd720799 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_GeneralModule.cxx @@ -70,7 +70,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolAssocGroupType tool; tool.OwnShared(anent, iter); } @@ -78,7 +80,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFile tool; tool.OwnShared(anent, iter); } @@ -86,7 +90,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileIndex tool; tool.OwnShared(anent, iter); } @@ -94,7 +100,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileName tool; tool.OwnShared(anent, iter); } @@ -102,7 +110,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefLibName tool; tool.OwnShared(anent, iter); } @@ -110,7 +120,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefName tool; tool.OwnShared(anent, iter); } @@ -118,7 +130,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalReferenceFile tool; tool.OwnShared(anent, iter); } @@ -126,7 +140,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroup tool; tool.OwnShared(anent, iter); } @@ -134,7 +150,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroupWithoutBackP tool; tool.OwnShared(anent, iter); } @@ -142,7 +160,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolHierarchy tool; tool.OwnShared(anent, iter); } @@ -150,7 +170,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolName tool; tool.OwnShared(anent, iter); } @@ -158,7 +180,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroup tool; tool.OwnShared(anent, iter); } @@ -166,7 +190,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; tool.OwnShared(anent, iter); } @@ -174,7 +200,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingleParent tool; tool.OwnShared(anent, iter); } @@ -182,7 +210,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingularSubfigure tool; tool.OwnShared(anent, iter); } @@ -190,7 +220,9 @@ void IGESBasic_GeneralModule::OwnSharedCase(const int case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSubfigureDef tool; tool.OwnShared(anent, iter); } @@ -209,112 +241,144 @@ IGESData_DirChecker IGESBasic_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolAssocGroupType tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalRefFile tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalRefFileIndex tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalRefFileName tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalRefLibName tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalRefName tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolExternalReferenceFile tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolGroup tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolGroupWithoutBackP tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolHierarchy tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolName tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolOrderedGroup tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolSingleParent tool; return tool.DirChecker(anent); } case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolSingularSubfigure tool; return tool.DirChecker(anent); } case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolSubfigureDef tool; return tool.DirChecker(anent); } @@ -334,7 +398,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolAssocGroupType tool; tool.OwnCheck(anent, shares, ach); } @@ -342,7 +408,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFile tool; tool.OwnCheck(anent, shares, ach); } @@ -350,7 +418,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileIndex tool; tool.OwnCheck(anent, shares, ach); } @@ -358,7 +428,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileName tool; tool.OwnCheck(anent, shares, ach); } @@ -366,7 +438,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefLibName tool; tool.OwnCheck(anent, shares, ach); } @@ -374,7 +448,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefName tool; tool.OwnCheck(anent, shares, ach); } @@ -382,7 +458,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalReferenceFile tool; tool.OwnCheck(anent, shares, ach); } @@ -390,7 +468,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroup tool; tool.OwnCheck(anent, shares, ach); } @@ -398,7 +478,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroupWithoutBackP tool; tool.OwnCheck(anent, shares, ach); } @@ -406,7 +488,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolHierarchy tool; tool.OwnCheck(anent, shares, ach); } @@ -414,7 +498,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolName tool; tool.OwnCheck(anent, shares, ach); } @@ -422,7 +508,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroup tool; tool.OwnCheck(anent, shares, ach); } @@ -430,7 +518,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; tool.OwnCheck(anent, shares, ach); } @@ -438,7 +528,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingleParent tool; tool.OwnCheck(anent, shares, ach); } @@ -446,7 +538,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingularSubfigure tool; tool.OwnCheck(anent, shares, ach); } @@ -454,7 +548,9 @@ void IGESBasic_GeneralModule::OwnCheckCase(const int case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSubfigureDef tool; tool.OwnCheck(anent, shares, ach); } @@ -651,8 +747,12 @@ int IGESBasic_GeneralModule::CategoryNumber(const int CN, const Interface_ShareTool&) const { if (CN == 10 || CN == 11) + { return Interface_Category::Number("Auxiliary"); + } if (CN >= 2 && CN <= 6) + { return Interface_Category::Number("Description"); + } return Interface_Category::Number("Structure"); } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Group.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Group.cxx index 75841ba32f..b558590f97 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Group.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Group.cxx @@ -35,7 +35,9 @@ IGESBasic_Group::IGESBasic_Group(const int nb) { InitTypeAndForm(402, 1); if (nb <= 0) + { return; + } theEntities = new NCollection_HArray1>(1, nb); } @@ -45,10 +47,14 @@ void IGESBasic_Group::Init( // ptv and rln September 14, 2000 BUC60743 // Protection against empty groups if (!allEntities.IsNull() && (allEntities->Lower() != 1)) + { throw Standard_DimensionMismatch("IGESBasic_Group : Init"); + } theEntities = allEntities; if (FormNumber() == 0) + { InitTypeAndForm(402, 1); + } } void IGESBasic_Group::SetOrdered(const bool mode) @@ -57,16 +63,24 @@ void IGESBasic_Group::SetOrdered(const bool mode) if (mode) { if (fn == 0 || fn == 1) + { InitTypeAndForm(402, 14); + } else if (fn == 7) + { InitTypeAndForm(402, 15); + } } else { if (fn == 14) + { InitTypeAndForm(402, 1); + } else if (fn == 15) + { InitTypeAndForm(402, 7); + } } } @@ -76,16 +90,24 @@ void IGESBasic_Group::SetWithoutBackP(const bool mode) if (mode) { if (fn == 0 || fn == 1) + { InitTypeAndForm(402, 7); + } else if (fn == 14) + { InitTypeAndForm(402, 15); + } } else { if (fn == 7) + { InitTypeAndForm(402, 1); + } else if (fn == 15) + { InitTypeAndForm(402, 14); + } } } @@ -104,7 +126,9 @@ bool IGESBasic_Group::IsWithoutBackP() const void IGESBasic_Group::SetUser(const int type, const int form) { if (type <= 5000) + { throw Standard_OutOfRange("IGESBasic_Group::SetUser"); + } InitTypeAndForm(type, form); } @@ -112,14 +136,20 @@ void IGESBasic_Group::SetNb(const int nb) { int i, oldnb = NbEntities(); if (nb == oldnb || nb <= 0) + { return; + } occ::handle>> newents = new NCollection_HArray1>(1, nb); if (oldnb > nb) + { oldnb = nb; + } for (i = 1; i <= oldnb; i++) + { newents->SetValue(i, theEntities->Value(i)); + } theEntities = newents; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Protocol.cxx index 41690dc1ff..54af586a22 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_Protocol.cxx @@ -50,36 +50,68 @@ occ::handle IGESBasic_Protocol::Resource(const int /*num*/) int IGESBasic_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESBasic_AssocGroupType)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalRefFile)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalRefFileIndex)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalRefFileName)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalRefLibName)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalRefName)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESBasic_ExternalReferenceFile)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESBasic_Group)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESBasic_GroupWithoutBackP)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESBasic_Hierarchy)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESBasic_Name)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESBasic_OrderedGroup)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESBasic_OrderedGroupWithoutBackP)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESBasic_SingleParent)) + { return 14; + } else if (atype == STANDARD_TYPE(IGESBasic_SingularSubfigure)) + { return 15; + } else if (atype == STANDARD_TYPE(IGESBasic_SubfigureDef)) + { return 16; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ReadWriteModule.cxx index da048f5c29..2a966b1bb8 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ReadWriteModule.cxx @@ -132,7 +132,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolAssocGroupType tool; tool.ReadOwnParams(anent, IR, PR); } @@ -140,7 +142,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFile tool; tool.ReadOwnParams(anent, IR, PR); } @@ -148,7 +152,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileIndex tool; tool.ReadOwnParams(anent, IR, PR); } @@ -156,7 +162,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileName tool; tool.ReadOwnParams(anent, IR, PR); } @@ -164,7 +172,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefLibName tool; tool.ReadOwnParams(anent, IR, PR); } @@ -172,7 +182,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefName tool; tool.ReadOwnParams(anent, IR, PR); } @@ -180,7 +192,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalReferenceFile tool; tool.ReadOwnParams(anent, IR, PR); } @@ -188,7 +202,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroup tool; tool.ReadOwnParams(anent, IR, PR); } @@ -196,7 +212,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroupWithoutBackP tool; tool.ReadOwnParams(anent, IR, PR); } @@ -204,7 +222,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolHierarchy tool; tool.ReadOwnParams(anent, IR, PR); } @@ -212,7 +232,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolName tool; tool.ReadOwnParams(anent, IR, PR); } @@ -220,7 +242,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroup tool; tool.ReadOwnParams(anent, IR, PR); } @@ -228,7 +252,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; tool.ReadOwnParams(anent, IR, PR); } @@ -236,7 +262,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingleParent tool; tool.ReadOwnParams(anent, IR, PR); } @@ -244,7 +272,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingularSubfigure tool; tool.ReadOwnParams(anent, IR, PR); } @@ -252,7 +282,9 @@ void IGESBasic_ReadWriteModule::ReadOwnParams(const int case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSubfigureDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -271,7 +303,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolAssocGroupType tool; tool.WriteOwnParams(anent, IW); } @@ -279,7 +313,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFile tool; tool.WriteOwnParams(anent, IW); } @@ -287,7 +323,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileIndex tool; tool.WriteOwnParams(anent, IW); } @@ -295,7 +333,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileName tool; tool.WriteOwnParams(anent, IW); } @@ -303,7 +343,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefLibName tool; tool.WriteOwnParams(anent, IW); } @@ -311,7 +353,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefName tool; tool.WriteOwnParams(anent, IW); } @@ -319,7 +363,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalReferenceFile tool; tool.WriteOwnParams(anent, IW); } @@ -327,7 +373,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroup tool; tool.WriteOwnParams(anent, IW); } @@ -335,7 +383,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroupWithoutBackP tool; tool.WriteOwnParams(anent, IW); } @@ -343,7 +393,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolHierarchy tool; tool.WriteOwnParams(anent, IW); } @@ -351,7 +403,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolName tool; tool.WriteOwnParams(anent, IW); } @@ -359,7 +413,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroup tool; tool.WriteOwnParams(anent, IW); } @@ -367,7 +423,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; tool.WriteOwnParams(anent, IW); } @@ -375,7 +433,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingleParent tool; tool.WriteOwnParams(anent, IW); } @@ -383,7 +443,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingularSubfigure tool; tool.WriteOwnParams(anent, IW); } @@ -391,7 +453,9 @@ void IGESBasic_ReadWriteModule::WriteOwnParams(const int case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSubfigureDef tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingleParent.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingleParent.cxx index 8408b327ab..205cb01213 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingleParent.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingleParent.cxx @@ -31,7 +31,9 @@ void IGESBasic_SingleParent::Init( const occ::handle>>& allChildren) { if (!allChildren.IsNull() && allChildren->Lower() != 1) + { throw Standard_DimensionMismatch("IGESBasic_SingleParent : Init"); + } theParentEntity = aParentEntity; theChildren = allChildren; theNbParentEntities = nbParentEntities; diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingularSubfigure.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingularSubfigure.cxx index 34e4a8eb7d..0f0cb826d0 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingularSubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SingularSubfigure.cxx @@ -62,6 +62,8 @@ gp_XYZ IGESBasic_SingularSubfigure::TransformedTranslation() const { gp_XYZ tmp = theTranslation; if (HasTransf()) + { Location().Transforms(tmp); + } return tmp; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SpecificModule.cxx index a0647e5002..2d95ba46f7 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SpecificModule.cxx @@ -67,7 +67,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolAssocGroupType tool; tool.OwnDump(anent, dumper, S, own); } @@ -75,7 +77,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 2: { DeclareAndCast(IGESBasic_ExternalRefFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFile tool; tool.OwnDump(anent, dumper, S, own); } @@ -83,7 +87,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 3: { DeclareAndCast(IGESBasic_ExternalRefFileIndex, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileIndex tool; tool.OwnDump(anent, dumper, S, own); } @@ -91,7 +97,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 4: { DeclareAndCast(IGESBasic_ExternalRefFileName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefFileName tool; tool.OwnDump(anent, dumper, S, own); } @@ -99,7 +107,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 5: { DeclareAndCast(IGESBasic_ExternalRefLibName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefLibName tool; tool.OwnDump(anent, dumper, S, own); } @@ -107,7 +117,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 6: { DeclareAndCast(IGESBasic_ExternalRefName, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalRefName tool; tool.OwnDump(anent, dumper, S, own); } @@ -115,7 +127,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 7: { DeclareAndCast(IGESBasic_ExternalReferenceFile, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolExternalReferenceFile tool; tool.OwnDump(anent, dumper, S, own); } @@ -123,7 +137,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroup tool; tool.OwnDump(anent, dumper, S, own); } @@ -131,7 +147,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolGroupWithoutBackP tool; tool.OwnDump(anent, dumper, S, own); } @@ -139,7 +157,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolHierarchy tool; tool.OwnDump(anent, dumper, S, own); } @@ -147,7 +167,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolName tool; tool.OwnDump(anent, dumper, S, own); } @@ -155,7 +177,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroup tool; tool.OwnDump(anent, dumper, S, own); } @@ -163,7 +187,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; tool.OwnDump(anent, dumper, S, own); } @@ -171,7 +197,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingleParent tool; tool.OwnDump(anent, dumper, S, own); } @@ -179,7 +207,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 15: { DeclareAndCast(IGESBasic_SingularSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSingularSubfigure tool; tool.OwnDump(anent, dumper, S, own); } @@ -187,7 +217,9 @@ void IGESBasic_SpecificModule::OwnDump(const int C case 16: { DeclareAndCast(IGESBasic_SubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESBasic_ToolSubfigureDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -206,56 +238,72 @@ bool IGESBasic_SpecificModule::OwnCorrect(const int case 1: { DeclareAndCast(IGESBasic_AssocGroupType, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolAssocGroupType tool; return tool.OwnCorrect(anent); } case 8: { DeclareAndCast(IGESBasic_Group, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolGroup tool; return tool.OwnCorrect(anent); } case 9: { DeclareAndCast(IGESBasic_GroupWithoutBackP, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolGroupWithoutBackP tool; return tool.OwnCorrect(anent); } case 10: { DeclareAndCast(IGESBasic_Hierarchy, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolHierarchy tool; return tool.OwnCorrect(anent); } case 11: { DeclareAndCast(IGESBasic_Name, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolName tool; return tool.OwnCorrect(anent); } case 12: { DeclareAndCast(IGESBasic_OrderedGroup, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolOrderedGroup tool; return tool.OwnCorrect(anent); } case 13: { DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolOrderedGroupWithoutBackP tool; return tool.OwnCorrect(anent); } case 14: { DeclareAndCast(IGESBasic_SingleParent, anent, ent); if (anent.IsNull()) + { break; + } IGESBasic_ToolSingleParent tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SubfigureDef.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SubfigureDef.cxx index 29a1efb200..27ffbb2ffb 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SubfigureDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_SubfigureDef.cxx @@ -33,7 +33,9 @@ void IGESBasic_SubfigureDef::Init( const occ::handle>>& allAssocEntities) { if (!allAssocEntities.IsNull() && allAssocEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESBasic_SubfigureDef : Init"); + } theDepth = aDepth; theName = aName; theAssocEntities = allAssocEntities; diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolAssocGroupType.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolAssocGroupType.cxx index bf640ed880..639cc604f6 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolAssocGroupType.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolAssocGroupType.cxx @@ -42,10 +42,12 @@ void IGESBasic_ToolAssocGroupType::ReadOwnParams( int tempType; occ::handle tempName; if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger(PR.Current(), "Number of data fields", tempNbData); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempNbData = 2; +} PR.ReadInteger(PR.Current(), "Type of attached associativity",tempType); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadText(PR.Current(), "Name of attached associativity", tempName); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on @@ -81,7 +83,9 @@ bool IGESBasic_ToolAssocGroupType::OwnCorrect( { bool res = (ent->NbData() != 2); if (res) + { ent->Init(2, ent->AssocType(), ent->Name()); + } return res; // nbdata=2 } @@ -105,7 +109,9 @@ void IGESBasic_ToolAssocGroupType::OwnCheck(const occ::handle& ach) const { if (ent->NbData() != 2) + { ach->AddFail("Number of data fields != 2"); + } } void IGESBasic_ToolAssocGroupType::OwnDump(const occ::handle& ent, @@ -118,5 +124,5 @@ void IGESBasic_ToolAssocGroupType::OwnDump(const occ::handleAssocType() << "\n" << "Name of attached associativity : "; IGESData_DumpString(S, ent->Name()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFile.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFile.cxx index 866ee31609..b85078b796 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFile.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFile.cxx @@ -98,5 +98,5 @@ void IGESBasic_ToolExternalRefFile::OwnDump(const occ::handleFileId()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileIndex.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileIndex.cxx index 809601800d..ad30f7a3d8 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileIndex.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileIndex.cxx @@ -54,22 +54,25 @@ void IGESBasic_ToolExternalRefFileIndex::ReadOwnParams( tempEntities = new NCollection_HArray1>(1, num); } else + { PR.AddFail("Number of index entries: Not Positive"); + } if (!tempNames.IsNull() && !tempEntities.IsNull()) + { for (i = 1; i <= num; i++) { occ::handle tempNam; - if (PR.ReadText(PR.Current(), - "External Reference Entity", - tempNam)) // szv#4:S4163:12Mar99 `st=` not needed + if (PR.ReadText(PR.Current(), "External Reference Entity", tempNam)) + { // szv#4:S4163:12Mar99 `st=` not needed tempNames->SetValue(i, tempNam); + } occ::handle tempEnt; - if (PR.ReadEntity(IR, - PR.Current(), - "Internal Entity", - tempEnt)) // szv#4:S4163:12Mar99 `st=` not needed + if (PR.ReadEntity(IR, PR.Current(), "Internal Entity", tempEnt)) + { // szv#4:S4163:12Mar99 `st=` not needed tempEntities->SetValue(i, tempEnt); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNames, tempEntities); } @@ -93,7 +96,9 @@ void IGESBasic_ToolExternalRefFileIndex::OwnShared( { int i, num; for (num = ent->NbEntries(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESBasic_ToolExternalRefFileIndex::OwnCopy( @@ -150,6 +155,7 @@ void IGESBasic_ToolExternalRefFileIndex::OwnDump( IGESData_DumpEntities(S, dumper, -level, 1, ent->NbEntries(), ent->Entity); S << "\n"; if (level > 4) + { for (num = ent->NbEntries(), i = 1; i <= num; i++) { S << "[" << i << "]: " @@ -159,5 +165,6 @@ void IGESBasic_ToolExternalRefFileIndex::OwnDump( dumper.Dump(ent->Entity(i), S, 1); S << "\n"; } - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileName.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileName.cxx index ce40d15f3e..1a7b8128b7 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileName.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefFileName.cxx @@ -97,7 +97,9 @@ void IGESBasic_ToolExternalRefFileName::OwnCheck( occ::handle& ach) const { if (ent->FormNumber() == 1) + { ach->AddFail("Invalid Form Number"); + } } void IGESBasic_ToolExternalRefFileName::OwnDump( @@ -112,5 +114,5 @@ void IGESBasic_ToolExternalRefFileName::OwnDump( S << "\n" << "External Reference Symbolic Name : "; IGESData_DumpString(S, ent->ReferenceName()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefLibName.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefLibName.cxx index 74283453b9..b7713984b5 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefLibName.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefLibName.cxx @@ -109,5 +109,5 @@ void IGESBasic_ToolExternalRefLibName::OwnDump(const occ::handleReferenceName()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefName.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefName.cxx index 6fdb7c162a..b3c7624ba9 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefName.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalRefName.cxx @@ -98,5 +98,5 @@ void IGESBasic_ToolExternalRefName::OwnDump(const occ::handleReferenceName()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalReferenceFile.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalReferenceFile.cxx index fe0688a389..9e9ce405f2 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalReferenceFile.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolExternalReferenceFile.cxx @@ -46,12 +46,18 @@ void IGESBasic_ToolExternalReferenceFile::ReadOwnParams( occ::handle>> tempNames; bool st = PR.ReadInteger(PR.Current(), "Number of list entries", num); if (st && num > 0) + { tempNames = new NCollection_HArray1>(1, num); + } else + { PR.AddFail("Number of list entries: Not Positive"); + } if (!tempNames.IsNull()) + { // clang-format off PR.ReadTexts(PR.CurrentList(num), "External Reference Entity", tempNames); //szv#4:S4163:12Mar99 `st=` not needed +} // clang-format on DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -65,7 +71,9 @@ void IGESBasic_ToolExternalReferenceFile::WriteOwnParams( int i, num; IW.Send(ent->NbListEntries()); for (num = ent->NbListEntries(), i = 1; i <= num; i++) + { IW.Send(ent->Name(i)); + } } void IGESBasic_ToolExternalReferenceFile::OwnShared( @@ -83,7 +91,9 @@ void IGESBasic_ToolExternalReferenceFile::OwnCopy( occ::handle>> tempNames = new NCollection_HArray1>(1, num); for (int i = 1; i <= num; i++) + { tempNames->SetValue(i, new TCollection_HAsciiString(another->Name(i))); + } ent->Init(tempNames); } @@ -118,5 +128,5 @@ void IGESBasic_ToolExternalReferenceFile::OwnDump( S << "IGESBasic_ExternalReferenceFile\n" << "External Reference Names : "; IGESData_DumpStrings(S, level, 1, ent->NbListEntries(), ent->Name); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroup.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroup.cxx index 11f0feb7f6..f7edab61ab 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroup.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroup.cxx @@ -80,7 +80,9 @@ void IGESBasic_ToolGroup::WriteOwnParams(const occ::handle& ent int upper = ent->NbEntities(); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Entity(i)); + } } void IGESBasic_ToolGroup::OwnShared(const occ::handle& ent, @@ -88,7 +90,9 @@ void IGESBasic_ToolGroup::OwnShared(const occ::handle& ent, { int upper = ent->NbEntities(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESBasic_ToolGroup::OwnCopy(const occ::handle& another, @@ -116,22 +120,34 @@ bool IGESBasic_ToolGroup::OwnCorrect(const occ::handle& ent) co { occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul++; + } else if (val->TypeNumber() == 0) + { ianul++; + } } if (ianul == 0) + { return false; + } occ::handle>> EntArray; if (ianul < nb) + { EntArray = new NCollection_HArray1>(1, nb - ianul); + } for (i = 1; i <= nb; i++) { occ::handle val = ent->Entity(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; EntArray->SetValue(nbtrue, ent->Entity(i)); } @@ -160,9 +176,13 @@ void IGESBasic_ToolGroup::OwnCheck(const occ::handle& ent, { occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul = true; + } else if (val->TypeNumber() == 0) + { ianul = true; + } if (ianul) { break; @@ -178,5 +198,5 @@ void IGESBasic_ToolGroup::OwnDump(const occ::handle& ent, S << "IGESBasic_Group\n" << "Entries in the Group : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbEntities(), ent->Entity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroupWithoutBackP.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroupWithoutBackP.cxx index bd487d2b51..034e803590 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroupWithoutBackP.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolGroupWithoutBackP.cxx @@ -82,7 +82,9 @@ void IGESBasic_ToolGroupWithoutBackP::WriteOwnParams( int upper = ent->NbEntities(); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Entity(i)); + } } void IGESBasic_ToolGroupWithoutBackP::OwnShared(const occ::handle& ent, @@ -90,7 +92,9 @@ void IGESBasic_ToolGroupWithoutBackP::OwnShared(const occ::handleNbEntities(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESBasic_ToolGroupWithoutBackP::OwnCopy( @@ -120,22 +124,34 @@ bool IGESBasic_ToolGroupWithoutBackP::OwnCorrect( { occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul++; + } else if (val->TypeNumber() == 0) + { ianul++; + } } if (ianul == 0) + { return false; + } occ::handle>> EntArray; if (ianul < nb) + { EntArray = new NCollection_HArray1>(1, nb - ianul); + } for (i = 1; i <= nb; i++) { occ::handle val = ent->Entity(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; EntArray->SetValue(nbtrue, ent->Entity(i)); } @@ -164,9 +180,13 @@ void IGESBasic_ToolGroupWithoutBackP::OwnCheck(const occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul = true; + } else if (val->TypeNumber() == 0) + { ianul = true; + } if (ianul) { break; @@ -182,5 +202,5 @@ void IGESBasic_ToolGroupWithoutBackP::OwnDump(const occ::handleNbEntities(), ent->Entity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolHierarchy.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolHierarchy.cxx index 557221e0bd..5581a3a259 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolHierarchy.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolHierarchy.cxx @@ -96,6 +96,7 @@ bool IGESBasic_ToolHierarchy::OwnCorrect(const occ::handle& { bool res = (ent->NbPropertyValues() != 6); if (res) + { ent->Init(6, ent->NewLineFont(), ent->NewView(), @@ -103,6 +104,7 @@ bool IGESBasic_ToolHierarchy::OwnCorrect(const occ::handle& ent->NewBlankStatus(), ent->NewLineWeight(), ent->NewColorNum()); + } return res; // nbpropertyvalues=6 } @@ -123,18 +125,32 @@ void IGESBasic_ToolHierarchy::OwnCheck(const occ::handle& e occ::handle& ach) const { if (ent->NbPropertyValues() != 6) + { ach->AddFail("Number of Property Values != 6"); + } if (ent->NewLineFont() != 0 && ent->NewLineFont() != 1) + { ach->AddFail("InCorrect LineFont"); + } if (ent->NewView() != 0 && ent->NewView() != 1) + { ach->AddFail("InCorrect View"); + } if (ent->NewEntityLevel() != 0 && ent->NewEntityLevel() != 1) + { ach->AddFail("InCorrect EntityLevel"); + } if (ent->NewBlankStatus() != 0 && ent->NewBlankStatus() != 1) + { if (ent->NewLineWeight() != 0 && ent->NewLineWeight() != 1) + { ach->AddFail("InCorrect LineWeight"); + } + } if (ent->NewColorNum() != 0 && ent->NewColorNum() != 1) + { ach->AddFail("InCorrect ColorNum"); + } } void IGESBasic_ToolHierarchy::OwnDump(const occ::handle& ent, @@ -149,5 +165,5 @@ void IGESBasic_ToolHierarchy::OwnDump(const occ::handle& en << "Entity level : " << ent->NewEntityLevel() << "\n" << "Blank status : " << ent->NewBlankStatus() << "\n" << "Line weight : " << ent->NewLineWeight() << "\n" - << "Color number : " << ent->NewColorNum() << std::endl; + << "Color number : " << ent->NewColorNum() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolName.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolName.cxx index ea51f1f1e1..9eaa1c734c 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolName.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolName.cxx @@ -76,7 +76,9 @@ bool IGESBasic_ToolName::OwnCorrect(const occ::handle& ent) cons { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->Value()); + } return res; // nbpropertyvalues = 1 } @@ -96,7 +98,9 @@ void IGESBasic_ToolName::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->NbPropertyValues() != 1) + { ach->AddFail("Number of Property Values != 1"); + } } void IGESBasic_ToolName::OwnDump(const occ::handle& ent, @@ -108,5 +112,5 @@ void IGESBasic_ToolName::OwnDump(const occ::handle& ent, << "Number of property values : " << ent->NbPropertyValues() << "\n" << "Name : "; IGESData_DumpString(S, ent->Value()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroup.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroup.cxx index 15912e3b8b..1f35df28ac 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroup.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroup.cxx @@ -70,7 +70,9 @@ void IGESBasic_ToolOrderedGroup::WriteOwnParams(const occ::handleNbEntities(); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Entity(i)); + } } void IGESBasic_ToolOrderedGroup::OwnShared(const occ::handle& ent, @@ -78,7 +80,9 @@ void IGESBasic_ToolOrderedGroup::OwnShared(const occ::handleNbEntities(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESBasic_ToolOrderedGroup::OwnCopy(const occ::handle& another, @@ -106,22 +110,34 @@ bool IGESBasic_ToolOrderedGroup::OwnCorrect(const occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul++; + } else if (val->TypeNumber() == 0) + { ianul++; + } } if (ianul == 0) + { return false; + } occ::handle>> EntArray; if (ianul < nb) + { EntArray = new NCollection_HArray1>(1, nb - ianul); + } for (i = 1; i <= nb; i++) { occ::handle val = ent->Entity(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; EntArray->SetValue(nbtrue, ent->Entity(i)); } @@ -150,9 +166,13 @@ void IGESBasic_ToolOrderedGroup::OwnCheck(const occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul = true; + } else if (val->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one element is Null"); @@ -169,5 +189,5 @@ void IGESBasic_ToolOrderedGroup::OwnDump(const occ::handleNbEntities(), ent->Entity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroupWithoutBackP.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroupWithoutBackP.cxx index a58b1ee744..8aa921633a 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroupWithoutBackP.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolOrderedGroupWithoutBackP.cxx @@ -72,7 +72,9 @@ void IGESBasic_ToolOrderedGroupWithoutBackP::WriteOwnParams( int upper = ent->NbEntities(); IW.Send(ent->NbEntities()); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Entity(i)); + } } void IGESBasic_ToolOrderedGroupWithoutBackP::OwnShared( @@ -81,7 +83,9 @@ void IGESBasic_ToolOrderedGroupWithoutBackP::OwnShared( { int upper = ent->NbEntities(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESBasic_ToolOrderedGroupWithoutBackP::OwnCopy( @@ -111,22 +115,34 @@ bool IGESBasic_ToolOrderedGroupWithoutBackP::OwnCorrect( { occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul++; + } else if (val->TypeNumber() == 0) + { ianul++; + } } if (ianul == 0) + { return false; + } occ::handle>> EntArray; if (ianul < nb) + { EntArray = new NCollection_HArray1>(1, nb - ianul); + } for (i = 1; i <= nb; i++) { occ::handle val = ent->Entity(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; EntArray->SetValue(nbtrue, ent->Entity(i)); } @@ -156,9 +172,13 @@ void IGESBasic_ToolOrderedGroupWithoutBackP::OwnCheck( { occ::handle val = ent->Entity(i); if (val.IsNull()) + { ianul = true; + } else if (val->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one element is Null"); @@ -176,5 +196,5 @@ void IGESBasic_ToolOrderedGroupWithoutBackP::OwnDump( S << "IGESBasic_OrderedGroupWithoutBackP\n" << "Entries in the Group : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbEntities(), ent->Entity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingleParent.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingleParent.cxx index 5c3afcf7e4..6a25b7163b 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingleParent.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingleParent.cxx @@ -96,7 +96,8 @@ void IGESBasic_ToolSingleParent::ReadOwnParams(const occ::handle 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed + if (nbval > 0) { PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed +} //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren); // clang-format on DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -111,7 +112,9 @@ void IGESBasic_ToolSingleParent::WriteOwnParams(const occ::handleSingleParent()); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Child(i)); + } } void IGESBasic_ToolSingleParent::OwnShared(const occ::handle& ent, @@ -120,7 +123,9 @@ void IGESBasic_ToolSingleParent::OwnShared(const occ::handleSingleParent()); int upper = ent->NbChildren(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Child(i)); + } } void IGESBasic_ToolSingleParent::OwnCopy(const occ::handle& another, @@ -143,12 +148,16 @@ void IGESBasic_ToolSingleParent::OwnCopy(const occ::handle& ent) const { if (ent->NbParentEntities() == 1) + { return false; + } int nb = ent->NbChildren(); occ::handle>> EntArray = new NCollection_HArray1>(1, nb); for (int i = 1; i <= nb; i++) + { EntArray->SetValue(i, ent->Child(i)); + } ent->Init(1, ent->SingleParent(), EntArray); return true; // nbparents = 1 } @@ -192,5 +201,5 @@ void IGESBasic_ToolSingleParent::OwnDump(const occ::handleNbChildren(), ent->Child); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingularSubfigure.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingularSubfigure.cxx index f8a92b33d3..623c6d90d2 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingularSubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSingularSubfigure.cxx @@ -121,9 +121,13 @@ void IGESBasic_ToolSingularSubfigure::WriteOwnParams( IW.Send(ent->Translation().Y()); IW.Send(ent->Translation().Z()); if (ent->HasScaleFactor()) + { IW.Send(ent->ScaleFactor()); + } else + { IW.SendVoid(); + } } void IGESBasic_ToolSingularSubfigure::OwnShared(const occ::handle& ent, @@ -155,7 +159,9 @@ IGESData_DirChecker IGESBasic_ToolSingularSubfigure::DirChecker( IGESData_DirChecker DC(408, 0); // TypeNo. 408, Form no. 0 DC.Structure(IGESData_DefVoid); if (ent->HierarchyStatus() == 1) + { DC.GraphicsIgnored(01); // GraphicsIgnored if Hierarchy = 01 + } return DC; } @@ -177,5 +183,5 @@ void IGESBasic_ToolSingularSubfigure::OwnDump(const occ::handleTranslation(), ent->Location()); - S << " Scale Factors : " << ent->ScaleFactor() << "\n" << std::endl; + S << " Scale Factors : " << ent->ScaleFactor() << "\n" << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSubfigureDef.cxx b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSubfigureDef.cxx index 99a00743e5..9da31c6ed7 100644 --- a/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSubfigureDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESBasic/IGESBasic_ToolSubfigureDef.cxx @@ -88,7 +88,9 @@ void IGESBasic_ToolSubfigureDef::WriteOwnParams(const occ::handleName()); IW.Send(nb); for (int i = 1; i <= nb; i++) + { IW.Send(ent->AssociatedEntity(i)); + } } void IGESBasic_ToolSubfigureDef::OwnShared(const occ::handle& ent, @@ -96,7 +98,9 @@ void IGESBasic_ToolSubfigureDef::OwnShared(const occ::handleNbEntities(); for (int i = 1; i <= nb; i++) + { iter.GetOneItem(ent->AssociatedEntity(i)); + } } void IGESBasic_ToolSubfigureDef::OwnCopy(const occ::handle& another, @@ -125,8 +129,10 @@ IGESData_DirChecker IGESBasic_ToolSubfigureDef::DirChecker( IGESData_DirChecker DC(308, 0); // TypeNo. 308, Form no. 0 DC.Structure(IGESData_DefVoid); if (ent->HierarchyStatus() == 1) + { DC.GraphicsIgnored(01); - // GraphicsIgnored if hierarchy status = 01 + // GraphicsIgnored if hierarchy status = 01 + } else { DC.BlankStatusIgnored(); @@ -153,5 +159,5 @@ void IGESBasic_ToolSubfigureDef::OwnDump(const occ::handleNbEntities(), ent->AssociatedEntity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl.cxx b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl.cxx index 4bebefbe0e..2a6d107a3a 100644 --- a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl.cxx +++ b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl.cxx @@ -48,17 +48,29 @@ int IGESCAFControl::EncodeColor(const Quantity_Color& col) { int code = 0; if (std::abs(col.Red() - 1.) <= Quantity_Color::Epsilon()) + { code |= 0x001; + } else if (std::abs(col.Red()) > Quantity_Color::Epsilon()) + { return 0; + } if (std::abs(col.Green() - 1.) <= Quantity_Color::Epsilon()) + { code |= 0x010; + } else if (std::abs(col.Green()) > Quantity_Color::Epsilon()) + { return 0; + } if (std::abs(col.Blue() - 1.) <= Quantity_Color::Epsilon()) + { code |= 0x100; + } else if (std::abs(col.Blue()) > Quantity_Color::Epsilon()) + { return 0; + } switch (code) { diff --git a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Reader.cxx b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Reader.cxx index f57031526c..56daf43fcf 100644 --- a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Reader.cxx +++ b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Reader.cxx @@ -49,9 +49,13 @@ static void checkColorRange(double& theCol) { if (theCol < 0.) + { theCol = 0.; + } if (theCol > 100.) + { theCol = 100.; + } } static inline bool IsComposite(const TopoDS_Shape& theShape) @@ -59,13 +63,17 @@ static inline bool IsComposite(const TopoDS_Shape& theShape) if (theShape.ShapeType() == TopAbs_COMPOUND) { if (!theShape.Location().IsIdentity()) + { return true; + } TopoDS_Iterator anIt(theShape, false, false); for (; anIt.More(); anIt.Next()) { if (IsComposite(anIt.Value())) + { return true; + } } } return false; @@ -96,9 +104,13 @@ static void AddCompositeShape(const occ::handle& theSTool, TopoDS_Shape aShape = theShape; const TopLoc_Location& aLoc = theShape.Location(); if (!theConsiderLoc && !aLoc.IsIdentity()) + { aShape.Location(TopLoc_Location()); + } if (!theMap.Add(aShape)) + { return; + } TopoDS_Iterator anIt(theShape, false, false); bool aHasCompositeSubShape = false; @@ -135,13 +147,16 @@ static void AddCompositeShape(const occ::handle& theSTool, aB.Add(aNewShape, aCompShape); if (!aLoc.IsIdentity()) + { aNewShape.Location(aLoc); + } aNewShape.Orientation(theShape.Orientation()); theSTool->AddShape(aNewShape, aHasCompositeSubShape, false); } else + { theSTool->AddShape(aShape, aHasCompositeSubShape, false); - return; + } } //================================================================================================= @@ -171,19 +186,25 @@ bool IGESCAFControl_Reader::Transfer(const occ::handle& doc, TransferRoots(theProgress); // replaces the above num = NbShapes(); if (num <= 0) + { return false; + } // and insert them to the document occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(doc->Main()); if (STool.IsNull()) + { return false; + } int i; for (i = 1; i <= num; i++) { TopoDS_Shape sh = Shape(i); // ---- HERE -- to add check [ assembly / hybrid model ] if (!IsComposite(sh)) + { STool->AddShape(sh, false); + } else { NCollection_Map aMap; @@ -197,24 +218,34 @@ bool IGESCAFControl_Reader::Transfer(const occ::handle& doc, bool IsCTool = true; occ::handle CTool = XCAFDoc_DocumentTool::ColorTool(doc->Main()); if (CTool.IsNull()) + { IsCTool = false; + } bool IsLTool = true; occ::handle LTool = XCAFDoc_DocumentTool::LayerTool(doc->Main()); if (LTool.IsNull()) + { IsLTool = false; + } int nb = aModel->NbEntities(); for (i = 1; i <= nb; i++) { occ::handle ent = occ::down_cast(aModel->Value(i)); if (ent.IsNull()) + { continue; + } occ::handle binder = TP->Find(ent); if (binder.IsNull()) + { continue; + } TopoDS_Shape S = TransferBRep::ShapeResult(binder); if (S.IsNull()) + { continue; + } bool IsColor = false; Quantity_Color col; @@ -379,6 +410,8 @@ bool IGESCAFControl_Reader::Perform(const char* const filenam const Message_ProgressRange& theProgress) { if (ReadFile(filename) != IFSelect_RetDone) + { return false; + } return Transfer(doc, theProgress); } diff --git a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Writer.cxx b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Writer.cxx index 26afc260f5..fdea5fe7fd 100644 --- a/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Writer.cxx +++ b/src/DataExchange/TKDEIGES/IGESCAFControl/IGESCAFControl_Writer.cxx @@ -89,9 +89,13 @@ void CollectShapeNames(const TDF_Label& theLabel, { TopoDS_Shape aShape; if (!XCAFDoc_ShapeTool::GetShape(aSeq.Value(anIter), aShape)) + { continue; + } if (!aSeq.Value(anIter).FindAttribute(TDataStd_Name::GetID(), aName)) + { continue; + } theMapOfShapeNames.Bind(aShape, aName->Get()); } } @@ -100,7 +104,9 @@ void CollectShapeNames(const TDF_Label& theLabel, { TopoDS_Shape aShape; if (!XCAFDoc_ShapeTool::GetShape(theLabel, aShape)) + { return; + } aShape.Move(theLocation, false); theMapOfShapeNames.Bind(aShape, thePrevName->Get()); } @@ -153,7 +159,9 @@ bool IGESCAFControl_Writer::Transfer(const occ::handle& doc, // translate free top-level shapes of the DECAF document occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(doc->Main()); if (STool.IsNull()) + { return false; + } NCollection_Sequence labels; STool->GetFreeShapes(labels); @@ -176,28 +184,38 @@ bool IGESCAFControl_Writer::Transfer(const NCollection_Sequence& labe const Message_ProgressRange& theProgress) { if (labels.Length() <= 0) + { return false; + } prepareUnit(labels.First()); // set local length unit to the model Message_ProgressScope aPS(theProgress, "Labels", labels.Length()); for (int i = 1; i <= labels.Length() && aPS.More(); i++) { TopoDS_Shape shape = XCAFDoc_ShapeTool::GetShape(labels.Value(i)); if (!shape.IsNull()) + { AddShape(shape, aPS.Next()); + } // IGESControl_Writer::Transfer ( shape ); } // write colors if (GetColorMode()) + { WriteAttributes(labels); + } // write layers if (GetLayerMode()) + { WriteLayers(labels); + } // write names if (GetNameMode()) + { WriteNames(labels); + } // refresh graph // WS()->ComputeGraph ( true ); @@ -213,7 +231,9 @@ bool IGESCAFControl_Writer::Perform(const occ::handle& doc, const Message_ProgressRange& theProgress) { if (!Transfer(doc, theProgress)) + { return false; + } return Write(filename) == IFSelect_RetDone; } @@ -224,7 +244,9 @@ bool IGESCAFControl_Writer::Perform(const occ::handle& doc, const Message_ProgressRange& theProgress) { if (!Transfer(doc, theProgress)) + { return false; + } return Write(filename.ToCString()) == IFSelect_RetDone; } @@ -234,7 +256,9 @@ bool IGESCAFControl_Writer::WriteAttributes(const NCollection_Sequence> colors; @@ -273,7 +301,9 @@ void IGESCAFControl_Writer::MakeColors( { // skip already processed shapes if (!Map.Add(S)) + { return; + } // check if shape has its own style (or inherits from ancestor) XCAFPrs_Style style = inherit; @@ -281,9 +311,13 @@ void IGESCAFControl_Writer::MakeColors( { const XCAFPrs_Style& own = settings.FindFromKey(S); if (own.IsSetColorCurv()) + { style.SetColorCurv(own.GetColorCurv()); + } if (own.IsSetColorSurf()) + { style.SetColorSurf(own.GetColorSurf()); + } style.SetMaterial(own.Material()); } @@ -350,7 +384,9 @@ void IGESCAFControl_Writer::MakeColors( if (!ent_f.IsNull()) { if (!ent_f->Surface().IsNull()) + { ent_f->Surface()->InitColor(colent, rank); + } } } else @@ -377,7 +413,9 @@ void IGESCAFControl_Writer::MakeColors( if (!ent_f.IsNull()) { if (!ent_f->Surface().IsNull()) + { ent_f->Surface()->InitColor(colent, rank); + } } } } @@ -397,7 +435,9 @@ void IGESCAFControl_Writer::MakeColors( // iterate on subshapes (except vertices :) if (S.ShapeType() == TopAbs_EDGE) + { return; + } for (TopoDS_Iterator it(S); it.More(); it.Next()) { MakeColors(it.Value(), settings, colors, Map, style); @@ -420,7 +460,9 @@ static void AttachLayer(const occ::handle& FP, occ::handle> shLayers = new NCollection_HSequence; if (!LTool->GetLayers(newSh, shLayers) || newSh.ShapeType() == TopAbs_COMPOUND) + { AttachLayer(FP, LTool, newSh, localIntName); + } } return; } @@ -464,7 +506,9 @@ static void MakeLayers(const occ::handle& FP, TDF_Label aShapeLabel = aShapeLabels.Value(j); TopoDS_Shape aSh; if (!STool->GetShape(aShapeLabel, aSh)) + { continue; + } AttachLayer(FP, LTool, aSh, localIntName); } } @@ -474,13 +518,19 @@ static void MakeLayers(const occ::handle& FP, bool IGESCAFControl_Writer::WriteLayers(const NCollection_Sequence& labels) { if (labels.Length() <= 0) + { return false; + } occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(labels(1)); if (STool.IsNull()) + { return false; + } occ::handle LTool = XCAFDoc_DocumentTool::LayerTool(labels(1)); if (LTool.IsNull()) + { return false; + } int globalIntName = 0; NCollection_Sequence aLayerLabels; @@ -491,7 +541,9 @@ bool IGESCAFControl_Writer::WriteLayers(const NCollection_Sequence& l { TDF_Label aOneLayerL = aLayerLabels.Value(i); if (aOneLayerL.IsNull()) + { continue; + } TCollection_ExtendedString localName; LTool->GetLayer(aOneLayerL, localName); int localIntName = 0; @@ -500,12 +552,16 @@ bool IGESCAFControl_Writer::WriteLayers(const NCollection_Sequence& l { localIntName = asciiName.IntegerValue(); if (globalIntName < localIntName) + { globalIntName = localIntName; + } NCollection_Sequence aShapeLabels; LTool->GetShapesOfLayer(aOneLayerL, aShapeLabels); if (aShapeLabels.Length() <= 0) + { continue; + } MakeLayers(FP, STool, LTool, aShapeLabels, localIntName); } } @@ -514,17 +570,23 @@ bool IGESCAFControl_Writer::WriteLayers(const NCollection_Sequence& l { TDF_Label aOneLayerL = aLayerLabels.Value(i1); if (aOneLayerL.IsNull()) + { continue; + } TCollection_ExtendedString localName; LTool->GetLayer(aOneLayerL, localName); int localIntName = 0; TCollection_AsciiString asciiName(localName, '?'); if (asciiName.IsIntegerValue()) + { continue; + } NCollection_Sequence aShapeLabels; LTool->GetShapesOfLayer(aOneLayerL, aShapeLabels); if (aShapeLabels.Length() <= 0) + { continue; + } localIntName = ++globalIntName; MakeLayers(FP, STool, LTool, aShapeLabels, localIntName); } @@ -537,7 +599,9 @@ bool IGESCAFControl_Writer::WriteLayers(const NCollection_Sequence& l bool IGESCAFControl_Writer::WriteNames(const NCollection_Sequence& theLabels) { if (theLabels.Length() <= 0) + { return false; + } DataMapOfShapeNames aMapOfShapeNames; @@ -548,9 +612,13 @@ bool IGESCAFControl_Writer::WriteNames(const NCollection_Sequence& th TopoDS_Shape aShape; occ::handle aName; if (!XCAFDoc_ShapeTool::GetShape(aLabel, aShape)) + { continue; + } if (!aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) + { continue; + } aMapOfShapeNames.Bind(aShape, aName->Get()); @@ -576,7 +644,9 @@ bool IGESCAFControl_Writer::WriteNames(const NCollection_Sequence& th occ::handle anAsciiName = new TCollection_HAsciiString(" "); int aNameLength = 8 - aName.Length(); if (aNameLength < 0) + { aNameLength = 0; + } for (int aCharPos = 1; aNameLength < 8; aCharPos++, aNameLength++) { anAsciiName->SetValue(aNameLength + 1, diff --git a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_ActorWrite.cxx b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_ActorWrite.cxx index 7a9e8b18ba..8a0a52b3a4 100644 --- a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_ActorWrite.cxx +++ b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_ActorWrite.cxx @@ -45,7 +45,9 @@ bool IGESControl_ActorWrite::Recognize(const occ::handle& start { DeclareAndCast(TransferBRep_ShapeMapper, shmap, start); if (!shmap.IsNull()) + { return true; + } DeclareAndCast(Transfer_TransientMapper, gemap, start); if (!gemap.IsNull()) { @@ -53,7 +55,9 @@ bool IGESControl_ActorWrite::Recognize(const occ::handle& start DeclareAndCast(Geom_Curve, Curve, geom); DeclareAndCast(Geom_Surface, Surf, geom); if (!Curve.IsNull() || !Surf.IsNull()) + { return true; + } } return false; } @@ -69,9 +73,13 @@ occ::handle IGESControl_ActorWrite::Transfer( DeclareAndCast(IGESData_IGESModel, modl, FP->Model()); if (modl.IsNull()) + { return NullResult(); + } if (themodetrans < 0 || themodetrans > 1) + { return NullResult(); + } occ::handle ent; DeclareAndCast(TransferBRep_ShapeMapper, shmap, start); @@ -94,12 +102,18 @@ occ::handle IGESControl_ActorWrite::Transfer( BR1.SetTransferProcess(FP); if (themodetrans == 0) + { ent = BR0.TransferShape(shape, theProgress); + } if (themodetrans == 1) + { ent = BR1.TransferShape(shape, theProgress); + } aShapeProcessor.MergeTransferInfo(FP); if (!ent.IsNull()) + { return TransientResult(ent); + } } DeclareAndCast(Transfer_TransientMapper, gemap, start); if (!gemap.IsNull()) @@ -117,7 +131,9 @@ occ::handle IGESControl_ActorWrite::Transfer( GeomToIGES_GeomSurface GS; GS.SetModel(modl); if (!Curve.IsNull()) + { ent = GC.TransferCurve(Curve, Curve->FirstParameter(), Curve->LastParameter()); + } else if (!Surf.IsNull()) { double U1, U2, V1, V2; @@ -125,7 +141,9 @@ occ::handle IGESControl_ActorWrite::Transfer( ent = GS.TransferSurface(Surf, U1, U2, V1, V2); } if (!ent.IsNull()) + { return TransientResult(ent); + } } return NullResult(); diff --git a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Controller.cxx b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Controller.cxx index be3b60a0ac..46eb034876 100644 --- a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Controller.cxx +++ b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Controller.cxx @@ -162,7 +162,9 @@ void IGESControl_Controller::Customise(occ::handle& WS) occ::handle xma; occ::handle xma1 = WS->NamedItem("xst-model-all"); if (xma1.IsNull()) + { xma = new IFSelect_SelectModelEntities; + } else { xma = occ::down_cast(xma1); @@ -172,7 +174,9 @@ void IGESControl_Controller::Customise(occ::handle& WS) occ::handle xmr; occ::handle xmr1 = WS->NamedItem("xst-model-roots"); if (!xmr1.IsNull()) + { xmr = occ::down_cast(xmr1); + } else { xmr = new IFSelect_SelectModelRoots; @@ -182,7 +186,9 @@ void IGESControl_Controller::Customise(occ::handle& WS) occ::handle xtr; occ::handle xtr1 = WS->NamedItem("xst-transferrable-roots"); if (!xtr1.IsNull()) + { xtr = occ::down_cast(xtr1); + } else { xtr = new XSControl_SelectForTransfer; diff --git a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_IGESBoundary.cxx b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_IGESBoundary.cxx index 6e188fad5c..461463a383 100644 --- a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_IGESBoundary.cxx +++ b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_IGESBoundary.cxx @@ -78,9 +78,13 @@ void IGESControl_IGESBoundary::Check(const bool result, saw->Load(mysewd3d); saw->CheckConnected(1); if (saw->LastCheckStatus(ShapeExtend_FAIL)) + { okCurve3d = false; + } else + { okCurve2d = false; + } Result = false; } } @@ -175,7 +179,9 @@ bool IGESControl_IGESBoundary::Transfer( int len3d = 0, len2d = 0; occ::handle>> seq3d, seq2d; if (usescurve) + { len3d = scurve3d->NbEdges(); + } else { IGESToBRep::IGESCurveToSequenceOfIGESCurve(icurve3d, seq3d); @@ -184,29 +190,45 @@ bool IGESControl_IGESBoundary::Transfer( if (!curves2d.IsNull()) { for (int i = 1; i <= curves2d->Length(); i++) + { IGESToBRep::IGESCurveToSequenceOfIGESCurve(curves2d->Value(i), seq2d); + } len2d = seq2d->Length(); } int surfcurv = myCS.GetSurfaceCurve(); if ((surfcurv == -2 && len2d > 0) || len3d == 0) + { GTranslate3d = false; + } else if ((surfcurv == -3 && len3d > 0) || len2d == 0) + { GTranslate2d = false; + } if (GTranslate3d && GTranslate2d) { // Setting preference in the case of inconsistency between 3D and 2D if (surfcurv == 2) + { Preferred3d = false; + } else if (surfcurv == 3) + { Preferred2d = false; + } else if (myfilepreference == 2) + { Preferred3d = false; + } else if (myfilepreference == 3) + { Preferred2d = false; + } else + { Preferred3d = false; + } } if (GTranslate3d && GTranslate2d && len3d != len2d) { @@ -234,8 +256,10 @@ bool IGESControl_IGESBoundary::Transfer( Gsewd->Add(Gsewd3d->Wire()); } else + { Gsewd->Add( Sh); // Gsewd = Gsewd3d is impossible to avoid sharing of sewd (UK1.igs entity 7) + } } } } @@ -245,7 +269,9 @@ bool IGESControl_IGESBoundary::Transfer( { TopoDS_Shape Sh = TC.Transfer2dTopoCurve(curves2d->Value(i), myface, mytrsf, myuFact); if (!Sh.IsNull()) + { Gsewd2d->Add(Sh); + } } if (toreverse2d) { @@ -264,7 +290,9 @@ bool IGESControl_IGESBoundary::Transfer( occ::handle Lsewd3d = new ShapeExtend_WireData; TC.SetBadCase(false); //: 27 if (usescurve) + { Lsewd3d->Add(scurve3d->Edge(i)); + } else { TopoDS_Shape shape3d = @@ -278,7 +306,9 @@ bool IGESControl_IGESBoundary::Transfer( } } else + { LTranslate3d = false; + } } bool bad3d = TC.BadCase(); //: 27 okCurve3d = okCurve3d @@ -305,14 +335,18 @@ bool IGESControl_IGESBoundary::Transfer( ->ConnectNextWire(saw2d, Lsewd2d, maxtol, distmin, revsewd, revnextsewd); } else + { LTranslate2d = false; + } // if (LTranslate3d && LTranslate2d && (Lsewd3d->NbEdges() != Lsewd2d->NbEdges() || bad3d // || bad2d)) { bool isBSpline = false; if (!usescurve && !seq3d->Value(i).IsNull() && !seq2d->Value(i).IsNull()) + { isBSpline = seq3d->Value(i)->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve)) && seq2d->Value(i)->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve)); + } if (LTranslate3d && LTranslate2d && ((isBSpline && (Lsewd3d->NbEdges() != Lsewd2d->NbEdges())) @@ -325,9 +359,13 @@ bool IGESControl_IGESBoundary::Transfer( } occ::handle Lsewd; // Lsewd3d or Lsewd2d or Lsewd3d+pcurve if (LTranslate3d && !LTranslate2d) + { Lsewd = Lsewd3d; + } else if (!LTranslate3d && LTranslate2d) + { Lsewd = Lsewd2d; + } else { Lsewd = Lsewd3d; @@ -337,7 +375,9 @@ bool IGESControl_IGESBoundary::Transfer( { TopoDS_Edge edge3d = Lsewd3d->Edge(iedge), edge2d = Lsewd2d->Edge(iedge); if (!IGESToBRep::TransferPCurve(edge2d, edge3d, myface)) + { continue; + } if (sfe->FixReversed2d(edge3d, myface)) { #ifdef OCCT_DEBUG @@ -358,7 +398,9 @@ bool IGESControl_IGESBoundary::Transfer( sfe->FixSameParameter(edge3d, SPTol); } else + { sfe->FixSameParameter(edge3d); + } double maxdev = BRep_Tool::Tolerance(edge3d); // pdn 08.04.99 S4135 recomputing only if deviation is greater than maxtol if (maxdev > maxtol) @@ -368,7 +410,9 @@ bool IGESControl_IGESBoundary::Transfer( #endif ShapeFix_ShapeTolerance().SetTolerance(edge3d, Precision::Confusion()); for (int ie = 1; ie <= iedge; ie++) + { ShapeBuild_Edge().RemovePCurve(Lsewd3d->Edge(ie), myface); + } if (Preferred3d) { #ifdef OCCT_DEBUG @@ -403,13 +447,17 @@ bool IGESControl_IGESBoundary::Transfer( for (int j = 1; j <= len3d; j++) { if (usescurve) + { Gsewd3d->Add(scurve3d->Edge(j)); + } else { TopoDS_Shape Sh = TC.TransferTopoCurve(occ::down_cast(seq3d->Value(j))); if (!Sh.IsNull()) + { Gsewd3d->Add(Sh); + } } } if (toreverse3d) @@ -425,7 +473,9 @@ bool IGESControl_IGESBoundary::Transfer( mytrsf, myuFact); if (!Sh.IsNull()) + { Gsewd2d->Add(Sh); + } } if (toreverse2d) { @@ -445,9 +495,13 @@ bool IGESControl_IGESBoundary::Transfer( Gsewd3d->Add(w3); Gsewd2d->Add(w3); if (tol3 < tol2) + { Gsewd->Add(w3); + } else + { Gsewd->Add(w2); + } okCurve = true; okCurve2d = true; okCurve3d = true; diff --git a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Reader.cxx b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Reader.cxx index f390b63af6..8cc2f59474 100644 --- a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Reader.cxx +++ b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Reader.cxx @@ -82,12 +82,16 @@ occ::handle IGESControl_Reader::IGESModel() const int IGESControl_Reader::NbRootsForTransfer() { if (therootsta) + { return theroots.Length(); + } therootsta = true; occ::handle model = IGESModel(); if (model.IsNull()) + { return 0; + } occ::handle session = WS(); occ::handle protocol = session->Protocol(); @@ -104,7 +108,9 @@ int IGESControl_Reader::NbRootsForTransfer() { occ::handle ent = model->Entity(i); if (SH.IsShared(ent) || !actor->Recognize(ent)) + { continue; + } // add processing to take only visible entities if (!theReadOnlyVisible || ent->BlankStatus() == 0) { @@ -144,9 +150,13 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, const occ::handle& aBinder = iterTrans.Value(); Sprintf(mess, "\t%s", aBinder->ResultTypeName()); if (aMapCountResult.IsBound(mess)) + { aMapCountResult.ChangeFind(mess)++; + } else + { aMapCountResult.Bind(mess, 1); + } } // Init for dicoCountMapping for IFSelect_Mapping else if (mode == IFSelect_Mapping) @@ -163,9 +173,13 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, aBinder->ResultTypeName()); // std::cout << mess << std::endl; if (aMapCountMapping.IsBound(mess)) + { aMapCountMapping.ChangeFind(mess)++; + } else + { aMapCountMapping.Bind(mess, 1); + } } } @@ -185,13 +199,19 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, { Sprintf(mess, "\t W\t%d\t%d\t%s", type, form, aCheck->CWarning(i)); if (aMapCount.IsBound(mess)) + { aMapCount.ChangeFind(mess)++; + } else + { aMapCount.Bind(mess, 1); + } occ::handle> alist; if (aMapList.IsBound(mess)) + { alist = aMapList.ChangeFind(mess); + } else { alist = new NCollection_HSequence(); @@ -204,12 +224,18 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, Sprintf(mess, "\t F\t%d\t%d\t%s", type, form, aCheck->CFail(i)); // TF << mess << std::endl; if (aMapCount.IsBound(mess)) + { aMapCount.ChangeFind(mess)++; + } else + { aMapCount.Bind(mess, 1); + } occ::handle> alist; if (aMapList.IsBound(mess)) + { alist = aMapList.ChangeFind(mess); + } else { alist = new NCollection_HSequence(); @@ -257,7 +283,7 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, aMapCountIter.Next(), aMapListIter.Next()) { Message_Messenger::StreamBuffer aSender = TF->SendInfo(); - aSender << aMapCountIter.Value() << aMapCountIter.Key() << std::endl; + aSender << aMapCountIter.Value() << aMapCountIter.Key() << '\n'; if (mode == IFSelect_ListByItem) { const occ::handle>& entityList = aMapListIter.Value(); @@ -280,7 +306,7 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, aSender << line; } } - aSender << std::endl; + aSender << '\n'; } } break; @@ -300,7 +326,7 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, NCollection_DataMap::Iterator aMapIter(aMapCountResult); for (; aMapIter.More(); aMapIter.Next()) { - TF->SendInfo() << aMapIter.Key() << aMapIter.Value() << std::endl; + TF->SendInfo() << aMapIter.Key() << aMapIter.Value() << '\n'; } break; } @@ -333,9 +359,13 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, "Failed"); // std::cout << mess << std::endl; if (aMapCountMapping.IsBound(mess)) + { aMapCountMapping.ChangeFind(mess)++; + } else + { aMapCountMapping.Bind(mess, 1); + } } } } @@ -345,8 +375,8 @@ void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly, char mess[80]; Sprintf(mess, aMapCountIter.Key().ToCString(), aMapCountIter.Value()); // clang-format off - TF->SendInfo() << mess << std::endl; //dicoCountIter.Value() << dicoCountIter.Name() << std::endl; - // clang-format on + TF->SendInfo() << mess << '\n'; //dicoCountIter.Value() << dicoCountIter.Name() << std::endl; + // clang-format on } break; } diff --git a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Writer.cxx b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Writer.cxx index 7f8fbd6cc4..3d87173f7c 100644 --- a/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Writer.cxx +++ b/src/DataExchange/TKDEIGES/IGESControl/IGESControl_Writer.cxx @@ -95,7 +95,9 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, const Message_ProgressRange& theProgress) { if (theShape.IsNull()) + { return false; + } XSAlgo_ShapeProcessor::PrepareForTransfer(); @@ -107,7 +109,9 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, TopoDS_Shape Shape = aShapeProcessor.ProcessShape(theShape, myShapeProcFlags.first, aPS.Next()); if (!aPS.More()) + { return false; + } BRepToIGES_BREntity B0; B0.SetTransferProcess(myTP); @@ -118,10 +122,14 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, occ::handle ent = myWriteMode ? B1.TransferShape(Shape, aPS.Next()) : B0.TransferShape(Shape, aPS.Next()); if (!aPS.More()) + { return false; + } if (ent.IsNull()) + { return false; + } aShapeProcessor.MergeTransferInfo(myTP); // 22.10.98 gka BUC60080 @@ -134,7 +142,9 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, int tolmod = Interface_Static::IVal("write.precision.mode"); if (tolmod == 2) + { newtol = Interface_Static::RVal("write.precision.val"); + } else { ShapeAnalysis_ShapeTolerance stu; @@ -150,13 +160,17 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, { // Least newtol = std::min(Tolv, Tole); if (oldnb > 0) + { newtol = std::min(oldtol, newtol); + } } else { // Greatest newtol = std::max(Tolv, Tole); if (oldnb > 0) + { newtol = std::max(oldtol, newtol); + } } } @@ -183,7 +197,9 @@ bool IGESControl_Writer::AddShape(const TopoDS_Shape& theShape, bool IGESControl_Writer::AddGeom(const occ::handle& geom) { if (geom.IsNull() || !geom->IsKind(STANDARD_TYPE(Geom_Geometry))) + { return false; + } DeclareAndCast(Geom_Curve, Curve, geom); DeclareAndCast(Geom_Surface, Surf, geom); occ::handle ent; @@ -227,7 +243,9 @@ bool IGESControl_Writer::AddGeom(const occ::handle& geom) bool IGESControl_Writer::AddEntity(const occ::handle& ent) { if (ent.IsNull()) + { return false; + } myModel->AddWithRefs(ent, IGESSelect_WorkLibrary::DefineProtocol()); myIsComputed = false; return true; @@ -250,16 +268,22 @@ void IGESControl_Writer::ComputeModel() bool IGESControl_Writer::Write(Standard_OStream& S, const bool fnes) { if (!S) + { return false; + } ComputeModel(); int nbEnt = myModel->NbEntities(); if (!nbEnt) + { return false; + } IGESData_IGESWriter IW(myModel); // do not forget the fnes mode ... to transmit to IW IW.SendModel(IGESSelect_WorkLibrary::DefineProtocol()); if (fnes) + { IW.WriteMode() = 10; + } bool status = IW.Print(S); return status; } diff --git a/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom.cxx b/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom.cxx index 7def87eb64..cb0bbbc6aa 100644 --- a/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom.cxx +++ b/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom.cxx @@ -44,12 +44,16 @@ int IGESConvGeom::SplineCurveFromIGES(const occ::handle& s // we retrieve the degree int degree = st->SplineType(); if (degree > 3) + { degree = 3; + } // we retrieve the number of segments. int nbSegs = st->NbSegments(); if (nbSegs < 1) + { return 5; // FAIL : no segment + } int nbKnots = nbSegs + 1; @@ -64,10 +68,14 @@ int IGESConvGeom::SplineCurveFromIGES(const occ::handle& s NCollection_Array1 delta(1, nbSegs); int i; // svv Jan 10 2000 : porting on DEC for (i = 1; i <= nbKnots; i++) + { knots.SetValue(i, st->BreakPoint(i)); + } for (i = 1; i <= nbSegs; i++) + { delta.SetValue(i, st->BreakPoint(i + 1) - st->BreakPoint(i)); + } NCollection_Array1 bspoles(1, nbSegs * degree + 1); int ibspole = bspoles.Lower() - 1; // Bspole Index. @@ -81,7 +89,9 @@ int IGESConvGeom::SplineCurveFromIGES(const occ::handle& s st->YCoordPolynomial(i, AY, BY, CY, DY); st->ZCoordPolynomial(i, AZ, BZ, CZ, DZ); if (st->NbDimensions() == 2) + { BZ = 0., CZ = 0., DZ = 0.; + } double Di = delta(i); double Di2 = delta(i) * delta(i); double Di3 = delta(i) * delta(i) * delta(i); @@ -122,10 +132,14 @@ int IGESConvGeom::SplineCurveFromIGES(const occ::handle& s } } if (i == 1) + { bspoles.SetValue(++ibspole, bzpoles.Value(bzpoles.Lower())); + } for (int j = bzpoles.Lower() + 1; j <= bzpoles.Upper(); j++) + { bspoles.SetValue(++ibspole, bzpoles.Value(j)); + } } if (ibspole != bspoles.Upper()) { @@ -162,7 +176,9 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle& const int continuity) { if (continuity < 1) + { return continuity; + } bool isC1 = true, isC2 = true; int degree = res->Degree(); @@ -171,6 +187,7 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle& { isModified = false; for (int i = res->FirstUKnotIndex() + 1; i < res->LastUKnotIndex(); i++) + { if (degree - res->Multiplicity(i) < continuity) { if (continuity >= 2) @@ -183,7 +200,9 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle& isModified |= locOK; } else + { isModified = true; + } } else { @@ -192,12 +211,17 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle& isModified |= locOK; } } + } } while (isModified); if (!isC1) + { return 0; + } if (continuity >= 2 && !isC2) + { return 1; + } return continuity; } @@ -208,7 +232,9 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle const int continuity) { if (continuity < 1) + { return continuity; + } bool isC1 = true, isC2 = true; int degree = res->Degree(); @@ -217,6 +243,7 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle { isModified = false; for (int i = res->FirstUKnotIndex() + 1; i < res->LastUKnotIndex(); i++) + { if (degree - res->Multiplicity(i) < continuity) { if (continuity >= 2) @@ -229,7 +256,9 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle isModified |= locOK; } else + { isModified = true; + } } else { @@ -238,12 +267,17 @@ int IGESConvGeom::IncreaseCurveContinuity(const occ::handle isModified |= locOK; } } + } } while (isModified); if (!isC1) + { return 0; + } if (continuity >= 2 && !isC2) + { return 1; + } return continuity; } @@ -257,7 +291,9 @@ int IGESConvGeom::SplineSurfaceFromIGES(const occ::handleBoundaryType(); if (degree > 3) + { degree = 3; + } int DegreeU = degree; int DegreeV = degree; @@ -265,7 +301,9 @@ int IGESConvGeom::SplineSurfaceFromIGES(const occ::handleNbVSegments(); if ((NbUSeg < 1) || (NbVSeg < 1)) + { return 5; + } // Output BSpline knots & multiplicities arrays for U & V : // ========================================================= @@ -277,16 +315,24 @@ int IGESConvGeom::SplineSurfaceFromIGES(const occ::handleUBreakPoint(i)); + } for (i = 1; i <= NbUSeg; i++) + { deltaU.SetValue(i, st->UBreakPoint(i + 1) - st->UBreakPoint(i)); + } for (i = 1; i <= NbVSeg + 1; i++) + { VKnot.SetValue(i, st->VBreakPoint(i)); + } for (i = 1; i <= NbVSeg; i++) + { deltaV.SetValue(i, st->VBreakPoint(i + 1) - st->VBreakPoint(i)); + } NCollection_Array1 UMult(1, NbUSeg + 1); UMult.Init(DegreeU); @@ -346,7 +392,9 @@ int IGESConvGeom::SplineSurfaceFromIGES(const occ::handleUDegree(); @@ -589,6 +657,7 @@ int IGESConvGeom::IncreaseSurfaceContinuity(const occ::handleFirstUKnotIndex() + 1; i < res->LastUKnotIndex(); i++) + { if (DegreeU - res->UMultiplicity(i) < continuity) { if (continuity >= 2) @@ -601,7 +670,9 @@ int IGESConvGeom::IncreaseSurfaceContinuity(const occ::handleVDegree(); @@ -617,6 +689,7 @@ int IGESConvGeom::IncreaseSurfaceContinuity(const occ::handleFirstVKnotIndex() + 1; i < res->LastVKnotIndex(); i++) + { if (DegreeV - res->VMultiplicity(i) < continuity) { if (continuity >= 2) @@ -629,7 +702,9 @@ int IGESConvGeom::IncreaseSurfaceContinuity(const occ::handle= 2 && !isC2) + { return 1; + } return continuity; } diff --git a/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx b/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx index b540435ab1..c401ae21b5 100644 --- a/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx +++ b/src/DataExchange/TKDEIGES/IGESConvGeom/IGESConvGeom_GeomBuilder.cxx @@ -59,7 +59,9 @@ void IGESConvGeom_GeomBuilder::AddXYZ(const gp_XYZ& val) void IGESConvGeom_GeomBuilder::AddVec(const gp_XYZ& val) { if (!theVec->IsEmpty()) + { theVec->SetValue(theVec->Length(), val); + } } int IGESConvGeom_GeomBuilder::NbPoints() const @@ -78,11 +80,15 @@ occ::handle IGESConvGeom_GeomBuilder::MakeCopiousData( { int num, nb = theXYZ->Length(); if (datatype < 1 || datatype > 3 || nb == 0 || (polyline && datatype == 3)) + { throw Standard_DomainError("IGESConvGeom_GeomBuilder : MakeCopiousData"); + } int nbd = datatype + 1; // 1->2 2->3 and 3->6 if (datatype == 3) + { nbd = 6; + } occ::handle> data = new NCollection_HArray1(1, nb * nbd); double CZ = 0.; for (num = 1; num <= nb; num++) @@ -91,18 +97,26 @@ occ::handle IGESConvGeom_GeomBuilder::MakeCopiousData( data->SetValue((num - 1) * nbd + 1, pnt.X()); data->SetValue((num - 1) * nbd + 2, pnt.Y()); if (datatype > 1) + { data->SetValue((num - 1) * nbd + 3, pnt.Z()); + } else + { CZ += pnt.Z(); + } if (datatype < 3) + { continue; + } const gp_XYZ& vec = theVec->Value(num); data->SetValue((num - 1) * nbd + 4, vec.X()); data->SetValue((num - 1) * nbd + 5, vec.Y()); data->SetValue((num - 1) * nbd + 6, vec.Z()); } if (datatype == 1) + { CZ /= nb; + } occ::handle res = new IGESGeom_CopiousData; res->Init(datatype, CZ, data); @@ -145,37 +159,51 @@ void IGESConvGeom_GeomBuilder::SetPosition(const gp_Ax1& pos) bool IGESConvGeom_GeomBuilder::IsIdentity() const { if (thepos.Form() == gp_Identity) + { return true; + } // otherwise, look more closely ... if (!IsTranslation()) + { return false; + } if (!thepos.TranslationPart().IsEqual(gp_XYZ(0., 0., 0.), epsl)) + { return false; + } return true; } bool IGESConvGeom_GeomBuilder::IsTranslation() const { if (thepos.Form() == gp_Identity || thepos.Form() == gp_Translation) + { return true; + } // otherwise, look more closely ... int i, j; for (i = 1; i <= 3; i++) + { for (j = 1; j <= 3; j++) { double cons = (i == j ? 1. : 0.); double val = thepos.Value(i, j); if (val > cons + epsa || val < cons - epsa) + { return false; + } } + } return true; } bool IGESConvGeom_GeomBuilder::IsZOnly() const { if (!IsTranslation()) + { return false; + } gp_XYZ t = thepos.TranslationPart(); t.SetZ(0.0); return t.IsEqual(gp_XYZ(0., 0., 0.), epsl); @@ -193,11 +221,17 @@ occ::handle IGESConvGeom_GeomBuilder::MakeTransfo occ::handle> data = new NCollection_HArray2(1, 3, 1, 4); int i, j; for (i = 1; i <= 3; i++) + { for (j = 1; j <= 4; j++) + { data->SetValue(i, j, (j == 4 ? thepos.Value(i, j) / unit : thepos.Value(i, j))); + } + } occ::handle rs = new IGESGeom_TransformationMatrix; rs->Init(data); if (thepos.IsNegative()) + { rs->SetFormNumber(1); + } return rs; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData.cxx index 575ad42035..68948e1f86 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData.cxx @@ -34,14 +34,22 @@ static occ::handle speci; void IGESData::Init() { if (proto.IsNull()) + { proto = new IGESData_Protocol; + } if (stmod.IsNull()) + { stmod = new IGESData_DefaultGeneral; + } if (speci.IsNull()) + { speci = new IGESData_DefaultSpecific; + } // and template model "iges" if (Interface_InterfaceModel::HasTemplate("iges")) + { return; + } OSD_Process process; @@ -229,11 +237,15 @@ void IGESData::Init() year = ladate.Year(); occ::handle datestr; if (year < 2000) + { // #65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000) datestr = IGESData_GlobalSection::NewDateString(0, 0, 0, 0, 0, 0, 0); + } else + { // #65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000) datestr = IGESData_GlobalSection::NewDateString(0, 0, 0, 0, 0, 0, -1); + } GS.SetSeparator(','); GS.SetEndMark(';'); GS.SetSendName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product"))); diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_BasicEditor.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_BasicEditor.cxx index 16865a5a83..f67c8cbd4c 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_BasicEditor.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_BasicEditor.cxx @@ -75,14 +75,20 @@ occ::handle IGESData_BasicEditor::Model() const bool IGESData_BasicEditor::SetUnitFlag(const int flag) { if (themodel.IsNull()) + { return false; + } if (flag < 1 || flag > 11) + { return false; + } IGESData_GlobalSection GS = themodel->GlobalSection(); occ::handle name = GS.UnitName(); const char* nam = IGESData_BasicEditor::UnitFlagName(flag); if (nam[0] != '\0') + { name = new TCollection_HAsciiString(nam); + } GS.SetUnitFlag(flag); GS.SetUnitName(name); themodel->SetGlobalSection(GS); @@ -93,7 +99,9 @@ bool IGESData_BasicEditor::SetUnitFlag(const int flag) bool IGESData_BasicEditor::SetUnitValue(const double val) { if (val <= 0.) + { return false; + } double vmm = val * themodel->GlobalSection().CascadeUnit(); // #73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection // if (Interface_Static::IVal("read.scale.unit") == 1) vmm = vmm * 1000.; @@ -107,25 +115,45 @@ bool IGESData_BasicEditor::SetUnitValue(const double val) int IGESData_BasicEditor::GetFlagByValue(const double theValue) { if (theValue >= 25. && theValue <= 26.) + { return 1; + } if (theValue >= 0.9 && theValue <= 1.1) + { return 2; + } if (theValue >= 300. && theValue <= 310.) + { return 4; + } if (theValue >= 1600000. && theValue <= 1620000.) + { return 5; + } if (theValue >= 990. && theValue <= 1010.) + { return 6; + } if (theValue >= 990000. && theValue <= 1010000.) + { return 7; + } if (theValue >= 0.025 && theValue <= 0.026) + { return 8; + } if (theValue >= 0.0009 && theValue <= 0.0011) + { return 9; + } if (theValue >= 9. && theValue <= 11.) + { return 10; + } if (theValue >= 0.000025 && theValue <= 0.000026) + { return 11; + } return 0; } @@ -134,33 +162,45 @@ int IGESData_BasicEditor::GetFlagByValue(const double theValue) bool IGESData_BasicEditor::SetUnitName(const char* const name) { if (themodel.IsNull()) + { return false; + } int flag = IGESData_BasicEditor::UnitNameFlag(name); IGESData_GlobalSection GS = themodel->GlobalSection(); if (GS.UnitFlag() == 3) { char* nam = (char*)name; if (name[1] == 'H') + { nam = (char*)&name[2]; + } GS.SetUnitName(new TCollection_HAsciiString(nam)); themodel->SetGlobalSection(GS); return true; } if (flag > 0) + { return SetUnitFlag(flag); + } return (flag > 0); } void IGESData_BasicEditor::ApplyUnit(const bool enforce) { if (themodel.IsNull()) + { return; + } if (!enforce && !theunit) + { return; + } IGESData_GlobalSection GS = themodel->GlobalSection(); double unit = GS.UnitValue(); if (unit <= 0.) + { return; + } if (unit != 1.) { GS.SetMaxLineWeight(GS.MaxLineWeight() / unit); @@ -176,10 +216,14 @@ void IGESData_BasicEditor::ApplyUnit(const bool enforce) void IGESData_BasicEditor::ComputeStatus() { if (themodel.IsNull()) + { return; + } int nb = themodel->NbEntities(); if (nb == 0) + { return; + } NCollection_Array1 subs(0, nb); subs.Init(0); // gere Subordinate Status Interface_Graph G(themodel, theglib); // gere & memorise UseFlag @@ -225,9 +269,13 @@ void IGESData_BasicEditor::ComputeStatus() { int nums = themodel->Number(sh.Value()); if (igt == 402 || igt == 404) + { subs.SetValue(nums, subs.Value(nums) | 2); + } else + { subs.SetValue(nums, subs.Value(nums) | 1); + } //// std::cout<<"ComputeStatus : nums = "<"< 0) + { G.GetFromEntity(ent, true, 4); + } // UV : see AutoCorrect of concerned classes (Boundary and CurveOnSurface) /* } else if (ent->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface))) { @@ -268,7 +318,9 @@ void IGESData_BasicEditor::ComputeStatus() int bl = ent->BlankStatus(); int uf = ent->UseFlag(); if (uf == 0) + { uf = G.Status(i); + } int hy = ent->HierarchyStatus(); //// std::cout<<" Ent.n0."<& e occ::handle smod; if (theslib.Select(ent, smod, CN)) + { done |= smod->OwnCorrect(CN, ent); + } return done; } @@ -368,7 +426,9 @@ int IGESData_BasicEditor::AutoCorrectModel() for (int i = 1; i <= nb; i++) { if (AutoCorrect(themodel->Entity(i))) + { res++; + } } return res; } @@ -383,27 +443,49 @@ int IGESData_BasicEditor::UnitNameFlag(const char* const name) nam = (char*)&name[2]; } if (!strcmp(nam, "INCH")) + { return 1; + } if (!strcmp(nam, "IN")) + { return 1; + } if (!strcmp(nam, "MM")) + { return 2; + } if (!strcmp(nam, "FT")) + { return 4; + } if (!strcmp(nam, "MI")) + { return 5; + } if (!strcmp(nam, "M")) + { return 6; + } if (!strcmp(nam, "KM")) + { return 7; + } if (!strcmp(nam, "MIL")) + { return 8; + } if (!strcmp(nam, "UM")) + { return 9; + } if (!strcmp(nam, "CM")) + { return 10; + } if (!strcmp(nam, "UIN")) + { return 11; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_DefSwitch.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_DefSwitch.cxx index 4383e9ce59..c2ed019065 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_DefSwitch.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_DefSwitch.cxx @@ -50,10 +50,14 @@ void IGESData_DefSwitch::SetRank(const int theRank) IGESData_DefType IGESData_DefSwitch::DefType() const { if (theval < 0) + { return IGESData_DefReference; + } if (theval > 0) + { return IGESData_DefValue; + } return IGESData_DefVoid; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_DefaultGeneral.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_DefaultGeneral.cxx index e9523be9e4..fd056b862c 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_DefaultGeneral.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_DefaultGeneral.cxx @@ -40,16 +40,22 @@ void IGESData_DefaultGeneral::OwnSharedCase(const int Interface_EntityIterator& iter) const { if (CN == 0) + { return; + } DeclareAndCast(IGESData_UndefinedEntity, anent, ent); if (anent.IsNull()) + { return; + } occ::handle cont = anent->UndefinedContent(); int nb = cont->NbParams(); for (int i = 1; i <= nb; i++) { if (cont->IsParamEntity(i)) + { iter.GetOneItem(cont->ParamEntity(i)); + } } } @@ -72,11 +78,17 @@ bool IGESData_DefaultGeneral::NewVoid(const int CN, occ::handleDirStatus(); if (dstat != 0) + { S << " -- Directory Entry Error Status = " << dstat << " --\n"; + } occ::handle cont = lent->UndefinedContent(); int nb = cont->NbParams(); S << " UNDEFINED ENTITY ...\n" @@ -50,7 +54,9 @@ void IGESData_DefaultSpecific::OwnDump(const int /*CN*/, { Interface_ParamType ptyp = cont->ParamType(i); if (ptyp == Interface_ParamVoid) + { S << " [" << i << ":Void]"; + } else if (cont->IsParamEntity(i)) { DeclareAndCast(IGESData_IGESEntity, anent, cont->ParamEntity(i)); @@ -62,7 +68,9 @@ void IGESData_DefaultSpecific::OwnDump(const int /*CN*/, S << " [" << i << "]=" << cont->ParamValue(i)->String(); } if (i == (i % 5) * 5) + { S << "\n"; + } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_DirChecker.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_DirChecker.cxx index e3a6ce1717..c9bbd3f6da 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_DirChecker.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_DirChecker.cxx @@ -346,11 +346,13 @@ void IGESData_DirChecker::CheckTypeAndForm(occ::handle& } if (theform1 <= theform2) + { if (ent->FormNumber() < theform1 || ent->FormNumber() > theform2) { Message_Msg Msg71("XSTEP_71"); ach->SendWarning(Msg71); } + } } } @@ -377,17 +379,23 @@ bool IGESData_DirChecker::Correct(const occ::handle& ent) c occ::handle structure; // by default Null if (thestructure != IGESData_DefVoid) + { structure = ent->Structure(); + } occ::handle nulview; occ::handle nulfont; occ::handle nulevel; occ::handle nulcolor; occ::handle label; // by default Null if (thegraphier != -1) + { label = ent->LabelDisplay(); + } int linew = 0; if (thegraphier != -1 && thelineweig != IGESData_DefVoid) + { linew = ent->LineWeightNumber(); + } if (thegraphier == -1 || (ent->RankLineFont() != 0 && thelinefont == IGESData_DefVoid)) { diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_FileProtocol.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_FileProtocol.cxx index 05f5007d1a..b7806de7bb 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_FileProtocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_FileProtocol.cxx @@ -23,11 +23,17 @@ IGESData_FileProtocol::IGESData_FileProtocol() = default; void IGESData_FileProtocol::Add(const occ::handle& protocol) { if (theresource.IsNull()) + { theresource = protocol; + } else if (theresource->IsInstance(protocol->DynamicType())) + { return; // passer + } else if (!thenext.IsNull()) + { thenext->Add(protocol); + } else { thenext = new IGESData_FileProtocol; @@ -39,7 +45,9 @@ int IGESData_FileProtocol::NbResources() const { int nb = (theresource.IsNull() ? 0 : 1); if (!thenext.IsNull()) + { nb += thenext->NbResources(); + } return nb; } @@ -47,8 +55,12 @@ occ::handle IGESData_FileProtocol::Resource(const int num) c { occ::handle res; if (num == 1) + { return occ::handle(theresource); + } else if (!thenext.IsNull()) + { return thenext->Resource(num - 1); + } return res; // Null } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_FreeFormatEntity.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_FreeFormatEntity.cxx index ce5f1e1cbf..0af06f2189 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_FreeFormatEntity.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_FreeFormatEntity.cxx @@ -68,11 +68,17 @@ occ::handle IGESData_FreeFormatEntity::ParamEntity(const in bool IGESData_FreeFormatEntity::IsNegativePointer(const int num) const { if (thenegptrs.IsNull()) + { return false; + } int nb = thenegptrs->Length(); for (int i = 1; i <= nb; i++) + { if (thenegptrs->Value(i) == num) + { return true; + } + } return false; } @@ -103,9 +109,13 @@ void IGESData_FreeFormatEntity::AddEntity(const Interface_ParamType { UndefinedContent()->AddEntity(ptype, ent); if (!negative) + { return; + } if (thenegptrs.IsNull()) + { thenegptrs = new NCollection_HSequence(); + } thenegptrs->Append(NbParams()); } @@ -129,7 +139,9 @@ void IGESData_FreeFormatEntity::AddNegativePointers( const occ::handle>& list) { if (thenegptrs.IsNull()) + { thenegptrs = new NCollection_HSequence(); + } thenegptrs->Append(list); } @@ -144,18 +156,22 @@ void IGESData_FreeFormatEntity::WriteOwnParams(IGESData_IGESWriter& IW) const int neg = 0; int fneg = 0; if (!thenegptrs.IsNull()) + { if (!thenegptrs->IsEmpty()) { neg = thenegptrs->Value(1); fneg = 1; } + } int nb = UndefinedContent()->NbParams(); for (int i = 1; i <= nb; i++) { Interface_ParamType ptyp = UndefinedContent()->ParamType(i); if (ptyp == Interface_ParamVoid) + { IW.SendVoid(); + } else if (UndefinedContent()->IsParamEntity(i)) { DeclareAndCast(IGESData_IGESEntity, anent, UndefinedContent()->ParamEntity(i)); @@ -164,7 +180,9 @@ void IGESData_FreeFormatEntity::WriteOwnParams(IGESData_IGESWriter& IW) const { IW.Send(anent, true); if (fneg >= thenegptrs->Length()) + { neg = 0; + } else { fneg++; @@ -172,9 +190,13 @@ void IGESData_FreeFormatEntity::WriteOwnParams(IGESData_IGESWriter& IW) const } } else + { IW.Send(anent, false); + } } else + { IW.SendString(UndefinedContent()->ParamValue(i)); + } } } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_GeneralModule.cxx index 6778340175..a7d5286a59 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_GeneralModule.cxx @@ -38,7 +38,9 @@ void IGESData_GeneralModule::FillSharedCase(const int { DeclareAndCast(IGESData_IGESEntity, anent, ent); if (anent.IsNull()) + { return; + } // .... Directory Part iter.AddItem(anent->DirFieldEntity(3)); iter.AddItem(anent->DirFieldEntity(4)); @@ -54,7 +56,9 @@ void IGESData_GeneralModule::FillSharedCase(const int // .... Properties Interface_EntityIterator assocs = anent->Properties(); for (; assocs.More(); assocs.Next()) + { iter.AddItem(assocs.Value()); + } } void IGESData_GeneralModule::ListImpliedCase(const int CN, @@ -63,11 +67,15 @@ void IGESData_GeneralModule::ListImpliedCase(const int { DeclareAndCast(IGESData_IGESEntity, anent, ent); if (anent.IsNull()) + { return; + } OwnImpliedCase(CN, anent, iter); Interface_EntityIterator assocs = anent->Associativities(); for (; assocs.More(); assocs.Next()) + { iter.AddItem(assocs.Value()); + } } void IGESData_GeneralModule::OwnImpliedCase(const int, @@ -107,20 +115,32 @@ void IGESData_GeneralModule::CopyCase(const int CN, //? ento->InitTypeAndForm (enfr->TypeNumber(), enfr->FormNumber());ShallowCopy if (enfr->DefLineFont() == IGESData_DefReference) + { ento->InitLineFont(GetCasted(IGESData_LineFontEntity, TC.Transferred(enfr->LineFont()))); + } else + { ento->InitLineFont(enfr->LineFont(), enfr->RankLineFont()); + } if (enfr->DefLevel() == IGESData_DefSeveral) + { ento->InitLevel(GetCasted(IGESData_LevelListEntity, TC.Transferred(enfr->LevelList())), -1); + } else + { ento->InitLevel(enfr->LevelList(), enfr->Level()); + } if (enfr->DefView() != IGESData_DefNone) + { ento->InitView(GetCasted(IGESData_ViewKindEntity, TC.Transferred(enfr->View()))); + } if (enfr->HasTransf()) + { ento->InitTransf(GetCasted(IGESData_TransfEntity, TC.Transferred(enfr->Transf()))); + } ento->InitStatus(enfr->BlankStatus(), enfr->SubordinateStatus(), @@ -128,25 +148,39 @@ void IGESData_GeneralModule::CopyCase(const int CN, enfr->HierarchyStatus()); if (enfr->DefColor() == IGESData_DefReference) + { ento->InitColor(GetCasted(IGESData_ColorEntity, TC.Transferred(enfr->Color()))); + } else + { ento->InitColor(enfr->Color(), enfr->RankColor()); + } if (enfr->HasShortLabel()) + { ento->SetLabel(new TCollection_HAsciiString(enfr->ShortLabel()), enfr->SubScriptNumber()); + } else + { ento->SetLabel(enfr->ShortLabel(), enfr->SubScriptNumber()); + } // Directory Part : Miscellaneous occ::handle Structure; if (enfr->HasStructure()) + { Structure = GetCasted(IGESData_IGESEntity, TC.Transferred(enfr->Structure())); + } if (enfr->HasLabelDisplay()) + { ento->InitMisc(Structure, GetCasted(IGESData_LabelDisplayEntity, TC.Transferred(enfr->LabelDisplay())), enfr->LineWeightNumber()); + } else + { ento->InitMisc(Structure, enfr->LabelDisplay(), enfr->LineWeightNumber()); + } // LineWeightValue, Res1, Res2 : through action of ShallowCopy ? @@ -180,7 +214,9 @@ void IGESData_GeneralModule::RenewImpliedCase(const int const occ::handle& anent = iter.Value(); occ::handle newent; if (TC.Search(anent, newent)) + { ento->AddAssociativity(GetCasted(IGESData_IGESEntity, newent)); + } } } } @@ -198,7 +234,9 @@ void IGESData_GeneralModule::WhenDeleteCase(const int { DeclareAndCast(IGESData_IGESEntity, anent, ent); if (anent.IsNull()) + { return; + } anent->Clear(); OwnDeleteCase(CN, anent); } @@ -215,7 +253,9 @@ occ::handle IGESData_GeneralModule::Name( occ::handle name; DeclareAndCast(IGESData_IGESEntity, anent, ent); if (anent.IsNull()) + { return name; + } name = anent->NameValue(); return name; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx index d989939e2e..57ec67f99e 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx @@ -30,9 +30,13 @@ void IGESData_GlobalNodeOfSpecificLib::Add(const occ::handle& aprotocol) { if (themod == amodule) + { return; + } if (theprot == aprotocol) + { themod = amodule; + } else if (thenext.IsNull()) { if (themod.IsNull()) @@ -47,7 +51,9 @@ void IGESData_GlobalNodeOfSpecificLib::Add(const occ::handleAdd(amodule, aprotocol); + } } const occ::handle& IGESData_GlobalNodeOfSpecificLib::Module() const diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx index 55b332356a..30394273ee 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx @@ -30,9 +30,13 @@ void IGESData_GlobalNodeOfWriterLib::Add(const occ::handle& aprotocol) { if (themod == amodule) + { return; + } if (theprot == aprotocol) + { themod = amodule; + } else if (thenext.IsNull()) { if (themod.IsNull()) @@ -47,7 +51,9 @@ void IGESData_GlobalNodeOfWriterLib::Add(const occ::handleAdd(amodule, aprotocol); + } } const occ::handle& IGESData_GlobalNodeOfWriterLib::Module() const diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalSection.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalSection.cxx index d83dac8437..54be5368a6 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalSection.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_GlobalSection.cxx @@ -36,7 +36,9 @@ static void CopyString(occ::handle& astr) { if (astr.IsNull()) + { return; // do nothing if String not defined ! + } occ::handle S = new TCollection_HAsciiString(""); S->AssignCat(astr); astr = S; @@ -47,16 +49,24 @@ static void MakeHollerith(const occ::handle& astr, cha lt = 0; text[0] = '\0'; if (astr.IsNull()) + { return; + } int ln = astr->Length(); if (ln == 0) + { return; + } Sprintf(text, "%dH%s", ln, astr->ToCString()); lt = ln + 2; if (ln >= 10) + { lt++; + } if (ln >= 100) + { lt++; // strlen text + } } //================================================================================================= @@ -89,19 +99,29 @@ occ::handle IGESData_GlobalSection::TranslatedFromHoll { occ::handle res; if (astr.IsNull()) + { return res; + } int n = astr->Search("H"); if (n > 1) { if (!astr->Token("H")->IsIntegerValue()) + { n = 0; + } } if (n > 1 && n < astr->Length()) + { res = astr->SubString(n + 1, astr->Length()); + } else if (astr->ToCString() == nullptr) + { res = new TCollection_HAsciiString; + } else + { res = new TCollection_HAsciiString(astr->ToCString()); + } return res; } @@ -160,14 +180,18 @@ void IGESData_GlobalSection::Init(const occ::handle& params, const char* val = params->Param(i).CValue(); Interface_ParamType fpt = params->Param(i).ParamType(); if (fpt == Interface_ParamVoid) + { continue; + } // if the param is an Integer if (fpt == Interface_ParamInteger) { // but a real is expected if (i == 13 || i == 17 || i == 19 || i == 20) + { realval = Atof(val); + } intval = atoi(val); } @@ -179,11 +203,17 @@ void IGESData_GlobalSection::Init(const occ::handle& params, for (k = 0; k < 50; k++) { if (val[k] == 'D' || val[k] == 'd') + { text[j++] = 'e'; + } else + { text[j++] = val[k]; + } if (val[k] == '\0') + { break; + } } realval = Atof(text); } @@ -197,10 +227,16 @@ void IGESData_GlobalSection::Init(const occ::handle& params, int nhol = strval->Search("H"); int lhol = strval->Length(); if (nhol > 1) + { if (!strval->Token("H")->IsIntegerValue()) + { nhol = 0; + } + } if (nhol > 1 && nhol < lhol) + { strval = strval->SubString(nhol + 1, lhol); + } } } @@ -208,20 +244,28 @@ void IGESData_GlobalSection::Init(const occ::handle& params, if (i < 3) { if (val[0] != '\0') + { sepend = val[0]; + } if (val[1] == 'H') + { sepend = val[2]; // prioritaire + } } switch (i) { case 1: if (sepend != '\0') + { theSeparator = sepend; + } break; case 2: if (sepend != '\0') + { theEndMark = sepend; + } break; case 3: theSendName = strval; @@ -312,9 +356,13 @@ void IGESData_GlobalSection::Init(const occ::handle& params, Msg39.Arg(24); Msg39.Arg(25); if (nbp < 24) + { ach->SendFail(Msg39); + } else + { ach->SendWarning(Msg39); + } } } // Version 5.3 @@ -325,9 +373,13 @@ void IGESData_GlobalSection::Init(const occ::handle& params, Msg39.Arg(25); Msg39.Arg(26); if (nbp < 25) + { ach->SendFail(Msg39); + } else + { ach->SendWarning(Msg39); + } } //: 45 by abv 11.12.97: if UnitFlag is not defined in the file, @@ -336,12 +388,18 @@ void IGESData_GlobalSection::Init(const occ::handle& params, { int corrected = 0; if (theUnitName.IsNull()) + { // default (inches) value taken corrected = 1; + } else + { corrected = IGESData_BasicEditor::UnitNameFlag(theUnitName->ToCString()); + } if (corrected > 0) + { theUnitFlag = corrected; + } else if (theUnitFlag == 3) { Message_Msg Msg49("XSTEP_49"); @@ -385,7 +443,9 @@ occ::handle IGESData_GlobalSection::Params() const uncar[0] = ','; occ::handle res = new Interface_ParamSet(26); // gka 19.01.99 if (theSeparator == ',') + { res->Append(vide, 0, Interface_ParamVoid, 0); + } else { uncar[0] = theSeparator; @@ -393,7 +453,9 @@ occ::handle IGESData_GlobalSection::Params() const } if (theEndMark == ';') + { res->Append(vide, 0, Interface_ParamVoid, 0); + } else { uncar[0] = theEndMark; @@ -455,10 +517,14 @@ occ::handle IGESData_GlobalSection::Params() const res->Append(nombre, (int)strlen(nombre), Interface_ParamReal, 0); if (hasMaxCoord) + { Interface_FloatWriter::Convert(theMaxCoord, nombre, true, 0., 0., "%f", "%f"); - // Sprintf(nombre,"%f",theMaxCoord); + // Sprintf(nombre,"%f",theMaxCoord); + } else + { nombre[0] = '\0'; + } res->Append(nombre, (int)strlen(nombre), Interface_ParamReal, 0); MakeHollerith(theAuthorName, text, lt); @@ -692,17 +758,23 @@ bool IGESData_GlobalSection::HasLastChangeDate() const void IGESData_GlobalSection::SetLastChangeDate() { if (HasLastChangeDate()) + { return; + } int mois, jour, annee, heure, minute, seconde, millisec, microsec; OSD_Process system; Quantity_Date ladate = system.SystemDate(); ladate.Values(mois, jour, annee, heure, minute, seconde, millisec, microsec); if (annee < 2000) + { // #65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000) theLastChangeDate = NewDateString(annee, mois, jour, heure, minute, seconde, 0); + } else + { // #65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000) theLastChangeDate = NewDateString(annee, mois, jour, heure, minute, seconde, -1); + } } //================================================================================================= @@ -745,7 +817,9 @@ occ::handle IGESData_GlobalSection::NewDateString(cons int an = anne % 100; bool dizaine = (an >= 10); if (!dizaine) + { an += 10; + } if (mode < 0) { an = anne; @@ -756,7 +830,9 @@ occ::handle IGESData_GlobalSection::NewDateString(cons Sprintf(madate, "%d%d", date1, date2); madate[(mode == 0 ? 6 : 8)] = '.'; if (!dizaine) + { madate[0] = '0'; + } } else if (mode == 1) { @@ -773,20 +849,30 @@ occ::handle IGESData_GlobalSection::NewDateString( { int anne, moi, jou, heur, minut, second; if (date.IsNull()) + { return date; + } int i0 = 0; if (date->Length() == 15) + { i0 = 2; + } else if (date->Length() != 13) + { return date; + } if (date->Value(i0 + 7) != '.') + { return date; + } anne = (date->Value(i0 + 1) - 48) * 10 + (date->Value(i0 + 2) - 48); if (i0 == 0) { anne = anne + 1900; if (anne < 1980) + { anne += 100; + } } else { @@ -922,10 +1008,14 @@ void IGESData_GlobalSection::MaxMaxCoord(const double val) if (hasMaxCoord) { if (aval > theMaxCoord) + { theMaxCoord = aval; + } } else + { SetMaxCoord(aval); + } } void IGESData_GlobalSection::MaxMaxCoords(const gp_XYZ& xyz) diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESDumper.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESDumper.cxx index 73cc589dbc..217433459e 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESDumper.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESDumper.cxx @@ -43,10 +43,14 @@ void IGESData_IGESDumper::PrintDNum(const occ::handle& ent, if (!ent.IsNull()) { if (themodel.IsNull()) + { S << " D??? "; + } else if ((num = themodel->Number(ent)) == 0) + { S << " 0:D?????"; - // throw Interface_InterfaceError("IGESDumper : PrintDNum"); + // throw Interface_InterfaceError("IGESDumper : PrintDNum"); + } else { S << Interface_MSG::Blanks(num, 9) << num << ":D" << 2 * num - 1 @@ -54,7 +58,9 @@ void IGESData_IGESDumper::PrintDNum(const occ::handle& ent, } } else + { S << " D0(Null) "; + } } void IGESData_IGESDumper::PrintShort(const occ::handle& ent, @@ -65,9 +71,13 @@ void IGESData_IGESDumper::PrintShort(const occ::handle& ent { int num = 0; if (!themodel.IsNull()) + { num = themodel->Number(ent); + } if (num > 0) + { S << num << ":D" << 2 * num - 1; + } S << " Type:" << ent->TypeNumber() << " Form:" << ent->FormNumber() << Interface_MSG::Blanks(ent->FormNumber(), 3) << " Class:" << Interface_InterfaceModel::ClassName(ent->DynamicType()->Name()); @@ -82,20 +92,30 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, int att = attached; int diratt = 1; if (own < 3) + { diratt = own - 1; + } if (att == 0) + { att = diratt; // -1 signifie : ne rien sortir + } if (own < 0) + { return; + } if (own > 1) + { S << "\n"; + } if (ent.IsNull()) { S << "(Null)"; if (own > 1) + { S << "\n"; + } return; } if (own == 0) @@ -110,7 +130,9 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, } // affichage auxiliaire if (own > 0) + { S << "**** Dump IGES, level " << own << " ( "; + } switch (own) { case 0: @@ -144,17 +166,25 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, S << " Directory Part\n"; // ** Status : Blank:1 Subordinate:2 UseFlag:3 Hierarchy:4 if (own >= 2) + { S << "** Status Number : Blank:" << ent->BlankStatus() << " Subordinate:" << ent->SubordinateStatus() << " UseFlag:" << ent->UseFlag() << " Hierarchy:" << ent->HierarchyStatus() << "\n"; + } if (own >= 1) { if (ent->HasShortLabel()) + { S << "**** Label :" << ent->ShortLabel()->ToCString(); + } if (ent->HasSubScriptNumber()) + { S << " SubScript:" << ent->SubScriptNumber(); + } if (ent->HasShortLabel()) - S << std::endl; + { + S << '\n'; + } if (ent->HasTransf()) { @@ -200,7 +230,9 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, } if (ent->Level() > 0) + { S << "** Level Value :" << ent->Level() << "\n"; + } else if (ent->Level() < 0) { S << "** Level List :"; @@ -218,8 +250,10 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, { S << "** LineWeight Num:" << ent->LineWeightNumber(); if (diratt > 0) + { S << " -> Value:" << ent->LineWeight(); - S << std::endl; + } + S << '\n'; } if (ent->DefColor() == IGESData_DefValue) { @@ -230,7 +264,7 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, S << "** Color Ref :"; PrintDNum(ent->Color(), S); } - S << std::endl; + S << '\n'; if (own > 3) { @@ -241,7 +275,9 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, // Attached data : Properties, Associativities, and Sharings if (att < 0) + { return; + } Interface_EntityIterator iter = ent->Properties(); int nb = iter.NbEntities(); bool iasuit = (nb > 0); @@ -257,7 +293,9 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, iter = ent->Associativities(); nb = iter.NbEntities(); if (nb > 0) + { iasuit = true; + } if (nb > 0) { S << "\n**** Associativities (nb:" << nb << ") ****\n"; @@ -270,9 +308,11 @@ void IGESData_IGESDumper::Dump(const occ::handle& ent, if (iasuit) { if (att <= 1) + { S << "\n"; + } } - S << "\n**** End of Dump ****\n" << std::endl; + S << "\n**** End of Dump ****\n" << '\n'; } void IGESData_IGESDumper::OwnDump(const occ::handle& ent, @@ -282,10 +322,16 @@ void IGESData_IGESDumper::OwnDump(const occ::handle& ent, occ::handle module; int CN; if (thelib.Select(ent, module, CN)) + { module->OwnDump(CN, ent, *this, S, own); + } else if (themodel.IsNull()) - S << " **** Dump impossible. Type " << ent->DynamicType()->Name() << std::endl; + { + S << " **** Dump impossible. Type " << ent->DynamicType()->Name() << '\n'; + } else + { S << " **** Dump Impossible, n0:id:" << themodel->Number(ent) << ":D" << themodel->DNum(ent) - << " Type " << ent->DynamicType()->Name() << std::endl; + << " Type " << ent->DynamicType()->Name() << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESEntity.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESEntity.cxx index a07739c075..b08870e53f 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESEntity.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESEntity.cxx @@ -111,19 +111,33 @@ occ::handle IGESData_IGESEntity::DirFieldEntity(const int n { occ::handle ent; if (num == 3) + { ent = theStructure; + } if (num == 4) + { ent = theLineFont; + } if (num == 5) + { ent = theLevelList; + } if (num == 6) + { ent = theView; + } if (num == 7) + { ent = theTransf; + } if (num == 8) + { ent = theLabDisplay; + } if (num == 13) + { ent = theColor; + } return ent; } @@ -155,9 +169,13 @@ occ::handle IGESData_IGESEntity::LineFont() const IGESData_DefList IGESData_IGESEntity::DefLevel() const { if (theDefLevel > 0) + { return IGESData_DefOne; + } if (theDefLevel < 0) + { return IGESData_DefSeveral; + } return IGESData_DefNone; } @@ -174,11 +192,17 @@ occ::handle IGESData_IGESEntity::LevelList() const IGESData_DefList IGESData_IGESEntity::DefView() const { if (View().IsNull()) + { return IGESData_DefNone; + } if (View()->IsSingle()) + { return IGESData_DefOne; + } else + { return IGESData_DefSeveral; + } } occ::handle IGESData_IGESEntity::View() const @@ -190,7 +214,9 @@ occ::handle IGESData_IGESEntity::SingleView() const { occ::handle nulvue; if (DefView() != IGESData_DefOne) + { return nulvue; + } return View(); } @@ -198,7 +224,9 @@ occ::handle IGESData_IGESEntity::ViewList() const { occ::handle nulvue; if (DefView() != IGESData_DefSeveral) + { return nulvue; + } return View(); } @@ -308,7 +336,9 @@ bool IGESData_IGESEntity::HasSubScriptNumber() const int IGESData_IGESEntity::SubScriptNumber() const { if (theSubScriptN < 0) + { return 0; + } return theSubScriptN; } @@ -324,19 +354,33 @@ void IGESData_IGESEntity::InitDirFieldEntity(const int const occ::handle& ent) { if (num == 3) + { theStructure = ent; + } if (num == 4) + { theLineFont = ent; + } if (num == 5) + { theLevelList = ent; + } if (num == 6) + { theView = ent; + } if (num == 7) + { theTransf = ent; + } if (num == 8) + { theLabDisplay = ent; + } if (num == 13) + { theColor = ent; + } } void IGESData_IGESEntity::InitTransf(const occ::handle& ent) @@ -393,9 +437,13 @@ void IGESData_IGESEntity::InitMisc(const occ::handle& theStructure = str; theLabDisplay = lab; if (theLWeightNum != 0) + { theLWeightVal *= (weightnum / theLWeightNum); + } else if (weightnum == 0) + { theLWeightVal = 0; + } theLWeightNum = weightnum; } @@ -412,7 +460,9 @@ bool IGESData_IGESEntity::HasOneParent() const occ::handle IGESData_IGESEntity::UniqueParent() const { if (NbTypedProperties(STANDARD_TYPE(IGESData_SingleParentEntity)) != 1) + { throw Interface_InterfaceError("IGESEntity : UniqueParent"); + } else { DeclareAndCast(IGESData_SingleParentEntity, @@ -428,7 +478,9 @@ gp_GTrsf IGESData_IGESEntity::Location() const // if (!HasTransf()) return gp_GTrsf(); // Identite // else return Transf()->Value(); // c-a-d Compoound if (!HasTransf()) + { return gp_GTrsf(); // Identite + } occ::handle trsf = Transf(); return (trsf.IsNull()) ? gp_GTrsf() : trsf->Value(); } @@ -436,8 +488,10 @@ gp_GTrsf IGESData_IGESEntity::Location() const gp_GTrsf IGESData_IGESEntity::VectorLocation() const { if (!HasTransf()) - return gp_GTrsf(); // Identite - // Take Location and cancel TranslationPart + { + return gp_GTrsf(); // Identite + } + // Take Location and cancel TranslationPart gp_GTrsf loca = Transf()->Value(); // c-a-d Compoound loca.SetTranslationPart(gp_XYZ(0., 0., 0.)); return loca; @@ -447,7 +501,9 @@ gp_GTrsf IGESData_IGESEntity::CompoundLocation() const { gp_GTrsf loca = Location(); if (!HasOneParent()) + { return loca; + } gp_GTrsf locp = UniqueParent()->CompoundLocation(); loca.PreMultiply(locp); return loca; @@ -456,7 +512,9 @@ gp_GTrsf IGESData_IGESEntity::CompoundLocation() const bool IGESData_IGESEntity::HasName() const { if (HasShortLabel()) + { return true; + } return (NbTypedProperties(STANDARD_TYPE(IGESData_NameEntity)) == 1); } @@ -468,9 +526,13 @@ occ::handle IGESData_IGESEntity::NameValue() const if (nbname == 0) { if (!HasShortLabel()) + { return nom; + } if (theSubScriptN < 0) + { return theShortLabel; + } char lenom[50]; Sprintf(lenom, "%s(%d)", theShortLabel->ToCString(), theSubScriptN); nom = new TCollection_HAsciiString(lenom); @@ -489,14 +551,18 @@ occ::handle IGESData_IGESEntity::NameValue() const bool IGESData_IGESEntity::ArePresentAssociativities() const { if (!theAssocs.IsEmpty()) + { return true; + } return (theStatusNum & IGESFlagAssocs) != 0; } int IGESData_IGESEntity::NbAssociativities() const { if (theAssocs.IsEmpty()) + { return 0; + } return theAssocs.NbEntities(); } @@ -542,26 +608,34 @@ void IGESData_IGESEntity::ClearAssociativities() void IGESData_IGESEntity::Associate(const occ::handle& ent) const { if (!ent.IsNull()) + { ent->AddAssociativity(ThisEntity); + } } void IGESData_IGESEntity::Dissociate(const occ::handle& ent) const { if (!ent.IsNull()) + { ent->RemoveAssociativity(ThisEntity); + } } bool IGESData_IGESEntity::ArePresentProperties() const { if (!theProps.IsEmpty()) + { return true; + } return (theStatusNum & IGESFlagProps) != 0; } int IGESData_IGESEntity::NbProperties() const { if (theProps.IsEmpty()) + { return 0; + } return theProps.NbEntities(); } @@ -610,9 +684,15 @@ void IGESData_IGESEntity::ClearProperties() void IGESData_IGESEntity::SetLineWeight(const double defw, const double maxw, const int gradw) { if (theLWeightNum == 0) + { theLWeightVal = defw; + } else if (gradw == 1) + { theLWeightVal = maxw * theLWeightNum; + } else + { theLWeightVal = (maxw * theLWeightNum) / gradw; + } } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESModel.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESModel.cxx index a19bb6aac5..30c12b40f3 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESModel.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESModel.cxx @@ -60,48 +60,68 @@ void IGESData_IGESModel::ClearHeader() void IGESData_IGESModel::DumpHeader(Standard_OStream& S, const int) const { int ns = thestart->Length(); - S << "**** Dump of IGES Model , Start and Global Sections ****" << std::endl; + S << "**** Dump of IGES Model , Start and Global Sections ****" << '\n'; if (ns > 0) { S << "**** Start Section : " << ns << " Line(s) ****\n"; for (int i = 1; i <= ns; i++) - S << "[" << (i < 10 ? " " : "") << i << "]:" << thestart->Value(i)->ToCString() << std::endl; + { + S << "[" << (i < 10 ? " " : "") << i << "]:" << thestart->Value(i)->ToCString() << '\n'; + } } S << "\n**** Global Section ****\n"; char sep = theheader.Separator(); if (sep == ',') + { S << "[ 1] Default Separator : " << sep; + } else + { S << "[ 1] Non Default Separator : " << sep; + } char emk = theheader.EndMark(); if (emk == ';') + { S << " [ 2] Default End Mark : " << emk; + } else + { S << " [ 2] Non Default End Mark : " << emk; + } S << "\n"; occ::handle str; str = theheader.SendName(); if (!str.IsNull()) - S << "[ 3] Sender : " << str->ToCString() << std::endl; + { + S << "[ 3] Sender : " << str->ToCString() << '\n'; + } str = theheader.FileName(); if (!str.IsNull()) - S << "[ 4] (recorded) File Name : " << str->ToCString() << std::endl; + { + S << "[ 4] (recorded) File Name : " << str->ToCString() << '\n'; + } str = theheader.SystemId(); if (!str.IsNull()) - S << "[ 5] System Identification : " << str->ToCString() << std::endl; + { + S << "[ 5] System Identification : " << str->ToCString() << '\n'; + } str = theheader.InterfaceVersion(); if (!str.IsNull()) - S << "[ 6] Interface Version : " << str->ToCString() << std::endl; - S << std::endl; + { + S << "[ 6] Interface Version : " << str->ToCString() << '\n'; + } + S << '\n'; S << "[ 7] Integer Bits : " << theheader.IntegerBits() - << " Features for Reals : " << std::endl; + << " Features for Reals : " << '\n'; S << "[ 8] Single Max.Power(10) : " << theheader.MaxPower10Single(); S << " [ 9] Digits : " << theheader.MaxDigitsSingle() << "\n"; S << "[10] Double Max.Power(10) : " << theheader.MaxPower10Double(); S << " [11] Digits : " << theheader.MaxDigitsDouble() << "\n\n"; str = theheader.ReceiveName(); if (!str.IsNull()) + { S << "[12] Receiver : " << str->ToCString() << "\n"; + } S << "[13] Scale : " << theheader.Scale() << "\n"; S << "[14] Unit Flag : " << theheader.UnitFlag(); // if (Interface_Static::IVal("read.scale.unit") == 1) @@ -113,26 +133,38 @@ void IGESData_IGESModel::DumpHeader(Standard_OStream& S, const int) const str = theheader.UnitName(); if (!str.IsNull()) + { S << "[15] Unit Name : " << str->ToCString() << "\n\n"; + } S << "[16] Line Weight Gradient : " << theheader.LineWeightGrad() << "\n"; S << "[17] Line Weight Max Value: " << theheader.MaxLineWeight() << "\n"; str = theheader.Date(); if (!str.IsNull()) + { S << "[18] (Creation) Date : " << str->ToCString() << " i.e. " << IGESData_GlobalSection::NewDateString(str, 1)->ToCString() << "\n"; + } S << "[19] Resolution : " << theheader.Resolution() << "\n"; if (theheader.HasMaxCoord()) + { S << "[20] Maximum Coord : " << theheader.MaxCoord() << "\n\n"; + } else + { S << "[20] Maximum Coord not defined\n\n"; + } str = theheader.AuthorName(); if (!str.IsNull()) + { S << "[21] Author : " << str->ToCString() << "\n"; + } str = theheader.CompanyName(); if (!str.IsNull()) + { S << "[22] Company : " << str->ToCString() << "\n"; + } int num = theheader.IGESVersion(); S << "[23] IGES Version Number : " << num << " -> Name : " << IGESData_BasicEditor::IGESVersionName(num); @@ -140,25 +172,29 @@ void IGESData_IGESModel::DumpHeader(Standard_OStream& S, const int) const num = theheader.DraftingStandard(); S << "\n[24] Drafting Standard : " << num; if (num > 0) + { S << " -> Name : " << IGESData_BasicEditor::DraftingName(num); - S << std::endl; + } + S << '\n'; if (theheader.HasLastChangeDate()) { str = theheader.LastChangeDate(); S << "[25] Last Change Date : " << str->ToCString() << " i.e. " - << IGESData_GlobalSection::NewDateString(str, 1)->ToCString() << std::endl; + << IGESData_GlobalSection::NewDateString(str, 1)->ToCString() << '\n'; } else - S << "[25] Last Change Date not defined (version IGES < 5.1)" << std::endl; + { + S << "[25] Last Change Date not defined (version IGES < 5.1)" << '\n'; + } if (theheader.HasApplicationProtocol()) { str = theheader.ApplicationProtocol(); - S << "[26] Application Protocol : " << str->ToCString() << std::endl; + S << "[26] Application Protocol : " << str->ToCString() << '\n'; } - S << " **** End of Dump ****" << std::endl; + S << " **** End of Dump ****" << '\n'; } //================================================================================================= @@ -181,7 +217,9 @@ int IGESData_IGESModel::NbStartLines() const const char* IGESData_IGESModel::StartLine(const int num) const { if (num > 0 && num <= thestart->Length()) + { return thestart->Value(num)->ToCString(); + } return voidline; } @@ -200,15 +238,23 @@ void IGESData_IGESModel::SetStartSection( { thestart = new NCollection_HSequence>(); if (list.IsNull()) + { return; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) + { thestart->Append(new TCollection_HAsciiString(list->Value(i)->ToCString())); + } } else if (list.IsNull()) + { thestart = new NCollection_HSequence>(); + } else + { thestart = list; + } } //================================================================================================= @@ -216,9 +262,13 @@ void IGESData_IGESModel::SetStartSection( void IGESData_IGESModel::AddStartLine(const char* const line, const int atnum) { if (atnum <= 0 || atnum > thestart->Length()) + { thestart->Append(new TCollection_HAsciiString(line)); + } else + { thestart->InsertBefore(atnum, new TCollection_HAsciiString(line)); + } } //================================================================================================= @@ -246,21 +296,27 @@ bool IGESData_IGESModel::ApplyStatic(const char* const param) { val = Interface_Static::CVal("write.iges.header.receiver"); if (!val || val[0] == '\0') + { return false; + } theheader.SetReceiveName(new TCollection_HAsciiString(val)); } if (param[0] == 'a') { val = Interface_Static::CVal("write.iges.header.author"); if (!val || val[0] == '\0') + { return false; + } theheader.SetAuthorName(new TCollection_HAsciiString(val)); } if (param[0] == 'c') { val = Interface_Static::CVal("write.iges.header.company"); if (!val || val[0] == '\0') + { return false; + } theheader.SetCompanyName(new TCollection_HAsciiString(val)); } return true; @@ -279,9 +335,13 @@ int IGESData_IGESModel::DNum(const occ::handle& ent) const { int num = Number(ent); if (num == 0) + { return 0; + } else + { return 2 * num - 1; + } } //================================================================================================= @@ -495,7 +555,9 @@ void IGESData_IGESModel::VerifyCheck(occ::handle& ach) const ach->SendWarning(Msg55); } else + { IGESData_VerifyDate(theheader.LastChangeDate(), ach, "Last Change Date"); + } } } @@ -517,38 +579,59 @@ void IGESData_VerifyDate(const occ::handle& str, const occ::handle& stdvar = str; if (strcmp(mess, "Last Change Date") == 0) + { Msg57.Arg(25); + } else + { Msg57.Arg(18); + } if (((stdvar->Length() != 13) && (stdvar->Length() != 15)) || !stdvar->IsRealValue()) + { ach->SendFail(Msg57); - // smh#13 For short year date + // smh#13 For short year date + } else if ((stdvar->Value(3) > '1' || (stdvar->Value(3) == '1' && stdvar->Value(4) > '2')) && (stdvar->Length() == 13)) + { ach->SendFail(Msg57); - + } else if ((stdvar->Value(5) > '3' || (stdvar->Value(5) == '3' && stdvar->Value(6) > '1')) && (stdvar->Length() == 13)) + { ach->SendFail(Msg57); + } else if ((stdvar->Value(7) != '.' || stdvar->Value(10) > '5' || stdvar->Value(12) > '5') && (stdvar->Length() == 13)) + { ach->SendFail(Msg57); + } else if ((stdvar->Value(8) > '2' || (stdvar->Value(8) == '2' && stdvar->Value(9) > '3')) && (stdvar->Length() == 13)) + { ach->SendFail(Msg57); - // smh#13 For long year date + // smh#13 For long year date + } else if ((stdvar->Value(5) > '1' || (stdvar->Value(5) == '1' && stdvar->Value(6) > '2')) && (stdvar->Length() == 15)) + { ach->SendFail(Msg57); + } else if ((stdvar->Value(7) > '3' || (stdvar->Value(7) == '3' && stdvar->Value(8) > '1')) && (stdvar->Length() == 15)) + { ach->SendFail(Msg57); + } else if ((stdvar->Value(9) != '.' || stdvar->Value(12) > '5' || stdvar->Value(14) > '5') && (stdvar->Length() == 15)) + { ach->SendFail(Msg57); + } else if ((stdvar->Value(10) > '2' || (stdvar->Value(10) == '2' && stdvar->Value(11) > '3')) && (stdvar->Length() == 15)) + { ach->SendFail(Msg57); + } } //================================================================================================= @@ -564,7 +647,9 @@ void IGESData_IGESModel::SetLineWeights(const double defw) lwg = 1; } for (int i = 1; i <= nb; i++) + { Entity(i)->SetLineWeight(defw, maxw, lwg); + } } //================================================================================================= @@ -578,14 +663,20 @@ void IGESData_IGESModel::PrintLabel(const occ::handle& ent, { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { S << "Null"; + } else { int num = Number(ent); if (num == 0) + { S << "??"; + } else + { S << "D" << (2 * num - 1); + } } } @@ -599,7 +690,9 @@ void IGESData_IGESModel::PrintToLog(const occ::handle& ent, { int num = Number(ent); if (num == 0) + { S << "??"; + } else { S << " DE : " << (2 * num - 1) << " type : " << igesent->TypeNumber(); @@ -615,12 +708,16 @@ void IGESData_IGESModel::PrintInfo(const occ::handle& ent, { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { S << "(NOT IGES)"; + } else { int num = Number(ent); if (num == 0) + { S << "??"; + } else { S << (2 * num - 1) << "type " << Type(ent)->Name(); @@ -636,15 +733,21 @@ occ::handle IGESData_IGESModel::StringLabel( occ::handle label; DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return new TCollection_HAsciiString("(NOT IGES)"); + } else { char text[20]; int num = Number(ent); if (num > 0) + { Sprintf(text, "D%d", 2 * num - 1); + } else + { Sprintf(text, "D0..."); + } label = new TCollection_HAsciiString(text); } return label; diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderData.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderData.cxx index 787a0b8de4..323c74a3f7 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderData.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderData.cxx @@ -175,9 +175,13 @@ int IGESData_IGESReaderData::NbEntities() const int IGESData_IGESReaderData::FindNextRecord(const int num) const { if (num >= thedirs.Upper()) + { return 0; + } else + { return (num + 1); + } } // Reference to other entities: this is both very simple and problematic diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderTool.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderTool.cxx index 5e598d8f79..fd70bb6726 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderTool.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESReaderTool.cxx @@ -72,12 +72,18 @@ bool IGESData_IGESReaderTool::Recognize(const int num, // Recognizer -> Liste limitative if (!thereco.IsNull()) + { res = thereco->Evaluate(thectyp, anent); + } if (res) + { ent = anent; - // Sinon, Library + // Sinon, Library + } else + { res = RecognizeByLib(num, theglib, therlib, ach, ent); + } return res; } @@ -129,7 +135,9 @@ bool IGESData_IGESReaderTool::AnalyseRecord(const int ReadDir(ent, igesdat, DP, ach); // Reading with this DP } else + { ReadDir(ent, igesdat, igesdat->DirPart(num), ach); + } thestep = IGESData_ReadDir; @@ -141,7 +149,9 @@ bool IGESData_IGESReaderTool::AnalyseRecord(const int { // Empty list not allowed, except if Undefined (for example null type) if (!undent.IsNull()) + { return true; + } // Sending of message : DE : no parameter Message_Msg Msg27("XSTEP_27"); Msg27.Arg(thecnum); @@ -162,27 +172,37 @@ bool IGESData_IGESReaderTool::AnalyseRecord(const int thestep = IGESData_ReadOwn; ReadOwnParams(ent, igesdat, PR); if ((thestep = PR.Stage()) == IGESData_ReadOwn) + { PR.NextStage(); + } if (thestep == IGESData_ReadEnd) { if (!PR.IsCheckEmpty()) + { ach = PR.Check(); + } return (!ach->HasFailed()); } ReadAssocs(ent, igesdat, PR); if ((thestep = PR.Stage()) == IGESData_ReadAssocs) + { PR.NextStage(); + } if (thestep == IGESData_ReadEnd) { if (!PR.IsCheckEmpty()) + { ach = PR.Check(); + } return (!ach->HasFailed()); } ReadProps(ent, igesdat, PR); // thestep = IGESData_ReadEnd; if (!PR.IsCheckEmpty()) + { ach = PR.Check(); + } return (!ach->HasFailed()); } @@ -234,7 +254,9 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitTypeAndForm(v[0], v[16]); occ::handle fieldent, Structure, fieldlab; if (v[2] < 0) + { Structure = GetCasted(IGESData_IGESEntity, IR->BoundEntity((1 - v[2]) / 2)); + } occ::handle Lnf; if (v[3] < 0) @@ -251,10 +273,14 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitDirFieldEntity(4, fieldent); } else + { ent->InitLineFont(Lnf); + } } else + { ent->InitLineFont(Lnf, v[3]); // ici Lnf Null + } occ::handle Lvs; if (v[4] < 0) @@ -271,10 +297,14 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitDirFieldEntity(5, fieldent); } else + { ent->InitLevel(Lvs, -1); + } } else + { ent->InitLevel(Lvs, v[4]); // ici Lvs Null + } if (v[5] != 0) { @@ -290,7 +320,9 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitDirFieldEntity(6, fieldent); } else + { ent->InitView(View); + } } if (v[6] != 0) @@ -307,7 +339,9 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitDirFieldEntity(7, fieldent); } else + { ent->InitTransf(Transf); + } } occ::handle Lbd; @@ -346,10 +380,14 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& ent->InitDirFieldEntity(13, Color); } else + { ent->InitColor(Color); + } } else + { ent->InitColor(Color, v[14]); + } ent->InitMisc(Structure, Lbd, LWeightNum); ent->InitDirFieldEntity(8, fieldlab); @@ -365,20 +403,30 @@ void IGESData_IGESReaderTool::ReadDir(const occ::handle& for (i = 0; i < 8; i++) { if (nom[i] > ' ') + { iacar = 1; + } } if (iacar > 0) + { ShortLabel = new TCollection_HAsciiString(nom); + } iacar = 0; for (i = 0; i < 8; i++) { if (snum[i] > ' ') + { iacar = 1; + } if (snum[i] == 0) + { break; + } } if (iacar > 0) + { SubScriptN = atoi(snum); + } ent->SetLabel(ShortLabel, SubScriptN); // Finally, SetLineWeight, taking into account the default @@ -443,7 +491,9 @@ void IGESData_IGESReaderTool::ReadProps(const occ::handle& Msg38.Arg(thecnum); Msg38.Arg(thectyp.Type()); if (PR.Stage() != IGESData_ReadProps) + { ach->SendFail(Msg38); + } int ncur = PR.CurrentNumber(); int nbp = PR.NbParams(); if (ncur == nbp + 1) @@ -452,11 +502,15 @@ void IGESData_IGESReaderTool::ReadProps(const occ::handle& return; } else if (ncur > nbp || ncur == 0) + { ach->SendWarning(Msg38); + } int nbprops = 0; if (!PR.DefinedElseSkip()) + { return; + } if (!PR.ReadInteger(ncur, nbprops)) { Message_Msg Msg221("XSTEP_221"); @@ -471,7 +525,9 @@ void IGESData_IGESReaderTool::ReadProps(const occ::handle& ++ncur; Interface_EntityList props; if (PR.ReadEntList(IR, PR.CurrentList(nbprops), Msg38, props, false)) + { ent->LoadProperties(props); + } } // ######## Associativites ######## @@ -490,7 +546,9 @@ void IGESData_IGESReaderTool::ReadAssocs(const occ::handle& Msg37.Arg(thectyp.Type()); occ::handle ach = new Interface_Check; if (PR.Stage() != IGESData_ReadAssocs) + { ach->SendFail(Msg37); + } int ncur = PR.CurrentNumber(); int nbp = PR.NbParams(); if (ncur == nbp + 1) @@ -499,11 +557,15 @@ void IGESData_IGESReaderTool::ReadAssocs(const occ::handle& return; } else if (ncur > nbp || ncur == 0) + { ach->SendWarning(Msg37); + } int nbassocs = 0; if (!PR.DefinedElseSkip()) + { return; + } if (!PR.ReadInteger(PR.Current(), nbassocs)) { Message_Msg Msg220("XSTEP_220"); @@ -511,8 +573,12 @@ void IGESData_IGESReaderTool::ReadAssocs(const occ::handle& return; } if (nbassocs == 0) + { return; + } Interface_EntityList assocs; if (PR.ReadEntList(IR, PR.CurrentList(nbassocs), Msg37, assocs, false)) + { ent->LoadAssociativities(assocs); + } } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESWriter.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESWriter.cxx index 455c2e4a07..293bce18d4 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESWriter.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_IGESWriter.cxx @@ -101,9 +101,13 @@ void IGESData_IGESWriter::SendStartLine(const char* const startline) // size_t lst = strlen(startline); if (lst == 0) + { return; + } if (thestar.IsNull()) + { thestar = new NCollection_HSequence>(); + } if (lst <= (size_t)MaxcarsG) { thestar->Append(new TCollection_HAsciiString(startline)); @@ -130,7 +134,9 @@ void IGESData_IGESWriter::SendModel(const occ::handle& protoc int ns = themodel->NbStartLines(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= ns; i++) + { SendStartLine(themodel->StartLine(i)); + } SectionG(themodel->GlobalSection()); SectionsDP(); for (i = 1; i <= nb; i++) @@ -144,12 +150,16 @@ void IGESData_IGESWriter::SendModel(const occ::handle& protoc // Watch out for error cases : redefined content if (themodel->IsRedefinedContent(i)) { - sout << " -- IGESWriter : Erroneous Entity N0." << i << " --" << std::endl; + sout << " -- IGESWriter : Erroneous Entity N0." << i << " --" << '\n'; occ::handle rep = themodel->ReportEntity(i); if (!rep.IsNull()) + { cnt = GetCasted(IGESData_IGESEntity, rep->Content()); + } if (cnt.IsNull()) + { cnt = ent; // secours + } } DirPart(cnt); @@ -160,15 +170,19 @@ void IGESData_IGESWriter::SendModel(const occ::handle& protoc int CN; // Different cases if (lib.Select(cnt, module, CN)) + { module->WriteOwnParams(CN, cnt, *this); + } else if (cnt->IsKind(STANDARD_TYPE(IGESData_UndefinedEntity))) { DeclareAndCast(IGESData_UndefinedEntity, undent, cnt); undent->WriteOwnParams(*this); } else + { sout << " -- IGESWriter : Not Processed for n0." << i << " in file, Type " - << cnt->TypeNumber() << " Form " << cnt->FormNumber() << std::endl; + << cnt->TypeNumber() << " Form " << cnt->FormNumber() << '\n'; + } Associativities(cnt); Properties(cnt); @@ -183,14 +197,18 @@ void IGESData_IGESWriter::SendModel(const occ::handle& protoc void IGESData_IGESWriter::SectionS() { if (thesect != 0) + { throw Interface_InterfaceError("IGESWriter : SectionS"); + } thesect = 1; } void IGESData_IGESWriter::SectionG(const IGESData_GlobalSection& header) { if (thesect != 1) + { throw Interface_InterfaceError("IGESWriter : SectionG"); + } thesect = 2; thesep = header.Separator(); theendm = header.EndMark(); @@ -204,18 +222,26 @@ void IGESData_IGESWriter::SectionG(const IGESData_GlobalSection& header) const Interface_FileParameter& FP = gl->Param(i); AddString(FP.CValue()); if (i < nb) + { AddChar(thesep); + } else + { AddChar(theendm); + } } if (thecurr.Length() > 0) + { thehead->Append(thecurr.Moved()); + } } void IGESData_IGESWriter::SectionsDP() { if (thesect != 2) + { throw Interface_InterfaceError("IGESWriter : SectionsDP"); + } thesect = 3; thecurr.SetMax(MaxcarsP); thestep = IGESData_ReadEnd; @@ -224,7 +250,9 @@ void IGESData_IGESWriter::SectionsDP() void IGESData_IGESWriter::SectionT() { if (thesect != 3) + { throw Interface_InterfaceError("IGESWriter : SectionT"); + } thesect = 4; thepnum.SetValue(thepnum.Length(), thepars->Length() + 1); } @@ -232,52 +260,84 @@ void IGESData_IGESWriter::SectionT() void IGESData_IGESWriter::DirPart(const occ::handle& anent) { if (thesect != 3 && thestep != IGESData_ReadEnd) + { throw Interface_InterfaceError("IGESWriter : DirPart"); + } int v[17]; char res1[9], res2[9], label[9], snum[9]; int nument = themodel->Number(anent); if (nument == 0) + { return; + } IGESData_DirPart& DP = thedirs.ChangeValue(nument); // Filling the DirPart v[0] = anent->TypeNumber(); v[1] = 0; // number in section P: calculated later if (anent->HasStructure()) + { v[2] = -themodel->DNum(anent->DirFieldEntity(3)); + } else + { v[2] = 0; + } IGESData_DefType linet = anent->DefLineFont(); if (linet == IGESData_DefReference) + { v[3] = -themodel->DNum(anent->DirFieldEntity(4)); + } else if (linet == IGESData_DefValue) + { v[3] = anent->RankLineFont(); + } else + { v[3] = 0; + } IGESData_DefList levt = anent->DefLevel(); if (levt == IGESData_DefSeveral) + { v[4] = -themodel->DNum(anent->DirFieldEntity(5)); + } else if (levt == IGESData_DefOne) + { v[4] = anent->Level(); + } else + { v[4] = 0; + } IGESData_DefList viewt = anent->DefView(); if (viewt == IGESData_DefSeveral || viewt == IGESData_DefOne) + { v[5] = themodel->DNum(anent->DirFieldEntity(6)); + } else + { v[5] = 0; + } if (anent->HasTransf()) + { v[6] = themodel->DNum(anent->DirFieldEntity(7)); + } else + { v[6] = 0; + } if (anent->HasLabelDisplay()) + { v[7] = themodel->DNum(anent->DirFieldEntity(8)); + } else + { v[7] = 0; + } v[8] = anent->BlankStatus(); v[9] = anent->SubordinateStatus(); @@ -288,11 +348,17 @@ void IGESData_IGESWriter::DirPart(const occ::handle& anent) IGESData_DefType colt = anent->DefColor(); if (colt == IGESData_DefReference) + { v[14] = -themodel->DNum(anent->DirFieldEntity(13)); + } else if (colt == IGESData_DefValue) + { v[14] = anent->RankColor(); + } else + { v[14] = 0; + } v[15] = 0; // number of lines in section P: calculated later v[16] = anent->FormNumber(); @@ -300,12 +366,16 @@ void IGESData_IGESWriter::DirPart(const occ::handle& anent) anent->CResValues(res1, res2); int i; // svv Jan11 2000 : porting on DEC for (i = 0; i < 8; i++) + { label[i] = snum[i] = ' '; + } if (anent->HasShortLabel()) { occ::handle slab = anent->ShortLabel(); for (i = 0; i < slab->Length() && i < 8; i++) + { label[i] = slab->Value(i + 1); + } } if (anent->HasSubScriptNumber()) { @@ -349,7 +419,9 @@ void IGESData_IGESWriter::OwnParams(const occ::handle& anen { char text[20]; if (thesect != 3 && thestep != IGESData_ReadDir) + { throw Interface_InterfaceError("IGESWriter : OwnParams"); + } thepnum.SetValue(themodel->Number(anent), thepars->Length() + 1); thecurr.Clear(); Sprintf(text, "%d", anent->TypeNumber()); @@ -360,10 +432,14 @@ void IGESData_IGESWriter::OwnParams(const occ::handle& anen void IGESData_IGESWriter::Properties(const occ::handle& anent) { if (thesect != 3 && thestep != IGESData_ReadOwn) + { throw Interface_InterfaceError("IGESWriter : Properties"); + } thestep = IGESData_ReadProps; if (!anent->ArePresentProperties()) + { return; + } Send(anent->NbProperties()); for (Interface_EntityIterator iter = anent->Properties(); iter.More(); iter.Next()) { @@ -375,10 +451,14 @@ void IGESData_IGESWriter::Properties(const occ::handle& ane void IGESData_IGESWriter::Associativities(const occ::handle& anent) { if (thesect != 3 && thestep != IGESData_ReadOwn) + { throw Interface_InterfaceError("IGESWriter : Associativities"); + } thestep = IGESData_ReadAssocs; if (!anent->ArePresentAssociativities() && !anent->ArePresentProperties()) + { return; // Properties follow : do not omit them ! + } Send(anent->NbAssociativities()); for (Interface_EntityIterator iter = anent->Associativities(); iter.More(); iter.Next()) { @@ -391,10 +471,14 @@ void IGESData_IGESWriter::Associativities(const occ::handle void IGESData_IGESWriter::EndEntity() { if (thesect != 3 && thestep != IGESData_ReadOwn) + { throw Interface_InterfaceError("IGESWriter : EndEntity"); + } AddChar(theendm); if (thecurr.Length() > 0) + { thepars->Append(thecurr.Moved()); + } thestep = IGESData_ReadEnd; } @@ -404,7 +488,9 @@ void IGESData_IGESWriter::AddString(const occ::handle& const int more) { if (val.IsNull()) + { return; + } AddString(val->ToCString(), val->Length(), more); } @@ -412,14 +498,20 @@ void IGESData_IGESWriter::AddString(const char* const val, const int lnval, cons { int lnstr = lnval; if (lnstr <= 0) + { lnstr = (int)strlen(val); + } if (!thecurr.CanGet(lnstr + more + 1)) { // + 1 (18-SEP-1996) to be sure that the separator n is not at the head of line if (thesect < 3) + { thehead->Append(thecurr.Moved()); + } else + { thepars->Append(thecurr.Moved()); + } } int maxcars = (thesect == 3 ? MaxcarsP : MaxcarsG); int n2 = 0; @@ -428,9 +520,13 @@ void IGESData_IGESWriter::AddString(const char* const val, const int lnval, cons { thecurr.Add(&val[n2], lnstr); if (thesect < 3) + { thehead->Append(thecurr.Moved()); + } else + { thepars->Append(thecurr.Moved()); + } n2 += maxcars; lnstr -= maxcars; } @@ -446,9 +542,13 @@ void IGESData_IGESWriter::AddChar(const char val, const int more) if (!thecurr.CanGet(1 + more)) { if (thesect < 3) + { thehead->Append(thecurr.Moved()); + } else + { thepars->Append(thecurr.Moved()); + } } thecurr.Add(text, 1); } @@ -470,9 +570,13 @@ void IGESData_IGESWriter::SendBoolean(const bool val) { AddChar(thesep); if (val) + { AddString("1"); + } else + { AddString("0"); + } } void IGESData_IGESWriter::Send(const double val) @@ -488,10 +592,14 @@ void IGESData_IGESWriter::Send(const occ::handle& val) { AddChar(thesep); if (val.IsNull()) + { return; + } int lns = val->Length(); if (lns == 0) + { return; // string vide : void vaut mieux que 0H + } occ::handle hol = new TCollection_HAsciiString(lns); hol->AssignCat("H"); hol->AssignCat(val->ToCString()); @@ -502,9 +610,13 @@ void IGESData_IGESWriter::Send(const occ::handle& val, cons { int num = 0; if (!val.IsNull()) + { num = themodel->DNum(val); + } if (negative) + { num = -num; + } Send(num); // which handles everything, once Entity converted to Integer } @@ -534,11 +646,17 @@ occ::handle>> IGESDa { occ::handle>> res; if (num == 1) + { res = thestar; + } if (num == 2) + { res = thehead; + } if (num >= 3) + { res = thepars; + } return res; } @@ -548,7 +666,9 @@ static void writefnes(Standard_OStream& S, const char* const ligne) for (int i = 0; i < 80; i++) { if (ligne[i] == '\0') + { return; + } val = (char)(ligne[i] ^ (150 + (i & 3))); S << val; } @@ -566,7 +686,9 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const bool isGood = (S.good()); bool fnes = (themodew >= 10); if (!isGood) + { return isGood; + } char ligne[256]; #ifdef PATIENCELOG int lignespatience = 1000; @@ -574,16 +696,22 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const char blancs[73]; int i; // svv Jan11 2000 : porting on DEC for (i = 0; i < MaxcarsG; i++) + { blancs[i] = ' '; + } blancs[MaxcarsG] = '\0'; if (fnes) { for (i = 0; i < MaxcarsG; i++) + { blancs[i] = (char)(blancs[i] ^ (150 + (i & 3))); + } } if (thesect != 4) + { throw Interface_InterfaceError("IGESWriter not ready for Print"); + } // Start Section (quite simple, all in all). Watch out for comments occ::handle line; int nbs = 1; @@ -591,14 +719,16 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const { if (fnes) { - S << " *** EUCLID/STRIM DESKTOP CLIPBOARD ***" << std::endl; + S << " *** EUCLID/STRIM DESKTOP CLIPBOARD ***" << '\n'; writefnes(S, " S0000001"); } else + { S << " S0000001"; + } // 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12 - S << std::endl; + S << '\n'; } else { @@ -610,16 +740,24 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const line = thestar->Value(i); if (fnes) + { writefnes(S, line->ToCString()); + } else + { S << line->ToCString(); + } // for (int k = line->Length()+1; k <= MaxcarsG; k ++) aSender <<' '; S << &blancs[line->Length()]; if (fnes) + { writefnes(S, finlin); + } else + { S << finlin; - S << std::endl; + } + S << '\n'; } } #ifdef PATIENCELOG @@ -635,20 +773,30 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const line = thehead->Value(i); if (fnes) + { writefnes(S, line->ToCString()); + } else + { S << line->ToCString(); + } // for (int k = line->Length()+1; k <= MaxcarsG; k ++) aSender <<' '; S << &blancs[line->Length()]; if (fnes) + { writefnes(S, finlin); + } else + { S << finlin; - S << std::endl; + } + S << '\n'; isGood = S.good(); } if (!isGood) + { return isGood; + } #ifdef PATIENCELOG std::cout << nbg << " lines" << std::endl; #endif @@ -701,9 +849,13 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const v[11], 2 * i - 1); if (fnes) + { writefnes(S, ligne); + } else + { S << ligne; + } S << "\n"; Sprintf(ligne, "%8d%8d%8d%8d%8d%8s%8s%8s%8sD%7.7d", @@ -718,9 +870,13 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const num, 2 * i); if (fnes) + { writefnes(S, ligne); + } else + { S << ligne; + } S << "\n"; // std::cout << "Ent.no "<LeftJustify(MaxcarsP,' '); replaced by more economical ! : if (fnes) + { writefnes(S, line->ToCString()); + } else + { S << line->ToCString(); + } // for (int k = line->Length()+1; k <= MaxcarsP; k ++)aSender <<' '; S << &blancs[line->Length()]; if (fnes) + { writefnes(S, finlin); + } else + { S << finlin; - S << std::endl; + } + S << '\n'; isGood = S.good(); #ifdef PATIENCELOG lignespatience--; @@ -769,7 +935,9 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const } } if (!isGood) + { return isGood; + } // Terminal Section (pas trop compliquee, ma foi) Sprintf(ligne, "S%7dG%7dD%7dP%7d T0000001", @@ -779,9 +947,13 @@ bool IGESData_IGESWriter::Print(Standard_OStream& S) const thepnum.Value(thepnum.Length()) - 1); // 12345678- 16- 24- 32 56789 123456789 123456789 123456789 12 if (fnes) + { writefnes(S, ligne); + } else + { S << ligne; + } S << "\n"; S.flush(); isGood = S.good(); diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_LevelListEntity.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_LevelListEntity.cxx index caad0f350a..ea4a7ed055 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_LevelListEntity.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_LevelListEntity.cxx @@ -24,7 +24,9 @@ bool IGESData_LevelListEntity::HasLevelNumber(const int level) const for (int i = 1; i <= nb; i++) { if (LevelNumber(i) == level) + { return true; + } } return false; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfSpecificLib_0.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfSpecificLib_0.cxx index ae7a063747..bd7f751a7e 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfSpecificLib_0.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfSpecificLib_0.cxx @@ -29,11 +29,15 @@ IGESData_NodeOfSpecificLib::IGESData_NodeOfSpecificLib() = default; void IGESData_NodeOfSpecificLib::AddNode(const occ::handle& anode) { if (thenode == anode) + { return; + } if (thenext.IsNull()) { if (thenode.IsNull()) + { thenode = anode; + } else { thenext = new IGESData_NodeOfSpecificLib; @@ -41,7 +45,9 @@ void IGESData_NodeOfSpecificLib::AddNode(const occ::handleAddNode(anode); + } } const occ::handle& IGESData_NodeOfSpecificLib::Module() const diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfWriterLib_0.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfWriterLib_0.cxx index 56fbc0e8c4..977e4d6f57 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfWriterLib_0.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_NodeOfWriterLib_0.cxx @@ -29,11 +29,15 @@ IGESData_NodeOfWriterLib::IGESData_NodeOfWriterLib() = default; void IGESData_NodeOfWriterLib::AddNode(const occ::handle& anode) { if (thenode == anode) + { return; + } if (thenext.IsNull()) { if (thenode.IsNull()) + { thenode = anode; + } else { thenext = new IGESData_NodeOfWriterLib; @@ -41,7 +45,9 @@ void IGESData_NodeOfWriterLib::AddNode(const occ::handleAddNode(anode); + } } const occ::handle& IGESData_NodeOfWriterLib::Module() const diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamCursor.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamCursor.cxx index c851d5dd34..4556ec0f8d 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamCursor.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamCursor.cxx @@ -41,10 +41,14 @@ void IGESData_ParamCursor::SetTerm(const int size, const bool autoadv) theoffst += thetsize; thetsize = size; if (autoadv) + { theadv = (theoffst + thetsize == theisize); + } if (theoffst + thetsize > theisize) + { throw Interface_InterfaceError( "IGESDAta ParamCursor : required Term size overpass whole Item size"); + } } void IGESData_ParamCursor::SetOne(const bool autoadv) diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamReader.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamReader.cxx index 695ec18366..fd643a6688 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamReader.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_ParamReader.cxx @@ -97,7 +97,9 @@ IGESData_ReadStage IGESData_ParamReader::Stage() const void IGESData_ParamReader::NextStage() { if (thestage != IGESData_ReadEnd) + { thestage = (IGESData_ReadStage)(((long)thestage) + 1); + } } //================================================================================================= @@ -135,7 +137,9 @@ const char* IGESData_ParamReader::ParamValue(const int num) const bool IGESData_ParamReader::IsParamDefined(const int num) const { if (num >= thenbpar) + { return false; + } return (theparams->Value(num + thebase).ParamType() != Interface_ParamVoid); } @@ -161,7 +165,9 @@ occ::handle IGESData_ParamReader::ParamEntity( { int n = ParamNumber(num); if (n == 0) + { thecheck->AddFail("IGES ParamReader : ParamEntity, bad param"); + } return GetCasted(IGESData_IGESEntity, IR->BoundEntity(n)); } @@ -224,7 +230,9 @@ bool IGESData_ParamReader::PrepareRead(const IGESData_ParamCursor& PC, return false; } if (PC.Advance()) + { SetCurrentNumber(themaxind); // themaxind : prochain index + } thelast = true; return true; } @@ -258,14 +266,20 @@ bool IGESData_ParamReader::PrepareRead(const IGESData_ParamCursor& PC, if (theindex <= 0 || (themaxind - 1) > NbParams()) { if (thenbitem == 1) + { AddFail(mess, " : Parameter number out of range", ""); - // else AddFail (mess," : too many values to read" ,""); + // else AddFail (mess," : too many values to read" ,""); + } else + { AddWarning(mess, " : too many values to read", ""); + } return false; } if (PC.Advance()) + { SetCurrentNumber(themaxind); // themaxind : prochain index + } thelast = true; return true; } @@ -297,7 +311,9 @@ int IGESData_ParamReader::NextRead(const int nb) { int res = theindex; if (theindex >= themaxind) + { res = 0; + } thenbterm += nb; // Per Item: read thetermsz, then next item if (thenbterm >= thetermsz) { @@ -312,9 +328,13 @@ int IGESData_ParamReader::NextRead(const int nb) bool IGESData_ParamReader::DefinedElseSkip() { if (thecurr > NbParams()) + { return false; // Skip en butee + } if (IsParamDefined(thecurr)) - return true; // Defined + { + return true; // Defined + } SetCurrentNumber(thecurr + 1); // Skip return false; } @@ -326,7 +346,9 @@ bool IGESData_ParamReader::DefinedElseSkip() bool IGESData_ParamReader::ReadInteger(const IGESData_ParamCursor& PC, int& val) { if (!PrepareRead(PC, false)) + { return false; + } const Interface_FileParameter& FP = theparams->Value(theindex + thebase); if (FP.ParamType() != Interface_ParamInteger) { @@ -348,7 +370,9 @@ bool IGESData_ParamReader::ReadInteger(const IGESData_ParamCursor& PC, int& val) { if (!PrepareRead(PC, mess, false)) + { return false; + } const Interface_FileParameter& FP = theparams->Value(theindex + thebase); if (FP.ParamType() != Interface_ParamInteger) { @@ -374,7 +398,9 @@ bool IGESData_ParamReader::ReadBoolean(const IGESData_ParamCursor& PC, const bool exact) { if (!PrepareRead(PC, false)) + { return false; + } const Interface_FileParameter& FP = theparams->Value(theindex + thebase); if (FP.ParamType() != Interface_ParamInteger) { @@ -415,7 +441,9 @@ bool IGESData_ParamReader::ReadBoolean(const IGESData_ParamCursor& PC, const bool exact) { if (!PrepareRead(PC, mess, false)) + { return false; + } const Interface_FileParameter& FP = theparams->Value(theindex + thebase); if (FP.ParamType() != Interface_ParamInteger) { @@ -442,7 +470,9 @@ bool IGESData_ParamReader::ReadBoolean(const IGESData_ParamCursor& PC, return false; } else + { AddWarning(mess, ssem, " : Value is not 0/1, but %s"); + } } val = (flag > 0); return true; @@ -455,7 +485,9 @@ bool IGESData_ParamReader::ReadBoolean(const IGESData_ParamCursor& PC, bool IGESData_ParamReader::ReadReal(const IGESData_ParamCursor& PC, double& val) { if (!PrepareRead(PC, false)) + { return false; + } // return ReadingReal (theindex,amsg,val); return ReadingReal(theindex, val); } @@ -467,7 +499,9 @@ bool IGESData_ParamReader::ReadReal(const IGESData_ParamCursor& PC, double& val) { if (!PrepareRead(PC, mess, false)) + { return false; + } return ReadingReal(theindex, mess, val); } @@ -478,11 +512,15 @@ bool IGESData_ParamReader::ReadReal(const IGESData_ParamCursor& PC, bool IGESData_ParamReader::ReadXY(const IGESData_ParamCursor& PC, Message_Msg& /*amsg*/, gp_XY& val) { if (!PrepareRead(PC, false, 2)) + { return false; + } double X, Y = 0.; bool stat = (ReadingReal(theindex, X) && ReadingReal(theindex + 1, Y)); if (stat) + { val.SetCoord(X, Y); + } return stat; } @@ -493,11 +531,15 @@ bool IGESData_ParamReader::ReadXY(const IGESData_ParamCursor& PC, gp_XY& val) { if (!PrepareRead(PC, mess, false, 2)) + { return false; + } double X, Y = 0.; bool stat = (ReadingReal(theindex, mess, X) && ReadingReal(theindex + 1, mess, Y)); if (stat) + { val.SetCoord(X, Y); + } return stat; } @@ -510,12 +552,16 @@ bool IGESData_ParamReader::ReadXYZ(const IGESData_ParamCursor& PC, gp_XYZ& val) { if (!PrepareRead(PC, false, 3)) + { return false; + } double X, Y = 0., Z = 0.; bool stat = (ReadingReal(theindex, X) && ReadingReal(theindex + 1, Y) && ReadingReal(theindex + 2, Z)); if (stat) + { val.SetCoord(X, Y, Z); + } return true; } @@ -526,12 +572,16 @@ bool IGESData_ParamReader::ReadXYZ(const IGESData_ParamCursor& PC, gp_XYZ& val) { if (!PrepareRead(PC, mess, false, 3)) + { return false; + } double X, Y = 0., Z = 0.; bool stat = (ReadingReal(theindex, mess, X) && ReadingReal(theindex + 1, mess, Y) && ReadingReal(theindex + 2, mess, Z)); if (stat) + { val.SetCoord(X, Y, Z); + } return true; } @@ -598,7 +648,9 @@ bool IGESData_ParamReader::ReadText(const IGESData_ParamCursor& PC, occ::handle& val) { if (!PrepareRead(PC, mess, false)) + { return false; + } const Interface_FileParameter& FP = theparams->Value(theindex + thebase); if (FP.ParamType() != Interface_ParamText) { @@ -622,7 +674,9 @@ bool IGESData_ParamReader::ReadText(const IGESData_ParamCursor& PC, { int hol = atoi(tval->SubString(1, lnh - 1)->ToCString()); if (hol != (lnt - lnh)) + { AddWarning(mess, " : bad Hollerith count ", ""); + } } val = new TCollection_HAsciiString(tval->SubString(lnh + 1, lnt)->ToCString()); return true; @@ -640,11 +694,15 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle { aStatus = IGESData_EntityError; if (!PrepareRead(PC, false)) + { return false; + } int nval; // if (!ReadingEntityNumber(theindex,amsg,nval)) return false; if (!ReadingEntityNumber(theindex, nval)) + { return false; + } if (nval == 0) { val.Nullify(); @@ -658,13 +716,19 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle thelast = true; } else + { aStatus = IGESData_EntityOK; + } return canbenul; } else + { val = GetCasted(IGESData_IGESEntity, IR->BoundEntity(nval)); + } if (val.IsNull()) + { return canbenul; + } // Case of "Null IGES" if (val->TypeNumber() == 0) { // Null or not yet filled ... @@ -680,7 +744,9 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle thelast = true; } else + { aStatus = IGESData_EntityOK; + } return canbenul; } } @@ -697,10 +763,14 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle const bool canbenul) { if (!PrepareRead(PC, mess, false)) + { return false; + } int nval; if (!ReadingEntityNumber(theindex, mess, nval)) + { return false; + } if (nval == 0) { val.Nullify(); @@ -712,9 +782,13 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle return canbenul; } else + { val = GetCasted(IGESData_IGESEntity, IR->BoundEntity(nval)); + } if (val.IsNull()) + { return canbenul; + } // Case of "Null IGES" if (val->TypeNumber() == 0) { // Null or not yet filled ... @@ -749,7 +823,9 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle return res; } if (val.IsNull()) + { return res; + } if (!val->IsKind(type)) { aStatus = IGESData_TypeError; @@ -774,9 +850,13 @@ bool IGESData_ParamReader::ReadEntity(const occ::handle { bool res = ReadEntity(IR, PC, mess, val, canbenul); if (!res) + { return res; + } if (val.IsNull()) + { return res; + } if (!val->IsKind(type)) { AddFail(mess, " : Incorrect Type", ""); @@ -797,9 +877,13 @@ bool IGESData_ParamReader::ReadInts(const IGESData_ParamCursor& PC, const int index) { if (!PrepareRead(PC, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1(index, index + thenbitem * thetermsz - 1); int ind = index; @@ -833,9 +917,13 @@ bool IGESData_ParamReader::ReadInts(const IGESData_ParamCursor& PC, const int index) { if (!PrepareRead(PC, mess, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1(index, index + thenbitem * thetermsz - 1); int ind = index; @@ -873,9 +961,13 @@ bool IGESData_ParamReader::ReadReals(const IGESData_ParamCursor& PC, const int index) { if (!PrepareRead(PC, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1(index, index + thenbitem * thetermsz - 1); int ind = index; @@ -883,7 +975,9 @@ bool IGESData_ParamReader::ReadReals(const IGESData_ParamCursor& PC, { double rval; if (!ReadingReal(i, rval)) + { return false; + } val->SetValue(ind, rval); ind++; } @@ -898,9 +992,13 @@ bool IGESData_ParamReader::ReadReals(const IGESData_ParamCursor& P const int index) { if (!PrepareRead(PC, mess, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1(index, index + thenbitem * thetermsz - 1); int ind = index; @@ -908,7 +1006,9 @@ bool IGESData_ParamReader::ReadReals(const IGESData_ParamCursor& P { double rval; if (!ReadingReal(i, mess, rval)) + { return false; + } val->SetValue(ind, rval); ind++; } @@ -926,9 +1026,13 @@ bool IGESData_ParamReader::ReadTexts( const int index) { if (!PrepareRead(PC, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1>(index, index + thenbitem * thetermsz - 1); @@ -962,7 +1066,9 @@ bool IGESData_ParamReader::ReadTexts( { int hol = atoi(tval->SubString(1, lnh - 1)->ToCString()); if (hol != (lnt - lnh)) + { SendWarning(amsg); + } } val->SetValue(ind, new TCollection_HAsciiString(tval->SubString(lnh + 1, lnt)->ToCString())); ind++; @@ -979,9 +1085,13 @@ bool IGESData_ParamReader::ReadTexts( const int index) { if (!PrepareRead(PC, mess, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } val = new NCollection_HArray1>(index, index + thenbitem * thetermsz - 1); @@ -1015,7 +1125,9 @@ bool IGESData_ParamReader::ReadTexts( { int hol = atoi(tval->SubString(1, lnh - 1)->ToCString()); if (hol != (lnt - lnh)) + { AddWarning(mess, " : bad Hollerith count ", ""); + } } val->SetValue(ind, new TCollection_HAsciiString(tval->SubString(lnh + 1, lnt)->ToCString())); ind++; @@ -1035,9 +1147,13 @@ bool IGESData_ParamReader::ReadEnts( const int index) { if (!PrepareRead(PC, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } int indmax = index + thenbitem * thetermsz - 1; val = new NCollection_HArray1>(index, indmax); int ind = index; @@ -1048,14 +1164,20 @@ bool IGESData_ParamReader::ReadEnts( { int nval; if (!ReadingEntityNumber(i, nval)) + { nval = 0; // return false; + } if (nval > 0) { DeclareAndCast(IGESData_IGESEntity, anent, IR->BoundEntity(nval)); if (anent.IsNull()) + { nbnul++; + } else if (IR->DirType(nval).Type() == 0) + { nbnul++; + } else { val->SetValue(ind, anent); @@ -1067,14 +1189,18 @@ bool IGESData_ParamReader::ReadEnts( { } // complete array else if (ind == index) + { val.Nullify(); // empty array + } else { // Gaps: they have been eliminated, but the array needs to be resized occ::handle>> tab = new NCollection_HArray1>(index, ind - 1); for (i = index; i < ind; i++) + { tab->SetValue(i, val->Value(i)); + } val = tab; } if (nbnul > 0) @@ -1094,9 +1220,13 @@ bool IGESData_ParamReader::ReadEnts( const int index) { if (!PrepareRead(PC, mess, true)) + { return false; + } if (thenbitem == 0) + { return true; // vide : retour Null ... + } int indmax = index + thenbitem * thetermsz - 1; val = new NCollection_HArray1>(index, indmax); int ind = index; @@ -1107,16 +1237,24 @@ bool IGESData_ParamReader::ReadEnts( { int nval; if (!ReadingEntityNumber(i, mess, nval)) + { nval = 0; // return false; + } if (nval < 0) + { nbneg++; + } if (nval > 0) { DeclareAndCast(IGESData_IGESEntity, anent, IR->BoundEntity(nval)); if (anent.IsNull()) + { nbnul++; + } else if (IR->DirType(nval).Type() == 0) + { nbnul++; + } else { val->SetValue(ind, anent); @@ -1128,14 +1266,18 @@ bool IGESData_ParamReader::ReadEnts( { } // complete array else if (ind == index) + { val.Nullify(); // empty array + } else { // Gaps: they have been eliminated, but the array needs to be resized occ::handle>> tab = new NCollection_HArray1>(index, ind - 1); for (i = index; i < ind; i++) + { tab->SetValue(i, val->Value(i)); + } val = tab; } // Messages ? @@ -1165,15 +1307,21 @@ bool IGESData_ParamReader::ReadEntList(const occ::handle 0; i = NextRead()) { int nval; if (!ReadingEntityNumber(i, nval)) + { return false; + } if (nval < 0) { Message_Msg Msg219("XSTEP_219"); @@ -1181,7 +1329,9 @@ bool IGESData_ParamReader::ReadEntList(const occ::handleBoundEntity(nval)); if (anent.IsNull()) { @@ -1195,9 +1345,13 @@ bool IGESData_ParamReader::ReadEntList(const occ::handle 0; i = NextRead()) { int nval; if (!ReadingEntityNumber(i, mess, nval)) + { return false; + } if (nval < 0) + { AddWarning(" Negative Pointer, skipped", ""); + } if (nval <= 0) + { continue; + } DeclareAndCast(IGESData_IGESEntity, anent, IR->BoundEntity(nval)); if (anent.IsNull()) + { AddWarning(" Null Pointer, skipped", ""); + } else if (IR->DirType(nval).Type() == 0) + { AddWarning(" Pointer to IGES Null Entity, skipped", ""); + } else if (ord) + { val.Append(anent); + } else + { val.Add(anent); + } } return true; } @@ -1249,7 +1421,9 @@ bool IGESData_ParamReader::ReadingReal(const int num, double& val) if (!pbrealint) { if (testconv < 0) + { testconv = 0; // Interface_Static::IVal("iges.convert.read"); + } if (testconv > 0) { // char ssem[100]; @@ -1268,20 +1442,30 @@ bool IGESData_ParamReader::ReadingReal(const int num, double& val) for (i = 0; i < 50; i++) { if (orig[i] == 'D' || orig[i] == 'd') + { text[j++] = 'e'; + } else + { text[j++] = orig[i]; + } if (orig[i] == '\0') + { break; + } } if (FP.ParamType() == Interface_ParamReal) + { val = Atof(text); + } else if (FP.ParamType() == Interface_ParamEnum) { // convention if (!pbrealform) { if (testconv < 0) + { testconv = 0; // Interface_Static::IVal("iges.convert.read"); + } if (testconv > 0) { // char ssem[100]; @@ -1325,7 +1509,9 @@ bool IGESData_ParamReader::ReadingReal(const int num, const char* const mess, do if (!pbrealint) { if (testconv < 0) + { testconv = 0; // Interface_Static::IVal("iges.convert.read"); + } if (testconv > 0) { char ssem[100]; @@ -1344,20 +1530,30 @@ bool IGESData_ParamReader::ReadingReal(const int num, const char* const mess, do for (i = 0; i < 50; i++) { if (orig[i] == 'D' || orig[i] == 'd') + { text[j++] = 'e'; + } else + { text[j++] = orig[i]; + } if (orig[i] == '\0') + { break; + } } if (FP.ParamType() == Interface_ParamReal) + { val = Atof(text); + } else if (FP.ParamType() == Interface_ParamEnum) { // convention if (!pbrealform) { if (testconv < 0) + { testconv = 0; // Interface_Static::IVal("iges.convert.read"); + } if (testconv > 0) { char ssem[100]; @@ -1400,9 +1596,13 @@ bool IGESData_ParamReader::ReadingEntityNumber(const int num, int& val) { bool nulref = false; if (FP.ParamType() == Interface_ParamInteger) + { nulref = (atoi(FP.CValue()) == 0); + } else if (FP.ParamType() == Interface_ParamVoid) + { nulref = true; + } if (!nulref) { // AddFail (mess," : cannot refer to an Entity",""); @@ -1423,9 +1623,13 @@ bool IGESData_ParamReader::ReadingEntityNumber(const int num, const char* const { bool nulref = false; if (FP.ParamType() == Interface_ParamInteger) + { nulref = (atoi(FP.CValue()) == 0); + } else if (FP.ParamType() == Interface_ParamVoid) + { nulref = true; + } if (!nulref) { AddFail(mess, " : cannot refer to an Entity", ""); @@ -1462,7 +1666,9 @@ void IGESData_ParamReader::AddFail(const char* const { afail->Insert(1, idm); if (bfail != afail) + { bfail->Insert(1, idm); + } thecheck->AddFail(afail, bfail); thelast = false; } @@ -1476,7 +1682,9 @@ void IGESData_ParamReader::AddFail(const char* const idm, occ::handle af = new TCollection_HAsciiString(afail); occ::handle bf = af; if (bfail[0] != '\0') + { bf = new TCollection_HAsciiString(bfail); + } AddFail(idm, af, bf); } @@ -1488,7 +1696,9 @@ void IGESData_ParamReader::AddWarning(const char* const { aw->Insert(1, idm); if (bw != aw) + { bw->Insert(1, idm); + } thecheck->AddWarning(aw, bw); } @@ -1501,7 +1711,9 @@ void IGESData_ParamReader::AddWarning(const char* const idm, occ::handle aw = new TCollection_HAsciiString(awarn); occ::handle bw = aw; if (bwarn[0] != '\0') + { bw = new TCollection_HAsciiString(bwarn); + } AddWarning(idm, aw, bw); } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_Protocol.cxx index dceaedcee5..308b226e36 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_Protocol.cxx @@ -40,7 +40,9 @@ occ::handle IGESData_Protocol::Resource(const int /*num*/) c int IGESData_Protocol::TypeNumber(const occ::handle& atype) const { if (atype->SubType(STANDARD_TYPE(IGESData_UndefinedEntity))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_ToolLocation.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_ToolLocation.cxx index 1774d56c26..d77798589a 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_ToolLocation.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_ToolLocation.cxx @@ -56,7 +56,9 @@ void IGESData_ToolLocation::Load() { occ::handle ent = themodel->Entity(i); if (ent->IsKind(STANDARD_TYPE(IGESData_TransfEntity))) + { continue; + } // Case of SingleParentEntity if (ent->IsKind(STANDARD_TYPE(IGESData_SingleParentEntity))) { @@ -64,11 +66,15 @@ void IGESData_ToolLocation::Load() int nbc = assoc->NbChildren(); occ::handle parent = assoc->SingleParent(); for (int j = 1; j <= nbc; j++) + { SetParentAssoc(parent, assoc->Child(j)); + } continue; } if (ent->TypeNumber() == TYPEFORASSOC) + { continue; // Assoc except SingleParent + } // Current case SetOwnAsDependent(ent); // which operates } @@ -85,9 +91,13 @@ void IGESData_ToolLocation::SetReference(const occ::handle& int np = themodel->Number(parent); int nc = themodel->Number(child); if (np == 0 || nc == 0) + { return; + } if (therefs(nc) > 0) + { np = -1; // note ambigu + } therefs.SetValue(nc, np); } @@ -97,9 +107,13 @@ void IGESData_ToolLocation::SetParentAssoc(const occ::handleNumber(parent); int nc = themodel->Number(child); if (np == 0 || nc == 0) + { return; + } if (theassocs(nc) > 0) + { np = -1; // note ambigu + } theassocs.SetValue(nc, np); } @@ -107,7 +121,9 @@ void IGESData_ToolLocation::ResetDependences(const occ::handleNumber(child); if (nc == 0) + { return; + } therefs.SetValue(nc, 0); theassocs.SetValue(nc, 0); } @@ -117,7 +133,9 @@ void IGESData_ToolLocation::SetOwnAsDependent(const occ::handle gmodule; if (!thelib.Select(ent, gmodule, CN)) + { return; + } occ::handle module = occ::down_cast(gmodule); Interface_EntityIterator list; module->OwnSharedCase(CN, ent, list); @@ -125,7 +143,9 @@ void IGESData_ToolLocation::SetOwnAsDependent(const occ::handle& { int num = themodel->Number(ent); if (num == 0) + { return false; + } if (therefs(num) < 0 || theassocs(num) < 0) + { return true; + } if (therefs(num) != 0 && theassocs(num) != 0) + { return true; + } return false; } @@ -167,13 +193,21 @@ bool IGESData_ToolLocation::HasParent(const occ::handle& en { int num = themodel->Number(ent); if (num == 0) + { return false; + } if (therefs(num) < 0 || theassocs(num) < 0) + { throw Standard_DomainError("IGESData_ToolLocation : HasParent"); + } if (therefs(num) != 0 && theassocs(num) != 0) + { throw Standard_DomainError("IGESData_ToolLocation : HasParent"); + } if (therefs(num) != 0 || theassocs(num) != 0) + { return true; + } return false; } @@ -183,15 +217,25 @@ occ::handle IGESData_ToolLocation::Parent( occ::handle parent; int num = themodel->Number(ent); if (num == 0) + { return parent; + } if (therefs(num) < 0 || theassocs(num) < 0) + { throw Standard_DomainError("IGESData_ToolLocation : Parent"); + } if (therefs(num) != 0 && theassocs(num) != 0) + { throw Standard_DomainError("IGESData_ToolLocation : Parent"); + } if (therefs(num) != 0) + { parent = themodel->Entity(therefs(num)); + } if (theassocs(num) != 0) + { parent = themodel->Entity(theassocs(num)); + } return parent; } @@ -200,13 +244,21 @@ bool IGESData_ToolLocation::HasParentByAssociativity( { int num = themodel->Number(ent); if (num == 0) + { return false; + } if (therefs(num) < 0 || theassocs(num) < 0) + { throw Standard_DomainError("IGESData_ToolLocation : HasParentByAssociativity"); + } if (therefs(num) != 0 && theassocs(num) != 0) + { throw Standard_DomainError("IGESData_ToolLocation : HasParentByAssociativity"); + } if (theassocs(num) != 0) + { return true; + } return false; } @@ -216,7 +268,9 @@ gp_GTrsf IGESData_ToolLocation::ParentLocation(const occ::handle parent = Parent(ent); // Definition recursive if (!parent.IsNull()) + { locat = EffectiveLocation(parent); + } return locat; } @@ -239,7 +293,9 @@ bool IGESData_ToolLocation::ConvertLocation(const double prec, const double unit) { if (result.Form() != gp_Identity) + { result = gp_Trsf(); // Identity forced at start + } // We take the content of . Be careful with addressing gp_XYZ v1(loc.Value(1, 1), loc.Value(1, 2), loc.Value(1, 3)); gp_XYZ v2(loc.Value(2, 1), loc.Value(2, 2), loc.Value(2, 3)); @@ -250,25 +306,37 @@ bool IGESData_ToolLocation::ConvertLocation(const double prec, double m3 = v3.Modulus(); // First is this matrix singular ? if (m1 < prec || m2 < prec || m3 < prec) + { return false; + } double mm = (m1 + m2 + m3) / 3.; // here is the average Norm, see Scale if (std::abs(m1 - mm) > prec * mm || std::abs(m2 - mm) > prec * mm || std::abs(m3 - mm) > prec * mm) + { return false; + } v1.Divide(m1); v2.Divide(m2); v3.Divide(m3); if (std::abs(v1.Dot(v2)) > prec || std::abs(v2.Dot(v3)) > prec || std::abs(v3.Dot(v1)) > prec) + { return false; + } // Here, Orthogonal and same norms. Plus we normalized it // Remain the other characteristics : if (std::abs(mm - 1.) > prec) + { result.SetScale(gp_Pnt(0, 0, 0), mm); + } gp_XYZ tp = loc.TranslationPart(); if (unit != 1.) + { tp.Multiply(unit); + } if (tp.X() != 0. || tp.Y() != 0. || tp.Z() != 0.) + { result.SetTranslationPart(tp); + } // We isolate the case of Identity (so easy and advantageous) if (v1.X() != 1. || v1.Y() != 0. || v1.Z() != 0. || v2.X() != 0. || v2.Y() != 1. || v2.Z() != 0. || v3.X() != 0. || v3.Y() != 0. || v3.Z() != 1.) @@ -280,7 +348,9 @@ bool IGESData_ToolLocation::ConvertLocation(const double prec, gp_Ax3 axes(gp_Pnt(0, 0, 0), d3, d1); d3.Cross(d1); if (d3.Dot(d2) < 0) + { axes.YReverse(); + } gp_Trsf transf; transf.SetTransformation(axes); result *= transf; // szv#9:PRO19565:04Oct99 diff --git a/src/DataExchange/TKDEIGES/IGESData/IGESData_UndefinedEntity.cxx b/src/DataExchange/TKDEIGES/IGESData/IGESData_UndefinedEntity.cxx index 4ab70cf2a5..b737837eab 100644 --- a/src/DataExchange/TKDEIGES/IGESData/IGESData_UndefinedEntity.cxx +++ b/src/DataExchange/TKDEIGES/IGESData/IGESData_UndefinedEntity.cxx @@ -88,11 +88,17 @@ IGESData_DefType IGESData_UndefinedEntity::DefLineFont() const { int st = ((thedstat / 4) & 3); if (st == 0) + { return IGESData_IGESEntity::DefLineFont(); + } else if (st == 1) + { return IGESData_ErrorVal; + } else + { return IGESData_ErrorRef; + } } //================================================================================================= @@ -101,11 +107,17 @@ IGESData_DefList IGESData_UndefinedEntity::DefLevel() const { int st = ((thedstat / 16) & 3); if (st == 0) + { return IGESData_IGESEntity::DefLevel(); + } else if (st == 1) + { return IGESData_ErrorOne; + } else + { return IGESData_ErrorSeveral; + } } //================================================================================================= @@ -114,11 +126,17 @@ IGESData_DefList IGESData_UndefinedEntity::DefView() const { int st = ((thedstat / 64) & 3); if (st == 0) + { return IGESData_IGESEntity::DefView(); + } else if (st == 1) + { return IGESData_ErrorOne; + } else + { return IGESData_ErrorSeveral; + } } //================================================================================================= @@ -127,11 +145,17 @@ IGESData_DefType IGESData_UndefinedEntity::DefColor() const { int st = ((thedstat / 256) & 3); if (st == 0) + { return IGESData_IGESEntity::DefColor(); + } else if (st == 1) + { return IGESData_ErrorVal; + } else + { return IGESData_ErrorRef; + } } //================================================================================================= @@ -140,9 +164,13 @@ bool IGESData_UndefinedEntity::HasSubScriptNumber() const { int st = ((thedstat / 1024) & 1); if (st == 0) + { return IGESData_IGESEntity::HasSubScriptNumber(); + } else + { return false; + } } // ReadDir verifies the data, if there are errors notes them (status), @@ -196,12 +224,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handleBoundEntity((1 - v[3]) / 2)); if (!anent->IsKind(STANDARD_TYPE(IGESData_LineFontEntity))) + { iapb = true; + } } // Sending of message : Line Font Pattern field is incorrect. if (iapb) @@ -214,12 +246,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handleBoundEntity((1 - v[4]) / 2)); if (!anent->IsKind(STANDARD_TYPE(IGESData_LevelListEntity))) + { iapb = true; + } } // Sending of message : Level field is incorrect. @@ -233,12 +269,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handle max) + { iapb = true; + } else if (v[5] > 0) { anent = GetCasted(IGESData_IGESEntity, IR->BoundEntity((1 + v[5]) / 2)); if (!anent->IsKind(STANDARD_TYPE(IGESData_ViewKindEntity))) + { iapb = true; + } } // Sending of message : View field is incorrect. @@ -252,12 +292,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handle max) + { iapb = true; + } else if (v[6] > 0) { anent = GetCasted(IGESData_IGESEntity, IR->BoundEntity((1 + v[6]) / 2)); if (!anent->IsKind(STANDARD_TYPE(IGESData_TransfEntity))) + { iapb = true; + } } // Sending of message : Transformation Matrix field is incorrect @@ -271,12 +315,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handle max) + { iapb = true; + } else if (v[7] > 0) { anent = GetCasted(IGESData_IGESEntity, IR->BoundEntity((1 + v[7]) / 2)); if (!anent->IsKind(STANDARD_TYPE(IGESData_LabelDisplayEntity))) + { iapb = true; + } } // Sending of message : Label Display Entity field is incorrect. @@ -290,7 +338,9 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handle max) + { iapb = true; + } else if (v[14] < 0) { anent = GetCasted(IGESData_IGESEntity, IR->BoundEntity((1 - v[14]) / 2)); @@ -315,9 +365,13 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handle 57)) + { iapb = true; + } } // Sending of message : Entity Subscript Number field is incorrect. @@ -327,12 +381,16 @@ bool IGESData_UndefinedEntity::ReadDir(const occ::handleSendFail(Msg72); thedstat += 1024; for (i = 0; i < 8; i++) + { subs[i] = ' '; + } } // ... End of this analysis : if necessary we rebuild DP ... if (thedstat == 0) + { return true; + } else { DP.Init(v[0], @@ -393,13 +451,17 @@ void IGESData_UndefinedEntity::WriteOwnParams(IGESData_IGESWriter& IW) const { Interface_ParamType ptyp = thecont->ParamType(i); if (ptyp == Interface_ParamVoid) + { IW.SendVoid(); + } else if (thecont->IsParamEntity(i)) { DeclareAndCast(IGESData_IGESEntity, anent, thecont->ParamEntity(i)); IW.Send(anent); } else + { IW.SendString(thecont->ParamValue(i)); + } } } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AssociativityDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AssociativityDef.cxx index 8ba95a5e8c..e8b424cce6 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AssociativityDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AssociativityDef.cxx @@ -34,7 +34,9 @@ void IGESDefs_AssociativityDef::Init(const occ::handle> if (requirements->Lower() != 1 || (orders->Lower() != 1 || orders->Length() != len) || (numItems->Lower() != 1 || numItems->Length() != len) || (items->Lower() != 1 || items->Length() != len)) + { throw Standard_DimensionMismatch("IGESDefs_AssociativityDef : Init"); + } theBackPointerReqs = requirements; theClassOrders = orders; diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeDef.cxx index d59465ecdb..fde3b25d38 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeDef.cxx @@ -48,15 +48,25 @@ void IGESDefs_AttributeDef::Init( if (attrTypes->Lower() != 1 || attrValueDataTypes->Lower() != 1 || attrValueDataTypes->Length() != nb || attrValueCounts->Lower() != 1 || attrValueCounts->Length() != nb) + { throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init"); + } if (FormNumber() >= 1) + { if (attrValues->Lower() != 1 || attrValues->Length() != nb) + { throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init"); + } + } if (FormNumber() == 2) + { if (attrValuePointers->Lower() != 1 || attrValuePointers->Length() != nb) + { throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init"); + } + } // Form 1 : attrValues defined Form = 2 : attrValuePointers defined theName = aName; @@ -67,11 +77,17 @@ void IGESDefs_AttributeDef::Init( theAttrValues = attrValues; theAttrValuePointers = attrValuePointers; if (attrValues.IsNull()) + { InitTypeAndForm(322, 0); + } else if (attrValuePointers.IsNull()) + { InitTypeAndForm(322, 1); + } else + { InitTypeAndForm(322, 2); + } } bool IGESDefs_AttributeDef::HasTableName() const @@ -125,7 +141,9 @@ occ::handle IGESDefs_AttributeDef::AttributeTextD { occ::handle res; if (HasTextDisplay()) + { res = theAttrValuePointers->Value(AttrNum)->Value(PointerNum); + } return res; } @@ -133,7 +151,9 @@ occ::handle IGESDefs_AttributeDef::AttributeList(const int A { occ::handle nulres; if (!HasValues()) + { return nulres; + } return theAttrValues->Value(AttrNum); } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeTable.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeTable.cxx index c27a300cd8..95aeecccb7 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeTable.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_AttributeTable.cxx @@ -39,14 +39,20 @@ void IGESDefs_AttributeTable::Init( const occ::handle>>& attributes) { if (attributes->LowerCol() != 1 || attributes->LowerRow() != 1) + { throw Standard_DimensionMismatch("IGESDefs_AttributeTable : Init"); + } theAttributes = attributes; int fn = FormNumber(); if (attributes->UpperCol() > 1) + { fn = 1; + } else if (fn < 0 || fn > 1) + { fn = 0; + } InitTypeAndForm(422, fn); // FormNumber : 0 SingleRow, 1 MultipleRows (can be reduced to one ...) } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GeneralModule.cxx index 08c90861ed..effa2c825d 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GeneralModule.cxx @@ -52,7 +52,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAssociativityDef tool; tool.OwnShared(anent, iter); } @@ -60,7 +62,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeDef tool; tool.OwnShared(anent, iter); } @@ -68,7 +72,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeTable tool; tool.OwnShared(anent, iter); } @@ -76,7 +82,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolGenericData tool; tool.OwnShared(anent, iter); } @@ -84,7 +92,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolMacroDef tool; tool.OwnShared(anent, iter); } @@ -92,7 +102,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolTabularData tool; tool.OwnShared(anent, iter); } @@ -100,7 +112,9 @@ void IGESDefs_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolUnitsData tool; tool.OwnShared(anent, iter); } @@ -119,49 +133,63 @@ IGESData_DirChecker IGESDefs_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolAssociativityDef tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolAttributeDef tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolAttributeTable tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolGenericData tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolMacroDef tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolTabularData tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { break; + } IGESDefs_ToolUnitsData tool; return tool.DirChecker(anent); } @@ -181,7 +209,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAssociativityDef tool; tool.OwnCheck(anent, shares, ach); } @@ -189,7 +219,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeDef tool; tool.OwnCheck(anent, shares, ach); } @@ -197,7 +229,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeTable tool; tool.OwnCheck(anent, shares, ach); } @@ -205,7 +239,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolGenericData tool; tool.OwnCheck(anent, shares, ach); } @@ -213,7 +249,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolMacroDef tool; tool.OwnCheck(anent, shares, ach); } @@ -221,7 +259,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolTabularData tool; tool.OwnCheck(anent, shares, ach); } @@ -229,7 +269,9 @@ void IGESDefs_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolUnitsData tool; tool.OwnCheck(anent, shares, ach); } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GenericData.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GenericData.cxx index b1881f77f7..dcd54427c2 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GenericData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_GenericData.cxx @@ -42,7 +42,9 @@ void IGESDefs_GenericData::Init( if (!allTypes.IsNull() && !allValues.IsNull() && (allValues->Lower() != 1 || allTypes->Lower() != 1 || allTypes->Length() != allValues->Length())) + { throw Standard_DimensionMismatch("IGESDefs_GenericData: Init"); + } theNbPropertyValues = nbPropVal; theName = aName; theTypes = allTypes; diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_MacroDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_MacroDef.cxx index c289afad0e..81f36b633e 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_MacroDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_MacroDef.cxx @@ -32,7 +32,9 @@ void IGESDefs_MacroDef::Init( const occ::handle& endMacro) { if (langStatements->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDefs_MacroDef : Init"); + } theMACRO = macro; theEntityTypeID = entityTypeID; theLangStatements = langStatements; diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_Protocol.cxx index e8b2ace2dd..e52045cd4f 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_Protocol.cxx @@ -43,18 +43,32 @@ occ::handle IGESDefs_Protocol::Resource(const int /*num*/) c int IGESDefs_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESDefs_AssociativityDef)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESDefs_AttributeDef)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESDefs_AttributeTable)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESDefs_GenericData)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESDefs_MacroDef)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESDefs_TabularData)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESDefs_UnitsData)) + { return 7; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ReadWriteModule.cxx index 4ecb30ae0e..158ac01c94 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ReadWriteModule.cxx @@ -80,7 +80,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAssociativityDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -88,7 +90,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -96,7 +100,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeTable tool; tool.ReadOwnParams(anent, IR, PR); } @@ -104,7 +110,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolGenericData tool; tool.ReadOwnParams(anent, IR, PR); } @@ -112,7 +120,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolMacroDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -120,7 +130,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolTabularData tool; tool.ReadOwnParams(anent, IR, PR); } @@ -128,7 +140,9 @@ void IGESDefs_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolUnitsData tool; tool.ReadOwnParams(anent, IR, PR); } @@ -147,7 +161,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAssociativityDef tool; tool.WriteOwnParams(anent, IW); } @@ -155,7 +171,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeDef tool; tool.WriteOwnParams(anent, IW); } @@ -163,7 +181,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeTable tool; tool.WriteOwnParams(anent, IW); } @@ -171,7 +191,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolGenericData tool; tool.WriteOwnParams(anent, IW); } @@ -179,7 +201,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolMacroDef tool; tool.WriteOwnParams(anent, IW); } @@ -187,7 +211,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolTabularData tool; tool.WriteOwnParams(anent, IW); } @@ -195,7 +221,9 @@ void IGESDefs_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolUnitsData tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_SpecificModule.cxx index 74fe36099b..f5a47ca2f4 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_SpecificModule.cxx @@ -48,7 +48,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 1: { DeclareAndCast(IGESDefs_AssociativityDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAssociativityDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -56,7 +58,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 2: { DeclareAndCast(IGESDefs_AttributeDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -64,7 +68,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 3: { DeclareAndCast(IGESDefs_AttributeTable, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolAttributeTable tool; tool.OwnDump(anent, dumper, S, own); } @@ -72,7 +78,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 4: { DeclareAndCast(IGESDefs_GenericData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolGenericData tool; tool.OwnDump(anent, dumper, S, own); } @@ -80,7 +88,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 5: { DeclareAndCast(IGESDefs_MacroDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolMacroDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -88,7 +98,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 6: { DeclareAndCast(IGESDefs_TabularData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolTabularData tool; tool.OwnDump(anent, dumper, S, own); } @@ -96,7 +108,9 @@ void IGESDefs_SpecificModule::OwnDump(const int CN case 7: { DeclareAndCast(IGESDefs_UnitsData, anent, ent); if (anent.IsNull()) + { return; + } IGESDefs_ToolUnitsData tool; tool.OwnDump(anent, dumper, S, own); } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_TabularData.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_TabularData.cxx index 86364e142e..af4199e521 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_TabularData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_TabularData.cxx @@ -41,7 +41,9 @@ void IGESDefs_TabularData::Init(const int nbProps, int num = typesInd->Length(); if (typesInd->Lower() != 1 || nbValuesInd->Lower() != 1 || nbValuesInd->Length() != num || valuesInd->Lower() != 1 || valuesInd->Length() != num || valuesDep->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDefs_TabularData : Init"); + } theNbPropertyValues = nbProps; thePropertyType = propType; /* theNbDependents = nbDeps; */ @@ -67,7 +69,9 @@ bool IGESDefs_TabularData::OwnCorrect() { int newnb = ComputedNbPropertyValues(); if (newnb == theNbPropertyValues) + { return false; + } theNbPropertyValues = newnb; return true; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAssociativityDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAssociativityDef.cxx index de3fa909ca..aad14fb1af 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAssociativityDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAssociativityDef.cxx @@ -58,9 +58,12 @@ void IGESDefs_ToolAssociativityDef::ReadOwnParams( items = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval); } else + { PR.AddFail("No. of Class definitions: Not Positive"); + } if (!requirements.IsNull()) + { for (int i = 1; i <= nbval; i++) { int requirement; @@ -71,12 +74,16 @@ void IGESDefs_ToolAssociativityDef::ReadOwnParams( // st = PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement)) + { requirements->SetValue(i, requirement); + } // st = PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order)) + { orders->SetValue(i, order); + } // st = PR.ReadInteger(PR.Current(),"No. of items per entry", numItem); //szv#4:S4163:12Mar99 // moved in if @@ -90,11 +97,14 @@ void IGESDefs_ToolAssociativityDef::ReadOwnParams( // int temp; //szv#4:S4163:12Mar99 moved out of for // st = PR.ReadInteger(PR.Current(), "Item", temp); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Item", temp)) + { item->SetValue(j, temp); + } } items->SetValue(i, item); } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(requirements, orders, numItems, items); @@ -113,7 +123,9 @@ void IGESDefs_ToolAssociativityDef::WriteOwnParams( IW.Send(ent->NbItemsPerClass(i)); int items = ent->NbItemsPerClass(i); for (int j = 1; j <= items; j++) + { IW.Send(ent->Item(i, j)); + } } } @@ -196,7 +208,7 @@ void IGESDefs_ToolAssociativityDef::OwnDump(const occ::handleNbClassDefs(), ent->BackPointerReq); - S << std::endl; + S << '\n'; if (level > 4) { // Warning : Item is a JAGGED Array @@ -206,14 +218,22 @@ void IGESDefs_ToolAssociativityDef::OwnDump(const occ::handleBackPointerReq(i) << " "; if (ent->IsBackPointerReq(i)) + { S << "(Yes) "; + } else + { S << "(No) "; + } S << " Ordered/Unordered Class : " << ent->ClassOrder(i) << " "; if (ent->IsOrdered(i)) + { S << "(Yes)\n"; + } else + { S << "(No)\n"; + } S << "Number Of Items per Entry : " << ent->NbItemsPerClass(i); if (level < 6) { @@ -222,9 +242,11 @@ void IGESDefs_ToolAssociativityDef::OwnDump(const occ::handleNbItemsPerClass(i); j++) + { S << " " << ent->Item(i, j); + } S << "]\n"; } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeDef.cxx index 7e71922492..a3e5cc5514 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeDef.cxx @@ -58,8 +58,10 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleFormNumber(); if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadText(PR.Current(), "Attribute Table Name", aName); //szv#4:S4163:12Mar99 `st=` not needed +} PR.ReadInteger(PR.Current(), "Attribute List Type", aListType); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on @@ -71,14 +73,21 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handle(1, nbval); attrValueCounts = new NCollection_HArray1(1, nbval); if (fn > 0) + { attrValues = new NCollection_HArray1>(1, nbval); + } if (fn > 1) + { attrValuePointers = new IGESDefs_HArray1OfHArray1OfTextDisplayTemplate(1, nbval); + } } else + { PR.AddFail("Number of Attributes: Not Positive"); + } if (!attrTypes.IsNull()) + { for (int i = 1; i <= nbval; i++) { int attrType; @@ -90,26 +99,37 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(i, attrType); + } st = PR.ReadInteger(PR.Current(), "Attribute Data Type", attrValueDataType); if (st) + { attrValueDataTypes->SetValue(i, attrValueDataType); + } if (PR.DefinedElseSkip()) + { st = PR.ReadInteger(PR.Current(), "Attribute Value Count", avc); + } else + { avc = 1; + } if (st) { attrValueCounts->SetValue(i, avc); if (fn > 1) + { attrValuePointer = new NCollection_HArray1>(1, avc); + } } if (!attrValues.IsNull()) + { if (fn > 0) { occ::handle> attrInt; @@ -155,7 +175,9 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, temp); + } } break; case 2: { @@ -163,7 +185,9 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, temp); + } } break; case 3: { @@ -171,7 +195,9 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, temp); + } } break; case 4: { @@ -179,7 +205,9 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, temp); + } } break; case 5: @@ -190,7 +218,9 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, (temp ? 1 : 0)); + } } break; } @@ -205,13 +235,19 @@ void IGESDefs_ToolAttributeDef::ReadOwnParams(const occ::handleSetValue(j, tempText); + } } } if (fn == 2) + { attrValuePointers->SetValue(i, attrValuePointer); + } } + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(aName, @@ -227,9 +263,13 @@ void IGESDefs_ToolAttributeDef::WriteOwnParams(const occ::handleHasTableName()) + { IW.Send(ent->TableName()); + } else + { IW.SendVoid(); + } IW.Send(ent->ListType()); int upper = ent->NbAttributes(); IW.Send(upper); @@ -272,7 +312,9 @@ void IGESDefs_ToolAttributeDef::WriteOwnParams(const occ::handleFormNumber() == 2) + { IW.Send(ent->AttributeTextDisplay(i, j)); + } } } } @@ -291,9 +333,13 @@ void IGESDefs_ToolAttributeDef::OwnShared(const occ::handleAttributeAsEntity(i, j)); + } if (ent->FormNumber() == 2) + { iter.GetOneItem(ent->AttributeTextDisplay(i, j)); + } } } } @@ -305,7 +351,9 @@ void IGESDefs_ToolAttributeDef::OwnCopy(const occ::handle { occ::handle aName; if (!another->TableName().IsNull()) + { aName = new TCollection_HAsciiString(another->TableName()); + } int aListType = another->ListType(); occ::handle> attrTypes; @@ -319,9 +367,13 @@ void IGESDefs_ToolAttributeDef::OwnCopy(const occ::handle attrValueDataTypes = new NCollection_HArray1(1, nbval); attrValueCounts = new NCollection_HArray1(1, nbval); if (another->HasValues()) + { attrValues = new NCollection_HArray1>(1, nbval); + } if (another->HasTextDisplay()) + { attrValuePointers = new IGESDefs_HArray1OfHArray1OfTextDisplayTemplate(1, nbval); + } for (int i = 1; i <= nbval; i++) { @@ -334,8 +386,10 @@ void IGESDefs_ToolAttributeDef::OwnCopy(const occ::handle occ::handle>> attrValuePointer; if (another->HasTextDisplay()) + { attrValuePointer = new NCollection_HArray1>(1, avc); + } if (another->HasValues()) { @@ -407,7 +461,9 @@ void IGESDefs_ToolAttributeDef::OwnCopy(const occ::handle } } if (another->HasTextDisplay()) + { attrValuePointers->SetValue(i, attrValuePointer); + } } } ent->Init(aName, @@ -455,18 +511,24 @@ void IGESDefs_ToolAttributeDef::OwnCheck(const occ::handleAddFail(mess); } if (ent->AttributeValueCount(i) <= 0) + { continue; + } occ::handle list = ent->AttributeList(i); if (fn > 0 && ent.IsNull()) { if (aty == 0 || aty == 5) + { continue; + } Sprintf(mess, "Form Number > 0 and Attribute Value List n0.%d undefined", aty); ach->AddFail(mess); continue; } else if (fn == 0) + { continue; + } mess[0] = '\0'; switch (aty) { @@ -505,7 +567,9 @@ void IGESDefs_ToolAttributeDef::OwnCheck(const occ::handleAddFail(mess); + } } } @@ -526,9 +590,13 @@ void IGESDefs_ToolAttributeDef::OwnDump(const occ::handle << "Attribute Value Data Types :\n" << "Attribute Value Counts :\n"; if (ent->HasValues()) + { S << "Attribute Values :\n"; + } if (ent->HasTextDisplay()) + { S << "Attribute Value Entities :\n"; + } IGESData_DumpVals(S, -level, 1, ent->NbAttributes(), ent->AttributeType); S << "\n"; if (level > 4) @@ -609,10 +677,10 @@ void IGESDefs_ToolAttributeDef::OwnDump(const occ::handle S << " Attribute Value Pointer : "; dumper.Dump(ent->AttributeTextDisplay(i, j), S, sublevel); } - S << std::endl; + S << '\n'; } } } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeTable.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeTable.cxx index c1a1462de1..724b74305c 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeTable.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolAttributeTable.cxx @@ -59,9 +59,13 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleNbAttributes(); if (ent->FormNumber() == 1) + { st = PR.ReadInteger(PR.Current(), "No. of rows", nr); + } if (st) + { list2 = new NCollection_HArray2>(1, na, 1, nr); + } // AttributeDef repeated once (Form 0) or times (Form 1) for (int k = 1; k <= nr; k++) @@ -74,7 +78,9 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handle> attrInt = new NCollection_HArray1(1, avc); @@ -84,7 +90,9 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleSetValue(j, item); + } } } break; @@ -97,7 +105,9 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleSetValue(j, item); + } } } break; @@ -110,7 +120,9 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleSetValue(j, item); + } } } break; @@ -123,13 +135,17 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleSetValue(j, item); + } } } break; case 5: for (j = 1; j <= avc; j++) + { PR.SetCurrentNumber(PR.CurrentNumber() + 1); // skip + } break; case 6: { // Here item takes value 0 or 1 occ::handle> attrInt = new NCollection_HArray1(1, avc); @@ -139,7 +155,9 @@ void IGESDefs_ToolAttributeTable::ReadOwnParams(const occ::handleSetValue(j, item); + } } } break; @@ -160,7 +178,9 @@ void IGESDefs_ToolAttributeTable::WriteOwnParams(const occ::handleNbRows(); int na = ent->NbAttributes(); if (ent->FormNumber() == 1) + { IW.Send(nr); + } for (int k = 1; k <= nr; k++) { for (int i = 1; i <= na; i++) @@ -210,10 +230,14 @@ void IGESDefs_ToolAttributeTable::OwnShared(const occ::handleAttributeValueDataType(i) != 4) + { continue; + } int avc = ab->AttributeValueCount(i); for (int j = 1; j <= avc; j++) + { iter.GetOneItem(ent->AttributeAsEntity(i, k, j)); + } } } } @@ -243,7 +267,9 @@ void IGESDefs_ToolAttributeTable::OwnCopy(const occ::handle> attrInt = new NCollection_HArray1(1, avc); list2->SetValue(i, k, attrInt); for (j = 1; j <= avc; j++) + { attrInt->SetValue(j, otherInt->Value(j)); + } } break; case 2: { @@ -252,7 +278,9 @@ void IGESDefs_ToolAttributeTable::OwnCopy(const occ::handle(1, avc); list2->SetValue(i, k, attrReal); for (j = 1; j <= avc; j++) + { attrReal->SetValue(j, otherReal->Value(j)); + } } break; case 3: { @@ -263,7 +291,9 @@ void IGESDefs_ToolAttributeTable::OwnCopy(const occ::handle>(1, avc); list2->SetValue(i, k, attrStr); for (j = 1; j <= avc; j++) + { attrStr->SetValue(j, new TCollection_HAsciiString(otherStr->Value(j))); + } } break; case 4: { @@ -274,8 +304,10 @@ void IGESDefs_ToolAttributeTable::OwnCopy(const occ::handle>(1, avc); list2->SetValue(i, k, attrEnt); for (j = 1; j <= avc; j++) + { attrEnt->SetValue(j, GetCasted(IGESData_IGESEntity, TC.Transferred(otherEnt->Value(j)))); + } } break; case 5: ///// list2->SetValue(i,k,NULL); by default @@ -285,7 +317,9 @@ void IGESDefs_ToolAttributeTable::OwnCopy(const occ::handle> attrInt = new NCollection_HArray1(1, avc); list2->SetValue(i, k, attrInt); for (j = 1; j <= avc; j++) + { attrInt->SetValue(j, otherInt->Value(j)); + } } break; default: @@ -314,14 +348,22 @@ void IGESDefs_ToolAttributeTable::OwnCheck(const occ::handleDefinition().IsNull()) { if (ent->HasStructure()) + { ach->AddFail("Structure in Directory Entry is not an Attribute Definition Table"); + } else + { ach->AddFail("No Attribute Definition defined"); + } } if (ent->FormNumber() == 0 && ent->NbRows() != 1) + { ach->AddFail("Form 0 with several Rows"); + } if (ent->NbAttributes() != ent->Definition()->NbAttributes()) + { ach->AddFail("Mismatch between Definition (Structure) and Content"); + } } void IGESDefs_ToolAttributeTable::OwnDump(const occ::handle& ent, @@ -336,13 +378,20 @@ void IGESDefs_ToolAttributeTable::OwnDump(const occ::handleNbAttributes(); int nr = ent->NbRows(); if (ent->FormNumber() == 1) + { S << "Number of Rows (i.e. complete sets of Attributes) : " << nr << "\n"; + } else + { S << "One set of Attributes\n"; + } S << "Number of defined Attributes : " << na << "\n"; if (level <= 4) + { S << " [ structure : see Structure in Directory Entry; content : level > 4 ]\n"; + } else + { for (int k = 1; k <= nr; k++) { for (int i = 1; i <= na; i++) @@ -403,5 +452,6 @@ void IGESDefs_ToolAttributeTable::OwnDump(const occ::handle>(1, num); } else + { PR.AddFail("Number of TYPE/VALUEs: Not Positive"); + } if (!tempTypes.IsNull() && !tempValues.IsNull()) + { for (i = 1; i <= num; i++) { int tempTyp; @@ -81,7 +84,9 @@ void IGESDefs_ToolGenericData::ReadOwnParams(const occ::handleSetValue(i, tempObj); + } } break; case 2: // Real @@ -90,7 +95,9 @@ void IGESDefs_ToolGenericData::ReadOwnParams(const occ::handleSetValue(i, tempObj); + } } break; case 3: // Character string @@ -99,7 +106,9 @@ void IGESDefs_ToolGenericData::ReadOwnParams(const occ::handleSetValue(i, tempObj); + } } break; case 4: // Pointer @@ -108,7 +117,9 @@ void IGESDefs_ToolGenericData::ReadOwnParams(const occ::handleSetValue(i, tempEntity); + } } break; case 5: // Not used @@ -129,6 +140,7 @@ void IGESDefs_ToolGenericData::ReadOwnParams(const occ::handleInit(tempNbPropVal, tempName, tempTypes, tempValues); @@ -180,7 +192,9 @@ void IGESDefs_ToolGenericData::OwnShared(const occ::handle for (num = ent->NbTypeValuePairs(), i = 1; i <= num; i++) { if (ent->Type(i) == 4) + { iter.GetOneItem(ent->ValueAsEntity(i)); + } } } @@ -262,7 +276,9 @@ void IGESDefs_ToolGenericData::OwnCheck(const occ::handle& occ::handle& ach) const { if (ent->NbPropertyValues() != ent->NbTypeValuePairs() * 2 + 2) + { ach->AddFail("Nb. of Property Values not consistent with Nb. of Type/value Pairs"); + } } void IGESDefs_ToolGenericData::OwnDump(const occ::handle& ent, @@ -274,7 +290,7 @@ void IGESDefs_ToolGenericData::OwnDump(const occ::handle& << "Number of property values : " << ent->NbPropertyValues() << "\n" << "Property Name : "; IGESData_DumpString(S, ent->Name()); - S << std::endl; + S << '\n'; switch (level) { case 4: @@ -322,5 +338,5 @@ void IGESDefs_ToolGenericData::OwnDump(const occ::handle& } } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolMacroDef.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolMacroDef.cxx index 30c41f8bae..999f7787dc 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolMacroDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolMacroDef.cxx @@ -57,13 +57,19 @@ void IGESDefs_ToolMacroDef::ReadOwnParams(const occ::handle& int nbval; // svv Jan 10 2000 : porting on DEC for (nbval = 0; PR.CurrentNumber() != PR.NbParams(); nbval++, PR.SetCurrentNumber(PR.CurrentNumber() + 1)) + { ; + } PR.SetCurrentNumber(tempCurrent); if (nbval > 0) + { langStatements = new NCollection_HArray1>(1, nbval); + } else + { PR.AddFail("Number of Lang. Stats. : Not Positive"); + } if (!langStatements.IsNull()) { @@ -73,7 +79,9 @@ void IGESDefs_ToolMacroDef::ReadOwnParams(const occ::handle& // st = PR.ReadText(PR.Current(), "Language Statement", langStat); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadText(PR.Current(), "Language Statement", langStat)) + { langStatements->SetValue(i, langStat); + } } } @@ -90,7 +98,9 @@ void IGESDefs_ToolMacroDef::WriteOwnParams(const occ::handle& IW.Send(ent->EntityTypeID()); int upper = ent->NbStatements(); for (int i = 1; i <= upper; i++) + { IW.Send(ent->LanguageStatement(i)); + } IW.Send(ent->ENDMACRO()); } @@ -156,5 +166,5 @@ void IGESDefs_ToolMacroDef::OwnDump(const occ::handle& ent, IGESData_DumpStrings(S, level, 1, ent->NbStatements(), ent->LanguageStatement); S << "END MACRO : "; IGESData_DumpString(S, ent->ENDMACRO()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolTabularData.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolTabularData.cxx index 5cb9b4ce45..6f86be5fc0 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolTabularData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolTabularData.cxx @@ -62,7 +62,9 @@ void IGESDefs_ToolTabularData::ReadOwnParams(const occ::handle 0) + { valuesDep = new IGESBasic_HArray1OfHArray1OfReal(1, nbDeps); + } st = PR.ReadInteger(PR.Current(), "No. of Independent variables", nbIndeps); if (st && nbIndeps > 0) @@ -109,12 +111,16 @@ void IGESDefs_ToolTabularData::ReadOwnParams(const occ::handle> somedeps; if (nbd > 0) + { somedeps = new NCollection_HArray1(1, nbd); + } for (i = 1; i <= nbd; i++) { double treal; @@ -124,9 +130,13 @@ void IGESDefs_ToolTabularData::ReadOwnParams(const occ::handleSetValue(i, treal); } if (nbDeps > 0) + { valuesDep->SetValue(1, somedeps); + } else + { PR.AddWarning("Some Real remain while no dependent value is defined"); + } nbProps = PR.CurrentNumber() - 2; /* for (;;) { @@ -151,18 +161,30 @@ void IGESDefs_ToolTabularData::WriteOwnParams(const occ::handleTypeOfIndependents(i)); + } for (i = 1; i <= nbIndeps; i++) + { IW.Send(ent->NbValues(i)); + } for (i = 1; i <= nbIndeps; i++) + { for (j = 1; j <= ent->NbValues(i); j++) + { IW.Send(ent->IndependentValue(i, j)); + } + } // UNFINISHED if (nbDeps == 0) + { return; + } occ::handle> deps = ent->DependentValues(1); for (i = 1; i <= deps->Length(); i++) + { IW.Send(deps->Value(i)); + } /* for (i=1; i<=nbDeps; i++) for (j=1; j<= .. ->Value(i); j++) @@ -198,7 +220,9 @@ void IGESDefs_ToolTabularData::OwnCopy(const occ::handle& nbValuesInd->SetValue(i, nval); occ::handle> tmparr = new NCollection_HArray1(1, nval); for (j = 1; j <= nval; j++) + { tmparr->SetValue(j, another->IndependentValue(i, j)); + } valuesInd->SetValue(i, tmparr); } // UNFINISHED @@ -249,21 +273,25 @@ void IGESDefs_ToolTabularData::OwnDump(const occ::handle& S << "\nNumber of values of independent variables : "; IGESData_DumpVals(S, level, 1, nbIndeps, ent->NbValues); // ?? JAGGED ?? - S << std::endl << "Values of the independent variable : "; + S << '\n' << "Values of the independent variable : "; if (level < 5) + { S << " [ask level > 4]"; + } else { for (int ind = 1; ind <= nbIndeps; ind++) { - S << std::endl << "[" << ind << "]:"; + S << '\n' << "[" << ind << "]:"; int nbi = ent->NbValues(ind); for (int iv = 1; iv <= nbi; iv++) + { S << " " << ent->IndependentValue(ind, iv); + } } } // IGESData_DumpVals(aSender,level,1, nbIndeps,ent->IndependentValue); - S << std::endl << "Values of the dependent variable : "; + S << '\n' << "Values of the dependent variable : "; // IGESData_DumpVals(aSender,level,1, nbDeps,ent->DependentValue); - S << " TO BE DONE" << std::endl; + S << " TO BE DONE" << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolUnitsData.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolUnitsData.cxx index 95a0ae21aa..ef0f9a46fc 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolUnitsData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_ToolUnitsData.cxx @@ -53,9 +53,12 @@ void IGESDefs_ToolUnitsData::ReadOwnParams(const occ::handle unitScales = new NCollection_HArray1(1, nbval); } else + { PR.AddFail("Number of Units: Less than or Equal or zero"); + } if (!unitTypes.IsNull()) + { for (int i = 1; i <= nbval; i++) { occ::handle unitType; @@ -64,18 +67,25 @@ void IGESDefs_ToolUnitsData::ReadOwnParams(const occ::handle // st = PR.ReadText(PR.Current(), "Type of Unit", unitType); //szv#4:S4163:12Mar99 moved in if if (PR.ReadText(PR.Current(), "Type of Unit", unitType)) + { unitTypes->SetValue(i, unitType); + } // st = PR.ReadText(PR.Current(), "Value of Unit", unitValue); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadText(PR.Current(), "Value of Unit", unitValue)) + { unitValues->SetValue(i, unitValue); + } // st = PR.ReadReal(PR.Current(), "Scale of Unit", unitScale); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Scale of Unit", unitScale)) + { unitScales->SetValue(i, unitScale); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(unitTypes, unitValues, unitScales); @@ -176,5 +186,5 @@ void IGESDefs_ToolUnitsData::OwnDump(const occ::handle& ent, << " ScaleFactor: " << ent->ScaleFactor(i) << "\n"; } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_UnitsData.cxx b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_UnitsData.cxx index bd6c505ad3..3a0eb76f1d 100644 --- a/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_UnitsData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDefs/IGESDefs_UnitsData.cxx @@ -33,7 +33,9 @@ void IGESDefs_UnitsData::Init( int length = unitTypes->Length(); if (unitTypes->Lower() != 1 || (unitValues->Lower() != 1 || unitValues->Length() != length) || (unitScales->Lower() != 1 || unitScales->Length() != length)) + { throw Standard_DimensionMismatch("IGESDefs_UnitsData : Init"); + } theUnitTypes = unitTypes; theUnitValues = unitValues; theUnitScales = unitScales; diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_AngularDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_AngularDimension.cxx index 0087c0b660..f55a2936e8 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_AngularDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_AngularDimension.cxx @@ -83,7 +83,9 @@ gp_Pnt2d IGESDimen_AngularDimension::TransformedVertex() const { gp_XYZ point(theVertex.X(), theVertex.Y(), 0.0); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt2d(point.X(), point.Y()); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_CenterLine.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_CenterLine.cxx index cd621d92f4..4eeed6740e 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_CenterLine.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_CenterLine.cxx @@ -32,7 +32,9 @@ void IGESDimen_CenterLine::Init(const int a const occ::handle>& dataPnts) { if (dataPnts->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_CenterLine : Init"); + } theDatatype = aDataType; theZDisplacement = aZdisp; theDataPoints = dataPnts; @@ -72,7 +74,9 @@ gp_Pnt IGESDimen_CenterLine::TransformedPoint(const int Index) const gp_XY point2d = (theDataPoints->Value(Index)); gp_XYZ point(point2d.X(), point2d.Y(), theZDisplacement); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DiameterDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DiameterDimension.cxx index fc8305b102..44cc57ddb6 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DiameterDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DiameterDimension.cxx @@ -71,6 +71,8 @@ gp_Pnt2d IGESDimen_DiameterDimension::TransformedCenter() const { gp_XYZ center(theCenter.X(), theCenter.Y(), 0); if (HasTransf()) + { Location().Transforms(center); + } return gp_Pnt2d(center.X(), center.Y()); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionDisplayData.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionDisplayData.cxx index d2d5f072ef..8082ec331a 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionDisplayData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionDisplayData.cxx @@ -42,9 +42,13 @@ void IGESDimen_DimensionDisplayData::Init(const int const occ::handle>& endInd) { if (!notes.IsNull()) + { if (notes->Lower() != 1 || (startInd->Lower() != 1 || notes->Length() != startInd->Length()) || (endInd->Lower() != 1 || notes->Length() != endInd->Length())) + { throw Standard_DimensionMismatch("IGESDimen_DimensionDisplayData : Init"); + } + } theNbPropertyValues = numProps; theDimensionType = aDimType; diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionedGeometry.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionedGeometry.cxx index 1e963c7751..cfa36211b0 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionedGeometry.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_DimensionedGeometry.cxx @@ -30,7 +30,9 @@ void IGESDimen_DimensionedGeometry::Init( const occ::handle>>& entities) { if (entities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_DimensionedGeometry : Init"); + } theNbDimensions = nbDims; theDimension = aDimension; theGeometryEntities = entities; diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_FlagNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_FlagNote.cxx index 364fb17a8d..d937bfc793 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_FlagNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_FlagNote.cxx @@ -36,8 +36,12 @@ void IGESDimen_FlagNote::Init( const occ::handle>>& someLeaders) { if (!someLeaders.IsNull()) + { if (someLeaders->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_FlagNote : Init"); + } + } theLowerLeftcorner = leftCorner; theAngle = anAngle; theNote = aNote; @@ -55,7 +59,9 @@ gp_Pnt IGESDimen_FlagNote::TransformedLowerLeftCorner() const { gp_XYZ tempXYZ = theLowerLeftcorner; if (HasTransf()) + { Location().Transforms(tempXYZ); + } return gp_Pnt(tempXYZ); } @@ -90,7 +96,9 @@ double IGESDimen_FlagNote::CharacterHeight() const for (int i = 2; i <= theNote->NbStrings(); i++) { if (Max < theNote->BoxHeight(i)) + { Max = theNote->BoxHeight(i); + } } return (Max); } @@ -104,7 +112,9 @@ double IGESDimen_FlagNote::TextWidth() const { double width = 0; for (int i = 1; i <= theNote->NbStrings(); i++) + { width += theNote->BoxWidth(i); + } return (width); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralLabel.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralLabel.cxx index c79d248101..76c1ba6b01 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralLabel.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralLabel.cxx @@ -31,7 +31,9 @@ void IGESDimen_GeneralLabel::Init( const occ::handle>>& someLeaders) { if (someLeaders->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_GeneralLabel : Init"); + } theNote = aNote; theLeaders = someLeaders; InitTypeAndForm(210, 0); diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralModule.cxx index 207b382f82..c43b5c7343 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralModule.cxx @@ -84,7 +84,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolAngularDimension tool; tool.OwnShared(anent, iter); } @@ -92,7 +94,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolBasicDimension tool; tool.OwnShared(anent, iter); } @@ -100,7 +104,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCenterLine tool; tool.OwnShared(anent, iter); } @@ -108,7 +114,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCurveDimension tool; tool.OwnShared(anent, iter); } @@ -116,7 +124,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDiameterDimension tool; tool.OwnShared(anent, iter); } @@ -124,7 +134,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionDisplayData tool; tool.OwnShared(anent, iter); } @@ -132,7 +144,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionTolerance tool; tool.OwnShared(anent, iter); } @@ -140,7 +154,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionUnits tool; tool.OwnShared(anent, iter); } @@ -148,7 +164,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionedGeometry tool; tool.OwnShared(anent, iter); } @@ -156,7 +174,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolFlagNote tool; tool.OwnShared(anent, iter); } @@ -164,7 +184,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralLabel tool; tool.OwnShared(anent, iter); } @@ -172,7 +194,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralNote tool; tool.OwnShared(anent, iter); } @@ -180,7 +204,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralSymbol tool; tool.OwnShared(anent, iter); } @@ -188,7 +214,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLeaderArrow tool; tool.OwnShared(anent, iter); } @@ -196,7 +224,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLinearDimension tool; tool.OwnShared(anent, iter); } @@ -204,7 +234,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewDimensionedGeometry tool; tool.OwnShared(anent, iter); } @@ -212,7 +244,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewGeneralNote tool; tool.OwnShared(anent, iter); } @@ -220,7 +254,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolOrdinateDimension tool; tool.OwnShared(anent, iter); } @@ -228,7 +264,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolPointDimension tool; tool.OwnShared(anent, iter); } @@ -236,7 +274,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolRadiusDimension tool; tool.OwnShared(anent, iter); } @@ -244,7 +284,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSection tool; tool.OwnShared(anent, iter); } @@ -252,7 +294,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSectionedArea tool; tool.OwnShared(anent, iter); } @@ -260,7 +304,9 @@ void IGESDimen_GeneralModule::OwnSharedCase(const int case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolWitnessLine tool; tool.OwnShared(anent, iter); } @@ -279,161 +325,207 @@ IGESData_DirChecker IGESDimen_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolAngularDimension tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolBasicDimension tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolCenterLine tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolCurveDimension tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDiameterDimension tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionDisplayData tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionTolerance tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionUnits tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionedGeometry tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolFlagNote tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolGeneralLabel tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolGeneralNote tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolGeneralSymbol tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolLeaderArrow tool; return tool.DirChecker(anent); } case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolLinearDimension tool; return tool.DirChecker(anent); } case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolNewDimensionedGeometry tool; return tool.DirChecker(anent); } case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolNewGeneralNote tool; return tool.DirChecker(anent); } case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolOrdinateDimension tool; return tool.DirChecker(anent); } case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolPointDimension tool; return tool.DirChecker(anent); } case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolRadiusDimension tool; return tool.DirChecker(anent); } case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolSection tool; return tool.DirChecker(anent); } case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolSectionedArea tool; return tool.DirChecker(anent); } case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolWitnessLine tool; return tool.DirChecker(anent); } @@ -453,7 +545,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolAngularDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -461,7 +555,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolBasicDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -469,7 +565,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCenterLine tool; tool.OwnCheck(anent, shares, ach); } @@ -477,7 +575,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCurveDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -485,7 +585,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDiameterDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -493,7 +595,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionDisplayData tool; tool.OwnCheck(anent, shares, ach); } @@ -501,7 +605,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionTolerance tool; tool.OwnCheck(anent, shares, ach); } @@ -509,7 +615,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionUnits tool; tool.OwnCheck(anent, shares, ach); } @@ -517,7 +625,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionedGeometry tool; tool.OwnCheck(anent, shares, ach); } @@ -525,7 +635,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolFlagNote tool; tool.OwnCheck(anent, shares, ach); } @@ -533,7 +645,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralLabel tool; tool.OwnCheck(anent, shares, ach); } @@ -541,7 +655,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralNote tool; tool.OwnCheck(anent, shares, ach); } @@ -549,7 +665,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralSymbol tool; tool.OwnCheck(anent, shares, ach); } @@ -557,7 +675,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLeaderArrow tool; tool.OwnCheck(anent, shares, ach); } @@ -565,7 +685,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLinearDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -573,7 +695,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewDimensionedGeometry tool; tool.OwnCheck(anent, shares, ach); } @@ -581,7 +705,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewGeneralNote tool; tool.OwnCheck(anent, shares, ach); } @@ -589,7 +715,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolOrdinateDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -597,7 +725,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolPointDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -605,7 +735,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolRadiusDimension tool; tool.OwnCheck(anent, shares, ach); } @@ -613,7 +745,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSection tool; tool.OwnCheck(anent, shares, ach); } @@ -621,7 +755,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSectionedArea tool; tool.OwnCheck(anent, shares, ach); } @@ -629,7 +765,9 @@ void IGESDimen_GeneralModule::OwnCheckCase(const int case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolWitnessLine tool; tool.OwnCheck(anent, shares, ach); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralNote.cxx index 971336e510..54882c659a 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralNote.cxx @@ -54,7 +54,9 @@ void IGESDimen_GeneralNote::Init( || (rotFlags->Lower() != 1 || rotFlags->Length() != num) || (start->Lower() != 1 || start->Length() != num) || (texts->Lower() != 1 || texts->Length() != num)) + { throw Standard_DimensionMismatch("IGESDimen_GeneralNote : Init"); + } theNbChars = nbChars; theBoxWidths = widths; @@ -74,7 +76,9 @@ void IGESDimen_GeneralNote::Init( void IGESDimen_GeneralNote::SetFormNumber(const int form) { if ((form < 0 || form > 8) && (form < 100 || form > 102) && form != 105) + { throw Standard_OutOfRange("IGESDimen_GeneralNote : SetFormNumber"); + } InitTypeAndForm(212, form); } @@ -143,7 +147,9 @@ gp_Pnt IGESDimen_GeneralNote::TransformedStartPoint(const int Index) const { gp_XYZ point = (theStartPoints->Value(Index)); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralSymbol.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralSymbol.cxx index 82b9a04f90..e18835a17e 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralSymbol.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_GeneralSymbol.cxx @@ -33,10 +33,16 @@ void IGESDimen_GeneralSymbol::Init( const occ::handle>>& allLeaders) { if (!allGeoms.IsNull() && allGeoms->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_GeneralSymbol : Init"); + } if (!allLeaders.IsNull()) + { if (allLeaders->Lower() != 1) + { throw Standard_DimensionMismatch("$"); + } + } theNote = aNote; theGeoms = allGeoms; theLeaders = allLeaders; @@ -47,7 +53,9 @@ void IGESDimen_GeneralSymbol::Init( void IGESDimen_GeneralSymbol::SetFormNumber(const int form) { if ((form < 0 || form > 3) && form < 5000) + { throw Standard_OutOfRange("IGESDimen_GeneralSymbol : SetFormNumber"); + } InitTypeAndForm(228, form); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LeaderArrow.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LeaderArrow.cxx index 0aee6cc00c..7fbc6a6776 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LeaderArrow.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LeaderArrow.cxx @@ -36,7 +36,9 @@ void IGESDimen_LeaderArrow::Init(const double const occ::handle>& segments) { if (segments->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_LeaderArrow : Init"); + } theArrowHeadHeight = height; theArrowHeadWidth = width; theZDepth = depth; @@ -49,7 +51,9 @@ void IGESDimen_LeaderArrow::Init(const double void IGESDimen_LeaderArrow::SetFormNumber(const int form) { if (form < 1 || form > 12) + { throw Standard_OutOfRange("IGESDimen_LeaderArrow : SetFormNumber"); + } InitTypeAndForm(214, form); } @@ -83,7 +87,9 @@ gp_Pnt IGESDimen_LeaderArrow::TransformedArrowHead() const { gp_XYZ point(theArrowHead.X(), theArrowHead.Y(), ZDepth()); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } @@ -98,6 +104,8 @@ gp_Pnt IGESDimen_LeaderArrow::TransformedSegmentTail(const int Index) const gp_XY point2d = theSegmentTails->Value(Index); gp_XYZ point(point2d.X(), point2d.Y(), ZDepth()); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LinearDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LinearDimension.cxx index 9edc8b1f35..8cb725b81d 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LinearDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_LinearDimension.cxx @@ -45,7 +45,9 @@ void IGESDimen_LinearDimension::Init(const occ::handle& a void IGESDimen_LinearDimension::SetFormNumber(const int fm) { if (fm < 0 || fm > 2) + { throw Standard_OutOfRange("IGESDimen_LinearDimension : SetFormNumber"); + } InitTypeAndForm(216, fm); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewDimensionedGeometry.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewDimensionedGeometry.cxx index 926823fd46..df6b4fc47c 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewDimensionedGeometry.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewDimensionedGeometry.cxx @@ -39,7 +39,9 @@ void IGESDimen_NewDimensionedGeometry::Init( int num = allEntities->Length(); if (allEntities->Lower() != 1 || allLocations->Lower() != 1 || allLocations->Length() != num || allPoints->Lower() != 1 || allPoints->Length() != num) + { throw Standard_DimensionMismatch("IGESDimen_NewDimensionedGeometry: Init"); + } theNbDimensions = nbDimens; theDimensionEntity = aDimen; theDimensionOrientationFlag = anOrientation; @@ -95,6 +97,8 @@ gp_Pnt IGESDimen_NewDimensionedGeometry::TransformedPoint(const int Index) const { gp_XYZ point = thePoints->Value(Index); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewGeneralNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewGeneralNote.cxx index eb0a227352..8e2c39ba95 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewGeneralNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_NewGeneralNote.cxx @@ -76,7 +76,9 @@ void IGESDimen_NewGeneralNote::Init( || (rotateFlags->Lower() != 1 || rotateFlags->Length() != num) || (startPoints->Lower() != 1 || startPoints->Length() != num) || (texts->Lower() != 1 || texts->Length() != num)) + { throw Standard_DimensionMismatch("IGESDimen_GeneralNote : Init"); + } theWidth = width; theHeight = height; @@ -132,7 +134,9 @@ gp_Pnt IGESDimen_NewGeneralNote::TransformedAreaLocation() const { gp_XYZ tempXYZ = theAreaLoc; if (HasTransf()) + { Location().Transforms(tempXYZ); + } return gp_Pnt(tempXYZ); } @@ -156,7 +160,9 @@ gp_Pnt IGESDimen_NewGeneralNote::TransformedBaseLinePosition() const { gp_XYZ tempXYZ = theBaseLinePos; if (HasTransf()) + { Location().Transforms(tempXYZ); + } return gp_Pnt(tempXYZ); } @@ -285,7 +291,9 @@ gp_Pnt IGESDimen_NewGeneralNote::TransformedStartPoint(const int Index) const { gp_XYZ tempXYZ = theStartPoints->Value(Index); if (HasTransf()) + { Location().Transforms(tempXYZ); + } return gp_Pnt(tempXYZ); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_OrdinateDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_OrdinateDimension.cxx index 70483571e0..4a3cc7552e 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_OrdinateDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_OrdinateDimension.cxx @@ -36,9 +36,13 @@ void IGESDimen_OrdinateDimension::Init(const occ::handle& theWitnessLine = aLine; theLeader = anArrow; if ((aLine.IsNull()) || (anArrow.IsNull())) + { InitTypeAndForm(218, 0); + } else + { InitTypeAndForm(218, 1); + } } occ::handle IGESDimen_OrdinateDimension::Note() const diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_PointDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_PointDimension.cxx index 2152cf0bfe..76bcc8a812 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_PointDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_PointDimension.cxx @@ -66,11 +66,19 @@ occ::handle IGESDimen_PointDimension::Geom() const int IGESDimen_PointDimension::GeomCase() const { if (theGeom.IsNull()) + { return 0; + } else if (theGeom->TypeNumber() == 100) + { return 1; + } else if (theGeom->TypeNumber() == 102) + { return 2; + } else + { return 3; + } } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Protocol.cxx index 6bd1e7167d..18f34cfe70 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Protocol.cxx @@ -56,59 +56,109 @@ occ::handle IGESDimen_Protocol::Resource(const int num) cons { occ::handle res; if (num == 1) + { res = IGESGraph::Protocol(); + } if (num == 2) + { res = IGESGeom::Protocol(); + } return res; } int IGESDimen_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESDimen_AngularDimension)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESDimen_BasicDimension)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESDimen_CenterLine)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESDimen_CurveDimension)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESDimen_DiameterDimension)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESDimen_DimensionDisplayData)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESDimen_DimensionTolerance)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESDimen_DimensionUnits)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESDimen_DimensionedGeometry)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESDimen_FlagNote)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESDimen_GeneralLabel)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESDimen_GeneralNote)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESDimen_GeneralSymbol)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESDimen_LeaderArrow)) + { return 14; + } else if (atype == STANDARD_TYPE(IGESDimen_LinearDimension)) + { return 15; + } else if (atype == STANDARD_TYPE(IGESDimen_NewDimensionedGeometry)) + { return 16; + } else if (atype == STANDARD_TYPE(IGESDimen_NewGeneralNote)) + { return 17; + } else if (atype == STANDARD_TYPE(IGESDimen_OrdinateDimension)) + { return 18; + } else if (atype == STANDARD_TYPE(IGESDimen_PointDimension)) + { return 19; + } else if (atype == STANDARD_TYPE(IGESDimen_RadiusDimension)) + { return 20; + } else if (atype == STANDARD_TYPE(IGESDimen_Section)) + { return 21; + } else if (atype == STANDARD_TYPE(IGESDimen_SectionedArea)) + { return 22; + } else if (atype == STANDARD_TYPE(IGESDimen_WitnessLine)) + { return 23; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_RadiusDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_RadiusDimension.cxx index ff1f9e6c4a..5d46e3f674 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_RadiusDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_RadiusDimension.cxx @@ -39,9 +39,13 @@ void IGESDimen_RadiusDimension::Init(const occ::handle& a theCenter = arcCenter; theLeader2 = anotherArrow; if (!anotherArrow.IsNull()) + { InitTypeAndForm(222, 1); // 1 also admits Null + } else + { InitTypeAndForm(222, FormNumber()); + } } void IGESDimen_RadiusDimension::InitForm(const int form) @@ -74,7 +78,9 @@ gp_Pnt IGESDimen_RadiusDimension::TransformedCenter() const { gp_XYZ tmpXYZ(theCenter.X(), theCenter.Y(), theLeaderArrow->ZDepth()); if (HasTransf()) + { Location().Transforms(tmpXYZ); + } return gp_Pnt(tmpXYZ); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ReadWriteModule.cxx index f54ac6dd78..89ab1ee4ba 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ReadWriteModule.cxx @@ -77,11 +77,17 @@ int IGESDimen_ReadWriteModule::CaseIGES(const int typenum, const int formnum) co { case 106: if (formnum == 20 || formnum == 21) + { return 3; + } else if (formnum > 30 && formnum < 40) + { return 21; + } else if (formnum == 40) + { return 23; + } break; case 202: return 1; @@ -153,7 +159,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolAngularDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -161,7 +169,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolBasicDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -169,7 +179,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCenterLine tool; tool.ReadOwnParams(anent, IR, PR); } @@ -177,7 +189,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCurveDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -185,7 +199,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDiameterDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -193,7 +209,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionDisplayData tool; tool.ReadOwnParams(anent, IR, PR); } @@ -201,7 +219,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionTolerance tool; tool.ReadOwnParams(anent, IR, PR); } @@ -209,7 +229,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionUnits tool; tool.ReadOwnParams(anent, IR, PR); } @@ -217,7 +239,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionedGeometry tool; tool.ReadOwnParams(anent, IR, PR); } @@ -225,7 +249,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolFlagNote tool; tool.ReadOwnParams(anent, IR, PR); } @@ -233,7 +259,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralLabel tool; tool.ReadOwnParams(anent, IR, PR); } @@ -241,7 +269,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralNote tool; tool.ReadOwnParams(anent, IR, PR); } @@ -249,7 +279,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralSymbol tool; tool.ReadOwnParams(anent, IR, PR); } @@ -257,7 +289,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLeaderArrow tool; tool.ReadOwnParams(anent, IR, PR); } @@ -265,7 +299,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLinearDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -273,7 +309,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewDimensionedGeometry tool; tool.ReadOwnParams(anent, IR, PR); } @@ -281,7 +319,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewGeneralNote tool; tool.ReadOwnParams(anent, IR, PR); } @@ -289,7 +329,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolOrdinateDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -297,7 +339,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolPointDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -305,7 +349,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolRadiusDimension tool; tool.ReadOwnParams(anent, IR, PR); } @@ -313,7 +359,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSection tool; tool.ReadOwnParams(anent, IR, PR); } @@ -321,7 +369,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSectionedArea tool; tool.ReadOwnParams(anent, IR, PR); } @@ -329,7 +379,9 @@ void IGESDimen_ReadWriteModule::ReadOwnParams(const int case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolWitnessLine tool; tool.ReadOwnParams(anent, IR, PR); } @@ -348,7 +400,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolAngularDimension tool; tool.WriteOwnParams(anent, IW); } @@ -356,7 +410,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolBasicDimension tool; tool.WriteOwnParams(anent, IW); } @@ -364,7 +420,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCenterLine tool; tool.WriteOwnParams(anent, IW); } @@ -372,7 +430,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCurveDimension tool; tool.WriteOwnParams(anent, IW); } @@ -380,7 +440,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDiameterDimension tool; tool.WriteOwnParams(anent, IW); } @@ -388,7 +450,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionDisplayData tool; tool.WriteOwnParams(anent, IW); } @@ -396,7 +460,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionTolerance tool; tool.WriteOwnParams(anent, IW); } @@ -404,7 +470,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionUnits tool; tool.WriteOwnParams(anent, IW); } @@ -412,7 +480,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionedGeometry tool; tool.WriteOwnParams(anent, IW); } @@ -420,7 +490,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolFlagNote tool; tool.WriteOwnParams(anent, IW); } @@ -428,7 +500,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralLabel tool; tool.WriteOwnParams(anent, IW); } @@ -436,7 +510,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralNote tool; tool.WriteOwnParams(anent, IW); } @@ -444,7 +520,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralSymbol tool; tool.WriteOwnParams(anent, IW); } @@ -452,7 +530,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLeaderArrow tool; tool.WriteOwnParams(anent, IW); } @@ -460,7 +540,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLinearDimension tool; tool.WriteOwnParams(anent, IW); } @@ -468,7 +550,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewDimensionedGeometry tool; tool.WriteOwnParams(anent, IW); } @@ -476,7 +560,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewGeneralNote tool; tool.WriteOwnParams(anent, IW); } @@ -484,7 +570,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolOrdinateDimension tool; tool.WriteOwnParams(anent, IW); } @@ -492,7 +580,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolPointDimension tool; tool.WriteOwnParams(anent, IW); } @@ -500,7 +590,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolRadiusDimension tool; tool.WriteOwnParams(anent, IW); } @@ -508,7 +600,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSection tool; tool.WriteOwnParams(anent, IW); } @@ -516,7 +610,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSectionedArea tool; tool.WriteOwnParams(anent, IW); } @@ -524,7 +620,9 @@ void IGESDimen_ReadWriteModule::WriteOwnParams(const int case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolWitnessLine tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Section.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Section.cxx index 4abe4007e5..940cd6d9e8 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Section.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_Section.cxx @@ -33,7 +33,9 @@ void IGESDimen_Section::Init(const int data const occ::handle>& dataPoints) { if (dataPoints->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_Section : Init"); + } theDatatype = dataType; theZDisplacement = aDisp; theDataPoints = dataPoints; @@ -44,7 +46,9 @@ void IGESDimen_Section::Init(const int data void IGESDimen_Section::SetFormNumber(const int form) { if (form < 31 || form > 38) + { throw Standard_OutOfRange("IGESDimen_Section : SetFormNumber"); + } InitTypeAndForm(106, form); } @@ -75,6 +79,8 @@ gp_Pnt IGESDimen_Section::TransformedPoint(const int Index) const gp_XY point2d = theDataPoints->Value(Index); gp_XYZ point(point2d.X(), point2d.Y(), theZDisplacement); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SectionedArea.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SectionedArea.cxx index 72f9c73f85..9d82e4792b 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SectionedArea.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SectionedArea.cxx @@ -36,8 +36,12 @@ void IGESDimen_SectionedArea::Init( const occ::handle>>& someIslands) { if (!someIslands.IsNull()) + { if (someIslands->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_SectionedArea : Init"); + } + } theExteriorCurve = aCurve; thePattern = aPattern; thePassingPoint = aPoint; @@ -76,7 +80,9 @@ gp_Pnt IGESDimen_SectionedArea::TransformedPassingPoint() const { gp_XYZ tmpXYZ(thePassingPoint); if (HasTransf()) + { Location().Transforms(tmpXYZ); + } return gp_Pnt(tmpXYZ); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SpecificModule.cxx index 8986c9481b..afa7feb7d5 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_SpecificModule.cxx @@ -81,7 +81,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 1: { DeclareAndCast(IGESDimen_AngularDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolAngularDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -89,7 +91,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolBasicDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -97,7 +101,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCenterLine tool; tool.OwnDump(anent, dumper, S, own); } @@ -105,7 +111,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 4: { DeclareAndCast(IGESDimen_CurveDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolCurveDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -113,7 +121,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 5: { DeclareAndCast(IGESDimen_DiameterDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDiameterDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -121,7 +131,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionDisplayData tool; tool.OwnDump(anent, dumper, S, own); } @@ -129,7 +141,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionTolerance tool; tool.OwnDump(anent, dumper, S, own); } @@ -137,7 +151,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionUnits tool; tool.OwnDump(anent, dumper, S, own); } @@ -145,7 +161,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolDimensionedGeometry tool; tool.OwnDump(anent, dumper, S, own); } @@ -153,7 +171,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 10: { DeclareAndCast(IGESDimen_FlagNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolFlagNote tool; tool.OwnDump(anent, dumper, S, own); } @@ -161,7 +181,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 11: { DeclareAndCast(IGESDimen_GeneralLabel, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralLabel tool; tool.OwnDump(anent, dumper, S, own); } @@ -169,7 +191,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 12: { DeclareAndCast(IGESDimen_GeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralNote tool; tool.OwnDump(anent, dumper, S, own); } @@ -177,7 +201,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 13: { DeclareAndCast(IGESDimen_GeneralSymbol, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolGeneralSymbol tool; tool.OwnDump(anent, dumper, S, own); } @@ -185,7 +211,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 14: { DeclareAndCast(IGESDimen_LeaderArrow, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLeaderArrow tool; tool.OwnDump(anent, dumper, S, own); } @@ -193,7 +221,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 15: { DeclareAndCast(IGESDimen_LinearDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolLinearDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -201,7 +231,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewDimensionedGeometry tool; tool.OwnDump(anent, dumper, S, own); } @@ -209,7 +241,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 17: { DeclareAndCast(IGESDimen_NewGeneralNote, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolNewGeneralNote tool; tool.OwnDump(anent, dumper, S, own); } @@ -217,7 +251,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 18: { DeclareAndCast(IGESDimen_OrdinateDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolOrdinateDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -225,7 +261,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 19: { DeclareAndCast(IGESDimen_PointDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolPointDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -233,7 +271,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 20: { DeclareAndCast(IGESDimen_RadiusDimension, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolRadiusDimension tool; tool.OwnDump(anent, dumper, S, own); } @@ -241,7 +281,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSection tool; tool.OwnDump(anent, dumper, S, own); } @@ -249,7 +291,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 22: { DeclareAndCast(IGESDimen_SectionedArea, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolSectionedArea tool; tool.OwnDump(anent, dumper, S, own); } @@ -257,7 +301,9 @@ void IGESDimen_SpecificModule::OwnDump(const int C case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { return; + } IGESDimen_ToolWitnessLine tool; tool.OwnDump(anent, dumper, S, own); } @@ -276,63 +322,81 @@ bool IGESDimen_SpecificModule::OwnCorrect(const int case 2: { DeclareAndCast(IGESDimen_BasicDimension, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolBasicDimension tool; return tool.OwnCorrect(anent); } case 3: { DeclareAndCast(IGESDimen_CenterLine, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolCenterLine tool; return tool.OwnCorrect(anent); } case 6: { DeclareAndCast(IGESDimen_DimensionDisplayData, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionDisplayData tool; return tool.OwnCorrect(anent); } case 7: { DeclareAndCast(IGESDimen_DimensionTolerance, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionTolerance tool; return tool.OwnCorrect(anent); } case 8: { DeclareAndCast(IGESDimen_DimensionUnits, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionUnits tool; return tool.OwnCorrect(anent); } case 9: { DeclareAndCast(IGESDimen_DimensionedGeometry, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolDimensionedGeometry tool; return tool.OwnCorrect(anent); } case 16: { DeclareAndCast(IGESDimen_NewDimensionedGeometry, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolNewDimensionedGeometry tool; return tool.OwnCorrect(anent); } case 21: { DeclareAndCast(IGESDimen_Section, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolSection tool; return tool.OwnCorrect(anent); } case 23: { DeclareAndCast(IGESDimen_WitnessLine, anent, ent); if (anent.IsNull()) + { break; + } IGESDimen_ToolWitnessLine tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolAngularDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolAngularDimension.cxx index 02e48adf1e..8bb0f922c2 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolAngularDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolAngularDimension.cxx @@ -176,5 +176,5 @@ void IGESDimen_ToolAngularDimension::OwnDump(const occ::handleSecondLeader(), S, sublevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolBasicDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolBasicDimension.cxx index 2b11e96d60..e0966da71e 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolBasicDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolBasicDimension.cxx @@ -94,11 +94,13 @@ bool IGESDimen_ToolBasicDimension::OwnCorrect( { bool res = (ent->NbPropertyValues() != 8); if (res) + { ent->Init(8, ent->LowerLeft().XY(), ent->LowerRight().XY(), ent->UpperRight().XY(), ent->UpperLeft().XY()); // nbpropertyvalues = 8 + } return res; } @@ -120,7 +122,9 @@ void IGESDimen_ToolBasicDimension::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 8) + { ach->AddFail("Num of Property Values != 8"); + } } void IGESDimen_ToolBasicDimension::OwnDump(const occ::handle& ent, @@ -138,5 +142,5 @@ void IGESDimen_ToolBasicDimension::OwnDump(const occ::handleUpperRight()); S << "\n Upper left corner : "; IGESData_DumpXY(S, ent->UpperLeft()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCenterLine.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCenterLine.cxx index 93808bbc9b..2e4e2f1a61 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCenterLine.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCenterLine.cxx @@ -53,21 +53,26 @@ void IGESDimen_ToolCenterLine::ReadOwnParams(const occ::handle 0) dataPoints = new NCollection_HArray1(1, nbval); - else PR.AddFail("Number of data points: Not Positive"); + if (st && nbval > 0) { dataPoints = new NCollection_HArray1(1, nbval); + } else { PR.AddFail("Number of data points: Not Positive"); +} PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on if (!dataPoints.IsNull()) + { for (int i = 1; i <= nbval; i++) { gp_XY tempXY; // st = PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY)) + { dataPoints->SetValue(i, tempXY); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(datatype, zDisplacement, dataPoints); @@ -121,14 +126,20 @@ bool IGESDimen_ToolCenterLine::OwnCorrect(const occ::handleInitLineFont(nulfont, 1); } if (ent->Datatype() == 1) + { return res; + } // Force DataType = 1 -> reconstruct int nb = ent->NbPoints(); if (nb == 0) + { return res; // nothing could be done (is this possible?) + } occ::handle> pts = new NCollection_HArray1(1, nb); for (int i = 1; i <= nb; i++) + { pts->SetValue(i, gp_XY(ent->Point(i).X(), ent->Point(i).Y())); + } ent->Init(1, ent->ZDisplacement(), pts); return true; } @@ -151,11 +162,17 @@ void IGESDimen_ToolCenterLine::OwnCheck(const occ::handle& occ::handle& ach) const { if (ent->RankLineFont() != 1) + { ach->AddFail("Line Font Pattern != 1"); + } if (ent->Datatype() != 1) + { ach->AddFail("Interpretation Flag != 1"); + } if (ent->NbPoints() % 2 != 0) + { ach->AddFail("Number of data points is not even"); + } } void IGESDimen_ToolCenterLine::OwnDump(const occ::handle& ent, @@ -165,9 +182,13 @@ void IGESDimen_ToolCenterLine::OwnDump(const occ::handle& { S << "IGESDimen_CenterLine\n"; if (ent->IsCrossHair()) + { S << "Cross Hair\n"; + } else + { S << "Through Circle Centers\n"; + } S << "Data Type : " << ent->Datatype() << " " << "Number of Data Points : " << ent->NbPoints() << " " << "Common Z displacement : " << ent->ZDisplacement() << " " @@ -179,5 +200,5 @@ void IGESDimen_ToolCenterLine::OwnDump(const occ::handle& ent->Point, ent->Location(), ent->ZDisplacement()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCurveDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCurveDimension.cxx index 7f8255c08a..7ab5312ea1 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCurveDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolCurveDimension.cxx @@ -151,8 +151,12 @@ void IGESDimen_ToolCurveDimension::OwnCheck(const occ::handleHasSecondCurve()) { if (ent->FirstCurve()->IsKind(STANDARD_TYPE(IGESGeom_Line))) + { if (ent->SecondCurve()->IsKind(STANDARD_TYPE(IGESGeom_Line))) + { ach->AddWarning("Both curves are IGESGeom_Line Entities"); + } + } } } @@ -184,5 +188,5 @@ void IGESDimen_ToolCurveDimension::OwnDump(const occ::handleSecondWitnessLine(), S, sublevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDiameterDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDiameterDimension.cxx index 91b7c029c3..a30cfe9577 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDiameterDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDiameterDimension.cxx @@ -145,5 +145,5 @@ void IGESDimen_ToolDiameterDimension::OwnDump(const occ::handleCenter(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionDisplayData.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionDisplayData.cxx index b3cb3691fd..d6c883b7e3 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionDisplayData.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionDisplayData.cxx @@ -63,30 +63,37 @@ void IGESDimen_ToolDimensionDisplayData::ReadOwnParams( PR.ReadInteger(PR.Current(), "Dimension Type", tempDimType); PR.ReadInteger(PR.Current(), "Label Position", tempLabelPos); if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger(PR.Current(),"Character Set", tempCharSet); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempCharSet = 1; +} //szv#4:S4163:12Mar99 `st=` not needed PR.ReadText(PR.Current(),"L String", tempLString); PR.ReadInteger(PR.Current(),"Decimal Symbol",tempDeciSymb); - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(),"Witness Line Angle",tempWitLineAng); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempWitLineAng = M_PI / 2; +} PR.ReadInteger(PR.Current(),"Text Alignment",tempTextAlign); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadInteger(PR.Current(),"Text Level",tempTextLevel); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempTextLevel = 0; +} - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadInteger(PR.Current(),"Text Place",tempTextPlace); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else + { tempTextPlace = 0; + } // szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "ArrowHeadOrientation", tempArrHeadOrient); @@ -104,13 +111,19 @@ void IGESDimen_ToolDimensionDisplayData::ReadOwnParams( // st = PR.ReadInteger(PR.Current(), "Supplementary Notes", anote); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "Supplementary Notes", anote)) + { tempSuppleNotes->SetValue(i, anote); + } // st = PR.ReadInteger(PR.Current(),"Start Index", astart); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Start Index", astart)) + { tempStartInd->SetValue(i, astart); + } // st = PR.ReadInteger(PR.Current(),"End Index",anend); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "End Index", anend)) + { tempEndInd->SetValue(i, anend); + } } } @@ -222,7 +235,9 @@ bool IGESDimen_ToolDimensionDisplayData::OwnCorrect( { bool res = (ent->NbPropertyValues() != 14); if (!res) + { return res; + } occ::handle> EndList; occ::handle> StartList; occ::handle> NotesList; @@ -277,28 +292,48 @@ void IGESDimen_ToolDimensionDisplayData::OwnCheck( occ::handle& ach) const { if (ent->NbPropertyValues() != 14) + { ach->AddFail("The No. of property values != 14 "); + } if (ent->DimensionType() < 0 || ent->DimensionType() > 2) + { ach->AddFail("Incorrect Dimension Type"); + } if (ent->LabelPosition() < 0 || ent->LabelPosition() > 4) + { ach->AddFail("Incorrect Preferred Label Position"); + } if (ent->CharacterSet() != 1 && ent->CharacterSet() != 1001 && ent->CharacterSet() != 1002 && ent->CharacterSet() != 1003) + { ach->AddFail("Incorrect Character Set"); + } if (ent->DecimalSymbol() != 0 && ent->DecimalSymbol() != 1) + { ach->AddFail("Incorrect Decimal Symbol"); + } if (ent->TextAlignment() != 0 && ent->TextAlignment() != 1) + { ach->AddFail("Incorrect Text Alignment"); + } if (ent->TextLevel() < 0 || ent->TextLevel() > 2) + { ach->AddFail("Incorrect Text Level"); + } if (ent->TextPlacement() < 0 || ent->TextPlacement() > 2) + { ach->AddFail("Incorrect Text Placement"); + } if (ent->ArrowHeadOrientation() != 0 && ent->ArrowHeadOrientation() != 1) + { ach->AddFail("Incorrect ArrowHead Orientation"); + } for (int upper = ent->NbSupplementaryNotes(), i = 1; i <= upper; i++) { if (ent->SupplementaryNote(i) < 1 || ent->SupplementaryNote(i) > 4) + { ach->AddFail("Incorrect First supplement note"); + } } } @@ -375,18 +410,28 @@ void IGESDimen_ToolDimensionDisplayData::OwnDump( S << "\n" << "Decimal Symbol : "; if (ent->DecimalSymbol() == 0) + { S << "0 (.)\n"; + } else + { S << "1 (,)\n"; + } S << "Witness Line Angle : " << ent->WitnessLineAngle() << "\n" << "Text Alignment : "; if (ent->TextAlignment() == 0) + { S << "0 (Horizontal)\n"; + } else if (ent->TextAlignment() == 1) + { S << "1 (Parallel)\n"; + } else + { S << ent->TextAlignment() << " (Incorrect Value)\n"; + } S << "Text Level : " << ent->TextLevel(); switch (ent->TextLevel()) @@ -424,11 +469,17 @@ void IGESDimen_ToolDimensionDisplayData::OwnDump( S << "Arrow Head Orientation : " << ent->ArrowHeadOrientation(); if (ent->ArrowHeadOrientation() == 0) + { S << " (In, pointing out)\n"; + } else if (ent->ArrowHeadOrientation() == 1) + { S << " (Out, pointing in)\n"; + } else + { S << " (Incorrect Value)\n"; + } int nbnotes = ent->NbSupplementaryNotes(); S << " Primary Dimension Value : " << ent->InitialValue() << "\n" @@ -439,11 +490,13 @@ void IGESDimen_ToolDimensionDisplayData::OwnDump( IGESData_DumpVals(S, -level, 1, nbnotes, ent->EndIndex); S << "\n"; if (level > 4) + { for (int i = 1; i <= nbnotes; i++) { S << "[" << i << "]:\n" << "Supplementary Note : " << ent->SupplementaryNote(i) << ", Start Index : " << ent->StartIndex(i) << ", End Index : " << ent->EndIndex(i) << "\n"; } - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionTolerance.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionTolerance.cxx index e4ab131ca8..f0e06a0a6f 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionTolerance.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionTolerance.cxx @@ -47,19 +47,22 @@ void IGESDimen_ToolDimensionTolerance::ReadOwnParams( int tempPrecision; if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger(PR.Current(), "Number of properties", tempNbProps); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempNbProps = 8; +} PR.ReadInteger(PR.Current(), "Secondary Tolerance Flag", tempSecondTolFlag); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "Tolerance Type", tempTolTyp); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadInteger(PR.Current(), "Tolerance Placement Flag", tempTolPlaceFlag); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempTolPlaceFlag = 2; +} PR.ReadReal(PR.Current(), "Upper Tolerance", tempUpperTol); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadReal(PR.Current(), "Lower Tolerance", tempLowerTol); //szv#4:S4163:12Mar99 `st=` not needed @@ -123,6 +126,7 @@ bool IGESDimen_ToolDimensionTolerance::OwnCorrect( { bool res = (ent->NbPropertyValues() != 8); if (res) + { ent->Init(8, ent->SecondaryToleranceFlag(), ent->ToleranceType(), @@ -132,6 +136,7 @@ bool IGESDimen_ToolDimensionTolerance::OwnCorrect( (ent->SignSuppressionFlag() ? 1 : 0), ent->FractionFlag(), ent->Precision()); // nbpropertyvalues=8 + } return res; } @@ -157,15 +162,25 @@ void IGESDimen_ToolDimensionTolerance::OwnCheck( occ::handle& ach) const { if (ent->NbPropertyValues() != 8) + { ach->AddFail("Number of properties != 8"); + } if ((ent->SecondaryToleranceFlag() < 0) || (ent->SecondaryToleranceFlag() > 2)) + { ach->AddFail("Secondary Tolerance Flag != 0-2"); + } if ((ent->ToleranceType() < 1) || (ent->ToleranceType() > 10)) + { ach->AddFail("Tolerance Type != 1-10"); + } if ((ent->TolerancePlacementFlag() < 1) || (ent->TolerancePlacementFlag() > 4)) + { ach->AddFail("Tolerance Placement Flag != 1-4"); + } if ((ent->FractionFlag() < 0) || (ent->FractionFlag() > 2)) + { ach->AddFail("Fraction Flag != 0-2"); + } } void IGESDimen_ToolDimensionTolerance::OwnDump(const occ::handle& ent, @@ -182,5 +197,5 @@ void IGESDimen_ToolDimensionTolerance::OwnDump(const occ::handleLowerTolerance() << "\n" << "Sign Suppression Flag : " << (ent->SignSuppressionFlag() ? "True" : "False") << "\n" << "Fraction Flag : " << ent->FractionFlag() << "\n" - << "Precision : " << ent->Precision() << std::endl; + << "Precision : " << ent->Precision() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionUnits.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionUnits.cxx index 680a7023f5..46a79f7f8a 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionUnits.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionUnits.cxx @@ -48,18 +48,21 @@ void IGESDimen_ToolDimensionUnits::ReadOwnParams( occ::handle tempFormatString; if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger(PR.Current(), "Number of Properties", tempNbProps); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempNbProps = 6; +} PR.ReadInteger(PR.Current(), "Secondary Dimension Position", tempSecondDimenPos); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "Units Indicator", tempUnitsIndic); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadInteger(PR.Current(), "Character Set", tempCharSet); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempCharSet = 1; +} PR.ReadText(PR.Current(), "Format String", tempFormatString); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadInteger(PR.Current(), "Fraction Flag", tempFracFlag); //szv#4:S4163:12Mar99 `st=` not needed @@ -119,6 +122,7 @@ bool IGESDimen_ToolDimensionUnits::OwnCorrect( { bool res = (ent->NbPropertyValues() != 6); if (res) + { ent->Init(6, ent->SecondaryDimenPosition(), ent->UnitsIndicator(), @@ -126,6 +130,7 @@ bool IGESDimen_ToolDimensionUnits::OwnCorrect( ent->FormatString(), ent->FractionFlag(), ent->PrecisionOrDenominator()); + } return res; // nbpropertyvalues = 6 } @@ -150,13 +155,21 @@ void IGESDimen_ToolDimensionUnits::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 6) + { ach->AddFail("Number of properties != 6"); + } if (ent->SecondaryDimenPosition() < 0 || ent->SecondaryDimenPosition() > 4) + { ach->AddFail("Secondary Dimension Position != 0-4"); + } if ((ent->CharacterSet() != 1) && ((ent->CharacterSet() < 1001) || (ent->CharacterSet() > 1003))) + { ach->AddFail("Character Set != 1,1001-1003"); + } if ((ent->FractionFlag() != 0) && (ent->FractionFlag() != 1)) + { ach->AddFail("Fraction Flag != 0,1"); + } } void IGESDimen_ToolDimensionUnits::OwnDump(const occ::handle& ent, @@ -174,8 +187,12 @@ void IGESDimen_ToolDimensionUnits::OwnDump(const occ::handleFractionFlag(); if (ent->FractionFlag() == 0) + { S << " Decimal , Precision : "; + } else + { S << " Fraction , Denominator : "; - S << ent->PrecisionOrDenominator() << std::endl; + } + S << ent->PrecisionOrDenominator() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionedGeometry.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionedGeometry.cxx index 5fa3e7c5e7..5b2c859b31 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionedGeometry.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolDimensionedGeometry.cxx @@ -52,10 +52,12 @@ void IGESDimen_ToolDimensionedGeometry::ReadOwnParams( // clang-format on if (nbgeom > 0) + { PR.ReadEnts(IR, PR.CurrentList(nbgeom), "Geometry Entities", GeomEntities); // szv#4:S4163:12Mar99 `st=` not needed + } /* { GeomEntities = new NCollection_HArray1>(1,nbgeom); @@ -79,7 +81,9 @@ void IGESDimen_ToolDimensionedGeometry::WriteOwnParams( IW.Send(ent->NbGeometryEntities()); IW.Send(ent->DimensionEntity()); for (int upper = ent->NbGeometryEntities(), i = 1; i <= upper; i++) + { IW.Send(ent->GeometryEntity(i)); + } } void IGESDimen_ToolDimensionedGeometry::OwnShared( @@ -88,7 +92,9 @@ void IGESDimen_ToolDimensionedGeometry::OwnShared( { iter.GetOneItem(ent->DimensionEntity()); for (int upper = ent->NbGeometryEntities(), i = 1; i <= upper; i++) + { iter.GetOneItem(ent->GeometryEntity(i)); + } } void IGESDimen_ToolDimensionedGeometry::OwnCopy( @@ -113,13 +119,17 @@ bool IGESDimen_ToolDimensionedGeometry::OwnCorrect( const occ::handle& ent) const { if (ent->NbDimensions() == 1) + { return false; + } // force NbDimensions to 1 -> reconstruct int nb = ent->NbGeometryEntities(); occ::handle>> EntArray = new NCollection_HArray1>(1, nb); for (int i = 1; i <= nb; i++) + { EntArray->SetValue(i, ent->GeometryEntity(i)); + } ent->Init(1, ent->DimensionEntity(), EntArray); return true; } @@ -141,9 +151,13 @@ void IGESDimen_ToolDimensionedGeometry::OwnCheck( occ::handle& ach) const { if (ent->NbDimensions() != 1) + { ach->AddFail("NbDimensions != 1"); + } if (ent->UseFlag() > 3) + { ach->AddFail("Incorrect UseFlag"); + } } void IGESDimen_ToolDimensionedGeometry::OwnDump( @@ -163,5 +177,5 @@ void IGESDimen_ToolDimensionedGeometry::OwnDump( S << "\n" << "Geometry Entities : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbGeometryEntities(), ent->GeometryEntity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolFlagNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolFlagNote.cxx index dc7089b595..2949105145 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolFlagNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolFlagNote.cxx @@ -77,11 +77,15 @@ void IGESDimen_ToolFlagNote::ReadOwnParams(const occ::handle "Leaders", STANDARD_TYPE(IGESDimen_LeaderArrow), anentity)) + { leaders->SetValue(i, anentity); + } } } else if (nbval < 0) + { PR.AddFail("Number of Leaders: Less than zero"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(lowerLeft, angle, note, leaders); @@ -98,7 +102,9 @@ void IGESDimen_ToolFlagNote::WriteOwnParams(const occ::handleNbLeaders(); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Leader(i)); + } } void IGESDimen_ToolFlagNote::OwnShared(const occ::handle& ent, @@ -107,7 +113,9 @@ void IGESDimen_ToolFlagNote::OwnShared(const occ::handle& en iter.GetOneItem(ent->Note()); int upper = ent->NbLeaders(); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Leader(i)); + } } void IGESDimen_ToolFlagNote::OwnCopy(const occ::handle& another, @@ -167,5 +175,5 @@ void IGESDimen_ToolFlagNote::OwnDump(const occ::handle& ent, S << "\n" << "Number of Leaders : " << ent->NbLeaders() << " Leaders : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbLeaders(), ent->Leader); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralLabel.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralLabel.cxx index 45d6261e88..11020156c5 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralLabel.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralLabel.cxx @@ -55,11 +55,16 @@ void IGESDimen_ToolGeneralLabel::ReadOwnParams(const occ::handle 0) + { leaders = new NCollection_HArray1>(1, nbval); + } else + { PR.AddFail("Number of Leaders: Not Positive"); + } if (!leaders.IsNull()) + { for (int i = 1; i <= nbval; i++) { occ::handle anentity; @@ -70,8 +75,11 @@ void IGESDimen_ToolGeneralLabel::ReadOwnParams(const occ::handleSetValue(i, anentity); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(note, leaders); @@ -84,7 +92,9 @@ void IGESDimen_ToolGeneralLabel::WriteOwnParams(const occ::handleNote()); IW.Send(upper); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Leader(i)); + } } void IGESDimen_ToolGeneralLabel::OwnShared(const occ::handle& ent, @@ -93,7 +103,9 @@ void IGESDimen_ToolGeneralLabel::OwnShared(const occ::handleNbLeaders(); iter.GetOneItem(ent->Note()); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Leader(i)); + } } void IGESDimen_ToolGeneralLabel::OwnCopy(const occ::handle& another, @@ -145,5 +157,5 @@ void IGESDimen_ToolGeneralLabel::OwnDump(const occ::handleNbLeaders() << "\n" << "Leaders : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbLeaders(), ent->Leader); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralNote.cxx index d7afb33c3e..3c9d566039 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralNote.cxx @@ -78,7 +78,9 @@ void IGESDimen_ToolGeneralNote::ReadOwnParams(const occ::handle>(1, nbval); } else + { PR.AddFail("Number of Text Strings: Not Positive"); + } if (!nbChars.IsNull()) { @@ -99,15 +101,21 @@ void IGESDimen_ToolGeneralNote::ReadOwnParams(const occ::handleSetValue(i, nbChar); + } // st = PR.ReadReal(PR.Current(), "Box Width", boxWidth); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Box Width", boxWidth)) + { boxWidths->SetValue(i, boxWidth); + } // st = PR.ReadReal(PR.Current(), "Box Height", boxHeight); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Box Height", boxHeight)) + { boxHeights->SetValue(i, boxHeight); + } int curnum = PR.CurrentNumber(); if (PR.DefinedElseSkip()) @@ -121,12 +129,16 @@ void IGESDimen_ToolGeneralNote::ReadOwnParams(const occ::handleSetValue(i, fontEntity); fontCodes->SetValue(i, -1); } else + { fontCodes->SetValue(i, fontCode); + } } else { @@ -138,34 +150,48 @@ void IGESDimen_ToolGeneralNote::ReadOwnParams(const occ::handleSetValue(i, slantAngle); + } } else + { slantAngles->SetValue(i, M_PI / 2); + } // st = PR.ReadReal(PR.Current(), "Rotation Angle", rotationAngle); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Rotation Angle", rotationAngle)) + { rotationAngles->SetValue(i, rotationAngle); + } // st = PR.ReadInteger(PR.Current(), "Mirror Flag", mirrorFlag); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadInteger(PR.Current(), "Mirror Flag", mirrorFlag)) + { mirrorFlags->SetValue(i, mirrorFlag); + } // st = PR.ReadInteger(PR.Current(), "Rotate Flag", rotateFlag); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadInteger(PR.Current(), "Rotate Flag", rotateFlag)) + { rotateFlags->SetValue(i, rotateFlag); + } // st = PR.ReadXYZ(PR.CurrentList(1, 3), "Start Point", startPoint); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadXYZ(PR.CurrentList(1, 3), "Start Point", startPoint)) + { startPoints->SetValue(i, startPoint); + } // st = PR.ReadText(PR.Current(), "Text String", text); //szv#4:S4163:12Mar99 moved in if if (PR.ReadText(PR.Current(), "Text String", text)) + { texts->SetValue(i, text); + } } } // sln 28.09.2001, BUC61004, If the condition is false function ent->Init is not called in order @@ -201,9 +227,13 @@ void IGESDimen_ToolGeneralNote::WriteOwnParams(const occ::handleBoxWidth(i)); IW.Send(ent->BoxHeight(i)); if (ent->IsFontEntity(i)) + { IW.Send(ent->FontEntity(i), true); // negative + } else + { IW.Send(ent->FontCode(i)); + } IW.Send(ent->SlantAngle(i)); IW.Send(ent->RotationAngle(i)); IW.Send(ent->MirrorFlag(i)); @@ -222,7 +252,9 @@ void IGESDimen_ToolGeneralNote::OwnShared(const occ::handleIsFontEntity(i)) + { iter.GetOneItem(ent->FontEntity(i)); + } } } @@ -325,7 +357,9 @@ void IGESDimen_ToolGeneralNote::OwnCheck(const occ::handleFormNumber() < 0) || (ent->FormNumber() > 8)) && ((ent->FormNumber() < 100) || (ent->FormNumber() > 102)) && (ent->FormNumber() != 105)) + { ach->AddFail("Form Number: Not Valid"); + } int upper = ent->NbStrings(); for (int i = 1; i <= upper; i++) @@ -392,17 +426,19 @@ void IGESDimen_ToolGeneralNote::OwnDump(const occ::handle S << "\n"; } else + { S << "Font Code : " << ent->FontCode(i) << "\n" << "Slant Angle : " << ent->SlantAngle(i) << " " << "Rotation Angle : " << ent->RotationAngle(i) << " " << "Mirror Flag : " << ent->MirrorFlag(i) << " " << "Rotate Flag : " << ent->RotateFlag(i) << "\n" << "Start Point : "; + } IGESData_DumpXYZL(S, level, ent->StartPoint(i), ent->Location()); S << "\nText : "; IGESData_DumpString(S, ent->Text(i)); S << "\n"; } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralSymbol.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralSymbol.cxx index 07037b1a44..b45c2f8bf7 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralSymbol.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolGeneralSymbol.cxx @@ -48,17 +48,23 @@ void IGESDimen_ToolGeneralSymbol::ReadOwnParams(const occ::handle tempNote; if ((ent->FormNumber() == 0) && (!PR.IsParamEntity(PR.CurrentNumber()))) + { PR.SetCurrentNumber(PR.CurrentNumber() + 1); + } else + { PR.ReadEntity(IR, PR.Current(), "General Note Entity", STANDARD_TYPE(IGESDimen_GeneralNote), tempNote); // szv#4:S4163:12Mar99 `st=` not needed + } bool st = PR.ReadInteger(PR.Current(), "Number of Geometries", num); if (!st || num <= 0) + { PR.AddFail("Number of Geometries: Not Positive"); + } if (num > 0) { // clang-format off @@ -80,10 +86,15 @@ void IGESDimen_ToolGeneralSymbol::ReadOwnParams(const occ::handle 0) + { tempLeaders = new NCollection_HArray1>(1, num); + } else if (num < 0) + { PR.AddFail("Number of Leaders: Less than zero"); + } if (!tempLeaders.IsNull()) + { for (i = 1; i <= num; i++) { occ::handle tempEnt; @@ -94,8 +105,11 @@ void IGESDimen_ToolGeneralSymbol::ReadOwnParams(const occ::handleSetValue(i, tempEnt); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNote, tempGeoms, tempLeaders); @@ -108,10 +122,14 @@ void IGESDimen_ToolGeneralSymbol::WriteOwnParams(const occ::handleNote()); IW.Send(ent->NbGeomEntities()); for (num = ent->NbGeomEntities(), i = 1; i <= num; i++) + { IW.Send(ent->GeomEntity(i)); + } IW.Send(ent->NbLeaders()); for (num = ent->NbLeaders(), i = 1; i <= num; i++) + { IW.Send(ent->LeaderArrow(i)); + } } void IGESDimen_ToolGeneralSymbol::OwnShared(const occ::handle& ent, @@ -120,9 +138,13 @@ void IGESDimen_ToolGeneralSymbol::OwnShared(const occ::handleNote()); for (num = ent->NbGeomEntities(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->GeomEntity(i)); + } for (num = ent->NbLeaders(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->LeaderArrow(i)); + } } void IGESDimen_ToolGeneralSymbol::OwnCopy(const occ::handle& another, @@ -173,10 +195,16 @@ void IGESDimen_ToolGeneralSymbol::OwnCheck(const occ::handleFormNumber() < 0 || ent->FormNumber() > 3) && (ent->FormNumber() < 5001 || ent->FormNumber() > 9999)) + { ach->AddFail("Invalid Form Number"); + } if (ent->FormNumber() != 0) + { if (ent->Note().IsNull()) + { ach->AddFail("No General Note defined for form number non 0"); + } + } } void IGESDimen_ToolGeneralSymbol::OwnDump(const occ::handle& ent, @@ -192,5 +220,5 @@ void IGESDimen_ToolGeneralSymbol::OwnDump(const occ::handleNbGeomEntities(), ent->GeomEntity); S << "\nLeader Arrows : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbLeaders(), ent->LeaderArrow); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLeaderArrow.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLeaderArrow.cxx index d1c482a62e..6ace193c8a 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLeaderArrow.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLeaderArrow.cxx @@ -51,9 +51,13 @@ void IGESDimen_ToolLeaderArrow::ReadOwnParams(const occ::handle 0) + { segmentTails = new NCollection_HArray1(1, nbval); + } else + { PR.AddFail("Count of Segments: Not Positive"); + } // szv#4:S4163:12Mar99 `st=` not needed PR.ReadReal(PR.Current(), "Arrow Head Height", arrowHeadHeight); @@ -69,7 +73,9 @@ void IGESDimen_ToolLeaderArrow::ReadOwnParams(const occ::handleSetValue(i, tempXY); + } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails); @@ -158,5 +164,5 @@ void IGESDimen_ToolLeaderArrow::OwnDump(const occ::handle ent->SegmentTail, ent->Location(), ent->ZDepth()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLinearDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLinearDimension.cxx index 921fb27135..6342a34b57 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLinearDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolLinearDimension.cxx @@ -140,11 +140,17 @@ void IGESDimen_ToolLinearDimension::OwnDump(const occ::handleFormNumber() == 0) + { S << " (Undetermined Form)\n"; + } else if (ent->FormNumber() == 1) + { S << " (Diameter Form)\n"; + } else if (ent->FormNumber() == 2) + { S << " (Radius Form)\n"; + } S << "General Note Entity : "; dumper.Dump(ent->Note(), S, sublevel); S << "\n" @@ -159,5 +165,5 @@ void IGESDimen_ToolLinearDimension::OwnDump(const occ::handleSecondWitness(), S, sublevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewDimensionedGeometry.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewDimensionedGeometry.cxx index 83c64985dc..150e620f0f 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewDimensionedGeometry.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewDimensionedGeometry.cxx @@ -56,11 +56,15 @@ void IGESDimen_ToolNewDimensionedGeometry::ReadOwnParams( occ::handle> tempPoints; if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger(PR.Current(), "Number of Dimensions", tempNbDimens); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else + { tempNbDimens = 1; + } bool st = PR.ReadInteger(PR.Current(), "Number of Geometries", num); if (st && num > 0) @@ -70,7 +74,9 @@ void IGESDimen_ToolNewDimensionedGeometry::ReadOwnParams( tempPoints = new NCollection_HArray1(1, num); } else + { PR.AddFail("Number of Geometries: Not Positive"); + } // szv#4:S4163:12Mar99 `st=` not needed PR.ReadEntity(IR, PR.Current(), "Dimension Entity", tempDimen); @@ -78,6 +84,7 @@ void IGESDimen_ToolNewDimensionedGeometry::ReadOwnParams( PR.ReadReal(PR.Current(), "Angle Value", tempAngle); if (!tempGeomEnts.IsNull()) + { for (i = 1; i <= num; i++) { occ::handle tempEnt; @@ -95,6 +102,7 @@ void IGESDimen_ToolNewDimensionedGeometry::ReadOwnParams( PR.ReadXYZ(PR.CurrentList(1, 3), "Point", tempPnt); // szv#4:S4163:12Mar99 `st=` not needed tempPoints->SetValue(i, tempPnt); } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempNbDimens, @@ -133,7 +141,9 @@ void IGESDimen_ToolNewDimensionedGeometry::OwnShared( int i, num; iter.GetOneItem(ent->DimensionEntity()); for (num = ent->NbGeometries(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->GeometryEntity(i)); + } } void IGESDimen_ToolNewDimensionedGeometry::OwnCopy( @@ -178,7 +188,9 @@ bool IGESDimen_ToolNewDimensionedGeometry::OwnCorrect( ent->InitTransf(nultransf); } if (ent->NbDimensions() == 1) + { return res; + } // Force NbDimensions = 1 -> reconstruct int nb = ent->NbGeometries(); occ::handle>> tempGeomEnts = @@ -224,9 +236,13 @@ void IGESDimen_ToolNewDimensionedGeometry::OwnCheck( occ::handle& ach) const { if (ent->NbDimensions() != 1) + { ach->AddFail("Number of Dimensions != 1"); + } if (ent->HasTransf()) + { ach->AddWarning("Transformation Matrix exists, ignored"); + } } void IGESDimen_ToolNewDimensionedGeometry::OwnDump( @@ -249,6 +265,7 @@ void IGESDimen_ToolNewDimensionedGeometry::OwnDump( IGESData_DumpEntities(S, dumper, -level, 1, ent->NbGeometries(), ent->GeometryEntity); S << "\n"; if (level > 4) + { for (num = ent->NbGeometries(), i = 1; i <= num; i++) { S << "[" << i << "]:\n" @@ -259,5 +276,6 @@ void IGESDimen_ToolNewDimensionedGeometry::OwnDump( << "Point : "; IGESData_DumpXYZL(S, level, ent->Point(i), ent->Location()); } - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewGeneralNote.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewGeneralNote.cxx index 0faf7f632c..9ea71c7a32 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewGeneralNote.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolNewGeneralNote.cxx @@ -108,9 +108,12 @@ void IGESDimen_ToolNewGeneralNote::ReadOwnParams(const occ::handle>(1, nbval); } else + { PR.AddFail("Number of Text Strings: Not Positive"); + } if (!charDisplays.IsNull()) + { for (int i = 1; i <= nbval; i++) { int charDisplay; @@ -136,55 +139,77 @@ void IGESDimen_ToolNewGeneralNote::ReadOwnParams(const occ::handleSetValue(i, charDisplay); + } // st = PR.ReadReal(PR.Current(), "Character Width", charWidth); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Character Width", charWidth)) + { charWidths->SetValue(i, charWidth); + } // st = PR.ReadReal(PR.Current(), "Character Height", charHeight); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Character Height", charHeight)) + { charHeights->SetValue(i, charHeight); + } // st = PR.ReadReal(PR.Current(), "Inter-character space", interCharSpace); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Inter-character space", interCharSpace)) + { interCharSpaces->SetValue(i, interCharSpace); + } // st = PR.ReadReal(PR.Current(), "Interline space", interlineSpace); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Interline space", interlineSpace)) + { interlineSpaces->SetValue(i, interlineSpace); + } // st = PR.ReadInteger(PR.Current(), "Font Style", fontStyle); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadInteger(PR.Current(), "Font Style", fontStyle)) + { fontStyles->SetValue(i, fontStyle); + } // st = PR.ReadReal(PR.Current(), "Character Angle", charAngle); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Character Angle", charAngle)) + { charAngles->SetValue(i, charAngle); + } // st = PR.ReadText(PR.Current(),"Control Code String", controlCodeString); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadText(PR.Current(), "Control Code String", controlCodeString)) + { controlCodeStrings->SetValue(i, controlCodeString); + } // st = PR.ReadInteger(PR.Current(), "Number of Characters", nbChar); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "Number of Characters", nbChar)) + { nbChars->SetValue(i, nbChar); + } // st = PR.ReadReal(PR.Current(), "Box Width", boxWidth); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Box Width", boxWidth)) + { boxWidths->SetValue(i, boxWidth); + } // st = PR.ReadReal(PR.Current(), "Box Height", boxHeight); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Box Height", boxHeight)) + { boxHeights->SetValue(i, boxHeight); + } int curnum = PR.CurrentNumber(); if (PR.DefinedElseSkip()) @@ -198,7 +223,9 @@ void IGESDimen_ToolNewGeneralNote::ReadOwnParams(const occ::handleSetValue(i, charSetEntity); charSetCodes->SetValue(i, -1); } @@ -209,42 +236,59 @@ void IGESDimen_ToolNewGeneralNote::ReadOwnParams(const occ::handleSetValue(i, 1); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Slant Angle", slantAngle); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Slant Angle", slantAngle)) + { slantAngles->SetValue(i, slantAngle); + } } else + { slantAngles->SetValue(i, M_PI / 2); + } // st = PR.ReadReal(PR.Current(), "Rotation Angle", rotationAngle); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Rotation Angle", rotationAngle)) + { rotationAngles->SetValue(i, rotationAngle); + } // st = PR.ReadInteger(PR.Current(), "Mirror Flag", mirrorFlag); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadInteger(PR.Current(), "Mirror Flag", mirrorFlag)) + { mirrorFlags->SetValue(i, mirrorFlag); + } // st = PR.ReadInteger(PR.Current(), "Rotate Flag", rotateFlag); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadInteger(PR.Current(), "Rotate Flag", rotateFlag)) + { rotateFlags->SetValue(i, rotateFlag); + } // st = PR.ReadXYZ(PR.CurrentList(1, 3), "Start Point", startPoint); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadXYZ(PR.CurrentList(1, 3), "Start Point", startPoint)) + { startPoints->SetValue(i, startPoint); + } // st = PR.ReadText(PR.Current(), "Text String", text); //szv#4:S4163:12Mar99 moved in if if (PR.ReadText(PR.Current(), "Text String", text)) + { texts->SetValue(i, text); + } } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(width, @@ -306,9 +350,13 @@ void IGESDimen_ToolNewGeneralNote::WriteOwnParams(const occ::handleBoxWidth(i)); IW.Send(ent->BoxHeight(i)); if (ent->IsCharSetEntity(i)) + { IW.Send(ent->CharSetEntity(i), true); // negative + } else + { IW.Send(ent->CharSetCode(i)); + } IW.Send(ent->SlantAngle(i)); IW.Send(ent->RotationAngle(i)); IW.Send(ent->MirrorFlag(i)); @@ -328,7 +376,9 @@ void IGESDimen_ToolNewGeneralNote::OwnShared(const occ::handleIsCharSetEntity(i)) + { iter.GetOneItem(ent->CharSetEntity(i)); + } } } @@ -405,7 +455,9 @@ void IGESDimen_ToolNewGeneralNote::OwnCopy(const occ::handleSetValue(i, charSetEntity); } else + { charSetCodes->SetValue(i, another->CharSetCode(i)); + } slantAngles->SetValue(i, another->SlantAngle(i)); rotationAngles->SetValue(i, another->RotationAngle(i)); @@ -463,7 +515,9 @@ void IGESDimen_ToolNewGeneralNote::OwnCheck(const occ::handleJustifyCode(); if ((jcode < 0) || (jcode > 3)) + { ach->AddFail("Justify Code != 0, 1, 2, 3"); + } int upper = ent->NbStrings(); for (int i = 1; i <= upper; i++) { @@ -575,6 +629,7 @@ void IGESDimen_ToolNewGeneralNote::OwnDump(const occ::handleCharSetCode(i) << "\n" << "Slant Angle : " << ent->SlantAngle(i) << " " @@ -582,6 +637,7 @@ void IGESDimen_ToolNewGeneralNote::OwnDump(const occ::handleMirrorFlag(i) << " " << "Rotate Flag : " << ent->RotateFlag(i) << "\n" << "Start Point : "; + } IGESData_DumpXYZL(S, level, ent->StartPoint(i), ent->Location()); S << "Text : "; IGESData_DumpString(S, ent->Text(i)); @@ -589,5 +645,7 @@ void IGESDimen_ToolNewGeneralNote::OwnDump(const occ::handleFormNumber() == 0) // either WitnessLine or LeaderArrow { if (ent->IsLine()) + { IW.Send(ent->WitnessLine()); + } else + { IW.Send(ent->Leader()); + } } else // both WitnessLine and LeaderArrow { @@ -134,16 +140,22 @@ void IGESDimen_ToolOrdinateDimension::OwnCheck(const occ::handleWitnessLine().IsNull(); bool noleader = ent->Leader().IsNull(); if (nowitnes && noleader) + { ach->AddFail("Neither WitnessLine nor LeaderArrow is defined"); + } else if (ent->FormNumber() == 0) { if (!nowitnes && !noleader) + { ach->AddFail("Form 0 cannot afford both WitnessLine and LeaderArrow"); + } } else { if (nowitnes || noleader) + { ach->AddFail("Form 1 requires both WtnessLine and LeaderArrow"); + } } } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolPointDimension.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolPointDimension.cxx index a128270bfe..a070d47c18 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolPointDimension.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolPointDimension.cxx @@ -55,8 +55,10 @@ void IGESDimen_ToolPointDimension::ReadOwnParams(const occ::handleFormNumber() == 1) + { PR.ReadEntity(IR, PR.Current(), "Leader arrow 2", // clang-format off STANDARD_TYPE(IGESDimen_LeaderArrow), leadArr2, true); //szv#4:S4163:12Mar99 `st=` not needed +} // clang-format on DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -83,7 +85,9 @@ void IGESDimen_ToolRadiusDimension::WriteOwnParams( IW.Send(ent->Center().X()); IW.Send(ent->Center().Y()); if (ent->HasLeader2() || ent->FormNumber() == 1) + { IW.Send(ent->Leader2()); + } } void IGESDimen_ToolRadiusDimension::OwnShared(const occ::handle& ent, @@ -103,7 +107,9 @@ void IGESDimen_ToolRadiusDimension::OwnCopy(const occ::handleCenter().XY(); occ::handle leadArr2; if (another->HasLeader2()) + { leadArr2 = GetCasted(IGESDimen_LeaderArrow, TC.Transferred(another->Leader2())); + } ent->Init(tempNote, leadArr, arcCenter, leadArr2); ent->InitForm(another->FormNumber()); } @@ -127,7 +133,9 @@ void IGESDimen_ToolRadiusDimension::OwnCheck(const occ::handle& ach) const { if (ent->HasLeader2() && ent->FormNumber() == 0) + { ach->AddFail("Value of Form Number not consistent with presence of Leader2"); + } // Form 1 : Leader can be defined or not. Form 0 : only cannot } @@ -153,5 +161,5 @@ void IGESDimen_ToolRadiusDimension::OwnDump(const occ::handleLeader2(), S, sublevel); S << "\n"; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSection.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSection.cxx index 33c7a3d57b..0751fcfd87 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSection.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSection.cxx @@ -53,14 +53,16 @@ void IGESDimen_ToolSection::ReadOwnParams(const occ::handle& PR.ReadInteger(PR.Current(), "Interpretation Flag", datatype); //szv#4:S4163:12Mar99 `st=` not needed bool st = PR.ReadInteger(PR.Current(), "Number of data points", nbval); - if (st && nbval > 0) + if (st && nbval > 0) { dataPoints = new NCollection_HArray1(1, nbval); - else PR.AddFail("Number of data points: Not Positive"); + } else { PR.AddFail("Number of data points: Not Positive"); +} PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on if (!dataPoints.IsNull()) + { for (int i = 1; i <= nbval; i++) { gp_XY tempXY; @@ -68,6 +70,7 @@ void IGESDimen_ToolSection::ReadOwnParams(const occ::handle& // needed dataPoints->SetValue(i, tempXY); } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(datatype, zDisplacement, dataPoints); @@ -121,14 +124,20 @@ bool IGESDimen_ToolSection::OwnCorrect(const occ::handle& ent ent->InitLineFont(nulfont, 1); } if (ent->Datatype() == 1) + { return res; + } // Force DataType = 1 -> reconstruct int nb = ent->NbPoints(); if (nb == 0) + { return false; // nothing could be done (is this possible?) + } occ::handle> pts = new NCollection_HArray1(1, nb); for (int i = 1; i <= nb; i++) + { pts->SetValue(i, gp_XY(ent->Point(i).X(), ent->Point(i).Y())); + } ent->Init(1, ent->ZDisplacement(), pts); return true; } @@ -151,11 +160,17 @@ void IGESDimen_ToolSection::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->RankLineFont() != 1) + { ach->AddFail("Line Font Pattern != 1"); + } if (ent->Datatype() != 1) + { ach->AddFail("Interpretation Flag != 1"); + } if (ent->NbPoints() % 2 != 0) + { ach->AddFail("Number of data points is not even"); + } } void IGESDimen_ToolSection::OwnDump(const occ::handle& ent, @@ -175,5 +190,5 @@ void IGESDimen_ToolSection::OwnDump(const occ::handle& ent, ent->Point, ent->Location(), ent->ZDisplacement()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSectionedArea.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSectionedArea.cxx index 92fccc5a4c..1da2e0bf61 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSectionedArea.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolSectionedArea.cxx @@ -54,14 +54,17 @@ void IGESDimen_ToolSectionedArea::ReadOwnParams(const occ::handle 0) + if (st && nbislands > 0) { PR.ReadEnts (IR,PR.CurrentList(nbislands),"Island curves",tempIslands); //szv#4:S4163:12Mar99 `st=` not needed +} // clang-format on /* { @@ -91,7 +94,9 @@ void IGESDimen_ToolSectionedArea::WriteOwnParams(const occ::handleAngle()); IW.Send(length); for (i = 1; i <= length; i++) + { IW.Send(ent->IslandCurve(i)); + } } void IGESDimen_ToolSectionedArea::OwnShared(const occ::handle& ent, @@ -100,7 +105,9 @@ void IGESDimen_ToolSectionedArea::OwnShared(const occ::handleNbIslands(); iter.GetOneItem(ent->ExteriorCurve()); for (i = 1; i <= length; i++) + { iter.GetOneItem(ent->IslandCurve(i)); + } } void IGESDimen_ToolSectionedArea::OwnCopy(const occ::handle& another, diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolWitnessLine.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolWitnessLine.cxx index 04e9ba3774..7bcbcd3eb5 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolWitnessLine.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_ToolWitnessLine.cxx @@ -53,14 +53,16 @@ void IGESDimen_ToolWitnessLine::ReadOwnParams(const occ::handle 0) + if (st && nbval > 0) { dataPoints = new NCollection_HArray1(1, nbval); - else PR.AddFail("Number of data points: Not Positive"); + } else { PR.AddFail("Number of data points: Not Positive"); +} PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed // clang-format on if (!dataPoints.IsNull()) + { for (int i = 1; i <= nbval; i++) { gp_XY tempXY; @@ -68,6 +70,7 @@ void IGESDimen_ToolWitnessLine::ReadOwnParams(const occ::handleSetValue(i, tempXY); } + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(datatype, zDisplacement, dataPoints); @@ -120,14 +123,20 @@ bool IGESDimen_ToolWitnessLine::OwnCorrect(const occ::handleInitLineFont(nulfont, 1); } if (ent->Datatype() == 1) + { return res; + } // Force DataType = 1 -> reconstruct int nb = ent->NbPoints(); if (nb == 0) + { return false; // nothing could be done (is this possible?) + } occ::handle> pts = new NCollection_HArray1(1, nb); for (int i = 1; i <= nb; i++) + { pts->SetValue(i, gp_XY(ent->Point(i).X(), ent->Point(i).Y())); + } ent->Init(1, ent->ZDisplacement(), pts); return true; } @@ -150,13 +159,21 @@ void IGESDimen_ToolWitnessLine::OwnCheck(const occ::handle& ach) const { if (ent->RankLineFont() != 1) + { ach->AddFail("Line Font Pattern != 1"); + } if (ent->Datatype() != 1) + { ach->AddFail("Interpretation Flag != 1"); + } if (ent->NbPoints() < 3) + { ach->AddFail("Number of data points < 3"); + } if (ent->NbPoints() % 2 == 0) + { ach->AddFail("Number of data points is not odd"); + } } void IGESDimen_ToolWitnessLine::OwnDump(const occ::handle& ent, @@ -176,5 +193,5 @@ void IGESDimen_ToolWitnessLine::OwnDump(const occ::handle ent->Point, ent->Location(), ent->ZDisplacement()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_WitnessLine.cxx b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_WitnessLine.cxx index d08bfb009c..60cb58dd40 100644 --- a/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_WitnessLine.cxx +++ b/src/DataExchange/TKDEIGES/IGESDimen/IGESDimen_WitnessLine.cxx @@ -32,7 +32,9 @@ void IGESDimen_WitnessLine::Init(const int const occ::handle>& dataPoints) { if (dataPoints->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDimen_WitnessLine : Init"); + } theDatatype = dataType; theZDisplacement = aDisp; theDataPoints = dataPoints; @@ -66,6 +68,8 @@ gp_Pnt IGESDimen_WitnessLine::TransformedPoint(const int Index) const gp_XY point2d = theDataPoints->Value(Index); gp_XYZ point(point2d.X(), point2d.Y(), theZDisplacement); if (HasTransf()) + { Location().Transforms(point); + } return gp_Pnt(point); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_CircArraySubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_CircArraySubfigure.cxx index 8a36ef484f..bc6db981dd 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_CircArraySubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_CircArraySubfigure.cxx @@ -37,8 +37,12 @@ void IGESDraw_CircArraySubfigure::Init(const occ::handle& const occ::handle>& allNumPos) { if (!allNumPos.IsNull()) + { if (allNumPos->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_CircArraySubfigure : Init"); + } + } theBaseEntity = aBase; theNbLocations = aNumLocs; theCenter = aCenter; @@ -70,7 +74,9 @@ gp_Pnt IGESDraw_CircArraySubfigure::TransformedCenterPoint() const { gp_XYZ tempCenterPoint = theCenter; if (HasTransf()) + { Location().Transforms(tempCenterPoint); + } gp_Pnt tempRes(tempCenterPoint); return tempRes; @@ -116,8 +122,9 @@ bool IGESDraw_CircArraySubfigure::PositionNum(const int Index) const // array return theDoDontFlag else return !theDoDontFlag. if (thePositions.IsNull()) + { return theDoDontFlag; - + } else { int I; @@ -125,7 +132,9 @@ bool IGESDraw_CircArraySubfigure::PositionNum(const int Index) const for (I = 1; I <= up; I++) { if (thePositions->Value(I) == Index) + { return theDoDontFlag; + } } return (!theDoDontFlag); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ConnectPoint.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ConnectPoint.cxx index bfb3db63a8..56c50819d4 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ConnectPoint.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ConnectPoint.cxx @@ -67,7 +67,9 @@ gp_Pnt IGESDraw_ConnectPoint::TransformedPoint() const { gp_XYZ tempPoint = thePoint; if (HasTransf()) + { Location().Transforms(tempPoint); + } gp_Pnt tempRes(tempPoint); return (tempRes); diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Drawing.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Drawing.cxx index 99358e6c98..55a9fc4efa 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Drawing.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Drawing.cxx @@ -42,11 +42,17 @@ void IGESDraw_Drawing::Init( int Len = allViews->Length(); bool Flag = (allViewOrigins->Length() == Len); if (!Flag || allViews->Lower() != 1 || allViewOrigins->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_Drawing : Init"); + } } if (!allAnnotations.IsNull()) + { if (allAnnotations->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_Drawing : Init"); + } + } theViews = allViews; theViewOrigins = allViewOrigins; @@ -112,10 +118,14 @@ bool IGESDraw_Drawing::DrawingUnit(double& val) const val = 0.; occ::handle typunit = STANDARD_TYPE(IGESGraph_DrawingUnits); if (NbTypedProperties(typunit) != 1) + { return false; + } DeclareAndCast(IGESGraph_DrawingUnits, units, TypedProperty(typunit)); if (units.IsNull()) + { return false; + } val = units->UnitValue(); return true; } @@ -125,10 +135,14 @@ bool IGESDraw_Drawing::DrawingSize(double& X, double& Y) const X = Y = 0.; occ::handle typsize = STANDARD_TYPE(IGESGraph_DrawingSize); if (NbTypedProperties(typsize) != 1) + { return false; + } DeclareAndCast(IGESGraph_DrawingSize, size, TypedProperty(typsize)); if (size.IsNull()) + { return false; + } X = size->XSize(); Y = size->YSize(); return true; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_DrawingWithRotation.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_DrawingWithRotation.cxx index f4dc4b1b12..b835a4ad24 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_DrawingWithRotation.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_DrawingWithRotation.cxx @@ -41,10 +41,16 @@ void IGESDraw_DrawingWithRotation::Init( int Len = allViews->Length(); if (allViews->Lower() != 1 || (allViewOrigins->Lower() != 1 || allViewOrigins->Length() != Len) || (allOrientationAngles->Lower() != 1 || allOrientationAngles->Length() != Len)) + { throw Standard_DimensionMismatch("IGESDraw_DrawingWithRotation : Init"); + } if (!allAnnotations.IsNull()) + { if (allAnnotations->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_DrawingWithRotation : Init"); + } + } theViews = allViews; theViewOrigins = allViewOrigins; @@ -118,10 +124,14 @@ bool IGESDraw_DrawingWithRotation::DrawingUnit(double& val) const val = 0.; occ::handle typunit = STANDARD_TYPE(IGESGraph_DrawingUnits); if (NbTypedProperties(typunit) != 1) + { return false; + } DeclareAndCast(IGESGraph_DrawingUnits, units, TypedProperty(typunit)); if (units.IsNull()) + { return false; + } val = units->UnitValue(); return true; } @@ -131,10 +141,14 @@ bool IGESDraw_DrawingWithRotation::DrawingSize(double& X, double& Y) const X = Y = 0.; occ::handle typsize = STANDARD_TYPE(IGESGraph_DrawingSize); if (NbTypedProperties(typsize) != 1) + { return false; + } DeclareAndCast(IGESGraph_DrawingSize, size, TypedProperty(typsize)); if (size.IsNull()) + { return false; + } X = size->XSize(); Y = size->YSize(); return true; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_GeneralModule.cxx index 378ba54327..138a40a32a 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_GeneralModule.cxx @@ -65,7 +65,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolCircArraySubfigure tool; tool.OwnShared(anent, iter); } @@ -73,7 +75,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolConnectPoint tool; tool.OwnShared(anent, iter); } @@ -81,7 +85,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawing tool; tool.OwnShared(anent, iter); } @@ -89,7 +95,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawingWithRotation tool; tool.OwnShared(anent, iter); } @@ -97,7 +105,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolLabelDisplay tool; tool.OwnShared(anent, iter); } @@ -105,7 +115,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigure tool; tool.OwnShared(anent, iter); } @@ -113,7 +125,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigureDef tool; tool.OwnShared(anent, iter); } @@ -121,7 +135,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPerspectiveView tool; tool.OwnShared(anent, iter); } @@ -129,7 +145,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPlanar tool; tool.OwnShared(anent, iter); } @@ -137,7 +155,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolRectArraySubfigure tool; tool.OwnShared(anent, iter); } @@ -145,7 +165,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolSegmentedViewsVisible tool; tool.OwnShared(anent, iter); } @@ -153,7 +175,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolView tool; tool.OwnShared(anent, iter); } @@ -161,7 +185,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisible tool; tool.OwnShared(anent, iter); } @@ -169,7 +195,9 @@ void IGESDraw_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.OwnShared(anent, iter); } @@ -188,7 +216,9 @@ void IGESDraw_GeneralModule::OwnImpliedCase(const int case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisible tool; tool.OwnImplied(anent, iter); } @@ -196,7 +226,9 @@ void IGESDraw_GeneralModule::OwnImpliedCase(const int case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.OwnImplied(anent, iter); } @@ -215,98 +247,126 @@ IGESData_DirChecker IGESDraw_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolCircArraySubfigure tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolConnectPoint tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolDrawing tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolDrawingWithRotation tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolLabelDisplay tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolNetworkSubfigure tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolNetworkSubfigureDef tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolPerspectiveView tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolPlanar tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolRectArraySubfigure tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolSegmentedViewsVisible tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolView tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisible tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisibleWithAttr tool; return tool.DirChecker(anent); } @@ -326,7 +386,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolCircArraySubfigure tool; tool.OwnCheck(anent, shares, ach); } @@ -334,7 +396,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolConnectPoint tool; tool.OwnCheck(anent, shares, ach); } @@ -342,7 +406,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawing tool; tool.OwnCheck(anent, shares, ach); } @@ -350,7 +416,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawingWithRotation tool; tool.OwnCheck(anent, shares, ach); } @@ -358,7 +426,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolLabelDisplay tool; tool.OwnCheck(anent, shares, ach); } @@ -366,7 +436,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigure tool; tool.OwnCheck(anent, shares, ach); } @@ -374,7 +446,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigureDef tool; tool.OwnCheck(anent, shares, ach); } @@ -382,7 +456,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPerspectiveView tool; tool.OwnCheck(anent, shares, ach); } @@ -390,7 +466,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPlanar tool; tool.OwnCheck(anent, shares, ach); } @@ -398,7 +476,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolRectArraySubfigure tool; tool.OwnCheck(anent, shares, ach); } @@ -406,7 +486,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolSegmentedViewsVisible tool; tool.OwnCheck(anent, shares, ach); } @@ -414,7 +496,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolView tool; tool.OwnCheck(anent, shares, ach); } @@ -422,7 +506,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisible tool; tool.OwnCheck(anent, shares, ach); } @@ -430,7 +516,9 @@ void IGESDraw_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.OwnCheck(anent, shares, ach); } @@ -655,8 +743,12 @@ int IGESDraw_GeneralModule::CategoryNumber(const int CN, const Interface_ShareTool&) const { if (CN == 9) + { return Interface_Category::Number("Auxiliary"); + } if (CN == 1 || CN == 2 || CN == 10) + { return Interface_Category::Number("Structure"); + } return Interface_Category::Number("Drawing"); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_LabelDisplay.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_LabelDisplay.cxx index 206d2e052f..68d77a6b01 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_LabelDisplay.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_LabelDisplay.cxx @@ -40,7 +40,9 @@ void IGESDraw_LabelDisplay::Init( || (allLeaderEntities->Lower() != 1 || allLeaderEntities->Length() != Ln) || (allLabelLevels->Lower() != 1 || allLabelLevels->Length() != Ln) || (allDisplayedEntities->Lower() != 1 || allDisplayedEntities->Length() != Ln)) + { throw Standard_DimensionMismatch("IGESDraw_LabelDisplay : Init"); + } theViews = allViews; theTextLocations = allTextLocations; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigure.cxx index 9b98a18d1d..8381930580 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigure.cxx @@ -39,8 +39,12 @@ void IGESDraw_NetworkSubfigure::Init( const occ::handle>>& allConnectPoints) { if (!allConnectPoints.IsNull()) + { if (allConnectPoints->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_NetworkSubfigure : Init"); + } + } theSubfigureDefinition = aDefinition; theTranslation = aTranslation; theScaleFactor = aScaleFactor; @@ -65,7 +69,9 @@ gp_XYZ IGESDraw_NetworkSubfigure::TransformedTranslation() const { gp_XYZ TempXYZ = theTranslation; if (HasTransf()) + { Location().Transforms(TempXYZ); + } return (TempXYZ); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigureDef.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigureDef.cxx index 896fdb972d..b7a94a9557 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigureDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_NetworkSubfigureDef.cxx @@ -36,8 +36,12 @@ void IGESDraw_NetworkSubfigureDef::Init( const occ::handle>>& allPointEntities) { if (!allPointEntities.IsNull()) + { if (allPointEntities->Lower() != 1 || allEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_NetworkSubfigureDef : Init"); + } + } theDepth = aDepth; theName = aName; theEntities = allEntities; @@ -97,7 +101,9 @@ int IGESDraw_NetworkSubfigureDef::NbPointEntities() const bool IGESDraw_NetworkSubfigureDef::HasPointEntity(const int Index) const { if (thePointEntities.IsNull()) + { return false; + } return (!thePointEntities->Value(Index).IsNull()); // if Index is out of bound HArray1 will raise OutOfRange exception } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Planar.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Planar.cxx index 5619829cf0..91c8becfba 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Planar.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Planar.cxx @@ -31,8 +31,12 @@ void IGESDraw_Planar::Init( const occ::handle>>& allEntities) { if (!allEntities.IsNull()) + { if (allEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_Planar : Init"); + } + } theNbMatrices = nbMats; theTransformationMatrix = aTransformationMatrix; theEntities = allEntities; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Protocol.cxx index 68bdfab05e..e73e473eb0 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_Protocol.cxx @@ -49,32 +49,60 @@ occ::handle IGESDraw_Protocol::Resource(const int /*num*/) c int IGESDraw_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESDraw_CircArraySubfigure)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESDraw_ConnectPoint)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESDraw_Drawing)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESDraw_DrawingWithRotation)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESDraw_LabelDisplay)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESDraw_NetworkSubfigure)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESDraw_NetworkSubfigureDef)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESDraw_PerspectiveView)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESDraw_Planar)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESDraw_RectArraySubfigure)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESDraw_SegmentedViewsVisible)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESDraw_View)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESDraw_ViewsVisible)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESDraw_ViewsVisibleWithAttr)) + { return 14; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ReadWriteModule.cxx index f8b44295cd..2abf4d5669 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ReadWriteModule.cxx @@ -81,9 +81,13 @@ int IGESDraw_ReadWriteModule::CaseIGES(const int typenum, const int formnum) con return formnum + 3; // 0->3 1->4 case 410: if (formnum == 0) + { return 12; + } else if (formnum == 1) + { return 8; + } break; case 412: return 10; @@ -107,7 +111,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolCircArraySubfigure tool; tool.ReadOwnParams(anent, IR, PR); } @@ -115,7 +121,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolConnectPoint tool; tool.ReadOwnParams(anent, IR, PR); } @@ -123,7 +131,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawing tool; tool.ReadOwnParams(anent, IR, PR); } @@ -131,7 +141,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawingWithRotation tool; tool.ReadOwnParams(anent, IR, PR); } @@ -139,7 +151,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolLabelDisplay tool; tool.ReadOwnParams(anent, IR, PR); } @@ -147,7 +161,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigure tool; tool.ReadOwnParams(anent, IR, PR); } @@ -155,7 +171,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigureDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -163,7 +181,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPerspectiveView tool; tool.ReadOwnParams(anent, IR, PR); } @@ -171,7 +191,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPlanar tool; tool.ReadOwnParams(anent, IR, PR); } @@ -179,7 +201,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolRectArraySubfigure tool; tool.ReadOwnParams(anent, IR, PR); } @@ -187,7 +211,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolSegmentedViewsVisible tool; tool.ReadOwnParams(anent, IR, PR); } @@ -195,7 +221,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolView tool; tool.ReadOwnParams(anent, IR, PR); } @@ -203,7 +231,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisible tool; tool.ReadOwnParams(anent, IR, PR); } @@ -211,7 +241,9 @@ void IGESDraw_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.ReadOwnParams(anent, IR, PR); } @@ -230,7 +262,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolCircArraySubfigure tool; tool.WriteOwnParams(anent, IW); } @@ -238,7 +272,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolConnectPoint tool; tool.WriteOwnParams(anent, IW); } @@ -246,7 +282,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawing tool; tool.WriteOwnParams(anent, IW); } @@ -254,7 +292,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawingWithRotation tool; tool.WriteOwnParams(anent, IW); } @@ -262,7 +302,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolLabelDisplay tool; tool.WriteOwnParams(anent, IW); } @@ -270,7 +312,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigure tool; tool.WriteOwnParams(anent, IW); } @@ -278,7 +322,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigureDef tool; tool.WriteOwnParams(anent, IW); } @@ -286,7 +332,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPerspectiveView tool; tool.WriteOwnParams(anent, IW); } @@ -294,7 +342,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPlanar tool; tool.WriteOwnParams(anent, IW); } @@ -302,7 +352,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolRectArraySubfigure tool; tool.WriteOwnParams(anent, IW); } @@ -310,7 +362,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolSegmentedViewsVisible tool; tool.WriteOwnParams(anent, IW); } @@ -318,7 +372,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolView tool; tool.WriteOwnParams(anent, IW); } @@ -326,7 +382,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisible tool; tool.WriteOwnParams(anent, IW); } @@ -334,7 +392,9 @@ void IGESDraw_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_RectArraySubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_RectArraySubfigure.cxx index 5cee4aab9a..9b177c4719 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_RectArraySubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_RectArraySubfigure.cxx @@ -39,8 +39,12 @@ void IGESDraw_RectArraySubfigure::Init(const occ::handle& const occ::handle>& allNumPos) { if (!allNumPos.IsNull()) + { if (allNumPos->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_RectArraySubfigure : Init"); + } + } theBaseEntity = aBase; theScaleFactor = aScale; theLowerLeftCorner = aCorner; @@ -74,7 +78,9 @@ gp_Pnt IGESDraw_RectArraySubfigure::TransformedLowerLeftCorner() const { gp_XYZ tempLowerLeftCorner = theLowerLeftCorner; if (HasTransf()) + { Location().Transforms(tempLowerLeftCorner); + } gp_Pnt tempRes(tempLowerLeftCorner); return (tempRes); @@ -128,14 +134,18 @@ bool IGESDraw_RectArraySubfigure::PositionNum(const int Index) const // array return theDoDontFlag else return !theDoDontFlag. if (thePositions.IsNull()) + { return theDoDontFlag; + } int I; int up = thePositions->Upper(); for (I = 1; I <= up; I++) { if (thePositions->Value(I) == Index) + { return theDoDontFlag; + } } return (!theDoDontFlag); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SegmentedViewsVisible.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SegmentedViewsVisible.cxx index eba5c238f9..81bfcf176c 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SegmentedViewsVisible.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SegmentedViewsVisible.cxx @@ -45,7 +45,9 @@ void IGESDraw_SegmentedViewsVisible::Init( || (allLineFontValues->Lower() != 1 || allLineFontValues->Length() != Len) || (allLineFontDefinitions->Lower() != 1 || allLineFontDefinitions->Length() != Len) || (allLineWeights->Lower() != 1 || allLineWeights->Length() != Len)) + { throw Standard_DimensionMismatch("IGESDraw_SegmentedViewsVisible : Init"); + } theViews = allViews; theBreakpointParameters = allBreakpointParameters; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SpecificModule.cxx index d80889c112..6540f682c5 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_SpecificModule.cxx @@ -61,7 +61,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 1: { DeclareAndCast(IGESDraw_CircArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolCircArraySubfigure tool; tool.OwnDump(anent, dumper, S, own); } @@ -69,7 +71,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 2: { DeclareAndCast(IGESDraw_ConnectPoint, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolConnectPoint tool; tool.OwnDump(anent, dumper, S, own); } @@ -77,7 +81,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawing tool; tool.OwnDump(anent, dumper, S, own); } @@ -85,7 +91,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolDrawingWithRotation tool; tool.OwnDump(anent, dumper, S, own); } @@ -93,7 +101,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 5: { DeclareAndCast(IGESDraw_LabelDisplay, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolLabelDisplay tool; tool.OwnDump(anent, dumper, S, own); } @@ -101,7 +111,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 6: { DeclareAndCast(IGESDraw_NetworkSubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigure tool; tool.OwnDump(anent, dumper, S, own); } @@ -109,7 +121,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 7: { DeclareAndCast(IGESDraw_NetworkSubfigureDef, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolNetworkSubfigureDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -117,7 +131,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 8: { DeclareAndCast(IGESDraw_PerspectiveView, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPerspectiveView tool; tool.OwnDump(anent, dumper, S, own); } @@ -125,7 +141,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolPlanar tool; tool.OwnDump(anent, dumper, S, own); } @@ -133,7 +151,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 10: { DeclareAndCast(IGESDraw_RectArraySubfigure, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolRectArraySubfigure tool; tool.OwnDump(anent, dumper, S, own); } @@ -141,7 +161,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 11: { DeclareAndCast(IGESDraw_SegmentedViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolSegmentedViewsVisible tool; tool.OwnDump(anent, dumper, S, own); } @@ -149,7 +171,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 12: { DeclareAndCast(IGESDraw_View, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolView tool; tool.OwnDump(anent, dumper, S, own); } @@ -157,7 +181,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisible tool; tool.OwnDump(anent, dumper, S, own); } @@ -165,7 +191,9 @@ void IGESDraw_SpecificModule::OwnDump(const int CN case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { return; + } IGESDraw_ToolViewsVisibleWithAttr tool; tool.OwnDump(anent, dumper, S, own); } @@ -184,35 +212,45 @@ bool IGESDraw_SpecificModule::OwnCorrect(const int case 3: { DeclareAndCast(IGESDraw_Drawing, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolDrawing tool; return tool.OwnCorrect(anent); } case 4: { DeclareAndCast(IGESDraw_DrawingWithRotation, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolDrawingWithRotation tool; return tool.OwnCorrect(anent); } case 9: { DeclareAndCast(IGESDraw_Planar, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolPlanar tool; return tool.OwnCorrect(anent); } case 13: { DeclareAndCast(IGESDraw_ViewsVisible, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisible tool; return tool.OwnCorrect(anent); } case 14: { DeclareAndCast(IGESDraw_ViewsVisibleWithAttr, anent, ent); if (anent.IsNull()) + { break; + } IGESDraw_ToolViewsVisibleWithAttr tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolCircArraySubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolCircArraySubfigure.cxx index 15d44e70a7..bdf0131a8b 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolCircArraySubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolCircArraySubfigure.cxx @@ -64,9 +64,13 @@ void IGESDraw_ToolCircArraySubfigure::ReadOwnParams( { // Initialise HArray1 only if there is no error reading its Length if (tempListCount > 0) + { tempNumPos = new NCollection_HArray1(1, tempListCount); + } else if (tempListCount < 0) + { PR.AddFail("DO-DONT List Count : Less than Zero"); + } } PR.ReadInteger(PR.Current(), "DO-DONT Flag", tempFlag); // szv#4:S4163:12Mar99 `st=` not needed @@ -81,7 +85,9 @@ void IGESDraw_ToolCircArraySubfigure::ReadOwnParams( // st = PR.ReadInteger(PR.Current(), "Number Of Position To Process", // tempPosition); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Number Of Position To Process", tempPosition)) + { tempNumPos->SetValue(I, tempPosition); + } } } @@ -114,7 +120,9 @@ void IGESDraw_ToolCircArraySubfigure::WriteOwnParams( int I; int up = ent->ListCount(); for (I = 1; I <= up; I++) + { IW.Send(ent->ListPosition(I)); + } } void IGESDraw_ToolCircArraySubfigure::OwnShared( @@ -197,10 +205,14 @@ void IGESDraw_ToolCircArraySubfigure::OwnDump(const occ::handleDeltaAngle() << "\n" << "Do-Dont Flag : "; if (ent->DoDontFlag()) + { S << "Dont\n"; + } else + { S << "Do\n"; + } S << "The Do-Dont List : "; IGESData_DumpVals(S, level, 1, ent->ListCount(), ent->ListPosition); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolConnectPoint.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolConnectPoint.cxx index 7581744f5c..463412b529 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolConnectPoint.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolConnectPoint.cxx @@ -94,11 +94,15 @@ void IGESDraw_ToolConnectPoint::ReadOwnParams(const occ::handleTypeFlag() > 2) && (ent->TypeFlag() < 101)) || ((ent->TypeFlag() > 104) && (ent->TypeFlag() < 201)) || ((ent->TypeFlag() > 203) && (ent->TypeFlag() < 5001))) + { ach->AddFail("TypeFlag has Invalid value"); + } if ((ent->FunctionFlag() < 0) || (ent->FunctionFlag() > 2)) + { ach->AddFail("FunctionFlag has Invalid value"); + } if ((ent->FunctionCode() < 0) || (ent->FunctionCode() > 9999) || ((ent->FunctionCode() > 49) && (ent->FunctionCode() < 98)) || ((ent->FunctionCode() > 99) && (ent->FunctionCode() < 5001))) + { ach->AddFail("FunctionCode has Invalid value"); + } // if ((ent->SwapFlag() < 0) || (ent->SwapFlag() > 1)) //szv#4:S4163:12Mar99 SGI warns if ((ent->SwapFlag() != 0) && (ent->SwapFlag() != 1)) + { ach->AddFail("SwapFlag has Invalid value"); + } } void IGESDraw_ToolConnectPoint::OwnDump(const occ::handle& ent, @@ -264,5 +276,5 @@ void IGESDraw_ToolConnectPoint::OwnDump(const occ::handle << "Swap Flag : " << (ent->SwapFlag() ? "True" : "False") << "\n" << "Owner Subfigure Entity : "; dumper.Dump(ent->OwnerSubfigure(), S, tempSubLevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawing.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawing.cxx index 53d515f136..d98b8839aa 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawing.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawing.cxx @@ -73,17 +73,23 @@ void IGESDraw_ToolDrawing::ReadOwnParams(const occ::handle& STANDARD_TYPE(IGESData_ViewKindEntity), tempView, true)) + { views->SetValue(i, tempView); + } // Reading viewOrigins(HArray1OfXY) // st = PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY)) + { viewOrigins->SetValue(i, tempXY); + } } } else if (nbval < 0) + { PR.AddFail("Count of view entities : Less than zero"); + } // Reading nbval(No. of Annotation Entities) // st = PR.ReadInteger(PR.Current(),"Count of array of Annotation entities", nbval); @@ -91,24 +97,28 @@ void IGESDraw_ToolDrawing::ReadOwnParams(const occ::handle& if (PR.ReadInteger(PR.Current(), "Count of array of Annotation entities", nbval)) { if (nbval > 0) + { // clang-format off PR.ReadEnts (IR,PR.CurrentList(nbval), "Annotation Entities", annotations); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on - /* - { - // Reading annotations(HArray1OfIGESEntity) - annotations = new NCollection_HArray1>(1, nbval); - occ::handle tempAnnotation; - for (int i = 1; i <= nbval; i++) - { - st = PR.ReadEntity - (IR, PR.Current(), "annotation entity", tempAnnotation,true); - if (st) annotations->SetValue(i, tempAnnotation); - } - } - */ + // clang-format on + /* + { + // Reading annotations(HArray1OfIGESEntity) + annotations = new NCollection_HArray1>(1, nbval); + occ::handle tempAnnotation; + for (int i = 1; i <= nbval; i++) + { + st = PR.ReadEntity + (IR, PR.Current(), "annotation entity", tempAnnotation,true); + if (st) annotations->SetValue(i, tempAnnotation); + } + } + */ + } else if (nbval < 0) + { PR.AddFail("Count of Annotation entities : Less than zero"); + } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -131,7 +141,9 @@ void IGESDraw_ToolDrawing::WriteOwnParams(const occ::handle& e Up = ent->NbAnnotations(); IW.Send(Up); for (i = 1; i <= Up; i++) + { IW.Send(ent->Annotation(i)); + } } void IGESDraw_ToolDrawing::OwnShared(const occ::handle& ent, @@ -140,11 +152,15 @@ void IGESDraw_ToolDrawing::OwnShared(const occ::handle& ent, int Up = ent->NbViews(); int i; // svv Jan 10 2000 : porting on DEC for (i = 1; i <= Up; i++) + { iter.GetOneItem(ent->ViewItem(i)); + } Up = ent->NbAnnotations(); for (i = 1; i <= Up; i++) + { iter.GetOneItem(ent->Annotation(i)); + } } void IGESDraw_ToolDrawing::OwnCopy(const occ::handle& another, @@ -194,12 +210,18 @@ bool IGESDraw_ToolDrawing::OwnCorrect(const occ::handle& ent) { occ::handle val = ent->ViewItem(i); if (val.IsNull()) + { nbtrue--; + } else if (val->TypeNumber() == 0) + { nbtrue--; + } } if (nbtrue == nb) + { return false; + } occ::handle>> views; occ::handle> viewOrigins; if (nbtrue > 0) @@ -212,9 +234,13 @@ bool IGESDraw_ToolDrawing::OwnCorrect(const occ::handle& ent) { occ::handle val = ent->ViewItem(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; views->SetValue(nbtrue, val); viewOrigins->SetValue(nbtrue, ent->ViewOrigin(i).XY()); @@ -225,7 +251,9 @@ bool IGESDraw_ToolDrawing::OwnCorrect(const occ::handle& ent) occ::handle>> annotations = new NCollection_HArray1>(1, nbanot); for (i = 1; i <= nbanot; i++) + { annotations->SetValue(i, ent->Annotation(i)); + } ent->Init(views, viewOrigins, annotations); return true; @@ -256,9 +284,13 @@ void IGESDraw_ToolDrawing::OwnCheck(const occ::handle& ent, { occ::handle tempView = ent->ViewItem(i); if (tempView.IsNull()) + { ianul = true; + } else if (tempView->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one View is Null"); @@ -270,9 +302,13 @@ void IGESDraw_ToolDrawing::OwnCheck(const occ::handle& ent, { occ::handle ann = ent->Annotation(i); if (ann.IsNull()) + { ianul = true; + } else if (ann->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one Annotation is Null"); @@ -317,5 +353,5 @@ void IGESDraw_ToolDrawing::OwnDump(const occ::handle& ent, } S << "\nAnnotation Entities : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbAnnotations(), ent->Annotation); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawingWithRotation.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawingWithRotation.cxx index 57fade2332..d1c4e8f217 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawingWithRotation.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolDrawingWithRotation.cxx @@ -77,13 +77,17 @@ void IGESDraw_ToolDrawingWithRotation::ReadOwnParams( STANDARD_TYPE(IGESData_ViewKindEntity), tempView, true)) + { views->SetValue(i, tempView); + } // Reading viewOrigins(HArray1OfXY) // st = PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY)) + { viewOrigins->SetValue(i, tempXY); + } if (PR.DefinedElseSkip()) { @@ -91,14 +95,20 @@ void IGESDraw_ToolDrawingWithRotation::ReadOwnParams( // st = PR.ReadReal(PR.Current(), "array viewOrigins", tempOrient); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "array viewOrigins", tempOrient)) + { orientationAngles->SetValue(i, tempOrient); + } } else + { orientationAngles->SetValue(i, 0.0); // Default Value + } } } else if (nbval <= 0) + { PR.AddFail("Count of view entities : Not Positive"); + } // Reading nbval(No. of Annotation Entities) // st = PR.ReadInteger(PR.Current(), "Count of array of Annotation entities", nbval); @@ -106,24 +116,28 @@ void IGESDraw_ToolDrawingWithRotation::ReadOwnParams( if (PR.ReadInteger(PR.Current(), "Count of array of Annotation entities", nbval)) { if (nbval > 0) + { // clang-format off PR.ReadEnts (IR,PR.CurrentList(nbval), "Annotation Entities", annotations); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on - /* - { - // Reading annotations(HArray1OfIGESEntity) - annotations = new NCollection_HArray1>(1, nbval); - occ::handle tempAnnotation; - for (int i = 1; i <= nbval; i++) - { - st = PR.ReadEntity - (IR, PR.Current(), "annotation entity", tempAnnotation,true); - if (st) annotations->SetValue(i, tempAnnotation); - } - } - */ + // clang-format on + /* + { + // Reading annotations(HArray1OfIGESEntity) + annotations = new NCollection_HArray1>(1, nbval); + occ::handle tempAnnotation; + for (int i = 1; i <= nbval; i++) + { + st = PR.ReadEntity + (IR, PR.Current(), "annotation entity", tempAnnotation,true); + if (st) annotations->SetValue(i, tempAnnotation); + } + } + */ + } else if (nbval < 0) + { PR.AddFail("Count of Annotation entities : Less than zero"); + } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -148,7 +162,9 @@ void IGESDraw_ToolDrawingWithRotation::WriteOwnParams( Up = ent->NbAnnotations(); IW.Send(Up); for (i = 1; i <= Up; i++) + { IW.Send(ent->Annotation(i)); + } } void IGESDraw_ToolDrawingWithRotation::OwnShared( @@ -158,10 +174,14 @@ void IGESDraw_ToolDrawingWithRotation::OwnShared( int Up = ent->NbViews(); int i; // svv Jan 10 2000 : porting on DEC for (i = 1; i <= Up; i++) + { iter.GetOneItem(ent->ViewItem(i)); + } Up = ent->NbAnnotations(); for (i = 1; i <= Up; i++) + { iter.GetOneItem(ent->Annotation(i)); + } } void IGESDraw_ToolDrawingWithRotation::OwnCopy( @@ -215,12 +235,18 @@ bool IGESDraw_ToolDrawingWithRotation::OwnCorrect( { occ::handle val = ent->ViewItem(i); if (val.IsNull()) + { nbtrue--; + } else if (val->TypeNumber() == 0) + { nbtrue--; + } } if (nbtrue == nb) + { return false; + } occ::handle>> views; occ::handle> viewOrigins; occ::handle> orientationAngles; @@ -235,9 +261,13 @@ bool IGESDraw_ToolDrawingWithRotation::OwnCorrect( { occ::handle val = ent->ViewItem(i); if (val.IsNull()) + { continue; + } else if (val->TypeNumber() == 0) + { continue; + } nbtrue++; views->SetValue(nbtrue, val); viewOrigins->SetValue(nbtrue, ent->ViewOrigin(i).XY()); @@ -249,7 +279,9 @@ bool IGESDraw_ToolDrawingWithRotation::OwnCorrect( occ::handle>> annotations = new NCollection_HArray1>(1, nbanot); for (i = 1; i <= nbanot; i++) + { annotations->SetValue(i, ent->Annotation(i)); + } ent->Init(views, viewOrigins, orientationAngles, annotations); return true; @@ -281,9 +313,13 @@ void IGESDraw_ToolDrawingWithRotation::OwnCheck( { occ::handle tempView = ent->ViewItem(i); if (tempView.IsNull()) + { ianul = true; + } else if (tempView->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one View is Null"); @@ -295,9 +331,13 @@ void IGESDraw_ToolDrawingWithRotation::OwnCheck( { occ::handle ann = ent->Annotation(i); if (ann.IsNull()) + { ianul = true; + } else if (ann->TypeNumber() == 0) + { ianul = true; + } if (ianul) { ach->AddWarning("At least one Annotation is Null"); @@ -336,5 +376,5 @@ void IGESDraw_ToolDrawingWithRotation::OwnDump(const occ::handleNbAnnotations(), ent->Annotation); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolLabelDisplay.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolLabelDisplay.cxx index 3c48153c50..16eeabe0f2 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolLabelDisplay.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolLabelDisplay.cxx @@ -78,13 +78,17 @@ void IGESDraw_ToolLabelDisplay::ReadOwnParams(const occ::handleSetValue(i, tempView); + } // Reading textLocations(HArray1OfXYZ) // st = PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ)) + { textLocations->SetValue(i, tempXYZ); + } // Reading leaderEntities(HArray1OfLeaderArrow) // st = PR.ReadEntity (IR, PR.Current(), "Instance of LeaderArrow", @@ -94,23 +98,31 @@ void IGESDraw_ToolLabelDisplay::ReadOwnParams(const occ::handleSetValue(i, tempLeaderArrow); + } // Reading labelLevels(HArray1OfInteger) // st = PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel)) + { labelLevels->SetValue(i, tempLabel); + } // Reading displayedEntities(HArray1OfIGESEntity) // st = PR.ReadEntity (IR, PR.Current(), "displayedEntities entity", // tempDisplayedEntity); //szv#4:S4163:12Mar99 moved in if if (PR.ReadEntity(IR, PR.Current(), "displayedEntities entity", tempDisplayedEntity)) + { displayedEntities->SetValue(i, tempDisplayedEntity); + } } } else + { PR.AddFail("No. of Label placements : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(views, textLocations, leaderEntities, labelLevels, displayedEntities); @@ -233,5 +245,5 @@ void IGESDraw_ToolLabelDisplay::OwnDump(const occ::handle S << "\n"; } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigure.cxx index 70a9c733d4..ce7b6075b7 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigure.cxx @@ -69,35 +69,55 @@ void IGESDraw_ToolNetworkSubfigure::ReadOwnParams(const occ::handle 0) { // Reading connectPoints(HArray1OfConnectPoint) @@ -130,11 +154,15 @@ void IGESDraw_ToolNetworkSubfigure::ReadOwnParams(const occ::handleSetValue(i, tempConnectPoint); + } } } else if (nbval < 0) + { PR.AddFail("Count of Connect point entities : Less than Zero"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(definition, translation, scale, typeflag, designator, textTemplate, connectPoints); @@ -160,7 +188,9 @@ void IGESDraw_ToolNetworkSubfigure::WriteOwnParams( int Up = ent->NbConnectPoints(); for (int i = 1; i <= Up; i++) + { IW.Send(ent->ConnectPoint(i)); + } } void IGESDraw_ToolNetworkSubfigure::OwnShared(const occ::handle& ent, @@ -170,7 +200,9 @@ void IGESDraw_ToolNetworkSubfigure::OwnShared(const occ::handleDesignatorTemplate()); int Up = ent->NbConnectPoints(); for (int i = 1; i <= Up; i++) + { iter.GetOneItem(ent->ConnectPoint(i)); + } } void IGESDraw_ToolNetworkSubfigure::OwnCopy(const occ::handle& another, @@ -194,14 +226,18 @@ void IGESDraw_ToolNetworkSubfigure::OwnCopy(const occ::handleScaleFactors(); typeflag = another->TypeFlag(); if (!another->ReferenceDesignator().IsNull()) + { designator = new TCollection_HAsciiString(another->ReferenceDesignator()); + } DeclareAndCast(IGESGraph_TextDisplayTemplate, textTemplate, TC.Transferred(another->DesignatorTemplate())); if (nbval > 0) + { connectPoints = new NCollection_HArray1>(1, nbval); + } for (int i = 1; i <= nbval; i++) { DeclareAndCast(IGESDraw_ConnectPoint, @@ -229,11 +265,17 @@ void IGESDraw_ToolNetworkSubfigure::OwnCheck(const occ::handle& ach) const { if (ent->TypeFlag() != 0 && ent->TypeFlag() != 1 && ent->TypeFlag() != 2) + { ach->AddFail("Type Flag : Value != 0/1/2"); + } if (ent->NbConnectPoints() != ent->SubfigureDefinition()->NbPointEntities()) + { ach->AddFail("Count of associated Connect Points inconsistent with Definition"); + } if (ent->ReferenceDesignator().IsNull()) + { ach->AddFail("Primary Reference Designator : not defined"); + } } void IGESDraw_ToolNetworkSubfigure::OwnDump(const occ::handle& ent, @@ -257,5 +299,5 @@ void IGESDraw_ToolNetworkSubfigure::OwnDump(const occ::handleDesignatorTemplate(), S, sublevel); S << "\nConnect Points : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbConnectPoints(), ent->ConnectPoint); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigureDef.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigureDef.cxx index f2a4903e0e..c1aa4721f3 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigureDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolNetworkSubfigureDef.cxx @@ -58,10 +58,14 @@ void IGESDraw_ToolNetworkSubfigureDef::ReadOwnParams( { // Initialize HArray1 only if there is no error reading its Length if (tempNbEntities1 < 0) + { PR.AddFail("Number Of Child Entities : Not Positive"); + } else if (tempNbEntities1 > 0) + { // clang-format off PR.ReadEnts(IR,PR.CurrentList(tempNbEntities1),"Child Entities",tempEntities); //szv#4:S4163:12Mar99 `st=` not needed +} // tempEntities = new NCollection_HArray1> (1,tempNbEntities1); // clang-format on } @@ -81,11 +85,15 @@ void IGESDraw_ToolNetworkSubfigureDef::ReadOwnParams( PR.ReadInteger(PR.Current(), "Type Flag", tempTypeFlag); // szv#4:S4163:12Mar99 `st=` not needed if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadText(PR.Current(), "Primary Reference Designator", tempDesignator); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else + { PR.AddWarning("Primary Reference Designator : Null"); + } bool st = PR.ReadEntity(IR, PR.Current(), @@ -95,17 +103,25 @@ void IGESDraw_ToolNetworkSubfigureDef::ReadOwnParams( true); if (PR.DefinedElseSkip()) + { st = PR.ReadInteger(PR.Current(), "Number Of Connect Points", tempNbEntities2); + } else + { tempNbEntities2 = 0; + } if (st) { // Initialise HArray1 only if there is no error reading its Length if (tempNbEntities2 < 0) + { PR.AddFail("Number Of Connect Points : Less Than Zero"); + } else if (tempNbEntities2 > 0) + { tempPointEntities = new NCollection_HArray1>(1, tempNbEntities2); + } } // Read the HArray1 only if its Length was read without any Error @@ -124,7 +140,9 @@ void IGESDraw_ToolNetworkSubfigureDef::ReadOwnParams( STANDARD_TYPE(IGESDraw_ConnectPoint), tempConnectPoint, true)) + { tempPointEntities->SetValue(I, tempConnectPoint); + } } } @@ -148,14 +166,18 @@ void IGESDraw_ToolNetworkSubfigureDef::WriteOwnParams( IW.Send(up); int I; for (I = 1; I <= up; I++) + { IW.Send(ent->Entity(I)); + } IW.Send(ent->TypeFlag()); IW.Send(ent->Designator()); IW.Send(ent->DesignatorTemplate()); up = ent->NbPointEntities(); IW.Send(up); for (I = 1; I <= up; I++) + { IW.Send(ent->PointEntity(I)); + } } void IGESDraw_ToolNetworkSubfigureDef::OwnShared( @@ -165,10 +187,14 @@ void IGESDraw_ToolNetworkSubfigureDef::OwnShared( int I; int up = ent->NbEntities(); for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->Entity(I)); + } up = ent->NbPointEntities(); for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->PointEntity(I)); + } } void IGESDraw_ToolNetworkSubfigureDef::OwnCopy( @@ -181,7 +207,9 @@ void IGESDraw_ToolNetworkSubfigureDef::OwnCopy( occ::handle>> tempEntities; int up = another->NbEntities(); if (up > 0) + { tempEntities = new NCollection_HArray1>(1, up); + } int I; for (I = 1; I <= up; I++) { @@ -191,11 +219,15 @@ void IGESDraw_ToolNetworkSubfigureDef::OwnCopy( int tempTypeFlag = another->TypeFlag(); occ::handle tempDesignator; if (!another->Designator().IsNull()) + { tempDesignator = new TCollection_HAsciiString(another->Designator()); + } up = another->NbPointEntities(); occ::handle>> tempPointEntities; if (up > 0) + { tempPointEntities = new NCollection_HArray1>(1, up); + } for (I = 1; I <= up; I++) { if (another->HasPointEntity(I)) @@ -254,9 +286,13 @@ void IGESDraw_ToolNetworkSubfigureDef::OwnCheck( occ::handle& ach) const { if ((ent->TypeFlag() < 0) || (ent->TypeFlag() > 2)) + { ach->AddFail("TypeFlag has Invalid value"); + } if (ent->Designator().IsNull()) + { ach->AddFail("Primary Reference Designator : not defined"); + } } void IGESDraw_ToolNetworkSubfigureDef::OwnDump(const occ::handle& ent, @@ -279,5 +315,5 @@ void IGESDraw_ToolNetworkSubfigureDef::OwnDump(const occ::handleDesignatorTemplate(), S, tempSubLevel); S << "\nConnect Point Entities : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbPointEntities(), ent->PointEntity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPerspectiveView.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPerspectiveView.cxx index 849f86dde5..3afedd6f86 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPerspectiveView.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPerspectiveView.cxx @@ -64,22 +64,30 @@ void IGESDraw_ToolPerspectiveView::ReadOwnParams(const occ::handle& ach) const { if ((ent->DepthClip() < 0) || (ent->DepthClip() > 3)) + { ach->AddFail("DepthClip has invalid value"); + } if (ent->HasTransf()) { if (ent->Transf()->FormNumber() != 0) + { ach->AddFail("Associated Matrix has not Form Number 0"); + } } } @@ -221,5 +233,5 @@ void IGESDraw_ToolPerspectiveView::OwnDump(const occ::handleBackPlaneDistance() << " " << "Front Plane Distance : " << ent->FrontPlaneDistance() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPlanar.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPlanar.cxx index cbdf5b2358..4f585c9d1f 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPlanar.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolPlanar.cxx @@ -48,14 +48,20 @@ void IGESDraw_ToolPlanar::ReadOwnParams(const occ::handle& // Reading nbMatrices(Integer) st = PR.ReadInteger(PR.Current(), "No. of Transformation matrices", nbMatrices); if (nbMatrices != 1) + { PR.AddFail("No. of Transformation matrices != 1"); + } // Reading nbval(Integer) st = PR.ReadInteger(PR.Current(), "No. of Entities in this plane", nbval); if (!st) + { nbval = 0; // szv#4:S4163:12Mar99 was bug: `nbval == 0` + } if (nbval <= 0) + { PR.AddFail("No. of Entities in this plane : Not Positive"); + } // Reading transformationMatrix(Instance of TransformationMatrix or Null) st = PR.ReadEntity(IR, @@ -66,7 +72,9 @@ void IGESDraw_ToolPlanar::ReadOwnParams(const occ::handle& true); if (nbval > 0) + { st = PR.ReadEnts(IR, PR.CurrentList(nbval), "Planar Entities", entities); + } /* { entities = new NCollection_HArray1>(1, nbval); @@ -94,7 +102,9 @@ void IGESDraw_ToolPlanar::WriteOwnParams(const occ::handle& ent IW.Send(ent->TransformMatrix()); for (int i = 1; i <= Up; i++) + { IW.Send(ent->Entity(i)); + } } void IGESDraw_ToolPlanar::OwnShared(const occ::handle& ent, @@ -103,7 +113,9 @@ void IGESDraw_ToolPlanar::OwnShared(const occ::handle& ent, int Up = ent->NbEntities(); iter.GetOneItem(ent->TransformMatrix()); for (int i = 1; i <= Up; i++) + { iter.GetOneItem(ent->Entity(i)); + } } void IGESDraw_ToolPlanar::OwnCopy(const occ::handle& another, @@ -133,13 +145,17 @@ void IGESDraw_ToolPlanar::OwnCopy(const occ::handle& another, bool IGESDraw_ToolPlanar::OwnCorrect(const occ::handle& ent) const { if (ent->NbMatrices() == 1) + { return false; + } // Forcer NbMNatrices a 1 -> Reconstruire int nb = ent->NbEntities(); occ::handle>> ents = new NCollection_HArray1>(1, nb); for (int i = 1; i <= nb; i++) + { ents->SetValue(i, ent->Entity(i)); + } ent->Init(1, ent->TransformMatrix(), ents); return true; } @@ -163,7 +179,9 @@ void IGESDraw_ToolPlanar::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->NbMatrices() != 1) + { ach->AddFail("No. of Transformation matrices : Value != 1"); + } } void IGESDraw_ToolPlanar::OwnDump(const occ::handle& ent, @@ -177,11 +195,15 @@ void IGESDraw_ToolPlanar::OwnDump(const occ::handle& ent, << "No. of Transformation Matrices : " << ent->NbMatrices() << " " << "i.e. : "; if (ent->TransformMatrix().IsNull()) + { S << "Null Handle"; + } else + { dumper.OwnDump(ent->TransformMatrix(), S, sublevel); + } S << "\n" << "Array of Entities on the specified plane : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbEntities(), ent->Entity); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolRectArraySubfigure.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolRectArraySubfigure.cxx index 44b300d90a..14bddaf686 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolRectArraySubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolRectArraySubfigure.cxx @@ -56,11 +56,14 @@ void IGESDraw_ToolRectArraySubfigure::ReadOwnParams( // clang-format off PR.ReadEntity(IR, PR.Current(), "Base Entity", tempBaseEntity); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "Scale Factor", tempScaleFactor); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else + { tempScaleFactor = 1.0; // Setting to default value of 1.0 + } // szv#4:S4163:12Mar99 `st=` not needed PR.ReadXYZ(PR.CurrentList(1, 3), "Lower Left Coordinate Of Array", tempLowerLeftCorner); @@ -76,9 +79,13 @@ void IGESDraw_ToolRectArraySubfigure::ReadOwnParams( { // Initialise HArray1 only if there is no error reading its Length if (tempListCount > 0) + { tempPositions = new NCollection_HArray1(1, tempListCount); + } else if (tempListCount < 0) + { PR.AddFail("DO-DONT List Count : Less than Zero"); + } } // clang-format off @@ -95,7 +102,9 @@ void IGESDraw_ToolRectArraySubfigure::ReadOwnParams( // st = PR.ReadInteger(PR.Current(), "Number Of Position To Process", // tempPos); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Number Of Position To Process", tempPos)) + { tempPositions->SetValue(I, tempPos); + } } } @@ -131,7 +140,9 @@ void IGESDraw_ToolRectArraySubfigure::WriteOwnParams( int I; int up = ent->ListCount(); for (I = 1; I <= up; I++) + { IW.Send(ent->ListPosition(I)); + } } void IGESDraw_ToolRectArraySubfigure::OwnShared(const occ::handle& ent, @@ -161,7 +172,9 @@ void IGESDraw_ToolRectArraySubfigure::OwnCopy( tempPositions = new NCollection_HArray1(1, tempListCount); int I; for (I = 1; I <= tempListCount; I++) + { tempPositions->SetValue(I, another->ListPosition(I)); + } } ent->Init(tempBaseEntity, @@ -217,10 +230,14 @@ void IGESDraw_ToolRectArraySubfigure::OwnDump(const occ::handleRotationAngle() << "\n" << "Do-Dont Flag : "; if (ent->DoDontFlag()) + { S << "(1)Dont "; + } else + { S << "(0)Do "; + } S << "Do-Dont List : "; IGESData_DumpVals(S, level, 1, ent->ListCount(), ent->ListPosition); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolSegmentedViewsVisible.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolSegmentedViewsVisible.cxx index ea9cab0a02..ca35337e52 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolSegmentedViewsVisible.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolSegmentedViewsVisible.cxx @@ -85,19 +85,25 @@ void IGESDraw_ToolSegmentedViewsVisible::ReadOwnParams( "Instance of views", STANDARD_TYPE(IGESData_ViewKindEntity), tempView)) + { views->SetValue(i, tempView); + } // Reading breakpointParameters(HArray1OfReal) // st = PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak ); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak)) + { breakpointParameters->SetValue(i, tempBreak); + } // Reading displayFlags(HArray1OfInteger) // st = PR.ReadInteger( PR.Current(), "array displayFlags", tempDisplay ); // //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "array displayFlags", tempDisplay)) + { displayFlags->SetValue(i, tempDisplay); + } int curnum = PR.CurrentNumber(); @@ -110,12 +116,18 @@ void IGESDraw_ToolSegmentedViewsVisible::ReadOwnParams( colorValues->SetValue(i, -1); tempColorDef = GetCasted(IGESGraph_Color, PR.ParamEntity(IR, curnum)); if (tempColorDef.IsNull()) + { PR.AddFail("A Color Definition Entity is incorrect"); + } else + { colorDefinitions->SetValue(i, tempColorDef); + } } else + { colorValues->SetValue(i, tempColorValue); + } curnum = PR.CurrentNumber(); // Reading Line Font : Value (>0) or Definition (<0 = D.E. Pointer) @@ -127,21 +139,29 @@ void IGESDraw_ToolSegmentedViewsVisible::ReadOwnParams( lineFontValues->SetValue(i, -1); tempLineFontDef = GetCasted(IGESData_LineFontEntity, PR.ParamEntity(IR, curnum)); if (tempLineFontDef.IsNull()) + { PR.AddFail("A Line Font Definition Entity is incorrect"); + } lineFontDefinitions->SetValue(i, tempLineFontDef); } else + { lineFontValues->SetValue(i, tempLineFontValue); + } // Reading lineWeights(HArray1OfInteger) // st = PR.ReadInteger( PR.Current(), "array lineWeights", tempLine ); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "array lineWeights", tempLine)) + { lineWeights->SetValue(i, tempLine); + } } } else + { PR.AddFail("No. of View/segment blocks : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(views, @@ -167,14 +187,22 @@ void IGESDraw_ToolSegmentedViewsVisible::WriteOwnParams( IW.Send(ent->DisplayFlag(i)); if (ent->IsColorDefinition(i)) + { IW.Send(ent->ColorDefinition(i), true); // negative + } else + { IW.Send(ent->ColorValue(i)); + } if (ent->IsFontDefinition(i)) + { IW.Send(ent->LineFontDefinition(i), true); // negative + } else + { IW.Send(ent->LineFontValue(i)); + } IW.Send(ent->LineWeightItem(i)); } @@ -189,9 +217,13 @@ void IGESDraw_ToolSegmentedViewsVisible::OwnShared( { iter.GetOneItem(ent->ViewItem(i)); if (ent->IsColorDefinition(i)) + { iter.GetOneItem(ent->ColorDefinition(i)); + } if (!ent->IsFontDefinition(i)) + { iter.GetOneItem(ent->LineFontDefinition(i)); + } } } @@ -353,5 +385,5 @@ void IGESDraw_ToolSegmentedViewsVisible::OwnDump( } break; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolView.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolView.cxx index 2bfe3092d6..5db6597ee0 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolView.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolView.cxx @@ -47,10 +47,11 @@ void IGESDraw_ToolView::ReadOwnParams(const occ::handle& // clang-format off PR.ReadInteger(PR.Current(), "View Number", tempViewNumber); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "Scale Factor", tempScaleFactor); //szv#4:S4163:12Mar99 `st=` not needed - else + } else { tempScaleFactor = 1.0; // Setting to default value of 1.0 +} PR.ReadEntity(IR, PR.Current(), "Left Side Of View Volume", STANDARD_TYPE(IGESGeom_Plane), tempLeftPlane, true); //szv#4:S4163:12Mar99 `st=` not needed @@ -150,7 +151,9 @@ void IGESDraw_ToolView::OwnCheck(const occ::handle& ent, if (ent->HasTransf()) { if (ent->Transf()->FormNumber() != 0) + { ach->AddFail("Associated Matrix has not Form Number 0"); + } } } @@ -181,5 +184,5 @@ void IGESDraw_ToolView::OwnDump(const occ::handle& ent, S << "\n"; S << "Front Plane Of View Volume : "; dumper.Dump(ent->FrontPlane(), S, tempSubLevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisible.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisible.cxx index b1f64b24f5..c6cc2eba4d 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisible.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisible.cxx @@ -50,16 +50,22 @@ void IGESDraw_ToolViewsVisible::ReadOwnParams(const occ::handle>(1, tempNbViewsVisible); + } } if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Number of Entities Displayed", tempNbDisplayedEntities); // szv#4:S4163:12Mar99 `st=` not needed + } else { tempNbDisplayedEntities = 0; @@ -67,7 +73,9 @@ void IGESDraw_ToolViewsVisible::ReadOwnParams(const occ::handle 0) { if (!tempViewEntities.IsNull()) @@ -84,7 +92,9 @@ void IGESDraw_ToolViewsVisible::ReadOwnParams(const occ::handleSetValue(I, tempViewEntity1); + } } } @@ -122,10 +132,14 @@ void IGESDraw_ToolViewsVisible::WriteOwnParams(const occ::handleNbViews(); for (I = 1; I <= up; I++) + { IW.Send(ent->ViewItem(I)); + } up = ent->NbDisplayedEntities(); for (I = 1; I <= up; I++) + { IW.Send(ent->DisplayedEntity(I)); + } } void IGESDraw_ToolViewsVisible::OwnShared(const occ::handle& ent, @@ -134,7 +148,9 @@ void IGESDraw_ToolViewsVisible::OwnShared(const occ::handleNbViews(); for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->ViewItem(I)); + } // Displayed -> Implied } @@ -144,7 +160,9 @@ void IGESDraw_ToolViewsVisible::OwnImplied(const occ::handleNbDisplayedEntities(); for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->DisplayedEntity(I)); + } } void IGESDraw_ToolViewsVisible::OwnCopy(const occ::handle& another, @@ -173,19 +191,25 @@ void IGESDraw_ToolViewsVisible::OwnRenew(const occ::handleNbDisplayedEntities(); if (up == 0) + { return; + } occ::handle>> tempDisplayEntities; occ::handle anew; for (I = 1; I <= up; I++) { if (TC.Search(another->DisplayedEntity(I), anew)) + { newdisp.GetOneItem(anew); + } } up = newdisp.NbEntities(); I = 0; if (up > 0) + { tempDisplayEntities = new NCollection_HArray1>(1, up); + } for (newdisp.Start(); newdisp.More(); newdisp.Next()) { I++; @@ -222,10 +246,14 @@ void IGESDraw_ToolViewsVisible::OwnCheck(const occ::handle displayed = ent->DisplayedEntity(i); if (entcomp != displayed->View()) + { res++; + } } if (!res) + { return; + } char mess[80]; Sprintf(mess, "Mismatch for %d Entities displayed", res); ach->AddFail(mess, "Mismatch for %d Entities displayed"); @@ -248,7 +276,7 @@ void IGESDraw_ToolViewsVisible::OwnDump(const occ::handle S << "\n" << "Entities Displayed : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbDisplayedEntities(), ent->DisplayedEntity); - S << std::endl; + S << '\n'; } bool IGESDraw_ToolViewsVisible::OwnCorrect(const occ::handle& ent) const @@ -261,10 +289,14 @@ bool IGESDraw_ToolViewsVisible::OwnCorrect(const occ::handle displayed = ent->DisplayedEntity(i); if (entcomp != displayed->View()) + { res = true; + } } if (!res) + { return res; + } occ::handle>> nulDisplayEntities; ent->InitImplied(nulDisplayEntities); return res; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisibleWithAttr.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisibleWithAttr.cxx index 0f07b0c8f0..397c69ef21 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisibleWithAttr.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ToolViewsVisibleWithAttr.cxx @@ -63,7 +63,9 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( { // Initialise HArray1 only if there is no error reading its Length if (tempNbBlocks <= 0) + { PR.AddFail("Number Of Blocks : Not Positive"); + } else { tempViewEntities = @@ -78,9 +80,11 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( } if (PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "Number of Entities Displayed", tempNbEntity); // szv#4:S4163:12Mar99 `st=` not needed + } else { tempNbEntity = 0; @@ -88,7 +92,9 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( } // Initialise HArray1 only if there is no error reading its Length if (tempNbEntity < 0) + { PR.AddFail("Number Of Entities Displayed : Less than Zero"); + } // Read the HArray1 only if its Length was read without any Error if (!(tempViewEntities.IsNull())) @@ -112,12 +118,16 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( "View Entity", STANDARD_TYPE(IGESData_ViewKindEntity), tempView)) + { tempViewEntities->SetValue(I, tempView); + } // st = PR.ReadInteger(PR.Current(), "Line Font Value", tempLineFont); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadInteger(PR.Current(), "Line Font Value", tempLineFont)) + { tempLineFonts->SetValue(I, tempLineFont); + } // st = PR.ReadEntity(IR, PR.Current(), "Line Font Definition", // STANDARD_TYPE(IGESData_LineFontEntity), @@ -129,14 +139,18 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( STANDARD_TYPE(IGESData_LineFontEntity), tempEntity1, true)) + { tempLineDefinitions->SetValue(I, tempEntity1); + } int curnum = PR.CurrentNumber(); // Reading Color : Value (>0) or Definition (<0 = D.E. Pointer) if (PR.DefinedElseSkip()) + { // clang-format off PR.ReadInteger( PR.Current(), "Color Value", tempColorValue); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else { tempColorValue = 0; @@ -147,17 +161,25 @@ void IGESDraw_ToolViewsVisibleWithAttr::ReadOwnParams( tempColorValues->SetValue(I, -1); tempColorDef = GetCasted(IGESGraph_Color, PR.ParamEntity(IR, curnum)); if (tempColorDef.IsNull()) + { PR.AddFail("A Color Definition Entity is incorrect"); + } else + { tempColorDefinitions->SetValue(I, tempColorDef); + } } else + { tempColorValues->SetValue(I, tempColorValue); + } // st = PR.ReadInteger(PR.Current(), "Line Weight Value", // tempLineWeightValue); //szv#4:S4163:12Mar99 moved in if if (PR.ReadInteger(PR.Current(), "Line Weight Value", tempLineWeightValue)) + { tempLineWeights->SetValue(I, tempLineWeightValue); + } } } @@ -202,14 +224,20 @@ void IGESDraw_ToolViewsVisibleWithAttr::WriteOwnParams( IW.Send(ent->LineFontValue(I)); IW.Send(ent->FontDefinition(I)); // controlled by LineFontValue, both sent if (ent->IsColorDefinition(I)) + { IW.Send(ent->ColorDefinition(I), true); // negative + } else + { IW.Send(ent->ColorValue(I)); + } IW.Send(ent->LineWeightItem(I)); } up = ent->NbDisplayedEntities(); for (I = 1; I <= up; I++) + { IW.Send(ent->DisplayedEntity(I)); + } } void IGESDraw_ToolViewsVisibleWithAttr::OwnShared( @@ -224,7 +252,9 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnShared( iter.GetOneItem(ent->ViewItem(I)); iter.GetOneItem(ent->FontDefinition(I)); if (ent->IsColorDefinition(I)) + { iter.GetOneItem(ent->ColorDefinition(I)); + } } // Displayed -> Implied } @@ -236,7 +266,9 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnImplied( int I, up; up = ent->NbDisplayedEntities(); for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->DisplayedEntity(I)); + } } void IGESDraw_ToolViewsVisibleWithAttr::OwnCopy( @@ -302,19 +334,25 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnRenew( int I, up; up = another->NbDisplayedEntities(); if (up == 0) + { return; + } occ::handle>> tempDisplayEntities; occ::handle anew; for (I = 1; I <= up; I++) { if (TC.Search(another->DisplayedEntity(I), anew)) + { newdisp.GetOneItem(anew); + } } up = newdisp.NbEntities(); I = 0; if (up > 0) + { tempDisplayEntities = new NCollection_HArray1>(1, up); + } for (newdisp.Start(); newdisp.More(); newdisp.Next()) { I++; @@ -350,7 +388,9 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnCheck( for (i = 1; i <= nb; i++) { if (ent->LineFontValue(i) != 0 && ent->IsFontDefinition(i)) + { ach->AddFail("At least one Line Font Definition Mismatch (both Value and Entity"); + } } const occ::handle& entcomp = ent; int res = 0; @@ -359,10 +399,14 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnCheck( { occ::handle displayed = ent->DisplayedEntity(i); if (entcomp != displayed->View()) + { res++; + } } if (!res) + { return; + } char mess[80]; Sprintf(mess, "Mismatch for %d Entities displayed", res); ach->AddFail(mess, "Mismatch for %d Entities displayed"); @@ -408,23 +452,27 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnDump( S << "\n"; } else + { S << "Line Font Value : " << ent->LineFontValue(I) << "\n"; + } if (ent->IsColorDefinition(I)) { S << "Color Definition : "; dumper.Dump(ent->ColorDefinition(I), S, tempSubLevel); - S << std::endl; + S << '\n'; } else + { S << "Color Value : " << ent->ColorValue(I) << "\n"; + } S << "Line Weight : " << ent->LineWeightItem(I) << "\n"; } } S << "Displayed Entities : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbDisplayedEntities(), ent->DisplayedEntity); - S << std::endl; + S << '\n'; } bool IGESDraw_ToolViewsVisibleWithAttr::OwnCorrect( @@ -438,10 +486,14 @@ bool IGESDraw_ToolViewsVisibleWithAttr::OwnCorrect( { occ::handle displayed = ent->DisplayedEntity(i); if (entcomp != displayed->View()) + { res = true; + } } if (!res) + { return res; + } occ::handle>> nulDisplayEntities; ent->InitImplied(nulDisplayEntities); return res; diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisible.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisible.cxx index d507a3f9d8..fc9472a60b 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisible.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisible.cxx @@ -31,11 +31,19 @@ void IGESDraw_ViewsVisible::Init( const occ::handle>>& allDisplayEntity) { if (!allDisplayEntity.IsNull()) + { if (allDisplayEntity->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisible : Init"); + } + } if (!allViewEntities.IsNull()) + { if (allViewEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisible : Init"); + } + } theViewEntities = allViewEntities; theDisplayEntity = allDisplayEntity; InitTypeAndForm(402, 3); @@ -45,8 +53,12 @@ void IGESDraw_ViewsVisible::InitImplied( const occ::handle>>& allDisplayEntity) { if (!allDisplayEntity.IsNull()) + { if (allDisplayEntity->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisible : InitImplied"); + } + } theDisplayEntity = allDisplayEntity; } diff --git a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisibleWithAttr.cxx b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisibleWithAttr.cxx index 14bad34d86..9172db5a38 100644 --- a/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisibleWithAttr.cxx +++ b/src/DataExchange/TKDEIGES/IGESDraw/IGESDraw_ViewsVisibleWithAttr.cxx @@ -45,11 +45,17 @@ void IGESDraw_ViewsVisibleWithAttr::Init( || (allLineWeights->Lower() != 1 || allLineWeights->Length() != Exp) || (allLineDefinitions->Lower() != 1 || allLineDefinitions->Length() != Exp) || (allColorDefinitions->Lower() != 1 || allColorDefinitions->Length() != Exp)) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisibleWithAttr : Init"); + } } if (!allDisplayEntities.IsNull()) + { if (allDisplayEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisibleWithAttr : Init"); + } + } theViewEntities = allViewEntities; theLineFonts = allLineFonts; @@ -65,8 +71,12 @@ void IGESDraw_ViewsVisibleWithAttr::InitImplied( const occ::handle>>& allDisplayEntity) { if (!allDisplayEntity.IsNull()) + { if (allDisplayEntity->Lower() != 1) + { throw Standard_DimensionMismatch("IGESDraw_ViewsVisibleWithAttr : InitImplied"); + } + } theDisplayEntities = allDisplayEntity; } diff --git a/src/DataExchange/TKDEIGES/IGESFile/IGESFile_Read.cxx b/src/DataExchange/TKDEIGES/IGESFile/IGESFile_Read.cxx index 44e28c0f97..cafd9a715f 100644 --- a/src/DataExchange/TKDEIGES/IGESFile/IGESFile_Read.cxx +++ b/src/DataExchange/TKDEIGES/IGESFile/IGESFile_Read.cxx @@ -94,7 +94,9 @@ int IGESFile_Read(char* nomfic, int result = igesread(ficnom, lesect, modefnes); if (result != 0) + { return result; + } // Loading results into an IGESReader @@ -133,7 +135,9 @@ int IGESFile_Read(char* nomfic, { OCC_CATCH_SIGNALS if (nbparts > 0) + { IGESFile_ReadContent(IR); + } // Sending of message : Loaded data } // end attempt 2 (entities) @@ -169,7 +173,9 @@ int IGESFile_Read(char* nomfic, // Sending of message : Loading of Model : Beginning IT.LoadModel(amodel); if (amodel->Protocol().IsNull()) + { amodel->SetProtocol(protocol); + } iges_finfile(2); // Now, the check @@ -216,17 +222,25 @@ void IGESFile_ReadHeader(const occ::handle& IR) { int j; // svv Jan11 2000 : porting on DEC for (j = 72; j >= 0; j--) + { if (parval[j] > 32) + { break; + } + } parval[j + 1] = '\0'; if (j >= 0 || l > 0) + { IR->AddStartLine(parval); + } l++; } // then the Global Section iges_setglobal(); while (iges_lirparam(&typarg, &parval) != 0) + { IR->AddGlobal(LesTypes[typarg], parval); + } IR->SetGlobalSection(); } @@ -276,15 +290,23 @@ void IGESFile_ReadContent(const occ::handle& IR) { int nument = atoi(parval); if (nument < 0) + { nument = -nument; + } if (nument & 1) + { nument = (nument + 1) / 2; + } else + { nument = 0; + } IR->AddParam(recupne, parval, LesTypes[typarg], nument); } else + { IR->AddParam(recupne, parval, LesTypes[typarg]); + } } IR->InitParams(recupne); iges_nextpart(); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineCurve.cxx index d8ae5d03fb..f52bbfaff6 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineCurve.cxx @@ -76,7 +76,9 @@ void IGESGeom_BSplineCurve::Init(const int void IGESGeom_BSplineCurve::SetFormNumber(const int form) { if (form < 0 || form > 5) + { throw Standard_OutOfRange("IGESGeom_BSplineCurve : SetFormNumber"); + } InitTypeAndForm(126, form); } @@ -103,12 +105,18 @@ bool IGESGeom_BSplineCurve::IsClosed() const bool IGESGeom_BSplineCurve::IsPolynomial(const bool flag) const { if (flag || theWeights.IsNull()) + { return isPolynomial; + } int i, i1 = theWeights->Lower(), i2 = theWeights->Upper(); double w0 = theWeights->Value(i1); for (i = i1 + 1; i <= i2; i++) + { if (std::abs(theWeights->Value(i) - w0) > 1.e-10) + { return false; + } + } return true; } @@ -148,7 +156,9 @@ gp_Pnt IGESGeom_BSplineCurve::TransformedPole(const int anIndex) const { gp_XYZ tempXYZ = thePoles->Value(anIndex); if (HasTransf()) + { Location().Transforms(tempXYZ); + } gp_Pnt Pole(tempXYZ); return Pole; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineSurface.cxx index f4346fea94..d87608f3a6 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BSplineSurface.cxx @@ -47,13 +47,17 @@ void IGESGeom_BSplineSurface::Init(const int { if (allWeights->RowLength() != allPoles->RowLength() || allWeights->ColLength() != allPoles->ColLength()) + { throw Standard_DimensionMismatch("IGESGeom_BSplineSurface : Init"); + } if (allKnotsU->Lower() != -aDegU || allKnotsV->Lower() != -aDegV || allKnotsU->Upper() != anIndexU + 1 || allKnotsV->Upper() != anIndexV + 1 || allWeights->LowerRow() != 0 || allWeights->LowerCol() != 0 || allPoles->LowerRow() != 0 || allPoles->LowerCol() != 0 || allPoles->UpperRow() != anIndexU || allPoles->UpperCol() != anIndexV) + { throw Standard_DimensionMismatch("IGESGeom_BSplineSurface : Init"); + } theIndexU = anIndexU; theIndexV = anIndexV; @@ -79,7 +83,9 @@ void IGESGeom_BSplineSurface::Init(const int void IGESGeom_BSplineSurface::SetFormNumber(const int form) { if (form < 0 || form > 9) + { throw Standard_OutOfRange("IGESGeom_BSplineSurface : SetFormNumber"); + } InitTypeAndForm(128, form); } @@ -116,7 +122,9 @@ bool IGESGeom_BSplineSurface::IsClosedV() const bool IGESGeom_BSplineSurface::IsPolynomial(const bool flag) const { if (flag) + { return isPolynomial; + } int i, j; double w0 = theWeights->Value(0, 0); /*CR23377 @@ -125,9 +133,15 @@ bool IGESGeom_BSplineSurface::IsPolynomial(const bool flag) const * theIndexU--> theIndexU+1 (=NbPolesU()) */ for (j = 0; j < (theIndexV + 1); j++) + { for (i = 0; i < (theIndexU + 1); i++) + { if (std::abs(theWeights->Value(i, j) - w0) > 1.e-10) + { return false; + } + } + } return true; } @@ -191,7 +205,9 @@ gp_Pnt IGESGeom_BSplineSurface::TransformedPole(const int anIndex1, const int an // Reversal of the order of indices since the poles are // stored in the array like that. See ReadOwnParams() if (HasTransf()) + { Location().Transforms(tempXYZ); + } gp_Pnt Pole(tempXYZ); return Pole; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Boundary.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Boundary.cxx index 16274592b3..50e7648647 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Boundary.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Boundary.cxx @@ -37,7 +37,9 @@ void IGESGeom_Boundary::Init( int num1 = allSenses->Length(); if (allSenses->Lower() != 1 || (allModelCurves->Lower() != 1 || allModelCurves->Length() != num1) || (allParameterCurves->Lower() != 1 || allParameterCurves->Length() != num1)) + { throw Standard_DimensionMismatch("IGESGeom_Boundary: Init"); + } theType = aType; thePreference = aPreference; @@ -81,7 +83,9 @@ occ::handle IGESGeom_Boundary::ModelSpaceCurve(const int In int IGESGeom_Boundary::NbParameterCurves(const int Index) const { if (theParameterCurves->Value(Index).IsNull()) + { return 0; + } return theParameterCurves->Value(Index)->Length(); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BoundedSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BoundedSurface.cxx index dd0cb5b348..312ea3e7b2 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BoundedSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_BoundedSurface.cxx @@ -30,7 +30,9 @@ void IGESGeom_BoundedSurface::Init( const occ::handle>>& aBoundary) { if (aBoundary->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGeom_BoundedSurface : Init"); + } theType = aType; theSurface = aSurface; theBoundaries = aBoundary; diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CircularArc.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CircularArc.cxx index 3c8b7b4c0a..4266c62837 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CircularArc.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CircularArc.cxx @@ -51,7 +51,9 @@ gp_Pnt IGESGeom_CircularArc::TransformedCenter() const { gp_XYZ Center(theCenter.X(), theCenter.Y(), theZT); if (HasTransf()) + { Location().Transforms(Center); + } gp_Pnt transCenter(Center); return transCenter; } @@ -66,7 +68,9 @@ gp_Pnt IGESGeom_CircularArc::TransformedStartPoint() const { gp_XYZ Start(theStart.X(), theStart.Y(), theZT); if (HasTransf()) + { Location().Transforms(Start); + } gp_Pnt transStart(Start); return transStart; } @@ -86,7 +90,9 @@ gp_Pnt IGESGeom_CircularArc::TransformedEndPoint() const { gp_XYZ End(theEnd.X(), theEnd.Y(), theZT); if (HasTransf()) + { Location().Transforms(End); + } gp_Pnt transEnd(End); return transEnd; } @@ -130,7 +136,9 @@ gp_Dir IGESGeom_CircularArc::TransformedAxis() const { gp_XYZ axis(0.0, 0.0, 1.0); if (!HasTransf()) + { return gp_Dir(axis); + } gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); loc.Transforms(axis); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CompositeCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CompositeCurve.cxx index fdf24154cc..987e793ae5 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CompositeCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CompositeCurve.cxx @@ -28,7 +28,9 @@ void IGESGeom_CompositeCurve::Init( const occ::handle>>& allEntities) { if (!allEntities.IsNull() && allEntities->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGeom_CompositeCurve : Init"); + } theEntities = allEntities; InitTypeAndForm(102, 0); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ConicArc.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ConicArc.cxx index 9eaadcff2c..ee88947a43 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ConicArc.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ConicArc.cxx @@ -51,7 +51,9 @@ void IGESGeom_ConicArc::Init(const double A, int fn = FormNumber(); if (fn == 0) + { fn = ComputedFormNumber(); + } InitTypeAndForm(104, fn); } @@ -59,7 +61,9 @@ bool IGESGeom_ConicArc::OwnCorrect() { int cfn = ComputedFormNumber(); if (FormNumber() == cfn) + { return false; + } InitTypeAndForm(104, cfn); return true; } @@ -90,7 +94,9 @@ gp_Pnt IGESGeom_ConicArc::TransformedStartPoint() const { gp_XYZ start(theStart.X(), theStart.Y(), theZT); if (HasTransf()) + { Location().Transforms(start); + } gp_Pnt transStart(start); return transStart; } @@ -105,7 +111,9 @@ gp_Pnt IGESGeom_ConicArc::TransformedEndPoint() const { gp_XYZ end(theEnd.X(), theEnd.Y(), theZT); if (HasTransf()) + { Location().Transforms(end); + } gp_Pnt transEnd(end); return transEnd; } @@ -127,11 +135,17 @@ int IGESGeom_ConicArc::ComputedFormNumber() const // each Qi has its own dimension: //[Q1] = L^-4, [Q2]=L^-4, [Q3]=L^-2 if (Q2 > eps4 && Q1 * Q3 < 0) + { return 1; // Ellipse + } if (Q2 < -eps4 && std::abs(Q1) > eps4) + { return 2; // Hyperbola + } if (std::abs(Q2) <= eps4 && std::abs(Q1) > eps4) + { return 3; // Parabola + } return 0; } @@ -139,7 +153,9 @@ bool IGESGeom_ConicArc::IsFromParabola() const { int fn = FormNumber(); if (fn == 0) + { fn = ComputedFormNumber(); + } return (fn == 3); } @@ -147,7 +163,9 @@ bool IGESGeom_ConicArc::IsFromEllipse() const { int fn = FormNumber(); if (fn == 0) + { fn = ComputedFormNumber(); + } return (fn == 1); } @@ -155,7 +173,9 @@ bool IGESGeom_ConicArc::IsFromHyperbola() const { int fn = FormNumber(); if (fn == 0) + { fn = ComputedFormNumber(); + } return (fn == 2); } @@ -176,7 +196,9 @@ gp_Dir IGESGeom_ConicArc::TransformedAxis() const { gp_XYZ axis(0.0, 0.0, 1.0); if (!HasTransf()) + { return gp_Dir(axis); + } gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); loc.Transforms(axis); @@ -258,9 +280,13 @@ void IGESGeom_ConicArc::ComputedDefinition(double& Xcen, double teta = M_PI / 2.; if (std::abs(b) > eps) + { teta = std::atan(-a / b); + } if (fc < 0) + { teta += M_PI; + } Xax = std::cos(teta); Yax = std::sin(teta); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CopiousData.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CopiousData.cxx index 0175929338..83b7cc5939 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CopiousData.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_CopiousData.cxx @@ -37,10 +37,14 @@ void IGESGeom_CopiousData::Init(const int { // PTV OCC386 crash application while reading So5771b.igs if (allData.IsNull()) + { throw Standard_NullObject("IGESGeom_CopiousData : Init with null data"); + } if (allData->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGeom_CopiousData : Init"); + } theDataType = aDataType; theZPlane = aZPlane; theData = allData; @@ -53,7 +57,9 @@ void IGESGeom_CopiousData::SetPolyline(const bool F) { int newfn = theDataType; if (F) + { newfn += 10; + } InitTypeAndForm(106, newfn); } @@ -87,15 +93,25 @@ int IGESGeom_CopiousData::NbPoints() const int nbtuples; // PTV OCC386 if (theData.IsNull()) + { nbtuples = 0; + } else + { nbtuples = theData->Length(); + } if (theDataType == 1) + { nbtuples /= 2; + } else if (theDataType == 2) + { nbtuples /= 3; + } else if (theDataType == 3) + { nbtuples /= 6; + } return nbtuples; } @@ -103,11 +119,17 @@ double IGESGeom_CopiousData::Data(const int nump, const int numdata) const { int numd = 0; if (theDataType == 1) + { numd = 2 * (nump - 1) + numdata; // 1-2 + } else if (theDataType == 2) + { numd = 3 * (nump - 1) + numdata; // 1-2-3 + } else if (theDataType == 3) + { numd = 6 * (nump - 1) + numdata; // 1-2-3-4-5-6 + } return theData->Value(numd); } @@ -152,7 +174,9 @@ gp_Pnt IGESGeom_CopiousData::Point(const int anIndex) const gp_Pnt IGESGeom_CopiousData::TransformedPoint(const int anIndex) const { if (!HasTransf()) + { return Point(anIndex); + } gp_XYZ xyz(Point(anIndex).XYZ()); Location().Transforms(xyz); return gp_Pnt(xyz); @@ -163,7 +187,9 @@ gp_Vec IGESGeom_CopiousData::Vector(const int anIndex) const int lower = theData->Lower(); int Real_Index; if (theDataType != 3) + { return gp_Vec(0.0, 0.0, 0.0); + } Real_Index = lower + 6 * (anIndex - 1) + 3; double I = theData->Value(Real_Index); double J = theData->Value(Real_Index + 1); @@ -174,7 +200,9 @@ gp_Vec IGESGeom_CopiousData::Vector(const int anIndex) const gp_Vec IGESGeom_CopiousData::TransformedVector(const int anIndex) const { if (!HasTransf()) + { return Vector(anIndex); + } gp_XYZ xyz(Vector(anIndex).XYZ()); gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Direction.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Direction.cxx index 445373b1ad..9b8b340466 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Direction.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Direction.cxx @@ -41,7 +41,9 @@ gp_Vec IGESGeom_Direction::Value() const gp_Vec IGESGeom_Direction::TransformedValue() const { if (!HasTransf()) + { return gp_Vec(theDirection); + } gp_XYZ xyz(theDirection); gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Flash.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Flash.cxx index 499512d1d8..5e99b37350 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Flash.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Flash.cxx @@ -46,7 +46,9 @@ void IGESGeom_Flash::Init(const gp_XY& aPoint, void IGESGeom_Flash::SetFormNumber(const int form) { if (form < 0 || form > 4) + { throw Standard_OutOfRange("IGESGeom_Flash : SetFormNumber"); + } InitTypeAndForm(125, form); } @@ -59,7 +61,9 @@ gp_Pnt IGESGeom_Flash::TransformedReferencePoint() const { gp_XYZ Point(thePoint.X(), thePoint.Y(), 0.0); if (HasTransf()) + { Location().Transforms(Point); + } return gp_Pnt(Point); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_GeneralModule.cxx index 957c627e67..66e0428ef7 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_GeneralModule.cxx @@ -83,7 +83,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineCurve tool; tool.OwnShared(anent, iter); } @@ -91,7 +93,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineSurface tool; tool.OwnShared(anent, iter); } @@ -99,7 +103,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundary tool; tool.OwnShared(anent, iter); } @@ -107,7 +113,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundedSurface tool; tool.OwnShared(anent, iter); } @@ -115,7 +123,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCircularArc tool; tool.OwnShared(anent, iter); } @@ -123,7 +133,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCompositeCurve tool; tool.OwnShared(anent, iter); } @@ -131,7 +143,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolConicArc tool; tool.OwnShared(anent, iter); } @@ -139,7 +153,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCopiousData tool; tool.OwnShared(anent, iter); } @@ -147,7 +163,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCurveOnSurface tool; tool.OwnShared(anent, iter); } @@ -155,7 +173,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolDirection tool; tool.OwnShared(anent, iter); } @@ -163,7 +183,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolFlash tool; tool.OwnShared(anent, iter); } @@ -171,7 +193,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolLine tool; tool.OwnShared(anent, iter); } @@ -179,7 +203,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetCurve tool; tool.OwnShared(anent, iter); } @@ -187,7 +213,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetSurface tool; tool.OwnShared(anent, iter); } @@ -195,7 +223,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPlane tool; tool.OwnShared(anent, iter); } @@ -203,7 +233,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPoint tool; tool.OwnShared(anent, iter); } @@ -211,7 +243,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolRuledSurface tool; tool.OwnShared(anent, iter); } @@ -219,7 +253,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineCurve tool; tool.OwnShared(anent, iter); } @@ -227,7 +263,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineSurface tool; tool.OwnShared(anent, iter); } @@ -235,7 +273,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSurfaceOfRevolution tool; tool.OwnShared(anent, iter); } @@ -243,7 +283,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTabulatedCylinder tool; tool.OwnShared(anent, iter); } @@ -251,7 +293,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTransformationMatrix tool; tool.OwnShared(anent, iter); } @@ -259,7 +303,9 @@ void IGESGeom_GeneralModule::OwnSharedCase(const int case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTrimmedSurface tool; tool.OwnShared(anent, iter); } @@ -278,161 +324,207 @@ IGESData_DirChecker IGESGeom_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBSplineCurve tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBSplineSurface tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBoundary tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBoundedSurface tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolCircularArc tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolCompositeCurve tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolConicArc tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolCopiousData tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolCurveOnSurface tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolDirection tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolFlash tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolLine tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolOffsetCurve tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolOffsetSurface tool; return tool.DirChecker(anent); } case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolPlane tool; return tool.DirChecker(anent); } case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolPoint tool; return tool.DirChecker(anent); } case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolRuledSurface tool; return tool.DirChecker(anent); } case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolSplineCurve tool; return tool.DirChecker(anent); } case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolSplineSurface tool; return tool.DirChecker(anent); } case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolSurfaceOfRevolution tool; return tool.DirChecker(anent); } case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolTabulatedCylinder tool; return tool.DirChecker(anent); } case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolTransformationMatrix tool; return tool.DirChecker(anent); } case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolTrimmedSurface tool; return tool.DirChecker(anent); } @@ -452,7 +544,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineCurve tool; tool.OwnCheck(anent, shares, ach); } @@ -460,7 +554,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -468,7 +564,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundary tool; tool.OwnCheck(anent, shares, ach); } @@ -476,7 +574,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundedSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -484,7 +584,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCircularArc tool; tool.OwnCheck(anent, shares, ach); } @@ -492,7 +594,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCompositeCurve tool; tool.OwnCheck(anent, shares, ach); } @@ -500,7 +604,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolConicArc tool; tool.OwnCheck(anent, shares, ach); } @@ -508,7 +614,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCopiousData tool; tool.OwnCheck(anent, shares, ach); } @@ -516,7 +624,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCurveOnSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -524,7 +634,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolDirection tool; tool.OwnCheck(anent, shares, ach); } @@ -532,7 +644,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolFlash tool; tool.OwnCheck(anent, shares, ach); } @@ -540,7 +654,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolLine tool; tool.OwnCheck(anent, shares, ach); } @@ -548,7 +664,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetCurve tool; tool.OwnCheck(anent, shares, ach); } @@ -556,7 +674,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -564,7 +684,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPlane tool; tool.OwnCheck(anent, shares, ach); } @@ -572,7 +694,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPoint tool; tool.OwnCheck(anent, shares, ach); } @@ -580,7 +704,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolRuledSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -588,7 +714,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineCurve tool; tool.OwnCheck(anent, shares, ach); } @@ -596,7 +724,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -604,7 +734,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSurfaceOfRevolution tool; tool.OwnCheck(anent, shares, ach); } @@ -612,7 +744,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTabulatedCylinder tool; tool.OwnCheck(anent, shares, ach); } @@ -620,7 +754,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTransformationMatrix tool; tool.OwnCheck(anent, shares, ach); } @@ -628,7 +764,9 @@ void IGESGeom_GeneralModule::OwnCheckCase(const int case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTrimmedSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -895,20 +1033,28 @@ int IGESGeom_GeneralModule::CategoryNumber(const int const Interface_ShareTool&) const { if (CN == 11) + { return Interface_Category::Number("Drawing"); + } if (CN == 15) { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent->HasSymbolAttach()) + { return Interface_Category::Number("Drawing"); + } } if (CN == 16) { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent->HasDisplaySymbol()) + { return Interface_Category::Number("Drawing"); + } } if (CN == 22) + { return Interface_Category::Number("Auxiliary"); + } return Interface_Category::Number("Shape"); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Line.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Line.cxx index 50dd2f41ad..136c310fda 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Line.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Line.cxx @@ -41,7 +41,9 @@ int IGESGeom_Line::Infinite() const void IGESGeom_Line::SetInfinite(const int status) { if (status >= 0 && status <= 2) + { InitTypeAndForm(110, status); + } } gp_Pnt IGESGeom_Line::StartPoint() const @@ -54,7 +56,9 @@ gp_Pnt IGESGeom_Line::TransformedStartPoint() const { gp_XYZ Start = theStart; if (HasTransf()) + { Location().Transforms(Start); + } gp_Pnt transStart(Start); return transStart; } @@ -69,7 +73,9 @@ gp_Pnt IGESGeom_Line::TransformedEndPoint() const { gp_XYZ End = theEnd; if (HasTransf()) + { Location().Transforms(End); + } gp_Pnt transEnd(End); return transEnd; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetCurve.cxx index 306997840e..21f1da2d44 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetCurve.cxx @@ -107,7 +107,9 @@ gp_Vec IGESGeom_OffsetCurve::NormalVector() const gp_Vec IGESGeom_OffsetCurve::TransformedNormalVector() const { if (!HasTransf()) + { return gp_Vec(theNormalVector); + } gp_XYZ tempXYZ(theNormalVector); gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetSurface.cxx index f8f757aa30..df999b6b05 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_OffsetSurface.cxx @@ -44,7 +44,9 @@ gp_Vec IGESGeom_OffsetSurface::OffsetIndicator() const gp_Vec IGESGeom_OffsetSurface::TransformedOffsetIndicator() const { if (!HasTransf()) + { return gp_Vec(theIndicator); + } gp_XYZ temp(theIndicator); gp_GTrsf loc = Location(); loc.SetTranslationPart(gp_XYZ(0., 0., 0.)); diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Plane.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Plane.cxx index 79cf5e60c1..81acd1f2ad 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Plane.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Plane.cxx @@ -49,9 +49,13 @@ void IGESGeom_Plane::SetFormNumber(const int form) { int fn = 0; if (form < 0) + { fn = -1; + } if (form > 0) + { fn = 1; + } InitTypeAndForm(108, fn); } @@ -98,7 +102,9 @@ gp_Pnt IGESGeom_Plane::TransformedSymbolAttach() const return gp_Pnt(Symbol); } else + { return gp_Pnt(0, 0, 0); + } } double IGESGeom_Plane::SymbolSize() const diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Point.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Point.cxx index 46e12ecd62..0c7da8ab62 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Point.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Point.cxx @@ -43,7 +43,9 @@ gp_Pnt IGESGeom_Point::TransformedValue() const { gp_XYZ Val = thePoint; if (HasTransf()) + { Location().Transforms(Val); + } gp_Pnt transVal(Val); return transVal; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Protocol.cxx index 81f21dbb32..b07f135822 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_Protocol.cxx @@ -57,50 +57,96 @@ occ::handle IGESGeom_Protocol::Resource(const int /*num*/) c int IGESGeom_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESGeom_BSplineCurve)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESGeom_BSplineSurface)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESGeom_Boundary)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESGeom_BoundedSurface)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESGeom_CircularArc)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESGeom_CompositeCurve)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESGeom_ConicArc)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESGeom_CopiousData)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESGeom_CurveOnSurface)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESGeom_Direction)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESGeom_Flash)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESGeom_Line)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESGeom_OffsetCurve)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESGeom_OffsetSurface)) + { return 14; + } else if (atype == STANDARD_TYPE(IGESGeom_Plane)) + { return 15; + } else if (atype == STANDARD_TYPE(IGESGeom_Point)) + { return 16; + } else if (atype == STANDARD_TYPE(IGESGeom_RuledSurface)) + { return 17; + } else if (atype == STANDARD_TYPE(IGESGeom_SplineCurve)) + { return 18; + } else if (atype == STANDARD_TYPE(IGESGeom_SplineSurface)) + { return 19; + } else if (atype == STANDARD_TYPE(IGESGeom_SurfaceOfRevolution)) + { return 20; + } else if (atype == STANDARD_TYPE(IGESGeom_TabulatedCylinder)) + { return 21; + } else if (atype == STANDARD_TYPE(IGESGeom_TransformationMatrix)) + { return 22; + } else if (atype == STANDARD_TYPE(IGESGeom_TrimmedSurface)) + { return 23; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ReadWriteModule.cxx index 76664748e1..6cbd336c9a 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ReadWriteModule.cxx @@ -81,7 +81,9 @@ int IGESGeom_ReadWriteModule::CaseIGES(const int typenum, const int formnum) con return 7; case 106: if (formnum < 20 || formnum > 40) + { return 8; + } break; case 108: return 15; @@ -137,7 +139,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineCurve tool; tool.ReadOwnParams(anent, IR, PR); } @@ -145,7 +149,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -153,7 +159,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundary tool; tool.ReadOwnParams(anent, IR, PR); } @@ -161,7 +169,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundedSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -169,7 +179,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCircularArc tool; tool.ReadOwnParams(anent, IR, PR); } @@ -177,7 +189,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCompositeCurve tool; tool.ReadOwnParams(anent, IR, PR); } @@ -185,7 +199,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolConicArc tool; tool.ReadOwnParams(anent, IR, PR); } @@ -193,7 +209,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCopiousData tool; tool.ReadOwnParams(anent, IR, PR); } @@ -201,7 +219,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCurveOnSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -209,7 +229,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolDirection tool; tool.ReadOwnParams(anent, IR, PR); } @@ -217,7 +239,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolFlash tool; tool.ReadOwnParams(anent, IR, PR); } @@ -225,7 +249,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolLine tool; tool.ReadOwnParams(anent, IR, PR); } @@ -233,7 +259,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetCurve tool; tool.ReadOwnParams(anent, IR, PR); } @@ -241,7 +269,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -249,7 +279,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPlane tool; tool.ReadOwnParams(anent, IR, PR); } @@ -257,7 +289,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPoint tool; tool.ReadOwnParams(anent, IR, PR); } @@ -265,7 +299,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolRuledSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -273,7 +309,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineCurve tool; tool.ReadOwnParams(anent, IR, PR); } @@ -281,7 +319,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -289,7 +329,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSurfaceOfRevolution tool; tool.ReadOwnParams(anent, IR, PR); } @@ -297,7 +339,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTabulatedCylinder tool; tool.ReadOwnParams(anent, IR, PR); } @@ -305,7 +349,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTransformationMatrix tool; tool.ReadOwnParams(anent, IR, PR); } @@ -313,7 +359,9 @@ void IGESGeom_ReadWriteModule::ReadOwnParams(const int case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTrimmedSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -332,7 +380,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineCurve tool; tool.WriteOwnParams(anent, IW); } @@ -340,7 +390,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineSurface tool; tool.WriteOwnParams(anent, IW); } @@ -348,7 +400,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundary tool; tool.WriteOwnParams(anent, IW); } @@ -356,7 +410,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundedSurface tool; tool.WriteOwnParams(anent, IW); } @@ -364,7 +420,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCircularArc tool; tool.WriteOwnParams(anent, IW); } @@ -372,7 +430,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCompositeCurve tool; tool.WriteOwnParams(anent, IW); } @@ -380,7 +440,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolConicArc tool; tool.WriteOwnParams(anent, IW); } @@ -388,7 +450,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCopiousData tool; tool.WriteOwnParams(anent, IW); } @@ -396,7 +460,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCurveOnSurface tool; tool.WriteOwnParams(anent, IW); } @@ -404,7 +470,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolDirection tool; tool.WriteOwnParams(anent, IW); } @@ -412,7 +480,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolFlash tool; tool.WriteOwnParams(anent, IW); } @@ -420,7 +490,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolLine tool; tool.WriteOwnParams(anent, IW); } @@ -428,7 +500,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetCurve tool; tool.WriteOwnParams(anent, IW); } @@ -436,7 +510,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetSurface tool; tool.WriteOwnParams(anent, IW); } @@ -444,7 +520,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPlane tool; tool.WriteOwnParams(anent, IW); } @@ -452,7 +530,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPoint tool; tool.WriteOwnParams(anent, IW); } @@ -460,7 +540,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolRuledSurface tool; tool.WriteOwnParams(anent, IW); } @@ -468,7 +550,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineCurve tool; tool.WriteOwnParams(anent, IW); } @@ -476,7 +560,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineSurface tool; tool.WriteOwnParams(anent, IW); } @@ -484,7 +570,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSurfaceOfRevolution tool; tool.WriteOwnParams(anent, IW); } @@ -492,7 +580,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTabulatedCylinder tool; tool.WriteOwnParams(anent, IW); } @@ -500,7 +590,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTransformationMatrix tool; tool.WriteOwnParams(anent, IW); } @@ -508,7 +600,9 @@ void IGESGeom_ReadWriteModule::WriteOwnParams(const int case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTrimmedSurface tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SpecificModule.cxx index 76d516f764..bf603a3755 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SpecificModule.cxx @@ -78,7 +78,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 1: { DeclareAndCast(IGESGeom_BSplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineCurve tool; tool.OwnDump(anent, dumper, S, own); } @@ -86,7 +88,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 2: { DeclareAndCast(IGESGeom_BSplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBSplineSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -94,7 +98,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundary tool; tool.OwnDump(anent, dumper, S, own); } @@ -102,7 +108,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 4: { DeclareAndCast(IGESGeom_BoundedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolBoundedSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -110,7 +118,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 5: { DeclareAndCast(IGESGeom_CircularArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCircularArc tool; tool.OwnDump(anent, dumper, S, own); } @@ -118,7 +128,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 6: { DeclareAndCast(IGESGeom_CompositeCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCompositeCurve tool; tool.OwnDump(anent, dumper, S, own); } @@ -126,7 +138,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolConicArc tool; tool.OwnDump(anent, dumper, S, own); } @@ -134,7 +148,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 8: { DeclareAndCast(IGESGeom_CopiousData, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCopiousData tool; tool.OwnDump(anent, dumper, S, own); } @@ -142,7 +158,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 9: { DeclareAndCast(IGESGeom_CurveOnSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolCurveOnSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -150,7 +168,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 10: { DeclareAndCast(IGESGeom_Direction, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolDirection tool; tool.OwnDump(anent, dumper, S, own); } @@ -158,7 +178,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolFlash tool; tool.OwnDump(anent, dumper, S, own); } @@ -166,7 +188,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 12: { DeclareAndCast(IGESGeom_Line, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolLine tool; tool.OwnDump(anent, dumper, S, own); } @@ -174,7 +198,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetCurve tool; tool.OwnDump(anent, dumper, S, own); } @@ -182,7 +208,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 14: { DeclareAndCast(IGESGeom_OffsetSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolOffsetSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -190,7 +218,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 15: { DeclareAndCast(IGESGeom_Plane, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPlane tool; tool.OwnDump(anent, dumper, S, own); } @@ -198,7 +228,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 16: { DeclareAndCast(IGESGeom_Point, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolPoint tool; tool.OwnDump(anent, dumper, S, own); } @@ -206,7 +238,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 17: { DeclareAndCast(IGESGeom_RuledSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolRuledSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -214,7 +248,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 18: { DeclareAndCast(IGESGeom_SplineCurve, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineCurve tool; tool.OwnDump(anent, dumper, S, own); } @@ -222,7 +258,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 19: { DeclareAndCast(IGESGeom_SplineSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSplineSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -230,7 +268,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 20: { DeclareAndCast(IGESGeom_SurfaceOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolSurfaceOfRevolution tool; tool.OwnDump(anent, dumper, S, own); } @@ -238,7 +278,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 21: { DeclareAndCast(IGESGeom_TabulatedCylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTabulatedCylinder tool; tool.OwnDump(anent, dumper, S, own); } @@ -246,7 +288,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTransformationMatrix tool; tool.OwnDump(anent, dumper, S, own); } @@ -254,7 +298,9 @@ void IGESGeom_SpecificModule::OwnDump(const int CN case 23: { DeclareAndCast(IGESGeom_TrimmedSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESGeom_ToolTrimmedSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -273,42 +319,54 @@ bool IGESGeom_SpecificModule::OwnCorrect(const int case 3: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBoundary tool; return tool.OwnCorrect(anent); } case 7: { DeclareAndCast(IGESGeom_ConicArc, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolConicArc tool; return tool.OwnCorrect(anent); } case 9: { DeclareAndCast(IGESGeom_Boundary, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolBoundary tool; return tool.OwnCorrect(anent); } case 11: { DeclareAndCast(IGESGeom_Flash, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolFlash tool; return tool.OwnCorrect(anent); } case 13: { DeclareAndCast(IGESGeom_OffsetCurve, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolOffsetCurve tool; return tool.OwnCorrect(anent); } case 22: { DeclareAndCast(IGESGeom_TransformationMatrix, anent, ent); if (anent.IsNull()) + { break; + } IGESGeom_ToolTransformationMatrix tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineCurve.cxx index 9e43f972f8..ff9b89e123 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineCurve.cxx @@ -37,20 +37,28 @@ void IGESGeom_SplineCurve::Init(const int { int len = allXPolynomials->ColLength(); if ((len != allYPolynomials->ColLength()) || (len != allZPolynomials->ColLength())) + { throw Standard_DimensionMismatch("IGESGeom_SplineCurve : Column Length of HArray2s in Init"); + } if (allBreakPoints->Lower() != 1 || allXvalues->Lower() != 1 || allYvalues->Lower() != 1 || allZvalues->Lower() != 1 || allXPolynomials->LowerCol() != 1 || allXPolynomials->LowerRow() != 1 || allYPolynomials->LowerCol() != 1 || allYPolynomials->LowerRow() != 1 || allZPolynomials->LowerCol() != 1 || allZPolynomials->LowerRow() != 1) + { throw Standard_DimensionMismatch("IGESGeom_SplineCurve : Lower Indices of HArrays in Init"); + } len = allXPolynomials->RowLength(); if ((len != allYPolynomials->RowLength()) || (len != allZPolynomials->RowLength())) + { throw Standard_DimensionMismatch("IGESGeom_SplineCurve : Row Length of HArray2s in Init"); + } len = allXvalues->Length(); if ((len != allYvalues->Length()) || (len != allZvalues->Length())) + { throw Standard_DimensionMismatch("IGESGeom_SplineCurve : Length of HArray1s in Init"); + } theType = aType; theDegree = aDegree; @@ -83,9 +91,13 @@ int IGESGeom_SplineCurve::NbDimensions() const int IGESGeom_SplineCurve::NbSegments() const { if (theBreakPoints.IsNull()) + { return 0; + } else + { return ((theBreakPoints->Length()) - 1); + } } double IGESGeom_SplineCurve::BreakPoint(const int Index) const diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineSurface.cxx index 7e46a7a3ff..96f18382c6 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_SplineSurface.cxx @@ -35,28 +35,37 @@ void IGESGeom_SplineSurface::Init( { int i, j; if (allUBreakPoints->Lower() != 1 || allVBreakPoints->Lower() != 1) + { throw Standard_DimensionMismatch( "IGESGeom_SplineSurface: Lower Indices of BreakPoints in Init"); + } int nbUSegs = allUBreakPoints->Length() - 1; int nbVSegs = allVBreakPoints->Length() - 1; int len = allXCoeffs->RowLength(); if ((len != allYCoeffs->RowLength()) || (len != allZCoeffs->RowLength())) + { throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Row Length of HArray2s in Init"); + } if (allXCoeffs->LowerCol() != 1 || allXCoeffs->LowerRow() != 1 || allYCoeffs->LowerCol() != 1 || allYCoeffs->LowerRow() != 1 || allZCoeffs->LowerCol() != 1 || allZCoeffs->LowerRow() != 1) + { throw Standard_DimensionMismatch( "IGESGeom_SplineSurface: Lower Col-Row Indices of HArray2s in Init"); + } len = allXCoeffs->ColLength(); if ((len != allYCoeffs->ColLength()) || (len != allZCoeffs->ColLength())) + { throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Column Length of HArray2s in Init"); + } occ::handle> temp1; occ::handle> temp2; occ::handle> temp3; for (i = 1; i <= nbUSegs; i++) + { for (j = 1; j <= nbVSegs; j++) { temp1 = allXCoeffs->Value(i, j); @@ -64,9 +73,12 @@ void IGESGeom_SplineSurface::Init( temp3 = allZCoeffs->Value(i, j); if ((temp1.IsNull() || temp1->Length() != 16) || (temp2.IsNull() || temp2->Length() != 16) || (temp3.IsNull() || temp3->Length() != 16)) + { throw Standard_DimensionMismatch( "IGESGeom_SplineSurface: Lengths of elements of HArray2s in Init"); + } } + } theBoundaryType = aBoundaryType; thePatchType = aPatchType; diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TabulatedCylinder.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TabulatedCylinder.cxx index a6de939e40..9512503aa3 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TabulatedCylinder.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TabulatedCylinder.cxx @@ -48,6 +48,8 @@ gp_Pnt IGESGeom_TabulatedCylinder::TransformedEndPoint() const { gp_XYZ EndPoint = theEnd; if (HasTransf()) + { Location().Transforms(EndPoint); + } return (gp_Pnt(EndPoint)); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineCurve.cxx index ff623b4c3e..480b56422f 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineCurve.cxx @@ -143,7 +143,9 @@ void IGESGeom_ToolBSplineCurve::ReadOwnParams(const occ::handleSetValue(I, tempPole); + } } } @@ -173,7 +175,9 @@ void IGESGeom_ToolBSplineCurve::ReadOwnParams(const occ::handleInit(anIndex, @@ -235,12 +245,16 @@ void IGESGeom_ToolBSplineCurve::WriteOwnParams(const occ::handleKnot(I)); + } low = 0; up = index; for (I = low; I <= up; I++) + { IW.Send(ent->Weight(I)); + } for (I = low; I <= up; I++) { @@ -289,19 +303,25 @@ void IGESGeom_ToolBSplineCurve::OwnCopy(const occ::handle low = -aDegree; up = anIndex + 1; for (I = low; I <= up; I++) + { allKnots->SetValue(I, another->Knot(I)); + } allWeights = new NCollection_HArray1(0, anIndex); low = 0; up = anIndex; for (I = low; I <= up; I++) + { allWeights->SetValue(I, another->Weight(I)); + } allPoles = new NCollection_HArray1(0, anIndex); for (I = low; I <= up; I++) + { allPoles->SetValue(I, (another->Pole(I)).XYZ()); + } aUmin = another->UMin(); aUmax = another->UMax(); @@ -372,7 +392,9 @@ void IGESGeom_ToolBSplineCurve::OwnCheck(const occ::handleWeight(I) > 0); + } if (!Flag) { @@ -384,7 +406,9 @@ void IGESGeom_ToolBSplineCurve::OwnCheck(const occ::handleWeight(lower); for (I = lower; ((I < upper) && (Flag)); I++) + { Flag &= (ent->Weight(I) == tempVal); + } /* if (Flag && !ent->IsPolynomial(true)) ach.AddWarning("All weights equal & PROP3 != 1 (Curve Not Polynomial)"); @@ -428,5 +452,5 @@ void IGESGeom_ToolBSplineCurve::OwnDump(const occ::handle << " Ending Parameter Value : " << ent->UMax() << "\n" << "Unit Normal : "; IGESData_DumpXYZL(S, level, ent->Normal(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineSurface.cxx index 47c5512fe1..f428d13dd9 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBSplineSurface.cxx @@ -174,13 +174,17 @@ void IGESGeom_ToolBSplineSurface::ReadOwnParams( } for (J = 0; J <= anIndexV; J++) + { for (I = 0; I <= anIndexU; I++) { // st = PR.ReadXYZ (PR.CurrentList(1, 3), Msg105, tempXYZ); //szv#4:S4163:12Mar99 moved down // st = PR.ReadXYZ (PR.CurrentList(1, 3), "Control Points", tempXYZ); if (PR.ReadXYZ(PR.CurrentList(1, 3), Msg105, tempXYZ)) + { allPoles->SetValue(I, J, tempXYZ); + } } + } } // szv#4:S4163:12Mar99 `st=` not needed @@ -221,16 +225,24 @@ void IGESGeom_ToolBSplineSurface::ReadOwnParams( PR.SendFail(Msg159); } // szv#4:S4163:12Mar99 `st=` not needed if (pbfin == 0) + { pbfin = 1; + } } else if (pt == Interface_ParamInteger || pt == Interface_ParamVoid) + { break; + } else + { pbfin = -1; + } icur++; } if (pbfin > 0) + { PR.SendWarning(Msg159); + } if (pbfin < 0) { Message_Msg Msg158("XSTEP_158"); @@ -277,16 +289,25 @@ void IGESGeom_ToolBSplineSurface::WriteOwnParams(const occ::handleIsPeriodicV()); for (I = -degU; I <= indU + 1; I++) + { IW.Send(ent->KnotU(I)); + } for (I = -degV; I <= indV + 1; I++) + { IW.Send(ent->KnotV(I)); + } for (J = 0; J <= indV; J++) + { for (I = 0; I <= indU; I++) + { IW.Send(ent->Weight(I, J)); + } + } for (J = 0; J <= indV; J++) + { for (I = 0; I <= indU; I++) { gp_XYZ tempXYZ = ent->Pole(I, J).XYZ(); @@ -294,6 +315,7 @@ void IGESGeom_ToolBSplineSurface::WriteOwnParams(const occ::handleUMin()); IW.Send(ent->UMax()); IW.Send(ent->VMin()); @@ -335,10 +357,14 @@ void IGESGeom_ToolBSplineSurface::OwnCopy(const occ::handle(-aDegV, anIndexV + 1); for (I = -aDegU; I <= anIndexU + 1; I++) + { allKnotsU->SetValue(I, another->KnotU(I)); + } for (I = -aDegV; I <= anIndexV + 1; I++) + { allKnotsV->SetValue(I, another->KnotV(I)); + } occ::handle> allWeights = new NCollection_HArray2(0, anIndexU, 0, anIndexV); @@ -346,12 +372,20 @@ void IGESGeom_ToolBSplineSurface::OwnCopy(const occ::handle(0, anIndexU, 0, anIndexV); for (J = 0; J <= anIndexV; J++) + { for (I = 0; I <= anIndexU; I++) + { allWeights->SetValue(I, J, another->Weight(I, J)); + } + } for (J = 0; J <= anIndexV; J++) + { for (I = 0; I <= anIndexU; I++) + { allPoles->SetValue(I, J, another->Pole(I, J).XYZ()); + } + } aUmin = another->UMin(); aUmax = another->UMax(); @@ -461,8 +495,12 @@ void IGESGeom_ToolBSplineSurface::OwnCheck(const occ::handleWeight(I, J) > 0); + } + } if (!Flag) { @@ -474,8 +512,12 @@ void IGESGeom_ToolBSplineSurface::OwnCheck(const occ::handleWeight(0, 0); for (J = 0; ((J < indV) && (Flag)); J++) + { for (I = 0; ((I < indU) && (Flag)); I++) + { Flag &= (ent->Weight(I, J) == tempVal); + } + } // bool Flap = ent->IsPolynomial(true); // if (Flag && !Flap) @@ -524,17 +566,21 @@ void IGESGeom_ToolBSplineSurface::OwnDump(const occ::handleNbPoles(),ent->Pole, ent->Location()); if (level < 5) { - S << " [ content : ask level > 4 ]" << std::endl; + S << " [ content : ask level > 4 ]" << '\n'; return; } gp_GTrsf loca = ent->Location(); for (int JP = 0; JP <= indV; JP++) + { for (int IP = 0; IP <= indU; IP++) { if (IP == 0) + { S << "\n"; + } S << " - [" << IP << "," << JP << "]: "; IGESData_DumpXYZL(S, level, ent->Pole(IP, JP), loca); } - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundary.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundary.cxx index 74149c7d7d..2deafea515 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundary.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundary.cxx @@ -118,7 +118,9 @@ void IGESGeom_ToolBoundary::ReadOwnParams(const occ::handle& // st = PR.ReadEntity(IR, PR.Current(), Msg127, tempEnt); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadEntity(IR, PR.Current(), "Model Space Curves", tempEnt); if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt)) + { tempModelCurves->SetValue(i, tempEnt); + } else { Message_Msg Msg127("XTSEP_127"); @@ -145,7 +147,9 @@ void IGESGeom_ToolBoundary::ReadOwnParams(const occ::handle& // st = PR.ReadInteger(PR.Current(), Msg128, tempSense); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadInteger(PR.Current(), "Orientation flags", tempSense); if (PR.ReadInteger(PR.Current(), tempSense)) + { tempSenses->SetValue(i, tempSense); + } else { Message_Msg Msg128("XTSEP_128"); @@ -229,7 +233,9 @@ void IGESGeom_ToolBoundary::WriteOwnParams(const occ::handle& if (nbc > 0) { for (j = 1; j <= nbc; j++) + { IW.Send(curves->Value(j)); + } } } } @@ -250,7 +256,9 @@ void IGESGeom_ToolBoundary::OwnShared(const occ::handle& ent, { int nbc = curves->Length(); for (j = 1; j <= nbc; j++) + { iter.GetOneItem(curves->Value(j)); + } } } } @@ -284,7 +292,9 @@ void IGESGeom_ToolBoundary::OwnCopy(const occ::handle& anothe another->ParameterCurves(i); occ::handle>> tempParCurves; if (num2 > 0) + { tempParCurves = new NCollection_HArray1>(1, num2); + } for (j = 1; j <= num2; j++) { DeclareAndCast(IGESData_IGESEntity, tempEnt1, TC.Transferred(ParCurves->Value(j))); @@ -309,21 +319,29 @@ bool IGESGeom_ToolBoundary::OwnCorrect(const occ::handle& ent { int nbi = ent->NbParameterCurves(i); if (nbi == 0) + { continue; + } for (int j = 1; j <= nbi; j++) { occ::handle c2d = ent->ParameterCurve(i, j); if (c2d.IsNull()) + { continue; + } c2d->InitStatus(c2d->BlankStatus(), c2d->SubordinateStatus(), 5, c2d->HierarchyStatus()); res = true; } r2d = true; } if (!r2d) + { return res; + } if (ent->BoundaryType() != 0) + { return res; // OK + } // Remaining Boundary Type : if there are ParameterCurves, it must be valued 1 // We therefore reconstruct the Boundary identically, but with BoundaryType = 1 @@ -402,11 +420,13 @@ void IGESGeom_ToolBoundary::OwnCheck(const occ::handle& ent, int i, num; for (num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++) + { if (ent->Sense(i) != 1 && ent->Sense(i) != 2) { Message_Msg Msg128("XTSEP_128"); ach->SendFail(Msg128); } + } /* if (ent->BoundaryType() == 0) for ( num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++ ) @@ -439,6 +459,7 @@ void IGESGeom_ToolBoundary::OwnDump(const occ::handle& ent, IGESData_DumpEntities(S, dumper, -level, 1, ent->NbModelSpaceCurves(), ent->ModelSpaceCurve); S << "\n"; if (level > 4) + { for (num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++) { S << "[" << i << "]: " @@ -458,5 +479,6 @@ void IGESGeom_ToolBoundary::OwnDump(const occ::handle& ent, } S << "\n"; } - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundedSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundedSurface.cxx index 1f53dcc251..9011f5bc85 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundedSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolBoundedSurface.cxx @@ -111,7 +111,9 @@ void IGESGeom_ToolBoundedSurface::ReadOwnParams(const occ::handleSetValue(i, occ::down_cast(tempEnt)); + } else { Message_Msg Msg168("XTSEP_168"); @@ -154,7 +156,9 @@ void IGESGeom_ToolBoundedSurface::WriteOwnParams(const occ::handleSurface()); IW.Send(ent->NbBoundaries()); for (num = ent->NbBoundaries(), i = 1; i <= num; i++) + { IW.Send(ent->Boundary(i)); + } } //================================================================================================= @@ -165,7 +169,9 @@ void IGESGeom_ToolBoundedSurface::OwnShared(const occ::handleSurface()); for (num = ent->NbBoundaries(), i = 1; i <= num; i++) + { iter.GetOneItem(ent->Boundary(i)); + } } //================================================================================================= @@ -181,7 +187,9 @@ void IGESGeom_ToolBoundedSurface::OwnCopy(const occ::handleNbBoundaries(); occ::handle>> tempBounds; if (num > 0) + { tempBounds = new NCollection_HArray1>(1, num); + } for (i = 1; i <= num; i++) { DeclareAndCast(IGESGeom_Boundary, tempBoundary, TC.Transferred(another->Boundary(i))); @@ -240,5 +248,5 @@ void IGESGeom_ToolBoundedSurface::OwnDump(const occ::handleNbBoundaries(), ent->Boundary); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCircularArc.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCircularArc.cxx index fad6518938..0bb1662079 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCircularArc.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCircularArc.cxx @@ -154,8 +154,10 @@ void IGESGeom_ToolCircularArc::OwnDump(const occ::handle& IGESData_DumpXYLZ(S, level, ent->EndPoint(), ent->Location(), ent->ZPlane()); S << "\n"; if (level <= 5) + { return; + } S << " Normal Axis : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCompositeCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCompositeCurve.cxx index dd08a33f11..5743f3dac8 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCompositeCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCompositeCurve.cxx @@ -74,7 +74,9 @@ void IGESGeom_ToolCompositeCurve::WriteOwnParams(const occ::handleNbCurves(), i = 1; i <= num; i++) + { IW.Send(ent->Curve(i)); + } } void IGESGeom_ToolCompositeCurve::OwnShared(const occ::handle& ent, @@ -82,7 +84,9 @@ void IGESGeom_ToolCompositeCurve::OwnShared(const occ::handleNbCurves(); for (int i = 1; i <= num; i++) + { iter.GetOneItem(ent->Curve(i)); + } } void IGESGeom_ToolCompositeCurve::OwnCopy(const occ::handle& another, @@ -126,5 +130,5 @@ void IGESGeom_ToolCompositeCurve::OwnDump(const occ::handleNbCurves(), ent->Curve); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolConicArc.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolConicArc.cxx index 627ee8740a..183e327e98 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolConicArc.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolConicArc.cxx @@ -260,15 +260,25 @@ void IGESGeom_ToolConicArc::OwnDump(const occ::handle& ent, S << "IGESGeom_ConicArc\n"; int cf = ent->FormNumber(); if (cf == 0) + { cf = ent->ComputedFormNumber(); + } if (cf == 1) + { S << " -- Ellipse --\n"; + } else if (cf == 2) + { S << " -- Hyperbola --\n"; + } else if (cf == 3) + { S << " -- Parabola --\n"; + } else + { S << " -- (Undetermined type of Conic) --\n"; + } S << "Conic Coefficient A : " << A << "\n" << "Conic Coefficient B : " << B << "\n" @@ -284,7 +294,9 @@ void IGESGeom_ToolConicArc::OwnDump(const occ::handle& ent, IGESData_DumpXYLZ(S, level, ent->EndPoint(), ent->Location(), ent->ZPlane()); S << "\n"; if (level <= 4) - S << " -- Computed Definition : ask level > 4" << std::endl; + { + S << " -- Computed Definition : ask level > 4" << '\n'; + } else { gp_Pnt Cen; @@ -303,14 +315,20 @@ void IGESGeom_ToolConicArc::OwnDump(const occ::handle& ent, IGESData_DumpXYZL(S, level, Ax, ent->VectorLocation()); S << "\n"; if (cf == 3) + { S << " Focal : " << Rmin << "\n"; + } else if (Rmin == Rmax) + { S << " Radius (Major = Minor) : " << Rmin << "\n"; + } else + { S << " Major Radius : " << Rmax << " Minor Radius : " << Rmin << "\n"; + } S << " Normal Axis : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCopiousData.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCopiousData.cxx index 0225cc62af..b59b216f36 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCopiousData.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCopiousData.cxx @@ -65,7 +65,9 @@ void IGESGeom_ToolCopiousData::ReadOwnParams(const occ::handle 0)) + { data = true; + } else { Message_Msg Msg86("XSTEP_86"); @@ -85,11 +87,17 @@ void IGESGeom_ToolCopiousData::ReadOwnParams(const occ::handle(1, upper) then fill it : @@ -111,16 +119,22 @@ void IGESGeom_ToolCopiousData::WriteOwnParams(const occ::handleDataType() == 1) + { IW.Send(ent->ZPlane()); + } for (int I = 1; I <= upper; I++) { // DataType = 1 : XY , 2 : XYZ , 3 : XYZ*2 IW.Send(ent->Data(I, 1)); IW.Send(ent->Data(I, 2)); if (dtype > 1) + { IW.Send(ent->Data(I, 3)); + } if (dtype <= 2) + { continue; + } IW.Send(ent->Data(I, 4)); IW.Send(ent->Data(I, 5)); IW.Send(ent->Data(I, 6)); @@ -147,16 +161,24 @@ void IGESGeom_ToolCopiousData::OwnCopy(const occ::handle& occ::handle> allData; if (aDataType == 1) + { upper = 2 * nbTuples; + } else if (aDataType == 2) + { upper = 3 * nbTuples; + } else + { upper = 6 * nbTuples; + } allData = new NCollection_HArray1(1, upper); if (aDataType == 1) + { aZPlane = another->ZPlane(); + } for (int I = 1; I <= nbTuples; I++) { @@ -185,9 +207,13 @@ void IGESGeom_ToolCopiousData::OwnCopy(const occ::handle& ent->Init(aDataType, aZPlane, allData); if (another->IsClosedPath2D()) + { ent->SetClosedPath2D(); + } else + { ent->SetPolyline(another->IsPolyline()); + } } //================================================================================================= @@ -262,11 +288,17 @@ void IGESGeom_ToolCopiousData::OwnDump(const occ::handle& S << "IGESGeom_CopiousData\n"; if (ent->IsPointSet()) + { S << "Point Set "; + } else if (ent->IsPolyline()) + { S << "Polyline "; + } else if (ent->IsClosedPath2D()) + { S << "Closed Path 2D "; + } S << "DataType " << ent->DataType() << " " << "Number of T-uples = " << nbPnts << " "; if (dtype == 1) @@ -275,9 +307,13 @@ void IGESGeom_ToolCopiousData::OwnDump(const occ::handle& << "ZPlane = " << ent->ZPlane() << "\n"; } else if (dtype == 2) + { S << "(Points 3D)\n"; + } else if (dtype == 3) + { S << "(Points 3D + Vectors 3D)\n"; + } if (level > 4) { @@ -285,9 +321,13 @@ void IGESGeom_ToolCopiousData::OwnDump(const occ::handle& { gp_XYZ T = ent->Point(i).XYZ(); if (dtype == 1) + { S << "[" << i << "] (" << T.X() << "," << T.Y() << ")"; + } else + { S << "[" << i << "] (" << T.X() << "," << T.Y() << "," << T.Z() << ")"; + } if (yatr) { @@ -305,10 +345,12 @@ void IGESGeom_ToolCopiousData::OwnDump(const occ::handle& S << " Transformed (" << T.X() << "," << T.Y() << "," << T.Z() << ")"; } } - S << std::endl; + S << '\n'; } } else + { S << " [ for content, ask level > 4 ]"; - S << std::endl; + } + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCurveOnSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCurveOnSurface.cxx index 99840f3078..31f31910fa 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCurveOnSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolCurveOnSurface.cxx @@ -183,10 +183,14 @@ bool IGESGeom_ToolCurveOnSurface::OwnCorrect(const occ::handle c2d = ent->CurveUV(); if (c2d.IsNull()) + { return false; + } int uf = c2d->UseFlag(); if (uf == 5) + { return false; + } c2d->InitStatus(c2d->BlankStatus(), c2d->SubordinateStatus(), 5, c2d->HierarchyStatus()); return true; } @@ -249,15 +253,25 @@ void IGESGeom_ToolCurveOnSurface::OwnDump(const occ::handleCreationMode(); S << "Creation Mode : " << crem << " i.e. "; if (crem == 0) + { S << " \n"; + } else if (crem == 1) + { S << " Projection of a Curve on a Surface\n"; + } else if (crem == 2) + { S << " Intersection of two Surfaces\n"; + } else if (crem == 3) + { S << " Isoparametric Curve (either U or V)\n"; + } else + { S << " \n"; + } S << "The Surface on which the curve lies : "; dumper.Dump(ent->Surface(), S, sublevel); S << "\n" @@ -270,13 +284,23 @@ void IGESGeom_ToolCurveOnSurface::OwnDump(const occ::handlePreferenceMode(); S << "Preferred representation mode : " << pref << " i.e. "; if (pref == 0) + { S << " \n"; + } else if (pref == 1) + { S << " Curve B on Surface\n"; + } else if (pref == 2) + { S << " Curve C in 3D Space\n"; + } else if (pref == 3) + { S << " Curves B & C equally preferred\n"; + } else + { S << " \n"; + } } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolDirection.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolDirection.cxx index 01f1dd75d8..0e2d2598c1 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolDirection.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolDirection.cxx @@ -55,7 +55,9 @@ void IGESGeom_ToolDirection::ReadOwnParams(const occ::handle { // st = PR.ReadReal(PR.Current(), "Direction", tmpReal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Direction", tmpReal)) + { aDirection.SetZ(tmpReal); + } } else { @@ -107,7 +109,9 @@ void IGESGeom_ToolDirection::OwnCheck(const occ::handle& ent occ::handle& ach) const { if (ent->Value().XYZ().SquareModulus() <= 0.0) + { ach->AddFail("Direction : The values indicate no direction"); + } } void IGESGeom_ToolDirection::OwnDump(const occ::handle& ent, @@ -118,5 +122,5 @@ void IGESGeom_ToolDirection::OwnDump(const occ::handle& ent, S << "IGESGeom_Direction\n\n" << "Value : "; IGESData_DumpXYZL(S, level, ent->Value(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolFlash.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolFlash.cxx index 3fba8db852..82166ea9e1 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolFlash.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolFlash.cxx @@ -54,27 +54,31 @@ void IGESGeom_ToolFlash::ReadOwnParams(const occ::handle& PR.ReadXY(PR.CurrentList(1, 2), "Reference of Flash", aPoint); //szv#4:S4163:12Mar99 `st=` not needed // Reading first flash sizing parameter - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "First Flash sizing parameter", aDim1); //szv#4:S4163:12Mar99 `st=` not needed - else if (fn > 0) PR.AddFail("Fist Flash sizing parameter : undefined"); + } else if (fn > 0) { PR.AddFail("Fist Flash sizing parameter : undefined"); +} // Reading second flash sizing parameter - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "Second Flash sizing parameter", aDim2); //szv#4:S4163:12Mar99 `st=` not needed - else { - if (fn > 1) PR.AddFail("Second Flash sizing parameter : not defined"); + } else { + if (fn > 1) { PR.AddFail("Second Flash sizing parameter : not defined"); +} } // Reading rotation of flash about reference point - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "Rotation about ref. point", aRotation); //szv#4:S4163:12Mar99 `st=` not needed - else { - if (fn == 2 || fn == 4) PR.AddFail("Rotation about ref. point : not defined"); + } else { + if (fn == 2 || fn == 4) { PR.AddFail("Rotation about ref. point : not defined"); +} } - if ( PR.IsParamEntity(PR.CurrentNumber()) ) + if ( PR.IsParamEntity(PR.CurrentNumber()) ) { // Reading the referenced entity PR.ReadEntity(IR, PR.Current(), "Referenced entity", aReference); //szv#4:S4163:12Mar99 `st=` not needed +} // "else" not necessary as this is the last field // clang-format on @@ -148,7 +152,9 @@ bool IGESGeom_ToolFlash::OwnCorrect(const occ::handle& ent) cons res1 = true; } if (res1) + { ent->Init(ent->ReferencePoint().XY(), d1, d2, rt, ref); + } return (res0 || res1); } @@ -170,18 +176,28 @@ void IGESGeom_ToolFlash::OwnCheck(const occ::handle& ent, { int fn = ent->FormNumber(); if (ent->RankLineFont() != 1) + { ach->AddFail("LineFontPattern : Value != 1"); + } if (ent->ReferenceEntity().IsNull()) { if (fn == 0) + { ach->AddFail("Flash defined by a Reference Entity, which is absent"); + } } else if (fn != 0) + { ach->AddWarning("Reference Entity present though useless"); + } if (fn == 1 && ent->Dimension2() != 0.) + { ach->AddWarning("Dimension 2 present though useless"); + } if ((fn == 1 || fn == 3) && ent->Rotation() != 0.) + { ach->AddWarning("Rotation present though useless"); + } } void IGESGeom_ToolFlash::OwnDump(const occ::handle& ent, @@ -221,5 +237,5 @@ void IGESGeom_ToolFlash::OwnDump(const occ::handle& ent, << " Rotation about reference entity : " << ent->Rotation() << "\n" << "Reference Entity : "; dumper.Dump(ent->ReferenceEntity(), S, sublevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolLine.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolLine.cxx index 592381ed3f..c9de36c88d 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolLine.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolLine.cxx @@ -126,5 +126,5 @@ void IGESGeom_ToolLine::OwnDump(const occ::handle& ent, S << "\n" "End Point : "; IGESData_DumpXYZL(S, level, ent->EndPoint(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetCurve.cxx index 46b1dd1752..0a0a7f8979 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetCurve.cxx @@ -283,10 +283,14 @@ void IGESGeom_ToolOffsetCurve::OwnCopy(const occ::handle& bool IGESGeom_ToolOffsetCurve::OwnCorrect(const occ::handle& ent) const { if (ent->OffsetType() == 3) + { return false; + } occ::handle func = ent->Function(); if (func.IsNull()) + { return false; + } // OffsetType != 3 : reconstruct with Null Offset Function func.Nullify(); ent->Init(ent->BaseCurve(), @@ -376,5 +380,5 @@ void IGESGeom_ToolOffsetCurve::OwnDump(const occ::handle& IGESData_DumpXYZL(S, level, ent->NormalVector(), ent->VectorLocation()); S << "\n"; S << "Offset curve Parameters. Starting : " << ent->StartParameter() << " " - << "Ending : " << ent->EndParameter() << std::endl; + << "Ending : " << ent->EndParameter() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetSurface.cxx index 70a9a1f76c..fb558390d4 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolOffsetSurface.cxx @@ -158,5 +158,5 @@ void IGESGeom_ToolOffsetSurface::OwnDump(const occ::handleDistance() << " " << "Surface to be offset : "; dumper.Dump(ent->Surface(), S, sublevel); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPlane.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPlane.cxx index a061e22b7b..968a12b5e2 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPlane.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPlane.cxx @@ -222,7 +222,9 @@ void IGESGeom_ToolPlane::OwnCheck(const occ::handle& ent, // if ( (A*A + B*B + C*C) < eps) // not null ! // ach.SendFail("Incorrect Coefficients for the Plane"); if (!ent->HasBoundingCurve()) + { return; + } // Symbol : check if Size defined > 0 (otherwise, has no meaning) /* double ec = 0.; if (ent->SymbolSize() > 0.) ec = A*ent->SymbolAttach().X() + B*ent->SymbolAttach().Y() + @@ -257,5 +259,5 @@ void IGESGeom_ToolPlane::OwnDump(const occ::handle& ent, S << "\n" << "Display Symbol Location : "; IGESData_DumpXYZL(S, level, ent->SymbolAttach(), ent->Location()); - S << " Size : " << ent->SymbolSize() << std::endl; + S << " Size : " << ent->SymbolSize() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPoint.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPoint.cxx index 5dea4c1bd6..667cab4be5 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPoint.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolPoint.cxx @@ -155,5 +155,5 @@ void IGESGeom_ToolPoint::OwnDump(const occ::handle& ent, S << "\n" << " Display Symbol : "; dumper.Dump(ent->DisplaySymbol(), S, (level <= 4) ? 0 : 1); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolRuledSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolRuledSurface.cxx index 927c00ef54..c55a714f36 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolRuledSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolRuledSurface.cxx @@ -170,11 +170,19 @@ void IGESGeom_ToolRuledSurface::OwnDump(const occ::handle S << "\n" << "Direction Flag : " << ent->DirectionFlag() << " i.e."; if (ent->DirectionFlag() == 0) + { S << "Join First to First, Last to Last\n"; + } else + { S << "Join First to Last, Last to First\n"; + } if (ent->IsDevelopable()) + { S << " .. Is Developable\n"; + } else + { S << " .. Is possibly not developable ..\n"; + } } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineCurve.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineCurve.cxx index 8faa82fa53..f55b4bed2d 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineCurve.cxx @@ -124,7 +124,9 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(I, J, temp->Value(J)); + } } // st = PR.ReadReals(PR.CurrentList(4),"Y-Coordinate Polynomial",temp); //szv#4:S4163:12Mar99 @@ -133,7 +135,9 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(I, J, temp->Value(J)); + } } // st = PR.ReadReals(PR.CurrentList(4),"Z-Coordinate Polynomial",temp); //szv#4:S4163:12Mar99 @@ -142,7 +146,9 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(I, J, temp->Value(J)); + } } } } @@ -153,7 +159,9 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(J, temp->Value(J)); + } } // st = PR.ReadReals(PR.CurrentList(4), "TerminatePoint Y-Values", temp); //szv#4:S4163:12Mar99 @@ -162,7 +170,9 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(J, temp->Value(J)); + } } // st = PR.ReadReals(PR.CurrentList(4), "TerminatePoint Z-Values", temp); //szv#4:S4163:12Mar99 @@ -171,14 +181,18 @@ void IGESGeom_ToolSplineCurve::ReadOwnParams(const occ::handleSetValue(J, temp->Value(J)); + } } // sln 28.09.2001, BUC61004, If the condition is true function ent->Init is not called in order to // avoid exception if (allBreakPoints.IsNull() || allXPolynomials.IsNull() || allYPolynomials.IsNull() || allZPolynomials.IsNull()) + { return; + } else { DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -206,7 +220,9 @@ void IGESGeom_ToolSplineCurve::WriteOwnParams(const occ::handleBreakPoint(I)); + } double AX, BX, CX, DX, AY, BY, CY, DY, AZ, BZ, CZ, DZ; for (I = 1; I <= nbSegments; I++) { @@ -264,7 +280,9 @@ void IGESGeom_ToolSplineCurve::OwnCopy(const occ::handle& occ::handle> allBreakPoints = new NCollection_HArray1(1, nbSegments + 1); for (I = 1; I <= (nbSegments + 1); I++) + { allBreakPoints->SetValue(I, another->BreakPoint(I)); + } occ::handle> allXPolynomials = new NCollection_HArray2(1, nbSegments, 1, 4); @@ -415,7 +433,7 @@ void IGESGeom_ToolSplineCurve::OwnDump(const occ::handle& IGESData_DumpVals(S, level, 1, nbSegments + 1, ent->BreakPoint); if (level <= 4) { - S << " [ also ask level > 4 for X-Y-Z Polynomials ]" << std::endl; + S << " [ also ask level > 4 for X-Y-Z Polynomials ]" << '\n'; return; } S << " -- Polynomial Values --\n"; @@ -440,5 +458,5 @@ void IGESGeom_ToolSplineCurve::OwnDump(const occ::handle& << " Value " << AX << " " << AY << " " << AZ << "\n" << " 1st Derivative " << BX << " " << BY << " " << BZ << "\n" << " 2nd Der./2! " << CX << " " << CY << " " << CZ << "\n" - << " 3rd Der./3! " << DX << " " << DY << " " << DZ << std::endl; + << " 3rd Der./3! " << DX << " " << DY << " " << DZ << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineSurface.cxx index 344ae567e3..909217864d 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSplineSurface.cxx @@ -146,7 +146,9 @@ void IGESGeom_ToolSplineSurface::ReadOwnParams(const occ::handleLength() == 16) + { allXCoeffs->SetValue(i, j, Temp); + } else { Message_Msg Msg147_X("XSTEP_147"); @@ -156,7 +158,9 @@ void IGESGeom_ToolSplineSurface::ReadOwnParams(const occ::handleLength() == 16) + { allYCoeffs->SetValue(i, j, Temp); + } else { Message_Msg Msg147_Y("XSTEP_147"); @@ -166,7 +170,9 @@ void IGESGeom_ToolSplineSurface::ReadOwnParams(const occ::handleLength() == 16) + { allZCoeffs->SetValue(i, j, Temp); + } else if (i < allNbUSegments || j < allNbVSegments) { Message_Msg Msg147_Z("XSTEP_147"); @@ -196,13 +202,19 @@ void IGESGeom_ToolSplineSurface::ReadOwnParams(const occ::handleUBreakPoint(I)); + } for (I = 1; I <= nbVSegs + 1; I++) + { IW.Send(ent->VBreakPoint(I)); + } for (I = 1; I <= nbUSegs; I++) { for (J = 1; J <= nbVSegs; J++) { for (k = 1; k <= 16; k++) + { IW.Send((ent->XPolynomial(I, J))->Value(k)); + } for (k = 1; k <= 16; k++) + { IW.Send((ent->YPolynomial(I, J))->Value(k)); + } for (k = 1; k <= 16; k++) + { IW.Send((ent->ZPolynomial(I, J))->Value(k)); + } } for (k = 1; k <= 48; k++) + { IW.Send(0.0); // Send Arbitrary Values + } } for (J = 1; J <= (nbVSegs + 1) * 48; J++) + { IW.Send(0.0); // Send Arbitrary Values + } } void IGESGeom_ToolSplineSurface::OwnShared(const occ::handle& /* ent */, @@ -277,10 +303,14 @@ void IGESGeom_ToolSplineSurface::OwnCopy(const occ::handle(1, allNbVSegments + 1); for (I = 1; I <= allNbUSegments + 1; I++) + { allUBreakPoints->SetValue(I, another->UBreakPoint(I)); + } for (I = 1; I <= allNbVSegments + 1; I++) + { allVBreakPoints->SetValue(I, another->VBreakPoint(I)); + } occ::handle>>> allXCoeffs = new NCollection_HArray2>>(1, @@ -303,6 +333,7 @@ void IGESGeom_ToolSplineSurface::OwnCopy(const occ::handle> temp = new NCollection_HArray1(1, 16); for (I = 1; I <= allNbUSegments; I++) + { for (J = 1; J <= allNbVSegments; J++) { temp = another->XPolynomial(I, J); @@ -312,6 +343,7 @@ void IGESGeom_ToolSplineSurface::OwnCopy(const occ::handleZPolynomial(I, J); allZCoeffs->SetValue(I, J, temp); } + } ent->Init(aBoundaryType, aPatchType, @@ -394,9 +426,13 @@ void IGESGeom_ToolSplineSurface::OwnDump(const occ::handlePatchType(); if (ent->PatchType() == 1) + { S << " (Cartesian Product)"; + } else + { S << " (Unspecified)"; + } S << "\n" << "Number Of Segments. In U : " << nbUSegs << " In V : " << nbVSegs << "\n" << "The U Break Points : "; @@ -408,6 +444,7 @@ void IGESGeom_ToolSplineSurface::OwnDump(const occ::handle 4) { for (I = 1; I <= nbUSegs; I++) + { for (J = 1; J <= nbVSegs; J++) { S << "[" << I << "," << J << "]:\n" @@ -424,7 +461,10 @@ void IGESGeom_ToolSplineSurface::OwnDump(const occ::handleLength(), temp->Value); S << "\n"; } + } } else - S << std::endl; + { + S << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSurfaceOfRevolution.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSurfaceOfRevolution.cxx index 96101ac484..ab36b875ee 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSurfaceOfRevolution.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolSurfaceOfRevolution.cxx @@ -185,5 +185,5 @@ void IGESGeom_ToolSurfaceOfRevolution::OwnDump(const occ::handleGeneratrix(), S, sublevel); S << "\n" << "Start Angle : " << ent->StartAngle() << " " - << "End Angle : " << ent->EndAngle() << std::endl; + << "End Angle : " << ent->EndAngle() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTabulatedCylinder.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTabulatedCylinder.cxx index 2d569c9ccf..83eecfc27f 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTabulatedCylinder.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTabulatedCylinder.cxx @@ -146,5 +146,5 @@ void IGESGeom_ToolTabulatedCylinder::OwnDump(const occ::handleEndPoint(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTransformationMatrix.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTransformationMatrix.cxx index a9f8955a86..0a7d7ae9e2 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTransformationMatrix.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTransformationMatrix.cxx @@ -57,7 +57,9 @@ void IGESGeom_ToolTransformationMatrix::ReadOwnParams( // st = PR.ReadReal(PR.Current(), Msg215, temp); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadReal(PR.Current(), "Matrix Elements", temp); if (PR.ReadReal(PR.Current(), temp)) + { aMatrix->SetValue(I, J, temp); + } else { Message_Msg Msg215("XSTEP_215"); @@ -119,10 +121,14 @@ bool IGESGeom_ToolTransformationMatrix::OwnCorrect( const occ::handle& ent) const { if (ent->FormNumber() > 1) + { return false; + } int cfn = (ent->Value().IsNegative() ? 1 : 0); if (cfn == ent->FormNumber()) + { return false; + } ent->SetFormNumber(cfn); return true; } @@ -203,22 +209,22 @@ void IGESGeom_ToolTransformationMatrix::OwnDump( switch (ent->FormNumber()) { case 0: - S << "-- Direct Orthogonal Matrix" << std::endl; + S << "-- Direct Orthogonal Matrix" << '\n'; break; case 1: - S << "-- Reverse Orthogonal Matrix" << std::endl; + S << "-- Reverse Orthogonal Matrix" << '\n'; break; case 10: - S << "-- Cartesien Coordinate System" << std::endl; + S << "-- Cartesien Coordinate System" << '\n'; break; case 11: - S << "-- Cylindrical Coordinate System" << std::endl; + S << "-- Cylindrical Coordinate System" << '\n'; break; case 12: - S << "-- Spherical Coordinate System" << std::endl; + S << "-- Spherical Coordinate System" << '\n'; break; default: - S << "-- (Incorrect Form Number)" << std::endl; + S << "-- (Incorrect Form Number)" << '\n'; break; } } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTrimmedSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTrimmedSurface.cxx index 2ffcca927b..57cf4ac311 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTrimmedSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_ToolTrimmedSurface.cxx @@ -98,7 +98,9 @@ void IGESGeom_ToolTrimmedSurface::ReadOwnParams(const occ::handle 0) + { anInner = new NCollection_HArray1>(1, count); + } } else { @@ -153,7 +155,9 @@ void IGESGeom_ToolTrimmedSurface::ReadOwnParams(const occ::handleSetValue(I, tempEnt); + } else { Message_Msg Msg173("XSTEP_173"); @@ -199,12 +203,18 @@ void IGESGeom_ToolTrimmedSurface::WriteOwnParams(const occ::handleOuterBoundaryType()) + { IW.Send(ent->OuterContour()); + } else + { IW.Send(0); + } int I; for (I = 1; I <= up; I++) + { IW.Send(ent->InnerContour(I)); + } } //================================================================================================= @@ -217,7 +227,9 @@ void IGESGeom_ToolTrimmedSurface::OwnShared(const occ::handleOuterContour()); int I; for (I = 1; I <= up; I++) + { iter.GetOneItem(ent->InnerContour(I)); + } } //================================================================================================= @@ -301,5 +313,5 @@ void IGESGeom_ToolTrimmedSurface::OwnDump(const occ::handleNbInnerContours(), ent->InnerContour); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TransformationMatrix.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TransformationMatrix.cxx index 56d907aa26..8aa1f03221 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TransformationMatrix.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TransformationMatrix.cxx @@ -34,10 +34,14 @@ void IGESGeom_TransformationMatrix::Init(const occ::handleInit(0.0); int i = 1; for (; i <= 3; i++) + { theData->SetValue(i, i, 1.0); + } } if ((aMatrix->RowLength() != 4) || (aMatrix->ColLength() != 3)) + { throw Standard_DimensionMismatch("IGESGeom_TransformationMatrix : Init"); + } theData = aMatrix; if (theData.IsNull()) @@ -50,9 +54,13 @@ void IGESGeom_TransformationMatrix::Init(const occ::handle 1) && (fm < 10 || fm > 12)) + { throw Standard_OutOfRange("IGESGeom_TransformationMatrix : SetFormNumber"); + } InitTypeAndForm(124, fm); } diff --git a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TrimmedSurface.cxx b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TrimmedSurface.cxx index 24e4896dd6..d21e7f2021 100644 --- a/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TrimmedSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESGeom/IGESGeom_TrimmedSurface.cxx @@ -31,8 +31,12 @@ void IGESGeom_TrimmedSurface::Init( const occ::handle>>& anInner) { if (!anInner.IsNull()) + { if (anInner->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGeom_TrimmedSurface : Init"); + } + } theSurface = aSurface; theFlag = aFlag; diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_DefinitionLevel.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_DefinitionLevel.cxx index dd51b0b5bf..e8d2bf5de1 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_DefinitionLevel.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_DefinitionLevel.cxx @@ -27,7 +27,9 @@ IGESGraph_DefinitionLevel::IGESGraph_DefinitionLevel() = default; void IGESGraph_DefinitionLevel::Init(const occ::handle>& allLevelNumbers) { if (allLevelNumbers->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGraph_DefinitionLevel : Init"); + } theLevelNumbers = allLevelNumbers; InitTypeAndForm(406, 1); } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_GeneralModule.cxx index 51a802ba11..1f812ff4ee 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_GeneralModule.cxx @@ -66,7 +66,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolColor tool; tool.OwnShared(anent, iter); } @@ -74,7 +76,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDefinitionLevel tool; tool.OwnShared(anent, iter); } @@ -82,7 +86,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingSize tool; tool.OwnShared(anent, iter); } @@ -90,7 +96,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingUnits tool; tool.OwnShared(anent, iter); } @@ -98,7 +106,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolHighLight tool; tool.OwnShared(anent, iter); } @@ -106,7 +116,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolIntercharacterSpacing tool; tool.OwnShared(anent, iter); } @@ -114,7 +126,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefPattern tool; tool.OwnShared(anent, iter); } @@ -122,7 +136,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontPredefined tool; tool.OwnShared(anent, iter); } @@ -130,7 +146,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefTemplate tool; tool.OwnShared(anent, iter); } @@ -138,7 +156,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolNominalSize tool; tool.OwnShared(anent, iter); } @@ -146,7 +166,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolPick tool; tool.OwnShared(anent, iter); } @@ -154,7 +176,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextDisplayTemplate tool; tool.OwnShared(anent, iter); } @@ -162,7 +186,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextFontDef tool; tool.OwnShared(anent, iter); } @@ -170,7 +196,9 @@ void IGESGraph_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolUniformRectGrid tool; tool.OwnShared(anent, iter); } @@ -189,98 +217,126 @@ IGESData_DirChecker IGESGraph_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolColor tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolDefinitionLevel tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolDrawingSize tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolDrawingUnits tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolHighLight tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolIntercharacterSpacing tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolLineFontDefPattern tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolLineFontPredefined tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolLineFontDefTemplate tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolNominalSize tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolPick tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolTextDisplayTemplate tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolTextFontDef tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolUniformRectGrid tool; return tool.DirChecker(anent); } @@ -300,7 +356,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolColor tool; tool.OwnCheck(anent, shares, ach); } @@ -308,7 +366,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDefinitionLevel tool; tool.OwnCheck(anent, shares, ach); } @@ -316,7 +376,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingSize tool; tool.OwnCheck(anent, shares, ach); } @@ -324,7 +386,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingUnits tool; tool.OwnCheck(anent, shares, ach); } @@ -332,7 +396,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolHighLight tool; tool.OwnCheck(anent, shares, ach); } @@ -340,7 +406,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolIntercharacterSpacing tool; tool.OwnCheck(anent, shares, ach); } @@ -348,7 +416,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefPattern tool; tool.OwnCheck(anent, shares, ach); } @@ -356,7 +426,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontPredefined tool; tool.OwnCheck(anent, shares, ach); } @@ -364,7 +436,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefTemplate tool; tool.OwnCheck(anent, shares, ach); } @@ -372,7 +446,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolNominalSize tool; tool.OwnCheck(anent, shares, ach); } @@ -380,7 +456,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolPick tool; tool.OwnCheck(anent, shares, ach); } @@ -388,7 +466,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextDisplayTemplate tool; tool.OwnCheck(anent, shares, ach); } @@ -396,7 +476,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextFontDef tool; tool.OwnCheck(anent, shares, ach); } @@ -404,7 +486,9 @@ void IGESGraph_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolUniformRectGrid tool; tool.OwnCheck(anent, shares, ach); } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_LineFontDefPattern.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_LineFontDefPattern.cxx index bc02bf0c21..d1c49249b3 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_LineFontDefPattern.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_LineFontDefPattern.cxx @@ -32,7 +32,9 @@ void IGESGraph_LineFontDefPattern::Init( const occ::handle& aPattern) { if (allSegLength->Lower() != 1) + { throw Standard_DimensionMismatch("IGESGraph_LineFontDefPattern : Init"); + } theSegmentLengths = allSegLength; theDisplayPattern = aPattern; InitTypeAndForm(304, 2); @@ -58,7 +60,9 @@ bool IGESGraph_LineFontDefPattern::IsVisible(const int Index) const { int nbSegs = theSegmentLengths->Length(); if (Index <= 0 || Index > nbSegs) + { return false; + } // Get the Character out of String, which contains the required BIT char tempStr[2]; diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_Protocol.cxx index 1d64b08d59..9dc35613e4 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_Protocol.cxx @@ -50,32 +50,60 @@ occ::handle IGESGraph_Protocol::Resource(const int /*num*/) int IGESGraph_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESGraph_Color)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESGraph_DefinitionLevel)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESGraph_DrawingSize)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESGraph_DrawingUnits)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESGraph_HighLight)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESGraph_IntercharacterSpacing)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESGraph_LineFontDefPattern)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESGraph_LineFontPredefined)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESGraph_LineFontDefTemplate)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESGraph_NominalSize)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESGraph_Pick)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESGraph_TextDisplayTemplate)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESGraph_TextFontDef)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESGraph_UniformRectGrid)) + { return 14; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ReadWriteModule.cxx index fc7c47ab9f..c4a69d313b 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ReadWriteModule.cxx @@ -59,9 +59,13 @@ int IGESGraph_ReadWriteModule::CaseIGES(const int typenum, const int formnum) co { case 304: if (formnum == 1) + { return 9; + } else if (formnum == 2) + { return 7; + } break; case 310: return 13; @@ -110,7 +114,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolColor tool; tool.ReadOwnParams(anent, IR, PR); } @@ -118,7 +124,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDefinitionLevel tool; tool.ReadOwnParams(anent, IR, PR); } @@ -126,7 +134,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingSize tool; tool.ReadOwnParams(anent, IR, PR); } @@ -134,7 +144,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingUnits tool; tool.ReadOwnParams(anent, IR, PR); } @@ -142,7 +154,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolHighLight tool; tool.ReadOwnParams(anent, IR, PR); } @@ -150,7 +164,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolIntercharacterSpacing tool; tool.ReadOwnParams(anent, IR, PR); } @@ -158,7 +174,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefPattern tool; tool.ReadOwnParams(anent, IR, PR); } @@ -166,7 +184,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontPredefined tool; tool.ReadOwnParams(anent, IR, PR); } @@ -174,7 +194,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefTemplate tool; tool.ReadOwnParams(anent, IR, PR); } @@ -182,7 +204,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolNominalSize tool; tool.ReadOwnParams(anent, IR, PR); } @@ -190,7 +214,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolPick tool; tool.ReadOwnParams(anent, IR, PR); } @@ -198,7 +224,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextDisplayTemplate tool; tool.ReadOwnParams(anent, IR, PR); } @@ -206,7 +234,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextFontDef tool; tool.ReadOwnParams(anent, IR, PR); } @@ -214,7 +244,9 @@ void IGESGraph_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolUniformRectGrid tool; tool.ReadOwnParams(anent, IR, PR); } @@ -233,7 +265,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolColor tool; tool.WriteOwnParams(anent, IW); } @@ -241,7 +275,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDefinitionLevel tool; tool.WriteOwnParams(anent, IW); } @@ -249,7 +285,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingSize tool; tool.WriteOwnParams(anent, IW); } @@ -257,7 +295,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingUnits tool; tool.WriteOwnParams(anent, IW); } @@ -265,7 +305,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolHighLight tool; tool.WriteOwnParams(anent, IW); } @@ -273,7 +315,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolIntercharacterSpacing tool; tool.WriteOwnParams(anent, IW); } @@ -281,7 +325,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefPattern tool; tool.WriteOwnParams(anent, IW); } @@ -289,7 +335,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontPredefined tool; tool.WriteOwnParams(anent, IW); } @@ -297,7 +345,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefTemplate tool; tool.WriteOwnParams(anent, IW); } @@ -305,7 +355,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolNominalSize tool; tool.WriteOwnParams(anent, IW); } @@ -313,7 +365,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolPick tool; tool.WriteOwnParams(anent, IW); } @@ -321,7 +375,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextDisplayTemplate tool; tool.WriteOwnParams(anent, IW); } @@ -329,7 +385,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextFontDef tool; tool.WriteOwnParams(anent, IW); } @@ -337,7 +395,9 @@ void IGESGraph_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolUniformRectGrid tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_SpecificModule.cxx index e3c0ae4dab..3cf6980edc 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_SpecificModule.cxx @@ -63,7 +63,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 1: { DeclareAndCast(IGESGraph_Color, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolColor tool; tool.OwnDump(anent, dumper, S, own); } @@ -71,7 +73,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 2: { DeclareAndCast(IGESGraph_DefinitionLevel, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDefinitionLevel tool; tool.OwnDump(anent, dumper, S, own); } @@ -79,7 +83,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingSize tool; tool.OwnDump(anent, dumper, S, own); } @@ -87,7 +93,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolDrawingUnits tool; tool.OwnDump(anent, dumper, S, own); } @@ -95,7 +103,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolHighLight tool; tool.OwnDump(anent, dumper, S, own); } @@ -103,7 +113,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolIntercharacterSpacing tool; tool.OwnDump(anent, dumper, S, own); } @@ -111,7 +123,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 7: { DeclareAndCast(IGESGraph_LineFontDefPattern, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefPattern tool; tool.OwnDump(anent, dumper, S, own); } @@ -119,7 +133,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontPredefined tool; tool.OwnDump(anent, dumper, S, own); } @@ -127,7 +143,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 9: { DeclareAndCast(IGESGraph_LineFontDefTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolLineFontDefTemplate tool; tool.OwnDump(anent, dumper, S, own); } @@ -135,7 +153,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolNominalSize tool; tool.OwnDump(anent, dumper, S, own); } @@ -143,7 +163,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolPick tool; tool.OwnDump(anent, dumper, S, own); } @@ -151,7 +173,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 12: { DeclareAndCast(IGESGraph_TextDisplayTemplate, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextDisplayTemplate tool; tool.OwnDump(anent, dumper, S, own); } @@ -159,7 +183,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 13: { DeclareAndCast(IGESGraph_TextFontDef, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolTextFontDef tool; tool.OwnDump(anent, dumper, S, own); } @@ -167,7 +193,9 @@ void IGESGraph_SpecificModule::OwnDump(const int C case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { return; + } IGESGraph_ToolUniformRectGrid tool; tool.OwnDump(anent, dumper, S, own); } @@ -186,56 +214,72 @@ bool IGESGraph_SpecificModule::OwnCorrect(const int case 3: { DeclareAndCast(IGESGraph_DrawingSize, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolDrawingSize tool; return tool.OwnCorrect(anent); } case 4: { DeclareAndCast(IGESGraph_DrawingUnits, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolDrawingUnits tool; return tool.OwnCorrect(anent); } case 5: { DeclareAndCast(IGESGraph_HighLight, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolHighLight tool; return tool.OwnCorrect(anent); } case 6: { DeclareAndCast(IGESGraph_IntercharacterSpacing, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolIntercharacterSpacing tool; return tool.OwnCorrect(anent); } case 8: { DeclareAndCast(IGESGraph_LineFontPredefined, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolLineFontPredefined tool; return tool.OwnCorrect(anent); } case 10: { DeclareAndCast(IGESGraph_NominalSize, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolNominalSize tool; return tool.OwnCorrect(anent); } case 11: { DeclareAndCast(IGESGraph_Pick, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolPick tool; return tool.OwnCorrect(anent); } case 14: { DeclareAndCast(IGESGraph_UniformRectGrid, anent, ent); if (anent.IsNull()) + { break; + } IGESGraph_ToolUniformRectGrid tool; return tool.OwnCorrect(anent); } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextDisplayTemplate.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextDisplayTemplate.cxx index d3219cf9de..aa8f3223ea 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextDisplayTemplate.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextDisplayTemplate.cxx @@ -113,6 +113,8 @@ gp_Pnt IGESGraph_TextDisplayTemplate::TransformedStartingCorner() const { gp_XYZ TempXYZ = theCorner; if (HasTransf()) + { Location().Transforms(TempXYZ); + } return (gp_Pnt(TempXYZ)); } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextFontDef.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextFontDef.cxx index 5a21189c88..9cebbc94ef 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextFontDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_TextFontDef.cxx @@ -47,7 +47,9 @@ void IGESGraph_TextFontDef::Init( || (allPenFlags->Lower() != 1 || allPenFlags->Length() != Len) || (allMovePenToX->Lower() != 1 || allMovePenToX->Length() != Len) || (allMovePenToY->Lower() != 1 || allMovePenToY->Length() != Len)) + { throw Standard_DimensionMismatch("IGESGraph_TextFontDef : Init"); + } theFontCode = aFontCode; theFontName = aFontName; diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolColor.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolColor.cxx index 0813a0f2aa..0146753a6b 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolColor.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolColor.cxx @@ -48,7 +48,9 @@ void IGESGraph_ToolColor::ReadOwnParams(const occ::handle& ent, if ((PR.CurrentNumber() <= PR.NbParams()) && (PR.ParamType(PR.CurrentNumber()) == Interface_ParamText)) + { PR.ReadText(PR.Current(), "Color Name", tempColorName); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempRed, tempGreen, tempBlue, tempColorName); @@ -64,9 +66,13 @@ void IGESGraph_ToolColor::WriteOwnParams(const occ::handle& ent IW.Send(Blue); // WARNING place to reserve (Null) if there are additional pointers if (ent->HasColorName()) + { IW.Send(ent->ColorName()); + } else + { IW.SendVoid(); // placekeeper to be reserved for additional pointers + } } void IGESGraph_ToolColor::OwnShared(const occ::handle& /*ent*/, @@ -82,7 +88,9 @@ void IGESGraph_ToolColor::OwnCopy(const occ::handle& another, occ::handle tempColorName; another->RGBIntensity(tempRed, tempGreen, tempBlue); if (another->HasColorName()) + { tempColorName = new TCollection_HAsciiString(another->ColorName()); + } ent->Init(tempRed, tempGreen, tempBlue, tempColorName); } @@ -127,5 +135,5 @@ void IGESGraph_ToolColor::OwnDump(const occ::handle& ent, << "Blue (in % Of Full Intensity) : " << Blue << "\n" << "Color Name : "; IGESData_DumpString(S, ent->ColorName()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDefinitionLevel.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDefinitionLevel.cxx index 0b65204417..5bacaffafc 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDefinitionLevel.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDefinitionLevel.cxx @@ -56,7 +56,9 @@ void IGESGraph_ToolDefinitionLevel::ReadOwnParams( // clang-format on } else + { PR.AddFail("No. of Property Values : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(levelNumbers); @@ -69,7 +71,9 @@ void IGESGraph_ToolDefinitionLevel::WriteOwnParams( int Up = ent->NbPropertyValues(); IW.Send(Up); for (int i = 1; i <= Up; i++) + { IW.Send(ent->LevelNumber(i)); + } } void IGESGraph_ToolDefinitionLevel::OwnShared(const occ::handle& /*ent*/, @@ -88,7 +92,9 @@ void IGESGraph_ToolDefinitionLevel::OwnCopy(const occ::handle(1, nbval); for (int i = 1; i <= nbval; i++) + { levelNumbers->SetValue(i, another->LevelNumber(i)); + } ent->Init(levelNumbers); } @@ -121,5 +127,5 @@ void IGESGraph_ToolDefinitionLevel::OwnDump(const occ::handleNbPropertyValues(), ent->LevelNumber); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingSize.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingSize.cxx index 18dd2e5933..1031cd30b0 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingSize.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingSize.cxx @@ -43,8 +43,9 @@ void IGESGraph_ToolDrawingSize::ReadOwnParams(const occ::handleNbPropertyValues() != 2); if (res) + { ent->Init(2, ent->XSize(), ent->YSize()); // nbpropertyvalues=2 + } return res; } @@ -104,7 +107,9 @@ void IGESGraph_ToolDrawingSize::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 2) + { ach->AddFail("No. of Property values : Value != 2"); + } } void IGESGraph_ToolDrawingSize::OwnDump(const occ::handle& ent, @@ -116,5 +121,5 @@ void IGESGraph_ToolDrawingSize::OwnDump(const occ::handle << "No. of property values : " << ent->NbPropertyValues() << "\n" << "Drawing extent along positive X-axis : " << ent->XSize() << "\n" << "Drawing extent along positive Y-axis : " << ent->YSize() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingUnits.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingUnits.cxx index f40de29cb2..5a072db9cc 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingUnits.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolDrawingUnits.cxx @@ -48,7 +48,9 @@ void IGESGraph_ToolDrawingUnits::ReadOwnParams(const occ::handle name; const char* unm = ""; if (!ent->Unit().IsNull()) + { unm = ent->Unit()->ToCString(); + } switch (unf) { case 1: @@ -167,9 +171,13 @@ bool IGESGraph_ToolDrawingUnits::OwnCorrect(const occ::handleUnit(); + } if (res) + { ent->Init(2, unf, name); // nbpropertyvalues=2 + Unit Flag//Name + } return res; } @@ -192,13 +200,17 @@ void IGESGraph_ToolDrawingUnits::OwnCheck(const occ::handle& ach) const { if (ent->NbPropertyValues() != 2) + { ach->AddFail("No. of Property values : Value != 2"); + } // Check Flag//Unit Name int unf = ent->Flag(); if (ent->Unit().IsNull()) { if (unf == 3) + { ach->AddFail("Unit Flag = 3 (user def.) and Unit Name undefined"); + } } else { @@ -244,7 +256,9 @@ void IGESGraph_ToolDrawingUnits::OwnCheck(const occ::handleAddFail("Unit Flag & Name not accorded"); + } } } @@ -257,5 +271,5 @@ void IGESGraph_ToolDrawingUnits::OwnDump(const occ::handleNbPropertyValues() << "\n" << " Units Flag : " << ent->Flag() << " Units Name : "; IGESData_DumpString(S, ent->Unit()); - S << " computed Value (in meters) : " << ent->UnitValue() << std::endl; + S << " computed Value (in meters) : " << ent->UnitValue() << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolHighLight.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolHighLight.cxx index 4e08663c08..5ae7c6843e 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolHighLight.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolHighLight.cxx @@ -40,13 +40,19 @@ void IGESGraph_ToolHighLight::ReadOwnParams(const occ::handleInit(nbPropertyValues, highLightStatus); @@ -75,7 +81,9 @@ bool IGESGraph_ToolHighLight::OwnCorrect(const occ::handle& { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->HighLightStatus()); // nbpropertyvalues=1 + } return res; } @@ -98,7 +106,9 @@ void IGESGraph_ToolHighLight::OwnCheck(const occ::handle& e occ::handle& ach) const { if (ent->NbPropertyValues() != 1) + { ach->AddFail("No. of Property values : Value != 1"); + } } void IGESGraph_ToolHighLight::OwnDump(const occ::handle& ent, @@ -109,5 +119,5 @@ void IGESGraph_ToolHighLight::OwnDump(const occ::handle& en S << "IGESGraph_HighLight\n" << "No. of property values : " << ent->NbPropertyValues() << "\n" << "Highlight Status : " << ent->HighLightStatus() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolIntercharacterSpacing.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolIntercharacterSpacing.cxx index 054ab6bb16..1e376b9187 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolIntercharacterSpacing.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolIntercharacterSpacing.cxx @@ -43,8 +43,9 @@ void IGESGraph_ToolIntercharacterSpacing::ReadOwnParams( // Reading nbPropertyValues(Integer) // clang-format off PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); //szv#4:S4163:12Mar99 `st=` not needed - if (nbPropertyValues != 1) + if (nbPropertyValues != 1) { PR.AddFail("No. of Property values : Value is not 1"); +} // Reading iSpace(Real) PR.ReadReal(PR.Current(), "Intercharacter space in % of text height", iSpace); //szv#4:S4163:12Mar99 `st=` not needed @@ -81,7 +82,9 @@ bool IGESGraph_ToolIntercharacterSpacing::OwnCorrect( { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->ISpace()); // nbpropertyvalues=1 + } return res; } @@ -105,9 +108,13 @@ void IGESGraph_ToolIntercharacterSpacing::OwnCheck( occ::handle& ach) const { if ((ent->ISpace() < 0.0) || (ent->ISpace() > 100.0)) + { ach->AddFail("Intercharacter Space : Value not in the range [0-100]"); + } if (ent->NbPropertyValues() != 1) + { ach->AddFail("No. of Property values : Value != 1"); + } } void IGESGraph_ToolIntercharacterSpacing::OwnDump( @@ -119,5 +126,5 @@ void IGESGraph_ToolIntercharacterSpacing::OwnDump( S << "IGESGraph_IntercharacterSpacing\n" << "No. of property values : " << ent->NbPropertyValues() << "\n" << "Intercharacter space in % of text height : " << ent->ISpace() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefPattern.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefPattern.cxx index a937c17be0..707381e0c5 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefPattern.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefPattern.cxx @@ -49,9 +49,13 @@ void IGESGraph_ToolLineFontDefPattern::ReadOwnParams( { // szv#4:S4163:12Mar99 `st=` not needed // Initialise HArray1 only if there is no error reading its Length if (tempNbSeg <= 0) + { PR.AddFail("Number of Visible-Blank Segments : Not Positive"); + } else + { tempSegmentLengths = new NCollection_HArray1(1, tempNbSeg); + } } // Read the HArray1 only if its Length was read without any Error @@ -61,10 +65,10 @@ void IGESGraph_ToolLineFontDefPattern::ReadOwnParams( for (I = 1; I <= tempNbSeg; I++) { double tempReal; - if (PR.ReadReal(PR.Current(), - "Length of Segment", - tempReal)) // szv#4:S4163:12Mar99 `st=` not needed + if (PR.ReadReal(PR.Current(), "Length of Segment", tempReal)) + { // szv#4:S4163:12Mar99 `st=` not needed tempSegmentLengths->SetValue(I, tempReal); + } } } @@ -84,7 +88,9 @@ void IGESGraph_ToolLineFontDefPattern::WriteOwnParams( IW.Send(up); int I; for (I = 1; I <= up; I++) + { IW.Send(ent->Length(I)); + } IW.Send(ent->DisplayPattern()); } @@ -104,7 +110,9 @@ void IGESGraph_ToolLineFontDefPattern::OwnCopy( int I; int up = another->NbSegments(); for (I = 1; I <= up; I++) + { tempSegmentLengths->SetValue(I, another->Length(I)); + } occ::handle tempDisplayPattern = new TCollection_HAsciiString(another->DisplayPattern()); @@ -133,9 +141,13 @@ void IGESGraph_ToolLineFontDefPattern::OwnCheck( occ::handle& ach) const { if (ent->RankLineFont() == 0) + { ach->AddWarning("Line Font Rank is zero"); + } else if (ent->RankLineFont() < 1 || ent->RankLineFont() > 5) + { ach->AddWarning("Invalid Value As Line Font Rank(Valid Range 1 to 5)"); + } } void IGESGraph_ToolLineFontDefPattern::OwnDump(const occ::handle& ent, @@ -156,8 +168,10 @@ void IGESGraph_ToolLineFontDefPattern::OwnDump(const occ::handleIsVisible(I)) + { S << " " << I; + } } - S << std::endl; + S << '\n'; } } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefTemplate.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefTemplate.cxx index 4a3fd0728a..7d0061a2aa 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefTemplate.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontDefTemplate.cxx @@ -115,9 +115,13 @@ void IGESGraph_ToolLineFontDefTemplate::OwnCheck( occ::handle& ach) const { if (ent->RankLineFont() == 0) + { ach->AddWarning("Line Font Rank is zero"); + } else if ((ent->RankLineFont() < 1) || (ent->RankLineFont() > 5)) + { ach->AddWarning("Invalid Value As Line Font Rank"); + } } void IGESGraph_ToolLineFontDefTemplate::OwnDump( @@ -135,5 +139,5 @@ void IGESGraph_ToolLineFontDefTemplate::OwnDump( S << "\n" << "Length Between Successive Template Figure : " << ent->Distance() << "\n" << "Scale Factor for Subfigure : " << ent->Scale() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontPredefined.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontPredefined.cxx index 652d6aec59..77aede15b2 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontPredefined.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolLineFontPredefined.cxx @@ -43,8 +43,9 @@ void IGESGraph_ToolLineFontPredefined::ReadOwnParams( // Reading nbPropertyValues(Integer) // clang-format off PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); //szv#4:S4163:12Mar99 `st=` not needed - if (nbPropertyValues != 1) + if (nbPropertyValues != 1) { PR.AddFail("No. of Property values : Value is not 1"); +} // Reading lineFontPatternCode(Integer) PR.ReadInteger(PR.Current(), "Line Font Pattern Code", lineFontPatternCode); //szv#4:S4163:12Mar99 `st=` not needed @@ -81,7 +82,9 @@ bool IGESGraph_ToolLineFontPredefined::OwnCorrect( { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->LineFontPatternCode()); // nbpropertyvalues=1 + } return res; } @@ -105,7 +108,9 @@ void IGESGraph_ToolLineFontPredefined::OwnCheck( occ::handle& ach) const { if (ent->NbPropertyValues() != 1) + { ach->AddFail("No. of Property values : Value != 1"); + } } void IGESGraph_ToolLineFontPredefined::OwnDump(const occ::handle& ent, @@ -116,5 +121,5 @@ void IGESGraph_ToolLineFontPredefined::OwnDump(const occ::handleNbPropertyValues() << "\n" << "Line font pattern code : " << ent->LineFontPatternCode() << "\n" - << std::endl; + << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolNominalSize.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolNominalSize.cxx index 6e4af04016..9db81ffd71 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolNominalSize.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolNominalSize.cxx @@ -47,8 +47,9 @@ void IGESGraph_ToolNominalSize::ReadOwnParams(const occ::handleNominalSizeName()); if (ent->HasStandardName()) + { IW.Send(ent->StandardName()); // optional + } } void IGESGraph_ToolNominalSize::OwnShared(const occ::handle& /*ent*/, @@ -100,7 +105,9 @@ void IGESGraph_ToolNominalSize::OwnCopy(const occ::handle nominalSizeValue = another->NominalSizeValue(); nominalSizeName = new TCollection_HAsciiString(another->NominalSizeName()); if (another->HasStandardName()) + { standardName = new TCollection_HAsciiString(another->StandardName()); + } ent->Init(nbPropertyValues, nominalSizeValue, nominalSizeName, standardName); } @@ -109,10 +116,14 @@ bool IGESGraph_ToolNominalSize::OwnCorrect(const occ::handleHasStandardName()) + { nbp = 3; + } bool res = (ent->NbPropertyValues() != nbp); if (res) + { ent->Init(nbp, ent->NominalSizeValue(), ent->NominalSizeName(), ent->StandardName()); + } return res; // nbpropertyvalues=2/3 selon standard } @@ -136,9 +147,13 @@ void IGESGraph_ToolNominalSize::OwnCheck(const occ::handleHasStandardName()) + { nbp = 3; + } if (ent->NbPropertyValues() != nbp) + { ach->AddFail("No. of Property values : Value != 2/3 according Standard Name Status"); + } } void IGESGraph_ToolNominalSize::OwnDump(const occ::handle& ent, @@ -154,5 +169,5 @@ void IGESGraph_ToolNominalSize::OwnDump(const occ::handle S << "\n" << "Name of relevant engineering standard : "; IGESData_DumpString(S, ent->StandardName()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolPick.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolPick.cxx index 32f97815bc..8d877bfcbe 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolPick.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolPick.cxx @@ -40,13 +40,19 @@ void IGESGraph_ToolPick::ReadOwnParams(const occ::handle& ent, // Reading nbPropertyValues(Integer) PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); if (nbPropertyValues != 1) + { PR.AddFail("No. of Property values : Value is not 1"); + } if (PR.DefinedElseSkip()) + { // Reading pickStatus(Integer) PR.ReadInteger(PR.Current(), "Pick Flag", pickStatus); + } else + { pickStatus = 0; // Default Value + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(nbPropertyValues, pickStatus); @@ -75,7 +81,9 @@ bool IGESGraph_ToolPick::OwnCorrect(const occ::handle& ent) cons { bool res = (ent->NbPropertyValues() != 1); if (res) + { ent->Init(1, ent->PickFlag()); // nbpropertyvalues=1 + } return res; } @@ -97,9 +105,13 @@ void IGESGraph_ToolPick::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->NbPropertyValues() != 1) + { ach->AddFail("No. of Property values : Value != 1"); + } if ((ent->PickFlag() != 0) && (ent->PickFlag() != 1)) + { ach->AddFail("Pick Flag : Value != 0/1"); + } } void IGESGraph_ToolPick::OwnDump(const occ::handle& ent, @@ -109,5 +121,5 @@ void IGESGraph_ToolPick::OwnDump(const occ::handle& ent, { S << "IGESGraph_Pick\n" << "No. of property values : " << ent->NbPropertyValues() << "\n" - << "Pick flag : " << ent->PickFlag() << (ent->PickFlag() == 0 ? " NO" : " YES") << std::endl; + << "Pick flag : " << ent->PickFlag() << (ent->PickFlag() == 0 ? " NO" : " YES") << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextDisplayTemplate.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextDisplayTemplate.cxx index 63b64e81ff..1e1fa3c77d 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextDisplayTemplate.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextDisplayTemplate.cxx @@ -72,17 +72,25 @@ void IGESGraph_ToolTextDisplayTemplate::ReadOwnParams( { fontEnt = GetCasted(IGESGraph_TextFontDef, PR.ParamEntity(IR, curnum)); if (fontEnt.IsNull()) + { PR.AddFail("Font Entity : incorrect reference"); + } } } else + { fontCode = 1; // Default Value + } if (PR.DefinedElseSkip()) + { // Reading slantAngle(Real) PR.ReadReal(PR.Current(), "Slant Angle", slantAngle); // szv#4:S4163:12Mar99 `st=` not needed + } else + { slantAngle = M_PI / 2.0; // Default Value + } // Reading rotationAngle(Real) // clang-format off @@ -120,9 +128,13 @@ void IGESGraph_ToolTextDisplayTemplate::WriteOwnParams( IW.Send(ent->BoxHeight()); if (ent->IsFontEntity()) + { IW.Send(ent->FontEntity(), true); // negative + } else + { IW.Send(ent->FontCode()); + } IW.Send(ent->SlantAngle()); IW.Send(ent->RotationAngle()); @@ -138,7 +150,9 @@ void IGESGraph_ToolTextDisplayTemplate::OwnShared( Interface_EntityIterator& iter) const { if (ent->IsFontEntity()) + { iter.GetOneItem(ent->FontEntity()); + } } void IGESGraph_ToolTextDisplayTemplate::OwnCopy( @@ -160,9 +174,13 @@ void IGESGraph_ToolTextDisplayTemplate::OwnCopy( boxHeight = another->BoxHeight(); if (another->IsFontEntity()) + { fontEntity = occ::down_cast(TC.Transferred(another->FontEntity())); + } else + { fontCode = another->FontCode(); + } slantAngle = another->SlantAngle(); rotationAngle = another->RotationAngle(); @@ -219,7 +237,9 @@ void IGESGraph_ToolTextDisplayTemplate::OwnDump( dumper.Dump(ent->FontEntity(), S, sublevel); } else + { S << "Font code : " << ent->FontCode(); + } S << "\n" << "Slant angle : " << ent->SlantAngle() << " " @@ -227,9 +247,13 @@ void IGESGraph_ToolTextDisplayTemplate::OwnDump( << "Mirror flag : " << ent->MirrorFlag() << " " << "Rotate flag : " << ent->RotateFlag() << "\n"; if (ent->FormNumber() == 0) + { S << "Lower Left Corner coordinates : "; + } else + { S << "Increments from coordinates : "; + } IGESData_DumpXYZL(S, level, ent->StartingCorner(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextFontDef.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextFontDef.cxx index b9f779003d..5b8125a2da 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextFontDef.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolTextFontDef.cxx @@ -80,9 +80,10 @@ void IGESGraph_ToolTextFontDef::ReadOwnParams(const occ::handleSetValue(i, tempCode); + } // Reading nextChars(HArray1OfInteger*2) - if (PR.ReadInteger(PR.Current(), - "array nextChar X", - tempNextX)) // szv#4:S4163:12Mar99 `st=` not needed + if (PR.ReadInteger(PR.Current(), "array nextChar X", tempNextX)) + { // szv#4:S4163:12Mar99 `st=` not needed nextCharX->SetValue(i, tempNextX); - if (PR.ReadInteger(PR.Current(), - "array nextChar Y", - tempNextY)) // szv#4:S4163:12Mar99 `st=` not needed + } + if (PR.ReadInteger(PR.Current(), "array nextChar Y", tempNextY)) + { // szv#4:S4163:12Mar99 `st=` not needed nextCharY->SetValue(i, tempNextY); + } // Reading penMotions(HArray1OfInteger) if (PR.ReadInteger(PR.Current(), "array penMotions", tempMotion)) @@ -135,35 +136,41 @@ void IGESGraph_ToolTextFontDef::ReadOwnParams(const occ::handleSetValue(j, tempFlag); + } } else + { intarray->SetValue(j, 0); // Default Value + } // Reading movePenTo(HArray1OfHArray1OfInteger*2) - if (PR.ReadInteger(PR.Current(), - "array movePenTo X", - tempMoveX)) // szv#4:S4163:12Mar99 `st=` not needed + if (PR.ReadInteger(PR.Current(), "array movePenTo X", tempMoveX)) + { // szv#4:S4163:12Mar99 `st=` not needed xarray->SetValue(j, tempMoveX); - if (PR.ReadInteger(PR.Current(), - "array movePenTo Y", - tempMoveY)) // szv#4:S4163:12Mar99 `st=` not needed + } + if (PR.ReadInteger(PR.Current(), "array movePenTo Y", tempMoveY)) + { // szv#4:S4163:12Mar99 `st=` not needed yarray->SetValue(j, tempMoveY); + } } penFlags->SetValue(i, intarray); movePenX->SetValue(i, xarray); movePenY->SetValue(i, yarray); } else + { PR.AddFail("Count of Pen motions : Not Positive"); + } } } } else + { PR.AddFail("Count of characters in this defn : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(fontCode, @@ -188,9 +195,13 @@ void IGESGraph_ToolTextFontDef::WriteOwnParams(const occ::handleFontName()); if (ent->IsSupersededFontEntity()) + { IW.Send(ent->SupersededFontEntity(), true); // negative + } else + { IW.Send(ent->SupersededFontCode()); + } IW.Send(ent->Scale()); @@ -217,7 +228,9 @@ void IGESGraph_ToolTextFontDef::OwnShared(const occ::handleIsSupersededFontEntity()) + { iter.GetOneItem(ent->SupersededFontEntity()); + } } void IGESGraph_ToolTextFontDef::OwnCopy(const occ::handle& another, @@ -250,10 +263,14 @@ void IGESGraph_ToolTextFontDef::OwnCopy(const occ::handle fontName = new TCollection_HAsciiString(another->FontName()); if (another->IsSupersededFontEntity()) + { supersededEntity = occ::down_cast(TC.Transferred(another->SupersededFontEntity())); + } else + { supersededFont = another->SupersededFontCode(); + } scale = another->Scale(); @@ -276,9 +293,13 @@ void IGESGraph_ToolTextFontDef::OwnCopy(const occ::handle for (j = 1; j <= tempMotion; j++) { if (another->IsPenUp(i, j)) + { intarray->SetValue(j, 1); + } else + { intarray->SetValue(j, 0); + } another->NextPenPosition(i, j, IX, IY); xarray->SetValue(j, IX); @@ -343,7 +364,9 @@ void IGESGraph_ToolTextFontDef::OwnDump(const occ::handle dumper.Dump(ent->SupersededFontEntity(), S, sublevel); } else + { S << "Superseding Font Number : " << ent->SupersededFontCode(); + } S << "\n" << "No. of Grid Units eqvt to 1 Text Height : " << ent->Scale() << "\n" << "ASCII Codes :\n" @@ -369,7 +392,9 @@ void IGESGraph_ToolTextFontDef::OwnDump(const occ::handle nbmotions = ent->NbPenMotions(I); S << " No. of Pen Motions : " << nbmotions; if (level <= 5) + { S << " [ ask level > 5 for Details ]\n"; + } else { S << "\n"; @@ -382,5 +407,5 @@ void IGESGraph_ToolTextFontDef::OwnDump(const occ::handle } } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolUniformRectGrid.cxx b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolUniformRectGrid.cxx index d40bc585ba..3286f8f026 100644 --- a/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolUniformRectGrid.cxx +++ b/src/DataExchange/TKDEIGES/IGESGraph/IGESGraph_ToolUniformRectGrid.cxx @@ -52,7 +52,9 @@ void IGESGraph_ToolUniformRectGrid::ReadOwnParams( // Reading nbPropertyValues(Integer) PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); if (nbPropertyValues != 9) + { PR.AddFail("No. of Property values : Value is not 9"); + } // Reading finite(Integer) PR.ReadInteger(PR.Current(), "Finite/infinite grid flag", finite); @@ -71,11 +73,15 @@ void IGESGraph_ToolUniformRectGrid::ReadOwnParams( // Reading nbPointsX(Integer) ?? even if not IsFinite ? if (finite != 0 || PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "No. of points/lines in X direction", nbPointsX); + } // Reading nbPointsY(Integer) if (finite != 0 || PR.DefinedElseSkip()) + { PR.ReadInteger(PR.Current(), "No. of points/lines in Y direction", nbPointsY); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(nbPropertyValues, finite, line, weighted, gridPoint, gridSpacing, nbPointsX, nbPointsY); @@ -121,6 +127,7 @@ bool IGESGraph_ToolUniformRectGrid::OwnCorrect( { bool res = (ent->NbPropertyValues() != 9); if (res) + { ent->Init(9, (ent->IsFinite() ? 1 : 0), (ent->IsLine() ? 1 : 0), @@ -129,6 +136,7 @@ bool IGESGraph_ToolUniformRectGrid::OwnCorrect( ent->GridSpacing().XY(), ent->NbPointsX(), ent->NbPointsY()); // nbpropertyvalues=9 + } return res; } @@ -151,13 +159,21 @@ void IGESGraph_ToolUniformRectGrid::OwnCheck(const occ::handle& ach) const { if (ent->IsFinite() != 0 && ent->IsFinite() != 1) + { ach->AddFail("Finite/infinite grid flag : Value != 0/1"); + } if (ent->IsLine() != 0 && ent->IsLine() != 1) + { ach->AddFail("Line/point grid flag : Value != 0/1"); + } if (ent->IsWeighted() != 0 && ent->IsWeighted() != 1) + { ach->AddFail("Weighted/unweighted grid flag : Value != 0/1"); + } if (ent->NbPropertyValues() != 9) + { ach->AddFail("No. of Property values : Value != 9"); + } } void IGESGraph_ToolUniformRectGrid::OwnDump(const occ::handle& ent, @@ -176,6 +192,8 @@ void IGESGraph_ToolUniformRectGrid::OwnDump(const occ::handleGridSpacing()); S << "\n"; if (ent->IsFinite()) + { S << "No. of points/lines in direction : X : " << ent->NbPointsX() - << " - Y : " << ent->NbPointsY() << std::endl; + << " - Y : " << ent->NbPointsY() << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect.cxx index 9f5c7f0160..c3d854074a 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect.cxx @@ -43,11 +43,15 @@ int IGESSelect::WhatIges(const occ::handle& ent, { const occ::handle& igesent = ent; if (igesent.IsNull()) + { return false; + } // int igt = igesent->TypeNumber(); DeclareAndCast(IGESData_IGESModel, model, G.Model()); if (igesent.IsNull() || model.IsNull()) + { return 0; + } // Plane : from View? from SingleParent? otherwise see TrimmedSurface & co diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Activator.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Activator.cxx index 27e75fb270..13a6cbcdb8 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Activator.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Activator.cxx @@ -121,14 +121,16 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int case 7: { // **** ListS(ingle)Views int listmode = 0; if (argc == 2 && arg1[0] == '?') + { argc = -1; + } if (argc < 2) { std::cout << "Add an argument to have :\n" << " l : summary list" << " c : complete list per item (but not for remaining)\n" << " r : same + complete remaining list\n" - << " on entire model. Add selection name to list on a part" << std::endl; + << " on entire model. Add selection name to list on a part" << '\n'; return (argc >= 0 ? IFSelect_RetError : IFSelect_RetVoid); } if (arg1[0] == 'l') @@ -139,49 +141,61 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int else if (arg1[0] == 'c') { listmode = 1; - std::cout << "Complete list per item (not for Remaining)" << std::endl; + std::cout << "Complete list per item (not for Remaining)" << '\n'; } else if (arg1[0] == 'r') { listmode = 2; - std::cout << "Complete list per item and for Remaining" << std::endl; + std::cout << "Complete list per item and for Remaining" << '\n'; } else { - std::cout << "Parametre de listage non compris" << std::endl; + std::cout << "Parametre de listage non compris" << '\n'; return IFSelect_RetError; } occ::handle vs = new IGESSelect_ViewSorter; vs->SetModel(GetCasted(IGESData_IGESModel, WS->Model())); if (argc == 2) + { vs->AddModel(WS->Model()); + } else { // on demande une selection DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg2)); if (sel.IsNull()) { - std::cout << "Pas une selection : " << arg2 << std::endl; + std::cout << "Pas une selection : " << arg2 << '\n'; return IFSelect_RetError; } vs->AddList(WS->SelectionResult(sel)); } bool listdr = (number > 5); if (number == 6) + { vs->SortDrawings(WS->Graph()); + } if (number == 7) + { vs->SortSingleViews(true); + } occ::handle sets = vs->Sets(listdr); int nb = vs->NbSets(listdr); std::cout << " -- ViewSorter for"; if (number == 5) + { std::cout << " Views & Drawings"; + } if (number == 6) + { std::cout << " Drawings only (complete)"; + } if (number == 7) + { std::cout << " Single Views & Drawing Frames"; - std::cout << ", on " << vs->NbEntities() << " ent.s, give " << nb << " Sets" << std::endl; + } + std::cout << ", on " << vs->NbEntities() << " ent.s, give " << nb << " Sets" << '\n'; Interface_EntityIterator iter; for (int i = 1; i <= nb; i++) @@ -189,17 +203,21 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int std::cout << " -- Set n0 " << i << " Item=entity n0: " << WS->Model()->Number(vs->SetItem(i, listdr)) << " List:"; - std::cout << sets->NbEntities(i) << " ent.s:" << std::endl; + std::cout << sets->NbEntities(i) << " ent.s:" << '\n'; if (listmode == 0) + { continue; + } iter = sets->Entities(i); WS->ListEntities(iter, 0, std::cout); } std::cout << " -- Remaining Entities (not yet sorted) :" << sets->NbDuplicated(0, false) - << std::endl; + << '\n'; if (listmode < 2) + { return IFSelect_RetVoid; + } iter = sets->Duplicated(0, false); WS->ListEntities(iter, 0, std::cout); return IFSelect_RetVoid; @@ -209,14 +227,18 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int if (argc < 2) { std::cout << "Give the desired type number, + optionally the form\n" - << " If no form, takes all forms of the requested type" << std::endl; + << " If no form, takes all forms of the requested type" << '\n'; return IFSelect_RetError; } char signature[20]; if (argc == 2) + { Sprintf(signature, "%s", arg1); + } else + { Sprintf(signature, "%s %s", arg1, arg2); + } occ::handle sel = new IFSelect_SelectSignature(new IGESSelect_IGESTypeForm, signature, (argc > 2)); return pilot->RecordItem(sel); @@ -229,7 +251,7 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int case 12: { // **** IGES Name if (argc < 2) { - std::cout << "Give a TextParam Name for IGESName" << std::endl; + std::cout << "Give a TextParam Name for IGESName" << '\n'; return IFSelect_RetError; } occ::handle sel = new IGESSelect_SelectName; @@ -244,13 +266,13 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int case 14: { // **** IGES LevelNumber if (argc < 2) { - std::cout << "Give IntParam name for Level" << std::endl; + std::cout << "Give IntParam name for Level" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_IntParam, lev, WS->NamedItem(arg1)); if (lev.IsNull()) { - std::cout << arg1 << " : not an IntParam (for Level)" << std::endl; + std::cout << arg1 << " : not an IntParam (for Level)" << '\n'; return IFSelect_RetError; } occ::handle sel = new IGESSelect_SelectLevelNumber; @@ -281,22 +303,32 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int case 40: { // **** FloatFormat char prem = ' '; if (argc < 2) + { prem = '?'; + } else if (argc == 5) { - std::cout << "floatformat alone gives the accepted forms" << std::endl; + std::cout << "floatformat alone gives the accepted forms" << '\n'; return IFSelect_RetError; } else + { prem = arg1[0]; + } bool zerosup = false; int digits = 0; if (prem == 'N' || prem == 'n') + { zerosup = false; + } else if (prem == 'Z' || prem == 'z') + { zerosup = true; + } else if (prem >= 48 && prem <= 57) + { digits = atoi(arg1); + } else { std::cout << "floatformat digits, digits=nb of significant digits, or\n" @@ -316,23 +348,31 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int Rmax = Atof(pilot->Word(5).ToCString()); if (Rmin <= 0 || Rmax <= 0) { - std::cout << "intervalle : donner reels > 0" << std::endl; + std::cout << "intervalle : donner reels > 0" << '\n'; return IFSelect_RetError; } } occ::handle fm = new IGESSelect_FloatFormat; if (argc == 2) + { fm->SetDefault(digits); + } else { fm->SetZeroSuppress(zerosup); fm->SetFormat(arg2); if (argc == 4) + { fm->SetFormatForRange(pilot->Word(3).ToCString()); + } else if (argc >= 6) + { fm->SetFormatForRange(pilot->Word(3).ToCString(), Rmin, Rmax); + } else + { fm->SetFormatForRange(""); + } } return pilot->RecordItem(fm); } @@ -340,19 +380,19 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int case 41: { // **** SetGlobalParameter if (argc < 3) { - std::cout << "Give integer=n0 param to change + TextParam name for the value" << std::endl; + std::cout << "Give integer=n0 param to change + TextParam name for the value" << '\n'; return IFSelect_RetError; } int numpar = atoi(arg1); if (numpar <= 0) { - std::cout << "Pas un n0 de param global correct:" << arg1 << std::endl; + std::cout << "Pas un n0 de param global correct:" << arg1 << '\n'; return IFSelect_RetError; } DeclareAndCast(TCollection_HAsciiString, val, WS->NamedItem(arg2)); if (val.IsNull()) { - std::cout << "Pas un nom de TextParam:" << arg2 << std::endl; + std::cout << "Pas un nom de TextParam:" << arg2 << '\n'; return IFSelect_RetError; } occ::handle mod = new IGESSelect_SetGlobalParameter(numpar); @@ -393,17 +433,21 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int if (argc < 2) { std::cout << "For SplineToBSpline, give mode :\n" - << " n for normal, t for tryC2" << std::endl; + << " n for normal, t for tryC2" << '\n'; return IFSelect_RetError; } bool tryC2; if (arg1[0] == 'n' || arg1[0] == 'N') + { tryC2 = false; + } else if (arg1[0] == 't' || arg1[0] == 'T') + { tryC2 = true; + } else { - std::cout << " Mode incorrect : " << arg1 << std::endl; + std::cout << " Mode incorrect : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle conv = new IGESSelect_SplineToBSpline(tryC2); @@ -421,10 +465,12 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int { DeclareAndCast(IGESData_IGESEntity, ent, list->Value(i)); if (!ent.IsNull()) + { ent->InitStatus(ent->BlankStatus(), ent->SubordinateStatus(), usefl, ent->HierarchyStatus()); + } } } else @@ -434,10 +480,12 @@ IFSelect_ReturnStatus IGESSelect_Activator::Do(const int { DeclareAndCast(IGESData_IGESEntity, ent, WS->StartingEntity(i)); if (!ent.IsNull()) + { ent->InitStatus(ent->BlankStatus(), ent->SubordinateStatus(), usefl, ent->HierarchyStatus()); + } } } return IFSelect_RetDone; diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_AutoCorrect.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_AutoCorrect.cxx index d84883bcec..0bb64f1b47 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_AutoCorrect.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_AutoCorrect.cxx @@ -47,7 +47,9 @@ void IGESSelect_AutoCorrect::Performing(IFSelect_ContextModif& c DeclareAndCast(IGESData_IGESEntity, ent, ctx.ValueResult()); bool done = corrector.AutoCorrect(ent); if (done) + { ctx.Trace(); + } } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelList.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelList.cxx index a12a9dbdc5..04f5e37ed2 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelList.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelList.cxx @@ -70,36 +70,56 @@ void IGESSelect_ChangeLevelList::Performing(IFSelect_ContextModif& ctx, int oldl = 0; bool yaold = HasOldNumber(); if (yaold) + { oldl = theold->Value(); + } bool yanew = HasOldNumber(); int newl = 0; if (yanew) + { newl = thenew->Value(); + } if (oldl < 0) + { ctx.CCheck()->AddFail("ChangeLevelList : OldNumber negative"); + } if (newl < 0) + { ctx.CCheck()->AddFail("ChangeLevelList : NewNumber negative"); + } if (oldl < 0 || newl < 0) + { return; + } occ::handle nulist; for (ctx.Start(); ctx.More(); ctx.Next()) { DeclareAndCast(IGESData_IGESEntity, ent, ctx.ValueResult()); if (ent.IsNull()) + { continue; + } if (ent->DefLevel() != IGESData_DefSeveral) + { continue; + } if (yaold && ent->Level() != oldl) + { continue; + } if (!yanew) { occ::handle list = ent->LevelList(); if (list.IsNull()) + { continue; + } newl = (list->NbLevelNumbers() > 0 ? list->LevelNumber(1) : 0); if (newl < 0) + { newl = 0; + } } ent->InitLevel(nulist, newl); ctx.Trace(); @@ -112,21 +132,33 @@ TCollection_AsciiString IGESSelect_ChangeLevelList::Label() const int oldl = 0; bool yaold = HasOldNumber(); if (yaold) + { oldl = theold->Value(); + } bool yanew = HasOldNumber(); int newl = 0; if (yanew) + { newl = thenew->Value(); + } if (yaold) + { Sprintf(labl, "Changes Level Lists containing %d", oldl); + } else + { Sprintf(labl, "Changes all Level Lists in D.E. %d", oldl); + } TCollection_AsciiString label(labl); if (yanew) + { Sprintf(labl, " to Number %d", newl); + } else + { Sprintf(labl, " to Number = first value in List"); + } label.AssignCat(labl); return label; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelNumber.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelNumber.cxx index b5cfa82204..741366b429 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ChangeLevelNumber.cxx @@ -65,27 +65,43 @@ void IGESSelect_ChangeLevelNumber::Performing(IFSelect_ContextModif& ctx, int oldl = 0; bool yaold = HasOldNumber(); if (yaold) + { oldl = theold->Value(); + } int newl = 0; if (!thenew.IsNull()) + { newl = thenew->Value(); + } if (oldl < 0) + { ctx.CCheck()->AddFail("ChangeLevelNumber : OldNumber negative"); + } if (newl < 0) + { ctx.CCheck()->AddFail("ChangeLevelNumber : NewNumber negative"); + } if (oldl < 0 || newl < 0) + { return; + } occ::handle nulist; for (ctx.Start(); ctx.More(); ctx.Next()) { DeclareAndCast(IGESData_IGESEntity, ent, ctx.ValueResult()); if (ent.IsNull()) + { continue; + } if (ent->DefLevel() == IGESData_DefSeveral) + { continue; + } if (yaold && ent->Level() != oldl) + { continue; + } ent->InitLevel(nulist, newl); ctx.Trace(); } @@ -97,14 +113,22 @@ TCollection_AsciiString IGESSelect_ChangeLevelNumber::Label() const int oldl = 0; bool yaold = HasOldNumber(); if (yaold) + { oldl = theold->Value(); + } int newl = 0; if (!thenew.IsNull()) + { newl = thenew->Value(); + } if (yaold) + { Sprintf(labl, "Changes Level Number %d to %d", oldl, newl); + } else + { Sprintf(labl, "Changes all Level Numbers positive and zero to %d", newl); + } return TCollection_AsciiString(labl); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_CounterOfLevelNumber.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_CounterOfLevelNumber.cxx index f65d3e4e17..6902a41b4a 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_CounterOfLevelNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_CounterOfLevelNumber.cxx @@ -42,15 +42,21 @@ void IGESSelect_CounterOfLevelNumber::AddSign( { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return; + } DeclareAndCast(IGESGraph_DefinitionLevel, levelist, igesent->LevelList()); int level = igesent->Level(); if (levelist.IsNull() && level < 0) + { return; + } // Enregistrer ce/ces niveau(x) if (levelist.IsNull()) + { AddLevel(ent, level); + } else { int nb = levelist->NbPropertyValues(); @@ -83,12 +89,16 @@ void IGESSelect_CounterOfLevelNumber::AddLevel(const occ::handle> levels = new NCollection_HArray1(0, level + 100); levels->Init(0); for (int i = 1; i <= upper; i++) + { levels->SetValue(i, thelevels->Value(i)); + } thelevels = levels; } thelevels->SetValue(level, thelevels->Value(level) + 1); if (level > thehigh) + { thehigh = level; + } // if (level == 0) Add(ent," NO LEVEL"); // else { @@ -106,9 +116,13 @@ int IGESSelect_CounterOfLevelNumber::HighestLevel() const int IGESSelect_CounterOfLevelNumber::NbTimesLevel(const int level) const { if (level < 0) + { return thenblists; + } if (level > thehigh) + { return 0; + } return thelevels->Value(level); } @@ -118,7 +132,9 @@ occ::handle> IGESSelect_CounterOfLevelNumber::Levels( for (int i = 1; i <= thehigh; i++) { if (thelevels->Value(i) > 0) + { list->Append(i); + } } return list; } @@ -131,15 +147,21 @@ occ::handle IGESSelect_CounterOfLevelNumber::Sign( // reprend les termes de AddSign pour la preparation (lecture du level) ... DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return res; + } DeclareAndCast(IGESGraph_DefinitionLevel, levelist, igesent->LevelList()); int level = igesent->Level(); if (levelist.IsNull() && level < 0) + { return res; + } // puis ceux de AddLevel pour calculer la signature if (level < 0) + { return new TCollection_HAsciiString("LEVEL LIST"); + } char signature[30]; Sprintf(signature, "%7d", level); return new TCollection_HAsciiString(signature); @@ -148,8 +170,10 @@ occ::handle IGESSelect_CounterOfLevelNumber::Sign( void IGESSelect_CounterOfLevelNumber::PrintCount(Standard_OStream& S) const { IFSelect_SignatureList::PrintCount(S); - S << " Highest value : " << thehigh << std::endl; + S << " Highest value : " << thehigh << '\n'; if (thenblists > 0) + { S << "REMARK for LEVEL LIST : Entities are counted in" - << " \n, and in each Level value of their list" << std::endl; + << " \n, and in each Level value of their list" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerDrawing.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerDrawing.cxx index a2b5177532..74aeaf0a32 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerDrawing.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerDrawing.cxx @@ -39,7 +39,9 @@ void IGESSelect_DispPerDrawing::Packets(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const { if (FinalSelection().IsNull()) + { return; + } Interface_EntityIterator list = FinalSelection()->UniqueResult(G); thesorter->SetModel(GetCasted(IGESData_IGESModel, G.Model())); thesorter->Clear(); @@ -67,7 +69,9 @@ Interface_EntityIterator IGESSelect_DispPerDrawing::Remainder(const Interface_Gr { Interface_EntityIterator list; if (FinalSelection().IsNull()) + { return list; + } list = FinalSelection()->UniqueResult(G); thesorter->Clear(); thesorter->AddList(list.Content()); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerSingleView.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerSingleView.cxx index c286287759..93d9507e69 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerSingleView.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_DispPerSingleView.cxx @@ -39,7 +39,9 @@ void IGESSelect_DispPerSingleView::Packets(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const { if (FinalSelection().IsNull()) + { return; + } Interface_EntityIterator list = FinalSelection()->UniqueResult(G); thesorter->SetModel(GetCasted(IGESData_IGESModel, G.Model())); thesorter->Clear(); @@ -67,7 +69,9 @@ Interface_EntityIterator IGESSelect_DispPerSingleView::Remainder(const Interface { Interface_EntityIterator list; if (FinalSelection().IsNull()) + { return list; + } list = FinalSelection()->UniqueResult(G); thesorter->Clear(); thesorter->Add(list.Content()); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Dumper.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Dumper.cxx index ded0d00d6a..18172bb519 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Dumper.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_Dumper.cxx @@ -52,12 +52,18 @@ bool IGESSelect_Dumper::WriteOwn(IFSelect_SessionFile& file, const occ::handle& item) const { if (item.IsNull()) + { return false; + } occ::handle type = item->DynamicType(); if (type == STANDARD_TYPE(IGESSelect_DispPerSingleView)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_DispPerDrawing)) + { return true; + } /* if (type == STANDARD_TYPE(IGESSelect_SelectIGESTypeForm)) { DeclareAndCast(IGESSelect_SelectIGESTypeForm,sf,item); bool exact = sf->IsExact(); @@ -68,7 +74,9 @@ bool IGESSelect_Dumper::WriteOwn(IFSelect_SessionFile& file, return true; } */ if (type == STANDARD_TYPE(IGESSelect_SelectVisibleStatus)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SelectLevelNumber)) { DeclareAndCast(IGESSelect_SelectLevelNumber, sl, item); @@ -84,15 +92,25 @@ bool IGESSelect_Dumper::WriteOwn(IFSelect_SessionFile& file, return true; } if (type == STANDARD_TYPE(IGESSelect_SelectFromSingleView)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SelectFromDrawing)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SelectSingleViewFrom)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SelectDrawingFrom)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SelectBypassGroup)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_FloatFormat)) { @@ -116,11 +134,17 @@ bool IGESSelect_Dumper::WriteOwn(IFSelect_SessionFile& file, } if (type == STANDARD_TYPE(IGESSelect_UpdateCreationDate)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_UpdateLastChange)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SetVersion5)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_SetGlobalParameter)) { DeclareAndCast(IGESSelect_SetGlobalParameter, sp, item); @@ -133,13 +157,21 @@ bool IGESSelect_Dumper::WriteOwn(IFSelect_SessionFile& file, return true; } if (type == STANDARD_TYPE(IGESSelect_AutoCorrect)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_ComputeStatus)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_RebuildDrawings)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_RebuildGroups)) + { return true; + } if (type == STANDARD_TYPE(IGESSelect_ChangeLevelList)) { DeclareAndCast(IGESSelect_ChangeLevelList, cl, item); @@ -182,11 +214,15 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_SelectIGESTypeForm")) { if (file.NbParams() < 2) + { return false; + } // bool exact; //szv#4:S4163:12Mar99 not needed const TCollection_AsciiString& exname = file.ParamValue(1); if (exname.Length() < 1) + { return false; + } if (exname.Value(1) == 'e') { } // szv#4:S4163:12Mar99 `exact = true` not needed @@ -194,13 +230,19 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, { } // szv#4:S4163:12Mar99 `exact = false` not needed else + { return false; + } // Attention, 2 termes possibles pour la signature char sig[40]; if (file.NbParams() == 2) + { Sprintf(sig, "%s", file.ParamValue(2).ToCString()); + } else + { Sprintf(sig, "%s %s", file.ParamValue(2).ToCString(), file.ParamValue(3).ToCString()); + } // item = new IGESSelect_SelectIGESTypeForm(sig,exact); // return true; } @@ -213,7 +255,9 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_SelectLevelNumber")) { if (file.NbParams() < 1) + { return false; + } occ::handle sl = new IGESSelect_SelectLevelNumber; DeclareAndCast(IFSelect_IntParam, lev, file.ItemValue(1)); sl->SetLevelNumber(lev); @@ -223,7 +267,9 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_SelectName")) { if (file.NbParams() < 1) + { return false; + } occ::handle sn = new IGESSelect_SelectName; occ::handle name = sn->Name(); item = sn; @@ -258,18 +304,28 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_FloatFormat")) { if (file.NbParams() < 2) + { return false; + } occ::handle ff = new IGESSelect_FloatFormat; bool zerosup; const TCollection_AsciiString& zsup = file.ParamValue(1); if (zsup.Length() < 1) + { return false; + } if (zsup.Value(1) == 'z') + { zerosup = true; + } else if (zsup.Value(1) == 'n') + { zerosup = false; + } else + { return false; + } ff->SetFormat(file.ParamValue(2).ToCString()); ff->SetZeroSuppress(zerosup); if (file.NbParams() >= 5) @@ -302,7 +358,9 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_SetGlobalParameter")) { if (file.NbParams() < 2) + { return false; + } int np = atoi(file.ParamValue(1).ToCString()); DeclareAndCast(TCollection_HAsciiString, val, file.ItemValue(2)); occ::handle sp = new IGESSelect_SetGlobalParameter(np); @@ -335,7 +393,9 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_ChangeLevelList")) { if (file.NbParams() < 2) + { return false; + } occ::handle cl = new IGESSelect_ChangeLevelList; DeclareAndCast(IFSelect_IntParam, oldpar, file.ItemValue(1)); DeclareAndCast(IFSelect_IntParam, newpar, file.ItemValue(2)); @@ -347,7 +407,9 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_ChangeLevelNumber")) { if (file.NbParams() < 2) + { return false; + } occ::handle cl = new IGESSelect_ChangeLevelNumber; DeclareAndCast(IFSelect_IntParam, oldpar, file.ItemValue(1)); DeclareAndCast(IFSelect_IntParam, newpar, file.ItemValue(2)); @@ -360,17 +422,27 @@ bool IGESSelect_Dumper::ReadOwn(IFSelect_SessionFile& file, if (type.IsEqual("IGESSelect_SplineToBSpline")) { if (file.NbParams() < 1) + { return false; + } bool tryc2; const TCollection_AsciiString& tc2 = file.ParamValue(1); if (tc2.Length() < 1) + { return false; + } if (tc2.Value(1) == 'T') + { tryc2 = true; + } else if (tc2.Value(1) == 'N') + { tryc2 = false; + } else + { return false; + } item = new IGESSelect_SplineToBSpline(tryc2); return true; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditDirPart.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditDirPart.cxx index b3b82983ed..899262a304 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditDirPart.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditDirPart.cxx @@ -201,34 +201,50 @@ bool IGESSelect_EditDirPart::Load(const occ::handle& f { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } occ::handle iges = occ::down_cast(ent); if (iges.IsNull()) + { return false; + } form->LoadValue(1, new TCollection_HAsciiString(iges->TypeNumber())); form->LoadValue(2, new TCollection_HAsciiString(iges->FormNumber())); if (iges->HasStructure()) + { form->LoadValue(3, modl->StringLabel(iges->Structure())); + } form->LoadValue(4, DefTypeName(iges->DefLineFont())); form->LoadValue(5, new TCollection_HAsciiString(iges->RankLineFont())); if (iges->DefLineFont() == IGESData_DefReference) + { form->LoadValue(6, modl->StringLabel(iges->LineFont())); + } form->LoadValue(7, DefListName(iges->DefLevel())); form->LoadValue(8, new TCollection_HAsciiString(iges->Level())); if (iges->DefLevel() == IGESData_DefSeveral) + { form->LoadValue(9, modl->StringLabel(iges->LevelList())); + } form->LoadValue(10, DefListName(iges->DefView())); if (iges->DefView() != IGESData_DefNone) + { form->LoadValue(11, modl->StringLabel(iges->View())); + } if (iges->HasTransf()) + { form->LoadValue(12, modl->StringLabel(iges->Transf())); + } if (iges->HasLabelDisplay()) + { form->LoadValue(13, modl->StringLabel(iges->LabelDisplay())); + } form->LoadValue(14, new TCollection_HAsciiString(iges->BlankStatus())); form->LoadValue(15, new TCollection_HAsciiString(iges->SubordinateStatus())); @@ -240,11 +256,15 @@ bool IGESSelect_EditDirPart::Load(const occ::handle& f form->LoadValue(19, DefTypeName(iges->DefColor())); form->LoadValue(20, new TCollection_HAsciiString(iges->RankColor())); if (iges->DefColor() == IGESData_DefReference) + { form->LoadValue(21, modl->StringLabel(iges->Color())); + } form->LoadValue(22, iges->ShortLabel()); if (iges->HasSubScriptNumber()) + { form->LoadValue(23, new TCollection_HAsciiString(iges->SubScriptNumber())); + } return true; } @@ -261,57 +281,85 @@ bool IGESSelect_EditDirPart::Update(const occ::handle& if (num == 5) { if (val.IsNull()) + { form->Touch(4, DefTypeName(IGESData_DefVoid)); + } else + { form->Touch(4, DefTypeName(IGESData_DefValue)); + } } if (num == 6) { if (val.IsNull()) + { form->Touch(4, DefTypeName(IGESData_DefVoid)); + } else + { form->Touch(4, DefTypeName(IGESData_DefReference)); + } } // Level if (num == 8) { if (val.IsNull()) + { form->Touch(7, DefListName(IGESData_DefNone)); + } else + { form->Touch(7, DefListName(IGESData_DefOne)); + } } if (num == 9) { if (val.IsNull()) + { form->Touch(7, DefListName(IGESData_DefNone)); + } else + { form->Touch(7, DefListName(IGESData_DefSeveral)); + } } // View if (num == 11) { if (val.IsNull()) + { form->Touch(10, DefListName(IGESData_DefNone)); + } else + { form->Touch(10, DefListName(IGESData_DefOne)); + } } // Color if (num == 20) { if (val.IsNull()) + { form->Touch(19, DefTypeName(IGESData_DefVoid)); + } else + { form->Touch(19, DefTypeName(IGESData_DefValue)); + } } if (num == 21) { if (val.IsNull()) + { form->Touch(19, DefTypeName(IGESData_DefVoid)); + } else + { form->Touch(19, DefTypeName(IGESData_DefReference)); + } } return true; @@ -323,10 +371,14 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } occ::handle iges = occ::down_cast(ent); if (iges.IsNull()) + { return false; + } occ::handle sub; occ::handle lfent; occ::handle levlist; @@ -344,13 +396,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& sub.Nullify(); num = 0; if (!str.IsNull()) + { num = modl->NextNumberForLabel(str->ToCString()); + } else + { num = -1; + } if (num > 0) + { sub = modl->Entity(num); + } if (num != 0) + { iges->InitDirFieldEntity(3, sub); + } } if (form->IsModified(5)) @@ -358,9 +418,13 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& str = form->EditedValue(5); lfent.Nullify(); if (str.IsNull()) + { num = 0; + } else + { num = str->IntegerValue(); + } iges->InitLineFont(lfent, num); } if (form->IsModified(6)) @@ -369,13 +433,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& lfent.Nullify(); num = 0; if (str.IsNull()) + { num = -1; + } else + { num = modl->NextNumberForLabel(str->ToCString()); + } if (num > 0) + { lfent = GetCasted(IGESData_LineFontEntity, modl->Entity(num)); + } if (num < 0 || !lfent.IsNull()) + { iges->InitLineFont(lfent, 0); + } } if (form->IsModified(8)) @@ -383,9 +455,13 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& str = form->EditedValue(8); levlist.Nullify(); if (str.IsNull()) + { num = 0; + } else + { num = str->IntegerValue(); + } iges->InitLevel(levlist, num); } if (form->IsModified(9)) @@ -394,13 +470,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& levlist.Nullify(); num = 0; if (str.IsNull()) + { num = -1; + } else + { num = modl->NextNumberForLabel(str->ToCString()); + } if (num > 0) + { levlist = GetCasted(IGESData_LevelListEntity, modl->Entity(num)); + } if (num < 0 || !levlist.IsNull()) + { iges->InitLevel(levlist, 0); + } } if (form->IsModified(11)) @@ -409,13 +493,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& view.Nullify(); num = 0; if (!str.IsNull()) + { num = modl->NextNumberForLabel(str->ToCString()); + } else + { num = -1; + } if (num > 0) + { view = GetCasted(IGESData_ViewKindEntity, modl->Entity(num)); + } if (num != 0 || !view.IsNull()) + { iges->InitView(view); + } } if (form->IsModified(12)) @@ -424,13 +516,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& transf.Nullify(); num = 0; if (!str.IsNull()) + { num = modl->NextNumberForLabel(str->ToCString()); + } else + { num = -1; + } if (num > 0) + { transf = GetCasted(IGESData_TransfEntity, modl->Entity(num)); + } if (num != 0 || !transf.IsNull()) + { iges->InitTransf(transf); + } } if (form->IsModified(13)) @@ -439,13 +539,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& labdisp.Nullify(); num = 0; if (!str.IsNull()) + { num = modl->NextNumberForLabel(str->ToCString()); + } else + { num = -1; + } if (num > 0) + { labdisp = GetCasted(IGESData_LabelDisplayEntity, modl->Entity(num)); + } if (num != 0 || !labdisp.IsNull()) + { iges->InitDirFieldEntity(8, labdisp); + } } if (form->IsModified(14) || form->IsModified(15) || form->IsModified(16) || form->IsModified(17)) @@ -456,13 +564,21 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& n3 = iges->UseFlag(); n4 = iges->HierarchyStatus(); if (form->IsModified(14)) + { n1 = form->EditedValue(14)->IntegerValue(); + } if (form->IsModified(15)) + { n2 = form->EditedValue(15)->IntegerValue(); + } if (form->IsModified(16)) + { n3 = form->EditedValue(16)->IntegerValue(); + } if (form->IsModified(17)) + { n4 = form->EditedValue(17)->IntegerValue(); + } iges->InitStatus(n1, n2, n3, n4); } @@ -471,7 +587,9 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& str = form->EditedValue(18); num = 0; if (!str.IsNull()) + { num = str->IntegerValue(); + } iges->InitMisc(iges->Structure(), iges->LabelDisplay(), num); } @@ -480,9 +598,13 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& str = form->EditedValue(20); color.Nullify(); if (str.IsNull()) + { num = 0; + } else + { num = str->IntegerValue(); + } iges->InitColor(color, num); } if (form->IsModified(21)) @@ -491,31 +613,47 @@ bool IGESSelect_EditDirPart::Apply(const occ::handle& color.Nullify(); num = 0; if (str.IsNull()) + { num = -1; + } else + { num = modl->NextNumberForLabel(str->ToCString()); + } if (num > 0) + { color = GetCasted(IGESData_ColorEntity, modl->Entity(num)); + } if (num < 0 || !color.IsNull()) + { iges->InitColor(color, 0); + } } if (form->IsModified(22) || form->IsModified(23)) { num = -1; if (iges->HasSubScriptNumber()) + { num = iges->SubScriptNumber(); + } if (form->IsModified(23)) { str = form->EditedValue(23); if (str.IsNull()) + { num = -1; + } else + { num = str->IntegerValue(); + } } str = iges->ShortLabel(); if (form->IsModified(22)) + { str = form->EditedValue(22); + } iges->SetLabel(str, num); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditHeader.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditHeader.cxx index df95d03ec7..f9626cdc52 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditHeader.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_EditHeader.cxx @@ -29,12 +29,16 @@ IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_EditHeader, IFSelect_Editor) static bool IsTimeStamp(const occ::handle& val) { if (val.IsNull()) + { return false; + } // La date peut etre sur 13 ou 15 caracteres (15 : bonjour l an 2000!) // forme [YY]YYMMDD.HHMMSS int lng = val->Length(); if (lng != 13 && lng != 15) + { return false; + } lng -= 13; // devient 0 ou 2 (offset siecle) // Cas du siecle present : @@ -42,10 +46,14 @@ static bool IsTimeStamp(const occ::handle& val) { char uncar = val->Value(1); if (uncar != '1' && uncar != '2') + { return false; + } uncar = val->Value(2); if (uncar < '0' || uncar > '9') + { return false; + } } // On y va @@ -60,58 +68,87 @@ static bool IsTimeStamp(const occ::handle& val) case 1: case 2: if (uncar < '0' || uncar > '9') + { return false; + } break; case 3: if (uncar != '0' && uncar != '1') + { return false; + } break; case 4: if (uncar < '0' || uncar > '9') + { return false; + } if (dizmois == '1' && (uncar < '0' || uncar > '2')) + { return false; + } break; case 5: if (uncar < '0' || uncar > '3') + { return false; + } break; case 6: if (uncar < '0' || uncar > '9') + { return false; + } if (dizjour == '3' && (uncar != '0' && uncar != '1')) + { return false; + } break; case 7: if (uncar != '.') + { return false; + } break; case 8: if (uncar < '0' || uncar > '2') + { return false; + } break; case 9: if (uncar < '0' || uncar > '9') + { return false; + } // clang-format off - if (dizheur == '2' && (uncar < '0' || uncar > '3')) return false; //szv#4:S4163:12Mar99 extra break + if (dizheur == '2' && (uncar < '0' || uncar > '3')) { return false; //szv#4:S4163:12Mar99 extra break +} // clang-format on break; case 10: if (uncar < '0' || uncar > '5') + { return false; + } break; case 11: if (uncar < '0' || uncar > '9') + { return false; + } break; case 12: if (uncar < '0' || uncar > '5') + { return false; + } break; case 13: if (uncar < '0' || uncar > '9') + { return false; + } break; default: break; @@ -182,7 +219,9 @@ IGESSelect_EditHeader::IGESSelect_EditHeader() new Interface_TypedValue("Units Name", Interface_ParamEnum); unitname->StartEnum(1); for (i = 1; i <= 11; i++) + { unitname->AddEnumValue(IGESData_BasicEditor::UnitFlagName(i), i); + } // similaire a Interface_Static::Static("XSTEP.iges.unit"); SetValue(16, unitname, "G15:UnitName", IFSelect_Optional); occ::handle unitval = @@ -222,7 +261,9 @@ IGESSelect_EditHeader::IGESSelect_EditHeader() new Interface_TypedValue("IGES Version Name", Interface_ParamEnum); versname->StartEnum(0); for (i = 0; i <= IGESData_BasicEditor::IGESVersionMax(); i++) + { versname->AddEnumValue(IGESData_BasicEditor::IGESVersionName(i), i); + } SetValue(26, versname, "V23:VersionName"); occ::handle draft = @@ -235,7 +276,9 @@ IGESSelect_EditHeader::IGESSelect_EditHeader() new Interface_TypedValue("Drafting Standard Name", Interface_ParamEnum); draftname->StartEnum(0); for (i = 0; i <= nb; i++) + { draftname->AddEnumValue(IGESData_BasicEditor::DraftingName(i), i); + } SetValue(28, draftname, "V24:DraftingName"); occ::handle changedate = @@ -272,7 +315,9 @@ bool IGESSelect_EditHeader::Load(const occ::handle& form, { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } IGESData_GlobalSection GS = modl->GlobalSection(); @@ -302,7 +347,9 @@ bool IGESSelect_EditHeader::Load(const occ::handle& form, form->LoadValue(20, GS.Date()); form->LoadValue(21, new TCollection_HAsciiString(GS.Resolution())); if (GS.HasMaxCoord()) + { form->LoadValue(22, new TCollection_HAsciiString(GS.MaxCoord())); + } form->LoadValue(23, GS.AuthorName()); form->LoadValue(24, GS.CompanyName()); @@ -328,23 +375,31 @@ bool IGESSelect_EditHeader::Update(const occ::handle& if (num == 15) { if (!enforce) + { return false; // quand meme ... - // Unit Flag : mettre a jour UnitName et UnitValue + } + // Unit Flag : mettre a jour UnitName et UnitValue int unitflag = val->IntegerValue(); const char* unitname = IGESData_BasicEditor::UnitFlagName(unitflag); if (unitname[0] == '\0') + { return false; + } form->Touch(16, new TCollection_HAsciiString(unitname)); form->Touch(17, new TCollection_HAsciiString(IGESData_BasicEditor::UnitFlagValue(unitflag))); } if (num == 16) { if (!enforce) + { return false; // quand meme ... - // Unit Name : mettre a jour UnitFlag et UnitValue + } + // Unit Name : mettre a jour UnitFlag et UnitValue int unitflag = IGESData_BasicEditor::UnitNameFlag(val->ToCString()); if (unitflag == 0) + { return false; // pas bon + } form->Touch(15, new TCollection_HAsciiString(unitflag)); form->Touch(17, new TCollection_HAsciiString(IGESData_BasicEditor::UnitFlagValue(unitflag))); } @@ -354,10 +409,14 @@ bool IGESSelect_EditHeader::Update(const occ::handle& // Unit Version : mettre a jour son nom int version = 3; // par defaut ... if (!val.IsNull()) + { version = atoi(val->ToCString()); + } const char* versname = IGESData_BasicEditor::IGESVersionName(version); if (versname[0] == '\0') + { return false; + } form->Touch(26, new TCollection_HAsciiString(versname)); } if (num == 27) @@ -365,10 +424,14 @@ bool IGESSelect_EditHeader::Update(const occ::handle& // Drafting : mettre a jour son nom int draft = 0; if (!val.IsNull()) + { draft = atoi(val->ToCString()); + } const char* draftname = IGESData_BasicEditor::IGESVersionName(draft); if (draftname[0] == '\0') + { return false; + } form->Touch(28, new TCollection_HAsciiString(draftname)); } return true; @@ -380,85 +443,143 @@ bool IGESSelect_EditHeader::Apply(const occ::handle& form, { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } IGESData_GlobalSection GS = modl->GlobalSection(); occ::handle str; if (form->IsModified(1)) + { modl->SetStartSection(form->EditedList(1)); + } if (form->IsModified(2)) { str = form->EditedValue(2); if (!str.IsNull() && str->Length() >= 1) + { GS.SetSeparator(str->Value(1)); + } } if (form->IsModified(3)) { str = form->EditedValue(3); if (!str.IsNull() && str->Length() >= 1) + { GS.SetEndMark(str->Value(1)); + } } if (form->IsModified(4)) + { GS.SetSendName(form->EditedValue(4)); + } if (form->IsModified(5)) + { GS.SetFileName(form->EditedValue(5)); + } if (form->IsModified(6)) + { GS.SetSystemId(form->EditedValue(6)); + } if (form->IsModified(7)) + { GS.SetInterfaceVersion(form->EditedValue(7)); + } if (form->IsModified(8)) + { GS.SetIntegerBits(form->EditedValue(8)->IntegerValue()); + } if (form->IsModified(9)) + { GS.SetMaxPower10Single(form->EditedValue(9)->IntegerValue()); + } if (form->IsModified(10)) + { GS.SetMaxDigitsSingle(form->EditedValue(10)->IntegerValue()); + } if (form->IsModified(11)) + { GS.SetMaxPower10Double(form->EditedValue(11)->IntegerValue()); + } if (form->IsModified(12)) + { GS.SetMaxDigitsDouble(form->EditedValue(12)->IntegerValue()); + } if (form->IsModified(13)) + { GS.SetReceiveName(form->EditedValue(13)); + } if (form->IsModified(14)) + { GS.SetScale(form->EditedValue(14)->RealValue()); + } if (form->IsModified(15)) + { GS.SetUnitFlag(form->EditedValue(15)->IntegerValue()); + } if (form->IsModified(16)) + { GS.SetUnitName(form->EditedValue(16)); + } if (form->IsModified(18)) + { GS.SetLineWeightGrad(form->EditedValue(18)->IntegerValue()); + } if (form->IsModified(19)) + { GS.SetMaxLineWeight(form->EditedValue(19)->RealValue()); + } if (form->IsModified(20)) + { GS.SetDate(form->EditedValue(20)); + } if (form->IsModified(21)) + { GS.SetResolution(form->EditedValue(21)->RealValue()); + } if (form->IsModified(22)) { str = form->EditedValue(22); if (str.IsNull()) + { GS.SetMaxCoord(); + } else + { GS.SetMaxCoord(str->RealValue()); + } } if (form->IsModified(23)) + { GS.SetAuthorName(form->EditedValue(23)); + } if (form->IsModified(24)) + { GS.SetCompanyName(form->EditedValue(24)); + } if (form->IsModified(25)) + { GS.SetIGESVersion(form->EditedValue(25)->IntegerValue()); + } if (form->IsModified(27)) + { GS.SetDraftingStandard(form->EditedValue(27)->IntegerValue()); + } if (form->IsModified(29)) + { GS.SetLastChangeDate(form->EditedValue(29)); + } if (form->IsModified(30)) + { GS.SetApplicationProtocol(form->EditedValue(30)); + } modl->SetGlobalSection(GS); @@ -467,7 +588,9 @@ bool IGESSelect_EditHeader::Apply(const occ::handle& form, { IGESData_BasicEditor bed(modl, occ::down_cast(modl->Protocol())); if (bed.SetUnitValue(GS.UnitValue())) + { return false; + } bed.ApplyUnit(true); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_FloatFormat.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_FloatFormat.cxx index 6c3c3b1875..a9e8b0c622 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_FloatFormat.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_FloatFormat.cxx @@ -96,14 +96,18 @@ void IGESSelect_FloatFormat::Perform(IFSelect_ContextWrite& /*ctx*/, writer.FloatWriter().SetFormat(themainform.ToCString()); writer.FloatWriter().SetZeroSuppress(thezerosup); if (theformrange.Length() > 0) + { writer.FloatWriter().SetFormatForRange(theformrange.ToCString(), therangemin, therangemax); + } } TCollection_AsciiString IGESSelect_FloatFormat::Label() const { TCollection_AsciiString lab("Float Format "); if (thezerosup) + { lab.AssignCat(" ZeroSup "); + } lab.AssignCat(themainform); if (theformrange.Length() > 0) { diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESName.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESName.cxx index 1c0429c8a1..7680d14a32 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESName.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESName.cxx @@ -34,9 +34,13 @@ const char* IGESSelect_IGESName::Value(const occ::handle& en { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return &falsetype[0]; + } occ::handle label = igesent->ShortLabel(); if (label.IsNull()) + { return &voidlabel[0]; + } return label->ToCString(); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESTypeForm.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESTypeForm.cxx index a13039fe0a..6fb4242d3d 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESTypeForm.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_IGESTypeForm.cxx @@ -49,23 +49,33 @@ const char* IGESSelect_IGESTypeForm::Value( { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return &falsetype[0]; + } bool unk = ent->IsKind(STANDARD_TYPE(IGESData_UndefinedEntity)); int typenum = igesent->TypeNumber(); int formnum = igesent->FormNumber(); if (unk) { if (theform) + { Sprintf(typeval, "%d %d (?)", typenum, formnum); + } else + { Sprintf(typeval, "%d (?)", typenum); + } } else { if (theform) + { Sprintf(typeval, "%d %d", typenum, formnum); + } else + { Sprintf(typeval, "%d", typenum); + } } return &typeval[0]; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildDrawings.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildDrawings.cxx index a7d9c704cc..e7058ef875 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildDrawings.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildDrawings.cxx @@ -77,26 +77,36 @@ void IGESSelect_RebuildDrawings::Performing(IFSelect_ContextModif& { occ::handle newent; if (TC.Search(setl.Value(), newent)) + { newset.AddItem(newent); + } } if (newset.NbEntities() == 0) + { continue; + } // On en tient un : le transferer (le reconstruire) occ::handle item = sorter->SetItem(is, true); if (item->TypeNumber() != PourDrawing) + { continue; + } if (item->IsKind(STANDARD_TYPE(IGESDraw_Drawing))) { DeclareAndCast(IGESDraw_Drawing, draw, item); int nbv = draw->NbViews(); occ::handle>> views; if (nbv > 0) + { views = new NCollection_HArray1>(1, nbv); + } // Passer ses vues : toutes // Aussi les positions des vues occ::handle> origs; if (nbv > 0) + { origs = new NCollection_HArray1(1, nbv); + } for (int iv = 1; iv <= nbv; iv++) { DeclareAndCast(IGESData_ViewKindEntity, aview, TC.Transferred(draw->ViewItem(iv))); @@ -113,12 +123,16 @@ void IGESSelect_RebuildDrawings::Performing(IFSelect_ContextModif& { occ::handle annot; if (TC.Search(draw->Annotation(ia), annot)) + { framelist.GetOneItem(annot); + } } nba = framelist.NbEntities(); ia = 0; if (nba > 0) + { frame = new NCollection_HArray1>(1, nba); + } for (framelist.Start(); framelist.More(); framelist.Next()) { ia++; @@ -137,12 +151,16 @@ void IGESSelect_RebuildDrawings::Performing(IFSelect_ContextModif& int nbv = draw->NbViews(); occ::handle>> views; if (nbv > 0) + { views = new NCollection_HArray1>(1, nbv); + } // Passer ses vues : toutes // Aussi les positions des vues .. et les rotations occ::handle> origs; if (nbv > 0) + { origs = new NCollection_HArray1(1, nbv); + } occ::handle> rots; if (nbv > 0) { @@ -167,12 +185,16 @@ void IGESSelect_RebuildDrawings::Performing(IFSelect_ContextModif& { occ::handle annot; if (TC.Search(draw->Annotation(ia), annot)) + { framelist.GetOneItem(annot); + } } nba = framelist.NbEntities(); ia = 0; if (nba > 0) + { frame = new NCollection_HArray1>(1, nba); + } for (framelist.Start(); framelist.More(); framelist.Next()) { ia++; @@ -192,13 +214,19 @@ void IGESSelect_RebuildDrawings::Performing(IFSelect_ContextModif& DeclareAndCast(IGESData_IGESEntity, ent, setl.Value()); occ::handle vieworig = ent->View(); if (vieworig.IsNull()) + { continue; + } occ::handle aView; if (!TC.Search(vieworig, aView)) + { continue; + } occ::handle viewnew = occ::down_cast(aView); if (!viewnew.IsNull()) + { ent->InitView(viewnew); + } } } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildGroups.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildGroups.cxx index 05d5667c9a..1277be00f7 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildGroups.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RebuildGroups.cxx @@ -58,12 +58,16 @@ void IGESSelect_RebuildGroups::Performing(IFSelect_ContextModif& { occ::handle ent = original->Entity(i); if (ent->TypeNumber() != 402) + { continue; + } int casenum = 0; occ::handle newent; Interface_EntityIterator newlist; if (TC.Search(ent, newent)) + { continue; // deja passe + } if (ent->IsKind(STANDARD_TYPE(IGESBasic_Group))) { DeclareAndCast(IGESBasic_Group, g, ent); @@ -72,7 +76,9 @@ void IGESSelect_RebuildGroups::Performing(IFSelect_ContextModif& for (int ig = 1; ig <= nbg; ig++) { if (TC.Search(g->Value(i), newent)) + { newlist.GetOneItem(newent); + } } } if (ent->IsKind(STANDARD_TYPE(IGESBasic_GroupWithoutBackP))) @@ -83,7 +89,9 @@ void IGESSelect_RebuildGroups::Performing(IFSelect_ContextModif& for (int ig = 1; ig <= nbg; ig++) { if (TC.Search(g->Value(i), newent)) + { newlist.GetOneItem(newent); + } } } if (ent->IsKind(STANDARD_TYPE(IGESBasic_OrderedGroup))) @@ -94,7 +102,9 @@ void IGESSelect_RebuildGroups::Performing(IFSelect_ContextModif& for (int ig = 1; ig <= nbg; ig++) { if (TC.Search(g->Value(i), newent)) + { newlist.GetOneItem(newent); + } } } if (ent->IsKind(STANDARD_TYPE(IGESBasic_OrderedGroupWithoutBackP))) @@ -105,12 +115,16 @@ void IGESSelect_RebuildGroups::Performing(IFSelect_ContextModif& for (int ig = 1; ig <= nbg; ig++) { if (TC.Search(g->Value(i), newent)) + { newlist.GetOneItem(newent); + } } } // A present, reconstruire sil le faut if (newlist.NbEntities() <= 1) + { continue; // 0 ou 1 : rien a refaire + } occ::handle>> tab = new NCollection_HArray1>(1, newlist.NbEntities()); int ng = 0; diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RemoveCurves.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RemoveCurves.cxx index 88ac0efc83..b71ac5e55e 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RemoveCurves.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_RemoveCurves.cxx @@ -70,22 +70,34 @@ static bool Edit(const occ::handle& ent, const bool UV) if (UV && !c3d.IsNull()) { if (cuv.IsNull() || c3d.IsNull()) + { return false; // rien a faire + } cuv.Nullify(); if (pref == 1) + { pref = 0; + } if (pref == 3) + { pref = 2; + } } else if (!cuv.IsNull()) { if (cuv.IsNull() || c3d.IsNull()) + { return false; // rien a faire + } c3d.Nullify(); if (pref == 2) + { pref = 0; + } if (pref == 3) + { pref = 1; + } } cons->Init(cons->CreationMode(), cons->Surface(), cuv, c3d, pref); return true; @@ -96,7 +108,9 @@ static bool Edit(const occ::handle& ent, const bool UV) { int i, nb = bndy->NbModelSpaceCurves(); if (nb == 0) + { return false; + } occ::handle>> arc3d = new NCollection_HArray1>(1, nb); occ::handle arcuv = @@ -111,14 +125,18 @@ static bool Edit(const occ::handle& ent, const bool UV) if (UV) { if (cuv.IsNull() || c3d.IsNull()) + { continue; // rien a faire + } cuv.Nullify(); arcuv->SetValue(i, cuv); } else { if (cuv.IsNull() || c3d.IsNull()) + { continue; // rien a faire + } c3d.Nullify(); arc3d->SetValue(i, c3d); res = true; @@ -129,19 +147,29 @@ static bool Edit(const occ::handle& ent, const bool UV) if (UV) { if (pref == 2) + { pref = 0; + } if (pref == 3) + { pref = 1; + } } else { if (pref == 1) + { pref = 0; + } if (pref == 3) + { pref = 2; + } } if (res) + { bndy->Init(bndy->BoundaryType(), pref, bndy->Surface(), arc3d, sens, arcuv); + } return res; } @@ -155,14 +183,20 @@ void IGESSelect_RemoveCurves::Performing(IFSelect_ContextModif& ctx, for (ctx.Start(); ctx.More(); ctx.Next()) { if (Edit(ctx.ValueResult(), theUV)) + { ctx.Trace(); + } } } TCollection_AsciiString IGESSelect_RemoveCurves::Label() const { if (theUV) + { return TCollection_AsciiString("Remove Curves UV on Face"); + } else + { return TCollection_AsciiString("Remove Curves 3D on Face"); + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBasicGeom.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBasicGeom.cxx index 7ce8ad28e0..e4ca15c009 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBasicGeom.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBasicGeom.cxx @@ -46,7 +46,9 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int igt = igesent->TypeNumber(); // CompositeCurve : a decomposer ? @@ -55,23 +57,31 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, DeclareAndCast(IGESGeom_CompositeCurve, cmc, ent); int i, nb = cmc->NbCurves(); for (i = 1; i <= nb; i++) + { explored.AddItem(cmc->Curve(i)); + } return true; } // Lignes en general. Attention CopiousData, aux variantes "habillage" if (igt == 106) + { return (igesent->FormNumber() < 20); + } if ((igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 || igt == 126 || igt == 130) + { return (thegeom >= 0); + } // Surfaces LIBRES, car il n y a pas d autre moyen de les reperer // (l ideal serait de prendre les bords naturels) // Ou surfaces debarassees de leurs contours if (igt == 114 || igt == 118 || igt == 120 || igt == 122 || igt == 128 || igt == 140 || igt == 190) + { return (thegeom <= 0); + } // Plan 108 // mode surface : on retourne tout le Plane sinon c est inexploitable @@ -79,12 +89,16 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, { DeclareAndCast(IGESGeom_Plane, pln, ent); if (thegeom >= 0) + { explored.AddItem(pln->BoundingCurve()); + } return pln->HasBoundingCurve(); } if (igt == 116) + { return (thegeom >= 0); // on point, ca va bien ... + } // TrimmedSurface 144 if (igt == 144) @@ -95,10 +109,14 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, explored.AddItem(trs->OuterContour()); int i, nb = trs->NbInnerContours(); for (i = 1; i <= nb; i++) + { explored.AddItem(trs->InnerContour(i)); + } } else + { explored.AddItem(trs->Surface()); + } return true; } @@ -116,7 +134,9 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, DeclareAndCast(IGESGeom_Boundary, bnd, ent); int i, nb = bnd->NbModelSpaceCurves(); for (i = 1; i <= nb; i++) + { explored.AddItem(bnd->ModelSpaceCurve(i)); + } return (nb > 0); } @@ -129,11 +149,15 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, { nb = bns->NbBoundaries(); for (i = 1; i <= nb; i++) + { explored.AddItem(bns->Boundary(i)); + } return (nb != 0); } else + { explored.AddItem(bns->Surface()); + } return true; } @@ -142,11 +166,15 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_SingleParent, sp, ent); if (sp.IsNull()) + { return false; + } explored.AddItem(sp->SingleParent()); int i, nb = sp->NbChildren(); for (i = 1; i <= nb; i++) + { explored.AddItem(sp->Child(i)); + } return true; } @@ -155,10 +183,14 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_Group, gr, ent); if (gr.IsNull()) + { return false; + } int i, nb = gr->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(gr->Entity(i)); + } return true; } @@ -169,7 +201,9 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, explored.AddItem(msb->Shell()); int i, nb = msb->NbVoidShells(); for (i = 1; i <= nb; i++) + { explored.AddItem(msb->VoidShell(i)); + } return true; } @@ -179,7 +213,9 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, DeclareAndCast(IGESSolid_Shell, sh, ent); int i, nb = sh->NbFaces(); for (i = 1; i <= nb; i++) + { explored.AddItem(sh->Face(i)); + } return true; } @@ -191,10 +227,14 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, { int i, nb = fc->NbLoops(); for (i = 1; i <= nb; i++) + { explored.AddItem(fc->Loop(i)); + } } else + { explored.AddItem(fc->Surface()); + } return true; } @@ -208,7 +248,9 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, DeclareAndCast(IGESSolid_EdgeList, edl, lp->Edge(i)); int ind = lp->ListIndex(i); if (edl.IsNull()) + { continue; + } explored.AddItem(edl->Curve(ind)); } return true; @@ -221,20 +263,30 @@ bool IGESSelect_SelectBasicGeom::Explore(const int /*level*/, TCollection_AsciiString IGESSelect_SelectBasicGeom::ExploreLabel() const { if (thegeom == 2) + { return TCollection_AsciiString("Basic Curves 3d"); + } else if (thegeom > 0) + { return TCollection_AsciiString("Curves 3d"); + } else if (thegeom < 0) + { return TCollection_AsciiString("Surfaces"); + } else + { return TCollection_AsciiString("Basic Geometry"); + } } bool IGESSelect_SelectBasicGeom::SubCurves(const occ::handle& ent, Interface_EntityIterator& explored) { if (ent.IsNull()) + { return false; + } int igt = ent->TypeNumber(); // CompositeCurve : a decomposer ? @@ -243,16 +295,22 @@ bool IGESSelect_SelectBasicGeom::SubCurves(const occ::handleNbCurves(); for (i = 1; i <= nb; i++) + { explored.AddItem(cmc->Curve(i)); + } return true; } // Lignes en general. Attention CopiousData, aux variantes "habillage" if (igt == 106) + { return (ent->FormNumber() < 20); + } if ((igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 || igt == 126 || igt == 130) + { return true; + } // Sinon return false; diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassGroup.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassGroup.cxx index afb7500a4c..5235447b35 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassGroup.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassGroup.cxx @@ -36,11 +36,15 @@ bool IGESSelect_SelectBypassGroup::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_Group, gr, ent); // Group groups them all if (gr.IsNull()) + { return true; + } int i, nb = gr->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(gr->Entity(i)); + } return true; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassSubfigure.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassSubfigure.cxx index b0874e2d06..5f47c36927 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassSubfigure.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectBypassSubfigure.cxx @@ -40,7 +40,9 @@ bool IGESSelect_SelectBypassSubfigure::Explore(const int /*level*/, { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int igt = igesent->TypeNumber(); // SingularSubfigure @@ -48,10 +50,14 @@ bool IGESSelect_SelectBypassSubfigure::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_SubfigureDef, subf, ent); if (subf.IsNull()) + { return true; + } int i, nb = subf->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(subf->AssociatedEntity(i)); + } return true; } if (igt == 408) @@ -65,10 +71,14 @@ bool IGESSelect_SelectBypassSubfigure::Explore(const int /*level*/, { DeclareAndCast(IGESDraw_NetworkSubfigureDef, subf, ent); if (subf.IsNull()) + { return true; + } int i, nb = subf->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(subf->Entity(i)); + } return true; } if (igt == 420) diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectDrawingFrom.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectDrawingFrom.cxx index 92fa663ba9..6a43446245 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectDrawingFrom.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectDrawingFrom.cxx @@ -40,7 +40,9 @@ Interface_EntityIterator IGESSelect_SelectDrawingFrom::RootResult(const Interfac Interface_EntityIterator list; int nb = sorter->NbSets(true); for (int i = 1; i <= nb; i++) + { list.GetOneItem(sorter->SetItem(i, true)); + } return list; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFaces.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFaces.cxx index de3ee3228f..269e1aae37 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFaces.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFaces.cxx @@ -39,17 +39,23 @@ bool IGESSelect_SelectFaces::Explore(const int /*level*/, { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int igt = igesent->TypeNumber(); // Cas clairs et nets : Faces typees comme telles if (igt == 510 || igt == 144 || igt == 143) + { return true; + } // Surfaces Libres if (igt == 114 || igt == 118 || igt == 120 || igt == 122 || igt == 128 || igt == 140) + { return true; + } // Cas du Plane if (igt == 108) @@ -65,11 +71,15 @@ bool IGESSelect_SelectFaces::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_SingleParent, sp, ent); if (sp.IsNull()) + { return false; + } explored.AddItem(sp->SingleParent()); int i, nb = sp->NbChildren(); for (i = 1; i <= nb; i++) + { explored.AddItem(sp->Child(i)); + } return true; } @@ -78,10 +88,14 @@ bool IGESSelect_SelectFaces::Explore(const int /*level*/, { DeclareAndCast(IGESBasic_Group, gr, ent); if (gr.IsNull()) + { return false; + } int i, nb = gr->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(gr->Entity(i)); + } return true; } @@ -92,7 +106,9 @@ bool IGESSelect_SelectFaces::Explore(const int /*level*/, explored.AddItem(msb->Shell()); int i, nb = msb->NbVoidShells(); for (i = 1; i <= nb; i++) + { explored.AddItem(msb->VoidShell(i)); + } return true; } @@ -102,7 +118,9 @@ bool IGESSelect_SelectFaces::Explore(const int /*level*/, DeclareAndCast(IGESSolid_Shell, sh, ent); int i, nb = sh->NbFaces(); for (i = 1; i <= nb; i++) + { explored.AddItem(sh->Face(i)); + } return true; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromDrawing.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromDrawing.cxx index fe8bcb3b22..ea5bf33722 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromDrawing.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromDrawing.cxx @@ -30,7 +30,9 @@ Interface_EntityIterator IGESSelect_SelectFromDrawing::RootResult(const Interfac Interface_EntityIterator list, views; Interface_EntityIterator draws = InputResult(G); if (draws.NbEntities() == 0) + { return list; + } int nb = G.Size(); int i; // svv Jan11 2000 : porting on DEC @@ -40,9 +42,13 @@ Interface_EntityIterator IGESSelect_SelectFromDrawing::RootResult(const Interfac { DeclareAndCast(IGESData_IGESEntity, igesent, draws.Value()); if (igesent.IsNull()) + { continue; + } if (igesent->TypeNumber() != PourDrawing) + { continue; + } list.GetOneItem(igesent); Interface_EntityIterator someviews = G.Shareds(draws.Value()); list.AddList(someviews.Content()); @@ -52,10 +58,14 @@ Interface_EntityIterator IGESSelect_SelectFromDrawing::RootResult(const Interfac // if (!G.IsPresent(i)) continue; DeclareAndCast(IGESData_IGESEntity, igesent, G.Entity(i)); if (igesent.IsNull()) + { continue; + } int nv = G.EntityNumber(igesent->View()); if (nv > 0 && nv <= nb) + { list.GetOneItem(igesent); + } } return list; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromSingleView.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromSingleView.cxx index 07b692e4cb..655859da17 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromSingleView.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectFromSingleView.cxx @@ -28,7 +28,9 @@ Interface_EntityIterator IGESSelect_SelectFromSingleView::RootResult(const Inter Interface_EntityIterator list; Interface_EntityIterator views = InputResult(G); if (views.NbEntities() == 0) + { return list; + } int nb = G.Size(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= nb; i++) @@ -36,10 +38,14 @@ Interface_EntityIterator IGESSelect_SelectFromSingleView::RootResult(const Inter // if (!G.IsPresent(i)) continue; DeclareAndCast(IGESData_IGESEntity, igesent, G.Entity(i)); if (igesent.IsNull()) + { continue; + } int nv = G.EntityNumber(igesent->View()); if (nv > 0 && nv <= nb) + { list.GetOneItem(igesent); + } } return list; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectLevelNumber.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectLevelNumber.cxx index 60efc111ac..7f504155d9 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectLevelNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectLevelNumber.cxx @@ -42,23 +42,33 @@ bool IGESSelect_SelectLevelNumber::Sort( { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int numlev = 0; if (!thelevnum.IsNull()) + { numlev = thelevnum->Value(); + } DeclareAndCast(IGESGraph_DefinitionLevel, levelist, igesent->LevelList()); int level = igesent->Level(); if (levelist.IsNull()) + { return (level == numlev); + } // Cas d une liste if (numlev == 0) + { return false; + } int nb = levelist->NbPropertyValues(); for (int i = 1; i <= nb; i++) { level = levelist->LevelNumber(i); if (level == numlev) + { return true; + } } return false; } @@ -68,9 +78,13 @@ TCollection_AsciiString IGESSelect_SelectLevelNumber::ExtractLabel() const char labl[50]; int numlev = 0; if (!thelevnum.IsNull()) + { numlev = thelevnum->Value(); + } if (numlev == 0) + { return TCollection_AsciiString("IGES Entity attached to no Level"); + } Sprintf(labl, "IGES Entity, Level Number admitting %d", numlev); return TCollection_AsciiString(labl); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectName.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectName.cxx index 1251779f68..719c333d44 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectName.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectName.cxx @@ -41,11 +41,17 @@ bool IGESSelect_SelectName::Sort(const int /*rank*/, { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } if (!igesent->HasName()) + { return false; + } if (thename.IsNull()) + { return false; + } occ::handle name = igesent->NameValue(); // std::cout<<"SelectName:"<ToCString()<<",with:"<ToCString()<<",IsSameString="<IsSameString // (name,false)<Value(i) != thename->Value(i)) + { return false; + } } if (nb0 > nb1) + { name = thename; + } for (i = nbf + 1; i <= nbt; i++) { if (name->Value(i) != ' ') + { return false; + } } return true; } @@ -78,5 +90,7 @@ TCollection_AsciiString IGESSelect_SelectName::ExtractLabel() const return TCollection_AsciiString(labl); } else + { return TCollection_AsciiString("IGES Entity, Name : (undefined)"); + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectPCurves.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectPCurves.cxx index 8f12e16cb6..edc64ba456 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectPCurves.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectPCurves.cxx @@ -41,7 +41,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int igt = igesent->TypeNumber(); // TrimmedSurface 144 @@ -51,7 +53,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le explored.AddItem(trs->OuterContour()); int i, nb = trs->NbInnerContours(); for (i = 1; i <= nb; i++) + { explored.AddItem(trs->InnerContour(i)); + } return true; } @@ -61,7 +65,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le DeclareAndCast(IGESGeom_CurveOnSurface, crf, ent); explored.AddItem(crf->CurveUV()); if (thebasic) + { IGESSelect_SelectBasicGeom::SubCurves(crf->CurveUV(), explored); + } return true; } @@ -87,7 +93,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le DeclareAndCast(IGESGeom_BoundedSurface, bns, ent); int i, nb = bns->NbBoundaries(); // szv#4:S4163:12Mar99 optimized for (i = 1; i <= nb; i++) + { explored.AddItem(bns->Boundary(i)); + } return (nb != 0); // return true; //szv#4:S4163:12Mar99 unreached } @@ -97,10 +105,14 @@ bool IGESSelect_SelectPCurves::Explore(const int le { DeclareAndCast(IGESBasic_Group, gr, ent); if (gr.IsNull()) + { return false; + } int i, nb = gr->NbEntities(); for (i = 1; i <= nb; i++) + { explored.AddItem(gr->Entity(i)); + } return true; } @@ -111,7 +123,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le explored.AddItem(msb->Shell()); int i, nb = msb->NbVoidShells(); for (i = 1; i <= nb; i++) + { explored.AddItem(msb->VoidShell(i)); + } return true; } @@ -121,7 +135,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le DeclareAndCast(IGESSolid_Shell, sh, ent); int i, nb = sh->NbFaces(); for (i = 1; i <= nb; i++) + { explored.AddItem(sh->Face(i)); + } return true; } @@ -131,7 +147,9 @@ bool IGESSelect_SelectPCurves::Explore(const int le DeclareAndCast(IGESSolid_Face, fc, ent); int i, nb = fc->NbLoops(); for (i = 1; i <= nb; i++) + { explored.AddItem(fc->Loop(i)); + } return true; } @@ -143,8 +161,10 @@ bool IGESSelect_SelectPCurves::Explore(const int le for (i = 1; i <= nb; i++) { int j, np = lp->NbParameterCurves(i); - for (j = 1; j <= np; j++) // szv#4:S4163:12Mar99 was bug + for (j = 1; j <= np; j++) + { // szv#4:S4163:12Mar99 was bug explored.AddItem(lp->ParametricCurve(i, j)); + } } return true; } @@ -152,13 +172,19 @@ bool IGESSelect_SelectPCurves::Explore(const int le // LES LIGNES : seult si en tant que pcurve : donc level >= 3 // Lignes en general. Attention CopiousData, aux variantes "habillage" if (level < 3) + { return false; + } if (igt == 106) + { return (igesent->FormNumber() < 20); + } if ((igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 || igt == 126 || igt == 130) + { return true; + } // Pas trouve return false; @@ -167,7 +193,11 @@ bool IGESSelect_SelectPCurves::Explore(const int le TCollection_AsciiString IGESSelect_SelectPCurves::ExploreLabel() const { if (thebasic) + { return TCollection_AsciiString("Basic PCurves"); + } else + { return TCollection_AsciiString("Global PCurves"); + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSingleViewFrom.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSingleViewFrom.cxx index bb5c5046a0..fa55b102be 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSingleViewFrom.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSingleViewFrom.cxx @@ -40,7 +40,9 @@ Interface_EntityIterator IGESSelect_SelectSingleViewFrom::RootResult(const Inter Interface_EntityIterator list; int nb = sorter->NbSets(true); for (int i = 1; i <= nb; i++) + { list.GetOneItem(sorter->SetItem(i, true)); + } return list; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSubordinate.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSubordinate.cxx index bf63e9cffe..d028f390c7 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSubordinate.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectSubordinate.cxx @@ -38,16 +38,26 @@ bool IGESSelect_SelectSubordinate::Sort( { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } int sub = igesent->SubordinateStatus(); if (sub == thestatus) + { return true; + } if (thestatus == 4 && (sub == 1 || sub == 3)) + { return true; + } if (thestatus == 5 && (sub == 2 || sub == 3)) + { return true; + } if (thestatus == 6 && sub != 0) + { return true; + } return false; } @@ -55,18 +65,32 @@ TCollection_AsciiString IGESSelect_SelectSubordinate::ExtractLabel() const { TCollection_AsciiString lab("IGESEntity, Subordinate "); if (thestatus == 0) + { lab.AssignCat("Independant (0)"); + } if (thestatus == 1) + { lab.AssignCat("Physically only Dependant (1)"); + } if (thestatus == 2) + { lab.AssignCat("Logically only Dependant (2) "); + } if (thestatus == 3) + { lab.AssignCat("Both Phys. and Log. Dependant (3)"); + } if (thestatus == 4) + { lab.AssignCat("Physically Dependant (1 or 3)"); + } if (thestatus == 5) + { lab.AssignCat("Logically Dependant (2 or 3)"); + } if (thestatus == 6) + { lab.AssignCat("Dependant in any way (1 or 2 or 3)"); + } return lab; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectVisibleStatus.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectVisibleStatus.cxx index 90b3d934e8..053f17274e 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectVisibleStatus.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SelectVisibleStatus.cxx @@ -30,7 +30,9 @@ bool IGESSelect_SelectVisibleStatus::Sort( { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return false; + } return (igesent->BlankStatus() == 0); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetGlobalParameter.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetGlobalParameter.cxx index cc4dc23ccc..0aae2e91bf 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetGlobalParameter.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetGlobalParameter.cxx @@ -70,15 +70,21 @@ void IGESSelect_SetGlobalParameter::Performing(IFSelect_ContextModif& GS.Init(oldset, check); ctx.AddCheck(check); if (!check->HasFailed()) + { target->SetGlobalSection(GS); + } } TCollection_AsciiString IGESSelect_SetGlobalParameter::Label() const { char mess[80]; if (theval.IsNull()) + { Sprintf(mess, "Set IGES Global Parameter (undefined)"); + } else + { Sprintf(mess, "Set IGES Global Parameter Number %d to %s", thenum, theval->ToCString()); + } return TCollection_AsciiString(mess); } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetLabel.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetLabel.cxx index 595e9bf784..6dee7d7c7d 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetLabel.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetLabel.cxx @@ -39,7 +39,9 @@ void IGESSelect_SetLabel::Performing(IFSelect_ContextModif& ctx, { DeclareAndCast(IGESData_IGESEntity, iges, ctx.ValueResult()); if (iges.IsNull()) + { continue; + } if (themode == 0) { iges->SetLabel(lab); @@ -49,13 +51,17 @@ void IGESSelect_SetLabel::Performing(IFSelect_ContextModif& ctx, // mode = 1 : mettre DEnnn , nnn est le DE Number lab = iges->ShortLabel(); if (theforce) + { lab.Nullify(); + } if (!lab.IsNull()) { if (lab->Length() > 2) { if (lab->Value(1) == 'D' && lab->Value(2) == 'E' && atoi(&(lab->ToCString())[2]) > 0) + { lab.Nullify(); + } } } // Si lab nul : le recalculer @@ -72,10 +78,16 @@ TCollection_AsciiString IGESSelect_SetLabel::Label() const { TCollection_AsciiString lab; if (themode == 0) + { lab.AssignCat("Clear Short Label"); + } if (themode == 1) + { lab.AssignCat("Set Short Label to DE Number"); + } if (theforce) + { lab.AssignCat(" (enforced)"); + } return lab; } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetVersion5.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetVersion5.cxx index 60c96348d3..9522ac8b39 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetVersion5.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SetVersion5.cxx @@ -32,14 +32,18 @@ void IGESSelect_SetVersion5::Performing(IFSelect_ContextModif& c { IGESData_GlobalSection GS = target->GlobalSection(); if (GS.IGESVersion() >= 9) + { return; + } GS.SetIGESVersion(9); GS.SetLastChangeDate(); target->SetGlobalSection(GS); occ::handle check = new Interface_Check; target->VerifyCheck(check); if (check->HasFailed()) + { ctx.CCheck()->GetMessages(check); + } } TCollection_AsciiString IGESSelect_SetVersion5::Label() const diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignColor.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignColor.cxx index 063c3af45e..c3509f2f00 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignColor.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignColor.cxx @@ -48,7 +48,9 @@ IGESSelect_SignColor::IGESSelect_SignColor(const int mode) themode(mode) { if (mode == 4 || mode == 5 || mode == 6) + { SetIntCase(true, 0, true, 0); + } } const char* IGESSelect_SignColor::Value(const occ::handle& ent, @@ -57,7 +59,9 @@ const char* IGESSelect_SignColor::Value(const occ::handle& double red = -1, green = -1, blue = -1; DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (igesent.IsNull()) + { return ""; + } int rank = igesent->RankColor(); DeclareAndCast(IGESGraph_Color, color, igesent->Color()); valbuf.Clear(); @@ -66,7 +70,9 @@ const char* IGESSelect_SignColor::Value(const occ::handle& if (themode < 2 || themode > 6) { if (rank == 0) + { return "(none)"; + } if (rank > 0) { valbuf.AssignCat("S"); @@ -105,13 +111,19 @@ const char* IGESSelect_SignColor::Value(const occ::handle& return "WHITE"; default: if (rank > 0) + { return "Unknown Number"; + } } occ::handle name; if (!color.IsNull()) + { name = color->ColorName(); + } if (!name.IsNull()) + { return name->ToCString(); + } int num = (model.IsNull() ? 0 : 2 * model->Number(color) - 1); valbuf.AssignCat("D"); valbuf.AssignCat(IFSelect_Signature::IntValue(num)); @@ -142,18 +154,28 @@ const char* IGESSelect_SignColor::Value(const occ::handle& return "100,100,100"; default: if (rank > 0) + { return ""; + } } if (!color.IsNull()) + { color->RGBIntensity(red, green, blue); + } if (red >= 0) + { valbuf.AssignCat(IFSelect_Signature::IntValue(int(red))); + } valbuf.AssignCat(","); if (green >= 0) + { valbuf.AssignCat(IFSelect_Signature::IntValue(int(green))); + } valbuf.AssignCat(","); if (blue >= 0) + { valbuf.AssignCat(IFSelect_Signature::IntValue(int(blue))); + } // RED value } @@ -181,12 +203,18 @@ const char* IGESSelect_SignColor::Value(const occ::handle& return "100"; default: if (rank > 0) + { return ""; + } } if (!color.IsNull()) + { color->RGBIntensity(red, green, blue); + } if (red >= 0) + { return IFSelect_Signature::IntValue(int(red)); + } // GREEN Value } @@ -214,12 +242,18 @@ const char* IGESSelect_SignColor::Value(const occ::handle& return "100"; default: if (rank > 0) + { return ""; + } } if (!color.IsNull()) + { color->RGBIntensity(red, green, blue); + } if (green >= 0) + { return IFSelect_Signature::IntValue(int(green)); + } // BLUE Value } @@ -247,12 +281,18 @@ const char* IGESSelect_SignColor::Value(const occ::handle& return "100"; default: if (rank > 0) + { return ""; + } } if (!color.IsNull()) + { color->RGBIntensity(red, green, blue); + } if (blue >= 0) + { return IFSelect_Signature::IntValue(int(blue)); + } } return valbuf.ToCString(); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignLevelNumber.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignLevelNumber.cxx index 37e134eb35..4b5c1b3b05 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignLevelNumber.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignLevelNumber.cxx @@ -59,13 +59,19 @@ const char* IGESSelect_SignLevelNumber::Value( // if (level < 0) return (thecountmode ? " NO LEVEL" : "/0/"); laval.Clear(); if (thecountmode) + { Sprintf(carlev, "%7d", level); + } else + { Sprintf(carlev, "/%d/", level); + } laval.AssignCat(carlev); } else if (thecountmode) + { return "LEVEL LIST"; + } else { int i, nblev = levelist->NbLevelNumbers(); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignStatus.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignStatus.cxx index 3964c9c750..4cb8979692 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignStatus.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SignStatus.cxx @@ -34,7 +34,9 @@ const char* IGESSelect_SignStatus::Value( { occ::handle igesent = occ::down_cast(ent); if (igesent.IsNull()) + { return ""; + } int i, j, k, l; i = igesent->BlankStatus(); j = igesent->SubordinateStatus(); @@ -51,7 +53,9 @@ bool IGESSelect_SignStatus::Matches(const occ::handle& ent, { occ::handle igesent = occ::down_cast(ent); if (igesent.IsNull()) + { return false; + } int i, j, k, l; i = igesent->BlankStatus(); j = igesent->SubordinateStatus(); @@ -59,9 +63,13 @@ bool IGESSelect_SignStatus::Matches(const occ::handle& ent, l = igesent->HierarchyStatus(); int n, nb = text.Length(); if (nb > 9) + { nb = 9; + } for (n = 1; n <= nb; n++) + { theval[n - 1] = text.Value(n); + } theval[nb] = '\0'; int vir = 0, val = 0; @@ -75,45 +83,73 @@ bool IGESSelect_SignStatus::Matches(const occ::handle& ent, } val = int(car - 48); if (car == 'V' && vir == 0) + { val = 0; + } if (car == 'B' && vir == 0) + { val = 1; + } if (car == 'I' && vir == 1) + { val = 0; + } if (car == 'P' && vir == 1) + { val = 1; + } if (car == 'L' && vir == 1) + { val = 2; + } if (car == 'D' && vir == 1) + { val = 3; + } // Matches ? if (vir == 0) { // Blank if (i == val && !exact) + { return true; + } if (i != val && exact) + { return false; + } } if (vir == 1) { // Subord. if (j == val && !exact) + { return true; + } if (j != val && exact) + { return false; + } } if (vir == 2) { // UseFlag if (k == val && !exact) + { return true; + } if (k != val && exact) + { return false; + } } if (vir == 3) { // Hierarchy if (l == val && !exact) + { return true; + } if (l != val && exact) + { return false; + } } } return exact; // a bit of reflection to arrive diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SplineToBSpline.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SplineToBSpline.cxx index 46344245e2..55fbc4b260 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SplineToBSpline.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_SplineToBSpline.cxx @@ -48,7 +48,9 @@ bool IGESSelect_SplineToBSpline::Perform(const Interface_Graph& G, { DeclareAndCast(IGESData_IGESEntity, ent, G.Entity(i)); if (ent.IsNull()) + { continue; + } int it = ent->TypeNumber(); if (it == 112 || it == 126) { @@ -61,7 +63,9 @@ bool IGESSelect_SplineToBSpline::Perform(const Interface_Graph& G, } newmod.Nullify(); if (!thefound) + { return true; + } // Il faudrait convertir ... checks.CCheck(0)->AddFail("IGESSelect_SplineToBSpline : not yet implemented"); @@ -77,15 +81,21 @@ bool IGESSelect_SplineToBSpline::Updated(const occ::handle& return true; } if (themap.IsNull()) + { return false; + } return themap->Search(entfrom, entto); } TCollection_AsciiString IGESSelect_SplineToBSpline::Label() const { if (thetryc2) + { return TCollection_AsciiString( "Convert Spline Forms to BSpline, trying to recover C1-C2 continuity"); + } else + { return TCollection_AsciiString("Convert Spline Forms to BSpline"); + } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateCreationDate.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateCreationDate.cxx index f3d282b88b..22d9fcc0b2 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateCreationDate.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateCreationDate.cxx @@ -42,12 +42,16 @@ void IGESSelect_UpdateCreationDate::Performing(IFSelect_ContextModif& IGESData_GlobalSection GS = target->GlobalSection(); if (annee < 2000) + { // #65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000) GS.SetDate(IGESData_GlobalSection::NewDateString(annee, mois, jour, heure, minute, seconde, 0)); + } else + { // #65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000) GS.SetDate( IGESData_GlobalSection::NewDateString(annee, mois, jour, heure, minute, seconde, -1)); + } target->SetGlobalSection(GS); occ::handle check = new Interface_Check; target->VerifyCheck(check); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateLastChange.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateLastChange.cxx index 0c01ff6c4e..f67b5393d3 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateLastChange.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_UpdateLastChange.cxx @@ -42,14 +42,20 @@ void IGESSelect_UpdateLastChange::Performing(IFSelect_ContextModif& IGESData_GlobalSection GS = target->GlobalSection(); if (GS.IGESVersion() < 9) + { GS.SetIGESVersion(9); + } if (annee < 2000) + { // #65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000) GS.SetDate(IGESData_GlobalSection::NewDateString(annee, mois, jour, heure, minute, seconde, 0)); + } else + { // #65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000) GS.SetDate( IGESData_GlobalSection::NewDateString(annee, mois, jour, heure, minute, seconde, -1)); + } target->SetGlobalSection(GS); occ::handle check = new Interface_Check; target->VerifyCheck(check); diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ViewSorter.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ViewSorter.cxx index 5cbc574957..b8f4985fa5 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ViewSorter.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_ViewSorter.cxx @@ -37,7 +37,9 @@ void IGESSelect_ViewSorter::Clear() { int nb = themodel->NbEntities(); if (nb < 100) + { nb = 100; + } themap.Clear(); themap.ReSize(nb); theitems.Clear(); @@ -52,7 +54,9 @@ bool IGESSelect_ViewSorter::Add(const occ::handle& ent) { DeclareAndCast(IGESData_IGESEntity, igesent, ent); if (!igesent.IsNull()) + { return AddEntity(igesent); + } DeclareAndCast(NCollection_HSequence>, list, ent); if (!list.IsNull()) { @@ -72,20 +76,30 @@ bool IGESSelect_ViewSorter::AddEntity(const occ::handle& ig { // Reception, controle de type et de map if (igesent.IsNull()) + { return false; + } if (themap.FindIndex(igesent)) + { return false; + } themap.Add(igesent); // View recovery (watch out for Drawing case) occ::handle view; if (igesent->TypeNumber() == PourDrawing) + { view = igesent; // DRAWING + } else { if (igesent->IsKind(STANDARD_TYPE(IGESData_ViewKindEntity))) + { view = igesent; // VIEW + } else + { view = igesent->View(); + } /* DeclareAndCast(IGESData_ViewKindEntity,trueview,view); if (!trueview.IsNull()) @@ -98,7 +112,9 @@ bool IGESSelect_ViewSorter::AddEntity(const occ::handle& ig { viewindex = theitems.FindIndex(view); if (viewindex <= 0) + { viewindex = theitems.Add(view); + } } theinditem.Append(viewindex); theindfin.Append(0); @@ -110,17 +126,23 @@ void IGESSelect_ViewSorter::AddList( { int nb = list->Length(); for (int i = 1; i <= nb; i++) + { Add(list->Value(i)); + } } void IGESSelect_ViewSorter::AddModel(const occ::handle& model) { DeclareAndCast(IGESData_IGESModel, igesmod, model); if (igesmod.IsNull()) + { return; + } int nb = igesmod->NbEntities(); for (int i = 1; i <= nb; i++) + { AddEntity(igesmod->Entity(i)); + } } int IGESSelect_ViewSorter::NbEntities() const @@ -149,18 +171,24 @@ void IGESSelect_ViewSorter::SortSingleViews(const bool alsoframes) DeclareAndCast(IGESData_IGESEntity, item, theitems.FindKey(numitem)); bool ok = false; if (alsoframes) + { ok = (item->TypeNumber() == PourDrawing); + } if (!ok) { DeclareAndCast(IGESData_ViewKindEntity, view, item); if (!view.IsNull()) + { ok = view->IsSingle(); + } } if (ok) { finalindex = thefinals.FindIndex(item); if (finalindex <= 0) + { finalindex = thefinals.Add(item); + } } } theindfin.SetValue(i, finalindex); @@ -183,11 +211,15 @@ void IGESSelect_ViewSorter::SortDrawings(const Interface_Graph& G) // numit = numitem; //szv#4:S4163:12Mar99 not needed DeclareAndCast(IGESData_IGESEntity, item, theitems.FindKey(numitem)); if (item.IsNull()) + { continue; + } // Si cest un Drawing, il definit le Set. Sinon, chercher Drawing contenant occ::handle drawing; if (item->TypeNumber() == PourDrawing) + { drawing = item; + } else { Interface_EntityIterator list = G.Sharings(item); @@ -195,16 +227,22 @@ void IGESSelect_ViewSorter::SortDrawings(const Interface_Graph& G) { DeclareAndCast(IGESData_IGESEntity, draw, list.Value()); if (draw.IsNull()) + { continue; + } if (draw->TypeNumber() == PourDrawing) + { drawing = draw; + } } } if (!drawing.IsNull()) { finalindex = thefinals.FindIndex(drawing); if (finalindex <= 0) + { finalindex = thefinals.Add(drawing); + } } } theindfin.SetValue(i, finalindex); @@ -216,18 +254,26 @@ void IGESSelect_ViewSorter::SortDrawings(const Interface_Graph& G) int IGESSelect_ViewSorter::NbSets(const bool final) const { if (final) + { return thefinals.Extent(); + } else + { return theitems.Extent(); + } } occ::handle IGESSelect_ViewSorter::SetItem(const int num, const bool final) const { if (final) + { return GetCasted(IGESData_IGESEntity, thefinals.FindKey(num)); + } else + { return GetCasted(IGESData_IGESEntity, theitems.FindKey(num)); + } } occ::handle IGESSelect_ViewSorter::Sets(const bool final) const @@ -245,7 +291,9 @@ occ::handle IGESSelect_ViewSorter::Sets(const bool final) c for (i = 1; i <= nb; i++) { if (theindfin.Value(i) != num) + { continue; + } list->Add(themap.FindKey(i)); } } @@ -254,7 +302,9 @@ occ::handle IGESSelect_ViewSorter::Sets(const bool final) c for (i = 1; i <= nb; i++) { if (theinditem.Value(i) != num) + { continue; + } list->Add(themap.FindKey(i)); } } diff --git a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_WorkLibrary.cxx b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_WorkLibrary.cxx index 48150908d2..7aa49a0c48 100644 --- a/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_WorkLibrary.cxx +++ b/src/DataExchange/TKDEIGES/IGESSelect/IGESSelect_WorkLibrary.cxx @@ -82,13 +82,21 @@ int IGESSelect_WorkLibrary::ReadFile(const char* const name int status = IGESFile_Read(pname, igesmod, prot); if (status < 0) - sout << "File not found : " << name << std::endl; + { + sout << "File not found : " << name << '\n'; + } if (status > 0) - sout << "Error when reading file : " << name << std::endl; + { + sout << "Error when reading file : " << name << '\n'; + } if (status == 0) + { model = igesmod; + } else + { model.Nullify(); + } return status; } @@ -100,14 +108,16 @@ bool IGESSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const DeclareAndCast(IGESData_Protocol, prot, ctx.Protocol()); if (igesmod.IsNull() || prot.IsNull()) + { return false; + } const occ::handle& aFileSystem = OSD_FileSystem::DefaultFileSystem(); std::shared_ptr aStream = aFileSystem->OpenOStream(ctx.FileName(), std::ios::out | std::ios::binary); if (aStream.get() == nullptr) { ctx.CCheck(0)->AddFail("IGES File could not be created"); - sout << " - IGES File could not be created : " << ctx.FileName() << std::endl; + sout << " - IGES File could not be created : " << ctx.FileName() << '\n'; return false; } sout << " IGES File Name : " << ctx.FileName(); @@ -121,13 +131,19 @@ bool IGESSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const ctx.SetModifier(numod); DeclareAndCast(IGESSelect_FileModifier, filemod, ctx.FileModifier()); if (!filemod.IsNull()) + { filemod->Perform(ctx, VW); + } // (impressions de mise au point) sout << " .. FileMod." << numod << " " << filemod->Label(); if (ctx.IsForAll()) + { sout << " (all model)"; + } else + { sout << " (" << ctx.NbEntities() << " entities)"; + } // sout << std::flush; } @@ -135,16 +151,20 @@ bool IGESSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const VW.SendModel(prot); sout << " Write "; if (themodefnes) + { VW.WriteMode() = 10; + } bool status = VW.Print(*aStream); - sout << " Done" << std::endl; + sout << " Done" << '\n'; errno = 0; aStream->flush(); status = aStream->good() && status && !errno; aStream.reset(); if (errno) - sout << strerror(errno) << std::endl; + { + sout << strerror(errno) << '\n'; + } return status; } @@ -152,7 +172,9 @@ bool IGESSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const occ::handle IGESSelect_WorkLibrary::DefineProtocol() { if (!IGESProto.IsNull()) + { return IGESProto; + } occ::handle IGESProto1 = IGESSolid::Protocol(); occ::handle IGESProto2 = IGESAppli::Protocol(); // occ::handle IGESProto = new IGESData_FileProtocol; @@ -172,19 +194,25 @@ void IGESSelect_WorkLibrary::DumpEntity(const occ::handleNumber(igesent); if (num == 0) + { return; + } S << " --- Entity " << num; bool iserr = model->IsRedefinedContent(num); occ::handle con; if (iserr) + { con = model->ReportEntity(num)->Content(); + } if (entity.IsNull()) { - S << " Null" << std::endl; + S << " Null" << '\n'; return; } @@ -193,9 +221,13 @@ void IGESSelect_WorkLibrary::DumpEntity(const occ::handleDynamicType()->Name(); + } else - S << "(undefined)" << std::endl; + { + S << "(undefined)" << '\n'; + } igesent = GetCasted(IGESData_IGESEntity, con); con.Nullify(); occ::handle check = model->ReportEntity(num)->Check(); @@ -203,10 +235,14 @@ void IGESSelect_WorkLibrary::DumpEntity(const occ::handleDynamicType()->Name(); + } IGESData_IGESDumper dump(igesmod, igespro); try @@ -216,6 +252,6 @@ void IGESSelect_WorkLibrary::DumpEntity(const occ::handleLower() != 1 || operations->Lower() != 1 || operands->Length() != operations->Length()) + { throw Standard_DimensionError("IGESSolid_BooleanTree : Init"); + } theOperations = operations; theOperands = operands; @@ -55,7 +57,11 @@ occ::handle IGESSolid_BooleanTree::Operand(const int Index) int IGESSolid_BooleanTree::Operation(const int Index) const { if (theOperands->Value(Index).IsNull()) + { return theOperations->Value(Index); + } else + { return 0; // It is not an operation. (operations can be : 1-2-3) + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ConeFrustum.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ConeFrustum.cxx index 2c7f777876..d16915f4a3 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ConeFrustum.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ConeFrustum.cxx @@ -63,7 +63,9 @@ gp_Pnt IGESSolid_ConeFrustum::FaceCenter() const gp_Pnt IGESSolid_ConeFrustum::TransformedFaceCenter() const { if (!HasTransf()) + { return gp_Pnt(theFaceCenter); + } else { gp_XYZ tmp = theFaceCenter; @@ -80,7 +82,9 @@ gp_Dir IGESSolid_ConeFrustum::Axis() const gp_Dir IGESSolid_ConeFrustum::TransformedAxis() const { if (!HasTransf()) + { return gp_Dir(theAxis); + } else { gp_XYZ xyz = theAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Cylinder.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Cylinder.cxx index 42d546f25e..f4a87211d0 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Cylinder.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Cylinder.cxx @@ -56,7 +56,9 @@ gp_Pnt IGESSolid_Cylinder::FaceCenter() const gp_Pnt IGESSolid_Cylinder::TransformedFaceCenter() const { if (!HasTransf()) + { return gp_Pnt(theFaceCenter); + } else { gp_XYZ tmp = theFaceCenter; @@ -73,7 +75,9 @@ gp_Dir IGESSolid_Cylinder::Axis() const gp_Dir IGESSolid_Cylinder::TransformedAxis() const { if (!HasTransf()) + { return gp_Dir(theAxis); + } else { gp_XYZ tmp = theAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_EdgeList.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_EdgeList.cxx index f1fdeb7b29..ec74b0e7c7 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_EdgeList.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_EdgeList.cxx @@ -39,7 +39,9 @@ void IGESSolid_EdgeList::Init( || startVertexIndex->Length() != nb || endVertexList->Lower() != 1 || endVertexList->Length() != nb || endVertexIndex->Lower() != 1 || endVertexIndex->Length() != nb) + { throw Standard_DimensionError("IGESSolid_EdgeList : Init"); + } theCurves = Curves; theStartVertexList = startVertexList; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Ellipsoid.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Ellipsoid.cxx index 734bdd934d..61c0556173 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Ellipsoid.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Ellipsoid.cxx @@ -66,7 +66,9 @@ gp_Pnt IGESSolid_Ellipsoid::Center() const gp_Pnt IGESSolid_Ellipsoid::TransformedCenter() const { if (!HasTransf()) + { return gp_Pnt(theCenter); + } else { gp_XYZ tmp = theCenter; @@ -83,7 +85,9 @@ gp_Dir IGESSolid_Ellipsoid::XAxis() const gp_Dir IGESSolid_Ellipsoid::TransformedXAxis() const { if (!HasTransf()) + { return gp_Dir(theXAxis); + } else { gp_XYZ tmp = theXAxis; @@ -102,7 +106,9 @@ gp_Dir IGESSolid_Ellipsoid::YAxis() const gp_Dir IGESSolid_Ellipsoid::TransformedYAxis() const { if (!HasTransf()) + { return gp_Dir(theXAxis ^ theZAxis); + } else { gp_XYZ tmp = theXAxis ^ theZAxis; @@ -121,7 +127,9 @@ gp_Dir IGESSolid_Ellipsoid::ZAxis() const gp_Dir IGESSolid_Ellipsoid::TransformedZAxis() const { if (!HasTransf()) + { return gp_Dir(theZAxis); + } else { gp_XYZ tmp = theZAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Face.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Face.cxx index 426eb971ea..453ce7d48a 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Face.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Face.cxx @@ -31,7 +31,9 @@ void IGESSolid_Face::Init( const occ::handle>>& Loops) { if (Loops->Lower() != 1) + { throw Standard_DimensionMismatch("IGESSolid_Face : Init"); + } theSurface = aSurface; hasOuterLoop = OuterLoopFlag; theLoops = Loops; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_GeneralModule.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_GeneralModule.cxx index 92419ba71e..218b66d24d 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_GeneralModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_GeneralModule.cxx @@ -84,7 +84,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBlock tool; tool.OwnShared(anent, iter); } @@ -92,7 +94,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBooleanTree tool; tool.OwnShared(anent, iter); } @@ -100,7 +104,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConeFrustum tool; tool.OwnShared(anent, iter); } @@ -108,7 +114,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConicalSurface tool; tool.OwnShared(anent, iter); } @@ -116,7 +124,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylinder tool; tool.OwnShared(anent, iter); } @@ -124,7 +134,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylindricalSurface tool; tool.OwnShared(anent, iter); } @@ -132,7 +144,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEdgeList tool; tool.OwnShared(anent, iter); } @@ -140,7 +154,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEllipsoid tool; tool.OwnShared(anent, iter); } @@ -148,7 +164,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolFace tool; tool.OwnShared(anent, iter); } @@ -156,7 +174,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolLoop tool; tool.OwnShared(anent, iter); } @@ -164,7 +184,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolManifoldSolid tool; tool.OwnShared(anent, iter); } @@ -172,7 +194,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolPlaneSurface tool; tool.OwnShared(anent, iter); } @@ -180,7 +204,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolRightAngularWedge tool; tool.OwnShared(anent, iter); } @@ -188,7 +214,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSelectedComponent tool; tool.OwnShared(anent, iter); } @@ -196,7 +224,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolShell tool; tool.OwnShared(anent, iter); } @@ -204,7 +234,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidAssembly tool; tool.OwnShared(anent, iter); } @@ -212,7 +244,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidInstance tool; tool.OwnShared(anent, iter); } @@ -220,7 +254,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfLinearExtrusion tool; tool.OwnShared(anent, iter); } @@ -228,7 +264,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfRevolution tool; tool.OwnShared(anent, iter); } @@ -236,7 +274,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphere tool; tool.OwnShared(anent, iter); } @@ -244,7 +284,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphericalSurface tool; tool.OwnShared(anent, iter); } @@ -252,7 +294,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolToroidalSurface tool; tool.OwnShared(anent, iter); } @@ -260,7 +304,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolTorus tool; tool.OwnShared(anent, iter); } @@ -268,7 +314,9 @@ void IGESSolid_GeneralModule::OwnSharedCase(const int case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolVertexList tool; tool.OwnShared(anent, iter); } @@ -287,168 +335,216 @@ IGESData_DirChecker IGESSolid_GeneralModule::DirChecker( case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolBlock tool; return tool.DirChecker(anent); } case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolBooleanTree tool; return tool.DirChecker(anent); } case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolConeFrustum tool; return tool.DirChecker(anent); } case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolConicalSurface tool; return tool.DirChecker(anent); } case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolCylinder tool; return tool.DirChecker(anent); } case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolCylindricalSurface tool; return tool.DirChecker(anent); } case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolEdgeList tool; return tool.DirChecker(anent); } case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolEllipsoid tool; return tool.DirChecker(anent); } case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolFace tool; return tool.DirChecker(anent); } case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolLoop tool; return tool.DirChecker(anent); } case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolManifoldSolid tool; return tool.DirChecker(anent); } case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolPlaneSurface tool; return tool.DirChecker(anent); } case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolRightAngularWedge tool; return tool.DirChecker(anent); } case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSelectedComponent tool; return tool.DirChecker(anent); } case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolShell tool; return tool.DirChecker(anent); } case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSolidAssembly tool; return tool.DirChecker(anent); } case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSolidInstance tool; return tool.DirChecker(anent); } case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSolidOfLinearExtrusion tool; return tool.DirChecker(anent); } case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSolidOfRevolution tool; return tool.DirChecker(anent); } case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSphere tool; return tool.DirChecker(anent); } case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolSphericalSurface tool; return tool.DirChecker(anent); } case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolToroidalSurface tool; return tool.DirChecker(anent); } case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolTorus tool; return tool.DirChecker(anent); } case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { break; + } IGESSolid_ToolVertexList tool; return tool.DirChecker(anent); } @@ -468,7 +564,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBlock tool; tool.OwnCheck(anent, shares, ach); } @@ -476,7 +574,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBooleanTree tool; tool.OwnCheck(anent, shares, ach); } @@ -484,7 +584,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConeFrustum tool; tool.OwnCheck(anent, shares, ach); } @@ -492,7 +594,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConicalSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -500,7 +604,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylinder tool; tool.OwnCheck(anent, shares, ach); } @@ -508,7 +614,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylindricalSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -516,7 +624,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEdgeList tool; tool.OwnCheck(anent, shares, ach); } @@ -524,7 +634,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEllipsoid tool; tool.OwnCheck(anent, shares, ach); } @@ -532,7 +644,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolFace tool; tool.OwnCheck(anent, shares, ach); } @@ -540,7 +654,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolLoop tool; tool.OwnCheck(anent, shares, ach); } @@ -548,7 +664,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolManifoldSolid tool; tool.OwnCheck(anent, shares, ach); } @@ -556,7 +674,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolPlaneSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -564,7 +684,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolRightAngularWedge tool; tool.OwnCheck(anent, shares, ach); } @@ -572,7 +694,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSelectedComponent tool; tool.OwnCheck(anent, shares, ach); } @@ -580,7 +704,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolShell tool; tool.OwnCheck(anent, shares, ach); } @@ -588,7 +714,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidAssembly tool; tool.OwnCheck(anent, shares, ach); } @@ -596,7 +724,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidInstance tool; tool.OwnCheck(anent, shares, ach); } @@ -604,7 +734,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfLinearExtrusion tool; tool.OwnCheck(anent, shares, ach); } @@ -612,7 +744,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfRevolution tool; tool.OwnCheck(anent, shares, ach); } @@ -620,7 +754,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphere tool; tool.OwnCheck(anent, shares, ach); } @@ -628,7 +764,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphericalSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -636,7 +774,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolToroidalSurface tool; tool.OwnCheck(anent, shares, ach); } @@ -644,7 +784,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolTorus tool; tool.OwnCheck(anent, shares, ach); } @@ -652,7 +794,9 @@ void IGESSolid_GeneralModule::OwnCheckCase(const int case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolVertexList tool; tool.OwnCheck(anent, shares, ach); } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Loop.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Loop.cxx index a27528a4bd..7b3572a687 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Loop.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Loop.cxx @@ -46,7 +46,9 @@ void IGESSolid_Loop::Init( || nbParameterCurves->Lower() != 1 || nb != nbParameterCurves->Length() || IsoparametricFlags->Lower() != 1 || nb != IsoparametricFlags->Length() || Curves->Lower() != 1 || nb != Curves->Length()) + { throw Standard_DimensionError("IGESSolid_Loop : Init"); + } theTypes = Types; theEdges = Edges; @@ -73,7 +75,9 @@ int IGESSolid_Loop::NbEdges() const { // pdn 20.04.99 CTS22655 to avoid exceptions on empty loops if (theEdges.IsNull()) + { return 0; + } return theEdges->Length(); } @@ -100,9 +104,13 @@ int IGESSolid_Loop::NbParameterCurves(const int Index) const bool IGESSolid_Loop::IsIsoparametric(const int EdgeIndex, const int CurveIndex) const { if (!theIsoparametricFlags->Value(EdgeIndex).IsNull()) + { return (theIsoparametricFlags->Value(EdgeIndex)->Value(CurveIndex) != 0); + } else + { return false; // must say something + } } occ::handle IGESSolid_Loop::ParametricCurve(const int EdgeIndex, @@ -110,7 +118,9 @@ occ::handle IGESSolid_Loop::ParametricCurve(const int EdgeI { occ::handle acurve; // by default will be null if (!theCurves->Value(EdgeIndex).IsNull()) + { acurve = theCurves->Value(EdgeIndex)->Value(CurveIndex); + } return acurve; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ManifoldSolid.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ManifoldSolid.cxx index 3bcba44e75..d1336d710f 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ManifoldSolid.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ManifoldSolid.cxx @@ -32,9 +32,13 @@ void IGESSolid_ManifoldSolid::Init( const occ::handle>& VoidShellFlags) { if (!VoidShells.IsNull()) + { if (VoidShells->Lower() != 1 || VoidShellFlags->Lower() != 1 || VoidShells->Length() != VoidShellFlags->Length()) + { throw Standard_DimensionError("IGESSolid_ManifoldSolid : Init"); + } + } theShell = aShell; theOrientationFlag = Shellflag; @@ -62,14 +66,20 @@ occ::handle IGESSolid_ManifoldSolid::VoidShell(const int index) { occ::handle ashell; // par defaut sera Null if (!theVoidShells.IsNull()) + { ashell = theVoidShells->Value(index); + } return ashell; } bool IGESSolid_ManifoldSolid::VoidOrientationFlag(const int index) const { if (!theOrientFlags.IsNull()) + { return (theOrientFlags->Value(index) != 0); + } else + { return false; // pour retourner qqchose ... + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Protocol.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Protocol.cxx index 12e4991e7e..c2c2df321c 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Protocol.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Protocol.cxx @@ -59,52 +59,100 @@ occ::handle IGESSolid_Protocol::Resource(const int /*num*/) int IGESSolid_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(IGESSolid_Block)) + { return 1; + } else if (atype == STANDARD_TYPE(IGESSolid_BooleanTree)) + { return 2; + } else if (atype == STANDARD_TYPE(IGESSolid_ConeFrustum)) + { return 3; + } else if (atype == STANDARD_TYPE(IGESSolid_ConicalSurface)) + { return 4; + } else if (atype == STANDARD_TYPE(IGESSolid_Cylinder)) + { return 5; + } else if (atype == STANDARD_TYPE(IGESSolid_CylindricalSurface)) + { return 6; + } else if (atype == STANDARD_TYPE(IGESSolid_EdgeList)) + { return 7; + } else if (atype == STANDARD_TYPE(IGESSolid_Ellipsoid)) + { return 8; + } else if (atype == STANDARD_TYPE(IGESSolid_Face)) + { return 9; + } else if (atype == STANDARD_TYPE(IGESSolid_Loop)) + { return 10; + } else if (atype == STANDARD_TYPE(IGESSolid_ManifoldSolid)) + { return 11; + } else if (atype == STANDARD_TYPE(IGESSolid_PlaneSurface)) + { return 12; + } else if (atype == STANDARD_TYPE(IGESSolid_RightAngularWedge)) + { return 13; + } else if (atype == STANDARD_TYPE(IGESSolid_SelectedComponent)) + { return 14; + } else if (atype == STANDARD_TYPE(IGESSolid_Shell)) + { return 15; + } else if (atype == STANDARD_TYPE(IGESSolid_SolidAssembly)) + { return 16; + } else if (atype == STANDARD_TYPE(IGESSolid_SolidInstance)) + { return 17; + } else if (atype == STANDARD_TYPE(IGESSolid_SolidOfLinearExtrusion)) + { return 18; + } else if (atype == STANDARD_TYPE(IGESSolid_SolidOfRevolution)) + { return 19; + } else if (atype == STANDARD_TYPE(IGESSolid_Sphere)) + { return 20; + } else if (atype == STANDARD_TYPE(IGESSolid_SphericalSurface)) + { return 21; + } else if (atype == STANDARD_TYPE(IGESSolid_ToroidalSurface)) + { return 22; + } else if (atype == STANDARD_TYPE(IGESSolid_Torus)) + { return 23; + } else if (atype == STANDARD_TYPE(IGESSolid_VertexList)) + { return 24; + } return 0; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ReadWriteModule.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ReadWriteModule.cxx index a701386dd7..c3ea17a1dd 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ReadWriteModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ReadWriteModule.cxx @@ -139,7 +139,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBlock tool; tool.ReadOwnParams(anent, IR, PR); } @@ -147,7 +149,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBooleanTree tool; tool.ReadOwnParams(anent, IR, PR); } @@ -155,7 +159,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConeFrustum tool; tool.ReadOwnParams(anent, IR, PR); } @@ -163,7 +169,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConicalSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -171,7 +179,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylinder tool; tool.ReadOwnParams(anent, IR, PR); } @@ -179,7 +189,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylindricalSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -187,7 +199,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEdgeList tool; tool.ReadOwnParams(anent, IR, PR); } @@ -195,7 +209,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEllipsoid tool; tool.ReadOwnParams(anent, IR, PR); } @@ -203,7 +219,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolFace tool; tool.ReadOwnParams(anent, IR, PR); } @@ -211,7 +229,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolLoop tool; tool.ReadOwnParams(anent, IR, PR); } @@ -219,7 +239,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolManifoldSolid tool; tool.ReadOwnParams(anent, IR, PR); } @@ -227,7 +249,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolPlaneSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -235,7 +259,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolRightAngularWedge tool; tool.ReadOwnParams(anent, IR, PR); } @@ -243,7 +269,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSelectedComponent tool; tool.ReadOwnParams(anent, IR, PR); } @@ -251,7 +279,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolShell tool; tool.ReadOwnParams(anent, IR, PR); } @@ -259,7 +289,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidAssembly tool; tool.ReadOwnParams(anent, IR, PR); } @@ -267,7 +299,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidInstance tool; tool.ReadOwnParams(anent, IR, PR); } @@ -275,7 +309,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfLinearExtrusion tool; tool.ReadOwnParams(anent, IR, PR); } @@ -283,7 +319,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfRevolution tool; tool.ReadOwnParams(anent, IR, PR); } @@ -291,7 +329,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphere tool; tool.ReadOwnParams(anent, IR, PR); } @@ -299,7 +339,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphericalSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -307,7 +349,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolToroidalSurface tool; tool.ReadOwnParams(anent, IR, PR); } @@ -315,7 +359,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolTorus tool; tool.ReadOwnParams(anent, IR, PR); } @@ -323,7 +369,9 @@ void IGESSolid_ReadWriteModule::ReadOwnParams(const int case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolVertexList tool; tool.ReadOwnParams(anent, IR, PR); } @@ -342,7 +390,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBlock tool; tool.WriteOwnParams(anent, IW); } @@ -350,7 +400,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBooleanTree tool; tool.WriteOwnParams(anent, IW); } @@ -358,7 +410,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConeFrustum tool; tool.WriteOwnParams(anent, IW); } @@ -366,7 +420,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConicalSurface tool; tool.WriteOwnParams(anent, IW); } @@ -374,7 +430,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylinder tool; tool.WriteOwnParams(anent, IW); } @@ -382,7 +440,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylindricalSurface tool; tool.WriteOwnParams(anent, IW); } @@ -390,7 +450,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEdgeList tool; tool.WriteOwnParams(anent, IW); } @@ -398,7 +460,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEllipsoid tool; tool.WriteOwnParams(anent, IW); } @@ -406,7 +470,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolFace tool; tool.WriteOwnParams(anent, IW); } @@ -414,7 +480,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolLoop tool; tool.WriteOwnParams(anent, IW); } @@ -422,7 +490,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolManifoldSolid tool; tool.WriteOwnParams(anent, IW); } @@ -430,7 +500,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolPlaneSurface tool; tool.WriteOwnParams(anent, IW); } @@ -438,7 +510,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolRightAngularWedge tool; tool.WriteOwnParams(anent, IW); } @@ -446,7 +520,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSelectedComponent tool; tool.WriteOwnParams(anent, IW); } @@ -454,7 +530,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolShell tool; tool.WriteOwnParams(anent, IW); } @@ -462,7 +540,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidAssembly tool; tool.WriteOwnParams(anent, IW); } @@ -470,7 +550,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidInstance tool; tool.WriteOwnParams(anent, IW); } @@ -478,7 +560,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfLinearExtrusion tool; tool.WriteOwnParams(anent, IW); } @@ -486,7 +570,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfRevolution tool; tool.WriteOwnParams(anent, IW); } @@ -494,7 +580,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphere tool; tool.WriteOwnParams(anent, IW); } @@ -502,7 +590,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphericalSurface tool; tool.WriteOwnParams(anent, IW); } @@ -510,7 +600,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolToroidalSurface tool; tool.WriteOwnParams(anent, IW); } @@ -518,7 +610,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolTorus tool; tool.WriteOwnParams(anent, IW); } @@ -526,7 +620,9 @@ void IGESSolid_ReadWriteModule::WriteOwnParams(const int case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolVertexList tool; tool.WriteOwnParams(anent, IW); } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_RightAngularWedge.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_RightAngularWedge.cxx index 1c3afa4704..afaa046cfe 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_RightAngularWedge.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_RightAngularWedge.cxx @@ -73,7 +73,9 @@ gp_Pnt IGESSolid_RightAngularWedge::Corner() const gp_Pnt IGESSolid_RightAngularWedge::TransformedCorner() const { if (!HasTransf()) + { return gp_Pnt(theCorner); + } else { gp_XYZ tmp = theCorner; @@ -90,7 +92,9 @@ gp_Dir IGESSolid_RightAngularWedge::XAxis() const gp_Dir IGESSolid_RightAngularWedge::TransformedXAxis() const { if (!HasTransf()) + { return gp_Dir(theXAxis); + } else { gp_XYZ tmp = theXAxis; @@ -109,7 +113,9 @@ gp_Dir IGESSolid_RightAngularWedge::YAxis() const gp_Dir IGESSolid_RightAngularWedge::TransformedYAxis() const { if (!HasTransf()) + { return gp_Dir(theXAxis ^ theZAxis); + } else { gp_XYZ tmp = theXAxis ^ theZAxis; @@ -128,7 +134,9 @@ gp_Dir IGESSolid_RightAngularWedge::ZAxis() const gp_Dir IGESSolid_RightAngularWedge::TransformedZAxis() const { if (!HasTransf()) + { return gp_Dir(theZAxis); + } else { gp_XYZ tmp = theZAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SelectedComponent.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SelectedComponent.cxx index f0292cdbb8..617925b854 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SelectedComponent.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SelectedComponent.cxx @@ -48,7 +48,9 @@ gp_Pnt IGESSolid_SelectedComponent::SelectPoint() const gp_Pnt IGESSolid_SelectedComponent::TransformedSelectPoint() const { if (!HasTransf()) + { return gp_Pnt(theSelectPoint); + } else { gp_XYZ tmp = theSelectPoint; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Shell.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Shell.cxx index 273140eabc..42671ac2bf 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Shell.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Shell.cxx @@ -29,7 +29,9 @@ void IGESSolid_Shell::Init( const occ::handle>& Orient) { if (Faces->Lower() != 1 || Orient->Lower() != 1 || Faces->Length() != Orient->Length()) + { throw Standard_DimensionError("IGESSolid_Shell : Init"); + } theFaces = Faces; theOrientation = Orient; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidAssembly.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidAssembly.cxx index d2f97aeb28..19969a2dec 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidAssembly.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidAssembly.cxx @@ -29,7 +29,9 @@ void IGESSolid_SolidAssembly::Init( const occ::handle>>& Matrices) { if (Items->Lower() != 1 || Matrices->Lower() != 1 || Items->Length() != Matrices->Length()) + { throw Standard_DimensionError("IGESSolid_SolidAssembly : Init"); + } theItems = Items; theMatrices = Matrices; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfLinearExtrusion.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfLinearExtrusion.cxx index a24a81c6dd..97b7661726 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfLinearExtrusion.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfLinearExtrusion.cxx @@ -53,7 +53,9 @@ gp_Dir IGESSolid_SolidOfLinearExtrusion::ExtrusionDirection() const gp_Dir IGESSolid_SolidOfLinearExtrusion::TransformedExtrusionDirection() const { if (!HasTransf()) + { return gp_Dir(theDirection); + } else { gp_XYZ tmp = theDirection; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfRevolution.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfRevolution.cxx index 58ad544c18..a1bb983662 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfRevolution.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SolidOfRevolution.cxx @@ -67,7 +67,9 @@ gp_Pnt IGESSolid_SolidOfRevolution::AxisPoint() const gp_Pnt IGESSolid_SolidOfRevolution::TransformedAxisPoint() const { if (!HasTransf()) + { return gp_Pnt(theAxisPoint); + } else { gp_XYZ tmp = theAxisPoint; @@ -84,7 +86,9 @@ gp_Dir IGESSolid_SolidOfRevolution::Axis() const gp_Dir IGESSolid_SolidOfRevolution::TransformedAxis() const { if (!HasTransf()) + { return gp_Dir(theAxis); + } else { gp_XYZ tmp = theAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SpecificModule.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SpecificModule.cxx index 53c24396a8..433b56f512 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SpecificModule.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SpecificModule.cxx @@ -80,7 +80,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 1: { DeclareAndCast(IGESSolid_Block, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBlock tool; tool.OwnDump(anent, dumper, S, own); } @@ -88,7 +90,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 2: { DeclareAndCast(IGESSolid_BooleanTree, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolBooleanTree tool; tool.OwnDump(anent, dumper, S, own); } @@ -96,7 +100,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 3: { DeclareAndCast(IGESSolid_ConeFrustum, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConeFrustum tool; tool.OwnDump(anent, dumper, S, own); } @@ -104,7 +110,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 4: { DeclareAndCast(IGESSolid_ConicalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolConicalSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -112,7 +120,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 5: { DeclareAndCast(IGESSolid_Cylinder, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylinder tool; tool.OwnDump(anent, dumper, S, own); } @@ -120,7 +130,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 6: { DeclareAndCast(IGESSolid_CylindricalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolCylindricalSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -128,7 +140,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 7: { DeclareAndCast(IGESSolid_EdgeList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEdgeList tool; tool.OwnDump(anent, dumper, S, own); } @@ -136,7 +150,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 8: { DeclareAndCast(IGESSolid_Ellipsoid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolEllipsoid tool; tool.OwnDump(anent, dumper, S, own); } @@ -144,7 +160,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 9: { DeclareAndCast(IGESSolid_Face, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolFace tool; tool.OwnDump(anent, dumper, S, own); } @@ -152,7 +170,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 10: { DeclareAndCast(IGESSolid_Loop, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolLoop tool; tool.OwnDump(anent, dumper, S, own); } @@ -160,7 +180,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 11: { DeclareAndCast(IGESSolid_ManifoldSolid, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolManifoldSolid tool; tool.OwnDump(anent, dumper, S, own); } @@ -168,7 +190,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 12: { DeclareAndCast(IGESSolid_PlaneSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolPlaneSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -176,7 +200,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 13: { DeclareAndCast(IGESSolid_RightAngularWedge, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolRightAngularWedge tool; tool.OwnDump(anent, dumper, S, own); } @@ -184,7 +210,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 14: { DeclareAndCast(IGESSolid_SelectedComponent, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSelectedComponent tool; tool.OwnDump(anent, dumper, S, own); } @@ -192,7 +220,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 15: { DeclareAndCast(IGESSolid_Shell, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolShell tool; tool.OwnDump(anent, dumper, S, own); } @@ -200,7 +230,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 16: { DeclareAndCast(IGESSolid_SolidAssembly, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidAssembly tool; tool.OwnDump(anent, dumper, S, own); } @@ -208,7 +240,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 17: { DeclareAndCast(IGESSolid_SolidInstance, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidInstance tool; tool.OwnDump(anent, dumper, S, own); } @@ -216,7 +250,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 18: { DeclareAndCast(IGESSolid_SolidOfLinearExtrusion, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfLinearExtrusion tool; tool.OwnDump(anent, dumper, S, own); } @@ -224,7 +260,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 19: { DeclareAndCast(IGESSolid_SolidOfRevolution, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSolidOfRevolution tool; tool.OwnDump(anent, dumper, S, own); } @@ -232,7 +270,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 20: { DeclareAndCast(IGESSolid_Sphere, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphere tool; tool.OwnDump(anent, dumper, S, own); } @@ -240,7 +280,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 21: { DeclareAndCast(IGESSolid_SphericalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolSphericalSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -248,7 +290,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 22: { DeclareAndCast(IGESSolid_ToroidalSurface, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolToroidalSurface tool; tool.OwnDump(anent, dumper, S, own); } @@ -256,7 +300,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 23: { DeclareAndCast(IGESSolid_Torus, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolTorus tool; tool.OwnDump(anent, dumper, S, own); } @@ -264,7 +310,9 @@ void IGESSolid_SpecificModule::OwnDump(const int C case 24: { DeclareAndCast(IGESSolid_VertexList, anent, ent); if (anent.IsNull()) + { return; + } IGESSolid_ToolVertexList tool; tool.OwnDump(anent, dumper, S, own); } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Sphere.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Sphere.cxx index 4a518cebbb..3410fc213b 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Sphere.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Sphere.cxx @@ -46,7 +46,9 @@ gp_Pnt IGESSolid_Sphere::Center() const gp_Pnt IGESSolid_Sphere::TransformedCenter() const { if (!HasTransf()) + { return gp_Pnt(theCenter); + } else { gp_XYZ tmp = theCenter; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SphericalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SphericalSurface.cxx index cdf5ee327f..d49d2cb770 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SphericalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_SphericalSurface.cxx @@ -47,7 +47,9 @@ occ::handle IGESSolid_SphericalSurface::Center() const gp_Pnt IGESSolid_SphericalSurface::TransformedCenter() const { if (!HasTransf()) + { return theCenter->Value(); + } else { gp_XYZ tmp = (theCenter->Value()).XYZ(); diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBlock.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBlock.cxx index 317b06071b..49c8c32e73 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBlock.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBlock.cxx @@ -53,98 +53,138 @@ void IGESSolid_ToolBlock::ReadOwnParams(const occ::handle& ent, // st = PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal)) + { tempCorner.SetX(tempreal); + } } else + { tempCorner.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal)) + { tempCorner.SetY(tempreal); + } } else + { tempCorner.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal)) + { tempCorner.SetZ(tempreal); + } } else + { tempCorner.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal)) + { tempXAxis.SetX(tempreal); + } } else + { tempXAxis.SetX(1.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal)) + { tempXAxis.SetY(tempreal); + } } else + { tempXAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal)) + { tempXAxis.SetZ(tempreal); + } } else + { tempXAxis.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal)) + { tempZAxis.SetX(tempreal); + } } else + { tempZAxis.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal)) + { tempZAxis.SetY(tempreal); + } } else + { tempZAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal)) + { tempZAxis.SetZ(tempreal); + } } else + { tempZAxis.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempSize, tempCorner, tempXAxis, tempZAxis); double eps = 1.E-05; if (!tempXAxis.IsEqual(ent->XAxis().XYZ(), eps)) + { PR.AddWarning("XAxis poorly unitary, normalized"); + } if (!tempZAxis.IsEqual(ent->ZAxis().XYZ(), eps)) + { PR.AddWarning("ZAxis poorly unitary, normalized"); + } } void IGESSolid_ToolBlock::WriteOwnParams(const occ::handle& ent, @@ -198,9 +238,13 @@ void IGESSolid_ToolBlock::OwnCheck(const occ::handle& ent, double eps = 1.E-04; double prosca = ent->XAxis() * ent->ZAxis(); if (prosca < -eps || prosca > eps) + { ach->AddFail("Local Z axis : Not orthogonal to X axis"); + } if (ent->Size().X() <= 0. || ent->Size().Y() <= 0. || ent->Size().Z() <= 0.) + { ach->AddFail("Size : Not positive lengths"); + } } void IGESSolid_ToolBlock::OwnDump(const occ::handle& ent, @@ -217,5 +261,5 @@ void IGESSolid_ToolBlock::OwnDump(const occ::handle& ent, IGESData_DumpXYZL(S, level, ent->XAxis(), ent->VectorLocation()); S << "\nZAxis : "; IGESData_DumpXYZL(S, level, ent->ZAxis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBooleanTree.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBooleanTree.cxx index 1bfe341337..77c87039a2 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBooleanTree.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolBooleanTree.cxx @@ -59,12 +59,16 @@ void IGESSolid_ToolBooleanTree::ReadOwnParams(const occ::handleSetValue(1, entvalue); + } // st = PR.ReadEntity(IR, PR.Current(), "Operand 2", entvalue); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadEntity(IR, PR.Current(), "Operand 2", entvalue)) + { tempOperands->SetValue(2, entvalue); + } // Op. 3 -> length-1 : Operand or Operation for (int i = 3; i < length; i++) @@ -77,21 +81,31 @@ void IGESSolid_ToolBooleanTree::ReadOwnParams(const occ::handleSetValue(i, entvalue); + } } else + { tempOperations->SetValue(i, intvalue); + } } // Last Op. : Operation // st = PR.ReadInteger(PR.Current(), "Operation code", intvalue); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadInteger(PR.Current(), "Operation code", intvalue)) + { tempOperations->SetValue(length, intvalue); + } } else + { PR.AddFail("Length of post-order : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempOperands, tempOperations); @@ -106,9 +120,13 @@ void IGESSolid_ToolBooleanTree::WriteOwnParams(const occ::handleIsOperand(i)) + { IW.Send(ent->Operand(i), true); + } else + { IW.Send(ent->Operation(i)); + } } } @@ -119,7 +137,9 @@ void IGESSolid_ToolBooleanTree::OwnShared(const occ::handleIsOperand(i)) + { iter.GetOneItem(ent->Operand(i)); + } } } @@ -141,8 +161,10 @@ void IGESSolid_ToolBooleanTree::OwnCopy(const occ::handle DeclareAndCast(IGESData_IGESEntity, new_ent, TC.Transferred(another->Operand(i))); tempOperands->SetValue(i, new_ent); } - else // Operation + else + { // Operation tempOperations->SetValue(i, another->Operation(i)); + } } ent->Init(tempOperands, tempOperations); } @@ -166,20 +188,30 @@ void IGESSolid_ToolBooleanTree::OwnCheck(const occ::handleLength(); if (length <= 2) + { ach->AddFail("Length of post-order notation : Less than three"); + } else { if (!ent->IsOperand(1)) + { ach->AddFail("First Item is not an Operand"); + } if (!ent->IsOperand(2)) + { ach->AddFail("Second Item is not an Operand"); + } if (ent->IsOperand(length)) + { ach->AddFail("Last Item is not an Operation"); + } } for (int i = 1; i <= length; i++) { if (!ent->Operand(i).IsNull()) + { continue; + } if (ent->Operation(i) < 1 || ent->Operation(i) > 3) { char mess[80]; @@ -214,13 +246,21 @@ void IGESSolid_ToolBooleanTree::OwnDump(const occ::handle int opcode = ent->Operation(i); S << "[" << i << "] Operator : " << opcode; if (opcode == 1) + { S << " (Union)"; + } else if (opcode == 2) + { S << " (Intersection)\n"; + } else if (opcode == 3) + { S << " (Difference)\n"; + } else + { S << " (incorrect value)\n"; + } } } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConeFrustum.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConeFrustum.cxx index 1ee0afffdc..7aac6282ca 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConeFrustum.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConeFrustum.cxx @@ -49,77 +49,107 @@ void IGESSolid_ToolConeFrustum::ReadOwnParams(const occ::handleInit(tempHeight, tempR1, tempR2, tempCenter, tempAxis); double eps = 1.E-05; if (!tempAxis.IsEqual(ent->Axis().XYZ(), eps)) + { PR.AddWarning("Axis poorly unitary, normalized"); + } } void IGESSolid_ToolConeFrustum::WriteOwnParams(const occ::handle& ent, @@ -171,13 +201,21 @@ void IGESSolid_ToolConeFrustum::OwnCheck(const occ::handle& ach) const { if (ent->Height() <= 0.0) + { ach->AddFail("Height : Value Not Positive"); + } if (ent->LargerRadius() <= 0.0) + { ach->AddFail("Larger face radius : Value Not Positive"); + } if (ent->SmallerRadius() < 0.0) + { ach->AddFail("Smaller face radius : Value Not Positive"); + } if (ent->SmallerRadius() > ent->LargerRadius()) + { ach->AddFail("Smaller face radius : is greater than Larger face radius"); + } } void IGESSolid_ToolConeFrustum::OwnDump(const occ::handle& ent, @@ -193,5 +231,5 @@ void IGESSolid_ToolConeFrustum::OwnDump(const occ::handle IGESData_DumpXYZL(S, level, ent->FaceCenter(), ent->Location()); S << "\nAxis : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConicalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConicalSurface.cxx index 1a869edd42..d08c87dbb7 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConicalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolConicalSurface.cxx @@ -59,12 +59,14 @@ void IGESSolid_ToolConicalSurface::ReadOwnParams(const occ::handleFormNumber() == 1) // Parametrised surface + if (ent->FormNumber() == 1) + { // Parametrised surface PR.ReadEntity(IR, PR.Current(), "Reference direction", STANDARD_TYPE(IGESGeom_Direction), tempRefdir); // szv#4:S4163:12Mar99 `st=` not needed + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempLocation, tempAxis, tempRadius, tempAngle, tempRefdir); @@ -78,7 +80,9 @@ void IGESSolid_ToolConicalSurface::WriteOwnParams(const occ::handleRadius()); IW.Send(ent->SemiAngle()); if (ent->IsParametrised()) + { IW.Send(ent->ReferenceDir()); // see FormNumber + } } void IGESSolid_ToolConicalSurface::OwnShared(const occ::handle& ent, @@ -132,14 +136,22 @@ void IGESSolid_ToolConicalSurface::OwnCheck(const occ::handle& ach) const { if (ent->Radius() < 0.0) + { ach->AddFail("Radius : Value Negative"); + } if (ent->SemiAngle() < 0.0 || ent->SemiAngle() > 90.0) + { ach->AddFail("Semi-angle : Value not in the range [0 - 90]"); + } int fn = 0; if (ent->IsParametrised()) + { fn = 1; + } if (fn != ent->FormNumber()) + { ach->AddFail("Parametrised Status Mismatches with Form Number"); + } } void IGESSolid_ToolConicalSurface::OwnDump(const occ::handle& ent, @@ -162,8 +174,10 @@ void IGESSolid_ToolConicalSurface::OwnDump(const occ::handleReferenceDir(), S, sublevel); - S << std::endl; + S << '\n'; } else - S << "Surface is UnParametrised" << std::endl; + { + S << "Surface is UnParametrised" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylinder.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylinder.cxx index a9b3bb3b8a..fe59ef5457 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylinder.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylinder.cxx @@ -52,66 +52,92 @@ void IGESSolid_ToolCylinder::ReadOwnParams(const occ::handle // st = PR.ReadReal(PR.Current(), "Face center (X)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Face center (X)", tempreal)) + { tempCenter.SetX(tempreal); + } } else + { tempCenter.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Face center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Face center (Y)", tempreal)) + { tempCenter.SetY(tempreal); + } } else + { tempCenter.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Face center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Face center (Z)", tempreal)) + { tempCenter.SetZ(tempreal); + } } else + { tempCenter.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal)) + { tempAxis.SetX(tempreal); + } } else + { tempAxis.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal)) + { tempAxis.SetY(tempreal); + } } else + { tempAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal)) + { tempAxis.SetZ(tempreal); + } } else + { tempAxis.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempHeight, tempRadius, tempCenter, tempAxis); double eps = 1.E-05; if (!tempAxis.IsEqual(ent->Axis().XYZ(), eps)) + { PR.AddWarning("Axis poorly unitary, normalized"); + } } void IGESSolid_ToolCylinder::WriteOwnParams(const occ::handle& ent, @@ -161,9 +187,13 @@ void IGESSolid_ToolCylinder::OwnCheck(const occ::handle& ent occ::handle& ach) const { if (ent->Height() <= 0.0) + { ach->AddFail("Height : Value < 0"); + } if (ent->Radius() <= 0.0) + { ach->AddFail("Radius : Value < 0"); + } } void IGESSolid_ToolCylinder::OwnDump(const occ::handle& ent, @@ -183,5 +213,5 @@ void IGESSolid_ToolCylinder::OwnDump(const occ::handle& ent, IGESData_DumpXYZL(S, level, ent->FaceCenter(), ent->Location()); S << "\nAxis : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylindricalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylindricalSurface.cxx index bc25e8aa18..d4fb322959 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylindricalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolCylindricalSurface.cxx @@ -58,12 +58,14 @@ void IGESSolid_ToolCylindricalSurface::ReadOwnParams( PR.ReadReal(PR.Current(), "Radius", tempRadius); // szv#4:S4163:12Mar99 `st=` not needed - if (ent->FormNumber() == 1) // Parametrised surface + if (ent->FormNumber() == 1) + { // Parametrised surface PR.ReadEntity(IR, PR.Current(), "Reference direction", STANDARD_TYPE(IGESGeom_Direction), tempRefdir); // szv#4:S4163:12Mar99 `st=` not needed + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempLocation, tempAxis, tempRadius, tempRefdir); @@ -77,7 +79,9 @@ void IGESSolid_ToolCylindricalSurface::WriteOwnParams( IW.Send(ent->Axis()); IW.Send(ent->Radius()); if (ent->IsParametrised()) + { IW.Send(ent->ReferenceDir()); + } } void IGESSolid_ToolCylindricalSurface::OwnShared( @@ -132,12 +136,18 @@ void IGESSolid_ToolCylindricalSurface::OwnCheck( occ::handle& ach) const { if (ent->Radius() <= 0.0) + { ach->AddFail("Radius : Value <= 0.0"); + } int fn = 0; if (ent->IsParametrised()) + { fn = 1; + } if (fn != ent->FormNumber()) + { ach->AddFail("Parametrised Status Mismatches with Form Number"); + } } void IGESSolid_ToolCylindricalSurface::OwnDump(const occ::handle& ent, @@ -159,8 +169,10 @@ void IGESSolid_ToolCylindricalSurface::OwnDump(const occ::handleReferenceDir(), S, sublevel); - S << std::endl; + S << '\n'; } else - S << "Surface is UnParametrised" << std::endl; + { + S << "Surface is UnParametrised" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEdgeList.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEdgeList.cxx index 1044bfed0d..e253d931e9 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEdgeList.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEdgeList.cxx @@ -80,7 +80,9 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle // st = PR.ReadEntity(IR, PR.Current(), Msg185, anent); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadEntity(IR, PR.Current(), "Model space curve", anent); if (PR.ReadEntity(IR, PR.Current(), aStatus, anent)) + { tempCurves->SetValue(i, anent); + } else { Message_Msg Msg185("XSTEP_185"); @@ -110,7 +112,9 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle STANDARD_TYPE(IGESSolid_VertexList), avert); */ if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert)) + { tempStartVertexList->SetValue(i, avert); + } else { Message_Msg Msg188("XSTEP_188"); @@ -143,7 +147,9 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle // st = PR.ReadInteger(PR.Current(), Msg186, anint); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadInteger(PR.Current(), "Start vertex index", anint); if (PR.ReadInteger(PR.Current(), anint)) + { tempStartVertexIndex->SetValue(i, anint); + } else { Message_Msg Msg186("XSTEP_186"); @@ -158,7 +164,9 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle STANDARD_TYPE(IGESSolid_VertexList), avert); */ if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert)) + { tempEndVertexList->SetValue(i, avert); + } else { Message_Msg Msg189("XSTEP_189"); @@ -190,7 +198,9 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle // st = PR.ReadInteger(PR.Current(), Msg187, anint); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadInteger(PR.Current(), "End vertex index", anint); if (PR.ReadInteger(PR.Current(), anint)) + { tempEndVertexIndex->SetValue(i, anint); + } else { Message_Msg Msg187("XSTEP_187"); @@ -206,11 +216,13 @@ void IGESSolid_ToolEdgeList::ReadOwnParams(const occ::handle } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); if (length > 0) + { ent->Init(tempCurves, tempStartVertexList, tempStartVertexIndex, tempEndVertexList, tempEndVertexIndex); + } } //================================================================================================= @@ -371,5 +383,5 @@ void IGESSolid_ToolEdgeList::OwnDump(const occ::handle& ent, default: break; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEllipsoid.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEllipsoid.cxx index 0683e88387..b06ea0b16e 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEllipsoid.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolEllipsoid.cxx @@ -51,98 +51,138 @@ void IGESSolid_ToolEllipsoid::ReadOwnParams(const occ::handleInit(tempSize, tempCenter, tempXAxis, tempZAxis); double eps = 1.E-05; if (!tempXAxis.IsEqual(ent->XAxis().XYZ(), eps)) + { PR.AddWarning("XAxis poorly unitary, normalized"); + } if (!tempZAxis.IsEqual(ent->ZAxis().XYZ(), eps)) + { PR.AddWarning("ZAxis poorly unitary, normalized"); + } } void IGESSolid_ToolEllipsoid::WriteOwnParams(const occ::handle& ent, @@ -197,10 +237,14 @@ void IGESSolid_ToolEllipsoid::OwnCheck(const occ::handle& e double eps = 1.E-04; double prosca = ent->XAxis().Dot(ent->ZAxis()); if (prosca < -eps || prosca > eps) + { ach->AddFail("Local Z axis : Not orthogonal to X axis"); + } if (ent->Size().X() < ent->Size().Y() || ent->Size().Y() < ent->Size().Z() || ent->Size().Z() <= 0) + { ach->AddFail("Size : The values does not satisfy LX >= LY >= LZ > 0"); + } } void IGESSolid_ToolEllipsoid::OwnDump(const occ::handle& ent, @@ -217,5 +261,5 @@ void IGESSolid_ToolEllipsoid::OwnDump(const occ::handle& en IGESData_DumpXYZL(S, level, ent->XAxis(), ent->VectorLocation()); S << "\nZAxis : "; IGESData_DumpXYZL(S, level, ent->ZAxis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolFace.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolFace.cxx index 24505e980f..434273dd62 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolFace.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolFace.cxx @@ -93,9 +93,13 @@ void IGESSolid_ToolFace::ReadOwnParams(const occ::handle& st = PR.ReadInteger(PR.Current(), "Number of loops", nbloops); */ if (st && nbloops > 0) + { tempLoops = new NCollection_HArray1>(1, nbloops); + } else + { PR.SendFail(Msg197); + } PR.ReadBoolean(PR.Current(), Msg198, outerLoopFlag); // szv#4:S4163:12Mar99 `st=` not needed // st = PR.ReadBoolean(PR.Current(), "Outer loop flag", outerLoopFlag); @@ -108,7 +112,9 @@ void IGESSolid_ToolFace::ReadOwnParams(const occ::handle& // //szv#4:S4163:12Mar99 moved in if st = PR.ReadEntity(IR, PR.Current(), "Loops", // STANDARD_TYPE(IGESSolid_Loop), aloop); if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Loop), aloop)) + { tempLoops->SetValue(i, aloop); + } else { Message_Msg Msg199("XSTEP_199"); @@ -152,7 +158,9 @@ void IGESSolid_ToolFace::WriteOwnParams(const occ::handle& ent, IW.Send(upper); IW.SendBoolean(ent->HasOuterLoop()); for (int i = 1; i <= upper; i++) + { IW.Send(ent->Loop(i)); + } } //================================================================================================= @@ -163,7 +171,9 @@ void IGESSolid_ToolFace::OwnShared(const occ::handle& ent, int upper = ent->NbLoops(); iter.GetOneItem(ent->Surface()); for (int i = 1; i <= upper; i++) + { iter.GetOneItem(ent->Loop(i)); + } } //================================================================================================= @@ -236,10 +246,14 @@ void IGESSolid_ToolFace::OwnDump(const occ::handle& ent, dumper.Dump(ent->Surface(), S, sublevel); S << "\n"; if (ent->HasOuterLoop()) + { S << "Outer loop is present (First one)\n"; + } else + { S << "Outer loop is not present\n"; + } S << "Loops : "; IGESData_DumpEntities(S, dumper, level, 1, ent->NbLoops(), ent->Loop); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolLoop.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolLoop.cxx index ba4a07209e..f17a46be76 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolLoop.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolLoop.cxx @@ -93,9 +93,13 @@ void IGESSolid_ToolLoop::ReadOwnParams(const occ::handle& // st = PR.ReadInteger(PR.Current(), Msg190, anint); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadInteger(PR.Current(), "Edge types", anint); if (PR.ReadInteger(PR.Current(), anint)) + { tempTypes->SetValue(i, anint); + } else + { PR.SendFail(Msg190); + } if (!PR.ReadEntity(IR, PR.Current(), aStatus, anent)) { // szv#4:S4163:12Mar99 `st=` not needed @@ -122,14 +126,20 @@ void IGESSolid_ToolLoop::ReadOwnParams(const occ::handle& // if (!st) { } // WARNING : Two possible Types : //szv#4:S4163:12Mar99 not needed if (!anent->IsKind(STANDARD_TYPE(IGESSolid_VertexList)) && !anent->IsKind(STANDARD_TYPE(IGESSolid_EdgeList))) + { PR.SendFail(Msg190); + } else + { tempEdges->SetValue(i, anent); + } // st = PR.ReadInteger(PR.Current(), Msg191, anint); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadInteger(PR.Current(), "List index", anint); if (PR.ReadInteger(PR.Current(), anint)) + { tempIndex->SetValue(i, anint); + } else { Message_Msg Msg191("XSTEP_191"); @@ -139,7 +149,9 @@ void IGESSolid_ToolLoop::ReadOwnParams(const occ::handle& // st = PR.ReadBoolean(PR.Current(), Msg180, abool); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadBoolean(PR.Current(), "Orientation flags", abool); if (PR.ReadBoolean(PR.Current(), Msg180, abool)) + { tempOrientation->SetValue(i, (abool ? 1 : 0)); // bool; + } bool st = PR.ReadInteger(PR.Current(), anint); if (!st) @@ -160,12 +172,16 @@ void IGESSolid_ToolLoop::ReadOwnParams(const occ::handle& // st = PR.ReadBoolean(PR.Current(), Msg195, abool); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadBoolean(PR.Current(), "Isoparametric flags", abool); if (PR.ReadBoolean(PR.Current(), Msg195, abool)) + { tmpints->SetValue(j, (abool ? 1 : 0)); // bool; + } // st = PR.ReadEntity(IR, PR.Current(), Msg194, anent); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadEntity(IR, PR.Current(), "Curves", anent); if (PR.ReadEntity(IR, PR.Current(), aStatus, anent)) + { tmpents->SetValue(j, anent); + } else { Message_Msg Msg194("XSTEP_194"); @@ -192,7 +208,9 @@ void IGESSolid_ToolLoop::ReadOwnParams(const occ::handle& tempCurves->SetValue(i, tmpents); } else + { nbParameterCurves->SetValue(i, anint); + } } } else @@ -249,7 +267,9 @@ void IGESSolid_ToolLoop::OwnShared(const occ::handle& ent, { iter.GetOneItem(ent->Edge(i)); for (j = 1; j <= ent->NbParameterCurves(i); j++) + { iter.GetOneItem(ent->ParametricCurve(i, j)); + } } } @@ -291,10 +311,14 @@ void IGESSolid_ToolLoop::OwnCopy(const occ::handle& another, occ::handle>> tmpents; if (anint > 0) + { tmpents = new NCollection_HArray1>(1, anint); + } occ::handle> tmpints; if (anint > 0) + { tmpints = new NCollection_HArray1(1, anint); + } for (j = 1; j <= anint; j++) { tmpints->SetValue(j, (another->IsIsoparametric(i, j) ? 1 : 0)); @@ -344,11 +368,13 @@ void IGESSolid_ToolLoop::OwnCheck(const occ::handle& ent, int upper = ent->NbEdges(); for (int i = 1; i <= upper; i++) + { if (ent->EdgeType(i) != 0 && ent->EdgeType(i) != 1) { Message_Msg Msg190("XSTEP_190"); ach->SendFail(Msg190); } + } } //================================================================================================= @@ -386,7 +412,9 @@ void IGESSolid_ToolLoop::OwnDump(const occ::handle& ent, if (nbc != 0) { if (level <= 5) + { S << "[ ask level > 5 for content ]"; + } else { S << ":\n [ "; @@ -405,5 +433,5 @@ void IGESSolid_ToolLoop::OwnDump(const occ::handle& ent, } S << " ]"; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolManifoldSolid.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolManifoldSolid.cxx index a0acf9f316..07452449b6 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolManifoldSolid.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolManifoldSolid.cxx @@ -106,7 +106,9 @@ void IGESSolid_ToolManifoldSolid::ReadOwnParams(const occ::handleSetValue(i, ashell); + } else { Message_Msg Msg179("XSTEP_179"); @@ -137,7 +139,9 @@ void IGESSolid_ToolManifoldSolid::ReadOwnParams(const occ::handleSetValue(i, 1); + } } } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); @@ -168,7 +172,9 @@ void IGESSolid_ToolManifoldSolid::OwnShared(const occ::handleShell()); for (i = 1; i <= nbshells; i++) + { iter.GetOneItem(ent->VoidShell(i)); + } } void IGESSolid_ToolManifoldSolid::OwnCopy(const occ::handle& another, @@ -226,12 +232,16 @@ void IGESSolid_ToolManifoldSolid::OwnDump(const occ::handleShell(), S, sublevel); S << "\n"; if (ent->OrientationFlag()) + { S << "Orientation agrees with the underlying surface\n"; + } else + { S << "Orientation does not agrees with the underlying surface\n"; + } S << "Void shells :\nOrientation flags : "; IGESData_DumpEntities(S, dumper, -level, 1, ent->NbVoidShells(), ent->VoidShell); - S << std::endl; + S << '\n'; if (level > 4) { S << "[\n"; @@ -245,12 +255,16 @@ void IGESSolid_ToolManifoldSolid::OwnDump(const occ::handleVoidShell(i), S, sublevel); S << " - Orientation flag : "; if (ent->VoidOrientationFlag(i)) + { S << "True\n"; + } else + { S << "False\n"; + } } } S << " ]\n"; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolPlaneSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolPlaneSurface.cxx index 1e6e937cd6..d37ce17f9c 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolPlaneSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolPlaneSurface.cxx @@ -159,7 +159,9 @@ void IGESSolid_ToolPlaneSurface::WriteOwnParams(const occ::handleLocationPoint()); IW.Send(ent->Normal()); if (ent->IsParametrised()) + { IW.Send(ent->ReferenceDir()); + } } //================================================================================================= @@ -223,7 +225,9 @@ void IGESSolid_ToolPlaneSurface::OwnCheck(const occ::handleIsParametrised()) + { fn = 1; + } if (fn != ent->FormNumber()) { Message_Msg Msg177("XSTEP_177"); @@ -251,8 +255,10 @@ void IGESSolid_ToolPlaneSurface::OwnDump(const occ::handleReferenceDir(), S, sublevel); - S << std::endl; + S << '\n'; } else - S << "Surface is UnParametrised" << std::endl; + { + S << "Surface is UnParametrised" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolRightAngularWedge.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolRightAngularWedge.cxx index 29dd9476a6..09c61aca10 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolRightAngularWedge.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolRightAngularWedge.cxx @@ -57,98 +57,138 @@ void IGESSolid_ToolRightAngularWedge::ReadOwnParams( // st = PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal)) + { tempCorner.SetX(tempreal); + } } else + { tempCorner.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal)) + { tempCorner.SetY(tempreal); + } } else + { tempCorner.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal)) + { tempCorner.SetZ(tempreal); + } } else + { tempCorner.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal)) + { tempXAxis.SetX(tempreal); + } } else + { tempXAxis.SetX(1.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal)) + { tempXAxis.SetY(tempreal); + } } else + { tempXAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal)) + { tempXAxis.SetZ(tempreal); + } } else + { tempXAxis.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal)) + { tempZAxis.SetX(tempreal); + } } else + { tempZAxis.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal)) + { tempZAxis.SetY(tempreal); + } } else + { tempZAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal)) + { tempZAxis.SetZ(tempreal); + } } else + { tempZAxis.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempSize, lowX, tempCorner, tempXAxis, tempZAxis); double eps = 1.E-05; if (!tempXAxis.IsEqual(ent->XAxis().XYZ(), eps)) + { PR.AddWarning("XAxis poorly unitary, normalized"); + } if (!tempZAxis.IsEqual(ent->ZAxis().XYZ(), eps)) + { PR.AddWarning("ZAxis poorly unitary, normalized"); + } } void IGESSolid_ToolRightAngularWedge::WriteOwnParams( @@ -208,13 +248,21 @@ void IGESSolid_ToolRightAngularWedge::OwnCheck(const occ::handleXAxis() * ent->ZAxis(); if (prosca < -eps || prosca > eps) + { ach->AddFail("Local Z axis : Not orthogonal to X axis"); + } if (ent->Size().X() <= 0. || ent->Size().Y() <= 0. || ent->Size().Z() <= 0.) + { ach->AddFail("Size : Values are not positive"); + } if (ent->XSmallLength() <= 0.0) + { ach->AddFail("Small X Length : Not Positive"); + } if (ent->XSmallLength() >= ent->Size().X()) + { ach->AddFail("Small X Length : Value not < LX"); + } } void IGESSolid_ToolRightAngularWedge::OwnDump(const occ::handle& ent, @@ -233,5 +281,5 @@ void IGESSolid_ToolRightAngularWedge::OwnDump(const occ::handleXAxis(), ent->VectorLocation()); S << "\nZAxis : "; IGESData_DumpXYZL(S, level, ent->ZAxis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSelectedComponent.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSelectedComponent.cxx index c7a5c39fb1..2bd3bde87a 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSelectedComponent.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSelectedComponent.cxx @@ -121,5 +121,5 @@ void IGESSolid_ToolSelectedComponent::OwnDump(const occ::handleComponent(), S, (level <= 4) ? 0 : 1); S << "Selected Point : "; IGESData_DumpXYZL(S, level, ent->SelectPoint(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolShell.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolShell.cxx index 9b179304bf..619f81b3cb 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolShell.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolShell.cxx @@ -74,7 +74,9 @@ void IGESSolid_ToolShell::ReadOwnParams(const occ::handle& // //szv#4:S4163:12Mar99 moved in if st = PR.ReadEntity(IR, PR.Current(), "Faces", // STANDARD_TYPE(IGESSolid_Face), aface); if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Face), aface)) + { tempFaces->SetValue(i, aface); + } else { Message_Msg Msg201("XSTEP_201"); @@ -105,7 +107,9 @@ void IGESSolid_ToolShell::ReadOwnParams(const occ::handle& // st = PR.ReadBoolean(PR.Current(), Msg180, abool); //szv#4:S4163:12Mar99 moved in if // st = PR.ReadBoolean(PR.Current(), "Orientation flags", abool); if (PR.ReadBoolean(PR.Current(), Msg180, abool)) + { tempOrientation->SetValue(i, (abool ? 1 : 0)); + } } } else @@ -140,7 +144,9 @@ void IGESSolid_ToolShell::OwnShared(const occ::handle& ent, { int nbfaces = ent->NbFaces(); for (int i = 1; i <= nbfaces; i++) + { iter.GetOneItem(ent->Face(i)); + } } //================================================================================================= @@ -222,10 +228,14 @@ void IGESSolid_ToolShell::OwnDump(const occ::handle& ent, dumper.Dump(ent->Face(i), S, sublevel); S << " - Orientation flag : "; if (ent->Orientation(i)) + { S << "True\n"; + } else + { S << "False\n"; + } } } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidAssembly.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidAssembly.cxx index 18d431e38c..f729fbd4b6 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidAssembly.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidAssembly.cxx @@ -57,7 +57,9 @@ void IGESSolid_ToolSolidAssembly::ReadOwnParams(const occ::handleSetValue(i, anent); + } } occ::handle amatr; @@ -72,11 +74,15 @@ void IGESSolid_ToolSolidAssembly::ReadOwnParams(const occ::handleSetValue(i, amatr); + } } } else + { PR.AddFail("Number of Items : Not Positive"); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempItems, tempMatrices); @@ -90,9 +96,13 @@ void IGESSolid_ToolSolidAssembly::WriteOwnParams(const occ::handleItem(i)); + } for (i = 1; i <= nbitems; i++) + { IW.Send(ent->TransfMatrix(i)); + } } void IGESSolid_ToolSolidAssembly::OwnShared(const occ::handle& ent, @@ -101,9 +111,13 @@ void IGESSolid_ToolSolidAssembly::OwnShared(const occ::handleNbItems(); int i; for (i = 1; i <= nbitems; i++) + { iter.GetOneItem(ent->Item(i)); + } for (i = 1; i <= nbitems; i++) + { iter.GetOneItem(ent->TransfMatrix(i)); + } } void IGESSolid_ToolSolidAssembly::OwnCopy(const occ::handle& another, @@ -167,5 +181,5 @@ void IGESSolid_ToolSolidAssembly::OwnDump(const occ::handleNbItems(), ent->TransfMatrix); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidInstance.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidInstance.cxx index ff86c9ee2d..64f4ab8695 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidInstance.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidInstance.cxx @@ -93,5 +93,5 @@ void IGESSolid_ToolSolidInstance::OwnDump(const occ::handleEntity(), S, (level <= 4) ? 0 : 1); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfLinearExtrusion.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfLinearExtrusion.cxx index aec5b9eca8..5ced567d6d 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfLinearExtrusion.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfLinearExtrusion.cxx @@ -57,36 +57,50 @@ void IGESSolid_ToolSolidOfLinearExtrusion::ReadOwnParams( // st = PR.ReadReal(PR.Current(), "Extrusion direction (I)", tempreal); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Extrusion direction (I)", tempreal)) + { tempDirection.SetX(tempreal); + } } else + { tempDirection.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Extrusion direction (J)", tempreal); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Extrusion direction (J)", tempreal)) + { tempDirection.SetY(tempreal); + } } else + { tempDirection.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Extrusion direction (K)", tempreal); //szv#4:S4163:12Mar99 // moved in if if (PR.ReadReal(PR.Current(), "Extrusion direction (K)", tempreal)) + { tempDirection.SetZ(tempreal); + } } else + { tempDirection.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempEntity, tempLength, tempDirection); double eps = 1.E-05; if (!tempDirection.IsEqual(ent->ExtrusionDirection().XYZ(), eps)) + { PR.AddWarning("Extrusion Direction poorly unitary, normalized"); + } } void IGESSolid_ToolSolidOfLinearExtrusion::WriteOwnParams( @@ -138,7 +152,9 @@ void IGESSolid_ToolSolidOfLinearExtrusion::OwnCheck( occ::handle& ach) const { if (ent->ExtrusionLength() <= 0.0) + { ach->AddFail("Length of extrusion : Not Positive"); + } } void IGESSolid_ToolSolidOfLinearExtrusion::OwnDump( @@ -154,5 +170,5 @@ void IGESSolid_ToolSolidOfLinearExtrusion::OwnDump( << "Extrusion length : " << ent->ExtrusionLength() << "\n" << "Extrusion direction : "; IGESData_DumpXYZL(S, level, ent->ExtrusionDirection(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfRevolution.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfRevolution.cxx index fa8e7415e7..efb2f3c566 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfRevolution.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSolidOfRevolution.cxx @@ -52,73 +52,102 @@ void IGESSolid_ToolSolidOfRevolution::ReadOwnParams( // clang-format off PR.ReadEntity(IR, PR.Current(), "Curve Entity", tempEntity); //szv#4:S4163:12Mar99 `st=` not needed - if (PR.DefinedElseSkip()) + if (PR.DefinedElseSkip()) { PR.ReadReal(PR.Current(), "Fraction of rotation", tempFraction); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + // clang-format on + } else + { tempFraction = 1.0; + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Axis Point (X)", tempreal)) + { tempAxisPoint.SetX(tempreal); + } } else + { tempAxisPoint.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Axis Point (Y)", tempreal)) + { tempAxisPoint.SetY(tempreal); + } } else + { tempAxisPoint.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Axis Point (Z)", tempreal)) + { tempAxisPoint.SetZ(tempreal); + } } else + { tempAxisPoint.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal)) + { tempAxis.SetX(tempreal); + } } else + { tempAxis.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal)) + { tempAxis.SetY(tempreal); + } } else + { tempAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal)) + { tempAxis.SetZ(tempreal); + } } else + { tempAxis.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempEntity, tempFraction, tempAxisPoint, tempAxis); double eps = 1.E-05; if (!tempAxis.IsEqual(ent->Axis().XYZ(), eps)) + { PR.AddWarning("Axis poorly unitary, normalized"); + } } void IGESSolid_ToolSolidOfRevolution::WriteOwnParams( @@ -172,7 +201,9 @@ void IGESSolid_ToolSolidOfRevolution::OwnCheck(const occ::handle& ach) const { if (ent->Fraction() <= 0 || ent->Fraction() > 1.0) + { ach->AddFail("Fraction of rotation : Incorrect value"); + } } void IGESSolid_ToolSolidOfRevolution::OwnDump(const occ::handle& ent, @@ -189,5 +220,5 @@ void IGESSolid_ToolSolidOfRevolution::OwnDump(const occ::handleAxisPoint(), ent->Location()); S << "\nAxis direction : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphere.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphere.cxx index 6498a6562c..d762510f1a 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphere.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphere.cxx @@ -49,28 +49,40 @@ void IGESSolid_ToolSphere::ReadOwnParams(const occ::handle& en { // st = PR.ReadReal(PR.Current(), "Center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Center (X)", tempreal)) + { tempCenter.SetX(tempreal); + } } else + { tempCenter.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Center (Y)", tempreal)) + { tempCenter.SetY(tempreal); + } } else + { tempCenter.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if if (PR.ReadReal(PR.Current(), "Center (Z)", tempreal)) + { tempCenter.SetZ(tempreal); + } } else + { tempCenter.SetZ(0.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempRadius, tempCenter); @@ -116,7 +128,9 @@ void IGESSolid_ToolSphere::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->Radius() <= 0.0) + { ach->AddFail("Radius : Not Positive"); + } } void IGESSolid_ToolSphere::OwnDump(const occ::handle& ent, @@ -128,5 +142,5 @@ void IGESSolid_ToolSphere::OwnDump(const occ::handle& ent, << "Radius : " << ent->Radius() << "\n" << "Center : "; IGESData_DumpXYZL(S, level, ent->Center(), ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphericalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphericalSurface.cxx index a9fad79d31..c1bd732472 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphericalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolSphericalSurface.cxx @@ -132,15 +132,25 @@ void IGESSolid_ToolSphericalSurface::OwnCheck(const occ::handle& ach) const { if (ent->Radius() <= 0.0) + { ach->AddFail("Radius : Not Positive"); + } int fn = 0; if (ent->IsParametrised()) + { fn = 1; + } if (fn != ent->FormNumber()) + { ach->AddFail("Parametrised Status Mismatches with Form Number"); + } if (ent->Axis().IsNull()) + { if (ent->IsParametrised()) + { ach->AddFail("Parametrised Spherical Surface : no Axis is defined"); + } + } } void IGESSolid_ToolSphericalSurface::OwnDump(const occ::handle& ent, @@ -163,8 +173,10 @@ void IGESSolid_ToolSphericalSurface::OwnDump(const occ::handleReferenceDir(), S, sublevel); - S << std::endl; + S << '\n'; } else - S << "Surface is UnParametrised" << std::endl; + { + S << "Surface is UnParametrised" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolToroidalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolToroidalSurface.cxx index ee1639eb64..4bfe123d47 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolToroidalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolToroidalSurface.cxx @@ -59,10 +59,10 @@ void IGESSolid_ToolToroidalSurface::ReadOwnParams(const occ::handleFormNumber() == 1) // Parametrised surface - // clang-format off - PR.ReadEntity(IR, PR.Current(), "Reference direction", tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed - // clang-format on + if (ent->FormNumber() == 1) + { // Parametrised surface + PR.ReadEntity(IR, PR.Current(), "Reference direction", tempRefdir); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(tempCenter, tempAxis, majRad, minRad, occ::down_cast(tempRefdir)); @@ -77,7 +77,9 @@ void IGESSolid_ToolToroidalSurface::WriteOwnParams( IW.Send(ent->MajorRadius()); IW.Send(ent->MinorRadius()); if (ent->IsParametrised()) + { IW.Send(ent->ReferenceDir()); + } } void IGESSolid_ToolToroidalSurface::OwnShared(const occ::handle& ent, @@ -128,16 +130,26 @@ void IGESSolid_ToolToroidalSurface::OwnCheck(const occ::handle& ach) const { if (ent->MajorRadius() <= 0.0) + { ach->AddFail("Major Radius : Not Positive"); + } if (ent->MinorRadius() <= 0.0) + { ach->AddFail("Minor Radius : Not Positive"); + } if (ent->MinorRadius() >= ent->MajorRadius()) + { ach->AddFail("Minor Radius : Value not < Major radius"); + } int fn = 0; if (ent->IsParametrised()) + { fn = 1; + } if (fn != ent->FormNumber()) + { ach->AddFail("Parametrised Status Mismatches with Form Number"); + } } void IGESSolid_ToolToroidalSurface::OwnDump(const occ::handle& ent, @@ -154,14 +166,16 @@ void IGESSolid_ToolToroidalSurface::OwnDump(const occ::handleAxis(), S, sublevel); S << "\n" - << "Major Radius : " << ent->MajorRadius() << " " - << "Minor Radius : " << ent->MinorRadius() << "\n"; + << "Major Radius : " << ent->MajorRadius() << " " << "Minor Radius : " << ent->MinorRadius() + << "\n"; if (ent->IsParametrised()) { S << "Surface is Parametrised - Reference direction : "; dumper.Dump(ent->ReferenceDir(), S, sublevel); - S << std::endl; + S << '\n'; } else - S << "Surface is UnParametrised" << std::endl; + { + S << "Surface is UnParametrised" << '\n'; + } } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolTorus.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolTorus.cxx index 605ffe9f8f..d778356a3f 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolTorus.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolTorus.cxx @@ -53,66 +53,92 @@ void IGESSolid_ToolTorus::ReadOwnParams(const occ::handle& ent, // st = PR.ReadReal(PR.Current(), "Center Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Center Point (X)", tempreal)) + { tempPoint.SetX(tempreal); + } } else + { tempPoint.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal)) + { tempPoint.SetY(tempreal); + } } else + { tempPoint.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in // if if (PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal)) + { tempPoint.SetZ(tempreal); + } } else + { tempPoint.SetZ(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal)) + { tempAxis.SetX(tempreal); + } } else + { tempAxis.SetX(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal)) + { tempAxis.SetY(tempreal); + } } else + { tempAxis.SetY(0.0); + } if (PR.DefinedElseSkip()) { // st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved // in if if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal)) + { tempAxis.SetZ(tempreal); + } } else + { tempAxis.SetZ(1.0); + } DirChecker(ent).CheckTypeAndForm(PR.CCheck(), ent); ent->Init(r1, r2, tempPoint, tempAxis); double eps = 1.E-05; if (!tempAxis.IsEqual(ent->Axis().XYZ(), eps)) + { PR.AddWarning("Axis poorly unitary, normalized"); + } } void IGESSolid_ToolTorus::WriteOwnParams(const occ::handle& ent, @@ -162,11 +188,17 @@ void IGESSolid_ToolTorus::OwnCheck(const occ::handle& ent, occ::handle& ach) const { if (ent->MajorRadius() <= 0.0) + { ach->AddFail("Radius of revolution : Not Positive"); + } if (ent->DiscRadius() <= 0.0) + { ach->AddFail("Radius of disc : Not Positive"); + } if (ent->DiscRadius() >= ent->MajorRadius()) + { ach->AddFail("Radius of disc : is not Less than Radius of revolution"); + } } void IGESSolid_ToolTorus::OwnDump(const occ::handle& ent, @@ -181,5 +213,5 @@ void IGESSolid_ToolTorus::OwnDump(const occ::handle& ent, IGESData_DumpXYZL(S, level, ent->AxisPoint(), ent->Location()); S << "\nAxis direction : "; IGESData_DumpXYZL(S, level, ent->Axis(), ent->VectorLocation()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolVertexList.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolVertexList.cxx index 6378b12f16..d528cfe410 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolVertexList.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToolVertexList.cxx @@ -74,7 +74,9 @@ void IGESSolid_ToolVertexList::ReadOwnParams(const occ::handleSetValue(i, anXYZ); + } } } else @@ -85,7 +87,9 @@ void IGESSolid_ToolVertexList::ReadOwnParams(const occ::handle 0) + { ent->Init(tempVertices); + } } //================================================================================================= @@ -177,5 +181,5 @@ void IGESSolid_ToolVertexList::OwnDump(const occ::handle& S << "IGESSolid_VertexList\n" << "Vertices : "; IGESData_DumpListXYZL(S, level, 1, ent->NbVertices(), ent->Vertex, ent->Location()); - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_TopoBuilder.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_TopoBuilder.cxx index 4f782f6a6d..9050f2a81a 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_TopoBuilder.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_TopoBuilder.cxx @@ -84,7 +84,9 @@ void IGESSolid_TopoBuilder::AddEdge(const occ::handle& curv { if (curve.IsNull() || vstart <= 0 || vend <= 0 || vstart > thepoint->Length() || vend > thepoint->Length()) + { throw Standard_DomainError("IGESSolid_TopoBuilder : AddEdge"); + } thecur3d->Append(curve); thevstar->Append(vstart); thevend->Append(vend); @@ -101,7 +103,9 @@ void IGESSolid_TopoBuilder::Edge(const int num, int& vend) const { if (num <= 0 || num > thecur3d->Length()) + { return; + } curve = GetCasted(IGESData_IGESEntity, thecur3d->Value(num)); vstart = thevstar->Value(num); vend = thevend->Value(num); @@ -125,7 +129,9 @@ void IGESSolid_TopoBuilder::EndLists() { vert = new NCollection_HArray1(1, nb); for (i = 1; i <= nb; i++) + { vert->SetValue(i, thepoint->Value(i)); + } } thevertl->Init(vert); @@ -164,7 +170,9 @@ void IGESSolid_TopoBuilder::MakeLoop() void IGESSolid_TopoBuilder::MakeEdge(const int edgetype, const int edge3d, const int orientation) { if (edge3d <= 0 || edge3d > thecur3d->Length()) + { throw Standard_DomainError("IGESSolid_TopoBuilder : MakeEdge"); + } theetype->Append(edgetype); thee3d->Append(edge3d); theeflag->Append(orientation); @@ -175,7 +183,9 @@ void IGESSolid_TopoBuilder::MakeEdge(const int edgetype, const int edge3d, const void IGESSolid_TopoBuilder::AddCurveUV(const occ::handle& curve, const int iso) { if (curve.IsNull() || thee3d->IsEmpty()) + { throw Standard_DomainError("IGESSolid_TopoBuilder : AddCurveUV"); + } thecuruv->Append(curve); theisol->Append(iso); } @@ -241,7 +251,9 @@ void IGESSolid_TopoBuilder::EndLoop() void IGESSolid_TopoBuilder::MakeFace(const occ::handle& surface) { if (surface.IsNull()) + { throw Standard_DomainError("IGESSolid_TopoBuilder : MakeFace"); + } thesurf = surface; theouter = false; theinner->Clear(); @@ -271,7 +283,9 @@ void IGESSolid_TopoBuilder::EndFace(const int orientation) { loops = new NCollection_HArray1>(1, nb); for (i = 1; i <= nb; i++) + { loops->SetValue(i, GetCasted(IGESSolid_Loop, theinner->Value(i))); + } } theface->Init(thesurf, theouter, loops); thefaces->Append(theface); diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToroidalSurface.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToroidalSurface.cxx index 249e8a0276..dbea3e18cd 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToroidalSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_ToroidalSurface.cxx @@ -49,7 +49,9 @@ occ::handle IGESSolid_ToroidalSurface::Center() const gp_Pnt IGESSolid_ToroidalSurface::TransformedCenter() const { if (!HasTransf()) + { return theCenter->Value(); + } else { gp_XYZ tmp = theCenter->Value().XYZ(); diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Torus.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Torus.cxx index 1032330832..cd7508e921 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Torus.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_Torus.cxx @@ -56,7 +56,9 @@ gp_Pnt IGESSolid_Torus::AxisPoint() const gp_Pnt IGESSolid_Torus::TransformedAxisPoint() const { if (!HasTransf()) + { return gp_Pnt(thePoint); + } else { gp_XYZ pnt = thePoint; @@ -73,7 +75,9 @@ gp_Dir IGESSolid_Torus::Axis() const gp_Dir IGESSolid_Torus::TransformedAxis() const { if (!HasTransf()) + { return gp_Dir(theAxis); + } else { gp_XYZ pnt = theAxis; diff --git a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_VertexList.cxx b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_VertexList.cxx index 5b80acb862..c0091a5cc0 100644 --- a/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_VertexList.cxx +++ b/src/DataExchange/TKDEIGES/IGESSolid/IGESSolid_VertexList.cxx @@ -28,7 +28,9 @@ IGESSolid_VertexList::IGESSolid_VertexList() = default; void IGESSolid_VertexList::Init(const occ::handle>& Vertices) { if (Vertices.IsNull() || Vertices->Lower() != 1) + { throw Standard_DimensionMismatch("IGESSolid_VertexList : Init"); + } theVertices = Vertices; InitTypeAndForm(502, 1); } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep.cxx index 5878dafd6f..a421f276b4 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep.cxx @@ -71,7 +71,9 @@ void IGESToBRep::Init() { static bool init = false; if (init) + { return; + } init = true; XSAlgo::Init(); theContainer = new IGESToBRep_AlgoContainer; @@ -100,13 +102,21 @@ bool IGESToBRep::IsCurveAndSurface(const occ::handle& start { // S4054 if (start.IsNull()) + { return false; + } if (IsTopoCurve(start)) + { return true; + } if (IsTopoSurface(start)) + { return true; + } if (IsBRepEntity(start)) + { return true; + } return false; } @@ -119,19 +129,33 @@ bool IGESToBRep::IsBasicCurve(const occ::handle& start) { // S4054 if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) + { return true; + } return false; } @@ -144,22 +168,38 @@ bool IGESToBRep::IsBasicSurface(const occ::handle& start) { // S4054 if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineSurface))) + { return true; + } // S4181 pdn 15.04.99 added to basic surfaces if (start->IsKind(STANDARD_TYPE(IGESSolid_PlaneSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_CylindricalSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_ConicalSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_SphericalSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_ToroidalSurface))) + { return true; + } return false; } @@ -173,19 +213,33 @@ bool IGESToBRep::IsTopoCurve(const occ::handle& start) { // S4054 if (start.IsNull()) + { return false; + } if (IsBasicCurve(start)) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_CompositeCurve))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_Boundary))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_Point))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_OffsetCurve))) + { return true; + } return false; } @@ -198,23 +252,41 @@ bool IGESToBRep::IsTopoSurface(const occ::handle& start) { // S4054 if (start.IsNull()) + { return false; + } if (IsBasicSurface(start)) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_Plane))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESGeom_OffsetSurface))) + { return true; + } // S4181 pdn 15.04.99 removing to basic surface // if (start->IsKind(STANDARD_TYPE(IGESSolid_PlaneSurface))) return true; // SingleParent, special case (Perforated Face: contains only PLANEs) @@ -222,12 +294,16 @@ bool IGESToBRep::IsTopoSurface(const occ::handle& start) { DeclareAndCast(IGESBasic_SingleParent, sp, start); if (!sp->SingleParent()->IsKind(STANDARD_TYPE(IGESGeom_Plane))) + { return false; + } int nb = sp->NbChildren(); for (int i = 1; i <= nb; i++) { if (!sp->Child(i)->IsKind(STANDARD_TYPE(IGESGeom_Plane))) + { return false; + } } return true; } @@ -243,19 +319,33 @@ bool IGESToBRep::IsBRepEntity(const occ::handle& start) { // S4054 if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_Face))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_Shell))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_ManifoldSolid))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_VertexList))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_EdgeList))) + { return true; + } if (start->IsKind(STANDARD_TYPE(IGESSolid_Loop))) + { return true; + } return false; } @@ -275,7 +365,9 @@ int IGESToBRep::IGESCurveToSequenceOfIGESCurve( occ::handle>>& sequence) { if (sequence.IsNull()) + { sequence = new NCollection_HSequence>; + } if (!curve.IsNull()) { if (curve->IsKind(STANDARD_TYPE(IGESGeom_CompositeCurve))) @@ -289,7 +381,9 @@ int IGESToBRep::IGESCurveToSequenceOfIGESCurve( } } else if (IGESToBRep::IsTopoCurve(curve) && !curve->IsKind(STANDARD_TYPE(IGESGeom_Point))) + { sequence->Append(curve); + } } return sequence->Length(); } @@ -347,17 +441,21 @@ bool IGESToBRep::TransferPCurve(const TopoDS_Edge& fromedge, } } if (toedge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(toedge, occ::down_cast(pcurve->Copy()), occ::down_cast(oldpcurve->Copy()), face, 0); + } else + { B.UpdateEdge(toedge, occ::down_cast(oldpcurve->Copy()), occ::down_cast(pcurve->Copy()), face, 0); + } } else { @@ -368,8 +466,12 @@ bool IGESToBRep::TransferPCurve(const TopoDS_Edge& fromedge, B.Range(toedge, face, a, b); double first, last; if (!BRep_Tool::Curve(toedge, first, last).IsNull() && (first != a || last != b)) + { B.SameRange(toedge, false); + } else + { B.SameRange(toedge, true); + } return result; } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Actor.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Actor.cxx index 920af59f8f..4c49893bca 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Actor.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Actor.cxx @@ -118,7 +118,9 @@ bool IGESToBRep_Actor::Recognize(const occ::handle& start) DeclareAndCast(IGESData_IGESModel, mymodel, themodel); DeclareAndCast(IGESData_IGESEntity, ent, start); if (ent.IsNull()) + { return false; + } // Cas reconnus int typnum = ent->TypeNumber(); @@ -138,11 +140,15 @@ occ::handle IGESToBRep_Actor::Transfer( DeclareAndCast(IGESData_IGESModel, mymodel, themodel); DeclareAndCast(IGESData_IGESEntity, ent, start); if (mymodel.IsNull() || ent.IsNull()) + { return NullResult(); + } int anum = mymodel->Number(start); if (Interface_Static::IVal("read.iges.faulty.entities") == 0 && mymodel->IsErrorEntity(anum)) + { return NullResult(); + } TopoDS_Shape shape; // Call the transfer only if type is OK. @@ -164,9 +170,13 @@ occ::handle IGESToBRep_Actor::Transfer( CAS.SetTransferProcess(TP); int Ival = Interface_Static::IVal("read.precision.mode"); if (Ival == 0) + { eps = mymodel->GlobalSection().Resolution(); + } else + { eps = Interface_Static::RVal("read.precision.val"); //: 10 ABV 11 Nov 97 + } //: 10 eps = BRepAPI::Precision(); Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode"); CAS.SetModeApprox((Ival > 0)); @@ -221,7 +231,9 @@ occ::handle IGESToBRep_Actor::Transfer( } occ::handle binder; if (!shape.IsNull()) + { binder = new TransferBRep_ShapeBinder(shape); + } return binder; } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BRepEntity.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BRepEntity.cxx index d46efdef21..6d31b39e49 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BRepEntity.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BRepEntity.cxx @@ -387,7 +387,9 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const occ::handleReverse(); + } // processing of 2d curves. // ------------------------- @@ -405,7 +407,9 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const occ::handle>(1, nbparam); for (int i = 1; i <= nbparam; i++) + { Curves2d->SetValue(i, start->ParametricCurve(iedge, i)); + } } occ::handle lsewd; // result of translation of current edge Result = Result @@ -418,7 +422,9 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const occ::handleWireData(); // initialization + } if (curve3d->NbEdges() == 1 && lsewd->NbEdges() == 1) { // the condition corresponds to limitation above // to keep sharing of edges all geometric representations should be put @@ -500,7 +506,9 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferFace(const occ::handle aMaxValue) + { aMaxValue = CWeights.Value(i); + } } if (aMaxValue - aMinValue > 1000) { @@ -111,15 +115,19 @@ static bool checkBSplineCurve(IGESToBRep_BasicCurve* theCurve // check whether knots are in ascending order. for (int i = CKnots.Lower(); i < CKnots.Upper(); i++) + { if (CKnots.Value(i + 1) < CKnots.Value(i)) { Message_Msg msg1373("IGES_1373"); // FAIL - Knots are not in ascending order theCurve->SendFail(theBSplineCurve, msg1373); aResult = false; } + } // Fix coincided knots if (aResult) + { ShapeConstruct_Curve::FixKnots(CKnots); + } return aResult; } @@ -219,7 +227,9 @@ occ::handle IGESToBRep_BasicCurve::TransferBasicCurve( // The more specific function have ever add a fail message for this entity } else + { res->Scale(gp_Pnt(0, 0, 0), GetUnitFactor()); + } return res; } @@ -368,14 +378,18 @@ occ::handle IGESToBRep_BasicCurve::TransferConicArc( t1 = ElCLib::Parameter(circ, startPoint); t2 = ElCLib::Parameter(circ, endPoint); if (t1 > t2 && (t1 - t2) > Precision::Confusion()) + { t2 += 2. * M_PI; + } if (std::abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2 Message_Msg msg1160("IGES_1160"); SendWarning(st, msg1160); } else + { res = new Geom_TrimmedCurve(res, t1, t2); + } } return res; } @@ -408,8 +422,10 @@ occ::handle IGESToBRep_BasicCurve::TransferConicArc( // AddWarning(st, "The trim of the parabola is not correct."); } else + { // if t1 > t2, the course of the curve is going to be reversed. res = new Geom_TrimmedCurve(res, t1, t2); + } return res; } @@ -431,7 +447,9 @@ occ::handle IGESToBRep_BasicCurve::TransferConicArc( t1 = ElCLib::Parameter(elips, startPoint); t2 = ElCLib::Parameter(elips, endPoint); if (t2 < t1 && (t1 - t2) > Precision::Confusion()) + { t2 += 2. * M_PI; + } if (std::abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2 Message_Msg msg1160("IGES_1160"); @@ -439,7 +457,9 @@ occ::handle IGESToBRep_BasicCurve::TransferConicArc( // AddWarning(st, "The trim of the ellipse is not correct, the result will be a ellipse."); } else + { res = new Geom_TrimmedCurve(res, t1, t2); + } } } else @@ -459,9 +479,13 @@ occ::handle IGESToBRep_BasicCurve::TransferConicArc( SendWarning(st, msg1160); } else if (t1 > t2) + { res = new Geom_TrimmedCurve(res, t2, t1); // parameter inversion. + } else + { res = new Geom_TrimmedCurve(res, t1, t2); + } } return res; @@ -542,7 +566,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( res = new Geom2d_Circle(frame, minorRadius); // #45 rln 23.11.98 if (st->TransformedAxis().IsOpposite(st->Axis(), GetEpsilon())) + { res->Reverse(); + } if (!st->IsClosed()) { @@ -554,14 +580,18 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( t2 = ElCLib::Parameter(circ, endPoint); if (t2 < t1 && (t1 - t2) > Precision::PConfusion()) + { t2 += 2. * M_PI; + } if (std::abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2 Message_Msg msg1160("IGES_1160"); SendWarning(st, msg1160); } else + { res = new Geom2d_TrimmedCurve(res, t1, t2); + } } return res; } @@ -583,7 +613,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( res = new Geom2d_Parabola(frame, focal); // #45 rln 23.11.98 if (st->TransformedAxis().IsOpposite(st->Axis(), GetEpsilon())) + { res->Reverse(); + } gp_Parab2d parab = occ::down_cast(res)->Parab2d(); // #45 rln (frame, focal); @@ -595,9 +627,13 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( SendWarning(st, msg1160); } else if (t1 > t2) + { res = new Geom2d_TrimmedCurve(res, t2, t1); // parameter inversion. + } else + { res = new Geom2d_TrimmedCurve(res, t1, t2); + } return res; } @@ -613,7 +649,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( res = new Geom2d_Ellipse(frame, majorRadius, minorRadius); // #45 rln 23.11.98 if (st->TransformedAxis().IsOpposite(st->Axis(), GetEpsilon())) + { res->Reverse(); + } if (!st->IsClosed()) { @@ -625,14 +663,18 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( t1 = ElCLib::Parameter(elips, startPoint); t2 = ElCLib::Parameter(elips, endPoint); if (t2 < t1 && (t1 - t2) > Precision::PConfusion()) + { t2 += 2. * M_PI; + } if (std::abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2 Message_Msg msg1160("IGES_1160"); SendWarning(st, msg1160); } else + { res = new Geom2d_TrimmedCurve(res, t1, t2); + } } } else @@ -641,7 +683,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( res = new Geom2d_Hyperbola(frame, majorRadius, minorRadius); // #45 rln 23.11.98 if (st->TransformedAxis().IsOpposite(st->Axis(), GetEpsilon())) + { res->Reverse(); + } // clang-format off gp_Hypr2d hpr = occ::down_cast(res)->Hypr2d();//#45 rln (frame, majorRadius, minorRadius); @@ -656,9 +700,13 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dConicArc( SendWarning(st, msg1160); } else if (t1 > t2) + { res = new Geom2d_TrimmedCurve(res, t2, t1); // parameter inversion. + } else + { res = new Geom2d_TrimmedCurve(res, t1, t2); + } } return res; @@ -720,7 +768,9 @@ occ::handle IGESToBRep_BasicCurve::TransferCircularArc( t2 = ElCLib::Parameter(circ, endPoint); if (st->IsClosed() && t1 >= GetEpsGeom()) + { t2 = t1 + 2. * M_PI; + } if (!st->IsClosed() && fabs(t1 - t2) <= Precision::PConfusion()) { // micro-arc @@ -730,7 +780,9 @@ occ::handle IGESToBRep_BasicCurve::TransferCircularArc( if (!st->IsClosed() || t1 >= GetEpsGeom()) { if (t2 < t1) + { t2 += 2. * M_PI; + } res = new Geom_TrimmedCurve(res, t1, t2); } @@ -783,7 +835,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCircularArc( endPoint.SetCoord(st->TransformedEndPoint().X(), st->TransformedEndPoint().Y()); // #45 rln 23.11.98 if (st->TransformedAxis().IsOpposite(st->Axis(), GetEpsilon())) + { res->Reverse(); + } } else { @@ -799,7 +853,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCircularArc( t2 = ElCLib::Parameter(circ, endPoint); if (st->IsClosed() && t1 >= GetEpsGeom()) + { t2 = t1 + 2. * M_PI; + } if (!st->IsClosed() && fabs(t1 - t2) <= Precision::PConfusion()) { // micro-arc @@ -809,7 +865,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCircularArc( if (!st->IsClosed() || t1 >= GetEpsGeom()) { if (t2 < t1) + { t2 += 2. * M_PI; + } res = new Geom2d_TrimmedCurve(res, t1, t2); } return res; @@ -892,7 +950,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dSplineCurve( occ::handle res3d = TransferSplineCurve(st); SetEpsGeom(epsGeom); if (res3d.IsNull()) + { return res; // The transfer was not over the top. + } // 2d // == @@ -903,7 +963,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dSplineCurve( const NCollection_Array1& multi = res3d->Multiplicities(); for (int i = bspoles2d.Lower(); i <= bspoles2d.Upper(); i++) + { bspoles2d.SetValue(i, gp_Pnt2d(res3d->Pole(i).X(), res3d->Pole(i).Y())); + } res = new Geom2d_BSplineCurve(bspoles2d, knots, multi, res3d->Degree()); return res; @@ -954,11 +1016,19 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( int i; // szv#4:S4163:12Mar99 j unused if (!GetModeTransfer() && start->HasTransf()) + { for (i = 0; i <= start->UpperIndex(); i++) + { Pole.SetValue(PoleIndex++, start->TransformedPole(i)); + } + } else + { for (i = 0; i <= start->UpperIndex(); i++) + { Pole.SetValue(PoleIndex++, start->Pole(i)); + } + } // Filling knots & multiplicities arrays : // ======================================== @@ -983,9 +1053,13 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( // double ek = Epsilon(Knot1); if (std::abs(Knot1 - Knot2) <= Epsilon(Knot1)) + { TempMult.SetValue(KnotIndex, TempMult.Value(KnotIndex) + 1); + } else + { TempKnot.SetValue(++KnotIndex, Knot1); + } } // Final knots & multiplicities arrays are dimensioned so as to be fully @@ -1031,7 +1105,9 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( if (newNbPoles < NbPoles) { for (i = 1; i <= NbPoles; i++) + { PoleInd.Append(i); + } int Offset = 0; for (int itab = 1; itab <= SeqIndex.Length(); itab++) { @@ -1137,9 +1213,13 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( { OCC_CATCH_SIGNALS if (start->IsPolynomial()) + { BSplineRes = new Geom_BSplineCurve(Poles, Knot, Mult, Degree); + } else + { BSplineRes = new Geom_BSplineCurve(Poles, Weight, Knot, Mult, Degree); + } } catch (Standard_Failure const& anException) { @@ -1175,7 +1255,9 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( { OCC_CATCH_SIGNALS if (std::abs(Ufin - Udeb) > Precision::PConfusion()) + { BSplineRes->Segment(Udeb, Ufin); + } res = BSplineRes; } catch (Standard_Failure const&) @@ -1185,7 +1267,9 @@ occ::handle IGESToBRep_BasicCurve::TransferBSplineCurve( } } else + { res = BSplineRes; + } return res; } @@ -1267,7 +1351,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dBSplineCurve( BSplineC = new Geom2d_BSplineCurve(Pole, Bspline->WeightsArray(), Knot, Mult, Degree); } else + { BSplineC = new Geom2d_BSplineCurve(Pole, Knot, Mult, Degree); + } res = BSplineC; @@ -1315,9 +1401,13 @@ occ::handle IGESToBRep_BasicCurve::TransferLine(const occ::handle Gline = new Geom_Line(line); if (Precision::IsNegativeInfinite(t1)) + { t1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(t2)) + { t2 = Precision::Infinite(); + } res = new Geom_TrimmedCurve(Gline, t1, t2); } else @@ -1363,9 +1453,13 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dLine( double t2 = ElCLib::Parameter(line2d, end); occ::handle Gline2d = new Geom2d_Line(line2d); if (Precision::IsNegativeInfinite(t1)) + { t1 = -Precision::Infinite(); + } if (Precision::IsPositiveInfinite(t2)) + { t2 = Precision::Infinite(); + } res = new Geom2d_TrimmedCurve(Gline2d, t1, t2); } // added by rln 18/12/97 CSR# CTS18544 entity 25168 and 31273 @@ -1394,7 +1488,9 @@ occ::handle IGESToBRep_BasicCurve::TransferTransformation( gp_Trsf resultat; SetEpsilon(1.E-05); if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(), start->Value(), resultat)) + { res = new Geom_Transformation(resultat); + } else { Message_Msg msg1036("IGES_1036"); @@ -1455,15 +1551,21 @@ occ::handle IGESToBRep_BasicCurve::TransferCopiousData( { gp_Pnt aPole; if (!GetModeTransfer() && start->HasTransf()) + { aPole = start->TransformedPoint(i); + } else + { aPole = start->Point(i); + } // #2 pdn 7 May 1998 BUC50028 // delete GetUnitFactor() // if (!aPole.IsEqual(TempPole(TempIndex-1),GetEpsGeom())) // S4054: some filter must be kept UKI60556 entity 7 (two equal points) if (!aPole.IsEqual(TempPole(TempIndex - 1), gp::Resolution())) + { TempPole.SetValue(TempIndex++, aPole); + } } NbPoints = TempIndex - TempPole.Lower(); @@ -1480,7 +1582,9 @@ occ::handle IGESToBRep_BasicCurve::TransferCopiousData( TempIndex = TempPole.Lower(); for (i = Pole.Lower(); i <= Pole.Upper(); i++) + { Pole.SetValue(i, TempPole.Value(TempIndex++)); + } // Filling array of knots : // ======================== @@ -1551,10 +1655,14 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCopiousData( int TempIndex = TempPole.Lower(); if (!GetModeTransfer() && start->HasTransf()) + { TempPole.SetValue(TempIndex, gp_Pnt2d(start->TransformedPoint(1).X(), start->TransformedPoint(1).Y())); + } else + { TempPole.SetValue(TempIndex, gp_Pnt2d(start->Point(1).X(), start->Point(1).Y())); + } TempIndex++; int i; // svv Jan 10 2000 : porting on DEC @@ -1562,14 +1670,20 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCopiousData( { gp_Pnt2d aPole; if (!GetModeTransfer() && start->HasTransf()) + { aPole = gp_Pnt2d(start->TransformedPoint(i).X(), start->TransformedPoint(i).Y()); + } else + { aPole = gp_Pnt2d(start->Point(i).X(), start->Point(i).Y()); + } // if (!aPole.IsEqual(TempPole(TempIndex-1), GetEpsCoeff())) //modified by rln 16/12/97 CSR# // PRO11641 entity 46GetEpsGeom()*GetUnitFactor() // S4054: some filter must be kept UKI60556 entity 7 (two equal points) if (!aPole.IsEqual(TempPole(TempIndex - 1), gp::Resolution())) + { TempPole.SetValue(TempIndex++, aPole); + } } NbPoints = TempIndex - TempPole.Lower(); @@ -1585,7 +1699,9 @@ occ::handle IGESToBRep_BasicCurve::Transfer2dCopiousData( TempIndex = TempPole.Lower(); for (i = Pole.Lower(); i <= Pole.Upper(); i++) + { Pole.SetValue(i, TempPole.Value(TempIndex++)); + } // Filling array of knots : // ======================== diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BasicSurface.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BasicSurface.cxx index db99f2e67a..cf46251f1e 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BasicSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_BasicSurface.cxx @@ -87,12 +87,17 @@ static bool checkBSplineSurface(IGESToBRep_BasicSurface* theS double aMinValue = SWeights.Value(SWeights.LowerRow(), SWeights.LowerCol()); double aMaxValue = SWeights.Value(SWeights.LowerRow(), SWeights.LowerCol()); for (int i = SWeights.LowerRow(); i <= SWeights.UpperRow(); i++) + { for (int j = SWeights.LowerCol(); j <= SWeights.UpperCol(); j++) { if (SWeights.Value(i, j) < aMinValue) + { aMinValue = SWeights.Value(i, j); + } if (SWeights.Value(i, j) > aMaxValue) + { aMaxValue = SWeights.Value(i, j); + } if (aMaxValue - aMinValue > 1000) { @@ -100,6 +105,7 @@ static bool checkBSplineSurface(IGESToBRep_BasicSurface* theS theSurface->SendWarning(theBSplineSurface, msg1374); } } + } } bool aResult = true; @@ -108,11 +114,19 @@ static bool checkBSplineSurface(IGESToBRep_BasicSurface* theS bool aWrongOrder = false; int i; for (i = SUKnots.Lower(); (i < SUKnots.Upper()) && (!aWrongOrder); i++) + { if (SUKnots.Value(i + 1) < SUKnots.Value(i)) + { aWrongOrder = true; + } + } for (i = SVKnots.Lower(); (i < SVKnots.Upper()) && (!aWrongOrder); i++) + { if (SVKnots.Value(i + 1) < SVKnots.Value(i)) + { aWrongOrder = true; + } + } if (aWrongOrder) { @@ -235,7 +249,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBasicSurface( // AddFail(start,"The IGESEntity cannot be transferred"); } else + { resurf->Scale(gp_Pnt(0, 0, 0), GetUnitFactor()); + } return resurf; } @@ -330,7 +346,9 @@ occ::handle IGESToBRep_BasicSurface::TransferRigthCylin gp_Dir ax = gp_Dir(Axis->Value()); gp_Ax3 ax3; if (!Param) + { ax3 = gp_Ax3(Pt, ax); + } else { occ::handle refdir = start->ReferenceDir(); @@ -389,13 +407,17 @@ occ::handle IGESToBRep_BasicSurface::TransferRigthConicalSu return res; } if (radius < Precision::Confusion()) + { radius = 0.; + } gp_Pnt Pt = Point->Value(); gp_Dir ax = gp_Dir(Axis->Value()); gp_Ax3 ax3; if (!Param) + { ax3 = gp_Ax3(Pt, ax); + } else { occ::handle refdir = start->ReferenceDir(); @@ -453,7 +475,9 @@ occ::handle IGESToBRep_BasicSurface::TransferSphericalSur gp_Dir ax = gp_Dir(Axis->Value()); gp_Ax3 ax3; if (!Param) + { ax3 = gp_Ax3(Pt, ax); + } else { occ::handle refdir = start->ReferenceDir(); @@ -512,7 +536,9 @@ occ::handle IGESToBRep_BasicSurface::TransferToroidalSurfa gp_Dir ax = gp_Dir(Axis->Value()); gp_Ax3 ax3; if (!Param) + { ax3 = gp_Ax3(Pt, ax); + } else { occ::handle refdir = start->ReferenceDir(); @@ -628,21 +654,29 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface int i, j; // szv#4:S4163:12Mar99 k unused if (!GetModeTransfer() && start->HasTransf()) + { for (i = 0; i <= start->UpperIndexU(); i++) { for (j = 0; j <= start->UpperIndexV(); j++) + { Pole.SetValue(UIndex, VIndex++, start->TransformedPole(i, j)); + } UIndex++; VIndex = Pole.LowerCol(); } + } else + { for (i = 0; i <= start->UpperIndexU(); i++) { for (j = 0; j <= start->UpperIndexV(); j++) + { Pole.SetValue(UIndex, VIndex++, start->Pole(i, j)); + } UIndex++; VIndex = Pole.LowerCol(); } + } // KNOTS & MULTIPLICITIES for U : // ============================== @@ -667,9 +701,13 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface double UKnot2 = start->KnotU(i - 1); if (std::abs(UKnot1 - UKnot2) <= Epsilon(UKnot2)) + { TempUMult.SetValue(UIndex, TempUMult.Value(UIndex) + 1); + } else + { TempUKnot.SetValue(++UIndex, UKnot1); + } } // Final knots & multiplicities arrays are dimensioned so as to be fully @@ -739,9 +777,13 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface double VKnot2 = start->KnotV(i - 1); if (std::abs(VKnot1 - VKnot2) <= Epsilon(VKnot2)) + { TempVMult.SetValue(VIndex, TempVMult.Value(VIndex) + 1); + } else + { TempVKnot.SetValue(++VIndex, VKnot1); + } } // Final knots & multiplicities arrays are dimensioned so as to be fully @@ -794,9 +836,13 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface NCollection_Sequence PoleUInd; NCollection_Sequence PoleVInd; for (i = 1; i <= NbPolesU; i++) + { PoleUInd.Append(i); + } for (i = 1; i <= NbPolesV; i++) + { PoleVInd.Append(i); + } UIndex = Poles.LowerRow(); VIndex = Poles.LowerCol(); @@ -829,7 +875,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface for (i = 1; i <= newNbPolesU; i++) { for (j = 1; j <= newNbPolesV; j++) + { Poles.SetValue(UIndex, VIndex++, Pole.Value(PoleUInd.Value(i), PoleVInd.Value(j))); + } UIndex++; VIndex = Poles.LowerCol(); } @@ -846,7 +894,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface for (i = 1; i <= newNbPolesU; i++) { for (j = 1; j <= newNbPolesV; j++) + { Poles.SetValue(UIndex, VIndex++, Pole.Value(i, j)); + } UIndex++; VIndex = Poles.LowerCol(); } @@ -860,9 +910,15 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface gp_GTrsf GBSplTrsf(start->CompoundLocation()); gp_Trsf BSplTrsf; if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(), GBSplTrsf, BSplTrsf)) + { for (i = Poles.LowerRow(); i <= Poles.UpperRow(); i++) + { for (j = Poles.LowerCol(); j <= Poles.UpperCol(); j++) + { Poles.SetValue(i, j, Poles.Value(i, j).Transformed(BSplTrsf)); + } + } + } else { Message_Msg msg1035("IGES_1035"); @@ -878,7 +934,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface // sln 29.12.2001 OCC90 : If surface can not be created do nothing NCollection_Array2 Weight(1, 1, 1, 1); if (!checkBSplineSurface(this, start, UKnot, VKnot, Weight)) + { return res; + } res = new Geom_BSplineSurface(Poles, UKnot, VKnot, UMult, VMult, DegreeU, DegreeV); } @@ -927,7 +985,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface for (i = 1; i <= newNbPolesU; i++) { for (j = 1; j <= newNbPolesV; j++) + { Weight.SetValue(UIndex, VIndex++, PoleWeight.Value(PoleUInd.Value(i), PoleVInd.Value(j))); + } UIndex++; VIndex = Poles.LowerCol(); } @@ -937,7 +997,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface for (i = 1; i <= newNbPolesU; i++) { for (j = 1; j <= newNbPolesV; j++) + { Weight.SetValue(UIndex, VIndex++, PoleWeight.Value(i, j)); + } UIndex++; VIndex = Poles.LowerCol(); } @@ -945,7 +1007,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface // sln 29.12.2001 OCC90 : If surface can not be created do nothing if (!checkBSplineSurface(this, start, UKnot, VKnot, Weight)) + { return res; + } res = new Geom_BSplineSurface(Poles, Weight, UKnot, VKnot, UMult, VMult, DegreeU, DegreeV); } @@ -967,7 +1031,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface res->RemoveUKnot(i, DegreeU - 1, GetEpsGeom()); // szv#4:S4163:12Mar99 `isC1=` not needed } else + { res->RemoveUKnot(i, DegreeU - 1, GetEpsGeom()); // szv#4:S4163:12Mar99 `isC1=` not needed + } } } @@ -983,7 +1049,9 @@ occ::handle IGESToBRep_BasicSurface::TransferBSplineSurface res->RemoveVKnot(i, DegreeV - 1, GetEpsGeom()); // szv#4:S4163:12Mar99 `isC1=` not needed } else + { res->RemoveVKnot(i, DegreeV - 1, GetEpsGeom()); // szv#4:S4163:12Mar99 `isC1=` not needed + } } } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_CurveAndSurface.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_CurveAndSurface.cxx index 4f6d5d9580..aa73ef3f2f 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_CurveAndSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_CurveAndSurface.cxx @@ -147,7 +147,9 @@ void IGESToBRep_CurveAndSurface::SetModel(const occ::handle& if (unitfactor != 1.) { if (myTP->TraceLevel() > 2) - myTP->Messenger()->SendInfo() << "UnitFactor = " << unitfactor << std::endl; + { + myTP->Messenger()->SendInfo() << "UnitFactor = " << unitfactor << '\n'; + } myUnitFactor = unitfactor; } UpdateMinMaxTol(); @@ -242,7 +244,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( if (IGESToBRep::IsCurveAndSurface(start)) { if (onlyvisible && start->BlankStatus() == 1) + { return res; + } try { OCC_CATCH_SIGNALS @@ -260,7 +264,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) { if (onlyvisible && start->BlankStatus() == 1) + { return res; + } DeclareAndCast(IGESBasic_SingularSubfigure, st408, start); occ::handle stsub = st408->Subfigure(); @@ -324,7 +330,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( continue; } if (onlyvisible && st308->AssociatedEntity(i)->BlankStatus() == 1) + { continue; + } if (HasShapeResult(st308->AssociatedEntity(i))) { @@ -361,7 +369,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( else if (start->IsKind(STANDARD_TYPE(IGESBasic_Group))) { if (onlyvisible && start->BlankStatus() == 1) + { return res; + } DeclareAndCast(IGESBasic_Group, st402f1, start); TopoDS_Compound group; @@ -389,7 +399,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( } if (onlyvisible && st402f1->Entity(i)->BlankStatus() == 1) + { continue; + } if (HasShapeResult(st402f1->Entity(i))) { @@ -435,7 +447,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( { if (onlyvisible && start->BlankStatus() == 1) + { return res; + } DeclareAndCast(IGESBasic_GroupWithoutBackP, st402f7, start); TopoDS_Compound group; @@ -464,7 +478,9 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry( } if (onlyvisible && st402f7->Entity(i)->BlankStatus() == 1) + { continue; + } if (HasShapeResult(st402f7->Entity(i))) { @@ -560,7 +576,9 @@ bool IGESToBRep_CurveAndSurface::HasShapeResult(const occ::handleFind(start)); if (binder.IsNull()) + { return false; + } return binder->HasResult(); } @@ -573,9 +591,13 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult( DeclareAndCast(TransferBRep_ShapeBinder, binder, myTP->Find(start)); if (binder.IsNull()) + { return res; + } if (binder->HasResult()) + { res = binder->Result(); + } return res; } @@ -596,7 +618,9 @@ int IGESToBRep_CurveAndSurface::NbShapeResult(const occ::handleFind(start)); if (binder.IsNull()) + { return nbres; + } nbres = binder->NbShapes(); return nbres; } @@ -611,10 +635,14 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult( DeclareAndCast(TransferBRep_ShapeListBinder, binder, myTP->Find(start)); if (binder.IsNull()) + { return res; + } if (num <= binder->NbShapes()) + { res = binder->Shape(num); + } return res; } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_IGESBoundary.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_IGESBoundary.cxx index bf89ac754c..f22e52a623 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_IGESBoundary.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_IGESBoundary.cxx @@ -148,7 +148,9 @@ bool IGESToBRep_IGESBoundary::Transfer( int len3d = 0, len2d = 0; occ::handle>> seq3d, seq2d; if (usescurve) + { len3d = scurve3d->NbEdges(); + } else { IGESToBRep::IGESCurveToSequenceOfIGESCurve(icurve3d, seq3d); @@ -157,24 +159,36 @@ bool IGESToBRep_IGESBoundary::Transfer( if (!curves2d.IsNull()) { for (int i = 1; i <= curves2d->Length(); i++) + { IGESToBRep::IGESCurveToSequenceOfIGESCurve(curves2d->Value(i), seq2d); + } len2d = seq2d->Length(); } if (len3d == 0) + { GTranslate3d = false; + } else if (len2d == 0) + { GTranslate2d = false; + } if (GTranslate3d && GTranslate2d) { // Setting preference in the case of inconsistency between 3D and 2D if (myfilepreference == 2) + { Preferred3d = false; + } else if (myfilepreference == 3) + { Preferred2d = false; + } else + { Preferred3d = false; + } } if (GTranslate3d && GTranslate2d && len3d != len2d) { @@ -187,7 +201,9 @@ bool IGESToBRep_IGESBoundary::Transfer( if (GTranslate3d && !GTranslate2d) { if (usescurve) + { Gsewd->Add(scurve3d->Wire()); + } else { TopoDS_Shape Sh = TC.TransferTopoCurve(icurve3d); @@ -200,8 +216,10 @@ bool IGESToBRep_IGESBoundary::Transfer( Gsewd->Add(Gsewd3d->Wire()); } else + { Gsewd->Add( Sh); // Gsewd = Gsewd3d is impossible to avoid sharing of sewd (UK1.igs entity 7) + } } } } @@ -211,10 +229,14 @@ bool IGESToBRep_IGESBoundary::Transfer( { TopoDS_Shape Sh = TC.Transfer2dTopoCurve(curves2d->Value(i), myface, mytrsf, myuFact); if (!Sh.IsNull()) + { Gsewd2d->Add(Sh); + } } if (toreverse2d) + { ReverseCurves2d(Gsewd2d, myface); + } Gsewd->Add(Gsewd2d->Wire()); } else if (GTranslate3d && GTranslate2d) @@ -228,7 +250,9 @@ bool IGESToBRep_IGESBoundary::Transfer( occ::handle Lsewd3d = new ShapeExtend_WireData; TC.SetBadCase(false); //: 27 if (usescurve) + { Lsewd3d->Add(scurve3d->Edge(i)); + } else { TopoDS_Shape shape3d = @@ -237,10 +261,14 @@ bool IGESToBRep_IGESBoundary::Transfer( { Lsewd3d->Add(shape3d); if (toreverse3d) + { ReverseCurves3d(Lsewd3d); + } } else + { LTranslate3d = false; + } } Gsewd3d->Add(Lsewd3d->Wire()); @@ -254,11 +282,15 @@ bool IGESToBRep_IGESBoundary::Transfer( { Lsewd2d->Add(shape2d); if (toreverse2d) + { ReverseCurves2d(Lsewd2d, myface); + } Gsewd2d->Add(Lsewd2d->Wire()); } else + { LTranslate2d = false; + } if (LTranslate3d && LTranslate2d && Lsewd3d->NbEdges() != Lsewd2d->NbEdges()) { @@ -267,9 +299,13 @@ bool IGESToBRep_IGESBoundary::Transfer( } occ::handle Lsewd; // Lsewd3d or Lsewd2d or Lsewd3d+pcurve if (LTranslate3d && !LTranslate2d) + { Lsewd = Lsewd3d; + } else if (!LTranslate3d && LTranslate2d) + { Lsewd = Lsewd2d; + } else { Lsewd = Lsewd3d; @@ -278,7 +314,9 @@ bool IGESToBRep_IGESBoundary::Transfer( { TopoDS_Edge edge3d = Lsewd3d->Edge(iedge), edge2d = Lsewd2d->Edge(iedge); if (!IGESToBRep::TransferPCurve(edge2d, edge3d, myface)) + { continue; + } } } Gsewd->Add(Lsewd->Wire()); @@ -319,19 +357,23 @@ void IGESToBRep_IGESBoundary::ReverseCurves3d(const occ::handle curve = BRep_Tool::Curve(oldedge, L, p1, p2); - if (curve->IsPeriodic()) // #21 + if (curve->IsPeriodic()) + { // #21 ShapeBuild_Edge().MakeEdge(newedge, curve->Reversed(), L, curve->ReversedParameter(p2), curve->ReversedParameter(p1)); + } else + { ShapeBuild_Edge().MakeEdge( newedge, curve->Reversed(), L, std::max(curve->ReversedParameter(curve->LastParameter()), curve->ReversedParameter(p2)), std::min(curve->ReversedParameter(curve->FirstParameter()), curve->ReversedParameter(p1))); + } newedge.Orientation(TopAbs::Reverse(oldedge.Orientation())); // sewd->Set (newedge, i); B.Add(W, newedge); @@ -361,12 +403,15 @@ void IGESToBRep_IGESBoundary::ReverseCurves2d(const occ::handleIsPeriodic()) + { ShapeBuild_Edge().MakeEdge(newedge, curve->Reversed(), face, curve->ReversedParameter(p2), curve->ReversedParameter(p1)); + } else + { ShapeBuild_Edge().MakeEdge( newedge, curve->Reversed(), @@ -374,6 +419,7 @@ void IGESToBRep_IGESBoundary::ReverseCurves2d(const occ::handleFirstParameter(), curve->ReversedParameter(p2)), // BUC50001 entity 936 2DForced std::min(curve->LastParameter(), curve->ReversedParameter(p1))); + } newedge.Orientation(oldedge.Orientation()); sewd->Set(newedge, i); } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Reader.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Reader.cxx index 047a7aae3f..144b28b272 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Reader.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_Reader.cxx @@ -128,7 +128,9 @@ IGESToBRep_Reader::IGESToBRep_Reader() int IGESToBRep_Reader::LoadFile(const char* const filename) { if (theProc.IsNull()) + { theProc = new Transfer_TransientProcess; + } occ::handle TF = theProc->Messenger(); // Message for Diagnostic file. @@ -221,11 +223,17 @@ int IGESToBRep_Reader::LoadFile(const char* const filename) int minute, hour; c.Show(second, minute, hour, cpu); if (hour > 0) + { Sprintf(t, "%dh:%dm:%.2fs", hour, minute, second); + } else if (minute > 0) + { Sprintf(t, "%dm:%.2fs", minute, second); + } else + { Sprintf(t, "%.2fs", second); + } // Sending of message : End of Loading Msg8.Arg(t); TF->Send(Msg8, Message_Info); @@ -242,9 +250,13 @@ void IGESToBRep_Reader::SetModel(const occ::handle& model) theDone = false; theShapes.Clear(); if (theProc.IsNull()) + { theProc = new Transfer_TransientProcess(theModel->NbEntities()); + } else + { theProc->Clear(); + } } //============================================================================= @@ -310,7 +322,9 @@ void IGESToBRep_Reader::TransferRoots(const bool onlyvisible, const Message_ProgressRange& theProgress) { if (theModel.IsNull() || theProc.IsNull()) + { return; + } occ::handle TF = theProc->Messenger(); // Declaration of messages. @@ -365,7 +379,9 @@ void IGESToBRep_Reader::TransferRoots(const bool onlyvisible, Message_ProgressRange aRange = PS.Next(); occ::handle ent = theModel->Entity(i); if (SH.IsShared(ent) || !theActor->Recognize(ent)) + { continue; + } if (level > 0) { Message_Msg msg2070("IGES_2070"); @@ -416,11 +432,17 @@ void IGESToBRep_Reader::TransferRoots(const bool onlyvisible, int minute, hour; c.Show(second, minute, hour, cpu); if (hour > 0) + { Sprintf(t, "%dh:%dm:%.2fs", hour, minute, second); + } else if (minute > 0) + { Sprintf(t, "%dm:%.2fs", minute, second); + } else + { Sprintf(t, "%.2fs", second); + } // Sending of message : End of Loading msg2065.Arg(t); TF->Send(msg2065, Message_Info); @@ -466,7 +488,9 @@ bool IGESToBRep_Reader::Transfer(const int num, const Message_ProgressRange& the msg2035.Arg(Ival); TF->Send(msg2035, Message_Info); if (Ival == 0) + { eps = theModel->GlobalSection().Resolution(); + } else { // mjm : modif du 19/12/97 pour prise en compte effective du parametre @@ -489,7 +513,9 @@ bool IGESToBRep_Reader::Transfer(const int num, const Message_ProgressRange& the CAS.SetSurfaceCurve(Ival); if (eps > 1.E-08) + { CAS.SetEpsGeom(eps); + } CAS.SetTransferProcess(theProc); bool exceptionRaised = false; @@ -501,7 +527,9 @@ bool IGESToBRep_Reader::Transfer(const int num, const Message_ProgressRange& the OCC_CATCH_SIGNALS shape = CAS.TransferGeometry(ent, aPS.Next()); if (aPS.UserBreak()) + { return false; + } } catch (Standard_Failure const&) { @@ -558,11 +586,17 @@ bool IGESToBRep_Reader::Transfer(const int num, const Message_ProgressRange& the int minute, hour; c.Show(second, minute, hour, cpu); if (hour > 0) + { Sprintf(t, "%dh:%dm:%.2fs", hour, minute, second); + } else if (minute > 0) + { Sprintf(t, "%dm:%.2fs", minute, second); + } else + { Sprintf(t, "%.2fs", second); + } // Sending of message : End of Loading msg2065.Arg(t); TF->Send(msg2065, Message_Info); @@ -589,7 +623,9 @@ TopoDS_Shape IGESToBRep_Reader::Shape(const int num) const { TopoDS_Shape res; if (num > 0 && num <= theShapes.Length()) + { res = theShapes.Value(num); + } return res; } @@ -600,16 +636,22 @@ TopoDS_Shape IGESToBRep_Reader::OneShape() const TopoDS_Shape res; int nb = theShapes.Length(); if (nb == 0) + { return res; + } else if (nb == 1) + { return theShapes.Value(1); + } else { TopoDS_Compound C; BRep_Builder B; B.MakeCompound(C); for (int i = 1; i <= nb; i++) + { B.Add(C, theShapes.Value(i)); + } return C; } } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoCurve.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoCurve.cxx index a0f238fd61..88b9e5007a 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoCurve.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoCurve.cxx @@ -142,9 +142,13 @@ TopoDS_Vertex IGESToBRep_TopoCurve::TransferPoint(const occ::handleHasTransf()) + { point = start->TransformedValue(); + } else + { point = start->Value(); + } point.Scale(gp_Pnt(0, 0, 0), GetUnitFactor()); B.MakeVertex(V1, point, Precision::Confusion()); // S4135: GetEpsGeom()*GetUnitFactor() @@ -185,9 +189,13 @@ TopoDS_Vertex IGESToBRep_TopoCurve::Transfer2dPoint(const occ::handleHasTransf()) + { point = gp_Pnt(start->TransformedValue().X(), start->TransformedValue().Y(), 0.); + } else + { point = gp_Pnt(start->Value().X(), start->Value().Y(), 0.); + } B.MakeVertex(V1, point, Precision::Confusion()); // S4135: GetEpsCoeff() return V1; @@ -263,13 +271,19 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferCompositeCurveGeneral( { TopoDS_Shape shape; //: 13 = TransferTopoCurve(IgesEnt); if (is2d) + { shape = Transfer2dTopoCurve(IgesEnt, face, trans, uFact); //: 13 + } else + { shape = TransferTopoCurve(IgesEnt); //: 13 + } if (!shape.IsNull()) { if (shape.ShapeType() == TopAbs_VERTEX) + { continue; + } occ::handle nextsewd = new ShapeExtend_WireData; nextsewd->Add(shape); @@ -513,9 +527,13 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferCurveOnFace( bool okCurve = true, okCurve3d = true, okCurve2d = true; int filepreference = 0; if (start->PreferenceMode() == 1) + { filepreference = 2; + } else if (start->PreferenceMode() == 2) + { filepreference = 3; + } occ::handle>> Curves2d = new NCollection_HArray1>(1, 1); Curves2d->SetValue(1, start->CurveUV()); @@ -586,9 +604,13 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferOffsetCurve( double Offset = start->FirstOffsetDistance(); gp_Dir NrmDir; if (start->HasTransf()) + { NrmDir = start->TransformedNormalVector(); + } else + { NrmDir = start->NormalVector(); + } //%11 pdn 12.01.99 CTS22023 NrmDir.Reverse(); @@ -667,7 +689,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferOffsetCurve( double first, last; Crv = BRep_Tool::Curve(anEdge, aLoc, first, last); if ((length + last - first) <= staPar) + { continue; + } if (length >= endPar) { if (begin) @@ -900,8 +924,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::Transfer2dTopoCurve( } // S4054 if (IGESToBRep::IsBasicCurve(start)) + { res = Transfer2dTopoBasicCurve(start, face, trans, uFact); - + } else if (start->IsKind(STANDARD_TYPE(IGESGeom_CompositeCurve))) { DeclareAndCast(IGESGeom_CompositeCurve, st102, start); @@ -955,12 +980,18 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferTopoBasicCurve( { occ::handle BSplineC = occ::down_cast(C); if (BSplineC->Degree() == 1) + { ApproxBSplineCurve(BSplineC); + } else + { TheCurves.Append(C); + } } else + { TheCurves.Append(C); + } // Si la courbe est une BSpline, il ne faut pas qu`elle soit C0. // sinon inutilisable dans les algos de topologie ... @@ -1074,7 +1105,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferTopoBasicCurve( return myshape; } else + { myedge = TopoDS::Edge(TopoDS_Iterator(myshape).Value()); + } // added by rln 23/12/97 CSR# UKI60155 entity 208 (CircularArc) // if Starting and Terminating point are the same this can be caused by either error in the file @@ -1082,7 +1115,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferTopoBasicCurve( // 2d representation if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc)) && occ::down_cast(start)->IsClosed()) + { TheBadCase = true; + } SetShapeResult(start, myshape); return myedge; } @@ -1127,12 +1162,18 @@ TopoDS_Shape IGESToBRep_TopoCurve::Transfer2dTopoBasicCurve( { occ::handle BSplineC2d = occ::down_cast(C2d); if (BSplineC2d->Degree() == 1) + { Approx2dBSplineCurve(BSplineC2d); + } else + { TheCurves2d.Append(C2d); + } } else + { TheCurves2d.Append(C2d); + } // Si la courbe est une BSpline, il ne faut pas qu`elle soit C0. // on construit un wire avec des morceaux de courbes C1. @@ -1174,11 +1215,15 @@ TopoDS_Shape IGESToBRep_TopoCurve::Transfer2dTopoBasicCurve( }*/ if (trans.Form() != gp_Identity) + { mycurve2d->Transform(trans); + } gp_Trsf2d ntrsf; if (mysurf->IsKind(STANDARD_TYPE(Geom_Plane))) + { ntrsf.SetScale(gp_Pnt2d(0, 0), GetUnitFactor()); + } double a = mycurve2d->FirstParameter(), b = mycurve2d->LastParameter(); ShapeBuild_Edge sbe; @@ -1258,7 +1303,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::Transfer2dTopoBasicCurve( // the same modifications as in TransferBasicCurve() if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc)) && occ::down_cast(start)->IsClosed()) + { TheBadCase = true; + } return myedge; } @@ -1365,9 +1412,13 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferBoundaryOnFace( bool okCurve = true, okCurve3d = true, okCurve2d = true; int filepreference = 0; if (start->PreferenceType() == 2) + { filepreference = 2; + } else if (start->PreferenceType() == 1) + { filepreference = 3; + } bool Result = true; occ::handle IB = @@ -1384,7 +1435,9 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferBoundaryOnFace( SendWarning(start, Msg1135); } else + { Curves2d = start->ParameterCurves(i); + } Result = Result & IB->Transfer(okCurve, okCurve3d, @@ -1455,7 +1508,9 @@ occ::handle IGESToBRep_TopoCurve::Curve(const int num) const { occ::handle res; if (num > 0 && num <= TheCurves.Length()) + { res = TheCurves.Value(num); + } return res; } @@ -1484,7 +1539,9 @@ occ::handle IGESToBRep_TopoCurve::Curve2d(const int num) const { occ::handle res; if (num > 0 && num <= TheCurves2d.Length()) + { res = TheCurves2d.Value(num); + } return res; } diff --git a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoSurface.cxx b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoSurface.cxx index acb2808a27..86d734a4cf 100644 --- a/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoSurface.cxx +++ b/src/DataExchange/TKDEIGES/IGESToBRep/IGESToBRep_TopoSurface.cxx @@ -161,15 +161,21 @@ static bool extractCurve3d(const TopoDS_Shape& theEdges, occ::handle { TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current()); if (anEdge.IsNull()) + { continue; + } howMuch++; theCurve = BRep_Tool::Curve(anEdge, f, l); } if (howMuch != 1 || theCurve.IsNull()) + { return false; + } if (f != theCurve->FirstParameter() || l != theCurve->LastParameter()) + { theCurve = new Geom_TrimmedCurve(theCurve, f, l); + } return true; } @@ -332,7 +338,9 @@ static void reparamBSpline(occ::handle& curve, const double First, c if (!curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { if (curve->FirstParameter() < First || curve->LastParameter() > Last) + { curve = new Geom_TrimmedCurve(curve, First, Last); + } bscurve = GeomConvert::CurveToBSplineCurve(curve, Convert_RationalC1); } else @@ -342,7 +350,9 @@ static void reparamBSpline(occ::handle& curve, const double First, c } if (bscurve.IsNull()) + { return; + } NCollection_Array1 Knots(bscurve->Knots()); BSplCLib::Reparametrize(0., 1., Knots); @@ -360,7 +370,9 @@ static void ReparamCurve(TopoDS_Edge& edge) // if ( Abs (First) <= Precision::PConfusion() && Abs (Last - 1.) <= Precision::PConfusion() ) // return; if (!curve->IsKind(STANDARD_TYPE(Geom_Line))) + { return; + } reparamBSpline(curve, First, Last); @@ -515,7 +527,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface( TopoDS_Edge edge2 = TopoDS::Edge(shape2); ReparamCurve(edge2); if (dirflag == 1) + { shape2.Reverse(); + } nbEdges2 = 1; } break; @@ -605,13 +619,17 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface( occ::down_cast(BRep_Tool::Curve(edge, L, First, Last)->Copy()); if (std::abs(First) <= Precision::PConfusion() && std::abs(Last - 1.) <= Precision::PConfusion()) + { continue; + } occ::handle bscurve; if (!curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { if (curve->FirstParameter() < First || curve->LastParameter() > Last) + { curve = new Geom_TrimmedCurve(curve, First, Last); + } bscurve = GeomConvert::CurveToBSplineCurve(curve, Convert_RationalC1); } else @@ -627,9 +645,13 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface( B.UpdateEdge(edge, bscurve, L, Precision::Confusion()); B.Range(edge, 0., 1); if (i == 1) + { shape1 = edge; + } else + { shape2 = edge; + } } res = BRepFill::Face(TopoDS::Edge(shape1), TopoDS::Edge(shape2)); @@ -749,7 +771,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution( double deltaAngle = endAngle - startAngle; bool IsFullAngle = (deltaAngle > 2. * M_PI - Precision::PConfusion()); if (IsFullAngle) + { deltaAngle = 2. * M_PI; // ** CKY 18-SEP-1996 + } // il faudra translater les courbes 2d de startAngle pour // be in phase IGES and BRep startLoc.SetRotation(revolAxis, startAngle); @@ -792,7 +816,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution( } if (aMakeF.IsDone()) + { res = aMakeF.Face(); + } } // if ( !aResultSurf.IsNull()) } // if (extractCurve3d(generatrix, aBasisCurve)) } @@ -939,7 +965,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTabulatedCylinder( dir.Magnitude(), Precision::Confusion()); if (aMakeF.IsDone()) + { res = aMakeF.Face(); + } } } } @@ -1126,7 +1154,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferOffsetSurface( } // smh#12 if (res.IsNull()) + { res = face; + } geomSupport = BRep_Tool::Surface(TopoDS::Face(res)); double umin, umax, vmin, vmax; geomSupport->Bounds(umin, umax, vmin, vmax); @@ -1441,7 +1471,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferBoundedSurface( face.EmptyCopy(); for (int i = 1; i <= st->NbBoundaries(); i++) + { TC.TransferBoundaryOnFace(face, st->Boundary(i), trans, uFact); + } BRepTools::Update(face); //: p4 // #22 rln 01.06.98 UK3.igs entity 1279 @@ -1653,7 +1685,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferPlaneParts(const occ::handleHasBoundingCurveHole()) + { wire.Reverse(); + } } else if (st->HasBoundingCurveHole()) + { wire.Reverse(); + } //: 3 by ABV 5 Nov 97: set plane to be finite //: 3 if (first) B.Add (plane,wire); if (first) @@ -1733,9 +1775,13 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferPlaneParts(const occ::handle Curve3d = BRep_Tool::Curve(theedge, First, Last); if (Precision::IsNegativeInfinite(First)) + { First = 0.; + } if (Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { @@ -1900,9 +1948,13 @@ TopoDS_Shape IGESToBRep_TopoSurface::ParamSurface(const occ::handleCenter(), gp_Dir2d(gp_Dir2d::D::X)), circ->Radius()), startpoint); if (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) + { paramv += ShapeAnalysis::AdjustToPeriod(paramv, -M_PI, M_PI); + } else if (Surf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) + { paramv += ShapeAnalysis::AdjustToPeriod(paramv, 0, M_PI * 2); + } } } else if (st->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) @@ -1922,9 +1974,13 @@ TopoDS_Shape IGESToBRep_TopoSurface::ParamSurface(const occ::handleEndAngle()); } else + { paramu = 0.; + } if (isrf->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) { @@ -1996,7 +2054,9 @@ TopoDS_Shape IGESToBRep_TopoSurface::ParamSurface(const occ::handle 0) + { paramv = paramv * 180. / M_PI; + } cscale = M_PI / 180.; uscale = 1.; } diff --git a/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_EditHeader.cxx b/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_EditHeader.cxx index e287159fee..f4c745f50e 100644 --- a/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_EditHeader.cxx +++ b/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_EditHeader.cxx @@ -26,9 +26,13 @@ IMPLEMENT_STANDARD_RTTIEXT(APIHeaderSection_EditHeader, IFSelect_Editor) static bool IsTimeStamp(const occ::handle& val) { if (val.IsNull()) + { return false; + } if (val->Length() != 19) + { return false; + } // On y va char dizmois = val->Value(6); char dizjour = val->Value(9); @@ -40,79 +44,119 @@ static bool IsTimeStamp(const occ::handle& val) { case 1: if (uncar != '1' && uncar != '2') + { return false; + } break; case 2: case 3: case 4: if (uncar < '0' || uncar > '9') + { return false; + } break; case 5: if (uncar != '-') + { return false; + } [[fallthrough]]; case 6: if (uncar != '0' && uncar != '1') + { return false; + } break; case 7: if (uncar < '0' || uncar > '9') + { return false; + } if (dizmois == '1' && (uncar < '0' || uncar > '2')) + { return false; + } break; case 8: if (uncar != '-') + { return false; + } [[fallthrough]]; case 9: if (uncar < '0' || uncar > '3') + { return false; + } break; case 10: if (uncar < '0' || uncar > '9') + { return false; + } if (dizjour == '3' && (uncar != '0' && uncar != '1')) + { return false; + } break; case 11: if (uncar != 'T') + { return false; + } [[fallthrough]]; case 12: if (uncar < '0' || uncar > '2') + { return false; + } break; case 13: if (uncar < '0' || uncar > '9') + { return false; + } if (dizheur == '2' && (uncar < '0' || uncar > '3')) + { return false; + } break; case 14: if (uncar != ':') + { return false; + } [[fallthrough]]; case 15: if (uncar < '0' || uncar > '5') + { return false; + } break; case 16: if (uncar < '0' || uncar > '9') + { return false; + } break; case 17: if (uncar != ':') + { return false; + } [[fallthrough]]; case 18: if (uncar < '0' || uncar > '5') + { return false; + } break; case 19: if (uncar < '0' || uncar > '9') + { return false; + } break; default: break; @@ -176,7 +220,9 @@ bool APIHeaderSection_EditHeader::Load(const occ::handle& for { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } APIHeaderSection_MakeHeader mkh(modl); @@ -202,32 +248,54 @@ bool APIHeaderSection_EditHeader::Apply(const occ::handle& fo { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } APIHeaderSection_MakeHeader mkh(modl); if (form->IsModified(1)) + { mkh.SetName(form->EditedValue(1)); + } if (form->IsModified(2)) + { mkh.SetTimeStamp(form->EditedValue(2)); + } if (form->IsModified(3)) + { mkh.SetAuthorValue(1, form->EditedValue(3)); + } if (form->IsModified(4)) + { mkh.SetOrganizationValue(1, form->EditedValue(4)); + } if (form->IsModified(5)) + { mkh.SetPreprocessorVersion(form->EditedValue(5)); + } if (form->IsModified(6)) + { mkh.SetOriginatingSystem(form->EditedValue(6)); + } if (form->IsModified(7)) + { mkh.SetAuthorisation(form->EditedValue(7)); + } if (form->IsModified(8)) + { mkh.SetSchemaIdentifiersValue(1, form->EditedValue(8)); + } if (form->IsModified(9)) + { mkh.SetDescriptionValue(1, form->EditedValue(9)); + } if (form->IsModified(10)) + { mkh.SetImplementationLevel(form->EditedValue(10)); + } mkh.Apply(occ::down_cast(model)); diff --git a/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_MakeHeader.cxx b/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_MakeHeader.cxx index d45f26ec06..57083a67bc 100644 --- a/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_MakeHeader.cxx +++ b/src/DataExchange/TKDESTEP/APIHeaderSection/APIHeaderSection_MakeHeader.cxx @@ -46,21 +46,27 @@ APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader( GetCasted(HeaderSection_FileName, model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileName))); } else + { done = false; + } if (model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))) { fs = GetCasted(HeaderSection_FileSchema, model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))); } else + { done = false; + } if (model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))) { fd = GetCasted(HeaderSection_FileDescription, model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))); } else + { done = false; + } } APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader(const int shapetype) @@ -93,7 +99,9 @@ void APIHeaderSection_MakeHeader::Init(const char* const nameval) char timestamp[50]; if (fn.IsNull()) + { fn = new HeaderSection_FileName; + } occ::handle name = new TCollection_HAsciiString(nameval); fn->SetName(name); // clang-format off @@ -128,7 +136,9 @@ void APIHeaderSection_MakeHeader::Init(const char* const nameval) // - File Description if (fd.IsNull()) + { fd = new HeaderSection_FileDescription; + } occ::handle>> descr = new NCollection_HArray1>(1, 1); occ::handle descr1 = new TCollection_HAsciiString("Open CASCADE Model"); @@ -140,7 +150,9 @@ void APIHeaderSection_MakeHeader::Init(const char* const nameval) // - File Schema if (fs.IsNull()) + { fs = new HeaderSection_FileSchema; + } occ::handle>> schid = new NCollection_HArray1>(1, 1); occ::handle schid1 = new TCollection_HAsciiString(""); @@ -157,9 +169,13 @@ void APIHeaderSection_MakeHeader::Apply(const occ::handle& m { Interface_EntityIterator header = model->Header(); if (HasFd() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))) + { header.AddItem(fd); + } if (HasFn() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileName))) + { header.AddItem(fn); + } if (HasFs() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))) { @@ -168,7 +184,9 @@ void APIHeaderSection_MakeHeader::Apply(const occ::handle& m occ::handle>> schid = fs->SchemaIdentifiers(); if (!schid.IsNull()) + { sch = schid->Value(1); + } else { schid = new NCollection_HArray1>(1, 1); @@ -177,21 +195,29 @@ void APIHeaderSection_MakeHeader::Apply(const occ::handle& m if (!sch.IsNull()) { if (sch->Length() < 2) + { sch.Nullify(); + } } // not defined if (sch.IsNull()) { occ::handle stepro = occ::down_cast(model->Protocol()); if (!stepro.IsNull()) + { sch = new TCollection_HAsciiString(stepro->SchemaName(model)); + } if (!sch.IsNull()) + { schid->SetValue(1, sch); + } } header.AddItem(fs); } model->ClearHeader(); for (header.Start(); header.More(); header.Next()) + { model->AddHeaderEntity(header.Value()); + } } // ======== @@ -256,7 +282,9 @@ void APIHeaderSection_MakeHeader::SetNameFromShapeType(const int shapetype) void APIHeaderSection_MakeHeader::SetName(const occ::handle& aName) { if (!fn.IsNull()) + { fn->SetName(aName); + } } occ::handle APIHeaderSection_MakeHeader::Name() const @@ -268,7 +296,9 @@ void APIHeaderSection_MakeHeader::SetTimeStamp( const occ::handle& aTimeStamp) { if (!fn.IsNull()) + { fn->SetTimeStamp(aTimeStamp); + } } occ::handle APIHeaderSection_MakeHeader::TimeStamp() const @@ -280,7 +310,9 @@ void APIHeaderSection_MakeHeader::SetAuthor( const occ::handle>>& aAuthor) { if (!fn.IsNull()) + { fn->SetAuthor(aAuthor); + } } void APIHeaderSection_MakeHeader::SetAuthorValue( @@ -288,10 +320,14 @@ void APIHeaderSection_MakeHeader::SetAuthorValue( const occ::handle& aAuthor) { if (fn.IsNull()) + { return; + } occ::handle>> li = fn->Author(); if (num >= li->Lower() && num <= li->Upper()) + { li->SetValue(num, aAuthor); + } } occ::handle>> @@ -314,7 +350,9 @@ void APIHeaderSection_MakeHeader::SetOrganization( const occ::handle>>& aOrganization) { if (!fn.IsNull()) + { fn->SetOrganization(aOrganization); + } } void APIHeaderSection_MakeHeader::SetOrganizationValue( @@ -322,10 +360,14 @@ void APIHeaderSection_MakeHeader::SetOrganizationValue( const occ::handle& aOrgan) { if (fn.IsNull()) + { return; + } occ::handle>> li = fn->Organization(); if (num >= li->Lower() && num <= li->Upper()) + { li->SetValue(num, aOrgan); + } } occ::handle>> @@ -349,7 +391,9 @@ void APIHeaderSection_MakeHeader::SetPreprocessorVersion( const occ::handle& aPreprocessorVersion) { if (!fn.IsNull()) + { fn->SetPreprocessorVersion(aPreprocessorVersion); + } } occ::handle APIHeaderSection_MakeHeader::PreprocessorVersion() const @@ -361,7 +405,9 @@ void APIHeaderSection_MakeHeader::SetOriginatingSystem( const occ::handle& aOriginatingSystem) { if (!fn.IsNull()) + { fn->SetOriginatingSystem(aOriginatingSystem); + } } occ::handle APIHeaderSection_MakeHeader::OriginatingSystem() const @@ -373,7 +419,9 @@ void APIHeaderSection_MakeHeader::SetAuthorisation( const occ::handle& aAuthorisation) { if (!fn.IsNull()) + { fn->SetAuthorisation(aAuthorisation); + } } occ::handle APIHeaderSection_MakeHeader::Authorisation() const @@ -399,7 +447,9 @@ void APIHeaderSection_MakeHeader::SetSchemaIdentifiers( const occ::handle>>& aSchemaIdentifiers) { if (!fs.IsNull()) + { fs->SetSchemaIdentifiers(aSchemaIdentifiers); + } } void APIHeaderSection_MakeHeader::SetSchemaIdentifiersValue( @@ -407,11 +457,15 @@ void APIHeaderSection_MakeHeader::SetSchemaIdentifiersValue( const occ::handle& aSchem) { if (fs.IsNull()) + { return; + } occ::handle>> li = fs->SchemaIdentifiers(); if (num >= li->Lower() && num <= li->Upper()) + { li->SetValue(num, aSchem); + } } occ::handle>> @@ -437,7 +491,9 @@ void APIHeaderSection_MakeHeader::AddSchemaIdentifier( const occ::handle& aSchem) { if (fs.IsNull()) + { fs = new HeaderSection_FileSchema; + } occ::handle>> idents = fs->SchemaIdentifiers(); @@ -446,7 +502,9 @@ void APIHeaderSection_MakeHeader::AddSchemaIdentifier( for (i = 1; !idents.IsNull() && i <= idents->Length(); i++) { if (aSchem->IsSameString(idents->Value(i))) + { return; + } } // add a subshema @@ -481,7 +539,9 @@ void APIHeaderSection_MakeHeader::SetDescription( const occ::handle>>& aDescription) { if (!fs.IsNull()) + { fd->SetDescription(aDescription); + } } void APIHeaderSection_MakeHeader::SetDescriptionValue( @@ -489,10 +549,14 @@ void APIHeaderSection_MakeHeader::SetDescriptionValue( const occ::handle& aDescr) { if (fd.IsNull()) + { return; + } occ::handle>> li = fd->Description(); if (num >= li->Lower() && num <= li->Upper()) + { li->SetValue(num, aDescr); + } } occ::handle>> @@ -516,7 +580,9 @@ void APIHeaderSection_MakeHeader::SetImplementationLevel( const occ::handle& aImplementationLevel) { if (!fd.IsNull()) + { fd->SetImplementationLevel(aImplementationLevel); + } } occ::handle APIHeaderSection_MakeHeader::ImplementationLevel() const diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve_gen.pxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve_gen.pxx index 93cd5daf94..2b77679fd0 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve_gen.pxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve_gen.pxx @@ -41,9 +41,13 @@ for (i = P.Lower(); i <= P.Upper(); i++) Form = StepGeom_bscfUnspecified; if (BS->IsClosed()) +{ Fermeture = StepData_LTrue; +} else +{ Fermeture = StepData_LFalse; +} Selfinter = StepData_LFalse; @@ -66,13 +70,21 @@ for (i = K.Lower(); i <= K.Upper(); i++) Distribution = BS->KnotDistribution(); if (Distribution == GeomAbs_NonUniform) +{ KnotSpec = StepGeom_ktUnspecified; +} else if (Distribution == GeomAbs_Uniform) +{ KnotSpec = StepGeom_ktUniformKnots; +} else if (Distribution == GeomAbs_QuasiUniform) +{ KnotSpec = StepGeom_ktQuasiUniformKnots; +} else +{ KnotSpec = StepGeom_ktPiecewiseBezierKnots; +} const NCollection_Array1& W = BS->WeightsArray(); ListWeights = new NCollection_HArray1(1, N); diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnots_gen.pxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnots_gen.pxx index 90e505b68b..4e9d6cc5b3 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnots_gen.pxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineCurveWithKnots_gen.pxx @@ -41,9 +41,13 @@ for (i = P.Lower(); i <= P.Upper(); i++) Form = StepGeom_bscfUnspecified; if (BS->IsClosed()) +{ Fermeture = StepData_LTrue; +} else +{ Fermeture = StepData_LFalse; +} Selfinter = StepData_LFalse; @@ -66,13 +70,21 @@ for (i = K.Lower(); i <= K.Upper(); i++) Distribution = BS->KnotDistribution(); if (Distribution == GeomAbs_NonUniform) +{ KnotSpec = StepGeom_ktUnspecified; +} else if (Distribution == GeomAbs_Uniform) +{ KnotSpec = StepGeom_ktUniformKnots; +} else if (Distribution == GeomAbs_QuasiUniform) +{ KnotSpec = StepGeom_ktQuasiUniformKnots; +} else +{ KnotSpec = StepGeom_ktPiecewiseBezierKnots; +} BSWK = new StepGeom_BSplineCurveWithKnots; occ::handle name = new TCollection_HAsciiString(""); diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnots.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnots.cxx index 9d840870b7..317f9c16a8 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnots.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnots.cxx @@ -72,14 +72,22 @@ GeomToStep_MakeBSplineSurfaceWithKnots::GeomToStep_MakeBSplineSurfaceWithKnots( aSurfaceForm = StepGeom_bssfUnspecified; if (BS->IsUClosed()) + { aUClosed = StepData_LTrue; + } else + { aUClosed = StepData_LFalse; + } if (BS->IsVClosed()) + { aVClosed = StepData_LTrue; + } else + { aVClosed = StepData_LFalse; + } aSelfIntersect = StepData_LFalse; @@ -118,15 +126,25 @@ GeomToStep_MakeBSplineSurfaceWithKnots::GeomToStep_MakeBSplineSurfaceWithKnots( UDistribution = BS->UKnotDistribution(); VDistribution = BS->VKnotDistribution(); if (UDistribution == GeomAbs_NonUniform && VDistribution == GeomAbs_NonUniform) + { KnotSpec = StepGeom_ktUnspecified; + } else if (UDistribution == GeomAbs_Uniform && VDistribution == GeomAbs_Uniform) + { KnotSpec = StepGeom_ktUniformKnots; + } else if (UDistribution == GeomAbs_QuasiUniform && VDistribution == GeomAbs_QuasiUniform) + { KnotSpec = StepGeom_ktQuasiUniformKnots; + } else if (UDistribution == GeomAbs_PiecewiseBezier && VDistribution == GeomAbs_PiecewiseBezier) + { KnotSpec = StepGeom_ktPiecewiseBezierKnots; + } else + { KnotSpec = StepGeom_ktUnspecified; + } BSWK = new StepGeom_BSplineSurfaceWithKnots; occ::handle name = new TCollection_HAsciiString(""); diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx index 048ab76c2b..eabf9a5b7b 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx @@ -75,14 +75,22 @@ GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface:: aSurfaceForm = StepGeom_bssfUnspecified; if (BS->IsUClosed()) + { aUClosed = StepData_LTrue; + } else + { aUClosed = StepData_LFalse; + } if (BS->IsVClosed()) + { aVClosed = StepData_LTrue; + } else + { aVClosed = StepData_LFalse; + } aSelfIntersect = StepData_LFalse; @@ -121,15 +129,25 @@ GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface:: UDistribution = BS->UKnotDistribution(); VDistribution = BS->VKnotDistribution(); if (UDistribution == GeomAbs_NonUniform && VDistribution == GeomAbs_NonUniform) + { KnotSpec = StepGeom_ktUnspecified; + } else if (UDistribution == GeomAbs_Uniform && VDistribution == GeomAbs_Uniform) + { KnotSpec = StepGeom_ktUniformKnots; + } else if (UDistribution == GeomAbs_QuasiUniform && VDistribution == GeomAbs_QuasiUniform) + { KnotSpec = StepGeom_ktQuasiUniformKnots; + } else if (UDistribution == GeomAbs_PiecewiseBezier && VDistribution == GeomAbs_PiecewiseBezier) + { KnotSpec = StepGeom_ktPiecewiseBezierKnots; + } else + { KnotSpec = StepGeom_ktUnspecified; + } const NCollection_Array2& W = BS->WeightsArray(); aWeightsData = new NCollection_HArray2(1, NU, 1, NV); diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBoundedCurve.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBoundedCurve.cxx index 1efe6071a6..039faaffb1 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBoundedCurve.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeBoundedCurve.cxx @@ -127,7 +127,9 @@ GeomToStep_MakeBoundedCurve::GeomToStep_MakeBoundedCurve(const occ::handle& C, theCurve = MkBoundedC.Value(); } else + { done = false; + } } //============================================================================= @@ -188,7 +190,9 @@ GeomToStep_MakeCurve::GeomToStep_MakeCurve(const occ::handle& C, theCurve = aMaker.Value(); } else + { done = false; + } } //============================================================================= diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeElementarySurface.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeElementarySurface.cxx index 145c8f6f3f..774c419363 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeElementarySurface.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeElementarySurface.cxx @@ -75,7 +75,9 @@ GeomToStep_MakeElementarySurface::GeomToStep_MakeElementarySurface( theElementarySurface = MkPlane.Value(); } else + { done = false; + } } //============================================================================= diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSurface.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSurface.cxx index 20bb874bda..f69eefa250 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSurface.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSurface.cxx @@ -64,7 +64,9 @@ GeomToStep_MakeSurface::GeomToStep_MakeSurface(const occ::handle& GeomToStep_MakeSurface MkBasis(S1->BasisSurface(), theLocalFactors); done = MkBasis.IsDone(); if (!done) + { return; + } occ::handle Surf = new StepGeom_OffsetSurface; Surf->Init(new TCollection_HAsciiString(""), MkBasis.Value(), diff --git a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSweptSurface.cxx b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSweptSurface.cxx index 86fe6a703f..8251178f41 100644 --- a/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSweptSurface.cxx +++ b/src/DataExchange/TKDESTEP/GeomToStep/GeomToStep_MakeSweptSurface.cxx @@ -49,7 +49,9 @@ GeomToStep_MakeSweptSurface::GeomToStep_MakeSweptSurface(const occ::handle HeaderSection_FileDescription::Description int HeaderSection_FileDescription::NbDescription() const { if (description.IsNull()) + { return 0; + } return description->Length(); } diff --git a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileName.cxx b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileName.cxx index db01dd5a1a..9f29e91599 100644 --- a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileName.cxx +++ b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileName.cxx @@ -78,7 +78,9 @@ occ::handle HeaderSection_FileName::AuthorValue(const int HeaderSection_FileName::NbAuthor() const { if (author.IsNull()) + { return 0; + } return author->Length(); } @@ -102,7 +104,9 @@ occ::handle HeaderSection_FileName::OrganizationValue( int HeaderSection_FileName::NbOrganization() const { if (organization.IsNull()) + { return 0; + } return organization->Length(); } diff --git a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileSchema.cxx b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileSchema.cxx index b8434e5ff2..23691e9aaa 100644 --- a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileSchema.cxx +++ b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_FileSchema.cxx @@ -47,6 +47,8 @@ occ::handle HeaderSection_FileSchema::SchemaIdentifier int HeaderSection_FileSchema::NbSchemaIdentifiers() const { if (schemaIdentifiers.IsNull()) + { return 0; + } return schemaIdentifiers->Length(); } diff --git a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_Protocol.cxx b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_Protocol.cxx index abd533e0e6..2191e978dd 100644 --- a/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_Protocol.cxx +++ b/src/DataExchange/TKDESTEP/HeaderSection/HeaderSection_Protocol.cxx @@ -27,15 +27,25 @@ HeaderSection_Protocol::HeaderSection_Protocol() = default; int HeaderSection_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(HeaderSection_FileName)) + { return 1; + } else if (atype == STANDARD_TYPE(HeaderSection_FileDescription)) + { return 2; + } else if (atype == STANDARD_TYPE(HeaderSection_FileSchema)) + { return 3; + } else if (atype == STANDARD_TYPE(StepData_UndefinedEntity)) + { return 4; + } else + { return 0; + } } const char* HeaderSection_Protocol::SchemaName(const occ::handle&) const diff --git a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection.cxx b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection.cxx index 000a263375..7eb65b3186 100644 --- a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection.cxx +++ b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection.cxx @@ -29,7 +29,11 @@ void RWHeaderSection::Init() occ::handle proto = HeaderSection::Protocol(); StepData::AddHeaderProtocol(proto); if (rwm.IsNull()) + { rwm = new RWHeaderSection_ReadWriteModule; + } if (rwg.IsNull()) + { rwg = new RWHeaderSection_GeneralModule; + } } diff --git a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_GeneralModule.cxx b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_GeneralModule.cxx index 5e675e088a..79892935ac 100644 --- a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_GeneralModule.cxx +++ b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_GeneralModule.cxx @@ -42,7 +42,9 @@ void RWHeaderSection_GeneralModule::FillSharedCase(const int Interface_EntityIterator& iter) const { if (CN != 4) + { return; + } DeclareAndCast(StepData_UndefinedEntity, undf, ent); undf->FillShared(iter); @@ -74,12 +76,16 @@ void RWHeaderSection_GeneralModule::CopyCase(const int occ::handle>> auth = new NCollection_HArray1>(1, nba); for (i = 1; i <= nba; i++) + { auth->SetValue(i, new TCollection_HAsciiString(enfr->AuthorValue(i))); + } int nbo = enfr->NbOrganization(); occ::handle>> orga = new NCollection_HArray1>(1, nbo); for (i = 1; i <= nbo; i++) + { orga->SetValue(i, new TCollection_HAsciiString(enfr->OrganizationValue(i))); + } occ::handle prep = new TCollection_HAsciiString(enfr->PreprocessorVersion()); occ::handle orig = @@ -98,7 +104,9 @@ void RWHeaderSection_GeneralModule::CopyCase(const int occ::handle>> desc = new NCollection_HArray1>(1, nbd); for (i = 1; i <= nbd; i++) + { desc->SetValue(i, new TCollection_HAsciiString(enfr->DescriptionValue(i))); + } occ::handle impl = new TCollection_HAsciiString(enfr->ImplementationLevel()); ento->Init(desc, impl); @@ -113,7 +121,9 @@ void RWHeaderSection_GeneralModule::CopyCase(const int occ::handle>> sche = new NCollection_HArray1>(1, nbs); for (i = 1; i <= nbs; i++) + { sche->SetValue(i, new TCollection_HAsciiString(enfr->SchemaIdentifiersValue(i))); + } ento->Init(sche); } break; @@ -136,7 +146,9 @@ bool RWHeaderSection_GeneralModule::NewVoid(const int CN, occ::handle& ent) const { if (CN == 0) + { return false; + } switch (CN) { case 1: diff --git a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx index 6e6cfa388c..d77908ae04 100644 --- a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx +++ b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileDescription.cxx @@ -31,7 +31,9 @@ void RWHeaderSection_RWFileDescription::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "file_description has not 2 parameter(s)")) + { return; + } // --- own field : description --- @@ -48,7 +50,9 @@ void RWHeaderSection_RWFileDescription::ReadStep( { bool stat1 = data->ReadString(nsub1, i1, "description", ach, aDescriptionItem); if (stat1) + { aDescription->SetValue(i1, aDescriptionItem); + } } } } @@ -65,7 +69,9 @@ void RWHeaderSection_RWFileDescription::ReadStep( //--- Initialisation of the read entity --- if (!ach->HasFailed()) + { ent->Init(aDescription, aImplementationLevel); + } } void RWHeaderSection_RWFileDescription::WriteStep( diff --git a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileName.cxx b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileName.cxx index 4b2cd43e13..667220a216 100644 --- a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileName.cxx +++ b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_RWFileName.cxx @@ -30,7 +30,9 @@ void RWHeaderSection_RWFileName::ReadStep(const occ::handleCheckNbParams(num, 7, ach, "file_name has not 7 parameter(s)")) + { return; + } // --- own field : name --- @@ -56,7 +58,9 @@ void RWHeaderSection_RWFileName::ReadStep(const occ::handleReadString(nsub3, i3, "author", ach, aAuthorItem); if (stat3) + { aAuthor->SetValue(i3, aAuthorItem); + } } } else @@ -78,7 +82,9 @@ void RWHeaderSection_RWFileName::ReadStep(const occ::handleReadString(nsub4, i4, "organization", ach, aOrganizationItem); if (stat4) + { aOrganization->SetValue(i4, aOrganizationItem); + } } } else @@ -104,6 +110,7 @@ void RWHeaderSection_RWFileName::ReadStep(const occ::handleHasFailed()) + { ent->Init(aName, aTimeStamp, aAuthor, @@ -111,6 +118,7 @@ void RWHeaderSection_RWFileName::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "file_schema has not 1 parameter(s)")) + { return; + } // --- own field : schemaIdentifiers --- @@ -46,7 +48,9 @@ void RWHeaderSection_RWFileSchema::ReadStep(const occ::handleReadString(nsub1, i1, "schema_identifiers", ach, aSchemaIdentifiersItem); if (stat1) + { aSchemaIdentifiers->SetValue(i1, aSchemaIdentifiersItem); + } } } else @@ -57,7 +61,9 @@ void RWHeaderSection_RWFileSchema::ReadStep(const occ::handleHasFailed()) + { ent->Init(aSchemaIdentifiers); + } } void RWHeaderSection_RWFileSchema::WriteStep(StepData_StepWriter& SW, diff --git a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx index 686c5d520a..460d9f3b84 100644 --- a/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx +++ b/src/DataExchange/TKDESTEP/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx @@ -53,11 +53,17 @@ RWHeaderSection_ReadWriteModule::RWHeaderSection_ReadWriteModule() int RWHeaderSection_ReadWriteModule::CaseStep(const TCollection_AsciiString& key) const { if (key.IsEqual(Reco_FileName)) + { return 1; + } if (key.IsEqual(Reco_FileDescription)) + { return 2; + } if (key.IsEqual(Reco_FileSchema)) + { return 3; + } return 0; } @@ -112,16 +118,22 @@ void RWHeaderSection_ReadWriteModule::ReadStep(const int const occ::handle& ent) const { if (CN == 0) + { return; + } switch (CN) { case 1: { DeclareAndCast(HeaderSection_FileName, anent, ent); RWHeaderSection_RWFileName tool; if (anent.IsNull()) + { ach->AddFail("Type Mismatch on FileName"); + } else + { tool.ReadStep(data, num, ach, anent); + } } break; @@ -129,9 +141,13 @@ void RWHeaderSection_ReadWriteModule::ReadStep(const int DeclareAndCast(HeaderSection_FileDescription, anent, ent); RWHeaderSection_RWFileDescription tool; if (anent.IsNull()) + { ach->AddFail("Type Mismatch on FileDescription"); + } else + { tool.ReadStep(data, num, ach, anent); + } } break; @@ -139,26 +155,32 @@ void RWHeaderSection_ReadWriteModule::ReadStep(const int DeclareAndCast(HeaderSection_FileSchema, anent, ent); RWHeaderSection_RWFileSchema tool; if (anent.IsNull()) + { ach->AddFail("Type Mismatch on FileSchema"); + } else + { tool.ReadStep(data, num, ach, anent); + } } break; case 4: { DeclareAndCast(StepData_UndefinedEntity, und, ent); if (und.IsNull()) + { ach->AddFail("# Entity neither Recognized nor set as UndefinedEntity from StepData #"); + } else + { und->ReadRecord(data, num, ach); + } } break; default: ach->AddFail("Type Mismatch when reading - Entity"); } - - return; } // -- Writing of a file -- @@ -168,16 +190,22 @@ void RWHeaderSection_ReadWriteModule::WriteStep(const int const occ::handle& ent) const { if (CN == 0) + { return; + } switch (CN) { case 1: { DeclareAndCast(HeaderSection_FileName, anent, ent); RWHeaderSection_RWFileName tool; if (anent.IsNull()) + { return; + } else + { tool.WriteStep(SW, anent); + } } break; @@ -185,9 +213,13 @@ void RWHeaderSection_ReadWriteModule::WriteStep(const int DeclareAndCast(HeaderSection_FileDescription, anent, ent); RWHeaderSection_RWFileDescription tool; if (anent.IsNull()) + { return; + } else + { tool.WriteStep(SW, anent); + } } break; @@ -195,24 +227,34 @@ void RWHeaderSection_ReadWriteModule::WriteStep(const int DeclareAndCast(HeaderSection_FileSchema, anent, ent); RWHeaderSection_RWFileSchema tool; if (anent.IsNull()) + { return; + } else + { tool.WriteStep(SW, anent); + } } break; case 4: { DeclareAndCast(StepData_UndefinedEntity, und, ent); if (und.IsNull()) + { break; + } // Parentheses gerees par StepWriter lui-meme // car en recevant le type PasReco, StepWriter ne l'affiche pas, // mais il gere les parentheses comme si de rien n etait if (und->IsComplex()) + { SW.StartComplex(); + } und->WriteParams(SW); if (und->IsComplex()) + { SW.EndComplex(); + } } break; diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignApproval.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignApproval.cxx index 3296824ccf..c1eda268c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignApproval.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignApproval.cxx @@ -41,7 +41,9 @@ void RWStepAP203_RWCcDesignApproval::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "cc_design_approval")) + { return; + } // Inherited fields of ApprovalAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignCertification.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignCertification.cxx index c353ae2eac..e6498185c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignCertification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignCertification.cxx @@ -41,7 +41,9 @@ void RWStepAP203_RWCcDesignCertification::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "cc_design_certification")) + { return; + } // Inherited fields of CertificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignContract.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignContract.cxx index 9bd0d2743a..f7b5d7ae4f 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignContract.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignContract.cxx @@ -41,7 +41,9 @@ void RWStepAP203_RWCcDesignContract::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "cc_design_contract")) + { return; + } // Inherited fields of ContractAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignDateAndTimeAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignDateAndTimeAssignment.cxx index 23063ecb40..109e28858d 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignDateAndTimeAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignDateAndTimeAssignment.cxx @@ -43,7 +43,9 @@ void RWStepAP203_RWCcDesignDateAndTimeAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "cc_design_date_and_time_assignment")) + { return; + } // Inherited fields of DateAndTimeAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignPersonAndOrganizationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignPersonAndOrganizationAssignment.cxx index c016d44000..67dc16c9e8 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignPersonAndOrganizationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignPersonAndOrganizationAssignment.cxx @@ -43,7 +43,9 @@ void RWStepAP203_RWCcDesignPersonAndOrganizationAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "cc_design_person_and_organization_assignment")) + { return; + } // Inherited fields of PersonAndOrganizationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSecurityClassification.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSecurityClassification.cxx index db1eaac36f..e056e90319 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSecurityClassification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSecurityClassification.cxx @@ -42,7 +42,9 @@ void RWStepAP203_RWCcDesignSecurityClassification::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "cc_design_security_classification")) + { return; + } // Inherited fields of SecurityClassificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSpecificationReference.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSpecificationReference.cxx index 115be161d8..3376f17ea0 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSpecificationReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWCcDesignSpecificationReference.cxx @@ -42,7 +42,9 @@ void RWStepAP203_RWCcDesignSpecificationReference::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "cc_design_specification_reference")) + { return; + } // Inherited fields of DocumentReference diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChange.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChange.cxx index de024f5bfa..e66caec399 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChange.cxx @@ -40,7 +40,9 @@ void RWStepAP203_RWChange::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "change")) + { return; + } // Inherited fields of ActionAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChangeRequest.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChangeRequest.cxx index 9d72ae29f4..47f63b19df 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChangeRequest.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWChangeRequest.cxx @@ -40,7 +40,9 @@ void RWStepAP203_RWChangeRequest::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "change_request")) + { return; + } // Inherited fields of ActionRequestAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartRequest.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartRequest.cxx index bb091fbccb..a945085c83 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartRequest.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartRequest.cxx @@ -38,7 +38,9 @@ void RWStepAP203_RWStartRequest::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "start_request")) + { return; + } // Inherited fields of ActionRequestAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartWork.cxx b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartWork.cxx index 487d2e6c4e..c8c78d9063 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartWork.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP203/RWStepAP203_RWStartWork.cxx @@ -38,7 +38,9 @@ void RWStepAP203_RWStartWork::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "start_work")) + { return; + } // Inherited fields of ActionAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.cxx index d967780147..7bdca3850b 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.cxx @@ -5420,7 +5420,9 @@ void RWStepAP214_GeneralModule::CopyCase(const int /*CN*/, bool RWStepAP214_GeneralModule::NewVoid(const int CN, occ::handle& ent) const { if (CN == 0) + { return false; + } switch (CN) { case 1: diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.pxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.pxx index 75ba88fec2..68b1d1de0b 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.pxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_GeneralModule.pxx @@ -62,12 +62,12 @@ public: Standard_HIDDEN bool NewVoid(const int CN, occ::handle& ent) const override; - Standard_HIDDEN virtual int CategoryNumber(const int CN, - const occ::handle& ent, - const Interface_ShareTool& shares) const override; + Standard_HIDDEN int CategoryNumber(const int CN, + const occ::handle& ent, + const Interface_ShareTool& shares) const override; //! Returns the name of a STEP Entity according to its type - Standard_HIDDEN virtual occ::handle Name( + Standard_HIDDEN occ::handle Name( const int CN, const occ::handle& ent, const Interface_ShareTool& shares) const override; diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedApprovalAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedApprovalAssignment.cxx index 43dcbd8c73..07cb2e8965 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedApprovalAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedApprovalAssignment.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWAppliedApprovalAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "applied_approval_assignment")) + { return; + } // --- inherited field : assignedApproval --- @@ -59,7 +61,9 @@ void RWStepAP214_RWAppliedApprovalAssignment::ReadStep( { bool stat2 = data->ReadEntity(nsub2, i2, "items", ach, aItemsItem); if (stat2) + { aItems->SetValue(i2, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAndTimeAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAndTimeAssignment.cxx index 28fc8b8f80..7fed050018 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAndTimeAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAndTimeAssignment.cxx @@ -37,7 +37,9 @@ void RWStepAP214_RWAppliedDateAndTimeAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "applied_date_and_time_assignment")) + { return; + } // --- inherited field : assignedDateAndTime --- @@ -67,7 +69,9 @@ void RWStepAP214_RWAppliedDateAndTimeAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAssignment.cxx index 007f1ee9f9..7ad20b34b3 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDateAssignment.cxx @@ -35,7 +35,9 @@ void RWStepAP214_RWAppliedDateAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "applied_date_assignment")) + { return; + } // --- inherited field : assignedDate --- @@ -60,7 +62,9 @@ void RWStepAP214_RWAppliedDateAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDocumentReference.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDocumentReference.cxx index 666a95c58e..57a78050df 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDocumentReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedDocumentReference.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWAppliedDocumentReference::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "applied_document_reference")) + { return; + } // --- inherited field : assigned_document @@ -59,7 +61,9 @@ void RWStepAP214_RWAppliedDocumentReference::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "item", ach, anItem); if (stat3) + { aItems->SetValue(i3, anItem); + } } } @@ -97,5 +101,7 @@ void RWStepAP214_RWAppliedDocumentReference::Share( { iter.AddItem(ent->AssignedDocument()); for (int i3 = 1; i3 <= ent->NbItems(); i3++) + { iter.AddItem(ent->ItemsValue(i3).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedExternalIdentificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedExternalIdentificationAssignment.cxx index 2ba0e303c7..ce68222281 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedExternalIdentificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedExternalIdentificationAssignment.cxx @@ -42,7 +42,9 @@ void RWStepAP214_RWAppliedExternalIdentificationAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "applied_external_identification_assignment")) + { return; + } // Inherited fields of IdentificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx index c7080c4c0b..78b62ea6fe 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx @@ -40,7 +40,9 @@ void RWStepAP214_RWAppliedGroupAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "applied_group_assignment")) + { return; + } // Inherited fields of GroupAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedOrganizationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedOrganizationAssignment.cxx index 72d2d92568..98a1d0305d 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedOrganizationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedOrganizationAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAppliedOrganizationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "applied_organization_assignment")) + { return; + } // --- inherited field : assignedOrganization --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAppliedOrganizationAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPersonAndOrganizationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPersonAndOrganizationAssignment.cxx index ea479fe552..f9569729c1 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPersonAndOrganizationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPersonAndOrganizationAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAppliedPersonAndOrganizationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "applied_person_and_organization_assignment")) + { return; + } // --- inherited field : assignedPersonAndOrganization --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAppliedPersonAndOrganizationAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPresentedItem.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPresentedItem.cxx index 23e267969f..08f382f9c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPresentedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedPresentedItem.cxx @@ -33,7 +33,9 @@ void RWStepAP214_RWAppliedPresentedItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "applied_presented_item")) + { return; + } // --- own field : items --- @@ -48,7 +50,9 @@ void RWStepAP214_RWAppliedPresentedItem::ReadStep( { bool stat1 = data->ReadEntity(nsub1, i1, "items", ach, anent1); if (stat1) + { aItems->SetValue(i1, anent1); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedSecurityClassificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedSecurityClassificationAssignment.cxx index 1caa3158e7..b04f7aca7e 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedSecurityClassificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAppliedSecurityClassificationAssignment.cxx @@ -35,7 +35,9 @@ void RWStepAP214_RWAppliedSecurityClassificationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "applied_security_classification_assignment")) + { return; + } // --- inherited field : assignedSecurityClassification --- @@ -60,7 +62,9 @@ void RWStepAP214_RWAppliedSecurityClassificationAssignment::ReadStep( { bool stat2 = data->ReadEntity(nsub2, i2, "items", ach, anent2); if (stat2) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAndTimeAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAndTimeAssignment.cxx index bfbf8c8ce5..73133901b0 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAndTimeAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAndTimeAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignActualDateAndTimeAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_actual_date_and_time_assignment")) + { return; + } // --- inherited field : assignedDateAndTime --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAutoDesignActualDateAndTimeAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAssignment.cxx index 42bca88fc4..139843dd60 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignActualDateAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignActualDateAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_actual_date_assignment")) + { return; + } // --- inherited field : assignedDate --- @@ -61,7 +63,9 @@ void RWStepAP214_RWAutoDesignActualDateAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignApprovalAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignApprovalAssignment.cxx index 66c1856692..179c64784d 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignApprovalAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignApprovalAssignment.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWAutoDesignApprovalAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "auto_design_approval_assignment")) + { return; + } // --- inherited field : assignedApproval --- @@ -59,7 +61,9 @@ void RWStepAP214_RWAutoDesignApprovalAssignment::ReadStep( { bool stat2 = data->ReadEntity(nsub2, i2, "items", ach, aItemsItem); if (stat2) + { aItems->SetValue(i2, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDateAndPersonAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDateAndPersonAssignment.cxx index d35d76c052..2a9cf5c453 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDateAndPersonAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDateAndPersonAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignDateAndPersonAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_date_and_person_assignment")) + { return; + } // --- inherited field : assignedPersonAndOrganization --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAutoDesignDateAndPersonAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDocumentReference.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDocumentReference.cxx index f25b90154f..ebe3d84b11 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDocumentReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignDocumentReference.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWAutoDesignDocumentReference::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_deesign_document_reference")) + { return; + } // --- inherited field : assigned_document @@ -59,7 +61,9 @@ void RWStepAP214_RWAutoDesignDocumentReference::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "item", ach, anItem); if (stat3) + { aItems->SetValue(i3, anItem); + } } } @@ -97,5 +101,7 @@ void RWStepAP214_RWAutoDesignDocumentReference::Share( { iter.AddItem(ent->AssignedDocument()); for (int i3 = 1; i3 <= ent->NbItems(); i3++) + { iter.AddItem(ent->ItemsValue(i3).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignGroupAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignGroupAssignment.cxx index 887a2aeae9..5b3d3dc0f7 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignGroupAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignGroupAssignment.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWAutoDesignGroupAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "auto_design_group_assignment")) + { return; + } // --- inherited field : assignedGroup --- @@ -54,7 +56,9 @@ void RWStepAP214_RWAutoDesignGroupAssignment::ReadStep( { bool stat2 = data->ReadEntity(nsub2, i2, "items", ach, aItemsItem); if (stat2) + { aItems->SetValue(i2, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment.cxx index 4d9ec236a9..c833b365a3 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_nominal_date_and_time_assignment")) + { return; + } // --- inherited field : assignedDateAndTime --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAutoDesignNominalDateAndTimeAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAssignment.cxx index 1277acc1dc..ae78f9a60c 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignNominalDateAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignNominalDateAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_nominal_date_assignment")) + { return; + } // --- inherited field : assignedDate --- @@ -61,7 +63,9 @@ void RWStepAP214_RWAutoDesignNominalDateAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignOrganizationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignOrganizationAssignment.cxx index 86fbf7dd2e..fed612503a 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignOrganizationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignOrganizationAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignOrganizationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_organization_assignment")) + { return; + } // --- inherited field : assignedOrganization --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAutoDesignOrganizationAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment.cxx index af748e470c..28dd4da61c 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment.cxx @@ -36,7 +36,9 @@ void RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "auto_design_person_and_organization_assignment")) + { return; + } // --- inherited field : assignedPersonAndOrganization --- @@ -66,7 +68,9 @@ void RWStepAP214_RWAutoDesignPersonAndOrganizationAssignment::ReadStep( { bool stat3 = data->ReadEntity(nsub3, i3, "items", ach, aItemsItem); if (stat3) + { aItems->SetValue(i3, aItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPresentedItem.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPresentedItem.cxx index a4e50432d3..d92d02e0bc 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPresentedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignPresentedItem.cxx @@ -33,7 +33,9 @@ void RWStepAP214_RWAutoDesignPresentedItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "auto_design_presented_item")) + { return; + } // --- own field : items --- @@ -48,7 +50,9 @@ void RWStepAP214_RWAutoDesignPresentedItem::ReadStep( { bool stat1 = data->ReadEntity(nsub1, i1, "auto_design_displayed_item", ach, anent1); if (stat1) + { aItems->SetValue(i1, anent1); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignSecurityClassificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignSecurityClassificationAssignment.cxx index 0c26f46b3e..654c939af9 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignSecurityClassificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWAutoDesignSecurityClassificationAssignment.cxx @@ -35,7 +35,9 @@ void RWStepAP214_RWAutoDesignSecurityClassificationAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "auto_design_security_classification_assignment")) + { return; + } // --- inherited field : assignedSecurityClassification --- @@ -65,7 +67,9 @@ void RWStepAP214_RWAutoDesignSecurityClassificationAssignment::ReadStep( STANDARD_TYPE(StepBasic_Approval), anent2); if (stat2) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWClass.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWClass.cxx index d3ef1bf620..fdf7255084 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWClass.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWClass.cxx @@ -34,7 +34,9 @@ void RWStepAP214_RWClass::ReadStep(const occ::handle& d { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "class")) + { return; + } // Inherited fields of Group @@ -71,7 +73,9 @@ void RWStepAP214_RWClass::WriteStep(StepData_StepWriter& SW, SW.Send(ent->StepBasic_Group::Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedClass.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedClass.cxx index af67cba614..5e35822b77 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedClass.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedClass.cxx @@ -37,7 +37,9 @@ void RWStepAP214_RWExternallyDefinedClass::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "externally_defined_class")) + { return; + } // Inherited fields of Group @@ -92,7 +94,9 @@ void RWStepAP214_RWExternallyDefinedClass::WriteStep( SW.Send(ent->StepBasic_Group::Description()); } else + { SW.SendUndef(); + } // Inherited fields of ExternallyDefinedItem diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedGeneralProperty.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedGeneralProperty.cxx index a5a18f1b85..602d121615 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedGeneralProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWExternallyDefinedGeneralProperty.cxx @@ -38,7 +38,9 @@ void RWStepAP214_RWExternallyDefinedGeneralProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "externally_defined_general_property")) + { return; + } // Inherited fields of GeneralProperty @@ -99,7 +101,9 @@ void RWStepAP214_RWExternallyDefinedGeneralProperty::WriteStep( SW.Send(ent->StepBasic_GeneralProperty::Description()); } else + { SW.SendUndef(); + } // Inherited fields of ExternallyDefinedItem diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWRepItemGroup.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWRepItemGroup.cxx index 2146817f88..18d9e1c2b8 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWRepItemGroup.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_RWRepItemGroup.cxx @@ -35,7 +35,9 @@ void RWStepAP214_RWRepItemGroup::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "rep_item_group")) + { return; + } // Inherited fields of Group @@ -77,7 +79,9 @@ void RWStepAP214_RWRepItemGroup::WriteStep(StepData_StepWriter& SW.Send(ent->StepBasic_Group::Description()); } else + { SW.SendUndef(); + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.cxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.cxx index 49d43f36f4..f339ce6999 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.cxx @@ -4329,11 +4329,17 @@ int RWStepAP214_ReadWriteModule::CaseStep(const TCollection_AsciiString& key) co // frequents dans le fichier cad geometry/topology int num; if (key.IsEqual(Reco_CartesianPoint)) + { return 59; // car tres courant + } if (THE_TYPENUMS.Find(static_cast(key), num)) + { return num; + } if (THE_TYPESHOR.Find(static_cast(key), num)) + { return num; // AJOUT DES TYPES COURTS + } return 0; } @@ -4375,9 +4381,13 @@ int RWStepAP214_ReadWriteModule::CaseStep( for (i = 1; i <= NbComp; i++) { if (THE_TYPESHOR.Find(static_cast(theTypes(i)), num)) + { longs.Append(TCollection_AsciiString(StepType(num))); + } else + { longs.Append(theTypes(i)); + } } return CaseStep(longs); } @@ -4386,7 +4396,9 @@ int RWStepAP214_ReadWriteModule::CaseStep( // sorting) NCollection_Sequence types; for (i = 1; i <= theTypes.Length(); i++) + { types.Append(theTypes(i)); + } // do ascending sorting bool isOK = false; TCollection_AsciiString tmpStr; @@ -4395,6 +4407,7 @@ int RWStepAP214_ReadWriteModule::CaseStep( { isOK = true; for (i = 1; i <= aLen; i++) + { if (types(i) > types(i + 1)) { tmpStr = types(i); @@ -4402,6 +4415,7 @@ int RWStepAP214_ReadWriteModule::CaseStep( types(i + 1) = tmpStr; isOK = false; } + } } if (NbComp == 8) @@ -11345,7 +11359,6 @@ void RWStepAP214_ReadWriteModule::ReadStep(const int default: ach->AddFail("Type Mismatch when reading - Entity"); } - return; } //================================================================================================= @@ -11355,7 +11368,9 @@ void RWStepAP214_ReadWriteModule::WriteStep(const int const occ::handle& ent) const { if (CN == 0) + { return; + } switch (CN) { case 1: { diff --git a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.pxx b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.pxx index 20707bca1a..43e2d3d674 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.pxx +++ b/src/DataExchange/TKDESTEP/RWStepAP214/RWStepAP214_ReadWriteModule.pxx @@ -45,17 +45,17 @@ public: //! associates a positive Case Number to each type of StepAP214 Complex entity, //! given as a String defined in the EXPRESS form - Standard_HIDDEN virtual int CaseStep( + Standard_HIDDEN int CaseStep( const NCollection_Sequence& types) const override; //! returns True if the Case Number corresponds to a Complex Type - Standard_HIDDEN virtual bool IsComplex(const int CN) const override; + Standard_HIDDEN bool IsComplex(const int CN) const override; //! returns a StepType (defined in EXPRESS form which belongs to a //! Type of Entity, identified by its CaseNumber determined by Protocol Standard_HIDDEN const std::string_view& StepType(const int CN) const override; - Standard_HIDDEN virtual bool ComplexType( + Standard_HIDDEN bool ComplexType( const int CN, NCollection_Sequence& types) const override; diff --git a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWDraughtingModelItemAssociation.cxx b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWDraughtingModelItemAssociation.cxx index d7072ae34e..c8fea49a68 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWDraughtingModelItemAssociation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWDraughtingModelItemAssociation.cxx @@ -38,7 +38,9 @@ void RWStepAP242_RWDraughtingModelItemAssociation::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 5, ach, "geometric_item_specific_usage")) + { return; + } // Inherited fields of ItemIdentifiedRepresentationUsage occ::handle aName; @@ -92,7 +94,9 @@ void RWStepAP242_RWDraughtingModelItemAssociation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -116,7 +120,9 @@ void RWStepAP242_RWDraughtingModelItemAssociation::WriteStep( SW.Send(ent->UsedRepresentation()); if (ent->NbIdentifiedItem() == 1) + { SW.Send(ent->IdentifiedItemValue(1)); + } else { SW.OpenSub(); @@ -139,5 +145,7 @@ void RWStepAP242_RWDraughtingModelItemAssociation::Share( iter.AddItem(ent->Definition().Value()); int i, nb = ent->NbIdentifiedItem(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->IdentifiedItemValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWGeometricItemSpecificUsage.cxx b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWGeometricItemSpecificUsage.cxx index 2b70986a9b..2c23b04e16 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWGeometricItemSpecificUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWGeometricItemSpecificUsage.cxx @@ -35,7 +35,9 @@ void RWStepAP242_RWGeometricItemSpecificUsage::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "geometric_item_specific_usage")) + { return; + } // Inherited fields of ItemIdentifiedRepresentationUsage @@ -90,7 +92,9 @@ void RWStepAP242_RWGeometricItemSpecificUsage::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -114,7 +118,9 @@ void RWStepAP242_RWGeometricItemSpecificUsage::WriteStep( SW.Send(ent->UsedRepresentation()); if (ent->NbIdentifiedItem() == 1) + { SW.Send(ent->IdentifiedItemValue(1)); + } else { SW.OpenSub(); @@ -135,5 +141,7 @@ void RWStepAP242_RWGeometricItemSpecificUsage::Share( iter.AddItem(ent->Definition().Value()); int i, nb = ent->NbIdentifiedItem(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->IdentifiedItemValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWIdAttribute.cxx b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWIdAttribute.cxx index 491d0b42e7..144ac7aa51 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWIdAttribute.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWIdAttribute.cxx @@ -31,7 +31,9 @@ void RWStepAP242_RWIdAttribute::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "id_attribute")) + { return; + } // --- own field : attribute_value --- diff --git a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWItemIdentifiedRepresentationUsage.cxx b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWItemIdentifiedRepresentationUsage.cxx index b8f2b5e3ea..aac5b93169 100644 --- a/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWItemIdentifiedRepresentationUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepAP242/RWStepAP242_RWItemIdentifiedRepresentationUsage.cxx @@ -34,7 +34,9 @@ void RWStepAP242_RWItemIdentifiedRepresentationUsage::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "item_identified_representation_usage")) + { return; + } // --- own field : name --- @@ -96,7 +98,9 @@ void RWStepAP242_RWItemIdentifiedRepresentationUsage::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -129,7 +133,9 @@ void RWStepAP242_RWItemIdentifiedRepresentationUsage::WriteStep( // --- own field : identified_item --- if (ent->NbIdentifiedItem() == 1) + { SW.Send(ent->IdentifiedItemValue(1)); + } else { SW.OpenSub(); @@ -148,5 +154,7 @@ void RWStepAP242_RWItemIdentifiedRepresentationUsage::Share( iter.AddItem(ent->Definition().Value()); int i, nb = ent->NbIdentifiedItem(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->IdentifiedItemValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAction.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAction.cxx index 309eb54fbe..3395074618 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAction.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAction.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWAction::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "action")) + { return; + } // Own fields of Action @@ -81,7 +83,9 @@ void RWStepBasic_RWAction::WriteStep(StepData_StepWriter& SW, SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->ChosenMethod()); } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionAssignment.cxx index 840529bdab..589b4830f1 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionAssignment.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWActionAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "action_assignment")) + { return; + } // Own fields of ActionAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionMethod.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionMethod.cxx index 82ba03edd3..c2a3dc67ac 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionMethod.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionMethod.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWActionMethod::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "action_method")) + { return; + } // Own fields of ActionMethod @@ -78,7 +80,9 @@ void RWStepBasic_RWActionMethod::WriteStep(StepData_StepWriter& SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->Consequence()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestAssignment.cxx index 7a0b3e5cae..a1553f440b 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestAssignment.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWActionRequestAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "action_request_assignment")) + { return; + } // Own fields of ActionRequestAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestSolution.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestSolution.cxx index bdaed22fdb..d4a630e38a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestSolution.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWActionRequestSolution.cxx @@ -38,7 +38,9 @@ void RWStepBasic_RWActionRequestSolution::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "action_request_solution")) + { return; + } // Own fields of ActionRequestSolution diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAddress.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAddress.cxx index 43f311b516..4d6f0d42d7 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAddress.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWAddress.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWAddress::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 12, ach, "address")) + { return; + } // --- own field : internalLocation --- occ::handle aInternalLocation; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContext.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContext.cxx index dda8bf439e..38e9887a96 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContext.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWApplicationContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "application_context")) + { return; + } // --- own field : application --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContextElement.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContextElement.cxx index 45a1951033..9e3908335a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContextElement.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationContextElement.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWApplicationContextElement::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "application_context_element")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationProtocolDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationProtocolDefinition.cxx index b216f015ea..c8505444e9 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationProtocolDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApplicationProtocolDefinition.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWApplicationProtocolDefinition::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "application_protocol_definition")) + { return; + } // --- own field : status --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApproval.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApproval.cxx index bd883ff1b9..90984f0703 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApproval.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApproval.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWApproval::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "approval")) + { return; + } // --- own field : status --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalDateTime.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalDateTime.cxx index de799f2222..421fc2f866 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalDateTime.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalDateTime.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWApprovalDateTime::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "approval_date_time")) + { return; + } // --- own fields diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalPersonOrganization.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalPersonOrganization.cxx index cf52260586..df723ef630 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalPersonOrganization.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalPersonOrganization.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWApprovalPersonOrganization::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "approval_person_organization")) + { return; + } // --- own field : personOrganization --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRelationship.cxx index 2257c37918..fab565d43d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRelationship.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWApprovalRelationship::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "approval_relationship")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRole.cxx index 94fa4b3353..bb9a4721f9 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalRole.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWApprovalRole::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "approval_role")) + { return; + } // --- own field : role --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalStatus.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalStatus.cxx index 935b63433a..874acb48ce 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalStatus.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWApprovalStatus.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWApprovalStatus::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "approval_status")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCalendarDate.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCalendarDate.cxx index e4fb6dadd3..7d68b3868e 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCalendarDate.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCalendarDate.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWCalendarDate::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "calendar_date")) + { return; + } // --- inherited field : yearComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertification.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertification.cxx index 988825564c..5c4960ca73 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertification.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWCertification::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "certification")) + { return; + } // Own fields of Certification diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationAssignment.cxx index dfce3692bf..311836bd83 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationAssignment.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWCertificationAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "certification_assignment")) + { return; + } // Own fields of CertificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationType.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationType.cxx index 900f8d0357..4d47e2edf8 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationType.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCertificationType.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWCertificationType::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "certification_type")) + { return; + } // Own fields of CertificationType diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCharacterizedObject.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCharacterizedObject.cxx index fd9a97beff..995aedc3a6 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCharacterizedObject.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCharacterizedObject.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWCharacterizedObject::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "characterized_object")) + { return; + } // Own fields of CharacterizedObject @@ -73,7 +75,9 @@ void RWStepBasic_RWCharacterizedObject::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContract.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContract.cxx index d5b6a77279..c99b7a1314 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContract.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContract.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWContract::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "contract")) + { return; + } // Own fields of Contract diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractAssignment.cxx index 3310fe53fc..21aa2bcacc 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractAssignment.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWContractAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "contract_assignment")) + { return; + } // Own fields of ContractAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractType.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractType.cxx index d6a5c87d95..b0600c6b9f 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractType.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWContractType.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWContractType::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "contract_type")) + { return; + } // Own fields of ContractType diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnit.cxx index f659243fc2..3c7dafa47e 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnit.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWConversionBasedUnit::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "conversion_based_unit")) + { return; + } // --- inherited field : dimensions --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndAreaUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndAreaUnit.cxx index 5d51ca4771..0ad07b6579 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndAreaUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndAreaUnit.cxx @@ -34,12 +34,16 @@ void RWStepBasic_RWConversionBasedUnitAndAreaUnit::ReadStep( int num = num0; // data->NamedForComplex("AREA_UNIT",num0,num,ach); if (!data->CheckNbParams(num, 0, ach, "area_unit")) + { return; + } // --- Instance of plex component ConversionBasedUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -54,7 +58,9 @@ void RWStepBasic_RWConversionBasedUnitAndAreaUnit::ReadStep( num = data->NextForComplex(num); if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } occ::handle aDimensions; data->ReadEntity(num, 1, diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndLengthUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndLengthUnit.cxx index 59d7d97011..05b761a061 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndLengthUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndLengthUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWConversionBasedUnitAndLengthUnit::ReadStep( // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } // --- field : name --- @@ -59,14 +61,18 @@ void RWStepBasic_RWConversionBasedUnitAndLengthUnit::ReadStep( // --- Instance of plex component LengthUnit --- if (!data->CheckNbParams(num, 0, ach, "length_unit")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- occ::handle aDimensions; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndMassUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndMassUnit.cxx index 0568878dc0..60ffed319a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndMassUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndMassUnit.cxx @@ -38,7 +38,9 @@ void RWStepBasic_RWConversionBasedUnitAndMassUnit::ReadStep( // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } // --- field : name --- occ::handle aName; // szv#4:S4163:12Mar99 `bool stat1 =` not needed @@ -57,13 +59,17 @@ void RWStepBasic_RWConversionBasedUnitAndMassUnit::ReadStep( // --- Instance of plex component MassUnit --- if (!data->CheckNbParams(num, 0, ach, "Mass_unit")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- occ::handle aDimensions; // szv#4:S4163:12Mar99 `bool stat3 =` not needed diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit.cxx index 5788a81650..9912554fdd 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit::ReadStep( int num = 0; // num0; data->NamedForComplex("CONVERSION_BASED_UNIT", "CNBSUN", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } occ::handle aName; data->ReadString(num, 1, "name", ach, aName); occ::handle aConversionFactor; @@ -52,7 +54,9 @@ void RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit::ReadStep( // num = 0; //gka TRJ9 c2-id-214.stp data->NamedForComplex("NAMED_UNIT", "NMDUNT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } occ::handle aDimensions; data->ReadEntity(num, 1, @@ -65,7 +69,9 @@ void RWStepBasic_RWConversionBasedUnitAndPlaneAngleUnit::ReadStep( // num = 0; //gka data->NamedForComplex("PLANE_ANGLE_UNIT", "PLANUN", num0, num, ach); if (!data->CheckNbParams(num, 0, ach, "plane_angle_unit")) + { return; + } ent->Init(aDimensions, aName, aConversionFactor); } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndRatioUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndRatioUnit.cxx index 2cbf7d3245..c64ffafa6d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndRatioUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndRatioUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWConversionBasedUnitAndRatioUnit::ReadStep( // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } // --- field : name --- @@ -59,7 +61,9 @@ void RWStepBasic_RWConversionBasedUnitAndRatioUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- @@ -77,7 +81,9 @@ void RWStepBasic_RWConversionBasedUnitAndRatioUnit::ReadStep( // --- Instance of plex component RatioUnit --- if (!data->CheckNbParams(num, 0, ach, "ratio_unit")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit.cxx index e889636bf4..a3d84debcc 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit::ReadStep( // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } // --- field : name --- @@ -59,7 +61,9 @@ void RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- occ::handle aDimensions; @@ -76,7 +80,9 @@ void RWStepBasic_RWConversionBasedUnitAndSolidAngleUnit::ReadStep( // --- Instance of plex component SolidAngleUnit --- if (!data->CheckNbParams(num, 0, ach, "solid_angle_unit")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndTimeUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndTimeUnit.cxx index 39a7b621b8..e2d6d53194 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndTimeUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndTimeUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWConversionBasedUnitAndTimeUnit::ReadStep( // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } // --- field : name --- @@ -59,7 +61,9 @@ void RWStepBasic_RWConversionBasedUnitAndTimeUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- occ::handle aDimensions; @@ -76,7 +80,9 @@ void RWStepBasic_RWConversionBasedUnitAndTimeUnit::ReadStep( // --- Instance of plex component TimeUnit --- if (!data->CheckNbParams(num, 0, ach, "time_unit")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndVolumeUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndVolumeUnit.cxx index 7ef96d8ea1..0bfa038ae7 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndVolumeUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWConversionBasedUnitAndVolumeUnit.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWConversionBasedUnitAndVolumeUnit::ReadStep( int num = num0; // --- Instance of plex component ConversionBasedUnit --- if (!data->CheckNbParams(num, 2, ach, "conversion_based_unit")) + { return; + } occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -49,7 +51,9 @@ void RWStepBasic_RWConversionBasedUnitAndVolumeUnit::ReadStep( num = data->NextForComplex(num); if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } occ::handle aDimensions; data->ReadEntity(num, 1, @@ -60,7 +64,9 @@ void RWStepBasic_RWConversionBasedUnitAndVolumeUnit::ReadStep( data->NamedForComplex("VOLUME_UNIT", "VLMUNT", num0, num, ach); if (!data->CheckNbParams(num, 0, ach, "volume_unit")) + { return; + } ent->Init(aDimensions, aName, aConversionFactor); } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCoordinatedUniversalTimeOffset.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCoordinatedUniversalTimeOffset.cxx index cce9c57e96..9413bc96a0 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCoordinatedUniversalTimeOffset.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWCoordinatedUniversalTimeOffset.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWCoordinatedUniversalTimeOffset::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "coordinated_universal_time_offset")) + { return; + } // --- own field : hourOffset --- @@ -67,7 +69,9 @@ void RWStepBasic_RWCoordinatedUniversalTimeOffset::ReadStep( } } else + { ach->AddFail("Parameter #3 (sense) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDate.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDate.cxx index 7ccde6ffb7..d036193b97 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDate.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDate.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWDate::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "date")) + { return; + } // --- own field : yearComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateAndTime.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateAndTime.cxx index ddb799eaaa..e13ba2725d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateAndTime.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateAndTime.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWDateAndTime::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "date_and_time")) + { return; + } // --- own field : dateComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateRole.cxx index 3f776c9f84..a26e28822d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateRole.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWDateRole::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "date_role")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateTimeRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateTimeRole.cxx index 1c4b3eaa20..99de31c76d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateTimeRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDateTimeRole.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWDateTimeRole::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "date_time_role")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnit.cxx index c730d70a3e..6002093a5c 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnit.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWDerivedUnit::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "derived_unit")) + { return; + } // --- own field : elements --- @@ -52,7 +54,9 @@ void RWStepBasic_RWDerivedUnit::ReadStep(const occ::handleSetValue(i1, anelt); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnitElement.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnitElement.cxx index c27c837faf..f1a610884f 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnitElement.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDerivedUnitElement.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWDerivedUnitElement::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "derived_unit_element")) + { return; + } // --- own fields diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDimensionalExponents.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDimensionalExponents.cxx index f5df2a8ab6..8d03b2dfbc 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDimensionalExponents.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDimensionalExponents.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWDimensionalExponents::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 7, ach, "dimensional_exponents")) + { return; + } // --- own field : lengthExponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocument.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocument.cxx index 2da279f0b5..34f56c0e8f 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocument.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocument.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWDocument::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "document")) + { return; + } // Own fields of Document @@ -80,7 +82,9 @@ void RWStepBasic_RWDocument::WriteStep(StepData_StepWriter& SW SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->Kind()); } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentFile.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentFile.cxx index 95d6df7118..08b053ef18 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentFile.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentFile.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWDocumentFile::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "document_file")) + { return; + } // Inherited fields of Document @@ -113,7 +115,9 @@ void RWStepBasic_RWDocumentFile::WriteStep(StepData_StepWriter& SW.Send(ent->StepBasic_Document::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_Document::Kind()); @@ -126,7 +130,9 @@ void RWStepBasic_RWDocumentFile::WriteStep(StepData_StepWriter& SW.Send(ent->CharacterizedObject()->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductAssociation.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductAssociation.cxx index 4777d8338f..01b1e5ccc5 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductAssociation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductAssociation.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWDocumentProductAssociation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "document_product_association")) + { return; + } // Own fields of DocumentProductAssociation @@ -85,7 +87,9 @@ void RWStepBasic_RWDocumentProductAssociation::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->RelatingDocument()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductEquivalence.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductEquivalence.cxx index 3305f4a860..89cc3f5c7a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductEquivalence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentProductEquivalence.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWDocumentProductEquivalence::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "document_product_equivalence")) + { return; + } // Inherited fields of DocumentProductAssociation @@ -101,7 +103,9 @@ void RWStepBasic_RWDocumentProductEquivalence::WriteStep( SW.Send(ent->StepBasic_DocumentProductAssociation::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_DocumentProductAssociation::RelatingDocument()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRelationship.cxx index 6571141176..8a7b646256 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRelationship.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWDocumentRelationship::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "document_relationship")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRepresentationType.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRepresentationType.cxx index 89673f1915..5f4b4739c0 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRepresentationType.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentRepresentationType.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWDocumentRepresentationType::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "document_representation_type")) + { return; + } // Own fields of DocumentRepresentationType diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentType.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentType.cxx index eb8beb9522..fdc96206bf 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentType.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentType.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWDocumentType::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "document_type")) + { return; + } // --- own field : product_data_type --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentUsageConstraint.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentUsageConstraint.cxx index c65b3c5b37..9c798d8fd2 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentUsageConstraint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWDocumentUsageConstraint.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWDocumentUsageConstraint::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "document_usage_constraint")) + { return; + } // --- own field : source --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivity.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivity.cxx index a33c25922d..2ff850e439 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivity.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWEffectivity::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "effectivity")) + { return; + } // --- own field : id --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivityAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivityAssignment.cxx index 16cbeae204..cc8b4f313a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivityAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEffectivityAssignment.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWEffectivityAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "effectivity_assignment")) + { return; + } // Own fields of EffectivityAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEulerAngles.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEulerAngles.cxx index e961ef293b..89a60e7131 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEulerAngles.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWEulerAngles.cxx @@ -38,7 +38,9 @@ void RWStepBasic_RWEulerAngles::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "euler_angles")) + { return; + } // Own fields of EulerAngles diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalIdentificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalIdentificationAssignment.cxx index 5c766a2345..dbc87118e1 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalIdentificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalIdentificationAssignment.cxx @@ -38,7 +38,9 @@ void RWStepBasic_RWExternalIdentificationAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "external_identification_assignment")) + { return; + } // Inherited fields of IdentificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalSource.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalSource.cxx index fa0605141c..bf46865a0b 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalSource.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternalSource.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWExternalSource::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "external_source")) + { return; + } // Own fields of ExternalSource diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternallyDefinedItem.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternallyDefinedItem.cxx index 90d3a36e41..b79b1ec213 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternallyDefinedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWExternallyDefinedItem.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWExternallyDefinedItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "externally_defined_item")) + { return; + } // Own fields of ExternallyDefinedItem diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralProperty.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralProperty.cxx index a96f0e12ac..74a89510fc 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralProperty.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWGeneralProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "general_property")) + { return; + } // Own fields of GeneralProperty @@ -78,7 +80,9 @@ void RWStepBasic_RWGeneralProperty::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyAssociation.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyAssociation.cxx index a64c67f104..b85cd13f41 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyAssociation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyAssociation.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWGeneralPropertyAssociation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theAch, "general_property_association")) + { return; + } occ::handle aName; theData->ReadString(theNum, 1, "name", theAch, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyRelationship.cxx index f84c7132b6..83b5bdcf70 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGeneralPropertyRelationship.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWGeneralPropertyRelationship::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theAch, "general_property_association")) + { return; + } occ::handle aName; theData->ReadString(theNum, 1, "name", theAch, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroup.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroup.cxx index 0d9f27e8e8..6deb8f4a7c 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroup.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroup.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWGroup::ReadStep(const occ::handle& d { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "group")) + { return; + } // Own fields of Group @@ -71,7 +73,9 @@ void RWStepBasic_RWGroup::WriteStep(StepData_StepWriter& SW, SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupAssignment.cxx index d4a6eabe75..a80e1ef4c0 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupAssignment.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWGroupAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "group_assignment")) + { return; + } // Own fields of GroupAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupRelationship.cxx index 96cd3e461a..658ea4460a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWGroupRelationship.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWGroupRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "group_relationship")) + { return; + } // Own fields of GroupRelationship @@ -80,7 +82,9 @@ void RWStepBasic_RWGroupRelationship::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->RelatingGroup()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationAssignment.cxx index 13c804bb25..e7cec9b9e4 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationAssignment.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWIdentificationAssignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "identification_assignment")) + { return; + } // Own fields of IdentificationAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationRole.cxx index 8015cb4eac..26ab6810ac 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWIdentificationRole.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWIdentificationRole::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "identification_role")) + { return; + } // Own fields of IdentificationRole @@ -73,7 +75,9 @@ void RWStepBasic_RWIdentificationRole::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthMeasureWithUnit.cxx index 2d666d3a7a..7b46692d3d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWLengthMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "length_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- // --- Update 12-02-96 by FMA , 31-MARS-1997 by CKY diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthUnit.cxx index edafa93dd1..ef1763d644 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLengthUnit.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWLengthUnit::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "length_unit")) + { return; + } // --- inherited field : dimensions --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLocalTime.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLocalTime.cxx index eb1b859fdb..a554ac9eed 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLocalTime.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWLocalTime.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWLocalTime::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "local_time")) + { return; + } // --- own field : hourComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassMeasureWithUnit.cxx index b594c264bd..baaf754635 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWMassMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "Mass_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- // --- Update 12-02-96 by FMA , 31-MARS-1997 by CKY diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassUnit.cxx index e0ebad0fb9..bf46c1bea6 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMassUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWMassUnit::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "mass_unit")) + { return; + } // Inherited fields of NamedUnit diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMeasureWithUnit.cxx index 320d6a18fc..a054516cc5 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "measure_with_unit")) + { return; + } // --- own field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMechanicalContext.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMechanicalContext.cxx index e8dd928bd7..dc14c60393 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMechanicalContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWMechanicalContext.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWMechanicalContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "mechanical_context")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNameAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNameAssignment.cxx index 2cfb769d30..c61d745dbf 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNameAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNameAssignment.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWNameAssignment::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "name_assignment")) + { return; + } // Own fields of NameAssignment diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNamedUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNamedUnit.cxx index 05ff4caa0b..c224654a5a 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNamedUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWNamedUnit.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWNamedUnit::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- own field : dimensions --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWObjectRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWObjectRole.cxx index 9197f66471..c2f35ee5ff 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWObjectRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWObjectRole.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWObjectRole::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "object_role")) + { return; + } // Own fields of ObjectRole @@ -71,7 +73,9 @@ void RWStepBasic_RWObjectRole::WriteStep(StepData_StepWriter& SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrdinalDate.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrdinalDate.cxx index 861992dd2c..67ec2ee500 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrdinalDate.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrdinalDate.cxx @@ -27,7 +27,9 @@ void RWStepBasic_RWOrdinalDate::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "ordinal_date")) + { return; + } // --- inherited field : yearComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganization.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganization.cxx index c00e63fa3d..489a89b81c 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganization.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganization.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWOrganization::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "organization")) + { return; + } // --- own field : id --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationRole.cxx index f33621f6ff..fd197eb297 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationRole.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWOrganizationRole::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "organization_role")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationalAddress.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationalAddress.cxx index a20cb88c20..c90094461b 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationalAddress.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWOrganizationalAddress.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWOrganizationalAddress::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 14, ach, "organizational_address")) + { return; + } // --- inherited field : internalLocation --- @@ -233,7 +235,9 @@ void RWStepBasic_RWOrganizationalAddress::ReadStep( ach, STANDARD_TYPE(StepBasic_Organization), anent13)) + { aOrganizations->SetValue(i13, anent13); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPerson.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPerson.cxx index 4bb46e871f..c4464b511b 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPerson.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPerson.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWPerson::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 6, ach, "person")) + { return; + } // --- own field : id --- @@ -82,7 +84,9 @@ void RWStepBasic_RWPerson::ReadStep(const occ::handle& { // szv#4:S4163:12Mar99 `bool stat4 =` not needed if (data->ReadString(nsub4, i4, "middle_names", ach, aMiddleNamesItem)) + { aMiddleNames->SetValue(i4, aMiddleNamesItem); + } } } } @@ -108,7 +112,9 @@ void RWStepBasic_RWPerson::ReadStep(const occ::handle& { // szv#4:S4163:12Mar99 `bool stat5 =` not needed if (data->ReadString(nsub5, i5, "prefix_titles", ach, aPrefixTitlesItem)) + { aPrefixTitles->SetValue(i5, aPrefixTitlesItem); + } } } } @@ -134,7 +140,9 @@ void RWStepBasic_RWPerson::ReadStep(const occ::handle& { // szv#4:S4163:12Mar99 `bool stat6 =` not needed if (data->ReadString(nsub6, i6, "suffix_titles", ach, aSuffixTitlesItem)) + { aSuffixTitles->SetValue(i6, aSuffixTitlesItem); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganization.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganization.cxx index d0d03aa67e..55fd6eff3f 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganization.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganization.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWPersonAndOrganization::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "person_and_organization")) + { return; + } // --- own field : thePerson --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganizationRole.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganizationRole.cxx index 2089f24e55..e6f6d61357 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganizationRole.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonAndOrganizationRole.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWPersonAndOrganizationRole::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "person_and_organization_role")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonalAddress.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonalAddress.cxx index 53ae2fb21f..cfea1b9ed0 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonalAddress.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPersonalAddress.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWPersonalAddress::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 14, ach, "personal_address")) + { return; + } // --- inherited field : internalLocation --- @@ -228,7 +230,9 @@ void RWStepBasic_RWPersonalAddress::ReadStep( { // szv#4:S4163:12Mar99 `bool stat13 =` not needed if (data->ReadEntity(nsub13, i13, "person", ach, STANDARD_TYPE(StepBasic_Person), anent13)) + { aPeople->SetValue(i13, anent13); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleMeasureWithUnit.cxx index 60ce2814f8..f49466d993 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWPlaneAngleMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "plane_angle_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- // UPDATE 21-02-96 , 31-MARS-1997 by CKY diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleUnit.cxx index 153e2d2799..4d000e5ae9 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWPlaneAngleUnit.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWPlaneAngleUnit::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "plane_angle_unit")) + { return; + } // --- inherited field : dimensions --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProduct.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProduct.cxx index 8c44e83d0e..e40e8541d0 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProduct.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProduct.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWProduct::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "product")) + { return; + } // --- own field : id --- @@ -72,7 +74,9 @@ void RWStepBasic_RWProduct::ReadStep(const occ::handle& ach, STANDARD_TYPE(StepBasic_ProductContext), anent4)) + { aFrameOfReference->SetValue(i4, anent4); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategory.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategory.cxx index aaaabdbc82..3418b71655 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategory.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategory.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWProductCategory::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "product_category")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategoryRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategoryRelationship.cxx index e6fd1d46f8..4446e02763 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategoryRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductCategoryRelationship.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWProductCategoryRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "product_category_relationship")) + { return; + } // Own fields of ProductCategoryRelationship @@ -86,7 +88,9 @@ void RWStepBasic_RWProductCategoryRelationship::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->Category()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductConceptContext.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductConceptContext.cxx index 3d49e44efe..770a16e6bd 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductConceptContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductConceptContext.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWProductConceptContext::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "product_concept_context")) + { return; + } // Inherited fields of ApplicationContextElement diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductContext.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductContext.cxx index 3bcfa99e2c..412bb1102e 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductContext.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWProductContext::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "product_context")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinition.cxx index 7c3d927f62..e2d1c7907c 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinition.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWProductDefinition::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "product_definition")) + { return; + } // --- own field : id --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionContext.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionContext.cxx index a0196e7f6f..e9b0bb2307 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionContext.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWProductDefinitionContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "product_definition_context")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionEffectivity.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionEffectivity.cxx index e068847ea0..0fbacb590c 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionEffectivity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionEffectivity.cxx @@ -31,7 +31,9 @@ void RWStepBasic_RWProductDefinitionEffectivity::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "product_definition_effectivity")) + { return; + } // --- inherited field : product_data_type --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormation.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormation.cxx index 88381762bc..2cc78154d5 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormation.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWProductDefinitionFormation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "product_definition_formation")) + { return; + } // --- own field : id --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationRelationship.cxx index 7e0d2f81d6..02fb34aceb 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationRelationship.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWProductDefinitionFormationRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "product_definition_formation_relationship")) + { return; + } // Own fields of ProductDefinitionFormationRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx index 692e5db6ad..9e1bd33971 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "product_definition_formation_with_specified_source")) + { return; + } // --- inherited field : id --- @@ -67,7 +69,9 @@ void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep( } } else + { ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReference.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReference.cxx index 9c2e6d3941..6f31dbb867 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReference.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWProductDefinitionReference::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 5, ach, "product_definition_reference")) + { return; + } // Own field source occ::handle aSource; @@ -90,9 +92,13 @@ void RWStepBasic_RWProductDefinitionReference::WriteStep( // Own field : id_owning_organization_name if (ent->HasIdOwningOrganizationName()) + { SW.Send(ent->IdOwningOrganizationName()); + } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReferenceWithLocalRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReferenceWithLocalRepresentation.cxx index 8a46b6c808..b13c29e730 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReferenceWithLocalRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionReferenceWithLocalRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepBasic_RWProductDefinitionReferenceWithLocalRepresentation::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 5, ach, "product_definition_reference_with_local_representation")) + { return; + } // Own field source occ::handle aSource; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionRelationship.cxx index ab09b57504..7e08cd6401 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionRelationship.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWProductDefinitionRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "product_definition_relationship")) + { return; + } // Own fields of ProductDefinitionRelationship @@ -90,7 +92,9 @@ void RWStepBasic_RWProductDefinitionRelationship::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->RelatingProductDefinitionAP242().Value()); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionWithAssociatedDocuments.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionWithAssociatedDocuments.cxx index 206b1c5205..c80e102e72 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionWithAssociatedDocuments.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductDefinitionWithAssociatedDocuments.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWProductDefinitionWithAssociatedDocuments::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "product_definition")) + { return; + } // --- inherited field : id --- @@ -78,7 +80,9 @@ void RWStepBasic_RWProductDefinitionWithAssociatedDocuments::ReadStep( { int nb5 = data->NbParams(nsub5); if (nb5 > 0) + { aDocIds = new NCollection_HArray1>(1, nb5); + } for (int i5 = 1; i5 <= nb5; i5++) { // szv#4:S4163:12Mar `99Standard_Boolean stat5 =` not needed @@ -88,7 +92,9 @@ void RWStepBasic_RWProductDefinitionWithAssociatedDocuments::ReadStep( ach, STANDARD_TYPE(StepBasic_Document), anent5)) + { aDocIds->SetValue(i5, anent5); + } } } @@ -123,7 +129,9 @@ void RWStepBasic_RWProductDefinitionWithAssociatedDocuments::WriteStep( SW.OpenSub(); int i, nb = ent->NbDocIds(); for (i = 1; i <= nb; i++) + { SW.Send(ent->DocIdsValue(i)); + } SW.CloseSub(); } @@ -138,5 +146,7 @@ void RWStepBasic_RWProductDefinitionWithAssociatedDocuments::Share( int i, nb = ent->NbDocIds(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->DocIdsValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductRelatedProductCategory.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductRelatedProductCategory.cxx index 47f3ad0d88..fe22cc825b 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductRelatedProductCategory.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductRelatedProductCategory.cxx @@ -32,7 +32,9 @@ void RWStepBasic_RWProductRelatedProductCategory::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "product_related_product_category")) + { return; + } // --- inherited field : name --- @@ -68,7 +70,9 @@ void RWStepBasic_RWProductRelatedProductCategory::ReadStep( { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "product", ach, STANDARD_TYPE(StepBasic_Product), anent3)) + { aProducts->SetValue(i3, anent3); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductType.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductType.cxx index 506597c928..c35cf3fbcd 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductType.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWProductType.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWProductType::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "product_type")) + { return; + } // --- inherited field : name --- @@ -66,7 +68,9 @@ void RWStepBasic_RWProductType::ReadStep(const occ::handleReadEntity(nsub3, i3, "product", ach, STANDARD_TYPE(StepBasic_Product), anent3)) + { aProducts->SetValue(i3, anent3); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRatioMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRatioMeasureWithUnit.cxx index cc7caa5424..099ccaa427 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRatioMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRatioMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWRatioMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "ratio_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRoleAssociation.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRoleAssociation.cxx index c12572af2d..968870fc16 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRoleAssociation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWRoleAssociation.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWRoleAssociation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "role_association")) + { return; + } // Own fields of RoleAssociation diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassification.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassification.cxx index da960a1102..76256b941f 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassification.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWSecurityClassification::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "security_classification")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassificationLevel.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassificationLevel.cxx index f6d6fc77b2..87cf46b5d1 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassificationLevel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSecurityClassificationLevel.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWSecurityClassificationLevel::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "security_classification_level")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnit.cxx index b79db1eb9e..d4f735ceab 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnit.cxx @@ -30,7 +30,9 @@ void RWStepBasic_RWSiUnit::ReadStep(const occ::handle& { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "si_unit")) + { return; + } // --- inherited field : dimensions --- // --- this field is redefined --- @@ -68,7 +70,9 @@ void RWStepBasic_RWSiUnit::ReadStep(const occ::handle& } } else + { ach->AddFail("Parameter #3 (name) is not an enumeration"); + } //--- Initialisation of the read entity --- ent->Init(hasAprefix, aPrefix, aName); @@ -84,9 +88,13 @@ void RWStepBasic_RWSiUnit::WriteStep(StepData_StepWriter& SW, // --- own field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- own field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndAreaUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndAreaUnit.cxx index e87454f4ac..a0013de771 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndAreaUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndAreaUnit.cxx @@ -34,11 +34,15 @@ void RWStepBasic_RWSiUnitAndAreaUnit::ReadStep( int num = 0; data->NamedForComplex("AREA_UNIT", "ARUNT", num0, num, ach); if (!data->CheckNbParams(num, 0, ach, "area_unit")) + { return; + } data->NamedForComplex("NAMED_UNIT", "NMDUNT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } occ::handle aDimensions; data->ReadEntity(num, 1, @@ -49,7 +53,9 @@ void RWStepBasic_RWSiUnitAndAreaUnit::ReadStep( data->NamedForComplex("SI_UNIT", "SUNT", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } StepBasic_SiPrefix aPrefix = StepBasic_spExa; bool hasAprefix = false; @@ -103,9 +109,13 @@ void RWStepBasic_RWSiUnitAndAreaUnit::WriteStep( bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); } diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndLengthUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndLengthUnit.cxx index 0600e77fc5..fe413f48c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndLengthUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndLengthUnit.cxx @@ -37,15 +37,21 @@ void RWStepBasic_RWSiUnitAndLengthUnit::ReadStep( // --- Instance of plex component LengthUnit --- if (!data->CheckNbParams(num, 0, ach, "length_unit")) + { return; + } if (!sorted) + { num = 0; // pdn unsorted case + } sorted &= data->NamedForComplex("NAMED_UNIT", "NMDUNT", num0, num, ach); // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- this field is redefined --- @@ -53,12 +59,16 @@ void RWStepBasic_RWSiUnitAndLengthUnit::ReadStep( data->CheckDerived(num, 1, "dimensions", ach, false); if (!sorted) + { num = 0; // pdn unsorted case + } data->NamedForComplex("SI_UNIT", "SUNT", num0, num, ach); // --- Instance of plex component SiUnit --- if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -124,9 +134,13 @@ void RWStepBasic_RWSiUnitAndLengthUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndMassUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndMassUnit.cxx index d98ea6572d..0bdfe17b19 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndMassUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndMassUnit.cxx @@ -39,15 +39,21 @@ void RWStepBasic_RWSiUnitAndMassUnit::ReadStep( // --- Instance of plex component LengthUnit --- if (!data->CheckNbParams(num, 0, ach, "mass_unit")) + { return; + } if (!sorted) + { num = 0; // pdn unsorted case + } sorted &= data->NamedForComplex("NAMED_UNIT", "NMDUNT", num0, num, ach); // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- this field is redefined --- @@ -55,12 +61,16 @@ void RWStepBasic_RWSiUnitAndMassUnit::ReadStep( data->CheckDerived(num, 1, "dimensions", ach, false); if (!sorted) + { num = 0; // pdn unsorted case + } data->NamedForComplex("SI_UNIT", "SUNT", num0, num, ach); // --- Instance of plex component SiUnit --- if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -126,9 +136,13 @@ void RWStepBasic_RWSiUnitAndMassUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndPlaneAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndPlaneAngleUnit.cxx index 4c52b24037..7fa76b7c12 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndPlaneAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndPlaneAngleUnit.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWSiUnitAndPlaneAngleUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- this field is redefined --- @@ -44,12 +46,16 @@ void RWStepBasic_RWSiUnitAndPlaneAngleUnit::ReadStep( // --- Instance of plex component PlaneAngleUnit --- if (!data->CheckNbParams(num, 0, ach, "plane_angle_unit")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component SiUnit --- if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -114,9 +120,13 @@ void RWStepBasic_RWSiUnitAndPlaneAngleUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndRatioUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndRatioUnit.cxx index 2cb3b55a0b..e587083442 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndRatioUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndRatioUnit.cxx @@ -35,7 +35,9 @@ void RWStepBasic_RWSiUnitAndRatioUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- this field is redefined --- @@ -45,12 +47,16 @@ void RWStepBasic_RWSiUnitAndRatioUnit::ReadStep( // --- Instance of plex component RatioUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 0, ach, "ratio_unit")) + { return; + } // --- Instance of plex component SiUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -115,9 +121,13 @@ void RWStepBasic_RWSiUnitAndRatioUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndSolidAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndSolidAngleUnit.cxx index 739756804f..28d91585e1 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndSolidAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndSolidAngleUnit.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWSiUnitAndSolidAngleUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- This field is redefined --- @@ -44,7 +46,9 @@ void RWStepBasic_RWSiUnitAndSolidAngleUnit::ReadStep( // --- Instance of plex component SiUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -88,7 +92,9 @@ void RWStepBasic_RWSiUnitAndSolidAngleUnit::ReadStep( // --- Instance of plex component SolidAngleUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 0, ach, "solid_angle_unit")) + { return; + } //--- Initialisation of the red entity --- ent->Init(hasAprefix, aPrefix, aName); @@ -111,9 +117,13 @@ void RWStepBasic_RWSiUnitAndSolidAngleUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.cxx index 439d06ede3..30384c18e3 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.cxx @@ -39,7 +39,9 @@ void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- This field is redefined --- @@ -49,7 +51,9 @@ void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::ReadStep( // --- Instance of plex component SiUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -93,7 +97,9 @@ void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::ReadStep( // --- Instance of plex component SolidAngleUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 0, ach, "thermodynamic_temperature_unit")) + { return; + } //--- Initialisation of the red entity --- ent->Init(hasAprefix, aPrefix, aName); @@ -118,9 +124,13 @@ void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndTimeUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndTimeUnit.cxx index 5a4beaaa95..e66ab62fad 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndTimeUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndTimeUnit.cxx @@ -38,7 +38,9 @@ void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep( // --- Instance of common supertype NamedUnit --- if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } // --- field : dimensions --- // --- this field is redefined --- @@ -48,7 +50,9 @@ void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep( // --- Instance of plex component SiUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } // --- field : prefix --- StepBasic_SiPrefix aPrefix = StepBasic_spExa; @@ -92,7 +96,9 @@ void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep( // --- Instance of plex component TimeUnit --- num = data->NextForComplex(num); if (!data->CheckNbParams(num, 0, ach, "time_unit")) + { return; + } //--- Initialisation of the red entity --- ent->Init(hasAprefix, aPrefix, aName); @@ -121,9 +127,13 @@ void RWStepBasic_RWSiUnitAndTimeUnit::WriteStep( // --- field : prefix --- bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } // --- field : name --- SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndVolumeUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndVolumeUnit.cxx index eab864532d..ec3aec130e 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndVolumeUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSiUnitAndVolumeUnit.cxx @@ -34,7 +34,9 @@ void RWStepBasic_RWSiUnitAndVolumeUnit::ReadStep( int num = 0; data->NamedForComplex("NAMED_UNIT", "NMDUNT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "named_unit")) + { return; + } occ::handle aDimensions; data->ReadEntity(num, 1, @@ -45,7 +47,9 @@ void RWStepBasic_RWSiUnitAndVolumeUnit::ReadStep( data->NamedForComplex("SI_UNIT", "SUNT", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "si_unit")) + { return; + } StepBasic_SiPrefix aPrefix = StepBasic_spExa; bool hasAprefix = false; @@ -86,7 +90,9 @@ void RWStepBasic_RWSiUnitAndVolumeUnit::ReadStep( data->NamedForComplex("VOLUME_UNIT", "VLMUNT", num0, num, ach); if (!data->CheckNbParams(num, 0, ach, "volume_unit")) + { return; + } ent->Init(hasAprefix, aPrefix, aName); ent->SetDimensions(aDimensions); @@ -102,9 +108,13 @@ void RWStepBasic_RWSiUnitAndVolumeUnit::WriteStep( bool hasAprefix = ent->HasPrefix(); if (hasAprefix) + { SW.SendEnum(RWStepBasic_RWSiPrefix::ConvertToString(ent->Prefix())); + } else + { SW.SendUndef(); + } SW.SendEnum(RWStepBasic_RWSiUnitName::ConvertToString(ent->Name())); SW.StartEntity("VOLUME_UNIT"); diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleMeasureWithUnit.cxx index 0990ca6574..70712f6532 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleMeasureWithUnit.cxx @@ -33,7 +33,9 @@ void RWStepBasic_RWSolidAngleMeasureWithUnit::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "solid_angle_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- // --- Update 12-02-96 by FMA , 31-MARS-1997 by CKY diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleUnit.cxx index a806a84195..d54180cbef 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWSolidAngleUnit.cxx @@ -29,7 +29,9 @@ void RWStepBasic_RWSolidAngleUnit::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "solid_angle_unit")) + { return; + } // --- inherited field : dimensions --- diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWThermodynamicTemperatureUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWThermodynamicTemperatureUnit.cxx index 0bf905ad2d..2e1e6e6918 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWThermodynamicTemperatureUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWThermodynamicTemperatureUnit.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWThermodynamicTemperatureUnit::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "thermodynamic_temperature_unit")) + { return; + } // Inherited fields of NamedUnit diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWUncertaintyMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWUncertaintyMeasureWithUnit.cxx index 5be46320f9..6d6f6e9f79 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWUncertaintyMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWUncertaintyMeasureWithUnit.cxx @@ -54,7 +54,9 @@ void RWStepBasic_RWUncertaintyMeasureWithUnit::ReadStep( num1 = data->NextForComplex(num1); if (!data->CheckNbParams(num1, 2, ach, "measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; @@ -68,7 +70,9 @@ void RWStepBasic_RWUncertaintyMeasureWithUnit::ReadStep( num1 = data->NextForComplex(num1); if (!data->CheckNbParams(num1, 2, ach, "uncertainty_measure_with_unit")) + { return; + } // --- own field : name --- occ::handle aName; @@ -89,7 +93,9 @@ void RWStepBasic_RWUncertaintyMeasureWithUnit::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "uncertainty_measure_with_unit")) + { return; + } // --- inherited field : valueComponent --- // double aValueComponent; diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWVersionedActionRequest.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWVersionedActionRequest.cxx index ea04b6c887..d9b7f88856 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWVersionedActionRequest.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWVersionedActionRequest.cxx @@ -36,7 +36,9 @@ void RWStepBasic_RWVersionedActionRequest::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "versioned_action_request")) + { return; + } // Own fields of VersionedActionRequest @@ -84,7 +86,9 @@ void RWStepBasic_RWVersionedActionRequest::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWWeekOfYearAndDayDate.cxx b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWWeekOfYearAndDayDate.cxx index 9502a67e4e..d2a4e59a8d 100644 --- a/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWWeekOfYearAndDayDate.cxx +++ b/src/DataExchange/TKDESTEP/RWStepBasic/RWStepBasic_RWWeekOfYearAndDayDate.cxx @@ -28,7 +28,9 @@ void RWStepBasic_RWWeekOfYearAndDayDate::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "week_of_year_and_day_date")) + { return; + } // --- inherited field : yearComponent --- diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWAngularityTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWAngularityTolerance.cxx index 38d0c81253..1a2086a940 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWAngularityTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWAngularityTolerance.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWAngularityTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "angularity_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCircularRunoutTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCircularRunoutTolerance.cxx index 038d5ddb58..94a8da5853 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCircularRunoutTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCircularRunoutTolerance.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWCircularRunoutTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "circular_runout_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCoaxialityTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCoaxialityTolerance.cxx index a48f7063c5..0d96c4ec67 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCoaxialityTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCoaxialityTolerance.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWCoaxialityTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "coaxiality_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCommonDatum.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCommonDatum.cxx index 3d1d1f3cd7..b7b90d12b8 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCommonDatum.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCommonDatum.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWCommonDatum::ReadStep(const occ::handleCheckNbParams(num, 9, ach, "common_datum")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWConcentricityTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWConcentricityTolerance.cxx index ae9bc8fc96..0de16dd27e 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWConcentricityTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWConcentricityTolerance.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWConcentricityTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "concentricity_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCylindricityTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCylindricityTolerance.cxx index 945603f94e..1db4089022 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCylindricityTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWCylindricityTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWCylindricityTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "cylindricity_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatum.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatum.cxx index 9f1a46cdb6..52a1cea235 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatum.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatum.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWDatum::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "datum")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumFeature.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumFeature.cxx index 99549eac9b..39fc656d94 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumFeature.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumFeature.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWDatumFeature::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "datum_feature")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReference.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReference.cxx index 51f0eda00d..f387e971d7 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReference.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWDatumReference::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "datum_reference")) + { return; + } // Own fields of DatumReference diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceCompartment.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceCompartment.cxx index 8cfbdde0a9..0637f5261d 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceCompartment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceCompartment.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWDatumReferenceCompartment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "datum_reference_element")) + { return; + } // Inherited fields of ShapeAspect @@ -111,7 +113,9 @@ void RWStepDimTol_RWDatumReferenceCompartment::ReadStep( ach, STANDARD_TYPE(StepDimTol_DatumReferenceElement), anEnt)) + { anItems->SetValue(i, anEnt); + } } } aBase.SetValue(anItems); @@ -194,7 +198,9 @@ void RWStepDimTol_RWDatumReferenceCompartment::WriteStep( int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); SW.OpenTypedSub("COMMON_DATUM_LIST"); for (i = 1; i <= nb; i++) + { SW.Send(anArray->Value(i)); + } SW.CloseSub(); } @@ -247,6 +253,8 @@ void RWStepDimTol_RWDatumReferenceCompartment::Share( ent->Base().CommonDatumList(); int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); for (i = 1; i <= nb; i++) + { iter.AddItem(anArray->Value(i)); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceElement.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceElement.cxx index 1b335fbfe1..f672499099 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceElement.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceElement.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWDatumReferenceElement::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "datum_reference_element")) + { return; + } // Inherited fields of ShapeAspect @@ -111,7 +113,9 @@ void RWStepDimTol_RWDatumReferenceElement::ReadStep( ach, STANDARD_TYPE(StepDimTol_DatumReferenceElement), anEnt)) + { anItems->SetValue(i, anEnt); + } } } aBase.SetValue(anItems); @@ -194,7 +198,9 @@ void RWStepDimTol_RWDatumReferenceElement::WriteStep( int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); SW.OpenTypedSub("COMMON_DATUM_LIST"); for (i = 1; i <= nb; i++) + { SW.Send(anArray->Value(i)); + } SW.CloseSub(); } @@ -247,6 +253,8 @@ void RWStepDimTol_RWDatumReferenceElement::Share( ent->Base().CommonDatumList(); int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); for (i = 1; i <= nb; i++) + { iter.AddItem(anArray->Value(i)); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceModifierWithValue.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceModifierWithValue.cxx index 4e0a9fa5e7..783c2e6a6d 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceModifierWithValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumReferenceModifierWithValue.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWDatumReferenceModifierWithValue::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "datum_reference_modifier_with_value")) + { return; + } // own fields of DatumReferenceModifierWithValue @@ -44,18 +46,30 @@ void RWStepDimTol_RWDatumReferenceModifierWithValue::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".CIRCULAR_OR_CYLINDRICAL.") == 0) + { aModifierType = StepDimTol_CircularOrCylindrical; + } else if (strcmp(text, ".DISTANCE.") == 0) + { aModifierType = StepDimTol_Distance; + } else if (strcmp(text, ".PROJECTED.") == 0) + { aModifierType = StepDimTol_Projected; + } else if (strcmp(text, ".SPHERICAL.") == 0) + { aModifierType = StepDimTol_Spherical; + } else + { ach->AddFail("Parameter #1 (modifier_type) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (modifier_type) is not an enumeration"); + } occ::handle aModifierValue; data->ReadEntity(num, diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumSystem.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumSystem.cxx index 23b4f82699..063bce5360 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumSystem.cxx @@ -34,7 +34,9 @@ void RWStepDimTol_RWDatumSystem::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "datum_system")) + { return; + } // Inherited fields of ShapeAspect @@ -80,7 +82,9 @@ void RWStepDimTol_RWDatumSystem::ReadStep(const occ::handleSetValue(i, anEnt); + } } } @@ -112,7 +116,9 @@ void RWStepDimTol_RWDatumSystem::WriteStep(StepData_StepWriter& int i, nb = ent->NbConstituents(); SW.OpenSub(); for (i = 1; i <= nb; i++) + { SW.Send(ent->ConstituentsValue(i)); + } SW.CloseSub(); } @@ -129,5 +135,7 @@ void RWStepDimTol_RWDatumSystem::Share(const occ::handle // Own fields of DatumSystem int i, nb = ent->NbConstituents(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ConstituentsValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumTarget.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumTarget.cxx index 4194bce355..4aac027786 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumTarget.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWDatumTarget.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWDatumTarget::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "datum_target")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWFlatnessTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWFlatnessTolerance.cxx index f802570175..ef168f3155 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWFlatnessTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWFlatnessTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWFlatnessTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "flatness_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeneralDatumReference.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeneralDatumReference.cxx index 3e32e66355..b9c6ca0e1f 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeneralDatumReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeneralDatumReference.cxx @@ -39,7 +39,9 @@ void RWStepDimTol_RWGeneralDatumReference::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "general_datum_reference")) + { return; + } // Inherited fields of ShapeAspect @@ -109,7 +111,9 @@ void RWStepDimTol_RWGeneralDatumReference::ReadStep( ach, STANDARD_TYPE(StepDimTol_DatumReferenceElement), anEnt)) + { anItems->SetValue(i, anEnt); + } } } aBase.SetValue(anItems); @@ -192,7 +196,9 @@ void RWStepDimTol_RWGeneralDatumReference::WriteStep( int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); SW.OpenTypedSub("COMMON_DATUM_LIST"); for (i = 1; i <= nb; i++) + { SW.Send(anArray->Value(i)); + } SW.CloseSub(); } @@ -245,6 +251,8 @@ void RWStepDimTol_RWGeneralDatumReference::Share( ent->Base().CommonDatumList(); int i, nb = (anArray.IsNull() ? 0 : anArray->Length()); for (i = 1; i <= nb; i++) + { iter.AddItem(anArray->Value(i)); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.cxx index 12b88f9a1a..b15ac81ec3 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.cxx @@ -40,7 +40,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -79,37 +81,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::ReadStep( const char* aLast = aTypes.Last().ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aType); @@ -123,17 +157,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -153,23 +199,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::WriteStep( SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx index aa6994ee1b..d0d5062eff 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx @@ -43,7 +43,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -100,40 +102,74 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } @@ -148,37 +184,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::ReadStep( const char* aLast = aTypes.Last().ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aGTWM, aMaxTol, aType); @@ -192,17 +260,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -281,23 +361,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::WriteStep( SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx index f497a11e27..d36226b911 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx @@ -42,7 +42,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -90,40 +92,74 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } @@ -138,37 +174,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::ReadStep( const char* aLast = aTypes.Last().ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aGTWM, aType); @@ -182,17 +250,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -269,23 +349,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::WriteStep( SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx index 80a2125f0b..832391d0db 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx @@ -40,7 +40,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -79,16 +81,26 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".MAXIMUM_MATERIAL_CONDITION.") == 0) + { aModifier = StepDimTol_MaximumMaterialCondition; + } else if (strcmp(text, ".LEAST_MATERIAL_CONDITION.") == 0) + { aModifier = StepDimTol_LeastMaterialCondition; + } else if (strcmp(text, ".REGARDLESS_OF_FEATURE_SIZE.") == 0) + { aModifier = StepDimTol_RegardlessOfFeatureSize; + } else + { ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE has not allowed value"); + } } else + { ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE is not enumeration"); + } occ::handle MGT = new StepDimTol_ModifiedGeometricTolerance; MGT->SetModifier(aModifier); diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx index 7336169f25..709a902bdd 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -93,37 +95,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::ReadStep( const char* aLast = aTypes.Value(3).ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aType, anUDGT); @@ -137,17 +171,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -167,23 +213,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::WriteStep( SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } SW.StartEntity("UNEQUALLY_DISPOSED_GEOMETRIC_TOLRANCE"); SW.Send(ent->GetUnequallyDisposedGeometricTolerance()->Displacement()); diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx index e8f69b4d22..c16a5a752b 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx @@ -38,7 +38,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -74,40 +76,74 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } @@ -122,37 +158,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::ReadStep( const char* aLast = aTypes.Last().ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWM, aMaxTol, aType); @@ -166,17 +234,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -242,23 +322,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::WriteStep( } SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMod.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMod.cxx index 9adccc31ad..42273b86c8 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMod.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMod.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMod::ReadStep( int num = 0; // num0; data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -64,40 +66,74 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMod::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } @@ -112,37 +148,69 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMod::ReadStep( const char* aLast = aTypes.Last().ToCString(); StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTAngularityTolerance; + } else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTCircularRunoutTolerance; + } else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCoaxialityTolerance; + } else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTConcentricityTolerance; + } else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTCylindricityTolerance; + } else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTFlatnessTolerance; + } else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTLineProfileTolerance; + } else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) + { aType = StepDimTol_GTTParallelismTolerance; + } else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) + { aType = StepDimTol_GTTPerpendicularityTolerance; + } else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) + { aType = StepDimTol_GTTPositionTolerance; + } else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTRoundnessTolerance; + } else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) + { aType = StepDimTol_GTTStraightnessTolerance; + } else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) + { aType = StepDimTol_GTTSurfaceProfileTolerance; + } else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) + { aType = StepDimTol_GTTSymmetryTolerance; + } else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) + { aType = StepDimTol_GTTTotalRunoutTolerance; + } else + { ach->AddFail("The type of geometric tolerance is not supported"); + } // Initialize entity ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWM, aType); @@ -156,17 +224,29 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMod::WriteStep( { StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); if (aType == StepDimTol_GTTAngularityTolerance) + { SW.StartEntity("ANGULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCircularRunoutTolerance) + { SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); + } else if (aType == StepDimTol_GTTCoaxialityTolerance) + { SW.StartEntity("COAXIALITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTConcentricityTolerance) + { SW.StartEntity("CONCENTRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTCylindricityTolerance) + { SW.StartEntity("CYLINDRICITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTFlatnessTolerance) + { SW.StartEntity("FLATNESS_TOLERANCE"); + } SW.StartEntity("GEOMETRIC_TOLERANCE"); SW.Send(ent->Name()); @@ -230,23 +310,41 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthMod::WriteStep( } SW.CloseSub(); if (aType == StepDimTol_GTTLineProfileTolerance) + { SW.StartEntity("LINE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTParallelismTolerance) + { SW.StartEntity("PARALLELISM_TOLERANCE"); + } else if (aType == StepDimTol_GTTPerpendicularityTolerance) + { SW.StartEntity("PERPENDICULARITY_TOLERANCE"); + } else if (aType == StepDimTol_GTTPositionTolerance) + { SW.StartEntity("POSITION_TOLERANCE"); + } else if (aType == StepDimTol_GTTRoundnessTolerance) + { SW.StartEntity("ROUNDNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTStraightnessTolerance) + { SW.StartEntity("STRAIGHTNESS_TOLERANCE"); + } else if (aType == StepDimTol_GTTSurfaceProfileTolerance) + { SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); + } else if (aType == StepDimTol_GTTSymmetryTolerance) + { SW.StartEntity("SYMMETRY_TOLERANCE"); + } else if (aType == StepDimTol_GTTTotalRunoutTolerance) + { SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricTolerance.cxx index d43dcf90cb..06f87e9b7b 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWGeometricTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance")) + { return; + } // Own fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceRelationship.cxx index 9180b94935..5381a4e989 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceRelationship.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWGeometricToleranceRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance_relationship")) + { return; + } // Own fields of GeometricToleranceRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDatumReference.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDatumReference.cxx index 6d91c2e7d4..9a72bf4a40 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDatumReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDatumReference.cxx @@ -41,7 +41,9 @@ void RWStepDimTol_RWGeometricToleranceWithDatumReference::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "geometric_tolerance_with_datum_reference")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit.cxx index 1c0ea880d7..ec1d2b462d 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 7, ach, "geometric_tolerance_with_defined_area_unit")) + { return; + } // inherited fields from GeometricTolerance @@ -78,26 +80,38 @@ void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::ReadStep( { const char* text = data->ParamCValue(num, 6); if (strcmp(text, ".CIRCULAR.") == 0) + { aType = StepDimTol_Circular; + } else if (strcmp(text, ".RECTANGULAR.") == 0) + { aType = StepDimTol_Rectangular; + } else if (strcmp(text, ".SQUARE.") == 0) + { aType = StepDimTol_Square; + } else + { ach->AddFail("Parameter #6 (area_type) has not allowed value"); + } } else + { ach->AddFail("Parameter #6 (area_type) is not enumerations"); + } occ::handle aSecondUnitSize; bool hasSecondUnitSize = data->IsParamDefined(num, 7); if (hasSecondUnitSize) + { data->ReadEntity(num, 7, "second_unit_size", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aSecondUnitSize); + } // Initialize entity ent->Init(aName, @@ -147,9 +161,13 @@ void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::WriteStep( } if (ent->HasSecondUnitSize()) + { SW.Send(ent->SecondUnitSize()); + } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedUnit.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedUnit.cxx index 21f9c988ff..1d90cfe0c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithDefinedUnit.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWGeometricToleranceWithDefinedUnit::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "geometric_tolerance_with_defined_unit")) + { return; + } // inherited fields from GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithMaximumTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithMaximumTolerance.cxx index 759ffa642d..64a856e433 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithMaximumTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithMaximumTolerance.cxx @@ -40,7 +40,9 @@ void RWStepDimTol_RWGeometricToleranceWithMaximumTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "geometric_tolerance_with_modifiers")) + { return; + } // inherited fields from GeometricTolerance @@ -80,40 +82,74 @@ void RWStepDimTol_RWGeometricToleranceWithMaximumTolerance::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithModifiers.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithModifiers.cxx index a26c521361..5a5f44237f 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithModifiers.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWGeometricToleranceWithModifiers.cxx @@ -40,7 +40,9 @@ void RWStepDimTol_RWGeometricToleranceWithModifiers::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "geometric_tolerance_with_modifiers")) + { return; + } // inherited fields from GeometricTolerance @@ -80,40 +82,74 @@ void RWStepDimTol_RWGeometricToleranceWithModifiers::ReadStep( { const char* text = data->ParamCValue(num2, i0); if (strcmp(text, ".ANY_CROSS_SECTION.") == 0) + { anIt0 = StepDimTol_GTMAnyCrossSection; + } else if (strcmp(text, ".COMMON_ZONE.") == 0) + { anIt0 = StepDimTol_GTMCommonZone; + } else if (strcmp(text, ".EACH_RADIAL_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMEachRadialElement; + } else if (strcmp(text, ".FREE_STATE.") == 0) + { anIt0 = StepDimTol_GTMFreeState; + } else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMLeastMaterialRequirement; + } else if (strcmp(text, ".LINE_ELEMENT.") == 0) + { anIt0 = StepDimTol_GTMLineElement; + } else if (strcmp(text, ".MAJOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMajorDiameter; + } else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMMaximumMaterialRequirement; + } else if (strcmp(text, ".MINOR_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMMinorDiameter; + } else if (strcmp(text, ".NOT_CONVEX.") == 0) + { anIt0 = StepDimTol_GTMNotConvex; + } else if (strcmp(text, ".PITCH_DIAMETER.") == 0) + { anIt0 = StepDimTol_GTMPitchDiameter; + } else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMReciprocityRequirement; + } else if (strcmp(text, ".SEPARATE_REQUIREMENT.") == 0) + { anIt0 = StepDimTol_GTMSeparateRequirement; + } else if (strcmp(text, ".STATISTICAL_TOLERANCE.") == 0) + { anIt0 = StepDimTol_GTMStatisticalTolerance; + } else if (strcmp(text, ".TANGENT_PLANE.") == 0) + { anIt0 = StepDimTol_GTMTangentPlane; + } else + { ach->AddFail("Parameter #5 (modifiers) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); + } aModifiers->SetValue(i0, anIt0); } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWLineProfileTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWLineProfileTolerance.cxx index 89366a2bbd..215d9a13f7 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWLineProfileTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWLineProfileTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWLineProfileTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "line_profile_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWModifiedGeometricTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWModifiedGeometricTolerance.cxx index 76d634c25c..9119b00f62 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWModifiedGeometricTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWModifiedGeometricTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWModifiedGeometricTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "modified_geometric_tolerance")) + { return; + } // Inherited fields of GeometricTolerance @@ -68,16 +70,26 @@ void RWStepDimTol_RWModifiedGeometricTolerance::ReadStep( { const char* text = data->ParamCValue(num, 5); if (strcmp(text, ".MAXIMUM_MATERIAL_CONDITION.") == 0) + { aModifier = StepDimTol_MaximumMaterialCondition; + } else if (strcmp(text, ".LEAST_MATERIAL_CONDITION.") == 0) + { aModifier = StepDimTol_LeastMaterialCondition; + } else if (strcmp(text, ".REGARDLESS_OF_FEATURE_SIZE.") == 0) + { aModifier = StepDimTol_RegardlessOfFeatureSize; + } else + { ach->AddFail("Parameter #5 (modifier) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (modifier) is not enumeration"); + } // Initialize entity ent->Init(aGeometricTolerance_Name, diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWNonUniformZoneDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWNonUniformZoneDefinition.cxx index 6d194ae3cc..dd752b5019 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWNonUniformZoneDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWNonUniformZoneDefinition.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWNonUniformZoneDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "non_uniform_zone_definition")) + { return; + } // Inherited fields from ToleranceZoneDefinition @@ -59,7 +61,9 @@ void RWStepDimTol_RWNonUniformZoneDefinition::ReadStep( { if (data ->ReadEntity(nbSub, i, "shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -98,5 +102,7 @@ void RWStepDimTol_RWNonUniformZoneDefinition::Share( int i, nb = ent->NbBoundaries(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->BoundariesValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWParallelismTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWParallelismTolerance.cxx index fd62dd7124..ae0bb90bd7 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWParallelismTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWParallelismTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWParallelismTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "parallelism_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPerpendicularityTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPerpendicularityTolerance.cxx index 77c61170c9..e0cb70e93a 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPerpendicularityTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPerpendicularityTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWPerpendicularityTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "perpendicularity_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPlacedDatumTargetFeature.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPlacedDatumTargetFeature.cxx index 9b6ae1f3dc..3206ec9a22 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPlacedDatumTargetFeature.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPlacedDatumTargetFeature.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWPlacedDatumTargetFeature::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "placed_datum_target_feature")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPositionTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPositionTolerance.cxx index 7c4840854c..efb2e06de6 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPositionTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWPositionTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWPositionTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "position_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWProjectedZoneDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWProjectedZoneDefinition.cxx index 0f8e8350a2..c7e2c6adf9 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWProjectedZoneDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWProjectedZoneDefinition.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWProjectedZoneDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "projected_zone_definition")) + { return; + } // Inherited fields from ToleranceZoneDefinition @@ -59,7 +61,9 @@ void RWStepDimTol_RWProjectedZoneDefinition::ReadStep( { if (data ->ReadEntity(nbSub, i, "shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -120,7 +124,9 @@ void RWStepDimTol_RWProjectedZoneDefinition::Share( int i, nb = ent->NbBoundaries(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->BoundariesValue(i)); + } // Own field of ProjectionZoneDefinition iter.AddItem(ent->ProjectionEnd()); diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRoundnessTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRoundnessTolerance.cxx index f522061ffe..4778dfe2b2 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRoundnessTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRoundnessTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWRoundnessTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "roundness_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneDefinition.cxx index 7956d4ac57..0b82822ad8 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneDefinition.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWRunoutZoneDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "runout_zone_definition")) + { return; + } // inherited fields from ToleranceZoneDefinition @@ -60,7 +62,9 @@ void RWStepDimTol_RWRunoutZoneDefinition::ReadStep( { if (data ->ReadEntity(nbSub, i, "shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -107,5 +111,7 @@ void RWStepDimTol_RWRunoutZoneDefinition::Share( int i, nb = ent->NbBoundaries(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->BoundariesValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneOrientation.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneOrientation.cxx index 6e58290ad6..589425f9d2 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneOrientation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWRunoutZoneOrientation.cxx @@ -33,7 +33,9 @@ void RWStepDimTol_RWRunoutZoneOrientation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "runout_zone_orientation")) + { return; + } // Own fields of RunoutZoneOrientation diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWStraightnessTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWStraightnessTolerance.cxx index b80e72e601..fc870a63d0 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWStraightnessTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWStraightnessTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWStraightnessTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "straightness_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSurfaceProfileTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSurfaceProfileTolerance.cxx index eadf137a5e..965c2774be 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSurfaceProfileTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSurfaceProfileTolerance.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWSurfaceProfileTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "surface_profile_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSymmetryTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSymmetryTolerance.cxx index 514a819282..c931bfc812 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSymmetryTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWSymmetryTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWSymmetryTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "symmetry_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZone.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZone.cxx index 39a278b98e..4a68c698ab 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZone.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZone.cxx @@ -36,7 +36,9 @@ void RWStepDimTol_RWToleranceZone::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "tolerance_zone")) + { return; + } // Inherited fields of ShapeAspect @@ -76,7 +78,9 @@ void RWStepDimTol_RWToleranceZone::ReadStep(const occ::handleReadEntity(nbSub, i, "tolerance_zone_target", ach, anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -133,5 +137,7 @@ void RWStepDimTol_RWToleranceZone::Share(const occ::handleNbDefiningTolerances(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->DefiningToleranceValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneDefinition.cxx index 66dd62b5c8..5a26ddb1c8 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneDefinition.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWToleranceZoneDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "tolerance_zone_definition")) + { return; + } // Own fields of ToleranceZoneDefinition @@ -53,7 +55,9 @@ void RWStepDimTol_RWToleranceZoneDefinition::ReadStep( { if (data ->ReadEntity(nbSub, i, "shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), anEnt)) + { anItems->SetValue(i, anEnt); + } } } @@ -92,5 +96,7 @@ void RWStepDimTol_RWToleranceZoneDefinition::Share( int i, nb = ent->NbBoundaries(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->BoundariesValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneForm.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneForm.cxx index 48746890fa..16fe7995f8 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneForm.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWToleranceZoneForm.cxx @@ -33,7 +33,9 @@ void RWStepDimTol_RWToleranceZoneForm::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "tolerance_zone_form")) + { return; + } // Own fields of ToleranceZoneForm diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWTotalRunoutTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWTotalRunoutTolerance.cxx index 402fa0833c..ab750bbb68 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWTotalRunoutTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWTotalRunoutTolerance.cxx @@ -37,7 +37,9 @@ void RWStepDimTol_RWTotalRunoutTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "total_runout_tolerance")) + { return; + } // Inherited fields of GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWUnequallyDisposedGeometricTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWUnequallyDisposedGeometricTolerance.cxx index cc3fe26511..2a0a4d9274 100644 --- a/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWUnequallyDisposedGeometricTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepDimTol/RWStepDimTol_RWUnequallyDisposedGeometricTolerance.cxx @@ -35,7 +35,9 @@ void RWStepDimTol_RWUnequallyDisposedGeometricTolerance::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "unequally_disposed_geometric_tolerance")) + { return; + } // inherited from GeometricTolerance diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWAnalysisItemWithinRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWAnalysisItemWithinRepresentation.cxx index 23742ff301..f7bcdcae75 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWAnalysisItemWithinRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWAnalysisItemWithinRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepElement_RWAnalysisItemWithinRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "analysis_item_within_representation")) + { return; + } // Own fields of AnalysisItemWithinRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurve3dElementDescriptor.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurve3dElementDescriptor.cxx index 303c888e29..d87d7726ce 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurve3dElementDescriptor.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurve3dElementDescriptor.cxx @@ -41,7 +41,9 @@ void RWStepElement_RWCurve3dElementDescriptor::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "curve3d_element_descriptor")) + { return; + } // Inherited fields of ElementDescriptor @@ -50,16 +52,26 @@ void RWStepElement_RWCurve3dElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".LINEAR.") == 0) + { aElementDescriptor_TopologyOrder = StepElement_Linear; + } else if (strcmp(text, ".QUADRATIC.") == 0) + { aElementDescriptor_TopologyOrder = StepElement_Quadratic; + } else if (strcmp(text, ".CUBIC.") == 0) + { aElementDescriptor_TopologyOrder = StepElement_Cubic; + } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) is not enumeration"); + } occ::handle aElementDescriptor_Description; data->ReadString(num, 2, "element_descriptor.description", ach, aElementDescriptor_Description); diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementEndReleasePacket.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementEndReleasePacket.cxx index 244d112b8e..2f5c67f266 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementEndReleasePacket.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementEndReleasePacket.cxx @@ -36,7 +36,9 @@ void RWStepElement_RWCurveElementEndReleasePacket::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "curve_element_end_release_packet")) + { return; + } // Own fields of CurveElementEndReleasePacket diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDefinition.cxx index 6ac07d3e20..27d882ec15 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDefinition.cxx @@ -36,7 +36,9 @@ void RWStepElement_RWCurveElementSectionDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "curve_element_section_definition")) + { return; + } // Own fields of CurveElementSectionDefinition diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDerivedDefinitions.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDerivedDefinitions.cxx index 53a07522e0..e5e96baf06 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDerivedDefinitions.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWCurveElementSectionDerivedDefinitions.cxx @@ -41,7 +41,9 @@ void RWStepElement_RWCurveElementSectionDerivedDefinitions::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 12, ach, "curve_element_section_derived_definitions")) + { return; + } // Inherited fields of CurveElementSectionDefinition diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementDescriptor.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementDescriptor.cxx index a98adfa558..0f2646b157 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementDescriptor.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementDescriptor.cxx @@ -35,7 +35,9 @@ void RWStepElement_RWElementDescriptor::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "element_descriptor")) + { return; + } // Own fields of ElementDescriptor @@ -44,16 +46,26 @@ void RWStepElement_RWElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".LINEAR.") == 0) + { aTopologyOrder = StepElement_Linear; + } else if (strcmp(text, ".QUADRATIC.") == 0) + { aTopologyOrder = StepElement_Quadratic; + } else if (strcmp(text, ".CUBIC.") == 0) + { aTopologyOrder = StepElement_Cubic; + } else + { ach->AddFail("Parameter #1 (topology_order) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (topology_order) is not enumeration"); + } occ::handle aDescription; data->ReadString(num, 2, "description", ach, aDescription); diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementMaterial.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementMaterial.cxx index 74bdd2f699..ab8b101e18 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementMaterial.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWElementMaterial.cxx @@ -39,7 +39,9 @@ void RWStepElement_RWElementMaterial::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "element_material")) + { return; + } // Own fields of ElementMaterial diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurface3dElementDescriptor.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurface3dElementDescriptor.cxx index 6b709225ee..57d00289c2 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurface3dElementDescriptor.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurface3dElementDescriptor.cxx @@ -39,7 +39,9 @@ void RWStepElement_RWSurface3dElementDescriptor::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "surface3d_element_descriptor")) + { return; + } // Inherited fields of ElementDescriptor @@ -48,16 +50,26 @@ void RWStepElement_RWSurface3dElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 1); if (!strcmp(text, ".LINEAR.")) + { aElementDescriptor_TopologyOrder = StepElement_Linear; + } else if (!strcmp(text, ".QUADRATIC.")) + { aElementDescriptor_TopologyOrder = StepElement_Quadratic; + } else if (!strcmp(text, ".CUBIC.")) + { aElementDescriptor_TopologyOrder = StepElement_Cubic; + } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) is not enumeration"); + } occ::handle aElementDescriptor_Description; data->ReadString(num, 2, "element_descriptor.description", ach, aElementDescriptor_Description); @@ -102,14 +114,22 @@ void RWStepElement_RWSurface3dElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 4); if (!strcmp(text, ".QUADRILATERAL.")) + { aShape = StepElement_Quadrilateral; + } else if (!strcmp(text, ".TRIANGLE.")) + { aShape = StepElement_Triangle; + } else + { ach->AddFail("Parameter #4 (shape) has not allowed value"); + } } else + { ach->AddFail("Parameter #4 (shape) is not enumeration"); + } // Initialize entity ent->Init(aElementDescriptor_TopologyOrder, aElementDescriptor_Description, aPurpose, aShape); diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceElementProperty.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceElementProperty.cxx index 8ec57d7d59..a95cec7717 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceElementProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceElementProperty.cxx @@ -36,7 +36,9 @@ void RWStepElement_RWSurfaceElementProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "surface_element_property")) + { return; + } // Own fields of SurfaceElementProperty diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSection.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSection.cxx index e0ac080f38..4b1489246c 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSection.cxx @@ -35,7 +35,9 @@ void RWStepElement_RWSurfaceSection::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "surface_section")) + { return; + } // Own fields of SurfaceSection diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionField.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionField.cxx index 3bcb1d8034..20245e0494 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionField.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionField.cxx @@ -35,7 +35,9 @@ void RWStepElement_RWSurfaceSectionField::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 0, ach, "surface_section_field")) + { return; + } // Initialize entity // ent->Init(); diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldConstant.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldConstant.cxx index adb86813a1..1a2ed62b05 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldConstant.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldConstant.cxx @@ -37,7 +37,9 @@ void RWStepElement_RWSurfaceSectionFieldConstant::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "surface_section_field_constant")) + { return; + } // Own fields of SurfaceSectionFieldConstant diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldVarying.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldVarying.cxx index e909c25cea..465d4fe1b1 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldVarying.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWSurfaceSectionFieldVarying.cxx @@ -37,7 +37,9 @@ void RWStepElement_RWSurfaceSectionFieldVarying::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "surface_section_field_varying")) + { return; + } // Own fields of SurfaceSectionFieldVarying diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWUniformSurfaceSection.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWUniformSurfaceSection.cxx index 7b78344f41..f5b713b725 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWUniformSurfaceSection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWUniformSurfaceSection.cxx @@ -35,7 +35,9 @@ void RWStepElement_RWUniformSurfaceSection::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "uniform_surface_section")) + { return; + } // Inherited fields of SurfaceSection diff --git a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWVolume3dElementDescriptor.cxx b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWVolume3dElementDescriptor.cxx index 2a8681e582..eb397658b1 100644 --- a/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWVolume3dElementDescriptor.cxx +++ b/src/DataExchange/TKDESTEP/RWStepElement/RWStepElement_RWVolume3dElementDescriptor.cxx @@ -37,7 +37,9 @@ void RWStepElement_RWVolume3dElementDescriptor::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "volume3d_element_descriptor")) + { return; + } // Inherited fields of ElementDescriptor @@ -46,16 +48,26 @@ void RWStepElement_RWVolume3dElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 1); if (!strcmp(text, ".LINEAR.")) + { aElementDescriptor_TopologyOrder = StepElement_Linear; + } else if (!strcmp(text, ".QUADRATIC.")) + { aElementDescriptor_TopologyOrder = StepElement_Quadratic; + } else if (!strcmp(text, ".CUBIC.")) + { aElementDescriptor_TopologyOrder = StepElement_Cubic; + } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (element_descriptor.topology_order) is not enumeration"); + } occ::handle aElementDescriptor_Description; data->ReadString(num, 2, "element_descriptor.description", ach, aElementDescriptor_Description); @@ -85,18 +97,30 @@ void RWStepElement_RWVolume3dElementDescriptor::ReadStep( { const char* text = data->ParamCValue(num, 4); if (!strcmp(text, ".HEXAHEDRON.")) + { aShape = StepElement_Hexahedron; + } else if (!strcmp(text, ".WEDGE.")) + { aShape = StepElement_Wedge; + } else if (!strcmp(text, ".TETRAHEDRON.")) + { aShape = StepElement_Tetrahedron; + } else if (!strcmp(text, ".PYRAMID.")) + { aShape = StepElement_Pyramid; + } else + { ach->AddFail("Parameter #4 (shape) has not allowed value"); + } } else + { ach->AddFail("Parameter #4 (shape) is not enumeration"); + } // Initialize entity ent->Init(aElementDescriptor_TopologyOrder, aElementDescriptor_Description, aPurpose, aShape); diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedCurve3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedCurve3dElementCoordinateSystem.cxx index 0aa073070d..8eb3e4dc8d 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedCurve3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedCurve3dElementCoordinateSystem.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWAlignedCurve3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "aligned_curve3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedSurface3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedSurface3dElementCoordinateSystem.cxx index 25b90251ee..735e8032ec 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedSurface3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWAlignedSurface3dElementCoordinateSystem.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWAlignedSurface3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "aligned_surface3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWArbitraryVolume3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWArbitraryVolume3dElementCoordinateSystem.cxx index 168c46d9b4..13dc63dbcc 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWArbitraryVolume3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWArbitraryVolume3dElementCoordinateSystem.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWArbitraryVolume3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "arbitrary_volume3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWConstantSurface3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWConstantSurface3dElementCoordinateSystem.cxx index 5b0726c2fb..4491c5e412 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWConstantSurface3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWConstantSurface3dElementCoordinateSystem.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWConstantSurface3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "constant_surface3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementProperty.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementProperty.cxx index 9a88af5410..031e578f51 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementProperty.cxx @@ -41,7 +41,9 @@ void RWStepFEA_RWCurve3dElementProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "curve3d_element_property")) + { return; + } // Own fields of Curve3dElementProperty diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementRepresentation.cxx index b2db3f56c0..e34b54f016 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurve3dElementRepresentation.cxx @@ -45,7 +45,9 @@ void RWStepFEA_RWCurve3dElementRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 8, ach, "curve3d_element_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndOffset.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndOffset.cxx index 5d699941d6..992b133e74 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndOffset.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndOffset.cxx @@ -39,7 +39,9 @@ void RWStepFEA_RWCurveElementEndOffset::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "curve_element_end_offset")) + { return; + } // Own fields of CurveElementEndOffset diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndRelease.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndRelease.cxx index e1d0bed6ab..4e88bff73f 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndRelease.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementEndRelease.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWCurveElementEndRelease::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "curve_element_end_release")) + { return; + } // Own fields of CurveElementEndRelease diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementInterval.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementInterval.cxx index 874636dd81..750c01a18d 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementInterval.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementInterval.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWCurveElementInterval::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "curve_element_interval")) + { return; + } // Own fields of CurveElementInterval diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalConstant.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalConstant.cxx index adfed2d6e9..b9d6191e5d 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalConstant.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalConstant.cxx @@ -38,7 +38,9 @@ void RWStepFEA_RWCurveElementIntervalConstant::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "curve_element_interval_constant")) + { return; + } // Inherited fields of CurveElementInterval diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalLinearlyVarying.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalLinearlyVarying.cxx index 38c110473a..f59306dd17 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalLinearlyVarying.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementIntervalLinearlyVarying.cxx @@ -39,7 +39,9 @@ void RWStepFEA_RWCurveElementIntervalLinearlyVarying::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "curve_element_interval_linearly_varying")) + { return; + } // Inherited fields of CurveElementInterval diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementLocation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementLocation.cxx index 258e7d201c..decf840377 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementLocation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWCurveElementLocation.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWCurveElementLocation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "curve_element_location")) + { return; + } // Own fields of CurveElementLocation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWDummyNode.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWDummyNode.cxx index 95b0c9b379..a09e67c06c 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWDummyNode.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWDummyNode.cxx @@ -40,7 +40,9 @@ void RWStepFEA_RWDummyNode::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "dummy_node")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGeometricRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGeometricRelationship.cxx index 25ffc2618b..50c4abf2fd 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGeometricRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGeometricRelationship.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWElementGeometricRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "element_geometric_relationship")) + { return; + } // Own fields of ElementGeometricRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGroup.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGroup.cxx index da3849bbaf..f204b38c43 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGroup.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementGroup.cxx @@ -39,7 +39,9 @@ void RWStepFEA_RWElementGroup::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "element_group")) + { return; + } // Inherited fields of Group diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementRepresentation.cxx index 215cb2f3ca..b7fc63aaad 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWElementRepresentation.cxx @@ -41,7 +41,9 @@ void RWStepFEA_RWElementRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "element_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAreaDensity.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAreaDensity.cxx index aabcaa018c..27feb6089d 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAreaDensity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAreaDensity.cxx @@ -34,7 +34,9 @@ void RWStepFEA_RWFeaAreaDensity::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "fea_area_density")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAxis2Placement3d.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAxis2Placement3d.cxx index 86bb17a669..17644a1889 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAxis2Placement3d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaAxis2Placement3d.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWFeaAxis2Placement3d::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "fea_axis2_placement3d")) + { return; + } // Inherited fields of RepresentationItem @@ -95,16 +97,26 @@ void RWStepFEA_RWFeaAxis2Placement3d::ReadStep( { const char* text = data->ParamCValue(num, 5); if (strcmp(text, ".CARTESIAN.") == 0) + { aSystemType = StepFEA_Cartesian; + } else if (strcmp(text, ".CYLINDRICAL.") == 0) + { aSystemType = StepFEA_Cylindrical; + } else if (strcmp(text, ".SPHERICAL.") == 0) + { aSystemType = StepFEA_Spherical; + } else + { ach->AddFail("Parameter #5 (system_type) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (system_type) is not enumeration"); + } occ::handle aDescription; data->ReadString(num, 6, "description", ach, aDescription); @@ -142,14 +154,18 @@ void RWStepFEA_RWFeaAxis2Placement3d::WriteStep( SW.Send(ent->StepGeom_Axis2Placement3d::Axis()); } else + { SW.SendUndef(); + } if (ent->StepGeom_Axis2Placement3d::HasRefDirection()) { SW.Send(ent->StepGeom_Axis2Placement3d::RefDirection()); } else + { SW.SendUndef(); + } // Own fields of FeaAxis2Placement3d diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaCurveSectionGeometricRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaCurveSectionGeometricRelationship.cxx index 6fd86cac73..1903802ccc 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaCurveSectionGeometricRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaCurveSectionGeometricRelationship.cxx @@ -38,7 +38,9 @@ void RWStepFEA_RWFeaCurveSectionGeometricRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_curve_section_geometric_relationship")) + { return; + } // Own fields of FeaCurveSectionGeometricRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaGroup.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaGroup.cxx index 510a5cac22..d44d4f52e0 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaGroup.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaGroup.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaGroup::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "fea_group")) + { return; + } // Inherited fields of Group diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaLinearElasticity.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaLinearElasticity.cxx index 828b18e1c3..6c46319229 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaLinearElasticity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaLinearElasticity.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaLinearElasticity::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_linear_elasticity")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMassDensity.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMassDensity.cxx index 9e0d133ba8..9b2a3581e0 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMassDensity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMassDensity.cxx @@ -34,7 +34,9 @@ void RWStepFEA_RWFeaMassDensity::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "fea_mass_density")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentation.cxx index 7058f507ea..c862beaabb 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepFEA_RWFeaMaterialPropertyRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "fea_material_property_representation")) + { return; + } // Inherited fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentationItem.cxx index 43ab9f2c0f..6f9dd9656b 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMaterialPropertyRepresentationItem.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWFeaMaterialPropertyRepresentationItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "fea_material_property_representation_item")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel.cxx index b96aa6c2d4..27f87328a6 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel.cxx @@ -41,7 +41,9 @@ void RWStepFEA_RWFeaModel::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 7, ach, "fea_model")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel3d.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel3d.cxx index 5680b5b841..57ae04e56f 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel3d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModel3d.cxx @@ -41,7 +41,9 @@ void RWStepFEA_RWFeaModel3d::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 7, ach, "fea_model3d")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModelDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModelDefinition.cxx index c87dc1bab4..265eeea7e9 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModelDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaModelDefinition.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWFeaModelDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "fea_model_definition")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMoistureAbsorption.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMoistureAbsorption.cxx index bcf6472de9..d1c8bd8f8b 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMoistureAbsorption.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaMoistureAbsorption.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaMoistureAbsorption::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_moisture_absorption")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaParametricPoint.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaParametricPoint.cxx index d3a8070859..98a37916e3 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaParametricPoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaParametricPoint.cxx @@ -39,7 +39,9 @@ void RWStepFEA_RWFeaParametricPoint::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_parametric_point")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaRepresentationItem.cxx index d2d22407f7..90595ee67e 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaRepresentationItem.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaRepresentationItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "fea_representation_item")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSecantCoefficientOfLinearThermalExpansion.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSecantCoefficientOfLinearThermalExpansion.cxx index c2ebea250a..6d17725fe9 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSecantCoefficientOfLinearThermalExpansion.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSecantCoefficientOfLinearThermalExpansion.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWFeaSecantCoefficientOfLinearThermalExpansion::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "fea_secant_coefficient_of_linear_thermal_expansion")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellBendingStiffness.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellBendingStiffness.cxx index a6964c6610..287272e05c 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellBendingStiffness.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellBendingStiffness.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaShellBendingStiffness::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_shell_bending_stiffness")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneBendingCouplingStiffness.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneBendingCouplingStiffness.cxx index f91a408690..5563d60641 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneBendingCouplingStiffness.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneBendingCouplingStiffness.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWFeaShellMembraneBendingCouplingStiffness::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_shell_membrane_bending_coupling_stiffness")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneStiffness.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneStiffness.cxx index e4c276fb63..eeec510287 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneStiffness.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellMembraneStiffness.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaShellMembraneStiffness::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_shell_membrane_stiffness")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellShearStiffness.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellShearStiffness.cxx index af0de46aed..9425a3d49f 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellShearStiffness.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaShellShearStiffness.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFeaShellShearStiffness::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_shell_shear_stiffness")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSurfaceSectionGeometricRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSurfaceSectionGeometricRelationship.cxx index 3250863b27..3ac6666cd4 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSurfaceSectionGeometricRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaSurfaceSectionGeometricRelationship.cxx @@ -38,7 +38,9 @@ void RWStepFEA_RWFeaSurfaceSectionGeometricRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_surface_section_geometric_relationship")) + { return; + } // Own fields of FeaSurfaceSectionGeometricRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaTangentialCoefficientOfLinearThermalExpansion.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaTangentialCoefficientOfLinearThermalExpansion.cxx index 2a71c7de80..d1b0aa02f7 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaTangentialCoefficientOfLinearThermalExpansion.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFeaTangentialCoefficientOfLinearThermalExpansion.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWFeaTangentialCoefficientOfLinearThermalExpansion::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "fea_tangential_coefficient_of_linear_thermal_expansion")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomAndCoefficient.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomAndCoefficient.cxx index 0d423273eb..0535d92acc 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomAndCoefficient.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomAndCoefficient.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWFreedomAndCoefficient::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "freedom_and_coefficient")) + { return; + } // Own fields of FreedomAndCoefficient diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomsList.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomsList.cxx index f277280460..fcd30b488e 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomsList.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWFreedomsList.cxx @@ -38,7 +38,9 @@ void RWStepFEA_RWFreedomsList::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "freedoms_list")) + { return; + } // Own fields of FreedomsList diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWGeometricNode.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWGeometricNode.cxx index e4c3d59a75..e54008e790 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWGeometricNode.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWGeometricNode.cxx @@ -40,7 +40,9 @@ void RWStepFEA_RWGeometricNode::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "geometric_node")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNode.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNode.cxx index 1c6f862e9f..10f7df6f8a 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNode.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNode.cxx @@ -40,7 +40,9 @@ void RWStepFEA_RWNode::ReadStep(const occ::handle& data { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "node")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeDefinition.cxx index 408bf5415d..6b137fb8c8 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeDefinition.cxx @@ -35,7 +35,9 @@ void RWStepFEA_RWNodeDefinition::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "node_definition")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeGroup.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeGroup.cxx index d013db1370..a3a8454278 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeGroup.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeGroup.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWNodeGroup::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "node_group")) + { return; + } // Inherited fields of Group diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeRepresentation.cxx index c3d49dcc0f..cfbf0b7b53 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeRepresentation.cxx @@ -41,7 +41,9 @@ void RWStepFEA_RWNodeRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "node_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeSet.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeSet.cxx index d0d344005b..0a56a5df89 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeSet.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWNodeSet::ReadStep(const occ::handle& d { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "node_set")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithSolutionCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithSolutionCoordinateSystem.cxx index b6d8e3d13e..76dcad6c9a 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithSolutionCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithSolutionCoordinateSystem.cxx @@ -42,7 +42,9 @@ void RWStepFEA_RWNodeWithSolutionCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "node_with_solution_coordinate_system")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithVector.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithVector.cxx index 441f35838c..594845b478 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithVector.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWNodeWithVector.cxx @@ -40,7 +40,9 @@ void RWStepFEA_RWNodeWithVector::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "node_with_vector")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateDirection.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateDirection.cxx index 374e9b8883..9b63bc76b8 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateDirection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateDirection.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWParametricCurve3dElementCoordinateDirection::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "parametric_curve3d_element_coordinate_direction")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateSystem.cxx index 0b6e5f01fc..89e7e9d324 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricCurve3dElementCoordinateSystem.cxx @@ -37,7 +37,9 @@ void RWStepFEA_RWParametricCurve3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "parametric_curve3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricSurface3dElementCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricSurface3dElementCoordinateSystem.cxx index c3affcde7a..0fe1d23b99 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricSurface3dElementCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWParametricSurface3dElementCoordinateSystem.cxx @@ -36,7 +36,9 @@ void RWStepFEA_RWParametricSurface3dElementCoordinateSystem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "parametric_surface3d_element_coordinate_system")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWSurface3dElementRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWSurface3dElementRepresentation.cxx index 6c65c620d0..7675ad24cb 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWSurface3dElementRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWSurface3dElementRepresentation.cxx @@ -45,7 +45,9 @@ void RWStepFEA_RWSurface3dElementRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 8, ach, "surface3d_element_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWVolume3dElementRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWVolume3dElementRepresentation.cxx index 118c3c58ae..1d780ab4a4 100644 --- a/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWVolume3dElementRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepFEA/RWStepFEA_RWVolume3dElementRepresentation.cxx @@ -44,7 +44,9 @@ void RWStepFEA_RWVolume3dElementRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 7, ach, "volume3d_element_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis1Placement.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis1Placement.cxx index 1eae5c4a85..ad960ad9d8 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis1Placement.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis1Placement.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWAxis1Placement::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "axis1_placement")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement2d.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement2d.cxx index 08f9814341..2d07b8af19 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement2d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement2d.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWAxis2Placement2d::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "axis2_placement_2d")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement3d.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement3d.cxx index e3d7816b0d..a760d31c74 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement3d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWAxis2Placement3d.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWAxis2Placement3d::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "axis2_placement_3d")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurve.cxx index 6a452fa820..65cf9d9af5 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurve.cxx @@ -36,7 +36,9 @@ void RWStepGeom_RWBSplineCurve::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "b_spline_curve")) + { return; + } // --- inherited field : name --- @@ -68,7 +70,9 @@ void RWStepGeom_RWBSplineCurve::ReadStep(const occ::handleSetValue(i3, anent3); + } } } @@ -84,7 +88,9 @@ void RWStepGeom_RWBSplineCurve::ReadStep(const occ::handleAddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- own field : closedCurve --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnots.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnots.cxx index 7644d91c92..e0174a5296 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnots.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnots.cxx @@ -40,7 +40,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 9, ach, "b_spline_curve_with_knots")) + { return; + } // --- inherited field : name --- @@ -63,7 +65,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( { int nb3 = data->NbParams(nsub3); if (nb3 < 1) + { ach->AddFail("Number of control points of the b_spline_curve_form is equal to 0"); + } else { aControlPointsList = new NCollection_HArray1>(1, nb3); @@ -76,7 +80,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, anent3); + } } } } @@ -93,7 +99,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( } } else + { ach->AddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- inherited field : closedCurve --- @@ -120,7 +128,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat7 =` not needed if (data->ReadInteger(nsub7, i7, "knot_multiplicities", ach, aKnotMultiplicitiesItem)) + { aKnotMultiplicities->SetValue(i7, aKnotMultiplicitiesItem); + } } } @@ -137,7 +147,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat8 =` not needed if (data->ReadReal(nsub8, i8, "knots", ach, aKnotsItem)) + { aKnots->SetValue(i8, aKnotsItem); + } } } @@ -153,7 +165,9 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep( } } else + { ach->AddFail("Parameter #9 (knot_spec) is not an enumeration"); + } //--- Initialisation of the read entity --- @@ -283,8 +297,12 @@ void RWStepGeom_RWBSplineCurveWithKnots::Check( { double distKn = ent->KnotsValue(i - 1) - ent->KnotsValue(i); if (std::abs(distKn) <= RealEpsilon()) + { ach->AddWarning("WARNING: Curve contains identical KnotsValues"); + } else if (distKn > RealEpsilon()) + { ach->AddFail("ERROR: Curve contains descending KnotsValues"); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx index 08486042c3..d5b251549e 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx @@ -55,7 +55,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( // --- Instance of common supertype BSplineCurve --- if (!data->CheckNbParams(num, 5, ach, "b_spline_curve")) + { return; + } // --- field : degree --- int aDegree; @@ -79,7 +81,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aControlPointsList->SetValue(i2, anent2); + } } } @@ -95,7 +99,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); + } // --- field : closedCurve --- StepData_Logical aClosedCurve; @@ -115,7 +121,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( // --- Instance of plex component BSplineCurveWithKnots --- if (!data->CheckNbParams(num, 3, ach, "b_spline_curve_with_knots")) + { return; + } // --- field : knotMultiplicities --- @@ -130,7 +138,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat6 =` not needed if (data->ReadInteger(nsub6, i6, "knot_multiplicities", ach, aKnotMultiplicitiesItem)) + { aKnotMultiplicities->SetValue(i6, aKnotMultiplicitiesItem); + } } } @@ -147,7 +157,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat7 =` not needed if (data->ReadReal(nsub7, i7, "knots", ach, aKnotsItem)) + { aKnots->SetValue(i7, aKnotsItem); + } } } @@ -163,7 +175,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (knot_spec) is not an enumeration"); + } // num = data->NextForComplex(num); // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity @@ -183,7 +197,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( // --- Instance of plex component RationalBSplineCurve --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_curve")) + { return; + } // --- field : weightsData --- @@ -198,7 +214,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat9 =` not needed if (data->ReadReal(nsub9, i9, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i9, aWeightsDataItem); + } } } @@ -210,7 +228,9 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurface.cxx index 939765d978..018e326077 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurface.cxx @@ -36,7 +36,9 @@ void RWStepGeom_RWBSplineSurface::ReadStep(const occ::handleCheckNbParams(num, 8, ach, "b_spline_surface")) + { return; + } // --- inherited field : name --- @@ -81,7 +83,9 @@ void RWStepGeom_RWBSplineSurface::ReadStep(const occ::handleSetValue(i4, j4, anent4); + } } } } @@ -99,7 +103,9 @@ void RWStepGeom_RWBSplineSurface::ReadStep(const occ::handleAddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- own field : uClosed --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnots.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnots.cxx index e4f8d06f9b..2fa0164e23 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnots.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnots.cxx @@ -42,7 +42,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 13, ach, "b_spline_surface_with_knots")) + { return; + } // --- inherited field : name --- @@ -87,7 +89,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent4)) + { aControlPointsList->SetValue(i4, j4, anent4); + } } } } @@ -105,7 +109,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( } } else + { ach->AddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- inherited field : uClosed --- @@ -138,7 +144,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat9 =` not needed if (data->ReadInteger(nsub9, i9, "u_multiplicities", ach, aUMultiplicitiesItem)) + { aUMultiplicities->SetValue(i9, aUMultiplicitiesItem); + } } } @@ -155,7 +163,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat10 =` not needed if (data->ReadInteger(nsub10, i10, "v_multiplicities", ach, aVMultiplicitiesItem)) + { aVMultiplicities->SetValue(i10, aVMultiplicitiesItem); + } } } @@ -172,7 +182,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat11 =` not needed if (data->ReadReal(nsub11, i11, "u_knots", ach, aUKnotsItem)) + { aUKnots->SetValue(i11, aUKnotsItem); + } } } @@ -189,7 +201,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( { // szv#4:S4163:12Mar99 `bool stat12 =` not needed if (data->ReadReal(nsub12, i12, "v_knots", ach, aVKnotsItem)) + { aVKnots->SetValue(i12, aVKnotsItem); + } } } @@ -205,7 +219,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::ReadStep( } } else + { ach->AddFail("Parameter #13 (knot_spec) is not an enumeration"); + } //--- Initialisation of the read entity --- @@ -394,9 +410,13 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::Check( { double distKn = ent->UKnotsValue(i - 1) - ent->UKnotsValue(i); if (std::abs(distKn) <= RealEpsilon()) + { ach->AddWarning("WARNING: Surface contains identical KnotsValues in U"); + } else if (distKn > RealEpsilon()) + { ach->AddFail("ERROR: Surface contains descending KnotsValues in U"); + } } // check in V direction @@ -424,8 +444,12 @@ void RWStepGeom_RWBSplineSurfaceWithKnots::Check( { double distKn = ent->VKnotsValue(i - 1) - ent->VKnotsValue(i); if (std::abs(distKn) <= RealEpsilon()) + { ach->AddWarning("WARNING: Surface contains identical KnotsValues in V"); + } else if (distKn > RealEpsilon()) + { ach->AddFail("ERROR: Surface contains descending KnotsValues in V"); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx index 9c069138a5..e050a11c97 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx @@ -52,7 +52,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( // --- Instance of common supertype BSplineSurface --- if (!data->CheckNbParams(num, 7, ach, "b_spline_surface")) + { return; + } // --- field : uDegree --- int aUDegree; @@ -89,7 +91,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, j3, anent3); + } } } } @@ -107,7 +111,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #4 (surface_form) is not an enumeration"); + } // --- field : uClosed --- StepData_Logical aUClosed; @@ -130,7 +136,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( // --- Instance of plex component BSplineSurfaceWithKnots --- if (!data->CheckNbParams(num, 5, ach, "b_spline_surface_with_knots")) + { return; + } // --- field : uMultiplicities --- @@ -145,7 +153,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat8 =` not needed if (data->ReadInteger(nsub8, i8, "u_multiplicities", ach, aUMultiplicitiesItem)) + { aUMultiplicities->SetValue(i8, aUMultiplicitiesItem); + } } } @@ -162,7 +172,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat9 =` not needed if (data->ReadInteger(nsub9, i9, "v_multiplicities", ach, aVMultiplicitiesItem)) + { aVMultiplicities->SetValue(i9, aVMultiplicitiesItem); + } } } @@ -179,7 +191,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat10 =` not needed if (data->ReadReal(nsub10, i10, "u_knots", ach, aUKnotsItem)) + { aUKnots->SetValue(i10, aUKnotsItem); + } } } @@ -196,7 +210,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat11 =` not needed if (data->ReadReal(nsub11, i11, "v_knots", ach, aVKnotsItem)) + { aVKnots->SetValue(i11, aVKnotsItem); + } } } @@ -212,7 +228,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #5 (knot_spec) is not an enumeration"); + } // num = data->NextForComplex(num); data->NamedForComplex("GEOMETRIC_REPRESENTATION_ITEM", "GMRPIT", num0, num, ach); @@ -223,7 +241,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( // --- Instance of plex component RationalBSplineSurface --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_surface")) + { return; + } // --- field : weightsData --- @@ -245,7 +265,9 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat13 =` not needed if (data->ReadReal(nsi13, j13, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i13, j13, aWeightsDataItem); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurve.cxx index 9140a8b3cc..2710fb8df8 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurve.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWBezierCurve::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "bezier_curve")) + { return; + } // --- inherited field : name --- @@ -67,7 +69,9 @@ void RWStepGeom_RWBezierCurve::ReadStep(const occ::handleSetValue(i3, anent3); + } } } @@ -83,7 +87,9 @@ void RWStepGeom_RWBezierCurve::ReadStep(const occ::handleAddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- inherited field : closedCurve --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurveAndRationalBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurveAndRationalBSplineCurve.cxx index 78826e3e52..19fa610114 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurveAndRationalBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierCurveAndRationalBSplineCurve.cxx @@ -39,21 +39,27 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component BezierCurve --- if (!data->CheckNbParams(num, 0, ach, "bezier_curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component BoundedCurve --- if (!data->CheckNbParams(num, 0, ach, "bounded_curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineCurve --- if (!data->CheckNbParams(num, 5, ach, "b_spline_curve")) + { return; + } // --- field : degree --- int aDegree; @@ -77,7 +83,9 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aControlPointsList->SetValue(i2, anent2); + } } } @@ -93,7 +101,9 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); + } // --- field : closedCurve --- StepData_Logical aClosedCurve; @@ -110,21 +120,27 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component Curve --- if (!data->CheckNbParams(num, 0, ach, "curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineCurve --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_curve")) + { return; + } // --- field : weightsData --- @@ -139,7 +155,9 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat6 =` not needed if (data->ReadReal(nsub6, i6, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i6, aWeightsDataItem); + } } } @@ -148,7 +166,9 @@ void RWStepGeom_RWBezierCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurface.cxx index 83ab79d702..3b7708ea51 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurface.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWBezierSurface::ReadStep(const occ::handleCheckNbParams(num, 8, ach, "bezier_surface")) + { return; + } // --- inherited field : name --- @@ -80,7 +82,9 @@ void RWStepGeom_RWBezierSurface::ReadStep(const occ::handleSetValue(i4, j4, anent4); + } } } } @@ -99,7 +103,9 @@ void RWStepGeom_RWBezierSurface::ReadStep(const occ::handleAddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- inherited field : uClosed --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface.cxx index 5fa36dcd6a..f33808d9d6 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface.cxx @@ -39,21 +39,27 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component BezierSurface --- if (!data->CheckNbParams(num, 0, ach, "bezier_surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component BoundedSurface --- if (!data->CheckNbParams(num, 0, ach, "bounded_surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineSurface --- if (!data->CheckNbParams(num, 7, ach, "b_spline_surface")) + { return; + } // --- field : uDegree --- int aUDegree; @@ -89,7 +95,9 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, j3, anent3); + } } } } @@ -107,7 +115,9 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #4 (surface_form) is not an enumeration"); + } // --- field : uClosed --- StepData_Logical aUClosed; @@ -129,14 +139,18 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineSurface --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_surface")) + { return; + } // --- field : weightsData --- @@ -157,7 +171,9 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat8 =` not needed if (data->ReadReal(nsi8, j8, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i8, j8, aWeightsDataItem); + } } } } @@ -168,7 +184,9 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -181,7 +199,9 @@ void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component Surface --- if (!data->CheckNbParams(num, 0, ach, "surface")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundaryCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundaryCurve.cxx index a5ef9e3df5..a5e6fef1a3 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundaryCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundaryCurve.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWBoundaryCurve::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "boundary_curve")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepGeom_RWBoundaryCurve::ReadStep(const occ::handleSetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedCurve.cxx index 4ae147c067..edce5d6da2 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedCurve.cxx @@ -27,7 +27,9 @@ void RWStepGeom_RWBoundedCurve::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "bounded_curve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedSurface.cxx index 1d163bf287..d0283c72da 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWBoundedSurface.cxx @@ -27,7 +27,9 @@ void RWStepGeom_RWBoundedSurface::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "bounded_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianPoint.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianPoint.cxx index 21b7b750a2..5163e6e3dd 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianPoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianPoint.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWCartesianPoint::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "cartesian_point")) + { return; + } // --- inherited field : name --- @@ -71,9 +73,13 @@ void RWStepGeom_RWCartesianPoint::ReadStep(const occ::handleInit(aName, aCoordinates); if (nbcoord == 3) + { ent->Init3D(aName, XYZ[0], XYZ[1], XYZ[2]); + } else + { ent->Init2D(aName, XYZ[0], XYZ[1]); + } } void RWStepGeom_RWCartesianPoint::WriteStep(StepData_StepWriter& SW, diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator.cxx index b5d13ff5d2..96b22b0b8a 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator.cxx @@ -37,7 +37,9 @@ void RWStepGeom_RWCartesianTransformationOperator::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 7, ach, "cartesian_transformation_operator")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator3d.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator3d.cxx index e02b8face6..343bbde034 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator3d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCartesianTransformationOperator3d.cxx @@ -37,7 +37,9 @@ void RWStepGeom_RWCartesianTransformationOperator3d::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 8, ach, "cartesian_transformation_operator_3d")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCircle.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCircle.cxx index f283a9b6a6..42a627bdf7 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCircle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCircle.cxx @@ -28,7 +28,9 @@ void RWStepGeom_RWCircle::ReadStep(const occ::handle& d // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "circle")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurve.cxx index 8975d45914..73724327d7 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurve.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWCompositeCurve::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "composite_curve")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepGeom_RWCompositeCurve::ReadStep(const occ::handleSetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveOnSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveOnSurface.cxx index b237e2e37e..95faf43e95 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveOnSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveOnSurface.cxx @@ -33,7 +33,9 @@ void RWStepGeom_RWCompositeCurveOnSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "composite_curve_on_surface")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepGeom_RWCompositeCurveOnSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CompositeCurveSegment), anent2)) + { aSegments->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveSegment.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveSegment.cxx index 2dd5a75118..0ff7406797 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveSegment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCompositeCurveSegment.cxx @@ -34,7 +34,9 @@ void RWStepGeom_RWCompositeCurveSegment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "composite_curve_segment")) + { return; + } // --- own field : transition --- @@ -48,7 +50,9 @@ void RWStepGeom_RWCompositeCurveSegment::ReadStep( } } else + { ach->AddFail("Parameter #1 (transition) is not an enumeration"); + } // --- own field : sameSense --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConic.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConic.cxx index 0ce0fa3fbc..d61e238587 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConic.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConic.cxx @@ -28,7 +28,9 @@ void RWStepGeom_RWConic::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "conic")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConicalSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConicalSurface.cxx index 98d9a57b66..603ec0a65f 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConicalSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWConicalSurface.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWConicalSurface::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "conical_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurve.cxx index 3bff0c4499..fd3ef7dfa4 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurve.cxx @@ -27,7 +27,9 @@ void RWStepGeom_RWCurve::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "curve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveBoundedSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveBoundedSurface.cxx index 649a2fbb26..ddcf6bc801 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveBoundedSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveBoundedSurface.cxx @@ -41,7 +41,9 @@ void RWStepGeom_RWCurveBoundedSurface::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "curve_bounded_surface")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveReplica.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveReplica.cxx index 9e4525f01e..a43d802d6c 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveReplica.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCurveReplica.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWCurveReplica::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "curve_replica")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCylindricalSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCylindricalSurface.cxx index 5e55ec13fc..40c946f34d 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCylindricalSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWCylindricalSurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWCylindricalSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "cylindrical_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegeneratePcurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegeneratePcurve.cxx index bb38a4e869..0e2def4fd8 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegeneratePcurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegeneratePcurve.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWDegeneratePcurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "degenerate_pcurve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegenerateToroidalSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegenerateToroidalSurface.cxx index bd5f14ff44..73cbbd5cb3 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegenerateToroidalSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDegenerateToroidalSurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWDegenerateToroidalSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "degenerate_toroidal_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDirection.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDirection.cxx index 0359d8d644..d47a83a590 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDirection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWDirection.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWDirection::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "direction")) + { return; + } // --- inherited field : name --- @@ -63,9 +65,13 @@ void RWStepGeom_RWDirection::ReadStep(const occ::handle //--- Initialisation of the read entity --- if (aNbCoord == 3) + { ent->Init3D(aName, aXYZ[0], aXYZ[1], aXYZ[2]); + } else + { ent->Init2D(aName, aXYZ[0], aXYZ[1]); + } } void RWStepGeom_RWDirection::WriteStep(StepData_StepWriter& SW, @@ -95,8 +101,12 @@ void RWStepGeom_RWDirection::Check(const occ::handle& ent, for (i = 1; i <= nbVal; i++) { if (std::abs(ent->DirectionRatiosValue(i)) >= RealEpsilon()) + { break; + } } if (i > nbVal) + { ach->AddFail("ERROR: DirectionRatios all 0.0"); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWElementarySurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWElementarySurface.cxx index ae72f7aad4..475b54866e 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWElementarySurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWElementarySurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWElementarySurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "elementary_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEllipse.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEllipse.cxx index 3576da5449..01a1960aa5 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEllipse.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEllipse.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWEllipse::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "ellipse")) + { return; + } // --- inherited field : name --- @@ -93,5 +95,7 @@ void RWStepGeom_RWEllipse::Check(const occ::handle& ent, occ::handle& ach) const { if (ent->SemiAxis1() < ent->SemiAxis2()) + { ach->AddWarning("ERROR: Ellipse: SemiMajor smaller than SemiMinor"); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEvaluatedDegeneratePcurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEvaluatedDegeneratePcurve.cxx index d7c55ba101..ab1d093980 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEvaluatedDegeneratePcurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWEvaluatedDegeneratePcurve.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWEvaluatedDegeneratePcurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "evaluated_degenerate_pcurve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.cxx index fa67e6ddfe..568479a065 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS // ----------------------------------------------------------------- if (!data->CheckNbParams(num, 1, ach, "geometric_representation_context")) + { return; + } // --- field : coordinateSpaceDimension --- @@ -50,7 +52,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS // ------------------------------------------------------------------- if (!data->CheckNbParams(num, 1, ach, "global_uncertainty_assigned_context")) + { return; + } // --- field : uncertainty --- @@ -71,7 +75,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS ach, STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3)) + { aUncertainty->SetValue(i3, anent3); + } } } @@ -82,7 +88,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS // ------------------------------------------------------------ if (!data->CheckNbParams(num, 1, ach, "global_unit_assigned_context")) + { return; + } // --- field : units --- @@ -97,7 +105,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2)) + { aUnits->SetValue(i2, anent2); + } } } @@ -108,7 +118,9 @@ void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadS // ---------------------------------------------------------- if (!data->CheckNbParams(num, 2, ach, "representation_context")) + { return; + } // --- field : contextIdentifier --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContext.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContext.cxx index 267719e2ff..85e3171a4d 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContext.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWGeometricRepresentationContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "geometric_representation_context")) + { return; + } // --- inherited field : contextIdentifier --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.cxx index 86d02eda8d..213c6d849b 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.cxx @@ -33,7 +33,9 @@ void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Re // --- Instance of plex component GeometricRepresentationContext --- if (!data->CheckNbParams(num, 1, ach, "geometric_representation_context")) + { return; + } // --- field : coordinateSpaceDimension --- @@ -46,7 +48,9 @@ void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Re // --- Instance of plex component GlobalUnitAssignedContext --- if (!data->CheckNbParams(num, 1, ach, "global_unit_assigned_context")) + { return; + } // --- field : units --- @@ -61,7 +65,9 @@ void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Re { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2)) + { aUnits->SetValue(i2, anent2); + } } } @@ -70,7 +76,9 @@ void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Re // --- Instance of common supertype RepresentationContext --- if (!data->CheckNbParams(num, 2, ach, "representation_context")) + { return; + } // --- field : contextIdentifier --- occ::handle aContextIdentifier; diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationContext.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationContext.cxx index bc9d0a9bc3..2f707c39ad 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationContext.cxx @@ -33,7 +33,9 @@ void RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationConte // --- Instance of plex component GeometricRepresentationContext --- if (!data->CheckNbParams(num, 1, ach, "geometric_representation_context")) + { return; + } // --- field : coordinateSpaceDimension --- @@ -46,14 +48,18 @@ void RWStepGeom_RWGeometricRepresentationContextAndParametricRepresentationConte // --- Instance of plex component ParametricRepresentationContext --- if (!data->CheckNbParams(num, 0, ach, "parametric_representation_context")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype RepresentationContext --- if (!data->CheckNbParams(num, 2, ach, "representation_context")) + { return; + } // --- field : contextIdentifier --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationItem.cxx index 82c53b12d7..ee0d69cc56 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWGeometricRepresentationItem.cxx @@ -28,7 +28,9 @@ void RWStepGeom_RWGeometricRepresentationItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "geometric_representation_item")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWHyperbola.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWHyperbola.cxx index 94d8842ed8..2f080c868f 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWHyperbola.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWHyperbola.cxx @@ -28,7 +28,9 @@ void RWStepGeom_RWHyperbola::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "hyperbola")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWIntersectionCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWIntersectionCurve.cxx index 47b504dd3f..fe012a9d3e 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWIntersectionCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWIntersectionCurve.cxx @@ -34,7 +34,9 @@ void RWStepGeom_RWIntersectionCurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "intersection_curve")) + { return; + } // --- inherited field : name --- @@ -61,7 +63,9 @@ void RWStepGeom_RWIntersectionCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "associated_geometry", ach, aAssociatedGeometryItem)) + { aAssociatedGeometry->SetValue(i3, aAssociatedGeometryItem); + } } } @@ -78,7 +82,9 @@ void RWStepGeom_RWIntersectionCurve::ReadStep( } } else + { ach->AddFail("Parameter #4 (master_representation) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWLine.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWLine.cxx index 6621c274fe..fedffbb3cc 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWLine.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWLine.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWLine::ReadStep(const occ::handle& dat // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "line")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetCurve3d.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetCurve3d.cxx index 2b126820ef..1d5f55d296 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetCurve3d.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetCurve3d.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWOffsetCurve3d::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "offset_curve_3d")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetSurface.cxx index 080659f6cf..890c382bd7 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOffsetSurface.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWOffsetSurface::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "offset_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOrientedSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOrientedSurface.cxx index c7e57e33ab..fbb579e385 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOrientedSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOrientedSurface.cxx @@ -34,7 +34,9 @@ void RWStepGeom_RWOrientedSurface::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "oriented_surface")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOuterBoundaryCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOuterBoundaryCurve.cxx index 3d5a091bb1..bfe3c2099a 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOuterBoundaryCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWOuterBoundaryCurve.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWOuterBoundaryCurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "outer_boundary_curve")) + { return; + } // --- inherited field : name --- @@ -56,7 +58,9 @@ void RWStepGeom_RWOuterBoundaryCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CompositeCurveSegment), anent2)) + { aSegments->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWParabola.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWParabola.cxx index b9fe9d2073..9460888abc 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWParabola.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWParabola.cxx @@ -28,7 +28,9 @@ void RWStepGeom_RWParabola::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "parabola")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPcurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPcurve.cxx index 08b7f501c3..b8064b4fd4 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPcurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPcurve.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWPcurve::ReadStep(const occ::handle& d // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "pcurve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlacement.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlacement.cxx index 2ce18d0358..b92bf3e96a 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlacement.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlacement.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPlacement::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "placement")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlane.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlane.cxx index 260871523d..e6ba52a144 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlane.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPlane.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPlane::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "plane")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPoint.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPoint.cxx index 1da7234d87..60ab8197c3 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPoint.cxx @@ -27,7 +27,9 @@ void RWStepGeom_RWPoint::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "point")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnCurve.cxx index c9d0ba4e72..ebde4a3e63 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnCurve.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPointOnCurve::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "point_on_curve")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnSurface.cxx index cdf7e34f22..cc650c9442 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointOnSurface.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPointOnSurface::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "point_on_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointReplica.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointReplica.cxx index d9305ac305..4f83f00792 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointReplica.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPointReplica.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPointReplica::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "point_replica")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPolyline.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPolyline.cxx index b8c1c9f443..7a2fd57212 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPolyline.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWPolyline.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWPolyline::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "polyline")) + { return; + } // --- inherited field : name --- @@ -55,7 +57,9 @@ void RWStepGeom_RWPolyline::ReadStep(const occ::handle& ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aPoints->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurve.cxx index 3bd135c011..b396f62fe5 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurve.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWQuasiUniformCurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 6, ach, "quasi_uniform_curve")) + { return; + } // --- inherited field : name --- @@ -64,7 +66,9 @@ void RWStepGeom_RWQuasiUniformCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, anent3); + } } } @@ -80,7 +84,9 @@ void RWStepGeom_RWQuasiUniformCurve::ReadStep( } } else + { ach->AddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- inherited field : closedCurve --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve.cxx index 6eb5b7b123..cf7d442083 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve.cxx @@ -37,14 +37,18 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component BoundedCurve --- if (!data->CheckNbParams(num, 0, ach, "bounded_curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineCurve --- if (!data->CheckNbParams(num, 5, ach, "b_spline_curve")) + { return; + } // --- field : degree --- int aDegree; @@ -68,7 +72,9 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aControlPointsList->SetValue(i2, anent2); + } } } @@ -84,7 +90,9 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); + } // --- field : closedCurve --- StepData_Logical aClosedCurve; @@ -101,28 +109,36 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component Curve --- if (!data->CheckNbParams(num, 0, ach, "curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component QuasiUniformCurve --- if (!data->CheckNbParams(num, 0, ach, "quasi_uniform_curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineCurve --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_curve")) + { return; + } // --- field : weightsData --- @@ -137,7 +153,9 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat6 =` not needed if (data->ReadReal(nsub6, i6, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i6, aWeightsDataItem); + } } } @@ -146,7 +164,9 @@ void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurface.cxx index 38fd44b70c..ee97ecbc9a 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurface.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWQuasiUniformSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 8, ach, "quasi_uniform_surface")) + { return; + } // --- inherited field : name --- @@ -77,7 +79,9 @@ void RWStepGeom_RWQuasiUniformSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent4)) + { aControlPointsList->SetValue(i4, j4, anent4); + } } } } @@ -95,7 +99,9 @@ void RWStepGeom_RWQuasiUniformSurface::ReadStep( } } else + { ach->AddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- inherited field : uClosed --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx index 417532880f..c6ab4bd6f2 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx @@ -37,14 +37,18 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component BoundedSurface --- if (!data->CheckNbParams(num, 0, ach, "bounded_surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineSurface --- if (!data->CheckNbParams(num, 7, ach, "b_spline_surface")) + { return; + } // --- field : uDegree --- int aUDegree; @@ -80,7 +84,9 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, j3, anent3); + } } } } @@ -98,7 +104,9 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #4 (surface_form) is not an enumeration"); + } // --- field : uClosed --- StepData_Logical aUClosed; @@ -120,21 +128,27 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component QuasiUniformSurface --- if (!data->CheckNbParams(num, 0, ach, "quasi_uniform_surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineSurface --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_surface")) + { return; + } // --- field : weightsData --- @@ -155,7 +169,9 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat8 =` not needed if (data->ReadReal(nsi8, j8, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i8, j8, aWeightsDataItem); + } } } } @@ -166,7 +182,9 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -179,7 +197,9 @@ void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component Surface --- if (!data->CheckNbParams(num, 0, ach, "surface")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineCurve.cxx index 1d90e7ca2e..8dc451fc53 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineCurve.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWRationalBSplineCurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 7, ach, "rational_b_spline_curve")) + { return; + } // --- inherited field : name --- @@ -67,7 +69,9 @@ void RWStepGeom_RWRationalBSplineCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, anent3); + } } } @@ -83,7 +87,9 @@ void RWStepGeom_RWRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- inherited field : closedCurve --- @@ -110,7 +116,9 @@ void RWStepGeom_RWRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat7 =` not needed if (data->ReadReal(nsub7, i7, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i7, aWeightsDataItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineSurface.cxx index 067ffa8789..d2e263778f 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRationalBSplineSurface.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWRationalBSplineSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 9, ach, "rational_b_spline_surface")) + { return; + } // --- inherited field : name --- @@ -80,7 +82,9 @@ void RWStepGeom_RWRationalBSplineSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent4)) + { aControlPointsList->SetValue(i4, j4, anent4); + } } } } @@ -98,7 +102,9 @@ void RWStepGeom_RWRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- inherited field : uClosed --- @@ -137,7 +143,9 @@ void RWStepGeom_RWRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat9 =` not needed if (data->ReadReal(nsi9, j9, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i9, j9, aWeightsDataItem); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularCompositeSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularCompositeSurface.cxx index 4300a44c81..a7b5a1b5fe 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularCompositeSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularCompositeSurface.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWRectangularCompositeSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "rectangular_composite_surface")) + { return; + } // --- inherited field : name --- @@ -63,7 +65,9 @@ void RWStepGeom_RWRectangularCompositeSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_SurfacePatch), anent2)) + { aSegments->SetValue(i2, j2, anent2); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularTrimmedSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularTrimmedSurface.cxx index 076a2a7233..f447e1e8ad 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularTrimmedSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWRectangularTrimmedSurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWRectangularTrimmedSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 8, ach, "rectangular_trimmed_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWReparametrisedCompositeCurveSegment.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWReparametrisedCompositeCurveSegment.cxx index 4a57345b21..13e6508a63 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWReparametrisedCompositeCurveSegment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWReparametrisedCompositeCurveSegment.cxx @@ -34,7 +34,9 @@ void RWStepGeom_RWReparametrisedCompositeCurveSegment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "reparametrised_composite_curve_segment")) + { return; + } // --- inherited field : transition --- @@ -48,7 +50,9 @@ void RWStepGeom_RWReparametrisedCompositeCurveSegment::ReadStep( } } else + { ach->AddFail("Parameter #1 (transition) is not an enumeration"); + } // --- inherited field : sameSense --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSeamCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSeamCurve.cxx index 93be70bf14..4fc4cadc37 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSeamCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSeamCurve.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWSeamCurve::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "seam_curve")) + { return; + } // --- inherited field : name --- @@ -59,11 +61,17 @@ void RWStepGeom_RWSeamCurve::ReadStep(const occ::handle { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "associated_geometry", ach, aAssociatedGeometryItem)) + { aAssociatedGeometry->SetValue(i3, aAssociatedGeometryItem); + } if (i3 == 1) + { assgeomval = aAssociatedGeometryItem.Value(); - else if (assgeomval == aAssociatedGeometryItem.Value()) //: a9 abv + } + else if (assgeomval == aAssociatedGeometryItem.Value()) + { //: a9 abv ach->AddFail("Seam Curve with twice the same geom"); + } } } @@ -80,7 +88,9 @@ void RWStepGeom_RWSeamCurve::ReadStep(const occ::handle } } else + { ach->AddFail("Parameter #4 (master_representation) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSphericalSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSphericalSurface.cxx index 4490220cc2..f51f5bb284 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSphericalSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSphericalSurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWSphericalSurface::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "spherical_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSuParameters.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSuParameters.cxx index d6bee394ad..2046feb186 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSuParameters.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSuParameters.cxx @@ -36,7 +36,9 @@ void RWStepGeom_RWSuParameters::ReadStep(const occ::handleCheckNbParams(theNum, 7, theAch, "su_parameters")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurface.cxx index e0c3b31d94..6231e916e5 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurface.cxx @@ -27,7 +27,9 @@ void RWStepGeom_RWSurface::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurve.cxx index 618e0dad3f..1368caf255 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurve.cxx @@ -32,7 +32,9 @@ void RWStepGeom_RWSurfaceCurve::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "surface_curve")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepGeom_RWSurfaceCurve::ReadStep(const occ::handleReadEntity(nsub3, i3, "associated_geometry", ach, aAssociatedGeometryItem)) + { aAssociatedGeometry->SetValue(i3, aAssociatedGeometryItem); + } } } @@ -76,7 +80,9 @@ void RWStepGeom_RWSurfaceCurve::ReadStep(const occ::handleAddFail("Parameter #4 (master_representation) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx index 8d902975bf..53a327f1bf 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx @@ -52,7 +52,9 @@ void RWStepGeom_RWSurfaceCurveAndBoundedCurve::ReadStep( // REPRESENTATION_ITEM: read name num1 = data->NextForComplex(num1); if (!data->CheckNbParams(num1, 1, ach, "representation_item")) + { return; + } occ::handle aName; data->ReadString(num1, 1, "name", ach, aName); @@ -60,7 +62,9 @@ void RWStepGeom_RWSurfaceCurveAndBoundedCurve::ReadStep( // SURFACE_CURVE: read data num1 = data->NextForComplex(num1); if (!data->CheckNbParams(num1, 3, ach, "surface_curve")) + { return; + } // --- own field : curve3d --- occ::handle aCurve3d; @@ -78,7 +82,9 @@ void RWStepGeom_RWSurfaceCurveAndBoundedCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "associated_geometry", ach, aAssociatedGeometryItem)) + { aAssociatedGeometry->SetValue(i3, aAssociatedGeometryItem); + } } } @@ -94,7 +100,9 @@ void RWStepGeom_RWSurfaceCurveAndBoundedCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (master_representation) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfLinearExtrusion.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfLinearExtrusion.cxx index 4c03dbf9f1..8573d27508 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfLinearExtrusion.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfLinearExtrusion.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWSurfaceOfLinearExtrusion::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "surface_of_linear_extrusion")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfRevolution.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfRevolution.cxx index 06c6fc315c..17472d1513 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfRevolution.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceOfRevolution.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWSurfaceOfRevolution::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "surface_of_revolution")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfacePatch.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfacePatch.cxx index c196ade889..f0a843e3d7 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfacePatch.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfacePatch.cxx @@ -33,7 +33,9 @@ void RWStepGeom_RWSurfacePatch::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "surface_patch")) + { return; + } // --- own field : parentSurface --- @@ -58,7 +60,9 @@ void RWStepGeom_RWSurfacePatch::ReadStep(const occ::handleAddFail("Parameter #2 (u_transition) is not an enumeration"); + } // --- own field : vTransition --- @@ -72,7 +76,9 @@ void RWStepGeom_RWSurfacePatch::ReadStep(const occ::handleAddFail("Parameter #3 (v_transition) is not an enumeration"); + } // --- own field : uSense --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceReplica.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceReplica.cxx index 470eb96a5a..59714a4d6d 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceReplica.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSurfaceReplica.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWSurfaceReplica::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "surface_replica")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSweptSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSweptSurface.cxx index d902803ccf..6ce247f1e8 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSweptSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWSweptSurface.cxx @@ -29,7 +29,9 @@ void RWStepGeom_RWSweptSurface::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "swept_surface")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWToroidalSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWToroidalSurface.cxx index 460f48c65a..ac3e6d17ea 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWToroidalSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWToroidalSurface.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWToroidalSurface::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "toroidal_surface")) + { return; + } // --- inherited field : name --- @@ -95,9 +97,15 @@ void RWStepGeom_RWToroidalSurface::Check(const occ::handleMajorRadius() < 0.0) + { ach->AddFail("ERROR: ToroidalSurface: MajorRadius < 0.0"); + } if (ent->MinorRadius() < 0.0) + { ach->AddFail("ERROR: ToroidalSurface: MinorRadius < 0.0"); + } if (ent->MajorRadius() < ent->MinorRadius()) + { ach->AddWarning("ToroidalSurface: MajorRadius smaller than MinorRadius"); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWTrimmedCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWTrimmedCurve.cxx index 9983dac1ff..8ba3a0b5e4 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWTrimmedCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWTrimmedCurve.cxx @@ -35,7 +35,9 @@ void RWStepGeom_RWTrimmedCurve::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "trimmed_curve")) + { return; + } // --- inherited field : name --- @@ -65,7 +67,9 @@ void RWStepGeom_RWTrimmedCurve::ReadStep(const occ::handleReadEntity(nsub3, i3, "trim_1", ach, aTrim1Item)) + { aTrim1->SetValue(i3, aTrim1Item); + } } } @@ -83,7 +87,9 @@ void RWStepGeom_RWTrimmedCurve::ReadStep(const occ::handleReadEntity(nsub4, i4, "trim_2", ach, aTrim2Item)) + { aTrim2->SetValue(i4, aTrim2Item); + } } } @@ -105,7 +111,9 @@ void RWStepGeom_RWTrimmedCurve::ReadStep(const occ::handleAddFail("Parameter #6 (master_representation) is not an enumeration"); + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurve.cxx index e43a9c8816..a10a628ec3 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurve.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWUniformCurve::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "uniform_curve")) + { return; + } // --- inherited field : name --- @@ -63,7 +65,9 @@ void RWStepGeom_RWUniformCurve::ReadStep(const occ::handleSetValue(i3, anent3); + } } } @@ -79,7 +83,9 @@ void RWStepGeom_RWUniformCurve::ReadStep(const occ::handleAddFail("Parameter #4 (curve_form) is not an enumeration"); + } // --- inherited field : closedCurve --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurveAndRationalBSplineCurve.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurveAndRationalBSplineCurve.cxx index d163aabee5..7a2eeaa0e7 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurveAndRationalBSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformCurveAndRationalBSplineCurve.cxx @@ -39,14 +39,18 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component BoundedCurve --- if (!data->CheckNbParams(num, 0, ach, "bounded_curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineCurve --- if (!data->CheckNbParams(num, 5, ach, "b_spline_curve")) + { return; + } // --- field : degree --- int aDegree; @@ -70,7 +74,9 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aControlPointsList->SetValue(i2, anent2); + } } } @@ -86,7 +92,9 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( } } else + { ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); + } // --- field : closedCurve --- StepData_Logical aClosedCurve; @@ -103,21 +111,27 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component Curve --- if (!data->CheckNbParams(num, 0, ach, "curve")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineCurve --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_curve")) + { return; + } // --- field : weightsData --- @@ -132,7 +146,9 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( { // szv#4:S4163:12Mar99 `bool stat6 =` not needed if (data->ReadReal(nsub6, i6, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i6, aWeightsDataItem); + } } } @@ -141,7 +157,9 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -154,7 +172,9 @@ void RWStepGeom_RWUniformCurveAndRationalBSplineCurve::ReadStep( // --- Instance of plex component UniformCurve --- if (!data->CheckNbParams(num, 0, ach, "uniform_curve")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurface.cxx index c91b319991..e2a75d69d8 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurface.cxx @@ -31,7 +31,9 @@ void RWStepGeom_RWUniformSurface::ReadStep(const occ::handleCheckNbParams(num, 8, ach, "uniform_surface")) + { return; + } // --- inherited field : name --- @@ -76,7 +78,9 @@ void RWStepGeom_RWUniformSurface::ReadStep(const occ::handleSetValue(i4, j4, anent4); + } } } } @@ -94,7 +98,9 @@ void RWStepGeom_RWUniformSurface::ReadStep(const occ::handleAddFail("Parameter #5 (surface_form) is not an enumeration"); + } // --- inherited field : uClosed --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface.cxx index f2dc47a919..9988c04ee1 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface.cxx @@ -39,14 +39,18 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component BoundedSurface --- if (!data->CheckNbParams(num, 0, ach, "bounded_surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype BSplineSurface --- if (!data->CheckNbParams(num, 7, ach, "b_spline_surface")) + { return; + } // --- field : uDegree --- int aUDegree; @@ -82,7 +86,9 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) + { aControlPointsList->SetValue(i3, j3, anent3); + } } } } @@ -100,7 +106,9 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( } } else + { ach->AddFail("Parameter #4 (surface_form) is not an enumeration"); + } // --- field : uClosed --- StepData_Logical aUClosed; @@ -122,14 +130,18 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component RationalBSplineSurface --- if (!data->CheckNbParams(num, 1, ach, "rational_b_spline_surface")) + { return; + } // --- field : weightsData --- @@ -150,7 +162,9 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( { // szv#4:S4163:12Mar99 `bool stat8 =` not needed if (data->ReadReal(nsi8, j8, "weights_data", ach, aWeightsDataItem)) + { aWeightsData->SetValue(i8, j8, aWeightsDataItem); + } } } } @@ -161,7 +175,9 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -174,14 +190,18 @@ void RWStepGeom_RWUniformSurfaceAndRationalBSplineSurface::ReadStep( // --- Instance of plex component Surface --- if (!data->CheckNbParams(num, 0, ach, "surface")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component UniformSurface --- if (!data->CheckNbParams(num, 0, ach, "uniform_surface")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWVector.cxx b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWVector.cxx index 50b8c45851..49b0ad4cad 100644 --- a/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWVector.cxx +++ b/src/DataExchange/TKDESTEP/RWStepGeom/RWStepGeom_RWVector.cxx @@ -30,7 +30,9 @@ void RWStepGeom_RWVector::ReadStep(const occ::handle& d // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "vector")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx index c19034fa55..e5f77b5adc 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx @@ -56,7 +56,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( int theNum = 0; // num0; theData->NamedForComplex("ACTUATED_KINEMATIC_PAIR", "ACKNPR", num0, theNum, theArch); if (!theData->CheckNbParams(theNum, 6, theArch, "kinematic actuated_kinematic_pair")) + { return; + } // Own fields of ActuatedKinematicPair occ::handle anActuatedKinematicPair = new StepKinematics_ActuatedKinematicPair; @@ -68,18 +70,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 1); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTX = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTX = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTX = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTX = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #1 (t_x) has not allowed value"); + } } else + { theArch->AddFail("Parameter #1 (t_x) is not enumeration"); + } } else { @@ -94,18 +108,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 8); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTY = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTY = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTY = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTY = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #2 (t_y) has not allowed value"); + } } else + { theArch->AddFail("Parameter #2 (t_y) is not enumeration"); + } } else { @@ -120,18 +146,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 9); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTZ = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTZ = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTZ = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTZ = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #3 (t_z) has not allowed value"); + } } else + { theArch->AddFail("Parameter #3 (t_z) is not enumeration"); + } } else { @@ -146,18 +184,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 10); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRX = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRX = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRX = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRX = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #14 (r_x) has not allowed value"); + } } else + { theArch->AddFail("Parameter #14 (r_x) is not enumeration"); + } } else { @@ -172,18 +222,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 11); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRY = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRY = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRY = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRY = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #5 (r_y) has not allowed value"); + } } else + { theArch->AddFail("Parameter #5 (r_y) is not enumeration"); + } } else { @@ -198,18 +260,30 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 12); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRZ = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRZ = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRZ = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRZ = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #6 (r_z) has not allowed value"); + } } else + { theArch->AddFail("Parameter #6 (r_z) is not enumeration"); + } } else { @@ -225,11 +299,13 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( occ::handle aItemDefinedTransformation_Name; if (strcmp(theData->ParamCValue(theNum, 1), "*")) + { theData->ReadString(theNum, 1, "item_defined_transformation.name", theArch, aItemDefinedTransformation_Name); + } occ::handle aItemDefinedTransformation_Description; bool hasItemDefinedTransformation_Description = true; @@ -291,44 +367,58 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( if (theData->CheckNbParams(theNum, 6, theArch, "LOW_ORDER_KINEMATIC_PAIR")) { if (strcmp(theData->ParamCValue(theNum, 1), "*")) + { theData->ReadBoolean(theNum, 1, "low_order_kinematic_pair.t_x", theArch, aLowOrderKinematicPair_TX); + } if (strcmp(theData->ParamCValue(theNum, 2), "*")) + { theData->ReadBoolean(theNum, 2, "low_order_kinematic_pair.t_y", theArch, aLowOrderKinematicPair_TY); + } if (strcmp(theData->ParamCValue(theNum, 3), "*")) + { theData->ReadBoolean(theNum, 3, "low_order_kinematic_pair.t_z", theArch, aLowOrderKinematicPair_TZ); + } if (strcmp(theData->ParamCValue(theNum, 4), "*")) + { theData->ReadBoolean(theNum, 4, "low_order_kinematic_pair.r_x", theArch, aLowOrderKinematicPair_RX); + } if (strcmp(theData->ParamCValue(theNum, 5), "*")) + { theData->ReadBoolean(theNum, 5, "low_order_kinematic_pair.r_y", theArch, aLowOrderKinematicPair_RY); + } if (strcmp(theData->ParamCValue(theNum, 6), "*")) + { theData->ReadBoolean(theNum, 6, "low_order_kinematic_pair.r_z", theArch, aLowOrderKinematicPair_RZ); + } } else + { theArch->AddFail("The supertype of kinematic pair is not supported"); + } aKinematicPair = new StepKinematics_KinematicPair; aKinematicPair->Init(aRepresentationItem_Name, aItemDefinedTransformation_Name, @@ -783,7 +873,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::ReadStep( } } else + { theArch->AddFail("The type of kinematic pair with range is not supported"); + } } else if (!strcmp(aPairtype, "PRISMATIC_PAIR")) { @@ -2018,7 +2110,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->GetActuatedKinematicPair()->HasTY()) { @@ -2039,7 +2133,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->GetActuatedKinematicPair()->HasTZ()) { @@ -2060,7 +2156,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->GetActuatedKinematicPair()->HasRX()) { @@ -2081,7 +2179,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->GetActuatedKinematicPair()->HasRY()) { @@ -2102,7 +2202,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->GetActuatedKinematicPair()->HasRZ()) { @@ -2123,7 +2225,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( } } else + { theSW.SendUndef(); + } theSW.StartEntity("(GEOMETRIC_REPRESENTATION_ITEM"); theSW.StartEntity("(ITEM_DEFINED_TRANSFORMATION"); @@ -2136,7 +2240,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -2181,14 +2287,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aRevolutePairWithRange->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (aRevolutePairWithRange->HasUpperLimitActualRotation()) { theSW.Send(aRevolutePairWithRange->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPair))) @@ -2207,28 +2317,36 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aCylindricalPairWithRange->LowerLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (aCylindricalPairWithRange->HasUpperLimitActualTranslation()) { theSW.Send(aCylindricalPairWithRange->UpperLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (aCylindricalPairWithRange->HasLowerLimitActualRotation()) { theSW.Send(aCylindricalPairWithRange->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (aCylindricalPairWithRange->HasUpperLimitActualRotation()) { theSW.Send(aCylindricalPairWithRange->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_SphericalPair))) @@ -2247,42 +2365,54 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aSphericalPairWithRange->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithRange->HasUpperLimitYaw()) { theSW.Send(aSphericalPairWithRange->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithRange->HasLowerLimitPitch()) { theSW.Send(aSphericalPairWithRange->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithRange->HasUpperLimitPitch()) { theSW.Send(aSphericalPairWithRange->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithRange->HasLowerLimitRoll()) { theSW.Send(aSphericalPairWithRange->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithRange->HasUpperLimitRoll()) { theSW.Send(aSphericalPairWithRange->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind( @@ -2303,28 +2433,36 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aSphericalPairWithPinAndRange->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithPinAndRange->HasUpperLimitYaw()) { theSW.Send(aSphericalPairWithPinAndRange->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithPinAndRange->HasLowerLimitRoll()) { theSW.Send(aSphericalPairWithPinAndRange->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (aSphericalPairWithPinAndRange->HasUpperLimitRoll()) { theSW.Send(aSphericalPairWithPinAndRange->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPair))) @@ -2343,14 +2481,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aPrismaticPairWithRange->LowerLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (aPrismaticPairWithRange->HasUpperLimitActualTranslation()) { theSW.Send(aPrismaticPairWithRange->UpperLimitActualTranslation()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_UniversalPair))) @@ -2365,7 +2507,9 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(anUniversalPair->InputSkewAngle()); } else + { theSW.SendUndef(); + } theSW.StartEntity("(PRISMATIC_PAIR_WITH_RANGE"); if (theEnt->GetOrderKinematicPair()->IsKind( @@ -2380,28 +2524,36 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(anUniversalPairWithRange->LowerLimitFirstRotation()); } else + { theSW.SendUndef(); + } if (anUniversalPairWithRange->HasUpperLimitFirstRotation()) { theSW.Send(anUniversalPairWithRange->UpperLimitFirstRotation()); } else + { theSW.SendUndef(); + } if (anUniversalPairWithRange->HasLowerLimitSecondRotation()) { theSW.Send(anUniversalPairWithRange->LowerLimitSecondRotation()); } else + { theSW.SendUndef(); + } if (anUniversalPairWithRange->HasUpperLimitSecondRotation()) { theSW.Send(anUniversalPairWithRange->UpperLimitSecondRotation()); } else + { theSW.SendUndef(); + } } } } @@ -2437,14 +2589,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aGearPairWithRange->LowerLimitActualRotation1()); } else + { theSW.SendUndef(); + } if (aGearPairWithRange->HasUpperLimitActualRotation1()) { theSW.Send(aGearPairWithRange->UpperLimitActualRotation1()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind( @@ -2471,14 +2627,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aRackAndPinionPairWithRange->LowerLimitRackDisplacement()); } else + { theSW.SendUndef(); + } if (aRackAndPinionPairWithRange->HasUpperLimitRackDisplacement()) { theSW.Send(aRackAndPinionPairWithRange->UpperLimitRackDisplacement()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_ScrewPair))) @@ -2502,14 +2662,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aScrewPairWithRange->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (aScrewPairWithRange->HasUpperLimitActualRotation()) { theSW.Send(aScrewPairWithRange->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } } } @@ -2544,42 +2708,54 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aPointOnPlanarCurvePairWithRange->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (aPointOnPlanarCurvePairWithRange->HasUpperLimitYaw()) { theSW.Send(aPointOnPlanarCurvePairWithRange->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (aPointOnPlanarCurvePairWithRange->HasLowerLimitPitch()) { theSW.Send(aPointOnPlanarCurvePairWithRange->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (aPointOnPlanarCurvePairWithRange->HasUpperLimitPitch()) { theSW.Send(aPointOnPlanarCurvePairWithRange->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (aPointOnPlanarCurvePairWithRange->HasLowerLimitRoll()) { theSW.Send(aPointOnPlanarCurvePairWithRange->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (aPointOnPlanarCurvePairWithRange->HasUpperLimitRoll()) { theSW.Send(aPointOnPlanarCurvePairWithRange->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind( @@ -2608,42 +2784,54 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aPointOnSurfacePairWithRange->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (aPointOnSurfacePairWithRange->HasUpperLimitYaw()) { theSW.Send(aPointOnSurfacePairWithRange->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (aPointOnSurfacePairWithRange->HasLowerLimitPitch()) { theSW.Send(aPointOnSurfacePairWithRange->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (aPointOnSurfacePairWithRange->HasUpperLimitPitch()) { theSW.Send(aPointOnSurfacePairWithRange->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (aPointOnSurfacePairWithRange->HasLowerLimitRoll()) { theSW.Send(aPointOnSurfacePairWithRange->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (aPointOnSurfacePairWithRange->HasUpperLimitRoll()) { theSW.Send(aPointOnSurfacePairWithRange->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } } else if (theEnt->GetOrderKinematicPair()->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePair))) @@ -2700,14 +2888,18 @@ void RWStepKinematics_RWActuatedKinPairAndOrderKinPair::WriteStep( theSW.Send(aSurfacePairWithRange->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (aSurfacePairWithRange->HasUpperLimitActualRotation()) { theSW.Send(aSurfacePairWithRange->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinematicPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinematicPair.cxx index f75aa50667..81dae2572c 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinematicPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWActuatedKinematicPair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "actuated_kinematic_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -108,18 +110,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 7); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTX = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTX = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTX = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTX = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #7 (t_x) has not allowed value"); + } } else + { theArch->AddFail("Parameter #7 (t_x) is not enumeration"); + } } else { @@ -134,18 +148,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 8); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTY = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTY = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTY = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTY = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #8 (t_y) has not allowed value"); + } } else + { theArch->AddFail("Parameter #8 (t_y) is not enumeration"); + } } else { @@ -160,18 +186,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 9); if (strcmp(text, ".BIDIRECTIONAL.")) + { aTZ = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aTZ = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aTZ = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aTZ = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #9 (t_z) has not allowed value"); + } } else + { theArch->AddFail("Parameter #9 (t_z) is not enumeration"); + } } else { @@ -186,18 +224,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 10); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRX = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRX = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRX = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRX = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #10 (r_x) has not allowed value"); + } } else + { theArch->AddFail("Parameter #10 (r_x) is not enumeration"); + } } else { @@ -212,18 +262,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 11); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRY = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRY = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRY = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRY = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #11 (r_y) has not allowed value"); + } } else + { theArch->AddFail("Parameter #11 (r_y) is not enumeration"); + } } else { @@ -238,18 +300,30 @@ void RWStepKinematics_RWActuatedKinematicPair::ReadStep( { const char* text = theData->ParamCValue(theNum, 12); if (strcmp(text, ".BIDIRECTIONAL.")) + { aRZ = StepKinematics_adBidirectional; + } else if (strcmp(text, ".POSITIVE_ONLY.")) + { aRZ = StepKinematics_adPositiveOnly; + } else if (strcmp(text, ".NEGATIVE_ONLY.")) + { aRZ = StepKinematics_adNegativeOnly; + } else if (strcmp(text, ".NOT_ACTUATED.")) + { aRZ = StepKinematics_adNotActuated; + } else + { theArch->AddFail("Parameter #12 (r_z) has not allowed value"); + } } else + { theArch->AddFail("Parameter #12 (r_z) is not enumeration"); + } } else { @@ -298,7 +372,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -329,7 +405,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->HasTY()) { @@ -350,7 +428,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->HasTZ()) { @@ -371,7 +451,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->HasRX()) { @@ -392,7 +474,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->HasRY()) { @@ -413,7 +497,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } if (theEnt->HasRZ()) { @@ -434,7 +520,9 @@ void RWStepKinematics_RWActuatedKinematicPair::WriteStep( } } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWContextDependentKinematicLinkRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWContextDependentKinematicLinkRepresentation.cxx index 3bd0ea0aba..16fe9cf374 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWContextDependentKinematicLinkRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWContextDependentKinematicLinkRepresentation.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWContextDependentKinematicLinkRepresentation::ReadStep( 2, theArch, "context_dependent_kinematic_link_representation")) + { return; + } // Own fields of ContextDependentKinematicLinkRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPair.cxx index 757cbf94c1..771b788f96 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWCylindricalPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "cylindrical_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWCylindricalPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairValue.cxx index 9c1fa7a455..c52107f841 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWCylindricalPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "cylindrical_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairWithRange.cxx index 9c6b32cc74..50646c0512 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWCylindricalPairWithRange.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWCylindricalPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 16, theArch, "cylindrical_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -253,7 +255,9 @@ void RWStepKinematics_RWCylindricalPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -284,28 +288,36 @@ void RWStepKinematics_RWCylindricalPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslation()) { theSW.Send(theEnt->UpperLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualRotation()) { theSW.Send(theEnt->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation()) { theSW.Send(theEnt->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWFullyConstrainedPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWFullyConstrainedPair.cxx index 8726ade1ee..3fb8e8e6b9 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWFullyConstrainedPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWFullyConstrainedPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWFullyConstrainedPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "fully_constrained_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWFullyConstrainedPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPair.cxx index 543d759d74..56b97c1f1f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWGearPair::ReadStep(const occ::handleCheckNbParams(theNum, 11, theArch, "gear_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -149,7 +151,9 @@ void RWStepKinematics_RWGearPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairValue.cxx index 1b169ee1e1..a6f4749c68 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWGearPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "gear_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairWithRange.cxx index e292c78a1f..f553daa76e 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWGearPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWGearPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 13, theArch, "gear_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -188,7 +190,9 @@ void RWStepKinematics_RWGearPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -217,14 +221,18 @@ void RWStepKinematics_RWGearPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotation1()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation1()) { theSW.Send(theEnt->UpperLimitActualRotation1()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWHomokineticPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWHomokineticPair.cxx index a61634bfd5..a7516ede7f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWHomokineticPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWHomokineticPair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWHomokineticPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 13, theArch, "homokinetic_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -198,7 +200,9 @@ void RWStepKinematics_RWHomokineticPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -229,7 +233,9 @@ void RWStepKinematics_RWHomokineticPair::WriteStep( theSW.Send(theEnt->InputSkewAngle()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicJoint.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicJoint.cxx index e40479a2e9..fb025168f2 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicJoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicJoint.cxx @@ -37,7 +37,9 @@ void RWStepKinematics_RWKinematicJoint::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "kinematic_joint")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLink.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLink.cxx index 1e24d0f1d4..4b4cdd5d85 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLink.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLink.cxx @@ -36,7 +36,9 @@ void RWStepKinematics_RWKinematicLink::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 1, theArch, "kinematic_link")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLinkRepresentationAssociation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLinkRepresentationAssociation.cxx index 06f4a77a26..22413debcf 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLinkRepresentationAssociation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicLinkRepresentationAssociation.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWKinematicLinkRepresentationAssociation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "kinematic_link_representation_association")) + { return; + } // Inherited fields of RepresentationRelationship @@ -81,7 +83,9 @@ void RWStepKinematics_RWKinematicLinkRepresentationAssociation::ReadStep( // Process only one type (Representation) if (aRepresentationRelationship_Rep1.CaseNumber() != 1 || aRepresentationRelationship_Rep1.CaseNumber() != 1) + { return; + } // Initialize entity theEnt->Init(aRepresentationRelationship_Name, @@ -106,7 +110,9 @@ void RWStepKinematics_RWKinematicLinkRepresentationAssociation::WriteStep( theSW.Send(theEnt->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->Rep1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicPropertyMechanismRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicPropertyMechanismRepresentation.cxx index 47c01ac439..27e98768f2 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicPropertyMechanismRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicPropertyMechanismRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWKinematicPropertyMechanismRepresentation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "kinematic_property_mechanism_representation")) + { return; + } // Inherited fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyDirectedStructure.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyDirectedStructure.cxx index 7853fcb11c..1d2dbedf63 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyDirectedStructure.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyDirectedStructure.cxx @@ -42,7 +42,9 @@ void RWStepKinematics_RWKinematicTopologyDirectedStructure::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "kinematic_topology_directed_structure")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyNetworkStructure.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyNetworkStructure.cxx index 22bc39e2b1..a0edbc54c6 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyNetworkStructure.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyNetworkStructure.cxx @@ -42,7 +42,9 @@ void RWStepKinematics_RWKinematicTopologyNetworkStructure::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "kinematic_topology_network_structure")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyStructure.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyStructure.cxx index be0619316f..2fa50331bf 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyStructure.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWKinematicTopologyStructure.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWKinematicTopologyStructure::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "kinematic_topology_structure")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPinionPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPinionPair.cxx index 0e9b5ab20b..df59b45a45 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPinionPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPinionPair.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWLinearFlexibleAndPinionPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 7, theArch, "linear_flexible_and_pinion_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -135,7 +137,9 @@ void RWStepKinematics_RWLinearFlexibleAndPinionPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair.cxx index 6ad85223ad..59f2c4327e 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 8, theArch, "linear_flexible_and_planar_curve_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -139,7 +141,9 @@ void RWStepKinematics_RWLinearFlexibleAndPlanarCurvePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleLinkRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleLinkRepresentation.cxx index d370d4b679..0ba914833f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleLinkRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLinearFlexibleLinkRepresentation.cxx @@ -42,7 +42,9 @@ void RWStepKinematics_RWLinearFlexibleLinkRepresentation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "linear_flexible_link_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPair.cxx index 2e9316e282..5b28eff577 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWLowOrderKinematicPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "low_order_kinematic_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -153,7 +155,9 @@ void RWStepKinematics_RWLowOrderKinematicPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairValue.cxx index 46712a83a4..3de5333300 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairValue.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWLowOrderKinematicPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 8, theArch, "low_order_kinematic_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairWithRange.cxx index d9b8d11964..384799881f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWLowOrderKinematicPairWithRange.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWLowOrderKinematicPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 24, theArch, "low_order_kinematic_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -397,7 +399,9 @@ void RWStepKinematics_RWLowOrderKinematicPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -428,84 +432,108 @@ void RWStepKinematics_RWLowOrderKinematicPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotationX()) { theSW.Send(theEnt->UpperLimitActualRotationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualRotationY()) { theSW.Send(theEnt->LowerLimitActualRotationY()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotationY()) { theSW.Send(theEnt->UpperLimitActualRotationY()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualRotationZ()) { theSW.Send(theEnt->LowerLimitActualRotationZ()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotationZ()) { theSW.Send(theEnt->UpperLimitActualRotationZ()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualTranslationX()) { theSW.Send(theEnt->LowerLimitActualTranslationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslationX()) { theSW.Send(theEnt->UpperLimitActualTranslationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualTranslationY()) { theSW.Send(theEnt->LowerLimitActualTranslationY()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslationY()) { theSW.Send(theEnt->UpperLimitActualTranslationY()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualTranslationZ()) { theSW.Send(theEnt->LowerLimitActualTranslationZ()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslationZ()) { theSW.Send(theEnt->UpperLimitActualTranslationZ()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismRepresentation.cxx index 89605a182c..9c1f424ae8 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismRepresentation.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWMechanismRepresentation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "mechanism_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx index 541779b614..8bf3b9890a 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepKinematics_RWMechanismStateRepresentation::ReadStep( { // Number of Parameter Control if (!theData->CheckNbParams(theNum, 4, theArch, "mechanism_state_representation")) + { return; + } // Inherited field : name occ::handle aName; @@ -59,7 +61,9 @@ void RWStepKinematics_RWMechanismStateRepresentation::ReadStep( theArch, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) + { aItems->SetValue(i, anEnt); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWOrientedJoint.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWOrientedJoint.cxx index f560add65b..38c1688c63 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWOrientedJoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWOrientedJoint.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWOrientedJoint::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 5, theArch, "oriented_joint")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPairRepresentationRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPairRepresentationRelationship.cxx index ebc04d17af..3f399cd4f9 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPairRepresentationRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPairRepresentationRelationship.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWPairRepresentationRelationship::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 6, theArch, "pair_representation_relationship")) + { return; + } // Inherited fields of RepresentationItem @@ -122,9 +124,13 @@ void RWStepKinematics_RWPairRepresentationRelationship::WriteStep( theSW.Send(theEnt->Name()); if (theEnt->RepresentationRelationshipWithTransformation()->HasDescription()) + { theSW.Send(theEnt->RepresentationRelationshipWithTransformation()->Description()); + } else + { theSW.SendUndef(); + } theSW.Send(theEnt->RepresentationRelationshipWithTransformation()->Rep1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePair.cxx index 09bc85a747..63c3defb0b 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPlanarCurvePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "planar_curve_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -142,7 +144,9 @@ void RWStepKinematics_RWPlanarCurvePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePairRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePairRange.cxx index fc47a6b22d..59c97ee623 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePairRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarCurvePairRange.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWPlanarCurvePairRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 11, theArch, "planar_curve_pair_range")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWPlanarCurvePairRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPair.cxx index 32c2cbf238..d2bd858fcc 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWPlanarPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "planar_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWPlanarPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairValue.cxx index 4cd01ef25e..46176d1c9f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWPlanarPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 5, theArch, "planar_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairWithRange.cxx index 14b116937f..68b8557267 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPlanarPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPlanarPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 18, theArch, "planar_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -288,7 +290,9 @@ void RWStepKinematics_RWPlanarPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -319,42 +323,54 @@ void RWStepKinematics_RWPlanarPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation()) { theSW.Send(theEnt->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualTranslationX()) { theSW.Send(theEnt->LowerLimitActualTranslationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslationX()) { theSW.Send(theEnt->UpperLimitActualTranslationX()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitActualTranslationY()) { theSW.Send(theEnt->LowerLimitActualTranslationY()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslationY()) { theSW.Send(theEnt->UpperLimitActualTranslationY()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePair.cxx index 1696f728b8..44a4d06b86 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 8, theArch, "point_on_planar_curve_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -138,7 +140,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx index 12ce8229a6..65b84be552 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "point_on_planar_curve_pair_value")) + { return; + } // Inherited fields of RepresentationItem @@ -87,7 +89,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::ReadStep( aInputOrientation.SetValue(aItems); } else + { theData->ReadEntity(theNum, 4, "input_orientation", theArch, aInputOrientation); + } // Initialize entity theEnt->Init(aRepresentationItem_Name, @@ -126,7 +130,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::WriteStep( theSW.CloseSub(); } else + { theSW.Send(theEnt->InputOrientation().Value()); + } } //================================================================================================= @@ -147,5 +153,7 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::Share( iter.AddItem(theEnt->ActualPointOnCurve()); if (!theEnt->InputOrientation().RotationAboutDirection().IsNull()) + { iter.AddItem(theEnt->InputOrientation().Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairWithRange.cxx index 1eda5d101c..09e28fea2e 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairWithRange.cxx @@ -43,7 +43,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 15, theArch, "point_on_planar_curve_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -245,7 +247,9 @@ void RWStepKinematics_RWPointOnPlanarCurvePairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -270,42 +274,54 @@ void RWStepKinematics_RWPointOnPlanarCurvePairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitYaw()) { theSW.Send(theEnt->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitPitch()) { theSW.Send(theEnt->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitPitch()) { theSW.Send(theEnt->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitRoll()) { theSW.Send(theEnt->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitRoll()) { theSW.Send(theEnt->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePair.cxx index dae26bf62e..f266799b07 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPointOnSurfacePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 7, theArch, "point_on_surface_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -135,7 +137,9 @@ void RWStepKinematics_RWPointOnSurfacePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx index ae36e0a376..28e1dc5822 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWPointOnSurfacePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "point_on_surface_pair_value")) + { return; + } // Inherited fields of RepresentationItem @@ -86,7 +88,9 @@ void RWStepKinematics_RWPointOnSurfacePairValue::ReadStep( aInputOrientation.SetValue(aItems); } else + { theData->ReadEntity(theNum, 4, "input_orientation", theArch, aInputOrientation); + } // Initialize entity theEnt->Init(aRepresentationItem_Name, @@ -125,7 +129,9 @@ void RWStepKinematics_RWPointOnSurfacePairValue::WriteStep( theSW.CloseSub(); } else + { theSW.Send(theEnt->InputOrientation().Value()); + } } //================================================================================================= @@ -146,5 +152,7 @@ void RWStepKinematics_RWPointOnSurfacePairValue::Share( iter.AddItem(theEnt->ActualPointOnSurface()); if (!theEnt->InputOrientation().RotationAboutDirection().IsNull()) + { iter.AddItem(theEnt->InputOrientation().Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairWithRange.cxx index b86ce58aeb..ca56d06b51 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairWithRange.cxx @@ -43,7 +43,9 @@ void RWStepKinematics_RWPointOnSurfacePairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 14, theArch, "point_on_surface_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -237,7 +239,9 @@ void RWStepKinematics_RWPointOnSurfacePairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -260,42 +264,54 @@ void RWStepKinematics_RWPointOnSurfacePairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitYaw()) { theSW.Send(theEnt->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitPitch()) { theSW.Send(theEnt->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitPitch()) { theSW.Send(theEnt->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitRoll()) { theSW.Send(theEnt->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitRoll()) { theSW.Send(theEnt->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPair.cxx index 03a5b247fc..9b73754587 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWPrismaticPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "prismatic_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWPrismaticPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairValue.cxx index 4d32b2a4f6..1200234b99 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWPrismaticPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "prismatic_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairWithRange.cxx index 4e58268e10..403609e420 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWPrismaticPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWPrismaticPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 14, theArch, "prismatic_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -216,7 +218,9 @@ void RWStepKinematics_RWPrismaticPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -247,14 +251,18 @@ void RWStepKinematics_RWPrismaticPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualTranslation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualTranslation()) { theSW.Send(theEnt->UpperLimitActualTranslation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionKinematics.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionKinematics.cxx index 6c7fc83688..28b0284ed8 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionKinematics.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionKinematics.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWProductDefinitionKinematics::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "product_definition_kinematics")) + { return; + } // Inherited fields of PropertyDefinition @@ -91,7 +93,9 @@ void RWStepKinematics_RWProductDefinitionKinematics::WriteStep( theSW.Send(theEnt->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->Definition().Value()); } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionRelationshipKinematics.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionRelationshipKinematics.cxx index b17fb18318..78603c34fc 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionRelationshipKinematics.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWProductDefinitionRelationshipKinematics.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWProductDefinitionRelationshipKinematics::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "product_definition_relationship_kinematics")) + { return; + } // Inherited fields of PropertyDefinition @@ -91,7 +93,9 @@ void RWStepKinematics_RWProductDefinitionRelationshipKinematics::WriteStep( theSW.Send(theEnt->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->Definition().Value()); } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPair.cxx index c34c264cc7..2c4c65e435 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWRackAndPinionPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 7, theArch, "rack_and_pinion_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -134,7 +136,9 @@ void RWStepKinematics_RWRackAndPinionPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairValue.cxx index e1d61c54d3..4b96817fda 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWRackAndPinionPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "rack_and_pinion_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairWithRange.cxx index 5a80a04dc1..713562f04e 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRackAndPinionPairWithRange.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWRackAndPinionPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "rack_and_pinion_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWRackAndPinionPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -198,14 +202,18 @@ void RWStepKinematics_RWRackAndPinionPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitRackDisplacement()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitRackDisplacement()) { theSW.Send(theEnt->UpperLimitRackDisplacement()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePair.cxx index 6b3b100442..4360ac2757 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWRevolutePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "revolute_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWRevolutePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairValue.cxx index 17dd0366fa..5c8793838f 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWRevolutePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "revolute_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairWithRange.cxx index d0c608dc0c..d1452a3253 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRevolutePairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWRevolutePairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 14, theArch, "revolute_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -216,7 +218,9 @@ void RWStepKinematics_RWRevolutePairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -247,14 +251,18 @@ void RWStepKinematics_RWRevolutePairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation()) { theSW.Send(theEnt->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRigidLinkRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRigidLinkRepresentation.cxx index 45f78bf0fa..4c5eba51e4 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRigidLinkRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRigidLinkRepresentation.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWRigidLinkRepresentation::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "rigid_link_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePair.cxx index 1ee472d9f3..9fc147d4ea 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWRollingCurvePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "rolling_curve_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -156,7 +158,9 @@ void RWStepKinematics_RWRollingCurvePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePairValue.cxx index de9694be69..56c6f914f2 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingCurvePairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWRollingCurvePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "rolling_curve_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePair.cxx index 79bfb5cddd..e4858bc59c 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWRollingSurfacePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "rolling_surface_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -152,7 +154,9 @@ void RWStepKinematics_RWRollingSurfacePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePairValue.cxx index df597caaf7..6bb3e3f096 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRollingSurfacePairValue.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWRollingSurfacePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "rolling_surface_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRotationAboutDirection.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRotationAboutDirection.cxx index dec12b53a0..46478a88ee 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRotationAboutDirection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWRotationAboutDirection.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWRotationAboutDirection::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "rotation_about_direction")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPair.cxx index a1500e89a2..ba71b20bed 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWScrewPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 7, theArch, "screw_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -134,7 +136,9 @@ void RWStepKinematics_RWScrewPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairValue.cxx index 6292e79779..5a3edd9828 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWScrewPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "screw_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairWithRange.cxx index a2103fd0e8..93aad6c789 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWScrewPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWScrewPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "screw_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -164,7 +166,9 @@ void RWStepKinematics_RWScrewPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -185,14 +189,18 @@ void RWStepKinematics_RWScrewPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation()) { theSW.Send(theEnt->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePair.cxx index ede551f692..fa84125f65 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWSlidingCurvePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "sliding_curve_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -156,7 +158,9 @@ void RWStepKinematics_RWSlidingCurvePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePairValue.cxx index d4d052e8a6..b93c7aac57 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingCurvePairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWSlidingCurvePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "sliding_curve_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePair.cxx index 8fc91ecb23..f2ddc7ce5e 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWSlidingSurfacePair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 9, theArch, "sliding_surface_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -152,7 +154,9 @@ void RWStepKinematics_RWSlidingSurfacePair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePairValue.cxx index 1ba9f8bb36..56936ecc93 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSlidingSurfacePairValue.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWSlidingSurfacePairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 5, theArch, "sliding_surface_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPair.cxx index 455be42369..1b7483fae2 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWSphericalPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "spherical_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWSphericalPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx index aa07c0d73d..d9b14ea64b 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWSphericalPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "spherical_pair_value")) + { return; + } // Inherited fields of RepresentationItem @@ -76,7 +78,9 @@ void RWStepKinematics_RWSphericalPairValue::ReadStep( aInputOrientation.SetValue(aItems); } else + { theData->ReadEntity(theNum, 3, "input_orientation", theArch, aInputOrientation); + } // Initialize entity theEnt->Init(aRepresentationItem_Name, aPairValue_AppliesToPair, aInputOrientation); @@ -110,7 +114,9 @@ void RWStepKinematics_RWSphericalPairValue::WriteStep( theSW.CloseSub(); } else + { theSW.Send(theEnt->InputOrientation().Value()); + } } //================================================================================================= @@ -129,5 +135,7 @@ void RWStepKinematics_RWSphericalPairValue::Share( // Own fields of SphericalPairValue if (!theEnt->InputOrientation().RotationAboutDirection().IsNull()) + { iter.AddItem(theEnt->InputOrientation().Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPin.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPin.cxx index 0d95f6e333..055a915df8 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPin.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPin.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWSphericalPairWithPin::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "spherical_pair_with_pin")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWSphericalPairWithPin::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPinAndRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPinAndRange.cxx index 0517c93551..61fa1ae0ff 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPinAndRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithPinAndRange.cxx @@ -41,7 +41,9 @@ void RWStepKinematics_RWSphericalPairWithPinAndRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 16, theArch, "spherical_pair_with_pin_and_range")) + { return; + } // Inherited fields of RepresentationItem @@ -237,7 +239,9 @@ void RWStepKinematics_RWSphericalPairWithPinAndRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -268,28 +272,36 @@ void RWStepKinematics_RWSphericalPairWithPinAndRange::WriteStep( theSW.Send(theEnt->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitYaw()) { theSW.Send(theEnt->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitRoll()) { theSW.Send(theEnt->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitRoll()) { theSW.Send(theEnt->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithRange.cxx index d94b6fb650..f5e8ea1ece 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSphericalPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWSphericalPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 18, theArch, "spherical_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -264,7 +266,9 @@ void RWStepKinematics_RWSphericalPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -295,42 +299,54 @@ void RWStepKinematics_RWSphericalPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitYaw()) { theSW.Send(theEnt->UpperLimitYaw()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitPitch()) { theSW.Send(theEnt->LowerLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitPitch()) { theSW.Send(theEnt->UpperLimitPitch()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitRoll()) { theSW.Send(theEnt->LowerLimitRoll()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitRoll()) { theSW.Send(theEnt->UpperLimitRoll()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSurfacePairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSurfacePairWithRange.cxx index b7fd330f57..ada0cccc2c 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSurfacePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWSurfacePairWithRange.cxx @@ -42,7 +42,9 @@ void RWStepKinematics_RWSurfacePairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 13, theArch, "surface_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -210,7 +212,9 @@ void RWStepKinematics_RWSurfacePairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -239,14 +243,18 @@ void RWStepKinematics_RWSurfacePairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitActualRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitActualRotation()) { theSW.Send(theEnt->UpperLimitActualRotation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPair.cxx index 2b0acb350e..92e59992b7 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPair.cxx @@ -39,7 +39,9 @@ void RWStepKinematics_RWUnconstrainedPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 12, theArch, "unconstrained_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -177,7 +179,9 @@ void RWStepKinematics_RWUnconstrainedPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPairValue.cxx index e47800fd6d..9ae3f5fae7 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUnconstrainedPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWUnconstrainedPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 3, theArch, "unconstrained_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPair.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPair.cxx index 4e183af808..c672982455 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPair.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPair.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWUniversalPair::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 13, theArch, "universal_pair")) + { return; + } // Inherited fields of RepresentationItem @@ -194,7 +196,9 @@ void RWStepKinematics_RWUniversalPair::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -225,7 +229,9 @@ void RWStepKinematics_RWUniversalPair::WriteStep( theSW.Send(theEnt->InputSkewAngle()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairValue.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairValue.cxx index 5bededff5d..4c993dd7c2 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairValue.cxx @@ -38,7 +38,9 @@ void RWStepKinematics_RWUniversalPairValue::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 4, theArch, "universal_pair_value")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairWithRange.cxx b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairWithRange.cxx index 73bedd1c3d..6aed600875 100644 --- a/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/RWStepKinematics/RWStepKinematics_RWUniversalPairWithRange.cxx @@ -40,7 +40,9 @@ void RWStepKinematics_RWUniversalPairWithRange::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 17, theArch, "universal_pair_with_range")) + { return; + } // Inherited fields of RepresentationItem @@ -264,7 +266,9 @@ void RWStepKinematics_RWUniversalPairWithRange::WriteStep( theSW.Send(theEnt->ItemDefinedTransformation()->Description()); } else + { theSW.SendUndef(); + } theSW.Send(theEnt->ItemDefinedTransformation()->TransformItem1()); @@ -295,7 +299,9 @@ void RWStepKinematics_RWUniversalPairWithRange::WriteStep( theSW.Send(theEnt->InputSkewAngle()); } else + { theSW.SendUndef(); + } // Own fields of UniversalPairWithRange @@ -304,28 +310,36 @@ void RWStepKinematics_RWUniversalPairWithRange::WriteStep( theSW.Send(theEnt->LowerLimitFirstRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitFirstRotation()) { theSW.Send(theEnt->UpperLimitFirstRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasLowerLimitSecondRotation()) { theSW.Send(theEnt->LowerLimitSecondRotation()); } else + { theSW.SendUndef(); + } if (theEnt->HasUpperLimitSecondRotation()) { theSW.Send(theEnt->UpperLimitSecondRotation()); } else + { theSW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAllAroundShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAllAroundShapeAspect.cxx index 6fb12cc2fb..85b6e4fbb4 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAllAroundShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAllAroundShapeAspect.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWAllAroundShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "all_around_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWApex.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWApex.cxx index ac0bbcfc98..20989123a1 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWApex.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWApex.cxx @@ -34,7 +34,9 @@ void RWStepRepr_RWApex::ReadStep(const occ::handle& dat { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "apex")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsage.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsage.cxx index 3d85b64d51..0f2bef62ac 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsage.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWAssemblyComponentUsage::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "assembly_component_usage")) + { return; + } // Inherited fields of ProductDefinitionRelationship @@ -156,7 +158,9 @@ void RWStepRepr_RWAssemblyComponentUsage::WriteStep( SW.Send(ent->StepBasic_ProductDefinitionRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_ProductDefinitionRelationship::RelatingProductDefinitionAP242().Value()); @@ -169,7 +173,9 @@ void RWStepRepr_RWAssemblyComponentUsage::WriteStep( SW.Send(ent->ReferenceDesignator()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsageSubstitute.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsageSubstitute.cxx index 06ef95b613..7e351562b1 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsageSubstitute.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWAssemblyComponentUsageSubstitute.cxx @@ -33,7 +33,9 @@ void RWStepRepr_RWAssemblyComponentUsageSubstitute::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "assembly_component_usage_substitute")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBetweenShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBetweenShapeAspect.cxx index 4374b3debf..3c4665f6a7 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBetweenShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBetweenShapeAspect.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWBetweenShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "between_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBooleanRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBooleanRepresentationItem.cxx index 2651e2b767..460e897f51 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBooleanRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWBooleanRepresentationItem.cxx @@ -27,7 +27,9 @@ void RWStepRepr_RWBooleanRepresentationItem::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 2, theAch, "boolean_representation_item")) + { return; + } // --- inherited field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCentreOfSymmetry.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCentreOfSymmetry.cxx index 662bd24d33..42e0dacc92 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCentreOfSymmetry.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCentreOfSymmetry.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWCentreOfSymmetry::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "centre_of_symmetry")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCharacterizedRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCharacterizedRepresentation.cxx index 27cbd21e39..8ee764502b 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCharacterizedRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCharacterizedRepresentation.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWCharacterizedRepresentation::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 4, ach, "characterized_representation")) + { return; + } // name occ::handle aName; @@ -62,7 +64,9 @@ void RWStepRepr_RWCharacterizedRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anItem)) + { anItems->SetValue(i, anItem); + } } } @@ -90,9 +94,13 @@ void RWStepRepr_RWCharacterizedRepresentation::WriteStep( // description if (!ent->Description().IsNull()) + { SW.Send(ent->Description()); + } else + { SW.SendUndef(); + } // items SW.OpenSub(); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompGroupShAspAndCompShAspAndDatumFeatAndShAsp.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompGroupShAspAndCompShAspAndDatumFeatAndShAsp.cxx index d793e9e759..48019a83cd 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompGroupShAspAndCompShAspAndDatumFeatAndShAsp.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompGroupShAspAndCompShAspAndDatumFeatAndShAsp.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWCompGroupShAspAndCompShAspAndDatumFeatAndShAsp::ReadStep( int num = 0; data->NamedForComplex("SHAPE_ASPECT", "SHPASP", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "shape_aspect")) + { return; + } occ::handle aName; data->ReadString(num, 1, "name", ach, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.cxx index 9c71feb54e..bf438837e5 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWCompShAspAndDatumFeatAndShAsp::ReadStep( int num = 0; data->NamedForComplex("SHAPE_ASPECT", "SHPASP", num0, num, ach); if (!data->CheckNbParams(num, 4, ach, "shape_aspect")) + { return; + } occ::handle aName; data->ReadString(num, 1, "name", ach, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeGroupShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeGroupShapeAspect.cxx index 4cdd5ab201..d932000fc2 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeGroupShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeGroupShapeAspect.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWCompositeGroupShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "composite_group_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeShapeAspect.cxx index 03aa4c7bdc..63af951992 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompositeShapeAspect.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWCompositeShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "composite_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompoundRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompoundRepresentationItem.cxx index ebeb038281..a51bf81bc1 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompoundRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWCompoundRepresentationItem.cxx @@ -32,7 +32,9 @@ void RWStepRepr_RWCompoundRepresentationItem::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "compound_representation_item")) + { return; + } // --- inherited field : name --- @@ -57,7 +59,9 @@ void RWStepRepr_RWCompoundRepresentationItem::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } @@ -88,5 +92,7 @@ void RWStepRepr_RWCompoundRepresentationItem::Share( { int i, nb = ent->NbItemElement(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ItemElementValue(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationDesign.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationDesign.cxx index 86c08ccaf7..c4d7b82307 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationDesign.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationDesign.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWConfigurationDesign::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "configuration_design")) + { return; + } // Own fields of ConfigurationDesign diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationEffectivity.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationEffectivity.cxx index d3cac212cd..1a2f770ab2 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationEffectivity.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationEffectivity.cxx @@ -38,7 +38,9 @@ void RWStepRepr_RWConfigurationEffectivity::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "configuration_effectivity")) + { return; + } // Inherited fields of Effectivity diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationItem.cxx index 7917b3b924..4ae04a2664 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConfigurationItem.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWConfigurationItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "configuration_item")) + { return; + } // Own fields of ConfigurationItem @@ -95,7 +97,9 @@ void RWStepRepr_RWConfigurationItem::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->ItemConcept()); @@ -104,7 +108,9 @@ void RWStepRepr_RWConfigurationItem::WriteStep( SW.Send(ent->Purpose()); } else + { SW.SendUndef(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentation.cxx index 0a38c56840..bafa253b40 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWConstructiveGeometryRepresentation::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "constructive_geometry_representation")) + { return; + } // Inherited field : name occ::handle aName; @@ -59,7 +61,9 @@ void RWStepRepr_RWConstructiveGeometryRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) + { aItems->SetValue(i, anEnt); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentationRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentationRelationship.cxx index 8c440b1e98..caafa38999 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentationRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWConstructiveGeometryRepresentationRelationship.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWConstructiveGeometryRepresentationRelationship::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 4, ach, "constructive_geometry_representation_relationship")) + { return; + } // Inherited field : name occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWContinuosShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWContinuosShapeAspect.cxx index 3169723855..78d8d2b289 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWContinuosShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWContinuosShapeAspect.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWContinuosShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "continuos_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDataEnvironment.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDataEnvironment.cxx index 5ae9e3f8c8..522bcd1580 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDataEnvironment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDataEnvironment.cxx @@ -38,7 +38,9 @@ void RWStepRepr_RWDataEnvironment::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "data_environment")) + { return; + } // Own fields of DataEnvironment diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDefinitionalRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDefinitionalRepresentation.cxx index 3661e2b2c1..08dd7f0140 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDefinitionalRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDefinitionalRepresentation.cxx @@ -34,7 +34,9 @@ void RWStepRepr_RWDefinitionalRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "definitional_representation")) + { return; + } // --- inherited field : name --- @@ -60,7 +62,9 @@ void RWStepRepr_RWDefinitionalRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDerivedShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDerivedShapeAspect.cxx index 7291edfad2..b457baf45e 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDerivedShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWDerivedShapeAspect.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWDerivedShapeAspect::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "derived_shape_aspect")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWExtension.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWExtension.cxx index b6f915f5ee..d8a30c8dc7 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWExtension.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWExtension.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWExtension::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "extension")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx index 49f54ad2dd..df96753f5b 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWFeatureForDatumTargetRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "feature_for_datum_target-relationship")) + { return; + } // Own fields of ShapeAspectRelationship @@ -91,7 +93,9 @@ void RWStepRepr_RWFeatureForDatumTargetRelationship::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFunctionallyDefinedTransformation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFunctionallyDefinedTransformation.cxx index 73bb7bcf2c..7e34487107 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFunctionallyDefinedTransformation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWFunctionallyDefinedTransformation.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWFunctionallyDefinedTransformation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "functionally_defined_transformation")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGeometricAlignment.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGeometricAlignment.cxx index e109c223ce..32c759a2a7 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGeometricAlignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGeometricAlignment.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWGeometricAlignment::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "geometric_alignment")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUncertaintyAssignedContext.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUncertaintyAssignedContext.cxx index 513d59df62..8526cd7af9 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUncertaintyAssignedContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUncertaintyAssignedContext.cxx @@ -32,7 +32,9 @@ void RWStepRepr_RWGlobalUncertaintyAssignedContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "global_uncertainty_assigned_context")) + { return; + } // --- inherited field : contextIdentifier --- @@ -65,7 +67,9 @@ void RWStepRepr_RWGlobalUncertaintyAssignedContext::ReadStep( ach, STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3)) + { aUncertainty->SetValue(i3, anent3); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUnitAssignedContext.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUnitAssignedContext.cxx index 6a61fc79e4..c881659922 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUnitAssignedContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWGlobalUnitAssignedContext.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWGlobalUnitAssignedContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "global_unit_assigned_context")) + { return; + } // --- inherited field : contextIdentifier --- @@ -58,7 +60,9 @@ void RWStepRepr_RWGlobalUnitAssignedContext::ReadStep( { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent3)) + { aUnits->SetValue(i3, anent3); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWIntegerRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWIntegerRepresentationItem.cxx index c895861c85..d3641d020d 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWIntegerRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWIntegerRepresentationItem.cxx @@ -29,7 +29,9 @@ void RWStepRepr_RWIntegerRepresentationItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "integer_representation_item")) + { return; + } // --- inherited field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWItemDefinedTransformation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWItemDefinedTransformation.cxx index 80d10060a3..97dcff0f0e 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWItemDefinedTransformation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWItemDefinedTransformation.cxx @@ -33,7 +33,9 @@ void RWStepRepr_RWItemDefinedTransformation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "item_defined_transformation")) + { return; + } // --- own fields occ::handle name, description; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMakeFromUsageOption.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMakeFromUsageOption.cxx index c1da268d6d..c4ecb3da40 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMakeFromUsageOption.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMakeFromUsageOption.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWMakeFromUsageOption::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 8, ach, "make_from_usage_option")) + { return; + } // Inherited fields of ProductDefinitionRelationship @@ -124,7 +126,9 @@ void RWStepRepr_RWMakeFromUsageOption::WriteStep( SW.Send(ent->StepBasic_ProductDefinitionRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_ProductDefinitionRelationship::RelatingProductDefinitionAP242().Value()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMappedItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMappedItem.cxx index 18e4b93809..0ba227979f 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMappedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMappedItem.cxx @@ -30,7 +30,9 @@ void RWStepRepr_RWMappedItem::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "mapped_item")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialDesignation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialDesignation.cxx index 78b3ad98c1..d2108e7feb 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialDesignation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialDesignation.cxx @@ -29,7 +29,9 @@ void RWStepRepr_RWMaterialDesignation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "material_designation")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialProperty.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialProperty.cxx index 8721616b1c..19f8abd997 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialProperty.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWMaterialProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "material_property")) + { return; + } // Inherited fields of PropertyDefinition @@ -83,7 +85,9 @@ void RWStepRepr_RWMaterialProperty::WriteStep( SW.Send(ent->StepRepr_PropertyDefinition::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_PropertyDefinition::Definition().Value()); } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialPropertyRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialPropertyRepresentation.cxx index bb68200e01..f607772e30 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialPropertyRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMaterialPropertyRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepRepr_RWMaterialPropertyRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "material_property_representation")) + { return; + } // Inherited fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMeasureRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMeasureRepresentationItem.cxx index 25849acf95..d9e7e78b99 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMeasureRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMeasureRepresentationItem.cxx @@ -39,7 +39,9 @@ void RWStepRepr_RWMeasureRepresentationItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "measure_representation_item")) + { return; + } // --- inherited from representation_item : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMechanicalDesignAndDraughtingRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMechanicalDesignAndDraughtingRelationship.cxx index abf26e47ef..dff4d0d775 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMechanicalDesignAndDraughtingRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWMechanicalDesignAndDraughtingRelationship.cxx @@ -30,7 +30,9 @@ void RWStepRepr_RWMechanicalDesignAndDraughtingRelationship::ReadStep( { // Number of Parameter Control if (!theData->CheckNbParams(theNum, 4, theAch, "mechanical_design_and_draughting_relationship")) + { return; + } // Inherited field : name occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParallelOffset.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParallelOffset.cxx index 8fd6a04739..921941ebd1 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParallelOffset.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParallelOffset.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWParallelOffset::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "parallel_offset")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParametricRepresentationContext.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParametricRepresentationContext.cxx index 6972471b45..f47e2e37d5 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParametricRepresentationContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWParametricRepresentationContext.cxx @@ -29,7 +29,9 @@ void RWStepRepr_RWParametricRepresentationContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "parametric_representation_context")) + { return; + } // --- inherited field : contextIdentifier --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPerpendicularTo.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPerpendicularTo.cxx index a26b981e96..802d743682 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPerpendicularTo.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPerpendicularTo.cxx @@ -34,7 +34,9 @@ void RWStepRepr_RWPerpendicularTo::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "perpendicular_to")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductConcept.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductConcept.cxx index d42434d4f5..af1915eaa9 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductConcept.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductConcept.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWProductConcept::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "product_concept")) + { return; + } // Own fields of ProductConcept @@ -86,7 +88,9 @@ void RWStepRepr_RWProductConcept::WriteStep(StepData_StepWriter& SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->MarketContext()); } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductDefinitionShape.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductDefinitionShape.cxx index 66477a9525..3c0b43ae17 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductDefinitionShape.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWProductDefinitionShape.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWProductDefinitionShape::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "product_definition_shape")) + { return; + } // Inherited fields of PropertyDefinition @@ -83,7 +85,9 @@ void RWStepRepr_RWProductDefinitionShape::WriteStep( SW.Send(ent->StepRepr_PropertyDefinition::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_PropertyDefinition::Definition().Value()); } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinition.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinition.cxx index d837c05f63..f2b1dec4f6 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinition.cxx @@ -35,7 +35,9 @@ void RWStepRepr_RWPropertyDefinition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "property_definition")) + { return; + } // Own fields of PropertyDefinition @@ -76,7 +78,9 @@ void RWStepRepr_RWPropertyDefinition::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->Definition().Value()); } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRelationship.cxx index ee8448c387..c2aadf11c7 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRelationship.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWPropertyDefinitionRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "property_definition_relationship")) + { return; + } // Own fields of PropertyDefinitionRelationship diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRepresentation.cxx index c15df606e9..f87fc22b42 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWPropertyDefinitionRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWPropertyDefinitionRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "property_definition_representation")) + { return; + } // Own fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWQuantifiedAssemblyComponentUsage.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWQuantifiedAssemblyComponentUsage.cxx index 5938ea6588..3905750cd5 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWQuantifiedAssemblyComponentUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWQuantifiedAssemblyComponentUsage.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWQuantifiedAssemblyComponentUsage::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 7, ach, "quantified_assembly_component_usage")) + { return; + } // Inherited fields of ProductDefinitionRelationship @@ -136,7 +138,9 @@ void RWStepRepr_RWQuantifiedAssemblyComponentUsage::WriteStep( SW.Send(ent->StepBasic_ProductDefinitionRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_ProductDefinitionRelationship::RelatingProductDefinitionAP242().Value()); @@ -149,7 +153,9 @@ void RWStepRepr_RWQuantifiedAssemblyComponentUsage::WriteStep( SW.Send(ent->StepRepr_AssemblyComponentUsage::ReferenceDesignator()); } else + { SW.SendUndef(); + } // Own fields of QuantifiedAssemblyComponentUsage diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRealRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRealRepresentationItem.cxx index d3dd905501..aa2f3f03db 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRealRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRealRepresentationItem.cxx @@ -27,7 +27,9 @@ void RWStepRepr_RWRealRepresentationItem::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 2, theAch, "real_representation_item")) + { return; + } // --- inherited field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnit.cxx index 6200346d8c..8747424145 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnit.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnit::ReadStep( int num = 0; // num0; data->NamedForComplex("MEASURE_WITH_UNIT", "MSWTUN", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "measure_with_unit")) + { return; + } // --- own field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; data->ReadMember(num, 1, "value_component", ach, mvc); @@ -48,7 +50,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnit::ReadStep( data->NamedForComplex("REPRESENTATION_ITEM", "RPRITM", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- own field : name --- occ::handle aName; data->ReadString(num, 1, "name", ach, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI.cxx index 3d8ace5288..74c7a16160 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI.cxx @@ -40,7 +40,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep( int num = 0; // num0; data->NamedForComplex("MEASURE_WITH_UNIT", "MSWTUN", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "measure_with_unit")) + { return; + } // --- own field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; data->ReadMember(num, 1, "value_component", ach, mvc); @@ -52,7 +54,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep( data->NamedForComplex("QUALIFIED_REPRESENTATION_ITEM", "QLRPIT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "qualified_representation_item")) + { return; + } // --- own field : qualifiers --- occ::handle> quals; int nsub; @@ -64,7 +68,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep( { StepShape_ValueQualifier aVQ; if (data->ReadEntity(nsub, i, "qualifier", ach, aVQ)) + { quals->SetValue(i, aVQ); + } } } @@ -74,7 +80,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep( data->NamedForComplex("REPRESENTATION_ITEM", "RPRITM", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- own field : name --- occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -101,7 +109,9 @@ void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::WriteStep( int i, nbq = aQRI->NbQualifiers(); SW.OpenSub(); for (i = 1; i <= nbq; i++) + { SW.Send(aQRI->QualifiersValue(i).Value()); + } SW.CloseSub(); SW.StartEntity("REPRESENTATION_ITEM"); SW.Send(ent->Name()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit.cxx index 7782ee85a8..90debeee3d 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit.cxx @@ -38,7 +38,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit::ReadStep( int num = 0; // num0; data->NamedForComplex("MEASURE_WITH_UNIT", "MSWTUN", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "measure_with_unit")) + { return; + } // --- own field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; data->ReadMember(num, 1, "value_component", ach, mvc); @@ -50,7 +52,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnit::ReadStep( data->NamedForComplex("REPRESENTATION_ITEM", "RPRITM", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- own field : name --- occ::handle aName; data->ReadString(num, 1, "name", ach, aName); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.cxx index 612d9f7f25..481b3eff87 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.cxx @@ -40,7 +40,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::ReadStep( int num = 0; // num0; data->NamedForComplex("MEASURE_WITH_UNIT", "MSWTUN", num0, num, ach); if (!data->CheckNbParams(num, 2, ach, "measure_with_unit")) + { return; + } // --- own field : valueComponent --- occ::handle mvc = new StepBasic_MeasureValueMember; data->ReadMember(num, 1, "value_component", ach, mvc); @@ -52,7 +54,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::ReadStep( data->NamedForComplex("QUALIFIED_REPRESENTATION_ITEM", "QLRPIT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "qualified_representation_item")) + { return; + } // --- own field : qualifiers --- occ::handle> quals; int nsub; @@ -64,7 +68,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::ReadStep( { StepShape_ValueQualifier aVQ; if (data->ReadEntity(nsub, i, "qualifier", ach, aVQ)) + { quals->SetValue(i, aVQ); + } } } occ::handle aQRI = @@ -73,7 +79,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::ReadStep( data->NamedForComplex("REPRESENTATION_ITEM", "RPRITM", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- own field : name --- occ::handle aName; data->ReadString(num, 1, "name", ach, aName); @@ -100,7 +108,9 @@ void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::WriteStep( int i, nbq = aQRI->NbQualifiers(); SW.OpenSub(); for (i = 1; i <= nbq; i++) + { SW.Send(aQRI->QualifiersValue(i).Value()); + } SW.CloseSub(); SW.StartEntity("REPRESENTATION_ITEM"); SW.Send(ent->Name()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentation.cxx index 11de93ff0b..b927f07499 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentation.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWRepresentation::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "representation")) + { return; + } // --- own field : name --- @@ -57,7 +59,9 @@ void RWStepRepr_RWRepresentation::ReadStep(const occ::handleSetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContext.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContext.cxx index 492e21c1dd..c663840a1d 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContext.cxx @@ -28,7 +28,9 @@ void RWStepRepr_RWRepresentationContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "representation_context")) + { return; + } // --- own field : contextIdentifier --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContextReference.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContextReference.cxx index 1f73fcd29e..f3f7867e5e 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContextReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationContextReference.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWRepresentationContextReference::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 1, theAch, "representation_context_reference")) + { return; + } // Own fields of RepresentationContextReference diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationItem.cxx index fad21e4dbf..cca39ecddc 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationItem.cxx @@ -28,7 +28,9 @@ void RWStepRepr_RWRepresentationItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationMap.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationMap.cxx index 22853cea40..a35606b91d 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationMap.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationMap.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWRepresentationMap::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "representation_map")) + { return; + } // --- own field : mappingOrigin --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationReference.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationReference.cxx index 7dc3fa3e76..1271a9e518 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationReference.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationReference.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWRepresentationReference::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 2, theAch, "representation_reference")) + { return; + } // Own fields of RepresentationReference diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationship.cxx index 1a65c53aac..aecf1182e9 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationship.cxx @@ -32,7 +32,9 @@ void RWStepRepr_RWRepresentationRelationship::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "representation_relationship")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationshipWithTransformation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationshipWithTransformation.cxx index 736822d70b..607fc7bc6e 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationshipWithTransformation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWRepresentationRelationshipWithTransformation.cxx @@ -32,7 +32,9 @@ void RWStepRepr_RWRepresentationRelationshipWithTransformation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "representation_relationship_with_transformation")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspect.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspect.cxx index a2addd0431..2ee784bfc9 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspect.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspect.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWShapeAspect::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "shape_aspect")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectDerivingRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectDerivingRelationship.cxx index d59b011536..5851fa34e2 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectDerivingRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectDerivingRelationship.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWShapeAspectDerivingRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "shape_aspect_deriving_relationship")) + { return; + } // Inherited fields of ShapeAspectRelationship @@ -99,7 +101,9 @@ void RWStepRepr_RWShapeAspectDerivingRelationship::WriteStep( SW.Send(ent->StepRepr_ShapeAspectRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectRelationship.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectRelationship.cxx index 83f0d66a6d..d9876dca37 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectRelationship.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectRelationship.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWShapeAspectRelationship::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "shape_aspect_relationship")) + { return; + } // Own fields of ShapeAspectRelationship @@ -90,7 +92,9 @@ void RWStepRepr_RWShapeAspectRelationship::WriteStep( SW.Send(ent->Description()); } else + { SW.SendUndef(); + } SW.Send(ent->RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectTransition.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectTransition.cxx index e3bbe12287..2305d69fdf 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectTransition.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeAspectTransition.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWShapeAspectTransition::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "shape_aspect_transition")) + { return; + } // Inherited fields of ShapeAspectRelationship @@ -98,7 +100,9 @@ void RWStepRepr_RWShapeAspectTransition::WriteStep( SW.Send(ent->StepRepr_ShapeAspectRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.cxx index cc23f72823..24e90afdc0 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.cxx @@ -41,7 +41,9 @@ void RWStepRepr_RWShapeRepresentationRelationshipWithTransformation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "representation_relationship")) + { return; + } // --- inherited field : name --- @@ -73,7 +75,9 @@ void RWStepRepr_RWShapeRepresentationRelationshipWithTransformation::ReadStep( data->NamedForComplex("REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION", "RRWT", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_relationship_with_transformation")) + { return; + } // --- own field : transformation_operator @@ -85,7 +89,9 @@ void RWStepRepr_RWShapeRepresentationRelationshipWithTransformation::ReadStep( data->NamedForComplex("SHAPE_REPRESENTATION_RELATIONSHIP", "SHRPRL", num0, num, ach); if (!data->CheckNbParams(num, 0, ach, "shape_representation_relationship")) + { return; + } //--- Initialisation of the read entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWSpecifiedHigherUsageOccurrence.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWSpecifiedHigherUsageOccurrence.cxx index 4371f9eaf0..3726805302 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWSpecifiedHigherUsageOccurrence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWSpecifiedHigherUsageOccurrence.cxx @@ -37,7 +37,9 @@ void RWStepRepr_RWSpecifiedHigherUsageOccurrence::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 8, ach, "specified_higher_usage_occurrence")) + { return; + } // Inherited fields of ProductDefinitionRelationship @@ -150,7 +152,9 @@ void RWStepRepr_RWSpecifiedHigherUsageOccurrence::WriteStep( SW.Send(ent->StepBasic_ProductDefinitionRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepBasic_ProductDefinitionRelationship::RelatingProductDefinitionAP242().Value()); @@ -163,7 +167,9 @@ void RWStepRepr_RWSpecifiedHigherUsageOccurrence::WriteStep( SW.Send(ent->StepRepr_AssemblyComponentUsage::ReferenceDesignator()); } else + { SW.SendUndef(); + } // Own fields of SpecifiedHigherUsageOccurrence diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponseProperty.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponseProperty.cxx index d5d8013eef..1d0709403b 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponseProperty.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponseProperty.cxx @@ -36,7 +36,9 @@ void RWStepRepr_RWStructuralResponseProperty::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "structural_response_property")) + { return; + } // Inherited fields of PropertyDefinition diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponsePropertyDefinitionRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponsePropertyDefinitionRepresentation.cxx index 7d3c325726..be8c57d947 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponsePropertyDefinitionRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWStructuralResponsePropertyDefinitionRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepRepr_RWStructuralResponsePropertyDefinitionRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "structural_response_property_definition_representation")) + { return; + } // Inherited fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWTangent.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWTangent.cxx index dad7e84eb0..8bafa90bb2 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWTangent.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWTangent.cxx @@ -34,7 +34,9 @@ void RWStepRepr_RWTangent::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "tangent")) + { return; + } // Inherited fields of ShapeAspect diff --git a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWValueRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWValueRepresentationItem.cxx index 4ac4b51fa2..a57883f0d3 100644 --- a/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWValueRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepRepr/RWStepRepr_RWValueRepresentationItem.cxx @@ -31,7 +31,9 @@ void RWStepRepr_RWValueRepresentationItem::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "value_representation_item")) + { return; + } // --- inherited field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedBrepShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedBrepShapeRepresentation.cxx index 166c009317..262fff4fab 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedBrepShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedBrepShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWAdvancedBrepShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "advanced_brep_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWAdvancedBrepShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedFace.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedFace.cxx index d9c2b2ebc2..eb464ee341 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedFace.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAdvancedFace.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWAdvancedFace::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "advanced_face")) + { return; + } // --- inherited field : name --- @@ -61,7 +63,9 @@ void RWStepShape_RWAdvancedFace::ReadStep(const occ::handleSetValue(i2, anent2); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularLocation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularLocation.cxx index c1714872ee..b3f26576b2 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularLocation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularLocation.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWAngularLocation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "angular_location")) + { return; + } // Inherited fields of ShapeAspectRelationship @@ -84,16 +86,26 @@ void RWStepShape_RWAngularLocation::ReadStep( { const char* text = data->ParamCValue(num, 5); if (strcmp(text, ".EQUAL.") == 0) + { aAngleSelection = StepShape_Equal; + } else if (strcmp(text, ".LARGE.") == 0) + { aAngleSelection = StepShape_Large; + } else if (strcmp(text, ".SMALL.") == 0) + { aAngleSelection = StepShape_Small; + } else + { ach->AddFail("Parameter #5 (angle_selection) has not allowed value"); + } } else + { ach->AddFail("Parameter #5 (angle_selection) is not enumeration"); + } // Initialize entity ent->Init(aShapeAspectRelationship_Name, @@ -120,7 +132,9 @@ void RWStepShape_RWAngularLocation::WriteStep( SW.Send(ent->StepRepr_ShapeAspectRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularSize.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularSize.cxx index 902faa89df..0226740301 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularSize.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWAngularSize.cxx @@ -35,7 +35,9 @@ void RWStepShape_RWAngularSize::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "angular_size")) + { return; + } // Inherited fields of DimensionalSize @@ -61,16 +63,26 @@ void RWStepShape_RWAngularSize::ReadStep(const occ::handleParamCValue(num, 3); if (strcmp(text, ".EQUAL.") == 0) + { aAngleSelection = StepShape_Equal; + } else if (strcmp(text, ".LARGE.") == 0) + { aAngleSelection = StepShape_Large; + } else if (strcmp(text, ".SMALL.") == 0) + { aAngleSelection = StepShape_Small; + } else + { ach->AddFail("Parameter #3 (angle_selection) has not allowed value"); + } } else + { ach->AddFail("Parameter #3 (angle_selection) is not enumeration"); + } // Initialize entity ent->Init(aDimensionalSize_AppliesTo, aDimensionalSize_Name, aAngleSelection); diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBlock.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBlock.cxx index 7a9be25bfe..42abf65d91 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBlock.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBlock.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWBlock::ReadStep(const occ::handle& d // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "block")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBooleanResult.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBooleanResult.cxx index fc7c0f1984..d22bf87575 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBooleanResult.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBooleanResult.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWBooleanResult::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "boolean_result")) + { return; + } // --- inherited field : name --- @@ -52,7 +54,9 @@ void RWStepShape_RWBooleanResult::ReadStep(const occ::handleAddFail("Parameter #2 (operator) is not an enumeration"); + } // --- own field : firstOperand (is a select type) --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxDomain.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxDomain.cxx index 9ca3f1a3c8..c04a7449ce 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxDomain.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxDomain.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWBoxDomain::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "box_domain")) + { return; + } // --- own field : corner --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxedHalfSpace.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxedHalfSpace.cxx index bd8a6a8c9b..3b678502d5 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxedHalfSpace.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBoxedHalfSpace.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWBoxedHalfSpace::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "boxed_half_space")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBrepWithVoids.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBrepWithVoids.cxx index 0abf6509b8..57a8ee9fc9 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBrepWithVoids.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWBrepWithVoids.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWBrepWithVoids::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "brep_with_voids")) + { return; + } // --- inherited field : name --- @@ -68,7 +70,9 @@ void RWStepShape_RWBrepWithVoids::ReadStep(const occ::handleSetValue(i3, anent3); + } } } @@ -118,9 +122,11 @@ void RWStepShape_RWBrepWithVoids::Check(const occ::handle& ach) const { for (int i = 1; i <= ent->NbVoids(); i++) + { if (ent->VoidsValue(i)->Orientation()) { ach->AddWarning("Void has orientation .T. while .F. is required by API 214"); break; } + } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWClosedShell.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWClosedShell.cxx index f18042d239..870f664e4a 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWClosedShell.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWClosedShell.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWClosedShell::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "closed_shell")) + { return; + } // --- inherited field : name --- @@ -53,7 +55,9 @@ void RWStepShape_RWClosedShell::ReadStep(const occ::handleReadEntity(nsub2, i2, "face", ach, STANDARD_TYPE(StepShape_Face), anent2)) + { aCfsFaces->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCompoundShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCompoundShapeRepresentation.cxx index 15ddfb8674..243f698f9c 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCompoundShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCompoundShapeRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepShape_RWCompoundShapeRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "compound_shape_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedEdgeSet.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedEdgeSet.cxx index 6220d3039b..2a39e39ed5 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedEdgeSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedEdgeSet.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWConnectedEdgeSet::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "connected_edge_set")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSet.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSet.cxx index f052fc128a..9bcd46dff6 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSet.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWConnectedFaceSet::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "connected_face_set")) + { return; + } // --- inherited field : name --- @@ -54,7 +56,9 @@ void RWStepShape_RWConnectedFaceSet::ReadStep( { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "face", ach, STANDARD_TYPE(StepShape_Face), anent2)) + { aCfsFaces->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceShapeRepresentation.cxx index 63eabd1211..58466624c5 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceShapeRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWConnectedFaceShapeRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "connected_face_shape_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSubSet.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSubSet.cxx index ed8dca0652..170c495c49 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSubSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWConnectedFaceSubSet.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWConnectedFaceSubSet::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "connected_face_sub_set")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWContextDependentShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWContextDependentShapeRepresentation.cxx index 2120c1d26a..e731611bc1 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWContextDependentShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWContextDependentShapeRepresentation.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWContextDependentShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "context_dependent_shape_representation")) + { return; + } // --- own field : representation_relation --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgShapeRepresentation.cxx index 5d2f4ed7bc..43f755d6a8 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgShapeRepresentation.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWCsgShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "csg_shape_representation")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepShape_RWCsgShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgSolid.cxx index 87e6ebff4c..bdf4d2f568 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWCsgSolid.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWCsgSolid::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "csg_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.cxx index 8f92e915eb..48ff464d11 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::ReadStep( // --- Instance of plex component definitional_representation --- if (!data->CheckNbParams(num, 3, ach, "representation")) + { return; + } // --- inherited field : name --- @@ -63,7 +65,9 @@ void RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalCharacteristicRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalCharacteristicRepresentation.cxx index 96c8c19d84..b0ce067470 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalCharacteristicRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalCharacteristicRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepShape_RWDimensionalCharacteristicRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "dimensional_characteristic_representation")) + { return; + } // Own fields of DimensionalCharacteristicRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocation.cxx index a04832a502..464a244ed0 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocation.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWDimensionalLocation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "dimensional_location")) + { return; + } // Inherited fields of ShapeAspectRelationship @@ -98,7 +100,9 @@ void RWStepShape_RWDimensionalLocation::WriteStep( SW.Send(ent->StepRepr_ShapeAspectRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocationWithPath.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocationWithPath.cxx index 4a76897368..ecb14bdc24 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocationWithPath.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalLocationWithPath.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWDimensionalLocationWithPath::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 5, ach, "dimensional_location_with_path")) + { return; + } // Inherited fields of ShapeAspectRelationship @@ -104,7 +106,9 @@ void RWStepShape_RWDimensionalLocationWithPath::WriteStep( SW.Send(ent->StepRepr_ShapeAspectRelationship::Description()); } else + { SW.SendUndef(); + } SW.Send(ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect()); diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSize.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSize.cxx index cd1d86d796..3844f129f8 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSize.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSize.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWDimensionalSize::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "dimensional_size")) + { return; + } // Own fields of DimensionalSize diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSizeWithPath.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSizeWithPath.cxx index 31f2c323df..4f65445190 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSizeWithPath.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWDimensionalSizeWithPath.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWDimensionalSizeWithPath::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "dimensional_size_with_path")) + { return; + } // Inherited fields of DimensionalSize diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdge.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdge.cxx index e325126395..4e1bfc3ee4 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdge.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdge.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWEdge::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "edge")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeModel.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeModel.cxx index 170228db95..05bfe4dde1 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeModel.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWEdgeBasedWireframeModel::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "edge_based_wireframe_model")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeShapeRepresentation.cxx index fc199b374c..0486c4f3ad 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeBasedWireframeShapeRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWEdgeBasedWireframeShapeRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "edge_based_wireframe_shape_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeLoop.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeLoop.cxx index 8a263da690..a3f91c2d99 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeLoop.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWEdgeLoop.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWEdgeLoop::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "edge_loop")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWEdgeLoop::ReadStep(const occ::handle ach, STANDARD_TYPE(StepShape_OrientedEdge), anent)) + { aEdgeList->SetValue(i1, anent); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedAreaSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedAreaSolid.cxx index 03413052c3..22581b35be 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedAreaSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedAreaSolid.cxx @@ -31,7 +31,9 @@ void RWStepShape_RWExtrudedAreaSolid::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "extruded_area_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedFaceSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedFaceSolid.cxx index af1c348ee3..bbff4bfaac 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedFaceSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWExtrudedFaceSolid.cxx @@ -31,7 +31,9 @@ void RWStepShape_RWExtrudedFaceSolid::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "extruded_face_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFace.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFace.cxx index 9844f88285..9db351f5c4 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFace.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFace.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWFace::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "face")) + { return; + } // --- inherited field : name --- @@ -54,7 +56,9 @@ void RWStepShape_RWFace::ReadStep(const occ::handle& da // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data ->ReadEntity(nsub2, i2, "face_bound", ach, STANDARD_TYPE(StepShape_FaceBound), anent2)) + { aBounds->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBasedSurfaceModel.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBasedSurfaceModel.cxx index a716ad945f..b38533a868 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBasedSurfaceModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBasedSurfaceModel.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWFaceBasedSurfaceModel::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "face_based_surface_model")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBound.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBound.cxx index 4620b073a1..868d483647 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBound.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceBound.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWFaceBound::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "face_bound")) + { return; + } // --- inherited field : name --- @@ -111,9 +113,13 @@ void RWStepShape_RWFaceBound::Check(const occ::handle& ent, occ::handle refOE2 = occ::down_cast(myShRef.Value()); if (theOE1 == refOE1) + { theOE2 = refOE2; + } else if (theOE1 == refOE2) + { theOE2 = refOE1; + } // get the FaceBound orientation for theOE2 diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceOuterBound.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceOuterBound.cxx index 79415234db..96f317d7a9 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceOuterBound.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceOuterBound.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWFaceOuterBound::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "face_outer_bound")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceSurface.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceSurface.cxx index a92550642e..c9c869018e 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceSurface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFaceSurface.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWFaceSurface::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "face_surface")) + { return; + } // --- inherited field : name --- @@ -55,7 +57,9 @@ void RWStepShape_RWFaceSurface::ReadStep(const occ::handleReadEntity(nsub2, i2, "face_bound", ach, STANDARD_TYPE(StepShape_FaceBound), anent2)) + { aBounds->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrep.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrep.cxx index 59425299ce..05d10edee3 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrep.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrep.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWFacetedBrep::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "faceted_brep")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepAndBrepWithVoids.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepAndBrepWithVoids.cxx index 9f709a9735..3f63206295 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepAndBrepWithVoids.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepAndBrepWithVoids.cxx @@ -37,7 +37,9 @@ void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep( // --- Instance of plex component BrepWithVoids --- if (!data->CheckNbParams(num, 1, ach, "brep_with_voids")) + { return; + } // --- field : voids --- @@ -57,7 +59,9 @@ void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep( ach, STANDARD_TYPE(StepShape_OrientedClosedShell), anent)) + { aVoids->SetValue(i1, anent); + } } } @@ -66,21 +70,27 @@ void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep( // --- Instance of plex component FacetedBrep --- if (!data->CheckNbParams(num, 0, ach, "faceted_brep")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component GeometricRepresentationItem --- if (!data->CheckNbParams(num, 0, ach, "geometric_representation_item")) + { return; + } num = data->NextForComplex(num); // --- Instance of common supertype ManifoldSolidBrep --- if (!data->CheckNbParams(num, 1, ach, "manifold_solid_brep")) + { return; + } // --- field : outer --- occ::handle aOuter; @@ -92,7 +102,9 @@ void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep( // --- Instance of plex component RepresentationItem --- if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -105,7 +117,9 @@ void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep( // --- Instance of plex component SolidModel --- if (!data->CheckNbParams(num, 0, ach, "solid_model")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepShapeRepresentation.cxx index ec6ecf48cc..fe6f7ec7af 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWFacetedBrepShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWFacetedBrepShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "faceted_brep_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWFacetedBrepShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricCurveSet.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricCurveSet.cxx index 3ce6abf8f1..e98d71d71e 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricCurveSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricCurveSet.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWGeometricCurveSet::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "geometric_curve_set")) + { return; + } // --- inherited field : name --- @@ -54,7 +56,9 @@ void RWStepShape_RWGeometricCurveSet::ReadStep( { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "elements", ach, aElementsItem)) + { aElements->SetValue(i2, aElementsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricSet.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricSet.cxx index c73ac560bc..a33e2b1af1 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricSet.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWGeometricSet::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "geometric_set")) + { return; + } // --- inherited field : name --- @@ -53,7 +55,9 @@ void RWStepShape_RWGeometricSet::ReadStep(const occ::handleReadEntity(nsub2, i2, "elements", ach, aElementsItem)) + { aElements->SetValue(i2, aElementsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation.cxx index 1baa0912e5..a35447c77b 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "geometrically_bounded_surface_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWGeometricallyBoundedSurfaceShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation.cxx index 6960ac421f..227e3eb4fb 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "geometrically_bounded_wireframe_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWGeometricallyBoundedWireframeShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWHalfSpaceSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWHalfSpaceSolid.cxx index 22f55edcb9..7e9106a826 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWHalfSpaceSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWHalfSpaceSolid.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWHalfSpaceSolid::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "half_space_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLimitsAndFits.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLimitsAndFits.cxx index 85ac2a84d0..9b46ddc63d 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLimitsAndFits.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLimitsAndFits.cxx @@ -27,7 +27,9 @@ void RWStepShape_RWLimitsAndFits::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "limits_and_fits")) + { return; + } // --- own field : form_variance --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoop.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoop.cxx index 860bfeee91..501d98dd1e 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoop.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoop.cxx @@ -27,7 +27,9 @@ void RWStepShape_RWLoop::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "loop")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoopAndPath.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoopAndPath.cxx index ecddce594b..9f2dd6fa00 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoopAndPath.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWLoopAndPath.cxx @@ -32,14 +32,18 @@ void RWStepShape_RWLoopAndPath::ReadStep(const occ::handleCheckNbParams(num, 0, ach, "loop")) + { return; + } num = data->NextForComplex(num); // --- Instance of plex component Path --- if (!data->CheckNbParams(num, 1, ach, "path")) + { return; + } // --- field : edgeList --- @@ -59,7 +63,9 @@ void RWStepShape_RWLoopAndPath::ReadStep(const occ::handleSetValue(i1, anent1); + } } } @@ -68,7 +74,9 @@ void RWStepShape_RWLoopAndPath::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- field : name --- @@ -81,7 +89,9 @@ void RWStepShape_RWLoopAndPath::ReadStep(const occ::handleCheckNbParams(num, 0, ach, "topological_representation_item")) + { return; + } //--- Initialisation of the red entity --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSolidBrep.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSolidBrep.cxx index 8ae25cf76a..6b7fd781fd 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSolidBrep.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSolidBrep.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWManifoldSolidBrep::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "manifold_solid_brep")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSurfaceShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSurfaceShapeRepresentation.cxx index 5dead4ef5a..073032f31f 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSurfaceShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWManifoldSurfaceShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWManifoldSurfaceShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "manifold_surface_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWManifoldSurfaceShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureQualification.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureQualification.cxx index 0860dad770..a1f297e54f 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureQualification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureQualification.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWMeasureQualification::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "measure_qualification")) + { return; + } // --- own field : name --- @@ -62,7 +64,9 @@ void RWStepShape_RWMeasureQualification::ReadStep( { StepShape_ValueQualifier VQ; if (data->ReadEntity(nsub4, i4, "qualifier", ach, VQ)) + { quals->SetValue(i4, VQ); + } } } @@ -81,7 +85,9 @@ void RWStepShape_RWMeasureQualification::WriteStep( int i, nbq = ent->NbQualifiers(); SW.OpenSub(); for (i = 1; i <= nbq; i++) + { SW.Send(ent->QualifiersValue(i).Value()); + } SW.CloseSub(); } @@ -91,5 +97,7 @@ void RWStepShape_RWMeasureQualification::Share( { int i, nbq = ent->NbQualifiers(); for (i = 1; i <= nbq; i++) + { iter.AddItem(ent->QualifiersValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem.cxx index 1fd1db3d66..8b52885ec7 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem.cxx @@ -42,7 +42,9 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Read // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "measure_representation_item")) + { return; + } // --- inherited from measure_with_unit : value_component --- occ::handle mvc = new StepBasic_MeasureValueMember; @@ -59,7 +61,9 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Read // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "qualified_representation_item")) + { return; + } // --- own field : qualifiers --- @@ -73,7 +77,9 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Read { StepShape_ValueQualifier VQ; if (data->ReadEntity(nsub1, i1, "qualifier", ach, VQ)) + { quals->SetValue(i1, VQ); + } } } @@ -82,7 +88,9 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Read data->NamedForComplex("REPRESENTATION_ITEM", "RPRITM", num0, num, ach); if (!data->CheckNbParams(num, 1, ach, "representation_item")) + { return; + } // --- inherited field from this component : name --- @@ -118,7 +126,9 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Writ int i, nbq = ent->NbQualifiers(); SW.OpenSub(); for (i = 1; i <= nbq; i++) + { SW.Send(ent->QualifiersValue(i).Value()); + } SW.CloseSub(); // --- Instance of plex component : RepresentationItem @@ -138,5 +148,7 @@ void RWStepShape_RWMeasureRepresentationItemAndQualifiedRepresentationItem::Shar int i, nbq = ent->NbQualifiers(); for (i = 1; i <= nbq; i++) + { iter.AddItem(ent->QualifiersValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWNonManifoldSurfaceShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWNonManifoldSurfaceShapeRepresentation.cxx index 8f88113a31..23f03bfd44 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWNonManifoldSurfaceShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWNonManifoldSurfaceShapeRepresentation.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWNonManifoldSurfaceShapeRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "non_manifold_surface_shape_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOpenShell.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOpenShell.cxx index a3e46b2ec9..161bd1e6ad 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOpenShell.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOpenShell.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWOpenShell::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "open_shell")) + { return; + } // --- inherited field : name --- @@ -50,7 +52,9 @@ void RWStepShape_RWOpenShell::ReadStep(const occ::handleReadEntity(nsub2, i2, "face", ach, STANDARD_TYPE(StepShape_Face), anent2)) + { aCfsFaces->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedClosedShell.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedClosedShell.cxx index 85b27ddb29..291dba7c6c 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedClosedShell.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedClosedShell.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWOrientedClosedShell::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "oriented_closed_shell")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedEdge.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedEdge.cxx index 6cfb04588e..19f46e256c 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedEdge.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedEdge.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWOrientedEdge::ReadStep(const occ::handleCheckNbParams(num, 5, ach, "oriented_edge")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedFace.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedFace.cxx index e6e409ddf0..4a8f011a80 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedFace.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedFace.cxx @@ -28,7 +28,9 @@ void RWStepShape_RWOrientedFace::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "oriented_face")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedOpenShell.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedOpenShell.cxx index d45e9bc7cd..7af6f5fd14 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedOpenShell.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedOpenShell.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWOrientedOpenShell::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "oriented_open_shell")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedPath.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedPath.cxx index de4e0f0138..72c2a6a45a 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedPath.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWOrientedPath.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWOrientedPath::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "oriented_path")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPath.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPath.cxx index 6357546f20..a3531d4fc4 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPath.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPath.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWPath::ReadStep(const occ::handle& da // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "path")) + { return; + } // --- inherited field : name --- @@ -56,7 +58,9 @@ void RWStepShape_RWPath::ReadStep(const occ::handle& da ach, STANDARD_TYPE(StepShape_OrientedEdge), anent2)) + { aEdgeList->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPlusMinusTolerance.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPlusMinusTolerance.cxx index e8340b587d..9e11caa0ac 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPlusMinusTolerance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPlusMinusTolerance.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWPlusMinusTolerance::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "plus_minus_tolerance")) + { return; + } // --- own field : range --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPointRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPointRepresentation.cxx index 4591e9ab90..e94a2a9e02 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPointRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPointRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepShape_RWPointRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "point_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPolyLoop.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPolyLoop.cxx index ba27d2a567..590b854bfd 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPolyLoop.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPolyLoop.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWPolyLoop::ReadStep(const occ::handle // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "poly_loop")) + { return; + } // --- inherited field : name --- @@ -55,7 +57,9 @@ void RWStepShape_RWPolyLoop::ReadStep(const occ::handle ach, STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) + { aPolygon->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPrecisionQualifier.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPrecisionQualifier.cxx index a0889e7b84..d572e9a938 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPrecisionQualifier.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWPrecisionQualifier.cxx @@ -27,7 +27,9 @@ void RWStepShape_RWPrecisionQualifier::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "precision_qualifier")) + { return; + } // --- own field : precision_value --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWQualifiedRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWQualifiedRepresentationItem.cxx index 4c91a22304..f0bb594f18 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWQualifiedRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWQualifiedRepresentationItem.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWQualifiedRepresentationItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "qualified_representation_item")) + { return; + } // --- inherited field : name --- @@ -51,7 +53,9 @@ void RWStepShape_RWQualifiedRepresentationItem::ReadStep( { StepShape_ValueQualifier VQ; if (data->ReadEntity(nsub2, i2, "qualifier", ach, VQ)) + { quals->SetValue(i2, VQ); + } } } @@ -72,7 +76,9 @@ void RWStepShape_RWQualifiedRepresentationItem::WriteStep( int i, nbq = ent->NbQualifiers(); SW.OpenSub(); for (i = 1; i <= nbq; i++) + { SW.Send(ent->QualifiersValue(i).Value()); + } SW.CloseSub(); } @@ -82,5 +88,7 @@ void RWStepShape_RWQualifiedRepresentationItem::Share( { int i, nbq = ent->NbQualifiers(); for (i = 1; i <= nbq; i++) + { iter.AddItem(ent->QualifiersValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedAreaSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedAreaSolid.cxx index 10c34e48de..9e47e0048c 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedAreaSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedAreaSolid.cxx @@ -31,7 +31,9 @@ void RWStepShape_RWRevolvedAreaSolid::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "revolved_area_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedFaceSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedFaceSolid.cxx index 5feb84cde0..7c32a03682 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedFaceSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRevolvedFaceSolid.cxx @@ -31,7 +31,9 @@ void RWStepShape_RWRevolvedFaceSolid::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "revolved_face_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightAngularWedge.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightAngularWedge.cxx index f3226e25c3..433f376141 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightAngularWedge.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightAngularWedge.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWRightAngularWedge::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 6, ach, "right_angular_wedge")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCone.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCone.cxx index 130c0a74fe..b3102b32be 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCone.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCone.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWRightCircularCone::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "right_circular_cone")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCylinder.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCylinder.cxx index e4052f811a..da584afb0a 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCylinder.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWRightCircularCylinder.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWRightCircularCylinder::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "right_circular_cylinder")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSeamEdge.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSeamEdge.cxx index d910cdd60a..a7f3be631f 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSeamEdge.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSeamEdge.cxx @@ -36,7 +36,9 @@ void RWStepShape_RWSeamEdge::ReadStep(const occ::handle { // Check number of parameters if (!data->CheckNbParams(num, 6, ach, "seam_edge")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDefinitionRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDefinitionRepresentation.cxx index c6415328f5..70a036322d 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDefinitionRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDefinitionRepresentation.cxx @@ -38,7 +38,9 @@ void RWStepShape_RWShapeDefinitionRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "shape_definition_representation")) + { return; + } // Inherited fields of PropertyDefinitionRepresentation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDimensionRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDimensionRepresentation.cxx index 235768fa0d..ecd505b283 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDimensionRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeDimensionRepresentation.cxx @@ -37,7 +37,9 @@ void RWStepShape_RWShapeDimensionRepresentation::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "shape_dimension_representation")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentation.cxx index 85ba72d6e9..f5f4f8eca2 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentation.cxx @@ -32,7 +32,9 @@ void RWStepShape_RWShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "shape_representation")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepShape_RWShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentationWithParameters.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentationWithParameters.cxx index 97220f68a0..41f7dadb5e 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentationWithParameters.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShapeRepresentationWithParameters.cxx @@ -39,7 +39,9 @@ void RWStepShape_RWShapeRepresentationWithParameters::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "shape_representation_with_parameters")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShellBasedSurfaceModel.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShellBasedSurfaceModel.cxx index 7c7b94f03d..cf82fd8db6 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShellBasedSurfaceModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWShellBasedSurfaceModel.cxx @@ -31,7 +31,9 @@ void RWStepShape_RWShellBasedSurfaceModel::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "shell_based_surface_model")) + { return; + } // --- inherited field : name --- @@ -52,7 +54,9 @@ void RWStepShape_RWShellBasedSurfaceModel::ReadStep( { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "sbsm_boundary", ach, aSbsmBoundaryItem)) + { aSbsmBoundary->SetValue(i2, aSbsmBoundaryItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidModel.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidModel.cxx index 91cb5b12d5..4a1fa8413d 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidModel.cxx @@ -27,7 +27,9 @@ void RWStepShape_RWSolidModel::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "solid_model")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidReplica.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidReplica.cxx index 58f4ab6876..a44fe28a58 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidReplica.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSolidReplica.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWSolidReplica::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "solid_replica")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSphere.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSphere.cxx index fb0791d9ae..63738676d1 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSphere.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSphere.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWSphere::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "sphere")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubedge.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubedge.cxx index 392d1ddf5d..a7d739c6df 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubedge.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubedge.cxx @@ -35,7 +35,9 @@ void RWStepShape_RWSubedge::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 4, ach, "subedge")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubface.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubface.cxx index 61878d91bb..584012886c 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubface.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSubface.cxx @@ -38,7 +38,9 @@ void RWStepShape_RWSubface::ReadStep(const occ::handle& { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "subface")) + { return; + } // Inherited fields of RepresentationItem diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptAreaSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptAreaSolid.cxx index e37e8a37f6..2f8b847cf6 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptAreaSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptAreaSolid.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWSweptAreaSolid::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "swept_area_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptFaceSolid.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptFaceSolid.cxx index 7b7309c334..ad876da3e3 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptFaceSolid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWSweptFaceSolid.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWSweptFaceSolid::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "swept_face_solid")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWToleranceValue.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWToleranceValue.cxx index d64729f4ef..627411c00f 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWToleranceValue.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWToleranceValue.cxx @@ -30,7 +30,9 @@ void RWStepShape_RWToleranceValue::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "tolerance_value")) + { return; + } // --- own field : lower_bound --- @@ -44,7 +46,9 @@ void RWStepShape_RWToleranceValue::ReadStep(const occ::handleClearFails(); + } ent->Init(aLowerBound, anUpperBound); } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTopologicalRepresentationItem.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTopologicalRepresentationItem.cxx index 654f5bf044..eeb33a34cd 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTopologicalRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTopologicalRepresentationItem.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWTopologicalRepresentationItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "topological_representation_item")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTorus.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTorus.cxx index 9e7c9aea09..0d67e9d3dd 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTorus.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTorus.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWTorus::ReadStep(const occ::handle& d // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "torus")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTransitionalShapeRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTransitionalShapeRepresentation.cxx index fddfdca0c9..526081a962 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTransitionalShapeRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTransitionalShapeRepresentation.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWTransitionalShapeRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "transitional_shape_representation")) + { return; + } // --- inherited field : name --- @@ -59,7 +61,9 @@ void RWStepShape_RWTransitionalShapeRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTypeQualifier.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTypeQualifier.cxx index 1f5003cff3..8b406c1bc5 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTypeQualifier.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWTypeQualifier.cxx @@ -26,7 +26,9 @@ void RWStepShape_RWTypeQualifier::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "type_qualifier")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWValueFormatTypeQualifier.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWValueFormatTypeQualifier.cxx index 491443dc8e..17b812bd7b 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWValueFormatTypeQualifier.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWValueFormatTypeQualifier.cxx @@ -33,7 +33,9 @@ void RWStepShape_RWValueFormatTypeQualifier::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "value_format_type_qualifier")) + { return; + } // Own fields of ValueFormatTypeQualifier diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertex.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertex.cxx index 1e4945a4f9..52cdfa7aae 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertex.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertex.cxx @@ -27,7 +27,9 @@ void RWStepShape_RWVertex::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "vertex")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexLoop.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexLoop.cxx index 2c6b3590dc..1d55574d53 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexLoop.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexLoop.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWVertexLoop::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "vertex_loop")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexPoint.cxx b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexPoint.cxx index af2cd84992..7e0917290e 100644 --- a/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexPoint.cxx +++ b/src/DataExchange/TKDESTEP/RWStepShape/RWStepShape_RWVertexPoint.cxx @@ -29,7 +29,9 @@ void RWStepShape_RWVertexPoint::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "vertex_point")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrence.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrence.cxx index 4ea4064d59..5d7a8e6c4c 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrence.cxx @@ -35,7 +35,9 @@ void RWStepVisual_RWAnnotationCurveOccurrence::ReadStep( // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "styled_item")) + { return; + } // Inherited field : name occ::handle aName; @@ -57,7 +59,9 @@ void RWStepVisual_RWAnnotationCurveOccurrence::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrenceAndGeomReprItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrenceAndGeomReprItem.cxx index cc6515cc42..cdf0880f13 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrenceAndGeomReprItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationCurveOccurrenceAndGeomReprItem.cxx @@ -56,7 +56,9 @@ void RWStepVisual_RWAnnotationCurveOccurrenceAndGeomReprItem::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anEnt)) + { aStyles->SetValue(i, anEnt); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillArea.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillArea.cxx index e13adf0415..7435835f60 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillArea.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillArea.cxx @@ -37,7 +37,9 @@ void RWStepVisual_RWAnnotationFillArea::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 2, ach, "annotation_fill_area")) + { return; + } // Inherited field : name @@ -55,7 +57,9 @@ void RWStepVisual_RWAnnotationFillArea::ReadStep( for (int i = 1; i <= nb; i++) { if (data->ReadEntity(nsub, i, "boundaries", ach, aElementsItem)) + { aElements->SetValue(i, aElementsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillAreaOccurrence.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillAreaOccurrence.cxx index 81bd17ca9f..c18de5e8e9 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillAreaOccurrence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationFillAreaOccurrence.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWAnnotationFillAreaOccurrence::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 4, ach, "annotation_fill_area_occurrence")) + { return; + } // Inherited field : name occ::handle aName; @@ -58,7 +60,9 @@ void RWStepVisual_RWAnnotationFillAreaOccurrence::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent)) + { aStyles->SetValue(i, anent); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationOccurrence.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationOccurrence.cxx index 31899cfea2..38a2133171 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationOccurrence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationOccurrence.cxx @@ -34,7 +34,9 @@ void RWStepVisual_RWAnnotationOccurrence::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "annotation_occurrence")) + { return; + } // Inherited field : name occ::handle aName; @@ -56,7 +58,9 @@ void RWStepVisual_RWAnnotationOccurrence::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationPlane.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationPlane.cxx index 6a313c3edf..c40cd970dd 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationPlane.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAnnotationPlane.cxx @@ -34,7 +34,9 @@ void RWStepVisual_RWAnnotationPlane::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 4, ach, "annotation_plane")) + { return; + } // Inherited field : name occ::handle aName; @@ -56,7 +58,9 @@ void RWStepVisual_RWAnnotationPlane::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } @@ -75,7 +79,9 @@ void RWStepVisual_RWAnnotationPlane::ReadStep( for (int i = 1; i <= nbElements; i++) { if (data->ReadEntity(nbSub, i, "content", ach, anEnt)) + { anElements->SetValue(i, anEnt); + } } } @@ -129,5 +135,7 @@ void RWStepVisual_RWAnnotationPlane::Share(const occ::handleNbElements(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ElementsValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAreaInSet.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAreaInSet.cxx index 3bb3cf3aa6..7058273ddf 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAreaInSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWAreaInSet.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWAreaInSet::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "area_in_set")) + { return; + } // --- own field : area --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWBackgroundColour.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWBackgroundColour.cxx index 7f99224f29..23bd154635 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWBackgroundColour.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWBackgroundColour.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWBackgroundColour::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "background_colour")) + { return; + } // --- own field : presentation --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraImage.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraImage.cxx index 5f24a40f81..3916d5f456 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraImage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraImage.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWCameraImage::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "camera_image")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModel.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModel.cxx index 705ec07837..37679c0b4c 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModel.cxx @@ -27,7 +27,9 @@ void RWStepVisual_RWCameraModel::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "camera_model has not 1 parameter(s)")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD2.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD2.cxx index 35d11ff14c..b79d168f84 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD2.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD2.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWCameraModelD2::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "camera_model_d2")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3.cxx index 01271be585..4a5bb12c86 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWCameraModelD3::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "camera_model_d3")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClipping.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClipping.cxx index a1bd05f665..847ffded72 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClipping.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClipping.cxx @@ -39,7 +39,9 @@ void RWStepVisual_RWCameraModelD3MultiClipping::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 4, ach, "camera_model_d3_multi_clipping")) + { return; + } // Inherited field : name occ::handle aName; @@ -77,7 +79,9 @@ void RWStepVisual_RWCameraModelD3MultiClipping::ReadStep( for (int i = 1; i <= nbElements; i++) { if (data->ReadEntity(nbSub, i, "shape_clipping", ach, anEnt)) + { aShapeClipping->SetValue(i, anEnt); + } } } @@ -122,5 +126,7 @@ void RWStepVisual_RWCameraModelD3MultiClipping::Share( // Own field: shape_clipping int i, nb = ent->ShapeClipping()->Length(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ShapeClipping()->Value(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingIntersection.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingIntersection.cxx index aab947c1cc..dd64a145f2 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingIntersection.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingIntersection.cxx @@ -38,7 +38,9 @@ void RWStepVisual_RWCameraModelD3MultiClippingIntersection::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 2, ach, "camera_model_d3_multi_clipping_intersection")) + { return; + } // Inherited field : name occ::handle aName; @@ -58,7 +60,9 @@ void RWStepVisual_RWCameraModelD3MultiClippingIntersection::ReadStep( for (int i = 1; i <= nbElements; i++) { if (data->ReadEntity(nbSub, i, "shape_clipping", ach, anEnt)) + { aShapeClipping->SetValue(i, anEnt); + } } } @@ -93,5 +97,7 @@ void RWStepVisual_RWCameraModelD3MultiClippingIntersection::Share( // Own field: shape_clipping int i, nb = ent->ShapeClipping()->Length(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ShapeClipping()->Value(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingUnion.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingUnion.cxx index 23fe2d3bab..0332e3c0d7 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingUnion.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraModelD3MultiClippingUnion.cxx @@ -38,7 +38,9 @@ void RWStepVisual_RWCameraModelD3MultiClippingUnion::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 2, ach, "camera_model_d3_multi_clipping_union")) + { return; + } // Inherited field : name occ::handle aName; @@ -56,7 +58,9 @@ void RWStepVisual_RWCameraModelD3MultiClippingUnion::ReadStep( for (int i = 1; i <= nbElements; i++) { if (data->ReadEntity(nbSub, i, "shape_clipping", ach, anEnt)) + { aShapeClipping->SetValue(i, anEnt); + } } } @@ -91,5 +95,7 @@ void RWStepVisual_RWCameraModelD3MultiClippingUnion::Share( // Own field: shape_clipping int i, nb = ent->ShapeClipping()->Length(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ShapeClipping()->Value(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraUsage.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraUsage.cxx index bd2b64ba9d..9768c352a6 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCameraUsage.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWCameraUsage::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "camera_usage")) + { return; + } // --- inherited field : mappingOrigin --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel.cxx index 6232bf5bf8..a9442c2f0e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel.cxx @@ -37,7 +37,9 @@ void RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::ReadSte int num = 0; data->NamedForComplex("REPRESENTATION", "RPRSNT", num0, num, ach); if (!data->CheckNbParams(num, 3, ach, "shape_aspect")) + { return; + } // name occ::handle aName; @@ -59,7 +61,9 @@ void RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::ReadSte ach, STANDARD_TYPE(StepRepr_RepresentationItem), anItem)) + { anItems->SetValue(i, anItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColour.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColour.cxx index 7868aa6608..231c1834e3 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColour.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColour.cxx @@ -26,7 +26,9 @@ void RWStepVisual_RWColour::ReadStep(const occ::handle& // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 0, ach, "colour")) + { return; + } //--- Initialisation of the read entity --- } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourRgb.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourRgb.cxx index 1f6a1f93c0..8cc3fc8538 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourRgb.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourRgb.cxx @@ -27,7 +27,9 @@ void RWStepVisual_RWColourRgb::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "colour_rgb")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourSpecification.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourSpecification.cxx index 2cccf5ff70..8b4016c7c1 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourSpecification.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWColourSpecification.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWColourSpecification::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "colour_specification")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeText.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeText.cxx index 9ba11ba730..198f826604 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeText.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeText.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWCompositeText::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "composite_text has not 2 parameter(s)")) + { return; + } // --- inherited field : name --- @@ -54,7 +56,9 @@ void RWStepVisual_RWCompositeText::ReadStep(const occ::handleReadEntity(nsub2, i2, "collected_text", ach, aCollectedTextItem)) + { aCollectedText->SetValue(i2, aCollectedTextItem); + } } } else diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeTextWithExtent.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeTextWithExtent.cxx index fee62ef01a..1d63bf2e2e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeTextWithExtent.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCompositeTextWithExtent.cxx @@ -34,7 +34,9 @@ void RWStepVisual_RWCompositeTextWithExtent::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "composite_text_with_extent has not 3 parameter(s)")) + { return; + } // --- inherited field : name --- @@ -56,7 +58,9 @@ void RWStepVisual_RWCompositeTextWithExtent::ReadStep( { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "collected_text", ach, aCollectedTextItem)) + { aCollectedText->SetValue(i2, aCollectedTextItem); + } } } else diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentInvisibility.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentInvisibility.cxx index c085803cfd..69e94b27e0 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentInvisibility.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentInvisibility.cxx @@ -35,7 +35,9 @@ void RWStepVisual_RWContextDependentInvisibility::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "context_dependent_invisibility")) + { return; + } // --- inherited field : invisibleItems --- @@ -50,7 +52,9 @@ void RWStepVisual_RWContextDependentInvisibility::ReadStep( { // szv#4:S4163:12Mar99 `bool stat1 =` not needed if (data->ReadEntity(nsub1, i1, "invisible_items", ach, aInvisibleItemsItem)) + { aInvisibleItems->SetValue(i1, aInvisibleItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentOverRidingStyledItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentOverRidingStyledItem.cxx index 08a713be83..eea44a5286 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentOverRidingStyledItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWContextDependentOverRidingStyledItem.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWContextDependentOverRidingStyledItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 5, ach, "context_dependent_over_riding_styled_item")) + { return; + } // --- inherited field : name --- @@ -62,7 +64,9 @@ void RWStepVisual_RWContextDependentOverRidingStyledItem::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } @@ -95,7 +99,9 @@ void RWStepVisual_RWContextDependentOverRidingStyledItem::ReadStep( { // szv#4:S4163:12Mar99 `bool stat5 =` not needed if (data->ReadEntity(nsub5, i5, "style_context", ach, aStyleContextItem)) + { aStyleContext->SetValue(i5, aStyleContextItem); + } } } else diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCoordinatesList.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCoordinatesList.cxx index cbed007b96..7b029bf348 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCoordinatesList.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCoordinatesList.cxx @@ -37,7 +37,9 @@ void RWStepVisual_RWCoordinatesList::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "coordinate list")) + { return; + } // Inherited field : name occ::handle aName; @@ -51,7 +53,9 @@ void RWStepVisual_RWCoordinatesList::ReadStep( { int nb2 = data->NbParams(nsub2); if (!nb2) + { return; + } aPoints = new NCollection_HArray1(1, nb2); for (int i = 1; i <= nb2; i++) { diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyle.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyle.cxx index 3e987ebc2d..8031c2511a 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyle.cxx @@ -34,7 +34,9 @@ void RWStepVisual_RWCurveStyle::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "curve_style")) + { return; + } // --- own field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFont.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFont.cxx index ead5aaf6f2..85a745c13d 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFont.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFont.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWCurveStyleFont::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "curve_style_font")) + { return; + } // --- own field : name --- @@ -59,7 +61,9 @@ void RWStepVisual_RWCurveStyleFont::ReadStep( ach, STANDARD_TYPE(StepVisual_CurveStyleFontPattern), anent2)) + { aPatternList->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFontPattern.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFontPattern.cxx index adb2a5e269..d00604be73 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFontPattern.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWCurveStyleFontPattern.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWCurveStyleFontPattern::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "curve_style_font_pattern")) + { return; + } // --- own field : visibleSegmentLength --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingCallout.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingCallout.cxx index 97c8d10695..017af1fe2f 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingCallout.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingCallout.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWDraughtingCallout::ReadStep( const occ::handle& ent) const { if (!data->CheckNbParams(num, 2, ach, "draughting_callout")) + { return; + } // Inherited field : name occ::handle aName; @@ -50,7 +52,9 @@ void RWStepVisual_RWDraughtingCallout::ReadStep( for (int i = 1; i <= nbElements; i++) { if (data->ReadEntity(nbSub, i, "content", ach, anEnt)) + { aContents->SetValue(i, anEnt); + } } } @@ -84,5 +88,7 @@ void RWStepVisual_RWDraughtingCallout::Share(const occ::handleNbContents(); for (i = 1; i <= nb; i++) + { iter.AddItem(ent->ContentsValue(i).Value()); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx index cf439e7aa4..f2dbfab567 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx @@ -37,7 +37,9 @@ void RWStepVisual_RWDraughtingModel::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "draughting_model")) + { return; + } // Inherited fields of Representation diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedColour.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedColour.cxx index 5939987d84..29f72f3d2f 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedColour.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedColour.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWDraughtingPreDefinedColour::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "draughting_pre_defined_colour has not 1 parameter(s)")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedCurveFont.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedCurveFont.cxx index ffd422608c..0c18a6ff1d 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedCurveFont.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWDraughtingPreDefinedCurveFont.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWDraughtingPreDefinedCurveFont::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "draughting_pre_defined_curve_font has not 1 parameter(s)")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWExternallyDefinedCurveFont.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWExternallyDefinedCurveFont.cxx index 12570acf7d..42c077bfd4 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWExternallyDefinedCurveFont.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWExternallyDefinedCurveFont.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWExternallyDefinedCurveFont::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "externally_defined_curve_font")) + { return; + } // Inherited fields of ExternallyDefinedItem diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyle.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyle.cxx index 404adb8616..5bf85fe073 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyle.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWFillAreaStyle::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "fill_area_style")) + { return; + } // --- own field : name --- @@ -53,7 +55,9 @@ void RWStepVisual_RWFillAreaStyle::ReadStep(const occ::handleReadEntity(nsub2, i2, "fill_styles", ach, aFillStylesItem)) + { aFillStyles->SetValue(i2, aFillStylesItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyleColour.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyleColour.cxx index dec21611c2..8699bca8ff 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyleColour.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWFillAreaStyleColour.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWFillAreaStyleColour::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "fill_area_style_colour")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWInvisibility.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWInvisibility.cxx index 61ee48fe47..091dbb120d 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWInvisibility.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWInvisibility.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWInvisibility::ReadStep(const occ::handleCheckNbParams(num, 1, ach, "invisibility")) + { return; + } // --- own field : invisibleItems --- @@ -45,7 +47,9 @@ void RWStepVisual_RWInvisibility::ReadStep(const occ::handleReadEntity(nsub1, i1, "invisible_items", ach, aInvisibleItemsItem)) + { aInvisibleItems->SetValue(i1, aInvisibleItemsItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationArea.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationArea.cxx index d2d1fa2af1..4efa244c41 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationArea.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationArea.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWMechanicalDesignGeometricPresentationArea::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "mechanical_design_geometric_presentation_area")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepVisual_RWMechanicalDesignGeometricPresentationArea::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation.cxx index 353a415030..6ef3ea944b 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation::ReadSte // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "mechanical_design_geometric_presentation_representation")) + { return; + } // --- inherited field : name --- @@ -49,7 +51,9 @@ void RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation::ReadSte { int nb2 = data->NbParams(nsub2); if (nb2 > 0) + { aItems = new NCollection_HArray1>(1, nb2); + } for (int i2 = 1; i2 <= nb2; i2++) { // szv#4:S4163:12Mar99 `bool stat2 =` not needed @@ -59,7 +63,9 @@ void RWStepVisual_RWMechanicalDesignGeometricPresentationRepresentation::ReadSte ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWOverRidingStyledItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWOverRidingStyledItem.cxx index 6cbf9b018a..a7e8ef2a8e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWOverRidingStyledItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWOverRidingStyledItem.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWOverRidingStyledItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 4, ach, "over_riding_styled_item")) + { return; + } // --- inherited field : name --- @@ -58,7 +60,9 @@ void RWStepVisual_RWOverRidingStyledItem::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarBox.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarBox.cxx index fb4b6f27c7..7e115f7847 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarBox.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarBox.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWPlanarBox::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "planar_box")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarExtent.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarExtent.cxx index 851b19a2dd..532fea078e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarExtent.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPlanarExtent.cxx @@ -27,7 +27,9 @@ void RWStepVisual_RWPlanarExtent::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "planar_extent")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPointStyle.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPointStyle.cxx index 85fdbf0812..fadcbca82d 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPointStyle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPointStyle.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWPointStyle::ReadStep(const occ::handleCheckNbParams(num, 4, ach, "point_style")) + { return; + } // --- own field : name --- @@ -84,6 +86,8 @@ void RWStepVisual_RWPointStyle::Share(const occ::handle& { if (ent->Marker().CaseNumber() > 0) + { iter.GetOneItem(ent->Marker().Value()); + } iter.GetOneItem(ent->MarkerColour()); } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedColour.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedColour.cxx index 311037ff73..4f55774a47 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedColour.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedColour.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWPreDefinedColour::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "pre_defined_colour")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedCurveFont.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedCurveFont.cxx index 62333c0ea6..4b9f561964 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedCurveFont.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedCurveFont.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWPreDefinedCurveFont::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "pre_defined_curve_font")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedItem.cxx index 2ea7f58ed7..dbd78ef339 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPreDefinedItem.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWPreDefinedItem::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "pre_defined_item")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationArea.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationArea.cxx index f8e23fc4ac..f82d84639e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationArea.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationArea.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWPresentationArea::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "presentation_area")) + { return; + } // --- inherited field : name --- @@ -57,7 +59,9 @@ void RWStepVisual_RWPresentationArea::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx index da27d19034..094aeffd5a 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWPresentationLayerAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "presentation_layer_assignment")) + { return; + } // --- own field : name --- @@ -59,7 +61,9 @@ void RWStepVisual_RWPresentationLayerAssignment::ReadStep( { // szv#4:S4163:12Mar99 `bool stat3 =` not needed if (data->ReadEntity(nsub3, i3, "assigned_items", ach, aAssignedItemsItem)) + { aAssignedItems->SetValue(i3, aAssignedItemsItem); + } } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerUsage.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerUsage.cxx index 964ac38f3a..f2486d44d9 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationLayerUsage.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWPresentationLayerUsage::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "presentation_layer_usage")) + { return; + } // --- own fields occ::handle pla; diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationRepresentation.cxx index da4d14c7bb..adc3a9c958 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationRepresentation.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWPresentationRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "presentation_representation")) + { return; + } // --- inherited field : name --- @@ -57,7 +59,9 @@ void RWStepVisual_RWPresentationRepresentation::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSet.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSet.cxx index 365705a8ed..91f89a1f77 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSet.cxx @@ -28,7 +28,9 @@ void RWStepVisual_RWPresentationSet::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 0, ach, "presentation_set")) + { return; + } //--- Initialisation of the read entity --- } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSize.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSize.cxx index 831885d8e1..1363698d34 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSize.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationSize.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWPresentationSize::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "presentation_size")) + { return; + } // --- own field : unit --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx index 23ce6f7576..bd13800b4e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleAssignment.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWPresentationStyleAssignment::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "presentation_style_assignment")) + { return; + } // --- own field : styles --- @@ -89,7 +91,9 @@ void RWStepVisual_RWPresentationStyleAssignment::WriteStep( SW.CloseSub(); } else + { SW.Send(aStyle.Value()); + } } SW.CloseSub(); } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx index 9f2c07f82c..96a4b3f363 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationStyleByContext.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWPresentationStyleByContext::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "presentation_style_by_context")) + { return; + } // --- inherited field : styles --- @@ -93,7 +95,9 @@ void RWStepVisual_RWPresentationStyleByContext::WriteStep( SW.CloseSub(); } else + { SW.Send(aStyle.Value()); + } } SW.CloseSub(); diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationView.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationView.cxx index 0c2899cc3e..fe20004289 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationView.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentationView.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWPresentationView::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "presentation_view has not 3 parameter(s)")) + { return; + } // --- inherited field : name --- @@ -57,7 +59,9 @@ void RWStepVisual_RWPresentationView::ReadStep( ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2)) + { aItems->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentedItemRepresentation.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentedItemRepresentation.cxx index 92ebd789e1..603f1fa3f5 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentedItemRepresentation.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWPresentedItemRepresentation.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWPresentedItemRepresentation::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "presented_item_representation")) + { return; + } // --- own fields diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedGeometricSet.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedGeometricSet.cxx index 325f8a682d..0a2d7c6ec9 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedGeometricSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedGeometricSet.cxx @@ -35,14 +35,18 @@ void RWStepVisual_RWRepositionedTessellatedGeometricSet::ReadStep( int aNum = 0; theData->NamedForComplex("REPOSITIONED_TESSELLATED_ITEM", theNum, aNum, theAch); if (!theData->CheckNbParams(aNum, 1, theAch, "location")) + { return; + } occ::handle aLocation; theData ->ReadEntity(aNum, 1, "location", theAch, STANDARD_TYPE(StepGeom_Axis2Placement3d), aLocation); theData->NamedForComplex("REPRESENTATION_ITEM", theNum, aNum, theAch); if (!theData->CheckNbParams(aNum, 1, theAch, "name")) + { return; + } occ::handle aName; theData->ReadString(aNum, 1, "name", theAch, aName); @@ -62,7 +66,9 @@ void RWStepVisual_RWRepositionedTessellatedGeometricSet::ReadStep( theAch, STANDARD_TYPE(StepVisual_TessellatedItem), anItem)) + { anItems->SetValue(i2, anItem); + } } } theEnt->Init(aName, anItems, aLocation); @@ -100,6 +106,8 @@ void RWStepVisual_RWRepositionedTessellatedGeometricSet::Share( { // Own field : children for (int i = 1; i <= theEnt->Items()->Length(); i++) + { theIter.AddItem(theEnt->Items()->Value(i)); + } theIter.AddItem(theEnt->Location()); } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedItem.cxx index b05a8d846d..ef4afa7b64 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedItem.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWRepositionedTessellatedItem::ReadStep( { // --- Number of Parameter Control --- if (!theData->CheckNbParams(theNum, 2, theAch, "tessellated_item")) + { return; + } // --- inherited field : name --- occ::handle aName; diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWStyledItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWStyledItem.cxx index 1dc7246b76..e098f6df40 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWStyledItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWStyledItem.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWStyledItem::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "styled_item")) + { return; + } // --- inherited field : name --- @@ -55,7 +57,9 @@ void RWStepVisual_RWStyledItem::ReadStep(const occ::handleSetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceSideStyle.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceSideStyle.cxx index 605d479b75..83cf9fc6b7 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceSideStyle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceSideStyle.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWSurfaceSideStyle::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "surface_side_style")) + { return; + } // --- own field : name --- @@ -52,7 +54,9 @@ void RWStepVisual_RWSurfaceSideStyle::ReadStep( { // szv#4:S4163:12Mar99 `bool stat2 =` not needed if (data->ReadEntity(nsub2, i2, "styles", ach, aStylesItem)) + { aStyles->SetValue(i2, aStylesItem); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleBoundary.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleBoundary.cxx index 3853b040a8..db96d709c4 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleBoundary.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleBoundary.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWSurfaceStyleBoundary::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface_style_boundary")) + { return; + } // --- own field : styleOfBoundary --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleControlGrid.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleControlGrid.cxx index f2b8d83b83..71c28cd35b 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleControlGrid.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleControlGrid.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWSurfaceStyleControlGrid::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface_style_control_grid")) + { return; + } // --- own field : styleOfControlGrid --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleFillArea.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleFillArea.cxx index af32e35ab3..651bc86151 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleFillArea.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleFillArea.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWSurfaceStyleFillArea::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface_style_fill_area")) + { return; + } // --- own field : fillArea --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleParameterLine.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleParameterLine.cxx index 8ee64fdc17..679f5d69a3 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleParameterLine.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleParameterLine.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWSurfaceStyleParameterLine::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "surface_style_parameter_line")) + { return; + } // --- own field : styleOfParameterLines --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbient.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbient.cxx index 36c16588f6..51c9ae03e0 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbient.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbient.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWSurfaceStyleReflectanceAmbient::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "surface_style_reflectance_ambient")) + { return; + } // Own fields of SurfaceStyleReflectanceAmbient diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuse.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuse.cxx index 8198bdd623..97c533ad0c 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuse.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuse.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuse::ReadStep( { // Check number of parameters if (!theData->CheckNbParams(theNum, 2, theAch, "surface_style_reflectance_ambient_diffuse")) + { return; + } // Inherited fields of SurfaceStyleReflectanceAmbient double aAmbientReflectance; diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuseSpecular.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuseSpecular.cxx index 967397d02a..59f3d6c5bf 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuseSpecular.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuseSpecular.cxx @@ -37,7 +37,9 @@ void RWStepVisual_RWSurfaceStyleReflectanceAmbientDiffuseSpecular::ReadStep( 5, theAch, "surface_style_reflectance_ambient_diffuse_specular")) + { return; + } // Inherited fields of SurfaceStyleReflectanceAmbient double aAmbientReflectance; diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx index 583245e7a6..e4489aff11 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWSurfaceStyleRendering::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 2, ach, "surface_style_rendering")) + { return; + } // Own fields of SurfaceStyleRendering @@ -45,18 +47,30 @@ void RWStepVisual_RWSurfaceStyleRendering::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".CONSTANT_SHADING.")) + { aRenderingMethod = StepVisual_ssmConstantShading; + } else if (strcmp(text, ".COLOUR_SHADING.")) + { aRenderingMethod = StepVisual_ssmColourShading; + } else if (strcmp(text, ".DOT_SHADING.")) + { aRenderingMethod = StepVisual_ssmDotShading; + } else if (strcmp(text, ".NORMAL_SHADING.")) + { aRenderingMethod = StepVisual_ssmNormalShading; + } else + { ach->AddFail("Parameter #1 (rendering_method) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (rendering_method) is not enumeration"); + } occ::handle aSurfaceColour; data->ReadEntity(num, 2, "surface_colour", ach, STANDARD_TYPE(StepVisual_Colour), aSurfaceColour); diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRenderingWithProperties.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRenderingWithProperties.cxx index 07a4eeb5ad..9da13a1695 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRenderingWithProperties.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleRenderingWithProperties.cxx @@ -40,7 +40,9 @@ void RWStepVisual_RWSurfaceStyleRenderingWithProperties::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 3, ach, "surface_style_rendering_with_properties")) + { return; + } // Inherited fields of SurfaceStyleRendering @@ -50,18 +52,30 @@ void RWStepVisual_RWSurfaceStyleRenderingWithProperties::ReadStep( { const char* text = data->ParamCValue(num, 1); if (strcmp(text, ".CONSTANT_SHADING.")) + { aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmConstantShading; + } else if (strcmp(text, ".COLOUR_SHADING.")) + { aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmColourShading; + } else if (strcmp(text, ".DOT_SHADING.")) + { aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmDotShading; + } else if (strcmp(text, ".NORMAL_SHADING.")) + { aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmNormalShading; + } else + { ach->AddFail("Parameter #1 (surface_style_rendering.rendering_method) has not allowed value"); + } } else + { ach->AddFail("Parameter #1 (surface_style_rendering.rendering_method) is not enumeration"); + } occ::handle aSurfaceStyleRendering_SurfaceColour; data->ReadEntity(num, diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSegmentationCurve.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSegmentationCurve.cxx index a39dd23fd8..eb7aedaf86 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSegmentationCurve.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSegmentationCurve.cxx @@ -31,7 +31,9 @@ void RWStepVisual_RWSurfaceStyleSegmentationCurve::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface_style_segmentation_curve")) + { return; + } // --- own field : styleOfSegmentationCurve --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSilhouette.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSilhouette.cxx index 5f4a17d91c..132ef386d8 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSilhouette.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleSilhouette.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWSurfaceStyleSilhouette::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "surface_style_silhouette")) + { return; + } // --- own field : styleOfSilhouette --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx index 1b3fb641a4..e96449fbf1 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx @@ -35,7 +35,9 @@ void RWStepVisual_RWSurfaceStyleTransparent::ReadStep( { // Check number of parameters if (!data->CheckNbParams(num, 1, ach, "surface_style_transparent")) + { return; + } // Own fields of SurfaceStyleTransparent diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleUsage.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleUsage.cxx index ec77492290..24ce563650 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleUsage.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWSurfaceStyleUsage.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWSurfaceStyleUsage::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 2, ach, "surface_style_usage")) + { return; + } // --- own field : side --- @@ -47,7 +49,9 @@ void RWStepVisual_RWSurfaceStyleUsage::ReadStep( } } else + { ach->AddFail("Parameter #1 (side) is not an enumeration"); + } // --- own field : style --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplate.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplate.cxx index b11d2308f7..0fa509ac8b 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplate.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplate.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWTemplate::ReadStep(const occ::handleCheckNbParams(num, 3, ach, "template")) + { return; + } // --- inherited field : name --- @@ -56,7 +58,9 @@ void RWStepVisual_RWTemplate::ReadStep(const occ::handleSetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplateInstance.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplateInstance.cxx index 5c4c3167d3..e2d5667c88 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplateInstance.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTemplateInstance.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWTemplateInstance::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 3, ach, "template_instance")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedAnnotationOccurrence.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedAnnotationOccurrence.cxx index e85e70e3c2..f8aaf8ea5e 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedAnnotationOccurrence.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedAnnotationOccurrence.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWTessellatedAnnotationOccurrence::ReadStep( // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "styled_item")) + { return; + } // Inherited field : name occ::handle aName; @@ -58,7 +60,9 @@ void RWStepVisual_RWTessellatedAnnotationOccurrence::ReadStep( ach, STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) + { aStyles->SetValue(i2, anent2); + } } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx index 70e3641293..36f8e766a5 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedCurveSet.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWTessellatedCurveSet::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 3, ach, "tessellated_curve_set")) + { return; + } // Inherited field : name occ::handle aName; @@ -53,7 +55,9 @@ void RWStepVisual_RWTessellatedCurveSet::ReadStep( { int nb2 = data->NbParams(nsub2); if (!nb2) + { return; + } for (int i = 1; i <= nb2; i++) { @@ -66,7 +70,9 @@ void RWStepVisual_RWTessellatedCurveSet::ReadStep( { int aVal = 0; if (data->ReadInteger(nsub3, j, "coordinates", ach, aVal)) + { aCurve->Append(aVal); + } } aCurves->Append(aCurve); } @@ -94,7 +100,9 @@ void RWStepVisual_RWTessellatedCurveSet::WriteStep( occ::handle> aCurve = ent->Curves()->Value(curveIt); SW.OpenSub(); for (int i = 1; i <= aCurve->Length(); i++) + { SW.Send(aCurve->Value(i)); + } SW.CloseSub(); } SW.CloseSub(); diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx index cdf616d9f4..c7569f18df 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedGeometricSet.cxx @@ -35,7 +35,9 @@ void RWStepVisual_RWTessellatedGeometricSet::ReadStep( { // Number of Parameter Control if (!data->CheckNbParams(num, 2, ach, "tessellated_geometric_set")) + { return; + } // Inherited field : name occ::handle aName; @@ -52,7 +54,9 @@ void RWStepVisual_RWTessellatedGeometricSet::ReadStep( occ::handle anItem; // = new StepVisual_TesselatedItem; if (data ->ReadEntity(nsub2, i2, "item", ach, STANDARD_TYPE(StepVisual_TessellatedItem), anItem)) + { anItems->SetValue(i2, anItem); + } } } @@ -73,7 +77,9 @@ void RWStepVisual_RWTessellatedGeometricSet::WriteStep( // Own field : children SW.OpenSub(); for (int i = 1; i <= ent->Items()->Length(); i++) + { SW.Send(ent->Items()->Value(i)); + } SW.CloseSub(); } @@ -85,5 +91,7 @@ void RWStepVisual_RWTessellatedGeometricSet::Share( { // Own field : children for (int i = 1; i <= ent->Items()->Length(); i++) + { iter.AddItem(ent->Items()->Value(i)); + } } diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedItem.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedItem.cxx index 05d95dc846..81e0c5ae90 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedItem.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTessellatedItem.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWTessellatedItem::ReadStep( { // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "tessellated_item")) + { return; + } // --- inherited field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextLiteral.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextLiteral.cxx index ad6e43b553..dea90534a4 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextLiteral.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextLiteral.cxx @@ -32,7 +32,9 @@ void RWStepVisual_RWTextLiteral::ReadStep(const occ::handleCheckNbParams(num, 6, ach, "text_literal has not 6 parameter(s)")) + { return; + } // --- inherited field : name --- @@ -70,7 +72,9 @@ void RWStepVisual_RWTextLiteral::ReadStep(const occ::handleAddFail("Parameter #5 (path) is not an enumeration"); + } // --- own field : font --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyle.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyle.cxx index 6966a41b1d..2f7b167100 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyle.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyle.cxx @@ -29,7 +29,9 @@ void RWStepVisual_RWTextStyle::ReadStep(const occ::handleCheckNbParams(num, 2, ach, "text_style has not 2 parameter(s)")) + { return; + } // --- own field : name --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleForDefinedFont.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleForDefinedFont.cxx index 42233fbfa8..4e14dd4670 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleForDefinedFont.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleForDefinedFont.cxx @@ -30,7 +30,9 @@ void RWStepVisual_RWTextStyleForDefinedFont::ReadStep( // --- Number of Parameter Control --- if (!data->CheckNbParams(num, 1, ach, "text_style_for_defined_font has not 1 parameter(s)")) + { return; + } // --- own field : textColour --- diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleWithBoxCharacteristics.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleWithBoxCharacteristics.cxx index 347d60125e..a8bab19db9 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleWithBoxCharacteristics.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWTextStyleWithBoxCharacteristics.cxx @@ -36,7 +36,9 @@ void RWStepVisual_RWTextStyleWithBoxCharacteristics::ReadStep( 3, ach, "text_style_with_box_characteristics has not 3 parameter(s)")) + { return; + } // --- inherited field : name --- @@ -85,13 +87,21 @@ void RWStepVisual_RWTextStyleWithBoxCharacteristics::ReadStep( { aBoxCharacteristicSelect.SetRealValue(aCharacteristicsItem); if (TrueType == TypeHeigth) + { aBoxCharacteristicSelect.SetTypeOfContent(1); + } else if (TrueType == TypeWidth) + { aBoxCharacteristicSelect.SetTypeOfContent(2); + } else if (TrueType == TypeSlant) + { aBoxCharacteristicSelect.SetTypeOfContent(3); + } else if (TrueType == TypeRotate) + { aBoxCharacteristicSelect.SetTypeOfContent(4); + } else { ach->AddFail("Parameter #3 (characteristics) item has illegal TYPE"); diff --git a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWViewVolume.cxx b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWViewVolume.cxx index 4eeb05375b..c85dc200ce 100644 --- a/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWViewVolume.cxx +++ b/src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWViewVolume.cxx @@ -33,7 +33,9 @@ void RWStepVisual_RWViewVolume::ReadStep(const occ::handleCheckNbParams(num, 9, ach, "view_volume")) + { return; + } // --- own field : projectionType --- @@ -47,7 +49,9 @@ void RWStepVisual_RWViewVolume::ReadStep(const occ::handleAddFail("Parameter #1 (projection_type) is not an enumeration"); + } // --- own field : projectionPoint --- diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_ActorWrite.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_ActorWrite.cxx index d2c429a7bd..b42b00a8d2 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_ActorWrite.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_ActorWrite.cxx @@ -31,7 +31,9 @@ void STEPCAFControl_ActorWrite::SetStdMode(const bool stdmode) { myStdMode = stdmode; if (myStdMode) + { ClearMap(); + } } //================================================================================================= @@ -46,7 +48,9 @@ void STEPCAFControl_ActorWrite::ClearMap() void STEPCAFControl_ActorWrite::RegisterAssembly(const TopoDS_Shape& S) { if (!myStdMode && S.ShapeType() == TopAbs_COMPOUND) + { myMap.Add(S); + } } //================================================================================================= @@ -55,6 +59,8 @@ bool STEPCAFControl_ActorWrite::IsAssembly(const occ::handle TopoDS_Shape& S) const { if (myStdMode) + { return STEPControl_ActorWrite::IsAssembly(theModel, S); + } return myMap.Contains(S); } diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Controller.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Controller.cxx index b7d481846d..eb40cd4e5c 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Controller.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Controller.cxx @@ -40,7 +40,9 @@ bool STEPCAFControl_Controller::Init() { static bool inic = false; if (inic) + { return true; + } inic = true; } // self-registering diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_GDTProperty.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_GDTProperty.cxx index e73cbec44e..36e6898a48 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_GDTProperty.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_GDTProperty.cxx @@ -315,7 +315,9 @@ void STEPCAFControl_GDTProperty::GetDimModifiers( occ::handle aDRI = occ::down_cast(theCRI->ItemElement()->Value(l)); if (aDRI.IsNull()) + { continue; + } XCAFDimTolObjects_DimensionModif aModifier = XCAFDimTolObjects_DimensionModif_ControlledRadius; const TCollection_AsciiString aModifStr = aDRI->Description()->String(); bool aFound = false; @@ -435,7 +437,9 @@ void STEPCAFControl_GDTProperty::GetDimModifiers( aModifier = XCAFDimTolObjects_DimensionModif_FreeStateCondition; } if (aFound) + { theModifiers.Append(aModifier); + } } } @@ -458,7 +462,9 @@ void STEPCAFControl_GDTProperty::GetDimClassOfTolerance( aFound = false; bool aCaseSens = false; if (c == 1) + { aCaseSens = true; + } occ::handle aStr = new TCollection_HAsciiString("a"); if (aFormV->IsSameString(aStr, aCaseSens)) { @@ -657,7 +663,9 @@ void STEPCAFControl_GDTProperty::GetDimClassOfTolerance( } if (c == 1 && !aFound) + { theHolle = true; + } } occ::handle aStr = new TCollection_HAsciiString("01"); theG = XCAFDimTolObjects_DimensionGrade_IT01; @@ -1074,9 +1082,13 @@ occ::handle STEPCAFControl_GDTProperty::GetLimitsAndFit occ::handle aGradeStr, aFormStr, aHoleStr; if (theGrade == XCAFDimTolObjects_DimensionGrade_IT01) + { aGradeStr = new TCollection_HAsciiString("01"); + } else + { aGradeStr = new TCollection_HAsciiString((int)theGrade + 1); + } switch (theFormVariance) { @@ -1375,10 +1387,14 @@ occ::handle> STEPCAFContr { if ((theModifiers.Length() == 0) && (theModifWithVal == XCAFDimTolObjects_DatumModifWithValue_None)) + { return nullptr; + } int aModifNb = theModifiers.Length(); if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) + { aModifNb++; + } occ::handle> aModifiers = new NCollection_HArray1(1, aModifNb); diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx index fa235db129..1262ea954f 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -458,7 +458,9 @@ bool STEPCAFControl_Reader::ExternFile(const char* const n { ef.Nullify(); if (myFiles.IsEmpty() || !myFiles.IsBound(name)) + { return false; + } ef = myFiles.Find(name); return true; } @@ -490,9 +492,13 @@ static void FillShapesMap(const TopoDS_Shape& S0.Location(loc); map.Add(S0); if (S.ShapeType() != TopAbs_COMPOUND) + { return; + } for (TopoDS_Iterator it(S); it.More(); it.Next()) + { FillShapesMap(it.Value(), map); + } } //================================================================================================= @@ -533,34 +539,46 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader // Read all shapes int num = reader.NbRootsForTransfer(); if (num <= 0) + { return false; + } Message_ProgressScope aPSRoot(theProgress, nullptr, 2); if (nroot) { if (nroot > num) + { return false; + } reader.TransferOneRoot(nroot, aPSRoot.Next()); } else { Message_ProgressScope aPS(aPSRoot.Next(), nullptr, num); for (i = 1; i <= num && aPS.More(); i++) + { reader.TransferOneRoot(i, aPS.Next()); + } } if (aPSRoot.UserBreak()) + { return false; + } num = reader.NbShapes(); if (num <= 0) + { return false; + } // Fill a map of (top-level) shapes resulting from that transfer // Only these shapes will be considered further NCollection_Map ShapesMap, NewShapesMap; for (i = 1; i <= num; i++) + { FillShapesMap(reader.Shape(i), ShapesMap); + } // Collect information on shapes originating from SDRs // this will be used to distinguish compounds representing assemblies @@ -613,7 +631,9 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader occ::handle binder = TP->MapItem(index); TopoDS_Shape S = TransferBRep::ShapeResult(binder); if (!S.IsNull() && ShapesMap.Contains(S)) + { NewShapesMap.Add(S); + } } } } @@ -679,7 +699,9 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader // compute true path to the extern file TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, filename); if (fullname.Length() <= 0) + { fullname = filename; + } // check for not the same file TCollection_AsciiString aMainFullName = OSD_Path::AbsolutePath(dpath, aMainName); @@ -703,9 +725,13 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader // get and check PD associated with the current extern ref occ::handle PD = ExtRefs.ProdDef(i); if (PD.IsNull()) + { continue; // not a valid extern ref + } if (!PDFileMap.IsBound(PD)) + { continue; // this PD is not concerned by current transfer + } // read extern file (or use existing data) and record its data occ::handle EF = @@ -716,9 +742,13 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader // and insert them to the document occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(doc->Main()); if (STool.IsNull()) + { return false; + } if (asOne) + { Lseq.Append(AddShape(reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap)); + } else { for (i = 1; i <= num; i++) @@ -729,35 +759,51 @@ bool STEPCAFControl_Reader::Transfer(STEPControl_Reader& reader // read colors if (GetColorMode()) + { ReadColors(reader.WS(), doc, aLocalFactors); + } // read names if (GetNameMode()) + { ReadNames(reader.WS(), doc, PDFileMap); + } // read validation props if (GetPropsMode()) + { ReadValProps(reader.WS(), doc, PDFileMap, aLocalFactors); + } // read layers if (GetLayerMode()) + { ReadLayers(reader.WS(), doc); + } // read SHUO entities from STEP model if (GetSHUOMode()) + { ReadSHUOs(reader.WS(), doc, PDFileMap); + } // read GDT entities from STEP model if (GetGDTMode()) + { ReadGDTs(reader.WS(), doc, aLocalFactors); + } // read Material entities from STEP model if (GetMatMode()) + { ReadMaterials(reader.WS(), doc, SeqPDS, aLocalFactors); + } // read View entities from STEP model if (GetViewMode()) + { ReadViews(reader.WS(), doc, aLocalFactors); + } // read metadata if (GetMetaMode()) @@ -828,7 +874,9 @@ TDF_Label STEPCAFControl_Reader::AddShape( TopLoc_Location loc; Sub0.Location(loc); if (NewShapesMap.Contains(Sub0)) + { isAssembly = true; + } } // if(nbComponents>0) isAssembly = true; @@ -871,7 +919,9 @@ TDF_Label STEPCAFControl_Reader::AddShape( { TDF_Label L = STool->AddShape(S, false); if (SHAS.Length() > 0) + { STool->SetExternRefs(L, SHAS); + } myMap.Bind(S, L); return L; } @@ -895,7 +945,9 @@ TDF_Label STEPCAFControl_Reader::AddShape( } } if (SHAS.Length() > 0) + { STool->SetExternRefs(L, SHAS); + } myMap.Bind(S, L); // STool->SetShape ( L, S ); // it is necessary for assemblies OCC1747 // commemted by skl for // OCC2941 @@ -940,7 +992,9 @@ occ::handle STEPCAFControl_Reader::ReadExternFile( NCollection_Sequence labels; EF->SetTransferStatus(Transfer(sr, 0, doc, labels, false, theProgress)); if (labels.Length() > 0) + { EF->SetLabel(labels.Value(1)); + } } // add read file to dictionary @@ -960,12 +1014,16 @@ static void findStyledSR(const occ::handle& style, occ::handle PSA = occ::down_cast(style->StylesValue(j)); if (PSA.IsNull()) + { continue; + } StepVisual_StyleContextSelect aStyleCntxSlct = PSA->StyleContext(); occ::handle aCurrentSR = occ::down_cast(aStyleCntxSlct.Representation()); if (aCurrentSR.IsNull()) + { continue; + } aSR = aCurrentSR; break; } @@ -983,9 +1041,13 @@ static void propagateColorToParts(const occ::handle& theSTool // collect components to propagate NCollection_Sequence aComponents; if (theRoot.IsEqual(theSTool->Label())) + { theSTool->GetFreeShapes(aComponents); + } else + { theSTool->GetComponents(theRoot, aComponents); + } // iterate each component for (NCollection_Sequence::Iterator anIt(aComponents); anIt.More(); anIt.Next()) @@ -1000,14 +1062,20 @@ static void propagateColorToParts(const occ::handle& theSTool { if (theCTool->GetColor(theRoot, (XCAFDoc_ColorType)aType, aColorL) && !theCTool->GetColor(anOriginalL, (XCAFDoc_ColorType)aType, aDummyColorL)) + { theCTool->SetColor(anOriginalL, aColorL, (XCAFDoc_ColorType)aType); + } } if (!theCTool->IsVisible(theRoot)) + { theCTool->SetVisibility(anOriginalL, false); + } // propagate to next level children if (theSTool->IsAssembly(anOriginalL)) + { propagateColorToParts(theSTool, theCTool, anOriginalL); + } } } @@ -1024,14 +1092,18 @@ static void SetAssemblyComponentStyle( const StepData_Factors& theLocalFactors) { if (theStyle.IsNull()) + { return; + } occ::handle aSurfCol, aBoundCol, aCurveCol; STEPConstruct_RenderingProperties aRenderProps; // check if it is component style bool anIsComponent = false; if (!theStyles.GetColors(theStyle, aSurfCol, aBoundCol, aCurveCol, aRenderProps, anIsComponent)) + { return; + } const Interface_Graph& aGraph = theTP->Graph(); TopLoc_Location aLoc; // init; @@ -1041,7 +1113,9 @@ static void SetAssemblyComponentStyle( occ::handle aRepr = occ::down_cast(theStyle->ItemAP242().Value()); if (aRepr.IsNull()) + { return; + } occ::handle aSRR; Interface_EntityIterator aSubs = theTP->Graph().Sharings(aRepr); for (aSubs.Start(); aSubs.More(); aSubs.Next()) @@ -1061,7 +1135,9 @@ static void SetAssemblyComponentStyle( aShape = TransferBRep::ShapeResult(aBinder); } if (aShape.IsNull()) + { return; + } // get transformation aSubs = aGraph.Shareds(theStyle); @@ -1071,7 +1147,9 @@ static void SetAssemblyComponentStyle( occ::handle aRelation = occ::down_cast(aSubs.Value()); if (aRelation.IsNull()) + { continue; + } auto aTransf = aRelation->TransformationOperator(); if (auto anItemTransf = aTransf.ItemDefinedTransformation()) @@ -1110,20 +1188,30 @@ static void SetAssemblyComponentStyle( aFullSCol = Quantity_ColorRGBA(aSCol); } if (!aBoundCol.IsNull()) + { STEPConstruct_Styles::DecodeColor(aBoundCol, aBCol); + } if (!aCurveCol.IsNull()) + { STEPConstruct_Styles::DecodeColor(aCurveCol, aCCol); + } if (aRenderProps.IsDefined()) { aFullSCol = aRenderProps.GetRGBAColor(); } if (!aSurfCol.IsNull() || aRenderProps.IsDefined()) + { theCTool->SetInstanceColor(aShape, XCAFDoc_ColorSurf, aFullSCol); + } if (!aBoundCol.IsNull()) + { theCTool->SetInstanceColor(aShape, XCAFDoc_ColorCurv, aBCol); + } if (!aCurveCol.IsNull()) + { theCTool->SetInstanceColor(aShape, XCAFDoc_ColorCurv, aCCol); + } } } @@ -1143,7 +1231,9 @@ static void SetStyle( const StepData_Factors& theLocalFactors) { if (theStyle.IsNull()) + { return; + } const occ::handle& aTP = theWS->TransferReader()->TransientProcess(); if (occ::handle anOverridingStyle = @@ -1174,7 +1264,9 @@ static void SetStyle( for (int si = 1; si <= theHSeqOfInvisStyle->Length(); si++) { if (theStyle != theHSeqOfInvisStyle->Value(si)) + { continue; + } // found that current style is invisible. anIsVisible = false; break; @@ -1186,7 +1278,9 @@ static void SetStyle( STEPConstruct_RenderingProperties aRenderProps; if (!theStyles.GetColors(theStyle, aSurfCol, aBoundCol, aCurveCol, aRenderProps, anIsComponent) && anIsVisible) + { return; + } // collect styled items NCollection_DynamicArray anItems; @@ -1213,25 +1307,33 @@ static void SetStyle( findStyledSR(theStyle, aSR); // search for SR along model if (aSR.IsNull()) + { break; + } Interface_EntityIterator aSubs = theWS->HGraph()->Graph().Sharings(aSR); occ::handle aSDR; for (aSubs.Start(); aSubs.More(); aSubs.Next()) { aSDR = occ::down_cast(aSubs.Value()); if (aSDR.IsNull()) + { continue; + } StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition(); occ::handle PDS = occ::down_cast(aPDSselect.PropertyDefinition()); if (PDS.IsNull()) + { continue; + } StepRepr_CharacterizedDefinition aCharDef = PDS->Definition(); occ::handle ACU = occ::down_cast(aCharDef.ProductDefinitionRelationship()); if (ACU.IsNull()) + { continue; + } // PTV 10.02.2003 skip styled item that refer to SHUO if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) { @@ -1241,7 +1343,9 @@ static void SetStyle( occ::handle NAUO = occ::down_cast(ACU); if (NAUO.IsNull()) + { continue; + } TopoDS_Shape aSh; // PTV 10.02.2003 to find component of assembly CORRECTLY @@ -1258,10 +1362,14 @@ static void SetStyle( break; } if (isSkipSHUOstyle) + { continue; // skip styled item which refer to SHUO + } if (aS.IsNull()) + { continue; + } if (!aSurfCol.IsNull() || !aBoundCol.IsNull() || !aCurveCol.IsNull() || aRenderProps.IsDefined() || !anIsVisible) @@ -1279,9 +1387,13 @@ static void SetStyle( aFullSCol = Quantity_ColorRGBA(aSCol); } if (!aBoundCol.IsNull()) + { STEPConstruct_Styles::DecodeColor(aBoundCol, aBCol); + } if (!aCurveCol.IsNull()) + { STEPConstruct_Styles::DecodeColor(aCurveCol, aCCol); + } if (aRenderProps.IsDefined()) { aFullSCol = aRenderProps.GetRGBAColor(); @@ -1289,11 +1401,17 @@ static void SetStyle( if (isFound) { if (!aSurfCol.IsNull() || aRenderProps.IsDefined()) + { theCTool->SetColor(aL, aFullSCol, XCAFDoc_ColorSurf); + } if (!aBoundCol.IsNull()) + { theCTool->SetColor(aL, aBCol, XCAFDoc_ColorCurv); + } if (!aCurveCol.IsNull()) + { theCTool->SetColor(aL, aCCol, XCAFDoc_ColorCurv); + } } else { @@ -1303,11 +1421,17 @@ static void SetStyle( if (theSTool->SearchUsingMap(it.Value(), aL1, false, true)) { if (!aSurfCol.IsNull() || aRenderProps.IsDefined()) + { theCTool->SetColor(aL1, aFullSCol, XCAFDoc_ColorSurf); + } if (!aBoundCol.IsNull()) + { theCTool->SetColor(aL1, aBCol, XCAFDoc_ColorCurv); + } if (!aCurveCol.IsNull()) + { theCTool->SetColor(aL1, aCCol, XCAFDoc_ColorCurv); + } } } } @@ -1316,7 +1440,9 @@ static void SetStyle( { // sets the invisibility for shape. if (isFound) + { theCTool->SetVisibility(aL, false); + } } } } @@ -1375,10 +1501,14 @@ bool STEPCAFControl_Reader::ReadColors(const occ::handle& occ::handle CTool = XCAFDoc_DocumentTool::ColorTool(Doc->Main()); if (CTool.IsNull()) + { return false; + } occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (STool.IsNull()) + { return false; + } const Interface_Graph& aGraph = Styles.Graph(); @@ -1435,22 +1565,32 @@ static TDF_Label GetLabelFromPD( { L = EF->GetLabel(); if (!L.IsNull()) + { return L; + } } } TopoDS_Shape S; occ::handle binder = TP->Find(PD); if (binder.IsNull() || !binder->HasResult()) + { return L; + } S = TransferBRep::ShapeResult(TP, binder); if (S.IsNull()) + { return L; + } if (ShapeLabelMap.IsBound(S)) + { L = ShapeLabelMap.Find(S); + } if (L.IsNull()) + { STool->Search(S, L, true, true, false); + } return L; } @@ -1487,9 +1627,13 @@ TDF_Label STEPCAFControl_Reader::FindInstance( } if (ShapeLabelMap.IsBound(S)) + { L = ShapeLabelMap(S); + } else + { STool->Search(S, L, true, true, false); + } return L; } @@ -1508,7 +1652,9 @@ bool STEPCAFControl_Reader::ReadNames( const occ::handle& TP = TR->TransientProcess(); occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (STool.IsNull()) + { return false; + } STEPConstruct_Tool Tool(WS); // iterate on model to find all SDRs and CDSRs @@ -1530,31 +1676,47 @@ bool STEPCAFControl_Reader::ReadNames( occ::handle NAUO = occ::down_cast(enti); if (NAUO.IsNull()) + { continue; + } Interface_EntityIterator subs = WS->Graph().Sharings(NAUO); for (subs.Start(); subs.More(); subs.Next()) { occ::handle PDS = occ::down_cast(subs.Value()); if (PDS.IsNull()) + { continue; + } occ::handle PDR = PDS->Definition().ProductDefinitionRelationship(); if (PDR.IsNull()) + { continue; + } if (PDR->HasDescription() && PDR->Description()->UsefullLength() > 0) + { name = PDR->Description(); + } else if (!PDR->Name().IsNull() && PDR->Name()->UsefullLength() > 0) + { name = PDR->Name(); + } else if (!PDR->Id().IsNull()) + { name = PDR->Id(); + } else + { name = new TCollection_HAsciiString; + } } // find proper label L = FindInstance(NAUO, STool, Tool, myMap); if (L.IsNull()) + { continue; + } TCollection_ExtendedString str = convertName(name->String()); TDataStd_Name::Set(L, str); @@ -1567,20 +1729,32 @@ bool STEPCAFControl_Reader::ReadNames( occ::handle PD = occ::down_cast(enti); if (PD.IsNull()) + { continue; + } occ::handle Prod = (!PD->Formation().IsNull() ? PD->Formation()->OfProduct() : nullptr); if (Prod.IsNull()) + { name = new TCollection_HAsciiString; + } else if (!Prod->Name().IsNull() && Prod->Name()->UsefullLength() > 0) + { name = Prod->Name(); + } else if (!Prod->Id().IsNull()) + { name = Prod->Id(); + } else + { name = new TCollection_HAsciiString; + } L = GetLabelFromPD(PD, STool, TP, PDFileMap, myMap); if (L.IsNull()) + { continue; + } TCollection_ExtendedString str = convertName(name->String()); TDataStd_Name::Set(L, str); } @@ -1610,16 +1784,24 @@ static TDF_Label GetLabelFromPD( { L = EF->GetLabel(); if (!L.IsNull()) + { return L; + } } } TopoDS_Shape S = Props.GetPropShape(PD); if (S.IsNull()) + { return L; + } if (ShapeLabelMap.IsBound(S)) + { L = ShapeLabelMap.Find(S); + } if (L.IsNull()) + { STool->Search(S, L, true, true, false); + } return L; } @@ -1637,7 +1819,9 @@ bool STEPCAFControl_Reader::ReadValProps( const occ::handle& TP = TR->TransientProcess(); occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (STool.IsNull()) + { return false; + } // load props from the STEP model NCollection_Sequence> props; @@ -1656,7 +1840,9 @@ bool STEPCAFControl_Reader::ReadValProps( occ::handle PDR = occ::down_cast(props.Value(i)); if (PDR.IsNull()) + { continue; + } TDF_Label L; @@ -1669,20 +1855,26 @@ bool STEPCAFControl_Reader::ReadValProps( occ::handle PDS = occ::down_cast(subs.Value()); if (PDS.IsNull()) + { continue; + } // find corresponding NAUO occ::handle NAUO; Interface_EntityIterator subs1 = Props.Graph().Shareds(PDS); for (subs1.Start(); NAUO.IsNull() && subs1.More(); subs1.Next()) { if (subs1.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) + { NAUO = occ::down_cast(subs1.Value()); + } } if (!NAUO.IsNull()) { L = FindInstance(NAUO, STool, WS, myMap); if (L.IsNull()) + { continue; + } } else { @@ -1692,10 +1884,14 @@ bool STEPCAFControl_Reader::ReadValProps( for (subsPDS.Start(); ProdDef.IsNull() && subsPDS.More(); subsPDS.Next()) { if (subsPDS.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { ProdDef = occ::down_cast(subsPDS.Value()); + } } if (ProdDef.IsNull()) + { continue; + } L = GetLabelFromPD(ProdDef, STool, Props, PDFileMap, myMap); } } @@ -1704,7 +1900,9 @@ bool STEPCAFControl_Reader::ReadValProps( { occ::handle SA = occ::down_cast(subs.Value()); if (SA.IsNull()) + { continue; + } // find ShapeRepresentation occ::handle SR; Interface_EntityIterator subs1 = Props.Graph().Sharings(SA); @@ -1713,19 +1911,25 @@ bool STEPCAFControl_Reader::ReadValProps( occ::handle PropD1 = occ::down_cast(subs1.Value()); if (PropD1.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Props.Graph().Sharings(PropD1); for (subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) { occ::handle SDR = occ::down_cast(subs2.Value()); if (SDR.IsNull()) + { continue; + } SR = occ::down_cast(SDR->UsedRepresentation()); } } if (SR.IsNull()) + { continue; + } occ::handle binder; for (int ir = 1; ir <= SR->NbItems() && binder.IsNull(); ir++) { @@ -1749,20 +1953,30 @@ bool STEPCAFControl_Reader::ReadValProps( } } if (binder.IsNull() || !binder->HasResult()) + { continue; + } TopoDS_Shape S; S = TransferBRep::ShapeResult(TP, binder); if (S.IsNull()) + { continue; + } if (myMap.IsBound(S)) + { L = myMap.Find(S); + } if (L.IsNull()) + { STool->Search(S, L, true, true, true); + } } } if (L.IsNull()) + { continue; + } // decode validation properties occ::handle rep = PDR->UsedRepresentation(); @@ -1775,9 +1989,13 @@ bool STEPCAFControl_Reader::ReadValProps( if (Props.GetPropReal(ent, val, isArea, theLocalFactors)) { if (isArea) + { XCAFDoc_Area::Set(L, val); + } else + { XCAFDoc_Volume::Set(L, val); + } } else if (Props.GetPropPnt(ent, rep->ContextOfItems(), pos, theLocalFactors)) { @@ -1798,10 +2016,14 @@ bool STEPCAFControl_Reader::ReadLayers(const occ::handle& const occ::handle& TP = TR->TransientProcess(); occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (STool.IsNull()) + { return false; + } occ::handle LTool = XCAFDoc_DocumentTool::LayerTool(Doc->Main()); if (LTool.IsNull()) + { return false; + } occ::handle tSVPLA = STANDARD_TYPE(StepVisual_PresentationLayerAssignment); int nb = Model->NbEntities(); @@ -1811,11 +2033,15 @@ bool STEPCAFControl_Reader::ReadLayers(const occ::handle& { occ::handle enti = Model->Value(i); if (!enti->IsKind(tSVPLA)) + { continue; + } occ::handle SVPLA = occ::down_cast(enti); if (SVPLA->AssignedItems().IsNull()) + { continue; + } occ::handle descr = SVPLA->Description(); occ::handle hName = SVPLA->Name(); @@ -1829,7 +2055,9 @@ bool STEPCAFControl_Reader::ReadLayers(const occ::handle& for (subs.Start(); subs.More() && isVisible; subs.Next()) { if (!subs.Value()->IsKind(STANDARD_TYPE(StepVisual_Invisibility))) + { continue; + } #ifdef OCCT_DEBUG std::cout << "\tLayer \"" << aLayerName << "\" is invisible" << std::endl; #endif @@ -1842,22 +2070,32 @@ bool STEPCAFControl_Reader::ReadLayers(const occ::handle& StepVisual_LayeredItem LI = SVPLA->AssignedItemsValue(j); occ::handle binder = TP->Find(LI.Value()); if (binder.IsNull() || !binder->HasResult()) + { continue; + } TopoDS_Shape S = TransferBRep::ShapeResult(TP, binder); if (S.IsNull()) + { continue; + } TDF_Label shL; if (!STool->Search(S, shL, true, true, true)) + { continue; + } if (aLayerLabel.IsNull()) + { aLayerLabel = LTool->AddLayer(aLayerName, isVisible); + } LTool->SetLayer(shL, aLayerLabel); } if (!aLayerLabel.IsNull()) + { LTool->SetVisibility(aLayerLabel, isVisible); + } } return true; } @@ -1884,11 +2122,15 @@ static bool findNextSHUOlevel( } } if (subSHUO.IsNull()) + { return false; + } occ::handle NUNAUO = subSHUO->NextUsage(); if (NUNAUO.IsNull()) + { return false; + } // occ::handle Model = WS->Model(); // occ::handle TR = WS->TransferReader(); // occ::handle TP = TR->TransientProcess(); @@ -1902,7 +2144,9 @@ static bool findNextSHUOlevel( NULab = STEPCAFControl_Reader::FindInstance(NUNAUO, STool, Tool, ShapeLabelMap); // STool->Search(NUSh, NUlab); if (NULab.IsNull()) + { return false; + } aLabels.Append(NULab); // and check by recurse. findNextSHUOlevel(WS, subSHUO, STool, PDFileMap, ShapeLabelMap, aLabels); @@ -1954,7 +2198,9 @@ static TDF_Label setSHUOintoDoc( // STool->Search(UUSh, UULab); // STool->Search(NUSh, NULab); if (UULab.IsNull() || NULab.IsNull()) + { return aMainLabel; + } // create sequence fo labels to set SHUO structure into the document NCollection_Sequence ShuoLabels; ShuoLabels.Append(UULab); @@ -1964,7 +2210,9 @@ static TDF_Label setSHUOintoDoc( // last accord for SHUO occ::handle anSHUOAttr; if (STool->SetSHUO(ShuoLabels, anSHUOAttr)) + { aMainLabel = anSHUOAttr->Label(); + } return aMainLabel; } @@ -2000,14 +2248,18 @@ bool STEPCAFControl_Reader::ReadSHUOs( { occ::handle style = Styles.Style(i); if (style.IsNull()) + { continue; + } bool IsVisible = true; // check the visibility of styled item. for (int si = 1; si <= aHSeqOfInvisStyle->Length(); si++) { if (style != aHSeqOfInvisStyle->Value(si)) + { continue; + } // found that current style is invisible. #ifdef OCCT_DEBUG std::cout << "Warning: item No " << i << "(" << style->Item()->DynamicType()->Name() @@ -2023,32 +2275,44 @@ bool STEPCAFControl_Reader::ReadSHUOs( STEPConstruct_RenderingProperties aRenderProps; if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, aRenderProps, IsComponent) && IsVisible) + { continue; + } if (!IsComponent) + { continue; + } occ::handle aSR; findStyledSR(style, aSR); // search for SR along model if (aSR.IsNull()) + { continue; + } Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings(aSR); occ::handle aSDR; for (subs.Start(); subs.More(); subs.Next()) { aSDR = occ::down_cast(subs.Value()); if (aSDR.IsNull()) + { continue; + } StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition(); occ::handle PDS = occ::down_cast(aPDSselect.PropertyDefinition()); if (PDS.IsNull()) + { continue; + } StepRepr_CharacterizedDefinition aCharDef = PDS->Definition(); occ::handle SHUO = occ::down_cast( aCharDef.ProductDefinitionRelationship()); if (SHUO.IsNull()) + { continue; + } // set the SHUO structure to the document TDF_Label aLabelForStyle = setSHUOintoDoc(WS, SHUO, STool, PDFileMap, myMap); @@ -2089,8 +2353,10 @@ bool STEPCAFControl_Reader::ReadSHUOs( CTool->SetColor(aLabelForStyle, col, XCAFDoc_ColorCurv); } if (!IsVisible) + { // sets the invisibility for shape. CTool->SetVisibility(aLabelForStyle, false); + } } // end search SHUO by SDR } // end iterates on styles @@ -2104,7 +2370,9 @@ static bool GetMassConversionFactor(const occ::handle& NU, { afact = 1.; if (!NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndMassUnit))) + { return false; + } occ::handle CBUMU = occ::down_cast(NU); occ::handle MWUCBU = GetMeasureWithUnit(CBUMU->ConversionFactor()); @@ -2119,7 +2387,9 @@ static bool GetMassConversionFactor(const occ::handle& NU, if (SU->Name() == StepBasic_sunGram) { if (SU->HasPrefix()) + { afact *= STEPConstruct_UnitContext::ConvertSiPrefix(SU->Prefix()); + } } } } @@ -2300,7 +2570,9 @@ bool readPMIPresentation(const occ::handle& thePresent occ::handle aTesselation = aDCallout->ContentsValue(i).TessellatedAnnotationOccurrence(); if (!aTesselation.IsNull()) + { anAnnotations.Append(aTesselation); + } } } @@ -2338,11 +2610,15 @@ bool readPMIPresentation(const occ::handle& thePresent { occ::handle aRepresentationItem = anItem->Item(); if (aRepresentationItem.IsNull()) + { continue; + } occ::handle aTessSet = occ::down_cast(aRepresentationItem); if (aTessSet.IsNull()) + { continue; + } gp_Trsf aTransf; if (aTessSet->IsKind(STANDARD_TYPE(StepVisual_RepositionedTessellatedGeometricSet))) { @@ -2440,7 +2716,9 @@ bool readPMIPresentation(const occ::handle& thePresent aNbShapes++; aB.Add(aResAnnotation, anAnnotationShape); if (i == anAnnotations.Length() - 1) + { BRepBndLib::AddClose(anAnnotationShape, aBox); + } } } @@ -2456,10 +2734,14 @@ bool readAnnotationPlane(const occ::handle& theAnnot const StepData_Factors& theLocalFactors) { if (theAnnotationPlane.IsNull()) + { return false; + } occ::handle aPlaneItem = theAnnotationPlane->Item(); if (aPlaneItem.IsNull()) + { return false; + } occ::handle aA2P3D; // retrieve axes from AnnotationPlane if (aPlaneItem->IsKind(STANDARD_TYPE(StepGeom_Plane))) @@ -2473,7 +2755,9 @@ bool readAnnotationPlane(const occ::handle& theAnnot aA2P3D = aBox->Placement().Axis2Placement3d(); } if (aA2P3D.IsNull()) + { return false; + } occ::handle anAxis = StepToGeom::MakeAxis2Placement(aA2P3D, theLocalFactors); thePlane = anAxis->Ax2(); @@ -2491,7 +2775,9 @@ void readAnnotation(const occ::handle& theTR, const StepData_Factors& theLocalFactors) { if (theGDT.IsNull() || theDimObject.IsNull()) + { return; + } occ::handle aPresentName; TopoDS_Compound aResAnnotation; occ::handle aTP = theTR->TransientProcess(); @@ -2502,7 +2788,9 @@ void readAnnotation(const occ::handle& theTR, for (subs.Start(); subs.More() && aDMIA.IsNull(); subs.Next()) { if (!subs.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation))) + { continue; + } aDMIA = occ::down_cast(subs.Value()); occ::handle aName = aDMIA->Name(); aName->LowerCase(); @@ -2512,7 +2800,9 @@ void readAnnotation(const occ::handle& theTR, } } if (aDMIA.IsNull() || aDMIA->NbIdentifiedItem() == 0) + { return; + } // calculate units occ::handle aDModel = @@ -2526,7 +2816,9 @@ void readAnnotation(const occ::handle& theTR, // retrieve AnnotationPlane occ::handle aDMIAE = aDMIA->IdentifiedItemValue(1); if (aDMIAE.IsNull()) + { return; + } gp_Ax2 aPlaneAxes; subs = aGraph.Sharings(aDMIAE); occ::handle anAnPlane; @@ -2563,7 +2855,9 @@ void readAnnotation(const occ::handle& theTR, // Retrieve presentation Bnd_Box aBox; if (!readPMIPresentation(aDMIAE, theTR, aFact, aResAnnotation, aPresentName, aBox, aLocalFactors)) + { return; + } gp_Pnt aPtext(0., 0., 0.); // if Annotation plane location inside bounding box set it to text position // else set the center of bounding box to text position 0027372 @@ -2607,7 +2901,6 @@ void readAnnotation(const occ::handle& theTR, anObj->SetPointTextAttach(aPtext); anObj->SetPresentation(aResAnnotation, aPresentName); } - return; } //======================================================================= @@ -2622,7 +2915,9 @@ static bool retrieveConnectionPointFromGISU( occ::handle& theConnName) { if (theGISU.IsNull() || theGISU->NbIdentifiedItem() == 0) + { return false; + } occ::handle aPoint = occ::down_cast(theGISU->IdentifiedItem()->Value(1)); @@ -2642,7 +2937,9 @@ static bool retrieveConnectionPointFromGISU( occ::handle anA2P3D = occ::down_cast(theGISU->IdentifiedItem()->Value(1)); if (anA2P3D.IsNull()) + { return false; + } theIsPoint = false; theConnName = anA2P3D->Name(); occ::handle anAxis = @@ -2663,7 +2960,9 @@ void readConnectionPoints(const occ::handle& const StepData_Factors& theLocalFactors) { if (theGDT.IsNull() || theDimObject.IsNull()) + { return; + } occ::handle aTP = theTR->TransientProcess(); const Interface_Graph& aGraph = aTP->Graph(); @@ -2677,8 +2976,10 @@ void readConnectionPoints(const occ::handle& occ::handle aDCR = occ::down_cast(anEnt); if (!aDCR.IsNull()) + { aSDR = !aDCR.IsNull() ? aDCR->Representation() : occ::down_cast(anEnt); + } } if (!aSDR.IsNull()) { @@ -2696,7 +2997,9 @@ void readConnectionPoints(const occ::handle& occ::handle aDSA = occ::down_cast(aDim->AppliesTo()); if (aDSA.IsNull()) + { return; + } occ::handle aGISU = nullptr; for (Interface_EntityIterator anIt = aGraph.Sharings(aDSA); aGISU.IsNull() && anIt.More(); anIt.Next()) @@ -2709,9 +3012,13 @@ void readConnectionPoints(const occ::handle& if (retrieveConnectionPointFromGISU(aGISU, aFact, aCS, aIsPoint, aConnName)) { if (aIsPoint) + { theDimObject->SetPoint(aCS.Location()); + } else + { theDimObject->SetConnectionAxis(aCS); + } theDimObject->SetConnectionName(aConnName); } } @@ -2725,7 +3032,9 @@ void readConnectionPoints(const occ::handle& occ::handle aDSA2 = occ::down_cast(aDim->RelatedShapeAspect()); if (aDSA1.IsNull() && aDSA2.IsNull()) + { return; + } occ::handle aGISU1 = nullptr; occ::handle aGISU2 = nullptr; if (!aDSA1.IsNull()) @@ -2751,18 +3060,26 @@ void readConnectionPoints(const occ::handle& if (retrieveConnectionPointFromGISU(aGISU1, aFact, aCS, aIsPoint, aConnName)) { if (aIsPoint) + { theDimObject->SetPoint(aCS.Location()); + } else + { theDimObject->SetConnectionAxis(aCS); + } theDimObject->SetConnectionName(aConnName); } // second point if (retrieveConnectionPointFromGISU(aGISU2, aFact, aCS, aIsPoint, aConnName)) { if (aIsPoint) + { theDimObject->SetPoint2(aCS.Location()); + } else + { theDimObject->SetConnectionAxis2(aCS); + } theDimObject->SetConnectionName2(aConnName); } } @@ -2778,7 +3095,9 @@ static bool ReadDatums(const occ::handle& const occ::handle& GTWDR) { if (GTWDR.IsNull()) + { return false; + } occ::handle> aHADSOR = GTWDR->DatumSystemAP242(); if (aHADSOR.IsNull()) @@ -2790,7 +3109,9 @@ static bool ReadDatums(const occ::handle& { const StepDimTol_DatumSystemOrReference aDSOR = aHADSOR->Value(idr); if (aDSOR.IsNull()) + { continue; + } occ::handle aDS = aDSOR.DatumSystem(); occ::handle aDR = aDSOR.DatumReference(); occ::handle aDatum; @@ -2813,18 +3134,24 @@ static bool ReadDatums(const occ::handle& { occ::handle aDatum = anIt.Value(); if (aDatum.IsNull()) + { continue; + } Interface_EntityIterator subs4 = graph.Sharings(aDatum); for (subs4.Start(); subs4.More(); subs4.Next()) { occ::handle SAR = occ::down_cast(subs4.Value()); if (SAR.IsNull()) + { continue; + } occ::handle DF = occ::down_cast(SAR->RelatingShapeAspect()); if (DF.IsNull()) + { continue; + } Interface_EntityIterator subs5 = graph.Sharings(DF); occ::handle PropDef; for (subs5.Start(); subs5.More() && PropDef.IsNull(); subs5.Next()) @@ -2832,7 +3159,9 @@ static bool ReadDatums(const occ::handle& PropDef = occ::down_cast(subs5.Value()); } if (PropDef.IsNull()) + { continue; + } occ::handle AF; subs5 = graph.Sharings(PropDef); for (subs5.Start(); subs5.More(); subs5.Next()) @@ -2850,7 +3179,9 @@ static bool ReadDatums(const occ::handle& } } if (AF.IsNull()) + { return false; + } int index = TP->MapIndex(AF); TopoDS_Shape aSh; if (index > 0) @@ -2859,10 +3190,14 @@ static bool ReadDatums(const occ::handle& aSh = TransferBRep::ShapeResult(binder); } if (aSh.IsNull()) + { continue; + } TDF_Label shL; if (!STool->Search(aSh, shL, true, true, true)) + { continue; + } DGTTool->SetDatum(shL, TolerL, PropDef->Name(), @@ -2884,7 +3219,9 @@ static int FindShapeIndexForDGT(const occ::handle& theEnt // try to find index of given entity int anIndex = aTP->MapIndex(theEnt); if (anIndex > 0 || theEnt.IsNull()) + { return anIndex; + } // if theEnt is a geometry item try to find its topological item const Interface_Graph& aGraph = aTP->Graph(); Interface_EntityIterator anIter = aGraph.Sharings(theEnt); @@ -2894,7 +3231,9 @@ static int FindShapeIndexForDGT(const occ::handle& theEnt { anIndex = aTP->MapIndex(anIter.Value()); if (anIndex > 0) + { return anIndex; + } } } return 0; @@ -2907,7 +3246,9 @@ static void collectShapeAspect(const occ::handle& NCollection_Sequence>& theSAs) { if (theSA.IsNull()) + { return; + } occ::handle aTR = theWS->TransferReader(); occ::handle aTP = aTR->TransientProcess(); const Interface_Graph& aGraph = aTP->Graph(); @@ -2921,7 +3262,9 @@ static void collectShapeAspect(const occ::handle& aSADR = occ::down_cast(anIter.Value()); } if (!aSADR.IsNull()) + { collectShapeAspect(aSADR->RelatedShapeAspect(), theWS, theSAs); + } } else if (theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature)) || theSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) @@ -2951,7 +3294,9 @@ static void collectShapeAspect(const occ::handle& } // If not Composite_Shape_Aspect (or subtype) append to sequence. if (isSimple) + { theSAs.Append(theSA); + } } } @@ -2971,7 +3316,9 @@ static TDF_Label getShapeLabel(const occ::handle& t aShape = TransferBRep::ShapeResult(aBinder); } if (aShape.IsNull()) + { return aShapeL; + } theShapeTool->Search(aShape, aShapeL, true, true, true); return aShapeL; } @@ -3006,12 +3353,16 @@ bool STEPCAFControl_Reader::setDatumToXCAF( occ::handle aSAR = occ::down_cast(anIterD.Value()); if (aSAR.IsNull() || aSAR->RelatingShapeAspect().IsNull()) + { continue; + } collectShapeAspect(aSAR->RelatingShapeAspect(), theWS, aSAs); occ::handle aDF = occ::down_cast(aSAR->RelatingShapeAspect()); if (!aSAR->RelatingShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) + { readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj, theLocalFactors); + } } // Collect shape labels @@ -3019,10 +3370,14 @@ bool STEPCAFControl_Reader::setDatumToXCAF( { occ::handle aSA = aSAs.Value(i); if (aSA.IsNull()) + { continue; + } // Skip datum targets if (aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) + { continue; + } // Process all connected GISU Interface_EntityIterator anIter = aGraph.Sharings(aSA); @@ -3031,12 +3386,16 @@ bool STEPCAFControl_Reader::setDatumToXCAF( occ::handle aGISU = occ::down_cast(anIter.Value()); if (aGISU.IsNull()) + { continue; + } for (int j = 1; j <= aGISU->NbIdentifiedItem(); j++) { TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool); if (!aShapeL.IsNull()) + { aShapeLabels.Append(aShapeL); + } } } } @@ -3048,7 +3407,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( occ::handle aDT = occ::down_cast(aSAs.Value(i)); if (aDT.IsNull()) + { continue; + } occ::handle aDatTargetObj = new XCAFDimTolObjects_DatumObject(); XCAFDimTolObjects_DatumTargetType aType; if (!STEPCAFControl_GDTProperty::GetDatumTargetType(aDT->Description(), aType)) @@ -3076,7 +3437,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( occ::handle aGISU = occ::down_cast(aSAIter.Value()); if (aGISU.IsNull()) + { continue; + } for (int j = 1; j <= aGISU->NbIdentifiedItem(); j++) { TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool); @@ -3097,7 +3460,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( occ::handle aGISU = occ::down_cast(aDTIter.Value()); if (aGISU.IsNull()) + { continue; + } for (int j = 1; j <= aGISU->NbIdentifiedItem(); j++) { TDF_Label aShapeL = getShapeLabel(aGISU->IdentifiedItemValue(j), theWS, aSTool); @@ -3114,7 +3479,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( { // Area datum target if (aRelationship.IsNull()) + { continue; + } occ::handle aSA = aRelationship->RelatingShapeAspect(); Interface_EntityIterator aSAIter = aGraph.Sharings(aSA); occ::handle aGISU; @@ -3124,9 +3491,13 @@ bool STEPCAFControl_Reader::setDatumToXCAF( } occ::handle anItem; if (!aGISU.IsNull() && aGISU->NbIdentifiedItem() > 0) + { anItem = aGISU->IdentifiedItemValue(1); + } if (anItem.IsNull()) + { continue; + } int anItemIndex = FindShapeIndexForDGT(anItem, theWS); if (anItemIndex > 0) { @@ -3164,7 +3535,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( for (int j = aSRWP->Items()->Lower(); j <= aSRWP->Items()->Upper(); j++) { if (aSRWP->ItemsValue(j).IsNull()) + { continue; + } if (aSRWP->ItemsValue(j)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d))) { occ::handle anAx = @@ -3185,18 +3558,26 @@ bool STEPCAFControl_Reader::setDatumToXCAF( double aVal = aM->GetMeasureWithUnit()->ValueComponent(); StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent(); if (anUnit.IsNull()) + { continue; + } occ::handle aNU = anUnit.NamedUnit(); if (aNU.IsNull()) + { continue; + } STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(aNU, theLocalFactors); aVal = aVal * anUnitCtx.LengthFactor(); if (aM->Name()->String().IsEqual("target length") || aM->Name()->String().IsEqual("target diameter")) + { aDatTargetObj->SetDatumTargetLength(aVal); + } else + { aDatTargetObj->SetDatumTargetWidth(aVal); + } } } } @@ -3216,9 +3597,13 @@ bool STEPCAFControl_Reader::setDatumToXCAF( aDatTargetObj->SetName(theDat->Identification()); aDatTargetObj->SetPosition(thePositionCounter); if (!theXCAFModifiers.IsEmpty()) + { aDatTargetObj->SetModifiers(theXCAFModifiers); + } if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) + { aDatTargetObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue); + } aDGTTool->SetDatumToGeomTol(aDatL, theGDTL); aDatTargetObj->IsDatumTarget(true); aDatTargetObj->SetDatumTargetNumber(aDT->TargetId()->IntegerValue()); @@ -3239,7 +3624,9 @@ bool STEPCAFControl_Reader::setDatumToXCAF( { occ::handle aSA = aSAs.Value(i); if (aSA.IsNull() || aSA->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget))) + { continue; + } myGDTMap.Bind(aSA, aDatL); } aDGTTool->Lock(aDatL); @@ -3248,9 +3635,13 @@ bool STEPCAFControl_Reader::setDatumToXCAF( aDatObj->SetName(theDat->Identification()); aDatObj->SetPosition(thePositionCounter); if (!theXCAFModifiers.IsEmpty()) + { aDatObj->SetModifiers(theXCAFModifiers); + } if (theXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) + { aDatObj->SetModifierWithValue(theXCAFModifWithVal, theModifValue); + } aDGTTool->SetDatumToGeomTol(aDatL, theGDTL); if (aDatObj->GetPresentation().IsNull()) { @@ -3334,9 +3725,11 @@ bool STEPCAFControl_Reader::readDatumsAP242(const occ::handleLower(); m <= aModif->Upper(); m++) { if (aModif->Value(m).CaseNumber() == 2) + { aXCAFModifiers.Append((XCAFDimTolObjects_DatumSingleModif)aModif->Value(m) .SimpleDatumReferenceModifierMember() ->Value()); + } else if (aModif->Value(m).CaseNumber() == 1) { aXCAFModifWithVal = @@ -3353,9 +3746,13 @@ bool STEPCAFControl_Reader::readDatumsAP242(const occ::handleModifierValue() ->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -3394,9 +3791,11 @@ bool STEPCAFControl_Reader::readDatumsAP242(const occ::handleLower(); k <= aModifE->Upper(); k++) { if (aModifE->Value(k).CaseNumber() == 2) + { aXCAFModifiers.Append((XCAFDimTolObjects_DatumSingleModif)aModifE->Value(k) .SimpleDatumReferenceModifierMember() ->Value()); + } else if (aModifE->Value(k).CaseNumber() == 1) { aXCAFModifWithVal = @@ -3413,9 +3812,13 @@ bool STEPCAFControl_Reader::readDatumsAP242(const occ::handleModifierValue() ->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -3475,14 +3878,18 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( occ::handle aGeomTol = occ::down_cast(theEnt); if (aGeomTol->TolerancedShapeAspect().IsNull()) + { return aGDTL; + } aSemanticName = aGeomTol->Name(); } if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) { occ::handle aDim = occ::down_cast(theEnt); if (aDim->AppliesTo().IsNull()) + { return aGDTL; + } aSemanticName = aDim->Name(); } if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) @@ -3490,7 +3897,9 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( occ::handle aDim = occ::down_cast(theEnt); if (aDim->RelatedShapeAspect().IsNull() || aDim->RelatingShapeAspect().IsNull()) + { return aGDTL; + } aSemanticName = aDim->Name(); } @@ -3598,14 +4007,18 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( } } if (RI.IsNull()) + { continue; + } if (theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) { // read dimensions occ::handle EC = occ::down_cast(RI); if (EC.IsNull()) + { continue; + } occ::handle aName; occ::handle DimSize = occ::down_cast(theEnt); @@ -3640,12 +4053,16 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( occ::handle>> HARI = VR->ItemElement(); if (HARI.IsNull()) + { continue; + } if (HARI->Length() > 0) { occ::handle RI1 = HARI->Value(1); if (RI1.IsNull()) + { continue; + } if (RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) { occ::handle RILMWU = @@ -3653,9 +4070,13 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent(); StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -3666,7 +4087,9 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( { occ::handle RI2 = HARI->Value(2); if (RI2.IsNull()) + { continue; + } if (RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) { occ::handle RILMWU = @@ -3674,9 +4097,13 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent(); StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -3688,9 +4115,13 @@ TDF_Label STEPCAFControl_Reader::createGDTObjectInXCAF( } } if (dim1 < 0) + { continue; + } if (dim2 < 0) + { dim2 = dim1; + } // std::cout<<"DimensionalSize: dim1="< 0) // upper limit + if (aName->Search("upper") > 0) + { // upper limit aDim2 = aVal; - else // lower limit or simple nominal value + } + else + { // lower limit or simple nominal value aDim1 = aVal; + } } else if (aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnitAndQRI))) { @@ -4104,9 +4601,13 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, double aVal = aMWU->GetMeasureWithUnit()->ValueComponent(); StepBasic_Unit anUnit = aMWU->GetMeasureWithUnit()->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -4129,11 +4630,17 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, occ::handle aValueType = aQRI->Qualifiers()->Value(1).TypeQualifier(); if (aValueType->Name()->String().IsEqual("minimum")) + { aDim2 = aVal; + } else if (aValueType->Name()->String().IsEqual("maximum")) + { aDim3 = aVal; + } else + { aDim1 = aVal; + } } else if (aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) { @@ -4169,7 +4676,9 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, isPlusMinusTolerance = true; StepShape_ToleranceMethodDefinition aTMD = aPMT->Range(); if (aPMT.IsNull()) + { continue; + } if (aTMD.CaseNumber() == 1) //! 1 -> ToleranceValue from StepShape //! 2 -> LimitsAndFits from StepShape @@ -4177,20 +4686,30 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, // plus minus tolerance aTV = aTMD.ToleranceValue(); if (aTV.IsNull()) + { continue; + } occ::handle aUpperBound = aTV->UpperBound(); if (aUpperBound.IsNull()) + { continue; + } occ::handle aMWU = GetMeasureWithUnit(aUpperBound); if (aMWU.IsNull()) + { continue; + } double aVal = aMWU->ValueComponent(); StepBasic_Unit anUnit = aMWU->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtxUpperBound; anUnitCtxUpperBound.ComputeFactors(NU, theLocalFactors); @@ -4209,18 +4728,26 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, occ::handle aLowerBound = aTV->LowerBound(); if (aLowerBound.IsNull()) + { continue; + } aMWU = GetMeasureWithUnit(aLowerBound); if (aMWU.IsNull()) + { continue; + } aVal = aMWU->ValueComponent(); anUnit = aMWU->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtxLowerBound; anUnitCtxLowerBound.ComputeFactors(NU, theLocalFactors); @@ -4246,10 +4773,14 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, } if (aDim1 < 0) + { return; + } if (aDim2 < 0) + { aDimObj->SetValue(aDim1); + } else if (aDim3 < 0) { occ::handle> anArr = new NCollection_HArray1(1, 2); @@ -4305,7 +4836,9 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, NCollection_Sequence aModifiers; STEPCAFControl_GDTProperty::GetDimModifiers(aCRI, aModifiers); if (aModifiers.Length() > 0) + { aDimObj->SetModifiers(aModifiers); + } } occ::handle aName; @@ -4329,11 +4862,17 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, // get qualifier for angular value aType = XCAFDimTolObjects_DimensionType_Size_Angular; if (anAngSize->AngleSelection() == StepShape_Equal) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Equal); + } else if (anAngSize->AngleSelection() == StepShape_Large) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Large); + } else if (anAngSize->AngleSelection() == StepShape_Small) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Small); + } } } else @@ -4345,11 +4884,17 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, // get qualifier for angular value aType = XCAFDimTolObjects_DimensionType_Location_Angular; if (anAngLoc->AngleSelection() == StepShape_Equal) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Equal); + } else if (anAngLoc->AngleSelection() == StepShape_Large) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Large); + } else if (anAngLoc->AngleSelection() == StepShape_Small) + { aDimObj->SetAngularQualifier(XCAFDimTolObjects_AngularQualifier_Small); + } } } if (aType == XCAFDimTolObjects_DimensionType_Location_None) @@ -4387,14 +4932,18 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, aPGISU = occ::down_cast(anIterDSWP.Value()); } if (aPGISU.IsNull()) + { return; + } if (aPGISU->NbIdentifiedItem() > 0) { aGRI = occ::down_cast(aPGISU->IdentifiedItemValue(1)); } if (aGRI.IsNull()) + { return; + } occ::handle aPRI; Interface_EntityIterator anIterGRI = aGraph.Sharings(aGRI); for (anIterGRI.Start(); anIterGRI.More() && aPRI.IsNull(); anIterGRI.Next()) @@ -4409,7 +4958,9 @@ static void setDimObjectToXCAF(const occ::handle& theEnt, aSh = TopoDS::Edge(TransferBRep::ShapeResult(aBinder)); } if (aSh.IsNull()) + { return; + } aDimObj->SetPath(aSh); } else if (!anAP.IsNull() && !anAP->RefDirection().IsNull() && !anAP->Name().IsNull() @@ -4451,7 +5002,9 @@ static bool getTolType(const occ::handle& theEnt, XCAFDimTolObjects_GeomToleranceType& theType) { if (theEnt.IsNull() || !theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return false; + } theType = XCAFDimTolObjects_GeomToleranceType_None; if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRef))) { @@ -4587,9 +5140,13 @@ static void setGeomTolObjectToXCAF(const occ::handle& the double aVal = aMWU->ValueComponent(); StepBasic_Unit anUnit = aMWU->UnitComponent(); if (anUnit.IsNull()) + { return; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { return; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -4619,9 +5176,13 @@ static void setGeomTolObjectToXCAF(const occ::handle& the double aVal = aPZone->ProjectionLength()->ValueComponent(); StepBasic_Unit anUnit = aPZone->ProjectionLength()->UnitComponent(); if (anUnit.IsNull()) + { return; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { return; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -4639,9 +5200,13 @@ static void setGeomTolObjectToXCAF(const occ::handle& the double aVal = aRZone->Orientation()->Angle()->ValueComponent(); StepBasic_Unit anUnit = aRZone->Orientation()->Angle()->UnitComponent(); if (anUnit.IsNull()) + { continue; + } if (!(anUnit.CaseNum(anUnit.Value()) == 1)) + { continue; + } occ::handle NU = anUnit.NamedUnit(); STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(NU, theLocalFactors); @@ -4688,11 +5253,17 @@ static void setGeomTolObjectToXCAF(const occ::handle& the for (int i = aModifiers->Lower(); i <= aModifiers->Upper(); i++) { if (aModifiers->Value(i) == StepDimTol_GTMLeastMaterialRequirement) + { aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_L); + } else if (aModifiers->Value(i) == StepDimTol_GTMMaximumMaterialRequirement) + { aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_M); + } else + { aTolObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)aModifiers->Value(i)); + } } } double aVal = 0; @@ -4744,11 +5315,15 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t Interface_EntityIterator anI = aSM->Header(); occ::handle aH; for (anI.Start(); anI.More() && aH.IsNull(); anI.Next()) + { aH = occ::down_cast(anI.Value()); + } occ::handle aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main()); occ::handle aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main()); if (aDGTTool.IsNull()) + { return false; + } int nb = aModel->NbEntities(); for (int i = 1; i <= nb; i++) @@ -4783,7 +5358,9 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t aDC = occ::down_cast(anIter.Value()); } if (!aDC.IsNull()) + { continue; + } // Read presentations for PMIs without semantic data. occ::handle aDMIA; NCollection_Sequence aShapesL; @@ -4850,10 +5427,14 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t } } if (isConnectedToGDT) + { continue; + } } else if (aDMIA->Definition().PropertyDefinition().IsNull()) + { continue; + } // Get shapes NCollection_Sequence> aSAs; @@ -4864,16 +5445,22 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t for (Interface_EntityIterator anIter = aGraph.Sharings(aSAs.Value(aSAIt)); anIter.More() && aGISU.IsNull(); anIter.Next()) + { aGISU = occ::down_cast(anIter.Value()); + } if (aGISU.IsNull()) + { continue; + } for (int anItemIt = 1; anItemIt <= aGISU->NbIdentifiedItem(); anItemIt++) { TDF_Label aLabel = getShapeLabel(aGISU->IdentifiedItemValue(anItemIt), theWS, XCAFDoc_DocumentTool::ShapeTool(theDoc->Main())); if (!aLabel.IsNull()) + { aShapesL.Append(aLabel); + } } } } @@ -4896,13 +5483,17 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t occ::handle aPresentName; Bnd_Box aBox; if (!readPMIPresentation(anEnt, aTR, aFact, aPresentation, aPresentName, aBox, aLocalFactors)) + { continue; + } // Annotation plane occ::handle anAnPlane; for (Interface_EntityIterator anIter = aGraph.Sharings(anEnt); anIter.More() && anAnPlane.IsNull(); anIter.Next()) + { anAnPlane = occ::down_cast(anIter.Value()); + } // Set object to XCAF TDF_Label aGDTL = aDGTTool->AddDimension(); @@ -4929,7 +5520,9 @@ bool STEPCAFControl_Reader::ReadGDTs(const occ::handle& t if (!anAnPlane.IsNull()) { if (readAnnotationPlane(anAnPlane, aPlaneAxes, aLocalFactors)) + { aDimObj->SetPlane(aPlaneAxes); + } } aDimObj->SetPresentation(aPresentation, aPresentName); aDim->SetObject(aDimObj); @@ -4952,10 +5545,14 @@ static occ::handle FindSolidForPDS( occ::handle SDR = occ::down_cast(subs.Value()); if (SDR.IsNull()) + { continue; + } SR = occ::down_cast(SDR->UsedRepresentation()); if (SR.IsNull()) + { continue; + } for (int i = 1; i <= SR->NbItems() && SM.IsNull(); i++) { SM = occ::down_cast(SR->ItemsValue(i)); @@ -4968,14 +5565,22 @@ static occ::handle FindSolidForPDS( occ::handle RR = occ::down_cast(subs1.Value()); if (RR.IsNull()) + { continue; + } occ::handle SR2; if (RR->Rep1() == SR) + { SR2 = occ::down_cast(RR->Rep2()); + } else + { SR2 = occ::down_cast(RR->Rep1()); + } if (SR2.IsNull()) + { continue; + } for (int i2 = 1; i2 <= SR2->NbItems() && SM.IsNull(); i2++) { SM = occ::down_cast(SR2->ItemsValue(i2)); @@ -4999,7 +5604,9 @@ bool STEPCAFControl_Reader::ReadMaterials( occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); occ::handle MatTool = XCAFDoc_DocumentTool::MaterialTool(Doc->Main()); if (MatTool.IsNull()) + { return false; + } const Interface_Graph& graph = TP->Graph(); for (int i = 1; i <= SeqPDS->Length(); i++) @@ -5007,10 +5614,14 @@ bool STEPCAFControl_Reader::ReadMaterials( occ::handle PDS = occ::down_cast(SeqPDS->Value(i)); if (PDS.IsNull()) + { continue; + } occ::handle aProdDef = PDS->Definition().ProductDefinition(); if (aProdDef.IsNull()) + { continue; + } occ::handle aName = new TCollection_HAsciiString(""); occ::handle aDescription = new TCollection_HAsciiString(""); occ::handle aDensName = new TCollection_HAsciiString(""); @@ -5022,23 +5633,31 @@ bool STEPCAFControl_Reader::ReadMaterials( occ::handle PropD = occ::down_cast(subs.Value()); if (PropD.IsNull()) + { continue; + } Interface_EntityIterator subs1 = graph.Sharings(PropD); for (subs1.Start(); subs1.More(); subs1.Next()) { occ::handle PDR = occ::down_cast(subs1.Value()); if (PDR.IsNull()) + { continue; + } occ::handle Repr = PDR->UsedRepresentation(); if (Repr.IsNull()) + { continue; + } int ir; for (ir = 1; ir <= Repr->NbItems(); ir++) { occ::handle RI = Repr->ItemsValue(ir); if (RI.IsNull()) + { continue; + } if (RI->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) { // find name and description for material @@ -5048,7 +5667,9 @@ bool STEPCAFControl_Reader::ReadMaterials( aDescription = DRI->Description(); if (aName.IsNull()) + { aName = aDescription; + } } if (RI->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) { @@ -5064,13 +5685,17 @@ bool STEPCAFControl_Reader::ReadMaterials( { occ::handle DU = aUnit.DerivedUnit(); if (DU.IsNull()) + { continue; + } for (int idu = 1; idu <= DU->NbElements(); idu++) { occ::handle DUE = DU->ElementsValue(idu); occ::handle NU = DUE->Unit(); if (NU.IsNull()) + { continue; + } if (NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)) || NU->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) { @@ -5100,7 +5725,9 @@ bool STEPCAFControl_Reader::ReadMaterials( } if (aName.IsNull() || aName->Length() == 0) + { continue; + } // find shape label amd create Material link TopoDS_Shape aSh; occ::handle SM = FindSolidForPDS(PDS, graph); @@ -5111,14 +5738,20 @@ bool STEPCAFControl_Reader::ReadMaterials( { occ::handle binder = TP->MapItem(index); if (!binder.IsNull()) + { aSh = TransferBRep::ShapeResult(binder); + } } } if (aSh.IsNull()) + { continue; + } TDF_Label shL; if (!STool->Search(aSh, shL, true, true, true)) + { continue; + } MatTool->SetMaterial(shL, aName, aDescription, aDensity, aDensName, aDensValType); } @@ -5151,17 +5784,23 @@ void collectViewShapes(const occ::handle& theWS, TDF_Label aShL; aSTool->FindShape(aSh, aShL); if (!aShL.IsNull()) + { theShapes.Append(aShL); + } } Interface_EntityIterator anIter = aGraph.Sharings(theRepr); for (; anIter.More(); anIter.Next()) { if (!anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship))) + { continue; + } occ::handle aReprRelationship = occ::down_cast(anIter.Value()); if (!aReprRelationship->Rep1().IsNull() && aReprRelationship->Rep1() != theRepr) + { collectViewShapes(theWS, theDoc, aReprRelationship->Rep1(), theShapes); + } } } @@ -5184,7 +5823,9 @@ occ::handle buildClippingPlanes( occ::down_cast(theClippingCameraModel); if (aCameraModel->ShapeClipping().IsNull()) + { return anExpression; + } // Root of clipping planes tree if (aCameraModel->ShapeClipping()->Length() == 1) @@ -5192,7 +5833,9 @@ occ::handle buildClippingPlanes( occ::handle aCameraModelUnion = aCameraModel->ShapeClipping()->Value(1).CameraModelD3MultiClippingUnion(); if (!aCameraModelUnion.IsNull()) + { return buildClippingPlanes(aCameraModelUnion, theClippingPlanes, theTool, theLocalFactors); + } } for (int i = 1; i <= aCameraModel->ShapeClipping()->Length(); i++) { @@ -5263,14 +5906,18 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& occ::handle aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main()); occ::handle aViewTool = XCAFDoc_DocumentTool::ViewTool(theDoc->Main()); if (aDGTTool.IsNull()) + { return false; + } int nb = aModel->NbEntities(); for (int i = 1; i <= nb; i++) { occ::handle anEnt = aModel->Value(i); if (!anEnt->IsKind(STANDARD_TYPE(StepVisual_CameraModelD3))) + { continue; + } occ::handle anObj = new XCAFView_Object(); // Import attributes of view occ::handle aCameraModel = @@ -5306,9 +5953,13 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& occ::handle aViewVolume = aCameraModel->PerspectiveOfVolume(); XCAFView_ProjectionType aType = XCAFView_ProjectionType_NoCamera; if (aViewVolume->ProjectionType() == StepVisual_copCentral) + { aType = XCAFView_ProjectionType_Central; + } else if (aViewVolume->ProjectionType() == StepVisual_copParallel) + { aType = XCAFView_ProjectionType_Parallel; + } anObj->SetType(aType); occ::handle aPoint = StepToGeom::MakeCartesianPoint(aViewVolume->ProjectionPoint(), aLocalFactors); @@ -5317,9 +5968,13 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& anObj->SetWindowHorizontalSize(aViewVolume->ViewWindow()->SizeInX()); anObj->SetWindowVerticalSize(aViewVolume->ViewWindow()->SizeInY()); if (aViewVolume->FrontPlaneClipping()) + { anObj->SetFrontPlaneDistance(aViewVolume->FrontPlaneDistance()); + } if (aViewVolume->BackPlaneClipping()) + { anObj->SetBackPlaneDistance(aViewVolume->BackPlaneDistance()); + } anObj->SetViewVolumeSidesClipping(aViewVolume->ViewVolumeSidesClipping()); // Clipping plane occ::handle aClippingCameraModel = @@ -5339,7 +5994,9 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& // Collect shapes and GDTs if (aDModel.IsNull()) + { return false; + } NCollection_Sequence aShapes, aGDTs; Interface_EntityIterator anIter = aGraph.Shareds(aDModel); for (; anIter.More(); anIter.Next()) @@ -5361,7 +6018,9 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& for (; aDMIAIter.More(); aDMIAIter.Next()) { if (!aDMIAIter.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation))) + { continue; + } occ::handle aDMIA = occ::down_cast(aDMIAIter.Value()); TDF_Label aGDTL; @@ -5371,7 +6030,9 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& isFind = myGDTMap.Find(anIter.Value(), aGDTL); } if (isFind) + { aGDTs.Append(aGDTL); + } } } else if (anIter.Value()->IsKind(STANDARD_TYPE(StepVisual_AnnotationPlane))) @@ -5384,13 +6045,17 @@ bool STEPCAFControl_Reader::ReadViews(const occ::handle& for (; aDMIAIter.More(); aDMIAIter.Next()) { if (!aDMIAIter.Value()->IsKind(STANDARD_TYPE(StepAP242_DraughtingModelItemAssociation))) + { continue; + } occ::handle aDMIA = occ::down_cast(aDMIAIter.Value()); TDF_Label aGDTL; bool isFind = myGDTMap.Find(aDMIA->Definition().Value(), aGDTL); if (isFind) + { aGDTs.Append(aGDTL); + } } } } @@ -5414,24 +6079,34 @@ TDF_Label STEPCAFControl_Reader::SettleShapeData( { TDF_Label aResult = theLab; if (theItem.IsNull()) + { return aResult; + } occ::handle hName = theItem->Name(); if (hName.IsNull() || hName->IsEmpty()) + { return aResult; + } occ::handle aBinder = TP->Find(theItem); if (aBinder.IsNull()) + { return aResult; + } TopoDS_Shape aShape = TransferBRep::ShapeResult(aBinder); if (aShape.IsNull()) + { return aResult; + } // Allocate sub-Label aResult = theShapeTool->AddSubShape(theLab, aShape); if (aResult.IsNull()) + { return aResult; + } TCollection_AsciiString aName = hName->String(); TDataStd_Name::Set(aResult, aName); @@ -5475,7 +6150,9 @@ void collectRepresentationItems( occ::handle aRepr = occ::down_cast(aRelationship->Rep2()); if (!aRepr.IsNull()) + { collectRepresentationItems(theGraph, aRepr, theItems); + } } } } @@ -5494,7 +6171,9 @@ void STEPCAFControl_Reader::ExpandSubShapes( NCollection_Map> aRepItems; occ::handle aStepModel = occ::down_cast(TP->Model()); if (!aStepModel->InternalParameters.ReadSubshapeNames) + { return; + } const Interface_Graph& Graph = Reader().WS()->Graph(); @@ -5507,7 +6186,9 @@ void STEPCAFControl_Reader::ExpandSubShapes( const TopoDS_Shape& aRootShape = it.Key(); const occ::handle& aPDef = it.Value(); if (aPDef.IsNull()) + { continue; + } // Find SDR by Product occ::handle aSDR; @@ -5518,34 +6199,46 @@ void STEPCAFControl_Reader::ExpandSubShapes( const occ::handle& aReferer = entIt.Value(); aSDR = occ::down_cast(aReferer); if (!aSDR.IsNull()) + { break; + } } if (aSDR.IsNull()) + { continue; + } // Access shape representation occ::handle aShapeRepr = occ::down_cast(aSDR->UsedRepresentation()); if (aShapeRepr.IsNull()) + { continue; + } // Access representation items NCollection_Sequence> aReprItems; collectRepresentationItems(Graph, aShapeRepr, aReprItems); if (aReprItems.Length() == 0) + { continue; + } if (!myMap.IsBound(aRootShape)) + { continue; + } TDF_Label aRootLab = myMap.Find(aRootShape); // Do not add subshapes to assembly, // they will be processed with corresponding Shape_Product_Definition of necessary part. if (ShapeTool->IsAssembly(aRootLab)) + { continue; + } NCollection_Sequence> aMSBSeq; NCollection_Sequence> aSBSMSeq; @@ -5556,9 +6249,13 @@ void STEPCAFControl_Reader::ExpandSubShapes( { const occ::handle& aTRepr = aReprItems.Value(i); if (aTRepr->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) + { aMSBSeq.Append(aTRepr); + } else if (aTRepr->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) + { aSBSMSeq.Append(aTRepr); + } } // Insert intermediate OCAF Labels for SOLIDs in case there are more @@ -5570,14 +6267,18 @@ void STEPCAFControl_Reader::ExpandSubShapes( { // Put additional Label for SOLID if (doInsertSolidLab) + { SettleShapeData(aMSBSeq.Value(i), aRootLab, ShapeTool, TP); + } ExpandManifoldSolidBrep(aRootLab, aMSBSeq.Value(i), TP, ShapeTool); } // Expand Shell-Based Surface Models for (int i = 1; i <= aSBSMSeq.Length(); ++i) + { ExpandSBSM(aRootLab, aSBSMSeq.Value(i), TP, ShapeTool); + } } } @@ -5617,9 +6318,13 @@ void STEPCAFControl_Reader::ExpandSBSM(TDF_Label& occ::handle aClosedShell = aShell.ClosedShell(); if (!anOpenShell.IsNull()) + { aCFS = anOpenShell; + } else + { aCFS = aClosedShell; + } ExpandShell(aCFS, ShapeLab, TP, ShapeTool); } @@ -5641,7 +6346,9 @@ void STEPCAFControl_Reader::ExpandShell(const occ::handle& aFace = aFaces->Value(f); if (aFace.IsNull()) + { continue; + } // Record CAF data SettleShapeData(aFace, RootLab, ShapeTool, TP); @@ -5649,7 +6356,9 @@ void STEPCAFControl_Reader::ExpandShell(const occ::handle>> aWires = aFace->Bounds(); if (aWires.IsNull()) + { continue; + } for (int w = aWires->Lower(); w <= aWires->Upper(); ++w) { const occ::handle& aWire = aWires->Value(w)->Bound(); @@ -5660,7 +6369,9 @@ void STEPCAFControl_Reader::ExpandShell(const occ::handleIsInstance(STANDARD_TYPE(StepShape_EdgeLoop))) + { continue; + } // Access edges occ::handle anEdgeLoop = occ::down_cast(aWire); @@ -5670,10 +6381,14 @@ void STEPCAFControl_Reader::ExpandShell(const occ::handle anOrientedEdge = anEdges->Value(e); if (anOrientedEdge.IsNull()) + { continue; + } occ::handle anEdge = anOrientedEdge->EdgeElement(); if (anEdge.IsNull()) + { continue; + } // Record CAF data SettleShapeData(anEdge, RootLab, ShapeTool, TP); @@ -6302,22 +7017,30 @@ bool STEPCAFControl_Reader::fillAttributes( occ::handle aPropDefRepr = occ::down_cast(aSharingListOfPD.Value()); if (aPropDefRepr.IsNull()) + { continue; + } occ::handle aUsedRepr = aPropDefRepr->UsedRepresentation(); if (aUsedRepr.IsNull()) + { continue; + } occ::handle>> aReprItems = aUsedRepr->Items(); if (aReprItems.IsNull()) + { continue; + } for (int anIndex = aReprItems->Lower(); anIndex <= aReprItems->Upper(); anIndex++) { occ::handle anItem = aReprItems->Value(anIndex); if (anItem.IsNull()) + { continue; + } if (anItem->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) { @@ -6357,7 +7080,9 @@ bool STEPCAFControl_Reader::fillAttributes( { occ::handle aDUElem = aDUnit->ElementsValue(anInd); if (aDUElem.IsNull()) + { continue; + } double anExp = aDUElem->Exponent(); occ::handle aNUnit = aDUElem->Unit(); @@ -6391,7 +7116,9 @@ bool STEPCAFControl_Reader::fillAttributes( STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(aNUnit, theLocalFactors); if (anUnitCtx.AreaDone()) + { aParam = anUnitCtx.AreaFactor(); + } if (anUnitCtx.LengthDone()) { double aLengthFactor = anUnitCtx.LengthFactor(); @@ -6422,11 +7149,17 @@ bool STEPCAFControl_Reader::fillAttributes( STEPConstruct_UnitContext anUnitCtx; anUnitCtx.ComputeFactors(aNUnit, theLocalFactors); if (anUnitCtx.AreaDone()) + { aParam = anUnitCtx.AreaFactor(); + } if (anUnitCtx.VolumeDone()) + { aParam = anUnitCtx.VolumeFactor(); + } if (anUnitCtx.LengthDone()) + { aParam = anUnitCtx.LengthFactor(); + } aValue *= aParam; } diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx index fe23587757..0f7ca4662a 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -228,7 +228,9 @@ static bool GetLabelName(const TDF_Label& theL, occ::handleGet(); if (aName.IsEmpty()) + { return false; + } // set name, removing spaces around it TCollection_AsciiString aBuffer(aName); @@ -405,7 +407,9 @@ bool STEPCAFControl_Writer::Transfer(const occ::handle& theDoc { occ::handle aShTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main()); if (aShTool.IsNull()) + { return false; + } myRootLabels.Clear(); myRootLabels.Add(theDoc->Main().Root()); @@ -496,7 +500,9 @@ bool STEPCAFControl_Writer::Perform(const occ::handle& theDoc, const Message_ProgressRange& theProgress) { if (!Transfer(theDoc, STEPControl_AsIs, nullptr, theProgress)) + { return false; + } return Write(theFileName) == IFSelect_RetDone; } @@ -508,7 +514,9 @@ bool STEPCAFControl_Writer::Perform(const occ::handle& theDoc, const Message_ProgressRange& theProgress) { if (!Transfer(theDoc, theParams, STEPControl_AsIs, nullptr, theProgress)) + { return false; + } return Write(theFileName) == IFSelect_RetDone; } @@ -519,7 +527,9 @@ bool STEPCAFControl_Writer::Perform(const occ::handle& theDoc, const Message_ProgressRange& theProgress) { if (!Transfer(theDoc, STEPControl_AsIs, nullptr, theProgress)) + { return false; + } return Write(theFileName.ToCString()) == IFSelect_RetDone; } @@ -530,7 +540,9 @@ bool STEPCAFControl_Writer::ExternFile(const TDF_Label& t { theExtFile.Nullify(); if (!myLabEF.IsBound(theLabel)) + { return false; + } theExtFile = myLabEF.Find(theLabel); return true; } @@ -542,7 +554,9 @@ bool STEPCAFControl_Writer::ExternFile(const char* const t { theExtFile.Nullify(); if (!myFiles.IsEmpty() || !myFiles.IsBound(theName)) + { return false; + } theExtFile = myFiles.Find(theName); return true; } @@ -603,7 +617,9 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW const Message_ProgressRange& theProgress) { if (theLabels.IsEmpty()) + { return false; + } occ::handle anActor = occ::down_cast(theWriter.WS()->NormAdaptor()->ActorWrite()); @@ -623,11 +639,15 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW Message_ProgressRange aRange = aPS.Next(); TDF_Label aCurL = aLabelIter.Value(); if (myLabels.IsBound(aCurL)) + { continue; // already processed + } TopoDS_Shape aCurShape = XCAFDoc_ShapeTool::GetShape(aCurL); if (aCurShape.IsNull()) + { continue; + } TopoDS_Shape aShapeForBind = aCurShape; // write shape either as a whole, or as multifile (with extern refs) if (!theIsMulti) @@ -658,17 +678,23 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW if (XCAFDoc_ShapeTool::GetReferredShape(aCurL, aRefL)) { if (XCAFDoc_ShapeTool::IsAssembly(aRefL)) + { XCAFDoc_ShapeTool::GetComponents(aRefL, aCompLabels, true); + } } if (!XCAFDoc_ShapeTool::IsFree(aCurL)) + { aCurL = aCurL.Father(); + } } else { // fill sequence of (sub) shapes for which attributes should be written // and set actor to handle assemblies in a proper way if (XCAFDoc_ShapeTool::IsAssembly(aCurL)) + { XCAFDoc_ShapeTool::GetComponents(aCurL, aCompLabels, true); + } } for (NCollection_Sequence::Iterator aCompIter(aCompLabels); aCompIter.More(); @@ -706,7 +732,9 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW aSubLabels.Append(aCurL); if (XCAFDoc_ShapeTool::IsAssembly(aCurL) || XCAFDoc_ShapeTool::IsReference(aCurL)) + { anActor->RegisterAssembly(aCurShape); + } theWriter.Transfer(aCurShape, theMode, aModel->InternalParameters, false, aRange); anActor->SetStdMode(true); // restore default behaviour @@ -718,7 +746,9 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW TopoDS_Shape aSass = transferExternFiles(aCurL, theMode, aSubLabels, aLocalFactors, theIsMulti, aPS1.Next()); if (aPS1.UserBreak()) + { return false; + } DESTEP_Parameters::WriteMode_Assembly assemblymode = aModel->InternalParameters.WriteAssembly; aModel->InternalParameters.WriteAssembly = DESTEP_Parameters::WriteMode_Assembly_On; @@ -727,28 +757,38 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW } } if (aPS.UserBreak()) + { return false; + } theWriter.WS()->ComputeGraph(true); // Setting to clear and regenerate graph // write names if (GetNameMode()) + { writeNames(theWriter.WS(), aSubLabels); + } if (!theIsMulti) { // write colors if (GetColorMode()) + { writeColors(theWriter.WS(), aSubLabels); + } // write layers if (GetLayerMode()) + { writeLayers(theWriter.WS(), aSubLabels); + } // write SHUO entities if (GetSHUOMode() && !theIsExternFile) + { // do not store SHUO for extern reference for the moment writeSHUOs(theWriter.WS(), aSubLabels); + } // write G&DTs if (GetDimTolMode()) @@ -765,7 +805,9 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW // write Materials if (GetMaterialMode()) + { writeMaterials(theWriter.WS(), aSubLabels); + } // register all MDGPRs in model for (NCollection_DataMapComputeGraph(true); @@ -813,18 +859,24 @@ bool STEPCAFControl_Writer::transfer(STEPControl_Writer& theW // Access name recorded in OCAF TDataStd_Name attribute occ::handle aHSubName = new TCollection_HAsciiString; if (!GetLabelName(aSubL, aHSubName)) + { continue; + } // Access topological data TopoDS_Shape aSubS = XCAFDoc_ShapeTool::GetShape(aSubL); if (aSubS.IsNull()) + { continue; + } // Access the correspondent STEP Representation Item occ::handle aRI; occ::handle aShMapper = TransferBRep::ShapeMapper(aFP, aSubS); if (!aFP->FindTypedTransient(aShMapper, STANDARD_TYPE(StepRepr_RepresentationItem), aRI)) + { continue; + } // Record the name aRI->SetName(aHSubName); @@ -867,7 +919,9 @@ TopoDS_Shape STEPCAFControl_Writer::transferExternFiles(const TDF_Label& // construct the name for extern file occ::handle aBaseName = new TCollection_HAsciiString; if (thePrefix && thePrefix[0]) + { aBaseName->AssignCat(thePrefix); + } GetLabelName(theLabel, aBaseName); occ::handle aNewName = new TCollection_HAsciiString(aBaseName); aNewName->AssignCat(".stp"); @@ -880,7 +934,9 @@ TopoDS_Shape STEPCAFControl_Writer::transferExternFiles(const TDF_Label& aNewName->AssignCat(TCollection_AsciiString(k).ToCString()); aNewName->AssignCat(".stp"); if (!myFiles.IsBound(aNewName->ToCString())) + { break; + } } } @@ -916,7 +972,9 @@ TopoDS_Shape STEPCAFControl_Writer::transferExternFiles(const TDF_Label& // else iterate on components add create structure of empty compounds // representing the assembly else if (XCAFDoc_ShapeTool::IsAssembly(theLabel)) + { XCAFDoc_ShapeTool::GetComponents(theLabel, aCompLabels, false); + } theLabels.Append(aLabel); Message_ProgressScope aPS(theProgress, nullptr, aCompLabels.Length()); @@ -928,7 +986,9 @@ TopoDS_Shape STEPCAFControl_Writer::transferExternFiles(const TDF_Label& const TDF_Label& aCurL = aLabelIter.Value(); TDF_Label aRefL; if (!XCAFDoc_ShapeTool::GetReferredShape(aCurL, aRefL)) + { continue; + } TopoDS_Shape aShComp = transferExternFiles(aRefL, theMode, theLabels, theLocalFactors, thePrefix, aPS.Next()); aShComp.Location(XCAFDoc_ShapeTool::GetLocation(aCurL)); @@ -944,7 +1004,9 @@ bool STEPCAFControl_Writer::writeExternRefs(const occ::handle& theLabels) const { if (theLabels.IsEmpty()) + { return false; + } const occ::handle& aTW = theWS->TransferWriter(); const occ::handle& aFP = aTW->FinderProcess(); @@ -957,16 +1019,22 @@ bool STEPCAFControl_Writer::writeExternRefs(const occ::handle anExtFile; if (!ExternFile(aLab, anExtFile)) + { continue; // should never be + } // find SDR if (!myLabels.IsBound(aLab)) + { continue; // not recorded as translated, skip + } TopoDS_Shape aShape = myLabels.Find(aLab); occ::handle aSDR; @@ -1027,7 +1095,9 @@ static int FindEntities(const occ::handle& t occ::handle aMapper = TransferBRep::ShapeMapper(theFP, theShape); occ::handle aBinder = theFP->Find(aMapper); if (aBinder.IsNull()) + { return 0; + } occ::handle aTransientListBinder = // occ::down_cast( bnd->Next(true) ); @@ -1040,7 +1110,9 @@ static int FindEntities(const occ::handle& t occ::handle aLocalItem = STEPConstruct::FindEntity(theFP, anIter.Value(), theLocation); if (aLocalItem.IsNull()) + { continue; + } aResCount++; theSeqRI.Append(aLocalItem); } @@ -1053,7 +1125,9 @@ static int FindEntities(const occ::handle& t occ::handle anEntity = aTransientListBinder->Transient(anInd); anItem = occ::down_cast(anEntity); if (anItem.IsNull()) + { continue; + } aResCount++; theSeqRI.Append(anItem); } @@ -1123,7 +1197,9 @@ static bool getStyledItem( } } if (!isSameMonSolBR) + { continue; + } } for (NCollection_HArray1>::Iterator aStyleIter(aSelItm->Styles()->Array1()); @@ -1134,7 +1210,9 @@ static bool getStyledItem( // check for PSA for top-level (not Presentation style by context for NAUO) if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) + { continue; + } theResSelItem = aSelItm; anIsFound = true; } @@ -1157,7 +1235,9 @@ static bool setDefaultInstanceColor(const occ::handle& th // check for PSA for top-level (not Presentation style by context for NAUO) if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) + { return false; + } // get style select from father PSA if (aFatherPSA->NbStyles() > 0) @@ -1173,11 +1253,17 @@ static bool setDefaultInstanceColor(const occ::handle& th StepVisual_PresentationStyleSelect aPSS; const StepVisual_PresentationStyleSelect& anOlDPSS = aFatherStyleIter.Value(); if (!anOlDPSS.PointStyle().IsNull()) + { aPSS.SetValue(anOlDPSS.PointStyle()); + } else if (!anOlDPSS.CurveStyle().IsNull()) + { aPSS.SetValue(anOlDPSS.CurveStyle()); + } else if (!anOlDPSS.SurfaceStyleUsage().IsNull()) + { aPSS.SetValue(anOlDPSS.SurfaceStyleUsage()); + } else { anIsFound = false; @@ -1216,23 +1302,35 @@ static void MakeSTEPStyles( { // skip already processed shapes if (!theMap.Add(theShape)) + { return; + } // check if shape has its own style (r inherits from ancestor) XCAFPrs_Style aStyle; if (theInherit) + { aStyle = *theInherit; + } if (theSettings.Contains(theShape)) { const XCAFPrs_Style& anOwnStyle = theSettings.FindFromKey(theShape); if (!anOwnStyle.IsVisible()) + { aStyle.SetVisibility(false); + } if (anOwnStyle.IsSetColorCurv()) + { aStyle.SetColorCurv(anOwnStyle.GetColorCurv()); + } if (anOwnStyle.IsSetColorSurf()) + { aStyle.SetColorSurf(anOwnStyle.GetColorSurfRGBA()); + } if (!anOwnStyle.Material().IsNull()) + { aStyle.SetMaterial(anOwnStyle.Material()); + } } // translate colors to STEP @@ -1245,7 +1343,9 @@ static void MakeSTEPStyles( aSurfColor = STEPConstruct_Styles::EncodeColor(aSurfCol.GetRGB(), theDPDCs, theColRGBs); } if (aStyle.IsSetColorCurv()) + { aCurvColor = STEPConstruct_Styles::EncodeColor(aStyle.GetColorCurv(), theDPDCs, theColRGBs); + } bool aHasOwn = (!aSurfColor.IsNull() || !aCurvColor.IsNull() || !aStyle.IsVisible()); @@ -1259,11 +1359,15 @@ static void MakeSTEPStyles( NCollection_Sequence> aSeqRI; int aNbEntities = FindEntities(theStyles.FinderProcess(), theShape, aLocation, aSeqRI); if (aNbEntities <= 0) + { Message::SendTrace() << "Warning: Cannot find RI for " << theShape.TShape()->DynamicType()->Name() << "\n"; + } // Get overridden style gka 10.06.03 if (theIsComponent && aNbEntities > 0) + { getStyledItem(theShape, theShTool, theStyles, theOverride, theMapCompMDGPR); + } for (NCollection_Sequence>::Iterator anEntIter(aSeqRI); anEntIter.More(); @@ -1299,7 +1403,9 @@ static void MakeSTEPStyles( STEPConstruct_RenderingProperties(), theIsComponent); if (theIsComponent) + { setDefaultInstanceColor(theOverride, aPSA); + } } // end of component case @@ -1311,7 +1417,9 @@ static void MakeSTEPStyles( // iterate on subshapes (except vertices :) if (theShape.ShapeType() == TopAbs_EDGE) + { return; + } if (theIsComponent) { return; @@ -1339,7 +1447,9 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle const NCollection_Sequence& theLabels) { if (theLabels.IsEmpty()) + { return false; + } STEPConstruct_Styles Styles(theWS); NCollection_DataMap> DPDCs; @@ -1360,7 +1470,9 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle // PTV 22.01.2003 Write color for instances. NCollection_Sequence compLabels; if (!aSTool->GetComponents(aLabel, compLabels)) + { continue; + } writeColors(theWS, compLabels); continue; } @@ -1370,7 +1482,9 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle // (all the colors set under that label will be put into that context) TopoDS_Shape aShape; if (!XCAFDoc_ShapeTool::GetShape(aLabel, aShape)) + { continue; + } bool anIsComponent = aSTool->IsComponent(aLabel) || myPureRefLabels.IsBound(aLabel); TopoDS_Shape aTopSh = aShape; occ::handle aContext = Styles.FindContext(aShape); @@ -1378,12 +1492,16 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle { TDF_Label aTopShL = aSTool->FindShape(aShape, false); if (aTopShL.IsNull()) + { continue; + } aTopSh = aSTool->GetShape(aTopShL); aContext = Styles.FindContext(aTopSh); } if (aContext.IsNull()) + { continue; + } // collect settings set on that label NCollection_IndexedDataMap aSettings; @@ -1411,9 +1529,13 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle aStyle.SetColorSurf(aColor); } if (XCAFDoc_ColorTool::GetColor(aSeqValue, XCAFDoc_ColorSurf, aColor)) + { aStyle.SetColorSurf(aColor); + } if (XCAFDoc_ColorTool::GetColor(aSeqValue, XCAFDoc_ColorCurv, aColor)) + { aStyle.SetColorCurv(aColor.GetRGB()); + } if (!aStyle.IsSetColorSurf()) { occ::handle aVisMat = @@ -1425,18 +1547,26 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle } } if (!aStyle.IsSetColorCurv() && !aStyle.IsSetColorSurf() && anIsVisible) + { continue; + } TopoDS_Shape aSub = XCAFDoc_ShapeTool::GetShape(aSeqValue); XCAFPrs_Style* aMapStyle = aSettings.ChangeSeek(aSub); if (aMapStyle == nullptr) + { aSettings.Add(aSub, aStyle); + } else + { *aMapStyle = aStyle; + } } if (aSettings.Extent() <= 0) + { continue; + } // iterate on subshapes and create STEP styles occ::handle anOverride; @@ -1470,7 +1600,9 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle } Styles.CreateMDGPR(aContext, aMDGPR, aStepModel); if (!aMDGPR.IsNull()) + { myMapCompMDGPR.Bind(aTopSh, aMDGPR); + } } else { @@ -1503,10 +1635,14 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle aMDGPR->Items(); int oldLengthlen = 0; if (!anOldItems.IsNull()) + { oldLengthlen = anOldItems->Length(); + } const int aNbIt = oldLengthlen + Styles.NbStyles(); if (!aNbIt) + { continue; + } occ::handle>> aNewItems = new NCollection_HArray1>(1, aNbIt); int anElemInd = 1; @@ -1520,7 +1656,9 @@ bool STEPCAFControl_Writer::writeColors(const occ::handle } if (aNewItems->Length() > 0) + { aMDGPR->SetItems(aNewItems); + } } // end of work with CDSR } if (!anIsVisible) @@ -1551,7 +1689,9 @@ bool STEPCAFControl_Writer::writeNames(const occ::handle& const NCollection_Sequence& theLabels) const { if (theLabels.IsEmpty()) + { return false; + } // get working data const occ::handle& aTW = theWS->TransferWriter(); @@ -1564,7 +1704,9 @@ bool STEPCAFControl_Writer::writeNames(const occ::handle& const TDF_Label& aLabel = aLabelIter.Value(); // find target STEP entity for the current shape if (!myLabels.IsBound(aLabel)) + { continue; // not recorded as translated, skip + } // get name occ::handle aHName = new TCollection_HAsciiString; if (!GetLabelName(aLabel, aHName)) @@ -1585,7 +1727,9 @@ bool STEPCAFControl_Writer::writeNames(const occ::handle& occ::handle aNAUO = aPDS->Definition().ProductDefinitionRelationship(); if (!aNAUO.IsNull()) + { aNAUO->SetName(aHName); + } TopoDS_Shape anInternalAssembly; if (myPureRefLabels.Find(aLabel, anInternalAssembly)) { @@ -1605,10 +1749,14 @@ bool STEPCAFControl_Writer::writeNames(const occ::handle& // set the name to the PRODUCT occ::handle aPropD = aSDR->Definition().PropertyDefinition(); if (aPropD.IsNull()) + { continue; + } occ::handle aPD = aPropD->Definition().ProductDefinition(); if (aPD.IsNull()) + { continue; + } occ::handle aProd = aPD->Formation()->OfProduct(); aProd->SetId(aHName); @@ -1663,11 +1811,15 @@ bool STEPCAFControl_Writer::writeMetadataForLabel(const occ::handle aNamedData; if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), aNamedData)) + { return false; // No metadata on this label + } // Find target STEP entity for the current shape: if (!myLabels.IsBound(theLabel)) + { return false; // Not recorded as translated, skip + } const TopoDS_Shape& aShape = myLabels.Find(theLabel); occ::handle aSDR; @@ -1682,11 +1834,15 @@ bool STEPCAFControl_Writer::writeMetadataForLabel(const occ::handle aPropDef = aSDR->Definition().PropertyDefinition(); if (aPropDef.IsNull()) + { return false; + } const occ::handle aProdDef = aPropDef->Definition().ProductDefinition(); if (aProdDef.IsNull()) + { return false; + } // Export string metadata. const NCollection_DataMap& aStringMap = @@ -1840,13 +1996,17 @@ static bool WritePropsForLabel(const occ::handle& const char* const theIsMulti) { if (theLabel.IsNull()) + { return false; + } STEPConstruct_ValidationProps aProps(theWS); TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theLabel); if (aShape.IsNull()) + { return false; + } if (!theIsMulti || XCAFDoc_ShapeTool::IsAssembly(theLabel)) { @@ -1894,7 +2054,9 @@ bool STEPCAFControl_Writer::writeValProps(const occ::handle::Iterator aLabelIter(theLabels); aLabelIter.More(); @@ -1915,7 +2077,9 @@ bool STEPCAFControl_Writer::writeLayers(const occ::handle { if (theLabels.IsEmpty()) + { return false; + } // get working data const occ::handle& aModel = theWS->Model(); @@ -1940,7 +2104,9 @@ bool STEPCAFControl_Writer::writeLayers(const occ::handle NCollection_Sequence aShapeLabels; XCAFDoc_LayerTool::GetShapesOfLayer(aLayerL, aShapeLabels); if (aShapeLabels.IsEmpty()) + { continue; + } // name of layer: if not set, is considered as being empty occ::handle aHName = new TCollection_HAsciiString; @@ -1954,7 +2120,9 @@ bool STEPCAFControl_Writer::writeLayers(const occ::handle { const TDF_Label& aShLabel = aShapeIter.Value(); if (aShLabel.IsNull()) + { continue; + } // there is no way to assign layer to instance in STEP if (XCAFDoc_ShapeTool::IsAssembly(aShLabel) || XCAFDoc_ShapeTool::IsReference(aShLabel)) @@ -1989,7 +2157,9 @@ bool STEPCAFControl_Writer::writeLayers(const occ::handle } } if (aSeqRI.IsEmpty()) + { continue; + } // analyze visibility occ::handle aStepLayerAs = @@ -2059,9 +2229,13 @@ static bool getSHUOstyle(const TDF_Label& theSHUOlab, XCAFPrs_Style& theSHUOstyl theSHUOstyle.SetColorSurf(aColor); } if (XCAFDoc_ColorTool::GetColor(theSHUOlab, XCAFDoc_ColorSurf, aColor)) + { theSHUOstyle.SetColorSurf(aColor); + } if (XCAFDoc_ColorTool::GetColor(theSHUOlab, XCAFDoc_ColorCurv, aColor)) + { theSHUOstyle.SetColorCurv(aColor); + } if (!theSHUOstyle.IsSetColorSurf()) { occ::handle aVisMat = @@ -2089,7 +2263,9 @@ static bool getProDefinitionOfNAUO(const occ::handle& bool theIsRelating) { if (theShape.IsNull()) + { return false; + } // get CDSR const occ::handle& aTW = theWS->TransferWriter(); const occ::handle& aFP = aTW->FinderProcess(); @@ -2104,7 +2280,9 @@ static bool getProDefinitionOfNAUO(const occ::handle& // get PDS of NAUO occ::handle aPDS = aCDSR->RepresentedProductRelation(); if (aPDS.IsNull()) + { return false; + } // get the NAUO entity Interface_Graph aGraph = theWS->HGraph()->Graph(); for (Interface_EntityIterator aShareds = aGraph.Shareds(aPDS); aShareds.More(); aShareds.Next()) @@ -2116,14 +2294,22 @@ static bool getProDefinitionOfNAUO(const occ::handle& } } if (theNAUO.IsNull()) + { return false; + } // get Relatinf or Related product definition if (!theIsRelating) + { thePD = theNAUO->RelatedProductDefinition(); + } else + { thePD = theNAUO->RelatingProductDefinition(); + } if (thePD.IsNull()) + { return false; + } return true; } @@ -2146,10 +2332,14 @@ static bool writeSHUO(const occ::handle& theS { // the top SHUO if (aNextUsageLabs.Length() < 1) + { return false; + } XCAFDoc_ShapeTool::GetSHUO(aNextUsageLabs.Value(1), aNuSHUO); if (aNuSHUO.IsNull()) + { return false; + } // get relating product definition TopoDS_Shape aTopCompShape = XCAFDoc_ShapeTool::GetShape(theSHUO->Label().Father()); occ::handle aRelatingNAUO; @@ -2192,12 +2382,16 @@ static bool writeSHUO(const occ::handle& theS { // store SHUO recursive if (aNextUsageLabs.Length() > 1) + { Message::SendTrace() << "Warning: store only one next_usage of current SHUO" << "\n"; + } XCAFDoc_ShapeTool::GetSHUO(aNextUsageLabs.Value(1), aNuSHUO); occ::handle aNUEntSHUO = new StepRepr_SpecifiedHigherUsageOccurrence; if (!writeSHUO(aNuSHUO, theWS, aNUEntSHUO, theNAUOShape, theRelatingPD, theIsDeepest)) + { return false; + } // store the deepest SHUO to the dociment TopoDS_Shape aNUSh, aUUSh; @@ -2264,7 +2458,9 @@ static bool createSHUOStyledItem( aSurfColor = STEPConstruct_Styles::EncodeColor(aSurfCol.GetRGB()); } if (theStyle.IsSetColorCurv()) + { aCurvColor = STEPConstruct_Styles::EncodeColor(theStyle.GetColorCurv()); + } bool isComponent = true; // cause need to get PSBC occ::handle anItem; // set default color for invisible SHUO. @@ -2293,7 +2489,9 @@ static bool createSHUOStyledItem( STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), aCDSR); if (aCDSR.IsNull()) + { return false; + } // find context occ::handle aContext = aStyles.FindContext(theShape); TopoDS_Shape aTopSh = theShape; @@ -2301,19 +2499,25 @@ static bool createSHUOStyledItem( { TDF_Label aTopShL = theSTool->FindShape(theShape, false); if (aTopShL.IsNull()) + { return false; + } aTopSh = XCAFDoc_ShapeTool::GetShape(aTopShL); aContext = aStyles.FindContext(aTopSh); } if (aContext.IsNull()) + { return false; + } // get representation item of the shape TopLoc_Location aLocation; NCollection_Sequence> aSeqRI; FindEntities(aFP, theShape, aLocation, aSeqRI); if (aSeqRI.Length() <= 0) + { Message::SendTrace() << "Warning: Cannot find RI for " << theShape.TShape()->DynamicType()->Name() << "\n"; + } anItem = occ::down_cast(aSeqRI(1)); // get overridden styled item getStyledItem(theShape, theSTool, aStyles, anOverride, theMapCompMDGPR); @@ -2333,7 +2537,9 @@ static bool createSHUOStyledItem( occ::handle aMDGPR; aStyles.CreateMDGPR(aContext, aMDGPR, aStepModel); if (!aMDGPR.IsNull()) + { theMapCompMDGPR.Bind(aTopSh, aMDGPR); + } } else if (!aTopSh.IsNull() && theMapCompMDGPR.IsBound(aTopSh)) { @@ -2345,7 +2551,9 @@ static bool createSHUOStyledItem( aMDGPR->Items(); int anOldLengthlen = 0; if (!anOldItems.IsNull()) + { anOldLengthlen = anOldItems->Length(); + } // create new array of styled items by an olds and new one occ::handle>> aNewItems = new NCollection_HArray1>(1, anOldLengthlen + 1); @@ -2360,7 +2568,9 @@ static bool createSHUOStyledItem( aNewItems->SetValue(aSetStyleInd++, aSTEPstyle); // init MDGPR be new array of styled items if (aNewItems->Length() > 0) + { aMDGPR->SetItems(aNewItems); + } } else { @@ -2398,7 +2608,9 @@ bool STEPCAFControl_Writer::writeSHUOs(const occ::handle& const NCollection_Sequence& theLabels) { if (theLabels.IsEmpty()) + { return false; + } // map of transferred SHUO NCollection_Map> aMapOfMainSHUO; @@ -2408,7 +2620,9 @@ bool STEPCAFControl_Writer::writeSHUOs(const occ::handle& { const TDF_Label& aLabel = aLabelIter.Value(); if (!myLabels.IsBound(aLabel)) + { continue; // not recorded as translated, skip + } if (!XCAFDoc_ShapeTool::IsAssembly(aLabel)) { continue; @@ -2435,9 +2649,13 @@ bool STEPCAFControl_Writer::writeSHUOs(const occ::handle& // check is it SHUO of upper_usage XCAFDoc_ShapeTool::GetSHUOUpperUsage(aSHUOlab, aUpLabels); if (aUpLabels.Length() > 0) + { continue; // transfer only main SHUO + } if (aMapOfMainSHUO.Contains(aSHUO)) + { continue; // do not try to transfer SHUO twice + } aMapOfMainSHUO.Add(aSHUO); // check if it is styled SHUO XCAFPrs_Style aSHUOstyle; @@ -2496,7 +2714,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle& theEC) { if (theEnt.IsNull()) + { return false; + } if (!theEnt->IsKind(STANDARD_TYPE(StepShape_EdgeCurve)) && !theEnt->IsKind(STANDARD_TYPE(StepShape_AdvancedFace))) { @@ -2514,14 +2734,18 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle anOE = occ::down_cast(aSharingsIter.Value()); if (anOE.IsNull()) + { continue; + } for (Interface_EntityIterator aSubs1 = theGraph.Sharings(anOE); aSubs1.More() && theAF.IsNull(); aSubs1.Next()) { occ::handle aEL = occ::down_cast(aSubs1.Value()); if (aEL.IsNull()) + { continue; + } for (Interface_EntityIterator aSubs2 = theGraph.Sharings(aEL); aSubs2.More() && theAF.IsNull(); aSubs2.Next()) @@ -2529,7 +2753,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle aFB = occ::down_cast(aSubs2.Value()); if (aFB.IsNull()) + { continue; + } for (Interface_EntityIterator aSubs3 = theGraph.Sharings(aFB); aSubs3.More() && theAF.IsNull(); aSubs3.Next()) @@ -2541,7 +2767,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph } } if (theAF.IsNull()) + { return false; + } for (Interface_EntityIterator aSharingsIter = theGraph.Sharings(theAF); aSharingsIter.More() && thePDS.IsNull(); @@ -2550,7 +2778,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle aCFS = occ::down_cast(aSharingsIter.Value()); if (aCFS.IsNull()) + { continue; + } for (Interface_EntityIterator aSubs1 = theGraph.Sharings(aCFS); aSubs1.More() && thePDS.IsNull(); aSubs1.Next()) @@ -2558,7 +2788,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle aRI = occ::down_cast(aSubs1.Value()); if (aRI.IsNull()) + { continue; + } for (Interface_EntityIterator aSubs2 = theGraph.Sharings(aRI); aSubs2.More() && thePDS.IsNull(); aSubs2.Next()) @@ -2566,7 +2798,9 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle aSR = occ::down_cast(aSubs2.Value()); if (aSR.IsNull()) + { continue; + } theRC = aSR->ContextOfItems(); for (Interface_EntityIterator aSubs3 = theGraph.Sharings(aSR); aSubs3.More() && thePDS.IsNull(); @@ -2575,10 +2809,14 @@ static bool FindPDSforDGT(const Interface_Graph& theGraph occ::handle aSDR = occ::down_cast(aSubs3.Value()); if (aSDR.IsNull()) + { continue; + } occ::handle aPropD = aSDR->Definition().PropertyDefinition(); if (aPropD.IsNull()) + { continue; + } thePDS = occ::down_cast(aPropD); } } @@ -2597,7 +2835,9 @@ static occ::handle FindPDS( occ::handle& theRC) { if (theEnt.IsNull()) + { return nullptr; + } occ::handle aPDS; // try to find shape_representation in sharings @@ -2607,7 +2847,9 @@ static occ::handle FindPDS( occ::handle aSR = occ::down_cast(anIter.Value()); if (aSR.IsNull()) + { continue; + } theRC = aSR->ContextOfItems(); Interface_EntityIterator aSDRIt = theGraph.Sharings(aSR); for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) @@ -2615,15 +2857,21 @@ static occ::handle FindPDS( occ::handle aSDR = occ::down_cast(aSDRIt.Value()); if (aSDR.IsNull()) + { continue; + } occ::handle aPropD = aSDR->Definition().PropertyDefinition(); if (aPropD.IsNull()) + { continue; + } aPDS = occ::down_cast(aPropD); } } if (!aPDS.IsNull()) + { return aPDS; + } for (Interface_EntityIterator anIter = theGraph.Sharings(theEnt); anIter.More(); anIter.Next()) { @@ -2632,7 +2880,9 @@ static occ::handle FindPDS( { aPDS = FindPDS(theGraph, anIter.Value(), theRC); if (!aPDS.IsNull()) + { return aPDS; + } } } return aPDS; @@ -2688,7 +2938,9 @@ static StepBasic_Unit GetUnit(const occ::handle& } } if (aCurrentUnit.IsNull()) + { aCurrentUnit = new StepBasic_SiUnitAndPlaneAngleUnit; + } } else { @@ -2732,7 +2984,9 @@ static StepBasic_Unit GetUnit(const occ::handle& } } if (aCurrentUnit.IsNull()) + { aCurrentUnit = new StepBasic_SiUnitAndLengthUnit; + } } aUnit.SetValue(aCurrentUnit); @@ -2814,7 +3068,9 @@ occ::handle STEPCAFControl_Writer::writeShapeAspect( const occ::handle& aFP = aTW->FinderProcess(); const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return nullptr; + } Interface_Graph aGraph = aHGraph->Graph(); TopLoc_Location aLoc; @@ -2832,7 +3088,9 @@ occ::handle STEPCAFControl_Writer::writeShapeAspect( occ::handle anEnt = aSeqRI.Value(1); aPDS = FindPDS(aGraph, anEnt, aRC); if (aPDS.IsNull()) + { return nullptr; + } theRC = aRC; // Shape_Aspect @@ -2843,9 +3101,13 @@ occ::handle STEPCAFControl_Writer::writeShapeAspect( aName = new TCollection_HAsciiString(TCollection_AsciiString(aNameAttr->Get())); int aFirstSpace = aName->Search(" "); if (aFirstSpace != -1) + { aName = aName->SubString(aFirstSpace + 1, aName->Length()); + } else + { aName = new TCollection_HAsciiString(); + } } occ::handle aDescription = new TCollection_HAsciiString(); occ::handle aSA = new StepRepr_ShapeAspect; @@ -2870,7 +3132,9 @@ occ::handle STEPCAFControl_Writer::writeShapeAspect( aSDR = occ::down_cast(anEntity); } if (aSDR.IsNull()) + { return nullptr; + } // Set entities to model aGISU->Init(aName, aDescription, aDefinition, aSDR->UsedRepresentation(), anReprItems); @@ -2896,7 +3160,9 @@ void STEPCAFControl_Writer::writePresentation( const StepData_Factors& theLocalFactors) { if (thePresentation.IsNull()) + { return; + } // Get working data const occ::handle& aModel = theWS->Model(); @@ -2927,9 +3193,13 @@ void STEPCAFControl_Writer::writePresentation( aDimension.SetValue(theDimension); occ::handle aDMIAName; if (theHasSemantic) + { aDMIAName = new TCollection_HAsciiString("PMI representation to presentation link"); + } else + { aDMIAName = new TCollection_HAsciiString(); + } occ::handle aDMIA = new StepAP242_DraughtingModelItemAssociation(); aDMIA->Init(aDMIAName, @@ -2940,7 +3210,9 @@ void STEPCAFControl_Writer::writePresentation( aModel->AddWithRefs(aDMIA); if (!theHasPlane) + { return; + } // Annotation plane // Presentation Style @@ -2965,7 +3237,9 @@ void STEPCAFControl_Writer::writePresentation( occ::handle aTextPos = new StepGeom_CartesianPoint(); occ::handle> aCoords = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aCoords->SetValue(i, theTextPosition.Coord(i)); + } aTextPos->Init(new TCollection_HAsciiString(), aCoords); anAxis->SetLocation(aTextPos); aPlane->Init(new TCollection_HAsciiString(), anAxis); @@ -3002,7 +3276,9 @@ occ::handle STEPCAFControl_Writer::writeDatumAP242( const occ::handle& aFP = aTW->FinderProcess(); const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return nullptr; + } Interface_Graph aGraph = aHGraph->Graph(); occ::handle aSA; @@ -3030,12 +3306,16 @@ occ::handle STEPCAFControl_Writer::writeDatumAP242( anEnt = aSeqRI.Value(1); aPDS = FindPDS(aGraph, anEnt, aRC); if (aPDS.IsNull()) + { continue; + } occ::handle aCurrentSA = writeShapeAspect(theWS, theDatumL, aShape, aRC, aGISU); if (aCurrentSA.IsNull()) + { continue; + } aSASeq.Append(aCurrentSA); aSANum = aModel->Number(aCurrentSA); aGISUNum = aModel->Number(aGISU); @@ -3047,22 +3327,30 @@ occ::handle STEPCAFControl_Writer::writeDatumAP242( Interface_EntityIterator aSDRIt = aGraph.Sharings(aPDS); occ::handle aSDR; for (aSDRIt.Start(); aSDRIt.More() && aSDR.IsNull(); aSDRIt.Next()) + { aSDR = occ::down_cast(aSDRIt.Value()); + } if (!aSDR.IsNull()) { occ::handle aRepr = aSDR->UsedRepresentation(); if (!aRepr.IsNull()) + { aRC = aRepr->ContextOfItems(); + } } } // Find if datum has datum targets and get common datum attributes occ::handle aDatumAttr; if (!theDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { return nullptr; + } occ::handle anObject = aDatumAttr->GetObject(); if (anObject.IsNull()) + { return nullptr; + } bool isSimpleDatum = !anObject->IsDatumTarget(); occ::handle anIdentifier = anObject->GetName(); occ::handle aTargetId = @@ -3073,7 +3361,9 @@ occ::handle STEPCAFControl_Writer::writeDatumAP242( // If datum type is area, but there is no area in object, write as simple datum if (anObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area && anObject->GetDatumTarget().IsNull()) + { isSimpleDatum = true; + } // Simple datum if (isSimpleDatum) @@ -3325,19 +3615,29 @@ static void WriteDimValues(const occ::handle& StepBasic_Unit aUnit = GetUnit(theRC, isAngle); const char* aMeasureName; if (isAngle) + { aMeasureName = "POSITIVE_PLANE_ANGLE_MEASURE"; + } else + { aMeasureName = "POSITIVE_LENGTH_MEASURE"; + } // Values occ::handle>> aValues; int aNbItems = 1, aValIt = 1; if (theObject->IsDimWithRange()) + { aNbItems += 2; + } if (aModifiers.Length() > 0) + { aNbItems++; + } if (theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented) + { aNbItems++; + } aNbItems += theObject->NbDescriptions(); aValues = new NCollection_HArray1>(1, aNbItems); @@ -3347,9 +3647,13 @@ static void WriteDimValues(const occ::handle& theObject->GetNbOfDecimalPlaces(aLeftNbDigits, aRightNbDigits); int aNbQualifiers = 0; if (theObject->HasQualifier() && !isAngle) + { aNbQualifiers++; + } if (aLeftNbDigits > 0 || aRightNbDigits > 0) + { aNbQualifiers++; + } // With qualifiers if (aNbQualifiers > 0) { @@ -3539,7 +3843,9 @@ static void WriteDimValues(const occ::handle& XCAFDimTolObjects_DimensionFormVariance aFormVariance; XCAFDimTolObjects_DimensionGrade aGrade; if (!theObject->GetClassOfTolerance(isHole, aFormVariance, aGrade)) + { return; + } occ::handle aLAF = STEPCAFControl_GDTProperty::GetLimitsAndFits(isHole, aFormVariance, aGrade); aModel->AddWithRefs(aLAF); @@ -3655,14 +3961,20 @@ static occ::handle> Write const occ::handle& aModel = theWS->Model(); const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return nullptr; + } Interface_Graph aGraph = aHGraph->Graph(); occ::handle aGTAttr; if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) + { return nullptr; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { return nullptr; + } // Unit StepBasic_Unit aUnit = GetUnit(theRC); @@ -3675,15 +3987,21 @@ static occ::handle> Write { occ::handle aDatumAttr; if (!aDatumIter.Value().FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { continue; + } occ::handle aDatumObj = aDatumAttr->GetObject(); if (aDatumObj.IsNull()) + { continue; + } aDatums.Append(aDatumObj); aMaxDatumNum = std::max(aMaxDatumNum, aDatumObj->GetPosition()); } if (aMaxDatumNum == 0) + { return nullptr; + } occ::handle>> aConstituents = @@ -3705,7 +4023,9 @@ static occ::handle> Write } } if (aDatumSeqPos.Length() < 1) + { continue; + } // Initialize Datum_Reference_Compartment StepDimTol_DatumOrCommonDatum aDatumRef; occ::handle aCompartment = @@ -3717,7 +4037,9 @@ static occ::handle> Write occ::handle aFDValue; if (theDatumMap.Find(aDatumSeqPos.Value(1)->GetName()->String(), aFDValue) && !aFDValue.IsNull()) + { aFirstDatum = occ::down_cast(aFDValue); + } aDatumRef.SetValue(aFirstDatum); // Modifiers NCollection_Sequence aSimpleModifiers = @@ -3757,11 +4079,15 @@ static occ::handle> Write occ::handle aDatum; occ::handle aDValue; if (theDatumMap.Find(aDatumObj->GetName()->String(), aDValue)) + { aDatum = occ::down_cast(aDValue); + } StepDimTol_DatumOrCommonDatum anElemDatumRef; anElemDatumRef.SetValue(aDatum); if (aFirstDatum.IsNull()) + { aFirstDatum = aDatum; + } // Modifiers NCollection_Sequence aSimpleModifiers = aDatumObj->GetModifiers(); @@ -3872,7 +4198,9 @@ static occ::handle> Write aSDR = occ::down_cast(aSharingsIter.Value()); } if (aSDR.IsNull()) + { return aDatumSystem; + } aGISU->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), @@ -3899,7 +4227,9 @@ void STEPCAFControl_Writer::writeToleranceZone( // Get working data const occ::handle& aModel = theWS->Model(); if (theEntity.IsNull() || theObject.IsNull()) + { return; + } // Return if there is no tolerance zones if (theObject->GetTypeOfValue() == XCAFDimTolObjects_GeomToleranceTypeValue_None @@ -3960,10 +4290,14 @@ void STEPCAFControl_Writer::writeGeomTolerance( const occ::handle& aModel = theWS->Model(); occ::handle aGTAttr; if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) + { return; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { return; + } // Value occ::handle aLMWU = new StepBasic_LengthMeasureWithUnit(); @@ -3994,7 +4328,9 @@ void STEPCAFControl_Writer::writeGeomTolerance( occ::handle aSA = writeShapeAspect(theWS, theGeomTolL, aShape, dummyRC, dummyGISU); if (aSA.IsNull()) + { continue; + } if (aCSA.IsNull()) { aCSA = new StepRepr_CompositeShapeAspect(); @@ -4018,7 +4354,9 @@ void STEPCAFControl_Writer::writeGeomTolerance( occ::handle aMaxLMWU; int aModifNb = aModifiers.Length(); if (anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) + { aModifNb++; + } for (int i = 1; i <= aModifiers.Length(); i++) { if (aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Around @@ -4171,7 +4509,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& { if (theLabels.IsEmpty()) + { return false; + } // get working data const occ::handle& aModel = theWS->Model(); @@ -4180,7 +4520,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return false; + } Interface_Graph aGraph = aHGraph->Graph(); NCollection_DataMap> aDatumMap; @@ -4198,7 +4540,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& } if (aDGTLabels.IsEmpty()) + { return false; + } for (NCollection_Sequence::Iterator aDGTIter(aDGTLabels); aDGTIter.More(); aDGTIter.Next()) @@ -4207,7 +4551,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& NCollection_Sequence aShapeL; NCollection_Sequence aNullSeq; if (!XCAFDoc_DimTolTool::GetRefShapeLabel(aDatumL, aShapeL, aNullSeq)) + { continue; + } // find target shape TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShapeL.Value(1)); TopLoc_Location aLoc; @@ -4226,10 +4572,14 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& occ::handle anEC; FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC); if (aPDS.IsNull()) + { continue; + } occ::handle aDatumAttr; if (!aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { continue; + } occ::handle aName = aDatumAttr->GetName(); occ::handle anIdentification = aDatumAttr->GetIdentification(); occ::handle aDescription = aDatumAttr->GetDescription(); @@ -4304,7 +4654,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& } if (aDGTLabels.IsEmpty()) + { return false; + } for (NCollection_Sequence::Iterator aDGTIter(aDGTLabels); aDGTIter.More(); aDGTIter.Next()) { @@ -4312,7 +4664,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& NCollection_Sequence aShapeL; NCollection_Sequence aNullSeq; if (!XCAFDoc_DimTolTool::GetRefShapeLabel(aDimTolL, aShapeL, aNullSeq)) + { continue; + } // find target shape TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aShapeL.Value(1)); TopLoc_Location aLoc; @@ -4331,11 +4685,15 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& occ::handle anEC; FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC); if (aPDS.IsNull()) + { continue; + } occ::handle aDimTolAttr; if (!aDimTolL.FindAttribute(XCAFDoc_DimTol::GetID(), aDimTolAttr)) + { continue; + } int aKind = aDimTolAttr->GetKind(); occ::handle> aVal = aDimTolAttr->GetVal(); occ::handle aName = aDimTolAttr->GetName(); @@ -4356,9 +4714,13 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& occ::handle>> aHARI = new NCollection_HArray1>(1, 1); if (aKind < 20) + { aHARI->SetValue(1, anEC); + } else + { aHARI->SetValue(1, anAF); + } aSR->Init(aName, aHARI, aRC); occ::handle aSDR = new StepShape_ShapeDefinitionRepresentation; @@ -4437,7 +4799,9 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& occ::handle aDatumAttr; const TDF_Label& aDatumL = aDatumIter.Value(); if (!aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { continue; + } occ::handle aNameD = aDatumAttr->GetName(); occ::handle aDescriptionD = aDatumAttr->GetDescription(); occ::handle anIdentificationD = aDatumAttr->GetIdentification(); @@ -4469,11 +4833,17 @@ bool STEPCAFControl_Writer::writeDGTs(const occ::handle& occ::handle aMGT = new StepDimTol_ModifiedGeometricTolerance; if (aKind == 21) + { aMGT->SetModifier(StepDimTol_MaximumMaterialCondition); + } else if (aKind == 22) + { aMGT->SetModifier(StepDimTol_LeastMaterialCondition); + } else if (aKind == 23) + { aMGT->SetModifier(StepDimTol_RegardlessOfFeatureSize); + } occ::handle aGTComplex = new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol; aGTComplex->Init(aName, aDescription, aLMWU, aSA, aGTWDR, aMGT); @@ -4549,7 +4919,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return false; + } Interface_Graph aGraph = aHGraph->Graph(); @@ -4597,7 +4969,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handleGetDatumTargetNumber()); if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId))) + { continue; + } occ::handle aWrittenDatum; bool isFirstDT = !aDatumMap.Find(aDatumName, aWrittenDatum); occ::handle aDatum = @@ -4638,10 +5012,14 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle aFirstShapeL, aSecondShapeL; occ::handle aDimAttr; if (!aDimensionL.FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr)) + { continue; + } occ::handle anObject = aDimAttr->GetObject(); if (anObject.IsNull()) + { continue; + } if (anObject->GetType() == XCAFDimTolObjects_DimensionType_CommonLabel) { occ::handle aSA = new StepRepr_ShapeAspect(); @@ -4662,7 +5040,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle aFirstSA, aSecondSA; @@ -4671,7 +5051,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle 1) { @@ -4682,7 +5064,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle aSA = writeShapeAspect(theWS, aDimensionL, aShape, dummyRC, dummyGISU); if (aSA.IsNull()) + { continue; + } if (aCSA.IsNull()) { aCSA = new StepRepr_CompositeShapeAspect(); @@ -4697,7 +5081,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handleAddWithRefs(aSAR); if (aRC.IsNull() && !dummyRC.IsNull()) + { aRC = dummyRC; + } } aFirstSA = aCSA; } @@ -4706,7 +5092,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle 1) { @@ -4733,7 +5121,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handleAddWithRefs(aSAR); } if (aRC.IsNull() && !dummyRC.IsNull()) + { aRC = dummyRC; + } } aSecondSA = aCSA; } @@ -4755,6 +5145,7 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handleHasPoint() || anObject->HasPoint2()) + { WriteDerivedGeometry(theWS, anObject, aCGRepr, @@ -4762,6 +5153,7 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handleGetType(); if (XCAFDimTolObjects_DimensionObject::IsDimensionalLocation(aDimType)) { @@ -4867,7 +5259,9 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle>(1, aConnectionPnts.Length()); for (int i = 0; i < aConnectionPnts.Length(); i++) + { anItems->SetValue(i + 1, aConnectionPnts(i)); + } aCGRepr->Init(new TCollection_HAsciiString(), anItems, dummyRC); aCGReprRel->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), @@ -4893,18 +5287,24 @@ bool STEPCAFControl_Writer::writeDGTsAP242(const occ::handle aFirstShapeL, aNullSeqL; if (!XCAFDoc_DimTolTool::GetRefShapeLabel(aGeomTolL, aFirstShapeL, aNullSeqL)) + { continue; + } NCollection_Sequence aDatumSeq; XCAFDoc_DimTolTool::GetDatumWithObjectOfTolerLabels(aGeomTolL, aDatumSeq); occ::handle> aDatumSystem; if (aDatumSeq.Length() > 0) + { aDatumSystem = WriteDatumSystem(theWS, aGeomTolL, aDatumSeq, aDatumMap, aRC, theLocalFactors); + } writeGeomTolerance(theWS, aFirstShapeL, aGeomTolL, aDatumSystem, aRC, theLocalFactors); } // Write Draughting model for Annotation Planes if (myGDTAnnotations.Length() == 0) + { return true; + } occ::handle>> aItems = new NCollection_HArray1>(1, myGDTAnnotations.Length()); @@ -4926,7 +5326,9 @@ static bool FindPDSforRI(const Interface_Graph& theGraph, occ::handle& theRC) { if (theEnt.IsNull() || !theEnt->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return false; + } for (Interface_EntityIterator aSharingIter = theGraph.Sharings(theEnt); aSharingIter.More() && thePDS.IsNull(); aSharingIter.Next()) @@ -4934,7 +5336,9 @@ static bool FindPDSforRI(const Interface_Graph& theGraph, occ::handle aSR = occ::down_cast(aSharingIter.Value()); if (aSR.IsNull()) + { continue; + } theRC = aSR->ContextOfItems(); for (Interface_EntityIterator aSubs1 = theGraph.Sharings(aSR); aSubs1.More() && thePDS.IsNull(); aSubs1.Next()) @@ -4942,10 +5346,14 @@ static bool FindPDSforRI(const Interface_Graph& theGraph, occ::handle aSDR = occ::down_cast(aSubs1.Value()); if (aSDR.IsNull()) + { continue; + } occ::handle aPropD = aSDR->Definition().PropertyDefinition(); if (aPropD.IsNull()) + { continue; + } thePDS = occ::down_cast(aPropD); } } @@ -4959,7 +5367,9 @@ bool STEPCAFControl_Writer::writeMaterials(const occ::handle& aModel = theWS->Model(); @@ -4968,7 +5378,9 @@ bool STEPCAFControl_Writer::writeMaterials(const occ::handle aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) + { return false; + } Interface_Graph aGraph = theWS->HGraph()->Graph(); @@ -4999,16 +5411,22 @@ bool STEPCAFControl_Writer::writeMaterials(const occ::handle> aSeqRI; FindEntities(aFP, aShape, aLocation, aSeqRI); if (aSeqRI.Length() <= 0) + { continue; + } occ::handle aPDS; occ::handle aRC; occ::handle anEnt = aSeqRI.Value(1); FindPDSforRI(aGraph, anEnt, aPDS, aRC); if (aPDS.IsNull()) + { continue; + } occ::handle aProdDef = aPDS->Definition().ProductDefinition(); if (aProdDef.IsNull()) + { continue; + } // write material entities TDF_Label aMatL = aNode->Father()->Label(); occ::handle aName; @@ -5026,7 +5444,9 @@ bool STEPCAFControl_Writer::writeMaterials(const occ::handleLength() == 0) + { continue; + } TCollection_AsciiString aKey(aName->ToCString()); if (aMapDRI.IsBound(aKey)) { @@ -5086,7 +5506,9 @@ bool STEPCAFControl_Writer::writeMaterials(const occ::handle STEPConstruct_AP203Context:: { TCollection_AsciiString token = user.Token(" \t", i); if (!token.Length()) + { break; + } names.Append(token); } if (names.Length() > 0) + { fname->AssignCat(names.Value(1).ToCString()); + } if (names.Length() > 1) + { lname->AssignCat(names.Value(names.Length()).ToCString()); + } if (names.Length() > 2) { mname = new NCollection_HArray1>(1, names.Length() - 2); for (i = 2; i < names.Length(); i++) + { mname->SetValue(i - 1, new TCollection_HAsciiString(names.Value(i))); + } } // create a person diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Assembly.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Assembly.cxx index 3701c0c67b..4238659710 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Assembly.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Assembly.cxx @@ -147,7 +147,9 @@ void STEPConstruct_Assembly::MakeRelationship() occ::handle STEPConstruct_Assembly::ItemValue() const { if (theval.IsNull()) + { return occ::handle(thesr); + } return theval; } @@ -194,7 +196,9 @@ bool STEPConstruct_Assembly::CheckSRRReversesNAUO( occ::handle rep1 = CDSR->RepresentationRelation()->Rep1(); occ::handle rep2 = CDSR->RepresentationRelation()->Rep2(); if (rep1.IsNull() || rep2.IsNull()) + { return false; + } // find SDRs corresponding to Rep1 and Rep2 and remember their PDs occ::handle tSDR = STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation); @@ -240,7 +244,9 @@ bool STEPConstruct_Assembly::CheckSRRReversesNAUO( if (pd1 == nauo->RelatedProductDefinition() && // OK pd2 == nauo->RelatingProductDefinition()) + { return false; + } if (pd2 == nauo->RelatedProductDefinition() && // Reversed pd1 == nauo->RelatingProductDefinition()) diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ContextTool.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ContextTool.cxx index 04267074cd..d4e8200fb9 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ContextTool.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ContextTool.cxx @@ -68,7 +68,9 @@ void STEPConstruct_ContextTool::SetModel(const occ::handle& if (ent->IsKind(STANDARD_TYPE(StepBasic_ApplicationProtocolDefinition))) { if (theAPD.IsNull()) + { theAPD = GetCasted(StepBasic_ApplicationProtocolDefinition, ent); + } } // if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductRelatedProductCategory))) { // if (thePRPC.IsNull()) thePRPC = GetCasted(StepBasic_ProductRelatedProductCategory, ent); @@ -96,7 +98,9 @@ void STEPConstruct_ContextTool::AddAPD(const bool enforce) { bool noapd = theAPD.IsNull(); if (noapd || enforce) + { theAPD = new StepBasic_ApplicationProtocolDefinition; + } switch (mySchema) { // j4 @@ -135,7 +139,9 @@ void STEPConstruct_ContextTool::AddAPD(const bool enforce) } if (theAPD->Application().IsNull()) + { theAPD->SetApplication(new StepBasic_ApplicationContext); + } occ::handle appl; switch (mySchema) { // j4 @@ -161,10 +167,14 @@ void STEPConstruct_ContextTool::AddAPD(const bool enforce) bool STEPConstruct_ContextTool::IsAP203() const { if (theAPD.IsNull()) + { return false; + } occ::handle schema = theAPD->ApplicationInterpretedModelSchemaName(); if (schema.IsNull()) + { return false; + } TCollection_AsciiString sch = schema->String(); sch.LowerCase(); return sch == "config_control_design"; @@ -175,10 +185,14 @@ bool STEPConstruct_ContextTool::IsAP203() const bool STEPConstruct_ContextTool::IsAP214() const { if (theAPD.IsNull()) + { return false; + } occ::handle schema = theAPD->ApplicationInterpretedModelSchemaName(); if (schema.IsNull()) + { return false; + } TCollection_AsciiString sch = schema->String(); sch.LowerCase(); return sch == "automotive_design"; @@ -189,10 +203,14 @@ bool STEPConstruct_ContextTool::IsAP214() const bool STEPConstruct_ContextTool::IsAP242() const { if (theAPD.IsNull()) + { return false; + } occ::handle schema = theAPD->ApplicationInterpretedModelSchemaName(); if (schema.IsNull()) + { return false; + } TCollection_AsciiString sch = schema->String(); sch.LowerCase(); return sch == "ap242_managed_model_based_3d_engineering"; @@ -209,7 +227,9 @@ bool STEPConstruct_ContextTool::IsAP242() const occ::handle STEPConstruct_ContextTool::GetACstatus() { if (GetAPD().IsNull()) + { return new TCollection_HAsciiString(""); + } return GetAPD()->Status(); } @@ -218,7 +238,9 @@ occ::handle STEPConstruct_ContextTool::GetACstatus() occ::handle STEPConstruct_ContextTool::GetACschemaName() { if (GetAPD().IsNull()) + { return new TCollection_HAsciiString(""); + } return GetAPD()->ApplicationInterpretedModelSchemaName(); } @@ -244,9 +266,13 @@ occ::handle STEPConstruct_ContextTool::GetACapplicati occ::handle STEPConstruct_ContextTool::GetACname() { if (GetAPD().IsNull()) + { return new TCollection_HAsciiString(""); + } if (GetAPD()->Application().IsNull()) + { return new TCollection_HAsciiString(""); + } return GetAPD()->Application()->Application(); } @@ -255,7 +281,9 @@ occ::handle STEPConstruct_ContextTool::GetACname() void STEPConstruct_ContextTool::SetACstatus(const occ::handle& status) { if (GetAPD().IsNull()) + { return; + } GetAPD()->SetStatus(status); } @@ -265,7 +293,9 @@ void STEPConstruct_ContextTool::SetACschemaName( const occ::handle& schemaName) { if (GetAPD().IsNull()) + { return; + } GetAPD()->SetApplicationInterpretedModelSchemaName(schemaName); } @@ -274,7 +304,9 @@ void STEPConstruct_ContextTool::SetACschemaName( void STEPConstruct_ContextTool::SetACyear(const int year) { if (GetAPD().IsNull()) + { return; + } GetAPD()->SetApplicationProtocolYear(year); } @@ -283,9 +315,13 @@ void STEPConstruct_ContextTool::SetACyear(const int year) void STEPConstruct_ContextTool::SetACname(const occ::handle& name) { if (GetAPD().IsNull()) + { return; + } if (GetAPD()->Application().IsNull()) + { GetAPD()->SetApplication(new StepBasic_ApplicationContext); + } GetAPD()->Application()->SetApplication(name); } @@ -327,7 +363,9 @@ void STEPConstruct_ContextTool::NextLevel() void STEPConstruct_ContextTool::PrevLevel() { if (myLevel.Length() > 0) + { myLevel.Remove(myLevel.Length()); + } } //================================================================================================= @@ -337,12 +375,16 @@ void STEPConstruct_ContextTool::SetLevel(const int lev) if (lev < myLevel.Length()) { while (lev < myLevel.Length() && myLevel.Length() > 0) + { myLevel.Remove(myLevel.Length()); + } } else { while (myLevel.Length() < lev) + { myLevel.Append(1); + } } } @@ -358,7 +400,9 @@ int STEPConstruct_ContextTool::Index() const void STEPConstruct_ContextTool::NextIndex() { if (myLevel.Length() > 0) + { myLevel.SetValue(myLevel.Length(), myLevel.Last() + 1); + } } //================================================================================================= @@ -366,7 +410,9 @@ void STEPConstruct_ContextTool::NextIndex() void STEPConstruct_ContextTool::PrevIndex() { if (myLevel.Length() > 0) + { myLevel.SetValue(myLevel.Length(), myLevel.Last() - 1); + } } //================================================================================================= @@ -374,7 +420,9 @@ void STEPConstruct_ContextTool::PrevIndex() void STEPConstruct_ContextTool::SetIndex(const int ind) { if (myLevel.Length() > 0) + { myLevel.SetValue(myLevel.Length(), ind); + } } //================================================================================================= @@ -383,9 +431,13 @@ occ::handle STEPConstruct_ContextTool::GetProductName( { occ::handle PdtName; if (!myProductName.IsEmpty()) + { PdtName = new TCollection_HAsciiString(myProductName); + } else + { PdtName = new TCollection_HAsciiString("Product"); + } for (int i = 1; i <= myLevel.Length(); i++) { @@ -410,7 +462,9 @@ occ::handle>> STEPConstruc // seq->Append ( GetAPD() ); if (!SDRTool.PRPC().IsNull()) + { seq->Append(SDRTool.PRPC()); + } // for AP203, add required product management data if (mySchema == 3) diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ExternRefs.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ExternRefs.cxx index 65006a487f..b42a0e89cd 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ExternRefs.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ExternRefs.cxx @@ -110,14 +110,18 @@ static bool findPDWADandExcludeExcess( for (subsADR.Start(); subsADR.More(); subsADR.Next()) { if (!subsADR.Value()->IsKind(STANDARD_TYPE(StepBasic_Document))) + { continue; + } occ::handle aDoc = occ::down_cast(subsADR.Value()); // looking for Document Product Equivalence Interface_EntityIterator subsD = Graph.Sharings(aDoc); for (subsD.Start(); subsD.More(); subsD.Next()) { if (!subsD.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentProductEquivalence))) + { continue; + } occ::handle aDPE = occ::down_cast(subsD.Value()); // take PDF and search the same PDF by PDWAD chain @@ -125,7 +129,9 @@ static bool findPDWADandExcludeExcess( for (subsDPE.Start(); subsDPE.More(); subsDPE.Next()) { if (!subsDPE.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { continue; + } occ::handle aPDF = occ::down_cast(subsDPE.Value()); Interface_EntityIterator subs = Graph.Sharings(aPDF); @@ -133,7 +139,9 @@ static bool findPDWADandExcludeExcess( { if (!subs.Value()->IsKind( STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) + { continue; + } aPDWAD = occ::down_cast(subs.Value()); } // now searching for PDWAD that refer to the same PDF @@ -171,9 +179,13 @@ bool STEPConstruct_ExternRefs::LoadExternRefs() { occ::handle enti = model->Value(ient); if (enti->DynamicType() == tPDWAD) + { aSeqOfPDWAD.Append(enti); + } else if (enti->DynamicType() == tADR) + { aSeqOfADR.Append(enti); + } } int IsAP214 = 0; // run on sequence aSeqOfADR of ADR and remove excess PDWAD from aSeqOfPDWAD @@ -196,14 +208,18 @@ bool STEPConstruct_ExternRefs::LoadExternRefs() for (subs4.Start(); subs4.More(); subs4.Next()) { if (subs4.Value()->IsKind(STANDARD_TYPE(StepBasic_RoleAssociation))) + { Role = occ::down_cast(subs4.Value()); + } } subs4 = Graph().Shareds(ADR); for (subs4.Start(); subs4.More(); subs4.Next()) { if (subs4.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { Shape = occ::down_cast(subs4.Value()); + } } // search for Document file occ::handle DocFile; @@ -213,16 +229,22 @@ bool STEPConstruct_ExternRefs::LoadExternRefs() subs4 = Graph().Shareds(ADR); } else + { // looking from PDWAD subs4 = Graph().Shareds(aPDWAD); + } for (subs4.Start(); subs4.More(); subs4.Next()) { if (!subs4.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { continue; + } DocFile = occ::down_cast(subs4.Value()); if (DocFile.IsNull()) + { continue; + } // for each DocumentFile, find associated with it data: Interface_EntityIterator subs = Graph().Sharings(DocFile); for (subs.Start(); subs.More(); subs.Next()) @@ -242,9 +264,13 @@ bool STEPConstruct_ExternRefs::LoadExternRefs() occ::handle PDR = occ::down_cast(subs2.Value()); if (PDR.IsNull()) + { continue; + } if (PDR->UsedRepresentation()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { Format = PDR; + } } } // DocumentRepresentationType @@ -253,13 +279,19 @@ bool STEPConstruct_ExternRefs::LoadExternRefs() Type = occ::down_cast(sub); } if (!Type.IsNull() && !Format.IsNull()) + { break; + } } if (!Type.IsNull() && !Format.IsNull()) + { break; + } } if (DocFile.IsNull()) + { continue; + } myAEIAs.Append(ADR); myRoles.Append(Role); myFormats.Append(Format); @@ -307,7 +339,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const occ::handle AEIA; const char* aCStringFileName = nullptr; if (myDocFiles.Length() >= num && !myDocFiles.Value(num).IsNull()) + { DocFile = occ::down_cast(myDocFiles.Value(num)); + } else if (myIsAP214(num) == 1) { occ::handle ADR = @@ -329,15 +363,21 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const subs4 = Graph().Shareds(ADR); } else + { // looking from PDWAD subs4 = Graph().Shareds(aPDWAD); + } for (subs4.Start(); subs4.More(); subs4.Next()) { if (!subs4.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { continue; + } DocFile = occ::down_cast(subs4.Value()); if (DocFile.IsNull()) + { continue; + } } } else @@ -345,14 +385,18 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const occ::handle aPDWAD = occ::down_cast(myShapes(num)); if (aPDWAD.IsNull() || aPDWAD->DocIds().IsNull()) + { return ""; + } int i; for (i = 1; i <= aPDWAD->NbDocIds(); i++) { occ::handle Doc = aPDWAD->DocIdsValue(i); occ::handle aFilename = Doc->Name(); if (!aFilename.IsNull() && !aFilename->IsEmpty()) + { return aFilename->ToCString(); + } } return ""; } @@ -366,7 +410,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const { AEIA = occ::down_cast(subs3.Value()); if (!AEIA.IsNull()) + { break; + } } } } @@ -379,7 +425,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const aCStringFileName = aFilename->ToCString(); // ptv 29.01.2003 file trj4_xr1-tc-214.stp entity #71 have id "#71" if (aCStringFileName && aCStringFileName[0] == '#') + { aCStringFileName = nullptr; + } } if (!aCStringFileName || !aCStringFileName[0]) { @@ -397,7 +445,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const // nothing to do, hope could take name later. } else + { aCStringFileName = theFileName->String(); + } } } } @@ -413,7 +463,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const { TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName); if (fullname.Length() <= 0) + { fullname = aCStringFileName; + } if (!OSD_File(fullname).Exists()) { oldFileName = aCStringFileName; @@ -427,12 +479,16 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const { occ::handle aFilename = DocFile->Id(); if (!aFilename.IsNull() && !aFilename->IsEmpty()) + { aCStringFileName = aFilename->ToCString(); + } if (!aCStringFileName || !aCStringFileName[0]) { aFilename = DocFile->Name(); if (!aFilename.IsNull() && !aFilename->IsEmpty()) + { aCStringFileName = aFilename->ToCString(); + } } if (!aCStringFileName || !aCStringFileName[0]) { @@ -449,7 +505,9 @@ const char* STEPConstruct_ExternRefs::FileName(const int num) const } TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName); if (fullname.Length() <= 0) + { fullname = aCStringFileName; + } if (!OSD_File(fullname).Exists()) { if (oldFileName) @@ -497,12 +555,16 @@ occ::handle STEPConstruct_ExternRefs::Format(const int occ::handle Format; if (myIsAP214(num) == 0) + { return Format; + } occ::handle PDR = occ::down_cast(myFormats(num)); if (PDR.IsNull()) + { return Format; + } occ::handle rep = PDR->UsedRepresentation(); for (int i = 1; i <= rep->NbItems(); i++) @@ -693,11 +755,15 @@ int STEPConstruct_ExternRefs::AddExternRef(const char* const { const occ::handle& sub = subs.Value(); if (!sub->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { continue; + } occ::handle ProdDefSh = occ::down_cast(sub); if (ProdDefSh.IsNull()) + { continue; + } StepRepr_CharacterizedDefinition CDf; CDf.SetValue(PDWAD); ProdDefSh->SetDefinition(CDf); @@ -806,9 +872,13 @@ int STEPConstruct_ExternRefs::WriteExternRefs(const int num) const { Model()->ReplaceEntity(myReplaceNum(i), myAEIAs(i)); if (!myRoles(i).IsNull()) + { Model()->AddWithRefs(myRoles(i)); + } if (!myTypes(i).IsNull()) + { Model()->AddWithRefs(myTypes(i)); + } } } else @@ -817,20 +887,32 @@ int STEPConstruct_ExternRefs::WriteExternRefs(const int num) const { Model()->AddWithRefs(myAEIAs(i)); if (!myRoles(i).IsNull()) + { Model()->AddWithRefs(myRoles(i)); + } if (!myFormats(i).IsNull()) + { Model()->AddWithRefs(myFormats(i)); + } if (!myShapes(i).IsNull()) + { Model()->AddWithRefs(myShapes(i)); + } if (!myTypes(i).IsNull()) + { Model()->AddWithRefs(myTypes(i)); + } } } // PTV 30.01.2003 TRJ11 if (!myAPD.IsNull()) + { Model()->AddWithRefs(myAPD); + } if (!mySharedPRPC.IsNull()) + { Model()->AddWithRefs(mySharedPRPC); + } return myAEIAs.Length(); } @@ -865,7 +947,9 @@ bool STEPConstruct_ExternRefs::addAP214ExterRef( mySharedPRPC->Products(); int nbProducts = 0; if (!HProducts.IsNull()) + { nbProducts = HProducts->Length(); + } int intProdId = 20001 + nbProducts; occ::handle ProductID = new TCollection_HAsciiString(intProdId); occ::handle ProductName = new TCollection_HAsciiString(filename); @@ -893,7 +977,9 @@ bool STEPConstruct_ExternRefs::addAP214ExterRef( occ::handle>> newHProducts = new NCollection_HArray1>(1, nbProducts + 1); for (int pi = 1; pi <= nbProducts; pi++) + { newHProducts->SetValue(pi, HProducts->Value(pi)); + } newHProducts->SetValue(nbProducts + 1, Product); // set the hArray to the PRPC mySharedPRPC->SetProducts(newHProducts); diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Part.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Part.cxx index 21d7c15f65..f71f84bc68 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Part.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Part.cxx @@ -202,7 +202,9 @@ occ::handle STEPConstruct_Part::SDRValu occ::handle STEPConstruct_Part::SRValue() const { if (!myDone) + { return nullptr; + } return occ::down_cast(mySDR->UsedRepresentation()); } diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Styles.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Styles.cxx index ea5fc9266a..8ff43659c7 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Styles.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Styles.cxx @@ -330,7 +330,9 @@ occ::handle STEPConstruct_Styles::AddStyle( occ::handle item = STEPConstruct::FindEntity(FinderProcess(), Shape); occ::handle Style; if (!item.IsNull()) + { Style = AddStyle(item, PSA, Override); + } return Style; } @@ -342,13 +344,17 @@ bool STEPConstruct_Styles::CreateMDGPR( occ::handle& theStepModel) { if (myStyles.Extent() < 1) + { return false; + } // create MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION occ::handle>> elems = new NCollection_HArray1>(1, myStyles.Extent()); for (int i = 1; i <= myStyles.Extent(); i++) + { elems->SetValue(i, occ::down_cast(myStyles.FindKey(i))); + } // create new MDGPR Repr = new StepVisual_MechanicalDesignGeometricPresentationRepresentation; occ::handle ReprName = new TCollection_HAsciiString(""); @@ -386,18 +392,26 @@ bool STEPConstruct_Styles::CreateNAUOSRD( // get PDS occ::handle aPDS; if (initPDS.IsNull()) + { aPDS = CDSR->RepresentedProductRelation(); + } else + { aPDS = initPDS; // for SHUO + } occ::handle aRepRelationShip = CDSR->RepresentationRelation(); occ::handle aRRwTRSF = occ::down_cast(aRepRelationShip); StepRepr_Transformation SetReprTRSF; if (!aRRwTRSF.IsNull()) + { SetReprTRSF = aRRwTRSF->TransformationOperator(); + } else + { return false; + } // take Item defined transformation occ::handle anItDT = SetReprTRSF.ItemDefinedTransformation(); elems->SetValue(1, anItDT->TransformItem2()); @@ -409,7 +423,9 @@ bool STEPConstruct_Styles::CreateNAUOSRD( occ::handle PSA = occ::down_cast(myPSA.Value(psbci)); if (PSA.IsNull()) + { continue; + } // register the reference StepVisual_StyleContextSelect aStyleCntxSlct; aStyleCntxSlct.SetValue(aSR); @@ -459,7 +475,9 @@ occ::handle STEPConstruct_Styles::FindContext( // std::cout << "Parsing back refs: found " << subs.Value()->DynamicType()->Name() << std::endl; #endif if (!subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { continue; + } sr = occ::down_cast(subs.Value()); Context = sr->ContextOfItems(); } @@ -505,7 +523,9 @@ bool STEPConstruct_Styles::LoadStyles() occ::handle style = occ::down_cast(container->ItemsValue(j)); if (style.IsNull()) + { continue; + } auto anItem = style->ItemAP242().Value(); if (!anItem.IsNull() && anItem->IsKind(tSR)) { @@ -547,7 +567,9 @@ bool STEPConstruct_Styles::LoadInvisStyles( { occ::handle enti = model->Value(i); if (enti->DynamicType() != tInvisibility) + { continue; + } // search for styled items occ::handle container = occ::down_cast(enti); int nbi = container->NbInvisibleItems(); @@ -556,10 +578,14 @@ bool STEPConstruct_Styles::LoadInvisStyles( StepVisual_InvisibleItem anInvItem = container->InvisibleItemsValue(j); occ::handle style = anInvItem.StyledItem(); if (style.IsNull()) + { continue; + } // collect the invisible styled items if (theInvStyles.IsNull()) + { theInvStyles = new NCollection_HSequence>; + } theInvStyles->Append(style); } } @@ -672,9 +698,13 @@ occ::handle STEPConstruct_Styles::MakeCo PSSs->SetValue(i, PSS); } if (!isForNAUO) + { PSA = new StepVisual_PresentationStyleAssignment; + } else + { PSA = new StepVisual_PresentationStyleByContext; + } PSA->Init(PSSs); return PSA; @@ -746,21 +776,37 @@ occ::handle STEPConstruct_Styles::EncodeColor(const Quantity_ // detect if color corresponds to one of pre-defined colors const char* cName = nullptr; if (C == Quantity_Color(Quantity_NOC_GREEN)) + { cName = "green"; + } else if (C == Quantity_Color(Quantity_NOC_RED)) + { cName = "red"; + } else if (C == Quantity_Color(Quantity_NOC_BLUE1)) + { cName = "blue"; + } else if (C == Quantity_Color(Quantity_NOC_YELLOW)) + { cName = "yellow"; + } else if (C == Quantity_Color(Quantity_NOC_MAGENTA1)) + { cName = "magenta"; + } else if (C == Quantity_Color(Quantity_NOC_CYAN1)) + { cName = "cyan"; + } else if (C == Quantity_Color(Quantity_NOC_BLACK)) + { cName = "black"; + } else if (C == Quantity_Color(Quantity_NOC_WHITE)) + { cName = "white"; + } if (cName) { @@ -792,21 +838,37 @@ occ::handle STEPConstruct_Styles::EncodeColor( // detect if color corresponds to one of pre-defined colors const char* cName = nullptr; if (C == Quantity_Color(Quantity_NOC_GREEN)) + { cName = "green"; + } else if (C == Quantity_Color(Quantity_NOC_RED)) + { cName = "red"; + } else if (C == Quantity_Color(Quantity_NOC_BLUE1)) + { cName = "blue"; + } else if (C == Quantity_Color(Quantity_NOC_YELLOW)) + { cName = "yellow"; + } else if (C == Quantity_Color(Quantity_NOC_MAGENTA1)) + { cName = "magenta"; + } else if (C == Quantity_Color(Quantity_NOC_CYAN1)) + { cName = "cyan"; + } else if (C == Quantity_Color(Quantity_NOC_BLACK)) + { cName = "black"; + } else if (C == Quantity_Color(Quantity_NOC_WHITE)) + { cName = "white"; + } if (cName) { @@ -816,7 +878,9 @@ occ::handle STEPConstruct_Styles::EncodeColor( { ColPr = occ::down_cast(DPDCs.Find(aName)); if (!ColPr.IsNull()) + { return ColPr; + } } ColPr = new StepVisual_DraughtingPreDefinedColour; occ::handle preDef = new StepVisual_PreDefinedItem; @@ -837,7 +901,9 @@ occ::handle STEPConstruct_Styles::EncodeColor( { ColRGB = occ::down_cast(ColRGBs.Find(P)); if (!ColRGB.IsNull()) + { return ColRGB; + } } occ::handle ColName = new TCollection_HAsciiString(""); ColRGB = new StepVisual_ColourRgb; @@ -859,13 +925,19 @@ bool STEPConstruct_Styles::DecodeColor(const occ::handle& Col { double norm = rgb->Red(); if (norm < rgb->Green()) + { norm = rgb->Green(); + } if (norm < rgb->Blue()) + { norm = rgb->Blue(); + } Col.SetValues(rgb->Red() / norm, rgb->Green() / norm, rgb->Blue() / norm, Quantity_TOC_sRGB); } else + { Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_sRGB); + } return true; } else if (Colour->IsKind(STANDARD_TYPE(StepVisual_PreDefinedColour))) @@ -875,21 +947,37 @@ bool STEPConstruct_Styles::DecodeColor(const occ::handle& Col occ::handle pdi = pdc->GetPreDefinedItem(); const TCollection_AsciiString name = pdi->Name()->String(); if (name.IsEqual("red")) + { Col.SetValues(Quantity_NOC_RED); + } else if (name.IsEqual("green")) + { Col.SetValues(Quantity_NOC_GREEN); + } else if (name.IsEqual("blue")) + { Col.SetValues(Quantity_NOC_BLUE1); + } else if (name.IsEqual("yellow")) + { Col.SetValues(Quantity_NOC_YELLOW); + } else if (name.IsEqual("magenta")) + { Col.SetValues(Quantity_NOC_MAGENTA1); + } else if (name.IsEqual("cyan")) + { Col.SetValues(Quantity_NOC_CYAN1); + } else if (name.IsEqual("black")) + { Col.SetValues(Quantity_NOC_BLACK); + } else if (name.IsEqual("white")) + { Col.SetValues(Quantity_NOC_WHITE); + } else { #ifdef OCCT_DEBUG diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Tool.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Tool.cxx index 49158984fd..f629c8de8b 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Tool.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_Tool.cxx @@ -38,19 +38,25 @@ bool STEPConstruct_Tool::SetWS(const occ::handle& WS) myFinderProcess.Nullify(); if (WS.IsNull()) + { return false; + } myWS = WS; myHGraph = myWS->HGraph(); // collect data on reading process const occ::handle& TR = WS->TransferReader(); if (!TR.IsNull()) + { myTransientProcess = TR->TransientProcess(); + } // collect data on writing process const occ::handle& TW = myWS->TransferWriter(); if (!TW.IsNull()) + { myFinderProcess = TW->FinderProcess(); + } return !myTransientProcess.IsNull() && !myFinderProcess.IsNull(); } diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_UnitContext.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_UnitContext.cxx index 93166f902e..6ac0036855 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_UnitContext.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_UnitContext.cxx @@ -146,7 +146,9 @@ void STEPConstruct_UnitContext::Init(const double Tol3 lengthUnit = convUnit; } else + { lengthUnit = siUnit; + } occ::handle radianUnit = new StepBasic_SiUnitAndPlaneAngleUnit; radianUnit->Init(false, @@ -307,7 +309,9 @@ int STEPConstruct_UnitContext::ComputeFactors(const occ::handleNbUncertainty(); + } else + { return 40; + } for (int un = 1; un <= nbUncertainty; un++) { @@ -498,7 +512,9 @@ int STEPConstruct_UnitContext::ComputeTolerance( // Update it according to the Length Unit Factor // pdn r_47-sd.stp to choose minimal uncertainty if (theUncertainty > LengthUncertainty) + { theUncertainty = LengthUncertainty; + } hasUncertainty = true; } else @@ -513,7 +529,8 @@ int STEPConstruct_UnitContext::ComputeTolerance( // Update it according to the Length Unit Factor // pdn r_47-sd.stp to choose minimal uncertainty // clang-format off - if(theUncertainty > LengthUncertainty) theUncertainty = LengthUncertainty; // *lengthFactor; fait par appelant + if(theUncertainty > LengthUncertainty) { theUncertainty = LengthUncertainty; // *lengthFactor; fait par appelant +} // clang-format on hasUncertainty = true; } diff --git a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ValidationProps.cxx b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ValidationProps.cxx index 49530f28e7..6c69e2868d 100644 --- a/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ValidationProps.cxx +++ b/src/DataExchange/TKDESTEP/STEPConstruct/STEPConstruct_ValidationProps.cxx @@ -80,7 +80,9 @@ static occ::handle TransientResult( { occ::handle binder; if (res.IsNull()) + { return binder; + } binder = new Transfer_SimpleBinderOfTransient; binder->SetResult(res); return binder; @@ -169,7 +171,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& occ::handle SDR = occ::down_cast(subs1.Value()); if (SDR.IsNull()) + { continue; + } PDS = occ::down_cast(SDR->Definition().PropertyDefinition()); } @@ -181,12 +185,18 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& occ::handle RR = occ::down_cast(subs1.Value()); if (RR.IsNull()) + { continue; + } occ::handle SR1; if (RR->Rep1() == SR) + { SR1 = occ::down_cast(RR->Rep2()); + } else + { SR1 = occ::down_cast(RR->Rep1()); + } if (!SR1.IsNull()) { Interface_EntityIterator subs2 = Graph().Sharings(SR1); @@ -195,7 +205,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& occ::handle SDR = occ::down_cast(subs2.Value()); if (SDR.IsNull()) + { continue; + } PDS = occ::down_cast( SDR->Definition().PropertyDefinition()); } @@ -232,7 +244,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& // std::cout << "Parsing back refs: found " << subs.Value()->DynamicType()->Name() << std::endl; #endif if (!subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { continue; + } occ::handle sr = occ::down_cast(subs.Value()); Context = sr->ContextOfItems(); @@ -240,7 +254,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& for (sub2.Start(); sub2.More(); sub2.Next()) { if (!sub2.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { continue; + } occ::handle sdr = occ::down_cast(sub2.Value()); PDS = @@ -322,7 +338,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& for (asubs.Start(); Context.IsNull() && asubs.More(); asubs.Next()) { if (!asubs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { continue; + } occ::handle sdr = occ::down_cast(asubs.Value()); Context = sdr->UsedRepresentation()->ContextOfItems(); @@ -330,7 +348,9 @@ bool STEPConstruct_ValidationProps::FindTarget(const TopoDS_Shape& } if (!aspect.IsNull()) + { target.SetValue(aspect); + } } #ifdef OCCT_DEBUG else @@ -403,7 +423,9 @@ bool STEPConstruct_ValidationProps::AddProp(const TopoDS_Shape& StepRepr_CharacterizedDefinition target; occ::handle Context; if (!FindTarget(Shape, target, Context, instance)) + { return false; + } return AddProp(target, Context, Prop, Descr); } @@ -503,7 +525,9 @@ bool STEPConstruct_ValidationProps::LoadProps( { occ::handle enti = Model()->Value(i); if (!enti->IsKind(tPDR)) + { continue; + } occ::handle PDR = occ::down_cast(enti); @@ -521,7 +545,9 @@ bool STEPConstruct_ValidationProps::LoadProps( aName.ChangeAll('_', ' ', false); aName.LowerCase(); if (aName != "geometric validation property") + { continue; + } } seq.Append(PDR); @@ -557,7 +583,9 @@ occ::handle STEPConstruct_ValidationProps::GetPropP { PDS = occ::down_cast(subs.Value()); if (PDS.IsNull()) + { return ProdDef; + } Interface_EntityIterator subs1 = Graph().Shareds(PDS); for (subs1.Start(); ProdDef.IsNull() && subs1.More(); subs1.Next()) { @@ -596,7 +624,9 @@ occ::handle STEPConstruct_ValidationProps: occ::handle NAUO; occ::handle PDS = CD.ProductDefinitionShape(); if (PDS.IsNull()) + { return NAUO; // not found + } Interface_EntityIterator subs = Graph().Shareds(PDS); for (subs.Start(); NAUO.IsNull() && subs.More(); subs.Next()) { @@ -646,7 +676,9 @@ TopoDS_Shape STEPConstruct_ValidationProps::GetPropShape( occ::handle ProdDef = GetPropPD(PD); TopoDS_Shape S; if (!ProdDef.IsNull()) + { S = GetPropShape(ProdDef); + } return S; } @@ -660,7 +692,9 @@ bool STEPConstruct_ValidationProps::GetPropReal( { // decode volume & area if (!item->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) + { return false; + } occ::handle mri = occ::down_cast(item); @@ -695,18 +729,26 @@ bool STEPConstruct_ValidationProps::GetPropReal( STEPConstruct_UnitContext unit; unit.ComputeFactors(NU, theLocalFactors); if (unit.AreaDone()) + { scale = unit.AreaFactor(); + } if (unit.VolumeDone()) + { scale = unit.VolumeFactor(); + } } } Val = M->ValueComponent() * scale; if (Name == "AREA_MEASURE") + { isArea = true; + } else if (Name == "VOLUME_MEASURE") + { isArea = false; + } else { #ifdef OCCT_DEBUG @@ -728,7 +770,9 @@ bool STEPConstruct_ValidationProps::GetPropPnt( { // centroid if (!item->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint))) + { return false; + } occ::handle P = occ::down_cast(item); if (P.IsNull() || P->NbCoordinates() != 3) diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorRead.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorRead.cxx index 4c4224e442..c6cde3191d 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorRead.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorRead.cxx @@ -228,13 +228,19 @@ STEPControl_ActorRead::STEPControl_ActorRead(const occ::handle& start) { if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) + { return true; + } occ::handle aStepModel = occ::down_cast(myModel); if (aStepModel.IsNull()) @@ -243,8 +249,12 @@ bool STEPControl_ActorRead::Recognize(const occ::handle& sta } bool aProdMode = aStepModel->InternalParameters.ReadProductMode; if (!aProdMode) + { if (start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { return true; + } + } DeclareAndCast(StepShape_ShapeRepresentation, sr, start); if (!sr.IsNull()) @@ -253,7 +263,9 @@ bool STEPControl_ActorRead::Recognize(const occ::handle& sta for (i = 1; i <= nb; i++) { if (Recognize(sr->ItemsValue(i))) + { return true; + } } return false; } @@ -261,35 +273,65 @@ bool STEPControl_ActorRead::Recognize(const occ::handle& sta const bool aCanReadTessGeom = aStepModel->InternalParameters.ReadTessellated != 0; if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrep))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_BrepWithVoids))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrepAndBrepWithVoids))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_FaceSurface))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_EdgeBasedWireframeModel))) + { return true; + } if (start->IsKind(STANDARD_TYPE(StepShape_FaceBasedSurfaceModel))) + { return true; + } if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedFace))) + { return true; + } if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedSurfaceSet))) + { return true; + } if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedShell))) + { return true; + } if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedSolid))) + { return true; + } if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedShapeRepresentation))) + { return true; + } // REPRESENTATION_RELATIONSHIP et consorts : on regarde le contenu ... // On prend WithTransformation ou non ... @@ -343,7 +385,9 @@ occ::handle STEPControl_ActorRead::Transfer( { occ::handle aPPVersion = aFileNameEntity->PreprocessorVersion(); if (aPPVersion.IsNull()) + { continue; + } #ifdef OCCT_DEBUG std::cout << "Preprocessor version detected: " << aPPVersion->ToCString() << std::endl; #endif @@ -368,7 +412,9 @@ occ::handle STEPControl_ActorRead::Transfer( static void ApplyTransformation(TopoDS_Shape& shape, const gp_Trsf& Trsf) { if (Trsf.Form() == gp_Identity) + { return; + } TopLoc_Location theLoc(Trsf); shape.Move(theLoc); } @@ -388,7 +434,9 @@ static occ::handle FindContext( { rep = occ::down_cast(subs.Value()); if (rep.IsNull() && level > 0) + { rep = FindContext(subs.Value(), TP, level - 1); + } } return rep; } @@ -402,17 +450,29 @@ static occ::handle FindContext( static int FindShapeReprType(const occ::handle& start) { if (start->IsKind(STANDARD_TYPE(StepShape_AdvancedBrepShapeRepresentation))) + { return 2; + } if (start->IsKind(STANDARD_TYPE(StepShape_ManifoldSurfaceShapeRepresentation))) + { return 3; + } if (start->IsKind(STANDARD_TYPE(StepShape_GeometricallyBoundedSurfaceShapeRepresentation))) + { return 4; + } if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrepShapeRepresentation))) + { return 5; + } if (start->IsKind(STANDARD_TYPE(StepShape_EdgeBasedWireframeShapeRepresentation))) + { return 6; + } if (start->IsKind(STANDARD_TYPE(StepShape_GeometricallyBoundedWireframeShapeRepresentation))) + { return 7; + } return 8; } @@ -430,12 +490,16 @@ static void getListSDR(const occ::handle& // check whether this ShapeAspect is used in G&DT, and if yes, ignore it if (sa->IsKind(STANDARD_TYPE(StepDimTol_DatumFeature))) + { return; + } Interface_EntityIterator subs5 = graph.Sharings(sa); for (subs5.Start(); subs5.More(); subs5.Next()) { if (subs5.Value()->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return; + } } // reiterate by referred entities and take all SDRs; note that SDRs that @@ -446,14 +510,18 @@ static void getListSDR(const occ::handle& occ::handle propd = occ::down_cast(subs5.Value()); if (propd.IsNull()) + { continue; + } Interface_EntityIterator subs6 = graph.Sharings(propd); for (subs6.Start(); subs6.More(); subs6.Next()) { occ::handle sdr = occ::down_cast(subs6.Value()); if (!sdr.IsNull()) + { listSDR->Append(sdr); + } } } } @@ -496,8 +564,10 @@ static void getSDR( { // if specific representation type is preferred, choose the // representations of the closest type - if (ICS == 1) // translate all SDRs + if (ICS == 1) + { // translate all SDRs listSDR->Append(sdr); + } else { int iDiff = std::abs(FindShapeReprType(rep) - ICS); @@ -505,12 +575,16 @@ static void getSDR( if (iDiff < delta) { while (listSDR->Length() > nbSDR0) + { listSDR->Remove(listSDR->Length()); + } delta = iDiff; } // take all representations of preferred or closest type if (iDiff <= delta) + { listSDR->Append(sdr); + } } } continue; @@ -530,7 +604,9 @@ static void getSDR( if (!NAUO.IsNull()) { if (PDS->Definition().ProductDefinition() == NAUO->RelatingProductDefinition()) + { listNAUO->Append(NAUO); + } continue; } } @@ -580,7 +656,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( if (!NAUO.IsNull()) { if (PD == NAUO->RelatingProductDefinition()) + { listNAUO->Append(NAUO); + } continue; } } @@ -598,7 +676,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( // should be taken into account int readSA = aStepModel->InternalParameters.ReadShapeAspect; if (!readSA) + { listSDRAspect->Clear(); + } // remember number of normal SDRs (not those found via ShapeAspect) // and merge both lists in one @@ -612,13 +692,19 @@ occ::handle STEPControl_ActorRead::TransferEntity( // ignoring sub-assemblies if any int readAssembly = aStepModel->InternalParameters.ReadAssemblyLevel; if (readAssembly == 3 || (readAssembly == 2 && listNAUO->Length() > 0)) + { listSDR->Clear(); + } else if (readAssembly == 4) + { listNAUO->Clear(); + } int nbEnt = listSDR->Length() + listNAUO->Length(); if (nbEnt <= 0) + { return shbinder; + } // common progress indicator for translation of own shapes and sub-assemblies Message_ProgressScope PS(theProgress, "Part", nbEnt); @@ -632,15 +718,21 @@ occ::handle STEPControl_ActorRead::TransferEntity( #ifdef TRANSLOG if (TP->TraceLevel() > 1) + { sout << " -- Actor : Ent.n0 " << TP->Model()->Number(PD) << " -> Shared Ent.no" - << TP->Model()->Number(NAUO) << std::endl; + << TP->Model()->Number(NAUO) << '\n'; + } #endif occ::handle binder; Message_ProgressRange aRange = PS.Next(); if (!TP->IsBound(NAUO)) + { binder = TransferEntity(NAUO, TP, theLocalFactors, aRange); + } else + { binder = TP->Find(NAUO); + } TopoDS_Shape theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) @@ -657,7 +749,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( } } else + { B.Add(Cund, theResult); + } // [END] ssv: OCCT#22436: extra compound in NMSSR case nbComponents++; } @@ -671,7 +765,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle rep = occ::down_cast(sdr->UsedRepresentation()); if (rep.IsNull()) + { continue; + } Message_ProgressScope aPS1(PS.Next(), nullptr, 2); @@ -684,14 +780,18 @@ occ::handle STEPControl_ActorRead::TransferEntity( bool useTrsf = theUseTrsf && (i <= nbNotAspect); occ::handle binder = TP->Find(rep); if (binder.IsNull()) + { binder = TransferEntity(rep, TP, theLocalFactors, isBound, useTrsf, aPS1.Next()); + } // if SDR is obtained from ShapeAspect and representation items have already been tramnslated, // this means that that ShapeAspect is used to refer to sub-shape of the main shape // (e.g. for validation properties), and we do not need to translate it actually; // otherwise it is considered as part of hybrid representation in AP203 before 1998 if (i > nbNotAspect && isBound) + { continue; + } // record shape resulting from translation TopoDS_Shape theResult; @@ -712,7 +812,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( } } else + { B.Add(Cund, theResult); + } // [END] ssv: OCCT#22436: extra compound in NMSSR case } } @@ -733,13 +835,19 @@ occ::handle STEPControl_ActorRead::TransferEntity( // make a warning if both own shape and sub-assemblies are present if ((Cund.NbChildren() - nbComponents) > 0 && nbComponents > 0) + { TP->AddWarning(PD, "Product has both sub-assemblies and directly assigned shape"); + } // if only single shape is read, add it as it is; otherwise add compound if ((Cund.NbChildren() - nbComponents) == 1 && nbComponents == 0) + { shbinder = new TransferBRep_ShapeBinder(Result1); + } else + { shbinder = new TransferBRep_ShapeBinder(Cund); + } // TP->Unbind( PD ); //:j3: unbind start (let it be bound by TransferProcess) TP->Bind(PD, shbinder); @@ -766,22 +874,30 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle PDS = occ::down_cast(subs1.Value()); if (PDS.IsNull()) + { continue; + } Interface_EntityIterator subs2 = graph.Sharings(PDS); for (subs2.Start(); subs2.More(); subs2.Next()) { occ::handle CDSR = occ::down_cast(subs2.Value()); if (CDSR.IsNull()) + { continue; + } IsDepend = true; occ::handle RR = CDSR->RepresentationRelation(); if (RR.IsNull()) + { continue; + } SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO(graph, CDSR); occ::handle rep = (SRRReversed ? RR->Rep2() : RR->Rep1()); if (rep.IsNull()) + { continue; + } iatrsf = ComputeSRRWT(RR, TP, Trsf, theLocalFactors); // find real ProductDefinition used rep Interface_EntityIterator subs3 = TP->Graph().Sharings(rep); @@ -794,7 +910,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle PDS1 = occ::down_cast(SDR->Definition().PropertyDefinition()); if (PDS1.IsNull()) + { continue; + } Interface_EntityIterator subs4 = graph.Shareds(PDS1); for (subs4.Start(); PD.IsNull() && subs4.More(); subs4.Next()) { @@ -823,16 +941,22 @@ occ::handle STEPControl_ActorRead::TransferEntity( { binder = TP->Find(PD); if (binder.IsNull()) + { binder = TransferEntity(PD, TP, theLocalFactors, false, aPS.Next()); + } theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) { if (iatrsf) { if (SRRReversed) + { ApplyTransformation(theResult, Trsf.Inverted()); + } else + { ApplyTransformation(theResult, Trsf); + } } shbinder = new TransferBRep_ShapeBinder(theResult); } @@ -846,7 +970,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( binder = TransferEntity(SRR, TP, theLocalFactors, 0, false, aPS.Next()); theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) + { shbinder = new TransferBRep_ShapeBinder(theResult); + } } } } @@ -868,14 +994,18 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle shbinder; occ::handle aStepModel = occ::down_cast(TP->Model()); if (!Recognize(sr)) + { return shbinder; + } isBound = false; int nb = sr->NbItems(); int nbTPitems = TP->NbMapped(); Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo(); #ifdef TRANSLOG if (TP->TraceLevel() > 2) - sout << " -- Actor : case ShapeRepr. NbItems=" << nb << std::endl; + { + sout << " -- Actor : case ShapeRepr. NbItems=" << nb << '\n'; + } #endif // Compute unit conversion factors and geometric Accuracy @@ -932,11 +1062,15 @@ occ::handle STEPControl_ActorRead::TransferEntity( Message_ProgressRange aRange = aPS.Next(); #ifdef TRANSLOG if (TP->TraceLevel() > 2) - sout << " -- Actor, shape_representation.item n0. " << i << std::endl; + { + sout << " -- Actor, shape_representation.item n0. " << i << '\n'; + } #endif occ::handle anitem = sr->ItemsValue(i); if (anitem.IsNull()) + { continue; + } if (theUseTrsf) { if (anitem->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d))) @@ -1064,7 +1198,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( { const TopoDS_Shape& aCurrentShell = allShellsExp.Current(); if (!myNMTool.IsPureNMShell(aCurrentShell) && !shellClosingsMap.Contains(aCurrentShell)) + { brepBuilder.Add(compWithClosings, aCurrentShell); + } } comp = compWithClosings; } @@ -1085,7 +1221,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( brepBuilder.Add(reconstComp, nextSolid); } else if (aSubShape.ShapeType() == TopAbs_SHELL) + { brepBuilder.Add(reconstComp, aSubShape); + } } comp = reconstComp; // [END] Reconstruct Solids from Closed Shells (ssv; 15.11.2010) @@ -1096,7 +1234,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( // else if (nsh == 1) shbinder = new TransferBRep_ShapeBinder (OneResult); // else shbinder = new TransferBRep_ShapeBinder (comp); if (nsh == 0) + { shbinder.Nullify(); + } else if (nsh == 1) { if (aTrsf.Form() != gp_Identity) @@ -1138,7 +1278,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( //: j2: treat SRRs here in order to compare them with NAUO occ::handle SRR = CDSR->RepresentationRelation(); if (SRR.IsNull()) + { return shbinder; + } bool SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO(TP->Graph(), CDSR); occ::handle rep1 = (SRRReversed ? SRR->Rep2() : SRR->Rep1()); @@ -1146,7 +1288,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::down_cast(rep1); if (SRRReversed) + { TP->AddWarning(SRR, "SRR reverses relation defined by NAUO; NAUO definition is taken"); + } TopoDS_Shape theResult; @@ -1156,9 +1300,13 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle binder; bool isBound = false; if (!TP->IsBound(rep)) + { binder = TransferEntity(rep, TP, theLocalFactors, isBound, false, theProgress); + } else + { binder = TP->Find(rep); + } theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) @@ -1166,14 +1314,20 @@ occ::handle STEPControl_ActorRead::TransferEntity( if (iatrsf) { if (SRRReversed) + { ApplyTransformation(theResult, Trsf.Inverted()); + } else + { ApplyTransformation(theResult, Trsf); + } } shbinder = new TransferBRep_ShapeBinder(theResult); } else + { shbinder.Nullify(); + } TP->Bind(CDSR, shbinder); return shbinder; } @@ -1192,7 +1346,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle shbinder; if (und.IsNull()) + { return shbinder; + } // On prend son contenu : Rep1 ou Rep2 , that is the question // on prend les 2. Mais quoi faire des axes @@ -1212,20 +1368,30 @@ occ::handle STEPControl_ActorRead::TransferEntity( { Message_ProgressRange aRange = aPS.Next(); if (nbrep && nbrep != i) + { continue; + } occ::handle anitemt; if (i == 1) + { anitemt = und->Rep1(); + } if (i == 2) + { anitemt = und->Rep2(); + } occ::handle anitem = occ::down_cast(anitemt); occ::handle binder; bool isBound = false; if (!TP->IsBound(anitem)) + { binder = TransferEntity(anitem, TP, theLocalFactors, isBound, theUseTrsf, aRange); + } else + { binder = TP->Find(anitem); + } TopoDS_Shape theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) { @@ -1242,16 +1408,26 @@ occ::handle STEPControl_ActorRead::TransferEntity( if (iatrsf) { if (nsh == 1) + { ApplyTransformation(OneResult, Trsf); + } else if (nsh > 1) + { ApplyTransformation(Cund, Trsf); + } } if (nsh == 0) + { shbinder.Nullify(); + } else if (nsh == 1) + { shbinder = new TransferBRep_ShapeBinder(OneResult); + } else + { shbinder = new TransferBRep_ShapeBinder(Cund); + } TP->Bind(und, shbinder); return shbinder; } @@ -1266,7 +1442,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle shbinder; if (theCGRR.IsNull()) + { return shbinder; + } bool resetUnits = false; occ::handle oldSRContext = mySRContext; StepData_Factors aLocalFactors = theLocalFactors; @@ -1279,7 +1457,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::down_cast(i == 1 ? theCGRR->Rep1() : theCGRR->Rep2()); if (aCRepr.IsNull()) + { continue; + } if (mySRContext.IsNull() || aCRepr->ContextOfItems() != mySRContext->ContextOfItems()) { PrepareUnits(aCRepr, theTP, aLocalFactors); @@ -1298,7 +1478,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle anAxis = StepToGeom::MakeAxis2Placement(aStepAxis, aLocalFactors); if (anAxis.IsNull()) + { continue; + } occ::handle aPlane = new Geom_Plane(gp_Ax3(anAxis->Ax2())); TopoDS_Face aPlaneFace; aB.MakeFace(aPlaneFace, aPlane, Precision::Confusion()); @@ -1311,7 +1493,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( shbinder = new TransferBRep_ShapeBinder(aComp); mySRContext = oldSRContext; if (oldSRContext.IsNull() || resetUnits) + { PrepareUnits(oldSRContext, theTP, aLocalFactors); + } theTP->Bind(theCGRR, shbinder); @@ -1328,7 +1512,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( { occ::handle aShBinder; if (theMDADR.IsNull()) + { return aShBinder; + } bool aResetUnits = false; occ::handle anOldSRContext = mySRContext; @@ -1344,7 +1530,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( occ::handle aRepr = (anIndex == 1) ? theMDADR->Rep1() : theMDADR->Rep2(); if (aRepr.IsNull()) + { continue; + } if (mySRContext.IsNull() || aRepr->ContextOfItems() != mySRContext->ContextOfItems()) { PrepareUnits(aRepr, theTP, aLocalFactors); @@ -1399,7 +1587,9 @@ static bool IsNeedRepresentation(const occ::handle& s occ::handle sdrA = occ::down_cast(subs7.Value()); if (sdrA.IsNull()) + { continue; + } // abv 23 Feb 00: use iterator to take into account AP203 hybrid models Interface_EntityIterator subs8 = graph.Shareds(sdrA); for (subs8.Start(); subs8.More(); subs8.Next()) @@ -1411,7 +1601,9 @@ static bool IsNeedRepresentation(const occ::handle& s occ::handle SRR = occ::down_cast(subs8.Value()); if (SRR.IsNull()) + { continue; + } rep2 = (sdrA->UsedRepresentation() == SRR->Rep1() ? SRR->Rep2() : SRR->Rep1()); } int i, j; // svv Jan 11 2000 : porting on DEC @@ -1419,13 +1611,21 @@ static bool IsNeedRepresentation(const occ::handle& s { occ::handle it = repA->ItemsValue(i); for (j = 1; j <= rep2->NbItems(); j++) + { if (it == rep2->ItemsValue(j)) + { break; + } + } if (j > rep2->NbItems()) + { break; + } } if (i > repA->NbItems()) + { IsSDRaspect = false; + } } } return IsSDRaspect; @@ -1454,7 +1654,9 @@ occ::handle STEPControl_ActorRead::OldWay( if (!SA.IsNull()) { if (!IsNeedRepresentation(SA, rep, TP)) + { return shbinder; + } } } @@ -1462,7 +1664,9 @@ occ::handle STEPControl_ActorRead::OldWay( #ifdef TRANSLOG if (TP->TraceLevel() > 2) - sout << " -- Actor : case shape_definition_representation." << std::endl; + { + sout << " -- Actor : case shape_definition_representation." << '\n'; + } #endif occ::handle binder = TP->Find(rep); { @@ -1473,7 +1677,9 @@ occ::handle STEPControl_ActorRead::OldWay( } } if (aPSRoot.UserBreak()) + { return shbinder; + } //: j2 if (!binder.IsNull()) return binder; // SDR designant des CDSR (lien implicite, via la UsedRepr) @@ -1507,26 +1713,36 @@ occ::handle STEPControl_ActorRead::OldWay( occ::handle tSRR = STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship); int nbitem = 0; for (subs.Start(); subs.More(); subs.Next()) + { nbitem++; + } Message_ProgressScope PS(aPSRoot.Next(), "Sub", nbitem); for (subs.Start(); subs.More() && PS.More(); subs.Next()) { Message_ProgressRange aRange = PS.Next(); const occ::handle& anitem = subs.Value(); if (anitem->DynamicType() != tCDSR && anitem->DynamicType() != tSRR) + { continue; + } // DeclareAndCast(StepShape_ContextDependentShapeRepresentation,anitem,subs.Value()); // if (anitem.IsNull()) continue; #ifdef TRANSLOG if (TP->TraceLevel() > 1) + { sout << " -- Actor : Ent.n0 " << TP->Model()->Number(start) << " -> Shared Ent.no" - << TP->Model()->Number(anitem) << std::endl; + << TP->Model()->Number(anitem) << '\n'; + } #endif if (!TP->IsBound(anitem)) + { binder = TP->Transferring(anitem, aRange); + } else + { binder = TP->Find(anitem); + } TopoDS_Shape theResult = TransferBRep::ShapeResult(binder); if (!theResult.IsNull()) { @@ -1537,11 +1753,17 @@ occ::handle STEPControl_ActorRead::OldWay( } if (nsh == 0) + { shbinder = new TransferBRep_ShapeBinder(Cund); // shbinder.Nullify(); + } else if (nsh == 1) + { shbinder = new TransferBRep_ShapeBinder(OneResult); + } else + { shbinder = new TransferBRep_ShapeBinder(Cund); + } TP->Unbind(start); //: j3: unbind start (let it be bound by TransferProcess) return shbinder; } @@ -1564,7 +1786,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( #ifdef TRANSLOG OSD_Timer chrono; if (TP->TraceLevel() > 2) - sout << "Begin transfer STEP -> CASCADE, Type " << start->DynamicType()->Name() << std::endl; + { + sout << "Begin transfer STEP -> CASCADE, Type " << start->DynamicType()->Name() << '\n'; + } chrono.Start(); #endif occ::handle aStepModel = occ::down_cast(TP->Model()); @@ -1580,7 +1804,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( ResetUnits(aStepModel, aLocalFactors); } else + { PrepareUnits(context, TP, aLocalFactors); + } } myShapeBuilder.SetPrecision(myPrecision); myShapeBuilder.SetMaxTol(myMaxTol); @@ -1694,7 +1920,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( } if (aPS.UserBreak()) + { return shbinder; + } if (found && myShapeBuilder.IsDone()) { @@ -1717,16 +1945,24 @@ occ::handle STEPControl_ActorRead::TransferEntity( } found = !mappedShape.IsNull(); if (found && shbinder.IsNull()) + { shbinder = new TransferBRep_ShapeBinder(mappedShape); + } #ifdef TRANSLOG chrono.Stop(); if (TP->TraceLevel() > 2) - sout << "End transfer STEP -> CASCADE :" << (found ? "OK" : " : no result") << std::endl; + { + sout << "End transfer STEP -> CASCADE :" << (found ? "OK" : " : no result") << '\n'; + } if (TP->TraceLevel() > 2) + { chrono.Show(); + } #endif - if (oldSRContext.IsNull() && !mySRContext.IsNull()) //: S4136 + if (oldSRContext.IsNull() && !mySRContext.IsNull()) + { //: S4136 PrepareUnits(oldSRContext, TP, aLocalFactors); + } TP->Bind(start, shbinder); return shbinder; } @@ -1756,10 +1992,14 @@ occ::handle STEPControl_ActorRead::TransferEntity( Message_ProgressScope aPSRoot(theProgress, nullptr, 2); occ::handle binder = TP->Find(maprep); if (binder.IsNull()) + { binder = TransferEntity(maprep, TP, theLocalFactors, isBound, false, theProgress); + } shbinder = occ::down_cast(binder); if (shbinder.IsNull()) + { TP->AddWarning(mapit, "No Shape Produced"); + } else { TopoDS_Shape mappedShape = shbinder->Result(); @@ -1794,9 +2034,13 @@ occ::handle STEPControl_ActorRead::TransferEntity( } if (ok) + { ApplyTransformation(mappedShape, Trsf); + } else + { TP->AddWarning(mapit, "Mapped Item, case not recognized, location ignored"); + } shbinder = new TransferBRep_ShapeBinder(mappedShape); } @@ -1819,7 +2063,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( const Interface_Graph& aGraph = TP->Graph(); int aSRRnum = 0; for (Interface_EntityIterator aSubsIt(aGraph.Sharings(maprep)); aSubsIt.More(); aSubsIt.Next()) + { ++aSRRnum; + } Message_ProgressScope aPS(aPSRoot.Next(), "Part", aSRRnum); TopoDS_Shape aNewResult = TransferRelatedSRR(TP, maprep, @@ -1834,7 +2080,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( } // if only single shape is read, add it as it is; otherwise add compound if (aCund.NbChildren() == 1) + { shbinder = new TransferBRep_ShapeBinder(aResult); + } else if (aCund.NbChildren() > 1) { shbinder = new TransferBRep_ShapeBinder(aCund); @@ -1883,7 +2131,9 @@ occ::handle STEPControl_ActorRead::TransferEntity( ResetUnits(aStepModel, aLocalFactors); } else + { PrepareUnits(context, TP, aLocalFactors); + } } // Apply ShapeFix @@ -1908,8 +2158,10 @@ occ::handle STEPControl_ActorRead::TransferEntity( aShapeProcessor.MergeTransferInfo(TP, nbTPitems); } - if (oldSRContext.IsNull() && !mySRContext.IsNull()) //: S4136 + if (oldSRContext.IsNull() && !mySRContext.IsNull()) + { //: S4136 PrepareUnits(oldSRContext, TP, aLocalFactors); + } TP->Bind(fs, sb); return sb; // TP->Find (start); } @@ -1933,14 +2185,18 @@ occ::handle STEPControl_ActorRead::TransferShape( const Message_ProgressRange& theProgress) { if (start.IsNull()) + { return NullResult(); + } Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo(); #ifdef TRANSLOG // POUR MISE AU POINT, a supprimer ensuite if (TP->TraceLevel() > 1) + { sout << " -- Actor : Transfer Ent.n0 " << TP->Model()->Number(start) << " Type " - << start->DynamicType()->Name() << std::endl; + << start->DynamicType()->Name() << '\n'; + } #endif occ::handle shbinder; @@ -1951,9 +2207,10 @@ occ::handle STEPControl_ActorRead::TransferShape( // case ShapeDefinitionRepresentation if ProductMode != ON bool aProdMode = aStepModel->InternalParameters.ReadProductMode; if (!aProdMode && start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { shbinder = OldWay(start, TP, theProgress); - // skl - + // skl + } else if (start->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) { occ::handle PD = @@ -2096,21 +2353,29 @@ void STEPControl_ActorRead::PrepareUnits(const occ::handleAddWarning(theRepCont, myUnit.StatusMessage(stat1)); + } } if (!aTol.IsNull()) { stat2 = myUnit.ComputeTolerance(aTol); if (stat2 != 0) + { TP->AddWarning(theRepCont, myUnit.StatusMessage(stat2)); + } } // myPrecision = Precision::Confusion(); - if (aStepModel->InternalParameters.ReadPrecisionMode == 1) //: i1 gka S4136 05.04.99 + if (aStepModel->InternalParameters.ReadPrecisionMode == 1) + { //: i1 gka S4136 05.04.99 myPrecision = aStepModel->InternalParameters.ReadPrecisionVal; + } else if (myUnit.HasUncertainty()) + { myPrecision = myUnit.Uncertainty() * myUnit.LengthFactor(); + } else { TP->AddWarning(theRepCont, "No Length Uncertainty, value of read.precision.val is taken"); @@ -2120,8 +2385,10 @@ void STEPControl_ActorRead::PrepareUnits(const occ::handleTraceLevel() > 1) + { TP->Messenger()->SendInfo() << " Cc1ToTopoDS : Length Unit = " << myUnit.LengthFactor() - << " Tolerance CASCADE = " << myPrecision << std::endl; + << " Tolerance CASCADE = " << myPrecision << '\n'; + } #endif } @@ -2149,7 +2416,9 @@ bool STEPControl_ActorRead::ComputeTransformation( { Trsf = gp_Trsf(); // reinit if (Origin.IsNull() || Target.IsNull()) + { return false; + } //: abv 31.10.01: TEST_MCI_2.step: check that Ax1 and Ax2 belong to // corresponding reps and fix case of inversion error @@ -2160,16 +2429,24 @@ bool STEPControl_ActorRead::ComputeTransformation( for (int i = 1; i <= OrigContext->NbItems(); i++) { if (OrigContext->ItemsValue(i) == org) + { isOKOrigin = true; + } else if (OrigContext->ItemsValue(i) == trg) + { isSwapTarget = true; + } } for (int i = 1; i <= TargContext->NbItems(); i++) { if (TargContext->ItemsValue(i) == trg) + { isOKTarget = true; + } else if (TargContext->ItemsValue(i) == org) + { isSwapOrigin = true; + } } if (!isOKOrigin || !isOKTarget) { @@ -2190,13 +2467,19 @@ bool STEPControl_ActorRead::ComputeTransformation( occ::handle oldSRContext = mySRContext; StepData_Factors aLocalFactors = theLocalFactors; if (OrigContext != oldSRContext) + { PrepareUnits(OrigContext, TP, aLocalFactors); + } occ::handle theOrig = StepToGeom::MakeAxis2Placement(org, aLocalFactors); if (TargContext != OrigContext) + { PrepareUnits(TargContext, TP, aLocalFactors); + } occ::handle theTarg = StepToGeom::MakeAxis2Placement(trg, aLocalFactors); if (oldSRContext != TargContext) + { PrepareUnits(oldSRContext, TP, aLocalFactors); + } gp_Ax3 ax3Orig(theOrig->Ax2()); gp_Ax3 ax3Targ(theTarg->Ax2()); @@ -2219,7 +2502,9 @@ bool STEPControl_ActorRead::ComputeSRRWT( DeclareAndCast(StepRepr_ShapeRepresentationRelationshipWithTransformation, srwt, SRR); if (srwt.IsNull()) + { return false; + } StepRepr_Transformation SelectTrans = srwt->TransformationOperator(); StepData_Factors aLocalFactors = theLocalFactors; @@ -2231,24 +2516,32 @@ bool STEPControl_ActorRead::ComputeSRRWT( // reset units (by Rep2 - ?) occ::handle oldSRContext = mySRContext; if (SRR->Rep2() != oldSRContext) + { PrepareUnits(SRR->Rep2(), TP, aLocalFactors); + } StepToGeom::MakeTransformation3d(CartOp, Trsf, aLocalFactors); if (SRR->Rep2() != oldSRContext) + { PrepareUnits(oldSRContext, TP, aLocalFactors); + } return Trsf.Form() != gp_Identity; } // item-defined transformation occ::handle ItemDef = SelectTrans.ItemDefinedTransformation(); if (ItemDef.IsNull()) + { return false; + } occ::handle Ax1 = occ::down_cast(ItemDef->TransformItem1()); occ::handle Ax2 = occ::down_cast(ItemDef->TransformItem2()); if (Ax1.IsNull() || Ax2.IsNull()) + { return false; + } return ComputeTransformation(Ax1, Ax2, SRR->Rep1(), SRR->Rep2(), TP, Trsf, aLocalFactors); } @@ -2298,9 +2591,13 @@ TopoDS_Shell STEPControl_ActorRead::closeIDEASShell( BRepCheck_Shell checker(TopoDS::Shell(result)); BRepCheck_Status checkStatus = checker.Closed(); if (checkStatus == BRepCheck_NoError) + { result.Closed(true); + } else + { return shell; // Cannot close this shell, skip it so... + } // Try to remove redundant Faces for (itL.Initialize(closingFaces); itL.More(); itL.Next()) @@ -2312,7 +2609,9 @@ TopoDS_Shell STEPControl_ActorRead::closeIDEASShell( BRepCheck_Status subCheckStatus = subChecker.Closed(); // If Shell becomes open, just put the deleted face back if (subCheckStatus != BRepCheck_NoError) + { brepBuilder.Add(result, currentFace); + } else { #ifdef OCCT_DEBUG @@ -2348,15 +2647,21 @@ void STEPControl_ActorRead::computeIDEASClosings( { const TopoDS_Shape& shellB = shellExpB.Current(); if (shellA.IsSame(shellB)) + { continue; + } // Check whether ShellB is non-manifold and adjacent to ShellA. // If so, ShellA has a chance to be closed with ShellB if (myNMTool.IsSuspectedAsClosing(shellA, shellB)) + { closingShells.Append(shellB); + } } if (!closingShells.IsEmpty()) + { shellClosingsMap.Add(shellA, closingShells); + } } } @@ -2388,7 +2693,9 @@ TopoDS_Shape STEPControl_ActorRead::TransferRelatedSRR( { occ::handle anItem = aSubsIt.Value(); if (!anItem->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship))) + { continue; + } occ::handle aBinder; if (anItem->DynamicType() == STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship)) { diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorWrite.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorWrite.cxx index 1de28ded6b..359e294cd8 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorWrite.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_ActorWrite.cxx @@ -180,7 +180,9 @@ static bool hasGeometry(const TopoDS_Shape& theShape) || CR->IsRegularity() || (CR->IsPolygon3D() && !CR->Polygon3D().IsNull()) || CR->IsPolygonOnTriangulation() || CR->IsPolygonOnSurface(); if (!aHasGeometry) + { return false; + } itrc.Next(); } return true; @@ -201,7 +203,9 @@ static bool hasGeometry(const TopoDS_Shape& theShape) const TopoDS_Shape& aShape = anIt.Value(); bool aHasGeometry = hasGeometry(aShape); if (!aHasGeometry) + { return false; + } } return true; } @@ -230,7 +234,9 @@ static bool IsManifoldShape(const TopoDS_Shape& theShape) { const TopoDS_Shape& aDirectChild = anIt.Value(); if (aDirectChild.ShapeType() != TopAbs_COMPOUND) + { aBrepBuilder.Add(aDirectShapes, aDirectChild); + } } #ifdef OCCT_DEBUG @@ -299,7 +305,9 @@ occ::handle STEPControl_ActorWr if (FP->FindTypedTransient(mapper, STANDARD_TYPE(StepShape_NonManifoldSurfaceShapeRepresentation), aResult)) + { break; + } } } @@ -332,7 +340,9 @@ void STEPControl_ActorWrite::mergeInfoForNM(const occ::handle aContext = occ::down_cast(theInfo); if (aContext.IsNull()) + { return; + } const NCollection_DataMap& aMap = aContext->Map(); @@ -343,12 +353,16 @@ void STEPControl_ActorWrite::mergeInfoForNM(const occ::handle anOrigMapper = TransferBRep::ShapeMapper(theFP, anOrig); occ::handle anOrigBinder = theFP->Find(anOrigMapper); if (anOrigBinder.IsNull()) + { continue; + } occ::handle aResMapper = TransferBRep::ShapeMapper(theFP, aRes); theFP->Bind(aResMapper, anOrigBinder); @@ -455,7 +469,9 @@ STEPControl_StepModelType STEPControl_ActorWrite::Mode() const void STEPControl_ActorWrite::SetGroupMode(const int mode) { if (mode >= 0) + { mygroup = mode; + } } //================================================================================================= @@ -483,9 +499,13 @@ bool STEPControl_ActorWrite::Recognize(const occ::handle& start STEPControl_StepModelType mymode = Mode(); occ::handle mapper = occ::down_cast(start); if (mapper.IsNull()) + { return false; + } if (mymode == STEPControl_AsIs) + { return true; + } bool yasolid = false, yashell = false, yaface = false; @@ -499,20 +519,34 @@ bool STEPControl_ActorWrite::Recognize(const occ::handle& start TopExp_Explorer SolidExp, ShellExp, FaceExp; for (SolidExp.Init(theShape, TopAbs_SOLID); SolidExp.More(); SolidExp.Next()) + { yasolid = true; + } for (ShellExp.Init(theShape, TopAbs_SHELL, TopAbs_SOLID); ShellExp.More(); ShellExp.Next()) + { yashell = true; + } for (FaceExp.Init(theShape, TopAbs_FACE, TopAbs_SHELL); FaceExp.More(); FaceExp.Next()) + { yaface = true; + } } else if (theShape.ShapeType() == TopAbs_SOLID) + { yasolid = true; + } else if (theShape.ShapeType() == TopAbs_SHELL) + { yashell = true; + } else if (theShape.ShapeType() == TopAbs_FACE) + { yaface = true; + } else if (mymode != STEPControl_GeometricCurveSet) + { return false; + } // pour wireframe ? // Faceted : il est OBLIGATOIRE d avoir des surfaces support Plane et des @@ -526,7 +560,9 @@ bool STEPControl_ActorWrite::Recognize(const occ::handle& start TopLoc_Location locbid; occ::handle surf = BRep_Tool::Surface(F, locbid); if (surf.IsNull() || !surf->IsKind(STANDARD_TYPE(Geom_Plane))) + { return false; + } } for (TopExp_Explorer fedg(theShape, TopAbs_EDGE); fedg.More(); fedg.Next()) { @@ -535,7 +571,9 @@ bool STEPControl_ActorWrite::Recognize(const occ::handle& start double first, last; occ::handle curv = BRep_Tool::Curve(E, locbid, first, last); if (curv.IsNull() || !curv->IsKind(STANDARD_TYPE(Geom_Line))) + { return false; + } } } @@ -569,15 +607,19 @@ occ::handle STEPControl_ActorWrite::Transfer( occ::handle mapper = occ::down_cast(start); if (mapper.IsNull()) + { return NullResult(); + } TopoDS_Shape shape = mapper->Value(); // init context occ::handle model = occ::down_cast(FP->Model()); if (!model.IsNull()) + { myContext.SetModel(model); //: abv 04.11.00: take APD from model - myContext.AddAPD(false); // update APD - myContext.SetLevel(1); // set assembly level to 1 (to ensure) + } + myContext.AddAPD(false); // update APD + myContext.SetLevel(1); // set assembly level to 1 (to ensure) if (!model->IsInitializedUnit()) { XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info @@ -606,7 +648,9 @@ occ::handle STEPControl_ActorWrite::Transfer( myContext.GetRootsForPart(SDRTool); occ::handle resprod = TransientResult(myContext.GetAPD()); for (int i = 1; i <= roots->Length(); i++) + { resprod->AddResult(TransientResult(roots->Value(i))); + } resprod->AddResult(resbind); // bind and exit @@ -628,7 +672,9 @@ static double UsedTolerance(occ::handle& theStepModel, double Tol = mytoler; int tolmod = theStepModel->InternalParameters.WritePrecisionMode; if (Tol <= 0 && tolmod == 2) + { Tol = theStepModel->InternalParameters.WritePrecisionVal; + } if (Tol <= 0) { ShapeAnalysis_ShapeTolerance stu; @@ -637,7 +683,9 @@ static double UsedTolerance(occ::handle& theStepModel, Tol = Interface_MSG::Intervalled(Tol * 1.5); // arrondi a 1 2 5 ... } if (Tol == 0) + { Tol = 1.e-07; // minimum ... + } return Tol; } @@ -651,7 +699,9 @@ bool STEPControl_ActorWrite::IsAssembly(const occ::handle& t TopoDS_Shape& S) const { if (!GroupMode() || S.ShapeType() != TopAbs_COMPOUND) + { return false; + } // PTV 16.09.2002 OCC725 for storing compound of vertices if (theModel->InternalParameters.WriteVertexMode == 0) { // bug 23950 @@ -668,18 +718,26 @@ bool STEPControl_ActorWrite::IsAssembly(const occ::handle& t } } if (IsOnlyVertices) + { return false; + } } } if (GroupMode() == 1) + { return true; + } TopoDS_Iterator it(S); if (!it.More()) + { return false; + } TopoDS_Shape shape = it.Value(); it.Next(); if (it.More()) + { return true; + } S = shape; return IsAssembly(theModel, S); } @@ -698,12 +756,16 @@ static bool transferVertex(const occ::handle& TopoDSToStep_MakeStepVertex aMkVrtx(TopoDS::Vertex(aShVrtx), aTool, FP, theLocalFactors); if (!aMkVrtx.IsDone()) + { return IsDone; + } occ::handle aVP = occ::down_cast(aTool.Find(aShVrtx)); if (aVP.IsNull()) + { return IsDone; + } StepShape_GeometricSetSelect select; select.SetValue(aVP->VertexGeometry()); @@ -731,18 +793,24 @@ occ::handle STEPControl_ActorWrite::TransferShape( bool useExistingNMSSR = false; if (mapper.IsNull()) + { return binder; + } TopoDS_Shape theShape = mapper->Value(); if (theShape.IsNull()) + { return binder; + } // INDIVIDUAL SHAPE ALREADY TRANSFERRED : RETURN IT ! binder = FP->Find(start); if (!binder.IsNull()) { if (!binder->HasResult()) + { binder.Nullify(); + } } if (!binder.IsNull()) { @@ -758,7 +826,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( // MODE ASSEMBLY : if Compound, (sub-)assembly if (IsAssembly(aStepModel, theShape)) + { return TransferCompound(start, SDR0, FP, theLocalFactors, theProgress); + } Message_ProgressScope aPSRoot(theProgress, nullptr, 2); @@ -801,11 +871,17 @@ occ::handle STEPControl_ActorWrite::TransferShape( { TopoDS_Shape aSubShape = it.Value(); if (aSubShape.ShapeType() == TopAbs_COMPOUND && !IsManifoldShape(aSubShape)) + { aNMCompound = TopoDS::Compound(aSubShape); + } else if (aSubShape.ShapeType() == TopAbs_COMPOUND) + { aListOfShapes.Append(aSubShape); + } else + { aListOfManifoldShapes.Append(aSubShape); + } } } @@ -850,7 +926,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( NonManifoldGroup->Append(aSubShape); } else + { RepItemSeq->Append(iter.Value()); + } } int aNMItemsNb = RepItemSeq->Length(); @@ -865,7 +943,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( // is used occ::handle sdr; if (isOnlyNonManifold) + { sdr = SDR0; + } else { STEPConstruct_Part SDRTool; @@ -891,13 +971,17 @@ occ::handle STEPControl_ActorWrite::TransferShape( // Nothing else needed for pure non-manifold topology, return if (isOnlyNonManifold) + { return aNMBinder; + } } } // [END] Separate manifold topology from non-manifold in group mode 0 (ssv; 18.11.2010) if (aPSRoot.UserBreak()) + { return occ::handle(); + } // create a list of items to translate occ::handle> RepItemSeq = @@ -964,15 +1048,21 @@ occ::handle STEPControl_ActorWrite::TransferShape( else { if (!isOnlyVertices) + { RepItemSeq->Append(theShape); //: j1 + } } if (mymode == STEPControl_AsIs) { TopExp_Explorer WireExp, EdgeExp; for (WireExp.Init(theShape, TopAbs_WIRE, TopAbs_FACE); WireExp.More(); WireExp.Next()) + { RepItemSeq->Append(TopoDS::Wire(WireExp.Current())); + } for (EdgeExp.Init(theShape, TopAbs_EDGE, TopAbs_WIRE); EdgeExp.More(); EdgeExp.Next()) + { RepItemSeq->Append(TopoDS::Edge(EdgeExp.Current())); + } } } else if (theShape.ShapeType() == TopAbs_SOLID) @@ -991,7 +1081,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( { FP->AddWarning(start, "NonManifold COMPSOLID was translated like a set of SOLIDs"); if (GroupMode() > 0) + { return TransferCompound(start, SDR0, FP, theLocalFactors, aPSRoot.Next()); + } else { TopExp_Explorer SolidExp; @@ -1008,7 +1100,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( return binder; } else + { RepItemSeq->Append(theShape); + } // COMPUTING 3D TOLERANCE // Either from Session, or Computed (Least,Average, or Greatest) @@ -1089,8 +1183,12 @@ occ::handle STEPControl_ActorWrite::TransferShape( // try to treat it as solid with voids int nbShells = 0; for (TopoDS_Iterator It(aSolid); It.More(); It.Next()) + { if (It.Value().ShapeType() == TopAbs_SHELL) + { nbShells++; + } + } if (nbShells > 1) { TopoDSToStep_MakeBrepWithVoids MkBRepWithVoids(aSolid, @@ -1104,7 +1202,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( itemTess = MkBRepWithVoids.TessellatedValue(); } else + { nbShells = 1; // smth went wrong; let it will be just Manifold + } } if (nbShells == 1) { @@ -1274,7 +1374,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( for (; anExp.More(); anExp.Next()) { if (anExp.Current().ShapeType() != TopAbs_VERTEX) + { continue; + } aNbVrtx++; } if (aNbVrtx) @@ -1290,7 +1392,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( { const TopoDS_Shape& aVertex = anExp.Current(); if (aVertex.ShapeType() != TopAbs_VERTEX) + { continue; + } curNb++; transferVertex(FP, aGSS, aVertex, curNb, theLocalFactors); } // end of iteration on compound with vertices. @@ -1305,7 +1409,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( break; } if (item.IsNull() && itemTess.IsNull()) + { continue; + } // add resulting item to the FP if (!item.IsNull()) @@ -1313,9 +1419,13 @@ occ::handle STEPControl_ActorWrite::TransferShape( ItemSeq->Append(item); occ::handle submapper; if (xShape.IsSame(mapper->Value())) + { submapper = occ::down_cast(start); + } if (submapper.IsNull()) + { submapper = TransferBRep::ShapeMapper(FP, xShape); + } occ::handle subbind = FP->Find(submapper); if (subbind.IsNull()) { @@ -1323,16 +1433,22 @@ occ::handle STEPControl_ActorWrite::TransferShape( FP->Bind(submapper, subbind); } else + { subbind->AddResult(TransientResult(item)); + } } if (!itemTess.IsNull()) { ItemSeq->Append(itemTess); occ::handle submapper; if (xShape.IsSame(mapper->Value())) + { submapper = occ::down_cast(start); + } if (submapper.IsNull()) + { submapper = TransferBRep::ShapeMapper(FP, xShape); + } occ::handle subbind = FP->Find(submapper); if (subbind.IsNull()) { @@ -1340,7 +1456,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( FP->Bind(submapper, subbind); } else + { subbind->AddResult(TransientResult(itemTess)); + } } // If shape is not processed, this function does nothing. Intentionally. @@ -1375,7 +1493,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( // be able to work with non-manifold cases case STEPControl_ShellBasedSurfaceModel: if (isManifold) + { shapeRep = new StepShape_ManifoldSurfaceShapeRepresentation; + } else { bool isNewNMSSRCreated; @@ -1390,24 +1510,36 @@ occ::handle STEPControl_ActorWrite::TransferShape( if (nbs == 1) { if (trmode == STEPControl_ManifoldSolidBrep) + { shapeRep = new StepShape_AdvancedBrepShapeRepresentation; + } else if (trmode == STEPControl_ShellBasedSurfaceModel) + { // Process non-manifold topology separately (ssv; 13.11.2010) if (isManifold) + { shapeRep = new StepShape_ManifoldSurfaceShapeRepresentation; + } else { bool isNewNMSSRCreated; shapeRep = this->getNMSSRForGroup(shapeGroup, FP, isNewNMSSRCreated); useExistingNMSSR = !isNewNMSSRCreated; } + } else if (trmode == STEPControl_GeometricCurveSet) + { shapeRep = new StepShape_GeometricallyBoundedWireframeShapeRepresentation; + } else if (trmode == STEPControl_FacetedBrep) + { shapeRep = new StepShape_FacetedBrepShapeRepresentation; + } } else + { shapeRep = new StepShape_ShapeRepresentation; + } } break; default: @@ -1446,17 +1578,29 @@ occ::handle STEPControl_ActorWrite::TransferShape( occ::handle ShapeRepr1; if (items->Value(j)->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) + { ShapeRepr1 = new StepShape_AdvancedBrepShapeRepresentation; + } else if (items->Value(j)->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) + { ShapeRepr1 = new StepShape_ManifoldSurfaceShapeRepresentation; + } else if (items->Value(j)->IsKind(STANDARD_TYPE(StepShape_GeometricCurveSet))) + { ShapeRepr1 = new StepShape_GeometricallyBoundedWireframeShapeRepresentation; + } else if (items->Value(j)->IsKind(STANDARD_TYPE(StepShape_FacetedBrep))) + { ShapeRepr1 = new StepShape_FacetedBrepShapeRepresentation; + } else if (items->Value(j)->IsKind(STANDARD_TYPE(StepVisual_TessellatedItem))) + { ShapeRepr1 = new StepVisual_TessellatedShapeRepresentation; + } else + { ShapeRepr1 = new StepShape_ShapeRepresentation; + } occ::handle>> repr1 = new NCollection_HArray1>(1, 2); @@ -1486,7 +1630,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( for (int i = 1; i <= items->Length(); i++) { if (!items->Value(i)->IsKind(STANDARD_TYPE(StepVisual_TessellatedItem))) + { continue; + } ++nC; } if (nC > 0) @@ -1497,7 +1643,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( for (int j = 1; j <= items->Length(); j++) { if (!items->Value(j)->IsKind(STANDARD_TYPE(StepVisual_TessellatedItem))) + { continue; + } itemsTess->SetValue(i++, items->Value(j)); } @@ -1512,7 +1660,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( aSeqBindRelation.Append(TransientResult(shapeTessRepr)); } if (!useExistingNMSSR) + { shapeRep->SetItems(items); + } else { // Add new representation item to the NMSSR's existing collection (ssv; 13.11.2010) @@ -1523,7 +1673,9 @@ occ::handle STEPControl_ActorWrite::TransferShape( oldItems->Length() + 1); int el = 1; for (int i = 1; i <= oldItems->Length(); i++) + { newItems->SetValue(el++, oldItems->Value(i)); + } newItems->SetValue(el, items->Value(items->Length())); shapeRep->SetItems(newItems); } @@ -1550,16 +1702,22 @@ occ::handle STEPControl_ActorWrite::TransferShape( // resbind = binder; } for (int k = 1; k <= aSeqBindRelation.Length(); k++) + { resbind->AddResult(aSeqBindRelation.Value(k)); + } // Add SDR for non-manifold topology in group mode 0 (ssv; 18.11.2010) if (!aNMBinder.IsNull()) + { resbind->AddResult(aNMBinder); + } return resbind; } else + { return FP->Find(start); + } } //======================================================================= @@ -1578,7 +1736,9 @@ occ::handle STEPControl_ActorWrite::TransferCompound( occ::handle mapper = occ::down_cast(start); occ::handle binder; if (mapper.IsNull()) + { return binder; + } TopoDS_Shape theShape = mapper->Value(); occ::handle aStepModel = occ::down_cast(FP->Model()); @@ -1587,9 +1747,13 @@ occ::handle STEPControl_ActorWrite::TransferCompound( bool isNMMode = aStepModel->InternalParameters.WriteNonmanifold != 0; bool isManifold; if (isNMMode) + { isManifold = IsManifoldShape(theShape); + } else + { isManifold = true; + } // get a sequence of components (subshapes) occ::handle> RepItemSeq = @@ -1633,7 +1797,9 @@ occ::handle STEPControl_ActorWrite::TransferCompound( NonManifoldGroup->Append(aSubShape); } else + { RepItemSeq->Append(aSubShape); + } continue; } @@ -1641,7 +1807,9 @@ occ::handle STEPControl_ActorWrite::TransferCompound( nbFreeVrtx++; } if (nbFreeVrtx) + { RepItemSeq->Append(aCompOfVrtx); + } // PTV OCC725 17.09.2002 -- end -- @@ -1682,7 +1850,9 @@ occ::handle STEPControl_ActorWrite::TransferCompound( aPS.Next()); if (!AX1.IsNull()) + { ItemSeq->Append(AX1); + } // copy binders so as to have all roots in upper binder, but do not conflict while (!bnd.IsNull()) { @@ -1703,7 +1873,9 @@ occ::handle STEPControl_ActorWrite::TransferCompound( // initialize representation for (int rep = 1; rep <= nsub; rep++) + { items->SetValue(rep, GetCasted(StepRepr_RepresentationItem, ItemSeq->Value(rep))); + } shapeRep->SetItems(items); double Tol = UsedTolerance(aStepModel, mytoler, theShape); STEPConstruct_UnitContext mk; @@ -1731,7 +1903,9 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( { occ::handle mapper = occ::down_cast(start); if (mapper.IsNull()) + { return NullResult(); + } TopoDS_Shape shape = mapper->Value(); // SHAPE EN POSITION VENANT D UN ASSEMBLAGE @@ -1763,7 +1937,9 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( bool iasdr = FP->GetTypedTransient(resbind, STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation), sdr); if (iasdr) + { SDRTool.ReadSDR(sdr); + } else { SDRTool.MakeSDR(nullptr, @@ -1783,11 +1959,15 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( occ::handle resbind1 = TransferShape(mapper, sdr, FP, theLocalFactors, shapeGroup, isManifold, theProgress); if (resbind1.IsNull() || sdr->UsedRepresentation().IsNull()) + { return occ::handle(); + } resbind = resbind1; occ::handle oldbind = FP->Find(mapper); if (!oldbind.IsNull() && !resbind.IsNull()) + { resbind->AddResult(oldbind); + } isJustTransferred = true; } @@ -1804,11 +1984,15 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( if (std::abs(aLoc.ScaleFactor() - 1.0) > Precision::Confusion()) { if (aStepModel->InternalParameters.WriteScalingTrsf) + { FP->AddWarning( start, "The shape has a scaling factor, exported as cartesian_transformation_operator"); + } else + { FP->AddWarning(start, "The shape has a scaling factor, skipped"); + } } if (std::abs(aLoc.ScaleFactor() - 1.0) < Precision::Confusion() || !aStepModel->InternalParameters.WriteScalingTrsf) @@ -1842,14 +2026,18 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( { resprod->AddResult(TransientResult(sdr)); if (resprod != resbind) + { resbind->AddResult(TransientResult(sdr)); // KA - OCC7141(skl 10.11.2004) + } roots->Append(myContext.GetRootsForPart(SDRTool)); } for (int i = 1; i <= roots->Length(); i++) { resprod->AddResult(TransientResult(roots->Value(i))); if (resprod != resbind) + { resbind->AddResult(TransientResult(roots->Value(i))); // KA - OCC7141(skl 10.11.2004) + } } if (isJustTransferred) { @@ -1866,10 +2054,16 @@ occ::handle STEPControl_ActorWrite::TransferSubShape( { occ::handle bnd = FP->Find(start); for (int j = 1; j <= roots->Length(); j++) + { if (bnd.IsNull()) + { bnd = TransientResult(roots->Value(j)); + } else + { bnd->AddResult(TransientResult(roots->Value(j))); + } + } FP->Bind(start, bnd); } diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Controller.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Controller.cxx index 5321c5c67c..111ba29bb1 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Controller.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Controller.cxx @@ -448,13 +448,17 @@ IFSelect_ReturnStatus STEPControl_Controller::TransferWriteShape( const Message_ProgressRange& theProgress) const { if (modeshape < 0 || modeshape > 4) + { return IFSelect_RetError; + } occ::handle ActWrite = occ::down_cast(myAdaptorWrite); // A PRESENT ON PASSE PAR LE PROFILE occ::handle aModel = occ::down_cast(model); if (!ActWrite.IsNull()) + { ActWrite->SetGroupMode(aModel->InternalParameters.WriteAssembly); + } TopoDS_Shape aShape = shape; NCollection_DataMap aModifedMap; if (aModel->InternalParameters.WriteNonmanifold) @@ -495,7 +499,9 @@ void STEPControl_Controller::Customise(occ::handle& WS) occ::handle slr; occ::handle slr1 = WS->NamedItem("xst-model-roots"); if (!slr1.IsNull()) + { slr = occ::down_cast(slr1); + } else { slr = new IFSelect_SelectModelRoots; diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Reader.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Reader.cxx index 50378fd4d1..8e0d2b48f0 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Reader.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Reader.cxx @@ -98,9 +98,13 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const char* const filename) occ::handle aLibrary = WS()->WorkLibrary(); occ::handle aProtocol = WS()->Protocol(); if (aLibrary.IsNull()) + { return IFSelect_RetVoid; + } if (aProtocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle aStepModel = new StepData_StepModel; aStepModel->InternalParameters.InitFromStatic(); aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage); @@ -112,22 +116,30 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const char* const filename) OCC_CATCH_SIGNALS int stat = aLibrary->ReadFile(filename, aStepModel, aProtocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** Interruption ReadFile par Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } WS()->SetModel(aStepModel); WS()->SetLoadedFile(filename); WS()->InitTransferReader(4); @@ -142,9 +154,13 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const char* const file occ::handle aLibrary = WS()->WorkLibrary(); occ::handle aProtocol = WS()->Protocol(); if (aLibrary.IsNull()) + { return IFSelect_RetVoid; + } if (aProtocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle aStepModel = new StepData_StepModel; aStepModel->InternalParameters = theParams; aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage); @@ -156,22 +172,30 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const char* const file OCC_CATCH_SIGNALS int stat = aLibrary->ReadFile(filename, aStepModel, aProtocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** Interruption ReadFile par Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } WS()->SetModel(aStepModel); WS()->SetLoadedFile(filename); WS()->InitTransferReader(4); @@ -186,9 +210,13 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const char* const theName, occ::handle aLibrary = WS()->WorkLibrary(); occ::handle aProtocol = WS()->Protocol(); if (aLibrary.IsNull()) + { return IFSelect_RetVoid; + } if (aProtocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle aStepModel = new StepData_StepModel; aStepModel->InternalParameters.InitFromStatic(); aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage); @@ -200,22 +228,30 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const char* const theName, OCC_CATCH_SIGNALS int stat = aLibrary->ReadStream(theName, theIStream, aStepModel, aProtocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** Interruption ReadFile par Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } WS()->SetModel(aStepModel); WS()->SetLoadedFile(theName); WS()->InitTransferReader(4); @@ -231,9 +267,13 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const char* const th occ::handle aLibrary = WS()->WorkLibrary(); occ::handle aProtocol = WS()->Protocol(); if (aLibrary.IsNull()) + { return IFSelect_RetVoid; + } if (aProtocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle aStepModel = new StepData_StepModel; aStepModel->InternalParameters = theParams; aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage); @@ -245,22 +285,30 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const char* const th OCC_CATCH_SIGNALS int stat = aLibrary->ReadStream(theName, theIStream, aStepModel, aProtocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** Interruption ReadFile par Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } WS()->SetModel(aStepModel); WS()->SetLoadedFile(theName); WS()->InitTransferReader(4); @@ -279,7 +327,9 @@ bool STEPControl_Reader::TransferRoot(const int num, const Message_ProgressRange int STEPControl_Reader::NbRootsForTransfer() { if (therootsta) + { return theroots.Length(); + } therootsta = true; occ::handle aStepModel = occ::down_cast(WS()->Model()); @@ -323,18 +373,24 @@ int STEPControl_Reader::NbRootsForTransfer() for (PDWADsubs.Start(); PDWADsubs.More(); PDWADsubs.Next()) { if (!PDWADsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { continue; + } occ::handle localPDF = occ::down_cast(PDWADsubs.Value()); Interface_EntityIterator PDFsubs = WS()->Graph().Sharings(localPDF); for (PDFsubs.Start(); PDFsubs.More(); PDFsubs.Next()) + { if (PDFsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentProductEquivalence))) { iSexclude = true; break; } + } if (iSexclude) + { break; + } } if (iSexclude) { @@ -356,9 +412,13 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle NAUO = occ::down_cast(subs.Value()); if (NAUO.IsNull()) + { continue; + } if (PD == NAUO->RelatedProductDefinition()) + { IsRoot = false; + } } // determinate roots used ProductDefinitionContext if (IsRoot) @@ -375,11 +435,15 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle PDC = occ::down_cast(subs.Value()); if (PDC.IsNull()) + { continue; + } const char* str2 = PDC->LifeCycleStage()->String().ToCString(); const char* str3 = PDC->Name()->String().ToCString(); if (strcasecmp(str1.ToCString(), str2) != 0 && strcasecmp(str1.ToCString(), str3) != 0) + { IsRoot = false; + } } } } @@ -416,7 +480,9 @@ int STEPControl_Reader::NbRootsForTransfer() { occ::handle PD = PropDef->Definition().ProductDefinition(); if (!PD.IsNull()) + { IsRoot = false; + } if (IsRoot) { occ::handle SA = PropDef->Definition().ShapeAspect(); @@ -425,7 +491,9 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle PDS = SA->OfShape(); PD = PDS->Definition().ProductDefinition(); if (!PD.IsNull()) + { IsRoot = false; + } } } if (IsRoot) @@ -434,14 +502,18 @@ int STEPControl_Reader::NbRootsForTransfer() occ::down_cast( PropDef->Definition().ProductDefinitionRelationship()); if (!NAUO.IsNull()) + { IsRoot = false; + } } if (IsRoot) { occ::handle SR = occ::down_cast(SDR->UsedRepresentation()); if (SR.IsNull()) + { IsRoot = false; + } } } if (IsRoot) @@ -462,7 +534,9 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle SDR = occ::down_cast(subs.Value()); if (!SDR.IsNull()) + { IsRoot = false; + } if (IsRoot) { occ::handle RR = @@ -472,7 +546,9 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle SR2 = occ::down_cast(RR->Rep1()); if (SR == SR2) + { SR2 = occ::down_cast(RR->Rep2()); + } if (!SR2.IsNull()) { Interface_EntityIterator subs2 = graph.Sharings(SR2); @@ -481,7 +557,9 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle SDR2 = occ::down_cast(subs2.Value()); if (!SDR2.IsNull()) + { IsRoot = false; + } // else { // if(SR==SRR->Rep2()) IsRoot = false; // } @@ -508,7 +586,9 @@ int STEPControl_Reader::NbRootsForTransfer() occ::handle SR2 = occ::down_cast(subs3.Value()); if (!SR2.IsNull()) + { IsRoot = false; + } } } } @@ -536,7 +616,9 @@ void STEPControl_Reader::FileUnits( { int nbroots = NbRootsForTransfer(); if (!nbroots) + { return; + } enum { @@ -553,7 +635,9 @@ void STEPControl_Reader::FileUnits( occ::handle anEnt = theroots(i); int num = graph.EntityNumber(anEnt); if (!num) + { continue; + } occ::handle aProdDef = occ::down_cast(anEnt); occ::handle aShapeDefRepr; @@ -565,7 +649,9 @@ void STEPControl_Reader::FileUnits( occ::handle aProdDefShape = occ::down_cast(subsPD.Value()); if (aProdDefShape.IsNull()) + { continue; + } Interface_EntityIterator subsSR = graph.Sharings(aProdDefShape); occ::handle SR; for (subsSR.Start(); subsSR.More() && aShapeDefRepr.IsNull(); subsSR.Next()) @@ -573,27 +659,37 @@ void STEPControl_Reader::FileUnits( occ::handle aCurShapeDefRepr = occ::down_cast(subsSR.Value()); if (aCurShapeDefRepr.IsNull()) + { continue; + } occ::handle aUseRepr = aCurShapeDefRepr->UsedRepresentation(); if (aUseRepr.IsNull()) + { continue; + } occ::handle aShapeRepr = occ::down_cast(aUseRepr); if (aShapeRepr.IsNull()) + { continue; + } aShapeDefRepr = aCurShapeDefRepr; } } } else + { aShapeDefRepr = occ::down_cast(anEnt); + } if (!aShapeDefRepr.IsNull()) { occ::handle aShapeRepr = occ::down_cast(aShapeDefRepr->UsedRepresentation()); occ::handle aRepCont = aShapeRepr->ContextOfItems(); if (aRepCont.IsNull()) + { continue; + } NCollection_Array1 aNameUnits(1, 3); NCollection_Array1 aFactorUnits(1, 3); if (findUnits(aRepCont, aNameUnits, aFactorUnits)) @@ -618,7 +714,9 @@ void STEPControl_Reader::FileUnits( { const occ::handle& aModel = WS()->Model(); if (aModel.IsNull()) + { return; + } int nb = aModel->NbEntities(); for (int i = 1; i <= nb; i++) { @@ -626,7 +724,9 @@ void STEPControl_Reader::FileUnits( occ::handle aRepCont = occ::down_cast(anEnt); if (aRepCont.IsNull()) + { continue; + } NCollection_Array1 aNameUnits(1, 3); NCollection_Array1 aFactorUnits(1, 3); if (findUnits(aRepCont, aNameUnits, aFactorUnits)) @@ -793,7 +893,9 @@ bool STEPControl_Reader::findUnits(const occ::handleGlobalUnitAssignedContext(); } if (aContext.IsNull()) + { return false; + } // Start Computation occ::handle>> anUnits = aContext->Units(); int nbU = aContext->NbUnits(); @@ -822,16 +924,26 @@ bool STEPControl_Reader::findUnits(const occ::handleIsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit))) + { anInd = 1; + } else if (aMeasWithUnit->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit))) + { anInd = 2; + } else if (aMeasWithUnit->IsKind(STANDARD_TYPE(StepBasic_SolidAngleMeasureWithUnit))) + { anInd = 3; + } if (!anInd) + { continue; + } aName = aConvUnit->Name()->String(); anUnitFact = aMeasWithUnit->ValueComponent(); } @@ -839,22 +951,34 @@ bool STEPControl_Reader::findUnits(const occ::handle aSiUnit = occ::down_cast(aNamedUnit); if (aSiUnit.IsNull()) + { continue; + } if (aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) + { anInd = 1; + } else if (aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) + { anInd = 2; + } else if (aSiUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndSolidAngleUnit))) + { anInd = 3; + } if (!anInd) + { continue; + } anUnitFact = (!aSiUnit->HasPrefix() ? 1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix())); aName = getSiName(aSiUnit); } if (!anInd) + { continue; + } theNameUnits.SetValue(anInd, aName); theFactorUnits.SetValue(anInd, anUnitFact); diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx index 24e4d1e244..c911126d5b 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx @@ -71,7 +71,9 @@ occ::handle STEPControl_Writer::Model(const bool newone) { DeclareAndCast(StepData_StepModel, model, thesession->Model()); if (newone || model.IsNull()) + { model = GetCasted(StepData_StepModel, thesession->NewModel()); + } return model; } @@ -81,7 +83,9 @@ void STEPControl_Writer::SetTolerance(const double Tol) { DeclareAndCast(STEPControl_ActorWrite, act, WS()->NormAdaptor()->ActorWrite()); if (!act.IsNull()) + { act->SetTolerance(Tol); + } } //================================================================================================= @@ -135,7 +139,9 @@ IFSelect_ReturnStatus STEPControl_Writer::Transfer(const TopoDS_Shape& break; } if (mws < 0) + { return IFSelect_RetError; // cas non reconnu + } thesession->TransferWriter()->SetTransferMode(mws); if (!Model()->IsInitializedUnit()) { diff --git a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit.cxx b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit.cxx index e41d24dc30..d151dc5407 100644 --- a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit.cxx +++ b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit.cxx @@ -49,7 +49,9 @@ occ::handle STEPEdit::SignType() std::lock_guard aLock(aMutex); static occ::handle sty; if (!sty.IsNull()) + { return sty; + } sty = new StepSelect_StepType; sty->SetProtocol(STEPEdit::Protocol()); return sty; diff --git a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditContext.cxx b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditContext.cxx index 8576977837..4aa25354d1 100644 --- a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditContext.cxx +++ b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditContext.cxx @@ -92,7 +92,9 @@ bool STEPEdit_EditContext::Load(const occ::handle& form, { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } STEPConstruct_ContextTool ctx(modl); StepData_Factors aLocalFactors; @@ -119,7 +121,9 @@ bool STEPEdit_EditContext::Apply(const occ::handle& form, { occ::handle modl = occ::down_cast(model); if (modl.IsNull()) + { return false; + } STEPConstruct_ContextTool ctx(modl); StepData_Factors aLocalFactors; @@ -129,13 +133,21 @@ bool STEPEdit_EditContext::Apply(const occ::handle& form, // ctx.AddPRPC(); if (form->IsModified(2)) + { ctx.SetACstatus(form->EditedValue(2)); + } if (form->IsModified(3)) + { ctx.SetACschemaName(form->EditedValue(3)); + } if (form->IsModified(4)) + { ctx.SetACyear(form->EditedValue(4)->IntegerValue()); + } if (form->IsModified(5)) + { ctx.SetACname(form->EditedValue(5)); + } // if (form->IsModified(7)) ctx.SetPRPCName (form->EditedValue(7)); // if (form->IsModified(8)) ctx.SetPRPCDescription (form->EditedValue(8)); diff --git a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditSDR.cxx b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditSDR.cxx index 446966a5be..326b2c92ae 100644 --- a/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditSDR.cxx +++ b/src/DataExchange/TKDESTEP/STEPEdit/STEPEdit_EditSDR.cxx @@ -110,7 +110,9 @@ bool STEPEdit_EditSDR::Load(const occ::handle& form, occ::down_cast(ent); occ::handle modl = occ::down_cast(model); if (sdr.IsNull() || modl.IsNull()) + { return false; + } STEPConstruct_Part ctx; ctx.ReadSDR(sdr); @@ -142,37 +144,61 @@ bool STEPEdit_EditSDR::Apply(const occ::handle& form, occ::down_cast(ent); occ::handle modl = occ::down_cast(model); if (sdr.IsNull() || modl.IsNull()) + { return false; + } STEPConstruct_Part ctx; ctx.ReadSDR(sdr); if (form->IsModified(1)) + { ctx.SetPDCname(form->EditedValue(1)); + } if (form->IsModified(2)) + { ctx.SetPDCstage(form->EditedValue(2)); + } if (form->IsModified(3)) + { ctx.SetPDdescription(form->EditedValue(3)); + } if (form->IsModified(4)) + { ctx.SetPDFid(form->EditedValue(4)); + } if (form->IsModified(5)) + { ctx.SetPDFdescription(form->EditedValue(5)); + } if (form->IsModified(6)) + { ctx.SetPid(form->EditedValue(6)); + } if (form->IsModified(7)) + { ctx.SetPname(form->EditedValue(7)); + } if (form->IsModified(8)) + { ctx.SetPdescription(form->EditedValue(8)); + } if (form->IsModified(9)) + { ctx.SetPCname(form->EditedValue(9)); + } if (form->IsModified(10)) + { ctx.SetPCdisciplineType(form->EditedValue(10)); + } if (form->IsModified(11)) + { ctx.SetACapplication(form->EditedValue(11)); + } return true; } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_AssemblyExplorer.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_AssemblyExplorer.cxx index 2f3e463d56..1663d097cb 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_AssemblyExplorer.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_AssemblyExplorer.cxx @@ -46,10 +46,16 @@ occ::handle STEPSelections_AssemblyExplorer::FindItemWithNAU occ::handle pds; Interface_EntityIterator subs = myGraph.Sharings(nauo); for (subs.Start(); subs.More() && pds.IsNull(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { pds = occ::down_cast(subs.Value()); + } + } if (pds.IsNull()) + { return item; + } subs = myGraph.Sharings(pds); occ::handle cdsr; @@ -59,21 +65,31 @@ occ::handle STEPSelections_AssemblyExplorer::FindItemWithNAU { itmp = subs.Value(); if (itmp->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) + { return itmp; + } if (itmp->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { shdefrep = occ::down_cast(itmp); + } } if (shdefrep.IsNull()) + { return shdefrep; + } occ::handle srep = occ::down_cast(shdefrep->UsedRepresentation()); if (srep.IsNull()) + { return srep; + } for (int i = 1; i <= srep->NbItems(); i++) { occ::handle repitem = srep->ItemsValue(i); if (repitem->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { return repitem; + } } return item; } @@ -83,16 +99,20 @@ occ::handle STEPSelections_AssemblyExpl { Interface_EntityIterator subs = myGraph.Sharings(product); for (subs.Start(); subs.More(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) { Interface_EntityIterator subs1 = myGraph.Sharings(subs.Value()); for (subs1.Start(); subs1.More(); subs1.Next()) + { if (subs1.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { DeclareAndCast(StepShape_ShapeDefinitionRepresentation, SDR, subs1.Value()); return SDR; } + } } + } occ::handle sdr; return sdr; } @@ -106,12 +126,17 @@ void STEPSelections_AssemblyExplorer::FillListWithGraph( occ::handle pdsh = occ::down_cast(SDR->Definition().PropertyDefinition()); if (pdsh.IsNull()) + { return; + } occ::handle pdf = pdsh->Definition().ProductDefinition(); if (pdf.IsNull()) + { return; + } Interface_EntityIterator subs = myGraph.Sharings(pdf); for (subs.Start(); subs.More(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) { DeclareAndCast(StepRepr_NextAssemblyUsageOccurrence, nauo, subs.Value()); @@ -122,15 +147,21 @@ void STEPSelections_AssemblyExplorer::FillListWithGraph( link->SetItem(FindItemWithNAUO(nauo)); occ::handle pdrComponent = nauo->RelatedProductDefinition(); if (pdrComponent.IsNull()) + { continue; + } occ::handle subSDR = FindSDRWithProduct(pdrComponent); if (subSDR.IsNull()) + { continue; + } int index = myMap.FindIndex(subSDR); if (index) + { link->SetComponent( occ::down_cast(myMap.FindFromIndex(index))); + } else { occ::handle>> sublist = @@ -144,6 +175,7 @@ void STEPSelections_AssemblyExplorer::FillListWithGraph( list->Append(link); } } + } } void STEPSelections_AssemblyExplorer::Init(const Interface_Graph& G) @@ -153,6 +185,7 @@ void STEPSelections_AssemblyExplorer::Init(const Interface_Graph& G) myMap.Clear(); Interface_EntityIterator roots = myGraph.RootEntities(); for (roots.Start(); roots.More(); roots.Next()) + { if (roots.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { occ::handle cmp = new STEPSelections_AssemblyComponent; @@ -161,6 +194,7 @@ void STEPSelections_AssemblyExplorer::Init(const Interface_Graph& G) FillListWithGraph(cmp); myRoots.Append(cmp); } + } } static const char* GetProductName(const occ::handle& SDR) @@ -169,13 +203,19 @@ static const char* GetProductName(const occ::handle empty; occ::handle PropDf = SDR->Definition().PropertyDefinition(); if (PropDf.IsNull()) + { return str; + } occ::handle PD = PropDf->Definition().ProductDefinition(); if (PD.IsNull()) + { return str; + } occ::handle PDF = PD->Formation(); if (PDF.IsNull()) + { return str; + } return PDF->OfProduct()->Name()->ToCString(); } @@ -187,19 +227,27 @@ static void PrintSubAssembly(Standard_OStream& // for ( int j=0; j < level; j++ ) os << "\t"; os << "SDR: " << Model->StringLabel(cmp->GetSDR())->ToCString() << "\t"; - os << "Product: " << GetProductName(cmp->GetSDR()) << std::endl; + os << "Product: " << GetProductName(cmp->GetSDR()) << '\n'; for (int i = 1; i <= cmp->GetList()->Length(); i++) { for (int j = 0; j < level + 1; j++) + { os << "\t"; + } os << "NAUO :" << Model->StringLabel(cmp->GetList()->Value(i)->GetNAUO())->ToCString() << ";\t"; if (cmp->GetList()->Value(i)->GetItem()->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { os << "MI "; + } else if (cmp->GetList()->Value(i)->GetItem()->IsKind( STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) + { os << "CDSR "; + } else + { os << "UNKNOWN LINK!!!"; + } PrintSubAssembly(os, cmp->GetList()->Value(i)->GetComponent(), Model, level + 1); } } @@ -209,7 +257,7 @@ void STEPSelections_AssemblyExplorer::Dump(Standard_OStream& os) const occ::handle model = myGraph.Model(); for (int i = 1; i <= myRoots.Length(); i++) { - os << "Assembly N: " << i << std::endl << std::endl; + os << "Assembly N: " << i << '\n' << '\n'; PrintSubAssembly(os, myRoots.Value(i), model, 0); } } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_Counter.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_Counter.cxx index 80a53bd697..c81f17817a 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_Counter.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_Counter.cxx @@ -56,10 +56,14 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, const occ::handle& start) { if (start.IsNull()) + { return; + } if (start->IsKind(STANDARD_TYPE(StepBasic_ProductRelatedProductCategory))) + { return; + } if (start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { @@ -70,7 +74,9 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, { DeclareAndCast(StepShape_ContextDependentShapeRepresentation, anitem, subs.Value()); if (anitem.IsNull()) + { continue; + } Count(graph, anitem); } return; @@ -105,7 +111,9 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, AddShell(brwv->Outer()); int nbvoids = brwv->NbVoids(); for (int i = 1; i <= nbvoids; i++) + { AddShell(brwv->VoidsValue(i)); + } return; } @@ -126,10 +134,14 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, { occ::handle osh = sbsm->SbsmBoundaryValue(i).OpenShell(); if (!osh.IsNull()) + { AddShell(osh); + } occ::handle csh = sbsm->SbsmBoundaryValue(i).ClosedShell(); if (!csh.IsNull()) + { AddShell(csh); + } } return; } @@ -142,7 +154,9 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, AddShell(fbwv->Outer()); int nbvoids = fbwv->NbVoids(); for (int i = 1; i <= nbvoids; i++) + { AddShell(fbwv->VoidsValue(i)); + } return; } @@ -180,7 +194,9 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, Count(graph, mi->MappingTarget()); occ::handle map = mi->MappingSource(); if (map.IsNull()) + { return; + } Count(graph, map->MappedRepresentation()); return; } @@ -197,22 +213,30 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, DeclareAndCast(StepShape_ContextDependentShapeRepresentation, CDSR, start); occ::handle SRR = CDSR->RepresentationRelation(); if (SRR.IsNull()) + { return; + } occ::handle rep; bool SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO(graph, CDSR); if (SRRReversed) + { rep = SRR->Rep2(); + } else + { rep = SRR->Rep1(); + } Interface_EntityIterator subs = graph.Sharings(rep); for (subs.Start(); subs.More(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { DeclareAndCast(StepShape_ShapeDefinitionRepresentation, SDR, subs.Value()); Count(graph, SDR); } + } //??? return; } @@ -224,9 +248,13 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, { occ::handle anitem; if (i == 1) + { anitem = und->Rep1(); + } if (i == 2) + { anitem = und->Rep2(); + } Count(graph, anitem); } return; @@ -253,9 +281,10 @@ void STEPSelections_Counter::AddShell(const occ::handleNbCfsFaces(); for (int i = 1; i <= nbf; i++) + { myMapOfFaces.Add(cfs->CfsFacesValue(i)); + } myNbFaces += nbf; - return; } void STEPSelections_Counter::AddCompositeCurve(const occ::handle& ccurve) @@ -268,7 +297,9 @@ void STEPSelections_Counter::AddCompositeCurve(const occ::handle crv = ccs->ParentCurve(); if (crv->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve))) + { AddCompositeCurve(occ::down_cast(crv)); + } else { myNbEdges++; diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectAssembly.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectAssembly.cxx index 138e011e3d..768081b42f 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectAssembly.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectAssembly.cxx @@ -41,17 +41,23 @@ bool STEPSelections_SelectAssembly::Explore(const int /*level*/, Interface_EntityIterator& explored) const { if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) { DeclareAndCast(StepShape_ContextDependentShapeRepresentation, sdsr, start); occ::handle pds = sdsr->RepresentedProductRelation(); if (pds.IsNull()) + { return false; + } occ::handle ent = pds->Definition().ProductDefinitionRelationship(); if (ent.IsNull()) + { return false; + } return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))); } @@ -61,26 +67,42 @@ bool STEPSelections_SelectAssembly::Explore(const int /*level*/, Interface_EntityIterator subs = G.Sharings(mapped); occ::handle shrep; for (subs.Start(); subs.More() && shrep.IsNull(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { shrep = occ::down_cast(subs.Value()); + } + } if (shrep.IsNull()) + { return false; + } subs = G.Sharings(shrep); occ::handle shdefrep; for (subs.Start(); subs.More() && shdefrep.IsNull(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) + { shdefrep = occ::down_cast(subs.Value()); + } + } if (shdefrep.IsNull()) + { return false; + } occ::handle pds = occ::down_cast(shdefrep->Definition().PropertyDefinition()); if (pds.IsNull()) + { return false; + } occ::handle ent = pds->Definition().ProductDefinitionRelationship(); if (ent.IsNull()) + { return false; + } return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))); } @@ -88,7 +110,9 @@ bool STEPSelections_SelectAssembly::Explore(const int /*level*/, subs.Start(); bool isSome = subs.More(); for (; subs.More(); subs.Next()) + { explored.AddItem(subs.Value()); + } return isSome; } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectDerived.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectDerived.cxx index 187bf57576..5b6975b20e 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectDerived.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectDerived.cxx @@ -35,10 +35,14 @@ static occ::handle GetStepType(const occ::handle atype; if (module.IsNull()) + { return atype; + } int num = module->CaseStep(type); if (num == 0) + { return atype; + } occ::handle ent; RWStepAP214_GeneralModule genModul; genModul.NewVoid(num, ent); @@ -55,17 +59,23 @@ bool STEPSelections_SelectDerived::Matches(const occ::handle occ::handle module; bool ok = thelib.Select(ent, module, CN); if (!ok) + { return false; + } occ::handle checker = GetStepType(module, text); if (checker.IsNull()) + { return false; + } bool plex = module->IsComplex(CN); if (!plex) { DeclareAndCast(Standard_Type, atype, ent); if (atype.IsNull()) + { atype = ent->DynamicType(); + } return atype->SubType(checker); } else @@ -77,7 +87,9 @@ bool STEPSelections_SelectDerived::Matches(const occ::handle { occ::handle atype = GetStepType(module, list.Value(i)); if (atype->SubType(checker)) + { return true; + } } } return false; diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectFaces.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectFaces.cxx index cb12a255f9..def76225d3 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectFaces.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectFaces.cxx @@ -37,10 +37,14 @@ bool STEPSelections_SelectFaces::Explore(const int /*level*/, Interface_EntityIterator& explored) const { if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(StepShape_FaceSurface))) + { return true; + } bool isInFaceOfInSurface = false; if (start->IsKind(STANDARD_TYPE(StepGeom_Surface))) @@ -49,11 +53,17 @@ bool STEPSelections_SelectFaces::Explore(const int /*level*/, for (subs.Start(); subs.More(); subs.Next()) { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) + { return true; + } if (subs.Value()->IsKind(STANDARD_TYPE(StepGeom_Surface))) + { isInFaceOfInSurface = true; + } if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_FaceSurface))) + { isInFaceOfInSurface = true; + } } return !isInFaceOfInSurface; } @@ -61,7 +71,9 @@ bool STEPSelections_SelectFaces::Explore(const int /*level*/, subs.Start(); bool isSome = subs.More(); for (; subs.More(); subs.Next()) + { explored.AddItem(subs.Value()); + } return isSome; } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectForTransfer.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectForTransfer.cxx index d4fe72725e..b8379456e1 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectForTransfer.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectForTransfer.cxx @@ -45,6 +45,8 @@ Interface_EntityIterator STEPSelections_SelectForTransfer::RootResult( Reader()->TransientProcess()->RootsForTransfer(); int nb = roots->Length(); for (int i = 1; i <= nb; i++) + { iter.GetOneItem(roots->Value(i)); + } return iter; } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectGSCurves.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectGSCurves.cxx index 912ae56200..f397038f5a 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectGSCurves.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectGSCurves.cxx @@ -44,7 +44,9 @@ bool STEPSelections_SelectGSCurves::Explore(const int /*level*/, Interface_EntityIterator& explored) const { if (start.IsNull()) + { return false; + } if (start->IsKind(STANDARD_TYPE(StepGeom_Curve))) { @@ -53,6 +55,7 @@ bool STEPSelections_SelectGSCurves::Explore(const int /*level*/, Interface_EntityIterator subs = G.Sharings(start); bool isInGeomSet = false; for (subs.Start(); subs.More() && !isInGeomSet; subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) { if (flag) @@ -62,17 +65,22 @@ bool STEPSelections_SelectGSCurves::Explore(const int /*level*/, } isInGeomSet = true; } + } if (isInGeomSet) { Interface_EntityIterator aSubsShareds = G.Shareds(start); aSubsShareds.Start(); bool isSome = aSubsShareds.More(); for (; aSubsShareds.More(); aSubsShareds.Next()) + { explored.AddItem(aSubsShareds.Value()); + } return isSome; } else + { return false; + } } else { @@ -81,7 +89,9 @@ bool STEPSelections_SelectGSCurves::Explore(const int /*level*/, { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet)) || subs.Value()->IsKind(STANDARD_TYPE(StepGeom_CompositeCurveSegment))) + { return true; + } } } } @@ -90,7 +100,9 @@ bool STEPSelections_SelectGSCurves::Explore(const int /*level*/, subs.Start(); bool isSome = subs.More(); for (; subs.More(); subs.Next()) + { explored.AddItem(subs.Value()); + } return isSome; } diff --git a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectInstances.cxx b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectInstances.cxx index 6c3ae727b8..c7698ba49b 100644 --- a/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectInstances.cxx +++ b/src/DataExchange/TKDESTEP/STEPSelections/STEPSelections_SelectInstances.cxx @@ -55,7 +55,9 @@ static void AddAllSharings(const occ::handle& start, Interface_EntityIterator& explored) { if (start.IsNull()) + { return; + } Interface_EntityIterator subs = graph.Shareds(start); for (subs.Start(); subs.More(); subs.Next()) { @@ -69,7 +71,9 @@ static void AddInstances(const occ::handle& start, Interface_EntityIterator& explored) { if (start.IsNull()) + { return; + } explored.AddItem(start); if (start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) @@ -81,7 +85,9 @@ static void AddInstances(const occ::handle& start, { DeclareAndCast(StepShape_ContextDependentShapeRepresentation, anitem, subs.Value()); if (anitem.IsNull()) + { continue; + } AddInstances(anitem, graph, explored); } return; @@ -117,22 +123,30 @@ static void AddInstances(const occ::handle& start, DeclareAndCast(StepShape_ContextDependentShapeRepresentation, CDSR, start); occ::handle SRR = CDSR->RepresentationRelation(); if (SRR.IsNull()) + { return; + } occ::handle rep; bool SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO(graph, CDSR); if (SRRReversed) + { rep = SRR->Rep2(); + } else + { rep = SRR->Rep1(); + } Interface_EntityIterator subs = graph.Sharings(rep); for (subs.Start(); subs.More(); subs.Next()) + { if (subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { DeclareAndCast(StepShape_ShapeDefinitionRepresentation, SDR, subs.Value()); AddInstances(SDR, graph, explored); } + } //??? return; } @@ -144,9 +158,13 @@ static void AddInstances(const occ::handle& start, { occ::handle anitem; if (i == 1) + { anitem = und->Rep1(); + } if (i == 2) + { anitem = und->Rep2(); + } AddInstances(anitem, graph, explored); } return; @@ -161,7 +179,9 @@ Interface_EntityIterator STEPSelections_SelectInstances::RootResult(const Interf myGraph = new Interface_HGraph(G); myEntities.Destroy(); for (roots.Start(); roots.More(); roots.Next()) + { AddInstances(roots.Value(), G, myEntities); + } } if (HasInput() || HasAlternate()) @@ -170,15 +190,23 @@ Interface_EntityIterator STEPSelections_SelectInstances::RootResult(const Interf int nbSelected = select.NbEntities(); NCollection_IndexedMap> filter(nbSelected); for (select.Start(); select.More(); select.Next()) + { filter.Add(select.Value()); + } Interface_EntityIterator result; for (myEntities.Start(); myEntities.More(); myEntities.Next()) + { if (filter.Contains(myEntities.Value())) + { result.AddItem(myEntities.Value()); + } + } return result; } else + { return myEntities; + } } bool STEPSelections_SelectInstances::Explore(const int, diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ApprovedItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ApprovedItem.cxx index af55cc9eae..43cdccce33 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ApprovedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ApprovedItem.cxx @@ -39,29 +39,53 @@ StepAP203_ApprovedItem::StepAP203_ApprovedItem() = default; int StepAP203_ApprovedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationEffectivity))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationItem))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_ChangeRequest))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_Change))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartRequest))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartWork))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Certification))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Contract))) + { return 11; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_CertifiedItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_CertifiedItem.cxx index 2b00f38152..4f0f249bf8 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_CertifiedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_CertifiedItem.cxx @@ -29,9 +29,13 @@ StepAP203_CertifiedItem::StepAP203_CertifiedItem() = default; int StepAP203_CertifiedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_SuppliedPartRelationship))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ChangeRequestItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ChangeRequestItem.cxx index 66bc90659e..f38a389a63 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ChangeRequestItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ChangeRequestItem.cxx @@ -29,9 +29,13 @@ StepAP203_ChangeRequestItem::StepAP203_ChangeRequestItem() = default; int StepAP203_ChangeRequestItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ClassifiedItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ClassifiedItem.cxx index 856bf9392c..76a4233a6b 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ClassifiedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ClassifiedItem.cxx @@ -30,11 +30,17 @@ StepAP203_ClassifiedItem::StepAP203_ClassifiedItem() = default; int StepAP203_ClassifiedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsage))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ContractedItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ContractedItem.cxx index 8c56201d3f..a59f00da34 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ContractedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_ContractedItem.cxx @@ -29,9 +29,13 @@ StepAP203_ContractedItem::StepAP203_ContractedItem() = default; int StepAP203_ContractedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_DateTimeItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_DateTimeItem.cxx index 92e6afc532..abb1d443a6 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_DateTimeItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_DateTimeItem.cxx @@ -37,25 +37,45 @@ StepAP203_DateTimeItem::StepAP203_DateTimeItem() = default; int StepAP203_DateTimeItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_ChangeRequest))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartRequest))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_Change))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartWork))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalPersonOrganization))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Contract))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Certification))) + { return 9; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_PersonOrganizationItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_PersonOrganizationItem.cxx index 8d913e15b5..a8dd493a39 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_PersonOrganizationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_PersonOrganizationItem.cxx @@ -38,27 +38,49 @@ StepAP203_PersonOrganizationItem::StepAP203_PersonOrganizationItem() = default; int StepAP203_PersonOrganizationItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_Change))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartWork))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_ChangeRequest))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepAP203_StartRequest))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationItem))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Contract))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 10; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_SpecifiedItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_SpecifiedItem.cxx index a74e4ea24e..7e6d4b59ad 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_SpecifiedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_SpecifiedItem.cxx @@ -30,11 +30,17 @@ StepAP203_SpecifiedItem::StepAP203_SpecifiedItem() = default; int StepAP203_SpecifiedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_StartRequestItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_StartRequestItem.cxx index 2fac99f758..a54b8a0702 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_StartRequestItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_StartRequestItem.cxx @@ -29,9 +29,13 @@ StepAP203_StartRequestItem::StepAP203_StartRequestItem() = default; int StepAP203_StartRequestItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_WorkItem.cxx b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_WorkItem.cxx index efda9e1ffd..b7b3bd14d4 100644 --- a/src/DataExchange/TKDESTEP/StepAP203/StepAP203_WorkItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP203/StepAP203_WorkItem.cxx @@ -29,9 +29,13 @@ StepAP203_WorkItem::StepAP203_WorkItem() = default; int StepAP203_WorkItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP209/StepAP209_Construct.cxx b/src/DataExchange/TKDESTEP/StepAP209/StepAP209_Construct.cxx index 44c2fb6e4e..bfc2f557a5 100644 --- a/src/DataExchange/TKDESTEP/StepAP209/StepAP209_Construct.cxx +++ b/src/DataExchange/TKDESTEP/StepAP209/StepAP209_Construct.cxx @@ -130,9 +130,13 @@ bool StepAP209_Construct::IsDesing( occ::handle PDFR = occ::down_cast(subs.Value()); if (PDFR.IsNull()) + { continue; + } if (PDF == PDFR->RelatingProductDefinitionFormation()) + { return true; + } } return false; } @@ -148,9 +152,13 @@ bool StepAP209_Construct::IsAnalys( occ::handle PDFR = occ::down_cast(subs.Value()); if (PDFR.IsNull()) + { continue; + } if (PDF == PDFR->RelatedProductDefinitionFormation()) + { return true; + } } return false; } @@ -206,20 +214,28 @@ occ::handle StepAP209_Construct::GetShReprForElem { occ::handle SR; if (ElemRepr.IsNull()) + { return SR; + } Interface_EntityIterator subs = Graph().Sharings(ElemRepr); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle EGR = occ::down_cast(subs.Value()); if (EGR.IsNull()) + { continue; + } occ::handle AIWR = EGR->Item(); if (AIWR.IsNull()) + { continue; + } occ::handle Repr = AIWR->Rep(); if (Repr.IsNull()) + { continue; + } SR = occ::down_cast(Repr); } return SR; @@ -234,14 +250,18 @@ occ::handle StepAP209_Construct::FeaModel( { occ::handle FM; if (Prod.IsNull()) + { return FM; + } Interface_EntityIterator subs = Graph().Sharings(Prod); for (subs.Start(); subs.More() && FM.IsNull(); subs.Next()) { occ::handle PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } FM = FeaModel(PDF); } return FM; @@ -256,14 +276,18 @@ occ::handle StepAP209_Construct::FeaModel( // int nb = model->NbEntities(); occ::handle FM; if (PD.IsNull()) + { return FM; + } Interface_EntityIterator subs = Graph().Shareds(PD); for (subs.Start(); subs.More() && FM.IsNull(); subs.Next()) { occ::handle PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } FM = FeaModel(PDF); } return FM; @@ -276,7 +300,9 @@ occ::handle StepAP209_Construct::FeaModel( { occ::handle FM; if (PDF.IsNull()) + { return FM; + } occ::handle PDF2; Interface_EntityIterator subs = Graph().Sharings(PDF); for (subs.Start(); subs.More(); subs.Next()) @@ -284,25 +310,33 @@ occ::handle StepAP209_Construct::FeaModel( occ::handle PDFR = occ::down_cast(subs.Value()); if (PDFR.IsNull()) + { continue; + } PDF2 = PDFR->RelatedProductDefinitionFormation(); } if (PDF2.IsNull()) + { return FM; + } subs = Graph().Sharings(PDF2); for (subs.Start(); subs.More() && FM.IsNull(); subs.Next()) { occ::handle PD = occ::down_cast(subs.Value()); if (PD.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Graph().Sharings(PD); for (subs2.Start(); subs2.More() && FM.IsNull(); subs2.Next()) { occ::handle PDS = occ::down_cast(subs2.Value()); if (PDS.IsNull()) + { continue; + } FM = FeaModel(PDS); } } @@ -321,7 +355,9 @@ occ::handle StepAP209_Construct::FeaModel( occ::handle FMD = occ::down_cast(subs.Value()); if (FMD.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Graph().Sharings(FMD); for (subs2.Start(); subs2.More() && FM.IsNull(); subs2.Next()) { @@ -329,7 +365,9 @@ occ::handle StepAP209_Construct::FeaModel( occ::handle SRP = occ::down_cast(subs2.Value()); if (SRP.IsNull()) + { continue; + } Interface_EntityIterator subs3 = Graph().Sharings(SRP); for (subs3.Start(); subs3.More() && FM.IsNull(); subs3.Next()) { @@ -339,12 +377,18 @@ occ::handle StepAP209_Construct::FeaModel( occ::down_cast( subs3.Value()); if (SRPDR.IsNull()) + { continue; + } occ::handle Repr = SRPDR->UsedRepresentation(); if (Repr.IsNull()) + { continue; + } if (Repr->IsKind(STANDARD_TYPE(StepFEA_FeaModel))) + { FM = occ::down_cast(Repr); + } } } } @@ -358,13 +402,17 @@ occ::handle StepAP209_Construct::GetFeaAxis2Placeme { occ::handle FA2P3D = new StepFEA_FeaAxis2Placement3d; if (theFeaModel.IsNull()) + { return FA2P3D; + } Interface_EntityIterator subs = Graph().Shareds(theFeaModel); for (subs.Start(); subs.More(); subs.Next()) { FA2P3D = occ::down_cast(subs.Value()); if (FA2P3D.IsNull()) + { continue; + } return FA2P3D; } return FA2P3D; @@ -379,14 +427,18 @@ occ::handle StepAP209_Construct::IdealShape( { occ::handle SR; if (Prod.IsNull()) + { return SR; + } Interface_EntityIterator subs = Graph().Sharings(Prod); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } SR = IdealShape(PDF); } return SR; @@ -399,14 +451,18 @@ occ::handle StepAP209_Construct::IdealShape( { occ::handle SR; if (PD.IsNull()) + { return SR; + } Interface_EntityIterator subs = Graph().Shareds(PD); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } SR = IdealShape(PDF); } return SR; @@ -419,7 +475,9 @@ occ::handle StepAP209_Construct::IdealShape( { occ::handle SR; if (PDF.IsNull()) + { return SR; + } occ::handle PDF2; Interface_EntityIterator subs = Graph().Sharings(PDF); for (subs.Start(); subs.More(); subs.Next()) @@ -427,25 +485,33 @@ occ::handle StepAP209_Construct::IdealShape( occ::handle PDFR = occ::down_cast(subs.Value()); if (PDFR.IsNull()) + { continue; + } PDF2 = PDFR->RelatedProductDefinitionFormation(); } if (PDF2.IsNull()) + { return SR; + } subs = Graph().Sharings(PDF2); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle PD = occ::down_cast(subs.Value()); if (PD.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Graph().Sharings(PD); for (subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) { occ::handle PDS = occ::down_cast(subs2.Value()); if (PDS.IsNull()) + { continue; + } SR = IdealShape(PDS); } } @@ -464,7 +530,9 @@ occ::handle StepAP209_Construct::IdealShape( occ::handle SDR = occ::down_cast(subs.Value()); if (SDR.IsNull()) + { continue; + } SR = occ::down_cast(SDR->UsedRepresentation()); } return SR; @@ -479,14 +547,18 @@ occ::handle StepAP209_Construct::NominShape( { occ::handle SR; if (Prod.IsNull()) + { return SR; + } Interface_EntityIterator subs = Graph().Sharings(Prod); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } SR = NominShape(PDF); } return SR; @@ -499,7 +571,9 @@ occ::handle StepAP209_Construct::NominShape( { occ::handle SR; if (PDF.IsNull()) + { return SR; + } occ::handle PDF2; Interface_EntityIterator subs = Graph().Sharings(PDF); for (subs.Start(); subs.More(); subs.Next()) @@ -507,32 +581,42 @@ occ::handle StepAP209_Construct::NominShape( occ::handle PDFR = occ::down_cast(subs.Value()); if (PDFR.IsNull()) + { continue; + } PDF2 = PDFR->RelatingProductDefinitionFormation(); } if (PDF2.IsNull()) + { return SR; + } subs = Graph().Sharings(PDF2); for (subs.Start(); subs.More() && SR.IsNull(); subs.Next()) { occ::handle PD = occ::down_cast(subs.Value()); if (PD.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Graph().Sharings(PD); for (subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) { occ::handle PDS = occ::down_cast(subs2.Value()); if (PDS.IsNull()) + { continue; + } Interface_EntityIterator subs3 = Graph().Sharings(PDS); for (subs3.Start(); subs3.More() && SR.IsNull(); subs3.Next()) { occ::handle SDR = occ::down_cast(subs3.Value()); if (SDR.IsNull()) + { continue; + } SR = occ::down_cast(SDR->UsedRepresentation()); } } @@ -572,12 +656,16 @@ occ::handle>> S { occ::handle>> aSequence; if (!theType->SubType(STANDARD_TYPE(StepFEA_ElementRepresentation))) + { return aSequence; + } Interface_EntityIterator anIter = Graph().Sharings(theFeaModel); anIter.Start(); if (anIter.More()) + { aSequence = new NCollection_HSequence>; + } for (; anIter.More(); anIter.Next()) { @@ -601,23 +689,31 @@ occ::handle>> aSequence = new NCollection_HSequence>; if (ElemRepr.IsNull()) + { return aSequence; + } occ::handle C3dEP = ElemRepr->Property(); if (C3dEP.IsNull()) + { return aSequence; + } occ::handle>> ACEI = C3dEP->IntervalDefinitions(); if (ACEI.IsNull()) + { return aSequence; + } for (int i = 1; i <= ACEI->Length(); i++) { occ::handle CEIC = occ::down_cast(ACEI->Value(i)); if (CEIC.IsNull()) + { continue; + } aSequence->Append(CEIC->Section()); } return aSequence; @@ -628,17 +724,23 @@ occ::handle& Prod) const { if (Prod.IsNull()) + { return false; + } Interface_EntityIterator subs = Graph().Sharings(Prod); occ::handle PDF; for (subs.Start(); subs.More() && PDF.IsNull(); subs.Next()) { PDF = occ::down_cast(subs.Value()); if (PDF.IsNull()) + { continue; + } } if (PDF.IsNull()) + { return false; + } // if( IsDesing(PDF) || IsAnalys(PDF) ) return false; // find nominal_design_shape: @@ -649,27 +751,35 @@ bool StepAP209_Construct::CreateAnalysStructure(const occ::handle(subs.Value()); if (PD.IsNull()) + { continue; + } Interface_EntityIterator subs2 = Graph().Sharings(PD); for (subs2.Start(); subs2.More() && SR.IsNull(); subs2.Next()) { occ::handle PDS = occ::down_cast(subs2.Value()); if (PDS.IsNull()) + { continue; + } Interface_EntityIterator subs3 = Graph().Sharings(PDS); for (subs3.Start(); subs3.More() && SR.IsNull(); subs3.Next()) { occ::handle SDR = occ::down_cast(subs3.Value()); if (SDR.IsNull()) + { continue; + } SR = occ::down_cast(SDR->UsedRepresentation()); } } } if (SR.IsNull()) + { return false; // no nominal_design_shape + } // create structure: ReplaceCcDesingToApplied(); @@ -817,7 +927,9 @@ bool StepAP209_Construct::CreateFeaStructure(const occ::handle SDR = occ::down_cast(subs.Value()); if (SDR.IsNull()) + { continue; + } AnaPDS = occ::down_cast(SDR->Definition().Value()); } @@ -882,7 +994,9 @@ bool StepAP209_Construct::CreateFeaStructure(const occ::handle>> NewHANU = new NCollection_HArray1>(1, OldHANU->Length() + 3); for (int i = 1; i <= OldHANU->Length(); i++) + { NewHANU->SetValue(i, OldHANU->Value(i)); + } // create SiUnitAndTimeUnit occ::handle SUTU = new StepBasic_SiUnitAndTimeUnit; SUTU->Init(false, StepBasic_spExa, StepBasic_sunSecond); @@ -1286,7 +1400,9 @@ occ::handle StepAP209_Construct::CreateAP203Structure() cons occ::handle smodel = occ::down_cast(Model()); occ::handle nmodel; // = new StepData_StepModel; if (smodel.IsNull()) + { return nmodel; + } // nmodel->SetProtocol(smodel->Protocol()); occ::handle PDF; occ::handle PD; @@ -1300,10 +1416,14 @@ occ::handle StepAP209_Construct::CreateAP203Structure() cons SDR = occ::down_cast(smodel->Value(i)); PDS = occ::down_cast(SDR->Definition().Value()); if (PDS.IsNull()) + { continue; + } PD = occ::down_cast(PDS->Definition().Value()); if (PD.IsNull()) + { continue; + } occ::handle PDF1 = PD->Formation(); if (IsDesing(PDF1)) { @@ -1313,7 +1433,9 @@ occ::handle StepAP209_Construct::CreateAP203Structure() cons } } if (PDF.IsNull()) + { return nmodel; + } nmodel = new StepData_StepModel; nmodel->SetProtocol(smodel->Protocol()); @@ -1380,7 +1502,9 @@ occ::handle StepAP209_Construct::CreateAP203Structure() cons { APD = occ::down_cast(subs.Value()); if (APD.IsNull()) + { continue; + } nmodel->AddWithRefs(APD); } } @@ -1410,7 +1534,9 @@ occ::handle StepAP209_Construct::CreateAP203Structure() cons occ::handle FS = occ::down_cast( smodel->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))); if (!FS.IsNull()) + { nmodel->AddHeaderEntity(FS); + } occ::handle FD = occ::down_cast( smodel->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))); if (!FD.IsNull()) @@ -1449,7 +1575,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle ASCA = occ::down_cast(subs.Value()); if (ASCA.IsNull()) + { continue; + } SC = ASCA->AssignedSecurityClassification(); } if (SC.IsNull()) @@ -1500,12 +1628,16 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle ADT = occ::down_cast(subs2.Value()); if (ADT.IsNull()) + { continue; + } aModel->AddWithRefs(ADT); occ::handle DT1 = occ::down_cast(ADT->DateTime().Value()); if (DT1.IsNull()) + { continue; + } DT = DT1; } } @@ -1536,12 +1668,16 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle ADT = occ::down_cast(subs2.Value()); if (ADT.IsNull()) + { continue; + } aModel->AddWithRefs(ADT); occ::handle DT1 = occ::down_cast(ADT->DateTime().Value()); if (DT1.IsNull()) + { continue; + } DT = DT1; } } @@ -1572,12 +1708,16 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle ADT = occ::down_cast(subs2.Value()); if (ADT.IsNull()) + { continue; + } aModel->AddWithRefs(ADT); occ::handle DT1 = occ::down_cast(ADT->DateTime().Value()); if (DT1.IsNull()) + { continue; + } DT = DT1; } } @@ -1592,7 +1732,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle ADTA = occ::down_cast(subs.Value()); if (ADTA.IsNull()) + { continue; + } occ::handle> HADTI214 = ADTA->Items(); occ::handle> HADTI = new NCollection_HArray1(1, HADTI214->Length()); @@ -1616,7 +1758,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle APOA = occ::down_cast(subs.Value()); if (APOA.IsNull()) + { continue; + } occ::handle> HAPOI214 = APOA->Items(); occ::handle> HAPOI = new NCollection_HArray1(1, HAPOI214->Length()); @@ -1637,7 +1781,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle APOA = occ::down_cast(subs.Value()); if (APOA.IsNull()) + { continue; + } occ::handle> HAPOI214 = APOA->Items(); occ::handle> HAPOI = new NCollection_HArray1(1, HAPOI214->Length()); @@ -1658,7 +1804,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle APOA = occ::down_cast(subs.Value()); if (APOA.IsNull()) + { continue; + } occ::handle> HAPOI214 = APOA->Items(); occ::handle> HAPOI = new NCollection_HArray1(1, HAPOI214->Length()); @@ -1679,7 +1827,9 @@ bool StepAP209_Construct::CreateAdding203Entities( occ::handle APOA = occ::down_cast(subs.Value()); if (APOA.IsNull()) + { continue; + } occ::handle> HAPOI214 = APOA->Items(); occ::handle> HAPOI = new NCollection_HArray1(1, HAPOI214->Length()); diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedPresentedItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedPresentedItem.cxx index 80bb965379..c03b6f2264 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedPresentedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedPresentedItem.cxx @@ -45,6 +45,8 @@ StepAP214_PresentedItemSelect StepAP214_AppliedPresentedItem::ItemsValue(const i int StepAP214_AppliedPresentedItem::NbItems() const { if (items.IsNull()) + { return 0; + } return items->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedSecurityClassificationAssignment.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedSecurityClassificationAssignment.cxx index 609890a744..b8d3337735 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedSecurityClassificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AppliedSecurityClassificationAssignment.cxx @@ -52,6 +52,8 @@ const StepAP214_SecurityClassificationItem& StepAP214_AppliedSecurityClassificat int StepAP214_AppliedSecurityClassificationAssignment::NbItems() const { if (items.IsNull()) + { return 0; + } return items->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ApprovalItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ApprovalItem.cxx index efecdc097a..332bb80784 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ApprovalItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ApprovalItem.cxx @@ -40,49 +40,93 @@ int StepAP214_ApprovalItem::CaseNum(const occ::handle& ent) { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationItem))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Date))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Document))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Effectivity))) + { return 16; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Group))) + { return 17; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GroupRelationship))) + { return 18; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormationRelationship))) + { return 19; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 20; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 21; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndPersonItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndPersonItem.cxx index 3124ca98bf..d98e4c3016 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndPersonItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndPersonItem.cxx @@ -28,25 +28,45 @@ StepAP214_AutoDesignDateAndPersonItem::StepAP214_AutoDesignDateAndPersonItem() = int StepAP214_AutoDesignDateAndPersonItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AutoDesignOrganizationAssignment))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AutoDesignDocumentReference))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ExternallyDefinedRepresentation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) + { return 9; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndTimeItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndTimeItem.cxx index 68cfcc79b6..49f0990d89 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndTimeItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDateAndTimeItem.cxx @@ -23,13 +23,21 @@ StepAP214_AutoDesignDateAndTimeItem::StepAP214_AutoDesignDateAndTimeItem() = def int StepAP214_AutoDesignDateAndTimeItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalPersonOrganization))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AutoDesignDateAndPersonAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionEffectivity))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDatedItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDatedItem.cxx index 63dfeb163b..58bd580fd1 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDatedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignDatedItem.cxx @@ -23,13 +23,21 @@ StepAP214_AutoDesignDatedItem::StepAP214_AutoDesignDatedItem() = default; int StepAP214_AutoDesignDatedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalPersonOrganization))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AutoDesignDateAndPersonAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionEffectivity))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGeneralOrgItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGeneralOrgItem.cxx index aa6833b885..dc874ecb39 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGeneralOrgItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGeneralOrgItem.cxx @@ -27,23 +27,41 @@ StepAP214_AutoDesignGeneralOrgItem::StepAP214_AutoDesignGeneralOrgItem() = defau int StepAP214_AutoDesignGeneralOrgItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ExternallyDefinedRepresentation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AutoDesignDocumentReference))) + { return 8; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGroupedItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGroupedItem.cxx index 54561c6a92..a48a6c142e 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGroupedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignGroupedItem.cxx @@ -30,29 +30,53 @@ StepAP214_AutoDesignGroupedItem::StepAP214_AutoDesignGroupedItem() = default; int StepAP214_AutoDesignGroupedItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_AdvancedBrepShapeRepresentation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_CsgShapeRepresentation))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepShape_FacetedBrepShapeRepresentation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepShape_GeometricallyBoundedSurfaceShapeRepresentation))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepShape_GeometricallyBoundedWireframeShapeRepresentation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ManifoldSurfaceShapeRepresentation))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_TemplateInstance))) + { return 11; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignOrganizationItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignOrganizationItem.cxx index f5b77f5b6d..05ccf5b9aa 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignOrganizationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignOrganizationItem.cxx @@ -22,14 +22,22 @@ StepAP214_AutoDesignOrganizationItem::StepAP214_AutoDesignOrganizationItem() = d int StepAP214_AutoDesignOrganizationItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } int num = StepAP214_AutoDesignGeneralOrgItem::CaseNum(ent); if (num > 0) + { return num; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Document))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_PhysicallyModeledProductDefinition))) + { return 10; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItem.cxx index 19cc5659a2..e0c4fb7409 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItem.cxx @@ -46,6 +46,8 @@ StepAP214_AutoDesignPresentedItemSelect StepAP214_AutoDesignPresentedItem::Items int StepAP214_AutoDesignPresentedItem::NbItems() const { if (items.IsNull()) + { return 0; + } return items->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItemSelect.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItemSelect.cxx index f209b0fc1f..ff1c5b976f 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItemSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignPresentedItemSelect.cxx @@ -27,19 +27,33 @@ int StepAP214_AutoDesignPresentedItemSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentRelationship))) + { return 6; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignReferencingItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignReferencingItem.cxx index 4c2048849f..ecc7e48977 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignReferencingItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignReferencingItem.cxx @@ -34,36 +34,66 @@ StepAP214_AutoDesignReferencingItem::StepAP214_AutoDesignReferencingItem() = def int StepAP214_AutoDesignReferencingItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Approval))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentRelationship))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ExternallyDefinedRepresentation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationView))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductCategory))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 14; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignSecurityClassificationAssignment.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignSecurityClassificationAssignment.cxx index 352ee74135..5d55783f48 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignSecurityClassificationAssignment.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_AutoDesignSecurityClassificationAssignment.cxx @@ -53,6 +53,8 @@ occ::handle StepAP214_AutoDesignSecurityClassificationAssign int StepAP214_AutoDesignSecurityClassificationAssignment::NbItems() const { if (items.IsNull()) + { return 0; + } return items->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateAndTimeItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateAndTimeItem.cxx index f36515c59d..70750c94c4 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateAndTimeItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateAndTimeItem.cxx @@ -36,39 +36,73 @@ StepAP214_DateAndTimeItem::StepAP214_DateAndTimeItem() = default; int StepAP214_DateAndTimeItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalPersonOrganization))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedPersonAndOrganizationAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Effectivity))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 16; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateItem.cxx index 5de9a929bf..d43c7791f9 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DateItem.cxx @@ -36,41 +36,77 @@ StepAP214_DateItem::StepAP214_DateItem() = default; int StepAP214_DateItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalPersonOrganization))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedPersonAndOrganizationAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Effectivity))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedSecurityClassificationAssignment))) + { return 16; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Document))) + { return 17; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DocumentReferenceItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DocumentReferenceItem.cxx index ecced6fb4d..d9a2226cae 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DocumentReferenceItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_DocumentReferenceItem.cxx @@ -39,47 +39,89 @@ StepAP214_DocumentReferenceItem::StepAP214_DocumentReferenceItem() = default; int StepAP214_DocumentReferenceItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Approval))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedExternalIdentificationAssignment))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsage))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_CharacterizedObject))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ExternallyDefinedItem))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Group))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GroupRelationship))) + { return 16; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) + { return 17; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductCategory))) + { return 18; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionContext))) + { return 19; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return 20; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ExternalIdentificationItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ExternalIdentificationItem.cxx index 4340e9f14e..16d6f82a51 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ExternalIdentificationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_ExternalIdentificationItem.cxx @@ -42,37 +42,69 @@ StepAP214_ExternalIdentificationItem::StepAP214_ExternalIdentificationItem() = d int StepAP214_ExternalIdentificationItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_ExternallyDefinedClass))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_ExternallyDefinedGeneralProperty))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedPersonAndOrganizationAssignment))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Approval))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalStatus))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ExternalSource))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_OrganizationalAddress))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_VersionedActionRequest))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DateAndTimeAssignment))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DateAssignment))) + { return 15; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_GroupItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_GroupItem.cxx index db77d04ccd..f8bcdf8989 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_GroupItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_GroupItem.cxx @@ -34,35 +34,65 @@ StepAP214_GroupItem::StepAP214_GroupItem() = default; int StepAP214_GroupItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GroupRelationship))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinitionRepresentation))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationshipWithTransformation))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_StyledItem))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem))) + { return 14; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_OrganizationItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_OrganizationItem.cxx index dcf0275cc8..adfa2fd029 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_OrganizationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_OrganizationItem.cxx @@ -35,37 +35,69 @@ StepAP214_OrganizationItem::StepAP214_OrganizationItem() = default; int StepAP214_OrganizationItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Approval))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedSecurityClassificationAssignment))) + { return 15; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PersonAndOrganizationItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PersonAndOrganizationItem.cxx index e867e0c664..1b27b29ac2 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PersonAndOrganizationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PersonAndOrganizationItem.cxx @@ -35,37 +35,69 @@ StepAP214_PersonAndOrganizationItem::StepAP214_PersonAndOrganizationItem() = def int StepAP214_PersonAndOrganizationItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassification))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedSecurityClassificationAssignment))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Approval))) + { return 15; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PresentedItemSelect.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PresentedItemSelect.cxx index 2cf0d62685..00b7db783b 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PresentedItemSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_PresentedItemSelect.cxx @@ -22,11 +22,17 @@ StepAP214_PresentedItemSelect::StepAP214_PresentedItemSelect() = default; int StepAP214_PresentedItemSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_Protocol.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_Protocol.cxx index 2bd87735c1..3dbaf2d4e7 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_Protocol.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_Protocol.cxx @@ -1580,9 +1580,13 @@ StepAP214_Protocol::StepAP214_Protocol() int StepAP214_Protocol::TypeNumber(const occ::handle& atype) const { if (types.IsBound(atype)) + { return types.Find(atype); + } else + { return 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_SecurityClassificationItem.cxx b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_SecurityClassificationItem.cxx index 00624868f1..0cc121cf4c 100644 --- a/src/DataExchange/TKDESTEP/StepAP214/StepAP214_SecurityClassificationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepAP214/StepAP214_SecurityClassificationItem.cxx @@ -40,51 +40,97 @@ int StepAP214_SecurityClassificationItem::CaseNum(const occ::handleIsKind(STANDARD_TYPE(StepBasic_Action))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsage))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_AssemblyComponentUsageSubstitute))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationDesign))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ConfigurationEffectivity))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Document))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_DraughtingModel))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GeneralProperty))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MakeFromUsageOption))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MaterialDesignation))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductConcept))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 16; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 17; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 18; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionUsage))) + { return 19; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 20; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { return 21; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_VersionedActionRequest))) + { return 22; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP242/StepAP242_IdAttributeSelect.cxx b/src/DataExchange/TKDESTEP/StepAP242/StepAP242_IdAttributeSelect.cxx index 23bf436344..697200a598 100644 --- a/src/DataExchange/TKDESTEP/StepAP242/StepAP242_IdAttributeSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepAP242/StepAP242_IdAttributeSelect.cxx @@ -36,29 +36,53 @@ StepAP242_IdAttributeSelect::StepAP242_IdAttributeSelect() = default; int StepAP242_IdAttributeSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Action))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Address))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApplicationContext))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Group))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductCategory))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 12; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepAP242/StepAP242_ItemIdentifiedRepresentationUsageDefinition.cxx b/src/DataExchange/TKDESTEP/StepAP242/StepAP242_ItemIdentifiedRepresentationUsageDefinition.cxx index 4a0cc4a59e..fc782af982 100644 --- a/src/DataExchange/TKDESTEP/StepAP242/StepAP242_ItemIdentifiedRepresentationUsageDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepAP242/StepAP242_ItemIdentifiedRepresentationUsageDefinition.cxx @@ -44,41 +44,77 @@ int StepAP242_ItemIdentifiedRepresentationUsageDefinition::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedApprovalAssignment))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedDateAndTimeAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedDateAssignment))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedDocumentReference))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedExternalIdentificationAssignment))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedGroupAssignment))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedOrganizationAssignment))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedPersonAndOrganizationAssignment))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepAP214_AppliedSecurityClassificationAssignment))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GeneralProperty))) + { return 11; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return 12; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 13; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 14; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinitionRelationship))) + { return 15; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 16; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 17; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Action.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Action.cxx index 94e509a5cc..04bd7f81aa 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Action.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Action.cxx @@ -45,7 +45,9 @@ void StepBasic_Action::Init(const occ::handle& aName, theDescription = aDescription; } else + { theDescription.Nullify(); + } theChosenMethod = aChosenMethod; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ActionMethod.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ActionMethod.cxx index ccc3c29748..a9861a9799 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ActionMethod.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ActionMethod.cxx @@ -45,7 +45,9 @@ void StepBasic_ActionMethod::Init(const occ::handle& a theDescription = aDescription; } else + { theDescription.Nullify(); + } theConsequence = aConsequence; diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_CharacterizedObject.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_CharacterizedObject.cxx index 40dea36403..283bee8f9e 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_CharacterizedObject.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_CharacterizedObject.cxx @@ -41,7 +41,9 @@ void StepBasic_CharacterizedObject::Init(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Date))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_LocalTime))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DateAndTime))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Document.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Document.cxx index 88c85ee00a..cecc09f8fa 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Document.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Document.cxx @@ -47,7 +47,9 @@ void StepBasic_Document::Init(const occ::handle& aId, theDescription = aDescription; } else + { theDescription.Nullify(); + } theKind = aKind; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_DocumentProductAssociation.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_DocumentProductAssociation.cxx index 293ed19716..349e865409 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_DocumentProductAssociation.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_DocumentProductAssociation.cxx @@ -47,7 +47,9 @@ void StepBasic_DocumentProductAssociation::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theRelatingDocument = aRelatingDocument; diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralProperty.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralProperty.cxx index b6f811dbb4..a6edb17457 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralProperty.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralProperty.cxx @@ -45,7 +45,9 @@ void StepBasic_GeneralProperty::Init(const occ::handle theDescription = aDescription; } else + { theDescription.Nullify(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralPropertyRelationship.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralPropertyRelationship.cxx index 637e41ebd3..4d84077582 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralPropertyRelationship.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GeneralPropertyRelationship.cxx @@ -38,7 +38,9 @@ void StepBasic_GeneralPropertyRelationship::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theRelatingGeneralProperty = aRelatingGeneralProperty; diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Group.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Group.cxx index 28fc6ec6a0..7547b4dbdc 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Group.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Group.cxx @@ -42,7 +42,9 @@ void StepBasic_Group::Init(const occ::handle& aName, theDescription = aDescription; } else + { theDescription.Nullify(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GroupRelationship.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GroupRelationship.cxx index 856deddd36..b32c7fa377 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GroupRelationship.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_GroupRelationship.cxx @@ -45,7 +45,9 @@ void StepBasic_GroupRelationship::Init(const occ::handleSetReal(aValueComponent); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ObjectRole.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ObjectRole.cxx index bb2e4ddfe9..e27d57c884 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ObjectRole.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ObjectRole.cxx @@ -42,7 +42,9 @@ void StepBasic_ObjectRole::Init(const occ::handle& aNa theDescription = aDescription; } else + { theDescription.Nullify(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_OrganizationalAddress.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_OrganizationalAddress.cxx index 8ae70cd052..beba2fdb63 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_OrganizationalAddress.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_OrganizationalAddress.cxx @@ -97,7 +97,9 @@ occ::handle StepBasic_OrganizationalAddress::Organizatio int StepBasic_OrganizationalAddress::NbOrganizations() const { if (organizations.IsNull()) + { return 0; + } return organizations->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Person.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Person.cxx index 91e7fd9231..7fbdfb13cd 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Person.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Person.cxx @@ -131,7 +131,9 @@ occ::handle StepBasic_Person::MiddleNamesValue(const i int StepBasic_Person::NbMiddleNames() const { if (middleNames.IsNull()) + { return 0; + } return middleNames->Length(); } @@ -167,7 +169,9 @@ occ::handle StepBasic_Person::PrefixTitlesValue(const int StepBasic_Person::NbPrefixTitles() const { if (prefixTitles.IsNull()) + { return 0; + } return prefixTitles->Length(); } @@ -203,6 +207,8 @@ occ::handle StepBasic_Person::SuffixTitlesValue(const int StepBasic_Person::NbSuffixTitles() const { if (suffixTitles.IsNull()) + { return 0; + } return suffixTitles->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonOrganizationSelect.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonOrganizationSelect.cxx index bf4577b8c2..0aceead5f4 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonOrganizationSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonOrganizationSelect.cxx @@ -23,13 +23,21 @@ StepBasic_PersonOrganizationSelect::StepBasic_PersonOrganizationSelect() = defau int StepBasic_PersonOrganizationSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Person))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Organization))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_PersonAndOrganization))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonalAddress.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonalAddress.cxx index b218e9516e..8085bf8676 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonalAddress.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_PersonalAddress.cxx @@ -96,7 +96,9 @@ occ::handle StepBasic_PersonalAddress::PeopleValue(const int n int StepBasic_PersonalAddress::NbPeople() const { if (people.IsNull()) + { return 0; + } return people->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Product.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Product.cxx index b98704e6c6..1301b9fc74 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Product.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Product.cxx @@ -82,6 +82,8 @@ occ::handle StepBasic_Product::FrameOfReferenceValue(c int StepBasic_Product::NbFrameOfReference() const { if (frameOfReference.IsNull()) + { return 0; + } return frameOfReference->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductCategoryRelationship.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductCategoryRelationship.cxx index d58cb1d544..037640ab43 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductCategoryRelationship.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductCategoryRelationship.cxx @@ -47,7 +47,9 @@ void StepBasic_ProductCategoryRelationship::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theCategory = aCategory; diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionOrReference.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionOrReference.cxx index 1d2cb216d1..aab0927ab8 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionOrReference.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionOrReference.cxx @@ -29,13 +29,21 @@ int StepBasic_ProductDefinitionOrReference::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionReference))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionReferenceWithLocalRepresentation))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionRelationship.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionRelationship.cxx index 4e7e9641cc..9ef582104e 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionRelationship.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductDefinitionRelationship.cxx @@ -49,7 +49,9 @@ void StepBasic_ProductDefinitionRelationship::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theRelatingProductDefinition.SetValue(aRelatingProductDefinition); @@ -75,7 +77,9 @@ void StepBasic_ProductDefinitionRelationship::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theRelatingProductDefinition = aRelatingProductDefinition; theRelatedProductDefinition = aRelatedProductDefinition; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductOrFormationOrDefinition.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductOrFormationOrDefinition.cxx index 6f84d2c0be..9cf5b86af6 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductOrFormationOrDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductOrFormationOrDefinition.cxx @@ -31,13 +31,21 @@ int StepBasic_ProductOrFormationOrDefinition::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_Product))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductRelatedProductCategory.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductRelatedProductCategory.cxx index 0d36b15ac6..b0c712969f 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductRelatedProductCategory.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_ProductRelatedProductCategory.cxx @@ -51,6 +51,8 @@ occ::handle StepBasic_ProductRelatedProductCategory::Products int StepBasic_ProductRelatedProductCategory::NbProducts() const { if (products.IsNull()) + { return 0; + } return products->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_RoleSelect.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_RoleSelect.cxx index fb6b3218e7..9c16a90c35 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_RoleSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_RoleSelect.cxx @@ -38,29 +38,53 @@ StepBasic_RoleSelect::StepBasic_RoleSelect() = default; int StepBasic_RoleSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ActionAssignment))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ActionRequestAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalAssignment))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ApprovalDateTime))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_CertificationAssignment))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ContractAssignment))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentReference))) + { return 7; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_EffectivityAssignment))) + { return 8; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GroupAssignment))) + { return 9; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_NameAssignment))) + { return 10; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SecurityClassificationAssignment))) + { return 11; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SizeSelect.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SizeSelect.cxx index e88f348974..76ff8b5dba 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SizeSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SizeSelect.cxx @@ -25,9 +25,13 @@ StepBasic_SizeSelect::StepBasic_SizeSelect() = default; int StepBasic_SizeSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_SizeMember))) + { return 1; + } return 0; } @@ -43,12 +47,16 @@ occ::handle StepBasic_SizeSelect::NewMember() const int StepBasic_SizeSelect::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } // skl Interface_ParamType type = ent->ParamType(); // Void : on admet "non defini" (en principe, on ne devrait pas) // skl if (type != Interface_ParamVoid && type != Interface_ParamReal) return 0; if (ent->Matches("POSITIVE_LENGTH_MEASURE")) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SourceItem.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SourceItem.cxx index 0aa2e69c7f..906120dd84 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SourceItem.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_SourceItem.cxx @@ -29,9 +29,13 @@ StepBasic_SourceItem::StepBasic_SourceItem() = default; int StepBasic_SourceItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepData_SelectNamed))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Unit.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Unit.cxx index 06da7478a4..ddeef7e04c 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Unit.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_Unit.cxx @@ -29,11 +29,17 @@ StepBasic_Unit::StepBasic_Unit() = default; int StepBasic_Unit::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_NamedUnit))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DerivedUnit))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_VersionedActionRequest.cxx b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_VersionedActionRequest.cxx index 07f71898a0..1b59dd8fa6 100644 --- a/src/DataExchange/TKDESTEP/StepBasic/StepBasic_VersionedActionRequest.cxx +++ b/src/DataExchange/TKDESTEP/StepBasic/StepBasic_VersionedActionRequest.cxx @@ -50,7 +50,9 @@ void StepBasic_VersionedActionRequest::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepData/StepData.cxx b/src/DataExchange/TKDESTEP/StepData/StepData.cxx index 5c4095a944..b5dd001dec 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData.cxx @@ -37,7 +37,9 @@ void StepData::AddHeaderProtocol(const occ::handle& header) { InitHandle(StepData_Protocol, theheader); if (theheader.IsNull()) + { theheader = header; + } else { DeclareAndCast(StepData_FileProtocol, headmult, theheader); diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_DefaultGeneral.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_DefaultGeneral.cxx index 3b1559e63e..394447bf20 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_DefaultGeneral.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_DefaultGeneral.cxx @@ -40,7 +40,9 @@ void StepData_DefaultGeneral::FillSharedCase(const int { // Fill iterator with shared entities from UndefinedEntity parameters if (casenum != 1) + { return; // Only handles case 1 (UndefinedEntity) + } DeclareAndCast(StepData_UndefinedEntity, undf, ent); occ::handle cont = undf->UndefinedContent(); int nb = cont->NbParams(); @@ -73,7 +75,9 @@ bool StepData_DefaultGeneral::NewVoid(const int CN, occ::handleGetFromAnother(undfrom, TC); // We could optimize this operation diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_ECDescr.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_ECDescr.cxx index e33ccf1cde..991cbc4edd 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_ECDescr.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_ECDescr.cxx @@ -25,7 +25,9 @@ StepData_ECDescr::StepData_ECDescr() = default; void StepData_ECDescr::Add(const occ::handle& member) { if (member.IsNull()) + { return; + } const char* name = member->TypeName(); TCollection_AsciiString nam(name); for (int i = NbMembers(); i > 0; i--) @@ -70,7 +72,9 @@ bool StepData_ECDescr::Matches(const char* const name) const { occ::handle member = Member(i); if (member->Matches(name)) + { return true; + } } return false; } @@ -89,7 +93,9 @@ occ::handle StepData_ECDescr::NewEntity() const occ::handle member = Member(i); occ::handle mem = occ::down_cast(member->NewEntity()); if (!mem.IsNull()) + { ent->Add(mem); + } } return ent; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_ESDescr.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_ESDescr.cxx index 0bc071329d..4ae52b76f7 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_ESDescr.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_ESDescr.cxx @@ -49,7 +49,9 @@ void StepData_ESDescr::SetNbFields(const int nb) { DeclareAndCast(StepData_PDescr, pde, thedescr->Value(i)); if (!pde.IsNull()) + { thenames.Bind(pde->Name(), i); // Rebuild name-to-index mapping + } li->SetValue(i, pde); } thedescr = li; @@ -61,7 +63,9 @@ void StepData_ESDescr::SetField(const int num, { // Set field descriptor at specified position with given name and parameter descriptor if (num < 1 || num > NbFields()) + { return; + } occ::handle pde = new StepData_PDescr; pde->SetFrom(descr); // Copy descriptor properties pde->SetName(name); // Set field name @@ -80,11 +84,17 @@ void StepData_ESDescr::SetSuper(const occ::handle& super) // Set the superclass descriptor, handling inheritance hierarchy occ::handle sup = super->Base(); if (sup.IsNull()) + { sup = super; + } if (!thebase.IsNull()) + { thebase->SetSuper(sup); // Delegate to base if exists + } else + { thesuper = sup; // Otherwise set directly + } } const char* StepData_ESDescr::TypeName() const @@ -112,16 +122,26 @@ bool StepData_ESDescr::IsSub(const occ::handle& other) const // Check if this descriptor is a subclass of the given descriptor occ::handle oth = other->Base(); if (oth.IsNull()) + { oth = other; + } if (!thebase.IsNull()) + { return thebase->IsSub(oth); // Delegate to base if exists + } occ::handle t1 = this; if (oth == t1) + { return true; // Same descriptor + } if (oth == thesuper) + { return true; // Direct superclass + } else if (thesuper.IsNull()) - return false; // No superclass + { + return false; // No superclass + } return thesuper->IsSub(oth); // Check recursively up the hierarchy } @@ -134,16 +154,22 @@ int StepData_ESDescr::Rank(const char* const name) const { int rank; if (!thenames.Find(name, rank)) + { return 0; + } return rank; } const char* StepData_ESDescr::Name(const int num) const { if (num < 1) + { return ""; + } if (num > NbFields()) + { return ""; + } DeclareAndCast(StepData_PDescr, pde, thedescr->Value(num)); return pde->Name(); } @@ -158,7 +184,9 @@ occ::handle StepData_ESDescr::NamedField(const char* const name occ::handle pde; int rank = Rank(name); if (rank > 0) + { pde = GetCasted(StepData_PDescr, thedescr->Value(rank)); + } return pde; } @@ -166,9 +194,13 @@ bool StepData_ESDescr::Matches(const char* const name) const { // Check if this descriptor matches the given type name (including inheritance) if (thenom.IsEqual(name)) + { return true; // Direct match + } if (thesuper.IsNull()) - return false; // No superclass to check + { + return false; // No superclass to check + } return thesuper->Matches(name); // Check superclass hierarchy } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_EnumTool.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_EnumTool.cxx index a0a3a566f2..333492ba7d 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_EnumTool.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_EnumTool.cxx @@ -103,16 +103,22 @@ void StepData_EnumTool::AddDefinition(const char* const term) { char text[80] = {0}; if (!term) + { return; + } if (term[0] == '\0') + { return; + } int n0 = 0, n1 = 0; for (; term[n0] != '\0'; n0++) { if (term[n0] <= 32) { if (n1 == 0) + { continue; + } if (n1 > 1 || text[0] != '$') { if (text[n1 - 1] != '.') @@ -174,7 +180,9 @@ int StepData_EnumTool::NullValue() const const TCollection_AsciiString& StepData_EnumTool::Text(const int num) const { if (num < 0 || num >= thetexts.Length()) + { return TCollection_AsciiString::EmptyString(); + } return thetexts.Value(num + 1); } @@ -184,7 +192,9 @@ int StepData_EnumTool::Value(const char* const txt) const for (int i = 1; i <= nb; i++) { if (thetexts.Value(i).IsEqual(txt)) + { return i - 1; + } } return (-1); } @@ -195,7 +205,9 @@ int StepData_EnumTool::Value(const TCollection_AsciiString& txt) const for (int i = 1; i <= nb; i++) { if (thetexts.Value(i).IsEqual(txt)) + { return i - 1; + } } return (-1); } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_Field.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_Field.cxx index 807000ccf7..ba570cd782 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_Field.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_Field.cxx @@ -82,7 +82,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) { DeclareAndCast(TCollection_HAsciiString, str, theany); if (!str.IsNull()) + { theany = new TCollection_HAsciiString(str->ToCString()); + } return; } if (thekind == KindSelect) @@ -112,7 +114,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) { occ::handle sn2 = new StepData_SelectNamed; if (sn->HasName()) + { sn2->SetName(sn2->Name()); + } sn2->CField().CopyFrom(*this); theany = sn2; return; @@ -129,7 +133,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) up = hi->Upper(); occ::handle> hi2 = new NCollection_HArray1(low, up); for (i = low; i <= up; i++) + { hi2->SetValue(i, hi->Value(i)); + } return; } DeclareAndCast(NCollection_HArray1, hr, theany); @@ -139,7 +145,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) up = hr->Upper(); occ::handle> hr2 = new NCollection_HArray1(low, up); for (i = low; i <= up; i++) + { hr2->SetValue(i, hr->Value(i)); + } return; } DeclareAndCast(NCollection_HArray1>, hs, theany); @@ -150,7 +158,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) occ::handle>> hs2 = new NCollection_HArray1>(low, up); for (i = low; i <= up; i++) + { hs2->SetValue(i, new TCollection_HAsciiString(hs->Value(i))); + } return; } DeclareAndCast(NCollection_HArray1>, ht, theany); @@ -162,7 +172,9 @@ void StepData_Field::CopyFrom(const StepData_Field& other) new NCollection_HArray1>(low, up); // Should handle SelectMember cases... for (i = low; i <= up; i++) + { ht2->SetValue(i, ht->Value(i)); + } return; } } @@ -198,7 +210,9 @@ void StepData_Field::SetInt(const int val) } if (thekind == KindInteger || thekind == KindBoolean || thekind == KindLogical || thekind == KindEnum) + { theint = val; + } // else ? } @@ -245,11 +259,17 @@ void StepData_Field::SetLogical(const StepData_Logical val) } Clear(KindLogical); if (val == StepData_LFalse) + { theint = 0; + } if (val == StepData_LTrue) + { theint = 1; + } if (val == StepData_LUnknown) + { theint = 2; + } } void StepData_Field::SetReal(const double val) @@ -279,7 +299,9 @@ void StepData_Field::SetString(const char* const val) } } if (thekind != KindEnum) + { Clear(KindString); + } theany = new TCollection_HAsciiString(val); } @@ -288,13 +310,17 @@ void StepData_Field::SetEnum(const int val, const char* const text) Clear(KindEnum); SetInt(val); if (text && text[0] != '\0') + { SetString(text); + } } void StepData_Field::SetSelectMember(const occ::handle& val) { if (val.IsNull()) + { return; + } Clear(KindSelect); theany = val; } @@ -338,7 +364,9 @@ void StepData_Field::SetList(const int size, const int first) theany = new NCollection_HArray1>(first, first + size - 1); } if (thekind == 0) + { thekind = KindAny; + } thekind |= KindList; } @@ -354,7 +382,9 @@ void StepData_Field::SetList2(const int siz1, const int siz2, const int f1, cons { DeclareAndCast(StepData_SelectMember, sm, theany); if (!sm.IsNull()) + { kind = sm->Kind(); + } } switch (kind) { @@ -381,7 +411,9 @@ void StepData_Field::SetList2(const int siz1, const int siz2, const int f1, cons f2 + siz2 - 1); } if (thekind == 0) + { thekind = KindAny; + } thekind |= KindList2; } @@ -391,7 +423,9 @@ void StepData_Field::Set(const occ::handle& val) Clear(); theany = val; if (val.IsNull()) + { return; + } if (val->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) { thekind = KindString; @@ -407,7 +441,9 @@ void StepData_Field::Set(const occ::handle& val) if (!hi.IsNull()) { if (kind == 0) + { kind = KindInteger; + } thekind = kind | KindList; theint = hi->Length(); return; @@ -430,7 +466,9 @@ void StepData_Field::Set(const occ::handle& val) if (!ht.IsNull()) { if (kind == 0) + { kind = KindAny; + } thekind = kind | KindList; theint = ht->Length(); return; @@ -439,7 +477,9 @@ void StepData_Field::Set(const occ::handle& val) if (!hi2.IsNull()) { if (kind == 0) + { kind = KindInteger; + } thekind = kind | KindList2; theint = hi2->ColLength(); thereal = double(hi2->RowLength()); @@ -457,7 +497,9 @@ void StepData_Field::Set(const occ::handle& val) if (!ht2.IsNull()) { if (kind == 0) + { kind = KindAny; + } thekind = kind | KindList2; theint = ht2->ColLength(); thereal = double(hi2->RowLength()); @@ -469,10 +511,14 @@ void StepData_Field::ClearItem(const int num) { DeclareAndCast(NCollection_HArray1>, ht, theany); if (!ht.IsNull()) + { ht->ChangeValue(num).Nullify(); + } DeclareAndCast(NCollection_HArray1>, hs, theany); if (!hs.IsNull()) + { hs->ChangeValue(num).Nullify(); + } } void StepData_Field::SetInt(const int num, const int val, const int kind) @@ -486,7 +532,9 @@ void StepData_Field::SetInt(const int num, const int val, const int kind) // If already started with something else, change and put selects DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return; // yena erreur, ou alors OfReal + } thekind = KindAny | KindList; DeclareAndCast(StepData_SelectMember, sm, ht->Value(num)); if (sm.IsNull()) @@ -511,11 +559,17 @@ void StepData_Field::SetBoolean(const int num, const bool val) void StepData_Field::SetLogical(const int num, const StepData_Logical val) { if (val == StepData_LFalse) + { SetInt(num, 0, KindLogical); + } if (val == StepData_LTrue) + { SetInt(num, 1, KindLogical); + } if (val == StepData_LUnknown) + { SetInt(num, 2, KindLogical); + } } void StepData_Field::SetEnum(const int num, const int val, const char* const text) @@ -547,7 +601,9 @@ void StepData_Field::SetReal(const int num, const double val) // If already started with something else, change and put selects DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return; // yena erreur, ou alors OfInteger + } thekind = KindAny | KindList; DeclareAndCast(StepData_SelectMember, sm, ht->Value(num)); if (sm.IsNull()) @@ -569,7 +625,9 @@ void StepData_Field::SetString(const int num, const char* const val) // et si OfInteger ou OfReal ? DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return; + } thekind = KindAny | KindList; ht->SetValue(num, new TCollection_HAsciiString(val)); } @@ -593,7 +651,9 @@ void StepData_Field::SetEntity(const int num, const occ::handleSetValue(i, val); + } else { sm = new StepData_SelectInt; @@ -615,7 +675,9 @@ void StepData_Field::SetEntity(const int num, const occ::handleSetValue(i, val); + } else { sm = new StepData_SelectReal; @@ -635,9 +697,13 @@ void StepData_Field::SetEntity(const int num, const occ::handleSetValue(i, val); + } else + { ht->SetValue(i, hs->Value(i)); + } } thekind = KindAny | KindList; return; @@ -649,28 +715,38 @@ void StepData_Field::SetEntity(const int num, const occ::handleKind() != 0); } if ((thekind & KindArity) == KindList) { DeclareAndCast(NCollection_HArray1>, ht, theany); if (!ht.IsNull()) + { return (!ht->Value(n1).IsNull()); + } DeclareAndCast(NCollection_HArray1>, hs, theany); if (!hs.IsNull()) + { return (!hs->Value(n1).IsNull()); + } } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (!ht.IsNull()) + { return (!ht->Value(n1, n2).IsNull()); + } } return true; } @@ -678,45 +754,63 @@ bool StepData_Field::IsSet(const int n1, const int n2) const int StepData_Field::ItemKind(const int n1, const int n2) const { if ((thekind & KindArity) == 0) + { return Kind(true); + } int kind = TrueKind(thekind); // si Any, evaluer ... if (kind != KindAny) + { return kind; + } // Otherwise, look for a Transient occ::handle item; if ((thekind & KindArity) == KindList) { DeclareAndCast(NCollection_HArray1>, ht, theany); if (!ht.IsNull()) + { return kind; + } item = ht->Value(n1); } else if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (!ht.IsNull()) + { return kind; + } item = ht->Value(n1, n2); } if (item.IsNull()) + { return 0; + } if (item->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) + { return KindString; + } DeclareAndCast(StepData_SelectMember, sm, item); if (sm.IsNull()) + { return KindEntity; + } return sm->Kind(); } int StepData_Field::Kind(const bool type) const { if (!type) + { return thekind; + } if (thekind == KindSelect) { DeclareAndCast(StepData_SelectMember, sm, theany); if (!sm.IsNull()) + { return TrueKind(sm->Kind()); + } } return TrueKind(thekind); } @@ -729,13 +823,19 @@ int StepData_Field::Arity() const int StepData_Field::Length(const int index) const { if ((thekind & KindArity) == KindList) + { return theint; + } if ((thekind & KindArity) == KindList2) { if (index == 2) + { return int(thereal); + } else + { return theint; + } } return 0; } @@ -746,26 +846,40 @@ int StepData_Field::Lower(const int index) const { DeclareAndCast(NCollection_HArray1, hi, theany); if (!hi.IsNull()) + { return hi->Lower(); + } DeclareAndCast(NCollection_HArray1, hr, theany); if (!hr.IsNull()) + { return hr->Lower(); + } DeclareAndCast(NCollection_HArray1>, hs, theany); if (!hs.IsNull()) + { return hs->Lower(); + } DeclareAndCast(NCollection_HArray1>, ht, theany); if (!ht.IsNull()) + { return ht->Lower(); + } } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (ht.IsNull()) + { return 0; + } if (index == 1) + { return ht->LowerCol(); + } if (index == 2) + { return ht->LowerRow(); + } } return 0; } @@ -783,7 +897,9 @@ int StepData_Field::Integer(const int n1, const int n2) const { DeclareAndCast(StepData_SelectMember, sm, theany); if (!sm.IsNull()) + { return sm->Int(); + } } return theint; } @@ -791,22 +907,32 @@ int StepData_Field::Integer(const int n1, const int n2) const { DeclareAndCast(NCollection_HArray1, hi, theany); if (!hi.IsNull()) + { return hi->Value(n1); + } DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return 0; + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1)); if (!sm.IsNull()) + { return sm->Int(); + } } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (ht.IsNull()) + { return 0; + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1, n2)); if (!sm.IsNull()) + { return sm->Int(); + } } return 0; } @@ -820,9 +946,13 @@ StepData_Logical StepData_Field::Logical(const int n1, const int n2) const { int ival = Integer(n1, n2); if (ival == 0) + { return StepData_LFalse; + } if (ival == 1) + { return StepData_LTrue; + } return StepData_LUnknown; } @@ -834,7 +964,9 @@ double StepData_Field::Real(const int n1, const int n2) const { DeclareAndCast(StepData_SelectMember, sm, theany); if (!sm.IsNull()) + { return sm->Real(); + } } return thereal; } @@ -842,25 +974,37 @@ double StepData_Field::Real(const int n1, const int n2) const { DeclareAndCast(NCollection_HArray1, hr, theany); if (!hr.IsNull()) + { return hr->Value(n1); + } DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return 0; + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1)); if (!sm.IsNull()) + { return sm->Real(); + } } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2, hr, theany); if (!hr.IsNull()) + { return hr->Value(n1, n2); + } DeclareAndCast(NCollection_HArray2>, ht, theany); if (ht.IsNull()) + { return 0; + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1, n2)); if (!sm.IsNull()) + { return sm->Int(); + } } return 0.0; } @@ -871,15 +1015,21 @@ const char* StepData_Field::String(const int n1, const int n2) const { DeclareAndCast(TCollection_HAsciiString, str, theany); if (!str.IsNull()) + { return str->ToCString(); + } else + { return ""; + } } if (thekind == KindSelect) { DeclareAndCast(StepData_SelectMember, sm, theany); if (!sm.IsNull()) + { return sm->String(); + } } if ((thekind & KindArity) == KindList) { @@ -887,31 +1037,47 @@ const char* StepData_Field::String(const int n1, const int n2) const if (!hs.IsNull()) { if (hs->Value(n1).IsNull()) + { return ""; + } else + { return hs->Value(n1)->ToCString(); + } } DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return ""; + } DeclareAndCast(TCollection_HAsciiString, str, ht->Value(n1)); if (!str.IsNull()) + { return str->ToCString(); + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1)); if (!sm.IsNull()) + { return sm->String(); + } } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (ht.IsNull()) + { return ""; + } DeclareAndCast(TCollection_HAsciiString, str, ht->Value(n1, n2)); if (!str.IsNull()) + { return str->ToCString(); + } DeclareAndCast(StepData_SelectMember, sm, ht->Value(n1, n2)); if (!sm.IsNull()) + { return sm->String(); + } } return ""; } @@ -932,33 +1098,47 @@ occ::handle StepData_Field::Entity(const int n1, const int n if ((thekind & KindArity) == 0) { if (thekind == KindEntity) + { return theany; + } return nulval; } if ((thekind & KindArity) == KindList) { DeclareAndCast(NCollection_HArray1>, ht, theany); if (ht.IsNull()) + { return nulval; + } nulval = ht->Value(n1); if (nulval.IsNull()) + { return nulval; + } if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember)) || nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) + { nulval.Nullify(); + } return nulval; } if ((thekind & KindArity) == KindList2) { DeclareAndCast(NCollection_HArray2>, ht, theany); if (ht.IsNull()) + { return nulval; + } nulval = ht->Value(n1, n2); if (nulval.IsNull()) + { return nulval; + } if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember)) || nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) + { nulval.Nullify(); + } return nulval; } return nulval; diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_FieldList.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_FieldList.cxx index 5393b7c5ba..773eba0b8c 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_FieldList.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_FieldList.cxx @@ -44,17 +44,25 @@ void StepData_FieldList::FillShared(Interface_EntityIterator& iter) const { const StepData_Field& fi = Field(i); if (fi.Kind() != 7) + { continue; // KindEntity + } int i1, i2, nb1 = 1, nb2 = 1, ari = fi.Arity(); if (ari == 1) + { nb1 = fi.Length(); + } if (ari == 2) { nb1 = fi.Length(1); nb2 = fi.Length(2); } for (i1 = 1; i1 <= nb1; i1++) + { for (i2 = 1; i2 <= nb2; i2++) + { iter.AddItem(fi.Entity(i1, i2)); + } + } } } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_FieldList1.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_FieldList1.cxx index 9418428d50..a1bbb270b4 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_FieldList1.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_FieldList1.cxx @@ -24,13 +24,17 @@ int StepData_FieldList1::NbFields() const const StepData_Field& StepData_FieldList1::Field(const int num) const { if (num != 1) + { throw Standard_OutOfRange("StepData_FieldList1 : Field"); + } return thefield; } StepData_Field& StepData_FieldList1::CField(const int num) { if (num != 1) + { throw Standard_OutOfRange("StepData_FieldList1 : CField"); + } return thefield; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_FieldListD.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_FieldListD.cxx index 5926c8bb5b..678436664c 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_FieldListD.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_FieldListD.cxx @@ -17,14 +17,18 @@ StepData_FieldListD::StepData_FieldListD(const int nb) { if (nb > 0) + { thefields = new NCollection_HArray1(1, nb); + } } void StepData_FieldListD::SetNb(const int nb) { thefields.Nullify(); if (nb > 0) + { thefields = new NCollection_HArray1(1, nb); + } } int StepData_FieldListD::NbFields() const @@ -35,13 +39,17 @@ int StepData_FieldListD::NbFields() const const StepData_Field& StepData_FieldListD::Field(const int num) const { if (thefields.IsNull()) + { throw Standard_OutOfRange("StepData_FieldListD::Field"); + } return thefields->Value(num); } StepData_Field& StepData_FieldListD::CField(const int num) { if (thefields.IsNull()) + { throw Standard_OutOfRange("StepData_FieldListD::Field"); + } return thefields->ChangeValue(num); } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_FileProtocol.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_FileProtocol.cxx index ed911a3688..f891762fde 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_FileProtocol.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_FileProtocol.cxx @@ -30,14 +30,18 @@ void StepData_FileProtocol::Add(const occ::handle& protocol) { // Add a protocol to the collection, avoiding duplicates of the same type if (protocol.IsNull()) + { return; + } occ::handle ptype = protocol->DynamicType(); int nb = thecomps.Length(); // Check if a protocol of the same type is already present for (int i = 1; i <= nb; i++) { if (thecomps.Value(i)->IsInstance(ptype)) + { return; // Protocol of this type already exists + } } thecomps.Append(protocol); } @@ -66,7 +70,9 @@ bool StepData_FileProtocol::GlobalCheck(const Interface_Graph& G, bool res = false; int i, nb = NbResources(); for (i = 1; i <= nb; i++) + { res |= Resource(i)->GlobalCheck(G, ach); // Aggregate results from all protocols + } return res; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_FreeFormEntity.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_FreeFormEntity.cxx index 8b48393732..dc9823fa8a 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_FreeFormEntity.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_FreeFormEntity.cxx @@ -35,11 +35,17 @@ void StepData_FreeFormEntity::SetNext(const occ::handle const bool last) { if (next.IsNull()) + { thenext.Nullify(); + } else if (thenext.IsNull()) + { thenext = next; + } else if (last) + { thenext->SetNext(next); + } else { next->SetNext(thenext, last); @@ -62,9 +68,13 @@ occ::handle StepData_FreeFormEntity::Typed(const char* { occ::handle res; if (thetype.IsEqual(typenam)) + { return this; + } if (thenext.IsNull()) + { return res; + } return thenext->Typed(typenam); } @@ -87,9 +97,13 @@ bool StepData_FreeFormEntity::Reorder(occ::handle& ent) { // Reorder complex entities to ensure alphabetical sorting of entity types if (ent.IsNull()) + { return false; + } if (!ent->IsComplex()) + { return false; + } bool afr = false; // flag: any reordering needed occ::handle e1 = ent; occ::handle e2 = ent->Next(); @@ -105,7 +119,9 @@ bool StepData_FreeFormEntity::Reorder(occ::handle& ent) e2 = e1->Next(); } if (!afr) + { return afr; + } // Reordering using a dictionary (map) to sort entity types alphabetically e1 = ent; e2.Nullify(); @@ -123,7 +139,9 @@ bool StepData_FreeFormEntity::Reorder(occ::handle& ent) { e1 = GetCasted(StepData_FreeFormEntity, iter.Value()); if (!e1.IsNull()) + { e1->SetNext(e2); + } } // ... then rebuild the chain in alphabetical order e1.Nullify(); @@ -134,7 +152,9 @@ bool StepData_FreeFormEntity::Reorder(occ::handle& ent) { e2 = GetCasted(StepData_FreeFormEntity, iter.Value()); if (!e1.IsNull()) + { e1->SetNext(e2); + } e1 = e2; } @@ -146,9 +166,13 @@ void StepData_FreeFormEntity::SetNbFields(const int nb) { // Initialize the array of fields for this entity if (nb <= 0) + { thefields.Nullify(); + } else + { thefields = new NCollection_HArray1(1, nb); + } } int StepData_FreeFormEntity::NbFields() const diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_GlobalNodeOfWriterLib_0.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_GlobalNodeOfWriterLib_0.cxx index 78f83f200c..0ee1af0a8c 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_GlobalNodeOfWriterLib_0.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_GlobalNodeOfWriterLib_0.cxx @@ -30,9 +30,13 @@ void StepData_GlobalNodeOfWriterLib::Add(const occ::handle& aprotocol) { if (themod == amodule) + { return; + } if (theprot == aprotocol) + { themod = amodule; + } else if (thenext.IsNull()) { if (themod.IsNull()) @@ -47,7 +51,9 @@ void StepData_GlobalNodeOfWriterLib::Add(const occ::handleAdd(amodule, aprotocol); + } } const occ::handle& StepData_GlobalNodeOfWriterLib::Module() const diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_NodeOfWriterLib_0.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_NodeOfWriterLib_0.cxx index e6fc45b732..f99a986f39 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_NodeOfWriterLib_0.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_NodeOfWriterLib_0.cxx @@ -29,11 +29,15 @@ StepData_NodeOfWriterLib::StepData_NodeOfWriterLib() = default; void StepData_NodeOfWriterLib::AddNode(const occ::handle& anode) { if (thenode == anode) + { return; + } if (thenext.IsNull()) { if (thenode.IsNull()) + { thenode = anode; + } else { thenext = new StepData_NodeOfWriterLib; @@ -41,7 +45,9 @@ void StepData_NodeOfWriterLib::AddNode(const occ::handleAddNode(anode); + } } const occ::handle& StepData_NodeOfWriterLib::Module() const diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_PDescr.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_PDescr.cxx index 638181ec39..a10213a415 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_PDescr.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_PDescr.cxx @@ -61,19 +61,33 @@ void StepData_PDescr::SetSelect() void StepData_PDescr::AddMember(const occ::handle& member) { if (member.IsNull()) + { return; + } if (thenext.IsNull()) + { thenext = member; + } else + { thenext->AddMember(member); + } if (thesel == 3) + { return; + } if (thekind < KindEntity && thenext->Kind() >= KindEntity) + { thesel = 3; + } else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) + { thesel = 3; + } else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) + { thesel = 2; + } } void StepData_PDescr::SetMemberName(const char* const memname) @@ -145,11 +159,15 @@ void StepData_PDescr::SetArity(const int arity) void StepData_PDescr::SetFrom(const occ::handle& other) { if (other.IsNull()) + { return; + } thekind = other->Kind(); int i, maxenum = other->EnumMax(); for (i = 0; i <= maxenum; i++) + { AddEnumDef(other->EnumText(i)); + } // SELECT types are not copied thetype = other->Type(); thearit = other->Arity(); @@ -183,19 +201,27 @@ void StepData_PDescr::SetField(const char* const name, const int rank) bool StepData_PDescr::IsSelect() const { if (!thefrom.IsNull()) + { return thefrom->IsSelect(); + } return (thesel > 0); } occ::handle StepData_PDescr::Member(const char* const name) const { if (!thefrom.IsNull()) + { return thefrom->Member(name); + } occ::handle descr; if (thesnam.IsEqual(name)) + { return this; + } if (thenext.IsNull()) + { return descr; // null + } return thenext->Member(name); } @@ -252,16 +278,24 @@ bool StepData_PDescr::IsEntity() const bool StepData_PDescr::IsType(const occ::handle& atype) const { if (atype.IsNull()) + { return false; + } if (!thetype.IsNull()) { if (atype->SubType(thetype)) + { return true; + } } if (!thenext.IsNull()) + { return thenext->IsType(atype); + } if (!thefrom.IsNull()) + { return thefrom->IsType(atype); + } return false; } @@ -273,16 +307,24 @@ occ::handle StepData_PDescr::Type() const bool StepData_PDescr::IsDescr(const occ::handle& descr) const { if (descr.IsNull()) + { return false; + } if (thednam.Length() > 0) { if (descr->Matches(thednam.ToCString())) + { return true; + } } if (!thenext.IsNull()) + { return thenext->IsDescr(descr); + } if (!thefrom.IsNull()) + { return thefrom->IsDescr(descr); + } return false; } @@ -299,9 +341,13 @@ int StepData_PDescr::Arity() const occ::handle StepData_PDescr::Simple() const { if (thearit == 0) + { return this; + } if (thefrom.IsNull()) + { return this; + } return thefrom; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_Plex.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_Plex.cxx index dfacf2016f..f6def1a727 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_Plex.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_Plex.cxx @@ -50,7 +50,9 @@ bool StepData_Plex::Matches(const char* const steptype) const for (i = 1; i <= nb; i++) { if (Member(i)->Matches(steptype)) + { return true; + } } return false; } @@ -63,7 +65,9 @@ occ::handle StepData_Plex::As(const char* const steptype) const { ent = Member(i); if (ent->Matches(steptype)) + { return ent; + } } ent.Nullify(); return ent; @@ -75,7 +79,9 @@ bool StepData_Plex::HasField(const char* const name) const for (i = 1; i <= nb; i++) { if (Member(i)->HasField(name)) + { return true; + } } return false; } @@ -88,7 +94,9 @@ const StepData_Field& StepData_Plex::Field(const char* const name) const { ent = Member(i); if (ent->HasField(name)) + { return ent->Field(name); + } } throw Interface_InterfaceMismatch("StepData_Plex : Field"); } @@ -101,7 +109,9 @@ StepData_Field& StepData_Plex::CField(const char* const name) { ent = Member(i); if (ent->HasField(name)) + { return ent->CField(name); + } } throw Interface_InterfaceMismatch("StepData_Plex : Field"); } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_Protocol.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_Protocol.cxx index 5fe50891d8..83b83eddee 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_Protocol.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_Protocol.cxx @@ -47,20 +47,28 @@ occ::handle StepData_Protocol::Resource(const int /*num*/) c int StepData_Protocol::CaseNumber(const occ::handle& obj) const { if (obj.IsNull()) + { return 0; + } int num = TypeNumber(obj->DynamicType()); if (num > 0) + { return num; + } occ::handle dc = occ::down_cast(obj); if (dc.IsNull()) + { return 0; + } return DescrNumber(dc->Description()); } int StepData_Protocol::TypeNumber(const occ::handle& atype) const { if (atype == STANDARD_TYPE(StepData_UndefinedEntity)) + { return 1; + } return 0; } @@ -87,7 +95,9 @@ occ::handle StepData_Protocol::UnknownEntity() const bool StepData_Protocol::IsUnknownEntity(const occ::handle& ent) const { if (!ent.IsNull()) + { return ent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity)); + } return false; } @@ -96,7 +106,9 @@ bool StepData_Protocol::IsUnknownEntity(const occ::handle& e int StepData_Protocol::DescrNumber(const occ::handle& adescr) const { if (thedscnum.IsBound(adescr)) + { return thedscnum.Find(adescr); + } return 0; } @@ -109,7 +121,9 @@ void StepData_Protocol::AddDescr(const occ::handle& adescr, con // Otherwise what to do? Store according to the passed number in alpha-numeric form... // (temporary solution) if (!sd.IsNull()) + { thedscnam.Bind(sd->TypeName(), sd); + } char fonom[10]; Sprintf(fonom, "%d", CN); thedscnam.Bind(fonom, adescr); @@ -124,14 +138,20 @@ occ::handle StepData_Protocol::Descr(const int num) const { occ::handle dsc; if (thedscnam.IsEmpty()) + { return dsc; + } char fonom[10]; Sprintf(fonom, "%d", num); occ::handle aTDsc; if (thedscnam.Find(fonom, aTDsc)) + { dsc = occ::down_cast(aTDsc); + } else + { dsc.Nullify(); + } return dsc; } @@ -143,20 +163,28 @@ occ::handle StepData_Protocol::Descr(const char* const name, { occ::handle aTSd; if (thedscnam.Find(name, aTSd)) + { return occ::down_cast(aTSd); + } } if (!anylevel) + { return sd; + } int i, nb = NbResources(); for (i = 1; i <= nb; i++) { occ::handle sp = occ::down_cast(Resource(i)); if (sp.IsNull()) + { continue; + } sd = sp->Descr(name, anylevel); if (!sd.IsNull()) + { return sd; + } } return sd; } @@ -178,9 +206,13 @@ occ::handle StepData_Protocol::ECDescr( { cd = occ::down_cast(iter.Key()); if (cd.IsNull()) + { continue; + } if (cd->NbMembers() != nb) + { continue; + } bool ok = true; for (i = 1; i <= nb; i++) { @@ -191,21 +223,29 @@ occ::handle StepData_Protocol::ECDescr( } } if (ok) + { return cd; + } } cd.Nullify(); if (!anylevel) + { return cd; + } nb = NbResources(); for (i = 1; i <= nb; i++) { occ::handle sp = occ::down_cast(Resource(i)); if (sp.IsNull()) + { continue; + } cd = sp->ECDescr(names, anylevel); if (!cd.IsNull()) + { return cd; + } } return cd; } @@ -223,20 +263,28 @@ occ::handle StepData_Protocol::PDescr(const char* const name, { occ::handle aTSd; if (thepdescr.Find(name, aTSd)) + { return occ::down_cast(aTSd); + } } if (!anylevel) + { return sd; + } int i, nb = NbResources(); for (i = 1; i <= nb; i++) { occ::handle sp = occ::down_cast(Resource(i)); if (sp.IsNull()) + { continue; + } sd = sp->PDescr(name, anylevel); if (!sd.IsNull()) + { return sd; + } } return sd; } @@ -254,20 +302,28 @@ occ::handle StepData_Protocol::BasicDescr(const char* const nam { occ::handle aTSd; if (thedscbas.Find(name, aTSd)) + { return occ::down_cast(aTSd); + } } if (!anylevel) + { return sd; + } int i, nb = NbResources(); for (i = 1; i <= nb; i++) { occ::handle sp = occ::down_cast(Resource(i)); if (sp.IsNull()) + { continue; + } sd = sp->BasicDescr(name, anylevel); if (!sd.IsNull()) + { return sd; + } } return sd; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_ReadWriteModule.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_ReadWriteModule.cxx index f5bf211619..b32d437ac3 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_ReadWriteModule.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_ReadWriteModule.cxx @@ -25,17 +25,25 @@ int StepData_ReadWriteModule::CaseNum(const occ::handleIsComplex(num)) { NCollection_Sequence types; stepdat->ComplexType(num, types); if (types.IsEmpty()) + { return 0; + } if (types.Length() == 1) + { return CaseStep(types.Value(1)); + } else + { return CaseStep(types); + } } return CaseStep(stepdat->RecordType(num)); } @@ -71,6 +79,8 @@ void StepData_ReadWriteModule::Read(const int { DeclareAndCast(StepData_StepReaderData, stepdat, data); if (stepdat.IsNull()) + { return; + } ReadStep(CN, stepdat, num, ach, ent); } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_SelectMember.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_SelectMember.cxx index 1a63cfad73..8b97ca08b0 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_SelectMember.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_SelectMember.cxx @@ -57,17 +57,29 @@ Interface_ParamType StepData_SelectMember::ParamType() const { int kind = Kind(); if (kind == 0) + { return Interface_ParamVoid; + } if (kind == 1) + { return Interface_ParamInteger; + } if (kind == 2 || kind == 3) + { return Interface_ParamLogical; + } if (kind == 4) + { return Interface_ParamEnum; + } if (kind == 5) + { return Interface_ParamReal; + } if (kind == 6) + { return Interface_ParamText; + } return Interface_ParamMisc; } @@ -104,9 +116,13 @@ StepData_Logical StepData_SelectMember::Logical() const { int ival = Int(); if (ival == 0) + { return StepData_LFalse; + } if (ival == 1) + { return StepData_LTrue; + } return StepData_LUnknown; } @@ -114,11 +130,17 @@ void StepData_SelectMember::SetLogical(const StepData_Logical val) { SetKind(KindLogical); if (val == StepData_LFalse) + { SetInt(0); + } if (val == StepData_LTrue) + { SetInt(0); + } if (val == StepData_LUnknown) + { SetInt(0); + } } double StepData_SelectMember::Real() const @@ -150,7 +172,9 @@ void StepData_SelectMember::SetEnum(const int val, const char* const text) SetKind(KindEnum); SetInt(val); if (text && text[0] != '\0') + { SetEnumText(val, text); + } } void StepData_SelectMember::SetEnumText(const int /*val*/, const char* const text) diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_SelectType.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_SelectType.cxx index 0e39e5b9f3..01a6ce44b7 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_SelectType.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_SelectType.cxx @@ -25,25 +25,39 @@ bool StepData_SelectType::Matches(const occ::handle& ent) const { if (CaseNum(ent) > 0) + { return true; + } DeclareAndCast(StepData_SelectMember, sm, ent); if (sm.IsNull()) + { return false; + } if (CaseMem(sm) > 0) + { return true; + } return false; } void StepData_SelectType::SetValue(const occ::handle& ent) { if (ent.IsNull()) + { thevalue.Nullify(); + } else if (ent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity))) + { thevalue = ent; + } else if (!Matches(ent)) + { throw Standard_TypeMismatch("StepData : SelectType, SetValue"); + } else + { thevalue = ent; + } } void StepData_SelectType::Nullify() @@ -64,14 +78,18 @@ bool StepData_SelectType::IsNull() const occ::handle StepData_SelectType::Type() const { if (thevalue.IsNull()) + { return STANDARD_TYPE(Standard_Transient); + } return thevalue->DynamicType(); } int StepData_SelectType::CaseNumber() const { if (thevalue.IsNull()) + { return 0; + } return CaseNum(thevalue); } @@ -98,7 +116,9 @@ int StepData_SelectType::CaseMember() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return 0; + } return CaseMem(sm); } @@ -111,7 +131,9 @@ const char* StepData_SelectType::SelectName() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return ""; + } return sm->Name(); } @@ -119,7 +141,9 @@ int StepData_SelectType::Int() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return 0; + } return sm->Int(); } @@ -127,7 +151,9 @@ void StepData_SelectType::SetInt(const int val) { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { throw Standard_TypeMismatch("StepData : SelectType, SetInt"); + } sm->SetInt(val); } @@ -141,8 +167,12 @@ static occ::handle SelectVal(const occ::handleSetName(name)) + { throw Standard_TypeMismatch("StepData : SelectType, SetInteger"); + } + } } else if (name && name[0] != '\0') { @@ -153,9 +183,13 @@ static occ::handle SelectVal(const occ::handleInteger(); } @@ -173,7 +209,9 @@ void StepData_SelectType::SetInteger(const int val, const char* const name) occ::handle sm = SelectVal(thevalue, name, 0); sm->SetInteger(val); if (CaseMem(sm) == 0) + { throw Standard_TypeMismatch("StepData : SelectType, SetInteger"); + } thevalue = sm; } @@ -181,7 +219,9 @@ bool StepData_SelectType::Boolean() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return false; + } return sm->Boolean(); } @@ -190,7 +230,9 @@ void StepData_SelectType::SetBoolean(const bool val, const char* const name) occ::handle sm = SelectVal(thevalue, name, 0); sm->SetBoolean(val); if (CaseMem(sm) == 0) + { throw Standard_TypeMismatch("StepData : SelectType, SetBoolean"); + } thevalue = sm; } @@ -198,7 +240,9 @@ StepData_Logical StepData_SelectType::Logical() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return StepData_LUnknown; + } return sm->Logical(); } @@ -207,7 +251,9 @@ void StepData_SelectType::SetLogical(const StepData_Logical val, const char* con occ::handle sm = SelectVal(thevalue, name, 0); sm->SetLogical(val); if (CaseMem(sm) == 0) + { throw Standard_TypeMismatch("StepData : SelectType, SetLogical"); + } thevalue = sm; } @@ -215,7 +261,9 @@ double StepData_SelectType::Real() const { DeclareAndCast(StepData_SelectMember, sm, thevalue); if (sm.IsNull()) + { return 0.0; + } return sm->Real(); } @@ -224,7 +272,9 @@ void StepData_SelectType::SetReal(const double val, const char* const name) occ::handle sm = SelectVal(thevalue, name, 1); sm->SetReal(val); if (CaseMem(sm) == 0) + { throw Standard_TypeMismatch("StepData : SelectType, SetReal"); + } thevalue = sm; } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_Simple.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_Simple.cxx index 6c0380bbdf..880ab6d00c 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_Simple.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_Simple.cxx @@ -50,7 +50,9 @@ occ::handle StepData_Simple::As(const char* const steptype) con { occ::handle nulent; if (Matches(steptype)) + { return this; + } return nulent; } @@ -64,7 +66,9 @@ const StepData_Field& StepData_Simple::Field(const char* const name) const { int num = ESDescr()->Rank(name); if (num == 0) + { throw Interface_InterfaceMismatch("StepData_Simple : Field"); + } return FieldNum(num); } @@ -72,7 +76,9 @@ StepData_Field& StepData_Simple::CField(const char* const name) { int num = ESDescr()->Rank(name); if (num == 0) + { throw Interface_InterfaceMismatch("StepData_Simple : Field"); + } return CFieldNum(num); } @@ -113,16 +119,22 @@ void StepData_Simple::Shared(Interface_EntityIterator& list) const int j1, j2, l1, l2; l1 = l2 = 1; if (fi.Arity() >= 1) + { l1 = fi.Length(1); + } if (fi.Arity() > 1) + { l2 = fi.Length(2); + } for (j1 = 1; j1 <= l1; j1++) { for (j2 = 1; j2 <= l2; j2++) { occ::handle ent = fi.Entity(j1, j2); if (!ent.IsNull()) + { list.AddItem(ent); + } } } } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_StepDumper.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_StepDumper.cxx index c3ab1141ee..349825ca23 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_StepDumper.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_StepDumper.cxx @@ -38,7 +38,9 @@ StepData_StepDumper::StepData_StepDumper(const occ::handle& { themodel = amodel; if (mode > 0) + { thewriter.LabelMode() = 2; + } } StepData_StepWriter& StepData_StepDumper::StepWriter() @@ -67,33 +69,47 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, occ::handle module; int CN; if (num > 0) + { S << "#" << num << " = "; + } else + { S << "#??? = "; // Unknown entity number + } if (thewlib.Select(ent, module, CN)) { if (module->IsComplex(CN)) { NCollection_Sequence listypes; if (!module->ComplexType(CN, listypes)) + { S << "(Complex Type : ask level > 0) cdl = " << ent->DynamicType()->Name() << " (...);" - << std::endl; + << '\n'; + } else { int n = listypes.Length(); for (i = 1; i <= n; i++) + { S << listypes.Value(i) << " (...)"; - S << std::endl; + } + S << '\n'; } } else - S << module->StepType(CN) << " (...);" << std::endl; + { + S << module->StepType(CN) << " (...);" << '\n'; + } } else + { S << "(Unrecognized Type for protocol) cdl = " << ent->DynamicType()->Name() << " (...);" - << std::endl; + << '\n'; + } if (nlab > 0) - S << "/* Ident in file for " << num << " : #" << nlab << " */" << std::endl; + { + S << "/* Ident in file for " << num << " : #" << nlab << " */" << '\n'; + } } else if (level == 1) @@ -142,7 +158,9 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, { // Process entity identifiers list if (tab.Value(i) == 0) + { continue; + } anent = themodel->Value(i); thewriter.SendEntity(i, thewlib); if (theslib.Select(anent, module, CN)) @@ -169,14 +187,22 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, { nlab = ids.Value(i); if (nlab == 0) + { continue; // Skip entities without identifiers - nbe++; // Count entities with identifiers + } + nbe++; // Count entities with identifiers if (nlab < 0) + { nbu = 0; // Entities without proper identifier + } else if (nlab == i) + { nbq = 0; // Entities where identifier matches entity number + } else if (nlab > 0) + { nbi++; // Entities with distinct proper identifiers + } } if (nbe > 0) { @@ -187,10 +213,12 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, for (i = 1; i <= nb; i++) { if (ids.Value(i) >= 0) + { continue; + } S << " #" << i; } - S << std::endl; + S << '\n'; } if (nbq > 0) { @@ -198,20 +226,24 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, for (i = 1; i <= nb; i++) { if (ids.Value(i) == i) + { S << " #" << i; + } } - S << std::endl; + S << '\n'; } if (nbi < 0) { // Display help format instead of individual num:#id entries int nbl = 0, nbr = 0, nbr0 = 0, nbc = 0; char unid[30]; // Alternative format: "#num #ident" - S << " (proper ident): num:#ident num:#ident ..." << std::endl; + S << " (proper ident): num:#ident num:#ident ..." << '\n'; for (i = 1; i <= nb; i++) { if (ids.Value(i) <= 0 || ids.Value(i) == i) + { continue; + } Sprintf(unid, "%d:#%d", i, ids.Value(i)); nbc = (int)strlen(unid); nbr = ((80 - nbc) % 4) + 2; @@ -219,13 +251,15 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, if (nbl + nbr0 > 79) { nbl = nbc; - S << std::endl; + S << '\n'; } else { nbl += nbr0; for (; nbr0 > 0; nbr0--) + { S << " "; + } } S << unid; nbr0 = nbr; @@ -236,10 +270,14 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, // - Tabular format with entity ranks and STEP identifiers } if (nbl > 0) - S << std::endl; + { + S << '\n'; + } } if (nbi > 0) - S << "In dump, iii:#jjj means : entity rank iii has step ident #jjj" << std::endl; + { + S << "In dump, iii:#jjj means : entity rank iii has step ident #jjj" << '\n'; + } // Debug output: entity dumping information with level details } if (level > 0) @@ -252,7 +290,9 @@ bool StepData_StepDumper::Dump(Standard_OStream& S, bool StepData_StepDumper::Dump(Standard_OStream& S, const int num, const int level) { if (num <= 0 || num > themodel->NbEntities()) + { return false; + } occ::handle ent = themodel->Value(num); return Dump(S, ent, level); } diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_StepModel.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_StepModel.cxx index 6a51ecca2d..1c9029d5c6 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_StepModel.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_StepModel.cxx @@ -45,7 +45,9 @@ void StepData_StepModel::GetFromAnother(const occ::handleHeader(); // Copy the header. Important: header is distinct from content... Interface_CopyTool TC(this, StepData::HeaderProtocol()); @@ -53,9 +55,13 @@ void StepData_StepModel::GetFromAnother(const occ::handle newhead; if (!TC.Copy(iter.Value(), newhead, false, false)) + { continue; + } if (!newhead.IsNull()) + { theheader.Append(newhead); + } } } @@ -108,7 +114,9 @@ void StepData_StepModel::VerifyCheck(occ::handle& ach) const { const occ::handle& head = iter.Value(); if (!lib.Select(head, module, CN)) + { continue; + } module->CheckCase(CN, head, sh, ach); } } @@ -120,7 +128,9 @@ void StepData_StepModel::DumpHeader(Standard_OStream& S, const int /*level*/) co occ::handle stepro = StepData::HeaderProtocol(); bool iapro = !stepro.IsNull(); if (!iapro) + { S << " -- WARNING : StepModel DumpHeader, Protocol not defined\n"; + } Interface_EntityIterator iter = Header(); int nb = iter.NbEntities(); @@ -130,7 +140,9 @@ void StepData_StepModel::DumpHeader(Standard_OStream& S, const int /*level*/) co S << " " << iter.Value()->DynamicType()->Name() << "\n"; } if (!iapro || nb == 0) + { return; + } S << " -- -- STEP MODEL HEADER CONTENT -- --" << "\n"; S << " -- Dumped with Protocol : " << stepro->DynamicType()->Name() << " --\n"; @@ -151,7 +163,9 @@ void StepData_StepModel::SetIdentLabel(const occ::handle& en { int num = Number(ent); if (!num) + { return; // Entity not found in model + } int nbEnt = NbEntities(); // Initialize identifier array if not yet created @@ -169,7 +183,9 @@ void StepData_StepModel::SetIdentLabel(const occ::handle& en // Copy existing identifier mappings int k = 1; for (; k <= prevLength; k++) + { idnums1->SetValue(k, theidnums->Value(k)); + } theidnums = idnums1; } theidnums->SetValue(num, ident); @@ -178,7 +194,9 @@ void StepData_StepModel::SetIdentLabel(const occ::handle& en int StepData_StepModel::IdentLabel(const occ::handle& ent) const { if (theidnums.IsNull()) + { return 0; + } int num = Number(ent); return (!num ? 0 : theidnums->Value(num)); } @@ -189,11 +207,17 @@ void StepData_StepModel::PrintLabel(const occ::handle& ent, int num = (theidnums.IsNull() ? 0 : Number(ent)); int nid = (!num ? 0 : theidnums->Value(num)); if (nid > 0) + { S << "#" << nid; + } else if (num > 0) + { S << "(#" << num << ")"; + } else + { S << "(#0..)"; + } } occ::handle StepData_StepModel::StringLabel( @@ -205,11 +229,17 @@ occ::handle StepData_StepModel::StringLabel( int nid = (!num ? 0 : theidnums->Value(num)); if (nid > 0) + { Sprintf(text, "#%d", nid); + } else if (num > 0) + { Sprintf(text, "(#%d)", num); + } else + { Sprintf(text, "(#0..)"); + } label = new TCollection_HAsciiString(text); return label; diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderData.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderData.cxx index 84255ee87f..33acf850e1 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderData.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderData.cxx @@ -374,18 +374,26 @@ void StepData_StepReaderData::SetRecord(const int num, int numlst; if (type[0] != '(') + { thenbents++; // total number of proper file terms + } thetypes.ChangeValue(num) = thenametypes.Add(TCollection_AsciiString(type)); if (ident[0] == '$') { if (strlen(ident) > 2) + { numlst = atoi(&ident[1]); + } else + { numlst = ident[1] - 48; + } if (thelastn < numlst) + { thelastn = numlst; // highest sub-list number + } theidents.SetValue(num, -2 - numlst); } else if (ident[0] == '#') @@ -418,15 +426,19 @@ void StepData_StepReaderData::SetRecord(const int num, { prev--; if (prev <= 0) + { break; + } } Message_Messenger::StreamBuffer sout = Message::SendTrace(); sout << " *** Incorrect record " << num << " (on " << NbRecords() << " -> " << num * 100 / NbRecords() << " % in File) ***"; if (prev > 0) + { sout << " Ident #" << theidents(prev); - sout << "\n" << errm << std::endl; + } + sout << "\n" << errm << '\n'; thecheck->AddWarning(errm.ToCString(), "Complex Type incorrect : "); } break; @@ -440,7 +452,9 @@ void StepData_StepReaderData::SetRecord(const int num, thenbscop++; } else if (!strcmp(ident, "ENDSCOPE")) + { theidents.SetValue(num, -2); // ENDSCOPE + } // Reste 0 // InitParams(num); @@ -513,14 +527,20 @@ int StepData_StepReaderData::RecordIdent(const int num) const int StepData_StepReaderData::SubListNumber(const int num, const int nump, const bool aslast) const { if (nump == 0 || nump > NbParams(num)) + { return 0; + } const Interface_FileParameter& FP = Param(num, nump); if (FP.ParamType() != Interface_ParamSub) + { return 0; + } if (aslast) { if (nump != NbParams(num)) + { return 0; + } } return FP.EntityNumber(); } @@ -540,7 +560,9 @@ void StepData_StepReaderData::ComplexType( NCollection_Sequence& types) const { if (theidents(num) < 0) + { return; + } for (int i = num; i > 0; i = NextForComplex(i)) { types.Append(RecordType(i)); @@ -553,7 +575,9 @@ int StepData_StepReaderData::NextForComplex(const int num) const { int next = 0; if (themults.IsBound(num)) + { next = themults.Find(num); + } return next; } @@ -573,9 +597,11 @@ bool StepData_StepReaderData::NamedForComplex(const char* const name return true; } - if (n == 0) /*stat =*/ + if (n == 0) + { /*stat =*/ NamedForComplex(name, num0, n, ach); // on a rembobine - // Not in alphabetical order: loop + } + // Not in alphabetical order: loop char txtmes[200]; const char* errmess = "Parameter n0.%d (%s) not a LIST"; Sprintf(txtmes, errmess, num0, name); @@ -648,13 +674,19 @@ bool StepData_StepReaderData::CheckNbParams(const int num, const char* const mess) const { if (NbParams(num) == nbreq) + { return true; + } char txtmes[200]; const char* errmess; if (mess[0] == '\0') + { errmess = "Count of Parameters is not %d"; + } else + { errmess = "Count of Parameters is not %d for %s"; + } Sprintf(txtmes, errmess, nbreq, mess); ach->AddFail(txtmes, errmess); return false; @@ -688,7 +720,9 @@ bool StepData_StepReaderData::ReadSubList(const int num, numsub = 0; bool isvoid = (Param(num, nump).ParamType() == Interface_ParamVoid); if (isvoid && optional) + { return false; + } const char* errmess = "Parameter n0.%d (%s) not a LIST"; Sprintf(txtmes, errmess, nump, mess); @@ -708,7 +742,9 @@ int StepData_StepReaderData::ReadSub(const int numsub, { int nbp = NbParams(numsub); if (nbp == 0) + { return 0; // empty list = Handle Null + } const TCollection_AsciiString& rectyp = RecordType(numsub); if (nbp == 1 && rectyp.ToCString()[0] != '(') { @@ -719,9 +755,13 @@ int StepData_StepReaderData::ReadSub(const int numsub, sn->SetName(rectyp.ToCString()); occ::handle aSN = sn; if (ReadAny(numsub, 1, mess, ach, descr, aSN)) + { return sn->Kind(); + } else + { return 0; + } } // common case: make an HArray1 of ... of ... of what exactly @@ -817,13 +857,21 @@ int StepData_StepReaderData::ReadSub(const int numsub, break; } if (!strcmp(str, ".F.")) + { hin->SetValue(ip, 0); + } else if (!strcmp(str, ".T.")) + { hin->SetValue(ip, 1); + } else if (!strcmp(str, ".U.")) + { hin->SetValue(ip, 2); + } else + { kod = 0; + } break; } case 4: { @@ -867,7 +915,9 @@ int StepData_StepReaderData::ReadSub(const int numsub, } // Remaining other cases ... everything is possible. cf the Param type if (kod > 0) + { continue; + } // Need to pass to transient ... if (htr.IsNull()) { @@ -976,7 +1026,9 @@ int StepData_StepReaderData::ReadSub(const int numsub, int nent = FP.EntityNumber(); int kind = ReadSub(nent, mess, ach, descr, sub); if (kind < 0) + { break; + } htr->SetValue(ip, sub); break; } @@ -1009,7 +1061,9 @@ bool StepData_StepReaderData::ReadMember(const int num } bool res = ReadAny(num, nump, mess, ach, nuldescr, v); if (v == val) + { return res; + } // changement -> refus char txtmes[200]; const char* errmess = "Parameter n0.%d (%s) : does not match SELECT clause"; @@ -1047,7 +1101,9 @@ bool StepData_StepReaderData::ReadField(const int num, case Interface_ParamIdent: nent = FP.EntityNumber(); if (nent > 0) + { fild.SetEntity(BoundEntity(nent)); + } break; case Interface_ParamVoid: break; @@ -1059,13 +1115,21 @@ bool StepData_StepReaderData::ReadField(const int num, } case Interface_ParamEnum: if (!strcmp(str, ".T.")) + { fild.SetLogical(StepData_LTrue); + } else if (!strcmp(str, ".F.")) + { fild.SetLogical(StepData_LFalse); + } else if (!strcmp(str, ".U.")) + { fild.SetLogical(StepData_LUnknown); + } else + { fild.SetEnum(-1, str); + } break; case Interface_ParamLogical: OK = false; @@ -1074,7 +1138,9 @@ bool StepData_StepReaderData::ReadField(const int num, nent = FP.EntityNumber(); kind = ReadSub(nent, mess, ach, descr, sub); if (kind < 0) + { break; + } fild.Clear(kind); fild.Set(sub); break; @@ -1092,7 +1158,9 @@ bool StepData_StepReaderData::ReadField(const int num, if (!OK) { if (!strcmp(str, "*")) + { fild.SetDerived(); + } } return true; } @@ -1107,7 +1175,9 @@ bool StepData_StepReaderData::ReadList(const int num, // controler nbs egaux int i, nb = list.NbFields(); if (!CheckNbParams(num, nb, ach, descr->TypeName())) + { return false; + } for (i = 1; i <= nb; i++) { occ::handle pde = descr->Field(i); @@ -1162,7 +1232,9 @@ bool StepData_StepReaderData::ReadAny(const int num, case Interface_ParamIdent: { int nent = FP.EntityNumber(); if (nent > 0) + { val = BoundEntity(nent); + } return (!val.IsNull()); } case Interface_ParamVoid: @@ -1170,7 +1242,9 @@ bool StepData_StepReaderData::ReadAny(const int num, case Interface_ParamEnum: { occ::handle sm; if (!val.IsNull()) + { sm = GetCasted(StepData_SelectMember, val); + } occ::handle sin; occ::handle sna; int logic = -1; @@ -1199,7 +1273,9 @@ bool StepData_StepReaderData::ReadAny(const int num, if (logic >= 0) { if (!sm.IsNull()) + { sm->SetLogical(slog); + } else { sin = new StepData_SelectInt; @@ -1210,7 +1286,9 @@ bool StepData_StepReaderData::ReadAny(const int num, else { if (!sm.IsNull()) + { sm->SetEnum(logic, str); + } else { sna = new StepData_SelectNamed; @@ -1241,7 +1319,9 @@ bool StepData_StepReaderData::ReadAny(const int num, int numsub = SubListNumber(num, nump, false); int nbp = NbParams(numsub); if (nbp == 0) + { return false; // empty list = Handle Null + } const TCollection_AsciiString& rectyp = RecordType(numsub); if (nbp == 1 && rectyp.ToCString()[0] != '(') { @@ -1257,18 +1337,26 @@ bool StepData_StepReaderData::ReadAny(const int num, if (Param(numsub2, 1).ParamType() == Interface_ParamReal) { if (!sma->SetName(rectyp.ToCString())) + { return false; + } occ::handle> aSeq = new NCollection_HSequence; for (int i = 1; i <= nbp2; i++) { if (Param(numsub2, i).ParamType() != Interface_ParamReal) + { continue; + } occ::handle asr = new StepData_SelectReal; if (!ReadAny(numsub2, i, mess, ach, descr, asr)) + { continue; + } occ::handle sm1 = occ::down_cast(asr); if (!sm1.IsNull()) + { aSeq->Append(sm1->Real()); + } } occ::handle> anArr = new NCollection_HArray1(1, aSeq->Length()); @@ -1288,7 +1376,9 @@ bool StepData_StepReaderData::ReadAny(const int num, val = sm; } if (!sm->SetName(rectyp.ToCString())) + { return false; // loupe + } return ReadAny(numsub, 1, mess, ach, descr, val); } } @@ -1318,24 +1408,38 @@ bool StepData_StepReaderData::ReadXY(const int num, { const Interface_FileParameter& FPX = Param(numsub, 1); if (FPX.ParamType() == Interface_ParamReal) + { X = Interface_FileReaderData::Fastof(FPX.CValue()); + } else + { errmess = "Parameter n0.%d (%s) : (X,Y) X not a Real"; + } const Interface_FileParameter& FPY = Param(numsub, 2); if (FPY.ParamType() == Interface_ParamReal) + { Y = Interface_FileReaderData::Fastof(FPY.CValue()); + } else + { errmess = "Parameter n0.%d (%s) : (X,Y) Y not a Real"; + } } else + { errmess = "Parameter n0.%d (%s) : (X,Y) has not 2 params"; + } } else + { errmess = "Parameter n0.%d (%s) : (X,Y) not a SubList"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1361,30 +1465,48 @@ bool StepData_StepReaderData::ReadXYZ(const int num, { const Interface_FileParameter& FPX = Param(numsub, 1); if (FPX.ParamType() == Interface_ParamReal) + { X = Interface_FileReaderData::Fastof(FPX.CValue()); + } else + { errmess = "Parameter n0.%d (%s) : (X,Y,Z) X not a Real"; + } const Interface_FileParameter& FPY = Param(numsub, 2); if (FPY.ParamType() == Interface_ParamReal) + { Y = Interface_FileReaderData::Fastof(FPY.CValue()); + } else + { errmess = "Parameter n0.%d (%s) : (X,Y,Z) Y not a Real"; + } const Interface_FileParameter& FPZ = Param(numsub, 3); if (FPZ.ParamType() == Interface_ParamReal) + { Z = Interface_FileReaderData::Fastof(FPZ.CValue()); + } else + { errmess = "Parameter n0.%d (%s) : (X,Y,Z) Z not a Real"; + } } else + { errmess = "Parameter n0.%d (%s) : (X,Y,Z) has not 3 params"; + } } else + { errmess = "Parameter n0.%d (%s) : (X,Y,Z) not a SubList"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1405,15 +1527,23 @@ bool StepData_StepReaderData::ReadReal(const int num, { const Interface_FileParameter& FP = Param(num, nump); if (FP.ParamType() == Interface_ParamReal || FP.ParamType() == Interface_ParamInteger) + { val = Interface_FileReaderData::Fastof(FP.CValue()); + } else + { errmess = "Parameter n0.%d (%s) not a Real"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1446,13 +1576,19 @@ bool StepData_StepReaderData::ReadEntity(const int num, { errmess = "Parameter n0.%d (%s) : Entity has illegal type"; if (!entent.IsNull() && entent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity))) + { ent = entent; + } } else + { ent = entent; + } } else + { errmess = "Parameter n0.%d (%s) : Unresolved reference"; + } } else { @@ -1465,7 +1601,9 @@ bool StepData_StepReaderData::ReadEntity(const int num, } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1496,13 +1634,19 @@ bool StepData_StepReaderData::ReadEntity(const int num, errmess = "Parameter n0.%d (%s) : Entity has illegal type"; // fot not supported STEP entity if (!entent.IsNull() && entent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity))) + { sel.SetValue(entent); + } } else + { sel.SetValue(entent); + } } else + { errmess = "Parameter n0.%d (%s) : Unresolved reference"; + } } else if (FP.ParamType() == Interface_ParamVoid) { @@ -1514,11 +1658,17 @@ bool StepData_StepReaderData::ReadEntity(const int num, occ::handle sm = sel.NewMember(); // SelectMember which performs this role. Can be specialized if (!ReadAny(num, nump, mess, ach, sel.Description(), sm)) + { errmess = "Parameter n0.%d (%s) : could not be read"; + } if (!sel.Matches(sm)) + { errmess = "Parameter n0.%d (%s) : illegal parameter type"; + } else + { sel.SetValue(sm); + } } } else @@ -1527,7 +1677,9 @@ bool StepData_StepReaderData::ReadEntity(const int num, } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1550,20 +1702,28 @@ bool StepData_StepReaderData::ReadInteger(const int num, { const Interface_FileParameter& FP = Param(num, nump); if (FP.ParamType() == Interface_ParamInteger) + { val = atoi(FP.CValue()); + } else if (FP.ParamType() == Interface_ParamReal) { val = static_cast(std::round(Interface_FileReaderData::Fastof(FP.CValue()))); errmess = "Parameter n0.%d (%s) was rounded"; } if (FP.ParamType() != Interface_ParamInteger && FP.ParamType() != Interface_ParamReal) + { errmess = "Parameter n0.%d (%s) not an Integer"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1588,20 +1748,32 @@ bool StepData_StepReaderData::ReadBoolean(const int num, { const char* txt = FP.CValue(); if (!strcmp(txt, ".T.")) + { flag = true; + } else if (!strcmp(txt, ".F.")) + { flag = false; + } else + { errmess = "Parameter n0.%d (%s) : Incorrect Boolean Value. It was set to true"; + } } else + { errmess = "Parameter n0.%d (%s) not a Boolean. It was set to true"; + } } else + { errmess = "Parameter n0.%d (%s) absent.It was set to true"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1625,22 +1797,36 @@ bool StepData_StepReaderData::ReadLogical(const int num, { const char* txt = FP.CValue(); if (!strcmp(txt, ".T.")) + { flag = StepData_LTrue; + } else if (!strcmp(txt, ".F.")) + { flag = StepData_LFalse; + } else if (!strcmp(txt, ".U.")) + { flag = StepData_LUnknown; + } else + { errmess = "Parameter n0.%d (%s) : Incorrect Logical Value"; + } } else + { errmess = "Parameter n0.%d (%s) not a Logical"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1678,10 +1864,14 @@ bool StepData_StepReaderData::ReadString(const int } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1710,13 +1900,19 @@ bool StepData_StepReaderData::ReadEnumParam(const int num, errmess = "Parameter n0.%d (%s) : Undefined Enumeration not allowed"; } else + { errmess = "Parameter n0.%d (%s) not an Enumeration"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1755,24 +1951,36 @@ bool StepData_StepReaderData::ReadEnum(const int num, { val = enumtool.Value(FP.CValue()); if (val >= 0) + { return true; + } else + { errmess = "Parameter n0.%d (%s) : Incorrect Enumeration Value"; + } } else if (FP.ParamType() == Interface_ParamVoid) { val = enumtool.NullValue(); if (val < 0) + { errmess = "Parameter n0.%d (%s) : Undefined Enumeration not allowed"; + } } else + { errmess = "Parameter n0.%d (%s) not an Enumeration"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); @@ -1813,14 +2021,20 @@ bool StepData_StepReaderData::ReadTypedParam(const int num, numr = FP.EntityNumber(); numrp = 1; if (NbParams(numr) != 1) + { errmess = "Parameter n0.%d (%s) : SubList, not typed"; + } typ = RecordType(numr); } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); ach->AddFail(txtmes, errmess); return false; @@ -1840,21 +2054,33 @@ bool StepData_StepReaderData::CheckDerived(const int num, if (nump > 0 && nump <= NbParams(num)) { if (!strcmp(Param(num, nump).CValue(), "*")) + { return true; + } else + { errmess = "Parameter n0.%d (%s) not Derived"; + } } else + { errmess = "Parameter n0.%d (%s) absent"; + } if (errmess == nullptr) + { return true; + } Sprintf(txtmes, errmess, nump, mess); if (warn) + { ach->AddWarning(txtmes, errmess); + } else + { ach->AddFail(txtmes, errmess); + } return false; } @@ -1878,16 +2104,22 @@ int StepData_StepReaderData::FindNextRecord(const int num) const // skips SCOPE and ENDSCOPE records and SUB-LISTS if (num < 0) + { return 0; + } int num1 = num + 1; if (num == 0) + { num1 = thenbhead + 1; + } int max = NbRecords(); while (num1 <= max) { if (theidents(num1) > 0) + { return num1; + } // SCOPE,ENDSCOPE and Sub-List have a fictitious identifier: -1,-2 respectively // and SUBLIST have a negative one. Only a real entity has a positive Ident @@ -1903,16 +2135,22 @@ int StepData_StepReaderData::FindEntityNumber(const int num, const int id) const // Given an "Id": search in the Ident type Parameters of , // if one of them designates #Id precisely. If yes, return its EntityNumber if (num == 0) + { return 0; + } int nb = NbParams(num); for (int i = 1; i <= nb; i++) { const Interface_FileParameter& FP = Param(num, i); if (FP.ParamType() != Interface_ParamIdent) + { continue; + } int ixp = atoi(&FP.CValue()[1]); if (ixp == id) + { return FP.EntityNumber(); + } } return 0; // ici, pas trouve } @@ -1996,7 +2234,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { int ident = theidents(num); if (ident < -2) + { subn(-(ident + 2)) = num; // toujours a jour ... + } int nba = NbParams(num); int nda = (num == 1 ? 0 : ParamFirstRank(num - 1)); @@ -2013,7 +2253,7 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) if (numsub > thelastn) { Message::SendInfo() << "Bad Sub.N0, Record " << num << " Param " << na << ":$" << numsub - << std::endl; + << '\n'; continue; } FP.SetEntityNumber(subn(numsub)); @@ -2026,9 +2266,13 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { // the map found it int num0 = indm(indmap); if (num0 > 0) + { FP.SetEntityNumber(num0); // AND THERE, we have resolved + } else + { FP.SetEntityNumber(-id); // CONFLICT -> will need to resolve ... + } } else { // NOT RESOLVED, if no pbmap, say it @@ -2043,7 +2287,7 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) thecheck->AddFail(failmess, "Unresolved Reference"); // ... And output a more complete message sout << "*** ERR StepReaderData *** Entite #" << ident << "\n Type:" << RecordType(num) - << " Param.n0 " << na << ": #" << id << " Not found" << std::endl; + << " Param.n0 " << na << ": #" << id << " Not found" << '\n'; } // END Mapping } // END Reference Processing } // END Parameters Loop @@ -2091,9 +2335,11 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) indmap = imap.FindIndex(ident); // plus sur pbmap = true; if (thenbscop == 0) + { errorscope = true; - // Identical numbers when there is no SCOPE? ERROR! - // (Of course, if there are SCOPES, we pass through, but still...) + // Identical numbers when there is no SCOPE? ERROR! + // (Of course, if there are SCOPES, we pass through, but still...) + } else { // If there are SCOPES, let's look more closely to report a problem @@ -2103,7 +2349,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) int fromscope = nr; int toscope = indm(indmap); if (toscope < 0) + { toscope = -toscope; + } for (;;) { fromscope--; // basic iteration @@ -2114,14 +2362,20 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) } int idtest = indi(fromscope); if (idtest >= 0) + { continue; // the next one (well, the previous one) + } if (idtest == -1) + { break; // not same level, so it's OK + } if (idtest == -3) { fromscope = inds(fromscope); if (fromscope < toscope) + { break; // we exit, not on same level + } } } } @@ -2131,11 +2385,13 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) char ligne[80]; Sprintf(ligne, "Ident defined SEVERAL TIMES : #%d", ident); thecheck->AddFail(ligne, "Ident defined SEVERAL TIMES : #%d"); - sout << "StepReaderData : SetEntityNumbers, " << ligne << std::endl; + sout << "StepReaderData : SetEntityNumbers, " << ligne << '\n'; } if (indm(indmap) > 0) + { indm(indmap) = -indm(indmap); // Not for Map - // Normal case for the Map + } + // Normal case for the Map } else { @@ -2168,7 +2424,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { indx = new NCollection_HArray1(0, nbseq); for (int ixp = 0; ixp <= nbseq; ixp++) + { indx->ChangeValue(ixp) = 0; + } } indx->ChangeValue(nr) = num; indx->ChangeValue(nscop) = num; @@ -2188,28 +2446,36 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) for (nr = 0; nr <= nbseq; nr++) { if (indx->Value(nr) == 0 && indi(nr) != -3) + { continue; // ENDSCOPE + EXPORT + } num = indx->Value(nr); int nba = NbParams(num); for (int na = 1; na <= nba; na++) { Interface_FileParameter& FP = ChangeParam(num, na); if (FP.ParamType() != Interface_ParamIdent) + { continue; + } int id = -FP.EntityNumber(); if (id < 0) + { continue; // already resolved at head - /* if (imap.Contains(id)) { et voila - FP.SetEntityNumber(indm(imap.FindIndex(id))); - continue; - } */ + } + /* if (imap.Contains(id)) { et voila + FP.SetEntityNumber(indm(imap.FindIndex(id))); + continue; + } */ // Search for the requested Id: if nested EXPORT, already resolved but we must // look! (useless however to go see: it's already done, because // a nested EXPORT has been processed BEFORE the one that nests) int n0 = nr - 1; if (indi(n0) == -3) + { n0--; // if we just follow an ENDSCOPE + } while (n0 > 0) { int irec = indi(n0); @@ -2219,7 +2485,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) break; } if (irec == -1) + { break; // SCOPE: end of this SCOPE/ENDSCOPE + } if (irec == -3) { // beware of EXPORT: if an EXPORT holds Id, note its already calculated Number @@ -2251,7 +2519,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { nr = indr(num); if (nr == 0) + { continue; // not an object or a sub-list + } int nba = NbParams(num); for (int na = nba; na > 0; na--) { @@ -2273,7 +2543,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) // ident type parameter (references an entity): search for requested ident int id = -FP.EntityNumber(); if (id < 0) + { continue; // already resolved at head + } // Here we go: we will search for id in ndi; scanning algorithm // This implements a bidirectional search strategy: first backward from current position @@ -2281,7 +2553,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) int pass, sens, nok, n0, irec; pass = sens = nok = 0; if (!iamap) + { pass = 1; // if map not available + } while (pass < 3) { pass++; @@ -2293,18 +2567,24 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { // the map found it nok = indm(indmap); if (nok < 0) + { continue; // CONFLICT -> need to resolve ... + } break; } else + { continue; + } } // 1st Pass: BACKWARD -> File beginning if (sens == 0 && nr > 1) { n0 = nr - 1; if (indi(n0) == -3) + { n0--; // if we just follow an ENDSCOPE + } while (n0 > 0) { irec = indi(n0); @@ -2317,13 +2597,17 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) if (irec == -3) { if (indx.IsNull()) + { n0 = inds(n0); + } else { // EXPORT, we must look nok = FindEntityNumber(indx->Value(n0), id); if (nok > 0) + { break; + } n0 = inds(n0); // ENDSCOPE: skip it } } @@ -2346,13 +2630,17 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) if (irec == -1) { if (indx.IsNull()) + { n0 = inds(n0); + } else { // EXPORT, we must look nok = FindEntityNumber(indx->Value(n0), id); if (nok > 0) + { break; + } n0 = inds(n0); // SCOPE: skip it } } @@ -2360,7 +2648,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) } } if (nok > 0) + { break; + } sens = 1 - sens; // next pass } // here we have nok, number found @@ -2380,7 +2670,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) for (n0ent = 1; n0ent <= nr; n0ent++) { if (indi(n0ent) > 0) + { nument++; + } } int ident = RecordIdent(num); if (ident < 0) @@ -2389,7 +2681,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) { ident = RecordIdent(n0ent); if (ident > 0) + { break; + } } } // ... Build the Check ... @@ -2404,7 +2698,7 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) // ... And output a more complete message sout << "*** ERR StepReaderData *** Entite " << nument << ", a " << (nr * 100) / nbseq << "% de DATA : #" << ident << "\n Type:" << RecordType(num) << " Param.n0 " - << na << ": #" << id << " Not found" << std::endl; + << na << ": #" << id << " Not found" << '\n'; FP.SetEntityNumber(0); // -> Unresolved reference } @@ -2419,7 +2713,9 @@ void StepData_StepReaderData::SetEntityNumbers(const bool withmap) occ::handle> newsubpil = new NCollection_HArray1(1, maxsubpil); for (int bidpil = 1; bidpil <= maxsubpil - 30; bidpil++) + { newsubpil->SetValue(bidpil, subpile->Value(bidpil)); + } subpile = newsubpil; } nbsubpil++; @@ -2440,7 +2736,9 @@ int StepData_StepReaderData::FindNextHeaderRecord(const int num) const // Operates like FindNextRecord but only scans the Header if (num < 0) + { return 0; + } int num1 = num + 1; int max = thenbhead; @@ -2449,7 +2747,9 @@ int StepData_StepReaderData::FindNextHeaderRecord(const int num) const // SCOPE,ENDSCOPE and Sub-List have a negative identifier // Only retain positive or null Idents (null: no Ident in Header) if (RecordIdent(num1) >= 0) + { return num1; + } num1++; } return 0; diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderTool.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderTool.cxx index 6ae92a23bb..8e475a0fba 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderTool.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_StepReaderTool.cxx @@ -136,7 +136,9 @@ void StepData_StepReaderTool::PrepareHeader(const occ::handleUnknownEntity(); + } stepdat->BindEntity(i, ent); } @@ -183,7 +185,9 @@ void StepData_StepReaderTool::BeginRead(const occ::handleNbWarnings(); sout << nbmess << " Warnings on Reading Header Entity N0." << i << ":"; if (!ent.IsNull()) - sout << ent->DynamicType()->Name() << std::endl; + { + sout << ent->DynamicType()->Name() << '\n'; + } for (int nf = 1; nf <= nbmess; nf++) { sout << ach->CWarning(nf) << "\n"; @@ -195,7 +199,9 @@ void StepData_StepReaderTool::BeginRead(const occ::handleNbFails(); sout << " Fails on Reading Header Entity N0." << i << ":"; if (!ent.IsNull()) - sout << ent->DynamicType()->Name() << std::endl; + { + sout << ent->DynamicType()->Name() << '\n'; + } for (int nf = 1; nf <= nbmess; nf++) { sout << ach->CFail(nf) << "\n"; @@ -228,9 +234,13 @@ bool StepData_StepReaderTool::AnalyseRecord(const int // Not found: try UndefinedEntity from StepData DeclareAndCast(StepData_UndefinedEntity, und, anent); if (und.IsNull()) + { acheck->AddFail("# Entity neither Recognized nor set as UndefinedEntity from StepData #"); + } else + { und->ReadRecord(stepdat, num, acheck); + } } return (!acheck->HasFailed()); } @@ -243,7 +253,9 @@ void StepData_StepReaderTool::EndRead(const occ::handleFindNextRecord(i)) != 0) { diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx index e93e9848f5..cb8fb7fb51 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx @@ -104,7 +104,9 @@ void StepData_StepWriter::SetScope(const int numscope, const int numin) { int nb = themodel->NbEntities(); if (numscope <= 0 || numscope > nb || numin <= 0 || numin > nb) + { throw Interface_InterfaceMismatch("StepWriter : SetScope, out of range"); + } if (thescopenext.IsNull()) { thescopebeg = new NCollection_HArray1(1, nb); @@ -124,10 +126,14 @@ void StepData_StepWriter::SetScope(const int numscope, const int numin) } thescopenext->SetValue(numin, -1); // new end of scope if (thescopebeg->Value(numscope) == 0) + { thescopebeg->SetValue(numscope, numin); + } int lastin = thescopeend->Value(numscope); if (lastin > 0) + { thescopenext->SetValue(lastin, numin); + } thescopeend->SetValue(numscope, numin); } @@ -136,7 +142,9 @@ void StepData_StepWriter::SetScope(const int numscope, const int numin) bool StepData_StepWriter::IsInScope(const int num) const { if (thescopenext.IsNull()) + { return false; + } return (thescopenext->Value(num) != 0); } @@ -153,7 +161,9 @@ void StepData_StepWriter::SendModel(const occ::handle& protoc StepData_WriterLib lib(protocol); if (!headeronly) + { thefile->Append(new TCollection_HAsciiString("ISO-10303-21;")); + } SendHeader(); // .... Header: sequence of entities without Ident .... @@ -170,37 +180,53 @@ void StepData_StepWriter::SendModel(const occ::handle& protoc if (lib.Select(anent, module, CN)) { if (module->IsComplex(CN)) + { StartComplex(); + } else { TCollection_AsciiString styp; if (thetypmode > 0) + { styp = module->ShortType(CN); + } if (styp.Length() == 0) + { styp = module->StepType(CN); + } StartEntity(styp); } module->WriteStep(CN, *this, anent); if (module->IsComplex(CN)) + { EndComplex(); + } } else { // Not found above ... try UndefinedEntity DeclareAndCast(StepData_UndefinedEntity, und, anent); if (und.IsNull()) + { continue; + } if (und->IsComplex()) + { StartComplex(); + } und->WriteParams(*this); if (und->IsComplex()) + { EndComplex(); + } } EndEntity(); } EndSec(); if (headeronly) + { return; + } // Data: Like Header but with Idents ... otherwise the code is the same SendData(); @@ -231,7 +257,9 @@ void StepData_StepWriter::SendModel(const occ::handle& protoc if (!thescopebeg.IsNull()) { if (thescopenext->Value(i) != 0) + { continue; + } } SendEntity(i, lib); } @@ -256,7 +284,9 @@ void StepData_StepWriter::SendHeader() void StepData_StepWriter::SendData() { if (thesect) + { throw Interface_InterfaceMismatch("StepWriter : Data section"); + } NewLine(false); thefile->Append(new TCollection_HAsciiString("DATA;")); thesect = true; @@ -275,7 +305,9 @@ void StepData_StepWriter::EndSec() void StepData_StepWriter::EndFile() { if (thesect) + { throw Interface_InterfaceMismatch("StepWriter : EndFile"); + } NewLine(false); thefile->Append(new TCollection_HAsciiString("END-ISO-10303-21;")); thesect = false; @@ -293,15 +325,25 @@ void StepData_StepWriter::SendEntity(const int num, const StepData_WriterLib& li // themodel->Number(anent) and/or IdentLabel(anent) if (thelabmode > 0) + { idtrue = themodel->IdentLabel(anent); + } if (thelabmode == 1) + { idnum = idtrue; + } if (idnum == 0) + { idnum = num; + } if (thelabmode < 2 || idnum == idtrue) + { Sprintf(lident, "#%d = ", idnum); // skl 29.01.2003 + } else + { Sprintf(lident, "%d:#%d = ", idnum, idtrue); // skl 29.01.2003 + } // SendIdent reused, lident has just been calculated thecurr.Clear(); @@ -344,7 +386,9 @@ void StepData_StepWriter::SendEntity(const int num, const StepData_WriterLib& li { thechecks.CCheck(num)->AddWarning("Erroneous Entity, equivalent content"); if (und->IsComplex()) + { AddString(" (", 2); + } und->WriteParams(*this); if (und->IsComplex()) { @@ -355,7 +399,9 @@ void StepData_StepWriter::SendEntity(const int num, const StepData_WriterLib& li NewLine(false); Comment(true); if (und.IsNull()) + { SendComment(" ERRONEOUS ENTITY, DATA LOST"); + } SendComment("On Entity above, Fail Messages recorded at Read time :"); occ::handle ach = rep->Check(); int nbfails = ach->NbFails(); @@ -371,19 +417,27 @@ void StepData_StepWriter::SendEntity(const int num, const StepData_WriterLib& li else if (lib.Select(anent, module, CN)) { if (module->IsComplex(CN)) + { StartComplex(); + } else { TCollection_AsciiString styp; if (thetypmode > 0) + { styp = module->ShortType(CN); + } if (styp.Length() == 0) + { styp = module->StepType(CN); + } StartEntity(styp); } module->WriteStep(CN, *this, anent); if (module->IsComplex(CN)) + { EndComplex(); + } EndEntity(); } else @@ -391,12 +445,18 @@ void StepData_StepWriter::SendEntity(const int num, const StepData_WriterLib& li // Not found above ... try UndefinedEntity DeclareAndCast(StepData_UndefinedEntity, und, anent); if (und.IsNull()) + { return; + } if (und->IsComplex()) + { StartComplex(); + } und->WriteParams(*this); if (und->IsComplex()) + { EndComplex(); + } EndEntity(); } } @@ -416,7 +476,9 @@ void StepData_StepWriter::NewLine(const bool evenempty) } int indst = thelevel * 2; if (theindent) + { indst += theindval; + } thecurr.SetInitial(indst); thecurr.Clear(); } @@ -470,9 +532,13 @@ void StepData_StepWriter::SendEndscope() void StepData_StepWriter::Comment(const bool mode) { if (mode && !thecomm) + { AddString(textcomm, 20); + } if (!mode && thecomm) + { AddString(textendcomm); + } thecomm = mode; } @@ -481,7 +547,9 @@ void StepData_StepWriter::Comment(const bool mode) void StepData_StepWriter::SendComment(const occ::handle& text) { if (!thecomm) + { throw Interface_InterfaceMismatch("StepWriter : Comment"); + } AddString(text->ToCString(), text->Length()); } @@ -490,7 +558,9 @@ void StepData_StepWriter::SendComment(const occ::handle& s // NB: current processing non-recursive (no SELNAME(SELNAME(..)) ) bool selname = false; if (sm.IsNull()) + { return; // ?? + } if (sm->HasName()) { selname = true; @@ -737,7 +814,9 @@ void StepData_StepWriter::SendSelect(const occ::handle& s break; // ?? } if (selname) + { CloseSub(); + } } //================================================================================================= @@ -751,7 +830,9 @@ void StepData_StepWriter::SendList(const StepData_FieldList& list, { occ::handle pde; if (!descr.IsNull()) + { pde = descr->Field(i); + } const StepData_Field& fild = list.Field(i); SendField(fild, pde); } @@ -776,7 +857,9 @@ void StepData_StepWriter::OpenTypedSub(const char* const subtype) { AddParam(); if (subtype[0] != '\0') + { AddString(subtype, (int)strlen(subtype)); + } AddString(textlist); thefirst = true; thelevel++; @@ -796,7 +879,9 @@ void StepData_StepWriter::CloseSub() void StepData_StepWriter::AddParam() { if (!thefirst) + { AddString(textparam); + } thefirst = false; } @@ -841,20 +926,30 @@ void StepData_StepWriter::Send(const TCollection_AsciiString& val) // Watch out for exceeding 72 characters if (thecurr.CanGet(aNn)) + { AddString(aVal, 0); - //: i2 + //: i2 + } else { thefile->Append(thecurr.Moved()); int anIndst = thelevel * 2; if (theindent) + { anIndst += theindval; + } if (anIndst + aNn <= StepLong) + { thecurr.SetInitial(anIndst); + } else + { thecurr.SetInitial(0); + } if (thecurr.CanGet(aNn)) + { AddString(aVal, 0); + } else { while (aNn > 0) @@ -867,19 +962,27 @@ void StepData_StepWriter::Send(const TCollection_AsciiString& val) } int aStop = StepLong; // position of last separator for (; aStop > 0 && aVal.Value(aStop) != ' '; aStop--) + { ; + } if (!aStop) { aStop = StepLong; for (; aStop > 0 && aVal.Value(aStop) != '\\'; aStop--) + { ; + } if (!aStop) { aStop = StepLong; for (; aStop > 0 && aVal.Value(aStop) != '_'; aStop--) + { ; + } if (!aStop) + { aStop = StepLong; + } } } TCollection_AsciiString aBval = aVal.Split(aStop); @@ -941,15 +1044,25 @@ void StepData_StepWriter::Send(const occ::handle& val) { int idnum = num, idtrue = 0; if (thelabmode > 0) + { idtrue = themodel->IdentLabel(val); + } if (thelabmode == 1) + { idnum = idtrue; + } if (idnum == 0) + { idnum = num; + } if (thelabmode < 2 || idnum == idtrue) + { Sprintf(lident, "#%d", idnum); + } else + { Sprintf(lident, "%d:#%d", idnum, idtrue); + } AddParam(); AddString(lident, (int)strlen(lident)); } @@ -960,9 +1073,13 @@ void StepData_StepWriter::Send(const occ::handle& val) void StepData_StepWriter::SendBoolean(const bool val) { if (val) + { SendString(texttrue); + } else + { SendString(textfalse); + } } //================================================================================================= @@ -970,11 +1087,17 @@ void StepData_StepWriter::SendBoolean(const bool val) void StepData_StepWriter::SendLogical(const StepData_Logical val) { if (val == StepData_LTrue) + { SendString(texttrue); + } else if (val == StepData_LFalse) + { SendString(textfalse); + } else + { SendString(textunknown); + } } // SendString: note, we give the exact label @@ -1011,9 +1134,13 @@ void StepData_StepWriter::SendEnum(const TCollection_AsciiString& val) AddParam(); TCollection_AsciiString aValue = val; if (aValue.Value(1) != '.') + { aValue.Prepend('.'); + } if (aValue.Value(aValue.Length()) != '.') + { aValue += '.'; + } AddString(aValue, 2); } @@ -1075,7 +1202,8 @@ void StepData_StepWriter::SendDerived() void StepData_StepWriter::EndEntity() { // clang-format off - if (thelevel != 1) throw Interface_InterfaceMismatch("StepWriter : EndEntity"); // parentheses count is wrong ... + if (thelevel != 1) { throw Interface_InterfaceMismatch("StepWriter : EndEntity"); // parentheses count is wrong ... +} // clang-format on AddString(textendent); thelevel = 0; // on garde theindval : sera traite au prochain NewLine @@ -1098,7 +1226,9 @@ void StepData_StepWriter::AddString(const TCollection_AsciiString& astr, const i thefile->Append(thecurr.Moved()); int indst = thelevel * 2; if (theindent) + { indst += theindval; + } thecurr.SetInitial(indst); } thecurr.Add(astr); @@ -1113,7 +1243,9 @@ void StepData_StepWriter::AddString(const char* const astr, const int lnstr, con thefile->Append(thecurr.Moved()); int indst = thelevel * 2; if (theindent) + { indst += theindval; + } thecurr.SetInitial(indst); } thecurr.Add(astr, lnstr); @@ -1149,7 +1281,9 @@ bool StepData_StepWriter::Print(Standard_OStream& S) bool isGood = (S.good()); int nb = thefile->Length(); for (int i = 1; i <= nb && isGood; i++) + { S << thefile->Value(i)->ToCString() << "\n"; + } S << std::flush; isGood = (S && S.good()); diff --git a/src/DataExchange/TKDESTEP/StepData/StepData_UndefinedEntity.cxx b/src/DataExchange/TKDESTEP/StepData/StepData_UndefinedEntity.cxx index 473c141d4a..200f354ce1 100644 --- a/src/DataExchange/TKDESTEP/StepData/StepData_UndefinedEntity.cxx +++ b/src/DataExchange/TKDESTEP/StepData/StepData_UndefinedEntity.cxx @@ -60,7 +60,9 @@ occ::handle StepData_UndefinedEntity::Next() const const char* StepData_UndefinedEntity::StepType() const { if (thetype.IsNull()) + { return ""; + } return thetype->ToCString(); } @@ -124,15 +126,23 @@ void StepData_UndefinedEntity::ReadRecord(const occ::handle 0) + { thecont->AddEntity(partyp, anent); + } else + { thecont->AddLiteral(partyp, hval); + } } int nextyp = SR->NextForComplex(num); if (nextyp == 0) + { return; + } thenext = new StepData_UndefinedEntity; thenext->ReadRecord(SR, nextyp, ach); } @@ -140,7 +150,9 @@ void StepData_UndefinedEntity::ReadRecord(const occ::handleNbParams(); occ::handle anent; for (int i = 1; i <= nb; i++) @@ -151,10 +163,14 @@ void StepData_UndefinedEntity::WriteParams(StepData_StepWriter& SW) const DeclareAndCast(StepData_UndefinedEntity, und, thecont->ParamEntity(i)); und->StepType(); // svv #2 if (und->IsSub()) + { SW.OpenTypedSub(und->StepType()); + } und->WriteParams(SW); if (und->IsSub()) + { SW.CloseSub(); + } } else if (partyp == Interface_ParamIdent) { @@ -162,12 +178,16 @@ void StepData_UndefinedEntity::WriteParams(StepData_StepWriter& SW) const SW.Send(anent); } else + { SW.SendString(thecont->ParamValue(i)->ToCString()); + } } // if (IsSub()) return; // SW.NewLine(true); if (thenext.IsNull()) + { return; + } thenext->WriteParams(SW); } @@ -181,9 +201,13 @@ void StepData_UndefinedEntity::GetFromAnother(const occ::handleIsSub(); if (another->IsComplex()) + { thenext = GetCasted(StepData_UndefinedEntity, TC.Transferred(another->Next())); + } else + { thenext.Nullify(); + } } void StepData_UndefinedEntity::FillShared(Interface_EntityIterator& list) const @@ -203,5 +227,7 @@ void StepData_UndefinedEntity::FillShared(Interface_EntityIterator& list) const } } if (!thenext.IsNull()) + { thenext->FillShared(list); + } } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumOrCommonDatum.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumOrCommonDatum.cxx index 661b5e8294..9a40dbd195 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumOrCommonDatum.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumOrCommonDatum.cxx @@ -30,12 +30,18 @@ StepDimTol_DatumOrCommonDatum::StepDimTol_DatumOrCommonDatum() = default; int StepDimTol_DatumOrCommonDatum::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_Datum))) + { return 1; + } if (ent->IsKind( STANDARD_TYPE(NCollection_HArray1>))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumReferenceModifier.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumReferenceModifier.cxx index 9275f6c654..ac4fc0dc93 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumReferenceModifier.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumReferenceModifier.cxx @@ -27,11 +27,17 @@ StepDimTol_DatumReferenceModifier::StepDimTol_DatumReferenceModifier() = default int StepDimTol_DatumReferenceModifier::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_DatumReferenceModifierWithValue))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_SimpleDatumReferenceModifierMember))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumSystemOrReference.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumSystemOrReference.cxx index 71a1c592c1..4bd5b0c0ca 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumSystemOrReference.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_DatumSystemOrReference.cxx @@ -27,11 +27,17 @@ StepDimTol_DatumSystemOrReference::StepDimTol_DatumSystemOrReference() = default int StepDimTol_DatumSystemOrReference::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_DatumSystem))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_DatumReference))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeneralDatumReference.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeneralDatumReference.cxx index 02829f6764..0cd996c216 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeneralDatumReference.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeneralDatumReference.cxx @@ -39,7 +39,11 @@ void StepDimTol_GeneralDatumReference::Init( StepRepr_ShapeAspect::Init(theName, theDescription, theOfShape, theProductDefinitional); myBase = theBase; if (theHasModifiers) + { myModifiers = theModifiers; + } else + { myModifiers.Nullify(); + } } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceTarget.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceTarget.cxx index e3613a41dc..d9453c5088 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceTarget.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceTarget.cxx @@ -29,15 +29,25 @@ StepDimTol_GeometricToleranceTarget::StepDimTol_GeometricToleranceTarget() = def int StepDimTol_GeometricToleranceTarget::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceWithDefinedAreaUnit.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceWithDefinedAreaUnit.cxx index 488a7092b0..80d7398ea9 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceWithDefinedAreaUnit.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_GeometricToleranceWithDefinedAreaUnit.cxx @@ -42,7 +42,11 @@ void StepDimTol_GeometricToleranceWithDefinedAreaUnit::Init( theUnitSize); myAreaType = theUnitType; if (theHasSecondUnitSize) + { mySecondUnitSize = theSecondUnitSize; + } else + { mySecondUnitSize.Nullify(); + } } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ShapeToleranceSelect.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ShapeToleranceSelect.cxx index c2e58d6f2c..8d0ae6d29b 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ShapeToleranceSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ShapeToleranceSelect.cxx @@ -29,11 +29,17 @@ StepDimTol_ShapeToleranceSelect::StepDimTol_ShapeToleranceSelect() = default; int StepDimTol_ShapeToleranceSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_PlusMinusTolerance))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.cxx index 921179aad1..fd37c14bb4 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.cxx @@ -61,7 +61,9 @@ void StepDimTol_SimpleDatumReferenceModifierMember::SetEnumText(const int /*theV { int aVal = tool.Value(theText); if (aVal >= 0) + { SetInt(aVal); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ToleranceZoneTarget.cxx b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ToleranceZoneTarget.cxx index b282ce6b4b..8f1d601fab 100644 --- a/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ToleranceZoneTarget.cxx +++ b/src/DataExchange/TKDESTEP/StepDimTol/StepDimTol_ToleranceZoneTarget.cxx @@ -29,15 +29,25 @@ StepDimTol_ToleranceZoneTarget::StepDimTol_ToleranceZoneTarget() = default; int StepDimTol_ToleranceZoneTarget::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepDimTol_GeneralDatumReference))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedom.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedom.cxx index 82595dcbe5..5ddec73de9 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedom.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedom.cxx @@ -40,13 +40,21 @@ int StepElement_CurveElementFreedom::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches(anEnum)) + { return 1; + } else if (ent->Matches(anApp)) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -64,7 +72,9 @@ void StepElement_CurveElementFreedom::SetEnumeratedCurveElementFreedom( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ENUMERATED_CURVE_ELEMENT_FREEDOM"); SelMem->SetName(name->ToCString()); @@ -79,13 +89,17 @@ StepElement_EnumeratedCurveElementFreedom StepElement_CurveElementFreedom:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_None; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ENUMERATED_CURVE_ELEMENT_FREEDOM"); if (name->IsDifferent(nameitem)) + { return StepElement_None; + } int numit = SelMem->Enum(); StepElement_EnumeratedCurveElementFreedom val; switch (numit) @@ -129,7 +143,9 @@ void StepElement_CurveElementFreedom::SetApplicationDefinedDegreeOfFreedom( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("APPLICATION_DEFINED_DEGREE_OF_FREEDOM"); SelMem->SetName(name->ToCString()); @@ -144,13 +160,17 @@ occ::handle StepElement_CurveElementFreedom:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("APPLICATION_DEFINED_DEGREE_OF_FREEDOM"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle val = new TCollection_HAsciiString; val->AssignCat(SelMem->String()); return val; diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedomMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedomMember.cxx index abc798c39a..a45d3c4ede 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedomMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementFreedomMember.cxx @@ -59,8 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; - + } else if (!strcmp(name, ECEF)) { thecase = 1; @@ -79,7 +80,9 @@ bool StepElement_CurveElementFreedomMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurpose.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurpose.cxx index 11f5e7ed7b..e549618db0 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurpose.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurpose.cxx @@ -37,13 +37,21 @@ int StepElement_CurveElementPurpose::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("EnumeratedCurveElementPurpose")) + { return 1; + } else if (ent->Matches("ApplicationDefinedElementPurpose")) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -61,7 +69,9 @@ void StepElement_CurveElementPurpose::SetEnumeratedCurveElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ENUMERATED_CURVE_ELEMENT_PURPOSE"); SelMem->SetName(name->ToCString()); @@ -76,13 +86,17 @@ StepElement_EnumeratedCurveElementPurpose StepElement_CurveElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_Axial; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ENUMERATED_CURVEELEMENT_PURPOSE"); if (name->IsDifferent(nameitem)) + { return StepElement_Axial; + } int numit = SelMem->Enum(); StepElement_EnumeratedCurveElementPurpose val; switch (numit) @@ -123,7 +137,9 @@ void StepElement_CurveElementPurpose::SetApplicationDefinedElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("APPLICATION_DEFINED_ELEMENT_PURPOSE"); SelMem->SetName(name->ToCString()); @@ -138,13 +154,17 @@ occ::handle StepElement_CurveElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("APPLICATION_DEFINED_ELEMENT_PURPOSE"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle val = new TCollection_HAsciiString; val->AssignCat(SelMem->String()); return val; diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurposeMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurposeMember.cxx index 88c356bd3c..94b9105df3 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurposeMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_CurveElementPurposeMember.cxx @@ -59,7 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, ECEP)) { thecase = 1; @@ -78,7 +80,9 @@ bool StepElement_CurveElementPurposeMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspect.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspect.cxx index 3122aa7682..9299d6940b 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspect.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspect.cxx @@ -37,29 +37,53 @@ int StepElement_ElementAspect::CaseNum(const occ::handle& /* int StepElement_ElementAspect::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("ELEMENT_VOLUME")) + { return 1; + } else if (ent->Matches("VOLUME_3D_FACE")) + { return 2; + } else if (ent->Matches("VOLUME_2D_FACE")) + { return 3; + } else if (ent->Matches("VOLUME_3D_EDGE")) + { return 4; + } else if (ent->Matches("VOLUME_2D_EDGE")) + { return 5; + } else if (ent->Matches("SURFACE_3D_FACE")) + { return 6; + } else if (ent->Matches("SURFACE_2D_FACE")) + { return 7; + } else if (ent->Matches("SURFACE_3D_EDGE")) + { return 8; + } else if (ent->Matches("SURFACE_2D_EDGE")) + { return 9; + } else if (ent->Matches("CURVE_EDGE")) + { return 10; + } else + { return 0; + } } //================================================================================================= @@ -76,7 +100,9 @@ void StepElement_ElementAspect::SetElementVolume(const StepElement_ElementVolume occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ELEMENT_VOLUME"); SelMem->SetName(name->ToCString()); SelMem->SetEnum((int)val); @@ -89,12 +115,16 @@ StepElement_ElementVolume StepElement_ElementAspect::ElementVolume() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_Volume; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ELEMENT_VOLUME"); if (name->IsDifferent(nameitem)) + { return StepElement_Volume; + } int numit = SelMem->Enum(); StepElement_ElementVolume val; switch (numit) @@ -116,7 +146,9 @@ void StepElement_ElementAspect::SetVolume3dFace(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("VOLUME_3D_FACE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -129,12 +161,16 @@ int StepElement_ElementAspect::Volume3dFace() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("VOLUME_3D_FACE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -146,7 +182,9 @@ void StepElement_ElementAspect::SetVolume2dFace(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("VOLUME_2D_FACE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -159,12 +197,16 @@ int StepElement_ElementAspect::Volume2dFace() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("VOLUME_2D_FACE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -176,7 +218,9 @@ void StepElement_ElementAspect::SetVolume3dEdge(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("VOLUME_3D_EDGE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -189,12 +233,16 @@ int StepElement_ElementAspect::Volume3dEdge() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("VOLUME_3D_EDGE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -206,7 +254,9 @@ void StepElement_ElementAspect::SetVolume2dEdge(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("VOLUME_2D_EDGE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -219,12 +269,16 @@ int StepElement_ElementAspect::Volume2dEdge() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("VOLUME_2D_EDGE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -236,7 +290,9 @@ void StepElement_ElementAspect::SetSurface3dFace(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("SURFACE_3D_FACE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -249,12 +305,16 @@ int StepElement_ElementAspect::Surface3dFace() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("SURFACE_3D_FACE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -266,7 +326,9 @@ void StepElement_ElementAspect::SetSurface2dFace(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("SURFACE_2D_FACE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -279,12 +341,16 @@ int StepElement_ElementAspect::Surface2dFace() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("SURFACE_2D_FACE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -296,7 +362,9 @@ void StepElement_ElementAspect::SetSurface3dEdge(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("SURFACE_3D_EDGE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -309,12 +377,16 @@ int StepElement_ElementAspect::Surface3dEdge() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("SURFACE_3D_EDGE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -326,7 +398,9 @@ void StepElement_ElementAspect::SetSurface2dEdge(const int val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("SURFACE_2D_EDGE"); SelMem->SetName(name->ToCString()); SelMem->SetInteger(val); @@ -339,12 +413,16 @@ int StepElement_ElementAspect::Surface2dEdge() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("SURFACE_2D_EDGE"); if (name->IsDifferent(nameitem)) + { return 0; + } int val = SelMem->Integer(); return val; } @@ -356,7 +434,9 @@ void StepElement_ElementAspect::SetCurveEdge(const StepElement_CurveEdge val) occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("CURVE_EDGE"); SelMem->SetName(name->ToCString()); SelMem->SetEnum((int)val); @@ -369,12 +449,16 @@ StepElement_CurveEdge StepElement_ElementAspect::CurveEdge() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_ElementEdge; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("CURVE_EDGE"); if (name->IsDifferent(nameitem)) + { return StepElement_ElementEdge; + } int numit = SelMem->Enum(); StepElement_CurveEdge val; switch (numit) diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspectMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspectMember.cxx index 35d9efe560..229a36f98b 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspectMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_ElementAspectMember.cxx @@ -83,28 +83,46 @@ static int CompareNames(const char* const name, int& numen) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, aElementVolume)) { thecase = 1; numen = 1; } else if (!strcmp(name, aVolume3dFace)) + { thecase = 2; + } else if (!strcmp(name, aVolume2dFace)) + { thecase = 3; + } else if (!strcmp(name, aVolume3dEdge)) + { thecase = 4; + } else if (!strcmp(name, aVolume2dEdge)) + { thecase = 5; + } else if (!strcmp(name, aSurface3dFace)) + { thecase = 6; + } else if (!strcmp(name, aSurface2dFace)) + { thecase = 7; + } else if (!strcmp(name, aSurface3dEdge)) + { thecase = 8; + } else if (!strcmp(name, aSurface2dEdge)) + { thecase = 9; + } else if (!strcmp(name, aCurveEdge)) { thecase = 10; @@ -120,7 +138,9 @@ bool StepElement_ElementAspectMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValue.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValue.cxx index fd87ed7dd5..18035aa9c9 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValue.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValue.cxx @@ -42,13 +42,21 @@ int StepElement_MeasureOrUnspecifiedValue::CaseMem( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches(aCDM)) + { return 1; + } else if (ent->Matches(anUV)) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -65,7 +73,9 @@ void StepElement_MeasureOrUnspecifiedValue::SetContextDependentMeasure(const dou occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("CONTEXT_DEPENDENT_MEASURE"); SelMem->SetName(name->ToCString()); @@ -79,13 +89,17 @@ double StepElement_MeasureOrUnspecifiedValue::ContextDependentMeasure() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("CONTEXT_DEPENDENT_MEASURE"); if (name->IsDifferent(nameitem)) + { return 0; + } double val = SelMem->Real(); return val; } @@ -98,7 +112,9 @@ void StepElement_MeasureOrUnspecifiedValue::SetUnspecifiedValue( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("UNSPECIFIED_VALUE"); SelMem->SetName(name->ToCString()); SelMem->SetEnum((int)val); @@ -111,13 +127,17 @@ StepElement_UnspecifiedValue StepElement_MeasureOrUnspecifiedValue::UnspecifiedV occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_Unspecified; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("UNSPECIFIED_VALUE"); if (name->IsDifferent(nameitem)) + { return StepElement_Unspecified; + } int numit = SelMem->Enum(); StepElement_UnspecifiedValue val; switch (numit) diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValueMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValueMember.cxx index 3a5183a7fb..94a318b630 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValueMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_MeasureOrUnspecifiedValueMember.cxx @@ -59,7 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, aContextDependedMeasure)) { thecase = 1; @@ -78,7 +80,9 @@ bool StepElement_MeasureOrUnspecifiedValueMember::SetName(const char* const name int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurpose.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurpose.cxx index ecce70051e..4b51197421 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurpose.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurpose.cxx @@ -37,13 +37,21 @@ int StepElement_SurfaceElementPurpose::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("EnumeratedSurfaceElementPurpose")) + { return 1; + } else if (ent->Matches("ApplicationDefinedElementPurpose")) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -61,7 +69,9 @@ void StepElement_SurfaceElementPurpose::SetEnumeratedSurfaceElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("EnumeratedSurfaceElementPurpose"); SelMem->SetName(name->ToCString()); @@ -76,13 +86,17 @@ StepElement_EnumeratedSurfaceElementPurpose StepElement_SurfaceElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_MembraneDirect; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("EnumeratedSurfaceElementPurpose"); if (name->IsDifferent(nameitem)) + { return StepElement_MembraneDirect; + } int numit = SelMem->Enum(); StepElement_EnumeratedSurfaceElementPurpose val; switch (numit) @@ -117,7 +131,9 @@ void StepElement_SurfaceElementPurpose::SetApplicationDefinedElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ApplicationDefinedElementPurpose"); SelMem->SetName(name->ToCString()); @@ -132,13 +148,17 @@ occ::handle StepElement_SurfaceElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ApplicationDefinedElementPurpose"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle val = new TCollection_HAsciiString; val->AssignCat(SelMem->String()); return val; diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurposeMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurposeMember.cxx index a36619e8a9..5db06a9a44 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurposeMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_SurfaceElementPurposeMember.cxx @@ -59,7 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, ESEP)) { thecase = 1; @@ -78,7 +80,9 @@ bool StepElement_SurfaceElementPurposeMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurpose.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurpose.cxx index b0cbe9fd26..96b9aa911c 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurpose.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurpose.cxx @@ -37,13 +37,21 @@ int StepElement_VolumeElementPurpose::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("EnumeratedVolumeElementPurpose")) + { return 1; + } else if (ent->Matches("ApplicationDefinedElementPurpose")) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -61,7 +69,9 @@ void StepElement_VolumeElementPurpose::SetEnumeratedVolumeElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("EnumeratedVolumeElementPurpose"); SelMem->SetName(name->ToCString()); @@ -76,13 +86,17 @@ StepElement_EnumeratedVolumeElementPurpose StepElement_VolumeElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepElement_StressDisplacement; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("EnumeratedVolumeElementPurpose"); if (name->IsDifferent(nameitem)) + { return StepElement_StressDisplacement; + } int numit = SelMem->Enum(); StepElement_EnumeratedVolumeElementPurpose val; switch (numit) @@ -105,7 +119,9 @@ void StepElement_VolumeElementPurpose::SetApplicationDefinedElementPurpose( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ApplicationDefinedElementPurpose"); SelMem->SetName(name->ToCString()); @@ -120,13 +136,17 @@ occ::handle StepElement_VolumeElementPurpose:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ApplicationDefinedElementPurpose"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle val = new TCollection_HAsciiString; val->AssignCat(SelMem->String()); return val; diff --git a/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurposeMember.cxx b/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurposeMember.cxx index c2a56eb76a..d59174dddf 100644 --- a/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurposeMember.cxx +++ b/src/DataExchange/TKDESTEP/StepElement/StepElement_VolumeElementPurposeMember.cxx @@ -59,7 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, EVEP)) { thecase = 1; @@ -78,7 +80,9 @@ bool StepElement_VolumeElementPurposeMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_CurveElementEndCoordinateSystem.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_CurveElementEndCoordinateSystem.cxx index 405129bd88..2ee2264433 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_CurveElementEndCoordinateSystem.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_CurveElementEndCoordinateSystem.cxx @@ -31,13 +31,21 @@ int StepFEA_CurveElementEndCoordinateSystem::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepFEA_FeaAxis2Placement3d))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepFEA_AlignedCurve3dElementCoordinateSystem))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepFEA_ParametricCurve3dElementCoordinateSystem))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedom.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedom.cxx index 4a352dbbd7..a075769733 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedom.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedom.cxx @@ -37,13 +37,21 @@ int StepFEA_DegreeOfFreedom::CaseNum(const occ::handle& /*en int StepFEA_DegreeOfFreedom::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("ENUMERATED_DEGREE_OF_FREEDOM")) + { return 1; + } else if (ent->Matches("APPLICATION_DEFINED_DEGREE_OF_FREEDOM")) + { return 2; + } else + { return 0; + } } //================================================================================================= @@ -61,7 +69,9 @@ void StepFEA_DegreeOfFreedom::SetEnumeratedDegreeOfFreedom( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ENUMERATED_DEGREE_OF_FREEDOM"); SelMem->SetName(name->ToCString()); @@ -75,13 +85,17 @@ StepFEA_EnumeratedDegreeOfFreedom StepFEA_DegreeOfFreedom::EnumeratedDegreeOfFre occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return StepFEA_XTranslation; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ENUMERATED_DEGREE_OF_FREEDOM"); if (name->IsDifferent(nameitem)) + { return StepFEA_XTranslation; + } int numit = SelMem->Enum(); StepFEA_EnumeratedDegreeOfFreedom val; switch (numit) @@ -111,7 +125,9 @@ void StepFEA_DegreeOfFreedom::SetApplicationDefinedDegreeOfFreedom( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("APPLICATION_DEFINED_DEGREE_OF_FREEDOM"); SelMem->SetName(name->ToCString()); @@ -126,13 +142,17 @@ occ::handle StepFEA_DegreeOfFreedom::ApplicationDefine occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("APPLICATION_DEFINED_DEGREE_OF_FREEDOM"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle val = new TCollection_HAsciiString; val->AssignCat(SelMem->String()); return val; diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedomMember.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedomMember.cxx index d9688ed418..efa3510d62 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedomMember.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_DegreeOfFreedomMember.cxx @@ -59,7 +59,9 @@ static int CompareNames(const char* const name, int& /*numen*/) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, anEnumeratedCurveElementFreedom)) { thecase = 1; @@ -112,7 +114,9 @@ bool StepFEA_DegreeOfFreedomMember::SetName(const char* const name) int numit = 0; mycase = CompareNames(name, numit); if (numit) + { SetInteger(numit); + } return (mycase > 0); } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_ElementOrElementGroup.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_ElementOrElementGroup.cxx index 3d4dbe6cac..4a0c90bb7e 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_ElementOrElementGroup.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_ElementOrElementGroup.cxx @@ -29,11 +29,17 @@ StepFEA_ElementOrElementGroup::StepFEA_ElementOrElementGroup() = default; int StepFEA_ElementOrElementGroup::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepFEA_ElementRepresentation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepFEA_ElementGroup))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor22d.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor22d.cxx index 4d0cb7aee1..43abdffb20 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor22d.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor22d.cxx @@ -32,9 +32,13 @@ StepFEA_SymmetricTensor22d::StepFEA_SymmetricTensor22d() = default; int StepFEA_SymmetricTensor22d::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepData_SelectArrReal))) + { return 1; + } return 0; } @@ -46,6 +50,8 @@ occ::handle> StepFEA_SymmetricTensor22d::Anisotropic // return occ::down_cast>(Value()); occ::handle SSR = occ::down_cast(Value()); if (SSR.IsNull()) + { return new NCollection_HArray1(1, 3); + } return SSR->ArrReal(); } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23d.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23d.cxx index b17b63d43e..91751a60b6 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23d.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23d.cxx @@ -37,15 +37,25 @@ int StepFEA_SymmetricTensor23d::CaseNum(const occ::handle& / int StepFEA_SymmetricTensor23d::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("ISOTROPIC_SYMMETRIC_TENSOR2_3D")) + { return 1; + } else if (ent->Matches("ORTHOTROPIC_SYMMETRIC_TENSOR2_3D")) + { return 2; + } else if (ent->Matches("ANISOTROPIC_SYMMETRIC_TENSOR2_3D")) + { return 3; + } else + { return 0; + } } //================================================================================================= @@ -62,7 +72,9 @@ void StepFEA_SymmetricTensor23d::SetIsotropicSymmetricTensor23d(const double val occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ISOTROPIC_SYMMETRIC_TENSOR2_3D"); SelMem->SetName(name->ToCString()); @@ -76,13 +88,17 @@ double StepFEA_SymmetricTensor23d::IsotropicSymmetricTensor23d() const occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return 0; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ISOTROPIC_SYMMETRIC_TENSOR2_3D"); if (name->IsDifferent(nameitem)) + { return 0; + } double val = SelMem->Real(); return val; } @@ -95,7 +111,9 @@ void StepFEA_SymmetricTensor23d::SetOrthotropicSymmetricTensor23d( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ORTHOTROPIC_SYMMETRIC_TENSOR2_3D"); SelMem->SetName(name->ToCString()); @@ -110,13 +128,17 @@ occ::handle> StepFEA_SymmetricTensor23d::Orthotropic occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ORTHOTROPIC_SYMMETRIC_TENSOR2_3D"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle> val /* = SelMem->HArray1OfReal()*/; return val; } @@ -129,7 +151,9 @@ void StepFEA_SymmetricTensor23d::SetAnisotropicSymmetricTensor23d( occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return; + } occ::handle name = new TCollection_HAsciiString("ANISOTROPIC_SYMMETRIC_TENSOR2_3D"); SelMem->SetName(name->ToCString()); @@ -144,13 +168,17 @@ occ::handle> StepFEA_SymmetricTensor23d::Anisotropic occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return nullptr; + } occ::handle name = new TCollection_HAsciiString; name->AssignCat(SelMem->Name()); occ::handle nameitem = new TCollection_HAsciiString("ANISOTROPIC_SYMMETRIC_TENSOR2_3D"); if (name->IsDifferent(nameitem)) + { return nullptr; + } occ::handle> val /*= SelMem->HArray1OfReal()*/; return val; } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23dMember.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23dMember.cxx index 380bcfe86c..fb63deb443 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23dMember.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor23dMember.cxx @@ -62,13 +62,21 @@ static int CompareNames(const char* const name) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, IST)) + { thecase = 1; + } else if (!strcmp(name, OST)) + { thecase = 2; + } else if (!strcmp(name, AST)) + { thecase = 3; + } return thecase; } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor42d.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor42d.cxx index c49d44ff21..2c70a876b4 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor42d.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor42d.cxx @@ -32,9 +32,13 @@ StepFEA_SymmetricTensor42d::StepFEA_SymmetricTensor42d() = default; int StepFEA_SymmetricTensor42d::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepData_SelectArrReal))) + { return 1; + } return 0; } @@ -46,6 +50,8 @@ occ::handle> StepFEA_SymmetricTensor42d::Anisotropic // return occ::down_cast>(Value()); occ::handle SSR = occ::down_cast(Value()); if (SSR.IsNull()) + { return new NCollection_HArray1(1, 6); + } return SSR->ArrReal(); } diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43d.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43d.cxx index 49518cd0db..777e60976e 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43d.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43d.cxx @@ -39,21 +39,37 @@ int StepFEA_SymmetricTensor43d::CaseNum(const occ::handle& / int StepFEA_SymmetricTensor43d::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->Matches("ANISOTROPIC_SYMMETRIC_TENSOR4_3D")) + { return 1; + } else if (ent->Matches("FEA_ISOTROPIC_SYMMETRIC_TENSOR4_3D")) + { return 2; + } else if (ent->Matches("FEA_ISO_ORTHOTROPIC_SYMMETRIC_TENSOR4_3D")) + { return 3; + } else if (ent->Matches("FEA_TRANSVERSE_ISOTROPIC_SYMMETRIC_TENSOR4_3D")) + { return 4; + } else if (ent->Matches("FEA_COLUMN_NORMALISED_ORTHOTROPIC_SYMMETRIC_TENSOR4_3D")) + { return 5; + } else if (ent->Matches("FEA_COLUMN_NORMALISED_MONOCLINIC_SYMMETRIC_TENSOR4_3D")) + { return 6; + } else + { return 0; + } } //================================================================================================= @@ -74,7 +90,9 @@ occ::handle> StepFEA_SymmetricTensor43d::Anisotropic occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return anArr; + } // occ::handle> aSeq = SelMem->SeqReal(); return anArr; // return occ::down_cast>(Value()); @@ -89,7 +107,9 @@ occ::handle> StepFEA_SymmetricTensor43d:: occ::handle SelMem = occ::down_cast(Value()); if (SelMem.IsNull()) + { return anArr; + } // occ::handle> aSeq = SelMem->SeqReal(); return anArr; // return occ::down_cast>(Value()); diff --git a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43dMember.cxx b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43dMember.cxx index 73c2de6488..5dedf82889 100644 --- a/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43dMember.cxx +++ b/src/DataExchange/TKDESTEP/StepFEA/StepFEA_SymmetricTensor43dMember.cxx @@ -67,19 +67,33 @@ static int CompareNames(const char* const name) { int thecase = 0; if (!name || name[0] == '\0') + { thecase = 0; + } else if (!strcmp(name, AST)) + { thecase = 1; + } else if (!strcmp(name, IST)) + { thecase = 2; + } else if (!strcmp(name, IOST)) + { thecase = 3; + } else if (!strcmp(name, TIST)) + { thecase = 4; + } else if (!strcmp(name, CNOST)) + { thecase = 5; + } else if (!strcmp(name, CNMST)) + { thecase = 6; + } return thecase; } diff --git a/src/DataExchange/TKDESTEP/StepFile/StepFile_Read.cxx b/src/DataExchange/TKDESTEP/StepFile/StepFile_Read.cxx index b6dae62d88..d5818d7720 100644 --- a/src/DataExchange/TKDESTEP/StepFile/StepFile_Read.cxx +++ b/src/DataExchange/TKDESTEP/StepFile/StepFile_Read.cxx @@ -59,10 +59,12 @@ static std::mutex& GetGlobalReadMutex() void StepFile_Interrupt(const char* theErrorMessage, const bool theIsFail) { if (theErrorMessage == nullptr) + { return; + } Message_Messenger::StreamBuffer sout = theIsFail ? Message::SendFail() : Message::SendTrace(); - sout << "**** ERR StepFile : " << theErrorMessage << " ****" << std::endl; + sout << "**** ERR StepFile : " << theErrorMessage << " ****" << '\n'; } static int StepFile_Read(const char* theName, @@ -186,7 +188,9 @@ static int StepFile_Read(const char* theName, readtool.LoadModel(theStepModel); if (theStepModel->Protocol().IsNull()) + { theStepModel->SetProtocol(theProtocol); + } aFileDataModel.ClearRecorder(2); anFailsCount = undirec->GlobalCheck()->NbFails() - anFailsCount; if (anFailsCount > 0) diff --git a/src/DataExchange/TKDESTEP/StepFile/StepFile_ReadData.cxx b/src/DataExchange/TKDESTEP/StepFile/StepFile_ReadData.cxx index 3e7ea9dc25..26afa02636 100644 --- a/src/DataExchange/TKDESTEP/StepFile/StepFile_ReadData.cxx +++ b/src/DataExchange/TKDESTEP/StepFile/StepFile_ReadData.cxx @@ -231,7 +231,9 @@ void StepFile_ReadData::RecordListStart() default: { char aBufSub[10]; if (myNumSub > 9) + { Sprintf(aBufSub, "$%d", myNumSub); + } else { aBufSub[0] = '$'; @@ -260,12 +262,18 @@ void StepFile_ReadData::CreateNewArg() myNbPar++; aNewArg->myType = myTypeArg; if (myTypeArg == Interface_ParamSub) + { aNewArg->myValue = mySubArg; + } else + { GetResultText(&aNewArg->myValue); + } if (myTypeArg == Interface_ParamMisc) + { myErrorArg = true; + } if (myCurRec->myFirst == nullptr) { @@ -329,7 +337,9 @@ void StepFile_ReadData::FinalOfScope() Scope* anOldScope; Record* aRecord; if (myCurScope == nullptr) + { return; + } aRecord = CreateNewRecord(); aRecord->myIdent = TextValue::Scope; @@ -384,7 +394,9 @@ void StepFile_ReadData::ClearRecorder(const int theMode) bool StepFile_ReadData::GetArgDescription(Interface_ParamType* theType, char** theValue) { if (myCurrArg == nullptr) + { return false; + } *theType = myCurrArg->myType; *theValue = myCurrArg->myValue; myCurrArg = myCurrArg->myNext; @@ -406,7 +418,9 @@ void StepFile_ReadData::GetFileNbR(int* theNbHead, int* theNbRec, int* theNbPage bool StepFile_ReadData::GetRecordDescription(char** theIdent, char** theType, int* theNbArg) { if (myCurRec == nullptr) + { return false; + } *theIdent = myCurRec->myIdent; *theType = myCurRec->myType; *theNbArg = (myCurRec->myFirst != nullptr); @@ -544,9 +558,13 @@ void StepFile_ReadData::AddNewRecord(Record* theNewRecord) { myNbRec++; if (myFirstRec == nullptr) + { myFirstRec = theNewRecord; + } if (myLastRec != nullptr) + { myLastRec->myNext = theNewRecord; + } myLastRec = theNewRecord; } @@ -574,7 +592,9 @@ void StepFile_ReadData::PrintRecord(Record* theRecord) theRecord->myType, (theRecord->myFirst ? theRecord->myFirst->myValue : "")); if (myModePrint < 2) + { return; + } myCurrArg = theRecord->myFirst; while (myCurrArg != nullptr) { @@ -594,5 +614,7 @@ void StepFile_ReadData::PrintRecord(Record* theRecord) myCurrArg = myCurrArg->myNext; } if (anArgLen > 0) + { Printf("\n"); + } } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Axis2Placement.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Axis2Placement.cxx index 5d8afe1538..e8aa3254b6 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Axis2Placement.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Axis2Placement.cxx @@ -22,11 +22,17 @@ StepGeom_Axis2Placement::StepGeom_Axis2Placement() = default; int StepGeom_Axis2Placement::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement2d))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineCurve.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineCurve.cxx index 5a7f1f278a..47b5bada1a 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineCurve.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineCurve.cxx @@ -68,7 +68,9 @@ occ::handle StepGeom_BSplineCurve::ControlPointsListVal int StepGeom_BSplineCurve::NbControlPointsList() const { if (controlPointsList.IsNull()) + { return 0; + } return controlPointsList->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineSurface.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineSurface.cxx index adbe5dfc63..5d975ac174 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_BSplineSurface.cxx @@ -83,14 +83,18 @@ occ::handle StepGeom_BSplineSurface::ControlPointsListV int StepGeom_BSplineSurface::NbControlPointsListI() const { if (controlPointsList.IsNull()) + { return 0; + } return controlPointsList->UpperRow() - controlPointsList->LowerRow() + 1; } int StepGeom_BSplineSurface::NbControlPointsListJ() const { if (controlPointsList.IsNull()) + { return 0; + } return controlPointsList->UpperCol() - controlPointsList->LowerCol() + 1; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CartesianPoint.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CartesianPoint.cxx index 7db8fcda96..1c7a552c3a 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CartesianPoint.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CartesianPoint.cxx @@ -57,11 +57,17 @@ void StepGeom_CartesianPoint::SetCoordinates( { myNbCoord = aCoordinates->Length(); if (myNbCoord > 0) + { myCoords[0] = aCoordinates->Value(1); + } if (myNbCoord > 1) + { myCoords[1] = aCoordinates->Value(2); + } if (myNbCoord > 2) + { myCoords[2] = aCoordinates->Value(3); + } } void StepGeom_CartesianPoint::SetCoordinates(const std::array& theCoordinates) diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CompositeCurve.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CompositeCurve.cxx index 3c9da053d6..d1d9556401 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CompositeCurve.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CompositeCurve.cxx @@ -52,7 +52,9 @@ occ::handle StepGeom_CompositeCurve::SegmentsVal int StepGeom_CompositeCurve::NbSegments() const { if (segments.IsNull()) + { return 0; + } return segments->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CurveOnSurface.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CurveOnSurface.cxx index 6ba5ef7347..5c0b215ca6 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CurveOnSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_CurveOnSurface.cxx @@ -23,13 +23,21 @@ StepGeom_CurveOnSurface::StepGeom_CurveOnSurface() = default; int StepGeom_CurveOnSurface::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_CompositeCurveOnSurface))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Direction.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Direction.cxx index 2778a42929..52bfc2aeae 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Direction.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Direction.cxx @@ -57,11 +57,17 @@ void StepGeom_Direction::SetDirectionRatios( { myNbCoord = theDirectionRatios->Length(); if (myNbCoord > 0) + { myCoords[0] = theDirectionRatios->Value(1); + } if (myNbCoord > 1) + { myCoords[1] = theDirectionRatios->Value(2); + } if (myNbCoord > 2) + { myCoords[2] = theDirectionRatios->Value(3); + } } void StepGeom_Direction::SetDirectionRatios(const std::array& theDirectionRatios) diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_PcurveOrSurface.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_PcurveOrSurface.cxx index ce5e088a04..c32d49536f 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_PcurveOrSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_PcurveOrSurface.cxx @@ -22,11 +22,17 @@ StepGeom_PcurveOrSurface::StepGeom_PcurveOrSurface() = default; int StepGeom_PcurveOrSurface::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Surface))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Polyline.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Polyline.cxx index 0d0bae0834..7a793682c0 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Polyline.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_Polyline.cxx @@ -48,6 +48,8 @@ occ::handle StepGeom_Polyline::PointsValue(const int nu int StepGeom_Polyline::NbPoints() const { if (points.IsNull()) + { return 0; + } return points->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_RectangularCompositeSurface.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_RectangularCompositeSurface.cxx index a84d523b5a..b653d81465 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_RectangularCompositeSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_RectangularCompositeSurface.cxx @@ -51,13 +51,17 @@ occ::handle StepGeom_RectangularCompositeSurface::Segment int StepGeom_RectangularCompositeSurface::NbSegmentsI() const { if (segments.IsNull()) + { return 0; + } return segments->UpperRow() - segments->LowerRow() + 1; } int StepGeom_RectangularCompositeSurface::NbSegmentsJ() const { if (segments.IsNull()) + { return 0; + } return segments->UpperCol() - segments->LowerCol() + 1; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_SurfaceBoundary.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_SurfaceBoundary.cxx index 742431b0b0..db0a79ce3d 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_SurfaceBoundary.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_SurfaceBoundary.cxx @@ -30,11 +30,17 @@ StepGeom_SurfaceBoundary::StepGeom_SurfaceBoundary() = default; int StepGeom_SurfaceBoundary::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_BoundaryCurve))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_DegeneratePcurve))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_TrimmingSelect.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_TrimmingSelect.cxx index 3899de6fc7..a34ca21f71 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_TrimmingSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_TrimmingSelect.cxx @@ -23,9 +23,13 @@ StepGeom_TrimmingSelect::StepGeom_TrimmingSelect() = default; int StepGeom_TrimmingSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint))) + { return 1; + } return 0; } @@ -37,13 +41,19 @@ occ::handle StepGeom_TrimmingSelect::NewMember() const int StepGeom_TrimmingSelect::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } Interface_ParamType type = ent->ParamType(); // Void : on admet "non defini" (en principe, on ne devrait pas) if (type != Interface_ParamVoid && type != Interface_ParamReal) + { return 0; + } if (ent->Matches("PARAMETER_VALUE")) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_VectorOrDirection.cxx b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_VectorOrDirection.cxx index 4f7530aecd..bb24ef82f3 100644 --- a/src/DataExchange/TKDESTEP/StepGeom/StepGeom_VectorOrDirection.cxx +++ b/src/DataExchange/TKDESTEP/StepGeom/StepGeom_VectorOrDirection.cxx @@ -22,11 +22,17 @@ StepGeom_VectorOrDirection::StepGeom_VectorOrDirection() = default; int StepGeom_VectorOrDirection::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Vector))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Direction))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ActuatedKinematicPair.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ActuatedKinematicPair.cxx index cf4f0c540f..03d153f4d4 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ActuatedKinematicPair.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ActuatedKinematicPair.cxx @@ -67,7 +67,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myTX = theTX; } else + { myTX = StepKinematics_ActuatedDirection(); + } defTY = hasTY; if (defTY) @@ -75,7 +77,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myTY = theTY; } else + { myTY = StepKinematics_ActuatedDirection(); + } defTZ = hasTZ; if (defTZ) @@ -83,7 +87,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myTZ = theTZ; } else + { myTZ = StepKinematics_ActuatedDirection(); + } defRX = hasRX; if (defRX) @@ -91,7 +97,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myRX = theRX; } else + { myRX = StepKinematics_ActuatedDirection(); + } defRY = hasRY; if (defRY) @@ -99,7 +107,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myRY = theRY; } else + { myRY = StepKinematics_ActuatedDirection(); + } defRZ = hasRZ; if (defRZ) @@ -107,7 +117,9 @@ void StepKinematics_ActuatedKinematicPair::Init( myRZ = theRZ; } else + { myRZ = StepKinematics_ActuatedDirection(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_CylindricalPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_CylindricalPairWithRange.cxx index 81a2d7dd45..6636849491 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_CylindricalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_CylindricalPairWithRange.cxx @@ -73,7 +73,9 @@ void StepKinematics_CylindricalPairWithRange::Init( myLowerLimitActualTranslation = theLowerLimitActualTranslation; } else + { myLowerLimitActualTranslation = 0; + } defUpperLimitActualTranslation = hasUpperLimitActualTranslation; if (defUpperLimitActualTranslation) @@ -81,7 +83,9 @@ void StepKinematics_CylindricalPairWithRange::Init( myUpperLimitActualTranslation = theUpperLimitActualTranslation; } else + { myUpperLimitActualTranslation = 0; + } defLowerLimitActualRotation = hasLowerLimitActualRotation; if (defLowerLimitActualRotation) @@ -89,7 +93,9 @@ void StepKinematics_CylindricalPairWithRange::Init( myLowerLimitActualRotation = theLowerLimitActualRotation; } else + { myLowerLimitActualRotation = 0; + } defUpperLimitActualRotation = hasUpperLimitActualRotation; if (defUpperLimitActualRotation) @@ -97,7 +103,9 @@ void StepKinematics_CylindricalPairWithRange::Init( myUpperLimitActualRotation = theUpperLimitActualRotation; } else + { myUpperLimitActualRotation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_GearPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_GearPairWithRange.cxx index a6e4d4e1b3..9884226cce 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_GearPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_GearPairWithRange.cxx @@ -65,7 +65,9 @@ void StepKinematics_GearPairWithRange::Init( myLowerLimitActualRotation1 = theLowerLimitActualRotation1; } else + { myLowerLimitActualRotation1 = 0; + } defUpperLimitActualRotation1 = hasUpperLimitActualRotation1; if (defUpperLimitActualRotation1) @@ -73,7 +75,9 @@ void StepKinematics_GearPairWithRange::Init( myUpperLimitActualRotation1 = theUpperLimitActualRotation1; } else + { myUpperLimitActualRotation1 = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_KinematicTopologyRepresentationSelect.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_KinematicTopologyRepresentationSelect.cxx index 58a95fdb73..5b53a01727 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_KinematicTopologyRepresentationSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_KinematicTopologyRepresentationSelect.cxx @@ -31,13 +31,21 @@ int StepKinematics_KinematicTopologyRepresentationSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_KinematicTopologyDirectedStructure))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_KinematicTopologyNetworkStructure))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_KinematicTopologyStructure))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_LowOrderKinematicPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_LowOrderKinematicPairWithRange.cxx index 3afcfa4370..7fbfc348b8 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_LowOrderKinematicPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_LowOrderKinematicPairWithRange.cxx @@ -98,7 +98,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualRotationX = theLowerLimitActualRotationX; } else + { myLowerLimitActualRotationX = 0; + } defUpperLimitActualRotationX = hasUpperLimitActualRotationX; if (defUpperLimitActualRotationX) @@ -106,7 +108,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualRotationX = theUpperLimitActualRotationX; } else + { myUpperLimitActualRotationX = 0; + } defLowerLimitActualRotationY = hasLowerLimitActualRotationY; if (defLowerLimitActualRotationY) @@ -114,7 +118,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualRotationY = theLowerLimitActualRotationY; } else + { myLowerLimitActualRotationY = 0; + } defUpperLimitActualRotationY = hasUpperLimitActualRotationY; if (defUpperLimitActualRotationY) @@ -122,7 +128,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualRotationY = theUpperLimitActualRotationY; } else + { myUpperLimitActualRotationY = 0; + } defLowerLimitActualRotationZ = hasLowerLimitActualRotationZ; if (defLowerLimitActualRotationZ) @@ -130,7 +138,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualRotationZ = theLowerLimitActualRotationZ; } else + { myLowerLimitActualRotationZ = 0; + } defUpperLimitActualRotationZ = hasUpperLimitActualRotationZ; if (defUpperLimitActualRotationZ) @@ -138,7 +148,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualRotationZ = theUpperLimitActualRotationZ; } else + { myUpperLimitActualRotationZ = 0; + } defLowerLimitActualTranslationX = hasLowerLimitActualTranslationX; if (defLowerLimitActualTranslationX) @@ -146,7 +158,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualTranslationX = theLowerLimitActualTranslationX; } else + { myLowerLimitActualTranslationX = 0; + } defUpperLimitActualTranslationX = hasUpperLimitActualTranslationX; if (defUpperLimitActualTranslationX) @@ -154,7 +168,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualTranslationX = theUpperLimitActualTranslationX; } else + { myUpperLimitActualTranslationX = 0; + } defLowerLimitActualTranslationY = hasLowerLimitActualTranslationY; if (defLowerLimitActualTranslationY) @@ -162,7 +178,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualTranslationY = theLowerLimitActualTranslationY; } else + { myLowerLimitActualTranslationY = 0; + } defUpperLimitActualTranslationY = hasUpperLimitActualTranslationY; if (defUpperLimitActualTranslationY) @@ -170,7 +188,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualTranslationY = theUpperLimitActualTranslationY; } else + { myUpperLimitActualTranslationY = 0; + } defLowerLimitActualTranslationZ = hasLowerLimitActualTranslationZ; if (defLowerLimitActualTranslationZ) @@ -178,7 +198,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myLowerLimitActualTranslationZ = theLowerLimitActualTranslationZ; } else + { myLowerLimitActualTranslationZ = 0; + } defUpperLimitActualTranslationZ = hasUpperLimitActualTranslationZ; if (defUpperLimitActualTranslationZ) @@ -186,7 +208,9 @@ void StepKinematics_LowOrderKinematicPairWithRange::Init( myUpperLimitActualTranslationZ = theUpperLimitActualTranslationZ; } else + { myUpperLimitActualTranslationZ = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PlanarPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PlanarPairWithRange.cxx index 1722838a54..5d44289c8c 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PlanarPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PlanarPairWithRange.cxx @@ -79,7 +79,9 @@ void StepKinematics_PlanarPairWithRange::Init( myLowerLimitActualRotation = theLowerLimitActualRotation; } else + { myLowerLimitActualRotation = 0; + } defUpperLimitActualRotation = hasUpperLimitActualRotation; if (defUpperLimitActualRotation) @@ -87,7 +89,9 @@ void StepKinematics_PlanarPairWithRange::Init( myUpperLimitActualRotation = theUpperLimitActualRotation; } else + { myUpperLimitActualRotation = 0; + } defLowerLimitActualTranslationX = hasLowerLimitActualTranslationX; if (defLowerLimitActualTranslationX) @@ -95,7 +99,9 @@ void StepKinematics_PlanarPairWithRange::Init( myLowerLimitActualTranslationX = theLowerLimitActualTranslationX; } else + { myLowerLimitActualTranslationX = 0; + } defUpperLimitActualTranslationX = hasUpperLimitActualTranslationX; if (defUpperLimitActualTranslationX) @@ -103,7 +109,9 @@ void StepKinematics_PlanarPairWithRange::Init( myUpperLimitActualTranslationX = theUpperLimitActualTranslationX; } else + { myUpperLimitActualTranslationX = 0; + } defLowerLimitActualTranslationY = hasLowerLimitActualTranslationY; if (defLowerLimitActualTranslationY) @@ -111,7 +119,9 @@ void StepKinematics_PlanarPairWithRange::Init( myLowerLimitActualTranslationY = theLowerLimitActualTranslationY; } else + { myLowerLimitActualTranslationY = 0; + } defUpperLimitActualTranslationY = hasUpperLimitActualTranslationY; if (defUpperLimitActualTranslationY) @@ -119,7 +129,9 @@ void StepKinematics_PlanarPairWithRange::Init( myUpperLimitActualTranslationY = theUpperLimitActualTranslationY; } else + { myUpperLimitActualTranslationY = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnPlanarCurvePairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnPlanarCurvePairWithRange.cxx index f23af89ccc..6358d45623 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnPlanarCurvePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnPlanarCurvePairWithRange.cxx @@ -75,7 +75,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myLowerLimitYaw = theLowerLimitYaw; } else + { myLowerLimitYaw = 0; + } defUpperLimitYaw = hasUpperLimitYaw; if (defUpperLimitYaw) @@ -83,7 +85,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myUpperLimitYaw = theUpperLimitYaw; } else + { myUpperLimitYaw = 0; + } defLowerLimitPitch = hasLowerLimitPitch; if (defLowerLimitPitch) @@ -91,7 +95,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myLowerLimitPitch = theLowerLimitPitch; } else + { myLowerLimitPitch = 0; + } defUpperLimitPitch = hasUpperLimitPitch; if (defUpperLimitPitch) @@ -99,7 +105,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myUpperLimitPitch = theUpperLimitPitch; } else + { myUpperLimitPitch = 0; + } defLowerLimitRoll = hasLowerLimitRoll; if (defLowerLimitRoll) @@ -107,7 +115,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myLowerLimitRoll = theLowerLimitRoll; } else + { myLowerLimitRoll = 0; + } defUpperLimitRoll = hasUpperLimitRoll; if (defUpperLimitRoll) @@ -115,7 +125,9 @@ void StepKinematics_PointOnPlanarCurvePairWithRange::Init( myUpperLimitRoll = theUpperLimitRoll; } else + { myUpperLimitRoll = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnSurfacePairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnSurfacePairWithRange.cxx index 2901541f10..471dbd9e30 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnSurfacePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PointOnSurfacePairWithRange.cxx @@ -73,7 +73,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myLowerLimitYaw = theLowerLimitYaw; } else + { myLowerLimitYaw = 0; + } defUpperLimitYaw = hasUpperLimitYaw; if (defUpperLimitYaw) @@ -81,7 +83,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myUpperLimitYaw = theUpperLimitYaw; } else + { myUpperLimitYaw = 0; + } defLowerLimitPitch = hasLowerLimitPitch; if (defLowerLimitPitch) @@ -89,7 +93,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myLowerLimitPitch = theLowerLimitPitch; } else + { myLowerLimitPitch = 0; + } defUpperLimitPitch = hasUpperLimitPitch; if (defUpperLimitPitch) @@ -97,7 +103,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myUpperLimitPitch = theUpperLimitPitch; } else + { myUpperLimitPitch = 0; + } defLowerLimitRoll = hasLowerLimitRoll; if (defLowerLimitRoll) @@ -105,7 +113,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myLowerLimitRoll = theLowerLimitRoll; } else + { myLowerLimitRoll = 0; + } defUpperLimitRoll = hasUpperLimitRoll; if (defUpperLimitRoll) @@ -113,7 +123,9 @@ void StepKinematics_PointOnSurfacePairWithRange::Init( myUpperLimitRoll = theUpperLimitRoll; } else + { myUpperLimitRoll = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PrismaticPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PrismaticPairWithRange.cxx index 89080b915c..46f29e74bf 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PrismaticPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_PrismaticPairWithRange.cxx @@ -67,7 +67,9 @@ void StepKinematics_PrismaticPairWithRange::Init( myLowerLimitActualTranslation = theLowerLimitActualTranslation; } else + { myLowerLimitActualTranslation = 0; + } defUpperLimitActualTranslation = hasUpperLimitActualTranslation; if (defUpperLimitActualTranslation) @@ -75,7 +77,9 @@ void StepKinematics_PrismaticPairWithRange::Init( myUpperLimitActualTranslation = theUpperLimitActualTranslation; } else + { myUpperLimitActualTranslation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RackAndPinionPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RackAndPinionPairWithRange.cxx index 084fdbbb12..e5d91cccd3 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RackAndPinionPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RackAndPinionPairWithRange.cxx @@ -58,7 +58,9 @@ void StepKinematics_RackAndPinionPairWithRange::Init( myLowerLimitRackDisplacement = theLowerLimitRackDisplacement; } else + { myLowerLimitRackDisplacement = 0; + } defUpperLimitRackDisplacement = hasUpperLimitRackDisplacement; if (defUpperLimitRackDisplacement) @@ -66,7 +68,9 @@ void StepKinematics_RackAndPinionPairWithRange::Init( myUpperLimitRackDisplacement = theUpperLimitRackDisplacement; } else + { myUpperLimitRackDisplacement = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RevolutePairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RevolutePairWithRange.cxx index 600831b1e2..066d89a792 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RevolutePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RevolutePairWithRange.cxx @@ -67,7 +67,9 @@ void StepKinematics_RevolutePairWithRange::Init( myLowerLimitActualRotation = theLowerLimitActualRotation; } else + { myLowerLimitActualRotation = 0; + } defUpperLimitActualRotation = hasUpperLimitActualRotation; if (defUpperLimitActualRotation) @@ -75,7 +77,9 @@ void StepKinematics_RevolutePairWithRange::Init( myUpperLimitActualRotation = theUpperLimitActualRotation; } else + { myUpperLimitActualRotation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RigidPlacement.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RigidPlacement.cxx index 0bf8eefb3a..0ad0a906b8 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RigidPlacement.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_RigidPlacement.cxx @@ -27,11 +27,17 @@ StepKinematics_RigidPlacement::StepKinematics_RigidPlacement() = default; int StepKinematics_RigidPlacement::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_SuParameters))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ScrewPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ScrewPairWithRange.cxx index 565f5e1ebd..a8819e4f10 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ScrewPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_ScrewPairWithRange.cxx @@ -57,7 +57,9 @@ void StepKinematics_ScrewPairWithRange::Init( myLowerLimitActualRotation = theLowerLimitActualRotation; } else + { myLowerLimitActualRotation = 0; + } defUpperLimitActualRotation = hasUpperLimitActualRotation; if (defUpperLimitActualRotation) @@ -65,7 +67,9 @@ void StepKinematics_ScrewPairWithRange::Init( myUpperLimitActualRotation = theUpperLimitActualRotation; } else + { myUpperLimitActualRotation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SpatialRotation.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SpatialRotation.cxx index 461cbd8eee..eb805ab710 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SpatialRotation.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SpatialRotation.cxx @@ -28,11 +28,17 @@ StepKinematics_SpatialRotation::StepKinematics_SpatialRotation() = default; int StepKinematics_SpatialRotation::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_RotationAboutDirection))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(NCollection_HArray1))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairSelect.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairSelect.cxx index 740e0454f2..52cf2925cc 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairSelect.cxx @@ -27,11 +27,17 @@ StepKinematics_SphericalPairSelect::StepKinematics_SphericalPairSelect() = defau int StepKinematics_SphericalPairSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_SphericalPair))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithPin))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithPinAndRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithPinAndRange.cxx index a2947d72a1..e9efac96ae 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithPinAndRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithPinAndRange.cxx @@ -74,7 +74,9 @@ void StepKinematics_SphericalPairWithPinAndRange::Init( myLowerLimitYaw = theLowerLimitYaw; } else + { myLowerLimitYaw = 0; + } defUpperLimitYaw = hasUpperLimitYaw; if (defUpperLimitYaw) @@ -82,7 +84,9 @@ void StepKinematics_SphericalPairWithPinAndRange::Init( myUpperLimitYaw = theUpperLimitYaw; } else + { myUpperLimitYaw = 0; + } defLowerLimitRoll = hasLowerLimitRoll; if (defLowerLimitRoll) @@ -90,7 +94,9 @@ void StepKinematics_SphericalPairWithPinAndRange::Init( myLowerLimitRoll = theLowerLimitRoll; } else + { myLowerLimitRoll = 0; + } defUpperLimitRoll = hasUpperLimitRoll; if (defUpperLimitRoll) @@ -98,7 +104,9 @@ void StepKinematics_SphericalPairWithPinAndRange::Init( myUpperLimitRoll = theUpperLimitRoll; } else + { myUpperLimitRoll = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithRange.cxx index f0a0afc950..eb0ffd56a5 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SphericalPairWithRange.cxx @@ -79,7 +79,9 @@ void StepKinematics_SphericalPairWithRange::Init( myLowerLimitYaw = theLowerLimitYaw; } else + { myLowerLimitYaw = 0; + } defUpperLimitYaw = hasUpperLimitYaw; if (defUpperLimitYaw) @@ -87,7 +89,9 @@ void StepKinematics_SphericalPairWithRange::Init( myUpperLimitYaw = theUpperLimitYaw; } else + { myUpperLimitYaw = 0; + } defLowerLimitPitch = hasLowerLimitPitch; if (defLowerLimitPitch) @@ -95,7 +99,9 @@ void StepKinematics_SphericalPairWithRange::Init( myLowerLimitPitch = theLowerLimitPitch; } else + { myLowerLimitPitch = 0; + } defUpperLimitPitch = hasUpperLimitPitch; if (defUpperLimitPitch) @@ -103,7 +109,9 @@ void StepKinematics_SphericalPairWithRange::Init( myUpperLimitPitch = theUpperLimitPitch; } else + { myUpperLimitPitch = 0; + } defLowerLimitRoll = hasLowerLimitRoll; if (defLowerLimitRoll) @@ -111,7 +119,9 @@ void StepKinematics_SphericalPairWithRange::Init( myLowerLimitRoll = theLowerLimitRoll; } else + { myLowerLimitRoll = 0; + } defUpperLimitRoll = hasUpperLimitRoll; if (defUpperLimitRoll) @@ -119,7 +129,9 @@ void StepKinematics_SphericalPairWithRange::Init( myUpperLimitRoll = theUpperLimitRoll; } else + { myUpperLimitRoll = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SurfacePairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SurfacePairWithRange.cxx index 866c3a1772..4e44c09e64 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SurfacePairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_SurfacePairWithRange.cxx @@ -67,7 +67,9 @@ void StepKinematics_SurfacePairWithRange::Init( myLowerLimitActualRotation = theLowerLimitActualRotation; } else + { myLowerLimitActualRotation = 0; + } defUpperLimitActualRotation = hasUpperLimitActualRotation; if (defUpperLimitActualRotation) @@ -75,7 +77,9 @@ void StepKinematics_SurfacePairWithRange::Init( myUpperLimitActualRotation = theUpperLimitActualRotation; } else + { myUpperLimitActualRotation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPair.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPair.cxx index 3af19c95e9..c02413c2e8 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPair.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPair.cxx @@ -64,7 +64,9 @@ void StepKinematics_UniversalPair::Init( myInputSkewAngle = theInputSkewAngle; } else + { myInputSkewAngle = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPairWithRange.cxx b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPairWithRange.cxx index abedcec9f6..094adb11a4 100644 --- a/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPairWithRange.cxx +++ b/src/DataExchange/TKDESTEP/StepKinematics/StepKinematics_UniversalPairWithRange.cxx @@ -77,7 +77,9 @@ void StepKinematics_UniversalPairWithRange::Init( myLowerLimitFirstRotation = theLowerLimitFirstRotation; } else + { myLowerLimitFirstRotation = 0; + } defUpperLimitFirstRotation = hasUpperLimitFirstRotation; if (defUpperLimitFirstRotation) @@ -85,7 +87,9 @@ void StepKinematics_UniversalPairWithRange::Init( myUpperLimitFirstRotation = theUpperLimitFirstRotation; } else + { myUpperLimitFirstRotation = 0; + } defLowerLimitSecondRotation = hasLowerLimitSecondRotation; if (defLowerLimitSecondRotation) @@ -93,7 +97,9 @@ void StepKinematics_UniversalPairWithRange::Init( myLowerLimitSecondRotation = theLowerLimitSecondRotation; } else + { myLowerLimitSecondRotation = 0; + } defUpperLimitSecondRotation = hasUpperLimitSecondRotation; if (defUpperLimitSecondRotation) @@ -101,7 +107,9 @@ void StepKinematics_UniversalPairWithRange::Init( myUpperLimitSecondRotation = theUpperLimitSecondRotation; } else + { myUpperLimitSecondRotation = 0; + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_AssemblyComponentUsage.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_AssemblyComponentUsage.cxx index b80635817f..2aae4dcd4a 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_AssemblyComponentUsage.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_AssemblyComponentUsage.cxx @@ -55,7 +55,9 @@ void StepRepr_AssemblyComponentUsage::Init( theReferenceDesignator = aReferenceDesignator; } else + { theReferenceDesignator.Nullify(); + } } //================================================================================================= @@ -85,7 +87,9 @@ void StepRepr_AssemblyComponentUsage::Init( theReferenceDesignator = aReferenceDesignator; } else + { theReferenceDesignator.Nullify(); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_CharacterizedDefinition.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_CharacterizedDefinition.cxx index 1ce1d2ef93..db09291701 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_CharacterizedDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_CharacterizedDefinition.cxx @@ -34,21 +34,37 @@ StepRepr_CharacterizedDefinition::StepRepr_CharacterizedDefinition() = default; int StepRepr_CharacterizedDefinition::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_CharacterizedObject))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionRelationship))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 6; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_DocumentFile))) + { return 7; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationDesignItem.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationDesignItem.cxx index 311b4bc682..15183493ef 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationDesignItem.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationDesignItem.cxx @@ -30,11 +30,17 @@ StepRepr_ConfigurationDesignItem::StepRepr_ConfigurationDesignItem() = default; int StepRepr_ConfigurationDesignItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationItem.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationItem.cxx index 1c9f435959..1c7e9b70db 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ConfigurationItem.cxx @@ -51,7 +51,9 @@ void StepRepr_ConfigurationItem::Init(const occ::handle StepRepr_GlobalUncertaintyAssi int StepRepr_GlobalUncertaintyAssignedContext::NbUncertainty() const { if (uncertainty.IsNull()) + { return 0; + } return uncertainty->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_GlobalUnitAssignedContext.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_GlobalUnitAssignedContext.cxx index 5bb38e4d2b..88d9e9dfdc 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_GlobalUnitAssignedContext.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_GlobalUnitAssignedContext.cxx @@ -49,6 +49,8 @@ occ::handle StepRepr_GlobalUnitAssignedContext::UnitsValue( int StepRepr_GlobalUnitAssignedContext::NbUnits() const { if (units.IsNull()) + { return 0; + } return units->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ProductConcept.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ProductConcept.cxx index b7bb4a372c..5f3ed99dff 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ProductConcept.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ProductConcept.cxx @@ -49,7 +49,9 @@ void StepRepr_ProductConcept::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theMarketContext = aMarketContext; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_PropertyDefinition.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_PropertyDefinition.cxx index 45e1efbaf0..d491dffdf0 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_PropertyDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_PropertyDefinition.cxx @@ -43,7 +43,9 @@ void StepRepr_PropertyDefinition::Init(const occ::handle StepRepr_Representation::ItemsValue(con int StepRepr_Representation::NbItems() const { if (items.IsNull()) + { return 0; + } return items->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentationOrRepresentationReference.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentationOrRepresentationReference.cxx index 6d35f4a174..578c7c7981 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentationOrRepresentationReference.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentationOrRepresentationReference.cxx @@ -29,11 +29,17 @@ int StepRepr_RepresentationOrRepresentationReference::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationReference))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentedDefinition.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentedDefinition.cxx index 75fb28fa6a..f778c46f12 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentedDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_RepresentedDefinition.cxx @@ -32,17 +32,29 @@ StepRepr_RepresentedDefinition::StepRepr_RepresentedDefinition() = default; int StepRepr_RepresentedDefinition::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepBasic_GeneralProperty))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinitionRelationship))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 5; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeAspectRelationship.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeAspectRelationship.cxx index 1e484c45cf..155ccde3b6 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeAspectRelationship.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeAspectRelationship.cxx @@ -46,7 +46,9 @@ void StepRepr_ShapeAspectRelationship::Init( theDescription = aDescription; } else + { theDescription.Nullify(); + } theRelatingShapeAspect = aRelatingShapeAspect; diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeDefinition.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeDefinition.cxx index 2473bb6bb5..7ca0b91c82 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_ShapeDefinition.cxx @@ -23,13 +23,21 @@ StepRepr_ShapeDefinition::StepRepr_ShapeDefinition() = default; int StepRepr_ShapeDefinition::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_Transformation.cxx b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_Transformation.cxx index fa79adc23a..a76a4da03b 100644 --- a/src/DataExchange/TKDESTEP/StepRepr/StepRepr_Transformation.cxx +++ b/src/DataExchange/TKDESTEP/StepRepr/StepRepr_Transformation.cxx @@ -23,13 +23,21 @@ StepRepr_Transformation::StepRepr_Transformation() = default; int StepRepr_Transformation::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_ItemDefinedTransformation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_FunctionallyDefinedTransformation))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_Activator.cxx b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_Activator.cxx index de011dcbe0..1584c7bf18 100644 --- a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_Activator.cxx +++ b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_Activator.cxx @@ -59,60 +59,70 @@ IFSelect_ReturnStatus StepSelect_Activator::Do(const int case 1: { // **** StepSchema if (argc < 2) { - std::cout << "Identify an entity" << std::endl; + std::cout << "Identify an entity" << '\n'; return IFSelect_RetError; } int num = pilot->Number(arg1); if (num <= 0) { - std::cout << "Not an entity : " << arg2 << std::endl; + std::cout << "Not an entity : " << arg2 << '\n'; return IFSelect_RetError; } occ::handle ent = pilot->Session()->StartingEntity(num); DeclareAndCast(StepData_UndefinedEntity, und, ent); if (!und.IsNull()) { - std::cout << "Entity " << arg2 << " : No Binding known" << std::endl; + std::cout << "Entity " << arg2 << " : No Binding known" << '\n'; return IFSelect_RetVoid; } DeclareAndCast(StepData_Simple, sim, ent); if (!sim.IsNull()) { - std::cout << "Entity " << arg2 << " : Late Binding" << std::endl; - std::cout << "Simple Type : " << sim->StepType() << std::endl; + std::cout << "Entity " << arg2 << " : Late Binding" << '\n'; + std::cout << "Simple Type : " << sim->StepType() << '\n'; return IFSelect_RetVoid; } DeclareAndCast(StepData_Plex, plx, ent); if (!plx.IsNull()) { - std::cout << "Entity " << arg2 << " : Late Binding" << std::endl; - std::cout << "Complex Type" << std::endl; + std::cout << "Entity " << arg2 << " : Late Binding" << '\n'; + std::cout << "Complex Type" << '\n'; } // reste Early Binding - std::cout << "Entity " << arg2 << " : Early Binding" << std::endl; - std::cout << "CDL Type : " << ent->DynamicType()->Name() << std::endl; + std::cout << "Entity " << arg2 << " : Early Binding" << '\n'; + std::cout << "CDL Type : " << ent->DynamicType()->Name() << '\n'; return IFSelect_RetVoid; } case 40: { // **** FloatFormat char prem = ' '; if (argc < 2) + { prem = '?'; + } else if (argc == 5) { - std::cout << "floatformat tout court donne les formes admises" << std::endl; + std::cout << "floatformat tout court donne les formes admises" << '\n'; return IFSelect_RetError; } else + { prem = arg1[0]; + } bool zerosup = false; int digits = 0; if (prem == 'N' || prem == 'n') + { zerosup = false; + } else if (prem == 'Z' || prem == 'z') + { zerosup = true; + } else if (prem >= 48 && prem <= 57) + { digits = atoi(arg1); + } else { std::cout << "floatformat digits, digits=nb de chiffres signifiants, ou\n" @@ -132,23 +142,31 @@ IFSelect_ReturnStatus StepSelect_Activator::Do(const int Rmax = Atof(pilot->Word(5).ToCString()); if (Rmin <= 0 || Rmax <= 0) { - std::cout << "intervalle : donner reels > 0" << std::endl; + std::cout << "intervalle : donner reels > 0" << '\n'; return IFSelect_RetError; } } occ::handle fm = new StepSelect_FloatFormat; if (argc == 2) + { fm->SetDefault(digits); + } else { fm->SetZeroSuppress(zerosup); fm->SetFormat(arg2); if (argc == 4) + { fm->SetFormatForRange(pilot->Word(3).ToCString()); + } else if (argc >= 6) + { fm->SetFormatForRange(pilot->Word(3).ToCString(), Rmin, Rmax); + } else + { fm->SetFormatForRange(""); + } } return pilot->RecordItem(fm); } diff --git a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_FloatFormat.cxx b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_FloatFormat.cxx index 75bd2ac42c..1fe2c188aa 100644 --- a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_FloatFormat.cxx +++ b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_FloatFormat.cxx @@ -95,14 +95,18 @@ void StepSelect_FloatFormat::Perform(IFSelect_ContextWrite& /*ctx*/, writer.FloatWriter().SetFormat(themainform.ToCString()); writer.FloatWriter().SetZeroSuppress(thezerosup); if (theformrange.Length() > 0) + { writer.FloatWriter().SetFormatForRange(theformrange.ToCString(), therangemin, therangemax); + } } TCollection_AsciiString StepSelect_FloatFormat::Label() const { TCollection_AsciiString lab("Float Format "); if (thezerosup) + { lab.AssignCat(" ZeroSuppress"); + } lab.AssignCat(themainform); if (theformrange.Length() > 0) { diff --git a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_StepType.cxx b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_StepType.cxx index b50f2992aa..346c2575f3 100644 --- a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_StepType.cxx +++ b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_StepType.cxx @@ -34,7 +34,9 @@ void StepSelect_StepType::SetProtocol(const occ::handle& pro { DeclareAndCast(StepData_Protocol, newproto, proto); if (newproto.IsNull()) + { throw Interface_InterfaceError("StepSelect_StepType"); + } theproto = newproto; thelib.Clear(); thelib.AddProtocol(theproto); @@ -62,7 +64,9 @@ const char* StepSelect_StepType::Value(const occ::handle& // Handle simple (non-complex) type - return direct reference from module if (!aModule->IsComplex(aCN)) + { return aModule->StepType(aCN).data(); + } // Handle complex type from module NCollection_Sequence aList; @@ -79,7 +83,9 @@ const char* StepSelect_StepType::Value(const occ::handle& for (int i = 1; i <= aNb; i++) { if (i > 1) + { theLastValue += ","; + } theLastValue += aList.Value(i); } theLastValue += ")"; @@ -96,7 +102,9 @@ const char* StepSelect_StepType::Value(const occ::handle& } if (!anUnd->IsComplex()) + { return anUnd->StepType(); // Direct return from entity's internal storage + } // Build complex type from undefined entity theLastValue = "("; @@ -104,7 +112,9 @@ const char* StepSelect_StepType::Value(const occ::handle& while (!anUnd.IsNull()) { if (!isFirst) + { theLastValue += ","; + } theLastValue += anUnd->StepType(); anUnd = anUnd->Next(); isFirst = false; diff --git a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_WorkLibrary.cxx b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_WorkLibrary.cxx index 3adf84ae5f..2f82147471 100644 --- a/src/DataExchange/TKDESTEP/StepSelect/StepSelect_WorkLibrary.cxx +++ b/src/DataExchange/TKDESTEP/StepSelect/StepSelect_WorkLibrary.cxx @@ -57,7 +57,9 @@ int StepSelect_WorkLibrary::ReadFile(const char* const name { DeclareAndCast(StepData_Protocol, stepro, protocol); if (stepro.IsNull()) + { return 1; + } int aStatus = StepFile_Read(name, nullptr, occ::down_cast(model), stepro); return aStatus; } @@ -69,7 +71,9 @@ int StepSelect_WorkLibrary::ReadStream(const char* const th { DeclareAndCast(StepData_Protocol, stepro, protocol); if (stepro.IsNull()) + { return 1; + } int aStatus = StepFile_Read(theName, &theIStream, occ::down_cast(model), stepro); return aStatus; @@ -82,7 +86,9 @@ bool StepSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const DeclareAndCast(StepData_StepModel, stepmodel, ctx.Model()); DeclareAndCast(StepData_Protocol, stepro, ctx.Protocol()); if (stepmodel.IsNull() || stepro.IsNull()) + { return false; + } const occ::handle& aFileSystem = OSD_FileSystem::DefaultFileSystem(); std::shared_ptr aStream = @@ -91,7 +97,7 @@ bool StepSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const if (aStream.get() == nullptr) { ctx.CCheck(0)->AddFail("Step File could not be created"); - sout << " Step File could not be created : " << ctx.FileName() << std::endl; + sout << " Step File could not be created : " << ctx.FileName() << '\n'; return false; } sout << " Step File Name : " << ctx.FileName(); @@ -105,13 +111,19 @@ bool StepSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const ctx.SetModifier(numod); DeclareAndCast(StepSelect_FileModifier, filemod, ctx.FileModifier()); if (!filemod.IsNull()) + { filemod->Perform(ctx, SW); + } // (impressions de mise au point) sout << " .. FileMod." << numod << filemod->Label(); if (ctx.IsForAll()) + { sout << " (all model)"; + } else + { sout << " (" << ctx.NbEntities() << " entities)"; + } // sout << std::flush; } @@ -119,17 +131,21 @@ bool StepSelect_WorkLibrary::WriteFile(IFSelect_ContextWrite& ctx) const SW.SendModel(stepro); Interface_CheckIterator chl = SW.CheckList(); for (chl.Start(); chl.More(); chl.Next()) + { ctx.CCheck(chl.Number())->GetMessages(chl.Value()); + } sout << " Write "; bool isGood = SW.Print(*aStream); - sout << " Done" << std::endl; + sout << " Done" << '\n'; errno = 0; aStream->flush(); isGood = aStream->good() && isGood && !errno; aStream.reset(); if (errno) - sout << strerror(errno) << std::endl; + { + sout << strerror(errno) << '\n'; + } return isGood; } @@ -139,7 +155,9 @@ bool StepSelect_WorkLibrary::CopyModel(const occ::handleNumber(entity); if (nument <= 0 || nument > model->NbEntities()) + { return; + } bool iserr = model->IsRedefinedContent(nument); occ::handle ent, con; ent = entity; S << " --- (STEP) Entity "; model->Print(entity, S); if (iserr) + { con = model->ReportEntity(nument)->Content(); + } if (entity.IsNull()) { - S << " Null" << std::endl; + S << " Null" << '\n'; return; } // On attaque le dump : d abord cas de l Erreur - S << " Type cdl : " << entity->DynamicType()->Name() << std::endl; + S << " Type cdl : " << entity->DynamicType()->Name() << '\n'; if (iserr) - S << " *** NOT WELL LOADED : CONTENT FROM FILE ***" << std::endl; + { + S << " *** NOT WELL LOADED : CONTENT FROM FILE ***" << '\n'; + } else if (model->IsUnknownEntity(nument)) - S << " *** UNKNOWN TYPE ***" << std::endl; + { + S << " *** UNKNOWN TYPE ***" << '\n'; + } StepData_StepDumper dump(GetCasted(StepData_StepModel, model), GetCasted(StepData_Protocol, protocol), diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_BrepWithVoids.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_BrepWithVoids.cxx index f2767795b1..d1ff2cf7a6 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_BrepWithVoids.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_BrepWithVoids.cxx @@ -51,6 +51,8 @@ occ::handle StepShape_BrepWithVoids::VoidsValue(c int StepShape_BrepWithVoids::NbVoids() const { if (voids.IsNull()) + { return 0; + } return voids->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_ConnectedFaceSet.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_ConnectedFaceSet.cxx index 2e102831f6..054c1b9326 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_ConnectedFaceSet.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_ConnectedFaceSet.cxx @@ -49,6 +49,8 @@ occ::handle StepShape_ConnectedFaceSet::CfsFacesValue(const int int StepShape_ConnectedFaceSet::NbCfsFaces() const { if (cfsFaces.IsNull()) + { return 0; + } return cfsFaces->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_CsgPrimitive.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_CsgPrimitive.cxx index b082282143..fe630b050f 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_CsgPrimitive.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_CsgPrimitive.cxx @@ -26,19 +26,33 @@ StepShape_CsgPrimitive::StepShape_CsgPrimitive() = default; int StepShape_CsgPrimitive::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Sphere))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Block))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepShape_RightAngularWedge))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Torus))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepShape_RightCircularCone))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepShape_RightCircularCylinder))) + { return 6; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_DimensionalCharacteristic.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_DimensionalCharacteristic.cxx index d1f0955470..5bd785d8e0 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_DimensionalCharacteristic.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_DimensionalCharacteristic.cxx @@ -29,11 +29,17 @@ StepShape_DimensionalCharacteristic::StepShape_DimensionalCharacteristic() = def int StepShape_DimensionalCharacteristic::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_EdgeLoop.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_EdgeLoop.cxx index 823fe801f9..f0839ef45c 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_EdgeLoop.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_EdgeLoop.cxx @@ -49,6 +49,8 @@ occ::handle StepShape_EdgeLoop::EdgeListValue(const int int StepShape_EdgeLoop::NbEdgeList() const { if (edgeList.IsNull()) + { return 0; + } return edgeList->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_Face.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_Face.cxx index 1abfde5782..d71621f9c1 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_Face.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_Face.cxx @@ -48,6 +48,8 @@ occ::handle StepShape_Face::BoundsValue(const int num) cons int StepShape_Face::NbBounds() const { if (bounds.IsNull()) + { return 0; + } return bounds->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSet.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSet.cxx index e24b96ac97..cb65d77d77 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSet.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSet.cxx @@ -49,6 +49,8 @@ StepShape_GeometricSetSelect StepShape_GeometricSet::ElementsValue(const int num int StepShape_GeometricSet::NbElements() const { if (elements.IsNull()) + { return 0; + } return elements->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSetSelect.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSetSelect.cxx index d68c5d2ed0..6dbd3fc6d3 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSetSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_GeometricSetSelect.cxx @@ -24,15 +24,25 @@ StepShape_GeometricSetSelect::StepShape_GeometricSetSelect() = default; int StepShape_GeometricSetSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Point))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Curve))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Surface))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedClosedShell.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedClosedShell.cxx index d54bb40d4d..fbfd3420ac 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedClosedShell.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedClosedShell.cxx @@ -58,7 +58,7 @@ void StepShape_OrientedClosedShell::SetCfsFaces( { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle>> StepShape_OrientedClosedShell:: diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedEdge.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedEdge.cxx index f54e7aaf6a..821f745312 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedEdge.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedEdge.cxx @@ -58,7 +58,7 @@ void StepShape_OrientedEdge::SetEdgeStart(const occ::handle& / { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle StepShape_OrientedEdge::EdgeStart() const @@ -66,7 +66,9 @@ occ::handle StepShape_OrientedEdge::EdgeStart() const // WARNING : the field is redefined. // method body is not yet automatically wrote if (edgeElement.IsNull()) + { return nullptr; + } if (Orientation()) { return edgeElement->EdgeStart(); @@ -81,7 +83,7 @@ void StepShape_OrientedEdge::SetEdgeEnd(const occ::handle& /*a { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle StepShape_OrientedEdge::EdgeEnd() const @@ -89,7 +91,9 @@ occ::handle StepShape_OrientedEdge::EdgeEnd() const // WARNING : the field is redefined. // method body is not yet automatically wrote if (edgeElement.IsNull()) + { return nullptr; + } if (Orientation()) { return edgeElement->EdgeEnd(); diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedFace.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedFace.cxx index 1d2c93c376..d4afe5cd6a 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedFace.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedFace.cxx @@ -56,7 +56,7 @@ void StepShape_OrientedFace::SetBounds( { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle>> StepShape_OrientedFace::Bounds() diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedOpenShell.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedOpenShell.cxx index 71318d4460..3fe718fc65 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedOpenShell.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedOpenShell.cxx @@ -57,7 +57,7 @@ void StepShape_OrientedOpenShell::SetCfsFaces( { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle>> StepShape_OrientedOpenShell:: diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedPath.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedPath.cxx index 8c127c09e4..5ea7bd3922 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedPath.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_OrientedPath.cxx @@ -58,7 +58,7 @@ void StepShape_OrientedPath::SetEdgeList( { // WARNING : the field is redefined. // field set up forbidden. - std::cout << "Field is redefined, SetUp Forbidden" << std::endl; + std::cout << "Field is redefined, SetUp Forbidden" << '\n'; } occ::handle>> StepShape_OrientedPath:: @@ -67,7 +67,9 @@ occ::handle>> StepShape_ // WARNING : the field is redefined. // method body is not yet automatically wrote if (orientation) + { return pathElement->EdgeList(); + } else { // on devrait creer un nouveau tableau d'oriented edge classe dans @@ -81,7 +83,9 @@ occ::handle StepShape_OrientedPath::EdgeListValue(const // WARNING : the field is redefined. // method body is not yet automatically wrote if (orientation) + { return pathElement->EdgeListValue(num); + } else { int nbEdges = pathElement->NbEdgeList(); diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_Path.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_Path.cxx index 82a859cf99..24bf5b1ab8 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_Path.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_Path.cxx @@ -48,6 +48,8 @@ occ::handle StepShape_Path::EdgeListValue(const int num) int StepShape_Path::NbEdgeList() const { if (edgeList.IsNull()) + { return 0; + } return edgeList->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_PolyLoop.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_PolyLoop.cxx index 40706241bb..5f9d36b389 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_PolyLoop.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_PolyLoop.cxx @@ -48,6 +48,8 @@ occ::handle StepShape_PolyLoop::PolygonValue(const int int StepShape_PolyLoop::NbPolygon() const { if (polygon.IsNull()) + { return 0; + } return polygon->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_ReversibleTopologyItem.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_ReversibleTopologyItem.cxx index 64ba313400..03d85b5773 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_ReversibleTopologyItem.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_ReversibleTopologyItem.cxx @@ -25,19 +25,33 @@ StepShape_ReversibleTopologyItem::StepShape_ReversibleTopologyItem() = default; int StepShape_ReversibleTopologyItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Edge))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Path))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Face))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepShape_FaceBound))) + { return 4; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ClosedShell))) + { return 5; + } if (ent->IsKind(STANDARD_TYPE(StepShape_OpenShell))) + { return 6; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_ShapeDimensionRepresentationItem.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_ShapeDimensionRepresentationItem.cxx index edf2bf47a0..92285284ca 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_ShapeDimensionRepresentationItem.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_ShapeDimensionRepresentationItem.cxx @@ -30,15 +30,25 @@ int StepShape_ShapeDimensionRepresentationItem::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_CompoundRepresentationItem))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Placement))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_Shell.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_Shell.cxx index 5b49801c7e..8d79a1ae3e 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_Shell.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_Shell.cxx @@ -22,11 +22,17 @@ StepShape_Shell::StepShape_Shell() = default; int StepShape_Shell::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_OpenShell))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ClosedShell))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_SurfaceModel.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_SurfaceModel.cxx index c70d02e92a..7d29d3d2b5 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_SurfaceModel.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_SurfaceModel.cxx @@ -22,9 +22,13 @@ StepShape_SurfaceModel::StepShape_SurfaceModel() = default; int StepShape_SurfaceModel::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) + { return 1; + } // if (ent->IsKind(STANDARD_TYPE(StepShape_FaceBasedSurfaceModel))) return 2; return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_ToleranceMethodDefinition.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_ToleranceMethodDefinition.cxx index dc2824489b..6b20f4335d 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_ToleranceMethodDefinition.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_ToleranceMethodDefinition.cxx @@ -21,11 +21,17 @@ StepShape_ToleranceMethodDefinition::StepShape_ToleranceMethodDefinition() = def int StepShape_ToleranceMethodDefinition::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ToleranceValue))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_LimitsAndFits))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepShape/StepShape_ValueQualifier.cxx b/src/DataExchange/TKDESTEP/StepShape/StepShape_ValueQualifier.cxx index 0521e3ff91..4bb5653138 100644 --- a/src/DataExchange/TKDESTEP/StepShape/StepShape_ValueQualifier.cxx +++ b/src/DataExchange/TKDESTEP/StepShape/StepShape_ValueQualifier.cxx @@ -22,13 +22,21 @@ StepShape_ValueQualifier::StepShape_ValueQualifier() = default; int StepShape_ValueQualifier::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_PrecisionQualifier))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_TypeQualifier))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepShape_ValueFormatTypeQualifier))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepToGeom/StepToGeom.cxx b/src/DataExchange/TKDESTEP/StepToGeom/StepToGeom.cxx index 32f2401660..9941fa90fa 100644 --- a/src/DataExchange/TKDESTEP/StepToGeom/StepToGeom.cxx +++ b/src/DataExchange/TKDESTEP/StepToGeom/StepToGeom.cxx @@ -153,7 +153,9 @@ occ::handle StepToGeom::MakeAxis1Placement( { occ::handle D1 = MakeDirection(SA->Axis()); if (!D1.IsNull()) + { D = D1->Dir(); + } } return new Geom_Axis1Placement(P->Pnt(), D); } @@ -180,7 +182,9 @@ occ::handle StepToGeom::MakeAxis2Placement( { occ::handle D = MakeDirection(SA->Axis()); if (!D.IsNull()) + { Ngp = D->Dir(); + } } gp_Ax2 gpAx2; @@ -199,7 +203,9 @@ occ::handle StepToGeom::MakeAxis2Placement( } } if (isDefaultDirectionUsed) + { gpAx2 = gp_Ax2(Pgp, Ngp); + } return new Geom_Axis2Placement(gpAx2); } @@ -251,7 +257,9 @@ occ::handle StepToGeom::MakeAxisPlacement( { occ::handle Vx = MakeDirection2d(SA->RefDirection()); if (!Vx.IsNull()) + { Vxgp = Vx->Dir2d(); + } } return new Geom2d_AxisPlacement(P->Pnt2d(), Vxgp); @@ -289,7 +297,9 @@ occ::handle StepToGeom::MakeBoundedCurve( const occ::handle BzC = occ::down_cast(SC); int aDegree = BzC->Degree(); if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree()) + { return nullptr; + } const occ::handle BSPL = new StepGeom_BSplineCurveWithKnots; BSPL->SetDegree(aDegree); BSPL->SetControlPointsList(BzC->ControlPointsList()); @@ -314,7 +324,9 @@ occ::handle StepToGeom::MakeBoundedCurve( const occ::handle UC = occ::down_cast(SC); int aDegree = UC->Degree(); if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree()) + { return nullptr; + } const occ::handle BSPL = new StepGeom_BSplineCurveWithKnots; BSPL->SetDegree(aDegree); BSPL->SetControlPointsList(UC->ControlPointsList()); @@ -343,7 +355,9 @@ occ::handle StepToGeom::MakeBoundedCurve( occ::down_cast(SC); int aDegree = QUC->Degree(); if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree()) + { return nullptr; + } const occ::handle BSPL = new StepGeom_BSplineCurveWithKnots; BSPL->SetDegree(aDegree); BSPL->SetControlPointsList(QUC->ControlPointsList()); @@ -374,7 +388,9 @@ occ::handle StepToGeom::MakeBoundedCurve( occ::down_cast(SC); int aDegree = RUC->Degree(); if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree()) + { return nullptr; + } const occ::handle RBSPL = new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve; @@ -409,7 +425,9 @@ occ::handle StepToGeom::MakeBoundedCurve( occ::down_cast(SC); int aDegree = RQUC->Degree(); if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree()) + { return nullptr; + } const occ::handle RBSPL = new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve; @@ -750,8 +768,10 @@ occ::handle MakeBSplineCurveCommon( aBSplineCurveWithKnots = aBSplineCurveWithKnotsAndRationalBSplineCurve->BSplineCurveWithKnots(); } else + { aBSplineCurveWithKnots = occ::down_cast(theStepGeom_BSplineCurve); + } const int aDegree = aBSplineCurveWithKnots->Degree(); const int NbPoles = aBSplineCurveWithKnots->NbControlPointsList(); @@ -808,9 +828,13 @@ occ::handle MakeBSplineCurveCommon( if (aCurrentVal > aDegree + 1) { if (i == 1) + { aFirstMuultypisityDifference = aCurrentVal - aDegree - 1; + } if (i == NbUniqueKnots) + { aLastMuultypisityDifference = aCurrentVal - aDegree - 1; + } #ifdef OCCT_DEBUG std::cout << "\nWrong multiplicity " << aCurrentVal << " on " << i << " knot!" << "\nChanged to " << aDegree + 1 << std::endl; @@ -877,7 +901,9 @@ occ::handle MakeBSplineCurveCommon( aBSplineCurveWithKnotsAndRationalBSplineCurve->WeightsData(); NCollection_Array1 aUniqueWeights(1, NbPoles - aSummaryMuultypisityDifference); for (int i = 1 + aFirstMuultypisityDifference; i <= NbPoles - aLastMuultypisityDifference; ++i) + { aUniqueWeights.SetValue(i - aFirstMuultypisityDifference, aWeights->Value(i)); + } aBSplineCurve = new TBSplineCurve(Poles, aUniqueWeights, aUniqueKnots, @@ -955,7 +981,9 @@ occ::handle StepToGeom::MakeBSplineSurface( BS = BSR->BSplineSurfaceWithKnots(); } else + { BS = occ::down_cast(SS); + } const int UDeg = BS->UDegree(); const int VDeg = BS->VDegree(); @@ -971,9 +999,13 @@ occ::handle StepToGeom::MakeBSplineSurface( occ::handle P = MakeCartesianPoint(aControlPointsList->Value(i, j), theLocalFactors); if (!P.IsNull()) + { Poles.SetValue(i, j, P->Pnt()); + } else + { return nullptr; + } } } const int NUKnots = BS->NbUMultiplicities(); @@ -1120,6 +1152,7 @@ occ::handle StepToGeom::MakeBSplineSurface( shouldBeVPeriodic); } else + { CS = new Geom_BSplineSurface(Poles, KUn, KVn, @@ -1129,6 +1162,7 @@ occ::handle StepToGeom::MakeBSplineSurface( VDeg, shouldBeUPeriodic, shouldBeVPeriodic); + } return CS; } @@ -1623,7 +1657,9 @@ occ::handle StepToGeom::MakeLine(const occ::handle& SC if (!D.IsNull()) { if (D->Vec().SquareMagnitude() < Precision::Confusion() * Precision::Confusion()) + { return nullptr; + } const gp_Dir V(D->Vec()); return new Geom_Line(P->Pnt(), V); } @@ -1716,7 +1752,9 @@ occ::handle StepToGeom::MakePolyline(const occ::handle(); + } const int nbp = SPL->NbPoints(); if (nbp > 1) @@ -1729,9 +1767,13 @@ occ::handle StepToGeom::MakePolyline(const occ::handle P = MakeCartesianPoint(SPL->PointsValue(i), theLocalFactors); if (!P.IsNull()) + { Poles.SetValue(i, P->Pnt()); + } else + { return nullptr; + } Knots.SetValue(i, double(i - 1)); Mults.SetValue(i, 1); } @@ -1750,7 +1792,9 @@ occ::handle StepToGeom::MakePolyline2d( const StepData_Factors& theLocalFactors) { if (SPL.IsNull()) + { return occ::handle(); + } const int nbp = SPL->NbPoints(); if (nbp > 1) @@ -1764,9 +1808,13 @@ occ::handle StepToGeom::MakePolyline2d( occ::handle P = MakeCartesianPoint2d(SPL->PointsValue(i), theLocalFactors); if (!P.IsNull()) + { Poles.SetValue(i, P->Pnt2d()); + } else + { return nullptr; + } Knots.SetValue(i, double(i - 1)); Mults.SetValue(i, 1); } @@ -1878,7 +1926,9 @@ occ::handle StepToGeom::MakeSurface(const occ::handle S1 = occ::down_cast(SS); if (S1->Position().IsNull()) + { return occ::handle(); + } return MakeElementarySurface(S1, theLocalFactors); } @@ -1970,7 +2020,9 @@ occ::handle StepToGeom::MakeSurfaceOfLinearExtrus const gp_Dir D(V->Vec()); occ::handle aLine = occ::down_cast(C); if (!aLine.IsNull() && aLine->Lin().Direction().IsParallel(D, Precision::Angular())) + { return occ::handle(); + } return new Geom_SurfaceOfLinearExtrusion(C, D); } } @@ -2084,7 +2136,9 @@ bool StepToGeom::MakeTransformation2d( { occ::handle D = MakeDirection2d(A); if (!D.IsNull()) + { D1 = D->Dir2d(); + } } const gp_Ax2d result(CP->Pnt2d(), D1); CT.SetTransformation(result); @@ -2114,7 +2168,9 @@ bool StepToGeom::MakeTransformation3d( { occ::handle D = MakeDirection(A1); if (!D.IsNull()) + { D1 = D->Dir(); + } } gp_Dir D2(gp_Dir::D::Y); @@ -2123,7 +2179,9 @@ bool StepToGeom::MakeTransformation3d( { occ::handle D = MakeDirection(A2); if (!D.IsNull()) + { D2 = D->Dir(); + } } bool isDefaultDirectionUsed = true; @@ -2139,7 +2197,9 @@ bool StepToGeom::MakeTransformation3d( } } if (isDefaultDirectionUsed) + { D3 = D1.Crossed(D2); + } const gp_Ax3 result(Pgp, D3, D1); CT.SetTransformation(result); @@ -2267,7 +2327,9 @@ occ::handle StepToGeom::MakeTrimmedCurve( const occ::handle theSTEPCurve = SC->BasisCurve(); occ::handle theCurve = MakeCurve(theSTEPCurve, theLocalFactors); if (theCurve.IsNull()) + { return occ::handle(); + } const occ::handle>& theTrimSel1 = SC->Trim1(); const occ::handle>& theTrimSel2 = SC->Trim2(); @@ -2325,7 +2387,9 @@ occ::handle StepToGeom::MakeTrimmedCurve( //: p3 abv 23 Feb 99: shift on pi/2 on ellipse with R1 < R2 const occ::handle ellipse = occ::down_cast(theSTEPCurve); if (!ellipse.IsNull() && ellipse->SemiAxis1() - ellipse->SemiAxis2() < 0.) + { shift = 0.5 * M_PI; + } // skl 04.02.2002 for OCC133: we can not make TrimmedCurve if // there is no X-direction in StepGeom_Axis2Placement3d @@ -2342,13 +2406,19 @@ occ::handle StepToGeom::MakeTrimmedCurve( ////gka 18.02.04 analysis for case when MasterRep = .Unspecified // and parameters are specified as CARTESIAN_POINT if (isPoint /*&& !MasterRep*/) + { MasterRep = 1; + } else { if (SC->SenseAgreement()) + { return new Geom_TrimmedCurve(theCurve, 0., 2. * M_PI, true); + } else + { return new Geom_TrimmedCurve(theCurve, 2. * M_PI, 0., false); + } } } } @@ -2371,13 +2441,21 @@ occ::handle StepToGeom::MakeTrimmedCurve( if (!theCurve->IsPeriodic()) { if (trim1 < cf) + { trim1 = cf; + } else if (trim1 > cl) + { trim1 = cl; + } if (trim2 < cf) + { trim2 = cf; + } else if (trim2 > cl) + { trim2 = cl; + } } if (std::abs(trim1 - trim2) < Precision::PConfusion()) { @@ -2406,9 +2484,13 @@ occ::handle StepToGeom::MakeTrimmedCurve( //: o6 trim1 = trim1 * fact; //: o6 trim2 = trim2 * fact; if (SC->SenseAgreement()) + { return new Geom_TrimmedCurve(theCurve, trim1, trim2, true); - else //: abv 29.09.00 PRO20362: reverse parameters in case of reversed curve + } + else + { //: abv 29.09.00 PRO20362: reverse parameters in case of reversed curve return new Geom_TrimmedCurve(theCurve, trim2, trim1, false); + } } return nullptr; } @@ -2425,7 +2507,9 @@ occ::handle StepToGeom::MakeTrimmedCurve2d( const occ::handle BasisCurve = SC->BasisCurve(); occ::handle theGeomBasis = MakeCurve2d(BasisCurve, theLocalFactors); if (theGeomBasis.IsNull()) + { return occ::handle(); + } if (theGeomBasis->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { @@ -2456,7 +2540,9 @@ occ::handle StepToGeom::MakeTrimmedCurve2d( //: p3 abv 23 Feb 99: shift on pi/2 on ellipse with R1 < R2 const occ::handle ellipse = occ::down_cast(BasisCurve); if (!ellipse.IsNull() && ellipse->SemiAxis1() - ellipse->SemiAxis2() < 0.) + { shift = 0.5 * M_PI; + } } else if (BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Parabola)) || BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Hyperbola))) @@ -2633,16 +2719,24 @@ occ::handle> StepToGeom::MakeYprRotation( if (std::abs(dx) >= Precision::Confusion()) { if (dx > 0.) + { anYPRRotation->SetValue(3, aYaw); + } else + { anYPRRotation->SetValue(3, aRoll); + } } else { if (dz > 0.) + { anYPRRotation->SetValue(1, aYaw); + } else + { anYPRRotation->SetValue(1, aRoll); + } } return anYPRRotation; } @@ -2686,9 +2780,13 @@ occ::handle> StepToGeom::MakeYprRotation( { // |aPitch| = PI/2 if (std::abs(aRotMat[0][2] - 1.) < Precision::Confusion()) + { aPitch = M_PI_2; + } else + { aPitch = -M_PI_2; + } // In this case, only the sum or difference of roll and yaw angles // is relevant and can be evaluated from the matrix. // According to IP `rectangular pitch angle' for ypr_rotation, @@ -2701,9 +2799,13 @@ occ::handle> StepToGeom::MakeYprRotation( if (aRotMat[1][1] < 0.) { if (aYaw <= 0.) + { aYaw = aYaw + M_PI; + } else + { aYaw = aYaw - M_PI; + } } } else @@ -2714,9 +2816,13 @@ occ::handle> StepToGeom::MakeYprRotation( if (aRotMat[0][0] < 0.) { if (aYaw < 0. || std::abs(aYaw) < Precision::Angular()) + { aYaw = aYaw + M_PI; + } else + { aYaw = aYaw - M_PI; + } } double aSY = std::sin(aYaw); double aCY = std::cos(aYaw); @@ -2731,11 +2837,17 @@ occ::handle> StepToGeom::MakeYprRotation( else { if (std::abs(aCY) > std::abs(aSR) && std::abs(aCY) > std::abs(aCR)) + { aCm1 = aRotMat[0][0] / aCY; + } else if (std::abs(aSR) > std::abs(aCR)) + { aCm1 = -aRotMat[1][2] / aSR; + } else + { aCm1 = aRotMat[2][2] / aCR; + } } aPitch = std::atan2(aRotMat[0][2], aCm1); } diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_Builder.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_Builder.cxx index b170f27d7f..06e8466024 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_Builder.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_Builder.cxx @@ -159,16 +159,16 @@ void StepToTopoDS_Builder::Init(const occ::handle& // Get Statistics : if (theTP->TraceLevel() > 2) { - sout << "Geometric Statistics : " << std::endl; - sout << " Surface Continuity : - C0 : " << aTool.C0Surf() << std::endl; - sout << " - C1 : " << aTool.C1Surf() << std::endl; - sout << " - C2 : " << aTool.C2Surf() << std::endl; - sout << " Curve Continuity : - C0 : " << aTool.C0Cur3() << std::endl; - sout << " - C1 : " << aTool.C1Cur3() << std::endl; - sout << " - C2 : " << aTool.C2Cur3() << std::endl; - sout << " PCurve Continuity : - C0 : " << aTool.C0Cur2() << std::endl; - sout << " - C1 : " << aTool.C1Cur2() << std::endl; - sout << " - C2 : " << aTool.C2Cur2() << std::endl; + sout << "Geometric Statistics : " << '\n'; + sout << " Surface Continuity : - C0 : " << aTool.C0Surf() << '\n'; + sout << " - C1 : " << aTool.C1Surf() << '\n'; + sout << " - C2 : " << aTool.C2Surf() << '\n'; + sout << " Curve Continuity : - C0 : " << aTool.C0Cur3() << '\n'; + sout << " - C1 : " << aTool.C1Cur3() << '\n'; + sout << " - C2 : " << aTool.C2Cur3() << '\n'; + sout << " PCurve Continuity : - C0 : " << aTool.C0Cur2() << '\n'; + sout << " - C1 : " << aTool.C1Cur2() << '\n'; + sout << " - C2 : " << aTool.C2Cur2() << '\n'; } ResetPreci(aStepModel, aSolid, MaxTol()); @@ -236,7 +236,9 @@ void StepToTopoDS_Builder::Init(const occ::handle& th //: e0 abv 25 Mar 98: void should be an OrientedShell if (!anOCShell.IsNull() && !anOCShell->Orientation()) + { aShape.Reverse(); + } aBuilder.Add(aSolid, aShape); } @@ -250,16 +252,16 @@ void StepToTopoDS_Builder::Init(const occ::handle& th // Get Statistics : if (theTP->TraceLevel() > 2) { - sout << "Geometric Statistics : " << std::endl; - sout << " Surface Continuity : - C0 : " << aTool.C0Surf() << std::endl; - sout << " - C1 : " << aTool.C1Surf() << std::endl; - sout << " - C2 : " << aTool.C2Surf() << std::endl; - sout << " Curve Continuity : - C0 : " << aTool.C0Cur3() << std::endl; - sout << " - C1 : " << aTool.C1Cur3() << std::endl; - sout << " - C2 : " << aTool.C2Cur3() << std::endl; - sout << " PCurve Continuity : - C0 : " << aTool.C0Cur2() << std::endl; - sout << " - C1 : " << aTool.C1Cur2() << std::endl; - sout << " - C2 : " << aTool.C2Cur2() << std::endl; + sout << "Geometric Statistics : " << '\n'; + sout << " Surface Continuity : - C0 : " << aTool.C0Surf() << '\n'; + sout << " - C1 : " << aTool.C1Surf() << '\n'; + sout << " - C2 : " << aTool.C2Surf() << '\n'; + sout << " Curve Continuity : - C0 : " << aTool.C0Cur3() << '\n'; + sout << " - C1 : " << aTool.C1Cur3() << '\n'; + sout << " - C2 : " << aTool.C2Cur3() << '\n'; + sout << " PCurve Continuity : - C0 : " << aTool.C0Cur2() << '\n'; + sout << " - C1 : " << aTool.C1Cur2() << '\n'; + sout << " - C2 : " << aTool.C2Cur2() << '\n'; } //: S4136 ShapeFix::SameParameter (S,false); @@ -448,9 +450,13 @@ void StepToTopoDS_Builder::Init(const occ::handle 1) + { myResult = S; + } else + { myResult = Shl; + } myError = StepToTopoDS_BuilderDone; done = true; @@ -458,16 +464,16 @@ void StepToTopoDS_Builder::Init(const occ::handleTraceLevel() > 2) { - sout << "Geometric Statistics : " << std::endl; - sout << " Surface Continuity : - C0 : " << myTool.C0Surf() << std::endl; - sout << " - C1 : " << myTool.C1Surf() << std::endl; - sout << " - C2 : " << myTool.C2Surf() << std::endl; - sout << " Curve Continuity : - C0 : " << myTool.C0Cur3() << std::endl; - sout << " - C1 : " << myTool.C1Cur3() << std::endl; - sout << " - C2 : " << myTool.C2Cur3() << std::endl; - sout << " PCurve Continuity : - C0 : " << myTool.C0Cur2() << std::endl; - sout << " - C1 : " << myTool.C1Cur2() << std::endl; - sout << " - C2 : " << myTool.C2Cur2() << std::endl; + sout << "Geometric Statistics : " << '\n'; + sout << " Surface Continuity : - C0 : " << myTool.C0Surf() << '\n'; + sout << " - C1 : " << myTool.C1Surf() << '\n'; + sout << " - C2 : " << myTool.C2Surf() << '\n'; + sout << " Curve Continuity : - C0 : " << myTool.C0Cur3() << '\n'; + sout << " - C1 : " << myTool.C1Cur3() << '\n'; + sout << " - C2 : " << myTool.C2Cur3() << '\n'; + sout << " PCurve Continuity : - C0 : " << myTool.C0Cur2() << '\n'; + sout << " - C1 : " << myTool.C1Cur2() << '\n'; + sout << " - C2 : " << myTool.C2Cur2() << '\n'; } //: S4136 ShapeFix::SameParameter (S,false); @@ -513,7 +519,9 @@ void StepToTopoDS_Builder::Init(const occ::handle ces = boundary->Value(i); if (ces.IsNull()) + { continue; + } occ::handle>> edges = ces->CesEdges(); if (edges.IsNull() || edges->Length() < 1) { @@ -525,22 +533,34 @@ void StepToTopoDS_Builder::Init(const occ::handleValue(j), myTool, dummyNMTool, theLocalFactors); if (!myTranEdge.IsDone()) + { continue; + } TopoDS_Edge E = TopoDS::Edge(myTranEdge.Value()); if (E.IsNull()) + { continue; // NULL, on saute + } if (W.IsNull()) + { B.MakeWire(W); + } B.Add(W, E); } if (W.IsNull()) + { continue; + } W.Closed(BRep_Tool::IsClosed(W)); B.Add(C, W); if (myResult.IsNull()) + { myResult = W; + } else + { myResult = C; + } } myError = (myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther); @@ -588,7 +608,9 @@ void StepToTopoDS_Builder::Init(const occ::handle cfs = boundary->Value(i); if (cfs.IsNull()) + { continue; + } occ::handle>> faces = cfs->CfsFaces(); if (faces.IsNull() || faces->Length() < 1) { @@ -602,22 +624,34 @@ void StepToTopoDS_Builder::Init(const occ::handle(faces->Value(j)); myTranFace.Init(fs, myTool, dummyNMTool, theLocalFactors); if (!myTranFace.IsDone()) + { continue; + } TopoDS_Face F = TopoDS::Face(myTranFace.Value()); if (F.IsNull()) + { continue; // NULL, on saute + } if (S.IsNull()) + { B.MakeShell(S); + } B.Add(S, F); } if (S.IsNull()) + { continue; + } S.Closed(BRep_Tool::IsClosed(S)); B.Add(C, S); if (myResult.IsNull()) + { myResult = S; + } else + { myResult = C; + } } myError = (myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther); @@ -642,7 +676,9 @@ static TopoDS_Face TranslateBoundedSurf(const occ::handle& sur occ::handle theSurf = StepToGeom::MakeSurface(surf, theLocalFactors); if (theSurf.IsNull() || //: i6: protection !theSurf->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) + { return res; + } BRepBuilderAPI_MakeFace myMkFace; occ::handle RS = @@ -722,11 +758,15 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC aB.MakeCompound(aComp); TopExp_Explorer anExp; for (anExp.Init(TrCC.Value(), TopAbs_EDGE); anExp.More(); anExp.Next()) + { aB.Add(aComp, anExp.Current()); + } res = aComp; } else + { res = TrCC.Value(); + } } } else @@ -741,7 +781,7 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC { Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo(); sout << "StepToTopoDS, GeometricSet, elem " << i << " of " << nbElem << ": exception "; - sout << anException.what() << std::endl; + sout << anException.what() << '\n'; } if (!aGeomCrv.IsNull()) { @@ -749,7 +789,9 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC aGeomCrv->FirstParameter(), aGeomCrv->LastParameter()); if (anEdge.IsDone()) + { res = anEdge.Edge(); + } } } } @@ -763,7 +805,9 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC { BRepBuilderAPI_MakeVertex myMkVtx(thePnt->Pnt()); if (myMkVtx.IsDone()) + { res = myMkVtx.Vertex(); + } } } // Element should finally be a Surface @@ -782,7 +826,9 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC TrCBS.Init(CBS, TP, theLocalFactors); if (TrCBS.IsDone()) + { res = TrCBS.Value(); + } } // try RectangularCompositeSurface else if (ent->IsKind(STANDARD_TYPE(StepGeom_RectangularCompositeSurface))) @@ -794,18 +840,24 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC TopoDS_Compound C; B.MakeCompound(C); for (int ii = 1; ii <= nbi; ii++) + { for (int j = 1; j <= nbj; j++) { occ::handle patch = RCS->SegmentsValue(ii, j); TopoDS_Face f = TranslateBoundedSurf(patch->ParentSurface(), preci, theLocalFactors); if (!f.IsNull()) + { B.Add(C, f); + } } + } res = C; } // try other surfs else + { res = TranslateBoundedSurf(aSurf, preci, theLocalFactors); + } } else if (ent->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) { @@ -816,7 +868,9 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC occ::handle anActor = occ::down_cast(RA); occ::handle binder; if (!anActor.IsNull()) + { binder = anActor->TransferShape(GRI, TP, theLocalFactors, isManifold, false, aRange); + } if (!binder.IsNull()) { res = TransferBRep::ShapeResult(binder); @@ -824,14 +878,18 @@ void StepToTopoDS_Builder::Init(const occ::handle& GC } } else + { TP->AddWarning(ent, " Entity is not a Curve, Point, Surface or GeometricRepresentationItem"); + } if (!res.IsNull()) { B.Add(S, res); TransferBRep::SetShapeResult(TP, ent, res); } else + { TP->AddWarning(ent, " Entity not mapped to TopoDS"); + } } myResult = S; myError = StepToTopoDS_BuilderDone; diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_GeometricTool.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_GeometricTool.cxx index f2abfa6d4e..f6d83369cc 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_GeometricTool.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_GeometricTool.cxx @@ -59,7 +59,9 @@ int StepToTopoDS_GeometricTool::PCurve(const occ::handle& if (!thePCurve.IsNull()) { if (thePCurve->BasisSurface() == BasisSurf) + { return i; + } } } thePCurve.Nullify(); @@ -78,10 +80,14 @@ bool StepToTopoDS_GeometricTool::IsSeamCurve(const occ::handle& EdgeLoop) { if (SurfCurve->IsKind(STANDARD_TYPE(StepGeom_SeamCurve))) + { return true; + } if (SurfCurve->NbAssociatedGeometry() != 2) + { return false; + } occ::handle StepPCurve1 = SurfCurve->AssociatedGeometryValue(1).Pcurve(); occ::handle StepPCurve2 = SurfCurve->AssociatedGeometryValue(2).Pcurve(); @@ -101,11 +107,15 @@ bool StepToTopoDS_GeometricTool::IsSeamCurve(const occ::handleEdgeListValue(i); if (StepEdge == OrEdge->EdgeElement()) + { nbOE++; + } } // two oriented edges of the same wire share the same edge if (nbOE == 2) + { return true; + } } return false; } @@ -124,7 +134,9 @@ bool StepToTopoDS_GeometricTool::IsLikeSeam(const occ::handle& EdgeLoop) { if (SurfCurve->NbAssociatedGeometry() != 2) + { return false; + } occ::handle StepPCurve1 = SurfCurve->AssociatedGeometryValue(1).Pcurve(); occ::handle StepPCurve2 = SurfCurve->AssociatedGeometryValue(2).Pcurve(); @@ -144,7 +156,9 @@ bool StepToTopoDS_GeometricTool::IsLikeSeam(const occ::handleEdgeListValue(i); if (StepEdge == OrEdge->EdgeElement()) + { nbOE++; + } } // the two oriented edges are not in the same wire if (nbOE == 1) @@ -173,9 +187,13 @@ bool StepToTopoDS_GeometricTool::IsLikeSeam(const occ::handle& th } if (w1 < w2) + { return true; + } if (theCurve->IsPeriodic()) { diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_MakeTransformed.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_MakeTransformed.cxx index a7905b69b7..0bf7241eef 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_MakeTransformed.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_MakeTransformed.cxx @@ -46,17 +46,23 @@ bool StepToTopoDS_MakeTransformed::Compute(const occ::handle theOrig = StepToGeom::MakeAxis2Placement(Origin, theLocalFactors); if (theOrig.IsNull()) + { return false; + } occ::handle theTarg = StepToGeom::MakeAxis2Placement(Target, theLocalFactors); if (theTarg.IsNull()) + { return false; + } const gp_Ax3 ax3Orig(theOrig->Ax2()); const gp_Ax3 ax3Targ(theTarg->Ax2()); @@ -87,7 +93,9 @@ const gp_Trsf& StepToTopoDS_MakeTransformed::Transformation() const bool StepToTopoDS_MakeTransformed::Transform(TopoDS_Shape& shape) const { if (theTrsf.Form() == gp_Identity) + { return false; + } TopLoc_Location theLoc(theTrsf); shape.Move(theLoc); return true; @@ -117,21 +125,31 @@ TopoDS_Shape StepToTopoDS_MakeTransformed::TranslateMappedItem( bool ok = false; if (!Origin.IsNull() && !Target.IsNull()) + { ok = Compute(Origin, Target, theLocalFactors); + } else if (!CartOp.IsNull()) + { ok = Compute(CartOp, theLocalFactors); + } if (!ok) + { TP->AddWarning(mapit, "Mapped Item, case not recognized, location ignored"); + } // La Shape, et la mise en position occ::handle maprep = mapit->MappingSource()->MappedRepresentation(); occ::handle binder = TP->Find(maprep); if (binder.IsNull()) + { binder = TP->Transferring(maprep, theProgress); + } occ::handle shbinder = occ::down_cast(binder); if (shbinder.IsNull()) + { TP->AddWarning(mapit, "No Shape Produced"); + } else { theResult = shbinder->Result(); diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_NMTool.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_NMTool.cxx index 6b578999f2..473029cfb9 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_NMTool.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_NMTool.cxx @@ -154,7 +154,9 @@ const TopoDS_Shape& StepToTopoDS_NMTool::Find(const TCollection_AsciiString& RIN void StepToTopoDS_NMTool::RegisterNMEdge(const TopoDS_Shape& Edge) { if (!this->isEdgeRegisteredAsNM(Edge)) + { myNMEdges.Append(Edge); + } } // ============================================================================ @@ -239,7 +241,9 @@ bool StepToTopoDS_NMTool::isEdgeRegisteredAsNM(const TopoDS_Shape& Edge) bool StepToTopoDS_NMTool::isAdjacentShell(const TopoDS_Shape& ShellA, const TopoDS_Shape& ShellB) { if (ShellA.IsSame(ShellB)) + { return false; + } TopExp_Explorer edgeExpA(ShellA, TopAbs_EDGE); for (; edgeExpA.More(); edgeExpA.Next()) @@ -250,7 +254,9 @@ bool StepToTopoDS_NMTool::isAdjacentShell(const TopoDS_Shape& ShellA, const Topo { const TopoDS_Shape& currentEdgeB = edgeExpB.Current(); if (currentEdgeA.IsSame(currentEdgeB)) + { return true; + } } } diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx index 9b32703152..c3f4547d6b 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx @@ -92,7 +92,9 @@ bool StepToTopoDS_TranslateCompositeCurve::Init(const occ::handleInternalParameters.ReadSurfaceCurveMode; if (modepcurve == -3) + { SurfMode = false; + } } occ::handle sbwd = new ShapeExtend_WireData; @@ -134,13 +138,17 @@ bool StepToTopoDS_TranslateCompositeCurve::Init(const occ::handle cc = occ::down_cast(crv); if (!Init(cc, TP, S, Surf, theLocalFactors) || myWire.IsNull()) + { continue; + } int nb = sbwd->NbEdges() + 1; for (TopoDS_Iterator it(myWire); it.More(); it.Next()) { TopoDS_Edge edge = TopoDS::Edge(it.Value()); if (ccs->SameSense()) + { sbwd->Add(edge); + } else { edge.Reverse(); @@ -168,10 +176,14 @@ bool StepToTopoDS_TranslateCompositeCurve::Init(const occ::handleAssociatedGeometryValue(j); occ::handle pc = PCorS.Pcurve(); if (pc.IsNull() || pc->BasisSurface() != S) + { continue; + } pcurve = pc; if (ccs->SameSense()) + { break; + } } } } @@ -179,7 +191,9 @@ bool StepToTopoDS_TranslateCompositeCurve::Init(const occ::handleBasisSurface() != S) + { pcurve.Nullify(); + } crv.Nullify(); } @@ -272,7 +286,9 @@ bool StepToTopoDS_TranslateCompositeCurve::Init(const occ::handleSameSense()) + { edge.Reverse(); + } sbwd->Add(edge); } if (sbwd->NbEdges() <= 0) diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx index 168a3ad9da..6d7cab7a1c 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx @@ -60,7 +60,9 @@ bool StepToTopoDS_TranslateCurveBoundedSurface::Init( { myFace.Nullify(); if (CBS.IsNull()) + { return false; + } // translate basis surface occ::handle S = CBS->BasisSurface(); @@ -97,7 +99,9 @@ bool StepToTopoDS_TranslateCurveBoundedSurface::Init( myFace = mf.Face(); } else + { TP->AddWarning(CBS, "Cannot make natural bounds on infinite surface"); + } } // translate boundaries @@ -107,7 +111,9 @@ bool StepToTopoDS_TranslateCurveBoundedSurface::Init( { occ::handle cc = bnd->Value(i).BoundaryCurve(); if (cc.IsNull()) + { continue; + } StepToTopoDS_TranslateCompositeCurve TrCC(cc, TP, S, Surf, theLocalFactors); if (!TrCC.IsDone()) { diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx index 92126abf13..7fdc396fd5 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx @@ -103,9 +103,13 @@ static void DecodeMakeEdgeError( case (BRepLib_DifferentsPointAndParameter): if (!ShapeConstruct_Curve() .AdjustCurve(myCurve, BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2), true, true)) + { TP->AddFail(orig, " Different Points and Parameters"); + } else + { TP->AddWarning(orig, "Different Points and Parameters, adjusted"); + } break; case (BRepLib_LineThroughIdenticPoints): TP->AddFail(orig, " Line through identic Points"); @@ -139,10 +143,14 @@ static occ::handle MakeCurve(const occ::handle& { occ::handle C2 = occ::down_cast(TP->FindTransient(C1)); if (!C2.IsNull()) + { return C2; + } C2 = StepToGeom::MakeCurve(C1, theLocalFactors); if (!C2.IsNull()) + { TP->BindTransient(C1, C2); + } return C2; } @@ -203,7 +211,9 @@ void StepToTopoDS_TranslateEdge::Init(const occ::handle& aEdge, occ::handle OE = occ::down_cast(aEdge); occ::handle wEdge = aEdge; if (!OE.IsNull()) + { wEdge = OE->EdgeElement(); + } occ::handle EC = occ::down_cast(wEdge); if (aTool.IsBound(EC)) @@ -229,7 +239,9 @@ void StepToTopoDS_TranslateEdge::Init(const occ::handle& aEdge, TopoDS_Shape existingShape = NMTool.Find(EC); // Reverse shape's orientation if needed if (!OE->Orientation()) + { existingShape.Reverse(); + } myResult = existingShape; myError = StepToTopoDS_TranslateEdgeDone; done = true; @@ -245,7 +257,9 @@ void StepToTopoDS_TranslateEdge::Init(const occ::handle& aEdge, TopoDS_Shape existingShape = NMTool.Find(anECName->String()); // Reverse shape's orientation if needed if (!OE->Orientation()) + { existingShape.Reverse(); + } // Register Edge for final processing (I-DEAS case) NMTool.RegisterNMEdge(existingShape); myResult = existingShape; @@ -349,7 +363,9 @@ void StepToTopoDS_TranslateEdge::Init(const occ::handle& aEdge, { NMTool.Bind(EC, E); if (NMTool.IsIDEASCase() && !anECName.IsNull() && !anECName->IsEmpty()) + { NMTool.Bind(anECName->String(), E); + } } myResult = E; @@ -375,7 +391,9 @@ static void GetCartesianPoints(const occ::handle& EC, ((i == 1) == EC->SameSense() ? EC->EdgeStart() : EC->EdgeEnd()); const occ::handle VP = occ::down_cast(V); if (VP.IsNull()) + { continue; + } const occ::handle P = occ::down_cast(VP->VertexGeometry()); occ::handle CP = StepToGeom::MakeCartesianPoint(P, theLocalFactors); @@ -418,13 +436,17 @@ void StepToTopoDS_TranslateEdge::MakeFromCurve3D(const occ::handleAddWarning(C3D, "Update of 3D-Parameters has failed"); + } //: d5: instead of AdjustCurve above which is incorrect if U1 and U2 are not ends GeomAdaptor_Curve aCA(C1); @@ -540,7 +562,9 @@ occ::handle StepToTopoDS_TranslateEdge::MakePCurve( occ::handle C2d; const occ::handle DRI = PCU->ReferenceToCurve(); if (DRI.IsNull()) + { return C2d; + } const occ::handle StepCurve = occ::down_cast(DRI->ItemsValue(1)); try { diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx index a5ac6e105f..95ffa2cf93 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx @@ -299,7 +299,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle // see bug #29979: oriented edge contains another oriented edge if (OrEdge1->EdgeElement()->IsKind(STANDARD_TYPE(StepShape_OrientedEdge))) + { OrEdge1 = occ::down_cast(OrEdge1->EdgeElement()); + } occ::handle EC = occ::down_cast(OrEdge1->EdgeElement()); @@ -329,9 +331,13 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle { C1 = StepToGeom::MakeCurve(C, theLocalFactors); if (!C1.IsNull()) + { TP->BindTransient(C, C1); + } else + { TP->AddWarning(C, "Could not convert a curve. Curve definition is incorrect"); + } } } catch (Standard_Failure const& anException) @@ -377,13 +383,21 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle { //: S4136: preci) { bool Fixed = true; if (!iseV) + { aTool.Bind(Vend, V1); // gka 21.08.1998 bug PRO7656 + } else if (!istV) + { aTool.Bind(Vstart, V2); + } else + { aTool.Bind(Vend, V1); + } if (!C1.IsNull() && !C1->IsClosed() && Fixed) + { TP->AddWarning(EL->EdgeListValue(j), "Vertex of same coordinates, set confused"); + } } } } @@ -398,7 +412,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle OrEdge1 = EL->EdgeListValue(j); OrEdge2 = EL->EdgeListValue(j < NbEdge ? j + 1 : 1); if (OrEdge1.IsNull() || OrEdge2.IsNull()) + { continue; + } occ::handle EC1 = occ::down_cast(OrEdge1->EdgeElement()); @@ -417,20 +433,30 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle Vs22 = (OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart()); if ((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) + { continue; + } StepToTopoDS_TranslateVertex myTranVertex1(Vs1, aTool, NMTool, theLocalFactors); StepToTopoDS_TranslateVertex myTranVertex2(Vs2, aTool, NMTool, theLocalFactors); TopoDS_Vertex V1, V2; if (myTranVertex1.IsDone()) + { V1 = TopoDS::Vertex(myTranVertex1.Value()); + } if (myTranVertex2.IsDone()) + { V2 = TopoDS::Vertex(myTranVertex2.Value()); + } if (V1.IsNull() || V2.IsNull()) + { continue; // not treated + } if (V1.IsSame(V2)) + { continue; // OK + } gp_Pnt p1 = BRep_Tool::Pnt(V1); gp_Pnt p2 = BRep_Tool::Pnt(V2); @@ -438,18 +464,30 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle if (p1.Distance(p2) <= preci) { if (!aTool.IsBound(EC1)) + { aTool.Bind(Vs1, V2); + } else if (!aTool.IsBound(EC2)) + { aTool.Bind(Vs2, V1); + } else + { locFixed = false; + } } else + { locFixed = false; + } if (locFixed) + { TP->AddWarning(EL, "Adjacent edges do not have common vertex; set confused"); + } else + { TP->AddWarning(EL, "Adjacent edges are not connected"); + } } // ----------------------------------------------- @@ -467,11 +505,15 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle OrEdge1 = EL->EdgeListValue(j); if (OrEdge1.IsNull() || OrEdge1->EdgeElement().IsNull()) + { continue; + } // see bug #29979: oriented edge contains another oriented edge if (OrEdge1->EdgeElement()->IsKind(STANDARD_TYPE(StepShape_OrientedEdge))) + { OrEdge1 = occ::down_cast(OrEdge1->EdgeElement()); + } occ::handle EC = occ::down_cast(OrEdge1->EdgeElement()); @@ -495,16 +537,24 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle E = TopoDS::Edge(myTranEdge.Value()); if (E.IsNull()) + { continue; // NULL, on saute + } occ::handle C = EC->EdgeGeometry(); if (OrEdge1->Orientation() && EC->SameSense()) + { E.Orientation(TopAbs_FORWARD); + } else if (!OrEdge1->Orientation() && !EC->SameSense()) + { E.Orientation(TopAbs_FORWARD); + } else + { E.Orientation(TopAbs_REVERSED); + } isSeam = isLikeSeam = false; @@ -553,7 +603,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle // De toute facon, on recalcule if (isPlane) + { hasPcurve = false; + } // ------------------------------------------- // --- Special Mapping Cases : --- @@ -571,8 +623,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle StepPCurve1 = SurfCurve->AssociatedGeometryValue(1).Pcurve(); StepPCurve2 = SurfCurve->AssociatedGeometryValue(2).Pcurve(); // clang-format off - if (StepPCurve1.IsNull() || StepPCurve2.IsNull()) hasPcurve = false; //smh : BUC60810 - // clang-format on + if (StepPCurve1.IsNull() || StepPCurve2.IsNull()) { hasPcurve = false; //smh : BUC60810 + // clang-format on + } else { C2d1 = myTranEdge.MakePCurve(StepPCurve1, ConvSurf, theLocalFactors); @@ -602,7 +655,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle break; } else + { C2d = C2d1; + } lastpcurve = StepToTopoDS_GeometricTool::PCurve(SurfCurve, StepSurf, StepPCurve, lastpcurve); // -- Statistics -- @@ -644,13 +699,21 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle TopAbs_Orientation CumulO, EdgeO, WireO, FaceO; EdgeO = E.Orientation(); if (ForwardWire) + { WireO = TopAbs_FORWARD; + } else + { WireO = TopAbs_REVERSED; + } if (sameSense) + { FaceO = TopAbs_FORWARD; + } else + { FaceO = TopAbs_REVERSED; + } CumulO = TopAbs::Compose(EdgeO, WireO); CumulO = TopAbs::Compose(CumulO, FaceO); @@ -666,7 +729,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle continue; } else if (!ForwardEdge) + { forwardPC = 3 - forwardPC; // inverser 1-2 + } if (forwardPC == 1) { @@ -681,7 +746,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle //: S4136 FindParameter(C2d1, C2d2, E, Face, preci); } else + { B.UpdateEdge(E, C2d1, Face, 0.); // preci + } } else { @@ -693,7 +760,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle //: S4136 FindParameter(C2d1, C2d2, E, Face, preci); } else + { B.UpdateEdge(E, C2d2, Face, 0.); + } } } else @@ -742,7 +811,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle } if (done) + { B.Add(W, E); // on le fait ici. Sauf si erreur rencontree ... ! + } else { occ::handle Vs1, Vs2; @@ -771,6 +842,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle // ---------------------------------------------- // pdn compute parameter of Vertices using projecting if (!aTool.ComputePCurve()) + { for (TopoDS_Iterator EdgeIt(W); EdgeIt.More(); EdgeIt.Next()) { TopoDS_Edge edge = TopoDS::Edge(EdgeIt.Value()); @@ -781,7 +853,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle if (myEdgePro->IsFirstDone() && myEdgePro->IsLastDone()) { if (std::abs(myEdgePro->FirstParam() - myEdgePro->LastParam()) < Precision::PConfusion()) + { continue; + } B.Range(edge, Face, myEdgePro->FirstParam(), myEdgePro->LastParam()); } else @@ -792,14 +866,13 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const occ::handle #endif } } + } myResult = W; myError = StepToTopoDS_TranslateEdgeLoopDone; done = true; // Check des PCurves SYSTEMATIQUE, s il n y en a que quelques unes CheckPCurves(W, Face, isPlane, preci); - - return; } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateFace.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateFace.cxx index c0d2a26797..b5375691f1 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateFace.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateFace.cxx @@ -385,13 +385,17 @@ static occ::handle CreatePolyTriangulation( { if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) && aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1)) + { ++aNbTriaStrips; + } } for (int anIndex = 4; anIndex <= aTriangleStrip->Length(); anIndex += 2) { if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) && aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1)) + { ++aNbTriaStrips; + } } } @@ -772,7 +776,9 @@ void StepToTopoDS_TranslateFace::Init(const occ::handle aTP = theTool.TransientProcess(); @@ -825,7 +831,9 @@ void StepToTopoDS_TranslateFace::Init(const occ::handleBind(theTF, new TransferBRep_ShapeBinder(aF)); @@ -845,7 +853,9 @@ void StepToTopoDS_TranslateFace::Init(const occ::handle aTP = theTool.TransientProcess(); BRep_Builder aB; @@ -873,7 +883,9 @@ void StepToTopoDS_TranslateFace::Init(const occ::handle& double Magn; occ::handle SP = occ::down_cast(GeomSurf); if (SP.IsNull()) + { TP->AddFail(PL, "Surface not planar in a FacetedBRep !"); + } occ::handle STSU = new ShapeAnalysis_Surface(GeomSurf); int Nb = PL->NbPolygon(); occ::handle>> Poly = new NCollection_HArray1>(1, Nb + 1); for (i = 1; i <= Nb; i++) + { Poly->SetValue(i, PL->PolygonValue(i)); + } Nb++; Poly->SetValue(Nb, PL->PolygonValue(1)); @@ -115,7 +119,9 @@ void StepToTopoDS_TranslatePolyLoop::Init(const occ::handle& { P2 = Poly->Value(i); if (P1 == P2) + { continue; // peut arriver (KK) CKY 9-DEC-1997 + } StepToTopoDS_PointPair PP(P1, P2); GP2 = StepToGeom::MakeCartesianPoint(P2, theLocalFactors); TopoDS_Shape aBoundEdge; @@ -150,7 +156,9 @@ void StepToTopoDS_TranslatePolyLoop::Init(const occ::handle& // - via sa premiere face, orientation combinee = celle de cette premiere face // - via sa deuxieme face, orientation combinee INVERSE de la precedente if (TopoFace.Orientation() == TopAbs_FORWARD) + { E.Reverse(); + } V2 = aTool.FindVertex(P2); } gp_Pnt2d V2p1 = STSU->ValueOfUV(GP1->Pnt(), Precision()); @@ -169,7 +177,9 @@ void StepToTopoDS_TranslatePolyLoop::Init(const occ::handle& TopoDS_Edge EB = E; // pour le binding : cumul des orientations ! EB.Orientation(TopoFace.Orientation()); if (!isbound) + { aTool.BindEdge(PP, EB); + } if (!E.IsNull()) { B.Add(W, E); diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateShell.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateShell.cxx index 30887ade54..06ad3b33ba 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateShell.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateShell.cxx @@ -56,7 +56,9 @@ void StepToTopoDS_TranslateShell::Init(const occ::handle aBinder = occ::down_cast(theTP->Find(theTSo->GeometricLink())); if (aBinder) + { aSo = aBinder->Solid(); + } } bool aNewSolid = false; diff --git a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateVertex.cxx b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateVertex.cxx index ceae8226f0..3f28c01c27 100644 --- a/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateVertex.cxx +++ b/src/DataExchange/TKDESTEP/StepToTopoDS/StepToTopoDS_TranslateVertex.cxx @@ -113,7 +113,9 @@ void StepToTopoDS_TranslateVertex::Init(const occ::handle& aVe { NMTool.Bind(aVertex, V); if (NMTool.IsIDEASCase() && !aVName.IsNull() && !aVName->IsEmpty()) + { NMTool.Bind(aVName->String(), V); + } } myResult = V; diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AnnotationPlaneElement.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AnnotationPlaneElement.cxx index 7ba9f92a98..2f44e3d8e9 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AnnotationPlaneElement.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AnnotationPlaneElement.cxx @@ -27,11 +27,17 @@ StepVisual_AnnotationPlaneElement::StepVisual_AnnotationPlaneElement() = default int StepVisual_AnnotationPlaneElement::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_StyledItem))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AreaOrView.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AreaOrView.cxx index 1db9445f0a..8fe67dd9c8 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AreaOrView.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_AreaOrView.cxx @@ -22,11 +22,17 @@ StepVisual_AreaOrView::StepVisual_AreaOrView() = default; int StepVisual_AreaOrView::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationView))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingInterectionSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingInterectionSelect.cxx index 40fd17ada3..ed757b13ec 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingInterectionSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingInterectionSelect.cxx @@ -29,11 +29,17 @@ int StepVisual_CameraModelD3MultiClippingInterectionSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Plane))) + { return 1; + } if (ent->IsInstance(STANDARD_TYPE(StepVisual_CameraModelD3MultiClippingUnion))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingUnionSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingUnionSelect.cxx index 655444da84..9e82b98f2b 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingUnionSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CameraModelD3MultiClippingUnionSelect.cxx @@ -29,11 +29,17 @@ int StepVisual_CameraModelD3MultiClippingUnionSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Plane))) + { return 1; + } if (ent->IsInstance(STANDARD_TYPE(StepVisual_CameraModelD3MultiClippingIntersection))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFont.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFont.cxx index 2921d24142..5e7f7eff60 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFont.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFont.cxx @@ -61,6 +61,8 @@ occ::handle StepVisual_CurveStyleFont::Pattern int StepVisual_CurveStyleFont::NbPatternList() const { if (patternList.IsNull()) + { return 0; + } return patternList->Length(); } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFontSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFontSelect.cxx index 0e4b705c4f..08fc11a846 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFontSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_CurveStyleFontSelect.cxx @@ -23,13 +23,21 @@ StepVisual_CurveStyleFontSelect::StepVisual_CurveStyleFontSelect() = default; int StepVisual_CurveStyleFontSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_CurveStyleFont))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PreDefinedCurveFont))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_ExternallyDefinedCurveFont))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_DraughtingCalloutElement.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_DraughtingCalloutElement.cxx index 425432eba7..0cee9345ed 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_DraughtingCalloutElement.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_DraughtingCalloutElement.cxx @@ -29,15 +29,25 @@ StepVisual_DraughtingCalloutElement::StepVisual_DraughtingCalloutElement() = def int StepVisual_DraughtingCalloutElement::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_AnnotationCurveOccurrence))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_AnnotationTextOccurrence))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_AnnotationFillAreaOccurrence))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_EdgeOrCurve.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_EdgeOrCurve.cxx index a17684465d..e2eed80331 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_EdgeOrCurve.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_EdgeOrCurve.cxx @@ -27,11 +27,17 @@ StepVisual_EdgeOrCurve::StepVisual_EdgeOrCurve() = default; int StepVisual_EdgeOrCurve::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Curve))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Edge))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FaceOrSurface.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FaceOrSurface.cxx index e508b9c87a..477c71b076 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FaceOrSurface.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FaceOrSurface.cxx @@ -27,11 +27,17 @@ StepVisual_FaceOrSurface::StepVisual_FaceOrSurface() = default; int StepVisual_FaceOrSurface::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Face))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_Surface))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FillStyleSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FillStyleSelect.cxx index 34accc3f75..7cc93cdeee 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FillStyleSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FillStyleSelect.cxx @@ -21,9 +21,13 @@ StepVisual_FillStyleSelect::StepVisual_FillStyleSelect() = default; int StepVisual_FillStyleSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_FillAreaStyleColour))) + { return 1; + } // if (ent->IsKind(STANDARD_TYPE(StepVisual_ExternallyDefinedTileStyle))) return 2; // if (ent->IsKind(STANDARD_TYPE(StepVisual_FillAreaStyleTiles))) return 3; // if (ent->IsKind(STANDARD_TYPE(StepVisual_ExternallyDefinedHatchStyle))) return 4; diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FontSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FontSelect.cxx index 2501faac9a..78a2723e0d 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FontSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_FontSelect.cxx @@ -22,11 +22,17 @@ StepVisual_FontSelect::StepVisual_FontSelect() = default; int StepVisual_FontSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PreDefinedTextFont))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_ExternallyDefinedTextFont))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibilityContext.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibilityContext.cxx index 8ca6b6325b..5acced0422 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibilityContext.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibilityContext.cxx @@ -23,13 +23,21 @@ StepVisual_InvisibilityContext::StepVisual_InvisibilityContext() = default; int StepVisual_InvisibilityContext::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationRepresentation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationSet))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_DraughtingModel))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibleItem.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibleItem.cxx index 499f699559..ad84bb63a3 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibleItem.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_InvisibleItem.cxx @@ -23,13 +23,21 @@ StepVisual_InvisibleItem::StepVisual_InvisibleItem() = default; int StepVisual_InvisibleItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_StyledItem))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationLayerAssignment))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationRepresentation))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_LayeredItem.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_LayeredItem.cxx index 9d49b24889..e89f4536d9 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_LayeredItem.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_LayeredItem.cxx @@ -21,11 +21,17 @@ StepVisual_LayeredItem::StepVisual_LayeredItem() = default; int StepVisual_LayeredItem::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationRepresentation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerMember.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerMember.cxx index 0e3fade2ef..f6049f0e20 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerMember.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerMember.cxx @@ -51,7 +51,9 @@ void StepVisual_MarkerMember::SetEnumText(const int /*val*/, const char* const t { int vl = tool.Value(text); if (vl >= 0) + { SetInt(vl); + } } void StepVisual_MarkerMember::SetValue(const StepVisual_MarkerType val) diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerSelect.cxx index d0aa1fe267..3467e242a0 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_MarkerSelect.cxx @@ -32,13 +32,19 @@ occ::handle StepVisual_MarkerSelect::NewMember() const int StepVisual_MarkerSelect::CaseMem(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } Interface_ParamType type = ent->ParamType(); // Void : on admet "non defini" (en principe, on ne devrait pas) if (type != Interface_ParamVoid && type != Interface_ParamEnum) + { return 0; + } if (ent->Matches("MARKER_TYPE")) + { return 1; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_NullStyleMember.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_NullStyleMember.cxx index b73695b59b..311af0ddf3 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_NullStyleMember.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_NullStyleMember.cxx @@ -38,7 +38,9 @@ void StepVisual_NullStyleMember::SetEnumText(const int /*theValue*/, const char* { int aVal = tool.Value(theText); if (aVal >= 0) + { SetInt(aVal); + } } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PathOrCompositeCurve.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PathOrCompositeCurve.cxx index 8977322a3c..66200af2e6 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PathOrCompositeCurve.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PathOrCompositeCurve.cxx @@ -27,11 +27,17 @@ StepVisual_PathOrCompositeCurve::StepVisual_PathOrCompositeCurve() = default; int StepVisual_PathOrCompositeCurve::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepShape_Path))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationRepresentationSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationRepresentationSelect.cxx index 1e6f427d95..b60e1cf439 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationRepresentationSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationRepresentationSelect.cxx @@ -24,11 +24,17 @@ int StepVisual_PresentationRepresentationSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationRepresentation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationSet))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationSizeAssignmentSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationSizeAssignmentSelect.cxx index a8935ce3ec..d0b796f169 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationSizeAssignmentSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationSizeAssignmentSelect.cxx @@ -25,13 +25,21 @@ int StepVisual_PresentationSizeAssignmentSelect::CaseNum( const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationView))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationArea))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_AreaInSet))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationStyleSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationStyleSelect.cxx index 6ba834b213..412e4bae18 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationStyleSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_PresentationStyleSelect.cxx @@ -25,18 +25,28 @@ StepVisual_PresentationStyleSelect::StepVisual_PresentationStyleSelect() = defau int StepVisual_PresentationStyleSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PointStyle))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_CurveStyle))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleUsage))) + { return 3; + } // if (ent->IsKind(STANDARD_TYPE(StepVisual_SymbolStyle))) return 4; // if (ent->IsKind(STANDARD_TYPE(StepVisual_FillAreaStyle))) return 5; // if (ent->IsKind(STANDARD_TYPE(StepVisual_TextStyle))) return 6; if (ent->IsKind(STANDARD_TYPE(StepVisual_NullStyleMember))) + { return 7; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_RenderingPropertiesSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_RenderingPropertiesSelect.cxx index aa4b360abd..6f801fb5c0 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_RenderingPropertiesSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_RenderingPropertiesSelect.cxx @@ -27,11 +27,17 @@ StepVisual_RenderingPropertiesSelect::StepVisual_RenderingPropertiesSelect() = d int StepVisual_RenderingPropertiesSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleReflectanceAmbient))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleTransparent))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyleContextSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyleContextSelect.cxx index f0511948f7..6623f2faf1 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyleContextSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyleContextSelect.cxx @@ -23,13 +23,21 @@ StepVisual_StyleContextSelect::StepVisual_StyleContextSelect() = default; int StepVisual_StyleContextSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_RepresentationItem))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_PresentationSet))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItem.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItem.cxx index 230b9a9eda..0f227c0af9 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItem.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItem.cxx @@ -54,6 +54,8 @@ StepVisual_StyledItemTarget StepVisual_StyledItem::ItemAP242() const { StepVisual_StyledItemTarget anItem; if (anItem.CaseNum(myItem) > 0) + { anItem.SetValue(myItem); + } return anItem; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItemTarget.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItemTarget.cxx index d63b04873d..0915cdb51f 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItemTarget.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_StyledItemTarget.cxx @@ -29,15 +29,25 @@ StepVisual_StyledItemTarget::StepVisual_StyledItemTarget() = default; int StepVisual_StyledItemTarget::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepRepr_Representation))) + { return 3; + } if (ent->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem))) + { return 4; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_SurfaceStyleElementSelect.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_SurfaceStyleElementSelect.cxx index 5faf587fcc..4cfa6b679e 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_SurfaceStyleElementSelect.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_SurfaceStyleElementSelect.cxx @@ -25,18 +25,28 @@ StepVisual_SurfaceStyleElementSelect::StepVisual_SurfaceStyleElementSelect() = d int StepVisual_SurfaceStyleElementSelect::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleFillArea))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleBoundary))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleParameterLine))) + { return 3; + } // if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleSilhouette))) return 4; // if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleSegmentationCurve))) return 5; // if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleControlGrid))) return 6; if (ent->IsKind(STANDARD_TYPE(StepVisual_SurfaceStyleRendering))) + { return 7; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TessellatedEdgeOrVertex.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TessellatedEdgeOrVertex.cxx index 25eca65e8a..8582318e1a 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TessellatedEdgeOrVertex.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TessellatedEdgeOrVertex.cxx @@ -27,11 +27,17 @@ StepVisual_TessellatedEdgeOrVertex::StepVisual_TessellatedEdgeOrVertex() = defau int StepVisual_TessellatedEdgeOrVertex::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_TessellatedEdge))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_TessellatedVertex))) + { return 2; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TextOrCharacter.cxx b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TextOrCharacter.cxx index ce0aa6b97a..786a298e64 100644 --- a/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TextOrCharacter.cxx +++ b/src/DataExchange/TKDESTEP/StepVisual/StepVisual_TextOrCharacter.cxx @@ -23,13 +23,21 @@ StepVisual_TextOrCharacter::StepVisual_TextOrCharacter() = default; int StepVisual_TextOrCharacter::CaseNum(const occ::handle& ent) const { if (ent.IsNull()) + { return 0; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_AnnotationText))) + { return 1; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_CompositeText))) + { return 2; + } if (ent->IsKind(STANDARD_TYPE(StepVisual_TextLiteral))) + { return 3; + } return 0; } diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep.cxx index b4ff40ce7b..131a03924b 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep.cxx @@ -153,9 +153,13 @@ void TopoDSToStep::AddResult(const occ::handle& FP, occ::handle binder = FP->Find(mapper); if (binder.IsNull()) + { FP->Bind(mapper, result); + } else + { binder->AddResult(result); + } } //================================================================================================= @@ -168,5 +172,7 @@ void TopoDSToStep::AddResult(const occ::handle& FP, NCollection_DataMap, TopTools_ShapeMapHasher>:: Iterator it(Map); for (; it.More(); it.Next()) + { TopoDSToStep::AddResult(FP, it.Key(), it.Value()); + } } diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Builder.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Builder.cxx index 76102b65bd..229370519e 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Builder.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Builder.cxx @@ -108,7 +108,9 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShap int nbshapes = 0; for (anExp.Init(myShell, TopAbs_FACE); anExp.More(); anExp.Next()) + { nbshapes++; + } Message_ProgressScope aPS1(aPS.Next(), nullptr, nbshapes); for (anExp.Init(myShell, TopAbs_FACE); anExp.More() && aPS1.More(); anExp.Next(), aPS1.Next()) { @@ -132,7 +134,9 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShap } } if (!aPS1.More()) + { return; + } int nbFaces = mySeq.Length(); if (nbFaces >= 1) @@ -145,9 +149,13 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShap } occ::handle CFSpms; if (myShell.Closed()) + { CFSpms = new StepShape_ClosedShell(); + } else + { CFSpms = new StepShape_OpenShell(); + } occ::handle aName = new TCollection_HAsciiString(""); CFSpms->Init(aName, aSet); diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx index 282a91661b..802ad9d4b2 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx @@ -91,18 +91,23 @@ TopoDSToStep_MakeBrepWithVoids::TopoDSToStep_MakeBrepWithVoids( int nbshapes = 0; for (It.Initialize(aSolid); It.More(); It.Next()) + { if (It.Value().ShapeType() == TopAbs_SHELL) + { nbshapes++; + } + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (It.Initialize(aSolid); It.More() && aPS.More(); It.Next()) { if (It.Value().ShapeType() == TopAbs_SHELL) { TopoDS_Shell CurrentShell = TopoDS::Shell(It.Value()); - if (!aOutShell.IsNull() - && !aOutShell.IsEqual(CurrentShell)) //: e0 abv 25 Mar 98: voids should be reversed - //: according to EXPRESS for ABSR + if (!aOutShell.IsNull() && !aOutShell.IsEqual(CurrentShell)) + { //: e0 abv 25 Mar 98: voids should be reversed + //: according to EXPRESS for ABSR CurrentShell.Reverse(); + } //: d7 abv 16 Mar 98: try to treat 'open' shells as closed since flag // IsClosed() is often incorrect (taken from MakeManifoldSolid(Solid)) aTool.Init(aMap, false, aStepModel->InternalParameters.WriteSurfaceCurMode); @@ -134,9 +139,13 @@ TopoDSToStep_MakeBrepWithVoids::TopoDSToStep_MakeBrepWithVoids( if (!aOutShell.IsNull() && !aCShell.IsNull()) { if (aOutShell.IsEqual(It.Value())) + { aOuter = aCShell; + } else + { S.Append(aCShell); + } } #ifdef OCCT_DEBUG else @@ -174,7 +183,9 @@ TopoDSToStep_MakeBrepWithVoids::TopoDSToStep_MakeBrepWithVoids( } } if (!aPS.More()) + { return; + } int N = S.Length(); if (N >= 1) diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx index 05e59d4bc9..297a4d196d 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx @@ -55,7 +55,9 @@ TopoDSToStep_MakeFacetedBrep::TopoDSToStep_MakeFacetedBrep( TopoDSToStep_Tool aTool(aMap, true, aStepModel->InternalParameters.WriteSurfaceCurMode); TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress); if (theProgress.UserBreak()) + { return; + } TopoDSToStep::AddResult(FP, aTool); if (StepB.IsDone()) @@ -118,7 +120,9 @@ TopoDSToStep_MakeFacetedBrep::TopoDSToStep_MakeFacetedBrep( theLocalFactors, theProgress); if (theProgress.UserBreak()) + { return; + } TopoDSToStep::AddResult(FP, aTool); if (StepB.IsDone()) diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx index f22f8368df..60f2c2ab3d 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx @@ -77,8 +77,12 @@ TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::TopoDSToStep_MakeFacetedBrepAndBre { int nbshapes = 0; for (It.Initialize(aSolid); It.More(); It.Next()) + { if (It.Value().ShapeType() == TopAbs_SHELL) + { nbshapes++; + } + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (It.Initialize(aSolid); It.More() && aPS.More(); It.Next()) { @@ -97,9 +101,13 @@ TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::TopoDSToStep_MakeFacetedBrepAndBre { aCShell = occ::down_cast(StepB.Value()); if (aOutShell.IsEqual(It.Value())) + { aOuter = aCShell; + } else + { S.Append(aCShell); + } occ::handle aTessShell = StepB.TessellatedValue(); if (!aTessShell.IsNull()) { @@ -124,7 +132,9 @@ TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::TopoDSToStep_MakeFacetedBrepAndBre } } if (!aPS.More()) + { return; + } } int N = S.Length(); if (N >= 1) diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx index 27b7688015..e0d8f66277 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx @@ -53,7 +53,9 @@ static std::pair, occ::handle, occ::handle aOShell = occ::down_cast(StepB.Value()); if (aOShell.IsNull()) + { return std::make_pair(theManifoldSolidBrep, aTessItem); + } else { aCShell = new StepShape_ClosedShell; diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx index e3d3e6ca04..60cdf742de 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx @@ -74,7 +74,9 @@ TopoDSToStep_MakeShellBasedSurfaceModel::TopoDSToStep_MakeShellBasedSurfaceModel TopoDSToStep_Tool aTool(aMap, false, aStepModel->InternalParameters.WriteSurfaceCurMode); TopoDSToStep_Builder StepB(aFace, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress); if (theProgress.UserBreak()) + { return; + } TopoDSToStep::AddResult(FP, aTool); @@ -137,7 +139,9 @@ TopoDSToStep_MakeShellBasedSurfaceModel::TopoDSToStep_MakeShellBasedSurfaceModel TopoDSToStep_Tool aTool(aMap, false, aStepModel->InternalParameters.WriteSurfaceCurMode); TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress); if (theProgress.UserBreak()) + { return; + } // TopoDSToStep::AddResult ( FP, aTool ); if (StepB.IsDone()) @@ -207,8 +211,12 @@ TopoDSToStep_MakeShellBasedSurfaceModel::TopoDSToStep_MakeShellBasedSurfaceModel int nbshapes = 0; for (It.Initialize(aSolid); It.More(); It.Next()) + { if (It.Value().ShapeType() == TopAbs_SHELL) + { nbshapes++; + } + } Message_ProgressScope aPS(theProgress, nullptr, nbshapes); for (It.Initialize(aSolid); It.More() && aPS.More(); It.Next()) { @@ -240,7 +248,9 @@ TopoDSToStep_MakeShellBasedSurfaceModel::TopoDSToStep_MakeShellBasedSurfaceModel } } if (!aPS.More()) + { return; + } int N = S.Length(); if (N >= 1) { diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx index 9ad45f22f6..121a4d1796 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx @@ -127,10 +127,16 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& int count = 0; TopExp_Explorer exp(aTool.CurrentFace(), TopAbs_EDGE); for (; exp.More(); exp.Next()) + { if (aEdge.IsSame(exp.Current())) + { count++; + } + } if (count < 2) + { isSeam = false; + } } if (aEdge.Orientation() == TopAbs_INTERNAL || aEdge.Orientation() == TopAbs_EXTERNAL) @@ -154,7 +160,9 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& MkVertex.Init(Vfirst, aTool, FP, theLocalFactors); if (MkVertex.IsDone()) + { V1 = occ::down_cast(MkVertex.Value()); + } else { occ::handle errShape = new TransferBRep_ShapeMapper(aEdge); @@ -166,7 +174,9 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& MkVertex.Init(Vlast, aTool, FP, theLocalFactors); if (MkVertex.IsDone()) + { V2 = occ::down_cast(MkVertex.Value()); + } else { occ::handle errShape = new TransferBRep_ShapeMapper(aEdge); @@ -338,7 +348,6 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& myError = TopoDSToStep_EdgeDone; myResult = Epms; done = true; - return; } //================================================================================================= diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx index fe3ec2b491..c1d8dbc2f2 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx @@ -179,7 +179,9 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& occ::handle aRTS = occ::down_cast(Su); if (!aRTS.IsNull()) + { Su = aRTS->BasisSurface(); + } // Surfaces with indirect Axes are already reversed aTool.SetSurfaceReversed(false); @@ -205,9 +207,13 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& { occ::handle TS; if (aSurfaceIsOffset) + { TS = occ::down_cast(anOffsetSu->BasisSurface()); + } else + { TS = occ::down_cast(Su); + } double R = TS->MajorRadius(); double r = TS->MinorRadius(); if (R < r) // if torus is degenerate or base surface is degenerate, make revolution instead @@ -224,6 +230,7 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& // convert basis curve to bspline in order to avoid self-intersecting // surface of revolution (necessary e.g. for CATIA) if (VL - VF - 2 * M_PI < -Precision::PConfusion()) + { BasisCurve = ShapeAlgo::AlgoContainer()->ConvertCurveToBSpline(BasisCurve, VF, @@ -232,11 +239,14 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& GeomAbs_C1, 100, 9); + } // create surface of revolution gp_Ax1 Axis = Ax3.Axis(); if (!Ax3.Direct()) + { Axis.Reverse(); + } occ::handle Rev = new Geom_SurfaceOfRevolution(BasisCurve, Axis); @@ -274,7 +284,9 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& { MkWire.Init(CurrentWire, aTool, FP, theLocalFactors); if (MkWire.IsDone()) + { Loop = occ::down_cast(MkWire.Value()); + } else { FP->AddWarning(errShape, " a Wire not mapped"); @@ -304,9 +316,13 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& // aupres des autres editeurs de CFAO de la Round Table. if (!aTool.Faceted() && aFace.Orientation() == TopAbs_REVERSED) + { FaceBound->Init(aName, Loop, (CurrentWire.Orientation() == TopAbs_REVERSED)); + } else + { FaceBound->Init(aName, Loop, (CurrentWire.Orientation() == TopAbs_FORWARD)); + } mySeq.Append(FaceBound); } @@ -339,11 +355,15 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& // for writing VERTEX_LOOP if (!aTool.IsBound(E)) + { continue; + } occ::handle Cpms = occ::down_cast(aTool.Find(E))->EdgeGeometry(); if (Cpms.IsNull()) + { continue; + } if (aTool.IsBound(E)) { @@ -416,7 +436,9 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& occ::handle> aGeom = C1pms->AssociatedGeometry(); if (aGeom.IsNull()) + { aGeom = new NCollection_HArray1(1, 2); + } StepGeom_PcurveOrSurface PcOrSur; PcOrSur.SetValue(Pc); if ((aGeom->Value(1)).IsNull()) diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.cxx index e3e49edabd..bc26abc679 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.cxx @@ -124,7 +124,9 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Face& { done = false; if (theProgress.UserBreak()) + { return; + } TopLoc_Location aLoc; const occ::handle& aMesh = BRep_Tool::Triangulation(theFace, aLoc); if (aMesh.IsNull()) @@ -206,7 +208,9 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theTessellatedItem.Nullify(); if (theProgress.UserBreak()) + { return; + } TopExp_Explorer anExp; int aNbFaces = 0; diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Tool.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Tool.cxx index 295eee18e8..032982f268 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Tool.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_Tool.cxx @@ -138,7 +138,9 @@ void TopoDSToStep_Tool::SetCurrentFace(const TopoDS_Face& F) #endif double FaceTol = BRep_Tool::Tolerance(F); if (FaceTol > myLowestTol) + { myLowestTol = FaceTol; + } myCurrentFace = F; } @@ -203,7 +205,9 @@ void TopoDSToStep_Tool::SetCurrentEdge(const TopoDS_Edge& E) #endif double EdgeTol = BRep_Tool::Tolerance(E); if (EdgeTol > myLowestTol) + { myLowestTol = EdgeTol; + } myCurrentEdge = E; } @@ -220,7 +224,9 @@ void TopoDSToStep_Tool::SetCurrentVertex(const TopoDS_Vertex& V) { double VertexTol = BRep_Tool::Tolerance(V); if (VertexTol > myLowestTol) + { myLowestTol = VertexTol; + } myCurrentVertex = V; } diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx index 261ea8e800..c29858c411 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx @@ -339,7 +339,9 @@ bool TopoDSToStep_WireframeBuilder::GetTrimmedCurveFromFace( curShape = exp.Current(); curEdge = TopoDS::Edge(curShape); if (GetTrimmedCurveFromEdge(curEdge, aFace, aMap, aCurveList, theLocalFactors)) + { result = true; + } } return result; } @@ -375,7 +377,9 @@ bool TopoDSToStep_WireframeBuilder::GetTrimmedCurveFromShape( curShape = exp.Current(); curEdge = TopoDS::Edge(curShape); if (GetTrimmedCurveFromEdge(curEdge, nulFace, aMap, aCurveList, theLocalFactors)) + { result = true; + } } break; } @@ -391,7 +395,9 @@ bool TopoDSToStep_WireframeBuilder::GetTrimmedCurveFromShape( { TopoDS_Face curFace = TopoDS::Face(It.Value()); if (GetTrimmedCurveFromFace(curFace, aMap, aCurveList, theLocalFactors)) + { result = true; + } #ifdef OCCT_DEBUG if (!result) { @@ -409,7 +415,9 @@ bool TopoDSToStep_WireframeBuilder::GetTrimmedCurveFromShape( if (It.Value().ShapeType() == TopAbs_SHELL) { if (GetTrimmedCurveFromShape(It.Value(), aMap, aCurveList, theLocalFactors)) + { result = true; + } } } break; @@ -428,7 +436,9 @@ bool TopoDSToStep_WireframeBuilder::GetTrimmedCurveFromShape( break; } */ if (GetTrimmedCurveFromShape(It.Value(), aMap, aCurveList, theLocalFactors)) + { result = true; + } } break; } diff --git a/src/DataExchange/TKDESTL/RWStl/RWStl.cxx b/src/DataExchange/TKDESTL/RWStl/RWStl.cxx index 53e7e5330b..2d8ab6e8fc 100644 --- a/src/DataExchange/TKDESTL/RWStl/RWStl.cxx +++ b/src/DataExchange/TKDESTL/RWStl/RWStl.cxx @@ -87,7 +87,9 @@ public: occ::handle GetTriangulation() { if (myTriangles.IsEmpty()) + { return occ::handle(); + } occ::handle aPoly = new Poly_Triangulation(myNodes.Length(), myTriangles.Length(), false); @@ -347,7 +349,9 @@ bool RWStl::WriteAscii(const occ::handle& theMesh, if ((aTriIter % IND_THRESHOLD) == 0) { if (!aPS.More()) + { return false; + } aPS.Next(IND_THRESHOLD); } } @@ -451,7 +455,9 @@ bool RWStl::WriteBinary(const occ::handle& theMesh, if ((aTriIter % IND_THRESHOLD) == 0) { if (!aPS.More()) + { return false; + } aPS.Next(IND_THRESHOLD); } } diff --git a/src/DataExchange/TKDESTL/RWStl/RWStl_Reader.cxx b/src/DataExchange/TKDESTL/RWStl/RWStl_Reader.cxx index e505b2293c..b0b94544de 100644 --- a/src/DataExchange/TKDESTL/RWStl/RWStl_Reader.cxx +++ b/src/DataExchange/TKDESTL/RWStl/RWStl_Reader.cxx @@ -254,7 +254,9 @@ bool RWStl_Reader::IsAscii(Standard_IStream& theStream, const bool isSeekgAvaila static inline bool str_starts_with(const char* theStr, const char* theWord, int theN) { while (isspace(*theStr) && *theStr != '\0') + { theStr++; + } return !strncasecmp(theStr, theWord, theN); } @@ -264,7 +266,9 @@ static bool ReadVertex(const char* theStr, double& theX, double& theY, double& t // skip 'vertex' while (isspace((unsigned char)*aStr) || isalpha((unsigned char)*aStr)) + { ++aStr; + } // read values char* aEnd; diff --git a/src/DataExchange/TKDESTL/StlAPI/StlAPI_Reader.cxx b/src/DataExchange/TKDESTL/StlAPI/StlAPI_Reader.cxx index cd1a48ce23..1adc9349fa 100644 --- a/src/DataExchange/TKDESTL/StlAPI/StlAPI_Reader.cxx +++ b/src/DataExchange/TKDESTL/StlAPI/StlAPI_Reader.cxx @@ -23,16 +23,22 @@ bool StlAPI_Reader::Read(TopoDS_Shape& theShape, const char* const theFileName) { occ::handle aMesh = RWStl::ReadFile(theFileName); if (aMesh.IsNull()) + { return false; + } BRepBuilderAPI_MakeShapeOnMesh aConverter(aMesh); aConverter.Build(); if (!aConverter.IsDone()) + { return false; + } TopoDS_Shape aResult = aConverter.Shape(); if (aResult.IsNull()) + { return false; + } theShape = aResult; return true; @@ -44,16 +50,22 @@ bool StlAPI_Reader::Read(TopoDS_Shape& theShape, Standard_IStream& theStream) { occ::handle aMesh = RWStl::ReadStream(theStream); if (aMesh.IsNull()) + { return false; + } BRepBuilderAPI_MakeShapeOnMesh aConverter(aMesh); aConverter.Build(); if (!aConverter.IsDone()) + { return false; + } TopoDS_Shape aResult = aConverter.Shape(); if (aResult.IsNull()) + { return false; + } theShape = aResult; return true; diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_AsciiText.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_AsciiText.cxx index 0d5054fdcd..9aefbfcb7a 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_AsciiText.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_AsciiText.cxx @@ -95,7 +95,9 @@ Standard_OStream& Vrml_AsciiText::Print(Standard_OStream& anOStream) const { anOStream << '"' << myString->Value(i) << '"'; if (i < myString->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_Coordinate3.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_Coordinate3.cxx index caba4fa517..6e10f6a013 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_Coordinate3.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_Coordinate3.cxx @@ -64,7 +64,9 @@ Standard_OStream& Vrml_Coordinate3::Print(Standard_OStream& anOStream) const anOStream << myPoint->Value(i).X() << ' ' << myPoint->Value(i).Y() << ' ' << myPoint->Value(i).Z(); if (i < myPoint->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedFaceSet.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedFaceSet.cxx index ac7a4ca3f8..d47d0765c9 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedFaceSet.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedFaceSet.cxx @@ -92,10 +92,14 @@ Standard_OStream& Vrml_IndexedFaceSet::Print(Standard_OStream& anOStream) const anOStream << myCoordIndex->Value(i); if (i < myCoordIndex->Length()) + { anOStream << ","; + } if (myCoordIndex->Value(i) == -1) + { anOStream << "\n\t"; + } } anOStream << "]\n"; } @@ -107,10 +111,14 @@ Standard_OStream& Vrml_IndexedFaceSet::Print(Standard_OStream& anOStream) const { anOStream << myMaterialIndex->Value(i); if (i < myMaterialIndex->Length()) + { anOStream << ","; + } if (myMaterialIndex->Value(i) == -1) + { anOStream << "\n\t"; + } } // End of for anOStream << "]\n"; } @@ -122,10 +130,14 @@ Standard_OStream& Vrml_IndexedFaceSet::Print(Standard_OStream& anOStream) const { anOStream << myNormalIndex->Value(i); if (i < myNormalIndex->Length()) + { anOStream << ","; + } if (myNormalIndex->Value(i) == -1) + { anOStream << "\n\t"; + } } // End of for anOStream << "]\n"; } @@ -137,10 +149,14 @@ Standard_OStream& Vrml_IndexedFaceSet::Print(Standard_OStream& anOStream) const { anOStream << myTextureCoordIndex->Value(i); if (i < myTextureCoordIndex->Length()) + { anOStream << ","; + } if (myTextureCoordIndex->Value(i) == -1) + { anOStream << "\n\t"; + } } // End of for anOStream << "]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedLineSet.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedLineSet.cxx index 6bbfca125f..7cedbd1965 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedLineSet.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_IndexedLineSet.cxx @@ -91,10 +91,14 @@ Standard_OStream& Vrml_IndexedLineSet::Print(Standard_OStream& anOStream) const { anOStream << myCoordIndex->Value(i); if (i < myCoordIndex->Length()) + { anOStream << ','; + } if (myCoordIndex->Value(i) == -1) + { anOStream << '\n' << '\t'; + } } anOStream << ']' << '\n'; } @@ -106,10 +110,14 @@ Standard_OStream& Vrml_IndexedLineSet::Print(Standard_OStream& anOStream) const { anOStream << myMaterialIndex->Value(i); if (i < myMaterialIndex->Length()) + { anOStream << ','; + } if (myMaterialIndex->Value(i) == -1) + { anOStream << '\n' << '\t'; + } } // End of for anOStream << ']' << '\n'; } @@ -121,10 +129,14 @@ Standard_OStream& Vrml_IndexedLineSet::Print(Standard_OStream& anOStream) const { anOStream << myNormalIndex->Value(i); if (i < myNormalIndex->Length()) + { anOStream << ','; + } if (myNormalIndex->Value(i) == -1) + { anOStream << '\n' << '\t'; + } } // End of for anOStream << ']' << '\n'; } @@ -137,10 +149,14 @@ Standard_OStream& Vrml_IndexedLineSet::Print(Standard_OStream& anOStream) const { anOStream << myTextureCoordIndex->Value(i); if (i < myTextureCoordIndex->Length()) + { anOStream << ","; + } if (myTextureCoordIndex->Value(i) == -1) + { anOStream << "\n\t"; + } } // End of for anOStream << "]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_LOD.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_LOD.cxx index 1deab802ad..1c0c687f37 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_LOD.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_LOD.cxx @@ -65,7 +65,9 @@ Standard_OStream& Vrml_LOD::Print(Standard_OStream& anOStream) const { anOStream << myRange->Value(i); if (i < myRange->Length()) + { anOStream << ","; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_Material.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_Material.cxx index 9c6ee1c139..502d703d7c 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_Material.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_Material.cxx @@ -161,7 +161,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const Quantity_TOC_sRGB); anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b(); if (i < myAmbientColor->Length()) + { anOStream << ",\n\t"; // ,,,,,,,,,, + } } anOStream << " ]\n"; } @@ -180,7 +182,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const Quantity_TOC_sRGB); anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b(); if (i < myDiffuseColor->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } @@ -199,7 +203,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const Quantity_TOC_sRGB); anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b(); if (i < mySpecularColor->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } @@ -218,7 +224,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const Quantity_TOC_sRGB); anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b(); if (i < myEmissiveColor->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } @@ -231,7 +239,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const { anOStream << myShininess->Value(i); if (i < myShininess->Length()) + { anOStream << ", "; + } } anOStream << " ]\n"; } @@ -244,7 +254,9 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const { anOStream << myTransparency->Value(i); if (i < myTransparency->Length()) + { anOStream << ", "; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_Normal.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_Normal.cxx index 2ab5bc677a..f60d9ce434 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_Normal.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_Normal.cxx @@ -63,7 +63,9 @@ Standard_OStream& Vrml_Normal::Print(Standard_OStream& anOStream) const anOStream << myVector->Value(i).X() << " " << myVector->Value(i).Y() << " " << myVector->Value(i).Z(); if (i < myVector->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_Separator.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_Separator.cxx index e63f1a6acc..a053e5f7e7 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_Separator.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_Separator.cxx @@ -43,9 +43,13 @@ Standard_OStream& Vrml_Separator::Print(Standard_OStream& anOStream) if (myRenderCulling != Vrml_AUTO) { if (myRenderCulling == Vrml_ON) + { anOStream << " renderCulling\tON\n"; + } else + { anOStream << " renderCulling\tOFF\n"; + } } myFlagPrint = true; } // End of if diff --git a/src/DataExchange/TKDEVRML/Vrml/Vrml_TextureCoordinate2.cxx b/src/DataExchange/TKDEVRML/Vrml/Vrml_TextureCoordinate2.cxx index f85036788a..a8a5abc973 100644 --- a/src/DataExchange/TKDEVRML/Vrml/Vrml_TextureCoordinate2.cxx +++ b/src/DataExchange/TKDEVRML/Vrml/Vrml_TextureCoordinate2.cxx @@ -52,7 +52,9 @@ Standard_OStream& Vrml_TextureCoordinate2::Print(Standard_OStream& anOStream) co anOStream << myPoint->Value(i).X() << " " << myPoint->Value(i).Y(); if (i < myPoint->Length()) + { anOStream << ",\n\t"; + } } anOStream << " ]\n"; } diff --git a/src/DataExchange/TKDEVRML/VrmlAPI/VrmlAPI_Writer.cxx b/src/DataExchange/TKDEVRML/VrmlAPI/VrmlAPI_Writer.cxx index 8466092475..e4bf1af11d 100644 --- a/src/DataExchange/TKDEVRML/VrmlAPI/VrmlAPI_Writer.cxx +++ b/src/DataExchange/TKDEVRML/VrmlAPI/VrmlAPI_Writer.cxx @@ -159,7 +159,9 @@ void VrmlAPI_Writer::SetDeflection(const double aDef) myDrawer->SetTypeOfDeflection(Aspect_TOD_ABSOLUTE); } else + { myDrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); + } } void VrmlAPI_Writer::SetRepresentation(const VrmlAPI_RepresentationOfShape aRep) @@ -303,9 +305,13 @@ bool VrmlAPI_Writer::Write(const TopoDS_Shape& aShape, const int aVersion) const { if (aVersion == 1) + { return write_v1(aShape, theOStream); + } else if (aVersion == 2) + { return write_v2(aShape, theOStream); + } return false; } @@ -401,15 +407,21 @@ bool VrmlAPI_Writer::write_v1(const TopoDS_Shape& aShape, Standard_OStream& theO Vrml::VrmlHeaderWriter(theOStream); if (myRepresentation == VrmlAPI_BothRepresentation) + { Vrml::CommentWriter( " This file contents both Shaded and Wire Frame representation of selected Shape ", theOStream); + } if (myRepresentation == VrmlAPI_ShadedRepresentation) + { Vrml::CommentWriter(" This file contents only Shaded representation of selected Shape ", theOStream); + } if (myRepresentation == VrmlAPI_WireFrameRepresentation) + { Vrml::CommentWriter(" This file contents only Wire Frame representation of selected Shape ", theOStream); + } Vrml_Separator S1; S1.Print(theOStream); @@ -456,12 +468,16 @@ bool VrmlAPI_Writer::write_v2(const TopoDS_Shape& aShape, Standard_OStream& theO bool anExtFace = false; if (myRepresentation == VrmlAPI_ShadedRepresentation || myRepresentation == VrmlAPI_BothRepresentation) + { anExtFace = true; + } bool anExtEdge = false; if (myRepresentation == VrmlAPI_WireFrameRepresentation || myRepresentation == VrmlAPI_BothRepresentation) + { anExtEdge = true; + } VrmlData_Scene aScene; VrmlData_ShapeConvert aConv(aScene); diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Curve.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Curve.cxx index 964e6be45a..d0f18f454e 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Curve.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Curve.cxx @@ -238,9 +238,13 @@ void VrmlConverter_Curve::Add(const Adaptor3d_Curve& aCurve, double V2 = U2; if (Precision::IsNegativeInfinite(V1)) + { V1 = -aDrawer->MaximalParameterValue(); + } if (Precision::IsPositiveInfinite(V2)) + { V2 = aDrawer->MaximalParameterValue(); + } // std::cout << "V1 = "<< V1 << std::endl; // std::cout << "V2 = "<< V2 << std::endl; @@ -265,9 +269,13 @@ void VrmlConverter_Curve::Add(const Adaptor3d_Curve& aCurve, double V2 = U2; if (Precision::IsNegativeInfinite(V1)) + { V1 = -aDrawer->MaximalParameterValue(); + } if (Precision::IsPositiveInfinite(V2)) + { V2 = aDrawer->MaximalParameterValue(); + } // std::cout << "V1 = "<< V1 << std::endl; // std::cout << "V2 = "<< V2 << std::endl; diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_DeflectionCurve.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_DeflectionCurve.cxx index cb454b7075..ae25a40e77 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_DeflectionCurve.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_DeflectionCurve.cxx @@ -311,9 +311,13 @@ void VrmlConverter_DeflectionCurve::Add(Standard_OStream& double V2 = U2; if (Precision::IsNegativeInfinite(V1)) + { V1 = -aDrawer->MaximalParameterValue(); + } if (Precision::IsPositiveInfinite(V2)) + { V2 = aDrawer->MaximalParameterValue(); + } double theRequestedDeflection = GetDeflection(aCurve, V1, V2, aDrawer); DrawCurve(aCurve, theRequestedDeflection, V1, V2, aDrawer, anOStream); diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Projector.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Projector.cxx index bb2cd688b9..a49d2c45e6 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Projector.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_Projector.cxx @@ -60,17 +60,29 @@ VrmlConverter_Projector::VrmlConverter_Projector(const NCollection_Array1 std::abs(MaxAngle)) + { MaxAngle = std::abs(V1.Angle(V2)); + } V2.SetX(0); V2.SetY(P2.Y()); @@ -245,7 +261,9 @@ VrmlConverter_Projector::VrmlConverter_Projector(const NCollection_Array1 std::abs(MaxAngle)) + { MaxAngle = std::abs(V1.Angle(V2)); + } if (std::abs(P2.Y()) > std::abs(MaxHeight)) { diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_ShadedShape.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_ShadedShape.cxx index 3e167dd92e..ef5cf64892 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_ShadedShape.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_ShadedShape.cxx @@ -70,7 +70,9 @@ void VrmlConverter_ShadedShape::Add(Standard_OStream& anO T = BRep_Tool::Triangulation(F, theLocation); // number of triangles: if (T.IsNull()) + { continue; // smh + } nnn = T->NbTriangles(); // Taking the nodes of the triangle, taking into account the orientation @@ -78,9 +80,13 @@ void VrmlConverter_ShadedShape::Add(Standard_OStream& anO for (nt = 1; nt <= nnn; nt++) { if (F.Orientation() == TopAbs_REVERSED) + { T->Triangle(nt).Get(n1, n3, n2); + } else + { T->Triangle(nt).Get(n1, n2, n3); + } const gp_Pnt P1 = T->Node(n1); const gp_Pnt P2 = T->Node(n2); @@ -186,9 +192,13 @@ void VrmlConverter_ShadedShape::Add(Standard_OStream& anO { pc.Triangles(i, t[0], t[1], t[2]); if (F.Orientation() == TopAbs_REVERSED) + { T->Triangle(i).Get(n[0], n[2], n[1]); + } else + { T->Triangle(i).Get(n[0], n[1], n[2]); + } const gp_Pnt P1 = T->Node(n[0]); const gp_Pnt P2 = T->Node(n[1]); const gp_Pnt P3 = T->Node(n[2]); @@ -404,7 +414,9 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace, CSLib::Normal(D1U, D1V, D2U, D2V, D2UV, Precision::Angular(), OK, NStat, Nor(i)); } if (aFace.Orientation() == TopAbs_REVERSED) + { (Nor(i)).Reverse(); + } } } else @@ -423,7 +435,9 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace, } Nor(i) = gp_Dir(eqPlan); if (aFace.Orientation() == TopAbs_REVERSED) + { (Nor(i)).Reverse(); + } } } } diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionRestrictedFace.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionRestrictedFace.cxx index 16899d1f56..3ddcba04fa 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionRestrictedFace.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionRestrictedFace.cxx @@ -162,15 +162,19 @@ void VrmlConverter_WFDeflectionRestrictedFace::Add(Standard_OStream& anOStream, dummypnt = UDP.Value(i); P2.SetCoord(dummypnt.X(), dummypnt.Y()); if (Orient == TopAbs_FORWARD) + { isobuild.Trim(P1, P2); + } else + { isobuild.Trim(P2, P1); + } } } } else { - std::cout << "Cannot evaluate curve on surface" << std::endl; + std::cout << "Cannot evaluate curve on surface" << '\n'; } } else @@ -180,9 +184,13 @@ void VrmlConverter_WFDeflectionRestrictedFace::Add(Standard_OStream& anOStream, P1 = TheRCurve->Value(U1); P2 = TheRCurve->Value(U2); if (Orient == TopAbs_FORWARD) + { isobuild.Trim(P1, P2); + } else + { isobuild.Trim(P2, P1); + } } } diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx index 7b0fa1b7bd..5356e0e7f0 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFDeflectionShape.cxx @@ -173,13 +173,17 @@ else { BRepAdaptor_Curve C(Tool.GetCurve()); BRep_Tool::PolygonOnTriangulation(Tool.GetCurve(), aPT, aT, aL); if (!aPT.IsNull() && !aT.IsNull() && aPT->HasParameters()) + { VrmlConverter_DeflectionCurve::Add(anOStream, C, aPT->Parameters(), aPT->NbNodes(), aDrawer); + } else + { VrmlConverter_DeflectionCurve::Add(anOStream, C, theRequestedDeflection, aDrawer); + } } } } @@ -208,13 +212,17 @@ else { BRepAdaptor_Curve C(Tool.GetCurve()); BRep_Tool::PolygonOnTriangulation(Tool.GetCurve(), aPT, aT, aL); if (!aPT.IsNull() && !aT.IsNull() && aPT->HasParameters()) + { VrmlConverter_DeflectionCurve::Add(anOStream, C, aPT->Parameters(), aPT->NbNodes(), aDrawer); + } else + { VrmlConverter_DeflectionCurve::Add(anOStream, C, theRequestedDeflection, aDrawer); + } } } } @@ -243,13 +251,17 @@ else { BRepAdaptor_Curve C(Tool.GetCurve()); BRep_Tool::PolygonOnTriangulation(Tool.GetCurve(), aPT, aT, aL); if (!aPT.IsNull() && !aT.IsNull() && aPT->HasParameters()) + { VrmlConverter_DeflectionCurve::Add(anOStream, C, aPT->Parameters(), aPT->NbNodes(), aDrawer); + } else + { VrmlConverter_DeflectionCurve::Add(anOStream, C, theRequestedDeflection, aDrawer); + } } } } diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFRestrictedFace.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFRestrictedFace.cxx index cc43cc1203..0a0848ed02 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFRestrictedFace.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFRestrictedFace.cxx @@ -114,9 +114,13 @@ void VrmlConverter_WFRestrictedFace::Add(Standard_OStream& P1 = P2; P2 = TheRCurve->Value(U); if (Orient == TopAbs_FORWARD) + { isobuild.Trim(P1, P2); + } else + { isobuild.Trim(P2, P1); + } } } else @@ -124,9 +128,13 @@ void VrmlConverter_WFRestrictedFace::Add(Standard_OStream& P1 = TheRCurve->Value(U1); P2 = TheRCurve->Value(U2); if (Orient == TopAbs_FORWARD) + { isobuild.Trim(P1, P2); + } else + { isobuild.Trim(P2, P1); + } } } diff --git a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFShape.cxx b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFShape.cxx index 8b161c36e8..61271b1a12 100644 --- a/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFShape.cxx +++ b/src/DataExchange/TKDEVRML/VrmlConverter/VrmlConverter_WFShape.cxx @@ -83,7 +83,9 @@ void VrmlConverter_WFShape::Add(Standard_OStream& anOStre if (Tool.HasSurface()) { if (Tool.IsPlanarFace()) + { isoU = aDrawer->IsoOnPlane(); + } if (isoU) { S.Initialize(Tool.GetFace()); @@ -110,7 +112,9 @@ void VrmlConverter_WFShape::Add(Standard_OStream& anOStre if (Tool.HasSurface()) { if (Tool.IsPlanarFace()) + { isoV = aDrawer->IsoOnPlane(); + } if (isoV) { S.Initialize(Tool.GetFace()); diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Geometry.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Geometry.cxx index 004970ecf2..b654a2ad4f 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Geometry.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Geometry.cxx @@ -83,7 +83,9 @@ occ::handle VrmlData_Box::Clone(const occ::handle& { occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Box(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->SetSize(mySize); return aResult; } @@ -96,9 +98,13 @@ VrmlData_ErrorStatus VrmlData_Box::Read(VrmlData_InBuffer& theBuffer) if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "size")) + { aStatus = Scene().ReadXYZ(theBuffer, mySize, true, true); + } if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } } return aStatus; } @@ -130,11 +136,17 @@ const occ::handle& VrmlData_Cone::TShape() gp_Ax2 aLocalAxis(gp_Pnt(0., -0.5 * myHeight, 0.), gp_Dir(gp_Dir::D::Y)); BRepPrim_Cone aBuilder(aLocalAxis, myBottomRadius, 0., myHeight); if (!myHasBottom) + { myTShape = aBuilder.LateralFace().TShape(); + } else if (!myHasSide) + { myTShape = aBuilder.BottomFace().TShape(); + } else + { myTShape = aBuilder.Shell().TShape(); + } myIsModified = false; } catch (Standard_Failure const&) @@ -152,7 +164,9 @@ occ::handle VrmlData_Cone::Clone(const occ::handle occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Cone(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->SetBottomRadius(myBottomRadius); aResult->SetHeight(myHeight); @@ -170,28 +184,42 @@ VrmlData_ErrorStatus VrmlData_Cone::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bottomRadius")) + { aStatus = Scene().ReadReal(theBuffer, myBottomRadius, true, true); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "height")) + { aStatus = Scene().ReadReal(theBuffer, myHeight, true, true); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "side")) { if (OK(aStatus, ReadBoolean(theBuffer, hasSide))) + { myHasSide = hasSide; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bottom")) { if (OK(aStatus, ReadBoolean(theBuffer, hasBottom))) + { myHasBottom = hasBottom; + } } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -215,9 +243,13 @@ VrmlData_ErrorStatus VrmlData_Cone::Write(const char* thePrefix) const aStatus = Scene().WriteLine(buf); } if (OK(aStatus) && !myHasBottom) + { aStatus = Scene().WriteLine("bottom FALSE"); + } if (OK(aStatus) && !myHasSide) + { aStatus = Scene().WriteLine("side FALSE"); + } aStatus = WriteClosing(); } @@ -248,11 +280,17 @@ const occ::handle& VrmlData_Cylinder::TShape() TopoDS_Shell aShell; aShapeBuilder.MakeShell(aShell); if (myHasSide) + { aShapeBuilder.AddShellFace(aShell, aBuilder.LateralFace()); + } if (myHasTop) + { aShapeBuilder.AddShellFace(aShell, aBuilder.TopFace()); + } if (myHasBottom) + { aShapeBuilder.AddShellFace(aShell, aBuilder.BottomFace()); + } myTShape = aShell.TShape(); myIsModified = false; } @@ -272,7 +310,9 @@ occ::handle VrmlData_Cylinder::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Cylinder(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->SetRadius(myRadius); aResult->SetHeight(myHeight); aResult->SetFaces(myHasBottom, myHasSide, myHasTop); @@ -290,34 +330,50 @@ VrmlData_ErrorStatus VrmlData_Cylinder::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "radius")) + { aStatus = Scene().ReadReal(theBuffer, myRadius, true, true); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "height")) + { aStatus = Scene().ReadReal(theBuffer, myHeight, true, true); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "top")) { if (OK(aStatus, ReadBoolean(theBuffer, hasTop))) + { myHasTop = hasTop; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "side")) { if (OK(aStatus, ReadBoolean(theBuffer, hasSide))) + { myHasSide = hasSide; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bottom")) { if (OK(aStatus, ReadBoolean(theBuffer, hasBottom))) + { myHasBottom = hasBottom; + } } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -341,11 +397,17 @@ VrmlData_ErrorStatus VrmlData_Cylinder::Write(const char* thePrefix) const aStatus = Scene().WriteLine(buf); } if (OK(aStatus) && !myHasBottom) + { aStatus = Scene().WriteLine("bottom FALSE"); + } if (OK(aStatus) && !myHasSide) + { aStatus = Scene().WriteLine("side FALSE"); + } if (OK(aStatus) && !myHasTop) + { aStatus = Scene().WriteLine("top FALSE"); + } aStatus = WriteClosing(); } @@ -388,7 +450,9 @@ occ::handle VrmlData_Sphere::Clone(const occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Sphere(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->SetRadius(myRadius); return aResult; } @@ -399,14 +463,22 @@ VrmlData_ErrorStatus VrmlData_Sphere::Read(VrmlData_InBuffer& theBuffer) { VrmlData_ErrorStatus aStatus; while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "radius")) + { aStatus = Scene().ReadReal(theBuffer, myRadius, true, true); + } else + { break; + } + } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -451,15 +523,21 @@ occ::handle VrmlData_TextureCoordinate::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_TextureCoordinate(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) + { aResult->SetPoints(myLength, myPoints); + } else { aResult->AllocateValues(myLength); for (size_t i = 0; i < myLength; i++) + { const_cast(aResult->myPoints[i]) = myPoints[i]; + } } return aResult; } @@ -474,11 +552,14 @@ VrmlData_ErrorStatus VrmlData_TextureCoordinate::Read(VrmlData_InBuffer& theBuff { // Match the name with the current word in the stream if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "point")) + { // Read the body of the data node (comma-separated list of duplets) if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { - if (theBuffer.LinePtr[0] != '[') // opening bracket + if (theBuffer.LinePtr[0] != '[') + { // opening bracket aStatus = VrmlData_VrmlFormatError; + } else { theBuffer.LinePtr++; @@ -486,7 +567,9 @@ VrmlData_ErrorStatus VrmlData_TextureCoordinate::Read(VrmlData_InBuffer& theBuff { gp_XY anXY; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } // closing bracket, in case that it follows a comma if (theBuffer.LinePtr[0] == ']') { @@ -494,10 +577,14 @@ VrmlData_ErrorStatus VrmlData_TextureCoordinate::Read(VrmlData_InBuffer& theBuff break; } if (!OK(aStatus, Scene().ReadXY(theBuffer, anXY, false, false))) + { break; + } vecValues.Append(anXY); if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == ',') { theBuffer.LinePtr++; @@ -510,6 +597,7 @@ VrmlData_ErrorStatus VrmlData_TextureCoordinate::Read(VrmlData_InBuffer& theBuff } } } + } if (OK(aStatus) && OK(aStatus, readBrace(theBuffer))) { myLength = vecValues.Length(); @@ -519,7 +607,9 @@ VrmlData_ErrorStatus VrmlData_TextureCoordinate::Read(VrmlData_InBuffer& theBuff reinterpret_cast(Scene().Allocator()->Allocate(myLength * sizeof(gp_XY))); myPoints = aPoints; for (int i = 0; i < int(myLength); i++) + { aPoints[i] = vecValues(i); + } } } } @@ -554,9 +644,13 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer { const size_t aNameLen = strlen(theName); if (strncmp(theBuffer.LinePtr, theName, aNameLen)) + { aStatus = VrmlData_VrmlFormatError; + } else + { theBuffer.LinePtr += aNameLen; + } } else { @@ -564,7 +658,9 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer while (theBuffer.LinePtr[0] != ' ' && theBuffer.LinePtr[0] != ',' && theBuffer.LinePtr[0] != '\t' && theBuffer.LinePtr[0] != '\n' && theBuffer.LinePtr[0] != '\r' && theBuffer.LinePtr[0] != '\0') + { theBuffer.LinePtr++; + } } // Read the body of the data node (list of triplets) if (OK(aStatus) && OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) @@ -575,9 +671,13 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer gp_XYZ anXYZ; // Read three numbers (XYZ value) if (!OK(aStatus, Scene().ReadXYZ(theBuffer, anXYZ, isScale, false))) + { aStatus = VrmlData_VrmlFormatError; + } else + { vecValues.Append(anXYZ); + } } else { @@ -586,7 +686,9 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer { gp_XYZ anXYZ; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } // closing bracket, in case that it follows a comma if (theBuffer.LinePtr[0] == ']') { @@ -595,10 +697,14 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer } // Read three numbers (XYZ value) if (!OK(aStatus, Scene().ReadXYZ(theBuffer, anXYZ, isScale, false))) + { break; + } vecValues.Append(anXYZ); if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == ']') { // closing bracket theBuffer.LinePtr++; @@ -616,7 +722,9 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::ReadArray(VrmlData_InBuffer& theBuffer reinterpret_cast(Scene().Allocator()->Allocate(myLength * sizeof(gp_XYZ))); myArray = anArray; for (int i = 0; i < int(myLength); i++) + { anArray[i] = vecValues(i); + } } } } @@ -634,13 +742,21 @@ VrmlData_ErrorStatus VrmlData_ArrayVec3d::WriteArray(const char* theName, const if (OK(aStatus)) { for (size_t i = 0; i < myLength - 1; i++) + { if (!OK(aStatus, Scene().WriteXYZ(myArray[i], isScale, ","))) + { break; + } + } if (OK(aStatus)) + { aStatus = Scene().WriteXYZ(myArray[myLength - 1], isScale); + } } if (aStatus == VrmlData_StatusOK) + { aStatus = Scene().WriteLine("]", nullptr, -2 * GlobalIndent()); + } } return aStatus; } @@ -660,14 +776,20 @@ occ::handle VrmlData_Coordinate::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Coordinate(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) + { aResult->SetValues(Length(), Values()); + } else { aResult->AllocateValues(Length()); for (size_t i = 0; i < Length(); i++) + { const_cast(aResult->Values()[i]) = Values()[i]; + } } return aResult; } @@ -700,14 +822,20 @@ occ::handle VrmlData_Color::Clone(const occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Color(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) + { aResult->SetValues(Length(), Values()); + } else { aResult->AllocateValues(Length()); for (size_t i = 0; i < Length(); i++) + { const_cast(aResult->Values()[i]) = Values()[i]; + } } return aResult; } @@ -740,14 +868,20 @@ occ::handle VrmlData_Normal::Clone(const occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Normal(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) + { aResult->SetValues(Length(), Values()); + } else { aResult->AllocateValues(Length()); for (size_t i = 0; i < Length(); i++) + { const_cast(aResult->Values()[i]) = Values()[i]; + } } return aResult; } diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Group.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Group.cxx index 4332e09691..4d6085bcbc 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Group.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Group.cxx @@ -52,12 +52,14 @@ bool VrmlData_Group::RemoveNode(const occ::handle& theNode) { bool aResult(false); for (Iterator anIter = NodeIterator(); anIter.More(); anIter.Next()) + { if (anIter.Value() == theNode) { aResult = true; myNodes.Remove(anIter); break; } + } return aResult; } @@ -81,12 +83,16 @@ occ::handle VrmlData_Group::Clone(const occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Group(theOther.IsNull() ? Scene() : theOther->Scene(), Name(), myIsTransform); + } aResult->myIsTransform = myIsTransform; if (&aResult->Scene() == &Scene()) + { aResult->myNodes = myNodes; + } else { // Create a dummy node to pass the different Scene instance to methods Clone @@ -96,11 +102,15 @@ occ::handle VrmlData_Group::Clone(const occ::handle& aNode = anIter.Value(); if (!aNode.IsNull()) + { aResult->myNodes.Append(aNode->Clone(aDummyNode)); + } } } if (myIsTransform) + { aResult->SetTransform(myTrsf); + } aResult->SetBox(myBox); return aResult; @@ -156,22 +166,28 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bboxCenter")) + { aStatus = Scene().ReadXYZ(theBuffer, aBoxCenter, true, false); - + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bboxSize")) + { aStatus = Scene().ReadXYZ(theBuffer, aBoxSize, true, false); - + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "children")) { bool isBracketed(false); // Read the opening bracket for the list of children if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == '[') { theBuffer.LinePtr++; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } isBracketed = true; } @@ -187,10 +203,14 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) } // otherwise read a node if (!OK(aStatus, ReadNode(theBuffer, aChildNode))) + { break; + } AddNode(aChildNode); if (!isBracketed) + { break; + } } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "collide")) @@ -203,13 +223,17 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) bool isBracketed(false); // Read the opening bracket for the list of children if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == '{') { theBuffer.LinePtr++; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } isBracketed = true; } @@ -226,11 +250,15 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) // otherwise read a node if (!OK(aStatus, ReadNode(theBuffer, aChildNode))) + { break; + } AddNode(aChildNode); if (!isBracketed) + { break; + } } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TransformSeparator") @@ -240,13 +268,17 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) bool isBracketed(false); // Read the opening bracket for the list of children if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == '{') { theBuffer.LinePtr++; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } isBracketed = true; } @@ -262,11 +294,15 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) } // otherwise read a node if (!OK(aStatus, ReadNode(theBuffer, aChildNode))) + { break; + } aGroupNode->AddNode(aChildNode); if (!isBracketed) + { break; + } } occ::handle aCoord; @@ -279,7 +315,9 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) { occ::handle aNode = anIt.Value(); if (aNode.IsNull()) + { continue; + } if (anIt.Value()->IsKind(STANDARD_TYPE(VrmlData_Coordinate))) { @@ -335,13 +373,17 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) { // Skip this tag if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == '{') { theBuffer.LinePtr++; if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { @@ -356,20 +398,27 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "center")) + { if (myIsTransform) + { aStatus = Scene().ReadXYZ(theBuffer, aCenter, true, false); + } else { aStatus = VrmlData_VrmlFormatError; break; } + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "rotation")) + { if (myIsTransform) { if (OK(aStatus, Scene().ReadXYZ(theBuffer, aRotAxis, false, false))) { if (aRotAxis.SquareModulus() < Precision::Confusion()) + { aRotAxis.SetZ(1.0); + } aStatus = Scene().ReadReal(theBuffer, aRotAngle, false, false); } } @@ -378,33 +427,46 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) aStatus = VrmlData_VrmlFormatError; break; } + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "scaleOrientation")) + { if (myIsTransform) { if (OK(aStatus, Scene().ReadXYZ(theBuffer, aScaleAxis, false, false))) + { aStatus = Scene().ReadReal(theBuffer, aScaleAngle, false, false); + } } else { aStatus = VrmlData_VrmlFormatError; break; } + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "scale")) + { if (myIsTransform) + { aStatus = Scene().ReadXYZ(theBuffer, aScale, false, true); + } else { aStatus = VrmlData_VrmlFormatError; break; } + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "translation")) + { if (myIsTransform) + { aStatus = Scene().ReadXYZ(theBuffer, aTrans, true, false); + } else { aStatus = VrmlData_VrmlFormatError; break; } + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "DEF")) { TCollection_AsciiString aWord; @@ -424,28 +486,39 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) std::ifstream aStream; const TCollection_AsciiString& aFileName = anIter.Value(); if (!OK(aStatus, openFile(aStream, aFileName))) + { break; + } VrmlData_Scene aScene(Scene().Allocator()); aScene.myLinearScale = Scene().myLinearScale; aScene.myVrmlDir = Scene().myVrmlDir; aScene << aStream; if (!OK(aStatus, aScene.Status())) + { break; + } VrmlData_Scene::Iterator anIterN = aScene.GetIterator(); for (; anIterN.More(); anIterN.Next()) + { if (!anIterN.Value()->IsKind(STANDARD_TYPE(VrmlData_WorldInfo))) + { AddNode(anIterN.Value()); + } + } VrmlData_Scene::Iterator anAllIter(aScene.myAllNodes); for (; anAllIter.More(); anAllIter.Next()) { const occ::handle& aNode = anAllIter.Value(); if (aNode->IsKind(STANDARD_TYPE(VrmlData_WorldInfo))) + { continue; + } const_cast(Scene()).myAllNodes.Append(aNode); aNode->myScene = &Scene(); // The name of the imported node should be prefixed by the URL // because each name must remain unique in the global scene. if (aNode->Name()) + { if (*aNode->Name() != '\0') { TCollection_AsciiString buf; @@ -465,20 +538,27 @@ VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer) memcpy(aNewName, buf.ToCString(), len); } } + } } } } } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } if (OK(aStatus)) { // Check if the Bounding Box has been imported @@ -533,12 +613,16 @@ VrmlData_ErrorStatus VrmlData_Group::openFile(Standard_IStream& the for (; aDirIter.More(); aDirIter.Next()) { if (!aDirIter.Value().IsAscii()) + { continue; + } const TCollection_AsciiString aFullName = TCollection_AsciiString(aDirIter.Value()) + theFilename; aStream.open(aFullName.ToCString(), std::ios::in); if (aStream.fail()) + { aStream.clear(); + } else { aStatus = VrmlData_StatusOK; @@ -549,10 +633,14 @@ VrmlData_ErrorStatus VrmlData_Group::openFile(Standard_IStream& the { aStream.open(theFilename.ToCString(), std::ios::in); if (!aStream.fail()) + { aStatus = VrmlData_StatusOK; + } } if (aStatus == VrmlData_EmptyData) + { aStatus = VrmlData_CannotOpenFile; + } return aStatus; } @@ -566,7 +654,9 @@ VrmlData_ErrorStatus VrmlData_Group::Write(const char* thePrefix) const const VrmlData_Scene& aScene = Scene(); bool isTransform = myIsTransform; if (isTransform && myTrsf.Form() == gp_Identity) + { isTransform = false; + } static const char* header[2] = {"Group {", "Transform {"}; if (OK(aStatus, aScene.WriteLine(thePrefix, header[isTransform ? 1 : 0], GlobalIndent()))) { diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedFaceSet.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedFaceSet.cxx index a6e2fa9949..10e6d1beb6 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedFaceSet.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedFaceSet.cxx @@ -50,17 +50,23 @@ VrmlData_ErrorStatus VrmlData_Faceted::readData(VrmlData_InBuffer& theBuffer) if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ccw")) { if (OK(aStatus, ReadBoolean(theBuffer, aBool))) + { myIsCCW = aBool; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "convex")) { if (OK(aStatus, ReadBoolean(theBuffer, aBool))) + { myIsConvex = aBool; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "solid")) { if (OK(aStatus, ReadBoolean(theBuffer, aBool))) + { myIsSolid = aBool; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "creaseAngle")) { @@ -68,9 +74,13 @@ VrmlData_ErrorStatus VrmlData_Faceted::readData(VrmlData_InBuffer& theBuffer) if (OK(aStatus, Scene().ReadReal(theBuffer, anAngle, false, false))) { if (anAngle < -Precision::Confusion() * 0.001) + { aStatus = VrmlData_IrrelevantNumber; + } else + { myCreaseAngle = anAngle; + } } } return aStatus; @@ -281,7 +291,9 @@ occ::handle VrmlData_IndexedFaceSet::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_IndexedFaceSet(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) { @@ -298,11 +310,17 @@ occ::handle VrmlData_IndexedFaceSet::Clone( // Create a dummy node to pass the different Scene instance to methods Clone const occ::handle aDummyNode = new VrmlData_UnknownNode(aResult->Scene()); if (!myCoords.IsNull()) + { aResult->SetCoordinates(occ::down_cast(myCoords->Clone(aDummyNode))); + } if (!myNormals.IsNull()) + { aResult->SetNormals(occ::down_cast(myNormals->Clone(aDummyNode))); + } if (!myColors.IsNull()) + { aResult->SetColors(occ::down_cast(myColors->Clone(aDummyNode))); + } // TODO: Replace the following lines with the relevant copying aResult->SetPolygons(myNbPolygons, myArrPolygons); aResult->SetNormalInd(myNbNormals, myArrNormalInd); @@ -323,13 +341,21 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (OK(aStatus, VrmlData_Faceted::readData(theBuffer))) + { continue; + } if (aStatus != VrmlData_EmptyData) + { break; + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorPerVertex")) + { aStatus = ReadBoolean(theBuffer, myColorPerVertex); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "normalPerVertex")) + { aStatus = ReadBoolean(theBuffer, myNormalPerVertex); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coordIndex")) { aStatus = aScene.ReadArrIndex(theBuffer, myArrPolygons, myNbPolygons); @@ -346,13 +372,19 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer) // } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorIndex")) + { aStatus = aScene.ReadArrIndex(theBuffer, myArrColorInd, myNbColors); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "normalIndex")) + { aStatus = aScene.ReadArrIndex(theBuffer, myArrNormalInd, myNbNormals); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "texCoordIndex")) + { aStatus = aScene.ReadArrIndex(theBuffer, myArrTextureInd, myNbTextures); - // These four checks should be the last one to avoid their interference - // with the other tokens (e.g., coordIndex) + // These four checks should be the last one to avoid their interference + // with the other tokens (e.g., coordIndex) + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "texCoord")) { occ::handle aNode; @@ -378,15 +410,19 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer) myNormals = occ::down_cast(aNode); } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus) || aStatus == VrmlData_EmptyData) + { if (OK(aStatus, readBrace(theBuffer))) { // Post-processing ; } + } return aStatus; } @@ -427,9 +463,13 @@ bool VrmlData_IndexedFaceSet::IsDefault() const { bool aResult(true); if (myNbPolygons) + { aResult = false; + } else if (!myCoords.IsNull()) + { aResult = myCoords->IsDefault(); + } return aResult; } @@ -445,11 +485,17 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Write(const char* thePrefix) const // Write the attributes of interface "VrmlData_Faceted" if (!IsCCW()) + { aStatus = aScene.WriteLine("ccw FALSE"); + } if (OK(aStatus) && !IsSolid()) + { aStatus = aScene.WriteLine("solid FALSE"); + } if (OK(aStatus) && !IsConvex()) + { aStatus = aScene.WriteLine("convex FALSE"); + } if (OK(aStatus) && CreaseAngle() > Precision::Confusion()) { char buf[64]; @@ -458,28 +504,48 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Write(const char* thePrefix) const } if (OK(aStatus) && !myCoords.IsNull()) + { aStatus = aScene.WriteNode("coord", myCoords); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("coordIndex", myArrPolygons, myNbPolygons); + } if (OK(aStatus) && !myNormalPerVertex) + { aStatus = aScene.WriteLine("normalPerVertex FALSE"); + } if (OK(aStatus) && !myNormals.IsNull()) + { aStatus = aScene.WriteNode("normal", myNormals); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("normalIndex", myArrNormalInd, myNbNormals); + } if (OK(aStatus) && !myColorPerVertex) + { aStatus = aScene.WriteLine("colorPerVertex FALSE"); + } if (OK(aStatus) && !myColors.IsNull()) + { aStatus = aScene.WriteNode("color", myColors); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("colorIndex", myArrColorInd, myNbColors); + } if (OK(aStatus) && !myTxCoords.IsNull()) + { aStatus = aScene.WriteNode("texCoord", myTxCoords); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("texCoordIndex", myArrTextureInd, myNbTextures); + } aStatus = WriteClosing(); } diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedLineSet.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedLineSet.cxx index ee5b7aa24d..ecbea2c1c7 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedLineSet.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_IndexedLineSet.cxx @@ -50,7 +50,9 @@ Quantity_Color VrmlData_IndexedLineSet::GetColor(const int /*iFace*/, const int const occ::handle& VrmlData_IndexedLineSet::TShape() { if (myNbPolygons == 0) + { myTShape.Nullify(); + } else if (myIsModified) { int i; @@ -89,7 +91,9 @@ occ::handle VrmlData_IndexedLineSet::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_IndexedLineSet(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) { @@ -103,9 +107,13 @@ occ::handle VrmlData_IndexedLineSet::Clone( // Create a dummy node to pass the different Scene instance to methods Clone const occ::handle aDummyNode = new VrmlData_UnknownNode(aResult->Scene()); if (!myCoords.IsNull()) + { aResult->SetCoordinates(occ::down_cast(myCoords->Clone(aDummyNode))); + } if (!myColors.IsNull()) + { aResult->SetColors(occ::down_cast(myColors->Clone(aDummyNode))); + } // TODO: Replace the following lines with the relevant copying aResult->SetPolygons(myNbPolygons, myArrPolygons); aResult->SetColorInd(myNbColors, myArrColorInd); @@ -126,13 +134,19 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorPerVertex")) + { aStatus = ReadBoolean(theBuffer, myColorPerVertex); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coordIndex")) + { aStatus = aScene.ReadArrIndex(theBuffer, myArrPolygons, myNbPolygons); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorIndex")) + { aStatus = aScene.ReadArrIndex(theBuffer, myArrColorInd, myNbColors); - // These two checks should be the last one to avoid their interference - // with the other tokens (e.g., coordIndex) + // These two checks should be the last one to avoid their interference + // with the other tokens (e.g., coordIndex) + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "color")) { occ::handle aNode; @@ -146,17 +160,23 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read(VrmlData_InBuffer& theBuffer) myCoords = occ::down_cast(aNode); } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus) || aStatus == VrmlData_EmptyData) + { if (OK(aStatus, readBrace(theBuffer))) { // Post-processing ; } + } return aStatus; } @@ -174,16 +194,26 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Write(const char* thePrefix) const { if (OK(aStatus) && !myCoords.IsNull()) + { aStatus = aScene.WriteNode("coord", myCoords); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("coordIndex", myArrPolygons, myNbPolygons); + } if (OK(aStatus) && !myColorPerVertex) + { aStatus = aScene.WriteLine("colorPerVertex FALSE"); + } if (OK(aStatus) && !myColors.IsNull()) + { aStatus = aScene.WriteNode("color", myColors); + } if (OK(aStatus)) + { aStatus = aScene.WriteArrIndex("colorIndex", myArrColorInd, myNbColors); + } aStatus = WriteClosing(); } @@ -200,8 +230,12 @@ bool VrmlData_IndexedLineSet::IsDefault() const { bool aResult(true); if (myNbPolygons) + { aResult = false; + } else if (!myCoords.IsNull()) + { aResult = myCoords->IsDefault(); + } return aResult; } diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Material.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Material.cxx index a1d11fc827..54a681652a 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Material.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Material.cxx @@ -164,7 +164,9 @@ occ::handle VrmlData_Material::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Material(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->SetAmbientIntensity(myAmbientIntensity); aResult->SetShininess(myShininess); @@ -217,15 +219,21 @@ VrmlData_ErrorStatus VrmlData_Material::Read(VrmlData_InBuffer& theBuffer) parseColor(aStatus, theBuffer, aColor[3], Scene()); } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } // Store the values in the Material node instance if (OK(aStatus)) diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Node.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Node.cxx index 083b796211..4dfb7a849c 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Node.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Node.cxx @@ -40,7 +40,9 @@ bool IsEqual(const occ::handle& theOne, const occ::handleName() != nullptr && theTwo->Name() != nullptr) + { aResult = (strcmp(theOne->Name(), theTwo->Name()) == 0); + } return aResult; } @@ -58,7 +60,9 @@ VrmlData_Node::VrmlData_Node(const VrmlData_Scene& theScene, const char* theName : myScene(&theScene) { if (theName == nullptr) + { theName = ""; + } setName(theName); } @@ -69,11 +73,17 @@ occ::handle VrmlData_Node::Clone(const occ::handle if (!theOther.IsNull()) { if (!theOther->IsKind(DynamicType())) + { return nullptr; + } if (&theOther->Scene() == myScene) + { theOther->myName = myName; + } else + { theOther->setName(myName); + } } return theOther; } @@ -84,12 +94,16 @@ void VrmlData_Node::setName(const char* theName, const char* theSuffix) { size_t len[2] = {strlen(theName) + 1, 0}; if (theSuffix) + { len[1] = strlen(theSuffix); + } char* aName = (char*)Scene().Allocator()->Allocate(len[0] + len[1]); myName = aName; memcpy(aName, theName, len[0]); if (len[1]) + { memcpy(&aName[len[0] - 1], theSuffix, len[1] + 1); + } } //================================================================================================= @@ -112,7 +126,9 @@ VrmlData_ErrorStatus VrmlData_Node::WriteClosing() const { VrmlData_ErrorStatus aResult = Scene().Status(); if (aResult == VrmlData_StatusOK || aResult == VrmlData_NotImplemented) + { aResult = Scene().WriteLine("}", nullptr, -GlobalIndent()); + } return aResult; } @@ -124,9 +140,13 @@ VrmlData_ErrorStatus VrmlData_Node::readBrace(VrmlData_InBuffer& theBuffer) if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (theBuffer.LinePtr[0] == '}') + { theBuffer.LinePtr++; + } else + { aStatus = VrmlData_VrmlFormatError; + } } return aStatus; } @@ -139,11 +159,17 @@ VrmlData_ErrorStatus VrmlData_Node::ReadBoolean(VrmlData_InBuffer& theBuffer, bo if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TRUE")) + { theResult = true; + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "FALSE")) + { theResult = false; + } else + { aStatus = VrmlData_BooleanInputError; + } } return aStatus; } @@ -159,7 +185,9 @@ VrmlData_ErrorStatus VrmlData_Node::ReadInteger(VrmlData_InBuffer& theBuffer, lo long aResult; aResult = strtol(theBuffer.LinePtr, &endptr, 10); if (endptr == theBuffer.LinePtr) + { aStatus = VrmlData_NumericInputError; + } else { theResult = aResult; @@ -178,14 +206,20 @@ VrmlData_ErrorStatus VrmlData_Node::ReadString(VrmlData_InBuffer& theBuffe if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (theBuffer.LinePtr[0] != '\"') + { aStatus = VrmlData_StringInputError; + } else { char* ptr = &theBuffer.LinePtr[1]; while (*ptr != '\0' && *ptr != '\"') + { ptr++; + } if (*ptr == '\0') + { aStatus = VrmlData_StringInputError; + } else { *ptr = '\0'; @@ -222,19 +256,27 @@ VrmlData_ErrorStatus VrmlData_Node::ReadMultiString( } TCollection_AsciiString aString; if (!OK(aStatus, ReadString(theBuffer, aString))) + { break; + } theResult.Append(aString); if (!isBracketed || !OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == ',') { theBuffer.LinePtr++; continue; } - else if (theBuffer.LinePtr[0] == ']') // closing bracket + else if (theBuffer.LinePtr[0] == ']') + { // closing bracket theBuffer.LinePtr++; + } else + { aStatus = VrmlData_VrmlFormatError; + } break; } } @@ -260,7 +302,9 @@ VrmlData_ErrorStatus VrmlData_Node::ReadNode(VrmlData_InBuffer& t { aNode = myScene->FindNode(aName.ToCString(), theType); if (aNode.IsNull()) + { aStatus = VrmlData_NodeNameUnknown; + } // else // aNode = aNode->Clone(0L); } @@ -269,12 +313,18 @@ VrmlData_ErrorStatus VrmlData_Node::ReadNode(VrmlData_InBuffer& t // We create a relevant node using the line with the type ID else if (OK(aStatus, const_cast(myScene)->createNode(theBuffer, aNode, theType))) + { if (!aNode.IsNull()) + { // The node data are read here, including the final closing brace aStatus = aNode->Read(theBuffer); + } + } if (aStatus == VrmlData_StatusOK) + { theNode = aNode; + } } return aStatus; } @@ -287,7 +337,9 @@ occ::handle VrmlData_ShapeNode::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_ShapeNode(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) { aResult->SetAppearance(myAppearance); @@ -298,9 +350,13 @@ occ::handle VrmlData_ShapeNode::Clone( // Create a dummy node to pass the different Scene instance to methods Clone const occ::handle aDummyNode = new VrmlData_UnknownNode(aResult->Scene()); if (!myAppearance.IsNull()) + { aResult->SetAppearance(occ::down_cast(myAppearance->Clone(aDummyNode))); + } if (!myGeometry.IsNull()) + { aResult->SetGeometry(occ::down_cast(myGeometry->Clone(aDummyNode))); + } } return aResult; } @@ -328,15 +384,21 @@ VrmlData_ErrorStatus VrmlData_ShapeNode::Read(VrmlData_InBuffer& theBuffer) // STANDARD_TYPE(VrmlData_Geometry)); } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -350,9 +412,13 @@ VrmlData_ErrorStatus VrmlData_ShapeNode::Write(const char* thePrefix) const if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent()))) { if (!myAppearance.IsNull()) + { aStatus = aScene.WriteNode("appearance", myAppearance); + } if (!myGeometry.IsNull() && OK(aStatus)) + { aStatus = aScene.WriteNode("geometry", myGeometry); + } aStatus = WriteClosing(); } @@ -365,7 +431,9 @@ bool VrmlData_ShapeNode::IsDefault() const { bool aResult(true); if (!myGeometry.IsNull()) + { aResult = myGeometry->IsDefault(); + } return aResult; } @@ -414,7 +482,9 @@ occ::handle VrmlData_Appearance::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_Appearance(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) { aResult->SetMaterial(myMaterial); @@ -426,12 +496,18 @@ occ::handle VrmlData_Appearance::Clone( // Create a dummy node to pass the different Scene instance to methods Clone const occ::handle aDummyNode = new VrmlData_UnknownNode(aResult->Scene()); if (!myMaterial.IsNull()) + { aResult->SetMaterial(occ::down_cast(myMaterial->Clone(aDummyNode))); + } if (!myTexture.IsNull()) + { aResult->SetTexture(occ::down_cast(myTexture->Clone(aDummyNode))); + } if (!myTTransform.IsNull()) + { aResult->SetTextureTransform( occ::down_cast(myTTransform->Clone(aDummyNode))); + } } return aResult; } @@ -463,15 +539,21 @@ VrmlData_ErrorStatus VrmlData_Appearance::Read(VrmlData_InBuffer& theBuffer) myTexture = occ::down_cast(aNode); } else + { break; + } if (!OK(aStatus)) + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -485,11 +567,17 @@ VrmlData_ErrorStatus VrmlData_Appearance::Write(const char* thePrefix) const if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent()))) { if (!myMaterial.IsNull()) + { aStatus = aScene.WriteNode("material", myMaterial); + } if (!myTexture.IsNull() && OK(aStatus)) + { aStatus = aScene.WriteNode("texture", myTexture); + } if (!myTTransform.IsNull() && OK(aStatus)) + { aStatus = aScene.WriteNode("textureTransform", myTTransform); + } aStatus = WriteClosing(); } @@ -502,11 +590,17 @@ bool VrmlData_Appearance::IsDefault() const { bool aResult(true); if (!myMaterial.IsNull()) + { aResult = myMaterial->IsDefault(); + } if (aResult && !myTexture.IsNull()) + { aResult = myTexture->IsDefault(); + } if (aResult && !myTTransform.IsNull()) + { aResult = myTTransform->IsDefault(); + } return aResult; } @@ -531,7 +625,9 @@ occ::handle VrmlData_ImageTexture::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_ImageTexture(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } aResult->myURL = myURL; return aResult; } @@ -546,16 +642,26 @@ VrmlData_ErrorStatus VrmlData_ImageTexture::Read(VrmlData_InBuffer& theBuffer) while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "url")) + { aStatus = ReadMultiString(theBuffer, myURL); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "repeatS")) + { aStatus = ReadBoolean(theBuffer, aRepeatS); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "repeatT")) + { aStatus = ReadBoolean(theBuffer, aRepeatT); + } else + { break; + } if (!OK(aStatus)) + { break; + } } if (OK(aStatus) && OK(aStatus, readBrace(theBuffer))) { diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Scene.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Scene.cxx index 364c937164..d2ff7d6f6a 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Scene.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_Scene.cxx @@ -82,6 +82,7 @@ const occ::handle& VrmlData_Scene::AddNode(const occ::handleIsKind(STANDARD_TYPE(VrmlData_WorldInfo))) { std::lock_guard aLock(myMutex); @@ -90,12 +91,19 @@ const occ::handle& VrmlData_Scene::AddNode(const occ::handleName()[0] != '\0') + { while (!myNamedNodes.Add(aNode)) + { aNode->setName(aNode->Name(), "D"); + } + } if (isTopLevel) + { myLstNodes.Append(aNode); + } return aNode; } + } static occ::handle aNullNode; aNullNode.Nullify(); return aNullNode; @@ -127,7 +135,9 @@ Standard_OStream& operator<<(Standard_OStream& theOutput, const VrmlData_Scene& { const VrmlData_ErrorStatus aStatus = aScene.WriteNode(nullptr, aNode); if (aStatus != VrmlData_StatusOK && aStatus != VrmlData_NotImplemented) + { break; + } } } @@ -145,7 +155,9 @@ Standard_OStream& operator<<(Standard_OStream& theOutput, const VrmlData_Scene& { const VrmlData_ErrorStatus aStatus = aScene.WriteNode(nullptr, aNode); if (aStatus != VrmlData_StatusOK && aStatus != VrmlData_NotImplemented) + { break; + } } } aScene.myOutput = nullptr; @@ -165,10 +177,13 @@ void VrmlData_Scene::SetVrmlDir(const TCollection_ExtendedString& theDir) } const char16_t aTerminator = aDir.Value(aDir.Length()); if (aTerminator != char16_t('\\') && aTerminator != char16_t('/')) + { #ifdef _WIN32 aDir += TCollection_ExtendedString("\\"); + } #else aDir += TCollection_ExtendedString("/"); + } #endif } @@ -254,8 +269,10 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadLine(VrmlData_InBuffer& theBuffer) if (*theBuffer.LinePtr != ' ' && *theBuffer.LinePtr != '\t' && *theBuffer.LinePtr != ',') { if (*theBuffer.LinePtr == '\n' || *theBuffer.LinePtr == '\r' || *theBuffer.LinePtr == '#') + { // go requesting the next line break; + } goto nonempty_line; } } @@ -276,7 +293,9 @@ nonempty_line: for (; *ptr != '\0'; ptr++) { if (anOffset) + { *ptr = ptr[anOffset]; + } if (*ptr == '\n' || *ptr == '\r' || *ptr == '#') { if (!isQuoted) @@ -286,9 +305,13 @@ nonempty_line: } } else if (*ptr == '\\' && isQuoted) + { ptr[0] = ptr[++anOffset]; + } else if (*ptr == '\"') + { isQuoted = !isQuoted; + } } theBuffer.IsProcessed = true; } @@ -338,7 +361,9 @@ VrmlData_Scene& VrmlData_Scene::operator<<(Standard_IStream& theInput) if (!VrmlData_Node::OK(myStatus, ReadLine(aBuffer))) { if (myStatus == VrmlData_EndOfFile) + { myStatus = VrmlData_StatusOK; + } break; } // this line provides the method ReadNode in the present context @@ -346,24 +371,32 @@ VrmlData_Scene& VrmlData_Scene::operator<<(Standard_IStream& theInput) myStatus = aNullNode->ReadNode(aBuffer, aNode); // Unknown nodes are not stored however they do not generate error if (myStatus != VrmlData_StatusOK) + { break; + } if (!aNode.IsNull() /*&& !aNode->IsKind (STANDARD_TYPE(VrmlData_UnknownNode))*/) { if (!aNode->IsKind(STANDARD_TYPE(VrmlData_WorldInfo))) + { myLstNodes.Append(aNode); + } else if (!aNode->IsDefault()) { const occ::handle aInfo = occ::down_cast(aNode); myWorldInfo->SetTitle(aInfo->Title()); NCollection_List::Iterator anIterInfo = aInfo->InfoIterator(); for (; anIterInfo.More(); anIterInfo.Next()) + { myWorldInfo->AddInfo(anIterInfo.Value()); + } } } } if (myStatus != VrmlData_StatusOK) + { myLineError = aBuffer.LineCount; + } return *this; } @@ -391,8 +424,10 @@ occ::handle VrmlData_Scene::FindNode( const occ::handle aDummyNode = new VrmlData_UnknownNode; aDummyNode->myName = theName; if (myNamedNodes.Contains(aDummyNode)) + { aResult = const_cast>&>(myNamedNodes).Added(aDummyNode); + } #endif return aResult; } @@ -408,7 +443,9 @@ occ::handle VrmlData_Scene::FindNode(const char* theName, gp_Trsf { const occ::handle& aNode = anIter.Value(); if (aNode.IsNull()) + { continue; + } // Match a top-level node name if (strcmp(aNode->Name(), theName) == 0) { @@ -424,7 +461,9 @@ occ::handle VrmlData_Scene::FindNode(const char* theName, gp_Trsf { aResult = aGroup->FindNode(theName, theLocation); if (!aResult.IsNull()) + { break; + } } } } @@ -442,10 +481,14 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadWord(VrmlData_InBuffer& theBuffer char* ptr = theBuffer.LinePtr; while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r' && *ptr != ' ' && *ptr != '\t' && *ptr != '{' && *ptr != '}' && *ptr != ',' && *ptr != '[' && *ptr != ']') + { ptr++; + } const int aLen = int(ptr - theBuffer.LinePtr); if (aLen <= 0) + { aStatus = VrmlData_StringInputError; + } else { theWord = TCollection_AsciiString((const char*)theBuffer.LinePtr, aLen); @@ -471,7 +514,9 @@ VrmlData_ErrorStatus VrmlData_Scene::createNode(VrmlData_InBuffer& if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "DEF")) { if (VrmlData_Node::OK(aStatus, ReadWord(theBuffer, aName))) + { aStatus = ReadLine(theBuffer); + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "NULL")) { @@ -485,54 +530,96 @@ VrmlData_ErrorStatus VrmlData_Scene::createNode(VrmlData_InBuffer& { // create the new node if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Appearance")) + { aNode = new VrmlData_Appearance(*this, strName); + } else if (!VRMLDATA_LCOMPARE_SKIP(theBuffer.LinePtr, "ShapeHints") && VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Shape")) + { aNode = new VrmlData_ShapeNode(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Box")) + { aNode = new VrmlData_Box(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Color")) + { aNode = new VrmlData_Color(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Cone")) + { aNode = new VrmlData_Cone(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Coordinate")) { aNode = new VrmlData_Coordinate(*this, strName); // Check for "Coordinate3" if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "3")) + { theBuffer.LinePtr++; + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Cylinder")) + { aNode = new VrmlData_Cylinder(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Group")) + { aNode = new VrmlData_Group(*this, strName, false); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Transform")) + { aNode = new VrmlData_Group(*this, strName, true); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Inline")) + { aNode = new VrmlData_Group(*this, strName, false); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Separator")) + { aNode = new VrmlData_Group(*this, strName, false); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Collision")) + { aNode = new VrmlData_Group(*this, strName, false); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Switch")) + { aNode = new VrmlData_Group(*this, strName, false); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ImageTexture")) + { aNode = new VrmlData_ImageTexture(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "IndexedFaceSet")) + { aNode = new VrmlData_IndexedFaceSet(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "IndexedLineSet")) + { aNode = new VrmlData_IndexedLineSet(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Material")) + { aNode = new VrmlData_Material(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Normal")) + { aNode = new VrmlData_Normal(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Sphere")) + { aNode = new VrmlData_Sphere(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TextureCoordinate")) + { aNode = new VrmlData_TextureCoordinate(*this, strName); + } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "WorldInfo")) + { aNode = new VrmlData_WorldInfo(*this, strName); + } else { void* isProto = VRMLDATA_LCOMPARE(theBuffer.LinePtr, "PROTO"); @@ -544,7 +631,9 @@ VrmlData_ErrorStatus VrmlData_Scene::createNode(VrmlData_InBuffer& if (aStatus == VrmlData_StatusOK) { if (theBuffer.LinePtr[0] != '[') + { aStatus = VrmlData_VrmlFormatError; + } else { theBuffer.LinePtr++; @@ -574,17 +663,25 @@ VrmlData_ErrorStatus VrmlData_Scene::createNode(VrmlData_InBuffer& } } if (aStatus == VrmlData_StatusOK) + { aNode = new VrmlData_UnknownNode(*this, strName, aTitle.ToCString()); + } } } aStatus = ReadLine(theBuffer); if (!aNode.IsNull()) { if (aNode->Name()[0] != '\0') + { myNamedNodes.Add(aNode); + } if (!theType.IsNull()) + { if (!aNode->IsKind(theType)) + { aStatus = VrmlData_VrmlFormatError; + } + } } if (aStatus == VrmlData_StatusOK) { @@ -647,7 +744,9 @@ void VrmlData_Scene::createShape( if (!aNodeGeom.IsNull()) { if (!aSingleShape.IsNull()) + { isSingleShape = false; + } const occ::handle aTShape = aNodeGeom->TShape(); aSingleShape.TShape(aTShape); if (!aSingleShape.IsNull()) @@ -660,7 +759,9 @@ void VrmlData_Scene::createShape( { // Check if the current topology is a single face if (aTShape->IsKind(STANDARD_TYPE(TopoDS_TFace))) + { pMapShapeApp->Bind(aTShape, anAppearance); + } else { // This is not a face, explode it in faces and bind each face @@ -693,7 +794,9 @@ void VrmlData_Scene::createShape( } } if (isSingleShape) + { outShape = aSingleShape; + } } //================================================================================================= @@ -710,9 +813,13 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadReal(VrmlData_InBuffer& theBuffer, char* endptr; aResult = Strtod(theBuffer.LinePtr, &endptr); if (endptr == theBuffer.LinePtr) + { aStatus = VrmlData_NumericInputError; + } else if (isOnlyPositive && aResult < 0.001 * Precision::Confusion()) + { aStatus = VrmlData_IrrelevantNumber; + } else { theResult = isScale ? (aResult * myLinearScale) : aResult; @@ -734,7 +841,9 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadXYZ(VrmlData_InBuffer& theBuffer, for (int i = 0; i < 3; i++) { if (!VrmlData_Node::OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } char* endptr; aVal[i] = Strtod(theBuffer.LinePtr, &endptr); if (endptr == theBuffer.LinePtr) @@ -778,7 +887,9 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadXY(VrmlData_InBuffer& theBuffer, for (int i = 0; i < 2; i++) { if (!VrmlData_Node::OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) + { break; + } char* endptr; aVal[i] = Strtod(theBuffer.LinePtr, &endptr); if (endptr == theBuffer.LinePtr) @@ -799,9 +910,13 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadXY(VrmlData_InBuffer& theBuffer, if (aStatus == VrmlData_StatusOK) { if (isScale) + { theXY.SetCoord(aVal[0] * myLinearScale, aVal[1] * myLinearScale); + } else + { theXY.SetCoord(aVal[0], aVal[1]); + } } return aStatus; } @@ -820,8 +935,10 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadArrIndex(VrmlData_InBuffer& theBuffer, theNBlocks = 0; if (VrmlData_Node::OK(aStatus, ReadLine(theBuffer))) { - if (theBuffer.LinePtr[0] != '[') // opening bracket + if (theBuffer.LinePtr[0] != '[') + { // opening bracket aStatus = VrmlData_VrmlFormatError; + } else { theBuffer.LinePtr++; @@ -840,10 +957,14 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadArrIndex(VrmlData_InBuffer& theBuffer, break; } if (!VrmlData_Node::OK(aStatus, VrmlData_Node::ReadInteger(theBuffer, anIntValue))) + { break; + } // Check for valid delimiter (']' or ',') if (!VrmlData_Node::OK(aStatus, ReadLine(theBuffer))) + { break; + } if (theBuffer.LinePtr[0] == ']') { theBuffer.LinePtr++; @@ -875,7 +996,9 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadArrIndex(VrmlData_InBuffer& theBuffer, } bufFace[0] = aLen; for (int i = 0; i < aLen; i++) + { bufFace[i + 1] = vecInt(i); + } vecInt.Clear(); vecIndice.Append(bufFace); } @@ -888,11 +1011,15 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadArrIndex(VrmlData_InBuffer& theBuffer, const int** anArray = static_cast(myAllocator->Allocate(aNbBlocks * sizeof(int*))); if (anArray == nullptr) + { aStatus = VrmlData_UnrecoverableError; + } else { for (size_t i = 0; i < aNbBlocks; i++) + { anArray[i] = vecIndice((int)i); + } theNBlocks = aNbBlocks; theArray = anArray; } @@ -942,7 +1069,9 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteArrIndex(const char* thePrefix, { Sprintf(ptr, "%d,", arrVal[i]); if (i == nVal - 1) + { break; + } ptr = strchr(ptr, ',') + 1; if ((ptr - &buf[0]) > (ptrdiff_t)aLineLimit) { @@ -955,7 +1084,9 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteArrIndex(const char* thePrefix, WriteLine(buf, iBlock < theNbBlocks - 1 ? "-1," : "-1"); } if (aStatus == VrmlData_StatusOK) + { aStatus = WriteLine("]", nullptr, -1); + } } } return aStatus; @@ -971,19 +1102,23 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteXYZ(const gp_XYZ& theXYZ, if (!IsDummyWrite()) { if (isApplyScale && myLinearScale > Precision::Confusion()) + { Sprintf(buf, "%.12g %.12g %.12g%s", theXYZ.X() / myLinearScale, theXYZ.Y() / myLinearScale, theXYZ.Z() / myLinearScale, thePostfix ? thePostfix : ""); + } else + { Sprintf(buf, "%.12g %.12g %.12g%s", theXYZ.X(), theXYZ.Y(), theXYZ.Z(), thePostfix ? thePostfix : ""); + } } return WriteLine(buf); } @@ -1001,16 +1136,24 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteLine(const char* theLin0, " "; VrmlData_ErrorStatus& aStatus = const_cast(myStatus); if (IsDummyWrite()) + { aStatus = VrmlData_StatusOK; + } else { int& aCurrentIndent = const_cast(myCurrentIndent); if (theIndent < 0) + { aCurrentIndent -= myIndent; + } if (aCurrentIndent < 0) + { aCurrentIndent = 0; + } if (theLin0 == nullptr && theLin1 == nullptr) + { (*myOutput) << "\n"; + } else { const int nSpaces = std::min(aCurrentIndent, static_cast(sizeof(spaces) - 1)); @@ -1019,22 +1162,32 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteLine(const char* theLin0, { (*myOutput) << theLin0; if (theLin1) + { (*myOutput) << " " << theLin1; + } } else + { (*myOutput) << theLin1; + } (*myOutput) << "\n"; } const int stat = myOutput->rdstate(); if (stat & std::ios::badbit) + { aStatus = VrmlData_UnrecoverableError; + } else if (stat & std::ios::failbit) + { // if (stat & std::ios::eofbit) // aStatus = VrmlData_EndOfFile; // else aStatus = VrmlData_GeneralError; + } if (theIndent > 0) + { aCurrentIndent += myIndent; + } } return myStatus; } @@ -1047,11 +1200,16 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteNode(const char* VrmlData_ErrorStatus aStatus(VrmlData_StatusOK); bool isNoName(false); if (theNode->Name() == nullptr) + { isNoName = true; + } else if (theNode->Name()[0] == '\0') + { isNoName = true; + } if (!theNode.IsNull()) + { if (!theNode->IsDefault()) { if (isNoName && IsDummyWrite()) @@ -1075,16 +1233,24 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteNode(const char* } } if (isNoName) + { aStatus = theNode->Write(thePrefix); + } else { // If the node name consists of blank characters, we do not write it const char* nptr = theNode->Name(); for (; *nptr != '\0'; nptr++) + { if (*nptr != ' ' && *nptr != '\t') + { break; + } + } if (*nptr == '\0') + { aStatus = theNode->Write(thePrefix); + } else { // Name is written under DEF clause @@ -1110,6 +1276,7 @@ VrmlData_ErrorStatus VrmlData_Scene::WriteNode(const char* } } } + } return aStatus; } @@ -1126,7 +1293,9 @@ void VrmlData_Scene::Dump(Standard_OStream& theStream) const */ Iterator anIter(myLstNodes); for (; anIter.More(); anIter.Next()) + { dumpNode(theStream, anIter.Value(), " "); + } } //======================================================================= @@ -1139,7 +1308,9 @@ void dumpNode(Standard_OStream& theStream, const TCollection_AsciiString& theIndent) { if (theNode.IsNull()) + { return; + } TCollection_AsciiString aNewIndent = theIndent.IsEmpty() ? theIndent : theIndent + " "; if (theNode->IsKind(STANDARD_TYPE(VrmlData_Appearance))) { @@ -1164,15 +1335,25 @@ void dumpNode(Standard_OStream& theStream, } } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Box))) + { dumpNodeHeader(theStream, theIndent, "Box", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Cylinder))) + { dumpNodeHeader(theStream, theIndent, "Cylinder", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Sphere))) + { dumpNodeHeader(theStream, theIndent, "Sphere", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Cone))) + { dumpNodeHeader(theStream, theIndent, "Cone", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Coordinate))) + { dumpNodeHeader(theStream, theIndent, "Coordinate", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Group))) { const occ::handle aGroup = occ::down_cast(theNode); @@ -1183,11 +1364,15 @@ void dumpNode(Standard_OStream& theStream, { NCollection_List>::Iterator anIter = aGroup->NodeIterator(); for (; anIter.More(); anIter.Next()) + { dumpNode(theStream, anIter.Value(), aNewIndent); + } } } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_ImageTexture))) + { dumpNodeHeader(theStream, theIndent, "ImageTexture", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_IndexedFaceSet))) { const occ::handle aNode = @@ -1220,11 +1405,17 @@ void dumpNode(Standard_OStream& theStream, dumpNodeHeader(theStream, theIndent, "Material", theNode->Name()); } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Normal))) + { dumpNodeHeader(theStream, theIndent, "Normal", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_TextureCoordinate))) + { dumpNodeHeader(theStream, theIndent, "TextureCoordinate", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_WorldInfo))) + { dumpNodeHeader(theStream, theIndent, "WorldInfo", theNode->Name()); + } else if (theNode->IsKind(STANDARD_TYPE(VrmlData_UnknownNode))) { const occ::handle anUnknown = @@ -1244,7 +1435,11 @@ void dumpNodeHeader(Standard_OStream& theStream, { theStream << theIndent << theType << " node"; if (theName[0] == '\0') + { theStream << "\n"; + } else + { theStream << ": \"" << theName << "\"\n"; + } } diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_ShapeConvert.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_ShapeConvert.cxx index e3af3571e6..de2b540a05 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_ShapeConvert.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_ShapeConvert.cxx @@ -75,11 +75,17 @@ void VrmlData_ShapeConvert::AddShape(const TopoDS_Shape& theShape, const char* t break; } if (sym == '\"' || sym == '\\') + { *optr = '/'; + } else if (sym == '.') + { *optr = '_'; + } else + { *optr = sym; + } if (++optr >= eptr) { *optr = '\0'; @@ -124,11 +130,15 @@ occ::handle VrmlData_ShapeConvert::makeTShapeNode( aTestedShapeRev.Orientation(isReverse ? TopAbs_FORWARD : TopAbs_REVERSED); occ::handle aFaceSetToReuse; if (myRelMap.IsBound(aTestedShapeRev)) + { aFaceSetToReuse = occ::down_cast(myRelMap(aTestedShapeRev)); + } occ::handle aCoordToReuse; if (!aFaceSetToReuse.IsNull()) + { aCoordToReuse = aFaceSetToReuse->Coordinates(); + } aTShapeNode = triToIndexedFaceSet(aTri, aFace, aCoordToReuse); myScene.AddNode(aTShapeNode, false); @@ -269,7 +279,9 @@ void VrmlData_ShapeConvert::Convert(const bool theExtractFaces, { if (!Extract[i]) + { continue; + } TopExp_Explorer anExp(aData.Shape, ShapeType[i]); for (; anExp.More(); anExp.Next()) @@ -286,8 +298,10 @@ void VrmlData_ShapeConvert::Convert(const bool theExtractFaces, myScene.AddNode(aShapeNode, false); aShapeNode->SetGeometry(aTShapeNode); if (aLoc.IsIdentity()) + { // Store the shape node directly into the main Group. aGroup->AddNode(aShapeNode); + } else { // Create a Transform grouping node @@ -375,7 +389,9 @@ occ::handle VrmlData_ShapeConvert::triToIndexedFaceSet( // Create the Coordinates node if (!theCoord.IsNull()) + { aFaceSet->SetCoordinates(theCoord); + } else { gp_XYZ* arrNodes = static_cast(anAlloc->Allocate(nNodes * sizeof(gp_XYZ))); @@ -444,23 +460,35 @@ occ::handle VrmlData_ShapeConvert::triToIndexedFaceSet( double mod = vv.Modulus(); if (mod < Tol) + { continue; + } eqPlan += vv / mod; } if (eqPlan.SquareModulus() > gp::Resolution()) + { aNormal = gp_Dir(eqPlan); + } } if (isReverse) + { aNormal.Reverse(); + } if (aNormal.X() * aNormal.X() < aConf2) + { aNormal.SetX(0.); + } if (aNormal.Y() * aNormal.Y() < aConf2) + { aNormal.SetY(0.); + } if (aNormal.Z() * aNormal.Z() < aConf2) + { aNormal.SetZ(0.); + } arrVec[i] = aNormal.XYZ(); } @@ -499,13 +527,17 @@ occ::handle VrmlData_ShapeConvert::polToIndexedLineSet( int* aPolygon = static_cast(anAlloc->Allocate((nNodes + 1) * sizeof(int))); aPolygon[0] = nNodes; for (i = 1; i <= nNodes; i++) + { aPolygon[i] = i - 1; + } arrPolygons[0] = aPolygon; // Create the Coordinates node gp_XYZ* arrNodes = static_cast(anAlloc->Allocate(nNodes * sizeof(gp_XYZ))); for (i = 0; i < nNodes; i++) + { arrNodes[i] = arrPolyNodes(i + 1).XYZ() * myScale; + } const occ::handle aCoordNode = new VrmlData_Coordinate(myScene, nullptr, nNodes, arrNodes); diff --git a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_WorldInfo.cxx b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_WorldInfo.cxx index 1cea9aeb61..5d7c670824 100644 --- a/src/DataExchange/TKDEVRML/VrmlData/VrmlData_WorldInfo.cxx +++ b/src/DataExchange/TKDEVRML/VrmlData/VrmlData_WorldInfo.cxx @@ -40,12 +40,16 @@ VrmlData_WorldInfo::VrmlData_WorldInfo(const VrmlData_Scene& theScene, void VrmlData_WorldInfo::SetTitle(const char* theString) { if (theString == nullptr) + { myTitle = nullptr; + } else { const size_t len = strlen(theString) + 1; if (len == 1) + { myTitle = nullptr; + } else { myTitle = static_cast(Scene().Allocator()->Allocate(len)); @@ -62,6 +66,7 @@ void VrmlData_WorldInfo::SetTitle(const char* theString) void VrmlData_WorldInfo::AddInfo(const char* theString) { if (theString != nullptr) + { if (*theString != '\0') { const size_t len = strlen(theString) + 1; @@ -69,6 +74,7 @@ void VrmlData_WorldInfo::AddInfo(const char* theString) memcpy(aStr, theString, len); myInfo.Append(aStr); } + } } //================================================================================================= @@ -79,7 +85,9 @@ occ::handle VrmlData_WorldInfo::Clone( occ::handle aResult = occ::down_cast(VrmlData_Node::Clone(theOther)); if (aResult.IsNull()) + { aResult = new VrmlData_WorldInfo(theOther.IsNull() ? Scene() : theOther->Scene(), Name()); + } if (&aResult->Scene() == &Scene()) { @@ -91,7 +99,9 @@ occ::handle VrmlData_WorldInfo::Clone( aResult->SetTitle(myTitle); NCollection_List::Iterator anIter(myInfo); for (; anIter.More(); anIter.Next()) + { aResult->AddInfo(anIter.Value()); + } } return aResult; } @@ -111,7 +121,9 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Read(VrmlData_InBuffer& theBuffer) { TCollection_AsciiString aTitleString; if (OK(aStatus, ReadString(theBuffer, aTitleString))) + { SetTitle(aTitleString.ToCString()); + } } else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "info")) { @@ -120,16 +132,22 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Read(VrmlData_InBuffer& theBuffer) { NCollection_List::Iterator anIter(lstInfo); for (; anIter.More(); anIter.Next()) + { AddInfo(anIter.Value().ToCString()); + } } } else + { break; + } } // Read the terminating (closing) brace if (OK(aStatus)) + { aStatus = readBrace(theBuffer); + } return aStatus; } @@ -162,9 +180,13 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Write(const char* thePrefix) const Sprintf(buf, "\"%s\"", anIter.Value()); anIter.Next(); if (anIter.More()) + { aStatus = aScene.WriteLine(buf, ","); + } else + { aStatus = aScene.WriteLine(buf); + } } } aStatus = aScene.WriteLine("]", nullptr, -GlobalIndent()); diff --git a/src/DataExchange/TKXCAF/XCAFApp/XCAFApp_Application.cxx b/src/DataExchange/TKXCAF/XCAFApp/XCAFApp_Application.cxx index f7391c5f2f..7155913c88 100644 --- a/src/DataExchange/TKXCAF/XCAFApp/XCAFApp_Application.cxx +++ b/src/DataExchange/TKXCAF/XCAFApp/XCAFApp_Application.cxx @@ -29,7 +29,9 @@ occ::handle XCAFApp_Application::GetApplication() { static occ::handle locApp; if (locApp.IsNull()) + { locApp = new XCAFApp_Application; + } return locApp; } diff --git a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx index 088f0806da..ac10d822f7 100644 --- a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx +++ b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx @@ -75,7 +75,9 @@ void XCAFDimTolObjects_DatumObject::SetSemanticName( occ::handle XCAFDimTolObjects_DatumObject::GetName() const { if (myName.IsNull()) + { return new TCollection_HAsciiString(); + } return myName; } diff --git a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx index 25abfe272e..4bf252900b 100644 --- a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx +++ b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx @@ -149,7 +149,9 @@ XCAFDimTolObjects_DimensionType XCAFDimTolObjects_DimensionObject::GetType() con double XCAFDimTolObjects_DimensionObject::GetValue() const { if (myVal.IsNull()) + { return 0; + } // Simple value or value with Plus_Minus_Tolerance if (myVal->Length() == 1 || myVal->Length() == 3) @@ -199,7 +201,9 @@ bool XCAFDimTolObjects_DimensionObject::IsDimWithRange() const void XCAFDimTolObjects_DimensionObject::SetUpperBound(const double theUpperBound) { if (!myVal.IsNull() && myVal->Length() > 1) + { myVal->SetValue(2, theUpperBound); + } else { myVal = new NCollection_HArray1(1, 2); @@ -213,7 +217,9 @@ void XCAFDimTolObjects_DimensionObject::SetUpperBound(const double theUpperBound void XCAFDimTolObjects_DimensionObject::SetLowerBound(const double theLowerBound) { if (!myVal.IsNull() && myVal->Length() > 1) + { myVal->SetValue(1, theLowerBound); + } else { myVal = new NCollection_HArray1(1, 2); @@ -429,7 +435,9 @@ bool XCAFDimTolObjects_DimensionObject::SetDirection(const gp_Dir& theDir) void XCAFDimTolObjects_DimensionObject::RemoveDescription(const int theNumber) { if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper()) + { return; + } NCollection_DynamicArray> aDescriptions; NCollection_DynamicArray> aDescriptionNames; for (int i = aDescriptions.Lower(); i < theNumber; i++) @@ -559,7 +567,9 @@ void XCAFDimTolObjects_DimensionObject::DumpJson(Standard_OStream& theOStream, i aDescIt.Next()) { if (aDescIt.Value().IsNull()) + { continue; + } const char* aDescription = aDescIt.Value()->ToCString(); OCCT_DUMP_FIELD_VALUE_STRING(theOStream, aDescription) } @@ -570,7 +580,9 @@ void XCAFDimTolObjects_DimensionObject::DumpJson(Standard_OStream& theOStream, i aDescNameIt.Next()) { if (aDescNameIt.Value().IsNull()) + { continue; + } const char* aDescriptionName = aDescNameIt.Value()->ToCString(); OCCT_DUMP_FIELD_VALUE_STRING(theOStream, aDescriptionName) } diff --git a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_Tool.cxx b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_Tool.cxx index 7feda9b4be..33fc63483f 100644 --- a/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_Tool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDimTolObjects/XCAFDimTolObjects_Tool.cxx @@ -110,7 +110,9 @@ bool XCAFDimTolObjects_Tool::GetRefDimensions( { occ::handle aDimension; if (aSeq.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) + { theDimensionObjectSequence.Append(aDimension->GetObject()); + } } return true; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc.cxx index f7adcc8f3b..b0986b59ea 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc.cxx @@ -256,19 +256,33 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& { const char* type = ""; if (theAtt->ID() == XCAFDoc::ShapeRefGUID()) + { type = "Shape Instance Link"; + } else if (theAtt->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen)) + { type = "Generic Color Link"; + } else if (theAtt->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf)) + { type = "Surface Color Link"; + } else if (theAtt->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv)) + { type = "Curve Color Link"; + } else if (theAtt->ID() == XCAFDoc::DimTolRefGUID()) + { type = "DGT Link"; + } else if (theAtt->ID() == XCAFDoc::DatumRefGUID()) + { type = "Datum Link"; + } else if (theAtt->ID() == XCAFDoc::MaterialRefGUID()) + { type = "Material Link"; + } occ::handle TN = occ::down_cast(theAtt); TCollection_AsciiString ref; if (TN->HasFather()) @@ -286,7 +300,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& { TDF_Tool::Entry(child->Label(), ref); if (child != TN->First()) + { anInfo += ", "; + } anInfo += ref; child = child->Next(); } @@ -343,7 +359,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { anInfo += TCollection_AsciiString(", "); + } anInfo += TCollection_AsciiString(val->Value(j)); } } @@ -353,7 +371,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { anInfo += TCollection_AsciiString(", "); + } anInfo += TCollection_AsciiString(val->Value(j)); } } @@ -363,7 +383,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { anInfo += TCollection_AsciiString(", "); + } anInfo += TCollection_AsciiString(val->Value(j)); } } @@ -372,11 +394,17 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& occ::handle val = occ::down_cast(theAtt); TopoDS_Shape S = val->Get(); if (!S.IsNull()) + { anInfo = S.TShape()->DynamicType()->Name(); + } else + { anInfo = "Empty Shape"; + } if (!S.Location().IsIdentity()) + { anInfo += TCollection_AsciiString("(located)"); + } } else if (theAtt->IsKind(STANDARD_TYPE(XCAFDoc_ShapeMapTool))) { @@ -409,9 +437,13 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& else if (theAtt->IsKind(STANDARD_TYPE(TDataStd_UAttribute))) { if (theAtt->ID() == XCAFDoc::AssemblyGUID()) + { anInfo += TCollection_AsciiString("is assembly"); + } if (theAtt->ID() == XCAFDoc::InvisibleGUID()) + { anInfo += TCollection_AsciiString("invisible"); + } } else if (theAtt->IsKind(STANDARD_TYPE(XCAFDoc_Color))) { @@ -522,7 +554,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& double dens = val->GetDensity(); const char* dimdens = "g/cu sm"; if (dens == 0) + { anInfo = val->GetName()->ToCString(); + } else { anInfo = val->GetName()->ToCString(); @@ -576,7 +610,9 @@ TCollection_AsciiString XCAFDoc::AttributeInfo(const occ::handle& type = "View Clipping Plane Link"; } else + { return TCollection_AsciiString(); + } occ::handle DETGN = occ::down_cast(theAtt); TCollection_AsciiString ref; diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Area.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Area.cxx index c2492b40b5..6bfe570f24 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Area.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Area.cxx @@ -77,7 +77,9 @@ bool XCAFDoc_Area::Get(const TDF_Label& label, double& area) { occ::handle anArea; if (!label.FindAttribute(XCAFDoc_Area::GetID(), anArea)) + { return false; + } area = anArea->Get(); return true; diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyGraph.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyGraph.cxx index e714f0b68c..e9e7ea4d6e 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyGraph.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyGraph.cxx @@ -62,7 +62,9 @@ XCAFDoc_AssemblyGraph::XCAFDoc_AssemblyGraph(const TDF_Label& theLabel) bool XCAFDoc_AssemblyGraph::IsDirectLink(const int theNode1, const int theNode2) const { if (!HasChildren(theNode1)) + { return false; + } return GetChildren(theNode1).Contains(theNode2); } @@ -73,7 +75,9 @@ XCAFDoc_AssemblyGraph::NodeType XCAFDoc_AssemblyGraph::GetNodeType(const int the { const NodeType* typePtr = myNodeTypes.Seek(theNode); if (typePtr == nullptr) + { return NodeType_UNDEFINED; + } return (*typePtr); } @@ -99,7 +103,9 @@ int XCAFDoc_AssemblyGraph::NbOccurrences(const int theNode) const { const int* aUsageOQPtr = myUsages.Seek(theNode); if (aUsageOQPtr == nullptr) + { return 0; + } return (*aUsageOQPtr); } @@ -114,9 +120,13 @@ void XCAFDoc_AssemblyGraph::buildGraph(const TDF_Label& theLabel) // We start from those shapes which are "free" in terms of XDE. NCollection_Sequence aRoots; if (theLabel.IsNull() || (myShapeTool->Label() == theLabel)) + { myShapeTool->GetFreeShapes(aRoots); + } else + { aRoots.Append(theLabel); + } for (NCollection_Sequence::Iterator it(aRoots); it.More(); it.Next()) { @@ -134,18 +144,24 @@ void XCAFDoc_AssemblyGraph::buildGraph(const TDF_Label& theLabel) { aRootId = addNode(aLabel, 0); if (aRootId == 0) + { continue; + } anIdToProceed = addNode(anOriginal, aRootId); } if (aRootId == 0 || anIdToProceed == 0) + { continue; + } myRoots.Add(aRootId); // Add components (the objects nested into the current one). if (myShapeTool->IsAssembly(anOriginal)) + { addComponents(anOriginal, anIdToProceed); + } } } @@ -172,25 +188,35 @@ void XCAFDoc_AssemblyGraph::addComponents(const TDF_Label& theParent, const int // Add component const int aComponentId = addNode(aComponent, theParentId); if (aComponentId == 0) + { continue; + } // Protection against deleted empty labels (after expand compounds, for example). occ::handle aJumpNode; if (!aComponent.FindAttribute(XCAFDoc::ShapeRefGUID(), aJumpNode)) + { continue; + } // Jump to the referred object (the original). TDF_Label aChildOriginal; if (!aJumpNode.IsNull() && aJumpNode->HasFather()) + { aChildOriginal = aJumpNode->Father()->Label(); // Declaration-level origin. + } if (aChildOriginal.IsNull()) + { continue; + } // Add child const int aChildId = addNode(aChildOriginal, aComponentId); if (aChildId == 0) + { continue; + } // Process children: add components recursively. addComponents(aChildOriginal, aChildId); @@ -205,9 +231,13 @@ int XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel, const int theParen if (myShapeTool->IsAssembly(theLabel)) { if (myShapeTool->IsFree(theLabel)) + { aNodeType = NodeType_AssemblyRoot; + } else + { aNodeType = NodeType_Subassembly; + } } else if (myShapeTool->IsReference(theLabel)) { @@ -223,7 +253,9 @@ int XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel, const int theParen } if (aNodeType == NodeType_UNDEFINED) + { return 0; + } // Get ID of the insertion-level node in the abstract assembly graph. const int aChildId = myNodes.Add(theLabel); @@ -234,9 +266,13 @@ int XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel, const int theParen // Bind usage occurrences. int* aUsageOQPtr = myUsages.ChangeSeek(aChildId); if (aUsageOQPtr == nullptr) + { aUsageOQPtr = myUsages.Bound(aChildId, 1); + } else + { ++(*aUsageOQPtr); + } } if (theParentId > 0) @@ -244,7 +280,9 @@ int XCAFDoc_AssemblyGraph::addNode(const TDF_Label& theLabel, const int theParen // Add link TColStd_PackedMapOfInteger* aMapPtr = myAdjacencyMap.ChangeSeek(theParentId); if (aMapPtr == nullptr) + { aMapPtr = myAdjacencyMap.Bound(theParentId, TColStd_PackedMapOfInteger()); + } (*aMapPtr).Add(aChildId); } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemId.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemId.cxx index d15b71d6fa..af72d0192a 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemId.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemId.cxx @@ -43,7 +43,9 @@ void XCAFDoc_AssemblyItemId::Init(const TCollection_AsciiString& theString) { TCollection_AsciiString anEntry = theString.Token("/", iEntry); if (anEntry.IsEmpty()) + { break; + } myPath.Append(anEntry); } @@ -62,13 +64,17 @@ void XCAFDoc_AssemblyItemId::Nullify() bool XCAFDoc_AssemblyItemId::IsChild(const XCAFDoc_AssemblyItemId& theOther) const { if (myPath.Size() <= theOther.myPath.Size()) + { return false; + } NCollection_List::Iterator anIt(myPath), anItOther(theOther.myPath); for (; anItOther.More(); anIt.Next(), anItOther.Next()) { if (anIt.Value() != anItOther.Value()) + { return false; + } } return true; @@ -82,16 +88,22 @@ bool XCAFDoc_AssemblyItemId::IsDirectChild(const XCAFDoc_AssemblyItemId& theOthe bool XCAFDoc_AssemblyItemId::IsEqual(const XCAFDoc_AssemblyItemId& theOther) const { if (this == &theOther) + { return true; + } if (myPath.Size() != theOther.myPath.Size()) + { return false; + } NCollection_List::Iterator anIt(myPath), anItOther(theOther.myPath); for (; anIt.More() && anItOther.More(); anIt.Next(), anItOther.Next()) { if (anIt.Value() != anItOther.Value()) + { return false; + } } return true; diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx index c8a4d6fd80..96c7c29e3e 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx @@ -104,26 +104,36 @@ XCAFDoc_AssemblyItemRef::XCAFDoc_AssemblyItemRef() bool XCAFDoc_AssemblyItemRef::IsOrphan() const { if (myItemId.IsNull()) + { return true; + } TDF_Label aRoot = Label().Root(); occ::handle anOwner; if (!aRoot.FindAttribute(TDocStd_Owner::GetID(), anOwner)) + { return true; + } occ::handle aDoc = anOwner->GetDocument(); if (aDoc.IsNull()) + { return true; + } occ::handle aData = aDoc->GetData(); if (aData.IsNull()) + { return true; + } TDF_Label aLabel; TDF_Tool::Label(aData, myItemId.GetPath().Last(), aLabel); if (aLabel.IsNull()) + { return true; + } if (HasExtraRef()) { @@ -131,20 +141,26 @@ bool XCAFDoc_AssemblyItemRef::IsOrphan() const { occ::handle anAttr; if (!aLabel.FindAttribute(GetGUID(), anAttr)) + { return true; + } } else if (IsSubshapeIndex()) { occ::handle aNamedShape; if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape)) + { return true; + } TopoDS_Shape aShape = aNamedShape->Get(); NCollection_IndexedMap aMap; TopExp::MapShapes(aShape, aMap); int aSubshapeIndex = GetSubshapeIndex(); if (aSubshapeIndex < 1 || aMap.Length() < aSubshapeIndex) + { return true; + } } } @@ -174,17 +190,25 @@ const XCAFDoc_AssemblyItemId& XCAFDoc_AssemblyItemRef::GetItem() const Standard_GUID XCAFDoc_AssemblyItemRef::GetGUID() const { if (IsGUID()) + { return Standard_GUID(myExtraId.ToCString()); + } else + { return Standard_GUID(); + } } int XCAFDoc_AssemblyItemRef::GetSubshapeIndex() const { if (IsSubshapeIndex()) + { return myExtraId.IntegerValue(); + } else + { return 0; + } } void XCAFDoc_AssemblyItemRef::SetItem(const XCAFDoc_AssemblyItemId& theItemId) @@ -273,9 +297,13 @@ Standard_OStream& XCAFDoc_AssemblyItemRef::Dump(Standard_OStream& theOS) const { theOS << "Path: " << myItemId.ToString(); if (IsGUID()) + { theOS << "/GUID:" << myExtraId; + } else if (IsSubshapeIndex()) + { theOS << "/Subshape: " << myExtraId; + } return theOS; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyIterator.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyIterator.cxx index b0083f0139..81efe30b93 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyIterator.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_AssemblyIterator.cxx @@ -75,7 +75,9 @@ XCAFDoc_AssemblyIterator::XCAFDoc_AssemblyIterator(const occ::handleGetData(), theRoot.GetPath().Last(), aSeed.myLabel); if (aSeed.myLabel.IsNull()) + { return; + } TDF_Label anOriginal; if (myShapeTool->GetReferredShape(aSeed.myLabel, anOriginal)) @@ -114,7 +116,9 @@ bool XCAFDoc_AssemblyIterator::More() const void XCAFDoc_AssemblyIterator::Next() { if (!More()) + { return; // No next item. + } // Pop item AuxAssemblyItem aCurrent = myFringe.Last(); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Centroid.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Centroid.cxx index 81b1f2f294..25dc673b91 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Centroid.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Centroid.cxx @@ -71,7 +71,9 @@ bool XCAFDoc_Centroid::Get(const TDF_Label& label, gp_Pnt& pnt) { occ::handle aCentroid; if (!label.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) + { return false; + } pnt = aCentroid->Get(); return true; diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ClippingPlaneTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ClippingPlaneTool.cxx index 21eaaecaee..11b4d0ecee 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ClippingPlaneTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ClippingPlaneTool.cxx @@ -42,7 +42,9 @@ TDF_Label XCAFDoc_ClippingPlaneTool::BaseLabel() const bool XCAFDoc_ClippingPlaneTool::IsClippingPlane(const TDF_Label& theLabel) const { if (theLabel.Father() != Label()) + { return false; + } occ::handle aPlaneAttribute; return theLabel.FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttribute); @@ -56,20 +58,28 @@ bool XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& the bool& theCapping) const { if (theLabel.Father() != Label()) + { return false; + } occ::handle aPlaneAttribute; if (!theLabel.FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttribute)) + { return false; + } TDataXtd_Geometry::Plane(aPlaneAttribute->Label(), thePlane); occ::handle aNameAttribute; if (theLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttribute)) + { theName = aNameAttribute->Get(); + } occ::handle aCappingAttribute; if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute)) + { theCapping = (aCappingAttribute->Get() == 1); + } return true; } @@ -83,7 +93,9 @@ bool XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& { TCollection_ExtendedString anExtName; if (!GetClippingPlane(theLabel, thePlane, anExtName, theCapping)) + { return false; + } theName = new TCollection_HAsciiString(anExtName); return true; } @@ -104,13 +116,21 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane( bool aCapping; GetClippingPlane(aClippingPlanes.Value(i), aPlane, aName, aCapping); if (!aName.IsEqual(theName)) + { continue; + } if (aPlane.Axis().Angle(thePlane.Axis()) > Precision::Angular()) + { continue; + } if (aPlane.XAxis().Angle(thePlane.XAxis()) > Precision::Angular()) + { continue; + } if (aPlane.YAxis().Angle(thePlane.YAxis()) > Precision::Angular()) + { continue; + } return aClippingPlanes.Value(i); } @@ -120,7 +140,9 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane( TDataXtd_Plane::Set(aLabel, thePlane); if (!theName.IsEmpty()) + { TDataStd_Name::Set(aLabel, theName); + } return aLabel; } @@ -165,7 +187,9 @@ bool XCAFDoc_ClippingPlaneTool::RemoveClippingPlane(const TDF_Label& theLabel) c { occ::handle Node; if (!IsClippingPlane(theLabel) || theLabel.FindAttribute(XCAFDoc::ViewRefPlaneGUID(), Node)) + { return false; + } theLabel.ForgetAllAttributes(true); return true; @@ -182,7 +206,9 @@ void XCAFDoc_ClippingPlaneTool::GetClippingPlanes(NCollection_SequenceLabel(); if (IsClippingPlane(aLabel)) + { theLabels.Append(aLabel); + } } } @@ -193,11 +219,15 @@ void XCAFDoc_ClippingPlaneTool::UpdateClippingPlane(const TDF_Label& const TCollection_ExtendedString& theName) const { if (theLabel.Father() != Label()) + { return; + } occ::handle aPlaneAttribute; if (!theLabel.FindAttribute(TDataXtd_Plane::GetID(), aPlaneAttribute)) + { return; + } theLabel.ForgetAttribute(TDataXtd_Plane::GetID()); TDataXtd_Plane::Set(theLabel, thePlane); theLabel.ForgetAttribute(TDataStd_Name::GetID()); @@ -210,7 +240,9 @@ void XCAFDoc_ClippingPlaneTool::SetCapping(const TDF_Label& theClippingPlaneL, const bool theCapping) { if (theClippingPlaneL.Father() != Label()) + { return; + } theClippingPlaneL.ForgetAttribute(TDataStd_Integer::GetID()); int aCappingVal = (theCapping) ? 1 : 0; @@ -222,11 +254,15 @@ void XCAFDoc_ClippingPlaneTool::SetCapping(const TDF_Label& theClippingPlaneL, bool XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClippingPlaneL) const { if (theClippingPlaneL.Father() != Label()) + { return false; + } occ::handle aCappingAttribute; if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute)) + { return (aCappingAttribute->Get() == 1); + } return false; } @@ -237,7 +273,9 @@ bool XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClippingPlaneL, bool& theCapping) const { if (theClippingPlaneL.Father() != Label()) + { return false; + } occ::handle aCappingAttribute; if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute)) diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ColorTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ColorTool.cxx index de0c74048a..fe4cec8f79 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ColorTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ColorTool.cxx @@ -58,7 +58,9 @@ TDF_Label XCAFDoc_ColorTool::BaseLabel() const const occ::handle& XCAFDoc_ColorTool::ShapeTool() { if (myShapeTool.IsNull()) + { myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label()); + } return myShapeTool; } @@ -77,7 +79,9 @@ bool XCAFDoc_ColorTool::GetColor(const TDF_Label& lab, Quantity_Color& col) Quantity_ColorRGBA aCol; bool isDone = GetColor(lab, aCol); if (isDone) + { col = aCol.GetRGB(); + } return isDone; } @@ -87,7 +91,9 @@ bool XCAFDoc_ColorTool::GetColor(const TDF_Label& lab, Quantity_ColorRGBA& col) { occ::handle ColorAttribute; if (!lab.FindAttribute(XCAFDoc_Color::GetID(), ColorAttribute)) + { return false; + } col = ColorAttribute->GetColorRGBA(); @@ -113,7 +119,9 @@ bool XCAFDoc_ColorTool::FindColor(const Quantity_ColorRGBA& col, TDF_Label& lab) TDF_Label aLabel = it.Value()->Label(); Quantity_ColorRGBA C; if (!GetColor(aLabel, C)) + { continue; + } if (C.IsEqual(col)) { lab = aLabel; @@ -195,7 +203,9 @@ void XCAFDoc_ColorTool::GetColors(NCollection_Sequence& Labels) const { TDF_Label L = ChildIDIterator.Value()->Label(); if (IsColor(L)) + { Labels.Append(L); + } } } @@ -256,7 +266,9 @@ bool XCAFDoc_ColorTool::GetColor(const TDF_Label& L, { occ::handle Node; if (!L.FindAttribute(XCAFDoc::ColorRefGUID(type), Node) || !Node->HasFather()) + { return false; + } colorL = Node->Father()->Label(); return true; } @@ -269,7 +281,9 @@ bool XCAFDoc_ColorTool::GetColor(const TDF_Label& L, { TDF_Label colorL; if (!GetColor(L, type, colorL)) + { return false; + } return GetColor(colorL, color); } @@ -281,7 +295,9 @@ bool XCAFDoc_ColorTool::GetColor(const TDF_Label& L, { TDF_Label colorL; if (!GetColor(L, type, colorL)) + { return false; + } return GetColor(colorL, color); } @@ -293,7 +309,9 @@ bool XCAFDoc_ColorTool::SetColor(const TopoDS_Shape& S, { TDF_Label L; if (!ShapeTool()->Search(S, L)) + { return false; + } SetColor(L, colorL, type); return true; } @@ -324,7 +342,9 @@ bool XCAFDoc_ColorTool::UnSetColor(const TopoDS_Shape& S, const XCAFDoc_ColorTyp { TDF_Label L; if (!ShapeTool()->Search(S, L)) + { return false; + } UnSetColor(L, type); return true; } @@ -335,7 +355,9 @@ bool XCAFDoc_ColorTool::IsSet(const TopoDS_Shape& S, const XCAFDoc_ColorType typ { TDF_Label L; if (!ShapeTool()->Search(S, L)) + { return false; + } return IsSet(L, type); } @@ -347,7 +369,9 @@ bool XCAFDoc_ColorTool::GetColor(const TopoDS_Shape& S, { TDF_Label L; if (!ShapeTool()->Search(S, L)) + { return false; + } return GetColor(L, type, colorL); } @@ -359,7 +383,9 @@ bool XCAFDoc_ColorTool::GetColor(const TopoDS_Shape& S, { TDF_Label colorL; if (!GetColor(S, type, colorL)) + { return false; + } return GetColor(colorL, color); } @@ -371,7 +397,9 @@ bool XCAFDoc_ColorTool::GetColor(const TopoDS_Shape& S, { TDF_Label colorL; if (!GetColor(S, type, colorL)) + { return false; + } return GetColor(colorL, color); } @@ -426,11 +454,17 @@ void XCAFDoc_ColorTool::SetVisibility(const TDF_Label& L, const bool isvisible) { occ::handle aSHUO; if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO(L, aSHUO)) + { if (!L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr)) + { TDataStd_UAttribute::Set(L, XCAFDoc::InvisibleGUID()); + } + } } else + { L.ForgetAttribute(XCAFDoc::InvisibleGUID()); + } } //================================================================================================= @@ -450,11 +484,17 @@ void XCAFDoc_ColorTool::SetColorByLayer(const TDF_Label& L, const bool isColorBy { occ::handle aSHUO; if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO(L, aSHUO)) + { if (!L.FindAttribute(XCAFDoc::ColorByLayerGUID(), aUAttr)) + { TDataStd_UAttribute::Set(L, XCAFDoc::ColorByLayerGUID()); + } + } } else + { L.ForgetAttribute(XCAFDoc::ColorByLayerGUID()); + } } //================================================================================================= @@ -479,7 +519,9 @@ bool XCAFDoc_ColorTool::SetInstanceColor(const TopoDS_Shape& theShape, // find shuo label structure NCollection_Sequence aLabels; if (!ShapeTool()->FindComponent(theShape, aLabels)) + { return false; + } occ::handle aSHUO; // set the SHUO structure for this component if it is not exist if (!ShapeTool()->FindSHUO(aLabels, aSHUO)) @@ -509,7 +551,9 @@ bool XCAFDoc_ColorTool::GetInstanceColor(const TopoDS_Shape& theShape, Quantity_ColorRGBA aCol; bool isDone = GetInstanceColor(theShape, type, aCol); if (isDone) + { color = aCol.GetRGB(); + } return isDone; } @@ -522,7 +566,9 @@ bool XCAFDoc_ColorTool::GetInstanceColor(const TopoDS_Shape& theShape, // find shuo label structure NCollection_Sequence aLabels; if (!ShapeTool()->FindComponent(theShape, aLabels)) + { return false; + } occ::handle aSHUO; // get shuo from document by label structure TDF_Label aCompLab = aLabels.Value(aLabels.Length()); @@ -538,15 +584,21 @@ bool XCAFDoc_ColorTool::GetInstanceColor(const TopoDS_Shape& theShape, { TDF_Label aSHUOLabel = aSHUO->Label(); if (GetColor(aSHUOLabel, type, color)) + { return true; + } else + { // try to find other shuo aLabels.Remove(aLabels.Length()); + } } } // attempt to get color exactly of component if (GetColor(aCompLab, type, color)) + { return true; + } // attempt to get color of solid TopLoc_Location aLoc; @@ -554,7 +606,9 @@ bool XCAFDoc_ColorTool::GetInstanceColor(const TopoDS_Shape& theShape, S0.Location(aLoc); TDF_Label aRefLab = ShapeTool()->FindShape(S0); if (!aRefLab.IsNull()) + { return GetColor(aRefLab, type, color); + } // no color assigned return false; } @@ -569,15 +623,21 @@ bool XCAFDoc_ColorTool::IsInstanceVisible(const TopoDS_Shape& theShape) S0.Location(NullLoc); TDF_Label aRefL = ShapeTool()->FindShape(S0); if (!aRefL.IsNull() && !IsVisible(aRefL)) + { return false; + } // find shuo label structure NCollection_Sequence aLabels; if (!ShapeTool()->FindComponent(theShape, aLabels)) + { return true; + } TDF_Label aCompLab = aLabels.Value(aLabels.Length()); // visibility status of component withouts SHUO. if (!IsVisible(aCompLab)) + { return false; + } // check by SHUO structure NCollection_Sequence aCurLabels; aCurLabels.Append(aCompLab); @@ -589,9 +649,13 @@ bool XCAFDoc_ColorTool::IsInstanceVisible(const TopoDS_Shape& theShape) // get shuo from document by label structure occ::handle aSHUO; if (!ShapeTool()->FindSHUO(aCurLabels, aSHUO)) + { continue; + } if (!IsVisible(aSHUO->Label())) + { return false; + } } return true; // visible, cause cannot find invisibility status } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Datum.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Datum.cxx index 16d0179441..ca4abc7147 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Datum.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Datum.cxx @@ -118,7 +118,9 @@ void XCAFDoc_Datum::Set(const occ::handle& theName, occ::handle XCAFDoc_Datum::GetName() const { if (myName.IsNull()) + { return new TCollection_HAsciiString(); + } return myName; } @@ -153,8 +155,10 @@ void XCAFDoc_Datum::SetObject(const occ::handle& Label().FindChild(aChild).ForgetAllAttributes(); } if (!theObject->GetName().IsNull() && !theObject->GetName()->IsEmpty()) + { occ::handle anAttName = TDataStd_AsciiString::Set(Label().FindChild(ChildLab_Name), theObject->GetName()->String()); + } occ::handle aPosition = TDataStd_Integer::Set(Label().FindChild(ChildLab_Position), theObject->GetPosition()); @@ -164,13 +168,17 @@ void XCAFDoc_Datum::SetObject(const occ::handle& occ::handle> anArr = new NCollection_HArray1(1, theObject->GetModifiers().Length()); for (int i = 1; i <= theObject->GetModifiers().Length(); i++) + { anArr->SetValue(i, theObject->GetModifiers().Value(i)); + } occ::handle aModifiers = TDataStd_IntegerArray::Set(Label().FindChild(ChildLab_Modifiers), 1, theObject->GetModifiers().Length()); if (!aModifiers.IsNull()) + { aModifiers->ChangeArray(anArr); + } } XCAFDimTolObjects_DatumModifWithValue aM; @@ -207,27 +215,39 @@ void XCAFDoc_Datum::SetObject(const occ::handle& gp_Ax2 anAx = theObject->GetDatumTargetAxis(); occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, anAx.Location().Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisLoc), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } occ::handle> aNArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aNArr->SetValue(i, anAx.Direction().Coord(i)); + } occ::handle aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisN), 1, 3); if (!aN.IsNull()) + { aN->ChangeArray(aNArr); + } occ::handle> aRArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aRArr->SetValue(i, anAx.XDirection().Coord(i)); + } occ::handle aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisRef), 1, 3); if (!aR.IsNull()) + { aR->ChangeArray(aRArr); + } if (theObject->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point) { @@ -235,9 +255,11 @@ void XCAFDoc_Datum::SetObject(const occ::handle& TDataStd_Real::Set(Label().FindChild(ChildLab_DTargetLength), theObject->GetDatumTargetLength()); if (theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle) + { occ::handle aWidth = TDataStd_Real::Set(Label().FindChild(ChildLab_DTargetWidth), theObject->GetDatumTargetWidth()); + } } } occ::handle aNum = @@ -251,27 +273,39 @@ void XCAFDoc_Datum::SetObject(const occ::handle& occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, anAx.Location().Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneLoc), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } occ::handle> aNArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aNArr->SetValue(i, anAx.Direction().Coord(i)); + } occ::handle aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneN), 1, 3); if (!aN.IsNull()) + { aN->ChangeArray(aNArr); + } occ::handle> aRArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aRArr->SetValue(i, anAx.XDirection().Coord(i)); + } occ::handle aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneRef), 1, 3); if (!aR.IsNull()) + { aR->ChangeArray(aRArr); + } } if (theObject->HasPoint()) @@ -280,11 +314,15 @@ void XCAFDoc_Datum::SetObject(const occ::handle& occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, aPnt.Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } } if (theObject->HasPointText()) @@ -293,11 +331,15 @@ void XCAFDoc_Datum::SetObject(const occ::handle& occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, aPntText.Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PntText), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } } TopoDS_Shape aPresentation = theObject->GetPresentation(); @@ -327,7 +369,9 @@ occ::handle XCAFDoc_Datum::GetObject() const { const TCollection_ExtendedString& aName = aSemanticNameAttr->Get(); if (!aName.IsEmpty()) + { aSemanticName = new TCollection_HAsciiString(aName); + } } anObj->SetSemanticName(aSemanticName); @@ -344,7 +388,9 @@ occ::handle XCAFDoc_Datum::GetObject() const { NCollection_Sequence aModifiers; for (int i = 1; i <= anArr->Length(); i++) + { aModifiers.Append((XCAFDimTolObjects_DatumSingleModif)anArr->Value(i)); + } anObj->SetModifiers(aModifiers); } @@ -500,7 +546,9 @@ occ::handle XCAFDoc_Datum::GetObject() const const TCollection_ExtendedString& aName = aNameAtrr->Get(); if (!aName.IsEmpty()) + { aPresentName = new TCollection_HAsciiString(aName); + } } anObj->SetPresentation(aPresentation, aPresentName); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DimTolTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DimTolTool.cxx index a8018ce8a5..bfb4c7dd75 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DimTolTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DimTolTool.cxx @@ -79,7 +79,9 @@ TDF_Label XCAFDoc_DimTolTool::BaseLabel() const const occ::handle& XCAFDoc_DimTolTool::ShapeTool() { if (myShapeTool.IsNull()) + { myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label()); + } return myShapeTool; } @@ -117,7 +119,9 @@ void XCAFDoc_DimTolTool::GetDimTolLabels(NCollection_Sequence& theLab { TDF_Label aL = aChildIterator.Value(); if (IsDimTol(aL)) + { theLabels.Append(aL); + } } } @@ -131,7 +135,9 @@ void XCAFDoc_DimTolTool::GetDimensionLabels(NCollection_Sequence& the { TDF_Label aL = aChildIterator.Value(); if (IsDimension(aL)) + { theLabels.Append(aL); + } } } @@ -145,7 +151,9 @@ void XCAFDoc_DimTolTool::GetGeomToleranceLabels(NCollection_Sequence& { TDF_Label aL = aChildIterator.Value(); if (IsGeomTolerance(aL)) + { theLabels.Append(aL); + } } } @@ -163,30 +171,42 @@ bool XCAFDoc_DimTolTool::FindDimTol(const int TDF_Label DimTolL = it.Value()->Label(); occ::handle DimTolAttr; if (!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(), DimTolAttr)) + { continue; + } int kind1 = DimTolAttr->GetKind(); occ::handle> aVal1 = DimTolAttr->GetVal(); occ::handle aName1 = DimTolAttr->GetName(); occ::handle aDescription1 = DimTolAttr->GetDescription(); bool IsEqual = true; if (!(kind1 == kind)) + { continue; + } if (!(aName == aName1)) + { continue; + } if (!(aDescription == aDescription1)) + { continue; + } if (kind < 20) { // dimension for (int i = 1; i <= aVal->Length(); i++) { if (std::abs(aVal->Value(i) - aVal1->Value(i)) > Precision::Confusion()) + { IsEqual = false; + } } } else if (kind < 50) { // tolerance if (std::abs(aVal->Value(1) - aVal1->Value(1)) > Precision::Confusion()) + { IsEqual = false; + } } if (IsEqual) { @@ -224,9 +244,13 @@ TDF_Label XCAFDoc_DimTolTool::AddDimTol( XCAFDoc_DimTol::Set(DimTolL, kind, aVal, aName, aDescription); TCollection_AsciiString str = "DGT:"; if (kind < 20) + { str.AssignCat("Dimension"); + } else + { str.AssignCat("Tolerance"); + } TDataStd_Name::Set(DimTolL, str); return DimTolL; } @@ -273,9 +297,13 @@ void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL, { NCollection_Sequence aFirstLS, aSecondLS; if (!theFirstL.IsNull()) + { aFirstLS.Append(theFirstL); + } if (!theSecondL.IsNull()) + { aSecondLS.Append(theSecondL); + } SetDimension(aFirstLS, aSecondLS, theDimTolL); } @@ -301,7 +329,9 @@ void XCAFDoc_DimTolTool::SetDimension(const NCollection_Sequence& the aFGNode = aChGNode->GetFather(1); aFGNode->UnSetChild(aChGNode); if (aFGNode->NbChildren() == 0) + { aFGNode->ForgetAttribute(XCAFDoc::DimensionRefFirstGUID()); + } } theDimTolL.ForgetAttribute(XCAFDoc::DimensionRefFirstGUID()); } @@ -312,7 +342,9 @@ void XCAFDoc_DimTolTool::SetDimension(const NCollection_Sequence& the aFGNode = aChGNode->GetFather(1); aFGNode->UnSetChild(aChGNode); if (aFGNode->NbChildren() == 0) + { aFGNode->ForgetAttribute(XCAFDoc::DimensionRefSecondGUID()); + } } theDimTolL.ForgetAttribute(XCAFDoc::DimensionRefSecondGUID()); } @@ -391,7 +423,9 @@ void XCAFDoc_DimTolTool::SetGeomTolerance(const NCollection_Sequence& aFGNode = aChGNode->GetFather(1); aFGNode->UnSetChild(aChGNode); if (aFGNode->NbChildren() == 0) + { aFGNode->ForgetAttribute(XCAFDoc::GeomToleranceRefGUID()); + } } theGeomTolL.ForgetAttribute(XCAFDoc::GeomToleranceRefGUID()); } @@ -601,7 +635,9 @@ void XCAFDoc_DimTolTool::GetDatumLabels(NCollection_Sequence& theLabe { TDF_Label L = aChildIterator.Value(); if (IsDatum(L)) + { theLabels.Append(L); + } } } @@ -618,13 +654,21 @@ bool XCAFDoc_DimTolTool::FindDatum(const occ::handle& occ::handle aName1, aDescription1, anIdentification1; TDF_Label aLabel = it.Value()->Label(); if (!GetDatum(aLabel, aName1, aDescription1, anIdentification1)) + { continue; + } if (!(aName == aName1)) + { continue; + } if (!(aDescription == aDescription1)) + { continue; + } if (!(anIdentification == anIdentification1)) + { continue; + } lab = aLabel; return true; } @@ -678,7 +722,9 @@ void XCAFDoc_DimTolTool::SetDatum(const NCollection_Sequence& theL, aFGNode = aChGNode->GetFather(1); aFGNode->UnSetChild(aChGNode); if (aFGNode->NbChildren() == 0) + { aFGNode->ForgetAttribute(XCAFDoc::DatumRefGUID()); + } } theDatumL.ForgetAttribute(XCAFDoc::DatumRefGUID()); } @@ -713,7 +759,9 @@ void XCAFDoc_DimTolTool::SetDatum( { TDF_Label DatumL; if (!FindDatum(aName, aDescription, anIdentification, DatumL)) + { DatumL = AddDatum(aName, aDescription, anIdentification); + } NCollection_Sequence aLabels; aLabels.Append(L); SetDatum(aLabels, DatumL); @@ -769,7 +817,9 @@ bool XCAFDoc_DimTolTool::GetDatum(const TDF_Label& theDatu { occ::handle aDatumAttr; if (theDatumL.IsNull() || !theDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { return false; + } theName = aDatumAttr->GetName(); theDescription = aDatumAttr->GetDescription(); @@ -784,7 +834,9 @@ bool XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& { occ::handle aNode; if (!theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode)) + { return false; + } for (int i = 1; i <= aNode->NbChildren(); i++) { @@ -801,7 +853,9 @@ bool XCAFDoc_DimTolTool::GetDatumWithObjectOfTolerLabels(const TDF_Label& theDim { occ::handle aNode; if (!theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode)) + { return false; + } NCollection_Map aDatumNameMap; for (int i = 1; i <= aNode->NbChildren(); i++) @@ -810,10 +864,14 @@ bool XCAFDoc_DimTolTool::GetDatumWithObjectOfTolerLabels(const TDF_Label& theDim TDF_Label aDatumL = aDatumNode->Label(); occ::handle aDatumAttr; if (!aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) + { continue; + } occ::handle aDatumObj = aDatumAttr->GetObject(); if (aDatumObj.IsNull()) + { continue; + } occ::handle aName = aDatumObj->GetName(); if (!aDatumNameMap.Add(aName->String())) { @@ -832,7 +890,9 @@ bool XCAFDoc_DimTolTool::GetTolerOfDatumLabels(const TDF_Label& { occ::handle aNode; if (!theDatumL.FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode)) + { return false; + } for (int i = 1; i <= aNode->NbFathers(); i++) { occ::handle aDatumNode = aNode->GetFather(i); @@ -882,13 +942,19 @@ void XCAFDoc_DimTolTool::GetGDTPresentations( occ::handle aDimAttr; const TDF_Label& aCL = aGDTs.Value(i); if (!aCL.FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr)) + { continue; + } occ::handle anObject = aDimAttr->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { theGDTLabelToShape.Add(aCL, aShape); + } } aGDTs.Clear(); @@ -898,13 +964,19 @@ void XCAFDoc_DimTolTool::GetGDTPresentations( occ::handle aGTAttr; const TDF_Label& aCL = aGDTs.Value(i); if (!aCL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) + { continue; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { theGDTLabelToShape.Add(aCL, aShape); + } } aGDTs.Clear(); @@ -914,13 +986,19 @@ void XCAFDoc_DimTolTool::GetGDTPresentations( occ::handle aGTAttr; const TDF_Label& aCL = aGDTs.Value(i); if (!aCL.FindAttribute(XCAFDoc_Datum::GetID(), aGTAttr)) + { continue; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { theGDTLabelToShape.Add(aCL, aShape); + } } } @@ -937,7 +1015,9 @@ void XCAFDoc_DimTolTool::SetGDTPresentations( { occ::handle anObject = aDimAttrDim->GetObject(); if (anObject.IsNull()) + { continue; + } const TopoDS_Shape& aPrs = theGDTLabelToPrs.FindFromIndex(i); anObject->SetPresentation(aPrs, anObject->GetPresentationName()); aDimAttrDim->SetObject(anObject); @@ -948,7 +1028,9 @@ void XCAFDoc_DimTolTool::SetGDTPresentations( { occ::handle anObject = aDimAttrG->GetObject(); if (anObject.IsNull()) + { continue; + } const TopoDS_Shape& aPrs = theGDTLabelToPrs.FindFromIndex(i); anObject->SetPresentation(aPrs, anObject->GetPresentationName()); aDimAttrG->SetObject(anObject); @@ -959,7 +1041,9 @@ void XCAFDoc_DimTolTool::SetGDTPresentations( { occ::handle anObject = aDimAttrD->GetObject(); if (anObject.IsNull()) + { continue; + } const TopoDS_Shape& aPrs = theGDTLabelToPrs.FindFromIndex(i); anObject->SetPresentation(aPrs, anObject->GetPresentationName()); aDimAttrD->SetObject(anObject); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Dimension.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Dimension.cxx index 34586613d0..c427b5ad45 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Dimension.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Dimension.cxx @@ -92,7 +92,9 @@ static void setString(const TDF_Label& theLabel, const occ::handle& theStr) { if (theStr.IsNull()) + { return; + } TCollection_ExtendedString aStr(theStr->String()); TDataStd_Name::Set(theLabel, aStr); @@ -108,7 +110,9 @@ static void setRealArrayXYZ(const TDF_Label& theLabel, const gp_XYZ& theArr) anArr->SetValue(3, theArr.Z()); occ::handle anArrayAttr = TDataStd_RealArray::Set(theLabel, 1, 3); if (!anArrayAttr.IsNull()) + { anArrayAttr->ChangeArray(anArr); + } } //================================================================================================= @@ -121,7 +125,9 @@ static occ::handle getString(const TDF_Label& theLabel { const TCollection_ExtendedString& aName = aStrAttr->Get(); if (!aName.IsEmpty()) + { aStr = new TCollection_HAsciiString(aName); + } } return aStr; } @@ -164,7 +170,9 @@ void XCAFDoc_Dimension::SetObject(const occ::handleGetValues()->Lower(), theObject->GetValues()->Lower() + theObject->GetValues()->Length() - 1); if (!aVal.IsNull()) + { aVal->ChangeArray(theObject->GetValues()); + } } occ::handle aQualifier = @@ -188,7 +196,9 @@ void XCAFDoc_Dimension::SetObject(const occ::handle aClass = TDataStd_IntegerArray::Set(Label().FindChild(ChildLab_Class), 1, 3); if (!aClass.IsNull()) + { aClass->ChangeArray(anArrI); + } } int aL, aR; @@ -201,20 +211,26 @@ void XCAFDoc_Dimension::SetObject(const occ::handle aDec = TDataStd_IntegerArray::Set(Label().FindChild(ChildLab_Dec), 1, 2); if (!aDec.IsNull()) + { aDec->ChangeArray(anArrI); + } } if (theObject->GetModifiers().Length() > 0) { anArrI = new NCollection_HArray1(1, theObject->GetModifiers().Length()); for (int i = 1; i <= theObject->GetModifiers().Length(); i++) + { anArrI->SetValue(i, theObject->GetModifiers().Value(i)); + } occ::handle aModifiers = TDataStd_IntegerArray::Set(Label().FindChild(ChildLab_Modifiers), 1, theObject->GetModifiers().Length()); if (!aModifiers.IsNull()) + { aModifiers->ChangeArray(anArrI); + } } if (!theObject->GetPath().IsNull()) @@ -250,7 +266,9 @@ void XCAFDoc_Dimension::SetObject(const occ::handle aAxis = TDataStd_RealArray::Set(Label().FindChild(ChildLab_ConnectionAxis1), 1, 6); if (!aAxis.IsNull()) + { aAxis->ChangeArray(aAxisArr); + } } } @@ -273,7 +291,9 @@ void XCAFDoc_Dimension::SetObject(const occ::handle aAxis = TDataStd_RealArray::Set(Label().FindChild(ChildLab_ConnectionAxis2), 1, 6); if (!aAxis.IsNull()) + { aAxis->ChangeArray(aAxisArr); + } } } @@ -322,9 +342,13 @@ void XCAFDoc_Dimension::SetObject(const occ::handleNbDescriptions()); if (!aDescriptions.IsNull()) + { aDescriptions->ChangeArray(aDescrArr); + } if (!aDescriptionNames.IsNull()) + { aDescriptionNames->ChangeArray(aDescrNameArr); + } } } @@ -388,7 +412,9 @@ occ::handle XCAFDoc_Dimension::GetObject() co { NCollection_Sequence aM; for (int i = 1; i <= aModifiers->Array()->Length(); i++) + { aM.Append((XCAFDimTolObjects_DimensionModif)aModifiers->Array()->Value(i)); + } anObj->SetModifiers(aM); } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DocumentTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DocumentTool.cxx index c0ee650517..570d204d5f 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DocumentTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_DocumentTool.cxx @@ -72,7 +72,9 @@ occ::handle XCAFDoc_DocumentTool::Set(const TDF_Label& L, if (!aL.FindAttribute(XCAFDoc_DocumentTool::GetID(), A)) { if (!IsAcces) + { aL = L; + } A = new XCAFDoc_DocumentTool; aL.AddAttribute(A); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Editor.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Editor.cxx index 68923cbc31..0b06e0b243 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Editor.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Editor.cxx @@ -72,7 +72,9 @@ bool XCAFDoc_Editor::Expand(const TDF_Label& theDoc, TDF_Label aCompoundPartL = theShape; if (aShapeTool->IsReference(theShape)) + { aShapeTool->GetReferredShape(aCompoundPartL, aCompoundPartL); + } TopoDS_Shape aS = aShapeTool->GetShape(aCompoundPartL); if (aShapeTool->Expand(aCompoundPartL)) @@ -131,7 +133,9 @@ bool XCAFDoc_Editor::Expand(const TDF_Label& theDoc, { TopoDS_Shape aPartShape = aShapeTool->GetShape(aPart); if (!aPartShape.IsNull() && aPartShape.ShapeType() == TopAbs_COMPOUND) + { Expand(theDoc, aPart, theRecursively); + } } } } @@ -974,7 +978,9 @@ bool XCAFDoc_Editor::RescaleGeometry(const TDF_Label& theLabel, if (aRescaleOtherValues) { for (int i = anArray.Lower() + 1; i <= anArray.Upper(); ++i) + { anArray.ChangeValue(i) *= theScaleFactor; + } occ::handle aName = aDimObj->GetSemanticName(); if (!aName.IsNull()) diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GeomTolerance.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GeomTolerance.cxx index e5f6620bf9..337c6440f3 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GeomTolerance.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GeomTolerance.cxx @@ -103,8 +103,10 @@ void XCAFDoc_GeomTolerance::SetObject( TDataStd_Integer::Set(Label().FindChild(ChildLab_Type), theObject->GetType()); if (theObject->GetTypeOfValue() != XCAFDimTolObjects_GeomToleranceTypeValue_None) + { occ::handle aTypeOfValue = TDataStd_Integer::Set(Label().FindChild(ChildLab_TypeOfValue), theObject->GetTypeOfValue()); + } occ::handle aValue = TDataStd_Real::Set(Label().FindChild(ChildLab_Value), theObject->GetValue()); @@ -112,36 +114,48 @@ void XCAFDoc_GeomTolerance::SetObject( occ::handle aMatReqModif; if (theObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) + { aMatReqModif = TDataStd_Integer::Set(Label().FindChild(ChildLab_MatReqModif), theObject->GetMaterialRequirementModifier()); + } if (theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None) + { occ::handle aZoneModif = TDataStd_Integer::Set(Label().FindChild(ChildLab_ZoneModif), theObject->GetZoneModifier()); + } if (theObject->GetValueOfZoneModifier() > 0) + { occ::handle aValueOfZoneModif = TDataStd_Real::Set(Label().FindChild(ChildLab_ValueOfZoneModif), theObject->GetValueOfZoneModifier()); + } if (theObject->GetModifiers().Length() > 0) { occ::handle> anArr = new NCollection_HArray1(1, theObject->GetModifiers().Length()); for (int i = 1; i <= theObject->GetModifiers().Length(); i++) + { anArr->SetValue(i, theObject->GetModifiers().Value(i)); + } occ::handle aModifiers = TDataStd_IntegerArray::Set(Label().FindChild(ChildLab_Modifiers), 1, theObject->GetModifiers().Length()); if (!aModifiers.IsNull()) + { aModifiers->ChangeArray(anArr); + } } if (theObject->GetMaxValueModifier() > 0) + { occ::handle aMaxValueModif = TDataStd_Real::Set(Label().FindChild(ChildLab_aMaxValueModif), theObject->GetMaxValueModifier()); + } if (theObject->HasAxis()) { @@ -149,27 +163,39 @@ void XCAFDoc_GeomTolerance::SetObject( occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, anAx.Location().Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisLoc), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } occ::handle> aNArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aNArr->SetValue(i, anAx.Direction().Coord(i)); + } occ::handle aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisN), 1, 3); if (!aN.IsNull()) + { aN->ChangeArray(aNArr); + } occ::handle> aRArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aRArr->SetValue(i, anAx.XDirection().Coord(i)); + } occ::handle aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_AxisRef), 1, 3); if (!aR.IsNull()) + { aR->ChangeArray(aRArr); + } } if (theObject->HasPlane()) @@ -178,27 +204,39 @@ void XCAFDoc_GeomTolerance::SetObject( occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, anAx.Location().Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneLoc), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } occ::handle> aNArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aNArr->SetValue(i, anAx.Direction().Coord(i)); + } occ::handle aN = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneN), 1, 3); if (!aN.IsNull()) + { aN->ChangeArray(aNArr); + } occ::handle> aRArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aRArr->SetValue(i, anAx.XDirection().Coord(i)); + } occ::handle aR = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PlaneRef), 1, 3); if (!aR.IsNull()) + { aR->ChangeArray(aRArr); + } } if (theObject->HasPoint()) @@ -207,11 +245,15 @@ void XCAFDoc_GeomTolerance::SetObject( occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, aPnt.Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_Pnt), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } } if (theObject->HasPointText()) @@ -220,11 +262,15 @@ void XCAFDoc_GeomTolerance::SetObject( occ::handle> aLocArr = new NCollection_HArray1(1, 3); for (int i = 1; i <= 3; i++) + { aLocArr->SetValue(i, aPntText.Coord(i)); + } occ::handle aLoc = TDataStd_RealArray::Set(Label().FindChild(ChildLab_PntText), 1, 3); if (!aLoc.IsNull()) + { aLoc->ChangeArray(aLocArr); + } } TopoDS_Shape aPresentation = theObject->GetPresentation(); @@ -262,7 +308,9 @@ occ::handle XCAFDoc_GeomTolerance::GetObj { const TCollection_ExtendedString& aName = aSemanticNameAttr->Get(); if (!aName.IsEmpty()) + { aSemanticName = new TCollection_HAsciiString(aName); + } } anObj->SetSemanticName(aSemanticName); @@ -315,7 +363,9 @@ occ::handle XCAFDoc_GeomTolerance::GetObj { NCollection_Sequence aModifiers; for (int i = 1; i <= anArr->Length(); i++) + { aModifiers.Append((XCAFDimTolObjects_GeomToleranceModif)anArr->Value(i)); + } anObj->SetModifiers(aModifiers); } @@ -397,7 +447,9 @@ occ::handle XCAFDoc_GeomTolerance::GetObj const TCollection_ExtendedString& aName = aNameAtrr->Get(); if (!aName.IsEmpty()) + { aPresentName = new TCollection_HAsciiString(aName); + } } anObj->SetPresentation(aPresentation, aPresentName); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GraphNode.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GraphNode.cxx index dac8984997..3d0a6fa4c6 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GraphNode.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_GraphNode.cxx @@ -364,8 +364,10 @@ Standard_OStream& XCAFDoc_GraphNode::Dump(Standard_OStream& anOS) const for (; i <= NbFathers(); i++) { if (!myFathers(i)->Label().IsNull()) + { myFathers(i)->Label().EntryDump(anOS); - anOS << std::endl; + } + anOS << '\n'; } } i = 1; @@ -375,8 +377,10 @@ Standard_OStream& XCAFDoc_GraphNode::Dump(Standard_OStream& anOS) const for (; i <= NbChildren(); i++) { if (!myChildren(i)->Label().IsNull()) + { myChildren(i)->Label().EntryDump(anOS); - anOS << std::endl; + } + anOS << '\n'; } } // anOS<& XCAFDoc_LayerTool::ShapeTool() { if (myShapeTool.IsNull()) + { myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label()); + } return myShapeTool; } @@ -88,7 +90,9 @@ bool XCAFDoc_LayerTool::IsLayer(const TDF_Label& lab) const bool XCAFDoc_LayerTool::GetLayer(const TDF_Label& lab, TCollection_ExtendedString& aLayer) const { if (lab.Father() != Label()) + { return false; + } // occ::handle aGN; // if (! lab.FindAttribute (XCAFDoc::LayerRefGUID(), aGN)) // return false; @@ -139,7 +143,9 @@ TDF_Label XCAFDoc_LayerTool::AddLayer(const TCollection_ExtendedString& theLayer { TDF_Label lab; if (FindLayer(theLayer, lab)) + { return lab; + } TDF_TagSource aTag; TDF_Label aLabel = TDF_TagSource::NewChild(Label()); occ::handle aName = new TDataStd_Name; @@ -154,7 +160,9 @@ TDF_Label XCAFDoc_LayerTool::AddLayer(const TCollection_ExtendedString& theLayer { TDF_Label lab = FindLayer(theLayer, true, theToFindVisible); if (!lab.IsNull()) + { return lab; + } TDF_TagSource aTag; TDF_Label aLabel = TDF_TagSource::NewChild(Label()); occ::handle aName = new TDataStd_Name; @@ -179,7 +187,9 @@ void XCAFDoc_LayerTool::GetLayerLabels(NCollection_Sequence& Labels) { TDF_Label L = ChildIterator.Value(); if (IsLayer(L)) + { Labels.Append(L); + } } } @@ -190,7 +200,9 @@ void XCAFDoc_LayerTool::SetLayer(const TDF_Label& L, const bool shapeInOneLayer) const { if (shapeInOneLayer) + { UnSetLayers(L); + } occ::handle FGNode; occ::handle ChGNode; if (!LayerL.FindAttribute(XCAFDoc::LayerRefGUID(), FGNode)) @@ -241,7 +253,9 @@ bool XCAFDoc_LayerTool::UnSetOneLayer(const TDF_Label& L, { TDF_Label alab; if (!FindLayer(aLayer, alab)) + { return false; + } return UnSetOneLayer(L, alab); } @@ -251,9 +265,13 @@ bool XCAFDoc_LayerTool::UnSetOneLayer(const TDF_Label& L, const TDF_Label& aLaye { occ::handle FGNode, ChGNode; if (!L.FindAttribute(XCAFDoc::LayerRefGUID(), ChGNode)) + { return false; + } if (!aLayerL.FindAttribute(XCAFDoc::LayerRefGUID(), FGNode)) + { return false; + } ChGNode->UnSetFather(FGNode); return true; } @@ -272,7 +290,9 @@ bool XCAFDoc_LayerTool::IsSet(const TDF_Label& L, const TCollection_ExtendedStri { lab = Node->GetFather(i)->Label(); if (lab.FindAttribute(TDataStd_Name::GetID(), aName) && (aName->Get().IsEqual(aLayer))) + { return true; + } } } return false; @@ -292,7 +312,9 @@ bool XCAFDoc_LayerTool::IsSet(const TDF_Label& L, const TDF_Label& aLayerL) cons { lab = Node->GetFather(i)->Label(); if (lab == aLayerL) + { return true; + } } } return false; @@ -384,7 +406,9 @@ void XCAFDoc_LayerTool::SetVisibility(const TDF_Label& layerL, const bool isvisi } } else + { layerL.ForgetAttribute(XCAFDoc::InvisibleGUID()); + } } //================================================================================================= @@ -396,7 +420,9 @@ bool XCAFDoc_LayerTool::SetLayer(const TopoDS_Shape& Sh, TDF_Label aLab; // PTV 22.01.2003 set layer for shape with location if it is necessary if (!myShapeTool->Search(Sh, aLab)) + { return false; + } SetLayer(aLab, LayerL, shapeInOneLayer); return true; } @@ -417,7 +443,9 @@ bool XCAFDoc_LayerTool::UnSetLayers(const TopoDS_Shape& Sh) { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } UnSetLayers(aLab); return true; } @@ -429,7 +457,9 @@ bool XCAFDoc_LayerTool::UnSetOneLayer(const TopoDS_Shape& Sh, { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } return UnSetOneLayer(aLab, aLayer); } @@ -439,7 +469,9 @@ bool XCAFDoc_LayerTool::UnSetOneLayer(const TopoDS_Shape& Sh, const TDF_Label& a { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } return UnSetOneLayer(aLab, aLayerL); } @@ -449,7 +481,9 @@ bool XCAFDoc_LayerTool::IsSet(const TopoDS_Shape& Sh, const TCollection_Extended { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } return IsSet(aLab, aLayer); } @@ -459,7 +493,9 @@ bool XCAFDoc_LayerTool::IsSet(const TopoDS_Shape& Sh, const TDF_Label& aLayerL) { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } return IsSet(aLab, aLayerL); } @@ -471,7 +507,9 @@ bool XCAFDoc_LayerTool::GetLayers( { TDF_Label aLab; if (!myShapeTool->Search(Sh, aLab)) + { return false; + } return GetLayers(aLab, aLayerS); } @@ -481,7 +519,9 @@ bool XCAFDoc_LayerTool::GetLayers(const TopoDS_Shape& Sh, NCollection_SequenceSearch(Sh, aLab)) + { return false; + } return GetLayers(aLab, aLayerLS); } @@ -494,7 +534,9 @@ occ::handle> XCAFDoc_LayerTool new NCollection_HSequence; TDF_Label aLab; if (myShapeTool->Search(Sh, aLab)) + { aLayerS = GetLayers(aLab); + } return aLayerS; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_LengthUnit.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_LengthUnit.cxx index 9efedadd3b..4c36b21df1 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_LengthUnit.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_LengthUnit.cxx @@ -119,7 +119,7 @@ Standard_OStream& XCAFDoc_LengthUnit::Dump(Standard_OStream& theOS) const anOS << " UnitScaleValue=|" << myUnitScaleValue << "|"; char aSGUID[Standard_GUID_SIZE_ALLOC]; ID().ToCString(aSGUID); - anOS << aSGUID << "|" << std::endl; + anOS << aSGUID << "|" << '\n'; return anOS; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_MaterialTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_MaterialTool.cxx index 46d5b66744..be874060da 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_MaterialTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_MaterialTool.cxx @@ -69,7 +69,9 @@ TDF_Label XCAFDoc_MaterialTool::BaseLabel() const const occ::handle& XCAFDoc_MaterialTool::ShapeTool() { if (myShapeTool.IsNull()) + { myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label()); + } return myShapeTool; } @@ -91,7 +93,9 @@ void XCAFDoc_MaterialTool::GetMaterialLabels(NCollection_Sequence& La { TDF_Label L = ChildIterator.Value(); if (IsMaterial(L)) + { Labels.Append(L); + } } } @@ -168,7 +172,9 @@ double XCAFDoc_MaterialTool::GetDensityForShape(const TDF_Label& ShapeL) double Dens = 0.0; occ::handle Node; if (!ShapeL.FindAttribute(XCAFDoc::MaterialRefGUID(), Node) || !Node->HasFather()) + { return Dens; + } TDF_Label MatL = Node->Father()->Label(); occ::handle MatAttr; if (!MatL.FindAttribute(XCAFDoc_Material::GetID(), MatAttr)) diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Note.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Note.cxx index f50418e427..31df35cfae 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Note.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Note.cxx @@ -55,7 +55,9 @@ occ::handle XCAFDoc_Note::Get(const TDF_Label& theLabel) { aNote = occ::down_cast(anIt.Value()); if (!aNote.IsNull()) + { break; + } } return aNote; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteBinData.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteBinData.cxx index 0f8c47fe51..60d732b12d 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteBinData.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteBinData.cxx @@ -52,9 +52,13 @@ occ::handle XCAFDoc_NoteBinData::Set( aNoteBinData = new XCAFDoc_NoteBinData(); aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp); if (aNoteBinData->Set(theTitle, theMIMEtype, theFile)) + { theLabel.AddAttribute(aNoteBinData); + } else + { aNoteBinData.Nullify(); + } } return aNoteBinData; } @@ -91,18 +95,24 @@ bool XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, OSD_File& theFile) { if (!theFile.IsOpen() || !theFile.IsReadable()) + { return false; + } Backup(); if (theFile.Size() > (size_t)IntegerLast()) + { return false; + } myData.reset(new NCollection_HArray1(1, (int)theFile.Size())); int nbReadBytes = 0; theFile.Read((void*)&myData->First(), myData->Length(), nbReadBytes); if (nbReadBytes < myData->Length()) + { return false; + } myTitle = theTitle; myMIMEtype = theMIMEtype; @@ -161,7 +171,9 @@ void XCAFDoc_NoteBinData::Paste(const occ::handle& theAttrI occ::handle aMine = occ::down_cast(theAttrInto); if (!aMine.IsNull()) + { aMine->Set(myTitle, myMIMEtype, myData); + } } //================================================================================================= @@ -176,7 +188,9 @@ Standard_OStream& XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const if (!myData.IsNull()) { for (int i = myData->Lower(); i <= myData->Upper(); ++i) + { theOS << myData->Value(i); + } } return theOS; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteComment.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteComment.cxx index 2d6798b6ed..b4f7c481aa 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteComment.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NoteComment.cxx @@ -89,7 +89,9 @@ void XCAFDoc_NoteComment::Restore(const occ::handle& theAttr) occ::handle aMine = occ::down_cast(theAttr); if (!aMine.IsNull()) + { myComment = aMine->myComment; + } } //================================================================================================= @@ -101,7 +103,9 @@ void XCAFDoc_NoteComment::Paste(const occ::handle& theAttrI occ::handle aMine = occ::down_cast(theAttrInto); if (!aMine.IsNull()) + { aMine->Set(myComment); + } } //================================================================================================= diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NotesTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NotesTool.cxx index 25e8c98f35..0792416874 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NotesTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_NotesTool.cxx @@ -94,7 +94,9 @@ int XCAFDoc_NotesTool::NbNotes() const { const TDF_Label aLabel = anIter.Value(); if (!XCAFDoc_Note::Get(aLabel).IsNull()) + { ++nbNotes; + } } return nbNotes; } @@ -121,7 +123,9 @@ void XCAFDoc_NotesTool::GetNotes(NCollection_Sequence& theNoteLabels) { const TDF_Label aLabel = anIter.Value(); if (!XCAFDoc_Note::Get(aLabel).IsNull()) + { theNoteLabels.Append(aLabel); + } } } @@ -162,7 +166,9 @@ TDF_Label XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& the occ::handle anItemRef = occ::down_cast(anIter.Value()); if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && !anItemRef->HasExtraRef()) + { return anItemRef->Label(); + } } return TDF_Label(); } @@ -187,7 +193,9 @@ TDF_Label XCAFDoc_NotesTool::FindAnnotatedItemAttr(const XCAFDoc_AssemblyItemId& occ::down_cast(anIter.Value()); if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && anItemRef->HasExtraRef() && anItemRef->GetGUID() == theGUID) + { return anItemRef->Label(); + } } return TDF_Label(); } @@ -213,7 +221,9 @@ TDF_Label XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const XCAFDoc_AssemblyIte occ::down_cast(anIter.Value()); if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && anItemRef->HasExtraRef() && anItemRef->GetSubshapeIndex() == theSubshapeIndex) + { return anItemRef->Label(); + } } return TDF_Label(); } @@ -299,11 +309,15 @@ int XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId, { TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId); if (anAnnotatedItem.IsNull()) + { return 0; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return 0; + } int nbFathers = aChild->NbFathers(); for (int iFather = 1; iFather <= nbFathers; ++iFather) @@ -331,11 +345,15 @@ int XCAFDoc_NotesTool::GetAttrNotes(const XCAFDoc_AssemblyItemId& theItemId, { TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID); if (anAnnotatedItem.IsNull()) + { return 0; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return 0; + } int nbFathers = aChild->NbFathers(); for (int iFather = 1; iFather <= nbFathers; ++iFather) @@ -364,11 +382,15 @@ int XCAFDoc_NotesTool::GetSubshapeNotes(const XCAFDoc_AssemblyItemId& theItem { TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex); if (anAnnotatedItem.IsNull()) + { return 0; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return 0; + } int nbFathers = aChild->NbFathers(); for (int iFather = 1; iFather <= nbFathers; ++iFather) @@ -389,7 +411,9 @@ occ::handle XCAFDoc_NotesTool::AddNote( occ::handle anItemRef; if (!XCAFDoc_Note::IsMine(theNoteLabel)) + { return anItemRef; + } occ::handle aChild; TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId); @@ -398,21 +422,27 @@ occ::handle XCAFDoc_NotesTool::AddNote( TDF_TagSource aTag; anAnnotatedItem = TDF_TagSource::NewChild(GetAnnotatedItemsLabel()); if (anAnnotatedItem.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) { aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID()); if (aChild.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), anItemRef)) { anItemRef = XCAFDoc_AssemblyItemRef::Set(anAnnotatedItem, theItemId); if (anItemRef.IsNull()) + { return anItemRef; + } } occ::handle aFather; @@ -420,7 +450,9 @@ occ::handle XCAFDoc_NotesTool::AddNote( { aFather = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID()); if (aFather.IsNull()) + { return anItemRef; + } } aChild->SetFather(aFather); @@ -447,7 +479,9 @@ occ::handle XCAFDoc_NotesTool::AddNoteToAttr( occ::handle anItemRef; if (!XCAFDoc_Note::IsMine(theNoteLabel)) + { return anItemRef; + } occ::handle aChild; TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID); @@ -456,21 +490,27 @@ occ::handle XCAFDoc_NotesTool::AddNoteToAttr( TDF_TagSource aTag; anAnnotatedItem = TDF_TagSource::NewChild(GetAnnotatedItemsLabel()); if (anAnnotatedItem.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) { aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID()); if (aChild.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), anItemRef)) { anItemRef = XCAFDoc_AssemblyItemRef::Set(anAnnotatedItem, theItemId); if (anItemRef.IsNull()) + { return anItemRef; + } } occ::handle aFather; @@ -478,7 +518,9 @@ occ::handle XCAFDoc_NotesTool::AddNoteToAttr( { aFather = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID()); if (aFather.IsNull()) + { return anItemRef; + } } aChild->SetFather(aFather); @@ -508,7 +550,9 @@ occ::handle XCAFDoc_NotesTool::AddNoteToSubshape( occ::handle anItemRef; if (!XCAFDoc_Note::IsMine(theNoteLabel)) + { return anItemRef; + } occ::handle aChild; TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex); @@ -517,21 +561,27 @@ occ::handle XCAFDoc_NotesTool::AddNoteToSubshape( TDF_TagSource aTag; anAnnotatedItem = TDF_TagSource::NewChild(GetAnnotatedItemsLabel()); if (anAnnotatedItem.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) { aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID()); if (aChild.IsNull()) + { return anItemRef; + } } if (!anAnnotatedItem.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), anItemRef)) { anItemRef = XCAFDoc_AssemblyItemRef::Set(anAnnotatedItem, theItemId); if (anItemRef.IsNull()) + { return anItemRef; + } } occ::handle aFather; @@ -539,7 +589,9 @@ occ::handle XCAFDoc_NotesTool::AddNoteToSubshape( { aFather = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID()); if (aFather.IsNull()) + { return anItemRef; + } } aChild->SetFather(aFather); @@ -569,26 +621,38 @@ bool XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel, occ::handle aNote = XCAFDoc_Note::Get(theNoteLabel); if (aNote.IsNull()) + { return false; + } occ::handle aFather; if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather)) + { return false; + } TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } aChild->UnSetFather(aFather); if (aChild->NbFathers() == 0) + { anAnnotatedItem.ForgetAllAttributes(); + } if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(theNoteLabel); + } return true; } @@ -612,26 +676,38 @@ bool XCAFDoc_NotesTool::RemoveSubshapeNote(const TDF_Label& theNote occ::handle aNote = XCAFDoc_Note::Get(theNoteLabel); if (aNote.IsNull()) + { return false; + } occ::handle aFather; if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather)) + { return false; + } TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } aChild->UnSetFather(aFather); if (aChild->NbFathers() == 0) + { anAnnotatedItem.ForgetAllAttributes(); + } if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(theNoteLabel); + } return true; } @@ -659,26 +735,38 @@ bool XCAFDoc_NotesTool::RemoveAttrNote(const TDF_Label& theNoteLabe occ::handle aNote = XCAFDoc_Note::Get(theNoteLabel); if (aNote.IsNull()) + { return false; + } occ::handle aFather; if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather)) + { return false; + } TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } aChild->UnSetFather(aFather); if (aChild->NbFathers() == 0) + { anAnnotatedItem.ForgetAllAttributes(); + } if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(theNoteLabel); + } return true; } @@ -699,11 +787,15 @@ bool XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId, { TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } while (aChild->NbFathers() > 0) { @@ -713,7 +805,9 @@ bool XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId, { aFather->UnSetChild(aChild); if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(aFather->Label()); + } } } @@ -737,11 +831,15 @@ bool XCAFDoc_NotesTool::RemoveAllSubshapeNotes(const XCAFDoc_AssemblyItemId& the { TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } while (aChild->NbFathers() > 0) { @@ -751,7 +849,9 @@ bool XCAFDoc_NotesTool::RemoveAllSubshapeNotes(const XCAFDoc_AssemblyItemId& the { aFather->UnSetChild(aChild); if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(aFather->Label()); + } } } @@ -768,11 +868,15 @@ bool XCAFDoc_NotesTool::RemoveAllAttrNotes(const XCAFDoc_AssemblyItemId& theItem { TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID); if (anAnnotatedItem.IsNull()) + { return false; + } occ::handle aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { return false; + } while (aChild->NbFathers() > 0) { @@ -782,7 +886,9 @@ bool XCAFDoc_NotesTool::RemoveAllAttrNotes(const XCAFDoc_AssemblyItemId& theItem { aFather->UnSetChild(aChild); if (theDelIfOrphan && aNote->IsOrphan()) + { DeleteNote(aFather->Label()); + } } } @@ -815,7 +921,9 @@ bool XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel) occ::handle aChild = aFather->GetChild(1); aFather->UnSetChild(aChild); if (aChild->NbFathers() == 0) + { aChild->Label().ForgetAllAttributes(true); + } } } theNoteLabel.ForgetAllAttributes(true); @@ -833,7 +941,9 @@ int XCAFDoc_NotesTool::DeleteNotes(NCollection_Sequence& theNoteLabel anIter.Next()) { if (DeleteNote(anIter.Value())) + { ++nbNotes; + } } return nbNotes; } @@ -846,7 +956,9 @@ int XCAFDoc_NotesTool::DeleteAllNotes() for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next()) { if (DeleteNote(anIter.Value())) + { ++nbNotes; + } } return nbNotes; } @@ -861,7 +973,9 @@ int XCAFDoc_NotesTool::NbOrphanNotes() const const TDF_Label aLabel = anIter.Value(); occ::handle aNote = XCAFDoc_Note::Get(aLabel); if (!aNote.IsNull() && aNote->IsOrphan()) + { ++nbNotes; + } } return nbNotes; } @@ -875,7 +989,9 @@ void XCAFDoc_NotesTool::GetOrphanNotes(NCollection_Sequence& theNoteL const TDF_Label aLabel = anIter.Value(); occ::handle aNote = XCAFDoc_Note::Get(aLabel); if (!aNote.IsNull() && aNote->IsOrphan()) + { theNoteLabels.Append(aLabel); + } } } @@ -889,7 +1005,9 @@ int XCAFDoc_NotesTool::DeleteOrphanNotes() const TDF_Label aLabel = anIter.Value(); occ::handle aNote = XCAFDoc_Note::Get(aLabel); if (!aNote.IsNull() && aNote->IsOrphan() && DeleteNote(aLabel)) + { ++nbNotes; + } } return nbNotes; } diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeMapTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeMapTool.cxx index 1d2d6b740e..81f0a0d591 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeMapTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeMapTool.cxx @@ -91,7 +91,9 @@ static void AddSubShape(const TopoDS_Shape& { myMap.Add(S); for (TopoDS_Iterator it(S); it.More(); it.Next()) + { AddSubShape(it.Value(), myMap); + } } //================================================================================================= @@ -100,7 +102,9 @@ void XCAFDoc_ShapeMapTool::SetShape(const TopoDS_Shape& S) { myMap.Clear(); for (TopoDS_Iterator it(S); it.More(); it.Next()) + { AddSubShape(it.Value(), myMap); + } } //================================================================================================= diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeTool.cxx index 182a5b0e92..65d8b94c1f 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ShapeTool.cxx @@ -183,10 +183,14 @@ bool XCAFDoc_ShapeTool::SearchUsingMap(const TopoDS_Shape& S, } // search subshapes if (!findSubShape) + { return false; + } TDF_Label mainL = FindMainShapeUsingMap(S); if (mainL.IsNull()) + { return false; + } L = AddSubShape(mainL, S); return !L.IsNull(); // true; } @@ -206,7 +210,9 @@ bool XCAFDoc_ShapeTool::Search(const TopoDS_Shape& S, { // try to find top-level instance if (findInstance && FindShape(S, L, true)) + { return true; + } // try to find component of assembly if (findComponent) { @@ -215,7 +221,9 @@ bool XCAFDoc_ShapeTool::Search(const TopoDS_Shape& S, for (int i = 1; i <= labels.Length(); i++) { if (!IsAssembly(labels.Value(i))) + { continue; + } NCollection_Sequence comp; GetComponents(labels.Value(i), comp); for (int j = 1; j <= comp.Length(); j++) @@ -232,14 +240,20 @@ bool XCAFDoc_ShapeTool::Search(const TopoDS_Shape& S, } // try to find top-level simple shape if (FindShape(S, L, false)) + { return true; + } // search subshapes if (!findSubShape) + { return false; + } TDF_Label mainL = FindMainShape(S); if (mainL.IsNull()) + { return false; + } L = AddSubShape(mainL, S); return !L.IsNull(); // true; } @@ -265,10 +279,14 @@ bool XCAFDoc_ShapeTool::FindShape(const TopoDS_Shape& S, L = TNaming_Tool::Label(Label(), S0, TransDef); } else + { return false; + } if (IsTopLevel(L)) + { return true; + } // Try to find shape manually TDF_ChildIDIterator it(Label(), TNaming_NamedShape::GetID()); @@ -294,7 +312,9 @@ TDF_Label XCAFDoc_ShapeTool::FindShape(const TopoDS_Shape& S, const bool findIns { TDF_Label L; if (FindShape(S, L, findInstance)) + { return L; + } return TDF_Label(); } @@ -318,7 +338,9 @@ bool XCAFDoc_ShapeTool::GetShape(const TDF_Label& L, TopoDS_Shape& S) && L.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute)) { if (!GetShape(Node->Father()->Label(), S)) + { return false; + } S.Move(LocationAttribute->Get(), false); return true; } @@ -326,7 +348,9 @@ bool XCAFDoc_ShapeTool::GetShape(const TDF_Label& L, TopoDS_Shape& S) // else just return shape on this label occ::handle NS; if (!L.FindAttribute(TNaming_NamedShape::GetID(), NS)) + { return false; + } S = TNaming_Tool::GetShape(NS); return true; } @@ -430,7 +454,9 @@ void XCAFDoc_ShapeTool::MakeReference(const TDF_Label& L, mainNode->Append(refNode); if (theAutoNaming) + { SetLabelNameByLink(L); + } } //================================================================================================= @@ -474,7 +500,9 @@ TDF_Label XCAFDoc_ShapeTool::addShape(const TopoDS_Shape& S, const bool makeAsse // search if the shape already exists (with the same location) if (S.IsNull() || FindShape(S, ShapeLabel, true)) + { return ShapeLabel; + } // else add a new label ShapeLabel = TDF_TagSource::NewChild(Label()); @@ -502,7 +530,9 @@ TDF_Label XCAFDoc_ShapeTool::addShape(const TopoDS_Shape& S, const bool makeAsse A->SetShape(S); if (theAutoNaming) + { SetLabelNameByShape(ShapeLabel); + } // if shape is Compound and flag is set, create assembly if (makeAssembly && S.ShapeType() == TopAbs_COMPOUND) @@ -511,7 +541,9 @@ TDF_Label XCAFDoc_ShapeTool::addShape(const TopoDS_Shape& S, const bool makeAsse occ::handle Uattr; Uattr = TDataStd_UAttribute::Set(ShapeLabel, XCAFDoc::AssemblyGUID()); if (theAutoNaming) + { TDataStd_Name::Set(ShapeLabel, TCollection_ExtendedString("ASSEMBLY")); + } // iterate on components TopoDS_Iterator Iterator(S); @@ -564,12 +596,16 @@ static bool prepareAssembly(const TopoDS_Shape& theShape, TopoDS_Shape& theOUTSh BRep_Builder B; // check if shape if frosen if (!theOUTShape.Free()) + { theOUTShape.Free(true); + } NCollection_Sequence aSubShapeSeq; TopoDS_Iterator Iterator(theShape); for (; Iterator.More(); Iterator.Next()) + { aSubShapeSeq.Append(Iterator.Value()); + } for (int i = 1; i <= aSubShapeSeq.Length(); i++) { const TopoDS_Shape& Scomp = aSubShapeSeq.Value(i); @@ -601,7 +637,9 @@ TDF_Label XCAFDoc_ShapeTool::AddShape(const TopoDS_Shape& theShape, // PTV 17.02.2003 to avoid components without location. TopoDS_Shape S = theShape; if (makePrepare && makeAssembly && S.ShapeType() == TopAbs_COMPOUND) + { prepareAssembly(theShape, S); // OCC1669 + } TDF_Label L = addShape(S, makeAssembly); @@ -620,7 +658,9 @@ TDF_Label XCAFDoc_ShapeTool::AddShape(const TopoDS_Shape& theShape, bool XCAFDoc_ShapeTool::RemoveShape(const TDF_Label& L, const bool removeCompletely) const { if (!IsTopLevel(L) || !IsFree(L)) + { return false; + } occ::handle aNode; TDF_Label aLabel; @@ -700,7 +740,9 @@ void XCAFDoc_ShapeTool::GetShapes(NCollection_Sequence& Labels) const TDF_Label L = it.Value(); TopoDS_Shape S; if (GetShape(L, S)) + { Labels.Append(L); + } } } @@ -716,7 +758,9 @@ void XCAFDoc_ShapeTool::GetFreeShapes(NCollection_Sequence& FreeLabel TDF_Label L = it.Value(); TopoDS_Shape S; if (GetShape(L, S) && IsFree(L)) + { FreeLabels.Append(L); + } } } @@ -810,7 +854,9 @@ int XCAFDoc_ShapeTool::GetUsers(const TDF_Label& L, occ::handle Node; if (!L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node)) + { return NbUsers; + } Node = Node->First(); while (!Node.IsNull()) @@ -845,7 +891,9 @@ bool XCAFDoc_ShapeTool::GetComponents(const TDF_Label& L, const bool getsubchilds) { if (!IsAssembly(L)) + { return false; + } TDF_ChildIterator It(L); for (; It.More(); It.Next()) @@ -857,7 +905,9 @@ bool XCAFDoc_ShapeTool::GetComponents(const TDF_Label& L, { TDF_Label underL; if (GetReferredShape(comp, underL)) + { GetComponents(underL, Labels, getsubchilds); + } } Labels.Append(comp); } @@ -871,7 +921,9 @@ TopLoc_Location XCAFDoc_ShapeTool::GetLocation(const TDF_Label& L) { occ::handle LocationAttribute; if (L.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute)) + { return LocationAttribute->Get(); + } occ::handle NS; TopoDS_Shape S; @@ -887,7 +939,9 @@ TopLoc_Location XCAFDoc_ShapeTool::GetLocation(const TDF_Label& L) bool XCAFDoc_ShapeTool::GetReferredShape(const TDF_Label& L, TDF_Label& Label) { if (!IsReference(L)) + { return false; + } occ::handle Node; L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node); @@ -908,9 +962,13 @@ TDF_Label XCAFDoc_ShapeTool::AddComponent(const TDF_Label& assembly, { // if it is simple shape, make it assembly if (IsSimpleShape(assembly)) + { TDataStd_UAttribute::Set(assembly, XCAFDoc::AssemblyGUID()); + } else + { return L; + } } // add a component as reference @@ -923,7 +981,9 @@ TDF_Label XCAFDoc_ShapeTool::AddComponent(const TDF_Label& assembly, if (GetShape(L, aShape)) { if (!myShapeLabels.IsBound(aShape)) + { myShapeLabels.Bind(aShape, L); + } } return L; @@ -1002,7 +1062,9 @@ bool XCAFDoc_ShapeTool::IsSubShape(const TDF_Label& shapeL, const TopoDS_Shape& { TopoDS_Shape aShape = GetShape(shapeL); if (aShape.IsNull()) + { return false; + } A = XCAFDoc_ShapeMapTool::Set(shapeL); A->SetShape(aShape); } @@ -1017,16 +1079,22 @@ bool XCAFDoc_ShapeTool::FindSubShape(const TDF_Label& shapeL, TDF_Label& L) const { if (sub.IsNull()) + { return false; + } if (TNaming_Tool::HasLabel(Label(), sub)) { int TransDef = 0; L = TNaming_Tool::Label(Label(), sub, TransDef); if (L.IsNull()) + { return false; + } if (L.Father() == shapeL) + { return true; + } } else { @@ -1042,7 +1110,9 @@ bool XCAFDoc_ShapeTool::FindSubShape(const TDF_Label& shapeL, TDF_Label aSubLabel = aChldLabIt.Value(); occ::handle NS; if (!aSubLabel.FindAttribute(TNaming_NamedShape::GetID(), NS)) + { continue; + } TopoDS_Shape aSubShape = TNaming_Tool::GetShape(NS); if (!aSubShape.IsNull() && aSubShape.IsSame(sub)) { @@ -1073,7 +1143,9 @@ bool XCAFDoc_ShapeTool::AddSubShape(const TDF_Label& shapeL, addedSubShapeL = TDF_Label(); // Check if adding subshape is possible if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL)) + { return false; + } TopoDS_Shape aSubShape = sub; bool isDefined = true; @@ -1098,11 +1170,15 @@ bool XCAFDoc_ShapeTool::AddSubShape(const TDF_Label& shapeL, } } if (!isDefined) + { return false; + } // Try to find already existed subshape if (FindSubShape(shapeL, aSubShape, addedSubShapeL)) + { return false; + } TDF_TagSource aTag; addedSubShapeL = TDF_TagSource::NewChild(shapeL); @@ -1121,7 +1197,9 @@ TDF_Label XCAFDoc_ShapeTool::FindMainShapeUsingMap(const TopoDS_Shape& sub) cons // if(IsSubShape(L,sub)) return L; // } if (mySubShapes.IsBound(sub)) + { return mySubShapes.Find(sub); + } TDF_Label L0; return L0; } @@ -1136,7 +1214,9 @@ TDF_Label XCAFDoc_ShapeTool::FindMainShape(const TopoDS_Shape& sub) const TDF_Label L = it.Value(); if (IsSimpleShape(L) && IsSubShape(L, sub)) + { return L; + } } TDF_Label L0; return L0; @@ -1151,7 +1231,9 @@ bool XCAFDoc_ShapeTool::GetSubShapes(const TDF_Label& L, NCollection_Sequence 0; } @@ -1176,9 +1258,13 @@ static void DumpAssembly(Standard_OStream& theDumpLog, TopoDS_Shape S; XCAFDoc_ShapeTool::GetShape(L, S); if (S.IsNull()) + { return; + } for (int i = 0; i < level; i++) + { theDumpLog << "\t"; + } TCollection_AsciiString Entry; TDF_Tool::Entry(L, Entry); @@ -1190,7 +1276,9 @@ static void DumpAssembly(Standard_OStream& theDumpLog, else if (XCAFDoc_ShapeTool::IsSimpleShape(L)) { if (L.Father().Father().Father().IsRoot()) + { theDumpLog << "PART "; + } } else { @@ -1208,16 +1296,20 @@ static void DumpAssembly(Standard_OStream& theDumpLog, } occ::handle Name; if (L.FindAttribute(TDataStd_Name::GetID(), Name)) + { theDumpLog << " \"" << Name->Get() << "\" "; + } if (deep) { theDumpLog << "(" << *(void**)&S.TShape(); if (!S.Location().IsIdentity()) + { theDumpLog << ", " << *(void**)&S.Location(); + } theDumpLog << ") "; } - theDumpLog << std::endl; + theDumpLog << '\n'; occ::handle Node; TDF_ChildIterator NodeIterator(L); @@ -1226,7 +1318,9 @@ static void DumpAssembly(Standard_OStream& theDumpLog, DumpAssembly(theDumpLog, NodeIterator.Value(), level + 1, deep); } if (level == 0) - theDumpLog << std::endl; + { + theDumpLog << '\n'; + } } //================================================================================================= @@ -1239,7 +1333,9 @@ Standard_OStream& XCAFDoc_ShapeTool::Dump(Standard_OStream& theDumpLog, const bo GetShapes(SeqLabels); if (SeqLabels.Length() > 0) - theDumpLog << std::endl; + { + theDumpLog << '\n'; + } int i; for (i = 1; i <= SeqLabels.Length(); i++) { @@ -1248,11 +1344,11 @@ Standard_OStream& XCAFDoc_ShapeTool::Dump(Standard_OStream& theDumpLog, const bo SeqLabels.Clear(); GetFreeShapes(SeqLabels); - theDumpLog << std::endl << "Free Shapes: " << SeqLabels.Length() << std::endl; + theDumpLog << '\n' << "Free Shapes: " << SeqLabels.Length() << '\n'; for (i = 1; i <= SeqLabels.Length(); i++) { DumpShape(theDumpLog, SeqLabels.Value(i), level, deep); - theDumpLog << std::endl; + theDumpLog << '\n'; } return theDumpLog; } @@ -1275,9 +1371,13 @@ void XCAFDoc_ShapeTool::DumpShape(Standard_OStream& theDumpLog, { TopoDS_Shape S; if (!XCAFDoc_ShapeTool::GetShape(L, S)) + { return; + } for (int i = 0; i < level; i++) + { theDumpLog << "\t"; + } if (XCAFDoc_ShapeTool::IsAssembly(L)) { @@ -1286,7 +1386,9 @@ void XCAFDoc_ShapeTool::DumpShape(Standard_OStream& theDumpLog, else if (XCAFDoc_ShapeTool::IsSimpleShape(L)) { if (L.Father().Father().Father().IsRoot()) + { theDumpLog << "PART "; + } } else { @@ -1307,13 +1409,17 @@ void XCAFDoc_ShapeTool::DumpShape(Standard_OStream& theDumpLog, // std::cout< Name; if (L.FindAttribute(TDataStd_Name::GetID(), Name)) + { theDumpLog << " \"" << Name->Get() << "\" "; + } if (deep) { theDumpLog << "(" << *(void**)&S.TShape(); if (!S.Location().IsIdentity()) + { theDumpLog << ", " << *(void**)&S.Location(); + } theDumpLog << ") "; } } @@ -1406,7 +1512,9 @@ bool XCAFDoc_ShapeTool::GetAllComponentSHUO( TDF_Label L = it.Value(); occ::handle aSHUOAttr; if (GetSHUO(L, aSHUOAttr)) + { theSHUOAttrs.Append(aSHUOAttr); + } } return (theSHUOAttrs.Length() > 0); } @@ -1419,12 +1527,18 @@ bool XCAFDoc_ShapeTool::SetSHUO(const NCollection_Sequence& labels, MainSHUOAttr.Nullify(); // check number of labels if (labels.Length() < 2) + { return false; + } // check is all labels contains components of any assemblyies int i; for (i = 1; i <= labels.Length(); i++) + { if (!IsComponent(labels.Value(i))) + { return false; + } + } TDF_TagSource aTag; TDF_Label UpperSubL = TDF_TagSource::NewChild(labels(1)); @@ -1467,11 +1581,15 @@ bool XCAFDoc_ShapeTool::GetSHUOUpperUsage(const TDF_Label& NextU { occ::handle aNextSHUO; if (!GetSHUO(NextUsageL, aNextSHUO) || aNextSHUO->NbFathers() < 1) + { return false; + } // get upper_usage SHAO for (int i = 1; i <= aNextSHUO->NbFathers(); i++) + { aLabels.Append(aNextSHUO->GetFather(i)->Label()); + } return true; } @@ -1482,10 +1600,14 @@ bool XCAFDoc_ShapeTool::GetSHUONextUsage(const TDF_Label& UpperU { occ::handle aUpperSHUO; if (!GetSHUO(UpperUsageL, aUpperSHUO) || aUpperSHUO->NbChildren() < 1) + { return false; + } // get upper_usage SHAO for (int i = 1; i <= aUpperSHUO->NbChildren(); i++) + { aLabels.Append(aUpperSHUO->GetChild(i)->Label()); + } return true; } @@ -1566,17 +1688,21 @@ static bool checkForShape(const TopoDS_Shape& theShape, // try to search deeply (upper by assembly structure) NCollection_Sequence aNewLabels; for (int j = 1; j <= theLabels.Length(); j++) + { aNewLabels.Append(theLabels.Value(j)); + } aNewLabels.Prepend(theUserL); NCollection_Sequence aUsers; ::XCAFDoc_ShapeTool::GetUsers(aSuperUserL, aUsers); for (int i = 1; i <= aUsers.Length(); i++) + { if (checkForShape(theShape, aCopySh, aUsers.Value(i), aNewLabels)) { // get solution theLabels = aNewLabels; return true; } + } return false; } @@ -1592,13 +1718,19 @@ bool XCAFDoc_ShapeTool::FindComponent(const TopoDS_Shape& theShape, S0.Location(loc); TDF_Label aRefL = FindShape(S0); if (aRefL.IsNull()) + { return false; // cannot find top-level shape. + } NCollection_Sequence aUsers; ::XCAFDoc_ShapeTool::GetUsers(aRefL, aUsers); for (int i = 1; i <= aUsers.Length(); i++) + { if (checkForShape(theShape, S0, aUsers.Value(i), theLabels)) + { break; + } + } return (theLabels.Length() > 0); } @@ -1614,6 +1746,7 @@ static bool getShapesOfSHUO(NCollection_IndexedMap& theaPrevLoc NCollection_Sequence aLabSeq; theSTool->GetSHUONextUsage(theSHUOlab, aLabSeq); if (aLabSeq.Length() >= 1) + { for (int i = 1; i <= aLabSeq.Length(); i++) { TDF_Label aSubCompL = aLabSeq.Value(i); @@ -1621,23 +1754,30 @@ static bool getShapesOfSHUO(NCollection_IndexedMap& theaPrevLoc // create new map of laocation (to not merge locations from different shapes) NCollection_IndexedMap aNewPrevLocMap; for (int m = 1; m <= theaPrevLocMap.Extent(); m++) + { aNewPrevLocMap.Add(theaPrevLocMap.FindKey(m)); + } aNewPrevLocMap.Add(compLoc); // got for the new sublocations and corresponding shape getShapesOfSHUO(aNewPrevLocMap, theSTool, aSubCompL, theShape); } + } else { TopoDS_Shape aSHUO_NUSh = theSTool->GetShape(theSHUOlab.Father()); if (aSHUO_NUSh.IsNull()) + { return false; + } // cause got shape with location already. TopLoc_Location nullLoc; aSHUO_NUSh.Location(nullLoc); // multiply the locations int intMapLenght = theaPrevLocMap.Extent(); if (intMapLenght < 1) + { return false; // should not be, but to avoid exception...? + } TopLoc_Location SupcompLoc; SupcompLoc = theaPrevLocMap.FindKey(intMapLenght); if (intMapLenght > 1) @@ -1661,7 +1801,9 @@ TopoDS_Shape XCAFDoc_ShapeTool::GetSHUOInstance(const occ::handleLabel(); // get location of the assembly @@ -1671,7 +1813,9 @@ TopoDS_Shape XCAFDoc_ShapeTool::GetSHUOInstance(const occ::handle aPrevLocMap; // get previous set location if (!loc.IsIdentity()) + { aPrevLocMap.Add(loc); + } aPrevLocMap.Add(compLoc); // get shape by recurse method const occ::handle& STool = this; @@ -1698,7 +1842,9 @@ static bool getUsersShapesOfSHUO(NCollection_IndexedMap& aPrevL aNewPrevLocMap.Add(compLoc); int i; for (i = 1; i <= aPrevLocMap.Extent(); i++) + { aNewPrevLocMap.Add(aPrevLocMap.FindKey(i)); + } TDF_Label L = theUserL.Father(); NCollection_Sequence usersLab; ::XCAFDoc_ShapeTool::GetUsers(L, usersLab); @@ -1729,7 +1875,9 @@ bool XCAFDoc_ShapeTool::GetAllSHUOInstances( NCollection_Sequence& theSHUOShapeSeq) const { if (theSHUO.IsNull()) + { return false; + } TDF_Label aSHUOlab = theSHUO->Label(); NCollection_IndexedMap aPrevLocMap; @@ -1739,7 +1887,9 @@ bool XCAFDoc_ShapeTool::GetAllSHUOInstances( TopLoc_Location compLoc = XCAFDoc_ShapeTool::GetLocation(aSHUOlab.Father()); // get previous set location if (!loc.IsIdentity()) + { aPrevLocMap.Add(loc); + } aPrevLocMap.Add(compLoc); // get label of assembly TDF_Label L = aSHUOlab.Father().Father(); @@ -1774,8 +1924,10 @@ occ::handle XCAFDoc_ShapeTool::SetInstanceSHUO( occ::handle SHUO; NCollection_Sequence aLabels; if (FindComponent(theShape, aLabels)) + { // set shuo structure on labels of component-assembly structure SetSHUO(aLabels, SHUO); + } return SHUO; } @@ -1787,7 +1939,9 @@ bool XCAFDoc_ShapeTool::FindSHUO(const NCollection_Sequence& theLabel NCollection_Sequence> SHUOAttrs; TDF_Label aCompLabel = theLabels.Value(1); if (!::XCAFDoc_ShapeTool::GetAllComponentSHUO(aCompLabel, SHUOAttrs)) + { return false; + } // WARNING: manage that each SHUO upper_usage have only one SHUO next_usage for (int i = 1; i <= SHUOAttrs.Length(); i++) { @@ -1802,16 +1956,24 @@ bool XCAFDoc_ShapeTool::FindSHUO(const NCollection_Sequence& theLabel // check the label sequences bool isEqual = true; if (theLabels.Length() != aCondidate.Length()) + { isEqual = false; + } else + { for (int li = 1; li <= theLabels.Length(); li++) + { if (theLabels.Value(li) != aCondidate.Value(li)) { isEqual = false; break; } + } + } if (!isEqual) + { continue; + } theSHUOAttr = occ::down_cast(SHUOAttrs.Value(i)); break; @@ -1824,11 +1986,15 @@ bool XCAFDoc_ShapeTool::FindSHUO(const NCollection_Sequence& theLabel bool XCAFDoc_ShapeTool::Expand(const TDF_Label& theShapeL) { if (theShapeL.IsNull() || IsAssembly(theShapeL)) + { return false; + } TopoDS_Shape aShape = GetShape(theShapeL); if (aShape.IsNull()) + { return false; + } TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); bool isExpandedType = aShapeType == TopAbs_COMPOUND || aShapeType == TopAbs_COMPSOLID @@ -1926,7 +2092,9 @@ void XCAFDoc_ShapeTool::makeSubShape(const TDF_Label& theMainShapeL, // Calculate location for subshapes of compound parts aSubLoc = aChildShape.Location(); if (isCompoundPart) + { aSubLoc = theLoc.Inverted() * aSubLoc; + } // make subshape TDF_Label aSubLabel; // Identical location and empty location are not the same for ShapeTool, so try to process @@ -1971,7 +2139,9 @@ bool XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel NCollection_Map& theUpdated) const { if (!IsAssembly(theItemLabel)) + { return false; // Do nothing for non-assemblies + } // Get the currently stored compound for the assembly TopoDS_Shape aCurrentRootShape; @@ -1999,7 +2169,9 @@ bool XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel const int aNumTopoComponents = aCurrentRootShape.NbChildren(); // if (aNumTopoComponents != aComponentLabs.Length()) + { isModified = true; + } // Iterate over the assembly components. If at least one component is // modified (this is the recursive check), then the actually stored @@ -2080,7 +2252,9 @@ bool XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel } if (isModified) + { theUpdated.Add(theItemLabel); + } return isModified; } @@ -2107,7 +2281,9 @@ occ::handle XCAFDoc_ShapeTool::GetNamedProperties(const Topo occ::handle aNamedProperty; TDF_Label aLabel; if (!Search(theShape, aLabel)) + { return aNamedProperty; + } aNamedProperty = GetNamedProperties(aLabel, theToCreate); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_View.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_View.cxx index 4cb71db648..4f84bc33d5 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_View.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_View.cxx @@ -129,8 +129,10 @@ void XCAFDoc_View::SetObject(const occ::handle& theObject) // Clipping Expression if (!theObject->ClippingExpression().IsNull()) + { TDataStd_AsciiString::Set(Label().FindChild(ChildLab_ClippingExpression), theObject->ClippingExpression()->String()); + } // GDT points if (theObject->HasGDTPoints()) @@ -266,7 +268,9 @@ occ::handle XCAFDoc_View::GetObject() const for (; anItrPnts.More(); anItrPnts.Next()) { if (anItrPnts.Value().FindAttribute(TDataXtd_Point::GetID(), aGDTPointAttr)) + { aNbGDTPoints++; + } } // Allocate the GDT-points and fill them in from Ocaf tree. diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ViewTool.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ViewTool.cxx index 2bfc6ff1c9..8f9d0735b4 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ViewTool.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_ViewTool.cxx @@ -79,7 +79,9 @@ void XCAFDoc_ViewTool::GetViewLabels(NCollection_Sequence& theLabels) { TDF_Label aLabel = aChildIterator.Value(); if (IsView(aLabel)) + { theLabels.Append(aLabel); + } } } @@ -106,7 +108,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, const TDF_Label& theViewL) const { if (!IsView(theViewL)) + { return; + } occ::handle aChGNode; occ::handle aShapeGNode; @@ -122,7 +126,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, aShapeGNode = aChGNode->GetFather(1); aShapeGNode->UnSetChild(aChGNode); if (aShapeGNode->NbChildren() == 0) + { aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); } @@ -133,7 +139,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, aGDTGNode = aChGNode->GetFather(1); aGDTGNode->UnSetChild(aChGNode); if (aGDTGNode->NbChildren() == 0) + { aGDTGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); } @@ -144,7 +152,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID()); } @@ -155,7 +165,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefNoteGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefNoteGUID()); } @@ -166,7 +178,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapes, aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefAnnotationGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefAnnotationGUID()); } @@ -272,7 +286,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa const TDF_Label& theViewL) const { if (!IsView(theViewL)) + { return; + } occ::handle aChGNode; occ::handle aShapeGNode; @@ -286,7 +302,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa aShapeGNode = aChGNode->GetFather(1); aShapeGNode->UnSetChild(aChGNode); if (aShapeGNode->NbChildren() == 0) + { aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); } @@ -297,7 +315,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa aGDTGNode = aChGNode->GetFather(1); aGDTGNode->UnSetChild(aChGNode); if (aGDTGNode->NbChildren() == 0) + { aGDTGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); } @@ -308,7 +328,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID()); } @@ -376,7 +398,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa const TDF_Label& theViewL) const { if (!IsView(theViewL)) + { return; + } occ::handle aChGNode; occ::handle aShapeGNode; @@ -389,7 +413,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa aShapeGNode = aChGNode->GetFather(1); aShapeGNode->UnSetChild(aChGNode); if (aShapeGNode->NbChildren() == 0) + { aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); } @@ -400,7 +426,9 @@ void XCAFDoc_ViewTool::SetView(const NCollection_Sequence& theShapeLa aGDTGNode = aChGNode->GetFather(1); aGDTGNode->UnSetChild(aChGNode); if (aGDTGNode->NbChildren() == 0) + { aGDTGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); } @@ -449,7 +477,9 @@ void XCAFDoc_ViewTool::SetClippingPlanes( const TDF_Label& theViewL) const { if (!IsView(theViewL)) + { return; + } occ::handle aChGNode; occ::handle aPlaneGNode; @@ -461,7 +491,9 @@ void XCAFDoc_ViewTool::SetClippingPlanes( aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID()); } @@ -491,7 +523,9 @@ void XCAFDoc_ViewTool::SetClippingPlanes( void XCAFDoc_ViewTool::RemoveView(const TDF_Label& theViewL) { if (!IsView(theViewL)) + { return; + } occ::handle aChGNode; occ::handle aShapeGNode; @@ -505,7 +539,9 @@ void XCAFDoc_ViewTool::RemoveView(const TDF_Label& theViewL) aShapeGNode = aChGNode->GetFather(1); aShapeGNode->UnSetChild(aChGNode); if (aShapeGNode->NbChildren() == 0) + { aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefShapeGUID()); + } } } if (theViewL.FindAttribute(XCAFDoc::ViewRefGDTGUID(), aChGNode)) @@ -515,7 +551,9 @@ void XCAFDoc_ViewTool::RemoveView(const TDF_Label& theViewL) aGDTGNode = aChGNode->GetFather(1); aGDTGNode->UnSetChild(aChGNode); if (aGDTGNode->NbChildren() == 0) + { aGDTGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } } if (theViewL.FindAttribute(XCAFDoc::ViewRefPlaneGUID(), aChGNode)) @@ -525,7 +563,9 @@ void XCAFDoc_ViewTool::RemoveView(const TDF_Label& theViewL) aPlaneGNode = aChGNode->GetFather(1); aPlaneGNode->UnSetChild(aChGNode); if (aPlaneGNode->NbChildren() == 0) + { aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID()); + } } } theViewL.ForgetAllAttributes(); @@ -544,11 +584,15 @@ bool XCAFDoc_ViewTool::GetRefShapeLabel(const TDF_Label& theView if (theViewL.FindAttribute(XCAFDoc::ViewRefShapeGUID(), aGNode) && aGNode->NbFathers() > 0) { for (int i = 1; i <= aGNode->NbFathers(); i++) + { theShapeLabels.Append(aGNode->GetFather(i)->Label()); + } return true; } else + { return false; + } } theShapeLabels.Append(aNode->Father()->Label()); @@ -568,11 +612,15 @@ bool XCAFDoc_ViewTool::GetRefGDTLabel(const TDF_Label& theViewL, if (theViewL.FindAttribute(XCAFDoc::ViewRefGDTGUID(), aGNode) && aGNode->NbFathers() > 0) { for (int i = 1; i <= aGNode->NbFathers(); i++) + { theGDTLabels.Append(aGNode->GetFather(i)->Label()); + } return true; } else + { return false; + } } theGDTLabels.Append(aNode->Father()->Label()); @@ -593,11 +641,15 @@ bool XCAFDoc_ViewTool::GetRefClippingPlaneLabel( if (theViewL.FindAttribute(XCAFDoc::ViewRefPlaneGUID(), aGNode) && aGNode->NbFathers() > 0) { for (int i = 1; i <= aGNode->NbFathers(); i++) + { theClippingPlaneLabels.Append(aGNode->GetFather(i)->Label()); + } return true; } else + { return false; + } } theClippingPlaneLabels.Append(aNode->Father()->Label()); @@ -617,11 +669,15 @@ bool XCAFDoc_ViewTool::GetRefNoteLabel(const TDF_Label& theViewL if (theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aGNode) && aGNode->NbFathers() > 0) { for (int i = 1; i <= aGNode->NbFathers(); i++) + { theNoteLabels.Append(aGNode->GetFather(i)->Label()); + } return true; } else + { return false; + } } theNoteLabels.Append(aNode->Father()->Label()); @@ -642,11 +698,15 @@ bool XCAFDoc_ViewTool::GetRefAnnotationLabel( if (theViewL.FindAttribute(XCAFDoc::ViewRefAnnotationGUID(), aGNode) && aGNode->NbFathers() > 0) { for (int i = 1; i <= aGNode->NbFathers(); i++) + { theAnnotationLabels.Append(aGNode->GetFather(i)->Label()); + } return true; } else + { return false; + } } theAnnotationLabels.Append(aNode->Father()->Label()); diff --git a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Volume.cxx b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Volume.cxx index 30a0e2e0d4..0e8d610905 100644 --- a/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Volume.cxx +++ b/src/DataExchange/TKXCAF/XCAFDoc/XCAFDoc_Volume.cxx @@ -77,7 +77,9 @@ bool XCAFDoc_Volume::Get(const TDF_Label& label, double& vol) { occ::handle aVolume; if (!label.FindAttribute(XCAFDoc_Volume::GetID(), aVolume)) + { return false; + } vol = aVolume->Get(); return true; diff --git a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs.cxx b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs.cxx index 21eb954571..3a5c9b12bf 100644 --- a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs.cxx +++ b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs.cxx @@ -60,6 +60,7 @@ static bool getShapesOfSHUO(NCollection_IndexedMap& theaPrevLoc NCollection_Sequence aLabSeq; theSTool->GetSHUONextUsage(theSHUOlab, aLabSeq); if (aLabSeq.Length() >= 1) + { for (int i = 1; i <= aLabSeq.Length(); i++) { TDF_Label aSubCompL = aLabSeq.Value(i); @@ -67,23 +68,30 @@ static bool getShapesOfSHUO(NCollection_IndexedMap& theaPrevLoc // create new map of laocation (to not merge locations from different shapes) NCollection_IndexedMap aNewPrevLocMap; for (int m = 1; m <= theaPrevLocMap.Extent(); m++) + { aNewPrevLocMap.Add(theaPrevLocMap.FindKey(m)); + } aNewPrevLocMap.Add(compLoc); // got for the new sublocations and corresponding shape getShapesOfSHUO(aNewPrevLocMap, theSTool, aSubCompL, theSHUOShapeSeq); } + } else { TopoDS_Shape aSHUO_NUSh = theSTool->GetShape(theSHUOlab.Father()); if (aSHUO_NUSh.IsNull()) + { return false; + } // cause got shape with location already. TopLoc_Location nullLoc; aSHUO_NUSh.Location(nullLoc); // multiply the locations int intMapLenght = theaPrevLocMap.Extent(); if (intMapLenght < 1) + { return false; // should not be, but to avoid exception...? + } TopLoc_Location SupcompLoc; SupcompLoc = theaPrevLocMap.FindKey(intMapLenght); if (intMapLenght > 1) @@ -125,7 +133,9 @@ void XCAFPrs::CollectStyleSettings( occ::handle aColorTool = XCAFDoc_DocumentTool::ColorTool(theLabel); Quantity_ColorRGBA aColor; if (aColorTool->GetColor(aLayer, XCAFDoc_ColorGen, aColor)) + { aLayerColor = aColor; + } } TopLoc_Location aLocSub = theLoc.Multiplied(XCAFDoc_ShapeTool::GetLocation(theLabel)); CollectStyleSettings(aLabelRef, aLocSub, theSettings, aLayerColor); @@ -283,11 +293,14 @@ void XCAFPrs::CollectStyleSettings( const TopoDS_Shape& aShuoShape = aShuoShapeIter.Value(); XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek(aShuoShape); if (aMapStyle == nullptr) + { theSettings.Add(aShuoShape, aShuoStyle); + } else + { *aMapStyle = aShuoStyle; + } } - continue; } } @@ -307,9 +320,13 @@ void XCAFPrs::CollectStyleSettings( aSubshape.Move(theLoc, false); XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek(aSubshape); if (aMapStyle == nullptr) + { theSettings.Add(aSubshape, aStyle); + } else + { *aMapStyle = aStyle; + } } } diff --git a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_AISObject.cxx b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_AISObject.cxx index 7906a00e29..f125aec1a5 100644 --- a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_AISObject.cxx +++ b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_AISObject.cxx @@ -160,9 +160,13 @@ void XCAFPrs_AISObject::DispatchStyles(const bool theToSyncStyles) aBuilder.Add(aComp, aStyledShapeIter.Key()); TopoDS_Compound* aMapShape = aStyleGroups.ChangeSeek(aStyledShapeIter.Value()); if (aMapShape == nullptr) + { aStyleGroups.Add(aStyledShapeIter.Value(), aComp); + } else + { *aMapShape = aComp; + } } aSettings.Clear(); diff --git a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_Driver.cxx b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_Driver.cxx index 66248285d0..03d07df45d 100644 --- a/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_Driver.cxx +++ b/src/DataExchange/TKXCAF/XCAFPrs/XCAFPrs_Driver.cxx @@ -36,7 +36,9 @@ bool XCAFPrs_Driver::Update(const TDF_Label& L, occ::handle& ent) { if (!thegraph.IsPresent(thegraph.EntityNumber(ent))) + { return; + } thegraph.GetFromEntity(ent, false); for (Interface_EntityIterator shareds = thegraph.Shareds(ent); shareds.More(); shareds.Next()) + { GetFromEntity(shareds.Value()); + } for (Interface_EntityIterator sharings = thegraph.Sharings(ent); sharings.More(); sharings.Next()) + { GetFromEntity(sharings.Value()); + } } void IFGraph_AllConnected::ResetData() diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_AllShared.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_AllShared.cxx index ea3ba41f6d..ee7a05ac17 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_AllShared.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_AllShared.cxx @@ -27,7 +27,9 @@ IFGraph_AllShared::IFGraph_AllShared(const Interface_Graph& agra : thegraph(agraph) { if (!agraph.Model()->Contains(ent)) + { return; + } GetFromEntity(ent); } @@ -39,7 +41,9 @@ void IFGraph_AllShared::GetFromEntity(const occ::handle& ent void IFGraph_AllShared::GetFromIter(const Interface_EntityIterator& iter) { for (iter.Start(); iter.More(); iter.Next()) + { thegraph.GetFromEntity(iter.Value(), true); + } } void IFGraph_AllShared::ResetData() diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Articulations.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Articulations.cxx index 899fef1a2a..f69df4b043 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Articulations.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Articulations.cxx @@ -23,7 +23,9 @@ IFGraph_Articulations::IFGraph_Articulations(const Interface_Graph& agraph, cons : thegraph(agraph) { if (whole) + { thegraph.GetFromModel(); + } } void IFGraph_Articulations::GetFromEntity(const occ::handle& ent) @@ -53,7 +55,9 @@ void IFGraph_Articulations::Evaluate() { thenow = 0; if (thegraph.IsPresent(i)) + { Visit(i); + } } // Result in thelist Reset(); @@ -86,12 +90,18 @@ int IFGraph_Articulations::Visit(const int num) { int mm = Visit(nument); if (mm < min) + { min = mm; + } if (mm > thegraph.Status(num)) + { thelist->Append(num); // WE HAVE ONE: num + } } else if (statent < min) + { min = statent; + } } return min; } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Compare.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Compare.cxx index a7ad8fb000..c3c6289583 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Compare.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Compare.cxx @@ -36,7 +36,9 @@ void IFGraph_Compare::GetFromIter(const Interface_EntityIterator& iter, const bo { int stat = 2; if (first) + { stat = 1; + } thegraph.GetFromIter(iter, stat, 3, false); } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_ConnectedComponants.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_ConnectedComponants.cxx index 25d2c38847..ee92d74d1e 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_ConnectedComponants.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_ConnectedComponants.cxx @@ -39,7 +39,9 @@ void IFGraph_ConnectedComponants::Evaluate() { const occ::handle& ent = loaded.Value(); if (IsInPart(ent)) + { continue; + } IFGraph_AllConnected connect(Model(), ent); AddPart(); GetFromIter(connect); diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cumulate.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cumulate.cxx index f6714a8288..2cb1d40c07 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cumulate.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cumulate.cxx @@ -61,7 +61,9 @@ Interface_EntityIterator IFGraph_Cumulate::Overlapped() const for (int i = 1; i <= nb; i++) { if (thegraph.IsPresent(i) && thegraph.Status(i) > 2) + { iter.GetOneItem(thegraph.Entity(i)); + } } return iter; } @@ -73,7 +75,9 @@ Interface_EntityIterator IFGraph_Cumulate::Forgotten() const for (int i = 1; i <= nb; i++) { if (!thegraph.IsPresent(i)) + { iter.GetOneItem(thegraph.Model()->Value(i)); + } } return iter; } @@ -85,7 +89,9 @@ Interface_EntityIterator IFGraph_Cumulate::PerCount(const int count) const for (int i = 1; i <= nb; i++) { if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1)) + { iter.GetOneItem(thegraph.Model()->Value(i)); + } } return iter; } @@ -94,7 +100,9 @@ int IFGraph_Cumulate::NbTimes(const occ::handle& ent) const { int num = thegraph.EntityNumber(ent); if (num == 0) + { return 0; + } int stat = thegraph.Status(num); return stat - 1; } @@ -106,10 +114,14 @@ int IFGraph_Cumulate::HighestNbTimes() const for (int i = 1; i <= nb; i++) { if (!thegraph.IsPresent(i)) + { continue; + } int count = thegraph.Status(i) - 1; if (count > max) + { max = count; + } } return max; } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cycles.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cycles.cxx index aca2083c0d..74bd3aaf0d 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cycles.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_Cycles.cxx @@ -35,7 +35,9 @@ void IFGraph_Cycles::Evaluate() for (complist.Start(); complist.More(); complist.Next()) { if (complist.IsSingle()) + { continue; + } AddPart(); GetFromIter(complist.Entities()); } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_ExternalSources.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_ExternalSources.cxx index bd5dddaba6..b9cfb5cff5 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_ExternalSources.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_ExternalSources.cxx @@ -51,7 +51,9 @@ void IFGraph_ExternalSources::Evaluate() for (int i = 1; i <= nb; i++) { if (thegraph.IsPresent(i) && thegraph.Status(i) == 0) + { thegraph.GetFromIter(thegraph.Sharings(thegraph.Entity(i)), 1); + } } GetFromGraph(thegraph, 1); } @@ -63,7 +65,9 @@ bool IFGraph_ExternalSources::IsEmpty() for (int i = 1; i <= nb; i++) { if (thegraph.IsPresent(i) || thegraph.Status(i) == 1) + { return false; + } } return true; } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_StrongComponants.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_StrongComponants.cxx index eb26c3e3a8..3a751d0b6f 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_StrongComponants.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_StrongComponants.cxx @@ -30,7 +30,9 @@ void IFGraph_StrongComponants::Evaluate() for (int i = 1; i <= nb; i++) { if (!G.IsPresent(i)) + { continue; + } AddPart(); GetFromEntity(G.Entity(i), false); } diff --git a/src/DataExchange/TKXSBase/IFGraph/IFGraph_SubPartsIterator.cxx b/src/DataExchange/TKXSBase/IFGraph/IFGraph_SubPartsIterator.cxx index 1a884499c1..34dbdfa38b 100644 --- a/src/DataExchange/TKXSBase/IFGraph/IFGraph_SubPartsIterator.cxx +++ b/src/DataExchange/TKXSBase/IFGraph/IFGraph_SubPartsIterator.cxx @@ -29,7 +29,9 @@ IFGraph_SubPartsIterator::IFGraph_SubPartsIterator(const Interface_Graph& agraph : thegraph(agraph) { if (whole) + { thegraph.GetFromModel(); + } theparts = new NCollection_HSequence(); thefirsts = new NCollection_HSequence(); thepart = 0; @@ -50,7 +52,9 @@ IFGraph_SubPartsIterator::IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& oth for (int i = 1; i <= nb; i++) { if (thegraph.Status(i) == thepart) + { nbent++; + } } theparts->Append(nbent); // empty count } @@ -61,7 +65,9 @@ IFGraph_SubPartsIterator::IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& oth void IFGraph_SubPartsIterator::GetParts(IFGraph_SubPartsIterator& other) { if (Model() != other.Model()) + { throw Interface_InterfaceError("SubPartsIterator : GetParts"); + } // We ADD the Parts from other, without losing our own // (same principle as the constructor above) int nb = thegraph.Size(); @@ -74,7 +80,9 @@ void IFGraph_SubPartsIterator::GetParts(IFGraph_SubPartsIterator& other) for (int i = 1; i <= nb; i++) { if (thegraph.Status(i) == thepart) + { nbent++; + } } theparts->Append(nbent); // empty count } @@ -116,7 +124,9 @@ void IFGraph_SubPartsIterator::SetLoad() void IFGraph_SubPartsIterator::SetPartNum(const int num) { if (num <= 0 || num > theparts->Length()) + { throw Standard_OutOfRange("IFGraph_SubPartsIterator : SetPartNum"); + } thepart = num; } @@ -157,7 +167,9 @@ Interface_Graph IFGraph_SubPartsIterator::LoadedGraph() const for (int i = 1; i <= nb; i++) { if (thegraph.IsPresent(i) && thegraph.Status(i) == 0) + { G.GetFromEntity(thegraph.Entity(i), false); + } } return G; } @@ -171,7 +183,9 @@ bool IFGraph_SubPartsIterator::IsInPart(const occ::handle& e { int num = thegraph.EntityNumber(ent); if (!thegraph.IsPresent(num)) + { return false; + } return (thegraph.Status(num) != 0); } @@ -179,7 +193,9 @@ int IFGraph_SubPartsIterator::EntityPartNum(const occ::handleLength(); if (thepart > nbp) + { thepart = nbp; + } if (nbp == 0) { thecurr = 1; @@ -205,14 +223,20 @@ void IFGraph_SubPartsIterator::Start() for (int i = 1; i <= nb; i++) { if (!thegraph.IsPresent(i)) + { continue; + } int nump = thegraph.Status(i); if (nump < 1 || nump > nbp) + { continue; + } int nbent = partcounts.Value(nump); partcounts.SetValue(nump, nbent + 1); if (nbent == 0) + { partfirsts.SetValue(nump, i); + } } // - Format them (i.e. in sequences) theparts->Clear(); @@ -222,12 +246,16 @@ void IFGraph_SubPartsIterator::Start() { int nbent = partcounts.Value(np); if (np != 0) + { lastp = np; + } theparts->Append(nbent); thefirsts->Append(partfirsts.Value(np)); } if (lastp < nbp) + { theparts->Remove(lastp + 1, nbp); + } // Finally, prepare to iterate thecurr = 1; } @@ -235,7 +263,9 @@ void IFGraph_SubPartsIterator::Start() bool IFGraph_SubPartsIterator::More() { if (thecurr == 0) + { Start(); + } return (thecurr <= theparts->Length()); } @@ -243,43 +273,61 @@ void IFGraph_SubPartsIterator::Next() { thecurr++; if (thecurr > theparts->Length()) + { return; + } if (theparts->Value(thecurr) == 0) + { Next(); // skip empty parts + } } bool IFGraph_SubPartsIterator::IsSingle() const { if (thecurr < 1 || thecurr > theparts->Length()) + { throw Standard_NoSuchObject("IFGraph_SubPartsIterator : IsSingle"); + } return (theparts->Value(thecurr) == 1); } occ::handle IFGraph_SubPartsIterator::FirstEntity() const { if (thecurr < 1 || thecurr > theparts->Length()) + { throw Standard_NoSuchObject("IFGraph_SubPartsIterator : FirstEntity"); + } int nument = thefirsts->Value(thecurr); if (nument == 0) + { throw Standard_NoSuchObject("IFGraph_SubPartsIterator : FirstEntity (current part is empty)"); + } return thegraph.Entity(nument); } Interface_EntityIterator IFGraph_SubPartsIterator::Entities() const { if (thecurr < 1 || thecurr > theparts->Length()) + { throw Standard_NoSuchObject("IFGraph_SubPartsIterator : Entities"); + } Interface_EntityIterator iter; int nb = thegraph.Size(); int nument = thefirsts->Value(thecurr); if (nument == 0) + { return iter; + } if (theparts->Value(thecurr) == 1) + { nb = nument; // obvious: 1 single Entity + } for (int i = nument; i <= nb; i++) { if (thegraph.Status(i) == thecurr && thegraph.IsPresent(i)) + { iter.GetOneItem(thegraph.Entity(i)); + } } return iter; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Act.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Act.cxx index ba27b3cc1a..e9d5bc5da7 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Act.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Act.cxx @@ -32,7 +32,9 @@ IFSelect_Act::IFSelect_Act(const char* const name, IFSelect_ReturnStatus IFSelect_Act::Do(const int, const occ::handle& pilot) { if (!thefunc) + { return IFSelect_RetVoid; + } return thefunc(pilot); } @@ -45,10 +47,14 @@ void IFSelect_Act::SetGroup(const char* const group, const char* const file) { thedefgr.Clear(); if (group[0] != '\0') + { thedefgr.AssignCat(group); + } thedefil.Clear(); if (file[0] != '\0') + { thedefil.AssignCat(file); + } } void IFSelect_Act::AddFunc(const char* const name, @@ -57,7 +63,9 @@ void IFSelect_Act::AddFunc(const char* const name, { occ::handle act = new IFSelect_Act(name, help, func); if (thedefgr.Length() > 0) + { act->SetForGroup(thedefgr.ToCString()); + } act->Add(1, name); } @@ -67,6 +75,8 @@ void IFSelect_Act::AddFSet(const char* const name, { occ::handle act = new IFSelect_Act(name, help, func); if (thedefgr.Length() > 0) + { act->SetForGroup(thedefgr.ToCString(), thedefil.ToCString()); + } act->AddSet(1, name); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Activator.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Activator.cxx index d240cf21d3..14dafad3e9 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Activator.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Activator.cxx @@ -69,7 +69,9 @@ bool IFSelect_Activator::Select(const char* const command, { int num; if (!thedico.Find(command, num)) + { return false; + } number = thenums(num); actor = occ::down_cast(theacts(num)); return true; @@ -79,7 +81,9 @@ int IFSelect_Activator::Mode(const char* const command) { int num; if (!thedico.Find(command, num)) + { return -1; + } return themodes(num); } @@ -94,20 +98,28 @@ occ::handle> IFSelect_Activator:: for (; iter.More(); iter.Next()) { if (!iter.Key().StartsWith(command)) + { continue; + } if (mode < 0) { DeclareAndCast(IFSelect_Activator, acti, theacts(iter.Value())); if (acti.IsNull()) + { continue; + } if (command[0] == '\0' || !strcmp(command, acti->Group())) + { list->Append(iter.Key()); + } } else { num = iter.Value(); if (themodes(num) == mode) + { list->Append(iter.Key()); + } } } return list; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_AppliedModifiers.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_AppliedModifiers.cxx index 06ec2a151f..adbf79d7a7 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_AppliedModifiers.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_AppliedModifiers.cxx @@ -27,7 +27,9 @@ IFSelect_AppliedModifiers::IFSelect_AppliedModifiers(const int nbmax, const int bool IFSelect_AppliedModifiers::AddModif(const occ::handle& modif) { if (themodifs.Length() >= thelists.NbEntities()) + { return false; + } themodifs.Append(modif); thelists.SetNumber(themodifs.Length()); return true; @@ -49,7 +51,9 @@ bool IFSelect_AppliedModifiers::Item(const int num, int& entcount) { if (num < 1 || num > themodifs.Length()) + { return false; + } modif = themodifs.Value(num); thelists.SetNumber(num); theentcnt = thelists.Length(); @@ -67,7 +71,9 @@ occ::handle> IFSelect_AppliedModifiers::ItemList() co occ::handle> list = new NCollection_HSequence(); int i, nb = (theentcnt > 0 ? theentcnt : thenbent); for (i = 1; i <= nb; i++) + { list->Append(ItemNum(i)); + } return list; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_BasicDumper.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_BasicDumper.cxx index 862abde2b9..c671e3d296 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_BasicDumper.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_BasicDumper.cxx @@ -55,9 +55,13 @@ bool IFSelect_BasicDumper::WriteOwn(IFSelect_SessionFile& file, { occ::handle type = item->DynamicType(); if (type == STANDARD_TYPE(IFSelect_SelectModelRoots)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectModelEntities)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) { DeclareAndCast(IFSelect_SelectEntityNumber, sen, item); @@ -65,23 +69,41 @@ bool IFSelect_BasicDumper::WriteOwn(IFSelect_SessionFile& file, return true; } if (type == STANDARD_TYPE(IFSelect_SelectPointed)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectUnion)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectIntersection)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectDiff)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectRoots)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectRootComps)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectRange)) { DeclareAndCast(IFSelect_SelectRange, sra, item); @@ -90,14 +112,22 @@ bool IFSelect_BasicDumper::WriteOwn(IFSelect_SessionFile& file, return true; } if (type == STANDARD_TYPE(IFSelect_SelectShared)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_SelectSharing)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_DispPerOne)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_DispGlobal)) + { return true; + } if (type == STANDARD_TYPE(IFSelect_DispPerCount)) { DeclareAndCast(IFSelect_DispPerCount, dpc, item); @@ -109,12 +139,18 @@ bool IFSelect_BasicDumper::WriteOwn(IFSelect_SessionFile& file, { DeclareAndCast(IFSelect_TransformStandard, trs, item); if (trs->CopyOption()) + { file.SendText("copy"); + } else + { file.SendText("onthespot"); + } int nbm = trs->NbModifiers(); for (int i = 1; i <= nbm; i++) + { file.SendItem(trs->Modifier(i)); + } } return false; @@ -198,7 +234,9 @@ bool IFSelect_BasicDumper::ReadOwn(IFSelect_SessionFile& file, { const TCollection_AsciiString& exname = file.ParamValue(1); if (exname.Length() < FIRSTCHAR) + { return false; + } if (exname.Value(FIRSTCHAR) == 'e') { } @@ -206,7 +244,9 @@ bool IFSelect_BasicDumper::ReadOwn(IFSelect_SessionFile& file, { } else + { return false; + } // item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact); // return true; } @@ -244,13 +284,21 @@ bool IFSelect_BasicDumper::ReadOwn(IFSelect_SessionFile& file, bool copyoption; const TCollection_AsciiString& copyname = file.ParamValue(1); if (copyname.Length() < FIRSTCHAR) + { return false; + } if (copyname.Value(FIRSTCHAR) == 'c') + { copyoption = true; + } else if (copyname.Value(FIRSTCHAR) == 'o') + { copyoption = false; + } else + { return false; + } occ::handle trs = new IFSelect_TransformStandard; trs->SetCopyOption(copyoption); int nbp = file.NbParams(); @@ -258,7 +306,9 @@ bool IFSelect_BasicDumper::ReadOwn(IFSelect_SessionFile& file, { DeclareAndCast(IFSelect_Modifier, modif, file.ItemValue(i)); if (!modif.IsNull()) + { trs->AddModifier(modif); + } } item = trs; return true; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_CheckCounter.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_CheckCounter.cxx index dfa66cf403..0cd7e03e2d 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_CheckCounter.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_CheckCounter.cxx @@ -61,35 +61,53 @@ void IFSelect_CheckCounter::Analyse(const Interface_CheckIterator& const occ::handle& check = list.Value(); ent = check->Entity(); if (ent.IsNull() && num > 0 && num <= nbe) + { ent = model->Value(num); + } nb = check->NbFails(); const char* tystr = nullptr; if (!ent.IsNull()) { if (!thesign.IsNull()) + { tystr = thesign->Text(ent, model).ToCString(); + } else if (!model.IsNull()) + { tystr = model->TypeName(ent); + } else + { tystr = Interface_InterfaceModel::ClassName(ent->DynamicType()->Name()); + } } for (i = 1; i <= nb; i++) { if (ent.IsNull()) + { Sprintf(mess, "F: %s", check->CFail(i, original)); + } else + { Sprintf(mess, "F:%s: %s", tystr, check->CFail(i, original)); + } Add(ent, mess); } nb = 0; if (!failsonly) + { nb = check->NbWarnings(); + } for (i = 1; i <= nb; i++) { if (ent.IsNull()) + { Sprintf(mess, "W: %s", check->CWarning(i, original)); + } else + { Sprintf(mess, "W:%s: %s", tystr, check->CWarning(i, original)); + } Add(ent, mess); } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextModif.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextModif.cxx index 0618948bce..c2dd6e0633 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextModif.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextModif.cxx @@ -44,7 +44,9 @@ IFSelect_ContextModif::IFSelect_ContextModif(const Interface_Graph& graph, for (int i = 1; i <= nb; i++) { if (themap->Search(graph.Entity(i), newent)) + { thelist.SetValue(i, '1'); + } } } @@ -61,7 +63,9 @@ IFSelect_ContextModif::IFSelect_ContextModif(const Interface_Graph& graph, int nb = thelist.Length(); occ::handle newent; for (int i = 1; i <= nb; i++) + { thelist.SetValue(i, '1'); + } } //================================================================================================= @@ -71,20 +75,28 @@ void IFSelect_ContextModif::Select(Interface_EntityIterator& list) thesel = true; int nb = thelist.Length(); for (int i = 1; i <= nb; i++) + { thelist.SetValue(i, ' '); + } for (list.Start(); list.More(); list.Next()) { occ::handle start, newent; start = list.Value(); int num = thegraf.EntityNumber(start); if (num > nb || num < 0) + { num = 0; + } if (themap.IsNull() && num > 0) + { thelist.SetValue(num, '1'); + } else if (themap->Search(start, newent)) { if (num > 0) + { thelist.SetValue(num, '1'); + } } } } @@ -143,12 +155,16 @@ occ::handle IFSelect_ContextModif::Control() const bool IFSelect_ContextModif::IsForNone() const { if (!thesel) + { return false; + } int nb = thelist.Length(); for (int i = 1; i <= nb; i++) { if (thelist.Value(i) != ' ') + { return false; + } } return true; } @@ -165,7 +181,9 @@ bool IFSelect_ContextModif::IsForAll() const bool IFSelect_ContextModif::IsTransferred(const occ::handle& ent) const { if (themap.IsNull()) + { return true; + } occ::handle newent; return themap->Search(ent, newent); } @@ -177,7 +195,9 @@ bool IFSelect_ContextModif::IsSelected(const occ::handle& en // Select already verified "IsTransferred" int num = thegraf.EntityNumber(ent); if (num == 0) + { return false; + } return (thelist.Value(num) != ' '); } @@ -190,7 +210,9 @@ Interface_EntityIterator IFSelect_ContextModif::SelectedOriginal() const for (int i = 1; i <= nb; i++) { if (thelist.Value(i) != ' ') + { list.GetOneItem(thegraf.Entity(i)); + } } return list; } @@ -205,11 +227,17 @@ Interface_EntityIterator IFSelect_ContextModif::SelectedResult() const { occ::handle newent; if (themap.IsNull()) + { newent = thegraf.Entity(i); + } else if (thelist.Value(i) != ' ') + { themap->Search(thegraf.Entity(i), newent); + } if (!newent.IsNull()) + { list.GetOneItem(newent); + } } return list; } @@ -223,7 +251,9 @@ int IFSelect_ContextModif::SelectedCount() const for (int i = 1; i <= nb; i++) { if (thelist.Value(i) != ' ') + { ns++; + } } return ns; } @@ -267,7 +297,9 @@ void IFSelect_ContextModif::Next() occ::handle IFSelect_ContextModif::ValueOriginal() const { if (thecurr <= 0) + { throw Standard_NoSuchObject("IFSelect_ContextModif"); + } return thegraf.Entity(thecurr); } @@ -276,13 +308,19 @@ occ::handle IFSelect_ContextModif::ValueOriginal() const occ::handle IFSelect_ContextModif::ValueResult() const { if (thecurr <= 0) + { throw Standard_NoSuchObject("IFSelect_ContextModif"); + } occ::handle ent, newent; ent = thegraf.Entity(thecurr); if (themap.IsNull()) + { newent = ent; + } else + { themap->Search(ent, newent); + } return newent; } @@ -291,27 +329,39 @@ occ::handle IFSelect_ContextModif::ValueResult() const void IFSelect_ContextModif::TraceModifier(const occ::handle& modif) { if (modif.IsNull()) + { return; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "--- Run Modifier:" << std::endl; + sout << "--- Run Modifier:" << '\n'; occ::handle sel = modif->Selection(); if (!sel.IsNull()) + { sout << " Selection:" << sel->Label(); + } else + { sout << " (no Selection)"; + } // on va simplement compter les entites int ne = 0, nb = thelist.Length(); for (int i = 1; i <= nb; i++) { if (thelist.Value(i) != ' ') + { ne++; + } } if (nb == ne) - sout << " All Model (" << nb << " Entities)" << std::endl; + { + sout << " All Model (" << nb << " Entities)" << '\n'; + } else - sout << " Entities,Total:" << nb << " Concerned:" << ne << std::endl; + { + sout << " Entities,Total:" << nb << " Concerned:" << ne << '\n'; + } } //================================================================================================= @@ -320,15 +370,23 @@ void IFSelect_ContextModif::Trace(const char* const mess) { // Trace courante if (thecurr <= 0) + { return; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (ValueOriginal() == ValueResult()) - sout << "-- ContextModif. Entity n0 " << thecurr << std::endl; + { + sout << "-- ContextModif. Entity n0 " << thecurr << '\n'; + } else + { sout << "-- ContextModif. Entity in Original, n0 " << thecurr << " in Result, n0 " << thecurt - << std::endl; + << '\n'; + } if (mess[0] != '\0') - sout << "-- Message:" << mess << std::endl; + { + sout << "-- Message:" << mess << '\n'; + } } //================================================================================================= @@ -336,11 +394,15 @@ void IFSelect_ContextModif::Trace(const char* const mess) void IFSelect_ContextModif::AddCheck(const occ::handle& check) { if (check->NbFails() + check->NbWarnings() == 0) + { return; + } const occ::handle& ent = check->Entity(); int num = thegraf.EntityNumber(ent); if (num == 0 && !ent.IsNull()) + { num = -1; // force enregistrement + } thechek.Add(check, num); } @@ -368,7 +430,9 @@ occ::handle IFSelect_ContextModif::CCheck(const int num) { occ::handle ach = thechek.CCheck(num); if (num > 0 && num <= thegraf.Size()) + { ach->SetEntity(thegraf.Entity(num)); + } return ach; } @@ -379,7 +443,9 @@ occ::handle IFSelect_ContextModif::CCheck( { int num = thegraf.EntityNumber(ent); if (num == 0) + { num = -1; // force l enregistrement + } occ::handle& ach = thechek.CCheck(num); ach->SetEntity(ent); return ach; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextWrite.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextWrite.cxx index 4ac00ca4a7..aa7f395b5a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextWrite.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ContextWrite.cxx @@ -88,7 +88,9 @@ occ::handle IFSelect_ContextWrite::AppliedModifiers() const Interface_Graph& IFSelect_ContextWrite::Graph() { if (thehgraf.IsNull()) + { thehgraf = new Interface_HGraph(themodel, theproto); + } return thehgraf->Graph(); } @@ -104,9 +106,13 @@ bool IFSelect_ContextWrite::SetModifier(const int numod) themodif.Nullify(); thenumod = thenbent = thecurr = 0; if (theapply.IsNull()) + { return false; + } if (numod < 1 || numod > theapply->Count()) + { return false; + } theapply->Item(numod, themodif, thenbent); return true; } @@ -165,7 +171,9 @@ void IFSelect_ContextWrite::Next() occ::handle IFSelect_ContextWrite::Value() const { if (thecurr < 1 || thecurr > thenbent) + { throw Standard_NoSuchObject("IFSelect_ContextWrite:Value"); + } int num = theapply->ItemNum(thecurr); return themodel->Value(num); } @@ -175,11 +183,15 @@ occ::handle IFSelect_ContextWrite::Value() const void IFSelect_ContextWrite::AddCheck(const occ::handle& check) { if (check->NbFails() + check->NbWarnings() == 0) + { return; + } const occ::handle& ent = check->Entity(); int num = themodel->Number(ent); if (num == 0 && !ent.IsNull()) + { num = -1; // force enregistrement + } thecheck.Add(check, num); } @@ -207,7 +219,9 @@ occ::handle IFSelect_ContextWrite::CCheck(const int num) { occ::handle ach = thecheck.CCheck(num); if (num > 0 && num <= themodel->NbEntities()) + { ach->SetEntity(themodel->Value(num)); + } return ach; } @@ -218,7 +232,9 @@ occ::handle IFSelect_ContextWrite::CCheck( { int num = themodel->Number(ent); if (num == 0) + { num = -1; // force l enregistrement + } occ::handle ach = thecheck.CCheck(num); ach->SetEntity(ent); return ach; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerCount.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerCount.cxx index 0ffcf87fc5..543470040a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerCount.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerCount.cxx @@ -40,9 +40,13 @@ int IFSelect_DispPerCount::CountValue() const { int pcount = 0; if (!thecount.IsNull()) + { pcount = thecount->Value(); + } if (pcount <= 0) + { pcount = 1; // option prise par defaut + } return pcount; } @@ -76,10 +80,14 @@ void IFSelect_DispPerCount::Packets(const Interface_Graph& G, IFGraph_SubPartsIt for (roots.Start(); roots.More(); roots.Next()) { if (i == 0) + { packs.AddPart(); + } i++; if (i >= pcount) + { i = 0; // regroupement selon "count" + } packs.GetFromIter(roots.Entities()); } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerFiles.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerFiles.cxx index 7bceecf66f..85d09262c6 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerFiles.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerFiles.cxx @@ -40,9 +40,13 @@ int IFSelect_DispPerFiles::CountValue() const { int pcount = 0; if (!thecount.IsNull()) + { pcount = thecount->Value(); + } if (pcount <= 0) + { pcount = 1; // default option taken + } return pcount; } @@ -74,16 +78,22 @@ void IFSelect_DispPerFiles::Packets(const Interface_Graph& G, IFGraph_SubPartsIt roots.Start(); // Start performs specific Evaluate int nb = roots.NbParts(); if (pcount > 0) + { pcount = (nb - 1) / pcount + 1; // per packet + } int i = 0; for (; roots.More(); roots.Next()) { // Start already done if (i == 0) + { packs.AddPart(); + } i++; if (i >= pcount) + { i = 0; // regroupement selon "count" + } packs.GetFromIter(roots.Entities()); } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerSignature.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerSignature.cxx index 729ab1769a..ca51e45603 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerSignature.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_DispPerSignature.cxx @@ -79,10 +79,14 @@ void IFSelect_DispPerSignature::Packets(const Interface_Graph& G, asign = list->Value(is); ents = thesign->Entities(asign->ToCString()); if (ents.IsNull()) + { continue; + } packs.AddPart(); nb = ents->Length(); for (i = 1; i <= nb; i++) + { packs.GetFromEntity(ents->Value(i), false); + } } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Dispatch.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Dispatch.cxx index c3aae32dda..99878e999a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Dispatch.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Dispatch.cxx @@ -80,7 +80,9 @@ Interface_EntityIterator IFSelect_Dispatch::Packeted(const Interface_Graph& G) c Interface_EntityIterator total = GetEntities(G); Interface_EntityIterator remain = Remainder(G); if (remain.NbEntities() == 0) + { return total; + } // otherwise, make the difference! IFGraph_Compare GC(G); GC.GetFromIter(total, true); diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_EditForm.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_EditForm.cxx index cbeab9809d..02354a4fbe 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_EditForm.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_EditForm.cxx @@ -60,7 +60,9 @@ IFSelect_EditForm::IFSelect_EditForm(const occ::handle& editor, { int i, nb = nums.Length(); for (i = 1; i <= nb; i++) + { thenums.SetValue(i, nums.Value(i)); + } } bool& IFSelect_EditForm::EditKeepStatus() @@ -125,28 +127,38 @@ bool IFSelect_EditForm::IsComplete() const int IFSelect_EditForm::NbValues(const bool editable) const { if (!editable || thecomplete) + { return theeditor->NbValues(); + } return thenums.Upper(); } int IFSelect_EditForm::NumberFromRank(const int rank) const { if (thecomplete) + { return rank; + } if (rank < 1 || rank > thenums.Upper()) + { return 0; + } return thenums.Value(rank); } int IFSelect_EditForm::RankFromNumber(const int num) const { if (thecomplete) + { return num; + } int i, n = thenums.Upper(); for (i = 1; i <= n; i++) { if (thenums.Value(i) == num) + { return i; + } } return 0; } @@ -155,13 +167,17 @@ int IFSelect_EditForm::NameNumber(const char* const name) const { int res = theeditor->NameNumber(name); if (thecomplete || res == 0) + { return res; + } // Otherwise, search res in thenums int i, nb = thenums.Length(); for (i = 1; i <= nb; i++) { if (res == thenums.Value(i)) + { return res; + } } return -res; } @@ -170,13 +186,17 @@ int IFSelect_EditForm::NameRank(const char* const name) const { int res = theeditor->NameNumber(name); if (thecomplete || res == 0) + { return res; + } // Otherwise, search res in thenums int i, nb = thenums.Length(); for (i = 1; i <= nb; i++) { if (res == thenums.Value(i)) + { return i; + } } return 0; } @@ -187,12 +207,16 @@ void IFSelect_EditForm::LoadDefault() thetouched = 0; int i, nb = theorigs.Upper(); if (nb == 0) + { return; + } for (i = 1; i <= nb; i++) { int num = NumberFromRank(i); if (num == 0) + { continue; + } occ::handle str = theeditor->StringValue(this, num); theorigs.SetValue(i, str); } @@ -203,7 +227,9 @@ bool IFSelect_EditForm::LoadData(const occ::handle& en { thetouched = 0; if (!theeditor->Load(this, ent, model)) + { return false; + } SetData(ent, model); theloaded = true; return true; @@ -214,7 +240,9 @@ bool IFSelect_EditForm::LoadEntity(const occ::handle& ent) thetouched = 0; occ::handle model; if (!theeditor->Load(this, ent, model)) + { return false; + } SetEntity(ent); theloaded = true; return true; @@ -225,7 +253,9 @@ bool IFSelect_EditForm::LoadModel(const occ::handle& m thetouched = 0; occ::handle ent; if (!theeditor->Load(this, ent, model)) + { return false; + } SetData(ent, model); theloaded = true; return true; @@ -237,7 +267,9 @@ bool IFSelect_EditForm::LoadData() occ::handle model; occ::handle ent; if (!theeditor->Load(this, ent, model)) + { return false; + } theloaded = true; return true; } @@ -249,9 +281,13 @@ occ::handle IFSelect_EditForm::ListEditor(const int num) co int n = RankFromNumber(num); occ::handle led; if (n <= 0 || n > theorigs.Upper()) + { return led; + } if (!theeditor->IsList(n)) + { return led; + } led = theeditor->ListEditor(num); occ::handle>> lis = theeditor->ListValue(this, num); @@ -264,7 +300,9 @@ void IFSelect_EditForm::LoadValue(const int num, const occ::handle theorigs.Upper()) + { return; + } theorigs.SetValue(n, val); } @@ -274,7 +312,9 @@ void IFSelect_EditForm::LoadList( { int n = RankFromNumber(num); if (n <= 0 || n > theorigs.Upper()) + { return; + } theorigs.SetValue(n, list); } @@ -283,9 +323,13 @@ occ::handle IFSelect_EditForm::OriginalValue(const int int n = RankFromNumber(num); occ::handle val; if (theorigs.Upper() == 0) + { return theeditor->StringValue(this, num); + } else + { return occ::down_cast(theorigs.Value(n)); + } } occ::handle>> IFSelect_EditForm:: @@ -294,18 +338,26 @@ occ::handle>> IFSele int n = RankFromNumber(num); occ::handle>> list; if (theorigs.Upper() == 0) + { return theeditor->ListValue(this, num); + } else + { return occ::down_cast>>( theorigs.Value(n)); + } } occ::handle IFSelect_EditForm::EditedValue(const int num) const { if (themodifs.Upper() == 0) + { return OriginalValue(num); + } if (!IsModified(num)) + { return OriginalValue(num); + } int n = RankFromNumber(num); return occ::down_cast(themodifs.Value(n)); } @@ -314,9 +366,13 @@ occ::handle>> IFSele EditedList(const int num) const { if (themodifs.Upper() == 0) + { return OriginalList(num); + } if (!IsModified(num)) + { return OriginalList(num); + } int n = RankFromNumber(num); return occ::down_cast>>( themodifs.Value(n)); @@ -325,7 +381,9 @@ occ::handle>> IFSele bool IFSelect_EditForm::IsModified(const int num) const { if (thestatus.Upper() == 0) + { return false; + } int n = RankFromNumber(num); return (thestatus.Value(n) != 0); } @@ -333,7 +391,9 @@ bool IFSelect_EditForm::IsModified(const int num) const bool IFSelect_EditForm::IsTouched(const int num) const { if (thestatus.Upper() == 0) + { return false; + } int n = RankFromNumber(num); return (thestatus.Value(n) == 2); } @@ -345,32 +405,48 @@ bool IFSelect_EditForm::Modify(const int num, // Peut-on editer thetouched = 0; if (themodifs.Upper() == 0) + { return false; + } int tnum = RankFromNumber(num); if (tnum == 0) + { return false; + } IFSelect_EditValue acc = theeditor->EditMode(num); if (newval.IsNull() && acc != IFSelect_Optional) + { return false; + } if (!enforce && (acc == IFSelect_EditProtected || acc == IFSelect_EditComputed)) + { return false; + } // Satisfies ? occ::handle typval = theeditor->TypedValue(num); if (!typval->Satisfies(newval)) + { return false; + } Interface_ParamType pty = typval->Type(); if (pty == Interface_ParamIdent && !newval.IsNull()) { if (themodel.IsNull()) + { return false; + } if (themodel->NextNumberForLabel(newval->ToCString(), 0, false) <= 0) + { return false; + } } // Update ? if (!theeditor->Update(this, num, newval, enforce)) + { return false; + } thestatus.SetValue(tnum, 1); themodifs.SetValue(tnum, newval); @@ -383,30 +459,46 @@ bool IFSelect_EditForm::ModifyList(const int num, { // Faut-il prendre if (edited.IsNull()) + { return false; + } if (!edited->IsTouched()) + { return false; + } occ::handle>> newlist = edited->EditedValues(); // Peut-on editer thetouched = 0; if (themodifs.Upper() == 0) + { return false; + } int tnum = RankFromNumber(num); if (tnum == 0) + { return false; + } IFSelect_EditValue acc = theeditor->EditMode(num); if (acc == IFSelect_EditRead || acc == IFSelect_EditDynamic) + { return false; + } if (newlist.IsNull() && acc != IFSelect_Optional) + { return false; + } if (!enforce && (acc == IFSelect_EditProtected || acc == IFSelect_EditComputed)) + { return false; + } // Update ? if (!theeditor->UpdateList(this, num, newlist, enforce)) + { return false; + } thestatus.SetValue(tnum, 1); themodifs.SetValue(tnum, newlist); @@ -420,19 +512,27 @@ bool IFSelect_EditForm::ModifyListValue( { occ::handle led = ListEditor(num); if (led.IsNull()) + { return false; + } if (!led->LoadEdited(list)) + { return false; + } return ModifyList(num, led, enforce); } bool IFSelect_EditForm::Touch(const int num, const occ::handle& newval) { if (themodifs.Upper() == 0) + { return false; + } int tnum = RankFromNumber(num); if (tnum == 0) + { return false; + } thestatus.SetValue(tnum, 2); themodifs.SetValue(tnum, newval); @@ -445,10 +545,14 @@ bool IFSelect_EditForm::TouchList( const occ::handle>>& newlist) { if (themodifs.Upper() == 0) + { return false; + } int tnum = RankFromNumber(num); if (tnum == 0) + { return false; + } thestatus.SetValue(tnum, 2); themodifs.SetValue(tnum, newlist); @@ -462,30 +566,38 @@ void IFSelect_EditForm::ClearEdit(const int num) if (num == 0) { for (i = 1; i <= nb; i++) + { thestatus.SetValue(i, 0); + } } else { int tnum = RankFromNumber(num); if (tnum > 0 && num <= nb) + { thestatus.SetValue(tnum, 0); + } } } void IFSelect_EditForm::PrintDefs(Standard_OStream& S) const { int iv, nbv = NbValues(true); - S << "***** EditForm, Label : " << Label() << std::endl; + S << "***** EditForm, Label : " << Label() << '\n'; if (IsComplete()) - S << "Complete, " << nbv << " Values" << std::endl; + { + S << "Complete, " << nbv << " Values" << '\n'; + } else { - S << "Extraction on " << nbv << " Values : (extracted<-editor)" << std::endl; + S << "Extraction on " << nbv << " Values : (extracted<-editor)" << '\n'; for (iv = 1; iv <= nbv; iv++) + { S << " " << iv << "<-" << NumberFromRank(iv); - S << std::endl; + } + S << '\n'; } - S << "*****" << std::endl; + S << "*****" << '\n'; } static void PrintList( @@ -495,19 +607,21 @@ static void PrintList( { if (list.IsNull()) { - S << "(NULL LIST)" << std::endl; + S << "(NULL LIST)" << '\n'; return; } int i, nb = list->Length(); - S << "(List : " << nb << " Items)" << std::endl; + S << "(List : " << nb << " Items)" << '\n'; if (!alsolist) + { return; + } for (i = 1; i <= nb; i++) { occ::handle str = list->Value(i); - S << " [" << i << "] " << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + S << " [" << i << "] " << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; } } @@ -517,26 +631,33 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, const bool alsolist) const { int iv, nbv = NbValues(true); - S << "****************************************************" << std::endl; - S << "***** " << Label() << Interface_MSG::Blanks(Label(), 40) << "*****" << std::endl; - S << "***** *****" << std::endl; + S << "****************************************************" << '\n'; + S << "***** " << Label() << Interface_MSG::Blanks(Label(), 40) << "*****" << '\n'; + S << "***** *****" << '\n'; if (!theloaded) - S << "***** Values are NOT loaded *****" << std::endl; - + { + S << "***** Values are NOT loaded *****" << '\n'; + } else { // Data on which we worked if (themodel.IsNull()) { if (theent.IsNull()) + { S << "***** No loaded data"; + } else + { S << "***** No loaded Model. Loaded object : type " << theent->DynamicType()->Name(); + } } else { if (theent.IsNull()) + { S << "***** No loaded entity"; + } else { S << "***** Loaded entity : "; @@ -544,9 +665,7 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, } } } - S << std::endl - << "****************************************************" << std::endl - << std::endl; + S << '\n' << "****************************************************" << '\n' << '\n'; // Display of values bool nams = names; @@ -558,9 +677,13 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, } int nbmod = 0; if (what != 0) - S << "Mod N0 Name Value" << std::endl; + { + S << "Mod N0 Name Value" << '\n'; + } else - S << " N0 Name Value" << std::endl; + { + S << " N0 Name Value" << '\n'; + } for (iv = 1; iv <= nbv; iv++) { @@ -572,9 +695,13 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, { occ::handle str; if (IsModified(jv)) + { S << "* "; + } else + { S << " "; + } S << Interface_MSG::Blanks(iv, 3) << iv << " " << name << Interface_MSG::Blanks(name, maxnam) << " "; @@ -582,26 +709,36 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, { occ::handle>> list; if (what < 0) + { list = OriginalList(jv); + } if (what > 0) + { list = EditedList(jv); + } PrintList(list, S, alsolist); continue; } if (what < 0) + { str = OriginalValue(jv); + } if (what > 0) + { str = EditedValue(jv); + } - S << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + S << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; // Modified only } else { if (!IsModified(jv)) + { continue; + } nbmod++; if (theeditor->IsList(jv)) { @@ -620,21 +757,25 @@ void IFSelect_EditForm::PrintValues(Standard_OStream& S, occ::handle str = OriginalValue(jv); S << Interface_MSG::Blanks(iv, 3) << iv << " " << name << Interface_MSG::Blanks(name, maxnam) - << " ORIG:" << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + << " ORIG:" << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; str = EditedValue(jv); S << Interface_MSG::Blanks("", maxnam + 4) - << " MOD :" << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + << " MOD :" << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; } } if (what == 0) - S << "On " << nbv << " Values, " << nbmod << " Modified" << std::endl; + { + S << "On " << nbv << " Values, " << nbmod << " Modified" << '\n'; + } } bool IFSelect_EditForm::Apply() { bool stat = ApplyData(theent, themodel); if (stat && !thekeepst) + { ClearEdit(); + } return stat; } @@ -652,12 +793,16 @@ bool IFSelect_EditForm::ApplyData(const occ::handle& e bool IFSelect_EditForm::Undo() { if (thestatus.Upper() == 0 || theorigs.Upper() == 0) + { return false; + } int i, nb = thestatus.Upper(); for (i = 1; i <= nb; i++) { if (thestatus.Value(i) != 0) + { themodifs.SetValue(i, theorigs.Value(i)); + } } return Apply(); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Editor.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Editor.cxx index 783b8ed17a..0dd1228223 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Editor.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Editor.cxx @@ -42,7 +42,9 @@ IFSelect_Editor::IFSelect_Editor(const int nbval) void IFSelect_Editor::SetNbValues(const int nbval) { if (nbval > thevalues.Upper()) + { throw Standard_OutOfRange("IFSelect_Editor:SetNbValues"); + } thenbval = nbval; } @@ -52,19 +54,29 @@ void IFSelect_Editor::SetValue(const int num, const IFSelect_EditValue editmode) { if (num < 1 || num > thenbval) + { return; + } TCollection_AsciiString shn(shortname); int lng = shn.Length(); if (lng > 0) + { thenames.Bind(shortname, num); + } if (lng > themaxsh) + { themaxsh = lng; + } lng = (int)strlen(typval->Name()); if (lng > themaxco) + { themaxco = lng; + } lng = (int)strlen(typval->Label()); if (lng > themaxla) + { themaxla = lng; + } thenames.Bind(typval->Name(), num); int edm = (int)editmode; @@ -76,7 +88,9 @@ void IFSelect_Editor::SetValue(const int num, void IFSelect_Editor::SetList(const int num, const int max) { if (num < 1 || num > thenbval) + { return; + } thelists.SetValue(num, max); } @@ -93,31 +107,43 @@ occ::handle IFSelect_Editor::TypedValue(const int num) con bool IFSelect_Editor::IsList(const int num) const { if (num < 1 || num > thenbval) + { return false; + } return (thelists.Value(num) >= 0); } int IFSelect_Editor::MaxList(const int num) const { if (num < 1 || num > thenbval) + { return -1; + } return thelists.Value(num); } const char* IFSelect_Editor::Name(const int num, const bool isshort) const { if (num < 1 || num > thenbval) + { return ""; + } if (isshort) + { return theshorts.Value(num).ToCString(); + } else + { return TypedValue(num)->Name(); + } } IFSelect_EditValue IFSelect_Editor::EditMode(const int num) const { if (num < 1 || num > thenbval) + { return IFSelect_EditDynamic; + } int edm = themodes.Value(num); return (IFSelect_EditValue)edm; } @@ -125,54 +151,65 @@ IFSelect_EditValue IFSelect_Editor::EditMode(const int num) const void IFSelect_Editor::PrintNames(Standard_OStream& S) const { int i, nb = NbValues(); - S << "**** Editor : " << Label() << std::endl; - S << "**** Nb Values = " << nb << " **** Names / Labels" << std::endl; + S << "**** Editor : " << Label() << '\n'; + S << "**** Nb Values = " << nb << " **** Names / Labels" << '\n'; S << " Num "; if (themaxsh > 0) + { S << "Short" << Interface_MSG::Blanks("Short", themaxsh) << " "; - S << "Complete" << Interface_MSG::Blanks("Complete", themaxco) << " Label" << std::endl; + } + S << "Complete" << Interface_MSG::Blanks("Complete", themaxco) << " Label" << '\n'; for (i = 1; i <= nb; i++) { occ::handle tv = TypedValue(i); if (tv.IsNull()) + { continue; + } S << Interface_MSG::Blanks(i, 3) << i << " "; if (themaxsh > 0) { const TCollection_AsciiString& sho = theshorts(i); S << sho << Interface_MSG::Blanks(sho.ToCString(), themaxsh) << " "; } - S << tv->Name() << Interface_MSG::Blanks(tv->Name(), themaxco) << " " << tv->Label() - << std::endl; + S << tv->Name() << Interface_MSG::Blanks(tv->Name(), themaxco) << " " << tv->Label() << '\n'; } } void IFSelect_Editor::PrintDefs(Standard_OStream& S, const bool labels) const { int i, nb = NbValues(); - S << "**** Editor : " << Label() << std::endl; + S << "**** Editor : " << Label() << '\n'; S << "**** Nb Values = " << nb << " **** " << (labels ? "Labels" : "Names") - << " / Definitions" << std::endl; + << " / Definitions" << '\n'; S << " Num "; if (labels) + { S << "Label" << Interface_MSG::Blanks("Label", themaxla); + } else { if (themaxsh > 0) + { S << "Short" << Interface_MSG::Blanks("Short", themaxsh + 1); + } S << "Complete" << Interface_MSG::Blanks("Complete", themaxco); } - S << " Edit Mode & Definition" << std::endl; + S << " Edit Mode & Definition" << '\n'; for (i = 1; i <= nb; i++) { occ::handle tv = TypedValue(i); if (tv.IsNull()) + { continue; + } S << " " << Interface_MSG::Blanks(i, 3) << i << " "; if (labels) + { S << tv->Label() << Interface_MSG::Blanks(tv->Label(), themaxla); + } else { if (themaxsh > 0) @@ -186,11 +223,17 @@ void IFSelect_Editor::PrintDefs(Standard_OStream& S, const bool labels) const S << " "; int maxls = MaxList(i); if (maxls == 0) + { S << " (List) "; + } else if (maxls > 0) + { S << " (List <= " << maxls << " Items) "; + } else + { S << " "; + } IFSelect_EditValue edm = EditMode(i); switch (edm) { @@ -217,18 +260,24 @@ void IFSelect_Editor::PrintDefs(Standard_OStream& S, const bool labels) const break; } - S << " " << tv->Definition() << std::endl; + S << " " << tv->Definition() << '\n'; } } int IFSelect_Editor::MaxNameLength(const int what) const { if (what == -1) + { return themaxsh; + } if (what == 0) + { return themaxco; + } if (what == 1) + { return themaxla; + } return 0; } @@ -236,10 +285,14 @@ int IFSelect_Editor::NameNumber(const char* const name) const { int res; if (thenames.Find(name, res)) + { return res; + } res = atoi(name); // if it's an integer, we try it if (res < 1 || res > NbValues()) + { res = 0; + } return res; } @@ -253,7 +306,9 @@ occ::handle IFSelect_Editor::ListEditor(const int num) cons occ::handle led; int max = MaxList(num); if (max < 0) + { return led; + } led = new IFSelect_ListEditor(TypedValue(num), max); return led; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Functions.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Functions.cxx index c834cae7d1..9b769056a5 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Functions.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Functions.cxx @@ -82,18 +82,28 @@ static void SplitFileName(const char* const filename, nomlon = resfile.Length(); nomdeb = resfile.SearchFromEnd("/"); if (nomdeb <= 0) + { nomdeb = resfile.SearchFromEnd("\\"); // for NT + } if (nomdeb < 0) + { nomdeb = 0; + } nomfin = resfile.SearchFromEnd("."); if (nomfin < nomdeb) + { nomfin = nomlon + 1; + } if (nomdeb > 0) + { prefix = resfile.SubString(1, nomdeb); + } fileroot = resfile.SubString(nomdeb + 1, nomfin - 1); if (nomfin <= nomlon) + { suffix = resfile.SubString(nomfin, nomlon); + } } // Functions defines a certain number of commands @@ -107,10 +117,10 @@ static IFSelect_ReturnStatus funstatus(const occ::handle& // **** Version & cie **** // #58 rln Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "Processor Version : " << XSTEP_PROCESSOR_VERSION << std::endl; - sout << "OL Version : " << XSTEP_SYSTEM_VERSION << std::endl; - sout << "Configuration : " << XSTEP_Config << std::endl; - sout << "UL Names : " << XSTEP_ULNames << std::endl; + sout << "Processor Version : " << XSTEP_PROCESSOR_VERSION << '\n'; + sout << "OL Version : " << XSTEP_SYSTEM_VERSION << '\n'; + sout << "Configuration : " << XSTEP_Config << '\n'; + sout << "UL Names : " << XSTEP_ULNames << '\n'; return IFSelect_RetVoid; } @@ -121,9 +131,13 @@ static IFSelect_ReturnStatus fun1(const occ::handle& pilo bool hand = !WS->ErrorHandle(); Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (hand) - sout << " -- Mode Catch Error now Active" << std::endl; + { + sout << " -- Mode Catch Error now Active" << '\n'; + } else - sout << " -- Mode Catch Error now Inactive" << std::endl; + { + sout << " -- Mode Catch Error now Inactive" << '\n'; + } WS->SetErrorHandle(hand); return IFSelect_RetDone; } @@ -137,17 +151,17 @@ static IFSelect_ReturnStatus fun3(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Read/Load : give file name !" << std::endl; + sout << "Read/Load : give file name !" << '\n'; return IFSelect_RetError; } if (WS->Protocol().IsNull()) { - sout << "Protocol not defined" << std::endl; + sout << "Protocol not defined" << '\n'; return IFSelect_RetError; } if (WS->WorkLibrary().IsNull()) { - sout << "WorkLibrary not defined" << std::endl; + sout << "WorkLibrary not defined" << '\n'; return IFSelect_RetError; } @@ -157,26 +171,28 @@ static IFSelect_ReturnStatus fun3(const occ::handle& pilo switch (status) { case IFSelect_RetVoid: - sout << "file:" << arg1 << " gives empty result" << std::endl; + sout << "file:" << arg1 << " gives empty result" << '\n'; break; case IFSelect_RetError: - sout << "file:" << arg1 << " could not be opened" << std::endl; + sout << "file:" << arg1 << " could not be opened" << '\n'; break; case IFSelect_RetDone: - sout << "file:" << arg1 << " read" << std::endl; + sout << "file:" << arg1 << " read" << '\n'; break; case IFSelect_RetFail: - sout << "file:" << arg1 << " : error while reading" << std::endl; + sout << "file:" << arg1 << " : error while reading" << '\n'; break; case IFSelect_RetStop: - sout << "file:" << arg1 << " : EXCEPTION while reading" << std::endl; + sout << "file:" << arg1 << " : EXCEPTION while reading" << '\n'; break; default: - sout << "file:" << arg1 << " could not be read" << std::endl; + sout << "file:" << arg1 << " could not be read" << '\n'; break; } if (status != IFSelect_RetDone) + { return status; + } // sout<<" - clearing list of already written files"<BeginSentFiles(true); return status; @@ -191,7 +207,7 @@ static IFSelect_ReturnStatus fun4(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Write All : give file name !" << std::endl; + sout << "Write All : give file name !" << '\n'; return IFSelect_RetError; } return WS->SendAll(arg1); @@ -207,18 +223,20 @@ static IFSelect_ReturnStatus fun5(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Write Selected : give file name + givelist !" << std::endl; + sout << "Write Selected : give file name + givelist !" << '\n'; return IFSelect_RetError; } occ::handle>> result = IFSelect_Functions::GiveList(WS, pilot->CommandPart(2)); if (result.IsNull()) { - sout << "No entity selected" << std::endl; + sout << "No entity selected" << '\n'; return IFSelect_RetError; } else - sout << "Nb Entities selected : " << result->Length() << std::endl; + { + sout << "Nb Entities selected : " << result->Length() << '\n'; + } occ::handle sp = new IFSelect_SelectPointed; sp->SetList(result); return WS->SendSelected(arg1, sp); @@ -233,7 +251,7 @@ static IFSelect_ReturnStatus fun6(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Write Entitie(s) : give file name + n0s entitie(s)!" << std::endl; + sout << "Write Entitie(s) : give file name + n0s entitie(s)!" << '\n'; return IFSelect_RetError; } int ko = 0; @@ -245,22 +263,24 @@ static IFSelect_ReturnStatus fun6(const occ::handle& pilo { occ::handle item = WS->StartingEntity(id); if (sp->Add(item)) - sout << "Added:no." << id << std::endl; + { + sout << "Added:no." << id << '\n'; + } else { - sout << " Fail Add n0." << id << std::endl; + sout << " Fail Add n0." << id << '\n'; ko++; } } else { - sout << "Not an entity number:" << pilot->Arg(ia) << std::endl; + sout << "Not an entity number:" << pilot->Arg(ia) << '\n'; ko++; } } if (ko > 0) { - sout << ko << " bad arguments, abandon" << std::endl; + sout << ko << " bad arguments, abandon" << '\n'; return IFSelect_RetError; } return WS->SendSelected(arg1, sp); @@ -275,23 +295,23 @@ static IFSelect_ReturnStatus fun7(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give entity number" << std::endl; + sout << "Give entity number" << '\n'; return IFSelect_RetError; } if (!WS->HasModel()) { - sout << "No loaded model, abandon" << std::endl; + sout << "No loaded model, abandon" << '\n'; return IFSelect_RetError; } int nument = WS->NumberFromLabel(arg1); if (nument <= 0 || nument > WS->NbStartingEntities()) { - sout << "Not a suitable number: " << arg1 << std::endl; + sout << "Not a suitable number: " << arg1 << '\n'; return IFSelect_RetError; } sout << "N0." << nument << " ->Label in Model : "; WS->Model()->PrintLabel(WS->StartingEntity(nument), sout); - sout << std::endl; + sout << '\n'; return IFSelect_RetVoid; } @@ -304,33 +324,39 @@ static IFSelect_ReturnStatus fun8(const occ::handle& pilo Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give label to search" << std::endl; + sout << "Give label to search" << '\n'; return IFSelect_RetError; } if (!WS->HasModel()) { - sout << "No loaded model, abandon" << std::endl; + sout << "No loaded model, abandon" << '\n'; return IFSelect_RetError; } const occ::handle& model = WS->Model(); int i, cnt = 0; bool exact = false; - sout << " ** Search Entity Number for Label : " << arg1 << std::endl; + sout << " ** Search Entity Number for Label : " << arg1 << '\n'; for (i = model->NextNumberForLabel(arg1, 0, exact); i != 0; i = model->NextNumberForLabel(arg1, i, exact)) { cnt++; sout << " ** Found n0/id:"; model->Print(model->Value(i), sout); - sout << std::endl; + sout << '\n'; } if (cnt == 0) - sout << " ** No Match" << std::endl; + { + sout << " ** No Match" << '\n'; + } else if (cnt == 1) - sout << " ** 1 Match" << std::endl; + { + sout << " ** 1 Match" << '\n'; + } else - sout << cnt << " Matches" << std::endl; + { + sout << cnt << " Matches" << '\n'; + } return IFSelect_RetVoid; } @@ -340,7 +366,9 @@ static IFSelect_ReturnStatus fun9(const occ::handle& pilo occ::handle WS = pilot->Session(); occ::handle signtype = WS->SignType(); if (signtype.IsNull()) + { signtype = new IFSelect_SignType; + } occ::handle counter = new IFSelect_SignCounter(signtype, false); return pilot->ExecuteCounter(counter, 1); } @@ -357,11 +385,10 @@ static IFSelect_ReturnStatus funcount(const occ::handle& Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Designer signature ou compteur, + facultatif selection + facultatif entite" - << std::endl; - sout << " signature/compteur seul -> tout le modele" << std::endl - << " sign/compteur + selection -> cette selection, evaluation normale" << std::endl - << " sign/compteur + sel + num -> cette selection evaluee sur entite n0 num" << std::endl; + sout << "Designer signature ou compteur, + facultatif selection + facultatif entite" << '\n'; + sout << " signature/compteur seul -> tout le modele" << '\n' + << " sign/compteur + selection -> cette selection, evaluation normale" << '\n' + << " sign/compteur + sel + num -> cette selection evaluee sur entite n0 num" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_SignCounter, counter, WS->NamedItem(arg1)); @@ -369,7 +396,9 @@ static IFSelect_ReturnStatus funcount(const occ::handle& { DeclareAndCast(IFSelect_Signature, signa, WS->NamedItem(arg1)); if (!signa.IsNull()) + { counter = new IFSelect_SignCounter(signa, false, listmode); + } } // occ::handle sel; // int n3 = 0; if (argc > 3) n3 = WS->NumberFromLabel(arg3); @@ -406,7 +435,7 @@ static IFSelect_ReturnStatus funcount(const occ::handle& sel = WS->GiveSelection(pilot->Arg(i)); if (!suite->AddInput(sel)) { - sout << "Incorrect definition for applied selection" << std::endl; + sout << "Incorrect definition for applied selection" << '\n'; return IFSelect_RetError; } } @@ -420,17 +449,23 @@ static IFSelect_ReturnStatus funcount(const occ::handle& if (counter.IsNull()) { - sout << "Neither Counter nor Signature : " << arg1 << std::endl; + sout << "Neither Counter nor Signature : " << arg1 << '\n'; return IFSelect_RetError; } if (onflag == 0) + { onflag = 1; + } IFSelect_PrintCount pcm = IFSelect_ListByItem; if (arg0[0] == 'c') + { pcm = IFSelect_CountByItem; + } if (arg0[0] == 's') + { pcm = IFSelect_CountSummary; + } return pilot->ExecuteCounter(counter, onflag + 1, pcm); } @@ -443,41 +478,49 @@ static IFSelect_ReturnStatus funsigntype(const occ::handle signtype = WS->SignType(); Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (signtype.IsNull()) - sout << "signtype actually undefined" << std::endl; + { + sout << "signtype actually undefined" << '\n'; + } else { occ::handle str = WS->Name(signtype); int id = WS->ItemIdent(signtype); - sout << signtype->Label() << std::endl; + sout << signtype->Label() << '\n'; if (str.IsNull()) { if (id > 0) - sout << "signtype : item n0 " << id << std::endl; + { + sout << "signtype : item n0 " << id << '\n'; + } } else { - sout << "signtype : also named as " << str->ToCString() << std::endl; + sout << "signtype : also named as " << str->ToCString() << '\n'; } } if (argc < 2) - sout << "signtype newitem to change, signtype . to clear" << std::endl; + { + sout << "signtype newitem to change, signtype . to clear" << '\n'; + } else { if (arg1[0] == '.' && arg1[1] == '\0') { signtype.Nullify(); - sout << "signtype now cleared" << std::endl; + sout << "signtype now cleared" << '\n'; } else { signtype = GetCasted(IFSelect_Signature, WS->NamedItem(arg1)); if (signtype.IsNull()) { - sout << "Not a Signature : " << arg1 << std::endl; + sout << "Not a Signature : " << arg1 << '\n'; return IFSelect_RetError; } else - sout << "signtype now set to " << arg1 << std::endl; + { + sout << "signtype now set to " << arg1 << '\n'; + } } WS->SetSignType(signtype); return IFSelect_RetDone; @@ -493,7 +536,9 @@ static IFSelect_ReturnStatus funsigncase(const occ::handle signcase = GetCasted(IFSelect_Signature, WS->NamedItem(arg1)); Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (signcase.IsNull()) - sout << "Not a Signature : " << arg1 << std::endl; + { + sout << "Not a Signature : " << arg1 << '\n'; + } else { bool hasmin, hasmax; @@ -502,22 +547,29 @@ static IFSelect_ReturnStatus funsigncase(const occ::handle> caselist = signcase->CaseList(); if (caselist.IsNull()) - sout << "Signature " << arg1 << " : no predefined case, see command count " << arg1 - << std::endl; + { + sout << "Signature " << arg1 << " : no predefined case, see command count " << arg1 << '\n'; + } else { int i, nb = caselist->Length(); - sout << "Signature " << arg1 << " : " << nb << " basic cases :" << std::endl; + sout << "Signature " << arg1 << " : " << nb << " basic cases :" << '\n'; for (i = 1; i <= nb; i++) + { sout << " " << caselist->Value(i); - sout << std::endl; + } + sout << '\n'; } } return IFSelect_RetVoid; @@ -536,14 +588,16 @@ static IFSelect_ReturnStatus fun10(const occ::handle& pil nb = Interface_Category::NbCategories(); sout << " Categories defined :" << nb << " i.e. :\n"; for (i = 0; i <= nb; i++) + { sout << "Cat." << i << " : " << Interface_Category::Name(i) << "\n"; - sout << " On a given entity : give its number" << std::endl; + } + sout << " On a given entity : give its number" << '\n'; return IFSelect_RetVoid; } int num = pilot->Number(arg1); if (num <= 0 || num > WS->NbStartingEntities()) { - sout << "Not a suitable entity number : " << arg1 << std::endl; + sout << "Not a suitable entity number : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle ent = WS->StartingEntity(num); @@ -573,7 +627,7 @@ static IFSelect_ReturnStatus fun11(const occ::handle& pil << " check CheckList (complete) per message (counting)\n" << " totalcheck CheckList (complete) per message (listing n0 ents)\n" << " FAILS CheckList (fails) per message (listing complete)\n" - << " TOTALCHECK CheckList (complete) per message (listing complete)" << std::endl; + << " TOTALCHECK CheckList (complete) per message (listing complete)" << '\n'; return IFSelect_RetVoid; case 'g': niv = 0; @@ -606,7 +660,7 @@ static IFSelect_ReturnStatus fun11(const occ::handle& pil niv = 10; break; default: - sout << "Unknown Mode . data simply for help" << std::endl; + sout << "Unknown Mode . data simply for help" << '\n'; return IFSelect_RetError; } WS->TraceDumpModel(niv); @@ -625,15 +679,20 @@ static IFSelect_ReturnStatus fundumpent(const occ::handle { sout << "Give n0 or id of entity"; if (levmax < 0) - sout << " and dump level" << std::endl; + { + sout << " and dump level" << '\n'; + } else - sout << " + optional, dump level in [0 - " << levmax << "] , default = " << levdef - << std::endl; + { + sout << " + optional, dump level in [0 - " << levmax << "] , default = " << levdef << '\n'; + } for (level = 0; level <= levmax; level++) { const char* help = WL->DumpHelp(level); if (help[0] != '\0') - sout << level << " : " << help << std::endl; + { + sout << level << " : " << help << '\n'; + } } return IFSelect_RetError; } @@ -642,24 +701,30 @@ static IFSelect_ReturnStatus fundumpent(const occ::handle const char* const arg2 = pilot->Arg(2); int num = pilot->Number(arg1); if (num == 0) + { return IFSelect_RetError; + } level = levdef; if (argc > 2) + { level = atoi(arg2); + } occ::handle ent = WS->StartingEntity(num); if (ent.IsNull()) { sout << "No entity with given id " << arg1 << " (" << num << ") is found in the current model" - << std::endl; + << '\n'; } else { - sout << " -- DUMP Entity n0 " << num << " level " << level << std::endl; + sout << " -- DUMP Entity n0 " << num << " level " << level << '\n'; WL->DumpEntity(WS->Model(), WS->Protocol(), ent, sout, level); Interface_CheckIterator chl = WS->CheckOne(ent); if (!chl.IsEmpty(false)) + { chl.Print(sout, WS->Model(), false); + } } // sout << std::flush; @@ -675,20 +740,22 @@ static IFSelect_ReturnStatus funsign(const occ::handle& p Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << " Give signature name + n0 or id of entity" << std::endl; + sout << " Give signature name + n0 or id of entity" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); if (sign.IsNull()) { - sout << "Not a signature : " << arg1 << std::endl; + sout << "Not a signature : " << arg1 << '\n'; return IFSelect_RetError; } int num = pilot->Number(arg2); occ::handle ent = WS->StartingEntity(num); if (num == 0) + { return IFSelect_RetError; - sout << "Entity n0 " << num << " : " << WS->SignValue(sign, ent) << std::endl; + } + sout << "Entity n0 " << num << " : " << WS->SignValue(sign, ent) << '\n'; return IFSelect_RetVoid; } @@ -701,20 +768,25 @@ static IFSelect_ReturnStatus funqp(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << " Give 2 numeros or labels : dad son" << std::endl; + sout << " Give 2 numeros or labels : dad son" << '\n'; return IFSelect_RetError; } int n1 = WS->NumberFromLabel(arg1); int n2 = WS->NumberFromLabel(arg2); - sout << "QueryParent for dad:" << arg1 << ":" << n1 << " and son:" << arg2 << ":" << n2 - << std::endl; + sout << "QueryParent for dad:" << arg1 << ":" << n1 << " and son:" << arg2 << ":" << n2 << '\n'; int qp = WS->QueryParent(WS->StartingEntity(n1), WS->StartingEntity(n2)); if (qp < 0) - sout << arg1 << " is not super-entity of " << arg2 << std::endl; + { + sout << arg1 << " is not super-entity of " << arg2 << '\n'; + } else if (qp == 0) - sout << arg1 << " is same as " << arg2 << std::endl; + { + sout << arg1 << " is same as " << arg2 << '\n'; + } else - sout << arg1 << " is super-entity of " << arg2 << " , max level found=" << qp << std::endl; + { + sout << arg1 << " is super-entity of " << arg2 << " , max level found=" << qp << '\n'; + } // sout<<" Trouve "<& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 1) { - sout << "Give integer value for IntParam" << std::endl; + sout << "Give integer value for IntParam" << '\n'; return IFSelect_RetError; } occ::handle intpar = new IFSelect_IntParam; if (argc >= 1) + { intpar->SetValue(atoi(arg1)); + } return pilot->RecordItem(intpar); } @@ -763,13 +837,15 @@ static IFSelect_ReturnStatus fun15(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner 2 arguments : nom Parametre et Valeur" << std::endl; + sout << "Donner 2 arguments : nom Parametre et Valeur" << '\n'; return IFSelect_RetError; } int val = atoi(arg2); DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); if (!WS->SetIntValue(par, val)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -782,12 +858,14 @@ static IFSelect_ReturnStatus fun16(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 1) { - sout << "Give text value for TextParam" << std::endl; + sout << "Give text value for TextParam" << '\n'; return IFSelect_RetError; } occ::handle textpar = new TCollection_HAsciiString(); if (argc >= 1) + { textpar->AssignCat(arg1); + } return pilot->RecordItem(textpar); } @@ -801,12 +879,14 @@ static IFSelect_ReturnStatus fun17(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner 2 arguments : nom Parametre et Valeur" << std::endl; + sout << "Donner 2 arguments : nom Parametre et Valeur" << '\n'; return IFSelect_RetError; } DeclareAndCast(TCollection_HAsciiString, par, WS->NamedItem(arg1)); if (!WS->SetTextValue(par, arg2)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -819,7 +899,7 @@ static IFSelect_ReturnStatus fun19(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give 1 argument : Selection Name" << std::endl; + sout << "Give 1 argument : Selection Name" << '\n'; return IFSelect_RetError; } WS->DumpSelection(GetCasted(IFSelect_Selection, WS->NamedItem(arg1))); @@ -836,11 +916,13 @@ static IFSelect_ReturnStatus fun20(const occ::handle& pil // **** MakeList **** char mode = pilot->Arg(0)[0]; // givelist/makelist if (mode == 'g') + { mode = pilot->Arg(0)[4]; // l list s short p pointed + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << std::endl; + sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << '\n'; return IFSelect_RetError; } @@ -853,12 +935,12 @@ static IFSelect_ReturnStatus fun20(const occ::handle& pil pnt = GetCasted(IFSelect_SelectPointed, item); if (!pnt.IsNull()) { - sout << arg1 << ":Already existing Selection for List, cleared then filled" << std::endl; + sout << arg1 << ":Already existing Selection for List, cleared then filled" << '\n'; pnt->Clear(); } else if (!item.IsNull()) { - sout << arg1 << ":Already existing Item not for a List, command ignored" << std::endl; + sout << arg1 << ":Already existing Item not for a List, command ignored" << '\n'; return IFSelect_RetFail; } else @@ -871,26 +953,34 @@ static IFSelect_ReturnStatus fun20(const occ::handle& pil occ::handle>> result = IFSelect_Functions::GiveList(WS, pilot->CommandPart((mode == 'm' ? 2 : 1))); if (result.IsNull()) + { return IFSelect_RetError; + } Interface_EntityIterator iter(result); sout << pilot->CommandPart((mode == 'm' ? 2 : 1)) << " : "; if (mode == 'l') + { WS->ListEntities(iter, 0, sout); + } else if (mode == 's' || mode == 'm') + { WS->ListEntities(iter, 2, sout); + } else if (mode == 'p') { sout << iter.NbEntities() << " Entities : "; for (iter.Start(); iter.More(); iter.Next()) + { sout << " +" << WS->StartingNumber(iter.Value()); - sout << std::endl; + } + sout << '\n'; } if (!pnt.IsNull()) { pnt->SetList(result); - sout << "List set to a SelectPointed : " << pilot->Arg(1) << std::endl; - sout << "Later editable by command setlist" << std::endl; + sout << "List set to a SelectPointed : " << pilot->Arg(1) << '\n'; + sout << "Later editable by command setlist" << '\n'; } return IFSelect_RetVoid; @@ -904,15 +994,17 @@ static IFSelect_ReturnStatus fun20c(const occ::handle& pi Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << std::endl; + sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << '\n'; return IFSelect_RetError; } // WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); occ::handle>> result = IFSelect_Functions::GiveList(WS, pilot->CommandPart(1)); if (result.IsNull()) + { return IFSelect_RetError; - sout << pilot->CommandPart(1) << " : List of " << result->Length() << " Entities" << std::endl; + } + sout << pilot->CommandPart(1) << " : List of " << result->Length() << " Entities" << '\n'; return IFSelect_RetVoid; } @@ -924,7 +1016,7 @@ static IFSelect_ReturnStatus funselsuite(const occ::handleEvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); @@ -935,8 +1027,7 @@ static IFSelect_ReturnStatus funselsuite(const occ::handle sel = WS->GiveSelection(pilot->Arg(i)); if (!selsuite->AddInput(sel)) { - sout << pilot->Arg(i - 1) << " : not a SelectDeduct, no more can be added. Abandon" - << std::endl; + sout << pilot->Arg(i - 1) << " : not a SelectDeduct, no more can be added. Abandon" << '\n'; return IFSelect_RetError; } } @@ -964,25 +1055,39 @@ static IFSelect_ReturnStatus fun22(const occ::handle& pil if (argc >= 2) { if (arg1[0] == 'a') + { mode = 1; + } if (arg1[0] == 'g') + { mode = 2; + } if (arg1[0] == 'c') + { mode = 3; + } if (arg1[0] == 'p') + { mode = 4; + } if (arg1[0] == '?') + { mode = -1; + } } else + { mode = 0; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (mode <= 0) { if (mode < 0) + { sout << "Give a suitable mode"; + } sout << " Available Modes :\n" - << " a : all data g : graph+check c : check p : selectpointed" << std::endl; + << " a : all data g : graph+check c : check p : selectpointed" << '\n'; return (mode < 0 ? IFSelect_RetError : IFSelect_RetVoid); } WS->ClearData(mode); @@ -998,14 +1103,16 @@ static IFSelect_ReturnStatus fun24(const occ::handle& pil TCollection_AsciiString label; if (argc < 2) { - sout << " Give label to search" << std::endl; + sout << " Give label to search" << '\n'; return IFSelect_RetError; } for (int i = 1; i < argc; i++) { label.AssignCat(pilot->Arg(i)); if (i < argc - 1) + { label.AssignCat(" "); + } } for (int mode = 0; mode <= 2; mode++) { @@ -1013,18 +1120,24 @@ static IFSelect_ReturnStatus fun24(const occ::handle& pil int id; sout << "Searching label : " << label << ". in mode "; if (mode == 0) - sout << " exact" << std::endl; + { + sout << " exact" << '\n'; + } if (mode == 1) - sout << " same head" << std::endl; + { + sout << " same head" << '\n'; + } if (mode == 2) - sout << " search if present" << std::endl; + { + sout << " search if present" << '\n'; + } for (id = WS->NextIdentForLabel(label.ToCString(), 0, mode); id != 0; id = WS->NextIdentForLabel(label.ToCString(), id, mode)) { sout << " " << id; nbitems++; } - sout << " -- giving " << nbitems << " found" << std::endl; + sout << " -- giving " << nbitems << " found" << '\n'; } return IFSelect_RetVoid; } @@ -1038,12 +1151,14 @@ static IFSelect_ReturnStatus fun25(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner nom du Fichier" << std::endl; + sout << "Donner nom du Fichier" << '\n'; return IFSelect_RetError; } IFSelect_SessionFile dumper(WS, arg1); if (!dumper.IsDone()) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1056,17 +1171,23 @@ static IFSelect_ReturnStatus fun26(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner nom du Fichier" << std::endl; + sout << "Donner nom du Fichier" << '\n'; return IFSelect_RetError; } IFSelect_SessionFile dumper(WS); int readstat = dumper.Read(arg1); if (readstat == 0) + { return IFSelect_RetDone; + } else if (readstat > 0) - sout << "-- Erreur Lecture Fichier " << arg1 << std::endl; + { + sout << "-- Erreur Lecture Fichier " << arg1 << '\n'; + } else - sout << "-- Pas pu ouvrir Fichier " << arg1 << std::endl; + { + sout << "-- Pas pu ouvrir Fichier " << arg1 << '\n'; + } return IFSelect_RetDone; } @@ -1103,7 +1224,7 @@ static IFSelect_ReturnStatus fun27(const occ::handle& pil { aPatternNb = nb; } - sout << " List of parameters : " << aPatternNb << " items : " << std::endl; + sout << " List of parameters : " << aPatternNb << " items : " << '\n'; for (i = 1; i <= nb; i++) { if (argc == 3 && strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) != 0) @@ -1111,7 +1232,7 @@ static IFSelect_ReturnStatus fun27(const occ::handle& pil continue; } sout << li->Value(i)->String(); - sout << " : " << Interface_Static::CVal(li->Value(i)->ToCString()) << std::endl; + sout << " : " << Interface_Static::CVal(li->Value(i)->ToCString()) << '\n'; } return IFSelect_RetVoid; } @@ -1123,23 +1244,35 @@ static IFSelect_ReturnStatus fun27(const occ::handle& pil else { if (argc > 2) - sout << " FORMER STATUS of Static Parameter " << arg1 << std::endl; + { + sout << " FORMER STATUS of Static Parameter " << arg1 << '\n'; + } else - sout << " ACTUAL STATUS of Static Parameter " << arg1 << std::endl; + { + sout << " ACTUAL STATUS of Static Parameter " << arg1 << '\n'; + } if (!Interface_Static::IsPresent(arg1)) { - sout << " Parameter " << arg1 << " undefined" << std::endl; + sout << " Parameter " << arg1 << " undefined" << '\n'; return IFSelect_RetError; } if (!Interface_Static::IsSet(arg1)) - sout << " Parameter " << arg1 << " not valued" << std::endl; + { + sout << " Parameter " << arg1 << " not valued" << '\n'; + } else if (argc == 2) + { Interface_Static::Static(arg1)->Print(sout); + } else - sout << " Value : " << Interface_Static::CVal(arg1) << std::endl; + { + sout << " Value : " << Interface_Static::CVal(arg1) << '\n'; + } if (argc == 2) - sout << "To modify, param name_param new_val" << std::endl; + { + sout << "To modify, param name_param new_val" << '\n'; + } else { if (strlen(arg2) != 0) @@ -1152,12 +1285,12 @@ static IFSelect_ReturnStatus fun27(const occ::handle& pil } if (Interface_Static::SetCVal(arg1, arg2)) { - sout << " OK" << std::endl; + sout << " OK" << '\n'; return IFSelect_RetDone; } else { - sout << " , refused" << std::endl; + sout << " , refused" << '\n'; return IFSelect_RetError; } } @@ -1173,13 +1306,15 @@ static IFSelect_ReturnStatus fun29(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (list.IsNull()) { - sout << "List of Sent Files not enabled" << std::endl; + sout << "List of Sent Files not enabled" << '\n'; return IFSelect_RetVoid; } int i, nb = list->Length(); - sout << " Sent Files : " << nb << " : " << std::endl; + sout << " Sent Files : " << nb << " : " << '\n'; for (i = 1; i <= nb; i++) - sout << list->Value(i)->ToCString() << std::endl; + { + sout << list->Value(i)->ToCString() << '\n'; + } return IFSelect_RetVoid; } @@ -1193,10 +1328,14 @@ static IFSelect_ReturnStatus fun30(const occ::handle& pil if (argc < 2) { if (WS->FilePrefix().IsNull()) - sout << "No prefix defined" << std::endl; + { + sout << "No prefix defined" << '\n'; + } else - sout << "Prefixe : " << WS->FilePrefix()->ToCString() << std::endl; - sout << "Pour changer : filepref newprefix" << std::endl; + { + sout << "Prefixe : " << WS->FilePrefix()->ToCString() << '\n'; + } + sout << "Pour changer : filepref newprefix" << '\n'; return IFSelect_RetVoid; } WS->SetFilePrefix(arg1); @@ -1213,10 +1352,14 @@ static IFSelect_ReturnStatus fun31(const occ::handle& pil if (argc < 2) { if (WS->FileExtension().IsNull()) - sout << "Pas d extension definie" << std::endl; + { + sout << "Pas d extension definie" << '\n'; + } else - sout << "Extension : " << WS->FileExtension()->ToCString() << std::endl; - sout << "Pour changer : fileext newext" << std::endl; + { + sout << "Extension : " << WS->FileExtension()->ToCString() << '\n'; + } + sout << "Pour changer : fileext newext" << '\n'; return IFSelect_RetVoid; } WS->SetFileExtension(arg1); @@ -1233,21 +1376,27 @@ static IFSelect_ReturnStatus fun32(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Dispatch and Root name" << std::endl; + sout << "Give Dispatch and Root name" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); if (argc < 3) { if (WS->FileRoot(disp).IsNull()) - sout << "No root defined for " << arg1 << std::endl; + { + sout << "No root defined for " << arg1 << '\n'; + } else - sout << "Root for " << arg1 << " : " << WS->FileRoot(disp)->ToCString() << std::endl; - sout << "Pour changer : fileroot nomdisp newroot" << std::endl; + { + sout << "Root for " << arg1 << " : " << WS->FileRoot(disp)->ToCString() << '\n'; + } + sout << "Pour changer : fileroot nomdisp newroot" << '\n'; return IFSelect_RetVoid; } if (!WS->SetFileRoot(disp, arg2)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1261,10 +1410,14 @@ static IFSelect_ReturnStatus fun33(const occ::handle& pil if (argc < 2) { if (WS->DefaultFileRoot().IsNull()) - sout << "No default root defined" << std::endl; + { + sout << "No default root defined" << '\n'; + } else - sout << "Racine par defaut : " << WS->DefaultFileRoot()->ToCString() << std::endl; - sout << "Pour changer : filedef newdef" << std::endl; + { + sout << "Racine par defaut : " << WS->DefaultFileRoot()->ToCString() << '\n'; + } + sout << "Pour changer : filedef newdef" << '\n'; return IFSelect_RetVoid; } WS->SetDefaultFileRoot(arg1); @@ -1278,11 +1431,11 @@ static IFSelect_ReturnStatus fun34(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (!WS->HasModel()) { - sout << "No Model loaded, abort" << std::endl; + sout << "No Model loaded, abort" << '\n'; return IFSelect_RetFail; } - sout << "Evaluation avec Memorisation des resultats" << std::endl; + sout << "Evaluation avec Memorisation des resultats" << '\n'; WS->EvaluateFile(); int nbf = WS->NbFiles(); for (int i = 1; i <= nbf; i++) @@ -1290,12 +1443,12 @@ static IFSelect_ReturnStatus fun34(const occ::handle& pil occ::handle mod = WS->FileModel(i); if (mod.IsNull()) { - sout << "Modele " << i << " Model non genere ..." << std::endl; + sout << "Modele " << i << " Model non genere ..." << '\n'; continue; } TCollection_AsciiString name = WS->FileName(i); sout << "Fichier n0 " << i << " Nb Entites : " << mod->NbEntities() << " Nom: "; - sout << name << std::endl; + sout << name << '\n'; } return IFSelect_RetDone; } @@ -1316,7 +1469,9 @@ static IFSelect_ReturnStatus fun36(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); IFSelect_ReturnStatus stat = IFSelect_RetVoid; if (argc < 2) - sout << "Split : last dispatch list defined" << std::endl; + { + sout << "Split : last dispatch list defined" << '\n'; + } else { WS->ClearShareOut(true); @@ -1325,18 +1480,24 @@ static IFSelect_ReturnStatus fun36(const occ::handle& pil DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(pilot->Arg(i))); if (disp.IsNull()) { - sout << "Pas un dispatch:" << pilot->Arg(i) << ", Splitt abandonne" << std::endl; + sout << "Pas un dispatch:" << pilot->Arg(i) << ", Splitt abandonne" << '\n'; stat = IFSelect_RetError; } else + { WS->SetActive(disp, true); + } } } if (stat == IFSelect_RetError) + { return stat; + } WS->BeginSentFiles(true); if (!WS->SendSplit()) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1349,28 +1510,46 @@ static IFSelect_ReturnStatus fun37(const occ::handle& pil char mode = '?'; IFSelect_RemainMode numod = IFSelect_RemainDisplay; if (argc >= 2) + { mode = arg1[0]; + } if (mode == 'u') + { numod = IFSelect_RemainUndo; + } else if (mode == 'l') + { numod = IFSelect_RemainDisplay; + } else if (mode == 'c') + { numod = IFSelect_RemainCompute; + } else if (mode == 'f') + { numod = IFSelect_RemainForget; + } else { Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) + { sout << "Donner un Mode - "; - sout << "Modes possibles : l list, c compute, u undo, f forget" << std::endl; + } + sout << "Modes possibles : l list, c compute, u undo, f forget" << '\n'; if (mode == '?') + { return IFSelect_RetDone; + } else + { return IFSelect_RetError; + } } if (!WS->SetRemaining(numod)) + { return IFSelect_RetVoid; + } return IFSelect_RetDone; } @@ -1384,14 +1563,14 @@ static IFSelect_ReturnStatus fun38(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner nom selection et mode (k=keep,r=remove)" << std::endl; + sout << "Donner nom selection et mode (k=keep,r=remove)" << '\n'; return IFSelect_RetError; } bool keepmode; DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); if (sel.IsNull()) { - sout << "No Selection with Name : " << arg1 << std::endl; + sout << "No Selection with Name : " << arg1 << '\n'; return IFSelect_RetError; } if (arg2[0] == 'k') @@ -1406,14 +1585,18 @@ static IFSelect_ReturnStatus fun38(const occ::handle& pil } else { - sout << "Donner nom selection et mode (k=keep,r=remove)" << std::endl; + sout << "Donner nom selection et mode (k=keep,r=remove)" << '\n'; return IFSelect_RetError; } if (WS->SetModelContent(sel, keepmode)) - sout << " Done" << std::endl; + { + sout << " Done" << '\n'; + } else - sout << " Result empty, ignored" << std::endl; + { + sout << " Result empty, ignored" << '\n'; + } return IFSelect_RetDone; } @@ -1435,40 +1618,52 @@ static IFSelect_ReturnStatus fun41(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner Nom du Modifier" << std::endl; + sout << "Donner Nom du Modifier" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); if (modif.IsNull()) { - sout << "No Modifier with Name : " << arg1 << std::endl; + sout << "No Modifier with Name : " << arg1 << '\n'; return IFSelect_RetVoid; } occ::handle low, up; occ::handle disp = modif->Dispatch(); - sout << "Modifier : " << arg1 << " Label : " << modif->Label() << std::endl; + sout << "Modifier : " << arg1 << " Label : " << modif->Label() << '\n'; int rank = WS->ModifierRank(modif); if (modif->IsKind(STANDARD_TYPE(IFSelect_Modifier))) + { sout << "Model Modifier n0." << rank; + } else + { sout << "File Modifier n0." << rank; + } if (disp.IsNull()) - sout << " Applique a tous les Dispatchs" << std::endl; + { + sout << " Applique a tous les Dispatchs" << '\n'; + } else { sout << " Dispatch : " << disp->Label(); if (WS->HasName(disp)) + { sout << " - Nom:" << WS->Name(disp)->ToCString(); - sout << std::endl; + } + sout << '\n'; } occ::handle sel = modif->Selection(); if (!sel.IsNull()) + { sout << " Selection : " << sel->Label(); + } if (WS->HasName(sel)) + { sout << " - Nom:" << WS->Name(sel)->ToCString(); - sout << std::endl; + } + sout << '\n'; return IFSelect_RetVoid; } @@ -1483,13 +1678,13 @@ static IFSelect_ReturnStatus fun42(const occ::handle& pil if (argc < 2) { sout << "Donner Nom Modifier; + Nom Selection optionnel\n" - << "Selection to Set a Selection, otherwise Cancel" << std::endl; + << "Selection to Set a Selection, otherwise Cancel" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); if (modif.IsNull()) { - sout << "Not a Modifier name : " << arg1 << std::endl; + sout << "Not a Modifier name : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle sel; @@ -1498,12 +1693,14 @@ static IFSelect_ReturnStatus fun42(const occ::handle& pil sel = GetCasted(IFSelect_Selection, WS->NamedItem(arg2)); if (sel.IsNull()) { - sout << "Not a Selection name : " << arg2 << std::endl; + sout << "Not a Selection name : " << arg2 << '\n'; return IFSelect_RetError; } } if (!WS->SetItemSelection(modif, sel)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1519,13 +1716,13 @@ static IFSelect_ReturnStatus fun43(const occ::handle& pil { sout << "Donner Nom Modifier; + Nom Dispatch ou Transformer optionnel :\n" << " - rien : tous Dispatches\n - Dispatch : ce Dispatch seul\n" - << " - Transformer : pas un Dispatch mais un Transformer" << std::endl; + << " - Transformer : pas un Dispatch mais un Transformer" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); if (modif.IsNull()) { - sout << "Not a Modifier name : " << arg1 << std::endl; + sout << "Not a Modifier name : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle item; @@ -1534,14 +1731,18 @@ static IFSelect_ReturnStatus fun43(const occ::handle& pil item = WS->NamedItem(arg2); if (item.IsNull()) { - sout << "Pas un nom connu : " << arg2 << std::endl; + sout << "Pas un nom connu : " << arg2 << '\n'; return IFSelect_RetError; } } else + { item = WS->ShareOut(); + } if (!WS->SetAppliedModifier(modif, item)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1554,17 +1755,19 @@ static IFSelect_ReturnStatus fun44(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Designer un modifier" << std::endl; + sout << "Designer un modifier" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); if (modif.IsNull()) { - sout << "Not a Modifier name : " << arg1 << std::endl; + sout << "Not a Modifier name : " << arg1 << '\n'; return IFSelect_RetError; } if (!WS->ResetAppliedModifier(modif)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1579,28 +1782,34 @@ static IFSelect_ReturnStatus fun45(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 4) { - sout << "modifmove MF rang1 rang2, M for Model F for File" << std::endl; + sout << "modifmove MF rang1 rang2, M for Model F for File" << '\n'; return IFSelect_RetError; } bool formodel; if (arg1[0] == 'm' || arg1[0] == 'M') + { formodel = true; + } else if (arg1[0] == 'f' || arg1[0] == 'F') + { formodel = false; + } else { - sout << "specify M for Model, F for File" << std::endl; + sout << "specify M for Model, F for File" << '\n'; return IFSelect_RetError; } int before = atoi(arg2); int after = atoi(arg3); if (before == 0 || after == 0) { - sout << "Donner 2 Entiers Positifs" << std::endl; + sout << "Donner 2 Entiers Positifs" << '\n'; return IFSelect_RetError; } if (!WS->ChangeModifierRank(formodel, before, after)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1614,23 +1823,25 @@ static IFSelect_ReturnStatus fun51(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner Noms Dispatch et Selection Finale" << std::endl; + sout << "Donner Noms Dispatch et Selection Finale" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); if (disp.IsNull()) { - sout << "Not a Dispatch name : " << arg1 << std::endl; + sout << "Not a Dispatch name : " << arg1 << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg2)); if (sel.IsNull()) { - sout << "Not a Selection name : " << arg2 << std::endl; + sout << "Not a Selection name : " << arg2 << '\n'; return IFSelect_RetError; } if (!WS->SetItemSelection(disp, sel)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1659,13 +1870,13 @@ static IFSelect_ReturnStatus fun_dispcount(const occ::handleNamedItem(arg1)); if (par.IsNull()) { - sout << "Not an IntParam name : " << arg1 << std::endl; + sout << "Not an IntParam name : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle disp = new IFSelect_DispPerCount; @@ -1682,13 +1893,13 @@ static IFSelect_ReturnStatus fun_dispfiles(const occ::handleNamedItem(arg1)); if (par.IsNull()) { - sout << "Not an IntParam name : " << arg1 << std::endl; + sout << "Not an IntParam name : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle disp = new IFSelect_DispPerFiles; @@ -1705,13 +1916,13 @@ static IFSelect_ReturnStatus fun_dispsign(const occ::handleNamedItem(arg1)); if (sig.IsNull()) { - sout << "Not a Signature name : " << arg1 << std::endl; + sout << "Not a Signature name : " << arg1 << '\n'; return IFSelect_RetError; } occ::handle disp = new IFSelect_DispPerSignature; @@ -1728,13 +1939,13 @@ static IFSelect_ReturnStatus fun56(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner Nom du Dispatch" << std::endl; + sout << "Donner Nom du Dispatch" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); if (disp.IsNull()) { - sout << "Pas un dispatch : " << arg1 << std::endl; + sout << "Pas un dispatch : " << arg1 << '\n'; return IFSelect_RetError; } int num = WS->DispatchRank(disp); @@ -1742,13 +1953,21 @@ static IFSelect_ReturnStatus fun56(const occ::handle& pil occ::handle sel = WS->ItemSelection(disp); occ::handle selname = WS->Name(sel); if (sel.IsNull()) - sout << "No Final Selection" << std::endl; + { + sout << "No Final Selection" << '\n'; + } else if (selname.IsNull()) - sout << "Selection Finale : #" << WS->ItemIdent(sel) << std::endl; + { + sout << "Selection Finale : #" << WS->ItemIdent(sel) << '\n'; + } else - sout << "Selection Finale : " << selname->ToCString() << std::endl; + { + sout << "Selection Finale : " << selname->ToCString() << '\n'; + } if (disp->HasRootName()) - sout << "-- Root file name : " << disp->RootName()->ToCString() << std::endl; + { + sout << "-- Root file name : " << disp->RootName()->ToCString() << '\n'; + } return IFSelect_RetVoid; } @@ -1761,11 +1980,13 @@ static IFSelect_ReturnStatus fun57(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Name to Remove !" << std::endl; + sout << "Give Name to Remove !" << '\n'; return IFSelect_RetError; } if (!WS->RemoveNamedItem(arg1)) + { return IFSelect_RetFail; + } return IFSelect_RetDone; } @@ -1779,8 +2000,8 @@ static IFSelect_ReturnStatus fun58(const occ::handle& pil if (argc < 3) { sout << "evaldisp mode disp [disp ...] : Mode + Name(s) of Dispatch(es). Mode:\n" - << " 0 brief 1 +forgotten ents 2 +duplicata 3 1+2" << std::endl - << "See also : evaladisp writedisp xsplit" << std::endl; + << " 0 brief 1 +forgotten ents 2 +duplicata 3 1+2" << '\n' + << "See also : evaladisp writedisp xsplit" << '\n'; return IFSelect_RetVoid; } bool OK = true; @@ -1791,13 +2012,13 @@ static IFSelect_ReturnStatus fun58(const occ::handle& pil DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(pilot->Arg(i))); if (disp.IsNull()) { - sout << "Not a dispatch:" << pilot->Arg(i) << std::endl; + sout << "Not a dispatch:" << pilot->Arg(i) << '\n'; OK = false; } } if (!OK) { - sout << "Some of the parameters are not correct" << std::endl; + sout << "Some of the parameters are not correct" << '\n'; return IFSelect_RetError; } @@ -1823,13 +2044,13 @@ static IFSelect_ReturnStatus fun_evaladisp(const occ::handle disp = IFSelect_Functions::GiveDispatch(WS, pilot->Arg(2), true); if (disp.IsNull()) { - sout << "Not a dispatch:" << pilot->Arg(2) << std::endl; + sout << "Not a dispatch:" << pilot->Arg(2) << '\n'; return IFSelect_RetError; } occ::handle selsav = disp->FinalSelection(); @@ -1858,13 +2079,15 @@ static IFSelect_ReturnStatus fun_evaladisp(const occ::handle 3) - sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << std::endl; + { + sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << '\n'; + } sel = selsav; } disp->SetFinalSelection(sel); @@ -1889,14 +2112,14 @@ static IFSelect_ReturnStatus fun_writedisp(const occ::handle disp = IFSelect_Functions::GiveDispatch(WS, pilot->Arg(2), true); if (disp.IsNull()) { - sout << "Not a dispatch:" << pilot->Arg(2) << std::endl; + sout << "Not a dispatch:" << pilot->Arg(2) << '\n'; return IFSelect_RetError; } occ::handle selsav = disp->FinalSelection(); @@ -1924,13 +2147,15 @@ static IFSelect_ReturnStatus fun_writedisp(const occ::handle 3) - sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << std::endl; + { + sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << '\n'; + } sel = selsav; } @@ -1957,11 +2182,13 @@ static IFSelect_ReturnStatus fun59(const occ::handle& pil int mode = 0; Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) + { sout << " -- mode par defaut 0\n"; + } else { mode = atoi(arg1); - sout << " -- mode : " << mode << std::endl; + sout << " -- mode : " << mode << '\n'; } WS->EvaluateComplete(mode); return IFSelect_RetVoid; @@ -1988,7 +2215,7 @@ static IFSelect_ReturnStatus fun61(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Transformer Name" << std::endl; + sout << "Give Transformer Name" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Transformer, tsf, WS->NamedItem(arg1)); @@ -1996,37 +2223,41 @@ static IFSelect_ReturnStatus fun61(const occ::handle& pil switch (effect) { case -4: - sout << "Edition sur place, nouveau Protocole, erreur recalcul graphe" << std::endl; + sout << "Edition sur place, nouveau Protocole, erreur recalcul graphe" << '\n'; break; case -3: - sout << "Erreur, Transformation ignoree" << std::endl; + sout << "Erreur, Transformation ignoree" << '\n'; break; case -2: - sout << "Error on in-place editing, risk of corruption (check)" << std::endl; + sout << "Error on in-place editing, risk of corruption (check)" << '\n'; break; case -1: - sout << "Error on local editing, risk of corruption (check)" << std::endl; + sout << "Error on local editing, risk of corruption (check)" << '\n'; break; case 0: if (tsf.IsNull()) - sout << "Erreur, pas un Transformer: " << arg1 << std::endl; + { + sout << "Erreur, pas un Transformer: " << arg1 << '\n'; + } else - sout << "Execution non faite" << std::endl; + { + sout << "Execution non faite" << '\n'; + } break; case 1: - sout << "Transformation locale (graphe non touche)" << std::endl; + sout << "Transformation locale (graphe non touche)" << '\n'; break; case 2: - sout << "Edition sur place (graphe recalcule)" << std::endl; + sout << "Edition sur place (graphe recalcule)" << '\n'; break; case 3: - sout << "Modele reconstruit" << std::endl; + sout << "Modele reconstruit" << '\n'; break; case 4: - sout << "Edition sur place, nouveau Protocole" << std::endl; + sout << "Edition sur place, nouveau Protocole" << '\n'; break; case 5: - sout << "Nouveau Modele avec nouveau Protocole" << std::endl; + sout << "Nouveau Modele avec nouveau Protocole" << '\n'; break; default: break; @@ -2059,7 +2290,9 @@ static IFSelect_ReturnStatus fun6465(const occ::handle& p // either it's a name, otherwise it's a command occ::handle modif; if (WS->NameIdent(arg1) > 0) + { modif = GetCasted(IFSelect_Modifier, WS->NamedItem(arg1)); + } else { pilot->RemoveWord(0); // it was the run command @@ -2069,7 +2302,7 @@ static IFSelect_ReturnStatus fun6465(const occ::handle& p Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (modif.IsNull()) { - sout << "Not a Modifier name : " << arg1 << std::endl; + sout << "Not a Modifier name : " << arg1 << '\n'; return IFSelect_RetError; } @@ -2088,37 +2321,41 @@ static IFSelect_ReturnStatus fun6465(const occ::handle& p switch (effect) { case -4: - sout << "Edition sur place, nouveau Protocole, erreur recalcul graphe" << std::endl; + sout << "Edition sur place, nouveau Protocole, erreur recalcul graphe" << '\n'; break; case -3: - sout << "Erreur, Transformation ignoree" << std::endl; + sout << "Erreur, Transformation ignoree" << '\n'; break; case -2: - sout << "Error on in-place editing, risk of corruption (check)" << std::endl; + sout << "Error on in-place editing, risk of corruption (check)" << '\n'; break; case -1: - sout << "Error on local editing, risk of corruption (check)" << std::endl; + sout << "Error on local editing, risk of corruption (check)" << '\n'; break; case 0: if (modif.IsNull()) - sout << "Erreur, pas un Modifier: " << arg1 << std::endl; + { + sout << "Erreur, pas un Modifier: " << arg1 << '\n'; + } else - sout << "Execution non faite" << std::endl; + { + sout << "Execution non faite" << '\n'; + } break; case 1: - sout << "Transformation locale (graphe non touche)" << std::endl; + sout << "Transformation locale (graphe non touche)" << '\n'; break; case 2: - sout << "Edition sur place (graphe recalcule)" << std::endl; + sout << "Edition sur place (graphe recalcule)" << '\n'; break; case 3: - sout << "Modele reconstruit" << std::endl; + sout << "Modele reconstruit" << '\n'; break; case 4: - sout << "Edition sur place, nouveau Protocole" << std::endl; + sout << "Edition sur place, nouveau Protocole" << '\n'; break; case 5: - sout << "Nouveau Modele avec nouveau Protocole" << std::endl; + sout << "Nouveau Modele avec nouveau Protocole" << '\n'; break; default: break; @@ -2132,11 +2369,13 @@ static IFSelect_ReturnStatus fun66(const occ::handle& pil char opt = ' '; int argc = pilot->NbWords(); if (argc >= 2) + { opt = pilot->Word(1).Value(1); + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (opt != 'f' && opt != 'l') { - sout << "Donner option : f -> root-first l -> root-last" << std::endl; + sout << "Donner option : f -> root-first l -> root-last" << '\n'; return IFSelect_RetError; } return pilot->RecordItem(new IFSelect_ModifReorder(opt == 'l')); @@ -2151,19 +2390,23 @@ static IFSelect_ReturnStatus fun70(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give Selection Name" << std::endl; + sout << "Give Selection Name" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); if (!WS->ToggleSelectExtract(sel)) { - sout << "Pas une SelectExtract : " << arg1 << std::endl; + sout << "Pas une SelectExtract : " << arg1 << '\n'; return IFSelect_RetFail; } if (WS->IsReversedSelectExtract(sel)) - sout << arg1 << " a present Reversed" << std::endl; + { + sout << arg1 << " a present Reversed" << '\n'; + } else - sout << arg1 << " a present Directe" << std::endl; + { + sout << arg1 << " a present Directe" << '\n'; + } return IFSelect_RetDone; } @@ -2177,19 +2420,19 @@ static IFSelect_ReturnStatus fun71(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner Noms Selections cible et input" << std::endl; + sout << "Donner Noms Selections cible et input" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, sou, WS->NamedItem(arg2)); if (sel.IsNull() || sou.IsNull()) { - sout << "Incorrect : " << arg1 << "," << arg2 << std::endl; + sout << "Incorrect : " << arg1 << "," << arg2 << '\n'; return IFSelect_RetError; } if (!WS->SetInputSelection(sel, sou)) { - sout << "Nom incorrect ou Selection " << arg1 << " ni Extract ni Deduct" << std::endl; + sout << "Nom incorrect ou Selection " << arg1 << " ni Extract ni Deduct" << '\n'; return IFSelect_RetFail; } return IFSelect_RetDone; @@ -2211,13 +2454,15 @@ static IFSelect_ReturnStatus fun73(const occ::handle& pil // **** SelRange **** Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc >= 2 && arg1[0] == '?') + { argc = 1; + } if (argc < 2) { sout << "Donner la description du SelectRange" << " Accepted forms :\n : Range from to \n" << " tout seul : Range n0 \n from : Range From \n" - << " until : Range Until " << std::endl; + << " until : Range Until " << '\n'; return IFSelect_RetVoid; } @@ -2228,7 +2473,7 @@ static IFSelect_ReturnStatus fun73(const occ::handle& pil { if (argc < 3) { - sout << "Forme admise : from " << std::endl; + sout << "Forme admise : from " << '\n'; return IFSelect_RetError; } low = GetCasted(IFSelect_IntParam, WS->NamedItem(arg2)); @@ -2240,7 +2485,7 @@ static IFSelect_ReturnStatus fun73(const occ::handle& pil { if (argc < 3) { - sout << "Forme admise : until " << std::endl; + sout << "Forme admise : until " << '\n'; return IFSelect_RetError; } up = GetCasted(IFSelect_IntParam, WS->NamedItem(arg2)); @@ -2288,18 +2533,30 @@ static IFSelect_ReturnStatus fun76(const occ::handle& pil // **** SelDiff **** occ::handle sel = new IFSelect_SelectDiff; if (sel.IsNull()) + { return IFSelect_RetFail; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) - sout << "Diff without input : don't forget to define them (ctlmain, ctlsec)!" << std::endl; + { + sout << "Diff without input : don't forget to define them (ctlmain, ctlsec)!" << '\n'; + } DeclareAndCast(IFSelect_Selection, selmain, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, selsec, WS->NamedItem(arg2)); if (argc >= 2) + { if (!WS->SetControl(sel, selmain, true)) - sout << "Echec ControlMain:" << arg1 << " , a refaire (ctlmain)" << std::endl; + { + sout << "Echec ControlMain:" << arg1 << " , a refaire (ctlmain)" << '\n'; + } + } if (argc >= 3) + { if (!WS->SetControl(sel, selsec, false)) - sout << "Echec ControlSecond:" << arg2 << " , a refaire (ctlsec)" << std::endl; + { + sout << "Echec ControlSecond:" << arg2 << " , a refaire (ctlsec)" << '\n'; + } + } return pilot->RecordItem(sel); } @@ -2313,14 +2570,16 @@ static IFSelect_ReturnStatus fun77(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Give Control and MainInput Names" << std::endl; + sout << "Give Control and MainInput Names" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, selmain, WS->NamedItem(arg2)); if (WS->SetControl(sel, selmain, true)) + { return IFSelect_RetDone; - sout << "Incorrect name or Selection " << arg1 << " not of Control type" << std::endl; + } + sout << "Incorrect name or Selection " << arg1 << " not of Control type" << '\n'; return IFSelect_RetFail; } @@ -2334,14 +2593,16 @@ static IFSelect_ReturnStatus fun78(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Give Control and SecondInput Names" << std::endl; + sout << "Give Control and SecondInput Names" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, seldif, WS->NamedItem(arg2)); if (WS->SetControl(sel, seldif, false)) + { return IFSelect_RetDone; - sout << "Incorrect name or Selection " << arg1 << " not of Control type" << std::endl; + } + sout << "Incorrect name or Selection " << arg1 << " not of Control type" << '\n'; return IFSelect_RetFail; } @@ -2362,14 +2623,16 @@ static IFSelect_ReturnStatus fun80(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner n0 Combine et une Input" << std::endl; + sout << "Donner n0 Combine et une Input" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, seladd, WS->NamedItem(arg2)); if (WS->CombineAdd(sel, seladd)) + { return IFSelect_RetDone; - sout << "Nom incorrect ou Selection " << arg1 << " pas Combine" << std::endl; + } + sout << "Nom incorrect ou Selection " << arg1 << " pas Combine" << '\n'; return IFSelect_RetFail; } @@ -2383,14 +2646,16 @@ static IFSelect_ReturnStatus fun81(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Donner n0 Combine et RANG a supprimer" << std::endl; + sout << "Donner n0 Combine et RANG a supprimer" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); DeclareAndCast(IFSelect_Selection, inp, WS->NamedItem(arg2)); if (WS->CombineRemove(sel, inp)) + { return IFSelect_RetDone; - sout << "Nom incorrect ou Selection " << arg1 << " ni Union ni Intersection" << std::endl; + } + sout << "Nom incorrect ou Selection " << arg1 << " ni Union ni Intersection" << '\n'; return IFSelect_RetFail; } @@ -2403,7 +2668,7 @@ static IFSelect_ReturnStatus fun82(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Give IntParam Name for Entity n0" << std::endl; + sout << "Give IntParam Name for Entity n0" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); @@ -2434,7 +2699,7 @@ static IFSelect_ReturnStatus fun85(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner le TYPE a selectionner" << std::endl; + sout << "Donner le TYPE a selectionner" << '\n'; return IFSelect_RetError; } return pilot->RecordItem(new IFSelect_SelectSignature(new IFSelect_SignType, arg1, true)); @@ -2466,7 +2731,7 @@ static IFSelect_ReturnStatus fun89(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner le TYPE a selectionner" << std::endl; + sout << "Donner le TYPE a selectionner" << '\n'; return IFSelect_RetError; } return pilot->RecordItem(new IFSelect_SelectSignature(new IFSelect_SignType, arg1, false)); @@ -2481,9 +2746,11 @@ static IFSelect_ReturnStatus fun90(const occ::handle& pil occ::handle>> list = IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(1)); if (list.IsNull()) + { return IFSelect_RetFail; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "SelectPointed : " << list->Length() << " entities" << std::endl; + sout << "SelectPointed : " << list->Length() << " entities" << '\n'; sp->AddList(list); } return pilot->RecordItem(sp); @@ -2500,26 +2767,28 @@ static IFSelect_ReturnStatus fun91(const occ::handle& pil { sout << "Donner NOM SelectPointed + Option(s) :\n" << " aucune : liste des entites pointees\n" - << " 0: Clear +nn ajout entite nn -nn enleve nn /nn toggle nn" << std::endl; + << " 0: Clear +nn ajout entite nn -nn enleve nn /nn toggle nn" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_SelectPointed, sp, WS->NamedItem(arg1)); if (sp.IsNull()) { - sout << "Pas une SelectPointed:" << arg1 << std::endl; + sout << "Pas une SelectPointed:" << arg1 << '\n'; return IFSelect_RetError; } const occ::handle& model = WS->Model(); // for Print if (argc == 2) { // listage simple int nb = sp->NbItems(); - sout << " SelectPointed : " << arg1 << " : " << nb << " Items :" << std::endl; + sout << " SelectPointed : " << arg1 << " : " << nb << " Items :" << '\n'; for (int i = 1; i <= nb; i++) { occ::handle pointed = sp->Item(i); int id = WS->StartingNumber(pointed); if (id == 0) + { sout << " (inconnu)"; + } else { sout << " "; @@ -2527,7 +2796,9 @@ static IFSelect_ReturnStatus fun91(const occ::handle& pil } } if (nb > 0) - sout << std::endl; + { + sout << '\n'; + } return IFSelect_RetDone; } @@ -2538,10 +2809,12 @@ static IFSelect_ReturnStatus fun91(const occ::handle& pil if (id == 0) { if (!argi.IsEqual("0")) - sout << "Incorrect,ignore:" << argi << std::endl; + { + sout << "Incorrect,ignore:" << argi << '\n'; + } else { - sout << "Clear SelectPointed" << std::endl; + sout << "Clear SelectPointed" << '\n'; sp->Clear(); } } @@ -2549,35 +2822,47 @@ static IFSelect_ReturnStatus fun91(const occ::handle& pil { occ::handle item = WS->StartingEntity(id); if (sp->Remove(item)) + { sout << "Removed:no." << id; + } else + { sout << " Echec Remove " << id; - sout << ": " << std::endl; + } + sout << ": " << '\n'; model->Print(item, sout); } else if (argi.Value(1) == '/') { occ::handle item = WS->StartingEntity(id); if (sp->Remove(item)) + { sout << "Toggled:n0." << id; + } else + { sout << " Echec Toggle " << id; - sout << ": " << std::endl; + } + sout << ": " << '\n'; model->Print(item, sout); } else if (argi.Value(1) == '+') { occ::handle item = WS->StartingEntity(id); if (sp->Add(item)) + { sout << "Added:no." << id; + } else + { sout << " Echec Add " << id; - sout << ": " << std::endl; + } + sout << ": " << '\n'; model->Print(item, sout); } else { - sout << "Ignore:" << argi << " , give n0 PRECEDED by + or - or /" << std::endl; + sout << "Ignore:" << argi << " , give n0 PRECEDED by + or - or /" << '\n'; } } return IFSelect_RetDone; @@ -2601,14 +2886,16 @@ static IFSelect_ReturnStatus fun93(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 3) { - sout << "Give name of Signature or Counter, text + option exact(D) else contains" << std::endl; + sout << "Give name of Signature or Counter, text + option exact(D) else contains" << '\n'; return IFSelect_RetError; } bool exact = true; if (argc > 3) { if (pilot->Arg(3)[0] == 'c') + { exact = false; + } } DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); @@ -2616,12 +2903,16 @@ static IFSelect_ReturnStatus fun93(const occ::handle& pil occ::handle sel; if (!sign.IsNull()) + { sel = new IFSelect_SelectSignature(sign, arg2, exact); + } else if (!cnt.IsNull()) + { sel = new IFSelect_SelectSignature(cnt, arg2, exact); + } else { - sout << arg1 << ":neither Signature nor Counter" << std::endl; + sout << arg1 << ":neither Signature nor Counter" << '\n'; return IFSelect_RetError; } @@ -2637,13 +2928,13 @@ static IFSelect_ReturnStatus fun94(const occ::handle& pil Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc < 2) { - sout << "Donner nom signature" << std::endl; + sout << "Donner nom signature" << '\n'; return IFSelect_RetError; } DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); if (sign.IsNull()) { - sout << arg1 << ":pas une signature" << std::endl; + sout << arg1 << ":pas une signature" << '\n'; return IFSelect_RetError; } occ::handle cnt = new IFSelect_SignCounter(sign, true, true); @@ -2659,13 +2950,13 @@ static IFSelect_ReturnStatus funbselected(const occ::handleGiveSelection(arg1)); if (applied.IsNull()) { - sout << arg1 << ":pas une SelectDeduct" << std::endl; + sout << arg1 << ":pas une SelectDeduct" << '\n'; return IFSelect_RetError; } occ::handle cnt = new IFSelect_GraphCounter(true, true); @@ -2683,7 +2974,7 @@ static IFSelect_ReturnStatus fun_editlist(const occ::handleArg(1); @@ -2696,7 +2987,7 @@ static IFSelect_ReturnStatus fun_editlist(const occ::handle edt; if (!edf.IsNull()) { - sout << "Print EditForm " << arg1 << std::endl; + sout << "Print EditForm " << arg1 << '\n'; edt = edf->Editor(); if (argc < 3) { @@ -2704,20 +2995,24 @@ static IFSelect_ReturnStatus fun_editlist(const occ::handleNamedItem(arg1)); + } if (edt.IsNull()) + { return IFSelect_RetVoid; + } - sout << "Editor, Label : " << edt->Label() << std::endl; - sout << std::endl << " -- Names (short - complete) + Labels of Values" << std::endl; + sout << "Editor, Label : " << edt->Label() << '\n'; + sout << '\n' << " -- Names (short - complete) + Labels of Values" << '\n'; edt->PrintNames(sout); - sout << std::endl << " -- Definitions --" << std::endl; + sout << '\n' << " -- Definitions --" << '\n'; edt->PrintDefs(sout); if (!edf.IsNull()) { edf->PrintDefs(sout); - sout << std::endl - << "To display values, add an option : o original f final m modified" << std::endl; + sout << '\n' + << "To display values, add an option : o original f final m modified" << '\n'; } return IFSelect_RetVoid; @@ -2727,9 +3022,13 @@ static IFSelect_ReturnStatus fun_editlist(const occ::handlePrintValues(sout, what, false); } @@ -2744,8 +3043,7 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handleArg(1); @@ -2754,16 +3052,22 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handleNamedItem(arg1)); if (edf.IsNull()) { - sout << "Not an EditForm : " << arg1 << std::endl; + sout << "Not an EditForm : " << arg1 << '\n'; return IFSelect_RetError; } int num = edf->NameNumber(arg2); if (num == 0) - sout << "Unknown Value Name : " << arg2 << std::endl; + { + sout << "Unknown Value Name : " << arg2 << '\n'; + } if (num < 0) - sout << "Not Extracted Value Name : " << arg2 << std::endl; + { + sout << "Not Extracted Value Name : " << arg2 << '\n'; + } if (num <= 0) + { return IFSelect_RetError; + } bool islist = edf->Editor()->IsList(num); const char* name = edf->Editor()->Name(num, true); // real name @@ -2775,28 +3079,33 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handleEditedList(num); if (listr.IsNull()) - sout << "(NULL LIST)" << std::endl; + { + sout << "(NULL LIST)" << '\n'; + } else { int ilist, nblist = listr->Length(); - sout << "(List : " << nblist << " Items)" << std::endl; + sout << "(List : " << nblist << " Items)" << '\n'; for (ilist = 1; ilist <= nblist; ilist++) { str = listr->Value(ilist); - sout << " [" << ilist << "] " << (str.IsNull() ? "(NULL)" : str->ToCString()) - << std::endl; + sout << " [" << ilist << "] " << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; } } if (argc < 4) - sout << "To Edit, options by editval edit-form value-name ?" << std::endl; + { + sout << "To Edit, options by editval edit-form value-name ?" << '\n'; + } } else { str = edf->EditedValue(num); - sout << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + sout << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; } if (argc < 4) + { return IFSelect_RetVoid; + } // Valeur simple ou liste ? int numarg = 3; @@ -2807,18 +3116,20 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handle listed = edf->ListEditor(num); if (listed.IsNull()) + { return IFSelect_RetError; + } if (argval[0] == '.') { listr.Nullify(); @@ -2828,7 +3139,9 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handleAddValue(new TCollection_HAsciiString(pilot->CommandPart(numarg + 1)), numadd); } @@ -2841,29 +3154,41 @@ static IFSelect_ReturnStatus fun_editvalue(const occ::handle 0) + { stated = listed->AddValue(new TCollection_HAsciiString(pilot->CommandPart(numarg + 1)), numset); + } } if (stated) + { stated = edf->ModifyList(num, listed, true); + } if (stated) - sout << "List Edition done" << std::endl; + { + sout << "List Edition done" << '\n'; + } else - sout << "List Edition not done, option" << argval << std::endl; + { + sout << "List Edition not done, option" << argval << '\n'; + } } else { if (argval[0] == '.' && argval[1] == '\0') - str.Nullify(); - else - str = new TCollection_HAsciiString(pilot->CommandPart(numarg)); - if (edf->Modify(num, str, true)) { - sout << "Now set to " << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + str.Nullify(); } else { - sout << "Modify not done" << std::endl; + str = new TCollection_HAsciiString(pilot->CommandPart(numarg)); + } + if (edf->Modify(num, str, true)) + { + sout << "Now set to " << (str.IsNull() ? "(NULL)" : str->ToCString()) << '\n'; + } + else + { + sout << "Modify not done" << '\n'; return IFSelect_RetFail; } } @@ -2876,7 +3201,7 @@ static IFSelect_ReturnStatus fun_editclear(const occ::handleArg(1); @@ -2885,30 +3210,36 @@ static IFSelect_ReturnStatus fun_editclear(const occ::handleNamedItem(arg1)); if (edf.IsNull()) { - sout << "Not an EditForm : " << arg1 << std::endl; + sout << "Not an EditForm : " << arg1 << '\n'; return IFSelect_RetError; } if (argc < 3) { edf->ClearEdit(); - sout << "All Modifications Cleared" << std::endl; + sout << "All Modifications Cleared" << '\n'; } else { int num = edf->NameNumber(arg2); if (num == 0) - sout << "Unknown Value Name : " << arg2 << std::endl; + { + sout << "Unknown Value Name : " << arg2 << '\n'; + } if (num < 0) - sout << "Not Extracted Value Name : " << arg2 << std::endl; + { + sout << "Not Extracted Value Name : " << arg2 << '\n'; + } if (num <= 0) + { return IFSelect_RetError; + } if (!edf->IsModified(num)) { - sout << "Value " << arg2 << " was not modified" << std::endl; + sout << "Value " << arg2 << " was not modified" << '\n'; return IFSelect_RetVoid; } edf->ClearEdit(num); - sout << "Modification on Value " << arg2 << " Cleared" << std::endl; + sout << "Modification on Value " << arg2 << " Cleared" << '\n'; } return IFSelect_RetDone; } @@ -2919,7 +3250,7 @@ static IFSelect_ReturnStatus fun_editapply(const occ::handleArg(1); @@ -2928,7 +3259,7 @@ static IFSelect_ReturnStatus fun_editapply(const occ::handleNamedItem(arg1)); if (edf.IsNull()) { - sout << "Not an EditForm : " << arg1 << std::endl; + sout << "Not an EditForm : " << arg1 << '\n'; return IFSelect_RetError; } @@ -2937,7 +3268,9 @@ static IFSelect_ReturnStatus fun_editapply(const occ::handleApplyData(edf->Entity(), edf->Model())) { - sout << "Modifications could not be applied" << std::endl; + sout << "Modifications could not be applied" << '\n'; return IFSelect_RetFail; } - sout << "Modifications have been applied" << std::endl; + sout << "Modifications have been applied" << '\n'; bool stat = true; if (argc > 2 && arg2[0] == 'k') + { stat = false; + } if (stat) { edf->ClearEdit(); - sout << "Edited values are cleared" << std::endl; + sout << "Edited values are cleared" << '\n'; } else - sout << "Edited values are kept for another loading/applying" << std::endl; + { + sout << "Edited values are kept for another loading/applying" << '\n'; + } return IFSelect_RetDone; } @@ -2974,7 +3313,7 @@ static IFSelect_ReturnStatus fun_editload(const occ::handleArg(1); @@ -2983,7 +3322,7 @@ static IFSelect_ReturnStatus fun_editload(const occ::handleNamedItem(arg1)); if (edf.IsNull()) { - sout << "Not an EditForm : " << arg1 << std::endl; + sout << "Not an EditForm : " << arg1 << '\n'; return IFSelect_RetError; } @@ -2991,26 +3330,26 @@ static IFSelect_ReturnStatus fun_editload(const occ::handleLoadModel(WS->Model()); } else if (num <= 0) { - sout << "Not an entity ident : " << arg2 << std::endl; + sout << "Not an entity ident : " << arg2 << '\n'; return IFSelect_RetError; } else { - sout << "EditForm " << arg1 << " : Loading Entity " << arg2 << std::endl; + sout << "EditForm " << arg1 << " : Loading Entity " << arg2 << '\n'; stat = edf->LoadData(WS->StartingEntity(num), WS->Model()); } if (!stat) { - sout << "Loading not done" << std::endl; + sout << "Loading not done" << '\n'; return IFSelect_RetFail; } - sout << "Loading done" << std::endl; + sout << "Loading done" << '\n'; return IFSelect_RetDone; } @@ -3025,7 +3364,9 @@ occ::handle IFSelect_Functions::GiveEntity( occ::handle ent; // demarre a Null int num = GiveEntityNumber(WS, name); if (num > 0) + { ent = WS->StartingEntity(num); + } return ent; } @@ -3042,11 +3383,15 @@ int IFSelect_Functions::GiveEntityNumber(const occ::handle std::cin >> ligne; // std::cin.clear(); std::cin.getline (ligne,79); if (ligne[0] == '\0') + { return 0; + } num = WS->NumberFromLabel(ligne); } else + { num = WS->NumberFromLabel(name); + } return num; } @@ -3072,7 +3417,9 @@ occ::handle IFSelect_Functions::GiveDispatch( { DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(name)); if (!disp.IsNull()) + { return disp; // OK as it is given + } // Else, let s try special cases TCollection_AsciiString nam(name); @@ -3081,10 +3428,14 @@ occ::handle IFSelect_Functions::GiveDispatch( nam.SetValue(paro, '\0'); nam.SetValue(parf, '\0'); if (paro <= 0 && parf <= 0) + { return disp; + } disp = GetCasted(IFSelect_Dispatch, WS->NamedItem(nam.ToCString())); if (disp.IsNull()) + { return disp; // KO anyway + } // According to the type of dispatch : Message_Messenger::StreamBuffer sout = Message::SendInfo(); @@ -3094,7 +3445,7 @@ occ::handle IFSelect_Functions::GiveDispatch( int nb = atoi(&(nam.ToCString())[paro]); if (nb <= 0) { - sout << " DispPerCount, count is not positive" << std::endl; + sout << " DispPerCount, count is not positive" << '\n'; disp.Nullify(); return disp; } @@ -3112,7 +3463,7 @@ occ::handle IFSelect_Functions::GiveDispatch( int nb = atoi(&(nam.ToCString())[paro]); if (nb <= 0) { - sout << " DispPerFiles, count is not positive" << std::endl; + sout << " DispPerFiles, count is not positive" << '\n'; disp.Nullify(); return disp; } @@ -3131,15 +3482,17 @@ occ::handle IFSelect_Functions::GiveDispatch( if (sg.IsNull()) { sout << "DispPerSignature " << nam << " , Signature not valid : " << &(nam.ToCString())[paro] - << std::endl; + << '\n'; disp.Nullify(); return disp; } if (mode) + { ds->SetSignCounter(new IFSelect_SignCounter(sg)); + } return ds; } - sout << "Dispatch : " << name << " , Parameter : " << &(nam.ToCString())[paro] << std::endl; + sout << "Dispatch : " << name << " , Parameter : " << &(nam.ToCString())[paro] << '\n'; return disp; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_GeneralModifier.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_GeneralModifier.cxx index 20eaaf0469..a691585863 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_GeneralModifier.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_GeneralModifier.cxx @@ -42,9 +42,13 @@ occ::handle IFSelect_GeneralModifier::Dispatch() const bool IFSelect_GeneralModifier::Applies(const occ::handle& disp) const { if (thedisp.IsNull()) + { return true; + } if (thedisp != disp) + { return false; + } return true; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_GraphCounter.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_GraphCounter.cxx index 732cd981e2..c9e7d7da9a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_GraphCounter.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_GraphCounter.cxx @@ -46,7 +46,9 @@ void IFSelect_GraphCounter::AddWithGraph( return; } if (list.IsNull()) + { return; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) { diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_IntParam.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_IntParam.cxx index e234e3418e..48defec0ef 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_IntParam.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_IntParam.cxx @@ -31,9 +31,13 @@ void IFSelect_IntParam::SetStaticName(const char* const statname) int IFSelect_IntParam::Value() const { if (thestn.Length() == 0) + { return theval; + } if (!Interface_Static::IsSet(thestn.ToCString())) + { return theval; + } return Interface_Static::IVal(thestn.ToCString()); } @@ -41,8 +45,12 @@ void IFSelect_IntParam::SetValue(const int val) { theval = val; if (thestn.Length() == 0) + { return; + } if (!Interface_Static::IsPresent(thestn.ToCString())) + { return; + } Interface_Static::SetIVal(thestn.ToCString(), theval); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ListEditor.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ListEditor.cxx index 5a8631f6dd..755210df5b 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ListEditor.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ListEditor.cxx @@ -55,7 +55,9 @@ void IFSelect_ListEditor::ClearEdit() theedit = new NCollection_HSequence>(); thestat = new NCollection_HSequence(); if (theorig.IsNull()) + { return; + } int i, nb = theorig->Length(); for (i = 1; i <= nb; i++) { @@ -72,15 +74,21 @@ static bool CheckValue(const occ::handle& val, const occ::handle& thedef) { if (val.IsNull() || modl.IsNull() || thedef.IsNull()) + { return true; + } Interface_ParamType pty = thedef->Type(); if (!thedef->Satisfies(val)) + { return false; + } if (pty == Interface_ParamIdent && !val.IsNull()) { if (modl->NextNumberForLabel(val->ToCString(), 0) <= 0) + { return false; + } } return true; } @@ -91,10 +99,14 @@ bool IFSelect_ListEditor::LoadEdited( const occ::handle>>& list) { if (list.IsNull()) + { return false; + } int i, nb = list->Length(); if (nb > themax) + { return false; + } // check values if (!thedef.IsNull()) @@ -103,7 +115,9 @@ bool IFSelect_ListEditor::LoadEdited( { occ::handle newval = list->Value(i); if (!CheckValue(newval, themodl, thedef)) + { return false; + } } } @@ -111,7 +125,9 @@ bool IFSelect_ListEditor::LoadEdited( theedit = list; thestat = new NCollection_HSequence(); for (i = 1; i <= nb; i++) + { thestat->Append(1); + } thetouc = 1; return true; @@ -120,13 +136,19 @@ bool IFSelect_ListEditor::LoadEdited( bool IFSelect_ListEditor::SetValue(const int num, const occ::handle& val) { if (theedit.IsNull()) + { return false; + } if (num < 1 || num > theedit->Length()) + { return false; + } // check value if (!CheckValue(val, themodl, thedef)) + { return false; + } // OK theedit->SetValue(num, val); @@ -139,11 +161,17 @@ bool IFSelect_ListEditor::AddValue(const occ::handle& const int atnum) { if (theedit.IsNull()) + { return false; + } if (themax > 0 && theedit->Length() >= themax) + { return false; + } if (!CheckValue(val, themodl, thedef)) + { return false; + } if (atnum > 0) { theedit->InsertBefore(atnum, val); @@ -161,15 +189,23 @@ bool IFSelect_ListEditor::AddValue(const occ::handle& bool IFSelect_ListEditor::Remove(const int num, const int howmany) { if (theedit.IsNull()) + { return false; + } int nb = theedit->Length(); if (num < 0) + { return false; + } if (num == 0) + { return Remove(nb - howmany, howmany); + } if ((num + howmany) > nb) + { return false; + } theedit->Remove(num, howmany); thestat->Remove(num, howmany); thetouc = 3; @@ -193,7 +229,9 @@ occ::handle>> IFSele int IFSelect_ListEditor::NbValues(const bool edited) const { if (edited) + { return (theedit.IsNull() ? 0 : theedit->Length()); + } return (theorig.IsNull() ? 0 : theorig->Length()); } @@ -204,17 +242,25 @@ occ::handle IFSelect_ListEditor::Value(const int num, if (edited) { if (theedit.IsNull()) + { return val; + } if (num < 1 || num > theedit->Length()) + { return val; + } val = theedit->Value(num); } else { if (theorig.IsNull()) + { return val; + } if (num < 1 || num > theorig->Length()) + { return val; + } val = theorig->Value(num); } return val; @@ -223,9 +269,13 @@ occ::handle IFSelect_ListEditor::Value(const int num, bool IFSelect_ListEditor::IsChanged(const int num) const { if (thestat.IsNull()) + { return false; + } if (num < 1 || num > thestat->Length()) + { return false; + } int stat = thestat->Value(num); return (stat != 0); } @@ -233,9 +283,13 @@ bool IFSelect_ListEditor::IsChanged(const int num) const bool IFSelect_ListEditor::IsModified(const int num) const { if (thestat.IsNull()) + { return false; + } if (num < 1 || num > thestat->Length()) + { return false; + } int stat = thestat->Value(num); return (stat == 1); } @@ -243,9 +297,13 @@ bool IFSelect_ListEditor::IsModified(const int num) const bool IFSelect_ListEditor::IsAdded(const int num) const { if (thestat.IsNull()) + { return false; + } if (num < 1 || num > thestat->Length()) + { return false; + } int stat = thestat->Value(num); return (stat == 2); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModelCopier.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModelCopier.cxx index 7137508b1a..36a48eb3f1 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModelCopier.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModelCopier.cxx @@ -64,9 +64,13 @@ bool IFSelect_ModelCopier::AddFile(const TCollection_AsciiString& for (int i = 1; i <= nb; i++) { if (filename.IsEmpty()) + { continue; + } if (thefilenames(i).IsEqual(filename)) + { return false; + } } occ::handle nulapplied; thefilenames.Append(filename); @@ -79,13 +83,19 @@ bool IFSelect_ModelCopier::NameFile(const int num, const TCollection_AsciiString { int nb = thefilenames.Length(); if (num <= 0 || num > nb) + { return false; + } for (int i = 1; i <= nb; i++) { if (filename.IsEmpty()) + { continue; + } if (thefilenames(i).IsEqual(filename)) + { return false; + } } thefilenames.SetValue(num, filename); return true; @@ -95,7 +105,9 @@ bool IFSelect_ModelCopier::ClearFile(const int num) { int nb = thefilenames.Length(); if (num <= 0 || num > nb) + { return false; + } thefilenames.ChangeValue(num).Clear(); return true; } @@ -106,7 +118,9 @@ bool IFSelect_ModelCopier::SetAppliedModifiers( { int nb = theapplieds.Length(); if (num <= 0 || num > nb) + { return false; + } theapplieds.SetValue(num, applied); return true; } @@ -115,7 +129,9 @@ bool IFSelect_ModelCopier::ClearAppliedModifiers(const int num) { int nb = theapplieds.Length(); if (num <= 0 || num > nb) + { return false; + } theapplieds.ChangeValue(num).Nullify(); return true; } @@ -138,7 +154,7 @@ Interface_CheckIterator IFSelect_ModelCopier::Copying( const occ::handle& protocol, Interface_CopyTool& TC) { - Message::SendInfo() << "** WorkSession : Copying split data before sending" << std::endl; + Message::SendInfo() << "** WorkSession : Copying split data before sending" << '\n'; const Interface_Graph& G = eval.Graph(); Interface_CheckIterator checks; theshareout = eval.ShareOut(); @@ -178,7 +194,7 @@ Interface_CheckIterator IFSelect_ModelCopier::SendCopied( const occ::handle& WL, const occ::handle& protocol) { - Message::SendInfo() << "** WorkSession : Sending split data already copied" << std::endl; + Message::SendInfo() << "** WorkSession : Sending split data already copied" << '\n'; int nb = NbFiles(); Interface_CheckIterator checks; if (nb > 0) @@ -186,7 +202,9 @@ Interface_CheckIterator IFSelect_ModelCopier::SendCopied( for (int i = 1; i <= nb; i++) { if (FileName(i).Length() == 0) + { continue; + } occ::handle curapp = theapplieds.Value(i); IFSelect_ContextWrite ctx(FileModel(i), protocol, curapp, FileName(i).ToCString()); bool res = WL->WriteFile(ctx); @@ -202,8 +220,7 @@ Interface_CheckIterator IFSelect_ModelCopier::SendCopied( char mess[100]; Sprintf(mess, "Split Send (WriteFile) abandon on file n0.%d", i); checks.CCheck(0)->AddFail(mess); - Message::SendInfo() << " ** Sending File n0." << i << " has failed, abandon **" - << std::endl; + Message::SendInfo() << " ** Sending File n0." << i << " has failed, abandon **" << '\n'; return checks; } AddSentFile(FileName(i).ToCString()); @@ -233,7 +250,7 @@ Interface_CheckIterator IFSelect_ModelCopier::Sending( const Interface_Graph& G = eval.Graph(); Interface_CheckIterator checks; int i = 0; - Message::SendInfo() << "** WorkSession : Copying then sending split data" << std::endl; + Message::SendInfo() << "** WorkSession : Copying then sending split data" << '\n'; theshareout = eval.ShareOut(); theremain = new NCollection_HArray1(0, G.Size()); theremain->Init(0); @@ -272,7 +289,7 @@ Interface_CheckIterator IFSelect_ModelCopier::Sending( Sprintf(mess, "Split Send (WriteFile) abandon on file n0.%d", i); checks.CCheck(0)->AddFail(mess); Message::SendInfo() << " ** Sending File " << filename << " has failed, abandon **" - << std::endl; + << '\n'; checks.SetName("X-STEP WorkSession : Split Send (only Write)"); return checks; } @@ -293,15 +310,19 @@ Interface_CheckIterator IFSelect_ModelCopier::SendAll( { Interface_CheckIterator checks; checks.SetName("X-STEP WorkSession : Send All"); - Message::SendInfo() << "** WorkSession : Sending all data" << std::endl; + Message::SendInfo() << "** WorkSession : Sending all data" << '\n'; const occ::handle& model = G.Model(); if (model.IsNull() || protocol.IsNull() || WL.IsNull()) + { return checks; + } Interface_CopyTool TC(model, protocol); int i, nb = model->NbEntities(); for (i = 1; i <= nb; i++) + { TC.Bind(model->Value(i), model->Value(i)); + } Interface_EntityIterator pipo; occ::handle newmod; @@ -323,7 +344,9 @@ Interface_CheckIterator IFSelect_ModelCopier::SendAll( Interface_CheckIterator checklst = ctx.CheckList(); checks.Merge(checklst); if (!res) + { checks.CCheck(0)->AddFail("SendAll (WriteFile) has failed"); + } // if (!checks.IsEmpty(false)) { // Message::SendWarning() << // " ** SendAll has produced Check Messages : **"<& original = G.Model(); if (original.IsNull() || protocol.IsNull() || WL.IsNull()) + { return checks; + } occ::handle newmod = original->NewEmptyModel(); Interface_CopyTool TC(original, protocol); TC.FillModel(newmod); // for Header ... @@ -360,7 +385,9 @@ Interface_CheckIterator IFSelect_ModelCopier::SendSelected( } int i, nb = newmod->NbEntities(); for (i = 1; i <= nb; i++) + { TC.Bind(newmod->Value(i), newmod->Value(i)); + } if (theremain.IsNull()) { theremain = new NCollection_HArray1(0, G.Size()); @@ -385,14 +412,18 @@ Interface_CheckIterator IFSelect_ModelCopier::SendSelected( for (int ic = TC.LastCopiedAfter(0, ent1, ent2); ic > 0; ic = TC.LastCopiedAfter(ic, ent1, ent2)) { if (ic <= theremain->Upper()) + { theremain->SetValue(ic, theremain->Value(ic) + 1); + } } IFSelect_ContextWrite ctx(newmod, protocol, applied, filename); bool res = WL->WriteFile(ctx); Interface_CheckIterator checklst = ctx.CheckList(); checks.Merge(checklst); if (!res) + { checks.CCheck(0)->AddFail("SendSelected (WriteFile) has failed"); + } // if (!checks.IsEmpty(false)) { // Message::SendWarning() << // " ** SendSelected has produced Check Messages : **"<Upper()) + { theremain->SetValue(ic, theremain->Value(ic) + 1); + } } } else if (newmod.IsNull()) + { newmod = original; + } // ... Then : We take into account the Model Modifiers ... int nbmod = 0; if (!theshareout.IsNull()) + { nbmod = theshareout->NbModifiers(true); + } int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= nbmod; i++) { @@ -453,8 +490,12 @@ void IFSelect_ModelCopier::CopiedModel(const Interface_Graph& // First, Dispatch/Packet criterion if (dispnum > 0) + { if (!unmod->Applies(theshareout->Dispatch(dispnum))) + { continue; + } + } IFSelect_ContextModif ctx(G, TC, filename.ToCString()); // Then, the Selection occ::handle sel = unmod->Selection(); @@ -464,7 +505,9 @@ void IFSelect_ModelCopier::CopiedModel(const Interface_Graph& ctx.Select(entiter); } if (ctx.IsForNone()) + { continue; + } unmod->Perform(ctx, newmod, protocol, TC); Interface_CheckIterator checklst = ctx.CheckList(); checks.Merge(checklst); @@ -480,9 +523,13 @@ void IFSelect_ModelCopier::CopiedModel(const Interface_Graph& // ... Then the File Modifiers : in fact, we record them ... nbmod = 0; if (!theshareout.IsNull()) + { nbmod = theshareout->NbModifiers(false); + } if (nbmod == 0) + { return; + } applied = new IFSelect_AppliedModifiers(nbmod, newmod->NbEntities()); for (i = 1; i <= nbmod; i++) { @@ -490,12 +537,18 @@ void IFSelect_ModelCopier::CopiedModel(const Interface_Graph& // First, Dispatch/Packet criterion if (dispnum > 0) + { if (!unmod->Applies(theshareout->Dispatch(dispnum))) + { continue; + } + } // Then, the Selection occ::handle sel = unmod->Selection(); if (sel.IsNull()) + { applied->AddModif(unmod); // empty -> we take all + } else { Interface_EntityIterator list = sel->UniqueResult(G); @@ -507,7 +560,9 @@ void IFSelect_ModelCopier::CopiedModel(const Interface_Graph& for (list.Start(); list.More(); list.Next()) { if (TC.Search(list.Value(), newent)) + { applied->AddNum(newmod->Number(newent)); + } } } } @@ -529,14 +584,20 @@ occ::handle IFSelect_ModelCopier::CopiedRemaining( for (int i = 1; i <= nb; i++) { if (G.Status(i) == 0) + { tocopy.AddItem(original->Value(i)); + } else + { theremain->SetValue(i, -1); // ?? -1 + } } WL->CopyModel(original, newmod, tocopy, TC); if (newmod->NbEntities() == 0) + { newmod.Nullify(); + } else { // WHAT FOLLOWS MUST NOT BE DELETED ! cf theremain @@ -545,7 +606,9 @@ occ::handle IFSelect_ModelCopier::CopiedRemaining( ic = TC.LastCopiedAfter(ic, ent1, ent2)) { if (ic <= theremain->Upper()) + { theremain->SetValue(ic, 1); + } } // some debugging prints #ifdef MISOPOINT @@ -583,13 +646,19 @@ bool IFSelect_ModelCopier::SetRemaining(Interface_Graph& CG) const { int nb = CG.Size(); if (theremain.IsNull()) + { return (nb == 0); + } if (nb != theremain->Upper()) + { return false; + } for (int i = 1; i <= nb; i++) { if (CG.Status(i) >= 0) + { CG.SetStatus(i, CG.Status(i) + theremain->Value(i)); + } } theremain->Init(0); return true; @@ -623,10 +692,14 @@ void IFSelect_ModelCopier::BeginSentFiles(const occ::handle& { thesentfiles.Nullify(); if (record) + { thesentfiles = new NCollection_HSequence>(); + } // and default file numbering : held by ShareOut if (sho.IsNull()) + { return; + } int lastrun = sho->LastRun(); sho->ClearResult(true); sho->SetLastRun(lastrun); // we are only interested in the numbers @@ -635,7 +708,9 @@ void IFSelect_ModelCopier::BeginSentFiles(const occ::handle& void IFSelect_ModelCopier::AddSentFile(const char* const filename) { if (!thesentfiles.IsNull()) + { thesentfiles->Append(new TCollection_HAsciiString(filename)); + } } occ::handle>> IFSelect_ModelCopier:: diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifEditForm.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifEditForm.cxx index 3563d95cc7..2f08b83ad5 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifEditForm.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifEditForm.cxx @@ -42,9 +42,13 @@ void IFSelect_ModifEditForm::Perform(IFSelect_ContextModif& { bool done = theedit->ApplyData(ctx.ValueResult(), target); if (done) + { ctx.Trace(); + } else + { ctx.AddWarning(ctx.ValueResult(), "EditForm could not be applied"); + } } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifReorder.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifReorder.cxx index cd004ff30e..da82821d22 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifReorder.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ModifReorder.cxx @@ -38,7 +38,9 @@ void IFSelect_ModifReorder::Perform(IFSelect_ContextModif& Interface_EntityIterator list = sht.All(ctx.OriginalModel(), thertl); target->ClearEntities(); for (list.Start(); list.More(); list.Next()) + { target->AddEntity(list.Value()); + } } TCollection_AsciiString IFSelect_ModifReorder::Label() const diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_PacketList.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_PacketList.cxx index 1fa82ce22c..1ec5f29946 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_PacketList.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_PacketList.cxx @@ -60,13 +60,19 @@ void IFSelect_PacketList::AddPacket() int nbl = thepacks.NbEntities(); int nbe = theflags.Upper(); for (int i = 1; i <= nbe; i++) + { theflags.SetValue(i, 0); + } if (thelast >= nbl) + { thepacks.SetNbEntities(nbl * 2); + } if (!thebegin) + { thelast++; + } thepacks.SetNumber(thelast); thebegin = false; } @@ -75,11 +81,17 @@ void IFSelect_PacketList::Add(const occ::handle& ent) { int num = themodel->Number(ent); if (num == 0) + { throw Interface_InterfaceError("PacketList:Add, Entity not in Model"); + } if (thelast == 0) + { throw Interface_InterfaceError("PacketList:Add, no Packet yet added"); + } if (theflags(num) != 0) + { return; + } theflags(num) = 1; thedupls(num)++; thepacks.Add(num); @@ -90,11 +102,15 @@ void IFSelect_PacketList::AddList( const occ::handle>>& list) { if (list.IsNull()) + { return; + } int i, nb = list->Length(); thepacks.Reservate(nb + 1); for (i = 1; i <= nb; i++) + { Add(list->Value(i)); + } } int IFSelect_PacketList::NbPackets() const @@ -105,7 +121,9 @@ int IFSelect_PacketList::NbPackets() const int IFSelect_PacketList::NbEntities(const int numpack) const { if (numpack <= 0 || numpack > NbPackets()) + { return 0; + } Interface_IntList lisi(thepacks, false); lisi.SetNumber(numpack); return lisi.Length(); @@ -115,12 +133,16 @@ Interface_EntityIterator IFSelect_PacketList::Entities(const int numpack) const { Interface_EntityIterator list; if (numpack <= 0 || numpack > NbPackets()) + { return list; + } Interface_IntList lisi(thepacks, false); lisi.SetNumber(numpack); int i, nb = lisi.Length(); for (i = 1; i <= nb; i++) + { list.AddItem(themodel->Value(lisi.Value(i))); + } return list; } @@ -132,7 +154,9 @@ int IFSelect_PacketList::HighestDuplicationCount() const { int j = thedupls.Value(i); if (j > high) + { high = j; + } } return high; } @@ -146,7 +170,9 @@ int IFSelect_PacketList::NbDuplicated(const int newcount, const bool andmore) co { int j = thedupls.Value(i); if (j == newcount || (j > newcount && andmore)) + { nbdu++; + } } return nbdu; } @@ -162,7 +188,9 @@ Interface_EntityIterator IFSelect_PacketList::Duplicated(const int newcount, { int j = thedupls.Value(i); if (j == newcount || (j > newcount && andmore)) + { list.AddItem(themodel->Value(i)); + } } return list; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ParamEditor.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ParamEditor.cxx index 8d5c2c959f..73a5c3c6f6 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ParamEditor.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ParamEditor.cxx @@ -29,7 +29,9 @@ IFSelect_ParamEditor::IFSelect_ParamEditor(const int nbmax, const char* const la { SetNbValues(0); if (thelabel.Length() == 0) + { thelabel.AssignCat("Param Editor"); + } } void IFSelect_ParamEditor::AddValue(const occ::handle& val, @@ -73,7 +75,9 @@ bool IFSelect_ParamEditor::Load(const occ::handle& form, { int i, nb = NbValues(); for (i = 1; i <= nb; i++) + { form->LoadValue(i, TypedValue(i)->HStringValue()); + } return true; } @@ -84,8 +88,12 @@ bool IFSelect_ParamEditor::Apply(const occ::handle& form, { int i, nb = NbValues(); for (i = 1; i <= nb; i++) + { if (form->IsModified(i)) + { TypedValue(i)->SetHStringValue(form->EditedValue(i)); + } + } return true; } @@ -96,7 +104,9 @@ occ::handle IFSelect_ParamEditor::StaticEditor( { occ::handle editor; if (list.IsNull()) + { return editor; + } int i, nb = list->Length(); // if (nb == 0) return editor; editor = new IFSelect_ParamEditor(nb + 10, label); @@ -104,7 +114,9 @@ occ::handle IFSelect_ParamEditor::StaticEditor( { occ::handle val = Interface_Static::Static(list->Value(i)->ToCString()); if (!val.IsNull()) + { editor->AddValue(val); + } } return editor; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectAnyList.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectAnyList.cxx index d0cca39bce..6d5075beaf 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectAnyList.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectAnyList.cxx @@ -61,7 +61,9 @@ occ::handle IFSelect_SelectAnyList::Lower() const int IFSelect_SelectAnyList::LowerValue() const { if (thelower.IsNull()) + { return 0; + } return thelower->Value(); } @@ -78,7 +80,9 @@ occ::handle IFSelect_SelectAnyList::Upper() const int IFSelect_SelectAnyList::UpperValue() const { if (theupper.IsNull()) + { return 0; + } return theupper->Value(); } @@ -88,31 +92,49 @@ Interface_EntityIterator IFSelect_SelectAnyList::RootResult(const Interface_Grap Interface_EntityIterator input = InputResult(G); KeepInputEntity(input); // selon type voulu if (input.NbEntities() > 1) + { throw Interface_InterfaceError("SelectAnyList : more than ONE Entity in input"); + } if (input.NbEntities() == 0) + { return input; + } occ::handle ent; for (input.Start(); input.More(); input.Next()) + { ent = input.Value(); + } int rankmax = NbItems(ent); int rankfrom = 1; if (!thelower.IsNull()) + { rankfrom = thelower->Value(); + } int rankto; if (!theupper.IsNull()) + { rankto = theupper->Value(); + } else + { rankto = rankmax; + } if (rankfrom < 1) + { rankfrom = 1; + } if (rankto > rankmax) + { rankto = rankmax; + } Interface_EntityIterator iter; if (rankfrom <= rankto) + { FillResult(rankfrom, rankto, ent, iter); + } return iter; } @@ -121,18 +143,30 @@ TCollection_AsciiString IFSelect_SelectAnyList::Label() const char lab[30]; int rankfrom = 0; if (HasLower()) + { rankfrom = LowerValue(); + } int rankto = 0; if (HasUpper()) + { rankto = UpperValue(); + } if (rankfrom == rankto) + { Sprintf(lab, " (no %d)", rankfrom); + } else if (rankfrom == 0) + { Sprintf(lab, " (-> %d)", rankfrom); + } else if (rankto == 0) + { Sprintf(lab, " (%d ->)", rankto); + } else + { Sprintf(lab, " (%d -> %d)", rankfrom, rankto); + } TCollection_AsciiString labl("In List "); labl.AssignCat(ListLabel()); diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectCombine.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectCombine.cxx index f59878d9df..f0c42ec964 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectCombine.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectCombine.cxx @@ -36,20 +36,30 @@ occ::handle IFSelect_SelectCombine::Input(const int num) con int IFSelect_SelectCombine::InputRank(const occ::handle& sel) const { if (sel.IsNull()) + { return 0; + } int i, nb = thelist.Length(); for (i = 1; i <= nb; i++) + { if (sel == thelist.Value(i)) + { return i; + } + } return 0; } void IFSelect_SelectCombine::Add(const occ::handle& sel, const int atnum) { if (atnum <= 0 || atnum > thelist.Length()) + { thelist.Append(sel); + } else + { thelist.InsertBefore(atnum, sel); + } } bool IFSelect_SelectCombine::Remove(const occ::handle& sel) @@ -60,7 +70,9 @@ bool IFSelect_SelectCombine::Remove(const occ::handle& sel) bool IFSelect_SelectCombine::Remove(const int num) { if (num <= 0 || num > thelist.Length()) + { return false; + } thelist.Remove(num); return true; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectControl.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectControl.cxx index 3eaa3e4086..73dbb69cdb 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectControl.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectControl.cxx @@ -47,5 +47,7 @@ void IFSelect_SelectControl::FillIterator(IFSelect_SelectionIterator& iter) cons { iter.AddItem(themain); if (!thesecond.IsNull()) + { iter.AddItem(thesecond); + } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDeduct.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDeduct.cxx index 20be14c37b..7f7cc224d4 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDeduct.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDeduct.cxx @@ -39,14 +39,18 @@ bool IFSelect_SelectDeduct::HasInput() const bool IFSelect_SelectDeduct::HasAlternate() const { if (!thealt.IsNull()) + { return thealt->IsSet(); + } return false; } occ::handle& IFSelect_SelectDeduct::Alternate() { if (thealt.IsNull()) + { thealt = new IFSelect_SelectPointed; + } return thealt; } @@ -63,7 +67,9 @@ Interface_EntityIterator IFSelect_SelectDeduct::InputResult(const Interface_Grap } } if (thesel.IsNull()) + { return res; + } return thesel->UniqueResult(G); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDiff.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDiff.cxx index e05092ae21..dc69d2ed6c 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDiff.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectDiff.cxx @@ -27,7 +27,9 @@ Interface_EntityIterator IFSelect_SelectDiff::RootResult(const Interface_Graph& IFGraph_Compare GC(G); GC.GetFromIter(MainInput()->RootResult(G), true); // first if (HasSecondInput()) + { GC.GetFromIter(SecondInput()->RootResult(G), false); // second + } return GC.FirstOnly(); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectEntityNumber.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectEntityNumber.cxx index 45aa6b4896..263cd79581 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectEntityNumber.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectEntityNumber.cxx @@ -38,11 +38,17 @@ Interface_EntityIterator IFSelect_SelectEntityNumber::RootResult(const Interface Interface_EntityIterator iter; int num = 0; if (!thenum.IsNull()) + { num = thenum->Value(); + } if (num < 1) + { return iter; // empty if num < 1 or num > NbEntities + } if (num <= G.Size()) + { iter.GetOneItem(G.Entity(num)); + } return iter; } @@ -50,7 +56,9 @@ TCollection_AsciiString IFSelect_SelectEntityNumber::Label() const { int num = 0; if (!thenum.IsNull()) + { num = thenum->Value(); + } TCollection_AsciiString labl(num); labl.InsertBefore(1, "Entity Number "); return labl; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExplore.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExplore.cxx index d7975d07d0..ffdd7ec3f0 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExplore.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExplore.cxx @@ -54,27 +54,37 @@ Interface_EntityIterator IFSelect_SelectExplore::RootResult(const Interface_Grap Interface_EntityIterator input; input = InputResult(G); for (input.Start(); input.More(); input.Next()) + { i = entrees.Add(input.Value()); + } ilev = entrees.Extent(); // Exploration for (i = 1; i <= nb; i++) { if (i > entrees.Extent()) + { break; + } if (i > ilev) { level++; if (level > thelevel && thelevel > 0) + { break; + } ilev = entrees.Extent(); } occ::handle ent = entrees.FindKey(i); if (ent.IsNull()) + { continue; + } Interface_EntityIterator exp; if (!Explore(level, ent, G, exp)) + { continue; + } // We take into account : entity to take directly ? // take back input list (level not reached) or result (level reached) @@ -86,12 +96,16 @@ Interface_EntityIterator IFSelect_SelectExplore::RootResult(const Interface_Grap else if (level == thelevel) { for (exp.Start(); exp.More(); exp.Next()) + { j = result.Add(exp.Value()); + } } else { for (exp.Start(); exp.More(); exp.Next()) + { j = entrees.Add(exp.Value()); + } } } @@ -99,7 +113,9 @@ Interface_EntityIterator IFSelect_SelectExplore::RootResult(const Interface_Grap Interface_EntityIterator res; nb = result.Extent(); for (j = 1; j <= nb; j++) + { res.AddItem(result.FindKey(j)); + } return res; } @@ -107,7 +123,9 @@ TCollection_AsciiString IFSelect_SelectExplore::Label() const { TCollection_AsciiString labl; if (thelevel == 0) + { labl.AssignCat("(Recursive)"); + } else if (thelevel > 0) { char lab[30]; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExtract.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExtract.cxx index 51995f235f..00358630c8 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExtract.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectExtract.cxx @@ -46,7 +46,9 @@ Interface_EntityIterator IFSelect_SelectExtract::RootResult(const Interface_Grap const occ::handle& ent = inputer.Value(); rank++; if (SortInGraph(rank, ent, G) == thesort) + { iter.GetOneItem(ent); + } } return iter; } @@ -62,9 +64,13 @@ TCollection_AsciiString IFSelect_SelectExtract::Label() const { TCollection_AsciiString labl; if (thesort) + { labl.AssignCat("Picked: "); + } if (!thesort) + { labl.AssignCat("Removed: "); + } labl.AssignCat(ExtractLabel()); return labl; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectFlag.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectFlag.cxx index b3c01b4992..92d1d5bd17 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectFlag.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectFlag.cxx @@ -38,16 +38,22 @@ Interface_EntityIterator IFSelect_SelectFlag::RootResult(const Interface_Graph& const Interface_BitMap& bm = G.BitMap(); int flag = bm.FlagNumber(thename.ToCString()); if (flag == 0) + { return res; + } Interface_EntityIterator inp = InputResult(G); for (inp.Start(); inp.More(); inp.Next()) { int num = G.EntityNumber(inp.Value()); if (num == 0) + { continue; + } if (direct == bm.Value(num, flag)) + { res.AddItem(G.Entity(num)); + } } return res; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectInList.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectInList.cxx index d2cffdac00..0ecb255db8 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectInList.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectInList.cxx @@ -26,5 +26,7 @@ void IFSelect_SelectInList::FillResult(const int n1 Interface_EntityIterator& result) const { for (int i = n1; i <= n2; i++) + { result.GetOneItem(ListedEntity(i, ent)); + } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectPointed.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectPointed.cxx index f56e708843..ad4eea431f 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectPointed.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectPointed.cxx @@ -44,7 +44,9 @@ void IFSelect_SelectPointed::SetEntity(const occ::handle& en theitems.Clear(); theset = true; if (ent.IsNull()) + { return; + } theitems.Append(ent); } @@ -54,10 +56,14 @@ void IFSelect_SelectPointed::SetList( theitems.Clear(); theset = true; if (list.IsNull()) + { return; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) + { theitems.Append(list->Value(i)); + } } // .... Editions @@ -65,10 +71,16 @@ void IFSelect_SelectPointed::SetList( bool IFSelect_SelectPointed::Add(const occ::handle& item) { if (item.IsNull()) + { return false; + } for (int i = theitems.Length(); i >= 1; i--) + { if (item == theitems.Value(i)) + { return false; + } + } theitems.Append(item); theset = true; return true; @@ -77,28 +89,42 @@ bool IFSelect_SelectPointed::Add(const occ::handle& item) bool IFSelect_SelectPointed::Remove(const occ::handle& item) { if (item.IsNull()) + { return false; + } for (int i = theitems.Length(); i >= 1; i--) + { if (item == theitems.Value(i)) { theitems.Remove(i); return true; } + } return true; } bool IFSelect_SelectPointed::Toggle(const occ::handle& item) { if (item.IsNull()) + { return false; + } int num = 0; for (int i = theitems.Length(); i >= 1; i--) + { if (item == theitems.Value(i)) + { num = i; + } + } if (num == 0) + { theitems.Append(item); + } else + { theitems.Remove(num); + } return (num == 0); } @@ -108,16 +134,22 @@ bool IFSelect_SelectPointed::AddList( // Optimized with a Map bool res = false; if (list.IsNull()) + { return res; + } int i, nb = theitems.Length(), nl = list->Length(); NCollection_Map> deja(nb + nl + 1); for (i = 1; i <= nb; i++) + { deja.Add(theitems.Value(i)); + } for (i = 1; i <= nl; i++) { if (!deja.Contains(list->Value(i))) + { theitems.Append(list->Value(i)); + } } theset = true; return res; @@ -128,10 +160,14 @@ bool IFSelect_SelectPointed::RemoveList( { bool res = false; if (list.IsNull()) + { return res; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) + { res |= Remove(list->Value(i)); + } return res; } @@ -140,10 +176,14 @@ bool IFSelect_SelectPointed::ToggleList( { bool res = true; if (list.IsNull()) + { return res; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) + { res |= Toggle(list->Value(i)); + } return res; } @@ -152,10 +192,16 @@ bool IFSelect_SelectPointed::ToggleList( int IFSelect_SelectPointed::Rank(const occ::handle& item) const { if (item.IsNull()) + { return 0; + } for (int i = theitems.Length(); i >= 1; i--) + { if (item == theitems.Value(i)) + { return i; + } + } return 0; } @@ -168,7 +214,9 @@ occ::handle IFSelect_SelectPointed::Item(const int num) cons { occ::handle item; if (num <= 0 || num > theitems.Length()) + { return item; + } return theitems.Value(num); } @@ -180,9 +228,13 @@ void IFSelect_SelectPointed::Update(const occ::handle& co occ::handle enfr, ento; enfr = theitems.Value(i); if (!control->Search(enfr, ento)) + { theitems.Remove(i); + } else + { theitems.SetValue(i, ento); + } } } @@ -194,9 +246,13 @@ void IFSelect_SelectPointed::Update(const occ::handle& trf occ::handle enfr, ento; enfr = theitems.Value(i); if (!trf->Updated(enfr, ento)) + { theitems.Remove(i); + } else + { theitems.SetValue(i, ento); + } } } @@ -210,7 +266,9 @@ Interface_EntityIterator IFSelect_SelectPointed::RootResult(const Interface_Grap { occ::handle item = theitems.Value(i); if (G.EntityNumber(item) > 0) + { result.GetOneItem(item); + } } return result; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRange.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRange.cxx index 3364c30017..0ccd39300f 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRange.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRange.cxx @@ -60,7 +60,9 @@ occ::handle IFSelect_SelectRange::Lower() const int IFSelect_SelectRange::LowerValue() const { if (thelower.IsNull()) + { return 0; + } return thelower->Value(); } @@ -77,7 +79,9 @@ occ::handle IFSelect_SelectRange::Upper() const int IFSelect_SelectRange::UpperValue() const { if (theupper.IsNull()) + { return 0; + } return theupper->Value(); } @@ -87,10 +91,14 @@ bool IFSelect_SelectRange::Sort(const int rank, { int rankfrom = 0; if (!thelower.IsNull()) + { rankfrom = thelower->Value(); + } int rankto = 0; if (!theupper.IsNull()) + { rankto = theupper->Value(); + } return (rank >= rankfrom && (rankto == 0 || rankto >= rank)); } @@ -99,18 +107,30 @@ TCollection_AsciiString IFSelect_SelectRange::ExtractLabel() const char lab[30]; int rankfrom = 0; if (!thelower.IsNull()) + { rankfrom = thelower->Value(); + } int rankto = 0; if (!theupper.IsNull()) + { rankto = theupper->Value(); + } if (rankfrom == rankto) + { Sprintf(lab, "Rank no %d", rankfrom); + } else if (rankfrom == 0) + { Sprintf(lab, "Until no %d", rankto); + } else if (rankto == 0) + { Sprintf(lab, "From no %d", rankto); + } else + { Sprintf(lab, "From %d Until %d", rankfrom, rankto); + } return TCollection_AsciiString(lab); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRootComps.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRootComps.cxx index f65aa45664..7bed4d6f81 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRootComps.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRootComps.cxx @@ -56,7 +56,9 @@ Interface_EntityIterator IFSelect_SelectRootComps::RootResult(const Interface_Gr { const occ::handle& ent = inp1.Value(); if ((GC.NbTimes(ent) <= 1) == IsDirect()) + { iter.GetOneItem(ent); + } } return iter; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRoots.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRoots.cxx index 681badee11..08acac976a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRoots.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectRoots.cxx @@ -44,7 +44,9 @@ Interface_EntityIterator IFSelect_SelectRoots::RootResult(const Interface_Graph& { const occ::handle& ent = input.Value(); if ((GC.NbTimes(ent) <= 1) == IsDirect()) + { iter.GetOneItem(ent); + } } return iter; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSent.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSent.cxx index a209664bed..6a551852de 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSent.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSent.cxx @@ -48,17 +48,27 @@ Interface_EntityIterator IFSelect_SelectSent::RootResult(const Interface_Graph& { int num = G.EntityNumber(inp.Value()); if (num == 0) + { continue; + } int nb = G.Status(num); // nb sent bool ok; if (thecnt == 0) + { ok = (nb == 0); + } else if (thelst) + { ok = (nb >= thecnt); + } else + { ok = (nb == thecnt); + } if (ok == direct) + { res.AddItem(G.Entity(num)); + } } return res; } @@ -75,21 +85,35 @@ TCollection_AsciiString IFSelect_SelectSent::ExtractLabel() const char lb[80]; TCollection_AsciiString lab; if (thecnt == 0) + { lab.AssignCat("Remaining (non-sent) entities"); + } if (thecnt == 1 && thelst) + { lab.AssignCat("Sent entities"); + } if (thecnt == 1 && !thelst) + { lab.AssignCat("Sent once (non-duplicated) entities"); + } if (thecnt == 2 && thelst) + { lab.AssignCat("Sent several times entities"); + } if (thecnt == 2 && !thelst) + { lab.AssignCat("Sent just twice entities"); + } if (thecnt > 2) { if (thelst) + { Sprintf(lb, "Sent at least %d times entities", thecnt); + } else + { Sprintf(lb, "Sent just %d times entities", thecnt); + } lab.AssignCat(lb); } return lab; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignature.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignature.cxx index 3d77cbee38..a0dfa885ce 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignature.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignature.cxx @@ -46,7 +46,9 @@ static int multsign(const TCollection_AsciiString& signtext, } } if (mode == 0) + { return mode; + } // On va tronconner TCollection_AsciiString item; int imod = 1; @@ -65,18 +67,28 @@ static int multsign(const TCollection_AsciiString& signtext, imod = (unsign == '|' ? 1 : 2); } else if (unsign == '<') + { imod += 16; + } else if (unsign == '>') + { imod += 32; + } else if (unsign == '=') { if (imod < 8) + { imod += 2; + } else + { imod += 8; + } } else + { item.AssignCat(unsign); + } } if (item.Length() > 0) { @@ -95,7 +107,9 @@ IFSelect_SelectSignature::IFSelect_SelectSignature(const occ::handle& matcher, @@ -106,7 +120,9 @@ IFSelect_SelectSignature::IFSelect_SelectSignature(const occ::handle& counter, @@ -117,7 +133,9 @@ IFSelect_SelectSignature::IFSelect_SelectSignature(const occ::handle IFSelect_SelectSignature::Signature() const @@ -140,7 +158,9 @@ bool IFSelect_SelectSignature::SortInGraph(const int, if (theexact <= 0) { if (!thematcher.IsNull()) + { return thematcher->Matches(ent, model, thesigntext, (theexact < 0)); + } txt = thecounter->ComputedSign(ent, G); return IFSelect_Signature::MatchValue(txt, thesigntext, (theexact < 0)); } @@ -166,17 +186,25 @@ bool IFSelect_SelectSignature::SortInGraph(const int, if (jmod == 0) { if (!thematcher.IsNull()) + { quid = thematcher->Matches(ent, model, signtext, (imod > 2)); + } else + { quid = IFSelect_Signature::MatchValue(thecounter->ComputedSign(ent, G), signtext, (imod > 2)); + } } else { if (!thematcher.IsNull()) + { txt = thematcher->Value(ent, model); + } else + { txt = thecounter->ComputedSign(ent, G); + } int val = atoi(txt); int lav = atoi(signtext); @@ -200,9 +228,13 @@ bool IFSelect_SelectSignature::SortInGraph(const int, } } if ((imod == 1 || imod == 3) && quid) + { res = true; + } if ((imod == 2 || imod == 4) && quid) + { res = false; + } } return res; } @@ -228,15 +260,25 @@ TCollection_AsciiString IFSelect_SelectSignature::ExtractLabel() const { TCollection_AsciiString lab; if (!thematcher.IsNull()) + { lab.AssignCat(thematcher->Name()); + } else + { lab.AssignCat(thecounter->Name()); + } if (theexact < 0) + { lab.AssignCat(" matching "); + } else if (theexact == 0) + { lab.AssignCat(" containing "); + } else + { lab.AssignCat(" matching list "); + } lab.AssignCat(thesigntext); return lab; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedShared.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedShared.cxx index d2826355b5..ffd0c3a3ca 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedShared.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedShared.cxx @@ -54,13 +54,17 @@ bool IFSelect_SelectSignedShared::Explore(const int Interface_EntityIterator& explored) const { if (thematcher->Matches(ent, G.Model(), thesigntext, theexact)) + { return true; + } // otherwise, we do the sorting here Interface_EntityIterator list = G.Shareds(ent); // If no more Shared, then it's finished if (list.NbEntities() == 0) + { return false; + } // Otherwise, sort if we are at the level if (level < Level()) @@ -71,7 +75,9 @@ bool IFSelect_SelectSignedShared::Explore(const int for (list.Start(); list.More(); list.Next()) { if (thematcher->Matches(list.Value(), G.Model(), thesigntext, theexact)) + { explored.AddItem(list.Value()); + } } return true; } @@ -81,9 +87,13 @@ TCollection_AsciiString IFSelect_SelectSignedShared::ExploreLabel() const TCollection_AsciiString lab("Shared,"); lab.AssignCat(thematcher->Name()); if (theexact) + { lab.AssignCat(" matching "); + } else + { lab.AssignCat(" containing "); + } lab.AssignCat(thesigntext); return lab; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedSharing.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedSharing.cxx index efd380ef79..233a90123b 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedSharing.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSignedSharing.cxx @@ -54,13 +54,17 @@ bool IFSelect_SelectSignedSharing::Explore(const int Interface_EntityIterator& explored) const { if (thematcher->Matches(ent, G.Model(), thesigntext, theexact)) + { return true; + } // otherwise, we do the sorting here Interface_EntityIterator list = G.Sharings(ent); // If no more Sharing, then it's finished if (list.NbEntities() == 0) + { return false; + } // Otherwise, sort if we are at the level if (level < Level()) @@ -71,7 +75,9 @@ bool IFSelect_SelectSignedSharing::Explore(const int for (list.Start(); list.More(); list.Next()) { if (thematcher->Matches(list.Value(), G.Model(), thesigntext, theexact)) + { explored.AddItem(list.Value()); + } } return true; } @@ -81,9 +87,13 @@ TCollection_AsciiString IFSelect_SelectSignedSharing::ExploreLabel() const TCollection_AsciiString lab("Sharing,"); lab.AssignCat(thematcher->Name()); if (theexact) + { lab.AssignCat(" matching "); + } else + { lab.AssignCat(" containing "); + } lab.AssignCat(thesigntext); return lab; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSuite.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSuite.cxx index 84a6ff908a..102e8d97ec 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSuite.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectSuite.cxx @@ -26,28 +26,40 @@ IFSelect_SelectSuite::IFSelect_SelectSuite() = default; bool IFSelect_SelectSuite::AddInput(const occ::handle& item) { if (item.IsNull()) + { return false; + } occ::handle input = Input(); if (!input.IsNull()) + { return false; + } occ::handle first = occ::down_cast(item); if (first.IsNull()) + { SetInput(item); + } else + { thesel.Prepend(item); + } return true; } void IFSelect_SelectSuite::AddPrevious(const occ::handle& item) { if (!item.IsNull()) + { thesel.Prepend(item); + } } void IFSelect_SelectSuite::AddNext(const occ::handle& item) { if (!item.IsNull()) + { thesel.Append(item); + } } int IFSelect_SelectSuite::NbItems() const @@ -71,7 +83,9 @@ Interface_EntityIterator IFSelect_SelectSuite::RootResult(const Interface_Graph& Interface_EntityIterator iter; bool firstin = (HasInput() || HasAlternate()); if (firstin) + { iter = InputResult(G); + } // Starting : we take the Input/Alternate IF one of the 2 is set // Otherwise, we start on the basic definition of the first selection @@ -80,7 +94,9 @@ Interface_EntityIterator IFSelect_SelectSuite::RootResult(const Interface_Graph& { occ::handle anitem = Item(i); if (firstin) + { anitem->Alternate()->SetList(iter.Content()); + } firstin = true; // then it's systematic iter = anitem->UniqueResult(G); } @@ -90,7 +106,9 @@ Interface_EntityIterator IFSelect_SelectSuite::RootResult(const Interface_Graph& TCollection_AsciiString IFSelect_SelectSuite::Label() const { if (thelab.Length() > 0) + { return thelab; + } char txt[100]; Sprintf(txt, "Suite of %d Selections", NbItems()); TCollection_AsciiString lab(txt); diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectUnion.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectUnion.cxx index 2e51c56a4f..5290fef3cb 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectUnion.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectUnion.cxx @@ -27,7 +27,9 @@ Interface_EntityIterator IFSelect_SelectUnion::RootResult(const Interface_Graph& IFGraph_Cumulate GC(G); int nb = NbInputs(); for (int i = 1; i <= nb; i++) + { GC.GetFromIter(Input(i)->RootResult(G)); + } return GC.Result(); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Selection.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Selection.cxx index 213d1b430f..675201cdbc 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Selection.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Selection.cxx @@ -31,7 +31,9 @@ Interface_EntityIterator IFSelect_Selection::UniqueResult(const Interface_Graph& { Interface_EntityIterator iter = RootResult(G); if (HasUniqueResult() || !G.ModeStat()) + { return iter; + } Interface_Graph GG(G); GG.GetFromIter(iter, 0); return Interface_GraphContent(GG); // specialized EntityIterator (same size) diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectionIterator.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectionIterator.cxx index eb93ef766a..69575db34b 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectionIterator.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SelectionIterator.cxx @@ -31,13 +31,17 @@ IFSelect_SelectionIterator::IFSelect_SelectionIterator(const occ::handle& sel) { if (!sel.IsNull()) + { thelist->Append(sel); + } } void IFSelect_SelectionIterator::AddList( @@ -45,7 +49,9 @@ void IFSelect_SelectionIterator::AddList( { int nb = list.Length(); // Pas Handle Handle for (int i = 1; i <= nb; i++) + { thelist->Append(list.Value(i)); + } } bool IFSelect_SelectionIterator::More() const diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionDumper.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionDumper.cxx index 47f88d7459..182869d492 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionDumper.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionDumper.cxx @@ -33,7 +33,9 @@ IFSelect_SessionDumper::IFSelect_SessionDumper() occ::handle bid = new IFSelect_BasicDumper; } else + { thenext = thefirst; + } thefirst = this; // as Handle } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionFile.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionFile.cxx index f2a4ef9aeb..f7f1ebba4a 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionFile.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionFile.cxx @@ -94,7 +94,9 @@ void IFSelect_SessionFile::AddLine(const char* const line) void IFSelect_SessionFile::RemoveLastLine() { if (thelist.Length() > 1) + { thelist.Remove(thelist.Length()); + } } bool IFSelect_SessionFile::WriteFile(const char* const filename) @@ -102,7 +104,9 @@ bool IFSelect_SessionFile::WriteFile(const char* const filename) FILE* lefic = OSD_OpenFile(filename, "w"); int nbl = thelist.Length(); for (int i = 1; i <= nbl; i++) + { fprintf(lefic, "%s\n", thelist.Value(i).ToCString()); + } fclose(lefic); ClearLines(); return true; @@ -113,7 +117,9 @@ bool IFSelect_SessionFile::ReadFile(const char* const filename) char ligne[201]; FILE* lefic = OSD_OpenFile(filename, "r"); if (!lefic) + { return false; + } ClearLines(); // read mode : read the lines // Load the file into "thelist" @@ -126,12 +132,16 @@ bool IFSelect_SessionFile::ReadFile(const char* const filename) break; } if (ligne[0] == '\0') + { continue; + } // First initial line ? if (!header) { if (!RecognizeFile(ligne)) + { break; + } header = true; } ligne[200] = '\0'; // forced end ... @@ -149,14 +159,14 @@ bool IFSelect_SessionFile::RecognizeFile(const char* const headerline) SplitLine(headerline); if (theline.Length() != 4) { - sout << "File Form Incorrect" << std::endl; + sout << "File Form Incorrect" << '\n'; return false; } occ::handle sesstype = thesess->DynamicType(); if (!theline.Value(1).IsEqual("!XSTEP") || !theline.Value(2).IsEqual("SESSION") || !theline.Value(4).IsEqual(sesstype->Name())) { - sout << "Lineno." << thenl << " : File Header Description Incorrect" << std::endl; + sout << "Lineno." << thenl << " : File Header Description Incorrect" << '\n'; return false; } // Value(3) defines the VERSION of the file format @@ -168,21 +178,29 @@ int IFSelect_SessionFile::Write(const char* const filename) thenewnum = 0; int stat = WriteSession(); if (stat != 0) + { return stat; + } stat = WriteEnd(); if (stat != 0) + { return stat; + } return (WriteFile(filename) ? 0 : -1); } int IFSelect_SessionFile::Read(const char* const filename) { if (!ReadFile(filename)) + { return -1; + } thenewnum = 0; int stat = ReadSession(); if (stat != 0) + { return stat; + } stat = ReadEnd(); return stat; } @@ -204,7 +222,9 @@ int IFSelect_SessionFile::WriteSession() { occ::handle item = thesess->Item(i); if (!item.IsNull()) + { thenums->SetValue(i, -1); + } } // ... WRITING @@ -221,7 +241,9 @@ int IFSelect_SessionFile::WriteSession() idents = thesess->ItemIdents(STANDARD_TYPE(IFSelect_IntParam)); nb = idents->Length(); if (nb > 0) + { WriteLine("!INTEGERS", '\n'); + } int j; // svv Jan11 2000 : porting on DEC for (j = 1; j <= nb; j++) { @@ -235,14 +257,18 @@ int IFSelect_SessionFile::WriteSession() Sprintf(laligne, " #%d %d", thenewnum, P->Value()); } else + { Sprintf(laligne, " %s %d", name->ToCString(), P->Value()); + } WriteLine(laligne, '\n'); } idents = thesess->ItemIdents(STANDARD_TYPE(TCollection_HAsciiString)); nb = idents->Length(); if (nb > 0) + { WriteLine("!TEXTS", '\n'); + } for (j = 1; j <= nb; j++) { i = idents->Value(j); @@ -255,14 +281,18 @@ int IFSelect_SessionFile::WriteSession() Sprintf(laligne, " #%d %s", thenewnum, P->ToCString()); } else + { Sprintf(laligne, " %s %s", name->ToCString(), P->ToCString()); + } WriteLine(laligne, '\n'); } idents = thesess->ItemIdents(STANDARD_TYPE(IFSelect_Selection)); nb = idents->Length(); if (nb > 0) + { WriteLine("!SELECTIONS", '\n'); + } for (j = 1; j <= nb; j++) { i = idents->Value(j); @@ -292,29 +322,41 @@ int IFSelect_SessionFile::WriteSession() SetOwn(false); if (nb > 0) + { WriteLine("!SOURCES", '\n'); + } for (j = 1; j <= nb; j++) { i = idents->Value(j); occ::handle P = thesess->Selection(i); int nbs = thesess->NbSources(P); if (nbs == 0) + { continue; + } name = thesess->Name(P); if (name.IsNull()) + { Sprintf(laligne, " #%d %d", thenums->Value(i), nbs); + } else + { Sprintf(laligne, " %s %d", name->ToCString(), nbs); + } WriteLine(laligne); for (int k = 1; k <= nbs; k++) + { SendItem(thesess->Source(P, k)); + } WriteLine("", '\n'); } idents = thesess->ItemIdents(STANDARD_TYPE(IFSelect_GeneralModifier)); nb = idents->Length(); if (nb > 0) + { WriteLine("!MODIFIERS", '\n'); + } for (j = 1; j <= nb; j++) { // Basic description of Modifiers, so without Selection or Dispatch-Rank @@ -330,7 +372,9 @@ int IFSelect_SessionFile::WriteSession() idents = thesess->ItemIdents(STANDARD_TYPE(IFSelect_Transformer)); nb = idents->Length(); if (nb > 0) + { WriteLine("!TRANSFORMERS", '\n'); + } for (j = 1; j <= nb; j++) { // Description of Transformers @@ -347,7 +391,9 @@ int IFSelect_SessionFile::WriteSession() idents = thesess->ItemIdents(STANDARD_TYPE(IFSelect_Dispatch)); nb = idents->Length(); if (nb > 0) + { WriteLine("!DISPATCHES", '\n'); + } for (j = 1; j <= nb; j++) { i = idents->Value(j); @@ -366,25 +412,43 @@ int IFSelect_SessionFile::WriteSession() SetOwn(false); occ::handle namingpart = thesess->FilePrefix(); if (namingpart->IsEmpty()) + { namingpart.Nullify(); + } if (namingpart.IsNull()) + { SendVoid(); + } else + { SendText(namingpart->ToCString()); + } namingpart = thesess->DefaultFileRoot(); if (namingpart->IsEmpty()) + { namingpart.Nullify(); + } if (namingpart.IsNull()) + { SendVoid(); + } else + { SendText(namingpart->ToCString()); + } namingpart = thesess->FileExtension(); if (namingpart->IsEmpty()) + { namingpart.Nullify(); + } if (namingpart.IsNull()) + { SendVoid(); + } else + { SendText(namingpart->ToCString()); + } WriteLine("", '\n'); for (j = 1; j <= nb; j++) @@ -392,7 +456,9 @@ int IFSelect_SessionFile::WriteSession() i = idents->Value(j); occ::handle P = thesess->Dispatch(i); if (!P->HasRootName()) + { continue; + } namingpart = P->RootName(); SetOwn(false); SendItem(P); @@ -410,11 +476,17 @@ int IFSelect_SessionFile::WriteSession() idents = thesess->FinalModifierIdents((formod > 0)); // given in application order nb = idents->Length(); if (nb == 0) + { continue; + } if (formod > 0) + { WriteLine("!MODELMODIFIERS", '\n'); + } else + { WriteLine("!FILEMODIFIERS", '\n'); + } for (j = 1; j <= nb; j++) { i = idents->Value(j); @@ -442,11 +514,17 @@ int IFSelect_SessionFile::WriteEnd() void IFSelect_SessionFile::WriteLine(const char* const line, const char follow) { if (line[0] != '\0') + { thebuff.AssignCat(line); + } if (follow == '\0') + { return; + } if (follow != '\n') + { thebuff.AssignCat(follow); + } else { thelist.Append(thebuff); @@ -458,13 +536,17 @@ void IFSelect_SessionFile::WriteLine(const char* const line, const char follow) bool IFSelect_SessionFile::WriteOwn(const occ::handle& item) { if (item.IsNull()) + { return false; + } SetOwn(true); occ::handle dumper = IFSelect_SessionDumper::First(); while (!dumper.IsNull()) { if (dumper->WriteOwn(*this, item)) + { break; + } dumper = dumper->Next(); } SetOwn(false); @@ -484,56 +566,71 @@ int IFSelect_SessionFile::ReadSession() thenames.Clear(); // .. General data, control if (!ReadLine()) + { return 1; + } if (theline.Length() != 4) { - sout << "File Form Incorrect" << std::endl; + sout << "File Form Incorrect" << '\n'; return 1; } occ::handle sesstype = thesess->DynamicType(); if (!theline.Value(1).IsEqual("!XSTEP") || !theline.Value(2).IsEqual("SESSION") || !theline.Value(4).IsEqual(sesstype->Name())) { - sout << "Lineno." << thenl << " : File Header Description Incorrect" << std::endl; + sout << "Lineno." << thenl << " : File Header Description Incorrect" << '\n'; return 1; } // Value(3) defines the VERSION of the file format if (!ReadLine()) + { return 1; + } // .. General Parameters int rubr = (theline.Length() == 1 && theline.Value(1).IsEqual("!GENERALS")); while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Length() == 0) + { continue; + } const TCollection_AsciiString& ungen = theline.Value(1); if (ungen.Value(1) == '!') + { break; // end of generals + } if (ungen.IsEqual("ErrorHandle")) { if (theline.Length() != 2) { - sout << "Lineno." << thenl << " : ErrorHandle Description Incorrect" << std::endl; + sout << "Lineno." << thenl << " : ErrorHandle Description Incorrect" << '\n'; continue; } if (theline.Value(2).IsEqual("0")) + { thesess->SetErrorHandle(false); + } else if (theline.Value(2).IsEqual("1")) + { thesess->SetErrorHandle(true); + } else { - sout << "Lineno." << thenl << " : ErrorHandle Incorrect : " << theline.Value(2) - << std::endl; + sout << "Lineno." << thenl << " : ErrorHandle Incorrect : " << theline.Value(2) << '\n'; continue; } continue; } else + { sout << "Lineno." << thenl << " : Unknown General Parameter : " << ungen << " , ignored" - << std::endl; + << '\n'; + } } // .. IntParams @@ -542,12 +639,16 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() != 2) { - sout << "Lineno." << thenl << " : An Integer Parameter is badly defined" << std::endl; + sout << "Lineno." << thenl << " : An Integer Parameter is badly defined" << '\n'; continue; } occ::handle par = new IFSelect_IntParam; @@ -560,12 +661,16 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() != 2) { - sout << "Lineno." << thenl << " : A Text Parameter is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Text Parameter is badly defined" << '\n'; continue; } // Caution, a text can contain blanks ... restart from line(thenl) @@ -576,9 +681,13 @@ int IFSelect_SessionFile::ReadSession() char unc = oneline.Value(1); inc = ic; if (unc == ' ') + { iw = 1; + } else if (iw > 0) + { break; + } } oneline.Remove(1, inc); AddItem(new TCollection_HAsciiString(oneline.ToCString())); @@ -589,12 +698,16 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 2) { - sout << "Lineno." << thenl << " : A Selection is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Selection is badly defined" << '\n'; continue; } // .. Analysis of certain general cases @@ -605,11 +718,17 @@ int IFSelect_SessionFile::ReadSession() if (theline.Length() > 2) { if (theline.Value(3).IsEqual("D")) + { direct = 1; + } else if (theline.Value(3).IsEqual("R")) + { direct = -1; + } if (direct != 0) + { firstown++; + } if (firstown + 2 <= theline.Length()) { if (theline.Value(firstown).IsEqual("LIST")) @@ -625,22 +744,32 @@ int IFSelect_SessionFile::ReadSession() occ::handle item; // to be provided ... ReadOwn(item); if (item.IsNull()) + { continue; + } DeclareAndCast(IFSelect_SelectExtract, sxt, item); if (!sxt.IsNull()) { if (direct == 0) - sout << "Lineno." << thenl << " : A SelectExtract is badly defined" << std::endl; + { + sout << "Lineno." << thenl << " : A SelectExtract is badly defined" << '\n'; + } else + { sxt->SetDirect((direct > 0)); + } } DeclareAndCast(IFSelect_SelectAnyList, sli, item); if (!sli.IsNull()) { if (numlist == 0) - sout << "Lineno." << thenl << " : A SelectAnyList is badly defined" << std::endl; + { + sout << "Lineno." << thenl << " : A SelectAnyList is badly defined" << '\n'; + } else + { sli->SetRange(low, up); + } } AddItem(item); } @@ -650,18 +779,22 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 3) { - sout << "Lineno." << thenl << " : A Selection Source List is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Selection Source List is badly defined" << '\n'; continue; } DeclareAndCast(IFSelect_Selection, sel, ItemValue(1)); if (sel.IsNull()) { - sout << "Lineno." << thenl << " : A Source List is not for a Selection" << std::endl; + sout << "Lineno." << thenl << " : A Source List is not for a Selection" << '\n'; continue; } int nbs = atoi(theline.Value(2).ToCString()); @@ -670,8 +803,10 @@ int IFSelect_SessionFile::ReadSession() if (!sxt.IsNull()) { if (nbs > 1) + { sout << "Lineno." << thenl << " : SelectExtract, more than one source, following ignored" - << std::endl; + << '\n'; + } DeclareAndCast(IFSelect_Selection, source, ItemValue(3)); sxt->SetInput(source); } @@ -679,16 +814,20 @@ int IFSelect_SessionFile::ReadSession() if (!sdt.IsNull()) { if (nbs > 1) + { sout << "Lineno." << thenl << " : SelectDeduct, more than one source, following ignored" - << std::endl; + << '\n'; + } sdt->SetInput(GetCasted(IFSelect_Selection, ItemValue(3))); } DeclareAndCast(IFSelect_SelectControl, sct, sel); if (!sct.IsNull()) { if (nbs != 2) + { sout << "Lineno." << thenl << " : SelectControl, not two sources, following ignored" - << std::endl; + << '\n'; + } sct->SetMainInput(GetCasted(IFSelect_Selection, ItemValue(3))); sct->SetSecondInput(GetCasted(IFSelect_Selection, ItemValue(4))); } @@ -696,7 +835,9 @@ int IFSelect_SessionFile::ReadSession() if (!sco.IsNull()) { for (int j = 1; j <= nbs; j++) + { sco->Add(GetCasted(IFSelect_Selection, ItemValue(j + 2))); + } } } @@ -705,22 +846,28 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 2) { - sout << "Lineno." << thenl << " : A Modifier is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Modifier is badly defined" << '\n'; continue; } occ::handle item; // to be provided ... ReadOwn(item); if (item.IsNull()) + { continue; + } DeclareAndCast(IFSelect_GeneralModifier, modif, item); if (modif.IsNull()) { - sout << "Lineno." << thenl << " : A Modifier has not been Recognized" << std::endl; + sout << "Lineno." << thenl << " : A Modifier has not been Recognized" << '\n'; continue; } AddItem(modif, false); // active later @@ -731,22 +878,28 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 2) { - sout << "Lineno." << thenl << " : A Transformer is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Transformer is badly defined" << '\n'; continue; } occ::handle item; // to be provided ... ReadOwn(item); if (item.IsNull()) + { continue; + } DeclareAndCast(IFSelect_Transformer, trf, item); if (trf.IsNull()) { - sout << "Lineno." << thenl << " : A Transformer has not been Recognized" << std::endl; + sout << "Lineno." << thenl << " : A Transformer has not been Recognized" << '\n'; continue; } AddItem(trf, false); // active later @@ -757,12 +910,16 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 3) { - sout << "Lineno." << thenl << " : A Dispatch is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A Dispatch is badly defined" << '\n'; continue; } DeclareAndCast(IFSelect_Selection, input, ItemValue(3)); @@ -770,11 +927,13 @@ int IFSelect_SessionFile::ReadSession() occ::handle item; // to be provided ... ReadOwn(item); if (item.IsNull()) + { continue; + } DeclareAndCast(IFSelect_Dispatch, disp, item); if (disp.IsNull()) { - sout << "Lineno." << thenl << " : A Dispatch has not been Recognized" << std::endl; + sout << "Lineno." << thenl << " : A Dispatch has not been Recognized" << '\n'; continue; } AddItem(disp); @@ -787,21 +946,31 @@ int IFSelect_SessionFile::ReadSession() if (rubr) { if (!IsVoid(2)) + { thesess->SetFilePrefix(TextValue(2).ToCString()); + } if (!IsVoid(3)) + { thesess->SetDefaultFileRoot(TextValue(3).ToCString()); + } if (!IsVoid(4)) + { thesess->SetFileExtension(TextValue(4).ToCString()); + } } while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() != 2) { - sout << "Lineno." << thenl << " : A File Root is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A File Root is badly defined" << '\n'; continue; } DeclareAndCast(IFSelect_Dispatch, disp, ItemValue(1)); @@ -824,12 +993,16 @@ int IFSelect_SessionFile::ReadSession() while (rubr) { if (!ReadLine()) + { return 1; + } if (theline.Value(1).Value(1) == '!') + { break; // liste suivante + } if (theline.Length() < 3) { - sout << "Lineno." << thenl << " : A General Modifier is badly defined" << std::endl; + sout << "Lineno." << thenl << " : A General Modifier is badly defined" << '\n'; continue; } DeclareAndCast(IFSelect_GeneralModifier, modif, ItemValue(1)); @@ -837,14 +1010,18 @@ int IFSelect_SessionFile::ReadSession() DeclareAndCast(IFSelect_Dispatch, disp, ItemValue(3)); if (modif.IsNull()) { - sout << "Lineno." << thenl << " : A General Modifier has not been Recognized" << std::endl; + sout << "Lineno." << thenl << " : A General Modifier has not been Recognized" << '\n'; continue; } thesess->SetItemSelection(modif, input); if (!disp.IsNull()) + { thesess->SetAppliedModifier(modif, disp); + } else + { thesess->SetAppliedModifier(modif, thesess->ShareOut()); + } } } @@ -858,7 +1035,7 @@ int IFSelect_SessionFile::ReadEnd() if (theline.Length() != 2 || !theline.Value(1).IsEqual("!XSTEP") || !theline.Value(2).IsEqual("END")) { - sout << "End of File Incorrect, lineno" << thenl << std::endl; + sout << "End of File Incorrect, lineno" << thenl << '\n'; return 1; } return 0; @@ -867,12 +1044,16 @@ int IFSelect_SessionFile::ReadEnd() bool IFSelect_SessionFile::ReadLine() { if (thenl >= thelist.Length()) + { return false; + } thenl++; const char* ligne = thelist.Value(thenl).ToCString(); // Empty lines? if (ligne[0] == '\0') + { return ReadLine(); + } SplitLine(ligne); return true; } @@ -904,7 +1085,9 @@ void IFSelect_SessionFile::SplitLine(const char* const line) theline.Append(TCollection_AsciiString(mot)); } if (line[i] == '\0' || line[i] == '\n') + { break; + } } } thelastgen = 0; @@ -915,23 +1098,31 @@ bool IFSelect_SessionFile::ReadOwn(occ::handle& item) Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (theline.Length() < 2) + { return false; + } const TCollection_AsciiString& type = theline.Value(2); if (thelastgen < 2) + { thelastgen = 2; // mini : ident+type first - // thelastgen = theline.Length(); - // for (int i = theline.Length(); i > 0; i --) { - // if (theline.Value(i).Value(1) == ':') thelastgen = i - 1; - // } + } + // thelastgen = theline.Length(); + // for (int i = theline.Length(); i > 0; i --) { + // if (theline.Value(i).Value(1) == ':') thelastgen = i - 1; + // } occ::handle dumper = IFSelect_SessionDumper::First(); while (!dumper.IsNull()) { if (dumper->ReadOwn(*this, type, item)) + { break; + } dumper = dumper->Next(); } if (dumper.IsNull()) - sout << " -- Lineno." << thenl << " : an Item could not be read" << std::endl; + { + sout << " -- Lineno." << thenl << " : an Item could not be read" << '\n'; + } return (!dumper.IsNull()); // IsNull -> echec } @@ -944,15 +1135,22 @@ void IFSelect_SessionFile::AddItem(const occ::handle& item, if (!item.IsNull()) { if (name.Value(1) == '#') + { id = thesess->AddItem(item, active); + } else if (!thesess->NamedItem(name.ToCString()).IsNull()) + { id = thesess->AddItem(item, active); + } else + { id = thesess->AddNamedItem(name.ToCString(), item, active); + } } else - sout << "Lineno." << thenl << " -- Name : " << name << " : Item could not be defined" - << std::endl; + { + sout << "Lineno." << thenl << " -- Name : " << name << " : Item could not be defined" << '\n'; + } thenames.Bind(name, id); } @@ -978,7 +1176,9 @@ void IFSelect_SessionFile::NewItem(const int ident, const occ::handleDynamicType()->Name()); } else + { Sprintf(laligne, " %s %s", thesess->Name(par)->ToCString(), par->DynamicType()->Name()); + } WriteLine(laligne); } @@ -1001,12 +1201,16 @@ void IFSelect_SessionFile::SendItem(const occ::handle& par) int filenum = 0; int id = thesess->ItemIdent(par); if (id != 0) + { filenum = thenums->Value(id); + } if (filenum == 0) { if (!par.IsNull()) + { sout << "Lineno " << thenl << " -- Unknown Item : " - << " Type:" << par->DynamicType()->Name() << std::endl; // sout<DynamicType()->Name() << '\n'; // sout<& par) //// if (theownflag) WriteLine(" :"); //// else WriteLine(" "); if (filenum < 0) + { Sprintf(laligne, " :%s", thesess->Name(par)->ToCString()); + } else + { Sprintf(laligne, " #%d", filenum); + } WriteLine(laligne); } @@ -1044,7 +1252,9 @@ bool IFSelect_SessionFile::IsVoid(const int num) const { int nm = num + thelastgen; if (nm <= 0 || nm > theline.Length()) + { return true; + } const TCollection_AsciiString& term = theline.Value(nm); return (term.IsEqual("$") || term.IsEqual(":$")); } @@ -1053,14 +1263,22 @@ bool IFSelect_SessionFile::IsText(const int num) const { int nm = num + thelastgen; if (nm <= 0 || nm > theline.Length()) + { return false; + } const TCollection_AsciiString& term = theline.Value(nm); if (term.Value(1) == ':') + { return false; + } if (term.Value(1) == '#') + { return false; + } if (term.IsEqual("$")) + { return false; + } return true; } @@ -1074,14 +1292,22 @@ TCollection_AsciiString IFSelect_SessionFile::TextValue(const int num) const int nm = num + thelastgen; TCollection_AsciiString res; if (nm <= 0 || nm > theline.Length()) + { return res; + } res = theline.Value(nm); if (res.Value(res.Length()) == '"') + { res.Remove(res.Length()); + } if (res.Value(1) == ':') + { res.Remove(1); + } if (res.Value(1) == '"') + { res.Remove(1); + } return res; } @@ -1092,17 +1318,22 @@ occ::handle IFSelect_SessionFile::ItemValue(const int num) c occ::handle res; int nm = num + thelastgen; if (nm <= 0 || nm > theline.Length()) + { return res; + } int id; TCollection_AsciiString name = theline.Value(nm); if (name.Value(1) == ':') + { name.Remove(1); + } if (name.IsEqual("$")) + { return res; // item non-defini justement + } if (!thenames.Find(name, id)) { - sout << " -- Item Unknown in File : " << name << " lineno " << thenl << " param." << nm - << std::endl; + sout << " -- Item Unknown in File : " << name << " lineno " << thenl << " param." << nm << '\n'; id = 0; } return thesess->Item(id); diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionPilot.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionPilot.cxx index 47776ce96c..a2202837fb 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionPilot.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SessionPilot.cxx @@ -91,7 +91,9 @@ void IFSelect_SessionPilot::SetSession(const occ::handle& void IFSelect_SessionPilot::SetLibrary(const occ::handle& WL) { if (!thesession.IsNull()) + { thesession->SetLibrary(WL); + } } void IFSelect_SessionPilot::SetRecordMode(const bool mode) @@ -103,8 +105,10 @@ void IFSelect_SessionPilot::SetCommandLine(const TCollection_AsciiString& comman { int lc = command.Length(); if (lc > 200) - std::cout << " VERY LONG Command : " << lc << " characters :" << std::endl - << command.ToCString() << std::endl; + { + std::cout << " VERY LONG Command : " << lc << " characters :" << '\n' + << command.ToCString() << '\n'; + } thecommand = command; if (thecommand.Value(lc) <= ' ') { @@ -120,7 +124,9 @@ void IFSelect_SessionPilot::SetCommandLine(const TCollection_AsciiString& comman if (val <= ' ') { if (nc == 0) + { continue; + } if (thenbwords >= MAXWORDS) { unarg[nc] = val; @@ -138,10 +144,12 @@ void IFSelect_SessionPilot::SetCommandLine(const TCollection_AsciiString& comman continue; } if (nc == 0) + { thewordeb.SetValue(thenbwords, i); + } if (nc > MAXCARS) { - std::cout << "Arg." << thenbwords << " > " << MAXCARS << " car.s, tronque" << std::endl; + std::cout << "Arg." << thenbwords << " > " << MAXCARS << " car.s, tronque" << '\n'; continue; } unarg[nc] = val; @@ -205,9 +213,13 @@ const TCollection_AsciiString& IFSelect_SessionPilot::CommandLine() const const char* IFSelect_SessionPilot::CommandPart(const int numarg) const { if (numarg <= 0) + { return thecommand.ToCString(); + } if (numarg >= thenbwords) + { return ""; + } return &(thecommand.ToCString())[thewordeb(numarg) - 1]; } @@ -219,7 +231,9 @@ int IFSelect_SessionPilot::NbWords() const const TCollection_AsciiString& IFSelect_SessionPilot::Word(const int num) const { if (num < thenbwords) + { return thewords(num); + } return TCollection_AsciiString::EmptyString(); } @@ -231,7 +245,9 @@ const char* IFSelect_SessionPilot::Arg(const int num) const bool IFSelect_SessionPilot::RemoveWord(const int num) { if (num < 0 || num > thenbwords) + { return false; + } int i; // svv Jan11 2000 : porting on DEC for (i = num; i < thenbwords; i++) { @@ -252,7 +268,9 @@ bool IFSelect_SessionPilot::RemoveWord(const int num) for (i = 0; i < thenbwords; i++) { if (i > 0) + { thecommand.AssignCat(" "); + } thecommand.AssignCat(thewords(i)); } } @@ -297,49 +315,65 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::ReadScript(const char* const file) { fic = OSD_OpenFile(file, "r"); if (fic) + { lefic = 1; + } else { - std::cout << " ... Script File " << file << " not found" << std::endl; + std::cout << " ... Script File " << file << " not found" << '\n'; return IFSelect_RetFail; } - std::cout << " ... Reading Script File " << file << std::endl; + std::cout << " ... Reading Script File " << file << '\n'; } else + { fic = stdin; + } IFSelect_ReturnStatus stat = IFSelect_RetVoid; for (;;) { char ligne[100]; if (!lefic) + { std::cout << theprompt.ToCString(); + } ligne[0] = '\0'; if (fgets(ligne, 100, fic) == nullptr || feof(fic) != 0) { break; } if (ligne[0] == '\0') + { continue; + } // We interpret this command TCollection_AsciiString command(ligne); if (lefic) + { std::cout << file << ":" << command; // the return is in the line ... ! + } stat = Execute(command); if (stat == IFSelect_RetStop) + { break; + } if ((stat == IFSelect_RetError || stat == IFSelect_RetFail) && lefic) { - std::cout << " ... Error in Script File, abandon" << std::endl; + std::cout << " ... Error in Script File, abandon" << '\n'; break; } } if (!lefic) + { return IFSelect_RetStop; + } fclose(fic); - std::cout << "End of Reading Script File " << file << std::endl; + std::cout << "End of Reading Script File " << file << '\n'; if (stat == IFSelect_RetError || stat == IFSelect_RetFail) + { return stat; + } return IFSelect_RetVoid; // end file : unstack } @@ -349,9 +383,13 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Perform() { IFSelect_ReturnStatus stat = IFSelect_RetVoid; if (thenbwords == 0) + { return stat; + } if (thewords(0).Value(1) == '#') + { return stat; // comment + } theobjrec.Nullify(); // Is it a name ? @@ -370,7 +408,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Perform() int addws = thesession->AddItem(theobjrec); if (addws == 0) { - std::cout << "Could not add item to session, sorry" << std::endl; + std::cout << "Could not add item to session, sorry" << '\n'; return IFSelect_RetFail; } } @@ -378,22 +416,30 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Perform() if (stat == IFSelect_RetVoid || stat == IFSelect_RetDone) { if (therecord) + { thecomlist.Append(thecommand); + } } else if (stat == IFSelect_RetError) - std::cout << "Error in Command : " << thecommand << std::endl; + { + std::cout << "Error in Command : " << thecommand << '\n'; + } else if (stat == IFSelect_RetFail) - std::cout << "Execution Failure for : " << thecommand << std::endl; + { + std::cout << "Execution Failure for : " << thecommand << '\n'; + } return stat; } - std::cout << " Command : " << thewords(0) << " unknown" << std::endl; + std::cout << " Command : " << thewords(0) << " unknown" << '\n'; return IFSelect_RetError; // not recognized therefore incorrect } IFSelect_ReturnStatus IFSelect_SessionPilot::ExecuteAlias(const TCollection_AsciiString& alias) { if (alias.Length() > 0) + { thewords(0) = alias; + } return Perform(); } @@ -409,10 +455,14 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::ExecuteCounter( const IFSelect_PrintCount mode) { if (counter.IsNull()) + { return IFSelect_RetError; + } counter->Clear(); if (NbWords() <= numword) + { counter->AddModel(thesession->Model()); + } else { // we request a givelist @@ -420,7 +470,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::ExecuteCounter( thesession->GiveList(CommandPart(numword)); if (list.IsNull()) { - std::cout << "Nothing selected from : " << CommandPart(numword) << std::endl; + std::cout << "Nothing selected from : " << CommandPart(numword) << '\n'; return IFSelect_RetError; } counter->AddWithGraph(list, thesession->Graph()); @@ -434,7 +484,9 @@ int IFSelect_SessionPilot::Number(const char* const val) const { int num = thesession->NumberFromLabel(val); if (num < 0) - std::cout << " Label:" << val << " ->" << -num << " ent.s, refus" << std::endl; + { + std::cout << " Label:" << val << " ->" << -num << " ent.s, refus" << '\n'; + } return num; } @@ -456,7 +508,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int { case -1: // **** HELP-XSNEW modhelp = 1; - std::cout << " -- Commands candidate for xsnew --" << std::endl; + std::cout << " -- Commands candidate for xsnew --" << '\n'; // HELP : either complete (by default) or limited to xsnew [[fallthrough]]; case 0: { // **** HELP @@ -467,7 +519,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int list = IFSelect_Activator::Commands(modhelp); int nbcom = 0; int nb = list->Length(); - std::cout << " -- List of Available Commands --" << std::endl; + std::cout << " -- List of Available Commands --" << '\n'; for (int i = 1; i <= nb; i++) { const TCollection_AsciiString& uncom = list->Value(i); @@ -475,30 +527,39 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int nbcom++; if (nbcom > MAXCOMPERLINE) { - std::cout << std::endl; + std::cout << '\n'; nbcom = 1; } std::cout << " " << uncom; if (nbcom == MAXCOMPERLINE) + { continue; + } for (int j = loncom; j < LENGTHFORCOM; j++) + { std::cout << " "; + } } if (nbcom > 0) - std::cout << std::endl; + { + std::cout << '\n'; + } std::cout << "\nhelp * lists all commands with help on each\n" << "help lists the command(s) starting with " - << " with help on each" << std::endl; + << " with help on each" << '\n'; // A particular Help } else { if (thewords(1).IsEqual("*")) + { list = IFSelect_Activator::Commands(modhelp); - + } else + { list = IFSelect_Activator::Commands(modhelp, thewords(1).ToCString()); + } int nb = list->Length(); for (int i = 1; i <= nb; i++) @@ -508,13 +569,17 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int if (IFSelect_Activator::Select(list->Value(i).ToCString(), num, actor)) { if (IFSelect_Activator::Mode(list->Value(i).ToCString()) == 1) + { std::cout << "[xsnew name] "; - std::cout << list->Value(i) << " : " << actor->Help(num) << std::endl; + } + std::cout << list->Value(i) << " : " << actor->Help(num) << '\n'; } } if (nb == 0 && thenbwords > 1) + { std::cout << " Command " << Word(1) << " unknown. " - << " help (without command) lists all the commands" << std::endl; + << " help (without command) lists all the commands" << '\n'; + } } return IFSelect_RetVoid; } @@ -528,17 +593,17 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int { std::cout << "Give an option :\n" << "a : analyze a line r : toggle record mode\n" - << "l : list recorded c : clear f name : save in file of name" << std::endl; + << "l : list recorded c : clear f name : save in file of name" << '\n'; return IFSelect_RetVoid; } switch (arg1[0]) { case 'a': { // **** command analyse - std::cout << "Command n0 " << number << " : " << session->CommandLine() << std::endl; + std::cout << "Command n0 " << number << " : " << session->CommandLine() << '\n'; std::cout << "Nb Words : " << argc - 2 << " :\n"; for (int i = 2; i < argc; i++) { - std::cout << " Word." << i - 1 << " : " << session->Word(i) << std::endl; + std::cout << " Word." << i - 1 << " : " << session->Word(i) << '\n'; } break; } @@ -548,45 +613,55 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int case 'f': { if (argc < 3) { - std::cout << "Give file name" << std::endl; + std::cout << "Give file name" << '\n'; return IFSelect_RetError; } int nb = session->NbCommands(); if (nb == 0) { - std::cout << "No command recorded" << std::endl; + std::cout << "No command recorded" << '\n'; break; } - std::cout << "Nb Recorded Commands : " << nb << std::endl; + std::cout << "Nb Recorded Commands : " << nb << '\n'; std::ofstream fout(Word(2).ToCString(), std::ios::out); for (int i = 1; i <= nb; i++) - fout << session->Command(i) << std::endl; + { + fout << session->Command(i) << '\n'; + } break; } case 'l': { // **** command list if (session->RecordMode()) - std::cout << " -- Record Mode Active" << std::endl; + { + std::cout << " -- Record Mode Active" << '\n'; + } else - std::cout << " -- Record Mode Inactive" << std::endl; + { + std::cout << " -- Record Mode Inactive" << '\n'; + } int nb = session->NbCommands(); - std::cout << "Nb Recorded Commands : " << nb << " :" << std::endl; + std::cout << "Nb Recorded Commands : " << nb << " :" << '\n'; for (int i = 1; i <= nb; i++) { - std::cout << " " << i << " " << session->Command(i) << std::endl; + std::cout << " " << i << " " << session->Command(i) << '\n'; } break; } case 'r': { // **** command record bool mode = session->RecordMode(); if (mode) - std::cout << " -- Record Mode now Inactive" << std::endl; + { + std::cout << " -- Record Mode now Inactive" << '\n'; + } else - std::cout << " -- Record Mode now Active" << std::endl; + { + std::cout << " -- Record Mode now Active" << '\n'; + } session->SetRecordMode(!mode); break; } default: - std::cout << "Command control option not understood" << std::endl; + std::cout << "Command control option not understood" << '\n'; } return IFSelect_RetVoid; } @@ -594,7 +669,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int case 4: { // **** FILE if (argc < 2) { - std::cout << "Give file name" << std::endl; + std::cout << "Give file name" << '\n'; return IFSelect_RetError; } return session->ReadScript(TCollection_AsciiString(session->Word(1)).ToCString()); @@ -604,8 +679,8 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int case 5: { // **** XSTEP if (argc < 2) { - std::cout << "xstep : neutral prefix for any xstep-draw command" << std::endl - << "xstep command args equivalent to command args" << std::endl; + std::cout << "xstep : neutral prefix for any xstep-draw command" << '\n' + << "xstep command args equivalent to command args" << '\n'; return Do(2, this); } else @@ -617,8 +692,8 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int case 6: { // **** XSNEW(variable) if (argc < 3) { - std::cout << "xsnew varname command [args] creates an item" << std::endl - << " varname : name of item (must be a new name) in the session" << std::endl; + std::cout << "xsnew varname command [args] creates an item" << '\n' + << " varname : name of item (must be a new name) in the session" << '\n'; return Do(-1, this); } else @@ -629,7 +704,7 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int // The name must not be already taken ! if (thesession.IsNull()) { - std::cout << "Command with a Name and no Session defined !" << std::endl; + std::cout << "Command with a Name and no Session defined !" << '\n'; return IFSelect_RetFail; } ////// if (thesession->NameIdent(thewords(0).ToCString()) > 0) @@ -653,16 +728,18 @@ IFSelect_ReturnStatus IFSelect_SessionPilot::Do(const int theobjrec.Nullify(); if (addws == 0) { - std::cout << "Could not add named item:" << name << ", sorry" << std::endl; + std::cout << "Could not add named item:" << name << ", sorry" << '\n'; return IFSelect_RetFail; } } else - std::cout << "Remark : xsnew with name:" << name << " and no result" << std::endl; + { + std::cout << "Remark : xsnew with name:" << name << " and no result" << '\n'; + } return stat; } - std::cout << " Command : " << thewords(0) << " unknown" << std::endl; + std::cout << " Command : " << thewords(0) << " unknown" << '\n'; return IFSelect_RetError; // not recognized therefore incorrect } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOut.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOut.cxx index 486565eb33..aab2802d68 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOut.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOut.cxx @@ -33,7 +33,9 @@ void IFSelect_ShareOut::Clear(const bool onlydisp) thedisps.Clear(); ClearResult(!onlydisp); if (onlydisp) + { return; + } themodelmodifiers.Clear(); thefilemodifiers.Clear(); } @@ -60,7 +62,9 @@ void IFSelect_ShareOut::ClearResult(const bool alsoname) { thelastrun = 0; if (alsoname) + { thenbdefs = 0; + } } int IFSelect_ShareOut::LastRun() const @@ -84,10 +88,16 @@ int IFSelect_ShareOut::NbDispatches() const int IFSelect_ShareOut::DispatchRank(const occ::handle& disp) const { if (disp.IsNull()) + { return 0; + } for (int i = thedisps.Length(); i >= 1; i--) + { if (disp == thedisps.Value(i)) + { return i; + } + } return 0; } @@ -99,14 +109,18 @@ const occ::handle& IFSelect_ShareOut::Dispatch(const int num) void IFSelect_ShareOut::AddDispatch(const occ::handle& disp) { if (disp.IsNull()) + { return; + } thedisps.Append(disp); } bool IFSelect_ShareOut::RemoveDispatch(const int rank) { if (rank <= thelastrun || rank > thedisps.Length()) + { return false; + } thedisps.Remove(rank); return true; } @@ -119,7 +133,9 @@ void IFSelect_ShareOut::AddModifier(const occ::handle& { bool formodel = modifier->IsKind(STANDARD_TYPE(IFSelect_Modifier)); if (ModifierRank(modifier) == 0) + { AddModif(modifier, formodel, atnum); + } occ::handle nuldisp; modifier->SetDispatch(nuldisp); } @@ -130,7 +146,9 @@ void IFSelect_ShareOut::AddModifier(const occ::handle& { bool formodel = modifier->IsKind(STANDARD_TYPE(IFSelect_Modifier)); if (ModifierRank(modifier) == 0) + { AddModif(modifier, formodel, atnum); + } occ::handle disp = Dispatch(dispnum); modifier->SetDispatch(disp); } @@ -142,34 +160,50 @@ void IFSelect_ShareOut::AddModif(const occ::handle& mo if (formodel) { if (atnum > 0 && atnum <= themodelmodifiers.Length()) + { themodelmodifiers.InsertBefore(atnum, modifier); + } else + { themodelmodifiers.Append(modifier); + } } else { if (atnum > 0 && atnum <= thefilemodifiers.Length()) + { thefilemodifiers.InsertBefore(atnum, modifier); + } else + { thefilemodifiers.Append(modifier); + } } } int IFSelect_ShareOut::NbModifiers(const bool formodel) const { if (formodel) + { return themodelmodifiers.Length(); + } else + { return thefilemodifiers.Length(); + } } occ::handle IFSelect_ShareOut::GeneralModifier(const bool formodel, const int atnum) const { if (formodel) + { return themodelmodifiers.Value(atnum); + } else + { return thefilemodifiers.Value(atnum); + } } occ::handle IFSelect_ShareOut::ModelModifier(const int num) const @@ -184,14 +218,22 @@ int IFSelect_ShareOut::ModifierRank(const occ::handle& if (formodel) { for (i = themodelmodifiers.Length(); i >= 1; i--) + { if (modifier == themodelmodifiers.Value(i)) + { return i; + } + } } else { for (i = thefilemodifiers.Length(); i >= 1; i--) + { if (modifier == thefilemodifiers.Value(i)) + { return i; + } + } } return 0; } @@ -199,17 +241,23 @@ int IFSelect_ShareOut::ModifierRank(const occ::handle& bool IFSelect_ShareOut::RemoveModifier(const bool formodel, const int atnum) { if (atnum <= 0) + { return false; + } if (formodel) { if (atnum > themodelmodifiers.Length()) + { return false; + } themodelmodifiers.Remove(atnum); } else { if (atnum > thefilemodifiers.Length()) + { return false; + } thefilemodifiers.Remove(atnum); } return true; @@ -221,32 +269,48 @@ bool IFSelect_ShareOut::ChangeModifierRank(const bool formodel, const int before { int nb; if (before <= 0 || after <= 0) + { return false; + } if (before == after) + { return true; + } if (formodel) { nb = themodelmodifiers.Length(); if (before > nb || after > nb) + { return false; + } occ::handle bef = themodelmodifiers.Value(before); themodelmodifiers.Remove(before); if (after == nb) + { themodelmodifiers.Append(bef); + } else + { themodelmodifiers.InsertBefore(after, bef); + } } else { nb = thefilemodifiers.Length(); if (before > nb || after > nb) + { return false; + } occ::handle bef = thefilemodifiers.Value(before); thefilemodifiers.Remove(before); if (after == nb) + { thefilemodifiers.Append(bef); + } else + { thefilemodifiers.InsertBefore(after, bef); + } } return true; } @@ -259,9 +323,13 @@ bool IFSelect_ShareOut::SetRootName(const int const occ::handle& name) { if (num < 1 || num > thedisps.Length()) + { return false; + } if (RootNumber(name) != 0) + { return false; + } Dispatch(num)->SetRootName(name); return true; } @@ -269,7 +337,9 @@ bool IFSelect_ShareOut::SetRootName(const int bool IFSelect_ShareOut::HasRootName(const int num) const { if (num < 1 || num > thedisps.Length()) + { return false; + } return Dispatch(num)->HasRootName(); } @@ -277,26 +347,36 @@ occ::handle IFSelect_ShareOut::RootName(const int num) { occ::handle nulname; if (num < 1 || num > thedisps.Length()) + { return nulname; + } return Dispatch(num)->RootName(); } int IFSelect_ShareOut::RootNumber(const occ::handle& name) const { if (name.IsNull()) + { return 0; + } if (!thedefrt.IsNull()) { if (thedefrt->IsSameString(name)) + { return -1; + } } for (int i = 1; i <= thedisps.Length(); i++) { occ::handle root = thedisps.Value(i)->RootName(); if (root.IsNull()) + { continue; + } if (root->IsSameString(name)) + { return i; + } } return 0; } @@ -310,9 +390,13 @@ void IFSelect_ShareOut::SetPrefix(const occ::handle& p bool IFSelect_ShareOut::SetDefaultRootName(const occ::handle& defrt) { if (RootNumber(defrt) != 0) + { return false; + } if (thedefrt.IsNull() || !thedefrt->IsSameString(defrt)) + { thenbdefs = 0; + } thedefrt = defrt; return true; } @@ -326,21 +410,27 @@ void IFSelect_ShareOut::SetExtension(const occ::handle occ::handle IFSelect_ShareOut::Prefix() const { if (thepref.IsNull()) + { return new TCollection_HAsciiString(""); + } return thepref; } occ::handle IFSelect_ShareOut::DefaultRootName() const { if (thedefrt.IsNull()) + { return new TCollection_HAsciiString(""); + } return thedefrt; } occ::handle IFSelect_ShareOut::Extension() const { if (theext.IsNull()) + { return new TCollection_HAsciiString(""); + } return theext; } @@ -363,9 +453,13 @@ TCollection_AsciiString IFSelect_ShareOut::FileName(const int dnum, TCollection_AsciiString res; if (!thepref.IsNull()) + { res.AssignCat(thepref->ToCString()); + } if (!rot.IsNull()) + { res.AssignCat(rot->ToCString()); + } // Suffixe numerique if (sufnum) @@ -406,6 +500,8 @@ TCollection_AsciiString IFSelect_ShareOut::FileName(const int dnum, } if (!theext.IsNull()) + { res.AssignCat(theext->ToCString()); + } return res; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOutResult.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOutResult.cxx index 1377631f2b..4c6e2c21c5 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOutResult.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_ShareOutResult.cxx @@ -81,7 +81,9 @@ void IFSelect_ShareOutResult::Reset() void IFSelect_ShareOutResult::Evaluate() { if (theeval) + { return; // already done. if not OK, do Reset before + } Prepare(); theeval = true; } @@ -95,9 +97,13 @@ occ::handle IFSelect_ShareOutResult::Packets(const bool com { list->AddPacket(); if (complete) + { list->AddList(PacketContent().Content()); + } else + { list->AddList(PacketRoot().Content()); + } } return list; } @@ -125,16 +131,22 @@ void IFSelect_ShareOutResult::Prepare() for (i = first; i <= nb; i++) { if (!theshareout.IsNull()) + { disp = theshareout->Dispatch(i); + } if (disp->FinalSelection().IsNull()) + { continue; // Dispatch neutralise + } IFGraph_SubPartsIterator packs(thegraph, false); disp->Packets(thegraph, packs); for (packs.Start(); packs.More(); packs.Next()) { Interface_EntityIterator iter = packs.Entities(); if (iter.NbEntities() == 0) + { continue; + } thedispres.AddPart(); thedispres.GetFromIter(iter); // we register this packet A.ResetData(); @@ -148,7 +160,9 @@ void IFSelect_ShareOutResult::Prepare() for (i = thepacknum; i <= thedisplist.Length(); i++) { if (thedisplist.Value(i) != thedispnum) + { break; + } thenbindisp++; } } @@ -164,7 +178,9 @@ void IFSelect_ShareOutResult::Next() thepacknum++; int dispnum; if (thepacknum <= thedisplist.Length()) + { dispnum = thedisplist.Value(thepacknum); + } else { thenbindisp = 0; @@ -174,7 +190,9 @@ void IFSelect_ShareOutResult::Next() return; } if (thedispnum == dispnum) + { thepackdisp++; + } else { thedispnum = dispnum; @@ -183,11 +201,15 @@ void IFSelect_ShareOutResult::Next() for (int i = thepacknum; i <= thedisplist.Length(); i++) { if (thedisplist.Value(i) != thedispnum) + { break; + } thenbindisp++; } if (!theshareout.IsNull()) + { thedispatch = theshareout->Dispatch(thedispnum); + } } } @@ -205,11 +227,15 @@ void IFSelect_ShareOutResult::NextDispatch() for (int i = thepacknum; i <= thedisplist.Length(); i++) { if (thedisplist.Value(i) != thedispnum) + { break; + } thenbindisp++; } if (!theshareout.IsNull()) + { thedispatch = theshareout->Dispatch(thedispnum); + } return; } } @@ -245,7 +271,9 @@ Interface_EntityIterator IFSelect_ShareOutResult::PacketContent() Interface_Graph G(thegraph); // G.GetFromIter(thedispres.Entities(),0); for (iter.Start(); iter.More(); iter.Next()) + { G.GetFromEntity(iter.Value(), true); + } Interface_GraphContent GC(G); return GC.Result(); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignAncestor.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignAncestor.cxx index d1056942d3..19ad20d9bb 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignAncestor.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignAncestor.cxx @@ -34,9 +34,13 @@ bool IFSelect_SignAncestor::Matches(const occ::handle& ent, const bool /*exact*/) const { if (ent.IsNull()) + { return false; + } DeclareAndCast(Standard_Type, atype, ent); if (atype.IsNull()) + { atype = ent->DynamicType(); + } return atype->SubType(text.ToCString()); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCategory.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCategory.cxx index 0819847781..fd0953772e 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCategory.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCategory.cxx @@ -27,13 +27,17 @@ IFSelect_SignCategory::IFSelect_SignCategory() Interface_Category::Init(); // if not already done int i, nb = Interface_Category::NbCategories(); for (i = 1; i <= nb; i++) + { AddCase(Interface_Category::Name(i)); + } } const char* IFSelect_SignCategory::Value(const occ::handle& ent, const occ::handle& model) const { if (ent.IsNull() || model.IsNull()) + { return nulsign; + } return Interface_Category::Name(model->CategoryNumber(model->Number(ent))); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCounter.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCounter.cxx index 3a2cb26c8b..f3093da2b8 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCounter.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignCounter.cxx @@ -58,7 +58,9 @@ bool IFSelect_SignCounter::AddEntity(const occ::handle& if (themapstat && !ent.IsNull()) { if (themap.Contains(ent)) + { return false; + } themap.Add(ent); } AddSign(ent, model); @@ -71,9 +73,13 @@ void IFSelect_SignCounter::AddSign(const occ::handle& char nulsign[2]; nulsign[0] = '\0'; if (ent.IsNull() || thematcher.IsNull()) + { Add(ent, nulsign); // to count the Nulls + } else + { Add(ent, thematcher->Value(ent, model)); + } } void IFSelect_SignCounter::AddList( @@ -81,10 +87,14 @@ void IFSelect_SignCounter::AddList( const occ::handle& model) { if (list.IsNull()) + { return; + } int nb = list->Length(); for (int i = 1; i <= nb; i++) + { AddEntity(list->Value(i), model); + } } void IFSelect_SignCounter::AddWithGraph( @@ -97,14 +107,20 @@ void IFSelect_SignCounter::AddWithGraph( void IFSelect_SignCounter::AddModel(const occ::handle& model) { if (model.IsNull()) + { return; + } int nb = model->NbEntities(); // If we start from empty, we know that each entity is unique in the model bool mapstat = themapstat; if (themap.Extent() == 0) + { themapstat = false; + } for (int i = 1; i <= nb; i++) + { AddEntity(model->Value(i), model); + } themapstat = mapstat; } @@ -132,11 +148,17 @@ occ::handle IFSelect_SignCounter::Selection() const void IFSelect_SignCounter::SetSelMode(const int selmode) { if (selmode < 0) + { thenbcomp1 = thenbcomp2 = 0; + } else + { theselmode = selmode; + } if (selmode == 0) + { theselect.Nullify(); + } } int IFSelect_SignCounter::SelMode() const @@ -147,17 +169,23 @@ int IFSelect_SignCounter::SelMode() const bool IFSelect_SignCounter::ComputeSelected(const Interface_Graph& G, const bool forced) { if (theselmode < 2 || theselect.IsNull()) + { return false; + } bool afaire = forced; Interface_EntityIterator iter = theselect->RootResult(G); int nb1 = G.Size(); int nb2 = iter.NbEntities(); if (!afaire) + { afaire = (nb1 != thenbcomp1 || nb2 != thenbcomp2); + } thenbcomp1 = nb1; thenbcomp2 = nb2; if (afaire) + { AddWithGraph(iter.Content(), G); + } return true; } @@ -167,7 +195,9 @@ occ::handle IFSelect_SignCounter::Sign( { occ::handle res; if (ent.IsNull() || thematcher.IsNull()) + { return res; + } res = new TCollection_HAsciiString(thematcher->Value(ent, model)); return res; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignMultiple.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignMultiple.cxx index b2b4b21a29..f1898c95ab 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignMultiple.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignMultiple.cxx @@ -31,7 +31,9 @@ void IFSelect_SignMultiple::Add(const occ::handle& subsign, const bool maxi) { if (subsign.IsNull()) + { return; + } thesubs.Append(subsign); thetabs.Append(maxi ? -tabul : tabul); } @@ -46,7 +48,9 @@ const char* IFSelect_SignMultiple::Value(const occ::handle& int tabul = thetabs.Value(i); bool maxi = (tabul < 0); if (maxi) + { tabul = -tabul; + } occ::handle sign = occ::down_cast(thesubs.Value(i)); const char* val = sign->Value(ent, model); TCollection_AsciiString str(val); @@ -69,13 +73,17 @@ bool IFSelect_SignMultiple::Matches(const occ::handle& const bool exact) const { if (exact) + { return IFSelect_Signature::Matches(ent, model, text, exact); + } int i, nb = thesubs.Length(); for (i = 1; i <= nb; i++) { occ::handle sign = occ::down_cast(thesubs.Value(i)); if (sign->Matches(ent, model, text, exact)) + { return true; + } } return false; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignType.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignType.cxx index 6ecf2248c4..31063b9dfa 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignType.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignType.cxx @@ -31,17 +31,25 @@ const char* IFSelect_SignType::Value(const occ::handle& ent, const occ::handle& /*model*/) const { if (ent.IsNull()) + { return nulsign; + } DeclareAndCast(Standard_Type, atype, ent); if (atype.IsNull()) + { atype = ent->DynamicType(); + } const char* tn = atype->Name(); if (!thenopk) + { return tn; + } for (int i = 0; tn[i] != '\0'; i++) { if (tn[i] == '_') + { return &tn[i + 1]; + } } return tn; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignValidity.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignValidity.cxx index 79399de9b7..be0d75fde7 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignValidity.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignValidity.cxx @@ -41,27 +41,43 @@ const char* IFSelect_SignValidity::CVal(const occ::handle& const occ::handle& model) { if (ent.IsNull() || model.IsNull()) + { return nulsign; + } int num = model->Number(ent); int cas = 0; if (model->IsUnknownEntity(num)) + { return "UNKNOWN"; + } if (model->IsRedefinedContent(num)) + { return "UNLOADED"; + } const occ::handle ch1 = model->Check(num, true); const occ::handle ch2 = model->Check(num, false); if (ch1->NbFails() > 0) + { return "Load-Error"; + } else if (ch1->NbWarnings() > 0) + { cas = 1; + } if (ch2->NbFails() > 0) + { return "Data-Error"; + } else if (cas == 1) + { return "Load-Warning"; + } else if (ch2->NbWarnings() > 0) + { return "Data-Warning"; + } return "OK"; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Signature.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Signature.cxx index 1f1d4561b3..020c7d80e8 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_Signature.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_Signature.cxx @@ -53,7 +53,9 @@ bool IFSelect_Signature::IsIntCase(bool& hasmin, int& valmin, bool& hasmax, int& hasmin = hasmax = false; valmin = valmax = 0; if (!thecasi[0]) + { return false; + } if (thecasi[0] & 2) { hasmin = true; @@ -70,7 +72,9 @@ bool IFSelect_Signature::IsIntCase(bool& hasmin, int& valmin, bool& hasmax, int& void IFSelect_Signature::AddCase(const char* const acase) { if (thecasl.IsNull()) + { thecasl = new NCollection_HSequence(); + } TCollection_AsciiString scase(acase); thecasl->Append(scase); } @@ -106,7 +110,9 @@ bool IFSelect_Signature::MatchValue(const char* const val, const bool exact) { if (exact) + { return text.IsEqual(val); + } // NB: no regexp char cardeb = text.Value(1); int ln, lnt, i, j; @@ -127,7 +133,9 @@ bool IFSelect_Signature::MatchValue(const char* const val, } } if (res) + { return res; + } } } return false; diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignatureList.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignatureList.cxx index 91fa2688f5..d4d2d985c6 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignatureList.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_SignatureList.cxx @@ -65,16 +65,22 @@ void IFSelect_SignatureList::Add(const occ::handle& ent, con } if (thedicount.Contains(sign)) + { thedicount.ChangeFromKey(sign)++; + } else + { thedicount.Add(sign, 1); + } if (thelistat) { occ::handle>> alist; if (thediclist.Contains(sign)) + { alist = occ::down_cast>>( thediclist.FindFromKey(sign)); + } else { alist = new NCollection_HSequence>(); @@ -101,7 +107,9 @@ void IFSelect_SignatureList::Init( thediclist = list; thenbnuls = nbnuls; if (thediclist.IsEmpty()) + { thelistat = false; + } } occ::handle>> IFSelect_SignatureList:: @@ -113,7 +121,9 @@ occ::handle>> IFSele for (; iter.More(); iter.Next()) { if (!iter.Key().StartsWith(root)) + { continue; + } occ::handle sign = new TCollection_HAsciiString(iter.Key()); list->Append(sign); @@ -144,11 +154,17 @@ occ::handle>> IFSelect_Sig occ::handle>> list; occ::handle aTList; if (!thelistat) + { return list; + } if (thediclist.FindFromKey(sign, aTList)) + { list = occ::down_cast>>(aTList); + } else + { list = new NCollection_HSequence>(); + } return list; } @@ -166,17 +182,19 @@ void IFSelect_SignatureList::PrintCount(Standard_OStream& S) const { int nbtot = 0, nbsign = 0; NCollection_IndexedDataMap::Iterator iter(thedicount); - S << " Count " << thename->ToCString() << "\n ----- -----------" << std::endl; + S << " Count " << thename->ToCString() << "\n ----- -----------" << '\n'; for (; iter.More(); iter.Next()) { int val = iter.Value(); - S << Interface_MSG::Blanks(val, 6) << val << " " << iter.Key() << std::endl; + S << Interface_MSG::Blanks(val, 6) << val << " " << iter.Key() << '\n'; nbtot += val; nbsign++; } if (thenbnuls > 0) - S << thename->ToCString() << " Nul : " << thenbnuls << std::endl; - S << " Nb Total:" << nbtot << " for " << nbsign << " items" << std::endl; + { + S << thename->ToCString() << " Nul : " << thenbnuls << '\n'; + } + S << " Nb Total:" << nbtot << " for " << nbsign << " items" << '\n'; } void IFSelect_SignatureList::PrintList(Standard_OStream& S, @@ -184,7 +202,9 @@ void IFSelect_SignatureList::PrintList(Standard_OStream& const IFSelect_PrintCount mod) const { if (mod == IFSelect_ItemsByEntity) + { return; + } if (mod == IFSelect_CountByItem) { PrintCount(S); @@ -197,7 +217,7 @@ void IFSelect_SignatureList::PrintList(Standard_OStream& } if (!HasEntities()) { - S << " SignatureList " << Name() << " : PrintList, list not available" << std::endl; + S << " SignatureList " << Name() << " : PrintList, list not available" << '\n'; PrintCount(S); return; } @@ -207,24 +227,28 @@ void IFSelect_SignatureList::PrintList(Standard_OStream& for (; iter.More(); iter.Next()) { DeclareAndCast(NCollection_HSequence>, list, iter.Value()); - S << Name() << " : " << iter.Key() << std::endl; + S << Name() << " : " << iter.Key() << '\n'; if (list.IsNull()) { - S << " - (empty list)" << std::endl; + S << " - (empty list)" << '\n'; continue; } int nb = list->Length(); S << " - Nb: " << nb << " : "; int nc = nb; if (nb > 5 && mod == IFSelect_ShortByItem) + { nc = 5; + } for (int i = 1; i <= nc; i++) { if (list->Value(i).IsNull()) { S << " 0"; if (mod == IFSelect_EntitiesByItem) + { S << ":(Global)"; + } continue; } int num = model->Number(list->Value(i)); @@ -241,18 +265,20 @@ void IFSelect_SignatureList::PrintList(Standard_OStream& } } if (nc < nb) + { S << " .. etc"; - S << std::endl; + } + S << '\n'; nbtot += nb; nbsign++; } - S << " Nb Total:" << nbtot << " for " << nbsign << " items" << std::endl; + S << " Nb Total:" << nbtot << " for " << nbsign << " items" << '\n'; } void IFSelect_SignatureList::PrintSum(Standard_OStream& S) const { NCollection_IndexedDataMap::Iterator iter(thedicount); - S << " Summary " << thename->ToCString() << "\n ----- -----------" << std::endl; + S << " Summary " << thename->ToCString() << "\n ----- -----------" << '\n'; int nbtot = 0, nbsign = 0, maxent = 0, nbval = 0, nbve = 0, minval = 0, maxval = 0, totval = 0; for (; iter.More(); iter.Next()) { @@ -260,7 +286,9 @@ void IFSelect_SignatureList::PrintSum(Standard_OStream& S) const nbtot += nbent; nbsign++; if (nbent > maxent) + { maxent = nbent; + } const TCollection_AsciiString& name = iter.Key(); // if (!name.IsIntegerValue()) continue; not very reliable int ic, nc = name.Length(); @@ -269,40 +297,50 @@ void IFSelect_SignatureList::PrintSum(Standard_OStream& S) const { char unc = name.Value(ic); if (ic == 1 && (unc == ' ' || unc == '+' || unc == '-')) + { continue; + } if (unc >= '0' && unc <= '9') + { continue; + } iaint = false; break; } if (!iaint) + { continue; + } int val = name.IntegerValue(); if (nbval == 0) { minval = maxval = val; } if (minval > val) + { minval = val; + } if (maxval < val) + { maxval = val; + } nbval++; nbve += nbent; totval += (val * nbent); } - S << " Nb Total:" << nbtot << " for " << nbsign << " items" << std::endl; - S << " Highest count of entities : " << maxent << " on one item" << std::endl; + S << " Nb Total:" << nbtot << " for " << nbsign << " items" << '\n'; + S << " Highest count of entities : " << maxent << " on one item" << '\n'; if (nbval > 0) { - S << " Summary on Integer Values" << std::endl; - S << " Nb Integer Items : " << nbval << std::endl; - S << " For Nb Entities : " << nbve << std::endl; - S << " Cumulated Values : " << totval << std::endl; - S << " Maximum Value : " << maxval << std::endl; + S << " Summary on Integer Values" << '\n'; + S << " Nb Integer Items : " << nbval << '\n'; + S << " For Nb Entities : " << nbve << '\n'; + S << " Cumulated Values : " << totval << '\n'; + S << " Maximum Value : " << maxval << '\n'; int avg1, avg2; avg1 = totval / nbve; avg2 = ((totval - (avg1 * nbve)) * 10) / nbve; - S << " Average Value : " << avg1 << " " << avg2 << "/10" << std::endl; - S << " Minimum Value : " << minval << std::endl; + S << " Average Value : " << avg1 << " " << avg2 << "/10" << '\n'; + S << " Minimum Value : " << minval << '\n'; } } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_TransformStandard.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_TransformStandard.cxx index f1eb510d97..8a85dc345e 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_TransformStandard.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_TransformStandard.cxx @@ -73,8 +73,12 @@ occ::handle IFSelect_TransformStandard::Modifier(const int nu int IFSelect_TransformStandard::ModifierRank(const occ::handle& modif) const { for (int i = themodifs.Length(); i >= 1; i--) + { if (modif == themodifs.Value(i)) + { return i; + } + } return 0; } @@ -82,11 +86,17 @@ bool IFSelect_TransformStandard::AddModifier(const occ::handle themodifs.Length()) + { return false; + } if (atnum == 0) + { themodifs.Append(modif); + } else + { themodifs.InsertBefore(atnum, modif); + } return true; } @@ -99,7 +109,9 @@ bool IFSelect_TransformStandard::RemoveModifier(const occ::handle themodifs.Length()) + { return false; + } themodifs.Remove(num); return true; } @@ -163,7 +175,9 @@ occ::handle IFSelect_TransformStandard::OnTheSpot( { int nb = G.Size(); for (int i = 1; i <= nb; i++) + { TC.Bind(G.Entity(i), G.Entity(i)); + } return G.Model(); } @@ -190,7 +204,9 @@ bool IFSelect_TransformStandard::ApplyModifiers(const Interface_Graph& { occ::handle unmod = Modifier(i); if (unmod->MayChangeGraph()) + { chg = true; + } // Apply this Modifier (nb : the Dispatch, we don't care about it) // First, the Selection @@ -200,14 +216,18 @@ bool IFSelect_TransformStandard::ApplyModifiers(const Interface_Graph& occ::handle sel = thesel; if (sel.IsNull()) + { sel = unmod->Selection(); + } if (!sel.IsNull()) { Interface_EntityIterator entiter = sel->UniqueResult(G); ctx.Select(entiter); } if (ctx.IsForNone()) + { continue; + } unmod->Perform(ctx, newmod, protocol, TC); // Error Reporting @@ -217,12 +237,12 @@ bool IFSelect_TransformStandard::ApplyModifiers(const Interface_Graph& { checks.Merge(checklist); sout << "IFSelect_TransformStandard : Messages from Modifier n0 " << i << " of " << nb - << std::endl; + << '\n'; checklist.Print(sout, newmod, false); } if (!checklist.IsEmpty(true)) { - sout << " -- Abandon TransformStandard --" << std::endl; + sout << " -- Abandon TransformStandard --" << '\n'; res = false; break; } @@ -230,7 +250,9 @@ bool IFSelect_TransformStandard::ApplyModifiers(const Interface_Graph& // Model not modified and Graph not modified: say it if (newmod == original && !chg) + { newmod.Nullify(); + } return res; } @@ -238,7 +260,9 @@ bool IFSelect_TransformStandard::Updated(const occ::handle& occ::handle& entto) const { if (themap.IsNull()) + { return false; + } return themap->Search(entfrom, entto); } @@ -247,16 +271,26 @@ TCollection_AsciiString IFSelect_TransformStandard::Label() const char lab[30]; TCollection_AsciiString labl(""); if (CopyOption()) + { labl.AssignCat("Standard Copy"); + } else + { labl.AssignCat("On the spot Edition"); + } int nb = NbModifiers(); if (nb == 0) + { Sprintf(lab, " (no Modifier)"); + } if (nb == 1) + { Sprintf(lab, " - %s", Modifier(1)->Label().ToCString()); + } if (nb > 1) + { Sprintf(lab, " - %d Modifiers", nb); + } labl.AssignCat(lab); return labl; } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkLibrary.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkLibrary.cxx index c866ae13f2..f41370822e 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkLibrary.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkLibrary.cxx @@ -35,7 +35,9 @@ bool IFSelect_WorkLibrary::CopyModel(const occ::handle Interface_CopyTool& TC) const { for (list.Start(); list.More(); list.Next()) + { TC.TransferEntity(list.Value()); + } TC.FillModel(newmodel); @@ -48,9 +50,13 @@ void IFSelect_WorkLibrary::DumpEntity(const occ::handle= 0) + { thelevhlp = new NCollection_HArray1>(0, max); + } } void IFSelect_WorkLibrary::DumpLevels(int& def, int& max) const @@ -70,15 +78,21 @@ void IFSelect_WorkLibrary::DumpLevels(int& def, int& max) const max = -1; } else + { max = thelevhlp->Upper(); + } } void IFSelect_WorkLibrary::SetDumpHelp(const int level, const char* const help) { if (thelevhlp.IsNull()) + { return; + } if (level < 0 || level > thelevhlp->Upper()) + { return; + } occ::handle str = new TCollection_HAsciiString(help); thelevhlp->SetValue(level, str); } @@ -86,12 +100,18 @@ void IFSelect_WorkLibrary::SetDumpHelp(const int level, const char* const help) const char* IFSelect_WorkLibrary::DumpHelp(const int level) const { if (thelevhlp.IsNull()) + { return ""; + } if (level < 0 || level > thelevhlp->Upper()) + { return ""; + } occ::handle str = thelevhlp->Value(level); if (str.IsNull()) + { return ""; + } return str->ToCString(); } diff --git a/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkSession.cxx b/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkSession.cxx index eec2420f91..6e34bf5e23 100644 --- a/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkSession.cxx +++ b/src/DataExchange/TKXSBase/IFSelect/IFSelect_WorkSession.cxx @@ -113,9 +113,13 @@ void IFSelect_WorkSession::SetSignType(const occ::handle& si { thegtool->SetSignType(signtype); if (signtype.IsNull()) + { thenames.UnBind("xst-sign-type"); + } else + { thenames.Bind("xst-sign-type", signtype); + } } //================================================================================================= @@ -140,10 +144,14 @@ void IFSelect_WorkSession::SetModel(const occ::handle& const bool clearpointed) { if (myModel != model) + { theloaded.Clear(); + } myModel = model; if (!thegtool.IsNull()) + { thegtool->ClearEntities(); // smh#14 FRA62479 + } myModel->SetGTool(thegtool); thegraph.Nullify(); @@ -153,7 +161,9 @@ void IFSelect_WorkSession::SetModel(const occ::handle& // UPDATE of SelectPointed I.E. clear their content if (clearpointed) + { ClearData(4); + } ClearData(0); } @@ -162,9 +172,13 @@ void IFSelect_WorkSession::SetModel(const occ::handle& IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile(const char* const filename) { if (thelibrary.IsNull()) + { return IFSelect_RetVoid; + } if (theprotocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle model; IFSelect_ReturnStatus status = IFSelect_RetVoid; try @@ -172,24 +186,34 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile(const char* const filename) OCC_CATCH_SIGNALS int stat = thelibrary->ReadFile(filename, model, theprotocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** ReadFile Interruption by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } if (model.IsNull()) + { return IFSelect_RetVoid; + } SetModel(model); SetLoadedFile(filename); return status; @@ -201,9 +225,13 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadStream(const char* const theName std::istream& theIStream) { if (thelibrary.IsNull()) + { return IFSelect_RetVoid; + } if (theprotocol.IsNull()) + { return IFSelect_RetVoid; + } occ::handle model; IFSelect_ReturnStatus status = IFSelect_RetVoid; try @@ -211,24 +239,34 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadStream(const char* const theName OCC_CATCH_SIGNALS int stat = thelibrary->ReadStream(theName, theIStream, model, theprotocol); if (stat == 0) + { status = IFSelect_RetDone; + } else if (stat < 0) + { status = IFSelect_RetError; + } else + { status = IFSelect_RetFail; + } } catch (Standard_Failure const& anException) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** ReadFile Interruption by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; status = IFSelect_RetFail; } if (status != IFSelect_RetDone) + { return status; + } if (model.IsNull()) + { return IFSelect_RetVoid; + } SetModel(model); SetLoadedFile(theName); return status; @@ -247,9 +285,13 @@ occ::handle IFSelect_WorkSession::StartingEntity(const int n { occ::handle res; // Null by default if (myModel.IsNull()) + { return res; + } if (num < 1 || num > myModel->NbEntities()) + { return res; + } return myModel->Value(num); } @@ -266,8 +308,10 @@ int IFSelect_WorkSession::NumberFromLabel(const char* const val, const int after { int i, cnt = 0, num = atoi(val); if (num > 0 || myModel.IsNull()) + { return num; // a direct n0 : won ! - // Otherwise, consider it as a label; to be treated in CaseNonSensitive ... + } + // Otherwise, consider it as a label; to be treated in CaseNonSensitive ... if (num > myModel->NbEntities()) { num = 0; @@ -280,10 +324,14 @@ int IFSelect_WorkSession::NumberFromLabel(const char* const val, const int after { cnt++; if (num <= 0) + { num = i; + } } if (cnt == 1) + { return num; + } num = -num; return num; @@ -295,9 +343,13 @@ occ::handle IFSelect_WorkSession::EntityLabel( const occ::handle& ent) const { if (myModel.IsNull() || ent.IsNull()) + { return nullptr; + } if (!myModel->Contains(ent)) + { return nullptr; + } return myModel->StringLabel(ent); } @@ -307,13 +359,17 @@ occ::handle IFSelect_WorkSession::EntityName( const occ::handle& ent) const { if (myModel.IsNull() || ent.IsNull()) + { return nullptr; + } Interface_ShareTool sht(thegraph->Graph()); int CN; occ::handle module; if (!thegtool->Select(ent, module, CN)) + { return nullptr; + } return module->Name(CN, ent, sht); } @@ -378,7 +434,9 @@ void IFSelect_WorkSession::ClearData(const int mode) { DeclareAndCast(IFSelect_SelectPointed, sp, Item(list->Value(i))); if (!sp.IsNull()) + { sp->Clear(); + } } list = ItemIdents(STANDARD_TYPE(IFSelect_SignatureList)); nb = list->Length(); @@ -386,10 +444,14 @@ void IFSelect_WorkSession::ClearData(const int mode) { DeclareAndCast(IFSelect_SignatureList, sl, Item(list->Value(i))); if (!sl.IsNull()) + { sl->Clear(); + } DeclareAndCast(IFSelect_SignCounter, sc, sl); if (!sc.IsNull()) + { sc->SetSelMode(-1); + } } list = ItemIdents(STANDARD_TYPE(IFSelect_EditForm)); nb = list->Length(); @@ -412,19 +474,29 @@ void IFSelect_WorkSession::ClearData(const int mode) bool IFSelect_WorkSession::ComputeGraph(const bool enforce) { if (theprotocol.IsNull()) + { return false; + } if (myModel.IsNull()) + { return false; + } if (enforce) + { thegraph.Nullify(); + } if (!thegraph.IsNull()) { if (myModel->NbEntities() == thegraph->Graph().Size()) + { return true; + } thegraph.Nullify(); } if (myModel->NbEntities() == 0) + { return false; + } // We must calculate the graph for good thegraph = new Interface_HGraph(myModel, themodelstat); int nb = myModel->NbEntities(); @@ -432,7 +504,9 @@ bool IFSelect_WorkSession::ComputeGraph(const bool enforce) { int i; // svv #1 for (i = 1; i <= nb; i++) + { thegraph->CGraph().SetStatus(i, 0); + } Interface_BitMap& bm = thegraph->CGraph().CBitMap(); bm.AddFlag(); bm.SetFlagName(Flag_Incorrect, "Incorrect"); @@ -446,7 +520,9 @@ bool IFSelect_WorkSession::ComputeGraph(const bool enforce) Interface_ShareTool sht(thegraph); int i = 1; for (; i <= nb; i++) + { myModel->SetCategoryNumber(i, categ.CatNum(myModel->Value(i), sht)); + } } return true; @@ -466,7 +542,9 @@ const Interface_Graph& IFSelect_WorkSession::Graph() { ComputeGraph(); if (thegraph.IsNull()) + { throw Standard_DomainError("IFSelect WorkSession : Graph not available"); + } return thegraph->Graph(); } @@ -477,9 +555,13 @@ occ::handle>> IFSelect_Wor { occ::handle>> list; if (!ComputeGraph()) + { return list; + } if (StartingNumber(ent) == 0) + { return list; + } return thegraph->Graph().Shareds(ent).Content(); } @@ -490,9 +572,13 @@ occ::handle>> IFSelect_Wor { occ::handle>> list; if (!ComputeGraph()) + { return list; + } if (StartingNumber(ent) == 0) + { return list; + } return thegraph->Graph().Sharings(ent).Content(); } @@ -501,15 +587,25 @@ occ::handle>> IFSelect_Wor bool IFSelect_WorkSession::IsLoaded() const { if (theprotocol.IsNull()) + { return false; + } if (myModel.IsNull()) + { return false; + } if (myModel->NbEntities() == 0) + { return false; + } if (thegraph.IsNull()) + { return false; + } if (myModel->NbEntities() == thegraph->Graph().Size()) + { return true; + } return false; } @@ -518,11 +614,17 @@ bool IFSelect_WorkSession::IsLoaded() const bool IFSelect_WorkSession::ComputeCheck(const bool enforce) { if (enforce) + { thecheckdone = false; + } if (thecheckdone) + { return true; + } if (!IsLoaded()) + { return false; + } Interface_Graph& CG = thegraph->CGraph(); Interface_CheckTool cht(thegraph); @@ -538,14 +640,22 @@ bool IFSelect_WorkSession::ComputeCheck(const bool enforce) { const occ::handle& chk = checklist.Value(); if (!chk->HasFailed()) + { continue; + } num = checklist.Number(); if (num > 0 && num <= nb) + { BM.SetTrue(num, Flag_Incorrect); + } } for (num = 1; num <= nb; num++) + { if (myModel->IsErrorEntity(num)) + { BM.SetTrue(num, Flag_Incorrect); + } + } } return true; } @@ -580,15 +690,23 @@ Interface_CheckIterator IFSelect_WorkSession::CheckOne(const occ::handleNumber(ent); + } occ::handle ach = myModel->Check(num, true); if (complete) + { ach->GetMessages(myModel->Check(num, false)); + } if (num > 0) + { ach->SetEntity(ent); + } checks.Add(ach, num); checks.SetName("Data Check (One Entity)"); return checks; @@ -610,9 +728,13 @@ occ::handle IFSelect_WorkSession::Item(const int id) const { occ::handle res; if (id <= 0 || id > MaxIdent()) + { return res; + } if (theitems.FindFromIndex(id).IsNull()) + { return res; + } return theitems.FindKey(id); } @@ -621,12 +743,18 @@ occ::handle IFSelect_WorkSession::Item(const int id) const int IFSelect_WorkSession::ItemIdent(const occ::handle& item) const { if (item.IsNull()) + { return 0; + } int id = theitems.FindIndex(item); if (id == 0) + { return 0; + } if (theitems.FindFromIndex(id).IsNull()) + { return 0; + } return id; } @@ -636,14 +764,18 @@ occ::handle IFSelect_WorkSession::NamedItem(const char* cons { occ::handle res; if (name[0] == '\0') + { return res; + } if (name[0] == '#') { // #nnn : not a name but an id number int id = atoi(&name[1]); return Item(id); } if (!thenames.Find(name, res)) + { res.Nullify(); + } return res; } @@ -654,7 +786,9 @@ occ::handle IFSelect_WorkSession::NamedItem( { occ::handle res; if (!name.IsNull()) + { res = NamedItem(name->ToCString()); + } return res; } @@ -664,14 +798,18 @@ int IFSelect_WorkSession::NameIdent(const char* const name) const { occ::handle res; if (name[0] == '\0') + { return 0; + } if (name[0] == '#') { // #nnn : not a name but an id number int id = atoi(&name[1]); return id; } if (!thenames.Find(name, res)) + { return 0; + } return ItemIdent(res); } @@ -680,13 +818,19 @@ int IFSelect_WorkSession::NameIdent(const char* const name) const bool IFSelect_WorkSession::HasName(const occ::handle& item) const { if (item.IsNull()) + { return false; + } int id = theitems.FindIndex(item); if (id == 0) + { return false; + } occ::handle att = theitems.FindFromIndex(id); if (att.IsNull()) + { return false; + } return att->IsKind(STANDARD_TYPE(TCollection_HAsciiString)); } @@ -697,10 +841,14 @@ occ::handle IFSelect_WorkSession::Name( { occ::handle res; if (item.IsNull()) + { return res; + } int id = theitems.FindIndex(item); if (id == 0) + { return res; // Null + } occ::handle att = theitems.FindFromIndex(id); return GetCasted(TCollection_HAsciiString, att); } @@ -710,20 +858,28 @@ occ::handle IFSelect_WorkSession::Name( int IFSelect_WorkSession::AddItem(const occ::handle& item, const bool active) { if (item.IsNull()) + { return 0; + } int id = theitems.FindIndex(item); if (id > 0) { occ::handle& att = theitems.ChangeFromIndex(id); if (att.IsNull()) + { att = item; + } } else + { id = theitems.Add(item, item); + } // Special cases : Dispatch,Modifier if (active) + { SetActive(item, true); + } return id; } @@ -734,20 +890,28 @@ int IFSelect_WorkSession::AddNamedItem(const char* const na const bool active) { if (item.IsNull()) + { return 0; + } if (name[0] == '#' || name[0] == '!') + { return 0; + } // #nnn : not a name but a number. !... : reserved (forbidden for a name) // name already taken : we overwrite the old value if (name[0] != '\0') + { thenames.Bind(name, item); + } int id = theitems.FindIndex(item); if (id > 0) { occ::handle& att = theitems.ChangeFromIndex(id); if (att.IsNull()) + { att = item; + } if (name[0] != '\0') { // if (!att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) overwriting allowed ! @@ -755,13 +919,19 @@ int IFSelect_WorkSession::AddNamedItem(const char* const na } } else if (name[0] != '\0') + { id = theitems.Add(item, new TCollection_HAsciiString(name)); + } else + { id = theitems.Add(item, item); + } // Special cases : Dispatch,Modifier if (active) + { SetActive(item, true); + } return id; } @@ -774,18 +944,24 @@ bool IFSelect_WorkSession::SetActive(const occ::handle& item DeclareAndCast(IFSelect_Dispatch, disp, item); int num = theshareout->DispatchRank(disp); if (num > theshareout->NbDispatches()) + { return false; + } if (mode) { if (num > 0) + { return false; + } theshareout->AddDispatch(disp); return true; } else { if (num <= theshareout->LastRun()) + { return false; + } theshareout->RemoveDispatch(num); SetFileRoot(disp, ""); // if onlynamed : also cleans ShareOut return true; @@ -801,9 +977,13 @@ bool IFSelect_WorkSession::RemoveNamedItem(const char* const name) { occ::handle item = NamedItem(name); if (item.IsNull()) + { return false; + } if (!RemoveItem(item)) + { return false; // which takes care of everything + } return true; } @@ -813,7 +993,9 @@ bool IFSelect_WorkSession::RemoveName(const char* const name) { occ::handle item = NamedItem(name); if (item.IsNull()) + { return false; + } theitems.Add(item, item); // remains but without name return thenames.UnBind(name); } @@ -823,13 +1005,19 @@ bool IFSelect_WorkSession::RemoveName(const char* const name) bool IFSelect_WorkSession::RemoveItem(const occ::handle& item) { if (item.IsNull()) + { return false; + } int id = theitems.FindIndex(item); if (id == 0) + { return false; + } occ::handle& att = theitems.ChangeFromIndex(id); if (att.IsNull()) + { return false; // already canceled + } // Special cases : Dispatch,Modifier theshareout->RemoveItem(item); @@ -838,7 +1026,9 @@ bool IFSelect_WorkSession::RemoveItem(const occ::handle& ite if (att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) { if (!thenames.UnBind(GetCasted(TCollection_HAsciiString, att)->ToCString())) + { return false; + } } att.Nullify(); // cf ChangeFromIndex // id = theitems.Add(item,att); @@ -861,7 +1051,9 @@ occ::handle IFSelect_WorkSession::ItemLabel(const int occ::handle res; occ::handle var = Item(id); if (var.IsNull()) + { return res; + } DeclareAndCast(TCollection_HAsciiString, text, var); if (!text.IsNull()) { @@ -887,9 +1079,13 @@ occ::handle IFSelect_WorkSession::ItemLabel(const int if (!mod.IsNull()) { if (mod->IsKind(STANDARD_TYPE(IFSelect_Modifier))) + { res = new TCollection_HAsciiString("ModelModifier:"); + } else + { res = new TCollection_HAsciiString("FileModifier:"); + } res->AssignCat(mod->Label().ToCString()); return res; } @@ -950,7 +1146,9 @@ occ::handle> IFSelect_WorkSession::ItemIdents( for (int i = 1; i <= nb; i++) { if (theitems.FindKey(i)->IsKind(type)) + { list->Append(i); + } } return list; } @@ -967,7 +1165,9 @@ occ::handle>> IFSele for (; IT.More(); IT.Next()) { if (IT.Value()->IsKind(type)) + { list->Append(new TCollection_HAsciiString(IT.Key())); + } } return list; } @@ -987,9 +1187,13 @@ occ::handle>> IFSele occ::handle lab = ItemLabel(i); occ::handle item = Item(i); if (lab.IsNull()) + { continue; + } if (label[0] != '\0' && lab->Search(label) <= 0) + { continue; + } occ::handle nom = Name(Item(i)); if (nom.IsNull()) @@ -998,7 +1202,9 @@ occ::handle>> IFSele nom->Insert(1, '#'); } else + { nom = new TCollection_HAsciiString(nom); + } list->Append(new TCollection_HAsciiString(lab)); } return list; @@ -1015,20 +1221,28 @@ int IFSelect_WorkSession::NextIdentForLabel(const char* const label, { occ::handle lab = ItemLabel(i); if (lab.IsNull()) + { continue; + } switch (mode) { case 0: if (!strcmp(lab->ToCString(), label)) + { return i; + } break; // switch case 1: if (lab->Search(label) == 1) + { return i; + } break; case 2: if (lab->Search(label) > 0) + { return i; + } break; default: break; // break from switch @@ -1048,7 +1262,9 @@ occ::handle IFSelect_WorkSession::NewParamFromStatic(const c occ::handle param; occ::handle stat = Interface_Static::Static(statname); if (stat.IsNull()) + { return param; + } if (stat->Type() == Interface_ParamInteger) { occ::handle intpar = new IFSelect_IntParam; @@ -1060,9 +1276,13 @@ occ::handle IFSelect_WorkSession::NewParamFromStatic(const c param = stat->HStringValue(); } if (param.IsNull()) + { return param; + } if (AddNamedItem(name, param) == 0) + { param.Nullify(); + } return param; } @@ -1078,9 +1298,13 @@ occ::handle IFSelect_WorkSession::IntParam(const int id) cons int IFSelect_WorkSession::IntValue(const occ::handle& par) const { if (!par.IsNull()) + { return par->Value(); + } else + { return 0; + } } //================================================================================================= @@ -1089,7 +1313,9 @@ occ::handle IFSelect_WorkSession::NewIntParam(const char* con { occ::handle intpar = new IFSelect_IntParam; if (AddNamedItem(name, intpar) == 0) + { intpar.Nullify(); + } return intpar; } @@ -1098,7 +1324,9 @@ occ::handle IFSelect_WorkSession::NewIntParam(const char* con bool IFSelect_WorkSession::SetIntValue(const occ::handle& par, const int val) { if (ItemIdent(par) == 0) + { return false; + } par->SetValue(val); return true; } @@ -1116,16 +1344,22 @@ TCollection_AsciiString IFSelect_WorkSession::TextValue( const occ::handle& par) const { if (!par.IsNull()) + { return TCollection_AsciiString(par->ToCString()); + } else + { return TCollection_AsciiString(); + } } occ::handle IFSelect_WorkSession::NewTextParam(const char* const name) { occ::handle textpar = new TCollection_HAsciiString(""); if (AddNamedItem(name, textpar) == 0) + { textpar.Nullify(); + } return textpar; } @@ -1135,7 +1369,9 @@ bool IFSelect_WorkSession::SetTextValue(const occ::handleClear(); par->AssignCat(val); return true; @@ -1155,9 +1391,13 @@ const char* IFSelect_WorkSession::SignValue(const occ::handle& ent) const { if (sign.IsNull() || myModel.IsNull()) + { return ""; + } if (StartingNumber(ent) == 0) + { return ""; + } return sign->Value(ent, myModel); } @@ -1190,14 +1430,16 @@ Interface_EntityIterator IFSelect_WorkSession::EvalSelection( Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** EvalSelection Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } errhand = theerrhand; return iter; } if (thegraph.IsNull()) + { return iter; + } iter = sel->UniqueResult(thegraph->Graph()); return iter; } @@ -1229,7 +1471,7 @@ occ::handle>> IFSelect_Wor Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** SelectionResult Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } errhand = theerrhand; return res; @@ -1237,13 +1479,13 @@ occ::handle>> IFSelect_Wor if (!IsLoaded()) { - std::cout << " *** Data for Evaluation not available ***" << std::endl; + std::cout << " *** Data for Evaluation not available ***" << '\n'; return new NCollection_HSequence>(); } // if (ItemIdent(sel) == 0) if (sel.IsNull()) { - std::cout << " Selection : Unknown" << std::endl; + std::cout << " Selection : Unknown" << '\n'; return res; } // std::cout<>> IFSelect_Wor const occ::handle>>& list) const { if (list.IsNull()) + { return SelectionResult(sel); + } DeclareAndCast(IFSelect_SelectDeduct, deduct, sel); if (deduct.IsNull()) + { return SelectionResult(sel); + } // We will search for the last deduction in the input chain occ::handle ssel, newinput; @@ -1271,7 +1517,9 @@ occ::handle>> IFSelect_Wor newinput = deduct->Input(); deduct = GetCasted(IFSelect_SelectDeduct, newinput); if (deduct.IsNull()) + { break; + } ssel = newinput; } @@ -1298,19 +1546,27 @@ bool IFSelect_WorkSession::SetItemSelection(const occ::handleSetFinalSelection(sel); return true; } if (!modif.IsNull()) { if (ItemIdent(modif) == 0) + { return false; + } if (!sel.IsNull() && ItemIdent(sel) == 0) + { return false; + } // Selection Nulle : Annuler Selection modif->SetSelection(sel); return true; @@ -1335,9 +1591,13 @@ occ::handle IFSelect_WorkSession::ItemSelection( DeclareAndCast(IFSelect_Dispatch, disp, item); DeclareAndCast(IFSelect_GeneralModifier, modif, item); if (ItemIdent(disp) > 0) + { return disp->FinalSelection(); + } if (ItemIdent(modif) > 0) + { return modif->Selection(); + } return sel; // Null or unknown -> Null } @@ -1357,9 +1617,13 @@ bool IFSelect_WorkSession::ComputeCounter(const occ::handleComputeSelected(Graph(), forced); } @@ -1371,11 +1635,17 @@ bool IFSelect_WorkSession::ComputeCounterFromList( const bool clear) { if (counter.IsNull()) + { return false; + } if (clear) + { counter->Clear(); + } if (list.IsNull()) + { return ComputeCounter(counter, true); + } counter->AddList(list, myModel); return true; } @@ -1415,7 +1685,9 @@ occ::handle IFSelect_WorkSession::Dispatch(const int id) cons int IFSelect_WorkSession::DispatchRank(const occ::handle& disp) const { if (ItemIdent(disp) == 0) + { return 0; + } return theshareout->DispatchRank(disp); } @@ -1447,7 +1719,9 @@ occ::handle> IFSelect_WorkSession::FinalModifierIdent occ::handle> list = new NCollection_HSequence(); int nbm = theshareout->NbModifiers(formodel); for (int i = 1; i <= nbm; i++) + { list->Append(ItemIdent(theshareout->GeneralModifier(formodel, i))); + } return list; } @@ -1470,7 +1744,9 @@ occ::handle IFSelect_WorkSession::ModelModifier(const int id) int IFSelect_WorkSession::ModifierRank(const occ::handle& modif) const { if (ItemIdent(modif) == 0) + { return 0; + } return theshareout->ModifierRank(modif); } @@ -1491,11 +1767,15 @@ void IFSelect_WorkSession::ClearFinalModifiers() int nb = list->Length(); int i; // svv #1 for (i = 1; i <= nb; i++) + { RemoveItem(GeneralModifier(list->Value(i))); + } list = FinalModifierIdents(false); nb = list->Length(); for (i = 1; i <= nb; i++) + { RemoveItem(GeneralModifier(list->Value(i))); + } } //================================================================================================= @@ -1504,10 +1784,14 @@ bool IFSelect_WorkSession::SetAppliedModifier(const occ::handle& item) { if (ItemIdent(modif) == 0) + { return false; + } if (item.IsNull()) + { return false; + } if (item == theshareout) { theshareout->AddModifier(modif, 0); @@ -1525,7 +1809,9 @@ bool IFSelect_WorkSession::SetAppliedModifier(const occ::handleAddModifier(tmod); theshareout->RemoveItem(modif); return true; @@ -1538,7 +1824,9 @@ bool IFSelect_WorkSession::SetAppliedModifier(const occ::handle& modif) { if (ItemIdent(modif) == 0) + { return false; + } return theshareout->RemoveItem(modif); } @@ -1550,12 +1838,18 @@ occ::handle IFSelect_WorkSession::UsesAppliedModifier( { occ::handle res; if (ItemIdent(modif) == 0) + { return res; + } if (theshareout->ModifierRank(modif) == 0) + { return res; + } res = modif->Dispatch(); if (res.IsNull()) + { res = theshareout; + } return res; } @@ -1575,7 +1869,9 @@ int IFSelect_WorkSession::RunTransformer(const occ::handle { int effect = 0; if (transf.IsNull() || !IsLoaded()) + { return effect; + } occ::handle newmod; // Null au depart Interface_CheckIterator checks; checks.SetName("X-STEP WorkSession : RunTransformer"); @@ -1584,14 +1880,16 @@ int IFSelect_WorkSession::RunTransformer(const occ::handle if (!checks.IsEmpty(false)) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << " ** RunTransformer has produced Check Messages : **" << std::endl; + sout << " ** RunTransformer has produced Check Messages : **" << '\n'; checks.Print(sout, myModel, false); } thecheckdone = false; thecheckrun = checks; if (newmod.IsNull()) + { return (res ? 1 : -1); + } // UPDATE of SelectPointed occ::handle> list = ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed)); int nb = list->Length(); @@ -1604,7 +1902,9 @@ int IFSelect_WorkSession::RunTransformer(const occ::handle { effect = (res ? 2 : -2); if (!res) + { return effect; + } occ::handle newproto = theprotocol; if (transf->ChangeProtocol(newproto)) { @@ -1618,7 +1918,9 @@ int IFSelect_WorkSession::RunTransformer(const occ::handle { effect = (res ? 3 : -3); if (!res) + { return effect; + } occ::handle newproto = theprotocol; if (transf->ChangeProtocol(newproto)) { @@ -1647,7 +1949,9 @@ int IFSelect_WorkSession::RunModifierSelected(const occ::handle stf = new IFSelect_TransformStandard; stf->SetCopyOption(copy); stf->SetSelection(sel); @@ -1663,7 +1967,9 @@ occ::handle IFSelect_WorkSession::NewTransformStandard(con occ::handle stf = new IFSelect_TransformStandard; stf->SetCopyOption(copy); if (AddNamedItem(name, stf) == 0) + { stf.Nullify(); + } return stf; } @@ -1674,10 +1980,14 @@ bool IFSelect_WorkSession::SetModelContent(const occ::handle const bool keep) { if (sel.IsNull() || !IsLoaded()) + { return false; + } Interface_EntityIterator list = sel->UniqueResult(thegraph->Graph()); if (list.NbEntities() == 0) + { return false; + } occ::handle newmod = myModel->NewEmptyModel(); Interface_CopyTool TC(myModel, theprotocol); @@ -1685,29 +1995,39 @@ bool IFSelect_WorkSession::SetModelContent(const occ::handle if (keep) { for (list.Start(); list.More(); list.Next()) + { TC.TransferEntity(list.Value()); + } } else { int* flags = new int[nb + 1]; for (i = 0; i <= nb; i++) + { flags[i] = 0; + } for (list.Start(); list.More(); list.Next()) { int num = myModel->Number(list.Value()); if (num <= nb) + { flags[num] = 1; + } } for (i = 1; i <= nb; i++) { if (flags[i] == 0) + { TC.TransferEntity(myModel->Value(i)); + } } delete[] flags; } TC.FillModel(newmod); if (newmod->NbEntities() == 0) + { return false; + } // Update (don't forget SelectPointed) theoldel = myModel; SetModel(newmod, false); @@ -1774,7 +2094,9 @@ bool IFSelect_WorkSession::SetDefaultFileRoot(const char* const name) { occ::handle defrt; if (name[0] != '\0') + { defrt = new TCollection_HAsciiString(name); + } return theshareout->SetDefaultRootName(defrt); } @@ -1785,7 +2107,9 @@ bool IFSelect_WorkSession::SetFileRoot(const occ::handle& dis { int id = ItemIdent(disp); if (id == 0) + { return false; + } int nd = theshareout->DispatchRank(disp); /* if (theonlynamed) { if (nd == 0 && namefile[0] != 0) @@ -1794,12 +2118,16 @@ bool IFSelect_WorkSession::SetFileRoot(const occ::handle& dis theshareout->RemoveDispatch (nd); } */ if (nd == 0) + { return false; + } // The order below prevented to change the root name on a given dispatch ! // if (theshareout->HasRootName(nd)) return false; occ::handle filename; if (namefile[0] != '\0') + { filename = new TCollection_HAsciiString(namefile); + } return theshareout->SetRootName(nd, filename); } @@ -1809,7 +2137,9 @@ const char* IFSelect_WorkSession::GiveFileRoot(const char* const file) const { OSD_Path path(file); if (!OSD_Path::IsValid(TCollection_AsciiString(file))) + { return file; // tant pis .. + } bufstr = path.Name(); return bufstr.ToCString(); } @@ -1827,31 +2157,43 @@ const char* IFSelect_WorkSession::GiveFileComplete(const char* const file) const { char val0 = '\0'; if (ext->Length() > 0) + { val0 = ext->Value(1); + } for (i = nb; i > 0; i--) + { if (bufstr.Value(i) == val0) { j = 1; break; } + } if (j == 0) + { bufstr.AssignCat(ext->ToCString()); + } } occ::handle pre = FilePrefix(); if (!pre.IsNull()) { char val1 = '\0'; if (pre->Length() > 0) + { val1 = pre->Value(pre->Length()); + } j = 0; for (i = nb; i > 0; i--) + { if (bufstr.Value(i) == val1) { j = 1; break; } + } if (j == 0) + { bufstr.Insert(1, pre->ToCString()); + } } return bufstr.ToCString(); @@ -1871,7 +2213,9 @@ void IFSelect_WorkSession::EvaluateFile() { ////... if (!IsLoaded()) + { return; + } Interface_CheckIterator checks; if (errhand) { @@ -1886,7 +2230,7 @@ void IFSelect_WorkSession::EvaluateFile() Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** EvaluateFile Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; checks.CCheck(0)->AddFail("Exception Raised -> Abandon"); } errhand = theerrhand; @@ -1899,7 +2243,7 @@ void IFSelect_WorkSession::EvaluateFile() if (!checks.IsEmpty(false)) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << " ** EvaluateFile has produced Check Messages : **" << std::endl; + sout << " ** EvaluateFile has produced Check Messages : **" << '\n'; checks.Print(sout, myModel, false); } thecopier->SetRemaining(thegraph->CGraph()); @@ -1919,7 +2263,9 @@ occ::handle IFSelect_WorkSession::FileModel(const int { occ::handle mod; if (num > 0 && num <= NbFiles()) + { mod = thecopier->FileModel(num); + } return mod; } @@ -1929,7 +2275,9 @@ TCollection_AsciiString IFSelect_WorkSession::FileName(const int num) const { TCollection_AsciiString name; if (num > 0 && num <= NbFiles()) + { name = thecopier->FileName(num); + } return name; } @@ -1971,7 +2319,7 @@ bool IFSelect_WorkSession::SendSplit() Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** SendSplit Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; checks.CCheck(0)->AddFail("Exception Raised -> Abandon"); } errhand = theerrhand; @@ -1988,14 +2336,16 @@ bool IFSelect_WorkSession::SendSplit() if (!IsLoaded()) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << " *** Data for SendSplit not available ***" << std::endl; + sout << " *** Data for SendSplit not available ***" << '\n'; checks.CCheck(0)->AddFail("Data not available"); thecheckrun = checks; return false; } if (NbFiles() > 0) + { checks = thecopier->SendCopied(thelibrary, theprotocol); + } else { /* @@ -2005,7 +2355,9 @@ bool IFSelect_WorkSession::SendSplit() */ // Decomposer if (theshareout.IsNull()) + { return false; + } int i, nbd = theshareout->NbDispatches(); int nf = 0; Message_Messenger::StreamBuffer sout = Message::SendInfo(); @@ -2014,14 +2366,18 @@ bool IFSelect_WorkSession::SendSplit() { occ::handle disp = theshareout->Dispatch(i); if (disp.IsNull()) + { continue; + } IFGraph_SubPartsIterator packs(thegraph->Graph(), false); disp->Packets(thegraph->Graph(), packs); for (packs.Start(); packs.More(); packs.Next()) { Interface_EntityIterator iter = packs.Entities(); if (iter.NbEntities() == 0) + { continue; + } // Write a list of entities occ::handle sp = new IFSelect_SelectPointed; sp->SetList(iter.Content()); @@ -2031,19 +2387,27 @@ bool IFSelect_WorkSession::SendSplit() occ::handle filepart; filepart = FileRoot(disp); if (!filepart.IsNull()) + { filnam.Insert(1, filepart->ToCString()); + } filepart = FilePrefix(); if (!filepart.IsNull()) + { filnam.Insert(1, filepart->ToCString()); + } filepart = FileExtension(); if (!filepart.IsNull()) + { filnam.AssignCat(filepart->ToCString()); + } IFSelect_ReturnStatus stat = SendSelected(filnam.ToCString(), sp); if (stat != IFSelect_RetDone) - std::cout << "File " << filnam << " failed" << std::endl; + { + std::cout << "File " << filnam << " failed" << '\n'; + } } } - sout << " .. Files Written : " << nf << std::endl; + sout << " .. Files Written : " << nf << '\n'; } thecheckrun = checks; return true; @@ -2055,7 +2419,9 @@ occ::handle IFSelect_WorkSession::EvalSplit() const { occ::handle pks; if (!IsLoaded()) + { return pks; + } IFSelect_ShareOutResult sho(ShareOut(), thegraph->Graph()); return sho.Packets(); } @@ -2066,7 +2432,9 @@ Interface_EntityIterator IFSelect_WorkSession::SentList(const int newcount) cons { Interface_EntityIterator iter; if (!IsLoaded()) + { return iter; + } const Interface_Graph& G = thegraph->Graph(); int nb = G.Size(); int i; @@ -2074,7 +2442,9 @@ Interface_EntityIterator IFSelect_WorkSession::SentList(const int newcount) cons { int stat = G.Status(i); if ((stat > 0 && newcount < 0) || stat == newcount) + { iter.GetOneItem(G.Entity(i)); + } } return iter; } @@ -2085,7 +2455,9 @@ int IFSelect_WorkSession::MaxSendingCount() const { int newcount = 0; if (!IsLoaded()) + { return newcount; + } const Interface_Graph& G = thegraph->Graph(); int nb = G.Size(); int i; @@ -2093,7 +2465,9 @@ int IFSelect_WorkSession::MaxSendingCount() const { int stat = G.Status(i); if (stat > newcount) + { newcount = stat; + } } return newcount; } @@ -2104,12 +2478,16 @@ bool IFSelect_WorkSession::SetRemaining(const IFSelect_RemainMode mode) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (!IsLoaded()) + { return false; + } if (mode == IFSelect_RemainForget) { int nb = thegraph->Graph().Size(); for (int i = 1; i <= nb; i++) + { thegraph->CGraph().SetStatus(i, 0); + } theoldel.Nullify(); return true; } @@ -2120,12 +2498,12 @@ bool IFSelect_WorkSession::SetRemaining(const IFSelect_RemainMode mode) thecopier->CopiedRemaining(thegraph->Graph(), thelibrary, TC); if (newmod.IsNull()) { - sout << " No Remaining Data recorded" << std::endl; + sout << " No Remaining Data recorded" << '\n'; return false; } else if (newmod == myModel) { - sout << " Remaining causes all original data to be kept" << std::endl; + sout << " Remaining causes all original data to be kept" << '\n'; thecopier->SetRemaining(thegraph->CGraph()); return false; } @@ -2152,24 +2530,25 @@ bool IFSelect_WorkSession::SetRemaining(const IFSelect_RemainMode mode) for (int i = 1; i <= nb; i++) { if (thegraph->Graph().Status(i) >= 0) + { ne++; + } } if (ne == 0) { - sout << " - All entities are remaining, none yet sent" << std::endl; + sout << " - All entities are remaining, none yet sent" << '\n'; return true; } Interface_EntityIterator iter = SentList(0); nb = iter.NbEntities(); if (nb == 0) { - sout << " - No recorded remaining entities" << std::endl; + sout << " - No recorded remaining entities" << '\n'; return true; } - sout << " -- Recorded Remaining (not yet sent) Entities --" << std::endl; + sout << " -- Recorded Remaining (not yet sent) Entities --" << '\n'; ListEntities(iter, 2, sout); - sout << " -- Maximum Sending Count (i.e. duplication in files) " << MaxSendingCount() - << std::endl; + sout << " -- Maximum Sending Count (i.e. duplication in files) " << MaxSendingCount() << '\n'; /* sout<< " - Now, dispatches are deactivated"<AddFail("WorkLibrary undefined"); @@ -2221,7 +2606,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendAll(const char* const filename, Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** SendAll Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; errhand = theerrhand; checks.CCheck(0)->AddFail("Exception Raised -> Abandon"); thecheckrun = checks; @@ -2229,17 +2614,23 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendAll(const char* const filename, } } else + { checks = thecopier->SendAll(filename, thegraph->Graph(), thelibrary, theprotocol); + } occ::handle aMainFail = checks.CCheck(0); if (!aMainFail.IsNull() && aMainFail->HasFailed()) { return IFSelect_RetStop; } if (theloaded.Length() == 0) + { theloaded.AssignCat(filename); + } thecheckrun = checks; if (checks.IsEmpty(true)) + { return IFSelect_RetDone; + } return IFSelect_RetError; } @@ -2251,7 +2642,9 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected(const char* const filen { ////... if (!IsLoaded()) + { return IFSelect_RetVoid; + } Interface_CheckIterator checks; if (thelibrary.IsNull()) { @@ -2274,7 +2667,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected(const char* const filen Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** SendSelected Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; checks.CCheck(0)->AddFail("Exception Raised -> Abandon"); errhand = theerrhand; thecheckrun = checks; @@ -2284,13 +2677,17 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected(const char* const filen // if (ItemIdent(sel) == 0) return 3; Interface_EntityIterator iter = sel->UniqueResult(thegraph->Graph()); if (iter.NbEntities() == 0) + { return IFSelect_RetVoid; + } checks = thecopier->SendSelected(filename, thegraph->Graph(), thelibrary, theprotocol, iter); thecopier->SetRemaining(thegraph->CGraph()); thecheckrun = checks; if (checks.IsEmpty(true)) + { return IFSelect_RetDone; + } return IFSelect_RetError; } @@ -2299,10 +2696,14 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected(const char* const filen IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile(const char* const filename) { if (WorkLibrary().IsNull()) + { return IFSelect_RetVoid; + } ComputeGraph(true); if (!IsLoaded()) + { return IFSelect_RetVoid; + } return SendAll(filename); } @@ -2312,10 +2713,14 @@ IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile(const char* const filename const occ::handle& sel) { if (WorkLibrary().IsNull() || sel.IsNull()) + { return IFSelect_RetVoid; + } ComputeGraph(true); if (!IsLoaded()) + { return IFSelect_RetVoid; + } return SendSelected(filename, sel); } @@ -2327,14 +2732,22 @@ IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile(const char* const filename int IFSelect_WorkSession::NbSources(const occ::handle& sel) const { if (ItemIdent(sel) == 0) + { return 0; + } if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) || sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct))) + { return 1; + } if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl))) + { return 2; + } if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine))) + { return GetCasted(IFSelect_SelectCombine, sel)->NbInputs(); + } return 0; } @@ -2346,20 +2759,32 @@ occ::handle IFSelect_WorkSession::Source( { occ::handle sr; if (ItemIdent(sel) == 0) + { return sr; + } if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract))) + { sr = GetCasted(IFSelect_SelectExtract, sel)->Input(); + } else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct))) + { sr = GetCasted(IFSelect_SelectDeduct, sel)->Input(); + } else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl))) { if (num == 1) + { sr = GetCasted(IFSelect_SelectControl, sel)->MainInput(); + } else if (num == 2) + { sr = GetCasted(IFSelect_SelectControl, sel)->SecondInput(); + } } else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine))) + { sr = GetCasted(IFSelect_SelectCombine, sel)->Input(num); + } return sr; } @@ -2368,10 +2793,14 @@ occ::handle IFSelect_WorkSession::Source( bool IFSelect_WorkSession::IsReversedSelectExtract(const occ::handle& sel) const { if (ItemIdent(sel) == 0) + { return false; + } DeclareAndCast(IFSelect_SelectExtract, sxt, sel); if (sxt.IsNull()) + { return false; + } return (!sxt->IsDirect()); } @@ -2380,10 +2809,14 @@ bool IFSelect_WorkSession::IsReversedSelectExtract(const occ::handle& sel) { if (ItemIdent(sel) == 0) + { return false; + } DeclareAndCast(IFSelect_SelectExtract, sxt, sel); if (sxt.IsNull()) + { return false; + } sxt->SetDirect(!sxt->IsDirect()); return true; } @@ -2394,9 +2827,13 @@ bool IFSelect_WorkSession::SetInputSelection(const occ::handle& inp) { if (ItemIdent(sel) == 0) + { return false; + } if (!inp.IsNull() && ItemIdent(inp) == 0) + { return false; + } DeclareAndCast(IFSelect_SelectExtract, sxt, sel); if (!sxt.IsNull()) { @@ -2420,13 +2857,21 @@ bool IFSelect_WorkSession::SetControl(const occ::handle& sel { DeclareAndCast(IFSelect_SelectControl, dsel, sel); if (ItemIdent(dsel) == 0) + { return false; + } if (ItemIdent(sc) == 0) + { return false; + } if (formain) + { dsel->SetMainInput(sc); + } else + { dsel->SetSecondInput(sc); + } return true; } @@ -2438,9 +2883,13 @@ int IFSelect_WorkSession::CombineAdd(const occ::handle& sel, { DeclareAndCast(IFSelect_SelectCombine, csel, sel); if (ItemIdent(csel) == 0) + { return 0; + } if (ItemIdent(seladd) == 0) + { return 0; + } csel->Add(seladd, atnum); return csel->NbInputs(); } @@ -2452,9 +2901,13 @@ bool IFSelect_WorkSession::CombineRemove(const occ::handle& { DeclareAndCast(IFSelect_SelectCombine, csel, selcomb); if (ItemIdent(csel) == 0) + { return false; + } if (ItemIdent(selrem) == 0) + { return false; + } int nb = csel->NbInputs(); for (int i = nb; i > 0; i--) { @@ -2475,9 +2928,13 @@ occ::handle IFSelect_WorkSession::NewSelectPointed( { occ::handle sel = new IFSelect_SelectPointed; if (!list.IsNull()) + { sel->AddList(list); + } if (AddNamedItem(name, sel) == 0) + { sel.Nullify(); + } return sel; } @@ -2490,13 +2947,21 @@ bool IFSelect_WorkSession::SetSelectPointed( { DeclareAndCast(IFSelect_SelectPointed, sp, sel); if (sp.IsNull() || list.IsNull()) + { return false; + } if (mode == 0) + { sp->Clear(); + } if (mode >= 0) + { sp->AddList(list); + } else + { sp->RemoveList(list); + } return true; } @@ -2515,7 +2980,9 @@ static void IFSelect_QueryProp(Interface_IntList& list, for (i = 1; i <= nb; i++) { if (i > 1) + { list.SetNumber(num); // because recursive call + depth first + } int n = list.Value(i); // is there a need to propagate? // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place @@ -2555,7 +3022,9 @@ static void IFSelect_QueryProp(Interface_IntList& list, break; } if (val == ' ') + { continue; + } ana.SetValue(n, val); IFSelect_QueryProp(list, ana, n, quoi); } @@ -2566,7 +3035,9 @@ static void IFSelect_QueryProp(Interface_IntList& list, void IFSelect_WorkSession::QueryCheckList(const Interface_CheckIterator& chl) { if (!IsLoaded()) + { return; + } int i, nb = myModel->NbEntities(); thecheckana = TCollection_AsciiString(nb + 1, ' '); for (chl.Start(); chl.More(); chl.Next()) @@ -2574,9 +3045,13 @@ void IFSelect_WorkSession::QueryCheckList(const Interface_CheckIterator& chl) int num = chl.Number(); const occ::handle& ach = chl.Value(); if (ach->HasFailed()) + { thecheckana.SetValue(num, '2'); + } else if (ach->HasWarnings()) + { thecheckana.SetValue(num, '1'); + } } // analysis according to the graph ... codes : blc = nothing // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place @@ -2588,18 +3063,26 @@ void IFSelect_WorkSession::QueryCheckList(const Interface_CheckIterator& chl) char val = thecheckana.Value(i); int quoi = -1; if (val == '1' || val == '4' || val == '7') + { quoi = 0; + } if (quoi >= 0) + { IFSelect_QueryProp(list, thecheckana, i, quoi); + } } for (i = 1; i <= nb; i++) { char val = thecheckana.Value(i); int quoi = -1; if (val == '2' || val == '5' || val == '8') + { quoi = 1; + } if (quoi >= 0) + { IFSelect_QueryProp(list, thecheckana, i, quoi); + } } } @@ -2608,35 +3091,59 @@ void IFSelect_WorkSession::QueryCheckList(const Interface_CheckIterator& chl) int IFSelect_WorkSession::QueryCheckStatus(const occ::handle& ent) const { if (!IsLoaded()) + { return -1; + } int num = myModel->Number(ent); if (num == 0) + { return -1; + } if (thecheckana.Length() < num) + { return -1; + } char val = thecheckana.Value(num); // codes : blc = rien -> 0 // 1 W/place -> 1 2 F/place -> 2 // 3 Wprop -> 10 4 Wprop+W/place -> 11 5 Wprop+F/place -> 12 // 6 Fprop -> 20 7 Fprop+W/place -> 21 8 Fprop+F/place -> 22 if (val == ' ') + { return 0; + } if (val == '1') + { return 1; + } if (val == '2') + { return 2; + } if (val == '3') + { return 10; + } if (val == '4') + { return 11; + } if (val == '5') + { return 12; + } if (val == '6') + { return 20; + } if (val == '7') + { return 21; + } if (val == '8') + { return 22; + } return 0; } @@ -2648,23 +3155,33 @@ int IFSelect_WorkSession::QueryParent(const occ::handle& ent int ndad = StartingNumber(entdad); int nson = StartingNumber(entson); if (ndad < 1 || nson < 1) + { return -1; + } if (ndad == nson) + { return 0; + } // we will calculate: for each immediate parent, of , status with + 1 // nb: not protected against loops ... occ::handle>> list = thegraph->Graph().Sharings(entson).Content(); if (list.IsNull()) + { return -1; + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) { if (list->Value(i) == entdad) + { return 1; + } int stat = QueryParent(entdad, list->Value(i)); if (stat >= 0) + { return stat + 1; + } } return -1; // not yet implemented ... } @@ -2688,7 +3205,9 @@ void IFSelect_WorkSession::SetParams( { DeclareAndCast(Interface_TypedValue, val, params.Value(i)); if (val.IsNull()) + { continue; + } editor->AddValue(val); } AddNamedItem("xst-params-edit", editor); @@ -2728,27 +3247,39 @@ void IFSelect_WorkSession::SetParams( occ::handle paramsgen = new IFSelect_EditForm(editor, listgen, false, true, "General Parameters"); if (listgen.Length() > 0) + { AddNamedItem("xst-params-general", paramsgen); + } occ::handle paramsload = new IFSelect_EditForm(editor, listload, false, true, "Loading Parameters"); if (listload.Length() > 0) + { AddNamedItem("xst-params-load", paramsload); + } occ::handle paramssend = new IFSelect_EditForm(editor, listsend, false, true, "Sending Parameters"); if (listsend.Length() > 0) + { AddNamedItem("xst-params-send", paramssend); + } occ::handle paramsplit = new IFSelect_EditForm(editor, listsplit, false, true, "Split Parameters"); if (listsplit.Length() > 0) + { AddNamedItem("xst-params-split", paramsplit); + } occ::handle paramsread = new IFSelect_EditForm(editor, listread, false, true, "Read(Transfer) Parameters"); if (listread.Length() > 0) + { AddNamedItem("xst-params-read", paramsread); + } occ::handle paramswrite = new IFSelect_EditForm(editor, listwrite, false, true, "Write(Transfer) Parameters"); if (listwrite.Length() > 0) + { AddNamedItem("xst-params-write", paramswrite); + } } //================================================================================================= @@ -2759,39 +3290,55 @@ void IFSelect_WorkSession::TraceStatics(const int use, const int mode) const if (use > 0) { if (mode == 0) - sout << "******************************************" << std::endl; + { + sout << "******************************************" << '\n'; + } if (use == 1) { if (mode == 0) - sout << "***** General Parameters *****" << std::endl; + { + sout << "***** General Parameters *****" << '\n'; + } } else if (use == 2) { if (mode == 0) - sout << "***** Load File *****" << std::endl; + { + sout << "***** Load File *****" << '\n'; + } } else if (use == 3) { if (mode == 0) - sout << "***** Write File *****" << std::endl; + { + sout << "***** Write File *****" << '\n'; + } } else if (use == 4) { if (mode == 0) - sout << "***** Split File *****" << std::endl; + { + sout << "***** Split File *****" << '\n'; + } } else if (use == 5) { if (mode == 0) - sout << "***** Transfer (Read) *****" << std::endl; + { + sout << "***** Transfer (Read) *****" << '\n'; + } } else if (use == 6) { if (mode == 0) - sout << "***** Transfer (Write) *****" << std::endl; + { + sout << "***** Transfer (Write) *****" << '\n'; + } } if (mode == 0) - sout << "******************************************" << std::endl << std::endl; + { + sout << "******************************************" << '\n' << '\n'; + } } // Echainements particuliers (use > 0) @@ -2799,13 +3346,17 @@ void IFSelect_WorkSession::TraceStatics(const int use, const int mode) const { TraceStatics(-2, mode); if (mode == 0) - sout << std::endl; + { + sout << '\n'; + } } else if (use == 4 || use == 6) { TraceStatics(-3, mode); if (mode == 0) - sout << std::endl; + { + sout << '\n'; + } } // Valeurs particulieres @@ -2823,19 +3374,31 @@ void IFSelect_WorkSession::TraceStatics(const int use, const int mode) const { occ::handle str = theshareout->Prefix(); if (!str.IsNull()) - sout << "Prefix : " << str->ToCString() << std::endl; + { + sout << "Prefix : " << str->ToCString() << '\n'; + } else - sout << "Prefix not Defined" << std::endl; + { + sout << "Prefix not Defined" << '\n'; + } str = theshareout->DefaultRootName(); if (!str.IsNull()) - sout << "Default Root : " << str->ToCString() << std::endl; + { + sout << "Default Root : " << str->ToCString() << '\n'; + } else - sout << "Default Root not Defined" << std::endl; + { + sout << "Default Root not Defined" << '\n'; + } str = theshareout->Extension(); if (!str.IsNull()) - sout << "Extension : " << str->ToCString() << std::endl; + { + sout << "Extension : " << str->ToCString() << '\n'; + } else - sout << "Extension not defined" << std::endl; + { + sout << "Extension not defined" << '\n'; + } } } @@ -2846,7 +3409,9 @@ void IFSelect_WorkSession::TraceStatics(const int use, const int mode) const if (use > 0) { if (mode == 0) - sout << "******************************************" << std::endl << std::endl; + { + sout << "******************************************" << '\n' << '\n'; + } } } @@ -2855,55 +3420,85 @@ void IFSelect_WorkSession::TraceStatics(const int use, const int mode) const void IFSelect_WorkSession::DumpShare() const { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << " ********** Definition ShareOut (Complete) **********" << std::endl; + sout << " ********** Definition ShareOut (Complete) **********" << '\n'; occ::handle str = theshareout->Prefix(); if (!str.IsNull()) - sout << "Prefix : " << str->ToCString() << std::endl; + { + sout << "Prefix : " << str->ToCString() << '\n'; + } else - sout << "Prefix not Defined" << std::endl; + { + sout << "Prefix not Defined" << '\n'; + } str = theshareout->DefaultRootName(); if (!str.IsNull()) - sout << "Default Root : " << str->ToCString() << std::endl; + { + sout << "Default Root : " << str->ToCString() << '\n'; + } else - sout << "Default Root not Defined" << std::endl; + { + sout << "Default Root not Defined" << '\n'; + } str = theshareout->Extension(); if (!str.IsNull()) - sout << "Extension : " << str->ToCString() << std::endl; + { + sout << "Extension : " << str->ToCString() << '\n'; + } else - sout << "Extension not defined" << std::endl; + { + sout << "Extension not defined" << '\n'; + } int lr = theshareout->LastRun(); int nb = theshareout->NbDispatches(); - sout << "Nb Dispatches : " << nb << " (Last Run : " << lr << ") : " << std::endl; + sout << "Nb Dispatches : " << nb << " (Last Run : " << lr << ") : " << '\n'; for (int i = 1; i <= nb; i++) { occ::handle disp = theshareout->Dispatch(i); sout << "Dispatch n0 " << i; if (HasName(disp)) + { sout << " Name:" << Name(disp)->ToCString(); - sout << " Label:" << disp->Label() << std::endl; + } + sout << " Label:" << disp->Label() << '\n'; occ::handle sel = disp->FinalSelection(); if (sel.IsNull()) - sout << " No Final Selection Defined" << std::endl; + { + sout << " No Final Selection Defined" << '\n'; + } else if (HasName(sel)) + { sout << " Final Selection : Name:" << Name(sel)->ToCString() << " Label:" << sel->Label() - << std::endl; + << '\n'; + } else - sout << " Final Selection : " << sel->Label() << std::endl; + { + sout << " Final Selection : " << sel->Label() << '\n'; + } if (disp->HasRootName()) - sout << " File Root Name : " << disp->RootName()->ToCString() << std::endl; + { + sout << " File Root Name : " << disp->RootName()->ToCString() << '\n'; + } else - sout << " No specific file root name (see Default Root)" << std::endl; + { + sout << " No specific file root name (see Default Root)" << '\n'; + } } int nbm = theshareout->NbModifiers(true); if (nbm > 0) - sout << " *** " << nbm << " active Model Modifiers : see ListModifiers ***" << std::endl; + { + sout << " *** " << nbm << " active Model Modifiers : see ListModifiers ***" << '\n'; + } int nbf = theshareout->NbModifiers(false); if (nbf > 0) - sout << " *** " << nbf << " active File Modifiers : see ListModifiers ***" << std::endl; + { + sout << " *** " << nbf << " active File Modifiers : see ListModifiers ***" << '\n'; + } if (nbm + nbf == 0) - sout << " *** No active Modifiers ***" << std::endl; + { + sout << " *** No active Modifiers ***" << '\n'; + } } // #### #### #### #### #### #### #### #### #### @@ -2914,28 +3509,38 @@ void IFSelect_WorkSession::DumpShare() const void IFSelect_WorkSession::ListItems(const char* const lab) const { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << " ********** Items in Session **********" << std::endl; + sout << " ********** Items in Session **********" << '\n'; int nb = MaxIdent(); occ::handle str; if (lab[0] != '\0') + { str = new TCollection_HAsciiString(lab); + } for (int i = 1; i <= nb; i++) { const occ::handle& var = theitems.FindKey(i); occ::handle label = ItemLabel(i); if (label.IsNull()) + { continue; // -> item supprime + } if (!str.IsNull()) { if (label->Location(str, 1, label->Length()) == 0) + { continue; + } } sout << "#" << i; if (HasName(var)) + { sout << " - Named : " << Name(var)->ToCString() << " - "; + } else + { sout << " - (no name) - "; - sout << var->DynamicType()->Name() << std::endl << " " << label->ToCString() << std::endl; + } + sout << var->DynamicType()->Name() << '\n' << " " << label->ToCString() << '\n'; } } @@ -2950,15 +3555,19 @@ void IFSelect_WorkSession::ListFinalModifiers(const bool formodel) const int nb = theshareout->NbModifiers(formodel); sout << " ********** Modifiers in Session "; sout << (formodel ? "(For Model)" : "(For File)"); - sout << ": " << nb << " **********" << std::endl; + sout << ": " << nb << " **********" << '\n'; for (int i = 1; i <= nb; i++) { occ::handle modif = theshareout->GeneralModifier(formodel, i); if (!modif.IsNull()) + { sout << "Modifier n0." << i << " : " << modif->Label(); + } if (HasName(modif)) + { sout << " Named as : " << Name(modif)->ToCString(); - sout << std::endl; + } + sout << '\n'; } } @@ -2972,14 +3581,16 @@ void IFSelect_WorkSession::DumpSelection(const occ::handle& Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (ItemIdent(sel) == 0) { - sout << "Selection : Unknown" << std::endl; // sout<ToCString(); - sout << " **********" << std::endl; - sout << "Label : " << sel->Label() << " . Input(s) : " << std::endl; + } + sout << " **********" << '\n'; + sout << "Label : " << sel->Label() << " . Input(s) : " << '\n'; int nb = 0; IFSelect_SelectionIterator iter; sel->FillIterator(iter); @@ -2987,9 +3598,9 @@ void IFSelect_WorkSession::DumpSelection(const occ::handle& { nb++; const occ::handle& newsel = iter.Value(); - sout << " -- " << newsel->Label() << std::endl; + sout << " -- " << newsel->Label() << '\n'; } - sout << " Nb Inputs:" << nb << std::endl; + sout << " Nb Inputs:" << nb << '\n'; } // ########################################## @@ -3018,7 +3629,9 @@ occ::handle IFSelect_WorkSession::GiveSelection(const char* { nivp--; if (nivp <= 0) + { nf = n; + } } //// if (selname[n] == ' ') { nb = n; break; } } @@ -3044,12 +3657,16 @@ occ::handle IFSelect_WorkSession::GiveSelection(const char* DeclareAndCast(IFSelect_Signature, sign, item); DeclareAndCast(IFSelect_SignCounter, cnt, item); if (!sign.IsNull()) + { selsign = new IFSelect_SelectSignature(sign, &nomsel[debsign], false); + } else if (!cnt.IsNull()) + { selsign = new IFSelect_SelectSignature(cnt, &nomsel[debsign], false); + } else { - std::cout << selname << " : neither Signature nor Counter" << std::endl; + std::cout << selname << " : neither Signature nor Counter" << '\n'; return sel; } @@ -3058,7 +3675,9 @@ occ::handle IFSelect_WorkSession::GiveSelection(const char* } else + { sel = GetCasted(IFSelect_Selection, item); + } return sel; } @@ -3071,11 +3690,15 @@ occ::handle>> IFSelect_Wor // Already a list DeclareAndCast(NCollection_HSequence>, list, obj); if (!list.IsNull()) + { return list; + } // Nothing at all: returns nothing at all if (obj.IsNull()) + { return list; + } // A selection: its result (standard) DeclareAndCast(IFSelect_Selection, sel, obj); @@ -3091,19 +3714,25 @@ occ::handle>> IFSelect_Wor { int i, nb = myModel->NbEntities(); for (i = 1; i <= nb; i++) + { list->Append(myModel->Value(i)); + } } // A model entity: this entity else if (StartingNumber(obj) > 0) + { list->Append(obj); - // A Text: its interpretation + // A Text: its interpretation + } else { DeclareAndCast(TCollection_HAsciiString, str, obj); if (!str.IsNull()) + { return GiveList(str->ToCString()); + } } // If it's not all that: an empty list @@ -3118,16 +3747,24 @@ occ::handle>> IFSelect_Wor { occ::handle>> list; if (!first || first[0] == '\0') + { return list; + } if (first[0] == ' ') + { return GiveList(&first[1], second); + } if (second && second[0] == ' ') + { return GiveList(first, &second[1]); + } // NULL list will be interpreted as SelectionResult (raw selection) // otherwise as SelectionResultFromList if (second && second[0] != '\0') + { list = GiveList(second, ""); + } list = GiveListFromList(first, list); return list; @@ -3152,21 +3789,31 @@ occ::handle>> IFSelect_Wor for (i = 1; selname[i] != '\0'; i++) { if (selname[i] == ' ') + { continue; + } if (selname[i] == ',' || selname[i] == ')') { entid[j] = '\0'; if (j == 0) + { continue; + } j = 0; num = NumberFromLabel(entid); if (num <= 0 || !numap.Add(num)) + { continue; + } occ::handle anent = StartingEntity(num); if (!anent.IsNull()) + { list->Append(anent); + } if (selname[i] == ')') + { break; + } continue; } entid[j] = selname[i]; @@ -3176,7 +3823,9 @@ occ::handle>> IFSelect_Wor } num = NumberFromLabel(selname); if (num > 0) + { return GiveList(StartingEntity(num)); + } // Other cases: is there an input list. // Si OUI -> SelectionResultFromList. Si NON -> SelectionResult @@ -3203,22 +3852,30 @@ occ::handle>> IFSelect_Wor } } if (nomsel[0] == '\0') + { return list; + } occ::handle sel = GiveSelection(nomsel); if (sel.IsNull()) { - std::cout << "Neither Entity Number/Label nor Selection :" << nomsel << std::endl; + std::cout << "Neither Entity Number/Label nor Selection :" << nomsel << '\n'; return list; } if (nb > 0) + { list = GiveListFromList(&selname[nb + 1], list); + } if (list.IsNull()) + { list = SelectionResult(sel); + } else + { list = SelectionResultFromList(sel, list); + } return list; } @@ -3232,7 +3889,9 @@ occ::handle>> IFSelect_Wor { occ::handle>> list; if (l1.IsNull() || l2.IsNull()) + { return list; + } // mode < 0 l1-l2 = 0 l1&l2 > 0 l1|l2 (l1+l2) NCollection_Map> numap; @@ -3241,10 +3900,14 @@ occ::handle>> IFSelect_Wor { occ::handle ent = l2->Value(i); if (ent.IsNull()) + { continue; + } numap.Add(ent); if (mode > 0) + { list->Append(ent); + } } // entities from l1 not already in l2 @@ -3253,19 +3916,25 @@ occ::handle>> IFSelect_Wor { occ::handle ent = l1->Value(i); if (ent.IsNull()) + { continue; + } if (numap.Contains(ent)) { // in l1 and in l2 if (mode == 0) + { list->Append(ent); + } } else { // in l1 but not in l2 if (mode != 0) + { list->Append(ent); + } } } @@ -3279,21 +3948,25 @@ void IFSelect_WorkSession::DumpModel(const int level, Standard_OStream& S) { if (!IsLoaded()) { - S << " *** Data for List not available ***" << std::endl; + S << " *** Data for List not available ***" << '\n'; return; } S << "\n *****************************************************************\n"; if (theloaded.Length() > 0) + { S << " ******** Loaded File : " << theloaded.ToCString() - << Interface_MSG::Blanks(32 - theloaded.Length()) << " ********" << std::endl; + << Interface_MSG::Blanks(32 - theloaded.Length()) << " ********" << '\n'; + } else - S << " ******** No name for Loaded File" << std::endl; + { + S << " ******** No name for Loaded File" << '\n'; + } if (level == 0) { S << " ******** Short Dump of Header ********\n"; S << " *****************************************************************\n\n"; myModel->DumpHeader(S); - S << std::endl; + S << '\n'; } int nbent = myModel->NbEntities(); @@ -3303,15 +3976,19 @@ void IFSelect_WorkSession::DumpModel(const int level, Standard_OStream& S) for (int i = 1; i <= nbent; i++) { if (!shar.IsShared(myModel->Value(i))) + { nbr++; + } } S << " *****************************************************************\n" << " ******** Model : " << nbent << " Entities, of which " << nbr << " Root(s)\n" << " *****************************************************************\n" - << std::endl; + << '\n'; if (level <= 0) + { return; + } else if (level == 1) { S << " ******** Root Entities ******** "; @@ -3326,19 +4003,29 @@ void IFSelect_WorkSession::DumpModel(const int level, Standard_OStream& S) { IFSelect_PrintCount mode = IFSelect_ItemsByEntity; if (level == 5 || level == 8) + { mode = IFSelect_CountByItem; + } if (level == 6 || level == 9) + { mode = IFSelect_ListByItem; + } if (level == 7 || level == 10) + { mode = IFSelect_EntitiesByItem; + } PrintCheckList(S, ModelCheckList(), false, mode); } else { if (level == 3) - S << " ******** Check Model (Fails) ********" << std::endl; + { + S << " ******** Check Model (Fails) ********" << '\n'; + } else - S << " ******** Check Model (Complete) ********" << std::endl; + { + S << " ******** Check Model (Complete) ********" << '\n'; + } Interface_CheckTool CT(Graph()); Interface_CheckIterator C; if (theerrhand) @@ -3347,22 +4034,30 @@ void IFSelect_WorkSession::DumpModel(const int level, Standard_OStream& S) { OCC_CATCH_SIGNALS if (level == 3) + { C = CT.CheckList(); + } else + { C = CT.CompleteCheckList(); + } } catch (Standard_Failure const&) { Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** DumpModel (Check) Interrupted by Exception ****\n"; S << " ** ** Exception Raised during Check ! ** **\n"; - S << " --> what could be determined is listed" << std::endl; + S << " --> what could be determined is listed" << '\n'; } } else if (level == 3) + { C = CT.CheckList(); + } else + { C = CT.CompleteCheckList(); + } // Check List: if empty (not requested), naturally passed try @@ -3375,11 +4070,10 @@ void IFSelect_WorkSession::DumpModel(const int level, Standard_OStream& S) Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << " **** DumpModel Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } } - S << std::endl - << "There are " << nbent << " Entities, of which " << nbr << " Root(s)" << std::endl; + S << '\n' << "There are " << nbent << " Entities, of which " << nbr << " Root(s)" << '\n'; } // .... TraceDumpModel .... (Model + CheckList) @@ -3408,22 +4102,21 @@ void IFSelect_WorkSession::DumpEntity(const occ::handle& ent { if (!IsLoaded()) { - S << " *** Data for List not available ***" << std::endl; + S << " *** Data for List not available ***" << '\n'; return; } int num = myModel->Number(ent); if (num == 0) { - S << " *** Entity to Dump not in the Model ***" << std::endl; + S << " *** Entity to Dump not in the Model ***" << '\n'; return; } if (thelibrary.IsNull()) { - S << " *** WorkLibrary not defined ***" << std::endl; + S << " *** WorkLibrary not defined ***" << '\n'; return; } - S << " ******** Dumping Entity n0 " << num << " level:" << level << " ********" - << std::endl; + S << " ******** Dumping Entity n0 " << num << " level:" << level << " ********" << '\n'; thelibrary->DumpEntity(myModel, theprotocol, ent, S, level); } @@ -3451,7 +4144,7 @@ void IFSelect_WorkSession::PrintEntityStatus(const occ::handlePrint(ent, S); occ::handle hname = EntityName(ent); if (!hname.IsNull() && hname->Length() > 0) + { S << " Name:" << hname->ToCString(); - S << std::endl; + } + S << '\n'; occ::handle signtype = SignType(); if (signtype.IsNull()) - S << " Type(CDL):" << ent->DynamicType()->Name() << std::endl; + { + S << " Type(CDL):" << ent->DynamicType()->Name() << '\n'; + } else - S << " Type:" << signtype->Value(ent, myModel) << std::endl; - S << " Category : " << CategoryName(ent) << " Validity : " << ValidityName(ent) - << std::endl; + { + S << " Type:" << signtype->Value(ent, myModel) << '\n'; + } + S << " Category : " << CategoryName(ent) << " Validity : " << ValidityName(ent) << '\n'; Interface_CheckIterator chl = CheckOne(ent); chl.Print(S, myModel, false, false); occ::handle>> list = Sharings(ent); if (list.IsNull()) - S << " Root" << std::endl; + { + S << " Root" << '\n'; + } else { nb = list->Length(); if (nb == 0) + { S << " Root"; + } else + { S << " Super-entities:" << nb << " : (n0/id):"; + } for (i = 1; i <= nb; i++) { S << " "; myModel->Print(list->Value(i), S); } - S << std::endl; + S << '\n'; } list = Shareds(ent); if (list.IsNull()) - S << " No sub-entity" << std::endl; + { + S << " No sub-entity" << '\n'; + } else { nb = list->Length(); if (nb == 0) + { S << " No sub-entity"; + } else + { S << " Sub-entities:" << nb << " , i.e. (n0/id):"; + } for (i = 1; i <= nb; i++) { S << " "; myModel->Print(list->Value(i), S); } - S << std::endl; + S << '\n'; } } @@ -3518,7 +4228,9 @@ void IFSelect_WorkSession::PrintCheckList(Standard_OStream& S, { // mode : 0 comptage 1 n0s entites 2 n0s+id ents if (mode == IFSelect_ItemsByEntity) + { checklist.Print(S, myModel, failsonly); + } else { const Interface_CheckIterator& chks = checklist; @@ -3538,7 +4250,9 @@ void IFSelect_WorkSession::PrintSignatureList(Standard_OStream& const IFSelect_PrintCount mode) const { if (signlist.IsNull()) + { return; + } signlist->PrintList(S, myModel, mode); } @@ -3562,7 +4276,7 @@ void IFSelect_WorkSession::EvaluateSelection(const occ::handleLabel() << std::endl; + sout << "**** (Unique) RootResult, Selection : " << sel->Label() << '\n'; } // #### #### #### #### #### #### #### #### #### @@ -3604,7 +4318,7 @@ void IFSelect_WorkSession::EvaluateDispatch(const occ::handle { sout << " **** EvaluateDispatch Interrupted by Exception **** Title\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } errhand = theerrhand; return; @@ -3613,20 +4327,20 @@ void IFSelect_WorkSession::EvaluateDispatch(const occ::handle int numdisp = DispatchRank(disp); if (!IsLoaded()) { - sout << " *** Data for List not available ***" << std::endl; + sout << " *** Data for List not available ***" << '\n'; return; } if (theshareout->NbDispatches() < numdisp || numdisp <= 0) { - sout << "Dispatch : Unknown" << std::endl; + sout << "Dispatch : Unknown" << '\n'; return; } // sout<FinalSelection().IsNull()) { - sout << "Dispatch : No Final Selection" << std::endl; + sout << "Dispatch : No Final Selection" << '\n'; return; } // sout<Label() << std::endl; + sout << " --- Dispatch Label : " << disp->Label() << '\n'; IFSelect_ShareOutResult eval(disp, thegraph->Graph()); eval.Evaluate(); @@ -3634,26 +4348,32 @@ void IFSelect_WorkSession::EvaluateDispatch(const occ::handle occ::handle evres = eval.Packets(mode != 0); int nbpack = evres->NbPackets(); - sout << "Nb Packets produced : " << nbpack << " :" << std::endl; + sout << "Nb Packets produced : " << nbpack << " :" << '\n'; for (numpack = 1; numpack <= nbpack; numpack++) { - sout << "\n **** Packet n0 : " << numpack << " ****" << std::endl; + sout << "\n **** Packet n0 : " << numpack << " ****" << '\n'; if (!mode) - std::cout << "Root Entities :" << std::endl; + { + std::cout << "Root Entities :" << '\n'; + } ListEntities(evres->Entities(numpack), (mode ? 2 : -1), sout); } //// Interface_EntityIterator iterem = disp->Remainder(thegraph->Graph()); if (mode == 0) + { return; + } if (mode == 1 || mode == 3) { - sout << std::endl; + sout << '\n'; if (evres->NbDuplicated(0, false) == 0) - sout << " **** All the Model is taken into account ****" << std::endl; + { + sout << " **** All the Model is taken into account ****" << '\n'; + } else { - sout << " **** Starting Entities not taken by this Dispatch ****" << std::endl; + sout << " **** Starting Entities not taken by this Dispatch ****" << '\n'; ListEntities(evres->Duplicated(0, false), 2, sout); } } @@ -3662,16 +4382,20 @@ void IFSelect_WorkSession::EvaluateDispatch(const occ::handle sout << " **** Entites in more than one packet ****"; int max = evres->HighestDuplicationCount(); if (max < 2) - sout << " : There are none" << std::endl; + { + sout << " : There are none" << '\n'; + } else { int newcount; - sout << std::endl; + sout << '\n'; for (newcount = 2; newcount <= max; newcount++) { if (evres->NbDuplicated(newcount, false) == 0) + { continue; - sout << " **** Entities put in " << newcount << " packets ****" << std::endl; + } + sout << " **** Entities put in " << newcount << " packets ****" << '\n'; ListEntities(evres->Duplicated(newcount, false), 2, sout); } } @@ -3698,7 +4422,7 @@ void IFSelect_WorkSession::EvaluateComplete(const int mode) const { sout << " **** EvaluateComplete Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } errhand = theerrhand; return; @@ -3706,58 +4430,72 @@ void IFSelect_WorkSession::EvaluateComplete(const int mode) const if (!IsLoaded()) { - sout << " *** Data for List not available ***" << std::endl; + sout << " *** Data for List not available ***" << '\n'; return; } IFSelect_ShareOutResult eval(theshareout, thegraph->Graph()); eval.Evaluate(); sout << "\n******** Evaluation ShareOutResult (Complete) ********\n"; - sout << " **** List of Packets **** Count : " << eval.NbPackets() << std::endl; + sout << " **** List of Packets **** Count : " << eval.NbPackets() << '\n'; if (mode == 0) - sout << " ** (for each one : Root Entities) **" << std::endl; + { + sout << " ** (for each one : Root Entities) **" << '\n'; + } else - sout << " ** (for each one : Evaluated Content) **" << std::endl; + { + sout << " ** (for each one : Evaluated Content) **" << '\n'; + } int numpack = 0; occ::handle evres = eval.Packets(mode != 0); int nbpack = evres->NbPackets(); - sout << "Nb Packets produced : " << nbpack << " :" << std::endl; + sout << "Nb Packets produced : " << nbpack << " :" << '\n'; for (numpack = 1; numpack <= nbpack; numpack++) { - sout << "\n **** Packet n0 : " << numpack << " ****" << std::endl; + sout << "\n **** Packet n0 : " << numpack << " ****" << '\n'; if (!mode) - std::cout << "Root Entities :" << std::endl; + { + std::cout << "Root Entities :" << '\n'; + } ListEntities(evres->Entities(numpack), (mode ? 2 : -1), sout); } if (mode == 0) + { return; + } if (mode == 1 || mode == 3) { - sout << std::endl; + sout << '\n'; if (evres->NbDuplicated(0, false) == 0) - sout << " **** All the Model is taken into account ****" << std::endl; + { + sout << " **** All the Model is taken into account ****" << '\n'; + } else { - sout << " **** Starting Entities Forgotten ****" << std::endl; + sout << " **** Starting Entities Forgotten ****" << '\n'; ListEntities(evres->Duplicated(0, false), 2, sout); } } if (mode >= 2) { - sout << " **** Entites in more than one packet ****" << std::endl; + sout << " **** Entites in more than one packet ****" << '\n'; int max = evres->HighestDuplicationCount(); if (max < 2) - sout << " : There are none" << std::endl; + { + sout << " : There are none" << '\n'; + } else { int newcount; - sout << std::endl; + sout << '\n'; for (newcount = 2; newcount <= max; newcount++) { if (evres->NbDuplicated(newcount, false) == 0) + { continue; - sout << " **** Entities put in " << newcount << " packets ****" << std::endl; + } + sout << " **** Entities put in " << newcount << " packets ****" << '\n'; ListEntities(evres->Duplicated(newcount, false), 2, sout); } } @@ -3776,10 +4514,12 @@ void IFSelect_WorkSession::ListEntities(const Interface_EntityIterator& iter, int titre = 0; int mode = (mmode < 0 ? -mmode : mmode); if (mmode >= 0) - sout << " List of " << iter.NbEntities() << " Entities :" << std::endl; + { + sout << " List of " << iter.NbEntities() << " Entities :" << '\n'; + } if (!IsLoaded()) { - sout << " *** Data for List not available ***" << std::endl; + sout << " *** Data for List not available ***" << '\n'; return; } Interface_ShareFlags tool(thegraph->Graph()); @@ -3793,13 +4533,19 @@ void IFSelect_WorkSession::ListEntities(const Interface_EntityIterator& iter, for (iter.Start(); iter.More(); iter.Next()) { if (!titre && mode == 1) + { sout << "Number/Id. Category Validity Type\n----------- ----...." - << std::endl; + << '\n'; + } // 123456789 123456789 123456 123456789 123456789 123456 if (!titre && mode == 0) - sout << " Keys : R Root ? Unknown * Unloaded" << std::endl; + { + sout << " Keys : R Root ? Unknown * Unloaded" << '\n'; + } if (!titre && mode == 2) + { sout << "("; + } titre = 1; const occ::handle& ent = iter.Value(); int num = myModel->Number(ent); @@ -3809,21 +4555,29 @@ void IFSelect_WorkSession::ListEntities(const Interface_EntityIterator& iter, sout << Interface_MSG::Blanks(num, 6); myModel->Print(ent, sout, 0); if (!tool.IsShared(ent)) + { sout << " #ROOT#"; + } else + { sout << " "; + } int catnum = myModel->CategoryNumber(num); if (catnum > 0) + { sout << " " << Interface_Category::Name(catnum); + } sout << " (" << ValidityName(ent) << ") "; - sout << " Type:" << myModel->TypeName(ent, false) << std::endl; + sout << " Type:" << myModel->TypeName(ent, false) << '\n'; } else if (mode == 2) { newcount++; if (newcount > 0) + { sout << ","; + } sout << num; } else @@ -3833,16 +4587,20 @@ void IFSelect_WorkSession::ListEntities(const Interface_EntityIterator& iter, cnt++; if (newcount >= 10) { - sout << std::endl << "[" << cnt << "]:"; + sout << '\n' << "[" << cnt << "]:"; newcount = 1; } if (newcount > 0) + { sout << " "; + } myModel->Print(ent, sout, 0); if (!tool.IsShared(ent)) { if (mods == 0) + { sout << "("; + } sout << "R"; mods++; } @@ -3864,14 +4622,18 @@ void IFSelect_WorkSession::ListEntities(const Interface_EntityIterator& iter, } } if (mode == 0) - sout << std::endl; + { + sout << '\n'; + } if (mode == 2) - sout << ")" << std::endl; + { + sout << ")" << '\n'; + } } catch (Standard_Failure const& anException) { sout << " **** ListEntities Interrupted by Exception : ****\n"; sout << anException.what(); - sout << "\n Abandon" << std::endl; + sout << "\n Abandon" << '\n'; } } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_BitMap.cxx b/src/DataExchange/TKXSBase/Interface/Interface_BitMap.cxx index 5f49326f5c..af9477228d 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_BitMap.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_BitMap.cxx @@ -63,14 +63,20 @@ void Interface_BitMap::Reservate(const int moreflags) int nb = theflags->Upper(); int nbflags = nb / thenbwords - 1; // flag 0 not counted ... if (nbflags >= thenbflags + moreflags) + { return; + } int nbw = thenbwords * (thenbflags + moreflags + 2); occ::handle> flags = new NCollection_HArray1(0, nbw); int i; // svv Jan11 2000 : porting on DEC for (i = 0; i <= nb; i++) + { flags->SetValue(i, theflags->Value(i)); + } for (i = nb + 1; i <= nbw; i++) + { flags->SetValue(i, 0); + } theflags = flags; } @@ -78,17 +84,23 @@ void Interface_BitMap::SetLength(const int nbitems) { int nbw = nbitems / 32 + 1; if (nbw == thenbwords) + { return; + } occ::handle> flags = new NCollection_HArray1(0, nbw * (thenbflags + 1)); if (nbw > thenbwords) + { flags->Init(0); + } int nbmots = (nbw > thenbwords ? thenbwords : nbw); int i0 = 0, i1 = 0; for (int nf = 0; nf <= thenbflags; nf++) { for (int i = 0; i < nbmots; i++) + { flags->SetValue(i1 + i, theflags->Value(i0 + i)); + } i0 += thenbwords; i1 += nbw; } @@ -102,7 +114,9 @@ int Interface_BitMap::AddFlag(const char* const name) Reservate(1); int deja = 0; if (thenames.IsNull()) + { thenames = new NCollection_HSequence(); + } else { int i, nb = thenames->Length(); @@ -116,7 +130,9 @@ int Interface_BitMap::AddFlag(const char* const name) } } if (!deja) + { thenames->Append(TCollection_AsciiString(name)); + } thenbflags++; return (deja ? deja : thenbflags); } @@ -125,9 +141,13 @@ int Interface_BitMap::AddSomeFlags(const int more) { Reservate(more); if (thenames.IsNull()) + { thenames = new NCollection_HSequence(); + } for (int i = 1; i <= more; i++) + { thenames->Append(TCollection_AsciiString("")); + } thenbflags += more; return thenbflags; } @@ -135,11 +155,17 @@ int Interface_BitMap::AddSomeFlags(const int more) bool Interface_BitMap::RemoveFlag(const int num) { if (num < 1 || num > thenames->Length()) + { return false; + } if (num == thenames->Length()) + { thenames->Remove(thenames->Length()); + } else + { thenames->ChangeValue(num).AssignCat("."); + } thenbflags--; return true; } @@ -147,10 +173,14 @@ bool Interface_BitMap::RemoveFlag(const int num) bool Interface_BitMap::SetFlagName(const int num, const char* const name) { if (num < 1 || num > thenames->Length()) + { return false; + } int deja = (name[0] == '\0' ? 0 : FlagNumber(name)); if (deja != 0 && deja != num) + { return false; + } thenames->ChangeValue(num).AssignCat(name); return true; } @@ -168,22 +198,34 @@ int Interface_BitMap::Length() const const char* Interface_BitMap::FlagName(const int num) const { if (theflags.IsNull()) + { return ""; + } if (num < 1 || num > thenames->Length()) + { return ""; + } return thenames->Value(num).ToCString(); } int Interface_BitMap::FlagNumber(const char* const name) const { if (name[0] == '\0') + { return 0; + } if (thenames.IsNull()) + { return 0; + } int i, nb = thenames->Length(); for (i = 1; i <= nb; i++) + { if (thenames->Value(i).IsEqual(name)) + { return i; + } + } return 0; } @@ -194,9 +236,13 @@ bool Interface_BitMap::Value(const int item, const int flag) const int numw = (thenbwords * flag) + (item >> 5); const int& val = theflags->Value(numw); if (val == 0) + { return false; + } if (val == ~(0)) + { return true; + } int numb = item & 31; return (((1 << numb) & val) != 0); } @@ -204,9 +250,13 @@ bool Interface_BitMap::Value(const int item, const int flag) const void Interface_BitMap::SetValue(const int item, const bool val, const int flag) const { if (val) + { SetTrue(item, flag); + } else + { SetFalse(item, flag); + } } void Interface_BitMap::SetTrue(const int item, const int flag) const @@ -221,7 +271,9 @@ void Interface_BitMap::SetFalse(const int item, const int flag) const int numw = (thenbwords * flag) + (item >> 5); int& val = theflags->ChangeValue(numw); if (val == 0) + { return; + } int numb = item & 31; theflags->ChangeValue(numw) &= ~(1 << numb); } @@ -275,11 +327,19 @@ void Interface_BitMap::Init(const bool val, const int flag) const ii = thenbwords * (thenbflags + 1); } if (val) + { for (i = 0; i < ii; i++) + { theflags->SetValue(i1 + i, ~(0)); + } + } else + { for (i = 0; i < ii; i++) + { theflags->SetValue(i1 + i, 0); + } + } } void Interface_BitMap::Clear() diff --git a/src/DataExchange/TKXSBase/Interface/Interface_Category.cxx b/src/DataExchange/TKXSBase/Interface/Interface_Category.cxx index eeca4fdc5c..d4fd7a6e93 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_Category.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_Category.cxx @@ -46,11 +46,15 @@ int Interface_Category::CatNum(const occ::handle& theEnt, const Interface_ShareTool& theShares) { if (theEnt.IsNull()) + { return 0; + } int CN; occ::handle aModule; if (!myGTool->Select(theEnt, aModule, CN)) + { return 0; + } return aModule->CategoryNumber(CN, theEnt, theShares); } @@ -59,21 +63,29 @@ void Interface_Category::Compute(const occ::handle& th { ClearNums(); if (theModel.IsNull()) + { return; + } int CN, i, nb = theModel->NbEntities(); myGTool->Reservate(nb); if (nb == 0) + { return; + } myNum = new NCollection_HArray1(1, nb); myNum->Init(0); for (i = 1; i <= nb; i++) { occ::handle anEnt = theModel->Value(i); if (anEnt.IsNull()) + { continue; + } occ::handle aModule; if (!myGTool->Select(anEnt, aModule, CN)) + { continue; + } myNum->SetValue(i, aModule->CategoryNumber(CN, anEnt, theShares)); } } @@ -81,9 +93,13 @@ void Interface_Category::Compute(const occ::handle& th int Interface_Category::Num(const int theNumEnt) const { if (myNum.IsNull()) + { return 0; + } if (theNumEnt < 1 || theNumEnt > myNum->Length()) + { return 0; + } return myNum->Value(theNumEnt); } @@ -93,7 +109,9 @@ int Interface_Category::AddCategory(const char* const theName) { int aNum = Interface_Category::Number(theName); if (aNum > 0) + { return aNum; + } theCats().Append(TCollection_AsciiString(theName)); return theCats().Length() + 1; } @@ -106,9 +124,13 @@ int Interface_Category::NbCategories() const char* Interface_Category::Name(const int theNum) { if (theNum < 0) + { return ""; + } if (theNum < theCats().Lower() || theNum > theCats().Upper()) + { return unspec; + } return theCats().ChangeValue(theNum).ToCString(); } @@ -118,7 +140,9 @@ int Interface_Category::Number(const char* const theName) for (i = theCats().Lower(); i <= theCats().Upper(); i++) { if (theCats().ChangeValue(i).IsEqual(theName)) + { return i; + } } return 0; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_Check.cxx b/src/DataExchange/TKXSBase/Interface/Interface_Check.cxx index f4a36fa9c5..73bbb024a8 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_Check.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_Check.cxx @@ -49,9 +49,13 @@ void Interface_Check::SendFail(const Message_Msg& amsg) void Interface_Check::AddFail(const occ::handle& mess) { if (thefails.IsNull()) + { thefails = new NCollection_HSequence>(); + } if (thefailo.IsNull()) + { thefailo = new NCollection_HSequence>(); + } thefails->Append(mess); thefailo->Append(mess); } @@ -62,9 +66,13 @@ void Interface_Check::AddFail(const occ::handle& mess, const occ::handle& orig) { if (thefails.IsNull()) + { thefails = new NCollection_HSequence>(); + } if (thefailo.IsNull()) + { thefailo = new NCollection_HSequence>(); + } thefails->Append(mess); thefailo->Append(orig); } @@ -74,11 +82,17 @@ void Interface_Check::AddFail(const occ::handle& mess, void Interface_Check::AddFail(const char* const amess, const char* const orig) { if (amess[0] == '\0') + { return; + } if (!orig || orig[0] == '\0') + { AddFail(new TCollection_HAsciiString(amess)); + } else + { AddFail(new TCollection_HAsciiString(amess), new TCollection_HAsciiString(orig)); + } } //================================================================================================= @@ -86,10 +100,14 @@ void Interface_Check::AddFail(const char* const amess, const char* const orig) void Interface_Check::AddFail(const Message_Msg& amsg) { if (amsg.IsEdited()) + { AddFail(new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())), new TCollection_HAsciiString(TCollection_AsciiString(amsg.Original()))); + } else + { AddFail(new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value()))); + } } //================================================================================================= @@ -112,7 +130,9 @@ const occ::handle& Interface_Check::Fail(const int nu const bool final) const { if (thefails.IsNull()) + { throw Standard_OutOfRange(); + } return (final ? thefails->Value(num) : thefailo->Value(num)); } @@ -129,7 +149,9 @@ occ::handle>> Interf const bool final) const { if (thefails.IsNull()) + { return new NCollection_HSequence>(); + } return (final ? thefails : thefailo); } @@ -147,9 +169,13 @@ void Interface_Check::SendWarning(const Message_Msg& amsg) void Interface_Check::AddWarning(const occ::handle& mess) { if (thewarns.IsNull()) + { thewarns = new NCollection_HSequence>(); + } if (thewarno.IsNull()) + { thewarno = new NCollection_HSequence>(); + } thewarns->Append(mess); thewarno->Append(mess); } @@ -160,9 +186,13 @@ void Interface_Check::AddWarning(const occ::handle& me const occ::handle& orig) { if (thewarns.IsNull()) + { thewarns = new NCollection_HSequence>(); + } if (thewarno.IsNull()) + { thewarno = new NCollection_HSequence>(); + } thewarns->Append(mess); thewarno->Append(orig); } @@ -172,11 +202,17 @@ void Interface_Check::AddWarning(const occ::handle& me void Interface_Check::AddWarning(const char* const amess, const char* const orig) { if (amess[0] == '\0') + { return; + } if (!orig || orig[0] == '\0') + { AddWarning(new TCollection_HAsciiString(amess)); + } else + { AddWarning(new TCollection_HAsciiString(amess), new TCollection_HAsciiString(orig)); + } } //================================================================================================= @@ -184,10 +220,14 @@ void Interface_Check::AddWarning(const char* const amess, const char* const orig void Interface_Check::AddWarning(const Message_Msg& amsg) { if (amsg.IsEdited()) + { AddWarning(new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())), new TCollection_HAsciiString(TCollection_AsciiString(amsg.Original()))); + } else + { AddWarning(new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value()))); + } } //================================================================================================= @@ -210,7 +250,9 @@ const occ::handle& Interface_Check::Warning(const int const bool final) const { if (thewarns.IsNull()) + { throw Standard_OutOfRange(); + } return (final ? thewarns->Value(num) : thewarno->Value(num)); } @@ -227,7 +269,9 @@ occ::handle>> Interf const bool final) const { if (thewarns.IsNull()) + { return new NCollection_HSequence>(); + } return (final ? thewarns : thewarno); } @@ -240,12 +284,18 @@ void Interface_Check::SendMsg(const Message_Msg& amsg) occ::handle mess = new TCollection_HAsciiString(amsg.Value()); occ::handle orig = mess; if (amsg.IsEdited()) + { orig = new TCollection_HAsciiString(amsg.Original()); + } if (theinfos.IsNull()) + { theinfos = new NCollection_HSequence>(); + } if (theinfoo.IsNull()) + { theinfoo = new NCollection_HSequence>(); + } theinfos->Append(mess); theinfoo->Append(mess); } @@ -263,7 +313,9 @@ const occ::handle& Interface_Check::InfoMsg(const int const bool final) const { if (theinfos.IsNull()) + { throw Standard_OutOfRange(); + } return (final ? theinfos->Value(num) : theinfoo->Value(num)); } @@ -280,7 +332,9 @@ occ::handle>> Interf const bool final) const { if (theinfos.IsNull()) + { return new NCollection_HSequence>(); + } return (final ? theinfos : theinfoo); } @@ -291,9 +345,13 @@ occ::handle>> Interf Interface_CheckStatus Interface_Check::Status() const { if (!thefails.IsNull()) + { return Interface_CheckFail; + } if (!thewarns.IsNull()) + { return Interface_CheckWarning; + } return Interface_CheckOK; } @@ -330,7 +388,9 @@ bool Interface_Check::Complies(const occ::handle& mess const Interface_CheckStatus status) const { if (mess.IsNull()) + { return false; + } int lng = mess->Length(); if (status == Interface_CheckWarning || status == Interface_CheckAny) { @@ -341,17 +401,23 @@ bool Interface_Check::Complies(const occ::handle& mess if (incl == 0) { if (mess->IsSameString(ames)) + { return true; + } } if (incl < 0) { if (ames->Location(mess, 1, ames->Length()) > 0) + { return true; + } } if (incl < 0) { if (mess->Location(mess, 1, lng) > 0) + { return true; + } } } } @@ -364,17 +430,23 @@ bool Interface_Check::Complies(const occ::handle& mess if (incl == 0) { if (mess->IsSameString(ames)) + { return true; + } } if (incl < 0) { if (ames->Location(mess, 1, ames->Length()) > 0) + { return true; + } } if (incl < 0) { if (mess->Location(mess, 1, lng) > 0) + { return true; + } } } } @@ -439,7 +511,9 @@ bool Interface_Check::Remove(const occ::handle& mess, const Interface_CheckStatus status) { if (mess.IsNull()) + { return false; + } bool res = false; int lng = mess->Length(); if (status == Interface_CheckWarning || status == Interface_CheckAny) @@ -450,11 +524,17 @@ bool Interface_Check::Remove(const occ::handle& mess, bool rem = false; occ::handle ames = Warning(i); if (incl == 0) + { rem = mess->IsSameString(ames); + } if (incl < 0) + { rem = (ames->Location(mess, 1, ames->Length()) > 0); + } if (incl < 0) + { rem = (mess->Location(mess, 1, lng) > 0); + } if (rem) { thewarns->Remove(i); @@ -471,11 +551,17 @@ bool Interface_Check::Remove(const occ::handle& mess, bool rem = false; occ::handle ames = Warning(i); if (incl == 0) + { rem = mess->IsSameString(ames); + } if (incl < 0) + { rem = (ames->Location(mess, 1, ames->Length()) > 0); + } if (incl < 0) + { rem = (mess->Location(mess, 1, lng) > 0); + } if (rem) { thefails->Remove(i); @@ -495,7 +581,9 @@ bool Interface_Check::Mend(const char* const pref, const int num) if (pref && pref[2] == '\0') { if (pref[0] == 'F' && pref[1] == 'M') + { return Mend("Mended", num); + } if (pref[0] == 'C' && pref[1] == 'A') { Clear(); @@ -509,7 +597,9 @@ bool Interface_Check::Mend(const char* const pref, const int num) return true; } if (num < 0 || num > NbWarnings()) + { return false; + } thewarns->Remove(num); thewarno->Remove(num); return true; @@ -522,7 +612,9 @@ bool Interface_Check::Mend(const char* const pref, const int num) return true; } if (num < 0 || num > NbFails()) + { return false; + } thefails->Remove(num); thefailo->Remove(num); return true; @@ -534,11 +626,15 @@ bool Interface_Check::Mend(const char* const pref, const int num) n1 = 1; n2 = NbFails(); for (i = n2; i >= n1; i--) + { Mend(pref, i); + } return true; } else if (num < 0 || num > NbFails()) + { return false; + } // A message occ::handle strf = thefails->Value(num); occ::handle stro = thefailo->Value(num); @@ -555,9 +651,13 @@ bool Interface_Check::Mend(const char* const pref, const int num) thefails->Remove(num); thefailo->Remove(num); if (stro == strf) + { AddFail(strf); + } else + { AddFail(strf, stro); + } return true; } @@ -573,7 +673,9 @@ void Interface_Check::SetEntity(const occ::handle& anentity) void Interface_Check::GetEntity(const occ::handle& anentity) { if (theent.IsNull()) + { SetEntity(anentity); + } } // .. GetMessages, takes messages by accumulating them with its own @@ -590,35 +692,59 @@ void Interface_Check::GetMessages(const occ::handle& other) if ((nb = other->NbFails()) != 0) { if (thefails.IsNull()) + { thefails = new NCollection_HSequence>(); + } if (thefailo.IsNull()) + { thefailo = new NCollection_HSequence>(); + } for (i = 1; i <= nb; i++) + { thefails->Append(other->Fail(i, true)); + } for (i = 1; i <= nb; i++) + { thefailo->Append(other->Fail(i, false)); + } } if ((nb = other->NbWarnings()) != 0) { if (thewarns.IsNull()) + { thewarns = new NCollection_HSequence>(); + } if (thewarno.IsNull()) + { thewarno = new NCollection_HSequence>(); + } for (i = 1; i <= nb; i++) + { thewarns->Append(other->Warning(i, true)); + } for (i = 1; i <= nb; i++) + { thewarno->Append(other->Warning(i, false)); + } } if ((nb = other->NbInfoMsgs()) != 0) { if (theinfos.IsNull()) + { theinfos = new NCollection_HSequence>(); + } if (theinfoo.IsNull()) + { theinfoo = new NCollection_HSequence>(); + } for (i = 1; i <= nb; i++) + { theinfos->Append(other->InfoMsg(i, true)); + } for (i = 1; i <= nb; i++) + { theinfoo->Append(other->InfoMsg(i, false)); + } } } @@ -630,24 +756,40 @@ void Interface_Check::GetAsWarning(const occ::handle& other, co if ((nb = other->NbFails()) != 0) { if (thewarns.IsNull()) + { thewarns = new NCollection_HSequence>(); + } if (thewarno.IsNull()) + { thewarno = new NCollection_HSequence>(); + } for (i = 1; i <= nb; i++) + { thewarns->Append(other->Fail(i, true)); + } for (i = 1; i <= nb; i++) + { thewarno->Append(other->Fail(i, false)); + } } if ((nb = other->NbWarnings()) != 0 || !failsonly) { if (thewarns.IsNull()) + { thewarns = new NCollection_HSequence>(); + } if (thewarno.IsNull()) + { thewarno = new NCollection_HSequence>(); + } for (i = 1; i <= nb; i++) + { thewarns->Append(other->Warning(i, true)); + } for (i = 1; i <= nb; i++) + { thewarno->Append(other->Warning(i, false)); + } } } @@ -664,9 +806,13 @@ void Interface_Check::Print(Standard_OStream& S, const int level, const int fina for (j = 1; j <= nb; j++) { if (final >= 0) + { S << CFail(j, true) << "\n"; + } else + { S << CFail(j, false) << "\n"; + } // if (final == 0) // if (Fail(j,true) != Fail(j,false)) // S<<"[original:"<= 0) + { S << CWarning(j, true) << "\n"; + } else + { S << CWarning(j, false) << "\n"; + } // if (final == 0) // if (Warning(j,true) != Warning(j,false)) // S<<"[original:"<= 0) + { S << CInfoMsg(j, true) << "\n"; + } else + { S << CInfoMsg(j, false) << "\n"; + } // if (final == 0) // if (InfoMsg(j,true) != InfoMsg(j,false)) // S<<"[original:"<& ach, const { // Add -> accumulate Checks if (ach->NbWarnings() + ach->NbFails() == 0) + { return; + } int nm = num; if (num <= 0 && ach->HasEntity()) { @@ -103,20 +109,26 @@ void Interface_CheckIterator::Add(const occ::handle& ach, const { nm = themod->Number(ach->Entity()); if (nm <= 0) + { nm = -1; + } } else + { nm = -1; + } } if (nm >= 0 && nm <= -(thecurr->Value())) { int i, numpos = 0, nb = thelist->Length(); for (i = nb; i > 0; i--) + { if (thenums->Value(i) == nm) { numpos = i; break; } + } if (numpos > 0 && nm >= 0) { occ::handle lch = thelist->ChangeValue(numpos); @@ -146,7 +158,9 @@ const occ::handle& Interface_CheckIterator::Check(const int num for (i = 1; i <= nb; i++) { if (num == thenums->Value(i)) + { return thelist->Value(i); + } } return nulcheck(); } @@ -158,15 +172,21 @@ const occ::handle& Interface_CheckIterator::Check( { int num = -1; if (!themod.IsNull()) + { num = themod->Number(ent); + } if (num > 0) + { return Check(num); + } int i, nb = thelist->Length(); for (i = 1; i <= nb; i++) { if (ent == thelist->Value(i)->Entity()) + { return thelist->Value(i); + } } return nulcheck(); } @@ -179,7 +199,9 @@ occ::handle& Interface_CheckIterator::CCheck(const int num) for (i = 1; i <= nb; i++) { if (num == thenums->Value(i)) + { return thelist->ChangeValue(i); + } } occ::handle ach = new Interface_Check; thelist->Append(ach); @@ -194,15 +216,21 @@ occ::handle& Interface_CheckIterator::CCheck( { int num = -1; if (!themod.IsNull()) + { num = themod->Number(ent); + } if (num > 0) + { return CCheck(num); + } int i, nb = thelist->Length(); for (i = 1; i <= nb; i++) { if (ent == thelist->Value(i)->Entity()) + { return thelist->ChangeValue(i); + } } occ::handle ach = new Interface_Check; @@ -216,14 +244,20 @@ occ::handle& Interface_CheckIterator::CCheck( bool Interface_CheckIterator::IsEmpty(const bool failsonly) const { if (thelist->IsEmpty()) + { return true; + } if (!failsonly) + { return false; + } int i, nb = thelist->Length(); for (i = 1; i <= nb; i++) { if (thelist->Value(i)->HasFailed()) + { return false; + } } return true; } @@ -238,9 +272,13 @@ Interface_CheckStatus Interface_CheckIterator::Status() const { const occ::handle ach = thelist->Value(i); if (ach->HasFailed()) + { return Interface_CheckFail; + } if (ach->NbWarnings() > 0) + { stat = Interface_CheckWarning; + } } return stat; } @@ -343,7 +381,9 @@ Interface_CheckIterator Interface_CheckIterator::Extract(const Interface_CheckSt break; } if (prend) + { res.Add(ach, thenums->Value(i)); + } } return res; } @@ -363,7 +403,9 @@ Interface_CheckIterator Interface_CheckIterator::Extract(const char* const { const occ::handle ach = thelist->Value(i); if (ach->Complies(str, incl, stat)) + { res.Add(ach, thenums->Value(i)); + } } return res; } @@ -381,7 +423,9 @@ bool Interface_CheckIterator::Remove(const char* const mess, { occ::handle ach = thelist->ChangeValue(i); if (ach->Remove(str, incl, stat)) + { res = true; + } } return res; } @@ -393,21 +437,31 @@ occ::handle>> Interface_Ch { occ::handle>> list; if (themod.IsNull()) + { return list; + } list = new NCollection_HSequence>(); int num, i, nb = thelist->Length(); for (i = 1; i <= nb; i++) { const occ::handle chk = thelist->Value(i); if (failsonly && !chk->HasFailed()) + { continue; + } if (chk->NbWarnings() == 0) + { continue; + } num = thenums->Value(i); if (num == 0 && global) + { list->Append(themod); + } else if (num > 0) + { list->Append(themod->Value(num)); + } } return list; } @@ -424,7 +478,9 @@ void Interface_CheckIterator::Start() const bool Interface_CheckIterator::More() const { if (thecurr->Value() < 0) + { thecurr->CValue() = 1; + } return (thecurr->Value() <= thelist->Length()); } @@ -433,7 +489,9 @@ bool Interface_CheckIterator::More() const void Interface_CheckIterator::Next() const { if (thecurr->Value() < 0) + { thecurr->CValue() = 1; + } thecurr->CValue()++; } @@ -442,7 +500,9 @@ void Interface_CheckIterator::Next() const const occ::handle& Interface_CheckIterator::Value() const { if (thecurr->Value() > thelist->Length()) + { throw Standard_NoSuchObject("Interface Check Iterator : Value"); + } return thelist->Value(thecurr->Value()); } @@ -451,7 +511,9 @@ const occ::handle& Interface_CheckIterator::Value() const int Interface_CheckIterator::Number() const { if (thecurr->Value() > thenums->Length()) + { throw Standard_NoSuchObject("Interface Check Iterator : Value"); + } return thenums->Value(thecurr->Value()); } @@ -483,33 +545,51 @@ void Interface_CheckIterator::Print(Standard_OStream& const occ::handle ach = thelist->Value(i); int nbw = 0, nbf = ach->NbFails(); if (!failsonly) + { nbw = ach->NbWarnings(); + } if (nbf + nbw == 0) + { continue; + } occ::handle ent = ach->Entity(); int nm0 = thenums->Value(i); bool entnul = ent.IsNull(); int num = nm0; if (nm0 <= 0 && !entnul && yamod) + { num = model->Number(ent); + } if (nm0 <= 0 && entnul) + { num = -1; // Global - // mesnum = mesnum0; - // if (yamod) mesnum = (nm0 > 0 ? mesnum1 : mesnum2); + } + // mesnum = mesnum0; + // if (yamod) mesnum = (nm0 > 0 ? mesnum1 : mesnum2); if (!titre) - S << " ** " << Name() << " **" << std::endl; + { + S << " ** " << Name() << " **" << '\n'; + } titre = true; S << "Check:"; if (nb > 9 && i < 10) + { S << " "; + } if (nb > 99 && i < 100) + { S << " "; + } S << i; if (num < 0) - S << " -- Global Check" << std::endl; + { + S << " -- Global Check" << '\n'; + } else if (num == 0) + { S << " -- Entity n0 ??:"; + } else { if (yamod) @@ -518,18 +598,26 @@ void Interface_CheckIterator::Print(Standard_OStream& model->Print(ent, S); } else + { S << " -- Entity n0 " << num; + } // S<<" -- Entity n0 "<PrintLabel(ent,S); } if (num >= 0 && entnul) - S << " (unknown Type)" << std::endl; + { + S << " (unknown Type)" << '\n'; + } else if (num >= 0 && !entnul) { if (yamod) - S << " Type:" << model->TypeName(ent) << std::endl; + { + S << " Type:" << model->TypeName(ent) << '\n'; + } else - S << " Type:" << ent->DynamicType()->Name() << std::endl; + { + S << " Type:" << ent->DynamicType()->Name() << '\n'; + } } ach->Print(S, (failsonly ? 1 : 3)); diff --git a/src/DataExchange/TKXSBase/Interface/Interface_CheckTool.cxx b/src/DataExchange/TKXSBase/Interface/Interface_CheckTool.cxx index c42be35a42..e82bdaedb3 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_CheckTool.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_CheckTool.cxx @@ -126,11 +126,15 @@ void Interface_CheckTool::FillCheck(const occ::handle& ent, { DeclareAndCast(Interface_ReportEntity, rep, ent); if (rep.IsNull()) + { return; + } ach = rep->Check(); } if (theshare.Graph().HasShareErrors(ent)) + { ach->AddFail("** Shared Items unknown from the containing Model"); + } } //================================================================================================= @@ -140,14 +144,18 @@ void Interface_CheckTool::Print(const occ::handle& ach, Standar int i, nb; nb = ach->NbFails(); if (nb > 0) + { S << " Fail Messages : " << nb << " :\n"; + } for (i = 1; i <= nb; i++) { S << ach->Fail(i)->String() << "\n"; } nb = ach->NbWarnings(); if (nb > 0) + { S << " Warning Messages : " << nb << " :\n"; + } for (i = 1; i <= nb; i++) { S << ach->Warning(i)->String() << "\n"; @@ -185,44 +193,64 @@ occ::handle Interface_CheckTool::Check(const int num) void Interface_CheckTool::CheckSuccess(const bool reset) { if (reset) + { thestat = 0; + } if (thestat > 3) + { throw Interface_CheckFailure // already tested with error ("Interface Model : Global Check"); + } occ::handle model = theshare.Model(); if (model->GlobalCheck()->NbFails() > 0) + { throw Interface_CheckFailure("Interface Model : Global Check"); + } occ::handle modchk = new Interface_Check; model->VerifyCheck(modchk); if (!model->Protocol().IsNull()) + { model->Protocol()->GlobalCheck(theshare.Graph(), modchk); + } if (modchk->HasFailed()) + { throw Interface_CheckFailure("Interface Model : Verify Check"); + } if (thestat == 3) + { return; // everything tested and it passes + } errh = 0; // No try/catch, because we precisely raise int nb = model->NbEntities(); for (int i = 1; i <= nb; i++) { if (model->IsErrorEntity(i)) + { throw Interface_CheckFailure("Interface Model : an Entity is recorded as Erroneous"); + } occ::handle ent = model->Value(i); if (thestat & 1) { if (!model->IsErrorEntity(i)) + { continue; // already verify, remains analyse + } } if (thestat & 2) { if (model->IsErrorEntity(i)) + { continue; // already analyse, remains verify + } } occ::handle ach = new Interface_Check(ent); FillCheck(ent, theshare, ach); if (ach->HasFailed()) + { throw Interface_CheckFailure("Interface Model : Check on an Entity has Failed"); + } } } @@ -239,12 +267,18 @@ Interface_CheckIterator Interface_CheckTool::CompleteCheckList() res.SetModel(model); occ::handle globch = model->GlobalCheck(); // GlobalCheck Statique if (!model->Protocol().IsNull()) + { model->Protocol()->GlobalCheck(theshare.Graph(), globch); + } model->VerifyCheck(globch); // GlobalCheck Dynamique if (globch->HasFailed() || globch->HasWarnings()) + { res.Add(globch, 0); + } if (globch->HasFailed()) + { thestat |= 12; + } int i = 0, n0 = 1, nb = model->NbEntities(); errh = 0; @@ -272,15 +306,21 @@ Interface_CheckIterator Interface_CheckTool::CompleteCheckList() } } if (!model->HasSemanticChecks()) + { FillCheck(ent, theshare, ach); + } else + { ach->GetMessages(model->Check(i, false)); + } if (ach->HasFailed() || ach->HasWarnings()) { res.Add(ach, i); ach = new Interface_Check; if (ach->HasFailed()) + { thestat |= 12; + } } } n0 = nb + 1; @@ -309,7 +349,9 @@ Interface_CheckIterator Interface_CheckTool::CheckList() int i = 0, n0 = 1, nb = model->NbEntities(); occ::handle globch = model->GlobalCheck(); if (!model->Protocol().IsNull()) + { model->Protocol()->GlobalCheck(theshare.Graph(), globch); + } model->VerifyCheck(globch); if (globch->HasFailed()) { @@ -342,9 +384,13 @@ Interface_CheckIterator Interface_CheckTool::CheckList() ach->Clear(); ach->SetEntity(ent); if (!model->HasSemanticChecks()) + { FillCheck(ent, theshare, ach); + } else + { ach = model->Check(i, false); + } if (ach->HasFailed()) { thestat |= 12; @@ -387,7 +433,9 @@ Interface_CheckIterator Interface_CheckTool::AnalyseCheckList() for (i = n0; i <= nb; i++) { if (!model->IsReportEntity(i)) + { continue; + } occ::handle rep = model->ReportEntity(i); ach = rep->Check(); if (ach->HasFailed() || ach->HasWarnings()) @@ -432,14 +480,20 @@ Interface_CheckIterator Interface_CheckTool::VerifyCheckList() for (i = n0; i <= nb; i++) { if (model->IsErrorEntity(i)) + { continue; + } ent = model->Value(i); ach->Clear(); ach->SetEntity(ent); if (!model->HasSemanticChecks()) + { FillCheck(ent, theshare, ach); + } else + { ach = model->Check(i, false); + } if (ach->HasFailed() || ach->HasWarnings()) { thestat |= 4; @@ -495,13 +549,21 @@ Interface_CheckIterator Interface_CheckTool::WarningCheckList() } ent = model->Value(i); if (!model->HasSemanticChecks()) + { FillCheck(ent, theshare, ach); + } else + { ach = model->Check(i, false); + } if (ach->HasFailed()) + { thestat |= 12; + } else if (ach->HasWarnings()) + { res.Add(ach, i); + } } n0 = nb + 1; } @@ -527,7 +589,9 @@ Interface_EntityIterator Interface_CheckTool::UnknownEntities() for (int i = 1; i <= nb; i++) { if (model->IsUnknownEntity(i)) + { res.GetOneItem(model->Value(i)); + } } return res; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_CopyMap.cxx b/src/DataExchange/TKXSBase/Interface/Interface_CopyMap.cxx index 33bb554961..b0c6669917 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_CopyMap.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_CopyMap.cxx @@ -31,7 +31,9 @@ void Interface_CopyMap::Clear() int nb = theres.Upper(); occ::handle bid; // Null for (int i = 1; i <= nb; i++) + { theres.SetValue(i, bid); + } } occ::handle Interface_CopyMap::Model() const @@ -44,10 +46,14 @@ void Interface_CopyMap::Bind(const occ::handle& ent, { int num = themod->Number(ent); if (num == 0 || num > theres.Upper()) + { throw Interface_InterfaceError( "CopyMap : Bind, Starting Entity not issued from Starting Model"); + } if (!theres.Value(num).IsNull()) + { throw Interface_InterfaceError("CopyMap : Bind, Starting Entity already bound"); + } theres.SetValue(num, res); } @@ -56,7 +62,9 @@ bool Interface_CopyMap::Search(const occ::handle& ent, { int num = themod->Number(ent); if (num == 0) + { return false; + } res = theres.Value(num); return (!res.IsNull()); } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_CopyTool.cxx b/src/DataExchange/TKXSBase/Interface/Interface_CopyTool.cxx index 0f4c91aaf1..4a4dd8316c 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_CopyTool.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_CopyTool.cxx @@ -66,7 +66,9 @@ Interface_CopyTool::Interface_CopyTool(const occ::handleNbEntities()) { if (Interface_Protocol::Active().IsNull()) + { throw Interface_InterfaceError("Interface CopyTool : Create with Active Protocol undefined"); + } thelst.Init(false); themod = amodel; @@ -110,15 +112,21 @@ bool Interface_CopyTool::NewVoid(const occ::handle& entfrom, if (entfrom == theent) { if (themdu.IsNull()) + { return false; + } return themdu->NewVoid(theCN, entto); } theent = entfrom; bool res = thelib.Select(entfrom, themdu, theCN); if (res) + { res = themdu->NewVoid(theCN, entto); + } if (!res) + { res = themdu->NewCopiedCase(theCN, entfrom, entto, *this); + } // if (!res) entto = entfrom->ShallowCopy(); sorry, nothing more possible return res; } @@ -132,7 +140,9 @@ bool Interface_CopyTool::Copy(const occ::handle& entfrom, if (entfrom == theent) { if (themdu.IsNull()) + { res = false; + } } else { @@ -143,7 +153,9 @@ bool Interface_CopyTool::Copy(const occ::handle& entfrom, { // Built-in : if (entfrom.IsNull()) + { return res; + } if (entfrom->DynamicType() == STANDARD_TYPE(TCollection_HAsciiString)) { entto = new TCollection_HAsciiString( @@ -155,7 +167,9 @@ bool Interface_CopyTool::Copy(const occ::handle& entfrom, // Create the empty Entity (NewVoid), the Copy remains to be done res = NewVoid(entfrom, entto); if (mapped) + { themap->Bind(entfrom, entto); // Map before continuing ... + } // Now, perform the Copy (depending on case; if ShallowCopy is not enough: // it is who decides) @@ -163,7 +177,9 @@ bool Interface_CopyTool::Copy(const occ::handle& entfrom, // An Entity in Error is not copied (no sense and it's risky ...) // However, it is "Copied Empty (NewVoid)" so referenceable if (!errstat) + { themdu->CopyCase(theCN, entfrom, entto, *this); + } return res; } @@ -173,7 +189,9 @@ void Interface_CopyTool::Implied(const occ::handle& entfrom, occ::handle module; int CN; if (thelib.Select(entfrom, module, CN)) + { module->RenewImpliedCase(CN, entfrom, entto, *this); + } } // .... Feeding the Map .... @@ -183,34 +201,46 @@ occ::handle Interface_CopyTool::Transferred( { occ::handle res; if (ent.IsNull()) + { return res; // Copy of a Null : very simple ... + } int nument = themod->Number(ent); // == 0 -> May be a non-shared sub-part ... // We accept but we protect against a loop if (nument == 0 && thelev > 100) + { throw Interface_InterfaceError( "CopyTool : Transferred, Entity is not contained in Starting Model"); + } if (!themap->Search(ent, res)) { // already transferred ? if not, do it // We perform the Copy (finally, we try) // In case of failure, nothing is recorded if (!Copy(ent, res, (nument != 0), themod->IsRedefinedContent(nument))) + { return res; + } thelev++; if (nument != 0) + { thelst.SetTrue(nument); + } occ::handle rep; if (nument != 0) + { rep = themod->ReportEntity(nument); + } if (!rep.IsNull()) { // WARNING WARNING, if ReportEntity : Also copy Content and remake a // ReportEntity with the initial terms if (rep->IsUnknown()) + { therep->Bind(ent, new Interface_ReportEntity(res)); + } else { occ::handle contfrom, contto; @@ -219,9 +249,13 @@ occ::handle Interface_CopyTool::Transferred( if (!contfrom.IsNull()) { if (contfrom == ent) + { contto = res; + } else + { Copy(contfrom, contto, themod->Contains(contfrom), false); + } repto->SetContent(contto); } therep->Bind(ent, repto); @@ -231,7 +265,9 @@ occ::handle Interface_CopyTool::Transferred( thelev--; } if (thelev == 0 && nument > 0) + { therts.Append(nument); + } return res; } @@ -268,7 +304,9 @@ int Interface_CopyTool::LastCopiedAfter(const int numfrom { ent = themod->Value(num); if (themap->Search(ent, res)) + { return num; + } } } return 0; @@ -285,7 +323,9 @@ void Interface_CopyTool::TransferEntity(const occ::handle& e void Interface_CopyTool::RenewImpliedRefs() { if (theimp) + { return; // already done + } theimp = true; // Transfer Pass 2 : recovery of non "Share" relations (but "Imply") @@ -299,8 +339,10 @@ void Interface_CopyTool::RenewImpliedRefs() occ::handle ent = themod->Value(i); occ::handle res; if (!themap->Search(ent, res)) + { continue; // entity not transferred - // Renewal of "Imply" references. Warning, do not copy if not loaded + } + // Renewal of "Imply" references. Warning, do not copy if not loaded occ::handle aRep; if (!therep->Search(ent, aRep)) { @@ -310,7 +352,9 @@ void Interface_CopyTool::RenewImpliedRefs() { occ::handle rep = occ::down_cast(aRep); if (!rep.IsNull() && !rep->HasNewContent()) + { Implied(ent, res); + } } } } @@ -339,12 +383,16 @@ Interface_EntityIterator Interface_CopyTool::CompleteResult(const bool withrepor occ::handle ent = themod->Value(i); occ::handle res; if (!themap->Search(ent, res)) + { continue; + } if (withreports) { occ::handle rep; if (therep->Search(ent, rep)) + { res = rep; + } } iter.GetOneItem(res); } @@ -361,12 +409,16 @@ Interface_EntityIterator Interface_CopyTool::RootResult(const bool withreports) occ::handle ent = themod->Value(j); occ::handle res; if (!themap->Search(ent, res)) + { continue; + } if (withreports) { occ::handle rep; if (therep->Search(ent, rep)) + { res = rep; + } } iter.GetOneItem(res); } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_EntityCluster.cxx b/src/DataExchange/TKXSBase/Interface/Interface_EntityCluster.cxx index a5bdd5738e..2ec99e2784 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_EntityCluster.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_EntityCluster.cxx @@ -52,24 +52,38 @@ Interface_EntityCluster::Interface_EntityCluster(const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityCluster Append"); + } if (theents[0].IsNull()) + { theents[0] = ent; + } else if (theents[1].IsNull()) + { theents[1] = ent; + } else if (theents[2].IsNull()) + { theents[2] = ent; + } else if (theents[3].IsNull()) + { theents[3] = ent; + } else { // If this one is full ... if (thenext.IsNull()) + { thenext = new Interface_EntityCluster(ent); + } else { occ::handle aCurEntClust = thenext; while (aCurEntClust->HasNext() && aCurEntClust->IsLocalFull()) + { aCurEntClust = aCurEntClust->thenext; + } aCurEntClust->Append(ent); } } @@ -78,27 +92,41 @@ void Interface_EntityCluster::Append(const occ::handle& ent) bool Interface_EntityCluster::Remove(const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityCluster Remove"); + } int i; // Is here? if yes, we have its rank if (ent == theents[0]) + { i = 1; + } else if (ent == theents[1]) + { i = 2; + } else if (ent == theents[2]) + { i = 3; + } else if (ent == theents[3]) + { i = 4; - // Otherwise, go to the next one, which can then become empty -> - // We remove the empty cluster from the list (in principle it's the last one) + // Otherwise, go to the next one, which can then become empty -> + // We remove the empty cluster from the list (in principle it's the last one) + } else { // Not found in this one ... if (thenext.IsNull()) + { return false; + } int res = thenext->Remove(ent); if (res) + { thenext = thenext->Next(); + } return false; } return Remove(i); @@ -107,19 +135,27 @@ bool Interface_EntityCluster::Remove(const occ::handle& ent) bool Interface_EntityCluster::Remove(const int num) { if (num < 1) + { throw Standard_OutOfRange("EntityCluster : Remove"); + } int n = NbLocal(); if (num > n) { if (thenext.IsNull()) + { throw Standard_OutOfRange("EntityCluster : Remove"); + } bool res = thenext->Remove(num - n); if (res) + { thenext = thenext->Next(); + } return false; } for (int j = num; j < n; j--) + { theents[j - 1] = theents[j]; + } theents[3].Nullify(); // We Nullify at the end return (n == 1); // Old NbLocal == 1 -> becomes null } @@ -130,7 +166,9 @@ int Interface_EntityCluster::NbEntities() const { int nb = NbLocal(); if (!thenext.IsNull()) + { nb += thenext->NbEntities(); + } return nb; } @@ -138,7 +176,9 @@ const occ::handle& Interface_EntityCluster::Value(const int { int nb = NbLocal(), aLocalNum = num; if (num <= 0) + { throw Standard_OutOfRange("Interface EntityCluster : Value"); + } if (num > nb) { occ::handle aCurEntClust = thenext; @@ -146,7 +186,9 @@ const occ::handle& Interface_EntityCluster::Value(const int while (aLocalNum > aCurEntClust->NbLocal()) { if (!aCurEntClust->HasNext()) + { throw Standard_OutOfRange("Interface EntityCluster : Value"); + } aCurEntClust = aCurEntClust->thenext; aLocalNum -= nb; } @@ -158,10 +200,14 @@ const occ::handle& Interface_EntityCluster::Value(const int void Interface_EntityCluster::SetValue(const int num, const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityCluster SetValue"); + } int nb = NbLocal(), aLocalNum = num; if (num <= 0) + { throw Standard_OutOfRange("Interface EntityCluster : SetValue"); + } if (num > nb) { occ::handle aCurEntClust = thenext; @@ -169,28 +215,42 @@ void Interface_EntityCluster::SetValue(const int num, const occ::handle aCurEntClust->NbLocal()) { if (thenext.IsNull()) + { throw Standard_OutOfRange("Interface EntityCluster : SetValue"); + } aCurEntClust = aCurEntClust->thenext; aLocalNum -= nb; } aCurEntClust->theents[aLocalNum - 1] = ent; } else + { theents[num - 1] = ent; // numbering from 0 + } } void Interface_EntityCluster::FillIterator(Interface_EntityIterator& iter) const { if (!theents[0].IsNull()) + { iter.GetOneItem(theents[0]); + } if (!theents[1].IsNull()) + { iter.GetOneItem(theents[1]); + } if (!theents[2].IsNull()) + { iter.GetOneItem(theents[2]); + } if (!theents[3].IsNull()) + { iter.GetOneItem(theents[3]); + } if (!thenext.IsNull()) + { thenext->FillIterator(iter); + } } // .... Actions atomiques internes .... @@ -207,15 +267,25 @@ int Interface_EntityCluster::NbLocal() const { int nb; if (!theents[3].IsNull()) + { nb = 4; + } else if (!theents[2].IsNull()) + { nb = 3; + } else if (!theents[1].IsNull()) + { nb = 2; + } else if (!theents[0].IsNull()) + { nb = 1; + } else + { nb = 0; + } return nb; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_EntityIterator.cxx b/src/DataExchange/TKXSBase/Interface/Interface_EntityIterator.cxx index 81e3c1a3a4..b2d1e8ab70 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_EntityIterator.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_EntityIterator.cxx @@ -41,9 +41,13 @@ void Interface_EntityIterator::AddList( const occ::handle>>& list) { if (thelist.IsNull()) + { thelist = new NCollection_HSequence>(); + } if (thecurr.IsNull()) + { thecurr = new Interface_IntVal; + } thecurr->CValue() = 0; thelist->Append(list); } @@ -51,11 +55,17 @@ void Interface_EntityIterator::AddList( void Interface_EntityIterator::AddItem(const occ::handle& anentity) { if (anentity.IsNull()) + { return; + } if (thecurr.IsNull()) + { thecurr = new Interface_IntVal; + } if (thelist.IsNull()) + { thelist = new NCollection_HSequence>(); + } thecurr->CValue() = 0; thelist->Append(anentity); } @@ -68,7 +78,9 @@ void Interface_EntityIterator::GetOneItem(const occ::handle& void Interface_EntityIterator::Reset() { if (thecurr.IsNull()) + { thecurr = new Interface_IntVal; + } thecurr->CValue() = 0; thelist = new NCollection_HSequence>(); } @@ -81,14 +93,18 @@ void Interface_EntityIterator::Reset() void Interface_EntityIterator::SelectType(const occ::handle& atype, const bool keep) { if (thelist.IsNull()) + { return; + } int i, n = thelist->Length(); occ::handle>> nlist = new NCollection_HSequence>(); for (i = 1; i <= n; i++) { if (thelist->Value(i)->IsKind(atype) == keep) + { nlist->Append(thelist->Value(i)); + } } thelist = nlist; } @@ -98,9 +114,13 @@ void Interface_EntityIterator::SelectType(const occ::handle& atyp int Interface_EntityIterator::NbEntities() const { if (thelist.IsNull()) + { return 0; + } if (!thecurr.IsNull() && thecurr->Value() == 0) + { Start(); + } return thelist->Length(); } @@ -108,12 +128,16 @@ int Interface_EntityIterator::NbTyped(const occ::handle& atype) c { int res = 0; if (thelist.IsNull()) + { return res; + } int i, n = thelist->Length(); for (i = 1; i <= n; i++) { if (thelist->Value(i)->IsKind(atype)) + { res++; + } } return res; } @@ -123,12 +147,16 @@ Interface_EntityIterator Interface_EntityIterator::Typed( { Interface_EntityIterator res; if (thelist.IsNull()) + { return res; + } int i, n = thelist->Length(); for (i = 1; i <= n; i++) { if (thelist->Value(i)->IsKind(atype)) + { res.AddItem(thelist->Value(i)); + } } return res; } @@ -136,17 +164,25 @@ Interface_EntityIterator Interface_EntityIterator::Typed( void Interface_EntityIterator::Start() const { if (!thecurr.IsNull()) + { thecurr->CValue() = 1; + } } // can be redefined ... bool Interface_EntityIterator::More() const { if (thecurr.IsNull()) + { return false; + } if (thecurr->Value() == 0) + { Start(); // iteration preparation + } if (thelist.IsNull()) + { return false; + } return (thecurr->Value() <= thelist->Length()); } @@ -159,9 +195,13 @@ const occ::handle& Interface_EntityIterator::Value() const { // NbEntity not const (we don't know how it is implemented after all) if (thelist.IsNull()) + { throw Standard_NoSuchObject("Interface_EntityIterator"); + } if (thecurr->Value() < 1 || thecurr->Value() > thelist->Length()) + { throw Standard_NoSuchObject("Interface_EntityIterator"); + } return thelist->Value(thecurr->Value()); } @@ -169,9 +209,13 @@ occ::handle>> Interface_En Content() const { if (!thecurr.IsNull() && thecurr->Value() == 0) + { Start(); + } if (thelist.IsNull()) + { return new NCollection_HSequence>(); // empty + } return thelist; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_EntityList.cxx b/src/DataExchange/TKXSBase/Interface/Interface_EntityList.cxx index d88dc2fe99..fb2dc346f4 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_EntityList.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_EntityList.cxx @@ -36,7 +36,9 @@ void Interface_EntityList::Clear() void Interface_EntityList::Append(const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityList Append"); + } if (theval.IsNull()) { theval = ent; @@ -44,7 +46,9 @@ void Interface_EntityList::Append(const occ::handle& ent) } occ::handle aValEC = occ::down_cast(theval); if (!aValEC.IsNull()) + { aValEC->Append(ent); // EntityCluster + } else { // reste InterfaceEntity ... occ::handle ec = new Interface_EntityCluster(theval); @@ -61,7 +65,9 @@ void Interface_EntityList::Append(const occ::handle& ent) void Interface_EntityList::Add(const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityList Add"); + } if (theval.IsNull()) { theval = ent; @@ -71,9 +77,13 @@ void Interface_EntityList::Add(const occ::handle& ent) if (!aValEC.IsNull()) { // EntityCluster if (aValEC->IsLocalFull()) + { theval = new Interface_EntityCluster(ent, aValEC); + } else + { aValEC->Append(ent); + } } else { // reste InterfaceEntity ... @@ -90,9 +100,13 @@ void Interface_EntityList::Add(const occ::handle& ent) void Interface_EntityList::Remove(const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityList Remove"); + } if (theval.IsNull()) + { return; + } if (theval == ent) { theval.Nullify(); @@ -100,10 +114,14 @@ void Interface_EntityList::Remove(const occ::handle& ent) } occ::handle ec = occ::down_cast(theval); if (ec.IsNull()) + { return; // A single Entity and not the right one + } bool res = ec->Remove(ent); if (res) + { theval.Nullify(); + } } // Remove by rank : test OutOfRange @@ -111,18 +129,24 @@ void Interface_EntityList::Remove(const occ::handle& ent) void Interface_EntityList::Remove(const int num) { if (theval.IsNull()) + { throw Standard_OutOfRange("EntityList : Remove"); + } occ::handle ec = occ::down_cast(theval); if (ec.IsNull()) { if (num != 1) + { throw Standard_OutOfRange("EntityList : Remove"); + } theval.Nullify(); return; } bool res = ec->Remove(num); if (res) + { theval.Nullify(); + } } // .... UNIT ACCESS TO DATA .... @@ -135,38 +159,58 @@ bool Interface_EntityList::IsEmpty() const int Interface_EntityList::NbEntities() const { if (theval.IsNull()) + { return 0; + } occ::handle ec = occ::down_cast(theval); if (ec.IsNull()) + { return 1; // A single Entity + } return ec->NbEntities(); } const occ::handle& Interface_EntityList::Value(const int num) const { if (theval.IsNull()) + { throw Standard_OutOfRange("Interface EntityList : Value"); + } occ::handle ec = occ::down_cast(theval); if (!ec.IsNull()) + { return ec->Value(num); // EntityCluster + } else if (num != 1) + { throw Standard_OutOfRange("Interface EntityList : Value"); + } return theval; } void Interface_EntityList::SetValue(const int num, const occ::handle& ent) { if (ent.IsNull()) + { throw Standard_NullObject("Interface_EntityList SetValue"); + } if (theval.IsNull()) + { throw Standard_OutOfRange("Interface EntityList : SetValue"); + } occ::handle ec = occ::down_cast(theval); if (!ec.IsNull()) + { ec->SetValue(num, ent); // EntityCluster + } else if (num != 1) + { throw Standard_OutOfRange("Interface EntityList : SetValue"); + } else + { theval = ent; + } } // .... Interrogations Generales .... @@ -174,19 +218,27 @@ void Interface_EntityList::SetValue(const int num, const occ::handle ec = occ::down_cast(theval); if (!ec.IsNull()) + { ec->FillIterator(iter); // EntityCluster; + } else + { iter.GetOneItem(theval); + } } int Interface_EntityList::NbTypedEntities(const occ::handle& atype) const { int res = 0; if (theval.IsNull()) + { return 0; + } occ::handle ec = occ::down_cast(theval); if (!ec.IsNull()) { // EntityCluster @@ -195,17 +247,23 @@ int Interface_EntityList::NbTypedEntities(const occ::handle& atyp for (int i = ec->NbLocal(); i > 0; i--) { if (ec->Value(i)->IsKind(atype)) + { res++; + } } if (!ec->HasNext()) + { break; + } ec = ec->Next(); } } else { // Une seule Entite if (theval->IsKind(atype)) + { res = 1; + } } return res; } @@ -217,7 +275,9 @@ occ::handle Interface_EntityList::TypedEntity( int res = 0; occ::handle entres; if (theval.IsNull()) + { throw Interface_InterfaceError("Interface EntityList : TypedEntity , none found"); + } occ::handle ec = occ::down_cast(theval); if (!ec.IsNull()) { // EntityCluster @@ -229,14 +289,20 @@ occ::handle Interface_EntityList::TypedEntity( { res++; if (num == 0 && res > 1) + { throw Interface_InterfaceError("Interface EntityList : TypedEntity , several found"); + } entres = ec->Value(i); if (res == num) + { return entres; + } } } if (!ec->HasNext()) + { break; + } ec = ec->Next(); } } @@ -247,7 +313,9 @@ occ::handle Interface_EntityList::TypedEntity( else { // InterfaceEntity if (!theval->IsKind(atype)) + { throw Interface_InterfaceError("Interface EntityList : TypedEntity , none found"); + } entres = theval; } return entres; diff --git a/src/DataExchange/TKXSBase/Interface/Interface_FileReaderData.cxx b/src/DataExchange/TKXSBase/Interface/Interface_FileReaderData.cxx index 2e8fca84c9..70331ea955 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_FileReaderData.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_FileReaderData.cxx @@ -60,7 +60,9 @@ int Interface_FileReaderData::NbEntities() const int nb = 0; int num = 0; while ((num = FindNextRecord(num)) > 0) + { nb++; + } return nb; } @@ -102,27 +104,41 @@ void Interface_FileReaderData::SetParam(const int num, int Interface_FileReaderData::NbParams(const int num) const { if (num > 1) + { return (thenumpar(num) - thenumpar(num - 1)); + } else if (num == 1) + { return thenumpar(num); + } else + { return theparams->NbParams(); + } } occ::handle Interface_FileReaderData::Params(const int num) const { if (num == 0) + { return theparams->Params(0, 0); // complet + } else if (num == 1) + { return theparams->Params(0, thenumpar(1)); + } else + { return theparams->Params(thenumpar(num - 1) + 1, (thenumpar(num) - thenumpar(num - 1))); + } } const Interface_FileParameter& Interface_FileReaderData::Param(const int num, const int nump) const { if (thefic != thenum0) + { return theparams->Param(thenumpar(num - 1) + nump); + } if (thenm0 != num) { thenp0 = thenumpar(num - 1); @@ -134,7 +150,9 @@ const Interface_FileParameter& Interface_FileReaderData::Param(const int num, co Interface_FileParameter& Interface_FileReaderData::ChangeParam(const int num, const int nump) { if (thefic != thenum0) + { return theparams->ChangeParam(thenumpar(num - 1) + nump); + } if (thenm0 != num) { thenp0 = thenumpar(num - 1); diff --git a/src/DataExchange/TKXSBase/Interface/Interface_FileReaderTool.cxx b/src/DataExchange/TKXSBase/Interface/Interface_FileReaderTool.cxx index d1c3d79870..0df0a2db52 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_FileReaderTool.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_FileReaderTool.cxx @@ -101,9 +101,13 @@ occ::handle Interface_FileReaderTool::Model() const void Interface_FileReaderTool::SetMessenger(const occ::handle& messenger) { if (messenger.IsNull()) + { themessenger = Message::DefaultMessenger(); + } else + { themessenger = messenger; + } } //================================================================================================= @@ -165,8 +169,10 @@ void Interface_FileReaderTool::SetEntities() { newent = UnknownEntity(); if (thereports.IsNull()) + { thereports = new NCollection_HArray1>(1, thereader->NbRecords()); + } thenbreps++; thenbrep0++; thereports->SetValue(num, new Interface_ReportEntity(ach, newent)); @@ -174,8 +180,10 @@ void Interface_FileReaderTool::SetEntities() else if ((ach->NbFails() + ach->NbWarnings() > 0) && !newent.IsNull()) { if (thereports.IsNull()) + { thereports = new NCollection_HArray1>(1, thereader->NbRecords()); + } thenbreps++; thenbrep0++; thereports->SetValue(num, new Interface_ReportEntity(ach, newent)); @@ -201,7 +209,9 @@ bool Interface_FileReaderTool::RecognizeByLib(const int n { rmod = rlib.Module(); if (rmod.IsNull()) + { continue; + } CN = rmod->CaseNum(thereader, num); if (CN > 0) { @@ -210,21 +220,31 @@ bool Interface_FileReaderTool::RecognizeByLib(const int n } } if (CN <= 0 || proto.IsNull()) + { return false; + } // Recalibrate in GeneralLib : Creation of empty entity occ::handle typrot = proto->DynamicType(); for (glib.Start(); glib.More(); glib.Next()) { proto = glib.Protocol(); if (proto.IsNull()) + { continue; + } if (proto->DynamicType() != typrot) + { continue; + } bool res = glib.Module()->NewVoid(CN, ent); if (res) + { return res; + } if (!rmod.IsNull()) + { return rmod->NewRead(CN, thereader, num, ach, ent); + } // return res; } return false; @@ -287,7 +307,9 @@ void Interface_FileReaderTool::LoadModel(const occ::handle(&anException) != nullptr) + { ierr = 2; + } #endif //: abv 03Apr00: anent is actually a previous one: if (anent.IsNull()) anent = thereader->BoundEntity(num); @@ -409,8 +433,10 @@ void Interface_FileReaderTool::LoadModel(const occ::handleSetContent(undef); if (thereports.IsNull()) + { thereports = new NCollection_HArray1>(1, thereader->NbRecords()); + } thenbreps++; thereports->SetValue(num, rep); // if(isValid) @@ -453,7 +479,9 @@ void Interface_FileReaderTool::LoadModel(const occ::handleValue(nr).IsNull()) + { continue; + } occ::handle anent = thereader->BoundEntity(nr); occ::handle rep = occ::down_cast(thereports->Value(nr)); @@ -480,7 +508,9 @@ void Interface_FileReaderTool::LoadModel(const occ::handle Interface_FileReaderTool::LoadedEntity(const int if (irep == 0) { if (thereports.IsNull()) + { thereports = new NCollection_HArray1>(1, thereader->NbRecords()); + } irep = num; thenbreps++; } @@ -553,7 +585,9 @@ occ::handle Interface_FileReaderTool::LoadedEntity(const int // Reloading ? if yes, in an UnknownEntity provided by the protocol if (thereader->IsErrorLoad()) + { nbf = (thereader->ResetErrorLoad() ? 1 : 0); + } if (nbf > 0) { occ::handle undef = UnknownEntity(); diff --git a/src/DataExchange/TKXSBase/Interface/Interface_FloatWriter.cxx b/src/DataExchange/TKXSBase/Interface/Interface_FloatWriter.cxx index bc8d41e6e9..e2ff60507d 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_FloatWriter.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_FloatWriter.cxx @@ -26,7 +26,9 @@ void Interface_FloatWriter::SetFormat(const char* const form, const bool reset) { strcpy(themainform, form); if (!reset) + { return; + } therange1 = therange2 = 0.; // second form : inhibee thezerosup = false; } @@ -109,14 +111,20 @@ int Interface_FloatWriter::Convert(const double val, int i0 = 0, j0 = 0; for (int i = 0; i < anMasSize; ++i) + { lxp[i] = '\0'; + } pText = (char*)text; // if ((val >= R1 && val < R2) || (val <= -R1 && val > -R2)) + { Sprintf(pText, rangeform, val); + } else + { Sprintf(pText, mainform, val); + } if (zsup) { @@ -132,12 +140,16 @@ int Interface_FloatWriter::Convert(const double val, lxp[4] = text[i + 4]; if (lxp[1] == '+' && lxp[2] == '0' && lxp[3] == '0' && lxp[4] == '\0') + { lxp[0] = '\0'; + } pText[i] = '\0'; } if (text[i] == '\0') + { break; + } } // #52 rln 23.12.98 converting 1e-07 throws exception for (int j = i0 - 1; j >= 0; j--) @@ -145,7 +157,9 @@ int Interface_FloatWriter::Convert(const double val, j0 = j; if (text[j] != '0') + { break; + } pText[j] = '\0'; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_GTool.cxx b/src/DataExchange/TKXSBase/Interface/Interface_GTool.cxx index dc6d0245fc..d5f5a0c2b4 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_GTool.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_GTool.cxx @@ -49,23 +49,31 @@ const char* Interface_GTool::SignValue(const occ::handle& const occ::handle& model) const { if (ent.IsNull()) + { return ""; + } if (thesign.IsNull()) + { return Interface_SignType::ClassName(ent->DynamicType()->Name()); + } return thesign->Value(ent, model); } const char* Interface_GTool::SignName() const { if (thesign.IsNull()) + { return "Class Name"; + } return thesign->Name(); } void Interface_GTool::SetProtocol(const occ::handle& proto, const bool enforce) { if (proto == theproto && !enforce) + { return; + } theproto = proto; thelib.Clear(); thelib.AddProtocol(proto); @@ -85,7 +93,9 @@ void Interface_GTool::Reservate(const int nb, const bool enforce) { const size_t aNbBuckets = thentnum.NbBuckets(); if (aNbBuckets < static_cast(nb) && !enforce) + { return; + } thentnum.ReSize(static_cast(nb)); thentmod.ReSize(static_cast(nb)); } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx b/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx index f483acf74b..d196ec298c 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx @@ -30,9 +30,13 @@ void Interface_GlobalNodeOfGeneralLib::Add(const occ::handle& aprotocol) { if (themod == amodule) + { return; + } if (theprot == aprotocol) + { themod = amodule; + } else if (thenext.IsNull()) { if (themod.IsNull()) @@ -47,7 +51,9 @@ void Interface_GlobalNodeOfGeneralLib::Add(const occ::handleAdd(amodule, aprotocol); + } } const occ::handle& Interface_GlobalNodeOfGeneralLib::Module() const diff --git a/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfReaderLib_0.cxx b/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfReaderLib_0.cxx index 26400c6d97..91228606ca 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfReaderLib_0.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_GlobalNodeOfReaderLib_0.cxx @@ -30,9 +30,13 @@ void Interface_GlobalNodeOfReaderLib::Add(const occ::handle& aprotocol) { if (themod == amodule) + { return; + } if (theprot == aprotocol) + { themod = amodule; + } else if (thenext.IsNull()) { if (themod.IsNull()) @@ -47,7 +51,9 @@ void Interface_GlobalNodeOfReaderLib::Add(const occ::handleAdd(amodule, aprotocol); + } } const occ::handle& Interface_GlobalNodeOfReaderLib::Module() const diff --git a/src/DataExchange/TKXSBase/Interface/Interface_Graph.cxx b/src/DataExchange/TKXSBase/Interface/Interface_Graph.cxx index fdf3269279..7cb1d6c6d0 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_Graph.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_Graph.cxx @@ -46,7 +46,9 @@ Interface_Graph::Interface_Graph(const occ::handle& am thepresents("") { if (theModeStat) + { InitStats(); + } Evaluate(); } @@ -58,7 +60,9 @@ Interface_Graph::Interface_Graph(const occ::handle& am { if (theModeStat) + { InitStats(); + } Evaluate(); } @@ -69,7 +73,9 @@ Interface_Graph::Interface_Graph(const occ::handle& am thepresents("") { if (theModeStat) + { InitStats(); + } Evaluate(); } @@ -79,7 +85,9 @@ Interface_Graph::Interface_Graph(const occ::handle& am thepresents("") { if (theModeStat) + { InitStats(); + } Evaluate(); } @@ -92,11 +100,17 @@ Interface_Graph::Interface_Graph(const Interface_Graph& agraph, const bool /*cop thesharings = agraph.SharingTable(); int nb = agraph.NbStatuses(); if (!nb) + { return; + } if (thestats.IsNull()) + { thestats = new NCollection_HArray1(1, nb); + } for (int i = 1; i <= nb; i++) + { thestats->SetValue(i, agraph.Status(i)); + } theflags.Initialize(agraph.BitMap(), true); } @@ -182,7 +196,9 @@ void Interface_Graph::Evaluate() occ::handle aCurEnt = anEntity; if (themodel->IsRedefinedContent(aNumber)) + { aCurEnt = themodel->ReportEntity(aNumber)->Content(); + } occ::handle aModule; int aCN; @@ -251,7 +267,9 @@ int Interface_Graph::EntityNumber(const occ::handle& ent) co bool Interface_Graph::IsPresent(const int num) const { if (num <= 0 || num > Size()) + { return false; + } return (!thestats.IsNull() ? theflags.Value(num, Graph_Present) : false); } @@ -273,7 +291,9 @@ int Interface_Graph::Status(const int num) const void Interface_Graph::SetStatus(const int num, const int stat) { if (!thestats.IsNull()) + { thestats->SetValue(num, stat); + } } void Interface_Graph::RemoveItem(const int num) @@ -288,24 +308,32 @@ void Interface_Graph::RemoveItem(const int num) void Interface_Graph::ChangeStatus(const int oldstat, const int newstat) { if (thestats.IsNull()) + { return; + } int nb = thestats->Upper(); for (int i = 1; i <= nb; i++) { if (thestats->Value(i) == oldstat) + { thestats->SetValue(i, newstat); + } } } void Interface_Graph::RemoveStatus(const int stat) { if (thestats.IsNull()) + { return; + } int nb = thestats->Upper(); for (int i = 1; i <= nb; i++) { if (thestats->Value(i) == stat) + { RemoveItem(i); + } } } @@ -331,7 +359,9 @@ const occ::handle& Interface_Graph::Model() const void Interface_Graph::GetFromModel() { if (themodel.IsNull() || thestats.IsNull()) + { return; // no model ... (-> we won't go far) + } theflags.Init(true, Graph_Present); thestats->Init(0); } @@ -341,20 +371,30 @@ void Interface_Graph::GetFromEntity(const occ::handle& ent, const int newstat) { if (thestats.IsNull()) + { return; + } int num = EntityNumber(ent); if (!num) + { return; + } if (theflags.CTrue(num, Graph_Present)) + { return; // already taken : we skip + } thestats->SetValue(num, newstat); if (!shared) + { return; + } // Watch out for redefinition ! Interface_EntityIterator aIter = GetShareds(ent); for (; aIter.More(); aIter.Next()) + { GetFromEntity(aIter.Value(), true, newstat); + } } void Interface_Graph::GetFromEntity(const occ::handle& ent, @@ -364,10 +404,14 @@ void Interface_Graph::GetFromEntity(const occ::handle& ent, const bool cumul) { if (thestats.IsNull()) + { return; + } int num = EntityNumber(ent); if (!num) + { return; + } bool pasla = !theflags.CTrue(num, Graph_Present); int stat = thestats->Value(num); @@ -382,34 +426,50 @@ void Interface_Graph::GetFromEntity(const occ::handle& ent, if (stat != newstat) { // already taken, same status : skip if (cumul) + { overstat += overlapstat; // new status : with cumulation ... + } else + { overstat = overlapstat; // ... or without (forced status) - if (stat != overstat) // if repass already done, skip + } + if (stat != overstat) + { // if repass already done, skip thestats->SetValue(num, overstat); + } } } if (!shared) + { return; + } // Watch out for redefinition ! Interface_EntityIterator aIter = GetShareds(ent); for (; aIter.More(); aIter.Next()) + { GetFromEntity(aIter.Value(), true, newstat); + } } void Interface_Graph::GetFromIter(const Interface_EntityIterator& iter, const int newstat) { if (thestats.IsNull()) + { return; + } for (iter.Start(); iter.More(); iter.Next()) { const occ::handle& ent = iter.Value(); int num = EntityNumber(ent); if (!num) + { continue; + } if (theflags.CTrue(num, Graph_Present)) + { continue; + } thestats->SetValue(num, newstat); } } @@ -420,13 +480,17 @@ void Interface_Graph::GetFromIter(const Interface_EntityIterator& iter, const bool cumul) { if (thestats.IsNull()) + { return; + } for (iter.Start(); iter.More(); iter.Next()) { const occ::handle& ent = iter.Value(); int num = EntityNumber(ent); if (!num) + { continue; + } /*bool pasla = !*/ theflags.Value(num, Graph_Present); /*int stat = */ thestats->Value(num); GetFromEntity(ent, false, newstat, overlapstat, cumul); @@ -436,24 +500,32 @@ void Interface_Graph::GetFromIter(const Interface_EntityIterator& iter, void Interface_Graph::GetFromGraph(const Interface_Graph& agraph) { if (Model() != agraph.Model()) + { throw Standard_DomainError("Graph from Interface : GetFromGraph"); + } int nb = Size(); for (int i = 1; i <= nb; i++) { if (agraph.IsPresent(i)) + { GetFromEntity(agraph.Entity(i), false, agraph.Status(i)); + } } } void Interface_Graph::GetFromGraph(const Interface_Graph& agraph, const int stat) { if (Model() != agraph.Model()) + { throw Standard_DomainError("Graph from Interface : GetFromGraph"); + } int nb = Size(); for (int i = 1; i <= nb; i++) { if (agraph.IsPresent(i) && agraph.Status(i) == stat) + { GetFromEntity(agraph.Entity(i), false, stat); + } } } @@ -464,10 +536,14 @@ void Interface_Graph::GetFromGraph(const Interface_Graph& agraph, const int stat bool Interface_Graph::HasShareErrors(const occ::handle& ent) const { if (thestats.IsNull()) + { return false; + } int num = EntityNumber(ent); if (num == 0) + { return true; + } return theflags.Value(num, Graph_ShareError); } @@ -476,17 +552,23 @@ Interface_EntityIterator Interface_Graph::Shareds(const occ::handle aCurEnt = ent; if (themodel->IsRedefinedContent(num)) + { aCurEnt = themodel->ReportEntity(num)->Content(); + } // if (num == 0) throw Standard_DomainError("Interface : Shareds"); occ::handle module; int CN; if (themodel->GTool()->Select(aCurEnt, module, CN)) + { module->FillShared(themodel, CN, aCurEnt, iter); + } return iter; } @@ -501,7 +583,9 @@ occ::handle>> Interface_Gr { int num = EntityNumber(ent); if (!num) + { return nullptr; + } // return // occ::down_cast>>(thesharings->Value(num)); const NCollection_List& alist = thesharings->Value(num); @@ -509,7 +593,9 @@ occ::handle>> Interface_Gr new NCollection_HSequence>; NCollection_List::Iterator aIt(alist); for (; aIt.More(); aIt.Next()) + { aSharings->Append(Entity(aIt.Value())); + } return aSharings; } @@ -525,22 +611,30 @@ static void AddTypedSharings(const occ::handle& ent, const Interface_Graph& G) { if (ent.IsNull()) + { return; + } if (ent->IsKind(type)) { iter.AddItem(ent); return; } if (iter.NbEntities() > n) + { return; + } occ::handle>> list = G.GetSharings(ent); if (list.IsNull()) + { return; + } int nb = list->Length(); for (int i = 1; i <= nb; i++) + { AddTypedSharings(list->Value(i), type, iter, nb, G); + } } Interface_EntityIterator Interface_Graph::TypedSharings( @@ -560,7 +654,9 @@ Interface_EntityIterator Interface_Graph::RootEntities() const for (int i = 1; i <= nb; i++) { if (!thesharings->Value(i).IsEmpty()) + { continue; + } iter.AddItem(Entity(i)); } return iter; @@ -571,18 +667,26 @@ occ::handle Interface_Graph::Name( { occ::handle str; if (themodel.IsNull()) + { return str; + } if (themodel->Number(ent)) + { return str; + } occ::handle gtool = themodel->GTool(); if (gtool.IsNull()) + { return str; + } occ::handle module; int CN; if (!gtool->Select(ent, module, CN)) + { return str; + } Interface_ShareTool sht(*this); return module->Name(CN, ent, sht); diff --git a/src/DataExchange/TKXSBase/Interface/Interface_GraphContent.cxx b/src/DataExchange/TKXSBase/Interface/Interface_GraphContent.cxx index ac0246d983..11a7804e10 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_GraphContent.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_GraphContent.cxx @@ -34,12 +34,16 @@ Interface_GraphContent::Interface_GraphContent(const Interface_Graph& Interface_EntityIterator list = agraph.Shareds(ent); int nb = list.NbEntities(); if (nb == 0) + { return; // Liste redefinie a VIDE + } for (; list.More(); list.Next()) { const occ::handle& curent = list.Value(); if (agraph.IsPresent(agraph.EntityNumber(curent))) + { GetOneItem(curent); + } } } @@ -49,7 +53,9 @@ void Interface_GraphContent::GetFromGraph(const Interface_Graph& agraph) for (int i = 1; i <= nb; i++) { if (agraph.IsPresent(i)) + { GetOneItem(agraph.Entity(i)); + } } } @@ -59,7 +65,9 @@ void Interface_GraphContent::GetFromGraph(const Interface_Graph& agraph, const i for (int i = 1; i <= nb; i++) { if (agraph.IsPresent(i) && agraph.Status(i) == stat) + { GetOneItem(agraph.Entity(i)); + } } } @@ -67,7 +75,9 @@ Interface_EntityIterator Interface_GraphContent::Result() { Interface_EntityIterator iter; // On transvase ... for (Begin(); More(); Next()) + { iter.GetOneItem(Value()); + } return iter; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_IntList.cxx b/src/DataExchange/TKXSBase/Interface/Interface_IntList.cxx index 31e6ad1c66..c31f493096 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_IntList.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_IntList.cxx @@ -52,11 +52,15 @@ Interface_IntList::Interface_IntList(const Interface_IntList& other, const bool occ::handle> ents = new NCollection_HArray1(0, thenbe); ents->Init(0); for (i = 1; i <= thenbe; i++) + { ents->SetValue(i, theents->Value(i)); + } occ::handle> refs = new NCollection_HArray1(0, thenbr); refs->Init(0); for (i = 1; i <= thenbr; i++) + { refs->SetValue(i, therefs->Value(i)); + } theents = ents; therefs = refs; } @@ -103,12 +107,16 @@ int Interface_IntList::NbEntities() const void Interface_IntList::SetNbEntities(const int nbe) { if (nbe <= theents->Upper()) + { return; + } int i; occ::handle> ents = new NCollection_HArray1(0, nbe); ents->Init(0); for (i = 1; i <= thenbe; i++) + { ents->SetValue(i, theents->Value(i)); + } theents = ents; thenbe = nbe; } @@ -120,7 +128,9 @@ void Interface_IntList::SetNumber(const int number) if (number < 0) { if (thenum == -number || number < -thenbe) + { return; + } bool preres = true; thenum = -number; int val = theents->Value(thenum); @@ -139,20 +149,28 @@ void Interface_IntList::SetNumber(const int number) therank = -val; thecount = therefs->Value(therank); if (thecount <= 0) + { preres = false; + } } if (preres) + { return; + } } // Current usage. The following in current usage or if no pre-reservation else if (number > 0) { if (thenum == number || number > thenbe) + { return; + } thenum = number; } else + { return; + } int val = theents->Value(thenum); if (val == 0) @@ -170,18 +188,24 @@ void Interface_IntList::SetNumber(const int number) therank = -val; thecount = 0; if (therefs->Value(therank + 1) == 0) + { thecount = -therefs->Value(therank); + } else { for (int j = 1;; j++) { val = therefs->Value(therank + j); if (val >= 0) + { break; + } thecount++; } if (val > 0) + { thecount++; + } } } else @@ -206,15 +230,21 @@ Interface_IntList Interface_IntList::List(const int number, const bool copied) c void Interface_IntList::SetRedefined(const bool mode) { if (!NbEntities() || thenum == 0) + { return; + } int val = theents->Value(thenum); if (val < -1) + { return; + } else if (mode) { if (val == 0) + { theents->SetValue(thenum, -1); + } else if (val > 0) { Reservate(2); @@ -226,12 +256,16 @@ void Interface_IntList::SetRedefined(const bool mode) else if (!mode) { if (val == -1) + { theents->SetValue(thenum, 0); + } else if (therefs->Value(therank + 1) >= 0) { theents->SetValue(thenum, therefs->Value(therank + 1)); if (thenbr == therank + 1) + { thenbr--; + } } } } @@ -243,7 +277,9 @@ void Interface_IntList::Reservate(const int count) { Reservate(-count - 1); if (thenum == 0) + { return; + } thenbr++; therefs->SetValue(thenbr, 0); // will contain the number ... therank = thenbr; @@ -256,38 +292,54 @@ void Interface_IntList::Reservate(const int count) { // i.e. not yet allocated ... up = thenbe / 2 + 1; if (up < 2) + { up = 2; + } if (up < count) + { up = count * 3 / 2; + } therefs = new NCollection_HArray1(0, up); therefs->Init(0); thenbr = 2; // we start after (convenience of addressing) } oldup = therefs->Upper(); if (thenbr + count < oldup) + { return; // OK + } up = oldup * 3 / 2 + count; if (up < 2) + { up = 2; + } occ::handle> refs = new NCollection_HArray1(0, up); refs->Init(0); for (int i = 1; i <= oldup; i++) + { refs->SetValue(i, therefs->Value(i)); + } therefs = refs; } void Interface_IntList::Add(const int ref) { if (thenum == 0) + { return; + } // ref < 0 : pre-reservation if (ref < 0) { Add(-ref); if (therank <= 0) + { return; + } if (therefs->Value(therank) >= 0) + { therefs->SetValue(therank, thecount); + } return; } @@ -353,25 +405,39 @@ bool Interface_IntList::IsRedefined(const int num) const { int n = (num == 0 ? thenum : num); if (!NbEntities() || n == 0) + { return false; + } if (theents->Value(n) < 0) + { return true; + } return false; } int Interface_IntList::Value(const int num) const { if (thenum == 0) + { return 0; + } if (num <= 0 || num > thecount) + { return 0; + } if (thecount == 0) + { return 0; + } if (therank <= 0) + { return theents->Value(thenum); + } int val = therefs->Value(therank + num); if (val < 0) + { return -val; + } return val; } @@ -383,19 +449,27 @@ bool Interface_IntList::Remove(const int) void Interface_IntList::Clear() { if (thenbr == 0) + { return; // already clear + } int i, low, up; low = theents->Lower(); up = theents->Upper(); for (i = low; i <= up; i++) + { theents->SetValue(i, 0); + } thenbr = 0; if (therefs.IsNull()) + { return; + } low = therefs->Lower(); up = therefs->Upper(); for (i = low; i <= up; i++) + { therefs->SetValue(i, 0); + } } void Interface_IntList::AdjustSize(const int margin) @@ -406,20 +480,28 @@ void Interface_IntList::AdjustSize(const int margin) occ::handle> ents = new NCollection_HArray1(0, thenbe); ents->Init(0); for (i = 1; i <= thenbe; i++) + { ents->SetValue(i, theents->Value(i)); + } theents = ents; } if (thenbr == 0) + { Reservate(margin); + } else { up = therefs->Upper(); if (up >= thenbr && up <= thenbr + margin) + { return; + } occ::handle> refs = new NCollection_HArray1(0, thenbr + margin); refs->Init(0); for (i = 1; i <= thenbr; i++) + { refs->SetValue(i, therefs->Value(i)); + } therefs = refs; } } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_InterfaceModel.cxx b/src/DataExchange/TKXSBase/Interface/Interface_InterfaceModel.cxx index e32a6c0b01..029c03e5ea 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_InterfaceModel.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_InterfaceModel.cxx @@ -88,7 +88,9 @@ occ::handle Interface_InterfaceModel::Protocol() const { occ::handle proto; if (!thegtool.IsNull()) + { return thegtool->Protocol(); + } return proto; } @@ -163,10 +165,14 @@ int Interface_InterfaceModel::NbEntities() const bool Interface_InterfaceModel::Contains(const occ::handle& anentity) const { if (theentities.Contains(anentity)) + { return true; + } occ::handle rep = occ::down_cast(anentity); if (!rep.IsNull()) + { return Contains(rep->Concerned()); + } return false; } @@ -175,15 +181,21 @@ bool Interface_InterfaceModel::Contains(const occ::handle& a int Interface_InterfaceModel::Number(const occ::handle& anentity) const { if (anentity.IsNull()) + { return 0; + } int num = theentities.FindIndex(anentity); if (num > 0) + { return num; + } if (anentity->IsKind(typerep())) { occ::handle rep = occ::down_cast(anentity); if (!rep.IsNull()) + { return Number(rep->Concerned()); + } } return 0; } @@ -218,7 +230,9 @@ const occ::handle& Interface_InterfaceModel::Value(const int int Interface_InterfaceModel::NbTypes(const occ::handle& ent) const { if (Protocol().IsNull()) + { return 1; + } return Protocol()->NbTypes(ent); } @@ -229,7 +243,9 @@ occ::handle Interface_InterfaceModel::Type( const int nt) const { if (Protocol().IsNull()) + { return ent->DynamicType(); + } return Protocol()->Type(ent, nt); } @@ -239,10 +255,14 @@ const char* Interface_InterfaceModel::TypeName(const occ::handleSignValue(ent, this); + } const char* tn = ent->DynamicType()->Name(); if (complet) + { return tn; + } return Interface_InterfaceModel::ClassName(tn); } @@ -261,27 +281,43 @@ Interface_DataState Interface_InterfaceModel::EntityState(const int num) const if (!thereports.IsBound(num)) { if (!therepch.IsBound(num)) + { return Interface_StateOK; + } rep = occ::down_cast(therepch.Find(num)); if (rep->IsError()) + { return Interface_DataFail; + } return Interface_DataWarning; } rep = occ::down_cast(thereports.Find(num)); if (rep.IsNull()) + { return Interface_StateUnknown; + } if (rep->IsUnknown()) + { return Interface_StateUnknown; + } if (rep->HasNewContent()) + { return Interface_StateUnloaded; + } if (rep->IsError()) + { return Interface_LoadFail; + } if (!therepch.IsBound(num)) + { return Interface_LoadWarning; + } rep = occ::down_cast(therepch.Find(num)); if (rep->IsError()) + { return Interface_DataFail; + } return Interface_DataWarning; } @@ -300,11 +336,17 @@ occ::handle Interface_InterfaceModel::ReportEntity( { occ::handle rep; if (!IsReportEntity(num, semantic)) + { return rep; + } if (semantic) + { rep = occ::down_cast(therepch.Find(num)); + } else + { rep = occ::down_cast(thereports.Find(num)); + } return rep; } @@ -314,7 +356,9 @@ bool Interface_InterfaceModel::IsErrorEntity(const int num) const { occ::handle rep = ReportEntity(num); if (rep.IsNull()) + { return false; + } return rep->IsError(); } @@ -324,7 +368,9 @@ bool Interface_InterfaceModel::IsRedefinedContent(const int num) const { occ::handle rep = ReportEntity(num); if (rep.IsNull()) + { return false; + } return rep->HasNewContent(); } @@ -333,7 +379,9 @@ bool Interface_InterfaceModel::IsRedefinedContent(const int num) const bool Interface_InterfaceModel::ClearReportEntity(const int num) { if (!thereports.IsBound(num)) + { return false; + } thereports.UnBind(num); return true; } @@ -349,30 +397,40 @@ bool Interface_InterfaceModel::SetReportEntity(const int { ent = Value(nm); if (!(ent == rep->Concerned())) + { throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } } else if (num < 0) { nm = -num; ent = Value(nm); if (!(ent == rep->Concerned())) + { throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } } else { ent = rep->Concerned(); nm = Number(ent); if (nm == 0) + { throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } } if (!thereports.IsBound(nm)) { const size_t aMaxRep = thereports.NbBuckets(); if (aMaxRep <= static_cast(thereports.Extent() + 10)) + { thereports.ReSize(aMaxRep * 3 / 2); + } } if (nm <= 0) + { return false; + } return thereports.Bind(nm, rep); } @@ -382,17 +440,27 @@ bool Interface_InterfaceModel::AddReportEntity(const occ::handle ent = rep->Concerned(); if (ent.IsNull()) + { return false; + } int num = Number(ent); if (num == 0) + { return false; + } if (semantic) + { return thereports.Bind(num, rep); + } else + { return therepch.Bind(num, rep); + } } //================================================================================================= @@ -401,7 +469,9 @@ bool Interface_InterfaceModel::IsUnknownEntity(const int num) const { occ::handle rep = ReportEntity(num); if (rep.IsNull()) + { return false; + } return rep->IsUnknown(); } @@ -417,7 +487,9 @@ void Interface_InterfaceModel::FillSemanticChecks(const Interface_CheckIterator& occ::handle t1 = checks.Model(); occ::handle t2 = this; if (t2 != t1) + { return; + } } if (clear) { @@ -426,7 +498,9 @@ void Interface_InterfaceModel::FillSemanticChecks(const Interface_CheckIterator& } int nb = 0; for (checks.Start(); checks.More(); checks.Next()) + { nb++; + } therepch.ReSize(therepch.Extent() + nb + 2); for (checks.Start(); checks.More(); checks.Next()) { @@ -434,7 +508,9 @@ void Interface_InterfaceModel::FillSemanticChecks(const Interface_CheckIterator& int num = checks.Number(); // global check : ok if SAME MODEL if (num == 0) + { thechecksem->GetMessages(ach); + } else { occ::handle ent = Value(num); @@ -460,20 +536,32 @@ const occ::handle& Interface_InterfaceModel::Check(const int n if (num == 0) { if (syntactic) + { return thecheckstx; + } else + { return thechecksem; + } } if (!(syntactic ? thereports.IsBound(num) : therepch.IsBound(num))) + { return nulch(); + } occ::handle trep; if (syntactic) + { trep = thereports.Find(num); + } else + { trep = therepch.Find(num); + } occ::handle rep = occ::down_cast(trep); if (rep.IsNull()) + { return nulch(); + } return rep->Check(); } @@ -484,9 +572,13 @@ const occ::handle& Interface_InterfaceModel::Check(const int n void Interface_InterfaceModel::Reservate(const int nbent) { if (nbent > 0 && static_cast(nbent) > theentities.NbBuckets()) + { theentities.ReSize(static_cast(nbent)); + } if (nbent < 0 && static_cast(-nbent) > thereports.NbBuckets()) + { thereports.ReSize(static_cast(-nbent)); + } } //================================================================================================= @@ -495,15 +587,19 @@ void Interface_InterfaceModel::AddEntity(const occ::handle& { // int newnum; svv #2 if (!anentity->IsKind(typerep())) + { theentities.Add(anentity); - // Report : Add Concerned, but note presence Report and its value + // Report : Add Concerned, but note presence Report and its value + } else { occ::handle rep = occ::down_cast(anentity); AddEntity(rep->Concerned()); const size_t aMaxRep = thereports.NbBuckets(); if (aMaxRep <= static_cast(thereports.Extent() + 10)) + { thereports.ReSize(aMaxRep * 3 / 2); + } thereports.Bind(Number(rep->Concerned()), rep); } } @@ -519,16 +615,22 @@ void Interface_InterfaceModel::AddWithRefs(const occ::handle const bool listall) { if (anent.IsNull()) + { return; + } if (theentities.FindIndex(anent) != 0) { if (!listall) + { return; + } } Interface_GeneralLib lib(proto); AddWithRefs(anent, lib, level, listall); if (Protocol().IsNull() && !proto.IsNull()) + { SetProtocol(proto); + } } //================================================================================================= @@ -539,7 +641,9 @@ void Interface_InterfaceModel::AddWithRefs(const occ::handle { occ::handle proto = Protocol(); if (proto.IsNull()) + { throw Interface_InterfaceMismatch("InterfaceModel : AddWithRefs"); + } AddWithRefs(anent, proto, level, listall); } @@ -551,14 +655,20 @@ void Interface_InterfaceModel::AddWithRefs(const occ::handle const bool listall) { if (anent.IsNull()) + { return; + } if (theentities.FindIndex(anent) != 0) { if (!listall) + { return; + } } else + { AddEntity(anent); + } Interface_EntityIterator iter; occ::handle module; @@ -572,9 +682,13 @@ void Interface_InterfaceModel::AddWithRefs(const occ::handle } int lev1 = level - 1; if (lev1 == 0) + { return; // level = 0 -> all levels; otherwise still n-1 + } for (iter.Start(); iter.More(); iter.Next()) + { AddWithRefs(iter.Value(), lib, lev1, listall); + } } //================================================================================================= @@ -595,36 +709,56 @@ void Interface_InterfaceModel::ReverseOrders(const int after) { int nb = NbEntities(); // int num; svv #2 if (nb < 2 || after >= nb) + { return; + } NCollection_Array1> ents(1, nb); int i; // svv #1 for (i = 1; i <= nb; i++) + { ents.SetValue(i, theentities.FindKey(i)); + } // We will empty the Map, then reload it : in order until after // in reverse order after theentities.Clear(); Reservate(nb); for (i = 1; i <= after; i++) + { theentities.Add(ents(i)); // svv #2 + } for (i = nb; i > after; i--) + { theentities.Add(ents(i)); + } // Will also have to take care of the Reports for (i = nb; i > after; i--) { int i2 = nb + after - i; occ::handle rep1, rep2; if (thereports.IsBound(i)) + { rep1 = thereports.Find(i); + } if (thereports.IsBound(i2)) + { rep2 = thereports.Find(i2); + } if (!rep1.IsNull()) + { thereports.Bind(i2, rep1); + } else + { thereports.UnBind(i2); + } if (!rep2.IsNull()) + { thereports.Bind(i, rep2); + } else + { thereports.UnBind(i); + } } } @@ -638,44 +772,70 @@ void Interface_InterfaceModel::ChangeOrder( int nb = NbEntities(); int i; //, num; svv #2 if (nb < 2 || newnum >= nb || cnt <= 0) + { return; + } NCollection_Array1> ents(1, nb); // We will prepare the change int minum = (oldnum > newnum ? newnum : oldnum); int mxnum = (oldnum < newnum ? newnum : oldnum); int kount = (oldnum > newnum ? cnt : -cnt); if (cnt <= 0 || cnt > mxnum - minum) + { throw Interface_InterfaceMismatch("InterfaceModel : ChangeOrder, Overlap"); + } for (i = 1; i < minum; i++) + { ents.SetValue(i, theentities.FindKey(i)); + } for (i = mxnum + cnt; i <= nb; i++) + { ents.SetValue(i, theentities.FindKey(i)); + } for (i = minum; i < mxnum; i++) + { ents.SetValue(i + kount, theentities.FindKey(i)); + } for (i = oldnum; i < oldnum + cnt; i++) + { ents.SetValue(i + (newnum - oldnum), theentities.FindKey(i)); + } theentities.Clear(); Reservate(nb); for (i = 1; i <= nb; i++) + { theentities.Add(ents(i)); // svv #2 + } int difnum = mxnum - minum; for (i = minum; i < minum + cnt; i++) { occ::handle rep1, rep2; if (thereports.IsBound(i)) + { rep1 = thereports.Find(i); + } if (thereports.IsBound(i + difnum)) + { rep1 = thereports.Find(i + difnum); + } if (!rep1.IsNull()) + { thereports.Bind(i + difnum, rep1); + } else + { thereports.UnBind(i + difnum); + } if (!rep2.IsNull()) + { thereports.Bind(i, rep2); + } else + { thereports.UnBind(i); + } } } @@ -703,14 +863,20 @@ bool Interface_InterfaceModel::SetCategoryNumber(const int num, const int val) { int i, nb = NbEntities(); if (num < 1 || num > nb) + { return false; + } if (thecategory.IsNull()) + { thecategory = new TCollection_HAsciiString(nb, ' '); + } else if (thecategory->Length() < nb) { occ::handle c = new TCollection_HAsciiString(nb, ' '); for (i = thecategory->Length(); i > 0; i--) + { c->SetValue(i, thecategory->Value(i)); + } thecategory = c; } char cval = (char)(val + 32); @@ -723,9 +889,13 @@ bool Interface_InterfaceModel::SetCategoryNumber(const int num, const int val) int Interface_InterfaceModel::CategoryNumber(const int num) const { if (thecategory.IsNull()) + { return 0; + } if (num < 1 || num > thecategory->Length()) + { return 0; + } int val = thecategory->Value(num); return val - 32; } @@ -736,7 +906,9 @@ void Interface_InterfaceModel::FillIterator(Interface_EntityIterator& iter) cons { int nb = NbEntities(); for (int i = 1; i <= nb; i++) + { iter.GetOneItem(theentities.FindKey(i)); + } } //================================================================================================= @@ -757,13 +929,17 @@ Interface_EntityIterator Interface_InterfaceModel::Reports(const bool semantic) { NCollection_DataMap>::Iterator itmap(therepch); for (; itmap.More(); itmap.Next()) + { iter.AddItem(itmap.Value()); + } } else { NCollection_DataMap>::Iterator itmap(thereports); for (; itmap.More(); itmap.Next()) + { iter.AddItem(itmap.Value()); + } } return iter; } @@ -778,9 +954,13 @@ Interface_EntityIterator Interface_InterfaceModel::Redefineds() const { occ::handle rep = occ::down_cast(itmap.Value()); if (rep.IsNull()) + { continue; + } if (!rep->HasNewContent()) + { continue; + } iter.AddItem(rep); } return iter; @@ -795,9 +975,13 @@ const occ::handle& Interface_InterfaceModel::GlobalCheck( const bool syntactic) const { if (syntactic) + { return thecheckstx; + } else + { return thechecksem; + } } //================================================================================================= @@ -824,16 +1008,24 @@ void Interface_InterfaceModel::Print(const occ::handle& ent, } int num = Number(ent); if (mode <= 0) + { S << num; + } if (mode == 0) + { S << ":"; + } if (mode >= 0) { if (num > 0) + { PrintToLog(ent, S); - // PrintLabel (ent,S); + // PrintLabel (ent,S); + } else + { S << "??"; + } } } @@ -863,30 +1055,44 @@ int Interface_InterfaceModel::NextNumberForLabel(const char* const label, { occ::handle lab = StringLabel(Value(i)); if (lab.IsNull()) + { continue; + } if (exact) { if (lab->IsSameString(labs, false)) + { return i; + } } else { if (lab->Length() < lnb) + { continue; + } lab->LowerCase(); if (lab->SearchFromEnd(labs) == lab->Length() - lnb + 1) + { return i; + } } } // In "non exact", we admit to receive the number between 1 and n if (exact) + { return 0; + } i = 0; if (labs->IsIntegerValue()) + { i = atoi(labs->ToCString()); + } if (i <= 0 || i > n) + { i = 0; + } return i; } @@ -903,7 +1109,9 @@ occ::handle Interface_InterfaceModel::Template(const c { occ::handle model, newmod; if (!HasTemplate(name)) + { return model; + } model = occ::down_cast(atemp.ChangeFind(name)); newmod = model->NewEmptyModel(); newmod->GetFromAnother(model); @@ -926,7 +1134,9 @@ occ::handle>> Interf occ::handle>> list = new NCollection_HSequence>(); if (atemp.IsEmpty()) + { return list; + } NCollection_DataMap>::Iterator iter( atemp); for (; iter.More(); iter.Next()) diff --git a/src/DataExchange/TKXSBase/Interface/Interface_MSG.cxx b/src/DataExchange/TKXSBase/Interface/Interface_MSG.cxx index 7c1630ee9b..9e11a335f7 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_MSG.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_MSG.cxx @@ -121,9 +121,13 @@ int Interface_MSG::Read(Standard_IStream& S) while (S.getline(buf, 200)) { if (buf[0] == '@' && buf[1] == '@') + { continue; + } if (buf[0] == '\0') + { continue; + } if (buf[0] == '@') { nb++; @@ -131,11 +135,15 @@ int Interface_MSG::Read(Standard_IStream& S) { key[i - 1] = buf[i]; if (buf[i] == '\0') + { break; + } } } else + { Record(key, buf); + } buf[0] = '\0'; } return nb; @@ -145,7 +153,9 @@ int Interface_MSG::Read(const char* const file) { std::ifstream S(file); if (!S) + { return -1; + } return Read(S); } @@ -153,19 +163,27 @@ int Interface_MSG::Write(Standard_OStream& S, const char* const rootkey) { int nb = 0; if (thedic.IsEmpty()) + { return nb; + } if (rootkey[0] != '\0') - S << "@@ ROOT:" << rootkey << std::endl; + { + S << "@@ ROOT:" << rootkey << '\n'; + } NCollection_DataMap>::Iterator iter(thedic); for (; iter.More(); iter.Next()) { if (!iter.Key().StartsWith(rootkey)) + { continue; + } S << "@" << iter.Key() << "\n"; const occ::handle& str = iter.Value(); if (str.IsNull()) + { continue; + } nb++; S << str->ToCString() << "\n"; } @@ -183,15 +201,21 @@ bool Interface_MSG::IsKey(const char* const key) const char* Interface_MSG::Translated(const char* const key) { if (!therun) + { return key; + } if (!thedic.IsEmpty()) { occ::handle str; if (thedic.Find(key, str)) + { return str->ToCString(); + } } if (theprint) - std::cout << " ** Interface_MSG:Translate ?? " << key << " **" << std::endl; + { + std::cout << " ** Interface_MSG:Translate ?? " << key << " **" << '\n'; + } if (therec) { if (thelist.IsBound(key)) @@ -199,10 +223,14 @@ const char* Interface_MSG::Translated(const char* const key) thelist.ChangeFind(key)++; } else + { thelist.Bind(key, 1); + } } if (theraise) + { throw Standard_DomainError("Interface_MSG : Translate"); + } return key; } @@ -220,18 +248,24 @@ void Interface_MSG::Record(const char* const key, const char* const item) return; } if (theprint) - std::cout << " ** Interface_MSG:Record ?? " << key << " ** " << item << " **" << std::endl; + { + std::cout << " ** Interface_MSG:Record ?? " << key << " ** " << item << " **" << '\n'; + } if (therec) { if (thedup.IsNull()) + { thedup = new NCollection_HSequence>(); + } dup = new TCollection_HAsciiString(key); thedup->Append(dup); dup = new TCollection_HAsciiString(item); thedup->Append(dup); } if (theraise) + { throw Standard_DomainError("Interface_MSG : Record"); + } } void Interface_MSG::SetTrace(const bool toprint, const bool torecord) @@ -251,21 +285,25 @@ void Interface_MSG::PrintTrace(Standard_OStream& S) occ::handle dup; int i, nb = 0; if (!thedup.IsNull()) + { nb = thedup->Length() / 2; + } for (i = 1; i <= nb; i++) { dup = thedup->Value(2 * i - 1); S << "** DUP:" << dup->ToCString(); dup = thedup->Value(2 * i); - S << " ** " << dup->ToCString() << std::endl; + S << " ** " << dup->ToCString() << '\n'; } if (thelist.IsEmpty()) + { return; + } NCollection_DataMap::Iterator iter(thelist); for (; iter.More(); iter.Next()) { - S << "** MSG(NB=" << iter.Value() << "): " << iter.Key() << std::endl; + S << "** MSG(NB=" << iter.Value() << "): " << iter.Key() << '\n'; } } @@ -281,7 +319,9 @@ double Interface_MSG::Intervalled(const double val, const int order, const bool for (int i = 0; i < 200; i++) { if (vl < bu) + { break; + } bl = bu; bu *= 10.; } @@ -292,81 +332,137 @@ double Interface_MSG::Intervalled(const double val, const int order, const bool for (int i = 0; i < 200; i++) { if (vl >= bl) + { break; + } bu = bl; bl /= 10.; } if (vl == 0.) + { return 0.; + } } double rst = vl / bl; if (order <= 1) + { rst = (upper ? 10. : 1.); + } else if (order == 2) { if (rst <= 3.) + { rst = (upper ? 3. : 1.); + } else + { rst = (upper ? 10. : 3.); + } } else if (order == 3) { if (rst <= 2.) + { rst = (upper ? 2. : 1.); + } else if (rst <= 5.) + { rst = (upper ? 5. : 2.); + } else + { rst = (upper ? 10. : 5.); + } } else if (order == 4) { if (rst <= 2.) + { rst = (upper ? 2. : 1.); + } else if (rst <= 3.) + { rst = (upper ? 3. : 2.); + } else if (rst <= 6.) + { rst = (upper ? 6. : 3.); + } else + { rst = (upper ? 10. : 6.); + } } else if (order <= 6) { if (rst <= 1.5) + { rst = (upper ? 1.5 : 1.); + } else if (rst <= 2.) + { rst = (upper ? 2. : 1.5); + } else if (rst <= 3.) + { rst = (upper ? 3. : 2.); + } else if (rst <= 5.) + { rst = (upper ? 5. : 3.); + } else if (rst <= 7.) + { rst = (upper ? 7. : 5.); + } else + { rst = (upper ? 10. : 7.); + } } else { // only makes sense up to 10 ... if (rst <= 1.2) + { rst = (upper ? 1.2 : 1.); + } else if (rst <= 1.5) + { rst = (upper ? 1.5 : 1.2); + } else if (rst <= 2.) + { rst = (upper ? 2. : 1.5); + } else if (rst <= 2.5) + { rst = (upper ? 2.5 : 2.); + } else if (rst <= 3.) + { rst = (upper ? 3. : 2.5); + } else if (rst <= 4.) + { rst = (upper ? 4. : 3.); + } else if (rst <= 5.) + { rst = (upper ? 5. : 4.); + } else if (rst <= 6.) + { rst = (upper ? 6. : 5.); + } else if (rst <= 8.) + { rst = (upper ? 8. : 6.); + } else + { rst = (upper ? 10. : 8.); + } } return ((val < 0.) ? -(bl * rst) : (bl * rst)); } @@ -417,9 +513,13 @@ void Interface_MSG::TDate(const char* const text, } char* pText = (char*)text; if (!format || format[0] == '\0') + { Sprintf(pText, "%4.4d-%2.2d-%2.2d:%2.2d-%2.2d-%2.2d", y2, m2, d2, h2, n2, s2); + } else if ((format[0] == 'c' || format[0] == 'C') && format[1] == ':') + { Sprintf(pText, &format[2], y2, m2, d2, h2, n2, s2); + } } bool Interface_MSG::NDate(const char* const text, @@ -437,22 +537,38 @@ bool Interface_MSG::NDate(const char* const text, if (val >= 48 && val <= 57) { if ((num & 1) == 0) + { num++; + } if (num == 1) + { yy = yy * 10 + (val - 48); + } if (num == 3) + { mm = mm * 10 + (val - 48); + } if (num == 5) + { dd = dd * 10 + (val - 48); + } if (num == 7) + { hh = hh * 10 + (val - 48); + } if (num == 9) + { mn = mn * 10 + (val - 48); + } if (num == 11) + { ss = ss * 10 + (val - 48); + } } else if ((num & 1) != 0) + { num++; + } } return (num > 0); } @@ -462,33 +578,61 @@ int Interface_MSG::CDate(const char* const text1, const char* const text2) int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, j1 = 0, j2 = 0, j3 = 0, j4 = 0, j5 = 0, j6 = 0; if (!NDate(text1, i1, i2, i3, i4, i5, i6)) + { return 0; + } if (!NDate(text2, j1, j2, j3, j4, j5, j6)) + { return 0; + } if (i1 < j1) + { return -1; + } if (i1 > j1) + { return 1; + } if (i2 < j2) + { return -1; + } if (i2 > j2) + { return 1; + } if (i3 < j3) + { return -1; + } if (i3 > j3) + { return 1; + } if (i4 < j4) + { return -1; + } if (i4 > j4) + { return 1; + } if (i5 < j5) + { return -1; + } if (i5 > j5) + { return 1; + } if (i6 < j6) + { return -1; + } if (i6 > j6) + { return 1; + } return 0; } @@ -496,30 +640,54 @@ const char* Interface_MSG::Blanks(const int val, const int max) { int count; if (val < 0) + { return Interface_MSG::Blanks(-val, max - 1); + } if (val < 10) + { count = 9; + } else if (val < 100) + { count = 8; + } else if (val < 1000) + { count = 7; + } else if (val < 10000) + { count = 6; + } else if (val < 100000) + { count = 5; + } else if (val < 1000000) + { count = 4; + } else if (val < 10000000) + { count = 3; + } else if (val < 100000000) + { count = 2; + } else if (val < 1000000000) + { count = 1; + } else + { count = 0; + } count = count + max - 10; if (count < 0) + { count = 0; + } return &blank[maxblank - count]; } @@ -527,16 +695,22 @@ const char* Interface_MSG::Blanks(const char* const val, const int max) { int lng = (int)strlen(val); if (lng > maxblank || lng > max) + { return ""; + } return &blank[maxblank - max + lng]; } const char* Interface_MSG::Blanks(const int count) { if (count <= 0) + { return ""; + } if (count >= maxblank) + { return blank; + } return &blank[maxblank - count]; } @@ -556,9 +730,15 @@ void Interface_MSG::Print(Standard_OStream& S, const char* const val, const int int m1 = (max - lng) / 2; int m2 = max - lng - m1; if (just < 0) + { S << val << &blank[maxblank - m1 - m2]; + } else if (just == 0) + { S << &blank[maxblank - m1] << val << &blank[maxblank - m2]; + } else + { S << &blank[maxblank - m1 - m2] << val; + } } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_NodeOfGeneralLib_0.cxx b/src/DataExchange/TKXSBase/Interface/Interface_NodeOfGeneralLib_0.cxx index 1c73d06a24..a924a32742 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_NodeOfGeneralLib_0.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_NodeOfGeneralLib_0.cxx @@ -29,11 +29,15 @@ Interface_NodeOfGeneralLib::Interface_NodeOfGeneralLib() = default; void Interface_NodeOfGeneralLib::AddNode(const occ::handle& anode) { if (thenode == anode) + { return; + } if (thenext.IsNull()) { if (thenode.IsNull()) + { thenode = anode; + } else { thenext = new Interface_NodeOfGeneralLib; @@ -41,7 +45,9 @@ void Interface_NodeOfGeneralLib::AddNode(const occ::handleAddNode(anode); + } } const occ::handle& Interface_NodeOfGeneralLib::Module() const diff --git a/src/DataExchange/TKXSBase/Interface/Interface_NodeOfReaderLib_0.cxx b/src/DataExchange/TKXSBase/Interface/Interface_NodeOfReaderLib_0.cxx index 50b7108d57..d8092ee32a 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_NodeOfReaderLib_0.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_NodeOfReaderLib_0.cxx @@ -29,11 +29,15 @@ Interface_NodeOfReaderLib::Interface_NodeOfReaderLib() = default; void Interface_NodeOfReaderLib::AddNode(const occ::handle& anode) { if (thenode == anode) + { return; + } if (thenext.IsNull()) { if (thenode.IsNull()) + { thenode = anode; + } else { thenext = new Interface_NodeOfReaderLib; @@ -41,7 +45,9 @@ void Interface_NodeOfReaderLib::AddNode(const occ::handleAddNode(anode); + } } const occ::handle& Interface_NodeOfReaderLib::Module() const diff --git a/src/DataExchange/TKXSBase/Interface/Interface_ParamSet.cxx b/src/DataExchange/TKXSBase/Interface/Interface_ParamSet.cxx index 3076aecb3c..dc571991a0 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_ParamSet.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_ParamSet.cxx @@ -53,7 +53,9 @@ int Interface_ParamSet::Append(const char* const val, Interface_FileParameter& FP = thelist->ChangeValue(thenbpar); FP.Init(val, typ); if (nument != 0) + { FP.SetEntityNumber(nument); + } } else { @@ -65,7 +67,9 @@ int Interface_ParamSet::Append(const char* const val, int newres = (int)(thelnres * 2 + lnval); char* newval = new char[newres]; for (i = 0; i < thelnval; i++) + { newval[i] = theval[i]; // szv#4:S4163:12Mar99 `<= thelnres` was wrong + } // and that's not all: must realign Params already recorded on // the old character reservation ... // int delta = (int) (newval - theval); @@ -83,7 +87,9 @@ int Interface_ParamSet::Append(const char* const val, int onum = OFP.EntityNumber(); OFP.Init(pnewVal + delta, otyp); // and there we go; we put back in the box if (onum != 0) + { OFP.SetEntityNumber(onum); + } } // Confirm the new reservation char* anOldVal = theval; @@ -93,13 +99,17 @@ int Interface_ParamSet::Append(const char* const val, } // Register this parameter for (i = 0; i < lnval; i++) + { theval[thelnval + i] = val[i]; + } theval[thelnval + lnval] = '\0'; Interface_FileParameter& FP = thelist->ChangeValue(thenbpar); FP.Init(&theval[thelnval], typ); if (nument != 0) + { FP.SetEntityNumber(nument); + } thelnval += (int)(lnval + 1); } return thenbpar; @@ -127,45 +137,65 @@ int Interface_ParamSet::NbParams() const const Interface_FileParameter& Interface_ParamSet::Param(const int num) const { if (num > themxpar) + { return thenext->Param(num - themxpar); + } else + { return thelist->Value(num); + } } Interface_FileParameter& Interface_ParamSet::ChangeParam(const int num) { if (num > themxpar) + { return thenext->ChangeParam(num - themxpar); + } else + { return thelist->ChangeValue(num); + } } void Interface_ParamSet::SetParam(const int num, const Interface_FileParameter& FP) { if (num > themxpar) + { thenext->SetParam(num - themxpar, FP); + } else + { thelist->SetValue(num, FP); + } } occ::handle Interface_ParamSet::Params(const int num, const int nb) const { int i, n0 = num - 1, nbp = nb; if (num > themxpar) + { return thenext->Params(num - themxpar, nb); + } if (num == 0 && nb == 0) { n0 = 0; nbp = thenbpar; if (thenbpar <= themxpar) + { return thelist; // and there you go + } } occ::handle list = new Interface_ParamList; if (nb == 0) + { return list; + } for (i = 1; i <= nbp; i++) + { list->SetValue(i, Param(n0 + i)); + } return list; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_Protocol.cxx b/src/DataExchange/TKXSBase/Interface/Interface_Protocol.cxx index 3ba396de01..a53aabce03 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_Protocol.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_Protocol.cxx @@ -55,7 +55,9 @@ void Interface_Protocol::ClearActive() int Interface_Protocol::CaseNumber(const occ::handle& obj) const { if (obj.IsNull()) + { return 0; + } return TypeNumber(Type(obj)); } @@ -79,7 +81,9 @@ occ::handle Interface_Protocol::Type(const occ::handleDynamicType(); } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_STAT.cxx b/src/DataExchange/TKXSBase/Interface/Interface_STAT.cxx index ca1391e78c..d5b0467b13 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_STAT.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_STAT.cxx @@ -115,7 +115,9 @@ void Interface_STAT::Phase(const int num, name = voidname; } else if (num < 1 || num > thephdeb->Length()) + { return; + } else { // Phase @@ -131,9 +133,13 @@ void Interface_STAT::Phase(const int num, double Interface_STAT::Step(const int num) const { if (thestw.IsNull()) + { return 1.; + } if (num < 1 || num > thestw->Length()) + { return 1.; + } return thestw->Value(num); } @@ -206,7 +212,9 @@ void Interface_STAT::NextPhase(const int items, const int cycles) // if a single cycle, we start it; otherwise, wait NextCycle TheStat.nbitc = 0; if (cycles == 1) + { NextCycle(items); + } } void Interface_STAT::SetPhase(const int items, const int cycles) @@ -231,7 +239,9 @@ void Interface_STAT::NextCycle(const int items) void Interface_STAT::NextStep() { if (TheStat.numst >= TheStat.n1) + { return; + } TheStat.numst++; TheStat.oldst += TheStat.stw; TheStat.numitem = 0; @@ -260,7 +270,9 @@ const char* Interface_STAT::Where(const bool phase) int Interface_STAT::Percent(const bool phase) { if (TheStat.numitem > TheStat.nbitc) + { TheStat.numitem = TheStat.nbitc; + } // we count the items already passed double enphase = TheStat.olditp * TheStat.otph + // complete cycles passed TheStat.nbitc * TheStat.oldst + // current cycle, complete steps passed @@ -269,7 +281,9 @@ int Interface_STAT::Percent(const bool phase) double prophase = enphase / (TheStat.nbitp * TheStat.otph); int res = int(prophase * 100.); if (phase) + { return res; + } // that's it for this phase // counting in the phases diff --git a/src/DataExchange/TKXSBase/Interface/Interface_ShareFlags.cxx b/src/DataExchange/TKXSBase/Interface/Interface_ShareFlags.cxx index faf8028669..55ec831ee4 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_ShareFlags.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_ShareFlags.cxx @@ -63,7 +63,9 @@ Interface_ShareFlags::Interface_ShareFlags(const Interface_Graph& agraph) themodel = agraph.Model(); int nb = themodel->NbEntities(); if (nb == 0) + { return; + } theroots = new NCollection_HSequence>(); for (int i = 1; i <= nb; i++) { @@ -73,9 +75,13 @@ Interface_ShareFlags::Interface_ShareFlags(const Interface_Graph& agraph) agraph.GetSharings(ent); if (!list.IsNull() && list->Length() > 0) + { theflags.SetTrue(i); + } else + { theroots->Append(ent); + } } } @@ -85,7 +91,9 @@ void Interface_ShareFlags::Evaluate(const Interface_GeneralLib& lib, bool patool = gtool.IsNull(); int nb = themodel->NbEntities(); if (nb == 0) + { return; + } theroots = new NCollection_HSequence>(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= nb; i++) @@ -95,7 +103,9 @@ void Interface_ShareFlags::Evaluate(const Interface_GeneralLib& lib, // equivalent "Content" occ::handle ent = themodel->Value(i); if (themodel->IsRedefinedContent(i)) + { ent = themodel->ReportEntity(i)->Content(); + } // Result obtained via GeneralLib Interface_EntityIterator iter; @@ -104,12 +114,16 @@ void Interface_ShareFlags::Evaluate(const Interface_GeneralLib& lib, if (patool) { if (lib.Select(ent, module, CN)) + { module->FillShared(themodel, CN, ent, iter); + } } else { if (gtool->Select(ent, module, CN)) + { module->FillShared(themodel, CN, ent, iter); + } } // Entities shared by : need to mark each one as "Shared" @@ -122,7 +136,9 @@ void Interface_ShareFlags::Evaluate(const Interface_GeneralLib& lib, for (i = 1; i <= nb; i++) { if (!theflags.Value(i)) + { theroots->Append(themodel->Value(i)); + } } } @@ -135,7 +151,9 @@ bool Interface_ShareFlags::IsShared(const occ::handle& ent) { int num = themodel->Number(ent); if (num == 0 || num > themodel->NbEntities()) + { throw Standard_DomainError("Interface ShareFlags : IsShared"); + } return theflags.Value(num); } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_ShareTool.cxx b/src/DataExchange/TKXSBase/Interface/Interface_ShareTool.cxx index ad070944d7..aa1adcc2a1 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_ShareTool.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_ShareTool.cxx @@ -124,7 +124,9 @@ int Interface_ShareTool::NbTypedSharings(const occ::handle& occ::handle>> list = thegraph.GetSharings(ent); if (list.IsNull()) + { return 0; + } int result = 0; int n = list->Length(); @@ -132,9 +134,13 @@ int Interface_ShareTool::NbTypedSharings(const occ::handle& { occ::handle entsh = list->Value(i); if (entsh.IsNull()) + { continue; + } if (entsh->IsKind(atype)) + { result++; + } } return result; } @@ -147,7 +153,9 @@ occ::handle Interface_ShareTool::TypedSharing( occ::handle>> list = thegraph.GetSharings(ent); if (list.IsNull()) + { return nullptr; + } occ::handle entresult; int result = 0; int n = list->Length(); @@ -155,17 +163,23 @@ occ::handle Interface_ShareTool::TypedSharing( { occ::handle entsh = list->Value(i); if (entsh.IsNull()) + { continue; + } if (entsh->IsKind(atype)) { entresult = entsh; result++; if (result > 1) + { throw Interface_InterfaceError("Interface ShareTool : TypedSharing, more than one found"); + } } } if (result == 0) + { throw Interface_InterfaceError("Interface ShareTool : TypedSharing, not found"); + } return entresult; } @@ -188,18 +202,22 @@ Interface_EntityIterator Interface_ShareTool::All(const occ::handleNumber(subl.Value()); if (fl->Value(nm) > 0) + { continue; + } n0++; fl->SetValue(nm, n0); } } // Warning, are there any omissions? for (i = 1; i <= nb; i++) + { if (fl->Value(i) == 0) { n0++; fl->SetValue(i, n0); } + } } else { @@ -212,7 +230,9 @@ Interface_EntityIterator Interface_ShareTool::All(const occ::handle en = sq->Value(i); int num = model->Number(en); if (fl->Value(num) != 0) + { continue; // already seen + } n0++; fl->SetValue(num, n0); Interface_EntityIterator sh = Shareds(en); @@ -228,17 +248,25 @@ Interface_EntityIterator Interface_ShareTool::All(const occ::handleSetValue(n0, i); } if (rootlast && ent != model) + { for (i = 1; i <= nb; i++) { if (ord->Value(i) != 0) + { list.AddItem(model->Value(ord->Value(i))); + } } + } else + { for (i = nb; i > 0; i--) { if (ord->Value(i) != 0) + { list.AddItem(model->Value(ord->Value(i))); + } } + } return list; } @@ -252,5 +280,5 @@ void Interface_ShareTool::Print(const Interface_EntityIterator& iter, Standard_O S << " n0/id:"; Model()->Print(ent, S); } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_SignLabel.cxx b/src/DataExchange/TKXSBase/Interface/Interface_SignLabel.cxx index 419decc9b2..221c21d47d 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_SignLabel.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_SignLabel.cxx @@ -34,9 +34,13 @@ TCollection_AsciiString Interface_SignLabel::Text( TCollection_AsciiString atext; occ::handle model = occ::down_cast(context); if (ent.IsNull() || model.IsNull()) + { return atext; + } occ::handle lab = model->StringLabel(ent); if (!lab.IsNull()) + { atext = lab->String(); + } return atext; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_SignType.cxx b/src/DataExchange/TKXSBase/Interface/Interface_SignType.cxx index 94e8e93120..de9a19f3a6 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_SignType.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_SignType.cxx @@ -26,7 +26,9 @@ TCollection_AsciiString Interface_SignType::Text( TCollection_AsciiString atext; occ::handle model = occ::down_cast(context); if (ent.IsNull() || model.IsNull()) + { return atext; + } atext.AssignCat(Value(ent, model)); return atext; } @@ -37,7 +39,9 @@ const char* Interface_SignType::ClassName(const char* const typnam) for (int i = 0; tn[i] != '\0'; i++) { if (tn[i] == '_') + { return &tn[i + 1]; + } } return tn; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_Static.cxx b/src/DataExchange/TKXSBase/Interface/Interface_Static.cxx index ff95e3c524..fcff3b658d 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_Static.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_Static.cxx @@ -54,17 +54,25 @@ Interface_Static::Interface_Static(const char* const family, case Interface_ParamInteger: { int lim; if (other->IntegerLimit(true, lim)) + { SetIntegerLimit(true, lim); + } if (other->IntegerLimit(false, lim)) + { SetIntegerLimit(false, lim); + } } break; case Interface_ParamReal: { double lim; if (other->RealLimit(true, lim)) + { SetRealLimit(true, lim); + } if (other->RealLimit(false, lim)) + { SetRealLimit(false, lim); + } SetUnitDef(other->UnitDef()); } break; @@ -75,7 +83,9 @@ Interface_Static::Interface_Static(const char* const family, StartEnum(e0, match); // if (e1 >= e0) theenums = new NCollection_HArray1(e0,e1); for (i = e0; i <= e1; i++) + { AddEnum(other->EnumVal(i)); + } } break; case Interface_ParamIdent: @@ -86,7 +96,9 @@ Interface_Static::Interface_Static(const char* const family, } if (other->IsSetValue()) + { SetCStringValue(other->CStringValue()); + } } // ## Print ## @@ -96,11 +108,15 @@ void Interface_Static::PrintStatic(Standard_OStream& S) const S << "--- Static Value : " << Name() << " Family:" << Family(); Print(S); if (!thewild.IsNull()) - S << " -- Attached to wild-card : " << thewild->Name() << std::endl; + { + S << " -- Attached to wild-card : " << thewild->Name() << '\n'; + } S << "--- Actual status : " << (theupdate ? "" : "original") << " Value : "; if (thesatisf) - S << " -- Specific Function for Satisfies : " << thesatisn.ToCString() << std::endl; + { + S << " -- Specific Function for Satisfies : " << thesatisn.ToCString() << '\n'; + } } // ######### COMPLEMENTS ########## @@ -141,20 +157,28 @@ bool Interface_Static::Init(const char* const family, const char* const init) { if (name[0] == '\0') + { return false; + } if (MoniTool_TypedValue::Stats().IsBound(name)) + { return false; + } occ::handle item; if (type == Interface_ParamMisc) { occ::handle other = Interface_Static::Static(init); if (other.IsNull()) + { return false; + } item = new Interface_Static(family, name, other); } else + { item = new Interface_Static(family, name, type, init); + } MoniTool_TypedValue::Stats().Bind(name, item); return true; @@ -192,46 +216,76 @@ bool Interface_Static::Init(const char* const family, case '&': { occ::handle unstat = Interface_Static::Static(name); if (unstat.IsNull()) + { return false; + } // Editions : init gives a small edition text, in 2 terms "cmd var" : // imin imax rmin rmax unit // enum ematch eval int i, iblc = 0; for (i = 0; init[i] != '\0'; i++) + { if (init[i] == ' ') + { iblc = i + 1; + } + } // Recognition of the sub-case and routing if (init[0] == 'i' && init[2] == 'i') + { unstat->SetIntegerLimit(false, atoi(&init[iblc])); + } else if (init[0] == 'i' && init[2] == 'a') + { unstat->SetIntegerLimit(true, atoi(&init[iblc])); + } else if (init[0] == 'r' && init[2] == 'i') + { unstat->SetRealLimit(false, Atof(&init[iblc])); + } else if (init[0] == 'r' && init[2] == 'a') + { unstat->SetRealLimit(true, Atof(&init[iblc])); + } else if (init[0] == 'u') + { unstat->SetUnitDef(&init[iblc]); + } else if (init[0] == 'e' && init[1] == 'm') + { unstat->StartEnum(atoi(&init[iblc]), true); + } else if (init[0] == 'e' && init[1] == 'n') + { unstat->StartEnum(atoi(&init[iblc]), false); + } else if (init[0] == 'e' && init[1] == 'v') + { unstat->AddEnum(&init[iblc]); + } else + { return false; + } return true; } default: return false; } if (!Interface_Static::Init(family, name, epyt, init)) + { return false; + } if (type != 'p') + { return true; + } occ::handle stat = Interface_Static::Static(name); // NT stat->SetSatisfies (StaticPath,"Path"); if (!stat->Satisfies(stat->HStringValue())) + { stat->SetCStringValue(""); + } return true; } @@ -250,27 +304,45 @@ bool Interface_Static::IsPresent(const char* const name) const char* Interface_Static::CDef(const char* const name, const char* const part) { if (!part || part[0] == '\0') + { return ""; + } occ::handle stat = Interface_Static::Static(name); if (stat.IsNull()) + { return ""; + } if (part[0] == 'f' && part[1] == 'a') + { return stat->Family(); + } if (part[0] == 'l' && part[1] == 'a') + { return stat->Label(); + } if (part[0] == 's' && part[1] == 'a') + { return stat->SatisfiesName(); + } if (part[0] == 't' && part[1] == 'y') { Interface_ParamType typ = stat->Type(); if (typ == Interface_ParamInteger) + { return "integer"; + } if (typ == Interface_ParamReal) + { return "real"; + } if (typ == Interface_ParamText) + { return "text"; + } if (typ == Interface_ParamEnum) + { return "enum"; + } return "?type?"; } if (part[0] == 'e') @@ -283,7 +355,9 @@ const char* Interface_Static::CDef(const char* const name, const char* const par { int ilim; if (!stat->IntegerLimit((part[2] == 'a'), ilim)) + { return ""; + } Sprintf(defmess, "%d", ilim); return defmess; } @@ -291,27 +365,37 @@ const char* Interface_Static::CDef(const char* const name, const char* const par { double rlim; if (!stat->RealLimit((part[2] == 'a'), rlim)) + { return ""; + } Sprintf(defmess, "%f", rlim); return defmess; } if (part[0] == 'u') + { return stat->UnitDef(); + } return ""; } int Interface_Static::IDef(const char* const name, const char* const part) { if (!part || part[0] == '\0') + { return 0; + } occ::handle stat = Interface_Static::Static(name); if (stat.IsNull()) + { return 0; + } if (part[0] == 'i') { int ilim; if (!stat->IntegerLimit((part[2] == 'a'), ilim)) + { return 0; + } return ilim; } if (part[0] == 'e') @@ -320,11 +404,17 @@ int Interface_Static::IDef(const char* const name, const char* const part) bool match; stat->EnumDef(startcase, endcase, match); if (part[1] == 's') + { return startcase; + } if (part[1] == 'c') + { return (endcase - startcase + 1); + } if (part[1] == 'm') + { return (match ? 1 : 0); + } if (part[1] == 'v') { char vale[51]; @@ -341,11 +431,17 @@ bool Interface_Static::IsSet(const char* const name, const bool proper) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } if (item->IsSetValue()) + { return true; + } if (proper) + { return false; + } item = item->Wild(); return item->IsSetValue(); } @@ -393,7 +489,9 @@ bool Interface_Static::SetCVal(const char* const name, const char* const val) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } return item->SetCStringValue(val); } @@ -401,9 +499,13 @@ bool Interface_Static::SetIVal(const char* const name, const int val) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } if (!item->SetIntegerValue(val)) + { return false; + } return true; } @@ -411,7 +513,9 @@ bool Interface_Static::SetRVal(const char* const name, const double val) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } return item->SetRealValue(val); } @@ -421,7 +525,9 @@ bool Interface_Static::Update(const char* const name) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } item->SetUptodate(); return true; } @@ -430,7 +536,9 @@ bool Interface_Static::IsUpdated(const char* const name) { occ::handle item = Interface_Static::Static(name); if (item.IsNull()) + { return false; + } return item->UpdatedStatus(); } @@ -447,31 +555,45 @@ occ::handle>> Interf { occ::handle item = occ::down_cast(iter.Value()); if (item.IsNull()) + { continue; + } bool ok = true; if (criter[0] == '$' && criter[1] == '\0') { if ((item->Family())[0] != '$') + { ok = false; + } } else if (criter[0] != '\0') { if (strcmp(criter, item->Family())) + { continue; + } ok = true; } else { // all ... except family with $ if (item->Family()[0] == '$') + { continue; + } } if (ok && (modup == 1)) + { ok = !item->UpdatedStatus(); + } if (ok && (modup == 2)) + { ok = item->UpdatedStatus(); + } if (ok) + { list->Append(new TCollection_HAsciiString(iter.Key())); + } } return list; } diff --git a/src/DataExchange/TKXSBase/Interface/Interface_UndefinedContent.cxx b/src/DataExchange/TKXSBase/Interface/Interface_UndefinedContent.cxx index cf3d180815..dcf152ee13 100644 --- a/src/DataExchange/TKXSBase/Interface/Interface_UndefinedContent.cxx +++ b/src/DataExchange/TKXSBase/Interface/Interface_UndefinedContent.cxx @@ -65,15 +65,21 @@ bool Interface_UndefinedContent::ParamData(const int occ::handle& val) const { if (num < 1 || num > thenbparams) + { throw Standard_OutOfRange("Interface UndefinedContent : ParamData"); + } int desc = theparams->Value(num); int local = ((desc >> Content_LocalShift) & Content_LocalField); ptype = Interface_ParamType(desc & Content_TypeField); int adr = desc >> Content_NumberShift; if (local == Content_LocalRef) + { ent = theentities.Value(adr); + } else + { val = thevalues->Value(adr); + } return (local == Content_LocalRef); } @@ -91,7 +97,9 @@ occ::handle Interface_UndefinedContent::ParamEntity(const in { int desc = theparams->Value(num); if (((desc >> Content_LocalShift) & Content_LocalField) != Content_LocalRef) + { throw Interface_InterfaceError("UndefinedContent : Param is not Entity type"); + } return theentities.Value(desc >> Content_NumberShift); } @@ -99,7 +107,9 @@ occ::handle Interface_UndefinedContent::ParamValue(con { int desc = theparams->Value(num); if (((desc >> Content_LocalShift) & Content_LocalField) != 0) + { throw Interface_InterfaceError("UndefinedContent : Param is not literal"); + } return thevalues->Value(desc >> Content_NumberShift); } @@ -111,15 +121,21 @@ void Interface_UndefinedContent::Reservate(const int nb, const int nblit) if (nb > thenbparams) { // Total reservation if (theparams.IsNull()) + { theparams = new NCollection_HArray1(1, nb); + } else if (nb > theparams->Length()) { int nbnew = 2 * thenbparams; // reserve a bit more if (nbnew < nb) + { nbnew = nb; + } occ::handle> newparams = new NCollection_HArray1(1, nbnew); for (int i = 1; i <= thenbparams; i++) + { newparams->SetValue(i, theparams->Value(i)); + } theparams = newparams; } } @@ -127,16 +143,22 @@ void Interface_UndefinedContent::Reservate(const int nb, const int nblit) if (nblit > thenbstr) { // Literal reservation if (thevalues.IsNull()) + { thevalues = new NCollection_HArray1>(1, nblit); + } else if (nblit > thevalues->Length()) { int nbnew = 2 * thenbstr; // reserve a bit more if (nbnew < nblit) + { nbnew = nblit; + } occ::handle>> newvalues = new NCollection_HArray1>(1, nbnew); for (int i = 1; i <= thenbstr; i++) + { newvalues->SetValue(i, thevalues->Value(i)); + } thevalues = newvalues; } } @@ -177,12 +199,16 @@ void Interface_UndefinedContent::RemoveParam(const int num) bool c1ent = (local == Content_LocalRef); // Remove an Entity if (c1ent) + { theentities.Remove(rang); - // Remove a Literal + // Remove a Literal + } else { // thevalues->Remove(rang) but it is an array for (int i = rang + 1; i <= thenbstr; i++) + { thevalues->SetValue(i - 1, thevalues->Value(i)); + } occ::handle nulstr; thevalues->SetValue(thenbstr, nulstr); thenbstr--; @@ -190,7 +216,9 @@ void Interface_UndefinedContent::RemoveParam(const int num) // Remove this parameter from the list (which is an array) int np; // svv Jan11 2000 : porting on DEC for (np = num + 1; np <= thenbparams; np++) + { theparams->SetValue(np - 1, theparams->Value(np)); + } theparams->SetValue(thenbparams, 0); thenbparams--; // Renumber, Entity or Literal, depending @@ -199,7 +227,9 @@ void Interface_UndefinedContent::RemoveParam(const int num) desc = theparams->Value(np); if (((desc >> Content_LocalShift) & Content_LocalField) == local && (desc >> Content_NumberShift) > rang) + { theparams->SetValue(np, desc - (1 << Content_NumberShift)); + } } } @@ -222,7 +252,9 @@ void Interface_UndefinedContent::SetLiteral(const int desc = theparams->Value(i); if (((desc >> Content_LocalShift) & Content_LocalField) == Content_LocalRef && (desc >> Content_NumberShift) > rang) + { theparams->SetValue(i, desc - (1 << Content_NumberShift)); + } } // And prepare arrival of an additional Literal Reservate(thenbparams, thenbstr + 1); @@ -251,7 +283,9 @@ void Interface_UndefinedContent::SetEntity(const int // (Remove Literal but in an array) int i; // svv Jan11 2000 : porting on DEC for (i = rang + 1; i <= thenbstr; i++) + { thevalues->SetValue(i - 1, thevalues->Value(i)); + } occ::handle nulstr; thevalues->SetValue(thenbstr, nulstr); @@ -260,7 +294,9 @@ void Interface_UndefinedContent::SetEntity(const int desc = theparams->Value(i); if (((desc >> Content_LocalShift) & Content_LocalField) == 0 && (desc >> Content_NumberShift) > rang) + { theparams->SetValue(i, desc - (1 << Content_NumberShift)); + } } // And prepare arrival of an additional Entity thenbstr--; @@ -269,7 +305,9 @@ void Interface_UndefinedContent::SetEntity(const int theentities.Append(ent); } else + { theentities.SetValue(rang, ent); + } desc = int(ptype) + (Content_LocalRef << Content_LocalShift) + (rang << Content_NumberShift); theparams->SetValue(num, desc); @@ -285,7 +323,9 @@ void Interface_UndefinedContent::SetEntity(const int int local = ((desc >> Content_LocalShift) & Content_LocalField); bool c1ent = (local == Content_LocalRef); if (!c1ent) + { throw Interface_InterfaceError("UndefinedContent : SetEntity"); + } theentities.SetValue(rang, ent); } @@ -316,6 +356,8 @@ void Interface_UndefinedContent::GetFromAnother( AddEntity(ptype, ent); } else + { AddLiteral(ptype, val); + } } } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_AttrList.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_AttrList.cxx index 8df8a8a2ea..b725171eb4 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_AttrList.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_AttrList.cxx @@ -37,7 +37,9 @@ void MoniTool_AttrList::SetAttribute(const char* const name bool MoniTool_AttrList::RemoveAttribute(const char* const name) { if (theattrib.IsEmpty()) + { return false; + } return theattrib.UnBind(name); } @@ -67,9 +69,13 @@ occ::handle MoniTool_AttrList::Attribute(const char* const n { occ::handle atr; if (theattrib.IsEmpty()) + { return atr; + } if (!theattrib.Find(name, atr)) + { atr.Nullify(); + } return atr; } @@ -77,13 +83,21 @@ MoniTool_ValueType MoniTool_AttrList::AttributeType(const char* const name) cons { occ::handle atr = Attribute(name); if (atr.IsNull()) + { return MoniTool_ValueVoid; + } if (atr->DynamicType() == STANDARD_TYPE(MoniTool_IntVal)) + { return MoniTool_ValueInteger; + } if (atr->DynamicType() == STANDARD_TYPE(MoniTool_RealVal)) + { return MoniTool_ValueReal; + } if (atr->DynamicType() == STANDARD_TYPE(TCollection_HAsciiString)) + { return MoniTool_ValueText; + } return MoniTool_ValueIdent; } @@ -110,7 +124,9 @@ int MoniTool_AttrList::IntegerAttribute(const char* const name) const { occ::handle ival = occ::down_cast(Attribute(name)); if (ival.IsNull()) + { return 0; + } return ival->Value(); } @@ -137,7 +153,9 @@ double MoniTool_AttrList::RealAttribute(const char* const name) const { occ::handle rval = occ::down_cast(Attribute(name)); if (rval.IsNull()) + { return 0; + } return rval->Value(); } @@ -165,7 +183,9 @@ const char* MoniTool_AttrList::StringAttribute(const char* const name) const occ::handle hval = occ::down_cast(Attribute(name)); if (hval.IsNull()) + { return ""; + } return hval->ToCString(); } @@ -187,7 +207,9 @@ void MoniTool_AttrList::GetAttributes(const MoniTool_AttrList& other, const NCollection_DataMap>& list = other.AttrList(); if (list.IsEmpty()) + { return; + } NCollection_DataMap>::Iterator iter( list); @@ -195,7 +217,9 @@ void MoniTool_AttrList::GetAttributes(const MoniTool_AttrList& other, { const TCollection_AsciiString& name = iter.Key(); if (!name.StartsWith(fromname)) + { continue; + } const occ::handle& atr = iter.Value(); occ::handle newatr = atr; diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_CaseData.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_CaseData.cxx index 40b6745c41..44456bbfb3 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_CaseData.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_CaseData.cxx @@ -128,7 +128,9 @@ void MoniTool_CaseData::AddData(const occ::handle& val, if (thesubst < 0) { if (name[0] != '\0') + { subs = NameNum(name); + } } // SetChange / SetReplace if (subs > 0 && subs <= thedata.Length()) @@ -136,7 +138,9 @@ void MoniTool_CaseData::AddData(const occ::handle& val, thedata.SetValue(subs, val); thekind.SetValue(subs, kind); if (aname.Length() > 0) + { thednam.SetValue(subs, aname); + } // Ajout Normal } else @@ -254,7 +258,9 @@ void MoniTool_CaseData::AddAny(const occ::handle& val, const void MoniTool_CaseData::RemoveData(const int num) { if (num < 1 || num > thedata.Length()) + { return; + } thedata.Remove(num); thekind.Remove(num); thednam.Remove(num); @@ -271,7 +277,9 @@ occ::handle MoniTool_CaseData::Data(const int nd) const { occ::handle val; if (nd < 1 || nd > thedata.Length()) + { return val; + } return thedata(nd); } @@ -280,14 +288,22 @@ bool MoniTool_CaseData::GetData(const int nd, occ::handle& val) const { if (type.IsNull()) + { return false; + } if (nd < 1 || nd > thedata.Length()) + { return false; + } occ::handle v = thedata(nd); if (v.IsNull()) + { return false; + } if (!v->IsKind(type)) + { return false; + } val = v; return true; } @@ -295,14 +311,18 @@ bool MoniTool_CaseData::GetData(const int nd, int MoniTool_CaseData::Kind(const int nd) const { if (nd < 1 || nd > thekind.Length()) + { return 0; + } return thekind(nd); } const TCollection_AsciiString& MoniTool_CaseData::Name(const int nd) const { if (nd < 1 || nd > thednam.Length()) + { return TCollection_AsciiString::EmptyString(); + } return thednam(nd); } @@ -310,41 +330,67 @@ static int NameKind(const char* const name) { char n0 = name[0]; if (n0 == 'A' && name[1] == 'N' && name[2] == 'Y' && name[3] == '\0') + { return 0; + } if (n0 == 'E') { if (name[1] == 'X' && name[2] == '\0') + { return 1; + } if (name[1] == 'N' && name[2] == '\0') + { return 2; + } return 0; } if (n0 == 'G' && name[1] == '\0') + { return 3; + } if (n0 == 'S' && name[1] == 'H' && name[2] == '\0') + { return 4; + } if (n0 == 'X' && name[1] == 'Y') { if (name[2] == 'Z' && name[3] == '\0') + { return 5; + } if (name[2] == '\0') + { return 6; + } } if (n0 == 'U' && name[1] == 'V' && name[2] == '\0') + { return 6; + } if (n0 == 'R') { if (name[1] == '\0') + { return 8; + } if (name[1] == 'R' && name[2] == '\0') + { return 7; + } } if (n0 == 'C' && name[1] == 'P' && name[2] == 'U' && name[3] == '\0') + { return 9; + } if (n0 == 'T' && name[1] == '\0') + { return 10; + } if (n0 == 'I' && name[1] == '\0') + { return 11; + } return 0; } @@ -354,7 +400,9 @@ static int NameRank(const char* const name) for (int i = 0; name[i] != '\0'; i++) { if (name[i] == ':' && name[i + 1] != '\0') + { return atoi(&name[i + 1]); + } } return 1; } @@ -362,17 +410,23 @@ static int NameRank(const char* const name) int MoniTool_CaseData::NameNum(const char* const name) const { if (!name || name[0] == '\0') + { return 0; + } int nd, nn = 0, nb = NbData(); for (nd = 1; nd <= nb; nd++) { if (thednam(nd).IsEqual(name)) + { return nd; + } } int kind = NameKind(name); if (kind < 0) + { return 0; + } int num = NameRank(name); for (nd = 1; nd <= nb; nd++) @@ -381,7 +435,9 @@ int MoniTool_CaseData::NameNum(const char* const name) const { nn++; if (nn == num) + { return nd; + } } } return 0; @@ -394,7 +450,9 @@ TopoDS_Shape MoniTool_CaseData::Shape(const int nd) const TopoDS_Shape sh; occ::handle hs = occ::down_cast(Data(nd)); if (!hs.IsNull()) + { sh = hs->Shape(); + } return sh; } @@ -402,7 +460,9 @@ bool MoniTool_CaseData::XYZ(const int nd, gp_XYZ& val) const { occ::handle p = occ::down_cast(Data(nd)); if (p.IsNull()) + { return false; + } val = p->Pnt().XYZ(); return true; } @@ -411,7 +471,9 @@ bool MoniTool_CaseData::XY(const int nd, gp_XY& val) const { occ::handle p = occ::down_cast(Data(nd)); if (p.IsNull()) + { return false; + } val = p->Pnt2d().XY(); return true; } @@ -420,7 +482,9 @@ bool MoniTool_CaseData::Reals(const int nd, double& v1, double& v2) const { occ::handle p = occ::down_cast(Data(nd)); if (p.IsNull()) + { return false; + } v1 = p->X(); v2 = p->Y(); return true; @@ -430,7 +494,9 @@ bool MoniTool_CaseData::Real(const int nd, double& val) const { occ::handle p = occ::down_cast(Data(nd)); if (p.IsNull()) + { return false; + } val = p->X(); return true; } @@ -439,7 +505,9 @@ bool MoniTool_CaseData::Text(const int nd, const char*& text) const { occ::handle t = occ::down_cast(Data(nd)); if (t.IsNull()) + { return false; + } text = t->ToCString(); return true; } @@ -449,7 +517,9 @@ bool MoniTool_CaseData::Integer(const int nd, int& val) const occ::handle p = occ::down_cast(Data(nd)); // if (p.IsNull()) return false; if (thekind(nd) != 11) + { return false; + } double rval = p->X(); val = (int)rval; return true; @@ -482,7 +552,9 @@ int MoniTool_CaseData::DefCheck(const char* const acode) { int val; if (!defch.Find(acode, val)) + { val = 0; + } return val; } @@ -496,9 +568,13 @@ const char* MoniTool_CaseData::DefMsg(const char* const casecode) { occ::handle aTStr; if (!defms.Find(casecode, aTStr)) + { return ""; + } occ::handle str = occ::down_cast(aTStr); if (str.IsNull()) + { return ""; + } return str->ToCString(); } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignShape.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignShape.cxx index a01c95f95b..7ca0afea09 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignShape.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignShape.cxx @@ -31,12 +31,18 @@ TCollection_AsciiString MoniTool_SignShape::Text( const occ::handle& /*context*/) const { if (ent.IsNull()) + { return ""; + } occ::handle HS = occ::down_cast(ent); if (HS.IsNull()) + { return ent->DynamicType()->Name(); + } TopoDS_Shape sh = HS->Shape(); if (sh.IsNull()) + { return "SHAPE"; + } return TopAbs::ShapeTypeToString(sh.ShapeType()); } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignText.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignText.cxx index 0c5e4f1451..bf71e0e753 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignText.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_SignText.cxx @@ -26,9 +26,13 @@ TCollection_AsciiString MoniTool_SignText::TextAlone( if (atext.Length() == 0) { if (ent.IsNull()) + { atext.AssignCat("(NULL)"); + } else + { atext.AssignCat(ent->DynamicType()->Name()); + } } return atext; } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_Stat.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_Stat.cxx index 472dad94fe..0a0b8b3dab 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_Stat.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_Stat.cxx @@ -53,7 +53,9 @@ int MoniTool_Stat::Open(const int nb) void MoniTool_Stat::OpenMore(const int id, const int nb) { if (id <= 0 || id > thelev) + { return; + } thetot->SetValue(id, thetot->Value(id) + nb); } @@ -77,7 +79,9 @@ void MoniTool_Stat::AddEnd() void MoniTool_Stat::Close(const int id) { if (id < thelev) + { Close(id + 1); + } AddEnd(); thelev--; } @@ -90,12 +94,16 @@ int MoniTool_Stat::Level() const double MoniTool_Stat::Percent(const int fromlev) const { if (fromlev > thelev) + { return 0; + } double r1, r2, r3; int tot = thetot->Value(fromlev); int done = thedone->Value(fromlev); if (done >= tot) + { return 100.; + } if (fromlev == thelev) { r1 = tot; @@ -113,6 +121,8 @@ double MoniTool_Stat::Percent(const int fromlev) const r3 = r3 * Percent(fromlev + 1); } if (r1 == 0) + { return 1; + } return (r2 * 100) / r1 + r3; } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_Timer.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_Timer.cxx index 1659bb13db..9386164bc7 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_Timer.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_Timer.cxx @@ -44,7 +44,7 @@ void MoniTool_Timer::Dump(Standard_OStream& ostr) system, myCount); - ostr << buff << std::endl; + ostr << buff << '\n'; } //================================================================================================= @@ -67,7 +67,9 @@ occ::handle MoniTool_Timer::Timer(const char* const name) NCollection_DataMap, Standard_CStringHasher>& dic = Dictionary(); if (dic.IsBound(name)) + { return dic.Find(name); + } occ::handle MT = new MoniTool_Timer; MT->Timer().Reset(); dic.Bind(name, MT); @@ -95,7 +97,7 @@ void MoniTool_Timer::DumpTimers(Standard_OStream& ostr) int NbTimers = dic.Extent(); - ostr << "DUMP OF TIMERS:" << std::endl; + ostr << "DUMP OF TIMERS:" << '\n'; const char** keys = new const char*[NbTimers]; int i = 0; for (; iter.More() && i < NbTimers; iter.Next()) @@ -122,7 +124,9 @@ void MoniTool_Timer::DumpTimers(Standard_OStream& ostr) Timer(stmp)->Dump(ostr); keys[ntmp] = nullptr; if (Timer(stmp)->IsRunning()) - std::cerr << "Warning: timer " << stmp << " is running" << std::endl; + { + std::cerr << "Warning: timer " << stmp << " is running" << '\n'; + } } delete[] keys; } @@ -153,8 +157,11 @@ void MoniTool_Timer::ComputeAmendments() MT0->Start(); for (i = 1; i <= NBTESTS; i++) { - for (int k = 1; k <= 100; k++) [[maybe_unused]] + for (int k = 1; k <= 100; k++) + { + [[maybe_unused]] const double aDummy = std::sqrt(i + k); + } } MT0->Stop(); @@ -164,8 +171,11 @@ void MoniTool_Timer::ComputeAmendments() for (i = 1; i <= NBTESTS; i++) { MT->Start(); - for (int k = 1; k <= 100; k++) [[maybe_unused]] + for (int k = 1; k <= 100; k++) + { + [[maybe_unused]] const double aDummy = std::sqrt(i + k); + } MT->Stop(); } MT1->Stop(); @@ -210,12 +220,12 @@ void MoniTool_Timer::ComputeAmendments() amAccess += (0.5 * (cpu3 - cpu1)) / NBTESTS; amError = std::abs(cpu1 + cpu3 - 2 * cpu2) / NBTESTS; - std::cout << "CPU 0: " << cpu0 << std::endl; - std::cout << "CPU 1: " << cpu1 << " INTERNAL: " << cput1 << std::endl; - std::cout << "CPU 2: " << cpu2 << " INTERNAL: " << cput2 << std::endl; - std::cout << "CPU 3: " << cpu3 << " INTERNAL: " << cput3 << std::endl; + std::cout << "CPU 0: " << cpu0 << '\n'; + std::cout << "CPU 1: " << cpu1 << " INTERNAL: " << cput1 << '\n'; + std::cout << "CPU 2: " << cpu2 << " INTERNAL: " << cput2 << '\n'; + std::cout << "CPU 3: " << cpu3 << " INTERNAL: " << cput3 << '\n'; std::cout << "Access: " << amAccess << ", External: " << amExternal - << ", Internal: " << amInternal << ", Error: " << amError << std::endl; + << ", Internal: " << amInternal << ", Error: " << amError << '\n'; } //================================================================================================= @@ -239,14 +249,18 @@ void MoniTool_Timer::AmendAccess() { double amend = amAccess; for (occ::handle act = myActive; !act.IsNull(); act = act->myNext) + { act->myAmend += amend; + } } void MoniTool_Timer::AmendStart() { double amend = amExternal; for (occ::handle act = myActive; !act.IsNull(); act = act->myNext) + { act->myAmend += amend; + } myAmend += amInternal; // add to list @@ -262,13 +276,19 @@ void MoniTool_Timer::AmendStop() { occ::handle thisActive(this); if (myActive == thisActive) + { myActive = myNext; + } // if ( myActive == this ) myActive = myNext; if (!myPrev.IsNull()) + { myPrev->myNext = myNext; + } if (!myNext.IsNull()) + { myNext->myPrev = myPrev; + } myNext = myPrev = nullptr; } diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_TransientElem.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_TransientElem.cxx index c8f65ae567..90c1cffb94 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_TransientElem.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_TransientElem.cxx @@ -33,11 +33,17 @@ const occ::handle& MoniTool_TransientElem::Value() const bool MoniTool_TransientElem::Equates(const occ::handle& other) const { if (other.IsNull()) + { return false; + } if (GetHashCode() != other->GetHashCode()) + { return false; + } if (other->DynamicType() != DynamicType()) + { return false; + } occ::handle another = occ::down_cast(other); // return (theval == another->Value()); return theval == another->Value(); diff --git a/src/DataExchange/TKXSBase/MoniTool/MoniTool_TypedValue.cxx b/src/DataExchange/TKXSBase/MoniTool/MoniTool_TypedValue.cxx index c8e1cdb9eb..88adf701e3 100644 --- a/src/DataExchange/TKXSBase/MoniTool/MoniTool_TypedValue.cxx +++ b/src/DataExchange/TKXSBase/MoniTool/MoniTool_TypedValue.cxx @@ -85,10 +85,16 @@ MoniTool_TypedValue::MoniTool_TypedValue(const char* const name, { if (type != MoniTool_ValueInteger && type != MoniTool_ValueReal && type != MoniTool_ValueEnum && type != MoniTool_ValueText && type != MoniTool_ValueIdent) + { throw Standard_ConstructionError("MoniTool_TypedValue : Type not supported"); + } if (init[0] != '\0') + { if (Satisfies(new TCollection_HAsciiString(init))) + { SetCStringValue(init); + } + } } MoniTool_TypedValue::MoniTool_TypedValue(const occ::handle& other) @@ -114,13 +120,21 @@ MoniTool_TypedValue::MoniTool_TypedValue(const occ::handle& thesatisn.AssignCat(satisname); if (other->IntegerLimit(false, theintlow)) + { thelims |= 1; + } if (other->IntegerLimit(true, theintup)) + { thelims |= 2; + } if (other->RealLimit(false, therealow)) + { thelims |= 1; + } if (other->RealLimit(true, therealup)) + { thelims |= 2; + } int startcase, endcase; bool match; @@ -129,9 +143,13 @@ MoniTool_TypedValue::MoniTool_TypedValue(const occ::handle& theintlow = startcase; theintup = endcase; if (match) + { thelims |= 4; + } if (theintup >= theintlow) + { theenums = new NCollection_HArray1(theintlow, theintup); + } for (startcase = theintlow; startcase <= theintup; startcase++) { theenums->SetValue(startcase, other->EnumVal(startcase)); @@ -142,12 +160,16 @@ MoniTool_TypedValue::MoniTool_TypedValue(const occ::handle& { NCollection_DataMap::Iterator itad(eadds); for (; itad.More(); itad.Next()) + { theeadds.Bind(itad.Key(), itad.Value()); + } } // we duplicate the string if (!thehval.IsNull()) + { thehval = new TCollection_HAsciiString(other->CStringValue()); + } } void MoniTool_TypedValue::Internals(MoniTool_ValueInterpret& interp, @@ -174,7 +196,9 @@ MoniTool_ValueType MoniTool_TypedValue::ValueType() const TCollection_AsciiString MoniTool_TypedValue::Definition() const { if (thedef.Length() > 0) + { return thedef; + } TCollection_AsciiString def; char mess[50]; switch (thetype) @@ -225,7 +249,9 @@ TCollection_AsciiString MoniTool_TypedValue::Definition() const { const char* enva = EnumVal(i); if (enva[0] == '?' || enva[0] == '\0') + { continue; + } Sprintf(mess, " %d:%s", i, enva); def.AssignCat(mess); } @@ -238,7 +264,9 @@ TCollection_AsciiString MoniTool_TypedValue::Definition() const const TCollection_AsciiString& aName = listadd.Key(); const char* enva = aName.ToCString(); if (enva[0] == '?') + { continue; + } Sprintf(mess, ":%d ", listadd.Value()); def.AssignCat(enva); def.AssignCat(mess); @@ -283,14 +311,18 @@ void MoniTool_TypedValue::Print(Standard_OStream& S) const { S << "--- Typed Value : " << Name(); if (thelabel.Length() > 0) + { S << " Label : " << Label(); - S << std::endl << "--- Type : " << Definition() << std::endl << "--- Value : "; + } + S << '\n' << "--- Type : " << Definition() << '\n' << "--- Value : "; PrintValue(S); - S << std::endl; + S << '\n'; if (thesatisf) - S << " -- Specific Function for Satisfies : " << thesatisn.ToCString() << std::endl; + { + S << " -- Specific Function for Satisfies : " << thesatisn.ToCString() << '\n'; + } } void MoniTool_TypedValue::PrintValue(Standard_OStream& S) const @@ -298,24 +330,34 @@ void MoniTool_TypedValue::PrintValue(Standard_OStream& S) const if (IsSetValue()) { if (thetype == MoniTool_ValueIdent) + { S << " (type) " << theoval->DynamicType()->Name(); + } if (!thehval.IsNull()) + { S << (thetype == MoniTool_ValueIdent ? " : " : "") << thehval->ToCString(); + } if (HasInterpret()) { S << " ("; occ::handle str = Interpret(thehval, true); if (!str.IsNull() && str != thehval) + { S << "Native:" << str->ToCString(); + } str = Interpret(thehval, false); if (!str.IsNull() && str != thehval) + { S << " Coded:" << str->ToCString(); + } S << ")"; } } else + { S << "(not set)"; + } } // ######### COMPLEMENTS ########## @@ -325,32 +367,57 @@ bool MoniTool_TypedValue::AddDef(const char* const init) // Editions : init gives a small edition text, in 2 terms "cmd var" : int i, iblc = 0; for (i = 0; init[i] != '\0'; i++) + { if (init[i] == ' ') + { iblc = i + 1; + } + } if (iblc == 0) + { return false; + } // Recognition of sub-case and routing - if (init[0] == 'i' && init[2] == 'i') // imin ival + if (init[0] == 'i' && init[2] == 'i') + { // imin ival SetIntegerLimit(false, atoi(&init[iblc])); - else if (init[0] == 'i' && init[2] == 'a') // imax ival + } + else if (init[0] == 'i' && init[2] == 'a') + { // imax ival SetIntegerLimit(true, atoi(&init[iblc])); - else if (init[0] == 'r' && init[2] == 'i') // rmin rval + } + else if (init[0] == 'r' && init[2] == 'i') + { // rmin rval SetRealLimit(false, Atof(&init[iblc])); - else if (init[0] == 'r' && init[2] == 'a') // rmax rval + } + else if (init[0] == 'r' && init[2] == 'a') + { // rmax rval SetRealLimit(true, Atof(&init[iblc])); - else if (init[0] == 'u') // unit name + } + else if (init[0] == 'u') + { // unit name SetUnitDef(&init[iblc]); - else if (init[0] == 'e' && init[1] == 'm') // ematch istart + } + else if (init[0] == 'e' && init[1] == 'm') + { // ematch istart StartEnum(atoi(&init[iblc]), true); - else if (init[0] == 'e' && init[1] == 'n') // enum istart + } + else if (init[0] == 'e' && init[1] == 'n') + { // enum istart StartEnum(atoi(&init[iblc]), false); - else if (init[0] == 'e' && init[1] == 'v') // eval text + } + else if (init[0] == 'e' && init[1] == 'v') + { // eval text AddEnum(&init[iblc]); - else if (init[0] == 't' && init[1] == 'm') // tmax length + } + else if (init[0] == 't' && init[1] == 'm') + { // tmax length SetMaxLength(atoi(&init[iblc])); - + } else + { return false; + } return true; } @@ -370,7 +437,9 @@ void MoniTool_TypedValue::SetMaxLength(const int max) { themaxlen = max; if (max < 0) + { themaxlen = 0; + } } int MoniTool_TypedValue::MaxLength() const @@ -381,7 +450,9 @@ int MoniTool_TypedValue::MaxLength() const void MoniTool_TypedValue::SetIntegerLimit(const bool max, const int val) { if (thetype != MoniTool_ValueInteger) + { throw Standard_ConstructionError("MoniTool_TypedValue : SetIntegerLimit, not an Integer"); + } if (max) { @@ -414,7 +485,9 @@ bool MoniTool_TypedValue::IntegerLimit(const bool max, int& val) const void MoniTool_TypedValue::SetRealLimit(const bool max, const double val) { if (thetype != MoniTool_ValueReal) + { throw Standard_ConstructionError("MoniTool_TypedValue : SetRealLimit, not a Real"); + } if (max) { @@ -460,11 +533,15 @@ const char* MoniTool_TypedValue::UnitDef() const void MoniTool_TypedValue::StartEnum(const int start, const bool match) { if (thetype != MoniTool_ValueEnum) + { throw Standard_ConstructionError("MoniTool_TypedValue : StartEnum, Not an Enum"); + } thelims |= 4; if (!match) + { thelims -= 4; + } theintlow = start; theintup = start - 1; } @@ -481,15 +558,21 @@ void MoniTool_TypedValue::AddEnum(const char* const v1, const char* const v10) { if (thetype != MoniTool_ValueEnum) + { throw Standard_ConstructionError("MoniTool_TypedValue : AddEnum, Not an Enum"); + } if (theenums.IsNull()) + { theenums = new NCollection_HArray1(theintlow, theintlow + 10); + } else if (theenums->Upper() < theintup + 10) { occ::handle> enums = new NCollection_HArray1(theintlow, theintup + 10); for (int i = theintlow; i <= theintup; i++) + { enums->SetValue(i, theenums->Value(i)); + } theenums = enums; } @@ -558,24 +641,36 @@ void MoniTool_TypedValue::AddEnum(const char* const v1, void MoniTool_TypedValue::AddEnumValue(const char* const val, const int num) { if (thetype != MoniTool_ValueEnum) + { throw Standard_ConstructionError("MoniTool_TypedValue : AddEnum, Not an Enum"); + } if (num < theintlow) + { throw Standard_ConstructionError("MoniTool_TypedValue : AddEnum, out of range"); + } if (val[0] == '\0') + { return; + } if (theenums.IsNull()) + { theenums = new NCollection_HArray1(theintlow, num + 1); + } else if (theenums->Upper() < num) { occ::handle> enums = new NCollection_HArray1(theintlow, num + 1); for (int i = theintlow; i <= theintup; i++) + { enums->SetValue(i, theenums->Value(i)); + } theenums = enums; } if (theintup < num) + { theintup = num; + } if (theenums->Value(num).Length() == 0) { theenums->SetValue(num, TCollection_AsciiString(val)); @@ -589,7 +684,9 @@ void MoniTool_TypedValue::AddEnumValue(const char* const val, const int num) bool MoniTool_TypedValue::EnumDef(int& startcase, int& endcase, bool& match) const { if (thetype != MoniTool_ValueEnum) + { return false; + } startcase = theintlow; endcase = theintup; match = ((thelims & 4) != 0); @@ -599,31 +696,47 @@ bool MoniTool_TypedValue::EnumDef(int& startcase, int& endcase, bool& match) con const char* MoniTool_TypedValue::EnumVal(const int num) const { if (thetype != MoniTool_ValueEnum) + { return ""; + } if (num < theintlow || num > theintup) + { return ""; + } return theenums->Value(num).ToCString(); } int MoniTool_TypedValue::EnumCase(const char* const val) const { if (thetype != MoniTool_ValueEnum) + { return (theintlow - 1); + } int i; // svv Jan 10 2000 : porting on DEC for (i = theintlow; i <= theintup; i++) + { if (theenums->Value(i).IsEqual(val)) + { return i; + } + } // cas additionnel ? if (!theeadds.IsEmpty()) { if (theeadds.Find(val, i)) + { return i; + } } // entier possible // gka S4054 for (i = 0; val[i] != '\0'; i++) + { if (val[i] != ' ' && val[i] != '-' && (val[i] < '0' || val[i] > '9')) + { return (theintlow - 1); + } + } return atoi(val); } @@ -632,14 +745,18 @@ int MoniTool_TypedValue::EnumCase(const char* const val) const void MoniTool_TypedValue::SetObjectType(const occ::handle& typ) { if (thetype != MoniTool_ValueIdent) + { throw Standard_ConstructionError("MoniTool_TypedValue : AddEnum, Not an Entity/Object"); + } theotyp = typ; } occ::handle MoniTool_TypedValue::ObjectType() const { if (!theotyp.IsNull()) + { return theotyp; + } return STANDARD_TYPE(Standard_Transient); } @@ -653,9 +770,13 @@ void MoniTool_TypedValue::SetInterpret(const MoniTool_ValueInterpret func) bool MoniTool_TypedValue::HasInterpret() const { if (theinterp) + { return true; + } if (thetype == MoniTool_ValueEnum) + { return true; + } return false; } @@ -664,7 +785,9 @@ void MoniTool_TypedValue::SetSatisfies(const MoniTool_ValueSatisfies func, const thesatisn.Clear(); thesatisf = func; if (thesatisf) + { thesatisn.AssignCat(name); + } } const char* MoniTool_TypedValue::SatisfiesName() const @@ -677,18 +800,26 @@ const char* MoniTool_TypedValue::SatisfiesName() const bool MoniTool_TypedValue::IsSetValue() const { if (thetype == MoniTool_ValueIdent) + { return (!theoval.IsNull()); + } if (thehval->Length() > 0) + { return true; + } if (!theoval.IsNull()) + { return true; + } return false; } const char* MoniTool_TypedValue::CStringValue() const { if (thehval.IsNull()) + { return ""; + } return thehval->ToCString(); } @@ -703,9 +834,13 @@ occ::handle MoniTool_TypedValue::Interpret( { occ::handle inter = hval; if (hval.IsNull()) + { return hval; + } if (theinterp) + { return theinterp(this, hval, native); + } if (thetype == MoniTool_ValueEnum) { // We accept both forms : Enum preferably, otherwise Integer @@ -714,11 +849,17 @@ occ::handle MoniTool_TypedValue::Interpret( EnumDef(startcase, endcase, match); int encas = EnumCase(hval->ToCString()); if (encas < startcase) + { return hval; // loupe + } if (native) + { inter = new TCollection_HAsciiString(EnumVal(encas)); + } else + { inter = new TCollection_HAsciiString(encas); + } } return inter; } @@ -726,38 +867,66 @@ occ::handle MoniTool_TypedValue::Interpret( bool MoniTool_TypedValue::Satisfies(const occ::handle& val) const { if (val.IsNull()) + { return false; + } if (thesatisf) + { if (!thesatisf(val)) + { return false; + } + } if (val->Length() == 0) + { return true; + } switch (thetype) { case MoniTool_ValueInteger: { if (!val->IsIntegerValue()) + { return false; + } int ival, ilim; ival = atoi(val->ToCString()); if (IntegerLimit(false, ilim)) + { if (ilim > ival) + { return false; + } + } if (IntegerLimit(true, ilim)) + { if (ilim < ival) + { return false; + } + } return true; } case MoniTool_ValueReal: { if (!val->IsRealValue()) + { return false; + } double rval, rlim; rval = val->RealValue(); if (RealLimit(false, rlim)) + { if (rlim > rval) + { return false; + } + } if (RealLimit(true, rlim)) + { if (rlim < rval) + { return false; + } + } return true; } case MoniTool_ValueEnum: { @@ -766,9 +935,13 @@ bool MoniTool_TypedValue::Satisfies(const occ::handle& bool match; EnumDef(startcase, endcase, match); if (!match) + { return true; + } if (EnumCase(val->ToCString()) >= startcase) + { return true; + } // Here, we accept an integer in the range //// if (val->IsIntegerValue()) ival = atoi (val->ToCString()); @@ -779,7 +952,9 @@ bool MoniTool_TypedValue::Satisfies(const occ::handle& } case MoniTool_ValueText: { if (themaxlen > 0 && val->Length() > themaxlen) + { return false; + } break; } default: @@ -799,9 +974,13 @@ bool MoniTool_TypedValue::SetCStringValue(const char* const val) { occ::handle hval = new TCollection_HAsciiString(val); if (hval->IsSameString(thehval)) + { return true; + } if (!Satisfies(hval)) + { return false; + } if (thetype == MoniTool_ValueInteger) { thehval->Clear(); @@ -813,7 +992,9 @@ bool MoniTool_TypedValue::SetCStringValue(const char* const val) int ival = EnumCase(val); const char* cval = EnumVal(ival); if (!cval || cval[0] == '\0') + { return false; + } theival = ival; thehval->Clear(); thehval->AssignCat(cval); @@ -830,14 +1011,22 @@ bool MoniTool_TypedValue::SetCStringValue(const char* const val) bool MoniTool_TypedValue::SetHStringValue(const occ::handle& hval) { if (hval.IsNull()) + { return false; + } if (!Satisfies(hval)) + { return false; + } thehval = hval; if (thetype == MoniTool_ValueInteger) + { theival = atoi(hval->ToCString()); + } else if (thetype == MoniTool_ValueEnum) + { theival = EnumCase(hval->ToCString()); + } // else return true; return true; } @@ -851,14 +1040,22 @@ bool MoniTool_TypedValue::SetIntegerValue(const int ival) { occ::handle hval = new TCollection_HAsciiString(ival); if (hval->IsSameString(thehval)) + { return true; + } if (!Satisfies(hval)) + { return false; + } thehval->Clear(); if (thetype == MoniTool_ValueEnum) + { thehval->AssignCat(EnumVal(ival)); + } else + { thehval->AssignCat(hval->ToCString()); + } theival = ival; return true; } @@ -866,9 +1063,13 @@ bool MoniTool_TypedValue::SetIntegerValue(const int ival) double MoniTool_TypedValue::RealValue() const { if (thehval->Length() == 0) + { return 0.0; + } if (!thehval->IsRealValue()) + { return 0.0; + } return thehval->RealValue(); } @@ -876,9 +1077,13 @@ bool MoniTool_TypedValue::SetRealValue(const double rval) { occ::handle hval = new TCollection_HAsciiString(rval); if (hval->IsSameString(thehval)) + { return true; + } if (!Satisfies(hval)) + { return false; + } thehval->Clear(); thehval->AssignCat(hval->ToCString()); return true; @@ -897,15 +1102,21 @@ void MoniTool_TypedValue::GetObjectValue(occ::handle& val) c bool MoniTool_TypedValue::SetObjectValue(const occ::handle& obj) { if (thetype != MoniTool_ValueIdent) + { return false; + } if (obj.IsNull()) { theoval.Nullify(); return true; } if (!theotyp.IsNull()) + { if (!obj->IsKind(theotyp)) + { return false; + } + } theoval = obj; return true; } @@ -913,10 +1124,14 @@ bool MoniTool_TypedValue::SetObjectValue(const occ::handle& const char* MoniTool_TypedValue::ObjectTypeName() const { if (theoval.IsNull()) + { return ""; + } occ::handle elm = occ::down_cast(theoval); if (!elm.IsNull()) + { return elm->ValueTypeName(); + } return theoval->DynamicType()->Name(); } @@ -926,9 +1141,13 @@ bool MoniTool_TypedValue::AddLib(const occ::handle& tv, const char* const defin) { if (tv.IsNull()) + { return false; + } if (defin[0] != '\0') + { tv->SetDefinition(defin); + } // else if (tv->Definition() == '\0') return false; libtv().Bind(tv->Name(), tv); return true; @@ -939,9 +1158,13 @@ occ::handle MoniTool_TypedValue::Lib(const char* const defi occ::handle val; occ::handle aTVal; if (libtv().Find(defin, aTVal)) + { val = occ::down_cast(aTVal); + } else + { val.Nullify(); + } return val; } @@ -949,7 +1172,9 @@ occ::handle MoniTool_TypedValue::FromLib(const char* const { occ::handle val = MoniTool_TypedValue::Lib(defin); if (!val.IsNull()) + { val = new MoniTool_TypedValue(val); + } return val; } @@ -958,7 +1183,9 @@ occ::handle> MoniTool_TypedValue: occ::handle> list = new NCollection_HSequence(); if (libtv().IsEmpty()) + { return list; + } NCollection_DataMap>::Iterator it( libtv()); for (; it.More(); it.Next()) @@ -979,8 +1206,12 @@ occ::handle MoniTool_TypedValue::StaticValue(const char* co occ::handle result; occ::handle aTResult; if (Stats().Find(name, aTResult)) + { result = occ::down_cast(aTResult); + } else + { result.Nullify(); + } return result; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfFinderProcess.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfFinderProcess.cxx index 1294d10024..b3ca47e648 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfFinderProcess.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfFinderProcess.cxx @@ -46,10 +46,14 @@ occ::handle Transfer_ActorOfFinderProcess::Transfer( { occ::handle tm = occ::down_cast(fnd); if (tm.IsNull()) + { return NullResult(); + } occ::handle res = TransferTransient(tm->Value(), FP, theProgress); if (res.IsNull()) + { return NullResult(); + } return TransientResult(res); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForFinder_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForFinder_0.cxx index c9cb9a6424..7d13f0429d 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForFinder_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForFinder_0.cxx @@ -56,7 +56,9 @@ occ::handle Transfer_ActorOfProcessForFinder:: { occ::handle binder; if (res.IsNull()) + { return binder; + } binder = new Transfer_SimpleBinderOfTransient; binder->SetResult(res); return binder; @@ -76,16 +78,22 @@ void Transfer_ActorOfProcessForFinder::SetNext( const occ::handle& next) { if (thenext == next) + { return; + } if (thenext.IsNull()) + { thenext = next; + } else if (thenext->IsLast()) { next->SetNext(thenext); thenext = next; } else + { thenext->SetNext(next); + } } //================================================================================================= diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForTransient_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForTransient_0.cxx index 7f80d1ef65..e597484030 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForTransient_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfProcessForTransient_0.cxx @@ -54,7 +54,9 @@ occ::handle Transfer_ActorOfProcessForTransien { occ::handle binder; if (res.IsNull()) + { return binder; + } binder = new Transfer_SimpleBinderOfTransient; binder->SetResult(res); return binder; @@ -74,16 +76,22 @@ void Transfer_ActorOfProcessForTransient::SetNext( const occ::handle& next) { if (thenext == next) + { return; + } if (thenext.IsNull()) + { thenext = next; + } else if (thenext->IsLast()) { next->SetNext(thenext); thenext = next; } else + { thenext->SetNext(next); + } } //================================================================================================= diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfTransientProcess.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfTransientProcess.cxx index cc512c335a..e79824faee 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfTransientProcess.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ActorOfTransientProcess.cxx @@ -31,7 +31,9 @@ occ::handle Transfer_ActorOfTransientProcess::Transfer( { occ::handle res = TransferTransient(start, TP, theProgress); if (res.IsNull()) + { return NullResult(); + } return TransientResult(res); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_Binder.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_Binder.cxx index 025098125f..c9761fe837 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_Binder.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_Binder.cxx @@ -35,9 +35,13 @@ Transfer_Binder::Transfer_Binder() void Transfer_Binder::Merge(const occ::handle& other) { if (other.IsNull()) + { return; + } if ((int)theexecst < (int)other->StatusExec()) + { theexecst = other->StatusExec(); + } thecheck->GetMessages(other->Check()); } @@ -46,15 +50,21 @@ void Transfer_Binder::Merge(const occ::handle& other) bool Transfer_Binder::IsMultiple() const { if (thenextr.IsNull()) + { return false; + } if (!HasResult()) + { return thenextr->IsMultiple(); + } occ::handle next = thenextr; while (!next.IsNull()) { if (next->HasResult()) + { return true; + } next = next->NextResult(); } return false; @@ -65,10 +75,14 @@ bool Transfer_Binder::IsMultiple() const void Transfer_Binder::AddResult(const occ::handle& next) { if (next == this || next.IsNull()) + { return; + } next->CutResult(this); if (thenextr.IsNull()) + { thenextr = next; + } else { // Modification of recursive to cycle @@ -82,7 +96,9 @@ void Transfer_Binder::AddResult(const occ::handle& next) return; } else + { theBinder = theBinder->NextResult(); + } } } } @@ -92,7 +108,9 @@ void Transfer_Binder::AddResult(const occ::handle& next) void Transfer_Binder::CutResult(const occ::handle& next) { if (thenextr.IsNull()) + { return; + } if (thenextr == next) { thenextr.Nullify(); @@ -105,7 +123,9 @@ void Transfer_Binder::CutResult(const occ::handle& next) while (!((currNext = currBinder->NextResult()) == next)) { if (currNext.IsNull()) + { return; + } currBinder = currNext; } currBinder->CutResult(next); @@ -124,7 +144,9 @@ occ::handle Transfer_Binder::NextResult() const void Transfer_Binder::SetResultPresent() { if (thestatus == Transfer_StatusUsed) + { throw Transfer_TransferFailure("Binder : SetResult, Result is Already Set and Used"); + } theexecst = Transfer_StatusDone; thestatus = Transfer_StatusDefined; } @@ -141,7 +163,9 @@ bool Transfer_Binder::HasResult() const void Transfer_Binder::SetAlreadyUsed() { if (thestatus != Transfer_StatusVoid) + { thestatus = Transfer_StatusUsed; + } } //================================================================================================= diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_Finder.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_Finder.cxx index e923c252e0..d008f28e75 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_Finder.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_Finder.cxx @@ -53,7 +53,9 @@ void Transfer_Finder::SetAttribute(const char* const name, bool Transfer_Finder::RemoveAttribute(const char* const name) { if (theattrib.IsEmpty()) + { return false; + } return theattrib.UnBind(name); } @@ -83,9 +85,13 @@ occ::handle Transfer_Finder::Attribute(const char* const nam { occ::handle atr; if (theattrib.IsEmpty()) + { return atr; + } if (!theattrib.Find(name, atr)) + { atr.Nullify(); + } return atr; } @@ -93,13 +99,21 @@ Interface_ParamType Transfer_Finder::AttributeType(const char* const name) const { occ::handle atr = Attribute(name); if (atr.IsNull()) + { return Interface_ParamVoid; + } if (atr->DynamicType() == STANDARD_TYPE(Interface_IntVal)) + { return Interface_ParamInteger; + } if (atr->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint)) + { return Interface_ParamReal; + } if (atr->DynamicType() == STANDARD_TYPE(TCollection_HAsciiString)) + { return Interface_ParamText; + } return Interface_ParamIdent; } @@ -126,7 +140,9 @@ int Transfer_Finder::IntegerAttribute(const char* const name) const { occ::handle ival = occ::down_cast(Attribute(name)); if (ival.IsNull()) + { return 0; + } return ival->Value(); } @@ -152,7 +168,9 @@ double Transfer_Finder::RealAttribute(const char* const name) const { occ::handle rval = occ::down_cast(Attribute(name)); if (rval.IsNull()) + { return 0; + } return rval->X(); } @@ -180,7 +198,9 @@ const char* Transfer_Finder::StringAttribute(const char* const name) const occ::handle hval = occ::down_cast(Attribute(name)); if (hval.IsNull()) + { return ""; + } return hval->ToCString(); } @@ -193,7 +213,9 @@ NCollection_DataMap>& T void Transfer_Finder::SameAttributes(const occ::handle& other) { if (!other.IsNull()) + { theattrib = other->AttrList(); + } } void Transfer_Finder::GetAttributes(const occ::handle& other, @@ -201,11 +223,15 @@ void Transfer_Finder::GetAttributes(const occ::handle& other, const bool copied) { if (other.IsNull()) + { return; + } NCollection_DataMap>& list = other->AttrList(); if (list.IsEmpty()) + { return; + } NCollection_DataMap>::Iterator iter( list); @@ -213,7 +239,9 @@ void Transfer_Finder::GetAttributes(const occ::handle& other, { const TCollection_AsciiString& name = iter.Key(); if (!name.StartsWith(fromname)) + { continue; + } const occ::handle& atr = iter.Value(); occ::handle newatr = atr; diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_FinderProcess.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_FinderProcess.cxx index f5c376f703..79075f540c 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_FinderProcess.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_FinderProcess.cxx @@ -40,9 +40,13 @@ int Transfer_FinderProcess::NextMappedWithAttribute(const char* const name, cons { occ::handle fnd = Mapped(num); if (fnd.IsNull()) + { continue; + } if (!fnd->Attribute(name).IsNull()) + { return num; + } } return 0; } @@ -53,7 +57,9 @@ occ::handle Transfer_FinderProcess::TransientMapper( occ::handle mapper = new Transfer_TransientMapper(obj); int index = MapIndex(mapper); if (index == 0) + { return mapper; + } return occ::down_cast(Mapped(index)); } @@ -61,7 +67,9 @@ void Transfer_FinderProcess::PrintTrace(const occ::handle& star Standard_OStream& S) const { if (!start.IsNull()) + { S << " Type:" << start->ValueTypeName(); + } } void Transfer_FinderProcess::PrintStats(const int mode, Standard_OStream& S) const @@ -69,38 +77,52 @@ void Transfer_FinderProcess::PrintStats(const int mode, Standard_OStream& S) con S << "\n*******************************************************************\n"; if (mode == 1) { // Basic statistics - S << "******** Basic Statistics ********" << std::endl; + S << "******** Basic Statistics ********" << '\n'; int nbr = 0, nbe = 0, nbw = 0; int i, max = NbMapped(), nbroots = NbRoots(); - S << "**** Nb Final Results : " << nbroots << std::endl; + S << "**** Nb Final Results : " << nbroots << '\n'; for (i = 1; i <= max; i++) { const occ::handle& binder = MapItem(i); if (binder.IsNull()) + { continue; + } const occ::handle ach = binder->Check(); Transfer_StatusExec stat = binder->StatusExec(); if (stat != Transfer_StatusInitial && stat != Transfer_StatusDone) + { nbe++; + } else { if (ach->NbWarnings() > 0) + { nbw++; + } if (binder->HasResult()) + { nbr++; + } } } if (nbr > nbroots) + { S << "**** ( Itermediate Results : " << nbr - nbroots << " )\n"; + } if (nbe > 0) + { S << "**** Errors on :" << Interface_MSG::Blanks(nbe, 4) << nbe << " Entities\n"; + } if (nbw > 0) + { S << "**** Warnings on : " << Interface_MSG::Blanks(nbw, 4) << nbw << " Entities\n"; + } S << "*******************************************************************"; } - S << std::endl; + S << '\n'; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForFinder_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForFinder_0.cxx index bbe552d01f..07b38e2690 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForFinder_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForFinder_0.cxx @@ -30,7 +30,9 @@ Transfer_IteratorOfProcessForFinder::Transfer_IteratorOfProcessForFinder(const b { if (withstarts) + { thestarts = new NCollection_HSequence>(); + } } //================================================================================================= @@ -38,8 +40,10 @@ Transfer_IteratorOfProcessForFinder::Transfer_IteratorOfProcessForFinder(const b void Transfer_IteratorOfProcessForFinder::Add(const occ::handle& binder) { if (!thestarts.IsNull()) + { throw Standard_NoSuchObject( "Transfer_IteratorOfProcessForFinder : Add, Starting Object required not provided"); + } AddItem(binder); } @@ -50,7 +54,9 @@ void Transfer_IteratorOfProcessForFinder::Add(const occ::handle { AddItem(binder); if (!thestarts.IsNull()) + { thestarts->Append(start); + } } //================================================================================================= @@ -60,10 +66,14 @@ void Transfer_IteratorOfProcessForFinder::Filter( const bool keep) { if (list.IsNull() || thestarts.IsNull()) + { return; + } int i, j, nb = thestarts->Length(); if (nb == 0) + { return; + } occ::handle factice; NCollection_IndexedDataMap, occ::handle, @@ -81,7 +91,9 @@ void Transfer_IteratorOfProcessForFinder::Filter( { j = amap.FindIndex(list->Value(i)); if (j > 0) + { SelectItem(j, keep); + } } } @@ -97,6 +109,8 @@ bool Transfer_IteratorOfProcessForFinder::HasStarting() const const occ::handle& Transfer_IteratorOfProcessForFinder::Starting() const { if (thestarts.IsNull()) + { throw Standard_NoSuchObject("TransferIterator : No Starting defined at all"); + } return thestarts->Value(thecurr); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForTransient_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForTransient_0.cxx index ae113fa9e7..623a2b1b71 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForTransient_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_IteratorOfProcessForTransient_0.cxx @@ -30,7 +30,9 @@ Transfer_IteratorOfProcessForTransient::Transfer_IteratorOfProcessForTransient( { if (withstarts) + { thestarts = new NCollection_HSequence>(); + } } //================================================================================================= @@ -38,8 +40,10 @@ Transfer_IteratorOfProcessForTransient::Transfer_IteratorOfProcessForTransient( void Transfer_IteratorOfProcessForTransient::Add(const occ::handle& binder) { if (!thestarts.IsNull()) + { throw Standard_NoSuchObject( "Transfer_IteratorOfProcessForTransient : Add, Starting Object required not provided"); + } AddItem(binder); } @@ -50,7 +54,9 @@ void Transfer_IteratorOfProcessForTransient::Add(const occ::handleAppend(start); + } } //================================================================================================= @@ -60,10 +66,14 @@ void Transfer_IteratorOfProcessForTransient::Filter( const bool keep) { if (list.IsNull() || thestarts.IsNull()) + { return; + } int i, j, nb = thestarts->Length(); if (nb == 0) + { return; + } occ::handle factice; NCollection_IndexedDataMap, occ::handle> amap( nb); @@ -79,7 +89,9 @@ void Transfer_IteratorOfProcessForTransient::Filter( { j = amap.FindIndex(list->Value(i)); if (j > 0) + { SelectItem(j, keep); + } } } @@ -95,6 +107,8 @@ bool Transfer_IteratorOfProcessForTransient::HasStarting() const const occ::handle& Transfer_IteratorOfProcessForTransient::Starting() const { if (thestarts.IsNull()) + { throw Standard_NoSuchObject("TransferIterator : No Starting defined at all"); + } return thestarts->Value(thecurr); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_MultipleBinder.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_MultipleBinder.cxx index 5168fe1001..5fe539ac3a 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_MultipleBinder.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_MultipleBinder.cxx @@ -28,7 +28,9 @@ Transfer_MultipleBinder::Transfer_MultipleBinder() = default; bool Transfer_MultipleBinder::IsMultiple() const { if (themulres.IsNull()) + { return false; + } return (themulres->Length() != 1); } @@ -47,7 +49,9 @@ const char* Transfer_MultipleBinder::ResultTypeName() const void Transfer_MultipleBinder::AddResult(const occ::handle& res) { if (themulres.IsNull()) + { themulres = new NCollection_HSequence>(); + } themulres->Append(res); } @@ -65,7 +69,9 @@ occ::handle>> Transfer_Mul MultipleResult() const { if (!themulres.IsNull()) + { return themulres; + } return new NCollection_HSequence>(); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForFinder_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForFinder_0.cxx index 517c86e9cb..5996a627c0 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForFinder_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForFinder_0.cxx @@ -96,10 +96,14 @@ void Transfer_ProcessForFinder::Clean() for (i = 1; i <= nb; i++) { if (themap(i).IsNull()) + { unb++; + } } if (unb == 0) + { return; + } // Redo the map -> offsets NCollection_Array1 unbs(1, nb); @@ -113,7 +117,9 @@ void Transfer_ProcessForFinder::Clean() occ::handle ent = Mapped(i); occ::handle bnd = MapItem(i); if (bnd.IsNull()) + { continue; + } j = newmap.Add(ent, bnd); unbs.SetValue(i, j); } @@ -126,7 +132,9 @@ void Transfer_ProcessForFinder::Clean() j = theroots.FindKey(i); int k = unbs.Value(j); if (k) + { aNewRoots.Add(k); + } } theroots.Clear(); theroots = aNewRoots; @@ -142,7 +150,9 @@ void Transfer_ProcessForFinder::Clean() void Transfer_ProcessForFinder::Resize(const int nb) { if (static_cast(nb) > themap.NbBuckets()) + { themap.ReSize(static_cast(nb)); + } } //================================================================================================= @@ -150,18 +160,26 @@ void Transfer_ProcessForFinder::Resize(const int nb) void Transfer_ProcessForFinder::SetActor(const occ::handle& actor) { if (theactor == actor) + { return; + } if (theactor.IsNull()) + { theactor = actor; + } else if (actor.IsNull()) + { theactor = actor; + } else if (theactor->IsLast()) { actor->SetNext(theactor); theactor = actor; } else + { theactor->SetNext(actor); + } } //================================================================================================= @@ -179,7 +197,9 @@ occ::handle Transfer_ProcessForFinder::Find( if (thelastobj == start) { if (theindex > 0) + { return thelastbnd; + } } int index = themap.FindIndex(start); if (index > 0) @@ -196,7 +216,9 @@ bool Transfer_ProcessForFinder::IsBound(const occ::handle& star { occ::handle binder = Find(start); if (binder.IsNull()) + { return false; + } return binder->HasResult(); } @@ -222,14 +244,20 @@ occ::handle Transfer_ProcessForFinder::FindAndMask( if (thelastobj == start) { if (theindex > 0) + { return thelastbnd; + } } thelastobj = start; theindex = themap.FindIndex(start); if (theindex > 0) + { thelastbnd = themap.FindFromIndex(theindex); + } else + { thelastbnd.Nullify(); + } return thelastbnd; } @@ -239,7 +267,9 @@ void Transfer_ProcessForFinder::Bind(const occ::handle& start, const occ::handle& binder) { if (binder.IsNull()) + { return; + } occ::handle former = FindAndMask(start); if (!former.IsNull()) { @@ -257,16 +287,22 @@ void Transfer_ProcessForFinder::Bind(const occ::handle& start, else { if (thetrace > 2) + { StartTrace(former, start, thelevel, 5); + } binder->CCheck()->GetMessages(former->Check()); } } if (theindex == 0 || thelastbnd.IsNull()) { if (theindex == 0) + { theindex = themap.Add(start, binder); + } else + { themap(theindex) = binder; + } thelastbnd = binder; } else @@ -290,18 +326,28 @@ bool Transfer_ProcessForFinder::Unbind(const occ::handle& start { occ::handle former = FindAndMask(start); if (theindex == 0) + { return false; + } if (former.IsNull()) + { return false; + } if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) + { return true; + } themap(theindex) = thelastbnd; if (theroots.Contains(theindex)) { NCollection_IndexedMap aNewRoots; for (int i = 1; i <= theroots.Extent(); i++) + { if (theindex != theroots.FindKey(i)) + { aNewRoots.Add(theroots.FindKey(i)); + } + } theroots.Clear(); theroots = aNewRoots; @@ -320,7 +366,9 @@ occ::handle Transfer_ProcessForFinder::FindElseBind( { occ::handle binder = FindAndMask(start); if (!binder.IsNull()) + { return binder; + } binder = new Transfer_VoidBinder; Bind(start, binder); return binder; @@ -331,9 +379,13 @@ occ::handle Transfer_ProcessForFinder::FindElseBind( void Transfer_ProcessForFinder::SetMessenger(const occ::handle& messenger) { if (messenger.IsNull()) + { themessenger = Message::DefaultMessenger(); + } else + { themessenger = messenger; + } } //================================================================================================= @@ -391,8 +443,10 @@ void Transfer_ProcessForFinder::SendMsg(const occ::handle& star Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); aSender << amsg.Value(); if (amsg.IsEdited() && thetrace > 2) + { aSender << " [from: " << amsg.Original() << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -415,8 +469,10 @@ void Transfer_ProcessForFinder::AddFail(const occ::handle& star Message_Messenger::StreamBuffer aSender = themessenger->SendFail(); aSender << " --> Fail : " << mess; if (orig[0] != '\0' && thetrace > 2) + { aSender << " [from: " << orig << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -435,11 +491,15 @@ void Transfer_ProcessForFinder::AddFail(const occ::handle& star const Message_Msg& amsg) { if (amsg.IsEdited()) + { AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString(), TCollection_AsciiString(amsg.Original()).ToCString()); + } else + { AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString()); + } } //================================================================================================= @@ -461,8 +521,10 @@ void Transfer_ProcessForFinder::AddWarning(const occ::handle& s Message_Messenger::StreamBuffer aSender = themessenger->SendWarning(); aSender << " --> Warning : " << mess; if (orig[0] != '\0' && thetrace > 2) + { aSender << " [from: " << orig << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -472,11 +534,15 @@ void Transfer_ProcessForFinder::AddWarning(const occ::handle& s const Message_Msg& amsg) { if (amsg.IsEdited()) + { AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString(), TCollection_AsciiString(amsg.Original()).ToCString()); + } else + { AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString()); + } } //================================================================================================= @@ -486,7 +552,9 @@ void Transfer_ProcessForFinder::Mend(const occ::handle& start, { occ::handle binder = FindAndMask(start); if (binder.IsNull()) + { return; // nothing to do ... + } occ::handle ach = binder->CCheck(); ach->Mend(pref); } @@ -511,7 +579,9 @@ void Transfer_ProcessForFinder::BindTransient(const occ::handle const occ::handle& res) { if (res.IsNull()) + { return; + } occ::handle former = Find(start); occ::handle binder = occ::down_cast(former); @@ -528,9 +598,13 @@ void Transfer_ProcessForFinder::BindTransient(const occ::handle binder = new Transfer_SimpleBinderOfTransient; binder->SetResult(res); if (former.IsNull()) + { Bind(start, binder); + } else + { Rebind(start, binder); + } } //================================================================================================= @@ -542,9 +616,13 @@ const occ::handle& Transfer_ProcessForFinder::FindTransient( occ::handle binder = occ::down_cast(Find(start)); if (binder.IsNull()) + { return aDummy; + } if (!binder->HasResult()) + { return aDummy; + } return binder->Result(); } @@ -562,7 +640,9 @@ void Transfer_ProcessForFinder::BindMultiple(const occ::handle& } } else + { Bind(start, new Transfer_MultipleBinder); + } } //================================================================================================= @@ -576,9 +656,13 @@ void Transfer_ProcessForFinder::AddMultiple(const occ::handle& { StartTrace(binder, start, thelevel, 4); if (binder.IsNull()) + { throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound"); + } else + { throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder"); + } } multr->AddResult(res); } @@ -641,7 +725,9 @@ void Transfer_ProcessForFinder::SetRoot(const occ::handle& star } theroots.Add(index); if (thetrace > 2) + { StartTrace(MapItem(index), start, thelevel, 3); + } } //================================================================================================= @@ -664,7 +750,9 @@ const occ::handle& Transfer_ProcessForFinder::Root(const int nu { int ind = 0; if (num > 0 && num <= theroots.Extent()) + { ind = theroots.FindKey(num); + } return themap.FindKey(ind); } @@ -674,7 +762,9 @@ occ::handle Transfer_ProcessForFinder::RootItem(const int num) { int ind = 0; if (num > 0 && num <= theroots.Extent()) + { ind = theroots.FindKey(num); + } return themap.FindFromIndex(ind); } @@ -684,7 +774,9 @@ int Transfer_ProcessForFinder::RootIndex(const occ::handle& sta { int index = MapIndex(start); if (index == 0) + { return 0; + } return theroots.FindIndex(index); } @@ -711,7 +803,9 @@ bool Transfer_ProcessForFinder::Recognize(const occ::handle& st while (!actor.IsNull()) { if (actor->Recognize(start)) + { return true; + } actor = actor->Next(); } return false; @@ -744,7 +838,7 @@ occ::handle Transfer_ProcessForFinder::Transferring( case Transfer_StatusInitial: break; case Transfer_StatusDone: - aSender << " .. and Transfer done" << std::endl; + aSender << " .. and Transfer done" << '\n'; return former; case Transfer_StatusRun: former->SetStatusExec(Transfer_StatusLoop); @@ -752,25 +846,31 @@ occ::handle Transfer_ProcessForFinder::Transferring( case Transfer_StatusError: if (thetrace) { - aSender << " *** Transfer in Error Status :" << std::endl; + aSender << " *** Transfer in Error Status :" << '\n'; StartTrace(former, start, thelevel, 0); } else + { StartTrace(former, start, thelevel, 4); + } throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status"); case Transfer_StatusLoop: if (thetrace) { - aSender << " *** Transfer Head of Dead Loop :" << std::endl; + aSender << " *** Transfer Head of Dead Loop :" << '\n'; StartTrace(former, start, thelevel, 0); } else + { StartTrace(former, start, thelevel, 4); + } hasDeadLoop = true; break; } if (!hasDeadLoop) + { former->SetStatusExec(Transfer_StatusRun); + } } #ifdef TRANSLOG std::cout << " GO .." << std::endl; @@ -788,11 +888,13 @@ occ::handle Transfer_ProcessForFinder::Transferring( Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); if (thetrace) { - aSender << " *** Dead Loop : Finding head of Loop :" << std::endl; + aSender << " *** Dead Loop : Finding head of Loop :" << '\n'; StartTrace(former, start, thelevel - 1, 0); } else + { StartTrace(former, start, thelevel - 1, 4); + } binder = former; binder->AddFail("Transfer: Head of Dead Loop"); binder->AddFail("Transfer in dead Loop"); @@ -812,7 +914,7 @@ occ::handle Transfer_ProcessForFinder::Transferring( { if (binder.IsNull()) { - aSender << " *** Exception Raised with no Result" << std::endl; + aSender << " *** Exception Raised with no Result" << '\n'; binder = new Transfer_VoidBinder; Bind(start, binder); newbind = true; @@ -820,7 +922,7 @@ occ::handle Transfer_ProcessForFinder::Transferring( binder->AddFail("Transfer stopped by exception raising"); if (thetrace) { - aSender << " *** Raised : " << anException.what() << std::endl; + aSender << " *** Raised : " << anException.what() << '\n'; StartTrace(binder, start, thelevel - 1, 4); } thelevel = oldlev; @@ -829,10 +931,14 @@ occ::handle Transfer_ProcessForFinder::Transferring( // Unprotected transfer (thus, dbx by hand in case of crash by Raise) else + { binder = TransferProduct(start, theProgress); + } if (theProgress.UserBreak()) + { return occ::handle(); + } // Conclusion: Note in the Map @@ -842,19 +948,25 @@ occ::handle Transfer_ProcessForFinder::Transferring( { // Maybe did Bind himself... check if not do it if (!IsBound(start)) + { Bind(start, binder); + } else { Rebind(start, binder); } } else + { Rebind(start, binder); + } } else { if (!former.IsNull()) + { former->SetStatusExec(Transfer_StatusDone); //+ + } return occ::handle(); } @@ -886,28 +998,42 @@ occ::handle Transfer_ProcessForFinder::TransferProduct( while (!actor.IsNull()) { if (actor->Recognize(start)) + { binder = actor->Transferring(start, this, aScope.Next()); + } else + { binder.Nullify(); + } if (!binder.IsNull()) + { break; + } actor = actor->Next(); } if (aScope.UserBreak()) + { return occ::handle(); + } if (binder.IsNull()) { if (thelevel > 0) + { thelevel--; + } return binder; } // Root level management (.. take a closer look..) if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone) + { therootl = thelevel - 1; + } if (thelevel > 0) + { thelevel--; + } return binder; } @@ -947,24 +1073,42 @@ void Transfer_ProcessForFinder::StartTrace(const occ::handle& b if (thetrace > 3) { // Internal to be switch when searching bug (trace >= 4) if (mode == 1) + { aSender << " ### Fail"; + } if (mode == 2) + { aSender << " ### Warning"; + } if (mode == 3) + { aSender << " ### New Root n0 " << theroots.Extent(); + } if (mode == 4) + { aSender << " ### Exception"; + } if (mode == 5) + { aSender << " ### Substitution"; + } if (mode == 6) + { aSender << " ### Information"; + } if (level > 1) + { aSender << " (nested)"; + } if (mode >= 0 && mode != 3) + { aSender << " at " << theroots.Extent() << " Roots"; + } } if (!start.IsNull()) + { PrintTrace(start, aSender); + } if (!binder.IsNull()) { @@ -975,9 +1119,13 @@ void Transfer_ProcessForFinder::StartTrace(const occ::handle& b if (bnd->Status() != Transfer_StatusVoid) { if (!hasres) + { aSender << "\n --- Result Type : "; + } else + { aSender << " , "; + } aSender << bnd->ResultTypeName(); hasres = true; } @@ -988,7 +1136,7 @@ void Transfer_ProcessForFinder::StartTrace(const occ::handle& b aSender << "\n --- No Result recorded"; } } - aSender << std::endl; + aSender << '\n'; } //================================================================================================= @@ -997,7 +1145,9 @@ void Transfer_ProcessForFinder::PrintTrace(const occ::handle& s Standard_OStream& S) const { if (!start.IsNull()) + { S << " Type:" << start->DynamicType()->Name(); + } } //================================================================================================= @@ -1019,11 +1169,17 @@ Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::RootResult( int i = theroots.FindKey(j); occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(i)); + } else + { iter.Add(binder); + } } return iter; } @@ -1039,11 +1195,17 @@ Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::CompleteResult( { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(i)); + } else + { iter.Add(binder); + } } return iter; } @@ -1058,10 +1220,14 @@ Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::AbnormalResult() { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) + { iter.Add(binder, Mapped(i)); // we note the "not normal" cases + } } return iter; } @@ -1076,17 +1242,25 @@ Interface_CheckIterator Transfer_ProcessForFinder::CheckList(const bool erronly) { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && !check->HasFailed()) + { check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); + } if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) + { continue; + } const occ::handle& ent = Mapped(i); num = CheckNum(ent); if (num == 0) + { num = i; + } check->SetEntity(ent); list.Add(check, num); } @@ -1104,7 +1278,9 @@ Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::ResultOne( int max = NbMapped(); int ind = MapIndex(start); if (ind == 0) + { return iter; + } int i1 = (level == 0 ? ind : 1); int i2 = (level == 0 ? ind : max); occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1113,14 +1289,22 @@ Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::ResultOne( { ind = map->Value(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(ind)); + } else + { iter.Add(binder); + } } return iter; } @@ -1136,7 +1320,9 @@ Interface_CheckIterator Transfer_ProcessForFinder::CheckListOne( int max = NbMapped(); int num, ind = MapIndex(start); if (ind == 0) + { return list; + } int i1 = (level == 0 ? ind : 1); int i2 = (level == 0 ? ind : max); occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1145,20 +1331,30 @@ Interface_CheckIterator Transfer_ProcessForFinder::CheckListOne( { ind = map->Value(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && !check->HasFailed()) + { check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); + } if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) + { continue; + } const occ::handle& ent = Mapped(ind); num = CheckNum(ent); if (num == 0) + { num = ind; + } check->SetEntity(ent); list.Add(check, num); } @@ -1174,7 +1370,9 @@ bool Transfer_ProcessForFinder::IsCheckListEmpty(const occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1183,17 +1381,25 @@ bool Transfer_ProcessForFinder::IsCheckListEmpty(const occ::handleValue(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) + { return false; + } if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) + { return false; + } } return true; } @@ -1207,7 +1413,9 @@ void Transfer_ProcessForFinder::RemoveResult(const occ::handle& int max = NbMapped(); int ind = MapIndex(start); if (ind == 0) + { return; + } int i1 = (level == 0 ? ind : 1); int i2 = (level == 0 ? ind : max); occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1217,10 +1425,14 @@ void Transfer_ProcessForFinder::RemoveResult(const occ::handle& { ind = map->Value(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } } } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForTransient_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForTransient_0.cxx index 16ff0acdc0..7d5be9563f 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForTransient_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ProcessForTransient_0.cxx @@ -95,10 +95,14 @@ void Transfer_ProcessForTransient::Clean() for (i = 1; i <= nb; i++) { if (themap(i).IsNull()) + { unb++; + } } if (unb == 0) + { return; + } // Redo the map -> offsets NCollection_Array1 unbs(1, nb); @@ -110,7 +114,9 @@ void Transfer_ProcessForTransient::Clean() occ::handle ent = Mapped(i); occ::handle bnd = MapItem(i); if (bnd.IsNull()) + { continue; + } j = newmap.Add(ent, bnd); unbs.SetValue(i, j); } @@ -123,7 +129,9 @@ void Transfer_ProcessForTransient::Clean() j = theroots.FindKey(i); int k = unbs.Value(j); if (k) + { aNewRoots.Add(k); + } } theroots.Clear(); theroots = aNewRoots; @@ -139,7 +147,9 @@ void Transfer_ProcessForTransient::Clean() void Transfer_ProcessForTransient::Resize(const int nb) { if (static_cast(nb) > themap.NbBuckets()) + { themap.ReSize(static_cast(nb)); + } } //================================================================================================= @@ -148,18 +158,26 @@ void Transfer_ProcessForTransient::SetActor( const occ::handle& actor) { if (theactor == actor) + { return; + } if (theactor.IsNull()) + { theactor = actor; + } else if (actor.IsNull()) + { theactor = actor; + } else if (theactor->IsLast()) { actor->SetNext(theactor); theactor = actor; } else + { theactor->SetNext(actor); + } } //================================================================================================= @@ -177,7 +195,9 @@ occ::handle Transfer_ProcessForTransient::Find( if (thelastobj == start) { if (theindex > 0) + { return thelastbnd; + } } int index = themap.FindIndex(start); if (index > 0) @@ -194,7 +214,9 @@ bool Transfer_ProcessForTransient::IsBound(const occ::handle { occ::handle binder = Find(start); if (binder.IsNull()) + { return false; + } return binder->HasResult(); } @@ -220,14 +242,20 @@ occ::handle Transfer_ProcessForTransient::FindAndMask( if (thelastobj == start) { if (theindex > 0) + { return thelastbnd; + } } thelastobj = start; theindex = themap.FindIndex(start); if (theindex > 0) + { thelastbnd = themap.FindFromIndex(theindex); + } else + { thelastbnd.Nullify(); + } return thelastbnd; } @@ -237,7 +265,9 @@ void Transfer_ProcessForTransient::Bind(const occ::handle& s const occ::handle& binder) { if (binder.IsNull()) + { return; + } occ::handle former = FindAndMask(start); if (!former.IsNull()) { @@ -255,16 +285,22 @@ void Transfer_ProcessForTransient::Bind(const occ::handle& s else { if (thetrace > 2) + { StartTrace(former, start, thelevel, 5); + } binder->CCheck()->GetMessages(former->Check()); } } if (theindex == 0 || thelastbnd.IsNull()) { if (theindex == 0) + { theindex = themap.Add(start, binder); + } else + { themap(theindex) = binder; + } thelastbnd = binder; } else @@ -288,18 +324,28 @@ bool Transfer_ProcessForTransient::Unbind(const occ::handle& { occ::handle former = FindAndMask(start); if (theindex == 0) + { return false; + } if (former.IsNull()) + { return false; + } if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) + { return true; + } themap(theindex) = thelastbnd; if (theroots.Contains(theindex)) { NCollection_IndexedMap aNewRoots; for (int i = 1; i <= theroots.Extent(); i++) + { if (theindex != theroots.FindKey(i)) + { aNewRoots.Add(theroots.FindKey(i)); + } + } theroots.Clear(); theroots = aNewRoots; @@ -318,7 +364,9 @@ occ::handle Transfer_ProcessForTransient::FindElseBind( { occ::handle binder = FindAndMask(start); if (!binder.IsNull()) + { return binder; + } binder = new Transfer_VoidBinder; Bind(start, binder); return binder; @@ -329,9 +377,13 @@ occ::handle Transfer_ProcessForTransient::FindElseBind( void Transfer_ProcessForTransient::SetMessenger(const occ::handle& messenger) { if (messenger.IsNull()) + { themessenger = Message::DefaultMessenger(); + } else + { themessenger = messenger; + } } //================================================================================================= @@ -389,8 +441,10 @@ void Transfer_ProcessForTransient::SendMsg(const occ::handle Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); aSender << amsg.Value(); if (amsg.IsEdited() && thetrace > 2) + { aSender << " [from: " << amsg.Original() << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -413,8 +467,10 @@ void Transfer_ProcessForTransient::AddFail(const occ::handle Message_Messenger::StreamBuffer aSender = themessenger->SendFail(); aSender << " --> Fail : " << mess; if (orig[0] != '\0' && thetrace > 2) + { aSender << " [from: " << orig << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -433,11 +489,15 @@ void Transfer_ProcessForTransient::AddFail(const occ::handle const Message_Msg& amsg) { if (amsg.IsEdited()) + { AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString(), TCollection_AsciiString(amsg.Original()).ToCString()); + } else + { AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString()); + } } //================================================================================================= @@ -459,8 +519,10 @@ void Transfer_ProcessForTransient::AddWarning(const occ::handleSendWarning(); aSender << " --> Warning : " << mess; if (orig[0] != '\0' && thetrace > 2) + { aSender << " [from: " << orig << "]"; - aSender << std::endl; + } + aSender << '\n'; } } @@ -470,11 +532,15 @@ void Transfer_ProcessForTransient::AddWarning(const occ::handle& s { occ::handle binder = FindAndMask(start); if (binder.IsNull()) + { return; + } occ::handle ach = binder->CCheck(); ach->Mend(pref); } @@ -509,7 +577,9 @@ void Transfer_ProcessForTransient::BindTransient(const occ::handle& res) { if (res.IsNull()) + { return; + } occ::handle former = Find(start); occ::handle binder = occ::down_cast(former); @@ -524,9 +594,13 @@ void Transfer_ProcessForTransient::BindTransient(const occ::handleSetResult(res); if (former.IsNull()) + { Bind(start, binder); + } else + { Rebind(start, binder); + } } //================================================================================================= @@ -538,9 +612,13 @@ const occ::handle& Transfer_ProcessForTransient::FindTransie occ::handle binder = occ::down_cast(Find(start)); if (binder.IsNull()) + { return aDummy; + } if (!binder->HasResult()) + { return aDummy; + } return binder->Result(); } @@ -558,7 +636,9 @@ void Transfer_ProcessForTransient::BindMultiple(const occ::handleAddResult(res); } @@ -638,7 +722,9 @@ void Transfer_ProcessForTransient::SetRoot(const occ::handle theroots.Add(index); if (thetrace > 2) + { StartTrace(MapItem(index), start, thelevel, 3); + } } //================================================================================================= @@ -661,7 +747,9 @@ const occ::handle& Transfer_ProcessForTransient::Root(const { int ind = 0; if (num > 0 && num <= theroots.Extent()) + { ind = theroots.FindKey(num); + } return themap.FindKey(ind); } @@ -671,7 +759,9 @@ occ::handle Transfer_ProcessForTransient::RootItem(const int nu { int ind = 0; if (num > 0 && num <= theroots.Extent()) + { ind = theroots.FindKey(num); + } return themap.FindFromIndex(ind); } @@ -681,7 +771,9 @@ int Transfer_ProcessForTransient::RootIndex(const occ::handleRecognize(start)) + { return true; + } actor = actor->Next(); } return false; @@ -739,7 +833,7 @@ occ::handle Transfer_ProcessForTransient::Transferring( case Transfer_StatusInitial: break; case Transfer_StatusDone: - aSender << " .. and Transfer done" << std::endl; + aSender << " .. and Transfer done" << '\n'; return former; case Transfer_StatusRun: former->SetStatusExec(Transfer_StatusLoop); @@ -747,25 +841,31 @@ occ::handle Transfer_ProcessForTransient::Transferring( case Transfer_StatusError: if (thetrace) { - aSender << " *** Transfer in Error Status :" << std::endl; + aSender << " *** Transfer in Error Status :" << '\n'; StartTrace(former, start, thelevel, 0); } else + { StartTrace(former, start, thelevel, 4); + } throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status"); case Transfer_StatusLoop: if (thetrace) { - aSender << " *** Transfer Head of Dead Loop :" << std::endl; + aSender << " *** Transfer Head of Dead Loop :" << '\n'; StartTrace(former, start, thelevel, 0); } else + { StartTrace(former, start, thelevel, 4); + } hasDeadLoop = true; break; } if (!hasDeadLoop) + { former->SetStatusExec(Transfer_StatusRun); + } } occ::handle binder; @@ -780,11 +880,13 @@ occ::handle Transfer_ProcessForTransient::Transferring( Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); if (thetrace) { - aSender << " *** Dead Loop : Finding head of Loop :" << std::endl; + aSender << " *** Dead Loop : Finding head of Loop :" << '\n'; StartTrace(former, start, thelevel - 1, 0); } else + { StartTrace(former, start, thelevel - 1, 4); + } binder = former; binder->AddFail("Transfer: Head of Dead Loop"); binder->AddFail("Transfer in dead Loop"); @@ -804,7 +906,7 @@ occ::handle Transfer_ProcessForTransient::Transferring( { if (binder.IsNull()) { - aSender << " *** Exception Raised with no Result" << std::endl; + aSender << " *** Exception Raised with no Result" << '\n'; binder = new Transfer_VoidBinder; Bind(start, binder); newbind = true; @@ -812,7 +914,7 @@ occ::handle Transfer_ProcessForTransient::Transferring( binder->AddFail("Transfer stopped by exception raising"); if (thetrace) { - aSender << " *** Raised : " << anException.what() << std::endl; + aSender << " *** Raised : " << anException.what() << '\n'; StartTrace(binder, start, thelevel - 1, 4); } thelevel = oldlev; @@ -821,30 +923,40 @@ occ::handle Transfer_ProcessForTransient::Transferring( // Unprotected transfer (thus, dbx by hand in case of crash by Raise) else + { binder = TransferProduct(start, theProgress); + } if (theProgress.UserBreak()) + { return occ::handle(); + } if (!newbind && !binder.IsNull()) { if (former.IsNull()) { if (!IsBound(start)) + { Bind(start, binder); + } else { Rebind(start, binder); } } else + { Rebind(start, binder); + } } else { if (!former.IsNull()) + { former->SetStatusExec(Transfer_StatusDone); //+ - return occ::handle(); // Null Binder ... what else to do? + } + return occ::handle(); // Null Binder ... what else to do? } if (therootl >= thelevel) @@ -887,19 +999,27 @@ occ::handle Transfer_ProcessForTransient::TransferProduct( actor = actor->Next(); } if (aScope.UserBreak()) + { return occ::handle(); + } if (binder.IsNull()) { if (thelevel > 0) + { thelevel--; + } return binder; } if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone) + { therootl = thelevel - 1; + } if (thelevel > 0) + { thelevel--; + } return binder; } @@ -939,24 +1059,42 @@ void Transfer_ProcessForTransient::StartTrace(const occ::handle if (thetrace > 3) { // Internal to be switch when searching bug (trace >= 4) if (mode == 1) + { aSender << " ### Fail"; + } if (mode == 2) + { aSender << " ### Warning"; + } if (mode == 3) + { aSender << " ### New Root n0 " << theroots.Extent(); + } if (mode == 4) + { aSender << " ### Exception"; + } if (mode == 5) + { aSender << " ### Substitution"; + } if (mode == 6) + { aSender << " ### Information"; + } if (level > 1) + { aSender << " (nested)"; + } if (mode >= 0 && mode != 3) + { aSender << " at " << theroots.Extent() << " Roots"; + } } if (!start.IsNull()) + { PrintTrace(start, aSender); + } if (!binder.IsNull()) { @@ -967,9 +1105,13 @@ void Transfer_ProcessForTransient::StartTrace(const occ::handle if (bnd->Status() != Transfer_StatusVoid) { if (!hasres) + { aSender << "\n --- Result Type : "; + } else + { aSender << " , "; + } aSender << bnd->ResultTypeName(); hasres = true; } @@ -980,7 +1122,7 @@ void Transfer_ProcessForTransient::StartTrace(const occ::handle aSender << "\n --- No Result recorded"; } } - aSender << std::endl; + aSender << '\n'; } //================================================================================================= @@ -989,7 +1131,9 @@ void Transfer_ProcessForTransient::PrintTrace(const occ::handleDynamicType()->Name(); + } } //================================================================================================= @@ -1011,11 +1155,17 @@ Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::RootResult( int i = theroots.FindKey(j); occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(i)); + } else + { iter.Add(binder); + } } return iter; } @@ -1031,11 +1181,17 @@ Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::CompleteRes { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(i)); + } else + { iter.Add(binder); + } } return iter; } @@ -1050,10 +1206,14 @@ Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::AbnormalRes { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) + { iter.Add(binder, Mapped(i)); + } } return iter; } @@ -1068,17 +1228,25 @@ Interface_CheckIterator Transfer_ProcessForTransient::CheckList(const bool erron { occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && !check->HasFailed()) + { check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); + } if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) + { continue; + } const occ::handle& ent = Mapped(i); num = CheckNum(ent); if (num == 0) + { num = i; + } check->SetEntity(ent); list.Add(check, num); } @@ -1096,7 +1264,9 @@ Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::ResultOne( int max = NbMapped(); int ind = MapIndex(start); if (ind == 0) + { return iter; + } int i1 = (level == 0 ? ind : 1); int i2 = (level == 0 ? ind : max); occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1105,14 +1275,22 @@ Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::ResultOne( { ind = map->Value(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(i); if (binder.IsNull()) + { continue; + } if (withstart) + { iter.Add(binder, Mapped(ind)); + } else + { iter.Add(binder); + } } return iter; } @@ -1128,7 +1306,9 @@ Interface_CheckIterator Transfer_ProcessForTransient::CheckListOne( int max = NbMapped(); int num, ind = MapIndex(start); if (ind == 0) + { return list; + } int i1 = (level == 0 ? ind : 1); int i2 = (level == 0 ? ind : max); occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1137,20 +1317,30 @@ Interface_CheckIterator Transfer_ProcessForTransient::CheckListOne( { ind = map->Value(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && !check->HasFailed()) + { check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); + } if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) + { continue; + } const occ::handle& ent = Mapped(ind); num = CheckNum(ent); if (num == 0) + { num = ind; + } check->SetEntity(ent); list.Add(check, num); } @@ -1166,7 +1356,9 @@ bool Transfer_ProcessForTransient::IsCheckListEmpty(const occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1175,17 +1367,25 @@ bool Transfer_ProcessForTransient::IsCheckListEmpty(const occ::handleValue(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); occ::handle check = binder->Check(); if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) + { return false; + } if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) + { return false; + } } return true; } @@ -1200,7 +1400,9 @@ void Transfer_ProcessForTransient::RemoveResult(const occ::handle> map = new NCollection_HArray1(i1, i2, 0); @@ -1210,10 +1412,14 @@ void Transfer_ProcessForTransient::RemoveResult(const occ::handleValue(i); if (ind == 0) + { continue; + } occ::handle binder = MapItem(ind); if (binder.IsNull()) + { continue; + } } } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromModel.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromModel.cxx index 2fd9e71f12..0f5fa8677d 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromModel.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromModel.cxx @@ -56,10 +56,14 @@ bool Transfer_ResultFromModel::Fill(const occ::handle const occ::handle& ent) { if (TP.IsNull() || ent.IsNull()) + { return false; + } occ::handle binder = TP->Find(ent); if (binder.IsNull()) + { return false; + } themain = new Transfer_ResultFromTransient; themain->SetStart(ent); themain->SetBinder(binder); @@ -67,20 +71,28 @@ bool Transfer_ResultFromModel::Fill(const occ::handle // Result substitution for the Shape (-> HShape): not here, we are // in the Transfer package which is general and doesn't know what a Shape is ... if (!TP->Model().IsNull()) + { themodel = TP->Model(); + } if (themodel.IsNull()) + { return true; + } themnum = themodel->Number(ent); themlab.Clear(); if (themnum > 0) + { themlab.AssignCat(themodel->StringLabel(ent)->ToCString()); + } return true; } void Transfer_ResultFromModel::Strip(const int mode) { if (themain.IsNull()) + { return; + } themain->Strip(); if (mode >= 10) { @@ -90,14 +102,18 @@ void Transfer_ResultFromModel::Strip(const int mode) occ::handle nulh; themain->SetStart(nulh); if (mode > 10) + { themain.Nullify(); + } } } void Transfer_ResultFromModel::FillBack(const occ::handle& TP) const { if (!themodel.IsNull()) + { TP->SetModel(themodel); + } themain->FillBack(TP); } @@ -116,11 +132,15 @@ void Transfer_ResultFromModel::SetMainResult(const occ::handleNumber(themain->Start()); themlab.Clear(); if (themnum > 0) + { themlab.AssignCat(themodel->StringLabel(themain->Start())->ToCString()); + } } const char* Transfer_ResultFromModel::MainLabel() const @@ -155,15 +175,21 @@ occ::handle>> Transfer_Res themain->FillMap(map); nb = map.Extent(); for (i = 1; i <= nb; i++) + { list->Append(map.FindKey(i)); + } } else + { list->Append(themain); + } if (level == 1) { nb = themain->NbSubResults(); for (i = 1; i <= nb; i++) + { list->Append(themain->SubResult(i)); + } list->Append(themain); } return list; @@ -181,9 +207,13 @@ occ::handle>> Transfer_Res { DeclareAndCast(Transfer_ResultFromTransient, unres, res->Value(i)); if (unres.IsNull()) + { continue; + } if (unres->HasResult()) + { list->Append(unres->Start()); + } } return list; } @@ -200,12 +230,18 @@ occ::handle>> Transfer_Res { DeclareAndCast(Transfer_ResultFromTransient, unres, res->Value(i)); if (unres.IsNull()) + { continue; + } if (result && !unres->HasResult()) + { continue; + } const occ::handle ach = unres->Check(); if (ach->Complies(check)) + { list->Append(unres->Start()); + } } return list; } @@ -223,10 +259,14 @@ Interface_CheckIterator Transfer_ResultFromModel::CheckList(const bool erronly, { DeclareAndCast(Transfer_ResultFromTransient, unres, res->Value(i)); if (unres.IsNull()) + { continue; + } Interface_CheckStatus stat = unres->CheckStatus(); if (stat == Interface_CheckOK || (stat == Interface_CheckWarning && erronly)) + { continue; + } occ::handle binder = unres->Binder(); occ::handle bch = binder->Check(); bch->SetEntity(unres->Start()); @@ -238,7 +278,9 @@ Interface_CheckIterator Transfer_ResultFromModel::CheckList(const bool erronly, Interface_CheckStatus Transfer_ResultFromModel::CheckStatus() const { if (themchk != Interface_CheckAny) + { return themchk; + } Interface_CheckIterator chl = CheckList(false, 2); return chl.Status(); } @@ -246,6 +288,8 @@ Interface_CheckStatus Transfer_ResultFromModel::CheckStatus() const Interface_CheckStatus Transfer_ResultFromModel::ComputeCheckStatus(const bool enforce) { if (themchk == Interface_CheckAny || enforce) + { themchk = CheckStatus(); + } return themchk; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromTransient.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromTransient.cxx index bcaf845ffa..7e31c81295 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromTransient.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_ResultFromTransient.cxx @@ -51,14 +51,18 @@ bool Transfer_ResultFromTransient::HasResult() const const occ::handle Transfer_ResultFromTransient::Check() const { if (thebinder.IsNull()) + { return voidcheck; + } return thebinder->Check(); } Interface_CheckStatus Transfer_ResultFromTransient::CheckStatus() const { if (thebinder.IsNull()) + { return Interface_CheckOK; + } const occ::handle ach = thebinder->Check(); return ach->Status(); } @@ -68,13 +72,17 @@ occ::handle Transfer_ResultFromTransient::ResultFr { occ::handle res; if (key == thestart) + { return this; + } int i, nb = NbSubResults(); for (i = 1; i <= nb; i++) { res = SubResult(i)->ResultFromKey(key); if (!res.IsNull()) + { return res; + } } return res; } @@ -83,12 +91,18 @@ void Transfer_ResultFromTransient::FillMap( NCollection_IndexedMap>& map) const { if (thesubs.IsNull()) + { return; + } int i, nb = thesubs->Length(); for (i = 1; i <= nb; i++) + { map.Add(thesubs->Value(i)); + } for (i = 1; i <= nb; i++) + { SubResult(i)->FillMap(map); + } } // ##### SUBS ##### @@ -102,9 +116,13 @@ void Transfer_ResultFromTransient::AddSubResult( const occ::handle& sub) { if (sub.IsNull()) + { return; + } if (thesubs.IsNull()) + { thesubs = new NCollection_HSequence>(); + } thesubs->Append(sub); } @@ -118,16 +136,19 @@ occ::handle Transfer_ResultFromTransient::SubResul { occ::handle sub; if (thesubs.IsNull()) + { return sub; + } if (num < 1 || num > thesubs->Length()) + { return sub; + } return occ::down_cast(thesubs->Value(num)); } void Transfer_ResultFromTransient::Fill(const occ::handle& /*TP*/) { // abv: WARNING: to be removed (scopes) - return; } void Transfer_ResultFromTransient::Strip() diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_SimpleBinderOfTransient.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_SimpleBinderOfTransient.cxx index b6781e82d2..2f5c3448fe 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_SimpleBinderOfTransient.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_SimpleBinderOfTransient.cxx @@ -27,14 +27,18 @@ Transfer_SimpleBinderOfTransient::Transfer_SimpleBinderOfTransient() = default; occ::handle Transfer_SimpleBinderOfTransient::ResultType() const { if (!HasResult() || theres.IsNull()) + { return STANDARD_TYPE(Standard_Transient); + } return Result()->DynamicType(); } const char* Transfer_SimpleBinderOfTransient::ResultTypeName() const { if (!HasResult() || theres.IsNull()) + { return "(void)"; + } return Result()->DynamicType()->Name(); } @@ -54,7 +58,9 @@ bool Transfer_SimpleBinderOfTransient::GetTypedResult(const occ::handle& res) { if (atype.IsNull()) + { return false; + } occ::handle bn = bnd; while (!bn.IsNull()) { @@ -62,12 +68,18 @@ bool Transfer_SimpleBinderOfTransient::GetTypedResult(const occ::handle(bn); bn = bn->NextResult(); if (trb.IsNull()) + { continue; + } const occ::handle& rs = trb->Result(); if (rs.IsNull()) + { continue; + } if (!rs->IsKind(atype)) + { continue; + } res = rs; return true; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferDispatch.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferDispatch.cxx index 12e0c3aab4..e66ceae238 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferDispatch.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferDispatch.cxx @@ -59,10 +59,14 @@ bool Transfer_TransferDispatch::Copy(const occ::handle& entf { occ::handle result = TransientProcess()->Transferring(entfrom); if (result.IsNull()) + { return Interface_CopyTool::Copy(entfrom, entto, mapped, errstat); + } if (!result->IsKind(STANDARD_TYPE(Transfer_SimpleBinderOfTransient))) + { return false; // Produces something, but what ? + } entto = GetCasted(Transfer_SimpleBinderOfTransient, result)->Result(); return true; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferInput.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferInput.cxx index b74e85bcf7..b07003c57e 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferInput.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferInput.cxx @@ -39,9 +39,13 @@ Interface_EntityIterator Transfer_TransferInput::Entities(Transfer_TransferItera { const occ::handle& binder = list.Value(); if (binder.IsNull()) + { continue; + } if (binder->IsKind(STANDARD_TYPE(Transfer_VoidBinder))) + { continue; + } // True result : must be transient (simple or list) DeclareAndCast(Transfer_SimpleBinderOfTransient, transb, binder); @@ -49,7 +53,9 @@ Interface_EntityIterator Transfer_TransferInput::Entities(Transfer_TransferItera if (!transb.IsNull()) { if (transb->HasResult()) + { iter.AddItem(transb->Result()); + } } else if (!multi.IsNull()) { @@ -57,13 +63,19 @@ Interface_EntityIterator Transfer_TransferInput::Entities(Transfer_TransferItera multi->MultipleResult(); int nbres = 0; if (!mulres.IsNull()) + { nbres = mulres->Length(); + } for (int i = 1; i <= nbres; i++) + { iter.AddItem(mulres->Value(i)); + } } else + { throw Transfer_TransferFailure( "TransferInput : Entities, one of the Results is not Transient Handle"); + } } return iter; } @@ -83,12 +95,18 @@ void Transfer_TransferInput::FillModel(const occ::handleRootResult(); + } else + { list = proc->CompleteResult(); + } Interface_EntityIterator iter = Entities(list); for (iter.Start(); iter.More(); iter.Next()) + { amodel->AddWithRefs(iter.Value(), proto); + } } void Transfer_TransferInput::FillModel(const occ::handle& proc, @@ -106,10 +124,16 @@ void Transfer_TransferInput::FillModel(const occ::handle { Transfer_TransferIterator list; if (roots) + { list = proc->RootResult(); + } else + { list = proc->CompleteResult(); + } Interface_EntityIterator iter = Entities(list); for (iter.Start(); iter.More(); iter.Next()) + { amodel->AddWithRefs(iter.Value(), proto); + } } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferIterator.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferIterator.cxx index 8ac1b2194a..c92cdfdadc 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferIterator.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferIterator.cxx @@ -43,7 +43,9 @@ void Transfer_TransferIterator::SelectBinder(const occ::handle& a { theselect->SetValue(i, 0); if (themaxi == i) + { themaxi = i - 1; + } } } } @@ -53,7 +55,9 @@ void Transfer_TransferIterator::SelectResult(const occ::handle& a { int casetype = 0; if (atype->SubType(STANDARD_TYPE(Standard_Transient))) + { casetype = 2; + } for (int i = theitems->Length(); i > 0; i--) { @@ -61,18 +65,28 @@ void Transfer_TransferIterator::SelectResult(const occ::handle& a occ::handle btype = ResultType(); bool matchtype; if (!atr->HasResult()) + { matchtype = false; + } else if (atr->IsMultiple()) + { matchtype = false; + } else if (casetype == 0) + { matchtype = (atype == btype); // Type fixe + } else + { matchtype = (btype->SubType(atype)); // Dynamique + } if (matchtype != keep) { theselect->SetValue(i, 0); if (themaxi == i) + { themaxi = i - 1; + } } } } @@ -86,7 +100,9 @@ void Transfer_TransferIterator::SelectUnique(const bool keep) { theselect->SetValue(i, 0); if (themaxi == i) + { themaxi = i - 1; + } } } } @@ -94,11 +110,17 @@ void Transfer_TransferIterator::SelectUnique(const bool keep) void Transfer_TransferIterator::SelectItem(const int num, const bool keep) { if (num < 1 || num > theselect->Length()) + { return; + } if (keep) + { theselect->SetValue(num, 1); + } else + { theselect->SetValue(num, 0); + } } // .... Iteration-Interrogations .... @@ -110,7 +132,9 @@ int Transfer_TransferIterator::Number() const for (i = 1; i <= themaxi; i++) { if (theselect->Value(i) != 0) + { numb++; + } } return numb; } @@ -124,11 +148,17 @@ void Transfer_TransferIterator::Start() bool Transfer_TransferIterator::More() { if (thecurr > themaxi) + { return false; + } if (theselect->Value(thecurr) == 0) + { Next(); + } if (thecurr > themaxi) + { return false; + } return (theselect->Value(thecurr) > 0); } @@ -136,17 +166,25 @@ void Transfer_TransferIterator::Next() { thecurr++; if (thecurr > themaxi) + { return; + } if (theselect->Value(thecurr) == 0) + { Next(); + } } const occ::handle& Transfer_TransferIterator::Value() const { if (thecurr == 0 || thecurr > themaxi) + { throw Standard_NoSuchObject("TransferIterator : Value"); + } if (theselect->Value(thecurr) == 0) + { throw Standard_NoSuchObject("TransferIterator : Value"); + } return theitems->Value(thecurr); } @@ -162,7 +200,9 @@ bool Transfer_TransferIterator::HasUniqueResult() const { occ::handle atr = Value(); if (atr->IsMultiple()) + { return false; + } return atr->HasResult(); } @@ -171,7 +211,9 @@ occ::handle Transfer_TransferIterator::ResultType() const occ::handle btype; occ::handle atr = Value(); if (!atr->IsMultiple()) + { btype = atr->ResultType(); + } // Binder's ResultType takes into account the Dynamic Type for Handles return btype; } @@ -180,7 +222,9 @@ bool Transfer_TransferIterator::HasTransientResult() const { occ::handle btype = ResultType(); if (btype.IsNull()) + { return false; + } return btype->SubType(STANDARD_TYPE(Standard_Transient)); } @@ -189,7 +233,9 @@ const occ::handle& Transfer_TransferIterator::TransientResul occ::handle atr = occ::down_cast(Value()); if (!atr.IsNull()) + { return atr->Result(); + } return nultrans; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferOutput.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferOutput.cxx index 2e83474626..62d66ca583 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransferOutput.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransferOutput.cxx @@ -64,8 +64,10 @@ void Transfer_TransferOutput::Transfer(const occ::handle& ob const Message_ProgressRange& theProgress) { if (themodel->Number(obj) == 0) + { throw Transfer_TransferFailure( "TransferOutput : Transfer, entities do not come from same initial model"); + } // int scope = 0; // if (thescope) scope = theproc->NewScope (obj); @@ -107,7 +109,9 @@ void Transfer_TransferOutput::TransferRoots(const occ::handleNewScope (ent); if (theproc->Transfer(ent, aPS.Next())) + { theproc->SetRoot(ent); + } // if (scope > 0) theproc->EndScope (scope); } } @@ -126,7 +130,9 @@ void Transfer_TransferOutput::TransferRoots(const Interface_Graph& G, // int scope = 0; // if (thescope) scope = theproc->NewScope (ent); if (theproc->Transfer(ent, aPS.Next())) + { theproc->SetRoot(ent); + } // if (scope > 0) theproc->EndScope (scope); } } @@ -141,11 +147,15 @@ Interface_EntityIterator Transfer_TransferOutput::ListForStatus(const bool norma const occ::handle& binder = (roots ? theproc->RootItem(i) : theproc->MapItem(i)); if (binder.IsNull()) + { continue; + } Transfer_StatusExec statex = binder->StatusExec(); bool ok = (statex == Transfer_StatusInitial || statex == Transfer_StatusDone); if (ok == normal) + { list.AddItem((roots ? theproc->Root(i) : theproc->Mapped(i))); + } } return list; } @@ -157,10 +167,14 @@ occ::handle Transfer_TransferOutput::ModelForStatus( { occ::handle newmod; if (themodel.IsNull()) + { return newmod; + } newmod = themodel->NewEmptyModel(); Interface_EntityIterator list = ListForStatus(normal, roots); for (list.Start(); list.More(); list.Next()) + { newmod->AddWithRefs(list.Value(), protocol); + } return newmod; } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransientMapper_0.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransientMapper_0.cxx index 907dcab11c..21b3c44293 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransientMapper_0.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransientMapper_0.cxx @@ -41,11 +41,17 @@ const occ::handle& Transfer_TransientMapper::Value() const bool Transfer_TransientMapper::Equates(const occ::handle& other) const { if (other.IsNull()) + { return false; + } if (GetHashCode() != other->GetHashCode()) + { return false; + } if (other->DynamicType() != DynamicType()) + { return false; + } occ::handle another = occ::down_cast(other); return theval == another->Value(); } diff --git a/src/DataExchange/TKXSBase/Transfer/Transfer_TransientProcess.cxx b/src/DataExchange/TKXSBase/Transfer/Transfer_TransientProcess.cxx index e30291c70b..b1ad44c6c9 100644 --- a/src/DataExchange/TKXSBase/Transfer/Transfer_TransientProcess.cxx +++ b/src/DataExchange/TKXSBase/Transfer/Transfer_TransientProcess.cxx @@ -50,9 +50,13 @@ void Transfer_TransientProcess::SetGraph(const occ::handle& HG { thegraph = HG; if (!thegraph.IsNull()) + { SetModel(thegraph->Graph().Model()); + } else + { themodel.Nullify(); + } } //================================================================================================= @@ -91,16 +95,26 @@ bool Transfer_TransientProcess::GetContext(const char* const nam occ::handle& ctx) const { if (thectx.IsEmpty()) + { return false; + } if (!thectx.Find(name, ctx)) + { ctx.Nullify(); + } if (ctx.IsNull()) + { return false; + } if (type.IsNull()) + { return true; + } if (!ctx->IsKind(type)) + { ctx.Nullify(); + } return !ctx.IsNull(); } @@ -127,7 +141,9 @@ void Transfer_TransientProcess::PrintTrace(const occ::handle // S<<" Type:"<TypeName (start); } else + { S << "Entity Type:" << Interface_InterfaceModel::ClassName(start->DynamicType()->Name()); + } // << start (handle) ?? } } @@ -147,7 +163,9 @@ Interface_EntityIterator Transfer_TransientProcess::TypedSharings( { Interface_EntityIterator iter; if (thegraph.IsNull()) + { return iter; + } return thegraph->Graph().TypedSharings(start, type); } @@ -156,12 +174,18 @@ Interface_EntityIterator Transfer_TransientProcess::TypedSharings( bool Transfer_TransientProcess::IsDataLoaded(const occ::handle& start) const { if (themodel.IsNull()) + { return true; + } int num = themodel->Number(start); if (num == 0) + { return true; + } if (themodel->IsUnknownEntity(num)) + { return false; + } return !themodel->IsRedefinedContent(num); } @@ -170,12 +194,18 @@ bool Transfer_TransientProcess::IsDataLoaded(const occ::handle& start) const { if (themodel.IsNull()) + { return false; + } int num = themodel->Number(start); if (num == 0) + { return false; + } if (themodel->IsErrorEntity(num)) + { return true; + } const occ::handle ach = themodel->Check(num, false); // semantic return ach->HasFailed(); } @@ -186,46 +216,64 @@ void Transfer_TransientProcess::PrintStats(const int /*mode*/, Standard_OStream& { S << "\n*******************************************************************\n"; // if (mode == 1) { // Basic statistics - S << "******** Basic Statistics ********" << std::endl; + S << "******** Basic Statistics ********" << '\n'; occ::handle model = Model(); if (model.IsNull()) - S << "**** Model unknown" << std::endl; + { + S << "**** Model unknown" << '\n'; + } else - S << "**** Nb Entities : " << model->NbEntities() << std::endl; + { + S << "**** Nb Entities : " << model->NbEntities() << '\n'; + } int nbr = 0, nbe = 0, nbw = 0; int i, max = NbMapped(), nbroots = NbRoots(); - S << "**** Nb Final Results : " << nbroots << std::endl; + S << "**** Nb Final Results : " << nbroots << '\n'; for (i = 1; i <= max; i++) { const occ::handle& binder = MapItem(i); if (binder.IsNull()) + { continue; + } const occ::handle ach = binder->Check(); Transfer_StatusExec stat = binder->StatusExec(); if (stat != Transfer_StatusInitial && stat != Transfer_StatusDone) + { nbe++; + } else { if (ach->NbWarnings() > 0) + { nbw++; + } if (binder->HasResult()) + { nbr++; + } } } if (nbr > nbroots) + { S << "**** ( Itermediate Results : " << nbr - nbroots << " )\n"; + } if (nbe > 0) + { S << "**** Errors on : " << Interface_MSG::Blanks(nbe, 4) << nbe << " Entities\n"; + } if (nbw > 0) + { S << "**** Warnings on : " << Interface_MSG::Blanks(nbw, 4) << nbw << " Entities\n"; + } S << "*******************************************************************"; // } - S << std::endl; + S << '\n'; } //================================================================================================= diff --git a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep.cxx b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep.cxx index 58ed01201d..b4ff12e185 100644 --- a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep.cxx +++ b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep.cxx @@ -38,30 +38,40 @@ static void ShapeAppend(const occ::handle& const occ::handle>& shapes) { if (binder.IsNull()) + { return; + } if (binder->IsKind(STANDARD_TYPE(TransferBRep_BinderOfShape))) { DeclareAndCast(TransferBRep_BinderOfShape, shbind, binder); if (shbind->HasResult()) + { shapes->Append(shbind->Result()); + } } else if (binder->IsKind(STANDARD_TYPE(TransferBRep_ShapeListBinder))) { DeclareAndCast(TransferBRep_ShapeListBinder, slbind, binder); int i, nb = slbind->NbShapes(); for (i = 1; i <= nb; i++) + { shapes->Append(slbind->Shape(i)); + } } else if (binder->IsKind(STANDARD_TYPE(Transfer_SimpleBinderOfTransient))) { DeclareAndCast(Transfer_SimpleBinderOfTransient, trbind, binder); DeclareAndCast(TopoDS_HShape, hs, trbind->Result()); if (!hs.IsNull()) + { shapes->Append(hs->Shape()); + } } occ::handle nextr = binder->NextResult(); if (!nextr.IsNull()) + { ShapeAppend(nextr, shapes); + } } TopoDS_Shape TransferBRep::ShapeResult(const occ::handle& binder) @@ -72,13 +82,17 @@ TopoDS_Shape TransferBRep::ShapeResult(const occ::handle& binde { DeclareAndCast(TransferBRep_BinderOfShape, shb, bnd); if (!shb.IsNull()) + { return shb->Result(); + } DeclareAndCast(Transfer_SimpleBinderOfTransient, hsb, bnd); if (!hsb.IsNull()) { occ::handle hsp = GetCasted(TopoDS_HShape, hsb->Result()); if (!hsp.IsNull()) + { return hsp->Shape(); + } } bnd = bnd->NextResult(); } @@ -91,12 +105,18 @@ TopoDS_Shape TransferBRep::ShapeResult(const occ::handle binder = TP->Find(ent); if (binder.IsNull()) + { binder = GetCasted(Transfer_Binder, ent); + } if (!binder.IsNull()) + { return TransferBRep::ShapeResult(binder); + } DeclareAndCast(TopoDS_HShape, hsp, ent); if (!hsp.IsNull()) + { return hsp->Shape(); + } return shape; } @@ -105,7 +125,9 @@ void TransferBRep::SetShapeResult(const occ::handle& const TopoDS_Shape& result) { if (result.IsNull() || ent.IsNull() || TP.IsNull()) + { return; + } TP->Bind(ent, new TransferBRep_ShapeBinder(result)); } @@ -115,7 +137,9 @@ occ::handle> TransferBRep::Shapes( { occ::handle> shapes; if (TP.IsNull()) + { return shapes; + } shapes = new NCollection_HSequence(); Transfer_IteratorOfProcessForTransient list = (roots ? TP->RootResult() : TP->CompleteResult()); @@ -134,7 +158,9 @@ occ::handle> TransferBRep::Shapes( { occ::handle> shapes; if (TP.IsNull() && list.IsNull()) + { return shapes; + } shapes = new NCollection_HSequence(); int ie, ne = list->Length(); @@ -151,18 +177,26 @@ TopAbs_Orientation TransferBRep::ShapeState(const occ::handle sm = new TransferBRep_ShapeMapper(shape); int index = FP->MapIndex(sm); if (index == 0) + { return TopAbs_EXTERNAL; + } sm = occ::down_cast(FP->Mapped(index)); if (sm.IsNull()) + { return TopAbs_EXTERNAL; + } const TopoDS_Shape& mapped = sm->Value(); // equality is assumed, we only test the orientation if (mapped.Orientation() != shape.Orientation()) + { return TopAbs_REVERSED; + } return TopAbs_FORWARD; } @@ -172,7 +206,9 @@ occ::handle TransferBRep::ResultFromShape( { occ::handle res; if (FP.IsNull() || shape.IsNull()) + { return res; + } occ::handle sm = new TransferBRep_ShapeMapper(shape); return FP->Find(sm); } @@ -183,7 +219,9 @@ occ::handle TransferBRep::TransientFromShape( { occ::handle res; if (FP.IsNull() || shape.IsNull()) + { return res; + } occ::handle sm = new TransferBRep_ShapeMapper(shape); return FP->FindTransient(sm); } @@ -193,7 +231,9 @@ void TransferBRep::SetTransientFromShape(const occ::handle& result) { if (FP.IsNull() || shape.IsNull()) + { return; + } occ::handle sm = new TransferBRep_ShapeMapper(shape); FP->BindTransient(sm, result); } @@ -205,7 +245,9 @@ occ::handle TransferBRep::ShapeMapper( occ::handle mapper = new TransferBRep_ShapeMapper(shape); int index = FP->MapIndex(mapper); if (index == 0) + { return mapper; + } return occ::down_cast(FP->Mapped(index)); } @@ -219,22 +261,40 @@ static void FillInfo(const occ::handle& Binder, { int R = 0, RW = 0, RF = 0, RWF = 0, NR = 0, NRW = 0, NRF = 0, NRWF = 0; if (Binder->HasResult()) + { if (Check->HasWarnings() && Check->HasFailed()) + { RWF++; + } else if (Check->HasWarnings()) + { RW++; + } else if (Check->HasFailed()) + { RF++; + } else + { R++; + } + } else if (Check->HasWarnings() && Check->HasFailed()) + { NRWF++; + } else if (Check->HasWarnings()) + { NRW++; + } else if (Check->HasFailed()) + { NRF++; + } else + { NR++; + } Info->Result() += R; Info->ResultWarning() += RW; Info->ResultFail() += RF; @@ -255,7 +315,9 @@ void TransferBRep::TransferResultInfo( // create output Sequence in accordance with required ShapeTypes InfoSeq = new NCollection_HSequence>; if (TP.IsNull() || EntityTypes.IsNull()) + { return; + } int SeqLen = EntityTypes->Length(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= SeqLen; i++) @@ -271,7 +333,9 @@ void TransferBRep::TransferResultInfo( occ::handle Binder = TP->Find(Entity); if (Binder.IsNull()) + { continue; + } const occ::handle Check = Binder->Check(); // find appropriate element in the Sequence @@ -297,7 +361,9 @@ void TransferBRep::TransferResultInfo( // create output Sequence in accordance with required ShapeTypes InfoSeq = new NCollection_HSequence>; if (FP.IsNull() || ShapeTypes.IsNull()) + { return; + } int SeqLen = ShapeTypes->Length(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= SeqLen; i++) @@ -313,7 +379,9 @@ void TransferBRep::TransferResultInfo( occ::down_cast(FP->Mapped(i)); occ::handle Binder = FP->Find(Mapper); if (Binder.IsNull()) + { continue; + } const occ::handle Check = Binder->Check(); TopoDS_Shape S = Mapper->Value(); @@ -359,18 +427,24 @@ Interface_CheckIterator TransferBRep::ResultCheckList( { Interface_CheckIterator nchl; if (FP.IsNull() || model.IsNull()) + { return nchl; + } nchl.SetModel(model); for (chl.Start(); chl.More(); chl.Next()) { int num = 0; const occ::handle& ach = chl.Value(); if (ach->NbFails() + ach->NbWarnings() == 0) + { continue; + } DeclareAndCast(Transfer_Finder, starting, ach->Entity()); occ::handle ent; if (!starting.IsNull()) + { ent = FP->FindTransient(starting); + } if (!ent.IsNull()) { ach->SetEntity(ent); @@ -391,16 +465,22 @@ occ::handle>> TransferBRep { const occ::handle& ach = chl.Value(); if (ach->NbFails() + ach->NbWarnings() == 0) + { continue; + } occ::handle ent = ach->Entity(); if (ent.IsNull()) + { continue; + } if (!alsoshapes) { if (ent->IsKind(STANDARD_TYPE(TransferBRep_BinderOfShape)) || ent->IsKind(STANDARD_TYPE(TopoDS_HShape)) || ent->IsKind(STANDARD_TYPE(TransferBRep_ShapeMapper))) + { continue; + } } ls->Append(ent); } @@ -415,19 +495,29 @@ occ::handle> TransferBRep::CheckedShapes( { const occ::handle& ach = chl.Value(); if (ach->NbFails() + ach->NbWarnings() == 0) + { continue; + } occ::handle ent = ach->Entity(); if (ent.IsNull()) + { continue; + } DeclareAndCast(TopoDS_HShape, hs, ent); DeclareAndCast(TransferBRep_BinderOfShape, sb, ent); DeclareAndCast(TransferBRep_ShapeMapper, sm, ent); if (!hs.IsNull()) + { ls->Append(hs->Shape()); + } if (!sb.IsNull()) + { ls->Append(sb->Result()); + } if (!sm.IsNull()) + { ls->Append(sm->Value()); + } } return ls; } @@ -440,21 +530,31 @@ Interface_CheckIterator TransferBRep::CheckObject(const Interface_CheckIterator& DeclareAndCast(TransferBRep_BinderOfShape, sb, obj); DeclareAndCast(TransferBRep_ShapeMapper, sm, obj); if (!hs.IsNull()) + { S = hs->Shape(); + } if (!sb.IsNull()) + { S = sb->Result(); + } if (!sm.IsNull()) + { S = sm->Value(); + } Interface_CheckIterator nchl; for (chl.Start(); chl.More(); chl.Next()) { const occ::handle& ach = chl.Value(); if (ach->NbFails() + ach->NbWarnings() == 0) + { continue; + } occ::handle ent = ach->Entity(); if (ent.IsNull()) + { continue; + } if (S.IsNull()) { if (ent == obj) @@ -471,11 +571,17 @@ Interface_CheckIterator TransferBRep::CheckObject(const Interface_CheckIterator& DeclareAndCast(TransferBRep_BinderOfShape, sbs, ent); DeclareAndCast(TransferBRep_ShapeMapper, smp, ent); if (!hsh.IsNull()) + { sh = hsh->Shape(); + } if (!sbs.IsNull()) + { sh = sbs->Result(); + } if (!smp.IsNull()) + { sh = smp->Value(); + } if (sh == S) { const occ::handle& bch(ach); diff --git a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_Reader.cxx b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_Reader.cxx index f900137add..6bc06e3065 100644 --- a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_Reader.cxx +++ b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_Reader.cxx @@ -122,12 +122,18 @@ bool TransferBRep_Reader::BeginTransfer() { theDone = false; if (theModel.IsNull()) + { return false; + } if (theNewpr || theProc.IsNull()) + { theProc = new Transfer_TransientProcess(theModel->NbEntities()); + } else + { theProc->Clear(); + } theProc->SetErrorHandle(true); theProc->SetModel(theModel); PrepareTransfer(); @@ -144,7 +150,9 @@ void TransferBRep_Reader::EndTransfer() occ::handle ent = theProc->Root(i); occ::handle res = theProc->FindTransient(ent); if (!res.IsNull()) + { theTransi->Append(res); + } } theDone = true; } @@ -155,7 +163,9 @@ void TransferBRep_Reader::TransferRoots(const Message_ProgressRange& theProgress { Clear(); if (!BeginTransfer()) + { return; + } Transfer_TransferOutput TP(theProc, theModel); TP.TransferRoots(theProto, theProgress); @@ -165,9 +175,13 @@ void TransferBRep_Reader::TransferRoots(const Message_ProgressRange& theProgress bool TransferBRep_Reader::Transfer(const int num, const Message_ProgressRange& theProgress) { if (!BeginTransfer()) + { return false; + } if (num <= 0 || num > theModel->NbEntities()) + { return false; + } occ::handle ent = theModel->Value(num); Transfer_TransferOutput TP(theProc, theModel); @@ -176,7 +190,7 @@ bool TransferBRep_Reader::Transfer(const int num, const Message_ProgressRange& t Message_Messenger::StreamBuffer sout = theProc->Messenger()->SendInfo(); sout << "-- Transfer(Read) : "; theModel->Print(ent, sout); - sout << std::endl; + sout << '\n'; } TP.Transfer(ent, theProgress); theProc->SetRoot(ent); @@ -189,28 +203,36 @@ void TransferBRep_Reader::TransferList( const Message_ProgressRange& theProgress) { if (!BeginTransfer()) + { return; + } if (list.IsNull()) + { return; + } Transfer_TransferOutput TP(theProc, theModel); int i, nb = list->Length(); Message_Messenger::StreamBuffer sout = theProc->Messenger()->SendInfo(); if (theProc->TraceLevel() > 1) - sout << "-- Transfer(Read-List) : " << nb << " Items" << std::endl; + { + sout << "-- Transfer(Read-List) : " << nb << " Items" << '\n'; + } Message_ProgressScope aPS(theProgress, nullptr, nb); for (i = 1; i <= nb && aPS.More(); i++) { Message_ProgressRange aRange = aPS.Next(); occ::handle ent = list->Value(i); if (theModel->Number(ent) == 0) + { continue; + } if (theProc->TraceLevel() > 1) { sout << "-- Transfer(Read-List), Item " << i << " : "; theModel->Print(ent, sout); - sout << std::endl; + sout << '\n'; } TP.Transfer(ent, aRange); theProc->SetRoot(ent); @@ -245,16 +267,22 @@ TopoDS_Shape TransferBRep_Reader::OneShape() const TopoDS_Shape res; int nb = theShapes->Length(); if (nb == 0) + { return res; + } else if (nb == 1) + { return theShapes->Value(1); + } else { TopoDS_Compound C; BRep_Builder B; B.MakeCompound(C); for (int i = 1; i <= nb; i++) + { B.Add(C, theShapes->Value(i)); + } return C; } } @@ -288,7 +316,9 @@ bool TransferBRep_Reader::CheckStatusResult(const bool withprint) const { Interface_CheckIterator chl; if (!theProc.IsNull()) + { chl = theProc->CheckList(false); + } if (withprint && !theProc.IsNull() && !theProc->Messenger().IsNull()) { Message_Messenger::StreamBuffer aBuffer = theProc->Messenger()->SendInfo(); @@ -300,7 +330,9 @@ bool TransferBRep_Reader::CheckStatusResult(const bool withprint) const Interface_CheckIterator TransferBRep_Reader::CheckListResult() const { if (!theProc.IsNull()) + { return theProc->CheckList(false); + } Interface_CheckIterator chbid; return chbid; } diff --git a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeBinder.cxx b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeBinder.cxx index 946cc3a82f..e158f0804c 100644 --- a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeBinder.cxx +++ b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeBinder.cxx @@ -35,7 +35,9 @@ TransferBRep_ShapeBinder::TransferBRep_ShapeBinder(const TopoDS_Shape& shape) TopAbs_ShapeEnum TransferBRep_ShapeBinder::ShapeType() const { if (!HasResult()) + { return TopAbs_SHAPE; + } return Result().ShapeType(); } diff --git a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeInfo.cxx b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeInfo.cxx index 8f5213ea47..a67b18786a 100644 --- a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeInfo.cxx +++ b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeInfo.cxx @@ -23,7 +23,9 @@ occ::handle TransferBRep_ShapeInfo::Type(const TopoDS_Shape& /*en const char* TransferBRep_ShapeInfo::TypeName(const TopoDS_Shape& ent) { if (ent.IsNull()) + { return "TopoDS_Shape"; + } switch (ent.ShapeType()) { case TopAbs_VERTEX: diff --git a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeMapper_0.cxx b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeMapper_0.cxx index d7c7782afd..af1ae666fc 100644 --- a/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeMapper_0.cxx +++ b/src/DataExchange/TKXSBase/TransferBRep/TransferBRep_ShapeMapper_0.cxx @@ -43,11 +43,17 @@ const TopoDS_Shape& TransferBRep_ShapeMapper::Value() const bool TransferBRep_ShapeMapper::Equates(const occ::handle& other) const { if (other.IsNull()) + { return false; + } if (GetHashCode() != other->GetHashCode()) + { return false; + } if (other->DynamicType() != DynamicType()) + { return false; + } occ::handle another = occ::down_cast(other); return TopTools_ShapeMapHasher{}(theval, another->Value()); } diff --git a/src/DataExchange/TKXSBase/XSAlgo/XSAlgo.cxx b/src/DataExchange/TKXSBase/XSAlgo/XSAlgo.cxx index 002d477bb6..fd7ccb65c4 100644 --- a/src/DataExchange/TKXSBase/XSAlgo/XSAlgo.cxx +++ b/src/DataExchange/TKXSBase/XSAlgo/XSAlgo.cxx @@ -28,7 +28,9 @@ void XSAlgo::Init() { static bool init = false; if (init) + { return; + } init = true; ShapeAlgo::Init(); theContainer = new XSAlgo_AlgoContainer; diff --git a/src/DataExchange/TKXSBase/XSAlgo/XSAlgo_AlgoContainer.cxx b/src/DataExchange/TKXSBase/XSAlgo/XSAlgo_AlgoContainer.cxx index a44899525e..b67558e858 100644 --- a/src/DataExchange/TKXSBase/XSAlgo/XSAlgo_AlgoContainer.cxx +++ b/src/DataExchange/TKXSBase/XSAlgo/XSAlgo_AlgoContainer.cxx @@ -77,7 +77,9 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& const char* aSeq = Interface_Static::CVal(thePseq); if (!aSeq) + { aSeq = thePseq; + } // if resource file is not loaded or does not define .exec.op, // do default fixes @@ -127,7 +129,9 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& aRsc->SetResource("Runtime.MaxTolerance", theMaxTol); if (!ShapeProcess::Perform(aContext, aSeq, theProgress)) + { return theShape; // return original shape + } return aContext->Result(); } @@ -150,13 +154,17 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const occ::handle context = occ::down_cast(info); if (context.IsNull()) + { return; + } const NCollection_DataMap& map = context->Map(); occ::handle msg = context->Messages(); if (map.Extent() <= 0 && (msg.IsNull() || msg->MapShape().Extent() <= 0)) + { return; + } int i = (startTPitem > 0 ? startTPitem : 1); for (; i <= TP->NbMapped(); i++) @@ -164,7 +172,9 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const occ::handle bnd = TP->MapItem(i); occ::handle sb = occ::down_cast(bnd); if (sb.IsNull() || sb->Result().IsNull()) + { continue; + } TopoDS_Shape orig = sb->Result(); @@ -177,7 +187,9 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const occ::handleSetResult(map.Find(atmpSh)); + } } else { @@ -232,7 +244,9 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const occ::handle context = occ::down_cast(info); if (context.IsNull()) + { return; + } const NCollection_DataMap& map = context->Map(); @@ -261,16 +275,22 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const occ::handle subMapper = TransferBRep::ShapeMapper(FP, it.Value()); if (subMapper.IsNull()) + { continue; + } occ::handle tr = FP->FindTransient(subMapper); if (tr.IsNull()) + { continue; + } TransientListBinder->AddResult(tr); sub = it.Value(); } if (TransientListBinder->NbTransients() == 1) + { resBinder = new TransferBRep_ShapeBinder(sub); + } else if (TransientListBinder->NbTransients() > 1) { resBinder->AddResult(TransientListBinder); diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl.cxx index a8471a4bce..6aaa225589 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl.cxx @@ -28,6 +28,8 @@ occ::handle XSControl::Vars(const occ::handle avars; occ::handle WS = XSControl::Session(pilot); if (!WS.IsNull()) + { avars = WS->Vars(); + } return avars; } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_ConnectedShapes.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_ConnectedShapes.cxx index 288002b3bf..16852e27c8 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_ConnectedShapes.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_ConnectedShapes.cxx @@ -51,12 +51,18 @@ bool XSControl_ConnectedShapes::Explore(const int /*level*/, { occ::handle TP; if (!theTR.IsNull()) + { TP = theTR->TransientProcess(); + } if (TP.IsNull()) + { return false; + } TopoDS_Shape Shape = TransferBRep::ShapeResult(TP, ent); if (Shape.IsNull()) + { return false; + } occ::handle>> li = AdjacentEntities(Shape, TP, TopAbs_FACE); explored.AddList(li); @@ -90,9 +96,13 @@ occ::handle>> XSControl_Co occ::handle bnd = TP->MapItem(i); TopoDS_Shape sh = TransferBRep::ShapeResult(bnd); if (sh.IsNull()) + { continue; + } if (sh.ShapeType() != type) + { continue; + } for (TopExp_Explorer vsh(sh, TopAbs_VERTEX); vsh.More(); vsh.Next()) { const TopoDS_Shape& avtx = vsh.Current(); diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Controller.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Controller.cxx index 58d56854fb..fa18006e1b 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Controller.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Controller.cxx @@ -79,7 +79,9 @@ void XSControl_Controller::TraceStatic(const char* const theName, const int theU { occ::handle val = Interface_Static::Static(theName); if (val.IsNull()) + { return; + } myParams.Append(val); myParamUses.Append(theUse); } @@ -109,9 +111,13 @@ void XSControl_Controller::Record(const char* const theName) const occ::handle thisadapt(this); occ::handle newadapt = listad.ChangeFind(theName); if (newadapt->IsKind(thisadapt->DynamicType())) + { return; + } if (!(thisadapt->IsKind(newadapt->DynamicType())) && thisadapt != newadapt) + { throw Standard_DomainError("XSControl_Controller : Record"); + } } listad.Bind(theName, this); } @@ -163,9 +169,13 @@ void XSControl_Controller::SetModeWrite(const int modemin, const int modemax, co void XSControl_Controller::SetModeWriteHelp(const int modetrans, const char* const help, const bool) { if (myModeWriteShapeN.IsNull()) + { return; + } if (modetrans < myModeWriteShapeN->Lower() || modetrans > myModeWriteShapeN->Upper()) + { return; + } occ::handle hl = new TCollection_HAsciiString(help); myModeWriteShapeN->SetValue(modetrans, hl); } @@ -176,7 +186,9 @@ bool XSControl_Controller::ModeWriteBounds(int& modemin, int& modemax, const boo { modemin = modemax = 0; if (myModeWriteShapeN.IsNull()) + { return false; + } modemin = myModeWriteShapeN->Lower(); modemax = myModeWriteShapeN->Upper(); return true; @@ -187,11 +199,17 @@ bool XSControl_Controller::ModeWriteBounds(int& modemin, int& modemax, const boo bool XSControl_Controller::IsModeWrite(const int modetrans, const bool) const { if (myModeWriteShapeN.IsNull()) + { return true; + } if (modetrans < myModeWriteShapeN->Lower()) + { return false; + } if (modetrans > myModeWriteShapeN->Upper()) + { return false; + } return true; } @@ -200,14 +218,22 @@ bool XSControl_Controller::IsModeWrite(const int modetrans, const bool) const const char* XSControl_Controller::ModeWriteHelp(const int modetrans, const bool) const { if (myModeWriteShapeN.IsNull()) + { return ""; + } if (modetrans < myModeWriteShapeN->Lower()) + { return ""; + } if (modetrans > myModeWriteShapeN->Upper()) + { return ""; + } occ::handle str = myModeWriteShapeN->Value(modetrans); if (str.IsNull()) + { return ""; + } return str->ToCString(); } @@ -221,7 +247,9 @@ bool XSControl_Controller::RecognizeWriteTransient(const occ::handleModeTrans() = modetrans; return myAdaptorWrite->Recognize(new Transfer_TransientMapper(obj)); } @@ -237,9 +265,13 @@ static IFSelect_ReturnStatus TransferFinder( const Message_ProgressRange& theProgress) { if (theActor.IsNull()) + { return IFSelect_RetError; + } if (theModel.IsNull()) + { return IFSelect_RetError; + } theActor->ModeTrans() = theModeTrans; theFP->SetModel(theModel); theFP->SetActor(theActor); @@ -275,7 +307,9 @@ IFSelect_ReturnStatus XSControl_Controller::TransferWriteTransient( const Message_ProgressRange& theProgress) const { if (theObj.IsNull()) + { return IFSelect_RetVoid; + } return TransferFinder(myAdaptorWrite, new Transfer_TransientMapper(theObj), theFP, @@ -289,7 +323,9 @@ IFSelect_ReturnStatus XSControl_Controller::TransferWriteTransient( bool XSControl_Controller::RecognizeWriteShape(const TopoDS_Shape& shape, const int modetrans) const { if (myAdaptorWrite.IsNull()) + { return false; + } myAdaptorWrite->ModeTrans() = modetrans; return myAdaptorWrite->Recognize(new TransferBRep_ShapeMapper(shape)); } @@ -304,7 +340,9 @@ IFSelect_ReturnStatus XSControl_Controller::TransferWriteShape( const Message_ProgressRange& theProgress) const { if (shape.IsNull()) + { return IFSelect_RetVoid; + } IFSelect_ReturnStatus theReturnStat = TransferFinder(myAdaptorWrite, new TransferBRep_ShapeMapper(shape), @@ -327,10 +365,14 @@ void XSControl_Controller::AddSessionItem(const occ::handle& const bool toApply) { if (theItem.IsNull() || theName[0] == '\0') + { return; + } myAdaptorSession.Bind(theName, theItem); if (toApply && theItem->IsKind(STANDARD_TYPE(IFSelect_GeneralModifier))) + { myAdaptorApplied.Append(theItem); + } } //================================================================================================= @@ -339,7 +381,9 @@ occ::handle XSControl_Controller::SessionItem(const char* co { occ::handle item; if (!myAdaptorSession.IsEmpty()) + { item = myAdaptorSession.Find(theName); + } return item; } @@ -355,7 +399,9 @@ void XSControl_Controller::Customise(occ::handle& WS) NCollection_DataMap>::Iterator iter( myAdaptorSession); for (; iter.More(); iter.Next()) + { WS->AddNamedItem(iter.Key().ToCString(), iter.ChangeValue()); + } } if (WS->NamedItem("xst-model-all").IsNull()) diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_FuncShape.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_FuncShape.cxx index 036bc2e7be..a580cc2e46 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_FuncShape.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_FuncShape.cxx @@ -64,42 +64,54 @@ static IFSelect_ReturnStatus XSControl_tpdraw(const occ::handle max) { - sout << " - Num=" << num << " hors limite (de 1 a " << max << ")" << std::endl; + sout << " - Num=" << num << " hors limite (de 1 a " << max << ")" << '\n'; return IFSelect_RetError; } else { n1 = n2 = num; nbvar = -1; // nbvar : 1st simple shape = no n0 - sout << ", n0 " << num << std::endl; + sout << ", n0 " << num << '\n'; } for (i = n1; i <= n2; i++) @@ -164,35 +176,51 @@ static IFSelect_ReturnStatus XSControl_tpdraw(const occ::handleMapped(i); if (model.IsNull()) + { num = 0; + } else + { num = model->Number(ent); + } index = i; } else if (mode == 2) { ent = TP->Root(i); if (model.IsNull()) + { num = 0; + } else + { num = model->Number(ent); + } index = TP->MapIndex(ent); } if (index > 0) + { binder = TP->MapItem(index); + } if (binder.IsNull()) + { index = 0; + } if (index == 0) { if (!tout) - sout << "Entite n0 " << num << " : non repertoriee" << std::endl; + { + sout << "Entite n0 " << num << " : non repertoriee" << '\n'; + } continue; } if (!binder->HasResult()) { if (!tout) - sout << "Entity n0 " << num << " : no result" << std::endl; + { + sout << "Entity n0 " << num << " : no result" << '\n'; + } continue; } sh = TransferBRep::ShapeResult(binder); @@ -203,35 +231,53 @@ static IFSelect_ReturnStatus XSControl_tpdraw(const occ::handle 3 && mode > 0) + { Sprintf(nomvar, "%s", arg3); + } else if (argc > 2 && mode == 0) + { Sprintf(nomvar, "%s", arg2); + } else + { Sprintf(nomvar, "tp_%d", i); + } } else { if (argc > 3 && mode > 0) + { Sprintf(nomvar, "%s_%d", arg3, nbvar); + } else if (argc > 2 && mode == 0) + { Sprintf(nomvar, "%s_%d", arg2, nbvar); + } else + { Sprintf(nomvar, "tp_%d", i); + } } - sout << " -> 1 DRAW Shape: " << nomvar << std::endl; + sout << " -> 1 DRAW Shape: " << nomvar << '\n'; XSControl::Vars(pilot)->SetShape(nomvar, sh); continue; } @@ -240,34 +286,48 @@ static IFSelect_ReturnStatus XSControl_tpdraw(const occ::handleNbShapes(); if (tout) + { sout << "[ " << i << " ]:"; + } if (num == 0) + { sout << " pas dans le modele"; + } else + { sout << " ent.n0 " << num; + } sout << ", item transfert n0 " << index; sout << " -> " << nbs << " DRAW Shapes :"; for (int j = 1; j <= nbs; j++) { sh = slb->Shape(j); if (nbvar < 0) + { nbvar = 0; + } nbvar++; if (sh.IsNull()) { - sout << " (no Shape recorded)" << std::endl; + sout << " (no Shape recorded)" << '\n'; continue; } if (argc > 3 && mode > 0) + { Sprintf(nomvar, "%s_%d", arg3, nbvar); + } else if (argc > 2 && mode == 0) + { Sprintf(nomvar, "%s_%d", arg2, nbvar); + } else + { Sprintf(nomvar, "tp_%d_%d", i, nbvar); + } sout << " " << nomvar; XSControl::Vars(pilot)->SetShape(nomvar, sh); } - sout << std::endl; + sout << '\n'; continue; } DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, binder); @@ -276,49 +336,67 @@ static IFSelect_ReturnStatus XSControl_tpdraw(const occ::handle resu = trb->Result(); if (resu.IsNull()) { - sout << "Entity n0 " << num << " : no result" << std::endl; + sout << "Entity n0 " << num << " : no result" << '\n'; continue; } DeclareAndCast(Geom_Geometry, geom, resu); sout << "Entite n0 " << num << " : resultat " << resu->DynamicType()->Name(); if (geom.IsNull()) { - sout << std::endl; + sout << '\n'; continue; } nbvar++; if (nbvar == 0) { if (argc > 3 && mode > 0) + { Sprintf(nomvar, "%s", arg3); + } else if (argc > 2 && mode == 0) + { Sprintf(nomvar, "%s", arg2); + } else + { Sprintf(nomvar, "tp_%d", i); + } } else { if (argc > 3 && mode > 0) + { Sprintf(nomvar, "%s_%d", arg3, nbvar); + } else if (argc > 2 && mode == 0) + { Sprintf(nomvar, "%s_%d", arg2, nbvar); + } else + { Sprintf(nomvar, "tp_%d", i); + } } char* nomv = nomvar; XSControl::Vars(pilot)->Set(nomv, geom); - sout << " -> DRAW Geom : " << nomvar << std::endl; + sout << " -> DRAW Geom : " << nomvar << '\n'; continue; } if (sh.IsNull() && trb.IsNull()) + { if (!tout) + { sout << "Entite n0 " << num << " : resultat pas une Shape mais " << binder->ResultTypeName() - << std::endl; + << '\n'; + } + } } if (sh.IsNull()) - sout << " (No Shape)" << std::endl; + { + sout << " (No Shape)" << '\n'; + } return IFSelect_RetDone; } @@ -333,25 +411,27 @@ static IFSelect_ReturnStatus XSControl_tpcompound(const occ::handle> list; if (argc == 2) + { list = TransferBRep::Shapes(TP); + } else { occ::handle>> lise = IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(2)); if (lise.IsNull()) { - sout << "Not a valid entity list : " << pilot->CommandPart(2) << std::endl; + sout << "Not a valid entity list : " << pilot->CommandPart(2) << '\n'; return IFSelect_RetError; } list = TransferBRep::Shapes(TP, lise); @@ -359,16 +439,18 @@ static IFSelect_ReturnStatus XSControl_tpcompound(const occ::handleLength(); - sout << nb << " Shape(s) listed" << std::endl; + sout << nb << " Shape(s) listed" << '\n'; TopoDS_Compound C; BRep_Builder B; B.MakeCompound(C); for (int i = 1; i <= nb; i++) + { B.Add(C, list->Value(i)); + } XSControl::Vars(pilot)->SetShape(arg1, C); return IFSelect_RetDone; } @@ -391,23 +473,29 @@ static IFSelect_ReturnStatus XSControl_traccess(const occ::handle& mdl = TR->Model(); if (mdl.IsNull()) { - sout << " modele absent" << std::endl; + sout << " modele absent" << '\n'; return IFSelect_RetError; } int num = (argc > 1 ? IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot), arg1) : 0); if (argc > 1) + { nomsh = arg1; + } else + { nomsh = cascomp ? "TREAD_COMP" : "TREAD_LIST"; + } if (cassave) - sout << " save shapes -> current directory" << std::endl; + { + sout << " save shapes -> current directory" << '\n'; + } if (num == 0 || cascomp) { @@ -416,56 +504,86 @@ static IFSelect_ReturnStatus XSControl_traccess(const occ::handle>& list = TR->ShapeResultList(true); - sout << " TOUS RESULTATS par ShapeResultList, soit " << list->Length() << std::endl; + sout << " TOUS RESULTATS par ShapeResultList, soit " << list->Length() << '\n'; for (int i = 1, nb = list->Length(); i <= nb; ++i) { noms = nomsh + "_" + i; if ((i % 1000) == 0) - sout << "(" << i << ")" << std::endl; + { + sout << "(" << i << ")" << '\n'; + } else if ((i % 100) == 0) + { sout << "*"; + } else if ((i % 10) == 0) + { sout << "0"; + } else + { sout << "."; + } if (list->Value(i).IsNull()) + { continue; + } if (!cascomp && !cassave) + { XSControl::Vars(pilot)->SetShape(noms.ToCString(), list->Value(i)); + } else if (!cascomp && cassave) + { BRepTools::Write(list->Value(i), noms.ToCString()); + } else if (cascomp) + { B.Add(C, list->Value(i)); + } } - sout << std::endl; + sout << '\n'; if (cascomp && !cassave) + { XSControl::Vars(pilot)->SetShape(nomsh.ToCString(), C); + } else if (cascomp && cassave) + { BRepTools::Write(C, nomsh.ToCString()); + } } else { if (num < 1 || num > mdl->NbEntities()) { - sout << " incorrect:" << arg1 << std::endl; + sout << " incorrect:" << arg1 << '\n'; return IFSelect_RetError; } TopoDS_Shape sh = TR->ShapeResult(mdl->Value(num)); if (sh.IsNull()) { - sout << " No result for " << arg1 << std::endl; + sout << " No result for " << arg1 << '\n'; return IFSelect_RetError; } if (argc > 2) + { nomsh = arg2; + } else + { nomsh = TCollection_AsciiString("TREAD_") + num; + } if (!cascomp && !cassave) + { XSControl::Vars(pilot)->SetShape(nomsh.ToCString(), sh); + } else if (!cascomp && cassave) + { BRepTools::Write(sh, nomsh.ToCString()); + } else - sout << "Option non comprise" << std::endl; + { + sout << "Option non comprise" << '\n'; + } } return IFSelect_RetDone; } @@ -476,7 +594,9 @@ static IFSelect_ReturnStatus XSControl_traccess(const occ::handle 0) { TopoDS_Shape varShape; @@ -486,7 +606,9 @@ static bool XSControl_IsEqualSubShape(const TopoDS_Shape& Shape, TopoDS_Shape& s { varShape = it.Value(); if (XSControl_IsEqualSubShape(Shape, varShape, aLevel)) + { return true; + } } } return false; @@ -502,20 +624,22 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handleGetShape(a1); if (Shape.IsNull()) { - sout << "Not a DRAW Shape:" << arg1 << std::endl; + sout << "Not a DRAW Shape:" << arg1 << '\n'; return IFSelect_RetError; } bool yena = false; int aLevel = 1; if (argc >= 3) + { aLevel = atoi(pilot->Arg(2)); + } bool silent = false; if (aLevel < 0) { @@ -532,7 +656,9 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handle ent = TR->EntityFromShapeResult(Shape, modrec); if (ent.IsNull()) @@ -547,8 +673,10 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handleNbMapped(); if (!silent) + { sout << "searching in map among " << nb << " ..."; + } for (i = 1; i <= nb; i++) { ent = TP->Mapped(i); @@ -568,11 +698,15 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handleModel()->Print(ent, sout); if (silent) - sout << " in file " << XSControl::Session(pilot)->LoadedFile() << std::endl; + { + sout << " in file " << XSControl::Session(pilot)->LoadedFile() << '\n'; + } } if (!silent) - sout << std::endl; + { + sout << '\n'; + } } // ET EN EXPORT ? @@ -637,14 +781,18 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handle fnd = TransferBRep::ShapeMapper(FP, Shape); occ::handle ent; if (!fnd.IsNull()) + { ent = FP->FindTransient(fnd); + } if (!ent.IsNull()) { sout << "Shape " << arg1 << ": exported to entity "; XSControl::Session(pilot)->Model()->Print(ent, sout); if (silent) + { sout << " in file " << XSControl::Session(pilot)->LoadedFile(); - sout << std::endl; + } + sout << '\n'; } // abv 31.08.00: treat case of split shape (several results) // it is supposed that results are of the same type and lie in one-level comp @@ -660,18 +808,24 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handleNbTransients(); if (nb > 0) + { sout << "Shape " << arg1 << ": exported to entities "; + } for (; i <= nb; i++) { XSControl::Session(pilot)->Model()->Print(TransientListBinder->Transient(i), sout); if (i < nb) + { sout << ", "; + } } if (nb > 0) { if (silent) + { sout << " in file " << XSControl::Session(pilot)->LoadedFile(); - sout << std::endl; + } + sout << '\n'; } } /* else { @@ -696,7 +850,9 @@ static IFSelect_ReturnStatus XSControl_fromshape(const occ::handle& TR = XSControl::Session(pilot)->TransferReader(); occ::handle TP; if (!TR.IsNull()) + { TP = TR->TransientProcess(); + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (TP.IsNull()) { - sout << "no transfer map" << std::endl; + sout << "no transfer map" << '\n'; return IFSelect_RetVoid; } if (argc < 2) { - sout << "Give name of a DRAW Shape + optional shape type v-e-w-f(D)-s" << std::endl; + sout << "Give name of a DRAW Shape + optional shape type v-e-w-f(D)-s" << '\n'; return IFSelect_RetError; } const char* a1 = (const char*)arg1; TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(a1); if (Shape.IsNull()) { - sout << "Not a DRAW Shape:" << arg1 << std::endl; + sout << "Not a DRAW Shape:" << arg1 << '\n'; return IFSelect_RetError; } sout << "Shape " << arg1 << " : "; @@ -736,16 +894,18 @@ static IFSelect_ReturnStatus XSControl_trconnexentities( occ::handle>> list = XSControl_ConnectedShapes::AdjacentEntities(Shape, TP, TopAbs_FACE); int i, nb = list->Length(); - sout << nb << " Entities produced Connected Shapes :" << std::endl; + sout << nb << " Entities produced Connected Shapes :" << '\n'; const occ::handle& model = XSControl::Session(pilot)->Model(); sout << "("; for (i = 1; i <= nb; i++) { if (i > 1) + { sout << ","; + } sout << model->Number(list->Value(i)); } - sout << ")" << std::endl; + sout << ")" << '\n'; return IFSelect_RetDone; } @@ -763,7 +923,7 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleArg(1); @@ -775,10 +935,14 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleCommandPart(3); @@ -792,13 +956,13 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleExecute(comload); if (status != IFSelect_RetDone) { - sout << "Abandon import" << std::endl; + sout << "Abandon import" << '\n'; return status; } } else { - sout << "Currently Loaded Model" << std::endl; + sout << "Currently Loaded Model" << '\n'; } // Selecting Entities @@ -816,11 +980,11 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleLength(); - sout << "Nb entities selected : " << nbl << std::endl; + sout << "Nb entities selected : " << nbl << '\n'; // Starting Transfer @@ -828,7 +992,7 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handle& TR = WS->TransferReader(); if (TR.IsNull()) { - sout << " init not done or failed" << std::endl; + sout << " init not done or failed" << '\n'; return IFSelect_RetError; } @@ -836,7 +1000,7 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleTransferList(list); - sout << "Nb Entities Selected : " << nbl << " have given " << nbt << " results" << std::endl; + sout << "Nb Entities Selected : " << nbl << " have given " << nbt << " results" << '\n'; // Filling VARS. one compound (trimpcomp) or one shape per ent (trimport) bool iscomp = (pilot->Arg(0)[5] == 'c'); @@ -848,7 +1012,7 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handle mdl = TR->Model(); if (mdl.IsNull()) { - sout << " modele absent" << std::endl; + sout << " modele absent" << '\n'; return IFSelect_RetError; } for (int il = 1; il <= nbl; il++) @@ -856,10 +1020,14 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handle ent = list->Value(il); sh = TR->ShapeResult(ent); if (sh.IsNull()) + { continue; + } nbs++; if (iscomp) + { B.Add(C, sh); + } else { char nomsh[50]; @@ -868,21 +1036,23 @@ static IFSelect_ReturnStatus XSControl_trimport(const occ::handleSetShape(rnom.ToCString(), sh); } else if (iscomp) { - sout << "One compound made of " << nbs << " Shapes, named " << rnom.ToCString() << std::endl; + sout << "One compound made of " << nbs << " Shapes, named " << rnom.ToCString() << '\n'; XSControl::Vars(pilot)->SetShape(rnom.ToCString(), C); } else { // several individual shapes sout << nbs << " Shapes, named " << rnom.ToCString() << "_1 to " << rnom.ToCString() << "_" - << nbs << std::endl; + << nbs << '\n'; } return IFSelect_RetDone; @@ -899,10 +1069,10 @@ static IFSelect_ReturnStatus XSControl_twrite(const occ::handle TW = XSControl::Session(pilot)->TransferWriter(); if (argc < 2) { - sout << " give draw shape name" << std::endl; + sout << " give draw shape name" << '\n'; return IFSelect_RetError; } - sout << "Attention, on alimente le modele courant ..." << std::endl; + sout << "Attention, on alimente le modele courant ..." << '\n'; // Shape for (int i = 1; i < argc; i++) @@ -911,12 +1081,12 @@ static IFSelect_ReturnStatus XSControl_twrite(const occ::handleGetShape(ai); if (Shape.IsNull()) { - sout << "not a draw shape name:" << arg1 << std::endl; + sout << "not a draw shape name:" << arg1 << '\n'; continue; } sout << "Pour Shape : " << ai; int stat = TW->TransferWriteShape(XSControl::Session(pilot)->Model(), Shape); - sout << " Transfer Write Status = " << stat << std::endl; + sout << " Transfer Write Status = " << stat << '\n'; } pilot->Session()->ComputeGraph(); // Transient ? (Geom) : ignore @@ -1014,20 +1184,24 @@ int XSControl_FuncShape::MoreShapes(const occ::handle& // name = nom(n1-n2) with n1,n2 integers : the variables of name nomn1 to nomn2 Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (list.IsNull()) + { list = new NCollection_HSequence(); + } if (name[0] == '*' && (name[1] == '\0' || (name[1] == '*' && name[2] == '\0'))) { const occ::handle& TP = session->TransferReader()->TransientProcess(); if (TP.IsNull()) { - sout << "last transfer : unknown" << std::endl; + sout << "last transfer : unknown" << '\n'; return 0; } occ::handle> li = TransferBRep::Shapes(TP, (name[1] == '\0')); if (li.IsNull()) + { return 0; + } list->Append(li); return li->Length(); } @@ -1035,18 +1209,26 @@ int XSControl_FuncShape::MoreShapes(const occ::handle& for (i = 0; name[i] != '\0'; i++) { if (name[i] == '(') + { paro = i; + } if (name[i] == '-') + { moins = i; + } if (name[i] == ')') + { parf = i; + } } if (paro && moins && parf) { n2 = atoi(&name[moins + 1]); n1 = atoi(&name[paro + 1]); if (n1 < 0) + { n1 += n2; // otherwise we have n1-n2 + } } // liste if (n1 <= n2 && n1 > 0) @@ -1065,18 +1247,20 @@ int XSControl_FuncShape::MoreShapes(const occ::handle& Sprintf(nomsh, "%s%d", nom, i); TopoDS_Shape Shape = session->Vars()->GetShape(nomshh); if (Shape.IsNull()) + { continue; + } list->Append(Shape); nbsh++; } - sout << " -> taken " << nbsh << " Shapes" << std::endl; + sout << " -> taken " << nbsh << " Shapes" << '\n'; return nbsh; } const char* a1 = (const char*)name; TopoDS_Shape Shape = session->Vars()->GetShape(a1); if (Shape.IsNull()) { - sout << "not a shape draw:" << a1 << std::endl; + sout << "not a shape draw:" << a1 << '\n'; return 0; } list->Append(Shape); @@ -1096,28 +1280,46 @@ bool XSControl_FuncShape::FileAndVar(const occ::handle& s resfile.Clear(); resvar.Clear(); if (file) + { if (file[0] == '\0' || (file[0] == '.' && file[1] == '\0')) + { iafic = false; + } + } if (!iafic) + { resfile.AssignCat(session->LoadedFile()); + } else + { resfile.AssignCat(file); + } if (var && var[0] != '\0' && (var[0] != '.' || var[1] != '\0')) + { resvar.AssignCat(var); + } else if (resfile.Length() == 0) + { resvar.AssignCat(def); + } else { int nomdeb, nomfin; nomdeb = resfile.SearchFromEnd("/"); if (nomdeb <= 0) + { nomdeb = resfile.SearchFromEnd("\\"); // for NT + } if (nomdeb < 0) + { nomdeb = 0; + } nomfin = resfile.SearchFromEnd("."); if (nomfin < nomdeb) + { nomfin = resfile.Length() + 1; + } resvar = resfile.SubString(nomdeb + 1, nomfin - 1); } return iafic; diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Functions.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Functions.cxx index 7fd547bf36..427e15d4e6 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Functions.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Functions.cxx @@ -46,9 +46,11 @@ static IFSelect_ReturnStatus XSControl_xinit(const occ::handleArg(1); // **** xinit **** if (argc > 1) + { return (XSControl::Session(pilot)->SelectNorm(arg1) ? IFSelect_RetDone : IFSelect_RetFail); + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "Selected Norm:" << XSControl::Session(pilot)->SelectedNorm() << std::endl; + sout << "Selected Norm:" << XSControl::Session(pilot)->SelectedNorm() << '\n'; return IFSelect_RetVoid; } @@ -64,26 +66,36 @@ static IFSelect_ReturnStatus XSControl_xnorm(const occ::handle control = WS->NormAdaptor(); Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (argc == 1) - sout << "Current Norm. xnorm newnorm to change" << std::endl; + { + sout << "Current Norm. xnorm newnorm to change" << '\n'; + } else - sout << "Current Norm :" << std::endl; + { + sout << "Current Norm :" << '\n'; + } if (control.IsNull()) - sout << "no norm currently defined" << std::endl; + { + sout << "no norm currently defined" << '\n'; + } else - sout << " Long Name (complete) : " << control->Name(false) << std::endl - << " Short name (resource) : " << control->Name(true) << std::endl; + { + sout << " Long Name (complete) : " << control->Name(false) << '\n' + << " Short name (resource) : " << control->Name(true) << '\n'; + } if (argc == 1) + { return IFSelect_RetVoid; + } control = XSControl_Controller::Recorded(arg1); if (control.IsNull()) { - sout << " No norm named : " << arg1 << std::endl; + sout << " No norm named : " << arg1 << '\n'; return IFSelect_RetError; } WS->SetController(control); - sout << "new norm : " << control->Name() << std::endl; + sout << "new norm : " << control->Name() << '\n'; return IFSelect_RetDone; } @@ -94,9 +106,11 @@ static IFSelect_ReturnStatus XSControl_newmodel(const occ::handleNewModel().IsNull()) + { return IFSelect_RetDone; + } Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "No new Model produced" << std::endl; + sout << "No new Model produced" << '\n'; return IFSelect_RetDone; } @@ -115,16 +129,24 @@ static IFSelect_ReturnStatus XSControl_tpclear(const occ::handleClear(); + } else - sout << "No Transfer Write" << std::endl; + { + sout << "No Transfer Write" << '\n'; + } } else { if (!TP.IsNull()) + { TP->Clear(); + } else - sout << "No Transfer Read" << std::endl; + { + sout << "No Transfer Read" << '\n'; + } } return IFSelect_RetDone; } @@ -142,7 +164,7 @@ static IFSelect_ReturnStatus XSControl_tpstat(const occ::handle 2) + { mod1 = 2; + } a2 = arg1[0]; break; } if (mod1 < 1 || mod1 > 3) + { a2 = '!'; + } switch (a2) { case 'n': @@ -232,7 +260,9 @@ static IFSelect_ReturnStatus XSControl_tpstat(const occ::handleModel() != pilot->Session()->Model()) + { sout << "Model differs from the session"; + } occ::handle>> list = IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(2)); XSControl_TransferReader::PrintStatsOnList(TP, list, mod1, mod2); // TP->PrintStats (1,sout); } else - sout << "TransferRead : not defined" << std::endl; + { + sout << "TransferRead : not defined" << '\n'; + } return IFSelect_RetVoid; } @@ -280,30 +316,36 @@ static IFSelect_ReturnStatus XSControl_tpent(const occ::handle model = TP->Model(); if (model.IsNull()) + { return IFSelect_RetFail; + } if (argc < 2) { - sout << "Give ENTITY NUMBER (IN MODEL TransferProcess)" << std::endl; + sout << "Give ENTITY NUMBER (IN MODEL TransferProcess)" << '\n'; return IFSelect_RetError; } int num = atoi(arg1); if (num <= 0 || num > model->NbEntities()) { - sout << "Number not in [1 - " << model->NbEntities() << "]" << std::endl; + sout << "Number not in [1 - " << model->NbEntities() << "]" << '\n'; return IFSelect_RetError; } occ::handle ent = model->Value(num); int index = TP->MapIndex(ent); if (index == 0) - sout << "Entity " << num << " not recorded in transfer" << std::endl; + { + sout << "Entity " << num << " not recorded in transfer" << '\n'; + } else + { XSControl::Session(pilot)->PrintTransferStatus(index, false, sout); + } return IFSelect_RetVoid; } @@ -318,21 +360,25 @@ static IFSelect_ReturnStatus XSControl_tpitem(const occ::handleWord(0).Value(3) == 'r') + { num = -num; + } bool modew = false; if (pilot->Word(0).Value(2) == 'w') + { modew = true; + } occ::handle binder; occ::handle finder; occ::handle ent; if (!XSControl::Session(pilot)->PrintTransferStatus(num, modew, sout)) { - sout << " - Num=" << num << " incorrect" << std::endl; + sout << " - Num=" << num << " incorrect" << '\n'; } return IFSelect_RetVoid; } @@ -355,33 +401,45 @@ static IFSelect_ReturnStatus XSControl_trecord(const occ::handleNbRoots(); - sout << " Recording " << nb << " Roots" << std::endl; + sout << " Recording " << nb << " Roots" << '\n'; for (int i = 1; i <= nb; i++) { ent = TP->Root(i); if (TR->RecordResult(ent)) - sout << " Root n0." << i << std::endl; + { + sout << " Root n0." << i << '\n'; + } else - sout << " Root n0." << i << " not recorded" << std::endl; + { + sout << " Root n0." << i << " not recorded" << '\n'; + } } } else { if (num < 1 || num > mdl->NbEntities()) - sout << "incorrect number:" << num << std::endl; + { + sout << "incorrect number:" << num << '\n'; + } else if (TR->RecordResult(mdl->Value(num))) - sout << " Entity n0." << num << std::endl; + { + sout << " Entity n0." << num << '\n'; + } else - sout << " Entity n0." << num << " not recorded" << std::endl; + { + sout << " Entity n0." << num << " not recorded" << '\n'; + } } return IFSelect_RetDone; } @@ -398,16 +456,16 @@ static IFSelect_ReturnStatus XSControl_trstat(const occ::handle& TR = XSControl::Session(pilot)->TransferReader(); if (TR.IsNull()) { - sout << " init not done" << std::endl; + sout << " init not done" << '\n'; return IFSelect_RetError; } occ::handle mdl = TR->Model(); if (mdl.IsNull()) { - sout << " No model" << std::endl; + sout << " No model" << '\n'; return IFSelect_RetError; } - sout << " Statistics : FileName : " << TR->FileName() << std::endl; + sout << " Statistics : FileName : " << TR->FileName() << '\n'; if (argc == 1) { // stats generales @@ -419,29 +477,31 @@ static IFSelect_ReturnStatus XSControl_trstat(const occ::handle mdl->NbEntities()) { - sout << " incorrect number:" << arg1 << std::endl; + sout << " incorrect number:" << arg1 << '\n'; return IFSelect_RetError; } occ::handle ent = mdl->Value(num); if (!TR->IsRecorded(ent)) { - sout << " Entity " << num << " not recorded" << std::endl; + sout << " Entity " << num << " not recorded" << '\n'; return IFSelect_RetError; } occ::handle RM = TR->FinalResult(ent); occ::handle>> list = TR->CheckedList(ent); int i, nb = list->Length(); if (nb > 0) + { sout << " Entities implied by Check/Result :" << nb << " i.e.:"; + } for (i = 1; i <= nb; i++) { sout << " "; mdl->Print(list->Value(i), sout); } - sout << std::endl; + sout << '\n'; if (RM.IsNull()) { - sout << " no other info" << std::endl; + sout << " no other info" << '\n'; return IFSelect_RetVoid; } Interface_CheckIterator chl = RM->CheckList(false); @@ -461,7 +521,9 @@ static IFSelect_ReturnStatus XSControl_trbegin(const occ::handleNbWords() > 1) { if (pilot->Arg(1)[0] == 'i') + { init = true; + } } if (init) { @@ -470,7 +532,7 @@ static IFSelect_ReturnStatus XSControl_trbegin(const occ::handle& TR = XSControl::Session(pilot)->TransferReader(); if (TR.IsNull()) { - sout << " init not done" << std::endl; + sout << " init not done" << '\n'; return IFSelect_RetError; } const occ::handle& mdl = TR->Model(); if (mdl.IsNull()) { - sout << " No model" << std::endl; + sout << " No model" << '\n'; return IFSelect_RetError; } if (argc < 2) @@ -505,20 +567,20 @@ static IFSelect_ReturnStatus XSControl_tread(const occ::handle sel = pilot->Session()->NamedItem("xst-model-roots"); if (sel.IsNull()) { - sout << "Select Roots absent" << std::endl; + sout << "Select Roots absent" << '\n'; return IFSelect_RetError; } occ::handle>> list = pilot->Session()->GiveList(sel); - sout << " Transferring all roots i.e. : " << TR->TransferList(list) << std::endl; + sout << " Transferring all roots i.e. : " << TR->TransferList(list) << '\n'; } else { occ::handle>> list = IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(1)); - sout << " Transfer of " << list->Length() << " entities" << std::endl; + sout << " Transfer of " << list->Length() << " entities" << '\n'; int nb = TR->TransferList(list); - sout << " Gives " << nb << " results" << std::endl; + sout << " Gives " << nb << " results" << '\n'; } return IFSelect_RetDone; } @@ -532,9 +594,13 @@ static IFSelect_ReturnStatus XSControl_trtp(const occ::handle& TR = XSControl::Session(pilot)->TransferReader(); Message_Messenger::StreamBuffer sout = Message::SendInfo(); if (TR.IsNull()) - sout << " No TransferReader" << std::endl; + { + sout << " No TransferReader" << '\n'; + } else if (TR->TransientProcess().IsNull()) - sout << " Transfer Reader without Process" << std::endl; + { + sout << " Transfer Reader without Process" << '\n'; + } return IFSelect_RetVoid; } @@ -562,20 +628,24 @@ static IFSelect_ReturnStatus XSControl_twmode(const occ::handleModeWriteBounds(modemin, modemax)) { - sout << "Write Mode : allowed values " << modemin << " to " << modemax << std::endl; + sout << "Write Mode : allowed values " << modemin << " to " << modemax << '\n'; for (int modd = modemin; modd <= modemax; modd++) { - sout << modd << " : " << control->ModeWriteHelp(modd) << std::endl; + sout << modd << " : " << control->ModeWriteHelp(modd) << '\n'; } } - sout << "Write Mode : actual = " << TW->TransferMode() << std::endl; + sout << "Write Mode : actual = " << TW->TransferMode() << '\n'; if (argc <= 1) + { return IFSelect_RetVoid; + } int mod = atoi(arg1); - sout << "New value -> " << arg1 << std::endl; + sout << "New value -> " << arg1 << '\n'; TW->SetTransferMode(mod); if (!control->IsModeWrite(mod)) - sout << "Warning : this new value is not supported" << std::endl; + { + sout << "Warning : this new value is not supported" << '\n'; + } return IFSelect_RetDone; } @@ -599,7 +669,9 @@ static IFSelect_ReturnStatus XSControl_twstat(const occ::handlePrintStats(1, sout); } else - sout << "TransferWrite: not defined" << std::endl; + { + sout << "TransferWrite: not defined" << '\n'; + } return IFSelect_RetVoid; } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Reader.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Reader.cxx index 9b2bdd13e2..ee96e01601 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Reader.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Reader.cxx @@ -61,7 +61,9 @@ XSControl_Reader::XSControl_Reader(const occ::handle& WS, bool XSControl_Reader::SetNorm(const char* const norm) { if (thesession.IsNull()) + { SetWS(new XSControl_WorkSession); + } bool stat = thesession->SelectNorm(norm); if (stat) { @@ -80,10 +82,14 @@ void XSControl_Reader::SetWS(const occ::handle& WS, const thesession = WS; // There must be a Controller ... Otherwise we'll see later (after SetNorm) if (thesession->NormAdaptor().IsNull()) + { return; + } occ::handle model = thesession->Model(); if (scratch || model.IsNull()) + { model = thesession->NewModel(); + } thesession->InitTransferReader(0); thesession->InitTransferReader(4); } @@ -136,7 +142,9 @@ occ::handle>> XSControl_Re new NCollection_HSequence>(); int i, nbr = NbRootsForTransfer(); for (i = 1; i <= nbr; i++) + { list->Append(RootForTransfer(i)); + } return list; } @@ -154,7 +162,9 @@ occ::handle>> XSControl_Re int XSControl_Reader::NbRootsForTransfer() { if (therootsta) + { return theroots.Length(); + } therootsta = true; Interface_ShareFlags sf(thesession->Graph()); int i, nbr = sf.NbRoots(); @@ -163,7 +173,9 @@ int XSControl_Reader::NbRootsForTransfer() // on filtre les racines qu on sait transferer occ::handle start = sf.Root(i); if (thesession->TransferReader()->Recognize(start)) + { theroots.Append(start); + } } return theroots.Length(); } @@ -175,7 +187,9 @@ occ::handle XSControl_Reader::RootForTransfer(const int num) occ::handle voidroot; int nbr = NbRootsForTransfer(); if (num < 1 || num > nbr) + { return voidroot; + } return theroots.Value(num); } @@ -201,13 +215,17 @@ bool XSControl_Reader::TransferEntity(const occ::handle& the const Message_ProgressRange& theProgress) { if (theStart.IsNull()) + { return false; + } const occ::handle& aTransferReader = thesession->TransferReader(); aTransferReader->BeginTransfer(); InitializeMissingParameters(); if (aTransferReader->TransferOne(theStart, true, theProgress) == 0) + { return false; + } const TopoDS_Shape aShape = aTransferReader->ShapeResult(theStart); // Null shapes are allowed intentionally. @@ -223,7 +241,9 @@ int XSControl_Reader::TransferList( const Message_ProgressRange& theProgress) { if (theList.IsNull()) + { return 0; + } int aTransferredCount = 0; const occ::handle& aTransferReader = thesession->TransferReader(); @@ -401,7 +421,9 @@ void XSControl_Reader::GetStatsTransfer( Transfer_IteratorOfProcessForTransient itrp(true); itrp = TP->CompleteResult(true); if (!list.IsNull()) + { itrp.Filter(list); + } nbMapped = nbWithFail = nbWithResult = 0; for (itrp.Start(); itrp.More(); itrp.Next()) @@ -409,16 +431,24 @@ void XSControl_Reader::GetStatsTransfer( const occ::handle& binder = itrp.Value(); nbMapped++; if (binder.IsNull()) + { nbWithFail++; + } else if (!binder->HasResult()) + { nbWithFail++; + } else { Interface_CheckStatus cst = binder->Check()->Status(); if ((cst == Interface_CheckOK) || (cst == Interface_CheckWarning)) + { nbWithResult++; + } else + { nbWithFail++; + } } } } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_SelectForTransfer.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_SelectForTransfer.cxx index bacbceba54..896f93b435 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_SelectForTransfer.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_SelectForTransfer.cxx @@ -55,9 +55,12 @@ bool XSControl_SelectForTransfer::Sort(const int /*rank*/, { occ::handle act = theAC; if (act.IsNull() && !theTR.IsNull()) + { act = theTR->Actor(); + } // clang-format off - if (!act.IsNull()) return act->Recognize(ent);//,theTR->TransientProcess());//act->Recognize(ent); + if (!act.IsNull()) { return act->Recognize(ent);//,theTR->TransientProcess());//act->Recognize(ent); +} // clang-format on return false; } @@ -65,6 +68,8 @@ bool XSControl_SelectForTransfer::Sort(const int /*rank*/, TCollection_AsciiString XSControl_SelectForTransfer::ExtractLabel() const { if (!theTR.IsNull()) + { return TCollection_AsciiString("Recognized for Transfer (current actor)"); + } return TCollection_AsciiString("Recognized for Transfer"); } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_SignTransferStatus.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_SignTransferStatus.cxx index f081989031..fe47f4729b 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_SignTransferStatus.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_SignTransferStatus.cxx @@ -72,18 +72,28 @@ static int BinderStatus(const occ::handle& binder) { int stat = 0; if (binder.IsNull()) + { return 0; + } Interface_CheckStatus cst = binder->Check()->Status(); Transfer_StatusExec est = binder->StatusExec(); bool res = binder->HasResult(); if (est == Transfer_StatusRun || est == Transfer_StatusLoop) + { return 20; + } if (cst == Interface_CheckOK) + { stat = (res ? 11 : 1); + } else if (cst == Interface_CheckWarning) + { stat = (res ? 12 : 2); + } else if (cst == Interface_CheckFail) + { stat = (res ? 13 : 3); + } return stat; } @@ -93,25 +103,39 @@ const char* XSControl_SignTransferStatus::Value( const occ::handle& /*model*/) const { if (ent.IsNull()) + { return ""; + } occ::handle TP = theTP; if (TP.IsNull() && !theTR.IsNull()) + { TP = theTR->TransientProcess(); + } if (TP.IsNull()) + { return ""; + } occ::handle binder = TP->Find(ent); int stat = BinderStatus(binder); if (stat <= 1) + { return ""; + } if (stat == 2) + { return "Warning"; + } if (stat == 3) + { return "Fail"; + } if (stat == 20) + { return "Fail on run"; + } themes().Clear(); if (stat > 10) @@ -124,9 +148,13 @@ const char* XSControl_SignTransferStatus::Value( if (bnd->Status() != Transfer_StatusVoid) { if (!hasres) + { themes().AssignCat("Result:"); + } else + { themes().AssignCat(","); + } themes().AssignCat(bnd->ResultTypeName()); hasres = true; } @@ -134,9 +162,13 @@ const char* XSControl_SignTransferStatus::Value( } // if (stat == 11) Sprintf(themes,"Result:%s",binder->ResultTypeName()); if (stat == 12) + { themes().AssignCat("/Warning"); + } if (stat == 13) + { themes().AssignCat("/Fail"); + } } return themes().ToCString(); } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_TransferReader.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_TransferReader.cxx index fd459c3381..625e5ae6e4 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_TransferReader.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_TransferReader.cxx @@ -67,7 +67,9 @@ void XSControl_TransferReader::SetController(const occ::handle XSControl_TransferReader::Actor() { if (myActor.IsNull() && !myController.IsNull() && !myModel.IsNull()) + { myActor = myController->ActorRead(myModel); + } return myActor; } @@ -77,7 +79,9 @@ void XSControl_TransferReader::SetModel(const occ::handleSetModel(model); + } } //================================================================================================= @@ -89,12 +93,16 @@ void XSControl_TransferReader::SetGraph(const occ::handle& gra myModel.Nullify(); } else + { myModel = graph->Graph().Model(); + } myGraph = graph; if (!myTP.IsNull()) + { myTP->SetGraph(graph); + } } //================================================================================================= @@ -112,15 +120,25 @@ bool XSControl_TransferReader::GetContext(const char* const name occ::handle& ctx) const { if (myContext.IsEmpty()) + { return false; + } if (!myContext.Find(name, ctx)) + { ctx.Nullify(); + } if (ctx.IsNull()) + { return false; + } if (type.IsNull()) + { return true; + } if (!ctx->IsKind(type)) + { ctx.Nullify(); + } return !ctx.IsNull(); } @@ -151,10 +169,14 @@ void XSControl_TransferReader::Clear(const int mode) bool XSControl_TransferReader::RecordResult(const occ::handle& ent) { if (myModel.IsNull() || myTP.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } occ::handle lab = myModel->StringLabel(ent); occ::handle res = new Transfer_ResultFromModel; @@ -181,12 +203,18 @@ bool XSControl_TransferReader::RecordResult(const occ::handle& ent) const { if (myModel.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } if (!myResults.IsBound(num)) + { return false; + } return (myResults.Find(num)->DynamicType() == STANDARD_TYPE(Transfer_ResultFromModel)); } @@ -195,15 +223,23 @@ bool XSControl_TransferReader::IsRecorded(const occ::handle& bool XSControl_TransferReader::HasResult(const occ::handle& ent) const { if (myModel.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } if (!myResults.IsBound(num)) + { return false; + } DeclareAndCast(Transfer_ResultFromModel, fr, myResults.Find(num)); if (fr.IsNull()) + { return false; + } return fr->HasResult(); } @@ -215,13 +251,19 @@ occ::handle>> XSControl_Tr occ::handle>> li = new NCollection_HSequence>(); if (myModel.IsNull()) + { return li; + } int i, nb = myModel->NbEntities(); for (i = 1; i <= nb; i++) { if (myResults.IsBound(i)) + { if (!myResults.Find(i).IsNull()) + { li->Append(myModel->Value(i)); + } + } } return li; } @@ -231,10 +273,14 @@ occ::handle>> XSControl_Tr bool XSControl_TransferReader::Skip(const occ::handle& ent) { if (myModel.IsNull() || myTP.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } myResults.Bind(num, ent); return true; } @@ -244,12 +290,18 @@ bool XSControl_TransferReader::Skip(const occ::handle& ent) bool XSControl_TransferReader::IsSkipped(const occ::handle& ent) const { if (myModel.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } if (!myResults.IsBound(num)) + { return false; + } return (myResults.Find(num)->DynamicType() != STANDARD_TYPE(Transfer_ResultFromModel)); } @@ -258,14 +310,22 @@ bool XSControl_TransferReader::IsSkipped(const occ::handle& bool XSControl_TransferReader::IsMarked(const occ::handle& ent) const { if (myModel.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } if (!myResults.IsBound(num)) + { return false; + } if (myResults.Find(num).IsNull()) + { return false; + } return true; } @@ -278,12 +338,18 @@ occ::handle XSControl_TransferReader::FinalResult( { occ::handle res; if (myModel.IsNull()) + { return res; + } int num = myModel->Number(ent); if (num == 0) + { return res; + } if (!myResults.IsBound(num)) + { return res; + } res = GetCasted(Transfer_ResultFromModel, myResults.Find(num)); return res; } @@ -295,7 +361,9 @@ const char* XSControl_TransferReader::FinalEntityLabel( { occ::handle resu = FinalResult(ent); if (resu.IsNull()) + { return ""; + } return resu->MainLabel(); } @@ -305,7 +373,9 @@ int XSControl_TransferReader::FinalEntityNumber(const occ::handle resu = FinalResult(ent); if (resu.IsNull()) + { return 0; + } return resu->MainNumber(); } @@ -316,9 +386,13 @@ occ::handle XSControl_TransferReader::ResultFromNumber { occ::handle res; if (num < 1 || num > myModel->NbEntities()) + { return res; + } if (!myResults.IsBound(num)) + { return res; + } res = GetCasted(Transfer_ResultFromModel, myResults.Find(num)); return res; } @@ -331,15 +405,23 @@ occ::handle XSControl_TransferReader::TransientResult( occ::handle tres; occ::handle res = FinalResult(ent); if (res.IsNull()) + { return tres; + } occ::handle mres = res->MainResult(); if (mres.IsNull()) + { return tres; + } DeclareAndCast(Transfer_SimpleBinderOfTransient, bnd, mres->Binder()); if (bnd.IsNull()) + { return tres; + } if (!bnd->HasResult()) + { return tres; + } return bnd->Result(); } @@ -350,17 +432,23 @@ TopoDS_Shape XSControl_TransferReader::ShapeResult(const occ::handle res = FinalResult(ent); if (res.IsNull()) + { return tres; + } occ::handle mres = res->MainResult(); if (mres.IsNull()) + { return tres; + } XSControl_Utils xu; TopoDS_Shape sh = xu.BinderShape(mres->Binder()); // Ooh the ugly wart double tolang = Interface_Static::RVal("read.encoderegularity.angle"); if (tolang <= 0 || sh.IsNull()) + { return sh; + } ShapeFix::EncodeRegularity(sh, tolang); return sh; } @@ -371,19 +459,29 @@ bool XSControl_TransferReader::ClearResult(const occ::handle const int mode) { if (myModel.IsNull()) + { return false; + } int num = myModel->Number(ent); if (num == 0) + { return false; + } if (!myResults.IsBound(num)) + { return false; + } if (mode < 0) + { myResults.ChangeFind(num).Nullify(); + } else { DeclareAndCast(Transfer_ResultFromModel, resu, myResults.Find(num)); if (resu.IsNull()) + { return false; + } resu->Strip(mode); } return true; @@ -404,7 +502,9 @@ occ::handle XSControl_TransferReader::EntityFromResult( XSControl_Utils xu; TopoDS_Shape sh = xu.BinderShape(res); if (!sh.IsNull()) + { return EntityFromShapeResult(sh, mode); + } occ::handle abinder; DeclareAndCast(Transfer_Binder, binder, res); @@ -420,21 +520,31 @@ occ::handle XSControl_TransferReader::EntityFromResult( { i = (mode == 0 ? myModel->Number(myTP->Root(j)) : j); if (i == 0) + { continue; + } abinder = myTP->MapItem(i); if (abinder.IsNull()) + { continue; + } if (!binder.IsNull()) { if (binder == abinder) + { return myTP->Mapped(i); + } continue; } DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, abinder); if (trb.IsNull()) + { continue; + } if (trb->Result() == res) + { return myTP->Mapped(i); + } } } return nulh; // Null @@ -449,7 +559,9 @@ occ::handle XSControl_TransferReader::EntityFromResult( { occ::handle rec = ResultFromNumber(i); if (rec.IsNull()) + { return nulh; + } occ::handle>> list = rec->Results(mode - 2); int ir, nr = list->Length(); @@ -457,9 +569,13 @@ occ::handle XSControl_TransferReader::EntityFromResult( { DeclareAndCast(Transfer_ResultFromTransient, rft, list->Value(ir)); if (rft.IsNull()) + { continue; + } if (rft->Binder() == binder) + { return rft->Start(); + } } } } @@ -478,7 +594,9 @@ occ::handle XSControl_TransferReader::EntityFromShapeResult( { occ::handle nulh, samesh, partner; if (res.IsNull()) + { return nulh; + } int i, j, nb; XSControl_Utils xu; @@ -492,26 +610,38 @@ occ::handle XSControl_TransferReader::EntityFromShapeResult( { i = (mode == 0 ? myModel->Number(myTP->Root(j)) : j); if (i == 0) + { continue; + } occ::handle ent = myTP->Mapped(i); TopoDS_Shape sh = TransferBRep::ShapeResult(myTP, ent); if (!sh.IsNull()) { if (sh == res) + { return ent; + } // lesser priorities : Same (always) or Partner (mode < 0) if (sh.IsSame(res)) + { samesh = ent; + } if (mode == -1 && sh.IsPartner(res)) + { partner = ent; + } } } } // Here, no true equality found. Lesser priorities: Same then Partner if (!samesh.IsNull()) + { return samesh; + } if (!partner.IsNull()) + { return partner; // calculated if mode = -1 + } return nulh; } @@ -524,7 +654,9 @@ occ::handle XSControl_TransferReader::EntityFromShapeResult( { occ::handle rec = ResultFromNumber(i); if (rec.IsNull()) + { continue; + } occ::handle>> list = rec->Results(mode - 2); @@ -533,10 +665,14 @@ occ::handle XSControl_TransferReader::EntityFromShapeResult( { DeclareAndCast(Transfer_ResultFromTransient, rft, list->Value(ir)); if (rft.IsNull()) + { continue; + } TopoDS_Shape sh = xu.BinderShape(rft->Binder()); if (!sh.IsNull() && sh == res) + { return rft->Start(); + } } } } @@ -553,15 +689,21 @@ occ::handle>> XSControl_Tr occ::handle>> lt = new NCollection_HSequence>(); if (res.IsNull()) + { return lt; + } NCollection_Map shapes; // We convert res to a map, for rapid presence test int i, j, nb = res->Length(); if (nb == 0) + { return lt; + } for (i = 1; i <= nb; i++) + { shapes.Add(res->Value(i)); + } // Now, search and registration @@ -576,7 +718,9 @@ occ::handle>> XSControl_Tr { i = (mode == 0 ? myModel->Number(myTP->Root(j)) : j); if (i == 0) + { continue; + } TopoDS_Shape sh = xu.BinderShape(myTP->MapItem(i)); if (!sh.IsNull() && shapes.Contains(sh)) { @@ -596,7 +740,9 @@ occ::handle>> XSControl_Tr { occ::handle rec = ResultFromNumber(i); if (rec.IsNull()) + { continue; + } occ::handle>> list = rec->Results(mode - 2); @@ -605,10 +751,14 @@ occ::handle>> XSControl_Tr { DeclareAndCast(Transfer_ResultFromTransient, rft, list->Value(i)); if (rft.IsNull()) + { continue; + } TopoDS_Shape sh = xu.BinderShape(rft->Binder()); if (!sh.IsNull() && shapes.Contains(sh)) + { lt->Append(rft->Start()); + } } } } @@ -626,7 +776,9 @@ Interface_CheckIterator XSControl_TransferReader::CheckList( { Interface_CheckIterator chl; if (myModel.IsNull() || ent.IsNull()) + { return chl; + } // Check-List COMPLETE ... the entire Model if (ent == myModel) { @@ -661,26 +813,40 @@ Interface_CheckIterator XSControl_TransferReader::CheckList( else if (level < 0) { if (myTP.IsNull()) + { return chl; + } chl.Add(myTP->Check(ent), myModel->Number(ent)); } else { occ::handle rec = FinalResult(ent); if (rec.IsNull()) + { return chl; + } chl = rec->CheckList(false, level); // manque level ... } if (ent == myModel) + { chl.SetName("XSControl : CheckList complete Model"); + } else if (level < 0) + { chl.SetName("XSControl : CheckList Last"); + } else if (level == 0) + { chl.SetName("XSControl : CheckList Final Main"); + } else if (level == 1) + { chl.SetName("XSControl : CheckList Final Main+Subs"); + } else if (level >= 2) + { chl.SetName("XSControl : CheckList Final Complete"); + } return chl; } @@ -691,12 +857,18 @@ bool XSControl_TransferReader::HasChecks(const occ::handle& { occ::handle resu = FinalResult(ent); if (resu.IsNull()) + { return false; + } int stat = resu->ComputeCheckStatus(false); if (stat == 0) + { return false; + } if (stat > 1) + { return true; + } return (!failsonly); } @@ -710,7 +882,9 @@ occ::handle>> XSControl_Tr occ::handle>> res = new NCollection_HSequence>(); if (ent.IsNull()) + { return res; + } if (ent == myModel) { @@ -719,7 +893,9 @@ occ::handle>> XSControl_Tr { occ::handle rec = ResultFromNumber(i); if (!rec.IsNull()) + { res->Append(rec->CheckedList(withcheck, level)); + } } } else if (ent->IsKind(STANDARD_TYPE(NCollection_HSequence>))) @@ -730,14 +906,18 @@ occ::handle>> XSControl_Tr { occ::handle rec = FinalResult(list->Value(i)); if (!rec.IsNull()) + { res->Append(rec->CheckedList(withcheck, level)); + } } } else { occ::handle rec = FinalResult(ent); if (!rec.IsNull()) + { res = rec->CheckedList(withcheck, level); + } } return res; } @@ -751,13 +931,19 @@ occ::handle>> XSControl_Tr bool XSControl_TransferReader::BeginTransfer() { if (myModel.IsNull()) + { return false; + } if (Actor().IsNull()) + { return false; + } myShapeResult.Nullify(); if (myTP.IsNull()) + { myTP = new Transfer_TransientProcess(myModel->NbEntities()); + } occ::handle actor; myTP->SetActor(actor); // -> Reset @@ -775,7 +961,9 @@ bool XSControl_TransferReader::BeginTransfer() bool XSControl_TransferReader::Recognize(const occ::handle& ent) { if (myActor.IsNull()) + { return false; + } return myActor->Recognize(ent); } @@ -786,12 +974,16 @@ int XSControl_TransferReader::TransferOne(const occ::handle& const Message_ProgressRange& theProgress) { if (myActor.IsNull() || myModel.IsNull()) + { return 0; + } if (myTP.IsNull()) { if (!BeginTransfer()) + { return 0; + } } Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo(); @@ -799,9 +991,13 @@ int XSControl_TransferReader::TransferOne(const occ::handle& Transfer_TransferOutput TP(myTP, myModel); if (myGraph.IsNull()) + { myTP->SetModel(myModel); + } else + { myTP->SetGraph(myGraph); + } // for the log-file if (level > 1) @@ -809,11 +1005,13 @@ int XSControl_TransferReader::TransferOne(const occ::handle& int num = myModel->Number(ent); occ::handle lab = myModel->StringLabel(ent); sout << "\n*******************************************************************\n"; - sout << "****** Transferring one Entity ******" << std::endl; + sout << "****** Transferring one Entity ******" << '\n'; if (!lab.IsNull()) + { sout << "****** N0 in file : " << Interface_MSG::Blanks(num, 5) << num << " Ident : " << lab->ToCString() << Interface_MSG::Blanks(14 - lab->Length()) << "******\n"; + } sout << "****** Type : " << myModel->TypeName(ent, false) << Interface_MSG::Blanks((int)(44 - strlen(myModel->TypeName(ent, false)))) << "******"; sout << "\n*******************************************************************\n"; @@ -824,18 +1022,26 @@ int XSControl_TransferReader::TransferOne(const occ::handle& const occ::handle& obj = ent; TP.Transfer(obj, theProgress); if (theProgress.UserBreak()) + { return res; + } myTP->SetRoot(obj); // Result ... occ::handle binder = myTP->Find(obj); if (binder.IsNull()) + { return res; + } if (rec) + { RecordResult(obj); + } if (!binder->HasResult()) + { return res; + } res++; return res; @@ -849,21 +1055,29 @@ int XSControl_TransferReader::TransferList( const Message_ProgressRange& theProgress) { if (myActor.IsNull() || myModel.IsNull()) + { return 0; + } if (myTP.IsNull()) { if (!BeginTransfer()) + { return 0; + } } int level = myTP->TraceLevel(); Transfer_TransferOutput TP(myTP, myModel); if (myGraph.IsNull()) + { myTP->SetModel(myModel); + } else + { myTP->SetGraph(myGraph); + } int i, nb = list->Length(); @@ -873,12 +1087,14 @@ int XSControl_TransferReader::TransferList( Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo(); sout << "\n*******************************************************************\n"; sout << "****** Transferring a list of " << Interface_MSG::Blanks(nb, 5) - << " Entities ******" << std::endl; + << " Entities ******" << '\n'; sout << "\n*******************************************************************\n"; occ::handle sl = new IFSelect_SignatureList; for (i = 1; i <= nb; i++) + { sl->Add(list->Value(i), myModel->TypeName(list->Value(i), false)); + } sl->SetName("Entities to Transfer"); sl->PrintCount(sout); sout << "\n*******************************************************************\n"; @@ -898,12 +1114,18 @@ int XSControl_TransferReader::TransferList( // Result ... occ::handle binder = myTP->Find(obj); if (binder.IsNull()) + { continue; + } if (rec) + { RecordResult(obj); + } if (!binder->HasResult()) + { continue; + } res++; } return res; @@ -917,16 +1139,24 @@ int XSControl_TransferReader::TransferRoots(const Interface_Graph& G, const Message_ProgressRange& theProgress) { if (myModel != G.Model()) + { return -1; + } if (!BeginTransfer()) + { return -1; + } int level = myTP->TraceLevel(); Transfer_TransferOutput TP(myTP, myModel); if (myGraph.IsNull()) + { myTP->SetModel(myModel); + } else + { myTP->SetGraph(myGraph); + } // For the log-file if (level > 0) @@ -936,11 +1166,13 @@ int XSControl_TransferReader::TransferRoots(const Interface_Graph& G, Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo(); sout << "\n*******************************************************************\n"; sout << "****** Transferring the " << Interface_MSG::Blanks(nb, 5) - << " Root Entities ******" << std::endl; + << " Root Entities ******" << '\n'; sout << "\n*******************************************************************\n"; occ::handle sl = new IFSelect_SignatureList; for (roots.Start(); roots.More(); roots.Next()) + { sl->Add(roots.Value(), myModel->TypeName(roots.Value(), false)); + } sl->SetName("Entities to Transfer"); sl->PrintCount(sout); sout << "\n*******************************************************************\n"; @@ -948,7 +1180,9 @@ int XSControl_TransferReader::TransferRoots(const Interface_Graph& G, TP.TransferRoots(G, theProgress); if (theProgress.UserBreak()) + { return -1; + } // The transferred entities are noted as "asmain" int i, n = myTP->NbMapped(); @@ -957,9 +1191,13 @@ int XSControl_TransferReader::TransferRoots(const Interface_Graph& G, occ::handle ent = myTP->Mapped(i); occ::handle bnd = myTP->MapItem(i); if (bnd.IsNull()) + { continue; + } if (!bnd->HasResult()) + { continue; + } RecordResult(ent); } @@ -975,7 +1213,9 @@ void XSControl_TransferReader::TransferClear(const occ::handleClear(); @@ -994,33 +1234,37 @@ void XSControl_TransferReader::PrintStats(Standard_OStream& sout, { // To be improved ... ! sout << "\n*******************************************************************\n"; - sout << "****** Statistics on Transfer (Read) ******" << std::endl; + sout << "****** Statistics on Transfer (Read) ******" << '\n'; sout << "\n*******************************************************************\n"; if (what > 10) { - sout << " *** Not yet implemented" << std::endl; + sout << " *** Not yet implemented" << '\n'; return; } if (what < 10) { - sout << "****** Data recorded on Last Transfer ******" << std::endl; + sout << "****** Data recorded on Last Transfer ******" << '\n'; PrintStatsProcess(myTP, what, mode); } // remaining what = 10: we list the roots of final results - sout << "****** Final Results ******" << std::endl; + sout << "****** Final Results ******" << '\n'; if (myModel.IsNull()) { - sout << "**** Model unknown" << std::endl; + sout << "**** Model unknown" << '\n'; return; } occ::handle>> list = RecordedList(); int i, nb = list->Length(); occ::handle counter; if (mode > 2) + { counter = new IFSelect_SignatureList(mode == 6); + } IFSelect_PrintCount pcm = IFSelect_CountByItem; if (mode == 6) + { pcm = IFSelect_ListByItem; + } sout << "**** Nb Recorded : " << nb << " : entities n0s : "; for (i = 1; i <= nb; i++) @@ -1043,9 +1287,11 @@ void XSControl_TransferReader::PrintStats(Standard_OStream& sout, } } if (!counter.IsNull()) + { counter->PrintList(sout, myModel, pcm); + } - sout << std::endl; + sout << '\n'; } // ######################################################## @@ -1057,7 +1303,9 @@ Interface_CheckIterator XSControl_TransferReader::LastCheckList() const { Interface_CheckIterator chl; if (!myTP.IsNull()) + { chl = myTP->CheckList(false); + } return chl; } @@ -1069,16 +1317,22 @@ occ::handle>> XSControl_Tr occ::handle>> li = new NCollection_HSequence>(); if (myTP.IsNull()) + { return li; + } int i, j, nb = (roots ? myTP->NbRoots() : myTP->NbMapped()); for (j = 1; j <= nb; j++) { i = (roots ? myModel->Number(myTP->Root(j)) : j); occ::handle bnd = myTP->MapItem(i); if (bnd.IsNull()) + { continue; + } if (!bnd->HasResult()) + { continue; + } li->Append(myTP->Mapped(i)); } return li; @@ -1092,16 +1346,24 @@ const occ::handle>& XSControl_TransferReader if (!rec) { if (myShapeResult.IsNull()) + { myShapeResult = TransferBRep::Shapes(myTP, true); + } if (myShapeResult.IsNull()) + { myShapeResult = new NCollection_HSequence(); + } } else { if (myShapeResult.IsNull()) + { myShapeResult = new NCollection_HSequence(); + } if (myModel.IsNull()) + { return myShapeResult; + } occ::handle>> li = RecordedList(); myShapeResult = new NCollection_HSequence(); int i, nb = myModel->NbEntities(); @@ -1110,7 +1372,9 @@ const occ::handle>& XSControl_TransferReader { sh = ShapeResult(myModel->Value(i)); if (!sh.IsNull()) + { myShapeResult->Append(sh); + } } } return myShapeResult; @@ -1138,7 +1402,9 @@ static int BinderStatus(const occ::handle& binder, char* mess) { stat = 11; if (binder->HasResult()) + { Sprintf(mess, "%s", binder->ResultTypeName()); + } else { Sprintf(mess, "(no result)"); @@ -1149,7 +1415,9 @@ static int BinderStatus(const occ::handle& binder, char* mess) { stat = 12; if (binder->HasResult()) + { Sprintf(mess, "%s (+ warning)", binder->ResultTypeName()); + } else { Sprintf(mess, "(warning)"); @@ -1160,7 +1428,9 @@ static int BinderStatus(const occ::handle& binder, char* mess) { stat = 13; if (binder->HasResult()) + { Sprintf(mess, "%s (+ FAIL)", binder->ResultTypeName()); + } else { Sprintf(mess, "(FAIL)"); @@ -1178,15 +1448,23 @@ static void PrintPercent(const occ::handle& sout, const int nl) { if (nb <= 0 || nl == 0) + { return; + } Message_Messenger::StreamBuffer aSender = sout->SendInfo(); aSender << "****** " << mess << ": "; if (nb == nl) - aSender << "100 %" << std::endl; + { + aSender << "100 %" << '\n'; + } else if (nb * 100 / nl == 0) - aSender << "< 1 %" << std::endl; + { + aSender << "< 1 %" << '\n'; + } else - aSender << (nb * 100 / nl < 10 ? " " : " ") << nb * 100 / nl << " %" << std::endl; + { + aSender << (nb * 100 / nl < 10 ? " " : " ") << nb * 100 / nl << " %" << '\n'; + } } //================================================================================================= @@ -1211,7 +1489,9 @@ void XSControl_TransferReader::PrintStatsOnList( char mess[250]; if (TP.IsNull()) + { return; + } if (what == 0) { TP->PrintStats(0, sout); @@ -1219,34 +1499,58 @@ void XSControl_TransferReader::PrintStatsOnList( } sout << "\n*******************************************************************\n"; - sout << "****** Statistics on Transfer Process (Read) ******" << std::endl; + sout << "****** Statistics on Transfer Process (Read) ******" << '\n'; if (what == 1) + { sout << "****** Individual Transfers (Roots) ******\n"; + } if (what == 2) + { sout << "****** All recorded data about Transfer ******\n"; + } if (what == 3) + { sout << "****** Abnormal records ******\n"; + } if (what == 1 || what == 2 || what == 3) { if (mode == 0) + { sout << "****** (n0s of recorded entities) ******\n"; + } if (mode == 1) + { sout << "****** (per entity : type + result) ******\n"; + } if (mode == 2) + { sout << "****** (per entity : type + result/status) ******\n"; + } if (mode == 3) + { sout << "****** (count per type of entity) ******\n"; + } if (mode == 4) + { sout << "****** (count per type of result) ******\n"; + } if (mode == 5) + { sout << "****** (count per couple entity-type / result-type/status) ******\n"; + } if (mode == 6) + { sout << "****** (list per couple entity-type / result-type/status) ******\n"; + } } if (what == 4) + { sout << "****** Check messages ******\n"; + } if (what == 5) + { sout << "****** Fail messages ******\n"; + } sout << "*******************************************************************\n"; // Case what = 1,2,3: content of TP (binders) @@ -1260,27 +1564,41 @@ void XSControl_TransferReader::PrintStatsOnList( int nbw = 0, nbf = 0, nbr = 0, nbrw = 0, nbrf = 0, nbnr = 0, nbi = 0; Transfer_IteratorOfProcessForTransient itrp(true); if (what == 1) + { itrp = TP->RootResult(true); + } if (what == 2) + { itrp = TP->CompleteResult(true); + } if (what == 3) + { itrp = TP->AbnormalResult(); + } int i = 0, nb = itrp.Number(); if (!nolist) + { itrp.Filter(list); + } int nl = itrp.Number(); // after filtering occ::handle counter; if (mode > 2) + { counter = new IFSelect_SignatureList(mode == 6); + } bool notrec = (!nolist && mode > 2); // note the "no record" IFSelect_PrintCount pcm = IFSelect_CountByItem; if (mode == 6) + { pcm = IFSelect_ListByItem; + } - sout << "**** Entities in Model : " << model->NbEntities() << std::endl; - sout << "**** Nb Items (Transfer) : " << nb << std::endl; + sout << "**** Entities in Model : " << model->NbEntities() << '\n'; + sout << "**** Nb Items (Transfer) : " << nb << '\n'; if (!nolist) - sout << "**** Nb Items (Listed) : " << nl << std::endl; + { + sout << "**** Nb Items (Listed) : " << nl << '\n'; + } for (itrp.Start(); itrp.More(); itrp.Next()) { @@ -1291,12 +1609,14 @@ void XSControl_TransferReader::PrintStatsOnList( { nbnr++; if (notrec) + { counter->Add(ent, "(not recorded)"); + } else if (mode == 1 || mode == 2) { sout << "[" << Interface_MSG::Blanks(nbi, 4) << nbi << " ]:"; model->Print(ent, sout); - sout << " " << model->TypeName(ent, false) << " (not recorded)" << std::endl; + sout << " " << model->TypeName(ent, false) << " (not recorded)" << '\n'; continue; } } @@ -1311,15 +1631,25 @@ void XSControl_TransferReader::PrintStatsOnList( // 0 Binder Null. 1 void 2 Warning only 3 Fail only // 11 Result OK. 12 Result+Warning. 13 Result+Fail if (stat == 2) + { nbw++; + } if (stat == 3) + { nbf++; + } if (stat == 11) + { nbr++; + } if (stat == 12) + { nbrw++; + } if (stat == 13) + { nbrf++; + } } // mode : 0 list num; 1 : num+label + type + result (abrege); 2 : complet @@ -1328,9 +1658,11 @@ void XSControl_TransferReader::PrintStatsOnList( sout << "[" << Interface_MSG::Blanks(i, 4) << i << " ]:"; model->Print(ent, sout); sout << " " << model->TypeName(ent, false); - sout << " Result:" << mess << std::endl; + sout << " Result:" << mess << '\n'; if (mode == 1) + { continue; + } const occ::handle& ch = binder->Check(); int newi, newnbw = ch->NbWarnings(), newnbf = ch->NbFails(); @@ -1339,13 +1671,17 @@ void XSControl_TransferReader::PrintStatsOnList( { sout << " - Warnings : " << newnbw << ":\n"; for (newi = 1; newi <= newnbw; newi++) - sout << ch->CWarning(newi) << std::endl; + { + sout << ch->CWarning(newi) << '\n'; + } } if (newnbf > 0) { sout << " - Fails : " << newnbf << ":\n"; for (newi = 1; newi <= newnbf; newi++) - sout << ch->CFail(newi) << std::endl; + { + sout << ch->CFail(newi) << '\n'; + } } continue; } @@ -1360,9 +1696,13 @@ void XSControl_TransferReader::PrintStatsOnList( // IFSelect_PrintCount newpcm = IFSelect_CountByItem; // if (mode == 6) newpcm = IFSelect_ListByItem; if (mode == 3) + { counter->Add(ent, model->TypeName(ent, false)); + } if (mode == 4) + { counter->Add(ent, mess); + } if (mode >= 5) { TCollection_AsciiString mest(model->TypeName(ent, false)); @@ -1376,13 +1716,17 @@ void XSControl_TransferReader::PrintStatsOnList( // End of iteration } if (!counter.IsNull()) + { counter->PrintList(sout, model, pcm); + } else - sout << std::endl; + { + sout << '\n'; + } // Pourcentages if (mode != 3 && nbi > 0) { - sout << "****** Percentages according Transfer Status ******" << std::endl; + sout << "****** Percentages according Transfer Status ******" << '\n'; PrintPercent(TP->Messenger(), "Result ", nbr + nbrw, nl); PrintPercent(TP->Messenger(), "Result + FAIL ", nbrf, nl); PrintPercent(TP->Messenger(), "FAIL, no Result ", nbf, nl); @@ -1417,7 +1761,9 @@ void XSControl_TransferReader::PrintStatsOnList( { IFSelect_PrintCount pcm = IFSelect_CountByItem; if (mode == 2) + { pcm = IFSelect_ListByItem; + } occ::handle counter = new IFSelect_CheckCounter(true); counter->Analyse(chl, model, true, (what == 5)); counter->PrintList(sout, model, pcm); diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_TransferWriter.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_TransferWriter.cxx index f90d8caaf1..ac09e79c5d 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_TransferWriter.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_TransferWriter.cxx @@ -34,9 +34,13 @@ IMPLEMENT_STANDARD_RTTIEXT(XSControl_TransferWriter, Standard_Transient) void XSControl_TransferWriter::Clear(const int mode) { if (mode < 0 || myTransferWriter.IsNull()) + { myTransferWriter = new Transfer_FinderProcess; + } else + { myTransferWriter->Clear(); + } } //================================================================================================= @@ -46,13 +50,15 @@ void XSControl_TransferWriter::PrintStats(const int, const int) const Message_Messenger::StreamBuffer sout = myTransferWriter->Messenger()->SendInfo(); // A ameliorer ... ! sout << "\n*******************************************************************\n"; - sout << "****** Statistics on Transfer (Write) ******" << std::endl; + sout << "****** Statistics on Transfer (Write) ******" << '\n'; sout << "\n*******************************************************************\n"; sout << "****** Transfer Mode = " << myTransferMode; const char* modehelp = myController->ModeWriteHelp(myTransferMode); if (modehelp && modehelp[0] != 0) + { sout << " I.E. " << modehelp; - sout << " ******" << std::endl; + } + sout << " ******" << '\n'; } // ########## LES ACTIONS ########## @@ -62,11 +68,15 @@ void XSControl_TransferWriter::PrintStats(const int, const int) const bool XSControl_TransferWriter::RecognizeTransient(const occ::handle& obj) { if (myController.IsNull()) + { return false; + } XSControl_Utils xu; TopoDS_Shape sh = xu.BinderShape(obj); if (!sh.IsNull()) + { return RecognizeShape(sh); + } return myController->RecognizeWriteTransient(obj, myTransferMode); } @@ -79,12 +89,18 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteTransient( { IFSelect_ReturnStatus status = IFSelect_RetVoid; if (myController.IsNull()) + { return IFSelect_RetError; + } if (model.IsNull()) + { return IFSelect_RetVoid; + } if (myTransferWriter.IsNull()) + { myTransferWriter = new Transfer_FinderProcess; + } occ::handle nulact; myTransferWriter->SetActor(nulact); occ::handle resultat; @@ -94,7 +110,7 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteTransient( OCC_CATCH_SIGNALS PrintStats(myTransferMode); sout << "****** Transferring Transient, CDL Type = "; - sout << obj->DynamicType()->Name() << " ******" << std::endl; + sout << obj->DynamicType()->Name() << " ******" << '\n'; status = myController->TransferWriteTransient(obj, myTransferWriter, model, @@ -105,7 +121,7 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteTransient( { sout << "**** **** TransferWriteShape, EXCEPTION : "; sout << anException.what(); - sout << std::endl; + sout << '\n'; status = IFSelect_RetFail; } return status; @@ -116,9 +132,13 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteTransient( bool XSControl_TransferWriter::RecognizeShape(const TopoDS_Shape& shape) { if (myController.IsNull()) + { return false; + } if (shape.IsNull()) + { return false; + } return myController->RecognizeWriteShape(shape, myTransferMode); } @@ -131,14 +151,20 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape( { IFSelect_ReturnStatus status = IFSelect_RetVoid; if (myController.IsNull()) + { return IFSelect_RetError; + } if (theModel.IsNull()) + { return IFSelect_RetVoid; + } TopoDS_Shape aShape = theShape; if (myTransferWriter.IsNull()) + { myTransferWriter = new Transfer_FinderProcess; + } // effacer l actor : Controller s en charge occ::handle nulact; myTransferWriter->SetActor(nulact); @@ -149,7 +175,7 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape( OCC_CATCH_SIGNALS PrintStats(myTransferMode); sout << "****** Transferring Shape, ShapeType = " << aShape.ShapeType(); - sout << " ******" << std::endl; + sout << " ******" << '\n'; status = myController->TransferWriteShape(aShape, myTransferWriter, theModel, @@ -160,7 +186,7 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape( { sout << "**** **** TransferWriteShape, EXCEPTION : "; sout << anException.what(); - sout << std::endl; + sout << '\n'; status = IFSelect_RetFail; } return status; @@ -172,21 +198,31 @@ Interface_CheckIterator XSControl_TransferWriter::CheckList() const { Interface_CheckIterator chl; if (myTransferWriter.IsNull()) + { return chl; + } int i, nb = myTransferWriter->NbMapped(); for (i = 1; i <= nb; i++) { DeclareAndCast(Transfer_SimpleBinderOfTransient, tb, myTransferWriter->MapItem(i)); if (tb.IsNull()) + { continue; + } occ::handle ach = tb->Check(); if (ach->NbFails() == 0 || ach->NbWarnings() == 0) + { continue; + } DeclareAndCast(Transfer_TransientMapper, tm, myTransferWriter->Mapped(i)); if (tm.IsNull()) + { ach->GetEntity(myTransferWriter->Mapped(i)); + } else + { ach->GetEntity(tm->Value()); + } chl.Add(ach); } return chl; @@ -199,21 +235,31 @@ Interface_CheckIterator XSControl_TransferWriter::ResultCheckList( { Interface_CheckIterator chl; if (myTransferWriter.IsNull()) + { return chl; + } int i, nb = myTransferWriter->NbMapped(); for (i = 1; i <= nb; i++) { DeclareAndCast(Transfer_SimpleBinderOfTransient, tb, myTransferWriter->MapItem(i)); if (tb.IsNull()) + { continue; + } const occ::handle ach = tb->Check(); if (ach->NbFails() == 0 || ach->NbWarnings() == 0) + { continue; + } occ::handle ent = tb->Result(); if (!ent.IsNull() && !model.IsNull()) + { chl.Add(ach, model->Number(ent)); + } else + { chl.Add(ach, 0); + } } return chl; } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Utils.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Utils.cxx index c91d7c0c11..2afaaccb0c 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Utils.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Utils.cxx @@ -52,7 +52,7 @@ XSControl_Utils::XSControl_Utils() = default; void XSControl_Utils::TraceLine(const char* const line) const { Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << line << std::endl; + sout << line << '\n'; } void XSControl_Utils::TraceLines(const occ::handle& lines) const @@ -64,8 +64,12 @@ void XSControl_Utils::TraceLines(const occ::handle& lines) c { nb = linha->Length(); for (i = 1; i <= nb; i++) + { if (!linha->Value(i).IsNull()) - sout << linha->Value(i)->ToCString() << std::endl; + { + sout << linha->Value(i)->ToCString() << '\n'; + } + } return; } DeclareAndCast(NCollection_HSequence, lina, lines); @@ -73,7 +77,9 @@ void XSControl_Utils::TraceLines(const occ::handle& lines) c { nb = lina->Length(); for (i = 1; i <= nb; i++) - sout << lina->Value(i).ToCString() << std::endl; + { + sout << lina->Value(i).ToCString() << '\n'; + } return; } DeclareAndCast(NCollection_HSequence>, linhe, lines); @@ -81,8 +87,12 @@ void XSControl_Utils::TraceLines(const occ::handle& lines) c { nb = linhe->Length(); for (i = 1; i <= nb; i++) + { if (!linhe->Value(i).IsNull()) - sout << linhe->Value(i)->String() << std::endl; + { + sout << linhe->Value(i)->String() << '\n'; + } + } return; } DeclareAndCast(NCollection_HSequence, linee, lines); @@ -90,15 +100,21 @@ void XSControl_Utils::TraceLines(const occ::handle& lines) c { nb = linee->Length(); for (i = 1; i <= nb; i++) - sout << linee->Value(i) << std::endl; + { + sout << linee->Value(i) << '\n'; + } return; } DeclareAndCast(TCollection_HAsciiString, lin1a, lines); if (!lin1a.IsNull()) + { sout << lin1a->String(); + } DeclareAndCast(TCollection_HExtendedString, lin1e, lines); if (!lin1e.IsNull()) + { sout << lin1e->String(); + } } // ######################################################### @@ -108,9 +124,13 @@ bool XSControl_Utils::IsKind(const occ::handle& item, const occ::handle& what) const { if (item.IsNull()) + { return false; + } if (what.IsNull()) + { return false; + } return item->IsKind(what); } @@ -118,17 +138,25 @@ const char* XSControl_Utils::TypeName(const occ::handle& ite const bool nopk) const { if (item.IsNull()) + { return ""; + } DeclareAndCast(Standard_Type, atype, item); if (atype.IsNull()) + { atype = item->DynamicType(); + } const char* tn = atype->Name(); if (!nopk) + { return tn; + } for (int i = 0; tn[i] != '\0'; i++) { if (tn[i] == '_') + { return &tn[i + 1]; + } } return tn; } @@ -141,21 +169,29 @@ occ::handle XSControl_Utils::TraValue( { occ::handle val; if (num < 1) + { return val; + } if (seqval.IsNull()) + { return val; + } DeclareAndCast(NCollection_HSequence>, seqs, seqval); if (!seqs.IsNull()) { if (num <= seqs->Length()) + { val = seqs->Value(num); + } return val; } DeclareAndCast(NCollection_HSequence>, seqt, seqval); if (!seqt.IsNull()) { if (num <= seqt->Length()) + { val = seqt->Value(num); + } return val; } // throw Standard_TypeMismatch("XSControl_Utils::SeqTraValue"); @@ -329,10 +365,14 @@ const char* XSControl_Utils::CStrValue(const occ::handle& li DeclareAndCast(TCollection_HAsciiString, lin1a, list); if (!lin1a.IsNull()) + { return lin1a->ToCString(); + } DeclareAndCast(TCollection_HExtendedString, lin1e, list); if (!lin1e.IsNull()) + { return ExtendedToAscii(lin1e->ToExtString()); + } return ""; } @@ -341,26 +381,38 @@ const char16_t* XSControl_Utils::EStrValue(const occ::handle { DeclareAndCast(NCollection_HSequence>, linha, list); if (!linha.IsNull()) + { return (num > linha->Length() ? voidext : AsciiToExtended(linha->Value(num)->ToCString())); + } DeclareAndCast(NCollection_HSequence, lina, list); if (!lina.IsNull()) + { (num > lina->Length() ? voidext : AsciiToExtended(lina->Value(num).ToCString())); + } DeclareAndCast(NCollection_HSequence>, linhe, list); if (!linhe.IsNull()) + { return (num > linhe->Length() ? voidext : linhe->Value(num)->ToExtString()); + } DeclareAndCast(NCollection_HSequence, linee, list); if (!linee.IsNull()) + { return (num > linee->Length() ? voidext : linee->Value(num).ToExtString()); + } DeclareAndCast(TCollection_HAsciiString, lin1a, list); if (!lin1a.IsNull()) + { return AsciiToExtended(lin1a->ToCString()); + } DeclareAndCast(TCollection_HExtendedString, lin1e, list); if (!lin1e.IsNull()) + { return lin1e->ToExtString(); + } return voidext; } @@ -401,39 +453,61 @@ TopoDS_Shape XSControl_Utils::CompoundFromSeq( B.MakeCompound(C); int i, n = seqval->Length(); for (i = 1; i <= n; i++) + { B.Add(C, seqval->Value(i)); + } return C; } TopAbs_ShapeEnum XSControl_Utils::ShapeType(const TopoDS_Shape& shape, const bool compound) const { if (shape.IsNull()) + { return TopAbs_SHAPE; + } TopAbs_ShapeEnum res = shape.ShapeType(); if (!compound || res != TopAbs_COMPOUND) + { return res; + } res = TopAbs_SHAPE; for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) { const TopoDS_Shape& sh = iter.Value(); if (sh.IsNull()) + { continue; + } TopAbs_ShapeEnum typ = sh.ShapeType(); if (typ == TopAbs_COMPOUND) + { typ = ShapeType(sh, compound); + } if (res == TopAbs_SHAPE) + { res = typ; - // Equality: OK; Pseudo-Equality: EDGE/WIRE or FACE/SHELL + // Equality: OK; Pseudo-Equality: EDGE/WIRE or FACE/SHELL + } else if (res == TopAbs_EDGE && typ == TopAbs_WIRE) + { res = typ; + } else if (res == TopAbs_WIRE && typ == TopAbs_EDGE) + { continue; + } else if (res == TopAbs_FACE && typ == TopAbs_SHELL) + { res = typ; + } else if (res == TopAbs_SHELL && typ == TopAbs_FACE) + { continue; + } else if (res != typ) + { return TopAbs_COMPOUND; + } } return res; } @@ -444,7 +518,9 @@ TopoDS_Shape XSControl_Utils::SortedCompound(const TopoDS_Shape& shape, const bool compound) const { if (shape.IsNull()) + { return shape; + } TopAbs_ShapeEnum typ = shape.ShapeType(); TopoDS_Shape sh, sh0; int nb = 0; @@ -459,7 +535,9 @@ TopoDS_Shape XSControl_Utils::SortedCompound(const TopoDS_Shape& shape, { sh0 = SortedCompound(it.Value(), type, explore, compound); if (sh0.IsNull()) + { continue; + } sh = sh0; typ = sh.ShapeType(); if (typ == TopAbs_COMPOUND && !compound) @@ -478,15 +556,21 @@ TopoDS_Shape XSControl_Utils::SortedCompound(const TopoDS_Shape& shape, } } if (nb == 0) + { C.Nullify(); + } else if (nb == 1) + { return sh; + } return C; } // Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL if (typ == type) + { return shape; + } if (typ == TopAbs_EDGE && type == TopAbs_WIRE) { BRep_Builder B; @@ -523,15 +607,21 @@ TopoDS_Shape XSControl_Utils::SortedCompound(const TopoDS_Shape& shape, { sh0 = SortedCompound(it.Value(), type, explore, compound); if (sh0.IsNull()) + { continue; + } sh = sh0; nb++; B.Add(C, sh); } if (nb == 0) + { C.Nullify(); + } else if (nb == 1) + { return sh; + } return C; } @@ -546,9 +636,13 @@ TopoDS_Shape XSControl_Utils::SortedCompound(const TopoDS_Shape& shape, BB.Add(CC, sh); } if (nb == 0) + { CC.Nullify(); + } else if (nb == 1) + { return sh; + } return CC; } @@ -560,9 +654,13 @@ TopoDS_Shape XSControl_Utils::ShapeValue( { TopoDS_Shape shape; if (seqval.IsNull()) + { return shape; + } if (num > 0 && num <= seqval->Length()) + { shape = seqval->Value(num); + } return shape; } @@ -583,9 +681,13 @@ occ::handle XSControl_Utils::ShapeBinder(const TopoDS_Shape& const bool hs) const { if (hs) + { return new TopoDS_HShape(shape); + } else + { return new TransferBRep_ShapeBinder(shape); + } } TopoDS_Shape XSControl_Utils::BinderShape(const occ::handle& tr) const @@ -593,13 +695,19 @@ TopoDS_Shape XSControl_Utils::BinderShape(const occ::handle& TopoDS_Shape sh; DeclareAndCast(Transfer_Binder, sb, tr); if (!sb.IsNull()) + { return TransferBRep::ShapeResult(sb); + } DeclareAndCast(TransferBRep_ShapeMapper, sm, tr); if (!sm.IsNull()) + { return sm->Value(); + } DeclareAndCast(TopoDS_HShape, hs, tr); if (!hs.IsNull()) + { return hs->Shape(); + } return sh; } @@ -609,29 +717,45 @@ TopoDS_Shape XSControl_Utils::BinderShape(const occ::handle& int XSControl_Utils::SeqLength(const occ::handle& seqval) const { if (seqval.IsNull()) + { return 0; + } DeclareAndCast(NCollection_HSequence>, seqs, seqval); if (!seqs.IsNull()) + { return seqs->Length(); + } DeclareAndCast(NCollection_HSequence, seqa, seqval); if (!seqa.IsNull()) + { return seqa->Length(); + } DeclareAndCast(NCollection_HSequence>, seqe, seqval); if (!seqe.IsNull()) + { return seqe->Length(); + } DeclareAndCast(NCollection_HSequence>, seqx, seqval); if (!seqx.IsNull()) + { return seqx->Length(); + } DeclareAndCast(NCollection_HSequence>, seqt, seqval); if (!seqt.IsNull()) + { return seqt->Length(); + } DeclareAndCast(NCollection_HSequence, seqh, seqval); if (!seqh.IsNull()) + { return seqh->Length(); + } DeclareAndCast(NCollection_HSequence, seqi, seqval); if (!seqi.IsNull()) + { return seqi->Length(); + } // throw Standard_TypeMismatch("XSControl_Utils::SeqLength"); return 0; } @@ -643,7 +767,9 @@ occ::handle XSControl_Utils::SeqToArr( int i, lng; occ::handle val; if (seqval.IsNull()) + { return val; + } DeclareAndCast(NCollection_HSequence>, seqs, seqval); if (!seqs.IsNull()) { @@ -651,7 +777,9 @@ occ::handle XSControl_Utils::SeqToArr( occ::handle>> arrs = new NCollection_HArray1>(first, lng - first + 1); for (i = 1; i <= lng; i++) + { arrs->SetValue(i - first + 1, seqs->Value(i)); + } return arrs; } DeclareAndCast(NCollection_HSequence>, seqt, seqval); @@ -661,7 +789,9 @@ occ::handle XSControl_Utils::SeqToArr( occ::handle>> arrt = new NCollection_HArray1>(first, lng - first + 1); for (i = 1; i <= lng; i++) + { arrt->SetValue(i - first + 1, seqt->Value(i)); + } return arrt; } throw Standard_TypeMismatch("XSControl_Utils::SeqToArr"); @@ -673,7 +803,9 @@ occ::handle XSControl_Utils::ArrToSeq( int i, first, last; occ::handle val; if (arrval.IsNull()) + { return val; + } DeclareAndCast(NCollection_HArray1>, arrs, arrval); if (!arrs.IsNull()) { @@ -682,7 +814,9 @@ occ::handle XSControl_Utils::ArrToSeq( occ::handle>> seqs = new NCollection_HSequence>(); for (i = first; i <= last; i++) + { seqs->Append(arrs->Value(i)); + } return seqs; } DeclareAndCast(NCollection_HArray1>, arrt, arrval); @@ -693,7 +827,9 @@ occ::handle XSControl_Utils::ArrToSeq( occ::handle>> seqt = new NCollection_HSequence>(); for (i = first; i <= last; i++) + { seqt->Append(arrt->Value(i)); + } return seqt; } throw Standard_TypeMismatch("XSControl_Utils::ArrToSeq"); @@ -703,6 +839,8 @@ int XSControl_Utils::SeqIntValue(const occ::handle>& const int num) const { if (seqval.IsNull()) + { return 0; + } return seqval->Value(num); } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Vars.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Vars.cxx index c535fdd2b4..9c0cfa7d05 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Vars.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Vars.cxx @@ -38,7 +38,9 @@ occ::handle XSControl_Vars::Get(const char*& name) const { occ::handle val; if (!thevars.Find(name, val)) + { val.Nullify(); + } return val; } @@ -71,7 +73,9 @@ bool XSControl_Vars::GetPoint(const char*& name, gp_Pnt& pnt) const { DeclareAndCast(Geom_CartesianPoint, val, Get(name)); if (val.IsNull()) + { return false; + } pnt = val->Pnt(); return true; } @@ -85,7 +89,9 @@ bool XSControl_Vars::GetPoint2d(const char*& name, gp_Pnt2d& pnt) const { DeclareAndCast(Geom2d_CartesianPoint, val, Get(name)); if (val.IsNull()) + { return false; + } pnt = val->Pnt2d(); return true; } @@ -100,6 +106,8 @@ TopoDS_Shape XSControl_Vars::GetShape(const char*& name) const TopoDS_Shape sh; DeclareAndCast(TopoDS_HShape, val, Get(name)); if (!val.IsNull()) + { sh = val->Shape(); + } return sh; } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_WorkSession.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_WorkSession.cxx index 291786669e..ac539fa891 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_WorkSession.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_WorkSession.cxx @@ -60,7 +60,9 @@ void XSControl_WorkSession::ClearData(const int mode) { // 1-2-3-4 : standard IFSelect if (mode >= 1 && mode <= 4) + { IFSelect_WorkSession::ClearData(mode); + } // 5 : Transfers only // 6 : Forced results only @@ -72,7 +74,9 @@ void XSControl_WorkSession::ClearData(const int mode) myTransferWriter->Clear(-1); } if (mode == 6 && !myTransferReader.IsNull()) + { myTransferReader->Clear(1); + } myTransferReader->SetGraph(HGraph()); } @@ -88,9 +92,13 @@ bool XSControl_WorkSession::SelectNorm(const char* const normname) occ::handle newadapt = XSControl_Controller::Recorded(normname); if (newadapt.IsNull()) + { return false; + } if (newadapt == myController) + { return true; + } SetController(newadapt); return true; } @@ -168,15 +176,21 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, if (wri) { if (FP.IsNull()) + { return false; + } if (num == 0) + { return false; + } int ne = 0, nr = 0, max = FP->NbMapped(), maxr = FP->NbRoots(); if (num > 0) { if (num > max) + { return false; + } ne = num; finder = FP->Mapped(ne); nr = FP->RootIndex(finder); @@ -185,7 +199,9 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, { nr = -num; if (nr > maxr) + { return false; + } finder = FP->Root(nr); ne = FP->MapIndex(finder); } @@ -195,9 +211,9 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, { S << " ** Transfer Root n0." << ne; } - S << std::endl; + S << '\n'; ent = FP->FindTransient(finder); - S << " -> Type " << finder->DynamicType()->Name() << std::endl; + S << " -> Type " << finder->DynamicType()->Name() << '\n'; FP->StartTrace(binder, finder, 0, 0); // pb sout/S if (!ent.IsNull()) { @@ -208,7 +224,7 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, S << " In output Model, Entity "; model->Print(ent, S); } - S << std::endl; + S << '\n'; } } @@ -216,20 +232,30 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, else { if (TP.IsNull()) + { return false; + } occ::handle model = TP->Model(); if (model.IsNull()) - std::cout << "No Model" << std::endl; + { + std::cout << "No Model" << '\n'; + } else if (model != Model()) - std::cout << "Model different from the session" << std::endl; + { + std::cout << "Model different from the session" << '\n'; + } if (num == 0) + { return false; + } int ne = 0, nr = 0, max = TP->NbMapped(), maxr = TP->NbRoots(); if (num > 0) { if (num > max) + { return false; + } ne = num; ent = TP->Mapped(ne); nr = TP->RootIndex(finder); @@ -238,7 +264,9 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, { nr = -num; if (nr > maxr) + { return false; + } ent = TP->Root(nr); ne = TP->MapIndex(ent); } @@ -248,14 +276,14 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, { S << " ** Transfer Root n0." << ne; } - S << std::endl; + S << '\n'; if (!model.IsNull()) { S << " In Model, Entity "; model->Print(ent, S); } binder = TP->MapItem(ne); - S << std::endl; + S << '\n'; TP->StartTrace(binder, ent, 0, 0); } @@ -268,13 +296,17 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, { S << " - Warnings : " << nbw << " :\n"; for (i = 1; i <= nbw; i++) - S << ch->CWarning(i) << std::endl; + { + S << ch->CWarning(i) << '\n'; + } } if (nbf > 0) { S << " - Fails : " << nbf << " :\n"; for (i = 1; i <= nbf; i++) - S << ch->CFail(i) << std::endl; + { + S << ch->CFail(i) << '\n'; + } } } return true; @@ -285,19 +317,29 @@ bool XSControl_WorkSession::PrintTransferStatus(const int num, void XSControl_WorkSession::InitTransferReader(const int mode) { if (mode == 0 || mode == 5) + { myTransferReader->Clear(-1); // full clear + } if (myTransferReader.IsNull()) + { SetTransferReader(new XSControl_TransferReader); + } else + { SetTransferReader(myTransferReader); + } // mode = 0 done by SetTransferReader following Nullify if (mode == 1) { if (!myTransferReader.IsNull()) + { myTransferReader->Clear(-1); + } else + { SetTransferReader(new XSControl_TransferReader); + } } if (mode == 2) { @@ -312,33 +354,47 @@ void XSControl_WorkSession::InitTransferReader(const int mode) myTransferReader->RecordedList(); int i, nb = lis->Length(); for (i = 1; i <= nb; i++) + { TP->SetRoot(lis->Value(i)); + } } if (mode == 3) { occ::handle TP = myTransferReader->TransientProcess(); if (TP.IsNull()) + { return; + } int i, nb = TP->NbRoots(); for (i = 1; i <= nb; i++) + { myTransferReader->RecordResult(TP->Root(i)); + } } if (mode == 4 || mode == 5) + { myTransferReader->BeginTransfer(); + } } //================================================================================================= void XSControl_WorkSession::SetTransferReader(const occ::handle& TR) { - if (myTransferReader != TR) // i1 pdn 03.04.99 BUC60301 + if (myTransferReader != TR) + { // i1 pdn 03.04.99 BUC60301 myTransferReader = TR; + } if (TR.IsNull()) + { return; + } TR->SetController(myController); TR->SetGraph(HGraph()); if (!TR->TransientProcess().IsNull()) + { return; + } occ::handle TP = new Transfer_TransientProcess(Model().IsNull() ? 100 : Model()->NbEntities() + 100); TP->SetGraph(HGraph()); @@ -358,12 +414,18 @@ occ::handle XSControl_WorkSession::MapReader() const bool XSControl_WorkSession::SetMapReader(const occ::handle& TP) { if (TP.IsNull()) + { return false; + } if (TP->Model().IsNull()) + { TP->SetModel(Model()); + } TP->SetGraph(HGraph()); if (TP->Model() != Model()) + { return false; + } // TR must not move, it's a "hook" for signatures, selections ... // On the other hand, better to reset it // occ::handle TR = new XSControl_TransferReader; @@ -388,20 +450,32 @@ occ::handle XSControl_WorkSession::Result( occ::handle resu; if (ouca != 1) + { resu = myTransferReader->FinalResult(ent); + } if (mode == 20) + { return resu; + } if (!resu.IsNull()) + { binder = resu->MainResult()->Binder(); + } if (binder.IsNull() && ouca > 0) + { binder = myTransferReader->TransientProcess()->Find(ent); + } if (kica == 1) + { return binder; + } DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, binder); if (!trb.IsNull()) + { return trb->Result(); + } return binder; } @@ -416,13 +490,19 @@ int XSControl_WorkSession::TransferReadOne(const occ::handle { occ::handle model = Model(); if (ent == model) + { return TransferReadRoots(theProgress); + } occ::handle>> list = GiveList(ent); if (list->Length() == 1) + { return myTransferReader->TransferOne(list->Value(1), true, theProgress); + } else + { return myTransferReader->TransferList(list, true, theProgress); + } } //================================================================================================= @@ -443,12 +523,16 @@ occ::handle XSControl_WorkSession::NewModel() const std::lock_guard aLock(GetGlobalMutex()); occ::handle newmod; if (myController.IsNull()) + { return newmod; + } newmod = myController->NewModel(); SetModel(newmod); if (!myTransferReader->TransientProcess().IsNull()) + { myTransferReader->TransientProcess()->Clear(); + } // clear all contains of WS myTransferReader->Clear(3); myTransferWriter->Clear(-1); @@ -466,7 +550,9 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape( const std::lock_guard aLock(GetGlobalMutex()); IFSelect_ReturnStatus status; if (myController.IsNull()) + { return IFSelect_RetError; + } const occ::handle& model = Model(); if (model.IsNull() || shape.IsNull()) { @@ -475,12 +561,16 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape( status = myTransferWriter->TransferWriteShape(model, shape, theProgress); if (theProgress.UserBreak()) + { return IFSelect_RetStop; + } // which takes care of everything, try/catch included // skl insert param compgraph for XDE writing 10.12.2003 if (compgraph) + { ComputeGraph(true); + } return status; } @@ -506,7 +596,9 @@ void XSControl_WorkSession::ClearBinders() { occ::handle bnd = FP->MapItem(i); if (!bnd.IsNull()) + { aSeqBnd.Append(bnd); + } occ::handle ash(FP->Mapped(i)); aSeqShapes.Append(ash); } diff --git a/src/DataExchange/TKXSBase/XSControl/XSControl_Writer.cxx b/src/DataExchange/TKXSBase/XSControl/XSControl_Writer.cxx index f566a66efc..7fde9b080a 100644 --- a/src/DataExchange/TKXSBase/XSControl/XSControl_Writer.cxx +++ b/src/DataExchange/TKXSBase/XSControl/XSControl_Writer.cxx @@ -37,7 +37,9 @@ XSControl_Writer::XSControl_Writer(const occ::handle& WS, bool XSControl_Writer::SetNorm(const char* const norm) { if (thesession.IsNull()) + { SetWS(new XSControl_WorkSession); + } bool sess = thesession->SelectNorm(norm); occ::handle model = Model(); //: i1 gka 03.04.99 BUC60301 return sess; @@ -60,7 +62,9 @@ occ::handle XSControl_Writer::Model(const bool newone) { occ::handle model = thesession->Model(); if (newone || model.IsNull()) + { model = thesession->NewModel(); + } return model; } diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_AssemblyItemRefDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_AssemblyItemRefDriver.cxx index 2a04acbda0..40c0553c91 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_AssemblyItemRefDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_AssemblyItemRefDriver.cxx @@ -49,11 +49,15 @@ bool XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const XmlObjMgt_Persistent& XmlObjMgt_DOMString aPath = anElement.getAttribute(::Path()); if (aPath == nullptr) + { return false; + } occ::handle aThis = occ::down_cast(theTarget); if (aThis.IsNull()) + { return false; + } aThis->SetItem(aPath.GetString()); @@ -70,7 +74,9 @@ bool XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const XmlObjMgt_Persistent& { int anIndex; if (!aSubshapeIndex.GetInteger(anIndex)) + { return false; + } aThis->SetSubshapeIndex(anIndex); return true; diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DatumDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DatumDriver.cxx index 0259cb9625..e52a387895 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DatumDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DatumDriver.cxx @@ -94,11 +94,17 @@ void XmlMXCAFDoc_DatumDriver::Paste(const occ::handle& theSource, XmlObjMgt_DOMString aNameString, aDescrString, anIdString; if (!anAtt->GetName().IsNull()) + { aNameString = anAtt->GetName()->String().ToCString(); + } if (!anAtt->GetDescription().IsNull()) + { aDescrString = anAtt->GetDescription()->String().ToCString(); + } if (!anAtt->GetIdentification().IsNull()) + { anIdString = anAtt->GetIdentification()->String().ToCString(); + } XmlObjMgt::SetStringValue(theTarget, aNameString); theTarget.Element().setAttribute(::DescrIndexString(), aDescrString); diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DimTolDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DimTolDriver.cxx index f2f103c684..7243988f0f 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DimTolDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_DimTolDriver.cxx @@ -80,7 +80,9 @@ bool XmlMXCAFDoc_DimTolDriver::Paste(const XmlObjMgt_Persistent& theSource int aFirstInd, aLastInd; XmlObjMgt_DOMString aFirstIndex = anElement.getAttribute(::FirstIndexString()); if (aFirstIndex == nullptr) + { aFirstInd = 1; + } else if (!aFirstIndex.GetInteger(aFirstInd)) { TCollection_ExtendedString aMessageString( @@ -90,7 +92,9 @@ bool XmlMXCAFDoc_DimTolDriver::Paste(const XmlObjMgt_Persistent& theSource } XmlObjMgt_DOMString aLastIndex = anElement.getAttribute(::LastIndexString()); if (aLastIndex == nullptr) + { aLastInd = 0; + } else if (!aLastIndex.GetInteger(aLastInd)) { TCollection_ExtendedString aMessageString( @@ -141,9 +145,13 @@ void XmlMXCAFDoc_DimTolDriver::Paste(const occ::handle& theSource XmlObjMgt_DOMString aNameString, aDescrString; if (!anAtt->GetName().IsNull()) + { aNameString = anAtt->GetName()->String().ToCString(); + } if (!anAtt->GetDescription().IsNull()) + { aDescrString = anAtt->GetDescription()->String().ToCString(); + } XmlObjMgt::SetStringValue(theTarget, anAtt->GetKind()); theTarget.Element().setAttribute(::NameIndexString(), aNameString); @@ -167,7 +175,9 @@ void XmlMXCAFDoc_DimTolDriver::Paste(const occ::handle& theSource Sprintf(aValueChar, "%.15g", aHArr->Value(i)); aValueStr += aValueChar; if (i < aLastInd) + { aValueStr += ' '; + } } theTarget.Element().setAttribute(::ValueIndexString(), aValueStr.ToCString()); } diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_GraphNodeDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_GraphNodeDriver.cxx index 9a4fda87ee..f8545711d0 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_GraphNodeDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_GraphNodeDriver.cxx @@ -69,7 +69,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou const char* aChildren = static_cast(aDOMStr.GetString()); int aNb = 0; if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { return false; + } while (aNb > 0) { @@ -78,7 +80,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou { aTChild = occ::down_cast(theRelocTable.Find(aNb)); if (aTChild.IsNull()) + { return false; + } } else { @@ -92,7 +96,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou // Get next child ID if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { aNb = 0; + } } } @@ -103,7 +109,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou const char* aChildren = static_cast(aDOMStr.GetString()); int aNb = 0; if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { return false; + } while (aNb > 0) { @@ -112,7 +120,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou { aTChild = occ::down_cast(theRelocTable.Find(aNb)); if (aTChild.IsNull()) + { return false; + } } else { @@ -126,7 +136,9 @@ bool XmlMXCAFDoc_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSou // Get next child ID if (!XmlObjMgt::GetInteger(aChildren, aNb)) + { aNb = 0; + } } } @@ -143,7 +155,9 @@ void XmlMXCAFDoc_GraphNodeDriver::Paste(const occ::handle& theSou { occ::handle aS = occ::down_cast(theSource); if (aS.IsNull()) + { return; + } // graph id char aGuidStr[40]; @@ -174,7 +188,9 @@ void XmlMXCAFDoc_GraphNodeDriver::Paste(const occ::handle& theSou } } if (aStr.Length() > 0) + { theTarget.Element().setAttribute(::FathersString(), aStr.ToCString()); + } // children aStr.Clear(); @@ -193,5 +209,7 @@ void XmlMXCAFDoc_GraphNodeDriver::Paste(const occ::handle& theSou } } if (aStr.Length() > 0) + { theTarget.Element().setAttribute(::ChildrenString(), aStr.ToCString()); + } } diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_LocationDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_LocationDriver.cxx index 9ceed7b894..4fa5401601 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_LocationDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_LocationDriver.cxx @@ -131,7 +131,9 @@ bool XmlMXCAFDoc_LocationDriver::Translate(const XmlObjMgt_Element& theParent { XmlObjMgt_Element aLocElem = XmlObjMgt::FindChildByName(theParent, ::LocationString()); if (aLocElem == nullptr) + { return false; + } int aFileVer = theMap.GetHeaderData()->StorageVersion().IntegerValue(); if (aFileVer >= TDocStd_FormatVersion_VERSION_6 && myLocations == nullptr) @@ -164,9 +166,13 @@ bool XmlMXCAFDoc_LocationDriver::Translate(const XmlObjMgt_Element& theParent int aDatumID; aLocElem.getAttribute(::DatumString()).GetInteger(aDatumID); if (aDatumID > 0 && theMap.IsBound(aDatumID)) + { aDatum = occ::down_cast(theMap.Find(aDatumID)); + } else + { return false; + } } else { diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx index a95cea2513..1162cc47df 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx @@ -102,13 +102,21 @@ void XmlMXCAFDoc_MaterialDriver::Paste(const occ::handle& theSour XmlObjMgt_DOMString aNameString, aDescrString, aDensNameStr, aDensTypeStr; if (!anAtt->GetName().IsNull()) + { aNameString = anAtt->GetName()->String().ToCString(); + } if (!anAtt->GetDescription().IsNull()) + { aDescrString = anAtt->GetDescription()->String().ToCString(); + } if (!anAtt->GetDensName().IsNull()) + { aDensNameStr = anAtt->GetDensName()->String().ToCString(); + } if (!anAtt->GetDensValType().IsNull()) + { aDensTypeStr = anAtt->GetDensValType()->String().ToCString(); + } TCollection_AsciiString aDensityStr(anAtt->GetDensity()); XmlObjMgt::SetStringValue(theTarget, aDensityStr.ToCString()); diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx index 55370b4483..a9a903b45c 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx @@ -55,15 +55,21 @@ bool XmlMXCAFDoc_NoteBinDataDriver::Paste(const XmlObjMgt_Persistent& theS XmlObjMgt_DOMString aMIMEtype = anElement.getAttribute(::MIMEtype()); XmlObjMgt_DOMString aSize = anElement.getAttribute(::Size()); if (aTitle == nullptr || aMIMEtype == nullptr || aSize == nullptr) + { return false; + } occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } int nbSize = 0; if (!aSize.GetInteger(nbSize)) + { return false; + } XmlObjMgt_DOMString aDataStr = XmlObjMgt::GetStringValue(theSource); Standard_SStream anSS(aDataStr.GetString()); diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx index 6920378f9a..f7ab5794c1 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx @@ -49,11 +49,15 @@ bool XmlMXCAFDoc_NoteCommentDriver::Paste(const XmlObjMgt_Persistent& theS XmlObjMgt_DOMString aComment = anElement.getAttribute(::Comment()); if (aComment == nullptr) + { return false; + } occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } aNote->Set(aComment.GetString()); diff --git a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.cxx b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.cxx index 01b4e9ccd3..901b4cfd76 100644 --- a/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.cxx +++ b/src/DataExchange/TKXmlXCAF/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.cxx @@ -42,11 +42,15 @@ bool XmlMXCAFDoc_NoteDriver::Paste(const XmlObjMgt_Persistent& theSource, XmlObjMgt_DOMString aUserName = anElement.getAttribute(::UserName()); XmlObjMgt_DOMString aTimeStamp = anElement.getAttribute(::TimeStamp()); if (aUserName == nullptr || aTimeStamp == nullptr) + { return false; + } occ::handle aNote = occ::down_cast(theTarget); if (aNote.IsNull()) + { return false; + } aNote->Set(aUserName.GetString(), aTimeStamp.GetString()); @@ -61,7 +65,9 @@ void XmlMXCAFDoc_NoteDriver::Paste(const occ::handle& theSource, { occ::handle aNote = occ::down_cast(theSource); if (aNote.IsNull()) + { return; + } XmlObjMgt_DOMString aUserName(TCollection_AsciiString(aNote->UserName()).ToCString()); XmlObjMgt_DOMString aTimeStamp(TCollection_AsciiString(aNote->TimeStamp()).ToCString()); diff --git a/src/Draw/TKDCAF/DDF/DDF.cxx b/src/Draw/TKDCAF/DDF/DDF.cxx index 1578aaedbe..d4b79af06b 100644 --- a/src/Draw/TKDCAF/DDF/DDF.cxx +++ b/src/Draw/TKDCAF/DDF/DDF.cxx @@ -47,7 +47,9 @@ bool DDF::FindLabel(const occ::handle& DF, Label.Nullify(); TDF_Tool::Label(DF, Entry, Label, false); if (Label.IsNull() && Complain) - std::cout << "No label for entry " << Entry << std::endl; + { + std::cout << "No label for entry " << Entry << '\n'; + } return !Label.IsNull(); } @@ -64,7 +66,9 @@ bool DDF::GetDF(const char*& Name, occ::handle& DF, const bool Complai return true; } if (Complain) - std::cout << "framework " << Name << " not found " << std::endl; + { + std::cout << "framework " << Name << " not found " << '\n'; + } return false; } @@ -80,9 +84,13 @@ bool DDF::Find(const occ::handle& DF, if (FindLabel(DF, Entry, L, Complain)) { if (L.FindAttribute(ID, A)) + { return true; + } if (Complain) - std::cout << "attribute not found for entry : " << Entry << std::endl; + { + std::cout << "attribute not found for entry : " << Entry << '\n'; + } } return false; } @@ -103,7 +111,9 @@ void DDF::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DDF::BasicCommands(theCommands); diff --git a/src/Draw/TKDCAF/DDF/DDF_AttributeBrowser.cxx b/src/Draw/TKDCAF/DDF/DDF_AttributeBrowser.cxx index 88ee20ea72..59d93ed26e 100644 --- a/src/Draw/TKDCAF/DDF/DDF_AttributeBrowser.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_AttributeBrowser.cxx @@ -66,7 +66,9 @@ DDF_AttributeBrowser* DDF_AttributeBrowser::FindBrowser(const occ::handleTest(anAtt)) + { break; + } browser = browser->Next(); } return browser; diff --git a/src/Draw/TKDCAF/DDF/DDF_BasicCommands.cxx b/src/Draw/TKDCAF/DDF/DDF_BasicCommands.cxx index be40abb49f..f267c01668 100644 --- a/src/Draw/TKDCAF/DDF/DDF_BasicCommands.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_BasicCommands.cxx @@ -47,17 +47,23 @@ static int DDF_Children(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; TCollection_AsciiString entry; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label lab; if (n == 3) + { TDF_Tool::Label(DF, a[2], lab); + } if (lab.IsNull()) { @@ -83,18 +89,24 @@ static int DDF_Children(Draw_Interpretor& di, int n, const char** a) static int DDF_Attributes(Draw_Interpretor& di, int n, const char** a) { if (n != 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label lab; TDF_Tool::Label(DF, a[2], lab); if (lab.IsNull()) + { return 1; + } for (TDF_AttributeIterator itr(lab); itr.More(); itr.Next()) { @@ -111,18 +123,24 @@ static int DDF_Attributes(Draw_Interpretor& di, int n, const char** a) static int DDF_SetEmptyAttribute(Draw_Interpretor& di, int n, const char** a) { if (n != 4) + { return 1; + } occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label lab; TDF_Tool::Label(DF, a[2], lab); if (lab.IsNull()) + { return 1; + } occ::handle anAttrByType = TDF_DerivedAttribute::Attribute(a[3]); if (anAttrByType.IsNull()) @@ -144,17 +162,23 @@ static int DDF_SetEmptyAttribute(Draw_Interpretor& di, int n, const char** a) static int DDF_ForgetAll(Draw_Interpretor& /*di*/, int n, const char** a) { if (n != 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label label; TDF_Tool::Label(DF, a[2], label); if (label.IsNull()) + { return 1; + } label.ForgetAllAttributes(); // POP pour NT return 0; @@ -168,15 +192,21 @@ static int DDF_ForgetAll(Draw_Interpretor& /*di*/, int n, const char** a) static int DDF_ForgetAttribute(Draw_Interpretor& di, int n, const char** a) { if (n != 4) + { return 1; + } occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label aLabel; TDF_Tool::Label(DF, a[2], aLabel); if (aLabel.IsNull()) + { return 1; + } if (!Standard_GUID::CheckGUIDFormat(a[3])) { // check this may be derived attribute by its type @@ -205,7 +235,9 @@ static int DDF_SetTagger(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); TDF_TagSource::Set(L); @@ -226,10 +258,14 @@ static int DDF_NewTag(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; if (!DDF::Find(DF, arg[2], TDF_TagSource::GetID(), A)) + { return 1; + } di << A->NewTag(); return 0; } @@ -248,7 +284,9 @@ static int DDF_NewChild(Draw_Interpretor& di, int nb, const char** arg) if (nb >= 2) { if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (nb == 2) { TDF_Label free = TDF_TagSource::NewChild(DF->Root()); @@ -259,7 +297,9 @@ static int DDF_NewChild(Draw_Interpretor& di, int nb, const char** arg) { TDF_Label fatherlabel; if (!DDF::FindLabel(DF, arg[2], fatherlabel)) + { return 1; + } TDF_Label free = TDF_TagSource::NewChild(fatherlabel); di << arg[2] << ":" << free.Tag(); return 0; @@ -279,7 +319,9 @@ static int DDF_Label(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L, false)) { @@ -300,7 +342,9 @@ void DDF::BasicCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DF basic commands"; diff --git a/src/Draw/TKDCAF/DDF/DDF_Browser.cxx b/src/Draw/TKDCAF/DDF/DDF_Browser.cxx index afadfa35ed..f0659024b4 100644 --- a/src/Draw/TKDCAF/DDF/DDF_Browser.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_Browser.cxx @@ -69,7 +69,7 @@ occ::handle DDF_Browser::Copy() const void DDF_Browser::Dump(Standard_OStream& S) const { - S << "DDF_Browser on a DF:" << std::endl; + S << "DDF_Browser on a DF:" << '\n'; S << myDF; } @@ -113,7 +113,9 @@ TCollection_AsciiString DDF_Browser::OpenRoot() const list.AssignCat("\""); list.AssignCat(TDF_BrowserSeparator2); if (!root.MayBeModified()) + { list.AssignCat("Not"); + } list.AssignCat("Modified"); list.AssignCat(TDF_BrowserSeparator2); list.AssignCat((root.HasAttribute() || root.HasChild()) ? "1" : "0"); @@ -140,7 +142,9 @@ TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const list.AssignCat("AttributeList"); list.AssignCat(TDF_BrowserSeparator2); if (!aLab.AttributesModified()) + { list.AssignCat("Not"); + } list.AssignCat("Modified"); split = true; } @@ -148,7 +152,9 @@ TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const for (TDF_ChildIterator itr(aLab); itr.More(); itr.Next()) { if (split) + { list.AssignCat(TDF_BrowserSeparator1); + } TDF_Tool::Entry(itr.Value(), entry); list.AssignCat(entry); list.AssignCat(TDF_BrowserSeparator2); @@ -162,7 +168,9 @@ TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const list.AssignCat("\""); list.AssignCat(TDF_BrowserSeparator2); if (!itr.Value().MayBeModified()) + { list.AssignCat("Not"); + } list.AssignCat("Modified"); list.AssignCat(TDF_BrowserSeparator2); // May be open. @@ -187,7 +195,9 @@ TCollection_AsciiString DDF_Browser::OpenAttributeList(const TDF_Label& aLab) for (TDF_AttributeIterator itr(aLab, false); itr.More(); itr.Next()) { if (split1) + { list.AssignCat(TDF_BrowserSeparator1); + } const occ::handle& att = itr.Value(); const int index = myAttMap.Add(att); TCollection_AsciiString indexStr(index); @@ -199,17 +209,23 @@ TCollection_AsciiString DDF_Browser::OpenAttributeList(const TDF_Label& aLab) // Valid. list.AssignCat(TDF_BrowserSeparator2); if (!att->IsValid()) + { list.AssignCat("Not"); + } list.AssignCat("Valid"); // Forgotten. list.AssignCat(TDF_BrowserSeparator2); if (!att->IsForgotten()) + { list.AssignCat("Not"); + } list.AssignCat("Forgotten"); // Backuped. list.AssignCat(TDF_BrowserSeparator2); if (!att->IsBackuped()) + { list.AssignCat("Not"); + } list.AssignCat("Backuped"); // May be open. list.AssignCat(TDF_BrowserSeparator2); @@ -231,7 +247,9 @@ TCollection_AsciiString DDF_Browser::OpenAttribute(const int anIndex) occ::handle att = myAttMap.FindKey(anIndex); DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att); if (br) + { list = br->Open(att); + } return list; } diff --git a/src/Draw/TKDCAF/DDF/DDF_BrowserCommands.cxx b/src/Draw/TKDCAF/DDF/DDF_BrowserCommands.cxx index 48bbd8f4fe..8578c6d0df 100644 --- a/src/Draw/TKDCAF/DDF/DDF_BrowserCommands.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_BrowserCommands.cxx @@ -90,7 +90,9 @@ static int DFBrowse(Draw_Interpretor& di, int n, const char** a) static int DFOpenLabel(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle browser = occ::down_cast(Draw::GetExisting(a[1])); if (browser.IsNull()) @@ -101,7 +103,9 @@ static int DFOpenLabel(Draw_Interpretor& di, int n, const char** a) TDF_Label lab; if (n == 3) + { TDF_Tool::Label(browser->Data(), a[2], lab); + } TCollection_AsciiString list(lab.IsNull() ? browser->OpenRoot() : browser->OpenLabel(lab)); di << list.ToCString(); @@ -118,7 +122,9 @@ static int DFOpenLabel(Draw_Interpretor& di, int n, const char** a) static int DFOpenAttributeList(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle browser = occ::down_cast(Draw::GetExisting(a[1])); if (browser.IsNull()) @@ -131,7 +137,9 @@ static int DFOpenAttributeList(Draw_Interpretor& di, int n, const char** a) TDF_Tool::Label(browser->Data(), a[2], lab); if (lab.IsNull()) + { return 1; + } TCollection_AsciiString list(browser->OpenAttributeList(lab)); di << list.ToCString(); @@ -148,7 +156,9 @@ static int DFOpenAttributeList(Draw_Interpretor& di, int n, const char** a) static int DFOpenAttribute(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle browser = occ::down_cast(Draw::GetExisting(a[1])); if (browser.IsNull()) @@ -171,7 +181,9 @@ void DDF::BrowserCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DF browser commands"; diff --git a/src/Draw/TKDCAF/DDF/DDF_Data.cxx b/src/Draw/TKDCAF/DDF/DDF_Data.cxx index 82bc14afb4..c0802bc2bc 100644 --- a/src/Draw/TKDCAF/DDF/DDF_Data.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_Data.cxx @@ -42,7 +42,7 @@ DDF_Data::DDF_Data(const occ::handle& aDF) void DDF_Data::DrawOn(Draw_Display& /*dis*/) const { - std::cout << "DDF_Data" << std::endl; + std::cout << "DDF_Data" << '\n'; } //================================================================================================= diff --git a/src/Draw/TKDCAF/DDF/DDF_DataCommands.cxx b/src/Draw/TKDCAF/DDF/DDF_DataCommands.cxx index a7b1d8edc9..9d85791326 100644 --- a/src/Draw/TKDCAF/DDF/DDF_DataCommands.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_DataCommands.cxx @@ -48,7 +48,9 @@ static int MakeDF(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D = Draw::Get(a[1]); occ::handle NewDDF; @@ -76,7 +78,9 @@ static int ClearDF(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D = Draw::Get(a[1]); occ::handle DDF; @@ -107,7 +111,9 @@ static int ClearDF(Draw_Interpretor& di, int n, const char** a) static int CopyDF(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 4 || n > 5) + { return 1; + } occ::handle DF1; occ::handle DF2; @@ -115,7 +121,9 @@ static int CopyDF(Draw_Interpretor& /*di*/, int n, const char** a) const char* Entry2; if (!DDF::GetDF(a[1], DF1)) + { return 1; + } Entry1 = a[2]; Entry2 = a[3]; @@ -128,13 +136,17 @@ static int CopyDF(Draw_Interpretor& /*di*/, int n, const char** a) else if (n == 5) { if (!DDF::GetDF(a[3], DF2)) + { return 1; + } Entry2 = a[4]; } TDF_Label Label1; if (!DDF::FindLabel(DF1, Entry1, Label1)) + { return 1; + } TDF_Label Label2; if (!DDF::FindLabel(DF2, Entry2, Label2, false)) @@ -157,7 +169,9 @@ static int CopyDF(Draw_Interpretor& /*di*/, int n, const char** a) static int MiniDumpDF(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; occ::handle DDF; @@ -197,7 +211,9 @@ static int MiniDumpDF(Draw_Interpretor& di, int n, const char** a) static int XDumpDF(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; occ::handle DDF; @@ -242,9 +258,13 @@ static int CopyLabel_SCopy(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } if (!DDF::FindLabel(DF, a[2], SOURCE)) + { return 1; + } if (DDF::FindLabel(DF, a[3], TARGET)) { di << " target label is already set \n"; @@ -255,7 +275,9 @@ static int CopyLabel_SCopy(Draw_Interpretor& di, int n, const char** a) cop.Load(SOURCE, TARGET); cop.Perform(); if (!cop.IsDone()) + { di << "copy not done\n"; + } return 0; } di << "DDF_CopyLabel : Error\n"; @@ -276,11 +298,17 @@ static int DDF_CheckAttrs(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } if (!DDF::FindLabel(DF, a[2], SOURCE)) + { return 1; + } if (!DDF::FindLabel(DF, a[3], TARGET)) + { return 1; + } occ::handle ds1 = new TDF_DataSet(); occ::handle ds2 = new TDF_DataSet(); @@ -311,6 +339,7 @@ static int DDF_CheckAttrs(Draw_Interpretor& di, int n, const char** a) // std::cout<<"\t\t\t\tTarget reference attribute dynamic type = //"<DynamicType()<IsInstance(sAtt->DynamicType())) + { if (tAtt == sAtt) { TCollection_AsciiString entr1, entr2; @@ -330,6 +359,7 @@ static int DDF_CheckAttrs(Draw_Interpretor& di, int n, const char** a) di << "\tAttribute dynamic type = " << sAtt->DynamicType()->Name(); di << ",\tlocated on Label = " << entr1.ToCString() << "\n"; } + } } ds2->Clear(); } @@ -337,7 +367,9 @@ static int DDF_CheckAttrs(Draw_Interpretor& di, int n, const char** a) ds1->Clear(); } if (!Shar) + { di << "Shareable attributes not found\n"; + } return 0; } di << "DDF_CheckAttrs : Error\n"; @@ -357,9 +389,13 @@ static int DDF_CheckLabel(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } if (!DDF::FindLabel(DF, a[2], SOURCE)) + { return 1; + } occ::handle ds1 = new TDF_DataSet(); for (TDF_AttributeIterator itr(SOURCE); itr.More(); itr.Next()) @@ -424,7 +460,9 @@ void DDF::DataCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DF Data Framework commands"; diff --git a/src/Draw/TKDCAF/DDF/DDF_TransactionCommands.cxx b/src/Draw/TKDCAF/DDF/DDF_TransactionCommands.cxx index fda7206513..34184a70f8 100644 --- a/src/Draw/TKDCAF/DDF/DDF_TransactionCommands.cxx +++ b/src/Draw/TKDCAF/DDF/DDF_TransactionCommands.cxx @@ -41,7 +41,9 @@ static occ::handle DDF_LastDelta; static int OpenTran(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; if (DDF::GetDF(a[1], DF)) @@ -58,7 +60,9 @@ static int OpenTran(Draw_Interpretor& di, int n, const char** a) static int AbortTran(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; if (DDF::GetDF(a[1], DF)) @@ -83,7 +87,9 @@ static int AbortTran(Draw_Interpretor& di, int n, const char** a) static int CommitTran(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; if (DDF::GetDF(a[1], DF)) @@ -94,7 +100,9 @@ static int CommitTran(Draw_Interpretor& di, int n, const char** a) di << "Commit transaction # " << tr->Transaction() << " # " << DF->Transaction() << "\n"; bool withDelta = false; if (n > 2) + { withDelta = (Draw::Atoi(a[2]) != 0); + } DDF_LastDelta = tr->Commit(withDelta); DDF_TStack.RemoveFirst(); } @@ -111,15 +119,21 @@ static int CommitTran(Draw_Interpretor& di, int n, const char** a) static int CurrentTran(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; if (DDF::GetDF(a[1], DF)) { di << "# " << DF->Transaction() << "\n"; if (!DDF_TStack.IsEmpty()) + { if (DF->Transaction() != DDF_TStack.First()->Transaction()) + { di << "Transaction object said # " << DDF_TStack.First()->Transaction() << "\n"; + } + } } return 0; } @@ -133,14 +147,18 @@ static int CurrentTran(Draw_Interpretor& di, int n, const char** a) static int Undo(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle DF; if (DDF::GetDF(a[1], DF)) { bool withDelta = false; if (n > 2) + { withDelta = (Draw::Atoi(a[2]) != 0); + } if (!DDF_LastDelta.IsNull()) { if (DF->IsApplicable(DDF_LastDelta)) @@ -176,7 +194,9 @@ void DDF::TransactionCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DF transaction and undo commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd.cxx index 7543940e37..5df07f4bf5 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd.cxx @@ -67,10 +67,14 @@ void DDataStd::DumpConstraint(const occ::handle& CTR, Stand TDataStd::Print(t, anOS); double val = CTR->GetValue()->Get(); if (t == TDataStd_ANGULAR) + { val = (180. * val) / M_PI; + } Standard_ENABLE_DEPRECATION_WARNINGS anOS << " "; anOS << val; } if (!CTR->Verified()) + { anOS << " NotVerifed"; + } } diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_BasicCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_BasicCommands.cxx index 2476ffe760..7b4ae2e15d 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_BasicCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_BasicCommands.cxx @@ -87,11 +87,15 @@ static int DDataStd_SetInteger(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); if (nb == 4) + { TDataStd_Integer::Set(L, Draw::Atoi(arg[3])); + } else { if (!Standard_GUID::CheckGUIDFormat(arg[4])) @@ -119,11 +123,15 @@ static int DDataStd_SetReal(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); if (nb == 4) + { TDataStd_Real::Set(L, Draw::Atof(arg[3])); + } else { if (!Standard_GUID::CheckGUIDFormat(arg[4])) @@ -151,12 +159,16 @@ static int DDataStd_SetReference(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); TDF_Label LREF; if (!DDF::FindLabel(DF, arg[3], LREF)) + { return 1; + } TDF_Reference::Set(L, LREF); return 0; } @@ -175,7 +187,9 @@ static int DDataStd_SetComment(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); TDataStd_Comment::Set(L, TCollection_ExtendedString(arg[3], true)); @@ -196,7 +210,9 @@ static int DDataStd_GetInteger(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; Standard_GUID aGuid; Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000"); @@ -206,7 +222,9 @@ static int DDataStd_GetInteger(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { // DF, entry, guid if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } } if (aGuid == aNullGuid) { @@ -218,7 +236,9 @@ static int DDataStd_GetInteger(Draw_Interpretor& di, int nb, const char** arg) { isdrawname = true; if (Standard_GUID::CheckGUIDFormat(arg[4])) + { aGuid = Standard_GUID(arg[4]); + } else { di << "DDataStd_GetInteger: The format of GUID is invalid\n"; @@ -227,11 +247,17 @@ static int DDataStd_GetInteger(Draw_Interpretor& di, int nb, const char** arg) } if (!DDF::Find(DF, arg[2], aGuid, A)) + { return 1; + } if (nb == 4 && isdrawname) + { Draw::Set(arg[3], A->Get()); + } else + { Draw::Set(arg[2], A->Get()); + } di << A->Get(); return 0; } @@ -250,7 +276,9 @@ static int DDataStd_GetReal(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; Standard_GUID aGuid; Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000"); @@ -260,7 +288,9 @@ static int DDataStd_GetReal(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } } if (aGuid == aNullGuid) { @@ -272,7 +302,9 @@ static int DDataStd_GetReal(Draw_Interpretor& di, int nb, const char** arg) { isdrawname = true; if (Standard_GUID::CheckGUIDFormat(arg[4])) + { aGuid = Standard_GUID(arg[4]); + } else { di << "DDataStd_GetReal: The format of GUID is invalid\n"; @@ -280,11 +312,17 @@ static int DDataStd_GetReal(Draw_Interpretor& di, int nb, const char** arg) } } if (!DDF::Find(DF, arg[2], aGuid, A)) + { return 1; + } if (nb == 4 && isdrawname) + { Draw::Set(arg[3], A->Get()); + } else + { Draw::Set(arg[2], A->Get()); + } di << A->Get(); return 0; } @@ -303,10 +341,14 @@ static int DDataStd_GetReference(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle REF; if (!DDF::Find(DF, arg[2], TDF_Reference::GetID(), REF)) + { return 1; + } TCollection_AsciiString entry; TDF_Tool::Entry(REF->Get(), entry); di << entry.ToCString(); @@ -327,10 +369,14 @@ static int DDataStd_GetComment(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; if (!DDF::Find(DF, arg[2], TDataStd_Comment::GetID(), A)) + { return 1; + } di << A->Get(); return 0; } @@ -350,10 +396,14 @@ static int DDataStd_Self(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } // TDataStd::MakeSelfContained(L,removed); // if (removed.IsEmpty()) std::cout << "no attribute removed" << std::endl; // for (NCollection_List>::Iterator @@ -398,7 +448,9 @@ static int DDataStd_SetUAttribute(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -420,7 +472,9 @@ static int DDataStd_GetUAttribute(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -491,7 +545,9 @@ static int DDataStd_SetIntArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); bool isDelta = Draw::Atoi(arg[3]) != 0; @@ -510,7 +566,9 @@ static int DDataStd_SetIntArray(Draw_Interpretor& di, int nb, const char** arg) } int j(4); if (isGuid) + { j = 6; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() || !TCollection_AsciiString(arg[j + 1]).IsIntegerValue()) @@ -522,9 +580,13 @@ static int DDataStd_SetIntArray(Draw_Interpretor& di, int nb, const char** arg) di << "Array of int with bounds from = " << From << " to = " << To << "\n"; occ::handle A; if (!isGuid) + { A = TDataStd_IntegerArray::Set(label, From, To, isDelta); + } else + { A = TDataStd_IntegerArray::Set(label, guid, From, To, isDelta); + } if ((!isGuid && nb > 6) || (isGuid && nb > 8)) { @@ -549,12 +611,16 @@ static int DDataStd_SetIntArrayValue(Draw_Interpretor&, int, const char** arg) // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -581,7 +647,9 @@ static int DDataStd_GetIntArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -592,7 +660,9 @@ static int DDataStd_GetIntArray(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -600,7 +670,9 @@ static int DDataStd_GetIntArray(Draw_Interpretor& di, int nb, const char** arg) } } else + { aGuid = TDataStd_IntegerArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) { @@ -612,7 +684,9 @@ static int DDataStd_GetIntArray(Draw_Interpretor& di, int nb, const char** arg) { di << A->Value(i); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -628,7 +702,9 @@ static int DDataStd_GetIntArrayValue(Draw_Interpretor& di, int, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -668,7 +744,9 @@ static int DDataStd_ChangeIntArray(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -686,7 +764,9 @@ static int DDataStd_ChangeIntArray(Draw_Interpretor& di, int nb, const char** ar int val = Draw::Atoi(arg[4]); int low = A->Lower(), up = A->Upper(); if (low <= indx && indx <= up) + { A->SetValue(indx, val); + } else { occ::handle> Arr = A->Array(); @@ -697,13 +777,19 @@ static int DDataStd_ChangeIntArray(Draw_Interpretor& di, int nb, const char** ar up = indx; arr = new NCollection_HArray1(low, up); for (i = low; i <= Arr->Upper(); i++) + { arr->SetValue(i, Arr->Value(i)); + } for (i = Arr->Upper() + 1; i <= up; i++) { if (i == up) + { arr->SetValue(i, val); + } else + { arr->SetValue(i, 0); + } } } else if (indx < up) @@ -711,7 +797,9 @@ static int DDataStd_ChangeIntArray(Draw_Interpretor& di, int nb, const char** ar up = abs(indx); arr = new NCollection_HArray1(low, up); for (i = low; i < up; i++) + { arr->SetValue(i, Arr->Value(i)); + } arr->SetValue(up, val); } A->ChangeArray(arr); @@ -731,7 +819,9 @@ static int DDataStd_SetIntArrayTest(Draw_Interpretor& di, int, const char** arg) occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); bool isDelta = Draw::Atoi(arg[3]) != 0; @@ -757,7 +847,9 @@ static int DDataStd_SetRealArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); bool isDelta = Draw::Atoi(arg[3]) != 0; @@ -776,7 +868,9 @@ static int DDataStd_SetRealArray(Draw_Interpretor& di, int nb, const char** arg) } int j(4); if (isGuid) + { j = 6; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() || !TCollection_AsciiString(arg[j + 1]).IsIntegerValue()) @@ -788,9 +882,13 @@ static int DDataStd_SetRealArray(Draw_Interpretor& di, int nb, const char** arg) di << " Array of double with bounds from = " << From << " to = " << To << "\n"; occ::handle A; if (!isGuid) + { A = TDataStd_RealArray::Set(label, From, To, isDelta); + } else + { A = TDataStd_RealArray::Set(label, guid, From, To, isDelta); + } if ((!isGuid && nb > 6) || (isGuid && nb > 8)) { j = j + 2; @@ -814,12 +912,16 @@ static int DDataStd_SetRealArrayValue(Draw_Interpretor&, int, const char** arg) // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -845,7 +947,9 @@ static int DDataStd_GetRealArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -856,7 +960,9 @@ static int DDataStd_GetRealArray(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -864,7 +970,9 @@ static int DDataStd_GetRealArray(Draw_Interpretor& di, int nb, const char** arg) } } else + { aGuid = TDataStd_RealArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -883,7 +991,9 @@ static int DDataStd_GetRealArray(Draw_Interpretor& di, int nb, const char** arg) #endif di << A->Value(i); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -899,7 +1009,9 @@ static int DDataStd_GetRealArrayValue(Draw_Interpretor& di, int, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -939,7 +1051,9 @@ static int DDataStd_ChangeRealArray(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -957,7 +1071,9 @@ static int DDataStd_ChangeRealArray(Draw_Interpretor& di, int nb, const char** a double val = Draw::Atof(arg[4]); int low = A->Lower(), up = A->Upper(); if (low <= indx && indx <= up) + { A->SetValue(indx, val); + } else { occ::handle> Arr = A->Array(); @@ -968,13 +1084,19 @@ static int DDataStd_ChangeRealArray(Draw_Interpretor& di, int nb, const char** a up = indx; arr = new NCollection_HArray1(low, up); for (i = low; i <= Arr->Upper(); i++) + { arr->SetValue(i, Arr->Value(i)); + } for (i = Arr->Upper() + 1; i <= up; i++) { if (i == up) + { arr->SetValue(i, val); + } else + { arr->SetValue(i, 0); + } } } else if (indx < up) @@ -982,7 +1104,9 @@ static int DDataStd_ChangeRealArray(Draw_Interpretor& di, int nb, const char** a up = abs(indx); arr = new NCollection_HArray1(low, up); for (i = low; i < up; i++) + { arr->SetValue(i, Arr->Value(i)); + } arr->SetValue(up, val); } A->ChangeArray(arr); @@ -1002,7 +1126,9 @@ static int DDataStd_SetVariable(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1028,7 +1154,9 @@ static int DDataStd_GetVariable(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1058,7 +1186,9 @@ static int DDataStd_SetRelation(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1096,7 +1226,9 @@ static int DDataStd_DumpRelation(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -1145,7 +1277,9 @@ static int DDataStd_SetFunction(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1171,7 +1305,9 @@ static int DDataStd_GetFunction(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -1208,7 +1344,9 @@ static int DDataStd_SetExtStringArray(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); bool isDelta = Draw::Atoi(arg[3]) != 0; @@ -1228,7 +1366,9 @@ static int DDataStd_SetExtStringArray(Draw_Interpretor& di, int nb, const char** } int j(4); if (isGuid) + { j = 6; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() || !TCollection_AsciiString(arg[j + 1]).IsIntegerValue()) @@ -1240,9 +1380,13 @@ static int DDataStd_SetExtStringArray(Draw_Interpretor& di, int nb, const char** di << "Array of ExtString with bounds from = " << From << " to = " << To << "\n"; occ::handle A; if (!isGuid) + { A = TDataStd_ExtStringArray::Set(label, From, To, isDelta); + } else + { A = TDataStd_ExtStringArray::Set(label, guid, From, To, isDelta); + } if ((!isGuid && nb > 6) || (isGuid && nb > 8)) { @@ -1268,12 +1412,16 @@ static int DDataStd_SetExtStringArrayValue(Draw_Interpretor&, int, const char** // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -1300,7 +1448,9 @@ static int DDataStd_GetExtStringArray(Draw_Interpretor& di, int nb, const char** occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -1311,7 +1461,9 @@ static int DDataStd_GetExtStringArray(Draw_Interpretor& di, int nb, const char** if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -1319,7 +1471,9 @@ static int DDataStd_GetExtStringArray(Draw_Interpretor& di, int nb, const char** } } else + { aGuid = TDataStd_ExtStringArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) { @@ -1331,7 +1485,9 @@ static int DDataStd_GetExtStringArray(Draw_Interpretor& di, int nb, const char** { di << A->Value(i); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -1347,7 +1503,9 @@ static int DDataStd_GetExtStringArrayValue(Draw_Interpretor& di, int, const char { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -1388,7 +1546,9 @@ static int DDataStd_ChangeExtStrArray(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -1406,7 +1566,9 @@ static int DDataStd_ChangeExtStrArray(Draw_Interpretor& di, int nb, const char** TCollection_ExtendedString val(arg[4]); int low = A->Lower(), up = A->Upper(); if (low <= indx && indx <= up) + { A->SetValue(indx, val); // NCollection_HArray1 + } else { occ::handle> Arr = A->Array(); @@ -1417,13 +1579,19 @@ static int DDataStd_ChangeExtStrArray(Draw_Interpretor& di, int nb, const char** up = indx; arr = new NCollection_HArray1(low, up); for (i = low; i <= Arr->Upper(); i++) + { arr->SetValue(i, Arr->Value(i)); + } for (i = Arr->Upper() + 1; i <= up; i++) { if (i == up) + { arr->SetValue(i, val); + } else + { arr->SetValue(i, 0); + } } } else if (indx < up) @@ -1431,7 +1599,9 @@ static int DDataStd_ChangeExtStrArray(Draw_Interpretor& di, int nb, const char** up = abs(indx); arr = new NCollection_HArray1(low, up); for (i = low; i < up; i++) + { arr->SetValue(i, Arr->Value(i)); + } arr->SetValue(up, val); } A->ChangeArray(arr); @@ -1452,7 +1622,9 @@ static int DDataStd_KeepUTF(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); const char* aFileName(arg[3]); @@ -1501,10 +1673,14 @@ static int DDataStd_GetUTFtoFile(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } TCollection_ExtendedString aES; bool aF = false; @@ -1520,7 +1696,9 @@ static int DDataStd_GetUTFtoFile(Draw_Interpretor& di, int nb, const char** arg) if (anAtt->Get().Length()) { if (aF) + { aES += '\n'; + } aES += anAtt->Get(); aF = true; } @@ -1571,7 +1749,9 @@ static int DDataStd_SetByteArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); bool isDelta = Draw::Atoi(arg[3]) != 0; @@ -1590,7 +1770,9 @@ static int DDataStd_SetByteArray(Draw_Interpretor& di, int nb, const char** arg) } int j(4); if (isGuid) + { j = 6; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() || !TCollection_AsciiString(arg[j + 1]).IsIntegerValue()) @@ -1602,9 +1784,13 @@ static int DDataStd_SetByteArray(Draw_Interpretor& di, int nb, const char** arg) di << "Array of uint8_t with bounds from = " << From << " to = " << To << "\n"; occ::handle A; if (!isGuid) + { A = TDataStd_ByteArray::Set(label, From, To, isDelta); + } else + { A = TDataStd_ByteArray::Set(label, guid, From, To, isDelta); + } if ((!isGuid && nb > 6) || (isGuid && nb > 8)) { @@ -1635,12 +1821,16 @@ static int DDataStd_SetByteArrayValue(Draw_Interpretor&, int, const char** arg) // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -1673,7 +1863,9 @@ static int DDataStd_SetBooleanArray(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1692,7 +1884,9 @@ static int DDataStd_SetBooleanArray(Draw_Interpretor& di, int nb, const char** a } int j(3); if (isGuid) + { j = 5; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() || !TCollection_AsciiString(arg[j + 1]).IsIntegerValue()) @@ -1704,9 +1898,13 @@ static int DDataStd_SetBooleanArray(Draw_Interpretor& di, int nb, const char** a di << "Array of bool with bounds from = " << From << " to = " << To << "\n"; occ::handle A; if (!isGuid) + { A = TDataStd_BooleanArray::Set(label, From, To); + } else + { A = TDataStd_BooleanArray::Set(label, guid, From, To); + } if ((!isGuid && nb > 5) || (isGuid && nb > 7)) { @@ -1737,12 +1935,16 @@ static int DDataStd_SetBooleanArrayValue(Draw_Interpretor& di, int, const char** // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -1775,7 +1977,9 @@ static int DDataStd_SetExtStringList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1828,7 +2032,9 @@ static int DDataStd_SetReferenceList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1865,7 +2071,9 @@ static int DDataStd_SetReferenceList(Draw_Interpretor& di, int nb, const char** TDF_Label aValueLabel; DDF::AddLabel(DF, arg[i], aValueLabel); if (aValueLabel.IsNull()) + { continue; + } A->Append(aValueLabel); } return 0; @@ -1883,7 +2091,9 @@ static int DDataStd_SetBooleanList(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1940,7 +2150,9 @@ static int DDataStd_SetIntegerList(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -1992,7 +2204,9 @@ static int DDataStd_SetRealList(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); @@ -2044,22 +2258,30 @@ static int DDataStd_InsertBeforeExtStringList(Draw_Interpretor& di, int nb, cons { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); TCollection_ExtendedString value = arg[4]; if (A->InsertBefore(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertBeforeExtStringList: Error\n"; return 1; @@ -2074,22 +2296,30 @@ static int DDataStd_InsertAfterExtStringList(Draw_Interpretor& di, int nb, const { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); TCollection_ExtendedString value = arg[4]; if (A->InsertAfter(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertAfterExtStringList: Error\n"; return 1; @@ -2104,21 +2334,29 @@ static int DDataStd_RemoveExtStringList(Draw_Interpretor& di, int nb, const char { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); if (A->Remove(index)) + { return 0; + } else + { return 1; + } } di << "DDataStd_RemoveExtStringList: Error\n"; return 1; @@ -2133,22 +2371,30 @@ static int DDataStd_InsertBeforeBooleanList(Draw_Interpretor& di, int nb, const { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); bool value = Draw::Atoi(arg[4]) != 0; if (A->InsertBefore(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertBeforeBooleanList: Error\n"; return 1; @@ -2163,22 +2409,30 @@ static int DDataStd_InsertAfterBooleanList(Draw_Interpretor& di, int nb, const c { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); bool value = Draw::Atoi(arg[4]) != 0; if (A->InsertAfter(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertAfterBooleanList: Error\n"; return 1; @@ -2193,21 +2447,29 @@ static int DDataStd_RemoveBooleanList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); if (A->Remove(index)) + { return 0; + } else + { return 1; + } } di << "DDataStd_RemoveBooleanList: Error\n"; return 1; @@ -2222,22 +2484,30 @@ static int DDataStd_InsertBeforeIntegerList(Draw_Interpretor& di, int nb, const { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); int value = (int)Draw::Atoi(arg[4]); if (A->InsertBeforeByIndex(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertBeforeIntegerList: Error\n"; return 1; @@ -2252,22 +2522,30 @@ static int DDataStd_InsertAfterIntegerList(Draw_Interpretor& di, int nb, const c { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); int value = (int)Draw::Atoi(arg[4]); if (A->InsertAfterByIndex(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertAfterIntegerList: Error\n"; return 1; @@ -2282,21 +2560,29 @@ static int DDataStd_RemoveIntegerList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); if (A->RemoveByIndex(index)) + { return 0; + } else + { return 1; + } } di << "DDataStd_RemoveIntegerList: Error\n"; return 1; @@ -2311,22 +2597,30 @@ static int DDataStd_InsertBeforeRealList(Draw_Interpretor& di, int nb, const cha { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_RealList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); double value = (double)Draw::Atof(arg[4]); if (A->InsertBeforeByIndex(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertBeforeRealList: Error\n"; return 1; @@ -2341,22 +2635,30 @@ static int DDataStd_InsertAfterRealList(Draw_Interpretor& di, int nb, const char { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_RealList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); double value = (double)Draw::Atof(arg[4]); if (A->InsertAfterByIndex(index, value)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertAfterRealList: Error\n"; return 1; @@ -2371,21 +2673,29 @@ static int DDataStd_RemoveRealList(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_RealList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); if (A->RemoveByIndex(index)) + { return 0; + } else + { return 1; + } } di << "DDataStd_RemoveRealList: Error\n"; return 1; @@ -2400,25 +2710,35 @@ static int DDataStd_InsertBeforeReferenceList(Draw_Interpretor& di, int nb, cons { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); TDF_Label refLabel; if (!DDF::AddLabel(DF, arg[4], refLabel)) + { return 1; + } if (A->InsertBefore(index, refLabel)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertBeforeReferenceList: Error\n"; return 1; @@ -2433,25 +2753,35 @@ static int DDataStd_InsertAfterReferenceList(Draw_Interpretor& di, int nb, const { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); TDF_Label refLabel; if (!DDF::AddLabel(DF, arg[4], refLabel)) + { return 1; + } if (A->InsertAfter(index, refLabel)) + { return 0; + } else + { return 1; + } } di << "DDataStd_InsertAfterReferenceList: Error\n"; return 1; @@ -2466,21 +2796,29 @@ static int DDataStd_RemoveReferenceList(Draw_Interpretor& di, int nb, const char { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); occ::handle A; if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A)) + { return 1; + } int index = Draw::Atoi(arg[3]); if (A->Remove(index)) + { return 0; + } else + { return 1; + } } di << "DDataStd_RemoveReferenceList: Error\n"; return 1; @@ -2495,7 +2833,9 @@ static int DDataStd_GetByteArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -2506,7 +2846,9 @@ static int DDataStd_GetByteArray(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2514,7 +2856,9 @@ static int DDataStd_GetByteArray(Draw_Interpretor& di, int nb, const char** arg) } } else + { aGuid = TDataStd_ByteArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) { @@ -2526,7 +2870,9 @@ static int DDataStd_GetByteArray(Draw_Interpretor& di, int nb, const char** arg) { di << A->Value(i); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -2542,7 +2888,9 @@ static int DDataStd_GetByteArrayValue(Draw_Interpretor& di, int, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2581,7 +2929,9 @@ static int DDataStd_GetBooleanArray(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2593,7 +2943,9 @@ static int DDataStd_GetBooleanArray(Draw_Interpretor& di, int nb, const char** a if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2601,7 +2953,9 @@ static int DDataStd_GetBooleanArray(Draw_Interpretor& di, int nb, const char** a } } else + { aGuid = TDataStd_BooleanArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -2614,7 +2968,9 @@ static int DDataStd_GetBooleanArray(Draw_Interpretor& di, int nb, const char** a { di << (int)A->Value(i); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -2630,7 +2986,9 @@ static int DDataStd_GetBooleanArrayValue(Draw_Interpretor& di, int, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2670,7 +3028,9 @@ static int DDataStd_ChangeByteArray(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -2693,7 +3053,9 @@ static int DDataStd_ChangeByteArray(Draw_Interpretor& di, int nb, const char** a } int low = A->Lower(), up = A->Upper(); if (low <= indx && indx <= up) + { A->SetValue(indx, (uint8_t)ival); + } else { occ::handle> Arr = A->InternalArray(); @@ -2704,13 +3066,19 @@ static int DDataStd_ChangeByteArray(Draw_Interpretor& di, int nb, const char** a up = indx; arr = new NCollection_HArray1(low, up); for (i = low; i <= Arr->Upper(); i++) + { arr->SetValue(i, Arr->Value(i)); + } for (i = Arr->Upper() + 1; i <= up; i++) { if (i == up) + { arr->SetValue(i, (uint8_t)ival); + } else + { arr->SetValue(i, 0); + } } } else if (indx < up) @@ -2718,7 +3086,9 @@ static int DDataStd_ChangeByteArray(Draw_Interpretor& di, int nb, const char** a up = abs(indx); arr = new NCollection_HArray1(low, up); for (i = low; i < up; i++) + { arr->SetValue(i, Arr->Value(i)); + } arr->SetValue(up, (uint8_t)ival); } A->ChangeArray(arr); @@ -2738,7 +3108,9 @@ static int DDataStd_GetBooleanList(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2750,7 +3122,9 @@ static int DDataStd_GetBooleanList(Draw_Interpretor& di, int nb, const char** ar if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2758,7 +3132,9 @@ static int DDataStd_GetBooleanList(Draw_Interpretor& di, int nb, const char** ar } } else + { aGuid = TDataStd_BooleanList::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -2779,7 +3155,9 @@ static int DDataStd_GetBooleanList(Draw_Interpretor& di, int nb, const char** ar di << "\n"; } else + { di << "List is empty\n"; + } return 0; } di << "DDataStd_GetBooleanList: Error\n"; @@ -2795,7 +3173,9 @@ static int DDataStd_GetIntegerList(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2807,7 +3187,9 @@ static int DDataStd_GetIntegerList(Draw_Interpretor& di, int nb, const char** ar if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2815,7 +3197,9 @@ static int DDataStd_GetIntegerList(Draw_Interpretor& di, int nb, const char** ar } } else + { aGuid = TDataStd_IntegerList::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -2836,7 +3220,9 @@ static int DDataStd_GetIntegerList(Draw_Interpretor& di, int nb, const char** ar di << "\n"; } else + { di << "List is empty\n"; + } return 0; } @@ -2853,7 +3239,9 @@ static int DDataStd_GetRealList(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2865,7 +3253,9 @@ static int DDataStd_GetRealList(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2873,7 +3263,9 @@ static int DDataStd_GetRealList(Draw_Interpretor& di, int nb, const char** arg) } } else + { aGuid = TDataStd_RealList::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -2894,7 +3286,9 @@ static int DDataStd_GetRealList(Draw_Interpretor& di, int nb, const char** arg) di << "\n"; } else + { di << "List is empty\n"; + } return 0; } di << "DDataStd_GetRealList: Error\n"; @@ -2910,7 +3304,9 @@ static int DDataStd_GetExtStringList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2922,7 +3318,9 @@ static int DDataStd_GetExtStringList(Draw_Interpretor& di, int nb, const char** if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2930,7 +3328,9 @@ static int DDataStd_GetExtStringList(Draw_Interpretor& di, int nb, const char** } } else + { aGuid = TDataStd_ExtStringList::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -2970,7 +3370,9 @@ static int DDataStd_GetReferenceList(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -2982,7 +3384,9 @@ static int DDataStd_GetReferenceList(Draw_Interpretor& di, int nb, const char** if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -2990,7 +3394,9 @@ static int DDataStd_GetReferenceList(Draw_Interpretor& di, int nb, const char** } } else + { aGuid = TDataStd_ReferenceList::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -3017,7 +3423,9 @@ static int DDataStd_GetReferenceList(Draw_Interpretor& di, int nb, const char** di << "\n"; } else + { di << "List is empty\n"; + } return 0; } di << "DDataStd_GetReferenceList: Error\n"; @@ -3036,14 +3444,18 @@ static int DDataStd_SetIntPackedMap(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); bool isDelta = Draw::Atoi(arg[3]) != 0; int aNum = nb - 4; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) + { anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta); + } if (anAtt.IsNull()) { di << "IntPackedMap attribute is not found or not set" << "\n"; @@ -3059,7 +3471,7 @@ static int DDataStd_SetIntPackedMap(Draw_Interpretor& di, int nb, const char** a } const occ::handle& aHMap = new TColStd_HPackedMapOfInteger(aMap); anAtt->ChangeMap(aHMap); - std::cout << "Map extent = " << anAtt->Extent() << std::endl; + std::cout << "Map extent = " << anAtt->Extent() << '\n'; return 0; } di << "DDataStd_SetIntPackedMap : Error\n"; @@ -3077,7 +3489,9 @@ static int DDataStd_GetIntPackedMap(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); occ::handle anAtt; @@ -3110,7 +3524,9 @@ static int DDataStd_ChangeIntPackedMap_Add(Draw_Interpretor& di, int nb, const c { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -3135,7 +3551,9 @@ static int DDataStd_ChangeIntPackedMap_Add(Draw_Interpretor& di, int nb, const c { int val = Draw::Atoi(arg[i + 2]); if (!ahMap->Map().Contains(val)) + { ahMap->ChangeMap().Add(val); + } } A->ChangeMap(ahMap); @@ -3156,7 +3574,9 @@ static int DDataStd_ChangeIntPackedMap_Rem(Draw_Interpretor& di, int nb, const c { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -3181,7 +3601,9 @@ static int DDataStd_ChangeIntPackedMap_Rem(Draw_Interpretor& di, int nb, const c { int val = Draw::Atoi(arg[i + 2]); if (ahMap->Map().Contains(val)) + { ahMap->ChangeMap().Remove(val); + } } A->ChangeMap(ahMap); @@ -3203,7 +3625,9 @@ static int DDataStd_ChangeIntPackedMap_AddRem(Draw_Interpretor& di, int nb, cons { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -3228,9 +3652,13 @@ static int DDataStd_ChangeIntPackedMap_AddRem(Draw_Interpretor& di, int nb, cons { int val = Draw::Atoi(arg[i + 2]); if (!ahMap->Map().Contains(val)) + { ahMap->ChangeMap().Add(val); + } else + { ahMap->ChangeMap().Remove(val); + } } A->ChangeMap(ahMap); @@ -3252,14 +3680,18 @@ static int DDataStd_SetIntPHugeMap(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); bool isDelta = Draw::Atoi(arg[3]) != 0; int aNum = Draw::Atoi(arg[4]); occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) + { anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta); + } if (anAtt.IsNull()) { di << "IntPackedMap attribute is not found or not set" << "\n"; @@ -3273,7 +3705,7 @@ static int DDataStd_SetIntPHugeMap(Draw_Interpretor& di, int nb, const char** ar } const occ::handle& aHMap = new TColStd_HPackedMapOfInteger(aMap); anAtt->ChangeMap(aHMap); - std::cout << "Map extent = " << anAtt->Extent() << std::endl; + std::cout << "Map extent = " << anAtt->Extent() << '\n'; return 0; } di << "DDataStd_SetIntPHugeMap : Error\n"; @@ -3291,13 +3723,17 @@ static int DDataStd_SetNDataIntegers2(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); int aNumP = Draw::Atoi(arg[3]), j; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { di << "NamedData attribute is not found or not set" << "\n"; @@ -3332,7 +3768,9 @@ static int DDataStd_SetNDataIntAr2(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); @@ -3340,10 +3778,14 @@ static int DDataStd_SetNDataIntAr2(Draw_Interpretor& di, int nb, const char** ar TCollection_ExtendedString aKey(arg[3]); int aNum = Draw::Atoi(arg[4]); if (aNum <= 0) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { Message::SendFail() << "NamedData attribute is not found or not set"; @@ -3377,7 +3819,9 @@ static int DDataStd_SetAsciiString(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); TCollection_AsciiString aString(arg[3]); @@ -3399,7 +3843,7 @@ static int DDataStd_SetAsciiString(Draw_Interpretor& di, int nb, const char** ar return 1; } - std::cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << std::endl; + std::cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << '\n'; return 0; } di << "DDataStd_SetAsciiString : Error\n"; @@ -3417,11 +3861,15 @@ static int DDataStd_GetAsciiString(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::FindLabel(DF, arg[2], aLabel); if (aLabel.IsNull()) + { di << "Label is not found" << "\n"; + } Standard_GUID aGuid(TDataStd_AsciiString::GetID()); if (nb == 4) { @@ -3460,7 +3908,9 @@ static int DDataStd_SetNDataIntegers(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); // @@ -3476,7 +3926,9 @@ static int DDataStd_SetNDataIntegers(Draw_Interpretor& di, int nb, const char** int aNumP = Draw::Atoi(arg[3]), j; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { di << "NamedData attribute is not found or not set" << "\n"; @@ -3508,10 +3960,14 @@ static int DDataStd_GetNDIntegers(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3520,8 +3976,8 @@ static int DDataStd_GetNDIntegers(Draw_Interpretor& di, int nb, const char** arg return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); const NCollection_DataMap& aMap = anAtt->GetIntegersContainer(); @@ -3549,10 +4005,14 @@ static int DDataStd_GetNDInteger(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3561,20 +4021,22 @@ static int DDataStd_GetNDInteger(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasInteger(aKey)) { - std::cout << "There is no data specified by Key = " << arg[3] << std::endl; + std::cout << "There is no data specified by Key = " << arg[3] << '\n'; return 1; } else { - std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetInteger(aKey) << std::endl; + std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetInteger(aKey) << '\n'; if (nb == 5) + { Draw::Set(arg[4], anAtt->GetInteger(aKey)); + } return 0; } } @@ -3594,14 +4056,18 @@ static int DDataStd_SetNDataReals(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); int aNumP = Draw::Atoi(arg[3]), j; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { Message::SendFail() << "NamedData attribute is not found or not set"; @@ -3633,13 +4099,17 @@ static int DDataStd_GetNDReals(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) { @@ -3673,10 +4143,14 @@ static int DDataStd_GetNDReal(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3685,8 +4159,8 @@ static int DDataStd_GetNDReal(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasReal(aKey)) @@ -3696,9 +4170,11 @@ static int DDataStd_GetNDReal(Draw_Interpretor& di, int nb, const char** arg) } else { - std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetReal(aKey) << std::endl; + std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetReal(aKey) << '\n'; if (nb == 5) + { Draw::Set(arg[4], anAtt->GetReal(aKey)); + } return 0; } } @@ -3718,14 +4194,18 @@ static int DDataStd_SetNDataStrings(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); int aNumP = Draw::Atoi(arg[3]), j; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { di << "NamedData attribute is not found or not set" << "\n"; @@ -3769,10 +4249,14 @@ static int DDataStd_GetNDStrings(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3781,8 +4265,8 @@ static int DDataStd_GetNDStrings(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); const NCollection_DataMap& aMap = anAtt->GetStringsContainer(); @@ -3818,10 +4302,14 @@ static int DDataStd_GetNDString(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3830,8 +4318,8 @@ static int DDataStd_GetNDString(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasString(aKey)) @@ -3842,9 +4330,11 @@ static int DDataStd_GetNDString(Draw_Interpretor& di, int nb, const char** arg) else { TCollection_AsciiString aValue(anAtt->GetString(aKey)); - std::cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << std::endl; + std::cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << '\n'; if (nb == 5) + { Draw::Set(arg[4], aValue.ToCString()); + } return 0; } } @@ -3864,14 +4354,18 @@ static int DDataStd_SetNDataBytes(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); int aNumP = Draw::Atoi(arg[3]), j; occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { Message::SendFail() << "NamedData attribute is not found or not set"; @@ -3903,10 +4397,14 @@ static int DDataStd_GetNDBytes(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3915,8 +4413,8 @@ static int DDataStd_GetNDBytes(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); const NCollection_DataMap& aMap = anAtt->GetBytesContainer(); @@ -3925,7 +4423,7 @@ static int DDataStd_GetNDBytes(Draw_Interpretor& di, int nb, const char** arg) { const TCollection_ExtendedString& aKey(itr.Key()); uint8_t aValue = itr.Value(); - std::cout << "Key = " << aKey << " Value = " << aValue << std::endl; + std::cout << "Key = " << aKey << " Value = " << aValue << '\n'; } return 0; } @@ -3943,10 +4441,14 @@ static int DDataStd_GetNDByte(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -3955,8 +4457,8 @@ static int DDataStd_GetNDByte(Draw_Interpretor& di, int nb, const char** arg) return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasByte(aKey)) @@ -3966,9 +4468,11 @@ static int DDataStd_GetNDByte(Draw_Interpretor& di, int nb, const char** arg) } else { - std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetByte(aKey) << std::endl; + std::cout << "Key = " << arg[3] << " Value = " << anAtt->GetByte(aKey) << '\n'; if (nb == 5) + { Draw::Set(arg[4], anAtt->GetByte(aKey)); + } return 0; } } @@ -3988,7 +4492,9 @@ static int DDataStd_SetNDataIntAr(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); @@ -3996,10 +4502,14 @@ static int DDataStd_SetNDataIntAr(Draw_Interpretor& di, int nb, const char** arg TCollection_ExtendedString aKey(arg[3]); int aNum = Draw::Atoi(arg[4]); if (aNum <= 0) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { Message::SendFail() << "NamedData attribute is not found or not set"; @@ -4032,10 +4542,14 @@ static int DDataStd_GetNDIntArrays(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -4044,8 +4558,8 @@ static int DDataStd_GetNDIntArrays(Draw_Interpretor& di, int nb, const char** ar return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); const NCollection_DataMap>>& aMap = anAtt->GetArraysOfIntegersContainer(); @@ -4054,7 +4568,7 @@ static int DDataStd_GetNDIntArrays(Draw_Interpretor& di, int nb, const char** ar for (; itr.More(); itr.Next()) { const TCollection_ExtendedString& aKey(itr.Key()); - std::cout << "Key = " << aKey << std::endl; + std::cout << "Key = " << aKey << '\n'; const occ::handle>& anArrValue = itr.Value(); if (!anArrValue.IsNull()) { @@ -4063,11 +4577,13 @@ static int DDataStd_GetNDIntArrays(Draw_Interpretor& di, int nb, const char** ar for (int i = lower; i <= upper; i++) { int aValue = anArrValue->Value(i); - std::cout << "\tValue(" << i << ") = " << aValue << std::endl; + std::cout << "\tValue(" << i << ") = " << aValue << '\n'; } } else - std::cout << "\tthe specified array is Null " << std::endl; + { + std::cout << "\tthe specified array is Null " << '\n'; + } } return 0; } @@ -4085,10 +4601,14 @@ static int DDataStd_GetNDIntArray(Draw_Interpretor& di, int nb, const char** arg { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -4097,8 +4617,8 @@ static int DDataStd_GetNDIntArray(Draw_Interpretor& di, int nb, const char** arg return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasArrayOfIntegers(aKey)) @@ -4108,7 +4628,7 @@ static int DDataStd_GetNDIntArray(Draw_Interpretor& di, int nb, const char** arg } else { - std::cout << "Key = " << arg[3] << std::endl; + std::cout << "Key = " << arg[3] << '\n'; occ::handle> anArrValue = anAtt->GetArrayOfIntegers(aKey); if (!anArrValue.IsNull()) @@ -4118,11 +4638,13 @@ static int DDataStd_GetNDIntArray(Draw_Interpretor& di, int nb, const char** arg for (int i = lower; i <= upper; i++) { int aValue = anArrValue->Value(i); - std::cout << "\tValue(" << i << ") = " << aValue << std::endl; + std::cout << "\tValue(" << i << ") = " << aValue << '\n'; } } else - std::cout << "\tthe specified array is Null or not found" << std::endl; + { + std::cout << "\tthe specified array is Null or not found" << '\n'; + } return 0; } } @@ -4142,7 +4664,9 @@ static int DDataStd_SetNDataRealAr(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(DF, arg[2], aLabel); @@ -4150,10 +4674,14 @@ static int DDataStd_SetNDataRealAr(Draw_Interpretor& di, int nb, const char** ar TCollection_ExtendedString aKey(arg[3]); int aNum = Draw::Atoi(arg[4]); if (aNum <= 0) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) + { anAtt = TDataStd_NamedData::Set(aLabel); + } if (anAtt.IsNull()) { Message::SendFail() << "NamedData attribute is not found or not set"; @@ -4186,10 +4714,14 @@ static int DDataStd_GetNDRealArrays(Draw_Interpretor& di, int nb, const char** a { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -4198,8 +4730,8 @@ static int DDataStd_GetNDRealArrays(Draw_Interpretor& di, int nb, const char** a return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); const NCollection_DataMap>>& aMap = anAtt->GetArraysOfRealsContainer(); @@ -4208,7 +4740,7 @@ static int DDataStd_GetNDRealArrays(Draw_Interpretor& di, int nb, const char** a for (; itr.More(); itr.Next()) { const TCollection_ExtendedString& aKey(itr.Key()); - std::cout << "Key = " << aKey << std::endl; + std::cout << "Key = " << aKey << '\n'; const occ::handle>& anArrValue = itr.Value(); if (!anArrValue.IsNull()) { @@ -4217,11 +4749,13 @@ static int DDataStd_GetNDRealArrays(Draw_Interpretor& di, int nb, const char** a for (int i = lower; i <= upper; i++) { double aValue = anArrValue->Value(i); - std::cout << "\tValue(" << i << ") = " << aValue << std::endl; + std::cout << "\tValue(" << i << ") = " << aValue << '\n'; } } else - std::cout << "\tthe specified array is Null " << std::endl; + { + std::cout << "\tthe specified array is Null " << '\n'; + } } return 0; } @@ -4239,10 +4773,14 @@ static int DDataStd_GetNDRealArray(Draw_Interpretor& di, int nb, const char** ar { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label aLabel; if (!DDF::FindLabel(DF, arg[2], aLabel)) + { return 1; + } occ::handle anAtt; if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) @@ -4251,18 +4789,18 @@ static int DDataStd_GetNDRealArray(Draw_Interpretor& di, int nb, const char** ar return 1; } - std::cout << std::endl; - std::cout << "NamedData attribute at Label = " << arg[2] << std::endl; + std::cout << '\n'; + std::cout << "NamedData attribute at Label = " << arg[2] << '\n'; anAtt->LoadDeferredData(); TCollection_ExtendedString aKey(arg[3], true); if (!anAtt->HasArrayOfReals(aKey)) { - std::cout << "There is no data specified by Key = " << arg[3] << std::endl; + std::cout << "There is no data specified by Key = " << arg[3] << '\n'; return 1; } else { - std::cout << "Key = " << arg[3] << std::endl; + std::cout << "Key = " << arg[3] << '\n'; occ::handle> anArrValue = anAtt->GetArrayOfReals(aKey); if (!anArrValue.IsNull()) @@ -4272,11 +4810,13 @@ static int DDataStd_GetNDRealArray(Draw_Interpretor& di, int nb, const char** ar for (int i = lower; i <= upper; i++) { double aValue = anArrValue->Value(i); - std::cout << "\tValue(" << i << ") = " << aValue << std::endl; + std::cout << "\tValue(" << i << ") = " << aValue << '\n'; } } else - std::cout << "\tthe specified array is Null or not found" << std::endl; + { + std::cout << "\tthe specified array is Null or not found" << '\n'; + } return 0; } } @@ -4293,7 +4833,9 @@ static int DDataStd_SetRefArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); Standard_GUID guid; @@ -4311,7 +4853,9 @@ static int DDataStd_SetRefArray(Draw_Interpretor& di, int nb, const char** arg) } int j(3); if (isGuid) + { j = 5; + } if ((strlen(arg[j]) > MAXLENGTH || strlen(arg[j + 1]) > MAXLENGTH) || !TCollection_AsciiString(arg[j]).IsIntegerValue() @@ -4325,9 +4869,13 @@ static int DDataStd_SetRefArray(Draw_Interpretor& di, int nb, const char** arg) occ::handle A; if (!isGuid) + { A = TDataStd_ReferenceArray::Set(label, From, To); + } else + { A = TDataStd_ReferenceArray::Set(label, guid, From, To); + } if ((!isGuid && nb > 5) || (isGuid && nb > 7)) { @@ -4354,12 +4902,16 @@ static int DDataStd_SetRefArrayValue(Draw_Interpretor&, int, const char** arg) // Get document. occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } // Get label. TDF_Label label; if (!DDF::AddLabel(DF, arg[2], label)) + { return 1; + } // Get index and value. int index = Draw::Atoi(arg[3]); @@ -4386,7 +4938,9 @@ static int DDataStd_GetRefArray(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -4397,7 +4951,9 @@ static int DDataStd_GetRefArray(Draw_Interpretor& di, int nb, const char** arg) if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -4405,7 +4961,9 @@ static int DDataStd_GetRefArray(Draw_Interpretor& di, int nb, const char** arg) } } else + { aGuid = TDataStd_ReferenceArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -4421,7 +4979,9 @@ static int DDataStd_GetRefArray(Draw_Interpretor& di, int nb, const char** arg) TDF_Tool::Entry(aLabel, entry); di << entry.ToCString(); if (i < A->Upper()) + { di << " "; + } } di << "\n"; return 0; @@ -4439,7 +4999,9 @@ static int DDataStd_GetRefArrayValue(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) @@ -4451,7 +5013,9 @@ static int DDataStd_GetRefArrayValue(Draw_Interpretor& di, int nb, const char** if (nb == 4) { if (Standard_GUID::CheckGUIDFormat(arg[3])) + { aGuid = Standard_GUID(arg[3]); + } else { di << "Wrong GUID format" << "\n"; @@ -4459,7 +5023,9 @@ static int DDataStd_GetRefArrayValue(Draw_Interpretor& di, int nb, const char** } } else + { aGuid = TDataStd_ReferenceArray::GetID(); + } occ::handle A; if (!label.FindAttribute(aGuid, A)) @@ -4498,11 +5064,15 @@ static int DDataStd_SetTriangulation(Draw_Interpretor& di, int nb, const char** { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::AddLabel(DF, arg[2], L)) + { return 1; + } // Get face. TopoDS_Shape face = DBRep::Get(arg[3]); @@ -4540,7 +5110,9 @@ static int DDataStd_DumpMesh(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle PT; if (!DDF::Find(DF, arg[2], TDataXtd_Triangulation::GetID(), PT)) @@ -4560,9 +5132,13 @@ static int DDataStd_DumpMesh(Draw_Interpretor& di, int nb, const char** arg) di << "Number of nodes " << PT->NbNodes() << "\n"; di << "Number of triangles " << PT->NbTriangles() << "\n"; if (PT->HasUVNodes()) + { di << "It has 2d-nodes\n"; + } if (PT->HasNormals()) + { di << "It has normals\n"; + } return 0; } @@ -4577,7 +5153,9 @@ void DDataStd::BasicCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_ConstraintCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_ConstraintCommands.cxx index 68f23c6f4b..230ba8025f 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_ConstraintCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_ConstraintCommands.cxx @@ -52,11 +52,15 @@ static int DDataStd_SetConstraint(Draw_Interpretor& di, int nb, const char** arg occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } TDataXtd_ConstraintEnum aCT; const char* aT = arg[3]; @@ -65,11 +69,15 @@ static int DDataStd_SetConstraint(Draw_Interpretor& di, int nb, const char** arg { occ::handle C; if (!L.FindAttribute(TDataXtd_Constraint::GetID(), C)) + { return 1; + } TDF_Label aLab; if (!DDF::FindLabel(DF, arg[4], aLab)) + { return 1; + } occ::handle aSh; if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSh)) { @@ -80,11 +88,15 @@ static int DDataStd_SetConstraint(Draw_Interpretor& di, int nb, const char** arg { occ::handle C; if (!L.FindAttribute(TDataXtd_Constraint::GetID(), C)) + { return 1; + } TDF_Label aLab; if (!DDF::FindLabel(DF, arg[4], aLab)) + { return 1; + } occ::handle aR; if (aLab.FindAttribute(TDataStd_Real::GetID(), aR)) { @@ -97,58 +109,110 @@ static int DDataStd_SetConstraint(Draw_Interpretor& di, int nb, const char** arg // planar constraints if (strcmp(aT, "rad") == 0) + { aCT = TDataXtd_RADIUS; + } else if (strcmp(aT, "dia") == 0) + { aCT = TDataXtd_DIAMETER; + } else if (strcmp(aT, "minr") == 0) + { aCT = TDataXtd_MINOR_RADIUS; + } else if (strcmp(aT, "majr") == 0) + { aCT = TDataXtd_MAJOR_RADIUS; + } else if (strcmp(aT, "tan") == 0) + { aCT = TDataXtd_TANGENT; + } else if (strcmp(aT, "par") == 0) + { aCT = TDataXtd_PARALLEL; + } else if (strcmp(aT, "perp") == 0) + { aCT = TDataXtd_PERPENDICULAR; + } else if (strcmp(aT, "concentric") == 0) + { aCT = TDataXtd_CONCENTRIC; + } else if (strcmp(aT, "equal") == 0) + { aCT = TDataXtd_COINCIDENT; + } else if (strcmp(aT, "dist") == 0) + { aCT = TDataXtd_DISTANCE; + } else if (strcmp(aT, "angle") == 0) + { aCT = TDataXtd_ANGLE; + } else if (strcmp(aT, "eqrad") == 0) + { aCT = TDataXtd_EQUAL_RADIUS; + } else if (strcmp(aT, "symm") == 0) + { aCT = TDataXtd_SYMMETRY; + } else if (strcmp(aT, "midp") == 0) + { aCT = TDataXtd_MIDPOINT; + } else if (strcmp(aT, "eqdist") == 0) + { aCT = TDataXtd_EQUAL_DISTANCE; + } else if (strcmp(aT, "fix") == 0) + { aCT = TDataXtd_FIX; + } else if (strcmp(aT, "rigid") == 0) + { aCT = TDataXtd_RIGID; - // placement constraints + // placement constraints + } else if (strcmp(aT, "from") == 0) + { aCT = TDataXtd_FROM; + } else if (strcmp(aT, "axis") == 0) + { aCT = TDataXtd_AXIS; + } else if (strcmp(aT, "mate") == 0) + { aCT = TDataXtd_MATE; + } else if (strcmp(aT, "alignf") == 0) + { aCT = TDataXtd_ALIGN_FACES; + } else if (strcmp(aT, "aligna") == 0) + { aCT = TDataXtd_ALIGN_AXES; + } else if (strcmp(aT, "axesa") == 0) + { aCT = TDataXtd_AXES_ANGLE; + } else if (strcmp(aT, "facesa") == 0) + { aCT = TDataXtd_FACES_ANGLE; + } else if (strcmp(aT, "round") == 0) + { aCT = TDataXtd_ROUND; + } else if (strcmp(aT, "offset") == 0) + { aCT = TDataXtd_OFFSET; + } else { di << "DDataStd_SetConstraint : unknown type, must be one of:\n"; @@ -169,7 +233,9 @@ static int DDataStd_SetConstraint(Draw_Interpretor& di, int nb, const char** arg for (i = 1; i <= nbSh; i++) { if (!DDF::FindLabel(DF, arg[i + 3], aLab)) + { return 1; + } if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSh)) { C->SetGeometry(i, aSh); @@ -191,9 +257,13 @@ static int DDataStd_GetConstraint(Draw_Interpretor& di, int nb, const char** arg occ::handle DF; TDF_Label L; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } if (L.FindAttribute(TDataXtd_Constraint::GetID(), CTR)) { Standard_SStream aStream; @@ -236,11 +306,15 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } occ::handle aP = TDataXtd_PatternStd::Set(L); @@ -267,7 +341,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // NSentry if (!DDF::FindLabel(DF, arg[4], aLab)) + { return 1; + } if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS)) { aP->Axis1(TNS); @@ -275,7 +351,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // realEntry if (!DDF::FindLabel(DF, arg[5], aLab)) + { return 1; + } if (aLab.FindAttribute(TDataStd_Real::GetID(), TReal)) { aP->Value1(TReal); @@ -283,7 +361,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // intEntry if (!DDF::FindLabel(DF, arg[6], aLab)) + { return 1; + } if (aLab.FindAttribute(TDataStd_Integer::GetID(), TInt)) { aP->NbInstances1(TInt); @@ -301,7 +381,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // NSentry if (!DDF::FindLabel(DF, arg[7], aLab)) + { return 1; + } if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS)) { aP->Axis2(TNS); @@ -309,7 +391,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // realEntry if (!DDF::FindLabel(DF, arg[8], aLab)) + { return 1; + } if (aLab.FindAttribute(TDataStd_Real::GetID(), TReal)) { aP->Value2(TReal); @@ -317,7 +401,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) // intEntry if (!DDF::FindLabel(DF, arg[9], aLab)) + { return 1; + } if (aLab.FindAttribute(TDataStd_Integer::GetID(), TInt)) { aP->NbInstances2(TInt); @@ -333,7 +419,9 @@ static int DDataStd_SetPattern(Draw_Interpretor& di, int nb, const char** arg) } if (!DDF::FindLabel(DF, arg[4], aLab)) + { return 1; + } if (aLab.FindAttribute(TNaming_NamedShape::GetID(), TNS)) { aP->Mirror(TNS); @@ -355,9 +443,13 @@ static int DDataStd_DumpPattern(Draw_Interpretor& di, int nb, const char** arg) occ::handle DF; TDF_Label L; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } if (L.FindAttribute(TDataXtd_PatternStd::GetID(), CTR)) { // Standard_SStream aStream; @@ -442,7 +534,9 @@ static int DDataStd_SetPosition(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); @@ -466,7 +560,9 @@ static int DDataStd_GetPosition(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); @@ -493,7 +589,9 @@ void DDataStd::ConstraintCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_DatumCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_DatumCommands.cxx index 04f9ce3174..5f967835d2 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_DatumCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_DatumCommands.cxx @@ -50,11 +50,15 @@ static int DDataStd_SetPoint(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 3) + { return 1; + } TDF_Label L; occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } DDF::AddLabel(DF, arg[2], L); if (nb == 3) { @@ -85,11 +89,15 @@ static int DDataStd_SetPoint(Draw_Interpretor& di, int nb, const char** arg) static int DDataStd_SetAxis(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 3) + { return 1; + } TDF_Label L; occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } DDF::AddLabel(DF, arg[2], L); if (nb == 3) { @@ -117,11 +125,15 @@ static int DDataStd_SetAxis(Draw_Interpretor& di, int nb, const char** arg) static int DDataStd_SetPlane(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 3) + { return 1; + } TDF_Label L; occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } DDF::AddLabel(DF, arg[2], L); if (nb == 3) { @@ -149,20 +161,30 @@ static int DDataStd_SetPlane(Draw_Interpretor& di, int nb, const char** arg) static int DDataStd_GetPoint(Draw_Interpretor&, int nb, const char** arg) { if (nb < 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; gp_Pnt P; if (!DDF::Find(DF, arg[2], TDataXtd_Point::GetID(), A)) + { return 1; + } if (TDataXtd_Geometry::Point(A->Label(), P)) { if (nb == 4) + { DrawTrSurf::Set(arg[3], P); + } else + { DrawTrSurf::Set(arg[2], P); + } return 0; } return 1; @@ -176,21 +198,31 @@ static int DDataStd_GetPoint(Draw_Interpretor&, int nb, const char** arg) static int DDataStd_GetAxis(Draw_Interpretor&, int nb, const char** arg) { if (nb < 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; if (!DDF::Find(DF, arg[2], TDataXtd_Axis::GetID(), A)) + { return 1; + } gp_Lin l; if (TDataXtd_Geometry::Line(A->Label(), l)) { occ::handle L = new Geom_Line(l); if (nb == 4) + { DrawTrSurf::Set(arg[3], L); + } else + { DrawTrSurf::Set(arg[2], L); + } return 0; } return 1; @@ -204,21 +236,31 @@ static int DDataStd_GetAxis(Draw_Interpretor&, int nb, const char** arg) static int DDataStd_GetPlane(Draw_Interpretor&, int nb, const char** arg) { if (nb < 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } occ::handle A; if (!DDF::Find(DF, arg[2], TDataXtd_Plane::GetID(), A)) + { return 1; + } gp_Pln p; if (TDataXtd_Geometry::Plane(A->Label(), p)) { occ::handle P = new Geom_Plane(p); if (nb == 4) + { DrawTrSurf::Set(arg[3], P); + } else + { DrawTrSurf::Set(arg[2], P); + } return 0; } return 1; @@ -231,15 +273,21 @@ static int DDataStd_GetPlane(Draw_Interpretor&, int nb, const char** arg) static int DDataStd_SetGeometry(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { DDF::AddLabel(DF, arg[2], L); + } if (nb == 5) { @@ -263,21 +311,37 @@ static int DDataStd_SetGeometry(Draw_Interpretor& di, int nb, const char** arg) { const char* aT = arg[3]; if (strcmp(aT, "any") == 0) + { aType = TDataXtd_ANY_GEOM; + } else if (strcmp(aT, "pnt") == 0) + { aType = TDataXtd_POINT; + } else if (strcmp(aT, "lin") == 0) + { aType = TDataXtd_LINE; + } else if (strcmp(aT, "cir") == 0) + { aType = TDataXtd_CIRCLE; + } else if (strcmp(aT, "ell") == 0) + { aType = TDataXtd_ELLIPSE; + } else if (strcmp(aT, "spl") == 0) + { aType = TDataXtd_SPLINE; + } else if (strcmp(aT, "pln") == 0) + { aType = TDataXtd_PLANE; + } else if (strcmp(aT, "cyl") == 0) + { aType = TDataXtd_CYLINDER; + } else { di << "DDataStd_SetGeometry : unknown type, must be one of:\n"; @@ -302,15 +366,21 @@ static int DDataStd_SetGeometry(Draw_Interpretor& di, int nb, const char** arg) static int DDataStd_GetGeometryType(Draw_Interpretor& di, int nb, const char** arg) { if (nb != 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { DDF::AddLabel(DF, arg[2], L); + } // get geometry attribute occ::handle aGA; @@ -364,7 +434,9 @@ void DDataStd::DatumCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDisplayCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDisplayCommands.cxx index 10e4f0c944..f61b9b60e7 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDisplayCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDisplayCommands.cxx @@ -29,7 +29,7 @@ #include #ifndef _WIN32 -extern Draw_Viewer dout; + #else Standard_IMPORT Draw_Viewer dout; #endif @@ -44,7 +44,9 @@ static int DDataStd_PNT(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); double x = Draw::Atof(arg[3]); @@ -104,10 +106,14 @@ static int DDataStd_DrawOwner(Draw_Interpretor& di, int nb, const char** arg) di << entry.ToCString(); } else + { di << name.ToCString(); + } } else + { di << 0; + } return 0; } di << "DDataStd_DrawOwner : Error\n"; @@ -125,10 +131,14 @@ static int DDataStd_DrawDisplay(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } DDataStd_DrawPresentation::Display(L); return 0; } @@ -168,10 +178,14 @@ static int DDataStd_DrawErase(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } DDataStd_DrawPresentation::Erase(L); return 0; } @@ -190,10 +204,14 @@ static int DDataStd_DrawUpdate(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, arg[2], L)) + { return 1; + } DDataStd_DrawPresentation::Update(L); return 0; } @@ -217,7 +235,9 @@ void DDataStd::DrawDisplayCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "SKETCH commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDriver.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDriver.cxx index 5a14124ef0..eedb199191 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDriver.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawDriver.cxx @@ -75,7 +75,9 @@ static TopoDS_Shape Geometry(const occ::handle& A, if (!S.IsNull()) { if (T != TopAbs_SHAPE && T != S.ShapeType()) + { S.Nullify(); + } } return S; } @@ -179,7 +181,9 @@ occ::handle DDataStd_DrawDriver::DrawableConstraint( TopoDS_Face F1 = TopoDS::Face(aLocalShape); // TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE)); if (!F1.IsNull()) + { D = new DrawDim_Radius(F1); + } } } break; @@ -241,7 +245,9 @@ occ::handle DDataStd_DrawDriver::DrawableConstraint( // TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE)); // TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE)); if (!F1.IsNull() && !F2.IsNull()) + { D = new DrawDim_Angle(F1, F2); + } } } break; @@ -280,7 +286,9 @@ occ::handle DDataStd_DrawDriver::DrawableConstraint( // TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE)); // TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE)); if (!F1.IsNull() && !F2.IsNull()) + { D = new DrawDim_Distance(F1, F2); + } } break; @@ -292,7 +300,9 @@ occ::handle DDataStd_DrawDriver::DrawableConstraint( // TopoDS_Face F1 = TopoDS::Face(Geometry(A,1,TopAbs_FACE)); // TopoDS_Face F2 = TopoDS::Face(Geometry(A,2,TopAbs_FACE)); if (!F1.IsNull() && !F2.IsNull()) + { D = new DrawDim_Distance(F1, F2); + } } break; @@ -318,12 +328,16 @@ occ::handle DDataStd_DrawDriver::DrawableConstraint( { double val = A->GetValue()->Get(); Standard_DISABLE_DEPRECATION_WARNINGS if (A->GetValue()->GetDimension() == TDataStd_ANGULAR) + { val = (180. * val) / M_PI; + } Standard_ENABLE_DEPRECATION_WARNINGS D->SetValue(val); } // unverified constraints are red (default is white) if (!A->Verified()) + { D->TextColor(Draw_rouge); + } } return D; } @@ -340,9 +354,13 @@ occ::handle DDataStd_DrawDriver::DrawableShape(const TDF_Label& { TopoDS_Shape S; if (current) + { S = TNaming_Tool::CurrentShape(NS); + } else + { S = TNaming_Tool::GetShape(NS); + } DS = DrawableShape(S, color); } return DS; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawPresentation.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawPresentation.cxx index 275610e239..8249cb42c0 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_DrawPresentation.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_DrawPresentation.cxx @@ -68,9 +68,13 @@ void DDataStd_DrawPresentation::Display(const TDF_Label& L) } // display if (P->IsDisplayed()) + { return; + } if (P->GetDrawable().IsNull()) + { P->DrawBuild(); + } DrawDisplay(P->Label(), P); P->SetDisplayed(true); } @@ -202,7 +206,9 @@ void DDataStd_DrawPresentation::BeforeForget() { // std::cout<< "DDataStd_DrawPresentation::BeforeForget" << std::endl; if (isDisplayed) + { DrawErase(Label(), this); + } } //================================================================================================= @@ -211,7 +217,9 @@ void DDataStd_DrawPresentation::AfterResume() { // std::cout<< "DDataStd_DrawPresentation::AfterResume"<< std::endl; if (isDisplayed) + { DrawDisplay(Label(), this); + } } //======================================================================= @@ -240,7 +248,9 @@ bool DDataStd_DrawPresentation::BeforeUndo(const occ::handle { // std::cout<< "DDataStd_DrawPresentation::BeforeUndo : delta on addition" << std::endl; if (Pfw->IsDisplayed()) + { DrawErase(AD->Label(), Pfw); + } // TDF appelle BeforeRemoval effacer } else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnRemoval))) @@ -251,7 +261,9 @@ bool DDataStd_DrawPresentation::BeforeUndo(const occ::handle { // std::cout<< "DDataStd_DrawPresentation::BeforeUndo : delta on modification" << std::endl; if (Pfw->IsDisplayed()) + { DrawErase(AD->Label(), Pfw); + } } else { @@ -292,13 +304,17 @@ bool DDataStd_DrawPresentation::AfterUndo(const occ::handle& { // std::cout<< "DDataStd_DrawPresentation::AfterUndo : delta on removal" << std::endl; if (Pdt->IsDisplayed()) + { DrawDisplay(AD->Label(), Pdt); + } } else if (AD->IsKind(STANDARD_TYPE(TDF_DefaultDeltaOnModification))) { // std::cout<< "DDataStd_DrawPresentation::AfterUndo : delta on modification" << std::endl; if (Pdt->IsDisplayed()) + { DrawDisplay(AD->Label(), Pdt); + } } else { @@ -322,7 +338,9 @@ void DDataStd_DrawPresentation::DrawBuild() } occ::handle D3D = DD->Drawable(Label()); if (D3D.IsNull()) - std::cout << "DDataStd_DrawPresentation::DrawBuild : null drawable" << std::endl; + { + std::cout << "DDataStd_DrawPresentation::DrawBuild : null drawable" << '\n'; + } myDrawable = D3D; } @@ -347,7 +365,7 @@ void DDataStd_DrawPresentation::DrawDisplay(const TDF_Label& return; } } - std::cout << "DDataStd_DrawPresentation::DrawDisplay : null Label" << std::endl; + std::cout << "DDataStd_DrawPresentation::DrawDisplay : null Label" << '\n'; } //================================================================================================= @@ -368,5 +386,5 @@ void DDataStd_DrawPresentation::DrawErase(const TDF_Label& return; } } - std::cout << "DDataStd_DrawPresentation::DrawErase : null Label" << std::endl; + std::cout << "DDataStd_DrawPresentation::DrawErase : null Label" << '\n'; } diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_NameCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_NameCommands.cxx index 269656f6d2..92709d7592 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_NameCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_NameCommands.cxx @@ -42,13 +42,19 @@ static int DDataStd_SetName(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); if (L.IsNull()) + { di << "Label is not found" << "\n"; + } if (nb == 4) + { TDataStd_Name::Set(L, TCollection_ExtendedString(arg[3], true)); + } else { if (!Standard_GUID::CheckGUIDFormat(arg[4])) @@ -77,11 +83,15 @@ static int DDataStd_GetName(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::FindLabel(DF, arg[2], L); if (L.IsNull()) + { di << "Label is not found" << "\n"; + } Standard_GUID aGuid(TDataStd_Name::GetID()); if (nb == 4) { @@ -116,7 +126,9 @@ void DDataStd::NameCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DDataStd : Name attribute commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_NamedShapeCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_NamedShapeCommands.cxx index 6264e4c2b7..80076b8d12 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_NamedShapeCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_NamedShapeCommands.cxx @@ -41,7 +41,9 @@ static int DDataStd_SetShape(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TopoDS_Shape s = DBRep::Get(arg[3]); if (s.IsNull()) { @@ -65,7 +67,9 @@ void DDataStd::NamedShapeCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_ObjectCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_ObjectCommands.cxx index c757208e1c..0d0afa6fc5 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_ObjectCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_ObjectCommands.cxx @@ -43,7 +43,9 @@ static int DDataStd_NewDirectory(Draw_Interpretor& di, int nb, const char** arg) } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); TDataStd_Directory::New(label); @@ -62,7 +64,9 @@ static int DDataStd_AddDirectory(Draw_Interpretor& di, int nb, const char** arg) } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -94,7 +98,9 @@ static int DDataStd_MakeObjectLabel(Draw_Interpretor& di, int nb, const char** a } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -124,7 +130,9 @@ static int DDataStd_NewNoteBook(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, arg[2], L); TDataStd_NoteBook::New(L); @@ -147,7 +155,9 @@ static int DDataStd_NewShape(Draw_Interpretor& di, int nb, const char** arg) } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; DDF::AddLabel(DF, arg[2], label); if (nb == 4) @@ -161,7 +171,9 @@ static int DDataStd_NewShape(Draw_Interpretor& di, int nb, const char** arg) TDataXtd_Shape::Set(label, shape); } else + { TDataXtd_Shape::New(label); + } return 0; } @@ -177,7 +189,9 @@ static int DDataStd_GetShape2(Draw_Interpretor& di, int nb, const char** arg) } occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, arg[2], label)) { @@ -196,7 +210,9 @@ void DDataStd::ObjectCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_TreeBrowser.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_TreeBrowser.cxx index 9bbe6ebef7..c545be3257 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_TreeBrowser.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_TreeBrowser.cxx @@ -53,7 +53,7 @@ DDataStd_TreeBrowser::DDataStd_TreeBrowser(const TDF_Label& aLabel) void DDataStd_TreeBrowser::DrawOn(Draw_Display& /*dis*/) const { - std::cout << "DDataStd_TreeBrowser" << std::endl; + std::cout << "DDataStd_TreeBrowser" << '\n'; } //================================================================================================= @@ -67,7 +67,7 @@ occ::handle DDataStd_TreeBrowser::Copy() const void DDataStd_TreeBrowser::Dump(Standard_OStream& S) const { - S << "DDataStd_TreeBrowser on a label: " << std::endl; + S << "DDataStd_TreeBrowser on a label: " << '\n'; S << myRoot; } @@ -122,7 +122,9 @@ TCollection_AsciiString DDataStd_TreeBrowser::OpenNode(const TDF_Label& aLabel) while (!current.IsNull()) { if (split) + { list.AssignCat(TDF_BrowserSeparator1); + } OpenNode(current, list); split = true; current = current->Next(); @@ -159,9 +161,13 @@ void DDataStd_TreeBrowser::OpenNode(const occ::handle& aTreeN aList.AssignCat(TDF_BrowserSeparator2); TCollection_ExtendedString ext; if (TDF::ProgIDFromGUID(aTreeNode->ID(), ext)) + { aList.AssignCat(ext); + } else + { aList.AssignCat(aTreeNode->DynamicType()->Name()); + } // Executable or Forgotten? -3 // aList.AssignCat(TDF_BrowserSeparator2); // if (aTreeNode->IsExecutable()) aList.AssignCat("Executable"); @@ -173,13 +179,19 @@ void DDataStd_TreeBrowser::OpenNode(const occ::handle& aTreeN // Children? -3 aList.AssignCat(TDF_BrowserSeparator2); if (aTreeNode->First().IsNull()) + { aList.AssignCat("Null"); + } else + { aList.AssignCat("First"); + } // Father? -4 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasFather()) + { aList.AssignCat("Null"); + } else { TDF_Tool::Entry(aTreeNode->Father()->Label(), tmp); @@ -188,7 +200,9 @@ void DDataStd_TreeBrowser::OpenNode(const occ::handle& aTreeN // First? -5 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasFirst()) + { aList.AssignCat("Null"); + } else { TDF_Tool::Entry(aTreeNode->First()->Label(), tmp); @@ -197,7 +211,9 @@ void DDataStd_TreeBrowser::OpenNode(const occ::handle& aTreeN // Next? -6 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasNext()) + { aList.AssignCat("Null"); + } else { TDF_Tool::Entry(aTreeNode->Next()->Label(), tmp); @@ -206,7 +222,9 @@ void DDataStd_TreeBrowser::OpenNode(const occ::handle& aTreeN // Previous? -7 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasPrevious()) + { aList.AssignCat("Null"); + } else { TDF_Tool::Entry(aTreeNode->Previous()->Label(), tmp); diff --git a/src/Draw/TKDCAF/DDataStd/DDataStd_TreeCommands.cxx b/src/Draw/TKDCAF/DDataStd/DDataStd_TreeCommands.cxx index 43852a8e4a..f2ce813f63 100644 --- a/src/Draw/TKDCAF/DDataStd/DDataStd_TreeCommands.cxx +++ b/src/Draw/TKDCAF/DDataStd/DDataStd_TreeCommands.cxx @@ -37,7 +37,9 @@ static int DDataStd_SetNode(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; occ::handle TN; DDF::AddLabel(DF, a[2], L); @@ -74,12 +76,16 @@ static int DDataStd_AppendNode(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle father, child; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -92,7 +98,9 @@ static int DDataStd_AppendNode(Draw_Interpretor& di, int n, const char** a) } if (!DDF::Find(DF, a[2], ID, father)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, a[3], L); @@ -103,7 +111,9 @@ static int DDataStd_AppendNode(Draw_Interpretor& di, int n, const char** a) } child = TDataStd_TreeNode::Set(L, ID); if (!father->Append(child)) + { return 1; + } #ifdef OCCT_DEBUG di << "AppendNode: OK\n"; #endif @@ -124,12 +134,16 @@ static int DDataStd_PrependNode(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle father, child; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -142,7 +156,9 @@ static int DDataStd_PrependNode(Draw_Interpretor& di, int n, const char** a) } if (!DDF::Find(DF, a[2], ID, father)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, a[3], L); @@ -153,7 +169,9 @@ static int DDataStd_PrependNode(Draw_Interpretor& di, int n, const char** a) } child = TDataStd_TreeNode::Set(L, ID); if (!father->Prepend(child)) + { return 1; + } #ifdef OCCT_DEBUG di << "PrependNode: OK\n"; #endif @@ -174,12 +192,16 @@ static int DDataStd_RootNode(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle TN; Standard_GUID ID; if (n == 3) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[3])) @@ -192,7 +214,9 @@ static int DDataStd_RootNode(Draw_Interpretor& di, int n, const char** a) } if (!DDF::Find(DF, a[2], ID, TN)) + { return 1; + } DDF::ReturnLabel(di, TN->Root()->Label()); return 0; } @@ -211,12 +235,16 @@ static int DDataStd_InsertNodeBefore(Draw_Interpretor& di, int n, const char** a { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle current, TN; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -229,15 +257,21 @@ static int DDataStd_InsertNodeBefore(Draw_Interpretor& di, int n, const char** a } if (!DDF::Find(DF, a[2], ID, current)) + { return 1; + } // if (!DDF::Find(DF,a[3],ID,TN)) return 1; TDF_Label L; if (!DDF::FindLabel(DF, a[3], L)) + { return 1; + } TN = TDataStd_TreeNode::Set(L, ID); if (!current->InsertBefore(TN)) + { return 1; + } return 0; } di << "DDataStd_InsertBefore : Error\n"; @@ -255,12 +289,16 @@ static int DDataStd_InsertNodeAfter(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle current, TN; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -273,14 +311,20 @@ static int DDataStd_InsertNodeAfter(Draw_Interpretor& di, int n, const char** a) } if (!DDF::Find(DF, a[2], ID, current)) + { return 1; + } // if (!DDF::Find(DF,a[3],TDataStd_TreeNode::GetDefaultTreeID(),TN)) return 1; TDF_Label L; if (!DDF::FindLabel(DF, a[3], L)) + { return 1; + } TN = TDataStd_TreeNode::Set(L); if (!current->InsertAfter(TN)) + { return 1; + } return 0; } di << "DDataStd_InsertNodeAfter : Error\n"; @@ -298,12 +342,16 @@ static int DDataStd_DetachNode(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle TN; Standard_GUID ID; if (n == 3) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[3])) @@ -316,9 +364,13 @@ static int DDataStd_DetachNode(Draw_Interpretor& di, int n, const char** a) } if (!DDF::Find(DF, a[2], ID, TN)) + { return 1; + } if (!TN->Remove()) + { di << "Can't Detach the TreeNode\n"; + } return 0; } di << "DDataStd_DetachNode : Error\n"; @@ -336,11 +388,15 @@ static int DDataStd_DetachNode(Draw_Interpretor& di, int n, const char** a) static int DDataStd_TreeBrowse(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label lab; TDF_Tool::Label(DF, a[2], lab); @@ -348,9 +404,13 @@ static int DDataStd_TreeBrowse(Draw_Interpretor& di, int n, const char** a) occ::handle NewTreeNode = new DDataStd_TreeBrowser(lab); char* name = new char[50]; if (n == 4) + { Sprintf(name, "treebrowser_%s", a[3]); + } else + { Sprintf(name, "treebrowser_%s", a[1]); + } Draw::Set(name, NewTreeNode); TCollection_AsciiString inst1("treebrowser "); @@ -369,7 +429,9 @@ static int DDataStd_TreeBrowse(Draw_Interpretor& di, int n, const char** a) static int DDataStd_OpenNode(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle browser = occ::down_cast(Draw::GetExisting(a[1])); @@ -381,7 +443,9 @@ static int DDataStd_OpenNode(Draw_Interpretor& di, int n, const char** a) TDF_Label lab; if (n == 3) + { TDF_Tool::Label(browser->Label().Data(), a[2], lab); + } if (n == 2 || lab.IsNull()) { @@ -407,13 +471,17 @@ static int DDataStd_ChildNodeIterate(Draw_Interpretor& di, int n, const char** a { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } const bool AllLevels = (Draw::Atoi(a[3]) != 0); occ::handle TN, Value; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -426,7 +494,9 @@ static int DDataStd_ChildNodeIterate(Draw_Interpretor& di, int n, const char** a } if (!DDF::Find(DF, a[2], ID, TN)) + { return 1; + } // di<<"TDataStd_ChildNodeIterator: \n"; TDataStd_ChildNodeIterator itr(TN, AllLevels); for (; itr.More(); itr.Next()) @@ -459,12 +529,16 @@ static int DDataStd_InitChildNodeIterator(Draw_Interpretor& di, int n, const cha { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } occ::handle TN, Value; Standard_GUID ID; if (n == 4) + { ID = Standard_GUID(TDataStd_TreeNode::GetDefaultTreeID()); + } else { if (!Standard_GUID::CheckGUIDFormat(a[4])) @@ -477,7 +551,9 @@ static int DDataStd_InitChildNodeIterator(Draw_Interpretor& di, int n, const cha } if (!DDF::Find(DF, a[2], ID, TN)) + { return 1; + } const bool AllLevels = (Draw::Atoi(a[3]) != 0); cni.Initialize(TN, AllLevels); return 0; @@ -533,7 +609,9 @@ void DDataStd::TreeCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DData : Standard Attribute Commands"; diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd.cxx index 88a13a47b4..af627db1d4 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd.cxx @@ -64,7 +64,9 @@ bool DDocStd::GetDocument(const char*& Name, if (DD.IsNull()) { if (Complain) - std::cout << Name << " is not a Document" << std::endl; + { + std::cout << Name << " is not a Document" << '\n'; + } return false; } occ::handle STDDOC = DD->GetDocument(); @@ -74,7 +76,9 @@ bool DDocStd::GetDocument(const char*& Name, return true; } if (Complain) - std::cout << Name << " is not a CAF Document" << std::endl; + { + std::cout << Name << " is not a CAF Document" << '\n'; + } return false; } @@ -88,7 +92,9 @@ bool DDocStd::Find(const occ::handle& D, Label.Nullify(); TDF_Tool::Label(D->GetData(), Entry, Label, false); if (Label.IsNull() && Complain) - std::cout << "No label for entry " << Entry << std::endl; + { + std::cout << "No label for entry " << Entry << '\n'; + } return !Label.IsNull(); } @@ -104,9 +110,13 @@ bool DDocStd::Find(const occ::handle& D, if (Find(D, Entry, L, Complain)) { if (L.FindAttribute(ID, A)) + { return true; + } if (Complain) - std::cout << "attribute not found for entry : " << Entry << std::endl; + { + std::cout << "attribute not found for entry : " << Entry << '\n'; + } } return false; } @@ -127,7 +137,9 @@ void DDocStd::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // define commands diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_ApplicationCommands.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_ApplicationCommands.cxx index e6482be2a4..c3b9309a1a 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_ApplicationCommands.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_ApplicationCommands.cxx @@ -61,7 +61,9 @@ static int DDocStd_ListDocuments(Draw_Interpretor& di, int nb, const char** /*a* di << " path : " << D->GetPath(); } else + { di << " not saved"; + } di << "\n"; } return 0; @@ -87,7 +89,9 @@ static int DDocStd_NewDocument(Draw_Interpretor& di, int nb, const char** a) DDocStd::ReturnLabel(di, D->Main()); } else + { di << a[1] << " is already a document\n"; + } return 0; } if (nb == 3) @@ -103,7 +107,9 @@ static int DDocStd_NewDocument(Draw_Interpretor& di, int nb, const char** a) DDocStd::ReturnLabel(di, D->Main()); } else + { di << a[1] << " is already a document\n"; + } return 0; } di << "DDocStd_NewDocument : Error\n"; @@ -236,7 +242,9 @@ static int DDocStd_Save(Draw_Interpretor& di, int nb, const char** a) { occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } occ::handle A = DDocStd::GetApplication(); if (!D->IsSaved()) { @@ -260,7 +268,9 @@ static int DDocStd_SaveAs(Draw_Interpretor& di, int nb, const char** a) { occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } TCollection_ExtendedString path(a[2], true); occ::handle A = DDocStd::GetApplication(); PCDM_StoreStatus theStatus; @@ -489,7 +499,9 @@ static int DDocStd_AddComment(Draw_Interpretor& di, int nb, const char** a) { occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } TCollection_ExtendedString comment(a[2], true); // occ::handle A = DDocStd::GetApplication(); // A->AddComment(D,comment); @@ -508,7 +520,9 @@ static int DDocStd_PrintComments(Draw_Interpretor& di, int nb, const char** a) { occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } NCollection_Sequence comments; D->Comments(comments); @@ -569,7 +583,9 @@ void DDocStd::ApplicationCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DDocStd application commands"; diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_DocumentCommands.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_DocumentCommands.cxx index 66b472f8dd..85ba3b8169 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_DocumentCommands.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_DocumentCommands.cxx @@ -43,7 +43,9 @@ static int DDocStd_Main(Draw_Interpretor& di, int nb, const char** a) { occ::handle DOC; if (!DDocStd::GetDocument(a[1], DOC)) + { return 1; + } DDocStd::ReturnLabel(di, DOC->Main()); return 0; } @@ -59,7 +61,9 @@ static int DDocStd_Format(Draw_Interpretor& di, int n, const char** a) if (n == 2) { if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } // std::cout << "FORMAT : " << D->StorageFormat() << std::endl; di << "FORMAT : "; Standard_SStream aStream; @@ -71,7 +75,9 @@ static int DDocStd_Format(Draw_Interpretor& di, int n, const char** a) if (n == 3) { if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } D->ChangeStorageFormat(a[2]); return 0; } @@ -89,14 +95,22 @@ static int DDocStd_Copy(Draw_Interpretor& di, int n, const char** a) { occ::handle DOC, XDOC; if (!DDocStd::GetDocument(a[1], DOC)) + { return 1; + } if (!DDocStd::GetDocument(a[3], XDOC)) + { return 1; + } TDF_Label L, XL; if (!DDocStd::Find(DOC, a[2], L)) + { return 1; + } if (!DDocStd::Find(XDOC, a[4], XL)) + { return 1; + } TDocStd_XLinkTool XLinkTool; XLinkTool.Copy(L, XL); if (!XLinkTool.IsDone()) @@ -119,14 +133,22 @@ static int DDocStd_CopyWithLink(Draw_Interpretor& di, int n, const char** a) { occ::handle DOC, XDOC; if (!DDocStd::GetDocument(a[1], DOC)) + { return 1; + } if (!DDocStd::GetDocument(a[3], XDOC)) + { return 1; + } TDF_Label L, XL; if (!DDocStd::Find(DOC, a[2], L)) + { return 1; + } if (!DDocStd::Find(XDOC, a[4], XL)) + { return 1; + } TDocStd_XLinkTool XLinkTool; XLinkTool.CopyWithLink(L, XL); if (!XLinkTool.IsDone()) @@ -149,13 +171,17 @@ static int DDocStd_UpdateLink(Draw_Interpretor& di, int nb, const char** a) { occ::handle DOC; if (!DDocStd::GetDocument(a[1], DOC)) + { return 1; + } occ::handle REF; TDocStd_XLinkTool XLinkTool; if (nb == 3) { if (!DDocStd::Find(DOC, a[2], TDF_Reference::GetID(), REF)) + { return 1; + } XLinkTool.UpdateLink(REF->Label()); if (!XLinkTool.IsDone()) { @@ -184,11 +210,15 @@ static int DDocStd_UpdateLink(Draw_Interpretor& di, int nb, const char** a) static int DDocStd_UndoLimit(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } if (n > 2) { @@ -211,11 +241,15 @@ static int DDocStd_UndoLimit(Draw_Interpretor& di, int n, const char** a) static int DDocStd_Undo(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } int i, step = 1; if (n > 2) @@ -231,19 +265,25 @@ static int DDocStd_Undo(Draw_Interpretor& di, int n, const char** a) if (undo) { if (!D->Undo()) + { di << "Undo not done\n"; + } } else { if (!D->Redo()) + { di << "Redo not done\n"; + } } } // Redraw the viewer. occ::handle IC; if (TPrsStd_AISViewer::Find(D->Main(), IC)) + { IC->UpdateCurrentViewer(); + } return 0; } @@ -253,10 +293,14 @@ static int DDocStd_Undo(Draw_Interpretor& di, int n, const char** a) static int DDocStd_NewCommand(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } D->NewCommand(); return 0; } @@ -266,11 +310,15 @@ static int DDocStd_NewCommand(Draw_Interpretor& /*di*/, int n, const char** a) static int DDocStd_OpenCommand(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } D->OpenCommand(); return 0; } @@ -280,10 +328,14 @@ static int DDocStd_OpenCommand(Draw_Interpretor& /*di*/, int n, const char** a) static int DDocStd_AbortCommand(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } D->AbortCommand(); return 0; } @@ -293,10 +345,14 @@ static int DDocStd_AbortCommand(Draw_Interpretor& /*di*/, int n, const char** a) static int DDocStd_CommitCommand(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } D->CommitCommand(); return 0; } @@ -312,13 +368,19 @@ static int DDocStd_DumpDocument(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } di << "\n"; // document name if (D->IsSaved()) + { di << "DOCUMENT : " << D->GetName(); + } else + { di << "DOCUMENT : not saved"; + } di << "\n"; // format // std::cout << "FORMAT : " << D->StorageFormat(); @@ -330,9 +392,13 @@ static int DDocStd_DumpDocument(Draw_Interpretor& di, int nb, const char** arg) // command di << "COMMAND : "; if (D->HasOpenCommand()) + { di << " Is Open"; + } else + { di << " Is Not Open"; + } // undo di << "UNDO :"; di << " limit :" << D->GetUndoLimit(); @@ -347,16 +413,22 @@ static int DDocStd_DumpDocument(Draw_Interpretor& di, int nb, const char** arg) // modified di << "MODIFIED : "; if (D->IsModified()) + { di << "true"; + } else + { di << "false"; + } di << "\n"; if (!TDocStd_Modified::IsEmpty(D->Main())) { di << "MODIFICATIONS : "; NCollection_Map::Iterator it(D->GetModified()); if (!it.More()) + { di << "VALID\n"; + } else { TCollection_AsciiString string; @@ -385,12 +457,16 @@ static int DDocStd_SetModified(Draw_Interpretor& di, int n, const char** a) { occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } TDF_Label L; for (int i = 2; i < n; i++) { if (DDocStd::Find(D, a[i], L)) + { D->SetModified(L); + } } return 0; } @@ -494,7 +570,9 @@ void DDocStd::DocumentCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DDocStd commands"; diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_DrawDocument.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_DrawDocument.cxx index 6a816a88e4..8db8e13a7c 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_DrawDocument.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_DrawDocument.cxx @@ -70,7 +70,7 @@ void DDocStd_DrawDocument::Dump(Standard_OStream& S) const } else { - S << myDocument->DynamicType()->Name() << " is not a CAF document" << std::endl; + S << myDocument->DynamicType()->Name() << " is not a CAF document" << '\n'; } } diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_MTMCommands.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_MTMCommands.cxx index 4bef8ce7a9..337a5a52a0 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_MTMCommands.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_MTMCommands.cxx @@ -45,11 +45,15 @@ static occ::handle sMultiTransactionManager = n static int mtmCreate(Draw_Interpretor& /*di*/, int n, const char** a) { if (!sMultiTransactionManager.IsNull()) + { sMultiTransactionManager->SetUndoLimit(0); + } sMultiTransactionManager = new TDocStd_MultiTransactionManager(); if (n > 1) + { sMultiTransactionManager->SetUndoLimit(Draw::Atoi(a[1])); + } return 0; } @@ -110,9 +114,13 @@ static int mtmCommitTransaction(Draw_Interpretor& di, int n, const char** a) return 1; } if (n > 1) + { sMultiTransactionManager->CommitCommand(TCollection_ExtendedString(a[1], true)); + } else + { sMultiTransactionManager->CommitCommand(); + } return 0; } @@ -224,7 +232,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) int num = Draw::Atoi(argv[3]); TDF_AttributeIterator itr(lab, false); for (int i = 1; itr.More() && i < num; i++) + { itr.Next(); + } if (!itr.More()) { @@ -250,7 +260,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) { TDF_Tool::Entry(child->Label(), ref); if (child != TN->First()) + { di << ", "; + } di << ref.ToCString(); child = child->Next(); } @@ -297,7 +309,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { di << ", "; + } TCollection_AsciiString str(val->Value(j)); di << str.ToCString(); } @@ -308,7 +322,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { di << ", "; + } TCollection_AsciiString str(val->Value(j)); di << str.ToCString(); } @@ -319,7 +335,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) for (int j = val->Lower(); j <= val->Upper(); j++) { if (j > val->Lower()) + { di << ", "; + } TCollection_AsciiString str(val->Value(j)); di << str.ToCString(); } @@ -330,7 +348,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape S = val->Get(); di << S.TShape()->DynamicType()->Name(); if (!S.Location().IsIdentity()) + { di << "(located)"; + } } return 0; @@ -373,7 +393,9 @@ void DDocStd::MTMCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "MTM test commands"; diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_ShapeSchemaCommands.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_ShapeSchemaCommands.cxx index 42bbac1d2e..96320558db 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_ShapeSchemaCommands.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_ShapeSchemaCommands.cxx @@ -124,7 +124,9 @@ static int DDocStd_fsdwrite(Draw_Interpretor& theDI, int theArgNb, const char** } if (hasStorageDriver) + { --iArgN; + } Storage_Error aStatus = aFileDriver->Open(theArgs[iArgN], Storage_VSWrite); if (aStatus != Storage_VSOk) @@ -146,9 +148,13 @@ static int DDocStd_fsdwrite(Draw_Interpretor& theDI, int theArgNb, const char** } aShapes.Append(aShape); if (aShapeNames.IsBound(theArgs[i])) + { aShapeNames.ChangeFind(theArgs[i]) += 1; + } else + { aShapeNames.Bind(theArgs[i], 1); + } } occ::handle aData = new StdStorage_Data; @@ -211,7 +217,9 @@ static int DDocStd_fsdread(Draw_Interpretor& theDI, int theArgNb, const char** t } bool rflag(false); if (strcmp(theArgs[2], "restore_with_names") == 0) + { rflag = true; + } occ::handle aData; Storage_Error anError = StdStorage::Read(TCollection_AsciiString(theArgs[1]), aData); if (anError != Storage_VSOk) @@ -242,7 +250,9 @@ static int DDocStd_fsdread(Draw_Interpretor& theDI, int theArgNb, const char** t if (rflag) { if (!aRoot->Name().IsEmpty()) + { DBRep::Set(aRoot->Name().ToCString(), aShape); + } else { TCollection_AsciiString aNam("name_"); @@ -255,7 +265,9 @@ static int DDocStd_fsdread(Draw_Interpretor& theDI, int theArgNb, const char** t #endif } else + { aShapes.Append(aShape); + } } } } @@ -273,11 +285,15 @@ static int DDocStd_fsdread(Draw_Interpretor& theDI, int theArgNb, const char** t TopoDS_Compound aC; aB.MakeCompound(aC); for (int i = 1; i <= aShapes.Length(); ++i) + { aB.Add(aC, aShapes.Value(i)); + } DBRep::Set(theArgs[2], aC); } else + { DBRep::Set(theArgs[2], aShapes.First()); + } } return 0; } @@ -291,7 +307,9 @@ void DDocStd::ShapeSchemaCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "Shape persistence commands"; diff --git a/src/Draw/TKDCAF/DDocStd/DDocStd_ToolsCommands.cxx b/src/Draw/TKDCAF/DDocStd/DDocStd_ToolsCommands.cxx index fa4ec95f4e..8947fd7102 100644 --- a/src/Draw/TKDCAF/DDocStd/DDocStd_ToolsCommands.cxx +++ b/src/Draw/TKDCAF/DDocStd/DDocStd_ToolsCommands.cxx @@ -37,10 +37,14 @@ static int DDocStd_UpdateXLinks(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } TCollection_AsciiString Entry(a[2]); D->UpdateReferences(Entry); // DDocStd::DisplayModified(a[1]); @@ -58,7 +62,9 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } // NCollection_List> added, forgoten, resumed, removed, modified; occ::handle AD; @@ -104,9 +110,13 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) di << "ADDED :"; it.Initialize(added); if (it.More()) + { di << "\n"; + } else + { di << " empty\n"; + } for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value()->Label(), string); @@ -119,9 +129,13 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) di << "FORGOTEN :"; it.Initialize(forgoten); if (it.More()) + { di << "\n"; + } else + { di << " empty\n"; + } for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value()->Label(), string); @@ -134,9 +148,13 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) di << "RESUMED :"; it.Initialize(resumed); if (it.More()) + { di << "\n"; + } else + { di << " empty\n"; + } for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value()->Label(), string); @@ -149,9 +167,13 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) di << "REMOVED :"; it.Initialize(removed); if (it.More()) + { di << "\n"; + } else + { di << " empty\n"; + } for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value()->Label(), string); @@ -164,9 +186,13 @@ static int DDocStd_DumpCommand(Draw_Interpretor& di, int nb, const char** arg) di << "MODIFIED :"; it.Initialize(modified); if (it.More()) + { di << "\n"; + } else + { di << " empty\n"; + } for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value()->Label(), string); @@ -186,7 +212,9 @@ void DDocStd::ToolsCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DDocStd commands"; diff --git a/src/Draw/TKDCAF/DNaming/DNaming.cxx b/src/Draw/TKDCAF/DNaming/DNaming.cxx index a74ea4c37b..5c288d946f 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming.cxx @@ -122,10 +122,12 @@ TopoDS_Shape DNaming::CurrentShape(const char* const LabelName, const occ::handl Label.FindAttribute(TNaming_NamedShape::GetID(), NS); S = TNaming_Tool::CurrentShape(NS); if (S.IsNull()) + { #ifdef OCCT_DEBUG std::cout << "current shape from " << LabelName << " is deleted" << std::endl; #endif - return S; + return S; + } } return S; } @@ -154,7 +156,9 @@ TCollection_AsciiString DNaming::GetEntry(const TopoDS_Shape& Shape, { theStatus++; if (theStatus == 2) + { break; + } } return entry; } @@ -165,7 +169,9 @@ void DNaming::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DNaming::BasicCommands(theCommands); @@ -197,7 +203,9 @@ static void LoadC0Vertices(const TopoDS_Shape& S, const occ::handle::Iterator itrF(vertexNaborFaces.Find(aVertex)); for (; itrF.More(); itrF.Next()) @@ -247,7 +255,9 @@ static void LoadC0Edges(const TopoDS_Shape& S, const occ::handle& { const TopoDS_Shape& anEdge = explV.Current(); if (!edgeNaborFaces.IsBound(anEdge)) + { edgeNaborFaces.Bind(anEdge, empty); + } bool faceIsNew = true; NCollection_List::Iterator itrF(edgeNaborFaces.Find(anEdge)); for (; itrF.More(); itrF.Next()) @@ -277,16 +287,22 @@ static void LoadC0Edges(const TopoDS_Shape& S, const occ::handle& { const NCollection_List& aList1 = edgeNaborFaces.Find(anEdge1); if (aList1.Extent() < 2) + { continue; // mpv (06.09.2002): these edges already was loaded + } NCollection_DataMap, TopTools_ShapeMapHasher>:: Iterator itr(edgeNaborFaces); for (; itr.More(); itr.Next()) { const TopoDS_Shape& anEdge2 = itr.Key(); if (anEdgesToDelete.Contains(anEdge2)) + { continue; + } if (anEdge1.IsSame(anEdge2)) + { continue; + } const NCollection_List& aList2 = itr.Value(); // compare lists of the neighbour faces of edge1 and edge2 if (aList1.Extent() == aList2.Extent()) @@ -294,10 +310,16 @@ static void LoadC0Edges(const TopoDS_Shape& S, const occ::handle& int aMatches = 0; for (NCollection_List::Iterator aLIter1(aList1); aLIter1.More(); aLIter1.Next()) + { for (NCollection_List::Iterator aLIter2(aList2); aLIter2.More(); aLIter2.Next()) + { if (aLIter1.Value().IsSame(aLIter2.Value())) + { aMatches++; + } + } + } if (aMatches == aList1.Extent()) { aC0 = true; @@ -340,18 +362,26 @@ static bool GetDangleShapes( subShapeAndAncestors; TopAbs_ShapeEnum GeneratedTo; if (GeneratedFrom == TopAbs_FACE) + { GeneratedTo = TopAbs_EDGE; + } else if (GeneratedFrom == TopAbs_EDGE) + { GeneratedTo = TopAbs_VERTEX; + } else + { return false; + } TopExp::MapShapesAndAncestors(ShapeIn, GeneratedTo, GeneratedFrom, subShapeAndAncestors); for (int i = 1; i <= subShapeAndAncestors.Extent(); i++) { const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i); const NCollection_List& ancestors = subShapeAndAncestors.FindFromIndex(i); if (ancestors.Extent() == 1) + { Dangles.Bind(ancestors.First(), mayBeDangle); + } } return !Dangles.IsEmpty(); } @@ -364,10 +394,14 @@ static void LoadGeneratedDangleShapes(const TopoDS_Shape& ShapeIn, { NCollection_DataMap dangles; if (!GetDangleShapes(ShapeIn, GeneratedFrom, dangles)) + { return; + } NCollection_DataMap::Iterator itr(dangles); for (; itr.More(); itr.Next()) + { Builder.Generated(itr.Key(), itr.Value()); + } } //======================================================================= @@ -489,11 +523,15 @@ static void LoadFirstLevel(const TopoDS_Shape& S, const occ::handle aTagger = TDF_TagSource::Set(theResultLabel); if (aTagger.IsNull()) + { return; + } aTagger->Set(0); LoadFirstLevel(theShape, aTagger); @@ -525,7 +565,9 @@ void DNaming::LoadPrime(const TDF_Label& theResultLabel, const TopoDS_Shape& the occ::handle aTagger = TDF_TagSource::Set(theResultLabel); if (aTagger.IsNull()) + { return; + } aTagger->Set(0); LoadFirstLevel(theShape, aTagger); @@ -543,7 +585,9 @@ occ::handle DNaming::GetReal(const occ::handle aReal; if (!POSITION(theFunction, thePosition).FindAttribute(TDataStd_Real::GetID(), aReal)) + { aReal = TDataStd_Real::Set(POSITION(theFunction, thePosition), 0.0); + } return aReal; } @@ -557,7 +601,9 @@ occ::handle DNaming::GetInteger( { occ::handle anInteger; if (!POSITION(theFunction, thePosition).FindAttribute(TDataStd_Integer::GetID(), anInteger)) + { anInteger = TDataStd_Integer::Set(POSITION(theFunction, thePosition), 0); + } return anInteger; } @@ -568,7 +614,9 @@ occ::handle DNaming::GetString(const occ::handle aString; if (!POSITION(theFunction, thePosition).FindAttribute(TDataStd_Name::GetID(), aString)) + { aString = TDataStd_Name::Set(POSITION(theFunction, thePosition), ""); + } return aString; } @@ -597,7 +645,9 @@ occ::handle DNaming::GetObjectArg( occ::handle anObject; occ::handle aReference; if (POSITION(theFunction, thePosition).FindAttribute(TDF_Reference::GetID(), aReference)) + { aReference->Get().FindAttribute(GEOMOBJECT_GUID, anObject); + } return anObject; } @@ -611,7 +661,9 @@ void DNaming::SetObjectArg(const occ::handle& theFunction, { if (theNewValue.IsNull()) + { return; + } TDF_Reference::Set(POSITION(theFunction, thePosition), theNewValue->Label()); } @@ -629,7 +681,9 @@ occ::handle DNaming::GetObjectValue( occ::handle aReference; if (theObject->FindAttribute(TDF_Reference::GetID(), aReference)) + { aReference->Get().FindAttribute(TNaming_NamedShape::GetID(), aNS); + } } return aNS; @@ -665,12 +719,18 @@ occ::handle DNaming::GetPrevFunction( while (!aNode.IsNull()) { if (!aNode->HasPrevious()) + { return aPrevFun; + } else + { aNode = aNode->Previous(); + } aNode->FindAttribute(TFunction_Function::GetID(), aPrevFun); if (!aPrevFun.IsNull()) + { break; + } } } return aPrevFun; @@ -697,17 +757,25 @@ occ::handle DNaming::GetFirstFunction( occ::handle aNode; theObject->FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aNode); if (aNode.IsNull()) + { return aFirstFun; + } if (!aNode->HasFirst()) + { return aFirstFun; + } else + { aNode = aNode->First(); + } while (!aNode.IsNull()) { aNode->FindAttribute(TFunction_Function::GetID(), aFirstFun); if (!aFirstFun.IsNull()) + { break; + } aNode = aNode->Next(); } } @@ -725,16 +793,24 @@ occ::handle DNaming::GetLastFunction( occ::handle aNode; theObject->FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aNode); if (aNode.IsNull()) + { return aLastFun; + } if (!aNode->HasFirst()) + { return aLastFun; + } else + { aNode = aNode->First(); + } while (!aNode.IsNull()) { if (aNode->IsAttribute(TFunction_Function::GetID())) + { aNode->FindAttribute(TFunction_Function::GetID(), aLastFun); + } aNode = aNode->Next(); } } @@ -754,9 +830,13 @@ occ::handle DNaming::GetObjectFromFunction( if (!aNode.IsNull()) { if (!aNode->HasFather()) + { return anObject; + } else + { aNode = aNode->Father(); + } aNode->FindAttribute(GEOMOBJECT_GUID, anObject); } } @@ -779,7 +859,9 @@ void DNaming::LoadResult(const TDF_Label& ResultLabel, BRepAlgoAPI_BooleanOperat { occ::handle Tagger = TDF_TagSource::Set(ResultLabel); if (Tagger.IsNull()) + { return; + } Tagger->Set(0); TNaming_Builder Builder(ResultLabel); TopoDS_Shape aResult = MS.Shape(); @@ -789,11 +871,15 @@ void DNaming::LoadResult(const TDF_Label& ResultLabel, BRepAlgoAPI_BooleanOperat { TopoDS_Iterator itr(aResult); if (itr.More()) + { aResult = itr.Value(); + } } } if (MS.Shape1().IsNull()) + { Builder.Generated(aResult); + } else { Builder.Modify(MS.Shape1(), aResult); @@ -815,7 +901,9 @@ void DNaming::LoadAndOrientModifiedShapes( { const TopoDS_Shape& Root = ShapeExplorer.Current(); if (!View.Add(Root)) + { continue; + } const NCollection_List& Shapes = MS.Modified(Root); NCollection_List::Iterator ShapesIterator(Shapes); for (; ShapesIterator.More(); ShapesIterator.Next()) @@ -826,7 +914,9 @@ void DNaming::LoadAndOrientModifiedShapes( newShape.Orientation((SubShapes(newShape)).Orientation()); } if (!Root.IsSame(newShape)) + { Builder.Modify(Root, newShape); + } } } } @@ -844,7 +934,9 @@ void DNaming::LoadDeletedShapes(BRepBuilderAPI_MakeShape& MS, { const TopoDS_Shape& Root = ShapeExplorer.Current(); if (!View.Add(Root)) + { continue; + } if (MS.IsDeleted(Root)) { Builder.Delete(Root); @@ -867,7 +959,9 @@ void DNaming::LoadAndOrientGeneratedShapes( { const TopoDS_Shape& Root = ShapeExplorer.Current(); if (!View.Add(Root)) + { continue; + } const NCollection_List& Shapes = MS.Generated(Root); NCollection_List::Iterator ShapesIterator(Shapes); for (; ShapesIterator.More(); ShapesIterator.Next()) @@ -878,7 +972,9 @@ void DNaming::LoadAndOrientGeneratedShapes( newShape.Orientation((SubShapes(newShape)).Orientation()); } if (!Root.IsSame(newShape)) + { Builder.Generated(Root, newShape); + } } } } @@ -890,10 +986,14 @@ void DNaming::LoadAndOrientGeneratedShapes( bool DNaming::ComputeAxis(const occ::handle& theNS, gp_Ax1& theAx1) { if (theNS.IsNull() || theNS->IsEmpty()) + { return false; + } TopoDS_Shape aShape = theNS->Get(); if (aShape.IsNull()) + { return false; + } if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) { if (aShape.ShapeType() == TopAbs_WIRE) @@ -983,7 +1083,9 @@ bool DNaming::ComputeSweepDir(const TopoDS_Shape& theShape, gp_Ax1& theAxis) std::cout << "Surface Dynamic TYPE = " << s << std::endl; #endif if (aSurf->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { aSurf = occ::down_cast(aSurf)->BasisSurface(); + } aPlane = occ::down_cast(aSurf); } @@ -991,19 +1093,27 @@ bool DNaming::ComputeSweepDir(const TopoDS_Shape& theShape, gp_Ax1& theAxis) { BRepLib_FindSurface aFinder(theShape, 0., true); if (!aFinder.Found()) + { return false; + } aPlane = occ::down_cast(aFinder.Surface()); } if (aPlane.IsNull()) + { return false; + } theAxis = aPlane->Pln().Axis(); if (!aPlane->Pln().Direct()) + { theAxis.Reverse(); + } if (theShape.Orientation() == TopAbs_REVERSED) + { theAxis.Reverse(); + } return true; } diff --git a/src/Draw/TKDCAF/DNaming/DNaming_BasicCommands.cxx b/src/Draw/TKDCAF/DNaming/DNaming_BasicCommands.cxx index a53dbda5a4..6e878bcb49 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_BasicCommands.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_BasicCommands.cxx @@ -45,7 +45,9 @@ static int Ascendants(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } char name[100]; @@ -53,19 +55,27 @@ static int Ascendants(Draw_Interpretor& di, int n, const char** a) // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } int T; if (n > 3) + { T = Draw::Atoi(a[3]); + } else + { T = ND->Transaction(); + } // TNaming_OldShapeIterator it (S, T, US); TNaming_OldShapeIterator it(S, T, ND->Root()); @@ -89,25 +99,35 @@ static int Descendants(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } char name[100]; occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } int T; if (n > 3) + { T = Draw::Atoi(a[3]); + } else + { T = ND->Transaction(); + } TNaming_NewShapeIterator it(S, T, ND->Root()); int i = 0; @@ -130,12 +150,16 @@ static int Descendants(Draw_Interpretor& di, int n, const char** a) static int Getentry(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); @@ -169,12 +193,16 @@ static int Getentry(Draw_Interpretor& di, int n, const char** a) static int NamedShape(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } TopoDS_Shape SS = DBRep::Get(a[2]); if (SS.IsNull()) { @@ -201,20 +229,28 @@ static int NamedShape(Draw_Interpretor& di, int n, const char** a) static int Currentshape(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle ND; if (!DDF::GetDF(a[1], ND)) + { return 1; + } const char* LabelName = a[2]; TopoDS_Shape S = DNaming::CurrentShape(LabelName, ND); if (!S.IsNull()) { if (n == 4) + { DBRep::Set(a[3], S); + } else + { DBRep::Set(a[2], S); + } return 0; } return 0; @@ -225,16 +261,22 @@ static int Currentshape(Draw_Interpretor&, int n, const char** a) static int Initialshape(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle ND; if (!DDF::GetDF(a[1], ND)) + { return 1; + } TopoDS_Shape NS = DBRep::Get(a[2]); if (NS.IsNull()) + { return 1; + } NCollection_List Labels; TopoDS_Shape S = TNaming_Tool::InitialShape(NS, ND->Root(), Labels); @@ -267,12 +309,16 @@ static int Exploreshape(Draw_Interpretor& di, int n, const char** a) char name[100]; if (n < 4) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); int Trans = ND->Transaction(); @@ -333,18 +379,26 @@ static int Generatedshape(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TopoDS_Shape Gen = DBRep::Get(arg[2]); occ::handle Generation; if (!DDF::Find(DF, arg[3], TNaming_NamedShape::GetID(), Generation)) + { return 1; + } S = TNaming_Tool::GeneratedShape(Gen, Generation); if (!S.IsNull()) { if (nb == 4) + { DBRep::Set(arg[4], S); + } else + { DBRep::Set(arg[3], S); + } return 0; } } @@ -362,16 +416,24 @@ static int Getshape(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::Find(DF, arg[2], TNaming_NamedShape::GetID(), A)) + { return 1; + } s = TNaming_Tool::GetShape(A); if (!s.IsNull()) { if (nb == 4) + { DBRep::Set(arg[3], s); + } else + { DBRep::Set(arg[2], s); + } return 0; } } @@ -391,9 +453,13 @@ static int Collect(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::Find(DF, arg[2], TNaming_NamedShape::GetID(), A)) + { return 1; + } if (nb >= 4) { OnlyModif = (Draw::Atoi(arg[3]) != 0); @@ -416,12 +482,16 @@ static int Collect(Draw_Interpretor& di, int nb, const char** arg) static int Getcreationentry(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape SS = DBRep::Get(a[2]); @@ -469,12 +539,16 @@ static int DNaming_ImportShape(Draw_Interpretor& di, int nb, const char** a) { occ::handle aDF; if (!DDF::GetDF(a[1], aDF)) + { return 1; + } TDF_Label L; DDF::AddLabel(aDF, a[2], L); const TopoDS_Shape& aShape = DBRep::Get(a[3]); if (aShape.IsNull()) + { return 1; + } if (nb == 5) { TDataStd_Name::Set(L, TCollection_ExtendedString(a[4], true)); @@ -501,7 +575,9 @@ static int CheckIter(Draw_Interpretor& di, int nb, const char** arg) occ::handle aDF; bool aNew(true); if (!DDF::GetDF(arg[1], aDF)) + { return 1; + } TDF_Label aLabel; DDF::AddLabel(aDF, arg[2], aLabel); TNaming_Builder aNB(aLabel); @@ -509,7 +585,9 @@ static int CheckIter(Draw_Interpretor& di, int nb, const char** arg) aNB.Generated(aShape); TNaming_Iterator aNameIter(aLabel); if (nb == 5) + { aNew = (Draw::Atoi(arg[4]) != 0); + } if (aNew) { TNaming_NewShapeIterator aNewShapeIter(aNameIter); @@ -533,7 +611,9 @@ void DNaming::BasicCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands"; diff --git a/src/Draw/TKDCAF/DNaming/DNaming_BooleanOperationDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_BooleanOperationDriver.cxx index 6142ac6663..d0ba6bfe7f 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_BooleanOperationDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_BooleanOperationDriver.cxx @@ -90,14 +90,18 @@ int DNaming_BooleanOperationDriver::Execute(occ::handle& theL occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } // occ::handle anObject = DNaming::GetObjectFromFunction(aFunction); // if(anObject.IsNull()) return -1; // occ::handle anObjectNS = DNaming::GetObjectValue(anObject); occ::handle aPrevFun = DNaming::GetPrevFunction(aFunction); if (aPrevFun.IsNull()) + { return -1; + } const TDF_Label& aLab = RESPOSITION(aPrevFun); occ::handle anObjectNS; aLab.FindAttribute(TNaming_NamedShape::GetID(), anObjectNS); @@ -165,7 +169,9 @@ int DNaming_BooleanOperationDriver::Execute(occ::handle& theL return -1; } if (!anIsDone) + { return -1; + } else { theLog->SetValid(RESPOSITION(aFunction), true); @@ -184,14 +190,22 @@ static TopAbs_ShapeEnum ShapeType(const TopoDS_Shape& theShape) { TopoDS_Iterator itr(theShape); if (!itr.More()) + { return TypeSh; + } TypeSh = ShapeType(itr.Value()); if (TypeSh == TopAbs_COMPOUND) + { return TypeSh; + } itr.Next(); for (; itr.More(); itr.Next()) + { if (ShapeType(itr.Value()) != TypeSh) + { return TopAbs_COMPOUND; + } + } } return TypeSh; } @@ -214,10 +228,14 @@ static bool IsWRCase(const BRepAlgoAPI_BooleanOperation& MS) const TopoDS_Shape& ToolSh = MS.Shape2(); const TopAbs_ShapeEnum& Type1 = ShapeType(ObjSh); if (Type1 == TopAbs_COMPOUND || Type1 > TopAbs_FACE) + { return false; + } const TopAbs_ShapeEnum& Type2 = ShapeType(ToolSh); if (Type2 == TopAbs_COMPOUND || Type2 > TopAbs_FACE) + { return false; + } NCollection_List aList; if (Type1 != TopAbs_FACE) @@ -226,11 +244,15 @@ static bool IsWRCase(const BRepAlgoAPI_BooleanOperation& MS) for (; anExp.More(); anExp.Next()) { if (IsValidSurfType(TopoDS::Face(anExp.Current()))) + { aList.Append(anExp.Current()); + } } } else if (IsValidSurfType(TopoDS::Face(ObjSh))) + { aList.Append(ObjSh); + } if (aList.Extent() == 0) { @@ -240,14 +262,20 @@ static bool IsWRCase(const BRepAlgoAPI_BooleanOperation& MS) for (; anExp.More(); anExp.Next()) { if (IsValidSurfType(TopoDS::Face(anExp.Current()))) + { aList.Append(anExp.Current()); + } } } else if (IsValidSurfType(TopoDS::Face(ToolSh))) + { aList.Append(ToolSh); + } } if (aList.Extent() > 0) + { return true; + } return false; } @@ -304,14 +332,18 @@ void DNaming_BooleanOperationDriver::LoadNamingDS(const TDF_Label& bool theCase(false); NCollection_Map aView; if (aList.Extent() > 0 && aList.Extent() < 3) + { theCase = true; + } NCollection_List::Iterator it(aList); for (; it.More(); it.Next()) { TopoDS_Shape newShape = it.Value(); if (SubShapes.IsBound(newShape)) + { newShape.Orientation((SubShapes(newShape)).Orientation()); + } TNaming_Builder secED(theResultLabel.NewChild()); secED.Generated(newShape); if (theCase) @@ -388,7 +420,9 @@ bool DNaming_BooleanOperationDriver::CheckAndLoad( BRepCheck_Analyzer aCheck(theMkOpe.Shape()); bool aResIsValid = true; if (!aCheck.IsValid(theMkOpe.Shape())) + { aResIsValid = FixSameParameter(theMkOpe.Shape(), aCheck); + } if (aResIsValid) { if (theFunction->GetDriverGUID() == FUSE_GUID) @@ -484,7 +518,9 @@ void FindSPErrorEdges(const TopoDS_Shape& const occ::handle& aResult = theAnalyzer.Result(anExpE.Current()); if (aResult.IsNull() || theMap.Contains(anExpE.Current())) + { continue; + } for (aResult->InitContextIterator(); aResult->MoreShapeInContext(); aResult->NextShapeInContext()) @@ -537,7 +573,9 @@ bool FindOtherErrors(const TopoDS_Shape& theShape, for (; anIt.More(); anIt.Next()) { if (FindOtherErrors(anIt.Value(), theAnalyzer, theMap)) + { return true; + } } const occ::handle& aResult = theAnalyzer.Result(theShape); @@ -562,7 +600,9 @@ bool FindOtherErrors(const TopoDS_Shape& theShape, const occ::handle& aResultE = theAnalyzer.Result(anExpE.Current()); if (aResultE.IsNull()) + { continue; + } bOtherFound = false; for (aResultE->InitContextIterator(); aResultE->MoreShapeInContext(); @@ -575,7 +615,9 @@ bool FindOtherErrors(const TopoDS_Shape& theShape, itl.Initialize(aResultE->StatusOnShape()); if (!itl.More()) + { continue; + } if (itl.Value() != BRepCheck_NoError) { diff --git a/src/Draw/TKDCAF/DNaming/DNaming_BoxDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_BoxDriver.cxx index 62a68a70c2..13e048943d 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_BoxDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_BoxDriver.cxx @@ -61,7 +61,9 @@ int DNaming_BoxDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } // perform calculations @@ -97,7 +99,9 @@ int DNaming_BoxDriver::Execute(occ::handle& theLog) const // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(RESPOSITION(aFunction), aLocation, true); + } theLog->SetValid(RESPOSITION(aFunction), true); diff --git a/src/Draw/TKDCAF/DNaming/DNaming_CylinderDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_CylinderDriver.cxx index 09e06cc2da..e642f6972b 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_CylinderDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_CylinderDriver.cxx @@ -66,7 +66,9 @@ int DNaming_CylinderDriver::Execute(occ::handle& theLog) cons occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } double aRadius = DNaming::GetReal(aFunction, CYL_RADIUS)->Get(); double aHeight = DNaming::GetReal(aFunction, CYL_HEIGHT)->Get(); @@ -158,7 +160,9 @@ int DNaming_CylinderDriver::Execute(occ::handle& theLog) cons // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(RESPOSITION(aFunction), aLocation, true); + } theLog->SetValid(RESPOSITION(aFunction), true); aFunction->SetFailure(DONE); diff --git a/src/Draw/TKDCAF/DNaming/DNaming_FilletDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_FilletDriver.cxx index ebd7eac399..33e0f88648 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_FilletDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_FilletDriver.cxx @@ -67,11 +67,15 @@ int DNaming_FilletDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } occ::handle aPrevFun = DNaming::GetPrevFunction(aFunction); if (aPrevFun.IsNull()) + { return -1; + } const TDF_Label& aLab = RESPOSITION(aPrevFun); occ::handle aContextNS; aLab.FindAttribute(TNaming_NamedShape::GetID(), aContextNS); @@ -136,9 +140,13 @@ int DNaming_FilletDriver::Execute(occ::handle& theLog) const { const TopoDS_Edge& anEdge = TopoDS::Edge(expl.Current()); if (!View.Add(anEdge)) + { continue; + } else + { aMkFillet.Add(aRadius, anEdge); // Edge + } } } else @@ -185,13 +193,19 @@ void DNaming_FilletDriver::LoadNamingDS(const TDF_Label& theResultLabel { TopoDS_Iterator itr(aResult); if (itr.More()) + { aResult = itr.Value(); + } } } if (aResult.IsNull()) + { aBuilder.Generated(aResult); + } else + { aBuilder.Modify(theContext, aResult); + } NCollection_DataMap SubShapes; for (TopExp_Explorer Exp(aResult, TopAbs_FACE); Exp.More(); Exp.Next()) diff --git a/src/Draw/TKDCAF/DNaming/DNaming_Line3DDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_Line3DDriver.cxx index 3660e9fc7b..89963b92f0 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_Line3DDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_Line3DDriver.cxx @@ -69,7 +69,9 @@ int DNaming_Line3DDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } aFunction->SetFailure(NOTDONE); occ::handle aPrevILine3D = DNaming::GetFunctionResult(aFunction); @@ -162,10 +164,14 @@ int DNaming_Line3DDriver::Execute(occ::handle& theLog) const aShape1 = aNS1->Get(); BRepBuilderAPI_MakeEdge aMakeEdge(TopoDS::Vertex(aShape2), TopoDS::Vertex(aShape1)); if (aMakeEdge.IsDone()) + { aMakeWire.Add(aMakeEdge.Edge()); + } } if (aMakeWire.IsDone()) + { aWire = aMakeWire.Wire(); + } if (aWire.IsNull()) { @@ -192,7 +198,9 @@ int DNaming_Line3DDriver::Execute(occ::handle& theLog) const // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(aResultLabel, aLocation, true); + } theLog->SetValid(aResultLabel, true); @@ -210,7 +218,9 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& const bool isClosed) const { if (theWire.IsNull()) + { return; + } // Wire TNaming_Builder aWBuilder(theResultLabel); aWBuilder.Generated(theWire); @@ -219,7 +229,9 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& #endif int aLength = theArV.Length(); if (aLength < 2) + { return; + } TopoDS_Shape aShape; NCollection_Array1 anArE(1, aLength); TopoDS_Vertex aFirst, aLast; @@ -244,9 +256,13 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& } } if (!aFound) + { anArE.SetValue(i, aShape); + } else + { aFound = false; + } } if (isClosed) { @@ -272,7 +288,9 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& } } if (!aFound) + { anArE.SetValue(aLength, aShape); + } } else { @@ -295,7 +313,9 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& { occ::handle aNS; if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + { TNaming_Builder aB(aLab); + } } } // put vertexes @@ -312,7 +332,9 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& { occ::handle aNS; if (aLab1.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + { TNaming_Builder aB(aLab1); + } } if (!aLast.IsNull()) { @@ -323,6 +345,8 @@ void DNaming_Line3DDriver::LoadNamingDS(const TDF_Label& { occ::handle aNS; if (aLab2.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + { TNaming_Builder aB(aLab2); + } } } diff --git a/src/Draw/TKDCAF/DNaming/DNaming_ModelingCommands.cxx b/src/Draw/TKDCAF/DNaming/DNaming_ModelingCommands.cxx index 637d5e7777..cf0efcef38 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_ModelingCommands.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_ModelingCommands.cxx @@ -92,12 +92,16 @@ static int DNaming_AddObject(Draw_Interpretor& di, int nb, const char** a) { occ::handle aDoc; if (!DDocStd::GetDocument(a[1], aDoc)) + { return 1; + } occ::handle anObj = AddObject(aDoc); if (!anObj.IsNull()) { if (nb == 3) + { TDataStd_Name::Set(anObj->Label(), TCollection_ExtendedString(a[2], true)); + } DDF::ReturnLabel(di, anObj->Label()); return 0; } @@ -154,47 +158,89 @@ static occ::handle GetDriver(const TCollection_AsciiString& na { occ::handle aDrv; if (name == "Box") + { aDrv = new DNaming_BoxDriver(); + } else if (name == "Cyl") + { aDrv = new DNaming_CylinderDriver(); + } else if (name == "Sph") + { aDrv = new DNaming_SphereDriver(); + } else if (name == "Cut") + { aDrv = new DNaming_BooleanOperationDriver(); + } else if (name == "Fuse") + { aDrv = new DNaming_BooleanOperationDriver(); + } else if (name == "Comm") + { aDrv = new DNaming_BooleanOperationDriver(); + } else if (name == "Prism") + { aDrv = new DNaming_PrismDriver(); + } else if (name == "FulRevol") + { aDrv = new DNaming_RevolutionDriver(); + } else if (name == "SecRevol") + { aDrv = new DNaming_RevolutionDriver(); + } else if (name == "PTxyz") + { aDrv = new DNaming_TransformationDriver(); + } else if (name == "PTALine") + { aDrv = new DNaming_TransformationDriver(); + } else if (name == "PRLine") + { aDrv = new DNaming_TransformationDriver(); + } else if (name == "PMirr") + { aDrv = new DNaming_TransformationDriver(); + } else if (name == "Fillet") + { aDrv = new DNaming_FilletDriver(); + } else if (name == "Attach") + { aDrv = new DNaming_SelectionDriver(); + } else if (name == "XAttach") + { aDrv = new DNaming_SelectionDriver(); + } else if (name == "PntXYZ") + { aDrv = new DNaming_PointDriver(); + } else if (name == "PntRLT") + { aDrv = new DNaming_PointDriver(); + } else if (name == "Line3D") + { aDrv = new DNaming_Line3DDriver(); + } else if (name == "Section") + { aDrv = new DNaming_BooleanOperationDriver(); + } else - std::cout << "the specified driver is not supported" << std::endl; + { + std::cout << "the specified driver is not supported" << '\n'; + } return aDrv; } @@ -209,13 +255,17 @@ static int DNaming_AddDriver(Draw_Interpretor& /*theDI*/, int theNb, const char* occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } occ::handle aFunctionDrvTable = TFunction_DriverTable::Get(); for (int i = 2; i < theNb; i++) { Standard_GUID drvGUID; if (!GetFuncGUID(theArg[i], drvGUID)) + { continue; + } aFunctionDrvTable->AddDriver(drvGUID, GetDriver(theArg[i])); #ifdef OCCT_DEBUG std::cout << "DNaming_AddDriver : " << theArg[i] << " driver is added" << std::endl; @@ -241,20 +291,26 @@ static occ::handle SetFunctionDS(const TDF_Label& objLab occ::handle objNode; objLabel.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), objNode); if (!objNode.IsNull()) + { objNode->Append(aNode); + } // set function data sub-structure const TDF_Label& aLab1 = TDF_TagSource::NewChild(aLabel); occ::handle aNode1 = TDataStd_TreeNode::Set(aLab1); TDataStd_Name::Set(aLab1, "Arguments"); if (!aNode.IsNull()) + { aNode->Append(aNode1); + } const TDF_Label& aLab2 = TDF_TagSource::NewChild(aLabel); occ::handle aNode2 = TDataStd_TreeNode::Set(aLab2); TDataStd_Name::Set(aLab2, "Result"); if (!aNode.IsNull()) + { aNode->Append(aNode2); + } return aFun; } @@ -270,10 +326,14 @@ static int DNaming_AddFunction(Draw_Interpretor& di, int nb, const char** a) { occ::handle aDoc; if (!DDocStd::GetDocument(a[1], aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), a[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) @@ -315,17 +375,25 @@ static int DNaming_AddBox(Draw_Interpretor& theDI, int theNb, const char** theAr occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Box", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Box_Function"); // clang-format off @@ -355,20 +423,30 @@ static occ::handle GetFunction(const TDF_Label& objLabel occ::handle aNode; objLabel.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aNode); if (aNode.IsNull()) + { return aFun; + } if (!aNode->HasFirst()) + { return aFun; + } else + { aNode = aNode->First(); + } while (!aNode.IsNull()) { if (aNode->FindAttribute(TFunction_Function::GetID(), aFun)) { const Standard_GUID& aGUID = aFun->GetDriverGUID(); if (aGUID == funGUID) + { break; + } else + { aFun.Nullify(); + } } aNode = aNode->Next(); } @@ -387,17 +465,25 @@ static int DNaming_BoxDX(Draw_Interpretor& theDI, int theNb, const char** theArg occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Box", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -424,17 +510,25 @@ static int DNaming_BoxDY(Draw_Interpretor& theDI, int theNb, const char** theArg occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Box", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -461,17 +555,25 @@ static int DNaming_BoxDZ(Draw_Interpretor& theDI, int theNb, const char** theArg occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Box", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -502,7 +604,9 @@ static int ComputeFunction(const occ::handle& theFun, aRes = aDriver->Execute(theLog); } else + { aRes = 1; + } return aRes; } @@ -519,13 +623,19 @@ static int DNaming_SolveFlatFrom(Draw_Interpretor& /*theDI*/, int theNb, const c occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label ObjLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], ObjLabel)) + { return 1; + } const TDF_Label& FatherLab = ObjLabel.Father(); if (FatherLab.IsNull()) + { goto ERR; + } TCollection_AsciiString entry; TDF_Tool::Entry(FatherLab, entry); #ifdef OCCT_DEBUG @@ -544,14 +654,16 @@ static int DNaming_SolveFlatFrom(Draw_Interpretor& /*theDI*/, int theNb, const c found = true; } else + { continue; + } } const TDF_Label& funLabel = aLabel.FindChild(FUNCTION_ARGUMENTS_LABEL, true); occ::handle aFun; funLabel.FindAttribute(TFunction_Function::GetID(), aFun); if (aFun.IsNull()) { - std::cout << "DNaming_SolveFlatFrom:: Null function is found!" << std::endl; + std::cout << "DNaming_SolveFlatFrom:: Null function is found!" << '\n'; continue; } else @@ -576,7 +688,7 @@ static int DNaming_SolveFlatFrom(Draw_Interpretor& /*theDI*/, int theNb, const c catch (EXCEPTION) { std::cout << "DNaming_SolveFlatFrom : Exception computing function at label " << entry - << std::endl; + << '\n'; } } } @@ -598,7 +710,9 @@ static int DNaming_InitLogBook(Draw_Interpretor& /*theDI*/, int theNb, const cha occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } occ::handle logbook = TFunction_Logbook::Set(aDoc->Main()); if (logbook->IsEmpty()) { @@ -630,20 +744,24 @@ static int DNaming_CheckLogBook(Draw_Interpretor& /*theDI*/, int theNb, const ch occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } occ::handle logbook = TFunction_Logbook::Set(aDoc->Main()); if (logbook->IsEmpty()) - std::cout << "DNaming_CheckLogBook : is empty" << std::endl; + { + std::cout << "DNaming_CheckLogBook : is empty" << '\n'; + } else { const NCollection_Map& aMap = logbook->GetValid(); NCollection_Map::Iterator it(aMap); TCollection_AsciiString entry; - std::cout << "DNaming_CheckLogBook : LogBook current state:" << std::endl; + std::cout << "DNaming_CheckLogBook : LogBook current state:" << '\n'; for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Key(), entry); - std::cout << entry << std::endl; + std::cout << entry << '\n'; } } return 0; @@ -663,15 +781,21 @@ static int DNaming_ComputeFun(Draw_Interpretor& /*theDI*/, int theNb, const char occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label funLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], funLabel)) + { return 1; + } occ::handle aFun; funLabel.FindAttribute(TFunction_Function::GetID(), aFun); if (aFun.IsNull()) + { return 1; + } if (!aFun.IsNull()) { occ::handle logbook = TFunction_Logbook::Set(funLabel); @@ -703,20 +827,30 @@ static int DNaming_AttachShape(Draw_Interpretor& di, int nb, const char** a) occ::handle aDoc; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } const char* aSS(a[2]); const TopoDS_Shape& aShape = DBRep::Get(aSS); // shape to be attached if (aShape.IsNull()) + { return 1; + } occ::handle aContainer, aContext; if (!DDocStd::Find(aDoc, a[3], GEOMOBJECT_GUID, aContext)) + { return 1; + } if (nb > 4) + { DDocStd::Find(aDoc, a[4], GEOMOBJECT_GUID, aContainer); + } if (aContainer.IsNull()) + { aContainer = aContext; + } occ::handle anObj = AddObject(aDoc); if (!anObj.IsNull()) @@ -724,10 +858,14 @@ static int DNaming_AttachShape(Draw_Interpretor& di, int nb, const char** a) occ::handle aNode, RNode; anObj->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aNode); if (aNode.IsNull()) + { aNode = TDataStd_TreeNode::Set(anObj->Label()); + } aNode->Remove(); if (aContainer->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), RNode)) + { RNode->Append(aNode); + } TDataStd_Name::Set(anObj->Label(), "Auxiliary_Object"); Standard_GUID funGUID; if (GetFuncGUID("Attach", funGUID)) @@ -741,10 +879,14 @@ static int DNaming_AttachShape(Draw_Interpretor& di, int nb, const char** a) aResultLabel.ForgetAllAttributes(true); bool aKeepOrientation(false); if (nb >= 6) + { aKeepOrientation = Draw::Atoi(a[5]) != 0; + } bool aGeometry(false); if (nb == 7) + { aGeometry = Draw::Atoi(a[6]) != 0; + } occ::handle aCont = DNaming::GetObjectValue(aContext); #ifdef OCCT_DEBUG if (aCont.IsNull() || aCont->IsEmpty()) @@ -755,11 +897,13 @@ static int DNaming_AttachShape(Draw_Interpretor& di, int nb, const char** a) TopoDS_Shape aCONTEXT = aCont->Get(); TNaming_Selector aSelector(aResultLabel); if (!aSelector.Select(aShape, aCONTEXT, aGeometry, aKeepOrientation)) + { return 1; + } } catch (Standard_Failure const&) { - std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << std::endl; + std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << '\n'; } if (!aCont.IsNull()) @@ -802,15 +946,21 @@ static int DNaming_XAttachShape(Draw_Interpretor& di, int nb, const char** a) occ::handle aDoc; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } const char* aSS(a[2]); const TopoDS_Shape& aShape = DBRep::Get(aSS); if (aShape.IsNull()) + { return 1; + } occ::handle aContext; if (!DDocStd::Find(aDoc, a[3], GEOMOBJECT_GUID, aContext)) + { return 1; + } occ::handle anObj = AddObject(aDoc); if (!anObj.IsNull()) @@ -828,14 +978,20 @@ static int DNaming_XAttachShape(Draw_Interpretor& di, int nb, const char** a) aResultLabel.ForgetAllAttributes(true); bool aKeepOrientation(false); if (nb >= 5) + { aKeepOrientation = Draw::Atoi(a[4]) != 0; + } bool aGeometry(false); if (nb == 6) + { aGeometry = Draw::Atoi(a[5]) != 0; + } occ::handle aCont = DNaming::GetObjectValue(aContext); if (aCont.IsNull() || aCont->IsEmpty()) - std::cout << "Wrong Context ..." << std::endl; + { + std::cout << "Wrong Context ..." << '\n'; + } else { TopoDS_Shape aCONTEXT = aCont->Get(); @@ -843,11 +999,13 @@ static int DNaming_XAttachShape(Draw_Interpretor& di, int nb, const char** a) { TNaming_Selector aSelector(aResultLabel); if (!aSelector.Select(aShape, aCONTEXT, aGeometry, aKeepOrientation)) + { return 1; + } } catch (Standard_Failure const&) { - std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << std::endl; + std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << '\n'; } TDF_Reference::Set( @@ -877,17 +1035,25 @@ static int DNaming_AddCylinder(Draw_Interpretor& theDI, int theNb, const char** occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Cyl", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Cyl_Function"); // clang-format off @@ -900,7 +1066,9 @@ static int DNaming_AddCylinder(Draw_Interpretor& theDI, int theNb, const char** occ::handle Axis; if (!DDocStd::Find(aDocument, theArg[4], GEOMOBJECT_GUID, Axis)) + { return 1; + } DNaming::GetReal(aFun, CYL_RADIUS)->Set(aR); DNaming::GetReal(aFun, CYL_HEIGHT)->Set(aH); DNaming::SetObjectArg(aFun, CYL_AXIS, Axis); @@ -924,17 +1092,25 @@ static int DNaming_CylRad(Draw_Interpretor& theDI, int theNb, const char** theAr occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Cyl", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -962,19 +1138,29 @@ static int DNaming_AddFuse(Draw_Interpretor& theDI, int theNb, const char** theA occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aTool; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, theArg[3], GEOMOBJECT_GUID, aTool)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Fuse", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Fuse"); // clang-format off @@ -1001,19 +1187,29 @@ static int DNaming_AddCut(Draw_Interpretor& theDI, int theNb, const char** theAr occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aTool; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, theArg[3], GEOMOBJECT_GUID, aTool)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Cut", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Cut"); // clang-format off @@ -1040,19 +1236,29 @@ static int DNaming_AddCommon(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aTool; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, theArg[3], GEOMOBJECT_GUID, aTool)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Comm", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Common"); // clang-format off @@ -1079,19 +1285,29 @@ static int DNaming_AddSection(Draw_Interpretor& theDI, int theNb, const char** t occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aTool; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, theArg[3], GEOMOBJECT_GUID, aTool)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Section", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Section"); // clang-format off @@ -1120,17 +1336,25 @@ static int DNaming_AddFillet(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Fillet", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Fillet"); // clang-format off @@ -1142,7 +1366,9 @@ static int DNaming_AddFillet(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aPath; if (!DDocStd::Find(aDocument, theArg[4], GEOMOBJECT_GUID, aPath)) + { return 1; + } DNaming::SetObjectArg(aFun, FILLET_PATH, aPath); DDF::ReturnLabel(theDI, aFun->Label()); return 0; @@ -1162,18 +1388,26 @@ static int DNaming_PTranslateDXYZ(Draw_Interpretor& di, int nb, const char** a) occ::handle aDocument; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject; // aShape; if (!DDocStd::Find(aDocument, a[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PTxyz", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "ParTranslation"); double aDx = 0., aDy = 0., aDz = 0.; @@ -1215,20 +1449,30 @@ static int DNaming_PTranslateLine(Draw_Interpretor& di, int nb, const char** a) occ::handle aDocument; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aLine; // aShape, aLine; if (!DDocStd::Find(aDocument, a[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, a[3], GEOMOBJECT_GUID, aLine)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PTALine", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "ParTranslationAlongLine"); double anOff = 0.; @@ -1256,20 +1500,30 @@ static int DNaming_PRotateLine(Draw_Interpretor& di, int nb, const char** a) occ::handle aDocument; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aLine; // aShape, aLine; if (!DDocStd::Find(aDocument, a[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, a[3], GEOMOBJECT_GUID, aLine)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PRLine", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "ParRotationAroundLine"); DNaming::SetObjectArg(aFun, PTRANSF_LINE, aLine); @@ -1299,20 +1553,30 @@ static int DNaming_PMirrorObject(Draw_Interpretor& di, int nb, const char** a) occ::handle aDocument; const char* aDocS(a[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObject, aPlane; if (!DDocStd::Find(aDocument, a[2], GEOMOBJECT_GUID, anObject)) + { return 1; + } if (!DDocStd::Find(aDocument, a[3], GEOMOBJECT_GUID, aPlane)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PMirr", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObject->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "ParMirror"); DNaming::SetObjectArg(aFun, PTRANSF_PLANE, aPlane); @@ -1340,17 +1604,25 @@ static int DNaming_AddPrism(Draw_Interpretor& theDI, int theNb, const char** the occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Prism", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Prism_Function"); // clang-format off TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here @@ -1359,7 +1631,9 @@ static int DNaming_AddPrism(Draw_Interpretor& theDI, int theNb, const char** the // arguments occ::handle aBasisObj; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aBasisObj)) + { return 1; + } DNaming::SetObjectArg(aFun, PRISM_BASIS, aBasisObj); double height = Draw::Atof(theArg[3]); DNaming::GetReal(aFun, PRISM_HEIGHT)->Set(height); @@ -1380,17 +1654,25 @@ static int DNaming_PrismHeight(Draw_Interpretor& theDI, int theNb, const char** occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Prism", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -1421,37 +1703,57 @@ static int DNaming_AddRevol(Draw_Interpretor& theDI, int theNb, const char** the occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle aBasisObj; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aBasisObj)) + { return 1; + } occ::handle anAxObj; if (!DDocStd::Find(aDocument, theArg[3], GEOMOBJECT_GUID, anAxObj)) + { return 1; + } bool aFull = true; occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } if (theNb > 4) + { aFull = false; + } Standard_GUID funGUID; if (aFull) { if (!GetFuncGUID("FulRevol", funGUID)) + { return 1; + } } else if (!GetFuncGUID("SecRevol", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } if (aFull) + { TDataStd_Name::Set(aFun->Label(), "FulRevol_Function"); + } else + { TDataStd_Name::Set(aFun->Label(), "SecRevol_Function"); + } // clang-format off TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here // clang-format on @@ -1485,17 +1787,25 @@ static int DNaming_RevolutionAngle(Draw_Interpretor& theDI, int theNb, const cha occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("SecRevol", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -1524,17 +1834,25 @@ static int DNaming_AddSphere(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Sph", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Sphere_Function"); // clang-format off TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here @@ -1542,7 +1860,9 @@ static int DNaming_AddSphere(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aCenterObj; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aCenterObj)) + { return 1; + } DNaming::SetObjectArg(aFun, SPHERE_CENTER, aCenterObj); double aRadius = Draw::Atof(theArg[3]); @@ -1563,17 +1883,25 @@ static int DNaming_SphereRadius(Draw_Interpretor& theDI, int theNb, const char** occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Sph", funGUID)) + { return 1; + } occ::handle aFun = GetFunction(objLabel, funGUID); if (!aFun.IsNull()) @@ -1601,17 +1929,25 @@ static int DNaming_AddPoint(Draw_Interpretor& theDI, int theNb, const char** the occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PntXYZ", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "PntXYZ_Function"); // clang-format off @@ -1646,17 +1982,25 @@ static int DNaming_AddPointRlt(Draw_Interpretor& theDI, int theNb, const char** occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PntRLT", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "PntRLT_Function"); // clang-format off @@ -1665,7 +2009,9 @@ static int DNaming_AddPointRlt(Draw_Interpretor& theDI, int theNb, const char** occ::handle aRefPnt; if (!DDocStd::Find(aDocument, theArg[2], GEOMOBJECT_GUID, aRefPnt)) + { return 1; + } double dx, dy, dz; dx = Draw::Atof(theArg[3]); @@ -1698,20 +2044,28 @@ static int DNaming_PntOffset(Draw_Interpretor& theDI, int theNb, const char** th occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label objLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], objLabel)) + { return 1; + } occ::handle anObj; if (!objLabel.FindAttribute(GEOMOBJECT_GUID, anObj)) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("PntXYZ", funGUID)) { if (!GetFuncGUID("PntRLT", funGUID)) + { return 1; + } } occ::handle aFun = GetFunction(objLabel, funGUID); @@ -1737,9 +2091,13 @@ static int DNaming_PntOffset(Draw_Interpretor& theDI, int theNb, const char** th DNaming::GetReal(aFun, PNT_DZ)->Set(value); } if (isDX || isDY || isDZ) + { DDF::ReturnLabel(theDI, objLabel); + } else - std::cout << "DNaming_PntOffset : Nothing changed" << std::endl; + { + std::cout << "DNaming_PntOffset : Nothing changed" << '\n'; + } return 0; } } @@ -1763,17 +2121,25 @@ static int DNaming_Line3D(Draw_Interpretor& theDI, int theNb, const char** theAr occ::handle aDocument; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDocument)) + { return 1; + } occ::handle anObj = AddObject(aDocument); if (anObj.IsNull()) + { return 1; + } Standard_GUID funGUID; if (!GetFuncGUID("Line3D", funGUID)) + { return 1; + } occ::handle aFun = SetFunctionDS(anObj->Label(), funGUID); if (aFun.IsNull()) + { return 1; + } TDataStd_Name::Set(aFun->Label(), "Line3D_Function"); // clang-format off TDF_Reference::Set(anObj->Label(), aFun->Label().FindChild(FUNCTION_RESULT_LABEL)); //result is here @@ -1789,7 +2155,9 @@ static int DNaming_Line3D(Draw_Interpretor& theDI, int theNb, const char** theAr { occ::handle aPntObj; if (!DDocStd::Find(aDocument, theArg[i], GEOMOBJECT_GUID, aPntObj)) + { return 1; + } aPos++; DNaming::SetObjectArg(aFun, aPos, aPntObj); } @@ -1823,7 +2191,9 @@ static void MapOfOrientedShapes(const TopoDS_Shape& S1, while (it.More()) { if (it.Value().ShapeType() == S1.ShapeType()) + { M.Add(it.Value()); + } it.Next(); } } @@ -1838,7 +2208,9 @@ static void MapOfShapes(const TopoDS_Shape& while (it.More()) { if (it.Value().ShapeType() == S1.ShapeType()) + { M.Add(it.Value()); + } it.Next(); } } @@ -1867,7 +2239,9 @@ inline static void CollectMultShapes(const TopoDS_Shape& S, NCollection_List& Obj, occ::handle aNode, RNode; Obj->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), aNode); if (aNode.IsNull()) + { aNode = TDataStd_TreeNode::Set(Obj->Label()); + } aNode->Remove(); const occ::handle& aContainer = ContextObj; if (aContainer->Label().FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), RNode)) + { RNode->Append(aNode); + } TDataStd_Name::Set(Obj->Label(), "Auxiliary_Object"); Standard_GUID funGUID; if (GetFuncGUID("Attach", funGUID)) @@ -1906,11 +2284,13 @@ static bool MakeSelection(const occ::handle& Obj, const TopoDS_Shape& aContext = aNS->Get(); TNaming_Selector aSelector(aResultLabel); if (!aSelector.Select(Selection, aContext, Geometry, KeepOrientation)) + { return false; + } } catch (...) { - std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << std::endl; + std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << '\n'; } if (!aNS.IsNull()) @@ -1973,11 +2353,13 @@ static bool MakeXSelection(const occ::handle& Obj, const TopoDS_Shape& aContext = aNS->Get(); TNaming_Selector aSelector(aResultLabel); if (!aSelector.Select(Selection, aContext, Geometry, KeepOrientation)) + { return false; + } } catch (...) { - std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << std::endl; + std::cout << "EXCEPTION: SELECTION_IMPOSSIBLE" << '\n'; } if (!aNS.IsNull()) @@ -2063,7 +2445,9 @@ inline static TCollection_ExtendedString compareShapes(const TopoDS_Shape& theSh if (theShape2.ShapeType() != TopAbs_COMPOUND) { if (isComma) + { aResult += ","; + } aResult += " Orientation was changed"; } else @@ -2072,12 +2456,16 @@ inline static TCollection_ExtendedString compareShapes(const TopoDS_Shape& theSh for (; it.More(); it.Next()) { if (it.Value().IsSame(theShape1)) + { if (theShape1.Orientation() != it.Value().Orientation()) { if (isComma) + { aResult += ","; + } aResult += " Orientation was changed"; } + } } } } @@ -2122,23 +2510,35 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label ObjLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], ObjLabel)) + { return 1; + } occ::handle aCntObj; if (!ObjLabel.FindAttribute(GEOMOBJECT_GUID, aCntObj)) + { return 1; + } bool Orientation(false); bool XSelection(false); bool Geometry(false); if (theNb == 4) + { Orientation = Draw::Atoi(theArg[3]) != 0; + } if (theNb == 5) + { XSelection = Draw::Atoi(theArg[4]) != 0; + } if (theNb == 6) + { Geometry = Draw::Atoi(theArg[5]) != 0; + } occ::handle aNS = DNaming::GetObjectValue(aCntObj); if (!aNS.IsNull() && !aNS->IsEmpty()) @@ -2149,7 +2549,9 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t NCollection_List aList, aFailedList; CollectShapes(aRootShape, aList); if (aList.Extent()) + { aList.RemoveFirst(); + } bool isFirst(true); occ::handle FirstAuxObj; NCollection_List::Iterator it(aList); @@ -2157,11 +2559,15 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t { const TopoDS_Shape& aCurShape = it.Value(); if (aCurShape.IsNull()) + { continue; + } if (aCurShape.ShapeType() == TopAbs_EDGE) { if (BRep_Tool::Degenerated(TopoDS::Edge(aCurShape))) + { continue; + } } occ::handle auxObj = AddObject(aDoc); if (isFirst) @@ -2180,15 +2586,19 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t OCC_CATCH_SIGNALS { if (!XSelection) + { isSelected = MakeSelection(auxObj, aCurShape, aCntObj, Geometry, Orientation); + } else + { isSelected = MakeXSelection(auxObj, aCurShape, aCntObj, Geometry, Orientation); + } } } catch (Standard_Failure const& anException) { std::cout << "%%%INFO:Error: ::TestSingleSelection failed :"; - std::cout << anException.what() << std::endl; + std::cout << anException.what() << '\n'; } catch (...) { @@ -2234,9 +2644,13 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t if (aResult.Length()) { if (aResult.Search("Warning") == -1) - std::cout << "Failed units: " << aResult << " at " << entry << std::endl; + { + std::cout << "Failed units: " << aResult << " at " << entry << '\n'; + } else - std::cout << aResult << " at " << entry << std::endl; + { + std::cout << aResult << " at " << entry << '\n'; + } TDataStd_Name::Set(auxObj->Label(), aResult); } } @@ -2252,11 +2666,13 @@ static int DNaming_TestSingle(Draw_Interpretor& theDI, int theNb, const char** t B.Generated(it1.Value()); TCollection_AsciiString entry; TDF_Tool::Entry(aLabel, entry); - std::cout << "\t" << entry << std::endl; + std::cout << "\t" << entry << '\n'; } } if (!FirstAuxObj.IsNull()) + { DDF::ReturnLabel(theDI, FirstAuxObj->Label()); + } return 0; } } @@ -2277,23 +2693,35 @@ static int DNaming_Multiple(Draw_Interpretor& theDI, int theNb, const char** the occ::handle aDoc; const char* aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) + { return 1; + } TDF_Label ObjLabel; if (!DDF::FindLabel(aDoc->GetData(), theArg[2], ObjLabel)) + { return 1; + } occ::handle aCntObj; if (!ObjLabel.FindAttribute(GEOMOBJECT_GUID, aCntObj)) + { return 1; + } bool Orientation(false); bool XSelection(false); bool Geometry(false); if (theNb == 4) + { Orientation = Draw::Atoi(theArg[3]) != 0; + } if (theNb == 5) + { XSelection = Draw::Atoi(theArg[4]) != 0; + } if (theNb == 6) + { Geometry = Draw::Atoi(theArg[5]) != 0; + } occ::handle aNS = DNaming::GetObjectValue(aCntObj); if (!aNS.IsNull() && !aNS->IsEmpty()) @@ -2311,11 +2739,15 @@ static int DNaming_Multiple(Draw_Interpretor& theDI, int theNb, const char** the { const TopoDS_Shape& aCurShape = it.Value(); if (aCurShape.IsNull()) + { continue; + } if (aCurShape.ShapeType() == TopAbs_EDGE) { if (BRep_Tool::Degenerated(TopoDS::Edge(aCurShape))) + { continue; + } } // occ::handle auxObj = AddObject(aDoc); if (isFirst) @@ -2334,15 +2766,19 @@ static int DNaming_Multiple(Draw_Interpretor& theDI, int theNb, const char** the OCC_CATCH_SIGNALS { if (!XSelection) + { isSelected = MakeSelection(auxObj, aCurShape, aCntObj, Geometry, Orientation); + } else + { isSelected = MakeXSelection(auxObj, aCurShape, aCntObj, Geometry, Orientation); + } } } catch (Standard_Failure const& anException) { std::cout << "%%%INFO:Error: ::TestSingleSelection failed :"; - std::cout << anException.what() << std::endl; + std::cout << anException.what() << '\n'; } catch (...) { @@ -2386,7 +2822,9 @@ static int DNaming_Multiple(Draw_Interpretor& theDI, int theNb, const char** the aFailedList.Append(aCurShape); } if (aResult.Length()) - std::cout << "Failed units: " << aResult << std::endl; + { + std::cout << "Failed units: " << aResult << '\n'; + } } if (aFailedList.Extent()) @@ -2401,7 +2839,9 @@ static int DNaming_Multiple(Draw_Interpretor& theDI, int theNb, const char** the } } if (!FirstAuxObj.IsNull()) + { DDF::ReturnLabel(theDI, FirstAuxObj->Label()); + } return 0; } } @@ -2417,7 +2857,9 @@ void DNaming::ModelingCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g2 = "Naming modeling commands"; diff --git a/src/Draw/TKDCAF/DNaming/DNaming_PointDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_PointDriver.cxx index 9f4c3b1a8d..e35dd1a236 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_PointDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_PointDriver.cxx @@ -64,7 +64,9 @@ int DNaming_PointDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } // perform calculations @@ -100,7 +102,9 @@ int DNaming_PointDriver::Execute(occ::handle& theLog) const aPoint.SetZ(aPoint.Z() + aDZ); } else + { aPoint = gp_Pnt(aDX, aDY, aDZ); + } BRepBuilderAPI_MakeVertex aMakeVertex(aPoint); @@ -117,7 +121,9 @@ int DNaming_PointDriver::Execute(occ::handle& theLog) const // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(aResultLabel, aLocation, true); + } theLog->SetValid(aResultLabel, true); diff --git a/src/Draw/TKDCAF/DNaming/DNaming_PrismDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_PrismDriver.cxx index 696b77acd0..f28753d235 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_PrismDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_PrismDriver.cxx @@ -90,7 +90,9 @@ int DNaming_PrismDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } // Save location occ::handle aPrevPrism = DNaming::GetFunctionResult(aFunction); @@ -118,11 +120,15 @@ int DNaming_PrismDriver::Execute(occ::handle& theLog) const { BRepBuilderAPI_MakeFace aMaker(TopoDS::Wire(aBasis), true); // Makes planar face if (aMaker.IsDone()) + { aBASIS = aMaker.Face(); // aMaker.Face(); + } } } else if (aBasis.ShapeType() == TopAbs_FACE) + { aBASIS = aBasis; + } if (aBASIS.IsNull()) { aFunction->SetFailure(WRONG_ARGUMENT); @@ -157,7 +163,9 @@ int DNaming_PrismDriver::Execute(occ::handle& theLog) const // Reverse int aRev = DNaming::GetInteger(aFunction, PRISM_DIR)->Get(); if (aRev) + { anAxis.Reverse(); + } // Calculate Vec - direction of extrusion gp_Vec aVEC(anAxis.Direction()); @@ -185,12 +193,16 @@ int DNaming_PrismDriver::Execute(occ::handle& theLog) const bool aVol = false; if (aResult.ShapeType() == TopAbs_SOLID) + { aVol = true; + } else if (aResult.ShapeType() == TopAbs_SHELL) { occ::handle aCheck = new BRepCheck_Shell(TopoDS::Shell(aResult)); if (aCheck->Closed() == BRepCheck_NoError) + { aVol = true; + } } if (aVol) @@ -206,13 +218,19 @@ int DNaming_PrismDriver::Execute(occ::handle& theLog) const // Naming if (anIsAttachment) + { LoadNamingDS(RESPOSITION(aFunction), aMakePrism, aBASIS, aContextOfBasis->Get()); + } else + { LoadNamingDS(RESPOSITION(aFunction), aMakePrism, aBASIS, aBASIS); + } // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(RESPOSITION(aFunction), aLocation, true); + } theLog->SetValid(RESPOSITION(aFunction), true); aFunction->SetFailure(DONE); @@ -235,14 +253,20 @@ void DNaming_PrismDriver::LoadNamingDS(const TDF_Label& theResultLabel, occ::handle Tagger = TDF_TagSource::Set(theResultLabel); if (Tagger.IsNull()) + { return; + } Tagger->Set(0); TNaming_Builder Builder(theResultLabel); if (Basis.IsEqual(Context)) + { Builder.Generated(MS.Shape()); + } else + { Builder.Generated(Context, MS.Shape()); + } // Insert lateral face : Face from Edge TNaming_Builder LateralFaceBuilder(theResultLabel.NewChild()); @@ -253,7 +277,9 @@ void DNaming_PrismDriver::LoadNamingDS(const TDF_Label& theResultLabel, { TopoDS_Iterator itr(Basis); if (itr.More() && itr.Value().ShapeType() == TopAbs_WIRE) + { makeTopBottom = false; + } } else if (Basis.ShapeType() == TopAbs_WIRE) { diff --git a/src/Draw/TKDCAF/DNaming/DNaming_RevolutionDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_RevolutionDriver.cxx index 942bb016e5..2e17c71673 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_RevolutionDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_RevolutionDriver.cxx @@ -77,7 +77,9 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } // Save location occ::handle aPrevRevol = DNaming::GetFunctionResult(aFunction); @@ -105,11 +107,15 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co { BRepBuilderAPI_MakeFace aMaker(TopoDS::Wire(aBasis), true); // Makes planar face if (aMaker.IsDone()) + { aBASIS = aMaker.Face(); // aMaker.Face(); + } } } else if (aBasis.ShapeType() == TopAbs_FACE) + { aBASIS = aBasis; + } if (aBASIS.IsNull()) { aFunction->SetFailure(WRONG_ARGUMENT); @@ -194,12 +200,16 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co } bool aVol = false; if (aResult.ShapeType() == TopAbs_SOLID) + { aVol = true; + } else if (aResult.ShapeType() == TopAbs_SHELL) { occ::handle aCheck = new BRepCheck_Shell(TopoDS::Shell(aResult)); if (aCheck->Closed() == BRepCheck_NoError) + { aVol = true; + } } if (aVol) { @@ -213,9 +223,13 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co } // Naming if (anIsAttachment) + { LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aContextOfBasis->Get()); + } else + { LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aBASIS); + } } else if (aFunction->GetDriverGUID() == SECREVOL_GUID) { @@ -228,7 +242,9 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co // Reverse int aRev = DNaming::GetInteger(aFunction, REVOL_REV)->Get(); if (aRev) + { anAXIS.Reverse(); + } BRepPrimAPI_MakeRevol aMakeRevol(aBASIS, anAXIS, anANGLE, true); aMakeRevol.Build(); @@ -246,12 +262,16 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co } bool aVol = false; if (aResult.ShapeType() == TopAbs_SOLID) + { aVol = true; + } else if (aResult.ShapeType() == TopAbs_SHELL) { occ::handle aCheck = new BRepCheck_Shell(TopoDS::Shell(aResult)); if (aCheck->Closed() == BRepCheck_NoError) + { aVol = true; + } } if (aVol) { @@ -266,9 +286,13 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co // Naming if (anIsAttachment) + { LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aContextOfBasis->Get()); + } else + { LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aBASIS); + } } else { @@ -278,7 +302,9 @@ int DNaming_RevolutionDriver::Execute(occ::handle& theLog) co // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(RESPOSITION(aFunction), aLocation, true); + } theLog->SetValid(RESPOSITION(aFunction), true); aFunction->SetFailure(DONE); @@ -298,14 +324,18 @@ static void LoadSeamEdge(BRepPrimAPI_MakeRevol& mkRevol, { const TopoDS_Shape& Root = ShapeExplorer.Current(); if (!View.Add(Root)) + { continue; + } const NCollection_List& Shapes = mkRevol.Generated(Root); NCollection_List::Iterator ShapesIterator(Shapes); for (; ShapesIterator.More(); ShapesIterator.Next()) { TopoDS_Shape newShape = ShapesIterator.Value(); if (newShape.ShapeType() != TopAbs_FACE) + { continue; + } if (!Root.IsSame(newShape)) { TopExp_Explorer exp(newShape, TopAbs_EDGE); @@ -333,7 +363,9 @@ static void LoadSeamEdge(BRepPrimAPI_MakeRevol& mkRevol, static bool HasDangle(const TopoDS_Shape& ShapeIn) { if (ShapeIn.ShapeType() == TopAbs_SOLID) + { return false; + } else if (ShapeIn.ShapeType() == TopAbs_SHELL) { occ::handle aCheck = new BRepCheck_Shell(TopoDS::Shell(ShapeIn)); @@ -341,7 +373,9 @@ static bool HasDangle(const TopoDS_Shape& ShapeIn) } else if (ShapeIn.ShapeType() == TopAbs_FACE || ShapeIn.ShapeType() == TopAbs_WIRE || ShapeIn.ShapeType() == TopAbs_EDGE || ShapeIn.ShapeType() == TopAbs_VERTEX) + { return true; + } return false; } @@ -355,13 +389,19 @@ static void BuildAtomicMap(const TopoDS_Shape& for (; it.More(); it.Next()) { if (it.Value().ShapeType() > TopAbs_COMPSOLID) + { M.Add(it.Value()); + } else + { BuildAtomicMap(it.Value(), M); + } } } else + { M.Add(S); + } } //================================================================================================= @@ -374,11 +414,17 @@ bool HasDangleShapes(const TopoDS_Shape& ShapeIn) BuildAtomicMap(ShapeIn, M); NCollection_Map::Iterator it(M); for (; it.More(); it.Next()) + { if (HasDangle(it.Key())) + { return true; + } + } } else + { return HasDangle(ShapeIn); + } return false; } @@ -398,14 +444,20 @@ void DNaming_RevolutionDriver::LoadNamingDS(const TDF_Label& theResultLabe occ::handle Tagger = TDF_TagSource::Set(theResultLabel); if (Tagger.IsNull()) + { return; + } Tagger->Set(0); TNaming_Builder Builder(theResultLabel); if (Basis.IsEqual(Context)) + { Builder.Generated(MS.Shape()); + } else + { Builder.Generated(Context, MS.Shape()); + } // Insert lateral face : Face from Edge TNaming_Builder LateralFaceBuilder(theResultLabel.NewChild()); @@ -416,7 +468,9 @@ void DNaming_RevolutionDriver::LoadNamingDS(const TDF_Label& theResultLabe TopoDS_Shape EndShape = MS.LastShape(); bool isFull(false); if (!StartShape.IsNull() && !EndShape.IsNull()) + { isFull = StartShape.IsEqual(EndShape); + } bool hasDangle = HasDangleShapes(MS.Shape()); bool isBasisClosed(true); diff --git a/src/Draw/TKDCAF/DNaming/DNaming_SelectionCommands.cxx b/src/Draw/TKDCAF/DNaming/DNaming_SelectionCommands.cxx index 70ca860551..9bb6f40a15 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_SelectionCommands.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_SelectionCommands.cxx @@ -94,7 +94,9 @@ static int DNaming_Select(Draw_Interpretor& di, int n, const char** a) bool geometry = !(strcmp(a[0], "SelectGeometry")); occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, a[2], L); TNaming_Selector SL(L); @@ -107,7 +109,9 @@ static int DNaming_Select(Draw_Interpretor& di, int n, const char** a) { bool Orient(false); if (n == 6) + { Orient = (Draw::Atoi(a[5]) != 0); + } TopoDS_Shape S = DBRep::Get(a[3], TopAbs_SHAPE); TopoDS_Shape C = DBRep::Get(a[4], TopAbs_SHAPE); SL.Select(S, C, geometry, Orient); @@ -131,9 +135,13 @@ bool FillValidMap(const TDF_Label& theLabel, NCollection_Map& theVali const TDF_Label& aLabel = itr.Value(); occ::handle aNaming; if (!aLabel.IsNull()) + { aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming); + } if (aNaming.IsNull()) + { continue; + } TDF_Tool::OutReferences(aLabel, anExtMap); for (NCollection_Map>::Iterator attMItr(anExtMap); attMItr.More(); attMItr.Next()) @@ -145,7 +153,9 @@ bool FillValidMap(const TDF_Label& theLabel, NCollection_Map& theVali occ::handle aNS; att->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS); if (!aNS.IsNull()) + { TNaming_NamingTool::BuildDescendants(aNS, theValidMap); + } extRefFound = true; } } @@ -165,24 +175,30 @@ static int DNaming_SolveSelection(Draw_Interpretor& di, int n, const char** a) char name[100]; occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, a[2], L); occ::handle naming; if (!L.FindAttribute(TNaming_Naming::GetID(), naming)) { - std::cout << "DNaming__SolveSelection : not a selection" << std::endl; + std::cout << "DNaming__SolveSelection : not a selection" << '\n'; return 1; } NCollection_Map aValidMap; if (!FillValidMap(L, aValidMap)) + { di << "Valid map is empty\n"; + } TNaming_Selector SL(L); bool isSolved = SL.Solve(aValidMap); if (!isSolved) + { di << "!!! Solver is failed\n"; + } TopoDS_Shape Res = TNaming_Tool::CurrentShape(SL.NamedShape()); Sprintf(name, "%s_%s", "new", a[2]); Display(name, Res); @@ -202,10 +218,14 @@ static int DNaming_DumpSelection(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; if (!L.FindAttribute(TNaming_Naming::GetID(), naming)) { @@ -226,7 +246,9 @@ static int DNaming_DumpSelection(Draw_Interpretor& di, int n, const char** a) { curdepth = (naming->Label().Depth() - depth); for (int i = 1; i <= curdepth; i++) + { di << " "; + } TDF_Tool::Entry(naming->Label(), Entry); di << Entry.ToCString() << " "; DumpNaming(naming, di); @@ -250,10 +272,14 @@ static int DNaming_ArgsSelection(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; if (!L.FindAttribute(TNaming_Naming::GetID(), naming)) { @@ -288,7 +314,9 @@ static void CollectAttachment(const TDF_Label& for (itarg.Initialize(args); itarg.More(); itarg.Next()) { if (!itarg.Value()->Label().IsDescendant(root)) + { attachment.Add(itarg.Value()); + } } occ::handle subnaming; for (TDF_ChildIterator it(naming->Label(), true); it.More(); it.Next()) @@ -300,7 +328,9 @@ static void CollectAttachment(const TDF_Label& for (itarg.Initialize(subargs); itarg.More(); itarg.Next()) { if (!itarg.Value()->Label().IsDescendant(root)) + { attachment.Add(itarg.Value()); + } } } } @@ -317,10 +347,14 @@ static int DNaming_Attachment(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; NCollection_Map> attachment; if (L.FindAttribute(TNaming_Naming::GetID(), naming)) @@ -362,7 +396,9 @@ void DNaming::SelectionCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands"; diff --git a/src/Draw/TKDCAF/DNaming/DNaming_SelectionDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_SelectionDriver.cxx index bb6a97bbf8..be27ab01fa 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_SelectionDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_SelectionDriver.cxx @@ -82,11 +82,15 @@ int DNaming_SelectionDriver::Execute(occ::handle& theLog) con occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } TDF_Label aRLabel = RESPOSITION(aFunction); if (aRLabel.IsNull()) + { return -1; + } bool aIsWire = false; TopAbs_ShapeEnum aPrevShapeType = TopAbs_SHAPE; @@ -97,7 +101,9 @@ int DNaming_SelectionDriver::Execute(occ::handle& theLog) con { aPrevShapeType = aNShape->Get().ShapeType(); if (aPrevShapeType == TopAbs_WIRE) + { aIsWire = true; + } } } @@ -131,19 +137,19 @@ int DNaming_SelectionDriver::Execute(occ::handle& theLog) con occ::handle aNS; if (!aRLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - std::cout << "%%%WARNING: DNaming_SelectionDriver::NamedShape is not found" << std::endl; + std::cout << "%%%WARNING: DNaming_SelectionDriver::NamedShape is not found" << '\n'; } else { if (aNS.IsNull()) { - std::cout << "%%%WARNING: DNaming_SelectionDriver::NamedShape is NULL" << std::endl; + std::cout << "%%%WARNING: DNaming_SelectionDriver::NamedShape is NULL" << '\n'; } else if (aNS->IsEmpty()) { std::cout << "%%%WARNING: DNaming_SelectionDriver::NamedShape is EMPTY on Label = "; aNS->Label().EntryDump(std::cout); - std::cout << std::endl; + std::cout << '\n'; } else { @@ -179,7 +185,7 @@ int DNaming_SelectionDriver::Execute(occ::handle& theLog) con { aFunction->SetFailure(NOTDONE); std::cout << "%%%WARNING: DNaming_SelectionDriver::Execute: Selection is Not solved !!!" - << std::endl; + << '\n'; return 1; } return 0; diff --git a/src/Draw/TKDCAF/DNaming/DNaming_SphereDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_SphereDriver.cxx index c8c98995eb..6672c09f25 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_SphereDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_SphereDriver.cxx @@ -70,7 +70,9 @@ int DNaming_SphereDriver::Execute(occ::handle& theLog) const occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } double aRadius = DNaming::GetReal(aFunction, SPHERE_RADIUS)->Get(); occ::handle anObject = DNaming::GetObjectArg(aFunction, SPHERE_CENTER); @@ -128,7 +130,9 @@ int DNaming_SphereDriver::Execute(occ::handle& theLog) const LoadNamingDS(RESPOSITION(aFunction), aMakeSphere); // restore location if (!aLocation.IsIdentity()) + { TNaming::Displace(RESPOSITION(aFunction), aLocation, true); + } theLog->SetValid(RESPOSITION(aFunction), true); aFunction->SetFailure(DONE); @@ -143,7 +147,9 @@ void DNaming_SphereDriver::LoadNamingDS(const TDF_Label& theResultLabel, occ::handle Tagger = TDF_TagSource::Set(theResultLabel); if (Tagger.IsNull()) + { return; + } Tagger->Set(0); TNaming_Builder Builder(theResultLabel); @@ -184,8 +190,12 @@ void DNaming_SphereDriver::LoadNamingDS(const TDF_Label& theResultLabel, int i = 1; NCollection_List goodEdges; for (; i <= LateralEdges.Extent(); i++) + { if (!BRep_Tool::Degenerated(TopoDS::Edge(LateralEdges.FindKey(i)))) + { goodEdges.Append(i); + } + } if (goodEdges.Extent() == 1) { diff --git a/src/Draw/TKDCAF/DNaming/DNaming_ToolsCommands.cxx b/src/Draw/TKDCAF/DNaming/DNaming_ToolsCommands.cxx index 50c0dd1441..58b887516b 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_ToolsCommands.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_ToolsCommands.cxx @@ -36,7 +36,9 @@ static int DNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 4) + { return 1; + } TopoDS_Shape S1 = DBRep::Get(arg[1]); if (S1.IsNull()) { @@ -55,13 +57,21 @@ static int DNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg) strtok(M, " \t"); TopAbs_ShapeEnum mod = TopAbs_FACE; if (M[0] == 'F' || M[0] == 'f') + { mod = TopAbs_FACE; + } else if (M[0] == 'E' || M[0] == 'e') + { mod = TopAbs_EDGE; + } else if (M[0] == 'V' || M[0] == 'v') + { mod = TopAbs_VERTEX; + } else + { return 1; + } TopExp_Explorer Exp1, Exp2; @@ -85,7 +95,9 @@ static int DNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg) { const TopoDS_Shape& s2 = itr2.Key(); if (s1.IsSame(s2)) + { di << "Shapes " << arg[1] << " and " << arg[2] << " have SAME subshapes\n"; + } } } @@ -102,7 +114,9 @@ static int DNaming_TCopyShape(Draw_Interpretor& di, int nb, const char** arg) { TNaming_Translator TR; if (nb < 2) + { return (1); + } NCollection_DataMap aDMapOfShapeOfName; @@ -119,7 +133,9 @@ static int DNaming_TCopyShape(Draw_Interpretor& di, int nb, const char** arg) // Add to Map if (S.IsNull()) + { return (1); + } else { aDMapOfShapeOfName.Bind(S, name); @@ -214,7 +230,9 @@ void DNaming::ToolsCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands "; diff --git a/src/Draw/TKDCAF/DNaming/DNaming_TransformationDriver.cxx b/src/Draw/TKDCAF/DNaming/DNaming_TransformationDriver.cxx index e1c80ba59f..fba8d55597 100644 --- a/src/Draw/TKDCAF/DNaming/DNaming_TransformationDriver.cxx +++ b/src/Draw/TKDCAF/DNaming/DNaming_TransformationDriver.cxx @@ -96,11 +96,15 @@ int DNaming_TransformationDriver::Execute(occ::handle& theLog occ::handle aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if (aFunction.IsNull()) + { return -1; + } occ::handle aPrevFun = DNaming::GetPrevFunction(aFunction); if (aPrevFun.IsNull()) + { return -1; + } const TDF_Label& aLab = RESPOSITION(aPrevFun); occ::handle aContextNS; aLab.FindAttribute(TNaming_NamedShape::GetID(), aContextNS); @@ -132,7 +136,9 @@ int DNaming_TransformationDriver::Execute(occ::handle& theLog occ::handle aLineNS = DNaming::GetObjectValue(aLineObj); gp_Ax1 anAxis; if (!DNaming::ComputeAxis(aLineNS, anAxis)) + { throw Standard_Failure(); + } gp_Vec aVector(anAxis.Direction()); aVector.Normalize(); double anOffset = DNaming::GetReal(aFunction, PTRANSF_OFF)->Get(); @@ -145,7 +151,9 @@ int DNaming_TransformationDriver::Execute(occ::handle& theLog occ::handle aLineNS = DNaming::GetObjectValue(aLineObj); gp_Ax1 anAxis; if (!DNaming::ComputeAxis(aLineNS, anAxis)) + { throw Standard_Failure(); + } double anAngle = DNaming::GetReal(aFunction, PTRANSF_ANG)->Get(); aTransformation.SetRotation(anAxis, anAngle); @@ -157,12 +165,16 @@ int DNaming_TransformationDriver::Execute(occ::handle& theLog if (aNS.IsNull() || aNS->IsEmpty() || aNS->Get().IsNull() || aNS->Get().ShapeType() != TopAbs_FACE) + { throw Standard_Failure(); + } TopoDS_Face aFace = TopoDS::Face(aNS->Get()); occ::handle aSurf = BRep_Tool::Surface(aFace); GeomLib_IsPlanarSurface isPlanarSurface(aSurf); if (!isPlanarSurface.IsPlanar()) + { throw Standard_Failure(); + } gp_Pln aPlane = isPlanarSurface.Plan(); gp_Ax2 aMirrorAx2 = aPlane.Position().Ax2(); aTransformation.SetMirror(aMirrorAx2); @@ -219,7 +231,9 @@ static void CollectShapes(const TopoDS_Shape& case TopAbs_COMPOUND: { TopoDS_Iterator it(SSh); for (; it.More(); it.Next()) + { CollectShapes(it.Value(), C, SMap, theLab, TagMap, isPrimitive); + } } break; case TopAbs_COMPSOLID: @@ -231,12 +245,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } anEx.Init(SSh, TopAbs_EDGE); @@ -245,12 +263,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } anEx.Init(SSh, TopAbs_VERTEX); @@ -259,12 +281,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } } @@ -272,20 +298,28 @@ static void CollectShapes(const TopoDS_Shape& case TopAbs_FACE: { const occ::handle aNamedShape = TNaming_Tool::NamedShape(SSh, theLab); if (!aNamedShape.IsNull()) + { if (SMap.Add(SSh)) + { aB.Add(C, SSh); + } + } TopExp_Explorer anEx(SSh, TopAbs_EDGE); for (; anEx.More(); anEx.Next()) { const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } anEx.Init(SSh, TopAbs_VERTEX); @@ -294,12 +328,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } } @@ -311,12 +349,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } anEx.Init(SSh, TopAbs_VERTEX); @@ -325,12 +367,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } } @@ -339,8 +385,12 @@ static void CollectShapes(const TopoDS_Shape& case TopAbs_EDGE: { const occ::handle aNamedShape = TNaming_Tool::NamedShape(SSh, theLab); if (!aNamedShape.IsNull()) + { if (SMap.Add(SSh)) + { aB.Add(C, SSh); + } + } TopExp_Explorer anEx(SSh, TopAbs_VERTEX); anEx.Init(SSh, TopAbs_VERTEX); for (; anEx.More(); anEx.Next()) @@ -348,12 +398,16 @@ static void CollectShapes(const TopoDS_Shape& const occ::handle aNS = TNaming_Tool::NamedShape(anEx.Current(), theLab); if (aNS.IsNull()) + { continue; + } if (SMap.Add(anEx.Current())) { aB.Add(C, anEx.Current()); if (isPrimitive) + { TagMap.Bind(anEx.Current(), aNS->Label().Tag()); + } } } } @@ -361,12 +415,14 @@ static void CollectShapes(const TopoDS_Shape& case TopAbs_VERTEX: { const occ::handle aNS = TNaming_Tool::NamedShape(SSh, theLab); if (!aNS.IsNull()) + { if (SMap.Add(SSh)) { aB.Add(C, SSh); // if(isPrimitive) // TagMap.Bind(SSh, aNS->Label().Tag()); } + } } break; default: @@ -381,7 +437,9 @@ void DNaming_TransformationDriver::LoadNamingDS(const TDF_Label& theResultLabel, const gp_Trsf& theTrsf) const { if (theSourceNS.IsNull() || theSourceNS->IsEmpty()) + { return; + } const TopoDS_Shape& aSrcShape = theSourceNS->Get(); if (aSrcShape.IsNull()) { @@ -394,7 +452,9 @@ void DNaming_TransformationDriver::LoadNamingDS(const TDF_Label& theResultLabel, } bool isPrimitive(false); if (theSourceNS->Evolution() == TNaming_PRIMITIVE) + { isPrimitive = true; + } const TDF_Label& aSrcLabel = theSourceNS->Label(); #ifdef OCCT_DEBUG_TRSF std::cout << "TransformationDriver: "; @@ -408,7 +468,9 @@ void DNaming_TransformationDriver::LoadNamingDS(const TDF_Label& theResultLabel, NCollection_DataMap aTagMap; // Collect shapes if (aSMap.Add(aSrcShape)) + { aB.Add(aCompShape, aSrcShape); + } CollectShapes(aSrcShape, aCompShape, aSMap, aSrcLabel, aTagMap, isPrimitive); // Transform @@ -419,7 +481,9 @@ void DNaming_TransformationDriver::LoadNamingDS(const TDF_Label& theResultLabel, // Load TopoDS_Shape aNewSh; if (aTMap.IsBound(aSrcShape)) + { aNewSh = aTMap(aSrcShape); + } if (!aNewSh.IsNull()) { TNaming_Builder aBuilder(theResultLabel); @@ -447,7 +511,9 @@ void DNaming_TransformationDriver::LoadNamingDS(const TDF_Label& theResultLabel, for (; it.More(); it.Next()) { if (it.Value() > aNextTag) + { aNextTag = it.Value(); + } } NCollection_Handle aFBuilder, anEBuilder, aVBuilder; NCollection_DataMap::Iterator anIt(aTMap); diff --git a/src/Draw/TKDCAF/DPrsStd/DPrsStd.cxx b/src/Draw/TKDCAF/DPrsStd/DPrsStd.cxx index a0496145ff..2f09bd9c49 100644 --- a/src/Draw/TKDCAF/DPrsStd/DPrsStd.cxx +++ b/src/Draw/TKDCAF/DPrsStd/DPrsStd.cxx @@ -29,7 +29,9 @@ void DPrsStd::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DPrsStd::AISPresentationCommands(theCommands); @@ -44,7 +46,9 @@ void DPrsStd::Factory(Draw_Interpretor& theDI) { static bool DPrsStdFactoryDone = false; if (DPrsStdFactoryDone) + { return; + } DPrsStdFactoryDone = true; DDF::AllCommands(theDI); diff --git a/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISPresentationCommands.cxx b/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISPresentationCommands.cxx index c8bffb071d..7cafcf77d4 100644 --- a/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISPresentationCommands.cxx +++ b/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISPresentationCommands.cxx @@ -52,13 +52,19 @@ static int DPrsStd_AISDisplay(Draw_Interpretor&, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle prs; if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { return 1; + } prs->Display(nb == 3); TPrsStd_AISViewer::Update(L); return 0; @@ -75,13 +81,19 @@ static int DPrsStd_AISRemove(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle P; if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), P)) + { return 1; + } P->Erase(true); TPrsStd_AISViewer::Update(L); return 0; @@ -101,13 +113,19 @@ static int DPrsStd_AISErase(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle prs; if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { return 1; + } prs->Erase(); TPrsStd_AISViewer::Update(L); return 0; @@ -127,13 +145,19 @@ static int DPrsStd_AISUpdate(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle prs; if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { return 1; + } prs->Update(); TPrsStd_AISViewer::Update(L); return 0; @@ -153,28 +177,44 @@ static int DPrsStd_AISSet(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } Standard_GUID guid; TCollection_ExtendedString str = arg[3]; #ifdef OCCT_DEBUG std::cout << "Inputted parameter > " << str << std::endl; #endif - if (str == "A") // axis - guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" - else if (str == "C") // constraint + if (str == "A") + { // axis + guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "C") + { // constraint guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" - else if (str == "NS") // namedshape - guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" - else if (str == "G") // geometry - guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" - else if (str == "PL") // plane - guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" - else if (str == "PT") // point - guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" - // else if( str == "SG" ) //TSketch_Geometry + } + else if (str == "NS") + { // namedshape + guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" + } + else if (str == "G") + { // geometry + guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "PL") + { // plane + guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "PT") + { // point + guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" + } + // else if( str == "SG" ) //TSketch_Geometry // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" // else if( str == "E" ) //TSketch_Edge // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" @@ -207,10 +247,14 @@ static int DPrsStd_AISDriver(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } Standard_GUID guid; occ::handle prs; @@ -232,19 +276,31 @@ static int DPrsStd_AISDriver(Draw_Interpretor& di, int nb, const char** arg) #ifdef OCCT_DEBUG std::cout << "Inputted parameter > " << str << std::endl; #endif - if (str == "A") // axis - guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" - else if (str == "C") // constraint + if (str == "A") + { // axis + guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "C") + { // constraint guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333" - else if (str == "NS") // namedshape - guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" - else if (str == "G") // geometry - guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" - else if (str == "PL") // plane - guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" - else if (str == "PT") // point - guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" - // else if( str == "SG" ) //TSketch_Geometry + } + else if (str == "NS") + { // namedshape + guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333" + } + else if (str == "G") + { // geometry + guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "PL") + { // plane + guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333" + } + else if (str == "PT") + { // point + guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333" + } + // else if( str == "SG" ) //TSketch_Geometry // guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333" // else if( str == "E" ) //TSketch_Edge // guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333" @@ -276,10 +332,14 @@ static int DPrsStd_AISUnset(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } TPrsStd_AISPresentation::Unset(L); TPrsStd_AISViewer::Update(L); return 0; @@ -299,14 +359,20 @@ static int DPrsStd_AISTransparency(Draw_Interpretor& di, int nb, const char** ar { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -347,10 +413,14 @@ static int DPrsStd_AISDefaultTransparency(Draw_Interpretor& di, int nb, const ch { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -435,14 +505,20 @@ static int DPrsStd_AISDefaultColor(Draw_Interpretor& di, int nb, const char** ar { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -467,14 +543,20 @@ static int DPrsStd_AISMaterial(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -515,14 +597,20 @@ static int DPrsStd_AISDefaultMaterial(Draw_Interpretor& di, int nb, const char** { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -547,18 +635,26 @@ static int DPrsStd_AISHasOwnColor(Draw_Interpretor& di, int nb, const char** arg if (nb >= 3) { if (nb > 3) + { di << "DPrsStd_AISHasOwnColor : Warning : too many arguments\n"; + } occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -582,18 +678,26 @@ static int DPrsStd_AISHasOwnMaterial(Draw_Interpretor& di, int nb, const char** if (nb >= 3) { if (nb > 3) + { di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments\n"; + } occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -617,18 +721,26 @@ static int DPrsStd_AISHasOwnTransparency(Draw_Interpretor& di, int nb, const cha if (nb >= 3) { if (nb > 3) + { di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments\n"; + } occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -653,11 +765,17 @@ static int DPrsStd_AISMode(Draw_Interpretor& di, int nb, const char** arg) if (nb >= 3 && nb <= 4) { if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { return 1; + } if (nb == 4) { int mode = Draw::Atoi(arg[3]); @@ -687,11 +805,17 @@ static int DPrsStd_AISSelMode(Draw_Interpretor& di, int nb, const char** arg) if (nb >= 3) { if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { return 1; + } if (nb >= 4) { // Set selection mode. @@ -721,7 +845,9 @@ static int DPrsStd_AISSelMode(Draw_Interpretor& di, int nb, const char** arg) int selMode = prs->SelectionMode(i); di << selMode; if (i < nbSelModes) + { di << " "; + } } } } @@ -737,7 +863,9 @@ void DPrsStd::AISPresentationCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "DPrsStd : standard presentation commands"; diff --git a/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISViewerCommands.cxx b/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISViewerCommands.cxx index bfa16224bd..7721dbfade 100644 --- a/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISViewerCommands.cxx +++ b/src/Draw/TKDCAF/DPrsStd/DPrsStd_AISViewerCommands.cxx @@ -71,7 +71,9 @@ static int DPrsStd_AISRepaint(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label acces = D->GetData()->Root(); TPrsStd_AISViewer::Update(acces); return 0; @@ -87,7 +89,9 @@ void DPrsStd::AISViewerCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "DPrsStd : standard presentation commands"; diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim.cxx index 25ad231c6f..2b879753c8 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim.cxx @@ -68,7 +68,9 @@ void DrawDim::DrawShapeName(const TopoDS_Shape& ashape, const char* const aname) { parameter = (f + l) / 2.; if (f > l) + { parameter = parameter + M_PI; + } position = ElCLib::Value(parameter, occ::down_cast(curve)->Circ()); } } diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim_Angle.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim_Angle.cxx index 79d5d1d820..18dafe38a8 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim_Angle.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim_Angle.cxx @@ -94,12 +94,18 @@ void DrawDim_Angle::DrawOn(Draw_Display&) const // calculation of myAxis gp_Pln pln1, pln2; if (!DrawDim::Pln(myPlane1, pln1)) + { return; + } if (!DrawDim::Pln(myPlane2, pln2)) + { return; + } IntAna_QuadQuadGeo ip(pln1, pln2, Precision::Confusion(), Precision::Angular()); if (!ip.IsDone()) + { return; + } gp_Pnt curpos; gp_Ax1 AxePos = myAxis; diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim_Dimension.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim_Dimension.cxx index 85b6bdd9f2..c77a4dd478 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim_Dimension.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim_Dimension.cxx @@ -45,7 +45,9 @@ void DrawDim_Dimension::SetValue(const double avalue) double DrawDim_Dimension::GetValue() const { if (!is_valued) + { throw Standard_DomainError(); + } return myValue; } diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim_Distance.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim_Distance.cxx index 0528830f38..2db991c95f 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim_Distance.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim_Distance.cxx @@ -84,7 +84,9 @@ void DrawDim_Distance::DrawOn(Draw_Display& dis) const // today we process only planar faces if (surf1.GetType() != GeomAbs_Plane) + { return; + } gp_Ax1 anAx1 = surf1.Plane().Axis(); gp_Vec V = anAx1.Direction(); diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarAngle.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarAngle.cxx index b09fcc0712..0fcd07f5f9 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarAngle.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarAngle.cxx @@ -94,14 +94,20 @@ void DrawDim_PlanarAngle::DrawOn(Draw_Display& dis) const gp_Pln plane = occ::down_cast(BRep_Tool::Surface(myPlane))->Pln(); // if (plane.IsNull()) return; if (!(myLine1.ShapeType() == TopAbs_EDGE)) + { return; + } if (!(myLine2.ShapeType() == TopAbs_EDGE)) + { return; + } double s1, e1, s2, e2; occ::handle curve1 = BRep_Tool::Curve(TopoDS::Edge(myLine1), s1, e1); occ::handle curve2 = BRep_Tool::Curve(TopoDS::Edge(myLine2), s2, e2); if (!curve1->IsKind(STANDARD_TYPE(Geom_Line)) || !curve2->IsKind(STANDARD_TYPE(Geom_Line))) + { return; + } occ::handle L1 = GeomAPI::To2d(curve1, plane); if (L1->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) { @@ -118,7 +124,9 @@ void DrawDim_PlanarAngle::DrawOn(Draw_Display& dis) const IntAna2d_AnaIntersection inter; inter.Perform(l1, l2); if (!inter.IsDone() || !inter.NbPoints()) + { return; + } gp_Pnt2d pinter = inter.Point(1).Value(); // double angle; diff --git a/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarDimensionCommands.cxx b/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarDimensionCommands.cxx index e61e27e2ab..499840e101 100644 --- a/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarDimensionCommands.cxx +++ b/src/Draw/TKDCAF/DrawDim/DrawDim_PlanarDimensionCommands.cxx @@ -189,12 +189,16 @@ static int DrawDim_CENTER(Draw_Interpretor& di, int nb, const char** arg) static int DrawDim_VARIABLES(Draw_Interpretor& di, int n, const char** a) { if (n != 2) + { return 1; + } TopoDS_Shape aLocalShape = DBRep::Get(a[1], TopAbs_FACE); TopoDS_Face F = TopoDS::Face(aLocalShape); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1],TopAbs_FACE)); if (F.IsNull()) + { return 0; + } int i = 0; TopoDS_Vertex vf, vl; diff --git a/src/Draw/TKDraw/DBRep/DBRep.cxx b/src/Draw/TKDraw/DBRep/DBRep.cxx index c8a6ed5370..736b13e04a 100644 --- a/src/Draw/TKDraw/DBRep/DBRep.cxx +++ b/src/Draw/TKDraw/DBRep/DBRep.cxx @@ -61,7 +61,7 @@ Standard_EXPORT void DBRep_WriteColorOrientation() std::cout << "\nrouge FORWARD"; std::cout << "\nbleu REVERSED"; std::cout << "\nrose EXTERNAL"; - std::cout << "\norange INTERNAL" << std::endl; + std::cout << "\norange INTERNAL" << '\n'; } Standard_EXPORT Draw_Color DBRep_ColorOrientation(const TopAbs_Orientation Or) @@ -114,7 +114,9 @@ static int isos(Draw_Interpretor& di, int NbArg, const char** Arg) int aNbIsos = 0; bool Change = false; if (!Characters(NbArg) && Float(NbArg)) + { return 1; + } if (!Characters(NbArg)) { aNbIsos = Draw::Atoi(Arg[NbArg]); @@ -149,7 +151,9 @@ static int isos(Draw_Interpretor& di, int NbArg, const char** Arg) } } if (Change) + { dout.RepaintAll(); + } } return 0; @@ -177,7 +181,9 @@ static int hlr(Draw_Interpretor& di, int n, const char** a) } } else + { di << " wireframe"; + } di << "\n"; return 0; } @@ -228,7 +234,9 @@ static int hlr(Draw_Interpretor& di, int n, const char** a) di << aParams.HLRAngle * 180 / M_PI << " degrees\n"; } else + { return 1; + } } int nFirst = 2; @@ -443,9 +451,13 @@ static int tclean(Draw_Interpretor& di, int n, const char** a) } if (toRemoveGeometry) + { BRepTools::CleanGeometry(aCompound); + } else + { BRepTools::Clean(aCompound, isForceClean); + } return 0; } @@ -486,7 +498,9 @@ static int polygons(Draw_Interpretor&, int n, const char** a) static int compound(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } BRep_Builder B; TopoDS_Compound C; B.MakeCompound(C); @@ -494,7 +508,9 @@ static int compound(Draw_Interpretor&, int n, const char** a) { TopoDS_Shape S2 = DBRep::Get(a[i]); if (!S2.IsNull()) + { B.Add(C, S2); + } } DBRep::Set(a[n - 1], C); return 0; @@ -507,10 +523,14 @@ static int compound(Draw_Interpretor&, int n, const char** a) static int emptycopy(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[(n == 2) ? 1 : 2]); if (S.IsNull()) + { return 1; + } S.EmptyCopy(); DBRep::Set(a[1], S); return 0; @@ -523,14 +543,20 @@ static int emptycopy(Draw_Interpretor&, int n, const char** a) static int add(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } BRep_Builder B; TopoDS_Shape S1 = DBRep::Get(a[1]); if (S1.IsNull()) + { return 1; + } TopoDS_Shape S2 = DBRep::Get(a[2]); if (S2.IsNull()) + { return 1; + } B.Add(S2, S1); DBRep::Set(a[2], S2); return 0; @@ -543,15 +569,21 @@ static int add(Draw_Interpretor&, int n, const char** a) static int explode(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } char newname[1024]; strcpy(newname, a[1]); char* p = newname; while (*p != '\0') + { p++; + } *p = '_'; p++; int i = 0; @@ -577,19 +609,29 @@ static int explode(Draw_Interpretor& di, int n, const char** a) case 'C': case 'c': if ((a[2][1] == 'd') || (a[2][1] == 'D')) + { typ = TopAbs_COMPOUND; + } else + { typ = TopAbs_COMPSOLID; + } break; case 'S': case 's': if ((a[2][1] == 'O') || (a[2][1] == 'o')) + { typ = TopAbs_SOLID; + } else if ((a[2][1] == 'H') || (a[2][1] == 'h')) + { typ = TopAbs_SHELL; + } else + { return 1; + } break; case 'F': @@ -642,15 +684,21 @@ static int explode(Draw_Interpretor& di, int n, const char** a) static int nexplode(Draw_Interpretor& di, int n, const char** a) { if (n <= 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } char newname[1024]; strcpy(newname, a[1]); char* p = newname; while (*p != '\0') + { p++; + } *p = '_'; p++; TopAbs_ShapeEnum typ; @@ -738,7 +786,9 @@ static int nexplode(Draw_Interpretor& di, int n, const char** a) for (Index = 1; Index < MaxShapes; Index++) { if (MidXYZ(OrderInd(Index + 1)) == MidXYZ(OrderInd(Index))) + { di << "Warning! For this shape the results may be incorrect.\n"; + } } for (Index = 1; Index <= MaxShapes; Index++) @@ -758,17 +808,25 @@ static int nexplode(Draw_Interpretor& di, int n, const char** a) static int exwire(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } if (S.ShapeType() != TopAbs_WIRE) + { return 0; + } char newname[1024]; strcpy(newname, a[1]); char* p = newname; while (*p != '\0') + { p++; + } *p = '_'; p++; int i = 0; @@ -790,10 +848,14 @@ static int exwire(Draw_Interpretor&, int n, const char** a) static int invert(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } BRep_Builder B; TopoDS_Shape NS = S.EmptyCopied(); @@ -817,14 +879,18 @@ static int invert(Draw_Interpretor&, int n, const char** a) static int orientation(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } int cas = 0; TopAbs_Orientation ori = TopAbs_FORWARD; int last = n; if (!strcasecmp(a[0], "orientation")) { if (n <= 2) + { return 1; + } last--; switch (*a[n - 1]) { @@ -863,11 +929,17 @@ static int orientation(Draw_Interpretor&, int n, const char** a) if (!S.IsNull()) { if (cas == -2) + { S.Complement(); + } else if (cas == -1) + { S.Reverse(); + } else + { S.Orientation(ori); + } DBRep::Set(a[i], S); } } @@ -883,7 +955,9 @@ static int orientation(Draw_Interpretor&, int n, const char** a) static int numshapes(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } int i; TopExp_Explorer ex; @@ -946,7 +1020,9 @@ static void DumpExtent(const TopoDS_Shape& aS, TCollection_AsciiString& aStr) static int nbshapes(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } int i; bool aTotal; @@ -985,7 +1061,9 @@ static int nbshapes(Draw_Interpretor& di, int n, const char** a) static int countshapes(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } int i; TopExp_Explorer ex; @@ -1207,13 +1285,17 @@ void setProp(TopoDS_Shape Sh, const char** a, int n) static int setFlags(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopExp_Explorer ex; TopoDS_Shape Sh = DBRep::Get(a[1]); if (Sh.IsNull()) + { return 1; + } setProp(Sh, a, n); for (ex.Init(Sh, TopAbs_VERTEX); ex.More(); ex.Next()) @@ -1255,7 +1337,9 @@ static int purgemmgt(Draw_Interpretor&, int, const char**) static int check(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } int i; TopExp_Explorer ex; @@ -1264,7 +1348,9 @@ static int check(Draw_Interpretor&, int n, const char** a) TopoDS_Shape S = DBRep::Get(a[i]); TopoDS_Shape C; if (S.IsNull()) + { continue; + } for (ex.Init(S, TopAbs_FACE); ex.More(); ex.Next()) { C = ex.Current(); @@ -1390,7 +1476,9 @@ static int normals(Draw_Interpretor& theDI, int theArgNum, const char** theArgs) TopAbs_Orientation aFaceOri = aFaceIt.Key().Orientation(); const Draw_Color aColor = DBRep_ColorOrientation(aFaceOri); if (aFaceOri == TopAbs_REVERSED) + { bReverse = true; + } for (NCollection_DynamicArray>::Iterator aNormalsIt(aFaceIt.Value()); aNormalsIt.More(); @@ -1404,7 +1492,9 @@ static int normals(Draw_Interpretor& theDI, int theArgNum, const char** theArgs) // Make the normal vector from the points gp_Vec aV(aVec.first, aVec.second); if (bReverse) + { aV.Reverse(); + } // Print values of the vector avoiding printing "-0" values theDI << "(" << (aV.X() == 0 ? 0 : aV.X()) << ", " << (aV.Y() == 0 ? 0 : aV.Y()) << ", " @@ -1466,7 +1556,7 @@ TopoDS_Shape DBRep::getShape(const char*& theName, TopAbs_ShapeEnum theType, boo TopAbs::Print(theType, std::cout); std::cout << " but a "; TopAbs::Print(aShape.ShapeType(), std::cout); - std::cout << std::endl; + std::cout << '\n'; } return TopoDS_Shape(); } @@ -1479,23 +1569,35 @@ static int XProgress(Draw_Interpretor& di, int argc, const char** argv) { bool turn = true; if (argv[i][0] == '-') + { turn = false; + } else if (argv[i][0] != '+') + { continue; + } TCollection_AsciiString anArgCase(argv[i]); anArgCase.LowerCase(); if (argv[i][1] == 't') + { Draw_ProgressIndicator::DefaultTclMode() = turn; + } else if (argv[i][1] == 'c') + { Draw_ProgressIndicator::DefaultConsoleMode() = turn; + } else if (argv[i][1] == 'g') + { Draw_ProgressIndicator::DefaultGraphMode() = turn; + } else if (!strcmp(argv[i], "-stop") && i + 1 < argc) { void* aPtr = nullptr; if (sscanf(argv[++i], "%p", &aPtr) == 1) + { Draw_ProgressIndicator::StopIndicator() = aPtr; + } return 0; } } @@ -1755,7 +1857,9 @@ static bool done = false; void DBRep::BasicCommands(Draw_Interpretor& theCommands) { if (done) + { return; + } done = true; Draw::Commands(theCommands); diff --git a/src/Draw/TKDraw/DBRep/DBRep_DrawableShape.cxx b/src/Draw/TKDraw/DBRep/DBRep_DrawableShape.cxx index 17b2828cc3..527454e456 100644 --- a/src/Draw/TKDraw/DBRep/DBRep_DrawableShape.cxx +++ b/src/Draw/TKDraw/DBRep/DBRep_DrawableShape.cxx @@ -103,7 +103,9 @@ void DBRep_DrawableShape::updateDisplayData() const myEdges.Clear(); if (myShape.IsNull()) + { return; + } //============================================================== // Process the faces @@ -126,10 +128,14 @@ void DBRep_DrawableShape::updateDisplayData() const IsoBuild.LoadIsos(myFaces.Last()); } else + { myFaces.Append(new DBRep_Face(TopologicalFace, 0, myEdgeCol)); + } } else + { myFaces.Append(new DBRep_Face(TopologicalFace, 0, myEdgeCol)); + } } //============================================================== @@ -148,7 +154,9 @@ void DBRep_DrawableShape::updateDisplayData() const // skip degenerated edges if (BRep_Tool::Degenerated(theEdge)) + { continue; + } // compute the number of faces int nbf = edgemap(iedge).Extent(); @@ -200,10 +208,14 @@ void DBRep_DrawableShape::ChangeNbIsos(const int NbIsos) IsoBuild.LoadIsos(myFaces.Last()); } else + { myFaces.Append(new DBRep_Face(TopologicalFace, 0, myEdgeCol)); + } } else + { myFaces.Append(new DBRep_Face(TopologicalFace, 0, myEdgeCol)); + } } } @@ -353,7 +365,9 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const } if (myFaces.IsEmpty() || myEdges.IsEmpty()) + { updateDisplayData(); + } // hidden lines if (myHLR) @@ -398,25 +412,39 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const if (aSurf->IsUPeriodic()) { if (FU1 < SU1 || FU1 > SU2) + { restriction = true; + } if (!restriction && (FU2 < SU1 || FU2 > SU2)) + { restriction = true; + } } if (!restriction && aSurf->IsVPeriodic()) { if (FV1 < SV1 || FV1 > SV2) + { restriction = true; + } if (!restriction && (FV2 < SV1 || FV2 > SV2)) + { restriction = true; + } } bool zeroS = (fabs(SU2 - SU1) <= 1.e-9 || fabs(SV2 - SV1) <= 1.e-9); bool zeroF = (fabs(FU2 - FU1) <= 1.e-9 || fabs(FV2 - FV1) <= 1.e-9); if (restriction && (zeroS || zeroF)) + { restriction = false; + } if (restriction && (FU1 >= FU2 || FV1 >= FV2)) + { restriction = false; + } if (restriction && (fabs(FU2 - FU1) > 4.1e+100 || fabs(FV2 - FV1) > 4.1e+100)) + { restriction = false; + } } BRepAdaptor_Surface S(F->Face(), restriction); @@ -471,9 +499,13 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const { if (TI(Intrv) <= T1 && TI(Intrv + 1) <= T1) + { continue; + } if (TI(Intrv) >= T2 && TI(Intrv + 1) >= T2) + { continue; + } if (T == GeomAbs_IsoU) { V1 = std::max(T1, TI(Intrv)); @@ -563,7 +595,9 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const || (T == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) { if (SurfType == GeomAbs_SurfaceOfExtrusion) + { break; + } for (j = 1; j < myDiscret; j++) { U1 += stepU; @@ -666,9 +700,13 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const const occ::handle& E = ite.Value(); if (myDispOr) + { dis.SetColor(DBRep_ColorOrientation(E->Edge().Orientation())); + } else + { dis.SetColor(E->Color()); + } // display geometrical curve if exists. bool isgeom = BRep_Tool::IsGeometric(E->Edge()); @@ -681,7 +719,7 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const if (aCheckU2 < aCheckU1) { // bad orientation - std::cout << "DBRep_DrawableShape : Bad parameters on edge." << std::endl; + std::cout << "DBRep_DrawableShape : Bad parameters on edge." << '\n'; BRepTools::Dump(E->Edge(), std::cout); ite.Next(); continue; @@ -867,7 +905,9 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const { if (myDispOr) + { dis.SetColor(DBRep_ColorOrientation(exv.Current().Orientation())); + } dis.DrawMarker(BRep_Tool::Pnt(TopoDS::Vertex(exv.Current())), Draw_Losange); if (dis.HasPicked()) { @@ -890,7 +930,9 @@ void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis) dout.GetTrsf(id, T); double focal = -1; if (!strcmp(dout.GetType(id), "PERS")) + { focal = dout.Focal(id); + } double Ang, Def; HLRBRep::PolyHLRAngleAndDeflection(myAng, Ang, Def); IMeshTools_Parameters aMeshParams; @@ -912,7 +954,9 @@ void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis) double ang = it.Value().Angle(); recompute = !it.Value().IsSame(T, focal) || myAng != ang; if (recompute) + { myHidData.Remove(it); + } else { it.ChangeValue().DrawOn(dis, myRg1, myRgN, myHid, myConnCol, myIsosCol); @@ -1099,17 +1143,29 @@ void DBRep_DrawableShape::Whatis(Draw_Interpretor& s) const << TopAbs::ShapeOrientationToString(myShape.Orientation()); if (myShape.Free()) + { s << " Free"; + } if (myShape.Modified()) + { s << " Modified"; + } if (myShape.Orientable()) + { s << " Orientable"; + } if (myShape.Closed()) + { s << " Closed"; + } if (myShape.Infinite()) + { s << " Infinite"; + } if (myShape.Convex()) + { s << " Convex"; + } } //================================================================================================= @@ -1139,8 +1195,12 @@ void DBRep_DrawableShape::display(const occ::handle& T, { pc.Triangles(i, t[0], t[1], t[2]); for (j = 0; j < 3; j++) + { if (t[j] == 0) + { nFree++; + } + } } // allocate the arrays diff --git a/src/Draw/TKDraw/DBRep/DBRep_HideData.cxx b/src/Draw/TKDraw/DBRep/DBRep_HideData.cxx index 47792ff5a8..f3e7a832cb 100644 --- a/src/Draw/TKDraw/DBRep/DBRep_HideData.cxx +++ b/src/Draw/TKDraw/DBRep/DBRep_HideData.cxx @@ -115,16 +115,22 @@ bool DBRep_HideData::IsSame(const gp_Trsf& TProj, const double focal) const if (focal > 0) { if (myFocal <= 0) + { return false; + } if (myFocal != focal) + { return false; + } const gp_XYZ& T1 = TProj.TranslationPart(); const gp_XYZ& T2 = myTrsf.TranslationPart(); for (int i = 1; i <= 3; i++) { if (T1.Coord(i) != T2.Coord(i)) + { return false; + } } } const gp_Mat& M1 = TProj.HVectorialPart(); @@ -136,7 +142,9 @@ bool DBRep_HideData::IsSame(const gp_Trsf& TProj, const double focal) const for (int j = 1; j <= 3; j++) { if (M1.Value(i, j) != M2.Value(i, j)) + { return false; + } } } return true; @@ -165,7 +173,9 @@ void DBRep_HideData::DrawOn(Draw_Display& D, bool todraw = true; if ((!withRg1 && BP.Rg1Line() && !BP.OutLine()) || (!withRgN && BP.RgNLine() && !BP.OutLine())) + { todraw = false; + } if (todraw) { D.MoveTo(BP.P1()); @@ -185,7 +195,9 @@ void DBRep_HideData::DrawOn(Draw_Display& D, const HLRBRep_BiPoint& BP = It.Value(); bool todraw = true; if ((!withRg1 && BP.Rg1Line() && !BP.OutLine()) || (!withRgN && BP.RgNLine() && !BP.OutLine())) + { todraw = false; + } if (todraw) { D.MoveTo(BP.P1()); diff --git a/src/Draw/TKDraw/DBRep/DBRep_IsoBuilder.cxx b/src/Draw/TKDraw/DBRep/DBRep_IsoBuilder.cxx index 48fac2e7f1..f840ef5f31 100644 --- a/src/Draw/TKDraw/DBRep/DBRep_IsoBuilder.cxx +++ b/src/Draw/TKDraw/DBRep/DBRep_IsoBuilder.cxx @@ -197,7 +197,9 @@ DBRep_IsoBuilder::DBRep_IsoBuilder(const TopoDS_Face& TopologicalFace, // if U1 and U2 coincide-->do nothing if (std::abs(U1 - U2) <= Precision::PConfusion()) + { continue; + } occ::handle TrimPCurve = new Geom2d_TrimmedCurve(PCurve, U1, U2); anEdgePCurveMap.Add(TopologicalEdge, TrimPCurve); } @@ -270,7 +272,9 @@ DBRep_IsoBuilder::DBRep_IsoBuilder(const TopoDS_Face& TopologicalFace, { ComputeDomains(Index); if (IsDone(Index)) + { myNbDom = myNbDom + Geom2dHatch_Hatcher::NbDomains(Index); + } } } @@ -281,7 +285,9 @@ DBRep_IsoBuilder::DBRep_IsoBuilder(const TopoDS_Face& TopologicalFace, { ComputeDomains(Index); if (IsDone(Index)) + { myNbDom = myNbDom + Geom2dHatch_Hatcher::NbDomains(Index); + } } } } @@ -309,19 +315,19 @@ void DBRep_IsoBuilder::LoadIsos(const occ::handle& Face) const switch (Status(UInd)) { case HatchGen_NoProblem: - std::cout << " No Problem" << std::endl; + std::cout << " No Problem" << '\n'; break; case HatchGen_TrimFailure: - std::cout << " Trim Failure" << std::endl; + std::cout << " Trim Failure" << '\n'; break; case HatchGen_TransitionFailure: - std::cout << " Transition Failure" << std::endl; + std::cout << " Transition Failure" << '\n'; break; case HatchGen_IncoherentParity: - std::cout << " Incoherent Parity" << std::endl; + std::cout << " Incoherent Parity" << '\n'; break; case HatchGen_IncompatibleStates: - std::cout << " Incompatible States" << std::endl; + std::cout << " Incompatible States" << '\n'; break; } } @@ -352,19 +358,19 @@ void DBRep_IsoBuilder::LoadIsos(const occ::handle& Face) const switch (Status(VInd)) { case HatchGen_NoProblem: - std::cout << " No Problem" << std::endl; + std::cout << " No Problem" << '\n'; break; case HatchGen_TrimFailure: - std::cout << " Trim Failure" << std::endl; + std::cout << " Trim Failure" << '\n'; break; case HatchGen_TransitionFailure: - std::cout << " Transition Failure" << std::endl; + std::cout << " Transition Failure" << '\n'; break; case HatchGen_IncoherentParity: - std::cout << " Incoherent Parity" << std::endl; + std::cout << " Incoherent Parity" << '\n'; break; case HatchGen_IncompatibleStates: - std::cout << " Incompatible States" << std::endl; + std::cout << " Incompatible States" << '\n'; break; } } @@ -399,7 +405,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& { const TopoDS_Shape& aW = aItW.Value(); if (aW.ShapeType() != TopAbs_WIRE) + { continue; + } // Use WireExplorer to iterate on edges of the wire // to get the pairs of connected edges. @@ -408,7 +416,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& BRepTools_WireExplorer aWExp; aWExp.Init(TopoDS::Wire(aW), theFace, myUMin, myUMax, myVMin, myVMax); if (!aWExp.More()) + { continue; + } // Check the number of edges in the wire, not to // miss the wires containing one edge only @@ -445,13 +455,17 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& } if (aPrevEdge.IsEqual(aCurrEdge) && !SingleEdge) + { continue; + } // Get p-curves occ::handle* pPC1 = theEdgePCurveMap.ChangeSeek(aPrevEdge); occ::handle* pPC2 = theEdgePCurveMap.ChangeSeek(aCurrEdge); if (!pPC1 || !pPC2) + { continue; + } occ::handle& aPrevC2d = *pPC1; occ::handle& aCurrC2d = *pPC2; @@ -471,26 +485,38 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& // Get vertex on the previous edge TopoDS_Vertex aCVOnPrev = TopExp::LastVertex(aPrevEdge, true); if (aCVOnPrev.IsNull()) + { continue; + } // Get parameter of the vertex on the previous edge double aTPrev = BRep_Tool::Parameter(aCVOnPrev, aPrevEdge); if (aTPrev < fp) + { aTPrev = fp; + } else if (aTPrev > lp) + { aTPrev = lp; + } // Get vertex on the current edge TopoDS_Vertex aCVOnCurr = TopExp::FirstVertex(aCurrEdge, true); if (aCVOnCurr.IsNull() || !aCVOnPrev.IsSame(aCVOnCurr)) + { continue; + } // Get parameter of the vertex on the current edge double aTCurr = BRep_Tool::Parameter(aCVOnCurr, aCurrEdge); if (aTCurr < fc) + { aTCurr = fc; + } else if (aTCurr > lc) + { aTCurr = lc; + } // Get bounding points on the edges corresponding to the current vertex gp_Pnt2d aPrevP2d = aPrevC2d->Value(aTPrev), aCurrP2d = aCurrC2d->Value(aTCurr); @@ -509,14 +535,18 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& // Check if the vertex closes the gap if (aPV.SquareDistance(aPrevPS) > aTolV2) + { continue; + } // Convert bounding point on current edge into 3D gp_Pnt aCurrPS = aBASurf.Value(aCurrP2d.X(), aCurrP2d.Y()); // Check if the vertex closes the gap if (aPV.SquareDistance(aCurrPS) > aTolV2) + { continue; + } } // Create the segment @@ -528,10 +558,14 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& if (bAddSegment) { if (aBASurf.IsUPeriodic()) + { bAddSegment = aSegmLen < aBASurf.UPeriod() / 4.; + } if (bAddSegment && aBASurf.IsVPeriodic()) + { bAddSegment = aSegmLen < aBASurf.VPeriod() / 4.; + } } // Check that p-curves do not interfere near the vertex. @@ -557,7 +591,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& // Get intersection points aNbInt = anInter.NbPoints(); for (iP = 1; iP <= aNbInt; ++iP) + { aLPInt.Append(anInter.Point(iP)); + } // Analyze the points and find the one closest to the current vertex bool bPointFound = false; @@ -603,7 +639,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& for (TopoDS_Iterator it2(aCurrEdge); it2.More(); it2.Next()) { if (it1.Value().IsSame(it2.Value())) + { ++aNbCV; + } } } @@ -637,7 +675,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& // Trim previous p-curve if (l - f > Precision::PConfusion()) + { aPrevC2d = new Geom2d_TrimmedCurve(aPrevC2d, f, l); + } // Prepare trimming parameters for current p-curve if (std::abs(fc - aTCurr) < std::abs(lc - aTCurr)) @@ -653,7 +693,9 @@ void DBRep_IsoBuilder::FillGaps(const TopoDS_Face& theFace, DataMapOfEdgePCurve& // Trim current p-curve if (l - f > Precision::PConfusion()) + { aCurrC2d = new Geom2d_TrimmedCurve(aCurrC2d, f, l); + } // Do not create the segment, as we performed the trimming // to the intersection point. diff --git a/src/Draw/TKDraw/Draw/Draw.cxx b/src/Draw/TKDraw/Draw/Draw.cxx index 18f1b81676..9519b98fb3 100644 --- a/src/Draw/TKDraw/Draw/Draw.cxx +++ b/src/Draw/TKDraw/Draw/Draw.cxx @@ -253,7 +253,9 @@ void exitProc(ClientData /*dc*/) if (!Draw_Batch) { for (int id = 0; id < MAXVIEW; id++) + { dout.DeleteView(id); + } } } #endif @@ -383,7 +385,9 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) #ifdef _WIN32 // in interactive mode, force Windows to report dll loading problems interactively if (!Draw_VirtualWindows && !Draw_Batch) + { ::SetErrorMode(0); + } #endif // ***************************************************************** @@ -394,14 +398,16 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) #endif if (!Draw_Batch) + { #ifdef _WIN32 Draw_Batch = !Init_Appli(hInst, hPrevInst, nShow, hWnd); #else Draw_Batch = !Init_Appli(); #endif + } else { - std::cout << "DRAW is running in batch mode" << std::endl; + std::cout << "DRAW is running in batch mode" << '\n'; theCommands.Init(); Tcl_Init(theCommands.Interp()); } @@ -413,7 +419,7 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) { if (!dout.DefineColor(i, ColorNames[i])) { - std::cout << "Could not allocate default color " << ColorNames[i] << std::endl; + std::cout << "Could not allocate default color " << ColorNames[i] << '\n'; } } } @@ -431,7 +437,9 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) Draw::VariableCommands(theCommands); Draw::UnitCommands(theCommands); if (!Draw_Batch) + { Draw::GraphicCommands(theCommands); + } // ***************************************************************** // user commands @@ -489,8 +497,8 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) #ifdef _WIN32 ReadInitFile("ddefault"); #else - std::cout << " the CASROOT variable is mandatory to Run OpenCascade " << std::endl; - std::cout << "No default file" << std::endl; + std::cout << " the CASROOT variable is mandatory to Run OpenCascade " << '\n'; + std::cout << "No default file" << '\n'; #endif } } @@ -506,11 +514,13 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) ReadInitFile(aRunFile); // provide a clean exit, this is useful for some analysis tools if (!isInteractiveForced) + { #ifndef _WIN32 return; #else ExitProcess(0); #endif + } } // execute command from command line @@ -533,11 +543,13 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli) Draw_Interprete(aCommand.ToCString()); // Linux and Windows batch mode // provide a clean exit, this is useful for some analysis tools if (!isInteractiveForced) + { #ifndef _WIN32 return; #else ExitProcess(0); #endif + } } // ***************************************************************** @@ -599,7 +611,9 @@ bool Draw_Interprete(const char* com) #endif if (!Draw_Interpretor::Complete(Tcl_DStringValue(&command))) + { return false; + } // ******************************************************************* // Command interpreter @@ -613,22 +627,30 @@ bool Draw_Interprete(const char* com) OSD_Timer tictac; bool hadchrono = Draw_Chrono; if (hadchrono) + { tictac.Start(); + } if (Draw_BeforeCommand) + { (*Draw_BeforeCommand)(); + } int c; c = theCommands.RecordAndEval(Tcl_DStringValue(&command)); if (Draw_AfterCommand) + { (*Draw_AfterCommand)(c); + } if (wasspying && Draw_Spying) { if (c > 0) + { spystream << "# "; + } spystream << Tcl_DStringValue(&command) << "\n"; } @@ -645,7 +667,7 @@ bool Draw_Interprete(const char* com) { Message_PrinterOStream::SetConsoleTextColor(&std::cout, Message_ConsoleColor_Default, false); } - std::cout << std::endl; + std::cout << '\n'; } if (Draw_Chrono && hadchrono) @@ -675,7 +697,7 @@ int Tcl_AppInit(Tcl_Interp*) int Draw_Call(char* c) { int r = theCommands.Eval(c); - std::cout << theCommands.Result() << std::endl; + std::cout << theCommands.Result() << '\n'; return r; } @@ -702,7 +724,7 @@ void Draw::Load(Draw_Interpretor& theDI, { Message::SendFail() << "could not find the resource:" << theKey; Standard_SStream aMsg; - aMsg << "Could not find the resource:" << theKey << std::endl; + aMsg << "Could not find the resource:" << theKey << '\n'; throw Draw_Failure(aMsg.str().c_str()); } diff --git a/src/Draw/TKDraw/Draw/Draw_BasicCommands.cxx b/src/Draw/TKDraw/Draw/Draw_BasicCommands.cxx index a97a1fd09f..658460ef38 100644 --- a/src/Draw/TKDraw/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_BasicCommands.cxx @@ -49,6 +49,8 @@ #define RLIM_INFINITY 0x7fffffff +extern bool Draw_Batch; + static clock_t CPU_CURRENT; // cpu time already used at last // cpulimit call. (sec.) #else /* _WIN32 */ @@ -64,8 +66,6 @@ static clock_t CPU_CURRENT; // cpu time already used at last #endif /* _WIN32 */ -extern bool Draw_Batch; - static clock_t CPU_LIMIT; // Cpu_limit in Sec. static OSD_Timer aTimer; @@ -212,9 +212,13 @@ static int dchronom(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV static int ifbatch(Draw_Interpretor& DI, int, const char**) { if (Draw_Batch) + { DI << "1"; + } else + { DI << "0"; + } return 0; } @@ -227,7 +231,9 @@ extern std::filebuf Draw_Spyfile; static int spy(Draw_Interpretor& di, int n, const char** a) { if (Draw_Spying) + { Draw_Spyfile.close(); + } Draw_Spying = false; if (n > 1) { @@ -509,7 +515,9 @@ static int Draw_wait(Draw_Interpretor&, int n, const char** a) { int w = 10; if (n > 1) + { w = Draw::Atoi(a[1]); + } time_t ct = time(nullptr) + w; while (time(nullptr) < ct) { @@ -569,7 +577,7 @@ static unsigned int __stdcall CpuFunc(void* /*param*/) #else static void cpulimitSignalHandler(int) { - std::cout << "Process killed by CPU limit (" << CPU_LIMIT << " sec)" << std::endl; + std::cout << "Process killed by CPU limit (" << CPU_LIMIT << " sec)" << '\n'; exit(2); } @@ -582,7 +590,7 @@ static void* CpuFunc(void* /*threadarg*/) anElapCurrent = clock_t(aTimer.ElapsedTime()); if (CPU_LIMIT > 0 && (anElapCurrent) >= CPU_LIMIT) { - std::cout << "Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << std::endl; + std::cout << "Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << '\n'; exit(2); } } @@ -683,17 +691,29 @@ static int dlocale(Draw_Interpretor& di, int n, const char** argv) { const char* cat = argv[1]; if (!strcmp(cat, "LC_ALL")) + { category = LC_ALL; + } else if (!strcmp(cat, "LC_COLLATE")) + { category = LC_COLLATE; + } else if (!strcmp(cat, "LC_CTYPE")) + { category = LC_CTYPE; + } else if (!strcmp(cat, "LC_MONETARY")) + { category = LC_MONETARY; + } else if (!strcmp(cat, "LC_NUMERIC")) + { category = LC_NUMERIC; + } else if (!strcmp(cat, "LC_TIME")) + { category = LC_TIME; + } else { Message::SendFail() << "Error: cannot recognize argument " << cat << " as one of LC_ macros"; @@ -703,9 +723,13 @@ static int dlocale(Draw_Interpretor& di, int n, const char** argv) const char* locale = (n > 2 ? argv[2] : nullptr); const char* result = setlocale(category, locale); if (result) + { di << result; + } else - std::cout << "Error: unsupported locale specification: " << locale << std::endl; + { + std::cout << "Error: unsupported locale specification: " << locale << '\n'; + } return 0; } @@ -1140,7 +1164,7 @@ static int dputs(Draw_Interpretor& theDI, int theArgNb, const char** theArgVec) } if (!isNoNewline) { - *aStream << std::endl; + *aStream << '\n'; } return 0; } @@ -1159,7 +1183,9 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands) { static bool Done = false; if (Done) + { return; + } Done = true; std::ios::sync_with_stdio(); diff --git a/src/Draw/TKDraw/Draw/Draw_Debug.cxx b/src/Draw/TKDraw/Draw/Draw_Debug.cxx index 805313e16e..e69ad9088a 100644 --- a/src/Draw/TKDraw/Draw/Draw_Debug.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Debug.cxx @@ -33,7 +33,7 @@ Standard_EXPORT const char* Draw_Eval(const char* theCommandStr) OCC_CATCH_SIGNALS Draw_Interpretor& aCommands = Draw::GetInterpretor(); aCommands.Eval(theCommandStr); - std::cout << aCommands.Result() << std::endl; + std::cout << aCommands.Result() << '\n'; return aCommands.Result(); } catch (Standard_Failure const& anException) diff --git a/src/Draw/TKDraw/Draw/Draw_Display.cxx b/src/Draw/TKDraw/Draw/Draw_Display.cxx index cda90e4ba8..a2e3e490bb 100644 --- a/src/Draw/TKDraw/Draw/Draw_Display.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Display.cxx @@ -124,22 +124,30 @@ void Draw_Display::DrawMarker(const gp_Pnt2d& pt, const Draw_MarkerShape S, cons case Draw_Circle: { int I = (int)R; if (!I) + { return; + } DrawMarker(pt, S, I); break; } case Draw_CircleZoom: if (R == 0.0) + { return; + } gp_Circ2d C; C.SetRadius(R); C.SetLocation(pt); // if the circus is too small, a "plus" is drawn to mark the point bool b = (R * Zoom()) > 2; if (b) + { Draw(C, 0, 2 * M_PI); + } else + { DrawMarker(pt, Draw_Plus); + } } Draw_Bounds = true; MoveTo(pt); @@ -157,7 +165,9 @@ void Draw_Display::Draw(const gp_Circ& C, { double A2 = A3; while (A2 < A1) + { A2 += 2 * M_PI; + } double angle = DEFLECTION / (C.Radius() * Zoom()); int n = (int)((A2 - A1) / angle); @@ -210,7 +220,9 @@ void Draw_Display::Draw(const gp_Circ2d& C, { double A2 = A3; while (A2 < A1) + { A2 += 2 * M_PI; + } double angle = DEFLECTION / (C.Radius() * Zoom()); int n = (int)((A2 - A1) / angle); diff --git a/src/Draw/TKDraw/Draw/Draw_GraphicCommands.cxx b/src/Draw/TKDraw/Draw/Draw_GraphicCommands.cxx index 1fa9050574..774f501ea6 100644 --- a/src/Draw/TKDraw/Draw/Draw_GraphicCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_GraphicCommands.cxx @@ -72,12 +72,12 @@ static int ViewId(const char* const a) int id = Draw::Atoi(a); if ((id < 0) || (id >= MAXVIEW)) { - std::cout << "Incorrect view-id, must be in 0.." << MAXVIEW - 1 << std::endl; + std::cout << "Incorrect view-id, must be in 0.." << MAXVIEW - 1 << '\n'; return -1; } if (!dout.HasView(id)) { - std::cout << "View " << id << " does not exist." << std::endl; + std::cout << "View " << id << " does not exist." << '\n'; return -1; } return id; @@ -121,7 +121,9 @@ static int zoom(Draw_Interpretor&, int n, const char** a) { int id = ViewId(a[1]); if (id < 0) + { return 1; + } double z = Draw::Atof(a[2]); dout.SetZoom(id, z); dout.RepaintView(id); @@ -129,7 +131,9 @@ static int zoom(Draw_Interpretor&, int n, const char** a) return 0; } else + { return 1; + } } //================================================================================================= @@ -163,9 +167,13 @@ static int wzoom(Draw_Interpretor& di, int argc, const char** argv) dY1 /= z; if (b != 1) + { return 0; + } if (id < 0) + { return 0; + } Draw_Display d = dout.MakeDisplay(id); d.SetColor(Draw_blanc); d.SetMode(10); @@ -207,7 +215,9 @@ static int wzoom(Draw_Interpretor& di, int argc, const char** argv) d.Draw(gp_Pnt2d(dOX2, dY1), gp_Pnt2d(dX1, dY1)); d.Flush(); if (b != 1) + { return 0; + } d.SetMode(0); } else @@ -232,16 +242,24 @@ static int wzoom(Draw_Interpretor& di, int argc, const char** argv) } if ((X1 == X2) || (Y1 == Y2)) + { return 0; + } zx = (double)std::abs(X2 - X1) / (double)W; zy = (double)std::abs(Y2 - Y1) / (double)H; if (zy > zx) + { zx = zy; + } zx = 1 / zx; if (X2 < X1) + { X1 = X2; + } if (Y2 > Y1) + { Y1 = Y2; + } X1 = (int)(X1 * zx); Y1 = (int)(Y1 * zx); dout.SetZoom(id, zx * dout.Zoom(id)); @@ -267,7 +285,9 @@ static int wclick(Draw_Interpretor& di, int, const char**) static int view(Draw_Interpretor& di, int n, const char** a) { if (Draw_Batch) + { return 1; + } if ((n >= 3) && (n != 4)) { @@ -283,15 +303,25 @@ static int view(Draw_Interpretor& di, int n, const char** a) int H = 500; // if view exist, get old values if (dout.HasView(id)) + { dout.GetPosSize(id, X, Y, W, H); + } if (n >= 4) + { X = Draw::Atoi(a[3]); + } if (n >= 5) + { Y = Draw::Atoi(a[4]); + } if (n >= 6) + { W = Draw::Atoi(a[5]); + } if (n >= 7) + { H = Draw::Atoi(a[6]); + } dout.MakeView(id, a[2], X, Y, W, H); if (!dout.HasView(id)) { @@ -322,7 +352,9 @@ static int view(Draw_Interpretor& di, int n, const char** a) return 0; } else + { return 1; + } } //================================================================================================= @@ -332,19 +364,25 @@ static int delview(Draw_Interpretor&, int n, const char** a) if (n == 1) { for (int id = 0; id < MAXVIEW; id++) + { dout.DeleteView(id); + } return 0; } else if (n >= 2) { int id = ViewId(a[1]); if (id < 0) + { return 1; + } dout.DeleteView(id); return 0; } else + { return 1; + } } //================================================================================================= @@ -365,7 +403,9 @@ static int fit(Draw_Interpretor&, int n, const char** a) // dout.FitView(id,frame); dout.FitView(id, (int)frame); if (dout.Zoom(id) < zoom) + { zoom = dout.Zoom(id); + } } } } @@ -387,7 +427,9 @@ static int fit(Draw_Interpretor&, int n, const char** a) { int id = ViewId(a[1]); if (id < 0) + { return 1; + } // dout.FitView(id,frame); dout.FitView(id, (int)frame); dout.RepaintView(id); @@ -395,7 +437,9 @@ static int fit(Draw_Interpretor&, int n, const char** a) return 0; } else + { return 1; + } } //================================================================================================= @@ -408,14 +452,20 @@ static int focal(Draw_Interpretor&, int n, const char** a) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; } double df = 1.; if (!strcasecmp(a[0], "fu")) + { df = stepfocal; + } if (!strcasecmp(a[0], "fd")) + { df = 1. / stepfocal; + } for (int id = start; id <= end; id++) { @@ -437,7 +487,9 @@ static int setfocal(Draw_Interpretor& di, int n, const char** a) for (int id = 0; id < MAXVIEW; id++) { if (!strcasecmp(dout.GetType(id), "PERS")) + { di << "Focal view " << id << " is " << dout.Focal(id) << "\n"; + } } } else @@ -446,7 +498,9 @@ static int setfocal(Draw_Interpretor& di, int n, const char** a) for (int id = 0; id < MAXVIEW; id++) { if (!strcasecmp(dout.GetType(id), "PERS")) + { dout.SetFocal(id, f); + } } dout.RepaintAll(); } @@ -464,18 +518,26 @@ static int magnify(Draw_Interpretor&, int n, const char** a) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; } bool v2d = (a[0][0] == '2'); // 2dmu, 2dmd const char* com = a[0]; if (v2d) + { com += 2; + } double dz = 1.; - if (!strcasecmp(com, "mu")) // mu, 2dmu + if (!strcasecmp(com, "mu")) + { // mu, 2dmu dz = stepmagnify; - else // md, 2dmd + } + else + { // md, 2dmd dz = 1 / stepmagnify; + } for (int id = start; id <= end; id++) { @@ -507,7 +569,9 @@ static int rotate(Draw_Interpretor&, int n, const char** a) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; } @@ -555,7 +619,9 @@ static int panning(Draw_Interpretor&, int n, const char** a) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; } int DX = 0; @@ -565,16 +631,26 @@ static int panning(Draw_Interpretor&, int n, const char** a) bool v2d = (a[0][0] == '2'); // pu2d, pd2d, pr2d, pl2d const char* com = a[0]; if (v2d) + { com += 2; + } - if (!strcasecmp(com, "pu")) // pu , 2dpu + if (!strcasecmp(com, "pu")) + { // pu , 2dpu DY = 1; - if (!strcasecmp(com, "pd")) // pd , 2dpd + } + if (!strcasecmp(com, "pd")) + { // pd , 2dpd DY = -1; - if (!strcasecmp(com, "pl")) // pl , 2dpl + } + if (!strcasecmp(com, "pl")) + { // pl , 2dpl DX = -1; - if (!strcasecmp(com, "pr")) // pr , 2dpr + } + if (!strcasecmp(com, "pr")) + { // pr , 2dpr DX = 1; + } for (int id = start; id <= end; id++) { @@ -600,12 +676,16 @@ static int ptv(Draw_Interpretor&, int n, const char** a) int start = 0; int end = MAXVIEW - 1; if (n < 4) + { return 1; + } if (n >= 5) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; X = Draw::Atof(a[2]); Y = Draw::Atof(a[3]); @@ -641,12 +721,16 @@ static int dptv(Draw_Interpretor&, int n, const char** a) int start = 0; int end = MAXVIEW - 1; if (n < 4) + { return 1; + } if (n >= 5) { int anid = ViewId(a[1]); if (anid < 0) + { return 1; + } start = end = anid; DX = Draw::Atof(a[2]); DY = Draw::Atof(a[3]); @@ -721,7 +805,9 @@ static int hardcopy(Draw_Interpretor&, int n, const char** a) { iview = ViewId(a[2]); if (iview < 0) + { return 1; + } if (n >= 4) { if (!strcmp(a[3], "a7")) @@ -884,7 +970,9 @@ extern void Draw_RepaintNowIfNecessary(); static int xwd(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } // enforce repaint if necessary Draw_RepaintNowIfNecessary(); @@ -897,7 +985,9 @@ static int xwd(Draw_Interpretor&, int n, const char** a) file = a[2]; } if (!dout.SaveView(id, file)) + { return 1; + } return 0; } @@ -971,7 +1061,9 @@ static int dtext(Draw_Interpretor& di, int n, const char** a) di << "Pick position with button 1, other button escape\n"; dout.Select(id, X, Y, b); if (b != 1) + { return 0; + } double z = dout.Zoom(id); P.SetCoord((double)X / z, (double)Y / z, 0); gp_Trsf T; @@ -986,7 +1078,9 @@ static int dtext(Draw_Interpretor& di, int n, const char** a) P.SetCoord(Draw::Atof(a[1]), Draw::Atof(a[2]), is3d ? Draw::Atof(a[3]) : 0); } else + { return 0; + } if (is3d) { @@ -1005,7 +1099,9 @@ void Draw::GraphicCommands(Draw_Interpretor& theCommands) { static bool Done = false; if (Done) + { return; + } Done = true; const char* g = "DRAW Graphic Commands"; diff --git a/src/Draw/TKDraw/Draw/Draw_Grid.cxx b/src/Draw/TKDraw/Draw/Draw_Grid.cxx index b48cc410d4..ea776cee94 100644 --- a/src/Draw/TKDraw/Draw/Draw_Grid.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Grid.cxx @@ -23,13 +23,15 @@ #include #include +#ifdef _WIN32 +extern Draw_Viewer dout; +#endif + IMPLEMENT_STANDARD_RTTIEXT(Draw_Grid, Draw_Drawable3D) static double MinimumStep = 1.e-3; static double Ratio = 200.0; -extern Draw_Viewer dout; - //================================================================================================= Draw_Grid::Draw_Grid() @@ -58,7 +60,9 @@ void Draw_Grid::Steps(const double StepX, const double StepY, const double StepZ void Draw_Grid::DrawOn(Draw_Display& Out) const { if (!myIsActive) + { return; + } int xmin, xmax, ymin, ymax; int IndexX, IndexY; @@ -74,7 +78,9 @@ void Draw_Grid::DrawOn(Draw_Display& Out) const IdtView = Out.ViewId(); if (!dout.HasView(IdtView)) + { return; + } Type = dout.GetType(IdtView); switch (*(Type + 1)) { diff --git a/src/Draw/TKDraw/Draw/Draw_Interpretor.cxx b/src/Draw/TKDraw/Draw/Draw_Interpretor.cxx index f9360529b2..b27afe7ff4 100644 --- a/src/Draw/TKDraw/Draw/Draw_Interpretor.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Interpretor.cxx @@ -57,8 +57,10 @@ namespace void dumpArgs(Standard_OStream& os, int argc, const char* argv[]) { for (int i = 0; i < argc; i++) + { os << argv[i] << " "; - os << std::endl; + } + os << '\n'; } void flush_standard_streams() @@ -96,7 +98,9 @@ int capture_start(int theFDStd, int theFDLog) void capture_end(int theFDStd, int& theFDSave) { if (theFDSave < 0) + { return; + } // restore normal descriptors of console stream if (dup2(theFDSave, theFDStd) < 0) @@ -138,7 +142,9 @@ static int CommandCmd(ClientData theClientData, Tcl_Interp* interp, int argc, co } if (doEcho || doLog) + { dumpArgs(std::cout, argc, argv); + } // run command try @@ -218,7 +224,7 @@ static int CommandCmd(ClientData theClientData, Tcl_Interp* interp, int argc, co const char* aResultStr = Tcl_GetStringResult(interp); if (aResultStr != nullptr && aResultStr[0] != '\0') { - std::cout << aResultStr << std::endl; + std::cout << aResultStr << '\n'; } } @@ -275,7 +281,9 @@ Draw_Interpretor::Draw_Interpretor(const Draw_PInterp& theInterp) void Draw_Interpretor::Init() { if (isAllocated) + { Tcl_DeleteInterp(myInterp); + } isAllocated = true; myInterp = Tcl_CreateInterp(); } @@ -520,7 +528,9 @@ Draw_PInterp Draw_Interpretor::Interp() const void Draw_Interpretor::Set(const Draw_PInterp& PIntrp) { if (isAllocated) + { Tcl_DeleteInterp(myInterp); + } isAllocated = false; myInterp = PIntrp; } @@ -530,7 +540,9 @@ void Draw_Interpretor::Set(const Draw_PInterp& PIntrp) void Draw_Interpretor::SetDoLog(bool doLog) { if (myDoLog == doLog) + { return; + } // create log file if not opened yet if (doLog && myFDLog < 0) @@ -579,7 +591,9 @@ bool Draw_Interpretor::GetDoEcho() const void Draw_Interpretor::ResetLog() { if (myFDLog < 0) + { return; + } // flush cerr and cout, for the case if they are bound to the log flush_standard_streams(); @@ -599,7 +613,9 @@ void Draw_Interpretor::ResetLog() void Draw_Interpretor::AddLog(const char* const theStr) { if (myFDLog < 0 || !theStr || !theStr[0]) + { return; + } // flush cerr and cout, for the case if they are bound to the log flush_standard_streams(); @@ -615,7 +631,9 @@ TCollection_AsciiString Draw_Interpretor::GetLog() { TCollection_AsciiString aLog; if (myFDLog < 0) + { return aLog; + } // flush cerr and cout flush_standard_streams(); diff --git a/src/Draw/TKDraw/Draw/Draw_Marker3D.cxx b/src/Draw/TKDraw/Draw/Draw_Marker3D.cxx index 5505430048..d149eb5330 100644 --- a/src/Draw/TKDraw/Draw/Draw_Marker3D.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Marker3D.cxx @@ -57,9 +57,13 @@ void Draw_Marker3D::DrawOn(Draw_Display& D) const { D.SetColor(myCol); if (myIsRSiz) + { D.DrawMarker(myPos, myTyp, myRSiz); + } else + { D.DrawMarker(myPos, myTyp, mySiz); + } } //================================================================================================= diff --git a/src/Draw/TKDraw/Draw/Draw_MessageCommands.cxx b/src/Draw/TKDraw/Draw/Draw_MessageCommands.cxx index 51ec89e88e..c11ee932c9 100644 --- a/src/Draw/TKDraw/Draw/Draw_MessageCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_MessageCommands.cxx @@ -107,7 +107,7 @@ static int PrintMessenger(Draw_Interpretor& theDI, int, const char**) Standard_SStream aSStream; aMessenger->DumpJson(aSStream); theDI << aSStream; - std::cout << aSStream.str() << std::endl; + std::cout << aSStream.str() << '\n'; return 0; } @@ -321,7 +321,9 @@ void Draw::MessageCommands(Draw_Interpretor& theCommands) { static bool Done = false; if (Done) + { return; + } Done = true; const char* group = "DRAW Message Commands"; diff --git a/src/Draw/TKDraw/Draw/Draw_PloadCommands.cxx b/src/Draw/TKDraw/Draw/Draw_PloadCommands.cxx index 74ea2013a7..d5cffd8ded 100644 --- a/src/Draw/TKDraw/Draw/Draw_PloadCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_PloadCommands.cxx @@ -275,7 +275,9 @@ void Draw::PloadCommands(Draw_Interpretor& theCommands) { static bool Done = false; if (Done) + { return; + } Done = true; const char* g = "Draw Plugin"; diff --git a/src/Draw/TKDraw/Draw/Draw_ProgressIndicator.cxx b/src/Draw/TKDraw/Draw/Draw_ProgressIndicator.cxx index 56740776ac..93fd835ab5 100644 --- a/src/Draw/TKDraw/Draw/Draw_ProgressIndicator.cxx +++ b/src/Draw/TKDraw/Draw/Draw_ProgressIndicator.cxx @@ -75,7 +75,9 @@ void Draw_ProgressIndicator::Reset() void Draw_ProgressIndicator::Show(const Message_ProgressScope& theScope, const bool force) { if (!myGraphMode && !myTclMode && !myConsoleMode) + { return; + } // remember time of the first call to Show as process start time if (!myStartTime) @@ -93,7 +95,9 @@ void Draw_ProgressIndicator::Show(const Message_ProgressScope& theScope, const b double aPosition = GetPosition(); if (!force && (1. - aPosition) > Precision::Confusion() && std::abs(aPosition - myLastPosition) < myUpdateThreshold) + { return; // return if update interval has not elapsed + } myLastPosition = aPosition; @@ -104,12 +108,16 @@ void Draw_ProgressIndicator::Show(const Message_ProgressScope& theScope, const b aText << "Progress: " << 100. * GetPosition() << "%"; NCollection_List aScopes; for (const Message_ProgressScope* aPS = &theScope; aPS; aPS = aPS->Parent()) + { aScopes.Prepend(aPS); + } for (NCollection_List::Iterator it(aScopes); it.More(); it.Next()) { const Message_ProgressScope* aPS = it.Value(); if (!aPS->Name()) + { continue; // skip unnamed scopes + } aText << " " << aPS->Name() << ": "; // print progress info differently for finite and infinite scopes diff --git a/src/Draw/TKDraw/Draw/Draw_UnitCommands.cxx b/src/Draw/TKDraw/Draw/Draw_UnitCommands.cxx index 874730573a..8d89589c47 100644 --- a/src/Draw/TKDraw/Draw/Draw_UnitCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_UnitCommands.cxx @@ -36,7 +36,9 @@ static int parsing(Draw_Interpretor& di, int argc, const char** argv) TCollection_AsciiString aStrTok(argv[1]); int nbIter = 1; if (argc > 2) + { nbIter = Draw::Atoi(argv[2]); + } UnitsAPI::SetLocalSystem(); occ::handle atoken; Units_UnitSentence aUnitSent(aStrTok.ToCString()); @@ -118,7 +120,9 @@ static int unit(Draw_Interpretor& di, int n, const char** a) return 0; } else + { return 1; + } } //================================================================================================= @@ -127,7 +131,9 @@ void Draw::UnitCommands(Draw_Interpretor& theCommands) { static bool Done = false; if (Done) + { return; + } Done = true; const char* g = "DRAW Unit Commands"; diff --git a/src/Draw/TKDraw/Draw/Draw_VariableCommands.cxx b/src/Draw/TKDraw/Draw/Draw_VariableCommands.cxx index 856ee85413..0a5131d06d 100644 --- a/src/Draw/TKDraw/Draw/Draw_VariableCommands.cxx +++ b/src/Draw/TKDraw/Draw/Draw_VariableCommands.cxx @@ -187,7 +187,9 @@ static int restore(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVe static int display(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { return 1; + } else { for (int i = 1; i < n; i++) @@ -238,7 +240,9 @@ static int erase(Draw_Interpretor& di, int n, const char** a) if (D.IsNull()) { if ((a[i][0] == '.') && (a[i][1] == '\0')) - std::cout << "Missed !!!" << std::endl; + { + std::cout << "Missed !!!" << '\n'; + } return 0; } } @@ -263,17 +267,27 @@ static int erase(Draw_Interpretor& di, int n, const char** a) // effacement de toutes les variables int erasemode = 1; if (a[0][0] == '2') + { erasemode = 2; + } if (a[0][0] == 'c') + { erasemode = 3; + } // effacement des graphiques non variables if (erasemode == 2) + { dout.Clear2D(); + } else if (erasemode == 3) + { dout.Clear3D(); + } else + { dout.Clear(); + } // affichage pour donly if (donly) @@ -287,7 +301,9 @@ static int erase(Draw_Interpretor& di, int n, const char** a) { dout << D; if (!draw_erase_mute) + { di << a[i] << " "; + } } } } @@ -295,7 +311,9 @@ static int erase(Draw_Interpretor& di, int n, const char** a) // afficahge des proteges for (i = 1; i <= prot.Length(); i++) + { dout << prot(i); + } } else { @@ -308,7 +326,9 @@ static int erase(Draw_Interpretor& di, int n, const char** a) { dout.RemoveDrawable(D); if (!draw_erase_mute) + { di << D->Name() << " "; + } } } } @@ -329,7 +349,9 @@ static int erase(Draw_Interpretor& di, int n, const char** a) static int draw(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } int id = Draw::Atoi(a[1]); if (!dout.HasView(id)) { @@ -344,7 +366,9 @@ static int draw(Draw_Interpretor&, int n, const char** a) { occ::handle D = Draw::Get(a[i]); if (!D.IsNull()) + { D->DrawOn(d); + } } d.Flush(); return 0; @@ -357,7 +381,9 @@ static int draw(Draw_Interpretor&, int n, const char** a) static int protect(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { return 1; + } bool prot = *a[0] != 'u'; for (int i = 1; i < n; i++) { @@ -378,14 +404,22 @@ static int protect(Draw_Interpretor& di, int n, const char** a) static int autodisplay(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { autodisp = !autodisp; + } else + { autodisp = !(!strcasecmp(a[1], "0")); + } if (autodisp) + { di << "1"; + } else + { di << "0"; + } return 0; } @@ -397,7 +431,9 @@ static int autodisplay(Draw_Interpretor& di, int n, const char** a) static int whatis(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { return 1; + } for (int i = 1; i < n; i++) { occ::handle D = Draw::Get(a[i]); @@ -416,7 +452,9 @@ static int whatis(Draw_Interpretor& di, int n, const char** a) static int value(Draw_Interpretor& di, int n, const char** a) { if (n != 2) + { return 1; + } di << Draw::Atof(a[1]); return 0; @@ -457,7 +495,9 @@ static int dname(Draw_Interpretor& di, int n, const char** a) static int dump(Draw_Interpretor& DI, int n, const char** a) { if (n < 2) + { return 1; + } int i; for (i = 1; i < n; i++) { @@ -481,22 +521,30 @@ static int dump(Draw_Interpretor& DI, int n, const char** a) static int copy(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } bool cop = !strcasecmp(a[0], "copy"); occ::handle D; for (int i = 1; i < n; i += 2) { if (i + 1 >= n) + { return 0; + } D = Draw::Get(a[i]); if (!D.IsNull()) { if (cop) + { D = D->Copy(); + } else + { // clear old name Draw::Set(a[i], occ::handle()); + } Draw::Set(a[i + 1], D); } @@ -509,10 +557,14 @@ static int copy(Draw_Interpretor&, int n, const char** a) static int repaintall(Draw_Interpretor&, int, const char**) { if (repaint2d) + { dout.Repaint2D(); + } repaint2d = false; if (repaint3d) + { dout.Repaint3D(); + } repaint3d = false; dout.Flush(); return 0; @@ -523,14 +575,18 @@ static int repaintall(Draw_Interpretor&, int, const char**) static int set(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } int i = 1; double val = 0; for (i = 1; i < n; i += 2) { val = 0; if (i + 1 < n) + { val = Draw::Atof(a[i + 1]); + } Draw::Set(a[i], val); } di << val; @@ -554,7 +610,9 @@ static int dsetenv(Draw_Interpretor& /*di*/, int argc, const char** argv) env.Build(); } else + { env.Remove(); + } return env.Failed(); } @@ -578,12 +636,18 @@ static int dgetenv(Draw_Interpretor& di, int argc, const char** argv) static int isdraw(Draw_Interpretor& di, int n, const char** a) { if (n != 2) + { return 1; + } occ::handle D = Draw::Get(a[1]); if (D.IsNull()) + { di << "0"; + } else + { di << "1"; + } return 0; } @@ -592,16 +656,24 @@ static int isdraw(Draw_Interpretor& di, int n, const char** a) int isprot(Draw_Interpretor& di, int n, const char** a) { if (n != 2) + { return 1; + } occ::handle D = Draw::Get(a[1]); if (D.IsNull()) + { di << "0"; + } else { if (D->Protected()) + { di << "1"; + } else + { di << "0"; + } } return 0; } @@ -611,12 +683,16 @@ int isprot(Draw_Interpretor& di, int n, const char** a) static int pick(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } int id; int X, Y, b; bool wait = (n == 6); if (!wait) + { id = Draw::Atoi(a[1]); + } dout.Select(id, X, Y, b, wait); double z = dout.Zoom(id); gp_Pnt P((double)X / z, (double)Y / z, 0); @@ -637,7 +713,9 @@ static int pick(Draw_Interpretor&, int n, const char** a) static int lastrep(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } Draw::Set(a[1], p_id); if (n == 5) @@ -703,9 +781,13 @@ static char* tracevar(ClientData CD, Tcl_Interp*, const char* name, const char*, { dout.RemoveDrawable(D); if (D->Is3D()) + { repaint3d = true; + } else + { repaint2d = true; + } } Tcl_UntraceVar(aCommands.Interp(), name, TCL_TRACE_UNSETS | TCL_TRACE_WRITES, tracevar, CD); Draw_changeDrawables().Remove(D); @@ -725,7 +807,9 @@ void Draw::Set(const char* const name, const occ::handle& D, co { dout.RemoveDrawable(D); if (displ) + { dout << D; + } } } else @@ -741,7 +825,7 @@ void Draw::Set(const char* const name, const occ::handle& D, co { if (Draw::Drawables().Contains(anOldD) && anOldD->Protected()) { - std::cout << "variable is protected" << std::endl; + std::cout << "variable is protected" << '\n'; return; } anOldD.Nullify(); @@ -763,10 +847,14 @@ void Draw::Set(const char* const name, const occ::handle& D, co if (displ) { if (!D->Visible()) + { dout << D; + } } else if (D->Visible()) + { dout.RemoveDrawable(D); + } } } } @@ -806,7 +894,7 @@ occ::handle Draw::getDrawable(const char*& theName, bool theToA return occ::handle(); } - std::cout << "Pick an object" << std::endl; + std::cout << "Pick an object" << '\n'; occ::handle aDrawable; dout.Select(p_id, p_X, p_Y, p_b); dout.Pick(p_id, p_X, p_Y, 5, aDrawable, 0); @@ -856,19 +944,33 @@ static int trigo(Draw_Interpretor& di, int, const char** a) double x = Draw::Atof(a[1]); if (!strcasecmp(a[0], "cos")) + { di << std::cos(x); + } else if (!strcasecmp(a[0], "sin")) + { di << std::sin(x); + } else if (!strcasecmp(a[0], "tan")) + { di << std::tan(x); + } else if (!strcasecmp(a[0], "sqrt")) + { di << std::sqrt(x); + } else if (!strcasecmp(a[0], "acos")) + { di << std::acos(x); + } else if (!strcasecmp(a[0], "asin")) + { di << std::asin(x); + } else if (!strcasecmp(a[0], "atan2")) + { di << std::atan2(x, Draw::Atof(a[2])); + } return 0; } @@ -906,7 +1008,7 @@ static double ParseValue(char*& theName) x = Parse(theName); if (*theName != ')') { - std::cout << "Mismatched parenthesis" << std::endl; + std::cout << "Mismatched parenthesis" << '\n'; } ++theName; break; @@ -981,7 +1083,7 @@ static double ParseValue(char*& theName) } if (pc > 0) { - std::cout << "Unclosed parenthesis" << std::endl; + std::cout << "Unclosed parenthesis" << '\n'; x = 0; } else @@ -1030,7 +1132,7 @@ static double ParseValue(char*& theName) } if (aCommands.Eval(theName) != 0) { - std::cout << "Call of function " << theName << " failed" << std::endl; + std::cout << "Call of function " << theName << " failed" << '\n'; x = 0; } else @@ -1071,7 +1173,9 @@ static double ParseFactor(char*& name) { char c = *name; if (c == '\0') + { return x; + } name++; switch (c) { @@ -1099,7 +1203,9 @@ static double Parse(char*& name) { char c = *name; if (c == '\0') + { return x; + } name++; switch (c) { @@ -1130,9 +1236,13 @@ double Draw::Atof(const char* const theName) Draw_ParseFailed = false; double x = Parse(n); while ((*n == ' ') || (*n == '\t')) + { n++; + } if (*n) + { Draw_ParseFailed = true; + } return x; } @@ -1208,9 +1318,13 @@ static void before() void Draw_RepaintNowIfNecessary() { if (repaint2d) + { dout.Repaint2D(); + } if (repaint3d) + { dout.Repaint3D(); + } repaint2d = false; repaint3d = false; } @@ -1229,7 +1343,9 @@ void Draw::VariableCommands(Draw_Interpretor& theCommandsArg) { static bool Done = false; if (Done) + { return; + } Done = true; // set up start and stop command diff --git a/src/Draw/TKDraw/Draw/Draw_Viewer.cxx b/src/Draw/TKDraw/Draw/Draw_Viewer.cxx index 438a1ec162..ffc617c677 100644 --- a/src/Draw/TKDraw/Draw/Draw_Viewer.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Viewer.cxx @@ -64,10 +64,14 @@ static DrawingMode CurrentMode = DRAW; Draw_Viewer::Draw_Viewer() { if (Draw_Batch) + { return; + } int i; for (i = 0; i < MAXVIEW; i++) + { myViews[i] = nullptr; + } for (i = 0; i < MAXCOLOR; i++) { ps_width[i] = 1; @@ -80,7 +84,9 @@ Draw_Viewer::Draw_Viewer() bool Draw_Viewer::DefineColor(const int i, const char* colname) { if (Draw_Batch) + { return true; + } return Draw_Window::DefineColor(i, colname); } @@ -94,7 +100,9 @@ void Draw_Viewer::MakeView(const int id, const int H) { if (Draw_Batch) + { return; + } if (id < MAXVIEW) { @@ -106,7 +114,9 @@ void Draw_Viewer::MakeView(const int id, myViews[id]->SetDy(-H / 2); if (!myViews[id]->Init(typ)) + { DeleteView(id); + } RepaintView(id); } @@ -149,7 +159,9 @@ void Draw_Viewer::MakeView(const int id, void Draw_Viewer::MakeView(const int id, const char* typ, const char* window) { if (Draw_Batch) + { return; + } if (id < MAXVIEW) { @@ -160,7 +172,9 @@ void Draw_Viewer::MakeView(const int id, const char* typ, const char* window) myViews[id]->SetDy(-myViews[id]->HeightWin() / 2); if (!myViews[id]->Init(typ)) + { DeleteView(id); + } RepaintView(id); } @@ -171,9 +185,13 @@ void Draw_Viewer::MakeView(const int id, const char* typ, const char* window) void Draw_Viewer::SetTitle(const int id, const char* name) { if (Draw_Batch) + { return; + } if (myViews[id]) + { myViews[id]->SetTitle(name); + } } //================================================================================================= @@ -181,7 +199,9 @@ void Draw_Viewer::SetTitle(const int id, const char* name) void Draw_Viewer::ResetView(const int id) { if (Draw_Batch) + { return; + } if (myViews[id]) { myViews[id]->Init(myViews[id]->Type()); @@ -194,7 +214,9 @@ void Draw_Viewer::ResetView(const int id) void Draw_Viewer::SetZoom(const int id, const double z) { if (Draw_Batch) + { return; + } Draw_View* aView = myViews[id]; if (aView) @@ -220,7 +242,9 @@ void Draw_Viewer::SetZoom(const int id, const double z) void Draw_Viewer::RotateView(const int id, const gp_Dir2d& D, const double A) { if (Draw_Batch) + { return; + } if (myViews[id]) { gp_Trsf T = myViews[id]->GetMatrix(); @@ -239,7 +263,9 @@ void Draw_Viewer::RotateView(const int id, const gp_Dir2d& D, const double A) void Draw_Viewer::RotateView(const int id, const gp_Pnt& P, const gp_Dir& D, const double A) { if (Draw_Batch) + { return; + } if (myViews[id]) { gp_Trsf T; @@ -253,9 +279,13 @@ void Draw_Viewer::RotateView(const int id, const gp_Pnt& P, const gp_Dir& D, con void Draw_Viewer::SetFocal(const int id, const double F) { if (Draw_Batch) + { return; + } if (myViews[id]) + { myViews[id]->SetFocalDistance(F); + } } //================================================================================================= @@ -263,11 +293,17 @@ void Draw_Viewer::SetFocal(const int id, const double F) char* Draw_Viewer::GetType(const int id) const { if (Draw_Batch) + { return blank; + } if (myViews[id]) + { return const_cast(myViews[id]->Type()); + } else + { return blank; + } } //================================================================================================= @@ -275,11 +311,17 @@ char* Draw_Viewer::GetType(const int id) const double Draw_Viewer::Zoom(const int id) const { if (Draw_Batch) + { return false; + } if (myViews[id]) + { return myViews[id]->GetZoom(); + } else + { return 0.0; + } } //================================================================================================= @@ -287,11 +329,17 @@ double Draw_Viewer::Zoom(const int id) const double Draw_Viewer::Focal(const int id) const { if (Draw_Batch) + { return 1.; + } if (myViews[id]) + { return myViews[id]->GetFocalDistance(); + } else + { return 0; + } } //================================================================================================= @@ -299,9 +347,13 @@ double Draw_Viewer::Focal(const int id) const void Draw_Viewer::GetTrsf(const int id, gp_Trsf& T) const { if (Draw_Batch) + { return; + } if (myViews[id]) + { T = myViews[id]->GetMatrix(); + } } //================================================================================================= @@ -309,11 +361,17 @@ void Draw_Viewer::GetTrsf(const int id, gp_Trsf& T) const bool Draw_Viewer::Is3D(const int id) const { if (Draw_Batch) + { return false; + } if (myViews[id]) + { return !myViews[id]->Is2D(); + } else + { return false; + } } //================================================================================================= @@ -321,9 +379,13 @@ bool Draw_Viewer::Is3D(const int id) const void Draw_Viewer::SetTrsf(const int id, gp_Trsf& T) { if (Draw_Batch) + { return; + } if (myViews[id]) + { myViews[id]->SetMatrix(T); + } } //================================================================================================= @@ -331,7 +393,9 @@ void Draw_Viewer::SetTrsf(const int id, gp_Trsf& T) void Draw_Viewer::GetPosSize(const int id, int& X, int& Y, int& W, int& H) { if (Draw_Batch) + { return; + } if (myViews[id] != nullptr) { myViews[id]->GetPosition(X, Y); @@ -345,7 +409,9 @@ void Draw_Viewer::GetPosSize(const int id, int& X, int& Y, int& W, int& H) void Draw_Viewer::GetFrame(const int id, int& xminf, int& yminf, int& xmaxf, int& ymaxf) { if (Draw_Batch) + { return; + } if (myViews[id]) { int X, Y, H, W; @@ -362,7 +428,9 @@ void Draw_Viewer::GetFrame(const int id, int& xminf, int& yminf, int& xmaxf, int void Draw_Viewer::FitView(const int id, const int frame) { if (Draw_Batch) + { return; + } if (myViews[id]) { @@ -374,7 +442,9 @@ void Draw_Viewer::FitView(const int id, const int frame) if (myViews[i]) { if (myViews[i]->Is2D() == is2d) + { ++nbviews; + } } } bool only = (nbviews == 1); @@ -384,7 +454,9 @@ void Draw_Viewer::FitView(const int id, const int frame) // compute the min max int n = myDrawables.Length(); if (n == 0) + { return; + } // Draw_Display DF; curview = myViews[id]; double umin, umax, vmin, vmax; @@ -399,16 +471,26 @@ void Draw_Viewer::FitView(const int id, const int frame) { // if this is not the only view recompute... if (!only) + { DrawOnView(id, myDrawables(i)); + } myDrawables(i)->Bounds(u1, u2, v1, v2); if (u1 < umin) + { umin = u1; + } if (u2 > umax) + { umax = u2; + } if (v1 < vmin) + { vmin = v1; + } if (v2 > vmax) + { vmax = v2; + } } } double z; @@ -419,9 +501,13 @@ void Draw_Viewer::FitView(const int id, const int frame) if ((umax - umin) < 1.e-6) { if ((vmax - vmin) < 1.e-6) + { return; + } else + { z = ((double)(H - 2 * frame)) / (vmax - vmin); + } } else { @@ -430,7 +516,9 @@ void Draw_Viewer::FitView(const int id, const int frame) { double z2 = ((double)(H - 2 * frame)) / (vmax - vmin); if (z2 < z) + { z = z2; + } } } curview->SetZoom(z); @@ -444,7 +532,9 @@ void Draw_Viewer::FitView(const int id, const int frame) void Draw_Viewer::PanView(const int id, const int DX, const int DY) { if (Draw_Batch) + { return; + } if (myViews[id]) { myViews[id]->SetDx(myViews[id]->GetDx() + DX); @@ -457,7 +547,9 @@ void Draw_Viewer::PanView(const int id, const int DX, const int DY) void Draw_Viewer::SetPan(const int id, const int DX, const int DY) { if (Draw_Batch) + { return; + } if (myViews[id]) { myViews[id]->SetDx(DX); @@ -470,7 +562,9 @@ void Draw_Viewer::SetPan(const int id, const int DX, const int DY) void Draw_Viewer::GetPan(const int id, int& DX, int& DY) { if (Draw_Batch) + { return; + } if (myViews[id]) { DX = myViews[id]->GetDx(); @@ -483,9 +577,13 @@ void Draw_Viewer::GetPan(const int id, int& DX, int& DY) bool Draw_Viewer::HasView(const int id) const { if (Draw_Batch) + { return false; + } if ((id < 0) || id >= MAXVIEW) + { return false; + } return myViews[id] != nullptr; } @@ -494,9 +592,13 @@ bool Draw_Viewer::HasView(const int id) const void Draw_Viewer::DisplayView(const int id) const { if (Draw_Batch) + { return; + } if (myViews[id]) + { myViews[id]->DisplayWindow(); + } } //================================================================================================= @@ -504,7 +606,9 @@ void Draw_Viewer::DisplayView(const int id) const void Draw_Viewer::HideView(const int id) const { if (Draw_Batch) + { return; + } if (myViews[id]) { // @@ -516,9 +620,13 @@ void Draw_Viewer::HideView(const int id) const void Draw_Viewer::ClearView(const int id) const { if (Draw_Batch) + { return; + } if (myViews[id]) + { myViews[id]->Clear(); + } } //================================================================================================= @@ -526,7 +634,9 @@ void Draw_Viewer::ClearView(const int id) const void Draw_Viewer::RemoveView(const int id) { if (Draw_Batch) + { return; + } delete myViews[id]; myViews[id] = nullptr; } @@ -536,13 +646,17 @@ void Draw_Viewer::RemoveView(const int id) void Draw_Viewer::RepaintView(const int id) const { if (Draw_Batch) + { return; + } if (myViews[id]) { ClearView(id); int n = myDrawables.Length(); for (int i = 1; i <= n; i++) + { DrawOnView(id, myDrawables(i)); + } } } @@ -584,7 +698,9 @@ void Draw_Viewer::UpdateView(const int id, const bool forced) const void Draw_Viewer::ConfigView(const int id) const { if (Draw_Batch) + { return; + } if (myViews[id]) { myViews[id]->SetDx(myViews[id]->WidthWin() / 2); @@ -606,7 +722,9 @@ void Draw_Viewer::PostScriptView(const int id, std::ostream& sortie) const { if (Draw_Batch) + { return; + } if (myViews[id]) { ps_vx = VXmin; @@ -618,21 +736,29 @@ void Draw_Viewer::PostScriptView(const int id, ps_stream = &sortie; int n = myDrawables.Length(); if (n == 0) + { return; + } CurrentMode = POSTSCRIPT; Draw_Display DF = MakeDisplay(id); bool view2d = myViews[id]->Is2D(); for (int i = 1; i <= n; i++) + { if (myDrawables(i)->Is3D()) { if (!view2d) + { myDrawables(i)->DrawOn(DF); + } } else { if (view2d) + { myDrawables(i)->DrawOn(DF); + } } + } sortie << "stroke\n"; CurrentMode = DRAW; } @@ -643,9 +769,13 @@ void Draw_Viewer::PostScriptView(const int id, void Draw_Viewer::PostColor(const int icol, const int width, const double gray) { if (Draw_Batch) + { return; + } if ((icol < 0) || (icol >= MAXCOLOR)) + { return; + } ps_width[icol] = width; ps_gray[icol] = gray; } @@ -675,9 +805,13 @@ bool Draw_Viewer::SaveView(const int id, const char* filename) void Draw_Viewer::RepaintAll() const { if (Draw_Batch) + { return; + } for (int id = 0; id < MAXVIEW; id++) + { RepaintView(id); + } } //================================================================================================= @@ -685,13 +819,19 @@ void Draw_Viewer::RepaintAll() const void Draw_Viewer::Repaint2D() const { if (Draw_Batch) + { return; + } for (int id = 0; id < MAXVIEW; id++) + { if (myViews[id]) { if (myViews[id]->Is2D()) + { RepaintView(id); + } } + } } //================================================================================================= @@ -699,13 +839,19 @@ void Draw_Viewer::Repaint2D() const void Draw_Viewer::Repaint3D() const { if (Draw_Batch) + { return; + } for (int id = 0; id < MAXVIEW; id++) + { if (myViews[id]) { if (!myViews[id]->Is2D()) + { RepaintView(id); + } } + } } //================================================================================================= @@ -713,7 +859,9 @@ void Draw_Viewer::Repaint3D() const void Draw_Viewer::DeleteView(const int id) { if (Draw_Batch) + { return; + } delete myViews[id]; myViews[id] = nullptr; } @@ -723,12 +871,18 @@ void Draw_Viewer::DeleteView(const int id) void Draw_Viewer::Clear() { if (Draw_Batch) + { return; + } for (int i = 1; i <= myDrawables.Length(); i++) + { myDrawables(i)->Visible(false); + } myDrawables.Clear(); for (int id = 0; id < MAXVIEW; id++) + { ClearView(id); + } } //================================================================================================= @@ -736,12 +890,16 @@ void Draw_Viewer::Clear() void Draw_Viewer::Clear2D() { if (Draw_Batch) + { return; + } int i = 1; while (i <= myDrawables.Length()) { if (myDrawables(i)->Is3D()) + { i++; + } else { myDrawables(i)->Visible(false); @@ -753,7 +911,9 @@ void Draw_Viewer::Clear2D() if (myViews[id]) { if (myViews[id]->Is2D()) + { ClearView(id); + } } } } @@ -763,7 +923,9 @@ void Draw_Viewer::Clear2D() void Draw_Viewer::Clear3D() { if (Draw_Batch) + { return; + } int i = 1; while (i <= myDrawables.Length()) { @@ -773,14 +935,18 @@ void Draw_Viewer::Clear3D() myDrawables.Remove(i); } else + { i++; + } } for (int id = 0; id < MAXVIEW; id++) { if (myViews[id]) { if (!myViews[id]->Is2D()) + { ClearView(id); + } } } } @@ -790,7 +956,9 @@ void Draw_Viewer::Clear3D() void Draw_Viewer::Flush() { if (Draw_Batch) + { return; + } Draw_Window::Flush(); } @@ -799,7 +967,9 @@ void Draw_Viewer::Flush() void Draw_Viewer::DrawOnView(const int id, const occ::handle& D) const { if (Draw_Batch) + { return; + } if (myViews[id]) { Draw_Display d = MakeDisplay(id); @@ -812,7 +982,9 @@ void Draw_Viewer::DrawOnView(const int id, const occ::handle& D { D->DrawOn(d); if (CurrentMode == DRAW) + { D->SetBounds(xmin, xmax, ymin, ymax); + } d.Flush(); } } @@ -825,7 +997,9 @@ void Draw_Viewer::HighlightOnView(const int id, const Draw_ColorKind C) const { if (Draw_Batch) + { return; + } highlight = true; highlightcol = C; DrawOnView(id, D); @@ -837,7 +1011,9 @@ void Draw_Viewer::HighlightOnView(const int id, void Draw_Viewer::AddDrawable(const occ::handle& D) { if (Draw_Batch) + { return; + } if (!D.IsNull() && !D->Visible()) { myDrawables.Append(D); @@ -850,7 +1026,9 @@ void Draw_Viewer::AddDrawable(const occ::handle& D) void Draw_Viewer::RemoveDrawable(const occ::handle& D) { if (Draw_Batch) + { return; + } if (!D.IsNull() && D->Visible()) { int index; @@ -1056,9 +1234,13 @@ int Draw_Viewer::Pick(const int id, const int first) const { if (Draw_Batch) + { return 0; + } if (myViews[id] == nullptr) + { return 0; + } // is this the only view in its category bool is2d = myViews[id]->Is2D(); @@ -1066,8 +1248,12 @@ int Draw_Viewer::Pick(const int id, for (i = 0; i < MAXVIEW; i++) { if (myViews[i]) + { if (myViews[i]->Is2D() == is2d) + { ++nbviews; + } + } } bool only = (nbviews == 1); @@ -1085,21 +1271,29 @@ int Draw_Viewer::Pick(const int id, { myDrawables(i)->Bounds(x1, x2, y1, y2); if ((xpick + Prec < x1) || (xpick - Prec > x2) || (ypick + Prec < y1) || (ypick - Prec > y2)) + { reject = true; + } } if (!reject) { DrawOnView(id, myDrawables(i)); if (found) + { break; + } } } CurrentMode = DRAW; found = false; if (i <= myDrawables.Length()) + { D = myDrawables(i); + } else + { i = 0; + } return i; } @@ -1108,7 +1302,9 @@ int Draw_Viewer::Pick(const int id, void Draw_Viewer::LastPick(gp_Pnt& P1, gp_Pnt& P2, double& Param) { if (Draw_Batch) + { return; + } P1 = lastPickP1; P2 = lastPickP2; Param = lastPickParam; @@ -1119,9 +1315,13 @@ void Draw_Viewer::LastPick(gp_Pnt& P1, gp_Pnt& P2, double& Param) Draw_Viewer::~Draw_Viewer() { if (Draw_Batch) + { return; + } for (int id = 0; id < MAXVIEW; id++) + { DeleteView(id); + } } //================================================================================================= @@ -1129,12 +1329,16 @@ Draw_Viewer::~Draw_Viewer() Draw_Viewer& Draw_Viewer::operator<<(const occ::handle& d3d) { if (Draw_Batch) + { return *this; + } if (!d3d.IsNull()) { AddDrawable(d3d); for (int id = 0; id < MAXVIEW; id++) + { DrawOnView(id, d3d); + } } return *this; } @@ -1153,9 +1357,13 @@ const NCollection_Sequence>& Draw_Viewer::GetDrawab void Draw_Flush() { if (Draw_Batch) + { return; + } if (highlight) + { curview->SetColor(highlightcol.ID()); + } curview->DrawSegments(segm, nbseg); nbseg = 0; } @@ -1165,9 +1373,13 @@ void Draw_Flush() void Draw_Display::SetColor(const Draw_Color& col) const { if (Draw_Batch) + { return; + } if (col.ID() == currentcolor.ID()) + { return; + } currentcolor = col; switch (CurrentMode) @@ -1193,7 +1405,9 @@ void Draw_Display::SetColor(const Draw_Color& col) const void Draw_Display::SetMode(const int M) const { if (Draw_Batch) + { return; + } switch (CurrentMode) { @@ -1213,7 +1427,9 @@ void Draw_Display::SetMode(const int M) const double Draw_Display::Zoom() const { if (Draw_Batch) + { return 1.; + } return curview->GetZoom(); } @@ -1222,7 +1438,9 @@ double Draw_Display::Zoom() const void Draw_Display::Flush() const { if (Draw_Batch) + { return; + } Draw_Flush(); } @@ -1234,18 +1452,28 @@ void Draw_Display::DrawString(const gp_Pnt2d& ppt, const double moveY) { if (Draw_Batch) + { return; + } if (ppt.X() > 1.e09 || ppt.X() < -1.e09) + { return; + } if (ppt.Y() > 1.e09 || ppt.Y() < -1.e09) + { return; + } gp_Pnt2d pt(ppt.X() * curview->GetZoom(), ppt.Y() * curview->GetZoom()); if (pt.X() > 1.e09 || pt.X() < -1.e09) + { return; + } if (pt.Y() > 1.e09 || pt.Y() < -1.e09) + { return; + } switch (CurrentMode) { @@ -1257,13 +1485,21 @@ void Draw_Display::DrawString(const gp_Pnt2d& ppt, if (Draw_Bounds) { if (pt.X() + moveX > xmax) + { xmax = pt.X(); + } if (pt.X() + moveX < xmin) + { xmin = pt.X(); + } if (-pt.Y() - moveY > ymax) + { ymax = -pt.Y(); + } if (-pt.Y() - moveY < ymin) + { ymin = -pt.Y(); + } } } break; @@ -1287,7 +1523,9 @@ void Draw_Display::DrawString(const gp_Pnt2d& ppt, void Draw_Display::DrawString(const gp_Pnt2d& ppt, const char* const S) { if (Draw_Batch) + { return; + } DrawString(ppt, S, 0.0, 0.0); } @@ -1299,7 +1537,9 @@ void Draw_Display::DrawString(const gp_Pnt& pt, const double moveY) { if (Draw_Batch) + { return; + } DrawString(Project(pt), S, moveX, moveY); } @@ -1308,7 +1548,9 @@ void Draw_Display::DrawString(const gp_Pnt& pt, void Draw_Display::DrawString(const gp_Pnt& pt, const char* const S) { if (Draw_Batch) + { return; + } DrawString(Project(pt), S, 0.0, 0.0); } @@ -1323,7 +1565,9 @@ static gp_Pnt PtPers; // current 3D point for Pers void Draw_Display::Project(const gp_Pnt& p, gp_Pnt2d& p2d) const { if (Draw_Batch) + { return; + } gp_Pnt pt = p; pt.Transform(curview->GetMatrix()); double xp, yp, zp; @@ -1342,7 +1586,9 @@ void Draw_Display::Project(const gp_Pnt& p, gp_Pnt2d& p2d) const Draw_Display::Draw_Display() { if (Draw_Batch) + { return; + } if (curview) { PtPers.SetCoord(0., 0., 0.); @@ -1356,7 +1602,9 @@ Draw_Display::Draw_Display() void Draw_Display::MoveTo(const gp_Pnt2d& pp) { if (Draw_Batch) + { return; + } const double aZoom = curview->GetZoom(); gp_Pnt2d pt(pp.X() * aZoom, pp.Y() * aZoom); switch (CurrentMode) @@ -1367,13 +1615,21 @@ void Draw_Display::MoveTo(const gp_Pnt2d& pp) if (Draw_Bounds) { if (pt.X() > xmax) + { xmax = pt.X(); + } if (pt.X() < xmin) + { xmin = pt.X(); + } if (pt.Y() > ymax) + { ymax = pt.Y(); + } if (pt.Y() < ymin) + { ymin = pt.Y(); + } } break; @@ -1442,7 +1698,9 @@ bool Trim(gp_Pnt2d& P1, gp_Pnt2d& P2, double x0, double y0, double x1, double y1 double dy = yb - ya; double dab = sqrt(dx * dx + dy * dy); if (dab < 1e-10) + { return (false); + } dx /= dab; dy /= dab; @@ -1460,7 +1718,9 @@ bool Trim(gp_Pnt2d& P1, gp_Pnt2d& P2, double x0, double y0, double x1, double y1 gp_Pnt2d MFen(mfenx, mfeny); if (MFen.SquareDistance(Pm) > d * d) + { return (false); + } double PmDistP1 = Pm.Distance(P1); double PmDistP2 = Pm.Distance(P2); @@ -1495,30 +1755,46 @@ bool Trim(gp_Pnt2d& P1, gp_Pnt2d& P2, double x0, double y0, double x1, double y1 return (true); } else + { return (false); + } } void Draw_Display::DrawTo(const gp_Pnt2d& pp2) { if (Draw_Batch) + { return; + } if (pp2.X() > 1.e09 || pp2.X() < -1.e09) + { return; + } if (pp2.Y() > 1.e09 || pp2.Y() < -1.e09) + { return; + } gp_Pnt2d p2(pp2.X() * curview->GetZoom(), pp2.Y() * curview->GetZoom()); if (p2.X() > 1.e09 || p2.X() < -1.e09) + { return; + } if (p2.Y() > 1.e09 || p2.Y() < -1.e09) + { return; + } gp_Pnt2d p1 = PtCur; if (p1.X() > 1.e09 || p1.X() < -1.e09) + { return; + } if (p1.Y() > 1.e09 || p1.Y() < -1.e09) + { return; + } PtCur = p2; @@ -1562,13 +1838,21 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) if (Draw_Bounds) { if (p2.X() > xmax) + { xmax = p2.X(); + } if (p2.X() < xmin) + { xmin = p2.X(); + } if (p2.Y() > ymax) + { ymax = p2.Y(); + } if (p2.Y() < ymin) + { ymin = p2.Y(); + } } } break; @@ -1581,13 +1865,21 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) int x2 = (int)p2.X(); int y2 = (int)p2.Y(); if ((x1 >= xpick + precpick) && (x2 >= xpick + precpick)) + { break; + } if ((x1 <= xpick - precpick) && (x2 <= xpick - precpick)) + { break; + } if ((y1 >= ypick + precpick) && (y2 >= ypick + precpick)) + { break; + } if ((y1 <= ypick - precpick) && (y2 <= ypick - precpick)) + { break; + } bool inside = true; if ((x1 > xpick + precpick) || (x2 > xpick + precpick)) @@ -1601,7 +1893,9 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) break; } else + { inside = false; + } } if ((x1 < xpick - precpick) || (x2 < xpick - precpick)) @@ -1615,7 +1909,9 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) break; } else + { inside = false; + } } if ((y1 > ypick + precpick) || (y2 > ypick + precpick)) @@ -1629,7 +1925,9 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) break; } else + { inside = false; + } } if ((y1 < ypick - precpick) || (y2 < ypick - precpick)) @@ -1643,7 +1941,9 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) break; } else + { inside = false; + } } found = found || inside; if (found) @@ -1651,16 +1951,24 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) if (std::abs(x2 - x1) > std::abs(y2 - y1)) { if (std::abs(x2 - x1) < 1e-5) + { lastPickParam = 0; + } else + { lastPickParam = (double)(xpick - x1) / (double)(x2 - x1); + } } else { if (std::abs(y2 - y1) < 1e-5) + { lastPickParam = 0; + } else + { lastPickParam = (double)(ypick - y1) / (double)(y2 - y1); + } } } } @@ -1680,13 +1988,19 @@ void Draw_Display::DrawTo(const gp_Pnt2d& pp2) void Draw_Display::MoveTo(const gp_Pnt& pt) { if (Draw_Batch) + { return; + } if (CurrentMode == PICK) { if (!found) + { lastPickP1 = pt; + } else + { return; + } } PtPers = pt; PtPers.Transform(curview->GetMatrix()); @@ -1710,9 +2024,13 @@ void Draw_Display::MoveTo(const gp_Pnt& pt) void Draw_Display::DrawTo(const gp_Pnt& pt) { if (Draw_Batch) + { return; + } if ((CurrentMode == PICK) && found) + { return; + } gp_Pnt pt2 = pt.Transformed(curview->GetMatrix()); double xp2 = pt2.X(); @@ -1754,9 +2072,13 @@ void Draw_Display::DrawTo(const gp_Pnt& pt) if (CurrentMode == PICK) { if (!found) + { lastPickP1 = pt; + } else + { lastPickP2 = pt; + } } } @@ -1765,7 +2087,9 @@ void Draw_Display::DrawTo(const gp_Pnt& pt) void Draw_Display::Draw(const gp_Pnt& p1, const gp_Pnt& p2) { if (Draw_Batch) + { return; + } MoveTo(p1); DrawTo(p2); } @@ -1775,7 +2099,9 @@ void Draw_Display::Draw(const gp_Pnt& p1, const gp_Pnt& p2) void Draw_Display::Draw(const gp_Pnt2d& p1, const gp_Pnt2d& p2) { if (Draw_Batch) + { return; + } MoveTo(p1); DrawTo(p2); } @@ -1785,7 +2111,9 @@ void Draw_Display::Draw(const gp_Pnt2d& p1, const gp_Pnt2d& p2) int Draw_Display::ViewId() const { if (Draw_Batch) + { return 0; + } return curviewId; } @@ -1794,6 +2122,8 @@ int Draw_Display::ViewId() const bool Draw_Display::HasPicked() const { if (Draw_Batch) + { return false; + } return found; } diff --git a/src/Draw/TKDraw/Draw/Draw_Window.cxx b/src/Draw/TKDraw/Draw/Draw_Window.cxx index 8ab8297564..d820d07e70 100644 --- a/src/Draw/TKDraw/Draw/Draw_Window.cxx +++ b/src/Draw/TKDraw/Draw/Draw_Window.cxx @@ -39,6 +39,10 @@ #include #endif +#ifdef _WIN32 +extern bool Draw_Batch; +#endif + #if defined(__EMSCRIPTEN__) #include @@ -115,7 +119,6 @@ static const int Draw_modeTab[16] = {R2_BLACK, R2_WHITE}; #endif -extern bool Draw_Batch; extern bool Draw_VirtualWindows; bool Draw_BlackBackGround = true; #if defined(_WIN32) @@ -205,7 +208,6 @@ static Tcl_DString Draw_TclLine; //! Forward declarations for procedures defined later in this file: static void StdinProc(ClientData theClientData, int theMask); -static void Prompt(Tcl_Interp* theInterp, int thePartial); //! Non-zero means standard input is a terminal-like device. //! Zero means it's a file. @@ -1306,7 +1308,7 @@ bool Init_Appli() catch (Standard_Failure const& theFail) { std::cout << "Cannot open display (" << theFail << "). Interpret commands in batch mode." - << std::endl; + << '\n'; return false; } } diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf.cxx index c9df5efd2a..110d7b585f 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf.cxx @@ -125,7 +125,9 @@ static occ::handle GetDrawable(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -136,7 +138,9 @@ static occ::handle GetSurface(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -147,7 +151,9 @@ static occ::handle GetBezierSurface(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -158,7 +164,9 @@ static occ::handle GetBSplineSurface(const char*& Nam occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -169,7 +177,9 @@ static occ::handle GetBezierCurve(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -180,7 +190,9 @@ static occ::handle GetBSplineCurve(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -191,7 +203,9 @@ static occ::handle GetBezierCurve2d(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -202,7 +216,9 @@ static occ::handle GetBSplineCurve2d(const char*& Nam occ::handle D = Draw::Get(Name); occ::handle Dr; if (!D.IsNull()) + { Dr = occ::down_cast(D); + } return Dr; } @@ -440,7 +456,9 @@ static int draw(Draw_Interpretor& di, int n, const char** a) { int mod = 0; if ((*a[n - 1] == 'U') || (*a[n - 1] == 'u')) + { mod = 1; + } aDrawable->SetDrawMode(mod); } else if (!strcmp(a[0], "discr")) @@ -463,7 +481,9 @@ static int draw(Draw_Interpretor& di, int n, const char** a) static int transform(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } gp_Trsf T; int i, last = n - 1; if (!strcmp(a[0], "pscale")) @@ -471,14 +491,18 @@ static int transform(Draw_Interpretor& di, int n, const char** a) double s = Draw::Atof(a[last]); last--; if (last < 4) + { return 1; + } gp_Pnt P(Draw::Atof(a[last - 2]), Draw::Atof(a[last - 1]), Draw::Atof(a[last])); T.SetScale(P, s); } else if (!strcmp(a[0] + 1, "mirror")) { if (last < 4) + { return 1; + } gp_Pnt P(Draw::Atof(a[last - 2]), Draw::Atof(a[last - 1]), Draw::Atof(a[last])); if (*a[0] == 'p') { @@ -488,7 +512,9 @@ static int transform(Draw_Interpretor& di, int n, const char** a) { last -= 3; if (last < 4) + { return 1; + } gp_Pnt O(Draw::Atof(a[last - 2]), Draw::Atof(a[last - 1]), Draw::Atof(a[last])); last -= 3; gp_Dir D(P.X(), P.Y(), P.Z()); @@ -507,7 +533,9 @@ static int transform(Draw_Interpretor& di, int n, const char** a) else if (!strcmp(a[0], "translate")) { if (last < 4) + { return 1; + } gp_Vec V(Draw::Atof(a[last - 2]), Draw::Atof(a[last - 1]), Draw::Atof(a[last])); last -= 3; T.SetTranslation(V); @@ -516,7 +544,9 @@ static int transform(Draw_Interpretor& di, int n, const char** a) else if (!strcmp(a[0], "rotate")) { if (last < 8) + { return 1; + } double ang = Draw::Atof(a[last]) * (M_PI / 180.0); last--; gp_Dir D(Draw::Atof(a[last - 2]), Draw::Atof(a[last - 1]), Draw::Atof(a[last])); @@ -553,7 +583,9 @@ static int transform(Draw_Interpretor& di, int n, const char** a) static int d2transform(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } gp_Trsf2d T; int i, last = n - 1; if (!strcmp(a[0], "2dpscale")) @@ -561,14 +593,18 @@ static int d2transform(Draw_Interpretor& di, int n, const char** a) double s = Draw::Atof(a[last]); last--; if (last < 3) + { return 1; + } gp_Pnt2d P(Draw::Atof(a[last - 1]), Draw::Atof(a[last])); T.SetScale(P, s); } else if ((!strcmp(a[0], "2dpmirror")) || (!strcmp(a[0], "2dlmirror"))) { if (last < 3) + { return 1; + } gp_Pnt2d P(Draw::Atof(a[last - 1]), Draw::Atof(a[last])); if (!strcmp(a[0], "2dpmirror")) { @@ -578,7 +614,9 @@ static int d2transform(Draw_Interpretor& di, int n, const char** a) { last -= 2; if (last < 3) + { return 1; + } gp_Pnt2d O(Draw::Atof(a[last - 1]), Draw::Atof(a[last])); last -= 2; gp_Dir2d D(P.X(), P.Y()); @@ -589,7 +627,9 @@ static int d2transform(Draw_Interpretor& di, int n, const char** a) else if (!strcmp(a[0], "2dtranslate")) { if (last < 3) + { return 1; + } gp_Vec2d V(Draw::Atof(a[last - 1]), Draw::Atof(a[last])); last -= 2; T.SetTranslation(V); @@ -598,7 +638,9 @@ static int d2transform(Draw_Interpretor& di, int n, const char** a) else if (!strcmp(a[0], "2drotate")) { if (last < 4) + { return 1; + } double ang = Draw::Atof(a[last]) * (M_PI / 180.0); last--; gp_Pnt2d P(Draw::Atof(a[last - 1]), Draw::Atof(a[last])); @@ -825,11 +867,15 @@ occ::handle DrawTrSurf::Get(const char*& Name) occ::handle DC = occ::down_cast(D); if (!DC.IsNull()) + { return DC->GetCurve(); + } occ::handle DS = occ::down_cast(D); if (!DS.IsNull()) + { return DS->GetSurface(); + } return occ::handle(); } @@ -840,9 +886,13 @@ bool DrawTrSurf::GetPoint(const char*& Name, gp_Pnt& P) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return false; + } else if (!D->Is3D()) + { return false; + } else { P = D->Point(); @@ -856,9 +906,13 @@ bool DrawTrSurf::GetPoint2d(const char*& Name, gp_Pnt2d& P) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return false; + } else if (D->Is3D()) + { return false; + } else { P = D->Point2d(); @@ -872,9 +926,13 @@ occ::handle DrawTrSurf::GetCurve(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->GetCurve(); + } } //================================================================================================= @@ -883,9 +941,13 @@ occ::handle DrawTrSurf::GetBezierCurve(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetCurve()); + } } //================================================================================================= @@ -894,9 +956,13 @@ occ::handle DrawTrSurf::GetBSplineCurve(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetCurve()); + } } //================================================================================================= @@ -905,9 +971,13 @@ occ::handle DrawTrSurf::GetCurve2d(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->GetCurve(); + } } //================================================================================================= @@ -916,9 +986,13 @@ occ::handle DrawTrSurf::GetBezierCurve2d(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetCurve()); + } } //================================================================================================= @@ -927,9 +1001,13 @@ occ::handle DrawTrSurf::GetBSplineCurve2d(const char*& Name { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetCurve()); + } } //================================================================================================= @@ -938,9 +1016,13 @@ occ::handle DrawTrSurf::GetSurface(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->GetSurface(); + } } //================================================================================================= @@ -950,9 +1032,13 @@ occ::handle DrawTrSurf::GetBezierSurface(const char*& Name) occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetSurface()); + } } //================================================================================================= @@ -962,9 +1048,13 @@ occ::handle DrawTrSurf::GetBSplineSurface(const char*& Name occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return occ::down_cast(D->GetSurface()); + } } //================================================================================================= @@ -974,9 +1064,13 @@ occ::handle DrawTrSurf::GetTriangulation(const char*& Name) occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->Triangulation(); + } } //================================================================================================= @@ -985,9 +1079,13 @@ occ::handle DrawTrSurf::GetPolygon3D(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->Polygon3D(); + } } //================================================================================================= @@ -996,9 +1094,13 @@ occ::handle DrawTrSurf::GetPolygon2D(const char*& Name) { occ::handle D = occ::down_cast(Draw::Get(Name)); if (D.IsNull()) + { return occ::handle(); + } else + { return D->Polygon2D(); + } } //================================================================================================= @@ -1062,35 +1164,65 @@ static Draw_Color recognizeColor(const char* theColorStr, const Draw_Color& theD Draw_Color aResult = theDefaultColor; if (!strcasecmp(theColorStr, "white")) + { aResult = Draw_blanc; + } if (!strcasecmp(theColorStr, "red")) + { aResult = Draw_rouge; + } if (!strcasecmp(theColorStr, "green")) + { aResult = Draw_vert; + } if (!strcasecmp(theColorStr, "blue")) + { aResult = Draw_bleu; + } if (!strcasecmp(theColorStr, "cyan")) + { aResult = Draw_cyan; + } if (!strcasecmp(theColorStr, "golden")) + { aResult = Draw_or; + } if (!strcasecmp(theColorStr, "magenta")) + { aResult = Draw_magenta; + } if (!strcasecmp(theColorStr, "brown")) + { aResult = Draw_marron; + } if (!strcasecmp(theColorStr, "orange")) + { aResult = Draw_orange; + } if (!strcasecmp(theColorStr, "pink")) + { aResult = Draw_rose; + } if (!strcasecmp(theColorStr, "salmon")) + { aResult = Draw_saumon; + } if (!strcasecmp(theColorStr, "violet")) + { aResult = Draw_violet; + } if (!strcasecmp(theColorStr, "yellow")) + { aResult = Draw_jaune; + } if (!strcasecmp(theColorStr, "darkgreen")) + { aResult = Draw_kaki; + } if (!strcasecmp(theColorStr, "coral")) + { aResult = Draw_corail; + } return aResult; } @@ -1126,7 +1258,9 @@ static int changecurvcolor(Draw_Interpretor&, int n, const char** a) DrawTrSurf_CurveColor(savecol); if (n < 3) + { return 1; + } col = recognizeColor(a[1], savecol); @@ -1171,7 +1305,9 @@ static int changepointcolor(Draw_Interpretor&, int n, const char** a) DrawTrSurf_PointColor(savecol); if (n < 3) + { return 1; + } col = recognizeColor(a[1], savecol); @@ -1220,17 +1356,29 @@ static Draw_MarkerShape recognizeMarker(const char* theMarkerStr, Draw_MarkerShape aResult = theDefaultMarker; if (!strcasecmp(theMarkerStr, "square")) + { aResult = Draw_Square; + } if (!strcasecmp(theMarkerStr, "diamond")) + { aResult = Draw_Losange; + } if (!strcasecmp(theMarkerStr, "x")) + { aResult = Draw_X; + } if (!strcasecmp(theMarkerStr, "plus")) + { aResult = Draw_Plus; + } if (!strcasecmp(theMarkerStr, "circle")) + { aResult = Draw_Circle; + } if (!strcasecmp(theMarkerStr, "circle_zoom")) + { aResult = Draw_CircleZoom; + } return aResult; } @@ -1266,7 +1414,9 @@ static int changepointmarker(Draw_Interpretor&, int n, const char** a) DrawTrSurf_PointMarker(savemark); if (n < 3) + { return 1; + } mark = recognizeMarker(a[1], savemark); @@ -1287,7 +1437,9 @@ static bool done = false; void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands) { if (done) + { return; + } done = true; DrawTrSurf_BezierCurve::RegisterFactory(); diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx index 016e536d7c..ce6912c69b 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BSplineCurve2d.cxx @@ -71,7 +71,9 @@ void DrawTrSurf_BSplineCurve2d::DrawOn(Draw_Display& dis) const dis.DrawTo(CPoles(i)); } if (C->IsPeriodic()) + { dis.DrawTo(CPoles(1)); + } } DrawTrSurf_Curve2d::DrawOn(dis); diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx index 2091e132dd..efc994a02a 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_BezierCurve2d.cxx @@ -79,7 +79,9 @@ void DrawTrSurf_BezierCurve2d::FindPole(const double X, P2d = bz->Pole(Index); P.SetCoord(P2d.X(), P2d.Y(), 0.0); if (D.Project(P).Distance(p1) <= Prec) + { return; + } Index++; } Index = 0; diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Drawable.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Drawable.cxx index f4c33599c9..4f63dfd1bf 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Drawable.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Drawable.cxx @@ -208,12 +208,18 @@ void DrawTrSurf_Drawable::DrawIsoCurveOn(Adaptor3d_IsoCurve& C, { GeomAdaptor_Curve GC; if (C.GetType() == GeomAbs_BezierCurve) + { GC.Load(C.Bezier(), F, L); + } else + { GC.Load(C.BSpline(), F, L); + } DrawCurveOn(GC, dis); } else + { DrawCurveOn(C, dis); + } } diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Point.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Point.cxx index 0339821530..84ac6b3299 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Point.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Point.cxx @@ -62,9 +62,13 @@ void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const { dis.SetColor(myColor); if (is3D) + { dis.DrawMarker(myPoint, myShape); + } else + { dis.DrawMarker(Point2d(), myShape); + } } //================================================================================================= @@ -89,9 +93,13 @@ occ::handle DrawTrSurf_Point::Copy() const { occ::handle P; if (is3D) + { P = new DrawTrSurf_Point(myPoint, myShape, myColor); + } else + { P = new DrawTrSurf_Point(Point2d(), myShape, myColor); + } return P; } @@ -109,9 +117,13 @@ void DrawTrSurf_Point::Dump(Standard_OStream& S) const std::streamsize prec = S.precision(15); #endif if (is3D) - S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() << std::endl; + { + S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() << '\n'; + } else - S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() << std::endl; + { + S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() << '\n'; + } #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX) S.setf(F); #else diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Surface.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Surface.cxx index 46541bce64..9006df64a4 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Surface.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Surface.cxx @@ -83,13 +83,21 @@ void DrawTrSurf_Surface::DrawOn(Draw_Display& dis, const bool Iso) const gp_Pnt P1, P2; double v; if (VfirstInf && VlastInf) + { v = 0; + } else if (VfirstInf) + { v = VLast; + } else if (VlastInf) + { v = VFirst; + } else + { v = (VFirst + VLast) / 2; + } double delta = 1.; @@ -196,13 +204,21 @@ void DrawTrSurf_Surface::DrawOn(Draw_Display& dis, const bool Iso) const // draw bounds dis.SetColor(boundsLook); if (!UfirstInf) + { DrawIsoCurveOn(C, GeomAbs_IsoU, UFirst, VFirst, VLast, dis); + } if (!UlastInf) + { DrawIsoCurveOn(C, GeomAbs_IsoU, ULast, VFirst, VLast, dis); + } if (!VfirstInf) + { DrawIsoCurveOn(C, GeomAbs_IsoV, VFirst, UFirst, ULast, dis); + } if (!VlastInf) + { DrawIsoCurveOn(C, GeomAbs_IsoV, VLast, UFirst, ULast, dis); + } // draw marker DrawIsoCurveOn(C, diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation.cxx index 0e393b4643..f8645cf494 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation.cxx @@ -48,8 +48,12 @@ DrawTrSurf_Triangulation::DrawTrSurf_Triangulation(const occ::handleNode(t[j]).Coord()); + } bary.Multiply(1. / 3.); Sprintf(text, "%d", i); diff --git a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx index 2b519e86ce..5ab95e7c48 100644 --- a/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx +++ b/src/Draw/TKDraw/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx @@ -48,8 +48,12 @@ DrawTrSurf_Triangulation2D::DrawTrSurf_Triangulation2D(const occ::handle& theWorkspace) const override { if (!myIObj.IsNull()) + { myIObj->Render(theWorkspace); + } } void Release(OpenGl_Context*) override diff --git a/src/Draw/TKQADraw/QABugs/QABugs.cxx b/src/Draw/TKQADraw/QABugs/QABugs.cxx index 099fc5930e..3a60cb55cf 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs.cxx @@ -35,6 +35,4 @@ void QABugs::Commands(Draw_Interpretor& theCommands) QABugs::Commands_19(theCommands); QABugs::Commands_20(theCommands); QABugs::Commands_BVH(theCommands); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_1.cxx b/src/Draw/TKQADraw/QABugs/QABugs_1.cxx index 40db83d769..904d2b759f 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_1.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_1.cxx @@ -72,14 +72,18 @@ static int OCC159bug(Draw_Interpretor& di, int argc, const char** argv) occ::handle D; if (!DDocStd::GetDocument(argv[1], D)) + { return 1; + } int DocRefCount1 = D->GetRefCount(); di << "DocRefCount1 = " << DocRefCount1 << "\n"; occ::handle Owner; if (!D->Main().Root().FindAttribute(TDocStd_Owner::GetID(), Owner)) + { return 1; + } occ::handle OwnerD1 = Owner->GetDocument(); if (OwnerD1.IsNull()) @@ -163,16 +167,22 @@ static int OCC73_SelectionMode(Draw_Interpretor& di, int argc, const char** argv occ::handle D; // std::cout << "OCC73_SelectionMode 1" << std::endl; if (!DDocStd::GetDocument(argv[1], D)) + { return 1; + } TDF_Label L; // std::cout << "OCC73_SelectionMode 2" << std::endl; if (!DDF::FindLabel(D->GetData(), argv[2], L)) + { return 1; + } occ::handle viewer; // std::cout << "OCC73_SelectionMode 3" << std::endl; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; // std::cout << "OCC73_SelectionMode 4" << std::endl; @@ -654,5 +664,4 @@ void QABugs::Commands_1(Draw_Interpretor& theCommands) __FILE__, OCC31956, group); - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_10.cxx b/src/Draw/TKQADraw/QABugs/QABugs_10.cxx index b669b7e0f8..2c826293af 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_10.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_10.cxx @@ -118,9 +118,13 @@ static int OCC486(Draw_Interpretor& di, int argc, const char** argv) constexpr double Tol = Precision::PConfusion(); Extrema_ExtPS myExtPS; if (argc > 5) + { du = Draw::Atof(argv[5]); + } if (argc > 6) + { dv = Draw::Atof(argv[6]); + } double uf, ul, vf, vl; GS->Bounds(uf, ul, vf, vl); @@ -157,12 +161,18 @@ static int OCC486(Draw_Interpretor& di, int argc, const char** argv) di << "CheckDistance = " << aCheckDist << "\n"; if (fabs(distMin - aCheckDist) < Precision::Confusion()) + { return 0; + } else + { return 1; + } } else + { return 1; + } } catch (Standard_Failure const&) { @@ -271,7 +281,9 @@ static int OCC712(Draw_Interpretor& di, int argc, const char** argv) { TopoDS_Face aFace = TopoDS::Face(ex.Current()); if (aFace.IsSame(fShape) || aFace.IsSame(lShape)) + { continue; + } draftSlab.Add(aFace, slabDir, angle, slabPln); if (!draftSlab.AddDone()) { @@ -311,6 +323,4 @@ void QABugs::Commands_10(Draw_Interpretor& theCommands) group); theCommands.Add("OCC486", "Use : OCC486 surf x y z du dv ", __FILE__, OCC486, group); theCommands.Add("OCC712", "OCC712 draftAngle slabThick", __FILE__, OCC712, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_11.cxx b/src/Draw/TKQADraw/QABugs/QABugs_11.cxx index 2ae5bade3c..9e32e16bc1 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_11.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_11.cxx @@ -284,7 +284,9 @@ static int OCC105(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); TopExp::Vertices(edge, ve1, ve2); if (vw1.IsSame(ve1) || vw1.IsSame(ve2)) + { vlast = vw1; + } else { // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2)); @@ -323,7 +325,9 @@ static int OCC105(Draw_Interpretor& di, int argc, const char** argv) curve.Load(acurve); algo.Initialize(curve, l, newufirst, newulast); if (!algo.IsDone()) + { di << "Not Done!!!" << "\n"; + } for (int Index = 1; Index <= algo.NbPoints(); Index++) { double t = algo.Parameter(Index); @@ -472,7 +476,9 @@ int OCC157(Draw_Interpretor& di, int n, const char** a) } } else + { di << "OCC157: ERROR; Planar surface is not found with toler = " << toler << "\n"; + } return 0; } @@ -596,9 +602,13 @@ static int OCC297(Draw_Interpretor& di, int /*argc*/, const char** argv) gp_Pnt g_pnt; if (up) + { g_pnt = gp_Pnt(0, 0, -100); + } else + { g_pnt = gp_Pnt(0, 0, 100); + } myAISContext->EraseAll(false); occ::handle GEOMPoint = new Geom_CartesianPoint(g_pnt); @@ -691,7 +701,9 @@ static int OCC381_Save(Draw_Interpretor& di, int nb, const char** a) occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } occ::handle A = DDocStd::GetApplication(); @@ -748,7 +760,9 @@ static int OCC381_SaveAs(Draw_Interpretor& di, int nb, const char** a) occ::handle D; if (!DDocStd::GetDocument(a[1], D)) + { return 1; + } TCollection_ExtendedString path(a[2]); occ::handle A = DDocStd::GetApplication(); @@ -886,8 +900,12 @@ static int OCC363(Draw_Interpretor& di, int argc, const char** argv) shapes->GetFreeShapes(seq); occ::handle prs; for (int i = 1; i <= seq.Length(); i++) + { if (!seq.Value(i).FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { prs = TPrsStd_AISPresentation::Set(seq.Value(i), XCAFPrs_Driver::GetID()); + } + } } catch (Standard_Failure const&) { @@ -1045,7 +1063,9 @@ static int OCC377(Draw_Interpretor& di, int argc, const char** argv) // 4.3. Compare results (they must be same) if (stat1 == stat2) + { di << "OCC377 OK\n"; + } else { di << "OCC377 FAULTY\n"; @@ -1101,13 +1121,19 @@ static int OCC22(Draw_Interpretor& di, int argc, const char** argv) occ::handle aReshape = new ShapeBuild_ReShape; aShapeUpgrade.SetContext(aReshape); if (aConsiderLocation) + { aReshape->ModeConsiderLocation() = true; + } // 3. Perform splitting if (aShapeUpgrade.Perform(false)) + { di << "Upgrade_SplitRevolution_Done \n"; + } else if (aShapeUpgrade.Status(ShapeExtend_OK)) + { di << "Upgrade_SplitRevolution_OK \n"; + } else if (aShapeUpgrade.Status(ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n"; @@ -1190,7 +1216,9 @@ static int OCC24(Draw_Interpretor& di, int argc, const char** argv) NCollection_DataMap::Iterator anIter( aShapeContext->Map()); for (; anIter.More(); anIter.Next()) + { aReshape->Replace(anIter.Key(), anIter.Value()); + } TopoDS_Shape aResultShape = aReshape->Apply(anInitShape); // 5 Create resultant Draw shape @@ -1446,7 +1474,9 @@ static int OCC921(Draw_Interpretor& di, int argc, const char** argv) double u1, u2, v1, v2; TopoDS_Face F = TopoDS::Face(DBRep::Get(argv[1])); // read the shape if (F.IsNull()) + { return 1; + } BRepTools::UVBounds(F, u1, u2, v1, v2); di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n"; return 0; @@ -1471,14 +1501,20 @@ static int OCC1029_AISTransparency(Draw_Interpretor& di, int nb, const char** ar { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -1510,14 +1546,20 @@ static int OCC1031_AISMaterial(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -1549,14 +1591,20 @@ static int OCC1032_AISWidth(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -1588,14 +1636,20 @@ static int OCC1033_AISMode(Draw_Interpretor& di, int nb, const char** arg) { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -1627,14 +1681,20 @@ static int OCC1034_AISSelectionMode(Draw_Interpretor& di, int nb, const char** a { occ::handle D; if (!DDocStd::GetDocument(arg[1], D)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(D->GetData(), arg[2], L)) + { return 1; + } occ::handle viewer; if (!TPrsStd_AISViewer::Find(L, viewer)) + { return 1; + } occ::handle prs; if (L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) @@ -1729,7 +1789,9 @@ static int OCC5739_UniAbs(Draw_Interpretor& di, int argc, const char** argv) Adaptor3d_Curve* adapCurve = nullptr; occ::handle curve = DrawTrSurf::GetCurve(argv[2]); if (!curve.IsNull()) + { adapCurve = new GeomAdaptor_Curve(curve); + } else { TopoDS_Shape wire = DBRep::Get(argv[2]); @@ -1775,7 +1837,9 @@ static int OCC5698(Draw_Interpretor& di, int argc, const char** argv) } TopoDS_Shape shape = DBRep::Get(argv[1], TopAbs_WIRE); if (shape.IsNull()) + { return 1; + } TopoDS_Wire wire = TopoDS::Wire(shape); // create curve parameterised by curvilinear distance BRepAdaptor_CompCurve curve(wire, true); @@ -1832,7 +1896,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "(Integer) Divide By Zero..." << std::endl; + std::cout << "(Integer) Divide By Zero..." << '\n'; di << "(Integer) Divide By Zero..."; // std::cout.flush(); di << "\n"; @@ -1868,7 +1932,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "(Real) Divide By Zero..." << std::endl; + std::cout << "(Real) Divide By Zero..." << '\n'; di << "(Real) Divide By Zero..."; // std::cout.flush(); di << "\n"; @@ -1899,7 +1963,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "(Integer) Overflow..." << std::endl; + std::cout << "(Integer) Overflow..." << '\n'; di << "(Integer) Overflow..."; // std::cout.flush(); di << "\n"; @@ -1942,7 +2006,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "(Real) Overflow..." << std::endl; + std::cout << "(Real) Overflow..." << '\n'; di << "(Real) Overflow..."; // std::cout.flush(); di << "\n"; @@ -1977,7 +2041,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) { OCC_CATCH_SIGNALS // clang-format off - std::cout << "(Real) Underflow" << std::endl; // to have message in log even if process crashed + std::cout << "(Real) Underflow" << '\n'; // to have message in log even if process crashed // clang-format on di << "(Real) Underflow"; // std::cout.flush(); @@ -2013,7 +2077,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "(Real) Invalid Operation..." << std::endl; + std::cout << "(Real) Invalid Operation..." << '\n'; di << "(Real) Invalid Operation..."; // std::cout.flush(); di << "\n"; @@ -2040,7 +2104,7 @@ static int OCC6143(Draw_Interpretor& di, int argc, const char** argv) try { OCC_CATCH_SIGNALS - std::cout << "Segmentation Fault..." << std::endl; + std::cout << "Segmentation Fault..." << '\n'; di << "Segmentation Fault..."; // std::cout.flush(); di << "\n"; @@ -2379,10 +2443,12 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) occ::handle array; if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) && array->Lower() == LOWER && array->Upper() == UPPER) - std::cout << "1: OK" << std::endl; + { + std::cout << "1: OK" << '\n'; + } else { - std::cout << "1: Failed.." << std::endl; + std::cout << "1: Failed.." << '\n'; return 1; } doc->CommitCommand(); @@ -2391,16 +2457,18 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) doc->OpenCommand(); int i; for (i = LOWER; i <= UPPER; i++) + { array->SetValue(i, i); + } for (i = LOWER; i <= UPPER; i++) { if (array->Value(i) != i) { - std::cout << "2: Failed.." << std::endl; + std::cout << "2: Failed.." << '\n'; return 2; } } - std::cout << "2: OK" << std::endl; + std::cout << "2: OK" << '\n'; doc->CommitCommand(); //! 3. Re-init the array @@ -2408,20 +2476,22 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) array->Init(LOWER + 2, UPPER + 4); if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4) { - std::cout << "3: Failed.." << std::endl; + std::cout << "3: Failed.." << '\n'; return 3; } for (i = LOWER + 2; i <= UPPER + 4; i++) + { array->SetValue(i, i); + } for (i = LOWER + 2; i <= UPPER + 4; i++) { if (array->Value(i) != i) { - std::cout << "3: Failed.." << std::endl; + std::cout << "3: Failed.." << '\n'; return 3; } } - std::cout << "3: OK" << std::endl; + std::cout << "3: OK" << '\n'; doc->CommitCommand(); //! 4. Change array @@ -2429,17 +2499,19 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) occ::handle> arr = new NCollection_HArray1(LOWER + 5, UPPER + 5); for (i = LOWER + 5; i <= UPPER + 5; i++) + { arr->SetValue(i, i); + } array->ChangeArray(arr); for (i = LOWER + 5; i <= UPPER + 5; i++) { if (array->Value(i) != i) { - std::cout << "4: Failed.." << std::endl; + std::cout << "4: Failed.." << '\n'; return 4; } } - std::cout << "4: OK" << std::endl; + std::cout << "4: OK" << '\n'; doc->CommitCommand(); //! 5. Copy the array @@ -2448,24 +2520,24 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) copier.Perform(); if (!copier.IsDone()) { - std::cout << "5: Failed.." << std::endl; + std::cout << "5: Failed.." << '\n'; return 5; } occ::handle array2; if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2)) { - std::cout << "5: Failed.." << std::endl; + std::cout << "5: Failed.." << '\n'; return 5; } for (i = LOWER + 5; i <= UPPER + 5; i++) { if (array->Value(i) != i) { - std::cout << "5: Failed.." << std::endl; + std::cout << "5: Failed.." << '\n'; return 5; } } - std::cout << "5: OK" << std::endl; + std::cout << "5: OK" << '\n'; doc->CommitCommand(); //! 6. Undo/Redo @@ -2474,7 +2546,7 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) || label2.FindAttribute(TDataStd_RealArray::GetID(), array2)) { - std::cout << "6.a: Failed.." << std::endl; + std::cout << "6.a: Failed.." << '\n'; return 6; } //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4) @@ -2482,14 +2554,14 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) || array->Lower() != LOWER + 2 || array->Upper() != UPPER + 4) { - std::cout << "6.b: Failed.." << std::endl; + std::cout << "6.b: Failed.." << '\n'; return 6; } for (i = LOWER + 2; i <= UPPER + 4; i++) { if (array->Value(i) != i) { - std::cout << "6.b: Failed.." << std::endl; + std::cout << "6.b: Failed.." << '\n'; return 6; } } @@ -2498,14 +2570,14 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) || array->Lower() != LOWER || array->Upper() != UPPER) { - std::cout << "6.c: Failed.." << std::endl; + std::cout << "6.c: Failed.." << '\n'; return 6; } for (i = LOWER; i <= UPPER; i++) { if (array->Value(i) != i) { - std::cout << "6.c: Failed.." << std::endl; + std::cout << "6.c: Failed.." << '\n'; return 6; } } @@ -2515,38 +2587,40 @@ static int OCC10138(Draw_Interpretor& di, int argc, const char** argv) if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) || array->Lower() != LOWER || array->Upper() != UPPER) { - std::cout << "6.d: Failed.." << std::endl; + std::cout << "6.d: Failed.." << '\n'; return 6; } for (i = LOWER; i <= UPPER; i++) { if (array->Value(i) != i) { - std::cout << "6.d: Failed.." << std::endl; + std::cout << "6.d: Failed.." << '\n'; return 6; } } - std::cout << "6: OK" << std::endl; + std::cout << "6: OK" << '\n'; //! 7. Re-set the array doc->OpenCommand(); array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1); if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1) { - std::cout << "7: Failed.." << std::endl; + std::cout << "7: Failed.." << '\n'; return 7; } for (i = LOWER + 1; i <= UPPER + 1; i++) + { array->SetValue(i, i); + } for (i = LOWER + 1; i <= UPPER + 1; i++) { if (array->Value(i) != i) { - std::cout << "7: Failed.." << std::endl; + std::cout << "7: Failed.." << '\n'; return 7; } } - std::cout << "7: OK" << std::endl; + std::cout << "7: OK" << '\n'; doc->CommitCommand(); //! 8.Test of speed: set LOWER and UPPER equal to great integer number and @@ -2728,18 +2802,26 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle tick; if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick)) + { return 1; + } // Forget doc->Main().ForgetAttribute(TDataStd_Tick::GetID()); if (doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 2; + } doc->Main().ResumeAttribute(tick); if (!doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 3; + } // Forget doc->Main().ForgetAttribute(TDataStd_Tick::GetID()); if (doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 2; + } // TDataStd_IntegerList: // Set @@ -2754,11 +2836,17 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getintlist; if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist)) + { return 1; + } if (getintlist->First() != 1) + { return 2; + } if (getintlist->Last() != 3) + { return 3; + } const NCollection_List& intlist = getintlist->List(); NCollection_List::Iterator itr_intlist(intlist); for (; itr_intlist.More(); itr_intlist.Next()) @@ -2783,11 +2871,17 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getdbllist; if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist)) + { return 1; + } if (getdbllist->First() != 1.5) + { return 2; + } if (getdbllist->Last() != 3.5) + { return 3; + } const NCollection_List& dbllist = getdbllist->List(); NCollection_List::Iterator itr_dbllist(dbllist); for (; itr_dbllist.More(); itr_dbllist.Next()) @@ -2812,11 +2906,17 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getstrlist; if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist)) + { return 1; + } if (getstrlist->First() != "Guten Tag") + { return 2; + } if (getstrlist->Last() != "Hello") + { return 3; + } const NCollection_List& strlist = getstrlist->List(); NCollection_List::Iterator itr_strlist(strlist); for (; itr_strlist.More(); itr_strlist.Next()) @@ -2837,11 +2937,17 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getboollist; if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist)) + { return 1; + } if (getboollist->First()) + { return 2; + } if (!getboollist->Last()) + { return 3; + } const NCollection_List& boollist = getboollist->List(); for (NCollection_List::Iterator itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next()) @@ -2871,11 +2977,17 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getreflist; if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist)) + { return 1; + } if (getreflist->First() != L2) + { return 2; + } if (getreflist->Last() != L1) + { return 3; + } const NCollection_List& reflist = getreflist->List(); NCollection_List::Iterator itr_reflist(reflist); for (; itr_reflist.More(); itr_reflist.Next()) @@ -2899,17 +3011,29 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getboolarr; if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr)) + { return 1; + } if (!getboolarr->Value(12)) + { return 2; + } if (getboolarr->Value(13)) + { return 2; + } if (!getboolarr->Value(14)) + { return 2; + } if (getboolarr->Value(15)) + { return 2; + } if (!getboolarr->Value(16)) + { return 2; + } // TDataStd_ReferenceArray: // Set @@ -2922,17 +3046,29 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getrefarr; if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr)) + { return 1; + } if (getrefarr->Value(0) != L1) + { return 2; + } if (getrefarr->Value(1) != L2) + { return 2; + } if (getrefarr->Value(2) != L3) + { return 2; + } if (getrefarr->Value(3) != L4) + { return 2; + } if (getrefarr->Value(4) != L5) + { return 2; + } // TDataStd_ByteArray: // Set @@ -2945,17 +3081,29 @@ int TestSetGet(const occ::handle& doc) // Get occ::handle getbytearr; if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr)) + { return 1; + } if (getbytearr->Value(12) != 0) + { return 2; + } if (getbytearr->Value(13) != 1) + { return 2; + } if (getbytearr->Value(14) != 2) + { return 2; + } if (getbytearr->Value(15) != 3) + { return 2; + } if (getbytearr->Value(16) != 255) + { return 2; + } // TDataStd_NamedData: // Set: @@ -2967,15 +3115,25 @@ int TestSetGet(const occ::handle& doc) // Get: occ::handle getnd; if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd)) + { return 1; + } if (!getnd->HasIntegers()) + { return 2; + } if (!getnd->HasInteger("Integer1")) + { return 3; + } if (getnd->GetInteger("Integer2") != 2) + { return 4; + } if (getnd->GetInteger("Integer3") != 3) + { return 4; + } return 0; } @@ -2987,13 +3145,19 @@ int TestUndoRedo(const occ::handle& doc) occ::handle tick = TDataStd_Tick::Set(doc->Main()); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 1; + } doc->Undo(); if (doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 2; + } doc->Redo(); if (!doc->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 3; + } // TDataStd_IntegerList: doc->OpenCommand(); @@ -3004,17 +3168,27 @@ int TestUndoRedo(const occ::handle& doc) intlist->InsertAfter(3, 2); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID())) + { return 1; + } doc->Undo(); if (!intlist->IsEmpty()) + { return 2; + } doc->Redo(); if (!intlist->Extent()) + { return 3; + } if (intlist->First() != 0) + { return 4; + } if (intlist->Last() != 3) + { return 5; + } intlist->Clear(); // TDataStd_RealList: @@ -3026,17 +3200,27 @@ int TestUndoRedo(const occ::handle& doc) dbllist->InsertAfter(3.5, 2.5); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_RealList::GetID())) + { return 1; + } doc->Undo(); if (!dbllist->IsEmpty()) + { return 2; + } doc->Redo(); if (!dbllist->Extent()) + { return 3; + } if (dbllist->First() != 0.5) + { return 4; + } if (dbllist->Last() != 3.5) + { return 5; + } dbllist->Clear(); // TDataStd_ExtStringList: @@ -3048,17 +3232,27 @@ int TestUndoRedo(const occ::handle& doc) strlist->InsertBefore("Bonsoir", "Hello"); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID())) + { return 1; + } doc->Undo(); if (!strlist->IsEmpty()) + { return 2; + } doc->Redo(); if (!strlist->Extent()) + { return 3; + } if (strlist->First() != "Guten Tag") + { return 4; + } if (strlist->Last() != "Hello") + { return 5; + } strlist->Clear(); // TDataStd_BooleanList: @@ -3068,17 +3262,27 @@ int TestUndoRedo(const occ::handle& doc) boollist->Prepend(false); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID())) + { return 1; + } doc->Undo(); if (!boollist->IsEmpty()) + { return 2; + } doc->Redo(); if (!boollist->Extent()) + { return 3; + } if (boollist->First()) + { return 4; + } if (!boollist->Last()) + { return 5; + } boollist->Clear(); // TDataStd_ReferenceList: @@ -3094,17 +3298,27 @@ int TestUndoRedo(const occ::handle& doc) reflist->InsertAfter(L4, L2); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID())) + { return 1; + } doc->Undo(); if (!reflist->IsEmpty()) + { return 2; + } doc->Redo(); if (!reflist->Extent()) + { return 3; + } if (reflist->First() != L2) + { return 4; + } if (reflist->Last() != L1) + { return 5; + } reflist->Clear(); // TDataStd_BooleanArray: @@ -3120,18 +3334,30 @@ int TestUndoRedo(const occ::handle& doc) doc->CommitCommand(); doc->Undo(); if (!boolarr->Value(23)) + { return 2; + } if (boolarr->Value(24)) + { return 2; + } if (!boolarr->Value(25)) + { return 2; + } doc->Redo(); if (!boolarr->Value(230)) + { return 3; + } if (boolarr->Value(240)) + { return 3; + } if (!boolarr->Value(250)) + { return 3; + } // TDataStd_ReferenceArray: doc->OpenCommand(); @@ -3142,17 +3368,27 @@ int TestUndoRedo(const occ::handle& doc) refarr->SetValue(8, L4); doc->CommitCommand(); if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID())) + { return 1; + } doc->Undo(); doc->Redo(); if (refarr->Value(5) != L1) + { return 4; + } if (refarr->Value(6) != L2) + { return 4; + } if (refarr->Value(7) != L3) + { return 4; + } if (refarr->Value(8) != L4) + { return 4; + } // TDataStd_ByteArray: doc->OpenCommand(); @@ -3167,14 +3403,22 @@ int TestUndoRedo(const occ::handle& doc) doc->CommitCommand(); doc->Undo(); if (bytearr->Value(23) != 23) + { return 2; + } if (bytearr->Value(25) != 25) + { return 2; + } doc->Redo(); if (bytearr->Value(230) != 230) + { return 3; + } if (bytearr->Value(250) != 250) + { return 3; + } // TDataStd_NamedData: doc->OpenCommand(); @@ -3193,30 +3437,54 @@ int TestUndoRedo(const occ::handle& doc) doc->CommitCommand(); doc->Undo(); if (nd->HasStrings()) + { return 1; + } if (nd->HasReals()) + { return 1; + } if (nd->HasReal("r17")) + { return 2; + } if (!nd->HasBytes()) + { return 3; + } if (nd->GetByte("b14") != 14) + { return 4; + } if (nd->GetByte("b17") != 17) + { return 4; + } if (nd->HasByte("b18")) + { return 5; + } doc->Redo(); if (!nd->HasBytes()) + { return 1; + } if (!nd->HasReals()) + { return 1; + } if (nd->GetByte("b14") != 14) + { return 2; + } if (nd->GetReal("r14") != 14.4) + { return 2; + } if (nd->GetReal("r17") != 17.7) + { return 2; + } return 0; } @@ -3231,9 +3499,13 @@ int TestCopyPaste(const occ::handle& doc) TDataStd_Tick::Set(L1); copier.Perform(); if (!copier.IsDone()) + { return 1; + } if (!L2.IsAttribute(TDataStd_Tick::GetID())) + { return 2; + } // TDataStd_IntegerList: occ::handle intlist = TDataStd_IntegerList::Set(L1); @@ -3241,15 +3513,23 @@ int TestCopyPaste(const occ::handle& doc) intlist->InsertAfter(2, 1); copier.Perform(); if (!copier.IsDone()) + { return 1; + } intlist->Clear(); intlist.Nullify(); if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist)) + { return 2; + } if (intlist->First() != 1) + { return 3; + } if (intlist->Last() != 2) + { return 4; + } intlist->Clear(); // TDataStd_RealList: @@ -3258,15 +3538,23 @@ int TestCopyPaste(const occ::handle& doc) dbllist->InsertAfter(2.5, 1.5); copier.Perform(); if (!copier.IsDone()) + { return 1; + } dbllist->Clear(); dbllist.Nullify(); if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist)) + { return 2; + } if (dbllist->First() != 1.5) + { return 3; + } if (dbllist->Last() != 2.5) + { return 4; + } dbllist->Clear(); // TDataStd_ExtStringList: @@ -3275,15 +3563,23 @@ int TestCopyPaste(const occ::handle& doc) strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE"); copier.Perform(); if (!copier.IsDone()) + { return 1; + } strlist->Clear(); strlist.Nullify(); if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist)) + { return 2; + } if (strlist->First() != "Open CASCADE") + { return 3; + } if (strlist->Last() != " - is the best set of libraries!") + { return 4; + } strlist->Clear(); // TDataStd_BooleanList: @@ -3292,15 +3588,23 @@ int TestCopyPaste(const occ::handle& doc) boollist->Prepend(false); copier.Perform(); if (!copier.IsDone()) + { return 1; + } boollist->Clear(); boollist.Nullify(); if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist)) + { return 2; + } if (boollist->First()) + { return 3; + } if (!boollist->Last()) + { return 4; + } boollist->Clear(); // TDataStd_ReferenceList: @@ -3311,15 +3615,23 @@ int TestCopyPaste(const occ::handle& doc) reflist->InsertAfter(L101, L100); copier.Perform(); if (!copier.IsDone()) + { return 1; + } reflist->Clear(); reflist.Nullify(); if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist)) + { return 2; + } if (reflist->First() != L100) + { return 3; + } if (reflist->Last() != L101) + { return 4; + } reflist->Clear(); // TDataStd_BooleanArray: @@ -3328,16 +3640,26 @@ int TestCopyPaste(const occ::handle& doc) boolarr->SetValue(6, true); copier.Perform(); if (!copier.IsDone()) + { return 1; + } boolarr.Nullify(); if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr)) + { return 2; + } if (!boolarr->Value(4)) + { return 3; + } if (boolarr->Value(5)) + { return 3; + } if (!boolarr->Value(6)) + { return 3; + } // TDataStd_ReferenceArray: occ::handle refarr = TDataStd_ReferenceArray::Set(L1, 3, 4); @@ -3345,14 +3667,22 @@ int TestCopyPaste(const occ::handle& doc) refarr->SetValue(4, L101); copier.Perform(); if (!copier.IsDone()) + { return 1; + } refarr.Nullify(); if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr)) + { return 2; + } if (refarr->Value(3) != L100) + { return 3; + } if (refarr->Value(4) != L101) + { return 3; + } // TDataStd_ByteArray: occ::handle bytearr = TDataStd_ByteArray::Set(L1, 4, 6); @@ -3360,14 +3690,22 @@ int TestCopyPaste(const occ::handle& doc) bytearr->SetValue(6, 60); copier.Perform(); if (!copier.IsDone()) + { return 1; + } bytearr.Nullify(); if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr)) + { return 2; + } if (bytearr->Value(4) != 40) + { return 3; + } if (bytearr->Value(6) != 60) + { return 3; + } // TDataStd_NamedData: occ::handle nd = TDataStd_NamedData::Set(L1); @@ -3381,45 +3719,83 @@ int TestCopyPaste(const occ::handle& doc) nd->SetArrayOfIntegers("Integers1", ints_arr); copier.Perform(); if (!copier.IsDone()) + { return 1; + } nd.Nullify(); if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd)) + { return 2; + } if (!nd->HasIntegers()) + { return 3; + } if (!nd->HasReals()) + { return 3; + } if (!nd->HasStrings()) + { return 3; + } if (!nd->HasBytes()) + { return 3; + } if (!nd->HasArraysOfIntegers()) + { return 3; + } if (nd->HasArraysOfReals()) + { return 3; + } if (!nd->HasInteger("Integer1")) + { return 4; + } if (nd->GetInteger("Integer1") != 11) + { return 4; + } if (!nd->HasReal("Real1")) + { return 4; + } if (nd->GetReal("Real1") != 11.1) + { return 4; + } if (!nd->HasString("String1")) + { return 4; + } if (nd->GetString("String1") != "11.11111111") + { return 4; + } if (!nd->HasByte("Byte1")) + { return 4; + } if (nd->GetByte("Byte1") != 111) + { return 4; + } if (!nd->HasArrayOfIntegers("Integers1")) + { return 4; + } const occ::handle>& ints_arr_out = nd->GetArrayOfIntegers("Integers1"); if (ints_arr_out.IsNull()) + { return 4; + } if (ints_arr_out->Value(5) != 5) + { return 4; + } return 0; } @@ -3484,7 +3860,9 @@ int TestOpenSave(const TCollection_ExtendedString& aFile1, // Save // if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK) if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK) + { return 1; + } intlist.Nullify(); dbllist.Nullify(); strlist.Nullify(); @@ -3496,75 +3874,141 @@ int TestOpenSave(const TCollection_ExtendedString& aFile1, doc_std.Nullify(); // if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK) if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK) + { return 2; + } if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 3; + } if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist)) + { return 4; + } if (intlist->First() != 1) + { return 5; + } if (intlist->Last() != 5) + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist)) + { return 4; + } if (dbllist->First() != 1.5) + { return 5; + } if (dbllist->Last() != 5.5) + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist)) + { return 4; + } if (strlist->First() != "Auf") + { return 5; + } if (strlist->Last() != "Wiedersehen") + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist)) + { return 4; + } if (boollist->First()) + { return 5; + } if (!boollist->Last()) + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist)) + { return 4; + } TDF_Tool::Entry(reflist->First(), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(reflist->Last(), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr)) + { return 4; + } if (boolarr->Value(15)) + { return 5; + } if (!boolarr->Value(16)) + { return 5; + } if (!boolarr->Value(17)) + { return 5; + } if (!boolarr->Value(18)) + { return 5; + } if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr)) + { return 4; + } TDF_Tool::Entry(refarr->Value(45), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(refarr->Value(46), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr)) + { return 4; + } if (bytearr->Value(15) != 150) + { return 5; + } if (bytearr->Value(16) != 160) + { return 5; + } if (bytearr->Value(17) != 170) + { return 5; + } if (bytearr->Value(18) != 180) + { return 5; + } if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref)) + { return 4; + } if (ref->Get().IsNull()) + { return 5; + } if (ref->Get().Tag() != 103) + { return 5; + } // Xml occ::handle doc_xml, doc_xml_open; @@ -3630,106 +4074,198 @@ int TestOpenSave(const TCollection_ExtendedString& aFile1, // Save // if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK) if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK) + { return 1; + } intlist.Nullify(); ref.Nullify(); app->Close(doc_xml); doc_xml.Nullify(); // if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK) if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK) + { return 2; + } if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 3; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist)) + { return 4; + } if (intlist->First() != 1) + { return 5; + } if (intlist->Last() != 5) + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist)) + { return 4; + } if (dbllist->First() != 1.5) + { return 5; + } if (dbllist->Last() != 5.5) + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist)) + { return 4; + } if (strlist->First() != "Guten ") + { return 5; + } if (strlist->Last() != "Tag") + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist)) + { return 4; + } if (boollist->First()) + { return 5; + } if (!boollist->Last()) + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist)) + { return 4; + } TDF_Tool::Entry(reflist->First(), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(reflist->Last(), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr)) + { return 4; + } if (boolarr->Value(15)) + { return 5; + } if (!boolarr->Value(16)) + { return 5; + } if (!boolarr->Value(17)) + { return 5; + } if (!boolarr->Value(18)) + { return 5; + } if (!boolarr->Value(19)) + { return 5; + } if (!boolarr->Value(20)) + { return 5; + } if (boolarr->Value(21)) + { return 5; + } if (!boolarr->Value(22)) + { return 5; + } if (!boolarr->Value(23)) + { return 5; + } if (!boolarr->Value(24)) + { return 5; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr)) + { return 4; + } TDF_Tool::Entry(refarr->Value(444), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(refarr->Value(445), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr)) + { return 4; + } if (bytearr->Value(15) != 0) + { return 5; + } if (bytearr->Value(16) != 10) + { return 5; + } if (bytearr->Value(17) != 100) + { return 5; + } if (bytearr->Value(18) != 200) + { return 5; + } if (bytearr->Value(19) != 250) + { return 5; + } if (bytearr->Value(20) != 251) + { return 5; + } if (bytearr->Value(21) != 252) + { return 5; + } if (bytearr->Value(22) != 253) + { return 5; + } if (bytearr->Value(23) != 254) + { return 5; + } if (bytearr->Value(24) != 255) + { return 5; + } if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref)) + { return 4; + } if (ref->Get().IsNull()) + { return 5; + } if (ref->Get().Tag() != 103) + { return 5; + } // Bin occ::handle doc_bin, doc_bin_open; @@ -3791,96 +4327,178 @@ int TestOpenSave(const TCollection_ExtendedString& aFile1, // Save // if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK) if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK) + { return 1; + } intlist.Nullify(); ref.Nullify(); app->Close(doc_bin); doc_bin.Nullify(); // if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK) if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK) + { return 2; + } if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID())) + { return 3; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist)) + { return 4; + } if (intlist->First() != 1) + { return 5; + } if (intlist->Last() != 5) + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist)) + { return 4; + } if (dbllist->First() != 1.5) + { return 5; + } if (dbllist->Last() != 5.5) + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist)) + { return 4; + } if (strlist->First() != "Bonjour") + { return 5; + } if (strlist->Last() != "Bonsoir") + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist)) + { return 4; + } if (boollist->First()) + { return 5; + } if (!boollist->Last()) + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist)) + { return 4; + } TDF_Tool::Entry(reflist->First(), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(reflist->Last(), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr)) + { return 4; + } if (boolarr->Value(15)) + { return 5; + } if (!boolarr->Value(16)) + { return 5; + } if (!boolarr->Value(17)) + { return 5; + } if (!boolarr->Value(18)) + { return 5; + } if (!boolarr->Value(19)) + { return 5; + } if (!boolarr->Value(20)) + { return 5; + } if (boolarr->Value(21)) + { return 5; + } if (!boolarr->Value(22)) + { return 5; + } if (!boolarr->Value(23)) + { return 5; + } if (!boolarr->Value(24)) + { return 5; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr)) + { return 4; + } TDF_Tool::Entry(refarr->Value(0), entry_first); if (entry1 != entry_first) + { return 5; + } TDF_Tool::Entry(refarr->Value(1), entry_last); if (entry2 != entry_last) + { return 6; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr)) + { return 4; + } if (bytearr->Value(15) != 0) + { return 5; + } if (bytearr->Value(16) != 255) + { return 5; + } if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata)) + { return 4; + } if (nameddata->GetByte("A") != 12) + { return 5; + } if (nameddata->GetByte("B") != 234) + { return 5; + } if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref)) + { return 4; + } if (ref->Get().IsNull()) + { return 5; + } if (ref->Get().Tag() != 103) + { return 5; + } return 0; } @@ -3899,7 +4517,9 @@ static int OCC16782(Draw_Interpretor& di, int argc, const char** argv) TCollection_ExtendedString aFile3(argv[3]); if (app.IsNull()) + { app = new AppStd_Application(); + } int good = 0; @@ -3928,9 +4548,13 @@ static int OCC16782(Draw_Interpretor& di, int argc, const char** argv) di << "Status = " << good << "\n"; if (!good) + { di << "\nThe " << argv[0] << " test is passed well, OK\n"; + } else + { di << "\nThe " << argv[0] << " test failed, Faulty\n"; + } return 0; } @@ -3995,9 +4619,13 @@ static int OCC12584(Draw_Interpretor& di, int argc, const char** argv) { bool IsDisplayed = aContext->IsDisplayed(aCS); if (IsDisplayed) + { di << "ColorScaleIsDisplayed = 1\n"; + } else + { di << "ColorScaleIsDisplayed = 0\n"; + } } } return 0; @@ -4118,12 +4746,16 @@ int OCC22301(Draw_Interpretor& di, int argc, const char** argv) // Create mask 1111: extent == 4 TColStd_PackedMapOfInteger aFullMask; for (int i = 0; i < 4; i++) + { aFullMask.Add(i); + } // Create mask 1100: extent == 2 TColStd_PackedMapOfInteger aPartMask; for (int i = 0; i < 2; i++) + { aPartMask.Add(i); + } di << "aFullMask = 1111\n"; di << "aPartMask = 1100\n"; @@ -4144,11 +4776,15 @@ int OCC22301(Draw_Interpretor& di, int argc, const char** argv) int OCC23429(Draw_Interpretor& /*di*/, int narg, const char** a) { if (narg < 4) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } BRepFeat_SplitShape Spls(aShape); Spls.SetCheckInterior(false); @@ -4158,7 +4794,9 @@ int OCC23429(Draw_Interpretor& /*di*/, int narg, const char** a) BRepAlgoAPI_Section Builder(aShape, aTool, false); Builder.ComputePCurveOn1(true); if (narg == 5) + { Builder.Approximation(true); + } Builder.Build(); TopoDS_Shape aSection = Builder.Shape(); @@ -4179,7 +4817,9 @@ int OCC23429(Draw_Interpretor& /*di*/, int narg, const char** a) TopLoc_Location aLoc; occ::handle aSurface = BRep_Tool::Surface(aFace, aLoc); if (aSurface == theSurface && aLoc == theLoc) + { break; + } } Spls.Add(anEdge, aFace); } @@ -4261,7 +4901,9 @@ struct Functor if (theTask.Range.More()) { if (theTask.Mat1.RowNumber() > 1) + { theTask.Mat3 = theTask.Mat1 * theTask.Mat2; + } } theTask.Range.Close(); } @@ -4279,13 +4921,21 @@ int OCC25748(Draw_Interpretor& di, int argc, const char** argv) for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-niter") == 0) + { nIter = Draw::Atoi(argv[++i]); + } else if (strcmp(argv[i], "-matsize") == 0) + { aMatSize = Draw::Atoi(argv[++i]); + } else if (strcmp(argv[i], "-progr") == 0) + { isProgress = true; + } else if (strcmp(argv[i], "-parallel") == 0) + { isParallel = true; + } else { di.PrintHelp("OCC25748"); @@ -4322,11 +4972,17 @@ int OCC25748(Draw_Interpretor& di, int argc, const char** argv) TCollection_AsciiString aText(nIter); aText += (isParallel ? " parallel" : " sequential"); if (aMatSize > 1) + { aText = aText + " calculations on matrices " + aMatSize + "x" + aMatSize; + } else + { aText += " empty tasks"; + } if (isProgress) + { aText += " with progress"; + } di << "COUNTER " << aText << ": " << aTimer.ElapsedTime(); di << "\nCOUNTER " << "including preparations" << ": " << aTimerWhole.ElapsedTime(); return 0; @@ -4470,5 +5126,4 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) __FILE__, OCC31965, group); - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_13.cxx b/src/Draw/TKQADraw/QABugs/QABugs_13.cxx index b7e4eff79f..46708cedaf 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_13.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_13.cxx @@ -77,15 +77,25 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) // Convert arguments if (argc > 1) + { radius_l = Draw::Atof(argv[1]); + } if (argc > 2) + { radius_r = Draw::Atof(argv[2]); + } if (argc > 3) + { bend_angle = Draw::Atof(argv[3]); + } if (argc > 4) + { major_rad = Draw::Atof(argv[4]); + } if (argc > 5) + { wall_thickness = Draw::Atof(argv[5]); + } // mkv 15.07.03 if ((bend_angle >= 2.0*M_PI)) { if ((bend_angle >= 2.0 * M_PI)) @@ -168,7 +178,9 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) mkEdge.Init(SpineCurve); if (!mkEdge.IsDone()) + { return 1; + } TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire(); Sprintf(name, "SpineWire"); @@ -206,7 +218,9 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) mkPipe1.SetLaw(Wire1_, myLaw, Location1, false, false); mkPipe1.Build(); if (!mkPipe1.IsDone()) + { return 1; + } // Make outer pipe shell BRepOffsetAPI_MakePipeShell mkPipe2(SpineWire); @@ -216,7 +230,9 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) mkPipe2.SetLaw(outerWire1_, myLaw2, Location1, false, false); mkPipe2.Build(); if (!mkPipe2.IsDone()) + { return 1; + } // Sprintf(name,"w1-first"); // DBRep::Set(name,mkPipe1.FirstShape()); @@ -248,7 +264,9 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) mkFace.Add(TopoDS::Wire(outerWire1_)); mkFace.Add(TopoDS::Wire(Wire1_.Reversed())); if (!mkFace.IsDone()) + { return 1; + } TopoDS_Face Face1 = mkFace.Face(); // Make face for second opening @@ -257,7 +275,9 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) mkFace.Add(TopoDS::Wire(outerWire2_)); mkFace.Add(TopoDS::Wire(Wire2_.Reversed())); if (!mkFace.IsDone()) + { return 1; + } TopoDS_Face Face2 = mkFace.Face(); // Grab the gas solid now that we've extracted the faces. @@ -381,21 +401,37 @@ static int OCC544(Draw_Interpretor& di, int argc, const char** argv) if (check) { if (!(BRepCheck_Analyzer(wallSolid).IsValid())) + { di << "The TopoDS_Solid was checked, and it was invalid!\n"; + } else + { di << "The TopoDS_Solid was checked, and it was valid.\n"; + } if (!wallSolid.Closed()) + { di << "The TopoDS_Solid is not closed!\n"; + } else + { di << "The TopoDS_Solid is closed.\n"; + } if (!wallSolid.Checked()) + { di << "The TopoDS_Solid is not checked!\n"; + } else + { di << "The TopoDS_Solid has been checked.\n"; + } if (wallSolid.Infinite()) + { di << "The TopoDS_Solid is infinite!\n"; + } else + { di << "The TopoDS_Solid is finite.\n"; + } } di << "The result is a "; @@ -442,6 +478,4 @@ void QABugs::Commands_13(Draw_Interpretor& theCommands) __FILE__, OCC544, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_14.cxx b/src/Draw/TKQADraw/QABugs/QABugs_14.cxx index 16322a4bc9..6e1cff38b2 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_14.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_14.cxx @@ -90,9 +90,13 @@ static int BUC60889(Draw_Interpretor& di, int argc, const char** argv) Draw::Atof(argv[8]), Draw::Atof(argv[9])); if (bnd_box.IsOut(p1, p2, d)) + { di << "The band lies out of the box\n"; + } else + { di << "The band intersects the box\n"; + } return 0; } @@ -101,13 +105,17 @@ static int BUC60889(Draw_Interpretor& di, int argc, const char** argv) static int BUC60852(Draw_Interpretor& di, int argc, const char** argv) { if (argc != 8) + { di << "Usage : " << argv[0] << " name_of_edge bndbox_X1 bndbox_Y1 bndbox_Z1 bndbox_X2 bndbox_Y2 bndbox_Z2\n"; + } else { TopoDS_Edge shape = TopoDS::Edge(DBRep::Get(argv[1])); if (shape.ShapeType() != TopAbs_EDGE) + { di << "shape must be an edge\n"; + } else { BRepAdaptor_Curve curve(shape); @@ -120,9 +128,13 @@ static int BUC60852(Draw_Interpretor& di, int argc, const char** argv) Draw::Atof(argv[6]), Draw::Atof(argv[7])); if (bnd_box.IsOut(lin)) + { di << "Line that lies on edge does not intersect the box\n"; + } else + { di << "Line that lies on edge intersects the box\n"; + } } } return 0; @@ -132,7 +144,9 @@ static int BUC60854(Draw_Interpretor& /*di*/, int argc, const char** argv) { int newnarg; if (argc < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(argv[2]); BRepFeat_SplitShape Spls(S); bool pick = false; @@ -155,7 +169,9 @@ static int BUC60854(Draw_Interpretor& /*di*/, int argc, const char** argv) pick = (argv[i][0] == '.'); EF = DBRep::Get(argv[i], TopAbs_FACE); if (EF.IsNull()) + { return 1; + } } while (i < newnarg) { @@ -173,7 +189,9 @@ static int BUC60854(Draw_Interpretor& /*di*/, int argc, const char** argv) if (argv[i][0] == '-') { if (argv[i][1] == '\0') + { return 1; + } pick = (argv[i][1] == '.'); const char* Temp = argv[i] + 1; W = DBRep::Get(Temp, TopAbs_SHAPE, false); @@ -219,7 +237,9 @@ static int BUC60854(Draw_Interpretor& /*di*/, int argc, const char** argv) } } else + { return 1; + } } i++; while (argv[i][0] != '#') @@ -260,7 +280,9 @@ static int BUC60854(Draw_Interpretor& /*di*/, int argc, const char** argv) return 1; } for (; anIter.More(); anIter.Next()) + { BB.Add(aShell, anIter.Value()); + } aShell.Closed(BRep_Tool::IsClosed(aShell)); DBRep::Set(argv[1], aShell); return 0; @@ -278,9 +300,13 @@ static int BUC60944(Draw_Interpretor& di, int argc, const char** argv) TCollection_AsciiString out; aPath->SystemName(out); if (in == out) + { di << "The conversion is right.\n"; + } else + { di << "Faulty : The conversion is incorrect : " << out.ToCString() << "\n"; + } di << out.ToCString() << "\n"; // std::cout << aPath->Trek() << " !" << std::endl; return 0; @@ -309,7 +335,9 @@ bool BuildWiresWithReshape(const occ::handle& theReshape, aShFixWire->SetPrecision(theTolerance); for (anEdgeIter.Initialize(theListOfEdges); anEdgeIter.More(); anEdgeIter.Next()) + { aWireData->Add(TopoDS::Edge(anEdgeIter.Value())); + } aWireOrder.KeepLoopsMode() = isKeepLoopsMode; aWireAnalyzer = aShFixWire->Analyzer(); @@ -318,7 +346,9 @@ bool BuildWiresWithReshape(const occ::handle& theReshape, aShFixWire->FixReorder(aWireOrder); isDone = !aShFixWire->StatusReorder(ShapeExtend_FAIL); if (!isDone) + { return false; + } if (isFixConnectedMode) { @@ -364,7 +394,9 @@ bool BuildWiresWithReshape(const occ::handle& theReshape, aVlast = aVl; TopExp::Vertices(aCurWire, aVf, aVl); if (aVf.IsSame(aVl)) + { aCurWire.Closed(true); + } theListOfWires.Append(aCurWire); aBuilder.MakeWire(aCurWire); aBuilder.Add(aCurWire, anE); @@ -373,7 +405,9 @@ bool BuildWiresWithReshape(const occ::handle& theReshape, TopExp::Vertices(aCurWire, aVf, aVl); if (aVf.IsSame(aVl)) + { aCurWire.Closed(true); + } theListOfWires.Append(aCurWire); return true; @@ -420,7 +454,9 @@ bool BuildBoundWires(const TopoDS_Shape& theShell, NCollection_List::Iterator aWireIter(aListOfWires); for (; aWireIter.More(); aWireIter.Next()) + { aBld.Add(aRes, aWireIter.Value()); + } } DBRep::Set(argv[1], aRes); @@ -484,9 +526,13 @@ static int BUC60924(Draw_Interpretor& di, int argc, const char** argv) isPlanar = ShapeAnalysis_Curve::IsPlanar(aCurve, aVec, 1e-7); if (isPlanar) + { di << "The curve is planar !\n"; + } else + { di << "Faulty : the curve is not planar!\n"; + } return 0; } @@ -793,14 +839,18 @@ static int OCC1919_real(Draw_Interpretor& di, int argc, const char** argv) { occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, argv[2], L); // TDataStd_Real::Set(L,Draw::Atof(arg[3])); TCollection_AsciiString AsciiStringReal(argv[3]); if (!AsciiStringReal.IsRealValue()) + { return 1; + } double aReal = AsciiStringReal.RealValue(); di << "aReal = " << aReal << "\n"; @@ -821,7 +871,9 @@ static int OCC2932_SetIDUAttribute(Draw_Interpretor& di, int argc, const char** } occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label label; if (!DDF::FindLabel(DF, argv[2], label)) { @@ -856,7 +908,9 @@ static int OCC2932_SetTag(Draw_Interpretor& di, int argc, const char** argv) } occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, argv[2], L); int Tag = Draw::Atoi(argv[3]); @@ -876,7 +930,9 @@ static int OCC2932_SetCurrent(Draw_Interpretor& di, int argc, const char** argv) } occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, argv[2], L); TDataStd_Current::Set(L); @@ -892,7 +948,9 @@ static int OCC2932_SetExpression(Draw_Interpretor& di, int argc, const char** ar } occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, argv[2], L); TCollection_ExtendedString Expression(argv[3]); @@ -912,7 +970,9 @@ static int OCC2932_SetRelation(Draw_Interpretor& di, int argc, const char** argv } occ::handle DF; if (!DDF::GetDF(argv[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, argv[2], L); TCollection_ExtendedString Relation(argv[3]); @@ -989,6 +1049,4 @@ void QABugs::Commands_14(Draw_Interpretor& theCommands) __FILE__, OCC2932_SetRelation, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_16.cxx b/src/Draw/TKQADraw/QABugs/QABugs_16.cxx index f235d8d73d..44660e6190 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_16.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_16.cxx @@ -222,7 +222,9 @@ static int BUC60972(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2], TopAbs_EDGE)); occ::handle aPlane = occ::down_cast(DrawTrSurf::GetSurface(argv[3])); if (aPlane.IsNull()) + { return 1; + } di << aPlane->Pln().SquareDistance(gp_Pnt(0, 0, 0)) << "\n"; @@ -344,9 +346,13 @@ static int OCC295(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape Sh1 = DBRep::Get(argv[2]); TopoDS_Shape Sh2 = DBRep::Get(argv[3]); if (Sh1.IsNull() || Sh2.IsNull()) + { return 1; + } if (Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) + { return 1; + } TopoDS_Edge e1 = TopoDS::Edge(Sh1); TopoDS_Edge e2 = TopoDS::Edge(Sh2); double f1, l1, f2, l2; @@ -356,13 +362,17 @@ static int OCC295(Draw_Interpretor& di, int argc, const char** argv) occ::handle bsplc1 = occ::down_cast(ac1); occ::handle bsplc2 = occ::down_cast(ac2); if (bsplc1.IsNull() || bsplc2.IsNull()) + { return 1; + } gp_Pnt pmid = 0.5 * (bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ()); bsplc1->SetPole(bsplc1->NbPoles(), pmid); bsplc2->SetPole(1, pmid); GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); if (!connect3d.Add(bsplc2, Precision::Confusion(), After, false)) + { return 1; + } BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); if (MkEdge.IsDone()) { @@ -371,7 +381,9 @@ static int OCC295(Draw_Interpretor& di, int argc, const char** argv) return 0; } else + { return 1; + } } static int OCC405(Draw_Interpretor& di, int argc, const char** argv) @@ -385,9 +397,13 @@ static int OCC405(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape Sh1 = DBRep::Get(argv[2]); TopoDS_Shape Sh2 = DBRep::Get(argv[3]); if (Sh1.IsNull() || Sh2.IsNull()) + { return 1; + } if (Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) + { return 1; + } TopoDS_Edge e1 = TopoDS::Edge(Sh1); TopoDS_Edge e2 = TopoDS::Edge(Sh2); double f1, l1, f2, l2; @@ -411,7 +427,9 @@ static int OCC405(Draw_Interpretor& di, int argc, const char** argv) occ::handle bsplc1 = occ::down_cast(ac1); occ::handle bsplc2 = occ::down_cast(ac2); if (bsplc1.IsNull() || bsplc2.IsNull()) + { return 1; + } if (bsplc1->FirstParameter() < f1 - Precision::PConfusion() || bsplc1->LastParameter() > l1 + Precision::PConfusion()) { @@ -431,7 +449,9 @@ static int OCC405(Draw_Interpretor& di, int argc, const char** argv) bsplc2->SetPole(1, pmid); GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); if (!connect3d.Add(bsplc2, Precision::Confusion(), After, false)) + { return 1; + } BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); if (MkEdge.IsDone()) { @@ -440,7 +460,9 @@ static int OCC405(Draw_Interpretor& di, int argc, const char** argv) return 0; } else + { return 1; + } } static int OCC395(Draw_Interpretor& di, int argc, const char** argv) @@ -455,9 +477,13 @@ static int OCC395(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape Sh1 = DBRep::Get(argv[2]); TopoDS_Shape Sh2 = DBRep::Get(argv[3]); if (Sh1.IsNull() || Sh2.IsNull()) + { return 1; + } if (Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) + { return 1; + } TopoDS_Edge e1 = TopoDS::Edge(Sh1); TopoDS_Edge e2 = TopoDS::Edge(Sh2); double f1, l1, f2, l2; @@ -481,13 +507,17 @@ static int OCC395(Draw_Interpretor& di, int argc, const char** argv) occ::handle bsplc1 = occ::down_cast(ac1); occ::handle bsplc2 = occ::down_cast(ac2); if (bsplc1.IsNull() || bsplc2.IsNull()) + { return 1; + } gp_Pnt pmid = 0.5 * (bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ()); bsplc1->SetPole(bsplc1->NbPoles(), pmid); bsplc2->SetPole(1, pmid); GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); if (!connect3d.Add(bsplc2, Precision::Confusion(), After, false)) + { return 1; + } BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); if (MkEdge.IsDone()) { @@ -496,7 +526,9 @@ static int OCC395(Draw_Interpretor& di, int argc, const char** argv) return 0; } else + { return 1; + } } static int OCC394(Draw_Interpretor& di, int argc, const char** argv) @@ -513,13 +545,19 @@ static int OCC394(Draw_Interpretor& di, int argc, const char** argv) int mode = 2; double tolang = M_PI / 2; if (argc > k) + { tol = Draw::Atof(argv[k++]); + } if (argc > k) + { mode = Draw::Atoi(argv[k++]); + } if (argc > k) + { tolang = Draw::Atof(argv[k++]); + } occ::handle aSfwr = new ShapeFix_Wireframe(); occ::handle aReShape = new ShapeBuild_ReShape; @@ -528,7 +566,9 @@ static int OCC394(Draw_Interpretor& di, int argc, const char** argv) aSfwr->SetPrecision(tol); bool aModeDrop = true; if (mode == 2) + { aModeDrop = false; + } NCollection_Map theSmallEdges, theMultyEdges; NCollection_DataMap, TopTools_ShapeMapHasher> @@ -607,7 +647,9 @@ static int OCC261(Draw_Interpretor& di, int argc, const char** argv) return 0; } else + { return 1; + } } #include @@ -623,9 +665,13 @@ static int OCC710(Draw_Interpretor& di, int argc, const char** argv) OSD_File* aFile = new OSD_File(in); bool anExists = aFile->Exists(); if (anExists) + { di << "1\n"; + } else + { di << "0\n"; + } return 0; } @@ -677,6 +723,4 @@ void QABugs::Commands_16(Draw_Interpretor& theCommands) theCommands.Add("OCC261", "OCC261 Doc", __FILE__, OCC261, group); theCommands.Add("OCC710", "OCC710 path", __FILE__, OCC710, group); theCommands.Add("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_17.cxx b/src/Draw/TKQADraw/QABugs/QABugs_17.cxx index cdfcbef8fa..6e7da037bd 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_17.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_17.cxx @@ -138,11 +138,17 @@ static int BUC60843(Draw_Interpretor& di, int argc, const char** argv) double par1 = 0.0, par2 = 0.0; double tol = Precision::Angular(); if (argc >= 5) + { par1 = Draw::Atof(argv[4]); + } if (argc == 6) + { par2 = Draw::Atof(argv[5]); + } if (argc == 7) + { tol = Draw::Atof(argv[6]); + } occ::handle aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]); occ::handle aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]); if (aCur2d1.IsNull() || aCur2d2.IsNull()) @@ -156,7 +162,9 @@ static int BUC60843(Draw_Interpretor& di, int argc, const char** argv) { c1IsCircle = true; if (argc == 6) + { tol = Draw::Atof(argv[5]); + } } if (c1IsCircle) { @@ -451,7 +459,9 @@ static int OCC566(Draw_Interpretor& di, int n, const char** a) } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } Bnd_Box B; BRepBndLib::AddClose(S, B); double axmin, aymin, azmin, axmax, aymax, azmax; @@ -498,7 +508,9 @@ static int MKEVOL(Draw_Interpretor& di, int narg, const char** a) Rake = nullptr; printtolblend(di); if (narg < 3) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); Rake = new BRepFilletAPI_MakeFillet(V); Rake->SetParams(ta, tesp, t2d, t3d, t2d, fl); @@ -528,7 +540,9 @@ static int UPDATEVOL(Draw_Interpretor& di, int narg, const char** a) return 1; } if (narg % 2 != 0 || narg < 4) + { return 1; + } NCollection_Array1 uandr(1, (narg / 2) - 1); double Rad, Par; TopoDS_Shape aLocalEdge(DBRep::Get(a[1], TopAbs_EDGE)); @@ -549,7 +563,9 @@ static int UPDATEVOL(Draw_Interpretor& di, int narg, const char** a) Rake->Add(law, E); } else + { Rake->Add(uandr, E); + } return 0; } @@ -591,9 +607,13 @@ static int OCC606(Draw_Interpretor& di, int n, const char** a) bool TrimMode = (n == 4); if (TrimMode) + { di << "INFO: Using trimmed curves...\n"; + } else + { di << "INFO: Using non trimmed curves...\n"; + } TopoDS_Shape S = DBRep::Get(a[2]); @@ -609,7 +629,9 @@ static int OCC606(Draw_Interpretor& di, int n, const char** a) if (!h_cur.IsNull()) { if (TrimMode) + { h_cur = new Geom_TrimmedCurve(h_cur, f, l); + } n_curves1.Append(h_cur); np.Append(param); @@ -682,15 +704,21 @@ static int OCC884(Draw_Interpretor& di, int argc, const char** argv) ShapeExtend_Status status = ShapeExtend_FAIL1; if (advWA->StatusSelfIntersection(status)) + { di << "Info: No P Curve found in the edge\n"; + } status = ShapeExtend_FAIL2; if (advWA->StatusSelfIntersection(status)) + { di << "Info: No Vertices found in the edge\n"; + } status = ShapeExtend_DONE1; if (advWA->StatusSelfIntersection(status)) + { di << "Info: Self-intersection found in the edge\n"; + } int i, num = points2d.Length(); di << "Info: No. of self-intersection points : " << num << "\n"; @@ -710,9 +738,13 @@ static int OCC884(Draw_Interpretor& di, int argc, const char** argv) sfw->SetFace(face); if (argc > 3) + { sfw->SetPrecision(Draw::Atof(argv[3]) /*0.1*/); + } if (argc > 4) + { sfw->SetMaxTolerance(Draw::Atof(argv[4])); + } di << "Info: Precision is set to " << sfw->Precision() << "\n"; di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n"; @@ -726,51 +758,73 @@ static int OCC884(Draw_Interpretor& di, int argc, const char** argv) status = ShapeExtend_OK; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_OK : No intersection found\n"; + } // printf("Info: ShapeExtend_OK : No intersection found\n"); status = ShapeExtend_FAIL1; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n"; + } status = ShapeExtend_FAIL2; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit " "of increasing tolerance (MaxTolerance)\n"; + } status = ShapeExtend_FAIL3; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed " "because of limit of increasing tolerance (MaxTolerance)\n"; + } status = ShapeExtend_DONE1; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n"; + } status = ShapeExtend_DONE2; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n"; + } status = ShapeExtend_DONE3; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n"; + } status = ShapeExtend_DONE4; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n"; + } status = ShapeExtend_DONE5; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of " "vertex(vertices)\n"; + } status = ShapeExtend_DONE6; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n"; + } status = ShapeExtend_DONE7; if (sfw->StatusSelfIntersection(status)) + { di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n"; + } return 0; } @@ -882,14 +936,20 @@ static int OCC1642(Draw_Interpretor& di, int argc, const char** argv) ShapeExtend_Status status = ShapeExtend_FAIL1; if (advWA->StatusSelfIntersection(status)) + { status = ShapeExtend_FAIL2; + } if (advWA->StatusSelfIntersection(status)) + { di << "\n No Vertices found in the edge"; + } status = ShapeExtend_DONE1; if (advWA->StatusSelfIntersection(status)) + { di << "\n Self-intersection found in the edge"; + } num = points2d.Length(); di << "\n No. of self-intersecting edges : " << num; @@ -935,50 +995,72 @@ static int OCC1642(Draw_Interpretor& di, int argc, const char** argv) ShapeExtend_Status status = ShapeExtend_OK; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_OK : No intersection found"; + } status = ShapeExtend_FAIL1; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)"; + } status = ShapeExtend_FAIL2; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of " "increasing tolerance (MaxTolerance)"; + } status = ShapeExtend_FAIL3; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because " "of limit of increasing tolerance (MaxTolerance)"; + } status = ShapeExtend_DONE1; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection"; + } status = ShapeExtend_DONE2; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection"; + } status = ShapeExtend_DONE3; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection"; + } status = ShapeExtend_DONE4; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified"; + } status = ShapeExtend_DONE5; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of " "vertex(vertices)"; + } status = ShapeExtend_DONE6; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection"; + } status = ShapeExtend_DONE7; if (sfw->StatusSelfIntersection(status)) + { di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection"; + } TopoDS_Wire finalwire = sfw->Wire(); @@ -1006,14 +1088,20 @@ static int OCC1642(Draw_Interpretor& di, int argc, const char** argv) status = ShapeExtend_FAIL1; if (advWA->StatusSelfIntersection(status)) + { status = ShapeExtend_FAIL2; + } if (advWA->StatusSelfIntersection(status)) + { di << "\n No Vertices found in the edge"; + } status = ShapeExtend_DONE1; if (advWA->StatusSelfIntersection(status)) + { di << "\n Self-intersection found in the edge"; + } num = points2d.Length(); di << "\n No. of self-intersecting edges : " << num; @@ -1086,6 +1174,4 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) __FILE__, OCC1642, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_18.cxx b/src/Draw/TKQADraw/QABugs/QABugs_18.cxx index 955356d4ca..fd4d5b8119 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_18.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_18.cxx @@ -43,7 +43,9 @@ static int OCC267(Draw_Interpretor& di, int argc, const char** argv) occ::handle D; if (!DDocStd::GetDocument(argv[1], D)) + { return 1; + } TCollection_ExtendedString path(argv[2]); occ::handle A = DDocStd::GetApplication(); @@ -104,7 +106,9 @@ static int OCC367(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); TopExp::Vertices(edge, ve1, ve2); if (vw1.IsSame(ve1) || vw1.IsSame(ve2)) + { vlast = vw1; + } else { Standard_ASSERT_RAISE(vw2.IsSame(ve1) || vw2.IsSame(ve2), "Disconnected vertices"); @@ -147,7 +151,9 @@ static int OCC367(Draw_Interpretor& di, int argc, const char** argv) curve.Load(acurve); algo.Initialize(curve, l, newufirst, newulast); if (!algo.IsDone()) + { di << "Not Done!!!" << "\n"; + } int maxIndex = algo.NbPoints(); for (int Index = 1; Index <= maxIndex; Index++) { @@ -194,6 +200,4 @@ void QABugs::Commands_18(Draw_Interpretor& theCommands) __FILE__, OCC367, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_19.cxx b/src/Draw/TKQADraw/QABugs/QABugs_19.cxx index aa8a37bf92..3997948aa6 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_19.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_19.cxx @@ -116,7 +116,9 @@ Standard_DISABLE_DEPRECATION_WARNINGS return false; } else + { di << "Dist0 = " << distShapeShape.Value() << "\n"; + } ////////////////////////////////////////////////////////////////////////// /// First Flip Y @@ -141,14 +143,18 @@ Standard_DISABLE_DEPRECATION_WARNINGS step1ModifiedShape, Extrema_ExtFlag_MIN); if (!distShapeShape1.IsDone()) + { return false; + } if (distShapeShape1.Value() > 0.01) { di << "Dist = " << distShapeShape1.Value() << "\n"; return false; } else + { di << "Dist1 = " << distShapeShape1.Value() << "\n"; + } ////////////////////////////////////////////////////////////////////////// /// Second flip Y @@ -168,7 +174,9 @@ Standard_DISABLE_DEPRECATION_WARNINGS BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN); // clang-format on if (!distShapeShape2.IsDone()) + { return false; + } // This last test case give error (the value is 1008.8822038689706) if (distShapeShape2.Value() > 0.01) @@ -177,9 +185,11 @@ Standard_DISABLE_DEPRECATION_WARNINGS int N = distShapeShape2.NbSolution(); di << "Nb = " << N << "\n"; for (int i = 1; i <= N; i++) + { di << "Sol(" << i << ") = " << distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) << "\n"; + } return false; } di << "Distance2 = " << distShapeShape2.Value() << "\n"; @@ -205,7 +215,9 @@ static int OCC23774(Draw_Interpretor& di, int n, const char** a) } const TopoDS_Face& aFace = TopoDS::Face(S1); if (!OCC23774Test(aFace, S2, di)) + { di << "Something is wrong\n"; + } return 0; } @@ -232,24 +244,24 @@ static void* GeomConvertTest(void* data) GeomConvert_ApproxSurface aGAS(info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1); if (!aGAS.IsDone()) { - std::cout << "Error: ApproxSurface is not done!" << std::endl; + std::cout << "Error: ApproxSurface is not done!" << '\n'; return nullptr; } const occ::handle& aBSurf = aGAS.Surface(); if (aBSurf.IsNull()) { - std::cout << "Error: BSplineSurface is not created!" << std::endl; + std::cout << "Error: BSplineSurface is not created!" << '\n'; return nullptr; } std::cout << "Number of UPoles:" << aBSurf->NbUPoles(); if (aBSurf->NbUPoles() == info->nbupoles) { - std::cout << ": OK" << std::endl; + std::cout << ": OK" << '\n'; return data; // any non-null pointer } else { - std::cout << ": Error, must be " << info->nbupoles << std::endl; + std::cout << ": Error, must be " << info->nbupoles << '\n'; return nullptr; } } @@ -258,7 +270,7 @@ static int OCC23952sweep(Draw_Interpretor& di, int argc, const char** argv) { if (argc != 3) { - std::cout << "Error: invalid number of arguments" << std::endl; + std::cout << "Error: invalid number of arguments" << '\n'; return 1; } @@ -267,7 +279,7 @@ static int OCC23952sweep(Draw_Interpretor& di, int argc, const char** argv) aStorage.surf = DrawTrSurf::GetSurface(argv[2]); if (aStorage.surf.IsNull()) { - std::cout << "Error: " << argv[2] << " is not a DRAW surface!" << std::endl; + std::cout << "Error: " << argv[2] << " is not a DRAW surface!" << '\n'; return 0; } @@ -278,7 +290,9 @@ static int OCC23952sweep(Draw_Interpretor& di, int argc, const char** argv) { aThread[i].SetFunction(GeomConvertTest); if (!aThread[i].Run(&aStorage)) + { di << "Error: Cannot start thread << " << i << "\n"; + } } // check results @@ -286,9 +300,13 @@ static int OCC23952sweep(Draw_Interpretor& di, int argc, const char** argv) { void* aResult = nullptr; if (!aThread[i].Wait(aResult)) + { di << "Error: Failed waiting for thread << " << i << "\n"; + } if (!aResult) + { di << "Error: wrong number of poles in thread " << i << "!\n"; + } } return 0; @@ -312,19 +330,19 @@ static void* GeomIntSSTest(void* data) anInter.Perform(info->surf1, info->surf2, Precision::Confusion(), true); if (!anInter.IsDone()) { - std::cout << "An intersection is not done!" << std::endl; + std::cout << "An intersection is not done!" << '\n'; return nullptr; } std::cout << "Number of Lines:" << anInter.NbLines(); if (anInter.NbLines() == info->nbsol) { - std::cout << ": OK" << std::endl; + std::cout << ": OK" << '\n'; return data; // any non-null pointer } else { - std::cout << ": Error, must be " << info->nbsol << std::endl; + std::cout << ": Error, must be " << info->nbsol << '\n'; return nullptr; } } @@ -333,7 +351,7 @@ static int OCC23952intersect(Draw_Interpretor& di, int argc, const char** argv) { if (argc != 4) { - std::cout << "Error: invalid number of arguments" << std::endl; + std::cout << "Error: invalid number of arguments" << '\n'; return 1; } @@ -344,7 +362,7 @@ static int OCC23952intersect(Draw_Interpretor& di, int argc, const char** argv) if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull()) { std::cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" - << std::endl; + << '\n'; return 0; } @@ -355,7 +373,9 @@ static int OCC23952intersect(Draw_Interpretor& di, int argc, const char** argv) { aThread[i].SetFunction(GeomIntSSTest); if (!aThread[i].Run(&aStorage)) + { di << "Error: Cannot start thread << " << i << "\n"; + } } // check results @@ -363,9 +383,13 @@ static int OCC23952intersect(Draw_Interpretor& di, int argc, const char** argv) { void* aResult = nullptr; if (!aThread[i].Wait(aResult)) + { di << "Error: Failed waiting for thread << " << i << "\n"; + } if (!aResult) + { di << "Error: wrong number of intersections in thread " << i << "!\n"; + } } return 0; @@ -496,11 +520,15 @@ static int OCC24008(Draw_Interpretor& di, int argc, const char** argv) static int OCC23945(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle aS = DrawTrSurf::GetSurface(a[1]); if (aS.IsNull()) + { return 1; + } GeomAdaptor_Surface GS(aS); @@ -509,7 +537,9 @@ static int OCC23945(Draw_Interpretor& /*di*/, int n, const char** a) bool DrawPoint = (n % 3 == 2); if (DrawPoint) + { n--; + } gp_Pnt P; if (n >= 13) @@ -530,7 +560,9 @@ static int OCC23945(Draw_Interpretor& /*di*/, int n, const char** a) Draw::Set(a[21], D2UV.Z()); } else + { GS.D1(U, V, P, DU, DV); + } Draw::Set(a[7], DU.X()); Draw::Set(a[8], DU.Y()); @@ -540,7 +572,9 @@ static int OCC23945(Draw_Interpretor& /*di*/, int n, const char** a) Draw::Set(a[12], DV.Z()); } else + { GS.D0(U, V, P); + } if (n > 6) { @@ -625,12 +659,12 @@ static int OCC24137(Draw_Interpretor& theDI, int theNArg, const char** theArgv) const int aNbIts = (anArgIter < theNArg) ? Draw::Atoi(theArgv[anArgIter++]) : 100; if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE) { - std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl; + std::cout << "Error: " << aFaceName << " shape is null / not a face" << '\n'; return 1; } if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX) { - std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl; + std::cout << "Error: " << aVertName << " shape is null / not a vertex" << '\n'; return 1; } const TopoDS_Face aFace = TopoDS::Face(aShapeF); @@ -774,29 +808,41 @@ static int OCC24667(Draw_Interpretor& di, int n, const char** a) } if (n > 1 && n < 4) + { return 1; + } TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_WIRE); if (Spine.IsNull()) + { return 1; + } TopoDS_Shape Profile = DBRep::Get(a[3]); if (Profile.IsNull()) + { return 1; + } GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; if (n >= 5) { int iMode = atoi(a[4]); if (iMode == 1) + { Mode = GeomFill_IsFrenet; + } else if (iMode == 2) + { Mode = GeomFill_IsDiscreteTrihedron; + } } bool ForceApproxC1 = false; if (n >= 6) + { ForceApproxC1 = true; + } BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine), Profile, Mode, ForceApproxC1); @@ -1092,7 +1138,9 @@ static int OCC25043(Draw_Interpretor& theDI, int theArgNb, const char** theArgVe for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next()) { if (anExp.Current().IsEqual(aFaultyShape)) + { anIsFaultyShapeFound = true; + } } if (!anIsFaultyShapeFound) @@ -1320,12 +1368,14 @@ static int OCC25413(Draw_Interpretor& di, int narg, const char** a) double zStep = (zMax - zMin) / N; for (double x = xMin; x <= xMax; x += xStep) + { for (double z = zMin; z <= zMax; z += zStep) { gp_Pnt aPoint(x, 0.0, z); gp_Lin aLine(aPoint, aDir); Inter.PerformNearest(aLine, -100., 100.); } + } return 0; } @@ -1561,11 +1611,17 @@ static ShapeExtend_Status getStatusGap(const occ::handle& theFix, { bool isFound; if (theIs3d) + { isFound = theFix->StatusGaps3d((ShapeExtend_Status)i); + } else + { isFound = theFix->StatusGaps2d((ShapeExtend_Status)i); + } if (isFound) + { return ShapeExtend_Status(i); + } } return ShapeExtend_OK; } @@ -1614,21 +1670,29 @@ static int OCC24881(Draw_Interpretor& di, int narg, const char** a) // not fixed, why? aStatus = getStatusGap(aWireFix, true); if (aStatus == ShapeExtend_OK) + { wasOk = true; + } else { // keep 3d fail status if (aStatusNbDMap.IsBound(aStatus)) + { aStatusNbDMap(aStatus)++; + } else + { aStatusNbDMap.Bind(aStatus, 1); + } continue; } } // fix 2d if (aWireFix->FixGaps2d()) + { nbFixed++; + } else { aStatus = getStatusGap(aWireFix, false); @@ -1640,16 +1704,22 @@ static int OCC24881(Draw_Interpretor& di, int narg, const char** a) continue; } else + { nbFixed++; + } } else { // keep 2d fail status int aStatus2d = aStatus + ShapeExtend_FAIL; if (aStatusNbDMap.IsBound(aStatus2d)) + { aStatusNbDMap(aStatus2d)++; + } else + { aStatusNbDMap.Bind(aStatus2d, 1); + } continue; } } @@ -1870,7 +1940,9 @@ static int OCC26485(Draw_Interpretor& theDI, int theArgNb, const char** theArgVe const occ::handle& aT = BRep_Tool::Triangulation(aFace, L); if (aT.IsNull()) + { continue; + } Poly::ComputeNormals(aT); @@ -2120,7 +2192,9 @@ static int OCC26462(Draw_Interpretor& theDI, int /*theArgNb*/, const char** /*th static int OCC26313(Draw_Interpretor& di, int n, const char** a) { if (n <= 1) + { return 1; + } gp_Trsf T; gp_GTrsf GT(T); @@ -2314,17 +2388,23 @@ static int OCC26396(Draw_Interpretor& theDI, int theArgc, const char** theArgv) break; } for (size_t j = 0; j < coords.Size(); j++) + { if (std::abs(ref_coords[j] - coords[j]) > RealEpsilon()) { Stat = false; break; } + } coords.Clear(); } if (!Stat) + { theDI << "Error: unstable results"; + } else + { theDI << "test OK"; + } return 0; } @@ -2337,7 +2417,7 @@ static int OCC27048(Draw_Interpretor& theDI, int theArgc, const char** theArgv) { if (theArgc != 5) { - std::cout << "Incorrect number of arguments. See usage:" << std::endl; + std::cout << "Incorrect number of arguments. See usage:" << '\n'; theDI.PrintHelp(theArgv[0]); return 1; } @@ -2350,7 +2430,9 @@ static int OCC27048(Draw_Interpretor& theDI, int theArgc, const char** theArgv) int aN = Draw::Atoi(theArgv[4]); for (; aN > 0; --aN) + { anAdaptor.Value(aU, aV); + } return 0; } @@ -2500,7 +2582,7 @@ static int OCC27700(Draw_Interpretor& /*theDI*/, int /*theArgNb*/, const char** occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) { - std::cout << "Error: no view available, call 'vinit' before!" << std::endl; + std::cout << "Error: no view available, call 'vinit' before!" << '\n'; return 1; } occ::handle aPresentation = new OCC27700_Text(); @@ -2839,5 +2921,4 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) __FILE__, OCC29412, group); - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_2.cxx b/src/Draw/TKQADraw/QABugs/QABugs_2.cxx index 417ef7a0ca..1b22fd7af5 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_2.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_2.cxx @@ -85,7 +85,9 @@ static int OCC527(Draw_Interpretor& di, int argc, const char** argv) { // If plane of the section does not intersect BndBox of the face do nothing if (zcur < Z1 || zcur > Z2) + { continue; + } // Build current section gp_Pln pl(0, 0, 1, -zcur); @@ -110,13 +112,19 @@ static int OCC527(Draw_Interpretor& di, int argc, const char** argv) double toler = BRep_Tool::Tolerance(aV); double dist = pl.Distance(BRep_Tool::Pnt(aV)); if (dist > lmaxdist) + { lmaxdist = dist; + } // If section was built check distance between vertexes and plane of the one str[0] = 0; if (dist > toler) + { Sprintf(str, "Dist=%f, Toler=%f, Param=%f FAULTY\n", dist, toler, gzmax); + } else + { Sprintf(str, "Dist=%f, Toler=%f, Param=%f\n", dist, toler, gzmax); + } di << str; } if (lmaxdist > gmaxdist) @@ -143,5 +151,4 @@ void QABugs::Commands_2(Draw_Interpretor& theCommands) const char* group = "QABugs"; theCommands.Add("OCC527", "OCC527 shape", __FILE__, OCC527, group); - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_20.cxx b/src/Draw/TKQADraw/QABugs/QABugs_20.cxx index 20aa88b566..525a821a8a 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_20.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_20.cxx @@ -116,7 +116,7 @@ static int OCC27021(Draw_Interpretor& theDI, int theNArg, const char** theArgVal { if (theNArg != 2) { - std::cout << "Use: " << theArgVal[0] << " shape" << std::endl; + std::cout << "Use: " << theArgVal[0] << " shape" << '\n'; return 1; } @@ -192,13 +192,19 @@ static int OCC27235(Draw_Interpretor& theDI, int n, const char** a) { occ::handle aDimAttr; if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr)) + { continue; + } occ::handle anObject = aDimAttr->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { B.Add(aPresentations, aShape); + } } aGDTs.Clear(); @@ -207,13 +213,19 @@ static int OCC27235(Draw_Interpretor& theDI, int n, const char** a) { occ::handle aGTAttr; if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) + { continue; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { B.Add(aPresentations, aShape); + } } for (int i = 1; i <= aLabels.Length(); i++) @@ -225,13 +237,19 @@ static int OCC27235(Draw_Interpretor& theDI, int n, const char** a) { occ::handle aDat; if (!aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat)) + { continue; + } occ::handle anObject = aDat->GetObject(); if (anObject.IsNull()) + { continue; + } TopoDS_Shape aShape = anObject->GetPresentation(); if (!aShape.IsNull()) + { B.Add(aPresentations, aShape); + } } } } @@ -251,7 +269,7 @@ static int OCC26930(Draw_Interpretor& theDI, int theNArg, const char** theArgVal { if (theNArg != 5) { - std::cout << "Use: " << theArgVal[0] << " surface curve start end" << std::endl; + std::cout << "Use: " << theArgVal[0] << " surface curve start end" << '\n'; return 1; } @@ -302,19 +320,25 @@ static int OCC27466(Draw_Interpretor& theDI, int theNArg, const char** theArgVal { if (theNArg != 4) { - std::cout << "Use: " << theArgVal[0] << " face point start_pnt2d" << std::endl; + std::cout << "Use: " << theArgVal[0] << " face point start_pnt2d" << '\n'; return 1; } TopoDS_Face aFace = TopoDS::Face(DBRep::Get(theArgVal[1], TopAbs_FACE, true)); if (aFace.IsNull()) + { return 1; + } gp_Pnt aPnt; if (!DrawTrSurf::GetPoint(theArgVal[2], aPnt)) + { return 1; + } gp_Pnt2d aUV; if (!DrawTrSurf::GetPoint2d(theArgVal[3], aUV)) + { return 1; + } BRepAdaptor_Surface aSurf(aFace); constexpr double aTolU = Precision::PConfusion(); @@ -564,15 +588,21 @@ static int OCC28389(Draw_Interpretor& di, int argc, const char** argv) NCollection_Sequence aSequence; aViewTool->GetRefShapeLabel(aLabel, aSequence); if (aSequence.Length() != nbShapes) + { isOK = false; + } aSequence.Clear(); aViewTool->GetRefGDTLabel(aLabel, aSequence); if (aSequence.Length() != nbGDTs) + { isOK = false; + } aSequence.Clear(); aViewTool->GetRefClippingPlaneLabel(aLabel, aSequence); if (aSequence.Length() != nbPlanes) + { isOK = false; + } if (!isOK) { di << "Error: Wrong references"; @@ -587,9 +617,13 @@ static int OCC28389(Draw_Interpretor& di, int argc, const char** argv) XCAFView_ProjectionType aType = XCAFView_ProjectionType_NoCamera; if (argv[7][0] == 'p') + { aType = XCAFView_ProjectionType_Parallel; + } else if (argv[7][0] == 'c') + { aType = XCAFView_ProjectionType_Central; + } if (anObj->Type() != aType) { @@ -625,9 +659,13 @@ static int OCC28389(Draw_Interpretor& di, int argc, const char** argv) } if (fabs(anObj->WindowHorizontalSize() - Draw::Atof(argv[18])) > Precision::Confusion()) + { isOK = false; + } if (fabs(anObj->WindowVerticalSize() - Draw::Atof(argv[19])) > Precision::Confusion()) + { isOK = false; + } if (!isOK) { di << "Error: Wrong Window size"; @@ -641,11 +679,15 @@ static int OCC28389(Draw_Interpretor& di, int argc, const char** argv) static int OCC28784(Draw_Interpretor&, int argc, const char** argv) { if (argc < 3) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(argv[2]); if (aShape.IsNull()) + { return 1; + } gp_Ax2 aPlane(gp::Origin(), gp::DX(), -gp::DZ()); HLRAlgo_Projector aProjector(aPlane); @@ -667,7 +709,7 @@ static int OCC28784(Draw_Interpretor&, int argc, const char** argv) static int OCC28829(Draw_Interpretor&, int, const char**) { // do something that causes FPE exception - std::cout << "sqrt(-1) = " << sqrt(-1.) << std::endl; + std::cout << "sqrt(-1) = " << sqrt(-1.) << '\n'; return 0; } @@ -760,7 +802,7 @@ static int OCC29311(Draw_Interpretor& theDI, int theArgc, const char** theArgv) { if (theArgc < 4) { - std::cerr << "Use: " << theArgv[0] << " shape counter_name nb_iterations" << std::endl; + std::cerr << "Use: " << theArgv[0] << " shape counter_name nb_iterations" << '\n'; return 1; } @@ -797,7 +839,9 @@ static int OCC30391(Draw_Interpretor& theDI, int theNArg, const char** theArgV) TopoDS_Shape aShape = DBRep::Get(theArgV[2], TopAbs_FACE); if (aShape.IsNull()) + { return 1; + } const TopoDS_Face& aFace = TopoDS::Face(aShape); @@ -851,15 +895,25 @@ static int OCC29745(Draw_Interpretor& theDI, int theArgc, const char** theArgv) int i = Draw::Atoi(theArgv[2]); GeomAbs_Shape aCont = GeomAbs_C0; if (i <= 0) + { aCont = GeomAbs_C0; + } else if (i == 1) + { aCont = GeomAbs_C1; + } else if (i == 2) + { aCont = GeomAbs_C2; + } else if (i == 3) + { aCont = GeomAbs_C3; + } else if (i >= 4) + { aCont = GeomAbs_CN; + } double t1 = Draw::Atof(theArgv[3]); double t2 = Draw::Atof(theArgv[4]); @@ -1013,7 +1067,7 @@ static int OCC29195(Draw_Interpretor&, int theArgC, const char** theArgV) std::cout << "\nnbRep - number repetitions of a thread function (by default - 50)"; std::cout << "\ndocN - names (5 in each group) of OCAF documents names (3 input files, 2 output)\n" - << std::endl; + << '\n'; return 1; } int iThread(0), off(0); @@ -1137,7 +1191,9 @@ static int OCC30435(Draw_Interpretor& di, int, const char** a) occ::handle GC; GC = DrawTrSurf::GetCurve(a[2]); if (GC.IsNull()) + { return 1; + } int Dmin = 3; int Dmax = 12; @@ -1157,7 +1213,9 @@ static int OCC30435(Draw_Interpretor& di, int, const char** a) anAppro.SetInvOrder(inverse); int i; for (i = 1; i <= maxit; ++i) + { anAppro.Perform(aCE); + } if (!anAppro.IsAllApproximated()) { @@ -1507,7 +1565,9 @@ static int OCC26441(Draw_Interpretor& theDi, int theNbArgs, const char** theArgV { int Inc = Draw::Atoi(theArgVec[4]); if (Inc > 0) + { isAllDiff = true; + } } BRep_Builder aBB; @@ -1533,16 +1593,22 @@ static int OCC26441(Draw_Interpretor& theDi, int theNbArgs, const char** theArgV } const TopoDS_Edge& anE = TopoDS::Edge(anExp.Current()); if (!aChecked.Add(anE)) + { continue; + } double aTolRef = BRep_Tool::Tolerance(aRefE); double aTol = BRep_Tool::Tolerance(anE); double aDiff = aTol - aTolRef; if (isAllDiff && aDiff < 0) + { aDiff = -aDiff; + } if (aDiff > anEps) { if (aDiff > aMaxE) + { aMaxE = aDiff; + } aBB.Add(aBadEdges, anE); } @@ -1552,16 +1618,22 @@ static int OCC26441(Draw_Interpretor& theDi, int theNbArgs, const char** theArgV for (int i = 0; i < 2; ++i) { if (aRefV[i].IsNull()) + { continue; + } if (!aChecked.Add(aV[i])) + { continue; + } aTolRef = BRep_Tool::Tolerance(aRefV[i]); aTol = BRep_Tool::Tolerance(aV[i]); aDiff = aTol - aTolRef; if (aDiff > anEps) { if (aDiff > aMaxV) + { aMaxV = aDiff; + } aBB.Add(aBadVerts, aV[i]); } @@ -1663,6 +1735,4 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) __FILE__, OCC26441, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_3.cxx b/src/Draw/TKQADraw/QABugs/QABugs_3.cxx index fae0e4ba08..629d1901da 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_3.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_3.cxx @@ -62,7 +62,9 @@ static int BUC60623(Draw_Interpretor& di, int argc, const char** a) return 0; } else + { di << "The first solution is Null!" << "\n"; + } di << "fini\n"; return 0; @@ -187,9 +189,13 @@ static int BUC60792(Draw_Interpretor& di, int /*argc*/, const char** argv) DBRep::Set(aStr, sh); occ::handle ais = new AIS_Shape(sh); if (i == 1) + { aContext->SetColor(ais, Quantity_NOC_GREEN, false); + } if (i == 2) + { aContext->SetColor(ais, Quantity_NOC_HOTPINK, false); + } aContext->Display(ais, false); double ParSol1, ParSol2, ParArg1, ParArg2; gp_Pnt2d PntSol1, PntSol2; @@ -588,7 +594,9 @@ static int statface(Draw_Interpretor& di, int /*argc*/, const char** argv) aString = aSurface->DynamicType()->Name(); if (aMap.IsBound(aString)) + { aMap.ChangeFind(aString)++; + } else { aMap.Bind(aString, 1); @@ -608,7 +616,9 @@ static int statface(Draw_Interpretor& di, int /*argc*/, const char** argv) occ::handle aCurve2d = BRep_Tool::CurveOnSurface(Edge, aFace, f3d, l3d); aString = aCurve2d->DynamicType()->Name(); if (aMap.IsBound(aString)) + { aMap.ChangeFind(aString)++; + } else { aMap.Bind(aString, 1); diff --git a/src/Draw/TKQADraw/QABugs/QABugs_5.cxx b/src/Draw/TKQADraw/QABugs/QABugs_5.cxx index a1f19b3e53..f955cb2fd0 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_5.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_5.cxx @@ -43,7 +43,9 @@ static int OCC6001(Draw_Interpretor& di, int argc, const char** argv) occ::handle hcurve; occ::handle curve = DrawTrSurf::GetCurve(argv[2]); if (!curve.IsNull()) + { hcurve = new GeomAdaptor_Curve(curve); + } else { TopoDS_Shape wire = DBRep::Get(argv[2]); @@ -89,6 +91,4 @@ void QABugs::Commands_5(Draw_Interpretor& theCommands) __FILE__, OCC6001, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_6.cxx b/src/Draw/TKQADraw/QABugs/QABugs_6.cxx index dc39de06b9..0e1b444ff8 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_6.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_6.cxx @@ -127,6 +127,4 @@ void QABugs::Commands_6(Draw_Interpretor& theCommands) const char* group = "QABugs"; theCommands.Add("OCC281", "OCC281 x y TypeOfMarker(0-12)", __FILE__, OCC281bug, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_8.cxx b/src/Draw/TKQADraw/QABugs/QABugs_8.cxx index d3c04475cc..81284f6660 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_8.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_8.cxx @@ -42,7 +42,9 @@ static int OCC162(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape aShape = DBRep::Get(argv[1]); if (aShape.IsNull()) + { return 0; + } double tolValue = 0.0001; BRepOffsetAPI_Sewing sew(tolValue); @@ -143,7 +145,9 @@ static int OCC1651(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape aShape = DBRep::Get(argv[1]); if (aShape.IsNull()) + { return 0; + } gp_Pnt aP1(Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4])); gp_Dir aD1(Draw::Atof(argv[5]), Draw::Atof(argv[6]), Draw::Atof(argv[7])); @@ -171,6 +175,4 @@ void QABugs::Commands_8(Draw_Interpretor& theCommands) __FILE__, OCC1651, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_9.cxx b/src/Draw/TKQADraw/QABugs/QABugs_9.cxx index d78cc1fac9..71e3e2c462 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_9.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_9.cxx @@ -76,6 +76,4 @@ void QABugs::Commands_9(Draw_Interpretor& theCommands) const char* group = "QABugs"; theCommands.Add("BUC60857", "BUC60857", __FILE__, BUC60857, group); - - return; } diff --git a/src/Draw/TKQADraw/QABugs/QABugs_BVH.cxx b/src/Draw/TKQADraw/QABugs/QABugs_BVH.cxx index dbd28ab286..13ebaf0359 100644 --- a/src/Draw/TKQADraw/QABugs/QABugs_BVH.cxx +++ b/src/Draw/TKQADraw/QABugs/QABugs_BVH.cxx @@ -162,7 +162,7 @@ static int QABVH_ShapeSelect(Draw_Interpretor& theDI, int theArgc, const char** TopoDS_Shape aShape = DBRep::Get(theArgv[2]); if (aShape.IsNull()) { - std::cout << theArgv[2] << " does not exist" << std::endl; + std::cout << theArgv[2] << " does not exist" << '\n'; return 1; } @@ -170,14 +170,16 @@ static int QABVH_ShapeSelect(Draw_Interpretor& theDI, int theArgc, const char** TopoDS_Shape aBShape = DBRep::Get(theArgv[3]); if (aBShape.IsNull()) { - std::cout << theArgv[3] << " does not exist" << std::endl; + std::cout << theArgv[3] << " does not exist" << '\n'; return 1; } // Which selector to use bool useVoidSelector = false; if (theArgc > 4) + { useVoidSelector = !strcmp(theArgv[4], "-void"); + } // Define BVH Builder opencascade::handle> aLBuilder = new BVH_LinearBuilder(); @@ -237,7 +239,9 @@ static int QABVH_ShapeSelect(Draw_Interpretor& theDI, int theArgc, const char** BRep_Builder().MakeCompound(aResult); for (NCollection_List::Iterator it(aSelectedShapes); it.More(); it.Next()) + { BRep_Builder().Add(aResult, it.Value()); + } DBRep::Set(theArgv[1], aResult); return 0; @@ -359,7 +363,7 @@ static int QABVH_PairSelect(Draw_Interpretor& theDI, int theArgc, const char** t aShape[0] = DBRep::Get(theArgv[2]); if (aShape[0].IsNull()) { - std::cout << theArgv[2] << " does not exist" << std::endl; + std::cout << theArgv[2] << " does not exist" << '\n'; return 1; } @@ -367,14 +371,16 @@ static int QABVH_PairSelect(Draw_Interpretor& theDI, int theArgc, const char** t aShape[1] = DBRep::Get(theArgv[3]); if (aShape[1].IsNull()) { - std::cout << theArgv[3] << " does not exist" << std::endl; + std::cout << theArgv[3] << " does not exist" << '\n'; return 1; } // Which selector to use bool useVoidSelector = false; if (theArgc > 4) + { useVoidSelector = !strcmp(theArgv[4], "-void"); + } // Define BVH Builder opencascade::handle> aLBuilder = new BVH_LinearBuilder(); @@ -493,7 +499,9 @@ static double TriangleTriangleSqDistance(const BVH_Vec3d& theNode11, { aMinDist = aDist; if (aMinDist == 0) + { return aMinDist; + } } } @@ -509,7 +517,9 @@ static double TriangleTriangleSqDistance(const BVH_Vec3d& theNode11, BVH_Vec3d anEdge = (aPLast - aPFirst); double aLength = anEdge.Modulus(); if (aLength < Precision::Confusion()) + { continue; + } anEdge /= aLength; double aDelta = aLength / aNbSeg; @@ -525,7 +535,9 @@ static double TriangleTriangleSqDistance(const BVH_Vec3d& theNode11, { aMinDist = aDist; if (aMinDist == 0) + { return aMinDist; + } } } } @@ -582,7 +594,7 @@ static int QABVH_PairDistance(Draw_Interpretor& theDI, int theArgc, const char** aShape[0] = DBRep::Get(theArgv[1]); if (aShape[0].IsNull()) { - std::cout << theArgv[1] << " does not exist" << std::endl; + std::cout << theArgv[1] << " does not exist" << '\n'; return 1; } @@ -590,7 +602,7 @@ static int QABVH_PairDistance(Draw_Interpretor& theDI, int theArgc, const char** aShape[1] = DBRep::Get(theArgv[2]); if (aShape[1].IsNull()) { - std::cout << theArgv[2] << " does not exist" << std::endl; + std::cout << theArgv[2] << " does not exist" << '\n'; return 1; } @@ -647,9 +659,13 @@ static int QABVH_PairDistance(Draw_Interpretor& theDI, int theArgc, const char** aDistTool.SetBVHSets(aTriangleBoxSet[0].get(), aTriangleBoxSet[1].get()); double aSqDist = aDistTool.ComputeDistance(); if (!aDistTool.IsDone()) - std::cout << "Not Done" << std::endl; + { + std::cout << "Not Done" << '\n'; + } else + { theDI << "Distance " << sqrt(aSqDist) << "\n"; + } return 0; } @@ -747,7 +763,7 @@ static int QABVH_DistanceField(Draw_Interpretor& theDI, int theArgc, const char* aShape = DBRep::Get(theArgv[1]); if (aShape.IsNull()) { - std::cout << theArgv[1] << " does not exist" << std::endl; + std::cout << theArgv[1] << " does not exist" << '\n'; return 1; } @@ -770,7 +786,7 @@ static int QABVH_DistanceField(Draw_Interpretor& theDI, int theArgc, const char* for (int iZ = 0; iZ < aDField.DimensionZ(); ++iZ) { double aDist = aDField.Voxel(iX, iY, iZ); - std::cout << "(" << iX << ", " << iY << ", " << iZ << "): " << aDist << std::endl; + std::cout << "(" << iX << ", " << iY << ", " << iZ << "): " << aDist << '\n'; } } } diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming.cxx index 6d348dcaf6..86671cc0b6 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming.cxx @@ -73,7 +73,7 @@ TopoDS_Shape QADNaming::CurrentShape(const char* const LabelName, const occ::han bool Found = DDF::AddLabel(DF, LabelName, Label); if (!Found) { - std::cout << "no labels" << std::endl; + std::cout << "no labels" << '\n'; return S; } if (Found) @@ -82,7 +82,9 @@ TopoDS_Shape QADNaming::CurrentShape(const char* const LabelName, const occ::han Label.FindAttribute(TNaming_NamedShape::GetID(), NS); S = TNaming_Tool::CurrentShape(NS); if (S.IsNull()) - std::cout << "current shape from " << LabelName << " is deleted" << std::endl; + { + std::cout << "current shape from " << LabelName << " is deleted" << '\n'; + } return S; } return S; @@ -112,7 +114,9 @@ TCollection_AsciiString QADNaming::GetEntry(const TopoDS_Shape& Shape, { theStatus++; if (theStatus == 2) + { break; + } } return entry; } @@ -125,13 +129,15 @@ bool QADNaming::Entry(void* const theArguments, TDF_Label& theLabel) occ::handle DF; if (!DDF::GetDF(arg[1], DF)) { - std::cout << "Wrong df" << std::endl; + std::cout << "Wrong df" << '\n'; return false; } DDF::AddLabel(DF, arg[2], theLabel); if (!theLabel.IsNull()) + { return true; - std::cout << "Wrong entry" << std::endl; + } + std::cout << "Wrong entry" << '\n'; return false; } @@ -146,9 +152,13 @@ static int QADNaming_IsSameShapes(Draw_Interpretor& di, int nb, const char** arg TopoDS_Shape aShape1 = DBRep::Get(arg[1]); TopoDS_Shape aShape2 = DBRep::Get(arg[2]); if (aShape1.IsNull() || aShape2.IsNull()) + { return 0; + } if (aShape1.IsSame(aShape2)) + { di << "1"; + } return 0; } return 1; @@ -162,7 +172,9 @@ static int QADNaming_CenterOfShape(Draw_Interpretor& di, int nb, const char** ar { TopoDS_Shape aShape = DBRep::Get(arg[1]); if (aShape.IsNull()) + { return 1; + } double x = 0, y = 0, z = 0; float all = 0; TopExp_Explorer anExp(aShape, TopAbs_VERTEX); @@ -191,7 +203,9 @@ void QADNaming::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; QADNaming::BasicCommands(theCommands); diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming_BasicCommands.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming_BasicCommands.cxx index 888ec52b39..6ae33ef6ee 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming_BasicCommands.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming_BasicCommands.cxx @@ -47,7 +47,9 @@ static int Ascendants(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } char name[100]; @@ -55,19 +57,27 @@ static int Ascendants(Draw_Interpretor& di, int n, const char** a) // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } int T; if (n > 3) + { T = Draw::Atoi(a[3]); + } else + { T = ND->Transaction(); + } // TNaming_OldShapeIterator it (S, T, US); TNaming_OldShapeIterator it(S, T, ND->Root()); @@ -91,25 +101,35 @@ static int Descendants(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } char name[100]; occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } int T; if (n > 3) + { T = Draw::Atoi(a[3]); + } else + { T = ND->Transaction(); + } TNaming_NewShapeIterator it(S, T, ND->Root()); int i = 0; @@ -132,12 +152,16 @@ static int Descendants(Draw_Interpretor& di, int n, const char** a) static int Getentry(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape S = DBRep::Get(a[2]); @@ -172,12 +196,16 @@ static int Getentry(Draw_Interpretor& di, int n, const char** a) static int NamedShape(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } TopoDS_Shape SS = DBRep::Get(a[2]); if (SS.IsNull()) { @@ -204,20 +232,28 @@ static int NamedShape(Draw_Interpretor& di, int n, const char** a) static int Currentshape(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle ND; if (!DDF::GetDF(a[1], ND)) + { return 1; + } const char* LabelName = a[2]; TopoDS_Shape S = QADNaming::CurrentShape(LabelName, ND); if (!S.IsNull()) { if (n == 4) + { DBRep::Set(a[3], S); + } else + { DBRep::Set(a[2], S); + } return 0; } return 0; @@ -228,16 +264,22 @@ static int Currentshape(Draw_Interpretor&, int n, const char** a) static int Initialshape(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle ND; if (!DDF::GetDF(a[1], ND)) + { return 1; + } TopoDS_Shape NS = DBRep::Get(a[2]); if (NS.IsNull()) + { return 1; + } NCollection_List Labels; TopoDS_Shape S = TNaming_Tool::InitialShape(NS, ND->Root(), Labels); @@ -270,12 +312,16 @@ static int Exploreshape(Draw_Interpretor& di, int n, const char** a) char name[100]; if (n < 4) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); int Trans = ND->Transaction(); @@ -336,18 +382,26 @@ static int Generatedshape(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } TopoDS_Shape Gen = DBRep::Get(arg[2]); occ::handle Generation; if (!DDF::Find(DF, arg[3], TNaming_NamedShape::GetID(), Generation)) + { return 1; + } S = TNaming_Tool::GeneratedShape(Gen, Generation); if (!S.IsNull()) { if (nb == 4) + { DBRep::Set(arg[4], S); + } else + { DBRep::Set(arg[3], S); + } return 0; } } @@ -365,16 +419,24 @@ static int Getshape(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::Find(DF, arg[2], TNaming_NamedShape::GetID(), A)) + { return 1; + } s = TNaming_Tool::GetShape(A); if (!s.IsNull()) { if (nb == 4) + { DBRep::Set(arg[3], s); + } else + { DBRep::Set(arg[2], s); + } return 0; } } @@ -394,9 +456,13 @@ static int Collect(Draw_Interpretor& di, int nb, const char** arg) { occ::handle DF; if (!DDF::GetDF(arg[1], DF)) + { return 1; + } if (!DDF::Find(DF, arg[2], TNaming_NamedShape::GetID(), A)) + { return 1; + } if (nb >= 4) { OnlyModif = Draw::Atoi(arg[3]) != 0; @@ -420,12 +486,16 @@ static int Collect(Draw_Interpretor& di, int nb, const char** arg) static int Getcreationentry(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle ND; // occ::handle US; if (!DDF::GetDF(a[1], ND)) + { return 1; + } // ND->Root().FindAttribute(TNaming_UsedShapes::GetID(),US); TopoDS_Shape SS = DBRep::Get(a[2]); @@ -468,7 +538,9 @@ void QADNaming::BasicCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands"; diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming_BuilderCommands.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming_BuilderCommands.cxx index eb92352d96..ec2f3f2375 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming_BuilderCommands.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming_BuilderCommands.cxx @@ -26,7 +26,9 @@ static int BuildNamedShape(Draw_Interpretor& di, int nb, const char** arg) { TDF_Label aLabel; if (!QADNaming::Entry(arg, aLabel)) + { return 1; + } char anEvolution = arg[3][0]; int a, anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2; // if (anEvolution == 'G') @@ -91,7 +93,9 @@ void QADNaming::BuilderCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming builder commands"; diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming_IteratorsCommands.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming_IteratorsCommands.cxx index d94600e90c..87eb4cc612 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming_IteratorsCommands.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming_IteratorsCommands.cxx @@ -57,7 +57,9 @@ static int GetNewShapes(Draw_Interpretor& di, int nb, const char** arg) { TDF_Label aLabel; if (!QADNaming::Entry(arg, aLabel)) + { return 1; + } occ::handle aNS; if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { @@ -71,7 +73,9 @@ static int GetNewShapes(Draw_Interpretor& di, int nb, const char** arg) for (a = 1; anIter.More(); anIter.Next(), a++) { if (anIter.NewShape().IsNull()) + { a--; + } else if (nb == 4) { Sprintf(aName, "%s_%d", arg[3], a); @@ -94,7 +98,9 @@ static int GetOldShapes(Draw_Interpretor& di, int nb, const char** arg) { TDF_Label aLabel; if (!QADNaming::Entry(arg, aLabel)) + { return 1; + } occ::handle aNS; if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { @@ -108,7 +114,9 @@ static int GetOldShapes(Draw_Interpretor& di, int nb, const char** arg) for (a = 1; anIter.More(); anIter.Next(), a++) { if (anIter.OldShape().IsNull()) + { a--; + } else if (nb == 4) { Sprintf(aName, "%s_%d", arg[3], a); @@ -159,7 +167,9 @@ static int GetAllNewShapes(Draw_Interpretor& di, int nb, const char** arg) { // label TDF_Label aLabel; if (!QADNaming::Entry(arg, aLabel)) + { return 1; + } occ::handle aNS; if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { @@ -211,11 +221,14 @@ static int GetAllOld(const TopoDS_Shape& theShape, TCollection_AsciiString aName; occ::handle aNS = TNaming_Tool::NamedShape(theShape, theAccess); if (aNS.IsNull()) + { return theIndex; + } TNaming_Iterator anIter(aNS); for (; anIter.More(); anIter.Next()) { if (!anIter.OldShape().IsNull() && !anIter.NewShape().IsNull()) + { if (anIter.NewShape().IsSame(theShape)) { theIndex++; @@ -226,6 +239,7 @@ static int GetAllOld(const TopoDS_Shape& theShape, } theIndex = GetAllOld(anIter.OldShape(), theAccess, theName, theIndex); } + } } return theIndex; } @@ -241,7 +255,9 @@ static int GetAllOldShapes(Draw_Interpretor& di, int nb, const char** arg) { // label TDF_Label aLabel; if (!QADNaming::Entry(arg, aLabel)) + { return 1; + } occ::handle aNS; if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { @@ -306,9 +322,13 @@ static int GetSameShapes(Draw_Interpretor& di, int nb, const char** arg) TCollection_AsciiString Name; TDF_Tool::Entry(anIter.Label(), Name); if (aResult != 0) + { aRes = aRes + Name + " "; + } else + { aRes = Name; + } aResult++; } } @@ -326,7 +346,9 @@ void QADNaming::IteratorsCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming builder commands"; diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming_SelectionCommands.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming_SelectionCommands.cxx index f9dbc7f474..d543fde489 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming_SelectionCommands.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming_SelectionCommands.cxx @@ -95,7 +95,9 @@ static int QADNaming_Select(Draw_Interpretor& di, int n, const char** a) bool geometry = (strcmp(a[0], "SelectGeometry") == 0 ? 1 : 0); occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; DDF::AddLabel(DF, a[2], L); TNaming_Selector SL(L); @@ -127,7 +129,9 @@ static int QADNaming_SolveSelection(Draw_Interpretor& di, int n, const char** a) { TDF_Label aLabel; if (!QADNaming::Entry(a, aLabel)) + { return 1; + } char name[100]; TNaming_Selector SL(aLabel); NCollection_Map valid; @@ -136,9 +140,13 @@ static int QADNaming_SolveSelection(Draw_Interpretor& di, int n, const char** a) { TDF_Label aValidLab; if (!DDF::FindLabel(aLabel.Data(), a[i], aValidLab)) + { di << "Warning: label " << a[i] << " not exists\n"; + } else + { valid.Add(aValidLab); + } } bool done = SL.Solve(valid); TopoDS_Shape Res = TNaming_Tool::CurrentShape(SL.NamedShape()); @@ -162,10 +170,14 @@ static int QADNaming_DumpSelection(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; if (!L.FindAttribute(TNaming_Naming::GetID(), naming)) { @@ -186,7 +198,9 @@ static int QADNaming_DumpSelection(Draw_Interpretor& di, int n, const char** a) { curdepth = (naming->Label().Depth() - depth); for (int i = 1; i <= curdepth; i++) + { di << " "; + } TDF_Tool::Entry(naming->Label(), Entry); di << Entry.ToCString() << " "; DumpNaming(naming, di); @@ -208,10 +222,14 @@ static int QADNaming_ArgsSelection(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; if (!L.FindAttribute(TNaming_Naming::GetID(), naming)) { @@ -246,7 +264,9 @@ static void CollectAttachment(const TDF_Label& for (itarg.Initialize(args); itarg.More(); itarg.Next()) { if (!itarg.Value()->Label().IsDescendant(root)) + { attachment.Add(itarg.Value()); + } } occ::handle subnaming; for (TDF_ChildIterator it(naming->Label(), true); it.More(); it.Next()) @@ -258,7 +278,9 @@ static void CollectAttachment(const TDF_Label& for (itarg.Initialize(subargs); itarg.More(); itarg.Next()) { if (!itarg.Value()->Label().IsDescendant(root)) + { attachment.Add(itarg.Value()); + } } } } @@ -272,10 +294,14 @@ static int QADNaming_Attachment(Draw_Interpretor& di, int n, const char** a) { occ::handle DF; if (!DDF::GetDF(a[1], DF)) + { return 1; + } TDF_Label L; if (!DDF::FindLabel(DF, a[2], L)) + { return 1; + } occ::handle naming; NCollection_Map> attachment; if (L.FindAttribute(TNaming_Naming::GetID(), naming)) @@ -317,7 +343,9 @@ void QADNaming::SelectionCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands"; diff --git a/src/Draw/TKQADraw/QADNaming/QADNaming_ToolsCommands.cxx b/src/Draw/TKQADraw/QADNaming/QADNaming_ToolsCommands.cxx index 6aa697d7ab..4345fab7ea 100644 --- a/src/Draw/TKQADraw/QADNaming/QADNaming_ToolsCommands.cxx +++ b/src/Draw/TKQADraw/QADNaming/QADNaming_ToolsCommands.cxx @@ -36,7 +36,9 @@ static int QADNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg) { if (nb < 4) + { return 1; + } TopoDS_Shape S1 = DBRep::Get(arg[1]); if (S1.IsNull()) { @@ -55,13 +57,21 @@ static int QADNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg strtok(M, " \t"); TopAbs_ShapeEnum mod = TopAbs_FACE; if (M[0] == 'F' || M[0] == 'f') + { mod = TopAbs_FACE; + } else if (M[0] == 'E' || M[0] == 'e') + { mod = TopAbs_EDGE; + } else if (M[0] == 'V' || M[0] == 'v') + { mod = TopAbs_VERTEX; + } else + { return 1; + } TopExp_Explorer Exp1, Exp2; @@ -85,7 +95,9 @@ static int QADNaming_CheckHasSame(Draw_Interpretor& di, int nb, const char** arg { const TopoDS_Shape& s2 = itr2.Key(); if (s1.IsSame(s2)) + { di << "Shapes " << arg[1] << " and " << arg[2] << " have SAME subshapes\n"; + } } } @@ -102,7 +114,9 @@ static int QADNaming_TCopyShape(Draw_Interpretor& di, int nb, const char** arg) { TNaming_Translator TR; if (nb < 2) + { return (1); + } NCollection_DataMap aDMapOfShapeOfName; @@ -119,7 +133,9 @@ static int QADNaming_TCopyShape(Draw_Interpretor& di, int nb, const char** arg) // Add to Map if (S.IsNull()) + { return (1); + } else { aDMapOfShapeOfName.Bind(S, name); @@ -156,7 +172,9 @@ void QADNaming::ToolsCommands(Draw_Interpretor& theCommands) static bool done = false; if (done) + { return; + } done = true; const char* g = "Naming data commands"; diff --git a/src/Draw/TKQADraw/QADraw/QADraw.cxx b/src/Draw/TKQADraw/QADraw/QADraw.cxx index 306a0a2b23..a3315d8cc2 100644 --- a/src/Draw/TKQADraw/QADraw/QADraw.cxx +++ b/src/Draw/TKQADraw/QADraw/QADraw.cxx @@ -40,7 +40,7 @@ static int QATestExtremaSS(Draw_Interpretor& theInterpretor, int theArgNb, const { if (theArgNb < 3 || theArgNb > 4) { - std::cerr << "Usage: type help " << theArgs[0] << std::endl; + std::cerr << "Usage: type help " << theArgs[0] << '\n'; return 1; } diff --git a/src/Draw/TKTObjDRAW/TObjDRAW/TObjDRAW.cxx b/src/Draw/TKTObjDRAW/TObjDRAW/TObjDRAW.cxx index 34a47b6044..f7edfbd345 100644 --- a/src/Draw/TKTObjDRAW/TObjDRAW/TObjDRAW.cxx +++ b/src/Draw/TKTObjDRAW/TObjDRAW/TObjDRAW.cxx @@ -159,7 +159,9 @@ static int newModel(Draw_Interpretor& di, int argc, const char** argv) di << "document " << argv[1] << " created\n"; } else + { di << argv[1] << " is already a document\n"; + } return 0; } @@ -169,12 +171,16 @@ static occ::handle getModelByName(const char* theName) occ::handle aModel; occ::handle D; if (!DDocStd::GetDocument(theName, D)) + { return aModel; + } TDF_Label aLabel = D->Main(); occ::handle aModelAttr; if (!aLabel.IsNull() && aLabel.FindAttribute(TObj_TModel::GetID(), aModelAttr)) + { aModel = aModelAttr->Model(); + } return aModel; } @@ -190,7 +196,9 @@ static int saveModel(Draw_Interpretor& di, int argc, const char** argv) occ::handle aModel = getModelByName(argv[1]); if (aModel.IsNull()) + { return 1; + } bool isSaved = false; if (argc > 2) { @@ -211,10 +219,14 @@ static int saveModel(Draw_Interpretor& di, int argc, const char** argv) isSaved = aModel->SaveAs(*aFileStream); } else + { isSaved = aModel->SaveAs(TCollection_ExtendedString(argv[2], true)); + } } else + { isSaved = aModel->Save(); + } if (!isSaved) { @@ -259,7 +271,9 @@ static int loadModel(Draw_Interpretor& di, int argc, const char** argv) isLoaded = aModel->Load(*aFileStream); } else + { isLoaded = aModel->Load(aPath); + } if (isLoaded) { @@ -295,7 +309,9 @@ static int closeModel(Draw_Interpretor& di, int argc, const char** argv) occ::handle aModel = getModelByName(argv[1]); if (aModel.IsNull()) + { return 1; + } aModel->Close(); return 0; @@ -312,7 +328,9 @@ static int addObj(Draw_Interpretor& di, int argc, const char** argv) } occ::handle aModel = getModelByName(argv[1]); if (aModel.IsNull()) + { return 1; + } occ::handle tObj = new TObjDRAW_Object(aModel->GetMainPartition()->NewLabel()); if (tObj.IsNull()) { @@ -329,7 +347,9 @@ static occ::handle getObjByName(const char* modelName, const ch occ::handle tObj; occ::handle aModel = getModelByName(modelName); if (aModel.IsNull()) + { return tObj; + } occ::handle aName = new TCollection_HExtendedString(objName); occ::handle aDict; tObj = occ::down_cast(aModel->FindObject(aName, aDict)); @@ -356,11 +376,15 @@ static int setVal(Draw_Interpretor& di, int argc, const char** argv) int Nb = Draw::Atoi(argv[4]); occ::handle> rArr = new NCollection_HArray1(1, Nb); for (int i = 1; i <= Nb; i++) + { rArr->SetValue(i, Draw::Atof(argv[4 + i])); + } tObj->SetRealArr(rArr); } else + { tObj->SetInt(Draw::Atoi(argv[3])); + } return 0; } @@ -382,17 +406,23 @@ static int getVal(Draw_Interpretor& di, int argc, const char** argv) return 1; } if (!strcmp(argv[3], "-i")) + { di << tObj->GetInt(); + } else { occ::handle> rArr = tObj->GetRealArr(); if (!rArr.IsNull()) + { for (int i = 1, n = rArr->Upper(); i <= n; i++) { if (i > 1) + { di << " "; + } di << rArr->Value(i); } + } } return 0; @@ -438,7 +468,9 @@ static int getRef(Draw_Interpretor& di, int argc, const char** argv) } occ::handle aRefObj = tObj->GetRef(); if (aRefObj.IsNull()) + { return 1; + } else { TCollection_AsciiString aName; @@ -506,7 +538,9 @@ static int getChildren(Draw_Interpretor& di, int argc, const char** argv) TCollection_AsciiString aName; anObj->GetName(aName); if (i > 0) + { di << " "; + } di << aName.ToCString(); } diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest.cxx index 07d1a9f122..00360face6 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest.cxx @@ -36,7 +36,9 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // BOPTest::BOPCommands(theCommands); @@ -61,7 +63,9 @@ void BOPTest::Factory(Draw_Interpretor& theCommands) { static bool FactoryDone = false; if (FactoryDone) + { return; + } FactoryDone = true; @@ -95,7 +99,9 @@ void BOPTest::ReportAlerts(const occ::handle& theReport) // check that this type of warnings has not yet been processed const occ::handle& aType = aIt.Value()->DynamicType(); if (!aPassedTypes.Add(aType)) + { continue; + } // get alert message Message_Msg aMsg(aIt.Value()->GetMessageKey()); diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_APICommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_APICommands.cxx index 505c78895c..75b6ec0302 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_APICommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_APICommands.cxx @@ -39,7 +39,9 @@ void BOPTest::APICommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -165,7 +167,9 @@ int bapibop(Draw_Interpretor& di, int n, const char** a) // Store the history of operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(pBuilder->History()); + } if (pBuilder->HasWarnings()) { @@ -234,7 +238,9 @@ int bapibuild(Draw_Interpretor& di, int n, const char** a) // Store the history of operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aBuilder.History()); + } if (aBuilder.HasWarnings()) { @@ -295,7 +301,9 @@ int bapisplit(Draw_Interpretor& di, int n, const char** a) // Store the history of operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aSplitter.History()); + } // check warning status if (aSplitter.HasWarnings()) diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_BOPCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_BOPCommands.cxx index 190b67ac67..7221d08a10 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_BOPCommands.cxx @@ -70,7 +70,9 @@ void BOPTest::BOPCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -240,7 +242,9 @@ int bopsmt(Draw_Interpretor& di, int n, const char** a, const BOPAlgo_Operation // Store the history of Boolean operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aBOP.History()); + } if (aBOP.HasErrors()) { @@ -309,7 +313,9 @@ int bopsection(Draw_Interpretor& di, int n, const char** a) // Store the history of Section operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aBOP.History()); + } if (aBOP.HasErrors()) { @@ -423,7 +429,9 @@ int bsection(Draw_Interpretor& di, int n, const char** a) aSec.Build(aProgress->Start()); // Store the history of Section operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aSec.History()); + } // if (aSec.HasWarnings()) @@ -496,7 +504,9 @@ int bsmt(Draw_Interpretor& di, int n, const char** a, const BOPAlgo_Operation aO // Store the history of Boolean operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aBOP.PDS()->Arguments(), aBOP); + } if (aBOP.HasErrors()) { @@ -844,7 +854,9 @@ int mkvolume(Draw_Interpretor& di, int n, const char** a) // Store the history of Volume Maker into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aLS, aMV); + } if (aMV.HasErrors()) { diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_CellsCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_CellsCommands.cxx index 7ebc2b5ac4..bf19dd0878 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_CellsCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_CellsCommands.cxx @@ -41,7 +41,9 @@ void BOPTest::CellsCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -139,7 +141,9 @@ int bcbuild(Draw_Interpretor& di, int n, const char** a) BOPTest::ReportAlerts(aCBuilder.GetReport()); // Store the history of the Cells Builder into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } if (aCBuilder.HasErrors()) { @@ -195,7 +199,9 @@ int bcaddall(Draw_Interpretor& di, int n, const char** a) // Update the history of the Cells Builder if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } DBRep::Set(a[1], aR); return 0; @@ -217,7 +223,9 @@ int bcremoveall(Draw_Interpretor& di, int n, const char**) // Update the history of the Cells Builder if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } return 0; } @@ -288,7 +296,9 @@ int bcadd(Draw_Interpretor& di, int n, const char** a) // Update the history of the Cells Builder if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } DBRep::Set(a[1], aR); return 0; @@ -340,7 +350,9 @@ int bcremove(Draw_Interpretor& di, int n, const char** a) // Update the history of the Cells Builder if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } DBRep::Set(a[1], aR); return 0; @@ -366,7 +378,9 @@ int bcremoveint(Draw_Interpretor& di, int n, const char** a) // Update the history of the Cells Builder if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder); + } DBRep::Set(a[1], aR); return 0; diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_CheckCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_CheckCommands.cxx index 5916afad15..19c17ba297 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_CheckCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_CheckCommands.cxx @@ -60,7 +60,9 @@ void BOPTest::CheckCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name @@ -522,7 +524,9 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) } } else + { aChecker.OperationType() = BOPAlgo_SECTION; + } aChecker.TangentMode() = true; aChecker.MergeVertexMode() = true; @@ -663,9 +667,13 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) { case BOPAlgo_BadType: { if (!aSS1.IsNull()) + { S1_BadType++; + } if (!aSS2.IsNull()) + { S2_BadType++; + } } break; case BOPAlgo_SelfIntersect: { @@ -673,13 +681,17 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) { S1_SelfInt++; if (isL1) + { MakeShapeForFullOutput(aS1SIBaseName, S1_SelfInt, aLS1, S1_SelfIntAll, di); + } } if (!aSS2.IsNull()) { S2_SelfInt++; if (isL2) + { MakeShapeForFullOutput(aS2SIBaseName, S2_SelfInt, aLS2, S2_SelfIntAll, di); + } } } break; @@ -688,13 +700,17 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) { S1_SmalE++; if (isL1) + { MakeShapeForFullOutput(aS1SEBaseName, S1_SmalE, aLS1, S1_SmalEAll, di); + } } if (!aSS2.IsNull()) { S2_SmalE++; if (isL2) + { MakeShapeForFullOutput(aS2SEBaseName, S2_SmalE, aLS2, S2_SmalEAll, di); + } } } break; @@ -703,13 +719,17 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) { S1_BadF++; if (isL1) + { MakeShapeForFullOutput(aS1BFBaseName, S1_BadF, aLS1, S1_BadFAll, di); + } } if (!aSS2.IsNull()) { S2_BadF++; if (isL2) + { MakeShapeForFullOutput(aS2BFBaseName, S2_BadF, aLS2, S2_BadFAll, di); + } } } break; @@ -813,9 +833,13 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) break; case BOPAlgo_OperationAborted: { if (!aSS1.IsNull()) + { S1_OpAb++; + } if (!aSS2.IsNull()) + { S2_OpAb++; + } } break; case BOPAlgo_CheckUnknown: @@ -838,87 +862,151 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) di << "---------------------------------\n"; const char* CString1; if (S1_BadType != 0) + { CString1 = "YES"; + } else + { CString1 = aChecker.ArgumentTypeMode() ? "NO" : "DISABLED"; + } di << "Shapes are not suppotrted by BOP: " << CString1 << "\n"; const char* CString2; if (S1_SelfInt != 0) + { CString2 = "YES"; + } else + { CString2 = aChecker.SelfInterMode() ? "NO" : "DISABLED"; + } di << "Self-Intersections : " << CString2; if (S1_SelfInt != 0) + { di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")\n"; + } else + { di << "\n"; + } const char* CString13; if (S1_OpAb != 0) + { CString13 = "YES"; + } else + { CString13 = aChecker.SelfInterMode() ? "NO" : "DISABLED"; + } di << "Check for SI has been aborted : " << CString13 << "\n"; const char* CString3; if (S1_SmalE != 0) + { CString3 = "YES"; + } else + { CString3 = aChecker.SmallEdgeMode() ? "NO" : "DISABLED"; + } di << "Too small edges : " << CString3; if (S1_SmalE != 0) + { di << " Cases(" << S1_SmalE << ") Total shapes(" << S1_SmalEAll << ")\n"; + } else + { di << "\n"; + } const char* CString4; if (S1_BadF != 0) + { CString4 = "YES"; + } else + { CString4 = aChecker.RebuildFaceMode() ? "NO" : "DISABLED"; + } di << "Bad faces : " << CString4; if (S1_BadF != 0) + { di << " Cases(" << S1_BadF << ") Total shapes(" << S1_BadFAll << ")\n"; + } else + { di << "\n"; + } const char* CString5; if (S1_BadV != 0) + { CString5 = "YES"; + } else + { CString5 = aChecker.MergeVertexMode() ? "NO" : "DISABLED"; + } di << "Too close vertices : " << CString5; if (S1_BadV != 0) + { di << " Cases(" << S1_BadV << ") Total shapes(" << S1_BadVAll << ")\n"; + } else + { di << "\n"; + } const char* CString6; if (S1_BadE != 0) + { CString6 = "YES"; + } else + { CString6 = aChecker.MergeEdgeMode() ? "NO" : "DISABLED"; + } di << "Too close edges : " << CString6; if (S1_BadE != 0) + { di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")\n"; + } else + { di << "\n"; + } const char* CString15; if (S1_C0 != 0) + { CString15 = "YES"; + } else + { CString15 = aChecker.ContinuityMode() ? "NO" : "DISABLED"; + } di << "Shapes with Continuity C0 : " << CString15; if (S1_C0 != 0) + { di << " Cases(" << S1_C0 << ") Total shapes(" << S1_C0All << ")\n"; + } else + { di << "\n"; + } const char* CString17; if (S1_COnS != 0) + { CString17 = "YES"; + } else + { CString17 = aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED"; + } di << "Invalid Curve on Surface : " << CString17; if (S1_COnS != 0) + { di << " Cases(" << S1_COnS << ") Total shapes(" << S1_COnSAll << ")\n"; + } else + { di << "\n"; + } } // output for second shape @@ -929,88 +1017,152 @@ int bopargcheck(Draw_Interpretor& di, int n, const char** a) di << "---------------------------------\n"; const char* CString7; if (S2_BadType != 0) + { CString7 = "YES"; + } else + { CString7 = aChecker.ArgumentTypeMode() ? "NO" : "DISABLED"; + } di << "Shapes are not suppotrted by BOP: " << CString7 << "\n"; const char* CString8; if (S2_SelfInt != 0) + { CString8 = "YES"; + } else + { CString8 = aChecker.SelfInterMode() ? "NO" : "DISABLED"; + } di << "Self-Intersections : " << CString8; if (S2_SelfInt != 0) + { di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")\n"; + } else + { di << "\n"; + } const char* CString14; if (S2_OpAb != 0) + { CString14 = "YES"; + } else + { CString14 = aChecker.SelfInterMode() ? "NO" : "DISABLED"; + } di << "Check for SI has been aborted : " << CString14 << "\n"; const char* CString9; if (S2_SmalE != 0) + { CString9 = "YES"; + } else + { CString9 = aChecker.SmallEdgeMode() ? "NO" : "DISABLED"; + } di << "Too small edges : " << CString9; if (S2_SmalE != 0) + { di << " Cases(" << S2_SmalE << ") Total shapes(" << S2_SmalEAll << ")\n"; + } else + { di << "\n"; + } const char* CString10; if (S2_BadF != 0) + { CString10 = "YES"; + } else + { CString10 = aChecker.RebuildFaceMode() ? "NO" : "DISABLED"; + } di << "Bad faces : " << CString10; if (S2_BadF != 0) + { di << " Cases(" << S2_BadF << ") Total shapes(" << S2_BadFAll << ")\n"; + } else + { di << "\n"; + } const char* CString11; if (S2_BadV != 0) + { CString11 = "YES"; + } else + { CString11 = aChecker.MergeVertexMode() ? "NO" : "DISABLED"; + } di << "Too close vertices : " << CString11; if (S2_BadV != 0) + { di << " Cases(" << S2_BadV << ") Total shapes(" << S2_BadVAll << ")\n"; + } else + { di << "\n"; + } const char* CString12; if (S2_BadE != 0) + { CString12 = "YES"; + } else + { CString12 = aChecker.MergeEdgeMode() ? "NO" : "DISABLED"; + } di << "Too close edges : " << CString12; if (S2_BadE != 0) + { di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")\n"; + } else + { di << "\n"; + } const char* CString16; if (S2_C0 != 0) + { CString16 = "YES"; + } else + { CString16 = aChecker.ContinuityMode() ? "NO" : "DISABLED"; + } di << "Shapes with Continuity C0 : " << CString16; if (S2_C0 != 0) + { di << " Cases(" << S2_C0 << ") Total shapes(" << S2_C0All << ")\n"; + } else + { di << "\n"; + } const char* CString18; if (S2_COnS != 0) + { CString18 = "YES"; + } else + { CString18 = aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED"; + } di << "Invalid Curve on Surface : " << CString18; if (S2_COnS != 0) + { di << " Cases(" << S2_COnS << ") Total shapes(" << S2_COnSAll << ")\n"; + } else + { di << "\n"; + } } // warning if (hasUnknown) @@ -1053,15 +1205,25 @@ int bopapicheck(Draw_Interpretor& di, int n, const char** a) // Get the operation type ++i; if (!strcmp(a[i], "common")) + { anOp = BOPAlgo_COMMON; + } else if (!strcmp(a[i], "fuse")) + { anOp = BOPAlgo_FUSE; + } else if (!strcmp(a[i], "cut")) + { anOp = BOPAlgo_CUT; + } else if (!strcmp(a[i], "tuc")) + { anOp = BOPAlgo_CUT21; + } else if (!strcmp(a[i], "section")) + { anOp = BOPAlgo_SECTION; + } } else if (!strcmp(a[i], "-se")) { @@ -1081,9 +1243,13 @@ int bopapicheck(Draw_Interpretor& di, int n, const char** a) if (aChecker.IsValid()) { if (aS2.IsNull()) + { di << "The shape seems to be valid\n"; + } else + { di << "The shapes seem to be valid\n"; + } return 0; } @@ -1113,15 +1279,21 @@ int bopapicheck(Draw_Interpretor& di, int n, const char** a) } if (isInv1 && isInv2 && isBadOp) + { break; + } } if (isInv1) { if (aS2.IsNull()) + { di << "The shape is invalid\n"; + } else + { di << "The first shape is invalid\n"; + } } if (isInv2) { @@ -1130,9 +1302,13 @@ int bopapicheck(Draw_Interpretor& di, int n, const char** a) if (isBadOp) { if (aS2.IsNull()) + { di << "The shape is empty\n"; + } else + { di << "The shapes are not valid for Boolean operation\n"; + } } return 0; } diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_DebugCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_DebugCommands.cxx index 0bb86389ae..9263029e5e 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_DebugCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_DebugCommands.cxx @@ -97,7 +97,9 @@ void BOPTest::DebugCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -715,9 +717,13 @@ int bopsc(Draw_Interpretor& di, int n, const char** a) // nSF1 = nSF2 = -1; if (n > 1) + { nSF1 = Draw::Atoi(a[1]); + } if (n > 2) + { nSF2 = Draw::Atoi(a[2]); + } NCollection_DynamicArray& aFFs = pDS->InterfFF(); // @@ -738,7 +744,9 @@ int bopsc(Draw_Interpretor& di, int n, const char** a) else if (n == 2) { if (!aFF.Contains(nSF1)) + { continue; + } } // aFF.Indices(nF1, nF2); diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_DrawableShape.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_DrawableShape.cxx index 572bdaf98f..5b7683405b 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_DrawableShape.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_DrawableShape.cxx @@ -111,7 +111,9 @@ gp_Pnt BOPTest_DrawableShape::Pnt() const u1 = CU.FirstParameter(); u2 = CU.LastParameter(); if (facpar == 0.) + { facpar = 0.20; + } p = u1 + (u2 - u1) * facpar; P = CU.Value(p); } @@ -125,7 +127,9 @@ gp_Pnt BOPTest_DrawableShape::Pnt() const u1 = CU.FirstParameter(); u2 = CU.LastParameter(); if (facpar == 0.) + { facpar = 0.40; + } p = u1 + (u2 - u1) * facpar; P = CU.Value(p); } diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_LowCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_LowCommands.cxx index dcce95bdb8..71545a691e 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_LowCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_LowCommands.cxx @@ -53,7 +53,9 @@ void BOPTest::LowCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -296,9 +298,13 @@ occ::handle CurveOnSurface(const TopoDS_Edge& E, occ::handle GC(occ::down_cast(cr)); GC->Range(First, Last); if (GC->IsCurveOnClosedSurface() && Eisreversed) + { return GC->PCurve2(); + } else + { return GC->PCurve(); + } } itcr.Next(); } diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_MkConnectedCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_MkConnectedCommands.cxx index b98535443a..d73c12e4b2 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_MkConnectedCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_MkConnectedCommands.cxx @@ -53,7 +53,9 @@ void BOPTest::MkConnectedCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* group = "BOPTest commands"; @@ -147,7 +149,9 @@ int MakeConnected(Draw_Interpretor& theDI, int theArgc, const char** theArgv) BRepTest_Objects::SetHistory(getMakeConnectedTool().History()); if (getMakeConnectedTool().HasErrors()) + { return 0; + } // Draw the result shape const TopoDS_Shape& aResult = getMakeConnectedTool().Shape(); @@ -178,11 +182,17 @@ int MakePeriodic(Draw_Interpretor& theDI, int theArgc, const char** theArgv) { int aDirID = -1; if (!strcasecmp(theArgv[i], "-x")) + { aDirID = 0; + } else if (!strcasecmp(theArgv[i], "-y")) + { aDirID = 1; + } else if (!strcasecmp(theArgv[i], "-z")) + { aDirID = 2; + } else { theDI << theArgv[i] << " - Invalid key\n"; @@ -194,7 +204,9 @@ int MakePeriodic(Draw_Interpretor& theDI, int theArgc, const char** theArgv) double aPeriod = 0; if (theArgc > i + 1) + { aPeriod = Draw::Atof(theArgv[++i]); + } if (aPeriod <= Precision::Confusion()) { @@ -234,7 +246,9 @@ int MakePeriodic(Draw_Interpretor& theDI, int theArgc, const char** theArgv) BRepTest_Objects::SetHistory(getMakeConnectedTool().History()); if (getMakeConnectedTool().HasErrors()) + { return 0; + } // Draw the result shape const TopoDS_Shape& aResult = getMakeConnectedTool().PeriodicShape(); @@ -263,11 +277,17 @@ int RepeatShape(Draw_Interpretor& theDI, int theArgc, const char** theArgv) { int aDirID = -1; if (!strcasecmp(theArgv[i], "-x")) + { aDirID = 0; + } else if (!strcasecmp(theArgv[i], "-y")) + { aDirID = 1; + } else if (!strcasecmp(theArgv[i], "-z")) + { aDirID = 2; + } else { theDI << theArgv[i] << " - Invalid key\n"; @@ -279,7 +299,9 @@ int RepeatShape(Draw_Interpretor& theDI, int theArgc, const char** theArgv) int aTimes = 0; if (theArgc > i + 1) + { aTimes = Draw::Atoi(theArgv[++i]); + } if (aTimes == 0) { @@ -297,7 +319,9 @@ int RepeatShape(Draw_Interpretor& theDI, int theArgc, const char** theArgv) BRepTest_Objects::SetHistory(getMakeConnectedTool().History()); if (getMakeConnectedTool().HasErrors()) + { return 0; + } // Draw the result shape const TopoDS_Shape& aResult = getMakeConnectedTool().PeriodicShape(); @@ -328,9 +352,13 @@ int MaterialsOn(Draw_Interpretor& theDI, int theArgc, const char** theArgv) bool bPositive; if (!strcmp("+", theArgv[2])) + { bPositive = true; + } else if (!strcmp("-", theArgv[2])) + { bPositive = false; + } else { theDI << theArgv[2] << " - invalid key.\n"; @@ -343,14 +371,20 @@ int MaterialsOn(Draw_Interpretor& theDI, int theArgc, const char** theArgv) TopoDS_Shape aResult; if (aLS.IsEmpty()) + { theDI << "No materials on this side.\n"; + } else if (aLS.Extent() == 1) + { aResult = aLS.First(); + } else { BRep_Builder().MakeCompound(TopoDS::Compound(aResult)); for (NCollection_List::Iterator it(aLS); it.More(); it.Next()) + { BRep_Builder().Add(aResult, it.Value()); + } } DBRep::Set(theArgv[1], aResult); @@ -381,14 +415,20 @@ int GetTwins(Draw_Interpretor& theDI, int theArgc, const char** theArgv) TopoDS_Shape aCTwins; if (aTwins.IsEmpty()) + { theDI << "No twins for the shape.\n"; + } else if (aTwins.Extent() == 1) + { aCTwins = aTwins.First(); + } else { BRep_Builder().MakeCompound(TopoDS::Compound(aCTwins)); for (NCollection_List::Iterator it(aTwins); it.More(); it.Next()) + { BRep_Builder().Add(aCTwins, it.Value()); + } } DBRep::Set(theArgv[1], aCTwins); diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_ObjCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_ObjCommands.cxx index 5cbc11aa7b..fe52635e1e 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_ObjCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_ObjCommands.cxx @@ -39,7 +39,9 @@ void BOPTest::ObjCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_OptionCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_OptionCommands.cxx index 2a099ab69a..7522a0b61b 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_OptionCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_OptionCommands.cxx @@ -35,7 +35,9 @@ void BOPTest::OptionCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_PartitionCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_PartitionCommands.cxx index 1f2930d353..616cf54527 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_PartitionCommands.cxx @@ -44,7 +44,9 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* g = "BOPTest commands"; @@ -281,7 +283,9 @@ int bbuild(Draw_Interpretor& di, int n, const char** a) // Set history of GF operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aPF.Arguments(), aBuilder); + } if (aBuilder.HasErrors()) { @@ -407,7 +411,9 @@ int bbop(Draw_Interpretor& di, int n, const char** a) // Set history of Boolean operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aPF.Arguments(), *pBuilder); + } if (pBuilder->HasErrors()) { @@ -486,7 +492,9 @@ int bsplit(Draw_Interpretor& di, int n, const char** a) // Set history of Split operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aPF.Arguments(), *pSplitter); + } if (pSplitter->HasErrors()) { @@ -600,7 +608,9 @@ int buildbop(Draw_Interpretor& di, int n, const char** a) } // End of arguments is reached if (j == n) + { break; + } } else if (!strcmp(a[i], "-op")) { @@ -612,13 +622,21 @@ int buildbop(Draw_Interpretor& di, int n, const char** a) ++i; if (!strcasecmp(a[i], "common")) + { anOp = BOPAlgo_COMMON; + } else if (!strcasecmp(a[i], "fuse")) + { anOp = BOPAlgo_FUSE; + } else if (!strcasecmp(a[i], "cut")) + { anOp = BOPAlgo_CUT; + } else if (!strcasecmp(a[i], "tuc")) + { anOp = BOPAlgo_CUT21; + } else { di << "Error: unknown operation type"; @@ -662,7 +680,9 @@ int buildbop(Draw_Interpretor& di, int n, const char** a) // Set history of Split operation into the session if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(pDS->Arguments(), *pBuilder); + } // Result shape const TopoDS_Shape& aR = pBuilder->Shape(); diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_PeriodicityCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_PeriodicityCommands.cxx index 8a8de634d9..e2f2f3c108 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_PeriodicityCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_PeriodicityCommands.cxx @@ -49,7 +49,9 @@ void BOPTest::PeriodicityCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* group = "BOPTest commands"; @@ -121,11 +123,17 @@ int MakePeriodic(Draw_Interpretor& theDI, int theArgc, const char** theArgv) int aDirID = -1; if (!strcasecmp(theArgv[i], "-x")) + { aDirID = 0; + } else if (!strcasecmp(theArgv[i], "-y")) + { aDirID = 1; + } else if (!strcasecmp(theArgv[i], "-z")) + { aDirID = 2; + } else { theDI << theArgv[i] << " - Invalid key\n"; @@ -209,14 +217,20 @@ int GetTwins(Draw_Interpretor& theDI, int theArgc, const char** theArgv) TopoDS_Shape aCTwins; if (aTwins.IsEmpty()) + { theDI << "No twins for the shape.\n"; + } else if (aTwins.Extent() == 1) + { aCTwins = aTwins.First(); + } else { BRep_Builder().MakeCompound(TopoDS::Compound(aCTwins)); for (NCollection_List::Iterator it(aTwins); it.More(); it.Next()) + { BRep_Builder().Add(aCTwins, it.Value()); + } } DBRep::Set(theArgv[1], aCTwins); @@ -238,11 +252,17 @@ int RepeatShape(Draw_Interpretor& theDI, int theArgc, const char** theArgv) { int aDirID = -1; if (!strcasecmp(theArgv[i], "-x")) + { aDirID = 0; + } else if (!strcasecmp(theArgv[i], "-y")) + { aDirID = 1; + } else if (!strcasecmp(theArgv[i], "-z")) + { aDirID = 2; + } else { theDI << theArgv[i] << " - Invalid key\n"; @@ -254,7 +274,9 @@ int RepeatShape(Draw_Interpretor& theDI, int theArgc, const char** theArgv) int aTimes = 0; if (theArgc > i + 1) + { aTimes = Draw::Atoi(theArgv[++i]); + } if (aTimes == 0) { diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_RemoveFeaturesCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_RemoveFeaturesCommands.cxx index e93bc8d4d6..62d5357766 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_RemoveFeaturesCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_RemoveFeaturesCommands.cxx @@ -34,7 +34,9 @@ void BOPTest::RemoveFeaturesCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* group = "BOPTest commands"; @@ -84,7 +86,9 @@ int RemoveFeatures(Draw_Interpretor& theDI, int theArgc, const char** theArgv) aRF.SetRunParallel(true); } else + { theDI << "Warning: " << theArgv[i] << " is a null shape. Skip it.\n"; + } continue; } @@ -101,10 +105,14 @@ int RemoveFeatures(Draw_Interpretor& theDI, int theArgc, const char** theArgv) BOPTest::ReportAlerts(aRF.GetReport()); if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(aRF.History()); + } if (aRF.HasErrors()) + { return 0; + } const TopoDS_Shape& aResult = aRF.Shape(); DBRep::Set(theArgv[1], aResult); diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_TolerCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_TolerCommands.cxx index 93e76b0c2f..4b94022e10 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_TolerCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_TolerCommands.cxx @@ -66,7 +66,9 @@ void BOPTest::TolerCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name diff --git a/src/Draw/TKTopTest/BOPTest/BOPTest_UtilityCommands.cxx b/src/Draw/TKTopTest/BOPTest/BOPTest_UtilityCommands.cxx index c3e0c2d741..05f0d2db41 100644 --- a/src/Draw/TKTopTest/BOPTest/BOPTest_UtilityCommands.cxx +++ b/src/Draw/TKTopTest/BOPTest/BOPTest_UtilityCommands.cxx @@ -37,7 +37,9 @@ void BOPTest::UtilityCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapter's name const char* group = "BOPTest commands"; @@ -236,7 +238,9 @@ static int BuildPcurvesOnPlane(Draw_Interpretor& theDI, int theNArg, const char* NCollection_List aLE; TopExp_Explorer exp1(aF, TopAbs_EDGE); for (; exp1.More(); exp1.Next()) + { aLE.Append(exp1.Current()); + } BRepLib::BuildPCurveForEdgesOnPlane(aLE, aF); } } diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest.cxx index 36aa548e38..14ead0f3a1 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest.cxx @@ -23,7 +23,9 @@ void BRepTest::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_BasicCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_BasicCommands.cxx index 5bf2edd7e1..8a4965bf6a 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_BasicCommands.cxx @@ -63,7 +63,9 @@ #include #include +#ifdef _WIN32 Standard_IMPORT Draw_Viewer dout; +#endif //======================================================================= // function : ConvertBndToShape @@ -95,10 +97,14 @@ static void ConvertBndToShape(const Bnd_OBB& theBox, const char* const theName) static int addpcurve(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape E = DBRep::Get(a[1]); if (E.IsNull()) + { return 1; + } occ::handle PC = DrawTrSurf::GetCurve2d(a[2]); TopoDS_Shape F = DBRep::Get(a[3]); double tol = 1.e-7; @@ -119,7 +125,9 @@ static int addpcurve(Draw_Interpretor&, int n, const char** a) static int transform(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } gp_Trsf T; int last = n; @@ -156,10 +164,14 @@ static int transform(Draw_Interpretor&, int n, const char** a) if (!strcmp(aName, "move")) { if (n < 3) + { return 1; + } TopoDS_Shape SL = DBRep::Get(a[n - 1]); if (SL.IsNull()) + { return 0; + } T = SL.Location().Transformation(); last = n - 1; isBasic = true; @@ -167,14 +179,18 @@ static int transform(Draw_Interpretor&, int n, const char** a) else if (!strcmp(aName, "translate")) { if (n < 5) + { return 1; + } T.SetTranslation(gp_Vec(Draw::Atof(a[n - 3]), Draw::Atof(a[n - 2]), Draw::Atof(a[n - 1]))); last = n - 3; } else if (!strcmp(aName, "rotate")) { if (n < 9) + { return 1; + } T.SetRotation( gp_Ax1(gp_Pnt(Draw::Atof(a[n - 7]), Draw::Atof(a[n - 6]), Draw::Atof(a[n - 5])), gp_Vec(Draw::Atof(a[n - 4]), Draw::Atof(a[n - 3]), Draw::Atof(a[n - 2]))), @@ -184,7 +200,9 @@ static int transform(Draw_Interpretor&, int n, const char** a) else if (!strcmp(aName, "mirror")) { if (n < 8) + { return 1; + } T.SetMirror(gp_Ax2(gp_Pnt(Draw::Atof(a[n - 6]), Draw::Atof(a[n - 5]), Draw::Atof(a[n - 4])), gp_Vec(Draw::Atof(a[n - 3]), Draw::Atof(a[n - 2]), Draw::Atof(a[n - 1])))); @@ -193,7 +211,9 @@ static int transform(Draw_Interpretor&, int n, const char** a) else if (!strcmp(aName, "scale")) { if (n < 6) + { return 1; + } T.SetScale(gp_Pnt(Draw::Atof(a[n - 4]), Draw::Atof(a[n - 3]), Draw::Atof(a[n - 2])), Draw::Atof(a[n - 1])); last = n - 4; @@ -254,7 +274,9 @@ static int transform(Draw_Interpretor&, int n, const char** a) { trf.Perform(S, isCopy, isCopyMesh); if (!trf.IsDone()) + { return 1; + } DBRep::Set(a[i], trf.Shape()); } } @@ -318,7 +340,9 @@ static int tcopy(Draw_Interpretor& di, int n, const char** a) for (int i = 1; i <= 2; i++) { if (a[i][0] != '-') + { break; + } if (a[i][1] == 'n') { copyGeom = false; @@ -359,9 +383,13 @@ static int tcopy(Draw_Interpretor& di, int n, const char** a) static int nurbsconvert(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } if ((n - 1) % 2 != 0) + { return 1; + } BRepBuilderAPI_NurbsConvert nbscv; for (int i = 0; i < (n - 1) / 2; i++) { @@ -396,13 +424,17 @@ static int mkedgecurve(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } double Tolerance = Draw::Atof(a[2]); TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } BRepLib::BuildCurves3d(S, Tolerance); return 0; @@ -428,11 +460,15 @@ static int sameparameter(Draw_Interpretor& di, int n, const char** a) double aTol1 = Draw::Atof(a[n - 1]); bool IsUseTol = aTol1 > 0; if (IsUseTol) + { aTol = aTol1; + } TopoDS_Shape anInpS = DBRep::Get(IsUseTol ? a[n - 2] : a[n - 1]); if (anInpS.IsNull()) + { return 1; + } if ((n == 4 && IsUseTol) || (n == 3 && !IsUseTol)) { @@ -468,7 +504,9 @@ static int updatetol(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape anInpS = IsF ? DBRep::Get(a[n - 2]) : aSh1; if (anInpS.IsNull()) + { return 1; + } if ((n == 4 && IsF) || (n == 3 && !IsF)) { @@ -492,13 +530,19 @@ static int updatetol(Draw_Interpretor& di, int n, const char** a) static int orientsolid(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } if (S.ShapeType() != TopAbs_SOLID) + { return 1; + } BRepLib::OrientClosedSolid(TopoDS::Solid(S)); @@ -511,14 +555,18 @@ static int orientsolid(Draw_Interpretor&, int n, const char** a) static int getcoords(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } for (int i = 1; i < n; i++) { const TopoDS_Shape aShape = DBRep::Get(a[i]); if (aShape.IsNull()) + { continue; + } if (aShape.ShapeType() == TopAbs_VERTEX) { @@ -875,7 +923,9 @@ static int gbounding(Draw_Interpretor& di, int n, const char** a) { bool IsOptimal = false; if (n == 3 && !strcmp(a[2], "-o")) + { IsOptimal = true; + } double axmin, aymin, azmin, axmax, aymax, azmax; Bnd_Box B; @@ -891,9 +941,13 @@ static int gbounding(Draw_Interpretor& di, int n, const char** a) // add surf GeomAdaptor_Surface aGAS(S); if (IsOptimal) + { BndLib_AddSurface::AddOptimal(aGAS, Precision::Confusion(), B); + } else + { BndLib_AddSurface::Add(aGAS, Precision::Confusion(), B); + } } else { @@ -903,9 +957,13 @@ static int gbounding(Draw_Interpretor& di, int n, const char** a) // add cur GeomAdaptor_Curve aGAC(C); if (IsOptimal) + { BndLib_Add3dCurve::AddOptimal(aGAC, Precision::Confusion(), B); + } else + { BndLib_Add3dCurve::Add(aGAC, Precision::Confusion(), B); + } } else { @@ -915,17 +973,21 @@ static int gbounding(Draw_Interpretor& di, int n, const char** a) // add cur2d Is3d = false; if (IsOptimal) + { BndLib_Add2dCurve::AddOptimal(C2d, C2d->FirstParameter(), C2d->LastParameter(), Precision::Confusion(), B2d); + } else + { BndLib_Add2dCurve::Add(C2d, C2d->FirstParameter(), C2d->LastParameter(), Precision::Confusion(), B2d); + } } else { @@ -965,10 +1027,14 @@ static int gbounding(Draw_Interpretor& di, int n, const char** a) static int findplane(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } double tolerance = 1.0e-5; BRepBuilderAPI_FindPlane a_plane_finder(S, tolerance); if (a_plane_finder.Found()) @@ -1009,9 +1075,13 @@ static int reperageshape(Draw_Interpretor& di, int narg, const char** a) { int details = 0; if (narg < 2) + { return 1; + } if (narg == 3) + { details = 1; + } const char* id1 = a[1]; TopoDS_Shape TheShape1 = DBRep::Get(id1); @@ -1104,10 +1174,14 @@ static int reperageshape(Draw_Interpretor& di, int narg, const char** a) static int maxtolerance(Draw_Interpretor& theCommands, int n, const char** a) { if (n < 2) + { return (1); + } TopoDS_Shape TheShape = DBRep::Get(a[1]); if (TheShape.IsNull()) + { return (1); + } double T, TMF, TME, TMV, TmF, TmE, TmV; int nbF, nbE, nbV; @@ -1122,9 +1196,13 @@ static int maxtolerance(Draw_Interpretor& theCommands, int n, const char** a) TopoDS_Face Face = TopoDS::Face(ex.Current()); T = BRep_Tool::Tolerance(Face); if (T > TMF) + { TMF = T; + } if (T < TmF) + { TmF = T; + } mapS.Add(Face); } @@ -1136,9 +1214,13 @@ static int maxtolerance(Draw_Interpretor& theCommands, int n, const char** a) TopoDS_Edge Edge = TopoDS::Edge(ex.Current()); T = BRep_Tool::Tolerance(Edge); if (T > TME) + { TME = T; + } if (T < TmE) + { TmE = T; + } mapS.Add(Edge); } @@ -1150,9 +1232,13 @@ static int maxtolerance(Draw_Interpretor& theCommands, int n, const char** a) TopoDS_Vertex Vertex = TopoDS::Vertex(ex.Current()); T = BRep_Tool::Tolerance(Vertex); if (T > TMV) + { TMV = T; + } if (T < TmV) + { TmV = T; + } mapS.Add(Vertex); } @@ -1164,14 +1250,20 @@ static int maxtolerance(Draw_Interpretor& theCommands, int n, const char** a) sss.precision(5); sss.setf(std::ios::scientific); if (TmF <= TMF) + { sss << "\n Face : Min " << std::setw(8) << TmF << " Max " << std::setw(8) << TMF << " \n "; + } if (TmE <= TME) + { sss << "\n Edge : Min " << std::setw(8) << TmE << " Max " << std::setw(8) << TME << " \n "; + } if (TmV <= TMV) + { sss << "\n Vertex : Min " << std::setw(8) << TmV << " Max " << std::setw(8) << TMV << " \n "; + } theCommands << sss; return 0; @@ -1203,17 +1295,29 @@ static int vecdc(Draw_Interpretor& di, int, const char**) P2.Transform(T); double xa, ya, za; if (std::abs(P1.X()) > std::abs(P2.X())) + { xa = P1.X(); + } else + { xa = P2.X(); + } if (std::abs(P1.Y()) > std::abs(P2.Y())) + { ya = P1.Y(); + } else + { ya = P2.Y(); + } if (std::abs(P1.Z()) > std::abs(P2.Z())) + { za = P1.Z(); + } else + { za = P2.Z(); + } P1.SetCoord(xa, ya, za); occ::handle D0 = new Draw_Marker3D(gp_Pnt(P1.X(), P1.Y(), P1.Z()), Draw_Square, Draw_blanc, 1); @@ -1234,17 +1338,29 @@ static int vecdc(Draw_Interpretor& di, int, const char**) PP2.SetCoord((double)X / z, (double)Y / z, 0.0); PP2.Transform(T); if (std::abs(PP1.X()) > std::abs(PP2.X())) + { xa = PP1.X(); + } else + { xa = PP2.X(); + } if (std::abs(PP1.Y()) > std::abs(PP2.Y())) + { ya = PP1.Y(); + } else + { ya = PP2.Y(); + } if (std::abs(PP1.Z()) > std::abs(PP2.Z())) + { za = PP1.Z(); + } else + { za = PP2.Z(); + } PP1.SetCoord(xa, ya, za); occ::handle d = new Draw_Segment3D(P1, PP1, Draw_blanc); dout << d; @@ -1285,7 +1401,9 @@ static int vecdc(Draw_Interpretor& di, int, const char**) static int nproject(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape InpShape; int arg = 2, i; NCollection_Sequence Args; @@ -1303,28 +1421,38 @@ static int nproject(Draw_Interpretor& di, int n, const char** a) arg++; } if (Args.Length() < 2) + { return 1; + } BRepOffsetAPI_NormalProjection OrtProj(Args.Last()); for (i = 1; i < Args.Length(); i++) + { OrtProj.Add(Args(i)); + } if (n > arg) + { if (!strcmp(a[arg], "-g")) { OrtProj.SetLimit(false); arg++; } + } if (n > arg) + { if (!strcmp(a[arg], "-d")) { arg++; if (n > arg) + { MaxDistance = Draw::Atof(a[arg++]); + } OrtProj.SetMaxDistance(MaxDistance); } + } if (n > arg) { Tol = std::max(Draw::Atof(a[arg++]), 1.e-10); @@ -1333,9 +1461,13 @@ static int nproject(Draw_Interpretor& di, int n, const char** a) if (n > arg) { if (Draw::Atoi(a[arg]) == 0) + { Continuity = GeomAbs_C0; + } else if (Draw::Atoi(a[arg]) == 2) + { Continuity = GeomAbs_C2; + } arg++; } @@ -1343,11 +1475,15 @@ static int nproject(Draw_Interpretor& di, int n, const char** a) { MaxDeg = Draw::Atoi(a[arg++]); if (MaxDeg < 1 || MaxDeg > 14) + { MaxDeg = 14; + } } if (n > arg) + { MaxSeg = Draw::Atoi(a[arg]); + } Tol2d = std::pow(Tol, 2. / 3); @@ -1372,22 +1508,32 @@ static int wexplo(Draw_Interpretor&, int argc, const char** argv) { char name[100]; if (argc < 2) + { return 1; + } TopoDS_Shape C1 = DBRep::Get(argv[1], TopAbs_WIRE); TopoDS_Shape C2; if (argc > 2) + { C2 = DBRep::Get(argv[2], TopAbs_FACE); + } if (C1.IsNull()) + { return 1; + } BRepTools_WireExplorer we; if (C2.IsNull()) + { we.Init(TopoDS::Wire(C1)); + } else + { we.Init(TopoDS::Wire(C1), TopoDS::Face(C2)); + } int k = 1; while (we.More()) @@ -1405,11 +1551,15 @@ static int wexplo(Draw_Interpretor&, int argc, const char** argv) static int scalexyz(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 6) + { return 1; + } TopoDS_Shape aShapeBase = DBRep::Get(a[2]); if (aShapeBase.IsNull()) + { return 1; + } double aFactorX = Draw::Atof(a[3]); double aFactorY = Draw::Atof(a[4]); @@ -1420,7 +1570,9 @@ static int scalexyz(Draw_Interpretor& /*di*/, int n, const char** a) aGTrsf.SetVectorialPart(rot); BRepBuilderAPI_GTransform aBRepGTrsf(aShapeBase, aGTrsf, false); if (!aBRepGTrsf.IsDone()) + { throw Standard_ConstructionError("Scaling not done"); + } TopoDS_Shape Result = aBRepGTrsf.Shape(); DBRep::Set(a[1], Result); @@ -1510,7 +1662,9 @@ static int purgeloc(Draw_Interpretor& di, int /*n*/, const char** a) TopoDS_Shape aShapeBase = DBRep::Get(a[2]); if (aShapeBase.IsNull()) + { return 1; + } BRepTools_PurgeLocations aRemLoc; bool isDone = aRemLoc.Perform(aShapeBase); @@ -1535,7 +1689,9 @@ static int checkloc(Draw_Interpretor& di, int /*n*/, const char** a) TopoDS_Shape aShapeBase = DBRep::Get(a[1]); if (aShapeBase.IsNull()) + { return 1; + } NCollection_List aLS; BRepTools::CheckLocations(aShapeBase, aLS); @@ -1562,7 +1718,9 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_ChamferCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_ChamferCommands.cxx index feaa22408c..c95e677e30 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_ChamferCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_ChamferCommands.cxx @@ -38,11 +38,15 @@ static int chamf_throat_with_penetration(Draw_Interpretor& di, int narg, const char** a) { if (narg < 7) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } TopoDS_Edge E; TopoDS_Face F; @@ -67,7 +71,9 @@ static int chamf_throat_with_penetration(Draw_Interpretor& di, int narg, const c throat = Draw::Atof(a[i + 3]); if (offset > Precision::Confusion() && throat > offset) + { aMCh.Add(offset, throat, E, F); + } } i += NbArg; } @@ -80,7 +86,9 @@ static int chamf_throat_with_penetration(Draw_Interpretor& di, int narg, const c return 1; } else + { aMCh.Build(); + } if (aMCh.IsDone()) { @@ -105,11 +113,15 @@ static int chamf_throat_with_penetration(Draw_Interpretor& di, int narg, const c static int chamf_throat(Draw_Interpretor& di, int narg, const char** a) { if (narg < 5) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } TopoDS_Edge E; double throat; @@ -127,7 +139,9 @@ static int chamf_throat(Draw_Interpretor& di, int narg, const char** a) throat = Draw::Atof(a[i + 1]); if (throat > Precision::Confusion()) + { aMCh.Add(throat, E); + } } i += 2; } @@ -140,7 +154,9 @@ static int chamf_throat(Draw_Interpretor& di, int narg, const char** a) return 1; } else + { aMCh.Build(); + } if (aMCh.IsDone()) { @@ -178,11 +194,15 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) else { if (narg < 5) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } TopoDS_Edge E; TopoDS_Face F; @@ -195,7 +215,9 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) { TopoDS_Shape aLocalEdge(DBRep::Get(a[i], TopAbs_EDGE)); if (aLocalEdge.IsNull()) + { return 1; + } E = TopoDS::Edge(aLocalEdge); TopoDS_Shape aLocalFace(DBRep::Get(a[i + 1], TopAbs_FACE)); if (aLocalFace.IsNull()) @@ -203,7 +225,9 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) // symmetric chamfer (one distance) d1 = atof(a[i + 1]); if (aMCh.Contour(E) == 0 && d1 > Precision::Confusion()) + { aMCh.Add(d1, E); + } i += 2; } else @@ -220,7 +244,9 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) angle *= M_PI / 180.; if (aMCh.Contour(E) == 0 && d1 > Precision::Confusion() && angle > Precision::Confusion() && M_PI / 2 - angle > Precision::Confusion()) + { aMCh.AddDA(d1, angle, E, F); + } i += 5; } else @@ -229,7 +255,9 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) d1 = Draw::Atof(a[i + 2]); d2 = Draw::Atof(a[i + 3]); if (aMCh.Contour(E) == 0 && d1 > Precision::Confusion() && d2 > Precision::Confusion()) + { aMCh.Add(d1, d2, E, F); + } i += 4; } } @@ -244,7 +272,9 @@ static int chamfer(Draw_Interpretor& di, int narg, const char** a) return 1; } else + { aMCh.Build(); + } if (aMCh.IsDone()) { @@ -268,7 +298,9 @@ void BRepTest::ChamferCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_CheckCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_CheckCommands.cxx index 8a43e32d7b..3965b0e7b4 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_CheckCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_CheckCommands.cxx @@ -213,7 +213,9 @@ static void Print(Standard_OStream& OS, const BRepCheck_Analyzer& Ana, const Top for (; itl.More(); itl.Next()) { if (itl.Value() != BRepCheck_NoError) + { BRepCheck::Print(itl.Value(), OS); + } } } } @@ -325,7 +327,9 @@ static int checksection(Draw_Interpretor& di, int narg, const char** a) for (exp.Init(S, TopAbs_VERTEX); exp.More(); exp.Next()) { if (!theVertices.Add(exp.Current())) + { theVertices.Remove(exp.Current()); + } } // std::cout << " nb alone Vertices : " << theVertices.Extent() << std::endl; di << " nb alone Vertices : " << theVertices.Extent() << "\n"; @@ -461,8 +465,10 @@ void ContextualDump(Draw_Interpretor& theCommands, theMap.Clear(); if (nbfaulty != 0) + { theCommands << "Faulty shapes in variables " << checkfaultyname << "1 to " << checkfaultyname << nbfaulty << " \n"; + } theCommands << "\n"; } @@ -476,7 +482,9 @@ static void FillProblems(const BRepCheck_Status stat, const int anID = static_cast(stat); if ((NbProblems->Upper() < anID) || (NbProblems->Lower() > anID)) + { return; + } NbProblems->SetValue(anID, NbProblems->Value(anID) + 1); } @@ -508,8 +516,12 @@ static void GetProblemSub(const BRepCheck_Analyzer& Ana, int ii = 0; for (ii = 1; ii <= sl->Length(); ii++) + { if (sl->Value(ii).IsSame(sub)) + { break; + } + } if (ii > sl->Length()) { @@ -517,8 +529,12 @@ static void GetProblemSub(const BRepCheck_Analyzer& Ana, FillProblems(itl.Value(), NbProblems); } for (ii = 1; ii <= sl->Length(); ii++) + { if (sl->Value(ii).IsSame(Shape)) + { break; + } + } if (ii > sl->Length()) { sl->Append(Shape); @@ -598,7 +614,9 @@ void StructuralDump(Draw_Interpretor& theCommands, occ::handle> NbProblems = new NCollection_HArray1(1, NumberOfStatus); for (i = 1; i <= NumberOfStatus; i++) + { NbProblems->SetValue(i, 0); + } occ::handle> sl, slv, sle, slw, slf, sls, slo; sl = new NCollection_HSequence(); theMap.Clear(); @@ -607,183 +625,255 @@ void StructuralDump(Draw_Interpretor& theCommands, int aProblemID = static_cast(BRepCheck_InvalidPointOnCurve); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Point on Curve ................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidPointOnCurveOnSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Point on CurveOnSurface .......... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidPointOnSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Point on Surface ................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_No3DCurve); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " No 3D Curve .............................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_Multiple3DCurve); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Multiple 3D Curve ........................ " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_Invalid3DCurve); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid 3D Curve ......................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_NoCurveOnSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " No Curve on Surface ...................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidCurveOnSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Curve on Surface ................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidCurveOnClosedSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Curve on closed Surface .......... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidSameRangeFlag); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid SameRange Flag ................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidSameParameterFlag); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid SameParameter Flag ............... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidDegeneratedFlag); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Degenerated Flag ................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_FreeEdge); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Free Edge ................................ " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidMultiConnexity); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid MultiConnexity ................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidRange); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Range ............................ " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_EmptyWire); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Empty Wire ............................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_RedundantEdge); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Redundant Edge ........................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_SelfIntersectingWire); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Self Intersecting Wire ................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_NoSurface); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " No Surface ............................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidWire); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Wire ............................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_RedundantWire); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Redundant Wire ........................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_IntersectingWires); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Intersecting Wires ....................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidImbricationOfWires); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Imbrication of Wires ............. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_EmptyShell); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Empty Shell .............................. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_RedundantFace); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Redundant Face ........................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_UnorientableShape); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Unorientable Shape ....................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_NotClosed); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Not Closed ............................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_NotConnected); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Not Connected ............................ " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_SubshapeNotInShape); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Subshape not in Shape .................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_BadOrientation); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Bad Orientation .......................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_BadOrientationOfSubshape); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Bad Orientation of Subshape .............. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidToleranceValue); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid tolerance value................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidPolygonOnTriangulation); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid polygon on triangulation.......... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_InvalidImbricationOfShells); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Invalid Imbrication of Shells............. " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_EnclosedRegion); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " Enclosed Region........................... " << NbProblems->Value(aProblemID) << "\n"; + } aProblemID = static_cast(BRepCheck_CheckFail); if (NbProblems->Value(aProblemID) > 0) + { theCommands << " checkshape failure........................ " << NbProblems->Value(aProblemID) << "\n"; + } theCommands << " ------------------------------------------------\n"; theCommands << "*** Shapes with problems : " << sl->Length() << "\n"; @@ -831,14 +921,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = slv->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, slv->Value(i)); + } char aName[20]; Sprintf(aName, "%s_v", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "VERTEX : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "VERTEX : " << nb << " Items -> compound named " << aName << "\n"; + } } if (sle->Length() > 0) { @@ -846,14 +942,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = sle->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, sle->Value(i)); + } char aName[20]; Sprintf(aName, "%s_e", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "EDGE : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "EDGE : " << nb << " Items -> compound named " << aName << "\n"; + } } if (slw->Length() > 0) { @@ -861,14 +963,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = slw->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, slw->Value(i)); + } char aName[20]; Sprintf(aName, "%s_w", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "WIRE : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "WIRE : " << nb << " Items -> compound named " << aName << "\n"; + } } if (slf->Length() > 0) { @@ -876,14 +984,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = slf->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, slf->Value(i)); + } char aName[20]; Sprintf(aName, "%s_f", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "FACE : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "FACE : " << nb << " Items -> compound named " << aName << "\n"; + } } if (sls->Length() > 0) { @@ -891,14 +1005,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = sls->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, sls->Value(i)); + } char aName[20]; Sprintf(aName, "%s_s", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "SHELL : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "SHELL : " << nb << " Items -> compound named " << aName << "\n"; + } } if (slo->Length() > 0) { @@ -906,14 +1026,20 @@ void StructuralDump(Draw_Interpretor& theCommands, B.MakeCompound(comp); int nb = slo->Length(); for (i = 1; i <= nb; i++) + { B.Add(comp, slo->Value(i)); + } char aName[20]; Sprintf(aName, "%s_o", Pref); DBRep::Set(aName, comp); if (nb > 9) + { theCommands << "SOLID : " << nb << " Items -> compound named " << aName << "\n"; + } else + { theCommands << "SOLID : " << nb << " Items -> compound named " << aName << "\n"; + } } } @@ -1077,15 +1203,21 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) InitEpsSurf(epsnl, epsC0, epsC1, epsC2, epsG1, percent, maxlen); bool ISG1 = true; if (n < 4) + { return 1; + } TopoDS_Face face1, face2; double f1, f2, l1, l2; TopoDS_Shape shape = DBRep::Get(a[1], TopAbs_SHAPE); if (shape.IsNull()) + { return 1; + } TopoDS_Shape edge = DBRep::Get(a[2], TopAbs_EDGE); if (edge.IsNull()) + { return 1; + } // calcul des deux faces NCollection_IndexedDataMap, TopTools_ShapeMapHasher> lface; @@ -1094,7 +1226,9 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) int nelem = lfac.Extent(); if (nelem != 2) + { return 1; + } NCollection_List::Iterator It; It.Initialize(lfac); face1 = TopoDS::Face(It.Value()); @@ -1106,13 +1240,19 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) // calcul des deux pcurves const occ::handle c1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face1, f1, l1); if (c1.IsNull()) + { return 1; + } if (IsSeam) + { edge.Reverse(); + } const occ::handle c2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face2, f2, l2); if (c2.IsNull()) + { return 1; + } occ::handle curv1 = new Geom2d_TrimmedCurve(c1, f1, l1); @@ -1125,22 +1265,30 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) // const occ::handle& s1 = // BRep_Tool::Surface(TopoDS::Face(face1),L1); if (s1.IsNull()) + { return 1; + } aLocalFace = face2; const occ::handle& s2 = BRep_Tool::Surface(aLocalFace, L2); // const occ::handle& s2 = // BRep_Tool::Surface(TopoDS::Face(face2),L2); if (s2.IsNull()) + { return 1; + } occ::handle surf1 = occ::down_cast(s1->Transformed(L1.Transformation())); if (surf1.IsNull()) + { return 1; + } occ::handle surf2 = occ::down_cast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) + { return 1; + } nbeval = (int)Draw::Atof(a[3]); @@ -1196,13 +1344,19 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) if (isconti) { if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } if (res.G1Angle() > MaxG1Angle) + { MaxG1Angle = res.G1Angle(); + } } } else + { isconti = false; + } } else @@ -1230,17 +1384,24 @@ static int shapeG1continuity(Draw_Interpretor& di, int n, const char** a) MaxG1Angle = res.G1Angle(); } if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } if (res.G1Angle() > MaxG1Angle) + { MaxG1Angle = res.G1Angle(); - ; + }; } else + { isconti = false; + } } if (!isconti) + { ISG1 = false; + } nb++; } while ((nb < nbeval) && isdone); @@ -1279,15 +1440,21 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) InitEpsSurf(epsnl, epsC0, epsC1, epsC2, epsG1, percent, maxlen); if (n < 4) + { return 1; + } TopoDS_Face face1, face2; double f1, f2, l1, l2; TopoDS_Shape shape = DBRep::Get(a[1], TopAbs_SHAPE); if (shape.IsNull()) + { return 1; + } TopoDS_Shape edge = DBRep::Get(a[2], TopAbs_EDGE); if (edge.IsNull()) + { return 1; + } // calcul des deux faces NCollection_IndexedDataMap, TopTools_ShapeMapHasher> lface; @@ -1296,7 +1463,9 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) int nelem = lfac.Extent(); if (nelem != 2) + { return 1; + } NCollection_List::Iterator It; It.Initialize(lfac); face1 = TopoDS::Face(It.Value()); @@ -1308,13 +1477,19 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) // calcul des deux pcurves const occ::handle c1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face1, f1, l1); if (c1.IsNull()) + { return 1; + } if (IsSeam) + { edge.Reverse(); + } const occ::handle c2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face2, f2, l2); if (c2.IsNull()) + { return 1; + } occ::handle curv1 = new Geom2d_TrimmedCurve(c1, f1, l1); @@ -1327,22 +1502,30 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) // const occ::handle& s1 = // BRep_Tool::Surface(TopoDS::Face(face1),L1); if (s1.IsNull()) + { return 1; + } aLocalFace = face2; const occ::handle& s2 = BRep_Tool::Surface(aLocalFace, L2); // const occ::handle& s2 = // BRep_Tool::Surface(TopoDS::Face(face2),L2); if (s2.IsNull()) + { return 1; + } occ::handle surf1 = occ::down_cast(s1->Transformed(L1.Transformation())); if (surf1.IsNull()) + { return 1; + } occ::handle surf2 = occ::down_cast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) + { return 1; + } nbeval = (int)Draw::Atof(a[3]); @@ -1393,11 +1576,17 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) { isconti = res.IsC0(); if (isconti) + { if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } + } } else + { isconti = false; + } } else @@ -1424,16 +1613,22 @@ static int shapeG0continuity(Draw_Interpretor& di, int n, const char** a) MaxG0Value = res.C0Value(); } if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } } else + { isconti = false; + } } nb++; if (!isconti) + { ISG0 = false; + } } while ((nb < nbeval) && isdone); @@ -1472,15 +1667,21 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) InitEpsSurf(epsnl, epsC0, epsC1, epsC2, epsG1, percent, maxlen); if (n < 4) + { return 1; + } TopoDS_Face face1, face2; double f1, f2, l1, l2; TopoDS_Shape shape = DBRep::Get(a[1], TopAbs_SHAPE); if (shape.IsNull()) + { return 1; + } TopoDS_Shape edge = DBRep::Get(a[2], TopAbs_EDGE); if (edge.IsNull()) + { return 1; + } // calcul des deux faces NCollection_IndexedDataMap, TopTools_ShapeMapHasher> lface; @@ -1489,7 +1690,9 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) int nelem = lfac.Extent(); if (nelem != 2) + { return 1; + } NCollection_List::Iterator It; It.Initialize(lfac); face1 = TopoDS::Face(It.Value()); @@ -1501,13 +1704,19 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) // calcul des deux pcurves const occ::handle c1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face1, f1, l1); if (c1.IsNull()) + { return 1; + } if (IsSeam) + { edge.Reverse(); + } const occ::handle c2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(edge), face2, f2, l2); if (c2.IsNull()) + { return 1; + } occ::handle curv1 = new Geom2d_TrimmedCurve(c1, f1, l1); @@ -1520,22 +1729,30 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) // const occ::handle& s1 = // BRep_Tool::Surface(TopoDS::Face(face1),L1); if (s1.IsNull()) + { return 1; + } aLocalFace = face2; const occ::handle& s2 = BRep_Tool::Surface(aLocalFace, L2); // const occ::handle& s2 = // BRep_Tool::Surface(TopoDS::Face(face2),L2); if (s2.IsNull()) + { return 1; + } occ::handle surf1 = occ::down_cast(s1->Transformed(L1.Transformation())); if (surf1.IsNull()) + { return 1; + } occ::handle surf2 = occ::down_cast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) + { return 1; + } nbeval = (int)Draw::Atof(a[3]); @@ -1596,15 +1813,23 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) if (isconti) { if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } if (res.G1Angle() > MaxG1Angle) + { MaxG1Angle = res.G1Angle(); + } if (res.G2CurvatureGap() > MaxG2Curvature) + { MaxG2Curvature = res.G2CurvatureGap(); + } } } else + { isconti = false; + } } else @@ -1633,19 +1858,29 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) MaxG2Curvature = res.G2CurvatureGap(); } if (res.C0Value() > MaxG0Value) + { MaxG0Value = res.C0Value(); + } if (res.G1Angle() > MaxG1Angle) + { MaxG1Angle = res.G1Angle(); + } if (res.G2CurvatureGap() > MaxG2Curvature) + { MaxG2Curvature = res.G2CurvatureGap(); + } } else + { isconti = false; + } } nb++; if (!isconti) + { ISG2 = false; + } } while ((nb < nbeval) && isdone); @@ -1662,9 +1897,13 @@ static int shapeG2continuity(Draw_Interpretor& di, int n, const char** a) return 1; } if (ISG2) + { di << " the continuity is G2 \n"; + } else + { di << " the continuity is not G2 \n"; + } di << "MaxG0Value :" << MaxG0Value << "\n"; di << "MaxG1Angle:" << MaxG1Angle << "\n"; di << "MaxG2Curvature:" << MaxG2Curvature << "\n"; @@ -1705,7 +1944,9 @@ static int clintedge(Draw_Interpretor& di, int narg, const char** a) di << "\n"; } else + { di << "no internal (or external) edges\n"; + } // std::cout << "no internal (or external) edges"<= 5) { DBRep::Set( @@ -85,9 +87,13 @@ static int vertex(Draw_Interpretor&, int n, const char** a) { TopoDS_Shape S = DBRep::Get(a[3]); if (S.IsNull()) + { return 0; + } if (S.ShapeType() != TopAbs_EDGE) + { return 0; + } BRepAdaptor_Curve C(TopoDS::Edge(S)); gp_Pnt P; C.D0(Draw::Atof(a[2]), P); @@ -108,24 +114,32 @@ static int vertex(Draw_Interpretor&, int n, const char** a) static int range(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape aLocalShape(DBRep::Get(a[1], TopAbs_EDGE)); TopoDS_Edge E = TopoDS::Edge(aLocalShape); // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[1],TopAbs_EDGE)); if (E.IsNull()) + { return 1; + } double f = Draw::Atof(a[n - 2]); double l = Draw::Atof(a[n - 1]); BRep_Builder B; if (n == 4) + { B.Range(E, f, l); + } else { aLocalShape = DBRep::Get(a[2], TopAbs_FACE); TopoDS_Face F = TopoDS::Face(aLocalShape); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } B.Range(E, F, f, l); } return 0; @@ -138,25 +152,39 @@ static int range(Draw_Interpretor&, int n, const char** a) static int trim(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape e = DBRep::Get(a[1]); if (e.IsNull()) + { return 1; + } if (e.ShapeType() != TopAbs_EDGE) + { return 1; + } TopoDS_Shape v1 = DBRep::Get(a[2]); if (v1.IsNull()) + { return 1; + } if (v1.ShapeType() != TopAbs_VERTEX) + { return 1; + } TopoDS_Shape v2; if (n > 3) { v2 = DBRep::Get(a[3]); if (v2.IsNull()) + { return 1; + } if (v2.ShapeType() != TopAbs_VERTEX) + { return 1; + } } TopLoc_Location L; double f, l; @@ -197,9 +225,13 @@ static int trim(Draw_Interpretor& di, int n, const char** a) static int polyline(Draw_Interpretor&, int n, const char** a) { if (n < 8) + { return 1; + } if (((n - 2) % 3) != 0) + { return 1; + } int i, j, np = (n - 2) / 3; BRepBuilderAPI_MakePolygon W; j = 2; @@ -219,16 +251,22 @@ static int polyline(Draw_Interpretor&, int n, const char** a) static int polyvertex(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } int i; BRepBuilderAPI_MakePolygon W; for (i = 2; i < n; i++) { TopoDS_Shape S = DBRep::Get(a[i]); if (S.IsNull()) + { return 1; + } if (S.ShapeType() != TopAbs_VERTEX) + { return 1; + } W.Add(TopoDS::Vertex(S)); } DBRep::Set(a[1], W.Wire()); @@ -242,24 +280,36 @@ static int polyvertex(Draw_Interpretor&, int n, const char** a) static int wire(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } int i; BRepBuilderAPI_MakeWire MW; bool IsUnsorted = !strcmp(a[2], "-unsorted"); if (!IsUnsorted) + { for (i = 2; i < n; i++) { TopoDS_Shape S = DBRep::Get(a[i]); if (S.IsNull()) + { continue; + } if (S.ShapeType() == TopAbs_EDGE) + { MW.Add(TopoDS::Edge(S)); + } else if (S.ShapeType() == TopAbs_WIRE) + { MW.Add(TopoDS::Wire(S)); + } else + { continue; + } } + } else { NCollection_List aLE; @@ -271,7 +321,9 @@ static int wire(Draw_Interpretor& di, int n, const char** a) { const TopoDS_Edge& anE = TopoDS::Edge(Exp.Current()); if (!anE.IsNull()) + { aLE.Append(anE); + } } } MW.Add(aLE); @@ -297,7 +349,9 @@ static int wire(Draw_Interpretor& di, int n, const char** a) } } else + { DBRep::Set(a[1], MW); + } return 0; } @@ -308,7 +362,9 @@ static int wire(Draw_Interpretor& di, int n, const char** a) static int mkedge(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle C = DrawTrSurf::GetCurve(a[2]); occ::handle C2d = DrawTrSurf::GetCurve2d(a[2]); @@ -326,9 +382,13 @@ static int mkedge(Draw_Interpretor& di, int n, const char** a) if (n == 3) { if (!C.IsNull()) + { edge = BRepBuilderAPI_MakeEdge(C); + } else if (!C2d.IsNull()) + { edge = BRepBuilderAPI_MakeEdge2d(C2d); + } else { BRep_Builder aBB; @@ -343,7 +403,9 @@ static int mkedge(Draw_Interpretor& di, int n, const char** a) { S = DrawTrSurf::GetSurface(a[3]); if (!S.IsNull()) + { i = 1; + } } TopoDS_Shape aLocalShape(DBRep::Get(a[3 + i], TopAbs_VERTEX)); TopoDS_Vertex V1 = TopoDS::Vertex(aLocalShape); @@ -353,11 +415,17 @@ static int mkedge(Draw_Interpretor& di, int n, const char** a) if (V1.IsNull()) { if (!C.IsNull()) + { edge = BRepBuilderAPI_MakeEdge(C, Draw::Atof(a[3]), Draw::Atof(a[4])); + } else if (S.IsNull()) + { edge = BRepBuilderAPI_MakeEdge2d(C2d, Draw::Atof(a[3]), Draw::Atof(a[4])); + } else + { edge = BRepBuilderAPI_MakeEdge(C2d, S, Draw::Atof(a[4]), Draw::Atof(a[5])); + } } else { @@ -365,11 +433,17 @@ static int mkedge(Draw_Interpretor& di, int n, const char** a) TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape); // TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[4+i],TopAbs_VERTEX)); if (!C.IsNull()) + { edge = BRepBuilderAPI_MakeEdge(C, V1, V2); + } else if (S.IsNull()) + { edge = BRepBuilderAPI_MakeEdge2d(C2d, V1, V2); + } else + { edge = BRepBuilderAPI_MakeEdge(C2d, S, V1, V2); + } } } else if (n == 7 + i) @@ -378,14 +452,22 @@ static int mkedge(Draw_Interpretor& di, int n, const char** a) TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape); // TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[5+i],TopAbs_VERTEX)); if (!C.IsNull()) + { edge = BRepBuilderAPI_MakeEdge(C, V1, V2, Draw::Atof(a[4]), Draw::Atof(a[6])); + } else if (S.IsNull()) + { edge = BRepBuilderAPI_MakeEdge2d(C2d, V1, V2, Draw::Atof(a[4]), Draw::Atof(a[6])); + } else + { edge = BRepBuilderAPI_MakeEdge(C2d, S, V1, V2, Draw::Atof(a[5]), Draw::Atof(a[7])); + } } else + { return 1; + } } DBRep::Set(a[1], edge); @@ -402,13 +484,17 @@ Standard_IMPORT Draw_Color DBRep_ColorOrientation(const TopAbs_Orientation Or); static int mkcurve(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } bool DispOrientation = !strcmp(a[0], "mkoricurve"); TopoDS_Shape S = DBRep::Get(a[2], TopAbs_EDGE); if (S.IsNull()) + { return 1; + } TopLoc_Location L; double f, l; @@ -443,11 +529,15 @@ static int mkcurve(Draw_Interpretor& di, int n, const char** a) static int mkpoint(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2], TopAbs_VERTEX); if (S.IsNull()) + { return 1; + } TopoDS_Vertex V = TopoDS::Vertex(S); @@ -464,12 +554,16 @@ static int mkpoint(Draw_Interpretor&, int n, const char** a) static int mk2dcurve(Draw_Interpretor& di, int na, const char** a) { if (na < 3) + { return 1; + } TopoDS_Shape S; S = DBRep::Get(a[2], TopAbs_EDGE); if (S.IsNull()) + { return 1; + } TopoDS_Edge E = TopoDS::Edge(S); @@ -528,11 +622,15 @@ static int mk2dcurve(Draw_Interpretor& di, int na, const char** a) static int edge(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape V1 = DBRep::Get(a[2], TopAbs_VERTEX); TopoDS_Shape V2 = DBRep::Get(a[3], TopAbs_VERTEX); if (V1.IsNull() || V2.IsNull()) + { return 1; + } TopoDS_Edge E = BRepBuilderAPI_MakeEdge(TopoDS::Vertex(V1), TopoDS::Vertex(V2)); DBRep::Set(a[1], E); return 0; @@ -545,7 +643,9 @@ static int edge(Draw_Interpretor&, int n, const char** a) static int isoedge(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } bool uiso = *a[0] == 'u'; double p = Draw::Atof(a[3]); @@ -553,7 +653,9 @@ static int isoedge(Draw_Interpretor&, int n, const char** a) double p2 = Draw::Atof(a[5]); TopoDS_Shape Sh = DBRep::Get(a[2], TopAbs_FACE); if (Sh.IsNull()) + { return 1; + } TopLoc_Location Loc; const occ::handle& S = BRep_Tool::Surface(TopoDS::Face(Sh), Loc); double UMin, UMax, VMin, VMax; @@ -600,12 +702,16 @@ static int isoedge(Draw_Interpretor&, int n, const char** a) static int transfert(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape E1 = DBRep::Get(a[1], TopAbs_EDGE); TopoDS_Shape E2 = DBRep::Get(a[2], TopAbs_EDGE); if (E1.IsNull() || E2.IsNull()) + { return 1; + } BRep_Builder B; B.Transfert(TopoDS::Edge(E1), TopoDS::Edge(E2)); @@ -721,7 +827,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'f': i += 2; if (i >= n) + { goto badargs; + } if (!first) { di << "profile: The F instruction must precede all moves"; @@ -736,7 +844,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'o': i += 3; if (i >= n) + { goto badargs; + } P.SetLocation(gp_Pnt(Draw::Atof(a[i - 2]), Draw::Atof(a[i - 1]), Draw::Atof(a[i]))); stayfirst = true; break; @@ -745,7 +855,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'p': i += 6; if (i >= n) + { goto badargs; + } { gp_Vec vn(Draw::Atof(a[i - 5]), Draw::Atof(a[i - 4]), Draw::Atof(a[i - 3])); gp_Vec vx(Draw::Atof(a[i - 2]), Draw::Atof(a[i - 1]), Draw::Atof(a[i])); @@ -769,7 +881,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 's': i += 1; if (i >= n) + { goto badargs; + } { TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_FACE)); TopoDS_Face Face = TopoDS::Face(aLocalShape); @@ -786,7 +900,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) isplanar = false; } else + { P = Plane->Pln(); + } } stayfirst = true; break; @@ -795,7 +911,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'x': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'X') || (a[i - 1][1] == 'x')) { @@ -810,7 +928,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'y': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'Y') || (a[i - 1][1] == 'y')) { @@ -825,7 +945,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'l': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); move = line; break; @@ -834,7 +956,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 't': i += 2; if (i >= n) + { goto badargs; + } { double vx = Draw::Atof(a[i - 1]); double vy = Draw::Atof(a[i]); @@ -857,7 +981,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'r': i++; if (i >= n) + { goto badargs; + } angle = Draw::Atof(a[i]) * (M_PI / 180.0); if ((a[i - 1][1] == 'R') || (a[i - 1][1] == 'r')) { @@ -878,7 +1004,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'd': i += 2; if (i >= n) + { goto badargs; + } { double vx = Draw::Atof(a[i - 1]); double vy = Draw::Atof(a[i]); @@ -896,7 +1024,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'c': i += 2; if (i >= n) + { goto badargs; + } radius = Draw::Atof(a[i - 1]); if (std::abs(radius) > Precision::Confusion()) { @@ -909,7 +1039,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) case 'i': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'X') || (a[i - 1][1] == 'x')) { @@ -963,9 +1095,13 @@ static int profile(Draw_Interpretor& di, int n, const char** a) } occ::handle l = new Geom2d_Line(gp_Pnt2d(x, y), gp_Dir2d(dx, dy)); if (isplanar) + { MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(l, P), 0, length)); + } else + { MW.Add(BRepBuilderAPI_MakeEdge(l, Surface, 0, length)); + } x += length * dx; y += length * dy; } @@ -988,9 +1124,13 @@ static int profile(Draw_Interpretor& di, int n, const char** a) } occ::handle c = new Geom2d_Circle(ax, radius, sense); if (isplanar) + { MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(c, P), 0, angle)); + } else + { MW.Add(BRepBuilderAPI_MakeEdge(c, Surface, 0, angle)); + } gp_Pnt2d p; gp_Vec2d v; c->D1(angle, p, v); @@ -1032,7 +1172,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) if (face) { if (isplanar) + { S = BRepBuilderAPI_MakeFace(P, MW.Wire()); + } else { BRepBuilderAPI_MakeFace MFace; @@ -1047,7 +1189,9 @@ static int profile(Draw_Interpretor& di, int n, const char** a) } if (!TheLocation.IsIdentity()) + { S.Move(TheLocation); + } if (!isplanar) { @@ -1143,7 +1287,9 @@ static int bsplineprof(Draw_Interpretor& di, int n, const char** a) isplanar = false; } else + { P = Plane->Pln(); + } } i += 1; break; @@ -1271,14 +1417,20 @@ static int bsplineprof(Draw_Interpretor& di, int n, const char** a) length = a_vector.Magnitude(); occ::handle l = new Geom2d_Line(gp_Pnt2d(x, y), gp_Dir2d(dx, dy)); if (isplanar) + { MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(l, P), 0, length)); + } else + { MW.Add(BRepBuilderAPI_MakeEdge(l, Surface, 0, length)); + } } if (face) { if (isplanar) + { S = BRepBuilderAPI_MakeFace(P, MW.Wire()); + } else { BRepBuilderAPI_MakeFace MFace; @@ -1293,7 +1445,9 @@ static int bsplineprof(Draw_Interpretor& di, int n, const char** a) } if (!TheLocation.IsIdentity()) + { S.Move(TheLocation); + } if (!isplanar) { @@ -1401,7 +1555,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'f': i += 2; if (i >= n) + { goto badargs; + } if (!first) { di << "profile: The F instruction must precede all moves"; @@ -1416,7 +1572,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'x': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'X') || (a[i - 1][1] == 'x')) { @@ -1431,7 +1589,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'y': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'Y') || (a[i - 1][1] == 'y')) { @@ -1446,7 +1606,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'l': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); move = line; break; @@ -1455,7 +1617,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 't': i += 2; if (i >= n) + { goto badargs; + } { double vx = Draw::Atof(a[i - 1]); double vy = Draw::Atof(a[i]); @@ -1478,7 +1642,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'r': i++; if (i >= n) + { goto badargs; + } angle = Draw::Atof(a[i]) * (M_PI / 180.0); if ((a[i - 1][1] == 'R') || (a[i - 1][1] == 'r')) { @@ -1499,7 +1665,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'd': i += 2; if (i >= n) + { goto badargs; + } { double vx = Draw::Atof(a[i - 1]); double vy = Draw::Atof(a[i]); @@ -1517,7 +1685,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'c': i += 2; if (i >= n) + { goto badargs; + } radius = Draw::Atof(a[i - 1]); if (std::abs(radius) > Precision::Confusion()) { @@ -1530,7 +1700,9 @@ static int profile2d(Draw_Interpretor& di, int n, const char** a) case 'i': i++; if (i >= n) + { goto badargs; + } length = Draw::Atof(a[i]); if ((a[i - 1][1] == 'X') || (a[i - 1][1] == 'x')) { @@ -1667,7 +1839,9 @@ badargs: int mkoffset(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } char name[100]; BRepOffsetAPI_MakeOffset Paral; @@ -1685,7 +1859,9 @@ int mkoffset(Draw_Interpretor& di, int n, const char** a) } if (n >= anIndArg && strcmp(a[anIndArg - 1], "i") == 0) + { theJoinType = GeomAbs_Intersection; + } } TopoDS_Shape Base = DBRep::Get(a[2], TopAbs_FACE); @@ -1694,7 +1870,9 @@ int mkoffset(Draw_Interpretor& di, int n, const char** a) { Base = DBRep::Get(a[2]); if (Base.IsNull()) + { return 1; + } Paral.Init(theJoinType); TopExp_Explorer exp; for (exp.Init(Base, TopAbs_WIRE); exp.More(); exp.Next()) @@ -1717,7 +1895,9 @@ int mkoffset(Draw_Interpretor& di, int n, const char** a) double Alt = 0.; if (n > anIndArg) + { Alt = Draw::Atof(a[anIndArg]); + } int Compt = 1; @@ -1747,7 +1927,9 @@ int mkoffset(Draw_Interpretor& di, int n, const char** a) int openoffset(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } char name[100]; BRepOffsetAPI_MakeOffset Paral; @@ -1765,7 +1947,9 @@ int openoffset(Draw_Interpretor& di, int n, const char** a) } if (n >= anIndArg && strcmp(a[anIndArg - 1], "i") == 0) + { theJoinType = GeomAbs_Intersection; + } } TopoDS_Shape Base = DBRep::Get(a[2], TopAbs_FACE); @@ -1774,7 +1958,9 @@ int openoffset(Draw_Interpretor& di, int n, const char** a) { Base = DBRep::Get(a[2], TopAbs_WIRE); if (Base.IsNull()) + { return 1; + } Paral.Init(theJoinType, true); Paral.AddWire(TopoDS::Wire(Base)); } @@ -1823,7 +2009,9 @@ int pickface(Draw_Interpretor& di, int, const char**) TopoDS_Shape S = DBRep::Get(pick_name, TopAbs_FACE); if (S.IsNull()) + { return 1; + } char* name = new char[100]; Sprintf(name, "PickedFace %s", pick_name); @@ -1835,24 +2023,32 @@ int pickface(Draw_Interpretor& di, int, const char**) int edgeintersector(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } TopoDS_Edge E[2]; TopoDS_Shape aLocalShape(DBRep::Get(a[2], TopAbs_EDGE)); E[0] = TopoDS::Edge(aLocalShape); // E[0] = TopoDS::Edge(DBRep::Get(a[2],TopAbs_EDGE)); if (E[0].IsNull()) + { return 1; + } aLocalShape = DBRep::Get(a[3], TopAbs_EDGE); E[1] = TopoDS::Edge(aLocalShape); // E[1] = TopoDS::Edge(DBRep::Get(a[3],TopAbs_EDGE)); if (E[1].IsNull()) + { return 1; + } aLocalShape = DBRep::Get(a[4], TopAbs_FACE); TopoDS_Face F = TopoDS::Face(aLocalShape); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[4],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } TopOpeBRep_EdgesIntersector EInter; char name[100]; @@ -1862,7 +2058,9 @@ int edgeintersector(Draw_Interpretor& di, int n, const char** a) EInter.SetFaces(F, F); double TolInter = 1.e-7; if (n == 6) + { TolInter = Draw::Atof(a[5]); + } EInter.ForceTolerances(TolInter, TolInter); bool reducesegments = true; EInter.Perform(E[0], E[1], reducesegments); @@ -1941,8 +2139,8 @@ static int arclinconvert(Draw_Interpretor& /*dout*/, int n, const char** a) // Check the command arguments if (n < 3) { - std::cout << "Error: " << a[0] << " - invalid number of arguments" << std::endl; - std::cout << "Usage: type help " << a[0] << std::endl; + std::cout << "Error: " << a[0] << " - invalid number of arguments" << '\n'; + std::cout << "Usage: type help " << a[0] << '\n'; return 1; // TCL_ERROR } @@ -1950,22 +2148,24 @@ static int arclinconvert(Draw_Interpretor& /*dout*/, int n, const char** a) const TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) { - std::cout << "Error: " << a[2] << " is null" << std::endl; + std::cout << "Error: " << a[2] << " is null" << '\n'; return 1; // TCL_ERROR } TopAbs_ShapeEnum aType = aShape.ShapeType(); if (aType != TopAbs_WIRE && aType != TopAbs_FACE) { - std::cout << "Error: " << a[2] << " is neither wire no face" << std::endl; + std::cout << "Error: " << a[2] << " is neither wire no face" << '\n'; return 1; // TCL_ERROR } // read tolerance double aTol = 0.01; if (n > 3) + { aTol = Draw::Atof(a[3]); - std::cout << "Info: tolerance is set to " << aTol << std::endl; + } + std::cout << "Info: tolerance is set to " << aTol << '\n'; TopoDS_Shape aResult; @@ -1975,7 +2175,7 @@ static int arclinconvert(Draw_Interpretor& /*dout*/, int n, const char** a) BRepBuilderAPI_MakeFace aFaceMaker(TopoDS::Wire(aShape), OnlyPlane); if (aFaceMaker.Error() != BRepBuilderAPI_FaceDone) { - std::cout << "Error: failed to find a face for the wire " << a[2] << std::endl; + std::cout << "Error: failed to find a face for the wire " << a[2] << '\n'; return 1; // TCL_ERROR } const TopoDS_Face& aFace = aFaceMaker.Face(); @@ -1991,7 +2191,7 @@ static int arclinconvert(Draw_Interpretor& /*dout*/, int n, const char** a) if (aResult.IsNull()) { - std::cout << "Error: could not convert " << a[2] << std::endl; + std::cout << "Error: could not convert " << a[2] << '\n'; return 1; // TCL_ERROR } @@ -2004,12 +2204,16 @@ static int arclinconvert(Draw_Interpretor& /*dout*/, int n, const char** a) int concatC0wire(Draw_Interpretor&, int n, const char** c) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(c[2], TopAbs_WIRE); if (S.IsNull()) + { return 1; // test if the shape is empty + } TopoDS_Wire W = TopoDS::Wire(S); TopoDS_Shape res; @@ -2029,16 +2233,24 @@ static int concatwire(Draw_Interpretor&, int n, const char** c) { GeomAbs_Shape Option = GeomAbs_C1; if (n < 3) + { return 1; + } - if (n == 4) // check if it's C1 or G1 + if (n == 4) + { // check if it's C1 or G1 if (!strcmp(c[3], "G1")) + { Option = GeomAbs_G1; + } + } TopoDS_Shape S = DBRep::Get(c[2], TopAbs_WIRE); if (S.IsNull()) + { return 1; // test if the shape is empty + } TopoDS_Wire W = TopoDS::Wire(S); TopoDS_Wire res; @@ -2062,7 +2274,9 @@ int build3d(Draw_Interpretor& di, int n, const char** a) bool Ok; TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } if (n == 2) { @@ -2089,17 +2303,23 @@ int build3d(Draw_Interpretor& di, int n, const char** a) int reducepcurves(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } int i; for (i = 1; i < n; i++) { TopoDS_Shape aShape = DBRep::Get(a[i]); if (aShape.IsNull()) + { // std::cout << a[i] << " is not a valid shape" << std::endl; di << a[i] << " is not a valid shape\n"; + } else + { BRepTools::RemoveUnusedPCurves(aShape); + } } return 0; @@ -2111,7 +2331,9 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_DraftAngleCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_DraftAngleCommands.cxx index da8a374c26..aff0e274f2 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_DraftAngleCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_DraftAngleCommands.cxx @@ -53,7 +53,9 @@ static void Print(Draw_Interpretor& di, const Draft_ErrorStatus St) static int DEP(Draw_Interpretor& theCommands, int narg, const char** a) { if ((narg < 14) || (narg % 8 != 6)) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); BRepOffsetAPI_DraftAngle drft(V); @@ -103,7 +105,9 @@ static int DEP(Draw_Interpretor& theCommands, int narg, const char** a) static int NDEP(Draw_Interpretor& theCommands, int narg, const char** a) { if ((narg < 15) || ((narg) % 9 != 6)) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); if (V.IsNull()) { @@ -172,7 +176,9 @@ static int draft(Draw_Interpretor& di, int n, const char** a) int Inside = -1; bool Internal = false; if (n < 8) + { return 1; + } double x, y, z, teta; TopoDS_Shape SInit = DBRep::Get(a[2]); // shape d'arret @@ -230,7 +236,9 @@ static int draft(Draw_Interpretor& di, int n, const char** a) // std::cout << "Internal Draft : " << std::endl; } else + { di << "External Draft : \n"; + } // std::cout << "External Draft : " << std::endl; TopoDS_Shape Stop = DBRep::Get(a[7]); // shape d'arret @@ -238,7 +246,9 @@ static int draft(Draw_Interpretor& di, int n, const char** a) { bool KeepOutside = true; if (Inside == 0) + { KeepOutside = false; + } MkDraft.Perform(Stop, KeepOutside); } else @@ -248,7 +258,9 @@ static int draft(Draw_Interpretor& di, int n, const char** a) { // surface d'arret bool KeepInside = true; if (Inside == 1) + { KeepInside = false; + } MkDraft.Perform(Surf, KeepInside); } else @@ -259,7 +271,9 @@ static int draft(Draw_Interpretor& di, int n, const char** a) MkDraft.Perform(L); } else + { return 1; + } } } @@ -275,7 +289,9 @@ void BRepTest::DraftAngleCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_ExtremaCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_ExtremaCommands.cxx index 9683425d32..e9913bb3fe 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_ExtremaCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_ExtremaCommands.cxx @@ -38,7 +38,9 @@ static int distance(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } const char* name1 = a[1]; const char* name2 = a[2]; @@ -46,11 +48,15 @@ static int distance(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape S1 = DBRep::Get(name1); TopoDS_Shape S2 = DBRep::Get(name2); if (S1.IsNull() || S2.IsNull()) + { return 1; + } gp_Pnt P1, P2; double D; if (!BRepExtrema_Poly::Distance(S1, S2, P1, P2, D)) + { return 1; + } // std::cout << " distance : " << D << std::endl; di << " distance : " << D << "\n"; TopoDS_Edge E = BRepLib_MakeEdge(P1, P2); @@ -129,9 +135,13 @@ static int distmini(Draw_Interpretor& di, int n, const char** a) TopoDS_Vertex V = BRepLib_MakeVertex(P1); char namev[100]; if (i1 == 1) + { Sprintf(namev, "%s", ns0); + } else + { Sprintf(namev, "%s%d", ns0, i1); + } char* tempv = namev; DBRep::Set(tempv, V); di << namev << " "; @@ -159,7 +169,9 @@ static int distmini(Draw_Interpretor& di, int n, const char** a) } else + { di << "problem: no distance is found\n"; + } return 0; } diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_FeatureCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_FeatureCommands.cxx index b22968a6af..9c062314fd 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_FeatureCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_FeatureCommands.cxx @@ -148,7 +148,9 @@ static void Print(Draw_Interpretor& di, const BRepFeat_Status St) static int Loc(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 6) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); TopoDS_Shape T = DBRep::Get(a[3]); @@ -245,7 +247,9 @@ static int Loc(Draw_Interpretor& theCommands, int narg, const char** a) static int HOLE1(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 10 || narg == 11) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -282,7 +286,9 @@ static int HOLE1(Draw_Interpretor& theCommands, int narg, const char** a) static int HOLE2(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 10) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -309,7 +315,9 @@ static int HOLE2(Draw_Interpretor& theCommands, int narg, const char** a) static int HOLE3(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 10) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -335,7 +343,9 @@ static int HOLE3(Draw_Interpretor& theCommands, int narg, const char** a) static int HOLE4(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 11) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -433,7 +443,9 @@ static void reportOffsetState(Draw_Interpretor& theCommands, const BRepOffset_Er static int PRW(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 9) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[3]); BRepFeat_MakePrism thePFace; gp_Vec V; @@ -504,7 +516,9 @@ static int PRW(Draw_Interpretor& theCommands, int narg, const char** a) else { if (a[i][1] == '\0') + { return 1; + } const char* Temp = a[i] + 1; aLocalShape = DBRep::Get(Temp, TopAbs_WIRE); wir = TopoDS::Wire(aLocalShape); @@ -636,7 +650,9 @@ static int PRW(Draw_Interpretor& theCommands, int narg, const char** a) static int PRF(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 8) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[3]); BRepFeat_MakePrism thePFace; int borne; @@ -876,7 +892,9 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) } if (aSh.ShapeType() == TopAbs_FACE) + { EF = TopoDS::Face(aSh); + } else { if (aSh.ShapeType() == TopAbs_COMPOUND || aSh.ShapeType() == TopAbs_WIRE @@ -884,7 +902,9 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) { TopExp_Explorer aExpE(aSh, TopAbs_EDGE, TopAbs_FACE); for (; aExpE.More(); aExpE.Next()) + { aSplitEdges.Append(aExpE.Current()); + } isSplittingEdges = !aSplitEdges.IsEmpty(); } @@ -908,7 +928,9 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) if (a[i][0] == '-') { if (a[i][1] == '\0') + { return 1; + } pick = (a[i][1] == '.'); const char* Temp = a[i] + 1; W = DBRep::Get(Temp, TopAbs_SHAPE, false); @@ -968,7 +990,9 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) } TopExp_Explorer aExpE(aSh, TopAbs_EDGE, TopAbs_FACE); for (; aExpE.More(); aExpE.Next()) + { aSplitEdges.Append(aExpE.Current()); + } } else { @@ -984,7 +1008,9 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) } if (isSplittingEdges) + { Spls.Add(aSplitEdges); + } // ici, i vaut newnarg for (; i < narg; i += 2) @@ -1017,10 +1043,14 @@ static int SPLS(Draw_Interpretor&, int narg, const char** a) int thickshell(Draw_Interpretor& theCommands, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } double Of = Draw::Atof(a[3]); @@ -1028,15 +1058,21 @@ int thickshell(Draw_Interpretor& theCommands, int n, const char** a) if (n > 4) { if (!strcmp(a[4], "i")) + { JT = GeomAbs_Intersection; + } if (!strcmp(a[4], "t")) + { JT = GeomAbs_Tangent; + } } bool Inter = false; // true; double Tol = Precision::Confusion(); if (n > 5) + { Tol = Draw::Atof(a[5]); + } occ::handle aProgress = new Draw_ProgressIndicator(theCommands, 1); @@ -1132,10 +1168,14 @@ static int mkoffsetshape(Draw_Interpretor& theDI, int theArgNb, const char** the int offsetshape(Draw_Interpretor& theCommands, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } double Of = Draw::Atof(a[3]); bool Inter = (!strcmp(a[0], "offsetcompshape")); @@ -1176,9 +1216,13 @@ int offsetshape(Draw_Interpretor& theCommands, int n, const char** a) occ::handle aProgress = new Draw_ProgressIndicator(theCommands, 1); if (!YaBouchon) + { B.MakeOffsetShape(aProgress->Start()); + } else + { B.MakeThickSolid(aProgress->Start()); + } const BRepOffset_Error aRetCode = B.Error(); reportOffsetState(theCommands, aRetCode); @@ -1244,17 +1288,25 @@ int offsetparameter(Draw_Interpretor& di, int n, const char** a) } if (n < 4) + { return 1; + } // TheTolerance = Draw::Atof(a[1]); TheInter = strcmp(a[2], "p") != 0; // if (!strcmp(a[3], "a")) + { TheJoin = GeomAbs_Arc; + } else if (!strcmp(a[3], "i")) + { TheJoin = GeomAbs_Intersection; + } else if (!strcmp(a[3], "t")) + { TheJoin = GeomAbs_Tangent; + } // RemoveIntEdges = (n >= 5) ? !strcmp(a[4], "r") : false; // @@ -1266,10 +1318,14 @@ int offsetparameter(Draw_Interpretor& di, int n, const char** a) int offsetload(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 1; + } double Of = Draw::Atof(a[2]); TheRadius = Of; @@ -1305,7 +1361,9 @@ int offsetload(Draw_Interpretor&, int n, const char** a) int offsetonface(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } for (int i = 1; i < n; i += 2) { @@ -1325,13 +1383,19 @@ int offsetonface(Draw_Interpretor&, int n, const char** a) int offsetperform(Draw_Interpretor& theCommands, int theNArg, const char** a) { if (theNArg < 2) + { return 1; + } occ::handle aProgress = new Draw_ProgressIndicator(theCommands, 1); if (theYaBouchon) + { TheOffset.MakeThickSolid(aProgress->Start()); + } else + { TheOffset.MakeOffsetShape(aProgress->Start()); + } if (TheOffset.IsDone()) { @@ -1359,7 +1423,9 @@ int offsetperform(Draw_Interpretor& theCommands, int theNArg, const char** a) static int ROW(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 13) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[3]); BRepFeat_MakeRevol theRFace; gp_Dir D; @@ -1429,7 +1495,9 @@ static int ROW(Draw_Interpretor& theCommands, int narg, const char** a) else { if (a[i][1] == '\0') + { return 1; + } const char* Temp = a[i] + 1; aLocalShape = DBRep::Get(Temp, TopAbs_WIRE); wir = TopoDS::Wire(aLocalShape); @@ -1543,7 +1611,9 @@ static int ROW(Draw_Interpretor& theCommands, int narg, const char** a) static int ROF(Draw_Interpretor& theCommands, int narg, const char** a) { if (narg < 12) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[3]); BRepFeat_MakeRevol theRFace; gp_Dir D; @@ -1716,7 +1786,9 @@ static int ROF(Draw_Interpretor& theCommands, int narg, const char** a) static int GLU(Draw_Interpretor&, int narg, const char** a) { if (narg < 6 || narg % 2 != 0) + { return 1; + } TopoDS_Shape Sne = DBRep::Get(a[2]); TopoDS_Shape Sba = DBRep::Get(a[3]); @@ -2560,7 +2632,9 @@ static int BOSS(Draw_Interpretor& theCommands, int narg, const char** a) DBRep::Set(a[3], theShapeBottom); dout.Flush(); if (Kas == 1) + { return 0; + } } if (Kas == 2 || Kas == 3) @@ -2578,10 +2652,13 @@ static int BOSS(Draw_Interpretor& theCommands, int narg, const char** a) } if (V.IsNull()) + { return 1; + } ChFi3d_FilletShape FSh = ChFi3d_Rational; - if (Rakk) + { delete Rakk; + } Rakk = new BRepFilletAPI_MakeFillet(V, FSh); Rakk->SetParams(ta, tesp, t2d, t3d, t2d, fl); Rakk->SetContinuity(blend_cont, tapp_angle); @@ -2596,7 +2673,9 @@ static int BOSS(Draw_Interpretor& theCommands, int narg, const char** a) { Rad = Draw::Atof(a[2 * ii + 1]); if (Rad == 0.) + { continue; + } S = DBRep::Get(a[(2 * ii + 2)], TopAbs_SHAPE); TopExp_Explorer exp; for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) @@ -2645,10 +2724,14 @@ static int BOSS(Draw_Interpretor& theCommands, int narg, const char** a) } if (!nbedge) + { return 1; + } Rakk->Build(); if (!Rakk->IsDone()) + { return 1; + } TopoDS_Shape res = Rakk->Shape(); if (Kas == 2) @@ -2725,7 +2808,9 @@ void BRepTest::FeatureCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_Fillet2DCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_Fillet2DCommands.cxx index a70301eb31..e40fbd2aa4 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_Fillet2DCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_Fillet2DCommands.cxx @@ -211,7 +211,9 @@ static occ::handle findPlane(const TopoDS_Shape& S) occ::handle plane; BRepBuilderAPI_FindPlane planeFinder(S); if (planeFinder.Found()) + { plane = planeFinder.Plane(); + } return plane; } @@ -247,13 +249,21 @@ static gp_Pnt findCommonPoint(const TopoDS_Shape& E1, const TopoDS_Shape& E2) const double d1221 = p12.SquareDistance(p21); const double d1222 = p12.SquareDistance(p22); if (d1121 < d1122 && d1121 < d1221 && d1121 < d1222) + { common = p11; + } else if (d1122 < d1121 && d1122 < d1221 && d1122 < d1222) + { common = p11; + } else if (d1221 < d1121 && d1221 < d1122 && d1221 < d1222) + { common = p12; + } else if (d1222 < d1121 && d1222 < d1122 && d1222 < d1221) + { common = p12; + } return common; } @@ -366,9 +376,13 @@ static int fillet2d(Draw_Interpretor& di, int n, const char** a) { BRepBuilderAPI_MakeWire mkWire(M1, fillet, M2); if (mkWire.IsDone()) + { DBRep::Set(a[1], mkWire.Wire()); + } else + { DBRep::Set(a[1], fillet); + } } return 0; } @@ -443,9 +457,13 @@ static int chamfer2d(Draw_Interpretor& di, int n, const char** a) { BRepBuilderAPI_MakeWire mkWire(M1, chamfer, M2); if (mkWire.IsDone()) + { DBRep::Set(a[1], mkWire.Wire()); + } else + { DBRep::Set(a[1], chamfer); + } } return 0; @@ -457,7 +475,9 @@ void BRepTest::Fillet2DCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_FilletCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_FilletCommands.cxx index 54881b327c..1668b3a163 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_FilletCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_FilletCommands.cxx @@ -89,7 +89,9 @@ static int contblend(Draw_Interpretor& di, int narg, const char** a) else { if (narg > 3) + { return 1; + } if (narg == 3) { tapp_angle = std::abs(Draw::Atof(a[2])); @@ -151,10 +153,14 @@ static int BLEND(Draw_Interpretor& di, int narg, const char** a) Rakk = nullptr; printtolblend(di); if (narg < 5) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); if (V.IsNull()) + { return 1; + } ChFi3d_FilletShape FSh = ChFi3d_Rational; if (narg % 2 == 0) { @@ -186,10 +192,14 @@ static int BLEND(Draw_Interpretor& di, int narg, const char** a) } } if (!nbedge) + { return 1; + } Rakk->Build(); if (!Rakk->IsDone()) + { return 1; + } // Save history for fillet if (BRepTest_Objects::IsHistoryNeeded()) @@ -277,7 +287,9 @@ static int MKEVOL(Draw_Interpretor& di, int narg, const char** a) Rake = nullptr; printtolblend(di); if (narg < 3) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); Rake = new BRepFilletAPI_MakeFillet(V); Rake->SetParams(ta, tesp, t2d, t3d, t2d, fl); @@ -308,7 +320,9 @@ static int UPDATEVOL(Draw_Interpretor& di, int narg, const char** a) return 1; } if (narg % 2 != 0 || narg < 4) + { return 1; + } NCollection_Array1 uandr(1, (narg / 2) - 1); double Rad, Par; TopoDS_Shape aLocalEdge(DBRep::Get(a[1], TopAbs_EDGE)); @@ -395,9 +409,13 @@ int boptopoblend(Draw_Interpretor& di, int narg, const char** a) BRepAlgoAPI_BooleanOperation* pBuilder = nullptr; if (fuse) + { pBuilder = new BRepAlgoAPI_Fuse(S1, S2, theDSFiller, aPS.Next(2)); + } else + { pBuilder = new BRepAlgoAPI_Cut(S1, S2, theDSFiller, true, aPS.Next(2)); + } bool anIsDone = pBuilder->IsDone(); if (!anIsDone) @@ -453,7 +471,9 @@ int boptopoblend(Draw_Interpretor& di, int narg, const char** a) Blender.Build(); if (Blender.IsDone()) + { BB.Add(result, Blender.Shape()); + } else { di << "Error: Cannot find the result of BLEND-operation." @@ -470,10 +490,14 @@ int boptopoblend(Draw_Interpretor& di, int narg, const char** a) static int blend1(Draw_Interpretor& di, int narg, const char** a) { if (narg < 5) + { return 1; + } TopoDS_Shape V = DBRep::Get(a[2]); if (V.IsNull()) + { return 1; + } int nb, i; double Rad; bool simul = false; @@ -484,16 +508,24 @@ static int blend1(Draw_Interpretor& di, int narg, const char** a) { TopoDS_Shape edge = DBRep::Get(a[i], TopAbs_EDGE); if (edge.IsNull()) + { return 1; + } if (edge.ShapeType() != TopAbs_EDGE) + { return 1; + } E.Append(edge); } FilletSurf_Builder aRakk(V, E, Rad); if (simul) + { aRakk.Simulate(); + } else + { aRakk.Perform(); + } // if (Rakk.IsDone()==FilletSurf_IsNotOk) // { FilletSurf_ErrorTypeStatus err=Rakk.StatusError(); @@ -511,22 +543,36 @@ static int blend1(Draw_Interpretor& di, int narg, const char** a) { FilletSurf_ErrorTypeStatus err = aRakk.StatusError(); if (err == FilletSurf_EmptyList) + { di << "StatusError=EmptyList\n"; + } else if (err == FilletSurf_EdgeNotG1) + { di << "StatusError=NotG1\n"; + } else if (err == FilletSurf_FacesNotG1) + { di << "StatusError=facesNotG1\n"; + } else if (err == FilletSurf_EdgeNotOnShape) + { di << "StatusError=edgenotonshape\n"; + } else if (err == FilletSurf_NotSharpEdge) + { di << "StatusError=notsharpedge\n"; + } else if (err == FilletSurf_PbFilletCompute) + { di << "StatusError=PBFillet\n"; + } } else { if (aRakk.IsDone() == FilletSurf_IsPartial) + { di << "partial result\n"; + } nb = aRakk.NbSurface(); char localname[100]; @@ -659,11 +705,15 @@ static int blend1(Draw_Interpretor& di, int narg, const char** a) int rollingball(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) + { return 1; + } double Rad = Draw::Atof(a[3]); double Tol = t3d; // the same as blend ! 1.e-7; @@ -756,7 +806,9 @@ int rollingball(Draw_Interpretor& di, int n, const char** a) } } else + { DBRep::Set(a[1], Roll.Shape()); + } return 0; } @@ -767,7 +819,9 @@ void BRepTest::FilletCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_FillingCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_FillingCommands.cxx index adb2ec47c2..547243e988 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_FillingCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_FillingCommands.cxx @@ -105,7 +105,9 @@ int MaxSegments = defMaxSegments; static int plate(Draw_Interpretor& di, int n, const char** a) { if (n < 8) + { return 1; + } int NbCurFront = Draw::Atoi(a[3]); occ::handle>> Fronts = new NCollection_HArray1>(1, NbCurFront); @@ -122,12 +124,16 @@ static int plate(Draw_Interpretor& di, int n, const char** a) TopoDS_Edge E = TopoDS::Edge(aLocalEdge); // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[3*i+1],TopAbs_EDGE)); if (E.IsNull()) + { return 1; + } TopoDS_Shape aLocalFace(DBRep::Get(a[3 * i + 2], TopAbs_FACE)); TopoDS_Face F = TopoDS::Face(aLocalFace); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[3*i+2],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } int T = Draw::Atoi(a[3 * i + 3]); Tang->SetValue(i, T); NbPtsCur->SetValue(i, Draw::Atoi(a[2])); @@ -190,7 +196,9 @@ static int plate(Draw_Interpretor& di, int n, const char** a) TopoDS_Wire W; W = MW.Wire(); if (!(W.Closed())) + { throw Standard_Failure("Wire is not closed"); + } BRepBuilderAPI_MakeFace MF(Henri.Surface(), W, true); DBRep::Set(a[1], MF.Face()); return 0; @@ -203,7 +211,9 @@ static int plate(Draw_Interpretor& di, int n, const char** a) static int gplate(Draw_Interpretor& di, int n, const char** a) { if (n < 6) + { return 1; + } int NbCurFront = Draw::Atoi(a[2]), NbPointConstraint = Draw::Atoi(a[3]); GeomPlate_BuildPlateSurface Henri(3, 15, 2); @@ -216,7 +226,9 @@ static int gplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Face SI = TopoDS::Face(aLocalFace); // TopoDS_Face SI = TopoDS::Face(DBRep::Get(a[Indice++],TopAbs_FACE)); if (SI.IsNull()) + { Indice--; + } else { occ::handle HSI = new BRepAdaptor_Surface(); @@ -229,7 +241,9 @@ static int gplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Edge E = TopoDS::Edge(aLocalShape); // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[Indice++],TopAbs_EDGE)); if (E.IsNull()) + { return 1; + } Conti = Draw::Atoi(a[Indice++]); if ((Conti == 0) || (Conti == -1)) { @@ -245,7 +259,9 @@ static int gplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Face F = TopoDS::Face(aLocalFace); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[Indice++],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } occ::handle S = new BRepAdaptor_Surface(); S->Initialize(F); occ::handle C = new BRepAdaptor_Curve2d(); @@ -279,7 +295,9 @@ static int gplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Face F = TopoDS::Face(aLocalFace); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[Indice++],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } occ::handle HF = new BRepAdaptor_Surface(); HF->Initialize(F); occ::handle PCont = @@ -333,7 +351,9 @@ static int gplate(Draw_Interpretor& di, int n, const char** a) static int approxplate(Draw_Interpretor& di, int n, const char** a) { if (n < 9) + { return 1; + } int NbMedium = Draw::Atoi(a[2]); int NbCurFront = Draw::Atoi(a[3]); occ::handle>> Fronts = @@ -350,12 +370,16 @@ static int approxplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Edge E = TopoDS::Edge(aLocalShape); // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[3*i+1],TopAbs_EDGE)); if (E.IsNull()) + { return 1; + } TopoDS_Shape aLocalFace(DBRep::Get(a[3 * i + 2], TopAbs_FACE)); TopoDS_Face F = TopoDS::Face(aLocalFace); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[3*i+2],TopAbs_FACE)); if (F.IsNull()) + { return 1; + } int T = Draw::Atoi(a[3 * i + 3]); Tang->SetValue(i, T); NbPtsCur->SetValue(i, NbMedium); @@ -456,7 +480,9 @@ static int approxplate(Draw_Interpretor& di, int n, const char** a) TopoDS_Wire W; W = MW.Wire(); if (!(W.Closed())) + { throw Standard_Failure("Wire is not closed"); + } BRepBuilderAPI_MakeFace MF(support, W, true); DBRep::Set(a[1], MF.Face()); @@ -494,7 +520,9 @@ static int filling(Draw_Interpretor& di, int n, const char** a) MaxSegments); TopoDS_Face InitFace = TopoDS::Face(DBRep::Get(a[5], TopAbs_FACE)); if (!InitFace.IsNull()) + { MakeFilling.LoadInitSurface(InitFace); + } int i = (InitFace.IsNull()) ? 5 : 6, k; TopoDS_Edge E; @@ -508,15 +536,21 @@ static int filling(Draw_Interpretor& di, int n, const char** a) F.Nullify(); E = TopoDS::Edge(DBRep::Get(a[i], TopAbs_EDGE)); if (!E.IsNull()) + { i++; + } F = TopoDS::Face(DBRep::Get(a[i], TopAbs_FACE)); if (!F.IsNull()) + { i++; + } Order = Draw::Atoi(a[i++]); if (!E.IsNull() && !F.IsNull()) + { MakeFilling.Add(E, F, (GeomAbs_Shape)Order); + } else if (E.IsNull()) { if (F.IsNull()) @@ -525,14 +559,20 @@ static int filling(Draw_Interpretor& di, int n, const char** a) return 1; } else + { MakeFilling.Add(F, (GeomAbs_Shape)Order); + } } else + { MakeFilling.Add(E, (GeomAbs_Shape)Order); + } // History if (!E.IsNull()) + { ListForHistory.Append(E); + } } for (k = 1; k <= NbConstraints; k++) { @@ -546,14 +586,20 @@ static int filling(Draw_Interpretor& di, int n, const char** a) } F = TopoDS::Face(DBRep::Get(a[i], TopAbs_FACE)); if (!F.IsNull()) + { i++; + } Order = Draw::Atoi(a[i++]); if (F.IsNull()) + { MakeFilling.Add(E, (GeomAbs_Shape)Order, false); + } else + { MakeFilling.Add(E, F, (GeomAbs_Shape)Order, false); + } } for (k = 1; k <= NbPoints; k++) { @@ -602,7 +648,9 @@ static int filling(Draw_Interpretor& di, int n, const char** a) // History if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(ListForHistory, MakeFilling); + } return 0; } @@ -707,7 +755,9 @@ void BRepTest::FillingCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_GPropCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_GPropCommands.cxx index 2bd95d2307..42bdf92da2 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_GPropCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_GPropCommands.cxx @@ -76,7 +76,9 @@ int props(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } GProp_GProps G; @@ -84,7 +86,9 @@ int props(Draw_Interpretor& di, int n, const char** a) double eps = 1.0; bool witheps = false; if ((n > 2 && *a[2] == 'c') || (n > 3 && *a[3] == 'c')) + { onlyClosed = true; + } if (n > 2 && *a[2] != 'c' && n != 5) { eps = Draw::Atof(a[2]); @@ -94,22 +98,36 @@ int props(Draw_Interpretor& di, int n, const char** a) if (witheps) { if (std::abs(eps) < Precision::Angular()) + { return 2; + } if (*a[0] == 'l') + { BRepGProp::LinearProperties(S, G, SkipShared); + } else if (*a[0] == 's') + { eps = BRepGProp::SurfaceProperties(S, G, eps, SkipShared); + } else + { eps = BRepGProp::VolumeProperties(S, G, eps, onlyClosed, SkipShared); + } } else { if (*a[0] == 'l') + { BRepGProp::LinearProperties(S, G, SkipShared, UseTriangulation); + } else if (*a[0] == 's') + { BRepGProp::SurfaceProperties(S, G, SkipShared, UseTriangulation); + } else + { BRepGProp::VolumeProperties(S, G, onlyClosed, SkipShared, UseTriangulation); + } } gp_Pnt P = G.CentreOfMass(); @@ -133,7 +151,9 @@ int props(Draw_Interpretor& di, int n, const char** a) aSStream1 << "\n\n"; aSStream1 << "Mass : " << std::setw(15) << G.Mass() << "\n\n"; if (witheps && *a[0] != 'l') + { aSStream1 << "Relative error of mass computation : " << std::setw(15) << eps << "\n\n"; + } aSStream1 << "Center of gravity : \n"; aSStream1 << "X = " << std::setw(15) << P.X() << "\n"; @@ -223,7 +243,9 @@ int vpropsgk(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } GProp_GProps G; bool SkipShared = false; @@ -244,16 +266,24 @@ int vpropsgk(Draw_Interpretor& di, int n, const char** a) eps = Draw::Atof(a[2]); mode = Draw::Atoi(a[3]); if (mode > 0) + { onlyClosed = true; + } mode = Draw::Atoi(a[4]); if (mode > 0) + { isUseSpan = true; + } mode = Draw::Atoi(a[5]); if (mode == 1 || mode == 3) + { CGFlag = true; + } if (mode == 2 || mode == 3) + { IFlag = true; + } // OSD_Chronometer aChrono; @@ -351,7 +381,9 @@ void BRepTest::GPropCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_HelixCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_HelixCommands.cxx index e1d8dd2785..1f1d75a37f 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_HelixCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_HelixCommands.cxx @@ -80,7 +80,9 @@ void BRepTest::HelixCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; // Chapters name const char* g = "Helix commands"; diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_HistoryCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_HistoryCommands.cxx index c765001d4b..3d54c31c14 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_HistoryCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_HistoryCommands.cxx @@ -37,7 +37,9 @@ void BRepTest::HistoryCommands(Draw_Interpretor& theCommands) { static bool isDone = false; if (isDone) + { return; + } isDone = true; // Chapter's name const char* group = "History commands"; @@ -174,13 +176,17 @@ static TopoDS_Shape MakeCompound(const NCollection_List& theLS) { TopoDS_Shape aC; if (theLS.Extent() == 1) + { aC = theLS.First(); + } else { BRep_Builder().MakeCompound(TopoDS::Compound(aC)); NCollection_List::Iterator it(theLS); for (; it.More(); it.Next()) + { BRep_Builder().Add(aC, it.Value()); + } } return aC; } @@ -197,11 +203,15 @@ int Modified(Draw_Interpretor& theDI, int theArgc, const char** theArgv) occ::handle aHistory = GetHistory(theDI, theArgv[2]); if (aHistory.IsNull()) + { return 1; + } TopoDS_Shape aS = GetShape(theDI, theArgv[3]); if (aS.IsNull()) + { return 1; + } const NCollection_List& aModified = aHistory->Modified(aS); @@ -228,11 +238,15 @@ int Generated(Draw_Interpretor& theDI, int theArgc, const char** theArgv) occ::handle aHistory = GetHistory(theDI, theArgv[2]); if (aHistory.IsNull()) + { return 1; + } TopoDS_Shape aS = GetShape(theDI, theArgv[3]); if (aS.IsNull()) + { return 1; + } const NCollection_List& aGenerated = aHistory->Generated(aS); @@ -259,11 +273,15 @@ int IsDeleted(Draw_Interpretor& theDI, int theArgc, const char** theArgv) occ::handle aHistory = GetHistory(theDI, theArgv[1]); if (aHistory.IsNull()) + { return 1; + } TopoDS_Shape aS = GetShape(theDI, theArgv[2]); if (aS.IsNull()) + { return 1; + } theDI << (aHistory->IsRemoved(aS) ? "Deleted." : "Not deleted."); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_MatCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_MatCommands.cxx index 35b83c5668..0c12608586 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_MatCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_MatCommands.cxx @@ -66,12 +66,16 @@ static void DrawCurve(const occ::handle& aCurve, const int Indice) static int topoload(Draw_Interpretor&, int argc, const char** argv) { if (argc < 2) + { return 1; + } TopoDS_Shape C1 = DBRep::Get(argv[1], TopAbs_FACE); if (C1.IsNull()) + { return 1; + } TopoDS_Face aFace = TopoDS::Face(C1); @@ -112,11 +116,15 @@ static int mat(Draw_Interpretor&, int n, const char** a) { GeomAbs_JoinType theJoinType = GeomAbs_Arc; if (n >= 2 && strcmp(a[1], "i") == 0) + { theJoinType = GeomAbs_Intersection; + } bool IsOpenResult = false; if (n == 3 && strcmp(a[2], "o") == 0) + { IsOpenResult = true; + } MapBiLo.Compute(anExplo, 1, SideOfMat, theJoinType, IsOpenResult); LinkComputed = false; @@ -132,7 +140,9 @@ static int mat(Draw_Interpretor&, int n, const char** a) static int zone(Draw_Interpretor&, int argc, const char** argv) { if (argc < 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(argv[1], TopAbs_EDGE); if (S.IsNull()) @@ -170,9 +180,13 @@ static int zone(Draw_Interpretor&, int argc, const char** argv) static int side(Draw_Interpretor&, int, const char** argv) { if (!strcmp(argv[1], "right")) + { SideOfMat = MAT_Right; + } else + { SideOfMat = MAT_Left; + } return 0; } @@ -250,11 +264,15 @@ void DrawCurve(const occ::handle& aCurve, const int Indice) delta = (Val1 <= Val2 ? Val1 : Val2); } if (aCurve->FirstParameter() == -Precision::Infinite()) + { CurveDraw = new Geom2d_TrimmedCurve(aCurve, -delta, delta); + } else + { CurveDraw = new Geom2d_TrimmedCurve(aCurve, aCurve->FirstParameter(), aCurve->FirstParameter() + delta); + } } else { @@ -268,22 +286,36 @@ void DrawCurve(const occ::handle& aCurve, const int Indice) } if (Indice == 1) + { Couleur = Draw_jaune; + } else if (Indice == 2) + { Couleur = Draw_bleu; + } else if (Indice == 3) + { Couleur = Draw_rouge; + } else if (Indice == 4) + { Couleur = Draw_vert; + } int Discret = 50; if (type == STANDARD_TYPE(Geom2d_Circle)) + { dr = new DrawTrSurf_Curve2d(CurveDraw, Couleur, 30, false); + } else if (type == STANDARD_TYPE(Geom2d_Line)) + { dr = new DrawTrSurf_Curve2d(CurveDraw, Couleur, 2, false); + } else + { dr = new DrawTrSurf_Curve2d(CurveDraw, Couleur, Discret, false); + } dout << dr; dout.Flush(); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_Objects.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_Objects.cxx index 1963cddd78..265dfa5b61 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_Objects.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_Objects.cxx @@ -35,7 +35,9 @@ public: void AddHistory(const occ::handle& theHistory) { if (myHistory.IsNull()) + { myHistory = new BRepTools_History; + } myHistory->Merge(theHistory); } diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_OtherCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_OtherCommands.cxx index 17c483c850..cd1748e253 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_OtherCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_OtherCommands.cxx @@ -77,7 +77,9 @@ void BRepTest::OtherCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; const char* g = "TOPOLOGY other commands"; @@ -114,7 +116,9 @@ void BRepTest::OtherCommands(Draw_Interpretor& theCommands) int emptyshape(Draw_Interpretor&, int n, const char** a) { if (n <= 1) + { return 1; + } BRep_Builder B; TopoDS_Shape S; @@ -189,16 +193,22 @@ int emptyshape(Draw_Interpretor&, int n, const char** a) int subshape(Draw_Interpretor& di, int n, const char** a) { if (n <= 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) + { return 0; + } char newname[1024]; strcpy(newname, a[1]); char* p = newname; while (*p != '\0') + { p++; + } *p = '_'; p++; int i = 0; @@ -234,11 +244,17 @@ int subshape(Draw_Interpretor& di, int n, const char** a) case 'S': case 's': if ((a[2][1] == 'O') || (a[2][1] == 'o')) + { typ = TopAbs_SOLID; + } else if ((a[2][1] == 'H') || (a[2][1] == 'h')) + { typ = TopAbs_SHELL; + } else + { return 1; + } break; case 'F': @@ -304,7 +320,9 @@ int brepintcs(Draw_Interpretor& di, int n, const char** a) { S = DBRep::Get(a[indshape]); if (!S.IsNull()) + { break; + } } if (S.IsNull()) { @@ -318,7 +336,9 @@ int brepintcs(Draw_Interpretor& di, int n, const char** a) { double preci = atof(a[n - 1]); if (preci >= Precision::Confusion()) + { tol = preci; + } } int nbpi = 0; gp_Pnt curp; @@ -329,7 +349,9 @@ int brepintcs(Draw_Interpretor& di, int n, const char** a) { occ::handle C = DrawTrSurf::GetCurve(a[1]); if (C.IsNull()) + { return 2; + } GeomAdaptor_Curve acur(C); theAlg.Init(S, acur, tol); @@ -374,9 +396,13 @@ int brepintcs(Draw_Interpretor& di, int n, const char** a) } } if (!nbpi) + { di << "Points of intersections are not found\n"; + } if (indshape < n - 1) + { DBRep::Set(a[n - 1], aComp); + } // POP pour NT return 0; } @@ -406,7 +432,9 @@ int MakeBoss(Draw_Interpretor&, int, const char** a) DPRISM.Build(); if (DPRISM.IsDone()) + { DBRep::Set(a[1], DPRISM.Shape()); + } return 0; } diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_PrimitiveCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_PrimitiveCommands.cxx index ee8600a363..1c2c269107 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_PrimitiveCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_PrimitiveCommands.cxx @@ -237,7 +237,9 @@ static int wedge(Draw_Interpretor&, int n, const char** a) Draw::Atof(a[8])); } else + { return 1; + } DBRep::Set(a[1], S); return 0; @@ -250,7 +252,9 @@ static int wedge(Draw_Interpretor&, int n, const char** a) static int cylinder(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Solid S; occ::handle P = occ::down_cast(DrawTrSurf::Get(a[2])); @@ -261,24 +265,34 @@ static int cylinder(Draw_Interpretor&, int n, const char** a) else if (n == 5) { if (P.IsNull()) + { S = BRepPrimAPI_MakeCylinder(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4])); + } } else if (n == 6) { if (P.IsNull()) + { return 1; + } else + { S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]) * (M_PI / 180.0)); + } } else + { return 1; + } DBRep::Set(a[1], S); return 0; @@ -291,7 +305,9 @@ static int cylinder(Draw_Interpretor&, int n, const char** a) static int cone(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Solid S; occ::handle P = occ::down_cast(DrawTrSurf::Get(a[2])); @@ -303,15 +319,19 @@ static int cone(Draw_Interpretor&, int n, const char** a) else if (n == 6) { if (P.IsNull()) + { S = BRepPrimAPI_MakeCone(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeCone(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); + } } else if (n == 7) { @@ -322,7 +342,9 @@ static int cone(Draw_Interpretor&, int n, const char** a) Draw::Atof(a[6]) * (M_PI / 180.0)); } else + { return 1; + } DBRep::Set(a[1], S); return 0; @@ -335,7 +357,9 @@ static int cone(Draw_Interpretor&, int n, const char** a) static int sphere(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Solid S; occ::handle P = occ::down_cast(DrawTrSurf::Get(a[2])); @@ -347,33 +371,45 @@ static int sphere(Draw_Interpretor&, int n, const char** a) else if (n == 4) { if (P.IsNull()) + { S = BRepPrimAPI_MakeSphere(Draw::Atof(a[2]), Draw::Atof(a[3]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(), Draw::Atof(a[3])); + } } else if (n == 5) { if (P.IsNull()) + { S = BRepPrimAPI_MakeSphere(Draw::Atof(a[2]), Draw::Atof(a[3]) * (M_PI / 180.0), Draw::Atof(a[4]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0)); + } } else if (n == 6) { if (P.IsNull()) + { S = BRepPrimAPI_MakeSphere(Draw::Atof(a[2]), Draw::Atof(a[3]) * (M_PI / 180.0), Draw::Atof(a[4]) * (M_PI / 180.0), Draw::Atof(a[5]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0), Draw::Atof(a[5]) * (M_PI / 180.0)); + } } else if (n == 7) { @@ -384,7 +420,9 @@ static int sphere(Draw_Interpretor&, int n, const char** a) Draw::Atof(a[6]) * (M_PI / 180.0)); } else + { return 1; + } DBRep::Set(a[1], S); return 0; @@ -397,7 +435,9 @@ static int sphere(Draw_Interpretor&, int n, const char** a) static int torus(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Solid S; occ::handle P = occ::down_cast(DrawTrSurf::Get(a[2])); @@ -409,39 +449,51 @@ static int torus(Draw_Interpretor&, int n, const char** a) else if (n == 5) { if (P.IsNull()) + { S = BRepPrimAPI_MakeTorus(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4])); + } } else if (n == 6) { if (P.IsNull()) + { S = BRepPrimAPI_MakeTorus(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0), Draw::Atof(a[5]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]) * (M_PI / 180.0)); + } } else if (n == 7) { if (P.IsNull()) + { S = BRepPrimAPI_MakeTorus(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]) * (M_PI / 180.0), Draw::Atof(a[5]) * (M_PI / 180.0), Draw::Atof(a[6]) * (M_PI / 180.0)); + } else + { S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(), Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]) * (M_PI / 180.0), Draw::Atof(a[6]) * (M_PI / 180.0)); + } } else if (n == 8) { @@ -453,7 +505,9 @@ static int torus(Draw_Interpretor&, int n, const char** a) Draw::Atof(a[7]) * (M_PI / 180.0)); } else + { return 1; + } DBRep::Set(a[1], S); return 0; @@ -465,7 +519,9 @@ void BRepTest::PrimitiveCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_ProjectionCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_ProjectionCommands.cxx index 18037c5a63..5bdd966abe 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_ProjectionCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_ProjectionCommands.cxx @@ -72,7 +72,9 @@ void BRepTest::ProjectionCommands(Draw_Interpretor& theCommands) { static bool loaded = false; if (loaded) + { return; + } loaded = true; const char* g = "Projection of wire commands"; diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_SurfaceCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_SurfaceCommands.cxx index d23e0ac764..c6653ed672 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_SurfaceCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_SurfaceCommands.cxx @@ -63,7 +63,9 @@ static void suppressarg(int& na, const char** a, const int d) static int mkface(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle S = DrawTrSurf::GetSurface(a[2]); if (S.IsNull()) @@ -85,36 +87,48 @@ static int mkface(Draw_Interpretor&, int n, const char** a) if (n == 3) { if (mkface) + { res = BRepBuilderAPI_MakeFace(S, Precision::Confusion()); + } else + { res = BRepBuilderAPI_MakeShell(S, Segment); + } } else if (n <= 5) { if (!mkface) + { return 1; + } bool orient = (n == 4); TopoDS_Shape W = DBRep::Get(a[3], TopAbs_WIRE); if (W.IsNull()) + { return 1; + } res = BRepBuilderAPI_MakeFace(S, TopoDS::Wire(W), orient); } else { if (mkface) + { res = BRepBuilderAPI_MakeFace(S, Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]), Draw::Atof(a[6]), Precision::Confusion()); + } else + { res = BRepBuilderAPI_MakeShell(S, Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]), Draw::Atof(a[6]), Segment); + } } DBRep::Set(a[1], res); @@ -128,7 +142,9 @@ static int mkface(Draw_Interpretor&, int n, const char** a) static int quilt(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } BRepTools_Quilt Q; int i = 2; @@ -186,11 +202,15 @@ static int quilt(Draw_Interpretor&, int n, const char** a) static int mksurface(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2], TopAbs_FACE); if (S.IsNull()) + { return 1; + } TopLoc_Location L; occ::handle C = BRep_Tool::Surface(TopoDS::Face(S), L); @@ -205,11 +225,15 @@ static int mksurface(Draw_Interpretor&, int n, const char** a) static int mkplane(Draw_Interpretor& theDI, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2], TopAbs_WIRE); if (S.IsNull()) + { return 1; + } bool OnlyPlane = false; if (n == 4) @@ -268,10 +292,14 @@ static int pcurve(Draw_Interpretor&, int n, const char** a) // pcurves of a face TopoDS_Shape S = DBRep::Get(a[1], TopAbs_FACE); if (S.IsNull()) + { return 1; + } if (!mute) + { DBRep_WriteColorOrientation(); + } Draw_Color col, savecol = DrawTrSurf_CurveColor(Draw_rouge); char* name = new char[100]; @@ -284,7 +312,7 @@ static int pcurve(Draw_Interpretor&, int n, const char** a) BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()), TopoDS::Face(S), f, l); if (c.IsNull()) { - std::cout << "Error: Edge " << i << " does not have pcurve" << std::endl; + std::cout << "Error: Edge " << i << " does not have pcurve" << '\n'; continue; } col = DBRep_ColorOrientation(ex.Current().Orientation()); @@ -315,10 +343,14 @@ static int pcurve(Draw_Interpretor&, int n, const char** a) { TopoDS_Shape SE = DBRep::Get(a[2], TopAbs_EDGE); if (SE.IsNull()) + { return 1; + } TopoDS_Shape SF = DBRep::Get(a[3], TopAbs_FACE); if (SF.IsNull()) + { return 1; + } Draw_Color col, savecol = DrawTrSurf_CurveColor(Draw_rouge); double f, l; @@ -400,7 +432,9 @@ static int sewing(Draw_Interpretor& theDi, int theArgc, const char** theArgv) if (tolower(theArgv[i][2]) == 'a' && i + 1 < theArgc) { if (Draw::Atof(theArgv[i + 1])) + { aMaxTol = Draw::Atof(theArgv[++i]); + } else { theDi << "Error! max tolerance can't possess the null value\n"; @@ -443,7 +477,9 @@ static int sewing(Draw_Interpretor& theDi, int theArgc, const char** theArgv) else { if (Draw::Atof(theArgv[i])) + { aTol = Draw::Atof(theArgv[i]); + } } } } @@ -472,11 +508,17 @@ static int sewing(Draw_Interpretor& theDi, int theArgc, const char** theArgv) } if (!aSetMinTol) + { aMinTol = aTol * 1e-4; + } if (aTol < Precision::Confusion()) + { aTol = Precision::Confusion(); + } if (aMinTol < Precision::Confusion()) + { aMinTol = Precision::Confusion(); + } if (aMinTol > aTol) { theDi << "Error! min tolerance can't exceed working tolerance\n"; @@ -496,7 +538,9 @@ static int sewing(Draw_Interpretor& theDi, int theArgc, const char** theArgv) aSewing.SetMaxTolerance(aMaxTol); for (int i = 1; i <= aSeq.Length(); i++) + { aSewing.Add(aSeq.Value(i)); + } occ::handle aProgress = new Draw_ProgressIndicator(theDi, 1); aSewing.Perform(aProgress->Start()); @@ -504,7 +548,9 @@ static int sewing(Draw_Interpretor& theDi, int theArgc, const char** theArgv) const TopoDS_Shape& aRes = aSewing.SewedShape(); if (!aRes.IsNull()) + { DBRep::Set(theArgv[1], aRes); + } return 0; } @@ -571,7 +617,9 @@ int fastsewing(Draw_Interpretor& theDI, int theNArg, const char** theArgVal) static int continuity(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return (1); + } BRepOffsetAPI_FindContigousEdges aFind; @@ -580,7 +628,9 @@ static int continuity(Draw_Interpretor&, int n, const char** a) if (sh.IsNull()) { if (n < 3) + { return (1); + } double tol = Draw::Atof(a[1]); aFind.Init(tol, false); i = 2; @@ -606,12 +656,18 @@ static int encoderegularity(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape sh = DBRep::Get(a[1]); if (sh.IsNull()) + { return 1; + } if (n == 2) + { BRepLib::EncodeRegularity(sh); + } else { double Tol = Draw::Atof(a[2]); @@ -789,7 +845,9 @@ void BRepTest::SurfaceCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_SweepCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_SweepCommands.cxx index 9d9700a5c1..04393346c1 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_SweepCommands.cxx @@ -66,11 +66,15 @@ static BRepOffsetAPI_ThruSections* Generator = nullptr; static int prism(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } TopoDS_Shape base = DBRep::Get(a[2]); if (base.IsNull()) + { return 1; + } gp_Vec V(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -117,11 +121,15 @@ static int prism(Draw_Interpretor&, int n, const char** a) static int revol(Draw_Interpretor& di, int n, const char** a) { if (n < 10) + { return 1; + } TopoDS_Shape base = DBRep::Get(a[2]); if (base.IsNull()) + { return 1; + } gp_Pnt P(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); gp_Dir D(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8])); @@ -169,29 +177,41 @@ static int pipe(Draw_Interpretor& di, int n, const char** a) } if (n > 1 && n < 4) + { return 1; + } TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_WIRE); if (Spine.IsNull()) + { return 1; + } TopoDS_Shape Profile = DBRep::Get(a[3]); if (Profile.IsNull()) + { return 1; + } GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; if (n >= 5) { int iMode = atoi(a[4]); if (iMode == 1) + { Mode = GeomFill_IsFrenet; + } else if (iMode == 2) + { Mode = GeomFill_IsDiscreteTrihedron; + } } bool ForceApproxC1 = false; if (n >= 6) + { ForceApproxC1 = true; + } BRepOffsetAPI_MakePipe PipeBuilder(TopoDS::Wire(Spine), Profile, Mode, ForceApproxC1); TopoDS_Shape S = PipeBuilder.Shape(); @@ -216,12 +236,18 @@ static int geompipe(Draw_Interpretor&, int n, const char** a) { TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_EDGE); if (Spine.IsNull()) + { return 1; + } if (n < 5) + { return 1; + } TopoDS_Shape Profile = DBRep::Get(a[3], TopAbs_EDGE); if (Profile.IsNull()) + { return 1; + } double aSpFirst, aSpLast, aPrFirst, aPrLast; occ::handle SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine), aSpFirst, aSpLast); occ::handle ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile), aPrFirst, aPrLast); @@ -237,9 +263,13 @@ static int geompipe(Draw_Interpretor&, int n, const char** a) occ::handle cStart = new Geom_Circle(aAx2Start, Radius); int k = 5; if (n > k) + { ByACR = (Draw::Atoi(a[k++]) == 1); + } if (n > k) + { rotate = (Draw::Atoi(a[k++]) == 1); + } GeomFill_Pipe aPipe(ProfileCurve, aAdaptCurve, cStart, ByACR, rotate); aPipe.Perform(true); if (!aPipe.IsDone()) @@ -249,12 +279,14 @@ static int geompipe(Draw_Interpretor&, int n, const char** a) } double Accuracy = aPipe.ErrorOnSurf(); - std::cout << "Accuracy of approximation = " << Accuracy << std::endl; + std::cout << "Accuracy of approximation = " << Accuracy << '\n'; occ::handle Sur = aPipe.Surface(); TopoDS_Face F; if (!Sur.IsNull()) + { F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion()); + } DBRep::Set(a[1], F); return 0; } @@ -276,7 +308,9 @@ int evolved(Draw_Interpretor& di, int n, const char** a) } if (n < 4) + { return 1; + } bool Solid = false; bool isVolume = false; bool hasToComputeAxes = false; @@ -368,7 +402,9 @@ int evolved(Draw_Interpretor& di, int n, const char** a) static int pruled(Draw_Interpretor&, int n, const char** a) { if (n != 4) + { return 1; + } bool YaWIRE = false; TopoDS_Shape S1 = DBRep::Get(a[2], TopAbs_EDGE); @@ -376,7 +412,9 @@ static int pruled(Draw_Interpretor&, int n, const char** a) { S1 = DBRep::Get(a[2], TopAbs_WIRE); if (S1.IsNull()) + { return 1; + } YaWIRE = true; } @@ -385,7 +423,9 @@ static int pruled(Draw_Interpretor&, int n, const char** a) { S2 = DBRep::Get(a[3], TopAbs_WIRE); if (S2.IsNull()) + { return 1; + } if (!YaWIRE) { S1 = BRepLib_MakeWire(TopoDS::Edge(S1)); @@ -419,7 +459,9 @@ static int pruled(Draw_Interpretor&, int n, const char** a) int gener(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } TopoDS_Shape Shape; @@ -429,7 +471,9 @@ int gener(Draw_Interpretor&, int n, const char** a) { Shape = DBRep::Get(a[i], TopAbs_WIRE); if (Shape.IsNull()) + { return 1; + } aGenerator.AddWire(TopoDS::Wire(Shape)); } @@ -448,7 +492,9 @@ int gener(Draw_Interpretor&, int n, const char** a) int thrusections(Draw_Interpretor& di, int n, const char** a) { if (n < 6) + { return 1; + } bool check = true; bool samenumber = true; @@ -457,7 +503,9 @@ int thrusections(Draw_Interpretor& di, int n, const char** a) if (!strcmp(a[1], "-N")) { if (n < 7) + { return 1; + } check = false; index++; } @@ -491,9 +539,13 @@ int thrusections(Draw_Interpretor& di, int n, const char** a) Shape = DBRep::Get(a[i], TopAbs_VERTEX); IsWire = false; if (!Shape.IsNull()) + { Generator->AddVertex(TopoDS::Vertex(Shape)); + } else + { return 1; + } } int cpt = 0; @@ -503,9 +555,13 @@ int thrusections(Draw_Interpretor& di, int n, const char** a) cpt++; } if (IsFirstWire) + { NbEdges = cpt; + } else if (IsWire && cpt != NbEdges) + { samenumber = false; + } } Generator->SetMutableInput(IsMutableInput); @@ -521,7 +577,9 @@ int thrusections(Draw_Interpretor& di, int n, const char** a) DBRep::Set(a[index - 1], Shell); // Save history of the lofting if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(Generator->Wires(), *Generator); + } } else { @@ -560,10 +618,14 @@ int thrusections(Draw_Interpretor& di, int n, const char** a) static int mksweep(Draw_Interpretor& di, int n, const char** a) { if (n != 2 && n != 5) + { return 1; + } TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE); if (Spine.IsNull()) + { return 1; + } delete Sweep; Sweep = nullptr; @@ -841,16 +903,24 @@ static int addsweep(Draw_Interpretor& di, int n, const char** a) if (thelaw.IsNull()) { if (HasVertex) + { Sweep->Add(Section, Vertex, isT, isR); + } else + { Sweep->Add(Section, isT, isR); + } } else { if (HasVertex) + { Sweep->SetLaw(Section, thelaw, Vertex, isT, isR); + } else + { Sweep->SetLaw(Section, thelaw, isT, isR); + } } return 0; @@ -930,7 +1000,9 @@ static int buildsweep(Draw_Interpretor& di, int n, const char** a) } // Reading solid ? if ((n > cur) && (!strcmp(a[cur], "-S"))) + { mksolid = true; + } // Calcul le resultat Sweep->Build(); @@ -954,7 +1026,9 @@ static int buildsweep(Draw_Interpretor& di, int n, const char** a) bool B; B = Sweep->MakeSolid(); if (!B) + { di << " BuildSweep : It is impossible to make a solid !\n"; + } } result = Sweep->Shape(); DBRep::Set(a[1], result); @@ -995,7 +1069,9 @@ static int errorsweep(Draw_Interpretor& di, int, const char**) static int simulsweep(Draw_Interpretor& di, int n, const char** a) { if ((n != 3) && (n != 4)) + { return 1; + } if (Sweep == nullptr) { @@ -1047,19 +1123,27 @@ static int simulsweep(Draw_Interpretor& di, int n, const char** a) static int middlepath(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 5) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } TopoDS_Shape StartShape = DBRep::Get(a[3]); if (StartShape.IsNull()) + { return 1; + } TopoDS_Shape EndShape = DBRep::Get(a[4]); if (EndShape.IsNull()) + { return 1; + } BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape); Builder.Build(); @@ -1076,7 +1160,9 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/BRepTest/BRepTest_TopologyCommands.cxx b/src/Draw/TKTopTest/BRepTest/BRepTest_TopologyCommands.cxx index a412e75e28..e25fa602a0 100644 --- a/src/Draw/TKTopTest/BRepTest/BRepTest_TopologyCommands.cxx +++ b/src/Draw/TKTopTest/BRepTest/BRepTest_TopologyCommands.cxx @@ -28,7 +28,9 @@ static int halfspace(Draw_Interpretor& di, int n, const char** a) { if (n < 6) + { return 1; + } // Le point indiquant le cote "matiere". gp_Pnt RefPnt = gp_Pnt(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); @@ -77,7 +79,9 @@ static int halfspace(Draw_Interpretor& di, int n, const char** a) static int buildfaces(Draw_Interpretor&, int narg, const char** a) { if (narg < 4) + { return 1; + } TopoDS_Shape InputShape(DBRep::Get(a[2], TopAbs_FACE)); TopoDS_Face F = TopoDS::Face(InputShape); @@ -92,7 +96,9 @@ static int buildfaces(Draw_Interpretor&, int narg, const char** a) } FR.Perform(); if (!FR.IsDone()) + { return 1; + } TopoDS_Compound Res; BRep_Builder BB; @@ -113,7 +119,9 @@ void BRepTest::TopologyCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; DBRep::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/DrawFairCurve/DrawFairCurve_Batten.cxx b/src/Draw/TKTopTest/DrawFairCurve/DrawFairCurve_Batten.cxx index b38b7152f2..5e5f23590a 100644 --- a/src/Draw/TKTopTest/DrawFairCurve/DrawFairCurve_Batten.cxx +++ b/src/Draw/TKTopTest/DrawFairCurve/DrawFairCurve_Batten.cxx @@ -95,9 +95,13 @@ void DrawFairCurve_Batten::SetSlope(const double Slope) double DrawFairCurve_Batten::GetAngle(const int Side) const { if (Side == 1) + { return ((FairCurve_Batten*)MyBatten)->GetAngle1(); + } else + { return ((FairCurve_Batten*)MyBatten)->GetAngle2(); + } } double DrawFairCurve_Batten::GetSliding() const @@ -114,9 +118,13 @@ void DrawFairCurve_Batten::FreeSliding() void DrawFairCurve_Batten::FreeAngle(const int Side) { if (Side == 1) + { ((FairCurve_Batten*)MyBatten)->SetConstraintOrder1(0); + } else + { ((FairCurve_Batten*)MyBatten)->SetConstraintOrder2(0); + } Compute(); } diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest.cxx index a1d49c3966..5b5c281e8a 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest.cxx @@ -23,7 +23,9 @@ void GeometryTest::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; GeomliteTest::AllCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_APICommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_APICommands.cxx index aa9af47642..b74d225e3e 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_APICommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_APICommands.cxx @@ -67,14 +67,22 @@ static void showProjSolution(Draw_Interpretor& di, { DrawTrSurf::Set(temp, P1); if (isSurface) + { di << " Point on surface "; + } else + { di << " Point on curve "; + } } if (isSurface) + { di << " Parameters: " << U << " " << V << "\n"; + } else + { di << " parameter " << i << " = " << U << "\n"; + } } //================================================================================================= @@ -94,14 +102,18 @@ static int proj(Draw_Interpretor& di, int n, const char** a) Extrema_ExtAlgo aProjAlgo = Extrema_ExtAlgo_Grad; if (n == 6 && a[5][0] == 't') + { aProjAlgo = Extrema_ExtAlgo_Tree; + } if (GC.IsNull()) { GS = DrawTrSurf::GetSurface(a[1]); if (GS.IsNull()) + { return 1; + } if (n <= 6) { @@ -147,7 +159,7 @@ static int proj(Draw_Interpretor& di, int n, const char** a) if (proj.NbPoints() == 0) { - std::cout << "No project point was found." << std::endl; + std::cout << "No project point was found." << '\n'; return 0; } @@ -167,7 +179,9 @@ static int proj(Draw_Interpretor& di, int n, const char** a) static int appro(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GC; int Nb = Draw::Atoi(a[2]); @@ -180,7 +194,9 @@ static int appro(Draw_Interpretor& di, int n, const char** a) { GC = DrawTrSurf::GetCurve(a[3]); if (GC.IsNull()) + { return 1; + } double U, U1, U2; U1 = GC->FirstParameter(); @@ -234,7 +250,9 @@ static int appro(Draw_Interpretor& di, int n, const char** a) static int grilapp(Draw_Interpretor& di, int n, const char** a) { if (n < 12) + { return 1; + } int i, j; int Nu = Draw::Atoi(a[2]); @@ -252,7 +270,9 @@ static int grilapp(Draw_Interpretor& di, int n, const char** a) for (i = 1; i <= Nu; i++) { if (Count > n) + { return 1; + } ZPoints(i, j) = Draw::Atof(a[Count]); Count++; } @@ -271,7 +291,9 @@ static int grilapp(Draw_Interpretor& di, int n, const char** a) static int surfapp(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } int i, j; int Nu = Draw::Atoi(a[2]); @@ -284,7 +306,9 @@ static int surfapp(Draw_Interpretor& di, int n, const char** a) { occ::handle Surf = DrawTrSurf::GetSurface(a[4]); if (Surf.IsNull()) + { return 1; + } double U, V, U1, V1, U2, V2; Surf->Bounds(U1, U2, V1, V2); @@ -301,7 +325,9 @@ static int surfapp(Draw_Interpretor& di, int n, const char** a) { int ip = Draw::Atoi(a[5]); if (ip > 0) + { IsPeriodic = true; + } } if (IsPeriodic) { @@ -324,7 +350,9 @@ static int surfapp(Draw_Interpretor& di, int n, const char** a) for (i = 1; i <= Nu; i++) { if (Count > n) + { return 1; + } Points(i, j) = gp_Pnt(Draw::Atof(a[Count]), Draw::Atof(a[Count + 1]), Draw::Atof(a[Count + 2])); Count += 3; @@ -376,11 +404,15 @@ static int surfapp(Draw_Interpretor& di, int n, const char** a) static int surfint(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle Surf = DrawTrSurf::GetSurface(a[2]); if (Surf.IsNull()) + { return 1; + } int i, j; int Nu = Draw::Atoi(a[3]); int Nv = Draw::Atoi(a[4]); @@ -415,7 +447,9 @@ static int surfint(Draw_Interpretor& di, int n, const char** a) { int ip = Draw::Atoi(a[5]); if (ip > 0) + { IsPeriodic = true; + } } bool RemoveLast = false; if (IsPeriodic) @@ -484,7 +518,9 @@ static int extrema(Draw_Interpretor& di, int n, const char** a) { GS1 = DrawTrSurf::GetSurface(a[1]); if (GS1.IsNull()) + { return 1; + } GS1->Bounds(U1f, U1l, V1f, V1l); } @@ -499,7 +535,9 @@ static int extrema(Draw_Interpretor& di, int n, const char** a) { GS2 = DrawTrSurf::GetSurface(a[2]); if (GS2.IsNull()) + { return 1; + } GS2->Bounds(U2f, U2l, V2f, V2l); } else @@ -626,9 +664,13 @@ static int extrema(Draw_Interpretor& di, int n, const char** a) // Infinity solutions flag may be set with 0 number of // solutions in analytic extrema Curve/Curve. if (isInfinitySolutions) + { di << "Infinite number of extremas, distance = " << aMinDist << "\n"; + } else + { di << "No solutions!\n"; + } } for (int aJ = 1; aJ <= aPntCount; aJ++) { @@ -683,7 +725,9 @@ static int extrema(Draw_Interpretor& di, int n, const char** a) static int totalextcc(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GC1, GC2; @@ -750,7 +794,9 @@ void GeometryTest::APICommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_ConstraintCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_ConstraintCommands.cxx index 0c3fa670b9..9d575ce865 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_ConstraintCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_ConstraintCommands.cxx @@ -329,7 +329,9 @@ static int Cirtang(Draw_Interpretor& theDI, int theNArgs, const char** theArgVal static int lintang(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle C1 = DrawTrSurf::GetCurve2d(a[2]); occ::handle C2 = DrawTrSurf::GetCurve2d(a[3]); @@ -337,7 +339,9 @@ static int lintang(Draw_Interpretor& di, int n, const char** a) char solname[200]; if (C1.IsNull() || C2.IsNull()) + { return 1; + } Draw_Color col = DrawTrSurf_CurveColor(Draw_Color(Draw_vert)); @@ -367,7 +371,9 @@ static int lintang(Draw_Interpretor& di, int n, const char** a) } } else + { di << "Lin2dTanObl Not done\n"; + } } else { @@ -388,7 +394,9 @@ static int lintang(Draw_Interpretor& di, int n, const char** a) } } else + { di << "Lin2d2Tan Not done\n"; + } } DrawTrSurf_CurveColor(col); @@ -412,9 +420,13 @@ static int interpol(Draw_Interpretor& di, int n, const char** a) dout.Select(id, XX, YY, b); double zoom = dout.Zoom(id); if (b != 1) + { return 0; + } if (id < 0) + { return 0; + } gp_Pnt P; gp_Pnt2d P2d; bool newcurve; @@ -466,7 +478,9 @@ static int interpol(Draw_Interpretor& di, int n, const char** a) { ThePoints = new NCollection_HArray1(1, i + 1); for (j = 1; j <= i; j++) + { ThePoints->SetValue(j, Points->Value(j)); + } } } } @@ -529,7 +543,9 @@ static int interpol(Draw_Interpretor& di, int n, const char** a) { ThePoints = new NCollection_HArray1(1, i + 1); for (j = 1; j <= i; j++) + { ThePoints->SetValue(j, Points->Value(j)); + } } } } @@ -551,7 +567,9 @@ static int interpol(Draw_Interpretor& di, int n, const char** a) const char* nomfic = a[2]; std::ifstream iFile(nomfic, std::ios::in); if (!iFile) + { return 1; + } int nbp, i; double x, y, z; iFile >> nbp; @@ -600,7 +618,9 @@ static int tanginterpol(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } int ii, jj, // num_knots, @@ -755,7 +775,9 @@ void GeometryTest::ConstraintCommands(Draw_Interpretor& theCommands) static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_ContinuityCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_ContinuityCommands.cxx index a2bed0bf94..b2309aa7cc 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_ContinuityCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_ContinuityCommands.cxx @@ -74,17 +74,23 @@ static int surfaceCcontinuity(Draw_Interpretor& di, int n, const char** a) bool b1, b2, b3, b4; double epsnl, epsC0, epsC1, epsC2, epsG1, maxlen, perce; if (n < 8) + { return 1; + } InitEpsSurf(epsnl, epsC0, epsC1, epsC2, epsG1, perce, maxlen); occ::handle surf1 = DrawTrSurf::GetSurface(a[2]); if (surf1.IsNull()) + { return 1; + } occ::handle surf2 = DrawTrSurf::GetSurface(a[5]); if (surf2.IsNull()) + { return 1; + } U1 = Draw::Atof(a[3]); U2 = Draw::Atof(a[6]); @@ -102,7 +108,9 @@ static int surfaceCcontinuity(Draw_Interpretor& di, int n, const char** a) b4 = ((((V2 >= v1) && (V2 <= v2)) || ((V2 <= v1) && (V2 >= v2)))); if (!((b1 && b2) && (b3 && b4))) + { return 1; + } switch (ord) { @@ -200,16 +208,22 @@ static int surfaceGcontinuity(Draw_Interpretor& di, int n, const char** a) double epsnl, epsC0, epsC1, epsC2, epsG1, maxlen, perce; if (n < 8) + { return 1; + } InitEpsSurf(epsnl, epsC0, epsC1, epsC2, epsG1, perce, maxlen); occ::handle surf1 = DrawTrSurf::GetSurface(a[2]); if (surf1.IsNull()) + { return 1; + } occ::handle surf2 = DrawTrSurf::GetSurface(a[5]); if (surf2.IsNull()) + { return 1; + } U1 = Draw::Atof(a[3]); U2 = Draw::Atof(a[6]); @@ -227,7 +241,9 @@ static int surfaceGcontinuity(Draw_Interpretor& di, int n, const char** a) b4 = ((((V2 >= v1) && (V2 <= v2)) || ((V2 <= v1) && (V2 >= v2)))); if (!((b1 && b2) && (b3 && b4))) + { return 1; + } switch (ord) { @@ -307,14 +323,20 @@ static int curveGcontinuity(Draw_Interpretor& di, int n, const char** a) bool b1, b2; double epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, maxlen, percent; if (n < 6) + { return 1; + } occ::handle curv1 = DrawTrSurf::GetCurve(a[2]); if (curv1.IsNull()) + { return 1; + } occ::handle curv2 = DrawTrSurf::GetCurve(a[4]); if (curv2.IsNull()) + { return 1; + } U1 = Draw::Atof(a[3]); U2 = Draw::Atof(a[5]); @@ -330,7 +352,9 @@ static int curveGcontinuity(Draw_Interpretor& di, int n, const char** a) b2 = ((((U2 >= u1) && (U2 <= u2)) || ((U2 <= u1) && (U2 >= u2)))); if (!(b1 && b2)) + { return 1; + } InitEpsCurv(epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, percent, maxlen); switch (ord) @@ -414,14 +438,20 @@ static int curveCcontinuity(Draw_Interpretor& di, int n, const char** a) bool b1, b2; double epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, maxlen, percent; if (n < 6) + { return 1; + } occ::handle curv1 = DrawTrSurf::GetCurve(a[2]); if (curv1.IsNull()) + { return 1; + } occ::handle curv2 = DrawTrSurf::GetCurve(a[4]); if (curv2.IsNull()) + { return 1; + } U1 = Draw::Atof(a[3]); U2 = Draw::Atof(a[5]); @@ -437,7 +467,9 @@ static int curveCcontinuity(Draw_Interpretor& di, int n, const char** a) b2 = ((((U2 >= u1) && (U2 <= u2)) || ((U2 <= u1) && (U2 >= u2)))); if (!(b1 && b2)) + { return 1; + } InitEpsCurv(epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, percent, maxlen); switch (ord) @@ -530,7 +562,9 @@ void GeometryTest::ContinuityCommands(Draw_Interpretor& theCommands) { static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveCommands.cxx index 13ba21204c..755018cbc4 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveCommands.cxx @@ -108,7 +108,9 @@ static int polelaw(Draw_Interpretor&, int n, const char** a) int k, jj, qq, i; if (n < 3) + { return 1; + } bool periodic = false; int deg = Draw::Atoi(a[2]); int nbk = Draw::Atoi(a[3]); @@ -160,26 +162,36 @@ static int polelaw(Draw_Interpretor&, int n, const char** a) static int to2d(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } // get the curve occ::handle C = DrawTrSurf::GetCurve(a[2]); if (C.IsNull()) + { return 1; + } occ::handle S; if (n >= 4) { S = DrawTrSurf::GetSurface(a[3]); if (S.IsNull()) + { return 1; + } } else + { S = new Geom_Plane(gp::XOY()); + } occ::handle P = occ::down_cast(S); if (P.IsNull()) + { return 1; + } occ::handle r = GeomAPI::To2d(C, P->Pln()); DrawTrSurf::Set(a[1], r); return 0; @@ -190,25 +202,35 @@ static int to2d(Draw_Interpretor&, int n, const char** a) static int to3d(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle C = DrawTrSurf::GetCurve2d(a[2]); if (C.IsNull()) + { return 1; + } occ::handle S; if (n >= 4) { S = DrawTrSurf::GetSurface(a[3]); if (S.IsNull()) + { return 1; + } } else + { S = new Geom_Plane(gp::XOY()); + } occ::handle P = occ::down_cast(S); if (P.IsNull()) + { return 1; + } occ::handle r = GeomAPI::To3d(C, P->Pln()); DrawTrSurf::Set(a[1], r); @@ -233,7 +255,9 @@ static int gproject(Draw_Interpretor& di, int n, const char** a) occ::handle Cur = DrawTrSurf::GetCurve(a[2]); occ::handle Sur = DrawTrSurf::GetSurface(a[3]); if (Cur.IsNull() || Sur.IsNull()) + { return 1; + } occ::handle hcur = new GeomAdaptor_Curve(Cur); occ::handle hsur = new GeomAdaptor_Surface(Sur); @@ -266,7 +290,9 @@ static int gproject(Draw_Interpretor& di, int n, const char** a) while (index + 1 < n) { if (a[index][0] != '-') + { return 1; + } if (a[index][1] == 'c') { @@ -368,14 +394,20 @@ static int project(Draw_Interpretor& di, int n, const char** a) } if (n < 4) + { return 1; + } occ::handle GS = DrawTrSurf::GetSurface(a[3]); if (GS.IsNull()) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve(a[2]); if (GC.IsNull()) + { return 1; + } double tolerance = Precision::Confusion(); @@ -389,7 +421,9 @@ static int project(Draw_Interpretor& di, int n, const char** a) while (index + 1 < n) { if (a[index][0] != '-') + { return 1; + } if (a[index][1] == 'e') { @@ -448,7 +482,9 @@ static int project(Draw_Interpretor& di, int n, const char** a) Dist = P1.Distance(P2); di << " Parameter = " << U << "\tDistance = " << Dist << "\n"; if (Dist > DistMax) + { DistMax = Dist; + } } di << " **** Distance Maximale : " << DistMax << "\n"; } @@ -461,11 +497,15 @@ static int project(Draw_Interpretor& di, int n, const char** a) int projonplane(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle S = DrawTrSurf::GetSurface(a[3]); if (S.IsNull()) + { return 1; + } occ::handle Pl = occ::down_cast(S); if (Pl.IsNull()) @@ -476,11 +516,15 @@ int projonplane(Draw_Interpretor& di, int n, const char** a) occ::handle C = DrawTrSurf::GetCurve(a[2]); if (C.IsNull()) + { return 1; + } bool Param = true; if ((n == 5 && Draw::Atoi(a[4]) == 0) || (n == 8 && Draw::Atoi(a[7]) == 0)) + { Param = false; + } gp_Dir D; @@ -505,9 +549,13 @@ static void solution(const occ::handle& Bis, const char* name, con { char solname[200]; if (i == 0) + { Sprintf(solname, "%s", name); + } else + { Sprintf(solname, "%s_%d", name, i); + } const char* temp = solname; // pour portage WNT switch (Bis->ArcType()) @@ -536,7 +584,9 @@ static void solution(const occ::handle& Bis, const char* name, con static int bisec(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle C1 = DrawTrSurf::GetCurve2d(a[2]); occ::handle C2 = DrawTrSurf::GetCurve2d(a[3]); @@ -581,7 +631,9 @@ static int bisec(Draw_Interpretor& di, int n, const char** a) { NbSol = Bis.NbSolutions(); if (NbSol >= 2) + { Compt = 1; + } for (i = 1; i <= NbSol; i++) { solution(Bis.ThisSolution(i), a[1], Compt); @@ -603,7 +655,9 @@ static int bisec(Draw_Interpretor& di, int n, const char** a) // char solname[200]; NbSol = Bis.NbSolutions(); if (NbSol >= 2) + { Compt = 1; + } for (i = 1; i <= NbSol; i++) { solution(Bis.ThisSolution(i), a[1], Compt); @@ -625,7 +679,9 @@ static int bisec(Draw_Interpretor& di, int n, const char** a) // char solname[200]; NbSol = Bis.NbSolutions(); if (NbSol >= 2) + { Compt = 1; + } for (i = 1; i <= NbSol; i++) { solution(Bis.ThisSolution(i), a[1], Compt); @@ -653,7 +709,9 @@ static int bisec(Draw_Interpretor& di, int n, const char** a) { NbSol = Bis.NbSolutions(); if (NbSol >= 2) + { Compt = 1; + } for (i = 1; i <= NbSol; i++) { solution(Bis.ThisSolution(i), a[1], Compt); @@ -698,7 +756,9 @@ static int bisec(Draw_Interpretor& di, int n, const char** a) { NbSol = Bis.NbSolutions(); if (NbSol >= 2) + { Compt = 1; + } for (i = 1; i <= Bis.NbSolutions(); i++) { solution(Bis.ThisSolution(i), a[1], Compt); @@ -1013,10 +1073,14 @@ static int crvtpoints(Draw_Interpretor& di, int n, const char** a) defl = Draw::Atof(a[3]); if (n > 4) + { angle = Draw::Atof(a[4]); + } if (n > 5) + { aMinPntsNb = Draw::Atoi(a[5]); + } GCPnts_TangentialDeflection PntGen(*aHCurve, angle, defl, aMinPntsNb); @@ -1065,7 +1129,9 @@ static int crvtpoints(Draw_Interpretor& di, int n, const char** a) static int uniformAbscissa(Draw_Interpretor& di, int n, const char** a) { if (n != 3) + { return 1; + } /*occ::handle ellip; ellip = DrawTrSurf::GetBSplineCurve(a[1]); @@ -1086,7 +1152,9 @@ static int uniformAbscissa(Draw_Interpretor& di, int n, const char** a) int nocp; nocp = Draw::Atoi(a[2]); if (nocp < 2) + { return 1; + } // test nbPoints for Geom_Ellipse @@ -1110,7 +1178,9 @@ static int uniformAbscissa(Draw_Interpretor& di, int n, const char** a) { di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n"; for (int i = 1; i <= myAlgo.NbPoints(); i++) + { di << i << " points = " << myAlgo.Parameter(i) << "\n"; + } } } @@ -1128,7 +1198,9 @@ static int uniformAbscissa(Draw_Interpretor& di, int n, const char** a) static int EllipsUniformAbscissa(Draw_Interpretor& di, int n, const char** a) { if (n != 4) + { return 1; + } double R1; R1 = Draw::Atof(a[1]); @@ -1138,7 +1210,9 @@ static int EllipsUniformAbscissa(Draw_Interpretor& di, int n, const char** a) int nocp; nocp = Draw::Atoi(a[3]); if (nocp < 2) + { return 1; + } // test nbPoints for Geom_Ellipse occ::handle ellip; @@ -1186,7 +1260,9 @@ static int EllipsUniformAbscissa(Draw_Interpretor& di, int n, const char** a) { di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n"; for (int i = 1; i <= myAlgo.NbPoints(); i++) + { di << i << " points = " << myAlgo.Parameter(i) << "\n"; + } } } @@ -1308,7 +1384,9 @@ static int mypoints(Draw_Interpretor& di, int /*n*/, const char** a) occ::handle aBS(occ::down_cast(C)); if (aBS.IsNull()) + { return 1; + } int ui1 = aBS->FirstUKnotIndex(); int ui2 = aBS->LastUKnotIndex(); @@ -1364,12 +1442,16 @@ static int mypoints(Draw_Interpretor& di, int /*n*/, const char** a) for (l = j + 1; l < k; ++l) { if (anUFlg(l)) + { continue; + } gp_Pnt pp = aBS->Value(anUPars(l)); double d = lin.SquareDistance(pp); if (d <= defl) + { continue; + } ok = false; break; @@ -1384,14 +1466,18 @@ static int mypoints(Draw_Interpretor& di, int /*n*/, const char** a) } if (k >= nbsu) + { bCont = false; + } } nbp = 0; for (i = 1; i <= nbsu; ++i) { if (anUFlg(i)) + { nbp++; + } } NCollection_Array1 aPoles(1, nbp); @@ -1496,7 +1582,9 @@ static int surfpoints(Draw_Interpretor& /*di*/, int /*n*/, const char** a) static int intersection(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } // occ::handle GC1; @@ -1505,18 +1593,24 @@ static int intersection(Draw_Interpretor& di, int n, const char** a) { GC1 = DrawTrSurf::GetCurve(a[2]); if (GC1.IsNull()) + { return 1; + } } // occ::handle GS2 = DrawTrSurf::GetSurface(a[3]); if (GS2.IsNull()) + { return 1; + } // double tol = Precision::Confusion(); if (n == 5 || n == 9 || n == 13 || n == 17) + { tol = Draw::Atof(a[n - 1]); + } // occ::handle Result; @@ -1573,7 +1667,9 @@ static int intersection(Draw_Interpretor& di, int n, const char** a) { double UVbnd[8]; for (int i = ibnd1; i <= ibnd2; i++) + { UVbnd[i - ibnd1] = Draw::Atof(a[i]); + } AS1 = new GeomAdaptor_Surface(GS1, UVbnd[0], UVbnd[1], UVbnd[2], UVbnd[3]); AS2 = new GeomAdaptor_Surface(GS2, UVbnd[4], UVbnd[5], UVbnd[6], UVbnd[7]); @@ -1666,7 +1762,9 @@ static int intersection(Draw_Interpretor& di, int n, const char** a) int Compt = 1; if (nblines >= 1) - std::cout << " Lines: " << std::endl; + { + std::cout << " Lines: " << '\n'; + } for (i = 1; i <= nblines; i++, Compt++) { @@ -1678,7 +1776,9 @@ static int intersection(Draw_Interpretor& di, int n, const char** a) } if (nbpoints >= 1) - std::cout << " Points: " << std::endl; + { + std::cout << " Points: " << '\n'; + } const int imax = nblines + nbpoints; @@ -1761,7 +1861,9 @@ void GeometryTest::CurveCommands(Draw_Interpretor& theCommands) static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveTanCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveTanCommands.cxx index 75deeb85ef..8fa89b0c3b 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveTanCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_CurveTanCommands.cxx @@ -48,20 +48,28 @@ static int qcurve(Draw_Interpretor&, int theArgsNb, const char** theArgVec) if (!strcmp(theArgVec[0], "qcircle")) { if (theArgsNb == 5 || theArgsNb == 6) + { aResult2d = new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(Draw::Atof(theArgVec[2]), Draw::Atof(theArgVec[3])), gp_Dir2d(gp_Dir2d::D::X)), Draw::Atof(theArgVec[4])); + } else if (theArgsNb == 7 || theArgsNb == 8) + { aResult2d = new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(Draw::Atof(theArgVec[2]), Draw::Atof(theArgVec[3])), gp_Dir2d(Draw::Atof(theArgVec[4]), Draw::Atof(theArgVec[5]))), Draw::Atof(theArgVec[6])); + } if (theArgsNb == 6) + { aPositionType = theArgVec[5]; + } else if (theArgsNb == 8) + { aPositionType = theArgVec[7]; + } } else if (!strcmp(theArgVec[0], "qline")) { @@ -73,7 +81,9 @@ static int qcurve(Draw_Interpretor&, int theArgsNb, const char** theArgVec) aResult2d = new Geom2d_Line(gp_Pnt2d(Draw::Atof(theArgVec[2]), Draw::Atof(theArgVec[3])), gp_Dir2d(Draw::Atof(theArgVec[4]), Draw::Atof(theArgVec[5]))); if (theArgsNb == 7) + { aPositionType = theArgVec[6]; + } } else { @@ -86,7 +96,9 @@ static int qcurve(Draw_Interpretor&, int theArgsNb, const char** theArgVec) { GccEnt_Position aParameterPosition; if (GccEnt::PositionFromString(aPositionType.ToCString(), aParameterPosition)) + { aKindOfPosition = aParameterPosition; + } } Draw::Set(theArgVec[1], new GeometryTest_DrawableQualifiedCurve2d(aResult2d, aKindOfPosition)); @@ -122,7 +134,9 @@ static int solutions(Draw_Interpretor& theDI, GccAna_Circ2d3Tan& theCirTan3, con theDI << " tangent points: point (parameter on solution, parameter on argument)\n"; // the first tangent point if (theCirTan3.IsTheSame1(aSolId)) + { theDI << " " << "= the solution number " << aSolId << " is equal to the first argument\n"; + } else { theCirTan3.Tangency1(aSolId, aParSol, aParArg, aPntSol); @@ -132,7 +146,9 @@ static int solutions(Draw_Interpretor& theDI, GccAna_Circ2d3Tan& theCirTan3, con } // the second tangent point if (theCirTan3.IsTheSame2(aSolId)) + { theDI << " " << "= the solution number " << aSolId << " is equal to the second argument\n"; + } else { theCirTan3.Tangency2(aSolId, aParSol, aParArg, aPntSol); @@ -142,7 +158,9 @@ static int solutions(Draw_Interpretor& theDI, GccAna_Circ2d3Tan& theCirTan3, con } // the third tangent point if (theCirTan3.IsTheSame3(aSolId)) + { theDI << " " << "= the solution number " << aSolId << " is equal to the third argument\n"; + } else { theCirTan3.Tangency3(aSolId, aParSol, aParArg, aPntSol); @@ -151,7 +169,9 @@ static int solutions(Draw_Interpretor& theDI, GccAna_Circ2d3Tan& theCirTan3, con theDI << " " << aTanPntIdName.ToCString() << " (" << aParSol << ", " << aParArg << ")"; } if (aSolId != theCirTan3.NbSolutions()) + { theDI << "\n"; + } } return 0; } @@ -184,7 +204,9 @@ static int circ2d3Tan(Draw_Interpretor& theDI, int theArgsNb, const char** theAr double aTolerance = Precision::Confusion(); if (theArgsNb > 5) + { aTolerance = Draw::Atof(theArgVec[5]); + } if (aQCurve1.IsNull()) // { @@ -318,7 +340,9 @@ void GeometryTest::CurveTanCommands(Draw_Interpretor& theCommands) { static bool aLoaded = false; if (aLoaded) + { return; + } aLoaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_FairCurveCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_FairCurveCommands.cxx index 64643a2527..caada469cb 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_FairCurveCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_FairCurveCommands.cxx @@ -33,7 +33,9 @@ bool IsGoodNumber(int argc, int waiting, Draw_Interpretor& di) return false; } else + { return true; + } } //======================================================================= @@ -41,7 +43,9 @@ static int BattenCurve(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 6, di)) + { return 1; + } const char* cp1 = argv[1]; const char* cp2 = argv[2]; @@ -55,9 +59,13 @@ static int BattenCurve(Draw_Interpretor& di, int argc, const char** argv) gp_Pnt2d P1, P2; if (!DrawTrSurf::GetPoint2d(cp1, P1)) + { return 1; + } if (!DrawTrSurf::GetPoint2d(cp2, P2)) + { return 1; + } FairCurve_Batten* Bat = new FairCurve_Batten(P1, P2, h); Bat->SetAngle1(a1 * M_PI / 180); @@ -83,7 +91,9 @@ static int MVCurve(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 6, di)) + { return 1; + } const char* cp1 = argv[1]; const char* cp2 = argv[2]; @@ -97,9 +107,13 @@ static int MVCurve(Draw_Interpretor& di, int argc, const char** argv) gp_Pnt2d P1, P2; if (!DrawTrSurf::GetPoint2d(cp1, P1)) + { return 1; + } if (!DrawTrSurf::GetPoint2d(cp2, P2)) + { return 1; + } FairCurve_MinimalVariation* MVC = new FairCurve_MinimalVariation(P1, P2, h); MVC->SetAngle1(a1 * M_PI / 180); @@ -125,7 +139,9 @@ static int SetPoint(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 3, di)) + { return 1; + } const char* side = argv[1]; const char* PointName = argv[2]; @@ -135,12 +151,16 @@ static int SetPoint(Draw_Interpretor& di, int argc, const char** argv) occ::handle Pnt = occ::down_cast(Draw::Get(PointName)); if (Pnt.IsNull()) + { return 1; + } occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->SetPoint(cote, Pnt->Point2d()); Draw::Repaint(); @@ -152,7 +172,9 @@ static int SetAngle(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 3, di)) + { return 1; + } const char* side = argv[1]; const char* val = argv[2]; @@ -164,7 +186,9 @@ static int SetAngle(Draw_Interpretor& di, int argc, const char** argv) occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->SetAngle(cote, angle); Draw::Repaint(); @@ -176,7 +200,9 @@ static int SetCurvature(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 3, di)) + { return 1; + } const char* side = argv[1]; const char* val = argv[2]; @@ -188,7 +214,9 @@ static int SetCurvature(Draw_Interpretor& di, int argc, const char** argv) occ::handle MVC = occ::down_cast(Draw::Get(MVCName)); if (MVC.IsNull()) + { return 1; + } MVC->SetCurvature(cote, rho); Draw::Repaint(); @@ -200,7 +228,9 @@ static int SetSlide(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* val = argv[1]; const char* BattenName = argv[2]; @@ -210,7 +240,9 @@ static int SetSlide(Draw_Interpretor& di, int argc, const char** argv) occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->SetSliding(slide); Draw::Repaint(); @@ -222,7 +254,9 @@ static int FreeAngle(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* side = argv[1]; const char* BattenName = argv[2]; @@ -232,7 +266,9 @@ static int FreeAngle(Draw_Interpretor& di, int argc, const char** argv) occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->FreeAngle(cote); Draw::Repaint(); @@ -244,7 +280,9 @@ static int FreeCurvature(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* side = argv[1]; const char* MVCName = argv[2]; @@ -254,7 +292,9 @@ static int FreeCurvature(Draw_Interpretor& di, int argc, const char** argv) occ::handle MVC = occ::down_cast(Draw::Get(MVCName)); if (MVC.IsNull()) + { return 1; + } MVC->FreeCurvature(cote); Draw::Repaint(); @@ -266,14 +306,18 @@ static int FreeSlide(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 1, di)) + { return 1; + } const char* BattenName = argv[1]; occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->FreeSliding(); Draw::Repaint(); @@ -285,7 +329,9 @@ static int SetHeight(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* val = argv[1]; const char* BattenName = argv[2]; @@ -295,7 +341,9 @@ static int SetHeight(Draw_Interpretor& di, int argc, const char** argv) occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->SetHeight(Height); Draw::Repaint(); @@ -307,7 +355,9 @@ static int SetSlope(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* val = argv[1]; const char* BattenName = argv[2]; @@ -317,7 +367,9 @@ static int SetSlope(Draw_Interpretor& di, int argc, const char** argv) occ::handle Bat = occ::down_cast(Draw::Get(BattenName)); if (Bat.IsNull()) + { return 1; + } Bat->SetSlope(Slope); Draw::Repaint(); @@ -328,7 +380,9 @@ static int SetPhysicalRatio(Draw_Interpretor& di, int argc, const char** argv) //======================================================================= { if (!IsGoodNumber(argc, 2, di)) + { return 1; + } const char* val = argv[1]; const char* MVCName = argv[2]; @@ -338,7 +392,9 @@ static int SetPhysicalRatio(Draw_Interpretor& di, int argc, const char** argv) occ::handle MVC = occ::down_cast(Draw::Get(MVCName)); if (MVC.IsNull()) + { return 1; + } MVC->SetPhysicalRatio(ratio); Draw::Repaint(); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_PolyCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_PolyCommands.cxx index 6a88eb3d61..cc508310b2 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_PolyCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_PolyCommands.cxx @@ -35,7 +35,9 @@ Standard_IMPORT Draw_Viewer dout; static int polytr(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } int nbNodes = Draw::Atoi(a[2]); int nbTri = Draw::Atoi(a[3]); @@ -81,7 +83,9 @@ static int polytr(Draw_Interpretor& di, int n, const char** a) static int polygon3d(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } int nbNodes = Draw::Atoi(a[2]); @@ -112,7 +116,9 @@ static int polygon3d(Draw_Interpretor& di, int n, const char** a) static int polygon2d(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } int nbNodes = Draw::Atoi(a[2]); @@ -143,7 +149,9 @@ static int polygon2d(Draw_Interpretor& di, int n, const char** a) static int shnodes(Draw_Interpretor&, int n, const char** a) { if (n != 2) + { return 1; + } occ::handle T = occ::down_cast(Draw::Get(a[1])); @@ -163,7 +171,9 @@ static int shnodes(Draw_Interpretor&, int n, const char** a) static int shtriangles(Draw_Interpretor&, int n, const char** a) { if (n != 2) + { return 1; + } occ::handle T = occ::down_cast(Draw::Get(a[1])); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_SurfaceCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_SurfaceCommands.cxx index 4e68217cfb..bc165cc8b0 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_SurfaceCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_SurfaceCommands.cxx @@ -61,7 +61,9 @@ static int sweep(Draw_Interpretor& di, int n, const char** a) double Tol = 1.e-4; if (n < 4) + { return 1; + } if (!strcmp(a[2], "-FX")) { @@ -98,15 +100,21 @@ static int sweep(Draw_Interpretor& di, int n, const char** a) { occ::handle path = DrawTrSurf::GetCurve2d(a[ipath]); if (path.IsNull()) + { return 1; + } occ::handle Support = DrawTrSurf::GetSurface(a[ipath + 1]); if (Support.IsNull()) + { return 1; + } occ::handle firstS = DrawTrSurf::GetCurve(a[ipath + 2]); if (firstS.IsNull()) + { return 1; + } Pipe.Init(path, Support, firstS); } @@ -121,11 +129,15 @@ static int sweep(Draw_Interpretor& di, int n, const char** a) { occ::handle path = DrawTrSurf::GetCurve(a[ipath]); if (path.IsNull()) + { return 1; + } occ::handle firstS = DrawTrSurf::GetCurve(a[ipath + 1]); if (firstS.IsNull()) + { return 1; + } Pipe.Init(path, firstS, Option); } @@ -134,7 +146,9 @@ static int sweep(Draw_Interpretor& di, int n, const char** a) { MaxDegree = Draw::Atoi(a[isection + 1]); if (n > isection + 2) + { NbSeg = Draw::Atoi(a[isection + 2]); + } } Pipe.Perform(Tol, false, GeomAbs_C2, MaxDegree, NbSeg); @@ -157,7 +171,9 @@ static int sweep(Draw_Interpretor& di, int n, const char** a) static int tuyau(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } GeomAbs_Shape Cont = GeomAbs_C2; GeomFill_Pipe Pipe; @@ -173,7 +189,9 @@ static int tuyau(Draw_Interpretor& di, int n, const char** a) } occ::handle path = DrawTrSurf::GetCurve(a[indice_path]); if (path.IsNull()) + { return 1; + } int isect = indice_path + 1; occ::handle firstS = DrawTrSurf::GetCurve(a[isect]); @@ -185,7 +203,9 @@ static int tuyau(Draw_Interpretor& di, int n, const char** a) Pipe.Init(path, Draw::Atof(a[isect])); } else + { return 1; + } } else { @@ -254,7 +274,9 @@ static int tuyau(Draw_Interpretor& di, int n, const char** a) static int ruled(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle C1 = DrawTrSurf::GetCurve(a[2]); if (C1.IsNull()) @@ -271,7 +293,9 @@ static int ruled(Draw_Interpretor& di, int n, const char** a) occ::handle S = GeomFill::Surface(C1, C2); if (S.IsNull()) + { return 1; + } DrawTrSurf::Set(a[1], S); return 0; @@ -282,7 +306,9 @@ static int ruled(Draw_Interpretor& di, int n, const char** a) static int appsurf(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } GeomFill_SectionGenerator Section; int i; @@ -291,7 +317,9 @@ static int appsurf(Draw_Interpretor& di, int n, const char** a) { C = DrawTrSurf::GetCurve(a[i]); if (C.IsNull()) + { return 1; + } Section.AddCurve(C); } @@ -327,7 +355,9 @@ static int appsurf(Draw_Interpretor& di, int n, const char** a) static int fillcurves(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 6) + { return 1; + } int i; occ::handle aC; @@ -336,21 +366,31 @@ static int fillcurves(Draw_Interpretor& /*di*/, int n, const char** a) { aC = DrawTrSurf::GetCurve(a[i]); if (aC.IsNull()) + { return 1; + } C[i - 2] = GeomConvert::CurveToBSplineCurve(aC, Convert_RationalC1); } int ist = 2; GeomFill_FillingStyle Style = GeomFill_CoonsStyle; if (n > 6) + { ist = Draw::Atoi(a[6]); + } if (ist == 1) + { Style = GeomFill_StretchStyle; + } if (ist == 2) + { Style = GeomFill_CoonsStyle; + } if (ist == 3) + { Style = GeomFill_CurvedStyle; + } GeomFill_BSplineCurves aFilling(C[0], C[1], C[2], C[3], Style); @@ -397,7 +437,9 @@ void GeometryTest::SurfaceCommands(Draw_Interpretor& theCommands) { static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeometryTest/GeometryTest_TestProjCommands.cxx b/src/Draw/TKTopTest/GeometryTest/GeometryTest_TestProjCommands.cxx index 1b5c92d30d..5a82653f95 100644 --- a/src/Draw/TKTopTest/GeometryTest/GeometryTest_TestProjCommands.cxx +++ b/src/Draw/TKTopTest/GeometryTest/GeometryTest_TestProjCommands.cxx @@ -33,7 +33,7 @@ static int xdistcc(Draw_Interpretor&, int n, const char** a) { if (n < 5) { - std::cout << " Use xdistcc c1 c2 t1 t2 nbp" << std::endl; + std::cout << " Use xdistcc c1 c2 t1 t2 nbp" << '\n'; return 0; } @@ -47,14 +47,14 @@ static int xdistcc(Draw_Interpretor&, int n, const char** a) aC1 = DrawTrSurf::GetCurve(a[1]); if (aC1.IsNull()) { - std::cout << a[1] << " is null curve" << std::endl; + std::cout << a[1] << " is null curve" << '\n'; return 0; } aC2 = DrawTrSurf::GetCurve(a[2]); if (aC2.IsNull()) { - std::cout << a[2] << " is null curve" << std::endl; + std::cout << a[2] << " is null curve" << '\n'; return 0; } @@ -77,7 +77,9 @@ static int xdistcc(Draw_Interpretor&, int n, const char** a) { aT = aT1 + i * dT; if (i == aNbP - 1) + { aT = aT2; + } aC1->D0(aT, aP1); aC2->D0(aT, aP2); @@ -96,8 +98,8 @@ static int xdistcc(Draw_Interpretor&, int n, const char** a) dout << aMr; } - std::cout << "Max distance = " << aMaxDist << std::endl; - std::cout << "Param = " << aMaxParam << std::endl; + std::cout << "Max distance = " << aMaxDist << '\n'; + std::cout << "Param = " << aMaxParam << '\n'; return 0; } @@ -108,7 +110,7 @@ static int xdistc2dc2dss(Draw_Interpretor&, int n, const char** a) { if (n < 7) { - std::cout << " Use xdistc2dc2dss c2d_1 c2d_2 s1 s2 t1 t2 nbp" << std::endl; + std::cout << " Use xdistc2dc2dss c2d_1 c2d_2 s1 s2 t1 t2 nbp" << '\n'; return 0; } @@ -124,28 +126,28 @@ static int xdistc2dc2dss(Draw_Interpretor&, int n, const char** a) aC2d1 = DrawTrSurf::GetCurve2d(a[1]); if (aC2d1.IsNull()) { - std::cout << a[1] << " is null 2dcurve" << std::endl; + std::cout << a[1] << " is null 2dcurve" << '\n'; return 0; } aC2d2 = DrawTrSurf::GetCurve2d(a[2]); if (aC2d2.IsNull()) { - std::cout << a[2] << " is null 2dcurve" << std::endl; + std::cout << a[2] << " is null 2dcurve" << '\n'; return 0; } aS1 = DrawTrSurf::GetSurface(a[3]); if (aS1.IsNull()) { - std::cout << a[3] << " is null surface" << std::endl; + std::cout << a[3] << " is null surface" << '\n'; return 0; } aS2 = DrawTrSurf::GetSurface(a[4]); if (aS2.IsNull()) { - std::cout << a[4] << " is null surface" << std::endl; + std::cout << a[4] << " is null surface" << '\n'; return 0; } @@ -168,7 +170,9 @@ static int xdistc2dc2dss(Draw_Interpretor&, int n, const char** a) { aT = aT1 + i * dT; if (i == aNbP - 1) + { aT = aT2; + } aC2d1->D0(aT, aP2d1); aS1->D0(aP2d1.X(), aP2d1.Y(), aP1); @@ -190,8 +194,8 @@ static int xdistc2dc2dss(Draw_Interpretor&, int n, const char** a) dout << aMr; } - std::cout << "Max distance = " << aMaxDist << std::endl; - std::cout << "Param = " << aMaxParam << std::endl; + std::cout << "Max distance = " << aMaxDist << '\n'; + std::cout << "Param = " << aMaxParam << '\n'; return 0; } @@ -202,7 +206,7 @@ static int xdistcc2ds(Draw_Interpretor&, int n, const char** a) { if (n < 6) { - std::cout << " Use xdistcc2ds c c2d s t1 t2 nbp" << std::endl; + std::cout << " Use xdistcc2ds c c2d s t1 t2 nbp" << '\n'; return 0; } @@ -219,21 +223,21 @@ static int xdistcc2ds(Draw_Interpretor&, int n, const char** a) aC = DrawTrSurf::GetCurve(a[1]); if (aC.IsNull()) { - std::cout << a[1] << " is null curve" << std::endl; + std::cout << a[1] << " is null curve" << '\n'; return 0; } aC2d = DrawTrSurf::GetCurve2d(a[2]); if (aC2d.IsNull()) { - std::cout << a[2] << " is null 2dcurve" << std::endl; + std::cout << a[2] << " is null 2dcurve" << '\n'; return 0; } aS = DrawTrSurf::GetSurface(a[3]); if (aS.IsNull()) { - std::cout << a[3] << " is null surface" << std::endl; + std::cout << a[3] << " is null surface" << '\n'; return 0; } @@ -256,7 +260,9 @@ static int xdistcc2ds(Draw_Interpretor&, int n, const char** a) { aT = aT1 + i * dT; if (i == aNbP - 1) + { aT = aT2; + } aC->D0(aT, aP); @@ -277,8 +283,8 @@ static int xdistcc2ds(Draw_Interpretor&, int n, const char** a) dout << aMr; } - std::cout << "Max distance = " << aMaxDist << std::endl; - std::cout << "Param = " << aMaxParam << std::endl; + std::cout << "Max distance = " << aMaxDist << '\n'; + std::cout << "Param = " << aMaxParam << '\n'; return 0; } @@ -289,13 +295,12 @@ static int xdistcs(Draw_Interpretor& di, int n, const char** a) { if (n < 6) { - std::cout << "Use: xdistcs curve surface t1 t2 nbpoints [tol [warn_tol]]" << std::endl; + std::cout << "Use: xdistcs curve surface t1 t2 nbpoints [tol [warn_tol]]" << '\n'; std::cout << "Measures distances from curve to surface by nbpoints probing points on a curve" - << std::endl; - std::cout << "Error will be reported for points where distance is greater than tol" - << std::endl; + << '\n'; + std::cout << "Error will be reported for points where distance is greater than tol" << '\n'; std::cout << "Warning will be reported for points where distance is greater than warn_tol" - << std::endl; + << '\n'; return 0; } // @@ -396,7 +401,9 @@ void GeometryTest::TestProjCommands(Draw_Interpretor& theCommands) static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest.cxx index b5967ef291..cba5755683 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest.cxx @@ -24,7 +24,9 @@ void GeomliteTest::AllCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } done = true; GeomliteTest::CurveCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_API2dCommands.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_API2dCommands.cxx index be61ca161d..b93455ef02 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_API2dCommands.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_API2dCommands.cxx @@ -161,7 +161,9 @@ static int appro(Draw_Interpretor& di, int n, const char** a) // points sur courbe occ::handle GC = DrawTrSurf::GetCurve2d(a[3]); if (GC.IsNull()) + { return 1; + } double U, U1, U2; U1 = GC->FirstParameter(); @@ -203,7 +205,9 @@ static int appro(Draw_Interpretor& di, int n, const char** a) } } else + { return 1; + } } // display the points for (i = 1; i <= Nb; i++) @@ -299,9 +303,13 @@ static int extrema(Draw_Interpretor& di, int n, const char** a) // Infinity solutions flag may be set with 0 number of // solutions in analytic extrema Curve/Curve. if (isInfinitySolutions) + { di << "Infinite number of extremas, distance = " << Ex.LowerDistance() << "\n"; + } else + { di << "No solutions!\n"; + } } for (int i = 1; i <= aNExtr; i++) @@ -692,7 +700,9 @@ void GeomliteTest::API2dCommands(Draw_Interpretor& theCommands) { static bool done = false; if (done) + { return; + } const char* g; diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ApproxCommands.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ApproxCommands.cxx index 1f6d6d6c05..0823986602 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ApproxCommands.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ApproxCommands.cxx @@ -114,9 +114,13 @@ static int PointsByPick(occ::handle> nbc; if ((nbc < 1) || (nbc > nbp)) + { return; // Y a comme un probleme + } AppParCurves_Constraint Constraint = AppParCurves_NoConstraint; TABofCC = new NCollection_HArray1(1, nbp); for (i = 1; i <= nbp; i++) @@ -296,10 +306,14 @@ static void PointsByFile(occ::handle> nbc; if ((nbc < 1) || (nbc > nbp)) + { return; // Y a comme un probleme + } AppParCurves_Constraint Constraint = AppParCurves_NoConstraint; TABofCC = new NCollection_HArray1(1, nbp); for (i = 1; i <= nbp; i++) @@ -445,9 +461,13 @@ static int smoothing(Draw_Interpretor& di, int n, const char** a) if (DegMax > 0) { if (DegMax < 3) + { Variation.SetContinuity(GeomAbs_C0); + } else if (DegMax < 5) + { Variation.SetContinuity(GeomAbs_C1); + } Variation.SetMaxDegree(DegMax); } Variation.SetTolerance(std::abs(Tolerance)); @@ -475,7 +495,9 @@ static int smoothing(Draw_Interpretor& di, int n, const char** a) DC->ClearPoles(); Draw::Set(a[1], DC); if (id != 0) + { dout.RepaintView(id); + } } else { @@ -495,9 +517,13 @@ static int smoothing(Draw_Interpretor& di, int n, const char** a) if (DegMax > 0) { if (DegMax < 3) + { Variation.SetContinuity(GeomAbs_C0); + } else if (DegMax < 5) + { Variation.SetContinuity(GeomAbs_C1); + } Variation.SetMaxDegree(DegMax); } Variation.SetTolerance(std::abs(Tolerance)); @@ -524,7 +550,9 @@ static int smoothing(Draw_Interpretor& di, int n, const char** a) DC->ClearPoles(); Draw::Set(a[1], DC); if (id != 0) + { dout.RepaintView(id); + } } return 0; } @@ -589,8 +617,10 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) Constraint = AppParCurves_NoConstraint; } if (n == 5) + { // Designation Graphique ------------------------ id = PointsByPick(Points, di); + } else { // lecture du fichier. @@ -627,11 +657,15 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) AppParCurves_ConstraintCouple AC1(1, AppParCurves_PassPoint); if (TABofCC->Value(1).Constraint() < AppParCurves_PassPoint) + { TABofCC->SetValue(1, AC1); + } AppParCurves_ConstraintCouple AC2(NbPoints, AppParCurves_PassPoint); if (TABofCC->Value(NbPoints).Constraint() < AppParCurves_PassPoint) + { TABofCC->SetValue(NbPoints, AC2); + } } if (methode < 3) @@ -641,7 +675,9 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) int NbIteration = 5; if (Degree < 4) + { degmin = std::max(1, Degree - 1); + } degmin = std::max( degmin, NbConstraint(TABofCC->Value(1).Constraint(), TABofCC->Value(NbPoints).Constraint())); @@ -692,7 +728,9 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) occ::handle DC = new (DrawTrSurf_BezierCurve2d)(Cvliss); Draw::Set(a[1], DC); if (id != 0) + { dout.RepaintView(id); + } } else { @@ -710,11 +748,15 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) AppParCurves_ConstraintCouple AC1(1, AppParCurves_PassPoint); if (TABofCC->Value(1).Constraint() < AppParCurves_PassPoint) + { TABofCC->SetValue(1, AC1); + } AppParCurves_ConstraintCouple AC2(NbPoints, AppParCurves_PassPoint); if (TABofCC->Value(NbPoints).Constraint() < AppParCurves_PassPoint) + { TABofCC->SetValue(NbPoints, AC2); + } } if (methode < 3) @@ -723,7 +765,9 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) int degmin = 4; int NbIteration = 5; if (Degree < 4) + { degmin = std::max(1, Degree - 1); + } degmin = std::max( degmin, NbConstraint(TABofCC->Value(1).Constraint(), TABofCC->Value(NbPoints).Constraint())); @@ -774,7 +818,9 @@ static int smoothingbybezier(Draw_Interpretor& di, int n, const char** a) occ::handle DC = new DrawTrSurf_BezierCurve(Cvliss); Draw::Set(a[1], DC); if (id != 0) + { dout.RepaintView(id); + } } return 0; } @@ -786,7 +832,9 @@ void GeomliteTest::ApproxCommands(Draw_Interpretor& theCommands) static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_CurveCommands.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_CurveCommands.cxx index 97742a5235..a36370d24d 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_CurveCommands.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_CurveCommands.cxx @@ -132,7 +132,9 @@ public: static int anacurve(Draw_Interpretor&, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle result; occ::handle result2d; @@ -140,146 +142,206 @@ static int anacurve(Draw_Interpretor&, int n, const char** a) if (!strcmp(a[0], "line")) { if (n == 6) + { result2d = new Geom2d_Line(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(Draw::Atof(a[4]), Draw::Atof(a[5]))); + } else if (n == 8) + { result = new Geom_Line(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]))); + } else + { return 1; + } } else if (!strcmp(a[0], "circle")) { if (n == 5) + { result2d = new Geom2d_Circle( gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(gp_Dir2d::D::X)), Draw::Atof(a[4])); + } else if (n == 6) + { result = new Geom_Circle( gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(gp_Dir::D::Z)), Draw::Atof(a[5])); + } else if (n == 7) + { result2d = new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(Draw::Atof(a[4]), Draw::Atof(a[5]))), Draw::Atof(a[6])); + } else if (n == 9) + { result = new Geom_Circle(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]))), Draw::Atof(a[8])); + } else if (n == 12) + { result = new Geom_Circle(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7])), gp_Dir(Draw::Atof(a[8]), Draw::Atof(a[9]), Draw::Atof(a[10]))), Draw::Atof(a[11])); + } else + { return 1; + } } else if (!strcmp(a[0], "parabola")) { if (n == 5) + { result2d = new Geom2d_Parabola( gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(gp_Dir2d::D::X)), Draw::Atof(a[4])); + } else if (n == 6) + { result = new Geom_Parabola( gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(gp_Dir::D::Z)), Draw::Atof(a[5])); + } else if (n == 7) + { result2d = new Geom2d_Parabola(gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(Draw::Atof(a[4]), Draw::Atof(a[5]))), Draw::Atof(a[6])); + } else if (n == 9) + { result = new Geom_Parabola(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]))), Draw::Atof(a[8])); + } else if (n == 12) + { result = new Geom_Parabola(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7])), gp_Dir(Draw::Atof(a[8]), Draw::Atof(a[9]), Draw::Atof(a[10]))), Draw::Atof(a[11])); + } else + { return 1; + } } else if (!strcmp(a[0], "ellipse")) { if (n == 6) + { result2d = new Geom2d_Ellipse( gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(gp_Dir2d::D::X)), Draw::Atof(a[4]), Draw::Atof(a[5])); + } else if (n == 7) + { result = new Geom_Ellipse( gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(gp_Dir::D::Z)), Draw::Atof(a[5]), Draw::Atof(a[6])); + } else if (n == 8) + { result2d = new Geom2d_Ellipse(gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(Draw::Atof(a[4]), Draw::Atof(a[5]))), Draw::Atof(a[6]), Draw::Atof(a[7])); + } else if (n == 10) + { result = new Geom_Ellipse(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]))), Draw::Atof(a[8]), Draw::Atof(a[9])); + } else if (n == 13) + { result = new Geom_Ellipse(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7])), gp_Dir(Draw::Atof(a[8]), Draw::Atof(a[9]), Draw::Atof(a[10]))), Draw::Atof(a[11]), Draw::Atof(a[12])); + } else + { return 1; + } } else if (!strcmp(a[0], "hyperbola")) { if (n == 6) + { result2d = new Geom2d_Hyperbola( gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(gp_Dir2d::D::X)), Draw::Atof(a[4]), Draw::Atof(a[5])); + } else if (n == 7) + { result = new Geom_Hyperbola( gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(gp_Dir::D::Z)), Draw::Atof(a[5]), Draw::Atof(a[6])); + } else if (n == 8) + { result2d = new Geom2d_Hyperbola(gp_Ax22d(gp_Pnt2d(Draw::Atof(a[2]), Draw::Atof(a[3])), gp_Dir2d(Draw::Atof(a[4]), Draw::Atof(a[5]))), Draw::Atof(a[6]), Draw::Atof(a[7])); + } else if (n == 10) + { result = new Geom_Hyperbola(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]))), Draw::Atof(a[8]), Draw::Atof(a[9])); + } else if (n == 13) + { result = new Geom_Hyperbola(gp_Ax2(gp_Pnt(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])), gp_Dir(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7])), gp_Dir(Draw::Atof(a[8]), Draw::Atof(a[9]), Draw::Atof(a[10]))), Draw::Atof(a[11]), Draw::Atof(a[12])); + } else + { return 1; + } } if (!result.IsNull()) + { DrawTrSurf::Set(a[1], result); + } else if (!result2d.IsNull()) + { DrawTrSurf::Set(a[1], result2d); + } else + { return 1; + } return 0; } @@ -291,18 +353,24 @@ static int polecurve(Draw_Interpretor&, int n, const char** a) int k, i; if (n < 3) + { return 1; + } if (!strcmp(a[0], "beziercurve")) { int np = Draw::Atoi(a[2]); if (np == 0) + { return 1; + } i = (n - 3) / (np); if (i < 3 || i > 4) + { return 1; + } bool hasw = i == 4; NCollection_Array1 poles(1, np); @@ -322,9 +390,13 @@ static int polecurve(Draw_Interpretor&, int n, const char** a) occ::handle result; if (hasw) + { result = new Geom_BezierCurve(poles, weights); + } else + { result = new Geom_BezierCurve(poles); + } DrawTrSurf::Set(a[1], result); } @@ -350,9 +422,13 @@ static int polecurve(Draw_Interpretor&, int n, const char** a) bool periodic = *a[0] == 'p'; int np; if (periodic) + { np = Sigma - mults(nbk); + } else + { np = Sigma - deg - 1; + } NCollection_Array1 poles(1, np); NCollection_Array1 weights(1, np); @@ -380,18 +456,24 @@ static int polecurve2d(Draw_Interpretor&, int n, const char** a) int k, i; if (n < 3) + { return 1; + } if (!strcmp(a[0], "2dbeziercurve")) { int np = Draw::Atoi(a[2]); if (np == 0) + { return 1; + } i = (n - 2) / (np); if (i < 2 || i > 3) + { return 1; + } bool hasw = i == 3; NCollection_Array1 poles(1, np); @@ -411,9 +493,13 @@ static int polecurve2d(Draw_Interpretor&, int n, const char** a) occ::handle result; if (hasw) + { result = new Geom2d_BezierCurve(poles, weights); + } else + { result = new Geom2d_BezierCurve(poles); + } DrawTrSurf::Set(a[1], result); } @@ -439,9 +525,13 @@ static int polecurve2d(Draw_Interpretor&, int n, const char** a) bool periodic = *(a[0] + 2) == 'p'; int np; if (periodic) + { np = Sigma - mults(nbk); + } else + { np = Sigma - deg - 1; + } NCollection_Array1 poles(1, np); NCollection_Array1 weights(1, np); @@ -467,7 +557,9 @@ static int polecurve2d(Draw_Interpretor&, int n, const char** a) static int reverse(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } int i; for (i = 1; i < n; i++) @@ -494,13 +586,17 @@ static int reverse(Draw_Interpretor&, int n, const char** a) static int cmovepole(Draw_Interpretor&, int n, const char** a) { if (n < 5) + { return 1; + } double dx = Draw::Atof(a[3]); double dy = Draw::Atof(a[4]); double dz = 0; if (n >= 6) + { dz = Draw::Atof(a[5]); + } int Index = Draw::Atoi(a[2]); occ::handle G1 = DrawTrSurf::GetBezierCurve(a[1]); @@ -645,13 +741,17 @@ static int cmovetangent(Draw_Interpretor& di, int n, const char** a) static int cmovepoint(Draw_Interpretor&, int n, const char** a) { if (n < 5) + { return 1; + } double dx = Draw::Atof(a[3]); double dy = Draw::Atof(a[4]); double dz = 0; if (n >= 6 && n != 7) + { dz = Draw::Atof(a[5]); + } double u = Draw::Atof(a[2]); int index1 = 0; int index2 = 0; @@ -706,31 +806,43 @@ static int cmovepoint(Draw_Interpretor&, int n, const char** a) static int cinsertknot(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (GBs.IsNull() && GBs2d.IsNull()) + { return 1; + } if (n <= 4) { double knot = Draw::Atof(a[2]); int mult = 1; if (n == 4) + { mult = Draw::Atoi(a[3]); + } if (!GBs.IsNull()) + { GBs->InsertKnot(knot, mult, Precision::PConfusion()); + } else + { GBs2d->InsertKnot(knot, mult, Precision::PConfusion()); + } } else { // multiple insertion if (n % 2 != 0) + { return 1; + } int i, nbk = (n - 2) / 2; NCollection_Array1 knots(1, nbk); NCollection_Array1 mults(1, nbk); @@ -741,9 +853,13 @@ static int cinsertknot(Draw_Interpretor&, int n, const char** a) } if (!GBs.IsNull()) + { GBs->InsertKnots(knots, mults, Precision::PConfusion()); + } else + { GBs2d->InsertKnots(knots, mults, Precision::PConfusion()); + } } Draw::Repaint(); @@ -755,13 +871,17 @@ static int cinsertknot(Draw_Interpretor&, int n, const char** a) static int csetknot(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (GBs.IsNull() && GBs2d.IsNull()) + { return 1; + } int index = Draw::Atoi(a[2]); double knot = Draw::Atof(a[3]); @@ -769,17 +889,25 @@ static int csetknot(Draw_Interpretor&, int n, const char** a) if (n == 4) { if (!GBs.IsNull()) + { GBs->SetKnot(index, knot); + } else + { GBs2d->SetKnot(index, knot); + } } else { int mult = Draw::Atoi(a[4]); if (!GBs.IsNull()) + { GBs->SetKnot(index, knot, mult); + } else + { GBs2d->SetKnot(index, knot, mult); + } } Draw::Repaint(); @@ -791,32 +919,44 @@ static int csetknot(Draw_Interpretor&, int n, const char** a) static int cremknot(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (GBs.IsNull() && GBs2d.IsNull()) + { return 1; + } int index = Draw::Atoi(a[2]); int mult = 0; if (n >= 4) + { mult = Draw::Atoi(a[3]); + } double tol = RealLast(); if (n >= 5) + { tol = Draw::Atof(a[4]); + } if (!GBs.IsNull()) { if (!GBs->RemoveKnot(index, mult, tol)) + { di << "Remove knots failed\n"; + } } else { if (!GBs2d->RemoveKnot(index, mult, tol)) + { di << "Remove knots failed\n"; + } } Draw::Repaint(); @@ -828,7 +968,9 @@ static int cremknot(Draw_Interpretor& di, int n, const char** a) static int increasedegree(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } int Deg = Draw::Atoi(a[2]); @@ -838,15 +980,25 @@ static int increasedegree(Draw_Interpretor&, int n, const char** a) occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (!GBz.IsNull()) + { GBz->Increase(Deg); + } else if (!GBs.IsNull()) + { GBs->IncreaseDegree(Deg); + } else if (!GBz2d.IsNull()) + { GBz2d->Increase(Deg); + } else if (!GBs2d.IsNull()) + { GBs2d->IncreaseDegree(Deg); + } else + { return 1; + } Draw::Repaint(); return 0; @@ -857,7 +1009,9 @@ static int increasedegree(Draw_Interpretor&, int n, const char** a) static int removepole(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } int Index = Draw::Atoi(a[2]); @@ -886,7 +1040,9 @@ static int removepole(Draw_Interpretor& di, int n, const char** a) static int insertpole(Draw_Interpretor& di, int n, const char** a) { if (n < 6) + { return 1; + } int Index = Draw::Atoi(a[2]); @@ -896,17 +1052,25 @@ static int insertpole(Draw_Interpretor& di, int n, const char** a) { gp_Pnt P(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); if (n == 7) + { GBZ->InsertPoleAfter(Index, P, Draw::Atof(a[6])); + } else + { GBZ->InsertPoleAfter(Index, P); + } } else if (!GBZ2d.IsNull()) { gp_Pnt2d P(Draw::Atof(a[3]), Draw::Atof(a[4])); if (n == 6) + { GBZ2d->InsertPoleAfter(Index, P, Draw::Atof(a[5])); + } else + { GBZ2d->InsertPoleAfter(Index, P); + } } else { @@ -923,7 +1087,9 @@ static int insertpole(Draw_Interpretor& di, int n, const char** a) static int cfindp(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } int Index = 0; int view = Draw::Atoi(a[2]); @@ -936,24 +1102,34 @@ static int cfindp(Draw_Interpretor&, int n, const char** a) occ::handle DBz = occ::down_cast(D); if (!DBz.IsNull()) + { DBz->FindPole(x, y, d, 5, Index); + } else { occ::handle DBs = occ::down_cast(D); if (!DBs.IsNull()) + { DBs->FindPole(x, y, d, 5, Index); + } else { occ::handle DBz2d = occ::down_cast(D); if (!DBz2d.IsNull()) + { DBz2d->FindPole(x, y, d, 5, Index); + } else { occ::handle DBs2d = occ::down_cast(D); if (!DBs2d.IsNull()) + { DBs2d->FindPole(x, y, d, 5, Index); + } else + { return 1; + } } } } @@ -968,27 +1144,39 @@ static int cfindp(Draw_Interpretor&, int n, const char** a) static int csetperiodic(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (GBs.IsNull() && GBs2d.IsNull()) + { return 1; + } if (!strcmp(a[0], "setperiodic")) { if (!GBs.IsNull()) + { GBs->SetPeriodic(); + } else + { GBs2d->SetPeriodic(); + } } else if (!strcmp(a[0], "setnotperiodic")) { if (!GBs.IsNull()) + { GBs->SetNotPeriodic(); + } else + { GBs2d->SetNotPeriodic(); + } } Draw::Repaint(); @@ -1000,28 +1188,38 @@ static int csetperiodic(Draw_Interpretor&, int n, const char** a) static int value(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve(a[1]); if (GC.IsNull()) + { return 1; + } double U = Draw::Atof(a[2]); bool DrawPoint = (n % 3 == 1); if (DrawPoint) + { n--; + } gp_Pnt P; if (n > 6) { if (n < 9) + { return 1; + } gp_Vec D1; if (n > 9) { if (n < 12) + { return 1; + } gp_Vec D2; GC->D2(U, P, D1, D2); Draw::Set(a[9], D2.X()); @@ -1029,13 +1227,17 @@ static int value(Draw_Interpretor&, int n, const char** a) Draw::Set(a[11], D2.Z()); } else + { GC->D1(U, P, D1); + } Draw::Set(a[6], D1.X()); Draw::Set(a[7], D1.Y()); Draw::Set(a[8], D1.Z()); } else + { GC->D0(U, P); + } if (n > 3) { @@ -1056,40 +1258,54 @@ static int value(Draw_Interpretor&, int n, const char** a) static int value2d(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve2d(a[1]); if (GC.IsNull()) + { return 1; + } double U = Draw::Atof(a[2]); bool DrawPoint = (n % 2 == 0); if (DrawPoint) + { n--; + } gp_Pnt2d P; if (n > 5) { if (n < 7) + { return 1; + } gp_Vec2d D1; if (n > 7) { if (n < 9) + { return 1; + } gp_Vec2d D2; GC->D2(U, P, D1, D2); Draw::Set(a[7], D2.X()); Draw::Set(a[8], D2.Y()); } else + { GC->D1(U, P, D1); + } Draw::Set(a[5], D1.X()); Draw::Set(a[6], D1.Y()); } else + { GC->D0(U, P); + } if (n > 3) { @@ -1109,7 +1325,9 @@ static int value2d(Draw_Interpretor&, int n, const char** a) static int segment(Draw_Interpretor&, int n, const char** a) { if (n < 4 || n > 5) + { return 1; + } occ::handle GBz = DrawTrSurf::GetBezierCurve(a[1]); occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); @@ -1120,18 +1338,30 @@ static int segment(Draw_Interpretor&, int n, const char** a) double aTolerance = Precision::PConfusion(); if (n == 5) + { aTolerance = Draw::Atof(a[4]); + } if (!GBz.IsNull()) + { GBz->Segment(f, l); + } else if (!GBs.IsNull()) + { GBs->Segment(f, l, aTolerance); + } else if (!GBz2d.IsNull()) + { GBz2d->Segment(f, l); + } else if (!GBs2d.IsNull()) + { GBs2d->Segment(f, l, aTolerance); + } else + { return 1; + } Draw::Repaint(); return 0; @@ -1142,17 +1372,25 @@ static int segment(Draw_Interpretor&, int n, const char** a) static int setorigin(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineCurve(a[1]); occ::handle GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]); if (!GBs.IsNull()) + { GBs->SetOrigin(Draw::Atoi(a[2])); + } if (!GBs2d.IsNull()) + { GBs2d->SetOrigin(Draw::Atoi(a[2])); + } else + { return 1; + } Draw::Repaint(); return 0; @@ -1163,7 +1401,9 @@ static int setorigin(Draw_Interpretor&, int n, const char** a) static int point(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } if (n >= 5) { gp_Pnt P(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4])); @@ -1186,7 +1426,9 @@ static int coord(Draw_Interpretor&, int n, const char** a) { gp_Pnt2d P; if (!DrawTrSurf::GetPoint2d(a[1], P)) + { return 1; + } Draw::Set(a[2], P.X()); Draw::Set(a[3], P.Y()); } @@ -1194,13 +1436,17 @@ static int coord(Draw_Interpretor&, int n, const char** a) { gp_Pnt P; if (!DrawTrSurf::GetPoint(a[1], P)) + { return 1; + } Draw::Set(a[2], P.X()); Draw::Set(a[3], P.Y()); Draw::Set(a[4], P.Z()); } else + { return 1; + } return 0; } @@ -1210,11 +1456,15 @@ static int coord(Draw_Interpretor&, int n, const char** a) static int minmaxcurandinf(Draw_Interpretor& di, int argc, const char** argv) { if (argc < 2) + { return 1; + } occ::handle C1 = DrawTrSurf::GetCurve2d(argv[1]); if (C1.IsNull()) + { return 1; + } Draw_Color Couleur; GeomLProp_CurAndInf2d Sommets; @@ -1263,7 +1513,9 @@ static int minmaxcurandinf(Draw_Interpretor& di, int argc, const char** argv) static int shcurvature(Draw_Interpretor&, int argc, const char** argv) { if (argc < 2) + { return 1; + } occ::handle C2d = occ::down_cast(Draw::Get(argv[1])); occ::handle C3d = occ::down_cast(Draw::Get(argv[1])); @@ -1271,7 +1523,9 @@ static int shcurvature(Draw_Interpretor&, int argc, const char** argv) if (C2d.IsNull()) { if (C3d.IsNull()) + { return 1; + } C3d->ShowCurvature(); } else @@ -1287,14 +1541,18 @@ static int shcurvature(Draw_Interpretor&, int argc, const char** argv) static int clcurvature(Draw_Interpretor&, int argc, const char** argv) { if (argc < 2) + { return 1; + } occ::handle C2d = occ::down_cast(Draw::Get(argv[1])); occ::handle C3d = occ::down_cast(Draw::Get(argv[1])); if (C2d.IsNull()) { if (C3d.IsNull()) + { return 1; + } C3d->ClearCurvature(); } else @@ -1312,7 +1570,9 @@ static int clcurvature(Draw_Interpretor&, int argc, const char** argv) static int radiusmax(Draw_Interpretor&, int argc, const char** argv) { if (argc < 3) + { return 1; + } double Radius = Draw::Atof(argv[2]); occ::handle C2d = occ::down_cast(Draw::Get(argv[1])); occ::handle C3d = occ::down_cast(Draw::Get(argv[1])); @@ -1320,7 +1580,9 @@ static int radiusmax(Draw_Interpretor&, int argc, const char** argv) if (C2d.IsNull()) { if (C3d.IsNull()) + { return 1; + } C3d->SetRadiusMax(Radius); } else @@ -1338,7 +1600,9 @@ static int radiusmax(Draw_Interpretor&, int argc, const char** argv) static int radiusratio(Draw_Interpretor&, int argc, const char** argv) { if (argc < 3) + { return 1; + } double Ratio = Draw::Atof(argv[2]); occ::handle C2d = occ::down_cast(Draw::Get(argv[1])); occ::handle C3d = occ::down_cast(Draw::Get(argv[1])); @@ -1346,7 +1610,9 @@ static int radiusratio(Draw_Interpretor&, int argc, const char** argv) if (C2d.IsNull()) { if (C3d.IsNull()) + { return 1; + } C3d->SetRadiusRatio(Ratio); } else @@ -1362,7 +1628,9 @@ static int radiusratio(Draw_Interpretor&, int argc, const char** argv) static int localprop(Draw_Interpretor& di, int argc, const char** argv) { if (argc < 3) + { return 1; + } double U = Draw::Atof(argv[2]); @@ -1373,7 +1641,9 @@ static int localprop(Draw_Interpretor& di, int argc, const char** argv) { C3d = DrawTrSurf::GetCurve(argv[1]); if (C3d.IsNull()) + { return 1; + } GeomLProp_CLProps Prop(C3d, 2, Precision::Confusion()); Prop.SetParameter(U); occ::handle drp = new Draw_Marker3D(Prop.Value(), Draw_Plus, Draw_vert); @@ -1402,7 +1672,9 @@ static int localprop(Draw_Interpretor& di, int argc, const char** argv) } } else + { di << "Tangent undefined.\n"; + } } else { @@ -1430,7 +1702,9 @@ static int localprop(Draw_Interpretor& di, int argc, const char** argv) } } else + { di << "Tangent undefined.\n"; + } } return 0; } @@ -1440,7 +1714,9 @@ static int localprop(Draw_Interpretor& di, int argc, const char** argv) static int rawcont(Draw_Interpretor& di, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle GC1; GC1 = DrawTrSurf::GetCurve(a[1]); @@ -1449,7 +1725,9 @@ static int rawcont(Draw_Interpretor& di, int n, const char** a) double param1 = Draw::Atof(a[3]); double param2 = Draw::Atof(a[4]); if (GC1.IsNull() || GC2.IsNull()) + { return 1; + } gp_Pnt a_point1, a_point2; GC1->D0(param1, a_point1); GC2->D0(param2, a_point2); @@ -1507,28 +1785,40 @@ static int approxcurveonsurf(Draw_Interpretor& di, int n, const char** a) int MaxSeg = 16; /*1*/ // Maximum number of segments if (n > 8 || n < 4) + { return 1; + } if (n > 4) + { Tol = std::max(Draw::Atof(a[4]), 1.e-10); + } if (n > 5) { if (Draw::Atoi(a[5]) == 0) + { Continuity = GeomAbs_C0; + } if (Draw::Atoi(a[5]) == 2) + { Continuity = GeomAbs_C2; + } } if (n > 6) { MaxDeg = Draw::Atoi(a[6]); if (MaxDeg < 1 || MaxDeg > 14) + { MaxDeg = 14; + } } if (n > 7) + { MaxSeg = Draw::Atoi(a[7]); + } occ::handle curve2d = DrawTrSurf::GetCurve2d(a[2]); occ::handle Surf = DrawTrSurf::GetSurface(a[3]); @@ -1570,13 +1860,17 @@ static int approxcurve(Draw_Interpretor& di, int n, const char** a) occ::handle surface, surface2; if (n < 2) + { return 1; + } if (!strcmp(a[1], "-L")) { // approximation with curvilinear abscissa reparametrization if (n > 11 || n < 4) + { return 1; + } Tol = 1.e-4; curve = DrawTrSurf::GetCurve(a[3]); if (!curve.IsNull()) @@ -1588,7 +1882,9 @@ static int approxcurve(Draw_Interpretor& di, int n, const char** a) { // approx curve_on_surface if (n < 5) + { return 1; + } curve2d = DrawTrSurf::GetCurve2d(a[3]); surface = DrawTrSurf::GetSurface(a[4]); if (curve2d.IsNull() || surface.IsNull()) @@ -1622,7 +1918,9 @@ static int approxcurve(Draw_Interpretor& di, int n, const char** a) { // approximation without reparamitrization if (n > 7 || n < 3) + { return 1; + } shift = 3; curve = DrawTrSurf::GetCurve(a[2]); if (curve.IsNull()) @@ -1635,29 +1933,41 @@ static int approxcurve(Draw_Interpretor& di, int n, const char** a) Case = 2; } else + { Case = 1; + } } if (n > shift) + { Tol = std::max(Draw::Atof(a[shift]), 1.e-10); + } if (n > shift + 1) { if (Draw::Atoi(a[shift + 1]) == 0) + { Continuity = GeomAbs_C0; + } if (Draw::Atoi(a[shift + 1]) == 2) + { Continuity = GeomAbs_C2; + } } if (n > shift + 2) { MaxDeg = Draw::Atoi(a[shift + 2]); if (MaxDeg < 1 || MaxDeg > 14) + { MaxDeg = 14; + } } if (n > shift + 3) + { MaxSeg = Draw::Atoi(a[shift + 3]); + } if (Case == 1) { @@ -1744,12 +2054,16 @@ static int approxcurve(Draw_Interpretor& di, int n, const char** a) static int fitcurve(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GC; GC = DrawTrSurf::GetCurve(a[2]); if (GC.IsNull()) + { return 1; + } int Dmin = 3; int Dmax = 14; @@ -1835,10 +2149,14 @@ static int splitc1(Draw_Interpretor& di, int n, const char** c) char name[100]; if (n < 3) + { return 1; + } optiontab = Draw::Atoi(c[2]); if (n >= 4) + { tolerance = Draw::Atof(c[3]); + } if (n >= 5) { angular_tolerance = Draw::Atof(c[4]); @@ -1857,7 +2175,9 @@ static int splitc1(Draw_Interpretor& di, int n, const char** c) occ::handle BS = GeomConvert::CurveToBSplineCurve(ACurve); if (BS.IsNull()) + { return 1; + } if (optiontab) { @@ -1894,12 +2214,18 @@ static int splitc12d(Draw_Interpretor& di, int n, const char** c) char name[100]; if (n < 3) + { return 1; + } optiontab = Draw::Atoi(c[2]); if (n == 4) + { tolerance = Draw::Atof(c[3]); + } if (n == 5) + { angular_tolerance = Draw::Atof(c[4]); + } occ::handle ACurve = DrawTrSurf::GetCurve2d(c[1]); double f = ACurve->FirstParameter(); @@ -1914,7 +2240,9 @@ static int splitc12d(Draw_Interpretor& di, int n, const char** c) occ::handle BS = Geom2dConvert::CurveToBSplineCurve(ACurve); if (BS.IsNull()) + { return 1; + } if (optiontab) { @@ -1949,13 +2277,19 @@ static int canceldenom(Draw_Interpretor&, int n, const char** c) bool udirection = false; bool vdirection = false; if (n < 4) + { return 1; + } uoption = Draw::Atoi(c[2]); voption = Draw::Atoi(c[3]); if (uoption) + { udirection = true; + } if (voption) + { vdirection = true; + } occ::handle BSurf = DrawTrSurf::GetBSplineSurface(c[1]); GeomLib::CancelDenominatorDerivative(BSurf, udirection, vdirection); DrawTrSurf::Set(c[1], BSurf); @@ -1967,12 +2301,16 @@ static int canceldenom(Draw_Interpretor&, int n, const char** c) static int length(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve(a[1]); occ::handle GC2d = DrawTrSurf::GetCurve2d(a[1]); double Tol = Precision::Confusion(), L; if (n == 3) + { Tol = Draw::Atof(a[2]); + } if (!GC.IsNull()) { @@ -2001,7 +2339,9 @@ void GeomliteTest::CurveCommands(Draw_Interpretor& theCommands) static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ModificationCommands.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ModificationCommands.cxx index 9fe4c8ab54..3767d5a90b 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ModificationCommands.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_ModificationCommands.cxx @@ -41,7 +41,9 @@ static int extendcurve(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GB = occ::down_cast(DrawTrSurf::GetCurve(a[1])); if (GB.IsNull()) @@ -52,7 +54,9 @@ static int extendcurve(Draw_Interpretor& di, int n, const char** a) gp_Pnt P; if (!DrawTrSurf::GetPoint(a[2], P)) + { return 1; + } bool apres = true; if (n == 5) { @@ -72,7 +76,9 @@ static int extendcurve(Draw_Interpretor& di, int n, const char** a) static int extendsurf(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle GB = occ::down_cast(DrawTrSurf::GetSurface(a[1])); @@ -114,7 +120,9 @@ static int extendsurf(Draw_Interpretor& di, int n, const char** a) static int samerange(Draw_Interpretor& /*di*/, int n, const char** a) { if (n < 6) + { return 1; + } occ::handle C = DrawTrSurf::GetCurve2d(a[2]); occ::handle Res; double f, l, rf, rl; @@ -205,7 +213,9 @@ void GeomliteTest::ModificationCommands(Draw_Interpretor& theCommands) { static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_SurfaceCommands.cxx b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_SurfaceCommands.cxx index 7db10c9920..b08f36269c 100644 --- a/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_SurfaceCommands.cxx +++ b/src/Draw/TKTopTest/GeomliteTest/GeomliteTest_SurfaceCommands.cxx @@ -81,9 +81,13 @@ static int surface_radius(Draw_Interpretor& di, int n, const char** a) double UParameter, VParameter, radius, tolerance = 1.0e-7; if (n < 4) + { return 1; + } if (n >= 6) + { report_curvature = 1; + } UParameter = Draw::Atof(a[2]); VParameter = Draw::Atof(a[3]); @@ -96,7 +100,9 @@ static int surface_radius(Draw_Interpretor& di, int n, const char** a) radius = myProperties.MinCurvature(); if (report_curvature) + { Draw::Set(a[4], radius); + } if (std::abs(radius) > tolerance) { @@ -110,14 +116,18 @@ static int surface_radius(Draw_Interpretor& di, int n, const char** a) radius = myProperties.MaxCurvature(); if (report_curvature) + { Draw::Set(a[5], radius); + } if (std::abs(radius) > tolerance) { radius = 1.0e0 / radius; di << "Max Radius of Curvature : " << radius << "\n"; } else + { di << "Min Radius of Curvature : infinite\n"; + } } else { @@ -136,7 +146,9 @@ static int surface_radius(Draw_Interpretor& di, int n, const char** a) static int anasurface(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } gp_Ax3 loc; int i; @@ -167,7 +179,9 @@ static int anasurface(Draw_Interpretor&, int n, const char** a) i = 11; } else + { return 1; + } occ::handle result; @@ -179,7 +193,9 @@ static int anasurface(Draw_Interpretor&, int n, const char** a) else { if (i >= n) + { return 1; + } double par1 = Draw::Atof(a[i]); if (!strcasecmp(a[0], "cylinder")) @@ -197,7 +213,9 @@ static int anasurface(Draw_Interpretor&, int n, const char** a) else { if (i + 1 >= n) + { return 1; + } double par2 = Draw::Atof(a[i + 1]); if (!strcasecmp(a[0], "cone")) @@ -226,7 +244,9 @@ static int polesurface(Draw_Interpretor&, int n, const char** a) int k, j, i; if (n < 4) + { return 1; + } if (!strcasecmp(a[0], "beziersurf")) { @@ -234,11 +254,15 @@ static int polesurface(Draw_Interpretor&, int n, const char** a) int nup = Draw::Atoi(a[2]); int nvp = Draw::Atoi(a[3]); if (nup * nvp == 0) + { return 1; + } i = (n - 4) / (nup * nvp); if (i < 3 || i > 4) + { return 1; + } bool hasw = i == 4; NCollection_Array2 poles(1, nup, 1, nvp); @@ -261,9 +285,13 @@ static int polesurface(Draw_Interpretor&, int n, const char** a) occ::handle result; if (hasw) + { result = new Geom_BezierSurface(poles, weights); + } else + { result = new Geom_BezierSurface(poles); + } DrawTrSurf::Set(a[1], result); } @@ -308,13 +336,21 @@ static int polesurface(Draw_Interpretor&, int n, const char** a) int nup, nvp; if (uper) + { nup = SigmaU - umult(nbuk); + } else + { nup = SigmaU - udeg - 1; + } if (vper) + { nvp = SigmaV - vmult(nbvk); + } else + { nvp = SigmaV - vdeg - 1; + } NCollection_Array2 poles(1, nup, 1, nvp); NCollection_Array2 weights(1, nup, 1, nvp); @@ -343,11 +379,15 @@ static int polesurface(Draw_Interpretor&, int n, const char** a) static int algosurface(Draw_Interpretor&, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve(a[2]); if (GC.IsNull()) + { return 1; + } gp_Dir D; gp_Pnt P; @@ -362,7 +402,9 @@ static int algosurface(Draw_Interpretor&, int n, const char** a) else if (!strcasecmp(a[0], "revsurf")) { if (n < 8) + { return 1; + } P.SetCoord(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5])); D.SetCoord(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8])); @@ -379,7 +421,9 @@ static int algosurface(Draw_Interpretor&, int n, const char** a) static int trimming(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GC = DrawTrSurf::GetCurve(a[2]); occ::handle GC2d = DrawTrSurf::GetCurve2d(a[2]); @@ -391,14 +435,18 @@ static int trimming(Draw_Interpretor&, int n, const char** a) { occ::handle T = occ::down_cast(GC); if (!T.IsNull()) + { GC = T->BasisCurve(); + } DrawTrSurf::Set(a[1], GC); } else if (!GC2d.IsNull()) { occ::handle T = occ::down_cast(GC2d); if (!T.IsNull()) + { GC2d = T->BasisCurve(); + } DrawTrSurf::Set(a[1], GC2d); } else if (!GS.IsNull()) @@ -406,14 +454,18 @@ static int trimming(Draw_Interpretor&, int n, const char** a) occ::handle T = occ::down_cast(GS); if (!T.IsNull()) + { GS = T->BasisSurface(); + } DrawTrSurf::Set(a[1], GS); } return 0; } if (n < 5) + { return 1; + } double u1 = Draw::Atof(a[3]); double u2 = Draw::Atof(a[4]); @@ -429,7 +481,9 @@ static int trimming(Draw_Interpretor&, int n, const char** a) if (!GS.IsNull()) { if (n < 7) + { return 1; + } v1 = Draw::Atof(a[5]); v2 = Draw::Atof(a[6]); if (n > 7) @@ -456,22 +510,32 @@ static int trimming(Draw_Interpretor&, int n, const char** a) result2d = new Geom2d_TrimmedCurve(GC2d, u1, u2, USense); } else + { return 1; + } } else { if (GS.IsNull()) + { return 1; + } bool Utrim = !strcasecmp(a[0], "trimu"); if (n > 5) + { USense = *a[5] != '0'; + } result = new Geom_RectangularTrimmedSurface(GS, u1, u2, Utrim, USense); } if (!result.IsNull()) + { DrawTrSurf::Set(a[1], result); + } else + { DrawTrSurf::Set(a[1], result2d); + } return 0; } @@ -481,7 +545,9 @@ static int trimming(Draw_Interpretor&, int n, const char** a) static int converting(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2; if (strcmp(a[n - 1], "qa") == 0) @@ -550,7 +616,9 @@ static int converting(Draw_Interpretor&, int n, const char** a) static int tocanon(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } GeomConvert_ConvType aConvType = GeomConvert_Simplest; GeomAbs_CurveType aCurv = GeomAbs_Line; @@ -626,7 +694,9 @@ static int tocanon(Draw_Interpretor& di, int n, const char** a) GeomConvert_SurfToAnaSurf aSurfToAna(GS); aSurfToAna.SetConvType(aConvType); if (aConvType == GeomConvert_Target) + { aSurfToAna.SetTarget(aSurf); + } occ::handle anAnaSurf = aSurfToAna.ConvertToAnalytical(tol); if (!anAnaSurf.IsNull()) { @@ -635,7 +705,9 @@ static int tocanon(Draw_Interpretor& di, int n, const char** a) di << "Gap = " << aGap << "\n"; } else + { di << "Conversion failed" << "\n"; + } } } else @@ -643,7 +715,9 @@ static int tocanon(Draw_Interpretor& di, int n, const char** a) GeomConvert_CurveToAnaCurve aCurvToAna(GC); aCurvToAna.SetConvType(aConvType); if (aConvType == GeomConvert_Target) + { aCurvToAna.SetTarget(aCurv); + } occ::handle anAnaCurv; double tf = GC->FirstParameter(), tl = GC->LastParameter(), ntf, ntl; @@ -656,7 +730,9 @@ static int tocanon(Draw_Interpretor& di, int n, const char** a) di << "Gap = " << aGap << "\n"; } else + { di << "Conversion failed" << "\n"; + } } return 0; @@ -667,7 +743,9 @@ static int tocanon(Draw_Interpretor& di, int n, const char** a) static int tobezier(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } int i, j, NbU, NbV, NbArc; char* name = new char[100]; @@ -679,7 +757,9 @@ static int tobezier(Draw_Interpretor& di, int n, const char** a) { occ::handle S = DrawTrSurf::GetBSplineSurface(a[2]); if (S.IsNull()) + { return 1; + } if (n == 7) { double U1, U2, V1, V2; @@ -788,7 +868,9 @@ static int tobezier(Draw_Interpretor& di, int n, const char** a) static int convbz(Draw_Interpretor& di, int n, const char** a) { if (n < 4) + { return 1; + } int ii, jj, kk = 0, NbU, NbV; double Tol = Precision::Confusion(); @@ -807,6 +889,7 @@ static int convbz(Draw_Interpretor& di, int n, const char** a) NCollection_Array2> BZ(1, NbU, 1, NbV); kk = 4; for (jj = 1; jj <= NbV; jj++) + { for (ii = 1; ii <= NbU; ii++) { BZ(ii, jj) = occ::down_cast(DrawTrSurf::Get(a[kk])); @@ -817,8 +900,11 @@ static int convbz(Draw_Interpretor& di, int n, const char** a) } kk++; } + } if (kk < n) + { Tol = Draw::Atof(a[kk]); + } GeomConvert_CompBezierSurfacesToBSplineSurface Conv(BZ, Tol); @@ -888,50 +974,78 @@ static int approxsurf(Draw_Interpretor& di, int n, const char** a) int myPrec = 1; if (n > 10 || n < 3) + { return 1; + } if (n > 3) + { Tol = std::max(Draw::Atof(a[3]), 1.e-10); + } if (n == 5) + { return 1; + } if (n > 5) { if (Draw::Atoi(a[4]) == 0) + { myUCont = GeomAbs_C0; + } if (Draw::Atoi(a[4]) == 2) + { myUCont = GeomAbs_C2; + } if (Draw::Atoi(a[5]) == 0) + { myVCont = GeomAbs_C0; + } if (Draw::Atoi(a[5]) == 2) + { myVCont = GeomAbs_C2; + } } if (n == 7) + { return 1; + } if (n > 7) { (degU = (Draw::Atoi(a[6]))); (degV = (Draw::Atoi(a[7]))); if ((degU < 1) || (degU > 24)) + { degU = 14; + } if ((degV < 1) || (degV > 24)) + { degV = 14; + } } if (n > 8) + { nmax = Draw::Atoi(a[8]); + } if (n > 9) + { myPrec = Draw::Atoi(a[9]); + } occ::handle surf = DrawTrSurf::GetSurface(a[2]); if (surf.IsNull()) + { return 1; + } GeomConvert_ApproxSurface myApprox(surf, Tol, myUCont, myVCont, degU, degV, nmax, myPrec); if (myApprox.HasResult()) + { DrawTrSurf::Set(a[1], myApprox.Surface()); + } di << a[1] << "\n"; return 0; } @@ -941,7 +1055,9 @@ static int approxsurf(Draw_Interpretor& di, int n, const char** a) static int offseting(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } // test the Geom2d curve occ::handle C2d = DrawTrSurf::GetCurve2d(a[2]); @@ -960,7 +1076,9 @@ static int offseting(Draw_Interpretor&, int n, const char** a) { GS = DrawTrSurf::GetSurface(a[2]); if (GS.IsNull()) + { return 1; + } yasurf = true; } @@ -976,7 +1094,9 @@ static int offseting(Draw_Interpretor&, int n, const char** a) else { if (n < 7) + { return 1; + } gp_Dir D(Draw::Atof(a[4]), Draw::Atof(a[5]), Draw::Atof(a[6])); occ::handle GT = new Geom_OffsetCurve(GC, dist, D); result = GT; @@ -991,7 +1111,9 @@ static int offseting(Draw_Interpretor&, int n, const char** a) static int sreverse(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } int i; for (i = 1; i < n; i++) @@ -1001,9 +1123,13 @@ static int sreverse(Draw_Interpretor&, int n, const char** a) if (!GS.IsNull()) { if (*a[0] == 'u') + { GS->UReverse(); + } else + { GS->VReverse(); + } Draw::Repaint(); } } @@ -1016,7 +1142,9 @@ static int sreverse(Draw_Interpretor&, int n, const char** a) static int iso(Draw_Interpretor&, int n, const char** a) { if (n < 4) + { return 1; + } occ::handle C; double par = Draw::Atof(a[3]); @@ -1024,9 +1152,13 @@ static int iso(Draw_Interpretor&, int n, const char** a) if (!GS.IsNull()) { if (*a[0] == 'u') + { C = GS->UIso(par); + } else + { C = GS->VIso(par); + } DrawTrSurf::Set(a[1], C); } @@ -1038,18 +1170,24 @@ static int iso(Draw_Interpretor&, int n, const char** a) static int value(Draw_Interpretor&, int n, const char** a) { if (n < 5) + { return 1; + } occ::handle GS = DrawTrSurf::GetSurface(a[1]); if (GS.IsNull()) + { return 1; + } double U = Draw::Atof(a[2]); double V = Draw::Atof(a[3]); bool DrawPoint = (n % 3 == 2); if (DrawPoint) + { n--; + } gp_Pnt P; if (n >= 13) @@ -1070,7 +1208,9 @@ static int value(Draw_Interpretor&, int n, const char** a) Draw::Set(a[21], D2UV.Z()); } else + { GS->D1(U, V, P, DU, DV); + } Draw::Set(a[7], DU.X()); Draw::Set(a[8], DU.Y()); @@ -1080,7 +1220,9 @@ static int value(Draw_Interpretor&, int n, const char** a) Draw::Set(a[12], DV.Z()); } else + { GS->D0(U, V, P); + } if (n > 6) { @@ -1101,11 +1243,15 @@ static int value(Draw_Interpretor&, int n, const char** a) static int derivative(Draw_Interpretor&, int theArgc, const char** theArgv) { if (theArgc != 9) + { return 1; + } occ::handle aSurf = DrawTrSurf::GetSurface(theArgv[1]); if (aSurf.IsNull()) + { return 1; + } double aU = Draw::Atof(theArgv[2]); double aV = Draw::Atof(theArgv[3]); @@ -1126,7 +1272,9 @@ static int derivative(Draw_Interpretor&, int theArgc, const char** theArgv) static int movepole(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } bool BSpline = false; occ::handle GBz = DrawTrSurf::GetBezierSurface(a[1]); @@ -1164,11 +1312,15 @@ static int movepole(Draw_Interpretor&, int n, const char** a) if (!strcasecmp(a[0], "movep")) { if (n < 7) + { return 1; + } FirstRow = Draw::Atoi(a[2]); FirstCol = Draw::Atoi(a[3]); if (FirstRow < 1 || FirstRow > nup || FirstCol < 1 || FirstCol > nvp) + { return 1; + } LastRow = FirstRow; LastCol = FirstCol; } @@ -1176,7 +1328,9 @@ static int movepole(Draw_Interpretor&, int n, const char** a) { FirstRow = Draw::Atoi(a[2]); if (FirstRow < 1 || FirstRow > nup) + { return 1; + } LastRow = FirstRow; FirstCol = 1; LastCol = nvp; @@ -1185,7 +1339,9 @@ static int movepole(Draw_Interpretor&, int n, const char** a) { FirstCol = Draw::Atoi(a[2]); if (FirstCol < 1 || FirstCol > nvp) + { return 1; + } LastCol = FirstCol; FirstRow = 1; LastRow = nup; @@ -1222,7 +1378,9 @@ static int movepole(Draw_Interpretor&, int n, const char** a) static int movepoint(Draw_Interpretor&, int n, const char** a) { if (n < 7) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) @@ -1271,12 +1429,16 @@ static int movepoint(Draw_Interpretor&, int n, const char** a) static int insertknot(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) + { return 1; + } double knot = 0; int mult = 0; @@ -1284,7 +1446,9 @@ static int insertknot(Draw_Interpretor&, int n, const char** a) if (!strcasecmp(a[0], "insertuknot") || !strcasecmp(a[0], "insertvknot")) { if (n < 4) + { return 1; + } knot = Draw::Atof(a[2]); mult = Draw::Atoi(a[3]); } @@ -1292,7 +1456,9 @@ static int insertknot(Draw_Interpretor&, int n, const char** a) { index = Draw::Atoi(a[2]); if (n >= 4) + { mult = Draw::Atoi(a[3]); + } } double tol = RealLast(); @@ -1308,16 +1474,24 @@ static int insertknot(Draw_Interpretor&, int n, const char** a) else if (!strcasecmp(a[0], "remuknot")) { if (n >= 5) + { tol = Draw::Atof(a[4]); + } if (!GBs->RemoveUKnot(index, mult, tol)) + { return 1; + } } else if (!strcasecmp(a[0], "remvknot")) { if (n >= 5) + { tol = Draw::Atof(a[4]); + } if (!GBs->RemoveVKnot(index, mult, tol)) + { return 1; + } } Draw::Repaint(); @@ -1329,7 +1503,9 @@ static int insertknot(Draw_Interpretor&, int n, const char** a) static int incdegree(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } int NewDeg = Draw::Atoi(a[2]); bool BSpline = false; @@ -1343,7 +1519,9 @@ static int incdegree(Draw_Interpretor& di, int n, const char** a) { GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) + { return 1; + } BSpline = true; } @@ -1401,7 +1579,9 @@ static int incdegree(Draw_Interpretor& di, int n, const char** a) static int rempole(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } int NewIndex = Draw::Atoi(a[2]); bool BSpline = false; @@ -1413,7 +1593,9 @@ static int rempole(Draw_Interpretor& di, int n, const char** a) { GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) + { return 1; + } BSpline = true; } @@ -1449,7 +1631,9 @@ static int rempole(Draw_Interpretor& di, int n, const char** a) static int sfindp(Draw_Interpretor&, int n, const char** a) { if (n < 7) + { return 1; + } bool BSpline = false; occ::handle GBz = DrawTrSurf::GetBezierSurface(a[1]); @@ -1494,7 +1678,9 @@ static int sfindp(Draw_Interpretor&, int n, const char** a) static int ssetperiodic(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } int i; @@ -1554,7 +1740,9 @@ static int ssetperiodic(Draw_Interpretor&, int n, const char** a) static int exchuv(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } int i; for (i = 1; i < n; i++) @@ -1585,7 +1773,9 @@ static int exchuv(Draw_Interpretor&, int n, const char** a) static int segsur(Draw_Interpretor&, int n, const char** a) { if (n < 6 || n > 8) + { return 1; + } occ::handle GBz = DrawTrSurf::GetBezierSurface(a[1]); occ::handle GBs; @@ -1593,14 +1783,20 @@ static int segsur(Draw_Interpretor&, int n, const char** a) { GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) + { return 1; + } double aUTolerance = Precision::PConfusion(); double aVTolerance = Precision::PConfusion(); if (n >= 7) + { aUTolerance = aVTolerance = Draw::Atof(a[6]); + } if (n == 8) + { aVTolerance = Draw::Atof(a[7]); + } GBs->Segment(Draw::Atof(a[2]), Draw::Atof(a[3]), @@ -1663,7 +1859,7 @@ static int compBsplSur(Draw_Interpretor&, int n, const char** a) if (aDist > Precision::SquareConfusion()) { double aD = sqrt(aDist); - std::cout << "Surfaces differ for U,V,Dist: " << aU << " " << aV << " " << aD << std::endl; + std::cout << "Surfaces differ for U,V,Dist: " << aU << " " << aV << " " << aD << '\n'; } } } @@ -1677,11 +1873,15 @@ static int compBsplSur(Draw_Interpretor&, int n, const char** a) static int setuvorigin(Draw_Interpretor&, int n, const char** a) { if (n < 3) + { return 1; + } occ::handle GBs = DrawTrSurf::GetBSplineSurface(a[1]); if (GBs.IsNull()) + { return 1; + } if (!strcasecmp(a[0], "setuorigin")) { GBs->SetUOrigin(Draw::Atoi(a[2])); @@ -1691,7 +1891,9 @@ static int setuvorigin(Draw_Interpretor&, int n, const char** a) GBs->SetVOrigin(Draw::Atoi(a[2])); } else + { return 1; + } Draw::Repaint(); return 0; @@ -1790,7 +1992,9 @@ int bounds(Draw_Interpretor&, int n, const char** a) { // 2dcurve occ::handle C2d = DrawTrSurf::GetCurve2d(a[1]); if (C2d.IsNull()) + { return 1; + } U1 = C2d->FirstParameter(); U2 = C2d->LastParameter(); } @@ -1806,7 +2010,9 @@ int bounds(Draw_Interpretor&, int n, const char** a) { // compute on a Surface occ::handle S = DrawTrSurf::GetSurface(a[1]); if (S.IsNull()) + { return 1; + } S->Bounds(U1, U2, V1, V2); Draw::Set(a[2], U1); @@ -1824,7 +2030,9 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands) { static bool loaded = false; if (loaded) + { return; + } loaded = true; DrawTrSurf::BasicCommands(theCommands); diff --git a/src/Draw/TKTopTest/HLRTest/HLRTest.cxx b/src/Draw/TKTopTest/HLRTest/HLRTest.cxx index 2a36cf1482..98b3851227 100644 --- a/src/Draw/TKTopTest/HLRTest/HLRTest.cxx +++ b/src/Draw/TKTopTest/HLRTest/HLRTest.cxx @@ -49,7 +49,9 @@ bool HLRTest::GetProjector(const char*& Name, HLRAlgo_Projector& P) { occ::handle HP = occ::down_cast(Draw::Get(Name)); if (HP.IsNull()) + { return false; + } P = HP->Projector(); return true; } @@ -68,7 +70,9 @@ occ::handle HLRTest::GetOutLiner(const char*& Name) occ::handle D = Draw::Get(Name); occ::handle HS = occ::down_cast(D); if (!HS.IsNull()) + { return HS->OutLiner(); + } occ::handle HO; return HO; } @@ -78,7 +82,9 @@ occ::handle HLRTest::GetOutLiner(const char*& Name) static int hprj(Draw_Interpretor&, int n, const char** a) { if (n < 2) + { return 1; + } // gp_Ax2 anAx2 = gp::XOY(); if (n == 11) @@ -111,7 +117,9 @@ static int hprj(Draw_Interpretor&, int n, const char** a) static int hout(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } const char* name = a[2]; TopoDS_Shape S = DBRep::Get(name); if (S.IsNull()) @@ -129,9 +137,13 @@ static int hfil(Draw_Interpretor& di, int n, const char** a) { int nbIso = 0; if (n < 3) + { return 1; + } if (n > 3) + { nbIso = Draw::Atoi(a[3]); + } const char* name1 = a[1]; occ::handle HS = HLRTest::GetOutLiner(name1); if (HS.IsNull()) @@ -156,7 +168,9 @@ static int hfil(Draw_Interpretor& di, int n, const char** a) static int sori(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } const char* name1 = a[1]; const char* name2 = a[2]; occ::handle HS = HLRTest::GetOutLiner(name2); @@ -174,7 +188,9 @@ static int sori(Draw_Interpretor& di, int n, const char** a) static int sout(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } const char* name1 = a[1]; const char* name2 = a[2]; occ::handle HS = HLRTest::GetOutLiner(name2); @@ -197,7 +213,9 @@ static int sout(Draw_Interpretor& di, int n, const char** a) static int hloa(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } const char* name1 = a[1]; occ::handle HS = HLRTest::GetOutLiner(name1); if (HS.IsNull()) @@ -264,7 +282,9 @@ static int hrem(Draw_Interpretor& di, int n, const char** a) static int sprj(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } const char* name = a[1]; HLRAlgo_Projector P; if (!HLRTest::GetProjector(name, P)) @@ -306,9 +326,13 @@ static int hdbg(Draw_Interpretor& di, int, const char**) { hider->Debug(!hider->Debug()); if (hider->Debug()) + { di << "debug\n"; + } else + { di << "no debug\n"; + } return 0; } @@ -359,25 +383,45 @@ static int hres(Draw_Interpretor&, int n, const char** a) HI = HS.IsoLineHCompound(S); } if (!V.IsNull()) + { DBRep::Set("vl", V); + } if (!V1.IsNull()) + { DBRep::Set("v1l", V1); + } if (!VN.IsNull()) + { DBRep::Set("vnl", VN); + } if (!VO.IsNull()) + { DBRep::Set("vol", VO); + } if (!VI.IsNull()) + { DBRep::Set("vil", VI); + } if (!H.IsNull()) + { DBRep::Set("hl", H); + } if (!H1.IsNull()) + { DBRep::Set("h1l", H1); + } if (!HN.IsNull()) + { DBRep::Set("hnl", HN); + } if (!HO.IsNull()) + { DBRep::Set("hol", HO); + } if (!HI.IsNull()) + { DBRep::Set("hil", HI); + } return 0; } @@ -386,11 +430,15 @@ static int hres(Draw_Interpretor&, int n, const char** a) static int reflectlines(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } double anAISViewProjX = atof(a[3]); double anAISViewProjY = atof(a[4]); @@ -426,11 +474,15 @@ static int reflectlines(Draw_Interpretor&, int n, const char** a) static int hlrin3d(Draw_Interpretor&, int n, const char** a) { if (n < 6) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } double anAISViewProjX = atof(a[3]); double anAISViewProjY = atof(a[4]); @@ -461,13 +513,19 @@ static int hlrin3d(Draw_Interpretor&, int n, const char** a) TopoDS_Shape SharpEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Sharp, true, true); if (!SharpEdges.IsNull()) + { BB.Add(Result, SharpEdges); + } TopoDS_Shape OutLines = Reflector.GetCompoundOf3dEdges(HLRBRep_OutLine, true, true); if (!OutLines.IsNull()) + { BB.Add(Result, OutLines); + } TopoDS_Shape SmoothEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Rg1Line, true, true); if (!SmoothEdges.IsNull()) + { BB.Add(Result, SmoothEdges); + } DBRep::Set(a[1], Result); @@ -479,11 +537,15 @@ static int hlrin3d(Draw_Interpretor&, int n, const char** a) static int hlrin2d(Draw_Interpretor&, int n, const char** a) { if (n < 9) + { return 1; + } TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } double anAISViewProjX = atof(a[3]); double anAISViewProjY = atof(a[4]); @@ -517,13 +579,19 @@ static int hlrin2d(Draw_Interpretor&, int n, const char** a) TopoDS_Shape SharpEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Sharp, true, false); if (!SharpEdges.IsNull()) + { BB.Add(Result, SharpEdges); + } TopoDS_Shape OutLines = Reflector.GetCompoundOf3dEdges(HLRBRep_OutLine, true, false); if (!OutLines.IsNull()) + { BB.Add(Result, OutLines); + } TopoDS_Shape SmoothEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Rg1Line, true, false); if (!SmoothEdges.IsNull()) + { BB.Add(Result, SmoothEdges); + } DBRep::Set(a[1], Result); diff --git a/src/Draw/TKTopTest/HLRTest/HLRTest_DrawableEdgeTool.cxx b/src/Draw/TKTopTest/HLRTest/HLRTest_DrawableEdgeTool.cxx index 822dc0975a..8563d7a350 100644 --- a/src/Draw/TKTopTest/HLRTest/HLRTest_DrawableEdgeTool.cxx +++ b/src/Draw/TKTopTest/HLRTest/HLRTest_DrawableEdgeTool.cxx @@ -50,7 +50,9 @@ void HLRTest_DrawableEdgeTool::DrawOn(Draw_Display& D) const if (myViewId == D.ViewId()) { if (myIsoLine) + { InternalDraw(D, 1); + } InternalDraw(D, 2); InternalDraw(D, 3); } @@ -79,14 +81,20 @@ void HLRTest_DrawableEdgeTool::InternalDraw(Draw_Display& D, const int typ) cons for (ie = 1; ie <= ne; ie++) { if (ed->Selected() && !ed->Vertical()) + { ed->Used(false); + } else + { ed->Used(true); + } ed++; } for (int iface = 1; iface <= nf; iface++) + { DrawFace(D, typ, nCB, iface, e2, iCB, DS); + } if (typ >= 3) { @@ -129,15 +137,25 @@ void HLRTest_DrawableEdgeTool::DrawFace(Draw_Display& D, bool todraw; if ((!myRg1Line && !Itf.OutLine() && edf.Rg1Line()) || (!myRgNLine && !Itf.OutLine() && edf.RgNLine())) + { todraw = false; + } else if (typ == 1) + { todraw = Itf.IsoLine(); + } else if (typ == 2) + { todraw = Itf.OutLine() || Itf.Internal(); + } else + { todraw = !(Itf.IsoLine() || (Itf.OutLine() || Itf.Internal())); + } if (todraw) + { DrawEdge(D, true, typ, nCB, ie, e2, iCB, edf); + } edf.Used(true); } } @@ -156,7 +174,9 @@ void HLRTest_DrawableEdgeTool::DrawEdge(Draw_Display& D, { bool todraw = true; if (!inFace && ((!myRg1Line && ed.Rg1Line()) || (!myRgNLine && ed.RgNLine()))) + { todraw = false; + } if (todraw) { double sta, end; @@ -172,11 +192,17 @@ void HLRTest_DrawableEdgeTool::DrawEdge(Draw_Display& D, ShB.Bounds(v1, v2, e1, e2, f1, f2); occ::handle ShData = occ::down_cast(ShB.ShapeData()); if (typ == 1) + { D.SetColor(ShData->VisibleIsoColor()); + } else if (typ == 2) + { D.SetColor(ShData->VisibleOutLineColor()); + } else + { D.SetColor(ShData->VisibleColor()); + } iCB++; } @@ -209,11 +235,17 @@ void HLRTest_DrawableEdgeTool::DrawEdge(Draw_Display& D, ShB.Bounds(v1, v2, e1, e2, f1, f2); occ::handle ShData = occ::down_cast(ShB.ShapeData()); if (typ == 1) + { D.SetColor(ShData->HiddenIsoColor()); + } else if (typ == 2) + { D.SetColor(ShData->HiddenOutLineColor()); + } else + { D.SetColor(ShData->HiddenColor()); + } iCB++; } diff --git a/src/Draw/TKTopTest/HLRTest/HLRTest_DrawablePolyEdgeTool.cxx b/src/Draw/TKTopTest/HLRTest/HLRTest_DrawablePolyEdgeTool.cxx index 4c8c6788de..a435c22e39 100644 --- a/src/Draw/TKTopTest/HLRTest/HLRTest_DrawablePolyEdgeTool.cxx +++ b/src/Draw/TKTopTest/HLRTest/HLRTest_DrawablePolyEdgeTool.cxx @@ -129,7 +129,9 @@ void HLRTest_DrawablePolyEdgeTool::DrawOn(Draw_Display& D) const bool todraw = true; if ((!myDispRg1 && BP.Rg1Line() && !BP.OutLine()) || (!myDispRgN && BP.RgNLine() && !BP.OutLine())) + { todraw = false; + } if (todraw) { D.MoveTo(BP.P1()); @@ -145,7 +147,9 @@ void HLRTest_DrawablePolyEdgeTool::DrawOn(Draw_Display& D) const bool todraw = true; if ((!myDispRg1 && BP.Rg1Line() && !BP.OutLine()) || (!myDispRgN && BP.RgNLine() && !BP.OutLine())) + { todraw = false; + } if (todraw) { D.MoveTo(BP.P1()); @@ -165,7 +169,9 @@ void HLRTest_DrawablePolyEdgeTool::DrawOn(Draw_Display& D) const Coordinates = &myAlgo->Show(S, reg1, regn, outl, intl); bool todraw = true; if ((!myDispRg1 && reg1 && !outl) || (!myDispRgN && regn && !outl)) + { todraw = false; + } if (todraw) { D.MoveTo(gp_Pnt(PntX1, PntY1, PntZ1)); diff --git a/src/Draw/TKTopTest/HLRTest/HLRTest_OutLiner.cxx b/src/Draw/TKTopTest/HLRTest/HLRTest_OutLiner.cxx index afec0a9447..281fde1699 100644 --- a/src/Draw/TKTopTest/HLRTest/HLRTest_OutLiner.cxx +++ b/src/Draw/TKTopTest/HLRTest/HLRTest_OutLiner.cxx @@ -46,7 +46,7 @@ occ::handle HLRTest_OutLiner::Copy() const void HLRTest_OutLiner::Dump(Standard_OStream& S) const { - S << "This is an outliner" << std::endl; + S << "This is an outliner" << '\n'; } //================================================================================================= diff --git a/src/Draw/TKTopTest/HLRTest/HLRTest_Projector.cxx b/src/Draw/TKTopTest/HLRTest/HLRTest_Projector.cxx index e0b2afabe4..453f72a74c 100644 --- a/src/Draw/TKTopTest/HLRTest/HLRTest_Projector.cxx +++ b/src/Draw/TKTopTest/HLRTest/HLRTest_Projector.cxx @@ -46,7 +46,9 @@ void HLRTest_Projector::Dump(Standard_OStream& S) const { S << "Projector : \n"; if (myProjector.Perspective()) + { S << "perspective, focal = " << myProjector.Focus() << "\n"; + } for (int i = 1; i <= 3; i++) { @@ -57,7 +59,7 @@ void HLRTest_Projector::Dump(Standard_OStream& S) const } S << "\n"; } - S << std::endl; + S << '\n'; } //================================================================================================= diff --git a/src/Draw/TKTopTest/MeshTest/MeshTest.cxx b/src/Draw/TKTopTest/MeshTest/MeshTest.cxx index 6ed25632dc..aa3e5378bb 100644 --- a/src/Draw/TKTopTest/MeshTest/MeshTest.cxx +++ b/src/Draw/TKTopTest/MeshTest/MeshTest.cxx @@ -448,20 +448,28 @@ static int tessellate(Draw_Interpretor& /*di*/, int nbarg, const char** argv) if (std::abs(aPFirst.X() - aPLast.X()) < 0.1 * (aUMax - aUMin)) // U=const { if (BRep_Tool::IsClosed(anEdge, aFace)) + { B.UpdateEdge(anEdge, aUMinPoly, aUMaxPoly, aTriangulation); + } else + { B.UpdateEdge(anEdge, (aPFirst.X() < 0.5 * (aUMin + aUMax) ? aUMinPoly : aUMaxPoly), aTriangulation); + } } else // V=const { if (BRep_Tool::IsClosed(anEdge, aFace)) + { B.UpdateEdge(anEdge, aVMinPoly, aVMaxPoly, aTriangulation); + } else + { B.UpdateEdge(anEdge, (aPFirst.Y() < 0.5 * (aVMin + aVMax) ? aVMinPoly : aVMaxPoly), aTriangulation); + } } } @@ -1062,13 +1070,19 @@ static int trianglesinfo(Draw_Interpretor& theDI, int theNbArgs, const char** th static int veriftriangles(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } bool quiet = true; if (n == 3) + { quiet = false; + } TopoDS_Shape Sh = DBRep::Get(a[1]); if (Sh.IsNull()) + { return 1; + } TopExp_Explorer ex; occ::handle T; TopLoc_Location L; @@ -1096,9 +1110,13 @@ static int veriftriangles(Draw_Interpretor& di, int n, const char** a) for (i = 1; i <= T->NbTriangles(); i++) { if (F.Orientation() == TopAbs_REVERSED) + { T->Triangle(i).Get(n1, n3, n2); + } else + { T->Triangle(i).Get(n1, n2, n3); + } const gp_Pnt2d xy1 = T->UVNode(n1); const gp_Pnt2d xy2 = T->UVNode(n2); @@ -1204,12 +1222,16 @@ static int tri2d(Draw_Interpretor&, int n, const char** a) { if (n != 2) + { return 1; + } TopoDS_Shape aLocalShape = DBRep::Get(a[1]); TopoDS_Face F = TopoDS::Face(aLocalShape); // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1])); if (F.IsNull()) + { return 1; + } occ::handle T; TopLoc_Location L; @@ -1228,8 +1250,12 @@ static int tri2d(Draw_Interpretor&, int n, const char** a) { pc.Triangles(i, t[0], t[1], t[2]); for (j = 0; j < 3; j++) + { if (t[j] == 0) + { nFree++; + } + } } // allocate the arrays @@ -1297,11 +1323,15 @@ static int tri2d(Draw_Interpretor&, int n, const char** a) static int wavefront(Draw_Interpretor&, int nbarg, const char** argv) { if (nbarg < 2) + { return 1; + } TopoDS_Shape S = DBRep::Get(argv[1]); if (S.IsNull()) + { return 1; + } // creation du maillage s'il n'existe pas. @@ -1337,7 +1367,9 @@ static int wavefront(Draw_Interpretor&, int nbarg, const char** argv) aFile += ".obj"; } else + { aFile = "wave.obj"; + } FILE* outfile = OSD_OpenFile(aFile.ToCString(), "w"); fprintf(outfile, "%s %s\n%s %s\n\n", "# CASCADE ", "MATRA DATAVISION", "#", aFile.ToCString()); @@ -1384,7 +1416,9 @@ static int wavefront(Draw_Interpretor&, int nbarg, const char** argv) CSLib::Normal(D1U, D1V, D2U, D2V, D2UV, Precision::Angular(), OK, NStat, Nor); } if (F.Orientation() == TopAbs_REVERSED) + { Nor.Reverse(); + } fprintf(outfile, "%s %f %f %f\n", "vn", Nor.X(), Nor.Y(), Nor.Z()); } @@ -1400,9 +1434,13 @@ static int wavefront(Draw_Interpretor&, int nbarg, const char** argv) for (i = 1; i <= nbTriangles; i++) { if (F.Orientation() == TopAbs_REVERSED) + { Tr->Triangle(i).Get(n1, n3, n2); + } else + { Tr->Triangle(i).Get(n1, n2, n3); + } k1 = n1 + totalnodes; k2 = n2 + totalnodes; k3 = n3 + totalnodes; @@ -1426,13 +1464,17 @@ static int wavefront(Draw_Interpretor&, int nbarg, const char** argv) static int triedgepoints(Draw_Interpretor& di, int nbarg, const char** argv) { if (nbarg < 2) + { return 1; + } for (int i = 1; i < nbarg; i++) { TopoDS_Shape aShape = DBRep::Get(argv[i]); if (aShape.IsNull()) + { continue; + } occ::handle aPoly; occ::handle aT; @@ -1448,17 +1490,23 @@ static int triedgepoints(Draw_Interpretor& di, int nbarg, const char** argv) { TopExp_Explorer ex(aShape, TopAbs_EDGE); for (; ex.More(); ex.Next()) + { anEdgeMap.Add(ex.Current()); + } } if (anEdgeMap.Extent() == 0) + { continue; + } char newname[1024]; strcpy(newname, argv[i]); char* p = newname; while (*p != '\0') + { p++; + } *p = '_'; p++; @@ -1467,7 +1515,9 @@ static int triedgepoints(Draw_Interpretor& di, int nbarg, const char** argv) { BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(it.Key()), aPoly, aT, aLoc); if (aT.IsNull() || aPoly.IsNull()) + { continue; + } const NCollection_Array1& Indices = aPoly->Nodes(); const int nbnodes = Indices.Length(); @@ -1476,12 +1526,18 @@ static int triedgepoints(Draw_Interpretor& di, int nbarg, const char** argv) { gp_Pnt P3d = aT->Node(Indices[j]); if (!aLoc.IsIdentity()) + { P3d.Transform(aLoc.Transformation()); + } if (anEdgeMap.Extent() > 1) + { Sprintf(p, "%d_%d", nbEdge, j); + } else + { Sprintf(p, "%d", j); + } DBRep::Set(newname, BRepBuilderAPI_MakeVertex(P3d)); di.AppendElement(newname); } diff --git a/src/Draw/TKTopTest/MeshTest/MeshTest_CheckTopology.cxx b/src/Draw/TKTopTest/MeshTest/MeshTest_CheckTopology.cxx index 924626c3be..6a88b67239 100644 --- a/src/Draw/TKTopTest/MeshTest/MeshTest_CheckTopology.cxx +++ b/src/Draw/TKTopTest/MeshTest/MeshTest_CheckTopology.cxx @@ -65,7 +65,9 @@ void MeshTest_CheckTopology::Perform(Draw_Interpretor& di) const TopoDS_Edge& aEdge = TopoDS::Edge(aMapEF.FindKey(ie)); const NCollection_List& aFaces = aMapEF(ie); if (aFaces.Extent() < 2) + { continue; + } // get polygon on first face const TopoDS_Face& aFace1 = TopoDS::Face(aFaces.First()); @@ -158,11 +160,15 @@ void MeshTest_CheckTopology::Perform(Draw_Interpretor& di) occ::handle aPoly = BRep_Tool::PolygonOnTriangulation(aEdge, aT, aLoc); if (aPoly.IsNull()) + { continue; + } const NCollection_Array1& aNodes = aPoly->Nodes(); int i; for (i = aNodes.Lower(); i <= aNodes.Upper(); i++) + { aMapBndNodes.Add(aNodes(i)); + } } TColStd_PackedMapOfInteger aUsedNodes; @@ -210,7 +216,9 @@ void MeshTest_CheckTopology::Perform(Draw_Interpretor& di) int n2 = n[k]; // skip if it is on boundary if (aMapBndNodes.Contains(n1) && aMapBndNodes.Contains(n2)) + { continue; + } if (!myMapFaceLinks.Contains(iF)) { occ::handle> tmpSeq = new NCollection_HSequence; @@ -226,11 +234,13 @@ void MeshTest_CheckTopology::Perform(Draw_Interpretor& di) // check of free nodes int aNbNodes = aT->NbNodes(); for (int k = 1; k <= aNbNodes; k++) + { if (!aUsedNodes.Contains(k)) { myFreeNodeFaces.Append(iF); myFreeNodeNums.Append(k); } + } } } diff --git a/src/Draw/TKTopTest/MeshTest/MeshTest_Debug.cxx b/src/Draw/TKTopTest/MeshTest/MeshTest_Debug.cxx index 3222528f00..c681822556 100644 --- a/src/Draw/TKTopTest/MeshTest/MeshTest_Debug.cxx +++ b/src/Draw/TKTopTest/MeshTest/MeshTest_Debug.cxx @@ -38,15 +38,19 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the const occ::handle& aMeshData = *(occ::handle*)theDataStruct; if (aMeshData.IsNull()) + { return "Null mesh data structure"; + } int nbLinks = aMeshData->NbLinks(); - std::cout << "nblink=" << nbLinks << std::endl; + std::cout << "nblink=" << nbLinks << '\n'; TCollection_AsciiString aName(theNameStr); for (int i = 1; i <= nbLinks; i++) { const BRepMesh_Edge& aLink = aMeshData->GetLink(i); if (aLink.Movability() == BRepMesh_Deleted) + { continue; + } int n1 = aLink.FirstNode(); int n2 = aLink.LastNode(); const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1); @@ -81,15 +85,19 @@ Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* *(occ::handle*)theDataStruct; if (aMeshData.IsNull()) + { return "Null mesh data structure"; + } int nbElem = aMeshData->NbElements(); - std::cout << "nbelem=" << nbElem << std::endl; + std::cout << "nbelem=" << nbElem << '\n'; TCollection_AsciiString aName(theNameStr); for (int i = 1; i <= nbElem; i++) { const BRepMesh_Triangle& aTri = aMeshData->GetElement(i); if (aTri.Movability() == BRepMesh_Deleted) + { continue; + } int n[3]; aMeshData->ElementNodes(aTri, n); const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]); diff --git a/src/Draw/TKTopTest/MeshTest/MeshTest_PluginCommands.cxx b/src/Draw/TKTopTest/MeshTest/MeshTest_PluginCommands.cxx index adb6e7da43..e85552cd34 100644 --- a/src/Draw/TKTopTest/MeshTest/MeshTest_PluginCommands.cxx +++ b/src/Draw/TKTopTest/MeshTest/MeshTest_PluginCommands.cxx @@ -212,14 +212,20 @@ static int triarea(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape shape = DBRep::Get(a[1]); if (shape.IsNull()) + { return 1; + } double anEps = -1.; if (n > 2) + { anEps = Draw::Atof(a[2]); + } NCollection_IndexedMap aMapF; TopExp::MapShapes(shape, TopAbs_FACE, aMapF); @@ -250,7 +256,7 @@ static int triarea(Draw_Interpretor& di, int n, const char** a) occ::handle aPoly = BRep_Tool::Triangulation(aFace, aLoc); if (aPoly.IsNull()) { - std::cout << "face " << i << " has no triangulation" << std::endl; + std::cout << "face " << i << " has no triangulation" << '\n'; continue; } for (int j = 1; j <= aPoly->NbTriangles(); j++) @@ -273,9 +279,13 @@ static int triarea(Draw_Interpretor& di, int n, const char** a) // compute area by geometry GProp_GProps props; if (anEps <= 0.) + { BRepGProp::SurfaceProperties(shape, props); + } else + { BRepGProp::SurfaceProperties(shape, props, anEps); + } double aGeomArea = props.Mass(); di << aTriArea << " " << aGeomArea << "\n"; @@ -291,11 +301,15 @@ bool IsEqual(const BRepMesh_Edge& theFirst, const BRepMesh_Edge& theSecond) static int tricheck(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape shape = DBRep::Get(a[1]); if (shape.IsNull()) + { return 1; + } const bool isToFindSmallTriangles = (n >= 3) ? (strcmp(a[2], "-small") == 0) : false; diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW.cxx index 53e94268c4..439e4c53ec 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW.cxx @@ -72,7 +72,9 @@ static int LocSet(Draw_Interpretor& di, int argc, const char** argv) L = b.Location().Multiplied(c.Location().Inverted()); } else + { L = b.Location(); + } } a.Location(L); DBRep::Set(argv[1], a); diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeAnalysis.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeAnalysis.cxx index 618ad65120..417e57f532 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeAnalysis.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeAnalysis.cxx @@ -120,7 +120,9 @@ static int tolerance(Draw_Interpretor& di, int argc, const char** argv) char opt = argv[2][0]; TopAbs_ShapeEnum type = TopAbs_SHAPE; if (opt == 'a') + { nextarg = 3; + } else if (opt == 'c') { nextarg = 3; @@ -142,13 +144,19 @@ static int tolerance(Draw_Interpretor& di, int argc, const char** argv) type = TopAbs_VERTEX; } if (nextarg < 3) + { opt = 'a'; + } double tol1 = 0., tol2 = 0.; if (nextarg < argc) + { tol1 = Draw::Atof(argv[nextarg]); + } if (nextarg < argc - 1) + { tol2 = Draw::Atof(argv[nextarg + 1]); + } // double tol = Draw::Atof (argv[2]); occ::handle> list = sat.InTolerance(Shape, tol1, tol2, type); @@ -171,15 +179,25 @@ static int tolerance(Draw_Interpretor& di, int argc, const char** argv) di << "Analysing all sub-shapes gives "; } if (tol1 == 0) + { di << nb << " Shapes below tol=" << tol2; + } else if (tol2 == 0) + { di << nb << " Shapes over tol=" << tol1; + } else + { di << nb << " Shapes between tol1=" << tol1 << " and tol2=" << tol2; + } if (nb == 1) + { di << " , named tol_1"; + } if (nb > 1) + { di << " , named tol_1 to tol_" << nb; + } di << "\n"; char nomsh[30]; for (i = 1; i <= nb; i++) @@ -226,13 +244,21 @@ static int projface(Draw_Interpretor& di, int argc, const char** argv) thesurf->Bounds(uf, ul, vf, vl); if (Precision::IsInfinite(uf)) + { uf = -1000; + } if (Precision::IsInfinite(ul)) + { ul = 1000; + } if (Precision::IsInfinite(vf)) + { vf = -1000; + } if (Precision::IsInfinite(vl)) + { vl = 1000; + } double du = std::abs(ul - uf) / 10; double dv = std::abs(vl - vf) / 10; @@ -246,7 +272,9 @@ static int projface(Draw_Interpretor& di, int argc, const char** argv) proj.Parameters(sol, U, V); TopAbs_State aStatus = aClassifier.Perform(gp_Pnt2d(U, V)); if (aStatus == TopAbs_OUT) + { continue; + } anIndSol++; double aDist = proj.Distance(sol); @@ -279,7 +307,9 @@ static int projface(Draw_Interpretor& di, int argc, const char** argv) di << " Point UV U = " << U << " V = " << V << "\n"; TopAbs_State aStatus = aClassifier.Perform(gp_Pnt2d(U, V)); if (aStatus == TopAbs_OUT) + { di << "does not belong to the face" << "\n"; + } else { gp_Pnt P3D = thesurf->Value(U, V); @@ -465,9 +495,13 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) nbe = 0; di << "WIRE " << nbw; if (Wire.Orientation() == TopAbs_FORWARD) + { di << " (FWD)\n"; + } else + { di << " (REV)\n"; + } gp_Pnt fin, debut; gp_Pnt2d finuv, debuv; gp_XY baseuv; @@ -492,21 +526,31 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) di << "Wire " << nbw << ", Edge " << nbe; if (Edge.Orientation() == TopAbs_FORWARD) + { di << " (FWD"; + } else + { di << " (REV"; + } di << " , Tol= " << BRep_Tool::Tolerance(Edge) << " )\n"; double f3d, l3d, f2d, l2d; occ::handle curve3d = BRep_Tool::Curve(Edge, f3d, l3d); occ::handle curve2d; if (iasurf) + { curve2d = BRep_Tool::CurveOnSurface(Edge, Face, f2d, l2d); + } bool ia2d = !curve2d.IsNull(); iaw2d |= ia2d; if (!ia2d) + { di << "-- No PCurve\n"; + } if (curve3d.IsNull()) + { di << "-- no Curve 3d\n"; + } // On va tacher de calculer les positions et les comparer gp_Pnt2d fuv, luv; @@ -514,13 +558,17 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) { TopExp::Vertices(Edge, fv, lv); if (ia2d) + { BRep_Tool::UVPoints(Edge, Face, fuv, luv); + } } else { TopExp::Vertices(Edge, lv, fv); if (ia2d) + { BRep_Tool::UVPoints(Edge, Face, luv, fuv); + } } gp_Pnt fp = BRep_Tool::Pnt(fv); gp_Pnt lp = BRep_Tool::Pnt(lv); @@ -585,7 +633,9 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) maxvtx = std::max(maxvtx, dvtx); di << " Fin(" << nbe - 1 << ")-Debut(" << nbe << "): DISTANCE=" << dvtx; if (ia2d) + { di << " DeltaUV=" << duv; + } di << " Tol(Fin)=" << BRep_Tool::Tolerance(lv) << "\n"; } fin = lxyz; @@ -607,12 +657,16 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) } di << " Fin(" << nbe << ")-Debut(1): DISTANCE=" << dvtx; if (iaw2d) + { di << " DeltaUV=" << duv; + } di << " Tol(Fin)=" << BRep_Tool::Tolerance(lv) << "\n"; di << " Wire " << nbw << " Max : Dist.Vertex=" << maxvtx; if (iaw2d) + { di << " Ecart UV/3D=" << maxp3d << " DeltaUV=" << maxuv; + } di << "\n"; // Min Max if (iaw2d) @@ -624,34 +678,54 @@ static int anaface(Draw_Interpretor& di, int argc, const char** argv) GProp_GProps G; BRepGProp::SurfaceProperties(Face, G); if (G.Mass() > 0) + { di << "GProps:Mass Out\n"; + } else + { di << "GProps:Mass In\n"; + } /// return (G.Mass() > 0); BRepTopAdaptor_FClass2d fcl(Face, BRep_Tool::Tolerance(Face)); if (fcl.PerformInfinitePoint() == TopAbs_OUT) + { di << "Classifier Infinite : Out\n"; + } else + { di << "Classifier Infinite : In\n"; + } gp_Pnt2d pcl; pcl.SetCoord(umin - difu, vmin - difv); if (fcl.Perform(pcl) == TopAbs_OUT) + { di << "Classifier UMin-VMin : Out\n"; + } pcl.SetCoord(umin - difu, vmax + difv); if (fcl.Perform(pcl) == TopAbs_OUT) + { di << "Classifier UMin-VMax : Out\n"; + } pcl.SetCoord(umax + difu, vmin - difv); if (fcl.Perform(pcl) == TopAbs_OUT) + { di << "Classifier UMax-VMin : Out\n"; + } pcl.SetCoord(umax + difu, vmax + difv); if (fcl.Perform(pcl) == TopAbs_OUT) + { di << "Classifier UMax-VMax : Out\n"; + } } } if (ShapeAnalysis::IsOuterBound(Face)) + { di << "ShapeAnalysis: Outer Bound\n"; + } else + { di << "ShapeAnalysis: Not Outer Bound\n"; + } di << " Total " << nbw << " Wire(s)\n"; return 0; } @@ -667,9 +741,13 @@ static int XSHAPE_statshape(Draw_Interpretor& di, int argc, const char** argv) const char* arg2 = nullptr; const char* arg3 = nullptr; if (argc > 2) + { arg2 = argv[2]; + } if (argc > 3) + { arg3 = argv[3]; + } TopoDS_Shape Shape = DBRep::Get(arg1); if (Shape.IsNull()) { @@ -694,88 +772,144 @@ static int XSHAPE_statshape(Draw_Interpretor& di, int argc, const char** argv) di << "Count Item\n----- ----\n"; nb = analyzer.NbEdges(); if (nb > 0) + { di << nb << " EDGE (Oriented)\n"; + } nb = analyzer.NbSharedEdges(); if (nb > 0) + { di << nb << " EDGE (Shared)\n"; + } nb = analyzer.NbFreeEdges(); if (nb > 0) + { di << nb << " EDGE (Free)\n"; + } nb = analyzer.NbFaces(); if (nb > 0) + { di << nb << " FACE\n"; + } nb = analyzer.NbFreeFaces(); if (nb > 0) + { di << nb << " FACE (Free)\n"; + } nb = analyzer.NbFreeWires(); if (nb > 0) + { di << nb << " WIRE (Free)\n"; + } nb = analyzer.NbShells(); if (nb > 0) + { di << nb << " SHELL\n"; + } nb = analyzer.NbSolids(); if (nb > 0) + { di << nb << " SOLID\n"; + } nb = analyzer.NbVertices(); if (nb > 0) + { di << nb << " VERTEX (Oriented)\n"; + } nb = analyzer.NbSharedVertices(); if (nb > 0) + { di << nb << " VERTEX (Shared)\n"; + } nb = analyzer.NbWires(); if (nb > 0) + { di << nb << " WIRE\n"; + } nb = analyzer.NbFaceWithSevWires(); if (nb > 0) + { di << nb << " Face with more than one wire\n"; + } nb = analyzer.NbNoPCurve(); if (nb > 0) + { di << nb << " No pcurve\n"; + } nb = analyzer.NbSolidsWithVoids(); if (nb > 0) + { di << nb << " SOLID with voids\n"; + } nb = analyzer.NbWireWitnSeam(); if (nb > 0) + { di << nb << " Wire(s) with one seam edge\n"; + } nb = analyzer.NbWireWithSevSeams(); if (nb > 0) + { di << nb << " Wire(s) with several seam edges\n"; + } nb = analyzer.NbBigSplines(); if (nb > 0) + { di << nb << " bigspl : BSpline > 8192 poles\n"; + } nb = analyzer.NbBezierSurf(); if (nb > 0) + { di << nb << " bezsur : BezierSurface\n"; + } nb = analyzer.NbBSplibeSurf(); if (nb > 0) + { di << nb << " bspsur : BSplineSurface\n"; + } nb = analyzer.NbC0Curves(); if (nb > 0) + { di << nb << " c0curv : Curve Only C0\n"; + } nb = analyzer.NbC0Surfaces(); if (nb > 0) + { di << nb << " c0surf : Surface Only C0\n"; + } nb = analyzer.NbIndirectSurf(); if (nb > 0) + { di << nb << " indsur : Indirect Surface\n"; + } nb = analyzer.NbOffsetCurves(); if (nb > 0) + { di << nb << " ofcur : Offset Curve(s)\n"; + } nb = analyzer.NbOffsetSurf(); if (nb > 0) + { di << nb << " ofsur : Offset Surface\n"; + } nb = analyzer.NbTrimmedCurve2d(); if (nb > 0) + { di << nb << " trc2d : Trimmed Curve2d\n"; + } nb = analyzer.NbTrimmedCurve3d(); if (nb > 0) + { di << nb << " trc3d : Trimmed Curve3d\n"; + } nb = analyzer.NbTrimSurf(); if (nb > 0) + { di << nb << " trimsu : RectangularTrimmedSurface\n"; + } if (arg3 == nullptr) + { return 0; + } occ::handle> sec; if (analyzer.ModifyBigSplineMode()) @@ -864,12 +998,18 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) { nbpnts = Draw::Atoi(argv[2]); if (nbpnts < 2) + { nbpnts = 2; + } if (argc > 3) + { prefix = argv[3]; + } } else + { prefix = argv[2]; + } } int num = 0; @@ -900,14 +1040,18 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) edmax = edge; } if (min > tol) + { min = tol; + } if (relmax < rel) { relmax = rel; edmaxrel = edge; } if (relmin > rel) + { relmin = rel; + } } num++; } @@ -931,7 +1075,9 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) DBRep::Set(name, edmax); di << "Edge with max tolerance saved to " << name; if (edmax.IsSame(edmaxrel)) + { di << "\n"; + } else { Sprintf(name, "%.10s_edge_rel", prefix); @@ -948,7 +1094,9 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) if (edge.IsSame(edmax) || edge.IsSame(edmaxrel)) { if (!num1) + { di << "Concerned faces saved to shapes "; + } Sprintf(name, "%.10s_%d", prefix, num1 + 1); DBRep::Set(name, face); // std::cout << ( num1 ? ", " : "" ) << name; @@ -966,7 +1114,9 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) } } if (num1 > 0) + { di << "\n"; + } } return 0; } @@ -976,22 +1126,34 @@ static int XSHAPE_comptoledge(Draw_Interpretor& di, int argc, const char** argv) static int freebounds(Draw_Interpretor& di, int n, const char** a) { if ((n < 3) || (n > 5)) + { return 1; + } TopoDS_Shape shape = DBRep::Get(a[1]); if (shape.IsNull()) + { return 1; + } double toler = Draw::Atof(a[2]); bool splitclosed = false, splitopen = false; if (n > 3) + { splitclosed = Draw::Atoi(a[3]) != 0; + } if (n > 4) + { splitopen = Draw::Atoi(a[4]) != 0; + } ShapeAnalysis_FreeBounds F; if (toler <= 0) + { F = ShapeAnalysis_FreeBounds(shape, splitclosed, splitopen); + } else + { F = ShapeAnalysis_FreeBounds(shape, toler, splitclosed, splitopen); + } char name[100]; TopoDS_Shape wires = F.GetClosedWires(); @@ -1043,16 +1205,26 @@ static int FreeBoundsProps(Draw_Interpretor& di, int n, const char** a) double toler = 0.; bool splitclosed = false, splitopen = false; if (n > 2) + { toler = Draw::Atof(a[2]); + } if (n > 3) + { splitclosed = Draw::Atoi(a[3]) != 0; + } if (n > 4) + { splitopen = Draw::Atoi(a[4]) != 0; + } ShapeAnalysis_FreeBoundsProperties analyzer; if (toler > 0) + { analyzer.Init(source, toler, splitclosed, splitopen); + } else + { analyzer.Init(source, splitclosed, splitopen); + } analyzer.Perform(); TopoDS_Compound closed, open; BRep_Builder B; @@ -1100,22 +1272,34 @@ static int FreeBoundsProps(Draw_Interpretor& di, int n, const char** a) static int closefreebounds(Draw_Interpretor& di, int n, const char** a) { if ((n < 4) || (n > 6)) + { return 1; + } TopoDS_Shape shape = DBRep::Get(a[1]); if (shape.IsNull()) + { return 1; + } double sewtoler = Draw::Atof(a[2]), closetoler = Draw::Atof(a[3]); bool splitclosed = false, splitopen = false; if (n > 4) + { splitclosed = Draw::Atoi(a[3]) != 0; + } if (n > 5) + { splitopen = Draw::Atoi(a[4]) != 0; + } ShapeFix_FreeBounds F; if (sewtoler <= 0) + { F = ShapeFix_FreeBounds(shape, closetoler, splitclosed, splitopen); + } else + { F = ShapeFix_FreeBounds(shape, sewtoler, closetoler, splitclosed, splitopen); + } char name[100]; TopoDS_Shape wires = F.GetClosedWires(); @@ -1133,7 +1317,9 @@ static int closefreebounds(Draw_Interpretor& di, int n, const char** a) static int getareacontour(Draw_Interpretor& di, int n, const char** a) { if (n < 2) + { return 1; + } TopoDS_Shape shape = DBRep::Get(a[1]); if (shape.IsNull()) { @@ -1186,7 +1372,9 @@ static int checkselfintersection(Draw_Interpretor& di, int argc, const char** ar { BRepBuilderAPI_MakeFace mkFace(TopoDS::Wire(wire), true); if (mkFace.IsDone()) + { face = mkFace.Face(); + } else { di << "Can't make a face for the wire. Provide please a face for analysis.\n"; @@ -1198,9 +1386,13 @@ static int checkselfintersection(Draw_Interpretor& di, int argc, const char** ar bool result = analyser.CheckSelfIntersection(); if (result) + { di << "A self-intersecting wire.\n"; + } else + { di << "Not self-intersecting wire.\n"; + } return 0; } @@ -1276,7 +1468,9 @@ static int checkedge(Draw_Interpretor& di, int argc, const char** argv) } if (isOk) + { di << "Edge seems OK.\n"; + } return 0; } @@ -1299,7 +1493,9 @@ static int getanasurf(Draw_Interpretor& di, int n, const char** a) } TopoDS_Shape sh = DBRep::Get(a[2]); if (sh.IsNull()) + { return 1; + } TopAbs_ShapeEnum aShType = sh.ShapeType(); if (aShType != TopAbs_SHELL && aShType != TopAbs_FACE && aShType != TopAbs_EDGE && aShType != TopAbs_WIRE) @@ -1313,18 +1509,28 @@ static int getanasurf(Draw_Interpretor& di, int n, const char** a) if (n > 3) { if (strcmp(a[3], "pln") == 0) + { isurf = 0; + } else if (strcmp(a[3], "cyl") == 0) + { isurf = 1; + } else if (strcmp(a[3], "con") == 0) + { isurf = 2; + } else if (strcmp(a[3], "sph") == 0) + { isurf = 3; + } } double tol = 1.e-7; if (n > 4) + { tol = Draw::Atof(a[4]); + } // get sample target for edge and wire GeomAdaptor_Surface aSampleSurf; @@ -1352,33 +1558,49 @@ static int getanasurf(Draw_Interpretor& di, int n, const char** a) case GeomAbs_Plane: { gp_Pln aPln; if (aSampleSurf.GetType() == GeomAbs_Plane) + { aPln = aSampleSurf.Plane(); + } if (aCanonRec.IsPlane(tol, aPln)) + { aRes = new Geom_Plane(aPln); + } break; } case GeomAbs_Cylinder: { gp_Cylinder aCyl; if (aSampleSurf.GetType() == GeomAbs_Cylinder) + { aCyl = aSampleSurf.Cylinder(); + } if (aCanonRec.IsCylinder(tol, aCyl)) + { aRes = new Geom_CylindricalSurface(aCyl); + } break; } case GeomAbs_Cone: { gp_Cone aCon; if (aSampleSurf.GetType() == GeomAbs_Cone) + { aCon = aSampleSurf.Cone(); + } if (aCanonRec.IsCone(tol, aCon)) + { aRes = new Geom_ConicalSurface(aCon); + } break; } case GeomAbs_Sphere: { gp_Sphere aSph; if (aSampleSurf.GetType() == GeomAbs_Sphere) + { aSph = aSampleSurf.Sphere(); + } if (aCanonRec.IsSphere(tol, aSph)) + { aRes = new Geom_SphericalSurface(aSph); + } break; } default: @@ -1410,7 +1632,9 @@ int getanacurve(Draw_Interpretor& di, int n, const char** a) } TopoDS_Shape sh = DBRep::Get(a[2]); if (sh.IsNull()) + { return 1; + } TopAbs_ShapeEnum aShType = sh.ShapeType(); if (aShType != TopAbs_WIRE && aShType != TopAbs_EDGE) { @@ -1423,16 +1647,24 @@ int getanacurve(Draw_Interpretor& di, int n, const char** a) if (n > 3) { if (strcmp(a[3], "lin") == 0) + { icurv = 0; + } else if (strcmp(a[3], "cir") == 0) + { icurv = 1; + } else if (strcmp(a[3], "ell") == 0) + { icurv = 2; + } } double tol = Precision::Confusion(); if (n > 4) + { tol = Draw::Atof(a[4]); + } ShapeAnalysis_CanonicalRecognition aCanonRec(sh); occ::handle aRes; @@ -1441,19 +1673,25 @@ int getanacurve(Draw_Interpretor& di, int n, const char** a) case GeomAbs_Line: { gp_Lin aLin; if (aCanonRec.IsLine(tol, aLin)) + { aRes = new Geom_Line(aLin); + } break; } case GeomAbs_Circle: { gp_Circ aCirc; if (aCanonRec.IsCircle(tol, aCirc)) + { aRes = new Geom_Circle(aCirc); + } break; } case GeomAbs_Ellipse: { gp_Elips anElips; if (aCanonRec.IsEllipse(tol, anElips)) + { aRes = new Geom_Ellipse(anElips); + } break; } default: diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeCustom.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeCustom.cxx index e20332544d..145f209b23 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeCustom.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeCustom.cxx @@ -127,7 +127,9 @@ static int ckeckKnots(const NCollection_Array1& theKnots, double theFirs { double aDL = theKnots(i) - theLast; if (fabs(aDL) <= Precision::PConfusion() || aDL > Precision::PConfusion()) + { break; + } aNum++; } } @@ -143,7 +145,9 @@ static void expcurv2d(const occ::handle& aCurve, double theLast) { if (aCurve.IsNull()) + { return; + } if (aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { @@ -164,17 +168,25 @@ static void expcurv2d(const occ::handle& aCurve, { occ::handle Bs = occ::down_cast(aCurve); if (Bs->Degree() > Degree) + { Nb.ChangeValue(1, 1)++; + } if (Bs->NbKnots() - 1 > MaxSeg) + { Nb.ChangeValue(1, 2)++; + } if (Bs->IsRational()) + { Nb.ChangeValue(1, 3)++; + } if (aCont < theCont && Bs->NbKnots() > 2) { const NCollection_Array1& aKnots = Bs->Knots(); int nbInt = ckeckKnots(aKnots, theFirst, theLast); if (nbInt > 1) + { Nb.ChangeValue(1, 4)++; + } } return; } @@ -182,9 +194,13 @@ static void expcurv2d(const occ::handle& aCurve, { occ::handle Bs = occ::down_cast(aCurve); if (Bs->Degree() > Degree) + { Nb.ChangeValue(2, 1)++; + } if (Bs->IsRational()) + { Nb.ChangeValue(2, 3)++; + } if (aCont < theCont) { @@ -193,8 +209,9 @@ static void expcurv2d(const occ::handle& aCurve, return; } else + { Nb.ChangeValue(1, 5)++; - return; + } } static void expcurv(const occ::handle& aCurve, @@ -206,7 +223,9 @@ static void expcurv(const occ::handle& aCurve, double theLast) { if (aCurve.IsNull()) + { return; + } if (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { occ::handle tmp = occ::down_cast(aCurve); @@ -227,17 +246,25 @@ static void expcurv(const occ::handle& aCurve, { occ::handle Bs = occ::down_cast(aCurve); if (Bs->Degree() > Degree) + { Nb.ChangeValue(1, 1)++; + } if (Bs->NbKnots() - 1 > MaxSeg) + { Nb.ChangeValue(1, 2)++; + } if (Bs->IsRational()) + { Nb.ChangeValue(1, 3)++; + } if (aCont < theCont && Bs->NbKnots() > 2) { const NCollection_Array1& aKnots = Bs->Knots(); int nbInt = ckeckKnots(aKnots, theFirst, theLast); if (nbInt > 1) + { Nb.ChangeValue(1, 4)++; + } } return; } @@ -245,16 +272,23 @@ static void expcurv(const occ::handle& aCurve, { occ::handle Bs = occ::down_cast(aCurve); if (Bs->Degree() > Degree) + { Nb.ChangeValue(2, 1)++; + } if (Bs->IsRational()) + { Nb.ChangeValue(2, 3)++; + } if (aCont < theCont) + { Nb.ChangeValue(2, 4)++; + } return; } else + { Nb.ChangeValue(1, 5)++; - return; + } } static void expsurf(const occ::handle& aSurface, @@ -264,7 +298,9 @@ static void expsurf(const occ::handle& aSurface, const int theCont) { if (aSurface.IsNull()) + { return; + } if (aSurface->IsKind(STANDARD_TYPE(Geom_SweptSurface))) { occ::handle aSurf = occ::down_cast(aSurface); @@ -299,24 +335,38 @@ static void expsurf(const occ::handle& aSurface, { occ::handle BS = occ::down_cast(aSurface); if (BS->UDegree() > Degree || BS->VDegree() > Degree) + { NbSurf.ChangeValue(1, 1)++; + } if (((BS->NbUKnots() - 1) * (BS->NbVKnots() - 1)) > MaxSeg) + { NbSurf.ChangeValue(1, 2)++; + } if (BS->IsURational() || BS->IsVRational()) + { NbSurf.ChangeValue(1, 3)++; + } if (aCont < theCont) + { NbSurf.ChangeValue(1, 4)++; + } return; } if (aSurface->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { occ::handle BS = occ::down_cast(aSurface); if (BS->UDegree() > Degree || BS->VDegree() > Degree) + { NbSurf.ChangeValue(2, 1)++; + } if (BS->IsURational() || BS->IsVRational()) + { NbSurf.ChangeValue(2, 3)++; + } if (aCont < theCont) + { NbSurf.ChangeValue(2, 4)++; + } return; } if (aSurface->IsKind(STANDARD_TYPE(Geom_Plane))) @@ -324,7 +374,9 @@ static void expsurf(const occ::handle& aSurface, NbSurf.ChangeValue(1, 5)++; } else + { NbSurf.ChangeValue(2, 5)++; + } } static int expshape(Draw_Interpretor& di, int argc, const char** argv) @@ -343,19 +395,33 @@ static int expshape(Draw_Interpretor& di, int argc, const char** argv) if (argc > k) { if (strcmp(argv[k], "C0") == 0) + { aCont3 = GeomAbs_C0; + } else if (strcmp(argv[k], "C1") == 0) + { aCont3 = GeomAbs_C1; + } else if (strcmp(argv[k], "C2") == 0) + { aCont3 = GeomAbs_C2; + } else if (strcmp(argv[k], "C3") == 0) + { aCont3 = GeomAbs_C3; + } else if (strcmp(argv[k], "CN") == 0) + { aCont3 = GeomAbs_CN; + } else if (strcmp(argv[k], "G1") == 0) + { aCont3 = GeomAbs_C0; + } else if (strcmp(argv[k], "G2") == 0) + { aCont3 = GeomAbs_C1; + } else { di << "Invalid argument Cont3e\n"; @@ -392,7 +458,9 @@ static int expshape(Draw_Interpretor& di, int argc, const char** argv) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); if (BRep_Tool::IsClosed(E, F)) + { nbSeam++; + } double First, Last; occ::handle aCurve = BRep_Tool::Curve(E, L, First, Last); expcurv(aCurve, NbCurv, Degree, MaxSeg, aCont, First, Last); @@ -517,19 +585,33 @@ static int BSplRes(Draw_Interpretor& di, int argc, const char** argv) } GeomAbs_Shape aCont3; if (strcmp(argv[7], "C0") == 0) + { aCont3 = GeomAbs_C0; + } else if (strcmp(argv[7], "C1") == 0) + { aCont3 = GeomAbs_C1; + } else if (strcmp(argv[7], "C2") == 0) + { aCont3 = GeomAbs_C2; + } else if (strcmp(argv[7], "C3") == 0) + { aCont3 = GeomAbs_C3; + } else if (strcmp(argv[7], "CN") == 0) + { aCont3 = GeomAbs_CN; + } else if (strcmp(argv[7], "G1") == 0) + { aCont3 = GeomAbs_C0; + } else if (strcmp(argv[7], "G2") == 0) + { aCont3 = GeomAbs_C1; + } else { di << "Invalid argument Cont3e\n"; @@ -537,19 +619,33 @@ static int BSplRes(Draw_Interpretor& di, int argc, const char** argv) } GeomAbs_Shape aCont2; if (strcmp(argv[8], "C0") == 0) + { aCont2 = GeomAbs_C0; + } else if (strcmp(argv[8], "C1") == 0) + { aCont2 = GeomAbs_C1; + } else if (strcmp(argv[8], "C2") == 0) + { aCont2 = GeomAbs_C2; + } else if (strcmp(argv[8], "C3") == 0) + { aCont2 = GeomAbs_C3; + } else if (strcmp(argv[8], "CN") == 0) + { aCont2 = GeomAbs_CN; + } else if (strcmp(argv[8], "G1") == 0) + { aCont2 = GeomAbs_C0; + } else if (strcmp(argv[8], "G2") == 0) + { aCont2 = GeomAbs_C1; + } else { di << "Invalid argument Cont3e\n"; diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeExtend.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeExtend.cxx index 857358ef84..b10fd63f32 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeExtend.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeExtend.cxx @@ -83,7 +83,9 @@ static int sortcompound(Draw_Interpretor& di, int argc, const char** argv) case TopAbs_COMPOUND: di << "COMPOUND"; if (i > 0) + { di << " (heterogeneous)"; + } break; } } diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeFix.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeFix.cxx index c7fb82ed8f..c1df8bb0a5 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeFix.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeFix.cxx @@ -77,7 +77,9 @@ static int edgesameparam(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape Shape = DBRep::Get(argv[1]); if (!ShapeFix::SameParameter(Shape, (argc > 2 && arg2[0] == 'f'), BRepBuilderAPI::Precision())) + { di << "Some edges were not processed\n"; + } di << "\n"; return 0; // Done } @@ -135,7 +137,9 @@ static int settolerance(Draw_Interpretor& di, int argc, const char** argv) double tmin, tmax; mod2 = argv[premarg][0]; if (mod2 == '=') + { tmin = tmax = Draw::Atof(argv[argc - 1]); + } else if (mod2 == '<') { tmin = 0; @@ -153,13 +157,21 @@ static int settolerance(Draw_Interpretor& di, int argc, const char** argv) } if (argc == premarg + 1 || tmin == tmax) + { di << "Setting Tolerance to " << tmin << "\n"; + } else if (tmax < tmin) + { di << "Minimum Tolerance to " << tmin << "\n"; + } else if (tmin <= 0) + { di << "Maximum Tolerance to " << tmax << "\n"; + } else + { di << "Tolerance Limited between " << tmin << " and " << tmax << "\n"; + } ShapeFix_ShapeTolerance sat; sat.LimitTolerance(Shape, tmin, tmax, styp); return 0; // Done @@ -196,7 +208,9 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) int valopt = 1; char opt = argv[i][0]; if (opt == '+') + { opt = argv[i][1]; + } if (opt == '-') { opt = argv[i][1]; @@ -248,7 +262,9 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) saw->SetFace(TopoDS::Face(Shape)); TopExp_Explorer expw(Shape, TopAbs_WIRE); if (expw.More()) + { awire = expw.Current(); + } saw->SetPrecision(BRepBuilderAPI::Precision()); } if (awire.IsNull()) @@ -267,9 +283,13 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) int orient = saw->CheckShapeConnect(E); di << "Orientation : " << orient << " LowerDist : " << saw->MinDistance3d() << "\n"; if (ox) + { sbwd->AddOriented(E, orient); + } else + { sbwd->Add(E); + } } // } // else sbwd->Init (awire); @@ -296,7 +316,9 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) di << " done"; } if (sfw->LastFixStatus(ShapeExtend_FAIL)) + { di << " (failed)"; + } di << "\n"; } } @@ -314,9 +336,13 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) int iord = WO.Ordered(i); di << "Edge n0 " << i; if (sbwd->Edge(iord).Orientation() == TopAbs_REVERSED) + { di << " REV"; + } else + { di << " FWD"; + } di << " ordered to " << iord << " Gap=" << WO.Gap(i) << "\n"; } di << "Reorder not yet done\n"; @@ -335,28 +361,48 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Edge E = sbwd->Edge(i); di << "Edge " << i; if (E.Orientation() == TopAbs_REVERSED) + { di << " REV"; + } else + { di << " FWD"; + } if (BRep_Tool::Degenerated(E)) + { di << " DGNR"; + } if (sbwd->IsSeam(i)) + { di << " SEAM_WIRE"; + } if (Shape.ShapeType() == TopAbs_FACE && sae.IsSeam(E, TopoDS::Face(Shape))) + { di << " SEAM_FACE"; + } if (Shape.ShapeType() == TopAbs_FACE) { if (sae.HasPCurve(E, TopoDS::Face(Shape))) + { di << " PCU"; + } else + { di << " NO_PCU"; + } } if (sae.HasCurve3d(E)) + { di << " C3D"; + } else + { di << " NO_C3D"; + } if (sae.IsClosed3d(E)) + { di << " CLOSED"; + } di << "\n"; } } @@ -402,7 +448,9 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) di << "Disjoined\n"; } if (stat >= 3 && stat <= 5) + { di << "\n - Position : " << pos.X() << " " << pos.Y() << " " << pos.Z() << "\n"; + } } ShapeFix_WireVertex sfwv; sfwv.Init(sawv); @@ -434,9 +482,13 @@ static int stwire(Draw_Interpretor& di, int argc, const char** argv) } */ else if (om) + { result = sbwd->WireAPIMake(); + } else + { result = sbwd->Wire(); + } if (result.IsNull()) { di << "Pas de resultat, desole\n"; @@ -474,7 +526,9 @@ static int reface(Draw_Interpretor& di, int argc, const char** argv) bool valopt = true; char opt = argv[i][0]; if (opt == '+') + { opt = argv[i][1]; + } if (opt == '-') { opt = argv[i][1]; @@ -540,7 +594,9 @@ static int reface(Draw_Interpretor& di, int argc, const char** argv) return 0; // Done } else + { di << "ShapeFix_Face n a rien trouve a redire\n"; + } return 0; } @@ -620,7 +676,9 @@ static int fixshape(Draw_Interpretor& di, int argc, const char** argv) case 1: { TopoDS_Shape initShape = DBRep::Get(argv[i]); if (initShape.IsNull()) + { continue; + } sfs->Init(initShape); } break; @@ -722,7 +780,9 @@ static int fixshape(Draw_Interpretor& di, int argc, const char** argv) int fixgaps(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) @@ -748,7 +808,9 @@ int fixgaps(Draw_Interpretor& di, int n, const char** a) int fixsmall(Draw_Interpretor& di, int n, const char** a) { if (n < 3) + { return 1; + } TopoDS_Shape S = DBRep::Get(a[2]); if (S.IsNull()) @@ -786,13 +848,19 @@ static int fixsmalledges(Draw_Interpretor& di, int n, const char** a) int mode = 2; double tolang = M_PI / 2; if (n > k) + { tol = Draw::Atof(a[k++]); + } if (n > k) + { mode = Draw::Atoi(a[k++]); + } if (n > k) + { tolang = Draw::Atof(a[k++]); + } occ::handle aSfwr = new ShapeFix_Wireframe(); occ::handle aReShape = new ShapeBuild_ReShape; @@ -801,7 +869,9 @@ static int fixsmalledges(Draw_Interpretor& di, int n, const char** a) aSfwr->SetPrecision(tol); bool aModeDrop = true; if (mode == 2) + { aModeDrop = false; + } NCollection_Map theSmallEdges, theMultyEdges; NCollection_DataMap, TopTools_ShapeMapHasher> @@ -893,15 +963,21 @@ static int checkoverlapedges(Draw_Interpretor& di, int n, const char** a) double aDistDomain = 0.0; int k = 3; if (k < n) + { aTol = Draw::Atof(a[k++]); + } if (k < n) + { aDistDomain = Draw::Atof(a[k++]); + } ShapeAnalysis_Edge sae; if (sae.CheckOverlapping(e1, e2, aTol, aDistDomain)) { if (aDistDomain == 0.0) + { di << "Edges are overlapping completely\n"; + } else { di << "Edges are overlapped\n"; @@ -910,7 +986,9 @@ static int checkoverlapedges(Draw_Interpretor& di, int n, const char** a) } } else + { di << "Edges are not overlapped\n"; + } return 0; } @@ -942,13 +1020,21 @@ static int checkfclass2d(Draw_Interpretor& di, int n, const char** a) BRepTopAdaptor_FClass2d f2d(aFace, tol); TopAbs_State stat = f2d.Perform(p2d); if (stat == TopAbs_OUT) + { di << "Point is OUT\n"; + } else if (stat == TopAbs_IN) + { di << "Point is IN\n"; + } else if (stat == TopAbs_ON) + { di << "Point is ON\n"; + } else + { di << "Point is UNKNOWN\n"; + } return 0; } @@ -967,11 +1053,15 @@ static int connectedges(Draw_Interpretor& di, int n, const char** a) } double aTol = Precision::Confusion(); if (n > 3) + { aTol = Draw::Atof(a[3]); + } bool shared = true; if (n > 4) + { shared = (Draw::Atoi(a[4]) == 1); + } TopExp_Explorer aExpE(aSh1, TopAbs_EDGE); occ::handle> aSeqEdges = new NCollection_HSequence; diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcess.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcess.cxx index d18456f838..b8a61f223d 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcess.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcess.cxx @@ -37,7 +37,9 @@ static int ApplySequence(Draw_Interpretor& di, int argc, const char** argv) const char* arg3 = argv[3]; const char* arg4 = ""; if (argc > 4) + { arg4 = argv[4]; + } TopoDS_Shape Shape = DBRep::Get(arg2); if (Shape.IsNull()) { diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcessAPI.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcessAPI.cxx index 98e91ad6de..f00b1098b4 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcessAPI.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeProcessAPI.cxx @@ -35,7 +35,9 @@ static int ApplySequence(Draw_Interpretor& di, int argc, const char** argv) const char* arg3 = argv[3]; const char* arg4 = ""; if (argc > 4) + { arg4 = argv[4]; + } TopoDS_Shape Shape = DBRep::Get(arg2); if (Shape.IsNull()) { diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeTool.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeTool.cxx index ceaef2263e..8908ed1dcf 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeTool.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeTool.cxx @@ -72,7 +72,9 @@ static int XSHAPE_edge(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Edge Edge = TopoDS::Edge(exp.Current()); nbe++; if (BRep_Tool::Degenerated(Edge)) + { continue; + } occ::handle curve3d = BRep_Tool::Curve(Edge, f3d, l3d); if (curve3d.IsNull()) { @@ -120,27 +122,37 @@ static int XSHAPE_explorewire(Draw_Interpretor& di, int argc, const char** argv) for (TopoDS_Iterator ext(W); ext.More(); ext.Next()) { if (ext.Value().ShapeType() != TopAbs_EDGE) + { continue; + } TopoDS_Edge E = TopoDS::Edge(ext.Value()); nbe++; num = map.Add(E); } int* nbs = new int[nbe + 1]; for (i = 0; i <= nbe; i++) + { nbs[i] = 0; + } di << "TopoDS_Iterator(EDGE) donne " << nbe << " Edges dont " << num << " distinctes\n"; nbe = num; nbw = 0; for (TopExp_Explorer exe(W.Oriented(TopAbs_FORWARD), TopAbs_EDGE); exe.More(); exe.Next()) + { nbw++; + } di << "TopExp_Explorer(EDGE) donne " << nbw << " Edges\n"; nbw = 0; BRepTools_WireExplorer bwe; if (F.IsNull()) + { bwe.Init(W); + } else + { bwe.Init(W, F); + } for (; bwe.More(); bwe.Next()) { TopoDS_Edge E = TopoDS::Edge(bwe.Current()); @@ -151,7 +163,9 @@ static int XSHAPE_explorewire(Draw_Interpretor& di, int argc, const char** argv) di << "BRepTools_WireExplorer donne " << nbw << " Edges\n"; di << "Par rapport a la map, edges sautees par WE en NOWE_num, passees > 1 fois en MULTWE_num\n"; if (nbs[0] > 0) + { di << "NB : Edge n0 0 comptee " << nbs[0] << " fois\n"; + } for (i = 1; i <= nbe; i++) { if (nbs[i] < 1) diff --git a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeUpgrade.cxx b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeUpgrade.cxx index 44640b84a3..f8ec5d39b4 100644 --- a/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeUpgrade.cxx +++ b/src/Draw/TKTopTest/SWDRAW/SWDRAW_ShapeUpgrade.cxx @@ -118,39 +118,73 @@ static int DT_ShapeDivide(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape res = tool.Result(); if (tool.Status(ShapeExtend_OK)) + { di << "Status: OK\n"; + } if (tool.Status(ShapeExtend_DONE1)) + { di << "Status: DONE1\n"; + } if (tool.Status(ShapeExtend_DONE2)) + { di << "Status: DONE2\n"; + } if (tool.Status(ShapeExtend_DONE3)) + { di << "Status: DONE3\n"; + } if (tool.Status(ShapeExtend_DONE4)) + { di << "Status: DONE4\n"; + } if (tool.Status(ShapeExtend_DONE5)) + { di << "Status: DONE5\n"; + } if (tool.Status(ShapeExtend_DONE6)) + { di << "Status: DONE6\n"; + } if (tool.Status(ShapeExtend_DONE7)) + { di << "Status: DONE7\n"; + } if (tool.Status(ShapeExtend_DONE8)) + { di << "Status: DONE8\n"; + } if (tool.Status(ShapeExtend_FAIL1)) + { di << "Status: FAIL1\n"; + } if (tool.Status(ShapeExtend_FAIL2)) + { di << "Status: FAIL2\n"; + } if (tool.Status(ShapeExtend_FAIL3)) + { di << "Status: FAIL3\n"; + } if (tool.Status(ShapeExtend_FAIL4)) + { di << "Status: FAIL4\n"; + } if (tool.Status(ShapeExtend_FAIL5)) + { di << "Status: FAIL5\n"; + } if (tool.Status(ShapeExtend_FAIL6)) + { di << "Status: FAIL6\n"; + } if (tool.Status(ShapeExtend_FAIL7)) + { di << "Status: FAIL7\n"; + } if (tool.Status(ShapeExtend_FAIL8)) + { di << "Status: FAIL8\n"; + } // fixes @@ -189,59 +223,103 @@ static int DT_ShapeConvertRev(Draw_Interpretor& di, int n, const char** a) di << "No modif\n"; } else + { di << "ConvertToRevolution -> Result : \n"; + } ShapeUpgrade_ShapeConvertToBezier tool(revsh); tool.SetSurfaceConversion(true); if (c2d) + { tool.Set2dConversion(true); + } if (c3d) { tool.Set3dConversion(true); if (n > 5) + { tool.Set3dLineConversion(false); + } if (n > 6) + { tool.Set3dCircleConversion(false); + } if (n > 7) + { tool.Set3dConicConversion(false); + } } tool.Perform(); TopoDS_Shape res = tool.Result(); if (tool.Status(ShapeExtend_OK)) + { di << "Status: OK\n"; + } if (tool.Status(ShapeExtend_DONE1)) + { di << "Status: DONE1\n"; + } if (tool.Status(ShapeExtend_DONE2)) + { di << "Status: DONE2\n"; + } if (tool.Status(ShapeExtend_DONE3)) + { di << "Status: DONE3\n"; + } if (tool.Status(ShapeExtend_DONE4)) + { di << "Status: DONE4\n"; + } if (tool.Status(ShapeExtend_DONE5)) + { di << "Status: DONE5\n"; + } if (tool.Status(ShapeExtend_DONE6)) + { di << "Status: DONE6\n"; + } if (tool.Status(ShapeExtend_DONE7)) + { di << "Status: DONE7\n"; + } if (tool.Status(ShapeExtend_DONE8)) + { di << "Status: DONE8\n"; + } if (tool.Status(ShapeExtend_FAIL1)) + { di << "Status: FAIL1\n"; + } if (tool.Status(ShapeExtend_FAIL2)) + { di << "Status: FAIL2\n"; + } if (tool.Status(ShapeExtend_FAIL3)) + { di << "Status: FAIL3\n"; + } if (tool.Status(ShapeExtend_FAIL4)) + { di << "Status: FAIL4\n"; + } if (tool.Status(ShapeExtend_FAIL5)) + { di << "Status: FAIL5\n"; + } if (tool.Status(ShapeExtend_FAIL6)) + { di << "Status: FAIL6\n"; + } if (tool.Status(ShapeExtend_FAIL7)) + { di << "Status: FAIL7\n"; + } if (tool.Status(ShapeExtend_FAIL8)) + { di << "Status: FAIL8\n"; + } // fixes @@ -446,46 +524,84 @@ static int DT_ShapeConvert(Draw_Interpretor& di, int n, const char** a) ShapeUpgrade_ShapeConvertToBezier tool(inputShape); tool.SetSurfaceConversion(true); if (c2d) + { tool.Set2dConversion(true); + } if (c3d) + { tool.Set3dConversion(true); + } tool.Perform(); TopoDS_Shape res = tool.Result(); if (tool.Status(ShapeExtend_OK)) + { di << "Status: OK\n"; + } if (tool.Status(ShapeExtend_DONE1)) + { di << "Status: DONE1\n"; + } if (tool.Status(ShapeExtend_DONE2)) + { di << "Status: DONE2\n"; + } if (tool.Status(ShapeExtend_DONE3)) + { di << "Status: DONE3\n"; + } if (tool.Status(ShapeExtend_DONE4)) + { di << "Status: DONE4\n"; + } if (tool.Status(ShapeExtend_DONE5)) + { di << "Status: DONE5\n"; + } if (tool.Status(ShapeExtend_DONE6)) + { di << "Status: DONE6\n"; + } if (tool.Status(ShapeExtend_DONE7)) + { di << "Status: DONE7\n"; + } if (tool.Status(ShapeExtend_DONE8)) + { di << "Status: DONE8\n"; + } if (tool.Status(ShapeExtend_FAIL1)) + { di << "Status: FAIL1\n"; + } if (tool.Status(ShapeExtend_FAIL2)) + { di << "Status: FAIL2\n"; + } if (tool.Status(ShapeExtend_FAIL3)) + { di << "Status: FAIL3\n"; + } if (tool.Status(ShapeExtend_FAIL4)) + { di << "Status: FAIL4\n"; + } if (tool.Status(ShapeExtend_FAIL5)) + { di << "Status: FAIL5\n"; + } if (tool.Status(ShapeExtend_FAIL6)) + { di << "Status: FAIL6\n"; + } if (tool.Status(ShapeExtend_FAIL7)) + { di << "Status: FAIL7\n"; + } if (tool.Status(ShapeExtend_FAIL8)) + { di << "Status: FAIL8\n"; + } // fixes @@ -515,7 +631,9 @@ static int DT_SplitAngle(Draw_Interpretor& di, int n, const char** a) { maxangle = Draw::Atof(a[3]); if (maxangle < 1) + { maxangle = 1; + } } ShapeUpgrade_ShapeDivideAngle tool(maxangle * M_PI / 180, inputShape); @@ -523,39 +641,73 @@ static int DT_SplitAngle(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape res = tool.Result(); if (tool.Status(ShapeExtend_OK)) + { di << "Status: OK\n"; + } if (tool.Status(ShapeExtend_DONE1)) + { di << "Status: DONE1\n"; + } if (tool.Status(ShapeExtend_DONE2)) + { di << "Status: DONE2\n"; + } if (tool.Status(ShapeExtend_DONE3)) + { di << "Status: DONE3\n"; + } if (tool.Status(ShapeExtend_DONE4)) + { di << "Status: DONE4\n"; + } if (tool.Status(ShapeExtend_DONE5)) + { di << "Status: DONE5\n"; + } if (tool.Status(ShapeExtend_DONE6)) + { di << "Status: DONE6\n"; + } if (tool.Status(ShapeExtend_DONE7)) + { di << "Status: DONE7\n"; + } if (tool.Status(ShapeExtend_DONE8)) + { di << "Status: DONE8\n"; + } if (tool.Status(ShapeExtend_FAIL1)) + { di << "Status: FAIL1\n"; + } if (tool.Status(ShapeExtend_FAIL2)) + { di << "Status: FAIL2\n"; + } if (tool.Status(ShapeExtend_FAIL3)) + { di << "Status: FAIL3\n"; + } if (tool.Status(ShapeExtend_FAIL4)) + { di << "Status: FAIL4\n"; + } if (tool.Status(ShapeExtend_FAIL5)) + { di << "Status: FAIL5\n"; + } if (tool.Status(ShapeExtend_FAIL6)) + { di << "Status: FAIL6\n"; + } if (tool.Status(ShapeExtend_FAIL7)) + { di << "Status: FAIL7\n"; + } if (tool.Status(ShapeExtend_FAIL8)) + { di << "Status: FAIL8\n"; + } // fixes @@ -722,7 +874,9 @@ static int DT_SplitCurve(Draw_Interpretor& di, int n, const char** a) double Tol = Draw::Atof(a[2]); occ::handle GC = DrawTrSurf::GetCurve(a[1]); if (GC.IsNull()) + { return 1; + } int Split = Draw::Atoi(a[3]); occ::handle theTool = new ShapeUpgrade_SplitCurve3dContinuity; @@ -733,7 +887,9 @@ static int DT_SplitCurve(Draw_Interpretor& di, int n, const char** a) { occ::handle> spval = new NCollection_HSequence; for (int i = 1; i <= 5; i++) + { spval->Append(i); + } theTool->SetSplitValues(spval); } theTool->Perform(true); @@ -771,7 +927,9 @@ static int DT_SplitCurve2d(Draw_Interpretor& di, int n, const char** a) double Tol = Draw::Atof(a[2]); occ::handle GC = DrawTrSurf::GetCurve2d(a[1]); if (GC.IsNull()) + { return 1; + } int Split = Draw::Atoi(a[3]); occ::handle theTool = new ShapeUpgrade_SplitCurve2dContinuity; @@ -782,7 +940,9 @@ static int DT_SplitCurve2d(Draw_Interpretor& di, int n, const char** a) { occ::handle> spval = new NCollection_HSequence; for (int i = 1; i <= 5; i++) + { spval->Append(i); + } theTool->SetSplitValues(spval); } theTool->Perform(true); @@ -948,7 +1108,9 @@ static int DT_SplitSurface(Draw_Interpretor& di, int n, const char** a) { occ::handle> spval = new NCollection_HSequence; for (int i = 1; i <= 5; i++) + { spval->Append(i); + } theTool->SetUSplitValues(spval); theTool->SetVSplitValues(spval); } @@ -964,11 +1126,15 @@ static int DT_SplitSurface(Draw_Interpretor& di, int n, const char** a) int nbGlV = GlobalV->Length(); di << "nb GlobalU ; nb GlobalV=" << nbGlU << " " << nbGlV; for (int iu = 1; iu <= nbGlU; iu++) + { di << " " << GlobalU->Value(iu); + } // di <<"\n"; // di << "nb GlobalV="<Value(iv); + } di << "\n"; di << "appel a Surfaces\n"; @@ -1007,7 +1173,9 @@ static int offset2dcurve(Draw_Interpretor& di, int argc, const char** argv) double Offset = Draw::Atof(argv[3]); occ::handle GC = DrawTrSurf::GetCurve2d(argv[2]); if (GC.IsNull()) + { return 1; + } occ::handle offcrv = new Geom2d_OffsetCurve(GC, Offset); DrawTrSurf::Set(argv[1], offcrv); return 0; @@ -1028,7 +1196,9 @@ static int offsetcurve(Draw_Interpretor& di, int argc, const char** argv) double Offset = Draw::Atof(argv[3]); occ::handle GC = DrawTrSurf::GetCurve(argv[2]); if (GC.IsNull()) + { return 1; + } gp_Pnt point; DrawTrSurf::GetPoint(argv[4], point); gp_Dir dir(point.XYZ()); @@ -1061,40 +1231,64 @@ static int splitface(Draw_Interpretor& di, int argc, const char** argv) double Umin, Umax, Vmin, Vmax; S->Bounds(Umin, Umax, Vmin, Vmax); if (Uf < Umin && !S->IsUPeriodic()) + { Uf = Umin; + } else if (Uf > Umin) { if (Precision::IsInfinite(Umin)) + { Uf -= 100; + } else + { Uf = Umin; + } } if (Vf < Vmin && !S->IsVPeriodic()) + { Vf = Vmin; + } else if (Vf > Vmin) { if (Precision::IsInfinite(Vmin)) + { Vf -= 100; + } else + { Vf = Vmin; + } } if (Ul > Umax && !S->IsUPeriodic()) + { Ul = Umax; + } else if (Ul < Umax) { if (Precision::IsInfinite(Umax)) + { Ul += 100; + } else + { Ul = Umax; + } } if (Vl > Vmax && !S->IsVPeriodic()) + { Vl = Vmax; + } else if (Vl < Vmax) { if (Precision::IsInfinite(Vmax)) + { Vl += 100; + } else + { Vl = Vmax; + } } NCollection_Sequence uval; @@ -1105,9 +1299,13 @@ static int splitface(Draw_Interpretor& di, int argc, const char** argv) for (i = 3; i < argc; i++) { if (argv[i][0] == 'u') + { byV = false; + } else if (argv[i][0] == 'v') + { byV = true; + } else { double val = Draw::Atof(argv[i]); @@ -1186,7 +1384,9 @@ static int splitface(Draw_Interpretor& di, int argc, const char** argv) occ::handle Grid = new ShapeExtend_CompositeSurface; if (!Grid->Init(AS)) + { di << "Grid badly connected!\n"; + } ShapeFix_ComposeShell SUCS; TopLoc_Location l; @@ -1196,39 +1396,73 @@ static int splitface(Draw_Interpretor& di, int argc, const char** argv) SUCS.Perform(); if (SUCS.Status(ShapeExtend_OK)) + { di << "Status: OK\n"; + } if (SUCS.Status(ShapeExtend_DONE1)) + { di << "Status: DONE1\n"; + } if (SUCS.Status(ShapeExtend_DONE2)) + { di << "Status: DONE2\n"; + } if (SUCS.Status(ShapeExtend_DONE3)) + { di << "Status: DONE3\n"; + } if (SUCS.Status(ShapeExtend_DONE4)) + { di << "Status: DONE4\n"; + } if (SUCS.Status(ShapeExtend_DONE5)) + { di << "Status: DONE5\n"; + } if (SUCS.Status(ShapeExtend_DONE6)) + { di << "Status: DONE6\n"; + } if (SUCS.Status(ShapeExtend_DONE7)) + { di << "Status: DONE7\n"; + } if (SUCS.Status(ShapeExtend_DONE8)) + { di << "Status: DONE8\n"; + } if (SUCS.Status(ShapeExtend_FAIL1)) + { di << "Status: FAIL1\n"; + } if (SUCS.Status(ShapeExtend_FAIL2)) + { di << "Status: FAIL2\n"; + } if (SUCS.Status(ShapeExtend_FAIL3)) + { di << "Status: FAIL3\n"; + } if (SUCS.Status(ShapeExtend_FAIL4)) + { di << "Status: FAIL4\n"; + } if (SUCS.Status(ShapeExtend_FAIL5)) + { di << "Status: FAIL5\n"; + } if (SUCS.Status(ShapeExtend_FAIL6)) + { di << "Status: FAIL6\n"; + } if (SUCS.Status(ShapeExtend_FAIL7)) + { di << "Status: FAIL7\n"; + } if (SUCS.Status(ShapeExtend_FAIL8)) + { di << "Status: FAIL8\n"; + } TopoDS_Shape sh = SUCS.Result(); ShapeFix::SameParameter(sh, false); @@ -1341,7 +1575,9 @@ static int splitbynumber(Draw_Interpretor& di, int argc, const char** argv) int aNbParts, aNumber1 = 0, aNumber2 = 0; aNbParts = aNumber1 = Draw::Atoi(argv[3]); if (argc > 4) + { aNumber2 = Draw::Atoi(argv[4]); + } if (argc == 4 && aNbParts <= 0) { @@ -1357,9 +1593,13 @@ static int splitbynumber(Draw_Interpretor& di, int argc, const char** argv) ShapeUpgrade_ShapeDivideArea tool(inputShape); tool.SetSplittingByNumber(true); if (argc == 4) + { tool.NbParts() = aNbParts; + } else + { tool.SetNumbersUVSplits(aNumber1, aNumber2); + } tool.Perform(); TopoDS_Shape res = tool.Result(); @@ -1385,7 +1625,9 @@ static int removeinternalwires(Draw_Interpretor& di, int argc, const char** argv occ::handle aTool; NCollection_Sequence aSeqShapes; if (inputShape.ShapeType() < TopAbs_WIRE) + { aTool = new ShapeUpgrade_RemoveInternalWires(inputShape); + } else { di << "Invalid type of first shape: should be FACE,SHELL,SOLID or COMPOUND\n"; @@ -1405,23 +1647,35 @@ static int removeinternalwires(Draw_Interpretor& di, int argc, const char** argv if (isShape) { if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_WIRE) + { aSeqShapes.Append(aShape); + } } } if (!isShape) + { aModeRemoveFaces = (Draw::Atoi(argv[k]) == 1); + } } aTool->MinArea() = aMinArea; aTool->RemoveFaceMode() = aModeRemoveFaces; if (aSeqShapes.Length()) + { aTool->Perform(aSeqShapes); + } else + { aTool->Perform(); + } if (aTool->Status(ShapeExtend_FAIL1)) + { di << "Initial shape has invalid type\n"; + } else if (aTool->Status(ShapeExtend_FAIL2)) + { di << "Specified sub-shape is not belonged to whole shape\n"; + } if (aTool->Status(ShapeExtend_DONE1)) { const NCollection_Sequence& aRemovedWires = aTool->RemovedWires(); @@ -1449,10 +1703,14 @@ static int removeloc(Draw_Interpretor& di, int argc, const char** argv) TopoDS_Shape aShape = DBRep::Get(argv[2]); if (aShape.IsNull()) + { return 1; + } ShapeUpgrade_RemoveLocations aRemLoc; if (argc > 3) + { aRemLoc.SetRemoveLevel((TopAbs_ShapeEnum)Draw::Atoi(argv[3])); + } aRemLoc.Remove(aShape); TopoDS_Shape aNewShape = aRemLoc.GetResult(); @@ -1490,7 +1748,9 @@ static int unifysamedom(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape aShape = DBRep::Get(a[2]); if (aShape.IsNull()) + { return 1; + } // default values bool anUFaces = true; @@ -1504,6 +1764,7 @@ static int unifysamedom(Draw_Interpretor& di, int n, const char** a) NCollection_Map aMapOfShapes; if (n > 3) + { for (int i = 3; i < n; i++) { aKeepShape = DBRep::Get(a[i]); @@ -1514,23 +1775,37 @@ static int unifysamedom(Draw_Interpretor& di, int n, const char** a) else { if (!strcmp(a[i], "-f")) + { anUFaces = false; + } else if (!strcmp(a[i], "-e")) + { anUEdges = false; + } else if (!strcmp(a[i], "-nosafe")) + { isSafeInputMode = false; + } else if (!strcmp(a[i], "+b")) + { anConBS = true; + } else if (!strcmp(a[i], "+i")) + { isAllowInternal = true; + } else if (!strcmp(a[i], "-t") || !strcmp(a[i], "-a")) { if (++i < n) { if (a[i - 1][1] == 't') + { aLinTol = Draw::Atof(a[i]); + } else + { aAngTol = Draw::Atof(a[i]) * (M_PI / 180.0); + } } else { @@ -1540,6 +1815,7 @@ static int unifysamedom(Draw_Interpretor& di, int n, const char** a) } } } + } Unifier().Initialize(aShape, anUEdges, anUFaces, anConBS); Unifier().KeepShapes(aMapOfShapes); @@ -1551,7 +1827,9 @@ static int unifysamedom(Draw_Interpretor& di, int n, const char** a) TopoDS_Shape Result = Unifier().Shape(); if (BRepTest_Objects::IsHistoryNeeded()) + { BRepTest_Objects::SetHistory(Unifier().History()); + } DBRep::Set(a[1], Result); return 0; @@ -1566,7 +1844,9 @@ static int copytranslate(Draw_Interpretor& di, int argc, const char** argv) } TopoDS_Shape aShape = DBRep::Get(argv[2]); if (aShape.IsNull()) + { return 1; + } double aDx = Draw::Atof(argv[3]); double aDy = Draw::Atof(argv[4]); double aDz = Draw::Atof(argv[5]); @@ -1658,23 +1938,41 @@ static int reshape(Draw_Interpretor& /*theDI*/, int theArgc, const char** theArg TCollection_AsciiString aLevelStr(aLevelCStr); aLevelStr.LowerCase(); if (aLevelStr == "compound" || aLevelStr == "cd") + { aShapeLevel = TopAbs_COMPOUND; + } else if (aLevelStr == "compsolid" || aLevelStr == "c") + { aShapeLevel = TopAbs_COMPSOLID; + } else if (aLevelStr == "solid" || aLevelStr == "so") + { aShapeLevel = TopAbs_SOLID; + } else if (aLevelStr == "shell" || aLevelStr == "sh") + { aShapeLevel = TopAbs_SHELL; + } else if (aLevelStr == "face" || aLevelStr == "f") + { aShapeLevel = TopAbs_FACE; + } else if (aLevelStr == "wire" || aLevelStr == "w") + { aShapeLevel = TopAbs_WIRE; + } else if (aLevelStr == "edge" || aLevelStr == "e") + { aShapeLevel = TopAbs_EDGE; + } else if (aLevelStr == "vertex" || aLevelStr == "v") + { aShapeLevel = TopAbs_VERTEX; + } else if (aLevelStr == "shape" || aLevelStr == "s") + { aShapeLevel = TopAbs_SHAPE; + } else { Message::SendFail() << "Error: unknown shape type '" << theArgv[i] << "'"; diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest.cxx index 5cd08c89ba..617083a80b 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest.cxx @@ -1440,7 +1440,9 @@ static int VDispMode(Draw_Interpretor&, int argc, const char** argv) static int VSubInt(Draw_Interpretor& di, int argc, const char** argv) { if (argc == 1) + { return 1; + } int On = Draw::Atoi(argv[1]); const occ::handle& Ctx = ViewerTest::GetAISContext(); if (Ctx.IsNull()) @@ -1474,12 +1476,18 @@ static int VSubInt(Draw_Interpretor& di, int argc, const char** argv) if (GetMapOfAIS().Find2(name, IO) && !IO.IsNull()) { if (On == 1) + { Ctx->SubIntensityOn(IO, true); + } else + { Ctx->SubIntensityOff(IO, true); + } } else + { return 1; + } } return 0; } @@ -1494,7 +1502,9 @@ public: { NCollection_Sequence aNames; if (!theName.IsEmpty()) + { aNames.Append(theName); + } Init(aNames); } @@ -3181,7 +3191,9 @@ static int VAspects(Draw_Interpretor& theDI, int theArgNb, const char** theArgVe { toCompactDump = false; if (++anArgIter >= theArgNb && Draw::ParseOnOff(theArgVec[anArgIter + 1], toCompactDump)) + { ++anArgIter; + } } else if (anArg == "-dumpdepth") { @@ -3259,9 +3271,13 @@ static int VAspects(Draw_Interpretor& theDI, int theArgNb, const char** theArgVe aDrawer->DumpJson(aStream, aDumpDepth); if (toCompactDump) + { theDI << Standard_Dump::Text(aStream); + } else + { theDI << Standard_Dump::FormatJson(aStream); + } } return 0; } @@ -3640,7 +3656,6 @@ int VRemove(Draw_Interpretor& theDI, int theArgNb, const char** theArgVec) } anIONameList.Append(anIter.Key2()); - continue; } } @@ -3938,7 +3953,9 @@ inline void bndPresentation(Draw_Interpretor& theDI aPrsIter.Next()) { if (aPrsIter.Value()->Mode() != theDispMode) + { continue; + } aBox = aPrsIter.Value()->MinMaxValues(); } @@ -5323,9 +5340,13 @@ static int VShading(Draw_Interpretor&, int argc, const char** argv) } if (HaveToSet) + { TheAISContext()->SetDeviationCoefficient(TheAisIO, myDevCoef, true); + } else + { TheAISContext()->SetDeviationCoefficient(TheAisIO, 0.0008, true); + } TheAISContext()->Redisplay(TheAisIO, true); return 0; @@ -5431,11 +5452,15 @@ static void printLocalSelectionInfo(const T& theContext, Draw_Interpretor& theDI occ::down_cast(theContext->SelectedInteractive()); const occ::handle anOwner = theContext->SelectedOwner(); if (aShapeIO.IsNull() || anOwner.IsNull()) + { continue; + } if (isGlobalCtx) { if (anOwner == aShapeIO->GlobalSelOwner()) + { continue; + } } const TopoDS_Shape aSubShape = theContext->SelectedShape(); if (aSubShape.IsNull() || aShapeIO.IsNull() || !GetMapOfAIS().IsBound1(aShapeIO)) @@ -5819,19 +5844,33 @@ static int VPickShape(Draw_Interpretor& di, int argc, const char** argv) aShapeArg.LowerCase(); aShapeType = TopAbs_COMPOUND; if (aShapeArg == "v" || aShapeArg == "vertex") + { aShapeType = TopAbs_VERTEX; + } else if (aShapeArg == "e" || aShapeArg == "edge") + { aShapeType = TopAbs_EDGE; + } else if (aShapeArg == "w" || aShapeArg == "wire") + { aShapeType = TopAbs_WIRE; + } else if (aShapeArg == "f" || aShapeArg == "face") + { aShapeType = TopAbs_FACE; + } else if (aShapeArg == "shape") + { aShapeType = TopAbs_SHAPE; + } else if (aShapeArg == "shell") + { aShapeType = TopAbs_SHELL; + } else if (aShapeArg == "solid") + { aShapeType = TopAbs_SOLID; + } else { Message::SendFail() << "Syntax error at '" << argv[1] << "'"; @@ -6054,9 +6093,13 @@ static int VIOTypes(Draw_Interpretor& di, int, const char**) di << "/n" << BlankLine.ToCString() << "\n"; for (i = 0; i <= 2; i++) + { Colum[i].Center(20, ' '); + } for (i = 0; i <= 2; i++) + { di << "|" << Colum[i].ToCString(); + } di << "|\n"; di << BlankLine.ToCString() << "\n"; @@ -6153,7 +6196,9 @@ static int VIOTypes(Draw_Interpretor& di, int, const char**) static int VEraseType(Draw_Interpretor&, int argc, const char** argv) { if (argc != 2) + { return 1; + } AIS_KindOfInteractive TheType; int TheSign(-1); @@ -6177,13 +6222,17 @@ static int VEraseType(Draw_Interpretor&, int argc, const char** argv) curio = it.Value(); if (dimension_status == -1) + { TheAISContext()->Erase(curio, false); + } else { PrsDim_KindOfDimension KOD = occ::down_cast(curio)->KindOfDimension(); if ((dimension_status == 0 && KOD == PrsDim_KOD_NONE) || (dimension_status == 1 && KOD != PrsDim_KOD_NONE)) + { TheAISContext()->Erase(curio, false); + } } } TheAISContext()->UpdateCurrentViewer(); @@ -6193,7 +6242,9 @@ static int VEraseType(Draw_Interpretor&, int argc, const char** argv) static int VDisplayType(Draw_Interpretor&, int argc, const char** argv) { if (argc != 2) + { return 1; + } AIS_KindOfInteractive TheType; int TheSign(-1); @@ -6215,13 +6266,17 @@ static int VDisplayType(Draw_Interpretor&, int argc, const char** argv) { curio = it.Value(); if (dimension_status == -1) + { TheAISContext()->Display(curio, false); + } else { PrsDim_KindOfDimension KOD = occ::down_cast(curio)->KindOfDimension(); if ((dimension_status == 0 && KOD == PrsDim_KOD_NONE) || (dimension_status == 1 && KOD != PrsDim_KOD_NONE)) + { TheAISContext()->Display(curio, false); + } } } diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_CmdParser.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_CmdParser.cxx index 01adffb69f..267c762969 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_CmdParser.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_CmdParser.cxx @@ -113,7 +113,7 @@ ViewerTest_CommandOptionKey ViewerTest_CmdParser::AddOption(const std::string& t void ViewerTest_CmdParser::PrintHelp() const { - std::cout << myDescription << std::endl; + std::cout << myDescription << '\n'; std::vector::const_iterator anIt = myOptionStorage.begin(); for (++anIt; anIt != myOptionStorage.end(); ++anIt) { @@ -133,7 +133,7 @@ void ViewerTest_CmdParser::PrintHelp() const } std::cout << " : " << aCommandOption.Description; } - std::cout << std::endl; + std::cout << '\n'; } //================================================================================================= diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_FilletCommands.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_FilletCommands.cxx index f0c2ef5fa9..8e768c3452 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_FilletCommands.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_FilletCommands.cxx @@ -64,7 +64,9 @@ static int VBLEND(Draw_Interpretor& di, int narg, const char** a) Rakk = nullptr; printtolblend(di); if (narg < 5) + { return 1; + } int NbToPick = (narg - 4) / 2; occ::handle> arr = @@ -83,7 +85,9 @@ static int VBLEND(Draw_Interpretor& di, int narg, const char** a) TopoDS_Shape V = DBRep::Get(a[2]); if (V.IsNull()) + { return 1; + } ChFi3d_FilletShape FSh = ChFi3d_Rational; if (narg % 2 == 0) { @@ -115,10 +119,14 @@ static int VBLEND(Draw_Interpretor& di, int narg, const char** a) } } if (!nbedge) + { return 1; + } Rakk->Build(); if (!Rakk->IsDone()) + { return 1; + } TopoDS_Shape res = Rakk->Shape(); DBRep::Set(a[1], res); diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ObjectCommands.cxx index fc5fdb378e..3152be5aae 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -179,27 +179,49 @@ static bool convertToDatumPart(const TCollection_AsciiString& theValue, TCollection_AsciiString aValue = theValue; aValue.LowerCase(); if (aValue == "origin") + { theDatumPart = Prs3d_DatumParts_Origin; + } else if (aValue == "xaxis") + { theDatumPart = Prs3d_DatumParts_XAxis; + } else if (aValue == "yaxis") + { theDatumPart = Prs3d_DatumParts_YAxis; + } else if (aValue == "zaxis") + { theDatumPart = Prs3d_DatumParts_ZAxis; + } else if (aValue == "xarrow") + { theDatumPart = Prs3d_DatumParts_XArrow; + } else if (aValue == "yarrow") + { theDatumPart = Prs3d_DatumParts_YArrow; + } else if (aValue == "zarrow") + { theDatumPart = Prs3d_DatumParts_ZArrow; + } else if (aValue == "xoyaxis") + { theDatumPart = Prs3d_DatumParts_XOYAxis; + } else if (aValue == "yozaxis") + { theDatumPart = Prs3d_DatumParts_YOZAxis; + } else if (aValue == "xozaxis") + { theDatumPart = Prs3d_DatumParts_XOZAxis; + } else if (aValue == "whole") + { theDatumPart = Prs3d_DatumParts_None; + } else { return false; @@ -234,23 +256,41 @@ static bool convertToDatumAttribute(const TCollection_AsciiString& theValue, TCollection_AsciiString aValue = theValue; aValue.LowerCase(); if (aValue == "xaxislength") + { theAttribute = Prs3d_DatumAttribute_XAxisLength; + } else if (aValue == "yaxislength") + { theAttribute = Prs3d_DatumAttribute_YAxisLength; + } else if (aValue == "zaxislength") + { theAttribute = Prs3d_DatumAttribute_ZAxisLength; + } else if (aValue == "tuberadiuspercent") + { theAttribute = Prs3d_DatumAttribute_ShadingTubeRadiusPercent; + } else if (aValue == "coneradiuspercent") + { theAttribute = Prs3d_DatumAttribute_ShadingConeRadiusPercent; + } else if (aValue == "conelengthpercent") + { theAttribute = Prs3d_DatumAttribute_ShadingConeLengthPercent; + } else if (aValue == "originradiuspercent") + { theAttribute = Prs3d_DatumAttribute_ShadingOriginRadiusPercent; + } else if (aValue == "shadingnumberoffacettes") + { theAttribute = Prs3d_DatumAttribute_ShadingNumberOfFacettes; + } else + { return false; + } return true; } @@ -281,19 +321,33 @@ static bool convertToDatumAxes(const TCollection_AsciiString& theValue, TCollection_AsciiString aValue = theValue; aValue.LowerCase(); if (aValue == "x") + { theDatumAxes = Prs3d_DatumAxes_XAxis; + } else if (aValue == "y") + { theDatumAxes = Prs3d_DatumAxes_YAxis; + } else if (aValue == "z") + { theDatumAxes = Prs3d_DatumAxes_ZAxis; + } else if (aValue == "xy") + { theDatumAxes = Prs3d_DatumAxes_XYAxes; + } else if (aValue == "zy") + { theDatumAxes = Prs3d_DatumAxes_YZAxes; + } else if (aValue == "xz") + { theDatumAxes = Prs3d_DatumAxes_XZAxes; + } else if (aValue == "xyz") + { theDatumAxes = Prs3d_DatumAxes_XYZAxes; + } else { return false; @@ -372,7 +426,9 @@ static bool setTrihedronParams(int theArgsNb, TCollection_AsciiString aValue(aValues->Value(1)); bool isWireframe = true; if (aValue.IsEqual("sh") || aValue.IsEqual("shading")) + { isWireframe = false; + } theTrihedron->SetDatumDisplayMode(isWireframe ? Prs3d_DM_WireFrame : Prs3d_DM_Shaded); } @@ -514,7 +570,9 @@ static bool setTrihedronParams(int theArgsNb, convertToDatumAttributes(aValues->Value(1), anAttributes); if (!theTrihedron->Attributes()->HasOwnDatumAspect()) + { theTrihedron->Attributes()->SetDatumAspect(new Prs3d_DatumAspect()); + } for (NCollection_List::Iterator anIterator(anAttributes); anIterator.More(); anIterator.Next()) @@ -560,7 +618,9 @@ static bool setTrihedronParams(int theArgsNb, return false; } if (!theTrihedron->Attributes()->HasOwnDatumAspect()) + { theTrihedron->Attributes()->SetDatumAspect(new Prs3d_DatumAspect()); + } theTrihedron->Attributes()->DatumAspect()->SetDrawDatumAxes(aDatumAxes); } return true; @@ -2038,9 +2098,13 @@ void FilledCircle::Compute(const occ::handle&, TopoDS_Face aFace = ComputeFace(); if (aFace.IsNull()) + { return; + } if (theMode != 0) + { return; + } StdPrs_ShadedShape::Add(thePrs, aFace, myDrawer); } @@ -2950,15 +3014,21 @@ occ::handle CalculationOfSphere(double X, gp_XYZ vv = v1 ^ v2; double mod = vv.Modulus(); if (mod < Tol) + { continue; + } eqPlan += vv / mod; } double modmax = eqPlan.Modulus(); if (modmax > Tol) + { Nor = gp_Dir(eqPlan); + } else + { Nor = gp_Dir(gp_Dir::D::Z); + } polyTriangulation->SetNormal(i, Nor.XYZ()); } @@ -2999,7 +3069,9 @@ static int VDrawSphere(Draw_Interpretor& /*di*/, int argc, const char** argv) VDisplayAISObject(aShapeName, occ::handle()); if (toPrintInfo) + { std::cout << "Compute Triangulation...\n"; + } occ::handle aShape = new AIS_Triangulation(CalculationOfSphere(aCenterX, aCenterY, aCenterZ, aResolution, aRadius)); const int aNumberPoints = aShape->GetTriangulation()->NbNodes(); @@ -3457,7 +3529,9 @@ bool MyPArrayObject::Init(Graphic3d_TypeOfPrimitiveArray thePrimType, } // unknown command else + { anArgIndex++; + } } if (myPArray.IsNull()) @@ -3568,13 +3642,16 @@ bool MyPArrayObject::Init(Graphic3d_TypeOfPrimitiveArray thePrimType, int aVertCount = theDesc->Value(anArgIndex - 1).IntegerValue(); if (CheckInputCommand("c", theDesc, anArgIndex, 3, anArgsCount)) + { myPArray->AddBound(aVertCount, theDesc->Value(anArgIndex - 3).RealValue(), theDesc->Value(anArgIndex - 2).RealValue(), theDesc->Value(anArgIndex - 1).RealValue()); - + } else + { myPArray->AddBound(aVertCount); + } } // edge command else if (CheckInputCommand("e", theDesc, anArgIndex, 1, anArgsCount)) @@ -3673,12 +3750,16 @@ bool MyPArrayObject::CheckInputCommand( { // check if there is more elements than expected if (theArgIndex >= theMaxArgs) + { return false; + } TCollection_AsciiString aStrCommand = theArgsArray->Value(theArgIndex); aStrCommand.LowerCase(); if (aStrCommand.Search(theCommand) != 1 || theArgIndex + (theArgCount - 1) >= theMaxArgs) + { return false; + } // go to the first data element theArgIndex++; @@ -3688,7 +3769,9 @@ bool MyPArrayObject::CheckInputCommand( { aStrCommand = theArgsArray->Value(theArgIndex); if (!aStrCommand.IsRealValue(true)) + { return false; + } } return true; @@ -4673,7 +4756,7 @@ static int VListConnected(Draw_Interpretor& /*di*/, int argc, const char** argv) { std::cout << " connected to " << aMap.Find1(aConnected->ConnectedTo()); } - std::cout << std::endl; + std::cout << '\n'; ++aCounter; } @@ -4757,16 +4840,24 @@ static int VChild(Draw_Interpretor&, int theNbArgs, const char** theArgVec) if (toAdd == 1) { if (toInheritTrsf == 0) + { aParent->AddChildWithCurrentTransformation(aChild); + } else + { aParent->AddChild(aChild); + } } else { if (toInheritTrsf == 0) + { aParent->RemoveChildWithRestoreTransformation(aChild); + } else + { aParent->RemoveChild(aChild); + } } } } @@ -4809,7 +4900,9 @@ static int VParent(Draw_Interpretor&, int theNbArgs, const char** theArgVec) TCollection_AsciiString anArg(theArgVec[anArgIter]); anArg.LowerCase(); if (anArg == "-ignorevisu") + { aParent->SetPropagateVisualState(false); + } } return 0; } @@ -5321,7 +5414,9 @@ static int VObjZLayer(Draw_Interpretor& di, int argc, const char** argv) // get operation TCollection_AsciiString aOperation; if (argc >= 2) + { aOperation = TCollection_AsciiString(argv[1]); + } // check for correct arguments if ((argc != 4 || !aOperation.IsEqual("set")) && (argc != 3 || !aOperation.IsEqual("get"))) @@ -5410,23 +5505,23 @@ static int VPolygonOffset(Draw_Interpretor& /*di*/, int argc, const char** argv) if (anInterObj->HasPolygonOffsets()) { anInterObj->PolygonOffsets(aMode, aFactor, aUnits); - std::cout << "Current polygon offset parameters for " << argv[1] << ":" << std::endl; - std::cout << "\tMode: " << aMode << std::endl; - std::cout << "\tFactor: " << aFactor << std::endl; - std::cout << "\tUnits: " << aUnits << std::endl; + std::cout << "Current polygon offset parameters for " << argv[1] << ":" << '\n'; + std::cout << "\tMode: " << aMode << '\n'; + std::cout << "\tFactor: " << aFactor << '\n'; + std::cout << "\tUnits: " << aUnits << '\n'; return 0; } else { - std::cout << "Specific polygon offset parameters are not set for " << argv[1] << std::endl; + std::cout << "Specific polygon offset parameters are not set for " << argv[1] << '\n'; } } - std::cout << "Default polygon offset parameters:" << std::endl; + std::cout << "Default polygon offset parameters:" << '\n'; aContext->DefaultDrawer()->ShadingAspect()->Aspect()->PolygonOffsets(aMode, aFactor, aUnits); - std::cout << "\tMode: " << aMode << std::endl; - std::cout << "\tFactor: " << aFactor << std::endl; - std::cout << "\tUnits: " << aUnits << std::endl; + std::cout << "\tMode: " << aMode << '\n'; + std::cout << "\tFactor: " << aFactor << '\n'; + std::cout << "\tUnits: " << aUnits << '\n'; return 0; } @@ -6181,7 +6276,9 @@ static int VVertexMode(Draw_Interpretor& theDI, int theArgNum, const char** theA } if (aRedrawNeeded) + { ViewerTest::CurrentView()->Redraw(); + } return 0; } diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_RelationCommands.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_RelationCommands.cxx index 4c0fd515c1..992b93c425 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_RelationCommands.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_RelationCommands.cxx @@ -1662,13 +1662,21 @@ static int VLengthParam(Draw_Interpretor&, int theArgNum, const char** theArgVec TCollection_AsciiString aValue = theArgVec[anArgumentIt]; aValue.LowerCase(); if (aValue == "ox") + { aDirection = gp::DX(); + } else if (aValue == "oy") + { aDirection = gp::DY(); + } else if (aValue == "oz") + { aDirection = gp::DZ(); + } else if (aValue == "autodirection") + { isCustomDirection = false; + } else { if (anArgumentIt + 2 >= theArgNum) diff --git a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ViewerCommands.cxx index 7a7a30c5fe..e0be213d9d 100644 --- a/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/Draw/TKViewerTest/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -272,7 +272,9 @@ TCollection_AsciiString CreateName( const TCollection_AsciiString& theDefaultString) { if (theObjectMap.IsEmpty()) + { return theDefaultString + TCollection_AsciiString(1); + } int aNextKey = 1; bool isFound = false; @@ -285,7 +287,9 @@ TCollection_AsciiString CreateName( aNextKey++; } else + { isFound = true; + } } return theDefaultString + TCollection_AsciiString(aNextKey); @@ -327,12 +331,16 @@ public: { // Get current configuration if (ViewerTest_myDrivers.IsEmpty()) + { myDriverName = CreateName>(ViewerTest_myDrivers, TCollection_AsciiString("Driver")); + } else + { myDriverName = ViewerTest_myDrivers.Find2(ViewerTest::GetAISContext()->CurrentViewer()->Driver()); + } if (ViewerTest_myContexts.IsEmpty()) { @@ -362,7 +370,9 @@ public: aName.Split(aParserPos - 1); } else + { break; + } } if (aParserNumber == 0) { @@ -390,8 +400,10 @@ public: { // Here is viewerName/viewName if (!ViewerTest::GetAISContext().IsNull()) + { myDriverName = ViewerTest_myDrivers.Find2(ViewerTest::GetAISContext()->CurrentViewer()->Driver()); + } else { // There is no opened contexts here, need to create name for driver @@ -432,7 +444,9 @@ occ::handle FindContextByView(const occ::handleCurrentViewer() == theView->Viewer()) + { return anIter.Key2(); + } } return anAISContext; } @@ -682,7 +696,9 @@ TCollection_AsciiString ViewerTest::ViewerInit(const ViewerTest_VinitParams& the { ViewerTest_ViewerCommandsInteractiveContextMap::Iterator anIter(ViewerTest_myContexts); if (anIter.More()) + { ViewerTest::SetAISContext(anIter.Key2()); + } a3DViewer = ViewerTest::GetAISContext()->CurrentViewer(); } else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())) @@ -1481,7 +1497,9 @@ static TCollection_AsciiString FindViewIdByWindowHandle(Aspect_Drawable theWindo { Aspect_Drawable aWindowHandle = anIter.Key2()->Window()->NativeHandle(); if (aWindowHandle == theWindowHandle) + { return anIter.Key1(); + } } return TCollection_AsciiString(""); } @@ -1815,7 +1833,9 @@ static int VViewList(Draw_Interpretor& theDi, int theArgsNb, const char** theArg return 1; } if (ViewerTest_myContexts.Size() < 1) + { return 0; + } bool isTreeView = ((theArgsNb == 1) || (strcasecmp(theArgVec[1], "long") != 0)); @@ -1829,7 +1849,9 @@ static int VViewList(Draw_Interpretor& theDi, int theArgsNb, const char** theArg aDriverIter.Next()) { if (isTreeView) + { theDi << aDriverIter.Key1() << ":\n"; + } for (ViewerTest_ViewerCommandsInteractiveContextMap::Iterator aContextIter( ViewerTest_myContexts); @@ -1854,9 +1876,13 @@ static int VViewList(Draw_Interpretor& theDi, int theArgsNb, const char** theArg if (isTreeView) { if (aViewIter.Key2() == ViewerTest::CurrentView()) + { theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n"; + } else + { theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n"; + } } else { @@ -2651,7 +2677,9 @@ static int VClear(Draw_Interpretor&, int, const char**) { occ::handle V = ViewerTest::CurrentView(); if (!V.IsNull()) + { ViewerTest::Clear(); + } return 0; } @@ -3137,7 +3165,9 @@ static int VScale(Draw_Interpretor& di, int argc, const char** argv) { occ::handle V3dView = ViewerTest::CurrentView(); if (V3dView.IsNull()) + { return 1; + } if (argc != 4) { @@ -3454,7 +3484,9 @@ static int VPan(Draw_Interpretor& di, int argc, const char** argv) { occ::handle V3dView = ViewerTest::CurrentView(); if (V3dView.IsNull()) + { return 1; + } if (argc == 3) { @@ -4955,7 +4987,9 @@ static int VLayerLine(Draw_Interpretor& di, int argc, const char** argv) // has width if (argc > 5) + { aWidth = Draw::Atof(argv[5]); + } // select appropriate line type Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; @@ -4970,7 +5004,9 @@ static int VLayerLine(Draw_Interpretor& di, int argc, const char** argv) { aTransparency = Draw::Atof(argv[7]); if (aTransparency < 0 || aTransparency > 1.0) + { aTransparency = 1.0; + } } static occ::handle aLine; @@ -5546,13 +5582,21 @@ static int VConvert(Draw_Interpretor& theDI, int theArgNb, const char** theArgVe TCollection_AsciiString anArg(theArgVec[anArgIdx]); anArg.LowerCase(); if (anArg == "window") + { aMode = Window; + } else if (anArg == "view") + { aMode = View; + } else if (anArg == "grid") + { aMode = Grid; + } else if (anArg == "ray") + { aMode = Ray; + } else { Message::SendFail() << "Error: wrong argument " << anArg << "! See usage:"; @@ -5892,7 +5936,7 @@ static int VReadPixel(Draw_Interpretor& theDI, int theArgNb, const char** theArg const char* aWarnLog = theDI.Result(); if (aWarnLog != nullptr && aWarnLog[0] != '\0') { - std::cout << aWarnLog << std::endl; + std::cout << aWarnLog << '\n'; } theDI.Reset(); @@ -10586,35 +10630,65 @@ static bool parsePerfStatsFlag(const TCollection_AsciiString& theValue } if (aVal == "fps" || aVal == "framerate") + { aFlag = Graphic3d_RenderingParams::PerfCounters_FrameRate; + } else if (aVal == "cpu") + { aFlag = Graphic3d_RenderingParams::PerfCounters_CPU; + } else if (aVal == "layers") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Layers; + } else if (aVal == "structs" || aVal == "structures" || aVal == "objects") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Structures; + } else if (aVal == "groups") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Groups; + } else if (aVal == "arrays") + { aFlag = Graphic3d_RenderingParams::PerfCounters_GroupArrays; + } else if (aVal == "tris" || aVal == "triangles") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Triangles; + } else if (aVal == "pnts" || aVal == "points") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Points; + } else if (aVal == "lines") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Lines; + } else if (aVal == "mem" || aVal == "gpumem" || aVal == "estimmem") + { aFlag = Graphic3d_RenderingParams::PerfCounters_EstimMem; + } else if (aVal == "skipimmediate" || aVal == "noimmediate") + { aFlag = Graphic3d_RenderingParams::PerfCounters_SkipImmediate; + } else if (aVal == "frametime" || aVal == "frametimers" || aVal == "time") + { aFlag = Graphic3d_RenderingParams::PerfCounters_FrameTime; + } else if (aVal == "basic") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Basic; + } else if (aVal == "extended" || aVal == "verbose" || aVal == "extra") + { aFlag = Graphic3d_RenderingParams::PerfCounters_Extended; + } else if (aVal == "full" || aVal == "all") + { aFlag = Graphic3d_RenderingParams::PerfCounters_All; + } else { return false; @@ -12013,31 +12087,53 @@ static int VStatProfiler(Draw_Interpretor& theDI, int theArgNb, const char** the { Graphic3d_RenderingParams::PerfCounters aParam = Graphic3d_RenderingParams::PerfCounters_NONE; if (aFlag == "fps") + { aParam = Graphic3d_RenderingParams::PerfCounters_FrameRate; + } else if (aFlag == "cpu") + { aParam = Graphic3d_RenderingParams::PerfCounters_CPU; + } else if (aFlag == "alllayers" || aFlag == "layers") + { aParam = Graphic3d_RenderingParams::PerfCounters_Layers; + } else if (aFlag == "allstructs" || aFlag == "allstructures" || aFlag == "structs" || aFlag == "structures") + { aParam = Graphic3d_RenderingParams::PerfCounters_Structures; + } else if (aFlag == "groups") + { aParam = Graphic3d_RenderingParams::PerfCounters_Groups; + } else if (aFlag == "allarrays" || aFlag == "fillarrays" || aFlag == "linearrays" || aFlag == "pointarrays" || aFlag == "textarrays") + { aParam = Graphic3d_RenderingParams::PerfCounters_GroupArrays; + } else if (aFlag == "triangles") + { aParam = Graphic3d_RenderingParams::PerfCounters_Triangles; + } else if (aFlag == "lines") + { aParam = Graphic3d_RenderingParams::PerfCounters_Lines; + } else if (aFlag == "points") + { aParam = Graphic3d_RenderingParams::PerfCounters_Points; + } else if (aFlag == "geommem" || aFlag == "texturemem" || aFlag == "framemem") + { aParam = Graphic3d_RenderingParams::PerfCounters_EstimMem; + } else if (aFlag == "elapsedframe" || aFlag == "cpuframeaverage" || aFlag == "cpupickingaverage" || aFlag == "cpucullingaverage" || aFlag == "cpudynaverage" || aFlag == "cpuframemax" || aFlag == "cpupickingmax" || aFlag == "cpucullingmax" || aFlag == "cpudynmax") + { aParam = Graphic3d_RenderingParams::PerfCounters_FrameTime; + } else { Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'"; @@ -13650,7 +13746,7 @@ static int VColorDiff(Draw_Interpretor& theDI, int theNbArgs, const char** theAr { if (theNbArgs != 7) { - std::cerr << "Error: command syntax is incorrect, see help" << std::endl; + std::cerr << "Error: command syntax is incorrect, see help" << '\n'; return 1; } diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW.cxx index e93113724d..66c26f66e8 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW.cxx @@ -138,7 +138,9 @@ static int newDoc(Draw_Interpretor& di, int argc, const char** argv) // DDocStd::ReturnLabel(di,D->Main()); } else + { di << argv[1] << " is already a document\n"; + } return 0; } @@ -153,13 +155,17 @@ static int saveDoc(Draw_Interpretor& di, int argc, const char** argv) if (argc == 1) { if (A->NbDocuments() < 1) + { return 1; + } D = A->GetDocument(1); } else { if (!DDocStd::GetDocument(argv[1], D)) + { return 1; + } } occ::handle aProgress = new Draw_ProgressIndicator(di); @@ -307,7 +313,9 @@ static int dump(Draw_Interpretor& di, int argc, const char** argv) occ::handle myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); bool deep = false; if ((argc == 3) && (Draw::Atoi(argv[2]) == 1)) + { deep = true; + } Standard_SStream aDumpLog; myAssembly->Dump(aDumpLog, deep); di << aDumpLog; @@ -333,12 +341,16 @@ static void StatAssembly(const TDF_Label L, if (PrintStructMode) { for (int j = 0; j <= level; j++) + { di << " "; + } } TCollection_AsciiString Entry; TDF_Tool::Entry(L, Entry); if (PrintStructMode) + { di << Entry.ToCString(); + } occ::handle Name; if (L.FindAttribute(TDataStd_Name::GetID(), Name)) @@ -352,27 +364,35 @@ static void StatAssembly(const TDF_Label L, else { if (PrintStructMode) + { di << " NoName has attributes: "; + } } occ::handle aCentroid = new (XCAFDoc_Centroid); if (L.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) { if (PrintStructMode) + { di << "Centroid "; + } NbCentroidProp++; } double tmp; if (XCAFDoc_Volume::Get(L, tmp)) { if (PrintStructMode) + { di << "Volume(" << tmp << ") "; + } NbVolumeProp++; } if (XCAFDoc_Area::Get(L, tmp)) { if (PrintStructMode) + { di << "Area(" << tmp << ") "; + } NbAreaProp++; } occ::handle CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main()); @@ -382,13 +402,21 @@ static void StatAssembly(const TDF_Label L, bool IsColor = false; bool IsByLayer = false; if (CTool->GetColor(L, XCAFDoc_ColorGen, col)) + { IsColor = true; + } else if (CTool->GetColor(L, XCAFDoc_ColorSurf, col)) + { IsColor = true; + } else if (CTool->GetColor(L, XCAFDoc_ColorCurv, col)) + { IsColor = true; + } else if (CTool->IsColorByLayer(L)) + { IsByLayer = true; + } if (IsColor || IsByLayer) { if (IsByLayer) @@ -418,7 +446,9 @@ static void StatAssembly(const TDF_Label L, TCollection_AsciiString Entry1; Entry1 = col.GetRGB().StringName(col.GetRGB().Name()); if (PrintStructMode) + { di << "Color(" << Entry1.ToCString() << " " << col.Alpha() << ") "; + } NbShapesWithColor++; } } @@ -433,9 +463,13 @@ static void StatAssembly(const TDF_Label L, { TCollection_AsciiString Entry2(aLayerS->Value(i)); if (i == 1) + { di << "\"" << Entry2.ToCString() << "\""; + } else + { di << " \"" << Entry2.ToCString() << "\""; + } } di << ") "; } @@ -458,7 +492,9 @@ static void StatAssembly(const TDF_Label L, NbShapesWithVisMaterial++; } if (PrintStructMode) + { di << "\n"; + } HAI->SetValue(level, HAI->Value(level) + 1); if (L.HasChild()) @@ -505,9 +541,13 @@ static int statdoc(Draw_Interpretor& di, int argc, const char** argv) NCollection_Sequence SeqLabels; aTool->GetShapes(SeqLabels); if (SeqLabels.Length() <= 0) + { return 0; + } if (PrintStructMode) + { di << "\nStructure of shapes in the document:\n"; + } int level = 0; int NbCentroidProp = 0, NbVolumeProp = 0, NbAreaProp = 0; int NbShapesWithName = 0, NbShapesWithColor = 0, NbShapesWithLayer = 0, @@ -515,7 +555,9 @@ static int statdoc(Draw_Interpretor& di, int argc, const char** argv) occ::handle> HAI = new NCollection_HArray1(0, 20); int i = 0; for (i = 0; i <= 20; i++) + { HAI->SetValue(i, 0); + } for (i = 1; i <= SeqLabels.Length(); i++) { StatAssembly(SeqLabels.Value(i), @@ -537,7 +579,9 @@ static int statdoc(Draw_Interpretor& di, int argc, const char** argv) for (i = 0; i <= 20; i++) { if (HAI->Value(i) == 0) + { break; + } // di<<"level N "<Value(i) << "\n"; NbLabelsShape = NbLabelsShape + HAI->Value(i); @@ -1106,7 +1150,9 @@ static int XAttributeValue(Draw_Interpretor& di, int argc, const char** argv) int num = Draw::Atoi(argv[3]); TDF_AttributeIterator itr(lab, false); for (int i = 1; itr.More() && i < num; i++) + { itr.Next(); + } if (!itr.More()) { @@ -1133,7 +1179,9 @@ static int setviewName(Draw_Interpretor& di, int argc, const char** argv) } bool mode = false; if (Draw::Atoi(argv[1]) == 1) + { mode = true; + } XCAFPrs::SetViewNameMode(mode); return 0; } @@ -1143,9 +1191,13 @@ static int setviewName(Draw_Interpretor& di, int argc, const char** argv) static int getviewName(Draw_Interpretor& di, int /*argc*/, const char** /*argv*/) { if (XCAFPrs::GetViewNameMode()) + { di << "Display names ON\n"; + } else + { di << "Display names OFF\n"; + } return 0; } @@ -1472,7 +1524,9 @@ static int XDumpAssemblyTree(Draw_Interpretor& di, int argc, const char** argv) anIt.Next(), aFirst = false) { if (!aFirst) + { aSS << "/"; + } TDF_Label aL; TDF_Tool::Label(aDoc->GetData(), anIt.Value(), aL, false); if (!aL.IsNull()) @@ -1488,11 +1542,11 @@ static int XDumpAssemblyTree(Draw_Interpretor& di, int argc, const char** argv) } aSS << anIt.Value(); } - aSS << std::endl; + aSS << '\n'; } else { - aSS << theItem.ToString() << std::endl; + aSS << theItem.ToString() << '\n'; } return true; }); @@ -1603,7 +1657,7 @@ static int XDumpAssemblyGraph(Draw_Interpretor& di, int argc, const char** argv) aSS << " " << anIt1.Key(); } } - aSS << std::endl; + aSS << '\n'; return true; }); @@ -1680,7 +1734,7 @@ static int XDumpNomenclature(Draw_Interpretor& di, int argc, const char** argv) } aSS << theNode << " " << graphNodeTypename(aNodeType) << " " << aNodeEntry << " " - << theGraph->NbOccurrences(theNode) << std::endl; + << theGraph->NbOccurrences(theNode) << '\n'; return true; }); @@ -1758,12 +1812,14 @@ static int testDoc(Draw_Interpretor&, int argc, const char** argv) { if (argc < 2) { - std::cout << "Invalid numbers of arguments should be: XTestDoc shape" << std::endl; + std::cout << "Invalid numbers of arguments should be: XTestDoc shape" << '\n'; return 1; } TopoDS_Shape shape = DBRep::Get(argv[1]); if (shape.IsNull()) + { return 1; + } occ::handle anApp = DDocStd::GetApplication(); @@ -1790,7 +1846,9 @@ static int testDoc(Draw_Interpretor&, int argc, const char** argv) } if (aLab.FindAttribute(TPrsStd_AISPresentation::GetID(), prs)) + { prs->Display(); + } TPrsStd_AISViewer::Update(aLab); ViewerTest::GetAISContext()->Display(aTriShape, true); diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Common.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Common.cxx index 60cc438c92..2b03fb4423 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Common.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Common.cxx @@ -110,7 +110,9 @@ static int FromShape(Draw_Interpretor& theDI, int theNbArgs, const char** theArg Sprintf(command, "fromshape %.200s -1", theArgVec[1]); const XSControl_WorkSessionMap& DictWS = XSDRAW::WorkSessionList(); if (DictWS.IsEmpty()) + { return theDI.Eval(command); + } occ::handle aWS = XSDRAW::Session(); for (XSControl_WorkSessionMap::Iterator DicIt(DictWS); DicIt.More(); DicIt.Next()) @@ -149,7 +151,9 @@ static int Expand(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); bool recurs = false; if (atoi(theArgVec[2]) != 0) + { recurs = true; + } if (theNbArgs == 3) { diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_GDTs.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_GDTs.cxx index 8b7418e0de..f604a77628 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_GDTs.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_GDTs.cxx @@ -158,9 +158,13 @@ static int DumpDGTs(Draw_Interpretor& di, int argc, const char** argv) } } if (aDimTolObj->HasQualifier()) + { di << ", Q " << aDimTolObj->GetQualifier(); + } if (aDimTolObj->HasAngularQualifier()) + { di << ", AQ " << aDimTolObj->GetAngularQualifier(); + } if (aDimTolObj->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented) { gp_Dir aD; @@ -184,23 +188,35 @@ static int DumpDGTs(Draw_Interpretor& di, int argc, const char** argv) { TCollection_AsciiString aName; if (!aDimTolObj->GetConnectionName().IsNull()) + { aName = aDimTolObj->GetConnectionName()->String(); + } di << " Conn1 \"" << aName << "\" "; if (aDimTolObj->IsPointConnection()) + { di << "P,"; + } else + { di << "CS,"; + } } if (aDimTolObj->HasPoint2()) { TCollection_AsciiString aName; if (!aDimTolObj->GetConnectionName2().IsNull()) + { aName = aDimTolObj->GetConnectionName2()->String(); + } di << " Conn2 \"" << aName << "\" "; if (aDimTolObj->IsPointConnection2()) + { di << "P,"; + } else + { di << "CS,"; + } } di << " )"; } @@ -394,7 +410,9 @@ static int DumpNbDGTs(Draw_Interpretor& di, int argc, const char** argv) { char aChar = argv[2][0]; if (aChar == 'f') + { isFull = true; + } } occ::handle Doc; DDocStd::GetDocument(argv[1], Doc); @@ -423,10 +441,14 @@ static int DumpNbDGTs(Draw_Interpretor& di, int argc, const char** argv) { occ::handle aDimAttr; if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr)) + { continue; + } occ::handle anObject = aDimAttr->GetObject(); if (anObject.IsNull()) + { continue; + } XCAFDimTolObjects_DimensionType aDimType = anObject->GetType(); if (aDimType == XCAFDimTolObjects_DimensionType_CommonLabel) { @@ -478,10 +500,14 @@ static int DumpNbDGTs(Draw_Interpretor& di, int argc, const char** argv) { occ::handle aGTAttr; if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) + { continue; + } occ::handle anObject = aGTAttr->GetObject(); if (anObject.IsNull()) + { continue; + } if (anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) { @@ -491,14 +517,18 @@ static int DumpNbDGTs(Draw_Interpretor& di, int argc, const char** argv) { bool isHasModif = false; for (int j = 1; j <= anObject->GetModifiers().Length(); j++) + { if (anObject->GetModifiers().Value(j) != XCAFDimTolObjects_GeomToleranceModif_All_Around && anObject->GetModifiers().Value(j) != XCAFDimTolObjects_GeomToleranceModif_All_Over) { isHasModif = true; break; } + } if (isHasModif) + { nbWithModif++; + } } if (anObject->GetMaxValueModifier() != 0) { @@ -543,7 +573,9 @@ static int DumpNbDGTs(Draw_Interpretor& di, int argc, const char** argv) } } if (isDatum) + { aCounter++; + } } } di << "\n NbOfDatumFeature : " << aCounter; @@ -606,9 +638,13 @@ static int addDim(Draw_Interpretor& di, int argc, const char** argv) TDF_Label aDimL = aDimTolTool->AddDimension(); if (aLabel1.IsNull()) + { aDimTolTool->SetDimension(aLabel, aDimL); + } else + { aDimTolTool->SetDimension(aLabel, aLabel1, aDimL); + } TCollection_AsciiString Entry; TDF_Tool::Entry(aDimL, Entry); di << Entry; @@ -682,9 +718,13 @@ static int addDatum(Draw_Interpretor& di, int argc, const char** argv) { TopoDS_Shape aShape = DBRep::Get(argv[i]); if (!aShape.IsNull()) + { aShapeTool->Search(aShape, aLabel); + } if (aLabel.IsNull()) + { continue; + } } aLabelSeq.Append(aLabel); } @@ -860,7 +900,9 @@ static int getDatum(Draw_Interpretor& di, int argc, const char** argv) for (int i = NCollection_Sequence::Lower(); i <= aD.Upper(); i++) { if (i > 1) + { di << ", "; + } TCollection_AsciiString Entry; TDF_Tool::Entry(aD.Value(i), Entry); di << Entry; @@ -940,7 +982,9 @@ static int getDatumModif(Draw_Interpretor& di, int argc, const char** argv) for (int i = 1; i <= aS.Length(); i++) { if (i > 1) + { di << ", "; + } switch (aS.Value(i)) { case 0: @@ -1655,7 +1699,9 @@ static int getTolModif(Draw_Interpretor& di, int argc, const char** argv) for (int i = 1; i <= aS.Length(); i++) { if (i > 1) + { di << ", "; + } switch (aS.Value(i)) { case 0: @@ -2700,7 +2746,9 @@ static int getDimModifier(Draw_Interpretor& di, int argc, const char** argv) for (int i = 1; i <= aS.Length(); i++) { if (i > 1) + { di << ", "; + } switch (aS.Value(i)) { case 0: @@ -3352,9 +3400,13 @@ static int getGDTAffectedPlane(Draw_Interpretor& di, int argc, const char** argv gp_Pln aPln = anObj->GetAffectedPlane(); aPlane = new Geom_Plane(aPln); if (anObj->GetAffectedPlaneType() == XCAFDimTolObjects_ToleranceZoneAffectedPlane_Intersection) + { di << "intersection plane\n"; + } if (anObj->GetAffectedPlaneType() == XCAFDimTolObjects_ToleranceZoneAffectedPlane_Orientation) + { di << "orientation plane\n"; + } DrawTrSurf::Set(argv[3], aPlane); } diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Layers.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Layers.cxx index 99e13c4ac3..b5f550b752 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Layers.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Layers.cxx @@ -101,7 +101,9 @@ static int removeLayer(Draw_Interpretor& di, int argc, const char** argv) aLabel = localLayerTool->FindLayer(aLayer); } if (aLabel.IsNull()) + { return 1; + } localLayerTool->RemoveLayer(aLabel); return 0; } @@ -115,7 +117,9 @@ static int setLayer(Draw_Interpretor& di, int argc, const char** argv) } bool shapeInOneLayer = false; if ((argc == 5) && (Draw::Atoi(argv[4]) == 1)) + { shapeInOneLayer = true; + } occ::handle Doc; DDocStd::GetDocument(argv[1], Doc); if (Doc.IsNull()) @@ -176,10 +180,12 @@ static int getLayers(Draw_Interpretor& di, int argc, const char** argv) } int i = 1; if (!aLayerS.IsNull() && aLayerS->Length() != 0) + { for (; i <= aLayerS->Length(); i++) { di << "\"" << aLayerS->Value(i) << "\" "; } + } return 0; } @@ -253,7 +259,9 @@ static int setLinkLayer(Draw_Interpretor& di, int argc, const char** argv) } bool shapeInOneLayer = false; if ((argc == 5) && (Draw::Atoi(argv[4]) == 1)) + { shapeInOneLayer = true; + } occ::handle Doc; DDocStd::GetDocument(argv[1], Doc); if (Doc.IsNull()) @@ -439,7 +447,9 @@ static int setVisibility(Draw_Interpretor& di, int argc, const char** argv) occ::handle localLayerTool = XCAFDoc_DocumentTool::LayerTool(Doc->Main()); bool isvisible = false; if ((argc == 4) && (Draw::Atoi(argv[3]) == 1)) + { isvisible = true; + } TDF_Label aLabel; TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); @@ -449,7 +459,9 @@ static int setVisibility(Draw_Interpretor& di, int argc, const char** argv) aLabel = localLayerTool->FindLayer(aLayer); } if (aLabel.IsNull()) + { return 1; + } localLayerTool->SetVisibility(aLabel, isvisible); return 0; } @@ -478,11 +490,17 @@ static int isVisible(Draw_Interpretor& di, int argc, const char** argv) aLabel = localLayerTool->FindLayer(aLayer); } if (aLabel.IsNull()) + { return 1; + } if (localLayerTool->IsVisible(aLabel)) + { di << 1; + } else + { di << 0; + } return 0; } diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Notes.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Notes.cxx index 3af01c363e..84daffbd7d 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Notes.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Notes.cxx @@ -1224,7 +1224,9 @@ static int noteDump(Draw_Interpretor& di, int argc, const char** argv) di << ss.str().c_str(); } if (aData->Length() > theMaxLen) + { di << " ..."; + } di << "\n"; } } @@ -1239,7 +1241,9 @@ static int noteDump(Draw_Interpretor& di, int argc, const char** argv) di << "[ " << aP.X() << " " << aP.Y() << " " << aP.Z() << " ]\n"; } else + { di << " not specified\n"; + } di << "plane : "; if (aNoteObj->HasPlane()) { @@ -1256,7 +1260,9 @@ static int noteDump(Draw_Interpretor& di, int argc, const char** argv) di << "[ " << aP.X() << " " << aP.Y() << " " << aP.Z() << " ]\n"; } else + { di << " not specified\n"; + } di << "presentation : " << (aNoteObj->GetPresentation().IsNull() ? "no" : "specified"); } @@ -1313,7 +1319,9 @@ static int noteRefDump(Draw_Interpretor& di, int argc, const char** argv) di << "Attribute : " << ss.str().c_str() << "\n"; } else if (aRef->IsSubshapeIndex()) + { di << "Subshape : " << aRef->GetSubshapeIndex() << "\n"; + } } di << "Orphan : " << (aRef->IsOrphan() ? "yes" : "no") << "\n"; diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Props.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Props.cxx index f156d8cdb8..1872f2f610 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Props.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Props.cxx @@ -93,9 +93,13 @@ static double TetraVol(gp_Pnt RefPoint, gp_Pnt Som1, gp_Pnt Som2, gp_Pnt Som3) gp_Vec Rad(RefPoint, Som1); if ((Rad * N) > 0) + { return (curVolume); + } else + { return (-curVolume); + } } //================================================================================================= @@ -127,6 +131,7 @@ static double CalculVolume(const TopoDS_Shape& So, TopoDS_Face F = TopoDS::Face(ex.Current()); TopLoc_Location L; if (!haveVertex) + { for (TopExp_Explorer Vex(F, TopAbs_VERTEX); Vex.More(); Vex.Next()) { TopoDS_Vertex v = TopoDS::Vertex(Vex.Current()); @@ -137,6 +142,7 @@ static double CalculVolume(const TopoDS_Shape& So, break; } } + } occ::handle facing = BRep_Tool::Triangulation(F, L); if (facing.IsNull() || withForce) @@ -152,9 +158,13 @@ static double CalculVolume(const TopoDS_Shape& So, Poly_Triangle trian = facing->Triangle(i); int index1, index2, index3; // M,N; if (F.Orientation() == TopAbs_REVERSED) + { trian.Get(index1, index3, index2); + } else + { trian.Get(index1, index2, index3); + } curVolume = TetraVol(aRefPoint, facing->Node(index1), facing->Node(index2), facing->Node(index3)); myVolume += curVolume; @@ -221,29 +231,39 @@ static int SetProps(Draw_Interpretor& di, int argc, const char** argv) // retrieve epsilon double anEps; if (argc > 3) + { anEps = Draw::Atof(argv[3]); + } else + { anEps = 0.001; + } GProp_GProps G; BRepGProp::VolumeProperties(aShape, G, anEps, true); Vres = G.Mass(); occ::handle aVolume = new XCAFDoc_Volume; if (!aLabel.FindAttribute(XCAFDoc_Volume::GetID(), aVolume)) + { aLabel.AddAttribute(aVolume); + } aVolume->Set(Vres); gp_Pnt aPoint = G.CentreOfMass(); occ::handle aCentroid = new XCAFDoc_Centroid; if (!aLabel.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) + { aLabel.AddAttribute(aCentroid); + } aCentroid->Set(aPoint); BRepGProp::SurfaceProperties(aShape, G, anEps); Ares = G.Mass(); occ::handle aArea = new XCAFDoc_Area; if (!aLabel.FindAttribute(XCAFDoc_Area::GetID(), aArea)) + { aLabel.AddAttribute(aArea); + } aArea->Set(Ares); di << argv[2] << ": Volume = " << Vres << ", Area = " << Ares << ", Centroid is (" << aPoint.X() @@ -287,7 +307,9 @@ static int SetVolume(Draw_Interpretor& di, int argc, const char** argv) res = Draw::Atof(argv[3]); occ::handle aVolume = new XCAFDoc_Volume; if (!aLabel.FindAttribute(XCAFDoc_Volume::GetID(), aVolume)) + { aLabel.AddAttribute(aVolume); + } aVolume->Set(res); } @@ -330,7 +352,9 @@ static int SetArea(Draw_Interpretor& di, int argc, const char** argv) res = Draw::Atof(argv[3]); occ::handle aArea = new XCAFDoc_Area; if (!aLabel.FindAttribute(XCAFDoc_Area::GetID(), aArea)) + { aLabel.AddAttribute(aArea); + } aArea->Set(res); } di << res; @@ -374,7 +398,9 @@ static int SetCentroid(Draw_Interpretor& di, int argc, const char** argv) aPoint.SetZ(Draw::Atof(argv[5])); occ::handle aCentroid = new XCAFDoc_Centroid; if (!aLabel.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) + { aLabel.AddAttribute(aCentroid); + } aCentroid->Set(aPoint); di << Draw::Atof(argv[3]) << " " << Draw::Atof(argv[4]) << " " << Draw::Atof(argv[5]); } @@ -416,7 +442,9 @@ static int GetVolume(Draw_Interpretor& di, int argc, const char** argv) // another case double aVol; if (XCAFDoc_Volume::Get(aLabel, aVol)) + { di << aVol; + } } return 0; } @@ -456,7 +484,9 @@ static int GetArea(Draw_Interpretor& di, int argc, const char** argv) // another case double anA; if (XCAFDoc_Area::Get(aLabel, anA)) + { di << anA; + } } return 0; } @@ -500,7 +530,9 @@ static int GetCentroid(Draw_Interpretor& di, int argc, const char** argv) // di << aPoint.X()<<" "< 2 && Draw::Atof(argv[2]) != 0) + { withVolFix = true; + } bool wholeDoc = (argc < 4); NCollection_Sequence seq; if (!wholeDoc) @@ -547,7 +581,9 @@ static int CheckProps(Draw_Interpretor& di, int argc, const char** argv) } } if (aLabel.IsNull()) + { return 1; + } seq.Append(aLabel); } else @@ -578,7 +614,9 @@ static int CheckProps(Draw_Interpretor& di, int argc, const char** argv) if (!lab.FindAttribute(XCAFDoc_Volume::GetID(), aVolume) && !lab.FindAttribute(XCAFDoc_Area::GetID(), aArea) && !lab.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) + { continue; + } seq.InsertAfter(m++, lab); } } @@ -596,7 +634,9 @@ static int CheckProps(Draw_Interpretor& di, int argc, const char** argv) di << " \"" << N->Get() << "\""; } if (!wholeDoc) + { di << "\n"; + } occ::handle aVolume; occ::handle aArea; @@ -775,7 +815,9 @@ static int ShapeVolume(Draw_Interpretor& di, int argc, const char** argv) } TopoDS_Shape aShape = DBRep::Get(argv[1]); if (aShape.IsNull()) + { return 1; + } gp_Pnt aPoint(0, 0, 0); double localVolume; double tol = Draw::Atof(argv[2]); @@ -821,7 +863,9 @@ static bool GetMassProps(const TDF_Label& aLabel, // S = TNaming_Tool::GetShape(NS); TopoDS_Shape aSh = NS->Get(); if (aSh.ShapeType() == TopAbs_SOLID) + { return false; + } } // TopoDS_Shape aSh = XCAFDoc_ShapeTool::GetShape(aLabel); @@ -842,7 +886,9 @@ static bool GetMassProps(const TDF_Label& aLabel, return true; } else + { return false; + } } else { @@ -850,7 +896,9 @@ static bool GetMassProps(const TDF_Label& aLabel, NCollection_Sequence comp; XCAFDoc_ShapeTool::GetComponents(aLabel, comp); if (!comp.Length()) + { return false; + } NCollection_Array1 anArrCentres(1, comp.Length()); NCollection_Array1 anArrMass(1, comp.Length()); @@ -906,7 +954,9 @@ static int ShapeMassProps(Draw_Interpretor& di, int argc, const char** argv) DDocStd::GetDocument(argv[1], Doc); double atol = Precision::Confusion(); if (argc > 2) + { atol = Draw::Atof(argv[2]); + } if (Doc.IsNull()) { di << argv[1] << " is not a document\n"; @@ -929,7 +979,9 @@ static int ShapeMassProps(Draw_Interpretor& di, int argc, const char** argv) } } if (aLabel.IsNull()) + { return 1; + } seq.Append(aLabel); } else @@ -1016,7 +1068,9 @@ static int GetValidationProps(Draw_Interpretor& di, int argc, const char** argv) occ::handle STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); NCollection_Sequence aLabels; if (argc == 2) + { STool->GetShapes(aLabels); + } else { TDF_Label aLabel; @@ -1030,7 +1084,9 @@ static int GetValidationProps(Draw_Interpretor& di, int argc, const char** argv) aLabel = STool->FindShape(aShape); } if (!aLabel.IsNull()) + { aLabels.Append(aLabel); + } } enum @@ -1043,7 +1099,9 @@ static int GetValidationProps(Draw_Interpretor& di, int argc, const char** argv) int nbProps[3]; int j = 0; for (; j <= Centroid; j++) + { nbProps[j] = 0; + } int i = 1; for (; i <= aLabels.Length(); i++) { @@ -1060,7 +1118,9 @@ static int GetValidationProps(Draw_Interpretor& di, int argc, const char** argv) occ::handle aCentroid = new (XCAFDoc_Centroid); if (aLabel.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid)) + { XCAFDoc_Centroid::Get(aLabel, aP); + } if (aProp[Vol] > 0 || aProp[Area] > 0 || !Precision::IsInfinite(aP.X())) { @@ -1088,7 +1148,9 @@ static int GetValidationProps(Draw_Interpretor& di, int argc, const char** argv) di << "=========================================================" << "\n"; di << "Number of the validation properties : "; for (i = Vol; i <= Centroid; i++) + { di << (i == Vol ? "Volume" : (i == Area ? "Area" : "Centroid")) << " : " << nbProps[i] << " ; "; + } di << "\n"; return 0; diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Shapes.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Shapes.cxx index 5abc39ef5c..b80b77e6c9 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Shapes.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Shapes.cxx @@ -75,11 +75,15 @@ static int addShape(Draw_Interpretor& di, int argc, const char** argv) occ::handle myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); bool makeAssembly = true; if (argc == 4 && Draw::Atoi(argv[3]) == 0) + { makeAssembly = false; + } TDF_Label aLabel; aLabel = myAssembly->AddShape(aShape, makeAssembly); if (aLabel.IsNull()) + { di << "Null Label\n"; + } TCollection_AsciiString Entry; TDF_Tool::Entry(aLabel, Entry); di << Entry.ToCString(); @@ -201,7 +205,9 @@ static int removeShape(Draw_Interpretor& di, int argc, const char** argv) occ::handle myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); bool removeCompletely = true; if (argc == 4 && Draw::Atoi(argv[3]) == 0) + { removeCompletely = false; + } myAssembly->RemoveShape(aLabel, removeCompletely); return 0; @@ -384,7 +390,9 @@ static int getUsers(Draw_Interpretor& di, int argc, const char** argv) } bool getsubchilds = false; if ((argc == 4) && (Draw::Atoi(argv[3]) == 1)) + { getsubchilds = true; + } occ::handle Doc; DDocStd::GetDocument(argv[1], Doc); @@ -414,7 +422,9 @@ static int nbComponents(Draw_Interpretor& di, int argc, const char** argv) } bool getsubchilds = false; if ((argc == 4) && (Draw::Atoi(argv[3]) == 1)) + { getsubchilds = true; + } occ::handle Doc; DDocStd::GetDocument(argv[1], Doc); if (Doc.IsNull()) @@ -679,7 +689,9 @@ static int XDumpLocation(Draw_Interpretor& di, int argc, const char** argv) for (int j = 1; j <= 4; j++) // column number { if (j > 1) + { di << ","; + } di << TCollection_AsciiString(aTrsf.Value(i, j)).ToCString(); } di << ")"; @@ -709,9 +721,13 @@ static int setSHUO(Draw_Interpretor& di, int argc, const char** argv) TDF_Label L; TDF_Tool::Label(Doc->GetData(), argv[i - 1], L); if (!L.IsNull()) + { aLabSeq.Append(L); + } else + { di << argv[i - 1] << " is null label" << "\n"; + } } if (aLabSeq.Length() < 2) { @@ -854,9 +870,13 @@ static int hasSHUO(Draw_Interpretor& di, int argc, const char** argv) occ::handle anAttrSHUO; occ::handle myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (myAssembly->GetSHUO(UL, anAttrSHUO)) + { di << 1; + } else + { di << 0; + } return 0; } @@ -950,7 +970,9 @@ static int getStyledComponent(Draw_Interpretor& di, int argc, const char** argv) TDF_Tool::Label(Doc->GetData(), argv[3], aLabel); occ::handle SHUO; if (myAssembly->GetSHUO(aLabel, SHUO)) + { aShape = myAssembly->GetSHUOInstance(SHUO); + } if (aShape.IsNull()) { @@ -982,6 +1004,7 @@ static int getAllStyledComponents(Draw_Interpretor& di, int argc, const char** a TDF_Tool::Label(Doc->GetData(), argv[3], aLabel); occ::handle SHUO; if (myAssembly->GetSHUO(aLabel, SHUO)) + { if (myAssembly->GetAllSHUOInstances(SHUO, aShapes)) { TopoDS_Compound aShape; @@ -995,6 +1018,7 @@ static int getAllStyledComponents(Draw_Interpretor& di, int argc, const char** a DBRep::Set(argv[2], aShape); di << argv[2]; } + } return 0; } @@ -1020,9 +1044,13 @@ static int findSHUO(Draw_Interpretor& di, int argc, const char** argv) TDF_Label L; TDF_Tool::Label(Doc->GetData(), argv[i - 1], L); if (!L.IsNull()) + { aLabSeq.Append(L); + } else + { di << argv[i - 1] << " is null label" << "\n"; + } } if (aLabSeq.Length() < 2) { @@ -1090,7 +1118,9 @@ static int updateAssemblies(Draw_Interpretor& di, int argc, const char** argv) occ::handle aDoc; DDocStd::GetDocument(argv[1], aDoc); if (aDoc.IsNull()) + { return 1; + } // Get XDE shape tool occ::handle aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); diff --git a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Views.cxx b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Views.cxx index 1ab953673a..b7d6294c17 100644 --- a/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Views.cxx +++ b/src/Draw/TKXDEDRAW/XDEDRAW/XDEDRAW_Views.cxx @@ -57,16 +57,24 @@ static int setView(Draw_Interpretor& di, int argc, const char** argv) TDF_Label aLabel; TDF_Tool::Label(aDoc->GetData(), argv[i], aLabel); if (aLabel.IsNull()) + { continue; + } if (aShapeTool->IsShape(aLabel)) + { aShapes.Append(aLabel); + } else if (aDimTolTool->IsDatum(aLabel) || aDimTolTool->IsDimension(aLabel) || aDimTolTool->IsGeomTolerance(aLabel)) + { aGDTs.Append(aLabel); + } } if (aShapes.Length() == 0 && aGDTs.Length() == 0) + { return 1; + } TDF_Label aViewL = aViewTool->AddView(); aViewTool->SetView(aShapes, aGDTs, aViewL); @@ -131,13 +139,19 @@ static int setClippingPlanes(Draw_Interpretor& di, int argc, const char** argv) TDF_Label aLabel; TDF_Tool::Label(aDoc->GetData(), argv[i], aLabel); if (aLabel.IsNull()) + { continue; + } if (aCPlaneTool->IsClippingPlane(aLabel)) + { aCPlanes.Append(aLabel); + } } if (aCPlanes.Length() == 0) + { return 1; + } TDF_Label aViewL; TDF_Tool::Label(aDoc->GetData(), argv[2], aViewL); @@ -172,9 +186,13 @@ static int isView(Draw_Interpretor& di, int argc, const char** argv) } if (aViewTool->IsView(aLabel)) + { di << "1"; + } else + { di << "0"; + } return 0; } @@ -397,9 +415,13 @@ static int setType(Draw_Interpretor& di, int argc, const char** argv) occ::handle anObj = aView->GetObject(); XCAFView_ProjectionType aType = XCAFView_ProjectionType_NoCamera; if (argv[3][0] == 'c') + { aType = XCAFView_ProjectionType_Central; + } else if (argv[3][0] == 'p') + { aType = XCAFView_ProjectionType_Parallel; + } anObj->SetType(aType); aView->SetObject(anObj); } @@ -896,9 +918,13 @@ static int getFrontPlaneDistance(Draw_Interpretor& di, int argc, const char** ar if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) { if (aView->GetObject()->HasFrontPlaneClipping()) + { di << aView->GetObject()->FrontPlaneDistance(); + } else + { di << "View has not front plane clipping\n"; + } } return 0; } @@ -1002,9 +1028,13 @@ static int getBackPlaneDistance(Draw_Interpretor& di, int argc, const char** arg if (aLabel.FindAttribute(XCAFDoc_View::GetID(), aView)) { if (aView->GetObject()->HasBackPlaneClipping()) + { di << aView->GetObject()->BackPlaneDistance(); + } else + { di << "View has not back plane clipping\n"; + } } return 0; } @@ -1168,14 +1198,22 @@ static int dump(Draw_Interpretor& di, int argc, const char** argv) << aView->GetObject()->WindowVerticalSize() << "\n"; if (aView->GetObject()->HasFrontPlaneClipping()) + { di << "Front Plane Distance: " << aView->GetObject()->FrontPlaneDistance() << "\n"; + } else + { di << "No Front Plane\n"; + } if (aView->GetObject()->HasFrontPlaneClipping()) + { di << "Front Back Distance: " << aView->GetObject()->BackPlaneDistance() << "\n"; + } else + { di << "No Back Plane\n"; + } di << "View VolumeSized Clipping: " << aView->GetObject()->HasViewVolumeSidesClipping() << "\n"; @@ -1204,7 +1242,7 @@ static int addClippingPlane(Draw_Interpretor& di, int argc, const char** argv) occ::handle aSurf = occ::down_cast(DrawTrSurf::GetSurface(argv[2])); if (aSurf.IsNull()) { - std::cout << argv[2] << " is not a plane" << std::endl; + std::cout << argv[2] << " is not a plane" << '\n'; return 1; } aPlane = aSurf->Pln(); @@ -1282,9 +1320,13 @@ static int removeClippingPlane(Draw_Interpretor& di, int argc, const char** argv } bool isRemoved = aClippingPlaneTool->RemoveClippingPlane(aLabel); if (isRemoved) + { di << "removed\n"; + } else + { di << "clipping plane is not free, not removed\n"; + } return 0; } diff --git a/src/Draw/TKXSDRAW/XSDRAW/XSDRAW.cxx b/src/Draw/TKXSDRAW/XSDRAW/XSDRAW.cxx index 893c5dcdd6..584f3b020b 100644 --- a/src/Draw/TKXSDRAW/XSDRAW/XSDRAW.cxx +++ b/src/Draw/TKXSDRAW/XSDRAW/XSDRAW.cxx @@ -105,9 +105,13 @@ static int XSTEPDRAWRUN(Draw_Interpretor& di, int argc, const char** argv) aMsgMgr->ChangePrinters().Append(aPrinters); if (stat == IFSelect_RetError || stat == IFSelect_RetFail) + { return 1; + } else + { return 0; + } } void XSDRAW::ChangeCommand(const char* const oldname, const char* const newname) @@ -116,7 +120,9 @@ void XSDRAW::ChangeCommand(const char* const oldname, const char* const newname) if (newname[0] != '\0') { if (thenews.IsNull()) + { thenews = new NCollection_HSequence(); + } TCollection_AsciiString newstr(newname); thenews->Append(newstr); num = thenews->Length(); @@ -132,7 +138,9 @@ void XSDRAW::RemoveCommand(const char* const oldname) bool XSDRAW::LoadSession() { if (deja) + { return false; + } deja = 1; thepilot = new IFSelect_SessionPilot("XSTEP-DRAW>"); occ::handle WS = new XSControl_WorkSession; @@ -222,13 +230,21 @@ const occ::handle XSDRAW::Session() void XSDRAW::SetController(const occ::handle& control) { if (thepilot.IsNull()) + { XSDRAW::LoadSession(); + } if (control.IsNull()) - std::cout << "XSTEP Controller not defined" << std::endl; + { + std::cout << "XSTEP Controller not defined" << '\n'; + } else if (!Session().IsNull()) + { Session()->SetController(control); + } else - std::cout << "XSTEP Session badly or not defined" << std::endl; + { + std::cout << "XSTEP Session badly or not defined" << '\n'; + } } occ::handle XSDRAW::Controller() @@ -255,7 +271,9 @@ void XSDRAW::SetModel(const occ::handle& model, const { thepilot->Session()->SetModel(model); if (file && file[0] != '\0') + { thepilot->Session()->SetLoadedFile(file); + } } occ::handle XSDRAW::NewModel() @@ -280,13 +298,17 @@ void XSDRAW::SetTransferProcess(const occ::handle& ATP) // Cas FinderProcess ==> TransferWriter if (!FP.IsNull()) + { Session()->SetMapWriter(FP); + } // Cas TransientProcess ==> TransferReader if (!TP.IsNull()) { if (!TP->Model().IsNull() && TP->Model() != Session()->Model()) + { Session()->SetModel(TP->Model()); + } Session()->SetMapReader(TP); } } @@ -339,7 +361,9 @@ occ::handle>> XSDRAW::GetL std::cin.get(terminateSymbol); if (terminateSymbol == '\n') + { return XSDRAW::GetList(aLineFirst.c_str(), nullptr); + } else { std::string aLineSecond; diff --git a/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx b/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx index 224643997f..540c352af8 100644 --- a/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx +++ b/src/Draw/TKXSDRAWIGES/XSDRAWIGES/XSDRAWIGES.cxx @@ -63,7 +63,7 @@ void WriteShape(const TopoDS_Shape& shape, const int number) char fname[110]; Sprintf(fname, "Shape_%d", number); std::ofstream f(fname, std::ios::out | std::ios::binary); - std::cout << "Output file name : " << fname << std::endl; + std::cout << "Output file name : " << fname << '\n'; f << "DBRep_DrawableShape\n"; BRepTools::Write(shape, f); @@ -78,7 +78,9 @@ TCollection_AsciiString XSDRAW_CommandPart(int argc, const char** argv, const in for (int i = argf; i < argc; i++) { if (i > argf) + { res.AssignCat(" "); + } res.AssignCat(argv[i]); } return res; @@ -98,11 +100,15 @@ static int GiveEntityNumber(const occ::handle& WS, const std::cin >> ligne; // std::cin.clear(); std::cin.getline (ligne,79); if (ligne[0] == '\0') + { return 0; + } num = WS->NumberFromLabel(ligne); } else + { num = WS->NumberFromLabel(name); + } return num; } @@ -119,28 +125,46 @@ bool FileAndVar(const occ::handle& session, resfile.Clear(); resvar.Clear(); if (file) + { if (file[0] == '\0' || (file[0] == '.' && file[1] == '\0')) + { iafic = false; + } + } if (!iafic) + { resfile.AssignCat(session->LoadedFile()); + } else + { resfile.AssignCat(file); + } if (var && var[0] != '\0' && (var[0] != '.' || var[1] != '\0')) + { resvar.AssignCat(var); + } else if (resfile.Length() == 0) + { resvar.AssignCat(def); + } else { int nomdeb, nomfin; nomdeb = resfile.SearchFromEnd("/"); if (nomdeb <= 0) + { nomdeb = resfile.SearchFromEnd("\\"); // pour NT + } if (nomdeb < 0) + { nomdeb = 0; + } nomfin = resfile.SearchFromEnd("."); if (nomfin < nomdeb) + { nomfin = resfile.Length() + 1; + } resvar = resfile.SubString(nomdeb + 1, nomfin - 1); } return iafic; @@ -170,9 +194,13 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV bool modfic = FileAndVar(aWS, theArgVec[1], theArgVec[2], "IGESBREP", fnom, rnom); if (modfic) + { theDI << " File IGES to read : " << fnom.ToCString() << "\n"; + } else + { theDI << " Model taken from the session : " << fnom.ToCString() << "\n"; + } theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n"; IFSelect_ReturnStatus readstat = IFSelect_RetVoid; @@ -187,27 +215,39 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV progress->Show(aPSRoot); if (modfic) + { readstat = Reader.ReadFile(fnom.ToCString()); + } else if (XSDRAW::Session()->NbStartingEntities() > 0) + { readstat = IFSelect_RetDone; + } aPSRoot.Next(20); // On average loading takes 20% if (aPSRoot.UserBreak()) + { return 1; + } if (readstat != IFSelect_RetDone) { if (modfic) + { theDI << "Could not read file " << fnom.ToCString() << " , abandon\n"; + } else + { theDI << "No model loaded\n"; + } return 1; } // Choice of treatment bool fromtcl = (theNbArgs > 3); int modepri = 1, nent, nbs; if (fromtcl) + { modepri = 4; + } while (modepri) { @@ -252,11 +292,15 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV progress->Show(aPSRoot); if (modepri == 1) + { Reader.SetReadVisible(true); + } Reader.TransferRoots(aPSRoot.Next(80)); if (aPSRoot.UserBreak()) + { return 1; + } // result in only one shape for all the roots // or in one shape for one root. @@ -276,7 +320,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV answer = Draw::Atoi(str_a); } if (answer == 0) + { continue; + } if (answer == 1 || answer == 3) { TopoDS_Shape shape = Reader.OneShape(); @@ -290,7 +336,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV Sprintf(fname, "%s", rnom.ToCString()); theDI << "Saving shape in variable Draw : " << fname << "\n"; if (answer == 3) + { WriteShape(shape, 1); + } try { OCC_CATCH_SIGNALS @@ -322,7 +370,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV Sprintf(fname, "%s_%d", rnom.ToCString(), inum); theDI << "Saving shape in variable Draw : " << fname << "\n"; if (answer == 4) + { WriteShape(shape, inum); + } try { OCC_CATCH_SIGNALS @@ -337,21 +387,25 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV } } else + { return 0; + } } else if (modepri == 3) { // One Entity - std::cout << "Only One Entity" << std::endl; + std::cout << "Only One Entity" << '\n'; std::cout << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") - << " (0 : no modif, 1 : C1, 2 : C2)" << std::endl; - std::cout << " To modify : command param read.iges.bspline.continuity" << std::endl; + << " (0 : no modif, 1 : C1, 2 : C2)" << '\n'; + std::cout << " To modify : command param read.iges.bspline.continuity" << '\n'; std::cout << " give the number of the Entity : " << std::flush; nent = GiveEntityNumber(aWS, ""); if (!Reader.TransferOne(nent)) + { theDI << "Transfer entity n0 " << nent << " : no result\n"; + } else { nbs = Reader.NbShapes(); @@ -390,7 +444,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV Reader.TransferRoots(aPSRoot.Next(80)); if (aPSRoot.UserBreak()) + { return 1; + } // result in only one shape for all the roots TopoDS_Shape shape = Reader.OneShape(); @@ -441,7 +497,7 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV list = XSDRAW::Session()->GiveList(""); if (list.IsNull()) { - std::cout << "No list defined" << std::endl; + std::cout << "No list defined" << '\n'; continue; } } @@ -449,7 +505,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV int nbl = list->Length(); theDI << "Nb entities selected : " << nbl << "\n"; if (nbl == 0) + { continue; + } while (answer) { if (!fromtcl) @@ -465,7 +523,9 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV answer = Draw::Atoi(str_answer); } if (answer <= 0 || answer > 3) + { continue; + } if (answer == 3) { for (int ill = 1; ill <= nbl; ill++) @@ -488,9 +548,13 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV { nent = Reader.Model()->Number(list->Value(ill)); if (nent == 0) + { continue; + } if (!Reader.TransferOne(nent, aPS.Next())) + { theDI << "Transfer entity n0 " << nent << " : no result\n"; + } else { nbs = Reader.NbShapes(); @@ -504,14 +568,18 @@ static int igesbrep(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV } } if (aPSRoot.UserBreak()) + { return 1; + } theDI << "Nb Shapes successfully produced : " << nbt << "\n"; answer = 0; // on ne reboucle pas } } } else + { theDI << "Unknown mode n0 " << modepri << "\n"; + } } return 0; } @@ -596,7 +664,9 @@ static int brepiges(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV { const char* aVariableName = theArgVec[i]; if (theArgVec[i][0] == '+') + { aVariableName = &(theArgVec[i])[1]; + } else if (i > 1) { aFileName = theArgVec[i]; @@ -605,16 +675,24 @@ static int brepiges(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV TopoDS_Shape aShape = DBRep::Get(aVariableName); if (anIgesWriter.AddShape(aShape, aStepProgress.Next())) + { aNumShapesProcessed++; + } else if (anIgesWriter.AddGeom(DrawTrSurf::GetCurve(aVariableName))) + { aNumShapesProcessed++; + } else if (anIgesWriter.AddGeom(DrawTrSurf::GetSurface(aVariableName))) + { aNumShapesProcessed++; + } } anIgesWriter.ComputeModel(); if (aRootProgress.UserBreak()) + { return 1; + } aRootProgress.SetName("Writing"); aProgress->Show(aRootProgress); @@ -846,7 +924,9 @@ static int XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI, int theNbArgs, const char* { char a2 = anArg1[1]; if (a2 == '\0') + { a2 = '!'; + } switch (anArg1[0]) { case 'g': @@ -873,7 +953,9 @@ static int XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI, int theNbArgs, const char* } } if (aMode < -1) + { theDI << "Unknown Mode\n"; + } if (aMode < 0) { theDI << "Modes available :\n" @@ -881,7 +963,9 @@ static int XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI, int theNbArgs, const char* << "r : number of CasCade resulting shapes\n" << "s : mapping between IGES entities and CasCade shapes\n"; if (aMode < -1) + { return -1; + } return 0; } return 0; @@ -921,14 +1005,20 @@ static int ReadIges(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV DeclareAndCast(IGESControl_Controller, aController, XSDRAW::Controller()); if (aController.IsNull()) + { XSDRAW::SetNorm("IGES"); + } TCollection_AsciiString aFileName, aModelName; bool isModified = XSDRAW::FileAndVar(theArgVec[2], theArgVec[1], "IGES", aFileName, aModelName); if (isModified) + { theDI << " File IGES to read : " << aFileName.ToCString() << "\n"; + } else + { theDI << " Model taken from the session : " << aModelName.ToCString() << "\n"; + } IGESCAFControl_Reader aReader(XSDRAW::Session(), isModified); int onlyVisible = Interface_Static::IVal("read.iges.onlyvisible"); @@ -938,6 +1028,7 @@ static int ReadIges(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV { bool mode = true; for (int i = 0; theArgVec[3][i]; i++) + { switch (theArgVec[3][i]) { case '-': @@ -956,6 +1047,7 @@ static int ReadIges(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV aReader.SetLayerMode(mode); break; } + } } occ::handle aProgress = new Draw_ProgressIndicator(theDI); Message_ProgressScope aRootScope(aProgress->Start(), "IGES import", isModified ? 2 : 1); @@ -1040,6 +1132,7 @@ static int WriteIges(Draw_Interpretor& theDI, int theNbArgs, const char** theArg { bool mode = true; for (int i = 0; theArgVec[3][i]; i++) + { switch (theArgVec[3][i]) { case '-': @@ -1058,6 +1151,7 @@ static int WriteIges(Draw_Interpretor& theDI, int theNbArgs, const char** theArg aWriter.SetLayerMode(mode); break; } + } } XSAlgo_ShapeProcessor::ProcessingData aProcessingData = XSAlgo_ShapeProcessor::ReadProcessingData("write.iges.resource.name", "write.iges.sequence"); diff --git a/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx index 93dae13020..b6d9c4c064 100644 --- a/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/Draw/TKXSDRAWSTEP/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -76,9 +76,13 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV TCollection_AsciiString fnom, rnom; bool modfic = XSDRAW::FileAndVar(theArgVec[1], theArgVec[2], "STEP", fnom, rnom); if (modfic) + { theDI << " File STEP to read : " << fnom.ToCString() << "\n"; + } else + { theDI << " Model taken from the session : " << fnom.ToCString() << "\n"; + } theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n"; IFSelect_ReturnStatus readstat = IFSelect_RetVoid; @@ -101,33 +105,51 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV k++; } else + { fromtcl = true; + } } if (!fromtcl) + { fromtcl = theNbArgs > k; + } if (aFullMode) + { std::cout << "Full model for translation with additional info will be used \n" << std::flush; + } else + { std::cout << "Reduced model for translation without additional info will be used \n" << std::flush; + } sr.WS()->SetModeStat(aFullMode); if (modfic) + { readstat = sr.ReadFile(fnom.ToCString()); + } else if (XSDRAW::Session()->NbStartingEntities() > 0) + { readstat = IFSelect_RetDone; + } aPSRoot.Next(20); // On average loading takes 20% if (aPSRoot.UserBreak()) + { return 1; + } if (readstat != IFSelect_RetDone) { if (modfic) + { theDI << "Could not read file " << fnom.ToCString() << " , abandon\n"; + } else + { theDI << "No model loaded\n"; + } return 1; } @@ -140,7 +162,9 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV // nom = "." -> fichier deja lu int i, num, nbs, modepri = 1; if (fromtcl) + { modepri = 4; + } while (modepri) { num = sr.NbRootsForTransfer(); @@ -178,7 +202,9 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV progress->Show(aPSRoot); if (!sr.TransferRoot(num, aPSRoot.Next(80))) + { theDI << "Transfer root n0 " << num << " : no result\n"; + } else { nbs = sr.NbShapes(); @@ -190,14 +216,18 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV DBRep::Set(shname, sh); } if (aPSRoot.UserBreak()) + { return 1; + } } else if (modepri == 3) { std::cout << "Entity : " << std::flush; num = XSDRAW::GetEntityNumber(""); if (!sr.TransferOne(num)) + { theDI << "Transfer entity n0 " << num << " : no result\n"; + } else { nbs = sr.NbShapes(); @@ -231,7 +261,9 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV { theDI << "List given by " << theArgVec[k]; if (theNbArgs > k + 1) + { theDI << " " << theArgVec[k + 1]; + } theDI << " : "; list = XSDRAW::Session()->GiveList(theArgVec[k], (theNbArgs > (k + 1) ? theArgVec[k + 1] : nullptr)); @@ -256,7 +288,9 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV int ill, nbl = list->Length(); theDI << "Nb entities selected : " << nbl << "\n"; if (nbl == 0) + { continue; + } aPSRoot.SetName("Translation"); progress->Show(aPSRoot); @@ -266,9 +300,13 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV { num = sr.Model()->Number(list->Value(ill)); if (num == 0) + { continue; + } if (!sr.TransferOne(num, aPS.Next())) + { theDI << "Transfer entity n0 " << num << " : no result\n"; + } else { nbs = sr.NbShapes(); @@ -281,10 +319,14 @@ static int stepread(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV } } if (aPSRoot.UserBreak()) + { return 1; + } } else + { theDI << "Unknown mode n0 " << modepri << "\n"; + } } return 0; } @@ -382,11 +424,17 @@ static int steptrans(Draw_Interpretor& theDI, int theNbArgs, const char** theArg int n1 = 0, n2 = 0; n1 = XSDRAW::GetEntityNumber(theArgVec[3]); if (theNbArgs > 4) + { n2 = XSDRAW::GetEntityNumber(theArgVec[4]); + } if (n1 > 0) + { ax1 = occ::down_cast(aWS->StartingEntity(n1)); + } if (n2 > 0) + { ax2 = occ::down_cast(aWS->StartingEntity(n2)); + } StepData_Factors aFactors; StepToTopoDS_MakeTransformed mktrans; if (mktrans.Compute(ax1, ax2, aFactors)) @@ -397,7 +445,9 @@ static int steptrans(Draw_Interpretor& theDI, int theNbArgs, const char** theArg theDI << "Transformed Shape as " << theArgVec[2] << "\n"; } else + { theDI << "No transformation computed\n"; + } return 0; } @@ -449,7 +499,9 @@ static int stepwrite(Draw_Interpretor& theDI, int theNbArgs, const char** theArg occ::handle ActWrite = occ::down_cast(aWS->NormAdaptor()->ActorWrite()); if (!ActWrite.IsNull()) + { ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly")); + } TopoDS_Shape shape = DBRep::Get(theArgVec[2]); STEPControl_Writer sw(aWS, false); @@ -474,7 +526,9 @@ static int stepwrite(Draw_Interpretor& theDI, int theNbArgs, const char** theArg theDI << "Error: translation failed, status = " << stat << "\n"; } if (aPSRoot.UserBreak()) + { return 1; + } aPSRoot.SetName("Writing"); progress->Show(aPSRoot); @@ -482,9 +536,13 @@ static int stepwrite(Draw_Interpretor& theDI, int theNbArgs, const char** theArg stepmodel = sw.Model(); int nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); if (nbavant > 0) + { theDI << "Beware : Model not empty before transferring\n"; + } if (nbapres <= nbavant) + { theDI << "Beware : No data produced by this transfer\n"; + } if (nbapres == 0) { theDI << "No data to write\n"; @@ -657,17 +715,23 @@ static int stepfileunits(Draw_Interpretor& theDI, int theNbArgs, const char** th theDI << "=====================================================\n"; theDI << "LENGTH Unit\n"; for (; i <= anUnitLengthNames.Length(); i++) + { theDI << anUnitLengthNames(i).ToCString() << "\n"; + } theDI << "=====================================================\n"; theDI << "Angle Unit\n"; for (i = 1; i <= anUnitAngleNames.Length(); i++) + { theDI << anUnitAngleNames(i).ToCString() << "\n"; + } theDI << "=====================================================\n"; theDI << "Solid Angle Unit\n"; for (i = 1; i <= anUnitSolidAngleNames.Length(); i++) + { theDI << anUnitSolidAngleNames(i).ToCString() << "\n"; + } return 0; } diff --git a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx index 8991d6002c..78b1b33eff 100644 --- a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx +++ b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx @@ -75,7 +75,9 @@ static int writestl(Draw_Interpretor& di, int argc, const char** argv) occ::handle aProgress = new Draw_ProgressIndicator(di); bool isOK = aWriter.Write(aShape, argv[2], aProgress->Start()); if (!isOK) + { di << "** Error **: Mesh writing has been failed.\n"; + } } return 0; } @@ -243,7 +245,9 @@ static int createmesh(Draw_Interpretor& theDI, int theNbArgs, const char** theAr occ::handle aNodes = new TColStd_HPackedMapOfInteger(); const int aLen = aSTLMesh->NbNodes(); for (int anIndex = 1; anIndex <= aLen; anIndex++) + { aNodes->ChangeMap().Add(anIndex); + } aMesh->SetHiddenNodes(aNodes); aMesh->SetSelectableNodes(aNodes); @@ -253,7 +257,9 @@ static int createmesh(Draw_Interpretor& theDI, int theNbArgs, const char** theAr Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh)); occ::handle aView = ViewerTest::CurrentView(); if (!aView.IsNull()) + { aView->FitAll(); + } return 0; } @@ -290,7 +296,9 @@ static int create3d(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV occ::handle aNodes = new TColStd_HPackedMapOfInteger(); int aLen = aDS->GetAllNodes().Extent(); for (int anIndex = 1; anIndex <= aLen; anIndex++) + { aNodes->ChangeMap().Add(anIndex); + } aMesh->SetHiddenNodes(aNodes); aMesh->SetSelectableNodes(aNodes); @@ -300,7 +308,9 @@ static int create3d(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh)); occ::handle aView = ViewerTest::CurrentView(); if (!aView.IsNull()) + { aView->FitAll(); + } return 0; } @@ -326,7 +336,9 @@ occ::handle getMesh(const char* theName, Draw_Interpretor& theDI) return nullptr; } else + { return aMesh; + } } } @@ -335,7 +347,9 @@ occ::handle getMesh(const char* theName, Draw_Interpretor& theDI) static int setcolor(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec, int theParam) { if (theNbArgs < 5) + { theDI << "Wrong number of parameters\n"; + } else { occ::handle aMesh = getMesh(theArgVec[1], theDI); @@ -350,9 +364,13 @@ static int setcolor(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else + { aContext->Redisplay(aMesh, true); + } } } return 0; @@ -377,7 +395,9 @@ static int linecolor(Draw_Interpretor& theInterp, int theNbArgs, const char** th static int meshmat(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec) { if (theNbArgs < 3) + { theDI << "Wrong number of parameters\n"; + } else { occ::handle aMesh = getMesh(theArgVec[1], theDI); @@ -399,9 +419,13 @@ static int meshmat(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVe occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else + { aContext->Redisplay(aMesh, true); + } } } return 0; @@ -412,7 +436,9 @@ static int meshmat(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVe static int shrink(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec) { if (theNbArgs < 3) + { theDI << "Wrong number of parameters\n"; + } else { occ::handle aMesh = getMesh(theArgVec[1], theDI); @@ -424,9 +450,13 @@ static int shrink(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else + { aContext->Redisplay(aMesh, true); + } } } return 0; @@ -467,7 +497,9 @@ static int closed(Draw_Interpretor& theDI, int theArgc, const char** theArgv) static int mdisplay(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec) { if (theNbArgs < 2) + { theDI << "Wrong number of parameters\n"; + } else { occ::handle aMesh = getMesh(theArgVec[1], theDI); @@ -476,7 +508,9 @@ static int mdisplay(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else { aContext->Display(aMesh, true); @@ -491,7 +525,9 @@ static int mdisplay(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV static int merase(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec) { if (theNbArgs < 2) + { theDI << "Wrong number of parameters\n"; + } else { occ::handle aMesh = getMesh(theArgVec[1], theDI); @@ -500,14 +536,18 @@ static int merase(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVec occ::handle aContext = ViewerTest::GetAISContext(); if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else { aContext->Erase(aMesh, true); } } else + { theDI << "Mesh is null\n"; + } } return 0; } @@ -532,7 +572,9 @@ static int hidesel(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVe } if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else { occ::handle aHiddenNodes = aMesh->GetHiddenNodes(); @@ -590,7 +632,9 @@ static int showonly(Draw_Interpretor& theDI, int theNbArgs, const char** theArgV } if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else { occ::handle aHiddenNodes = @@ -641,7 +685,9 @@ static int showall(Draw_Interpretor& theDI, int theNbArgs, const char** theArgVe } if (aContext.IsNull()) + { theDI << "The context is null\n"; + } else { aMesh->SetHiddenNodes(new TColStd_HPackedMapOfInteger()); @@ -702,11 +748,15 @@ static int meshcolors(Draw_Interpretor& theDI, int theNbArgs, const char** theAr { aTempBuilder = aMesh->FindBuilder(STANDARD_TYPE(MeshVS_ElementalColorPrsBuilder)); if (!aTempBuilder.IsNull()) + { aMesh->RemoveBuilderById(aTempBuilder->GetId()); + } aTempBuilder = aMesh->FindBuilder(STANDARD_TYPE(MeshVS_NodalColorPrsBuilder)); if (!aTempBuilder.IsNull()) + { aMesh->RemoveBuilderById(aTempBuilder->GetId()); + } } if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2")) @@ -720,18 +770,22 @@ static int meshcolors(Draw_Interpretor& theDI, int theNbArgs, const char** theAr aMesh->GetDataSource()->GetAllElements(); if (aMode.IsEqual("elem1")) + { for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements); anIter.More(); anIter.Next()) { Quantity_Color aColor((Quantity_NameOfColor)(anIter.Key() % Quantity_NOC_WHITE)); aBuilder->SetColor1(anIter.Key(), aColor); } + } else + { for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements); anIter.More(); anIter.Next()) { aBuilder->SetColor2(anIter.Key(), aColor1, aColor2); } + } aMesh->AddBuilder(aBuilder, true); } @@ -915,7 +969,9 @@ static int meshvectors(Draw_Interpretor& theDI, int theNbArgs, const char** theA aTempBuilder = aMesh->FindBuilder(STANDARD_TYPE(MeshVS_VectorPrsBuilder)); if (!aTempBuilder.IsNull()) + { aMesh->RemoveBuilderById(aTempBuilder->GetId()); + } if (!aMode.IsEqual("none")) { @@ -946,15 +1002,19 @@ static int meshvectors(Draw_Interpretor& theDI, int theNbArgs, const char** theA { aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType); if (aEntType == MeshVS_ET_Face) + { IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); + } } else + { IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), false, aCoords, aNbNodes, aEntType); + } gp_Vec aNorm; if (IsValidData) @@ -1093,7 +1153,9 @@ static int meshdeform(Draw_Interpretor& theDI, int theNbArgs, const char** theAr gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); if (!aNorm.Magnitude()) + { aNorm = gp_Vec(0, 0, 1); + } aDefDS->SetVector(anIter.Key(), aNorm.Normalized()); } @@ -1103,7 +1165,9 @@ static int meshdeform(Draw_Interpretor& theDI, int theNbArgs, const char** theAr occ::handle aView = ViewerTest::CurrentView(); if (!aView.IsNull()) + { aView->FitAll(); + } return 0; } diff --git a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource.cxx b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource.cxx index 9bab9aeb6f..762553783f 100644 --- a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource.cxx +++ b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource.cxx @@ -32,7 +32,7 @@ XSDRAWSTL_DataSource::XSDRAWSTL_DataSource(const occ::handle { const int aNbNodes = myMesh->NbNodes(); myNodeCoords = new NCollection_HArray2(1, aNbNodes, 1, 3); - std::cout << "Nodes : " << aNbNodes << std::endl; + std::cout << "Nodes : " << aNbNodes << '\n'; for (int i = 1; i <= aNbNodes; i++) { @@ -48,7 +48,7 @@ XSDRAWSTL_DataSource::XSDRAWSTL_DataSource(const occ::handle myElemNormals = new NCollection_HArray2(1, aNbTris, 1, 3); myElemNodes = new NCollection_HArray2(1, aNbTris, 1, 3); - std::cout << "Elements : " << aNbTris << std::endl; + std::cout << "Elements : " << aNbTris << '\n'; for (int i = 1; i <= aNbTris; i++) { @@ -68,9 +68,13 @@ XSDRAWSTL_DataSource::XSDRAWSTL_DataSource(const occ::handle gp_Vec aN = aV1.Crossed(aV2); if (aN.SquareMagnitude() > Precision::SquareConfusion()) + { aN.Normalize(); + } else + { aN.SetCoord(0.0, 0.0, 0.0); + } for (int j = 0; j < 3; j++) { @@ -82,7 +86,7 @@ XSDRAWSTL_DataSource::XSDRAWSTL_DataSource(const occ::handle myElemNormals->SetValue(i, 3, aN.Z()); } } - std::cout << "Construction is finished" << std::endl; + std::cout << "Construction is finished" << '\n'; } //================================================================================================= @@ -94,7 +98,9 @@ bool XSDRAWSTL_DataSource::GetGeom(const int ID, MeshVS_EntityType& Type) const { if (myMesh.IsNull()) + { return false; + } if (IsElement) { @@ -107,13 +113,17 @@ bool XSDRAWSTL_DataSource::GetGeom(const int ID, { int IdxNode = myElemNodes->Value(ID, i); for (int j = 1; j <= 3; j++, k++) + { Coords(k) = myNodeCoords->Value(IdxNode, j); + } } return true; } else + { return false; + } } else if (ID >= 1 && ID <= myNodes.Extent()) { @@ -126,7 +136,9 @@ bool XSDRAWSTL_DataSource::GetGeom(const int ID, return true; } else + { return false; + } } //================================================================================================= @@ -161,7 +173,9 @@ bool XSDRAWSTL_DataSource::GetNodesByElement(const int ID, int& /*theNbNodes*/) const { if (myMesh.IsNull()) + { return false; + } if (ID >= 1 && ID <= myElements.Extent() && theNodeIDs.Length() >= 3) { @@ -197,7 +211,9 @@ bool XSDRAWSTL_DataSource::GetNormal(const int Id, double& nz) const { if (myMesh.IsNull()) + { return false; + } if (Id >= 1 && Id <= myElements.Extent() && Max >= 3) { @@ -207,5 +223,7 @@ bool XSDRAWSTL_DataSource::GetNormal(const int Id, return true; } else + { return false; + } } diff --git a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx index d46cd066c5..8abceaecd8 100644 --- a/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx +++ b/src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx @@ -167,13 +167,17 @@ bool XSDRAWSTL_DataSource3D::GetGeom(const int theID, { int anIdxNode = myElemNodes->Value(theID, aNodeI); for (int aCoordI = 1; aCoordI <= 3; aCoordI++, aGlobCoordI++) + { theCoords(aGlobCoordI) = myNodeCoords->Value(anIdxNode, aCoordI); + } } return true; } else + { return false; + } } else if (theID >= 1 && theID <= myNodes.Extent()) { @@ -186,7 +190,9 @@ bool XSDRAWSTL_DataSource3D::GetGeom(const int theID, return true; } else + { return false; + } } //================================================================================================= diff --git a/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx b/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx index fe44ac481b..232d603628 100644 --- a/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx +++ b/src/Draw/TKXSDRAWVRML/XSDRAWVRML/XSDRAWVRML.cxx @@ -242,7 +242,9 @@ static int WriteVrml(Draw_Interpretor& di, int argc, const char** argv) static int loadvrml(Draw_Interpretor& di, int argc, const char** argv) { if (argc < 3) + { di << "wrong number of parameters" << "\n"; + } else { TopoDS_Shape aShape; @@ -263,9 +265,13 @@ static int loadvrml(Draw_Interpretor& di, int argc, const char** argv) if (!aTrek.IsEmpty()) { if (!aDisk.IsEmpty()) + { aVrmlDir = aDisk; + } else + { aVrmlDir.Clear(); + } aTrek.ChangeAll('|', '/'); aVrmlDir += aTrek; } @@ -376,7 +382,9 @@ static int writevrml(Draw_Interpretor& di, int argc, const char** argv) { aVersion = Draw::Atoi(argv[3]); if (argc == 5) + { aType = Draw::Atoi(argv[4]); + } } // Bound parameters diff --git a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib.cxx b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib.cxx index 1af4cde762..82f6763204 100644 --- a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib.cxx +++ b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib.cxx @@ -149,11 +149,17 @@ int BSplCLib::FlatIndex(const int Degree, pmu -= MLower; for (i = MLower + 1; i <= Index; i++) + { index += pmu[i] - 1; + } if (Periodic) + { index += Degree; + } else + { index += pmu[MLower] - 1; + } return index; } @@ -190,6 +196,7 @@ void BSplCLib::LocateParameter(const int Degree, double& NewU) { if (IsPeriodic) + { BSplCLib::LocateParameter(Knots, U, IsPeriodic, @@ -199,8 +206,11 @@ void BSplCLib::LocateParameter(const int Degree, NewU, Knots(Knots.Lower() + Degree), Knots(Knots.Upper() - Degree)); + } else + { BSplCLib::LocateParameter(Knots, U, IsPeriodic, FromK1, ToK2, KnotIndex, NewU, 0., 1.); + } } //================================================================================================= @@ -241,7 +251,9 @@ void BSplCLib::LocateParameter(const NCollection_Array1& Knots, int Last1 = Last - 1; NewU = U; if (IsPeriodic && (NewU < UFirst || NewU > ULast)) + { NewU = ElCLib::InPeriod(NewU, UFirst, ULast); + } BSplCLib::Hunt(Knots, NewU, KnotIndex); @@ -256,15 +268,23 @@ void BSplCLib::LocateParameter(const NCollection_Array1& Knots, { val = NewU - knots[KnotIndex + 1]; if (val < 0) + { val = -val; + } // <= to be coherent with Segment where Eps corresponds to a bit of error. if (val <= Eps) + { KnotIndex++; + } } if (KnotIndex < First) + { KnotIndex = First; + } if (KnotIndex > Last1) + { KnotIndex = Last1; + } if (KnotIndex != Last1) { @@ -272,20 +292,26 @@ void BSplCLib::LocateParameter(const NCollection_Array1& Knots, double K2 = knots[KnotIndex + 1]; val = K2 - K1; if (val < 0) + { val = -val; + } while (val <= Eps) { KnotIndex++; if (KnotIndex >= Knots.Upper()) + { break; + } K1 = K2; K2 = knots[KnotIndex + 1]; val = K2 - K1; if (val < 0) + { val = -val; + } } } } @@ -320,6 +346,7 @@ void BSplCLib::LocateParameter(const int Degree, last = Knots.Upper() - Degree; } if (KnotIndex < first || KnotIndex > last) + { BSplCLib::LocateParameter(Knots, U, Periodic, @@ -329,8 +356,11 @@ void BSplCLib::LocateParameter(const int Degree, NewU, Knots(first), Knots(last)); + } else + { NewU = U; + } } //================================================================================================= @@ -367,36 +397,54 @@ int BSplCLib::NbPoles(const int Degree, const bool Periodic, const NCollection_A const int Mf = pmu[0]; const int Ml = pmu[l - f]; if (Mf <= 0) + { return 0; + } if (Ml <= 0) + { return 0; + } int sigma; if (Periodic) { if (Mf > Degree) + { return 0; + } if (Ml > Degree) + { return 0; + } if (Mf != Ml) + { return 0; + } sigma = Mf; } else { const int Deg1 = Degree + 1; if (Mf > Deg1) + { return 0; + } if (Ml > Deg1) + { return 0; + } sigma = Mf + Ml - Deg1; } for (int i = 1; i < l - f; i++) { if (pmu[i] <= 0) + { return 0; + } if (pmu[i] > Degree) + { return 0; + } sigma += pmu[i]; } return sigma; @@ -415,9 +463,13 @@ int BSplCLib::KnotSequenceLength(const NCollection_Array1& Mults, pmu -= MLower; for (i = MLower; i <= MUpper; i++) + { l += pmu[i]; + } if (Periodic) + { l += 2 * (Degree + 1 - pmu[MLower]); + } return l; } @@ -663,7 +715,9 @@ void BSplCLib::KnotAnalysis(const int Degree, else { if (CMults(1) == 1) + { KnotForm = GeomAbs_Uniform; + } } break; case BSplCLib_QuasiConstant: @@ -671,9 +725,13 @@ void BSplCLib::KnotAnalysis(const int Degree, { double M = CMults(2); if (M == Degree) + { KnotForm = GeomAbs_PiecewiseBezier; + } else if (M == 1) + { KnotForm = GeomAbs_QuasiUniform; + } } break; } @@ -730,7 +788,9 @@ void BSplCLib::Reparametrize(const double U1, const double U2, Array1OfReal& Kno // for CheckCurveData double Eps = Epsilon(std::abs(Knots(i - 1))); if (Knots(i) - Knots(i - 1) <= Eps) + { Knots(i) = std::nextafter(Knots(i - 1) + Eps, RealLast()); + } K1 = K2; } @@ -793,7 +853,9 @@ bool BSplCLib::IsRational(const NCollection_Array1& Weights, for (i = I1 - f; i < I3; i++) { if (WG[f + (i % l)] != WG[f + ((i + 1) % l)]) + { return true; + } } return false; } @@ -1001,7 +1063,9 @@ void BSplCLib::BoorScheme(const double U, // P(i,j) = X * P(i-1,j) + (1-X) * P(i-1,j+1) for (k = 0; k < Dimension; k++) + { pole[k] = X * pole[k - Dimension] + Y * pole[k + Dimension]; + } } } } @@ -1035,7 +1099,9 @@ bool BSplCLib::AntiBoorScheme(const double U, { z = X * firstpole[k] + Y * firstpole[k + 2 * Dimension]; if (std::abs(z - firstpole[k + Dimension]) > Tolerance) + { return false; + } } return true; } @@ -1058,7 +1124,9 @@ bool BSplCLib::AntiBoorScheme(const double U, Y = 1. - X; for (k = 0; k < Dimension; k++) + { pole[k + Dimension] = (pole[k] - X * pole[k - Dimension]) / Y; + } } // second step from right to left @@ -1082,7 +1150,9 @@ bool BSplCLib::AntiBoorScheme(const double U, { z = (pole[k] - Y * pole[k + Dimension]) / X; if (std::abs(z - pole[k - Dimension]) > Tolerance) + { return false; + } pole[k - Dimension] += z; pole[k - Dimension] /= 2.; } @@ -1136,9 +1206,13 @@ void BSplCLib::Bohm(const double U, double *knot = &Knots, *pole, coef, *tbis, *psav, *psDD, *psDDmDim; psav = &Poles; if (N < Degree) + { min = N; + } else + { min = Degree; + } Degm1 = Degree - 1; DDmi = (Degree << 1) + 1; switch (Dimension) @@ -1651,7 +1725,9 @@ void BSplCLib::BuildKnots(const int Degree, } } if (getlow) + { knot[Deg1 - i] = pkn[ilow] - loffset; + } } if (getupp) { @@ -1669,7 +1745,9 @@ void BSplCLib::BuildKnots(const int Degree, } } if (getupp) + { knot[Degree + i] = pkn[iupp] + uoffset; + } } } } @@ -1685,11 +1763,17 @@ int BSplCLib::PoleIndex(const int Degree, int i, pindex = 0; for (i = Mults.Lower(); i <= Index; i++) + { pindex += Mults(i); + } if (Periodic) + { pindex -= Mults(Mults.Lower()); + } else + { pindex -= Degree + 1; + } return pindex; } @@ -1713,7 +1797,9 @@ void BSplCLib::BuildBoor(const int Index, poles[k] = Poles(ip); ip++; if (ip > Poles.Upper()) + { ip = Poles.Lower(); + } } poles += 2 * Dimension; } @@ -1724,9 +1810,13 @@ void BSplCLib::BuildBoor(const int Index, int BSplCLib::BoorIndex(const int Index, const int Length, const int Depth) { if (Index <= Depth) + { return Index; + } if (Index <= Length) + { return 2 * Index - Depth; + } return Length + Index - Depth; } @@ -1749,7 +1839,9 @@ void BSplCLib::GetPole(const int Index, Position++; } if (Position > Pole.Upper()) + { Position = Pole.Lower(); + } } //================================================================================================= @@ -1781,9 +1873,13 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, double adeltaK1 = Knots(first) - AddKnots(AddKnots.Lower()); double adeltaK2 = AddKnots(AddKnots.Upper()) - Knots(last); if (adeltaK1 > Tolerance) + { return false; + } if (adeltaK2 > Tolerance) + { return false; + } int sigma = 0, mult, amult; NbKnots = 0; @@ -1795,7 +1891,9 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, // gka for case when segments was produced on full period only one knot // was added in the end of curve if (std::abs(adeltaK1) <= gp::Resolution() && std::abs(adeltaK2) <= gp::Resolution()) + { ak++; + } } int aLastKnotMult = Mults(Knots.Upper()); @@ -1805,7 +1903,9 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, { au = AddKnots(ak); if (au < oldau) + { return false; + } oldau = au; Eps = std::max(Tolerance, Epsilon(au)); @@ -1818,9 +1918,13 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, } if (addflat) + { amult = 1; + } else + { amult = std::max(0, (*AddMults)(ak)); + } while ((ak < AddKnots.Upper()) && (std::abs(au - AddKnots(ak + 1)) <= Eps)) { @@ -1828,9 +1932,13 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, if (Add) { if (addflat) + { amult++; + } else + { amult += std::max(0, (*AddMults)(ak)); + } } } @@ -1841,13 +1949,17 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, if (Add) { if (mult + amult > Degree) + { amult = std::max(0, Degree - mult); + } sigma += amult; } else if (amult > mult) { if (amult > Degree) + { amult = Degree; + } if (k == Knots.Upper() && Periodic) { aLastKnotMult = std::max(amult, mult); @@ -1875,7 +1987,9 @@ bool BSplCLib::PrepareInsertKnots(const int Degree, if (amult > 0) { if (amult > Degree) + { amult = Degree; + } NbKnots++; sigma += amult; } @@ -1933,10 +2047,14 @@ static void Copy(const int NbPoles, NewPoles(NewFirst) = OldPoles(OldFirst); OldFirst++; if (OldFirst > OldPoles.Upper()) + { OldFirst = OldPoles.Lower(); + } NewFirst++; if (NewFirst > NewPoles.Upper()) + { NewFirst = NewPoles.Lower(); + } } } @@ -1986,9 +2104,13 @@ void BSplCLib::InsertKnots(const int Degree, // index is the first pole of the current curve for insertion schema if (Periodic) + { index = -Mults(Mults.Lower()); + } else + { index = -Degree - 1; + } // on Periodic curves the first knot and the last knot are inserted later // (they are the same knot) @@ -2066,21 +2188,31 @@ void BSplCLib::InsertKnots(const int Degree, bool sameknot = (std::abs(u - NewKnots(curnk)) <= Eps); if (sameknot) + { length = std::max(0, Degree - NewMults(curnk)); + } else + { length = Degree; + } if (addflat) + { depth = 1; + } else + { depth = std::min(Degree, (*AddMults)(kn)); + } if (sameknot) { if (Add) { if ((NewMults(curnk) + depth) > Degree) + { depth = Degree - NewMults(curnk); + } } else { @@ -2092,14 +2224,18 @@ void BSplCLib::InsertKnots(const int Degree, // on periodic curve the first and last knot are delayed to the end if (curk == Knots.Lower() || (curk == Knots.Upper())) { - if (firstmult == 0) // do that only once + if (firstmult == 0) + { // do that only once firstmult += depth; + } depth = 0; } } } if (depth <= 0) + { continue; + } BuildKnots(Degree, curnk, Periodic, nknots, &nmults, *knots); @@ -2129,7 +2265,9 @@ void BSplCLib::InsertKnots(const int Degree, np = NewKnots.Lower() + (index + 1) * Dimension; for (i = 1; i <= length + depth; i++) + { GetPole(i, length, depth, Dimension, *poles, np, ThePoles); + } //------------------- // insert the knot @@ -2195,12 +2333,16 @@ void BSplCLib::InsertKnots(const int Degree, np = NewPoles.Lower(); for (i = depth; i < length + depth; i++) + { GetPole(i, length, depth, Dimension, *poles, np, NewPoles); + } np = NewPoles.Upper() - depth * Dimension + 1; for (i = 0; i < depth; i++) + { GetPole(i, length, depth, Dimension, *poles, np, NewPoles); + } NewMults(NewMults.Lower()) += depth; NewMults(NewMults.Upper()) += depth; @@ -2240,12 +2382,18 @@ bool BSplCLib::RemoveKnot(const int Index, last = BSplCLib::LastUKnotIndex(Degree, Mults) - 1; } if (Index < first) + { return false; + } if (Index > last) + { return false; + } if (Periodic && (Index == first)) + { TheIndex = last; + } int depth = Mults(TheIndex) - Mult; int length = Degree - Mult; @@ -2271,10 +2419,14 @@ bool BSplCLib::RemoveKnot(const int Index, index += Mult; for (i = 0; i < Degree - Mult; i++) + { knots[i] = knots[i + Mult]; + } for (i = Degree - Mult; i < 2 * Degree; i++) + { knots[i] = knots[2 * Degree + i]; + } // ------------------------------------ // build the poles for anti Boor Scheme @@ -2292,7 +2444,9 @@ bool BSplCLib::RemoveKnot(const int Index, } p += Dimension; if (p > Poles.Upper()) + { p = Poles.Lower(); + } } // ---------------- @@ -2320,7 +2474,9 @@ bool BSplCLib::RemoveKnot(const int Index, // modified for (i = 1; i <= length; i++) + { BSplCLib::GetPole(i, length, 0, Dimension, *poles, np, NewPoles); + } p += (length + depth) * Dimension; // unmodified poles after @@ -2340,9 +2496,13 @@ bool BSplCLib::RemoveKnot(const int Index, if (Periodic) { if (TheIndex == first) + { NewMults(last) = Mult; + } if (TheIndex == last) + { NewMults(first) = Mult; + } } } else @@ -2389,7 +2549,9 @@ int BSplCLib::IncreaseDegreeCountKnots(const int Degree, const NCollection_Array1& Mults) { if (Periodic) + { return Mults.Length(); + } int f = FirstUKnotIndex(Degree, Mults); int l = LastUKnotIndex(Degree, Mults); int m, i, removed = 0, step = NewDegree - Degree; @@ -2404,7 +2566,9 @@ int BSplCLib::IncreaseDegreeCountKnots(const int Degree, i++; } if (m < NewDegree + 1) + { removed--; + } i = Mults.Upper(); m = Degree + (i - l + 1) * step + 1; @@ -2416,7 +2580,9 @@ int BSplCLib::IncreaseDegreeCountKnots(const int Degree, i--; } if (m < NewDegree + 1) + { removed--; + } return Mults.Length() - removed; } @@ -2480,14 +2646,18 @@ void BSplCLib::IncreaseDegree(const int Degree, pf = -Degree - 1; for (i = Mults.Lower(); i <= f; i++) + { pf += Mults(i); + } nbwknots += Mults.Upper() - l; pl = -Degree - 1; for (i = l; i <= Mults.Upper(); i++) + { pl += Mults(i); + } } // copy the knots and multiplicities @@ -2541,7 +2711,9 @@ void BSplCLib::IncreaseDegree(const int Degree, int nbwpoles = 0; for (i = 1; i <= nbwknots; i++) + { nbwpoles += wmults(i); + } nbwpoles -= Degree + 1; // we provide space for degree elevation @@ -2549,7 +2721,9 @@ void BSplCLib::IncreaseDegree(const int Degree, (nbwpoles + (nbwknots - 1) * (NewDegree - Degree)) * Dimension); for (i = 1; i <= pf * Dimension; i++) + { wpoles(i) = 0; + } k = Poles.Lower(); @@ -2558,11 +2732,15 @@ void BSplCLib::IncreaseDegree(const int Degree, wpoles(i) = Poles(k); k++; if (k > Poles.Upper()) + { k = Poles.Lower(); + } } for (i = (nbwpoles - pl) * Dimension + 1; i <= nbwpoles * Dimension; i++) + { wpoles(i) = 0; + } //----------------------------------------------------------- // Declare the temporary arrays used in degree incrementation @@ -2599,7 +2777,9 @@ void BSplCLib::IncreaseDegree(const int Degree, // Initialize the portion of nwpoles that will be used this iteration for (int idx = 1; idx <= nbwp * Dimension; idx++) + { nwpoles(idx) = 0.0; + } for (step = 0; step <= curDeg; step++) { @@ -2610,7 +2790,9 @@ void BSplCLib::IncreaseDegree(const int Degree, if (step != 0) { for (i = 1; i <= nbwknots; i++) + { wmults(i)--; + } } // Poles are the current poles @@ -2689,14 +2871,18 @@ void BSplCLib::IncreaseDegree(const int Degree, // add to the average for (i = 1; i <= nbwp * Dimension; i++) + { nwpoles(i) += ncurve(i); + } } else { // add to the average for (i = 1; i <= nbwp * Dimension; i++) + { nwpoles(i) += tempc1(i); + } } } @@ -2714,9 +2900,13 @@ void BSplCLib::IncreaseDegree(const int Degree, // index in new knots of the first knot of the curve if (Periodic) + { firstknot = Mults.Upper() - l + 1; + } else + { firstknot = f; + } // the new curve starts at index firstknot // so we must remove knots until the sum of multiplicities @@ -2726,7 +2916,9 @@ void BSplCLib::IncreaseDegree(const int Degree, m = 0; for (k = 1; k <= firstknot; k++) + { m += wmults(k); + } // compute the new first knot (k), pf will be the index of the first pole k = 1; @@ -2747,7 +2939,9 @@ void BSplCLib::IncreaseDegree(const int Degree, // on a periodic curve the knots start with firstknot if (Periodic) + { k = firstknot; + } // copy knots @@ -2781,7 +2975,9 @@ void BSplCLib::PrepareUnperiodize(const int Degree, NbPoles = -Degree - 1; for (i = Mults.Lower(); i <= Mults.Upper(); i++) + { NbPoles += Mults(i); + } int sigma, k; // Add knots at the beginning of the curve to raise Multiplicities @@ -2799,7 +2995,9 @@ void BSplCLib::PrepareUnperiodize(const int Degree, // We must add exactly until Degree + 1 -> // Suppress the excedent. if (sigma > Degree + 1) + { NbPoles -= sigma - Degree - 1; + } // Add knots at the end of the curve to raise Multiplicities // to Degre + 1; @@ -2816,7 +3014,9 @@ void BSplCLib::PrepareUnperiodize(const int Degree, // We must add exactly until Degree + 1 -> // Suppress the excedent. if (sigma > Degree + 1) + { NbPoles -= sigma - Degree - 1; + } } //================================================================================================= @@ -2901,7 +3101,9 @@ void BSplCLib::PrepareTrimming(const int Degree, LocateParameter(Degree, Knots, Mults, U2, Periodic, Knots.Lower(), Knots.Upper(), index2, NewU2); index1++; if (std::abs(Knots(index2) - U2) <= Epsilon(U1)) + { index2--; + } // eval NbKnots: NbKnots = index2 - index1 + 3; @@ -2910,7 +3112,9 @@ void BSplCLib::PrepareTrimming(const int Degree, NbPoles = Degree + 1; for (i = index1; i <= index2; i++) + { NbPoles += Mults(i); + } } //================================================================================================= @@ -2983,7 +3187,9 @@ void BSplCLib::Trimming(const int Degree, Pindex *= Dimension; for (i = 1; i <= NewPoles.Length(); i++) + { NewPoles(i) = TempPoles(Pindex + i); + } for (i = 1; i <= NewKnots.Length(); i++) { @@ -3168,14 +3374,18 @@ void BSplCLib::Interpolate(const int Degree, UpperBandWidth, LowerBandWidth); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } ErrorCode = BSplCLib::FactorBandedMatrix(InterpolationMatrix, UpperBandWidth, LowerBandWidth, InversionProblem); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } ErrorCode = BSplCLib::SolveBandedSystem(InterpolationMatrix, UpperBandWidth, @@ -3183,7 +3393,9 @@ void BSplCLib::Interpolate(const int Degree, ArrayDimension, Poles); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } } //================================================================================================= @@ -3213,14 +3425,18 @@ void BSplCLib::Interpolate(const int Degree, UpperBandWidth, LowerBandWidth); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } ErrorCode = BSplCLib::FactorBandedMatrix(InterpolationMatrix, UpperBandWidth, LowerBandWidth, InversionProblem); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } ErrorCode = BSplCLib::SolveBandedSystem(InterpolationMatrix, UpperBandWidth, @@ -3230,7 +3446,9 @@ void BSplCLib::Interpolate(const int Degree, Poles, Weights); if (ErrorCode) + { throw Standard_OutOfRange("BSplCLib::Interpolate"); + } } //================================================================================================= @@ -3670,9 +3888,13 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot Contraintes(1, ipos) = EvalBS(ipos); Contraintes(2, ipos) = C1Coefficient * EvalBS(ipos + CDimension); if (Continuity >= 2) + { Contraintes(3, ipos) = EvalBS(ipos + 2 * CDimension) * C1Coeff2; + } if (Continuity >= 3) + { Contraintes(4, ipos) = EvalBS(ipos + 3 * CDimension) * C1Coeff3; + } Contraintes(Continuity + 2, ipos) = ConstraintPoint(ipos); } } @@ -3683,11 +3905,17 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot Contraintes(1, ipos) = ConstraintPoint(ipos); Contraintes(2, ipos) = EvalBS(ipos); if (Continuity >= 1) + { Contraintes(3, ipos) = C1Coefficient * EvalBS(ipos + CDimension); + } if (Continuity >= 2) + { Contraintes(4, ipos) = EvalBS(ipos + 2 * CDimension) * C1Coeff2; + } if (Continuity >= 3) + { Contraintes(5, ipos) = EvalBS(ipos + 3 * CDimension) * C1Coeff3; + } } } @@ -3787,7 +4015,9 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot Ratio = L2 / L1; } if ((Ratio < 1.e-5) || (Ratio > 1.e5)) + { Ratio = 1; + } if (After) { @@ -3820,9 +4050,13 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot indP = (ii - 1) * CDimension + jj - 1; indEP = (ii - NbP1) * CDimension + jj; if (ii < NbP1) + { NewPoles(indNP) = Padr[indP]; + } else + { NewPoles(indNP) = NewP2(indEP); + } } } } @@ -3838,9 +4072,13 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot indEP = (ii - 1) * CDimension + jj; indP = (ii - NbP2) * CDimension + jj - 1; if (ii < NbP2) + { NewPoles(indNP) = NewP2(indEP); + } else + { NewPoles(indNP) = Padr[indP]; + } } } } @@ -3889,7 +4127,9 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot for (ii = 2; ii <= NbK1 + NbK2 - CDegree - 2; ii++) { if (NewFlats(ii) != NewFlats(ii - 1)) + { KLength++; + } } // flat nodes --> nodes + multiplicities @@ -3902,7 +4142,9 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot for (ii = 2; ii <= NbK1 + NbK2 - CDegree - 2; ii++) { if (NewFlats(ii) == NewFlats(ii - 1)) + { NewMults(jj)++; + } else { jj++; @@ -3913,7 +4155,9 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot // reduction of multiplicity at the second or the last but one node int Index = 2, M = CDegree; if (After) + { Index = KLength - 1; + } NCollection_Array1 ResultPoles(1, (NbP1 + NbP2 - 1) * CDimension); NCollection_Array1 ResultKnots(1, KLength); NCollection_Array1 ResultMults(1, KLength); @@ -3935,7 +4179,9 @@ void BSplCLib::TangExtendToConstraint(const NCollection_Array1& FlatKnot ResultMults, Tol); if (Ok) + { M--; + } } if (M == CDegree) @@ -4101,7 +4347,9 @@ void BSplCLib::Resolution(double& Poles, { W = WG[ii]; if (W < min_weights) + { min_weights = W; + } } for (ii = 1; ii < num_poles; ii++) @@ -4122,10 +4370,14 @@ void BSplCLib::Resolution(double& Poles, inverse = 1.0e0 / inverse; lower = ii - Deg1; if (lower < 0) + { lower = 0; + } upper = Deg2 + ii; if (upper > num_poles) + { upper = num_poles; + } for (jj = lower; jj < upper; jj++) { @@ -4135,17 +4387,23 @@ void BSplCLib::Resolution(double& Poles, factor = (((PA[jj_index] - pa_ii_inDim_0) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_0) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_1) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_1) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } max_derivative /= min_weights; @@ -4164,17 +4422,23 @@ void BSplCLib::Resolution(double& Poles, value = 0.0e0; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } break; @@ -4189,7 +4453,9 @@ void BSplCLib::Resolution(double& Poles, { W = WG[ii]; if (W < min_weights) + { min_weights = W; + } } for (ii = 1; ii < num_poles; ii++) @@ -4214,10 +4480,14 @@ void BSplCLib::Resolution(double& Poles, inverse = 1.0e0 / inverse; lower = ii - Deg1; if (lower < 0) + { lower = 0; + } upper = Deg2 + ii; if (upper > num_poles) + { upper = num_poles; + } for (jj = lower; jj < upper; jj++) { @@ -4227,23 +4497,31 @@ void BSplCLib::Resolution(double& Poles, factor = (((PA[jj_index] - pa_ii_inDim_0) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_0) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_1) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_1) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_2) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_2) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } max_derivative /= min_weights; @@ -4262,23 +4540,31 @@ void BSplCLib::Resolution(double& Poles, value = 0.0e0; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } break; @@ -4293,7 +4579,9 @@ void BSplCLib::Resolution(double& Poles, { W = WG[ii]; if (W < min_weights) + { min_weights = W; + } } for (ii = 1; ii < num_poles; ii++) @@ -4322,10 +4610,14 @@ void BSplCLib::Resolution(double& Poles, inverse = 1.0e0 / inverse; lower = ii - Deg1; if (lower < 0) + { lower = 0; + } upper = Deg2 + ii; if (upper > num_poles) + { upper = num_poles; + } for (jj = lower; jj < upper; jj++) { @@ -4335,29 +4627,39 @@ void BSplCLib::Resolution(double& Poles, factor = (((PA[jj_index] - pa_ii_inDim_0) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_0) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_1) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_1) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_2) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_2) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; jj_index++; factor = (((PA[jj_index] - pa_ii_inDim_3) * wg_ii_index) - ((PA[jj_index] - pa_ii_miDim_3) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } max_derivative /= min_weights; @@ -4376,29 +4678,39 @@ void BSplCLib::Resolution(double& Poles, value = 0.0e0; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; ii_index++; ii_minus++; factor = PA[ii_index] - PA[ii_minus]; if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } break; @@ -4414,7 +4726,9 @@ void BSplCLib::Resolution(double& Poles, { W = WG[ii]; if (W < min_weights) + { min_weights = W; + } } for (ii = 1; ii < num_poles; ii++) @@ -4429,10 +4743,14 @@ void BSplCLib::Resolution(double& Poles, inverse = 1.0e0 / inverse; lower = ii - Deg1; if (lower < 0) + { lower = 0; + } upper = Deg2 + ii; if (upper > num_poles) + { upper = num_poles; + } for (jj = lower; jj < upper; jj++) { @@ -4445,12 +4763,16 @@ void BSplCLib::Resolution(double& Poles, factor = (((PA[jj_index + kk] - PA[ii_inDim + kk]) * wg_ii_index) - ((PA[jj_index + kk] - PA[ii_miDim + kk]) * wg_ii_minus)); if (factor < 0) + { factor = -factor; + } value += factor; } value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } max_derivative /= min_weights; @@ -4472,21 +4794,29 @@ void BSplCLib::Resolution(double& Poles, { factor = PA[ii_index + kk] - PA[ii_minus + kk]; if (factor < 0) + { factor = -factor; + } value += factor; } value *= inverse; if (max_derivative < value) + { max_derivative = value; + } } } } } max_derivative *= Degree; if (max_derivative > RealSmall()) + { UTolerance = Tolerance3D / max_derivative; + } else + { UTolerance = Tolerance3D / RealSmall(); + } } //================================================================================================= @@ -4658,7 +4988,9 @@ struct UnitWeightsArray : Data{} { for (int i = 0; i < 2049; ++i) + { Data[i] = 1.0; + } } }; diff --git a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_2.cxx b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_2.cxx index 16ba056a1d..50ea7be1ba 100644 --- a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_2.cxx +++ b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_2.cxx @@ -64,7 +64,9 @@ void BSplCLib::BuildEval(const int Degree, { ip++; if (ip > PUpper) + { ip = PLower; + } pole[0] = Poles(ip); pole += 1; } @@ -76,7 +78,9 @@ void BSplCLib::BuildEval(const int Degree, { ip++; if (ip > PUpper) + { ip = PLower; + } pole[1] = w = (*Weights)(ip); pole[0] = Poles(ip) * w; pole += 2; @@ -104,9 +108,13 @@ static void PrepareEval(double& u, // make the knots BSplCLib::BuildKnots(Degree, index, Periodic, Knots, Mults, *dc.knots); if (Mults == nullptr) + { index -= Knots.Lower() + Degree; + } else + { index = BSplCLib::PoleIndex(Degree, index, Periodic, *Mults); + } // check truly rational rational = (Weights != nullptr); @@ -149,9 +157,13 @@ void BSplCLib::D0(const double U, PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc); BSplCLib::Eval(u, Degree, *dc.knots, dim, *dc.poles); if (rational) + { P = dc.poles[0] / dc.poles[1]; + } else + { P = dc.poles[0]; + } } //================================================================================================= @@ -214,9 +226,13 @@ void BSplCLib::D2(const double U, P = result[0]; V1 = result[1]; if (!rational && (Degree < 2)) + { V2 = 0.; + } else + { V2 = result[2]; + } } //================================================================================================= @@ -250,13 +266,21 @@ void BSplCLib::D3(const double U, P = result[0]; V1 = result[1]; if (!rational && (Degree < 2)) + { V2 = 0.; + } else + { V2 = result[2]; + } if (!rational && (Degree < 3)) + { V3 = 0.; + } else + { V3 = result[3]; + } } //================================================================================================= @@ -288,9 +312,13 @@ void BSplCLib::DN(const double U, else { if (N > Degree) + { VN = 0.; + } else + { VN = dc.poles[N]; + } } } diff --git a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx index 3be2a98d4e..e5ab1cabe6 100644 --- a/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx +++ b/src/FoundationClasses/TKMath/BSplCLib/BSplCLib_CurveComputation.pxx @@ -315,19 +315,25 @@ bool BSplCLib_RemoveKnot(const int Index, NCollection_Array1& NewMults, const double Tolerance) { - bool rational = Weights != NULL; + bool rational = Weights != nullptr; int dim; dim = Dimension; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.Length()); NCollection_Array1 newpoles(1, dim * NewPoles.Length()); if (rational) + { PLib::SetPoles(Poles, *Weights, poles); + } else + { PLib::SetPoles(Poles, poles); + } if (!BSplCLib::RemoveKnot(Index, Mult, @@ -341,12 +347,18 @@ bool BSplCLib_RemoveKnot(const int Index, NewKnots, NewMults, Tolerance)) + { return false; + } if (rational) + { PLib::GetPoles(newpoles, NewPoles, *NewWeights); + } else + { PLib::GetPoles(newpoles, NewPoles); + } return true; } @@ -381,19 +393,25 @@ void BSplCLib_InsertKnots(const int Degree, const double Epsilon, const bool Add) { - bool rational = Weights != NULL; + bool rational = Weights != nullptr; int dim; dim = Dimension; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.Length()); NCollection_Array1 newpoles(1, dim * NewPoles.Length()); if (rational) + { PLib::SetPoles(Poles, *Weights, poles); + } else + { PLib::SetPoles(Poles, poles); + } BSplCLib::InsertKnots(Degree, Periodic, @@ -410,9 +428,13 @@ void BSplCLib_InsertKnots(const int Degree, Add); if (rational) + { PLib::GetPoles(newpoles, NewPoles, *NewWeights); + } else + { PLib::GetPoles(newpoles, NewPoles); + } } // Inserts a single knot into the B-spline curve @@ -525,19 +547,25 @@ void BSplCLib_IncreaseDegree(const int Degree, NCollection_Array1& NewKnots, NCollection_Array1& NewMults) { - bool rational = Weights != NULL; + bool rational = Weights != nullptr; int dim; dim = Dimension; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.Length()); NCollection_Array1 newpoles(1, dim * NewPoles.Length()); if (rational) + { PLib::SetPoles(Poles, *Weights, poles); + } else + { PLib::SetPoles(Poles, poles); + } BSplCLib::IncreaseDegree(Degree, NewDegree, @@ -551,9 +579,13 @@ void BSplCLib_IncreaseDegree(const int Degree, NewMults); if (rational) + { PLib::GetPoles(newpoles, NewPoles, *NewWeights); + } else + { PLib::GetPoles(newpoles, NewPoles); + } } // Converts a periodic B-spline curve to non-periodic @@ -577,26 +609,36 @@ void BSplCLib_Unperiodize(const int Degree, Array1OfPoints& NewPoles, NCollection_Array1* NewWeights) { - bool rational = Weights != NULL; + bool rational = Weights != nullptr; int dim; dim = Dimension; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.Length()); NCollection_Array1 newpoles(1, dim * NewPoles.Length()); if (rational) + { PLib::SetPoles(Poles, *Weights, poles); + } else + { PLib::SetPoles(Poles, poles); + } BSplCLib::Unperiodize(Degree, dim, Mults, Knots, poles, NewMults, NewKnots, newpoles); if (rational) + { PLib::GetPoles(newpoles, NewPoles, *NewWeights); + } else + { PLib::GetPoles(newpoles, NewPoles); + } } // Trims the B-spline curve to a parameter range @@ -626,19 +668,25 @@ void BSplCLib_Trimming(const int Degree, Array1OfPoints& NewPoles, NCollection_Array1* NewWeights) { - bool rational = Weights != NULL; + bool rational = Weights != nullptr; int dim; dim = Dimension; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.Length()); NCollection_Array1 newpoles(1, dim * NewPoles.Length()); if (rational) + { PLib::SetPoles(Poles, *Weights, poles); + } else + { PLib::SetPoles(Poles, poles); + } BSplCLib::Trimming(Degree, Periodic, @@ -653,9 +701,13 @@ void BSplCLib_Trimming(const int Degree, newpoles); if (rational) + { PLib::GetPoles(newpoles, NewPoles, *NewWeights); + } else + { PLib::GetPoles(newpoles, NewPoles); + } } // Builds the local array for B-spline evaluation @@ -678,13 +730,15 @@ void BSplCLib_BuildEval(const int Degree, int PUpper = Poles.Upper(); int i; int ip = PLower + Index - 1; - if (Weights == NULL) + if (Weights == nullptr) { for (i = 0; i <= Degree; i++) { ip++; if (ip > PUpper) + { ip = PLower; + } const Point& P = Poles(ip); Traits::PointToCoords(pole, P, 0); pole += Dimension; @@ -696,7 +750,9 @@ void BSplCLib_BuildEval(const int Degree, { ip++; if (ip > PUpper) + { ip = PLower; + } const Point& P = Poles(ip); pole[Dimension] = w = (*Weights)(ip); Traits::PointToCoordsScaled(pole, P, w); @@ -735,13 +791,17 @@ static void PrepareEval_T(double& u, // make the knots BSplCLib::BuildKnots(Degree, index, Periodic, Knots, Mults, *dc.knots); - if (Mults == NULL) + if (Mults == nullptr) + { index -= Knots.Lower() + Degree; + } else + { index = BSplCLib::PoleIndex(Degree, index, Periodic, *Mults); + } // check truly rational - rational = (Weights != NULL); + rational = (Weights != nullptr); if (rational) { int WLower = Weights->Lower() + index; @@ -816,7 +876,9 @@ void BSplCLib_D0(const double U, Traits::CoordsToPointScaled(P, dc.poles, w); } else + { Traits::CoordsToPointDirect(P, dc.poles); + } } // Evaluates the point and first derivative on the B-spline curve at parameter U @@ -926,9 +988,13 @@ void BSplCLib_D2(const double U, Traits::CoordsToPointDirect(P, result); Traits::CoordsToVectorDirect(V1, result + Dimension); if (!rational && (Degree < 2)) + { Traits::NullifyVector(V2); + } else + { Traits::CoordsToVectorDirect(V2, result + 2 * Dimension); + } } // Evaluates the point and first three derivatives on the B-spline curve at parameter U @@ -987,13 +1053,21 @@ void BSplCLib_D3(const double U, Traits::CoordsToPointDirect(P, result); Traits::CoordsToVectorDirect(V1, result + Dimension); if (!rational && (Degree < 2)) + { Traits::NullifyVector(V2); + } else + { Traits::CoordsToVectorDirect(V2, result + 2 * Dimension); + } if (!rational && (Degree < 3)) + { Traits::NullifyVector(V3); + } else + { Traits::CoordsToVectorDirect(V3, result + 3 * Dimension); + } } // Evaluates the Nth derivative on the B-spline curve at parameter U @@ -1048,7 +1122,9 @@ void BSplCLib_DN(const double U, else { if (N > Degree) + { Traits::NullifyVector(VN); + } else { double* DN = dc.poles + N * Dimension; @@ -1173,7 +1249,9 @@ void BSplCLib_Eval(const double Parameter, } for (kk = 0; kk < Dimension; kk++) + { aPoint.SetCoord(kk + 1, P[kk]); + } } // Evaluates the point on cached B-spline curve at parameter @@ -1205,7 +1283,7 @@ void BSplCLib_CacheD0(const double Parameter, Degree * Dimension, PArray[0], myPoint[0]); - if (WeightsArray != NULL) + if (WeightsArray != nullptr) { const NCollection_Array1& refWeights = *WeightsArray; double* WArray = (double*)&refWeights(refWeights.Lower()); @@ -1248,7 +1326,7 @@ void BSplCLib_CacheD1(const double Parameter, Traits::ModifyCoordsDivide(LocalPDerivatives + Dimension, SpanLenght); - if (WeightsArray != NULL) + if (WeightsArray != nullptr) { const NCollection_Array1& refWeights = *WeightsArray; double* WArray = (double*)&refWeights(refWeights.Lower()); @@ -1318,7 +1396,7 @@ void BSplCLib_CacheD2(const double Parameter, Index += Dimension; } - if (WeightsArray != NULL) + if (WeightsArray != nullptr) { const NCollection_Array1& refWeights = *WeightsArray; double* WArray = (double*)&refWeights(refWeights.Lower()); @@ -1403,7 +1481,7 @@ void BSplCLib_CacheD3(const double Parameter, Index += Dimension; } - if (WeightsArray != NULL) + if (WeightsArray != nullptr) { const NCollection_Array1& refWeights = *WeightsArray; double* WArray = (double*)&refWeights(refWeights.Lower()); @@ -1510,10 +1588,12 @@ void BSplCLib_BuildCache(const double U, LocalValue *= SpanDomain / (double)ii; } - if (Weights != NULL) + if (Weights != nullptr) { for (ii = 1; ii <= Degree + 1; ii++) + { (*CacheWeights)(ii) = 0.0e0; + } (*CacheWeights)(1) = 1.0e0; } } @@ -1559,7 +1639,7 @@ void BSplCLib_BuildCache(const double theParameter, (BSplCLib::NoMults()), dc); - int aCacheShift = (theWeights != NULL && !isRational) ? aDimension + 1 : aDimension; + int aCacheShift = (theWeights != nullptr && !isRational) ? aDimension + 1 : aDimension; BSplCLib::Bohm(aParam, theDegree, theDegree, *dc.knots, aDimension, *dc.poles); @@ -1570,7 +1650,9 @@ void BSplCLib_BuildCache(const double theParameter, for (int i = 0; i <= theDegree; i++) { for (int j = 0; j < aDimension; j++) + { aCache[j] = aPolyCoeffs[j] * aCoeff; + } aCoeff *= theSpanDomain / (i + 1); aPolyCoeffs += aDimension; aCache += aDimension; @@ -1582,9 +1664,11 @@ void BSplCLib_BuildCache(const double theParameter, } if (aCacheShift > aDimension) + { theCacheArray.SetValue(theCacheArray.LowerRow(), theCacheArray.LowerCol() + aCacheShift - 1, 1.0); + } } // Interpolates points to create a B-spline curve @@ -1692,9 +1776,13 @@ void BSplCLib_MovePoint(const double U, FirstIndex = FirstNonZeroBsplineIndex; LastIndex = FirstNonZeroBsplineIndex + Degree; if (FirstIndex < Index1) + { FirstIndex = Index1; + } if (LastIndex > Index2) + { LastIndex = Index2; + } double maxValue = 0.0; int i, kk1 = 0, kk2, ii; @@ -1728,7 +1816,7 @@ void BSplCLib_MovePoint(const double U, for (i = 1; i <= Degree + 1; i++) { ii = i + FirstNonZeroBsplineIndex - 1; - if (Weights != NULL) + if (Weights != nullptr) { hN = Weights->Value(ii) * BSplineBasis(1, i); D2 += hN; @@ -1755,7 +1843,7 @@ void BSplCLib_MovePoint(const double U, } } - if (Weights != NULL) + if (Weights != nullptr) { Coef = D2 / D1; } diff --git a/src/FoundationClasses/TKMath/BSplSLib/BSplSLib.cxx b/src/FoundationClasses/TKMath/BSplSLib/BSplSLib.cxx index d7ab9d9cf7..eaf7b3d4fd 100644 --- a/src/FoundationClasses/TKMath/BSplSLib/BSplSLib.cxx +++ b/src/FoundationClasses/TKMath/BSplSLib/BSplSLib.cxx @@ -158,13 +158,21 @@ void BSplSLib::RationalDerivative(const int UDeg, index_u = 0; index_u1 = 0; if (UDeg < N) + { MinN = UDeg; + } else + { MinN = N; + } if (VDeg < M) + { MinM = VDeg; + } else + { MinM = M; + } MinN1 = MinN + 1; MinM1 = MinM + 1; iiM1 = -M1; @@ -337,14 +345,22 @@ static bool PrepareEval(const double U, { // compute the indices if (uindex < UKLower || uindex > UKUpper) + { BSplCLib::LocateParameter(UDegree, UKnots, UMults, U, UPer, uindex, u1); + } else + { u1 = U; + } if (vindex < VKLower || vindex > VKUpper) + { BSplCLib::LocateParameter(VDegree, VKnots, VMults, V, VPer, vindex, u2); + } else + { u2 = V; + } // get the knots d1 = UDegree; @@ -353,14 +369,22 @@ static bool PrepareEval(const double U, BSplCLib::BuildKnots(VDegree, vindex, VPer, VKnots, VMults, *dc.knots2); if (UMults == nullptr) + { uindex -= UKLower + UDegree; + } else + { uindex = BSplCLib::PoleIndex(UDegree, uindex, UPer, *UMults); + } if (VMults == nullptr) + { vindex -= VKLower + VDegree; + } else + { vindex = BSplCLib::PoleIndex(VDegree, vindex, VPer, *VMults); + } // get the poles int i, j, ip, jp; @@ -380,9 +404,13 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (ip < PLowerRow) + { ip = PUpperRow; + } if (jp < PLowerCol) + { jp = PUpperCol; + } w = Weights->Value(ip, jp); double eps = Epsilon(w); @@ -393,26 +421,34 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (jp < PLowerCol) + { jp = PUpperCol; + } for (j = 0; j <= VDegree && !rational; j++) { dw = Weights->Value(ip, jp) - w; if (dw < 0) + { dw = -dw; + } rational = (dw > eps); jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } } @@ -420,7 +456,9 @@ static bool PrepareEval(const double U, ip = PLowerRow + uindex; if (ip < PLowerRow) + { ip = PUpperRow; + } if (rational) { @@ -429,7 +467,9 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (jp < PLowerCol) + { jp = PUpperCol; + } for (j = 0; j <= d2; j++) { @@ -442,13 +482,17 @@ static bool PrepareEval(const double U, jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } } else @@ -458,7 +502,9 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (jp < PLowerCol) + { jp = PUpperCol; + } for (j = 0; j <= d2; j++) { @@ -470,13 +516,17 @@ static bool PrepareEval(const double U, jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } } @@ -486,14 +536,22 @@ static bool PrepareEval(const double U, { // compute the indices if (uindex < UKLower || uindex > UKUpper) + { BSplCLib::LocateParameter(UDegree, UKnots, UMults, U, UPer, uindex, u2); + } else + { u2 = U; + } if (vindex < VKLower || vindex > VKUpper) + { BSplCLib::LocateParameter(VDegree, VKnots, VMults, V, VPer, vindex, u1); + } else + { u1 = V; + } // get the knots @@ -504,14 +562,22 @@ static bool PrepareEval(const double U, BSplCLib::BuildKnots(VDegree, vindex, VPer, VKnots, VMults, *dc.knots1); if (UMults == nullptr) + { uindex -= UKLower + UDegree; + } else + { uindex = BSplCLib::PoleIndex(UDegree, uindex, UPer, *UMults); + } if (VMults == nullptr) + { vindex -= VKLower + VDegree; + } else + { vindex = BSplCLib::PoleIndex(VDegree, vindex, VPer, *VMults); + } // get the poles int i, j, ip, jp; @@ -531,10 +597,14 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (ip < PLowerRow) + { ip = PUpperRow; + } if (jp < PLowerCol) + { jp = PUpperCol; + } w = Weights->Value(ip, jp); double eps = Epsilon(w); @@ -545,25 +615,33 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (jp < PLowerCol) + { jp = PUpperCol; + } for (j = 0; j <= VDegree && !rational; j++) { dw = Weights->Value(ip, jp) - w; if (dw < 0) + { dw = -dw; + } rational = dw > eps; jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } } @@ -571,7 +649,9 @@ static bool PrepareEval(const double U, jp = PLowerCol + vindex; if (jp < PLowerCol) + { jp = PUpperCol; + } if (rational) { @@ -580,7 +660,9 @@ static bool PrepareEval(const double U, ip = PLowerRow + uindex; if (ip < PLowerRow) + { ip = PUpperRow; + } for (j = 0; j <= d2; j++) { @@ -593,13 +675,17 @@ static bool PrepareEval(const double U, ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } } else @@ -609,10 +695,14 @@ static bool PrepareEval(const double U, ip = PLowerRow + uindex; if (ip < PLowerRow) + { ip = PUpperRow; + } if (ip > PUpperRow) + { ip = PLowerRow; + } for (j = 0; j <= d2; j++) { @@ -624,13 +714,17 @@ static bool PrepareEval(const double U, ip++; if (ip > PUpperRow) + { ip = PLowerRow; + } } jp++; if (jp > PUpperCol) + { jp = PLowerCol; + } } } @@ -1029,7 +1123,9 @@ void BSplSLib::D2(const double U, BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } BSplSLib::RationalDerivative(d1, d2, 2, 2, *dc.poles, *dc.ders); result = dc.ders; resVu = result + 9; @@ -1047,18 +1143,28 @@ void BSplSLib::D2(const double U, BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } result = dc.poles; resVu = result + dim2; resVv = result + 3; if (UDegree <= 1) + { resVuu = BSplSLib_zero; + } else + { resVuu = result + (dim2 << 1); + } if (VDegree <= 1) + { resVvv = BSplSLib_zero; + } else + { resVvv = result + 6; + } resVuv = result + (d2 << 1) + d2 + 6; } } @@ -1072,7 +1178,9 @@ void BSplSLib::D2(const double U, BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } BSplSLib::RationalDerivative(d1, d2, 2, 2, *dc.poles, *dc.ders); result = dc.ders; resVu = result + 3; @@ -1090,18 +1198,28 @@ void BSplSLib::D2(const double U, BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } result = dc.poles; resVu = result + 3; resVv = result + dim2; if (UDegree <= 1) + { resVuu = BSplSLib_zero; + } else + { resVuu = result + 6; + } if (VDegree <= 1) + { resVvv = BSplSLib_zero; + } else + { resVvv = result + (dim2 << 1); + } resVuv = result + (d2 << 1) + d2 + 6; } } @@ -1197,9 +1315,13 @@ void BSplSLib::D3(const double U, BSplCLib::Bohm(u2, d2, 3, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } if (d1 > 2) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1) + dim2)); + } BSplSLib::RationalDerivative(d1, d2, 3, 3, *dc.poles, *dc.ders); result = dc.ders; resVu = result + 12; @@ -1221,9 +1343,13 @@ void BSplSLib::D3(const double U, BSplCLib::Bohm(u2, d2, 3, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } if (d1 > 2) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1) + dim2)); + } result = dc.poles; resVu = result + dim2; resVv = result + 3; @@ -1249,13 +1375,21 @@ void BSplSLib::D3(const double U, } resVuv = result + (d2 << 1) + d2 + 6; if (UDegree <= 2) + { resVuuu = BSplSLib_zero; + } else + { resVuuu = result + (dim2 << 1) + dim2; + } if (VDegree <= 2) + { resVvvv = BSplSLib_zero; + } else + { resVvvv = result + 9; + } } } else @@ -1268,9 +1402,13 @@ void BSplSLib::D3(const double U, BSplCLib::Bohm(u2, d2, 3, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } if (d1 > 2) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1) + dim2)); + } BSplSLib::RationalDerivative(d1, d2, 3, 3, *dc.poles, *dc.ders); result = dc.ders; resVu = result + 3; @@ -1292,9 +1430,13 @@ void BSplSLib::D3(const double U, BSplCLib::Bohm(u2, d2, 3, *dc.knots2, dim, *dc.poles); BSplCLib::Bohm(u2, d2, 2, *dc.knots2, dim, *(dc.poles + dim2)); if (d1 > 1) + { BSplCLib::Bohm(u2, d2, 1, *dc.knots2, dim, *(dc.poles + (dim2 << 1))); + } if (d1 > 2) + { BSplCLib::Eval(u2, d2, *dc.knots2, dim, *(dc.poles + (dim2 << 1) + dim2)); + } result = dc.poles; resVu = result + 3; resVv = result + dim2; @@ -1320,13 +1462,21 @@ void BSplSLib::D3(const double U, } resVuv = result + (d2 << 1) + d2 + 6; if (UDegree <= 2) + { resVuuu = BSplSLib_zero; + } else + { resVuuu = result + 9; + } if (VDegree <= 2) + { resVvvv = BSplSLib_zero; + } else + { resVvvv = result + (dim2 << 1) + dim2; + } } } @@ -1434,7 +1584,9 @@ void BSplSLib::DN(const double U, BSplCLib::Bohm(u1, d1, n1, *dc.knots1, dim * (d2 + 1), *dc.poles); for (k = 0; k <= std::min(n1, d1); k++) + { BSplCLib::Bohm(u2, d2, n2, *dc.knots2, dim, *(dc.poles + k * dim * (d2 + 1))); + } double* result; if (rational) @@ -1484,9 +1636,13 @@ void BSplSLib::Iso(const double Param, BSplCLib::LocateParameter(Degree, Knots, Mults, u, Periodic, index, u); BSplCLib::BuildKnots(Degree, index, Periodic, Knots, Mults, *locknots1); if (Mults == nullptr) + { index -= Knots.Lower() + Degree; + } else + { index = BSplCLib::PoleIndex(Degree, index, Periodic, *Mults); + } // copy the local poles @@ -1537,7 +1693,9 @@ void BSplSLib::Iso(const double Param, } index++; if (index > l1) + { index = f1; + } } // compute the iso @@ -1570,7 +1728,9 @@ void BSplSLib::Iso(const double Param, { for (i = CWeights->Lower(); i <= CWeights->Upper(); i++) + { (*CWeights)(i) = 1.; + } } } @@ -1743,7 +1903,9 @@ bool BSplSLib::IsRational(const NCollection_Array2& Weights, { if (std::abs(Weights(fi + i % li, fj + j % lj) - Weights(fi + (i + 1) % li, fj + j % lj)) > eps) + { return true; + } } } return false; @@ -1980,15 +2142,21 @@ void BSplSLib::InsertKnots(const bool UDirection, bool rational = Weights != nullptr; int dim = 3; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.RowLength() * Poles.ColLength()); NCollection_Array1 newpoles(1, dim * NewPoles.RowLength() * NewPoles.ColLength()); if (rational) + { SetPoles(Poles, *Weights, poles, UDirection); + } else + { SetPoles(Poles, poles, UDirection); + } if (UDirection) { @@ -2013,9 +2181,13 @@ void BSplSLib::InsertKnots(const bool UDirection, Add); if (rational) + { GetPoles(newpoles, NewPoles, *NewWeights, UDirection); + } else + { GetPoles(newpoles, NewPoles, UDirection); + } } //================================================================================================= @@ -2038,15 +2210,21 @@ bool BSplSLib::RemoveKnot(const bool UDirection, bool rational = Weights != nullptr; int dim = 3; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.RowLength() * Poles.ColLength()); NCollection_Array1 newpoles(1, dim * NewPoles.RowLength() * NewPoles.ColLength()); if (rational) + { SetPoles(Poles, *Weights, poles, UDirection); + } else + { SetPoles(Poles, poles, UDirection); + } if (UDirection) { @@ -2069,12 +2247,18 @@ bool BSplSLib::RemoveKnot(const bool UDirection, NewKnots, NewMults, Tolerance)) + { return false; + } if (rational) + { GetPoles(newpoles, NewPoles, *NewWeights, UDirection); + } else + { GetPoles(newpoles, NewPoles, UDirection); + } return true; } @@ -2096,15 +2280,21 @@ void BSplSLib::IncreaseDegree(const bool UDirection, bool rational = Weights != nullptr; int dim = 3; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.RowLength() * Poles.ColLength()); NCollection_Array1 newpoles(1, dim * NewPoles.RowLength() * NewPoles.ColLength()); if (rational) + { SetPoles(Poles, *Weights, poles, UDirection); + } else + { SetPoles(Poles, poles, UDirection); + } if (UDirection) { @@ -2127,9 +2317,13 @@ void BSplSLib::IncreaseDegree(const bool UDirection, NewMults); if (rational) + { GetPoles(newpoles, NewPoles, *NewWeights, UDirection); + } else + { GetPoles(newpoles, NewPoles, UDirection); + } } //================================================================================================= @@ -2148,15 +2342,21 @@ void BSplSLib::Unperiodize(const bool UDirection, bool rational = Weights != nullptr; int dim = 3; if (rational) + { dim++; + } NCollection_Array1 poles(1, dim * Poles.RowLength() * Poles.ColLength()); NCollection_Array1 newpoles(1, dim * NewPoles.RowLength() * NewPoles.ColLength()); if (rational) + { SetPoles(Poles, *Weights, poles, UDirection); + } else + { SetPoles(Poles, poles, UDirection); + } if (UDirection) { @@ -2170,9 +2370,13 @@ void BSplSLib::Unperiodize(const bool UDirection, BSplCLib::Unperiodize(Degree, dim, Mults, Knots, poles, NewMults, NewKnots, newpoles); if (rational) + { GetPoles(newpoles, NewPoles, *NewWeights, UDirection); + } else + { GetPoles(newpoles, NewPoles, UDirection); + } } //======================================================================= @@ -2203,9 +2407,13 @@ void BSplSLib::BuildCache(const double U, int kk, d1, d1p1, d2, d2p1, ii, jj, iii, jjj, Index; double u1, min_degree_domain, max_degree_domain, f, factor[2], u2; if (Weights != nullptr) + { rational_u = rational_v = true; + } else + { rational_u = rational_v = false; + } validateBSplineDegree(UDegree, VDegree); BSplSLib_DataContainer dc; flag_u_or_v = PrepareEval(U, @@ -2237,7 +2445,9 @@ void BSplSLib::BuildCache(const double U, BSplCLib::Bohm(u1, d1, d1, *dc.knots1, 4 * d2p1, *dc.poles); for (kk = 0; kk <= d1; kk++) + { BSplCLib::Bohm(u2, d2, d2, *dc.knots2, 4, *(dc.poles + kk * 4 * d2p1)); + } if (flag_u_or_v) { min_degree_domain = USpanDomain; @@ -2279,7 +2489,9 @@ void BSplSLib::BuildCache(const double U, BSplCLib::Bohm(u1, d1, d1, *dc.knots1, 3 * d2p1, *dc.poles); for (kk = 0; kk <= d1; kk++) + { BSplCLib::Bohm(u2, d2, d2, *dc.knots2, 3, *(dc.poles + kk * 3 * d2p1)); + } if (flag_u_or_v) { min_degree_domain = USpanDomain; @@ -2403,7 +2615,9 @@ void BSplSLib::BuildCache(const double theU, BSplCLib::Bohm(u1, d1, d1, *dc.knots1, aDimension * d2p1, *dc.poles); for (int kk = 0; kk <= d1; kk++) + { BSplCLib::Bohm(u2, d2, d2, *dc.knots2, aDimension, *(dc.poles + kk * aDimension * d2p1)); + } double* aCache = (double*)&(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol())); @@ -2421,7 +2635,9 @@ void BSplSLib::BuildCache(const double theU, double* aPolyCoeffs = dc.poles + (aCol * d2p1 + aRow) * aDimension; aCoeff = aFactors[0] * aFactors[1]; for (i = 0; i < aDimension; i++) + { aCache[i] = aPolyCoeffs[i] * aCoeff; + } aCache += aCacheShift; aFactors[0] *= aDomains[0] / (aCol + 1); } @@ -2434,11 +2650,13 @@ void BSplSLib::BuildCache(const double theU, aCache = (double*)&(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol())); aCache += aCacheShift - 1; for (aRow = 0; aRow <= d2; aRow++) + { for (aCol = 0; aCol <= d1; aCol++) { *aCache = 0.0; aCache += aCacheShift; } + } theCacheArray.SetValue(theCacheArray.LowerRow(), theCacheArray.LowerCol() + aCacheShift - 1, 1.0); @@ -2879,10 +3097,14 @@ void BSplSLib::CacheD2(const double UParameter, // int MinIndMax = 2; if (max_degree < 2) + { MinIndMax = max_degree; + } int MinIndMin = 2; if (min_degree < 2) + { MinIndMin = min_degree; + } index = MinIndMax * dimension; @@ -3080,9 +3302,13 @@ void BSplSLib::MovePoint(const double U, UFirstIndex = UFirstNonZeroBsplineIndex; ULastIndex = UFirstNonZeroBsplineIndex + UDegree; if (UFirstIndex < UIndex1) + { UFirstIndex = UIndex1; + } if (ULastIndex > UIndex2) + { ULastIndex = UIndex2; + } double maxValue = 0.0; int ukk1 = 0, ukk2; @@ -3113,9 +3339,13 @@ void BSplSLib::MovePoint(const double U, VLastIndex = VFirstNonZeroBsplineIndex + VDegree; if (VFirstIndex < VIndex1) + { VFirstIndex = VIndex1; + } if (VLastIndex > VIndex2) + { VLastIndex = VIndex2; + } maxValue = 0.0; int vkk1 = 0, vkk2; @@ -3334,7 +3564,9 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, { min = WG[ii]; if (min_weights > min) + { min_weights = min; + } } } int UD1 = UDegree + 1; @@ -3356,20 +3588,28 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, inverse = 1.0e0 / inverse; lower[0] = ii - UD1; if (lower[0] < 1) + { lower[0] = 1; + } upper[0] = ii + UD2 + 1; if (upper[0] > num_poles[0]) + { upper[0] = num_poles[0]; + } for (jj = 1; jj <= num_poles[1]; jj++) { jj_index = (jj - 1) % poles_length[1] + 1; lower[1] = jj - VD1; if (lower[1] < 1) + { lower[1] = 1; + } upper[1] = jj + VD2 + 1; if (upper[1] > num_poles[1]) + { upper[1] = num_poles[1]; + } const gp_Pnt& Pij = Poles.Value(ii_index, jj_index); Wij = Weights->Value(ii_index, jj_index); const gp_Pnt& Pmj = Poles.Value(ii_minus, jj_index); @@ -3396,21 +3636,29 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, factor = (Xpq - Xij) * Wij; factor -= (Xpq - Xmj) * Wmj; if (factor < 0) + { factor = -factor; + } value += factor; factor = (Ypq - Yij) * Wij; factor -= (Ypq - Ymj) * Wmj; if (factor < 0) + { factor = -factor; + } value += factor; factor = (Zpq - Zij) * Wij; factor -= (Zpq - Zmj) * Wmj; if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative[0] < value) + { max_derivative[0] = value; + } } } } @@ -3435,19 +3683,27 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, const gp_Pnt& Pmj = Poles.Value(ii_minus, jj_index); factor = Pij.X() - Pmj.X(); if (factor < 0) + { factor = -factor; + } value += factor; factor = Pij.Y() - Pmj.Y(); if (factor < 0) + { factor = -factor; + } value += factor; factor = Pij.Z() - Pmj.Z(); if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative[0] < value) + { max_derivative[0] = value; + } } } } @@ -3465,20 +3721,28 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, inverse = 1.0e0 / inverse; lower[0] = ii - VD1; if (lower[0] < 1) + { lower[0] = 1; + } upper[0] = ii + VD2 + 1; if (upper[0] > num_poles[1]) + { upper[0] = num_poles[1]; + } for (jj = 1; jj <= num_poles[0]; jj++) { jj_index = (jj - 1) % poles_length[0] + 1; lower[1] = jj - UD1; if (lower[1] < 1) + { lower[1] = 1; + } upper[1] = jj + UD2 + 1; if (upper[1] > num_poles[0]) + { upper[1] = num_poles[0]; + } const gp_Pnt& Pji = Poles.Value(jj_index, ii_index); Wji = Weights->Value(jj_index, ii_index); const gp_Pnt& Pjm = Poles.Value(jj_index, ii_minus); @@ -3505,21 +3769,29 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, factor = (Xqp - Xji) * Wji; factor -= (Xqp - Xjm) * Wjm; if (factor < 0) + { factor = -factor; + } value += factor; factor = (Yqp - Yji) * Wji; factor -= (Yqp - Yjm) * Wjm; if (factor < 0) + { factor = -factor; + } value += factor; factor = (Zqp - Zji) * Wji; factor -= (Zqp - Zjm) * Wjm; if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative[1] < value) + { max_derivative[1] = value; + } } } } @@ -3544,19 +3816,27 @@ void BSplSLib::Resolution(const NCollection_Array2& Poles, const gp_Pnt& Pjm = Poles.Value(jj_index, ii_minus); factor = Pji.X() - Pjm.X(); if (factor < 0) + { factor = -factor; + } value += factor; factor = Pji.Y() - Pjm.Y(); if (factor < 0) + { factor = -factor; + } value += factor; factor = Pji.Z() - Pjm.Z(); if (factor < 0) + { factor = -factor; + } value += factor; value *= inverse; if (max_derivative[1] < value) + { max_derivative[1] = value; + } } } } @@ -3623,7 +3903,9 @@ void BSplSLib::Interpolate(const int UDegree, poles_array[0], InversionProblem); if (InversionProblem != 0) + { return; + } // extraction of iso v @@ -3712,7 +3994,9 @@ void BSplSLib::Interpolate(const int UDegree, poles_array[0], InversionProblem); if (InversionProblem != 0) + { return; + } // extraction of iso v diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_Box.cxx b/src/FoundationClasses/TKMath/Bnd/Bnd_Box.cxx index 488ddcd471..ee4825be1a 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_Box.cxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_Box.cxx @@ -57,7 +57,9 @@ inline double DistanceInDimension(const double theMin1, { // Check if intervals overlap if ((theMin1 <= theMin2 && theMin2 <= theMax1) || (theMin2 <= theMin1 && theMin1 <= theMax2)) + { return 0.0; + } return DistMini2Box(theMin1, theMax1, theMin2, theMax2); } @@ -81,16 +83,22 @@ bool IsSegmentOut(const double theX1, && ((aXsMin - theX1 < anEps && theX1 - aXsMax < anEps) || (aXsMin - theX2 < anEps && theX2 - aXsMax < anEps) || (theX1 - theXs1 < anEps && theXs1 - theX2 < anEps))) + { return false; + } if (aXsMax - aXsMin < anEps && (theX1 - theXs1 < anEps && theXs1 - theX2 < anEps) && ((aYsMin - theY1 < anEps && theY1 - aYsMax < anEps) || (aYsMin - theY2 < anEps && theY2 - aYsMax < anEps) || (theY1 - theYs1 < anEps && theYs1 - theY2 < anEps))) + { return false; + } if ((theXs1 < theX1 && theXs2 < theX1) || (theXs1 > theX2 && theXs2 > theX2) || (theYs1 < theY1 && theYs2 < theY1) || (theYs1 > theY2 && theYs2 > theY2)) + { return true; + } if (std::abs(theXs2 - theXs1) > anEps) { @@ -99,7 +107,9 @@ bool IsSegmentOut(const double theX1, const double aYb = (std::max(theX1, theX2) - theXs1) * (theYs2 - theYs1) / (theXs2 - theXs1) + theYs1; if ((aYa < theY1 && aYb < theY1) || (aYa > theY2 && aYb > theY2)) + { return true; + } } else if (std::abs(theYs2 - theYs1) > anEps) { @@ -108,10 +118,14 @@ bool IsSegmentOut(const double theX1, const double aXb = (std::max(theY1, theY2) - theYs1) * (theXs2 - theXs1) / (theYs2 - theYs1) + theXs1; if ((aXa < theX1 && aXb < theX1) || (aXa > theX2 && aXb > theX2)) + { return true; + } } else + { return true; + } return false; } @@ -303,15 +317,25 @@ std::optional Bnd_Box::Center() const bool Bnd_Box::IsXThin(const double tol) const { if (IsWhole()) + { return false; + } if (IsVoid()) + { return true; + } if (IsOpenXmin()) + { return false; + } if (IsOpenXmax()) + { return false; + } if (Xmax - Xmin < tol) + { return true; + } return false; } @@ -320,15 +344,25 @@ bool Bnd_Box::IsXThin(const double tol) const bool Bnd_Box::IsYThin(const double tol) const { if (IsWhole()) + { return false; + } if (IsVoid()) + { return true; + } if (IsOpenYmin()) + { return false; + } if (IsOpenYmax()) + { return false; + } if (Ymax - Ymin < tol) + { return true; + } return false; } @@ -337,15 +371,25 @@ bool Bnd_Box::IsYThin(const double tol) const bool Bnd_Box::IsZThin(const double tol) const { if (IsWhole()) + { return false; + } if (IsVoid()) + { return true; + } if (IsOpenZmin()) + { return false; + } if (IsOpenZmax()) + { return false; + } if (Zmax - Zmin < tol) + { return true; + } return false; } @@ -354,15 +398,25 @@ bool Bnd_Box::IsZThin(const double tol) const bool Bnd_Box::IsThin(const double tol) const { if (IsWhole()) + { return false; + } if (IsVoid()) + { return true; + } if (IsOpenXmin() || IsOpenXmax() || Xmax - Xmin >= tol) + { return false; + } if (IsOpenYmin() || IsOpenYmax() || Ymax - Ymin >= tol) + { return false; + } if (IsOpenZmin() || IsOpenZmax() || Zmax - Zmin >= tol) + { return false; + } return true; } @@ -486,44 +540,68 @@ void Bnd_Box::Add(const Bnd_Box& Other) if (!IsOpenXmin()) { if (Other.IsOpenXmin()) + { OpenXmin(); + } else if (Xmin > Other.Xmin) + { Xmin = Other.Xmin; + } } if (!IsOpenXmax()) { if (Other.IsOpenXmax()) + { OpenXmax(); + } else if (Xmax < Other.Xmax) + { Xmax = Other.Xmax; + } } if (!IsOpenYmin()) { if (Other.IsOpenYmin()) + { OpenYmin(); + } else if (Ymin > Other.Ymin) + { Ymin = Other.Ymin; + } } if (!IsOpenYmax()) { if (Other.IsOpenYmax()) + { OpenYmax(); + } else if (Ymax < Other.Ymax) + { Ymax = Other.Ymax; + } } if (!IsOpenZmin()) { if (Other.IsOpenZmin()) + { OpenZmin(); + } else if (Zmin > Other.Zmin) + { Zmin = Other.Zmin; + } } if (!IsOpenZmax()) { if (Other.IsOpenZmax()) + { OpenZmax(); + } else if (Zmax < Other.Zmax) + { Zmax = Other.Zmax; + } } } @@ -552,19 +630,31 @@ void Bnd_Box::Add(const gp_Dir& D) D.Coord(DX, DY, DZ); if (DX < -RealEpsilon()) + { OpenXmin(); + } else if (DX > RealEpsilon()) + { OpenXmax(); + } if (DY < -RealEpsilon()) + { OpenYmin(); + } else if (DY > RealEpsilon()) + { OpenYmax(); + } if (DZ < -RealEpsilon()) + { OpenZmin(); + } else if (DZ > RealEpsilon()) + { OpenZmax(); + } } //================================================================================================= @@ -572,27 +662,45 @@ void Bnd_Box::Add(const gp_Dir& D) bool Bnd_Box::IsOut(const gp_Pnt& P) const { if (IsWhole()) + { return false; + } else if (IsVoid()) + { return true; + } else { double X, Y, Z; P.Coord(X, Y, Z); if (!IsOpenXmin() && (X < (Xmin - Gap))) + { return true; + } else if (!IsOpenXmax() && (X > (Xmax + Gap))) + { return true; + } else if (!IsOpenYmin() && (Y < (Ymin - Gap))) + { return true; + } else if (!IsOpenYmax() && (Y > (Ymax + Gap))) + { return true; + } else if (!IsOpenZmin() && (Z < (Zmin - Gap))) + { return true; + } else if (!IsOpenZmax() && (Z > (Zmax + Gap))) + { return true; + } else + { return false; + } } } @@ -601,9 +709,13 @@ bool Bnd_Box::IsOut(const gp_Pnt& P) const bool Bnd_Box::IsOut(const gp_Pln& P) const { if (IsWhole()) + { return false; + } else if (IsVoid()) + { return true; + } else { double A, B, C, D; @@ -617,17 +729,29 @@ bool Bnd_Box::IsOut(const gp_Pln& P) const double d = A * aXmin + B * aYmin + C * aZmin + D; bool plus = d > 0; if (plus != ((A * aXmin + B * aYmin + C * aZmax + D) > 0)) + { return false; + } if (plus != ((A * aXmin + B * aYmax + C * aZmin + D) > 0)) + { return false; + } if (plus != ((A * aXmin + B * aYmax + C * aZmax + D) > 0)) + { return false; + } if (plus != ((A * aXmax + B * aYmin + C * aZmin + D) > 0)) + { return false; + } if (plus != ((A * aXmax + B * aYmin + C * aZmax + D) > 0)) + { return false; + } if (plus != ((A * aXmax + B * aYmax + C * aZmin + D) > 0)) + { return false; + } return plus == ((A * aXmax + B * aYmax + C * aZmax + D) > 0); } } @@ -637,9 +761,13 @@ bool Bnd_Box::IsOut(const gp_Pln& P) const bool Bnd_Box::IsOut(const gp_Lin& L) const { if (IsWhole()) + { return false; + } else if (IsVoid()) + { return true; + } else { double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0; @@ -679,7 +807,9 @@ bool Bnd_Box::IsOut(const gp_Lin& L) const par2 = (myYmax - L.Location().XYZ().Y()) / L.Direction().XYZ().Y(); // Check if parameter ranges from this axis are disjoint (early exit) if (parmax < std::min(par1, par2) || parmin > std::max(par1, par2)) + { return true; + } parmin = std::max(parmin, std::min(par1, par2)); parmax = std::min(parmax, std::max(par1, par2)); @@ -702,7 +832,9 @@ bool Bnd_Box::IsOut(const gp_Lin& L) const par2 = (myZmax - L.Location().XYZ().Z()) / L.Direction().XYZ().Z(); // Check if parameter ranges from this axis are disjoint (early exit) if (parmax < std::min(par1, par2) || parmin > std::max(par1, par2)) + { return true; + } parmin = std::max(parmin, std::min(par1, par2)); parmax = std::min(parmax, std::max(par1, par2)); @@ -714,12 +846,16 @@ bool Bnd_Box::IsOut(const gp_Lin& L) const else { if (L.Location().XYZ().Z() < myZmin || myZmax < L.Location().XYZ().Z()) + { return true; + } zmin = L.Location().XYZ().Z(); zmax = L.Location().XYZ().Z(); } if (zmax < myZmin || myZmax < zmin) + { return true; + } if (xToSet) { @@ -729,7 +865,9 @@ bool Bnd_Box::IsOut(const gp_Lin& L) const xmax = std::max(par1, par2); } if (xmax < myXmin || myXmax < xmin) + { return true; + } if (yToSet) { @@ -739,7 +877,9 @@ bool Bnd_Box::IsOut(const gp_Lin& L) const ymax = std::max(par1, par2); } if (ymax < myYmin || myYmax < ymin) + { return true; + } } return false; } @@ -754,43 +894,71 @@ bool Bnd_Box::IsOut(const Bnd_Box& Other) const const double aDelta = Other.Gap + Gap; // Early exit on first separating axis found if (Xmin - Other.Xmax > aDelta) + { return true; + } if (Other.Xmin - Xmax > aDelta) + { return true; + } if (Ymin - Other.Ymax > aDelta) + { return true; + } if (Other.Ymin - Ymax > aDelta) + { return true; + } if (Zmin - Other.Zmax > aDelta) + { return true; + } if (Other.Zmin - Zmax > aDelta) + { return true; + } return false; } // Handle special cases if (IsVoid() || Other.IsVoid()) + { return true; + } if (IsWhole() || Other.IsWhole()) + { return false; + } const double aDelta = Other.Gap + Gap; // Check each axis with early exit if (!IsOpenXmin() && !Other.IsOpenXmax() && Xmin - Other.Xmax > aDelta) + { return true; + } if (!IsOpenXmax() && !Other.IsOpenXmin() && Other.Xmin - Xmax > aDelta) + { return true; + } if (!IsOpenYmin() && !Other.IsOpenYmax() && Ymin - Other.Ymax > aDelta) + { return true; + } if (!IsOpenYmax() && !Other.IsOpenYmin() && Other.Ymin - Ymax > aDelta) + { return true; + } if (!IsOpenZmin() && !Other.IsOpenZmax() && Zmin - Other.Zmax > aDelta) + { return true; + } if (!IsOpenZmax() && !Other.IsOpenZmin() && Other.Zmin - Zmax > aDelta) + { return true; + } return false; } @@ -815,22 +983,32 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const { if (IsWhole()) + { return false; + } else if (IsVoid()) + { return true; + } constexpr double eps = RealSmall(); double myXmin, myYmin, myZmin, myXmax, myYmax, myZmax; Get(myXmin, myYmin, myZmin, myXmax, myYmax, myZmax); if (std::abs(D.X()) < eps && std::abs(D.Y()) < eps) + { return IsSegmentOut(myXmin, myYmin, myXmax, myYmax, P1.X(), P1.Y(), P2.X(), P2.Y()); + } if (std::abs(D.X()) < eps && std::abs(D.Z()) < eps) + { return IsSegmentOut(myXmin, myZmin, myXmax, myZmax, P1.X(), P1.Z(), P2.X(), P2.Z()); + } if (std::abs(D.Y()) < eps && std::abs(D.Z()) < eps) + { return IsSegmentOut(myYmin, myZmin, myYmax, myZmax, P1.Y(), P1.Z(), P2.Y(), P2.Z()); + } if (std::abs(D.X()) < eps) { @@ -842,7 +1020,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmin - P1.Y()) * D.Z() / D.Y() + P1.Z(), P2.X(), (myYmin - P2.Y()) * D.Z() / D.Y() + P2.Z())) + { return false; + } if (!IsSegmentOut(myXmin, myZmin, @@ -852,7 +1032,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmax - P1.Y()) * D.Z() / D.Y() + P1.Z(), P2.X(), (myYmax - P2.Y()) * D.Z() / D.Y() + P2.Z())) + { return false; + } if (!IsSegmentOut(myXmin, myYmin, @@ -862,7 +1044,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmin - P1.Z()) * D.Y() / D.Z() + P1.Y(), P2.X(), (myZmin - P2.Z()) * D.Y() / D.Z() + P2.Y())) + { return false; + } if (!IsSegmentOut(myXmin, myYmin, @@ -872,7 +1056,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmax - P1.Z()) * D.Y() / D.Z() + P1.Y(), P2.X(), (myZmax - P2.Z()) * D.Y() / D.Z() + P2.Y())) + { return false; + } return true; } // if(D.X() == 0) @@ -887,7 +1073,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmin - P1.X()) * D.Z() / D.X() + P1.Z(), P2.Y(), (myXmin - P2.X()) * D.Z() / D.X() + P2.Z())) + { return false; + } if (!IsSegmentOut(myYmin, myZmin, @@ -897,7 +1085,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmax - P1.X()) * D.Z() / D.X() + P1.Z(), P2.Y(), (myXmax - P2.X()) * D.Z() / D.X() + P2.Z())) + { return false; + } if (!IsSegmentOut(myYmin, myXmin, @@ -907,7 +1097,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmin - P1.Z()) * D.X() / D.Z() + P1.X(), P2.Y(), (myZmin - P2.Z()) * D.X() / D.Z() + P2.X())) + { return false; + } if (!IsSegmentOut(myYmin, myXmin, @@ -917,7 +1109,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmax - P1.Z()) * D.X() / D.Z() + P1.X(), P2.Y(), (myZmax - P2.Z()) * D.X() / D.Z() + P2.X())) + { return false; + } return true; } // if(D.Y() == 0) @@ -932,7 +1126,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmax - P1.Y()) * D.X() / D.Y() + P1.X(), P2.Z(), (myYmax - P2.Y()) * D.X() / D.Y() + P2.X())) + { return false; + } if (!IsSegmentOut(myZmin, myXmin, @@ -942,7 +1138,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmin - P1.Y()) * D.X() / D.Y() + P1.X(), P2.Z(), (myYmin - P2.Y()) * D.X() / D.Y() + P2.X())) + { return false; + } if (!IsSegmentOut(myZmin, myYmin, @@ -952,7 +1150,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmax - P1.X()) * D.Y() / D.X() + P1.Y(), P2.Z(), (myXmax - P2.X()) * D.Y() / D.X() + P2.Y())) + { return false; + } if (!IsSegmentOut(myZmin, myYmin, @@ -962,7 +1162,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmin - P1.X()) * D.Y() / D.X() + P1.Y(), P2.Z(), (myXmin - P2.X()) * D.Y() / D.X() + P2.Y())) + { return false; + } return true; } // if(D.Z() == 0) @@ -975,7 +1177,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmin - P1.Y()) / D.Y() * D.Z() + P1.Z(), (myYmin - P2.Y()) / D.Y() * D.X() + P2.X(), (myYmin - P2.Y()) / D.Y() * D.Z() + P2.Z())) + { return false; + } if (!IsSegmentOut(myXmin, myZmin, @@ -985,7 +1189,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myYmax - P1.Y()) / D.Y() * D.Z() + P1.Z(), (myYmax - P2.Y()) / D.Y() * D.X() + P2.X(), (myYmax - P2.Y()) / D.Y() * D.Z() + P2.Z())) + { return false; + } if (!IsSegmentOut(myXmin, myYmin, @@ -995,7 +1201,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmin - P1.Z()) / D.Z() * D.Y() + P1.Y(), (myZmin - P2.Z()) / D.Z() * D.X() + P2.X(), (myZmin - P2.Z()) / D.Z() * D.Y() + P2.Y())) + { return false; + } if (!IsSegmentOut(myXmin, myYmin, @@ -1005,7 +1213,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myZmax - P1.Z()) / D.Z() * D.Y() + P1.Y(), (myZmax - P2.Z()) / D.Z() * D.X() + P2.X(), (myZmax - P2.Z()) / D.Z() * D.Y() + P2.Y())) + { return false; + } if (!IsSegmentOut(myZmin, myYmin, @@ -1015,7 +1225,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmin - P1.X()) / D.X() * D.Y() + P1.Y(), (myXmin - P2.X()) / D.X() * D.Z() + P2.Z(), (myXmin - P2.X()) / D.X() * D.Y() + P2.Y())) + { return false; + } if (!IsSegmentOut(myZmin, myYmin, @@ -1025,7 +1237,9 @@ bool Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir& D) const (myXmax - P1.X()) / D.X() * D.Y() + P1.Y(), (myXmax - P2.X()) / D.X() * D.Z() + P2.Z(), (myXmax - P2.X()) / D.X() * D.Y() + P2.Y())) + { return false; + } return true; } @@ -1058,41 +1272,69 @@ void Bnd_Box::Dump() const { std::cout << "Box3D : "; if (IsVoid()) + { std::cout << "Void"; + } else if (IsWhole()) + { std::cout << "Whole"; + } else { std::cout << "\n Xmin : "; if (IsOpenXmin()) + { std::cout << "Infinite"; + } else + { std::cout << Xmin; + } std::cout << "\n Xmax : "; if (IsOpenXmax()) + { std::cout << "Infinite"; + } else + { std::cout << Xmax; + } std::cout << "\n Ymin : "; if (IsOpenYmin()) + { std::cout << "Infinite"; + } else + { std::cout << Ymin; + } std::cout << "\n Ymax : "; if (IsOpenYmax()) + { std::cout << "Infinite"; + } else + { std::cout << Ymax; + } std::cout << "\n Zmin : "; if (IsOpenZmin()) + { std::cout << "Infinite"; + } else + { std::cout << Zmin; + } std::cout << "\n Zmax : "; if (IsOpenZmax()) + { std::cout << "Infinite"; + } else + { std::cout << Zmax; + } } std::cout << "\n Gap : " << Gap; std::cout << "\n"; diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_Box2d.cxx b/src/FoundationClasses/TKMath/Bnd/Bnd_Box2d.cxx index 9eddb1ccdd..ea300441bf 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_Box2d.cxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_Box2d.cxx @@ -49,13 +49,21 @@ void Bnd_Box2d::Update(const double x, const double y, const double X, const dou else { if (!(Flags & XminMask)) + { Xmin = std::min(Xmin, x); + } if (!(Flags & XmaxMask)) + { Xmax = std::max(Xmax, X); + } if (!(Flags & YminMask)) + { Ymin = std::min(Ymin, y); + } if (!(Flags & YmaxMask)) + { Ymax = std::max(Ymax, Y); + } } } @@ -74,13 +82,21 @@ void Bnd_Box2d::Update(const double X, const double Y) else { if (!(Flags & XminMask)) + { Xmin = std::min(Xmin, X); + } if (!(Flags & XmaxMask)) + { Xmax = std::max(Xmax, X); + } if (!(Flags & YminMask)) + { Ymin = std::min(Ymin, Y); + } if (!(Flags & YmaxMask)) + { Ymax = std::max(Ymax, Y); + } } } @@ -89,7 +105,9 @@ void Bnd_Box2d::Update(const double X, const double Y) void Bnd_Box2d::Get(double& x, double& y, double& Xm, double& Ym) const { if (Flags & VoidMask) + { throw Standard_ConstructionError("Bnd_Box is void"); + } x = GetXMin(); Xm = GetXMax(); @@ -139,7 +157,9 @@ Bnd_Box2d Bnd_Box2d::Transformed(const gp_Trsf2d& T) const const gp_TrsfForm aF = T.Form(); Bnd_Box2d aNewBox(*this); if (IsVoid()) + { return aNewBox; + } if (aF == gp_Identity) { @@ -149,13 +169,21 @@ Bnd_Box2d Bnd_Box2d::Transformed(const gp_Trsf2d& T) const double aDX, aDY; (T.TranslationPart()).Coord(aDX, aDY); if (!(Flags & XminMask)) + { aNewBox.Xmin += aDX; + } if (!(Flags & XmaxMask)) + { aNewBox.Xmax += aDX; + } if (!(Flags & YminMask)) + { aNewBox.Ymin += aDY; + } if (!(Flags & YmaxMask)) + { aNewBox.Ymax += aDY; + } } else { @@ -230,42 +258,66 @@ Bnd_Box2d Bnd_Box2d::Transformed(const gp_Trsf2d& T) const void Bnd_Box2d::Add(const Bnd_Box2d& Other) { if (IsWhole()) + { return; + } else if (Other.IsVoid()) + { return; + } else if (Other.IsWhole()) + { SetWhole(); + } else if (IsVoid()) + { (*this) = Other; + } else { if (!IsOpenXmin()) { if (Other.IsOpenXmin()) + { OpenXmin(); + } else if (Xmin > Other.Xmin) + { Xmin = Other.Xmin; + } } if (!IsOpenXmax()) { if (Other.IsOpenXmax()) + { OpenXmax(); + } else if (Xmax < Other.Xmax) + { Xmax = Other.Xmax; + } } if (!IsOpenYmin()) { if (Other.IsOpenYmin()) + { OpenYmin(); + } else if (Ymin > Other.Ymin) + { Ymin = Other.Ymin; + } } if (!IsOpenYmax()) { if (Other.IsOpenYmax()) + { OpenYmax(); + } else if (Ymax < Other.Ymax) + { Ymax = Other.Ymax; + } } Gap = std::max(Gap, Other.Gap); } @@ -279,14 +331,22 @@ void Bnd_Box2d::Add(const gp_Dir2d& D) double DY = D.Y(); if (DX < -RealEpsilon()) + { OpenXmin(); + } else if (DX > RealEpsilon()) + { OpenXmax(); + } if (DY < -RealEpsilon()) + { OpenYmin(); + } else if (DY > RealEpsilon()) + { OpenYmax(); + } } //================================================================================================= @@ -294,23 +354,37 @@ void Bnd_Box2d::Add(const gp_Dir2d& D) bool Bnd_Box2d::IsOut(const gp_Pnt2d& P) const { if (IsWhole()) + { return false; + } else if (IsVoid()) + { return true; + } else { double X = P.X(); double Y = P.Y(); if (!(Flags & XminMask) && (X < (Xmin - Gap))) + { return true; + } else if (!(Flags & XmaxMask) && (X > (Xmax + Gap))) + { return true; + } else if (!(Flags & YminMask) && (Y < (Ymin - Gap))) + { return true; + } else if (!(Flags & YmaxMask) && (Y > (Ymax + Gap))) + { return true; + } else + { return false; + } } } @@ -386,32 +460,52 @@ bool Bnd_Box2d::IsOut(const Bnd_Box2d& Other) const { const double aDelta = Other.Gap + Gap; if (Xmin - Other.Xmax > aDelta) + { return true; + } if (Other.Xmin - Xmax > aDelta) + { return true; + } if (Ymin - Other.Ymax > aDelta) + { return true; + } if (Other.Ymin - Ymax > aDelta) + { return true; + } return false; } // Handle special cases if (IsVoid() || Other.IsVoid()) + { return true; + } if (IsWhole() || Other.IsWhole()) + { return false; + } double OXmin, OXmax, OYmin, OYmax; Other.Get(OXmin, OYmin, OXmax, OYmax); if (!(Flags & XminMask) && (OXmax < (Xmin - Gap))) + { return true; + } if (!(Flags & XmaxMask) && (OXmin > (Xmax + Gap))) + { return true; + } if (!(Flags & YminMask) && (OYmax < (Ymin - Gap))) + { return true; + } if (!(Flags & YmaxMask) && (OYmin > (Ymax + Gap))) + { return true; + } return false; } @@ -471,31 +565,51 @@ void Bnd_Box2d::Dump() const { std::cout << "Box2d : "; if (IsVoid()) + { std::cout << "Void"; + } else if (IsWhole()) + { std::cout << "Whole"; + } else { std::cout << "\n Xmin : "; if (IsOpenXmin()) + { std::cout << "Infinite"; + } else + { std::cout << Xmin; + } std::cout << "\n Xmax : "; if (IsOpenXmax()) + { std::cout << "Infinite"; + } else + { std::cout << Xmax; + } std::cout << "\n Ymin : "; if (IsOpenYmin()) + { std::cout << "Infinite"; + } else + { std::cout << Ymin; + } std::cout << "\n Ymax : "; if (IsOpenYmax()) + { std::cout << "Infinite"; + } else + { std::cout << Ymax; + } } std::cout << "\n Gap : " << Gap; std::cout << "\n"; diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_OBB.cxx b/src/FoundationClasses/TKMath/Bnd/Bnd_OBB.cxx index 79284da0e6..81ffd1108c 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_OBB.cxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_OBB.cxx @@ -78,8 +78,10 @@ public: //! @name Definition of rejection/acceptance rules Bnd_Range& theMetric) const override { if (myPrmMin > myPrmMax) + { // No parameters computed yet return false; + } double aPrmMin = myPrmMin, aPrmMax = myPrmMax; bool isToReject = true; @@ -119,13 +121,17 @@ public: //! @name Definition of rejection/acceptance rules bool RejectMetric(const Bnd_Range& theMetric) const override { if (myPrmMin > myPrmMax) + { // no parameters computed return false; + } double aMin, aMax; if (!theMetric.GetBounds(aMin, aMax)) + { // void metric return false; + } // Check if the box of the branch is inside of the already computed parameters return aMin > myPrmMin && aMax < myPrmMax; @@ -154,22 +160,30 @@ public: //! @name Choosing the best branch bool IsMetricBetter(const Bnd_Range& theLeft, const Bnd_Range& theRight) const override { if (myPrmMin > myPrmMax) + { // no parameters computed return true; + } double aMin[2], aMax[2]; if (!theLeft.GetBounds(aMin[0], aMax[0]) || !theRight.GetBounds(aMin[1], aMax[1])) + { // void metrics return true; + } // Choose branch with larger extension over computed parameters double anExt[2] = {0.0, 0.0}; for (int i = 0; i < 2; ++i) { if (aMin[i] < myPrmMin) + { anExt[i] += myPrmMin - aMin[i]; + } if (aMax[i] > myPrmMax) + { anExt[i] += aMax[i] - myPrmMax; + } } return anExt[0] > anExt[1]; } @@ -282,16 +296,22 @@ private: theMin = RealLast(), theMax = RealFirst(); if (myOptimal) + { Project(theAxis, theMin, theMax); + } else { for (int i = 0; i < myNbExtremalPoints; ++i) { double aPrm = theAxis.Dot(myLExtremalPoints[i]); if (aPrm < theMin) + { theMin = aPrm; + } if (aPrm > theMax) + { theMax = aPrm; + } } } } @@ -315,9 +335,13 @@ private: theMin = anExtremePointsSelector.MinPrm(); theMax = anExtremePointsSelector.MaxPrm(); if (thePntMin) + { *thePntMin = anExtremePointsSelector.MinPnt(); + } if (thePntMax) + { *thePntMax = anExtremePointsSelector.MaxPnt(); + } } else { @@ -330,13 +354,17 @@ private: { theMin = aPrm; if (thePntMin) + { *thePntMin = aPoint; + } } if (aPrm > theMax) { theMax = aPrm; if (thePntMax) + { *thePntMax = aPoint; + } } } } @@ -476,7 +504,9 @@ void OBBTool::ComputeExtremePoints() if (!myOptimal) { for (int i = 0; i < 5; i++) + { myTriIdx[i] = INT_MAX; + } // Compute myTriIdx[0] and myTriIdx[1]. double aMaxSqDist = -1.0; @@ -511,7 +541,9 @@ void OBBTool::FillToTriangle3() for (int i = 0; i < myNbExtremalPoints; i++) { if ((i == myTriIdx[0]) || (i == myTriIdx[1])) + { continue; + } const gp_XYZ& aP = myLExtremalPoints[i]; const double aDistToAxe = anAxis.CrossSquareMagnitude(aP - aP0); @@ -540,7 +572,9 @@ void OBBTool::FillToTriangle5(const gp_XYZ& theNormal, const gp_XYZ& theBarryCen for (int aPtIdx = 0; aPtIdx < myNbExtremalPoints; aPtIdx++) { if ((aPtIdx == myTriIdx[0]) || (aPtIdx == myTriIdx[1]) || (aPtIdx == myTriIdx[2])) + { continue; + } const gp_XYZ& aCurrPoint = myLExtremalPoints[aPtIdx]; const double aParam = theNormal.Dot(aCurrPoint - theBarryCenter); @@ -559,10 +593,14 @@ void OBBTool::FillToTriangle5(const gp_XYZ& theNormal, const gp_XYZ& theBarryCen // The points must be in the different sides of the triangle plane. if (id3 >= 0 && aParams[0] < -Precision::Confusion()) + { myTriIdx[3] = id3; + } if (id4 >= 0 && aParams[1] > Precision::Confusion()) + { myTriIdx[4] = id4; + } } //======================================================================= @@ -591,7 +629,9 @@ void OBBTool::ProcessTriangle(const int theIdx1, double aSqMod = aZAxis.SquareModulus(); if (aSqMod < Precision::SquareConfusion()) + { return; + } aZAxis /= std::sqrt(aSqMod); @@ -611,7 +651,9 @@ void OBBTool::ProcessTriangle(const int theIdx1, } if (theIsBuiltTrg) + { FillToTriangle5(aZAxis, myLExtremalPoints[theIdx1]); + } // Min and Max parameter const int aNbPoints = 2 * aNbAxes; @@ -624,7 +666,9 @@ void OBBTool::ProcessTriangle(const int theIdx1, for (int anAxeInd = 0; anAxeInd < aNbAxes; anAxeInd++) { if (!aXAxisValid[anAxeInd]) + { continue; + } const gp_XYZ& aAX = aXAxis[anAxeInd]; // Compute params on XAxis @@ -641,7 +685,9 @@ void OBBTool::ProcessTriangle(const int theIdx1, } if (aMinIdx < 0) + { return; + } myAxes[0] = aXAxis[aMinIdx]; myAxes[1] = aYAxis[aMinIdx].Normalized(); @@ -780,7 +826,9 @@ void Bnd_OBB::ReBuild(const NCollection_Array1& theListOfPoints, case 1: ProcessOnePoint(theListOfPoints.First()); if (theListOfTolerances) + { Enlarge(theListOfTolerances->First()); + } return; case 2: { const double aTol1 = (theListOfTolerances == nullptr) ? 0.0 : theListOfTolerances->First(); @@ -831,7 +879,9 @@ void Bnd_OBB::ReBuild(const NCollection_Array1& theListOfPoints, bool Bnd_OBB::IsOut(const Bnd_OBB& theOther) const { if (IsVoid() || theOther.IsVoid()) + { return true; + } if (myIsAABox && theOther.myIsAABox) { @@ -867,13 +917,17 @@ bool Bnd_OBB::IsOut(const Bnd_OBB& theOther) const // Length of the second segment double aLSegm2 = 0; for (int j = 0; j < 3; ++j) + { aLSegm2 += theOther.myHDims[j] * std::abs(theOther.myAxes[j].Dot(myAxes[i])); + } // Distance between projected centers double aDistCC = std::abs(D.Dot(myAxes[i])); if (aDistCC > myHDims[i] + aLSegm2) + { return true; + } } // Check the axes of the Other box, i.e. L is one of theOther.myAxes @@ -883,13 +937,17 @@ bool Bnd_OBB::IsOut(const Bnd_OBB& theOther) const // Length of the first segment double aLSegm1 = 0.; for (int j = 0; j < 3; ++j) + { aLSegm1 += myHDims[j] * std::abs(myAxes[j].Dot(theOther.myAxes[i])); + } // Distance between projected centers double aDistCC = std::abs(D.Dot(theOther.myAxes[i])); if (aDistCC > aLSegm1 + theOther.myHDims[i]) + { return true; + } } const double aTolNull = Epsilon(1.0); @@ -904,25 +962,33 @@ bool Bnd_OBB::IsOut(const Bnd_OBB& theOther) const const double aNorm = aLAxe.Modulus(); if (aNorm < aTolNull) + { continue; + } aLAxe /= aNorm; // Length of the first segment double aLSegm1 = 0.; for (int k = 0; k < 3; ++k) + { aLSegm1 += myHDims[k] * std::abs(myAxes[k].Dot(aLAxe)); + } // Length of the second segment double aLSegm2 = 0.; for (int k = 0; k < 3; ++k) + { aLSegm2 += theOther.myHDims[k] * std::abs(theOther.myAxes[k].Dot(aLAxe)); + } // Distance between projected centers double aDistCC = std::abs(D.Dot(aLAxe)); if (aDistCC > aLSegm1 + aLSegm2) + { return true; + } } } @@ -951,14 +1017,18 @@ bool Bnd_OBB::IsOut(const gp_Pnt& theP) const bool Bnd_OBB::IsCompletelyInside(const Bnd_OBB& theOther) const { if (IsVoid() || theOther.IsVoid()) + { return false; + } gp_Pnt aVert[8]; theOther.GetVertex(aVert); for (int i = 0; i < 8; i++) { if (IsOut(aVert[i])) + { return false; + } } return true; diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_Range.cxx b/src/FoundationClasses/TKMath/Bnd/Bnd_Range.cxx index db74adb589..a85ed83fe7 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_Range.cxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_Range.cxx @@ -40,13 +40,19 @@ void Bnd_Range::Common(const Bnd_Range& theOther) bool Bnd_Range::Union(const Bnd_Range& theOther) { if (IsVoid() || theOther.IsVoid()) + { return false; + } if (myLast < theOther.myFirst) + { return false; + } if (myFirst > theOther.myLast) + { return false; + } myFirst = std::min(myFirst, theOther.myFirst); myLast = std::max(myLast, theOther.myLast); @@ -60,7 +66,9 @@ Bnd_Range::IntersectStatus Bnd_Range::IsIntersected(const double theVal, const double thePeriod) const { if (IsVoid()) + { return IntersectStatus_Out; + } const double aPeriod = std::abs(thePeriod); const double aDF = myFirst - theVal, aDL = myLast - theVal; @@ -69,10 +77,14 @@ Bnd_Range::IntersectStatus Bnd_Range::IsIntersected(const double theVal, { const double aDelta = aDF * aDL; if (IsEqual(aDelta, 0.0)) + { return IntersectStatus_Boundary; + } if (aDelta > 0.0) + { return IntersectStatus_Out; + } return IntersectStatus_In; } diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_Sphere.cxx b/src/FoundationClasses/TKMath/Bnd/Bnd_Sphere.cxx index 440f3648a9..a7bcf5c20d 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_Sphere.cxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_Sphere.cxx @@ -88,7 +88,9 @@ void Bnd_Sphere::Add(const Bnd_Sphere& theOther) } if (theOther.myRadius + aDist <= myRadius) + { return; // this sphere encloses other + } // expansion const double dfR = (aDist + myRadius + theOther.myRadius) * 0.5; @@ -109,9 +111,13 @@ bool Bnd_Sphere::IsOut(const gp_XYZ& theXYZ, double& theMaxDist) const double aCurMinDist, aCurMaxDist; Distances(theXYZ, aCurMinDist, aCurMaxDist); if (aCurMinDist > theMaxDist) + { return true; + } if (myIsValid && aCurMaxDist < theMaxDist) + { theMaxDist = aCurMaxDist; + } return false; } diff --git a/src/FoundationClasses/TKMath/Convert/Convert_ConeToBSplineSurface.cxx b/src/FoundationClasses/TKMath/Convert/Convert_ConeToBSplineSurface.cxx index e5dfef81f3..7558142f6b 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_ConeToBSplineSurface.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_ConeToBSplineSurface.cxx @@ -137,9 +137,13 @@ Convert_ConeToBSplineSurface::Convert_ConeToBSplineSurface(const gp_Cone& C, for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = std::cos(AlfaU); + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { @@ -201,9 +205,13 @@ Convert_ConeToBSplineSurface::Convert_ConeToBSplineSurface(const gp_Cone& C, for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W = 0.5; // = std::cos(pi /3) + } else + { W = 1.; + } for (j = 1; j <= myNbVPoles; j++) { diff --git a/src/FoundationClasses/TKMath/Convert/Convert_ConicToBSplineCurve.cxx b/src/FoundationClasses/TKMath/Convert/Convert_ConicToBSplineCurve.cxx index e6ea9bc77c..944623aa59 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_ConicToBSplineCurve.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_ConicToBSplineCurve.cxx @@ -80,7 +80,9 @@ Standard_DISABLE_DEPRECATION_WARNINGS gp_Pnt2d Convert_ConicToBSplineCurve::Pole(const int theIndex) const { if (theIndex < 1 || theIndex > myPoles.Length()) + { throw Standard_OutOfRange("Convert_ConicToBSplineCurve::Pole: Index out of range"); + } return myPoles(theIndex); } @@ -89,7 +91,9 @@ Standard_DISABLE_DEPRECATION_WARNINGS gp_Pnt2d double Convert_ConicToBSplineCurve::Weight(const int theIndex) const { if (theIndex < 1 || theIndex > myPoles.Length()) + { throw Standard_OutOfRange("Convert_ConicToBSplineCurve::Weight: Index out of range"); + } return myWeights(theIndex); } @@ -98,7 +102,9 @@ double Convert_ConicToBSplineCurve::Weight(const int theIndex) const double Convert_ConicToBSplineCurve::Knot(const int theIndex) const { if (theIndex < 1 || theIndex > myKnots.Length()) + { throw Standard_OutOfRange("Convert_ConicToBSplineCurve::Knot: Index out of range"); + } return myKnots(theIndex); } @@ -107,7 +113,9 @@ double Convert_ConicToBSplineCurve::Knot(const int theIndex) const int Convert_ConicToBSplineCurve::Multiplicity(const int theIndex) const { if (theIndex < 1 || theIndex > myKnots.Length()) + { throw Standard_OutOfRange("Convert_ConicToBSplineCurve::Multiplicity: Index out of range"); + } return myMults(theIndex); } diff --git a/src/FoundationClasses/TKMath/Convert/Convert_CylinderToBSplineSurface.cxx b/src/FoundationClasses/TKMath/Convert/Convert_CylinderToBSplineSurface.cxx index 46cc318897..e8aa09f60a 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_CylinderToBSplineSurface.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_CylinderToBSplineSurface.cxx @@ -125,9 +125,13 @@ Convert_CylinderToBSplineSurface::Convert_CylinderToBSplineSurface(const gp_Cyli for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = std::cos(AlfaU); + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { @@ -188,9 +192,13 @@ Convert_CylinderToBSplineSurface::Convert_CylinderToBSplineSurface(const gp_Cyli for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W = 0.5; // = std::cos(pi /3) + } else + { W = 1.; + } for (j = 1; j <= myNbVPoles; j++) { diff --git a/src/FoundationClasses/TKMath/Convert/Convert_GridPolynomialToPoles.cxx b/src/FoundationClasses/TKMath/Convert/Convert_GridPolynomialToPoles.cxx index 45610d98e3..4f963c8096 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_GridPolynomialToPoles.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_GridPolynomialToPoles.cxx @@ -53,9 +53,13 @@ Convert_GridPolynomialToPoles::Convert_GridPolynomialToPoles( myVDegree = NumCoeffPerSurface->Value(2) - 1; if (myUDegree > MaxUDegree) + { throw Standard_DomainError("Convert : Incoherence between NumCoeffPerSurface and MaxUDegree"); + } if (myVDegree > MaxVDegree) + { throw Standard_DomainError("Convert : Incoherence between NumCoeffPerSurface and MaxVDegree"); + } occ::handle> NumCoeff = new (NCollection_HArray2)(1, 1, 1, 2); NumCoeff->SetValue(1, 1, NumCoeffPerSurface->Value(1)); @@ -112,15 +116,23 @@ Convert_GridPolynomialToPoles::Convert_GridPolynomialToPoles( for (int ii = 1; ii <= NbUSurfaces * NbVSurfaces; ii++) { if (NumCoeffPerSurface->Value(ii, 1) > myUDegree + 1) + { myUDegree = NumCoeffPerSurface->Value(ii, 1) - 1; + } if (NumCoeffPerSurface->Value(ii, 2) > myVDegree + 1) + { myVDegree = NumCoeffPerSurface->Value(ii, 2) - 1; + } } if (myUDegree > RealUDegree) + { throw Standard_DomainError("Convert : Incoherence between NumCoeffPerSurface and MaxUDegree"); + } if (myVDegree > RealVDegree) + { throw Standard_DomainError("Convert : Incoherence between NumCoeffPerSurface and MaxVDegree"); + } Perform(UContinuity, VContinuity, diff --git a/src/FoundationClasses/TKMath/Convert/Convert_SphereToBSplineSurface.cxx b/src/FoundationClasses/TKMath/Convert/Convert_SphereToBSplineSurface.cxx index 493c97207c..f3c3ad216b 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_SphereToBSplineSurface.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_SphereToBSplineSurface.cxx @@ -153,16 +153,24 @@ Convert_SphereToBSplineSurface::Convert_SphereToBSplineSurface(const gp_Sphere& for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = std::cos(AlfaU); + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = std::cos(AlfaV); + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); @@ -268,16 +276,24 @@ Convert_SphereToBSplineSurface::Convert_SphereToBSplineSurface(const gp_Sphere& for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = CosU; + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = CosV; + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); @@ -335,16 +351,24 @@ Convert_SphereToBSplineSurface::Convert_SphereToBSplineSurface(const gp_Sphere& for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = 0.5; + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = std::sqrt(2.) / 2.; + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); diff --git a/src/FoundationClasses/TKMath/Convert/Convert_TorusToBSplineSurface.cxx b/src/FoundationClasses/TKMath/Convert/Convert_TorusToBSplineSurface.cxx index 69bc70290c..c29e53c65b 100644 --- a/src/FoundationClasses/TKMath/Convert/Convert_TorusToBSplineSurface.cxx +++ b/src/FoundationClasses/TKMath/Convert/Convert_TorusToBSplineSurface.cxx @@ -155,16 +155,24 @@ Convert_TorusToBSplineSurface::Convert_TorusToBSplineSurface(const gp_Torus& T, for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = std::cos(AlfaU); + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = std::cos(AlfaV); + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); @@ -270,16 +278,24 @@ Convert_TorusToBSplineSurface::Convert_TorusToBSplineSurface(const gp_Torus& T, for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = CosU; + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = CosV; + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); @@ -333,16 +349,24 @@ Convert_TorusToBSplineSurface::Convert_TorusToBSplineSurface(const gp_Torus& T) for (i = 1; i <= myNbUPoles; i++) { if (i % 2 == 0) + { W1 = 0.5; + } else + { W1 = 1.; + } for (j = 1; j <= myNbVPoles; j++) { if (j % 2 == 0) + { W2 = 0.5; + } else + { W2 = 1.; + } myWeights(i, j) = W1 * W2; myPoles(i, j).Transform(Trsf); diff --git a/src/FoundationClasses/TKMath/ElCLib/ElCLib.cxx b/src/FoundationClasses/TKMath/ElCLib/ElCLib.cxx index 40f0da6354..074d93487c 100644 --- a/src/FoundationClasses/TKMath/ElCLib/ElCLib.cxx +++ b/src/FoundationClasses/TKMath/ElCLib/ElCLib.cxx @@ -1200,15 +1200,19 @@ double ElCLib::CircleParameter(const gp_Ax2& Pos, const gp_Pnt& P) { const gp_Vec aVec(Pos.Location(), P); if (aVec.SquareMagnitude() < gp::Resolution()) + { // coinciding points -> infinite number of parameters return 0.0; + } const gp_Dir& dir = Pos.Direction(); // Project vector on circle's plane const gp_XYZ aVProj = dir.XYZ().CrossCrossed(aVec.XYZ(), dir.XYZ()); if (aVProj.SquareModulus() < gp::Resolution()) + { return 0.0; + } // Angle between X direction and projected vector double Teta = (Pos.XDirection()).AngleWithRef(aVProj, dir); @@ -1231,8 +1235,10 @@ double ElCLib::EllipseParameter(const gp_Ax2& Pos, const double NX = OP.Dot(xaxis); if ((std::abs(NX) <= gp::Resolution()) && (std::abs(NY) <= gp::Resolution())) + { //-- The point P is on the Axis of the Ellipse. return (0.0); + } yaxis.Multiply(NY * (MajorRadius / MinorRadius)); gp_XYZ Om = xaxis.Multiplied(NX); diff --git a/src/FoundationClasses/TKMath/ElSLib/ElSLib.cxx b/src/FoundationClasses/TKMath/ElSLib/ElSLib.cxx index 0e132ca903..d5d22733c9 100644 --- a/src/FoundationClasses/TKMath/ElSLib/ElSLib.cxx +++ b/src/FoundationClasses/TKMath/ElSLib/ElSLib.cxx @@ -146,13 +146,19 @@ gp_Pnt ElSLib::TorusValue(const double U, double eps = 10. * (MinorRadius + MajorRadius) * RealEpsilon(); if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + A3 * ZDir.X() + PLoc.X(), @@ -191,14 +197,18 @@ gp_Vec ElSLib::ConeDN(const double U, { Xdir.Multiply(Radius + V * sin(SAngle)); if (Nu == 0) + { Xdir.Add(Pos.Location().XYZ()); + } return gp_Vec(Xdir); } else if (Nv == 1) { Xdir.Multiply(sin(SAngle)); if (Nu == 0) + { Xdir.Add(Pos.Direction().XYZ() * cos(SAngle)); + } return gp_Vec(Xdir); } return gp_Vec(0.0, 0.0, 0.0); @@ -333,9 +343,13 @@ gp_Vec ElSLib::SphereDN(const double U, A2 = -SinU; } if (IsOdd(Nv)) + { A3 = -RSinV; + } else + { A3 = -RCosV; + } X = (A1 * XDir.X() + A2 * YDir.X()) * A3; Y = (A1 * XDir.Y() + A2 * YDir.Y()) * A3; Z = (A1 * XDir.Z() + A2 * YDir.Z()) * A3; @@ -386,10 +400,14 @@ gp_Vec ElSLib::TorusDN(const double U, } // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -419,13 +437,19 @@ gp_Vec ElSLib::TorusDN(const double U, } // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X() + A3 * ZDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y() + A3 * ZDir.Y(); @@ -446,10 +470,14 @@ gp_Vec ElSLib::TorusDN(const double U, A2 = -RSinV * CosU; // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -462,10 +490,14 @@ gp_Vec ElSLib::TorusDN(const double U, A2 = RCosV * SinU; // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -478,10 +510,14 @@ gp_Vec ElSLib::TorusDN(const double U, A2 = -RCosV * CosU; // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -500,10 +536,14 @@ gp_Vec ElSLib::TorusDN(const double U, A2 = RSinV * SinU; // Modified by skv - Tue Sep 9 15:10:34 2003 OCC620 Begin if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End X = A1 * XDir.X() + A2 * YDir.X(); Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -604,13 +644,19 @@ void ElSLib::TorusD0(const double U, double eps = 10. * (MinorRadius + MajorRadius) * RealEpsilon(); if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End P.SetX(A1 * XDir.X() + A2 * YDir.X() + A3 * ZDir.X() + PLoc.X()); P.SetY(A1 * XDir.Y() + A2 * YDir.Y() + A3 * ZDir.Y() + PLoc.Y()); @@ -788,16 +834,24 @@ void ElSLib::TorusD1(const double U, double eps = 10. * (MinorRadius + MajorRadius) * RealEpsilon(); if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } if (std::abs(A4) <= eps) + { A4 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End P.SetX(A1 * XDir.X() + A2 * YDir.X() + R2 * ZDir.X() + PLoc.X()); P.SetY(A1 * XDir.Y() + A2 * YDir.Y() + R2 * ZDir.Y() + PLoc.Y()); @@ -1035,22 +1089,34 @@ void ElSLib::TorusD2(const double U, double eps = 10. * (MinorRadius + MajorRadius) * RealEpsilon(); if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } if (std::abs(A4) <= eps) + { A4 = 0.; + } if (std::abs(A5) <= eps) + { A5 = 0.; + } if (std::abs(A6) <= eps) + { A6 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End double Som1X = A1 * XDir.X() + A2 * YDir.X(); double Som1Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -1400,22 +1466,34 @@ void ElSLib::TorusD3(const double U, double eps = 10. * (MinorRadius + MajorRadius) * RealEpsilon(); if (std::abs(A1) <= eps) + { A1 = 0.; + } if (std::abs(A2) <= eps) + { A2 = 0.; + } if (std::abs(A3) <= eps) + { A3 = 0.; + } if (std::abs(A4) <= eps) + { A4 = 0.; + } if (std::abs(A5) <= eps) + { A5 = 0.; + } if (std::abs(A6) <= eps) + { A6 = 0.; + } // Modified by skv - Tue Sep 9 15:10:35 2003 OCC620 End double Som1X = A1 * XDir.X() + A2 * YDir.X(); double Som1Y = A1 * XDir.Y() + A2 * YDir.Y(); @@ -1549,9 +1627,13 @@ void ElSLib::SphereParameters(const gp_Ax3& Pos, if (l < gp::Resolution()) { // point on axis Z of the sphere if (z > 0.) + { V = M_PI_2; // PI * 0.5 + } else + { V = -M_PI_2; // PI * 0.5 + } U = 0.; } else @@ -1596,7 +1678,9 @@ void ElSLib::TorusParameters(const gp_Ax3& Pos, const double AD1 = std::abs(D1); const double AD2 = std::abs(D2); if (AD2 < AD1) + { U += M_PI; + } } normalizeAngle(U); const double cosu = cos(U); diff --git a/src/FoundationClasses/TKMath/GTests/BVH_BuildQueue_Test.cxx b/src/FoundationClasses/TKMath/GTests/BVH_BuildQueue_Test.cxx index 3e0b082ab1..5a22c79391 100644 --- a/src/FoundationClasses/TKMath/GTests/BVH_BuildQueue_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/BVH_BuildQueue_Test.cxx @@ -231,7 +231,9 @@ TEST(BVH_BuildQueueTest, ConcurrentFetch) { int aItem = aQueue.Fetch(wasBusy); if (aItem == -1) + { break; + } aFetchedCounts[t]++; } }); diff --git a/src/FoundationClasses/TKMath/GTests/Bnd_BoundSortBox_Test.cxx b/src/FoundationClasses/TKMath/GTests/Bnd_BoundSortBox_Test.cxx index 9e53ed1b25..08df879fcd 100644 --- a/src/FoundationClasses/TKMath/GTests/Bnd_BoundSortBox_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/Bnd_BoundSortBox_Test.cxx @@ -95,9 +95,13 @@ TEST_F(Bnd_BoundSortBoxTest, InitializeWithBoxes) for (NCollection_List::Iterator it(result); it.More(); it.Next()) { if (it.Value() == 1) + { foundSmall = true; + } if (it.Value() == 2) + { foundLarge = true; + } } EXPECT_TRUE(foundSmall) << "Small box (index 1) should be in the result"; EXPECT_TRUE(foundLarge) << "Large box (index 2) should be in the result"; @@ -122,9 +126,13 @@ TEST_F(Bnd_BoundSortBoxTest, InitializeWithEnclosingBox) for (NCollection_List::Iterator it(result); it.More(); it.Next()) { if (it.Value() == 2) + { foundLarge = true; + } if (it.Value() == 3) + { foundOffset = true; + } } EXPECT_TRUE(foundLarge) << "Large box (index 2) should be in the result"; EXPECT_TRUE(foundOffset) << "Offset box (index 3) should be in the result"; diff --git a/src/FoundationClasses/TKMath/GTests/MathOpt_Newton_Test.cxx b/src/FoundationClasses/TKMath/GTests/MathOpt_Newton_Test.cxx index 7b03301b80..465ca6d90c 100644 --- a/src/FoundationClasses/TKMath/GTests/MathOpt_Newton_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/MathOpt_Newton_Test.cxx @@ -199,9 +199,13 @@ public: bool Values(const math_Vector& theX, double& theF, math_Vector& theG, math_Matrix& theH) override { if (!Value(theX, theF)) + { return false; + } if (!Gradient(theX, theG)) + { return false; + } theH(1, 1) = 2.0; theH(1, 2) = 0.0; theH(2, 1) = 0.0; @@ -244,9 +248,13 @@ public: bool Values(const math_Vector& theX, double& theF, math_Vector& theG, math_Matrix& theH) override { if (!Value(theX, theF)) + { return false; + } if (!Gradient(theX, theG)) + { return false; + } theH(1, 1) = 10.0; theH(1, 2) = 8.0; theH(2, 1) = 8.0; diff --git a/src/FoundationClasses/TKMath/GTests/math_BFGS_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_BFGS_Test.cxx index 84dfd4f902..03d95a45c6 100644 --- a/src/FoundationClasses/TKMath/GTests/math_BFGS_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_BFGS_Test.cxx @@ -39,7 +39,9 @@ public: bool Value(const math_Vector& theX, double& theF) override { if (theX.Length() != 2) + { return false; + } double dx = theX(1) - 1.0; double dy = theX(2) - 2.0; theF = dx * dx + dy * dy; @@ -49,7 +51,9 @@ public: bool Gradient(const math_Vector& theX, math_Vector& theG) override { if (theX.Length() != 2 || theG.Length() != 2) + { return false; + } theG(1) = 2.0 * (theX(1) - 1.0); theG(2) = 2.0 * (theX(2) - 2.0); return true; @@ -72,7 +76,9 @@ public: bool Value(const math_Vector& theX, double& theF) override { if (theX.Length() != 2) + { return false; + } double x = theX(1); double y = theX(2); double t1 = y - x * x; @@ -84,7 +90,9 @@ public: bool Gradient(const math_Vector& theX, math_Vector& theG) override { if (theX.Length() != 2 || theG.Length() != 2) + { return false; + } double x = theX(1); double y = theX(2); theG(1) = -400.0 * x * (y - x * x) - 2.0 * (1.0 - x); @@ -109,7 +117,9 @@ public: bool Value(const math_Vector& theX, double& theF) override { if (theX.Length() != 3) + { return false; + } theF = theX(1) * theX(1) + 2.0 * theX(2) * theX(2) + 3.0 * theX(3) * theX(3); return true; } @@ -117,7 +127,9 @@ public: bool Gradient(const math_Vector& theX, math_Vector& theG) override { if (theX.Length() != 3 || theG.Length() != 3) + { return false; + } theG(1) = 2.0 * theX(1); theG(2) = 4.0 * theX(2); theG(3) = 6.0 * theX(3); @@ -488,7 +500,9 @@ public: bool Value(const math_Vector& theX, double& theF) override { if (theX.Length() != 1) + { return false; + } const double x = theX(1); theF = x * x; return true; @@ -497,7 +511,9 @@ public: bool Gradient(const math_Vector& theX, math_Vector& theG) override { if (theX.Length() != 1 || theG.Length() != 1) + { return false; + } const double x = theX(1); theG(1) = 2.0 * x; return true; diff --git a/src/FoundationClasses/TKMath/GTests/math_EigenValuesSearcher_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_EigenValuesSearcher_Test.cxx index 436c2a3772..a266fc753e 100644 --- a/src/FoundationClasses/TKMath/GTests/math_EigenValuesSearcher_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_EigenValuesSearcher_Test.cxx @@ -37,7 +37,9 @@ void createTridiagonalMatrix(const NCollection_Array1& theDiagonal, // Set diagonal elements for (int i = 1; i <= aN; i++) + { theMatrix(i, i) = theDiagonal(i); + } // Set sub and super diagonal elements for (int i = 2; i <= aN; i++) @@ -61,7 +63,9 @@ bool verifyEigenPair(const math_Matrix& theMatrix, { double aSum = 0.0; for (int j = 1; j <= aN; j++) + { aSum += theMatrix(i, j) * theEigenVector(j); + } aResult(i) = aSum; } @@ -70,7 +74,9 @@ bool verifyEigenPair(const math_Matrix& theMatrix, { const double aExpected = theEigenValue * theEigenVector(i); if (std::abs(aResult(i) - aExpected) > theTolerance) + { return false; + } } return true; @@ -83,7 +89,9 @@ bool areOrthogonal(const math_Vector& theVec1, { double aDotProduct = 0.0; for (int i = 1; i <= theVec1.Length(); i++) + { aDotProduct += theVec1(i) * theVec2(i); + } return std::abs(aDotProduct) < theTolerance; } @@ -93,7 +101,9 @@ double vectorNorm(const math_Vector& theVector) { double aNorm = 0.0; for (int i = 1; i <= theVector.Length(); i++) + { aNorm += theVector(i) * theVector(i); + } return std::sqrt(aNorm); } } // namespace @@ -257,7 +267,9 @@ TEST(math_EigenValuesSearcherTest, DiagonalMatrix) // For a diagonal matrix, eigenvalues should be the diagonal elements std::vector eigenvals; for (int i = 1; i <= 4; i++) + { eigenvals.push_back(searcher.EigenValue(i)); + } std::sort(eigenvals.begin(), eigenvals.end()); @@ -338,11 +350,15 @@ TEST(math_EigenValuesSearcherTest, FiveByFiveMatrix) // Create a symmetric tridiagonal matrix with pattern for (int i = 1; i <= 5; i++) + { aDiagonal.SetValue(i, 2.0); + } aSubdiagonal.SetValue(1, 0.0); // Not used for (int i = 2; i <= 5; i++) + { aSubdiagonal.SetValue(i, -1.0); + } math_EigenValuesSearcher searcher(aDiagonal, aSubdiagonal); @@ -393,7 +409,9 @@ TEST(math_EigenValuesSearcherTest, SmallSubdiagonalElements) // Should converge to approximately diagonal values std::vector eigenvals; for (int i = 1; i <= 3; i++) + { eigenvals.push_back(searcher.EigenValue(i)); + } std::sort(eigenvals.begin(), eigenvals.end()); @@ -427,7 +445,9 @@ TEST(math_EigenValuesSearcherTest, ZeroDiagonalElements) // Eigenvalues should be -sqrt(2), 0, sqrt(2) std::vector eigenvals; for (int i = 1; i <= 3; i++) + { eigenvals.push_back(searcher.EigenValue(i)); + } std::sort(eigenvals.begin(), eigenvals.end()); @@ -569,7 +589,9 @@ TEST(math_EigenValuesSearcherTest, AntisymmetricSubdiagonal) // Symmetric tridiagonal with specific pattern for (int i = 1; i <= 5; i++) + { aDiagonal.SetValue(i, static_cast(i)); + } aSubdiagonal.SetValue(1, 0.0); aSubdiagonal.SetValue(2, 1.0); @@ -621,7 +643,9 @@ TEST(math_EigenValuesSearcherTest, WilkinsonMatrix) aSubdiagonal.SetValue(1, 0.0); for (int i = 2; i <= n; i++) + { aSubdiagonal.SetValue(i, 1.0); + } math_EigenValuesSearcher searcher(aDiagonal, aSubdiagonal); @@ -786,7 +810,9 @@ TEST(math_EigenValuesSearcherTest, NearDegenerateEigenvalues) // Should still find distinct eigenvalues despite near-degeneracy std::vector eigenvals; for (int i = 1; i <= 3; i++) + { eigenvals.push_back(searcher.EigenValue(i)); + } std::sort(eigenvals.begin(), eigenvals.end()); @@ -844,7 +870,9 @@ TEST(math_EigenValuesSearcherTest, DeflationConditionPrecision) // Eigenvalues should be close to diagonal elements due to small off-diagonal std::vector eigenvals; for (int i = 1; i <= 4; i++) + { eigenvals.push_back(searcher.EigenValue(i)); + } std::sort(eigenvals.begin(), eigenvals.end()); @@ -897,11 +925,15 @@ TEST(math_EigenValuesSearcherTest, ConvergenceBehavior) // Create a matrix that might require more iterations to converge for (int i = 1; i <= 6; i++) + { aDiagonal.SetValue(i, static_cast(i) * 0.1); + } aSubdiagonal.SetValue(1, 0.0); for (int i = 2; i <= 6; i++) + { aSubdiagonal.SetValue(i, 0.99); // Large off-diagonal elements + } math_EigenValuesSearcher searcher(aDiagonal, aSubdiagonal); @@ -1028,11 +1060,15 @@ TEST(math_EigenValuesSearcherTest, PathologicalEqualElements) // All elements equal - degenerate case const double value = 42.0; for (int i = 1; i <= 5; i++) + { aDiagonal.SetValue(i, value); + } aSubdiagonal.SetValue(1, 0.0); for (int i = 2; i <= 5; i++) + { aSubdiagonal.SetValue(i, value); + } math_EigenValuesSearcher searcher(aDiagonal, aSubdiagonal); @@ -1058,11 +1094,15 @@ TEST(math_EigenValuesSearcherTest, IncreasingSubdiagonal) NCollection_Array1 aSubdiagonal(1, 6); for (int i = 1; i <= 6; i++) + { aDiagonal.SetValue(i, 1.0); + } aSubdiagonal.SetValue(1, 0.0); for (int i = 2; i <= 6; i++) + { aSubdiagonal.SetValue(i, static_cast(i - 1) * 0.1); + } math_EigenValuesSearcher searcher(aDiagonal, aSubdiagonal); diff --git a/src/FoundationClasses/TKMath/GTests/math_FunctionAllRoots_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_FunctionAllRoots_Test.cxx index 8cd57c5933..693be403ab 100644 --- a/src/FoundationClasses/TKMath/GTests/math_FunctionAllRoots_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_FunctionAllRoots_Test.cxx @@ -75,20 +75,30 @@ public: bool Value(const double X, double& F) override { if (X >= 2.0 && X <= 4.0) + { F = 0.0; + } else if (X < 2.0) + { F = X - 2.0; + } else + { F = X - 4.0; + } return true; } bool Derivative(const double X, double& D) override { if (X >= 2.0 && X <= 4.0) + { D = 0.0; + } else + { D = 1.0; + } return true; } diff --git a/src/FoundationClasses/TKMath/GTests/math_GlobOptMin_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_GlobOptMin_Test.cxx index 5a26beab4b..844b36e7e9 100644 --- a/src/FoundationClasses/TKMath/GTests/math_GlobOptMin_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_GlobOptMin_Test.cxx @@ -614,12 +614,17 @@ TEST(MathGlobOptMinTest, OCC25004_BraninFunctionGlobalOptimum) } for (int i = 1; i <= aGridOrder; i++) + { for (int j = 1; j <= aGridOrder; j++) + { for (int k = 1; k <= aGridOrder; k++) + { for (int l = 1; l <= aGridOrder; l++) { if (i == k && j == l) + { continue; + } aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0); @@ -633,9 +638,14 @@ TEST(MathGlobOptMinTest, OCC25004_BraninFunctionGlobalOptimum) { const double aC = std::abs(aFuncValues(idx1) - aFuncValues(idx2)) / aDist; if (aC > aLipConst) + { aLipConst = aC; + } } } + } + } + } math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst); aFinder.Perform(); diff --git a/src/FoundationClasses/TKMath/GTests/math_SVD_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_SVD_Test.cxx index 0eb6401fbc..8328a62959 100644 --- a/src/FoundationClasses/TKMath/GTests/math_SVD_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_SVD_Test.cxx @@ -435,9 +435,13 @@ TEST(MathSVDTest, LargerMatrix) for (int aJ = 1; aJ <= 5; aJ++) { if (anI == aJ) + { aMatrix(anI, aJ) = 10.0; // Diagonal dominance + } else + { aMatrix(anI, aJ) = 1.0 / (abs(anI - aJ) + 1.0); + } } } diff --git a/src/FoundationClasses/TKMath/GTests/math_TrigonometricFunctionRoots_Test.cxx b/src/FoundationClasses/TKMath/GTests/math_TrigonometricFunctionRoots_Test.cxx index a204ff359c..e977ec37df 100644 --- a/src/FoundationClasses/TKMath/GTests/math_TrigonometricFunctionRoots_Test.cxx +++ b/src/FoundationClasses/TKMath/GTests/math_TrigonometricFunctionRoots_Test.cxx @@ -272,9 +272,13 @@ TEST(math_TrigonometricFunctionRoots, HighFrequencyTest) for (double sol : solutions) { if (fabs(sol - PI / 6.0) < 0.1) + { found_first = true; + } if (fabs(sol - 5.0 * PI / 6.0) < 0.1) + { found_second = true; + } } EXPECT_TRUE(found_first || found_second); } diff --git a/src/FoundationClasses/TKMath/PLib/PLib.cxx b/src/FoundationClasses/TKMath/PLib/PLib.cxx index 7bb1e4edbe..8e9eedcf79 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib.cxx +++ b/src/FoundationClasses/TKMath/PLib/PLib.cxx @@ -327,7 +327,9 @@ void PLib::RationalDerivative(const int Degree, int DeRequest1 = DerivativeRequest + 1; int MinDegRequ = DerivativeRequest; if (MinDegRequ > Degree) + { MinDegRequ = Degree; + } binomial_array.Allocate(DeRequest1); for (ii = 0; ii < DeRequest1; ii++) @@ -442,7 +444,9 @@ void PLib::RationalDerivative(const int Degree, int DeRequest1 = DerivativeRequest + 1; int MinDegRequ = DerivativeRequest; if (MinDegRequ > Degree) + { MinDegRequ = Degree; + } binomial_array.Allocate(DeRequest1); for (ii = 0; ii < DeRequest1; ii++) @@ -1412,15 +1416,23 @@ bool PLib::HermiteCoefficients(const double FirstParameter, // Test de validites if ((FirstOrder < 0) || (LastOrder < 0)) + { return false; + } double D1 = fabs(FirstParameter), D2 = fabs(LastParameter); if (D1 > 100 || D2 > 100) + { return false; + } D2 += D1; if (D2 < 0.01) + { return false; + } if (fabs(LastParameter - FirstParameter) / D2 < 0.01) + { return false; + } // Calcul de la matrice a inverser (MAT) @@ -1451,7 +1463,9 @@ bool PLib::HermiteCoefficients(const double FirstParameter, // resolution du systemes math_Gauss ResolCoeff(MAT, 1.0e-10); if (!ResolCoeff.IsDone()) + { return false; + } for (ii = 1; ii <= NbCoeff; ii++) { @@ -1547,7 +1561,9 @@ void PLib::CoefficientsPoles(const int dim, { Cnp = PLib::Bin(reflen - 1, i - 1); if (rat) + { (*Weights)(lowp + i - 1) = (*WCoefs)(lowc + i - 1) / Cnp; + } for (j = 0; j < dim; j++) { @@ -1561,7 +1577,9 @@ void PLib::CoefficientsPoles(const int dim, for (j = reflen - 1; j >= i; j--) { if (rat) + { (*Weights)(lowp + j) += (*Weights)(lowp + j - 1); + } for (k = 0; k < dim; k++) { @@ -1642,7 +1660,9 @@ void PLib::Trimming(const double U1, if (rat) { if (len != WCoefs->Length()) + { throw Standard_Failure("PLib::Trimming : nbcoefs/dim != nbweights !!!"); + } upw = WCoefs->Upper(); } len--; @@ -1652,7 +1672,9 @@ void PLib::Trimming(const double U1, int j; indc = upc - dim * (i - 1); if (rat) + { indw = upw - i + 1; + } // calcul du coefficient de degre le plus faible a l'iteration i for (j = 0; j < dim; j++) @@ -1660,7 +1682,9 @@ void PLib::Trimming(const double U1, Coefs(indc - dim + j) += U1 * Coefs(indc + j); } if (rat) + { (*WCoefs)(indw - 1) += U1 * (*WCoefs)(indw); + } // calcul des coefficients intermediaires : @@ -1686,7 +1710,9 @@ void PLib::Trimming(const double U1, Coefs(upc + j) *= lsp; } if (rat) + { (*WCoefs)(upw) *= lsp; + } } } @@ -1755,7 +1781,9 @@ void PLib::CoefficientsPoles(const NCollection_Array2& Coefs, Temp.SetLinearForm(Poles(NPoleu, I2).XYZ(), Poles(NPoleu, I2 - 1).XYZ()); Poles(NPoleu, I2).SetXYZ(Temp); if (rat) + { (*Weights)(NPoleu, I2) += (*Weights)(NPoleu, I2 - 1); + } } } } @@ -1770,7 +1798,9 @@ void PLib::CoefficientsPoles(const NCollection_Array2& Coefs, Temp.Divide(Cnp); Poles(Row, NPolev).SetXYZ(Temp); if (rat) + { (*Weights)(Row, NPolev) /= Cnp; + } } for (I1 = 1; I1 <= ColLength - 1; I1++) @@ -1781,7 +1811,9 @@ void PLib::CoefficientsPoles(const NCollection_Array2& Coefs, Temp.SetLinearForm(Poles(I2, NPolev).XYZ(), Poles(I2 - 1, NPolev).XYZ()); Poles(I2, NPolev).SetXYZ(Temp); if (rat) + { (*Weights)(I2, NPolev) += (*Weights)(I2 - 1, NPolev); + } } } } @@ -1824,18 +1856,26 @@ void PLib::UTrimming(const double U1, { Temp(irow) = Coeffs(irow, icol); if (rat) + { Temw(irow) = (*WCoeffs)(irow, icol); + } } if (rat) + { PLib::Trimming(U1, U2, Temp, &Temw); + } else + { PLib::Trimming(U1, U2, Temp, PLib::NoWeights()); + } for (irow = lr; irow <= ur; irow++) { Coeffs(irow, icol) = Temp(irow); if (rat) + { (*WCoeffs)(irow, icol) = Temw(irow); + } } } } @@ -1862,18 +1902,26 @@ void PLib::VTrimming(const double V1, { Temp(icol) = Coeffs(irow, icol); if (rat) + { Temw(icol) = (*WCoeffs)(irow, icol); + } } if (rat) + { PLib::Trimming(V1, V2, Temp, &Temw); + } else + { PLib::Trimming(V1, V2, Temp, PLib::NoWeights()); + } for (icol = lc; icol <= uc; icol++) { Coeffs(irow, icol) = Temp(icol); if (rat) + { (*WCoeffs)(irow, icol) = Temw(icol); + } } } } @@ -1923,7 +1971,9 @@ bool PLib::HermiteInterpolate(const int Dimension, { A(irow, icol) = Pattern[irow][icol] * FirstVal; if (irow <= icol) + { FirstVal *= FirstParameter; + } } } @@ -1935,7 +1985,9 @@ bool PLib::HermiteInterpolate(const int Dimension, { A(irow + FirstOrder + 1, icol) = Pattern[irow][icol] * LastVal; if (irow <= icol) + { LastVal *= LastParameter; + } } } // @@ -1963,10 +2015,14 @@ bool PLib::HermiteInterpolate(const int Dimension, math_Vector B(0, FirstOrder + LastOrder + 1); int icol; for (icol = 0; icol <= FirstOrder; icol++) + { B(icol) = FirstConstr(idim, icol); + } for (icol = 0; icol <= LastOrder; icol++) + { B(FirstOrder + 1 + icol) = LastConstr(idim, icol); + } // std::cout << "B=" << B << std::endl; // The solving of equations system A * X = B. Then B = X @@ -1974,12 +2030,16 @@ bool PLib::HermiteInterpolate(const int Dimension, // std::cout << "After Solving" << std::endl << "B=" << B << std::endl; if (!Equations.IsDone()) + { return false; + } // the filling of the Coefficients for (icol = 0; icol <= FirstOrder + LastOrder + 1; icol++) + { Coefficients(Dimension * icol + idim - 1) = B(icol); + } } return true; } @@ -2033,35 +2093,61 @@ void PLib::JacobiParameters(const GeomAbs_Shape ConstraintOrder, throw Standard_ConstructionError("Invalid ConstraintOrder"); } if (MaxDegree < 2 * NivConstr + 1) + { throw Standard_ConstructionError("Invalid MaxDegree"); + } if (Code >= 1) + { WorkDegree = MaxDegree + 9; + } else + { WorkDegree = MaxDegree + 6; + } //---> Nbre mini de points necessaires. int IPMIN = 0; if (WorkDegree < NDEG8) + { IPMIN = NDEG8; + } else if (WorkDegree < NDEG10) + { IPMIN = NDEG10; + } else if (WorkDegree < NDEG15) + { IPMIN = NDEG15; + } else if (WorkDegree < NDEG20) + { IPMIN = NDEG20; + } else if (WorkDegree < NDEG25) + { IPMIN = NDEG25; + } else if (WorkDegree < NDEG30) + { IPMIN = NDEG30; + } else if (WorkDegree < NDEG40) + { IPMIN = NDEG40; + } else if (WorkDegree < NDEG50) + { IPMIN = NDEG50; + } else if (WorkDegree < NDEG61) + { IPMIN = NDEG61; + } else + { throw Standard_ConstructionError("Invalid MaxDegree"); + } // ---> Nbre de points voulus. int IWANT = 0; switch (Code) diff --git a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx index e082e5dc8c..2afbf0fc32 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_HermitJacobi.cxx @@ -173,13 +173,17 @@ void PLib_HermitJacobi::ToCoefficients(const int Dimensi } if (Degree > aDegreeH) + { myJacobi.ToCoefficients(Dimension, Degree, AuxCoeff, Coefficients); + } else { int ibegC = Coefficients.Lower(); kdim = (Degree + 1) * Dimension; for (k = 0; k < kdim; k++) + { Coefficients(ibegC + k) = AuxCoeff(k); + } } } @@ -218,6 +222,7 @@ void PLib_HermitJacobi::D0123(const int NDeriv, // Evaluation des polynomes d'hermite math_Matrix HermitValues(0, aDegreeH, 0, NDeriv, 0.); if (NDeriv == 0) + { for (i = 0; i <= aDegreeH; i++) { PLib::NoDerivativeEvalPolynomial(U, @@ -227,11 +232,14 @@ void PLib_HermitJacobi::D0123(const int NDeriv, aHermiteMatrix(i + 1, 1), HermitValues(i, 0)); } + } else + { for (i = 0; i <= aDegreeH; i++) { PLib::EvalPolynomial(U, NDeriv, aDegreeH, 1, aHermiteMatrix(i + 1, 1), HermitValues(i, 0)); } + } // Evaluation des polynomes de Jaccobi if (aJacDegree >= 0) @@ -264,9 +272,13 @@ void PLib_HermitJacobi::D0123(const int NDeriv, // Evaluation de W(t) const double& aWCoeff = GetWCoefficients(aNivConstr); if (NDeriv == 0) + { PLib::NoDerivativeEvalPolynomial(U, aDegreeH + 1, 1, aDegreeH + 1, aWCoeff, WValues(0)); + } else + { PLib::EvalPolynomial(U, NDeriv, aDegreeH + 1, 1, aWCoeff, WValues(0)); + } } // Evaluation a l'ordre 0 diff --git a/src/FoundationClasses/TKMath/PointSetLib/PointSetLib_Equation.cxx b/src/FoundationClasses/TKMath/PointSetLib/PointSetLib_Equation.cxx index d6a1a447fc..3a245dcaf9 100644 --- a/src/FoundationClasses/TKMath/PointSetLib/PointSetLib_Equation.cxx +++ b/src/FoundationClasses/TKMath/PointSetLib/PointSetLib_Equation.cxx @@ -77,21 +77,33 @@ PointSetLib_Equation::PointSetLib_Equation(const NCollection_Array1& the const double aD1 = aDX * myAxes[0].X() + aDY * myAxes[0].Y() + aDZ * myAxes[0].Z(); if (aD1 > aMax1) + { aMax1 = aD1; + } if (aD1 < aMin1) + { aMin1 = aD1; + } const double aD2 = aDX * myAxes[1].X() + aDY * myAxes[1].Y() + aDZ * myAxes[1].Z(); if (aD2 > aMax2) + { aMax2 = aD2; + } if (aD2 < aMin2) + { aMin2 = aD2; + } const double aD3 = aDX * myAxes[2].X() + aDY * myAxes[2].Y() + aDZ * myAxes[2].Z(); if (aD3 > aMax3) + { aMax3 = aD3; + } if (aD3 < aMin3) + { aMin3 = aD3; + } } myExtents[0] = aMax1 - aMin1; @@ -126,21 +138,33 @@ PointSetLib_Equation::PointSetLib_Equation(const NCollection_Array1& the case 1: { myType = Type::Line; if (aDimCode == 4) + { myV1 = myAxes[2]; + } else if (aDimCode == 6) + { myV1 = myAxes[1]; + } else + { myV1 = myAxes[0]; + } break; } case 2: { myType = Type::Plane; if (aDimCode == 1) + { myV1 = myAxes[0]; + } else if (aDimCode == 2) + { myV1 = myAxes[1]; + } else + { myV1 = myAxes[2]; + } break; } case 3: { diff --git a/src/FoundationClasses/TKMath/Poly/Poly.cxx b/src/FoundationClasses/TKMath/Poly/Poly.cxx index 5f16bd5950..67f7b720a6 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly.cxx @@ -108,66 +108,96 @@ void Poly::Write(const occ::handle& T, Standard_OStream& OS, // write the deflection if (!Compact) + { OS << "Deflection : "; + } OS << T->Deflection() << "\n"; // write the 3d nodes if (!Compact) + { OS << "\n3D Nodes :\n"; + } int i, nbNodes = T->NbNodes(); for (i = 1; i <= nbNodes; i++) { const gp_Pnt aNode = T->Node(i); if (!Compact) + { OS << std::setw(10) << i << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << aNode.X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode.Y() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode.Z() << "\n"; } if (T->HasUVNodes()) { if (!Compact) + { OS << "\nUV Nodes :\n"; + } for (i = 1; i <= nbNodes; i++) { const gp_Pnt2d aNode2d = T->UVNode(i); if (!Compact) + { OS << std::setw(10) << i << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << aNode2d.X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode2d.Y() << "\n"; } } if (!Compact) + { OS << "\nTriangles :\n"; + } int nbTriangles = T->NbTriangles(); int n1, n2, n3; for (i = 1; i <= nbTriangles; i++) { if (!Compact) + { OS << std::setw(10) << i << " : "; + } T->Triangle(i).Get(n1, n2, n3); if (!Compact) + { OS << std::setw(10); + } OS << n1 << " "; if (!Compact) + { OS << std::setw(10); + } OS << n2 << " "; if (!Compact) + { OS << std::setw(10); + } OS << n3 << "\n"; } } @@ -191,35 +221,49 @@ void Poly::Write(const occ::handle& P, Standard_OStream& OS, con // write the deflection if (!Compact) + { OS << "Deflection : "; + } OS << P->Deflection() << "\n"; // write the nodes if (!Compact) + { OS << "\nNodes :\n"; + } int i, nbNodes = P->NbNodes(); const NCollection_Array1& Nodes = P->Nodes(); for (i = 1; i <= nbNodes; i++) { if (!Compact) + { OS << std::setw(10) << i << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << Nodes(i).X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << Nodes(i).Y() << " "; if (!Compact) + { OS << std::setw(17); + } OS << Nodes(i).Z() << "\n"; } if (P->HasParameters()) { if (!Compact) + { OS << "\nParameters :\n"; + } const NCollection_Array1& Param = P->Parameters(); for (i = 1; i <= nbNodes; i++) { @@ -246,25 +290,35 @@ void Poly::Write(const occ::handle& P, Standard_OStream& OS, con // write the deflection if (!Compact) + { OS << "Deflection : "; + } OS << P->Deflection() << "\n"; // write the nodes if (!Compact) + { OS << "\nNodes :\n"; + } int i, nbNodes = P->NbNodes(); const NCollection_Array1& Nodes = P->Nodes(); for (i = 1; i <= nbNodes; i++) { if (!Compact) + { OS << std::setw(10) << i << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << Nodes(i).X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << Nodes(i).Y() << "\n"; } } @@ -348,9 +402,13 @@ occ::handle Poly::ReadTriangulation(Standard_IStream& IS) occ::handle T; if (hasUV) + { T = new Poly_Triangulation(Nodes, UVNodes, Triangles); + } else + { T = new Poly_Triangulation(Nodes, Triangles); + } T->Deflection(d); @@ -404,9 +462,13 @@ occ::handle Poly::ReadPolygon3D(Standard_IStream& IS) occ::handle P; if (!hasparameters) + { P = new Poly_Polygon3D(Nodes); + } else + { P = new Poly_Polygon3D(Nodes, Param); + } P->Deflection(d); diff --git a/src/FoundationClasses/TKMath/Poly/Poly_CoherentNode.cxx b/src/FoundationClasses/TKMath/Poly/Poly_CoherentNode.cxx index 7456f06247..950453d7e8 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_CoherentNode.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_CoherentNode.cxx @@ -47,9 +47,13 @@ void Poly_CoherentNode::AddTriangle(const Poly_CoherentTriangle& const occ::handle& theAlloc) { if (myTriangles == nullptr) + { myTriangles = new (theAlloc) Poly_CoherentTriPtr(theTri); + } else + { myTriangles->Prepend(&theTri, theAlloc); + } } //================================================================================================= @@ -62,9 +66,13 @@ bool Poly_CoherentNode::RemoveTriangle(const Poly_CoherentTriangle& { Poly_CoherentTriPtr* aLostPtr = myTriangles; if (myTriangles == &myTriangles->Next()) + { myTriangles = nullptr; + } else + { myTriangles = &myTriangles->Next(); + } Poly_CoherentTriPtr::Remove(aLostPtr, theAlloc); aResult = true; } @@ -72,12 +80,14 @@ bool Poly_CoherentNode::RemoveTriangle(const Poly_CoherentTriangle& { Poly_CoherentTriPtr::Iterator anIter(*myTriangles); for (anIter.Next(); anIter.More(); anIter.Next()) + { if (&anIter.Value() == &theTri) { Poly_CoherentTriPtr::Remove(const_cast(&anIter.PtrValue()), theAlloc); aResult = true; break; } + } } return aResult; } @@ -88,12 +98,12 @@ void Poly_CoherentNode::Dump(Standard_OStream& theStream) const { char buf[256]; Sprintf(buf, " X =%9.4f; Y =%9.4f; Z =%9.4f", X(), Y(), Z()); - theStream << buf << std::endl; + theStream << buf << '\n'; Poly_CoherentTriPtr::Iterator anIter(*myTriangles); for (; anIter.More(); anIter.Next()) { const Poly_CoherentTriangle& aTri = anIter.Value(); Sprintf(buf, " %5d %5d %5d", aTri.Node(0), aTri.Node(1), aTri.Node(2)); - theStream << buf << std::endl; + theStream << buf << '\n'; } } diff --git a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriPtr.cxx b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriPtr.cxx index b897e926ef..ae4fd6d0e2 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriPtr.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriPtr.cxx @@ -23,7 +23,9 @@ void Poly_CoherentTriPtr::Iterator::Next() { myCurrent = myCurrent->myNext; if (myCurrent == myFirst) + { myCurrent = nullptr; + } } } @@ -34,7 +36,9 @@ void Poly_CoherentTriPtr::Append(const Poly_CoherentTriangle* p { occ::handle anAlloc = theAlloc; if (theAlloc.IsNull()) + { anAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); + } Poly_CoherentTriPtr* aNewPtr = new (anAlloc) Poly_CoherentTriPtr(*pTri); aNewPtr->myNext = myNext; myNext->myPrevious = aNewPtr; @@ -49,7 +53,9 @@ void Poly_CoherentTriPtr::Prepend(const Poly_CoherentTriangle* { occ::handle anAlloc = theAlloc; if (theAlloc.IsNull()) + { anAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); + } Poly_CoherentTriPtr* aNewPtr = new (anAlloc) Poly_CoherentTriPtr(*pTri); aNewPtr->myPrevious = myPrevious; myPrevious->myNext = aNewPtr; @@ -64,7 +70,9 @@ void Poly_CoherentTriPtr::Remove(Poly_CoherentTriPtr* t { occ::handle anAlloc = theAlloc; if (theAlloc.IsNull()) + { anAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); + } if (thePtr->myNext && thePtr->myPrevious) { thePtr->myPrevious->myNext = thePtr->myNext; @@ -82,12 +90,16 @@ void Poly_CoherentTriPtr::RemoveList(Poly_CoherentTriPtr* { occ::handle anAlloc = theAlloc; if (theAlloc.IsNull()) + { anAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); + } Poly_CoherentTriPtr* aPtr = thePtr; do { if (aPtr == nullptr) + { break; + } Poly_CoherentTriPtr* aLostPtr = aPtr; aPtr = aPtr->myNext; anAlloc->Free(aLostPtr); diff --git a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangle.cxx b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangle.cxx index fd9cb741b8..b6ae2ce770 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangle.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangle.cxx @@ -251,12 +251,18 @@ void Poly_CoherentTriangle::RemoveConnection(const int iConn) if (pConnectedTri->mypConnected[0] != this) { if (pConnectedTri->mypConnected[1] == this) + { iConn1 = 1; + } else if (pConnectedTri->mypConnected[2] == this) + { iConn1 = 2; + } else + { throw Standard_ProgramError("Poly_CoherentTriangle::RemoveConnection: " "wrong connection between triangles"); + } } pConnectedTri->mypConnected[iConn1] = nullptr; pConnectedTri->myNodesOnConnected[iConn1] = -1; @@ -273,7 +279,9 @@ bool Poly_CoherentTriangle::RemoveConnection(Poly_CoherentTriangle& theTri) { const int iConn = FindConnection(theTri); if (iConn >= 0) + { RemoveConnection(iConn); + } return (iConn >= 0); } @@ -283,12 +291,20 @@ int Poly_CoherentTriangle::FindConnection(const Poly_CoherentTriangle& theTri) c { int aResult; if (mypConnected[0] == &theTri) + { aResult = 0; + } else if (mypConnected[1] == &theTri) + { aResult = 1; + } else if (mypConnected[2] == &theTri) + { aResult = 2; + } else + { aResult = -1; + } return aResult; } diff --git a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.cxx b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.cxx index a89c9a7080..20d95b0eb5 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.cxx @@ -59,7 +59,9 @@ Poly_CoherentTriangulation::Poly_CoherentTriangulation( int iNode[3]; theTriangulation->Triangle(i).Get(iNode[0], iNode[1], iNode[2]); if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0]) + { AddTriangle(iNode[0] - 1, iNode[1] - 1, iNode[2] - 1); + } } // Copy UV coordinates of nodes @@ -168,7 +170,9 @@ bool Poly_CoherentTriangulation::GetFreeNodes(NCollection_List& lstNodes) c { const Poly_CoherentNode& aNode = myNodes(i); if (aNode.IsFreeNode()) + { lstNodes.Append(i); + } } return !lstNodes.IsEmpty(); } @@ -187,7 +191,9 @@ bool Poly_CoherentTriangulation::RemoveDegenerated( const int ind0[] = {2, 0, 1, 2, 0}; const int* ind = &ind0[1]; if (pLstRemovedNode) + { pLstRemovedNode->Clear(); + } // NCollection_DynamicArray::Iterator anIterT(myTriangles); Poly_CoherentTriangulation::IteratorOfTriangle anIterT(this); @@ -224,11 +230,17 @@ bool Poly_CoherentTriangulation::RemoveDegenerated( if (&aTriConn != &aTri) { if (aNewTriConn[0] == ip1) + { aNewTriConn[0] = im1; + } else if (aNewTriConn[1] == ip1) + { aNewTriConn[1] = im1; + } else if (aNewTriConn[2] == ip1) + { aNewTriConn[2] = im1; + } RemoveTriangle(aTriConn); AddTriangle(aNewTriConn[0], aNewTriConn[1], aNewTriConn[2]); @@ -266,7 +278,9 @@ Poly_CoherentTriangulation::IteratorOfTriangle::IteratorOfTriangle( { const Poly_CoherentTriangle& aTri = Value(); if (!aTri.IsEmpty()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -281,7 +295,9 @@ void Poly_CoherentTriangulation::IteratorOfTriangle::Next() noexcept { const Poly_CoherentTriangle& aTri = Value(); if (!aTri.IsEmpty()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -297,7 +313,9 @@ Poly_CoherentTriangulation::IteratorOfNode::IteratorOfNode( while (More()) { if (!Value().IsFreeNode()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -311,7 +329,9 @@ void Poly_CoherentTriangulation::IteratorOfNode::Next() noexcept while (More()) { if (!Value().IsFreeNode()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -327,7 +347,9 @@ Poly_CoherentTriangulation::IteratorOfLink::IteratorOfLink( while (More()) { if (!Value().IsEmpty()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -341,7 +363,9 @@ void Poly_CoherentTriangulation::IteratorOfLink::Next() noexcept while (More()) { if (!Value().IsEmpty()) + { break; + } NCollection_DynamicArray::Iterator::Next(); } } @@ -353,8 +377,12 @@ int Poly_CoherentTriangulation::NNodes() const int aCount(0); NCollection_DynamicArray::Iterator anIter(myNodes); for (; anIter.More(); anIter.Next()) + { if (!anIter.Value().IsFreeNode()) + { aCount++; + } + } return aCount; } @@ -368,7 +396,9 @@ int Poly_CoherentTriangulation::NTriangles() const { const Poly_CoherentTriangle& aTri = anIter.Value(); if (!aTri.IsEmpty()) + { aCount++; + } } return aCount; } @@ -382,7 +412,9 @@ int Poly_CoherentTriangulation::NLinks() const for (; anIter.More(); anIter.Next()) { if (!anIter.Value().IsEmpty()) + { aCount++; + } } return aCount; } @@ -393,7 +425,9 @@ int Poly_CoherentTriangulation::SetNode(const gp_XYZ& thePnt, const int iNode) { int aResult = myNodes.Length(); if (iNode < 0) + { myNodes.Append(Poly_CoherentNode(thePnt)); + } else { myNodes.SetValue(iNode, Poly_CoherentNode(thePnt)); @@ -441,7 +475,9 @@ bool Poly_CoherentTriangulation::RemoveTriangle(Poly_CoherentTriangle& theTriang } } if (toRemoveLink) + { RemoveLink(*aLink); + } } if (aNode.RemoveTriangle(theTriangle, myAlloc)) { @@ -477,7 +513,9 @@ bool Poly_CoherentTriangulation::ReplaceNodes(Poly_CoherentTriangle& theTriangle const int iNode2) { if (!theTriangle.IsEmpty()) + { RemoveTriangle(theTriangle); + } if (iNode0 >= 0 && iNode1 >= 0 && iNode2 >= 0) { theTriangle = Poly_CoherentTriangle(iNode0, iNode1, iNode2); @@ -549,14 +587,22 @@ void Poly_CoherentTriangulation::RemoveLink(Poly_CoherentLink& theLink) if (iNode >= 0 && pTri[i] != nullptr) { if (iNode == pTri[i]->Node(0)) + { const_cast(pTri[i])->mypLink[0] = nullptr; + } else if (iNode == pTri[i]->Node(1)) + { const_cast(pTri[i])->mypLink[1] = nullptr; + } else if (iNode == pTri[i]->Node(2)) + { const_cast(pTri[i])->mypLink[2] = nullptr; + } else + { throw Standard_ProgramError("Poly_CoherentTriangulation::RemoveLink: " " wrong connectivity between triangles"); + } } } } @@ -576,21 +622,33 @@ Poly_CoherentLink* Poly_CoherentTriangulation::AddLink(const Poly_CoherentTriang const Poly_CoherentTriangle* pTriOpp = theTri.GetConnectedTri(theConn); if (!pTriOpp) + { return pLink; + } if (pTriOpp->IsEmpty()) + { return pLink; + } if (pTriOpp) { if (pTriOpp->Node(0) == theTri.GetConnectedNode(theConn)) + { const_cast(pTriOpp)->mypLink[0] = pLink; + } else if (pTriOpp->Node(1) == theTri.GetConnectedNode(theConn)) + { const_cast(pTriOpp)->mypLink[1] = pLink; + } else if (pTriOpp->Node(2) == theTri.GetConnectedNode(theConn)) + { const_cast(pTriOpp)->mypLink[2] = pLink; + } else + { throw Standard_ProgramError("Poly_CoherentTriangulation::AddLink: " "Bad connectivity of triangles"); + } } } return pLink; @@ -613,29 +671,45 @@ bool Poly_CoherentTriangulation::FindTriangle(const Poly_CoherentLink& theLi if (aTri.Node(0) == iNode0) { if (aTri.Node(1) == theLink.Node(1)) + { pTri[0] = &aTri; + } else if (aTri.Node(2) == theLink.Node(1)) + { pTri[1] = &aTri; + } } else if (aTri.Node(1) == iNode0) { if (aTri.Node(2) == theLink.Node(1)) + { pTri[0] = &aTri; + } else if (aTri.Node(0) == theLink.Node(1)) + { pTri[1] = &aTri; + } } else if (aTri.Node(2) == iNode0) { if (aTri.Node(0) == theLink.Node(1)) + { pTri[0] = &aTri; + } else if (aTri.Node(1) == theLink.Node(1)) + { pTri[1] = &aTri; + } } else + { throw Standard_ProgramError("Poly_CoherentTriangulation::FindTriangle : " " Data incoherence detected"); + } if (pTri[0] && pTri[1]) + { break; + } } } return (pTri[0] != nullptr || pTri[1] != nullptr); @@ -652,14 +726,22 @@ int Poly_CoherentTriangulation::ComputeLinks() const Poly_CoherentTriangle& aTriangle = anIter.Value(); if (aTriangle.IsEmpty()) + { continue; + } if (aTriangle.Node(0) < aTriangle.Node(1)) + { AddLink(aTriangle, 2); + } if (aTriangle.Node(1) < aTriangle.Node(2)) + { AddLink(aTriangle, 0); + } if (aTriangle.Node(2) < aTriangle.Node(0)) + { AddLink(aTriangle, 1); + } } // Above algorithm does not create all boundary links, so // it is necessary to check triangles and add absentee links @@ -670,7 +752,9 @@ int Poly_CoherentTriangulation::ComputeLinks() Poly_CoherentTriangle& aTriangle = anIter.ChangeValue(); if (aTriangle.IsEmpty()) + { continue; + } for (i = 0; i < 3; ++i) { @@ -723,7 +807,9 @@ void Poly_CoherentTriangulation::Dump(Standard_OStream& theStream) const { const Poly_CoherentNode& aNode = myNodes(iNode); if (aNode.IsFreeNode()) + { continue; + } theStream << "Node " << iNode; aNode.Dump(theStream); } diff --git a/src/FoundationClasses/TKMath/Poly/Poly_Connect.cxx b/src/FoundationClasses/TKMath/Poly/Poly_Connect.cxx index 896d1fe7db..18f2a0eb50 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_Connect.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_Connect.cxx @@ -219,8 +219,12 @@ void Poly_Connect::Initialize(const int N) int i, no[3]; myTriangulation->Triangle(myfirst).Get(no[0], no[1], no[2]); for (i = 0; i < 3; i++) + { if (no[i] == mynode) + { break; + } + } myothernode = no[(i + 2) % 3]; } } @@ -256,8 +260,12 @@ void Poly_Connect::Next() // sinon, depart vers la gauche. myTriangulation->Triangle(myfirst).Get(n[0], n[1], n[2]); for (i = 0; i < 3; i++) + { if (n[i] == mynode) + { break; + } + } myothernode = n[(i + 1) % 3]; mysense = false; mytr = myfirst; diff --git a/src/FoundationClasses/TKMath/Poly/Poly_MakeLoops.cxx b/src/FoundationClasses/TKMath/Poly/Poly_MakeLoops.cxx index a2bddb2c60..c222a9dfe6 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_MakeLoops.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_MakeLoops.cxx @@ -52,7 +52,9 @@ void Poly_MakeLoops::Reset(const Helper* theHelp void Poly_MakeLoops::AddLink(const Link& theLink) { if (theLink.node1 == theLink.node2) + { return; + } int aInd = myMapLink.Add(theLink); Link& aLink = const_cast(myMapLink(aInd)); aLink.flags |= theLink.flags; @@ -66,7 +68,9 @@ void Poly_MakeLoops::AddLink(const Link& theLink) void Poly_MakeLoops::ReplaceLink(const Link& theLink, const Link& theNewLink) { if (theNewLink.node1 == theNewLink.node2) + { return; + } int aInd = myMapLink.Add(theLink); if (aInd > 0) { @@ -108,7 +112,9 @@ Poly_MakeLoops::Link Poly_MakeLoops::FindLink(const Link& theLink) const int aInd = myMapLink.FindIndex(theLink); Poly_MakeLoops::Link aLink; if (aInd > 0) + { aLink = myMapLink(aInd); + } return aLink; } @@ -123,9 +129,13 @@ int Poly_MakeLoops::Perform() { const Link& aLink = myMapLink(i); if (aLink.flags & LF_Fwd) + { myStartIndices.Add(i); + } if (aLink.flags & LF_Rev) + { myStartIndices.Add(-i); + } } #ifdef OCCT_DEBUG @@ -180,8 +190,10 @@ int Poly_MakeLoops::Perform() // it is required to mark hanging edges int aNode; if (aStartNumber <= aContour.Extent()) + { // mark hanging edges starting from the first one till a bifurcation aNode = getFirstNode(aIndexS); + } else { // open contour - mark from the end back till a bifurcation @@ -197,7 +209,9 @@ int Poly_MakeLoops::Perform() // move hanging links to start indices to make the second pass TColStd_PackedMapOfInteger::Iterator it(myHangIndices); for (; it.More(); it.Next()) + { myStartIndices.Add(it.Key()); + } } } #ifdef OCCT_DEBUG @@ -207,9 +221,13 @@ int Poly_MakeLoops::Perform() #endif if (!myLoops.IsEmpty()) + { aResult |= RC_LoopsDone; + } if (!myHangIndices.IsEmpty()) + { aResult |= RC_HangingLinks; + } return aResult; } @@ -249,15 +267,21 @@ int Poly_MakeLoops::findContour(int th { int aInd = myMapLink.FindIndex(itLinks.Value()); if (aInd == 0 || aInd == aIndex) + { continue; + } // determine the orientation in which the link is to be taken int aIndS = aInd; int aNode1 = getFirstNode(aInd); if (aNode1 != aLastNode) + { aIndS = -aIndS; + } if (canLinkBeTaken(aIndS)) + { aLstIndS.Append(aIndS); + } } if (aLstIndS.IsEmpty()) @@ -269,11 +293,15 @@ int Poly_MakeLoops::findContour(int th int aIndexSNext = 0; if (aLstIndS.First() == aLstIndS.Last()) + { // only one possible way aIndexSNext = aLstIndS.First(); + } else + { // find the most left way aIndexSNext = chooseLeftWay(aLastNode, aIndexS, aLstIndS); + } aIndexS = aIndexSNext; @@ -335,7 +363,9 @@ void Poly_MakeLoops::acceptContour(const NCollection_IndexedMap& theContour const Link& aLink = myMapLink(aIndex); Link aOrientedLink = aLink; if (aIndexS < 0) + { aOrientedLink.Reverse(); + } aLoop.Append(aOrientedLink); // remove from start set myStartIndices.Remove(aIndexS); @@ -353,7 +383,9 @@ int Poly_MakeLoops::getFirstNode(int theIndexS) const int aIndex = std::abs(theIndexS); const Link& aLink = myMapLink(aIndex); if (theIndexS > 0) + { return aLink.node1; + } return aLink.node2; } @@ -368,7 +400,9 @@ int Poly_MakeLoops::getLastNode(int theIndexS) const int aIndex = std::abs(theIndexS); const Link& aLink = myMapLink(aIndex); if (theIndexS > 0) + { return aLink.node2; + } return aLink.node1; } @@ -398,15 +432,23 @@ void Poly_MakeLoops::markHangChain(int theNode, int theIndexS) const Link& aL = itLinks.Value(); int aInd = myMapLink.FindIndex(aL); if (aInd == 0 || aInd == aIndex) + { continue; + } if ((isOut && aNode1 == aL.node1) || (!isOut && aNode1 == aL.node2)) + { aInd = -aInd; + } if (canLinkBeTaken(aInd)) + { nEdges++; + } } if (nEdges > 0) + { // leave this chain break; + } // mark the current link as hanging myStartIndices.Remove(aIndexS); @@ -414,9 +456,13 @@ void Poly_MakeLoops::markHangChain(int theNode, int theIndexS) // get other node of the link and the next link if (isOut) + { aNode1 = getLastNode(aIndexS); + } else + { aNode1 = getFirstNode(aIndexS); + } const ListOfLink& aNextLinks = myHelper->GetAdjacentLinks(aNode1); int aNextIndexS = 0; for (itLinks.Init(aNextLinks); itLinks.More(); itLinks.Next()) @@ -424,13 +470,19 @@ void Poly_MakeLoops::markHangChain(int theNode, int theIndexS) const Link& aL = itLinks.Value(); int aInd = myMapLink.FindIndex(aL); if (aInd == 0 || aInd == aIndex) + { continue; + } if ((isOut && aNode1 == aL.node2) || (!isOut && aNode1 == aL.node1)) + { aInd = -aInd; + } if (canLinkBeTaken(aInd)) { if (aNextIndexS == 0) + { aNextIndexS = aInd; + } else { // more than 1 ways, stop the chain @@ -440,7 +492,9 @@ void Poly_MakeLoops::markHangChain(int theNode, int theIndexS) } } if (aNextIndexS == 0) + { break; + } aIndexS = aNextIndexS; aIndex = std::abs(aIndexS); } @@ -540,7 +594,9 @@ void Poly_MakeLoops::GetHangingLinks(ListOfLink& theLinks) const int aIndexS = it.Key(); Link aLink = myMapLink(std::abs(aIndexS)); if (aIndexS < 0) + { aLink.Reverse(); + } theLinks.Append(aLink); } } @@ -563,19 +619,25 @@ int Poly_MakeLoops3D::chooseLeftWay(const int theNode, gp_Dir aNormal; const Helper* aHelper = getHelper(); if (!aHelper->GetNormal(theNode, aNormal)) + { return theLstIndS.First(); + } Link aLink = getLink(theSegIndex); gp_Dir aTgtRef; if (!aHelper->GetLastTangent(aLink, aTgtRef)) + { return theLstIndS.First(); + } // project tangent vector to the plane orthogonal to normal // to get the reference direction gp_XYZ aTgtRefXYZ = aNormal.XYZ().CrossCrossed(aTgtRef.XYZ(), aNormal.XYZ()); if (aTgtRefXYZ.SquareModulus() < 1e-14) + { // a problem with defining reference direction, take first way return theLstIndS.First(); + } aTgtRef = aTgtRefXYZ; // find the way with minimal angle to the reference direction @@ -589,17 +651,23 @@ int Poly_MakeLoops3D::chooseLeftWay(const int theNode, aLink = getLink(aIndS); gp_Dir aTgt; if (!aHelper->GetFirstTangent(aLink, aTgt)) + { continue; + } gp_XYZ aTgtXYZ = aNormal.XYZ().CrossCrossed(aTgt.XYZ(), aNormal.XYZ()); if (aTgtXYZ.SquareModulus() < 1e-14) + { // skip a problem way continue; + } aTgt = aTgtXYZ; double aAngle = aTgt.AngleWithRef(aTgtRef, aNormal); if (aAngle < 1e-4 - M_PI) + { aAngle = M_PI; + } if (aAngle < aAngleMin) { aAngleMin = aAngle; @@ -630,8 +698,10 @@ int Poly_MakeLoops2D::chooseLeftWay(const int /*theNode*/, Link aLink = getLink(theSegIndex); gp_Dir2d aTgtRef; if (!aHelper->GetLastTangent(aLink, aTgtRef)) + { // a problem with defining reference direction, take first way return theLstIndS.First(); + } // find the way with minimal angle to the reference direction // (the angle is in range ]-PI;PI]) @@ -644,14 +714,20 @@ int Poly_MakeLoops2D::chooseLeftWay(const int /*theNode*/, aLink = getLink(aIndS); gp_Dir2d aTgt; if (!aHelper->GetFirstTangent(aLink, aTgt)) + { // skip a problem way continue; + } double aAngle = aTgt.Angle(aTgtRef); if (myRightWay) + { aAngle = -aAngle; + } if (aAngle < 1e-4 - M_PI) + { aAngle = M_PI; + } if (aAngle < aAngleMin) { aAngleMin = aAngle; diff --git a/src/FoundationClasses/TKMath/Poly/Poly_Polygon2D.cxx b/src/FoundationClasses/TKMath/Poly/Poly_Polygon2D.cxx index 143aa107da..bfc3ec5a84 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_Polygon2D.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_Polygon2D.cxx @@ -34,7 +34,9 @@ Poly_Polygon2D::Poly_Polygon2D(const NCollection_Array1& Nodes) { int i, j = 1; for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) + { myNodes(j++) = Nodes(i); + } } //================================================================================================= diff --git a/src/FoundationClasses/TKMath/Poly/Poly_Polygon3D.cxx b/src/FoundationClasses/TKMath/Poly/Poly_Polygon3D.cxx index 578dfb71b1..5c5bb31e3d 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_Polygon3D.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_Polygon3D.cxx @@ -38,7 +38,9 @@ Poly_Polygon3D::Poly_Polygon3D(const NCollection_Array1& Nodes) { int i, j = 1; for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) + { myNodes(j++) = Nodes(i); + } } //================================================================================================= @@ -65,9 +67,13 @@ occ::handle Poly_Polygon3D::Copy() const { occ::handle aCopy; if (myParameters.IsNull()) + { aCopy = new Poly_Polygon3D(myNodes); + } else + { aCopy = new Poly_Polygon3D(myNodes, myParameters->Array1()); + } aCopy->Deflection(myDeflection); return aCopy; } diff --git a/src/FoundationClasses/TKMath/Poly/Poly_PolygonOnTriangulation.cxx b/src/FoundationClasses/TKMath/Poly/Poly_PolygonOnTriangulation.cxx index acad20b1ac..5ce89f2b2a 100644 --- a/src/FoundationClasses/TKMath/Poly/Poly_PolygonOnTriangulation.cxx +++ b/src/FoundationClasses/TKMath/Poly/Poly_PolygonOnTriangulation.cxx @@ -60,9 +60,13 @@ occ::handle Poly_PolygonOnTriangulation::Copy() con { occ::handle aCopy; if (myParameters.IsNull()) + { aCopy = new Poly_PolygonOnTriangulation(myNodes); + } else + { aCopy = new Poly_PolygonOnTriangulation(myNodes, myParameters->Array1()); + } aCopy->Deflection(myDeflection); return aCopy; } diff --git a/src/FoundationClasses/TKMath/TopLoc/TopLoc_Datum3D.cxx b/src/FoundationClasses/TKMath/TopLoc/TopLoc_Datum3D.cxx index 9c9548c85b..df8dc136aa 100644 --- a/src/FoundationClasses/TKMath/TopLoc/TopLoc_Datum3D.cxx +++ b/src/FoundationClasses/TKMath/TopLoc/TopLoc_Datum3D.cxx @@ -48,7 +48,7 @@ void TopLoc_Datum3D::DumpJson(Standard_OStream& theOStream, int theDepth) const void TopLoc_Datum3D::ShallowDump(Standard_OStream& S) const { - S << " TopLoc_Datum3D " << (void*)this << std::endl; + S << " TopLoc_Datum3D " << (void*)this << '\n'; int i; gp_Trsf T = myTrsf; for (i = 1; i <= 3; i++) @@ -59,5 +59,5 @@ void TopLoc_Datum3D::ShallowDump(Standard_OStream& S) const S << "," << std::setw(10) << T.Value(i, 4); S << ")\n"; } - S << std::endl; + S << '\n'; } diff --git a/src/FoundationClasses/TKMath/TopLoc/TopLoc_Location.cxx b/src/FoundationClasses/TKMath/TopLoc/TopLoc_Location.cxx index 96c0d99399..a862abe23d 100644 --- a/src/FoundationClasses/TKMath/TopLoc/TopLoc_Location.cxx +++ b/src/FoundationClasses/TKMath/TopLoc/TopLoc_Location.cxx @@ -43,9 +43,13 @@ const gp_Trsf& TopLoc_Location::Transformation() const { static const gp_Trsf THE_IDENTITY_TRSF; if (IsIdentity()) + { return THE_IDENTITY_TRSF; + } else + { return myItems.Value().myTrsf; + } } TopLoc_Location::operator gp_Trsf() const @@ -58,7 +62,9 @@ TopLoc_Location::operator gp_Trsf() const TopLoc_Location TopLoc_Location::Inverted() const { if (IsIdentity()) + { return *this; + } // // the inverse of a Location is a chain in revert order @@ -85,10 +91,14 @@ TopLoc_Location TopLoc_Location::Multiplied(const TopLoc_Location& Other) const // cancelling null exponents if (IsIdentity()) + { return Other; + } if (Other.IsIdentity()) + { return *this; + } // prepend the queue of Other TopLoc_Location result = Multiplied(Other.NextLocation()); @@ -104,7 +114,9 @@ TopLoc_Location TopLoc_Location::Multiplied(const TopLoc_Location& Other) const } } if (p != 0) + { result.myItems.Construct(TopLoc_ItemLocation(Other.FirstDatum(), p)); + } return result; } @@ -145,11 +157,17 @@ TopLoc_Location TopLoc_Location::Predivided(const TopLoc_Location& Other) const TopLoc_Location TopLoc_Location::Powered(const int pwr) const { if (IsIdentity()) + { return *this; + } if (pwr == 1) + { return *this; + } if (pwr == 0) + { return TopLoc_Location(); + } // optimisation when just one element if (myItems.Tail().IsEmpty()) @@ -160,9 +178,13 @@ TopLoc_Location TopLoc_Location::Powered(const int pwr) const } if (pwr > 0) + { return Multiplied(Powered(pwr - 1)); + } else + { return Inverted().Powered(-pwr); + } } //================================================================================================= @@ -182,11 +204,13 @@ void TopLoc_Location::ShallowDump(Standard_OStream& S) const S << "TopLoc_Location : "; TopLoc_SListOfItemLocation items = myItems; if (items.IsEmpty()) - S << "Identity" << std::endl; + { + S << "Identity" << '\n'; + } while (items.More()) { S << "\n"; - S << " Exponent : " << items.Value().myPower << std::endl; + S << " Exponent : " << items.Value().myPower << '\n'; items.Value().myDatum->ShallowDump(S); items.Next(); } diff --git a/src/FoundationClasses/TKMath/TopLoc/TopLoc_SListOfItemLocation.cxx b/src/FoundationClasses/TKMath/TopLoc/TopLoc_SListOfItemLocation.cxx index 1ba89df5d2..a9c06e09a3 100644 --- a/src/FoundationClasses/TKMath/TopLoc/TopLoc_SListOfItemLocation.cxx +++ b/src/FoundationClasses/TKMath/TopLoc/TopLoc_SListOfItemLocation.cxx @@ -38,7 +38,9 @@ TopLoc_SListOfItemLocation& TopLoc_SListOfItemLocation::Assign( const TopLoc_SListOfItemLocation& Other) { if (this == &Other) + { return *this; + } Clear(); myNode = Other.myNode; @@ -58,7 +60,11 @@ const TopLoc_ItemLocation& TopLoc_SListOfItemLocation::Value() const const TopLoc_SListOfItemLocation& TopLoc_SListOfItemLocation::Tail() const { if (!myNode.IsNull()) + { return myNode->Tail(); + } else + { return *this; + } } diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax2.cxx b/src/FoundationClasses/TKMath/gp/gp_Ax2.cxx index 6fac9a2b39..bfe9114c29 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax2.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax2.cxx @@ -47,23 +47,35 @@ gp_Ax2::gp_Ax2(const gp_Pnt& P, const gp_Dir& V) if (Babs <= Aabs && Babs <= Cabs) { if (Aabs > Cabs) + { D.SetCoord(-C, 0., A); + } else + { D.SetCoord(C, 0., -A); + } } else if (Aabs <= Babs && Aabs <= Cabs) { if (Babs > Cabs) + { D.SetCoord(0., -C, B); + } else + { D.SetCoord(0., C, -B); + } } else { if (Aabs > Babs) + { D.SetCoord(-B, A, 0.); + } else + { D.SetCoord(B, -A, 0.); + } } SetXDirection(D); } @@ -182,7 +194,9 @@ bool gp_Ax2::InitFromJson(const Standard_SStream& theSStream, int& theStreamPos) vydir = gp_Dir(anYDir); if (!Direction().IsEqual(aDir, Precision::Confusion())) + { return false; + } theStreamPos = aPos; return true; diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax2d.cxx b/src/FoundationClasses/TKMath/gp/gp_Ax2d.cxx index 46498debd2..63552f456a 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax2d.cxx @@ -34,12 +34,16 @@ bool gp_Ax2d::IsCoaxial(const gp_Ax2d& Other, XY1.Subtract(Other.loc.XY()); double D1 = XY1.Crossed(Other.vdir.XY()); if (D1 < 0) + { D1 = -D1; + } gp_XY XY2 = Other.loc.XY(); XY2.Subtract(loc.XY()); double D2 = XY2.Crossed(vdir.XY()); if (D2 < 0) + { D2 = -D2; + } return (vdir.IsParallel(Other.vdir, AngularTolerance) && D1 <= LinearTolerance && D2 <= LinearTolerance); } @@ -48,7 +52,9 @@ void gp_Ax2d::Scale(const gp_Pnt2d& P, const double S) { loc.Scale(P, S); if (S < 0.0) + { vdir.Reverse(); + } } void gp_Ax2d::Mirror(const gp_Pnt2d& P) noexcept diff --git a/src/FoundationClasses/TKMath/gp/gp_Ax3.cxx b/src/FoundationClasses/TKMath/gp/gp_Ax3.cxx index 319a823bf9..95f4faa593 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Ax3.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Ax3.cxx @@ -45,23 +45,35 @@ gp_Ax3::gp_Ax3(const gp_Pnt& P, const gp_Dir& V) if (Babs <= Aabs && Babs <= Cabs) { if (Aabs > Cabs) + { D.SetCoord(-C, 0., A); + } else + { D.SetCoord(C, 0., -A); + } } else if (Aabs <= Babs && Aabs <= Cabs) { if (Babs > Cabs) + { D.SetCoord(0., -C, B); + } else + { D.SetCoord(0., C, -B); + } } else { if (Aabs > Babs) + { D.SetCoord(-B, A, 0.); + } else + { D.SetCoord(B, -A, 0.); + } } vxdir = D; vydir = V.Crossed(vxdir); @@ -178,7 +190,9 @@ bool gp_Ax3::InitFromJson(const Standard_SStream& theSStream, int& theStreamPos) vydir = gp_Dir(anYDir); if (!Direction().IsEqual(aDir, Precision::Angular())) + { return false; + } theStreamPos = aPos; return true; diff --git a/src/FoundationClasses/TKMath/gp/gp_Dir.cxx b/src/FoundationClasses/TKMath/gp/gp_Dir.cxx index 688ddca3ec..fe39d3ecf8 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Dir.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Dir.cxx @@ -35,14 +35,20 @@ double gp_Dir::Angle(const gp_Dir& Other) const // 0 et PI double Cosinus = coord.Dot(Other.coord); if (Cosinus > -0.70710678118655 && Cosinus < 0.70710678118655) + { return acos(Cosinus); + } else { double Sinus = (coord.Crossed(Other.coord)).Modulus(); if (Cosinus < 0.0) + { return M_PI - asin(Sinus); + } else + { return asin(Sinus); + } } } @@ -53,18 +59,28 @@ double gp_Dir::AngleWithRef(const gp_Dir& Other, const gp_Dir& Vref) const double Cosinus = coord.Dot(Other.coord); double Sinus = XYZ.Modulus(); if (Cosinus > -0.70710678118655 && Cosinus < 0.70710678118655) + { Ang = acos(Cosinus); + } else { if (Cosinus < 0.0) + { Ang = M_PI - asin(Sinus); + } else + { Ang = asin(Sinus); + } } if (XYZ.Dot(Vref.coord) >= 0.0) + { return Ang; + } else + { return -Ang; + } } void gp_Dir::Mirror(const gp_Dir& V) noexcept diff --git a/src/FoundationClasses/TKMath/gp/gp_Dir2d.cxx b/src/FoundationClasses/TKMath/gp/gp_Dir2d.cxx index 6f7709245b..2c6f2fbae8 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Dir2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Dir2d.cxx @@ -36,20 +36,30 @@ double gp_Dir2d::Angle(const gp_Dir2d& Other) const if (Cosinus > -0.70710678118655 && Cosinus < 0.70710678118655) { if (Sinus > 0.0) + { return acos(Cosinus); + } else + { return -acos(Cosinus); + } } else { if (Cosinus > 0.0) + { return asin(Sinus); + } else { if (Sinus > 0.0) + { return M_PI - asin(Sinus); + } else + { return -M_PI - asin(Sinus); + } } } } diff --git a/src/FoundationClasses/TKMath/gp/gp_GTrsf.cxx b/src/FoundationClasses/TKMath/gp/gp_GTrsf.cxx index 68dcec5c86..f34c18fcd4 100644 --- a/src/FoundationClasses/TKMath/gp/gp_GTrsf.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_GTrsf.cxx @@ -157,12 +157,18 @@ void gp_GTrsf::SetForm() double s = M.Determinant(); if (std::abs(s) < gp::Resolution()) + { throw Standard_ConstructionError("gp_GTrsf::SetForm, null determinant"); + } if (s > 0) + { s = std::pow(s, 1. / 3.); + } else + { s = -std::pow(-s, 1. / 3.); + } M.Divide(s); // check if the matrix is an uniform matrix @@ -174,15 +180,21 @@ void gp_GTrsf::SetForm() anIdentity.SetIdentity(); TM.Subtract(anIdentity); if (shape == gp_Other) + { shape = gp_CompoundTrsf; + } for (int i = 1; i <= 3; i++) + { for (int j = 1; j <= 3; j++) + { if (std::abs(TM.Value(i, j)) > tol) { shape = gp_Other; return; } + } + } } //================================================================================================= diff --git a/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.cxx b/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.cxx index 229c1cae3b..57120db40e 100644 --- a/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_GTrsf2d.cxx @@ -170,20 +170,28 @@ gp_Trsf2d gp_GTrsf2d::Trsf2d() const const double aTolerance2 = 2.0 * aTolerance; if (Form() == gp_Other) + { throw Standard_ConstructionError("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(0)"); + } double value = (matrix.Value(1, 1) * matrix.Value(1, 1) + matrix.Value(2, 1) * matrix.Value(2, 1)); if (std::abs(value - 1.) > aTolerance2) + { throw Standard_ConstructionError("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(1)"); + } value = (matrix.Value(1, 2) * matrix.Value(1, 2) + matrix.Value(2, 2) * matrix.Value(2, 2)); if (std::abs(value - 1.) > aTolerance2) + { throw Standard_ConstructionError("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(2)"); + } value = (matrix.Value(1, 1) * matrix.Value(1, 2) + matrix.Value(2, 1) * matrix.Value(2, 2)); if (std::abs(value) > aTolerance) + { throw Standard_ConstructionError("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(3)"); + } gp_Trsf2d aTransformation; aTransformation.matrix = matrix; diff --git a/src/FoundationClasses/TKMath/gp/gp_Mat.cxx b/src/FoundationClasses/TKMath/gp/gp_Mat.cxx index e56fe67bb9..0c28f09267 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Mat.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Mat.cxx @@ -204,9 +204,13 @@ gp_XYZ gp_Mat::Column(const int theCol) const { Standard_OutOfRange_Raise_if(theCol < 1 || theCol > 3, "gp_Mat::Column() - wrong index"); if (theCol == 1) + { return gp_XYZ(myMat[0][0], myMat[1][0], myMat[2][0]); + } if (theCol == 2) + { return gp_XYZ(myMat[0][1], myMat[1][1], myMat[2][1]); + } return gp_XYZ(myMat[0][2], myMat[1][2], myMat[2][2]); } @@ -223,9 +227,13 @@ gp_XYZ gp_Mat::Row(const int theRow) const { Standard_OutOfRange_Raise_if(theRow < 1 || theRow > 3, "gp_Mat::Row() - wrong index"); if (theRow == 1) + { return gp_XYZ(myMat[0][0], myMat[0][1], myMat[0][2]); + } if (theRow == 2) + { return gp_XYZ(myMat[1][0], myMat[1][1], myMat[1][2]); + } return gp_XYZ(myMat[2][0], myMat[2][1], myMat[2][2]); } diff --git a/src/FoundationClasses/TKMath/gp/gp_Mat2d.cxx b/src/FoundationClasses/TKMath/gp/gp_Mat2d.cxx index 2b6e562886..59517cf418 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Mat2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Mat2d.cxx @@ -157,15 +157,21 @@ void gp_Mat2d::Power(const int theN) else { if (theN < 0) + { Invert(); + } int Npower = std::abs(theN) - 1; gp_Mat2d aTemp = *this; for (;;) { if (IsOdd(Npower)) + { Multiply(aTemp); + } if (Npower == 1) + { break; + } aTemp.Multiply(aTemp); Npower = Npower / 2; } diff --git a/src/FoundationClasses/TKMath/gp/gp_Pln.cxx b/src/FoundationClasses/TKMath/gp/gp_Pln.cxx index 4110fd0b13..9953074422 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Pln.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Pln.cxx @@ -49,23 +49,35 @@ gp_Pln::gp_Pln(const gp_Pnt& theP, const gp_Dir& theV) if (anAbsB <= anAbsA && anAbsB <= anAbsC) { if (anAbsA > anAbsC) + { myPosition = gp_Ax3(theP, theV, gp_Dir(-C, 0., A)); + } else + { myPosition = gp_Ax3(theP, theV, gp_Dir(C, 0., -A)); + } } else if (anAbsA <= anAbsB && anAbsA <= anAbsC) { if (anAbsB > anAbsC) + { myPosition = gp_Ax3(theP, theV, gp_Dir(0., -C, B)); + } else + { myPosition = gp_Ax3(theP, theV, gp_Dir(0., C, -B)); + } } else { if (anAbsA > anAbsB) + { myPosition = gp_Ax3(theP, theV, gp_Dir(-B, A, 0.)); + } else + { myPosition = gp_Ax3(theP, theV, gp_Dir(B, -A, 0.)); + } } } @@ -79,29 +91,41 @@ gp_Pln::gp_Pln(const double theA, const double theB, const double theC, const do if (anAbsB <= anAbsA && anAbsB <= anAbsC) { if (anAbsA > anAbsC) + { myPosition = gp_Ax3(gp_Pnt(-theD / theA, 0., 0.), gp_Dir(theA, theB, theC), gp_Dir(-theC, 0., theA)); + } else + { myPosition = gp_Ax3(gp_Pnt(0., 0., -theD / theC), gp_Dir(theA, theB, theC), gp_Dir(theC, 0., -theA)); + } } else if (anAbsA <= anAbsB && anAbsA <= anAbsC) { if (anAbsB > anAbsC) + { myPosition = gp_Ax3(gp_Pnt(0., -theD / theB, 0.), gp_Dir(theA, theB, theC), gp_Dir(0., -theC, theB)); + } else + { myPosition = gp_Ax3(gp_Pnt(0., 0., -theD / theC), gp_Dir(theA, theB, theC), gp_Dir(0., theC, -theB)); + } } else { if (anAbsA > anAbsB) + { myPosition = gp_Ax3(gp_Pnt(-theD / theA, 0., 0.), gp_Dir(theA, theB, theC), gp_Dir(-theB, theA, 0.)); + } else + { myPosition = gp_Ax3(gp_Pnt(0., -theD / theB, 0.), gp_Dir(theA, theB, theC), gp_Dir(theB, -theA, 0.)); + } } } diff --git a/src/FoundationClasses/TKMath/gp/gp_Quaternion.cxx b/src/FoundationClasses/TKMath/gp/gp_Quaternion.cxx index a610d0aab2..538e1e5e4d 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Quaternion.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Quaternion.cxx @@ -27,7 +27,9 @@ bool gp_Quaternion::IsEqual(const gp_Quaternion& theOther) const { if (this == &theOther) + { return true; + } return std::abs(x - theOther.x) <= gp::Resolution() && std::abs(y - theOther.y) <= gp::Resolution() && std::abs(z - theOther.z) <= gp::Resolution() @@ -45,9 +47,13 @@ void gp_Quaternion::SetRotation(const gp_Vec& theVecFrom, const gp_Vec& theVecTo if (w <= gp::Resolution()) // angle close to PI { if ((theVecFrom.Z() * theVecFrom.Z()) > (theVecFrom.X() * theVecFrom.X())) + { Set(0.0, theVecFrom.Z(), -theVecFrom.Y(), w); // theVecFrom * gp_Vec(1,0,0) + } else + { Set(theVecFrom.Y(), -theVecFrom.X(), 0.0, w); // theVecFrom * gp_Vec(0,0,1) + } } Normalize(); } @@ -307,7 +313,9 @@ void gp_Quaternion::SetEulerAngles(const gp_EulerSequence theOrder, c = theAlpha; } if (o.isOdd) + { b = -b; + } double ti = 0.5 * a; double tj = 0.5 * b; @@ -339,7 +347,9 @@ void gp_Quaternion::SetEulerAngles(const gp_EulerSequence theOrder, values[0] = cj * cc + sj * ss; } if (o.isOdd) + { values[o.j] = -values[o.j]; + } x = values[1]; y = values[2]; diff --git a/src/FoundationClasses/TKMath/gp/gp_Trsf.cxx b/src/FoundationClasses/TKMath/gp/gp_Trsf.cxx index 3e8b719e50..13970d43d2 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Trsf.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Trsf.cxx @@ -252,12 +252,16 @@ void gp_Trsf::SetTranslationPart(const gp_Vec& V) noexcept case gp_Identity: if (!locnull) + { shape = gp_Translation; + } break; case gp_Translation: if (locnull) + { shape = gp_Identity; + } break; case gp_Rotation: @@ -289,27 +293,41 @@ void gp_Trsf::SetScaleFactor(const double S) case gp_Identity: case gp_Translation: if (!unit) + { shape = gp_Scale; + } if (munit) + { shape = gp_PntMirror; + } break; case gp_Rotation: if (!unit) + { shape = gp_CompoundTrsf; + } break; case gp_PntMirror: case gp_Ax1Mirror: case gp_Ax2Mirror: if (!munit) + { shape = gp_Scale; + } if (unit) + { shape = gp_Identity; + } break; case gp_Scale: if (unit) + { shape = gp_Identity; + } if (munit) + { shape = gp_PntMirror; + } break; case gp_CompoundTrsf: break; @@ -348,9 +366,13 @@ void gp_Trsf::SetValues(const double a11, Standard_ConstructionError_Raise_if(std::abs(s) < gp::Resolution(), "gp_Trsf::SetValues, null determinant"); if (s > 0) + { s = std::pow(s, 1. / 3.); + } else + { s = -std::pow(-s, 1. / 3.); + } M.Divide(s); scale = s; @@ -382,7 +404,9 @@ void gp_Trsf::Invert() { } else if (shape == gp_Translation || shape == gp_PntMirror) + { loc.Reverse(); + } else if (shape == gp_Scale) { Standard_ConstructionError_Raise_if(std::abs(scale) <= gp::Resolution(), @@ -571,9 +595,13 @@ void gp_Trsf::Power(const int N) for (;;) { if (IsOdd(Npower)) + { loc.Add(Temploc); + } if (Npower == 1) + { break; + } Temploc.Add(Temploc); Npower = Npower / 2; } @@ -591,7 +619,9 @@ void gp_Trsf::Power(const int N) scale = scale * Tempscale; } if (Npower == 1) + { break; + } Temploc.Add(Temploc.Multiplied(Tempscale)); Tempscale = Tempscale * Tempscale; Npower = Npower / 2; @@ -606,9 +636,13 @@ void gp_Trsf::Power(const int N) for (;;) { if (IsOdd(Npower)) + { matrix.Multiply(Tempmatrix); + } if (Npower == 1) + { break; + } Tempmatrix.Multiply(Tempmatrix); Npower = Npower / 2; } @@ -624,7 +658,9 @@ void gp_Trsf::Power(const int N) matrix.Multiply(Tempmatrix); } if (Npower == 1) + { break; + } Temploc.Add(Temploc.Multiplied(Tempmatrix)); Tempmatrix.Multiply(Tempmatrix); Npower = Npower / 2; @@ -659,7 +695,9 @@ void gp_Trsf::Power(const int N) matrix.Multiply(Tempmatrix); } if (Npower == 1) + { break; + } Tempscale = Tempscale * Tempscale; Temploc.Add((Temploc.Multiplied(Tempmatrix)).Multiplied(Tempscale)); Tempmatrix.Multiply(Tempmatrix); @@ -731,7 +769,9 @@ void gp_Trsf::PreMultiply(const gp_Trsf& T) shape = gp_CompoundTrsf; matrix = T.matrix; if (T.scale == 1.0) + { loc.Multiply(T.matrix); + } else { scale = T.scale; @@ -771,7 +811,9 @@ void gp_Trsf::PreMultiply(const gp_Trsf& T) shape = gp_CompoundTrsf; matrix = T.matrix; if (T.scale == 1.0) + { loc.Multiply(T.matrix); + } else { loc.Multiply(matrix); diff --git a/src/FoundationClasses/TKMath/gp/gp_Trsf2d.cxx b/src/FoundationClasses/TKMath/gp/gp_Trsf2d.cxx index 201eac435d..e9f2943bcd 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Trsf2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Trsf2d.cxx @@ -123,10 +123,14 @@ void gp_Trsf2d::SetScaleFactor(const double S) { double X = loc.X(); if (X < 0) + { X = -X; + } double Y = loc.Y(); if (Y < 0) + { Y = -Y; + } if (X <= gp::Resolution() && Y <= gp::Resolution()) { if (shape == gp_Identity || shape == gp_Rotation) @@ -194,12 +198,18 @@ void gp_Trsf2d::SetScaleFactor(const double S) gp_Mat2d gp_Trsf2d::VectorialPart() const { if (scale == 1.0) + { return matrix; + } gp_Mat2d M = matrix; if (shape == gp_Scale || shape == gp_PntMirror) + { M.SetDiagonal(matrix.Value(1, 1) * scale, matrix.Value(2, 2) * scale); + } else + { M.Multiply(scale); + } return M; } @@ -291,7 +301,9 @@ void gp_Trsf2d::Multiply(const gp_Trsf2d& T) gp_XY Tloc(T.loc); Tloc.Multiply(matrix); if (scale != 1.0) + { Tloc.Multiply(scale); + } loc.Add(Tloc); } else if ((shape == gp_Scale || shape == gp_PntMirror) && T.shape == gp_Translation) @@ -330,7 +342,9 @@ void gp_Trsf2d::Multiply(const gp_Trsf2d& T) gp_XY Tloc(T.loc); Tloc.Multiply(matrix); if (scale == 1.0) + { scale = T.scale; + } else { Tloc.Multiply(scale); @@ -385,24 +399,34 @@ void gp_Trsf2d::Power(const int N) { } else if (N == -1) + { Invert(); + } else { if (N < 0) + { Invert(); + } if (shape == gp_Translation) { int Npower = N; if (Npower < 0) + { Npower = -Npower; + } Npower--; gp_XY Temploc = loc; for (;;) { if (IsOdd(Npower)) + { loc.Add(Temploc); + } if (Npower == 1) + { break; + } Temploc.Add(Temploc); Npower = Npower / 2; } @@ -411,7 +435,9 @@ void gp_Trsf2d::Power(const int N) { int Npower = N; if (Npower < 0) + { Npower = -Npower; + } Npower--; gp_XY Temploc = loc; double Tempscale = scale; @@ -423,7 +449,9 @@ void gp_Trsf2d::Power(const int N) scale = scale * Tempscale; } if (Npower == 1) + { break; + } Temploc.Add(Temploc.Multiplied(Tempscale)); Tempscale = Tempscale * Tempscale; Npower = Npower / 2; @@ -433,7 +461,9 @@ void gp_Trsf2d::Power(const int N) { int Npower = N; if (Npower < 0) + { Npower = -Npower; + } Npower--; gp_Mat2d Tempmatrix(matrix); if (loc.X() == 0.0 && loc.Y() == 0.0) @@ -441,9 +471,13 @@ void gp_Trsf2d::Power(const int N) for (;;) { if (IsOdd(Npower)) + { matrix.Multiply(Tempmatrix); + } if (Npower == 1) + { break; + } Tempmatrix.Multiply(Tempmatrix); Npower = Npower / 2; } @@ -459,7 +493,9 @@ void gp_Trsf2d::Power(const int N) matrix.Multiply(Tempmatrix); } if (Npower == 1) + { break; + } Temploc.Add(Temploc.Multiplied(Tempmatrix)); Tempmatrix.Multiply(Tempmatrix); Npower = Npower / 2; @@ -481,7 +517,9 @@ void gp_Trsf2d::Power(const int N) shape = gp_CompoundTrsf; int Npower = N; if (Npower < 0) + { Npower = -Npower; + } Npower--; matrix.SetDiagonal(scale * matrix.Value(1, 1), scale * matrix.Value(2, 2)); gp_XY Temploc = loc; @@ -496,7 +534,9 @@ void gp_Trsf2d::Power(const int N) matrix.Multiply(Tempmatrix); } if (Npower == 1) + { break; + } Tempscale = Tempscale * Tempscale; Temploc.Add((Temploc.Multiplied(Tempmatrix)).Multiplied(Tempscale)); Tempmatrix.Multiply(Tempmatrix); @@ -566,7 +606,9 @@ void gp_Trsf2d::PreMultiply(const gp_Trsf2d& T) shape = gp_CompoundTrsf; matrix = T.matrix; if (T.scale == 1.0) + { loc.Multiply(T.matrix); + } else { scale = T.scale; @@ -604,7 +646,9 @@ void gp_Trsf2d::PreMultiply(const gp_Trsf2d& T) shape = gp_CompoundTrsf; matrix = T.matrix; if (T.scale == 1.0) + { loc.Multiply(T.matrix); + } else { loc.Multiply(matrix); @@ -646,9 +690,13 @@ void gp_Trsf2d::SetValues(const double a11, "gp_Trsf2d::SetValues, null determinant"); if (s > 0) + { s = sqrt(s); + } else + { s = sqrt(-s); + } M.Divide(s); diff --git a/src/FoundationClasses/TKMath/gp/gp_Vec2d.cxx b/src/FoundationClasses/TKMath/gp/gp_Vec2d.cxx index 31acbf84a3..f12a08b9f5 100644 --- a/src/FoundationClasses/TKMath/gp/gp_Vec2d.cxx +++ b/src/FoundationClasses/TKMath/gp/gp_Vec2d.cxx @@ -55,7 +55,9 @@ double gp_Vec2d::Angle(const gp_Vec2d& theOther) const const double aNorm = Magnitude(); const double anOtherNorm = theOther.Magnitude(); if (aNorm <= gp::Resolution() || anOtherNorm <= gp::Resolution()) + { throw gp_VectorWithNullMagnitude(); + } const double aD = aNorm * anOtherNorm; const double aCosinus = coord.Dot(theOther.coord) / aD; @@ -73,9 +75,13 @@ double gp_Vec2d::Angle(const gp_Vec2d& theOther) const { // For angles near 0 degrees or +/-180 degrees, use asin for better precision if (aCosinus > 0.0) + { return asin(aSinus); + } else + { return (aSinus > 0.0) ? M_PI - asin(aSinus) : -M_PI - asin(aSinus); + } } } diff --git a/src/FoundationClasses/TKMath/math/math.cxx b/src/FoundationClasses/TKMath/math/math.cxx index f3113ec73d..1cad72e297 100644 --- a/src/FoundationClasses/TKMath/math/math.cxx +++ b/src/FoundationClasses/TKMath/math/math.cxx @@ -1971,7 +1971,9 @@ void math::GaussPoints(const int Index, math_Vector& GPoint) { GPoint(i) = Point[Som + i]; if ((i + ind) <= Index) + { GPoint(i + ind) = -GPoint(i); + } } } @@ -1990,7 +1992,9 @@ void math::GaussWeights(const int Index, math_Vector& GWeight) { GWeight(i) = Weight[Som + i]; if ((i + ind) <= Index) + { GWeight(i + ind) = GWeight(i); + } } } @@ -2005,8 +2009,10 @@ bool math::OrderedGaussPointsAndWeights(const int Index, math_Vector& Points, ma { if (Index < 1 || // Index is not positive Points.Length() != Index || // Inconsistent length of Points. - Weights.Length() != Index) // Inconsistent length of Weights. + Weights.Length() != Index) + { // Inconsistent length of Weights. return false; + } if (Index <= 61) { @@ -2016,7 +2022,9 @@ bool math::OrderedGaussPointsAndWeights(const int Index, math_Vector& Points, ma // Compute the index of starting point in the array. for (i = 1; i < Index; i++) + { aStartInd += (i + 1) / 2; + } // Get points from the array. int aNbPts = Index / 2; @@ -2044,7 +2052,9 @@ bool math::OrderedGaussPointsAndWeights(const int Index, math_Vector& Points, ma { math_ComputeGaussPointsAndWeights PWcomputer(Index); if (!PWcomputer.IsDone()) + { return false; + } Points = PWcomputer.Points(); Weights = PWcomputer.Weights(); return true; diff --git a/src/FoundationClasses/TKMath/math/math_BFGS.cxx b/src/FoundationClasses/TKMath/math/math_BFGS.cxx index 8ac56526f0..1f2bf12d41 100644 --- a/src/FoundationClasses/TKMath/math/math_BFGS.cxx +++ b/src/FoundationClasses/TKMath/math/math_BFGS.cxx @@ -119,13 +119,17 @@ static bool ComputeInitScale(const double theF0, { const double dy1 = theGr * theDir; if (std::abs(dy1) < RealSmall()) + { return false; + } const double aHnr1 = theDir.Norm2(); const double alfa = 0.7 * (-theF0) / dy1; theScale = 0.015 / std::sqrt(aHnr1); if (theScale > alfa) + { theScale = alfa; + } return true; } @@ -173,8 +177,10 @@ static bool ComputeMinMaxScale(const math_Vector& thePoint, theMinScale = std::max(theMinScale, std::min(aLScale, aRScale)); } else + { // point is out of bounds return false; + } } else { @@ -206,7 +212,9 @@ static bool MinimizeDirection(math_Vector& P, { double lambda; if (!ComputeInitScale(F0, Dir, Gr, lambda)) + { return false; + } // by default the scaling range is unlimited double aMinLambda = -Precision::Infinite(); @@ -215,7 +223,9 @@ static bool MinimizeDirection(math_Vector& P, { // limit the scaling range taking into account the bounds if (!ComputeMinMaxScale(P, Dir, theLeft, theRight, aMinLambda, aMaxLambda)) + { return false; + } if (aMinLambda > -Precision::PConfusion() && aMaxLambda < Precision::PConfusion()) { @@ -232,9 +242,13 @@ static bool MinimizeDirection(math_Vector& P, // re-compute scale values with new direction if (!ComputeInitScale(F0, Dir, Gr, lambda)) + { return false; + } if (!ComputeMinMaxScale(P, Dir, theLeft, theRight, aMinLambda, aMaxLambda)) + { return false; + } } lambda = std::min(lambda, aMaxLambda); lambda = std::max(lambda, aMinLambda); @@ -243,11 +257,15 @@ static bool MinimizeDirection(math_Vector& P, F.Initialize(P, Dir); double F1; if (!F.Value(lambda, F1)) + { return false; + } math_BracketMinimum Bracket(0.0, lambda); if (isBounds) + { Bracket.SetLimits(aMinLambda, aMaxLambda); + } Bracket.SetFA(F0); Bracket.SetFB(F1); Bracket.Perform(F); @@ -277,9 +295,13 @@ static bool MinimizeDirection(math_Vector& P, // set current point to intersection with bounds double aFMin, aFMax; if (!F.Value(aMinLambda, aFMin)) + { return false; + } if (!F.Value(aMaxLambda, aFMax)) + { return false; + } double aBestLambda; if (aFMin < aFMax) { @@ -372,13 +394,17 @@ void math_BFGS::Perform(math_MultipleVarFunctionWithGradient& F, const math_Vect } for (i = 1; i <= n; i++) + { dg(i) = TheGradient(i) - dg(i); + } for (i = 1; i <= n; i++) { hdg(i) = 0.0; for (j = 1; j <= n; j++) + { hdg(i) += hessin(i, j) * dg(j); + } } fac = fae = 0.0; @@ -391,24 +417,29 @@ void math_BFGS::Perform(math_MultipleVarFunctionWithGradient& F, const math_Vect fad = 1.0 / fae; for (i = 1; i <= n; i++) + { dg(i) = fac * xi(i) - fad * hdg(i); + } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) + { hessin(i, j) += fac * xi(i) * xi(j) - fad * hdg(i) * hdg(j) + fae * dg(i) * dg(j); + } } for (i = 1; i <= n; i++) { xi(i) = 0.0; for (j = 1; j <= n; j++) + { xi(i) -= hessin(i, j) * TheGradient(j); + } } } Done = false; TheStatus = math_TooManyIterations; - return; } //============================================================================= @@ -462,7 +493,9 @@ void math_BFGS::Dump(Standard_OStream& o) const o << " Number of iterations = " << NbIterations() << "\n"; } else + { o << " Status = not Done because " << (int)TheStatus << "\n"; + } } //============================================================================= diff --git a/src/FoundationClasses/TKMath/math/math_BissecNewton.cxx b/src/FoundationClasses/TKMath/math/math_BissecNewton.cxx index 9db17afaf3..915ad0a7a4 100644 --- a/src/FoundationClasses/TKMath/math/math_BissecNewton.cxx +++ b/src/FoundationClasses/TKMath/math/math_BissecNewton.cxx @@ -148,7 +148,6 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F, } TheStatus = math_TooManyIterations; Done = false; - return; } //================================================================================================= @@ -160,8 +159,8 @@ void math_BissecNewton::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " The Root is: " << x << std::endl; - o << " The value at this Root is: " << f << std::endl; + o << " The Root is: " << x << '\n'; + o << " The value at this Root is: " << f << '\n'; } else { diff --git a/src/FoundationClasses/TKMath/math/math_BracketMinimum.cxx b/src/FoundationClasses/TKMath/math/math_BracketMinimum.cxx index 67a36988aa..3f10158cd9 100644 --- a/src/FoundationClasses/TKMath/math/math_BracketMinimum.cxx +++ b/src/FoundationClasses/TKMath/math/math_BracketMinimum.cxx @@ -40,10 +40,14 @@ bool math_BracketMinimum::LimitAndMayBeSwap(math_Function& F, { theC = Limited(theC); if (std::abs(theB - theC) < Precision::PConfusion()) + { return false; + } bool OK = F.Value(theC, theFC); if (!OK) + { return false; + } // check that B is between A and C if ((theA - theB) * (theB - theC) < 0) { @@ -67,13 +71,17 @@ void math_BracketMinimum::Perform(math_Function& F) { OK = F.Value(Ax, FAx); if (!OK) + { return; + } } if (!myFB) { OK = F.Value(Bx, FBx); if (!OK) + { return; + } } if (FBx > FAx) { @@ -87,13 +95,17 @@ void math_BracketMinimum::Perform(math_Function& F) { OK = LimitAndMayBeSwap(F, Ax, Bx, FBx, Cx, FCx); if (!OK) + { return; + } } else { OK = F.Value(Cx, FCx); if (!OK) + { return; + } } while (FBx > FCx) @@ -103,13 +115,17 @@ void math_BracketMinimum::Perform(math_Function& F) u = Bx - ((Bx - Cx) * q - (Bx - Ax) * r) / (2.0 * SIGN(MAX(fabs(q - r), TINY), q - r)); ulim = Bx + GLIMIT * (Cx - Bx); if (myIsLimited) + { ulim = Limited(ulim); + } if ((Bx - u) * (u - Cx) > 0.0) { // u is between B and C OK = F.Value(u, fu); if (!OK) + { return; + } if (fu < FCx) { // solution is found (B, u, c) @@ -134,13 +150,17 @@ void math_BracketMinimum::Perform(math_Function& F) { OK = LimitAndMayBeSwap(F, Bx, Cx, FCx, u, fu); if (!OK) + { return; + } } else { OK = F.Value(u, fu); if (!OK) + { return; + } } } else if ((Cx - u) * (u - ulim) > 0.0) @@ -148,7 +168,9 @@ void math_BracketMinimum::Perform(math_Function& F) // u is beyond C but between C and limit OK = F.Value(u, fu); if (!OK) + { return; + } } else if ((u - ulim) * (ulim - Cx) >= 0.0) { @@ -156,7 +178,9 @@ void math_BracketMinimum::Perform(math_Function& F) u = ulim; OK = F.Value(u, fu); if (!OK) + { return; + } } else { @@ -167,13 +191,17 @@ void math_BracketMinimum::Perform(math_Function& F) { OK = LimitAndMayBeSwap(F, Bx, Cx, FCx, u, fu); if (!OK) + { return; + } } else { OK = F.Value(u, fu); if (!OK) + { return; + } } } SHFT(Ax, Bx, Cx, u); @@ -265,10 +293,10 @@ void math_BracketMinimum::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " The bracketed triplet is: " << std::endl; - o << Ax << ", " << Bx << ", " << Cx << std::endl; - o << " The corresponding function values are: " << std::endl; - o << FAx << ", " << FBx << ", " << FCx << std::endl; + o << " The bracketed triplet is: " << '\n'; + o << Ax << ", " << Bx << ", " << Cx << '\n'; + o << " The corresponding function values are: " << '\n'; + o << FAx << ", " << FBx << ", " << FCx << '\n'; } else { diff --git a/src/FoundationClasses/TKMath/math/math_BracketedRoot.cxx b/src/FoundationClasses/TKMath/math/math_BracketedRoot.cxx index 632842ef19..0798ac1738 100644 --- a/src/FoundationClasses/TKMath/math/math_BracketedRoot.cxx +++ b/src/FoundationClasses/TKMath/math/math_BracketedRoot.cxx @@ -127,9 +127,9 @@ void math_BracketedRoot::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " Number of iterations = " << NbIter << std::endl; - o << " The Root is: " << TheRoot << std::endl; - o << " The value at the root is: " << TheError << std::endl; + o << " Number of iterations = " << NbIter << '\n'; + o << " The Root is: " << TheRoot << '\n'; + o << " The value at the root is: " << TheError << '\n'; } else { diff --git a/src/FoundationClasses/TKMath/math/math_BrentMinimum.cxx b/src/FoundationClasses/TKMath/math/math_BrentMinimum.cxx index 1c48d1a6b6..9d4c6669f1 100644 --- a/src/FoundationClasses/TKMath/math/math_BrentMinimum.cxx +++ b/src/FoundationClasses/TKMath/math/math_BrentMinimum.cxx @@ -92,7 +92,9 @@ void math_BrentMinimum::Perform(math_Function& F, const double ax, const double { OK = F.Value(x, fx); if (!OK) + { return; + } } fw = fv = fx; for (iter = 1; iter <= Itermax; iter++) @@ -112,7 +114,9 @@ void math_BrentMinimum::Perform(math_Function& F, const double ax, const double p = (x - v) * q - (x - w) * r; q = 2.0 * (q - r); if (q > 0.0) + { p = -p; + } q = fabs(q); etemp = e; e = d; @@ -126,7 +130,9 @@ void math_BrentMinimum::Perform(math_Function& F, const double ax, const double d = p / q; u = x + d; if (u - a < tol2 || b - u < tol2) + { d = std::copysign(tol1, xm - x); + } } } else @@ -137,22 +143,32 @@ void math_BrentMinimum::Perform(math_Function& F, const double ax, const double u = (fabs(d) >= tol1 ? x + d : x + std::copysign(tol1, d)); OK = F.Value(u, fu); if (!OK) + { return; + } if (fu <= fx) { if (u >= x) + { a = x; + } else + { b = x; + } SHFT(v, w, x, u); SHFT(fv, fw, fx, fu); } else { if (u < x) + { a = u; + } else + { b = u; + } if (fu <= fw || w == x) { v = w; @@ -168,7 +184,6 @@ void math_BrentMinimum::Perform(math_Function& F, const double ax, const double } } Done = false; - return; } //================================================================================================= diff --git a/src/FoundationClasses/TKMath/math/math_ComputeGaussPointsAndWeights.cxx b/src/FoundationClasses/TKMath/math/math_ComputeGaussPointsAndWeights.cxx index 947c0a3947..b8311bcff3 100644 --- a/src/FoundationClasses/TKMath/math/math_ComputeGaussPointsAndWeights.cxx +++ b/src/FoundationClasses/TKMath/math/math_ComputeGaussPointsAndWeights.cxx @@ -43,7 +43,9 @@ math_ComputeGaussPointsAndWeights::math_ComputeGaussPointsAndWeights(const int N aDiag(i) = 0.; if (i == 1) + { aSubDiag(i) = 0.; + } else { int sqrIm1 = (i - 1) * (i - 1); @@ -92,7 +94,9 @@ math_Vector math_ComputeGaussPointsAndWeights::Points() const int Number = myPoints->Length(); math_Vector thePoints(1, Number); for (int i = 1; i <= Number; i++) + { thePoints(i) = myPoints->Value(i); + } return thePoints; } @@ -102,7 +106,9 @@ math_Vector math_ComputeGaussPointsAndWeights::Weights() const int Number = myWeights->Length(); math_Vector theWeights(1, Number); for (int i = 1; i <= Number; i++) + { theWeights(i) = myWeights->Value(i); + } return theWeights; } diff --git a/src/FoundationClasses/TKMath/math/math_ComputeKronrodPointsAndWeights.cxx b/src/FoundationClasses/TKMath/math/math_ComputeKronrodPointsAndWeights.cxx index de2e7d53d8..d4f6fb879f 100644 --- a/src/FoundationClasses/TKMath/math/math_ComputeKronrodPointsAndWeights.cxx +++ b/src/FoundationClasses/TKMath/math/math_ComputeKronrodPointsAndWeights.cxx @@ -45,7 +45,9 @@ math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const i aDiag(i) = 0.; if (i == 1) + { aSubDiag(i) = 0.; + } else { int sqrIm1 = (i - 1) * (i - 1); @@ -112,7 +114,9 @@ math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const i } for (j = aNd2; j >= 0; j--) + { s[j] = s[j - 1]; + } // Southward phase. for (m = n - 1; m <= 2 * n - 3; m++) @@ -157,7 +161,9 @@ math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const i delete[] bb; for (i = 1; i <= a2NP1; i++) + { aSubDiag(i) = std::sqrt(aSubDiag(i)); + } // Compute eigen values. math_EigenValuesSearcher EVsearch(aDiag, aSubDiag); @@ -199,7 +205,9 @@ math_Vector math_ComputeKronrodPointsAndWeights::Points() const int Number = myPoints->Length(); math_Vector thePoints(1, Number); for (int i = 1; i <= Number; i++) + { thePoints(i) = myPoints->Value(i); + } return thePoints; } @@ -209,7 +217,9 @@ math_Vector math_ComputeKronrodPointsAndWeights::Weights() const int Number = myWeights->Length(); math_Vector theWeights(1, Number); for (int i = 1; i <= Number; i++) + { theWeights(i) = myWeights->Value(i); + } return theWeights; } diff --git a/src/FoundationClasses/TKMath/math/math_DirectPolynomialRoots.cxx b/src/FoundationClasses/TKMath/math/math_DirectPolynomialRoots.cxx index f2db903901..600fc3132e 100644 --- a/src/FoundationClasses/TKMath/math/math_DirectPolynomialRoots.cxx +++ b/src/FoundationClasses/TKMath/math/math_DirectPolynomialRoots.cxx @@ -370,13 +370,21 @@ bool ShouldReduceDegreeQuartic(const double theA, bool aWithA = false; if (std::abs(theB) > ZERO_THRESHOLD && std::abs(theB) <= aMaxCoeff1000) + { aWithA = true; + } if (std::abs(theC) > ZERO_THRESHOLD && std::abs(theC) <= aMaxCoeff1000) + { aWithA = true; + } if (std::abs(theD) > ZERO_THRESHOLD && std::abs(theD) <= aMaxCoeff1000) + { aWithA = true; + } if (std::abs(theE) > ZERO_THRESHOLD && std::abs(theE) <= aMaxCoeff1000) + { aWithA = true; + } return !aWithA; } @@ -477,13 +485,21 @@ QuarticFactorization FactorQuarticViaFerrari(const double theA, const double anEps = 100.0 * MACHINE_EPSILON; if (std::abs(aFactors.P1) <= anEps) + { aFactors.P1 = 0.0; + } if (std::abs(aFactors.P2) <= anEps) + { aFactors.P2 = 0.0; + } if (std::abs(aFactors.Q1) <= anEps) + { aFactors.Q1 = 0.0; + } if (std::abs(aFactors.Q2) <= anEps) + { aFactors.Q2 = 0.0; + } return aFactors; } @@ -637,7 +653,9 @@ void math_DirectPolynomialRoots::Solve(const double theA, double aP = aP1 + aP2; const double aEp = 5.0 * MACHINE_EPSILON * (std::abs(aP1) + std::abs(aP2)); if (std::abs(aP) <= aEp) + { aP = 0.0; + } const double aQ1 = aScaled.C; const double aQ2 = -aScaled.A * aScaled.B / 3.0; @@ -645,7 +663,9 @@ void math_DirectPolynomialRoots::Solve(const double theA, double aQ = aQ1 + aQ2 + aQ3; const double aEq = 10.0 * MACHINE_EPSILON * (std::abs(aQ1) + std::abs(aQ2) + std::abs(aQ3)); if (std::abs(aQ) <= aEq) + { aQ = 0.0; + } // Check for overflow if (std::abs(aP) > OVERFLOW_LIMIT) diff --git a/src/FoundationClasses/TKMath/math/math_EigenValuesSearcher.cxx b/src/FoundationClasses/TKMath/math/math_EigenValuesSearcher.cxx index 25d46a5c9d..719dcdcf36 100644 --- a/src/FoundationClasses/TKMath/math/math_EigenValuesSearcher.cxx +++ b/src/FoundationClasses/TKMath/math/math_EigenValuesSearcher.cxx @@ -32,7 +32,9 @@ double computeHypotenuseLength(const double theX, const double theY) void shiftSubdiagonalElements(NCollection_Array1& theSubdiagWork, const int theSize) { for (int anIdx = 2; anIdx <= theSize; anIdx++) + { theSubdiagWork(anIdx - 1) = theSubdiagWork(anIdx); + } theSubdiagWork(theSize) = 0.0; } @@ -56,7 +58,9 @@ int findSubmatrixEnd(const NCollection_Array1& theDiagWork, // When this condition is true in floating-point arithmetic, the subdiagonal // element can be treated as zero for convergence purposes. if (std::abs(theSubdiagWork(aSubmatrixEnd)) + aDiagSum == aDiagSum) + { break; + } } return aSubmatrixEnd; } @@ -72,11 +76,15 @@ double computeWilkinsonShift(const NCollection_Array1& theDiagWork, const double aRadius = computeHypotenuseLength(1.0, aShift); if (aShift < 0.0) + { aShift = theDiagWork(theEnd) - theDiagWork(theStart) + theSubdiagWork(theStart) / (aShift - aRadius); + } else + { aShift = theDiagWork(theEnd) - theDiagWork(theStart) + theSubdiagWork(theStart) / (aShift + aRadius); + } return aShift; } @@ -133,7 +141,9 @@ bool performQLStep(NCollection_Array1& theDiagWork, // Handle special case and update final elements if (aRadius == 0.0 && aRowIdx >= 1) + { return true; + } theDiagWork(theStart) -= aPrevDiag; theSubdiagWork(theStart) = aShift; @@ -160,7 +170,9 @@ bool performQLAlgorithm(NCollection_Array1& theDiagWork, if (aSubmatrixEnd != aSubmatrixStart) { if (aIterCount++ == MAX_ITERATIONS) + { return false; + } const double aShift = computeWilkinsonShift(theDiagWork, theSubdiagWork, aSubmatrixStart, aSubmatrixEnd); @@ -172,7 +184,9 @@ bool performQLAlgorithm(NCollection_Array1& theDiagWork, aSubmatrixEnd, aShift, theSize)) + { return false; + } } } while (aSubmatrixEnd != aSubmatrixStart); } @@ -207,8 +221,12 @@ math_EigenValuesSearcher::math_EigenValuesSearcher(const NCollection_Array1= 0) + { b += std::abs(tol1); + } else + { b += -std::abs(tol1); + } } F.Value(b, fb); fb -= K; @@ -316,10 +320,14 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, for (i = 0; i <= N; i++, X += dx) { if (X > XN) + { X = XN; + } Ok = F.Value(X, aux); if (Ok) + { ptrval(++Nvalid) = aux - K; + } // ptrval(i)-=K; } //-- Toute la fonction est nulle ? @@ -355,7 +363,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, { X2 = X + dx; if (X2 > XN) + { X2 = XN; + } if (ptrval(i) < 0.0) { if (ptrval(ip1) > 0.0) @@ -388,19 +398,29 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, // double Val,Deriv; X = X0 + i * dx; if (X > XN) + { X = XN; + } double u0, u1; u0 = dx * 0.5; u1 = X + u0; u0 += X; if (u0 < X0) + { u0 = X0; + } if (u0 > XN) + { u0 = XN; + } if (u1 < X0) + { u1 = X0; + } if (u1 > XN) + { u1 = XN; + } double y0, y1; F.Value(u0, y0); @@ -448,7 +468,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, { Rediscr = false; if (xm > XN) + { xm = XN; + } if (ptrval(i) > 0.0) { if ((ptrval(im1) > ptrval(i)) && (ptrval(ip1) > ptrval(i))) @@ -457,7 +479,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, //-- -------------- Estimation a partir de Xim1 xm1 = xm - dx; if (xm1 < X0) + { xm1 = X0; + } F.Values(xm1, ym, dym); ym -= K; if (dym < -1e-10 || dym > 1e-10) @@ -473,7 +497,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, { xp1 = xm + dx; if (xp1 > XN) + { xp1 = XN; + } F.Values(xp1, ym, dym); ym -= K; if (dym < -1e-10 || dym > 1e-10) @@ -495,7 +521,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, //-- -------------- Estimation a partir de Xim1 xm1 = xm - dx; if (xm1 < X0) + { xm1 = X0; + } F.Values(xm1, ym, dym); ym -= K; if (dym > 1e-10 || dym < -1e-10) @@ -511,7 +539,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, { xm1 = xm - dx; if (xm1 < X0) + { xm1 = X0; + } F.Values(xm1, ym, dym); ym -= K; if (dym > 1e-10 || dym < -1e-10) @@ -530,9 +560,13 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, double x0 = xm - dx; double x3 = xm + dx; if (x0 < X0) + { x0 = X0; + } if (x3 > XN) + { x3 = XN; + } double aSolX1 = 0., aSolX2 = 0.; double aVal1 = 0., aVal2 = 0.; double aDer1 = 0., aDer2 = 0.; @@ -674,24 +708,36 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, if (isSol1 && isSol2) { if (aVal2 - aVal1 > EpsF) + { AppendRoot(Sol, NbStateSol, aSolX1, F, K, NEpsX); + } else if (aVal1 - aVal2 > EpsF) + { AppendRoot(Sol, NbStateSol, aSolX2, F, K, NEpsX); + } else { aDer1 = std::abs(aDer1); F.Derivative(aSolX2, aDer2); aDer2 = std::abs(aDer2); if (aDer1 < aDer2) + { AppendRoot(Sol, NbStateSol, aSolX1, F, K, NEpsX); + } else + { AppendRoot(Sol, NbStateSol, aSolX2, F, K, NEpsX); + } } } else if (isSol1) + { AppendRoot(Sol, NbStateSol, aSolX1, F, K, NEpsX); + } else if (isSol2) + { AppendRoot(Sol, NbStateSol, aSolX2, F, K, NEpsX); + } } //-- Recherche d un extrema } //-- for } @@ -1345,10 +1391,10 @@ void math_FunctionRoots::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " Number of solutions = " << Sol.Length() << std::endl; + o << " Number of solutions = " << Sol.Length() << '\n'; for (int i = 1; i <= Sol.Length(); i++) { - o << " Solution Number " << i << "= " << Sol.Value(i) << std::endl; + o << " Solution Number " << i << "= " << Sol.Value(i) << '\n'; } } else diff --git a/src/FoundationClasses/TKMath/math/math_FunctionSetRoot.cxx b/src/FoundationClasses/TKMath/math/math_FunctionSetRoot.cxx index 95df36041f..f9b396d847 100644 --- a/src/FoundationClasses/TKMath/math/math_FunctionSetRoot.cxx +++ b/src/FoundationClasses/TKMath/math/math_FunctionSetRoot.cxx @@ -133,10 +133,14 @@ bool MyDirFunction::Value(const double x, double& fval) for (int i = FV->Lower(); i <= FV->Upper(); i++) { aVal = FV->Value(i); - if (aVal <= -1.e+100) // Precision::HalfInfinite() later + if (aVal <= -1.e+100) + { // Precision::HalfInfinite() later return false; - else if (aVal >= 1.e+100) // Precision::HalfInfinite() later + } + else if (aVal >= 1.e+100) + { // Precision::HalfInfinite() later return false; + } } fval = 0.5 * (FV->Norm2()); @@ -163,11 +167,15 @@ bool MyDirFunction::Value(const math_Vector& Sol, aVal = FF.Value(i); if (aVal < 0.) { - if (aVal <= -1.e+100) // Precision::HalfInfinite() later + if (aVal <= -1.e+100) + { // Precision::HalfInfinite() later return false; + } } - else if (aVal >= 1.e+100) // Precision::HalfInfinite() later + else if (aVal >= 1.e+100) + { // Precision::HalfInfinite() later return false; + } // modified by NIZHNY-MKK Mon Oct 3 17:57:05 2005.END } @@ -206,10 +214,14 @@ static bool MinimizeDirection(const math_Vector& P0, { invnorme = std::abs(Delta(ii)); if (invnorme > Eps) + { tol1d = std::min(tol1d, Tol(ii) / invnorme); + } } if (tol1d > 1.9) + { return false; // Pas la peine de se fatiguer + } tol1d /= 3; // JR/Hp : @@ -219,7 +231,9 @@ static bool MinimizeDirection(const math_Vector& P0, // Delta = P1 - P0; invnorme = Delta.Norm(); if (invnorme <= Eps) + { return false; + } invnorme = ((double)1) / invnorme; F.Initialize(P1, Delta); @@ -230,7 +244,9 @@ static bool MinimizeDirection(const math_Vector& P0, bx = 0; cx = (P2 - P1).Norm() * invnorme; if (cx < 1.e-2) + { return false; + } math_BrentMinimum Sol(tol1d, 100, tol1d); Sol.Perform(F, ax, bx, cx); @@ -273,10 +289,14 @@ static bool MinimizeDirection(const math_Vector& P, { absdir = std::abs(Dir(ii)); if (absdir > Eps) + { tol1d = std::min(tol1d, Tol(ii) / absdir); + } } if (tol1d > 0.9) + { return false; + } // (1) On realise une premiere interpolation quadratique double ax, bx, cx, df1, df2, Delta, tsol, fsol, tsolbis; @@ -298,9 +318,13 @@ static bool MinimizeDirection(const math_Vector& P, if (std::abs(ax) <= Eps) { // cas lineaire if (std::abs(bx) >= Eps) + { tsol = -cx / bx; + } else + { tsol = 0; + } } else { // cas quadratique @@ -312,7 +336,9 @@ static bool MinimizeDirection(const math_Vector& P, tsol = -(bx + Delta); tsolbis = (Delta - bx); if (std::abs(tsolbis) < std::abs(tsol)) + { tsol = tsolbis; + } tsol /= 2 * ax; } else @@ -324,7 +350,9 @@ static bool MinimizeDirection(const math_Vector& P, } if (std::abs(tsol) >= 1) + { return false; // resultat sans interet + } F.Initialize(P, Dir); F.Value(tsol, fsol); @@ -429,32 +457,46 @@ static void SearchDirection(const math_Matrix& DF, } math_Gauss Solut(DF, 1.e-9); if (Solut.IsDone()) + { Solut.Solve(Direction); + } else { // we have to "forget" singular directions. FSR_DEBUG(" Matrice singuliere : On prend SVD"); math_SVD SolvebySVD(DF); if (SolvebySVD.IsDone()) + { SolvebySVD.Solve(-1 * FF, Direction); + } else + { ChangeDirection = true; + } } } else if (Ninc > Neq) { math_SVD Solut(DF); if (Solut.IsDone()) + { Solut.Solve(-1 * FF, Direction); + } else + { ChangeDirection = true; + } } else if (Ninc < Neq) { // Calcul par GaussLeastSquare math_GaussLeastSquare Solut(DF); if (Solut.IsDone()) + { Solut.Solve(-1 * FF, Direction); + } else + { ChangeDirection = true; + } } } // Il vaut mieux interdire des directions trops longue @@ -511,7 +553,9 @@ static void SearchDirection(const math_Matrix& DF, for (i = 1; i <= Ninc; i++) { if (Constraints(i) != 0) + { Cons++; + } // sinon le systeme a resoudre ne change pas. } @@ -562,7 +606,9 @@ static void SearchDirection(const math_Matrix& DF, Direction(i) = MyDirection(k); } else + { Direction(i) = -GH(i); + } k++; } else @@ -611,8 +657,10 @@ bool Bounds(const math_Vector& InfBound, Constraints(i) = 1; Out = true; // Delta(i) is negative - if (-Delta(i) > Tol(i)) // Afin d'eviter des ratio nulles pour rien + if (-Delta(i) > Tol(i)) + { // Afin d'eviter des ratio nulles pour rien monratio = std::min(monratio, (InfBound(i) - SolSave(i)) / Delta(i)); + } } else if (Sol(i) > SupBound(i)) { @@ -620,7 +668,9 @@ bool Bounds(const math_Vector& InfBound, Out = true; // Delta(i) is positive if (Delta(i) > Tol(i)) + { monratio = std::min(monratio, (SupBound(i) - SolSave(i)) / Delta(i)); + } } } @@ -727,7 +777,9 @@ math_FunctionSetRoot::~math_FunctionSetRoot() = default; void math_FunctionSetRoot::SetTolerance(const math_Vector& theTolerance) { for (int i = 1; i <= Tol.Length(); ++i) + { Tol(i) = theTolerance(i); + } } //================================================================================================= @@ -794,9 +846,13 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, for (i = 1; i <= Ninc; i++) { if (Sol(i) <= theInfBound(i)) + { Sol(i) = theInfBound(i); + } else if (Sol(i) > theSupBound(i)) + { Sol(i) = theSupBound(i); + } } // Calcul de la premiere valeur de F et de son gradient @@ -854,7 +910,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, { Ambda = Ambda2 / std::sqrt(std::abs(Dy)); if (Ambda > 1.0) + { Ambda = 1.0; + } } else { @@ -1021,7 +1079,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, if (std::abs(Dy) <= Eps) { if (F2 > OldF) + { Sol = SolSave; + } Done = false; if (!theStopOnDivergent || !myIsDivergent) { @@ -1063,7 +1123,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, { Ambda = Ambda2 / std::sqrt(-Dy); if (Ambda > 1.0) + { Ambda = 1.0; + } } else { @@ -1209,18 +1271,24 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, Save(Kount) = F2; // Est ce la solution ? if (ChangeDirection) + { Verif = true; - // Gradient : Il faut eviter de boucler + // Gradient : Il faut eviter de boucler + } else { Verif = false; if (Kount > 1) { // Pour accelerer les cas quasi-quadratique if (Save(Kount - 1) < 1.e-4 * Save(Kount - 2)) + { Verif = true; + } } else + { Verif = (F2 < 1.e-6 * Save(0)); // Pour les cas dejas solutions + } } if (Verif) { @@ -1259,7 +1327,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, if (F2 >= 0.95 * Save(Kount - 5)) { if (!ChangeDirection) + { ChangeDirection = true; + } else { Done = false; @@ -1272,10 +1342,14 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, } } else + { ChangeDirection = false; // If yes we restart + } } else + { ChangeDirection = false; // No history, we continue + } // If the gradient does not decrease sufficiently with Newton, we try // the gradient method unless f decreases (as strange as it may seem, // with NEWTON the gradient of f can increase while f diff --git a/src/FoundationClasses/TKMath/math/math_Gauss.cxx b/src/FoundationClasses/TKMath/math/math_Gauss.cxx index e41a339070..4eab97bfd9 100644 --- a/src/FoundationClasses/TKMath/math/math_Gauss.cxx +++ b/src/FoundationClasses/TKMath/math/math_Gauss.cxx @@ -103,7 +103,7 @@ void math_Gauss::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " Determinant of A = " << D << std::endl; + o << " Determinant of A = " << D << '\n'; } else { diff --git a/src/FoundationClasses/TKMath/math/math_GaussLeastSquare.cxx b/src/FoundationClasses/TKMath/math/math_GaussLeastSquare.cxx index c17ef21dce..81786bb816 100644 --- a/src/FoundationClasses/TKMath/math/math_GaussLeastSquare.cxx +++ b/src/FoundationClasses/TKMath/math/math_GaussLeastSquare.cxx @@ -46,8 +46,6 @@ void math_GaussLeastSquare::Solve(const math_Vector& B, math_Vector& X) const X.Multiply(A2, B); LU_Solve(LU, Index, X); - - return; } void math_GaussLeastSquare::Dump(Standard_OStream& o) const diff --git a/src/FoundationClasses/TKMath/math/math_GaussSetIntegration.cxx b/src/FoundationClasses/TKMath/math/math_GaussSetIntegration.cxx index 7641acba9e..a31a90b276 100644 --- a/src/FoundationClasses/TKMath/math/math_GaussSetIntegration.cxx +++ b/src/FoundationClasses/TKMath/math/math_GaussSetIntegration.cxx @@ -66,7 +66,9 @@ math_GaussSetIntegration::math_GaussSetIntegration(math_FunctionSet& F, Tval(1) = Xm; // + Xr * GaussP(ind1); IsOk = F.Value(Tval, Val); if (!IsOk) + { return; + } Val *= GaussW(ind1); } else @@ -79,11 +81,15 @@ math_GaussSetIntegration::math_GaussSetIntegration(math_FunctionSet& F, Tval(1) = Xm + Xr * GaussP(i); IsOk = F.Value(Tval, FVal1); if (!IsOk) + { return; + } Tval(1) = Xm - Xr * GaussP(i); IsOk = F.Value(Tval, FVal2); if (!IsOk) + { return; + } FVal1 += FVal2; FVal1 *= GaussW(i); Val += FVal1; diff --git a/src/FoundationClasses/TKMath/math/math_GaussSingleIntegration.cxx b/src/FoundationClasses/TKMath/math/math_GaussSingleIntegration.cxx index ec6ee36cdf..b9c09a9ce1 100644 --- a/src/FoundationClasses/TKMath/math/math_GaussSingleIntegration.cxx +++ b/src/FoundationClasses/TKMath/math/math_GaussSingleIntegration.cxx @@ -86,7 +86,9 @@ math_GaussSingleIntegration::math_GaussSingleIntegration(math_Function& F, { Perform(F, Lower + (i - 1) * dU, Lower + i * dU, theOrder); if (!Done) + { return; + } Len += Val; } NIter++; @@ -124,7 +126,9 @@ void math_GaussSingleIntegration::Perform(math_Function& F, { // odder case Ok1 = F.Value(xm, Val); if (!Ok1) + { return; + } Val *= GaussW(ind1); } // Sommation sur tous les points de Gauss: avec utilisation de la symetrie. @@ -133,10 +137,14 @@ void math_GaussSingleIntegration::Perform(math_Function& F, dx = xr * GaussP(j); Ok1 = F.Value(xm - dx, F1); if (!Ok1) + { return; + } Ok1 = F.Value(xm + dx, F2); if (!Ok1) + { return; + } // Multiplication par les poids de Gauss. double FT = F1 + F2; Val += GaussW(j) * FT; diff --git a/src/FoundationClasses/TKMath/math/math_GlobOptMin.cxx b/src/FoundationClasses/TKMath/math/math_GlobOptMin.cxx index f339d4154e..4b7dff5c0b 100644 --- a/src/FoundationClasses/TKMath/math/math_GlobOptMin.cxx +++ b/src/FoundationClasses/TKMath/math/math_GlobOptMin.cxx @@ -200,9 +200,13 @@ void math_GlobOptMin::Perform(const bool isFindSingleSolution) { double currentLength = myB(i) - myA(i); if (currentLength < minLength) + { minLength = currentLength; + } if (currentLength > maxLength) + { maxLength = currentLength; + } myV(i) = 0.0; } @@ -234,9 +238,13 @@ void math_GlobOptMin::Perform(const bool isFindSingleSolution) else { if (myC > 1.0) + { myE3 = -maxLength * myTol / 4.0; + } else + { myE3 = -maxLength * myTol * myC / 4.0; + } } // Search single solution and current solution in its neighborhood. @@ -276,7 +284,9 @@ bool math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt, theVal = newtonMinimum.Minimum(); if (isInside(theOutPnt)) + { return true; + } } } @@ -295,7 +305,9 @@ bool math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt, theVal = bfgs.Minimum(); if (isInside(theOutPnt)) + { return true; + } } } @@ -304,7 +316,9 @@ bool math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt, { math_Matrix m(1, myN, 1, myN, 0.0); for (i = 1; i <= myN; i++) + { m(i, i) = 1.0; + } math_Powell powell(*myFunc, 1e-10); powell.Perform(*myFunc, thePnt, m); @@ -315,7 +329,9 @@ bool math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt, theVal = powell.Minimum(); if (isInside(theOutPnt)) + { return true; + } } } @@ -362,9 +378,13 @@ void math_GlobOptMin::computeInitialValues() myC = myInitC; aLipConst *= std::sqrt(myN) / aStep; if (aLipConst < myC * aMinEps) + { myC = std::max(aLipConst * aMinEps, aMinLC); + } else if (aLipConst > myC * aMaxEps) + { myC = std::min(myC * aMaxEps, aMaxLC); + } } //================================================================================================= @@ -389,7 +409,9 @@ void math_GlobOptMin::computeGlobalExtremum(int j) } if (CheckFunctionalStopCriteria()) + { return; // Best possible value is obtained. + } if (j == 1) { @@ -408,7 +430,9 @@ void math_GlobOptMin::computeGlobalExtremum(int j) // Piyavsky midpoint estimation. double aParam = (2 * myX(1) - myV(1)) * 0.5 + (aPrevVal - d) * 0.5 / myC; if (Precision::IsInfinite(aPrevVal)) + { aParam = myX(1) - myV(1) * 0.5; // Protection from upper dimension step. + } myX(1) = aParam; double aVal = 0; @@ -429,7 +453,9 @@ void math_GlobOptMin::computeGlobalExtremum(int j) checkAddCandidate(aStepBestPoint, aStepBestValue); if (CheckFunctionalStopCriteria()) + { return; // Best possible value is obtained. + } myV(1) = std::min(myE2 + std::abs(myF - d) / myC, myMaxV(1)); myLastStep = myV(1); @@ -441,17 +467,23 @@ void math_GlobOptMin::computeGlobalExtremum(int j) // Nullify steps on lower dimensions. for (i = 1; i < j; i++) + { myV(i) = 0.0; + } } if (j < myN) { double aUpperDimStep = std::max(myV(j), myE2); if (myV(j + 1) > aUpperDimStep) { - if (aUpperDimStep > myMaxV(j + 1)) // Case of too big step. + if (aUpperDimStep > myMaxV(j + 1)) + { // Case of too big step. myV(j + 1) = myMaxV(j + 1); + } else + { myV(j + 1) = aUpperDimStep; + } } } } @@ -466,7 +498,9 @@ bool math_GlobOptMin::isInside(const math_Vector& thePnt) for (i = 1; i <= myN; i++) { if (thePnt(i) < myGlobA(i) || thePnt(i) > myGlobB(i)) + { return false; + } } return true; @@ -496,7 +530,9 @@ bool math_GlobOptMin::isStored(const math_Vector& thePnt) } } if (isSame) + { return true; + } } } else @@ -511,7 +547,9 @@ bool math_GlobOptMin::isStored(const math_Vector& thePnt) { math_Vector aVec(1, myN); for (int aSolDim = 1; aSolDim <= myN; aSolDim++) + { aVec(aSolDim) = myY(aSolIdx * myN + aSolDim); + } myFilter.Add(aVec, aVec); } @@ -541,7 +579,9 @@ void math_GlobOptMin::Points(const int theIndex, math_Vector& theSol) int j; for (j = 1; j <= myN; j++) + { theSol(j) = myY((theIndex - 1) * myN + j); + } } //================================================================================================= @@ -583,7 +623,9 @@ void math_GlobOptMin::ComputeInitSol() aPnt = myA + (myB - myA) * (i - 1) / 2.0; if (computeLocalExtremum(aPnt, aVal, aPnt)) + { checkAddCandidate(aPnt, aVal); + } } } @@ -597,9 +639,13 @@ void math_GlobOptMin::checkAddCandidate(const math_Vector& thePnt, const double if (!isStored(thePnt)) { if ((theValue - myF) * myZ > 0.0) + { myF = theValue; + } for (int j = 1; j <= myN; j++) + { myY.Append(thePnt(j)); + } mySolCount++; } } @@ -613,7 +659,9 @@ void math_GlobOptMin::checkAddCandidate(const math_Vector& thePnt, const double myF = theValue; myY.Clear(); for (int j = 1; j <= myN; j++) + { myY.Append(thePnt(j)); + } mySolCount = 1; isFirstCellFilterInvoke = true; diff --git a/src/FoundationClasses/TKMath/math/math_Jacobi.cxx b/src/FoundationClasses/TKMath/math/math_Jacobi.cxx index c69ef6c65a..48cca68d10 100644 --- a/src/FoundationClasses/TKMath/math/math_Jacobi.cxx +++ b/src/FoundationClasses/TKMath/math/math_Jacobi.cxx @@ -46,7 +46,7 @@ void math_Jacobi::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " The eigenvalues vector is: " << EigenValues << std::endl; + o << " The eigenvalues vector is: " << EigenValues << '\n'; } else { diff --git a/src/FoundationClasses/TKMath/math/math_Kronrod.cxx b/src/FoundationClasses/TKMath/math/math_Kronrod.cxx index f2592df87c..95dabe94b0 100644 --- a/src/FoundationClasses/TKMath/math/math_Kronrod.cxx +++ b/src/FoundationClasses/TKMath/math/math_Kronrod.cxx @@ -3010,8 +3010,10 @@ bool math::KronrodPointsAndWeights(const int Index, math_Vector& Points, math_Ve if (Index < 3 || // Index is less then 3 Index % 2 == 0 || // Index is even Points.Length() != Index || // Inconsistent length of Points - Weights.Length() != Index) // Inconsistent length of Weights + Weights.Length() != Index) + { // Inconsistent length of Weights return false; + } if (Index <= 123) { @@ -3021,7 +3023,9 @@ bool math::KronrodPointsAndWeights(const int Index, math_Vector& Points, math_Ve // Compute the index of starting point in the array. for (i = 3; i < Index; i += 2) + { aStartInd += (i + 1) / 2; + } // Get points from the array. int aNbPts = i / 2; @@ -3044,7 +3048,9 @@ bool math::KronrodPointsAndWeights(const int Index, math_Vector& Points, math_Ve { math_ComputeKronrodPointsAndWeights PWcomputer((Index - 1) / 2); if (!PWcomputer.IsDone()) + { return false; + } Points = PWcomputer.Points(); Weights = PWcomputer.Weights(); return true; diff --git a/src/FoundationClasses/TKMath/math/math_KronrodSingleIntegration.cxx b/src/FoundationClasses/TKMath/math/math_KronrodSingleIntegration.cxx index 71c45c8ebe..d9bc65d85f 100644 --- a/src/FoundationClasses/TKMath/math/math_KronrodSingleIntegration.cxx +++ b/src/FoundationClasses/TKMath/math/math_KronrodSingleIntegration.cxx @@ -126,7 +126,9 @@ void math_KronrodSingleIntegration::Perform(math_Function& theFunction, myErrorReached); if (!myIsDone) + { return; + } // double anAbsVal = std::abs(myValue); @@ -184,20 +186,28 @@ void math_KronrodSingleIntegration::Perform(math_Function& theFunction, myErrorReached); if (!myIsDone) + { return; + } double anAbsVal = std::abs(myValue); myAbsolutError = myErrorReached; if (anAbsVal > aMinVol) + { myErrorReached /= anAbsVal; + } myNbIterReached++; if (myErrorReached <= theTolerance) + { return; + } if (myNbIterReached >= theMaxNbIter) + { return; + } NCollection_Sequence anIntervals; NCollection_Sequence anErrors; @@ -238,32 +248,46 @@ void math_KronrodSingleIntegration::Perform(math_Function& theFunction, myIsDone = GKRule(theFunction, a, c, aGaussP, aGaussW, aKronrodP, aKronrodW, v1, e1); if (!myIsDone) + { return; + } myIsDone = GKRule(theFunction, c, b, aGaussP, aGaussW, aKronrodP, aKronrodW, v2, e2); if (!myIsDone) + { return; + } myNbIterReached++; double deltav = v1 + v2 - aValues(nint); myValue += deltav; if (std::abs(deltav) <= Epsilon(std::abs(myValue))) + { ++count; + } double deltae = e1 + e2 - anErrors(nint); myAbsolutError += deltae; if (myAbsolutError <= Epsilon(std::abs(myValue))) + { ++count; + } if (std::abs(myValue) > aMinVol) + { myErrorReached = myAbsolutError / std::abs(myValue); + } else + { myErrorReached = myAbsolutError; + } if (count > 50) + { return; + } // Inserting new interval @@ -336,7 +360,9 @@ bool math_KronrodSingleIntegration::GKRule(math_Function& theFunction, theValue += aVal1 * theKronrodW.Value(aNPnt2); if (i == aNPnt2) + { aGaussVal += aVal1 * theGaussW.Value(aNPnt2 / 2); + } // Compute Kronrod quadrature for (i = 1; i < aNPnt2; i += 2) @@ -372,9 +398,13 @@ bool math_KronrodSingleIntegration::GKRule(math_Function& theFunction, double scale = 1.; if (asc != 0. && theError != 0.) + { scale = std::pow((200. * theError / asc), 1.5); + } if (scale < 1.) + { theError = std::min(theError, asc * scale); + } // theFunction.GetStateNumber(); diff --git a/src/FoundationClasses/TKMath/math/math_NewtonFunctionRoot.cxx b/src/FoundationClasses/TKMath/math/math_NewtonFunctionRoot.cxx index 78bed5e7ae..0c64d32a13 100644 --- a/src/FoundationClasses/TKMath/math/math_NewtonFunctionRoot.cxx +++ b/src/FoundationClasses/TKMath/math/math_NewtonFunctionRoot.cxx @@ -110,7 +110,9 @@ void math_NewtonFunctionRoot::Perform(math_FunctionWithDerivative& F, const doub double AbsFx = Fx; if (AbsFx < 0) + { AbsFx = -AbsFx; + } if (AbsFx < BestFx) { BestFx = AbsFx; @@ -130,9 +132,13 @@ void math_NewtonFunctionRoot::Perform(math_FunctionWithDerivative& F, const doub X -= Dx; // Limitation des variations de X: if (X <= AA) + { X = AA; + } if (X >= BB) + { X = BB; + } It++; } } diff --git a/src/FoundationClasses/TKMath/math/math_NewtonFunctionSetRoot.cxx b/src/FoundationClasses/TKMath/math/math_NewtonFunctionSetRoot.cxx index 580ab2c3b4..3029cc901c 100644 --- a/src/FoundationClasses/TKMath/math/math_NewtonFunctionSetRoot.cxx +++ b/src/FoundationClasses/TKMath/math/math_NewtonFunctionSetRoot.cxx @@ -77,7 +77,9 @@ math_NewtonFunctionSetRoot::~math_NewtonFunctionSetRoot() = default; void math_NewtonFunctionSetRoot::SetTolerance(const math_Vector& theXTolerance) { for (int i = 1; i <= TolX.Length(); ++i) + { TolX(i) = theXTolerance(i); + } } //================================================================================================= @@ -107,7 +109,9 @@ void math_NewtonFunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, Sol = StartingPoint; OK = F.Values(Sol, FValues, Jacobian); if (!OK) + { return; + } for (Iter = 1; Iter <= Itermax; Iter++) { for (int k = 1; k <= DeltaX.Length(); k++) @@ -116,7 +120,9 @@ void math_NewtonFunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, } Error = LU_Decompose(Jacobian, Indx, d, Scratch, 1.0e-30); if (Error) + { return; + } LU_Solve(Jacobian, Indx, DeltaX); for (int i = 1; i <= Sol.Length(); i++) { @@ -124,13 +130,19 @@ void math_NewtonFunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, // Limitation de Sol dans les bornes [InfBound, SupBound] : if (Sol(i) <= InfBound(i)) + { Sol(i) = InfBound(i); + } if (Sol(i) >= SupBound(i)) + { Sol(i) = SupBound(i); + } } OK = F.Values(Sol, FValues, Jacobian); if (!OK) + { return; + } if (IsSolutionReached(F)) { State = F.GetStateNumber(); diff --git a/src/FoundationClasses/TKMath/math/math_NewtonMinimum.cxx b/src/FoundationClasses/TKMath/math/math_NewtonMinimum.cxx index b386307135..343df5d108 100644 --- a/src/FoundationClasses/TKMath/math/math_NewtonMinimum.cxx +++ b/src/FoundationClasses/TKMath/math/math_NewtonMinimum.cxx @@ -129,7 +129,9 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F, { double Delta = CTol + 0.1 * std::abs(MinEigenValue) - MinEigenValue; for (ii = 1; ii <= TheGradient.Length(); ii++) + { TheHessian(ii, ii) += Delta; + } } else { @@ -160,7 +162,9 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F, { const double anAbsStep = std::abs(TheStep(anIdx)); if (anAbsStep < gp::Resolution()) + { continue; + } if (suivant->Value(anIdx) < myLeft(anIdx)) { @@ -245,7 +249,9 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F, TheMinimum = VItere; Ok = (nbiter < Itermax); if (!Ok && NbConv < 2) + { TheStatus = math_TooManyIterations; + } } else { @@ -261,12 +267,12 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F, void math_NewtonMinimum::Dump(Standard_OStream& o) const { o << "math_Newton Optimisation: "; - o << " Done =" << Done << std::endl; - o << " Status = " << (int)TheStatus << std::endl; - o << " Location Vector = " << Location() << std::endl; - o << " Minimum value = " << Minimum() << std::endl; - o << " Previous value = " << PreviousMinimum << std::endl; - o << " Number of iterations = " << NbIterations() << std::endl; - o << " Convexity = " << Convex << std::endl; - o << " Eigen Value = " << MinEigenValue << std::endl; + o << " Done =" << Done << '\n'; + o << " Status = " << (int)TheStatus << '\n'; + o << " Location Vector = " << Location() << '\n'; + o << " Minimum value = " << Minimum() << '\n'; + o << " Previous value = " << PreviousMinimum << '\n'; + o << " Number of iterations = " << NbIterations() << '\n'; + o << " Convexity = " << Convex << '\n'; + o << " Eigen Value = " << MinEigenValue << '\n'; } diff --git a/src/FoundationClasses/TKMath/math/math_PSO.cxx b/src/FoundationClasses/TKMath/math/math_PSO.cxx index e2f4964e23..20a49d4d4e 100644 --- a/src/FoundationClasses/TKMath/math/math_PSO.cxx +++ b/src/FoundationClasses/TKMath/math/math_PSO.cxx @@ -105,12 +105,16 @@ void math_PSO::Perform(const math_Vector& theSteps, aCurrPoint(aDimIdx + 1) += mySteps(aDimIdx + 1); } else + { break; + } } // Stop criteria. if (aCurrPoint(myN) > aMaxUV(myN)) + { isRegularGridFinished = true; + } } while (!isRegularGridFinished); performPSOWithGivenParticles(aPool, myNbParticles, theValue, theOutPnt, theNbIter); @@ -150,7 +154,9 @@ void math_PSO::performPSOWithGivenParticles(math_PSOParticlesPool& theParticles, aParticle = aParticles.GetBestParticle(); for (int aDimIdx = 0; aDimIdx < myN; ++aDimIdx) + { aBestGlobalPosition(aDimIdx + 1) = aParticle->Position[aDimIdx]; + } double aBestGlobalDistance = aParticle->Distance; // This velocity is used for detecting stagnation state. @@ -199,13 +205,17 @@ void math_PSO::performPSOWithGivenParticles(math_PSOParticlesPool& theParticles, { aParticle->BestDistance = aParticle->Distance; for (int aDimIdx = 0; aDimIdx < myN; ++aDimIdx) + { aParticle->BestPosition[aDimIdx] = aParticle->Position[aDimIdx]; + } if (aParticle->Distance < aBestGlobalDistance) { aBestGlobalDistance = aParticle->Distance; for (int aDimIdx = 0; aDimIdx < myN; ++aDimIdx) + { aBestGlobalPosition(aDimIdx + 1) = aParticle->Position[aDimIdx]; + } } } } diff --git a/src/FoundationClasses/TKMath/math/math_Powell.cxx b/src/FoundationClasses/TKMath/math/math_Powell.cxx index 1ff4970299..e938a5d5e0 100644 --- a/src/FoundationClasses/TKMath/math/math_Powell.cxx +++ b/src/FoundationClasses/TKMath/math/math_Powell.cxx @@ -159,7 +159,9 @@ void math_Powell::Perform(math_MultipleVarFunction& F, for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) + { xit(j) = TheDirections(j, i); + } F.Value(TheLocation, fptt); bool IsGood = MinimizeDirection(TheLocation, xit, TheMinimum, F_Dir); diff --git a/src/FoundationClasses/TKMath/math/math_Recipes.cxx b/src/FoundationClasses/TKMath/math/math_Recipes.cxx index cee52b5eb5..8cce2b72ba 100644 --- a/src/FoundationClasses/TKMath/math/math_Recipes.cxx +++ b/src/FoundationClasses/TKMath/math/math_Recipes.cxx @@ -68,8 +68,12 @@ static void EigenSort(math_Vector& d, math_Matrix& v) { p = d(k = i); for (j = i + 1; j <= n; j++) + { if (d(j) >= p) + { p = d(k = j); + } + } if (k != i) { d(k) = d(i); @@ -96,7 +100,9 @@ int Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, int& nrot) for (ip = 1; ip <= n; ip++) { for (iq = 1; iq <= n; iq++) + { v(ip, iq) = 0.0; + } v(ip, ip) = 1.0; } for (ip = 1; ip <= n; ip++) @@ -111,7 +117,9 @@ int Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, int& nrot) for (ip = 1; ip < n; ip++) { for (iq = ip + 1; iq <= n; iq++) + { sm += fabs(a(ip, iq)); + } } if (sm == 0.0) { @@ -132,18 +140,24 @@ int Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, int& nrot) { g = 100.0 * fabs(a(ip, iq)); if (i > 4 && fabs(d(ip)) + g == fabs(d(ip)) && fabs(d(iq)) + g == fabs(d(iq))) + { a(ip, iq) = 0.0; + } else if (fabs(a(ip, iq)) > tresh) { h = d(iq) - d(ip); if (fabs(h) + g == fabs(h)) + { t = a(ip, iq) / h; + } else { theta = 0.5 * h / a(ip, iq); t = 1.0 / (fabs(theta) + sqrt(1.0 + theta * theta)); if (theta < 0.0) + { t = -t; + } } c = 1.0 / sqrt(1 + t * t); s = t * c; @@ -205,8 +219,12 @@ int LU_Decompose(math_Matrix& a, { big = 0.0; for (j = 1; j <= n; j++) + { if ((temp = fabs(a(i, j))) > big) + { big = temp; + } + } if (big <= TINY) { return math_Status_SingularMatrix; @@ -220,7 +238,9 @@ int LU_Decompose(math_Matrix& a, { sum = a(i, j); for (k = 1; k < i; k++) + { sum -= a(i, k) * a(k, j); + } a(i, j) = sum; } big = 0.0; @@ -228,7 +248,9 @@ int LU_Decompose(math_Matrix& a, { sum = a(i, j); for (k = 1; k < j; k++) + { sum -= a(i, k) * a(k, j); + } a(i, j) = sum; // Note that comparison is made so as to have imax updated even if argument is NAN, Inf or // IND, see #25559 @@ -259,7 +281,9 @@ int LU_Decompose(math_Matrix& a, { dum = 1.0 / (a(j, j)); for (i = j + 1; i <= n; i++) + { a(i, j) *= dum; + } } } @@ -296,17 +320,25 @@ void LU_Solve(const math_Matrix& a, const math_IntegerVector& indx, math_Vector& sum = b(ip + nblow); b(ip + nblow) = b(i + nblow); if (ii) + { for (j = ii; j < i; j++) + { sum -= a(i, j) * b(j + nblow); + } + } else if (sum) + { ii = i; + } b(i + nblow) = sum; } for (i = n; i >= 1; i--) { sum = b(i + nblow); for (j = i + 1; j <= n; j++) + { sum -= a(i, j) * b(j + nblow); + } b(i + nblow) = sum / a(i, i); } } @@ -327,11 +359,15 @@ int LU_Invert(math_Matrix& a) for (j = 1; j <= n; j++) { for (i = 1; i <= n; i++) + { col(i) = 0.0; + } col(j) = 1.0; LU_Solve(a, indx, col); for (i = 1; i <= n; i++) + { inv(i, j) = col(i); + } } for (j = 1; j <= n; j++) { @@ -372,9 +408,13 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r { aki = a(k, i); if (aki > 0) + { scale += aki; + } else + { scale -= aki; + } } if (scale) { @@ -392,14 +432,20 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r for (j = l; j <= n; j++) { for (s = 0.0, k = i; k <= m; k++) + { s += a(k, i) * a(k, j); + } f = s / h; for (k = i; k <= m; k++) + { a(k, j) += f * a(k, i); + } } } for (k = i; k <= m; k++) + { a(k, i) *= scale; + } } } w(i) = scale * g; @@ -410,9 +456,13 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r { aik = a(i, k); if (aik > 0) + { scale += aik; + } else + { scale -= aik; + } } if (scale) { @@ -426,31 +476,47 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r h = f * g - s; a(i, l) = f - g; for (k = l; k <= n; k++) + { rv1(k) = a(i, k) / h; + } if (i != m) { for (j = l; j <= m; j++) { for (s = 0.0, k = l; k <= n; k++) + { s += a(j, k) * a(i, k); + } for (k = l; k <= n; k++) + { a(j, k) += s * rv1(k); + } } } for (k = l; k <= n; k++) + { a(i, k) *= scale; + } } } aw = w(i); if (aw < 0) + { aw = -aw; + } ar = rv1(i); if (ar > 0) + { ar = aw + ar; + } else + { ar = aw - ar; + } if (anorm < ar) + { anorm = ar; + } } for (i = n; i >= 1; i--) { @@ -459,17 +525,25 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r if (g) { for (j = l; j <= n; j++) + { v(j, i) = (a(i, j) / a(i, l)) / g; + } for (j = l; j <= n; j++) { for (s = 0.0, k = l; k <= n; k++) + { s += a(i, k) * v(k, j); + } for (k = l; k <= n; k++) + { v(k, j) += s * v(k, i); + } } } for (j = l; j <= n; j++) + { v(i, j) = v(j, i) = 0.0; + } } v(i, i) = 1.0; g = rv1(i); @@ -480,8 +554,12 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r l = i + 1; g = w(i); if (i < n) + { for (j = l; j <= n; j++) + { a(i, j) = 0.0; + } + } if (g) { g = 1.0 / g; @@ -490,19 +568,27 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r for (j = l; j <= n; j++) { for (s = 0.0, k = l; k <= m; k++) + { s += a(k, i) * a(k, j); + } f = (s / a(i, i)) * g; for (k = i; k <= m; k++) + { a(k, j) += f * a(k, i); + } } } for (j = i; j <= m; j++) + { a(j, i) *= g; + } } else { for (j = i; j <= m; j++) + { a(j, i) = 0.0; + } } ++a(i, i); } @@ -520,7 +606,9 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r break; } if (fabs(w(nm)) + anorm == anorm) + { break; + } } if (flag) { @@ -553,7 +641,9 @@ int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& r { w(k) = -z; for (j = 1; j <= n; j++) + { v(j, k) = (-v(j, k)); + } } break; } @@ -639,7 +729,9 @@ void SVD_Solve(const math_Matrix& u, if (w(j)) { for (i = 1; i <= m; i++) + { s += u(i, j) * b(i); + } s /= w(j); } tmp(j) = s; @@ -648,7 +740,9 @@ void SVD_Solve(const math_Matrix& u, { s = 0.0; for (jj = 1; jj <= n; jj++) + { s += v(j, jj) * tmp(jj); + } x(j) = s; } } @@ -670,7 +764,9 @@ int DACTCL_Decompose(math_Vector& a, const math_IntegerVector& indx, const doubl jh = jd - jr; is = j - jh + 2; if (jh - 2 == 0) + { diag = true; + } if (jh - 2 > 0) { ie = j - 1; @@ -685,7 +781,9 @@ int DACTCL_Decompose(math_Vector& a, const math_IntegerVector& indx, const doubl ih = id - ir - 1; mh = i - is + 1; if (ih > mh) + { ih = mh; + } if (ih > 0.0) { dot = 0.0; @@ -714,9 +812,13 @@ int DACTCL_Decompose(math_Vector& a, const math_IntegerVector& indx, const doubl id = indx(k + i); aa = a(id); if (aa < 0) + { aa = -aa; + } if (aa <= MinPivot) + { return math_Status_SingularMatrix; + } d = a(i); a(i) = d / a(id); a(jd) = a(jd) - d * a(i); @@ -767,9 +869,13 @@ int DACTCL_Solve(const math_Vector& a, id = indx(i); aa = a(id); if (aa < 0) + { aa = -aa; + } if (aa <= MinPivot) + { return math_Status_SingularMatrix; + } b(i) = b(i) / a(id); } diff --git a/src/FoundationClasses/TKMath/math/math_SVD.cxx b/src/FoundationClasses/TKMath/math/math_SVD.cxx index f57a009786..fe197dee40 100644 --- a/src/FoundationClasses/TKMath/math/math_SVD.cxx +++ b/src/FoundationClasses/TKMath/math/math_SVD.cxx @@ -50,7 +50,9 @@ void math_SVD::Solve(const math_Vector& B, math_Vector& X, const double Eps) for (int I = 1; I <= Diag.Upper(); I++) { if (Diag(I) < wmin) + { Diag(I) = 0.0; + } } // Handle custom bounds in X vector - SVD_Solve expects 1-based indexing @@ -75,7 +77,9 @@ void math_SVD::PseudoInverse(math_Matrix& Result, const double Eps) for (i = 1; i <= Diag.Upper(); i++) { if (Diag(i) < wmin) + { Diag(i) = 0.0; + } } int ColA = Diag.Length(); @@ -85,11 +89,15 @@ void math_SVD::PseudoInverse(math_Matrix& Result, const double Eps) for (j = 1; j <= RowA; j++) { for (i = 1; i <= VNorme.Upper(); i++) + { VNorme(i) = 0.0; + } VNorme(j) = 1.0; SVD_Solve(U, Diag, V, VNorme, Column); for (i = 1; i <= ColA; i++) + { Result(i, j) = Column(i); + } } } diff --git a/src/FoundationClasses/TKMath/math/math_TrigonometricFunctionRoots.cxx b/src/FoundationClasses/TKMath/math/math_TrigonometricFunctionRoots.cxx index 4d67eb0cea..a5de1e691b 100644 --- a/src/FoundationClasses/TKMath/math/math_TrigonometricFunctionRoots.cxx +++ b/src/FoundationClasses/TKMath/math/math_TrigonometricFunctionRoots.cxx @@ -282,9 +282,13 @@ void math_TrigonometricFunctionRoots::Perform(const double A, if ((X >= (-Precision::PConfusion())) && (X <= Delta + Precision::PConfusion())) { if (Zer(i) < InfBound) + { Zer(i) = InfBound; + } if (Zer(i) > SupBound) + { Zer(i) = SupBound; + } NbSol++; Sol(NbSol) = Zer(i); } @@ -334,9 +338,13 @@ void math_TrigonometricFunctionRoots::Perform(const double A, if ((X >= (-Precision::PConfusion())) && (X <= Delta + Precision::PConfusion())) { if (Zer(i) < InfBound) + { Zer(i) = InfBound; + } if (Zer(i) > SupBound) + { Zer(i) = SupBound; + } NbSol++; Sol(NbSol) = Zer(i); } @@ -440,7 +448,9 @@ void math_TrigonometricFunctionRoots::Perform(const double A, } Teta += std::trunc(Mod) * Depi; if (Teta - MyBorneInf < 0) + { Teta += Depi; + } X = Teta - MyBorneInf; if ((X >= (-Epsilon(Delta))) && (X <= Delta + Epsilon(Delta))) diff --git a/src/FoundationClasses/TKMath/math/math_Uzawa.cxx b/src/FoundationClasses/TKMath/math/math_Uzawa.cxx index 3b919eee51..0bbf9589fa 100644 --- a/src/FoundationClasses/TKMath/math/math_Uzawa.cxx +++ b/src/FoundationClasses/TKMath/math/math_Uzawa.cxx @@ -275,8 +275,8 @@ void math_Uzawa::Dump(Standard_OStream& o) const if (Done) { o << " Status = Done \n"; - o << " Number of iterations = " << NbIter << std::endl; - o << " The solution vector is: " << Resul << std::endl; + o << " Number of iterations = " << NbIter << '\n'; + o << " The solution vector is: " << Resul << '\n'; } else { diff --git a/src/FoundationClasses/TKernel/FSD/FSD_BinaryFile.cxx b/src/FoundationClasses/TKernel/FSD/FSD_BinaryFile.cxx index 0cd0061925..fceb273979 100644 --- a/src/FoundationClasses/TKernel/FSD/FSD_BinaryFile.cxx +++ b/src/FoundationClasses/TKernel/FSD/FSD_BinaryFile.cxx @@ -197,7 +197,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutReference(const int aValue) throw Storage_StreamWriteError(); #else if (!fwrite(&aValue, sizeof(int), 1, myStream)) + { throw Storage_StreamWriteError(); + } #endif return *this; } @@ -207,7 +209,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutReference(const int aValue) Storage_BaseDriver& FSD_BinaryFile::PutCharacter(const char aValue) { if (!fwrite(&aValue, sizeof(char), 1, myStream)) + { throw Storage_StreamWriteError(); + } return *this; } @@ -222,7 +226,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutExtCharacter(const char16_t aValue) throw Storage_StreamWriteError(); #else if (!fwrite(&aValue, sizeof(char16_t), 1, myStream)) + { throw Storage_StreamWriteError(); + } #endif return *this; } @@ -238,7 +244,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutInteger(const int aValue) throw Storage_StreamWriteError(); #else if (!fwrite(&aValue, sizeof(int), 1, myStream)) + { throw Storage_StreamWriteError(); + } #endif return *this; @@ -278,7 +286,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutBoolean(const bool aValue) int t = aValue ? 1 : 0; #endif if (!fwrite(&t, sizeof(int), 1, myStream)) + { throw Storage_StreamWriteError(); + } return *this; } @@ -293,7 +303,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutReal(const double aValue) throw Storage_StreamWriteError(); #else if (!fwrite(&aValue, sizeof(double), 1, myStream)) + { throw Storage_StreamWriteError(); + } #endif return *this; } @@ -309,7 +321,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutShortReal(const float aValue) throw Storage_StreamWriteError(); #else if (!fwrite(&aValue, sizeof(float), 1, myStream)) + { throw Storage_StreamWriteError(); + } #endif return *this; } @@ -322,7 +336,9 @@ Storage_BaseDriver& FSD_BinaryFile::PutShortReal(const float aValue) Storage_BaseDriver& FSD_BinaryFile::GetReference(int& aValue) { if (!fread(&aValue, sizeof(int), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE aValue = InverseInt(aValue); #endif @@ -352,7 +368,9 @@ void FSD_BinaryFile::GetReference(Standard_IStream& theIStream, int& aValue) Storage_BaseDriver& FSD_BinaryFile::GetCharacter(char& aValue) { if (!fread(&aValue, sizeof(char), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } return *this; } @@ -361,7 +379,9 @@ Storage_BaseDriver& FSD_BinaryFile::GetCharacter(char& aValue) Storage_BaseDriver& FSD_BinaryFile::GetExtCharacter(char16_t& aValue) { if (!fread(&aValue, sizeof(char16_t), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE aValue = InverseExtChar(aValue); #endif @@ -373,7 +393,9 @@ Storage_BaseDriver& FSD_BinaryFile::GetExtCharacter(char16_t& aValue) Storage_BaseDriver& FSD_BinaryFile::GetInteger(int& aValue) { if (!fread(&aValue, sizeof(int), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE aValue = InverseInt(aValue); #endif @@ -403,7 +425,9 @@ Storage_BaseDriver& FSD_BinaryFile::GetBoolean(bool& aValue) { int anInt = 0; if (!fread(&anInt, sizeof(int), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE anInt = InverseInt(anInt); #endif @@ -416,7 +440,9 @@ Storage_BaseDriver& FSD_BinaryFile::GetBoolean(bool& aValue) Storage_BaseDriver& FSD_BinaryFile::GetReal(double& aValue) { if (!fread(&aValue, sizeof(double), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE aValue = InverseReal(aValue); #endif @@ -428,7 +454,9 @@ Storage_BaseDriver& FSD_BinaryFile::GetReal(double& aValue) Storage_BaseDriver& FSD_BinaryFile::GetShortReal(float& aValue) { if (!fread(&aValue, sizeof(float), 1, myStream)) + { throw Storage_StreamTypeMismatchError(); + } #if OCCT_BINARY_FILE_DO_INVERSE aValue = InverseShortReal(aValue); #endif @@ -465,7 +493,9 @@ Storage_Error FSD_BinaryFile::BeginWriteInfoSection() myHeader.testindian = aWrapUnion.aResult; if (!fwrite(FSD_BinaryFile::MagicNumber(), strlen(FSD_BinaryFile::MagicNumber()), 1, myStream)) + { throw Storage_StreamWriteError(); + } myHeader.binfo = (int)ftell(myStream); WriteHeader(); @@ -735,9 +765,13 @@ void FSD_BinaryFile::ReadCompleteInfo(Standard_IStream& theIStream, Storage_Error FSD_BinaryFile::EndReadInfoSection() { if (!fseek(myStream, myHeader.einfo, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -818,9 +852,13 @@ Storage_Error FSD_BinaryFile::EndWriteCommentSection(Standard_OStream& theOStrea Storage_Error FSD_BinaryFile::BeginReadCommentSection() { if (!fseek(myStream, myHeader.bcomment, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //================================================================================================= @@ -859,9 +897,13 @@ void FSD_BinaryFile::ReadComment(Standard_IStream& Storage_Error FSD_BinaryFile::EndReadCommentSection() { if (!fseek(myStream, myHeader.ecomment, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -907,9 +949,13 @@ Storage_Error FSD_BinaryFile::EndWriteTypeSection() Storage_Error FSD_BinaryFile::BeginReadTypeSection() { if (!fseek(myStream, myHeader.btype, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //================================================================================================= @@ -959,9 +1005,13 @@ void FSD_BinaryFile::ReadTypeInformations(Standard_IStream& theIStream, Storage_Error FSD_BinaryFile::EndReadTypeSection() { if (!fseek(myStream, myHeader.etype, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -1009,9 +1059,13 @@ Storage_Error FSD_BinaryFile::EndWriteRootSection() Storage_Error FSD_BinaryFile::BeginReadRootSection() { if (!fseek(myStream, myHeader.broot, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //================================================================================================= @@ -1066,9 +1120,13 @@ void FSD_BinaryFile::ReadRoot(Standard_IStream& theIStream, Storage_Error FSD_BinaryFile::EndReadRootSection() { if (!fseek(myStream, myHeader.eroot, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -1113,9 +1171,13 @@ Storage_Error FSD_BinaryFile::EndWriteRefSection() Storage_Error FSD_BinaryFile::BeginReadRefSection() { if (!fseek(myStream, myHeader.bref, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //================================================================================================= @@ -1163,9 +1225,13 @@ void FSD_BinaryFile::ReadReferenceType(Standard_IStream& theIStream, int& refere Storage_Error FSD_BinaryFile::EndReadRefSection() { if (!fseek(myStream, myHeader.eref, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -1222,9 +1288,13 @@ Storage_Error FSD_BinaryFile::EndWriteDataSection() Storage_Error FSD_BinaryFile::BeginReadDataSection() { if (!fseek(myStream, myHeader.bdata, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //================================================================================================= @@ -1256,9 +1326,13 @@ void FSD_BinaryFile::EndReadPersistentObjectData() {} Storage_Error FSD_BinaryFile::EndReadDataSection() { if (!fseek(myStream, myHeader.edata, SEEK_SET)) + { return Storage_VSOk; + } else + { return Storage_VSSectionNotFound; + } } //======================================================================= @@ -1277,7 +1351,9 @@ void FSD_BinaryFile::WriteString(const TCollection_AsciiString& aString) if (size > 0) { if (!fwrite(aString.ToCString(), aString.Length(), 1, myStream)) + { throw Storage_StreamWriteError(); + } } } @@ -1321,7 +1397,9 @@ void FSD_BinaryFile::ReadString(TCollection_AsciiString& aString) { char* c = (char*)Standard::Allocate((size + 1) * sizeof(char)); if (!fread(c, size, 1, myStream)) + { throw Storage_StreamWriteError(); + } c[size] = '\0'; aString = c; Standard::Free(c); @@ -1400,7 +1478,9 @@ void FSD_BinaryFile::WriteExtendedString(const TCollection_ExtendedString& aStri anExtStr = aString.ToExtString(); #endif if (!fwrite(anExtStr, sizeof(char16_t) * aString.Length(), 1, myStream)) + { throw Storage_StreamWriteError(); + } } } @@ -1461,7 +1541,9 @@ void FSD_BinaryFile::ReadExtendedString(TCollection_ExtendedString& aString) { char16_t* c = (char16_t*)Standard::Allocate((size + 1) * sizeof(char16_t)); if (!fread(c, size * sizeof(char16_t), 1, myStream)) + { throw Storage_StreamWriteError(); + } c[size] = '\0'; #if OCCT_BINARY_FILE_DO_INVERSE for (int i = 0; i < size; i++) diff --git a/src/FoundationClasses/TKernel/FSD/FSD_CmpFile.cxx b/src/FoundationClasses/TKernel/FSD/FSD_CmpFile.cxx index 305ac0424a..44d520c7cd 100644 --- a/src/FoundationClasses/TKernel/FSD/FSD_CmpFile.cxx +++ b/src/FoundationClasses/TKernel/FSD/FSD_CmpFile.cxx @@ -221,7 +221,9 @@ Storage_Error FSD_CmpFile::BeginWriteInfoSection() myStream << FSD_CmpFile::MagicNumber() << '\n'; myStream << "BEGIN_INFO_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -254,7 +256,9 @@ void FSD_CmpFile::WritePersistentObjectHeader(const int aRef, const int aType) { myStream << "\n#" << aRef << "%" << aType << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -262,7 +266,9 @@ void FSD_CmpFile::WritePersistentObjectHeader(const int aRef, const int aType) void FSD_CmpFile::BeginWritePersistentObjectData() { if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -270,7 +276,9 @@ void FSD_CmpFile::BeginWritePersistentObjectData() void FSD_CmpFile::BeginWriteObjectData() { if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -278,7 +286,9 @@ void FSD_CmpFile::BeginWriteObjectData() void FSD_CmpFile::EndWriteObjectData() { if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -286,7 +296,9 @@ void FSD_CmpFile::EndWriteObjectData() void FSD_CmpFile::EndWritePersistentObjectData() { if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -307,7 +319,9 @@ void FSD_CmpFile::ReadPersistentObjectHeader(int& aRef, int& aType) } if (!(myStream >> aRef)) + { throw Storage_StreamTypeMismatchError(); + } myStream.get(c); @@ -321,7 +335,9 @@ void FSD_CmpFile::ReadPersistentObjectHeader(int& aRef, int& aType) } if (!(myStream >> aType)) + { throw Storage_StreamTypeMismatchError(); + } // std::cout << "REF:" << aRef << " TYPE:"<< aType << std::endl; } diff --git a/src/FoundationClasses/TKernel/FSD/FSD_File.cxx b/src/FoundationClasses/TKernel/FSD/FSD_File.cxx index b91cac0d3e..204b989066 100644 --- a/src/FoundationClasses/TKernel/FSD/FSD_File.cxx +++ b/src/FoundationClasses/TKernel/FSD/FSD_File.cxx @@ -232,21 +232,31 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer) myStream.get(c); if (c == tg[count]) + { count++; + } else + { count = 0; + } if (count < SIZEOFNORMALEXTENDEDSECTION) { i = (char16_t)c; if (c == '\0') + { fin = true; + } i = (i << 8); myStream.get(c); if (c == tg[count]) + { count++; + } else + { count = 0; + } if (count < SIZEOFNORMALEXTENDEDSECTION) { if (c != '\n') @@ -313,7 +323,9 @@ void FSD_File::ReadString(TCollection_AsciiString& buffer) { isFirstTime = false; while (*bpos == '\n' || *bpos == ' ') + { bpos++; + } } // char c; // if (myStream.get(c) && c != '\n') { @@ -347,7 +359,9 @@ void FSD_File::ReadWord(TCollection_AsciiString& buffer) { myStream.get(c); if ((c != ' ') && (c != '\n')) + { IsEnd = true; + } } IsEnd = false; @@ -367,7 +381,9 @@ void FSD_File::ReadWord(TCollection_AsciiString& buffer) i++; myStream.get(c); if ((c == '\n') || (c == ' ')) + { IsEnd = true; + } } buffer += b; @@ -412,7 +428,9 @@ Storage_BaseDriver& FSD_File::PutReference(const int aValue) { myStream << aValue << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -425,7 +443,9 @@ Storage_BaseDriver& FSD_File::PutCharacter(const char aValue) i = aValue; myStream << i << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -435,7 +455,9 @@ Storage_BaseDriver& FSD_File::PutExtCharacter(const char16_t aValue) { myStream << (short)aValue << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -445,7 +467,9 @@ Storage_BaseDriver& FSD_File::PutInteger(const int aValue) { myStream << aValue << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -455,7 +479,9 @@ Storage_BaseDriver& FSD_File::PutBoolean(const bool aValue) { myStream << ((int)aValue) << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -465,7 +491,9 @@ Storage_BaseDriver& FSD_File::PutReal(const double aValue) { myStream << ((double)aValue) << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -475,7 +503,9 @@ Storage_BaseDriver& FSD_File::PutShortReal(const float aValue) { myStream << aValue << " "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return *this; } @@ -487,7 +517,9 @@ Storage_BaseDriver& FSD_File::PutShortReal(const float aValue) Storage_BaseDriver& FSD_File::GetReference(int& aValue) { if (!(myStream >> aValue)) + { throw Storage_StreamTypeMismatchError(); + } return *this; } @@ -503,7 +535,9 @@ Storage_BaseDriver& FSD_File::GetCharacter(char& aValue) // signes (-80 fait std::ios::badbit, mais la variable i est initialisee) // if (i == 0) + { throw Storage_StreamTypeMismatchError(); + } myStream.clear(std::ios::goodbit); // .clear(0) is not portable } aValue = (char)i; @@ -517,7 +551,9 @@ Storage_BaseDriver& FSD_File::GetExtCharacter(char16_t& aValue) { short aChar = 0; if (!(myStream >> aChar)) + { throw Storage_StreamTypeMismatchError(); + } aValue = aChar; return *this; } @@ -527,7 +563,9 @@ Storage_BaseDriver& FSD_File::GetExtCharacter(char16_t& aValue) Storage_BaseDriver& FSD_File::GetInteger(int& aValue) { if (!(myStream >> aValue)) + { throw Storage_StreamTypeMismatchError(); + } return *this; } @@ -537,7 +575,9 @@ Storage_BaseDriver& FSD_File::GetInteger(int& aValue) Storage_BaseDriver& FSD_File::GetBoolean(bool& aValue) { if (!(myStream >> aValue)) + { throw Storage_StreamTypeMismatchError(); + } return *this; } @@ -551,9 +591,13 @@ Storage_BaseDriver& FSD_File::GetReal(double& aValue) realbuffer[0] = '\0'; if (!(myStream >> realbuffer)) + { throw Storage_StreamTypeMismatchError(); + } if (!OSD::CStringToReal(realbuffer, aValue)) + { throw Storage_StreamTypeMismatchError(); + } return *this; #else @@ -574,9 +618,13 @@ Storage_BaseDriver& FSD_File::GetShortReal(float& aValue) realbuffer[0] = '\0'; if (!(myStream >> realbuffer)) + { throw Storage_StreamTypeMismatchError(); + } if (!OSD::CStringToReal(realbuffer, r)) + { throw Storage_StreamTypeMismatchError(); + } aValue = (float)r; @@ -608,7 +656,9 @@ Storage_Error FSD_File::BeginWriteInfoSection() myStream << FSD_File::MagicNumber() << '\n'; myStream << "BEGIN_INFO_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -639,13 +689,17 @@ void FSD_File::WriteInfo(const int nb myStream << userInfo.Length() << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } for (i = 1; i <= userInfo.Length(); i++) { myStream << userInfo.Value(i).ToCString() << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } } @@ -655,7 +709,9 @@ Storage_Error FSD_File::EndWriteInfoSection() { myStream << "END_INFO_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -697,7 +753,9 @@ void FSD_File::ReadInfo(int& nbObj, NCollection_Sequence& userInfo) { if (!(myStream >> nbObj)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); @@ -712,7 +770,9 @@ void FSD_File::ReadInfo(int& nbObj, int i, len = 0; if (!(myStream >> len)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); @@ -753,7 +813,9 @@ Storage_Error FSD_File::BeginWriteCommentSection() { myStream << "BEGIN_COMMENT_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -766,13 +828,17 @@ void FSD_File::WriteComment(const NCollection_Sequence& aCo int len, i; if (!(myStream >> len)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); @@ -832,7 +902,9 @@ Storage_Error FSD_File::BeginWriteTypeSection() { myStream << "BEGIN_TYPE_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -842,7 +914,9 @@ void FSD_File::SetTypeSectionSize(const int aSize) { myStream << aSize << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -851,7 +925,9 @@ void FSD_File::WriteTypeInformations(const int typeNum, const TCollection_AsciiS { myStream << typeNum << " " << typeName.ToCString() << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -860,7 +936,9 @@ Storage_Error FSD_File::EndWriteTypeSection() { myStream << "END_TYPE_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -881,7 +959,9 @@ int FSD_File::TypeSectionSize() int i; if (!(myStream >> i)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); @@ -893,9 +973,13 @@ int FSD_File::TypeSectionSize() void FSD_File::ReadTypeInformations(int& typeNum, TCollection_AsciiString& typeName) { if (!(myStream >> typeNum)) + { throw Storage_StreamTypeMismatchError(); + } if (!(myStream >> typeName)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); } @@ -919,7 +1003,9 @@ Storage_Error FSD_File::BeginWriteRootSection() { myStream << "BEGIN_ROOT_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -929,7 +1015,9 @@ void FSD_File::SetRootSectionSize(const int aSize) { myStream << aSize << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -940,7 +1028,9 @@ void FSD_File::WriteRoot(const TCollection_AsciiString& rootName, { myStream << aRef << " " << rootName.ToCString() << " " << rootType.ToCString() << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -949,7 +1039,9 @@ Storage_Error FSD_File::EndWriteRootSection() { myStream << "END_ROOT_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -970,7 +1062,9 @@ int FSD_File::RootSectionSize() int i; if (!(myStream >> i)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); @@ -984,7 +1078,9 @@ void FSD_File::ReadRoot(TCollection_AsciiString& rootName, TCollection_AsciiString& rootType) { if (!(myStream >> aRef)) + { throw Storage_StreamTypeMismatchError(); + } ReadWord(rootName); ReadWord(rootType); } @@ -1009,7 +1105,9 @@ Storage_Error FSD_File::BeginWriteRefSection() { myStream << "BEGIN_REF_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -1019,7 +1117,9 @@ void FSD_File::SetRefSectionSize(const int aSize) { myStream << aSize << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1028,7 +1128,9 @@ void FSD_File::WriteReferenceType(const int reference, const int typeNum) { myStream << reference << " " << typeNum << "\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1037,7 +1139,9 @@ Storage_Error FSD_File::EndWriteRefSection() { myStream << "END_REF_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -1058,7 +1162,9 @@ int FSD_File::RefSectionSize() int i; if (!(myStream >> i)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); return i; @@ -1069,9 +1175,13 @@ int FSD_File::RefSectionSize() void FSD_File::ReadReferenceType(int& reference, int& typeNum) { if (!(myStream >> reference)) + { throw Storage_StreamTypeMismatchError(); + } if (!(myStream >> typeNum)) + { throw Storage_StreamTypeMismatchError(); + } FlushEndOfLine(); } @@ -1095,7 +1205,9 @@ Storage_Error FSD_File::BeginWriteDataSection() { myStream << "BEGIN_DATA_SECTION"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -1105,7 +1217,9 @@ void FSD_File::WritePersistentObjectHeader(const int aRef, const int aType) { myStream << "\n#" << aRef << "=%" << aType; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1114,7 +1228,9 @@ void FSD_File::BeginWritePersistentObjectData() { myStream << "( "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1123,7 +1239,9 @@ void FSD_File::BeginWriteObjectData() { myStream << "( "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1132,7 +1250,9 @@ void FSD_File::EndWriteObjectData() { myStream << ") "; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1141,7 +1261,9 @@ void FSD_File::EndWritePersistentObjectData() { myStream << ")"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } } //================================================================================================= @@ -1150,7 +1272,9 @@ Storage_Error FSD_File::EndWriteDataSection() { myStream << "\nEND_DATA_SECTION\n"; if (myStream.bad()) + { throw Storage_StreamWriteError(); + } return Storage_VSOk; } @@ -1182,7 +1306,9 @@ void FSD_File::ReadPersistentObjectHeader(int& aRef, int& aType) } if (!(myStream >> aRef)) + { throw Storage_StreamTypeMismatchError(); + } myStream.get(c); @@ -1207,7 +1333,9 @@ void FSD_File::ReadPersistentObjectHeader(int& aRef, int& aType) } if (!(myStream >> aType)) + { throw Storage_StreamTypeMismatchError(); + } // std::cout << "REF:" << aRef << " TYPE:"<< aType << std::endl; } @@ -1317,9 +1445,13 @@ Storage_Position FSD_File::Tell() Storage_Position aPosR = (Storage_Position)myStream.tellp(); Storage_Position aPosW = (Storage_Position)myStream.tellg(); if (aPosR < aPosW) + { return aPosW; + } else + { return aPosR; + } } default: return -1; diff --git a/src/FoundationClasses/TKernel/GTests/FSD_BinaryFile_Test.cxx b/src/FoundationClasses/TKernel/GTests/FSD_BinaryFile_Test.cxx index 1ca74097e1..2706f100d9 100644 --- a/src/FoundationClasses/TKernel/GTests/FSD_BinaryFile_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/FSD_BinaryFile_Test.cxx @@ -62,7 +62,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseInt_Sequential) int anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]); + } EXPECT_EQ(0, memcmp(anInv, anIntRef, sizeof(anIntRef))); } @@ -77,7 +79,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseInt_Random) int anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aRndIntRef, sizeof(aRndIntRef))); } @@ -94,7 +98,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseReal_Sequential) double anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aRealRef, sizeof(aRealRef))); } @@ -111,7 +117,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseReal_Random) double anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aRndRealRef, sizeof(aRndRealRef))); } @@ -126,7 +134,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseShortReal_Sequential) float anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aShortRealRef, sizeof(aShortRealRef))); } @@ -142,7 +152,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseShortReal_Random) float anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef))); } @@ -154,7 +166,9 @@ TEST(FSD_BinaryFileTest, OCC24537_InverseSize_Sequential) size_t anInv[10]; for (int i = 0; i < 10; ++i) + { anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]); + } EXPECT_EQ(0, memcmp(anInv, aSizeRef, sizeof(size_t) * 10)); } diff --git a/src/FoundationClasses/TKernel/GTests/Message_Messenger_Test.cxx b/src/FoundationClasses/TKernel/GTests/Message_Messenger_Test.cxx index 3d2168d0f9..57eae87b4a 100644 --- a/src/FoundationClasses/TKernel/GTests/Message_Messenger_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/Message_Messenger_Test.cxx @@ -69,7 +69,8 @@ TEST(Message_Messenger_Test, OCC31189_StreamBufferMessageOrdering) // Check that messages output to sender and directly to messenger do not intermix aSender << "Sender message 1: start ..."; aMsgMgr->Send("Direct message 1"); - aSender << "... end" << std::endl; // endl should send the message + aSender << "... end"; + aSender.Flush(true); // Check that empty stream buffer does not produce output on destruction ::Message::SendInfo(); @@ -77,8 +78,9 @@ TEST(Message_Messenger_Test, OCC31189_StreamBufferMessageOrdering) // Additional message to check that they go in expected order aMsgMgr->Send("Direct message 2"); - // Check that empty stream buffer does produce empty line if std::endl is passed - ::Message::SendInfo() << std::endl; + // Check that empty stream buffer does produce empty line if explicit flush is requested + Message_Messenger::StreamBuffer anEmptySender = ::Message::SendInfo(); + anEmptySender.Flush(true); // Last message should be sent on destruction of a sender aSender << "Sender message 2"; @@ -131,7 +133,7 @@ TEST(Message_Messenger_Test, StreamBufferBasicUsage) aMsgMgr->AddPrinter(aPrinter); { Message_Messenger::StreamBuffer aBuffer = Message::SendInfo(); - aBuffer << "Test message" << std::endl; + aBuffer << "Test message" << '\n'; } aMsgMgr->ChangePrinters().Clear(); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_CellFilter_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_CellFilter_Test.cxx index f31b280865..c401865d32 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_CellFilter_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_CellFilter_Test.cxx @@ -58,7 +58,9 @@ public: NCollection_CellFilter_Action Inspect(const Target& theTarget) { if (theTarget == myPurgeValue) + { return CellFilter_Purge; + } myFound.push_back(theTarget); return CellFilter_Keep; } diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_DoubleMap_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_DoubleMap_Test.cxx index b960aa9ed1..97bbe9ce24 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_DoubleMap_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_DoubleMap_Test.cxx @@ -374,11 +374,17 @@ TEST(NCollection_DoubleMapTest, Iterator) const Key2Type& key2 = it.Key2(); if (key1 == 10 && key2 == 1.0) + { found10 = true; + } else if (key1 == 20 && key2 == 2.0) + { found20 = true; + } else if (key1 == 30 && key2 == 3.0) + { found30 = true; + } } EXPECT_EQ(count, 3); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_IndexedDataMap_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_IndexedDataMap_Test.cxx index 2a22bf1c77..bc87df3562 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_IndexedDataMap_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_IndexedDataMap_Test.cxx @@ -490,11 +490,17 @@ TEST(NCollection_IndexedDataMapTest, Iterator) const ItemType& value = it.Value(); if (key == 10 && value == 1.0) + { found10 = true; + } else if (key == 20 && value == 2.0) + { found20 = true; + } else if (key == 30 && value == 3.0) + { found30 = true; + } } EXPECT_EQ(count, 3); @@ -531,11 +537,17 @@ TEST(NCollection_IndexedDataMapTest, StlIterator) for (auto it = aMap.begin(); it != aMap.end(); ++it, ++count) { if (*it == 1.0) + { found1 = true; + } else if (*it == 2.0) + { found2 = true; + } else if (*it == 3.0) + { found3 = true; + } } EXPECT_EQ(count, 3); @@ -552,11 +564,17 @@ TEST(NCollection_IndexedDataMapTest, StlIterator) for (auto it = aMap.cbegin(); it != aMap.cend(); ++it, ++count) { if (*it == 1.0) + { found1 = true; + } else if (*it == 2.0) + { found2 = true; + } else if (*it == 3.0) + { found3 = true; + } } EXPECT_EQ(count, 3); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_IndexedMap_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_IndexedMap_Test.cxx index a2801f33bb..a315de4732 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_IndexedMap_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_IndexedMap_Test.cxx @@ -354,11 +354,17 @@ TEST(NCollection_IndexedMapTest, Iterator) { const KeyType& key = it.Value(); if (key == 10) + { found10 = true; + } else if (key == 20) + { found20 = true; + } else if (key == 30) + { found30 = true; + } } EXPECT_EQ(count, 3); @@ -385,11 +391,17 @@ TEST(NCollection_IndexedMapTest, StlIterator) for (auto it = aMap.cbegin(); it != aMap.cend(); ++it, ++count) { if (*it == 10) + { found10 = true; + } else if (*it == 20) + { found20 = true; + } else if (*it == 30) + { found30 = true; + } } EXPECT_EQ(count, 3); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_KDTree_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_KDTree_Test.cxx index 3b49770369..65ce3aba35 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_KDTree_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_KDTree_Test.cxx @@ -362,9 +362,15 @@ TEST(NCollection_KDTreeTest, NearestPoint3D_GridPoints) TestPoint3D aPoints[27]; int k = 0; for (int i = 0; i < 3; ++i) + { for (int j = 0; j < 3; ++j) + { for (int l = 0; l < 3; ++l) + { aPoints[k++] = {static_cast(i), static_cast(j), static_cast(l)}; + } + } + } NCollection_KDTree aTree; aTree.Build(aPoints, 27); TestPoint3D aQuery(1.1, 2.2, 0.9); @@ -1264,7 +1270,9 @@ TEST(NCollection_KDTreeTest, NearestPoint2D_ThinStrip) { const double aDist = sqDist2D({15, 0}, aPoints[i]); if (aDist < aBfBest) + { aBfBest = aDist; + } } EXPECT_NEAR(aSqDist, aBfBest, 1e-10); } @@ -1351,11 +1359,17 @@ TEST(NCollection_KDTreeTest, NearestPoint3D_LargeGrid) TestPoint3D aPoints[THE_N]; int k = 0; for (int i = 0; i < 5; ++i) + { for (int j = 0; j < 5; ++j) + { for (int l = 0; l < 5; ++l) + { aPoints[k++] = {static_cast(i * 2), static_cast(j * 2), static_cast(l * 2)}; + } + } + } NCollection_KDTree aTree; aTree.Build(aPoints, THE_N); const size_t aIdx = aTree.NearestPoint({3.1, 5.1, 7.1}); @@ -1577,8 +1591,12 @@ TEST(NCollection_KDTreeTest, RangeSearch2D_OffCenter) TestPoint2D aPoints[THE_N]; int k = 0; for (int i = 0; i < 5; ++i) + { for (int j = 0; j < 5; ++j) + { aPoints[k++] = {static_cast(i), static_cast(j)}; + } + } NCollection_KDTree aTree; aTree.Build(aPoints, THE_N); // Search radius 0.6 around (2, 2) should find only (2,2) @@ -2037,8 +2055,12 @@ TEST(NCollection_KDTreeTest, Degenerate_GridAlignedToAxes) TestPoint2D aPoints[THE_N]; int k = 0; for (int i = 0; i < 10; ++i) + { for (int j = 0; j < 10; ++j) + { aPoints[k++] = {static_cast(i), static_cast(j)}; + } + } NCollection_KDTree aTree; aTree.Build(aPoints, THE_N); // Verify nearest for several queries @@ -2559,7 +2581,9 @@ TEST(NCollection_KDTreeTest, BruteForce_AllQueries_500Points) { const double aDist = sqDist2D(aQuery, aPoints[i]); if (aDist < aBfBest) + { aBfBest = aDist; + } } EXPECT_NEAR(aKdSqDist, aBfBest, 1e-10) << "Nearest q=" << q; } @@ -2571,7 +2595,9 @@ TEST(NCollection_KDTreeTest, BruteForce_AllQueries_500Points) aTree.KNearestPoints(aQuery, K, anIndices, aDists); std::vector aBfDists(THE_N); for (int i = 0; i < THE_N; ++i) + { aBfDists[i] = sqDist2D(aQuery, aPoints[i]); + } std::sort(aBfDists.begin(), aBfDists.end()); EXPECT_NEAR(aDists.Value(static_cast(K)), aBfDists[K - 1], 1e-10) << "KNN q=" << q; } @@ -2584,7 +2610,9 @@ TEST(NCollection_KDTreeTest, BruteForce_AllQueries_500Points) for (int i = 0; i < THE_N; ++i) { if (sqDist2D(aQuery, aPoints[i]) <= aRadiusSq) + { ++aBfCount; + } } EXPECT_EQ(aKdResult.Size(), aBfCount) << "Range q=" << q; } @@ -2599,7 +2627,9 @@ TEST(NCollection_KDTreeTest, BruteForce_AllQueries_500Points) { if (aPoints[i].X >= aMin.X && aPoints[i].X <= aMax.X && aPoints[i].Y >= aMin.Y && aPoints[i].Y <= aMax.Y) + { ++aBfCount; + } } EXPECT_EQ(aKdResult.Size(), aBfCount) << "Box q=" << q; } diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_LocalArray_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_LocalArray_Test.cxx index 8e00cabea8..8b02613165 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_LocalArray_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_LocalArray_Test.cxx @@ -198,14 +198,18 @@ TEST(NCollection_LocalArrayTest, ReallocateStackToStack_WithCopy) { NCollection_LocalArray anArray(10); for (size_t i = 0; i < 10; ++i) + { anArray[i] = static_cast(i * 100); + } anArray.Reallocate(32, true); EXPECT_EQ(32u, anArray.Size()); // Original elements should be preserved for (size_t i = 0; i < 10; ++i) + { EXPECT_EQ(static_cast(i * 100), anArray[i]); + } } // Test Reallocate with copy (stack to heap) @@ -213,7 +217,9 @@ TEST(NCollection_LocalArrayTest, ReallocateStackToHeap_WithCopy) { NCollection_LocalArray anArray(8); for (size_t i = 0; i < 8; ++i) + { anArray[i] = static_cast(i + 1); + } // Force heap allocation anArray.Reallocate(16, true); @@ -221,7 +227,9 @@ TEST(NCollection_LocalArrayTest, ReallocateStackToHeap_WithCopy) // Original elements should be preserved for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i + 1), anArray[i]); + } } // Test Reallocate with copy (heap to larger heap) @@ -229,13 +237,17 @@ TEST(NCollection_LocalArrayTest, ReallocateHeapToHeap_WithCopy) { NCollection_LocalArray anArray(8); // starts on heap for (size_t i = 0; i < 8; ++i) + { anArray[i] = static_cast(i * 10); + } anArray.Reallocate(16, true); EXPECT_EQ(16u, anArray.Size()); for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i * 10), anArray[i]); + } } // Test Reallocate without copy @@ -243,7 +255,9 @@ TEST(NCollection_LocalArrayTest, ReallocateNoCopy) { NCollection_LocalArray anArray(8); for (size_t i = 0; i < 8; ++i) + { anArray[i] = static_cast(i + 1); + } anArray.Reallocate(16, false); EXPECT_EQ(16u, anArray.Size()); @@ -255,14 +269,18 @@ TEST(NCollection_LocalArrayTest, ReallocateShrink) { NCollection_LocalArray anArray(16); // starts on heap for (size_t i = 0; i < 16; ++i) + { anArray[i] = static_cast(i * 5); + } // Shrink - should only update logical size, data preserved anArray.Reallocate(4, true); EXPECT_EQ(4u, anArray.Size()); for (size_t i = 0; i < 4; ++i) + { EXPECT_EQ(static_cast(i * 5), anArray[i]); + } } // Test move constructor from stack-allocated source @@ -270,14 +288,18 @@ TEST(NCollection_LocalArrayTest, MoveConstructor_FromStack) { NCollection_LocalArray aSrc(10); for (size_t i = 0; i < 10; ++i) + { aSrc[i] = static_cast(i * 7); + } NCollection_LocalArray aDst(std::move(aSrc)); // Destination has the data EXPECT_EQ(10u, aDst.Size()); for (size_t i = 0; i < 10; ++i) + { EXPECT_EQ(static_cast(i * 7), aDst[i]); + } // Source is empty EXPECT_EQ(0u, aSrc.Size()); @@ -288,14 +310,18 @@ TEST(NCollection_LocalArrayTest, MoveConstructor_FromHeap) { NCollection_LocalArray aSrc(16); // exceeds stack buffer, goes to heap for (size_t i = 0; i < 16; ++i) + { aSrc[i] = static_cast(i * 3); + } NCollection_LocalArray aDst(std::move(aSrc)); // Destination has the data EXPECT_EQ(16u, aDst.Size()); for (size_t i = 0; i < 16; ++i) + { EXPECT_EQ(static_cast(i * 3), aDst[i]); + } // Source is empty EXPECT_EQ(0u, aSrc.Size()); @@ -306,17 +332,23 @@ TEST(NCollection_LocalArrayTest, MoveAssignment) { NCollection_LocalArray aSrc(8); for (size_t i = 0; i < 8; ++i) + { aSrc[i] = static_cast(i + 100); + } NCollection_LocalArray aDst(4); for (size_t i = 0; i < 4; ++i) + { aDst[i] = -1; + } aDst = std::move(aSrc); EXPECT_EQ(8u, aDst.Size()); for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i + 100), aDst[i]); + } EXPECT_EQ(0u, aSrc.Size()); } @@ -331,7 +363,9 @@ TEST(NCollection_LocalArrayTest, ReallocateAsGrowableStack) for (int i = 0; i < 20; ++i) { if (aTop >= static_cast(aStack.Size())) + { aStack.Reallocate(aStack.Size() * 2, true); + } aStack[aTop++] = i * 3; } @@ -419,10 +453,14 @@ TEST(NCollection_LocalArrayTest, NonTrivial_HeapAllocation) EXPECT_EQ(8u, anArr.Size()); for (size_t i = 0; i < 8; ++i) + { anArr[i].Value = static_cast(i * 100); + } for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i * 100), anArr[i].Value); + } } EXPECT_EQ(THE_CTOR_COUNT + THE_MOVE_COUNT, THE_DTOR_COUNT); } @@ -431,40 +469,52 @@ TEST(NCollection_LocalArrayTest, NonTrivial_ReallocateWithCopy_InlineToInline) { NCollection_LocalArray anArr(4); for (size_t i = 0; i < 4; ++i) + { anArr[i].Value = static_cast(i + 1); + } anArr.Reallocate(8, true); EXPECT_EQ(8u, anArr.Size()); // Original elements preserved. for (size_t i = 0; i < 4; ++i) + { EXPECT_EQ(static_cast(i + 1), anArr[i].Value); + } } TEST(NCollection_LocalArrayTest, NonTrivial_ReallocateWithCopy_InlineToHeap) { NCollection_LocalArray anArr(4); for (size_t i = 0; i < 4; ++i) + { anArr[i].Value = static_cast(i * 10); + } anArr.Reallocate(16, true); EXPECT_EQ(16u, anArr.Size()); for (size_t i = 0; i < 4; ++i) + { EXPECT_EQ(static_cast(i * 10), anArr[i].Value); + } } TEST(NCollection_LocalArrayTest, NonTrivial_ReallocateWithCopy_HeapToHeap) { NCollection_LocalArray anArr(8); for (size_t i = 0; i < 8; ++i) + { anArr[i].Value = static_cast(i * 5); + } anArr.Reallocate(16, true); EXPECT_EQ(16u, anArr.Size()); for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i * 5), anArr[i].Value); + } } TEST(NCollection_LocalArrayTest, NonTrivial_Shrink_DestroysExcess) @@ -487,13 +537,17 @@ TEST(NCollection_LocalArrayTest, NonTrivial_MoveConstructor_FromInline) { NCollection_LocalArray aSrc(4); for (size_t i = 0; i < 4; ++i) + { aSrc[i].Value = static_cast(i * 7); + } NCollection_LocalArray aDst(std::move(aSrc)); EXPECT_EQ(4u, aDst.Size()); for (size_t i = 0; i < 4; ++i) + { EXPECT_EQ(static_cast(i * 7), aDst[i].Value); + } EXPECT_EQ(0u, aSrc.Size()); } @@ -502,13 +556,17 @@ TEST(NCollection_LocalArrayTest, NonTrivial_MoveConstructor_FromHeap) { NCollection_LocalArray aSrc(8); for (size_t i = 0; i < 8; ++i) + { aSrc[i].Value = static_cast(i * 3); + } NCollection_LocalArray aDst(std::move(aSrc)); EXPECT_EQ(8u, aDst.Size()); for (size_t i = 0; i < 8; ++i) + { EXPECT_EQ(static_cast(i * 3), aDst[i].Value); + } EXPECT_EQ(0u, aSrc.Size()); } @@ -517,14 +575,18 @@ TEST(NCollection_LocalArrayTest, NonTrivial_MoveAssignment) { NCollection_LocalArray aSrc(4); for (size_t i = 0; i < 4; ++i) + { aSrc[i].Value = static_cast(i + 100); + } NCollection_LocalArray aDst(2); aDst = std::move(aSrc); EXPECT_EQ(4u, aDst.Size()); for (size_t i = 0; i < 4; ++i) + { EXPECT_EQ(static_cast(i + 100), aDst[i].Value); + } EXPECT_EQ(0u, aSrc.Size()); } diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_SparseArray_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_SparseArray_Test.cxx index e7c448dcf3..9f45de23c1 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_SparseArray_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_SparseArray_Test.cxx @@ -151,13 +151,21 @@ TEST(NCollection_SparseArrayTest, IteratorFunctions) ItemType value = anIt.Value(); if (index == 5 && value == 50) + { found5 = true; + } else if (index == 10 && value == 100) + { found10 = true; + } else if (index == 20 && value == 200) + { found20 = true; + } else if (index == 30 && value == 300) + { found30 = true; + } } EXPECT_EQ(count, 4); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_UBTree_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_UBTree_Test.cxx index a0b33f72bc..d933529777 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_UBTree_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_UBTree_Test.cxx @@ -43,9 +43,13 @@ struct TestBnd1D void Add(const TestBnd1D& theOther) { if (theOther.Min < Min) + { Min = theOther.Min; + } if (theOther.Max > Max) + { Max = theOther.Max; + } } bool IsOut(const TestBnd1D& theOther) const { return theOther.Min > Max || theOther.Max < Min; } @@ -99,7 +103,9 @@ public: myResults.push_back(theObj); myAccepted++; if (myAccepted >= myMaxAccept) + { myStop = true; + } return true; } diff --git a/src/FoundationClasses/TKernel/GTests/OSD_Parallel_Test.cxx b/src/FoundationClasses/TKernel/GTests/OSD_Parallel_Test.cxx index 505d246cb2..65a63102e3 100644 --- a/src/FoundationClasses/TKernel/GTests/OSD_Parallel_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/OSD_Parallel_Test.cxx @@ -79,7 +79,9 @@ public: const int aLower = theBatchIndex * THE_BATCH_SIZE; const int anUpper = std::min(aLower + THE_BATCH_SIZE - 1, myX.Upper()); for (int i = aLower; i <= anUpper; ++i) + { myY(i) = myScalar * myX(i) + myY(i); + } } void operator()(int /*theThreadIndex*/, int theBatchIndex) const { (*this)(theBatchIndex); } @@ -119,7 +121,9 @@ public: { double aTmp = 0.0; for (int k = 0; k < mySize; ++k) + { aTmp += myMat1(theIndex, k) * myMat2(k, j); + } myResult(theIndex, j) = aTmp; } } @@ -147,47 +151,63 @@ TEST(OSD_ParallelTest, OCC24826_SaxpyParallelMatchesSequential) NCollection_Array1 aX(0, aLength - 1); NCollection_Array1 anYRef(0, aLength - 1); for (int i = 0; i < aLength; ++i) + { aX(i) = anYRef(i) = static_cast(i); + } // Sequential reference { const SaxpyFunctor aFunctor(aX, anYRef, 1e-6); for (int i = 0; i < aLength; ++i) + { aFunctor(i); + } } // OSD_Parallel::For { NCollection_Array1 anY = aX; for (int i = 0; i < aLength; ++i) + { anY(i) = static_cast(i); + } SaxpyFunctor aFunctor(aX, anY, 1e-6); OSD_Parallel::For(aFunctor.Begin(), aFunctor.End(), aFunctor); for (int i = 0; i < aLength; ++i) + { EXPECT_DOUBLE_EQ(anY(i), anYRef(i)) << "Mismatch at index " << i; + } } // OSD_ThreadPool::Launcher { NCollection_Array1 anY = aX; for (int i = 0; i < aLength; ++i) + { anY(i) = static_cast(i); + } SaxpyFunctor aFunctor(aX, anY, 1e-6); OSD_ThreadPool::Launcher aLauncher(*OSD_ThreadPool::DefaultPool()); aLauncher.Perform(aFunctor.Begin(), aFunctor.End(), aFunctor); for (int i = 0; i < aLength; ++i) + { EXPECT_DOUBLE_EQ(anY(i), anYRef(i)) << "Mismatch at index " << i; + } } // OSD_Parallel::For with batched functor { NCollection_Array1 anY = aX; for (int i = 0; i < aLength; ++i) + { anY(i) = static_cast(i); + } SaxpyBatchFunctor aFunctor(aX, anY, 1e-6); OSD_Parallel::For(aFunctor.Begin(), aFunctor.End(), aFunctor); for (int i = 0; i < aLength; ++i) + { EXPECT_DOUBLE_EQ(anY(i), anYRef(i)) << "Mismatch at index " << i; + } } } @@ -204,17 +224,21 @@ TEST(OSD_ParallelTest, OCC29935_MatrixMultiplyParallelMatchesSequential) NCollection_Array2 aMatRes(0, aSize - 1, 0, aSize - 1); for (int i = 0; i < aSize; ++i) + { for (int j = 0; j < aSize; ++j) { aMat1(i, j) = static_cast(aGen() % 1000); aMat2(i, j) = static_cast(aGen() % 1000); } + } // Sequential reference { MatMultFunctor aFunctor(aMat1, aMat2, aMatRef, aSize); for (int i = aFunctor.Begin(); i < aFunctor.End(); ++i) + { aFunctor(i); + } } // OSD_Parallel::For @@ -223,8 +247,12 @@ TEST(OSD_ParallelTest, OCC29935_MatrixMultiplyParallelMatchesSequential) MatMultFunctor aFunctor(aMat1, aMat2, aMatRes, aSize); OSD_Parallel::For(aFunctor.Begin(), aFunctor.End(), aFunctor); for (int i = 0; i < aSize; ++i) + { for (int j = 0; j < aSize; ++j) + { EXPECT_DOUBLE_EQ(aMatRes(i, j), aMatRef(i, j)); + } + } } // OSD_ThreadPool::Launcher @@ -234,7 +262,11 @@ TEST(OSD_ParallelTest, OCC29935_MatrixMultiplyParallelMatchesSequential) OSD_ThreadPool::Launcher aLauncher(*OSD_ThreadPool::DefaultPool()); aLauncher.Perform(aFunctor.Begin(), aFunctor.End(), aFunctor); for (int i = 0; i < aSize; ++i) + { for (int j = 0; j < aSize; ++j) + { EXPECT_DOUBLE_EQ(aMatRes(i, j), aMatRef(i, j)); + } + } } } diff --git a/src/FoundationClasses/TKernel/GTests/Standard_Atomic_Test.cxx b/src/FoundationClasses/TKernel/GTests/Standard_Atomic_Test.cxx index d23de34827..935c0b9b80 100644 --- a/src/FoundationClasses/TKernel/GTests/Standard_Atomic_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/Standard_Atomic_Test.cxx @@ -31,9 +31,13 @@ public: void operator()(const size_t) const { if (myPositive) + { ++(*myVal); + } else + { --(*myVal); + } } private: diff --git a/src/FoundationClasses/TKernel/Message/Message.cxx b/src/FoundationClasses/TKernel/Message/Message.cxx index c2bf99e080..b90625f48f 100644 --- a/src/FoundationClasses/TKernel/Message/Message.cxx +++ b/src/FoundationClasses/TKernel/Message/Message.cxx @@ -52,11 +52,17 @@ TCollection_AsciiString Message::FillTime(const int hour, const int minute, cons { char t[30]; if (hour > 0) + { Sprintf(t, "%02dh:%02dm:%.2fs", hour, minute, second); + } else if (minute > 0) + { Sprintf(t, "%02dm:%.2fs", minute, second); + } else + { Sprintf(t, "%.2fs", second); + } return TCollection_AsciiString(t); } diff --git a/src/FoundationClasses/TKernel/Message/Message_Algorithm.cxx b/src/FoundationClasses/TKernel/Message/Message_Algorithm.cxx index 11fae04592..1972efe195 100644 --- a/src/FoundationClasses/TKernel/Message/Message_Algorithm.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_Algorithm.cxx @@ -45,9 +45,13 @@ Message_Algorithm::Message_Algorithm() void Message_Algorithm::SetMessenger(const occ::handle& theMsgr) { if (theMsgr.IsNull()) + { myMessenger = Message::DefaultMessenger(); + } else + { myMessenger = theMsgr; + } } //================================================================================================= @@ -67,16 +71,22 @@ void Message_Algorithm::SetStatus(const Message_Status& theStat, const int theIn // Find index of bit corresponding to that flag int aFlagIndex = Message_ExecStatus::StatusIndex(theStat); if (!aFlagIndex) + { return; + } // Create map of integer parameters for a given flag, if not yet done if (myReportIntegers.IsNull()) + { myReportIntegers = new NCollection_HArray1>(Message_ExecStatus::FirstStatus, Message_ExecStatus::LastStatus); + } occ::handle& aData = myReportIntegers->ChangeValue(aFlagIndex); if (aData.IsNull()) + { aData = new TColStd_HPackedMapOfInteger; + } // add integer parameter for the status occ::down_cast(aData)->ChangeMap().Add(theInt); @@ -91,33 +101,47 @@ void Message_Algorithm::SetStatus(const Message_Status& // Set status flag SetStatus(theStat); if (theStr.IsNull()) + { return; + } // Find index of bit corresponding to that flag int aFlagIndex = Message_ExecStatus::StatusIndex(theStat); if (!aFlagIndex) + { return; + } // Create sequence of string parameters for a given flag, if not yet done if (myReportStrings.IsNull()) + { myReportStrings = new NCollection_HArray1>(Message_ExecStatus::FirstStatus, Message_ExecStatus::LastStatus); + } occ::handle& aData = myReportStrings->ChangeValue(aFlagIndex); if (aData.IsNull()) + { aData = new NCollection_HSequence>; + } // Add string parameter occ::handle>> aReportSeq = occ::down_cast>>(aData); if (aReportSeq.IsNull()) + { return; + } if (noRepetitions) { // if the provided string has been already registered, just do nothing for (int i = 1; i <= aReportSeq->Length(); i++) + { if (aReportSeq->Value(i)->String().IsEqual(theStr->String())) + { return; + } + } } aReportSeq->Append(theStr); @@ -181,7 +205,9 @@ void Message_Algorithm::SendStatusMessages(const Message_ExecStatus& theStatus, NCollection_Handle aMsgCustom; if (!myReportMessages.IsNull()) + { aMsgCustom = myReportMessages->Value(i); + } if (!aMsgCustom.IsNull()) { // print custom message @@ -217,7 +243,9 @@ void Message_Algorithm::SendStatusMessages(const Message_ExecStatus& theStatus, aMsgName = aType->Name(); aMsgName += aSuffix; if (Message_MsgFile::HasMsg(aMsgName)) + { break; + } } // create a message @@ -280,7 +308,9 @@ void Message_Algorithm::AddStatus(const Message_ExecStatus& theAllow { Message_Status stat = Message_ExecStatus::StatusByIndex(i); if (!theAllowedStatus.IsSet(stat) || !aStatusOfAlgo.IsSet(stat)) + { continue; + } SetStatus(stat); @@ -292,12 +322,16 @@ void Message_Algorithm::AddStatus(const Message_ExecStatus& theAllow { // Create sequence of integer parameters for a given flag, if not yet done if (myReportIntegers.IsNull()) + { myReportIntegers = new NCollection_HArray1>(Message_ExecStatus::FirstStatus, Message_ExecStatus::LastStatus); + } occ::handle& aData = myReportIntegers->ChangeValue(i); if (aData.IsNull()) + { aData = new TColStd_HPackedMapOfInteger; + } // add integer parameter for the status NCollection_PackedMapAlgo::Unite( @@ -310,7 +344,9 @@ void Message_Algorithm::AddStatus(const Message_ExecStatus& theAllow if (!aStrsOther.IsNull()) { for (int n = 1; n < aStrsOther->Length(); n++) + { SetStatus(stat, aStrsOther->Value(n)); + } } } } @@ -321,12 +357,16 @@ occ::handle Message_Algorithm::GetMessageNumbers( const Message_Status& theStatus) const { if (myReportIntegers.IsNull()) + { return nullptr; + } // Find index of bit corresponding to that flag int aFlagIndex = Message_ExecStatus::StatusIndex(theStatus); if (!aFlagIndex) + { return nullptr; + } return occ::down_cast(myReportIntegers->Value(aFlagIndex)); } @@ -337,12 +377,16 @@ occ::handle>> Mes GetMessageStrings(const Message_Status& theStatus) const { if (myReportStrings.IsNull()) + { return nullptr; + } // Find index of bit corresponding to that flag int aFlagIndex = Message_ExecStatus::StatusIndex(theStatus); if (!aFlagIndex) + { return nullptr; + } return occ::down_cast>>( myReportStrings->Value(aFlagIndex)); @@ -360,7 +404,9 @@ TCollection_ExtendedString Message_Algorithm::PrepareReport( for (; anIt.More() && nb <= theMaxCount; anIt.Next(), nb++) { if (nb > 1) + { aNewReport += " "; + } aNewReport += anIt.Key(); } diff --git a/src/FoundationClasses/TKernel/Message/Message_AttributeMeter.cxx b/src/FoundationClasses/TKernel/Message/Message_AttributeMeter.cxx index e3e1f8e030..2241972b2f 100644 --- a/src/FoundationClasses/TKernel/Message/Message_AttributeMeter.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_AttributeMeter.cxx @@ -119,9 +119,13 @@ void Message_AttributeMeter::SetAlertMetrics(const occ::handleSetStartValue(Message_MetricType_WallClock, aTime); + } else + { aMeterAttribute->SetStopValue(Message_MetricType_WallClock, aTime); + } } if (anActiveMetrics.Contains(Message_MetricType_ProcessCPUUserTime) || anActiveMetrics.Contains(Message_MetricType_ProcessCPUSystemTime) diff --git a/src/FoundationClasses/TKernel/Message/Message_CompositeAlerts.cxx b/src/FoundationClasses/TKernel/Message/Message_CompositeAlerts.cxx index ff45fe5a9c..88fde363de 100644 --- a/src/FoundationClasses/TKernel/Message/Message_CompositeAlerts.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_CompositeAlerts.cxx @@ -53,7 +53,9 @@ bool Message_CompositeAlerts::AddAlert(Message_Gravity theGrav { // if merged successfully, just return if (aType == anIt.Value()->DynamicType() && theAlert->Merge(anIt.Value())) + { return false; + } } } @@ -171,7 +173,9 @@ void Message_CompositeAlerts::DumpJson(Standard_OStream& theOStream, int theDept for (unsigned int i = 0; i < sizeof(myAlerts) / sizeof(myAlerts[0]); ++i) { if (myAlerts[i].IsEmpty()) + { continue; + } for (NCollection_List>::Iterator anIt(myAlerts[i]); anIt.More(); anIt.Next(), anInc++) diff --git a/src/FoundationClasses/TKernel/Message/Message_Msg.cxx b/src/FoundationClasses/TKernel/Message/Message_Msg.cxx index 5ae5aa41ba..5c867ce962 100644 --- a/src/FoundationClasses/TKernel/Message/Message_Msg.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_Msg.cxx @@ -36,7 +36,9 @@ Message_Msg::Message_Msg(const Message_Msg& theMsg) myMessageBody = theMsg.myMessageBody; myOriginal = theMsg.myOriginal; for (int i = 1, n = theMsg.mySeqOfFormats.Length(); i <= n; i++) + { mySeqOfFormats.Append(theMsg.mySeqOfFormats.Value(i)); + } } //================================================================================================= @@ -82,7 +84,9 @@ void Message_Msg::Set(const TCollection_ExtendedString& theMsg) { myMessageBody.Remove(i + 1); if (i >= --anMsgLength) + { break; + } aChar = ToCharacter(anExtString[i]); } // Skip flags, field width and precision @@ -90,17 +94,25 @@ void Message_Msg::Set(const TCollection_ExtendedString& theMsg) { if (aChar == '-' || aChar == '+' || aChar == ' ' || aChar == '#' || (aChar >= '0' && aChar <= '9') || aChar == '.') + { i++; + } else + { break; + } aChar = ToCharacter(anExtString[i]); } if (i >= anMsgLength) + { break; + } FormatType aFormatType; if (aChar == 'h' || aChar == 'l') + { aChar = ToCharacter(anExtString[++i]); + } switch (aChar) // detect the type of format spec { case 'd': @@ -140,7 +152,9 @@ Message_Msg& Message_Msg::Arg(const char* const theString) TCollection_AsciiString aFormat; int aFirst = getFormat(Msg_StringType, aFormat); if (!aFirst) + { return *this; + } // print string according to format char* sStringBuffer = new char[std::max(static_cast(strlen(theString) + 1), 1024)]; @@ -167,7 +181,9 @@ Message_Msg& Message_Msg::Arg(const TCollection_ExtendedString& theString) TCollection_AsciiString aFormat; int aFirst = getFormat(Msg_StringType, aFormat); if (!aFirst) + { return *this; + } // replace the format placeholder by the actual string replaceText(aFirst, aFormat.Length(), theString); @@ -183,7 +199,9 @@ Message_Msg& Message_Msg::Arg(const int theValue) TCollection_AsciiString aFormat; int aFirst = getFormat(Msg_IntegerType, aFormat); if (!aFirst) + { return *this; + } // print string according to format char sStringBuffer[64]; @@ -204,7 +222,9 @@ Message_Msg& Message_Msg::Arg(const double theValue) TCollection_AsciiString aFormat; int aFirst = getFormat(Msg_RealType, aFormat); if (!aFirst) + { return *this; + } // print string according to format char sStringBuffer[64]; @@ -252,6 +272,7 @@ const TCollection_ExtendedString& Message_Msg::Get() int Message_Msg::getFormat(const int theType, TCollection_AsciiString& theFormat) { for (int i = 1; i <= mySeqOfFormats.Length(); i += 3) + { if (mySeqOfFormats(i) == theType) { // Extract format @@ -259,13 +280,18 @@ int Message_Msg::getFormat(const int theType, TCollection_AsciiString& theFormat int aLen = mySeqOfFormats(i + 2); theFormat = TCollection_AsciiString(aLen, ' '); for (int j = 1; j <= aLen; j++) + { if (IsAnAscii(myMessageBody.Value(aFirst + j))) + { theFormat.SetValue(j, (char)myMessageBody.Value(aFirst + j)); + } + } // delete information on this placeholder mySeqOfFormats.Remove(i, i + 2); // return start position return aFirst + 1; } + } return 0; } @@ -285,8 +311,14 @@ void Message_Msg::replaceText(const int theFirst, // update information on remaining format placeholders int anIncrement = theStr.Length() - theNb; if (!anIncrement) + { return; + } for (int i = 1; i <= mySeqOfFormats.Length(); i += 3) + { if (mySeqOfFormats(i + 1) > theFirst) + { mySeqOfFormats(i + 1) += anIncrement; + } + } } diff --git a/src/FoundationClasses/TKernel/Message/Message_MsgFile.cxx b/src/FoundationClasses/TKernel/Message/Message_MsgFile.cxx index 6a9ae0da48..14eca3eba0 100644 --- a/src/FoundationClasses/TKernel/Message/Message_MsgFile.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_MsgFile.cxx @@ -58,7 +58,9 @@ typedef enum bool Message_MsgFile::Load(const char* const theDirName, const char* const theFileName) { if (!theDirName || !theFileName) + { return false; + } bool ret = true; TCollection_AsciiString aDirList(theDirName); @@ -67,7 +69,9 @@ bool Message_MsgFile::Load(const char* const theDirName, const char* const theFi { TCollection_AsciiString aFileName = aDirList.Token(" \t\n", i); if (aFileName.IsEmpty()) + { break; + } #ifdef _WIN32 aFileName += '\\'; #else @@ -75,7 +79,9 @@ bool Message_MsgFile::Load(const char* const theDirName, const char* const theFi #endif aFileName += theFileName; if (!LoadFile(aFileName.ToCString())) + { ret = false; + } } return ret; } @@ -120,33 +126,49 @@ static inline bool getString(CharType*& thePtr, { CharType aChar = *aPtr; if (aChar == ' ') + { aLeftSpaces++; + } else if (aChar == '\t') + { aLeftSpaces += 8; + } else if (aChar == '\r' || *aPtr == '\n') + { aLeftSpaces = 0; + } else + { break; + } aPtr++; } // Find the end of the string for (anEndPtr = aPtr; *anEndPtr; anEndPtr++) + { if (anEndPtr[0] == '\n') { if (anEndPtr[-1] == '\r') + { anEndPtr--; + } break; } + } } while (aPtr[0] == '!'); // form the result if (aPtr == anEndPtr) + { return false; + } thePtr = anEndPtr; if (*thePtr) + { *thePtr++ = '\0'; + } theString = typename TCollection_String::type(aPtr); theLeftSpaces = aLeftSpaces; return true; @@ -175,15 +197,19 @@ static inline bool loadFile(_Char* theBuffer) { case MsgFile_WaitingMoreMessage: if (isKeyword) + { Message_MsgFile::AddMsg(aKeyword, aMessage); // terminate the previous one - // Pass from here to 'case MsgFile_WaitingKeyword' + // Pass from here to 'case MsgFile_WaitingKeyword' + } else { // Add another line to the message already in the buffer 'aMessage' aMessage += '\n'; aLeftSpaces -= aFirstLeftSpaces; if (aLeftSpaces > 0) + { aMessage += TCollection_ExtendedString(aLeftSpaces, ' '); + } aMessage += aString; break; } @@ -214,7 +240,9 @@ static inline bool loadFile(_Char* theBuffer) } // Process the last string still remaining in the buffer if (aState == MsgFile_WaitingMoreMessage) + { Message_MsgFile::AddMsg(aKeyword, aMessage); + } return true; } @@ -223,15 +251,21 @@ static inline bool loadFile(_Char* theBuffer) static int GetFileSize(FILE* theFile) { if (!theFile) + { return -1; + } // get real file size long nRealFileSize = 0; if (fseek(theFile, 0, SEEK_END) != 0) + { return -1; + } nRealFileSize = ftell(theFile); if (fseek(theFile, 0, SEEK_SET) != 0) + { return -1; + } return (int)nRealFileSize; } @@ -244,12 +278,16 @@ static int GetFileSize(FILE* theFile) bool Message_MsgFile::LoadFile(const char* const theFileName) { if (theFileName == nullptr || *theFileName == '\0') + { return false; + } // Open the file FILE* anMsgFile = OSD_OpenFile(theFileName, "rb"); if (!anMsgFile) + { return false; + } const int aFileSize = GetFileSize(anMsgFile); NCollection_Buffer aBuffer(NCollection_BaseAllocator::CommonBaseAllocator()); @@ -264,7 +302,9 @@ bool Message_MsgFile::LoadFile(const char* const theFileName) fclose(anMsgFile); if (nbRead != aFileSize) + { return false; + } anMsgBuffer[aFileSize] = 0; anMsgBuffer[aFileSize + 1] = 0; @@ -294,7 +334,9 @@ bool Message_MsgFile::LoadFile(const char* const theFileName) return ::loadFile(aUnicodeBuffer); } else + { return ::loadFile(anMsgBuffer); + } } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/Message/Message_PrinterOStream.cxx b/src/FoundationClasses/TKernel/Message/Message_PrinterOStream.cxx index b8e8368038..234f5637dc 100644 --- a/src/FoundationClasses/TKernel/Message/Message_PrinterOStream.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_PrinterOStream.cxx @@ -95,7 +95,9 @@ Message_PrinterOStream::Message_PrinterOStream(const char* const theFileName void Message_PrinterOStream::Close() { if (!myStream) + { return; + } Standard_OStream* ostr = (Standard_OStream*)myStream; myStream = nullptr; @@ -158,7 +160,7 @@ void Message_PrinterOStream::send(const TCollection_AsciiString& theString, { *aStream << theString; } - (*aStream) << std::endl; + (*aStream) << '\n'; } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/Message/Message_Report.cxx b/src/FoundationClasses/TKernel/Message/Message_Report.cxx index 4380ae0fed..ce228fa445 100644 --- a/src/FoundationClasses/TKernel/Message/Message_Report.cxx +++ b/src/FoundationClasses/TKernel/Message/Message_Report.cxx @@ -87,7 +87,9 @@ bool Message_Report::HasAlert(const occ::handle& theType) for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity) { if (HasAlert(theType, (Message_Gravity)iGravity)) + { return true; + } } return false; } @@ -117,7 +119,9 @@ void Message_Report::ActivateInMessenger(const bool t const occ::handle& theMessenger) { if (toActivate == IsActiveInMessenger()) + { return; + } myIsActiveInMessenger = toActivate; occ::handle aMessenger = @@ -139,7 +143,9 @@ void Message_Report::ActivateInMessenger(const bool t const occ::handle& aPrinter = anIterator.Value(); if (aPrinter->IsKind(STANDARD_TYPE(Message_PrinterToReport)) && occ::down_cast(aPrinter)->Report() == this) + { aPrintersToRemove.Append(aPrinter); + } } for (NCollection_Sequence>::Iterator anIterator(aPrintersToRemove); anIterator.More(); @@ -424,7 +430,7 @@ void Message_Report::dumpMessages(Standard_OStream& th for (NCollection_List>::Iterator anIt(anAlerts); anIt.More(); anIt.Next()) { - theOS << anIt.Value()->GetMessageKey() << std::endl; + theOS << anIt.Value()->GetMessageKey() << '\n'; occ::handle anExtendedAlert = occ::down_cast(anIt.Value()); diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.cxx index e99243c1c0..f3ef0a9030 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.cxx @@ -62,11 +62,15 @@ void* NCollection_AccAllocator::Allocate(const size_t theSize) aBlock = aBlock->prevBlock) { if (aSize <= aBlock->FreeSize()) + { break; + } } if (aBlock == nullptr || !aBlocksRest) + { // There is no available block with enough free space, create a new one aBlock = allocateNewBlock(myBlockSize); + } } void* anAddress = aBlock->Allocate(aSize); diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.cxx index ab87c88835..96490ea69a 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.cxx @@ -41,9 +41,13 @@ void NCollection_BaseList::PClear(NCollection_DelListNode fDel) void NCollection_BaseList::PAppend(NCollection_ListNode* theNode) noexcept { if (myLength) + { myLast->Next() = theNode; + } else + { myFirst = theNode; + } theNode->Next() = nullptr; myLast = theNode; myLength++; @@ -57,12 +61,18 @@ void NCollection_BaseList::PAppend(NCollection_ListNode* theNode) noexcept void NCollection_BaseList::PAppend(NCollection_BaseList& theOther) noexcept { if (this == &theOther || theOther.IsEmpty()) + { return; + } if (IsEmpty()) + { myFirst = theOther.myFirst; + } else + { myLast->Next() = theOther.myFirst; + } myLast = theOther.myLast; theOther.myFirst = theOther.myLast = nullptr; @@ -80,7 +90,9 @@ void NCollection_BaseList::PPrepend(NCollection_ListNode* theNode) noexcept theNode->Next() = myFirst; myFirst = theNode; if (myLast == nullptr) + { myLast = myFirst; + } myLength++; } @@ -89,12 +101,18 @@ void NCollection_BaseList::PPrepend(NCollection_ListNode* theNode) noexcept void NCollection_BaseList::PPrepend(NCollection_BaseList& theOther) noexcept { if (this == &theOther || theOther.IsEmpty()) + { return; + } if (IsEmpty()) + { myLast = theOther.myLast; + } else + { theOther.myLast->Next() = myFirst; + } myFirst = theOther.myFirst; theOther.myFirst = theOther.myLast = nullptr; @@ -112,7 +130,9 @@ void NCollection_BaseList::PRemoveFirst(NCollection_DelListNode fDel) fDel(pItem, myAllocator); myLength--; if (myLength == 0) + { myLast = nullptr; + } } //================================================================================================= @@ -132,7 +152,9 @@ void NCollection_BaseList::PRemove(Iterator& theIter, NCollection_DelListNode fD fDel(theIter.myCurrent, myAllocator); theIter.myCurrent = pNode; if (pNode == nullptr) + { myLast = theIter.myPrevious; + } myLength--; } } diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.cxx index d111c8d774..7f53bfda9e 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.cxx @@ -30,9 +30,13 @@ bool NCollection_BaseMap::BeginResize(const size_t theExtent, if (theNewBuckets <= myNbBuckets) { if (!myData1) + { theNewBuckets = myNbBuckets; + } else + { return false; + } } data1 = (NCollection_ListNode**)Standard::Allocate((theNewBuckets + 1) * sizeof(NCollection_ListNode*)); @@ -42,7 +46,9 @@ bool NCollection_BaseMap::BeginResize(const size_t theExtent, * sizeof(NCollection_ListNode*)); } else + { data2 = nullptr; + } return true; } @@ -56,7 +62,9 @@ void NCollection_BaseMap::EndResize(const size_t theExtent, (void)theExtent; // obsolete parameter Standard::Free(myData1); if (isDouble) + { Standard::Free(myData2); + } myNbBuckets = theNewBuckets; myData1 = data1; myData2 = data2; diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.cxx index c8f7a43af1..4d3d25bd3c 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.cxx @@ -64,7 +64,9 @@ void NCollection_BaseSequence::PAppend(NCollection_SeqNode* theItem) void NCollection_BaseSequence::PAppend(NCollection_BaseSequence& Other) { if (Other.mySize == 0) + { return; + } if (mySize == 0) { mySize = Other.mySize; @@ -115,7 +117,9 @@ void NCollection_BaseSequence::PPrepend(NCollection_SeqNode* theItem) void NCollection_BaseSequence::PPrepend(NCollection_BaseSequence& Other) { if (Other.mySize == 0) + { return; + } if (mySize == 0) { mySize = Other.mySize; @@ -128,7 +132,9 @@ void NCollection_BaseSequence::PPrepend(NCollection_BaseSequence& Other) { mySize += Other.mySize; if (Other.myLastItem) + { Other.myLastItem->SetNext(myFirstItem); + } myFirstItem->SetPrevious(Other.myLastItem); myFirstItem = Other.myFirstItem; myCurrentIndex += Other.mySize; @@ -155,7 +161,9 @@ void NCollection_BaseSequence::PReverse() noexcept myFirstItem = myLastItem; myLastItem = tmp; if (mySize != 0) + { myCurrentIndex = mySize + 1 - myCurrentIndex; + } } //================================================================================================= @@ -165,15 +173,21 @@ void NCollection_BaseSequence::PInsertAfter(NCollection_BaseSequence::Iterator& { NCollection_SeqNode* aPos = thePosition.myCurrent; if (aPos == nullptr) + { PPrepend(theItem); + } else { theItem->SetNext(aPos->Next()); theItem->SetPrevious(aPos); if (aPos->Next() == nullptr) + { myLastItem = theItem; + } else + { aPos->Next()->SetPrevious(theItem); + } aPos->SetNext(theItem); ++mySize; myCurrentItem = myFirstItem; @@ -186,20 +200,28 @@ void NCollection_BaseSequence::PInsertAfter(NCollection_BaseSequence::Iterator& void NCollection_BaseSequence::PInsertAfter(const size_t theIndex, NCollection_SeqNode* theItem) { if (theIndex == 0) + { PPrepend(theItem); + } else { NCollection_SeqNode* p = Find(theIndex); theItem->SetNext(p->Next()); theItem->SetPrevious(p); if (theIndex == mySize) + { myLastItem = theItem; + } else + { p->Next()->SetPrevious(theItem); + } p->SetNext(theItem); ++mySize; if (theIndex < myCurrentIndex) + { ++myCurrentIndex; + } } } @@ -211,24 +233,34 @@ void NCollection_BaseSequence::PInsertAfter(const size_t theIndex, NCollection_S void NCollection_BaseSequence::PInsertAfter(const size_t theIndex, NCollection_BaseSequence& Other) { if (theIndex > mySize) + { throw Standard_OutOfRange(); + } if (Other.mySize != 0) { if (theIndex == 0) + { PPrepend(Other); + } else { NCollection_SeqNode* p = Find(theIndex); Other.myFirstItem->SetPrevious(p); Other.myLastItem->SetNext(p->Next()); if (theIndex == mySize) + { myLastItem = Other.myLastItem; + } else + { p->Next()->SetPrevious(Other.myLastItem); + } p->SetNext(Other.myFirstItem); mySize += Other.mySize; if (theIndex < myCurrentIndex) + { myCurrentIndex += Other.mySize; + } Other.Nullify(); } } @@ -245,7 +277,9 @@ void NCollection_BaseSequence::PExchange(const size_t I, const size_t J) // Assume I < J if (J < I) + { PExchange(J, I); + } else if (I < J) { NCollection_SeqNode* pi = Find(I); @@ -253,15 +287,23 @@ void NCollection_BaseSequence::PExchange(const size_t I, const size_t J) // update the node before I if (pi->Previous()) + { pi->Previous()->SetNext(pj); + } else + { myFirstItem = pj; + } // update the node after J if (pj->Next()) + { pj->Next()->SetPrevious(pi); + } else + { myLastItem = pi; + } if (pi->Next() == pj) { // I and J are consecutives, update them @@ -286,9 +328,13 @@ void NCollection_BaseSequence::PExchange(const size_t I, const size_t J) } if (myCurrentIndex == I) + { myCurrentItem = pj; + } else if (myCurrentIndex == J) + { myCurrentItem = pi; + } } } @@ -333,18 +379,28 @@ void NCollection_BaseSequence::RemoveSeq(NCollection_BaseSequence::Iterator& the { NCollection_SeqNode* aPos = thePosition.myCurrent; if (aPos == nullptr) + { return; + } thePosition.myCurrent = aPos->Next(); if (aPos->Previous()) + { aPos->Previous()->SetNext(aPos->Next()); + } else + { myFirstItem = aPos->Next(); + } if (aPos->Next()) + { aPos->Next()->SetPrevious(aPos->Previous()); + } else + { myLastItem = aPos->Previous(); + } --mySize; myCurrentItem = myLastItem; @@ -362,21 +418,33 @@ void NCollection_BaseSequence::RemoveSeq(const size_t theIndex, NCollection_DelS NCollection_SeqNode* p = Find(theIndex); if (p->Previous()) + { p->Previous()->SetNext(p->Next()); + } else + { myFirstItem = p->Next(); + } if (p->Next()) + { p->Next()->SetPrevious(p->Previous()); + } else + { myLastItem = p->Previous(); + } --mySize; if (myCurrentIndex > theIndex) + { --myCurrentIndex; + } else if (myCurrentIndex == theIndex) { if (p->Next()) + { myCurrentItem = p->Next(); + } else { myCurrentItem = myLastItem; @@ -399,17 +467,27 @@ void NCollection_BaseSequence::RemoveSeq(const size_t From, NCollection_SeqNode* pto = Find(To); if (pfrom->Previous()) + { pfrom->Previous()->SetNext(pto->Next()); + } else + { myFirstItem = pto->Next(); + } if (pto->Next()) + { pto->Next()->SetPrevious(pfrom->Previous()); + } else + { myLastItem = pfrom->Previous(); + } mySize -= To - From + 1; if (myCurrentIndex > To) + { myCurrentIndex -= To - From + 1; + } else if (myCurrentIndex >= From) { if (pto->Next()) @@ -444,13 +522,17 @@ NCollection_SeqNode* NCollection_BaseSequence::Find(const size_t theIndex) const { p = myFirstItem; for (i = 1; i < theIndex; ++i) + { p = p->Next(); + } } else { p = myCurrentItem; for (i = myCurrentIndex; i > theIndex; --i) + { p = p->Previous(); + } } } else @@ -459,13 +541,17 @@ NCollection_SeqNode* NCollection_BaseSequence::Find(const size_t theIndex) const { p = myCurrentItem; for (i = myCurrentIndex; i < theIndex; ++i) + { p = p->Next(); + } } else { p = myLastItem; for (i = mySize; i > theIndex; --i) + { p = p->Previous(); + } } } return p; diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_IncAllocator.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_IncAllocator.cxx index 237bf36f06..5f1e524cbd 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_IncAllocator.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_IncAllocator.cxx @@ -204,7 +204,9 @@ void NCollection_IncAllocator::clean() { // Exclusive lock - no allocations can be in progress. if (myMutex) + { myMutex->lock(); + } IBlock* aHeapIter = myOrderedBlocks; while (aHeapIter) { @@ -218,7 +220,9 @@ void NCollection_IncAllocator::clean() myBlockCount = 0; myBlockSize = THE_DEFAULT_BLOCK_SIZE; if (myMutex) + { myMutex->unlock(); + } } //================================================================================================= @@ -266,7 +270,9 @@ void NCollection_IncAllocator::Reset(const bool theReleaseMemory) return; } if (myMutex) + { myMutex->lock(); + } IBlock* aHeapIter = myOrderedBlocks; while (aHeapIter) { @@ -278,7 +284,9 @@ void NCollection_IncAllocator::Reset(const bool theReleaseMemory) myAllocationHeap = myOrderedBlocks; myUsedHeap = nullptr; if (myMutex) + { myMutex->unlock(); + } } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_SparseArrayBase.cxx b/src/FoundationClasses/TKernel/NCollection/NCollection_SparseArrayBase.cxx index 4199728b4f..7d77c60afe 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_SparseArrayBase.cxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_SparseArrayBase.cxx @@ -24,17 +24,23 @@ void NCollection_SparseArrayBase::allocData(const size_t iBlock) { if (iBlock < myNbBlocks) + { return; + } // the allocation of blocks starts from myBlockSize items // and then is multiplied by 2 every time reallocation is needed size_t newNbBlocks = (myNbBlocks ? myNbBlocks * 2 : myBlockSize); while (iBlock >= newNbBlocks) + { newNbBlocks *= 2; + } void** newData = (void**)Standard::AllocateOptimal(newNbBlocks * sizeof(void*)); if (myNbBlocks > 0) + { memcpy(newData, myData, myNbBlocks * sizeof(void*)); + } memset(newData + myNbBlocks, 0, (newNbBlocks - myNbBlocks) * sizeof(void*)); Standard::Free(myData); @@ -48,7 +54,9 @@ void NCollection_SparseArrayBase::freeBlock(const size_t iBlock, DestroyItemFunc { void*& anAddr = myData[iBlock]; if (!anAddr) + { return; + } Block aBlock = getBlock(anAddr); // Destroy all items in the block @@ -92,11 +100,15 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO CopyItemFunc theCopyItem) { if (this == &theOther) + { return; + } // if block size is different, clear all data if (myBlockSize != theOther.myBlockSize) + { clearItems(theDestroyItem); + } myBlockSize = theOther.myBlockSize; // iterate by blocks in theOther @@ -107,12 +119,16 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO { // if other block is empty, just make sure to empty that block in "this" if (iBlock < myNbBlocks && myData[iBlock]) + { freeBlock(iBlock, theDestroyItem); + } continue; } if (iBlock >= myNbBlocks) + { allocData(iBlock); + } Block anOtherBlock = getBlock(theOther.myData[iBlock]); // if block not yet allocated, just allocate and fill @@ -124,6 +140,7 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO memset(anAddr, 0, aBlockSize); Block aBlock(getBlock(anAddr)); for (size_t anInd = 0; anInd < myBlockSize; anInd++) + { if (anOtherBlock.IsSet(anInd)) { void* anItem = getItem(aBlock, anInd); @@ -132,6 +149,7 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO mySize++; theCreateItem(anItem, getItem(anOtherBlock, anInd)); } + } } // else perform copying item-by-item else @@ -168,8 +186,12 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO // clear any remaining blocks in this for (; iBlock < myNbBlocks; iBlock++) + { if (myData[iBlock]) + { freeBlock(iBlock, theDestroyItem); + } + } } //================================================================================================= @@ -177,7 +199,9 @@ void NCollection_SparseArrayBase::assign(const NCollection_SparseArrayBase& theO void NCollection_SparseArrayBase::exchange(NCollection_SparseArrayBase& theOther) noexcept { if (this == &theOther) + { return; + } // swap fields of this and theOther using std::swap for better optimization std::swap(myItemSize, theOther.myItemSize); @@ -199,7 +223,9 @@ void* NCollection_SparseArrayBase::setValue(const size_t theIndex, // resize blocks array if necessary if (iBlock >= myNbBlocks) + { allocData(iBlock); + } // allocate block if necessary void*& anAddr = myData[iBlock]; @@ -238,7 +264,9 @@ bool NCollection_SparseArrayBase::HasValue(const size_t theIndex) const { size_t iBlock = theIndex / myBlockSize; if (iBlock >= myNbBlocks || !myData[iBlock]) + { return false; + } return getBlock(myData[iBlock]).IsSet(theIndex % myBlockSize) != 0; } @@ -249,12 +277,16 @@ bool NCollection_SparseArrayBase::unsetValue(const size_t theIndex, DestroyItemF // check that the item is defined size_t iBlock = theIndex / myBlockSize; if (iBlock >= myNbBlocks || !myData[iBlock]) + { return false; + } Block aBlock(getBlock(myData[iBlock])); size_t anInd = theIndex % myBlockSize; if (!aBlock.Unset(anInd)) + { return false; + } // destroy the item theDestroyItem(getItem(aBlock, anInd)); @@ -263,7 +295,9 @@ bool NCollection_SparseArrayBase::unsetValue(const size_t theIndex, DestroyItemF // free block if it becomes empty if (!(*aBlock.Count)) + { freeBlock(iBlock, theDestroyItem); + } return true; } @@ -285,7 +319,9 @@ NCollection_SparseArrayBase::Iterator::Iterator(const NCollection_SparseArrayBas void NCollection_SparseArrayBase::Iterator::Next() { if (!myArr || !myHasMore) + { return; + } // iterate by items and blocks for (myInd++;; myInd++) @@ -310,7 +346,9 @@ void NCollection_SparseArrayBase::Iterator::Next() } // check if item is defined if (myBlock.IsSet(myInd)) + { return; + } } } @@ -327,12 +365,16 @@ void NCollection_SparseArrayBase::Iterator::init(const NCollection_SparseArrayBa for (myIBlock = 0; myIBlock < myArr->myNbBlocks; myIBlock++) { if (!myArr->myData[myIBlock]) + { continue; + } myHasMore = true; myBlock = Block(myArr->myData[myIBlock], myArr->myBlockSize, myArr->myItemSize); // if first item in the block is not set, advance to the next defined item if (!myBlock.IsSet(myInd)) + { Next(); + } return; } } diff --git a/src/FoundationClasses/TKernel/OSD/OSD.cxx b/src/FoundationClasses/TKernel/OSD/OSD.cxx index a945c2ad5a..0af1a7279f 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD.cxx @@ -22,8 +22,10 @@ bool OSD::RealToCString(const double aReal, Standard_PCharacter& aString) { char *p, *q; - if (Sprintf(aString, "%.17e", aReal) <= 0) // BUC60808 + if (Sprintf(aString, "%.17e", aReal) <= 0) + { // BUC60808 return false; + } // Suppress "e+00" and insignificant 0's @@ -31,15 +33,23 @@ bool OSD::RealToCString(const double aReal, Standard_PCharacter& aString) if (p) { if (!strcmp(p, "e+00")) + { *p = 0; + } for (q = p - 1; *q == '0'; q--) + { ; + } if (q != p - 1) { if (*q != '.') + { q++; + } while (*p) + { *q++ = *p++; + } *q = 0; } } diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Chronometer.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Chronometer.cxx index 421601265f..55114cf0d3 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Chronometer.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Chronometer.cxx @@ -210,9 +210,13 @@ void OSD_Chronometer::Stop() { double Curr_user, Curr_sys; if (myIsThreadOnly) + { GetThreadCPU(Curr_user, Curr_sys); + } else + { GetProcessCPU(Curr_user, Curr_sys); + } myCumulCpuUser += Curr_user - myStartCpuUser; myCumulCpuSys += Curr_sys - myStartCpuSys; @@ -228,9 +232,13 @@ void OSD_Chronometer::Start() if (myIsStopped) { if (myIsThreadOnly) + { GetThreadCPU(myStartCpuUser, myStartCpuSys); + } else + { GetProcessCPU(myStartCpuUser, myStartCpuSys); + } myIsStopped = false; } @@ -268,9 +276,13 @@ void OSD_Chronometer::Show(double& theUserSec, double& theSystemSec) const double aCurrUser, aCurrSys; if (myIsThreadOnly) + { GetThreadCPU(aCurrUser, aCurrSys); + } else + { GetProcessCPU(aCurrUser, aCurrSys); + } theUserSec += aCurrUser - myStartCpuUser; theSystemSec += aCurrSys - myStartCpuSys; diff --git a/src/FoundationClasses/TKernel/OSD/OSD_DirectoryIterator.cxx b/src/FoundationClasses/TKernel/OSD/OSD_DirectoryIterator.cxx index b3c377c543..3af2b00410 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_DirectoryIterator.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_DirectoryIterator.cxx @@ -54,7 +54,9 @@ void OSD_DirectoryIterator::Initialize(const OSD_Path& where, const TCollection_ myFlag = false; where.SystemName(myPlace); if (myPlace.Length() == 0) + { myPlace = "."; + } myMask = Mask; if (myDescr) { @@ -90,17 +92,31 @@ static int strcmp_joker(const char* Mask, const char* Name) const char *p, *s; for (p = Mask, s = Name; *p && *p != '*'; p++, s++) + { if (*p != *s) + { return 0; + } + } if (!*p) + { return !(*s); + } while (*p == '*') + { p++; + } if (!*p) + { return 1; + } for (; *s; s++) + { if (strcmp_joker(p, s)) + { return 1; + } + } return 0; } @@ -132,13 +148,15 @@ void OSD_DirectoryIterator::Next() // Is it a directory ? const TCollection_AsciiString aFullName = myPlace + "/" + ((struct dirent*)myEntry)->d_name; stat(aFullName.ToCString(), &stat_buf); - if (S_ISDIR(stat_buf.st_mode)) // Ensure me it's not a file + if (S_ISDIR(stat_buf.st_mode)) + { // Ensure me it's not a file if (strcmp_joker(myMask.ToCString(), ((struct dirent*)myEntry)->d_name)) { // Does it follow mask ? myFlag = true; again = 0; } + } } } while (again); @@ -154,7 +172,9 @@ OSD_Directory OSD_DirectoryIterator::Values() int position; if (myEntry) + { Name = ((struct dirent*)myEntry)->d_name; + } position = Name.Search("."); diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Environment.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Environment.cxx index a4b50bfc8e..4fc62983ea 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Environment.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Environment.cxx @@ -51,7 +51,9 @@ OSD_Environment::OSD_Environment(const TCollection_AsciiString& Name) { if (!Name.IsAscii() || Name.Search("$") != -1) + { throw Standard_ConstructionError("OSD_Environment::OSD_Environment: bad argument"); + } myName = Name; } @@ -65,7 +67,9 @@ OSD_Environment::OSD_Environment(const TCollection_AsciiString& Name, if (!Name.IsAscii() || !Value.IsAscii() || // JPT : Dec-7-1992 Name.Search("$") != -1 || Value.Search("$") != -1) Name.Search("$") != -1) + { throw Standard_ConstructionError("OSD_Environment::OSD_Environment: bad argument"); + } myName = Name; myValue = Value; @@ -84,7 +88,9 @@ void OSD_Environment::SetName(const TCollection_AsciiString& Name) { myError.Reset(); if (!Name.IsAscii() || Name.Search("$") != -1) + { throw Standard_ConstructionError("OSD_Environment::SetName: bad argument"); + } myName = Name; } @@ -94,7 +100,9 @@ void OSD_Environment::SetName(const TCollection_AsciiString& Name) void OSD_Environment::SetValue(const TCollection_AsciiString& Value) { if (!Value.IsAscii() || Value.Search("$") != -1) + { throw Standard_ConstructionError("OSD_Environment::Change: bad argument"); + } myValue = Value; } @@ -105,9 +113,13 @@ TCollection_AsciiString OSD_Environment::Value() { char* result = getenv(myName.ToCString()); if (result == nullptr) + { myValue.Clear(); + } else + { myValue = result; + } return myValue; } @@ -170,7 +182,9 @@ void OSD_Environment::Build() // check the result char* result = getenv(myName.ToCString()); if (result == nullptr) + { myError.SetValue(errno, Iam, "Set Environment"); + } } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Error.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Error.cxx index 2de4144e20..bc2df4b32d 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Error.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Error.cxx @@ -35,9 +35,13 @@ void OSD_Error::Reset() bool OSD_Error::Failed() const { if (myErrno == 0) + { return (false); + } else + { return (true); + } } void OSD_Error::SetValue(const int errcode, const int from, const TCollection_AsciiString& message) @@ -57,7 +61,9 @@ void OSD_Error::Perror() TCollection_AsciiString buffer; if (myErrno == 0) + { return; + } buffer += " :\n "; extCode = ERR_SURPRISE; @@ -386,7 +392,9 @@ void OSD_Error::Perror() case OSD_WFileNode: case OSD_WFile: if (myMessage != "Open") + { buffer += "File doesn't exist or"; + } buffer += "Invalid path (empty string)"; extCode = ERR_NOENT; break; diff --git a/src/FoundationClasses/TKernel/OSD/OSD_FileIterator.cxx b/src/FoundationClasses/TKernel/OSD/OSD_FileIterator.cxx index 784c1773ca..1bccb1273c 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_FileIterator.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_FileIterator.cxx @@ -75,7 +75,9 @@ void OSD_FileIterator::Initialize(const OSD_Path& where, const TCollection_Ascii myFlag = false; where.SystemName(myPlace); if (myPlace.Length() == 0) + { myPlace = "."; + } myMask = Mask; if (myDescr) { @@ -110,18 +112,32 @@ static int strcmp_joker(const char* Mask, const char* Name) const char *p, *s; for (p = Mask, s = Name; *p && *p != '*'; p++, s++) + { if (*p != *s) + { return 0; + } + } if (!*p) + { return !(*s); + } while (*p == '*') + { p++; + } if (!*p) + { return 1; + } for (; *s; s++) + { if (strcmp_joker(p, s)) + { return 1; + } + } return 0; } @@ -148,20 +164,26 @@ void OSD_FileIterator::Next() else { if (!strcmp(((struct dirent*)myEntry)->d_name, ".")) + { continue; + } if (!strcmp(((struct dirent*)myEntry)->d_name, "..")) + { continue; + } // Is it a file ? const TCollection_AsciiString aFullName = myPlace + "/" + ((struct dirent*)myEntry)->d_name; stat(aFullName.ToCString(), &stat_buf); - if (S_ISREG(stat_buf.st_mode)) // LD : Ensure me it's a regular file + if (S_ISREG(stat_buf.st_mode)) + { // LD : Ensure me it's a regular file if (strcmp_joker(myMask.ToCString(), ((struct dirent*)myEntry)->d_name)) { // Does it follow mask ? myFlag = true; again = 0; } + } } } while (again); @@ -177,7 +199,9 @@ OSD_File OSD_FileIterator::Values() int position; if (myEntry) + { Name = ((struct dirent*)myEntry)->d_name; + } position = Name.Search("."); diff --git a/src/FoundationClasses/TKernel/OSD/OSD_FileNode.cxx b/src/FoundationClasses/TKernel/OSD/OSD_FileNode.cxx index e2352d1b04..ca0566f06c 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_FileNode.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_FileNode.cxx @@ -80,9 +80,13 @@ bool OSD_FileNode::Exists() status = access(aBuffer.ToCString(), F_OK); if (status == 0) + { return (true); + } else + { return (false); + } } // Physically remove a file/directory @@ -127,11 +131,12 @@ void OSD_FileNode::Remove() { if (unlink(aBuffer.ToCString()) == -1) + { myError.SetValue(errno, Iam, "Remove"); + } return; } myError.SetValue(EINVAL, Iam, "Remove"); - return; } // Move a file/directory to another path @@ -152,7 +157,9 @@ void OSD_FileNode::Move(const OSD_Path& NewPath) status = rename(aBuffer.ToCString(), thisPath.ToCString()); if (status == -1) + { myError.SetValue(errno, Iam, "Move"); + } } // Copy a file to another path and name @@ -162,7 +169,9 @@ int static copy_file(const char* src, const char* trg) errno = 0; int fds = open(src, O_RDONLY); if (fds < 0) + { return errno; + } int fdo = open(trg, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fdo < 0) @@ -191,10 +200,14 @@ int static copy_file(const char* src, const char* trg) err = errno; close(fdo); if (!err) + { err = errno; + } close(fds); if (!err) + { err = errno; + } return err; } @@ -213,7 +226,9 @@ void OSD_FileNode::Copy(const OSD_Path& ToPath) myPath.SystemName(aBuffer); status = copy_file(aBuffer.ToCString(), second_name.ToCString()); if (status != 0) + { myError.SetValue(-1, Iam, "Copy failed"); // (LD) + } #ifdef OCCT_DEBUG printf("Status %d : errno # %d\n", status, errno); #endif @@ -237,30 +252,50 @@ OSD_Protection OSD_FileNode::Protection() myPath.SystemName(aBuffer); status = stat(aBuffer.ToCString(), &myStat); if (status == -1) + { myError.SetValue(errno, Iam, "Protection"); + } u = g = w = OSD_None; if (myStat.st_mode & S_IRUSR) + { u |= OSD_R; + } if (myStat.st_mode & S_IWUSR) + { u |= OSD_W; + } if (myStat.st_mode & S_IXUSR) + { u |= OSD_X; + } if (myStat.st_mode & S_IRGRP) + { g |= OSD_R; + } if (myStat.st_mode & S_IWGRP) + { g |= OSD_W; + } if (myStat.st_mode & S_IXGRP) + { g |= OSD_X; + } if (myStat.st_mode & S_IROTH) + { w |= OSD_R; + } if (myStat.st_mode & S_IWOTH) + { w |= OSD_W; + } if (myStat.st_mode & S_IXOTH) + { w |= OSD_X; + } s = g; thisProt.SetValues((OSD_SingleProtection)s, @@ -286,7 +321,9 @@ void OSD_FileNode::SetProtection(const OSD_Protection& Prot) myPath.SystemName(aBuffer); status = chmod(aBuffer.ToCString(), (mode_t)Prot.Internal()); if (status == -1) + { myError.SetValue(errno, Iam, "SetProtection"); + } } // return the date of last access of file/directory @@ -321,7 +358,9 @@ Quantity_Date OSD_FileNode::CreationMoment() 0); } else + { result.SetValues(1, 1, 1979, 0, 0, 0, 0, 0); + } return (result); } @@ -357,7 +396,9 @@ Quantity_Date OSD_FileNode::AccessMoment() 0); } else + { result.SetValues(1, 1, 1979, 0, 0, 0, 0, 0); + } return (result); } diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Host.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Host.cxx index f12ac14e2f..ce00a9e80a 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Host.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Host.cxx @@ -74,25 +74,45 @@ OSD_SysType OSD_Host::SystemId() const uname(&info); if (!strcmp(info.sysname, "SunOS")) + { return (OSD_UnixBSD); + } if (!strcmp(info.sysname, "ULTRIX")) + { return (OSD_UnixBSD); + } if (!strcmp(info.sysname, "FreeBSD")) + { return (OSD_UnixBSD); + } if (!strncmp(info.sysname, "Linux", 5)) + { return (OSD_LinuxREDHAT); + } if (!strncmp(info.sysname, "IRIX", 4)) + { return (OSD_UnixSystemV); + } if (!strncmp(info.sysname, "OSF", 3)) + { return (OSD_OSF); + } if (!strcmp(info.sysname, "AIX")) + { return (OSD_Aix); + } if (!strcmp(info.sysname, "UNIX_System_V")) + { return (OSD_UnixSystemV); + } if (!strcmp(info.sysname, "VMS_POSIX")) + { return (OSD_VMS); + } if (!strcmp(info.sysname, "Darwin")) + { return (OSD_MacOs); + } return (OSD_Unknown); } @@ -106,7 +126,9 @@ TCollection_AsciiString OSD_Host::HostName() status = gethostname(value, 64); if (status == -1) + { myError.SetValue(errno, Iam, "Host Name"); + } result = value; return (result); @@ -165,27 +187,49 @@ OSD_OEMType OSD_Host::MachineType() uname(&info); if (!strcmp(info.sysname, "SunOS")) + { return (OSD_SUN); + } if (!strcmp(info.sysname, "ULTRIX")) + { return (OSD_DEC); + } if (!strncmp(info.sysname, "IRIX", 4)) + { return (OSD_SGI); + } if (!strcmp(info.sysname, "HP-UX")) + { return (OSD_HP); + } if (!strcmp(info.sysname, "UNIX_System_V")) + { return (OSD_NEC); + } if (!strcmp(info.sysname, "VMS_POSIX")) + { return (OSD_VAX); + } if (!strncmp(info.sysname, "OSF", 3)) + { return (OSD_DEC); + } if (!strncmp(info.sysname, "Linux", 5)) + { return (OSD_LIN); + } if (!strcmp(info.sysname, "FreeBSD")) + { return (OSD_LIN); + } if (!strncmp(info.sysname, "AIX", 3)) + { return (OSD_AIX); + } if (!strcmp(info.sysname, "Darwin")) + { return (OSD_MAC); + } return (OSD_Unavailable); } diff --git a/src/FoundationClasses/TKernel/OSD/OSD_MemInfo.cxx b/src/FoundationClasses/TKernel/OSD/OSD_MemInfo.cxx index 6119b225f2..99b82ee858 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_MemInfo.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_MemInfo.cxx @@ -229,13 +229,17 @@ void OSD_MemInfo::Update() else if (IsActive(MemPrivate) && strncmp(aBuff, "VmData:", strlen("VmData:")) == 0) { if (myCounters[MemPrivate] == size_t(-1)) + { ++myCounters[MemPrivate]; + } myCounters[MemPrivate] += atol(aBuff + strlen("VmData:")) * 1024; } else if (IsActive(MemPrivate) && strncmp(aBuff, "VmStk:", strlen("VmStk:")) == 0) { if (myCounters[MemPrivate] == size_t(-1)) + { ++myCounters[MemPrivate]; + } myCounters[MemPrivate] += atol(aBuff + strlen("VmStk:")) * 1024; } } diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Path.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Path.cxx index 22bd052c15..a39c0c848a 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Path.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Path.cxx @@ -88,7 +88,9 @@ static void VmsExtract(const TCollection_AsciiString& what, buffer.Remove(1, node.Length()); } else + { node = ""; + } username = buffer.Token("\" "); buffer.Remove(1, username.Length() + 2); // Removes <<"username ' ' or '"' >> @@ -101,7 +103,9 @@ static void VmsExtract(const TCollection_AsciiString& what, // If we found a node then we must find "::" if (buffer.Search("::") != -1) + { buffer.Remove(1, 2); // Removes <<::>> + } } else // No name or password if (buffer.Search("::") != -1) @@ -116,7 +120,9 @@ static void VmsExtract(const TCollection_AsciiString& what, buffer.Remove(1, disk.Length() + 1); // Removes <> } else + { disk = ""; + } // Analyse trek @@ -125,9 +131,13 @@ static void VmsExtract(const TCollection_AsciiString& what, trek = buffer.Token("[]"); if (trek.Value(1) == '.') + { trek.Remove(1, 1); // Removes first '.' + } else + { trek.Insert(1, '|'); // Add root + } trek.ChangeAll('.', '|'); // Translates to portable syntax trek.ChangeAll('-', '^'); @@ -137,13 +147,17 @@ static void VmsExtract(const TCollection_AsciiString& what, { trek.Remove(pos, 6); // on VMS [000000] is the root if (trek.Search("||") != -1) + { trek.Remove(1, 1); // When [000000.xxx] -> ||xxx + } } name = buffer.Token("]", 2); } else + { name = buffer; + } if (name.Search(".") != -1) { @@ -152,7 +166,9 @@ static void VmsExtract(const TCollection_AsciiString& what, name.Remove(name.Search("."), ext.Length()); } else + { ext = ""; + } } //================================================================================================= @@ -199,7 +215,9 @@ static void UnixExtract(const TCollection_AsciiString& what, buffer.Remove(1, node.Length() + 1); // Removes << node: >> } else + { node = ""; + } username = ""; password = ""; @@ -215,7 +233,9 @@ static void UnixExtract(const TCollection_AsciiString& what, p = (Standard_PCharacter)trek.ToCString(); name = &p[pos]; if (name.Length()) + { trek.Remove(pos + 1, name.Length()); + } } else { // No '|' means no trek but a name @@ -232,8 +252,10 @@ static void UnixExtract(const TCollection_AsciiString& what, } pos = name.SearchFromEnd("."); // LD : debug - if (pos != -1) // There is an extension to extract + if (pos != -1) + { // There is an extension to extract ext = name.Split(pos - 1); + } // if (name.Search(".") != -1){ // There is an extension to extract // if ( name.Value(1) == '.' ) { @@ -290,7 +312,9 @@ static void DosExtract(const TCollection_AsciiString& what, p = (Standard_PCharacter)trek.ToCString(); name = &p[pos]; if (name.Length()) + { trek.Remove(pos + 1, name.Length()); + } } else { // No '|' means no trek but a name @@ -299,8 +323,10 @@ static void DosExtract(const TCollection_AsciiString& what, } pos = name.SearchFromEnd("."); - if (pos != -1) // There is an extension to extract + if (pos != -1) + { // There is an extension to extract ext = name.Split(pos - 1); + } } //================================================================================================= @@ -448,7 +474,9 @@ void OSD_Path::UpTrek() int length = TrekLength(); if (length == 0) + { return; + } int awhere, aHowmany; TCollection_AsciiString tok; @@ -460,7 +488,9 @@ void OSD_Path::UpTrek() awhere = myTrek.Search("||"); // Searches leaving "||" if (awhere != -1) + { myTrek.Remove(awhere); + } } void OSD_Path::DownTrek(const TCollection_AsciiString& aName) @@ -468,15 +498,19 @@ void OSD_Path::DownTrek(const TCollection_AsciiString& aName) myTrek += aName; // Pb signale par GG : pour ne pas avoir "||" ; if (aName.ToCString()[aName.Length() - 1] != '|') + { myTrek += "|"; + } } int OSD_Path::TrekLength() const { int cpt = 0; - while (myTrek.Token("|", cpt + 1) != "") // Counts token separated by '|' + while (myTrek.Token("|", cpt + 1) != "") + { // Counts token separated by '|' cpt++; + } return (cpt); } @@ -486,7 +520,9 @@ void OSD_Path::RemoveATrek(const int thewhere) int length = TrekLength(); if (length <= 0 || thewhere > length) + { throw Standard_NumericError("OSD_Path::RemoveATrek : where has an invalid value"); + } int posit, aHowmany; TCollection_AsciiString tok; @@ -498,7 +534,9 @@ void OSD_Path::RemoveATrek(const int thewhere) posit = myTrek.Search("||"); // Searches leaving "||" if (posit != -1) + { myTrek.Remove(posit); + } } void OSD_Path::RemoveATrek(const TCollection_AsciiString& aName) @@ -506,7 +544,9 @@ void OSD_Path::RemoveATrek(const TCollection_AsciiString& aName) int length = TrekLength(); if (length == 0) + { return; + } int awhere; @@ -517,7 +557,9 @@ void OSD_Path::RemoveATrek(const TCollection_AsciiString& aName) awhere = myTrek.Search("||"); // Searches leaving "||" if (awhere != -1) + { myTrek.Remove(awhere); + } } } @@ -526,7 +568,9 @@ TCollection_AsciiString OSD_Path::TrekValue(const int thewhere) const TCollection_AsciiString result = myTrek.Token("|", thewhere); if (result == "") + { throw Standard_NumericError("OSD_Path::TrekValue : where is invalid"); + } return (result); } @@ -536,7 +580,9 @@ void OSD_Path::InsertATrek(const TCollection_AsciiString& aName, const int thewh int length = TrekLength(); if (thewhere <= 0 || thewhere > length) + { throw Standard_NumericError("OSD_Path::InsertATrek : where has an invalid value"); + } TCollection_AsciiString tok = myTrek.Token("|", thewhere); int wwhere = myTrek.Search(tok); @@ -562,15 +608,25 @@ static void P2VMS(TCollection_AsciiString& Way) int length = Way.Length(); if (length == 0) + { return; + } - if (Way.Value(1) == '|') // If begin with '|' remove '|' + if (Way.Value(1) == '|') + { // If begin with '|' remove '|' if (Way.Value(1) != '\0') + { Way.Remove(1, 1); + } else + { Way = "000000"; // Si uniquement la racine -> [000000] + } + } else if (Way.Length() != 0) + { Way.Insert(1, '|'); // Else insert '|' at beginning if not empty; + } Way.ChangeAll('|', '.'); Way.ChangeAll('^', '-'); @@ -584,7 +640,8 @@ static void P2MAC(TCollection_AsciiString& Way) Way.ChangeAll('|', ':'); l = (int)Way.Length(); - for (i = 1; i <= l; i++) // Replace '^' by "::" + for (i = 1; i <= l; i++) + { // Replace '^' by "::" if (Way.Value(i) == '^') { Way.SetValue(i, ':'); @@ -592,6 +649,7 @@ static void P2MAC(TCollection_AsciiString& Way) i++; l++; } + } } // Convert a Trek to UNIX syntax @@ -602,7 +660,9 @@ static void P2UNIX(TCollection_AsciiString& Way) int length = Way.Length(); if (length == 0) + { return; + } // if (Way.Value(length) == '|') // If Finishes with "|" removes it // Way.Trunc(length-1); @@ -610,7 +670,8 @@ static void P2UNIX(TCollection_AsciiString& Way) Way.ChangeAll('|', '/'); l = (int)Way.Length(); - for (i = 1; i <= l; i++) // Replace '^' by "../" + for (i = 1; i <= l; i++) + { // Replace '^' by "../" if (Way.Value(i) == '^') { Way.SetValue(i, '.'); @@ -619,6 +680,7 @@ static void P2UNIX(TCollection_AsciiString& Way) i += 1; l += 1; } + } } // Convert a Trek to DOS like syntax @@ -629,15 +691,20 @@ static void P2DOS(TCollection_AsciiString& Way) int len = Way.Length(); if (len == 0) + { return; + } - if (Way.Value(len) == '|') // If Finishes with "|" removes it + if (Way.Value(len) == '|') + { // If Finishes with "|" removes it Way.Trunc(len - 1); + } Way.ChangeAll('|', '\\'); l = (int)Way.Length(); - for (i = 1; i <= l; i++) // Replace '^' by ".." + for (i = 1; i <= l; i++) + { // Replace '^' by ".." if (Way.Value(i) == '^') { Way.SetValue(i, '.'); @@ -645,6 +712,7 @@ static void P2DOS(TCollection_AsciiString& Way) i++; l++; } + } } // Convert a path to system dependent syntax @@ -676,7 +744,9 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a P2VMS(Way); // Convert path if (myNode.Length() != 0) + { FullName += myNode; // Append Node + } if (myUserName.Length() != 0) { // Append User name @@ -700,7 +770,9 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a } if (pNode.Length() != 0) + { FullName += "::"; + } if (myDisk.Length() != 0) { // Append Disk @@ -708,8 +780,10 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a FullName += ":"; } - if (Way.Length() != 0) // Append VMS path + if (Way.Length() != 0) + { // Append VMS path FullName = FullName + "[" + Way + "]" + myName + myExtension; + } // FullName.UpperCase(); break; @@ -721,6 +795,7 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a P2DOS(Way); if (length != 1) + { if (myDisk.Length() != 0) { @@ -732,7 +807,9 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a { FullName += myDisk; if (myDisk.Value(length) != ':') + { FullName += ":"; + } } else // This is an assigned Disk { @@ -741,12 +818,17 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a VMSDisk2Other(pDisk); FullName += pDisk; if (Way.Value(1) != '\\') + { FullName += "\\"; + } } } + } if (Way.Length() != 0) + { FullName = FullName + Way + "\\"; + } FullName += myName; FullName += myExtension; @@ -776,7 +858,9 @@ void OSD_Path::SystemName(TCollection_AsciiString& FullName, const OSD_SysType a FullName += myUserName; // appends user name if (myPassword.Length() != 0) + { FullName = FullName + "\"" + myPassword + "\""; // a password if not empty + } FullName += "@"; // and character '@' } @@ -1540,12 +1624,18 @@ static int RemoveExtraSeparator(TCollection_AsciiString& aString) char c = aString.Value(j); aString.SetValue(i, c); if (c == '/') + { while (j < len && aString.Value(j + 1) == '/') + { j++; + } + } } len = i - 1; if (aString.Value(len) == '/') + { len--; + } aString.Trunc(len); return len; } @@ -1566,16 +1656,22 @@ TCollection_AsciiString OSD_Path::RelativePath(const TCollection_AsciiString& aD { // Cas WNT Wnt = true; if (FilePath.Search(":") != 2 || UpperCase(aDirPath.Value(1)) != UpperCase(FilePath.Value(1))) + { return EmptyString; + } FilePath.ChangeAll('\\', '/'); if (FilePath.Search("/") != 3) + { return EmptyString; + } } else { // Cas Unix if (aDirPath.Value(1) != '/' || FilePath.Value(1) != '/') + { return EmptyString; + } } // Eliminer les separateurs redondants @@ -1585,7 +1681,9 @@ TCollection_AsciiString OSD_Path::RelativePath(const TCollection_AsciiString& aD if (!Wnt) { if (len < 2) + { return EmptyString; + } FilePath = FilePath.SubString(2, len); } TCollection_AsciiString DirToken, FileToken; @@ -1595,7 +1693,9 @@ TCollection_AsciiString OSD_Path::RelativePath(const TCollection_AsciiString& aD { DirToken = aDirPath.Token("/\\", n); if (DirToken.IsEmpty()) + { return FilePath; + } if (!Sibling) { @@ -1604,7 +1704,9 @@ TCollection_AsciiString OSD_Path::RelativePath(const TCollection_AsciiString& aD if (i > 0) { if (i == len) + { return EmptyString; + } FileToken = FilePath.SubString(1, i - 1); if (Wnt) @@ -1619,10 +1721,13 @@ TCollection_AsciiString OSD_Path::RelativePath(const TCollection_AsciiString& aD } } else if (DirToken == FilePath) + { return EmptyString; - + } else + { Sibling = true; + } } FilePath.Insert(1, "../"); } @@ -1635,15 +1740,21 @@ TCollection_AsciiString OSD_Path::AbsolutePath(const TCollection_AsciiString& aD { TCollection_AsciiString EmptyString = ""; if (aRelFilePath.Search("/") == 1 || aRelFilePath.Search(":") == 2) + { return aRelFilePath; + } TCollection_AsciiString DirPath = aDirPath, RelFilePath = aRelFilePath; int i, len; if (DirPath.Search("/") != 1 && DirPath.Search(":") != 2) + { return EmptyString; + } if (DirPath.Search(":") == 2) + { DirPath.ChangeAll('\\', '/'); + } RelFilePath.ChangeAll('\\', '/'); RemoveExtraSeparator(DirPath); len = RemoveExtraSeparator(RelFilePath); @@ -1651,14 +1762,20 @@ TCollection_AsciiString OSD_Path::AbsolutePath(const TCollection_AsciiString& aD while (RelFilePath.Search("../") == 1) { if (len == 3) + { return EmptyString; + } RelFilePath = RelFilePath.SubString(4, len); len -= 3; if (DirPath.IsEmpty()) + { return EmptyString; + } i = DirPath.SearchFromEnd("/"); if (i < 0) + { return EmptyString; + } DirPath.Trunc(i - 1); } DirPath += '/'; diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Process.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Process.cxx index 4a56523c70..dd9bc29e4f 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Process.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Process.cxx @@ -77,7 +77,9 @@ Quantity_Date OSD_Process::SystemDate() status = gettimeofday(&tval, &tzone); if (status == -1) + { myError.SetValue(errno, Iam, "GetSystem"); + } else { memcpy(&transfert, localtime((time_t*)&tval.tv_sec), sizeof(struct tm)); @@ -121,7 +123,9 @@ OSD_Path OSD_Process::CurrentDirectory() TCollection_AsciiString Name; if (!getcwd(cwd, MAXPATHLEN + 1)) + { myError.SetValue(errno, Iam, "Where"); + } else { Name = cwd; @@ -164,7 +168,9 @@ void OSD_Process::SetCurrentDirectory(const OSD_Path& where) status = chdir(Name.ToCString()); if (status == -1) + { myError.SetValue(errno, Iam, "Move to directory"); + } } void OSD_Process::Reset() diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Protection.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Protection.cxx index 12cb6e0b5b..f54310328d 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Protection.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Protection.cxx @@ -680,40 +680,72 @@ int OSD_Protection::Internal() const int internal_prot = 0; if (u & OSD_R) + { internal_prot |= S_IRUSR; + } if (u & OSD_W) + { internal_prot |= S_IWUSR; + } if (u & OSD_D) + { internal_prot |= S_IWUSR; + } if (u & OSD_X) + { internal_prot |= S_IXUSR; + } if (g & OSD_R) + { internal_prot |= S_IRGRP; + } if (g & OSD_W) + { internal_prot |= S_IWGRP; + } if (g & OSD_D) + { internal_prot |= S_IWGRP; + } if (g & OSD_X) + { internal_prot |= S_IXGRP; + } if (w & OSD_R) + { internal_prot |= S_IROTH; + } if (w & OSD_W) + { internal_prot |= S_IWOTH; + } if (w & OSD_D) + { internal_prot |= S_IWOTH; + } if (w & OSD_X) + { internal_prot |= S_IXOTH; + } if (s & OSD_R) + { internal_prot |= S_IROTH; + } if (s & OSD_W) + { internal_prot |= S_IWOTH; + } if (s & OSD_D) + { internal_prot |= S_IWOTH; + } if (s & OSD_X) + { internal_prot |= S_IXOTH; + } return (internal_prot); } diff --git a/src/FoundationClasses/TKernel/OSD/OSD_Thread.cxx b/src/FoundationClasses/TKernel/OSD/OSD_Thread.cxx index b3cb7275e2..6b3df6f505 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_Thread.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_Thread.cxx @@ -152,7 +152,9 @@ bool OSD_Thread::Run(void* const data, ) { if (!myFunc) + { return false; + } // detach current thread, if open Detach(); @@ -209,7 +211,9 @@ void OSD_Thread::Detach() // On Unix/Linux, detach a thread if (myThread) + { pthread_detach(myThread); + } #endif diff --git a/src/FoundationClasses/TKernel/OSD/OSD_signal.cxx b/src/FoundationClasses/TKernel/OSD/OSD_signal.cxx index 11b7077691..66c6002dff 100644 --- a/src/FoundationClasses/TKernel/OSD/OSD_signal.cxx +++ b/src/FoundationClasses/TKernel/OSD/OSD_signal.cxx @@ -802,7 +802,9 @@ static void Handler(const int theSignal) { // std::cout << " signal is " << theSignal << " handler is " << oldact.sa_handler << std::endl; if (sigaction(theSignal, &oldact, &act)) + { perror("sigaction"); + } } else { @@ -813,7 +815,9 @@ static void Handler(const int theSignal) // std::endl ; ACT_SIGIO_HANDLER* aSigHandler = ADR_ACT_SIGIO_HANDLER.load(std::memory_order_acquire); if (aSigHandler != nullptr) + { (*aSigHandler)(); + } sigset_t set; sigemptyset(&set); @@ -1099,7 +1103,7 @@ void OSD::SetSignal(OSD_SignalMode theSignalMode, bool theFloatingSignal) Standard_ASSERT(retcode == 0, "sigaction() failed", std::cout << "OSD::SetSignal(): sigaction() failed for " << aSignalTypes[i] - << std::endl); + << '\n'); } } diff --git a/src/FoundationClasses/TKernel/Plugin/Plugin.cxx b/src/FoundationClasses/TKernel/Plugin/Plugin.cxx index f1967dd20c..20a228776b 100644 --- a/src/FoundationClasses/TKernel/Plugin/Plugin.cxx +++ b/src/FoundationClasses/TKernel/Plugin/Plugin.cxx @@ -66,9 +66,11 @@ occ::handle Plugin::Load(const Standard_GUID& aGUID, const b { Standard_SStream aMsg; aMsg << "could not find the resource:"; - aMsg << theResource.ToCString() << std::endl; + aMsg << theResource.ToCString() << '\n'; if (theVerbose) - std::cout << "could not find the resource:" << theResource.ToCString() << std::endl; + { + std::cout << "could not find the resource:" << theResource.ToCString() << '\n'; + } throw Plugin_Failure(aMsg.str().c_str()); } @@ -96,8 +98,10 @@ occ::handle Plugin::Load(const Standard_GUID& aGUID, const b aMsg << "; reason:"; aMsg << error.ToCString(); if (theVerbose) + { std::cout << "could not open: " << PluginResource->Value(theResource.ToCString()) - << " ; reason: " << error.ToCString() << std::endl; + << " ; reason: " << error.ToCString() << '\n'; + } throw Plugin_Failure(aMsg.str().c_str()); } f = theSharedLibrary.DlSymb("PLUGINFACTORY"); diff --git a/src/FoundationClasses/TKernel/Quantity/Quantity_Color.cxx b/src/FoundationClasses/TKernel/Quantity/Quantity_Color.cxx index 0be82024cd..4bc889eb55 100644 --- a/src/FoundationClasses/TKernel/Quantity/Quantity_Color.cxx +++ b/src/FoundationClasses/TKernel/Quantity/Quantity_Color.cxx @@ -411,9 +411,13 @@ double Quantity_Color::DeltaE2000(const Quantity_Color& theOther) const double ah1x = (aC1x > Epsilon() ? std::atan2(ab1, aa1x) * RAD_TO_DEG : 270.); double ah2x = (aC2x > Epsilon() ? std::atan2(ab2, aa2x) * RAD_TO_DEG : 270.); if (ah1x < 0.) + { ah1x += 360.; + } if (ah2x < 0.) + { ah2x += 360.; + } double aHx_mean = 0.5 * (ah1x + ah2x); double aDeltahx = ah2x - ah1x; if (std::abs(aDeltahx) > 180.) @@ -595,16 +599,22 @@ NCollection_Vec3 Quantity_Color::Convert_sRGB_To_HLS( // compute minimum from RGB components float min = theRgb.r(); if (theRgb.g() < min) + { min = theRgb.g(); + } if (theRgb.b() < min) + { min = theRgb.b(); + } const float aDelta = aMax - min; // compute saturation float aSaturation = 0.0f; if (aMax != 0.0f) + { aSaturation = aDelta / aMax; + } // compute hue float aHue = RGBHLS_H_UNDEFINED; @@ -612,7 +622,9 @@ NCollection_Vec3 Quantity_Color::Convert_sRGB_To_HLS( { aHue = 60.0f * (aPlus + aDiff / aDelta); if (aHue < 0.0f) + { aHue += 360.0f; + } } return NCollection_Vec3(aHue, aMax, aSaturation); } @@ -729,7 +741,9 @@ NCollection_Vec3 Quantity_Color::Convert_Lab_To_Lch( double aH = (aC > Epsilon() ? std::atan2(ab, aa) * RAD_TO_DEG : 0.); if (aH < 0.) + { aH += 360.; + } return NCollection_Vec3(theLab[0], (float)aC, (float)aH); } diff --git a/src/FoundationClasses/TKernel/Quantity/Quantity_Date.cxx b/src/FoundationClasses/TKernel/Quantity/Quantity_Date.cxx index 85b8849d9f..da3471c041 100644 --- a/src/FoundationClasses/TKernel/Quantity/Quantity_Date.cxx +++ b/src/FoundationClasses/TKernel/Quantity/Quantity_Date.cxx @@ -80,28 +80,44 @@ bool Quantity_Date::IsValid(const int mm, { if (mm < 1 || mm > 12) + { return false; + } if (yy < 1979) + { return false; + } if (dd < 1 || dd > getDaysInMonth(mm, yy)) + { return false; + } if (hh < 0 || hh > 23) + { return false; + } if (mn < 0 || mn > 59) + { return false; + } if (ss < 0 || ss > 59) + { return false; + } if (mis < 0 || mis > 999) + { return false; + } if (mics < 0 || mics > 999) + { return false; + } return true; } @@ -144,16 +160,22 @@ void Quantity_Date::SetValues(const int mm, int i; if (!Quantity_Date::IsValid(mm, dd, yy, hh, mn, ss, mis, mics)) + { throw Quantity_DateDefinitionError("Quantity_Date::Quantity_Date invalid parameters"); + } mySec = 0; myUSec = 0; for (i = 1979; i < yy; i++) { if (!Quantity_Date::IsLeap(i)) + { mySec += SecondsByYear; + } else + { mySec += SecondsByLeapYear; + } } for (i = 1; i < mm; i++) @@ -196,16 +218,24 @@ void Quantity_Date::Values(int& mm, if (!Quantity_Date::IsLeap(yy)) { if (carry >= SecondsByYear) + { carry -= SecondsByYear; + } else + { break; + } } else { if (carry >= SecondsByLeapYear) + { carry -= SecondsByLeapYear; + } else + { break; + } } } @@ -213,9 +243,13 @@ void Quantity_Date::Values(int& mm, { int i = getDaysInMonth(mm, yy) * SECONDS_PER_DAY; if (carry >= i) + { carry -= i; + } else + { break; + } } // Extract day within the month @@ -287,8 +321,10 @@ Quantity_Date Quantity_Date::Subtract(const Quantity_Period& During) normalizeSubtractionBorrow(result.mySec, result.myUSec); if (result.mySec < 0) + { throw Quantity_DateDefinitionError( "Quantity_Date::Subtract : The result date is anterior to Jan,1 1979"); + } return (result); } diff --git a/src/FoundationClasses/TKernel/Quantity/Quantity_Period.cxx b/src/FoundationClasses/TKernel/Quantity/Quantity_Period.cxx index 09ddc25889..589ce4c8b8 100644 --- a/src/FoundationClasses/TKernel/Quantity/Quantity_Period.cxx +++ b/src/FoundationClasses/TKernel/Quantity/Quantity_Period.cxx @@ -128,7 +128,9 @@ void Quantity_Period::SetValues(const int ss, const int mics) { if (!Quantity_Period::IsValid(ss, mics)) + { throw Quantity_PeriodDefinitionError("Quantity_Period::SetValues invalid parameters"); + } mySec = ss; myUSec = mics; diff --git a/src/FoundationClasses/TKernel/Resource/Resource_Manager.cxx b/src/FoundationClasses/TKernel/Resource/Resource_Manager.cxx index 3cb4e52b33..06ee6c0ac5 100644 --- a/src/FoundationClasses/TKernel/Resource/Resource_Manager.cxx +++ b/src/FoundationClasses/TKernel/Resource/Resource_Manager.cxx @@ -78,7 +78,7 @@ Resource_Manager::Resource_Manager(const TCollection_AsciiString& theName, } else if (myVerbose) { - std::cout << "Resource Manager Warning: aDefaultsDirectory is empty." << std::endl; + std::cout << "Resource Manager Warning: aDefaultsDirectory is empty." << '\n'; } if (!theUserDefaultsDirectory.IsEmpty()) @@ -96,7 +96,7 @@ Resource_Manager::Resource_Manager(const TCollection_AsciiString& theName, } else if (myVerbose) { - std::cout << "Resource Manager Warning: anUserDefaultsDirectory is empty." << std::endl; + std::cout << "Resource Manager Warning: anUserDefaultsDirectory is empty." << '\n'; } } @@ -112,23 +112,33 @@ Resource_Manager::Resource_Manager(const char* const aName, const bool Verbose) OSD_Environment envVerbose("CSF_ResourceVerbose"); if (!envVerbose.Value().IsEmpty()) + { myVerbose = true; + } TCollection_AsciiString aPath, aUserPath; GetResourcePath(aPath, aName, false); GetResourcePath(aUserPath, aName, true); if (!aPath.IsEmpty()) + { Load(aPath, myRefMap); + } else if (myVerbose) + { std::cout << "Resource Manager Warning: Environment variable \"CSF_" << aName - << "Defaults\" not set." << std::endl; + << "Defaults\" not set." << '\n'; + } if (!aUserPath.IsEmpty()) + { Load(aUserPath, myRefMap); + } else if (myVerbose) + { std::cout << "Resource Manager Warning: Environment variable \"CSF_" << aName - << "UserDefaults\" not set." << std::endl; + << "UserDefaults\" not set." << '\n'; + } } //================================================================================================= @@ -155,8 +165,10 @@ void Resource_Manager::Load( if (File.Failed()) { if (myVerbose) + { std::cout << "Resource Manager Warning: Cannot read file \"" << FileName - << "\". File not found or permission denied." << std::endl; + << "\". File not found or permission denied." << '\n'; + } return; } myInitialized = true; @@ -171,20 +183,26 @@ void Resource_Manager::Load( break; case Resource_KOL_Resource: if (!aMap.Bind(Token1, Token2)) + { aMap(Token1) = Token2; + } break; case Resource_KOL_Error: if (myVerbose) + { std::cout << "Resource Manager: Syntax error at line " << LineNumber - << " in file : " << FileName << std::endl; + << " in file : " << FileName << '\n'; + } break; } LineNumber++; } File.Close(); if (myVerbose) + { std::cout << "Resource Manager: " << ((&aMap == &myUserMap) ? "User" : "Reference") - << " file \"" << FileName << "\" loaded" << std::endl; + << " file \"" << FileName << "\" loaded" << '\n'; + } } static Resource_KindOfLine WhatKindOfLine(OSD_File& aFile, @@ -196,30 +214,43 @@ static Resource_KindOfLine WhatKindOfLine(OSD_File& aFile, TCollection_AsciiString Line; if (!GetLine(aFile, Line)) + { return Resource_KOL_End; + } if (Line.Value(1) == '!') + { return Resource_KOL_Comment; + } Pos1 = Line.FirstLocationNotInSet(WhiteSpace, 1, Line.Length()); if (Line.Value(Pos1) == '\n') + { return Resource_KOL_Empty; + } Pos2 = Line.Location(1, ':', Pos1, Line.Length()); if (!Pos2 || Pos1 == Pos2) + { return Resource_KOL_Error; + } for (Pos = Pos2 - 1; Line.Value(Pos) == '\t' || Line.Value(Pos) == ' '; Pos--) + { ; + } aToken1 = Line.SubString(Pos1, Pos); if (Debug) + { std::cout << "Key = '" << aToken1 << std::flush; + } Pos = Line.FirstLocationNotInSet(WhiteSpace, Pos2 + 1, Line.Length()); if (Pos) { if (Line.Value(Pos) == '\\') + { switch (Line.Value(Pos + 1)) { case '\\': @@ -228,9 +259,12 @@ static Resource_KindOfLine WhatKindOfLine(OSD_File& aFile, Pos++; break; } + } } if (Pos == Line.Length()) + { aToken2.Clear(); + } else { Line.Remove(1, Pos - 1); @@ -246,7 +280,9 @@ static Resource_KindOfLine WhatKindOfLine(OSD_File& aFile, aToken2 = Line; } if (Debug) - std::cout << "'\t Value = '" << aToken2 << "'" << std::endl << std::flush; + { + std::cout << "'\t Value = '" << aToken2 << "'" << '\n' << std::flush; + } return Resource_KOL_Resource; } @@ -266,9 +302,13 @@ static int GetLine(OSD_File& aFile, TCollection_AsciiString& aLine) if (aFile.IsAtEnd()) { if (!aLine.Length()) + { return 0; + } else + { aLine += "\n"; + } } } while (aLine.Value(aLine.Length()) != '\n'); @@ -292,8 +332,10 @@ bool Resource_Manager::Save() const if (dir.IsEmpty()) { if (myVerbose) + { std::cout << "Resource Manager Warning: environment variable \"" << anEnvVar - << "\" not set. Cannot save resources." << std::endl; + << "\" not set. Cannot save resources." << '\n'; + } return false; } @@ -318,8 +360,10 @@ bool Resource_Manager::Save() const if (!aStatus) { if (myVerbose) + { std::cout << "Resource Manager: Error opening or creating directory \"" << aFilePath - << "\". Permission denied. Cannot save resources." << std::endl; + << "\". Permission denied. Cannot save resources." << '\n'; + } return false; } } @@ -350,8 +394,10 @@ bool Resource_Manager::Save() const if (!aStatus) { if (myVerbose) + { std::cout << "Resource Manager: Error opening or creating file \"" << aFilePath - << "\". Permission denied. Cannot save resources." << std::endl; + << "\". Permission denied. Cannot save resources." << '\n'; + } return false; } @@ -363,7 +409,9 @@ bool Resource_Manager::Save() const int Index; for (Index = 1; Iter.More(); Iter.Next()) + { KeyArray(Index++) = Iter.Key(); + } std::sort(KeyArray.begin(), KeyArray.end()); @@ -372,6 +420,7 @@ bool Resource_Manager::Save() const { Value = myUserMap(KeyArray(Index)); if (!Value.IsEmpty()) + { switch (Value.Value(1)) { case '\\': @@ -380,15 +429,20 @@ bool Resource_Manager::Save() const Value.Insert(1, '\\'); break; } + } Line = KeyArray(Index) + ":\t" + Value + "\n"; if (Debug) - std::cout << "Line = '" << Line << "'" << std::endl; + { + std::cout << "Line = '" << Line << "'" << '\n'; + } File.Write(Line, Line.Length()); } if (myVerbose) - std::cout << "Resource Manager: Resources saved in file " << aFilePath << std::endl; + { + std::cout << "Resource Manager: Resources saved in file " << aFilePath << '\n'; + } } File.Close(); return true; @@ -439,9 +493,13 @@ const char* Resource_Manager::Value(const char* const aResource) const { TCollection_AsciiString Resource(aResource); if (myUserMap.IsBound(Resource)) + { return myUserMap(Resource).ToCString(); + } if (myRefMap.IsBound(Resource)) + { return myRefMap(Resource).ToCString(); + } throw Resource_NoSuchResource(aResource); } @@ -454,7 +512,9 @@ const char16_t* Resource_Manager::ExtValue(const char* const aResource) { TCollection_AsciiString Resource(aResource); if (myExtStrMap.IsBound(Resource)) + { return myExtStrMap(Resource).ToExtString(); + } TCollection_AsciiString Result = Value(aResource); TCollection_ExtendedString ExtResult; @@ -520,7 +580,9 @@ void Resource_Manager::SetResource(const char* const aResource, const char* cons TCollection_AsciiString Resource = aResource; TCollection_AsciiString Value = aValue; if (!myUserMap.Bind(Resource, Value)) + { myUserMap(Resource) = Value; + } } //================================================================================================= @@ -555,7 +617,9 @@ void Resource_Manager::GetResourcePath(TCollection_AsciiString& aPath, OSD_Environment anEnv(anEnvVar); dir = anEnv.Value(); if (dir.IsEmpty()) + { return; + } TCollection_AsciiString aResPath(dir); diff --git a/src/FoundationClasses/TKernel/Resource/Resource_Unicode.cxx b/src/FoundationClasses/TKernel/Resource/Resource_Unicode.cxx index 45c112a60f..ca3ff0add9 100644 --- a/src/FoundationClasses/TKernel/Resource/Resource_Unicode.cxx +++ b/src/FoundationClasses/TKernel/Resource/Resource_Unicode.cxx @@ -264,7 +264,9 @@ bool Resource_Unicode::ConvertGBKToUnicode(const char* const fromstr, currentch++; } else + { return false; + } } } return true; @@ -334,7 +336,9 @@ bool Resource_Unicode::ConvertBig5ToUnicode(const char* const fromstr, NCollection_UtfString aStr16 = aStr32.ToUtf16(); if (aStr16.Size() != 4) + { return false; // not a surrogate pair + } const char16_t* aChar16 = aStr16.ToCString(); tostr.Insert(aLength + 1, (char16_t)(*aChar16)); aChar16++; @@ -372,7 +376,9 @@ bool Resource_Unicode::ConvertBig5ToUnicode(const char* const fromstr, currentch++; } else + { return false; + } } } return true; diff --git a/src/FoundationClasses/TKernel/Standard/Standard.cxx b/src/FoundationClasses/TKernel/Standard/Standard.cxx index 4a9ac8fd3f..bddca3eb3b 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard.cxx @@ -385,7 +385,9 @@ void* Standard::Allocate(const size_t theSize) #else void* aPtr = calloc(theSize, sizeof(char)); if (!aPtr) + { throw Standard_OutOfMemory("Standard_MMgrRaw::Allocate(): malloc failed"); + } return aPtr; #endif // OCCT_MMGT_OPT_FLEXIBLE } @@ -442,7 +444,9 @@ void* Standard::Reallocate(void* theStorage, const size_t theSize) #else void* aNewStorage = (void*)realloc(theStorage, theSize); if (!aNewStorage) + { throw Standard_OutOfMemory("Standard_MMgrRaw::Reallocate(): realloc failed"); + } return aNewStorage; #endif } diff --git a/src/FoundationClasses/TKernel/Standard/Standard_Dump.cxx b/src/FoundationClasses/TKernel/Standard/Standard_Dump.cxx index 0c18953991..b097d4b62b 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_Dump.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_Dump.cxx @@ -76,7 +76,9 @@ void Standard_Dump::DumpCharacterValues(Standard_OStream& theOStream, int theCou for (int i = 0; i < theCount; ++i) { if (i > 0) + { theOStream << ", "; + } theOStream << "\"" << va_arg(vl, char*) << "\""; } va_end(vl); @@ -91,7 +93,9 @@ void Standard_Dump::DumpRealValues(Standard_OStream& theOStream, int theCount, . for (int i = 0; i < theCount; ++i) { if (i > 0) + { theOStream << ", "; + } theOStream << va_arg(vl, double); } va_end(vl); @@ -104,10 +108,14 @@ bool Standard_Dump::ProcessStreamName(const TCollection_AsciiString& theStreamSt int& theStreamPos) { if (theStreamStr.IsEmpty()) + { return false; + } if (theStreamStr.Length() < theStreamPos) + { return false; + } TCollection_AsciiString aSubText = theStreamStr.SubString(theStreamPos, theStreamStr.Length()); if (aSubText.StartsWith(JsonKeyToString(Standard_JsonKey_SeparatorValueToValue))) @@ -121,7 +129,9 @@ bool Standard_Dump::ProcessStreamName(const TCollection_AsciiString& theStreamSt + JsonKeyToString(Standard_JsonKey_SeparatorKeyToValue); bool aResult = aSubText.StartsWith(aKeyName); if (aResult) + { theStreamPos += aKeyName.Length(); + } return aResult; } @@ -133,7 +143,9 @@ bool Standard_Dump::ProcessFieldName(const TCollection_AsciiString& theStreamStr int& theStreamPos) { if (theStreamStr.IsEmpty()) + { return false; + } TCollection_AsciiString aSubText = theStreamStr.SubString(theStreamPos, theStreamStr.Length()); if (aSubText.StartsWith(JsonKeyToString(Standard_JsonKey_SeparatorValueToValue))) @@ -150,7 +162,9 @@ bool Standard_Dump::ProcessFieldName(const TCollection_AsciiString& theStreamStr bool aResult = aSubText.StartsWith(aKeyName); if (aResult) + { theStreamPos += aKeyName.Length(); + } return aResult; } @@ -241,7 +255,9 @@ TCollection_AsciiString Standard_Dump::GetPointerInfo( const bool isShortInfo) { if (thePointer.IsNull()) + { return TCollection_AsciiString(); + } return GetPointerInfo(thePointer.get(), isShortInfo); } @@ -252,12 +268,16 @@ TCollection_AsciiString Standard_Dump::GetPointerInfo(const void* thePointer, const bool isShortInfo) { if (!thePointer) + { return TCollection_AsciiString(); + } std::ostringstream aPtrStr; aPtrStr << thePointer; if (!isShortInfo) + { return aPtrStr.str().c_str(); + } TCollection_AsciiString anInfoPtr(aPtrStr.str().c_str()); for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++) @@ -290,7 +310,9 @@ TCollection_AsciiString Standard_Dump::DumpFieldToName(const TCollection_AsciiSt aName.Remove(1, 2); } else + { aName.Remove(1, 1); + } } else if (aName.Length() > 2 && ::LowerCase(aName.Value(1)) == 'm' && aName.Value(2) == 'y') { @@ -325,7 +347,9 @@ TCollection_AsciiString Standard_Dump::FormatJson(const Standard_SStream& theStr TCollection_AsciiString aStreamStr = Text(theStream); TCollection_AsciiString anIndentStr; for (int anIndentId = 0; anIndentId < theIndent; anIndentId++) + { anIndentStr.AssignCat(' '); + } TCollection_AsciiString aText; @@ -358,7 +382,9 @@ TCollection_AsciiString Standard_Dump::FormatJson(const Standard_SStream& theStr aText += '\n'; for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + { aText += anIndentStr; + } aText += aSymbol; } else if (aSymbol == '[') @@ -378,19 +404,27 @@ TCollection_AsciiString Standard_Dump::FormatJson(const Standard_SStream& theStr aText += aSymbol; aText += '\n'; for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + { aText += anIndentStr; + } if (anIndex + 1 < aStreamStr.Length() && aStreamStr.Value(anIndex + 1) == ' ') + { anIndex++; // skip empty value after comma + } } else + { aText += aSymbol; + } } else if (aSymbol == '\n') { aText += ""; // json does not support multi-lined values, skip this symbol } else + { aText += aSymbol; + } if (anIndex == aStreamStr.Length() && aSymbol != '}') { @@ -400,7 +434,9 @@ TCollection_AsciiString Standard_Dump::FormatJson(const Standard_SStream& theStr anIndentCount--; aText += '\n'; for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + { aText += anIndentStr; + } aText += aSymbol; } } @@ -419,7 +455,9 @@ bool Standard_Dump::SplitJson( { Standard_JsonKey aKey = Standard_JsonKey_None; if (!jsonKey(theStreamStr, aNextIndex, aNextIndex, aKey)) + { return false; + } bool aProcessed = false; switch (aKey) @@ -435,12 +473,16 @@ bool Standard_Dump::SplitJson( Standard_JsonKey_OpenChild, Standard_JsonKey_CloseChild); if (aClosePos == 0) + { return false; + } TCollection_AsciiString aSubStreamStr = theStreamStr.SubString(aStartIndex + JsonKeyLength(aKey), aNextIndex - 2); if (!SplitJson(aSubStreamStr, theKeyToValues)) + { return false; + } aNextIndex = aClosePos + int(JsonKeyLength(Standard_JsonKey_CloseChild)); break; @@ -452,7 +494,9 @@ bool Standard_Dump::SplitJson( break; } if (!aProcessed) + { return false; + } } return true; } @@ -468,7 +512,9 @@ NCollection_List Standard_Dump::HierarchicalValueIndices( for (int anIndex = 1; anIndex <= theValues.Extent(); anIndex++) { if (HasChildKey(theValues.FindFromIndex(anIndex))) + { anIndices.Append(anIndex); + } } return anIndices; } @@ -487,7 +533,9 @@ bool Standard_Dump::splitKeyToValue( int aCloseIndex = nextClosePosition(theStreamStr, aStartIndex + 1, Standard_JsonKey_None, Standard_JsonKey_Quote); if (aCloseIndex == 0) + { return false; + } TCollection_AsciiString aSplitKey = theStreamStr.SubString(aStartIndex, aCloseIndex - 1); @@ -495,7 +543,9 @@ bool Standard_Dump::splitKeyToValue( aStartIndex = aCloseIndex + 1; Standard_JsonKey aKey = Standard_JsonKey_None; if (!jsonKey(theStreamStr, aStartIndex, aCloseIndex, aKey)) + { return false; + } // find value aStartIndex = aCloseIndex; @@ -513,7 +563,9 @@ bool Standard_Dump::splitKeyToValue( Standard_JsonKey_OpenChild, Standard_JsonKey_CloseChild); if (aCloseIndex > aStartIndex) + { aSplitValue = theStreamStr.SubString(aStartIndex, aCloseIndex); + } theNextIndex = aCloseIndex + 1; break; } @@ -523,7 +575,9 @@ bool Standard_Dump::splitKeyToValue( Standard_JsonKey_OpenContainer, Standard_JsonKey_CloseContainer); if (aCloseIndex > aStartIndex) + { aSplitValue = theStreamStr.SubString(aStartIndex, aCloseIndex - 1); + } theNextIndex = aCloseIndex + 1; break; } @@ -613,7 +667,9 @@ bool Standard_Dump::jsonKey(const TCollection_AsciiString& theStreamStr, Standard_JsonKey aKey = (Standard_JsonKey)aKeyId; const char* aKeyToStr = JsonKeyToString(aKey); if (!aSubStreamStr.StartsWith(aKeyToStr)) + { continue; + } theNextIndex = theStartIndex + int(JsonKeyLength(aKey)); theKey = aKey; @@ -685,7 +741,9 @@ int Standard_Dump::nextClosePosition(const TCollection_AsciiString& theSourceVal int anOpenKeyPos = theSourceValue.Location(anOpenKey, aStartPos, theSourceValue.Length()); int aCloseKeyPos = theSourceValue.Location(aCloseKeyStr, aStartPos, theSourceValue.Length()); if (aCloseKeyPos == 0) + { break; + } if (anOpenKeyPos != 0 && anOpenKeyPos <= aCloseKeyPos) { @@ -695,7 +753,9 @@ int Standard_Dump::nextClosePosition(const TCollection_AsciiString& theSourceVal else { if (aDepthKey == 0) + { return aCloseKeyPos; + } else { aDepthKey--; diff --git a/src/FoundationClasses/TKernel/Standard/Standard_ErrorHandler.cxx b/src/FoundationClasses/TKernel/Standard/Standard_ErrorHandler.cxx index 2308a99a8f..1ba52391bb 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_ErrorHandler.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_ErrorHandler.cxx @@ -80,7 +80,7 @@ void Standard_ErrorHandler::Raise() if (std::holds_alternative(myCaughtError)) { std::cerr << "*** Abort *** an exception handler was called, but no exception object is set." - << std::endl; + << '\n'; exit(1); } @@ -115,7 +115,9 @@ Standard_ErrorHandler::Callback::~Callback() void Standard_ErrorHandler::Callback::RegisterCallback() { if (myHandler) + { return; // already registered + } // find current active exception handler Standard_ErrorHandler* aHandler = Standard_ErrorHandler::FindHandler(); @@ -126,7 +128,9 @@ void Standard_ErrorHandler::Callback::RegisterCallback() myHandler = aHandler; myNext = aHandler->myCallbackPtr; if (myNext) + { ((Standard_ErrorHandler::Callback*)myNext)->myPrev = this; + } aHandler->myCallbackPtr = this; } } @@ -134,13 +138,21 @@ void Standard_ErrorHandler::Callback::RegisterCallback() void Standard_ErrorHandler::Callback::UnregisterCallback() { if (!myHandler) + { return; + } if (myNext) + { ((Standard_ErrorHandler::Callback*)myNext)->myPrev = myPrev; + } if (myPrev) + { ((Standard_ErrorHandler::Callback*)myPrev)->myNext = myNext; + } else if (((Standard_ErrorHandler*)myHandler)->myCallbackPtr == this) + { ((Standard_ErrorHandler*)myHandler)->myCallbackPtr = (Standard_ErrorHandler::Callback*)myNext; + } myHandler = myNext = myPrev = nullptr; } #endif diff --git a/src/FoundationClasses/TKernel/Standard/Standard_GUID.cxx b/src/FoundationClasses/TKernel/Standard/Standard_GUID.cxx index 8117b5ac25..11544266f4 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_GUID.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_GUID.cxx @@ -34,10 +34,14 @@ int Standard_GUID_MatchChar(const char* const buffer, const char aChar) } if (*tmpbuffer == '\0') + { return -1; // The searched symbol wasn't found + } if (result >= 0) + { result++; + } return result; } @@ -57,7 +61,9 @@ Standard_PCharacter Standard_GUID_GetValue32(Standard_PCharacter tmpBuffer, int& my32b = (int)strtoul(strtmp, (char**)nullptr, 16); } else + { return nullptr; + } return &tmpBuffer[pos + 1]; } @@ -76,7 +82,9 @@ Standard_PCharacter Standard_GUID_GetValue16(Standard_PCharacter tmpBuffer, char my32b = (char16_t)strtoul(strtmp, (char**)nullptr, 16); } else + { return nullptr; + } // std::cout << "V16 :" << hex(my32b) << std::endl; return &tmpBuffer[pos + 1]; } @@ -101,7 +109,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) bool result = true; if (aGuid == nullptr) + { return false; + } if (strlen(aGuid) == Standard_GUID_SIZE) { @@ -116,7 +126,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) } if (aGuid[8] != '-') + { return false; + } for (i = 9; i < 13 && result; i++) { @@ -127,7 +139,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) } if (aGuid[13] != '-') + { return false; + } for (i = 14; i < 18 && result; i++) { @@ -138,7 +152,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) } if (aGuid[18] != '-') + { return false; + } for (i = 19; i < 23; i++) { @@ -149,7 +165,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) } if (aGuid[23] != '-') + { return false; + } for (i = 24; i < 36; i++) { @@ -160,7 +178,9 @@ bool Standard_GUID::CheckGUIDFormat(const char* const aGuid) } } else + { result = false; + } return result; } @@ -182,16 +202,26 @@ Standard_GUID::Standard_GUID(const char* const aGuid) char* tmpBuffer = (char*)aGuid; if (!CheckGUIDFormat(tmpBuffer)) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue32(tmpBuffer, my32b)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b1)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b2)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b3)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b1); tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b2); tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b3); @@ -224,16 +254,26 @@ Standard_GUID::Standard_GUID(const char16_t* const aGuid) tmpBuffer[i] = '\0'; if (!CheckGUIDFormat(tmpBuffer)) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue32(tmpBuffer, my32b)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b1)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b2)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } if ((tmpBuffer = Standard_GUID_GetValue16(tmpBuffer, my16b3)) == nullptr) + { throw Standard_RangeError("Invalid format of GUID"); + } tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b1); tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b2); tmpBuffer = Standard_GUID_GetValue8(tmpBuffer, my8b3); diff --git a/src/FoundationClasses/TKernel/Standard/Standard_MMgrOpt.cxx b/src/FoundationClasses/TKernel/Standard/Standard_MMgrOpt.cxx index 83c4686889..5e2d64d11d 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_MMgrOpt.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_MMgrOpt.cxx @@ -188,13 +188,17 @@ void Standard_MMgrOpt::Initialize() { // check number of pages in small blocks pools if (myNbPages < 100) + { myNbPages = 1000; + } // get system-dependent page size #ifndef _WIN32 myPageSize = getpagesize(); if (!myPageSize) + { myMMap = 0; + } #else SYSTEM_INFO SystemInfo; GetSystemInfo(&SystemInfo); @@ -255,7 +259,9 @@ void Standard_MMgrOpt::Initialize() } } if (!myMMap) + { perror("ERR_MMAP_FAIL"); + } #else myMMap = -1; #endif @@ -287,7 +293,9 @@ inline void callBack(const bool isAlloc, const size_t aSize) { if (MyPCallBackFunc) + { (*MyPCallBackFunc)(isAlloc, aStorage, aRoundSize, aSize); + } } //================================================================================================= @@ -333,7 +341,9 @@ void* Standard_MMgrOpt::Allocate(const size_t aSize) // clear block if requested if (myClear) + { memset(aStorage, 0, RoundSize); + } } // else if block size is small allocate it in pools else if (RoundSize <= myCellSize) @@ -401,10 +411,14 @@ void* Standard_MMgrOpt::Allocate(const size_t aSize) if (!aBlock) { if (Purge(false)) + { aBlock = (size_t*)calloc(RoundSizeN + BLOCK_SHIFT, sizeof(size_t)); + } // if still not succeeded, raise exception if (!aBlock) + { throw Standard_OutOfMemory("Standard_MMgrOpt::Allocate(): malloc failed"); + } } // initialize new block header by its size @@ -442,7 +456,9 @@ void Standard_MMgrOpt::Free(void* theStorage) { // safely return if attempt to free null pointer if (!theStorage) + { return; + } // get the pointer to the memory block header size_t* aBlock = GET_BLOCK(theStorage); @@ -471,7 +487,9 @@ void Standard_MMgrOpt::Free(void* theStorage) } // otherwise, we have block of big size which shall be simply released else + { FreeMemory(aBlock, RoundSize); + } } //======================================================================= @@ -571,7 +589,9 @@ int Standard_MMgrOpt::Purge(bool) { aFreeSize[iPool] = ROUNDUP_CELL(aFreeSize[iPool]); if (aFreeSize[iPool] == RPoolSize) + { aFreePools[++iLastFree] = iPool; + } } if (iLastFree == -1) { @@ -593,16 +613,22 @@ int Standard_MMgrOpt::Purge(bool) { iPool = aFreePools[j]; if (aFree >= aPools[iPool] && aFree < aPools[iPool] + PoolSizeN) + { break; + } } if (j <= iLastFree) { // remove aFree = *(size_t**)aFree; if (aPrevFree) + { *(size_t**)aPrevFree = aFree; // link to previous + } else + { myFreeList[i] = aFree; + } nbFreed++; } else @@ -624,7 +650,9 @@ int Standard_MMgrOpt::Purge(bool) { // update the pointer to the previous non-free pool if (iPool - aFreePools[j - 1] > 1) + { aPrev = aPools[iPool - 1]; + } } if (j == iLastFree || aFreePools[j + 1] - iPool > 1) { @@ -633,9 +661,13 @@ int Standard_MMgrOpt::Purge(bool) // and connect it to the list of pools that have been processed // and remain non-free if (aPrev) + { *(size_t**)aPrev = aNext; + } else + { myAllocList = aNext; + } } FreeMemory(aPools[iPool], PoolSize); } @@ -700,7 +732,9 @@ void* Standard_MMgrOpt::Reallocate(void* theStorage, const size_t theNewSize) Free(theStorage); // clear newly added part of the block if (myClear) + { memset(((char*)newStorage) + OldSize, 0, theNewSize - OldSize); + } } return newStorage; } @@ -735,7 +769,9 @@ retry: int errcode = errno; // as a last resort, try freeing some memory by calling Purge() if (Purge(false)) + { goto retry; + } // if nothing helps, raise exception throw Standard_OutOfMemory(strerror(errcode)); } @@ -804,14 +840,18 @@ retry: { // as a last resort, try freeing some memory by calling Purge() if (Purge(false)) + { goto retry; + } // if nothing helps, raise exception throw Standard_OutOfMemory("Standard_MMgrOpt::Allocate(): malloc failed"); } } // clear whole block if clearing option is set if (myClear) + { memset(aBlock, 0, Size); + } return aBlock; } @@ -840,5 +880,7 @@ void Standard_MMgrOpt::FreeMemory(void* aBlock, #endif } else + { free(aBlock); + } } diff --git a/src/FoundationClasses/TKernel/Standard/Standard_Strtod.cxx b/src/FoundationClasses/TKernel/Standard/Standard_Strtod.cxx index 8b2587a2c2..44ec12a9cd 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_Strtod.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_Strtod.cxx @@ -1215,7 +1215,9 @@ static Bigint* Balloc(int k MTd) /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ /* but this case seems very unlikely. */ if (k <= Kmax && (rv = freelist[k])) + { freelist[k] = rv->next; + } else { x = 1 << k; @@ -1254,7 +1256,9 @@ static void Bfree(Bigint* v MTd) if (v) { if (v->k > Kmax) + { FREE((void*)v); + } else { #ifdef MULTIPLE_THREADS @@ -1337,7 +1341,9 @@ static Bigint* s2b(const char* s, int nd0, int nd, ULong y9, int dplen MTd) x = (nd + 8) / 9; for (k = 0, y = 1; x > y; y <<= 1, k++) + { ; + } #ifdef Pack_32 b = Balloc(k MTa); b->x[0] = y9; @@ -1353,14 +1359,19 @@ static Bigint* s2b(const char* s, int nd0, int nd, ULong y9, int dplen MTd) { s += 9; do + { b = multadd(b, 10, *s++ - '0' MTa); - while (++i < nd0); + } while (++i < nd0); s += dplen; } else + { s += dplen + 9; + } for (; i < nd; i++) + { b = multadd(b, 10, *s++ - '0' MTa); + } return b; } @@ -1392,7 +1403,9 @@ static int hi0bits(ULong x) { k++; if (!(x & 0x40000000)) + { return 32; + } } return k; } @@ -1405,7 +1418,9 @@ static int lo0bits(ULong* y) if (x & 7) { if (x & 1) + { return 0; + } if (x & 2) { *y = x >> 1; @@ -1440,7 +1455,9 @@ static int lo0bits(ULong* y) k++; x >>= 1; if (!x) + { return 32; + } } *y = x; return k; @@ -1482,10 +1499,14 @@ static Bigint* mult(Bigint* a, Bigint* b MTd) wb = b->wds; wc = wa + wb; if (wc > a->maxwds) + { k++; + } c = Balloc(k MTa); for (x = c->x, xa = x + wc; x < xa; x++) + { *x = 0; + } xa = a->x; xae = xa + wa; xb = b->x; @@ -1564,7 +1585,9 @@ static Bigint* mult(Bigint* a, Bigint* b MTd) #endif #endif for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) + { ; + } c->wds = wc; return c; } @@ -1579,10 +1602,14 @@ static Bigint* pow5mult(Bigint* b, int k MTd) static int p05[3] = {5, 25, 125}; if ((i = k & 3)) + { b = multadd(b, p05[i - 1], 0 MTa); + } if (!(k >>= 2)) + { return b; + } #ifdef MULTIPLE_THREADS if (!(TI = *PTI)) *PTI = TI = get_TI(); @@ -1616,7 +1643,9 @@ static Bigint* pow5mult(Bigint* b, int k MTd) b = b1; } if (!(k >>= 1)) + { break; + } if (!(p51 = p5->next)) { #ifdef MULTIPLE_THREADS @@ -1655,11 +1684,15 @@ static Bigint* lshift(Bigint* b, int k MTd) k1 = b->k; n1 = n + b->wds + 1; for (i = b->maxwds; n1 > i; i <<= 1) + { k1++; + } b1 = Balloc(k1 MTa); x1 = b1->x; for (i = 0; i < n; i++) + { *x1++ = 0; + } x = b->x; xe = x + b->wds; #ifdef Pack_32 @@ -1673,7 +1706,9 @@ static Bigint* lshift(Bigint* b, int k MTd) z = *x++ >> k1; } while (x < xe); if ((*x1 = z)) + { ++n1; + } } #else if (k &= 0xf) @@ -1690,9 +1725,12 @@ static Bigint* lshift(Bigint* b, int k MTd) } #endif else + { do + { *x1++ = *x++; - while (x < xe); + } while (x < xe); + } b1->wds = n1 - 1; Bfree(b MTa); return b1; @@ -1712,7 +1750,9 @@ static int cmp(Bigint* a, Bigint* b) Bug("cmp called with b->x[b->wds-1] == 0"); #endif if (i -= j) + { return i; + } xa0 = a->x; xa = xa0 + j; xb0 = b->x; @@ -1720,9 +1760,13 @@ static int cmp(Bigint* a, Bigint* b) for (;;) { if (*--xa != *--xb) + { return *xa < *xb ? -1 : 1; + } if (xa <= xa0) + { break; + } } return 0; } @@ -1757,7 +1801,9 @@ static Bigint* diff(Bigint* a, Bigint* b MTd) i = 1; } else + { i = 0; + } c = Balloc(a->k MTa); c->sign = i; wa = a->wds; @@ -1815,7 +1861,9 @@ static Bigint* diff(Bigint* a, Bigint* b MTd) #endif #endif while (!*--xc) + { wa--; + } c->wds = wa; return c; } @@ -1962,7 +2010,9 @@ static Bigint* d2b(U* d, int* e, int* bits MTd) #endif #else if ((de = (int)(d0 >> Exp_shift))) + { z |= Exp_msk1; + } #endif #ifdef Pack_32 if ((y = d1)) @@ -1973,7 +2023,9 @@ static Bigint* d2b(U* d, int* e, int* bits MTd) z >>= k; } else + { x[0] = y; + } #ifndef Sudden_Underflow i = #endif @@ -2098,7 +2150,9 @@ static double ratio(Bigint* a, Bigint* b) } #else if (k > 0) + { word0(&da) += k * Exp_msk1; + } else { k = -k; @@ -2213,9 +2267,13 @@ static int match(const char** sp, const char* t) while ((d = *t++)) { if ((c = *++s) >= 'A' && c <= 'Z') + { c += 'a' - 'A'; + } if (c != d) + { return 0; + } } *sp = s + 1; return 1; @@ -2235,13 +2293,19 @@ static void hexnan(U* rvp, const char** sp) s = *sp; /* allow optional initial 0x or 0X */ while ((c = *(const unsigned char*)(s + 1)) && c <= ' ') + { ++s; + } if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) + { s += 2; + } while ((c = *(const unsigned char*)++s)) { if ((c1 = hexdig[c])) + { c = c1 & 0xf; + } else if (c <= ' ') { if (udx0 && havedig) @@ -2281,7 +2345,9 @@ static void hexnan(U* rvp, const char** sp) x[1] = 0; } if (udx0) + { x[0] = (x[0] << 4) | (x[1] >> 28); + } x[1] = (x[1] << 4) | c; } if ((x[0] &= 0xfffff) || x[1]) @@ -2358,14 +2424,22 @@ static void rshift(Bigint* b, int k) y = *x++ >> k; } if ((*x1 = y) != 0) + { x1++; + } } else + { while (x < xe) + { *x1++ = *x++; + } + } } if ((b->wds = int(x1 - b->x)) == 0) + { b->x[0] = 0; + } } static ULong any_on(Bigint* b, int k) @@ -2377,20 +2451,28 @@ static ULong any_on(Bigint* b, int k) nwds = b->wds; n = k >> kshift; if (n > nwds) + { n = nwds; + } else if (n < nwds && (k &= kmask)) { x1 = x2 = x[n]; x1 >>= k; x1 <<= k; if (x1 != x2) + { return 1; + } } x0 = x; x += n; while (x > x0) + { if (*--x) + { return 1; + } + } return 0; } @@ -2452,14 +2534,18 @@ void gethex(const char** sp, U* rvp, int rounding, int sign MTd) havedig = 0; s0 = *(const unsigned char**)sp + 2; while (s0[havedig] == '0') + { havedig++; + } s0 += havedig; s = s0; decpt = nullptr; zret = 0; e = 0; if (hexdig[*s]) + { havedig++; + } else { zret = 1; @@ -2472,20 +2558,30 @@ void gethex(const char** sp, U* rvp, int rounding, int sign MTd) decpt = s += i; #else if (*s != '.') + { goto pcheck; + } decpt = ++s; #endif if (!hexdig[*s]) + { goto pcheck; + } while (*s == '0') + { s++; + } if (hexdig[*s]) + { zret = 0; + } havedig = 1; s0 = s; } while (hexdig[*s]) + { s++; + } #ifdef USE_LOCALE if (*s == *decimalpoint && !decpt) { @@ -2501,10 +2597,14 @@ void gethex(const char** sp, U* rvp, int rounding, int sign MTd) decpt = ++s; #endif while (hexdig[*s]) + { s++; + } } /*}*/ if (decpt) + { e = -(((Long)(s - decpt)) << 2); + } pcheck: s1 = s; big = esign = 0; @@ -2530,18 +2630,26 @@ pcheck: while ((n = hexdig[*++s]) != 0 && n <= 0x19) { if (e1 & 0xf8000000) + { big = 1; + } e1 = 10 * e1 + n - 0x10; } if (esign) + { e1 = -e1; + } e += e1; } *sp = (char*)s; if (!havedig) + { *sp = (char*)s0 - 1; + } if (zret) + { goto retz1; + } if (big) { if (esign) @@ -2551,11 +2659,15 @@ pcheck: { case Round_up: if (sign) + { break; + } goto ret_tiny; case Round_down: if (!sign) + { break; + } goto ret_tiny; } #endif @@ -2576,11 +2688,15 @@ pcheck: goto ovfl1; case Round_up: if (!sign) + { goto ovfl1; + } goto ret_big; case Round_down: if (sign) + { goto ovfl1; + } goto ret_big; } ret_big: @@ -2590,7 +2706,9 @@ pcheck: } n = int(s1 - s0 - 1); for (k = 0; n > (1 << (kshift - 2)) - 1; n >>= 1) + { k++; + } b = Balloc(k MTa); x = b->x; n = 0; @@ -2609,7 +2727,9 @@ pcheck: } #else if (*--s1 == '.') + { continue; + } #endif if (n == ULbits) { @@ -2637,7 +2757,9 @@ pcheck: { lostbits = 2; if (k > 0 && any_on(b, k)) + { lostbits = 3; + } } } rshift(b, n); @@ -2686,15 +2808,21 @@ pcheck: { case Round_near: if (n == nbits && (n < 2 || lostbits || any_on(b, n - 1))) + { goto ret_tinyf; + } break; case Round_up: if (!sign) + { goto ret_tinyf; + } break; case Round_down: if (sign) + { goto ret_tinyf; + } } #endif /* } IEEE_Arith */ Bfree(b MTa); @@ -2706,11 +2834,17 @@ pcheck: } k = n - 1; if (lostbits) + { lostbits = 1; + } else if (k > 0) + { lostbits = any_on(b, k); + } if (x[k >> kshift] & 1 << (k & kmask)) + { lostbits |= 2; + } nbits -= n; rshift(b, n); e = emin; @@ -2724,7 +2858,9 @@ pcheck: break; case Round_near: if (lostbits & 2 && (lostbits & 1) | (x[0] & 1)) + { up = 1; + } break; case Round_up: up = 1 - sign; @@ -2744,15 +2880,21 @@ pcheck: { rshift(b, 1); if (++e > Emax) + { goto ovfl; + } } } } #ifdef IEEE_Arith if (denorm) + { word0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0; + } else + { word0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20); + } word1(rvp) = b->x[0]; #endif #ifdef IBM @@ -2798,7 +2940,9 @@ static int dshift(Bigint* b, int p2) { int rv = hi0bits(b->x[b->wds - 1]) - 4; if (p2 > 0) + { rv -= p2; + } return rv & kmask; } @@ -2821,7 +2965,9 @@ static int quorem(Bigint* b, Bigint* S) /*debug*/ Bug("oversize b in quorem"); #endif if (b->wds < n) + { return 0; + } sx = S->x; sxe = sx + --n; bx = b->x; @@ -2873,7 +3019,9 @@ static int quorem(Bigint* b, Bigint* S) { bx = b->x; while (--bxe > bx && !*bxe) + { --n; + } b->wds = n; } } @@ -2917,7 +3065,9 @@ static int quorem(Bigint* b, Bigint* S) if (!*bxe) { while (--bxe > bx && !*bxe) + { --n; + } b->wds = n; } } @@ -2933,7 +3083,9 @@ static double sulp(U* x, BCinfo* bc) rv = ulp(x); if (!bc->scale || (i = 2 * P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) + { return rv; /* Is there an example where i <= 0 ? */ + } word0(&u) = Exp_1 + (i << Exp_shift); word1(&u) = 0; return rv * u.d; @@ -2975,8 +3127,10 @@ static void bigcomp(U* rv, const char* s0, BCinfo* bc MTd) } } else + { #endif b = d2b(rv, &p2, &bbits MTa); + } #ifdef Avoid_Underflow p2 -= bc->scale; #endif @@ -2997,7 +3151,7 @@ static void bigcomp(U* rv, const char* s0, BCinfo* bc MTd) #endif word1(rv) = 0; #else - i = j; + i = j; #endif } #ifdef Honor_FLT_ROUNDS @@ -3023,9 +3177,13 @@ have_i: * shift left if necessary so divisor has 4 leading 0 bits. */ if (p5 > 0) + { d = pow5mult(d, p5 MTa); + } else if (p5 < 0) + { b = pow5mult(b, -p5 MTa); + } if (p2 > 0) { b2 = p2; @@ -3038,9 +3196,13 @@ have_i: } i = dshift(d, d2); if ((b2 += i) > 0) + { b = lshift(b, b2 MTa); + } if ((d2 += i) > 0) + { d = lshift(d, d2 MTa); + } /* Now b/d = exactly half-way between the two floating-point values */ /* on either side of the input string. Compute first digit of b/d. */ @@ -3056,11 +3218,15 @@ have_i: for (i = 0; i < nd0;) { if ((dd = s0[i++] - '0' - dig)) + { goto ret; + } if (!b->x[0] && b->wds == 1) { if (i < nd) + { dd = 1; + } goto ret; } b = multadd(b, 10, 0 MTa); @@ -3069,18 +3235,24 @@ have_i: for (j = bc->dp1; i++ < nd;) { if ((dd = s0[j++] - '0' - dig)) + { goto ret; + } if (!b->x[0] && b->wds == 1) { if (i < nd) + { dd = 1; + } goto ret; } b = multadd(b, 10, 0 MTa); dig = quorem(b, d); } if (dig > 0 || b->x[0] || b->wds > 1) + { dd = -1; + } ret: Bfree(b MTa); Bfree(d MTa); @@ -3121,13 +3293,17 @@ ret: if (speccase) { if (dd <= 0) + { rv->d = 0.; + } } else if (dd < 0) { - if (!dsign) /* does not happen for round-near */ + if (!dsign) + { /* does not happen for round-near */ retlow1: dval(rv) -= sulp(rv, bc); + } } else if (dd > 0) { @@ -3146,16 +3322,22 @@ ret: if (i <= 31) { if (word1(rv) & (0x1 << i)) + { goto odd; + } } else if (word0(rv) & (0x1 << (i - 32))) + { goto odd; + } } else if (word1(rv) & 1) { odd: if (dsign) + { goto rethi1; + } goto retlow1; } } @@ -3163,7 +3345,6 @@ ret: #ifdef Honor_FLT_ROUNDS ret1: #endif - return; } #endif /* NO_STRTOD_BIGCOMP */ @@ -3221,6 +3402,7 @@ double Strtod(const char* s00, char** se) sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0; dval(&rv) = 0.; for (s = s00;; s++) + { switch (*s) { case '-': @@ -3229,7 +3411,9 @@ double Strtod(const char* s00, char** se) [[fallthrough]]; case '+': if (*++s) + { goto break2; + } /* no break */ [[fallthrough]]; case 0: @@ -3244,6 +3428,7 @@ double Strtod(const char* s00, char** se) default: goto break2; } + } break2: if (*s == '0') { @@ -3262,17 +3447,25 @@ break2: #endif /*}*/ nz0 = 1; while (*++s == '0') + { ; + } if (!*s) + { goto ret; + } } s0 = s; nd = nf = 0; #ifdef USE_BF96 yz = 0; for (; (c = *s) >= '0' && c <= '9'; nd++, s++) + { if (nd < 19) + { yz = 10 * yz + c - '0'; + } + } #else y = z = 0; for (; (c = *s) >= '0' && c <= '9'; nd++, s++) @@ -3284,7 +3477,9 @@ break2: nd0 = nd; bc.dp0 = bc.dp1 = int(s - s0); for (s1 = s; s1 > s0 && *--s1 == '0';) + { ++nz1; + } #ifdef USE_LOCALE s1 = localeconv()->decimal_point; if (c == *s1) @@ -3317,7 +3512,9 @@ break2: if (!nd) { for (; c == '0'; c = *++s) + { nz++; + } if (c > '0' && c <= '9') { bc.dp0 = int(s0 - s); @@ -3341,10 +3538,14 @@ break2: for (; i < nz; ++i) { if (++nd <= 19) + { yz *= 10; + } } if (++nd <= 19) + { yz = 10 * yz + c; + } #else for (; i < nz; ++i) { @@ -3383,28 +3584,42 @@ dig_done: if (c >= '0' && c <= '9') { while (c == '0') + { c = *++s; + } if (c > '0' && c <= '9') { L = c - '0'; s1 = s; while ((c = *++s) >= '0' && c <= '9') + { L = 10 * L + c - '0'; + } if (s - s1 > 8 || L > 19999) + { /* Avoid confusion from exponents * so large that e might overflow. */ e = 19999; /* safe for 16 bit ints */ + } else + { e = (int)L; + } if (esign) + { e = -e; + } } else + { e = 0; + } } else + { s = s00; + } } if (!nd) { @@ -3413,6 +3628,7 @@ dig_done: #ifdef INFNAN_CHECK /*{*/ /* Check for Nan and Infinity */ if (!bc.dplen) + { switch (c) { case 'i': @@ -3421,7 +3637,9 @@ dig_done: { --s; if (!match(&s, "inity")) + { ++s; + } word0(&rv) = 0x7ff00000; word1(&rv) = 0; goto ret; @@ -3434,12 +3652,15 @@ dig_done: word0(&rv) = NAN_WORD0; word1(&rv) = NAN_WORD1; #ifndef No_Hex_NaN - if (*s == '(') /*)*/ + if (*s == '(') + { /*)*/ hexnan(&rv, &s); + } #endif goto ret; } } + } #endif /*} INFNAN_CHECK */ ret0: s = s00; @@ -3455,7 +3676,9 @@ dig_done: * 10**e */ if (!nd0) + { nd0 = nd; + } #ifndef USE_BF96 k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2; dval(&rv) = y; @@ -3481,7 +3704,9 @@ dig_done: dval(&rv) = yz; #endif if (!e) + { goto ret; + } #ifndef ROUND_BIASED_without_Round_Up if (e > 0) { @@ -3591,9 +3816,13 @@ dig_done: Debug(++dtoa_stats[0]); i = e1 + 342; if (i < 0) + { goto undfl; + } if (i > 650) + { goto ovfl; + } p10 = &pten[i]; brv = yz; /* shift brv left, with i = number of bits shifted */ @@ -3630,7 +3859,9 @@ dig_done: } erv = (64 + 0x3fe) + p10->e - i; if (erv <= 0 && nd > 19) + { goto many_digits; /* denormal: may need to look at all digits */ + } bhi = brv >> 32; blo = brv & 0xffffffffull; /* Unsigned 32-bit ints lie in [0,2^32-1] and */ @@ -3646,9 +3877,13 @@ dig_done: if ((t00 & 0x3ff) && (~t00 & 0x3fe)) { /* unambiguous result? */ if (nd > 19 && ((t00 + (1 << i) + 2) & 0x400) ^ (t00 & 0x400)) + { goto many_digits; + } if (erv <= 0) + { goto denormal; + } #ifdef Honor_FLT_ROUNDS switch (bc.rounding) { @@ -3659,7 +3894,9 @@ dig_done: } #endif if (t00 & 0x400 && t00 & 0xbff) + { goto roundup; + } goto noround; } } @@ -3668,9 +3905,13 @@ dig_done: if ((t00 & 0x1ff) && (~t00 & 0x1fe)) { /* unambiguous result? */ if (nd > 19 && ((t00 + (1 << i) + 2) & 0x200) ^ (t00 & 0x200)) + { goto many_digits; + } if (erv <= 1) + { goto denormal1; + } #ifdef Honor_FLT_ROUNDS switch (bc.rounding) { @@ -3681,7 +3922,9 @@ dig_done: } #endif if (t00 & 0x200) + { goto roundup1; + } goto noround1; } } @@ -3691,17 +3934,23 @@ dig_done: t11 = blo * p10->b1 + (t02 & 0xffffffffull); bexact = 1; if (e1 < 0 || e1 > 41 || (t10 | t11) & 0xffffffffull || nd > 19) + { bexact = 0; + } tlo = (t10 & 0xffffffffull) + (t02 >> 32) + (t11 >> 32); if (!bexact && (tlo + 0x10) >> 32 > tlo >> 32) + { goto many_digits; + } t00 += tlo >> 32; if (t00 & 0x8000000000000000ull) { if (erv <= 0) { /* denormal result */ if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x3ff))) + { goto many_digits; + } denormal: if (erv <= -52) { @@ -3715,7 +3964,9 @@ dig_done: } #endif if (erv < -52 || !(t00 & 0x7fffffffffffffffull)) + { goto undfl; + } goto tiniest; } tg = 1ull << (11 - erv); @@ -3738,7 +3989,9 @@ dig_done: if (!(t00 & 0x8000000000000000ull)) { if (++erv > 0) + { goto smallest_normal; + } t00 = 0x8000000000000000ull; } } @@ -3769,7 +4022,9 @@ dig_done: } #endif if (t00 & 0x400 && (tlo & 0xffffffff) | (t00 & 0xbff)) + { goto roundup; + } goto noround; } if ((tlo & 0xfffffff0) | (t00 & 0x3ff) @@ -3796,7 +4051,9 @@ dig_done: { /* rounded up to a power of 2 */ if (erv >= 0x7fe) + { goto ovfl; + } terv = erv + 1; LLval(&rv) = terv << 52; goto ret; @@ -3804,7 +4061,9 @@ dig_done: } noround: if (erv >= 0x7ff) + { goto ovfl; + } terv = erv; LLval(&rv) = (terv << 52) | ((t00 & 0x7ffffffffffff800ull) >> 11); goto ret; @@ -3815,7 +4074,9 @@ dig_done: if (erv <= 1) { /* denormal result */ if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x1ff))) + { goto many_digits; + } denormal1: if (erv <= -51) { @@ -3829,7 +4090,9 @@ dig_done: } #endif if (erv < -51 || !(t00 & 0x3fffffffffffffffull)) + { goto undfl; + } tiniest: LLval(&rv) = 1; Set_errno(ERANGE); @@ -3862,7 +4125,9 @@ dig_done: noround1_den: #endif if (erv <= -52) + { goto undfl; + } LLval(&rv) = t00 >> (12 - erv); Set_errno(ERANGE); goto ret; @@ -3887,7 +4152,9 @@ dig_done: } #endif if (t00 & 0x200 && (t00 & 0x5ff || tlo)) + { goto roundup1; + } goto noround1; } if ((tlo & 0xfffffff0) | (t00 & 0x1ff) @@ -3912,7 +4179,9 @@ dig_done: { /* rounded up to a power of 2 */ if (erv >= 0x7ff) + { goto ovfl; + } terv = erv; LLval(&rv) = terv << 52; goto ret; @@ -3920,7 +4189,9 @@ dig_done: } noround1: if (erv >= 0x800) + { goto ovfl; + } terv = erv - 1; LLval(&rv) = (terv << 52) | ((t00 & 0x3ffffffffffffc00ull) >> 10); goto ret; @@ -3948,7 +4219,9 @@ many_digits: y = ULong((yz >> i) / pfive[i - 1]); } else + { y = ULong(yz); + } dval(&rv) = yz; #endif /*}*/ @@ -3963,7 +4236,9 @@ many_digits: if (e1 > 0) { if ((i = e1 & 15)) + { dval(&rv) *= tens[i]; + } if (e1 &= ~15) { if (e1 > DBL_MAX_10_EXP) @@ -4010,13 +4285,19 @@ many_digits: } e1 >>= 4; for (j = 0; e1 > 1; j++, e1 >>= 1) + { if (e1 & 1) + { dval(&rv) *= bigtens[j]; + } + } /* The last multiplication could overflow. */ word0(&rv) -= P * Exp_msk1; dval(&rv) *= bigtens[j]; if ((z = word0(&rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) + { goto ovfl; + } if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) { /* set to largest number */ @@ -4025,39 +4306,59 @@ many_digits: word1(&rv) = Big1; } else + { word0(&rv) += P * Exp_msk1; + } } } else if (e1 < 0) { e1 = -e1; if ((i = e1 & 15)) + { dval(&rv) /= tens[i]; + } if (e1 >>= 4) { if (e1 >= 1 << n_bigtens) + { goto undfl; + } #ifdef Avoid_Underflow if (e1 & Scale_Bit) + { bc.scale = 2 * P; + } for (j = 0; e1 > 0; j++, e1 >>= 1) + { if (e1 & 1) + { dval(&rv) *= tinytens[j]; + } + } if (bc.scale && (j = 2 * P + 1 - ((word0(&rv) & Exp_mask) >> Exp_shift)) > 0) { /* scaled rv is denormal; clear j low bits */ if (j >= 32) { if (j > 54) + { goto undfl; + } word1(&rv) = 0; if (j >= 53) + { word0(&rv) = (P + 2) * Exp_msk1; + } else + { word0(&rv) &= 0xffffffff << (j - 32); + } } else + { word1(&rv) &= 0xffffffff << j; + } } #else for (j = 0; e1 > 1; j++, e1 >>= 1) @@ -4108,26 +4409,38 @@ if (nd > strtod_diglim) /* in IEEE arithmetic. */ i = j = 18; if (i > nd0) + { j += bc.dplen; + } for (;;) { if (--j < bc.dp1 && j >= bc.dp0) + { j = bc.dp0 - 1; + } if (s0[j] != '0') + { break; + } --i; } e += nd - i; nd = i; if (nd0 > nd) + { nd0 = nd; + } if (nd < 9) { /* must recompute y */ y = 0; for (i = 0; i < nd0; ++i) + { y = 10 * y + s0[i] - '0'; + } for (j = bc.dp1; i < nd; ++i) + { y = 10 * y + s0[j++] - '0'; + } } } #endif @@ -4151,9 +4464,13 @@ for (;;) bd2 = bd5 = 0; } if (bbe >= 0) + { bb2 += bbe; + } else + { bd2 -= bbe; + } bs2 = bb2; #ifdef Honor_FLT_ROUNDS if (bc.rounding != 1) @@ -4170,11 +4487,17 @@ for (;;) i = Emin - i; j -= i; if (i < 32) + { Lsb <<= i; + } else if (i < 52) + { Lsb1 = Lsb << (i - 32); + } else + { Lsb1 = Exp_mask; + } } #else /*Avoid_Underflow*/ #ifdef Sudden_Underflow @@ -4199,7 +4522,9 @@ for (;;) #endif i = bb2 < bd2 ? bb2 : bd2; if (i > bs2) + { i = bs2; + } if (i > 0) { bb2 -= i; @@ -4214,13 +4539,21 @@ for (;;) bb = bb1; } if (bb2 > 0) + { bb = lshift(bb, bb2 MTb); + } if (bd5 > 0) + { bd = pow5mult(bd, bd5 MTb); + } if (bd2 > 0) + { bd = lshift(bd, bd2 MTb); + } if (bs2 > 0) + { bs = lshift(bs, bs2 MTb); + } delta = diff(bb, bd MTb); bc.dsign = delta->sign; delta->sign = 0; @@ -4382,7 +4715,9 @@ for (;;) } delta = lshift(delta, Log2P MTb); if (cmp(delta, bs) > 0) + { goto drop_down; + } break; } if (i == 0) @@ -4402,7 +4737,9 @@ for (;;) { /*boundary case -- increment exponent*/ if (word0(&rv) == Big0 && word1(&rv) == Big1) + { goto ovfl; + } word0(&rv) = (word0(&rv) & Exp_mask) + Exp_msk1 #ifdef IBM | Exp_msk1 >> 4 @@ -4447,9 +4784,11 @@ for (;;) if (L <= (2 * P + 1) * Exp_msk1) { if (L > (P + 2) * Exp_msk1) + { /* round even ==> */ /* accept rv */ break; + } /* rv = smallest denormal */ if (bc.nd > nd) { @@ -4469,7 +4808,9 @@ for (;;) #else #ifndef NO_STRTOD_BIGCOMP if (bc.nd > nd) + { goto cont; + } #endif break; #endif @@ -4479,22 +4820,28 @@ for (;;) if (Lsb1) { if (!(word0(&rv) & Lsb1)) + { break; + } } else if (!(word1(&rv) & Lsb)) + { break; + } #else if (!(word1(&rv) & LSB)) break; #endif #endif if (bc.dsign) + { #ifdef Avoid_Underflow dval(&rv) += sulp(&rv, &bc); #else dval(&rv) += ulp(&rv); #endif #ifndef ROUND_BIASED + } else { #ifdef Avoid_Underflow @@ -4523,7 +4870,9 @@ for (;;) if ((aadj = ratio(delta, bs)) <= 2.) { if (bc.dsign) + { aadj = aadj1 = 1.; + } else if (word1(&rv) || word0(&rv) & Bndry_mask) { #ifndef Sudden_Underflow @@ -4546,9 +4895,13 @@ for (;;) /* rounded down... */ if (aadj < 2. / FLT_RADIX) + { aadj = 1. / FLT_RADIX; + } else + { aadj *= 0.5; + } aadj1 = -aadj; } } @@ -4567,8 +4920,10 @@ for (;;) aadj1 += 0.5; } #else - if (Flt_Rounds == 0) - aadj1 += 0.5; + if (Flt_Rounds == 0) + { + aadj1 += 0.5; + } #endif /*Check_FLT_ROUNDS*/ } y = word0(&rv) & Exp_mask; @@ -4584,13 +4939,17 @@ for (;;) if ((word0(&rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P)) { if (word0(&rv0) == Big0 && word1(&rv0) == Big1) + { goto ovfl; + } word0(&rv) = Big0; word1(&rv) = Big1; goto cont; } else + { word0(&rv) += P * Exp_msk1; + } } else { @@ -4600,7 +4959,9 @@ for (;;) if (aadj <= 0x7fffffff) { if ((z = aadj) <= 0) + { z = 1; + } aadj = z; aadj1 = bc.dsign ? aadj : -aadj; } @@ -4626,55 +4987,55 @@ for (;;) } #else #ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) - { - dval(&rv0) = dval(&rv); - word0(&rv) += P * Exp_msk1; - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; - #ifdef IBM - if ((word0(&rv) & Exp_mask) < P * Exp_msk1) - #else if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) - #endif { - if (word0(&rv0) == Tiny0 && word1(&rv0) == Tiny1) + dval(&rv0) = dval(&rv); + word0(&rv) += P * Exp_msk1; + adj.d = aadj1 * ulp(&rv); + dval(&rv) += adj.d; + #ifdef IBM + if ((word0(&rv) & Exp_mask) < P * Exp_msk1) + #else + if ((word0(&rv) & Exp_mask) <= P * Exp_msk1) + #endif { - if (bc.nd > nd) + if (word0(&rv0) == Tiny0 && word1(&rv0) == Tiny1) { - bc.uflchk = 1; - break; + if (bc.nd > nd) + { + bc.uflchk = 1; + break; + } + goto undfl; } - goto undfl; + word0(&rv) = Tiny0; + word1(&rv) = Tiny1; + goto cont; } - word0(&rv) = Tiny0; - word1(&rv) = Tiny1; - goto cont; + else + word0(&rv) -= P * Exp_msk1; } else - word0(&rv) -= P * Exp_msk1; - } - else - { + { + adj.d = aadj1 * ulp(&rv); + dval(&rv) += adj.d; + } + #else /*Sudden_Underflow*/ + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P - 1) * Exp_msk1 && aadj > 1.) + { + aadj1 = (double)(int)(aadj + 0.5); + if (!bc.dsign) + aadj1 = -aadj1; + } adj.d = aadj1 * ulp(&rv); dval(&rv) += adj.d; - } - #else /*Sudden_Underflow*/ - /* Compute adj so that the IEEE rounding rules will - * correctly round rv + adj in some half-way cases. - * If rv * ulp(rv) is denormalized (i.e., - * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid - * trouble from bits lost to denormalization; - * example: 1.2e-307 . - */ - if (y <= (P - 1) * Exp_msk1 && aadj > 1.) - { - aadj1 = (double)(int)(aadj + 0.5); - if (!bc.dsign) - aadj1 = -aadj1; - } - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; #endif /*Sudden_Underflow*/ #endif /*Avoid_Underflow*/ } @@ -4684,6 +5045,7 @@ for (;;) { #ifdef Avoid_Underflow if (!bc.scale) + { #endif if (y == z) { @@ -4694,11 +5056,16 @@ for (;;) if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) { if (aadj < .4999999 || aadj > .5000001) + { break; + } } else if (aadj < .4999999 / FLT_RADIX) + { break; + } } + } } #endif cont: @@ -4720,9 +5087,13 @@ if (req_bigcomp) bigcomp(&rv, s0, &bc MTb); y = word0(&rv) & Exp_mask; if (y == Exp_mask) + { goto ovfl; + } if (y == 0 && rv.d == 0.) + { goto undfl; + } } #endif #ifdef Avoid_Underflow @@ -4735,10 +5106,12 @@ if (bc.scale) /* try to avoid the bug of testing an 8087 register value */ #ifdef IEEE_Arith if (!(word0(&rv) & Exp_mask)) + { #else if (word0(&rv) == 0 && word1(&rv) == 0) #endif Set_errno(ERANGE); + } #endif } #endif /* Avoid_Underflow */ @@ -4762,7 +5135,9 @@ ret: else if (!oldinexact) clear_inexact(); #endif if (se) +{ *se = (char*)s; +} return sign ? -dval(&rv) : dval(&rv); } diff --git a/src/FoundationClasses/TKernel/Standard/Standard_Transient.cxx b/src/FoundationClasses/TKernel/Standard/Standard_Transient.cxx index 7284c684c7..81d0591d54 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_Transient.cxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_Transient.cxx @@ -68,7 +68,9 @@ bool Standard_Transient::IsKind(const char* const theTypeName) const Standard_Transient* Standard_Transient::This() const { if (GetRefCount() == 0) + { throw Standard_ProgramError( "Attempt to create handle to object created in stack, not yet constructed, or destroyed"); + } return const_cast(this); } diff --git a/src/FoundationClasses/TKernel/Storage/Storage_Schema.cxx b/src/FoundationClasses/TKernel/Storage/Storage_Schema.cxx index 4faed32e83..64d3f3d08b 100644 --- a/src/FoundationClasses/TKernel/Storage/Storage_Schema.cxx +++ b/src/FoundationClasses/TKernel/Storage/Storage_Schema.cxx @@ -104,7 +104,9 @@ void Storage_BucketOfPersistent::Clear() int i; for (i = 1; i < myNumberOfBucket; i++) + { delete myBuckets[i]; + } myNumberOfBucket = 1; myCurrentBucket = myBuckets[0]; myCurrentBucket->Clear(); @@ -197,7 +199,9 @@ void Storage_BucketIterator::Reset() myMoreObject = true; } else + { myMoreObject = false; + } } //================================================================================================= @@ -214,7 +218,9 @@ void Storage_BucketIterator::Init(Storage_BucketOfPersistent* aBucketManager) myMoreObject = true; } else + { myMoreObject = false; + } } //================================================================================================= @@ -222,7 +228,9 @@ void Storage_BucketIterator::Init(Storage_BucketOfPersistent* aBucketManager) void Storage_BucketIterator::Next() { if (!myMoreObject) + { return; + } if (myCurrentIndex < myCurrentBucket->myCurrentSpace) { @@ -300,7 +308,9 @@ void Storage_Schema::Write(const occ::handle& theDriver, const occ::handle& aData) const { if (aData.IsNull()) + { return; + } // add all the persistent to write... // @@ -425,7 +435,9 @@ void Storage_Schema::Write(const occ::handle& theDriver, { p = bit.Value(); if (!p.IsNull()) + { theDriver->WriteReferenceType(p->_refnum, p->_typenum); + } bit.Next(); } diff --git a/src/FoundationClasses/TKernel/TCollection/TCollection_AsciiString.cxx b/src/FoundationClasses/TKernel/TCollection/TCollection_AsciiString.cxx index ea74e53ed0..29885fe7d3 100644 --- a/src/FoundationClasses/TKernel/TCollection/TCollection_AsciiString.cxx +++ b/src/FoundationClasses/TKernel/TCollection/TCollection_AsciiString.cxx @@ -347,7 +347,9 @@ void TCollection_AsciiString::AssignCat(const char theOther) void TCollection_AsciiString::AssignCat(const char* const theString, const int theLength) { if (theLength == 0 || theString == nullptr) + { return; + } // Check if theString points into our own buffer (self-assignment protection) // Use std::less for well-defined pointer comparison (avoids undefined behavior) @@ -381,9 +383,13 @@ void TCollection_AsciiString::AssignCat(const char* const theString, const int t void TCollection_AsciiString::Capitalize() { if (myLength) + { myString[0] = ::UpperCase(myString[0]); + } for (int i = 1; i < myLength; i++) + { myString[i] = ::LowerCase(myString[i]); + } } //================================================================================================= @@ -483,15 +489,23 @@ void TCollection_AsciiString::ChangeAll(const char theChar, if (theCaseSensitive) { for (int i = 0; i < myLength; i++) + { if (myString[i] == theChar) + { myString[i] = theNewChar; + } + } } else { char anUpperChar = ::UpperCase(theChar); for (int i = 0; i < myLength; i++) + { if (::UpperCase(myString[i]) == anUpperChar) + { myString[i] = theNewChar; + } + } } } @@ -577,13 +591,21 @@ int TCollection_AsciiString::FirstLocationInSet(const char* const theSet, const int theToIndex) const { if (myLength == 0 || theSetLength == 0) + { return 0; + } if (theFromIndex > 0 && theToIndex <= myLength && theFromIndex <= theToIndex) { for (int i = theFromIndex - 1; i < theToIndex; i++) + { for (int j = 0; j < theSetLength; j++) + { if (myString[i] == theSet[j]) + { return i + 1; + } + } + } return 0; } throw Standard_OutOfRange(); @@ -597,7 +619,9 @@ int TCollection_AsciiString::FirstLocationNotInSet(const char* const theSet, const int theToIndex) const { if (myLength == 0 || theSetLength == 0) + { return 0; + } if (theFromIndex > 0 && theToIndex <= myLength && theFromIndex <= theToIndex) { bool aFind; @@ -605,10 +629,16 @@ int TCollection_AsciiString::FirstLocationNotInSet(const char* const theSet, { aFind = false; for (int j = 0; j < theSetLength; j++) + { if (myString[i] == theSet[j]) + { aFind = true; + } + } if (!aFind) + { return i + 1; + } } return 0; } @@ -620,16 +650,22 @@ int TCollection_AsciiString::FirstLocationNotInSet(const char* const theSet, void TCollection_AsciiString::Insert(const int theWhere, const char theWhat) { if (theWhere > myLength + 1) + { throw Standard_OutOfRange("TCollection_AsciiString::Insert : Parameter theWhere is too big"); + } if (theWhere < 1) + { throw Standard_OutOfRange("TCollection_AsciiString::Insert : Parameter theWhere is too small"); + } const int anOldLength = myLength; reallocate(myLength + 1); if (theWhere != anOldLength + 1) { for (int i = anOldLength - 1; i >= theWhere - 1; i--) + { myString[i + 1] = myString[i]; + } } myString[theWhere - 1] = theWhat; } @@ -641,10 +677,14 @@ void TCollection_AsciiString::Insert(const int theWhere, const int theLength) { if (theWhere < 1 || theWhere > myLength + 1) + { throw Standard_OutOfRange("TCollection_AsciiString::Insert : parameter theWhere"); + } if (theLength == 0 || theString == nullptr) + { return; + } const int anInsertSize = theLength; const int anOldLength = myLength; @@ -703,7 +743,9 @@ void TCollection_AsciiString::InsertAfter(const int theIndex, const int theLength) { if (theIndex < 0 || theIndex > myLength) + { throw Standard_OutOfRange(); + } Insert(theIndex + 1, theString, theLength); } @@ -714,7 +756,9 @@ void TCollection_AsciiString::InsertBefore(const int theIndex, const int theLength) { if (theIndex < 1 || theIndex > myLength) + { throw Standard_OutOfRange(); + } Insert(theIndex, theString, theLength); } @@ -723,10 +767,14 @@ void TCollection_AsciiString::InsertBefore(const int theIndex, bool TCollection_AsciiString::IsEqual(const char* const theString, const int theLength) const { if (myLength != theLength) + { return false; + } if (myLength == 0) + { return true; + } return memcmp(myString, theString, myLength) == 0; } @@ -739,9 +787,13 @@ bool TCollection_AsciiString::IsLess(const char* const theString, const int theL const int aResult = memcmp(myString, theString, aMinLength); if (aResult < 0) + { return true; + } if (aResult > 0) + { return false; + } return myLength < theLength; } @@ -754,9 +806,13 @@ bool TCollection_AsciiString::IsGreater(const char* const theString, const int t const int aResult = memcmp(myString, theString, aMinLength); if (aResult > 0) + { return true; + } if (aResult < 0) + { return false; + } return myLength > theLength; } @@ -767,10 +823,14 @@ bool TCollection_AsciiString::StartsWith(const char* const theStartString, const int theStartLength) const { if (theStartLength > myLength) + { return false; + } if (theStartLength == 0) + { return true; + } return memcmp(myString, theStartString, theStartLength) == 0; } @@ -780,10 +840,14 @@ bool TCollection_AsciiString::StartsWith(const char* const theStartString, bool TCollection_AsciiString::EndsWith(const char* const theEndString, const int theEndLength) const { if (theEndLength > myLength) + { return false; + } if (theEndLength == 0) + { return true; + } return memcmp(myString + myLength - theEndLength, theEndString, theEndLength) == 0; } @@ -795,7 +859,9 @@ int TCollection_AsciiString::IntegerValue() const char* ptr; int value = (int)strtol(myString, &ptr, 10); if (ptr != myString) + { return value; + } throw Standard_NumericError("TCollection_AsciiString::IntegerValue"); } @@ -812,7 +878,9 @@ bool TCollection_AsciiString::IsIntegerValue() const for (int i = int(ptr - myString); i < myLength; i++) { if (myString[i] == '.') + { return false; // what about 'e','x',etc ??? + } } return true; } @@ -842,8 +910,12 @@ bool TCollection_AsciiString::IsAscii() const // LD : Debuggee le 26/11/98 // Cette fonction retournait TOUJOURS true ! for (int i = 0; i < myLength; i++) + { if (myString[i] >= 127 || myString[i] < ' ') + { return false; + } + } return true; } @@ -853,10 +925,16 @@ void TCollection_AsciiString::LeftAdjust() { int i; for (i = 0; i < myLength; i++) + { if (!IsSpace(myString[i])) + { break; + } + } if (i > 0) + { Remove(1, i); + } } //================================================================================================= @@ -868,7 +946,9 @@ void TCollection_AsciiString::LeftJustify(const int theWidth, const char theFill const int anOldLength = myLength; reallocate(theWidth); for (int i = anOldLength; i < theWidth; i++) + { myString[i] = theFiller; + } } else if (theWidth < 0) { @@ -891,7 +971,9 @@ int TCollection_AsciiString::Location(const int theN, { aCount++; if (aCount == theN) + { return i + 1; + } } } return 0; @@ -906,7 +988,9 @@ int TCollection_AsciiString::Location(const TCollection_AsciiString& theWhat, const int theToIndex) const { if (myLength == 0 || theWhat.myLength == 0) + { return 0; + } if (theToIndex <= myLength && theFromIndex > 0 && theFromIndex <= theToIndex) { int i = theFromIndex - 1; @@ -919,21 +1003,29 @@ int TCollection_AsciiString::Location(const TCollection_AsciiString& theWhat, { k++; if (k > theWhat.myLength) + { aFind = true; + } } else { if (k > 1) + { i--; // si on est en cours de recherche + } k = 1; l = i; } i++; } if (aFind) + { return l + 2; + } else + { return 0; + } } throw Standard_OutOfRange(); } @@ -943,7 +1035,9 @@ int TCollection_AsciiString::Location(const TCollection_AsciiString& theWhat, void TCollection_AsciiString::LowerCase() { for (int i = 0; i < myLength; i++) + { myString[i] = ::LowerCase(myString[i]); + } } //================================================================================================= @@ -960,7 +1054,9 @@ double TCollection_AsciiString::RealValue() const char* ptr; double value = Strtod(myString, &ptr); if (ptr != myString) + { return value; + } throw Standard_NumericError("TCollection_AsciiString::RealValue"); } @@ -993,7 +1089,9 @@ Standard_IStream& operator>>(Standard_IStream& astream, TCollection_AsciiString& void TCollection_AsciiString::Print(Standard_OStream& theStream) const { if (myString) + { theStream << myString; + } } // ---------------------------------------------------------------------------- @@ -1040,7 +1138,9 @@ void TCollection_AsciiString::Remove(const int theWhere, const int theHowMany) { int i, j; for (i = theWhere + theHowMany - 1, j = theWhere - 1; i < myLength; i++, j++) + { myString[j] = myString[i]; + } myLength -= theHowMany; myString[myLength] = '\0'; } @@ -1058,10 +1158,16 @@ void TCollection_AsciiString::RightAdjust() { int i; for (i = myLength - 1; i >= 0; i--) + { if (!IsSpace(myString[i])) + { break; + } + } if (i < myLength - 1) + { Remove(i + 2, myLength - (i + 2) + 1); + } } //================================================================================================= @@ -1074,9 +1180,13 @@ void TCollection_AsciiString::RightJustify(const int theWidth, const char theFil reallocate(theWidth); int i, k; for (i = anOldLength - 1, k = theWidth - 1; i >= 0; i--, k--) + { myString[k] = myString[i]; + } for (; k >= 0; k--) + { myString[k] = theFiller; + } } else if (theWidth < 0) { @@ -1089,7 +1199,9 @@ void TCollection_AsciiString::RightJustify(const int theWidth, const char theFil int TCollection_AsciiString::Search(const char* const theWhat, const int theWhatLength) const { if (theWhatLength == 0) + { return -1; + } for (int i = 0; i <= myLength - theWhatLength; ++i) { @@ -1106,7 +1218,9 @@ int TCollection_AsciiString::Search(const char* const theWhat, const int theWhat int TCollection_AsciiString::SearchFromEnd(const char* const theWhat, const int theWhatLength) const { if (theWhatLength == 0) + { return -1; + } for (int i = myLength - theWhatLength; i >= 0; --i) { @@ -1140,7 +1254,9 @@ void TCollection_AsciiString::SetValue(const int theWhere, const int theLength) { if (theWhere <= 0) + { throw Standard_OutOfRange("TCollection_AsciiString::SetValue"); + } const int anInsertSize = theLength; const int aNewLength = theWhere - 1 + anInsertSize; @@ -1186,8 +1302,10 @@ TCollection_AsciiString TCollection_AsciiString::Token(const char* const theSepa const int theWhichOne) const { if (!theSeparators) + { throw Standard_NullObject("TCollection_AsciiString::Token : " "parameter 'theSeparators'"); + } int anIndex; int aStringIndex = 0; @@ -1202,7 +1320,9 @@ TCollection_AsciiString TCollection_AsciiString::Token(const char* const theSepa anEndIndex = 0; // std::cout << "anIndex " << anIndex << std::endl ; if (aStringIndex == myLength) + { break; + } for (; aStringIndex < myLength && anEndIndex == 0; aStringIndex++) { aSeparatorIndex = 0; @@ -1234,9 +1354,13 @@ TCollection_AsciiString TCollection_AsciiString::Token(const char* const theSepa // std::cout << "aBeginIndex " << aBeginIndex << " anEndIndex " << anEndIndex << std::endl ; } if (aBeginIndex == 0) + { return TCollection_AsciiString("", 0); + } if (anEndIndex == 0) + { anEndIndex = myLength; + } // std::cout << "'" << SubString( aBeginIndex , anEndIndex ).ToCString() << "'" << std::endl ; return TCollection_AsciiString(&myString[aBeginIndex - 1], anEndIndex - aBeginIndex + 1); } @@ -1246,8 +1370,10 @@ TCollection_AsciiString TCollection_AsciiString::Token(const char* const theSepa void TCollection_AsciiString::Trunc(const int theHowMany) { if (theHowMany < 0 || theHowMany > myLength) + { throw Standard_OutOfRange("TCollection_AsciiString::Trunc : " "parameter 'theHowMany'"); + } myLength = theHowMany; myString[myLength] = '\0'; } @@ -1257,7 +1383,9 @@ void TCollection_AsciiString::Trunc(const int theHowMany) void TCollection_AsciiString::UpperCase() { for (int i = 0; i < myLength; i++) + { myString[i] = ::UpperCase(myString[i]); + } } //================================================================================================= @@ -1355,10 +1483,14 @@ bool TCollection_AsciiString::IsSameString(const char* const theString1, const bool theIsCaseSensitive) { if (theLength1 != theLength2) + { return false; + } if (theLength1 == 0) + { return true; + } if (theIsCaseSensitive) { @@ -1369,7 +1501,9 @@ bool TCollection_AsciiString::IsSameString(const char* const theString1, for (int anIndex = 0; anIndex < theLength1; ++anIndex) { if (::UpperCase(theString1[anIndex]) != ::UpperCase(theString2[anIndex])) + { return false; + } } return true; } diff --git a/src/FoundationClasses/TKernel/TCollection/TCollection_ExtendedString.cxx b/src/FoundationClasses/TKernel/TCollection/TCollection_ExtendedString.cxx index 05a2222c84..3b8aec663a 100644 --- a/src/FoundationClasses/TKernel/TCollection/TCollection_ExtendedString.cxx +++ b/src/FoundationClasses/TKernel/TCollection/TCollection_ExtendedString.cxx @@ -495,8 +495,12 @@ TCollection_ExtendedString TCollection_ExtendedString::Cat(const char16_t theCha void TCollection_ExtendedString::ChangeAll(const char16_t theChar, const char16_t theNewChar) { for (int i = 0; i < myLength; i++) + { if (myString[i] == theChar) + { myString[i] = theNewChar; + } + } } //================================================================================================= @@ -573,16 +577,22 @@ TCollection_ExtendedString::~TCollection_ExtendedString() void TCollection_ExtendedString::Insert(const int theWhere, const char16_t theWhat) { if (theWhere > myLength + 1) + { throw Standard_OutOfRange("TCollection_ExtendedString::Insert : " "Parameter theWhere is too big"); + } if (theWhere < 1) + { throw Standard_OutOfRange("TCollection_ExtendedString::Insert : " "Parameter theWhere is out of range"); + } reallocate(myLength + 1); if (theWhere != myLength) { for (int i = myLength - 2; i >= theWhere - 1; i--) + { myString[i + 1] = myString[i]; + } } myString[theWhere - 1] = theWhat; } @@ -778,8 +788,12 @@ bool TCollection_ExtendedString::EndsWith(const char16_t* const theEndString, bool TCollection_ExtendedString::IsAscii() const { for (int i = 0; i < myLength; i++) + { if (!IsAnAscii(myString[i])) + { return false; + } + } return true; } @@ -816,11 +830,17 @@ void TCollection_ExtendedString::RemoveAll(const char16_t theWhat) { if (myLength == 0) + { return; + } int c = 0; for (int i = 0; i < myLength; i++) + { if (myString[i] != theWhat) + { myString[c++] = myString[i]; + } + } myLength = c; myString[myLength] = u'\0'; } @@ -1005,8 +1025,10 @@ TCollection_ExtendedString TCollection_ExtendedString::Token(const char16_t* con } TCollection_ExtendedString res(myLength, 0); if (!theSeparators) + { throw Standard_NullObject("TCollection_ExtendedString::Token : " "parameter 'theSeparators'"); + } int i, j, k, l; char16_t* buftmp = res.myString; @@ -1043,7 +1065,9 @@ TCollection_ExtendedString TCollection_ExtendedString::Token(const char16_t* con } } if (otherSepFound) + { j++; + } } while (!isSepFound && k < myLength && j < myLength) @@ -1068,7 +1092,9 @@ TCollection_ExtendedString TCollection_ExtendedString::Token(const char16_t* con j++; k++; if (j == myLength) + { buftmp[k] = 0; + } } } @@ -1080,7 +1106,9 @@ TCollection_ExtendedString TCollection_ExtendedString::Token(const char16_t* con else { for (res.myLength = 0; buftmp[res.myLength]; ++res.myLength) + { ; + } res.myString[res.myLength] = u'\0'; } return res; @@ -1098,8 +1126,10 @@ const char16_t* TCollection_ExtendedString::ToExtString() const void TCollection_ExtendedString::Trunc(const int theHowMany) { if (theHowMany < 0 || theHowMany > myLength) + { throw Standard_OutOfRange("TCollection_ExtendedString::Trunc : " "parameter 'theHowMany'"); + } myLength = theHowMany; myString[myLength] = u'\0'; } @@ -1111,9 +1141,13 @@ char16_t TCollection_ExtendedString::Value(const int theWhere) const if (theWhere > 0 && theWhere <= myLength) { if (myString) + { return myString[theWhere - 1]; + } else + { return 0; + } } throw Standard_OutOfRange("TCollection_ExtendedString::Value : " "parameter theWhere"); diff --git a/src/FoundationClasses/TKernel/TCollection/TCollection_HAsciiString.cxx b/src/FoundationClasses/TKernel/TCollection/TCollection_HAsciiString.cxx index 0e5f1f1748..23d89ad6d6 100644 --- a/src/FoundationClasses/TKernel/TCollection/TCollection_HAsciiString.cxx +++ b/src/FoundationClasses/TKernel/TCollection/TCollection_HAsciiString.cxx @@ -113,7 +113,9 @@ occ::handle TCollection_HAsciiString::Cat( void TCollection_HAsciiString::Center(const int Width, const char Filler) { if (Width < 0) + { throw Standard_NegativeValue(); + } myString.Center(Width, Filler); } @@ -140,9 +142,13 @@ int TCollection_HAsciiString::FirstLocationInSet(const occ::handleLength() == 0) + { return 0; + } if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex) + { throw Standard_OutOfRange(); + } return (myString.FirstLocationInSet(Set->String(), FromIndex, ToIndex)); } @@ -154,9 +160,13 @@ int TCollection_HAsciiString::FirstLocationNotInSet( const int ToIndex) const { if (Length() == 0 || Set->Length() == 0) + { return 0; + } if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex) + { throw Standard_OutOfRange(); + } return (myString.FirstLocationNotInSet(Set->String(), FromIndex, ToIndex)); } @@ -190,7 +200,9 @@ void TCollection_HAsciiString::InsertAfter(const int int size1 = Length(); #ifndef NOBOUNDCHECK if (Index < 0 || Index > size1) + { throw Standard_OutOfRange(); + } #endif myString.InsertAfter(Index, S->String()); } @@ -203,7 +215,9 @@ void TCollection_HAsciiString::InsertBefore(const int int size1 = Length(); #ifndef NOBOUNDCHECK if (Index < 1 || Index > size1) + { throw Standard_OutOfRange(); + } #endif myString.InsertBefore(Index, S->String()); } @@ -262,9 +276,13 @@ bool TCollection_HAsciiString::IsAscii() const bool TCollection_HAsciiString::IsDifferent(const occ::handle& S) const { if (S.IsNull()) + { throw Standard_NullObject("TCollection_HAsciiString::IsDifferent"); + } if (S->Length() != myString.Length()) + { return true; + } return (strncmp(myString.ToCString(), S->ToCString(), myString.Length()) != 0); } @@ -273,11 +291,17 @@ bool TCollection_HAsciiString::IsDifferent(const occ::handle& S) const { if (S.IsNull()) + { throw Standard_NullObject("TCollection_HAsciiString::IsSameString"); + } if (myString.Length() == S->Length()) + { return (strncmp(myString.ToCString(), S->ToCString(), myString.Length()) == 0); + } else + { return false; + } } //================================================================================================= @@ -286,7 +310,9 @@ bool TCollection_HAsciiString::IsSameString(const occ::handlemyString, CaseSensitive); } @@ -302,7 +328,9 @@ void TCollection_HAsciiString::LeftAdjust() void TCollection_HAsciiString::LeftJustify(const int Width, const char Filler) { if (Width < 0) + { throw Standard_NegativeValue(); + } myString.LeftJustify(Width, Filler); } @@ -314,7 +342,9 @@ int TCollection_HAsciiString::Location(const int N, const int ToIndex) const { if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex) + { throw Standard_OutOfRange(); + } return myString.Location(N, C, FromIndex, ToIndex); } @@ -325,9 +355,13 @@ int TCollection_HAsciiString::Location(const occ::handleLength() == 0) + { return 0; + } if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex) + { throw Standard_OutOfRange(); + } return myString.Location(S->String(), FromIndex, ToIndex); } @@ -393,7 +427,9 @@ void TCollection_HAsciiString::RightAdjust() void TCollection_HAsciiString::RightJustify(const int Width, const char Filler) { if (Width < 0) + { throw Standard_NegativeValue(); + } myString.RightJustify(Width, Filler); } @@ -503,7 +539,11 @@ char TCollection_HAsciiString::Value(const int where) const bool TCollection_HAsciiString::IsSameState(const occ::handle& other) const { if (myString.Length() == other->Length()) + { return (strncmp(myString.ToCString(), other->ToCString(), myString.Length()) == 0); + } else + { return false; + } } diff --git a/src/FoundationClasses/TKernel/TCollection/TCollection_HExtendedString.cxx b/src/FoundationClasses/TKernel/TCollection/TCollection_HExtendedString.cxx index 5982403763..d57cff0699 100644 --- a/src/FoundationClasses/TKernel/TCollection/TCollection_HExtendedString.cxx +++ b/src/FoundationClasses/TKernel/TCollection/TCollection_HExtendedString.cxx @@ -244,7 +244,7 @@ const TCollection_ExtendedString& TCollection_HExtendedString::String() const //--------------------------------------------------------------------- void TCollection_HExtendedString::Print(Standard_OStream& S) const { - S << "begin class HExtendedString " << std::endl; + S << "begin class HExtendedString " << '\n'; myString.Print(S); } diff --git a/src/FoundationClasses/TKernel/Units/Units.cxx b/src/FoundationClasses/TKernel/Units/Units.cxx index 656c46eb16..6c3a30c046 100644 --- a/src/FoundationClasses/TKernel/Units/Units.cxx +++ b/src/FoundationClasses/TKernel/Units/Units.cxx @@ -98,7 +98,9 @@ occ::handle Units::Quantity(const char* const aquantity) { quantity = quantitiessequence->Value(index); if (quantity->Name() == aquantity) + { return quantity; + } } return nullquantity; } @@ -119,7 +121,9 @@ const char* Units::FirstQuantity(const char* const aunit) TCollection_AsciiString symbol(aunit); if (symbol == symbol_string) + { return quantity_string.ToCString(); + } quantitiessequence = Units::DictionaryOfUnits()->Sequence(); for (i = 1; i <= quantitiessequence->Length(); i++) @@ -176,7 +180,9 @@ occ::handle Units::NullDimensions() { std::lock_guard aLock(THE_UNITS_MUTEX); if (nulldimensions.IsNull()) + { nulldimensions = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 0., 0.); + } return nulldimensions; } diff --git a/src/FoundationClasses/TKernel/Units/Units_Dimensions.cxx b/src/FoundationClasses/TKernel/Units/Units_Dimensions.cxx index fff94307d8..cd4066f795 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Dimensions.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Dimensions.cxx @@ -153,35 +153,55 @@ void Units_Dimensions::Dump(const int ashift) const { int i; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " with the physical dimensions : " << std::endl; + } + std::cout << " with the physical dimensions : " << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " mass : " << themass << std::endl; + } + std::cout << " mass : " << themass << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " length : " << thelength << std::endl; + } + std::cout << " length : " << thelength << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " time : " << thetime << std::endl; + } + std::cout << " time : " << thetime << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " electric current : " << theelectriccurrent << std::endl; + } + std::cout << " electric current : " << theelectriccurrent << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " thermodynamic temperature : " << thethermodynamictemperature << std::endl; + } + std::cout << " thermodynamic temperature : " << thethermodynamictemperature << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " amount of substance : " << theamountofsubstance << std::endl; + } + std::cout << " amount of substance : " << theamountofsubstance << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " luminous intensity : " << theluminousintensity << std::endl; + } + std::cout << " luminous intensity : " << theluminousintensity << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " plane angle : " << theplaneangle << std::endl; + } + std::cout << " plane angle : " << theplaneangle << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " solid angle : " << thesolidangle << std::endl; + } + std::cout << " solid angle : " << thesolidangle << '\n'; } //======================================================================= @@ -234,7 +254,9 @@ occ::handle Units_Dimensions::ALess() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 0., 0.); + } return aDim; } @@ -242,7 +264,9 @@ occ::handle Units_Dimensions::AMass() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(1., 0., 0., 0., 0., 0., 0., 0., 0.); + } return aDim; } @@ -250,7 +274,9 @@ occ::handle Units_Dimensions::ALength() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 1., 0., 0., 0., 0., 0., 0., 0.); + } return aDim; } @@ -258,7 +284,9 @@ occ::handle Units_Dimensions::ATime() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 1., 0., 0., 0., 0., 0., 0.); + } return aDim; } @@ -266,7 +294,9 @@ occ::handle Units_Dimensions::AElectricCurrent() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 1., 0., 0., 0., 0., 0.); + } return aDim; } @@ -274,7 +304,9 @@ occ::handle Units_Dimensions::AThermodynamicTemperature() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 1., 0., 0., 0., 0.); + } return aDim; } @@ -282,7 +314,9 @@ occ::handle Units_Dimensions::AAmountOfSubstance() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 0., 1., 0., 0., 0.); + } return aDim; } @@ -290,7 +324,9 @@ occ::handle Units_Dimensions::ALuminousIntensity() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 0., 0., 1., 0., 0.); + } return aDim; } @@ -298,7 +334,9 @@ occ::handle Units_Dimensions::APlaneAngle() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 1., 0.); + } return aDim; } @@ -306,6 +344,8 @@ occ::handle Units_Dimensions::ASolidAngle() { static occ::handle aDim; if (aDim.IsNull()) + { aDim = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 0., 1.); + } return aDim; } diff --git a/src/FoundationClasses/TKernel/Units/Units_Explorer.cxx b/src/FoundationClasses/TKernel/Units/Units_Explorer.cxx index 55c6ba9605..2cd4b7ea72 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Explorer.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Explorer.cxx @@ -69,7 +69,9 @@ void Units_Explorer::Init(const occ::handle& aunitssystem) thequantitiessequence = aunitssystem->QuantitiesSequence(); theactiveunitssequence = aunitssystem->ActiveUnitsSequence(); if (MoreQuantity()) + { theunitssequence = thequantitiessequence->Value(thecurrentquantity)->Sequence(); + } thecurrentunit = 1; } @@ -87,7 +89,9 @@ void Units_Explorer::Init(const occ::handle& aunitsdictio } if (MoreQuantity()) + { theunitssequence = thequantitiessequence->Value(thecurrentquantity)->Sequence(); + } thecurrentunit = 1; } @@ -162,7 +166,9 @@ void Units_Explorer::NextQuantity() thecurrentquantity++; thecurrentunit = 1; if (MoreQuantity()) + { theunitssequence = thequantitiessequence->Value(thecurrentquantity)->Sequence(); + } } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/Units/Units_Measurement.cxx b/src/FoundationClasses/TKernel/Units/Units_Measurement.cxx index 2ac7d48d8a..f01c2870cd 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Measurement.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Measurement.cxx @@ -123,7 +123,9 @@ Units_Measurement Units_Measurement::Add(const Units_Measurement& ameasurement) double value; Units_Measurement measurement; if (myToken->Dimensions()->IsNotEqual((ameasurement.Token())->Dimensions())) + { return measurement; + } value = ameasurement.Token()->Multiplied(ameasurement.Measurement()); value = myToken->Divided(value); value = themeasurement + value; @@ -138,7 +140,9 @@ Units_Measurement Units_Measurement::Subtract(const Units_Measurement& ameasurem double value; Units_Measurement measurement; if (myToken->Dimensions()->IsNotEqual((ameasurement.Token())->Dimensions())) + { return measurement; + } value = ameasurement.Token()->Multiplied(ameasurement.Measurement()); value = myToken->Divided(value); value = themeasurement - value; diff --git a/src/FoundationClasses/TKernel/Units/Units_Quantity.cxx b/src/FoundationClasses/TKernel/Units/Units_Quantity.cxx index ae00cb8016..a9cfd16a6e 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Quantity.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Quantity.cxx @@ -32,15 +32,19 @@ bool Units_Quantity::IsEqual(const char* const astring) const void Units_Quantity::Dump(const int ashift, const int alevel) const { int index; - std::cout << std::endl; + std::cout << '\n'; for (int i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << Name() << std::endl; + } + std::cout << Name() << '\n'; // thedimensions->Dump(ashift+1); if (alevel > 0) { for (index = 1; index <= theunitssequence->Length(); index++) + { theunitssequence->Value(index)->Dump(ashift + 1, 0); + } } } diff --git a/src/FoundationClasses/TKernel/Units/Units_Sentence.cxx b/src/FoundationClasses/TKernel/Units/Units_Sentence.cxx index 24c62ecfa8..624350f173 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Sentence.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Sentence.cxx @@ -41,7 +41,9 @@ static occ::handle CreateTokenForNumber(const char* const str) IsPoint = true; } else + { break; + } } return new Units_Token(tstr.ToCString(), "0"); } @@ -59,7 +61,9 @@ Units_Sentence::Units_Sentence(const occ::handle& alexicon, thesequenceoftokens = new NCollection_HSequence>(); occ::handle>> lstlexicon = alexicon->Sequence(); if (lstlexicon.IsNull()) + { throw Units_NoSuchType("BAD LEXICON descriptor"); + } limchain = strlen(astring); i = 0; @@ -179,7 +183,9 @@ static occ::handle CalculateLocal( if (aSeq->Length() == 2) { if (aSeq->Value(1)->Word() == "+") + { aSeq->Remove(1); + } if (aSeq->Value(1)->Word() == "-") { tok2 = aSeq->Value(2); @@ -208,13 +214,21 @@ static occ::handle CalculateLocal( for (j = i + 1; j <= aSeq->Length(); j++) { if (aSeq->Value(j)->Word() == ")") + { NbBrackets--; + } if (aSeq->Value(j)->Word() == "(") + { NbBrackets++; + } if (NbBrackets > 0) + { TmpSeq->Append(aSeq->Value(j)); + } else + { break; + } } tok1 = CalculateLocal(TmpSeq); aSeq->Remove(i + 1, j); @@ -248,9 +262,13 @@ static occ::handle CalculateLocal( tok1 = aSeq->Value(i - 1); tok2 = aSeq->Value(i + 1); if (aSeq->Value(i)->Word() == "/") + { tok1 = tok1 / tok2; + } else + { tok1 = tok1 * tok2; + } aSeq->Remove(i); aSeq->Remove(i); aSeq->SetValue(i - 1, tok1); @@ -269,7 +287,9 @@ occ::handle Units_Sentence::Evaluate() { occ::handle rtoken, ktoken; if (thesequenceoftokens->Length() == 0) + { return rtoken; + } /* old variant int index; diff --git a/src/FoundationClasses/TKernel/Units/Units_ShiftedToken.cxx b/src/FoundationClasses/TKernel/Units/Units_ShiftedToken.cxx index 61fc5e7c3d..7e839527d1 100644 --- a/src/FoundationClasses/TKernel/Units/Units_ShiftedToken.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_ShiftedToken.cxx @@ -69,6 +69,8 @@ void Units_ShiftedToken::Dump(const int ashift, const int alevel) const { Units_Token::Dump(ashift, alevel); for (int i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " move : " << themove << std::endl; + } + std::cout << " move : " << themove << '\n'; } diff --git a/src/FoundationClasses/TKernel/Units/Units_ShiftedUnit.cxx b/src/FoundationClasses/TKernel/Units/Units_ShiftedUnit.cxx index b88436702e..a11410b480 100644 --- a/src/FoundationClasses/TKernel/Units/Units_ShiftedUnit.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_ShiftedUnit.cxx @@ -94,9 +94,11 @@ void Units_ShiftedUnit::Dump(const int, const int) const { string = thesymbolssequence->Value(index)->String(); if (index != 1) + { std::cout << " or "; + } std::cout << "\"" << string.ToCString() << "\""; } std::cout << " Name: " << Name().ToCString() << " (= *" << thevalue << " SI + " - << themove << ")" << std::endl; + << themove << ")" << '\n'; } diff --git a/src/FoundationClasses/TKernel/Units/Units_Token.cxx b/src/FoundationClasses/TKernel/Units/Units_Token.cxx index b30476df1c..21b7771d4c 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Token.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Token.cxx @@ -81,8 +81,11 @@ Units_Token::Units_Token(const char* const aword, themean = amean; thevalue = avalue; if (adimensions.IsNull()) + { thedimensions = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 0., 0.); + } else + { thedimensions = new Units_Dimensions(adimensions->Mass(), adimensions->Length(), adimensions->Time(), @@ -92,6 +95,7 @@ Units_Token::Units_Token(const char* const aword, adimensions->LuminousIntensity(), adimensions->PlaneAngle(), adimensions->SolidAngle()); + } } //================================================================================================= @@ -115,8 +119,11 @@ int Units_Token::Length() const void Units_Token::Dimensions(const occ::handle& adimensions) { if (adimensions.IsNull()) + { thedimensions = new Units_Dimensions(0., 0., 0., 0., 0., 0., 0., 0., 0.); + } else + { thedimensions = new Units_Dimensions(adimensions->Mass(), adimensions->Length(), adimensions->Time(), @@ -126,6 +133,7 @@ void Units_Token::Dimensions(const occ::handle& adimensions) adimensions->LuminousIntensity(), adimensions->PlaneAngle(), adimensions->SolidAngle()); + } } //================================================================================================= @@ -144,8 +152,9 @@ void Units_Token::Update(const char* const amean) { TCollection_AsciiString string = Mean(); if (string.Search(amean) != -1) - std::cout << Word() << " encountered twice with the same signification : " << amean - << std::endl; + { + std::cout << Word() << " encountered twice with the same signification : " << amean << '\n'; + } string = string + amean; themean = string; } @@ -166,9 +175,13 @@ occ::handle Units_Token::Add(const occ::handle& atoken { TCollection_AsciiString word = Word(); if (thedimensions->IsEqual(atoken->Dimensions())) + { return new Units_Token(word.ToCString(), " ", thevalue + atoken->Value(), thedimensions); + } else + { return new Units_Token(" "); + } } //================================================================================================= @@ -177,9 +190,13 @@ occ::handle Units_Token::Subtract(const occ::handle& a { TCollection_AsciiString word = Word(); if (thedimensions->IsEqual(atoken->Dimensions())) + { return new Units_Token(word.ToCString(), " ", thevalue - atoken->Value(), thedimensions); + } else + { return new Units_Token(" "); + } } //================================================================================================= @@ -275,9 +292,13 @@ bool Units_Token::IsEqual(const char* const astring) const unsigned int length = string.Length(); #endif if (strlen(astring) == length) + { return strncmp(string.ToCString(), astring, unsigned(length)) == 0; + } else + { return false; + } } //================================================================================================= @@ -288,9 +309,13 @@ bool Units_Token::IsEqual(const occ::handle& atoken) const TCollection_AsciiString string2 = atoken->Word(); int length = string1.Length(); if (length == atoken->Length()) + { return strcmp(string1.ToCString(), string2.ToCString()) == 0; + } else + { return false; + } } //================================================================================================= @@ -302,19 +327,29 @@ void Units_Token::Dump(const int ashift, const int alevel) const TCollection_AsciiString mean = Mean(); for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << "Units_Token::Dump of " << this << std::endl; + } + std::cout << "Units_Token::Dump of " << this << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << word.ToCString() << std::endl; + } + std::cout << word.ToCString() << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " value : " << thevalue << std::endl; + } + std::cout << " value : " << thevalue << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " mean : " << mean.ToCString() << std::endl; + } + std::cout << " mean : " << mean.ToCString() << '\n'; if (alevel) + { thedimensions->Dump(ashift); + } } //======================================================================= diff --git a/src/FoundationClasses/TKernel/Units/Units_Unit.cxx b/src/FoundationClasses/TKernel/Units/Units_Unit.cxx index 2fe832deba..6caf6a21b2 100644 --- a/src/FoundationClasses/TKernel/Units/Units_Unit.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_Unit.cxx @@ -86,7 +86,9 @@ bool Units_Unit::IsEqual(const char* const astring) const { symbol = thesymbolssequence->Value(index)->String(); if (symbol == astring) + { return true; + } } return false; @@ -105,11 +107,12 @@ void Units_Unit::Dump(const int /*ashift*/, const int) const { string = thesymbolssequence->Value(index)->String(); if (index != 1) + { std::cout << " or "; + } std::cout << "\"" << string.ToCString() << "\""; } - std::cout << " Name: " << Name().ToCString() << " (= " << thevalue << " SI)" - << std::endl; + std::cout << " Name: " << Name().ToCString() << " (= " << thevalue << " SI)" << '\n'; } //================================================================================================= diff --git a/src/FoundationClasses/TKernel/Units/Units_UnitSentence.cxx b/src/FoundationClasses/TKernel/Units/Units_UnitSentence.cxx index 0da7b4aa27..f2e42721d5 100644 --- a/src/FoundationClasses/TKernel/Units/Units_UnitSentence.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_UnitSentence.cxx @@ -52,7 +52,9 @@ Units_UnitSentence::Units_UnitSentence( void Units_UnitSentence::Analyse() { if (Sequence()->Length() == 0) + { return; + } int index; TCollection_AsciiString s; @@ -203,16 +205,24 @@ void Units_UnitSentence::SetUnits( { symbol = currenttoken->Word(); if (unit == symbol.ToCString()) + { sequenceoftokens->SetValue(kindex, unit->Token()); + } else + { istheend = false; + } } } } if (istheend) + { break; + } } if (istheend) + { break; + } } } diff --git a/src/FoundationClasses/TKernel/Units/Units_UnitsDictionary.cxx b/src/FoundationClasses/TKernel/Units/Units_UnitsDictionary.cxx index faa9c20444..48fd10a848 100644 --- a/src/FoundationClasses/TKernel/Units/Units_UnitsDictionary.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_UnitsDictionary.cxx @@ -129,11 +129,15 @@ void Units_UnitsDictionary::Creates() { unitscomputed = 0; for (i = 0; i <= numberofunits; i++) + { matrix(i, i) = 1.; + } for (i = 0; i <= numberofunits; i++) { if (matrix(i, 0)) + { unitscomputed++; + } } while (unitscomputed != numberofunits + 1) { @@ -148,7 +152,9 @@ void Units_UnitsDictionary::Creates() matrix(j, 0) = matrix(i, 0) * matrix(j, i); unitscomputed++; if (unitscomputed == numberofunits + 1) + { break; + } } } for (k = j + 1; k <= numberofunits; k++) @@ -158,12 +164,16 @@ void Units_UnitsDictionary::Creates() matrix(j, 0) = matrix(k, 0) / matrix(k, j); unitscomputed++; if (unitscomputed == numberofunits + 1) + { break; + } } } } if (unitscomputed == numberofunits + 1) + { break; + } } } for (i = 1; i <= theunitssequence->Length(); i++) @@ -228,7 +238,9 @@ void Units_UnitsDictionary::Creates() for (i = 0; i < 50; i++) { for (j = 0; j < 50; j++) + { matrix(i, j) = 0.; + } } // skip next line (dotted) @@ -254,7 +266,9 @@ void Units_UnitsDictionary::Creates() strrightadjust(convert); strrightadjust(unit2); if (!unite[0] && !symbol[0] && !convert[0] && !unit2[0]) + { continue; // empty line + } if (convert[0] == '[') { @@ -297,9 +311,13 @@ void Units_UnitsDictionary::Creates() convert[i - 1] = 0; Units_MathSentence mathsentence(&convert[charnumber + 1]); if (ismove) + { move = (mathsentence.Evaluate())->Value(); + } else + { coeff = (mathsentence.Evaluate())->Value(); + } } else if (convert[0]) { @@ -308,7 +326,9 @@ void Units_UnitsDictionary::Creates() OSD::CStringToReal(&convert[charnumber], move); } else + { OSD::CStringToReal(convert, coeff); + } } else { @@ -329,8 +349,12 @@ void Units_UnitsDictionary::Creates() if (unit2[0]) { for (j = 1; j <= theunitssequence->Length(); j++) + { if (theunitssequence->Value(j) == unit2) + { break; + } + } if (j < numberofunits) { @@ -371,7 +395,9 @@ TCollection_AsciiString Units_UnitsDictionary::ActiveUnit(const char* const aqua { unitssequence = quantity->Sequence(); if (unitssequence->Length()) + { return unitssequence->Value(1)->SymbolsSequence()->Value(1)->String(); + } else { #ifdef OCCT_DEBUG @@ -382,6 +408,6 @@ TCollection_AsciiString Units_UnitsDictionary::ActiveUnit(const char* const aqua } } - std::cout << " La grandeur physique " << aquantity << " n'existe pas." << std::endl; + std::cout << " La grandeur physique " << aquantity << " n'existe pas." << '\n'; return ""; } diff --git a/src/FoundationClasses/TKernel/Units/Units_UnitsLexicon.cxx b/src/FoundationClasses/TKernel/Units/Units_UnitsLexicon.cxx index 3784e6ba88..b81787d64f 100644 --- a/src/FoundationClasses/TKernel/Units/Units_UnitsLexicon.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_UnitsLexicon.cxx @@ -41,5 +41,7 @@ void Units_UnitsLexicon::Creates(const bool amode) Units_Lexicon::Creates(); if (amode) + { unitsdictionary = Units::DictionaryOfUnits(amode); + } } diff --git a/src/FoundationClasses/TKernel/Units/Units_UnitsSystem.cxx b/src/FoundationClasses/TKernel/Units/Units_UnitsSystem.cxx index 008e225cce..da044dffae 100644 --- a/src/FoundationClasses/TKernel/Units/Units_UnitsSystem.cxx +++ b/src/FoundationClasses/TKernel/Units/Units_UnitsSystem.cxx @@ -84,7 +84,7 @@ void Units_UnitsSystem::Specify(const char* const aquantity, const char* const a Units_UnitSentence unitsentence(aunit); if (!unitsentence.IsDone()) { - std::cout << "Units_UnitsSystem::Specify : incorrect unit" << std::endl; + std::cout << "Units_UnitsSystem::Specify : incorrect unit" << '\n'; return; } occ::handle token = unitsentence.Evaluate(); @@ -119,8 +119,7 @@ void Units_UnitsSystem::Specify(const char* const aquantity, const char* const a // Units_NoSuchType_Raise_if(quantity.IsNull(),aquantity); if (quantity.IsNull()) { - std::cout << "Warning: in Units_UnitsSystem : Units_NoSuchType '" << aquantity << "'" - << std::endl; + std::cout << "Warning: in Units_UnitsSystem : Units_NoSuchType '" << aquantity << "'" << '\n'; return; } @@ -166,9 +165,13 @@ void Units_UnitsSystem::Remove(const char* const aquantity, const char* const au else { if (theactiveunitssequence->Value(index1) == index2) + { theactiveunitssequence->SetValue(index1, 0); + } else if (theactiveunitssequence->Value(index1) > index2) + { theactiveunitssequence->SetValue(index1, theactiveunitssequence->Value(index1) - 1); + } return; } } @@ -248,7 +251,9 @@ TCollection_AsciiString Units_UnitsSystem::ActiveUnit(const char* const aquantit unitssequence = quantity->Sequence(); index2 = theactiveunitssequence->Value(index1); if (index2) + { return unitssequence->Value(index2)->SymbolsSequence()->Value(1)->String(); + } else { #ifdef OCCT_DEBUG @@ -271,8 +276,7 @@ double Units_UnitsSystem::ConvertValueToUserSystem(const char* const aquantity, Units_UnitSentence unitsentence(aunit); if (!unitsentence.IsDone()) { - std::cout << "Units_UnitsSystem::ConvertValueToUserSystem : incorrect unit => return 0" - << std::endl; + std::cout << "Units_UnitsSystem::ConvertValueToUserSystem : incorrect unit => return 0" << '\n'; return 0.; } return ConvertSIValueToUserSystem(aquantity, avalue * (unitsentence.Evaluate())->Value()); @@ -385,12 +389,14 @@ void Units_UnitsSystem::Dump() const occ::handle transient = This(); occ::handle unitssystem = occ::down_cast(transient); Units_Explorer explorer(unitssystem); - std::cout << " UNITSSYSTEM : " << std::endl; + std::cout << " UNITSSYSTEM : " << '\n'; for (; explorer.MoreQuantity(); explorer.NextQuantity()) { - std::cout << explorer.Quantity() << std::endl; + std::cout << explorer.Quantity() << '\n'; for (; explorer.MoreUnit(); explorer.NextUnit()) - std::cout << " " << explorer.Unit() << std::endl; + { + std::cout << " " << explorer.Unit() << '\n'; + } } } diff --git a/src/FoundationClasses/TKernel/UnitsAPI/UnitsAPI.cxx b/src/FoundationClasses/TKernel/UnitsAPI/UnitsAPI.cxx index 941c9f68c3..a667f89593 100644 --- a/src/FoundationClasses/TKernel/UnitsAPI/UnitsAPI.cxx +++ b/src/FoundationClasses/TKernel/UnitsAPI/UnitsAPI.cxx @@ -38,7 +38,9 @@ void UnitsAPI::CheckLoading(const UnitsAPI_SystemUnits aSystemUnits) { case UnitsAPI_DEFAULT: if (!CurrentUnits.IsNull()) + { break; + } [[fallthrough]]; case UnitsAPI_SI: currentSystem = UnitsAPI_SI; @@ -288,7 +290,9 @@ double UnitsAPI::AnyToLS(const double aData, const char* const aUnit) occ::handle aDim; aValue = Units::ToSI(aValue, aUnit, aDim); if (aDim.IsNull()) + { return aValue; + } const char* quantity = aDim->Quantity(); if (quantity) { @@ -314,7 +318,9 @@ double UnitsAPI::AnyToLS(const double aData, aValue = Units::ToSI(aValue, aUnit, aDim); const char* quantity = aDim->Quantity(); if (aDim.IsNull()) + { return aValue; + } if (quantity) { aValue = LocalSystemUnits.ConvertSIValueToUserSystem(quantity, aValue); diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx index 8ee2880963..0c78c3cb19 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx @@ -165,7 +165,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (mySmallEdgeMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestSmallEdge(); + } if (UserBreak(aPS)) { return; @@ -176,7 +178,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (myRebuildFaceMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestRebuildFace(); + } if (UserBreak(aPS)) { return; @@ -200,7 +204,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (myMergeVertexMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestMergeVertex(); + } if (UserBreak(aPS)) { return; @@ -211,7 +217,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (myMergeEdgeMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestMergeEdge(); + } if (UserBreak(aPS)) { return; @@ -222,7 +230,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (myContinuityMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestContinuity(); + } if (UserBreak(aPS)) { return; @@ -233,7 +243,9 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange) if (myCurveOnSurfaceMode) { if (myResult.IsEmpty() || !myStopOnFirst) + { TestCurveOnSurface(); + } } } catch (Standard_Failure const&) @@ -302,9 +314,13 @@ void BOPAlgo_ArgumentAnalyzer::TestTypes() { const TopoDS_Shape& aS = myEmpty1 ? myShape1 : myShape2; if (myEmpty1) + { aResult.SetShape1(aS); + } else + { aResult.SetShape2(aS); + } } aResult.SetCheckStatus(BOPAlgo_BadType); myResult.Append(aResult); @@ -392,14 +408,18 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences(const Message_ProgressRange aResult.SetShape1(myShape1); aResult.AddFaultyShape1(aS1); if (!aS1.IsSame(aS2)) + { aResult.AddFaultyShape1(aS2); + } } else { aResult.SetShape2(myShape2); aResult.AddFaultyShape2(aS1); if (!aS1.IsSame(aS2)) + { aResult.AddFaultyShape2(aS2); + } } aResult.SetCheckStatus(BOPAlgo_SelfIntersect); myResult.Append(aResult); @@ -439,7 +459,9 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2; if (aS.IsNull()) + { continue; + } TopExp_Explorer anExp(aS, TopAbs_EDGE); @@ -549,7 +571,9 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() void BOPAlgo_ArgumentAnalyzer::TestRebuildFace() { if ((myOperation == BOPAlgo_SECTION) || (myOperation == BOPAlgo_UNKNOWN)) + { return; + } int i = 0; for (i = 0; i < 2; i++) @@ -557,7 +581,9 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace() const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2; if (aS.IsNull()) + { continue; + } TopExp_Explorer anExp(aS, TopAbs_FACE); NCollection_List aLS; @@ -608,7 +634,9 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace() anExpE.Init(aLF.First(), TopAbs_EDGE); for (; anExpE.More(); anExpE.Next(), nbedgeused++) + { ; + } if (nbstartedges != nbedgeused) { @@ -655,10 +683,14 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType) { if (myShape1.IsNull() || myShape2.IsNull()) + { return; + } if (myEmpty1 || myEmpty2) + { return; + } BOPAlgo_CheckStatus aStatus = BOPAlgo_CheckUnknown; @@ -689,7 +721,9 @@ void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType const TopoDS_Shape& aS1 = anExp1.Current(); if (aMap1.Contains(aS1)) + { continue; + } aSeq1.Append(aS1); aMap1.Add(aS1); } @@ -698,7 +732,9 @@ void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType { const TopoDS_Shape& aS2 = anExp2.Current(); if (aMap2.Contains(aS2)) + { continue; + } aSeq2.Append(aS2); aMap2.Add(aS2); } @@ -706,8 +742,12 @@ void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType NCollection_Array2 anArrayOfFlag(1, aSeq1.Length(), 1, aSeq2.Length()); int i = 0, j = 0; for (i = 1; i <= aSeq1.Length(); i++) + { for (j = 1; j <= aSeq2.Length(); j++) + { anArrayOfFlag.SetValue(i, j, false); + } + } for (i = 1; i <= aSeq1.Length(); i++) { diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BOP.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BOP.cxx index f76af78ad8..0385060b22 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BOP.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BOP.cxx @@ -170,9 +170,13 @@ void BOPAlgo_BOP::CheckData() BOPTools_AlgoTools::Dimensions(aS, iDMin, iDMax); if (iDMin < iDimMin[i]) + { iDimMin[i] = iDMin; + } if (iDMax > iDimMax[i]) + { iDimMax[i] = iDMax; + } if (bFuse && (iDimMin[i] != iDimMax[i])) { @@ -265,8 +269,10 @@ bool BOPAlgo_BOP::TreatEmptyShape() { case BOPAlgo_FUSE: { if (aLValidObjs.Extent() + aLValidTools.Extent() > 1) + { // The arguments must be split before adding into result return false; + } // Add not empty shapes into result pLResult = bHasValidObj ? &aLValidObjs : &aLValidTools; @@ -274,8 +280,10 @@ bool BOPAlgo_BOP::TreatEmptyShape() } case BOPAlgo_CUT: { if (aLValidObjs.Extent() > 1) + { // The objects must be split before adding into result return false; + } // Add objects into result pLResult = &aLValidObjs; @@ -283,8 +291,10 @@ bool BOPAlgo_BOP::TreatEmptyShape() } case BOPAlgo_CUT21: { if (aLValidTools.Extent() > 1) + { // The tools must be split before adding into result return false; + } // Add tools into result pLResult = &aLValidTools; @@ -625,7 +635,9 @@ void BOPAlgo_BOP::BuildRC(const Message_ProgressRange& theRange) const TopoDS_Shape& aSS = itList.Value(); iDim = BOPTools_AlgoTools::Dimension(aSS); if (iDim < 0) + { continue; + } aType = TypeToExplore(iDim); TopExp::MapShapes(aSS, aType, aMS); } @@ -1066,11 +1078,15 @@ void BOPAlgo_BOP::BuildShape(const Message_ProgressRange& theRange) { const TopoDS_Shape& aSIm = aItLSIm.Value(); if (aMSRC.Contains(aSIm) && aMSResult.Add(aSIm)) + { aBB.Add(aResult, aSIm); + } } } else if (aMSRC.Contains(aS) && aMSResult.Add(aS)) + { aBB.Add(aResult, aS); + } } myShape = aResult; @@ -1375,7 +1391,9 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { const occ::handle& aType = aIt.Value()->DynamicType(); if (aType != STANDARD_TYPE(BOPAlgo_AlertSolidBuilderUnusedFaces)) + { continue; + } occ::handle aShapeAlert = occ::down_cast(aIt.Value()); @@ -1386,7 +1404,9 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { TopExp_Explorer expS(aWarnShape, TopAbs_SOLID); for (; expS.More(); expS.Next()) + { aFailedSolids.Add(expS.Current()); + } } } } @@ -1403,7 +1423,9 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_SOLID) + { continue; + } const TopoDS_Shape& aSolid = aSI.Shape(); @@ -1419,7 +1441,9 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { const TopoDS_Shape& aSh = itSh.Value(); if (aSh.ShapeType() != TopAbs_SHELL) + { continue; + } for (TopoDS_Iterator itF(aSh); itF.More(); itF.Next()) { @@ -1431,13 +1455,19 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { NCollection_List::Iterator itLFIm(*pLFIm); for (; itLFIm.More(); itLFIm.Next()) + { aMFInternal.Add(itLFIm.Value()); + } } else + { aMFInternal.Add(aF); + } } else + { TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } } } @@ -1448,8 +1478,10 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { const TopoDS_Edge& aE = TopoDS::Edge(aMEF.FindKey(j)); if (BRep_Tool::Degenerated(aE)) + { // Skip degenerated edges continue; + } isClosed = (aMEF(j).Extent() > 1); if (!isClosed) @@ -1473,18 +1505,24 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() } if (isClosed) + { continue; + } // Not closed solid is found if (aFailedSolids.Contains(aSolid)) + { // Warning has been generated for this solid, return positive result right away. return true; + } // Check the splits not to acquire new INTERNAL faces const NCollection_List* pLSIm = myImages.Seek(aSolid); if (!pLSIm) + { continue; + } NCollection_List::Iterator itLSIm(*pLSIm); for (; itLSIm.More(); itLSIm.Next()) @@ -1494,7 +1532,9 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() { const TopoDS_Shape& aSh = itSh.Value(); if (aSh.ShapeType() != TopAbs_SHELL) + { continue; + } for (TopoDS_Iterator itF(aSh); itF.More(); itF.Next()) { @@ -1502,8 +1542,10 @@ bool BOPAlgo_BOP::CheckArgsForOpenSolid() if (aF.Orientation() == TopAbs_INTERNAL) { if (!aMFInternal.Contains(aF)) + { // New internal face is found return true; + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx index bee927f01e..eee52ec74a 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder.cxx @@ -484,7 +484,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, occ::handle theReport) { if (HasErrors()) + { return; + } // Report for the method occ::handle aReport = theReport.IsNull() ? myReport : theReport; @@ -579,7 +581,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { const TopoDS_Shape& aF = expF.Current(); if (aF.Orientation() != TopAbs_FORWARD && aF.Orientation() != TopAbs_REVERSED) + { continue; + } const NCollection_List* pLFIm = myImages.Seek(aF); if (pLFIm) { @@ -616,7 +620,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, !i ? anINObjects : anINTools; NCollection_List::Iterator itLFIn(*pLFIN); for (; itLFIn.More(); itLFIn.Next()) + { anINMap.Add(itLFIn.Value()); + } } } } @@ -662,11 +668,15 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, // Filtering for FUSE - avoid any IN faces if (bAvoidIN && (isIN || isINOpposite)) + { continue; + } // Filtering for CUT - avoid faces IN for both groups if (bAvoidINforBoth && isIN && isINOpposite) + { continue; + } // Treatment of SD faces if (!aMFence.Add(aFIm)) @@ -675,7 +685,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { // The face belongs to only one group if (bTakeIN != isSameOriNeeded) + { aMFToAvoid.Add(aFIm); + } } else { @@ -686,17 +698,23 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { // Take the shape without classification if (aMResFacesFence.Add(aFIm)) + { aMResFacesOri.Add(aFIm); + } } else + { // Remove the face aMFToAvoid.Add(aFIm); + } continue; } } if (!aMFenceOri.Add(aFIm)) + { continue; + } if (bTakeIN == isINOpposite) { @@ -706,9 +724,13 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, aMResFacesOri.Add(aFIm.Reversed()); } else if (bTakeIN && !isSameOriNeeded) + { aMResFacesOri.Add(aFIm.Reversed()); + } else + { aMResFacesOri.Add(aFIm); + } aMResFacesFence.Add(aFIm); } } @@ -721,7 +743,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { const TopoDS_Shape& aRF = aMResFacesOri(i); if (!aMFToAvoid.Contains(aRF)) + { aResFaces.Append(aRF); + } } Message_ProgressScope aPS(theRange, nullptr, 2); BRep_Builder aBB; @@ -752,7 +776,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { const TopoDS_Shape& aF = expF.Current(); if (aMObjFacesOri.Contains(aF) || aMToolFacesOri.Contains(aF)) + { break; + } } if (expF.More()) { @@ -774,7 +800,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, for (; itLF.More(); itLF.Next()) { if (aMFence.Add(itLF.Value())) + { aBB.Add(anUnUsedFaces, itLF.Value()); + } } // Build blocks from the unused faces @@ -791,7 +819,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, // Add faces of the block to the shell TopExp_Explorer anExpF(aCB, TopAbs_FACE); for (; anExpF.More(); anExpF.Next()) + { aBB.Add(aShell, anExpF.Current()); + } BOPTools_AlgoTools::OrientFacesOnShell(aShell); // Make solid out of the shell @@ -820,13 +850,17 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, { const TopoDS_Shape& aSInt = it.Value(); if (aSInt.Orientation() == TopAbs_INTERNAL) + { anInParts.Append(aSInt); // vertex or edge + } else { // shell treatment TopoDS_Iterator itInt(aSInt); if (itInt.More() && itInt.Value().Orientation() == TopAbs_INTERNAL) + { anInParts.Append(aSInt); + } } } } @@ -842,7 +876,9 @@ void BOPAlgo_Builder::BuildBOP(const NCollection_List& theObjects, NCollection_List::Iterator itLS(aResSolids); for (; itLS.More(); itLS.Next()) + { aBB.Add(aResult, itLS.Value()); + } myShape = aResult; PrepareHistory(aPS.Next()); diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderFace.cxx index ee179e490c..41381258bf 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderFace.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -405,7 +405,9 @@ void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) TopoDS_Face aFace; aBB.MakeFace(aFace, aS, aLoc, aTol); if (BRep_Tool::NaturalRestriction(myFace)) + { aBB.NaturalRestriction(aFace, true); + } myAreas.Append(aFace); } return; @@ -514,7 +516,9 @@ void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) const TopoDS_Shape& aHole = aHoleFaces(k); // Check if it is inside if (!IsInside(aHole, aFace, myContext)) + { continue; + } // Save the relation TopoDS_Shape* pFaceWas = aHoleFaceMap.ChangeSeek(aHole); @@ -544,7 +548,9 @@ void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) // NCollection_List* pLHoles = aFaceHolesMap.ChangeSeek(aFace); if (!pLHoles) + { pLHoles = &aFaceHolesMap(aFaceHolesMap.Add(aFace, NCollection_List())); + } pLHoles->Append(aHole); } @@ -565,7 +571,9 @@ void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) { const TopoDS_Shape& aHole = aHoleFaces(i); if (!aHoleFaceMap.Contains(aHole)) + { anUnUsedHoles.Append(aHole); + } } // Save it aNewFaces.Append(aFace); @@ -610,13 +618,17 @@ void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& theRange) { if (myAvoidInternalShapes) + { // User-defined option to avoid internal edges // in the result is in force. return; + } if (myLoopsInternal.IsEmpty()) + { // No edges left for classification return; + } // Prepare tree with the boxes of the edges to classify BOPTools_Box2dTree aBoxTree; @@ -678,7 +690,9 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the aSelector.SetBVHSet(&aBoxTree); aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxF)); if (!aSelector.Select()) + { continue; + } // Collect edges inside the face NCollection_IndexedMap anEdgesInside; @@ -689,7 +703,9 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the { const int nE = itLI.Value(); if (aMEDone.Contains(nE)) + { continue; + } const TopoDS_Edge& aE = TopoDS::Edge(anEdgesMap(nE)); if (IsInside(aE, aF, myContext)) @@ -700,7 +716,9 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the } if (anEdgesInside.IsEmpty()) + { continue; + } // Make internal wires NCollection_List aLSI; @@ -716,8 +734,10 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the // Condition of early exit if (aMEDone.Extent() == anEdgesMap.Extent()) + { // All edges are classified and added into the faces return; + } } // Some edges are left unclassified - warn user about them @@ -725,7 +745,9 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the for (int i = 1; i <= anEdgesMap.Extent(); ++i) { if (!aMEDone.Contains(i)) + { anEdgesUnUsed.Add(anEdgesMap(i)); + } } // Make internal wires @@ -737,13 +759,17 @@ void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& the BRep_Builder().MakeCompound(aWShape); BRep_Builder().Add(aWShape, myFace); if (aLSI.Extent() == 1) + { BRep_Builder().Add(aWShape, aLSI.First()); + } else { TopoDS_Compound aCE; BRep_Builder().MakeCompound(aCE); for (NCollection_List::Iterator it(aLSI); it.More(); it.Next()) + { BRep_Builder().Add(aCE, it.Value()); + } BRep_Builder().Add(aWShape, aCE); } @@ -836,19 +862,25 @@ bool IsInside(const TopoDS_Shape& theWire, { const TopoDS_Edge& aE = TopoDS::Edge(anExp.Current()); if (BRep_Tool::Degenerated(aE)) + { // Avoid checking degenerated edges. continue; + } if (aFaceEdgesMap.Contains(aE)) + { // Face contains the edge from the wire, thus the wire cannot be // inside that face. return isInside; + } // Get 2d curve of the edge on the face double aT1, aT2; const occ::handle& aC2D = BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); if (aC2D.IsNull()) + { continue; + } // Get middle point on the curve gp_Pnt2d aP2D = aC2D->Value((aT1 + aT2) / 2.); @@ -872,7 +904,9 @@ bool IsGrowthWire(const TopoDS_Shape& for (; aIt.More(); aIt.Next()) { if (theMHE.Contains(aIt.Value())) + { return true; + } } } return false; diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderSolid.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderSolid.cxx index 8b9fb58cdb..187d9495b4 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderSolid.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_BuilderSolid.cxx @@ -80,7 +80,9 @@ void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange) GetReport()->Clear(); // if (myShapes.IsEmpty()) + { return; + } if (myContext.IsNull()) { @@ -507,7 +509,9 @@ void BOPAlgo_BuilderSolid::PerformAreas(const Message_ProgressRange& theRange) const TopoDS_Shape& aHole = aHoleShells(k); // Check if it is inside if (!IsInside(aHole, aSolid, myContext)) + { continue; + } // Save the relation TopoDS_Shape* pSolidWas = aHoleSolidMap.ChangeSeek(aHole); @@ -537,7 +541,9 @@ void BOPAlgo_BuilderSolid::PerformAreas(const Message_ProgressRange& theRange) // NCollection_List* pLHoles = aSolidHolesMap.ChangeSeek(aSolid); if (!pLHoles) + { pLHoles = &aSolidHolesMap(aSolidHolesMap.Add(aSolid, NCollection_List())); + } pLHoles->Append(aHole); } @@ -596,12 +602,16 @@ void BOPAlgo_BuilderSolid::PerformAreas(const Message_ProgressRange& theRange) void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& theRange) { if (myAvoidInternalShapes) + { // user-defined option to avoid internal parts is in force return; + } if (myLoopsInternal.IsEmpty()) + { // no internal parts return; + } Message_ProgressScope aMainScope(theRange, "Adding internal shapes", 2); @@ -613,7 +623,9 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th const TopoDS_Shape& aShell = aItLS.Value(); TopoDS_Iterator aIt(aShell); for (; aIt.More(); aIt.Next()) + { aMFs.Add(aIt.Value()); + } } BRep_Builder aBB; @@ -630,7 +642,9 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th // aItLS.Initialize(aLSI); for (; aItLS.More(); aItLS.Next()) + { aBB.Add(aSolid, aItLS.Value()); + } myAreas.Append(aSolid); return; @@ -647,7 +661,9 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th NCollection_List aLFaces; int i, aNbF = aMFs.Extent(); for (i = 1; i <= aNbF; ++i) + { aLFaces.Append(aMFs(i)); + } // Map of solids with IN faces NCollection_IndexedDataMap, TopTools_ShapeMapHasher> @@ -681,7 +697,9 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th const NCollection_List& aLF = aMSLF(i); if (aLF.IsEmpty()) + { continue; + } NCollection_IndexedMap aMF; aItLS.Initialize(aLF); @@ -711,7 +729,9 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th { const TopoDS_Shape& aF = aMFs(i); if (!aMFDone.Contains(aF)) + { aMFUnUsed.Add(aF); + } } if (aMFUnUsed.Extent()) @@ -721,13 +741,17 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& th TopoDS_Shape aWShape; if (aLSI.Extent() == 1) + { aWShape = aLSI.First(); + } else { aBB.MakeCompound(TopoDS::Compound(aWShape)); aItLS.Initialize(aLSI); for (; aItLS.More(); aItLS.Next()) + { aBB.Add(aWShape, aItLS.Value()); + } } AddWarning(new BOPAlgo_AlertSolidBuilderUnusedFaces(aWShape)); @@ -846,7 +870,9 @@ bool IsGrowthShell(const TopoDS_Shape& for (; aIt.More(); aIt.Next()) { if (theMHF.Contains(aIt.Value())) + { return true; + } } } return false; diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_1.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_1.cxx index 7e34e56b0c..b3997907a4 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_1.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_1.cxx @@ -59,7 +59,9 @@ void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange) // Add to Origins map NCollection_List* pLOr = myOrigins.ChangeSeek(aVSD); if (!pLOr) + { pLOr = myOrigins.Bound(aVSD, NCollection_List()); + } pLOr->Append(aV); } } @@ -136,14 +138,18 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType) { const TopoDS_Shape& aS = aItA.Value(); if (aS.ShapeType() != theType) + { continue; + } // Get images const NCollection_List* pLSIm = myImages.Seek(aS); if (!pLSIm) { // No images -> add the argument shape itself into result if (aMFence.Add(aS)) + { BRep_Builder().Add(myShape, aS); + } } else { @@ -153,7 +159,9 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType) { const TopoDS_Shape& aSIm = aItIm.Value(); if (aMFence.Add(aSIm)) + { BRep_Builder().Add(myShape, aSIm); + } } } } @@ -219,7 +227,9 @@ void BOPAlgo_Builder::FillImagesContainer(const TopoDS_Shape& theS, const TopAbs const TopoDS_Shape& aSS = aIt.Value(); const NCollection_List* pLFIm = myImages.Seek(aSS); if (pLFIm && ((pLFIm->Extent() != 1) || !pLFIm->First().IsSame(aSS))) + { break; + } } if (!aIt.More()) diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_2.cxx index fd6f9af42a..9512836ecd 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -320,13 +320,17 @@ void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange) TopoDS_Iterator itE(aItW.Value()); hasInternals = (itE.More() && (itE.Value().Orientation() == TopAbs_INTERNAL)); if (hasInternals) + { break; + } hasModified |= myImages.IsBound(aItW.Value()); } if (!hasInternals && !hasModified) + { continue; + } } if (!hasInternals) @@ -540,7 +544,9 @@ void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange) { TopoDS_Shape& aFR = aIt.ChangeValue(); if (anOriF == TopAbs_REVERSED) + { aFR.Orientation(TopAbs_REVERSED); + } pLFIm->Append(aFR); } } @@ -563,7 +569,9 @@ static void AddEdgeSet(const TopoDS_Shape& theS, // Add set to the map, keeping connection to the shape NCollection_List* pLF = theMap.ChangeSeek(aSE); if (!pLF) + { pLF = &theMap(theMap.Add(aSE, NCollection_List(theAllocator))); + } pLF->Append(theS); } @@ -576,7 +584,9 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) const NCollection_DynamicArray& aFFs = myDS->InterfFF(); int aNbFFs = aFFs.Length(); if (!aNbFFs) + { return; + } Message_ProgressScope aPSOuter(theRange, nullptr, 10); @@ -593,13 +603,17 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(iSrc); if (aSI.ShapeType() != TopAbs_SOLID) + { continue; + } const TopoDS_Shape& aSolid = aSI.Shape(); for (TopExp_Explorer anExpF(aSolid, TopAbs_FACE); anExpF.More(); anExpF.Next()) { const TopoDS_Shape& aF = anExpF.Current(); if (!aFaceToParent.IsBound(aF)) + { aFaceToParent.Bind(aF, aSolid); + } } } NCollection_DataMap aPropagation( @@ -613,12 +627,16 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) { const TopoDS_Shape* pParent = aFaceToParent.Seek(anItIm.Key()); if (pParent == nullptr) + { continue; + } for (NCollection_List::Iterator anItPiece(anItIm.Value()); anItPiece.More(); anItPiece.Next()) { if (!aFaceToParent.IsBound(anItPiece.Value())) + { aPropagation.Bind(anItPiece.Value(), *pParent); + } } } for (NCollection_DataMap::Iterator @@ -652,10 +670,14 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) for (int j = 0; j < 2; ++j) { if (!myDS->HasFaceInfo(nF[j])) + { continue; + } if (!aMFence.Add(nF[j])) + { continue; + } aFIVec.Appended() = nF[j]; } @@ -703,14 +725,18 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) { AddEdgeSet(aItLF.Value(), anESetFaces, aAllocator); if (bCheckPlanar) + { aMFPlanar.Add(aItLF.Value()); + } } } else { AddEdgeSet(aF, anESetFaces, aAllocator); if (bCheckPlanar) + { aMFPlanar.Add(aF); + } } } @@ -730,7 +756,9 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) } const NCollection_List& aLF = anESetFaces(i); if (aLF.Extent() < 2) + { continue; + } // All possible pairs from should be checked NCollection_List::Iterator aIt1(aLF); @@ -746,7 +774,9 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) const TopoDS_Shape& aF2 = aIt2.Value(); const TopoDS_Shape* pParent2 = aFaceToParent.Seek(aF2); if (pParent1 != nullptr && pParent2 != nullptr && pParent1->IsSame(*pParent2)) + { continue; + } if (bCheckPlanar && aMFPlanar.Contains(aF2)) { // Consider planar bounded faces as Same Domain without additional check @@ -786,7 +816,9 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) { BOPAlgo_PairOfShapeBoolean& aPSB = aVPSB(i); if (aPSB.Flag()) + { BOPAlgo_Tools::FillMap(aPSB.Shape1(), aPSB.Shape2(), aDMSLS, aAllocator); + } } aVPSB.Clear(); @@ -856,12 +888,16 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_FACE) + { continue; + } const TopoDS_Shape& aF = aSI.Shape(); NCollection_List* pLFIm = myImages.ChangeSeek(aF); if (!pLFIm) + { continue; + } NCollection_List::Iterator aItLFIm(*pLFIm); for (; aItLFIm.More(); aItLFIm.Next()) @@ -869,13 +905,17 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange) TopoDS_Shape& aFIm = aItLFIm.ChangeValue(); const TopoDS_Shape* pFSD = myShapesSD.Seek(aFIm); if (pFSD) + { // Update image with SD face aFIm = *pFSD; + } // Fill the map of origins NCollection_List* pLFOr = myOrigins.ChangeSeek(aFIm); if (!pLFOr) + { pLFOr = myOrigins.Bound(aFIm, NCollection_List()); + } pLFOr->Append(aF); } } @@ -899,7 +939,9 @@ void BOPAlgo_Builder::FillInternalVertices(const Message_ProgressRange& theRange { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_FACE) + { continue; + } if (UserBreak(aPSOuter)) { @@ -909,7 +951,9 @@ void BOPAlgo_Builder::FillInternalVertices(const Message_ProgressRange& theRange const TopoDS_Shape& aF = aSI.Shape(); const NCollection_List* pLFIm = myImages.Seek(aF); if (!pLFIm) + { continue; + } // Find vertices to add as internal into the splits NCollection_List aLIAV; @@ -987,10 +1031,14 @@ static bool HasMultiConnected( // The list is expected to be 1-2 elements long, // thus using "Contains" is safe. if (!pList->Contains(theEdge)) + { pList->Append(theEdge); + } if (pList->Extent() > 2) + { return true; + } } } return false; @@ -1035,12 +1083,16 @@ TopoDS_Face BuildDraftFace( { const TopoDS_Shape& aW = aItW.Value(); if (aW.ShapeType() != TopAbs_WIRE) + { continue; + } // Rebuild wire using images of edges TopoDS_Iterator aItE(aW.Oriented(TopAbs_FORWARD)); if (!aItE.More()) + { continue; + } TopoDS_Wire aNewWire; aBB.MakeWire(aNewWire); @@ -1068,11 +1120,15 @@ TopoDS_Face BuildDraftFace( { // Check if the edge has multi-connected vertices if (!bIsDegenerated && HasMultiConnected(aE, aVerticesCounter)) + { return TopoDS_Face(); + } // Check edges unification if (!bIsClosed && !aMEdges.Add(aE)) + { return TopoDS_Face(); + } aBB.Add(aNewWire, aE); continue; @@ -1085,11 +1141,15 @@ TopoDS_Face BuildDraftFace( // Check if the split has multi-connected vertices if (!bIsDegenerated && HasMultiConnected(aSp, aVerticesCounter)) + { return TopoDS_Face(); + } // Check edges unification if (!bIsClosed && !aMEdges.Add(aSp)) + { return TopoDS_Face(); + } aSp.Orientation(anOriE); if (bIsDegenerated) @@ -1101,11 +1161,15 @@ TopoDS_Face BuildDraftFace( // If the original edge is closed on the face check closeness // of the split edge and if it is not closed make the second PCurve if (bIsClosed && !BRep_Tool::IsClosed(aSp, theFace)) + { BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, theFace); + } // Check if the split should be reversed if (BOPTools_AlgoTools::IsSplitToReverseWithWarn(aSp, aE, theCtx, theReport)) + { aSp.Reverse(); + } aBB.Add(aNewWire, aSp); } @@ -1117,7 +1181,9 @@ TopoDS_Face BuildDraftFace( } if (theFace.Orientation() == TopAbs_REVERSED) + { aDraftFace.Reverse(); + } return aDraftFace; } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_3.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_3.cxx index fd107c11f9..9fb42d8992 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_3.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_3.cxx @@ -118,7 +118,9 @@ void BOPAlgo_Builder::FillIn3DParts( { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_FACE) + { continue; + } if (UserBreak(aPS)) { @@ -135,7 +137,9 @@ void BOPAlgo_Builder::FillIn3DParts( { const TopoDS_Shape& aSIm = aItLSIm.Value(); if (aMFence.Add(aSIm)) + { aLFaces.Append(aSIm); + } } } else @@ -174,7 +178,9 @@ void BOPAlgo_Builder::FillIn3DParts( // Bounding box for the solid aS Bnd_Box& aBoxS = aSI.ChangeBox(); if (aBoxS.IsVoid()) + { myDS->BuildBndBoxSolid(i, aBoxS, myCheckInverted); + } // Build Draft Solid NCollection_List aLIF; @@ -221,11 +227,15 @@ void BOPAlgo_Builder::FillIn3DParts( bool bHasImage = false; // Check if the shells of the solid have image for (TopoDS_Iterator it(aSolid); it.More() && !bHasImage; it.Next()) + { bHasImage = myImages.IsBound(it.Value()); + } if (!bHasImage) + { // no need to split the solid continue; + } } theDraftSolids.Bind(aSolid, aSDraft); @@ -239,11 +249,15 @@ void BOPAlgo_Builder::FillIn3DParts( NCollection_List::Iterator aItLS(aLInFaces); for (; aItLS.More(); aItLS.Next()) + { pLIN->Append(aItLS.Value()); + } aItLS.Initialize(aLInternal); for (; aItLS.More(); aItLS.Next()) + { pLIN->Append(aItLS.Value()); + } } } } @@ -455,12 +469,16 @@ void BOPAlgo_Builder::BuildSplitSolids( { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_SOLID) + { continue; + } const TopoDS_Shape& aS = aSI.Shape(); const TopoDS_Solid& aSolid = (*(TopoDS_Solid*)(&aS)); if (!theDraftSolids.IsBound(aS)) + { continue; + } const TopoDS_Shape& aSD = theDraftSolids.Find(aS); const NCollection_List* pLFIN = myInParts.Seek(aS); @@ -551,7 +569,9 @@ void BOPAlgo_Builder::BuildSplitSolids( AddWarning(anAlertWithShape); } else + { AddWarning(anAlert); + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_4.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_4.cxx index 21ff2f620e..3a7a9a3acb 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_4.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Builder_4.cxx @@ -36,25 +36,33 @@ const NCollection_List& BOPAlgo_Builder::LocGenerated(const TopoDS myHistShapes.Clear(); if (theS.IsNull()) + { return myHistShapes; + } // Only EDGES and FACES should be considered TopAbs_ShapeEnum aType = theS.ShapeType(); if (aType != TopAbs_EDGE && aType != TopAbs_FACE) + { // Wrong type return myHistShapes; + } // Check that DS contains the shape, i.e. it is from the arguments of the operation int nS = myDS->Index(theS); if (nS < 0) + { // Unknown shape return myHistShapes; + } // Check that the shape has participated in any intersections const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nS); if (!aSI.HasReference()) + { // Untouched shape return myHistShapes; + } // Analyze all types of Interferences which can produce // new vertices - Edge/Edge and Edge/Face @@ -76,29 +84,39 @@ const NCollection_List& BOPAlgo_Builder::LocGenerated(const TopoDS { BOPDS_Interf* aInt = !k ? (BOPDS_Interf*)(&aEEs(i)) : (BOPDS_Interf*)(&aEFs(i)); if (!aInt->HasIndexNew()) + { // No new vertices created continue; + } if (!aInt->Contains(nS)) + { continue; + } int nVNew = aInt->IndexNew(); myDS->HasShapeSD(nVNew, nVNew); if (!aMFence.Add(nVNew)) + { continue; + } // Get the new vertex const TopoDS_Shape& aVNew = myDS->Shape(nVNew); // Check that the result shape contains vertex if (myMapShape.Contains(aVNew)) + { // Save the vertex as generated myHistShapes.Append(aVNew); + } } } if (!isFace) + { return myHistShapes; + } // For the FACE it is also necessary to collect all // section elements created in FACE/FACE interferences. @@ -113,7 +131,9 @@ const NCollection_List& BOPAlgo_Builder::LocGenerated(const TopoDS { const TopoDS_Shape& aENew = myDS->Shape(aMPBSc(i)->Edge()); if (myMapShape.Contains(aENew)) + { myHistShapes.Append(aENew); + } } // Section vertices of the face @@ -124,7 +144,9 @@ const NCollection_List& BOPAlgo_Builder::LocGenerated(const TopoDS { const TopoDS_Shape& aVNew = myDS->Shape(aItM.Value()); if (myMapShape.Contains(aVNew)) + { myHistShapes.Append(aVNew); + } } return myHistShapes; @@ -142,7 +164,9 @@ const NCollection_List* BOPAlgo_Builder::LocModified(const TopoDS_ void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange) { if (!HasHistory()) + { return; + } // Initializing history tool myHistory = new BRepTools_History; @@ -166,7 +190,9 @@ void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange) // Check if History information is available for this kind of shape. if (!BRepTools_History::IsSupportedType(aS)) + { continue; + } if (UserBreak(aPS)) { @@ -190,9 +216,13 @@ void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange) // Add modified shape with proper orientation TopAbs_ShapeEnum aType = aSp.ShapeType(); if (aType == TopAbs_VERTEX || aType == TopAbs_SOLID) + { aSp.Orientation(aS.Orientation()); + } else if (BOPTools_AlgoTools::IsSplitToReverse(aSp, aS, myContext)) + { aSp.Reverse(); + } myHistory->AddModified(aS, aSp); isModified = true; @@ -207,12 +237,16 @@ void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange) { const TopoDS_Shape& aG = aIt.Value(); if (myMapShape.Contains(aG)) + { myHistory->AddGenerated(aS, aG); + } } // Check if the shape has been deleted, i.e. it is not contained in the result // and has no Modified shapes. if (!isModified && !myMapShape.Contains(aS)) + { myHistory->Remove(aS); + } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CellsBuilder.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CellsBuilder.cxx index 41df7ef60a..2e0d1edc3e 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CellsBuilder.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CellsBuilder.cxx @@ -562,10 +562,14 @@ void BOPAlgo_CellsBuilder::RemoveInternalBoundaries() for (int iType = 0; iType < 2; ++iType) { if (aLSUnify[iType].IsEmpty()) + { continue; + } NCollection_List aLSN; if (RemoveInternals(aLSUnify[iType], aLSN, aKeepMap[iType])) + { bChanged = true; + } // add shapes to result ([unified] edges or faces) for (NCollection_List::Iterator aItLS(aLSN); aItLS.More(); aItLS.Next()) { @@ -853,9 +857,13 @@ bool BOPAlgo_CellsBuilder::RemoveInternals( { // add the warning if (bFaces) + { AddWarning(new BOPAlgo_AlertRemovalOfIBForFacesFailed(aShape)); + } else + { AddWarning(new BOPAlgo_AlertRemovalOfIBForEdgesFailed(aShape)); + } // theLSNew.Assign(theLS); return bRemoved; @@ -882,7 +890,9 @@ bool BOPAlgo_CellsBuilder::RemoveInternals( myMapModified.Bind(aSS, aSU); bRemoved = true; if (pMaterial && !myShapeMaterial.IsBound(aSU)) + { myShapeMaterial.Bind(aSU, *pMaterial); + } } } } @@ -1017,7 +1027,9 @@ bool BOPAlgo_CellsBuilder::RemoveInternals( // Save information about the fuse of the solids into a history map aItS.Initialize(aCB); for (; aItS.More(); aItS.Next()) + { myMapModified.Bind(aItS.Value(), aSNew); + } } } return bRemoved; @@ -1030,8 +1042,10 @@ const NCollection_List* BOPAlgo_CellsBuilder::LocModified(const To // Get shape's modification coming from GF operation const NCollection_List* pLSp = BOPAlgo_Builder::LocModified(theS); if (myMapModified.IsEmpty()) + { // No local modifications return pLSp; + } myHistShapes.Clear(); @@ -1042,7 +1056,9 @@ const NCollection_List* BOPAlgo_CellsBuilder::LocModified(const To // Check if the shape has been unified with other shapes const TopoDS_Shape* pSU = myMapModified.Seek(theS); if (!pSU) + { return nullptr; + } myHistShapes.Append(*pSU); } @@ -1056,9 +1072,13 @@ const NCollection_List* BOPAlgo_CellsBuilder::LocModified(const To const TopoDS_Shape* pSp = &aIt.Value(); const TopoDS_Shape* pSU = myMapModified.Seek(*pSp); if (pSU) + { pSp = pSU; + } if (aMFence.Add(*pSp)) + { myHistShapes.Append(*pSp); + } } } return &myHistShapes; diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CheckerSI.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CheckerSI.cxx index dbebd3ba08..10aaf74ed7 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CheckerSI.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_CheckerSI.cxx @@ -174,19 +174,29 @@ void BOPAlgo_CheckerSI::Perform(const Message_ProgressRange& theRange) Message_ProgressScope aPSZZ(aPS.Next(), nullptr, 4); // Perform intersection with solids if (!HasErrors()) + { PerformVZ(aPSZZ.Next()); + } // if (!HasErrors()) + { PerformEZ(aPSZZ.Next()); + } // if (!HasErrors()) + { PerformFZ(aPSZZ.Next()); + } // if (!HasErrors()) + { PerformZZ(aPSZZ.Next()); + } // if (HasErrors()) + { return; + } // Treat the intersection results PostTreat(); @@ -403,7 +413,9 @@ void BOPAlgo_CheckerSI::PostTreat() void BOPAlgo_CheckerSI::CheckFaceSelfIntersection(const Message_ProgressRange& theRange) { if (myLevelOfCheck < 5) + { return; + } BOPDS_Pair aPK; @@ -421,14 +433,18 @@ void BOPAlgo_CheckerSI::CheckFaceSelfIntersection(const Message_ProgressRange& t { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_FACE) + { continue; + } // const TopoDS_Face& aF = (*(TopoDS_Face*)(&aSI.Shape())); BRepAdaptor_Surface BAsurf(aF, false); GeomAbs_SurfaceType aSurfType = BAsurf.GetType(); if (aSurfType == GeomAbs_Plane || aSurfType == GeomAbs_Cylinder || aSurfType == GeomAbs_Cone || aSurfType == GeomAbs_Sphere) + { continue; + } if (aSurfType == GeomAbs_Torus) { @@ -436,7 +452,9 @@ void BOPAlgo_CheckerSI::CheckFaceSelfIntersection(const Message_ProgressRange& t double aMajorRadius = aTorus.MajorRadius(); double aMinorRadius = aTorus.MinorRadius(); if (aMajorRadius > aMinorRadius + Precision::Confusion()) + { continue; + } } double aTolF = BRep_Tool::Tolerance(aF); diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakeConnected.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakeConnected.cxx index 8244754032..cceecbcfa5 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakeConnected.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakeConnected.cxx @@ -32,20 +32,28 @@ void BOPAlgo_MakeConnected::Perform() // Check the input data CheckData(); if (HasErrors()) + { return; + } if (myHistory.IsNull()) + { myHistory = new BRepTools_History; + } // Glue the arguments MakeConnected(); if (HasErrors()) + { return; + } // Perform material associations for the faces AssociateMaterials(); if (HasErrors()) + { return; + } } //======================================================================= @@ -71,7 +79,9 @@ void BOPAlgo_MakeConnected::CheckData() NCollection_List::Iterator itLA(myArguments); for (; itLA.More(); itLA.Next()) + { BOPTools_AlgoTools::TreatCompound(itLA.Value(), aLA, &aMFence); + } if (aLA.IsEmpty()) { @@ -100,7 +110,9 @@ void BOPAlgo_MakeConnected::MakeConnected() { // Initialize the history if (myGlueHistory.IsNull()) + { myGlueHistory = new BRepTools_History; + } if (myArguments.Extent() == 1) { @@ -122,7 +134,9 @@ void BOPAlgo_MakeConnected::MakeConnected() TopoDS_Compound aCW; BRep_Builder().MakeCompound(aCW); for (NCollection_List::Iterator it(myArguments); it.More(); it.Next()) + { BRep_Builder().Add(aCW, it.Value()); + } AddError(new BOPAlgo_AlertUnableToGlue(aCW)); return; } @@ -150,7 +164,9 @@ void BOPAlgo_MakeConnected::FillOrigins() { NCollection_List::Iterator itLA(myArguments); for (; itLA.More(); itLA.Next()) + { TopExp::MapShapes(itLA.Value(), myAllInputsMap); + } } const int aNbS = myAllInputsMap.Extent(); @@ -158,7 +174,9 @@ void BOPAlgo_MakeConnected::FillOrigins() { const TopoDS_Shape& aS = myAllInputsMap(i); if (!BRepTools_History::IsSupportedType(aS)) + { continue; + } // Get Modified & Generated shapes for (int j = 0; j < 2; ++j) @@ -171,9 +189,13 @@ void BOPAlgo_MakeConnected::FillOrigins() const TopoDS_Shape& aHS = itLH.Value(); NCollection_List* pLOr = myOrigins.ChangeSeek(aHS); if (!pLOr) + { pLOr = myOrigins.Bound(aHS, NCollection_List()); + } if (!pLOr->Contains(aS)) + { pLOr->Append(aS); + } } } } @@ -193,19 +215,29 @@ void BOPAlgo_MakeConnected::AssociateMaterials() BOPTools_AlgoTools::TreatCompound(myShape, aLShapes, &aMFence); if (aLShapes.IsEmpty()) + { return; + } // Define the element type and the material type TopAbs_ShapeEnum anElemType; const TopAbs_ShapeEnum aMaterialType = aLShapes.First().ShapeType(); if (aMaterialType == TopAbs_SOLID || aMaterialType == TopAbs_COMPSOLID) + { anElemType = TopAbs_FACE; + } else if (aMaterialType == TopAbs_FACE || aMaterialType == TopAbs_SHELL) + { anElemType = TopAbs_EDGE; + } else if (aMaterialType == TopAbs_EDGE || aMaterialType == TopAbs_WIRE) + { anElemType = TopAbs_VERTEX; + } else + { return; + } NCollection_List::Iterator itLS(aLShapes); for (; itLS.More(); itLS.Next()) @@ -220,7 +252,9 @@ void BOPAlgo_MakeConnected::AssociateMaterials() const TopoDS_Shape& anElement = anExp.Current(); NCollection_List* pLM = myMaterials.ChangeSeek(anElement); if (!pLM) + { pLM = myMaterials.Bound(anElement, NCollection_List()); + } pLM->Append(aSOr); } } @@ -236,9 +270,13 @@ void BOPAlgo_MakeConnected::Update() // Update history myHistory->Clear(); if (!myGlueHistory.IsNull()) + { myHistory->Merge(myGlueHistory); + } if (!myPeriodicityMaker.History().IsNull()) + { myHistory->Merge(myPeriodicityMaker.History()); + } // Fill the map of origins FillOrigins(); @@ -254,7 +292,9 @@ void BOPAlgo_MakeConnected::Update() void BOPAlgo_MakeConnected::MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams) { if (HasErrors()) + { return; + } // Make the shape periodic myPeriodicityMaker.Clear(); @@ -283,7 +323,9 @@ void BOPAlgo_MakeConnected::MakePeriodic(const BOPAlgo_MakePeriodic::Periodicity void BOPAlgo_MakeConnected::RepeatShape(const int theDirectionID, const int theTimes) { if (HasErrors()) + { return; + } if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors()) { @@ -307,7 +349,9 @@ void BOPAlgo_MakeConnected::RepeatShape(const int theDirectionID, const int theT void BOPAlgo_MakeConnected::ClearRepetitions() { if (HasErrors()) + { return; + } if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors()) { diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakePeriodic.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakePeriodic.cxx index 22491bb66f..18bee5b7ad 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakePeriodic.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakePeriodic.cxx @@ -51,19 +51,25 @@ void BOPAlgo_MakePeriodic::Perform() // Check the validity of input data CheckData(); if (HasErrors()) + { return; + } // Trim the shape to fit to the required period in // required periodic directions Trim(); if (HasErrors()) + { return; + } // Make the shape identical on the opposite sides in // required periodic directions MakeIdentical(); if (HasErrors()) + { return; + } } //======================================================================= @@ -91,7 +97,9 @@ void BOPAlgo_MakePeriodic::CheckData() static void AddToShape(const TopoDS_Shape& theWhat, TopoDS_Shape& theWhere) { if (theWhere.IsNull()) + { BRep_Builder().MakeCompound(TopoDS::Compound(theWhere)); + } BRep_Builder().Add(theWhere, theWhat); } @@ -103,7 +111,9 @@ static void AddToShape(const NCollection_List& theLWhat, TopoDS_Sh { NCollection_List::Iterator it(theLWhat); for (; it.More(); it.Next()) + { AddToShape(it.Value(), theWhere); + } } //======================================================================= @@ -114,7 +124,9 @@ void BOPAlgo_MakePeriodic::Trim() { // Check if trim is required at all if (IsInputXTrimmed() && IsInputYTrimmed() && IsInputZTrimmed()) + { return; + } // Compute bounding box for the shape to use it as a starting // volume for trimming. If required, the volume will be modified @@ -132,7 +144,9 @@ void BOPAlgo_MakePeriodic::Trim() for (int i = 0; i < 3; ++i) { if (IsInputTrimmed(i)) + { continue; + } aPMin.SetCoord(i + 1, PeriodFirst(i)); aPMax.SetCoord(i + 1, PeriodFirst(i) + Period(i)); @@ -183,16 +197,22 @@ void BOPAlgo_MakePeriodic::Trim() void BOPAlgo_MakePeriodic::MakeIdentical() { if (myShape.IsNull()) + { myShape = myInputShape; + } if (mySplitHistory.IsNull()) + { mySplitHistory = new BRepTools_History; + } // Split the negative side of the shape with the geometry // located on the positive side SplitNegative(); if (HasErrors()) + { return; + } // Split the positive side of the shape with the geometry // located on the negative side. @@ -219,7 +239,9 @@ void BOPAlgo_MakePeriodic::SplitNegative() for (int i = 0; i < 3; ++i) { if (!IsPeriodic(i)) + { continue; + } // Translate the shape to the negative side gp_Trsf aNegTrsf; @@ -255,11 +277,15 @@ static void AddTwin( for (; itLT.More(); itLT.Next()) { if (theTwin.IsSame(itLT.Value())) + { break; + } } if (!itLT.More()) + { aTwins->Append(theTwin); + } } //======================================================================= @@ -287,7 +313,9 @@ void BOPAlgo_MakePeriodic::SplitPositive() for (int i = 0; i < 3; ++i) { if (!IsPeriodic(i)) + { continue; + } // Translate the shape to the positive side gp_Trsf aPosTrsf; @@ -304,7 +332,9 @@ void BOPAlgo_MakePeriodic::SplitPositive() const NCollection_List& aSM = aTranslator.Modified(aS); NCollection_List* pTS = aTranslationHistMap.ChangeSeek(aS); if (!pTS) + { pTS = &aTranslationHistMap(aTranslationHistMap.Add(aS, NCollection_List())); + } pTS->Append(aSM.First()); } } @@ -317,7 +347,9 @@ void BOPAlgo_MakePeriodic::SplitPositive() // Split the positive side of the shape SplitShape(aTools, aSplitShapeHist, aSplitToolsHist); if (HasErrors()) + { return; + } mySplitHistory->Merge(aSplitShapeHist); @@ -328,9 +360,13 @@ void BOPAlgo_MakePeriodic::SplitPositive() const TopoDS_Shape* pS = &aTranslationHistMap.FindKey(i); const NCollection_List& aSIm = aSplitShapeHist->Modified(*pS); if (aSIm.Extent() == 1) + { pS = &aSIm.First(); + } else if (aSIm.Extent() > 1) + { continue; + } const NCollection_List& aLTranslated = aTranslationHistMap(i); @@ -424,9 +460,13 @@ void BOPAlgo_MakePeriodic::SplitShape(const NCollection_List& theT myShape = aSplitter.Shape(); // Remember the split history if (!theSplitShapeHistory.IsNull()) + { theSplitShapeHistory->Merge(anObj, aSplitter); + } if (!theSplitToolsHistory.IsNull()) + { theSplitToolsHistory->Merge(theTools, aSplitter); + } } //======================================================================= @@ -436,18 +476,26 @@ void BOPAlgo_MakePeriodic::SplitShape(const NCollection_List& theT const TopoDS_Shape& BOPAlgo_MakePeriodic::RepeatShape(const int theDir, const int theTimes) { if (myRepeatedShape.IsNull()) + { myRepeatedShape = myShape; + } if (!IsPeriodic(theDir)) + { return myRepeatedShape; + } if (theTimes == 0) + { return myRepeatedShape; + } // Get the shape's period in the required direction const int id = BOPAlgo_MakePeriodic::ToDirectionID(theDir); if (myRepeatPeriod[id] < Precision::Confusion()) + { myRepeatPeriod[id] = Period(id); + } const double aPeriod = myRepeatPeriod[id]; // Coefficient to define in which direction the repetition will be performed: @@ -470,7 +518,9 @@ const TopoDS_Shape& BOPAlgo_MakePeriodic::RepeatShape(const int theDir, const in { const TopoDS_Shape& aS = aSubShapesMap(i); if (BRepTools_History::IsSupportedType(aS)) + { aTranslationHistory.AddGenerated(aS, aS); + } } // Create translated copies of the shape @@ -538,10 +588,14 @@ void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHi const BRepTools_History& theGluingHistory) { if (myTwins.IsEmpty()) + { return; + } if (myRepeatedTwins.IsEmpty()) + { myRepeatedTwins = myTwins; + } // New twins NCollection_DataMap, TopTools_ShapeMapHasher> @@ -565,11 +619,15 @@ void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHi for (; itLT.More(); itLT.Next()) { if (aMTwinsDone.Contains(itLT.Value())) + { break; + } } if (itLT.More()) + { // Group of twins has already been processed continue; + } // All shapes generated from the shape itself and generated // from its twins will be the new twins for the shape @@ -586,19 +644,27 @@ void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHi const TopoDS_Shape& aG = itLG.Value(); const NCollection_List& aLM = theGluingHistory.Modified(aG); if (aLM.IsEmpty()) + { aNewGroup.Add(aG); + } else { NCollection_List::Iterator itLM(aLM); for (; itLM.More(); itLM.Next()) + { aNewGroup.Add(itLM.Value()); + } } } if (bShape) + { bShape = false; + } else + { itLT.Next(); + } } // Associate the twins to each other @@ -608,8 +674,12 @@ void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHi NCollection_List* pTwins = aNewTwinsMap.Bound(aNewGroup(i), NCollection_List()); for (int j = 1; j <= aNbTwins; ++j) + { if (i != j) + { pTwins->Append(aNewGroup(j)); + } + } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakerVolume.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakerVolume.cxx index a7f4473bd0..9ebf181a8a 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakerVolume.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_MakerVolume.cxx @@ -370,7 +370,9 @@ void BOPAlgo_MakerVolume::FillInternalShapes(const NCollection_List::Iterator itLA(myDS->Arguments()); for (; itLA.More(); itLA.Next()) + { BOPTools_AlgoTools::TreatCompound(itLA.Value(), aLSC, &aMFence); + } // Get only edges and vertices from arguments NCollection_List aLVE; @@ -386,11 +388,15 @@ void BOPAlgo_MakerVolume::FillInternalShapes(const NCollection_ListShapeInfo(i); if (aSI.ShapeType() != TopAbs_VERTEX) + { continue; + } // Check if the tolerance of the original vertex has been increased if (myIncreasedSS.Contains(i)) { @@ -375,14 +379,20 @@ void BOPAlgo_PaveFiller::RepeatIntersection(const Message_ProgressRange& theRang // Check if the vertex created a new vertex with greater tolerance int nVSD; if (!myDS->HasShapeSD(i, nVSD)) + { continue; + } if (myIncreasedSS.Contains(nVSD)) + { anExtraInterfMap.Add(i); + } } if (anExtraInterfMap.IsEmpty()) + { return; + } // Update iterator of pairs of shapes with interfering boxes myIterator->IntersectExt(anExtraInterfMap); @@ -391,17 +401,23 @@ void BOPAlgo_PaveFiller::RepeatIntersection(const Message_ProgressRange& theRang PerformVV(aPS.Next()); if (HasErrors()) + { return; + } UpdatePaveBlocksWithSDVertices(); PerformVE(aPS.Next()); if (HasErrors()) + { return; + } UpdatePaveBlocksWithSDVertices(); PerformVF(aPS.Next()); if (HasErrors()) + { return; + } UpdatePaveBlocksWithSDVertices(); UpdateInterfsWithSDVertices(); diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_1.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_1.cxx index 7707146b5c..08c9a4a805 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_1.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_1.cxx @@ -186,7 +186,9 @@ int BOPAlgo_PaveFiller::MakeSDVertices(const NCollection_List& theVertIndic // Fill ShapesSD NCollection_DynamicArray& aVVs = myDS->InterfVV(); if (theAddInterfs) + { aVVs.SetIncrement(theVertIndices.Extent()); + } // aItLI.Initialize(theVertIndices); for (; aItLI.More(); aItLI.Next()) diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_10.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_10.cxx index df9f228265..10dd8d905b 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_10.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_10.cxx @@ -69,14 +69,18 @@ void BOPAlgo_PaveFiller::UpdateEdgeTolerance(const int nE, const double theTol) if (myNonDestructive) { if (!myDS->IsNewShape(nE)) + { return; + } NCollection_List::Iterator itLI(aLI); for (; itLI.More(); itLI.Next()) { int nV = itLI.Value(), nVSD; if (!myDS->IsNewShape(nV) && !myDS->HasShapeSD(nV, nVSD)) + { return; + } } } @@ -150,7 +154,9 @@ int BOPAlgo_PaveFiller::UpdateVertex(const int nV, const double aTolNew) myVertsToAvoidExtension.Add(nVNew); if (aTolV < aTolNew) + { myIncreasedSS.Add(nV); + } return nVNew; } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_2.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_2.cxx index 2657c2752d..5e9e398c92 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_2.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_2.cxx @@ -198,7 +198,9 @@ void BOPAlgo_PaveFiller::PerformVE(const Message_ProgressRange& theRange) // NCollection_List* pLV = aMVEPairs.ChangeSeek(aPB); if (!pLV) + { pLV = &aMVEPairs(aMVEPairs.Add(aPB, NCollection_List())); + } pLV->Append(nV); } // @@ -261,7 +263,9 @@ void BOPAlgo_PaveFiller::IntersectVE( myDS->HasShapeSD(nV, nVSD); // if (aMVPB.Contains(nVSD)) + { continue; + } BOPDS_Pair aPair(nVSD, nE); NCollection_List* pLI = aDMVSD.ChangeSeek(aPair); @@ -344,10 +348,14 @@ void BOPAlgo_PaveFiller::IntersectVE( double aT1, aT2; aPB->Range(aT1, aT2); if (aT > aT1 && aT < aT2) + { break; + } } if (!itPB.More()) + { continue; + } BOPDS_Pave aPave; aPave.SetIndex(nVx); @@ -463,8 +471,10 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const NCollection_Map& theMEdges, int nV1, nV2; aPBN->Indices(nV1, nV2); if (nV1 == nV2) + { // Same vertices -> no valid range, no need to unify vertices continue; + } // Decide whether to unify vertices or not if (bCheckDist) @@ -472,8 +482,10 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const NCollection_Map& theMEdges, const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1)); const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2)); if (BOPTools_AlgoTools::ComputeVV(aV1, aV2, myFuzzyValue) == 0) + { // vertices are interfering -> no valid range, unify vertices bHasValidRange = false; + } } if (!bHasValidRange) @@ -608,7 +620,9 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const NCollection_Map& theMEdges, // Init pave blocks for vertices which have acquired SD vertex aItM.Initialize(aMVerticesToInitPB); for (; aItM.More(); aItM.Next()) + { myDS->InitPaveBlocksForVertex(aItM.Value()); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index a01ad3bd94..43ce5daf02 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -410,7 +410,9 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange) occ::handle& aPB = (j < 2) ? aPB2 : aPB1; bIsOnPave[j] = ForceInterfVE(nV[j], aPB, aMEdges); if (bIsOnPave[j]) + { isVExists = true; + } } } @@ -428,8 +430,10 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange) const gp_Pnt aPOnE1 = BRepAdaptor_Curve(aE1).Value(aT1); const gp_Pnt aPOnE2 = BRepAdaptor_Curve(aE2).Value(aT2); if (aPOnE1.Distance(aPOnE2) > Precision::Intersection()) + { // No intersection point continue; + } // Real intersection is present. // Update the existing vertex to cover the intersection point. @@ -739,7 +743,9 @@ void BOPAlgo_PaveFiller::FillShrunkData(occ::handle& thePB) { nE = thePB->OriginalEdge(); if (nE < 0) + { return; + } } const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE))); @@ -787,9 +793,13 @@ void BOPAlgo_PaveFiller::AnalyzeShrunkData(const occ::handle& t if (!theSR.IsDone()) { if (bWholeEdge) + { AddWarning(new BOPAlgo_AlertTooSmallEdge(aWarnShape)); + } else + { AddWarning(new BOPAlgo_AlertBadPositioning(aWarnShape)); + } double aTS1, aTS2; theSR.ShrunkRange(aTS1, aTS2); thePB->SetShrunkData(aTS1, aTS2, Bnd_Box(), false); @@ -797,9 +807,13 @@ void BOPAlgo_PaveFiller::AnalyzeShrunkData(const occ::handle& t } // if (bWholeEdge) + { AddWarning(new BOPAlgo_AlertNotSplittableEdge(aWarnShape)); + } else + { AddWarning(new BOPAlgo_AlertBadPositioning(aWarnShape)); + } } // double aTS1, aTS2; @@ -958,11 +972,15 @@ void BOPAlgo_PaveFiller::UpdateVerticesOfCB() { const occ::handle& aCB = myDS->CommonBlock(itPB.Value()); if (aCB.IsNull()) + { continue; + } const occ::handle& aPBR = aCB->PaveBlock1(); if (!aMPBFence.Add(aPBR)) + { continue; + } double aTolCB = aCB->Tolerance(); if (aTolCB > 0.) @@ -994,7 +1012,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) if (aSI.ShapeType() == TopAbs_VERTEX) { if (myDS->HasInterf(i)) + { myDS->InitPaveBlocksForVertex(i); + } } if (UserBreak(aPSOuter)) { @@ -1013,16 +1033,22 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_EDGE) + { // Not an edge continue; + } if (!aSI.HasReference()) + { // Edge has no pave blocks continue; + } if (aSI.HasFlag()) + { // Degenerated edge continue; + } if (UserBreak(aPSOuter)) { return; @@ -1034,7 +1060,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) const occ::handle& aPB = aItLPB.Value(); const occ::handle& aPBR = myDS->RealPaveBlock(aPB); if (!aMPBFence.Add(aPBR)) + { continue; + } // Get indices int nV1, nV2; @@ -1044,14 +1072,18 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) BOPDS_Pair aPair(nV1, nV2); NCollection_List>* pList = aPBMap.ChangeSeek(aPair); if (!pList) + { pList = &aPBMap(aPBMap.Add(aPair, NCollection_List>(anAlloc))); + } pList->Append(aPBR); } } int aNbPB = aPBMap.Extent(); if (!aNbPB) + { return; + } const bool bSICheckMode = (myArguments.Extent() == 1); @@ -1066,7 +1098,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) } const NCollection_List>& aLPB = aPBMap(i); if (aLPB.Extent() < 2) + { continue; + } const BOPDS_Pair& aPair = aPBMap.FindKey(i); int nV1, nV2; @@ -1099,7 +1133,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) gp_Vec aVTgt1; aBAC1.D1((aT11 + aT12) * 0.5, aPm, aVTgt1); if (aVTgt1.SquareMagnitude() < gp::Resolution()) + { continue; + } aVTgt1.Normalize(); NCollection_List>::Iterator aItLPB2 = aItLPB1; @@ -1118,14 +1154,18 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) // they came from the same argument if ((!myDS->IsNewShape(nV1) && (myDS->Rank(nV1) == iR1)) || (!myDS->IsNewShape(nV2) && (myDS->Rank(nV2) == iR2))) + { continue; + } } // Check that the Pave blocks do not form the Common block already if (!aCB1.IsNull() && !aCB2.IsNull()) { if (aCB1 == aCB2) + { continue; + } } const TopoDS_Edge& aE2 = TopoDS::Edge(myDS->Shape(nE2)); @@ -1143,18 +1183,24 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) GeomAPI_ProjectPointOnCurve& aProjPC = myContext->ProjPC(aE2); aProjPC.Perform(aPm); if (!aProjPC.NbPoints()) + { continue; + } gp_Pnt aPm2; gp_Vec aVTgt2; aBAC2.D1(aProjPC.LowerDistanceParameter(), aPm2, aVTgt2); if (aVTgt2.SquareMagnitude() < gp::Resolution()) + { continue; + } // The angle should be close to zero double aCos = aVTgt1.Dot(aVTgt2.Normalized()); if (std::abs(aCos) < 0.9063) + { bUseAddTol = false; + } } } @@ -1180,7 +1226,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) int aNbPairs = aVEdgeEdge.Length(); if (!aNbPairs) + { return; + } // close preparation step aPSOuter.Next(0.7); @@ -1204,7 +1252,9 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) } NCollection_DynamicArray& aEEs = myDS->InterfEE(); if (aEEs.IsEmpty()) + { aEEs.SetIncrement(10); + } // Analyze the results of intersection looking for TopAbs_EDGE // intersection type only. @@ -1230,11 +1280,15 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) const NCollection_Sequence& aCParts = anEdgeEdge.CommonParts(); if (aCParts.Length() != 1) + { continue; + } const IntTools_CommonPrt& aCP = aCParts(1); if (aCP.Type() != TopAbs_EDGE) + { continue; + } occ::handle aPB[] = {anEdgeEdge.PaveBlock1(), anEdgeEdge.PaveBlock2()}; const int nE1 = aPB[0]->OriginalEdge(); @@ -1264,10 +1318,12 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange) myDS->CommonBlock(aPB[j])->PaveBlocks(); NCollection_List>::Iterator aItLPB(aLPBCB); for (; aItLPB.More(); aItLPB.Next()) + { BOPAlgo_Tools::FillMap>(aPB[j], aItLPB.Value(), aMPBLPB, anAlloc); + } } } BOPAlgo_Tools::FillMap>(aPB[0], aPB[1], aMPBLPB, anAlloc); diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index 9aba878ef0..9e0f0fa18d 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -299,7 +299,9 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange) // Save the pair to avoid their forced intersection NCollection_Map>* pMPB = myFPBDone.ChangeSeek(nF); if (!pMPB) + { pMPB = myFPBDone.Bound(nF, NCollection_Map>()); + } pMPB->Add(aPB); } // for (; aIt.More(); aIt.Next()) { } // for (; myIterator->More(); myIterator->Next()) { @@ -351,7 +353,9 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange) aPB->Range(aT1, aT2); NCollection_List* pList = myDistances.ChangeSeek(BOPDS_Pair(nE, nF)); if (!pList) + { pList = myDistances.Bound(BOPDS_Pair(nE, nF), NCollection_List()); + } pList->Append(EdgeRangeDistance(aT1, aT2, aEdgeFace.MinimalDistance())); } continue; @@ -446,7 +450,9 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange) { bV[j] = CheckFacePaves(nV[j], aMIFOn, aMIFIn); if (!bV[j]) + { bIsOnPave[j] = ForceInterfVF(nV[j], nF); + } } } @@ -466,8 +472,10 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange) bool hasRealIntersection = aMinDistEF < Precision::Intersection(); if (!hasRealIntersection) + { // no intersection point continue; + } // Real intersection is present. // Update the existing vertex to cover the intersection point. @@ -765,7 +773,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const Message_ProgressRange& theRange) { Message_ProgressScope aPS(theRange, nullptr, 1); if (!myIsPrimary) + { return; + } // Now that we have vertices increased and unified, try to find additional // edge/face common blocks among the pairs of edge/face. @@ -780,16 +790,22 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const Message_ProgressRange& theRange) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nE); if (aSI.ShapeType() != TopAbs_EDGE) + { // Not an edge continue; + } if (!aSI.HasReference()) + { // Edge has no pave blocks continue; + } if (aSI.HasFlag()) + { // Degenerated edge continue; + } if (UserBreak(aPS)) { @@ -820,7 +836,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( // Split progress on preparation, intersection and post-treatment stages Message_ProgressScope aPSOuter(theRange, nullptr, 10); if (theMPB.IsEmpty()) + { return; + } // Fill the tree with bounding boxes of the pave blocks BOPTools_BoxTree aBBTree; @@ -835,7 +853,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { FillShrunkData(aPB); if (!aPB->HasShrunkData()) + { continue; + } } if (UserBreak(aPSOuter)) { @@ -864,12 +884,16 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF); if (aSI.ShapeType() != TopAbs_FACE) + { // Not a face continue; + } if (!aSI.HasReference()) + { // Face has no face info continue; + } if (UserBreak(aPSOuter)) { @@ -881,7 +905,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxF)); aSelector.SetBVHSet(&aBBTree); if (!aSelector.Select()) + { continue; + } const TopoDS_Face& aF = TopoDS::Face(aSI.Shape()); const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nF); @@ -892,7 +918,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { NCollection_Map::Iterator itM(*pMVF[iM]); for (; itM.More(); itM.Next()) + { aMVF.Add(itM.Value()); + } } // Pave Blocks of the face @@ -922,14 +950,18 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { const occ::handle& aPB = aPBMap(itLIPB.Value()); if (pMPBF[0]->Contains(aPB) || pMPBF[1]->Contains(aPB) || pMPBF[2]->Contains(aPB)) + { continue; + } // Check if the face contains both vertices of the pave block int nV1, nV2; aPB->Indices(nV1, nV2); if (!aMVF.Contains(nV1) || !aMVF.Contains(nV2)) + { // Face does not contain the vertices continue; + } // Get the edge int nE; @@ -937,11 +969,15 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { nE = aPB->OriginalEdge(); if (nE < 0) + { continue; + } // Make sure that the edge and face came from different arguments if (myDS->Rank(nF) == myDS->Rank(nE)) + { continue; + } } const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE)); @@ -965,11 +1001,15 @@ void BOPAlgo_PaveFiller::ForceInterfEF( gp_Vec aVETgt; aBAC.D1(BOPTools_AlgoTools2D::IntermediatePoint(aTS[0], aTS[1]), aPOnE, aVETgt); if (aVETgt.SquareMagnitude() < gp::Resolution()) + { continue; + } aProjPS.Perform(aPOnE); if (!aProjPS.NbPoints()) + { continue; + } // Check the distance in the middle point, using the max vertices // tolerance as the criteria. @@ -984,12 +1024,16 @@ void BOPAlgo_PaveFiller::ForceInterfEF( : 2 * std::max(BRep_Tool::Tolerance(aV1), BRep_Tool::Tolerance(aV2))); if (aProjPS.LowerDistance() > aTolCheck + myFuzzyValue) + { continue; + } double U, V; aProjPS.LowerDistanceParameters(U, V); if (!myContext->IsPointInFace(aF, gp_Pnt2d(U, V))) + { continue; + } if (aSurfAdaptor.GetType() != GeomAbs_Plane || aBAC.GetType() != GeomAbs_Line) { @@ -1001,7 +1045,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( // We allow deviation of 25 degrees. double aCos = aVFNorm.Normalized().Dot(aVETgt.Normalized()); if (std::abs(aCos) > 0.4226) + { bUseAddTol = false; + } } } @@ -1023,14 +1069,18 @@ void BOPAlgo_PaveFiller::ForceInterfEF( { double aDistEF = aProjPS.LowerDistance(); if (aDistEF < aTolCheck && aDistEF > aTolAdd) + { aTolAdd = aDistEF; + } } } if (aTolAdd > 0.) { aTolAdd -= (BRep_Tool::Tolerance(aE) + BRep_Tool::Tolerance(aF)); if (aTolAdd < 0.) + { aTolAdd = 0.; + } } } @@ -1084,7 +1134,9 @@ void BOPAlgo_PaveFiller::ForceInterfEF( NCollection_DynamicArray& aEFs = myDS->InterfEF(); if (theAddInterf && aEFs.IsEmpty()) + { aEFs.SetIncrement(10); + } // Analyze the results of intersection looking for TopAbs_EDGE // intersection type only. @@ -1108,11 +1160,15 @@ void BOPAlgo_PaveFiller::ForceInterfEF( const NCollection_Sequence& aCParts = anEdgeFace.CommonParts(); if (aCParts.Length() != 1) + { continue; + } const IntTools_CommonPrt& aCP = aCParts(1); if (aCP.Type() != TopAbs_EDGE) + { continue; + } int nE, nF; anEdgeFace.Indices(nE, nF); @@ -1129,11 +1185,15 @@ void BOPAlgo_PaveFiller::ForceInterfEF( // Update face information with new IN pave block myDS->ChangeFaceInfo(nF).ChangePaveBlocksIn().Add(aPB); if (theAddInterf) + { // Fill map for common blocks creation BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, anAlloc); + } } if (aMPBLI.Extent()) + { // Create new common blocks for coinciding pairs BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, anAlloc, myDS); + } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index ad5c8e3bde..ac522f554d 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -638,7 +638,9 @@ static void UpdateSavedTolerance(const BOPDS_PDS& theDS, const int nV = itSS.Value(); double* pTolSaved = theMVTol.ChangeSeek(nV); if (pTolSaved && *pTolSaved < theTolNew) + { *pTolSaved = theTolNew; + } } } @@ -859,10 +861,14 @@ void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange) { const occ::handle& aPB = aMPBOnIn(iPB); if (!aPB->HasEdge()) + { continue; + } if (myDS->ShapeInfo(aPB->OriginalEdge()).HasFlag()) + { continue; + } aPBTree.Add(iPB, Bnd_Tools::Bnd2BVH(myDS->ShapeInfo(aPB->Edge()).Box())); } @@ -968,7 +974,9 @@ void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange) const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE); double aTolE = BRep_Tool::Tolerance(aE); if (aTolNew < aNC.Tolerance()) + { aTolNew = aNC.Tolerance(); // use real tolerance of intersection + } if (aTolNew > aTolE) { UpdateEdgeTolerance(nE, aTolNew); @@ -980,10 +988,14 @@ void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange) const int nF = bInF1 ? nF2 : nF1; NCollection_List* pFaces = aPBFacesMap.ChangeSeek(aPBOut); if (!pFaces) + { pFaces = aPBFacesMap.Bound(aPBOut, NCollection_List()); + } // List is expected to be short, so we allow the check here if (pFaces->IsEmpty() || !pFaces->Contains(nF)) + { pFaces->Append(nF); + } // Try fusing the vertices of the existing pave block // with the vertices put on the real section curve (except @@ -1077,7 +1089,9 @@ void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange) aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion()); // if (aDMVLV.IsBound(nV1)) + { aDMVLV.UnBind(nV1); + } } // ProcessExistingPaveBlocks(aCurInd, @@ -1206,9 +1220,13 @@ void BOPAlgo_PaveFiller::PostTreatFF( int indV = itmap.Value(); const TopoDS_Shape& aVertex = myDS->Shape(indV); if (IndMap.Add(indV)) + { VertsUnused.Add(aVertex); + } else + { VertsUnused.RemoveKey(aVertex); + } } } ///////////////////// @@ -1267,9 +1285,13 @@ void BOPAlgo_PaveFiller::PostTreatFF( const TopoDS_Shape& aS = theMSCPB.FindKey(k); const occ::handle& aPB = theMSCPB(k).PaveBlock1(); if (!aPB.IsNull() && aPB->HasEdge()) + { BRep_Builder().Add(anExistingEdges, aS); + } else + { aLS.Append(aS); + } // add vertices-candidates for SD from the map aDMNewSD, // so that they took part in fuse operation. TopoDS_Iterator itV(aS); @@ -1282,12 +1304,16 @@ void BOPAlgo_PaveFiller::PostTreatFF( { const TopoDS_Shape& aVSD = myDS->Shape(*pSD); if (anAddedSD.Add(aVSD)) + { aLS.Append(aVSD); + } } } } if (anExistingEdges.NbChildren() > 0) + { aLS.Append(anExistingEdges); + } // // The section edges considered as a micro should be // specially treated - their vertices should be united and @@ -1305,7 +1331,9 @@ void BOPAlgo_PaveFiller::PostTreatFF( const int* pSD = aDMNewSD.Seek(nVerts[i]); aVerts[i] = TopoDS::Vertex(myDS->Shape(pSD ? *pSD : nVerts[i])); if (anAddedSD.Add(aVerts[i])) + { aLS.Append(aVerts[i]); + } } // if (aVerts[0].IsSame(aVerts[1])) @@ -1345,10 +1373,14 @@ void BOPAlgo_PaveFiller::PostTreatFF( int iVer = myDS->Index(aVer); const int* pSD = aDMNewSD.Seek(iVer); if (pSD) + { aVer = myDS->Shape(*pSD); + } if (anAddedSD.Add(aVer)) + { aLS.Append(aVer); + } } } // @@ -1379,7 +1411,9 @@ void BOPAlgo_PaveFiller::PostTreatFF( if (aSx.ShapeType() == TopAbs_COMPOUND) { for (TopoDS_Iterator itC(aSx); itC.More(); itC.Next()) + { aLS.Append(itC.Value()); + } continue; } nSx = aPDS->Index(aSx); @@ -1487,7 +1521,9 @@ void BOPAlgo_PaveFiller::PostTreatFF( // The edge became micro edge, check vertices for SD TopoDS_Iterator itV(aSx); for (; itV.More(); itV.Next()) + { aLS.Append(itV.Value()); + } continue; } @@ -1630,7 +1666,6 @@ void BOPAlgo_PaveFiller::PostTreatFF( myDS->AddShapeSD(itDM.Key(), *pSD); } } - return; } //================================================================================================= @@ -1685,7 +1720,9 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( const int nE = itLPB.Value()->Edge(); NCollection_List>* pLPBOnE = anEdgeLPB.ChangeSeek(nE); if (!pLPBOnE) + { pLPBOnE = anEdgeLPB.Bound(nE, NCollection_List>()); + } pLPBOnE->Append(itLPB.Value()); } @@ -1699,7 +1736,9 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( const int nE = aPB->Edge(); NCollection_List>* pLPBOnE = anEdgeLPB.ChangeSeek(nE); if (!pLPBOnE) + { pLPBOnE = anEdgeLPB.Bound(nE, NCollection_List>()); + } pLPBOnE->Append(aPB); aItLPB.Next(); @@ -1735,7 +1774,9 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( { const NCollection_List>& aLPB = itDM.Value(); if (aLPB.Extent() == 1) + { continue; + } bNewCB = true; @@ -1759,15 +1800,21 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( const NCollection_List>& aLPBOnCB = aPBCB->PaveBlocks(); for (NCollection_List>::Iterator it(aLPBOnCB); it.More(); it.Next()) + { aMPaveBlocks.Add(it.Value()); + } // Get faces const NCollection_List& aLFacesOnCB = aPBCB->Faces(); for (NCollection_List::Iterator it(aLFacesOnCB); it.More(); it.Next()) + { aMFaces.Add(it.Value()); + } if (aCB.IsNull()) + { aCB = aPBCB; + } } } @@ -1802,7 +1849,9 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( // Update faces of the common block NCollection_List aLFaces; for (NCollection_Map::Iterator it(aMFaces); it.More(); it.Next()) + { aLFaces.Append(it.Value()); + } aCB->SetFaces(aLFaces); } } @@ -1842,10 +1891,14 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( nV2 = aItMV.Value(); // if (aMVOn.Remove(nV1)) + { aMVOn.Add(nV2); + } // if (aMVIn.Remove(nV1)) + { aMVIn.Add(nV2); + } } // for (; aItMV.More(); aItMV.Next()) { } // if (bVerts) { // @@ -1873,14 +1926,18 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo( const occ::handle& aPB1 = aItLPB.Value(); const occ::handle& aPBR = myDS->RealPaveBlock(aPB1); if (aMPBFence.Add(aPBR)) + { pMPB[i]->Add(aPBR); + } } } else { const occ::handle& aPBR = myDS->RealPaveBlock(aPB); if (aMPBFence.Add(aPBR)) + { pMPB[i]->Add(aPBR); + } } } // for (j = 1; j <= aNbPB; ++j) { } // for (i = 0; i < 2; ++i) { @@ -1935,7 +1992,9 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock(const occ::handle& double& theTolNew) { if (theLSE.IsEmpty()) + { return false; + } double aT1, aT2, aTm, aTx, aTolE, aTolCheck, aTol, aDist; int nE, iFlag, nV1, nV2; @@ -1961,7 +2020,9 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock(const occ::handle& { nE = aItLI.Value(); if (nE < 0) + { continue; + } const BOPDS_ShapeInfo& aSIE = myDS->ChangeShapeInfo(nE); const Bnd_Box& aBoxE = aSIE.Box(); if (!aBoxE.IsOut(aBoxPm)) @@ -2014,7 +2075,9 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock( aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxP1)); aSelector.SetBVHSet(&thePBTree); if (!aSelector.Select()) + { return false; + } // intermediate point Bnd_Box aBoxPm; @@ -2026,7 +2089,9 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock( aBoxPm.Add(aPm); bool isVtgt1Valid = aVTgt1.SquareMagnitude() > gp::Resolution(); if (isVtgt1Valid) + { aVTgt1.Normalize(); + } // last point Bnd_Box aBoxP2; @@ -2068,7 +2133,9 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock( int iFlag1 = (nV11 == nV21 || nV11 == nV22) ? 2 : 1; int iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 : (!aBoxSp.IsOut(aBoxP2) ? 1 : 0); if (!iFlag2) + { continue; + } double aDist = 0.; double aCoeff = 1.; // Coeff for taking in account deflections between edge and theNC @@ -2081,9 +2148,11 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock( { aRealTol = std::max(aRealTol, std::max(aTolV1, aTolV2)); if (theMPBCommon.Contains(aPB)) + { // for an edge, which is a common block with a face, // increase the chance to coincide with section curve aRealTol *= 2.; + } } else if (iFlag1 == 2 && iFlag2 == 2) { @@ -2145,21 +2214,27 @@ bool BOPAlgo_PaveFiller::IsExistingPaveBlock( { aPEStatus = myContext->ComputePE(aPm, aRealTol, aSp, aTx, aDistToSp); if (aPEStatus < 0) + { continue; + } } // if (iFlag1 == 1) { iFlag1 = !myContext->ComputePE(aP1, aRealTol, aSp, aTx, aDist); if (iFlag1 && aDistToSp < aDist) + { aDistToSp = aDist; + } } // if (iFlag2 == 1) { iFlag2 = !myContext->ComputePE(aP2, aRealTol, aSp, aTx, aDist); if (iFlag2 && aDistToSp < aDist) + { aDistToSp = aDist; + } } // if (iFlag1 && iFlag2) @@ -2186,7 +2261,9 @@ static void getBoundPaves(const BOPDS_DS* theDS, const BOPDS_Curve& theNC, int t const NCollection_List& aLP = aPB->ExtPaves(); int aNbEP = aLP.Extent(); if (aNbEP == 0) + { return; + } double aTmin = RealLast(); double aTmax = -aTmin; for (NCollection_List::Iterator aItLP(aLP); aItLP.More(); aItLP.Next()) @@ -2220,7 +2297,9 @@ static void getBoundPaves(const BOPDS_DS* theDS, const BOPDS_Curve& theNC, int t const TopoDS_Vertex& aV = (*(TopoDS_Vertex*)(&aSIV.Shape())); int iFlag = BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol); if (iFlag != 0) + { theNV[j] = -1; + } } } @@ -2244,7 +2323,9 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1, double aTolVnew = Precision::Confusion(); bool isClosed = aP[1].IsEqual(aP[0], aTolVnew); if (isClosed && (aBndNV[0] > 0 || aBndNV[1] > 0)) + { return; + } for (int j = 0; j < 2; ++j) { @@ -2386,11 +2467,15 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const NCollection_DynamicArray anEps && aSqD1Mod > anEps) + { aSin = sqrt(aSin / aSqDist / aSqD1Mod); + } NCollection_List* pList = aIDMVertPBs.ChangeSeek(nV); if (!pList) + { pList = &aIDMVertPBs.ChangeFromIndex(aIDMVertPBs.Add(nV, NCollection_List())); + } PaveBlockDist aPBD = {aPB, aSqDist, aSin, aTolR3D}; pList->Append(aPBD); } @@ -2434,7 +2519,9 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const NCollection_DynamicArray aMaxDistKept) + { aMaxDistKept = aPBD.SquareDist; + } } if (isRemoved && aMaxDistKept > 0) @@ -2717,7 +2804,9 @@ void BOPAlgo_PaveFiller::PutStickPavesOnCurve( for (m = 0; m < 2; ++m) { if (aBndNV[m] >= 0) + { continue; + } aD2 = aPC[m].SquareDistance(aPV); if (aD2 > aDT2) { // no rich @@ -2840,7 +2929,9 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(const NCollection_DynamicArray& aMV) { if (aMV.IsEmpty()) + { return; + } for (int i = 0; i < aVC.Length(); ++i) { @@ -2853,7 +2944,9 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(const NCollection_DynamicArray& aLP = aPB->ExtPaves(); NCollection_List::Iterator itLP(aLP); for (; itLP.More(); itLP.Next()) + { aMV.Remove(itLP.Value().Index()); + } aMV.Remove(aPB->Pave1().Index()); aMV.Remove(aPB->Pave2().Index()); @@ -2998,7 +3091,9 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxES)); aSelector.SetBVHSet(&thePBTree); if (!aSelector.Select()) + { return; + } const double aTolES = BRep_Tool::Tolerance(theES); @@ -3009,7 +3104,9 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( { const occ::handle& aPBF = theMPBOnIn(itPB.Value()); if (theMPB.Contains(aPBF)) + { continue; + } bool bInF1 = (aFI1.PaveBlocksOn().Contains(aPBF) || aFI1.PaveBlocksIn().Contains(aPBF)); bool bInF2 = (aFI2.PaveBlocksOn().Contains(aPBF) || aFI2.PaveBlocksIn().Contains(aPBF)); @@ -3025,7 +3122,9 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( const NCollection_List* pList = myDistances.Seek(BOPDS_Pair(aPBF->OriginalEdge(), nF)); if (!pList) + { continue; + } double aT1, aT2; aPBF->Range(aT1, aT2); @@ -3055,9 +3154,13 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( NCollection_List* pFaces = thePBFacesMap.ChangeSeek(aPBF); if (!pFaces) + { pFaces = thePBFacesMap.Bound(aPBF, NCollection_List()); + } if (pFaces->IsEmpty() || !pFaces->Contains(nF)) + { pFaces->Append(nF); + } } } } @@ -3120,7 +3223,9 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxV)); aSelector.SetBVHSet(&thePBTree); if (!aSelector.Select()) + { continue; + } for (NCollection_List::Iterator it(aSelector.Indices()); it.More(); it.Next()) { @@ -3153,10 +3258,14 @@ void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks( const int nF = bInF1 ? nF2 : nF1; NCollection_List* pFaces = thePBFacesMap.ChangeSeek(aPB); if (!pFaces) + { pFaces = thePBFacesMap.Bound(aPB, NCollection_List()); + } // List is expected to be short, so we allow the check here if (pFaces->IsEmpty() || !pFaces->Contains(nF)) + { pFaces->Append(nF); + } } } } @@ -3339,7 +3448,9 @@ void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks( // Try to project the edge on the faces const NCollection_List* pLFaces = thePBFacesMap.Seek(aPBf); if (!pLFaces) + { return; + } NCollection_List::Iterator itLF(*pLFaces); for (; itLF.More(); itLF.Next()) { @@ -3352,7 +3463,9 @@ void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks( { aPB = aIt.ChangeValue(); if (aFI.PaveBlocksOn().Contains(aPB) || aFI.PaveBlocksIn().Contains(aPB)) + { continue; + } const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); // @@ -3390,11 +3503,15 @@ void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC) const occ::handle& aC3D = aIC.Curve(); // check 3d curve if (aC3D.IsNull()) + { return; + } // check bounds if (!aIC.HasBounds()) + { return; + } // check closeness double aT[2]; @@ -3430,8 +3547,10 @@ void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC) } if (nV < 0) + { // No paves on the bounds of the curve return; + } // Check if the curve is closed using the tolerance // of found vertex @@ -3587,7 +3706,9 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const NCollection_DataMap& a const NCollection_List>& aLPBC = aNC.PaveBlocks(); aItPB.Initialize(aLPBC); for (; aItPB.More(); aItPB.Next()) + { anAllPBs.Append(aItPB.Value()); + } } } @@ -3600,7 +3721,9 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const NCollection_DataMap& a NCollection_List>& aLPB = aPBP(i); aItPB.Initialize(aLPB); for (; aItPB.More(); aItPB.Next()) + { anAllPBs.Append(aItPB.Value()); + } } // Process all pave blocks @@ -3669,16 +3792,22 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const NCollection_DataMap& a } nSp = SplitEdge(nE, nV[0], aT[0], nV[1], aT[1]); if (bCB) + { aCB->SetEdge(nSp); + } else + { aPB->SetEdge(nSp); + } } // if (bRebuild) { } // if (aMPB.Add(aPB)) { } // for (; aItPB.More(); aItPB.Next()) { aMPB.Clear(); if (aMicroEdges.Extent()) + { RemovePaveBlocks(aMicroEdges); + } } //================================================================================================= @@ -3700,9 +3829,13 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const NCollection_Map& theEdges) { const occ::handle& aPB = aItPB.Value(); if (theEdges.Contains(aPB->Edge())) + { aLPB.Remove(aItPB); + } else + { aItPB.Next(); + } } } @@ -3725,9 +3858,13 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const NCollection_Map& theEdges) { const occ::handle& aPB = aItPB.Value(); if (theEdges.Contains(aPB->Edge())) + { aLPB.Remove(aItPB); + } else + { aItPB.Next(); + } } } } @@ -3737,9 +3874,13 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const NCollection_Map& theEdges) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (aSI.ShapeType() != TopAbs_FACE) + { continue; + } if (!aSI.HasReference()) + { continue; + } BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(i); NCollection_IndexedMap>* aIMPB[] = {&aFI.ChangePaveBlocksIn(), @@ -3752,7 +3893,9 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const NCollection_Map& theEdges) { const occ::handle& aPB = aIMPB[k]->FindKey(m); if (theEdges.Contains(aPB->Edge())) + { break; + } } if (m <= aNbPB) { @@ -3762,7 +3905,9 @@ void BOPAlgo_PaveFiller::RemovePaveBlocks(const NCollection_Map& theEdges) { const occ::handle& aPB = aMPBCopy(m); if (!theEdges.Contains(aPB->Edge())) + { aIMPB[k]->Add(aPB); + } } } } @@ -4149,7 +4294,9 @@ void BOPAlgo_PaveFiller::PutSEInOtherFaces(const Message_ProgressRange& theRange const NCollection_List>& aLPBC = aVNC(j).PaveBlocks(); NCollection_List>::Iterator aItPB(aLPBC); for (; aItPB.More(); aItPB.Next()) + { aMPBScAll.Add(aItPB.Value()); + } } } // Perform intersection of collected pave blocks @@ -4164,8 +4311,10 @@ void BOPAlgo_PaveFiller::RemoveMicroSectionEdges( NCollection_IndexedMap>& theMicroPB) { if (theMSCPB.IsEmpty()) + { // no section edges return; + } // Get all F/F interferences NCollection_DynamicArray& aFFs = myDS->InterfFF(); @@ -4229,7 +4378,9 @@ void BOPAlgo_PaveFiller::RemoveMicroSectionEdges( // Overwrite the old map if necessary if (aSEPBMap.Extent() != theMSCPB.Extent()) + { theMSCPB = aSEPBMap; + } } //================================================================================================= @@ -4248,11 +4399,15 @@ void BOPAlgo_PaveFiller::RemoveMicroEdges() { NCollection_List>& aLPB = aPBP(i); if (aLPB.Extent() < 2) + { // No splits continue; + } if (myDS->ShapeInfo(aLPB.First()->OriginalEdge()).HasFlag()) + { continue; + } NCollection_List>::Iterator it(aLPB); for (; it.More(); it.Next()) @@ -4269,7 +4424,9 @@ void BOPAlgo_PaveFiller::RemoveMicroEdges() // Check if it has the valid range FillShrunkData(aPBR); if (!aPBR->HasShrunkData()) + { aMicroEdges.Add(aPBR->Edge()); + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_7.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_7.cxx index b1b727d35d..822b767933 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_7.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_7.cxx @@ -244,7 +244,9 @@ public: iErr = BOPTools_AlgoTools2D::AttachExistingPCurve(aSpz, aCopyE, myF, myContext); } if (iErr) + { BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aCopyE, myF, myContext); + } myNewC2d = BRep_Tool::CurveOnSurface(aCopyE, myF, f, l); if (myNewC2d.IsNull()) @@ -253,7 +255,9 @@ public: return; } else + { myNewTol = BRep_Tool::Tolerance(aCopyE); + } } else { @@ -267,9 +271,13 @@ public: aC2d, myNewC2d); if (myNewC2d != aC2d) + { myNewTol = BRep_Tool::Tolerance(aCopyE); + } else + { myNewC2d.Nullify(); + } } } @@ -408,7 +416,9 @@ void BOPAlgo_PaveFiller::MakeSplitEdges(const Message_ProgressRange& theRange) const occ::handle& aCB = myDS->CommonBlock(aPB); bool bCB = !aCB.IsNull(); if (bCB && !aMCB.Add(aCB)) + { continue; + } aPB->Indices(nV1, nV2); // Check if it is necessary to make the split of the edge @@ -429,7 +439,9 @@ void BOPAlgo_PaveFiller::MakeSplitEdges(const Message_ProgressRange& theRange) { nE = it.Value()->OriginalEdge(); if (myDS->PaveBlocks(nE).Extent() == 1) + { break; + } } if (it.More()) { @@ -448,7 +460,9 @@ void BOPAlgo_PaveFiller::MakeSplitEdges(const Message_ProgressRange& theRange) aPB->SetEdge(nE); } if (!bToSplit) + { continue; + } } } } @@ -576,7 +590,9 @@ void BOPAlgo_PaveFiller::MakePCurves(const Message_ProgressRange& theRange) { Message_ProgressScope aPSOuter(theRange, nullptr, 1); if (myAvoidBuildPCurve || (!mySectionAttribute.PCurveOnS1() && !mySectionAttribute.PCurveOnS2())) + { return; + } bool bHasPC; int i, nF1, aNbC, k, nE, aNbFF, aNbFI, nEx; int j, aNbPBIn, aNbPBOn; @@ -701,7 +717,9 @@ void BOPAlgo_PaveFiller::MakePCurves(const Message_ProgressRange& theRange) const NCollection_DynamicArray& aVNC = aFF.Curves(); aNbC = aVNC.Length(); if (aNbC == 0) + { continue; + } int nF[2]; aFF.Indices(nF[0], nF[1]); // @@ -775,7 +793,9 @@ void BOPAlgo_PaveFiller::MakePCurves(const Message_ProgressRange& theRange) // if aNewPC is null we do not need to update the edge because it already contains // valid p-curve, and only vertices have been updated. if (!aNewPC.IsNull()) + { BRep_Builder().UpdateEdge(aMPC.Edge(), aNewPC, aMPC.Face(), aMPC.GetNewTolerance()); + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_8.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_8.cxx index dd59e76087..53d56ab7f1 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_8.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_PaveFiller_8.cxx @@ -90,7 +90,9 @@ void BOPAlgo_PaveFiller::ProcessDE(const Message_ProgressRange& theRange) myDS->ChangePaveBlocks(anEdgeIndex); Standard_ASSERT_VOID(!aLPBD.IsEmpty(), "ListOfPaveBlock is unexpectedly empty"); if (aLPBD.IsEmpty()) + { continue; + } occ::handle aPBD = aLPBD.First(); // FillPaves(nV, anEdgeIndex, nF, aLPBOut, aPBD); @@ -373,12 +375,16 @@ bool AddSplitPoint(const occ::handle& thePBD, double aT = thePave.Parameter(); // Check that the parameter is inside the Pave Block if (aT - aTD1 < theTol || aTD2 - aT < theTol) + { return false; + } // Check that the pave block does not contain the same parameter int anInd; if (thePBD->ContainsParameter(aT, theTol, anInd)) + { return false; + } // Add the point as an Extra pave to the Pave Block for further // splitting of the latter diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_RemoveFeatures.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_RemoveFeatures.cxx index 3adc0d7c6c..1ffa005f71 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_RemoveFeatures.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_RemoveFeatures.cxx @@ -172,12 +172,16 @@ void BOPAlgo_RemoveFeatures::Perform(const Message_ProgressRange& theRange) OCC_CATCH_SIGNALS if (HasHistory()) + { myHistory = new BRepTools_History(); + } // Check the input data CheckData(); if (HasErrors()) + { return; + } Message_ProgressScope aPS(theRange, "Removing features", 100); BOPAlgo_PISteps aSteps(PIOperation_Last); analyzeProgress(100., aSteps); @@ -230,7 +234,9 @@ void BOPAlgo_RemoveFeatures::CheckData() const TopAbs_ShapeEnum aType = myInputShape.ShapeType(); if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) + { return; // OK + } if (aType == TopAbs_COMPOUND) { @@ -253,9 +259,13 @@ void BOPAlgo_RemoveFeatures::CheckData() { const TopoDS_Shape& aS = aIt.Value(); if (aS.ShapeType() == TopAbs_SOLID || aS.ShapeType() == TopAbs_COMPSOLID) + { aSolids.Append(aS); + } else + { anOtherShapes.Append(aS); + } } if (aSolids.IsEmpty()) @@ -277,7 +287,9 @@ void BOPAlgo_RemoveFeatures::CheckData() TopoDS_Compound aCS; BRep_Builder().MakeCompound(aCS); for (aIt.Initialize(aSolids); aIt.More(); aIt.Next()) + { BRep_Builder().Add(aCS, aIt.Value()); + } myShape = aCS; @@ -323,7 +335,9 @@ void BOPAlgo_RemoveFeatures::PrepareFeatures(const Message_ProgressRange& theRan } const TopoDS_Shape& aF = anExpF.Current(); if (myInputsMap.Contains(aF)) + { aFacesToRemove.Append(aF); + } } } @@ -338,7 +352,9 @@ void BOPAlgo_RemoveFeatures::PrepareFeatures(const Message_ProgressRange& theRan TopoDS_Compound aCFToRemove; BRep_Builder().MakeCompound(aCFToRemove); for (aIt.Initialize(aFacesToRemove); aIt.More(); aIt.Next()) + { BRep_Builder().Add(aCFToRemove, aIt.Value()); + } // Fill the list of features with connexity blocks of faces BOPTools_AlgoTools::MakeConnexityBlocks(aCFToRemove, TopAbs_EDGE, TopAbs_FACE, myFeatures); @@ -420,7 +436,9 @@ public: //! @name Perform the operation myHasAdjacentFaces = (aMFAdjacent.Extent() > 0); if (!myHasAdjacentFaces) + { return; + } // Extend the adjacent faces keeping the connection to the original faces NCollection_IndexedDataMap @@ -476,7 +494,9 @@ private: //! @name Private methods performing the operation // Map the faces of the feature to avoid them in the map of adjacent faces TopoDS_Iterator aIt(myFeature); for (; aIt.More(); aIt.Next()) + { myFeatureFacesMap.Add(aIt.Value()); + } Message_ProgressScope aPSOuter(theRange, nullptr, 2); // Find faces adjacent to the feature using the connection map aIt.Initialize(myFeature); @@ -500,7 +520,9 @@ private: //! @name Private methods performing the operation { const TopoDS_Shape& anAF = itLFA.Value(); if (!myFeatureFacesMap.Contains(anAF)) + { theMFAdjacent.Add(anAF); + } } } } @@ -510,7 +532,9 @@ private: //! @name Private methods performing the operation { NCollection_List::Iterator itLS(*pLS); for (; itLS.More(); itLS.Next()) + { mySolids.Add(itLS.Value()); + } } } @@ -539,7 +563,9 @@ private: //! @name Private methods performing the operation { NCollection_List::Iterator itLS(*pLS); for (; itLS.More(); itLS.Next()) + { mySolids.Add(itLS.Value()); + } } } } @@ -585,7 +611,9 @@ private: //! @name Private methods performing the operation // Add faces for intersection const int aNbF = theFaceExtFaceMap.Extent(); for (int i = 1; i <= aNbF; ++i) + { aGFInter.AddArgument(theFaceExtFaceMap(i)); + } aGFInter.SetRunParallel(myRunParallel); @@ -596,14 +624,18 @@ private: //! @name Private methods performing the operation { aGFInter.Perform(aPSOuter.Next()); if (aGFInter.HasErrors()) + { return; + } anIntResult = aGFInter.Shape(); myHistory->Merge(aGFInter.History()); } else + { anIntResult = aGFInter.Arguments().First(); + } // Prepare the EF map of the extended faces after intersection // to select from them only boundary edges @@ -649,7 +681,9 @@ private: //! @name Private methods performing the operation const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current()); // skip degenerated and seam edges if (BRep_Tool::Degenerated(aE) || BRep_Tool::IsClosed(aE, theFExt)) + { continue; + } NCollection_List aLEIm; TakeModified(aE, theGFInter, aLEIm); NCollection_List::Iterator itLEIm(aLEIm); @@ -657,7 +691,9 @@ private: //! @name Private methods performing the operation { const TopoDS_Shape& aEIm = itLEIm.Value(); if (theEFExtMap.FindFromKey(aEIm).Extent() == 1) + { aMExtEdges.Add(aEIm); + } } } @@ -681,7 +717,9 @@ private: //! @name Private methods performing the operation if (!BRep_Tool::Degenerated(aE) && !BRep_Tool::IsClosed(aE, theFOriginal)) { if (!aMEdgesToCheckOri.Add(aE)) + { aMEdgesToCheckOri.Remove(aE); + } } } } @@ -693,7 +731,9 @@ private: //! @name Private methods performing the operation aGFTrim.Perform(); if (aGFTrim.HasErrors()) + { return; + } // Get all splits const TopoDS_Shape& aSplits = aGFTrim.Shape(); @@ -708,10 +748,14 @@ private: //! @name Private methods performing the operation for (; anExpE.More(); anExpE.Next()) { if (aMExtEdges.Contains(anExpE.Current())) + { break; + } } if (!anExpE.More()) + { aLFTrimmed.Append(aSp); + } } if (aLFTrimmed.Extent() > 1) @@ -724,7 +768,9 @@ private: //! @name Private methods performing the operation anEFMap; NCollection_List::Iterator itLF(aLFTrimmed); for (; itLF.More(); itLF.Next()) + { TopExp::MapShapesAndAncestors(itLF.Value(), TopAbs_EDGE, TopAbs_FACE, anEFMap); + } // Check edges orientations NCollection_Map aFacesToAvoid, aValidFaces; @@ -740,7 +786,9 @@ private: //! @name Private methods performing the operation for (; itLF.More(); itLF.Next()) { if (!aFacesToAvoid.Contains(itLF.Value())) + { BRep_Builder().Add(aCF, itLF.Value()); + } } NCollection_List aLCB; @@ -756,13 +804,17 @@ private: //! @name Private methods performing the operation for (; itF.More(); itF.Next()) { if (aValidFaces.Contains(itF.Value())) + { break; + } } if (!itF.More()) { // Invalid block for (itF.Initialize(aCB); itF.More(); itF.Next()) + { aFacesToAvoid.Add(itF.Value()); + } } } } @@ -772,9 +824,13 @@ private: //! @name Private methods performing the operation for (; itLF.More();) { if (aFacesToAvoid.Contains(itLF.Value())) + { aLFTrimmed.Remove(itLF); + } else + { itLF.Next(); + } } } else if (aLFTrimmed.IsEmpty()) @@ -782,7 +838,9 @@ private: //! @name Private methods performing the operation // Use all splits, including those having the bounds of extended face anExpF.ReInit(); for (; anExpF.More(); anExpF.Next()) + { aLFTrimmed.Append(anExpF.Current()); + } } if (aLFTrimmed.Extent()) @@ -803,7 +861,9 @@ private: //! @name Private methods performing the operation NCollection_IndexedMap aResMap; NCollection_List::Iterator itLF(aLFTrimmed); for (; itLF.More(); itLF.Next()) + { TopExp::MapShapes(itLF.Value(), aResMap); + } NCollection_List aLSplits; aLSplits.Append(aSplits); @@ -895,7 +955,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeatures(const Message_ProgressRange& theRang // - The faces modification after each feature removal to find the // splits of the adjacent and feature faces for the next steps. if (myHistory.IsNull()) + { myHistory = new BRepTools_History(); + } // Remove the features one by one. // It will allow removing the features even if there were @@ -1006,7 +1068,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( aBB.MakeCompound(anOrigF); int aNbFK = aFacesToBeKept.Extent(); for (int i = 1; i <= aNbFK; ++i) + { aBB.Add(anOrigF, aFacesToBeKept(i)); + } // Tool for solids reconstruction BOPAlgo_MakerVolume aMV; @@ -1034,7 +1098,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( aBB.MakeCompound(anAdjF); NCollection_List::Iterator itLFA(aLFA); for (; itLFA.More(); itLFA.Next()) + { aBB.Add(anAdjF, itLFA.Value()); + } aMV.AddArgument(anAdjF); aFacesToBeKept.Add(anAdjF); @@ -1084,12 +1150,16 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( const TopoDS_Shape& aF = theAdjFaces.FindKey(i); const NCollection_List& aLFIm = myHistory->Modified(aF); if (aLFIm.IsEmpty()) + { anAdjFacesSplits.Add(aF); + } else { NCollection_List::Iterator itLFIm(aLFIm); for (; itLFIm.More(); itLFIm.Next()) + { anAdjFacesSplits.Add(itLFIm.Value()); + } } } @@ -1101,7 +1171,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( const TopoDS_Shape& aS = aFacesToBeKept(i); if (anAdjFacesSplits.Contains(aS)) + { continue; + } if (!aPS.More()) { return; @@ -1111,7 +1183,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( { const TopoDS_Shape& aF = anExpF.Current(); if (!aMV.IsDeleted(aF)) + { break; + } } bValid = anExpF.More(); } @@ -1158,7 +1232,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( NCollection_IndexedMap aMSRes; NCollection_List::Iterator itLS(aLSRes); for (; itLS.More(); itLS.Next()) + { TopExp::MapShapes(itLS.Value(), aMSRes); + } // Remove internal shapes and extra faces BRepTools_History aRemHist; @@ -1180,12 +1256,16 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( // Add reconstructed solids NCollection_List::Iterator itLS(aLSRes); for (; itLS.More(); itLS.Next()) + { aBB.Add(aCRes, itLS.Value()); + } // Add unmodified solids itLS.Initialize(anUnTouchedSolids); for (; itLS.More(); itLS.Next()) + { aBB.Add(aCRes, itLS.Value()); + } // Save the result myShape = aCRes; @@ -1198,7 +1278,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature( void BOPAlgo_RemoveFeatures::UpdateHistory(const Message_ProgressRange& theRange) { if (!HasHistory()) + { return; + } // Map the result myMapShape.Clear(); @@ -1213,10 +1295,14 @@ void BOPAlgo_RemoveFeatures::UpdateHistory(const Message_ProgressRange& theRange { const TopoDS_Shape& aS = myInputsMap(i); if (!BRepTools_History::IsSupportedType(aS)) + { continue; + } if (myHistory->IsRemoved(aS)) + { continue; + } if (UserBreak(aPS)) { @@ -1227,14 +1313,18 @@ void BOPAlgo_RemoveFeatures::UpdateHistory(const Message_ProgressRange& theRange if (aLSIm.IsEmpty()) { if (!myMapShape.Contains(aS)) + { aHistory.Remove(aS); + } } NCollection_List::Iterator itLSIm(aLSIm); for (; itLSIm.More(); itLSIm.Next()) { if (!myMapShape.Contains(itLSIm.Value())) + { aHistory.Remove(itLSIm.Value()); + } } } @@ -1249,7 +1339,9 @@ void BOPAlgo_RemoveFeatures::UpdateHistory(const Message_ProgressRange& theRange void BOPAlgo_RemoveFeatures::SimplifyResult(const Message_ProgressRange& theRange) { if (myShape.IsSame(myInputShape)) + { return; + } Message_ProgressScope aPSOuter(theRange, "Simplifyingthe result", 2); ShapeUpgrade_UnifySameDomain aSDTool; aSDTool.Initialize(myShape, true, true); @@ -1257,7 +1349,9 @@ void BOPAlgo_RemoveFeatures::SimplifyResult(const Message_ProgressRange& theRang aSDTool.AllowInternalEdges(false); // Avoid removal of the input edges and vertices if (myMapShape.IsEmpty()) + { TopExp::MapShapes(myShape, myMapShape); + } const int aNbS = myInputsMap.Extent(); Message_ProgressScope aPS(aPSOuter.Next(), nullptr, aNbS); @@ -1268,7 +1362,9 @@ void BOPAlgo_RemoveFeatures::SimplifyResult(const Message_ProgressRange& theRang return; } if (myMapShape.Contains(myInputsMap(i))) + { aSDTool.KeepShape(myInputsMap(i)); + } } // Perform unification @@ -1276,7 +1372,9 @@ void BOPAlgo_RemoveFeatures::SimplifyResult(const Message_ProgressRange& theRang aPSOuter.Next(); myShape = aSDTool.Shape(); if (HasHistory()) + { myHistory->Merge(aSDTool.History()); + } } //======================================================================= @@ -1288,7 +1386,9 @@ void BOPAlgo_RemoveFeatures::PostTreat() const TopAbs_ShapeEnum anInputType = myInputShape.ShapeType(); const TopAbs_ShapeEnum aResType = myShape.ShapeType(); if (aResType == anInputType) + { return; + } TopExp_Explorer anExpS(myShape, TopAbs_SOLID); @@ -1300,12 +1400,18 @@ void BOPAlgo_RemoveFeatures::PostTreat() TopoDS_Shape aRes; if (anInputType == TopAbs_COMPOUND) + { BRep_Builder().MakeCompound(TopoDS::Compound(aRes)); + } else + { BRep_Builder().MakeCompSolid(TopoDS::CompSolid(aRes)); + } for (; anExpS.More(); anExpS.Next()) + { BRep_Builder().Add(aRes, anExpS.Current()); + } myShape = aRes; } @@ -1326,7 +1432,9 @@ void MakeRemoved(const NCollection_List& NCollection_IndexedMap aShapesMap; NCollection_List::Iterator it(theShapes); for (; it.More(); it.Next()) + { TopExp::MapShapes(it.Value(), aShapesMap); + } const int aNbS = aShapesMap.Extent(); for (int i = 1; i <= aNbS; ++i) @@ -1350,7 +1458,9 @@ void FindInternals(const TopoDS_Shape& theS, NCollection_List& the { const TopoDS_Shape& aSS = itS.Value(); if (aSS.Orientation() == TopAbs_INTERNAL) + { theLInt.Append(aSS); + } else { TopoDS_Iterator itSS(aSS); @@ -1390,7 +1500,9 @@ void RemoveInternalWires(const NCollection_List& theShapes, for (; itR.More(); itR.Next()) { if (theRemoved) + { theRemoved->Append(itR.Value()); + } BRep_Builder().Remove(aF, itR.Value()); } aF.Free(false); @@ -1429,9 +1541,13 @@ void GetOriginalFaces( const TopoDS_Shape& aSol = theSolids(i); const NCollection_List& aLFIm = theHistory->Modified(aSol); if (aLFIm.IsEmpty()) + { theSolidsToRebuild.Add(aSol); + } else + { theSolidsToRebuild.Add(aLFIm.First()); + } } // Splits of the feature faces @@ -1442,12 +1558,16 @@ void GetOriginalFaces( const TopoDS_Shape& aF = itM.Value(); const NCollection_List& aLFIm = theHistory->Modified(aF); if (aLFIm.IsEmpty()) + { aFeatureFacesSplits.Add(aF); + } else { NCollection_List::Iterator itLFIm(aLFIm); for (; itLFIm.More(); itLFIm.Next()) + { aFeatureFacesSplits.Add(itLFIm.Value()); + } } } @@ -1480,11 +1600,15 @@ void GetOriginalFaces( const TopoDS_Shape& aF = itF.Value(); // Avoid the feature faces if (aFeatureFacesSplits.Contains(aF)) + { continue; + } // Avoid the adjacent faces if (theAdjFaces.Contains(aF)) + { continue; + } if (aF.Orientation() != TopAbs_INTERNAL) { @@ -1497,7 +1621,9 @@ void GetOriginalFaces( } } else + { theInternalShapes.Append(aSh); + } } } } @@ -1536,7 +1662,9 @@ void GetValidSolids( { TopExp_Explorer anExpS(theMV.Shape(), TopAbs_SOLID); for (; anExpS.More(); anExpS.Next()) + { theLSRes.Append(anExpS.Current()); + } if (theLSRes.Extent() > theNbSol) { @@ -1553,9 +1681,13 @@ void GetValidSolids( for (; itLS.More();) { if (aSolidsToAvoid.Contains(itLS.Value())) + { theLSRes.Remove(itLS); + } else + { itLS.Next(); + } } } @@ -1571,7 +1703,9 @@ void GetValidSolids( NCollection_Map anOrigFacesRes; TopExp_Explorer anExpF(theOrigFaces, TopAbs_FACE); for (; anExpF.More(); anExpF.Next()) + { TakeModified(anExpF.Current(), theMV, anOrigFacesRes); + } NCollection_List::Iterator itLS(theLSRes); for (; itLS.More();) @@ -1580,7 +1714,9 @@ void GetValidSolids( for (; anExpF.More(); anExpF.Next()) { if (anOrigFacesRes.Contains(anExpF.Current())) + { break; + } } if (!anExpF.More()) { @@ -1588,7 +1724,9 @@ void GetValidSolids( theLSRes.Remove(itLS); } else + { itLS.Next(); + } } } } @@ -1625,14 +1763,18 @@ void FindExtraShapes( const NCollection_List* pShapesToValidate = theConnectionMap.Seek(aSIm); if (!pShapesToValidate) + { continue; + } NCollection_List::Iterator itSV(*pShapesToValidate); for (; itSV.More(); itSV.Next()) { const TopoDS_Shape& aShapeToValidate = itSV.Value(); if (pValidShapes->Contains(aShapeToValidate)) + { continue; + } TopoDS_Face aSInShape; FindShape(aSIm, aShapeToValidate, aSInShape); @@ -1640,16 +1782,22 @@ void FindExtraShapes( bool bSameOri = !BOPTools_AlgoTools::IsSplitToReverse(aSInShape, aSToCheckOri, aCtx); if (bSameOri) + { pValidShapes->Add(aShapeToValidate); + } else + { theShapesToAvoid.Add(aShapeToValidate); + } } } } itM.Initialize(*pValidShapes); for (; itM.More(); itM.Next()) + { theShapesToAvoid.Remove(itM.Value()); + } } //======================================================================= @@ -1667,14 +1815,18 @@ void AvoidExtraSharedFaces(NCollection_List& theLSolids, NCollection_List aLFSharedSp; NCollection_List::Iterator itLFS(theLFSharedToAvoid); for (; itLFS.More(); itLFS.Next()) + { TakeModified(itLFS.Value(), theBuilder, aMFSharedSp); + } } NCollection_IndexedDataMap, TopTools_ShapeMapHasher> aFSMap; NCollection_List::Iterator itLS(theLSolids); for (; itLS.More(); itLS.Next()) + { TopExp::MapShapesAndAncestors(itLS.Value(), TopAbs_FACE, TopAbs_SOLID, aFSMap); + } NCollection_List anExtraFaces; NCollection_List aLFArguments; @@ -1688,14 +1840,20 @@ void AvoidExtraSharedFaces(NCollection_List& theLSolids, const TopoDS_Shape& aF = anExpF.Current(); const NCollection_List& aLSol = aFSMap.FindFromKey(aF); if (aLSol.Extent() != 2 || aMFSharedSp.Contains(aF)) + { aLFArguments.Append(aF); + } else + { anExtraFaces.Append(aF); + } } } if (anExtraFaces.IsEmpty()) + { return; + } // Rebuild the solids avoiding the extra faces BOPAlgo_BuilderSolid aBS; @@ -1703,7 +1861,9 @@ void AvoidExtraSharedFaces(NCollection_List& theLSolids, aBS.SetShapes(aLFArguments); aBS.Perform(); if (aBS.HasErrors()) + { return; + } theLSolids = aBS.Areas(); theExtraFaces.Append(anExtraFaces); @@ -1772,12 +1932,16 @@ void TakeModified(const TopoDS_Shape& theS, { const NCollection_List& aModified = theBuilder.Modified(theS); if (aModified.IsEmpty() && !theBuilder.IsDeleted(theS)) + { theList.Append(theS); + } else { NCollection_List::Iterator itM(aModified); for (; itM.More(); itM.Next()) + { theList.Append(itM.Value()); + } } } @@ -1791,12 +1955,16 @@ void TakeModified(const TopoDS_Shape& theS, { const NCollection_List& aModified = theBuilder.Modified(theS); if (aModified.IsEmpty() && !theBuilder.IsDeleted(theS)) + { theMap.Add(theS); + } else { NCollection_List::Iterator itM(aModified); for (; itM.More(); itM.Next()) + { theMap.Add(itM.Value()); + } } } @@ -1826,7 +1994,9 @@ void FindSolid(const TopoDS_Shape& theSol { NCollection_List::Iterator itLFA(*pLFA); for (; itLFA.More(); itLFA.Next()) + { TakeModified(itLFA.Value(), theBuilder, aMFSIm); + } } else { diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ShellSplitter.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ShellSplitter.cxx index e4e3faa769..1416925aea 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ShellSplitter.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ShellSplitter.cxx @@ -238,7 +238,9 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB) { aLFConnected.Append(aF); if (!aBoundaryFaces.Add(aF)) + { aBoundaryFaces.Remove(aF); + } } } // diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Splitter.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Splitter.cxx index 700ae63e0a..76c27a703f 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Splitter.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Splitter.cxx @@ -112,7 +112,9 @@ void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType) const TopoDS_Shape& aSFirst = it.Value(); it.Next(); if (!it.More()) + { myShape = aSFirst; + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Tools.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Tools.cxx index 76847809ce..bdf607ae8a 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Tools.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Tools.cxx @@ -132,7 +132,9 @@ void BOPAlgo_Tools::PerformCommonBlocks( const NCollection_List>& aLPB = aItB.Value(); int aNbPB = aLPB.Extent(); if (aNbPB < 2) + { continue; + } aMFaces.Clear(); anAllocTmp->Reset(false); @@ -155,20 +157,28 @@ void BOPAlgo_Tools::PerformCommonBlocks( const int nF = aItLF.Value(); // Append to common list avoiding duplicates if (aMFaces.Add(nF)) + { aLFaces.Append(nF); + } } if (aCB.IsNull()) + { aCB = aCBx; + } } } if (aCB.IsNull()) + { aCB = new BOPDS_CommonBlock; + } aCB->SetPaveBlocks(aLPB); aCB->SetFaces(aLFaces); for (aItLPB.Initialize(aLPB); aItLPB.More(); aItLPB.Next()) + { pDS->SetCommonBlock(aItLPB.Value(), aCB); + } // Compute tolerance for Common Block double aTolCB = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, pDS, theContext); @@ -216,7 +226,9 @@ void BOPAlgo_Tools::PerformCommonBlocks( for (; it.More(); it.Next()) { if (it.Value() == nF) + { break; + } } if (!it.More()) { @@ -267,7 +279,9 @@ double BOPAlgo_Tools::ComputeToleranceOfCB(const occ::handle& // occ::handle aCtx = theContext; if (aCtx.IsNull()) + { aCtx = new IntTools_Context(); + } // compute max tolerance for common blocks on edges if (aLPB.Extent() > 1) @@ -1063,14 +1077,18 @@ public: const TopoDS_Vertex& aV1 = TopoDS::Vertex(myVertices->FindKey(anID1)); double aTolV1 = BRep_Tool::Tolerance(aV1); if (aTolV1 < myVertices->FindFromIndex(anID1)) + { aTolV1 = myVertices->FindFromIndex(anID1); + } gp_Pnt aP1 = BRep_Tool::Pnt(aV1); const int anID2 = this->myBVHSet1->Element(theID2); const TopoDS_Vertex& aV2 = TopoDS::Vertex(myVertices->FindKey(anID2)); double aTolV2 = BRep_Tool::Tolerance(aV2); if (aTolV2 < myVertices->FindFromIndex(anID2)) + { aTolV2 = myVertices->FindFromIndex(anID2); + } gp_Pnt aP2 = BRep_Tool::Pnt(aV2); double aTolSum2 = aTolV1 + aTolV2 + myFuzzyValue; @@ -1125,7 +1143,9 @@ void BOPAlgo_Tools::IntersectVertices( const TopoDS_Vertex& aV = TopoDS::Vertex(theVertices.FindKey(i)); double aTol = BRep_Tool::Tolerance(aV); if (aTol < theVertices(i)) + { aTol = theVertices(i); + } // Build bnd box for vertex Bnd_Box aBox; @@ -1168,7 +1188,9 @@ void BOPAlgo_Tools::IntersectVertices( NCollection_List& aChain = theChains.Append(NCollection_List()); for (NCollection_List::Iterator itI(aLI); itI.More(); itI.Next()) + { aChain.Append(theVertices.FindKey(itI.Value())); + } } // Add not interfered vertices as a chain of 1 element @@ -1325,7 +1347,9 @@ void BOPAlgo_FillIn3DParts::Perform() aSelector.SetBVHSet(myBBTree); // if (!aSelector.Select()) + { return; + } const NCollection_List& aLIFP = aSelector.Indices(); @@ -1349,7 +1373,9 @@ void BOPAlgo_FillIn3DParts::Perform() // Add own internal faces of the solid into aMSF NCollection_List::Iterator aItLS(myOwnIF); for (; aItLS.More(); aItLS.Next()) + { aMSF.Add(aItLS.Value()); + } // 3. aIVec - faces to process. // Filter the selected faces with faces of the solid. @@ -1361,7 +1387,9 @@ void BOPAlgo_FillIn3DParts::Perform() int nFP = aItLI.Value(); const TopoDS_Shape& aFP = aVShapeBox(nFP).Shape(); if (!aMSF.Contains(aFP)) + { aIVec.Appended() = nFP; + } } // 4. Classify faces relatively solid. @@ -1370,7 +1398,9 @@ void BOPAlgo_FillIn3DParts::Perform() int k, aNbFP = aIVec.Length(); // Sort indices if necessary if (aNbFP > 1) + { std::sort(aIVec.begin(), aIVec.end()); + } if (bIsEmpty) { @@ -1379,7 +1409,9 @@ void BOPAlgo_FillIn3DParts::Perform() // Classification of any point relatively empty solid would always give IN status. // Thus, we consider all selected faces as IN without real classification. for (k = 0; k < aNbFP; ++k) + { myInFaces.Append(aVShapeBox(aIVec(k)).Shape()); + } return; } @@ -1390,7 +1422,9 @@ void BOPAlgo_FillIn3DParts::Perform() if (aNbFP > 1) { for (k = 0; k < aNbFP; ++k) + { MapEdgesAndFaces(aVShapeBox(aIVec(k)).Shape(), aMEFP, anAlloc); + } } aPSOuter.Next(); @@ -1419,7 +1453,9 @@ void BOPAlgo_FillIn3DParts::Perform() int nFP = aIVec(k); const TopoDS_Face& aFP = (*(TopoDS_Face*)&aVShapeBox(nFP).Shape()); if (!aMFDone.Add(aFP)) + { continue; + } // Make connexity blocks of faces, avoiding passing through the // borders of the solid. It helps to reduce significantly the @@ -1449,15 +1485,21 @@ void BOPAlgo_FillIn3DParts::Perform() } } if (bOut) + { continue; + } } if (aFaceToClassify.IsNull()) + { aFaceToClassify = aFP; + } if (aMEFDS.IsEmpty()) + { // Fill EF map for Solid TopExp::MapShapesAndAncestors(mySolid, TopAbs_EDGE, TopAbs_FACE, aMEFDS); + } // All vertices are interfere with the solids box, run classification. bool bIsIN = BOPTools_AlgoTools::IsInternalFace(aFaceToClassify, @@ -1469,7 +1511,9 @@ void BOPAlgo_FillIn3DParts::Perform() { aItLS.Initialize(aLCBF); for (; aItLS.More(); aItLS.Next()) + { myInFaces.Append(aItLS.Value()); + } } } } @@ -1487,7 +1531,9 @@ void BOPAlgo_FillIn3DParts::MapEdgesAndFaces( { const TopoDS_Shape& aW = myItF.Value(); if (aW.ShapeType() != TopAbs_WIRE) + { continue; + } myItW.Initialize(aW); for (; myItW.More(); myItW.Next()) @@ -1496,7 +1542,9 @@ void BOPAlgo_FillIn3DParts::MapEdgesAndFaces( NCollection_List* pLF = theEFMap.ChangeSeek(aE); if (!pLF) + { pLF = &theEFMap(theEFMap.Add(aE, NCollection_List(theAllocator))); + } pLF->Append(theF); } } @@ -1517,7 +1565,9 @@ void BOPAlgo_FillIn3DParts::MakeConnexityBlock( // Add start element theLCB.Append(theFStart); if (theEFMap.IsEmpty()) + { return; + } NCollection_List::Iterator aItCB(theLCB); for (; aItCB.More(); aItCB.Next()) @@ -1528,7 +1578,9 @@ void BOPAlgo_FillIn3DParts::MakeConnexityBlock( { const TopoDS_Shape& aW = myItF.Value(); if (aW.ShapeType() != TopAbs_WIRE) + { continue; + } myItW.Initialize(aW); for (; myItW.More(); myItW.Next()) @@ -1537,19 +1589,25 @@ void BOPAlgo_FillIn3DParts::MakeConnexityBlock( if (theMEAvoid.Contains(aE) || BRep_Tool::Degenerated(aE)) { if (theFaceToClassify.IsNull()) + { theFaceToClassify = TopoDS::Face(aF); + } continue; } const NCollection_List* pLF = theEFMap.Seek(aE); if (!pLF) + { continue; + } NCollection_List::Iterator aItLF(*pLF); for (; aItLF.More(); aItLF.Next()) { const TopoDS_Shape& aFToAdd = aItLF.Value(); if (theMFDone.Add(aFToAdd)) + { theLCB.Append(aFToAdd); + } } } } @@ -1596,7 +1654,9 @@ void BOPAlgo_Tools::ClassifyFaces( // Get bounding box for the face const Bnd_Box* pBox = theShapeBoxMap.Seek(aF); if (pBox) + { aSB.SetBox(*pBox); + } else { // Build the bounding box @@ -1633,7 +1693,9 @@ void BOPAlgo_Tools::ClassifyFaces( // Get bounding box for the solid const Bnd_Box* pBox = theShapeBoxMap.Seek(aSolid); if (pBox) + { aFIP.SetBoxS(*pBox); + } else { // Build the bounding box @@ -1642,14 +1704,18 @@ void BOPAlgo_Tools::ClassifyFaces( if (!aBox.IsWhole()) { if (BOPTools_AlgoTools::IsInvertedSolid(aSolid)) + { aBox.SetWhole(); + } } aFIP.SetBoxS(aBox); } const NCollection_List* pLIF = theSolidsIF.Seek(aSolid); if (pLIF) + { aFIP.SetOwnIF(*pLIF); + } aFIP.SetBBTree(&aBBTree); aFIP.SetShapeBoxVector(aVSB); @@ -1690,7 +1756,9 @@ void BOPAlgo_Tools::FillInternals( const occ::handle& theContext) { if (theSolids.IsEmpty() || theParts.IsEmpty()) + { return; + } // Map the solids to avoid classification of the own shapes of the solids NCollection_IndexedMap aMSSolids; @@ -1726,17 +1794,23 @@ void BOPAlgo_Tools::FillInternals( { const TopoDS_Shape& aPartIm = itIm.Value(); if (!aMSSolids.Contains(aPartIm)) + { aLParts.Append(aPartIm); + } } } else if (!aMSSolids.Contains(aPart)) + { aLParts.Append(aPart); + } break; } default: { for (TopoDS_Iterator it(aPart); it.More(); it.Next()) + { aLPartsInput.Append(it.Value()); + } break; } } @@ -1753,7 +1827,9 @@ void BOPAlgo_Tools::FillInternals( { const TopoDS_Shape& aSolid = itLS.Value(); if (aSolid.ShapeType() != TopAbs_SOLID) + { continue; + } TopoDS_Solid aSd = *(TopoDS_Solid*)&aSolid; @@ -1769,7 +1845,9 @@ void BOPAlgo_Tools::FillInternals( { NCollection_List* pFaces = anINFaces.ChangeSeek(aSd); if (!pFaces) + { pFaces = anINFaces.Bound(aSd, NCollection_List()); + } pFaces->Append(aPart); } else @@ -1780,7 +1858,9 @@ void BOPAlgo_Tools::FillInternals( aLParts.Remove(itLP); } else + { itLP.Next(); + } } } @@ -1797,7 +1877,9 @@ void BOPAlgo_Tools::FillInternals( NCollection_List::Iterator itLF(aFaces); for (; itLF.More(); itLF.Next()) + { BRep_Builder().Add(aCF, itLF.Value()); + } // Build blocks from the faces NCollection_List aLCB; @@ -1840,11 +1922,15 @@ bool BOPAlgo_Tools::TrsfToPoint(const Bnd_Box& theBox1, gp_XYZ aBCenter = (aBox.CornerMin().XYZ() + aBox.CornerMax().XYZ()) / 2.; double aPBDist = (thePoint.XYZ() - aBCenter).Modulus(); if (aPBDist < theCriteria) + { return false; + } double aBSize = std::sqrt(aBox.SquareExtent()); if ((aBSize / aPBDist) > (1. / theCriteria)) + { return false; + } theTrsf.SetTranslation(gp_Vec(aBox.CornerMin(), thePoint)); return true; diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ToolsProvider.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ToolsProvider.cxx index 1bb2f7010a..0bb68b0080 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ToolsProvider.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_ToolsProvider.cxx @@ -47,7 +47,9 @@ void BOPAlgo_ToolsProvider::Clear() void BOPAlgo_ToolsProvider::AddTool(const TopoDS_Shape& theShape) { if (myMapTools.Add(theShape)) + { myTools.Append(theShape); + } } //================================================================================================= @@ -57,5 +59,7 @@ void BOPAlgo_ToolsProvider::SetTools(const NCollection_List& theSh myTools.Clear(); NCollection_List::Iterator aIt(theShapes); for (; aIt.More(); aIt.Next()) + { AddTool(aIt.Value()); + } } diff --git a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_WireSplitter_1.cxx b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_WireSplitter_1.cxx index f583efb74a..2660043817 100644 --- a/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_WireSplitter_1.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_WireSplitter_1.cxx @@ -82,8 +82,6 @@ static void Path(const BRepAdaptor_Surface& aGAS, NCollection_List, TopTools_ShapeMapHasher>& mySmartMap); -static double Angle(const gp_Dir2d& aDir2D); - static double Tolerance2D(const TopoDS_Vertex& aV, const BRepAdaptor_Surface& aGAS); static double UTolerance2D(const TopoDS_Vertex& aV, const BRepAdaptor_Surface& aGAS); @@ -148,7 +146,9 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFac bIsClosed = BRep_Tool::Degenerated(aE) || BRep_Tool::IsClosed(aE, myFace); if (!aMS.Add(aE) && !bIsClosed) + { aMS.Remove(aE); + } // aItS.Initialize(aE); @@ -848,7 +848,9 @@ double Angle(const gp_Dir2d& aDir2D) anAngle = aRefDir.Angle(aDir2D); if (anAngle < 0.) + { anAngle += M_PI + M_PI; + } return anAngle; } diff --git a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_DS.cxx b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_DS.cxx index 862cadf31c..cc419529b8 100644 --- a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_DS.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_DS.cxx @@ -464,10 +464,14 @@ void BOPDS_DS::InitPaveBlocks(const int theEdgeIndex) aVertexIndex = GetSameDomainIndex(aVertexIndex); BOPDS_Pave aPave(aVertexIndex, aVertexParam); - if (anEdgeInfo.HasFlag()) // for a degenerated edge append pave unconditionally + if (anEdgeInfo.HasFlag()) + { // for a degenerated edge append pave unconditionally aPaveBlock->AppendExtPave1(aPave); + } else + { aPaveBlock->AppendExtPave(aPave); + } // Handle closed edges (seam edges) that have a single vertex shared by both ends. // In this case, we need to add two paves: one for the start and one for the end diff --git a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_Iterator.cxx b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_Iterator.cxx index 7e741929fd..3271c59032 100644 --- a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_Iterator.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_Iterator.cxx @@ -280,7 +280,9 @@ void BOPDS_Iterator::Intersect(const occ::handle& theCtx, { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (!aSI.HasBRep()) + { continue; + } const Bnd_Box& aBox = aSI.Box(); aBoxTree.Add(i, Bnd_Tools::Bnd2BVH(aBox)); } @@ -310,12 +312,16 @@ void BOPDS_Iterator::Intersect(const occ::handle& theCtx, { const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair]; if (!aRange.Contains(aPair.ID1)) + { // Go to the next range break; + } if (aRange.Contains(aPair.ID2)) + { // Go to the next pair continue; + } const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo(aPair.ID1); const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo(aPair.ID2); @@ -329,7 +335,9 @@ void BOPDS_Iterator::Intersect(const occ::handle& theCtx, // avoid interfering of the shape with its sub-shapes if (((iType1 < iType2) && aSI1.HasSubShape(aPair.ID2)) || ((iType1 > iType2) && aSI2.HasSubShape(aPair.ID1))) + { continue; + } if (theCheckOBB) { @@ -338,7 +346,9 @@ void BOPDS_Iterator::Intersect(const occ::handle& theCtx, const Bnd_OBB& anOBB2 = theCtx->OBB(aSI2.Shape(), theFuzzyValue); if (anOBB1.IsOut(anOBB2)) + { continue; + } } int iX = BOPDS_Tools::TypeToInteger(aType1, aType2); @@ -353,7 +363,9 @@ void BOPDS_Iterator::Intersect(const occ::handle& theCtx, void BOPDS_Iterator::IntersectExt(const NCollection_Map& theIndices) { if (!myDS) + { return; + } const int aNb = myDS->NbSourceShapes(); @@ -365,7 +377,9 @@ void BOPDS_Iterator::IntersectExt(const NCollection_Map& theIndices) { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (!aSI.IsInterfering() || (aSI.ShapeType() == TopAbs_SOLID)) + { continue; + } // if (theIndices.Contains(i)) { @@ -403,7 +417,9 @@ void BOPDS_Iterator::IntersectExt(const NCollection_Map& theIndices) BOPDS_TSR& aTSRi = aVTSR(k); const NCollection_List& aLI = aTSRi.Indices(); if (aLI.IsEmpty()) + { continue; + } const int i = aTSRi.Index(); const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); @@ -417,7 +433,9 @@ void BOPDS_Iterator::IntersectExt(const NCollection_Map& theIndices) const int j = itLI.Value(); // Index in DS const int iRankJ = myDS->Rank(j); if (iRankI == iRankJ) + { continue; + } const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j); const TopAbs_ShapeEnum aTJ = aSJ.ShapeType(); @@ -425,14 +443,18 @@ void BOPDS_Iterator::IntersectExt(const NCollection_Map& theIndices) // avoid interfering of the shape with its sub-shapes if (((iTI < iTJ) && aSI.HasSubShape(j)) || ((iTI > iTJ) && aSJ.HasSubShape(i))) + { continue; + } BOPDS_Pair aPair(i, j); if (aMPFence.Add(aPair)) { const int iX = BOPDS_Tools::TypeToInteger(aTI, aTJ); if (iX < BOPDS_Iterator::NbExtInterfs()) + { myExtLists(iX).Append(aPair); + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_IteratorSI.cxx b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_IteratorSI.cxx index e237f1c03b..fccc4b1055 100644 --- a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_IteratorSI.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_IteratorSI.cxx @@ -70,7 +70,9 @@ void BOPDS_IteratorSI::Intersect(const occ::handle& theCtx, { const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); if (!aSI.IsInterfering()) + { continue; + } const Bnd_Box& aBoxEx = aSI.Box(); aBBTree.Add(i, Bnd_Tools::Bnd2BVH(aBoxEx)); @@ -105,7 +107,9 @@ void BOPDS_IteratorSI::Intersect(const occ::handle& theCtx, // avoid interfering of the shape with its sub-shapes if (((iType1 < iType2) && aSI1.HasSubShape(aPair.ID2)) || ((iType1 > iType2) && aSI2.HasSubShape(aPair.ID1))) + { continue; + } if (theCheckOBB) { @@ -114,7 +118,9 @@ void BOPDS_IteratorSI::Intersect(const occ::handle& theCtx, const Bnd_OBB& anOBB2 = theCtx->OBB(aSI2.Shape(), theFuzzyValue); if (anOBB1.IsOut(anOBB2)) + { continue; + } } int iX = BOPDS_Tools::TypeToInteger(aType1, aType2); diff --git a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_PaveBlock.cxx b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_PaveBlock.cxx old mode 100755 new mode 100644 index 356a8e4c77..94b1600602 --- a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_PaveBlock.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_PaveBlock.cxx @@ -189,9 +189,13 @@ void BOPDS_PaveBlock::RemoveExtPave(const int theVertNum) while (itPaves.More()) { if (itPaves.Value().Index() == theVertNum) + { myExtPaves.Remove(itPaves); + } else + { itPaves.Next(); + } } myMFence.Remove(theVertNum); } diff --git a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_SubIterator.cxx b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_SubIterator.cxx index 76cd6beac3..187ac8d9be 100644 --- a/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_SubIterator.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPDS/BOPDS_SubIterator.cxx @@ -103,7 +103,9 @@ void BOPDS_SubIterator::Prepare() void BOPDS_SubIterator::Intersect() { if (!mySubSet1->Extent() || !mySubSet2->Extent()) + { return; + } // Construct BVH tree for each sub-set BOPTools_BoxTree aBBTree[2]; @@ -138,11 +140,15 @@ void BOPDS_SubIterator::Intersect() { const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair]; if (aPair.ID1 == aPair.ID2) + { continue; + } BOPDS_Pair aDSPair(std::min(aPair.ID1, aPair.ID2), std::max(aPair.ID1, aPair.ID2)); if (!aMPKFence.Add(aDSPair)) + { continue; + } const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo(aPair.ID1); const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo(aPair.ID2); @@ -156,7 +162,9 @@ void BOPDS_SubIterator::Intersect() // avoid interfering of the shape with its sub-shapes if (((iType1 < iType2) && aSI1.HasSubShape(aPair.ID2)) || ((iType1 > iType2) && aSI2.HasSubShape(aPair.ID1))) + { continue; + } myList.Append(aDSPair); } diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx index e9346cd366..f708a5d2d9 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx @@ -142,7 +142,9 @@ void BOPTools_AlgoTools::MakeConnexityBlocks( { const TopoDS_Shape& aS2 = aItLS.Value(); if (aMFence.Add(aS2)) + { aLBlock.Append(aS2); + } } } } @@ -172,7 +174,9 @@ void BOPTools_AlgoTools::MakeConnexityBlocks(const TopoDS_Shape& the TopoDS_Compound aBlock; BRep_Builder().MakeCompound(aBlock); for (NCollection_List::Iterator it(aLB); it.More(); it.Next()) + { BRep_Builder().Add(aBlock, it.Value()); + } theLCB.Append(aBlock); } @@ -197,9 +201,13 @@ void BOPTools_AlgoTools::MakeConnexityBlocks(const NCollection_List> aLCB; @@ -235,7 +243,9 @@ void BOPTools_AlgoTools::MakeConnexityBlocks(const NCollection_List aTolEMax) + { aTolEMax = aTolE; + } } } if (aTolEMax > aTolF1) + { aTolF1 = aTolEMax; + } if (aTolEMax > aTolF2) + { aTolF2 = aTolEMax; + } } // Checking criteria @@ -1251,7 +1281,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Shape& t // default: if (theError) + { *theError = 100; + } break; } return bRet; @@ -1288,7 +1320,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& t { // Set OK error status if (theError) + { *theError = 0; + } // Compare surfaces occ::handle aSFSp = BRep_Tool::Surface(theFSp); @@ -1329,7 +1363,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& t if (!anExp.More()) { if (theError) + { *theError = 1; + } // The point has not been found. return bDone; } @@ -1341,7 +1377,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& t if (!bDone) { if (theError) + { *theError = 2; + } return bDone; } // @@ -1358,7 +1396,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& t if (!bDone) { if (theError) + { *theError = 3; + } return bDone; } // UV coordinates of the point on the original face @@ -1371,7 +1411,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& t if (!bDone) { if (theError) + { *theError = 4; + } return bDone; } // @@ -1399,13 +1441,17 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Edge& t if (BRep_Tool::Degenerated(theESp) || BRep_Tool::Degenerated(theEOr)) { if (theError) + { *theError = 1; + } return false; } // Set OK error status if (theError) + { *theError = 0; + } // Get the curves from the edges double f, l; @@ -1414,12 +1460,16 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Edge& t // If the curves are the same, compare orientations only if (aCSp == aCOr) + { return theESp.Orientation() != theEOr.Orientation(); + } // Find valid range of the split edge, to ensure that the point for computing // tangent vectors will be inside both edges. if (!BRepLib::FindValidRange(theESp, f, l)) + { BRep_Tool::Range(theESp, f, l); + } // Error code int anErr = 0; @@ -1465,7 +1515,9 @@ bool BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Edge& t } if (theError) + { *theError = anErr; + } return false; } @@ -1739,7 +1791,9 @@ void BOPTools_AlgoTools::MakeVertex(const NCollection_List& aLV, T { int aNb = aLV.Extent(); if (aNb == 1) + { aVnew = *((TopoDS_Vertex*)(&aLV.First())); + } else if (aNb > 1) { double aNTol; diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D.cxx index 09638a16ba..4ba27198bf 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D.cxx @@ -67,7 +67,6 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(const TopoDS_Edge& aTolFact = std::max(aTolEdge, aTolPC); aBB.UpdateEdge(aE, aC2D, aF, aTolFact); - return; } //================================================================================================= @@ -120,7 +119,6 @@ void BOPTools_AlgoTools2D::PointOnSurface(const TopoDS_Edge& a aC2D->D0(aParameter, aP2D); U = aP2D.X(); V = aP2D.Y(); - return; } //================================================================================================= @@ -135,7 +133,6 @@ void BOPTools_AlgoTools2D::CurveOnSurface(const TopoDS_Edge& a // BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aFirst, aLast, aToler, theContext); // - return; } //================================================================================================= @@ -160,7 +157,6 @@ void BOPTools_AlgoTools2D::CurveOnSurface(const TopoDS_Edge& a BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, theContext); aC2D = C2D; - return; } //================================================================================================= @@ -423,7 +419,9 @@ double BOPTools_AlgoTools2D::IntermediatePoint(const TopoDS_Edge& aE) occ::handle aC1 = BRep_Tool::Curve(aE, aT1, aT2); if (aC1.IsNull()) + { BRep_Tool::Range(aE, aT1, aT2); + } aT = BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); return aT; @@ -621,9 +619,13 @@ void BOPTools_AlgoTools2D::MakePCurveOnFace(const TopoDS_Face& if ((aTCFirst - aT1) > Precision::PConfusion() || (aT2 - aTCLast) > Precision::PConfusion()) { if (aTCFirst < aT1) + { aTCFirst = aT1; + } if (aTCLast > aT2) + { aTCLast = aT2; + } GeomLib::SameRange(Precision::PConfusion(), aC2D, aTCFirst, aTCLast, aT1, aT2, aC2D); } @@ -680,7 +682,9 @@ void BOPTools_AlgoTools2D::IsEdgeIsoline(const TopoDS_Edge& theE, const double aSqMagn = aT.SquareMagnitude(); if (aSqMagn <= gp::Resolution()) + { return; + } // Normalize aT aT /= sqrt(aSqMagn); diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D_1.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D_1.cxx index c828ceb6f3..fb194b601c 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D_1.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools2D_1.cxx @@ -153,7 +153,9 @@ int BOPTools_AlgoTools2D::AttachExistingPCurve(const TopoDS_Edge& double aNewTol = BRep_Tool::Tolerance(aE1T); TopoDS_Iterator it(aE1); for (; it.More(); it.Next()) + { aBB.UpdateVertex(TopoDS::Vertex(it.Value()), aNewTol); + } return iRet; } diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools3D.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools3D.cxx index dc6734775a..44f5e13231 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools3D.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools3D.cxx @@ -85,9 +85,13 @@ bool BOPTools_AlgoTools3D::DoSplitSEAMOnFace(const TopoDS_Edge& aSplit, const To bIsVPeriodic = aS->IsVClosed(); if (bIsUPeriodic) + { anUPeriod = aUmax - aUmin; + } if (bIsVPeriodic) + { anVPeriod = aVmax - aVmin; + } // if (!bIsUPeriodic && !bIsVPeriodic) @@ -97,8 +101,9 @@ bool BOPTools_AlgoTools3D::DoSplitSEAMOnFace(const TopoDS_Edge& aSplit, const To aRTS = occ::down_cast(aS); // if (aRTS.IsNull()) + { return false; - + } else { occ::handle aSB; @@ -233,10 +238,14 @@ bool BOPTools_AlgoTools3D::DoSplitSEAMOnFace(const TopoDS_Edge& theEOrigin, const TopoDS_Face& theFace) { if (!BRep_Tool::IsClosed(theEOrigin, theFace)) + { return false; + } if (BRep_Tool::IsClosed(theESplit, theFace)) + { return true; + } TopoDS_Edge aESplit = theESplit; aESplit.Orientation(TopAbs_FORWARD); @@ -247,7 +256,9 @@ bool BOPTools_AlgoTools3D::DoSplitSEAMOnFace(const TopoDS_Edge& theEOrigin, double aTS1, aTS2; occ::handle aC2DSplit = BRep_Tool::CurveOnSurface(aESplit, aFace, aTS1, aTS2); if (aC2DSplit.IsNull()) + { return false; + } double aT1, aT2; occ::handle aC2D1 = @@ -266,13 +277,17 @@ bool BOPTools_AlgoTools3D::DoSplitSEAMOnFace(const TopoDS_Edge& theEOrigin, aProjPC2.Init(aPMid, aC2D2, aT1, aT2); if (!aProjPC1.NbPoints() && !aProjPC2.NbPoints()) + { return false; + } double aDist1 = aProjPC1.NbPoints() ? aProjPC1.LowerDistance() : RealLast(); double aDist2 = aProjPC2.NbPoints() ? aProjPC2.LowerDistance() : RealLast(); if (aDist1 > Precision::PConfusion() && aDist2 > Precision::PConfusion()) + { return false; + } // choose the closest and take corresponding point from the opposite gp_Pnt2d aNewPnt = aDist1 < aDist2 ? aC2D2->Value(aProjPC1.LowerDistanceParameter()) @@ -400,18 +415,24 @@ bool BOPTools_AlgoTools3D::GetNormalToSurface(const occ::handle& a double aLenU = aD1U.SquareMagnitude(); if (aLenU < gp::Resolution()) + { return false; + } double aLenV = aD1V.SquareMagnitude(); if (aLenV < gp::Resolution()) + { return false; + } gp_Dir aDD1U(aD1U); gp_Dir aDD1V(aD1V); bool bFlag = IntTools_Tools::IsDirsCoinside(aDD1U, aDD1U); if (!bFlag) + { return bFlag; + } aDNS = aDD1U ^ aDD1V; return bFlag; diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_1.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_1.cxx index 8a1f8f1347..abe4a52721 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_1.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_1.cxx @@ -476,7 +476,9 @@ void CheckEdge(const TopoDS_Edge& { double aNewTolerance = sqrt(aD2) + dd; if (aNewTolerance < aMaxTol) + { UpdateShape(aV, aNewTolerance, aMapToAvoid); + } } } aItPR.Next(); @@ -502,7 +504,9 @@ void CheckEdge(const TopoDS_Edge& { double aNewTolerance = sqrt(aD2) + dd; if (aNewTolerance < aMaxTol) + { UpdateShape(aV, aNewTolerance, aMapToAvoid); + } } } } @@ -732,7 +736,9 @@ void CorrectWires(const TopoDS_Face& const TopoDS_Shape& aE2 = *aEData2.Edge; if (aE1.IsSame(aE2)) + { continue; + } aD2 = IntersectCurves2d(aV, aS, aEData1, aEData2, aMapEdgeLen); if (aD2 > aD2max) @@ -861,7 +867,9 @@ void CorrectEdgeTolerance( // 2. Tolerances in InContext { if (myCref.IsNull()) + { return; + } occ::handle& TE = *((occ::handle*)&myShape.TShape()); double Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape)); diff --git a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_2.cxx b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_2.cxx index 0024f09062..4251a26c4b 100644 --- a/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_2.cxx +++ b/src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools_2.cxx @@ -126,7 +126,9 @@ TopoDS_Edge BOPTools_AlgoTools::CopyEdge(const TopoDS_Edge& theEdge) TopoDS_Edge aNewEdge = TopoDS::Edge(theEdge.Oriented(TopAbs_FORWARD)); aNewEdge.EmptyCopy(); for (TopoDS_Iterator it(theEdge, false); it.More(); it.Next()) + { BRep_Builder().Add(aNewEdge, it.Value()); + } aNewEdge.Orientation(theEdge.Orientation()); return aNewEdge; } @@ -466,7 +468,9 @@ void BOPTools_AlgoTools::Dimensions(const TopoDS_Shape& theS, int& theDMin, int& { theDMin = theDMax = dimension(theS); if (theDMax >= 0) + { return; + } NCollection_List aLS; NCollection_Map aMFence; @@ -484,9 +488,13 @@ void BOPTools_AlgoTools::Dimensions(const TopoDS_Shape& theS, int& theDMin, int& { int aDim = dimension(it.Value()); if (aDim < theDMin) + { theDMin = aDim; + } if (aDim > theDMax) + { theDMax = aDim; + } } } diff --git a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx index 39452ef499..7ea122e1b0 100644 --- a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx +++ b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx @@ -176,7 +176,9 @@ void BRepAlgoAPI_BooleanOperation::Build(const Message_ProgressRange& theRange) // Combine Objects and Tools into a single list for intersection NCollection_List aLArgs = myArguments; for (NCollection_List::Iterator it(myTools); it.More(); it.Next()) + { aLArgs.Append(it.Value()); + } // Perform intersection IntersectShapes(aLArgs, aPS.Next(70)); @@ -246,14 +248,20 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1, OSD_File aScript(aFileName); isExist = aScript.Exists(); if (isExist) + { aNumOper++; + } } FILE* afile = fopen(aFileName.ToCString(), "w+"); if (!afile) + { return; + } if (myIsDumpArgs) + { fprintf(afile, "%s\n", "# Arguments are invalid"); + } TCollection_AsciiString aName1; TCollection_AsciiString aName2; @@ -264,7 +272,9 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1, BRepTools::Write(theShape1, aName1.ToCString()); } else + { fprintf(afile, "%s\n", "# First argument is Null "); + } if (!theShape2.IsNull()) { @@ -273,7 +283,9 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1, BRepTools::Write(theShape2, aName2.ToCString()); } else + { fprintf(afile, "%s\n", "# Second argument is Null "); + } if (!theResult.IsNull()) { @@ -282,7 +294,9 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1, BRepTools::Write(theResult, aNameRes.ToCString()); } else + { fprintf(afile, "%s\n", "# Result is Null "); + } fprintf(afile, "%s %s %s\n", "restore", aName1.ToCString(), "arg1"); fprintf(afile, "%s %s %s\n", "restore", aName2.ToCString(), "arg2"); @@ -307,7 +321,9 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1, }; aBopString += ("arg1 arg2"); if (theOperation == BOPAlgo_CUT21) + { aBopString += " 1"; + } fprintf(afile, "%s\n", aBopString.ToCString()); fclose(afile); diff --git a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx index 49965e1e2d..d6abdc53b7 100644 --- a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx +++ b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx @@ -66,10 +66,14 @@ void BRepAlgoAPI_BuilderAlgo::Clear() delete myBuilder; myBuilder = nullptr; if (myHistory) + { myHistory.Nullify(); + } if (mySimplifierHistory) + { mySimplifierHistory.Nullify(); + } } //================================================================================================= @@ -84,7 +88,9 @@ void BRepAlgoAPI_BuilderAlgo::Build(const Message_ProgressRange& theRange) // If necessary perform intersection of the argument shapes IntersectShapes(myArguments, aPS.Next(70)); if (HasErrors()) + { return; + } // Initialization of the Building tool myBuilder = new BOPAlgo_Builder(myAllocator); @@ -102,7 +108,9 @@ void BRepAlgoAPI_BuilderAlgo::IntersectShapes(const NCollection_ListMerge(myBuilder->GetReport()); // Check for the errors if (myBuilder->HasErrors()) + { return; + } // Set done status Done(); // Get the result shape @@ -160,10 +170,14 @@ void BRepAlgoAPI_BuilderAlgo::SimplifyResult(const bool theUnifyEdges, const double theAngularTol) { if (HasErrors()) + { return; + } if (!theUnifyEdges && !theUnifyFaces) + { return; + } // Simplification tool ShapeUpgrade_UnifySameDomain anUnifier(myShape, theUnifyEdges, theUnifyFaces, true); @@ -179,8 +193,10 @@ void BRepAlgoAPI_BuilderAlgo::SimplifyResult(const bool theUnifyEdges, // Keep simplification history mySimplifierHistory = anUnifier.History(); if (myFillHistory) + { // Merge simplification history into result history myHistory->Merge(mySimplifierHistory); + } } //================================================================================================= @@ -188,7 +204,9 @@ void BRepAlgoAPI_BuilderAlgo::SimplifyResult(const bool theUnifyEdges, const NCollection_List& BRepAlgoAPI_BuilderAlgo::Modified(const TopoDS_Shape& theS) { if (myFillHistory && myHistory) + { return myHistory->Modified(theS); + } myGenerated.Clear(); return myGenerated; } @@ -198,7 +216,9 @@ const NCollection_List& BRepAlgoAPI_BuilderAlgo::Modified(const To const NCollection_List& BRepAlgoAPI_BuilderAlgo::Generated(const TopoDS_Shape& theS) { if (myFillHistory && myHistory) + { return myHistory->Generated(theS); + } myGenerated.Clear(); return myGenerated; } @@ -237,7 +257,9 @@ const NCollection_List& BRepAlgoAPI_BuilderAlgo::SectionEdges() { myGenerated.Clear(); if (myBuilder == nullptr) + { return myGenerated; + } // Fence map to avoid duplicated section edges in the result list NCollection_Map aMFence; @@ -263,12 +285,16 @@ const NCollection_List& BRepAlgoAPI_BuilderAlgo::SectionEdges() const occ::handle& aPB = aItPB.Value(); const TopoDS_Shape& aSE = pDS->Shape(aPB->Edge()); if (!aMFence.Add(aSE)) + { continue; + } // Take into account simplification of the result shape if (mySimplifierHistory) { if (mySimplifierHistory->IsRemoved(aSE)) + { continue; + } const NCollection_List& aLSEIm = mySimplifierHistory->Modified(aSE); if (!aLSEIm.IsEmpty()) @@ -277,14 +303,20 @@ const NCollection_List& BRepAlgoAPI_BuilderAlgo::SectionEdges() for (; aItLEIm.More(); aItLEIm.Next()) { if (aMFence.Add(aItLEIm.Value())) + { myGenerated.Append(aItLEIm.Value()); + } } } else + { myGenerated.Append(aSE); + } } else + { myGenerated.Append(aSE); + } } } } diff --git a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Defeaturing.cxx b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Defeaturing.cxx index 1de1b1b396..fac1d388fd 100644 --- a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Defeaturing.cxx +++ b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Defeaturing.cxx @@ -37,7 +37,9 @@ void BRepAlgoAPI_Defeaturing::Build(const Message_ProgressRange& theRange) GetReport()->Merge(myFeatureRemovalTool.GetReport()); if (HasErrors()) + { return; + } // Set done state Done(); diff --git a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx index 741395033b..3bd5fca9fc 100644 --- a/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx +++ b/src/ModelingAlgorithms/TKBO/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx @@ -54,12 +54,16 @@ void BRepAlgoAPI_Splitter::Build(const Message_ProgressRange& theRange) // Combine Arguments and Tools for intersection into a single list NCollection_List aLArgs = myArguments; for (NCollection_List::Iterator it(myTools); it.More(); it.Next()) + { aLArgs.Append(it.Value()); + } // Perform intersection IntersectShapes(aLArgs, aPS.Next(70)); if (HasErrors()) + { return; + } } // Initialization of the building tool diff --git a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_PaveFiller_Test.cxx b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_PaveFiller_Test.cxx index 2f8d1d2928..fb21b53a69 100644 --- a/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_PaveFiller_Test.cxx +++ b/src/ModelingAlgorithms/TKBO/GTests/BOPAlgo_PaveFiller_Test.cxx @@ -249,7 +249,9 @@ TEST_F(BOPAlgo_PaveFillerTest, FuseConeWithRemovedPCurve_NullPCurveHandling) } } if (!aDegeneratedEdge.IsNull()) + { break; + } } // If we found a degenerated edge with pcurve, create a modified cone diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools.cxx index 8b0018c2fe..c70b26b25f 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools.cxx @@ -107,7 +107,9 @@ int IntTools::PrepareArgs(BRepAdaptor_Curve& C, aPars.Append(tCurrent); tNext = tCurrent + dt; if (i == Discret) + { tNext = Tmax; + } /////////////////////////////////////////////////// if (!aRFlag) { diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_BeanFaceIntersector.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_BeanFaceIntersector.cxx index 5d3b4496ed..cedd74772b 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_BeanFaceIntersector.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_BeanFaceIntersector.cxx @@ -353,7 +353,9 @@ void IntTools_BeanFaceIntersector::Perform() for (int i = 1; i <= myRangeManager.Length(); i++) { if (myRangeManager.Flag(i) != 2) + { continue; + } IntTools_Range aRange = myRangeManager.Range(i); int iLastRange = myResults.Length(); @@ -370,7 +372,9 @@ void IntTools_BeanFaceIntersector::Perform() } } else + { myResults.Append(aRange); + } } } @@ -439,7 +443,9 @@ double IntTools_BeanFaceIntersector::Distance(const double theArg) useMinMaxPoints = false; if (aDistance > aProjectorOnCurve.LowerDistance()) + { aDistance = aProjectorOnCurve.LowerDistance(); + } } } @@ -643,7 +649,9 @@ void IntTools_BeanFaceIntersector::ComputeAroundExactIntersection() } if (!solutionIsValid) + { continue; + } int aNbRanges = myRangeManager.Length(); @@ -731,7 +739,9 @@ bool IntTools_BeanFaceIntersector::FastComputeAnalytic() double anAngle = aDir.Angle(surfPlane.Axis().Direction()); if (anAngle > Precision::Angular()) + { return false; + } hasIntersection = false; @@ -751,7 +761,9 @@ bool IntTools_BeanFaceIntersector::FastComputeAnalytic() { gp_Lin aLin = myCurve.Line(); if (!aLin.Direction().IsParallel(aCylDir, Precision::Angular())) + { return false; + } hasIntersection = false; @@ -765,15 +777,19 @@ bool IntTools_BeanFaceIntersector::FastComputeAnalytic() double anAngle = aCylDir.Angle(aCircle.Axis().Direction()); if (anAngle > Precision::Angular()) + { return false; + } double aDistLoc = gp_Lin(aCylAxis).Distance(aCircle.Location()); double aDist = aDistLoc + std::abs(aCircle.Radius() - aCylRadius); isCoincide = (aDist < myCriteria); if (!isCoincide) + { hasIntersection = (aDistLoc - (aCircle.Radius() + aCylRadius)) < myCriteria && (std::abs(aCircle.Radius() - aCylRadius) - aDistLoc) < myCriteria; + } } } @@ -832,10 +848,14 @@ void IntTools_BeanFaceIntersector::ComputeLinePlane() gp_Pnt p2 = ElCLib::Value(myLastParameter, L); double d1 = A * p1.X() + B * p1.Y() + C * p1.Z() + D; if (d1 < 0) + { d1 = -d1; + } double d2 = A * p2.X() + B * p2.Y() + C * p2.Z() + D; if (d2 < 0) + { d2 = -d2; + } if (d1 <= myCriteria && d2 <= myCriteria) { inplane = true; @@ -883,8 +903,6 @@ void IntTools_BeanFaceIntersector::ComputeLinePlane() double t2 = std::min(myLastParameter, t + aDt); IntTools_Range aRange(t1, t2); myResults.Append(aRange); - - return; } //================================================================================================= @@ -899,7 +917,9 @@ void IntTools_BeanFaceIntersector::ComputeUsingExtremum() { if (myRangeManager.Flag(i) > 0) + { continue; + } IntTools_Range aParamRange = myRangeManager.Range(i); double anarg1 = aParamRange.First(); @@ -1071,10 +1091,14 @@ void IntTools_BeanFaceIntersector::ComputeNearRangeBoundaries() { if (myRangeManager.Flag(i) > 0) + { continue; + } if ((i > 1) && (myRangeManager.Flag(i - 1) > 0)) + { continue; + } IntTools_Range aParamRange = myRangeManager.Range(i); @@ -1156,7 +1180,9 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const bool ToInc const int theIndex) { if (myRangeManager.Flag(theIndex) > 0) + { return; + } int aValidIndex = theIndex; @@ -1164,7 +1190,9 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const bool ToInc double aDeltaRestrictor = 0.1 * (myLastParameter - myFirstParameter); if (aMinDelta > aDeltaRestrictor) + { aMinDelta = aDeltaRestrictor * 0.5; + } double tenOfMinDelta = aMinDelta * 10.; double aDelta = myCurveResolution; @@ -1219,7 +1247,9 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const bool ToInc anotherSolutionFound = true; if (BoundaryCondition && (isboundaryindex || !isvalidindex)) + { break; + } } else { @@ -1238,7 +1268,9 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const bool ToInc // if (aCurPar == aPrevPar) + { break; + } BoundaryCondition = (ToIncreaseParameter) ? (aCurPar > aCurrentRange.Last()) : (aCurPar < aCurrentRange.First()); @@ -1297,9 +1329,13 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const bool ToInc if (anotherSolutionFound) { if (ToIncreaseParameter) + { myRangeManager.InsertRange(theParameter, aPrevPar, 2); + } else + { myRangeManager.InsertRange(aPrevPar, theParameter, 2); + } } } @@ -1723,7 +1759,9 @@ bool IntTools_BeanFaceIntersector::LocalizeSolutions( theSurfaceData, theListCurveRange, theListSurfaceRange)) + { return false; + } } } // end (tIt...) @@ -1744,7 +1782,9 @@ bool IntTools_BeanFaceIntersector::LocalizeSolutions( theSurfaceData, theListCurveRange, theListSurfaceRange)) + { return false; + } } } } // end for (vIt...) @@ -1910,17 +1950,23 @@ bool IntTools_BeanFaceIntersector::ComputeLocalized() IntTools_Range aRangeC(myFirstParameter, myLastParameter); if (bAllowSamplingC) + { aRangeC = anItC.Value().GetRange(myFirstParameter, myLastParameter, nbSampleC); + } IntTools_Range aRangeU(myUMinParameter, myUMaxParameter); if (bAllowSamplingU) + { aRangeU = anItS.Value().GetRangeU(myUMinParameter, myUMaxParameter, nbSampleU); + } IntTools_Range aRangeV(myVMinParameter, myVMaxParameter); if (bAllowSamplingV) + { aRangeV = anItS.Value().GetRangeV(myVMinParameter, myVMaxParameter, nbSampleV); + } double anarg1 = aRangeC.First(), anarg2 = aRangeC.Last(); @@ -1948,7 +1994,9 @@ bool IntTools_BeanFaceIntersector::ComputeLocalized() } if (bFound) + { continue; + } nMinIndex = (nMaxIndex >= 0) ? nMaxIndex : nMinIndex; const NCollection_Sequence& anInds2 = myRangeManager.GetIndices(anarg2); @@ -1969,7 +2017,9 @@ bool IntTools_BeanFaceIntersector::ComputeLocalized() } if (bFound) + { continue; + } double parUF = aRangeU.First(), parUL = aRangeU.Last(); double parVF = aRangeV.First(), parVL = aRangeV.Last(); @@ -2002,22 +2052,36 @@ bool IntTools_BeanFaceIntersector::ComputeLocalized() p2.Parameter(U, V); if (myCurve.IsPeriodic()) + { T = ElCLib::InPeriod(T, anarg1, anarg1 + myCurve.Period()); + } if (mySurface.IsUPeriodic()) + { U = ElCLib::InPeriod(U, parUF, parUF + mySurface.UPeriod()); + } if (mySurface.IsVPeriodic()) + { V = ElCLib::InPeriod(V, parVF, parVF + mySurface.VPeriod()); + } // To avoid occasional going out of boundaries because of numerical // problem if (U < myUMinParameter) + { U = myUMinParameter; + } if (U > myUMaxParameter) + { U = myUMaxParameter; + } if (V < myVMinParameter) + { V = myVMinParameter; + } if (V > myVMaxParameter) + { V = myVMaxParameter; + } int aNbRanges = myRangeManager.Length(); ComputeRangeFromStartPoint(false, T, U, V); @@ -2073,7 +2137,9 @@ bool IntTools_BeanFaceIntersector::TestComputeCoinside() double U, V; if (Distance(cfp, U, V) > myCriteria) + { return false; + } // ComputeRangeFromStartPoint(true, cfp, U, V); @@ -2084,11 +2150,15 @@ bool IntTools_BeanFaceIntersector::TestComputeCoinside() if (aFoundIndex != 0) { if (myRangeManager.Flag(aFoundIndex) == 2) + { return true; + } } if (Distance(clp, U, V) > myCriteria) + { return false; + } // ComputeRangeFromStartPoint(false, clp, U, V); @@ -2099,7 +2169,9 @@ bool IntTools_BeanFaceIntersector::TestComputeCoinside() double aPar = (cfp + ((double)i) * cdp); if (Distance(aPar, U, V) > myCriteria) + { return false; + } int aNbRanges = myRangeManager.Length(); ComputeRangeFromStartPoint(false, aPar, U, V); @@ -2171,49 +2243,71 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf, for (i = 1; i <= aNbKnots[j] && (iMin[j] == -1 || iMax[j] == -1); i++) { if (iMin[j] == -1 && aFpTol[j] < aKnots.Value(i)) + { iMin[j] = i - 1; + } iLmI = aNbKnots[j] - i + 1; if (iMax[j] == -1 && aLmTol[j] > aKnots.Value(iLmI)) + { iMax[j] = iLmI + 1; + } } // If indices are not found, return. // if (iMin[j] == -1 || iMax[j] == -1) // return; if (iMin[j] == -1) + { iMin[j] = 1; + } if (iMax[j] == -1) + { iMax[j] = aNbKnots[j]; + } if (iMin[j] == 0) + { iMin[j] = 1; + } if (iMax[j] > aNbKnots[j]) + { iMax[j] = aNbKnots[j]; + } if (iMax[j] < iMin[j]) + { return; + } if (iMax[j] == iMin[j]) { iMax[j]++; iMin[j]--; if (iMin[j] == 0) + { iMin[j] = 1; + } if (iMax[j] > aNbKnots[j]) + { iMax[j] = aNbKnots[j]; + } } aNbGridPnts[j] = (iMax[j] - iMin[j]) * aNbSamples[j] + 1; // Setting the number of grid points. if (j == 0) + { theSurfaceData.SetRangeUGrid(aNbGridPnts[j]); - else // j == 1 + } + else + { // j == 1 theSurfaceData.SetRangeVGrid(aNbGridPnts[j]); + } // Setting the first and last parameters. int iAbs = 1; @@ -2227,9 +2321,13 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf, { // The first knot. if (aFmTol[j] > aKnots.Value(iMin[j])) + { aMinPar = aFPar[j]; + } else + { aMinPar = aKnots.Value(iMin[j]); + } } else { @@ -2241,9 +2339,13 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf, { // The last knot. if (aLpTol[j] < aKnots.Value(iMax[j])) + { aMaxPar = aLPar[j]; + } else + { aMaxPar = aKnots.Value(iMax[j]); + } } else { @@ -2256,17 +2358,25 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf, for (k = 0; k < aNbSamples[j]; k++, aMinPar += aDelta) { if (j == 0) + { theSurfaceData.SetUParam(iAbs++, aMinPar); + } else + { theSurfaceData.SetVParam(iAbs++, aMinPar); + } } } // Add the last parameter if (j == 0) + { theSurfaceData.SetUParam(iAbs++, aMaxPar); + } else + { theSurfaceData.SetVParam(iAbs++, aMaxPar); + } } // Compute of grid points. @@ -2363,7 +2473,9 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf, } if (theTolerance > aDef) + { aDef = 2. * theTolerance; + } theSurfaceData.SetGridDeflection(aDef); } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Context.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Context.cxx index f390beb76e..ad2f8e1f5d 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Context.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Context.cxx @@ -802,7 +802,9 @@ bool IntTools_Context::IsVertexOnLine(const TopoDS_Vertex& aV, { aTolSum = 2. * aTolSum; // xft if (aTolSum < 1.e-6) + { aTolSum = 1.e-6; + } } // aFirst = aC3D->FirstParameter(); @@ -833,7 +835,9 @@ bool IntTools_Context::IsVertexOnLine(const TopoDS_Vertex& aV, if ((aT > (aLast + aFirst) * 0.5) || (aPv.Distance(aPOncurve.Value()) > aTolSum) || (aPCFirst.Distance(aPOncurve.Value()) < Precision::Confusion())) + { aT = aFirst; + } } else { @@ -859,7 +863,9 @@ bool IntTools_Context::IsVertexOnLine(const TopoDS_Vertex& aV, if ((aT > (aLast + aFirst) * 0.5) || (aPv.Distance(aPOncurve.Value()) > aTolSum) || (aPCFirst.Distance(aPOncurve.Value()) < Precision::Confusion())) + { aT = aFirst; + } } } } @@ -890,7 +896,9 @@ bool IntTools_Context::IsVertexOnLine(const TopoDS_Vertex& aV, if ((aT < (aLast + aFirst) * 0.5) || (aPv.Distance(aPOncurve.Value()) > aTolSum) || (aPCLast.Distance(aPOncurve.Value()) < Precision::Confusion())) + { aT = aLast; + } } else { @@ -916,7 +924,9 @@ bool IntTools_Context::IsVertexOnLine(const TopoDS_Vertex& aV, if ((aT < (aLast + aFirst) * 0.5) || (aPv.Distance(aPOncurve.Value()) > aTolSum) || (aPCLast.Distance(aPOncurve.Value()) < Precision::Confusion())) + { aT = aLast; + } } } } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_CurveRangeLocalizeData.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_CurveRangeLocalizeData.cxx index cd4d80ecbe..8e689132c5 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_CurveRangeLocalizeData.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_CurveRangeLocalizeData.cxx @@ -59,5 +59,7 @@ void IntTools_CurveRangeLocalizeData::ListRangeOut( NCollection_Map::Iterator anIt(myMapRangeOut); for (; anIt.More(); anIt.Next()) + { theList.Append(anIt.Key()); + } } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeEdge.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeEdge.cxx index 8f9606052d..c18cd1fb30 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeEdge.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeEdge.cxx @@ -453,7 +453,9 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR bStop = true; } else + { BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1); + } } while (!bStop); // @@ -540,7 +542,9 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR const IntTools_Range& aR1 = aSegments1(i); BndBuildBox(myCurve1, aR1.First(), aR1.Last(), myTol1, aB1); if (!aB1.IsOut(aB2) && (aNb1 == 1 || aB1.SquareExtent() < aB1SqExtent)) + { FindSolutions(aR1, aB1, aR2, aB2, theRanges1, theRanges2); + } } } @@ -910,7 +914,9 @@ void IntTools_EdgeEdge::ComputeLineLine() if (IsCoincide) { if (aL1.SquareDistance(aL2.Location()) > aTol) + { return; + } } double aT11, aT12, aT21, aT22; @@ -924,7 +930,9 @@ void IntTools_EdgeEdge::ComputeLineLine() { gp_Pnt O2(aL2.Location()); if (!Precision::IsInfinite(aT21) && !Precision::IsInfinite(aT22)) + { O2 = ElCLib::Value((aT21 + aT22) / 2., aL2); + } gp_Vec aVec1 = gp_Vec(O2, aP11).Crossed(aD2); gp_Vec aVec2 = gp_Vec(O2, aP12).Crossed(aD2); @@ -935,8 +943,10 @@ void IntTools_EdgeEdge::ComputeLineLine() IsCoincide = (aSqDist1 <= aTol && aSqDist2 <= aTol); if (!IsCoincide && aVec1.Dot(aVec2) > 0) + { // the lines do not intersect return; + } } IntTools_CommonPrt aCommonPrt; @@ -949,11 +959,15 @@ void IntTools_EdgeEdge::ComputeLineLine() double t22 = ElCLib::Parameter(aL2, aP12); if ((t21 > aT22 && t22 > aT22) || (t21 < aT21 && t22 < aT21)) + { // projections are out of range return; + } if (t21 > t22) + { std::swap(t21, t22); + } if (t21 >= aT21) { @@ -983,7 +997,9 @@ void IntTools_EdgeEdge::ComputeLineLine() gp_XYZ aCross = aD1.XYZ().Crossed(aD2.XYZ()); double aDistLL = O1O2.Dot(gp_Vec(aCross.Normalized())); if (std::abs(aDistLL) > myTol) + { return; + } { // Fast check that no intersection needs to be added @@ -992,7 +1008,9 @@ void IntTools_EdgeEdge::ComputeLineLine() for (TopoDS_Iterator it2(myEdge2); it2.More(); it2.Next()) { if (it1.Value().IsSame(it2.Value())) + { return; + } } } } @@ -1002,22 +1020,28 @@ void IntTools_EdgeEdge::ComputeLineLine() aT2 /= aSqSin; if (aT2 < aT21 || aT2 > aT22) + { // out of range return; + } gp_Pnt aP2 = ElCLib::Value(aT2, aL2); double aT1 = gp_Vec(aL1.Location(), aP2).Dot(aD1); if (aT1 < aT11 || aT1 > aT12) + { // out of range return; + } gp_Pnt aP1 = ElCLib::Value(aT1, aL1); double aDist = aP1.SquareDistance(aP2); if (aDist > aTol) + { // no intersection return; + } // compute correct range on the edges double aDt1 = IntTools_Tools::ComputeIntRange(myTol1, myTol2, anAngle); diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeFace.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeFace.cxx index 09dd9ac0ea..c763caeedc 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeFace.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_EdgeFace.cxx @@ -72,7 +72,9 @@ bool IntTools_EdgeFace::IsCoincident() int aNbSeg = 23; if (myC.GetType() == GeomAbs_Line && myS.GetType() == GeomAbs_Plane) + { aNbSeg = 2; // Check only three points for Line/Plane intersection + } const double aTresh = 0.5; const int aTreshIdxF = RealToInt((aNbSeg + 1) * 0.25), @@ -106,9 +108,13 @@ bool IntTools_EdgeFace::IsCoincident() if (aD > myCriteria) { if (aD > 100. * myCriteria) + { return false; + } else + { continue; + } } // @@ -125,10 +131,14 @@ bool IntTools_EdgeFace::IsCoincident() // classified correctly. if (((0 < i) && (i < aTreshIdxF)) || ((aTreshIdxL < i) && (i < aNbSeg))) + { continue; + } if (isClassified && (i != aNbSeg)) + { continue; + } aProjector.LowerDistanceParameters(aU, aV); aP2d.SetX(aU); @@ -138,10 +148,14 @@ bool IntTools_EdgeFace::IsCoincident() aState = aClass2d.Perform(aP2d); if (aState == TopAbs_OUT) + { return false; + } if (i != 0) + { isClassified = true; + } } // const double aCoeff = (double)iCnt / ((double)aNbSeg + 1); @@ -311,7 +325,9 @@ int IntTools_EdgeFace::MakeType(IntTools_CommonPrt& aCommonPrt) if ((std::abs(af1 - myRange.First()) < myC.Resolution(myCriteria)) && (std::abs(al1 - myRange.Last()) < myC.Resolution(myCriteria))) + { isWholeRange = true; + } if ((df1 > myCriteria * 2.) && isWholeRange) { @@ -522,8 +538,10 @@ void IntTools_EdgeFace::Perform() { myCriteria = std::max(aTolE, aTolF); } - else //--- 5112 + else + { //--- 5112 myCriteria = 1.5 * aTolE + aTolF; + } } else { @@ -552,7 +570,9 @@ void IntTools_EdgeFace::Perform() anIntersector.Perform(); if (anIntersector.MinimalSquareDistance() < RealLast()) + { myMinDistance = std::sqrt(anIntersector.MinimalSquareDistance()); + } if (!anIntersector.IsDone()) { diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FClass2d.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FClass2d.cxx index ebc06342a8..1ac1ade150 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FClass2d.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FClass2d.cxx @@ -286,13 +286,21 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) u = aPrms(iX); P2d = C.Value(u); if (P2d.X() < Umin) + { Umin = P2d.X(); + } if (P2d.X() > Umax) + { Umax = P2d.X(); + } if (P2d.Y() < Vmin) + { Vmin = P2d.Y(); + } if (P2d.Y() > Vmax) + { Vmax = P2d.Y(); + } // aDstX = RealLast(); if (!degenerated) @@ -364,7 +372,9 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) } // if (firstpoint == 1) + { firstpoint = 2; + } WireIsNotEmpty = true; // Append the derivative of the first parameter. double aU = aPrms(1); @@ -374,7 +384,9 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) C.D1(aU, aP, aV); if (Or == TopAbs_REVERSED) + { aV.Reverse(); + } aD1Next.Append(aV); @@ -383,18 +395,28 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) C.D1(aU, aP, aV); if (Or == TopAbs_REVERSED) + { aV.Reverse(); + } if (NbEdges > 0) + { aD1Prev.Append(aV); + } else + { aD1Prev.Prepend(aV); + } // Fill the map anIndexMap. if (Avant > 0) + { anIndexMap.Bind(Avant, aD1Next.Length()); + } else + { anIndexMap.Bind(1, aD1Next.Length()); + } } // for(;aWExp.More(); aWExp.Next()) { // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // @@ -455,11 +477,15 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) { BRep_Tool::Range(edge, Face, pfbid, plbid); if (std::abs(plbid - pfbid) < 1.e-9) + { continue; + } BRepAdaptor_Curve2d C(edge, Face); GCPnts_QuasiUniformDeflection aDiscr(C, aDiscrDefl); if (!aDiscr.IsDone()) + { break; + } int nbp = aDiscr.NbPoints(); int iStep = 1, i = 1, iEnd = nbp + 1; if (Or == TopAbs_REVERSED) @@ -469,7 +495,9 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) iEnd = 0; } if (firstpoint == 2) + { i += iStep; + } for (; i != iEnd; i += iStep) { gp_Pnt2d aP2d = C.Value(aDiscr.Parameter(i)); @@ -484,9 +512,13 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) double dU = std::abs(Pp.X() - SeqPnt2d(ii - 1).X()); double dV = std::abs(Pp.Y() - SeqPnt2d(ii - 1).Y()); if (dU > FlecheU) + { FlecheU = dU; + } if (dV > FlecheV) + { FlecheV = dV; + } } firstpoint = 2; } @@ -502,10 +534,14 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) } // if (FlecheU < Toluv) + { FlecheU = Toluv; + } if (FlecheV < Toluv) + { FlecheV = Toluv; + } TabClass.Append(CSLib_Class2d(SeqPnt2d, FlecheU, FlecheV, Umin, Vmin, Umax, Vmax)); // @@ -555,7 +591,9 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) { double uuu = M_PI + M_PI - (Umax - Umin); if (uuu < 0) + { uuu = 0; + } U1 = Umin - uuu * 0.5; U2 = U1 + M_PI + M_PI; } @@ -568,7 +606,9 @@ void IntTools_FClass2d::Init(const TopoDS_Face& aFace, const double TolUV) { double uuu = M_PI + M_PI - (Vmax - Vmin); if (uuu < 0) + { uuu = 0; + } V1 = Vmin - uuu * 0.5; V2 = V1 + M_PI + M_PI; @@ -706,7 +746,9 @@ TopAbs_State IntTools_FClass2d::Perform(const gp_Pnt2d& _Puv, const bool Recadre // if (myFExplorer.get() == nullptr) + { myFExplorer.reset(new BRepClass_FaceExplorer(Face)); + } BRepClass_FClassifier aClassifier; aClassifier.Perform(*myFExplorer, Puv, aFCTol); @@ -714,10 +756,14 @@ TopAbs_State IntTools_FClass2d::Perform(const gp_Pnt2d& _Puv, const bool Recadre } if (!RecadreOnPeriodic || (!IsUPer && !IsVPer)) + { return aStatus; + } if (aStatus == TopAbs_IN || aStatus == TopAbs_ON) + { return aStatus; + } if (!urecadre) { @@ -847,7 +893,9 @@ TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, { //-- TabOrien(1)=-1 Wrong Wire if (myFExplorer.get() == nullptr) + { myFExplorer.reset(new BRepClass_FaceExplorer(Face)); + } BRepClass_FClassifier aClassifier; aClassifier.Perform(*myFExplorer, Puv, Tol); @@ -855,9 +903,13 @@ TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, } if (!RecadreOnPeriodic || (!IsUPer && !IsVPer)) + { return aStatus; + } if (aStatus == TopAbs_IN || aStatus == TopAbs_ON) + { return aStatus; + } if (!urecadre) { @@ -865,7 +917,9 @@ TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, urecadre = true; } else if (IsUPer) + { u += uperiod; + } if (u > Umax || !IsUPer) { if (!vrecadre) @@ -874,12 +928,16 @@ TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, vrecadre = true; } else if (IsVPer) + { v += vperiod; + } u = uu; if (v > Vmax || !IsVPer) + { return aStatus; + } } } // for (;;) } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FaceFace.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FaceFace.cxx index 79df93de7f..226edfa143 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FaceFace.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_FaceFace.cxx @@ -278,9 +278,13 @@ static bool isTreatAnalityc(const BRepAdaptor_Surface& theBAS1, const double VMax = theBAS1.LastVParameter(); if (Precision::IsNegativeInfinite(VMin) || Precision::IsPositiveInfinite(VMax)) + { return true; + } else + { aHigh = VMax - VMin; + } } else if (aType2 == GeomAbs_Cylinder) { @@ -290,9 +294,13 @@ static bool isTreatAnalityc(const BRepAdaptor_Surface& theBAS1, const double VMax = theBAS2.LastVParameter(); if (Precision::IsNegativeInfinite(VMin) || Precision::IsPositiveInfinite(VMax)) + { return true; + } else + { aHigh = VMax - VMin; + } } else { @@ -513,9 +521,13 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, const bool isGeomInt = isTreatAnalityc(aBAS1, aBAS2, myTol); if (aF1.IsSame(aF2)) + { myIntersector.Perform(myHS1, dom1, TolArc, TolTang); + } else + { myIntersector.Perform(myHS1, dom1, myHS2, dom2, TolArc, TolTang, myListOfPnts, isGeomInt); + } myIsDone = myIntersector.IsDone(); @@ -734,7 +746,9 @@ reapprox:; typl = L->ArcType(); if (typl == IntPatch_Restriction) + { bAvoidLineConstructor = true; + } // // Line Constructor @@ -811,7 +825,9 @@ reapprox:; GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc, myHS1->Surface(), newc, C2d); if (C2d.IsNull()) + { continue; + } aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm)); } @@ -822,7 +838,9 @@ reapprox:; GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc, myHS2->Surface(), newc, C2d); if (C2d.IsNull()) + { continue; + } aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm)); } @@ -913,9 +931,13 @@ reapprox:; { // interval that goes through 0. is divided on two intervals; while (fprm < aNul || fprm > aPeriod) + { fprm = fprm + aPeriod; + } while (lprm < aNul || lprm > aPeriod) + { lprm = lprm + aPeriod; + } // if ((aPeriod - fprm) > Tolpc) { @@ -1313,7 +1335,9 @@ reapprox:; else { if (reApprox && !rejectSurface) + { theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, 30, false, aParType); + } else { int iDegMax, iDegMin, iNbIter; @@ -1728,7 +1752,9 @@ reapprox:; GeomInt_IntSS::TreatRLine(RL, myHS1, myHS2, aC3d, aC2d1, aC2d2, aTolReached); if (aC3d.IsNull()) + { break; + } Bnd_Box2d aBox1, aBox2; @@ -1766,7 +1792,9 @@ reapprox:; { // In order to more precise extending to the boundaries of source curves. if (anInd < aNbIntersSolutionsm1 - 1) + { aParL = aParF; + } continue; } @@ -1780,10 +1808,14 @@ reapprox:; aC2d1->D0(aPar, aPt); if (aBox1.IsOut(aPt)) + { continue; + } if (myApprox1) + { aCurv2d1 = new Geom2d_TrimmedCurve(aC2d1, aParF, aParL); + } } if (!aC2d2.IsNull()) @@ -1791,10 +1823,14 @@ reapprox:; aC2d2->D0(aPar, aPt); if (aBox2.IsOut(aPt)) + { continue; + } if (myApprox2) + { aCurv2d2 = new Geom2d_TrimmedCurve(aC2d2, aParF, aParL); + } } occ::handle aCurv3d = new Geom_TrimmedCurve(aC3d, aParF, aParL); @@ -2037,16 +2073,22 @@ void CorrectSurfaceBoundaries(const TopoDS_Face& theFace, { if (!Precision::IsInfinite(theumin) && ((theumin - uinf) > delta)) + { theumin -= delta; + } else { theumin = uinf; } if (!Precision::IsInfinite(theumax) && ((usup - theumax) > delta)) + { theumax += delta; + } else + { theumax = usup; + } } // @@ -2126,7 +2168,9 @@ void CorrectSurfaceBoundaries(const TopoDS_Face& theFace, aBox.Add(pp2); } if (!correct) + { break; + } } } @@ -2138,7 +2182,9 @@ void CorrectSurfaceBoundaries(const TopoDS_Face& theFace, if (isuperiodic && correctU) { if (theumin < umin) + { theumin = umin; + } if (theumax > umax) { theumax = umax; @@ -2147,9 +2193,13 @@ void CorrectSurfaceBoundaries(const TopoDS_Face& theFace, if (isvperiodic && correctV) { if (thevmin < vmin) + { thevmin = vmin; + } if (thevmax > vmax) + { thevmax = vmax; + } } } } @@ -2195,9 +2245,13 @@ bool ParameterOutOfBoundary(const double theParameter, while (aState == TopAbs_ON) { if (bIncreasePar) + { acurpar += adelta; + } else + { acurpar -= adelta; + } gp_Pnt aPCurrent = theCurve->Value(acurpar); aPrj1.Perform(aPCurrent); double U = 0., V = 0.; @@ -2234,12 +2288,16 @@ bool ParameterOutOfBoundary(const double theParameter, if (bIncreasePar) { if (acurpar >= theOtherParameter) + { theNewParameter = theOtherParameter; + } } else { if (acurpar <= theOtherParameter) + { theNewParameter = theOtherParameter; + } } } return bIsComputed; @@ -2250,7 +2308,9 @@ bool ParameterOutOfBoundary(const double theParameter, bool IsCurveValid(const occ::handle& thePCurve) { if (thePCurve.IsNull()) + { return false; + } double tolint = 1.e-10; Geom2dAdaptor_Curve PCA; @@ -2270,17 +2330,23 @@ bool IsCurveValid(const occ::handle& thePCurve) if (!PCA.IsPeriodic()) { if (PCA.FirstParameter() > pf) + { pf = PCA.FirstParameter(); + } if (PCA.LastParameter() < pl) + { pl = PCA.LastParameter(); + } } PCD.SetValues(pntf, pf, tolint, pntl, pl, tolint); PCI.Perform(PCA, PCD, tolint, tolint); if (PCI.IsDone()) + { if (PCI.NbPoints() > 0) { return false; } + } } return true; @@ -2333,7 +2399,9 @@ bool ApproxWithPCurves(const gp_Cylinder& theCyl, const gp_Sphere& theSph) double aDRel = std::abs(aDist - R1) / R2; if (aDRel > .2) + { return bRes; + } double par = ElCLib::Parameter(anCylAx, theSph.Location()); gp_Pnt aP = ElCLib::Value(par, anCylAx); @@ -2342,9 +2410,13 @@ bool ApproxWithPCurves(const gp_Cylinder& theCyl, const gp_Sphere& theSph) double dd = aV.Dot(theSph.Position().XDirection()); if (aDist < R1 && dd > 0.) + { return false; + } if (aDist > R1 && dd < 0.) + { return false; + } return bRes; } @@ -2405,26 +2477,36 @@ void PerformPlanes(const occ::handle& theS1, double P11, P12; bool IsCrossed = ClassifyLin2d(theS1, aLin2d1, TolTang, P11, P12); if (!IsCrossed) + { return; + } // classify line2d2 relatively second plane double P21, P22; IsCrossed = ClassifyLin2d(theS2, aLin2d2, TolTang, P21, P22); if (!IsCrossed) + { return; + } // Analysis of parametric intervals: must have common part if (P21 >= P12) + { return; + } if (P22 <= P11) + { return; + } double pmin, pmax; pmin = std::max(P11, P21); pmax = std::min(P12, P22); if (pmax - pmin <= TolTang) + { return; + } occ::handle aGLin = new Geom_Line(aLin); @@ -2536,7 +2618,9 @@ bool ClassifyLin2d(const occ::handle& theS, return true; } else + { return false; + } } // xmin, ymax <-> xmax, ymax @@ -2570,7 +2654,9 @@ bool ClassifyLin2d(const occ::handle& theS, return true; } else + { return false; + } } // xmax, ymax <-> xmax, ymin @@ -2602,7 +2688,9 @@ bool ClassifyLin2d(const occ::handle& theS, return true; } else + { return false; + } } // xmax, ymin <-> xmin, ymin @@ -2634,7 +2722,9 @@ bool ClassifyLin2d(const occ::handle& theS, return true; } else + { return false; + } } return false; @@ -2947,7 +3037,9 @@ bool CheckPCurve(const occ::handle& aPC, double aPer = aSurf->UPeriod(); int nshift = (int)((u - umin) / aPer); if (u < umin + aPer * nshift) + { nshift--; + } umin += aPer * nshift; umax += aPer * nshift; } @@ -2956,7 +3048,9 @@ bool CheckPCurve(const occ::handle& aPC, double aPer = aSurf->VPeriod(); int nshift = (int)((v - vmin) / aPer); if (v < vmin + aPer * nshift) + { nshift--; + } vmin += aPer * nshift; vmax += aPer * nshift; } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_MarkedRangeSet.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_MarkedRangeSet.cxx index ed5f0f611f..dd33be8b4b 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_MarkedRangeSet.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_MarkedRangeSet.cxx @@ -70,11 +70,15 @@ bool IntTools_MarkedRangeSet::InsertRange(const double theFirstBoundary, int anIndex1 = GetIndex(theFirstBoundary, true); if (!anIndex1) + { return false; + } int anIndex2 = GetIndex(theLastBoundary, false); if (!anIndex2) + { return false; + } if (anIndex2 < anIndex1) { // it can be if theLastBoundary==theFirstBoundary==boundary_of_a_range or theFirstBoundary > @@ -84,7 +88,9 @@ bool IntTools_MarkedRangeSet::InsertRange(const double theFirstBoundary, anIndex2 = atmpindex; if (theLastBoundary < theFirstBoundary) + { return false; + } } bool areEqualIndices = (anIndex1 == anIndex2); @@ -136,7 +142,9 @@ bool IntTools_MarkedRangeSet::InsertRange(const double theFirstBoundary, int anIndex = theIndex; if ((theIndex <= 0) || (theIndex > myRangeNumber)) + { return false; + } if ((theFirstBoundary < myRangeSetStorer(theIndex)) || (theLastBoundary > myRangeSetStorer(theIndex + 1)) @@ -195,7 +203,9 @@ const NCollection_Sequence& IntTools_MarkedRangeSet::GetIndices(const doubl myFoundIndices.Clear(); if (theValue < myRangeSetStorer(1)) + { return myFoundIndices; + } else { bool found = false; @@ -238,7 +248,9 @@ int IntTools_MarkedRangeSet::GetIndex(const double theValue) const int anIndex = 0; if (theValue < myRangeSetStorer(1)) + { anIndex = 0; + } else { for (int i = 2; i <= myRangeSetStorer.Length(); i++) @@ -260,7 +272,9 @@ int IntTools_MarkedRangeSet::GetIndex(const double theValue, const bool UseLower if ((UseLower && (theValue < myRangeSetStorer(1))) || (!UseLower && (theValue <= myRangeSetStorer(1)))) + { anIndex = 0; + } else { for (int i = 2; i <= myRangeSetStorer.Length(); i++) diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Root.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Root.cxx index 0fc420f9f0..29cc0be9ab 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Root.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Root.cxx @@ -140,13 +140,21 @@ double IntTools_Root::LayerHeight() const bool IntTools_Root::IsValid() const { if (myStateBefore == TopAbs_OUT && myStateAfter == TopAbs_IN) + { return true; + } if (myStateBefore == TopAbs_OUT && myStateAfter == TopAbs_ON) + { return true; + } if (myStateBefore == TopAbs_ON && myStateAfter == TopAbs_OUT) + { return true; + } if (myStateBefore == TopAbs_IN && myStateAfter == TopAbs_OUT) + { return true; + } return false; } diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_SurfaceRangeLocalizeData.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_SurfaceRangeLocalizeData.cxx index c206803e2f..a518c95e80 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_SurfaceRangeLocalizeData.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_SurfaceRangeLocalizeData.cxx @@ -78,13 +78,19 @@ IntTools_SurfaceRangeLocalizeData& IntTools_SurfaceRangeLocalizeData::Assign( myVIndMax = Other.myVIndMax; if (!Other.myUParams.IsNull()) + { myUParams = Other.myUParams; + } if (!Other.myVParams.IsNull()) + { myVParams = Other.myVParams; + } if (!Other.myGridPoints.IsNull()) + { myGridPoints = Other.myGridPoints; + } // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End return *(this); } @@ -125,7 +131,9 @@ void IntTools_SurfaceRangeLocalizeData::ListRangeOut( NCollection_Map::Iterator anIt(myMapRangeOut); for (; anIt.More(); anIt.Next()) + { theList.Append(anIt.Key()); + } } void IntTools_SurfaceRangeLocalizeData::RemoveRangeOutAll() @@ -193,16 +201,22 @@ void IntTools_SurfaceRangeLocalizeData::SetFrame(const double theUMin, for (i = 1; i <= aLen; i++) { if (myUIndMin == 0 && theUMin < myUParams->Value(i)) + { myUIndMin = i; + } aLmI = aLen - i + 1; if (myUIndMax == 0 && theUMax > myUParams->Value(aLmI)) + { myUIndMax = aLmI; + } } if (myUIndMin == 0) + { myUIndMin = aLen + 1; + } // Compute frame along V. aLen = myVParams->Length(); @@ -210,16 +224,22 @@ void IntTools_SurfaceRangeLocalizeData::SetFrame(const double theUMin, for (i = 1; i <= aLen; i++) { if (myVIndMin == 0 && theVMin < myVParams->Value(i)) + { myVIndMin = i; + } aLmI = aLen - i + 1; if (myVIndMax == 0 && theVMax > myVParams->Value(aLmI)) + { myVIndMax = aLmI; + } } if (myVIndMin == 0) + { myVIndMin = aLen + 1; + } } const gp_Pnt& IntTools_SurfaceRangeLocalizeData::GetPointInFrame(const int theUIndex, @@ -229,7 +249,9 @@ const gp_Pnt& IntTools_SurfaceRangeLocalizeData::GetPointInFrame(const int theUI int aFrmVInd = theVIndex + myVIndMin - 1; if (myGridPoints.IsNull() || aFrmUInd > myUIndMax || aFrmVInd > myVIndMax) + { return gp::Origin(); + } return myGridPoints->Value(aFrmUInd, aFrmVInd); } @@ -239,7 +261,9 @@ double IntTools_SurfaceRangeLocalizeData::GetUParamInFrame(const int theIndex) c int aFrmInd = theIndex + myUIndMin - 1; if (myUParams.IsNull() || aFrmInd > myUIndMax) + { return Precision::Infinite(); + } return myUParams->Value(aFrmInd); } @@ -249,7 +273,9 @@ double IntTools_SurfaceRangeLocalizeData::GetVParamInFrame(const int theIndex) c int aFrmInd = theIndex + myVIndMin - 1; if (myVParams.IsNull() || aFrmInd > myVIndMax) + { return Precision::Infinite(); + } return myVParams->Value(aFrmInd); } @@ -263,13 +289,19 @@ void IntTools_SurfaceRangeLocalizeData::ClearGrid() myVIndMax = 0; if (!myUParams.IsNull()) + { myUParams.Nullify(); + } if (!myVParams.IsNull()) + { myVParams.Nullify(); + } if (!myGridPoints.IsNull()) + { myGridPoints.Nullify(); + } } // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Tools.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Tools.cxx index eacd738ea6..2f1bf6deef 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Tools.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_Tools.cxx @@ -192,7 +192,9 @@ int IntTools_Tools::SplitCurve(const IntTools_Curve& IC, NCollection_Sequence& aC3D = IC.Curve(); if (aC3D.IsNull()) + { return 0; + } // const occ::handle& aC2D1 = IC.FirstCurve2d(); const occ::handle& aC2D2 = IC.SecondCurve2d(); diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_TopolTool.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_TopolTool.cxx index 1a553b053f..1c43d1a486 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_TopolTool.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_TopolTool.cxx @@ -159,16 +159,24 @@ void IntTools_TopolTool::ComputeSamplePoints() nbsv /= 10; if (nbsu < 2) + { nbsu = 2; + } if (nbsv < 2) + { nbsv = 2; + } // if(nbsu < 10) nbsu = 10; // if(nbsv < 10) nbsv = 10; if (nbsu > aMaxNbSample) + { nbsu = aMaxNbSample; + } if (nbsv > aMaxNbSample) + { nbsv = aMaxNbSample; + } } break; case GeomAbs_Cone: { @@ -179,7 +187,9 @@ void IntTools_TopolTool::ComputeSamplePoints() aCircle = ElSLib::ConeVIso(aCone.Position(), aCone.RefRadius(), aCone.SemiAngle(), vsup); if (aRadius < aCircle.Radius()) + { aRadius = aCircle.Radius(); + } double aMaxAngle = M_PI * 0.5; double aDeflection = 1.e-02; @@ -199,13 +209,21 @@ void IntTools_TopolTool::ComputeSamplePoints() // if(nbsv < 2) nbsv = 2; if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } if (nbsu > aMaxNbSample) + { nbsu = aMaxNbSample; + } if (nbsv > aMaxNbSample) + { nbsv = aMaxNbSample; + } } break; case GeomAbs_Sphere: @@ -260,13 +278,21 @@ void IntTools_TopolTool::ComputeSamplePoints() nbsv = int((vsup - vinf) / aMaxAngle); } if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } if (nbsu > aMaxNbSample) + { nbsu = aMaxNbSample; + } if (nbsv > aMaxNbSample) + { nbsv = aMaxNbSample; + } } break; case GeomAbs_BezierSurface: { @@ -280,20 +306,28 @@ void IntTools_TopolTool::ComputeSamplePoints() } if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } } break; case GeomAbs_BSplineSurface: { nbsv = myS->NbVKnots(); nbsv *= myS->VDegree(); if (nbsv < 4) + { nbsv = 4; + } nbsu = myS->NbUKnots(); nbsu *= myS->UDegree(); if (nbsu < 4) + { nbsu = 4; + } if (nbsu > 10 || nbsv > 10) { @@ -301,9 +335,13 @@ void IntTools_TopolTool::ComputeSamplePoints() Analyse(array2, nbsu, nbsv); } if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } // Check anisotropy double anULen = (usup - uinf) / myS->UResolution(1.); double anVLen = (vsup - vinf) / myS->VResolution(1.); @@ -325,9 +363,13 @@ void IntTools_TopolTool::ComputeSamplePoints() nbsv = (int)(vsup - vinf); nbsv /= 10; if (nbsv < 15) + { nbsv = 15; + } if (nbsv > aMaxNbSample) + { nbsv = aMaxNbSample; + } } break; case GeomAbs_SurfaceOfRevolution: { @@ -402,7 +444,9 @@ void IntTools_TopolTool::SamplePoint(const int Index, gp_Pnt2d& P2d, gp_Pnt& P3d P3d = myS->Value(u, v); } else + { Adaptor3d_TopolTool::SamplePoint(Index, P2d, P3d); + } } //================================================================================================= @@ -511,7 +555,9 @@ void Analyse(const NCollection_Array2& array2, int& theNbSamplesU, int& } } if (locnbch > nbch) + { nbch = locnbch; + } } } theNbSamplesU = nbch + 5; diff --git a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_WLineTool.cxx b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_WLineTool.cxx index ade65f53f4..24df773edc 100644 --- a/src/ModelingAlgorithms/TKBO/IntTools/IntTools_WLineTool.cxx +++ b/src/ModelingAlgorithms/TKBO/IntTools/IntTools_WLineTool.cxx @@ -400,9 +400,13 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, anOtherVecNormal.SetY(0.); if (i < 2) + { aprojpoint.SetX(theUmin); + } else + { aprojpoint.SetX(theUmax); + } } else { @@ -412,9 +416,13 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, anOtherVecNormal.SetY(1.); if (i < 2) + { aprojpoint.SetY(theVmin); + } else + { aprojpoint.SetY(theVmax); + } } gp_Vec2d anormvec = aVec; anormvec.Normalize(); @@ -422,7 +430,9 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, double adot1 = anormvec.Dot(anOtherVecNormal); if (fabs(adot1) < Precision::Angular()) + { continue; + } double adist = 0.; bool bIsOut = false; @@ -444,7 +454,9 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, gp_Pnt2d acurpoint(aprojpoint.XY() + (anOtherVec.XY() * anoffset)); gp_Vec2d acurvec(theLastPoint, acurpoint); if (bIsOut) + { acurvec.Reverse(); + } double aDotX, anAngleX; // @@ -648,10 +660,14 @@ bool IntTools_WLineTool::DecompositionOfWLine( int aneighbourindex = (j == 0) ? (i - 1) : (i + 1); if ((aneighbourindex < 1) || (aneighbourindex > nblines)) + { continue; + } if (anArrayOfLineType.Value(aneighbourindex) == 0) + { continue; + } const NCollection_List& aNeighbour = anArrayOfLines.Value(aneighbourindex); int anIndex = (j == 0) ? aNeighbour.Last() : aNeighbour.First(); const IntSurf_PntOn2S& aPoint = theWLine->Point(anIndex); @@ -676,9 +692,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double U = 0., V = 0.; if (surfit == 0) + { aNewP.ParametersOnS1(U, V); + } else + { aNewP.ParametersOnS2(U, V); + } int nbboundaries = 0; bool bIsNearBoundary = false; @@ -786,9 +806,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double nU1, nV1; if (surfit == 0) + { aNeighbourPoint.ParametersOnS1(nU1, nV1); + } else + { aNeighbourPoint.ParametersOnS2(nU1, nV1); + } double adist1 = (bIsUBoundary) ? fabs(nU1 - U) : fabs(nV1 - V); double adist2 = (bIsUBoundary) ? fabs(nU1 - anotherPar) : fabs(nV1 - anotherPar); @@ -833,9 +857,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double nU2, nV2; if (surfit == 0) + { aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); + } else + { aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); + } gp_Vec2d aVecOld(gp_Pnt2d(nU2, nV2), gp_Pnt2d(nU1, nV1)); if (aVecOld.SquareMagnitude() <= gp::Resolution()) @@ -894,18 +922,26 @@ bool IntTools_WLineTool::DecompositionOfWLine( double u1, v1, u2, v2; aNewP.Parameters(u1, v1, u2, v2); if (surfit == 0) + { anewpoint = gp_Pnt2d(u1, v1); + } else + { anewpoint = gp_Pnt2d(u2, v2); + } int aneighbourpointindex1 = (j == 0) ? iFirst : iLast; const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1); double nU1, nV1; if (surfit == 0) + { aNeighbourPoint.ParametersOnS1(nU1, nV1); + } else + { aNeighbourPoint.ParametersOnS2(nU1, nV1); + } gp_Pnt2d ap1(nU1, nV1); gp_Pnt2d ap2; @@ -933,9 +969,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double nU1, nV1; if (surfit == 0) + { aNeighbourPoint.ParametersOnS1(nU1, nV1); + } else + { aNeighbourPoint.ParametersOnS2(nU1, nV1); + } gp_Pnt2d ap1(nU1, nV1); gp_Pnt2d ap2(nU1, nV1); int aneighbourpointindex2 = aneighbourpointindex1; @@ -948,9 +988,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double nU2, nV2; if (surfit == 0) + { aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); + } else + { aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); + } ap2.SetX(nU2); ap2.SetY(nV2); @@ -990,9 +1034,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( double nUn, nVn; if (surfit == 0) + { aNeighbourPoint.ParametersOnS2(nUn, nVn); + } else + { aNeighbourPoint.ParametersOnS1(nUn, nVn); + } gp_Pnt2d aNeighbour2d(nUn, nVn); gp_Pnt2d anAdjustedPoint = AdjustByNeighbour(aNeighbour2d, gp_Pnt2d(foundU, foundV), aSurfaceOther); @@ -1028,9 +1076,13 @@ bool IntTools_WLineTool::DecompositionOfWLine( // Correction of projected coordinates. End if (surfit == 0) + { aNewP.SetValue(aP3d, anewpoint.X(), anewpoint.Y(), foundU, foundV); + } else + { aNewP.SetValue(aP3d, foundU, foundV, anewpoint.X(), anewpoint.Y()); + } } } } @@ -1162,7 +1214,9 @@ bool IntTools_WLineTool::DecompositionOfWLine( { pit = anIt.Value(); if ((pit < ifprm) || (pit > ilprm)) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(pit); aLineOn2S->Add(aP); } @@ -1179,7 +1233,9 @@ bool IntTools_WLineTool::DecompositionOfWLine( { pit = anIt.Value(); if (pit < ifprm) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(pit); aLineOn2S->Add(aP); } @@ -1232,7 +1288,9 @@ bool IntTools_WLineTool::DecompositionOfWLine( { pit = anIt.Value(); if (pit > ilprm) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(pit); aLineOn2S->Add(aP); } diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo.cxx index 0706b6803d..594e215ca5 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo.cxx @@ -66,7 +66,9 @@ struct OrientedCurve inline gp_Pnt2d Point(const bool isEnd) const { if (isEnd == IsReverse) + { return Curve->StartPoint(); + } return Curve->EndPoint(); } }; @@ -92,9 +94,13 @@ TopoDS_Wire BRepAlgo::ConvertWire(const TopoDS_Wire& theWire, BRepAdaptor_Curve2d aCurve(anEdge, theFace); double aTol = BRep_Tool::Tolerance(anEdge); if (aTol < MINIMAL_TOLERANCE) + { aTol = MINIMAL_TOLERANCE; + } if (aTol > aMaxTol) + { aMaxTol = aTol; + } Geom2dConvert_ApproxArcsSegments anAlgo(aCurve, aTol, theAngleTol); const NCollection_Sequence>& aResultApprox = anAlgo.GetResult(); @@ -134,7 +140,9 @@ TopoDS_Wire BRepAlgo::ConvertWire(const TopoDS_Wire& theWire, gp_Pnt2d aPnt[2] = {vecCurve(0).Point(false), vecCurve(vecCurve.Length() - 1).Point(true)}; double aDist = aPnt[0].Distance(aPnt[1]); if (aDist > aMaxTol + Precision::Confusion()) + { aDist = Precision::Confusion(); + } else { aDist = 0.5 * aDist + Precision::Confusion(); @@ -203,7 +211,9 @@ TopoDS_Wire BRepAlgo::ConvertWire(const TopoDS_Wire& theWire, } if (aMkWire.IsDone()) + { aResult = aMkWire.Wire(); + } } return aResult; } @@ -280,7 +290,9 @@ TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W, if (index >= 1) { // continuity test loop if (edge.Orientation() == TopAbs_REVERSED) + { tab(index)->Reverse(); + } tolleft = BRep_Tool::Tolerance(TopExp::LastVertex(edge)); tolright = BRep_Tool::Tolerance(TopExp::FirstVertex(edge)); tabtolvertex(index - 1) = std::max(tolleft, tolright); @@ -295,24 +307,33 @@ TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W, tab(index)->Reverse(); } else + { Vfirst = TopExp::FirstVertex(edge); + } } if (index == nb_curve - 1) { // storage of the last edge features if (edge.Orientation() == TopAbs_REVERSED) + { Vlast = TopExp::FirstVertex(edge); + } else + { Vlast = TopExp::LastVertex(edge); + } } WExp.Next(); } - if (BRep_Tool::Tolerance(Vfirst) - > BRep_Tool::Tolerance(Vlast)) // computation of the closing tolerance + if (BRep_Tool::Tolerance(Vfirst) > BRep_Tool::Tolerance(Vlast)) + { // computation of the closing tolerance toler = BRep_Tool::Tolerance(Vfirst); + } else + { toler = BRep_Tool::Tolerance(Vlast); + } Pfirst = BRep_Tool::Pnt(Vfirst); Plast = BRep_Tool::Pnt(Vlast); @@ -331,18 +352,22 @@ TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W, concatcurve; // array of the concatenated curves occ::handle> ArrayOfIndices; // array of the remaining Vertex if (Option == GeomAbs_G1) + { GeomConvert::ConcatG1(tab, tabtolvertex, concatcurve, closed_flag, closed_tolerance); // G1 concatenation + } else + { GeomConvert::ConcatC1(tab, tabtolvertex, ArrayOfIndices, concatcurve, closed_flag, closed_tolerance); // C1 concatenation + } for (index = 0; index <= (concatcurve->Length() - 1); index++) { // building of the resulting Wire @@ -408,7 +433,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); if (aCurve.IsNull()) + { continue; + } GeomAdaptor_Curve aGACurve(aCurve); GeomAbs_CurveType aType = aGACurve.GetType(); @@ -653,7 +680,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) LastVtx_final.Orientation(TopAbs_REVERSED); if (CurveSeq.IsEmpty()) + { return ResEdge; + } int nb_curve = CurveSeq.Length(); // number of curves NCollection_Array1> tab(0, nb_curve - 1); // array of the curves @@ -668,7 +697,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) for (i = 1; i <= nb_curve; i++) { if (CurveSeq(i)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { CurveSeq(i) = (*((occ::handle*)&(CurveSeq(i))))->BasisCurve(); + } occ::handle aTrCurve = new Geom_TrimmedCurve(CurveSeq(i), FparSeq(i), LparSeq(i)); @@ -686,7 +717,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) // DrawTrSurf::Set(name, tab(i-1)); if (i > 1) + { tabtolvertex(i - 2) = TolSeq(i - 1) * 5.; + } } tabtolvertex(nb_curve - 1) = TolSeq(TolSeq.Length()) * 5.; @@ -721,14 +754,20 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) { double MaxTolVer = LinTol; for (i = 1; i <= TolSeq.Length(); i++) + { if (TolSeq(i) > MaxTolVer) + { MaxTolVer = TolSeq(i); + } + } MaxTolVer *= 5.; GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); for (i = concatcurve->Lower() + 1; i <= concatcurve->Upper(); i++) + { Concat.Add(concatcurve->Value(i), MaxTolVer, true); + } concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); } @@ -746,7 +785,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) else { if (CurveSeq(1)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { CurveSeq(1) = (*((occ::handle*)&(CurveSeq(1))))->BasisCurve(); + } occ::handle aCopyCurve = occ::down_cast(CurveSeq(1)->Copy()); @@ -754,7 +795,9 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire) } if (isReverse) + { ResEdge.Reverse(); + } return ResEdge; } diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_1.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_1.cxx index 4499822f61..753abc2641 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_1.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_1.cxx @@ -50,7 +50,9 @@ bool BRepAlgo::IsValid(const NCollection_List& theArgs, const bool GeomCtrl) { if (theResult.IsNull()) + { return true; + } bool validate = false; NCollection_Map allFaces; @@ -74,10 +76,14 @@ bool BRepAlgo::IsValid(const NCollection_List& theArgs, if (allFaces.IsEmpty()) { if (validate) + { return true; + } BRepCheck_Analyzer ana(theResult, GeomCtrl); if (!ana.IsValid()) + { return false; + } } else if (!validate) { @@ -89,7 +95,9 @@ bool BRepAlgo::IsValid(const NCollection_List& theArgs, if (!allFaces.Contains(curf)) { if (toCheck.IsNull()) + { bB.MakeCompound(toCheck); + } BRepTools::Update(curf); bB.Add(toCheck, curf); } @@ -154,7 +162,9 @@ bool BRepAlgo::IsValid(const NCollection_List& theArgs, // corrected ana.Init(toCheck, true); if (!ana.IsValid()) + { return false; + } } } } @@ -163,17 +173,27 @@ bool BRepAlgo::IsValid(const NCollection_List& theArgs, for (tEx.Init(theResult, TopAbs_SHELL); tEx.More(); tEx.Next()) { if (HR.IsNull()) + { HR = new BRepCheck_Shell(TopoDS::Shell(tEx.Current())); + } else + { HR->Init(tEx.Current()); + } if (HR->Status().First() != BRepCheck_NoError) + { return false; + } if (HR->Orientation(false) != BRepCheck_NoError) + { return false; + } if (closedSolid) { if (HR->Closed() != BRepCheck_NoError) + { return false; + } } } diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_AsDes.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_AsDes.cxx index 5f9ab8a655..91f3d13b4e 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_AsDes.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_AsDes.cxx @@ -83,7 +83,9 @@ bool BRepAlgo_AsDes::HasDescendant(const TopoDS_Shape& S) const const NCollection_List& BRepAlgo_AsDes::Ascendant(const TopoDS_Shape& S) const { if (up.IsBound(S)) + { return up(S); + } static NCollection_List empty; return empty; } @@ -93,7 +95,9 @@ const NCollection_List& BRepAlgo_AsDes::Ascendant(const TopoDS_Sha const NCollection_List& BRepAlgo_AsDes::Descendant(const TopoDS_Shape& S) const { if (down.IsBound(S)) + { return down(S); + } static NCollection_List empty; return empty; } @@ -103,7 +107,9 @@ const NCollection_List& BRepAlgo_AsDes::Descendant(const TopoDS_Sh NCollection_List& BRepAlgo_AsDes::ChangeDescendant(const TopoDS_Shape& S) { if (down.IsBound(S)) + { return down.ChangeFind(S); + } static NCollection_List empty; return empty; } @@ -133,7 +139,9 @@ static void ReplaceInList(const TopoDS_Shape& OldS, L.Remove(it); } else + { it.Next(); + } } } diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_FaceRestrictor.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_FaceRestrictor.cxx index 0e7db31198..1ad1aef007 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_FaceRestrictor.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_FaceRestrictor.cxx @@ -76,7 +76,9 @@ static bool ChangePCurve(TopoDS_Edge& E, const occ::handle& S, Top BRep_Tool::CurveOnSurface(E, C2, SE, LE, f, l, 1); if (!C2.IsNull()) + { BB.UpdateEdge(E, C2, S, L, Precision::Confusion()); + } return (C2.IsNull()); } @@ -210,7 +212,9 @@ static bool IsClosed(const TopoDS_Wire& W) { if (W.Closed()) + { return true; + } TopoDS_Vertex V1, V2; TopExp::Vertices(W, V1, V2); return (V1.IsSame(V2)); @@ -298,7 +302,9 @@ static void BuildFaceIn( BRep_Builder B; if (!KeyContains.IsBound(W) || KeyContains(W).IsEmpty()) + { return; + } // Removal of W in KeyIsIn. // for (NCollection_List::Iterator it(KeyContains(W)); it.More(); it.Next()) { diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Image.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Image.cxx index a46adac909..c9cab01324 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Image.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Image.cxx @@ -62,9 +62,13 @@ void BRepAlgo_Image::Bind(const TopoDS_Shape& OldS, const NCollection_List LI; if (HasImage(S)) + { LastImage(S, LI); + } M.Bind(S, LI); } up.Clear(); @@ -298,7 +310,9 @@ void BRepAlgo_Image::RemoveRoot(const TopoDS_Shape& Root) } if (!isRemoved) + { return; + } const NCollection_List* pNewS = down.Seek(Root); if (pNewS) @@ -307,7 +321,9 @@ void BRepAlgo_Image::RemoveRoot(const TopoDS_Shape& Root) { const TopoDS_Shape* pOldS = up.Seek(it.Value()); if (pOldS && pOldS->IsSame(Root)) + { up.UnBind(it.Value()); + } } down.UnBind(Root); } @@ -318,13 +334,19 @@ void BRepAlgo_Image::RemoveRoot(const TopoDS_Shape& Root) void BRepAlgo_Image::ReplaceRoot(const TopoDS_Shape& OldRoot, const TopoDS_Shape& NewRoot) { if (!HasImage(OldRoot)) + { return; + } const NCollection_List& aLImage = Image(OldRoot); if (HasImage(NewRoot)) + { Add(NewRoot, aLImage); + } else + { Bind(NewRoot, aLImage); + } SetRoot(NewRoot); RemoveRoot(OldRoot); diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Loop.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Loop.cxx index cd5bde9b39..b0d3bbd2d4 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Loop.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_Loop.cxx @@ -81,12 +81,16 @@ static void Bubble(const TopoDS_Edge& E, NCollection_Sequence& Seq { // Remove duplicates for (int i = 1; i < Seq.Length(); i++) + { for (int j = i + 1; j <= Seq.Length(); j++) + { if (Seq(i) == Seq(j)) { Seq.Remove(j); j--; } + } + } bool Invert = true; int NbPoints = Seq.Length(); @@ -167,7 +171,9 @@ static TopoDS_Vertex UpdateClosedEdge(const TopoDS_Edge& E, NCollection_Sequence /////////////////////////////////////////////// if (SV.IsEmpty()) + { return VRes; + } VB[0] = TopoDS::Vertex(SV.First()); VB[1] = TopoDS::Vertex(SV.Last()); @@ -180,9 +186,13 @@ static TopoDS_Vertex UpdateClosedEdge(const TopoDS_Edge& E, NCollection_Sequence { VRes = VB[i]; if (i == 0) + { OnStart = true; + } else + { OnEnd = true; + } } } if (OnStart && OnEnd) @@ -198,13 +208,19 @@ static TopoDS_Vertex UpdateClosedEdge(const TopoDS_Edge& E, NCollection_Sequence { SV.Remove(1); if (!SV.IsEmpty()) + { SV.Remove(SV.Length()); + } } } else if (OnStart) + { SV.Remove(1); + } else if (OnEnd) + { SV.Remove(SV.Length()); + } return VRes; } @@ -269,7 +285,9 @@ static void RemovePendingEdges( LE.Remove(itl); } else + { itl.Next(); + } } } } @@ -289,14 +307,22 @@ static bool SamePnt2d(const TopoDS_Vertex& V, TopoDS_Edge& E1, TopoDS_Edge& E2, occ::handle C1 = BRep_Tool::CurveOnSurface(E1, FF, f1, l1); occ::handle C2 = BRep_Tool::CurveOnSurface(E2, FF, f2, l2); if (E1.Orientation() == TopAbs_FORWARD) + { P1 = C1->Value(f1); + } else + { P1 = C1->Value(l1); + } if (E2.Orientation() == TopAbs_FORWARD) + { P2 = C2->Value(l2); + } else + { P2 = C2->Value(f2); + } double Tol = 100 * BRep_Tool::Tolerance(V); double Dist = P1.Distance(P2); return Dist < Tol; @@ -355,9 +381,13 @@ static bool SelectEdge(const TopoDS_Face& F, double dist, distmin = 100 * BRep_Tool::Tolerance(CV); double u; if (CE.Orientation() == TopAbs_FORWARD) + { u = l; + } else + { u = f; + } gp_Pnt2d P2, PV = C->Value(u); @@ -368,9 +398,13 @@ static bool SelectEdge(const TopoDS_Face& F, { C = BRep_Tool::CurveOnSurface(E, FForward, f, l); if (E.Orientation() == TopAbs_FORWARD) + { u = f; + } else + { u = l; + } P2 = C->Value(u); dist = PV.Distance(P2); if (dist <= distmin) @@ -382,7 +416,9 @@ static bool SelectEdge(const TopoDS_Face& F, k++; } if (kmin == 0) + { return false; + } k = 1; itl.Initialize(LE); @@ -457,7 +493,9 @@ static void StoreInMVE( NCollection_List VList; TopoDS_Iterator VerExp(E); for (; VerExp.More(); VerExp.Next()) + { VList.Append(VerExp.Value()); + } NCollection_List::Iterator itl(VList); for (; itl.More(); itl.Next()) { @@ -481,7 +519,9 @@ static void StoreInMVE( { TopoDS_Shape NewNewV = VerticesForSubstitute(V); if (!NewNewV.IsSame(V1)) + { VerticesForSubstitute.Bind(V1, NewNewV); + } } else { @@ -489,8 +529,12 @@ static void StoreInMVE( NCollection_DataMap::Iterator mapit(VerticesForSubstitute); for (; mapit.More(); mapit.Next()) + { if (mapit.Value().IsSame(V1)) + { VerticesForSubstitute(mapit.Key()) = V; + } + } } } E.Free(true); @@ -586,7 +630,9 @@ void BRepAlgo_Loop::Perform() { TopoDS_Edge& E = TopoDS::Edge(itl1.ChangeValue()); if (!Emap.Add(E)) + { continue; + } StoreInMVE(myFace, E, MVE, YaCouture, myVerticesForSubstitute, myTolConf); } } @@ -600,7 +646,9 @@ void BRepAlgo_Loop::Perform() { TopoDS_Edge& E = TopoDS::Edge(itl.ChangeValue()); if (DejaVu.Add(E)) + { StoreInMVE(myFace, E, MVE, YaCouture, myVerticesForSubstitute, myTolConf); + } } //----------------------------------------------- @@ -625,7 +673,9 @@ void BRepAlgo_Loop::Perform() RemovePendingEdges(MVE); if (MVE.Extent() == 0) + { break; + } //-------------------------------- // Start edge. //-------------------------------- @@ -643,7 +693,9 @@ void BRepAlgo_Loop::Perform() CV = VF = V2; } if (!MVE.Contains(CV)) + { continue; + } NCollection_List& aListEdges = MVE.ChangeFromKey(CV); for (itl.Initialize(aListEdges); itl.More(); itl.Next()) { @@ -662,9 +714,13 @@ void BRepAlgo_Loop::Perform() //------------------------------- TopExp::Vertices(CE, V1, V2); if (!CV.IsSame(V1)) + { CV = V1; + } else + { CV = V2; + } B.Add(NW, CE); UsedEdges.Add(CE); @@ -680,7 +736,9 @@ void BRepAlgo_Loop::Perform() { CE = NE; if (MVE.FindFromKey(CV).IsEmpty()) + { MVE.RemoveKey(CV); + } } } } @@ -800,9 +858,13 @@ void BRepAlgo_Loop::CutEdge(const TopoDS_Edge& E, // Eventually all extremities of the edge. //----------------------------------------- if (!VF.IsNull() && !VF.IsSame(SV.First())) + { SV.Prepend(VF); + } if (!VL.IsNull() && !VL.IsSame(SV.Last())) + { SV.Append(VL); + } } while (!SV.IsEmpty()) @@ -812,11 +874,15 @@ void BRepAlgo_Loop::CutEdge(const TopoDS_Edge& E, SV.Remove(1); } if (SV.IsEmpty()) + { break; + } V1 = TopoDS::Vertex(SV.First()); SV.Remove(1); if (SV.IsEmpty()) + { break; + } if (SV.First().Orientation() == TopAbs_REVERSED) { V2 = TopoDS::Vertex(SV.First()); @@ -830,14 +896,18 @@ void BRepAlgo_Loop::CutEdge(const TopoDS_Edge& E, aLocalEdge = V2.Oriented(TopAbs_REVERSED); B.Add(TopoDS::Edge(NewEdge), aLocalEdge); if (V1.IsSame(VF)) + { U1 = f; + } else { TopoDS_Shape aLocalV = V1.Oriented(TopAbs_INTERNAL); U1 = BRep_Tool::Parameter(TopoDS::Vertex(aLocalV), WE); } if (V2.IsSame(VL)) + { U2 = l; + } else { TopoDS_Shape aLocalV = V2.Oriented(TopAbs_INTERNAL); @@ -858,15 +928,21 @@ void BRepAlgo_Loop::CutEdge(const TopoDS_Edge& E, double fpar, lpar; BRep_Tool::Range(EE, fpar, lpar); if (lpar - fpar <= Precision::Confusion()) + { NE.Remove(it); + } else { gp_Pnt2d pf, pl; BRep_Tool::UVPoints(EE, myFace, pf, pl); if (pf.Distance(pl) <= Tol && !BRep_Tool::IsClosed(EE)) + { NE.Remove(it); + } else + { it.Next(); + } } } } @@ -969,14 +1045,18 @@ void BRepAlgo_Loop::UpdateVEmap( } if (VerLver.IsEmpty()) + { return; + } BRep_Builder aBB; for (int ii = 1; ii <= VerLver.Extent(); ii++) { const NCollection_List& aVlist = VerLver(ii); if (aVlist.Extent() == 1) + { continue; + } double aMaxTol = 0.; NCollection_Array1 Points(1, aVlist.Extent()); @@ -1014,23 +1094,31 @@ void BRepAlgo_Loop::UpdateVEmap( const TopoDS_Shape& anEdge = aElist.First(); NCollection_List::Iterator itcedges(myConstEdges); for (; itcedges.More(); itcedges.Next()) + { if (anEdge.IsSame(itcedges.Value())) { aConstVertex = aVertex; break; } + } if (!aConstVertex.IsNull()) + { break; + } } if (aConstVertex.IsNull()) + { aConstVertex = TopoDS::Vertex(aVlist.First()); + } aBB.UpdateVertex(aConstVertex, aCentre, aMaxTol); for (itl.Initialize(aVlist); itl.More(); itl.Next()) { const TopoDS_Vertex& aVertex = TopoDS::Vertex(itl.Value()); if (aVertex.IsSame(aConstVertex)) + { continue; + } const NCollection_List& aElist = theVEmap.FindFromKey(aVertex); TopoDS_Edge anEdge = TopoDS::Edge(aElist.First()); @@ -1050,10 +1138,14 @@ void BRepAlgo_Loop::UpdateVEmap( const NCollection_List& aElist = theVEmap(ii); NCollection_List::Iterator itl(aElist); for (; itl.More(); itl.Next()) + { Emap.Add(itl.Value()); + } } theVEmap.Clear(); for (int ii = 1; ii <= Emap.Extent(); ii++) + { TopExp::MapShapesAndAncestors(Emap(ii), TopAbs_VERTEX, TopAbs_EDGE, theVEmap); + } } diff --git a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_NormalProjection.cxx b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_NormalProjection.cxx index d214165439..696a7966a9 100644 --- a/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_NormalProjection.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepAlgo/BRepAlgo_NormalProjection.cxx @@ -310,10 +310,14 @@ void BRepAlgo_NormalProjection::Build() Only3d = true; } else + { HPCur = HProjector; + } if ((!myWith3d || Elementary) && (HProjector->MaxDistance(k) <= myTol3d)) + { Only2d = true; + } if (Only2d && Only3d) { @@ -332,7 +336,9 @@ void BRepAlgo_NormalProjection::Build() appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d); if (appr.MaxError3d() > 1.e3 * myTol3d) + { continue; + } #ifdef OCCT_DEBUG_CHRONO ResultChron(chr_approx, t_approx); @@ -349,7 +355,9 @@ void BRepAlgo_NormalProjection::Build() #endif if (!Only3d) + { PCur2d = appr.Curve2d(); + } if (Only2d) { BRepLib_MakeEdge MKed(GeomAdaptor::MakeCurve(*hcur), Udeb, Ufin); @@ -534,7 +542,9 @@ void BRepAlgo_NormalProjection::Build() // relations of map myAncestorMap, myCorresp will be lost. if (YaVertexRes) + { BB.Add(myRes, VertexRes); + } myIsDone = true; @@ -653,7 +663,9 @@ bool BRepAlgo_NormalProjection::BuildWire(NCollection_List& ListOf TopExp_Explorer exp2(Wire, TopAbs_EDGE); int NbEdges = 0; for (; exp2.More(); exp2.Next()) + { NbEdges++; + } if (NbEdges == List.Extent()) { ListOfWire.Append(Wire); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill.cxx index 5bd87df0c7..7637929bc5 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill.cxx @@ -415,7 +415,9 @@ TopoDS_Face BRepFill::Face(const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2) BRepLib::SameParameter(Face); if (SameLoc) + { Face.Move(L); + } return Face; } @@ -492,7 +494,9 @@ TopoDS_Shell BRepFill::Shell(const TopoDS_Wire& Wire1, const TopoDS_Wire& Wire2) C1->Reverse(); } else + { TopExp::Vertices(Edge1, V1f, V1l); + } if (std::abs(f2 - C2->FirstParameter()) > Precision::PConfusion() || std::abs(l2 - C2->LastParameter()) > Precision::PConfusion()) @@ -513,7 +517,9 @@ TopoDS_Shell BRepFill::Shell(const TopoDS_Wire& Wire1, const TopoDS_Wire& Wire2) C2->Reverse(); } else + { TopExp::Vertices(Edge2, V2f, V2l); + } GeomFill_Generator Generator; Generator.AddCurve(C1); @@ -599,7 +605,9 @@ TopoDS_Shell BRepFill::Shell(const TopoDS_Wire& Wire1, const TopoDS_Wire& Wire2) B.Add(Face, W); if (SameLoc) + { Face.Move(L); + } B.Add(Shell, Face); @@ -701,10 +709,14 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, } if (S.IsNull()) + { throw Standard_DomainError("BRepFill_Evolved::Axe"); + } if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } Normal = occ::down_cast(S)->Pln().Axis().Direction(); @@ -735,11 +747,15 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, double DistP1P2 = P1.SquareDistance(P2); IsOnVertex = (DistP1P2 <= Tol2); if (IsOnVertex) + { break; + } } // otherwise SE.Next() is done and VonF is wrong if (IsOnVertex) + { break; + } // modified by NIZHNY-EAP Wed Jan 26 09:08:36 2000 ___END___ } @@ -768,7 +784,9 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, Loc1.Transform(L.Transformation()); } if (E1.Orientation() == TopAbs_REVERSED) + { Tang1.Reverse(); + } occ::handle CE2 = BRep_Tool::Curve(E2, L, f, l); double Par2 = BRep_Tool::Parameter(VonF, E2, aFace); @@ -779,7 +797,9 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, Loc2.Transform(L.Transformation()); } if (E2.Orientation() == TopAbs_REVERSED) + { Tang2.Reverse(); + } // modified by NIZHNY-EAP Wed Feb 2 15:38:41 2000 ___BEGIN___ Tang1.Normalize(); @@ -843,7 +863,9 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, BRepAdaptor_Curve BAC(E); BAC.D1(Par, Loc, Tang); if (E.Orientation() == TopAbs_REVERSED) + { Tang.Reverse(); + } } } } @@ -863,7 +885,9 @@ void BRepFill::Axe(const TopoDS_Shape& Spine, void BRepFill::SearchOrigin(TopoDS_Wire& W, const gp_Pnt& P, const gp_Vec& Dir, const double Tol) { if (!W.Closed()) + { throw Standard_NoSuchObject("BRepFill::SearchOrigin : the wire must be closed"); + } bool NewVertex = false; double theparam = 1.e101, angle; @@ -883,11 +907,13 @@ void BRepFill::SearchOrigin(TopoDS_Wire& W, const gp_Pnt& P, const gp_Vec& Dir, int isol = 1; double dss = P.Distance(DSS.PointOnShape2(isol)); for (int iss = 2; iss <= DSS.NbSolution(); iss++) + { if (dss > P.Distance(DSS.PointOnShape2(iss))) { dss = P.Distance(DSS.PointOnShape2(iss)); isol = iss; } + } TopoDS_Shape supp = DSS.SupportOnShape2(isol); if (DSS.SupportTypeShape2(isol) == BRepExtrema_IsVertex) { @@ -932,7 +958,9 @@ void BRepFill::SearchOrigin(TopoDS_Wire& W, const gp_Pnt& P, const gp_Vec& Dir, // Calculate the number of edges for (exp.Init(W); exp.More(); exp.Next()) + { NbEdges++; + } if (NewVertex) { NbEdges++; @@ -963,7 +991,9 @@ void BRepFill::SearchOrigin(TopoDS_Wire& W, const gp_Pnt& P, const gp_Vec& Dir, } } if (rangdeb == 0) + { rangdeb = NbEdges; + } // Calculate the direction of parsing E = TopoDS::Edge(Edges(rangdeb)); @@ -982,7 +1012,9 @@ void BRepFill::SearchOrigin(TopoDS_Wire& W, const gp_Pnt& P, const gp_Vec& Dir, } angle = Ve.Angle(Dir); if (angle > M_PI) + { angle = 2 * M_PI - angle; + } forward = (angle <= M_PI / 2); // Reconstruction @@ -1093,12 +1125,16 @@ TopoDS_Wire BRepFill::InsertACR(const TopoDS_Wire& wire, if (E.Orientation() == TopAbs_FORWARD) { for (j = 1; j <= ndec; j++) + { SR.Append(paradec(j)); + } } else { for (j = 1; j <= ndec; j++) + { SR.Append(t0 + t1 - paradec(ndec + 1 - j)); + } } TrimEdge(E, SR, t0, t1, SO, SE); for (j = 1; j <= SE.Length(); j++) diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ACRLaw.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ACRLaw.cxx index 5b3e1b8bd5..b570a5be46 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ACRLaw.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ACRLaw.cxx @@ -43,7 +43,9 @@ BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path BRepTools_WireExplorer wexp; int NbEdge = 0; for (wexp.Init(myPath); wexp.More(); wexp.Next()) + { NbEdge++; + } // tab to memorize ACR for each edge OrigParam = new (NCollection_HArray1)(0, NbEdge); @@ -62,7 +64,9 @@ BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path // return ACR of edges of the trajectory OrigParam->SetValue(0, 0); for (ipath = 1; ipath <= NbEdge; ipath++) + { OrigParam->SetValue(ipath, Orig(ipath)); + } // process each edge of the trajectory for (ipath = 0, wexp.Init(myPath); wexp.More(); wexp.Next()) diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_AdvancedEvolved.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_AdvancedEvolved.cxx index 1608c948d0..b561e8d0fd 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_AdvancedEvolved.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_AdvancedEvolved.cxx @@ -121,7 +121,9 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, const NCollection_List& aLE = aMVEP.FindFromIndex(i); if (aLE.Extent() < 2) + { continue; + } const TopoDS_Edge& anE1 = TopoDS::Edge(aLE.First()); const TopoDS_Edge& anE2 = TopoDS::Edge(aLE.Last()); @@ -154,7 +156,9 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, const gp_Pln aPln(aLoc, aN2); BRepLib_MakeFace aMF(aPln, theProfile); if (!aMF.IsDone()) + { return; + } anExtr.LoadS2(aMF.Face()); } @@ -164,11 +168,15 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, } if (!anExtr.Perform()) + { return; + } const int aNbSol = anExtr.NbSolution(); if (aNbSol < 1) + { return; + } double aDistMin = RealLast(); int anIdxMin = 0; @@ -177,7 +185,9 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, { const double aD = anExtr.Value(); if (aD > aDistMin) + { continue; + } aDistMin = aD; anIdxMin = aSolId; @@ -262,7 +272,9 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, case BRepExtrema_IsVertex: { const BRepLib_MakeFace aMkFSpine(theSpine, true); if (!aMkFSpine.IsDone()) + { return; + } const TopoDS_Face& aFSpine = aMkFSpine.Face(); const occ::handle aPlnSpine = @@ -300,10 +312,14 @@ void BRepFill_AdvancedEvolved::GetSpineAndProfile(const TopoDS_Wire& theSpine, double aSqT2 = aT2.SquareMagnitude(); if (aSqT1 < Precision::SquareConfusion()) + { aSqT1 = RealLast(); + } if (aSqT2 < Precision::SquareConfusion()) + { aSqT2 = RealLast(); + } const double aDP1 = aT1.Dot(aN1); const double aDP2 = aT2.Dot(aN1); @@ -361,12 +377,16 @@ bool BRepFill_AdvancedEvolved::IsLid( const NCollection_IndexedMap& theMapOfLids) const { if (theMapOfLids.IsEmpty()) + { return false; + } const occ::handle aPlnF = occ::down_cast(BRep_Tool::Surface(theF)); if (aPlnF.IsNull()) + { return false; + } NCollection_IndexedMap::Iterator anItr(theMapOfLids); for (; anItr.More(); anItr.Next()) @@ -375,7 +395,9 @@ bool BRepFill_AdvancedEvolved::IsLid( const occ::handle aPlane = occ::down_cast(BRep_Tool::Surface(aF)); if (aPlane == aPlnF) + { return true; + } } return false; @@ -461,17 +483,23 @@ void BRepFill_AdvancedEvolved::Perform(const TopoDS_Wire& theSpine, { BRep_Builder aBB; if (aShell.IsNull()) + { aBB.MakeShell(aShell); + } const TopoDS_Face& aF = TopoDS::Face(anExp.Current()); if (IsLid(aF, aMFLids)) + { continue; + } aBB.Add(aShell, aF); } if (!aShell.IsNull()) + { myResult = aShell; + } } //================================================================================================= @@ -479,7 +507,9 @@ void BRepFill_AdvancedEvolved::Perform(const TopoDS_Wire& theSpine, void BRepFill_AdvancedEvolved::PerformSweep() { if (myErrorStatus != BRepFill_AdvancedEvolved_Empty) + { return; + } myErrorStatus = BRepFill_AdvancedEvolved_SweepError; @@ -500,7 +530,9 @@ void BRepFill_AdvancedEvolved::PerformSweep() void BRepFill_AdvancedEvolved::GetLids() { if (myPipeShell.IsNull()) + { return; + } if (BRep_Tool::IsClosed(myProfile)) { @@ -549,7 +581,9 @@ void BRepFill_AdvancedEvolved::GetLids() NCollection_List& aListF = aMapEF(i); if (aListF.Extent() != 1) + { continue; + } const TopoDS_Edge& anE = TopoDS::Edge(aMapEF.FindKey(i)); @@ -564,11 +598,15 @@ void BRepFill_AdvancedEvolved::GetLids() const double aSqModulus = aTan.SquareMagnitude(); if (aSqModulus < Precision::Confusion()) + { continue; + } const double aDP = aTan.XYZ().Dot(aNormal.XYZ()); if (std::abs(aDP) > aDPMax) + { aDPMax = std::abs(aDP); + } if (aDP * aDP > aSqModulus * aSqAnguarTol) { // Only planar edges are considered @@ -627,7 +665,9 @@ void BRepFill_AdvancedEvolved::GetLids() const double aSqD = aDelta.SquareModulus(); if (aSqD < Precision::SquareConfusion()) + { continue; + } const double aDP = aDelta.Dot(aNorm); @@ -665,7 +705,9 @@ void BRepFill_AdvancedEvolved::GetLids() void BRepFill_AdvancedEvolved::BuildSolid() { if (myErrorStatus != BRepFill_AdvancedEvolved_NotSolid) + { return; + } myErrorStatus = BRepFill_AdvancedEvolved_NotVolume; @@ -683,7 +725,9 @@ void BRepFill_AdvancedEvolved::BuildSolid() { const TopoDS_Face& aF = TopoDS::Face(anExpF.Current()); if (!aMapF.Add(aF)) + { continue; + } ReduceVertexTolerance(aF); CheckSingularityAndAdd(aF, myFuzzyValue, aLF, aLSplits); @@ -726,7 +770,9 @@ void BRepFill_AdvancedEvolved::BuildSolid() { const TopoDS_Face& aF = TopoDS::Face(anExpF.Current()); if (!aMapF.Add(aF)) + { continue; + } aLF.Append(aF); } @@ -814,11 +860,15 @@ void BRepFill_AdvancedEvolved::ExtractOuterSolid(TopoDS_Shape& for (int i = 1; i <= aNbF; ++i) { if (aMapS(i).Extent() == 1) + { aNewList.Append(aMapS.FindKey(i)); + } } if (aNewList.IsEmpty()) + { return; + } { NCollection_List::Iterator anItrF; @@ -863,7 +913,9 @@ void BRepFill_AdvancedEvolved::RemoveExcessSolids(const NCollection_List aC = BRep_Tool::CurveOnSurface(anEdge, theFace, aF, aL); aF = BRep_Tool::Parameter(aVertCurr, anEdge); @@ -1290,7 +1358,9 @@ static void InsertEDegenerated(const TopoDS_Face& theFace, } if (aFirstEdge.IsNull() || aLastEdge.IsNull()) + { return; + } // TopExp::CommonVertex(...) does not work // if edges have more than one pair of common vertex @@ -1317,7 +1387,9 @@ static void InsertEDegenerated(const TopoDS_Face& theFace, for (int anIDLE = 2; anIDLE < 4; anIDLE++) { if (!aV[anIDFE].IsSame(aV[anIDLE])) + { continue; + } const NCollection_List* anEList = aMapVE.Seek(aV[anIDFE]); if ((anEList != nullptr) && (anEList->Extent() > 2)) @@ -1383,7 +1455,9 @@ bool BRepFill_AdvancedEvolved::CheckSingularityAndAdd( const TopoDS_Edge& anE = TopoDS::Edge(anExp.Current()); if (aME.Add(anE)) + { aLE.Append(anE); + } } // Split interfered edges @@ -1561,7 +1635,9 @@ void FindInternals(const TopoDS_Shape& theS, NCollection_List& the { const TopoDS_Shape& aSS = itS.Value(); if (aSS.Orientation() == TopAbs_INTERNAL) + { theLInt.Append(aSS); + } else { TopoDS_Iterator itSS(aSS); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ApproxSeewing.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ApproxSeewing.cxx index 22b7b96f61..09b6c29bc8 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ApproxSeewing.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ApproxSeewing.cxx @@ -100,7 +100,9 @@ void BRepFill_ApproxSeewing::Perform(const BRepFill_MultiLine& ML) for (i = 2; i < NbPoints; i++) { while (LP(Index).X() < Corde) + { Index++; + } Alpha = (Corde - LP(Index - 1).X()) / (LP(Index).X() - LP(Index - 1).X()); U = LP(Index - 1).Y() + Alpha * (LP(Index).Y() - LP(Index - 1).Y()); AppDef_MultiPointConstraint MPC(1, 2); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx index eb4f3effdb..71cd13ee36 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CompatibleWires.cxx @@ -144,7 +144,9 @@ static void AddNewEdge(const TopoDS_Shape& theEd } } else + { ListNewEdges.Append(theEdge); + } } static void SeqOfVertices(const TopoDS_Wire& W, NCollection_Sequence& S) @@ -158,10 +160,14 @@ static void SeqOfVertices(const TopoDS_Wire& W, NCollection_Sequence(S->Transformed(L.Transformation())); + } P = (occ::down_cast(S))->Pln(); P.SetLocation(Bary); } @@ -245,7 +257,9 @@ static bool PlaneOfWire(const TopoDS_Wire& W, gp_Pln& P) if ((std::abs(RMax - R1) < Tol && std::abs(RMax - R2) < Tol) || (std::abs(RMax - R1) < Tol && std::abs(RMax - R3) < Tol) || (std::abs(RMax - R2) < Tol && std::abs(RMax - R3) < Tol)) + { isplane = false; + } else { if (R1 >= R2 && R1 >= R3) @@ -298,7 +312,9 @@ static void WireContinuity(const TopoDS_Wire& W, GeomAbs_Shape& contW) nbEdges++; Edges->Append(anExp.Current()); if (BRep_Tool::Degenerated(anExp.Current())) + { IsDegenerated = true; + } } if (!IsDegenerated) @@ -332,13 +348,17 @@ static void WireContinuity(const TopoDS_Wire& W, GeomAbs_Shape& contW) double Eps = BRep_Tool::Tolerance(V2) + BRep_Tool::Tolerance(V1); if (j == nbEdges) + { testconti = Curve1.Value(U1).IsEqual(Curve2.Value(U2), Eps); + } if (testconti) { cont = BRepLProp::Continuity(Curve1, Curve2, U1, U2, Eps, Precision::Angular()); if (cont <= contW) + { contW = cont; + } } } } @@ -449,7 +469,9 @@ static bool SearchRoot( ilyest = true; } if (ilyest) + { break; + } } if (ilyest) { @@ -457,7 +479,9 @@ static bool SearchRoot( VRoot = TopoDS::Vertex(it.Key()); } if (trouve) + { break; + } } return trouve; } @@ -483,7 +507,9 @@ static bool SearchVertex(const NCollection_List& List, ilyest = true; } if (ilyest) + { break; + } } if (ilyest) { @@ -491,7 +517,9 @@ static bool SearchVertex(const NCollection_List& List, VonW = Vi; } if (trouve) + { break; + } } return trouve; } @@ -580,7 +608,9 @@ static bool EdgeIntersectOnWire( { TopoDS_Vertex VRoot; if (SearchRoot(Vsol, Map, VRoot)) + { NewVertex = true; + } } } else @@ -667,9 +697,13 @@ static void Transform(const bool WithRotation, alpha = Vtrans.Dot(axe1); beta = Vtrans.Dot(axe2); if (alpha < -1.e-7) + { axe1 *= -1; + } if (beta < 1.e-7) + { axe2 *= -1; + } alpha = Vtrans.Dot(axe1); beta = Vtrans.Dot(axe2); gp_Vec norm2 = axe1 ^ axe2; @@ -678,15 +712,21 @@ static void Transform(const bool WithRotation, beta = Vsign.Dot(axe2); bool pasnul = (std::abs(alpha) > 1.e-4 && std::abs(beta) > 1.e-4); if (alpha * beta > 0.0 && pasnul) + { sign = -1; + } gp_Ax1 Norm(Pos2, norm2); double ang = axe1.AngleWithRef(axe2, norm2); if (!WithRotation) { if (ang > M_PI / 2) + { ang = ang - M_PI; + } if (ang < -M_PI / 2) + { ang = ang + M_PI; + } } ang *= sign; Pnew = Pnew.Rotated(Norm, ang); @@ -723,7 +763,9 @@ static void BuildConnectedEdges(const TopoDS_Wire& aWire, } } if (CurVertex.IsSame(Origin)) + { break; + } } } @@ -758,7 +800,9 @@ void BRepFill_CompatibleWires::Init(const NCollection_Sequence& Se void BRepFill_CompatibleWires::SetPercent(const double Percent) { if (0. < Percent && Percent < 1.) + { myPercent = Percent; + } } //================================================================================================= @@ -832,16 +876,26 @@ void BRepFill_CompatibleWires::Perform(const bool WithRotation) TopoDS_Wire W = TopoDS::Wire(myWork(i)); WireContinuity(W, cont); if (cont < contS) + { contS = cont; + } nbEdges(i) = 0; for (anExp.Init(W); anExp.More(); anExp.Next()) + { nbEdges(i)++; + } if (i == 1) + { nbmin = nbEdges(i); + } if (nbmax < nbEdges(i)) + { nbmax = nbEdges(i); + } if (nbmin > nbEdges(i)) + { nbmin = nbEdges(i); + } } // if the number of elements is not the same or if all wires are at least // C1, the report is carried out by curvilinear abscissa of cuts, otherwise @@ -871,7 +925,9 @@ void BRepFill_CompatibleWires::Perform(const bool WithRotation) myDegen1 = myDegen1 && (BRep_Tool::Degenerated(anExp.Current())); } if (myDegen1) + { ideb++; + } // check if the last wire is punctual myDegen2 = true; for (anExp.Init(TopoDS::Wire(myWork(ifin))); anExp.More(); anExp.Next()) @@ -879,7 +935,9 @@ void BRepFill_CompatibleWires::Perform(const bool WithRotation) myDegen2 = myDegen2 && (BRep_Tool::Degenerated(anExp.Current())); } if (myDegen2) + { ifin--; + } bool wClosed, allClosed = true, allOpen = true; for (i = ideb; i <= ifin; i++) @@ -891,7 +949,9 @@ void BRepFill_CompatibleWires::Perform(const bool WithRotation) TopoDS_Vertex V1, V2; TopExp::Vertices(TopoDS::Wire(myWork(i)), V1, V2); if (V1.IsSame(V2)) + { wClosed = true; + } } allClosed = (allClosed && wClosed); allOpen = (allOpen && !wClosed); @@ -971,9 +1031,13 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) // sections ponctuelles, sections bouclantes ? if (myDegen1) + { ideb++; + } if (myDegen2) + { ifin--; + } bool vClosed = (!myDegen1) && (!myDegen2) && (myWork(ideb).IsSame(myWork(ifin))); // Removing degenerated edges @@ -999,7 +1063,9 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) { const TopoDS_Edge& anEdge = TopoDS::Edge(anItw.Value()); if (!BRep_Tool::Degenerated(anEdge)) + { aBBuilder.Add(aNewWire, anEdge); + } } myWork(i) = aNewWire; } @@ -1100,7 +1166,9 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) newwire, EdgeNewEdges); if (NewVertex) + { myWork(i - 1) = newwire; + } RMap(Vi).Append(Vsol); } @@ -1206,7 +1274,9 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) EdgeNewEdges); MapVLV(VRoot).Append(Vsol); if (NewVertex) + { myWork(i + 1) = newwire; + } } } } // loop on ii @@ -1218,7 +1288,9 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) // except for the last if the sections loop int ibout = ifin; if (vClosed) + { ibout--; + } for (i = ideb + 1; i <= ibout; i++) { @@ -1358,7 +1430,9 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) scal1 = N1.Dot(Ns); scal2 = N2.Dot(Ns); if (scal2 > scal1) + { E.Reverse(); + } MW.Add(E); } myWork(i) = MW.Wire(); @@ -1392,11 +1466,17 @@ void BRepFill_CompatibleWires::SameNumberByPolarMethod(const bool WithRotation) nbEdges++; } if (i == ideb) + { nbmin = nbEdges; + } if (nbmax < nbEdges) + { nbmax = nbEdges; + } if (nbmin > nbEdges) + { nbmin = nbEdges; + } } if (nbmin != nbmax) { @@ -1430,9 +1510,13 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) // point sections, blocking sections? if (myDegen1) + { ideb++; + } if (myDegen2) + { ifin--; + } bool vClosed = (!myDegen1) && (!myDegen2) && (myWork(ideb).IsSame(myWork(ifin))); int nbSects = myWork.Length(), i; @@ -1446,11 +1530,17 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) nbEdges(i)++; } if (i == 1) + { nbmin = nbEdges(i); + } if (nbmax < nbEdges(i)) + { nbmax = nbEdges(i); + } if (nbmin > nbEdges(i)) + { nbmin = nbEdges(i); + } } if (nbmax > 1) @@ -1491,7 +1581,9 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) { k++; if (k > nbdec) + { break; + } } if (dec(k - 1) < ACR(j) && ACR(j) < dec(k)) { @@ -1510,7 +1602,9 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) { k++; if (k > nbdec) + { break; + } } nbdec = k - 1; NCollection_Array1 dec2(1, nbdec); @@ -1536,14 +1630,20 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) } } if (AllLengthsNull) + { CutsToRemove.Add(k); + } } int NewNbDec = nbdec - CutsToRemove.Extent(); NCollection_Array1 dec3(1, NewNbDec); i = 1; for (k = 1; k <= nbdec; k++) + { if (!CutsToRemove.Contains(k)) + { dec3(i++) = dec2(k); + } + } /////////////////// // insertion of cuts in each wire @@ -1552,7 +1652,9 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) const TopoDS_Wire& oldwire = TopoDS::Wire(myWork(i)); double tol = Precision::Confusion(); if (WireLen(i) > gp::Resolution()) + { tol /= WireLen(i); + } TopoDS_Wire newwire = BRepFill::InsertACR(oldwire, dec3, tol); BRepTools_WireExplorer anExp1, anExp2; anExp1.Init(oldwire); @@ -1569,15 +1671,23 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) TopoDS_Vertex VF, VR; TopExp::Vertices(Ecur, VF, VR, true); if (V1.IsSame(VF)) + { P1 = BRep_Tool::Pnt(VR); + } if (V1.IsSame(VR)) + { P1 = BRep_Tool::Pnt(VF); + } TopoDS_Vertex V2 = anExp2.CurrentVertex(); TopExp::Vertices(TopoDS::Edge(anExp2.Current()), VF, VR, true); if (V2.IsSame(VF)) + { P2 = BRep_Tool::Pnt(VR); + } if (V2.IsSame(VR)) + { P2 = BRep_Tool::Pnt(VF); + } while (P1.Distance(P2) > 1.e-3) { LE.Append(anExp2.Current()); @@ -1585,9 +1695,13 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) V2 = anExp2.CurrentVertex(); TopExp::Vertices(TopoDS::Edge(anExp2.Current()), VF, VR, true); if (V2.IsSame(VF)) + { P2 = BRep_Tool::Pnt(VR); + } if (V2.IsSame(VR)) + { P2 = BRep_Tool::Pnt(VF); + } if (P1.Distance(P2) <= 1.e-3) { LE.Append(anExp2.Current()); @@ -1617,7 +1731,9 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) myMap(Ancestor).Remove(itlist); } if (itlist.More()) + { itlist.Next(); + } } } } @@ -1633,7 +1749,9 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) // blocking sections ? if (vClosed) + { myWork(myWork.Length()) = myWork(1); + } // check the number of edges for debug nbmax = 0; @@ -1645,11 +1763,17 @@ void BRepFill_CompatibleWires::SameNumberByACR(const bool report) nbEdges(i)++; } if (i == ideb) + { nbmin = nbEdges(i); + } if (nbmax < nbEdges(i)) + { nbmax = nbEdges(i); + } if (nbmin > nbEdges(i)) + { nbmin = nbEdges(i); + } } if (nbmax != nbmin) { @@ -1675,9 +1799,13 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) // point sections, blocking sections if (myDegen1) + { ideb++; + } if (myDegen2) + { ifin--; + } bool vClosed = (!myDegen1) && (!myDegen2) && (myWork(ideb).IsSame(myWork(ifin))); for (i = ideb; i <= ifin; i++) @@ -1689,7 +1817,9 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) TopoDS_Vertex V1, V2; TopExp::Vertices(TopoDS::Wire(myWork(i)), V1, V2); if (V1.IsSame(V2)) + { wClosed = true; + } } allClosed = (allClosed && wClosed); } @@ -1752,7 +1882,9 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) int nbs, NbSamples = 0; if (theLength <= 2) + { NbSamples = 4; + } gp_Pln FirstPlane; PlaneOfWire(TopoDS::Wire(myWork(ideb)), FirstPlane); gp_Pnt PrevBary = FirstPlane.Location(); @@ -1792,6 +1924,7 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) forward = true; } else + { for (j = 1; j <= theLength; j++) { // Forward @@ -1878,7 +2011,9 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) { int k_cur = k - 1; if (k_cur == 0) + { k_cur = theLength; + } const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n)); const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k_cur)); BRepAdaptor_Curve PrevEcurve(PrevEdge); @@ -1939,6 +2074,7 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) forward = false; } } + } PrevSeq.Clear(); PrevEseq.Clear(); @@ -1974,9 +2110,13 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) PrevEseq.Append(SeqEdges(j).Reversed()); } for (j = jmin; j >= 1; j--) + { PrevSeq.Append(SeqVertices(j)); + } for (j = theLength; j > jmin; j--) + { PrevSeq.Append(SeqVertices(j)); + } } newwire.Closed(true); @@ -2303,7 +2443,9 @@ void BRepFill_CompatibleWires::ComputeOrigin(const bool /*polar*/) // blocking sections ? if (vClosed) + { myWork(myWork.Length()) = myWork(1); + } } //================================================================================================= @@ -2322,9 +2464,13 @@ void BRepFill_CompatibleWires::SearchOrigin() bool allOpen = true; int ideb = 1, ifin = myWork.Length(); if (myDegen1) + { ideb++; + } if (myDegen2) + { ifin--; + } bool vClosed = (!myDegen1) && (!myDegen2) && (myWork(ideb).IsSame(myWork(ifin))); // for (int i=ideb; i<=ifin; i++) { @@ -2477,5 +2623,7 @@ void BRepFill_CompatibleWires::SearchOrigin() // blocking sections ? if (vClosed) + { myWork(myWork.Length()) = myWork(1); + } } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CurveConstraint.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CurveConstraint.cxx index 203f4ddb52..9c7db3cd12 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CurveConstraint.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_CurveConstraint.cxx @@ -46,13 +46,17 @@ BRepFill_CurveConstraint ::BRepFill_CurveConstraint( myLProp = SLP; myOrder = Tang; if ((Tang < -1) || (Tang > 2)) + { throw Standard_Failure("BRepFill : The continuity is not G0 G1 or G2"); + } myNbPoints = NPt; myConstG0 = true; myConstG1 = true; myConstG2 = true; if (myFrontiere.IsNull()) + { throw Standard_Failure("BRepFill_CurveConstraint : Curve must be on a Surface"); + } occ::handle Surf; occ::handle GS1; GS1 = occ::down_cast(myFrontiere->GetSurface()); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Draft.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Draft.cxx index f7f7e758e5..f648c8738b 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Draft.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Draft.cxx @@ -225,7 +225,9 @@ BRepFill_Draft::BRepFill_Draft(const TopoDS_Shape& S, const gp_Dir& Dir, const d { nbf = edgemap(iedge).Extent(); if (nbf == 1) + { List.Append(theEdge); + } } } @@ -265,7 +267,9 @@ BRepFill_Draft::BRepFill_Draft(const TopoDS_Shape& S, const gp_Dir& Dir, const d TopoDS_Vertex Vf, Vl; TopExp::Vertices(myWire, Vf, Vl); if (Vf.IsSame(Vl)) + { myWire.Closed(true); + } } myAngle = std::abs(Angle); @@ -439,7 +443,9 @@ void BRepFill_Draft::Init(const occ::handle&, const double Length, double ang = myDir.Angle(BN); if (ang > M_PI / 2) + { D.Reverse(); + } occ::handle L = new (Geom_Line)(P, D); occ::handle TC = new (Geom_TrimmedCurve)(L, 0, Length); @@ -494,7 +500,9 @@ void BRepFill_Draft::BuildShell(const occ::handle& Surf, const boo SF.D1(u, v, P, V1, V2); V = V1.Crossed(V2); if (F.Orientation() == TopAbs_REVERSED) + { V.Reverse(); + } if (V.Magnitude() > 1.e-10) { out = myDir.Angle(V) > M_PI / 2; @@ -584,15 +592,19 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) aPF.SetArguments(anArgs); aPF.Perform(); if (aPF.HasErrors()) + { return false; + } BRepAlgoAPI_Section aSec(Sol1, Sol2, aPF); const TopoDS_Shape& aSection = aSec.Shape(); TopExp_Explorer exp(aSection, TopAbs_EDGE); if (!exp.More()) + { // No section edges produced return false; + } if (StopShape.ShapeType() != TopAbs_SOLID) { @@ -617,7 +629,9 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) Dmin = D; aSEMin = TopoDS::Edge(aSE); if (Dmin < Precision::Confusion()) + { break; + } } } } @@ -650,9 +664,13 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) { // Subtract State1 if (myDir.Angle(SP.Normal()) < M_PI / 2) + { State1 = TopAbs_IN; + } else + { State1 = TopAbs_OUT; + } } } } @@ -660,9 +678,13 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) if (!KeepOutSide) { // Invert State2; if (State2 == TopAbs_IN) + { State2 = TopAbs_OUT; + } else + { State2 = TopAbs_IN; + } } // Perform Boolean operation @@ -671,7 +693,9 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) aBuilder.AddArgument(Sol2); aBuilder.PerformWithFiller(aPF); if (aBuilder.HasErrors()) + { return false; + } TopoDS_Shape result; occ::handle aHistory = new BRepTools_History; @@ -754,20 +778,26 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) aBuilder.BuildBOP(aLO, State1, aLT, State2, Message_ProgressRange()); if (aBuilder.HasErrors()) + { return false; + } aHistory->Merge(aBuilder.History()); result = aBuilder.Shape(); } if (issolid) + { myShape = result; + } else { TopExp_Explorer Exp; Exp.Init(result, TopAbs_SHELL); if (Exp.More()) + { myShape = Exp.Current(); + } } // Update the History @@ -776,13 +806,17 @@ bool BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape, const bool KeepOutSide) { const NCollection_List& L = aHistory->Modified(myFaces->Value(1, ii)); if (L.Extent() > 0) + { myFaces->SetValue(1, ii, L.First()); + } } for (ii = 1; ii <= myLoc->NbLaw() + 1; ii++) { const NCollection_List& L = aHistory->Modified(mySections->Value(1, ii)); if (L.Extent() > 0) + { mySections->SetValue(1, ii, L.First()); + } } return true; @@ -799,7 +833,9 @@ bool BRepFill_Draft::Sewing() ToAss = (myTop.ShapeType() != TopAbs_WIRE); if ((!ToAss) || (!myDone)) + { return false; + } // Assembly make a shell from the faces of the shape + the input shape occ::handle Ass = new BRepBuilderAPI_Sewing(5 * myTol, true, true, false); @@ -842,12 +878,16 @@ bool BRepFill_Draft::Sewing() for (ii = 1; ii <= myLoc->NbLaw(); ii++) { if (Ass->IsModified(myFaces->Value(1, ii))) + { myFaces->SetValue(1, ii, Ass->Modified(myFaces->Value(1, ii))); + } } for (ii = 1; ii <= myLoc->NbLaw() + 1; ii++) { if (Ass->IsModified(mySections->Value(1, ii))) + { mySections->SetValue(1, ii, Ass->Modified(mySections->Value(1, ii))); + } } if (myShape.Closed()) @@ -888,20 +928,24 @@ const NCollection_List& BRepFill_Draft::Generated(const TopoDS_Sha if (E.IsNull()) { for (ii = 0; ii <= myLoc->NbLaw(); ii++) + { if (E.IsSame(myLoc->Vertex(ii))) { myGenerated.Append(mySections->Value(1, ii + 1)); break; } + } } else { for (ii = 1; ii <= myLoc->NbLaw(); ii++) + { if (E.IsSame(myLoc->Edge(ii))) { myGenerated.Append(myFaces->Value(1, ii)); break; } + } } return myGenerated; diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Evolved.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Evolved.cxx index 844376ada6..d127ccd3c3 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Evolved.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Evolved.cxx @@ -230,7 +230,9 @@ static bool IsVertical(const TopoDS_Edge& E) double f, l; occ::handle GC = BRep_Tool::Curve(E, Loc, f, l); if (GC->DynamicType() == STANDARD_TYPE(Geom_Line)) + { return true; + } } return false; } @@ -251,7 +253,9 @@ static bool IsPlanar(const TopoDS_Edge& E) double f, l; occ::handle GC = BRep_Tool::Curve(E, Loc, f, l); if (GC->DynamicType() == STANDARD_TYPE(Geom_Line)) + { return true; + } } return false; } @@ -282,13 +286,21 @@ static int Side(const TopoDS_Wire& Profil, const double Tol) gp_Pnt P2 = BRep_Tool::Pnt(V2); if (P1.Y() < -Tol || P2.Y() < -Tol) + { TheSide = 4; + } else + { TheSide = 1; + } if (IsVertical(E)) + { TheSide += 2; + } else if (IsPlanar(E)) + { TheSide++; + } return TheSide; } @@ -371,11 +383,17 @@ void BRepFill_Evolved::PrivatePerform(const TopoDS_Face& Spine, { SP = TopoDS::Wire(WPIte.Value()); if (Side(SP, Tol) < 4) + { YaLeft = true; + } else + { YaRight = true; + } if (YaLeft && YaRight) + { break; + } } TopoDS_Face Face; @@ -490,7 +508,9 @@ void BRepFill_Evolved::PrivatePerform(const TopoDS_Face& Spine, } if (Solid) + { CutVevo.AddTopAndBottom(Glue); + } //------------------------------------------------------------------------- // Gluing of regularites on parallel edges generate4d by vertices of the @@ -513,7 +533,9 @@ void BRepFill_Evolved::PrivatePerform(const TopoDS_Face& Spine, // Orientation of the solid. if (Solid) + { MakeSolid(); + } // modified by NIZHNY-EAP Mon Jan 24 11:26:48 2000 ___BEGIN___ BRepLib::UpdateTolerances(myShape, false); @@ -531,7 +553,9 @@ static void IsInversed(const TopoDS_Shape& S, Inverse[0] = Inverse[1] = false; if (S.ShapeType() != TopAbs_EDGE) + { return; + } gp_Pnt P; gp_Vec DS, DC1, DC2; @@ -561,7 +585,9 @@ static void IsInversed(const TopoDS_Shape& S, Inverse[0] = (DS.Dot(DC1) < 0.); } else + { Inverse[0] = true; + } if (!BRep_Tool::Degenerated(E2)) { @@ -578,7 +604,9 @@ static void IsInversed(const TopoDS_Shape& S, Inverse[1] = (DS.Dot(DC2) < 0.); } else + { Inverse[1] = true; + } } //================================================================================================= @@ -600,7 +628,9 @@ static bool ConcaveSide(const TopoDS_Shape& S, const TopoDS_Face& F) { if (S.ShapeType() == TopAbs_VERTEX) + { return false; + } if (S.ShapeType() == TopAbs_EDGE) { @@ -613,7 +643,9 @@ static bool ConcaveSide(const TopoDS_Shape& S, const TopoDS_Face& F) { bool Direct = AC.Circle().IsDirect(); if (S.Orientation() == TopAbs_REVERSED) + { Direct = (!Direct); + } return Direct; } } @@ -762,9 +794,13 @@ void BRepFill_Evolved::ElementaryPerform(const TopoDS_Face& Sp, Inv0[0] = Inv0[1] = Inv1[0] = Inv1[1] = false; if (Concave0) + { IsInversed(S[0], E[0], E[1], Inv0); + } if (Concave1) + { IsInversed(S[1], E[2], E[3], Inv1); + } //--------------------------------------------- // Construction of geometries. @@ -881,13 +917,17 @@ void BRepFill_Evolved::ElementaryPerform(const TopoDS_Face& Sp, // Test if the Bissectrice is not projected on the face //------------------------------------------------------ if ((StartOnF == 0) && (EndOnF == 0) && VOnL.IsEmpty() && VOnF.IsEmpty()) + { // No trace of the bisectrice on the face. continue; + } if ((StartOnF == 0) && (EndOnF == 0) && (VOnL.Length() + VOnF.Length() == 1)) + { // the first or last node of the arc is on the edge // but the arc is not on the face. continue; + } //--------------------------------------------------------- // determine the intervals of the bissectrice that are @@ -990,9 +1030,13 @@ void BRepFill_Evolved::ElementaryPerform(const TopoDS_Face& Sp, { MapBis(E[k]).Append(VOnF.Value(ii)); if (k == 0) + { MapVerPar(E[k]).Append(ParOnF.Value(ii).Y()); + } else + { MapVerPar(E[k]).Append(ParOnF.Value(ii).Z()); + } } } } @@ -1013,9 +1057,13 @@ void BRepFill_Evolved::ElementaryPerform(const TopoDS_Face& Sp, { MapBis(E[k]).Append(VOnL.Value(ii)); if (k == 1) + { MapVerPar(E[k]).Append(ParOnL.Value(ii).Y()); + } else + { MapVerPar(E[k]).Append(ParOnL.Value(ii).Z()); + } } } } @@ -1272,16 +1320,22 @@ void BRepFill_Evolved::PlanarPerform(const TopoDS_Face& Sp, const TopoDS_Edge& WC = TopoDS::Edge(Exp.Current()); const TopoDS_Shape& GS = OffAnc.Ancestor(WC); if (!myMap.IsBound(GS)) + { myMap.Bind(GS, EmptyMap); + } if (!myMap(GS).IsBound(V[i])) + { myMap(GS).Bind(V[i], Paral.GeneratedShapes(GS)); + } } } TopoDS_Shape Rest = MapVP(V[i]); bool ToReverse = false; if ((IsMinV1 && (i == 1)) || (!IsMinV1 && (i == 0))) + { ToReverse = true; + } if (!Rest.IsNull()) { @@ -1294,7 +1348,9 @@ void BRepFill_Evolved::PlanarPerform(const TopoDS_Face& Sp, FR.Add(aWire); } else + { FR.Add(TopoDS::Wire(Rest)); + } } else { @@ -1309,7 +1365,9 @@ void BRepFill_Evolved::PlanarPerform(const TopoDS_Face& Sp, FR.Add(bWire); } else + { FR.Add(WCop); + } } } } @@ -1341,9 +1399,13 @@ void BRepFill_Evolved::PlanarPerform(const TopoDS_Face& Sp, { const TopoDS_Shape& InitE = OffAnc.Ancestor(CE); if (!myMap.IsBound(InitE)) + { myMap.Bind(InitE, EmptyMap); + } if (!myMap(InitE).IsBound(E)) + { myMap(InitE).Bind(E, EmptyList); + } myMap(InitE)(E).Append(F); } } @@ -1539,9 +1601,13 @@ void BRepFill_Evolved::PrepareProfile( MapProf.Bind(NE, E); EdgeVertices(NE, V1, V2); if (!MapProf.IsBound(V1)) + { MapProf.Bind(V1, E); + } if (!MapProf.IsBound(V2)) + { MapProf.Bind(V2, E); + } B.Add(W, NE); Cuts.RemoveFirst(); @@ -1694,9 +1760,13 @@ void BRepFill_Evolved::PrepareSpine( MapSpine.Bind(NE, E); EdgeVertices(NE, V1, V2); if (!MapSpine.IsBound(V1)) + { MapSpine.Bind(V1, E); + } if (!MapSpine.IsBound(V2)) + { MapSpine.Bind(V2, E); + } } } } @@ -1762,7 +1832,9 @@ static TopAbs_Orientation Compare(const TopoDS_Edge& E1, const TopoDS_Edge& E2) gp_Pnt P2 = BRep_Tool::Pnt(V2[0]); gp_Pnt P3 = BRep_Tool::Pnt(V2[1]); if (P1.Distance(P3) < P1.Distance(P2)) + { OO = TopAbs_REVERSED; + } return OO; } @@ -1785,7 +1857,9 @@ void BRepFill_Evolved::Add(BRepFill_Evolved& Vevo, const TopoDS_Wire& Prof, BRep TopoDS_Shape CurrentSpine, CurrentProf; if (Vevo.Shape().IsNull()) + { return; + } //------------------------------------------------- // Find wires common to and . @@ -1867,9 +1941,13 @@ void BRepFill_Evolved::Add(BRepFill_Evolved& Vevo, const TopoDS_Wire& Prof, BRep { // during Glue.Add the shared shapes are recreated. if (Glue.IsCopied(itl.Value())) + { myMap(CurrentSpine)(CurrentProf).Append(Glue.Copy(itl.Value())); + } else + { myMap(CurrentSpine)(CurrentProf).Append(itl.Value()); + } } } } @@ -2003,7 +2081,9 @@ void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue) TopoDS_Vertex V[2]; TopExp::Vertices(myProfile, V[0], V[1]); if (V[0].IsSame(V[1])) + { return; + } NCollection_List::Iterator itL; bool ToReverse = false; @@ -2048,7 +2128,9 @@ void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue) TopAbs_Orientation Or = ES.Orientation(); if (ToReverse) + { Or = TopAbs::Reverse(Or); + } TopoDS_Shape aLocalShape = E.Oriented(Or); Loop.AddConstEdge(TopoDS::Edge(aLocalShape)); // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or))); @@ -2091,7 +2173,9 @@ void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue) } TopAbs_Orientation Or = TopAbs_FORWARD; if (ToReverse) + { Or = TopAbs_REVERSED; + } TopoDS_Shape aLocalShape = E.Oriented(Or); Loop.AddConstEdge(TopoDS::Edge(aLocalShape)); // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or))); @@ -2117,15 +2201,23 @@ void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue) j++; Glue.Add(anIterL.Value()); if (j == 1 && i == 0) + { myTop = anIterL.Value(); + } if (j == 1 && i == 1) + { myBottom = anIterL.Value(); + } B.Add(Bouchon, anIterL.Value()); } if (i == 0 && j > 1) + { myTop = Bouchon; + } if (i == 1 && j > 1) + { myBottom = Bouchon; + } } } @@ -2324,11 +2416,15 @@ TopLoc_Location BRepFill_Evolved::FindLocation(const TopoDS_Face& Face) const L = FS.Location(); } else + { throw Standard_NoSuchObject("BRepFill_Evolved : The Face is not planar"); + } } if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } occ::handle P = occ::down_cast(S); gp_Ax3 Axis = P->Position(); @@ -2369,7 +2465,9 @@ void BRepFill_Evolved::ContinuityOnOffsetEdge(const NCollection_ListD1(First, P, D1); + } else + { C2d->D1(Last, P, D1); + } D1.Reverse(); } else { if (!AtStart) + { C2d->D1(Last, P, D1); + } else + { C2d->D1(First, P, D1); + } } gp_Pnt P3d(P.X(), P.Y(), 0.); gp_Vec V3d(D1.X(), D1.Y(), 0.); @@ -2877,10 +2991,14 @@ static TopAbs_Orientation Relative(const TopoDS_Wire& W1, TopoDS_Wire WW1 = BRepLib_MakeWire(E1); TopoDS_Wire WW2 = BRepLib_MakeWire(E2); double Tol = BRepFill_Confusion(); - if (Side(WW1, Tol) < 4 && Side(WW2, Tol) < 4) // two to the left + if (Side(WW1, Tol) < 4 && Side(WW2, Tol) < 4) + { // two to the left return TopAbs_FORWARD; - if (Side(WW1, Tol) > 4 && Side(WW2, Tol) > 4) // two to the right + } + if (Side(WW1, Tol) > 4 && Side(WW2, Tol) > 4) + { // two to the right return TopAbs_FORWARD; + } return TopAbs_REVERSED; } @@ -2899,19 +3017,27 @@ static TopAbs_Orientation Relative(const TopoDS_Wire& W1, int PosOnFace(double d1, double d2, double d3) { if (std::abs(d1 - d2) <= BRepFill_Confusion()) + { return 1; + } if (std::abs(d1 - d3) <= BRepFill_Confusion()) + { return 3; + } if (d2 < d3) { if (d1 > (d2 + BRepFill_Confusion()) && d1 < (d3 - BRepFill_Confusion())) + { return 2; + } } else { if (d1 > (d3 + BRepFill_Confusion()) && d1 < (d2 - BRepFill_Confusion())) + { return 2; + } } return 0; } @@ -2933,16 +3059,24 @@ bool DoubleOrNotInFace(const NCollection_Sequence& EC, const TopoD if (V1.IsSame(V)) { if (Vu) + { return true; + } else + { Vu = true; + } } if (V2.IsSame(V)) { if (Vu) + { return true; + } else + { Vu = true; + } } } return !Vu; @@ -3105,9 +3239,13 @@ void CutEdgeProf( TopoDS_Edge EE = BRepLib_MakeEdge(C, Vf, VV); EE.Orientation(E.Orientation()); if (EE.Orientation() == TopAbs_FORWARD) + { Cuts.Append(EE); + } else + { Cuts.Prepend(EE); + } // reinitialize CurParam = Param; @@ -3119,9 +3257,13 @@ void CutEdgeProf( TopoDS_Edge EE = BRepLib_MakeEdge(C, Vf, Vl); EE.Orientation(E.Orientation()); if (EE.Orientation() == TopAbs_FORWARD) + { Cuts.Append(EE); + } else + { Cuts.Prepend(EE); + } } //======================================================================= @@ -3266,11 +3408,17 @@ int VertexFromNode( Status = PosOnFace(aNode->Distance(), DistanceToOZ(VF), DistanceToOZ(VL)); } if (Status == 2) + { ShapeOnNode = E; + } else if (Status == 1) + { ShapeOnNode = VF; + } else if (Status == 3) + { ShapeOnNode = VL; + } if (!ShapeOnNode.IsNull()) { diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Filling.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Filling.cxx index 3d63785641..6aa7957205 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Filling.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Filling.cxx @@ -110,9 +110,13 @@ static TopoDS_Wire WireFromList(NCollection_List& Edges) V1 = V4; } else if (V1.IsSame(V4)) + { V1 = V3; + } else if (V2.IsSame(V3)) + { V2 = V4; + } else { anEdge.Reverse(); @@ -412,6 +416,7 @@ void BRepFill_Filling::BuildWires(NCollection_List& EdgeList, for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) + { if (V_wire[i].IsSame(V_edge[j])) { MW.Add(CurEdge); @@ -419,11 +424,16 @@ void BRepFill_Filling::BuildWires(NCollection_List& EdgeList, found = true; break; } + } if (found) + { break; + } } if (found) + { break; + } } if (!found) // try to find geometric coincidence { @@ -452,10 +462,14 @@ void BRepFill_Filling::BuildWires(NCollection_List& EdgeList, } } if (found) + { break; + } } if (found) + { break; + } } } if (!found) // end of current wire, begin next wire @@ -475,14 +489,18 @@ void BRepFill_Filling::FindExtremitiesOfHoles(const NCollection_List WireSeq; NCollection_List::Iterator Itl(WireList); for (; Itl.More(); Itl.Next()) + { WireSeq.Append(Itl.Value()); + } TopoDS_Wire theWire; theWire = TopoDS::Wire(WireSeq(1)); WireSeq.Remove(1); if (BRep_Tool::IsClosed(theWire)) + { return; + } TopoDS_Vertex Vfirst, Vlast; TopExp::Vertices(theWire, Vfirst, Vlast); @@ -577,7 +595,9 @@ void BRepFill_Filling::Build() // Building missing bounds NCollection_List EdgeList, WireList; for (i = 1; i <= myBoundary.Length(); i++) + { EdgeList.Append(myBoundary(i).myEdge); + } BuildWires(EdgeList, WireList); FindExtremitiesOfHoles(WireList, VerSeq); @@ -602,7 +622,9 @@ void BRepFill_Filling::Build() gp_Pnt FirstPnt = BRep_Tool::Pnt(FirstVtx); Projector.Init(FirstPnt, CurSurface); if (Projector.LowerDistance() > Precision::Confusion()) + { continue; + } Projector.LowerDistanceParameters(U1, V1); /* @@ -614,7 +636,9 @@ void BRepFill_Filling::Build() gp_Pnt LastPnt = BRep_Tool::Pnt(LastVtx); Projector.Init(LastPnt, CurSurface); if (Projector.LowerDistance() > Precision::Confusion()) + { continue; + } Projector.LowerDistanceParameters(U2, V2); /* @@ -701,7 +725,9 @@ void BRepFill_Filling::Build() TopoDS_Edge anEdge = InitEdge; anEdge.Orientation(TopAbs_FORWARD); if (myOldNewMap.IsBound(anEdge)) + { anEdge = TopoDS::Edge(myOldNewMap(anEdge)); + } occ::handle aCurveOnPlate = CurvesOnPlate->Value(i); @@ -711,7 +737,9 @@ void BRepFill_Filling::Build() TopExp::Vertices(anEdge, V1, V2); if (myOldNewMap.IsBound(V1)) + { NewV1 = TopoDS::Vertex(myOldNewMap(V1)); + } else { gp_Pnt aPnt = BRep_Tool::Pnt(V1); @@ -721,7 +749,9 @@ void BRepFill_Filling::Build() } if (myOldNewMap.IsBound(V2)) + { NewV2 = TopoDS::Vertex(myOldNewMap(V2)); + } else { gp_Pnt aPnt = BRep_Tool::Pnt(V2); @@ -770,7 +800,9 @@ const NCollection_List& BRepFill_Filling::Generated(const TopoDS_S myGenerated.Clear(); if (myOldNewMap.IsBound(S)) + { myGenerated.Append(myOldNewMap(S)); + } return myGenerated; } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Generator.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Generator.cxx index a9d96db9e0..04efdd417a 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Generator.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Generator.cxx @@ -309,7 +309,9 @@ int DetectKPart(const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2) else if (IType == -2) { if (AdC.GetType() == GeomAbs_Line) + { IType = 4; // plane + } else if (AdC.GetType() == GeomAbs_Circle) { // the only particular case with degenerated edge at the beginning the cone @@ -338,13 +340,17 @@ int DetectKPart(const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2) } } else + { IType = 0; + } } } } // torus and extrusion are not particular cases. if (IType == 3 || IType == 5) + { IType = 0; + } return IType; } @@ -447,10 +453,14 @@ bool CreateKPart(const TopoDS_Edge& Edge1, GeomAdaptor_Curve aC1Adaptor; if (!C1.IsNull()) + { aC1Adaptor.Load(C1); + } GeomAdaptor_Curve aC2Adaptor; if (!C2.IsNull()) + { aC2Adaptor.Load(C2); + } // calculate the surface occ::handle surface; @@ -712,21 +722,33 @@ void BRepFill_Generator::Perform() // ATTENTION : a non-punctual wire should not // contain a punctual edge if (!wPoint1) + { ex1.Next(); + } if (!wPoint2) + { ex2.Next(); + } // initialization of vertices occ::handle Surf; double f1 = 0, l1 = 1, f2 = 0, l2 = 1; if (Edge1.Orientation() == TopAbs_REVERSED) + { TopExp::Vertices(Edge1, V1l, V1f); + } else + { TopExp::Vertices(Edge1, V1f, V1l); + } if (Edge2.Orientation() == TopAbs_REVERSED) + { TopExp::Vertices(Edge2, V2l, V2f); + } else + { TopExp::Vertices(Edge2, V2f, V2l); + } if (degen1) { Vf_toMap = V2f; @@ -800,7 +822,9 @@ void BRepFill_Generator::Perform() C1 = occ::down_cast(C1->Copy()); } if (!SameLoc) + { C1->Transform(L1.Transformation()); + } if (Edge1.Orientation() == TopAbs_REVERSED) { C1->Reverse(); @@ -816,7 +840,9 @@ void BRepFill_Generator::Perform() C2 = occ::down_cast(C2->Copy()); } if (!SameLoc) + { C2->Transform(L2.Transformation()); + } if (Edge2.Orientation() == TopAbs_REVERSED) { C2->Reverse(); @@ -1096,9 +1122,13 @@ void BRepFill_Generator::Perform() tantque = ex1.More() && ex2.More(); if (wPoint1) + { tantque = ex2.More(); + } if (wPoint2) + { tantque = ex1.More(); + } } aFirstWire = false; } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_LocationLaw.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_LocationLaw.cxx index 2f407546df..216d768345 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_LocationLaw.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_LocationLaw.cxx @@ -53,11 +53,15 @@ static double Norm(const gp_Mat& M) Coord = M.Row(2); R = std::abs(Coord.X()) + std::abs(Coord.Y()) + std::abs(Coord.Z()); if (R > Norme) + { Norme = R; + } Coord = M.Row(3); R = std::abs(Coord.X()) + std::abs(Coord.Y()) + std::abs(Coord.Z()); if (R > Norme) + { Norme = R; + } return Norme; } @@ -88,9 +92,13 @@ void BRepFill_LocationLaw::Init(const TopoDS_Wire& Path) myTol = 1.e-4; for (NbEdge = 0, wexp.Init(myPath); wexp.More(); wexp.Next()) + { // if (! B.Degenerated(wexp.Current())) NbEdge++; if (!BRep_Tool::Degenerated(wexp.Current())) + { NbEdge++; + } + } myLaws = new (NCollection_HArray1>)(1, NbEdge); myLength = new (NCollection_HArray1)(1, NbEdge + 1); @@ -254,11 +262,15 @@ int BRepFill_LocationLaw::NbHoles(const double Tol) { myDisc = new (NCollection_HArray1)(1, NbDisc); for (ii = 1; ii <= NbDisc; ii++) + { myDisc->SetValue(ii, Seq(ii)); + } } } if (myDisc.IsNull()) + { return 0; + } return myDisc->Length(); } @@ -269,7 +281,9 @@ void BRepFill_LocationLaw::Holes(NCollection_Array1& Disc) const if (!myDisc.IsNull()) { for (int ii = 1; ii <= myDisc->Length(); ii++) + { Disc(ii) = myDisc->Value(ii); + } } } @@ -311,17 +325,25 @@ TopoDS_Vertex BRepFill_LocationLaw::Vertex(const int Index) const { E = TopoDS::Edge(myEdges->Value(Index)); if (E.Orientation() == TopAbs_REVERSED) + { V = TopExp::LastVertex(E); + } else + { V = TopExp::FirstVertex(E); + } } else if (Index == myEdges->Length() + 1) { E = TopoDS::Edge(myEdges->Value(Index - 1)); if (E.Orientation() == TopAbs_REVERSED) + { V = TopExp::FirstVertex(E); + } else + { V = TopExp::LastVertex(E); + } } return V; } @@ -356,9 +378,13 @@ void BRepFill_LocationLaw::PerformVertex(const int Index, { myLaws->Value(Index + 1)->GetDomain(First, Last); if (ILoc == 0) + { myLaws->Value(Index + 1)->D0(First, M2, V2); + } else + { myLaws->Value(Index + 1)->D0(First, M1, V1); + } } } @@ -390,9 +416,13 @@ void BRepFill_LocationLaw::PerformVertex(const int Index, { myLaws->Value(1)->GetDomain(First, Last); if (ILoc == 0) + { myLaws->Value(1)->D0(First, M2, V2); + } else + { myLaws->Value(1)->D0(First, M1, V1); + } } } } @@ -448,7 +478,9 @@ void BRepFill_LocationLaw::CurvilinearBounds(const int Index, double& First, dou bool BRepFill_LocationLaw::IsClosed() const { if (myPath.Closed()) + { return true; + } TopoDS_Vertex V1, V2; TopExp::Vertices(myPath, V1, V2); @@ -478,38 +510,56 @@ int BRepFill_LocationLaw::IsG1(const int Index, myLaws->Value(Index)->GetDomain(First, Last); Ok_D1 = myLaws->Value(Index)->D1(Last, M1, V1, DM1, DV1, Bid1, Bid2); if (!Ok_D1) + { myLaws->Value(Index)->D0(Last, M1, V1); + } myLaws->Value(Index + 1)->GetDomain(First, Last); if (Ok_D1) + { Ok_D1 = myLaws->Value(Index + 1)->D1(First, M2, V2, DM2, DV2, Bid1, Bid2); + } if (!Ok_D1) + { myLaws->Value(Index + 1)->D0(First, M2, V2); + } E = TopoDS::Edge(myEdges->Value(Index + 1)); } if (Index == 0 || Index == myLaws->Length()) { if (!myPath.Closed()) + { return -1; + } myLaws->Value(myLaws->Length())->GetDomain(First, Last); Ok_D1 = myLaws->Value(myLaws->Length())->D1(Last, M1, V1, DM1, DV1, Bid1, Bid2); if (!Ok_D1) + { myLaws->Value(myLaws->Length())->D0(Last, M1, V1); + } myLaws->Value(1)->GetDomain(First, Last); if (Ok_D1) + { myLaws->Value(1)->D1(First, M2, V2, DM2, DV2, Bid1, Bid2); + } if (!Ok_D1) + { myLaws->Value(1)->D0(First, M2, V2); + } E = TopoDS::Edge(myEdges->Value(1)); } if (E.Orientation() == TopAbs_REVERSED) + { V = TopExp::LastVertex(E); + } else + { V = TopExp::FirstVertex(E); + } TolEps += 2 * BRep_Tool::Tolerance(V); @@ -517,18 +567,28 @@ int BRepFill_LocationLaw::IsG1(const int Index, bool isG1 = true; if ((V1 - V2).Magnitude() > TolEps) + { isG0 = false; + } if (Norm(M1 - M2) > SpatialTolerance) + { isG0 = false; + } if (!isG0) + { return -1; + } if (!Ok_D1) + { return 0; // No control of the derivative + } if ((DV1.Magnitude() > EpsNul) && (DV2.Magnitude() > EpsNul) && (DV1.Angle(DV2) > AngularTolerance)) + { isG1 = false; + } // For the next, the tests are mostly empirical double Norm1 = Norm(DM1); @@ -542,16 +602,24 @@ int BRepFill_LocationLaw::IsG1(const int Index, DM1 /= Norm1; DM2 /= Norm2; if (Norm(DM1 - DM2) > AngularTolerance) + { isG1 = false; + } } else + { isG1 = false; // 1 Null the other is not + } } if (isG1) + { return 1; + } else + { return 0; + } } //================================================================================================= @@ -576,7 +644,9 @@ void BRepFill_LocationLaw::Parameter(const double Abcissa, int& Index, double& U Trouve = true; } else + { iedge++; + } } if (Trouve) diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_MultiLine.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_MultiLine.cxx index 2843fa96dc..fc24816b6b 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_MultiLine.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_MultiLine.cxx @@ -144,7 +144,9 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, occ::handle S; S = BRep_Tool::Surface(myFace1, L); if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } if (myIsoU1) { @@ -261,7 +263,9 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, S = BRep_Tool::Surface(myFace2, L); if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } if (myIsoU2) { @@ -362,16 +366,22 @@ BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1, if (myIsoU1) { if (std::abs(aPnt1.Y() - aPnt2.Y()) < eps) + { myKPart = 1; + } } else { if (std::abs(aPnt1.X() - aPnt2.X()) < eps) + { myKPart = 1; + } } if (myKPart == 1) + { myCont = GeomAbs_G1; + } if ((Type1 == GeomAbs_Plane) && (Type2 == GeomAbs_Plane)) { @@ -409,7 +419,9 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, TopLoc_Location L; occ::handle S = BRep_Tool::Surface(myFace1, L); if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } bool Sens; if (!myIsoU1) @@ -417,16 +429,24 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, Curve = S->UIso(PMil.X()); Sens = P1.Y() < P2.Y(); if (Sens) + { Curve = new Geom_TrimmedCurve(Curve, P1.Y(), P2.Y(), Sens); + } else + { Curve = new Geom_TrimmedCurve(Curve, P2.Y(), P1.Y(), Sens); + } f = Curve->FirstParameter(); l = Curve->LastParameter(); if (Sens) + { PCurve1 = new Geom2d_Line(gp_Pnt2d(PMil.X(), P1.Y() - f), gp::DY2d()); + } else + { PCurve1 = new Geom2d_Line(gp_Pnt2d(PMil.X(), P1.Y() + f), -gp::DY2d()); + } PCurve1 = new Geom2d_TrimmedCurve(PCurve1, f, l); } else @@ -434,16 +454,24 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, Curve = S->VIso(PMil.Y()); Sens = P1.X() < P2.X(); if (Sens) + { Curve = new Geom_TrimmedCurve(Curve, P1.X(), P2.X(), Sens); + } else + { Curve = new Geom_TrimmedCurve(Curve, P2.X(), P1.X(), Sens); + } f = Curve->FirstParameter(); l = Curve->LastParameter(); if (Sens) + { PCurve1 = new Geom2d_Line(gp_Pnt2d(P1.X() - f, PMil.Y()), gp::DX2d()); + } else + { PCurve1 = new Geom2d_Line(gp_Pnt2d(P1.X() + f, PMil.Y()), -gp::DX2d()); + } PCurve1 = new Geom2d_TrimmedCurve(PCurve1, f, l); } @@ -455,17 +483,25 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, { Sens = P1.Y() < P2.Y(); if (Sens) + { PCurve2 = new Geom2d_Line(gp_Pnt2d(PMil.X(), (P1.Y() - f)), gp::DY2d()); + } else + { PCurve2 = new Geom2d_Line(gp_Pnt2d(PMil.X(), (P1.Y() + f)), -gp::DY2d()); + } } else { Sens = P1.X() < P2.X(); if (Sens) + { PCurve2 = new Geom2d_Line(gp_Pnt2d(P1.X() - f, PMil.Y()), gp::DX2d()); + } else + { PCurve2 = new Geom2d_Line(gp_Pnt2d(P1.X() + f, PMil.Y()), -gp::DX2d()); + } } PCurve2 = new Geom2d_TrimmedCurve(PCurve2, f, l); } @@ -475,10 +511,14 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, occ::handle S = BRep_Tool::Surface(myFace1, L); if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { S = occ::down_cast(S)->BasisSurface(); + } occ::handle Plane = occ::down_cast(S); // eval the 3d curve corresponding to the bissectrice. @@ -495,9 +535,13 @@ void BRepFill_MultiLine::Curves(occ::handle& Curve, // eval PCurve2 S = BRep_Tool::Surface(myFace2, L); if (!L.IsIdentity()) + { S = occ::down_cast(S->Transformed(L.Transformation())); + } if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { S = occ::down_cast(S)->BasisSurface(); + } Plane = occ::down_cast(S); PCurve2 = GeomProjLib::Curve2d(Curve, Plane); } @@ -570,7 +614,9 @@ static gp_Pnt2d ValueOnFace(const double U, gp_Vec2d D12d = TheBis.DN(TheBis.FirstParameter(), 1); double Ang = Axis.Angle(D12d); if (!TheU.Circle().IsDirect()) + { Ang = -Ang; + } UU = ElCLib::InPeriod(Ang, TheU.FirstParameter(), TheU.FirstParameter() + 2 * M_PI); Dist = TheU.Circle().Radius(); } @@ -613,7 +659,9 @@ static gp_Pnt2d ValueOnFace(const double U, { // test if the curve is at the side `negative Y`. if (std::min(PF.Y(), PL.Y()) < -Tol) + { Dist = -Dist; + } occ::handle Line = new Geom2d_Line(gp_Pnt2d(0., Dist), gp::DX2d()); @@ -655,17 +703,25 @@ static gp_Pnt2d ValueOnFace(const double U, std::cout << " ---> ValueonFace failed at parameter U = " << U << std::endl; #endif if (std::abs(Dist - PL.Y()) < std::abs(Dist - PF.Y())) + { VV = TheV.LastParameter(); + } else + { VV = TheV.FirstParameter(); + } } } } if (IsIsoU) + { return gp_Pnt2d(VV, UU); + } else + { return gp_Pnt2d(UU, VV); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_NSections.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_NSections.cxx index be15049d46..9cab173929 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_NSections.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_NSections.cxx @@ -99,14 +99,20 @@ static occ::handle EdgeToBSpline(const TopoDS_Edge& theEdge) const occ::handle& aCurveTemp = aTrimCurve; // to avoid ambiguity GeomConvert_ApproxCurve anAppr(aCurveTemp, Precision::Confusion(), GeomAbs_C1, 16, 14); if (anAppr.HasResult()) + { aBSCurve = anAppr.Curve(); + } if (aBSCurve.IsNull()) + { aBSCurve = GeomConvert::CurveToBSplineCurve(aTrimCurve); + } // apply transformation if needed if (!aLoc.IsIdentity()) + { aBSCurve->Transform(aLoc.Transformation()); + } // reparameterize to [0,1] NCollection_Array1 aKnots(aBSCurve->Knots()); @@ -116,7 +122,9 @@ static occ::handle EdgeToBSpline(const TopoDS_Edge& theEdge) // reverse curve if edge is reversed if (theEdge.Orientation() == TopAbs_REVERSED) + { aBSCurve->Reverse(); + } return aBSCurve; } @@ -193,12 +201,18 @@ static occ::handle totalsurf(const NCollection_Array2 totalsurf(const NCollection_Array2 totalsurf(const NCollection_Array2 totalsurf(const NCollection_Array2& myDone = true; } else + { myDone = false; + } } //======================================================================= @@ -408,16 +436,24 @@ void BRepFill_NSections::Init(const NCollection_Sequence& P, const bool // Check if the start and end wires are punctual W = TopoDS::Wire(myShapes(1)); for (wexp.Init(W); wexp.More(); wexp.Next()) + { // w1Point = w1Point && B.Degenerated(wexp.Current()); w1Point = w1Point && BRep_Tool::Degenerated(wexp.Current()); + } if (w1Point) + { ideb++; + } W = TopoDS::Wire(myShapes(NbSects)); for (wexp.Init(W); wexp.More(); wexp.Next()) + { // w2Point = w2Point && B.Degenerated(wexp.Current()); w2Point = w2Point && BRep_Tool::Degenerated(wexp.Current()); + } if (w2Point) + { ifin--; + } // Check if the start and end wires are identical vclosed = myShapes(1).IsSame(myShapes(NbSects)); @@ -425,9 +461,13 @@ void BRepFill_NSections::Init(const NCollection_Sequence& P, const bool // Count the number of non-degenerated edges W = TopoDS::Wire(myShapes(ideb)); for (NbEdge = 0, wexp.Init(W); wexp.More(); wexp.Next()) + { // if (! B.Degenerated(wexp.Current())) NbEdge++; if (!BRep_Tool::Degenerated(wexp.Current())) + { NbEdge++; + } + } myEdges = new (NCollection_HArray2)(1, NbEdge, 1, NbSects); @@ -447,9 +487,13 @@ void BRepFill_NSections::Init(const NCollection_Sequence& P, const bool { myEdges->SetValue(ii, jj, E); if (E.Orientation() == TopAbs_FORWARD) + { myIndices.Bind(E, ii); + } else + { myIndices.Bind(E, -ii); + } } } @@ -496,7 +540,9 @@ void BRepFill_NSections::Init(const NCollection_Sequence& P, const bool } } if (!wClosed) + { uclosed = false; + } } // point sections at end @@ -658,7 +704,9 @@ double BRepFill_NSections::VertexTol(const int Index, const double Param) const if ((Index == 0) || (Index == myEdges->ColLength())) { if (!uclosed) + { return Tol; // The least possible error + } I1 = myEdges->ColLength(); I2 = 1; } @@ -718,7 +766,9 @@ occ::handle BRepFill_NSections::ConcatenedLaw() const { occ::handle Law; if (myLaws->Length() == 1) + { return myLaws->Value(1); + } else { double Ufirst, Ulast, Vfirst, Vlast; @@ -751,7 +801,9 @@ GeomAbs_Shape BRepFill_NSections::Continuity(const int Index, const double TolAn if ((Index == 0) || (Index == myEdges->ColLength())) { if (!uclosed) + { return GeomAbs_C0; // The least possible error + } Edge1 = TopoDS::Edge(myEdges->Value(myEdges->ColLength(), jj)); Edge2 = TopoDS::Edge(myEdges->Value(1, jj)); @@ -781,7 +833,9 @@ GeomAbs_Shape BRepFill_NSections::Continuity(const int Index, const double TolAn } if (BRep_Tool::Degenerated(Edge1) || BRep_Tool::Degenerated(Edge2)) + { cont_jj = GeomAbs_CN; + } else { double U1 = BRep_Tool::Parameter(V1, Edge1); @@ -793,9 +847,13 @@ GeomAbs_Shape BRepFill_NSections::Continuity(const int Index, const double TolAn } if (jj == 1) + { cont = cont_jj; + } if (cont > cont_jj) + { cont = cont_jj; + } } return cont; diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_OffsetWire.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_OffsetWire.cxx index 9619f8bcb5..d15528f651 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_OffsetWire.cxx @@ -237,21 +237,27 @@ static bool KPartCircle( if (AHC->GetType() == GeomAbs_Line) { if (E.Orientation() == TopAbs_FORWARD) + { anOffset *= -1; + } Adaptor2d_OffsetCurve Off(AHC, anOffset); OC = new Geom2d_Line(Off.Line()); } else if (AHC->GetType() == GeomAbs_Circle) { if (E.Orientation() == TopAbs_FORWARD) + { anOffset *= -1; + } if (!BRep_Tool::IsClosed(E)) { anOffset *= -1; } gp_Circ2d theCirc = AHC->Circle(); if (anOffset > 0. || std::abs(anOffset) < theCirc.Radius()) + { OC = new Geom2d_Circle(theCirc.Position(), theCirc.Radius() + anOffset); + } else { myIsDone = false; @@ -261,7 +267,9 @@ static bool KPartCircle( else { if (E.Orientation() == TopAbs_FORWARD) + { anOffset *= -1; + } occ::handle G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l); OC = new Geom2d_OffsetCurve(G2dT, anOffset); } @@ -342,7 +350,9 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, NCollection_IndexedDataMap> aMap; bool Done; if (KPartCircle(myWorkSpine, 1., myIsOpenResult, 0., aShape, aMap, Done)) + { return; + } //----------------------------------------------------- // Calculate the map of bissectors to the left. @@ -449,7 +459,9 @@ void BRepFill_OffsetWire::Perform(const double Offset, const double Alt) OCC_CATCH_SIGNALS myCallGen = false; if (KPartCircle(myWorkSpine, Offset, myIsOpenResult, Alt, myShape, myMap, myIsDone)) + { return; + } TopoDS_Face oldWorkSpain = myWorkSpine; @@ -520,9 +532,13 @@ void BRepFill_OffsetWire::Perform(const double Offset, const double Alt) TopoDS_Vertex NewV1, NewV2; EdgeVertices(NewEdge, NewV1, NewV2); if (!myMapSpine.IsBound(NewV1)) + { myMapSpine.Bind(NewV1, myMapSpine(anE)); + } if (!myMapSpine.IsBound(NewV2)) + { myMapSpine.Bind(NewV2, myMapSpine(anE)); + } } myMapSpine.UnBind(anE); } @@ -550,7 +566,9 @@ void BRepFill_OffsetWire::Perform(const double Offset, const double Alt) NCollection_DataMap, TopTools_ShapeMapHasher>:: Iterator itmap(wwmap); for (; itmap.More(); itmap.Next()) + { aSubst.Substitute(itmap.Key(), itmap.Value()); + } aSubst.Build(myWorkSpine); @@ -631,7 +649,9 @@ void Compute(const TopoDS_Face& B.MakeCompound(TopoDS::Compound(aShape)); double ALT = Alt; if (Spine.Orientation() == TopAbs_REVERSED) + { ALT = -Alt; + } gp_Trsf T; T.SetTranslation(gp_Vec(0., 0., ALT)); TopLoc_Location L(T); @@ -691,7 +711,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, // Calculate for a non null offset //******************************** if (KPartCircle(myWorkSpine, Offset, myIsOpenResult, Alt, myShape, myMap, myIsDone)) + { return; + } BRep_Builder myBuilder; @@ -721,7 +743,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, { double anAlt = Alt; if (myWorkSpine.Orientation() == TopAbs_REVERSED) + { anAlt = -Alt; + } RefPlane = occ::down_cast( RefPlane->Translated(anAlt * gp_Vec(RefPlane->Axis().Direction()))); } @@ -754,7 +778,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, if (SE.ShapeType() == TopAbs_VERTEX) { if (!SE.IsSame(Ends[0]) && !SE.IsSame(Ends[1])) + { MakeCircle(TopoDS::Edge(PE), TopoDS::Vertex(SE), myWorkSpine, myOffset, myMap, RefPlane); + } } else { @@ -779,7 +805,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, myMap.RemoveFromIndex(1); } if (!myMap.IsEmpty() && myMap.FindKey(myMap.Extent()).ShapeType() == TopAbs_VERTEX) + { myMap.RemoveLast(); + } } #ifdef OCCT_DEBUG @@ -831,7 +859,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, E[1] = TopoDS::Edge(myMap.FindFromKey(S[1]).First()); } else + { continue; + } //----------------------------------------------------------- // Construction of vertices corresponding to the node of the map. @@ -869,7 +899,9 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, } if (myJoinType == GeomAbs_Intersection) + { StartOnEdge = EndOnEdge = false; + } //--------------------------------------------- // Construction of geometries. @@ -901,22 +933,28 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, bool Start = true; Trim.AddOrConfuse(Start, E[0], E[1], Params); if (Params.Length() == Vertices.Length() && Params.Length() != 0) + { Vertices.SetValue(1, VS); - + } else + { // the point was not found by IntersectWith Vertices.Prepend(VS); + } } if (EndOnEdge) { bool Start = false; Trim.AddOrConfuse(Start, E[0], E[1], Params); if (Params.Length() == Vertices.Length() && Params.Length() != 0) + { Vertices.SetValue(Params.Length(), VE); - + } else + { // the point was not found by IntersectWith Vertices.Append(VE); + } } //------------------------------------------------------------ @@ -928,9 +966,13 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, // offset. //------------------------------------------------------------ if (!Detromp.IsBound(S[0])) + { Detromp.Bind(S[0], EmptyList); + } if (!Detromp.IsBound(S[1])) + { Detromp.Bind(S[1], EmptyList); + } UpdateDetromp(Detromp, S[0], S[1], Vertices, Params, Bisec, StartOnEdge, EndOnEdge, Trim); //---------------------------------------------- @@ -950,9 +992,13 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, { MapBis(E[k]).Append(Vertices.Value(ii)); if (k == 0) + { MapVerPar(E[k]).Append(Params.Value(ii).Y()); + } else + { MapVerPar(E[k]).Append(Params.Value(ii).Z()); + } } } } @@ -1005,9 +1051,13 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, if (myIsOpenResult) { if (j == 1) + { IndOfE = 1; + } else if (j == myMap.Extent()) + { IndOfE = -1; + } } TrimEdge(CurrentEdge, CurrentSpine, @@ -1110,18 +1160,24 @@ void BRepFill_OffsetWire::PerformWithBiLo(const TopoDS_Face& Spine, MapVertex.Add(V1); } else + { TV1->UpdateTolerance(1.5 * dist1); + } if (!MapVertex.Contains(V2)) { TV2->Pnt(l3d); MapVertex.Add(V2); } else + { TV2->UpdateTolerance(1.5 * dist2); + } } if (!myIsOpenResult) + { FixHoles(); + } myIsDone = true; } @@ -1165,8 +1221,10 @@ void BRepFill_OffsetWire::PrepareSpine() TopExp::MapShapes(IteF.Value(), TopAbs_EDGE, EdgeMap); int nbEdges = EdgeMap.Extent(); - if (nbEdges == 1 && !myIsOpenResult) // in case of open wire there's no need to do it + if (nbEdges == 1 && !myIsOpenResult) + { // in case of open wire there's no need to do it ForcedCut = 2; + } // Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End for (TopoDS_Iterator IteW(IteF.Value()); IteW.More(); IteW.Next()) @@ -1184,7 +1242,9 @@ void BRepFill_OffsetWire::PrepareSpine() occ::handle TEdge = occ::down_cast(E.TShape()); const int aNumCurvesInEdge = TEdge->Curves().Length(); if (nbEdges == 2 && nbResEdges == 0 && aNumCurvesInEdge > 1) + { ForcedCut = 1; + } // Modified by Sergey KHROMOV - Thu Nov 16 17:29:33 2000 End nbResEdges = CutEdge(TopoDS::Edge(aLocalShape), mySpine, ForcedCut, Cuts); @@ -1203,9 +1263,13 @@ void BRepFill_OffsetWire::PrepareSpine() myMapSpine.Bind(NE, E); EdgeVertices(NE, V1, V2); if (!myMapSpine.IsBound(V1)) + { myMapSpine.Bind(V1, E); + } if (!myMapSpine.IsBound(V2)) + { myMapSpine.Bind(V2, E); + } } } } @@ -1362,9 +1426,13 @@ void BRepFill_OffsetWire::MakeWires() const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); TopExp::Vertices(E, V1, V2); if (V1.IsSame(V2) && IsSmallClosedEdge(E, V1)) + { continue; // remove small closed edges + } if (!CheckSmallParamOnEdge(E)) + { continue; + } if (!MVE.Contains(V1)) { NCollection_List empty; @@ -1399,12 +1467,18 @@ void BRepFill_OffsetWire::MakeWires() // MVEit.Initialize(MVE); for (i = 1; i <= MVE.Extent(); i++) + { if (MVE(i).Extent() == 1) + { break; + } + } // if(!MVEit.More()) MVEit.Initialize(MVE); if (i > MVE.Extent()) + { i = 1; + } CV = VF = TopoDS::Vertex(MVE.FindKey(i)); CE = TopoDS::Edge(MVE(i).First()); @@ -1428,9 +1502,13 @@ void BRepFill_OffsetWire::MakeWires() //------------------------------- TopExp::Vertices(CE, V1, V2); if (!CV.IsSame(V1)) + { CV = V1; + } else + { CV = V2; + } B.Add(NW, CE); @@ -1462,8 +1540,10 @@ void BRepFill_OffsetWire::MakeWires() CE = TopoDS::Edge(MVE.FindFromKey(CV).First()); MVE.ChangeFromKey(CV).RemoveFirst(); } - else if (myIsOpenResult) // CV was a vertex with one edge + else if (myIsOpenResult) + { // CV was a vertex with one edge End = true; + } if (MVE.FindFromKey(CV).IsEmpty()) { @@ -1513,7 +1593,9 @@ void BRepFill_OffsetWire::FixHoles() const TopoDS_Vertex& aVertex = TopoDS::Vertex(Explo.Current()); double Tol = BRep_Tool::Tolerance(aVertex); if (Tol > MaxTol) + { MaxTol = Tol; + } } MaxTol *= 100.; @@ -1534,7 +1616,9 @@ void BRepFill_OffsetWire::FixHoles() EEmap.Bind(anEdge, LE); } else + { EEmap(anEdge).Append(anEdge); + } } aWire.Free(true); NCollection_DataMap, TopTools_ShapeMapHasher>:: @@ -1544,13 +1628,19 @@ void BRepFill_OffsetWire::FixHoles() const NCollection_List& LE = mapit.Value(); NCollection_List::Iterator itl(LE); for (; itl.More(); itl.Next()) + { BB.Remove(aWire, itl.Value()); + } } // Sorting if (aWire.Closed()) + { ClosedWires.Append(aWire); + } else + { UnclosedWires.Append(aWire); + } } while (!UnclosedWires.IsEmpty()) @@ -1612,9 +1702,13 @@ void BRepFill_OffsetWire::FixHoles() } } if (DistF > MaxTol) + { IndexF = 0; + } if (DistL > MaxTol) + { IndexL = 0; + } TopoDS_Wire theWire; TopoDS_Edge theEdge; TopoDS_Vertex theVertex; @@ -1651,9 +1745,13 @@ void BRepFill_OffsetWire::FixHoles() { TopoDS_Edge anEdge = TopoDS::Edge(it.Value()); if (IsFirstF) + { anEdge.Reverse(); + } if (!anEdge.IsSame(theEdge)) + { BB.Add(Base, anEdge); + } } theVertex = (IsFirstF) ? V1 : V2; CommonTol = std::max(BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex)); @@ -1665,13 +1763,17 @@ void BRepFill_OffsetWire::FixHoles() BB.Add(theEdge, Vf); BB.UpdateVertex(Vf, CommonTol); if (IsFirstF) + { theEdge.Reverse(); + } BB.Add(Base, theEdge); } else { if (IsFirstF) + { theEdge.Reverse(); + } BB.Add(Base, theEdge); // Creating new edge from theVertex to Vf TopoDS_Edge NewEdge = BRepLib_MakeEdge(theVertex, Vf); @@ -1695,9 +1797,13 @@ void BRepFill_OffsetWire::FixHoles() { TopoDS_Edge anEdge = TopoDS::Edge(it.Value()); if (!IsFirstL) + { anEdge.Reverse(); + } if (!anEdge.IsSame(theEdge)) + { BB.Add(Base, anEdge); + } } theVertex = (IsFirstL) ? V1 : V2; CommonTol = std::max(BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex)); @@ -1709,13 +1815,17 @@ void BRepFill_OffsetWire::FixHoles() BB.Add(theEdge, Vl); BB.UpdateVertex(Vl, CommonTol); if (!IsFirstL) + { theEdge.Reverse(); + } BB.Add(Base, theEdge); } else { if (!IsFirstL) + { theEdge.Reverse(); + } BB.Add(Base, theEdge); // Creating new edge from Vl to theVertex TopoDS_Edge NewEdge = BRepLib_MakeEdge(Vl, theVertex); @@ -1757,11 +1867,15 @@ void BRepFill_OffsetWire::FixHoles() } // Updating sequences ClosedWires and UnclosedWires if (DistF <= MaxTol) + { UnclosedWires.Remove(IndexF); + } if (DistL <= MaxTol && IndexL != IndexF) { if (DistF <= MaxTol && IndexL > IndexF) + { IndexL--; + } UnclosedWires.Remove(IndexL); } if (Base.Closed()) @@ -1780,9 +1894,13 @@ void BRepFill_OffsetWire::FixHoles() if (ClosedWires.Length() + IsolatedWires.Length() == 1) { if (!ClosedWires.IsEmpty()) + { myShape = ClosedWires.First(); + } else + { myShape = IsolatedWires.First(); + } } else { @@ -1790,9 +1908,13 @@ void BRepFill_OffsetWire::FixHoles() BB.MakeCompound(R); int i; for (i = 1; i <= ClosedWires.Length(); i++) + { BB.Add(R, ClosedWires(i)); + } for (i = 1; i <= IsolatedWires.Length(); i++) + { BB.Add(R, IsolatedWires(i)); + } myShape = R; } } @@ -1855,7 +1977,9 @@ int CutEdge(const TopoDS_Edge& E, else { for (int k = 1; k <= Cuter.NbCurves(); k++) + { theCurves.Append(Cuter.Value(k)); + } } } else if (ForceCut == 1) @@ -1867,8 +1991,10 @@ int CutEdge(const TopoDS_Edge& E, else { for (int k = 1; k <= Cuter.NbCurves(); k++) + { theCurves.Append(Cuter.Value(k)); + } } } else if (ForceCut == 2) @@ -1898,7 +2024,9 @@ int CutEdge(const TopoDS_Edge& E, else { for (int k = 1; k <= Cuter.NbCurves(); k++) + { theCurves.Append(Cuter.Value(k)); + } } } } @@ -1973,7 +2101,9 @@ void CutCurve(const occ::handle& C, if (UC - UF > PTol && PC.Distance(PF) > Tol) { if (UL - UC < PTol || PL.Distance(PC) < Tol) + { continue; + } TrimC = new Geom2d_TrimmedCurve(C, UF, UC); theCurves.Append(TrimC); @@ -1988,7 +2118,9 @@ void CutCurve(const occ::handle& C, theCurves.Append(TrimC); } else + { theCurves.Append(C); + } } // Modified by Sergey KHROMOV - Thu Nov 16 17:28:13 2000 End @@ -2014,7 +2146,9 @@ void MakeCircle(const TopoDS_Edge& DX.Reverse(); } else + { GC->D1(f, P, DX); + } gp_Ax2d Axis(P, gp_Dir2d(DX)); occ::handle Circ = new Geom2d_Circle(Axis, std::abs(Offset), Offset < 0.); @@ -2045,7 +2179,9 @@ void MakeOffset(const TopoDS_Edge& double anOffset = Offset; if (E.Orientation() == TopAbs_FORWARD) + { anOffset *= -1; + } occ::handle G2d = BRep_Tool::CurveOnSurface(E, F, f, l); occ::handle G2dOC; @@ -2057,9 +2193,13 @@ void MakeOffset(const TopoDS_Edge& TopoDS_Vertex V1, V2; TopExp::Vertices(E, V1, V2); if (V1.IsSame(Ends[0]) || V1.IsSame(Ends[1])) + { ToExtendFirstPar = false; + } if (V2.IsSame(Ends[0]) || V2.IsSame(Ends[1])) + { ToExtendLastPar = false; + } } Geom2dAdaptor_Curve AC(G2d, f, l); @@ -2085,9 +2225,13 @@ void MakeOffset(const TopoDS_Edge& if (theJoinType == GeomAbs_Arc) { if (ToExtendFirstPar) + { f -= 0.2 * Delta; + } if (ToExtendLastPar) + { l += 0.2 * Delta; + } } else // GeomAbs_Intersection { @@ -2119,16 +2263,24 @@ void MakeOffset(const TopoDS_Edge& if (ToExtendFirstPar) { if (theJoinType == GeomAbs_Arc) + { f -= Delta; - else // GeomAbs_Intersection + } + else + { // GeomAbs_Intersection f = -Precision::Infinite(); + } } if (ToExtendLastPar) { if (theJoinType == GeomAbs_Arc) + { l += Delta; - else // GeomAbs_Intersection + } + else + { // GeomAbs_Intersection l = Precision::Infinite(); + } } G2dOC = new Geom2d_TrimmedCurve(CC, f, l); } @@ -2184,7 +2336,9 @@ bool VertexFromNode(const occ::handle& aN Status = true; } else + { Status = false; + } return Status; } @@ -2200,14 +2354,22 @@ void StoreInMap( int i; if (MapVV.Contains(V2)) + { NewV = MapVV.FindFromKey(V2); + } if (MapVV.Contains(V1)) + { MapVV.ChangeFromKey(V1) = NewV; + } for (i = 1; i <= MapVV.Extent(); i++) + { if (MapVV(i).IsSame(V1)) + { MapVV(i) = NewV; + } + } MapVV.Add(V1, NewV); } @@ -2417,7 +2579,9 @@ static bool IsInnerEdge(const TopoDS_Shape& ProE, double& TrPar2) { if (ProE.ShapeType() != TopAbs_EDGE) + { return false; + } TopoDS_Edge anEdge = TopoDS::Edge(ProE); @@ -2428,7 +2592,9 @@ static bool IsInnerEdge(const TopoDS_Shape& ProE, { const NCollection_List& LE = VEmap(i); if (LE.Extent() == 1 && anEdge.IsSame(LE.First())) + { return false; + } } BRep_Tool::Range(anEdge, TrPar1, TrPar2); @@ -2450,9 +2616,13 @@ bool DoubleOrNotInside(const NCollection_List& LV, const TopoDS_Ve if (V.IsSame(it.Value())) { if (Vu) + { return true; + } else + { Vu = true; + } } } return !Vu; @@ -2526,7 +2696,9 @@ static void CheckBadEdges(const TopoDS_Face& Spine, bool reverse = false; if (E.Orientation() == TopAbs_FORWARD) + { reverse = true; + } gp_Pnt2d P, Pc; gp_Dir2d N; @@ -2550,7 +2722,9 @@ static void CheckBadEdges(const TopoDS_Face& Spine, double x = N.Y(), y = -N.X(); N.SetCoord(x, y); if (reverse) + { N.Reverse(); + } aCLProps.CentreOfCurvature(Pc); gp_Vec2d Dir(P, Pc); if (N.Dot(Dir) > 0.) @@ -2581,7 +2755,9 @@ static void CheckBadEdges(const TopoDS_Face& Spine, double x = N.Y(), y = -N.X(); N.SetCoord(x, y); if (reverse) + { N.Reverse(); + } aCLProps.CentreOfCurvature(Pc); gp_Vec2d Dir(P, Pc); if (N.Dot(Dir) > 0.) @@ -2756,7 +2932,9 @@ bool CheckSmallParamOnEdge(const TopoDS_Edge& anEdge) double f = (occ::down_cast(CRep))->First(); double l = (occ::down_cast(CRep))->Last(); if (std::abs(l - f) < Precision::PConfusion()) + { return false; + } } return true; } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Pipe.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Pipe.cxx index 135cc42956..b7726d639f 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Pipe.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Pipe.cxx @@ -86,7 +86,9 @@ static bool UpdateMap( } if (!found) + { aList.Append(theValue); + } return !found; } @@ -96,11 +98,15 @@ static void UpdateTolFromTopOrBottomPCurve(const TopoDS_Face& aFace, TopoDS_Edge double fpar, lpar; occ::handle aPCurve = BRep_Tool::CurveOnSurface(anEdge, aFace, fpar, lpar); if (aPCurve.IsNull()) + { return; + } occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); if (aCurve.IsNull()) + { return; + } occ::handle GAHC2d = new Geom2dAdaptor_Curve(aPCurve, fpar, lpar); occ::handle aSurf = BRep_Tool::Surface(aFace); @@ -119,7 +125,9 @@ static void UpdateTolFromTopOrBottomPCurve(const TopoDS_Face& aFace, TopoDS_Edge gp_Pnt prj = ConS.Value(par); double sqdist = pnt.SquareDistance(prj); if (sqdist > TolTol) + { TolTol = sqdist; + } } Tol = 1.00005 * std::sqrt(TolTol); if (Tol >= InitTol) @@ -163,11 +171,15 @@ BRepFill_Pipe::BRepFill_Pipe(const TopoDS_Wire& Spine, myMode = GeomFill_IsCorrectedFrenet; if (aMode == GeomFill_IsFrenet || aMode == GeomFill_IsCorrectedFrenet || aMode == GeomFill_IsDiscreteTrihedron) + { myMode = aMode; + } myContinuity = GeomAbs_C2; if (myMode == GeomFill_IsDiscreteTrihedron) + { myContinuity = GeomAbs_C0; + } myForceApproxC1 = ForceApproxC1; @@ -361,7 +373,9 @@ TopoDS_Face BRepFill_Pipe::Face(const TopoDS_Edge& ESpine, const TopoDS_Edge& EP TopoDS_Face theFace; if (BRep_Tool::Degenerated(EProfile)) + { return theFace; + } int ii, ispin = 0, iprof = 0, count = 0; @@ -371,18 +385,26 @@ TopoDS_Face BRepFill_Pipe::Face(const TopoDS_Edge& ESpine, const TopoDS_Edge& EP iprof = FindEdge(myProfile, EProfile, count); if (!iprof) + { throw Standard_DomainError("BRepFill_Pipe::Face : Edge not in the Profile"); + } // ************************************************* // Search if ESpine is an edge of mySpine and find // the index of the corresponding Filler // ************************************************* for (ii = 1; ii <= myLoc->NbLaw() && (!ispin); ii++) + { if (ESpine.IsSame(myLoc->Edge(ii))) + { ispin = ii; + } + } if (!ispin) + { throw Standard_DomainError("BRepFill_Pipe::Edge : Edge not in the Spine"); + } theFace = TopoDS::Face(myFaces->Value(iprof, ispin)); return theFace; @@ -399,7 +421,9 @@ TopoDS_Edge BRepFill_Pipe::Edge(const TopoDS_Edge& ESpine, const TopoDS_Vertex& // ************************************************* iprof = FindVertex(myProfile, VProfile, count); if (!iprof) + { throw Standard_DomainError("BRepFill_Pipe::Edge : Vertex not in the Profile"); + } // ************************************************* // Search if ESpine is an edge of mySpine and find @@ -407,11 +431,17 @@ TopoDS_Edge BRepFill_Pipe::Edge(const TopoDS_Edge& ESpine, const TopoDS_Vertex& // ************************************************* for (ii = 1; ii <= myLoc->NbLaw() && (!ispin); ii++) + { if (ESpine.IsSame(myLoc->Edge(ii))) + { ispin = ii; + } + } if (!ispin) + { throw Standard_DomainError("BRepFill_Pipe::Edge : Edge not in the Spine"); + } // ************************************************* // Generate the corresponding Shape @@ -439,17 +469,25 @@ TopoDS_Shape BRepFill_Pipe::Section(const TopoDS_Vertex& VSpine) const // iterate on all the edges of mySpine for (ii = 1; ii <= myLoc->NbLaw() + 1 && (!ispin); ii++) + { if (VSpine.IsSame(myLoc->Vertex(ii))) + { ispin = ii; + } + } if (!ispin) + { throw Standard_DomainError("BRepFill_Pipe::Section : Vertex not in the Spine"); + } BRep_Builder B; TopoDS_Compound Comp; B.MakeCompound(Comp); for (ii = 1; ii <= mySections->ColLength(); ii++) + { B.Add(Comp, mySections->Value(ii, ispin)); + } return Comp; } @@ -503,7 +541,9 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, TheFirst = FirstShape; TheLast = LastShape; if (!myFaces.IsNull()) + { InitialLength = myFaces->ColLength(); + } TopLoc_Location BackLoc(myTrsf.Inverted()); @@ -589,27 +629,43 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, TopoDS_Iterator itFirst, itLast; TopoDS_Shape first, last; if (!TheFirst.IsNull()) + { itFirst.Initialize(TheFirst); + } if (!TheLast.IsNull()) + { itLast.Initialize(TheLast); + } TopoDS_Iterator it(S); TopoDS_Iterator itorig(theOriginalS); for (; it.More(); it.Next(), itorig.Next()) { if (!TheFirst.IsNull()) + { first = itFirst.Value(); + } if (!TheLast.IsNull()) + { last = itLast.Value(); + } if (TheS.ShapeType() == TopAbs_FACE) + { MakeShape(it.Value(), itorig.Value(), first, last); + } else + { B.Add(result, MakeShape(it.Value(), itorig.Value(), first, last)); + } if (!TheFirst.IsNull()) + { itFirst.Next(); + } if (!TheLast.IsNull()) + { itLast.Next(); + } } } @@ -681,10 +737,14 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, for (jj = 1; jj <= myFaces->RowLength(); jj++) { for (ii = 1; ii <= myFaces->ColLength(); ii++) + { Somme->SetValue(ii, jj, myFaces->Value(ii, jj)); + } for (kk = 1, ii = myFaces->ColLength() + 1; kk <= Aux->ColLength(); kk++, ii++) + { Somme->SetValue(ii, jj, Aux->Value(kk, jj)); + } } myFaces = Somme; @@ -694,12 +754,16 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, for (jj = 1; jj <= mySections->RowLength(); jj++) { for (ii = 1; ii <= mySections->ColLength(); ii++) + { Somme->SetValue(ii, jj, mySections->Value(ii, jj)); + } myCurIndexOfSectionEdge = mySections->ColLength() + 1; for (kk = 1, ii = mySections->ColLength() + 1; kk <= Aux->ColLength(); kk++, ii++) + { Somme->SetValue(ii, jj, Aux->Value(kk, jj)); + } } mySections = Somme; @@ -709,10 +773,14 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, for (jj = 1; jj <= myEdges->RowLength(); jj++) { for (ii = 1; ii <= myEdges->ColLength(); ii++) + { Somme->SetValue(ii, jj, myEdges->Value(ii, jj)); + } for (kk = 1, ii = myEdges->ColLength() + 1; kk <= Aux->ColLength(); kk++, ii++) + { Somme->SetValue(ii, jj, Aux->Value(kk, jj)); + } } myEdges = Somme; @@ -742,7 +810,9 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S, { F = TopoDS::Face(myFaces->Value(ii, jj)); if (!F.IsNull()) + { B.Add(result, F); + } } } } @@ -798,7 +868,9 @@ int BRepFill_Pipe::FindEdge(const TopoDS_Shape& S, const TopoDS_Edge& E, int& In case TopAbs_EDGE: { InitialLength++; if (S.IsSame(E)) + { result = InitialLength; + } break; } @@ -809,7 +881,9 @@ int BRepFill_Pipe::FindEdge(const TopoDS_Shape& S, const TopoDS_Edge& E, int& In for (int ii = 1; (ii <= NbLaw) && (!result); ii++) { if (E.IsSame(Section->Edge(ii))) + { result = InitialLength + ii; + } } InitialLength += NbLaw; break; @@ -819,7 +893,9 @@ int BRepFill_Pipe::FindEdge(const TopoDS_Shape& S, const TopoDS_Edge& E, int& In case TopAbs_SHELL: case TopAbs_COMPOUND: { for (TopoDS_Iterator it(S); it.More() && (!result); it.Next()) + { result = FindEdge(it.Value(), E, InitialLength); + } break; } @@ -850,7 +926,9 @@ int BRepFill_Pipe::FindVertex(const TopoDS_Shape& S, case TopAbs_VERTEX: { InitialLength++; if (S.IsSame(V)) + { result = InitialLength; + } break; } @@ -865,9 +943,13 @@ int BRepFill_Pipe::FindVertex(const TopoDS_Shape& S, VL = aux; } if (VF.IsSame(V)) + { result = InitialLength + 1; + } else if (VL.IsSame(V)) + { result = InitialLength + 2; + } InitialLength += 2; break; } @@ -880,7 +962,9 @@ int BRepFill_Pipe::FindVertex(const TopoDS_Shape& S, for (; (ii <= InitialLength) && (!result); ii++) { if (V.IsSame(Section->Vertex(ii, 0.))) + { result = ii; + } } break; } @@ -889,7 +973,9 @@ int BRepFill_Pipe::FindVertex(const TopoDS_Shape& S, case TopAbs_SHELL: case TopAbs_COMPOUND: { for (TopoDS_Iterator it(S); it.More() && (!result); it.Next()) + { result = FindVertex(it.Value(), V, InitialLength); + } break; } @@ -921,14 +1007,20 @@ void BRepFill_Pipe::DefineRealSegmax() double first, last; occ::handle C = BRep_Tool::Curve(E, first, last); if (C.IsNull()) + { continue; + } while (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve) || C->DynamicType() == STANDARD_TYPE(Geom_OffsetCurve)) { if (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) + { C = occ::down_cast(C)->BasisCurve(); + } if (C->DynamicType() == STANDARD_TYPE(Geom_OffsetCurve)) + { C = occ::down_cast(C)->BasisCurve(); + } } if (C->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) { @@ -952,7 +1044,9 @@ void BRepFill_Pipe::DefineRealSegmax() } if (mySegmax < RealSegmax) + { mySegmax = RealSegmax; + } } //======================================================================= @@ -1020,9 +1114,13 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh inde++; const TopoDS_Edge& anEdge = TopoDS::Edge(wexp_sec.Current()); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } if (myGenMap.IsBound(anEdge)) + { continue; + } TopoDS_Vertex aVertex[2]; TopExp::Vertices(anEdge, aVertex[0], aVertex[1]); @@ -1049,7 +1147,9 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh for (int kk = 0; kk < 2; kk++) { if (myGenMap.IsBound(aVertex[kk])) + { continue; + } // Assemble the list of edges ("rail" along the path) NCollection_List* Elist = @@ -1059,7 +1159,9 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh { const TopoDS_Shape& anUedge = anUEdges->Value(UIndex[kk], jj); if (!anUedge.IsNull()) + { Elist->Append(anUedge); + } } } // for (int kk = 0; kk < 2; kk++) @@ -1067,7 +1169,9 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh myGenMap.Bound(anEdge, NCollection_List()); TopoDS_Iterator itsh(aTape); for (; itsh.More(); itsh.Next()) + { Flist->Append(itsh.Value()); + } } // for (inde = 0; wexp_sec.More(); wexp_sec.Next()) } // if (theSection.ShapeType() == TopAbs_WIRE) @@ -1081,7 +1185,9 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh for (;;) { if (!wexp.More()) + { ToExit = true; + } inde++; @@ -1103,9 +1209,13 @@ void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep, const TopoDS_Sh } if (ToExit) + { break; + } if (wexp.More()) + { wexp.Next(); + } } } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_PipeShell.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_PipeShell.cxx index 141b7aed4d..7fe332236c 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_PipeShell.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_PipeShell.cxx @@ -112,7 +112,9 @@ static bool ComputeSection(const TopoDS_Wire& W1, CW.SetPercent(0.1); CW.Perform(); if (!CW.IsDone()) + { throw StdFail_NotDone("Uncompatible wires"); + } NCollection_Sequence EmptyTrsfs; occ::handle SL = new (BRepFill_NSections)(CW.Shape(), EmptyTrsfs, SR, 0., 1.); double US = p1 / (p1 + p2); @@ -133,9 +135,13 @@ static void PerformTransition(const BRepFill_TransitionStyle Mode, { Loc->DeleteTransform(); if (Mode == BRepFill_Modified) + { Loc->TransformInG0Law(); + } else + { Loc->TransformInCompatibleLaw(angmin); + } } } @@ -152,7 +158,9 @@ static bool PerformPlan(TopoDS_Shape& S) { const TopoDS_Edge& anEdge = TopoDS::Edge(explo.Current()); if (!BRep_Tool::Degenerated(anEdge)) + { isDegen = false; + } } if (isDegen) { @@ -236,7 +244,9 @@ BRepFill_PipeShell::BRepFill_PipeShell(const TopoDS_Wire& Spine) TopoDS_Vertex Vf, Vl; TopExp::Vertices(mySpine, Vf, Vl); if (Vf.IsSame(Vl)) + { mySpine.Closed(true); + } } } @@ -340,7 +350,9 @@ void BRepFill_PipeShell::Set(const TopoDS_Wire& AuxiliarySpine, bool SpClose = mySpine.Closed(), GuideClose = AuxiliarySpine.Closed(); if (KeepContact == BRepFill_ContactOnBorder) + { myIsAutomaticLaw = true; + } if (!SpClose && !GuideClose) { @@ -353,7 +365,9 @@ void BRepFill_PipeShell::Set(const TopoDS_Wire& AuxiliarySpine, CW.SetPercent(0.1); CW.Perform(); if (!CW.IsDone()) + { throw StdFail_NotDone("Uncompatible wires"); + } TheGuide = TopoDS::Wire(CW.Shape().Value(2)); } else if (GuideClose) @@ -387,9 +401,13 @@ void BRepFill_PipeShell::Set(const TopoDS_Wire& AuxiliarySpine, if (CurvilinearEquivalence) { // trihedron by curvilinear reduced abscissa if (KeepContact == BRepFill_Contact || KeepContact == BRepFill_ContactOnBorder) + { myTrihedron = GeomFill_IsGuideACWithContact; // with rotation + } else + { myTrihedron = GeomFill_IsGuideAC; // without rotation + } occ::handle TLaw = new (GeomFill_GuideTrihedronAC)(Guide); occ::handle Loc = new (GeomFill_LocationGuide)(TLaw); @@ -398,9 +416,13 @@ void BRepFill_PipeShell::Set(const TopoDS_Wire& AuxiliarySpine, else { // trihedron by plane if (KeepContact == BRepFill_Contact || KeepContact == BRepFill_ContactOnBorder) + { myTrihedron = GeomFill_IsGuidePlanWithContact; // with rotation + } else + { myTrihedron = GeomFill_IsGuidePlan; // without rotation + } occ::handle TLaw = new (GeomFill_GuideTrihedronPlan)(Guide); occ::handle Loc = new (GeomFill_LocationGuide)(TLaw); @@ -576,7 +598,9 @@ void BRepFill_PipeShell::DeleteProfile(const TopoDS_Shape& Profile) } if (Trouve) + { mySection.Nullify(); + } ResetLoc(); } @@ -614,7 +638,9 @@ void BRepFill_PipeShell::SetTransition(const BRepFill_TransitionStyle Mode, const double Angmax) { if (myTransition != Mode) + { mySection.Nullify(); // It is required to relocalize the sections. + } myTransition = Mode; angmin = Angmin; angmax = Angmax; @@ -639,7 +665,9 @@ void BRepFill_PipeShell::Simulate(const int N, NCollection_List& L myLocation->CurvilinearBounds(NbL, First, Length); Delta = Length; if (N > 1) + { Delta /= (N - 1); + } myLocation->CurvilinearBounds(1, First, Last); // Initiation of Last for (U = 0.0, ii = 1; !Finis; U += Delta) @@ -652,11 +680,17 @@ void BRepFill_PipeShell::Simulate(const int N, NCollection_List& L else { if (ii < NbL) + { myLocation->CurvilinearBounds(NbL, First, Last); + } if (U > Last) + { U = (Last + First) / 2; // The edge is not skipped + } if (U > First) + { ii++; + } } US = FirstS + (U / Length) * DeltaS; // Calcul d'une section @@ -693,7 +727,9 @@ bool BRepFill_PipeShell::Build() if (mySection->IsVClosed() && myLocation->IsClosed()) { if (myLocation->IsG1(0) >= 0) + { myLast = myFirst; + } else { myFirst.Nullify(); @@ -712,7 +748,9 @@ bool BRepFill_PipeShell::Build() { BRepBuilderAPI_Copy copy(myLast); if (copy.IsDone()) + { myLast = copy.Shape(); + } } // eap 5 Jun 2002 occ332, end modif } @@ -726,7 +764,9 @@ bool BRepFill_PipeShell::Build() GeomAbs_Shape theContinuity = GeomAbs_C2; if (myTrihedron == GeomFill_IsDiscreteTrihedron) + { theContinuity = GeomAbs_C0; + } NCollection_Map Dummy; NCollection_DataMap>, @@ -780,7 +820,9 @@ bool BRepFill_PipeShell::Build() } if (DegenFirst && DegenLast) + { myShape.Closed(true); + } } if (myIsBuildHistory) @@ -795,7 +837,9 @@ bool BRepFill_PipeShell::Build() B.MakeShell(Sh); myShape = Sh; // Nullify if (myStatus == GeomFill_PipeOk) + { myStatus = GeomFill_PipeNotOk; + } } return Ok; } @@ -805,7 +849,9 @@ bool BRepFill_PipeShell::Build() bool BRepFill_PipeShell::MakeSolid() { if (myShape.IsNull()) + { throw StdFail_NotDone("PipeShell is not built"); + } bool B = myShape.Closed(); BRep_Builder BS; @@ -825,14 +871,22 @@ bool BRepFill_PipeShell::MakeSolid() if (B) { if (!myFirst.IsNull() && !IsSameOriented(myFirst, myShape)) + { myFirst.Reverse(); + } if (!myLast.IsNull() && !IsSameOriented(myLast, myShape)) + { myLast.Reverse(); + } if (!myFirst.IsNull()) + { BS.Add(myShape, TopoDS::Face(myFirst)); + } if (!myLast.IsNull()) + { BS.Add(myShape, TopoDS::Face(myLast)); + } myShape.Closed(true); } @@ -914,9 +968,13 @@ void BRepFill_PipeShell::Prepare() TopoDS_Wire theSect; if (!IsReady()) + { throw StdFail_NotDone("PipeShell"); + } if (!myLocation.IsNull() && !mySection.IsNull()) + { return; // It is ready + } // Check set of section for right configuration of punctual sections int i; @@ -930,19 +988,25 @@ void BRepFill_PipeShell::Prepare() wdeg = wdeg && (BRep_Tool::Degenerated(anEdge)); } if (wdeg) + { throw Standard_Failure("Wrong usage of punctual sections"); + } } if (mySeq.Length() <= 2) { bool wdeg = true; for (i = 1; i <= mySeq.Length(); i++) + { for (iter.Initialize(mySeq(i).Wire()); iter.More(); iter.Next()) { const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value()); wdeg = wdeg && (BRep_Tool::Degenerated(anEdge)); } + } if (wdeg) + { throw Standard_Failure("Wrong usage of punctual sections"); + } } // Construction of the law of location @@ -973,10 +1037,14 @@ void BRepFill_PipeShell::Prepare() Place(mySeq(1), theSect, aTrsf, p1); TopoDS_Wire aLocalShape = theSect; if (mySeq(1).IsLaw()) + { mySection = new BRepFill_ShapeLaw(aLocalShape, myLaw); - // mySection = new (BRepFill_ShapeLaw) (TopoDS_Wire(theSect), myLaw); + // mySection = new (BRepFill_ShapeLaw) (TopoDS_Wire(theSect), myLaw); + } else + { mySection = new BRepFill_ShapeLaw(aLocalShape); + } // mySection = new (BRepFill_ShapeLaw) (TopoDS::Wire(theSect)); WSeq.Append(theSect); @@ -1012,9 +1080,13 @@ void BRepFill_PipeShell::Prepare() WSeq.Append(theSect); Transformations.Append(aTrsf); if (param == V1) + { ideb = iseq; + } if (param == V2) + { ifin = iseq; + } } // looping sections ? @@ -1088,12 +1160,16 @@ void BRepFill_PipeShell::Prepare() } // Fill the array of real indices of sections for (int ii = 1; ii <= mySeq.Length(); ii++) + { for (int jj = 1; jj <= IndSec.Length(); jj++) + { if (IndSec(jj) == ii) { myIndOfSec.Append(jj); break; } + } + } // Calculate work sections NCollection_Sequence WorkingSections; @@ -1152,7 +1228,9 @@ void BRepFill_PipeShell::Prepare() myStatus = myLocation->GetStatus(); if (!mySection->IsDone()) + { myStatus = GeomFill_PipeNotOk; + } } //======================================================================= @@ -1224,13 +1302,19 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) NCollection_List* Elist = myGenMap.Bound(Section, NCollection_List()); for (int i = 1; i <= anUEdges->UpperRow(); i++) + { for (int j = 1; j <= anUEdges->UpperCol(); j++) + { Elist->Append(anUEdges->Value(i, j)); + } + } continue; } else + { aSection = TopoDS::Wire(Section); + } // Take the real index of section on the path int IndOfW = myIndOfSec(indw); const TopoDS_Wire& theWire = TopoDS::Wire(WSeq(IndOfW)); @@ -1240,7 +1324,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) const TopoDS_Edge& anOriginalEdge = TopoDS::Edge(wexp_sec.Current()); TopoDS_Edge anEdge = TopoDS::Edge(mySeq(indw).ModifiedShape(anOriginalEdge)); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } TopoDS_Shell aShell; BB.MakeShell(aShell); @@ -1256,9 +1342,13 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) { theEdge = TopoDS::Edge(wexp.Current()); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } if (i == inde) + { break; + } i++; } @@ -1279,7 +1369,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) TopoDS_Shape aTape = theSweep.Tape(anIndE); TopoDS_Iterator itsh(aTape); for (; itsh.More(); itsh.Next()) + { BB.Add(aShell, itsh.Value()); + } } // Processing of vertices of @@ -1297,9 +1389,13 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) if (mySection->IsUClosed()) { if (UIndex[0] > mySection->NbLaw()) + { UIndex[0] = 1; + } if (UIndex[1] > mySection->NbLaw()) + { UIndex[1] = 1; + } } // if (SignOfAnEdge * SignOfANewEdge == -1) if (SignOfAnEdge == -1 || SignOfANewEdge == -1) @@ -1317,14 +1413,18 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) for (int kk = 0; kk < 2; kk++) { if (myGenMap.IsBound(aVertex[kk])) + { continue; + } if (IndWireMap.IsBound(UIndex[kk])) { NCollection_List* Elist = myGenMap.Bound(aVertex[kk], NCollection_List()); for (itw.Initialize(IndWireMap(UIndex[kk])); itw.More(); itw.Next()) + { Elist->Append(itw.Value()); + } continue; } @@ -1333,7 +1433,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) NCollection_Sequence SeqEdges; int jj; for (jj = 1; jj <= anUEdges->UpperCol(); jj++) + { SeqEdges.Append(anUEdges->Value(UIndex[kk], jj)); + } // Assemble the wire ("rail" along the path) // checking for possible holes @@ -1344,7 +1446,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) BB.MakeWire(aWire); const TopoDS_Edge& FirstEdge = TopoDS::Edge(SeqEdges(1)); if (FirstEdge.IsNull()) + { continue; + } BB.Add(aWire, FirstEdge); TopoDS_Vertex FirstVertex, CurVertex; TopExp::Vertices(FirstEdge, FirstVertex, CurVertex); @@ -1355,7 +1459,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) TopoDS_Vertex Vfirst, Vlast; TopExp::Vertices(CurEdge, Vfirst, Vlast); if (CurVertex.IsSame(Vfirst)) + { CurVertex = Vlast; + } else // a hole { const NCollection_List& Elist = VEmap.FindFromKey(Vfirst); @@ -1364,7 +1470,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) { const TopoDS_Edge& Candidate = TopoDS::Edge(itl.Value()); if (Candidate.IsSame(CurEdge)) + { continue; + } TopoDS_Vertex V1, V2; TopExp::Vertices(Candidate, V1, V2); if (V1.IsSame(CurVertex) || V2.IsSame(CurVertex)) @@ -1386,7 +1494,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) { const TopoDS_Edge& Candidate = TopoDS::Edge(itl.Value()); if (Candidate.IsSame(CurEdge)) + { continue; + } TopoDS_Vertex V1, V2; TopExp::Vertices(Candidate, V1, V2); if (V1.IsSame(FirstVertex) || V2.IsSame(FirstVertex)) @@ -1401,7 +1511,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) myGenMap.Bound(aVertex[kk], NCollection_List()); for (itw.Initialize(aWire); itw.More(); itw.Next()) + { Elist->Append(itw.Value()); + } // Save already built wire with its index IndWireMap.Bind(UIndex[kk], aWire); @@ -1412,7 +1524,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) myGenMap.Bound(anOriginalEdge, NCollection_List()); TopoDS_Iterator itsh(aShell); for (; itsh.More(); itsh.Next()) + { Flist->Append(itsh.Value()); + } //////////////////////// inde++; @@ -1429,7 +1543,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) for (;;) { if (!wexp.More()) + { ToExit = true; + } inde++; @@ -1444,7 +1560,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) { const TopoDS_Shape& aFace = aFaces->Value(i, inde); if (aFace.ShapeType() == TopAbs_FACE) + { Flist->Append(aFace); + } } } @@ -1459,7 +1577,9 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) continue; } if (aVshape.ShapeType() == TopAbs_EDGE || aVshape.ShapeType() == TopAbs_FACE) + { ListVshapes->Append(aVshape); + } else { TopoDS_Iterator itvshape(aVshape); @@ -1467,22 +1587,30 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) { const TopoDS_Shape& aSubshape = itvshape.Value(); if (aSubshape.ShapeType() == TopAbs_EDGE || aSubshape.ShapeType() == TopAbs_FACE) + { ListVshapes->Append(aSubshape); + } else { // it is wire for (itw.Initialize(aSubshape); itw.More(); itw.Next()) + { ListVshapes->Append(itw.Value()); + } } } } } if (ToExit) + { break; + } if (wexp.More()) + { wexp.Next(); + } } } @@ -1523,7 +1651,9 @@ bool BuildBoundaries(const BRepFill_Sweep& theSweep, } if (!aBottomEdge.IsNull() && !aTopEdge.IsNull() && !aBottomEdge.IsSame(aTopEdge)) + { bAllSame = false; + } } if (theSection->IsUClosed()) @@ -1543,7 +1673,9 @@ bool BuildBoundaries(const BRepFill_Sweep& theSweep, } if (bAllSame && bfoundbottom && bfoundtop) + { theTop = theBottom; + } return bfoundbottom || bfoundtop; } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Section.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Section.cxx index 01e95bca43..0787414522 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Section.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Section.cxx @@ -50,7 +50,9 @@ BRepFill_Section::BRepFill_Section(const TopoDS_Shape& Profile, TopoDS_Shape aProfile = RemLoc.GetResult(); if (aProfile.ShapeType() == TopAbs_WIRE) + { wire = TopoDS::Wire(aProfile); + } else if (aProfile.ShapeType() == TopAbs_VERTEX) { ispunctual = true; @@ -68,7 +70,9 @@ BRepFill_Section::BRepFill_Section(const TopoDS_Shape& Profile, wire.Closed(true); } else + { throw Standard_Failure("BRepFill_Section: bad shape type of section"); + } } void BRepFill_Section::Set(const bool IsLaw) @@ -84,7 +88,9 @@ TopoDS_Shape BRepFill_Section::ModifiedShape(const TopoDS_Shape& theShape) const { case TopAbs_WIRE: if (theShape.IsSame(myOriginalShape)) + { aModifiedShape = wire; + } break; case TopAbs_EDGE: { TopoDS_Iterator itor(myOriginalShape); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionLaw.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionLaw.cxx index 9ba86e8647..f2eab0f17a 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionLaw.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionLaw.cxx @@ -104,6 +104,8 @@ TopoDS_Edge BRepFill_SectionLaw::CurrentEdge() } if (myIterator.More()) + { myIterator.Next(); + } return E; } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionPlacement.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionPlacement.cxx index c5b1a522cb..a52810ccb8 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionPlacement.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_SectionPlacement.cxx @@ -97,11 +97,15 @@ void BRepFill_SectionPlacement::Perform(const bool WithContact, { const TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current()); if (anEdge.IsNull() || BRep_Tool::Degenerated(anEdge)) + { continue; + } aCurve = BRep_Tool::Curve(anEdge, anEdgeStartParam, anEdgeEndParam); if (aCurve.IsNull()) + { continue; + } break; } @@ -130,11 +134,15 @@ void BRepFill_SectionPlacement::Perform(const bool WithContact, TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current()); // avoid null, degenerated edges if (anEdge.IsNull() || BRep_Tool::Degenerated(anEdge)) + { continue; + } aCurve = BRep_Tool::Curve(anEdge, anEdgeStartParam, anEdgeEndParam); if (aCurve.IsNull()) + { continue; + } TopoDS_Vertex aFirstVertex; TopoDS_Vertex aLastVertex; @@ -247,7 +255,9 @@ void BRepFill_SectionPlacement::Perform(const bool WithContact, else { if (aLawIndex1 == aLawIndex2) + { aVertex.Reverse(); + } aSectionPlacement.Perform(SearchParam(myLaw, aLawIndex2, aVertex), Precision::Confusion()); } if (aSectionPlacement.Angle() > Angle) diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ShapeLaw.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ShapeLaw.cxx index e883a1c2d4..8661a6c0bd 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ShapeLaw.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_ShapeLaw.cxx @@ -157,7 +157,9 @@ void BRepFill_ShapeLaw::Init(const bool Build) bool IsClosed = BRep_Tool::IsClosed(E); if (IsClosed && std::abs(C->FirstParameter() - First) > Precision::PConfusion()) + { IsClosed = false; // trimmed curve differs + } if ((ii > 1) || !IsClosed) { // Trim C @@ -249,17 +251,25 @@ TopoDS_Vertex BRepFill_ShapeLaw::Vertex(const int Index, const double Param) con { E = TopoDS::Edge(myEdges->Value(Index)); if (E.Orientation() == TopAbs_REVERSED) + { V = TopExp::LastVertex(E); + } else + { V = TopExp::FirstVertex(E); + } } else if (Index == myEdges->Length() + 1) { E = TopoDS::Edge(myEdges->Value(Index - 1)); if (E.Orientation() == TopAbs_REVERSED) + { V = TopExp::FirstVertex(E); + } else + { V = TopExp::LastVertex(E); + } } if (!TheLaw.IsNull()) @@ -284,7 +294,9 @@ double BRepFill_ShapeLaw::VertexTol(const int Index, const double Param) const if ((Index == 0) || (Index == myEdges->Length())) { if (!uclosed) + { return Tol; // The least possible error + } I1 = myEdges->Length(); I2 = 1; } @@ -344,7 +356,9 @@ occ::handle BRepFill_ShapeLaw::ConcatenedLaw() const { occ::handle Law; if (myLaws->Length() == 1) + { return myLaws->Value(1); + } else { TopoDS_Wire W; @@ -372,10 +386,14 @@ occ::handle BRepFill_ShapeLaw::ConcatenedLaw() const epsV = BRep_Tool::Tolerance(V); } else + { epsV = 10 * Precision::PConfusion(); + } Bof = Concat.Add(TC, epsV, true, false, 20); if (!Bof) + { Bof = Concat.Add(TC, 200 * epsV, true, false, 20); + } #ifdef OCCT_DEBUG if (!Bof) std::cout << "BRepFill_ShapeLaw::ConcatenedLaw INCOMPLET !!!" << std::endl; @@ -405,7 +423,9 @@ GeomAbs_Shape BRepFill_ShapeLaw::Continuity(const int Index, const double TolAng if ((Index == 0) || (Index == myEdges->Length())) { if (!uclosed) + { return GeomAbs_C0; // The least possible error + } Edge1 = TopoDS::Edge(myEdges->Value(myEdges->Length())); Edge2 = TopoDS::Edge(myEdges->Value(1)); diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Sweep.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Sweep.cxx index 22aca57911..58268e5723 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Sweep.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_Sweep.cxx @@ -105,8 +105,10 @@ static int NumberOfPoles(const TopoDS_Wire& W) double dfUf = c.FirstParameter(); double dfUl = c.LastParameter(); if (IsEqual(dfUf, dfUl)) + { // Degenerate continue; + } switch (c.GetType()) { @@ -115,7 +117,9 @@ static int NumberOfPoles(const TopoDS_Wire& W) occ::handle GC = c.Bezier(); int iNbPol = GC->NbPoles(); if (iNbPol >= 2) + { NbPoints += iNbPol; + } break; } case GeomAbs_BSplineCurve: { @@ -123,7 +127,9 @@ static int NumberOfPoles(const TopoDS_Wire& W) occ::handle GC = c.BSpline(); int iNbPol = GC->NbPoles(); if (iNbPol >= 2) + { NbPoints += iNbPol; + } break; } case GeomAbs_Line: { @@ -222,9 +228,13 @@ static occ::handle Couture(const TopoDS_Edge& E, { occ::handle GC(occ::down_cast(cr)); if (GC->IsCurveOnClosedSurface() && Eisreversed) + { return GC->PCurve2(); + } else + { return GC->PCurve(); + } } itcr.Next(); } @@ -322,7 +332,9 @@ static bool SameParameter(TopoDS_Edge& E, double ResTol; if (CheckSameParameter(HC3d, Pcurv, S, tol3d, tolreached)) + { return true; + } if (!HasPCurves(E)) { @@ -346,7 +358,9 @@ static bool SameParameter(TopoDS_Edge& E, const occ::handle& aHCurve = HC3d; // to avoid ambiguity Approx_SameParameter sp(aHCurve, Pcurv, S, tol3d); if (sp.IsDone() && !sp.IsSameParameter()) + { Pcurv = sp.Curve2d(); + } else if (!sp.IsDone() && !sp.IsSameParameter()) { #ifdef OCCT_DEBUG @@ -370,7 +384,9 @@ static bool SameParameter(TopoDS_Edge& E, { tolreached = 1.1 * ResTol; if (sp.IsDone() && !sp.IsSameParameter()) + { Pcurv = sp.Curve2d(); + } } return true; } @@ -380,7 +396,9 @@ static void CorrectSameParameter(TopoDS_Edge& theEdge, const TopoDS_Face& theFace2) { if (BRep_Tool::Degenerated(theEdge)) + { return; + } double fpar, lpar; occ::handle aCurve = BRep_Tool::Curve(theEdge, fpar, lpar); @@ -394,7 +412,9 @@ static void CorrectSameParameter(TopoDS_Edge& theEdge, BAcurve[0].Initialize(theEdge, theFace1); } if (!theFace1.IsNull() && theFace1.IsSame(theFace2)) + { theEdge.Reverse(); + } if (!theFace2.IsNull()) { PCurveExists[1] = true; @@ -410,13 +430,17 @@ static void CorrectSameParameter(TopoDS_Edge& theEdge, double aParam = fpar + i * delta; gp_Pnt aPnt = aCurve->Value(aParam); for (int j = 0; j < 2; j++) + { if (PCurveExists[j]) { gp_Pnt aPntFromFace = BAcurve[j].Value(aParam); double aSqDist = aPnt.SquareDistance(aPntFromFace); if (aSqDist > MaxSqDist) + { MaxSqDist = aSqDist; + } } + } } double aTol = sqrt(MaxSqDist); @@ -457,9 +481,13 @@ static void Oriente(const occ::handle& S, TopoDS_Edge& E) } if (!isfirst) + { E.Reverse(); + } if (isopposite) + { E.Reverse(); + } } // OCC500(apo)-> @@ -478,10 +506,14 @@ static void UpdateEdgeOnPlane(const TopoDS_Face& F, const TopoDS_Edge& E, const Tol *= 1.01; V = TopExp::FirstVertex(E); if (BRep_Tool::Tolerance(V) < Tol) + { BB.UpdateVertex(V, Tol); + } V = TopExp::LastVertex(E); if (BRep_Tool::Tolerance(V) < Tol) + { BB.UpdateVertex(V, Tol); + } } //<-OCC500(apo) @@ -569,7 +601,9 @@ static void BuildFace( Oriente(S, e1); // if (!IsPlan || !BT.Degenerated(e1)) if (!IsPlan || !BRep_Tool::Degenerated(e1)) + { B.Add(e1); + } e2 = E2; Oriente(S, e2); @@ -583,9 +617,13 @@ static void BuildFace( TopoDS_Shape NewEdge; // take the last edge added to WW for (Iter.Initialize(WW); Iter.More(); Iter.Next()) + { NewEdge = Iter.Value(); + } if (!e2.IsSame(NewEdge)) + { EEmap.Bind(e2, NewEdge); + } } } @@ -609,9 +647,13 @@ static void BuildFace( TopoDS_Shape NewEdge; // take the last edge added to WW for (Iter.Initialize(WW); Iter.More(); Iter.Next()) + { NewEdge = Iter.Value(); + } if (!E.IsSame(NewEdge)) + { EEmap.Bind(E, NewEdge); + } } } @@ -635,9 +677,13 @@ static void BuildFace( TopoDS_Shape NewEdge; // take the last edge added to WW for (Iter.Initialize(WW); Iter.More(); Iter.Next()) + { NewEdge = Iter.Value(); + } if (!E.IsSame(NewEdge)) + { EEmap.Bind(E, NewEdge); + } } } @@ -657,7 +703,9 @@ static void BuildFace( NS = DU ^ DV; NP = thePlane->Pln().Axis().Direction(); if (NS.Dot(NP) < 0.) + { thePlane->UReverse(); + } BRepLib_MakeFace MkF(thePlane, WW); if (MkF.Error() != BRepLib_FaceDone) { @@ -704,9 +752,13 @@ static void BuildFace( // Reorientation if (ExchUV) + { F.Reverse(); + } if (UReverse) + { F.Reverse(); + } } //================================================================================================= @@ -745,12 +797,16 @@ static TopoDS_Edge BuildEdge(occ::handle& C3d, S->D0(P2d.X(), P2d.Y(), P); d = P1.Distance(P); if (d > Tol) + { Tol = d; + } C2d->D0(l, P2d); S->D0(P2d.X(), P2d.Y(), P); d = P2.Distance(P); if (d > Tol) + { Tol = d; + } B.UpdateVertex(VF, Tol); B.UpdateVertex(VL, Tol); @@ -768,12 +824,16 @@ static TopoDS_Edge BuildEdge(occ::handle& C3d, C3d->D0(f, P); d = P1.Distance(P); if (d > Tol1) + { B.UpdateVertex(VF, d); + } C3d->D0(l, P); d = P2.Distance(P); if (d > Tol2) + { B.UpdateVertex(VL, d); + } BRepLib_MakeEdge MkE(C3d, VF, VL, f, l); if (!MkE.IsDone()) @@ -1201,15 +1261,23 @@ static bool Filling(const TopoDS_Shape& // Render the calculated borders. // if (!BT.Degenerated(E3)) if (!BRep_Tool::Degenerated(E3)) + { Aux1 = E3; + } else + { B.MakeEdge(Aux1); // Nullify + } // if (!BT.Degenerated(E4)) if (!BRep_Tool::Degenerated(E4)) + { Aux2 = E4; + } else + { B.MakeEdge(Aux2); + } // Set the orientation @@ -1225,7 +1293,9 @@ static bool Filling(const TopoDS_Shape& N1 = D1U ^ D1V; if (N1.SquareMagnitude() < Precision::SquareConfusion()) + { continue; + } // C1 = BT.CurveOnSurface(E1, TopoDS::Face(F1), f2, l2); C1 = BRep_Tool::CurveOnSurface(E1, TopoDS::Face(F1), f2, l2); @@ -1235,7 +1305,9 @@ static bool Filling(const TopoDS_Shape& N2 = D1U ^ D1V; if (N2.SquareMagnitude() < Precision::SquareConfusion()) + { continue; + } Angle = N1.Angle(N2); @@ -1243,15 +1315,23 @@ static bool Filling(const TopoDS_Shape& } if (Angle == RealFirst()) + { return false; + } if ((F1.Orientation() == TopAbs_REVERSED) ^ (Angle > M_PI / 2)) + { Result.Orientation(TopAbs_REVERSED); + } else + { Result.Orientation(TopAbs_FORWARD); + } if (ToReverseResult) + { Result.Reverse(); + } return true; } @@ -1367,9 +1447,13 @@ static void BuildVertex(const occ::handle& Iso, double val; if (isfirst) + { val = First; + } else + { val = Last; + } B.MakeVertex(TopoDS::Vertex(Vertex), Iso->Value(val), Precision::Confusion()); } @@ -1418,7 +1502,9 @@ static TopoDS_Edge BuildEdge(const occ::handle& S, // double tol = BT.Tolerance(V); double tol = BRep_Tool::Tolerance(V); if (Tol > tol) + { tol = Tol; + } Iso->D0((Iso->FirstParameter() + Iso->LastParameter()) / 2, P); // if (P.Distance(BT.Pnt(V)) < tol) { if (P.Distance(BRep_Tool::Pnt(V)) < tol) @@ -1462,22 +1548,32 @@ static TopoDS_Edge BuildEdge(const occ::handle& S, p21 = P2.Distance(BRep_Tool::Pnt(TopoDS::Vertex(VFirst))); if (p11 < p12 && p22 < p21) + { fwd = true; + } if (fwd) { // OCC500(apo) if (p11 >= t1) + { BB.UpdateVertex(TopoDS::Vertex(VFirst), 1.01 * p11); + } if (p22 >= t2) + { BB.UpdateVertex(TopoDS::Vertex(VLast), 1.01 * p22); + } } else { // Iso = S->VIso(ValIso); if (p12 >= t2) + { BB.UpdateVertex(TopoDS::Vertex(VLast), 1.01 * p12); + } if (p21 >= t1) + { BB.UpdateVertex(TopoDS::Vertex(VFirst), 1.01 * p21); + } } BRepLib_MakeEdge MkE; @@ -1488,17 +1584,21 @@ static TopoDS_Edge BuildEdge(const occ::handle& S, // Iso->FirstParameter(), // Iso->LastParameter()); if (fwd) + { MkE.Init(Iso, TopoDS::Vertex(VFirst), TopoDS::Vertex(VLast), Iso->FirstParameter(), Iso->LastParameter()); + } else + { MkE.Init(Iso, TopoDS::Vertex(VLast), TopoDS::Vertex(VFirst), Iso->FirstParameter(), Iso->LastParameter()); + } // if (!MkE.IsDone()) { // Il faut peut etre permuter les Vertex // MkE.Init(Iso, @@ -1538,7 +1638,9 @@ static TopoDS_Edge BuildEdge(const occ::handle& S, B.UpdateEdge(E, L, S, Loc, Precision::Confusion()); if (sing) + { B.Range(E, S, Loc, Iso->FirstParameter(), Iso->LastParameter()); + } double MaxTol = 1.e-4; double theTol; @@ -1692,21 +1794,29 @@ static void UpdateEdge(TopoDS_Edge& E, PCurve = Couture(E, S, Loc); if (PCurve.IsNull()) + { B.UpdateEdge(E, CL, S, Loc, Precision::Confusion()); + } else { // Sewing edge TopoDS_Edge e = E; Oriente(S, e); if (e.Orientation() == TopAbs_REVERSED) + { B.UpdateEdge(E, CL, PCurve, S, Loc, Precision::Confusion()); + } else + { B.UpdateEdge(E, PCurve, CL, S, Loc, Precision::Confusion()); + } } // Attention to case not SameRange on its shapes (PRO13551) // if (!BT.SameRange(E)) B.Range(E, S, Loc, First, Last); if (!BRep_Tool::SameRange(E)) + { B.Range(E, S, Loc, First, Last); + } } //======================================================================= @@ -1741,7 +1851,9 @@ static bool IsDegen(const occ::handle& S, const double Tol) } if (B) + { return true; + } // Check the length of Iso-V t = (Vmin + Vmax) / 2; @@ -1792,25 +1904,33 @@ static void ReverseModifiedEdges( const NCollection_Map& theEmap) { if (theEmap.IsEmpty()) + { return; + } TopoDS_Iterator itw(theWire); BRep_Builder BB; NCollection_List Ledges; for (; itw.More(); itw.Next()) + { Ledges.Append(itw.Value()); + } theWire.Free(true); NCollection_List::Iterator itl(Ledges); for (; itl.More(); itl.Next()) + { BB.Remove(theWire, itl.Value()); + } for (itl.Initialize(Ledges); itl.More(); itl.Next()) { TopoDS_Shape anEdge = itl.Value(); if (theEmap.Contains(anEdge)) + { anEdge.Reverse(); + } BB.Add(theWire, anEdge); } } @@ -1934,14 +2054,20 @@ bool BRepFill_Sweep::CorrectApproxParameters() GeomAbs_Shape aContinuity = aBAcurve.Continuity(); int aNbInterv = aBAcurve.NbIntervals(GeomAbs_CN); if (aContinuity < NewCont) + { NewCont = aContinuity; + } if (aNbInterv > NewSegmax) + { NewSegmax = aNbInterv; + } } bool Corrected = false; if (NewCont != myContinuity || NewSegmax != mySegmax) + { Corrected = true; + } myContinuity = NewCont; mySegmax = NewSegmax; return Corrected; @@ -1985,27 +2111,39 @@ bool BRepFill_Sweep::BuildWire(const BRepFill_TransitionStyle /*Transition*/) Sweep.SetForceApproxC1(myForceApproxC1); Sweep.Build(mySec->Law(isec), myApproxStyle, myContinuity, myDegmax, mySegmax); if (!Sweep.IsDone()) + { return false; + } S = Sweep.Surface(); if (Sweep.ExchangeUV()) { if (Sweep.UReversed()) + { S->Bounds(First, Last, bid, val); + } else + { S->Bounds(First, Last, val, bid); + } Iso = S->VIso(val); } else { if (Sweep.UReversed()) + { S->Bounds(bid, val, First, Last); + } else + { S->Bounds(val, bid, First, Last); + } Iso = S->UIso(val); } // Vertex by position if (ipath < NbPath) + { BuildVertex(Iso, false, First, Last, myVEdges->ChangeValue(1, ipath + 1)); + } else { if (vclose) @@ -2020,9 +2158,13 @@ bool BRepFill_Sweep::BuildWire(const BRepFill_TransitionStyle /*Transition*/) else { if (!LastShape.IsNull()) + { myVEdges->SetValue(1, NbPath, FirstShape); + } else + { BuildVertex(Iso, false, First, Last, myVEdges->ChangeValue(1, NbPath + 1)); + } } } @@ -2037,9 +2179,13 @@ bool BRepFill_Sweep::BuildWire(const BRepFill_TransitionStyle /*Transition*/) if (ipath == 1) { if (!FirstShape.IsNull()) + { myVEdges->SetValue(1, 1, FirstShape); + } else + { BuildVertex(Iso, true, First, Last, myVEdges->ChangeValue(1, 1)); + } } // Construction of the edge @@ -2126,7 +2272,9 @@ bool BRepFill_Sweep::BuildShell( Vi(1) = SecDeb + (Ll / Length) * SecDom; } else + { Vi(1) = SecDeb; + } // Error a priori on vertices if (constSection) @@ -2167,13 +2315,17 @@ bool BRepFill_Sweep::BuildShell( { Sweep.Build(mySec->Law(isec), myApproxStyle, myContinuity, myDegmax, mySegmax); if (!Sweep.IsDone()) + { return false; + } TabS(isec, ipath) = Sweep.Surface(); TabErr(isec, ipath) = Sweep.ErrorOnSurface(); ExchUV(isec, ipath) = Sweep.ExchangeUV(); UReverse(isec, ipath) = Sweep.UReversed(); if (Sweep.ErrorOnSurface() > Error) + { Error = Sweep.ErrorOnSurface(); + } if ((ipath == 1) && (ExtendFirst > 0)) { @@ -2216,9 +2368,13 @@ bool BRepFill_Sweep::BuildShell( TopExp::Vertices(E, Vfirst, Vlast); VEdge(isec, 1) = E; if (E.Orientation() == TopAbs_REVERSED) + { Vertex(isec + 1, 1) = Vfirst; // TopExp::FirstVertex(E); + } else + { Vertex(isec + 1, 1) = Vlast; // TopExp::LastVertex(E); + } UpdateVertex(IFirst - 1, isec + 1, TabErr(isec, 1), Vi(1), Vertex(isec + 1, 1)); StartEdges(isec) = E; @@ -2235,29 +2391,47 @@ bool BRepFill_Sweep::BuildShell( } int ifirst = isec + 1, ilast = isec; // direction of round is reversed for (j = 1; j <= NbPath; j++) + { UEdge(ifirst, j) = Tapes(E)->Value(2, j); + } for (j = 1; j <= NbPath; j++) + { UEdge(ilast, j) = Tapes(E)->Value(3, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(ifirst, j) = Tapes(E)->Value(4, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(ilast, j) = Tapes(E)->Value(5, j); + } for (j = 1; j <= NbPath; j++) + { myFaces->SetValue(isec, j, Tapes(E)->Value(6, j)); + } if (uclose && isec == 1) { for (j = 1; j <= NbPath; j++) + { UEdge(NbLaw + 1, j) = UEdge(1, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(NbLaw + 1, j) = Vertex(1, j); + } } if (uclose && isec == NbLaw) { for (j = 1; j <= NbPath; j++) + { UEdge(1, j) = UEdge(NbLaw + 1, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(1, j) = Vertex(NbLaw + 1, j); + } } } else @@ -2270,25 +2444,37 @@ bool BRepFill_Sweep::BuildShell( { int ind = (E.Orientation() == TopAbs_REVERSED) ? isec + 1 : isec; for (j = 1; j <= NbPath; j++) + { UEdge(ind, j) = Rails(Vfirst)->Value(1, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(ind, j) = Rails(Vfirst)->Value(2, j); + } } if (Rails.IsBound(Vlast)) { int ind = (E.Orientation() == TopAbs_FORWARD) ? isec + 1 : isec; for (j = 1; j <= NbPath; j++) + { UEdge(ind, j) = Rails(Vlast)->Value(1, j); + } for (j = 1; j <= NbPath + 1; j++) + { Vertex(ind, j) = Rails(Vlast)->Value(2, j); + } } } } if (VEdge(1, 1).Orientation() == TopAbs_REVERSED) + { Vertex(1, 1) = TopExp::LastVertex(TopoDS::Edge(VEdge(1, 1))); + } else + { Vertex(1, 1) = TopExp::FirstVertex(TopoDS::Edge(VEdge(1, 1))); + } UpdateVertex(IFirst - 1, 1, TabErr(1, 1), Vi(1), Vertex(1, 1)); } @@ -2348,9 +2534,11 @@ bool BRepFill_Sweep::BuildShell( // construction of vertices if (Vertex(isec, 1).IsNull()) + { B.MakeVertex(TopoDS::Vertex(Vertex(isec, 1)), S->Value(u, v), mySec->VertexTol(isec - 1, Vi(1))); + } else { TopLoc_Location Identity; @@ -2368,14 +2556,20 @@ bool BRepFill_Sweep::BuildShell( { E = mySec->CurrentEdge(); if (VEdge(isec, NbPath + 1).IsNull()) + { VEdge(isec, NbPath + 1) = E; + } if (Vertex(isec + 1, NbPath + 1).IsNull()) { if (VEdge(isec, NbPath + 1).Orientation() == TopAbs_REVERSED) + { Vertex(isec + 1, NbPath + 1) = TopExp::FirstVertex(TopoDS::Edge(VEdge(isec, NbPath + 1))); + } else + { Vertex(isec + 1, NbPath + 1) = TopExp::LastVertex(TopoDS::Edge(VEdge(isec, NbPath + 1))); + } } UpdateVertex(ILast - 1, isec + 1, @@ -2387,9 +2581,13 @@ bool BRepFill_Sweep::BuildShell( if (Vertex(1, NbPath + 1).IsNull()) { if (VEdge(1, NbPath + 1).Orientation() == TopAbs_REVERSED) + { Vertex(1, NbPath + 1) = TopExp::LastVertex(TopoDS::Edge(VEdge(1, NbPath + 1))); + } else + { Vertex(1, NbPath + 1) = TopExp::FirstVertex(TopoDS::Edge(VEdge(1, NbPath + 1))); + } } UpdateVertex(ILast - 1, 1, TabErr(1, NbPath), Vi(NbPath + 1), Vertex(1, NbPath + 1)); } @@ -2448,9 +2646,11 @@ bool BRepFill_Sweep::BuildShell( // construction of vertex if (Vertex(isec, NbPath + 1).IsNull()) + { B.MakeVertex(TopoDS::Vertex(Vertex(isec, NbPath + 1)), S->Value(u, v), mySec->VertexTol(isec - 1, Vi(NbPath + 1))); + } else { TopLoc_Location Identity; @@ -2467,7 +2667,9 @@ bool BRepFill_Sweep::BuildShell( for (isec = 1; isec <= NbLaw; isec++) { if (IsBuilt(isec)) + { continue; + } S = TabS(isec, ipath); exuv = ExchUV(isec, ipath); @@ -2496,15 +2698,19 @@ bool BRepFill_Sweep::BuildShell( { // All first if (constSection) + { myLoc->PerformVertex(IPath - 1, TopoDS::Vertex(SecVertex(1)), VError(1), TopoDS::Vertex(Vertex(1, 1))); + } else + { myLoc->PerformVertex(IPath - 1, mySec->Vertex(1, Vi(1)), mySec->VertexTol(0, Vi(1)), TopoDS::Vertex(Vertex(1, 1))); + } } // the first and the next column if (vclose && (ipath == NbPath)) @@ -2514,15 +2720,19 @@ bool BRepFill_Sweep::BuildShell( else if (Vertex(1, ipath + 1).IsNull()) { if (constSection) + { myLoc->PerformVertex(IPath, TopoDS::Vertex(SecVertex(1)), TabErr(1, ipath) + VError(1), TopoDS::Vertex(Vertex(1, ipath + 1))); + } else + { myLoc->PerformVertex(IPath, mySec->Vertex(1, Vi(ipath + 1)), TabErr(1, ipath) + mySec->VertexTol(0, Vi(ipath + 1)), TopoDS::Vertex(Vertex(1, ipath + 1))); + } if (MergeVertex(Vertex(1, ipath), Vertex(1, ipath + 1))) { @@ -2540,15 +2750,19 @@ bool BRepFill_Sweep::BuildShell( else if (Vertex(isec + 1, 1).IsNull()) { if (constSection) + { myLoc->PerformVertex(IPath - 1, TopoDS::Vertex(SecVertex(isec + 1)), TabErr(isec, 1) + VError(isec + 1), TopoDS::Vertex(Vertex(isec + 1, 1))); + } else + { myLoc->PerformVertex(IPath - 1, mySec->Vertex(isec + 1, Vi(1)), TabErr(isec, 1) + mySec->VertexTol(isec, Vi(1)), TopoDS::Vertex(Vertex(isec + 1, 1))); + } if (MergeVertex(Vertex(isec, 1), Vertex(isec + 1, 1))) { @@ -2568,15 +2782,19 @@ bool BRepFill_Sweep::BuildShell( else if (Vertex(isec + 1, ipath + 1).IsNull()) { if (constSection) + { myLoc->PerformVertex(IPath, TopoDS::Vertex(SecVertex(isec + 1)), TabErr(isec, ipath) + VError(isec + 1), TopoDS::Vertex(Vertex(isec + 1, ipath + 1))); + } else + { myLoc->PerformVertex(IPath, mySec->Vertex(isec + 1, Vi(ipath + 1)), TabErr(isec, ipath) + mySec->VertexTol(isec, Vi(ipath + 1)), TopoDS::Vertex(Vertex(isec + 1, ipath + 1))); + } } // Singular cases @@ -2641,15 +2859,19 @@ bool BRepFill_Sweep::BuildShell( gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(Vertex(1, ipath))); gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(Vertex(1, ipath + 1))); if (P1.Distance(P2) <= myTol3d) + { Vertex(1, ipath + 1) = Vertex(1, ipath); + } } UEdge(1, ipath) = BuildEdge(S, !exuv, UFirst, Vertex(1, ipath), Vertex(1, ipath + 1), myTol3d); } else { - if (UEdge(isec, ipath).IsNull()) // sweep failed + if (UEdge(isec, ipath).IsNull()) + { // sweep failed return false; + } UpdateEdge(TopoDS::Edge(UEdge(isec, ipath)), S, !exuv, UFirst); } @@ -2673,14 +2895,18 @@ bool BRepFill_Sweep::BuildShell( else { if (UEdge(isec + 1, ipath).IsNull()) + { UEdge(isec + 1, ipath) = BuildEdge(S, !exuv, ULast, Vertex(isec + 1, ipath), Vertex(isec + 1, ipath + 1), myTol3d); + } else + { UpdateEdge(TopoDS::Edge(UEdge(isec + 1, ipath)), S, !exuv, ULast); + } } // (2.3) Iso-v @@ -2689,7 +2915,9 @@ bool BRepFill_Sweep::BuildShell( TopoDS_Edge aNewFirstEdge = BuildEdge(S, exuv, VFirst, Vertex(isec, 1), Vertex(isec + 1, 1), myTol3d); if (VEdge(isec, ipath).IsNull()) + { VEdge(isec, ipath) = aNewFirstEdge; + } else // rebuild first edge { RebuildTopOrBottomEdge(aNewFirstEdge, TopoDS::Edge(VEdge(isec, ipath)), ReversedEdges); @@ -2702,7 +2930,9 @@ bool BRepFill_Sweep::BuildShell( } else + { UpdateEdge(TopoDS::Edge(VEdge(isec, ipath)), S, exuv, VFirst); + } if (vclose && (ipath == NbPath)) { @@ -2722,17 +2952,21 @@ bool BRepFill_Sweep::BuildShell( } } else if (VEdge(isec, ipath + 1).IsNull()) + { VEdge(isec, ipath + 1) = BuildEdge(S, exuv, VLast, Vertex(isec, ipath + 1), Vertex(isec + 1, ipath + 1), myTol3d); + } else { if (ipath != NbPath || vclose || (global_vclose && ILast == myLoc->NbLaw() + 1)) + { UpdateEdge(TopoDS::Edge(VEdge(isec, ipath + 1)), S, exuv, VLast); + } else // ipath == NbPath && !vclose => rebuild last edge { TopoDS_Edge aNewLastEdge = BuildEdge(S, @@ -2745,7 +2979,9 @@ bool BRepFill_Sweep::BuildShell( TopoDS::Edge(VEdge(isec, ipath + 1)), ReversedEdges); if (ReversedEdges.Contains(VEdge(isec, ipath + 1))) + { ReverseEdgeInFirstOrLastWire(LastShape, VEdge(isec, ipath + 1)); + } } } } @@ -2762,9 +2998,13 @@ bool BRepFill_Sweep::BuildShell( if (Degenerated(isec, ipath)) { if (UEdge(isec, ipath).IsSame(UEdge(isec + 1, ipath))) + { myFaces->SetValue(isec, IPath, UEdge(isec, ipath)); + } else + { myFaces->SetValue(isec, IPath, VEdge(isec, ipath)); + } } else if (myFaces->Value(isec, IPath).IsNull()) { @@ -2784,9 +3024,15 @@ bool BRepFill_Sweep::BuildShell( // (3.1) Reverse the faces that have been built earlier for (ipath = 1; ipath <= NbPath; ipath++) + { for (isec = 1; isec <= NbLaw; isec++) + { if (IsBuilt(isec)) + { myFaces->ChangeValue(isec, ipath).Reverse(); + } + } + } // (4) History and Continuity @@ -2796,16 +3042,24 @@ bool BRepFill_Sweep::BuildShell( TopoDS_Compound Comp; B.MakeCompound(Comp); for (isec = 1; isec <= NbLaw + 1; isec++) + { for (ipath = 1, IPath = IFirst; ipath <= NbPath + 1; ipath++, IPath++) { if (ipath <= NbPath) + { myUEdges->SetValue(isec, IPath, UEdge(isec, ipath)); + } if (isec <= NbLaw) + { myVEdges->SetValue(isec, IPath, VEdge(isec, ipath)); + } if ((ipath <= NbPath) && (isec <= NbLaw) && !myFaces->Value(isec, IPath).IsNull() && myFaces->Value(isec, IPath).ShapeType() == TopAbs_FACE) + { B.Add(Comp, myFaces->Value(isec, IPath)); + } } + } BRepLib::EncodeRegularity(Comp, myTolAngular); } else @@ -2818,18 +3072,26 @@ bool BRepFill_Sweep::BuildShell( for (isec = 1; isec <= NbLaw + 1; isec++) { if (isec > 1) + { isG1 = (mySec->Continuity(isec - 1, myTolAngular) >= GeomAbs_G1); + } else + { isG1 = false; + } for (ipath = 1, IPath = IFirst; ipath <= NbPath; ipath++, IPath++) { myUEdges->SetValue(isec, IPath, UEdge(isec, ipath)); if (isG1) { if (isec == NbLaw + 1) + { FF = TopoDS::Face(myFaces->Value(1, IPath)); + } else + { FF = TopoDS::Face(myFaces->Value(isec, IPath)); + } B.Continuity(TopoDS::Edge(myUEdges->Value(isec, IPath)), TopoDS::Face(myFaces->Value(isec - 1, IPath)), FF, @@ -2840,22 +3102,32 @@ bool BRepFill_Sweep::BuildShell( int nbpath = NbPath; if (vclose) + { nbpath++; // Another test G1 + } for (ipath = 1, IPath = IFirst; ipath <= NbPath + 1; ipath++, IPath++) { if ((ipath > 1) && (ipath <= nbpath)) + { isG1 = (myLoc->IsG1(IPath - 1, myTol3d, myTolAngular) >= 0); + } else + { isG1 = false; + } for (isec = 1; isec <= NbLaw; isec++) { myVEdges->SetValue(isec, IPath, VEdge(isec, ipath)); if (isG1) { if (ipath == NbPath + 1) + { FF = TopoDS::Face(myFaces->Value(isec, 1)); + } else + { FF = TopoDS::Face(myFaces->Value(isec, IPath)); + } anEdge = TopoDS::Edge(myVEdges->Value(isec, IPath)); BRepLib::EncodeRegularity(anEdge, FF, @@ -2873,17 +3145,29 @@ bool BRepFill_Sweep::BuildShell( for (isec = 1; isec <= NbLaw; isec++) { for (j = 1; j <= NbPath + 1; j++) + { Tapes(StartEdges(isec))->SetValue(1, j, myVEdges->Value(isec, j)); + } for (j = 1; j <= NbPath; j++) + { Tapes(StartEdges(isec))->SetValue(2, j, myUEdges->Value(isec, j)); + } for (j = 1; j <= NbPath; j++) + { Tapes(StartEdges(isec))->SetValue(3, j, myUEdges->Value(isec + 1, j)); + } for (j = 1; j <= NbPath + 1; j++) + { Tapes(StartEdges(isec))->SetValue(4, j, Vertex(isec, j)); + } for (j = 1; j <= NbPath + 1; j++) + { Tapes(StartEdges(isec))->SetValue(5, j, Vertex(isec + 1, j)); + } for (j = 1; j <= NbPath; j++) + { Tapes(StartEdges(isec))->SetValue(6, j, myFaces->Value(isec, j)); + } TopoDS_Vertex Vfirst, Vlast; // clang-format off TopExp::Vertices(TopoDS::Edge(StartEdges(isec)), Vfirst, Vlast, true); //with orientation @@ -2893,9 +3177,13 @@ bool BRepFill_Sweep::BuildShell( occ::handle> anArray = new NCollection_HArray2(1, 2, 1, NbPath + 1); for (j = 1; j <= NbPath; j++) + { anArray->SetValue(1, j, myUEdges->Value(isec, j)); + } for (j = 1; j <= NbPath + 1; j++) + { anArray->SetValue(2, j, Vertex(isec, j)); + } Rails.Bind(Vfirst, anArray); } if (!Rails.IsBound(Vlast)) @@ -2903,9 +3191,13 @@ bool BRepFill_Sweep::BuildShell( occ::handle> anArray = new NCollection_HArray2(1, 2, 1, NbPath + 1); for (j = 1; j <= NbPath; j++) + { anArray->SetValue(1, j, myUEdges->Value(isec + 1, j)); + } for (j = 1; j <= NbPath + 1; j++) + { anArray->SetValue(2, j, Vertex(isec + 1, j)); + } Rails.Bind(Vlast, anArray); } } @@ -2940,8 +3232,9 @@ void BRepFill_Sweep::Build(NCollection_MapIsVertex()) + { isDone = BuildWire(Transition); - + } else { // Shell int NbTrous = myLoc->NbHoles(myTol3d), NbPath = myLoc->NbLaw(), NbLaw = mySec->NbLaw(), ii, jj, @@ -2970,13 +3263,17 @@ void BRepFill_Sweep::Build(NCollection_MapHoles(Trous->ChangeArray1()); NbPart += NbTrous; if (Trous->Value(NbTrous) == NbPath + 1) + { NbPart--; + } } if (NbPart == 1) { // This is done at once double Extend = 0.0; if (NbTrous == 1) + { Extend = EvalExtrapol(1, Transition); + } isDone = BuildShell(Transition, 1, NbPath + 1, ReversedEdges, Tapes, Rails, Extend, Extend); } else @@ -2985,9 +3282,13 @@ void BRepFill_Sweep::Build(NCollection_Map NbTrous) + { ILast = NbPath + 1; + } else + { ILast = Trous->Value(ii); + } isDone = BuildShell(Transition, IFirst, ILast, @@ -3027,6 +3328,7 @@ void BRepFill_Sweep::Build(NCollection_MapValue(isec, ipath); @@ -3036,6 +3338,7 @@ void BRepFill_Sweep::Build(NCollection_Map 0) ? (aNbFaces < NbLaw) : (aNbFaces == 0)) { @@ -3048,7 +3351,9 @@ void BRepFill_Sweep::Build(NCollection_Map& aList = aSubstitute.Copy(aLocalShape); if (!aList.IsEmpty()) + { myFaces->ChangeValue(ii, jj) = aList.First(); + } } } } @@ -3111,7 +3418,9 @@ void BRepFill_Sweep::Build(NCollection_Map& aList = aSubstitute.Copy(aLocalShape); if (!aList.IsEmpty()) + { myVEdges->ChangeValue(ii, jj) = aList.First(); + } } } } @@ -3127,7 +3436,9 @@ void BRepFill_Sweep::Build(NCollection_Map& aList = aSubstitute.Copy(aLocalShape); if (!aList.IsEmpty()) + { myUEdges->ChangeValue(ii, jj) = aList.First(); + } } } } @@ -3136,42 +3447,60 @@ void BRepFill_Sweep::Build(NCollection_MapLowerRow(); ii <= myUEdges->UpperRow(); ii++) { if (mySec->IsUClosed() && ii == myUEdges->UpperRow()) + { continue; + } for (jj = myUEdges->LowerCol(); jj <= myUEdges->UpperCol(); jj++) { TopoDS_Edge anEdge = TopoDS::Edge(myUEdges->Value(ii, jj)); if (anEdge.IsNull() || BRep_Tool::Degenerated(anEdge)) + { continue; + } TopoDS_Face Face1, Face2; int i1 = ii - 1, i2 = ii; if (i1 == 0 && mySec->IsUClosed()) + { i1 = myFaces->UpperRow(); + } if (i2 > myFaces->UpperRow()) + { i2 = 0; + } if (i1 != 0) { const TopoDS_Shape& aShape1 = myFaces->Value(i1, jj); if (aShape1.ShapeType() == TopAbs_FACE) + { Face1 = TopoDS::Face(aShape1); + } } if (i2 != 0) { const TopoDS_Shape& aShape2 = myFaces->Value(i2, jj); if (aShape2.ShapeType() == TopAbs_FACE) + { Face2 = TopoDS::Face(aShape2); + } } if (!Face1.IsNull() && !Face2.IsNull()) + { CorrectSameParameter(anEdge, Face1, Face2); + } } } for (ii = 1; ii <= NbLaw; ii++) + { for (jj = 1; jj <= NbPath; jj++) { const TopoDS_Shape& aFace = myFaces->Value(ii, jj); if (!aFace.IsNull() && aFace.ShapeType() == TopAbs_FACE) + { BB.Add(myTapes->ChangeValue(ii), aFace); + } } + } // Is it Closed ? if (myLoc->IsClosed() && mySec->IsUClosed()) @@ -3189,7 +3518,9 @@ void BRepFill_Sweep::Build(NCollection_Map 1); } shell.Closed(closed); @@ -3259,7 +3590,9 @@ bool BRepFill_Sweep::PerformCorner(const int { if (Transition == BRepFill_Modified) + { return true; // Do nothing. + } const double anAngularTol = 0.025; @@ -3399,7 +3732,9 @@ bool BRepFill_Sweep::PerformCorner(const int myVEdges->SetValue(ii, Index, NullEdge); } else + { myVEdges->SetValue(ii, Index, listmodif.First()); + } } listmodif.Clear(); @@ -3476,23 +3811,35 @@ bool BRepFill_Sweep::PerformCorner(const int if (!Bord1.IsNull() && TopExp::CommonVertex(E, Bord1, VC)) { if (VC.IsSame(VF)) + { E1 = Bord1; + } else + { E2 = Bord1; + } } if (!Bord2.IsNull() && TopExp::CommonVertex(E, Bord2, VC)) { if (VC.IsSame(VF)) + { E1 = Bord2; + } else + { E2 = Bord2; + } } if (!BordFirst.IsNull() && TopExp::CommonVertex(E, BordFirst, VC)) { if (VC.IsSame(VF)) + { E1 = BordFirst; + } else + { E2 = BordFirst; + } } Bord1 = E1; Bord2 = E2; @@ -3519,7 +3866,9 @@ bool BRepFill_Sweep::PerformCorner(const int TopoDS_Compound aCompound; BB.MakeCompound(aCompound); if (!aVshape.IsNull()) + { BB.Add(aCompound, aVshape); + } BB.Add(aCompound, FF); myVEdges->ChangeValue(ii, I2) = aCompound; @@ -3527,7 +3876,9 @@ bool BRepFill_Sweep::PerformCorner(const int HasFilling = true; } if (ii == 1) + { BordFirst = Bord1; + } } } #ifdef OCCT_DEBUG @@ -3566,7 +3917,9 @@ double BRepFill_Sweep::EvalExtrapol(const int Index, if ((Index == 1) || (Index == myLoc->NbLaw() + 1)) { if (!myLoc->IsClosed() || !mySec->IsVClosed()) + { return Extrap; + } I1 = myLoc->NbLaw(); I2 = 1; } @@ -3638,7 +3991,9 @@ bool BRepFill_Sweep::MergeVertex(const TopoDS_Shape& V1, TopoDS_Shape& V2) const // tol = std::max(BT.Tolerance(v1), BT.Tolerance(v2)); tol = std::max(BRep_Tool::Tolerance(v1), BRep_Tool::Tolerance(v2)); if (tol < myTol3d) + { tol = myTol3d; + } // if (BT.Pnt(v1).Distance(BT.Pnt(v2)) <= tol ){ if (BRep_Tool::Pnt(v1).Distance(BRep_Tool::Pnt(v2)) <= tol) { @@ -3701,7 +4056,9 @@ void BRepFill_Sweep::RebuildTopOrBottomEdge( bool ToReverse = false; bool IsDegen = BRep_Tool::Degenerated(aNewEdge); if (IsDegen) + { BRep_Tool::Range(aNewEdge, fpar, lpar); + } else { TopoDS_Vertex V1, V2, NewV1, NewV2; @@ -3713,14 +4070,18 @@ void BRepFill_Sweep::RebuildTopOrBottomEdge( if (!V1.IsSame(NewV1)) { if (V1.IsSame(NewV2)) + { ToReverse = true; + } else { gp_Pnt Pnt1 = BRep_Tool::Pnt(V1); gp_Pnt NewPnt1 = BRep_Tool::Pnt(NewV1); double TolSum = BRep_Tool::Tolerance(V1) + BRep_Tool::Tolerance(NewV1); if (!Pnt1.IsEqual(NewPnt1, TolSum)) + { ToReverse = true; + } } } } @@ -3733,7 +4094,9 @@ void BRepFill_Sweep::RebuildTopOrBottomEdge( OldCurve->D1(0.5 * (OldFirst + OldLast), MidPnt, OldD1); aNewCurve->D1(0.5 * (fpar + lpar), MidPnt, NewD1); if (OldD1 * NewD1 < 0.) + { ToReverse = true; + } } } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimEdgeTool.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimEdgeTool.cxx index 206b0b31e1..f06826b386 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimEdgeTool.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimEdgeTool.cxx @@ -423,9 +423,13 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, { P.SetY(t); if (Params.IsEmpty()) + { Params.Append(P); + } else + { Params.SetValue(1, P); + } } } else if (Params.Length() == 1 && Points2.Length() == 0) @@ -452,9 +456,13 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, { P.SetY(t); if (Points2.IsEmpty()) + { Points2.Append(P); + } else + { Points2.SetValue(1, P); + } } } @@ -502,13 +510,19 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, else { if (P1.X() < P2.X()) + { Params.Remove(i); + } else + { Points2.Remove(i); + } } } else + { i++; + } } if (Params.Length() > Points2.Length()) @@ -539,20 +553,30 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, TopoDS_Vertex V1, V2; TopExp::Vertices(InitEdge1, V1, V2); if (V1.IsSame(End1) || V1.IsSame(End2)) + { ToExtendFirstPar = false; + } if (V2.IsSame(End1) || V2.IsSame(End2)) + { ToExtendLastPar = false; + } } BRepAdaptor_Curve IC1(InitEdge1); if (IC1.GetType() == GeomAbs_Circle) { double Delta = 2 * M_PI - IC1.LastParameter() + IC1.FirstParameter(); if (ToExtendFirstPar && ToExtendLastPar) + { init_fpar = AC1.FirstParameter() + Delta / 2; + } else if (ToExtendFirstPar) + { init_fpar = AC1.FirstParameter() + Delta; + } else if (ToExtendLastPar) + { init_fpar = AC1.FirstParameter(); + } init_lpar = init_fpar + IC1.LastParameter() - IC1.FirstParameter(); } } @@ -563,19 +587,25 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, // if they are out of initial range int imin = 1; for (i = 2; i <= NbPoints; i++) + { if (Params(i).X() < Params(imin).X()) + { imin = i; + } + } NCollection_Sequence ParamsCopy = Params; NCollection_Sequence Points2Copy = Points2; Params.Clear(); Points2.Clear(); for (i = 1; i <= ParamsCopy.Length(); i++) + { if (imin == i || (ParamsCopy(i).Y() >= init_fpar && ParamsCopy(i).Y() <= init_lpar)) { Params.Append(ParamsCopy(i)); Points2.Append(Points2Copy(i)); } + } /* gp_Pnt Pnt1 = Params(imin); @@ -622,18 +652,26 @@ void BRepFill_TrimEdgeTool::AddOrConfuse(const bool Start, Geom2dAdaptor_Curve AC1(C1, f, l); if (Start) + { PBis = myBis.Value(myBis.FirstParameter()); + } else + { PBis = myBis.Value(myBis.LastParameter()); + } // Test if the end of the bissectrice is in the set of intersection points. if (!Params.IsEmpty()) { gp_Pnt2d P; if (Start) + { P = AC1.Value(Params.First().Y()); + } else + { P = AC1.Value(Params.Last().Y()); + } ToProj = !PBis.IsEqual(P, Tol); } @@ -703,9 +741,13 @@ bool BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const double Dist = RealLast(); // Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End if (isPoint1) + { Dist = P.Distance(myP1); + } else if (isPoint2) + { Dist = P.Distance(myP2); + } else { Geom2dAPI_ProjectPointOnCurve Projector(P, myC1); @@ -727,7 +769,9 @@ bool BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const double aDistMin = std::min(P.Distance(PF), P.Distance(PL)); if (Dist > aDistMin) + { Dist = aDistMin; + } // Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimShellCorner.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimShellCorner.cxx index d1e436a510..defe428ea4 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimShellCorner.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimShellCorner.cxx @@ -256,7 +256,9 @@ void BRepFill_TrimShellCorner::AddVEdges( myVEdges = new NCollection_HArray1(theVEdges->LowerRow(), theVEdges->UpperRow()); for (int i = theVEdges->LowerRow(); i <= theVEdges->UpperRow(); i++) + { myVEdges->SetValue(i, theVEdges->Value(i, theIndex)); + } } //================================================================================================= @@ -270,7 +272,9 @@ void BRepFill_TrimShellCorner::Perform() myHistMap.Clear(); if (myFaces->RowLength() != 2) + { return; + } int ii = 0, jj = 0; BRep_Builder aBB; @@ -345,7 +349,9 @@ void BRepFill_TrimShellCorner::Perform() anIndex2 = theDS->Index(aF2); if ((anIndex1 == -1) || (anIndex2 == -1)) + { continue; + } for (i = 0; i < aNbFFs; ++i) { @@ -475,7 +481,9 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, const NCollection_List& lst = myHistMap.Find(aShape1); if (!lst.IsEmpty()) + { aUE1 = TopoDS::Edge(lst.First()); + } } if (myHistMap.IsBound(aShape2)) @@ -483,14 +491,20 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, const NCollection_List& lst = myHistMap.Find(aShape2); if (!lst.IsEmpty()) + { aUE2 = TopoDS::Edge(lst.First()); + } } if (!aShape1.IsSame(aUE1)) + { aSubstitutor->Replace(aShape1.Oriented(TopAbs_FORWARD), aUE1.Oriented(TopAbs_FORWARD)); + } if (!aShape2.IsSame(aUE2)) + { aSubstitutor->Replace(aShape2.Oriented(TopAbs_FORWARD), aUE2.Oriented(TopAbs_FORWARD)); + } TopoDS_Vertex V1 = TopExp::LastVertex(aUE1); TopoDS_Vertex V2 = TopExp::FirstVertex(aUE2); @@ -506,12 +520,18 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, if (bvertexfound) { if (aCommonVertices.Extent() != 1) + { return false; + } if (acommonflag == 1) + { aNewEdge = BRepLib_MakeEdge(TopoDS::Vertex(aCommonVertices.First()), aCommonVertex); + } else + { aNewEdge = BRepLib_MakeEdge(aCommonVertex, TopoDS::Vertex(aCommonVertices.First())); + } bHasNewEdge = true; } @@ -540,7 +560,9 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, const NCollection_List& lst = myHistMap.Find(aShape); if (!lst.IsEmpty()) + { aUE = TopoDS::Edge(lst.First()); + } } const TopoDS_Shape& aV = (fit == 1) ? TopExp::FirstVertex(TopoDS::Edge(aUE)) : TopExp::LastVertex(TopoDS::Edge(aUE)); @@ -558,7 +580,9 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, FindFreeVertices(aComp, aMapV, alonevertices); if (!alonevertices.IsEmpty() && (alonevertices.Extent() != 2)) + { return false; + } int aFaceIndex = (fit == 1) ? theFaceIndex1 : theFaceIndex2; TopoDS_Shape aFace = theDS->Shape(aFaceIndex); @@ -674,13 +698,19 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, for (; !bfoundv && anExpV.More(); anExpV.Next()) { if (aV2.IsSame(anExpV.Current())) + { bfoundv = true; + } } if (bfoundv) + { aOrderedList.Append(aNewEdge); + } else + { aOrderedList.Prepend(aNewEdge); + } } } else @@ -707,9 +737,13 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, aBB.Add(aW, anItE.Value()); } if (fit == 1) + { aSubstitutor->Replace(aE1.Oriented(TopAbs_FORWARD), aW); + } else + { aSubstitutor->Replace(aE2.Oriented(TopAbs_FORWARD), aW); + } } aSubstitutor->Apply(aFace); @@ -726,10 +760,14 @@ bool BRepFill_TrimShellCorner::MakeFacesNonSec(const int theIndex, TopoDS_Shape aNewValue = aSubstitutor->Value(anExpE.Current()); if (aNewValue.IsNull() || aNewValue.IsSame(anExpE.Current())) + { continue; + } if (myHistMap.IsBound(anExpE.Current())) + { continue; + } NCollection_List aListOfNewEdge; TopExp_Explorer anExpE2(aNewValue, TopAbs_EDGE); @@ -762,7 +800,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, TopoDS_Face aSecPlane; if (!FilterSectionEdges(aBCurves, aSecPlane, theDS, aSecEdges)) + { return false; + } // Extract vertices on the intersection of correspondent U-edges const TopoDS_Shape& LeftE1 = myUEdges->Value(theIndex, 1); @@ -806,7 +846,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, TopExp_Explorer explo(SecWire, TopAbs_EDGE); for (; explo.More(); explo.Next()) + { BB.Add(aComp, explo.Current()); + } aSecEdges = aComp; StoreVedgeInHistMap(myVEdges, theIndex, SecWire, myHistMap); @@ -830,7 +872,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, TopoDS_Edge aUE2; if (!GetUEdges(theIndex, fit, myUEdges, aBoundEdge, aFaceF, aUE1, aUE2)) + { return false; + } TopoDS_Edge aUE1old = aUE1; TopoDS_Edge aUE2old = aUE2; @@ -844,7 +888,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, const TopoDS_Shape& anEdge = lst.First().Oriented(aUE1.Orientation()); if (!aUE1.IsSame(anEdge)) + { aSubstitutor->Replace(aUE1.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); + } aUE1 = TopoDS::Edge(anEdge); } } @@ -858,7 +904,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, const TopoDS_Shape& anEdge = lst.First().Oriented(aUE2.Orientation()); if (!aUE2.IsSame(anEdge)) + { aSubstitutor->Replace(aUE2.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); + } aUE2 = TopoDS::Edge(anEdge); } } @@ -925,7 +973,9 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, for (; aEIt.More(); aEIt.Next()) { if (!aBoundEdge.IsSame(aEIt.Value())) + { aBB.Add(aW, aEIt.Value()); + } } aSubstitutor->Replace(aBoundEdge.Oriented(TopAbs_FORWARD), aW); } @@ -944,10 +994,14 @@ bool BRepFill_TrimShellCorner::MakeFacesSec(const int theIndex, TopoDS_Shape aNewValue = aSubstitutor->Value(anExpE.Current()); if (aNewValue.IsNull() || aNewValue.IsSame(anExpE.Current())) + { continue; + } if (myHistMap.IsBound(anExpE.Current())) + { continue; + } NCollection_List aListOfNewEdge; TopExp_Explorer anExpE2(aNewValue, TopAbs_EDGE); @@ -986,12 +1040,16 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, BB.MakeCompound(OldComp); TopoDS_Iterator iter(Comp); for (; iter.More(); iter.Next()) + { BB.Add(OldComp, iter.Value()); + } TopoDS_Edge FirstEdge = FindEdgeCloseToBisectorPlane(theFirstVertex, OldComp, myAxeOfBisPlane.Axis()); if (FirstEdge.IsNull()) + { return false; + } iter.Initialize(OldComp); if (!iter.More()) @@ -1002,7 +1060,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, TopoDS_Edge LastEdge = FindEdgeCloseToBisectorPlane(theLastVertex, OldComp, myAxeOfBisPlane.Axis()); if (LastEdge.IsNull()) + { return false; + } if (FirstEdge.IsNull() || LastEdge.IsNull()) { @@ -1017,7 +1077,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, bool CommonVertexExists = FindCommonVertex(FirstEdge, LastEdge, theFirstVertex, theLastVertex, aCommonVertex); if (CommonVertexExists) + { BB.Add(NewWire, LastEdge); + } else { TopoDS_Vertex Vertex1, Vertex2, V1, V2; @@ -1031,7 +1093,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, { NCollection_List::Iterator itl(MiddleEdges); for (; itl.More(); itl.Next()) + { BB.Add(NewWire, itl.Value()); + } BB.Add(NewWire, LastEdge); } else @@ -1043,8 +1107,12 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, { int imin = 1; for (i = 2; i <= Extrema.NbExt(); i++) + { if (Extrema.SquareDistance(i) < Extrema.SquareDistance(imin)) + { imin = i; + } + } double aMinDist = sqrt(Extrema.SquareDistance(imin)); double ParamOnFirstEdge = Extrema.ParameterOnE1(imin); @@ -1075,7 +1143,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, B.MakeCompound(OldComp); TopoDS_Iterator iter(Comp); for (; iter.More(); iter.Next()) + { B.Add(OldComp, iter.Value()); + } bool anError = false; // TopoDS_Wire NewWire [2]; @@ -1084,7 +1154,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, { TopExp_Explorer explo(OldComp, TopAbs_EDGE); if (!explo.More()) + { break; + } TopoDS_Edge FirstEdge = TopoDS::Edge(explo.Current()); TopoDS_Wire NewWire = BRepLib_MakeWire(FirstEdge); B.Remove(OldComp, FirstEdge); @@ -1110,11 +1182,17 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, TopExp::MapShapesAndAncestors(OldComp, TopAbs_VERTEX, TopAbs_EDGE, VEmap); NCollection_List Vedges[2]; for (j = 0; j < 2; j++) + { if (VEmap.Contains(Extremity[j])) + { Vedges[j] = VEmap.FindFromKey(Extremity[j]); + } + } if (Vedges[0].IsEmpty() && Vedges[1].IsEmpty()) + { // no more edges in OldComp to continue NewWire break; + } bool Modified = false; for (j = 0; j < 2; j++) { @@ -1132,7 +1210,9 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, NCollection_Sequence Edges; NCollection_List::Iterator itl(Vedges[ind]); for (; itl.More(); itl.Next()) + { Edges.Append(itl.Value()); + } int theind = 0; double MinDeviation = RealLast(); for (j = 1; j <= Edges.Length(); j++) @@ -1151,11 +1231,15 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, B.Remove(OldComp, Edges(theind)); } if (NewWire.Closed()) + { break; + } } Wseq.Append(NewWire); if (anError) + { break; + } } double MinAngle = RealLast(); @@ -1177,11 +1261,15 @@ bool BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Comp, bool issing; ComputeAveragePlaneAndMaxDeviation(aWire, aPln, issing); if (issing) + { continue; + } double Angle = aPln.Axis().Angle(myAxeOfBisPlane.Axis()); if (Angle > M_PI / 2) + { Angle = M_PI - Angle; + } if (Angle < MinAngle) { @@ -1222,7 +1310,9 @@ bool SplitUEdges( const TopoDS_Shape& aE2 = theUEdges->Value(ueit, upCol); if (theHistMap.IsBound(aE1) || theHistMap.IsBound(aE2)) + { continue; + } int anEIndex1 = theDS->Index(aE1); int anEIndex2 = theDS->Index(aE2); @@ -1333,7 +1423,9 @@ void FindFreeVertices( const TopoDS_Shape& aKey = aMap.FindKey(i); if (theVerticesToAvoid.Contains(aKey)) + { continue; + } const NCollection_List& aList = aMap.FindFromIndex(i); if (aList.Extent() < 2) @@ -1375,7 +1467,9 @@ bool FindCommonVertex(const BOPDS_PDS& theDS, { if (!aEE.HasIndexNew()) + { continue; + } IntTools_CommonPrt aCP = aEE.CommonPart(); if (aCP.Type() == TopAbs_VERTEX) @@ -1383,9 +1477,13 @@ bool FindCommonVertex(const BOPDS_PDS& theDS, theCommonVertex = *(TopoDS_Vertex*)&theDS->Shape(aEE.IndexNew()); if (theEIndex1 == aEE.Index1()) + { IntTools_Tools::VertexParameters(aCP, theParamOnE1, theParamOnE2); + } else + { IntTools_Tools::VertexParameters(aCP, theParamOnE2, theParamOnE1); + } gp_Pnt aPt; gp_Vec aDirOnE1, aDirOnE2; @@ -1439,18 +1537,24 @@ bool GetUEdges(const int theIndex, } if (E1.IsNull() || E2.IsNull()) + { return false; + } double f, l; occ::handle C1 = BRep_Tool::CurveOnSurface(E1, aFace, f, l); if (C1.IsNull()) + { return false; + } gp_Pnt2d PU1 = (theRank == 0) ? C1->Value(l) : C1->Value(f); occ::handle C2 = BRep_Tool::CurveOnSurface(theBoundEdge, aFace, f, l); if (C2.IsNull()) + { return false; + } BRep_Tool::Range(theBoundEdge, f, l); gp_Pnt2d pf = C2->Value(f); TopoDS_Vertex aV = (theRank == 0) ? TopExp::LastVertex(E1) : TopExp::FirstVertex(E1); @@ -1526,7 +1630,9 @@ bool FindNextEdge(const TopoDS_Vertex& for (i = 1; i <= theMapVE.Extent(); i++) { if (!theMapVE.Contains(aCurVertex)) + { break; + } const NCollection_List& lste = theMapVE.FindFromKey(aCurVertex); bool befound = false; @@ -1576,7 +1682,9 @@ bool FindNextEdge(const TopoDS_Vertex& } if (aCurVertex.IsSame(theLastVertex)) + { break; + } if (!befound) { @@ -1603,7 +1711,9 @@ bool CheckAndOrientEdges(const NCollection_List& theOrderedList, NCollection_List::Iterator anIt(theOrderedList); if (!anIt.More()) + { return true; + } double f, l; TopoDS_Edge aEPrev = TopoDS::Edge(anIt.Value()); @@ -1630,13 +1740,17 @@ bool CheckAndOrientEdges(const NCollection_List& theOrderedList, if (ap.Distance(theFirstPoint) < aTolerance1) { if (theOrientedList.IsEmpty()) + { theOrientedList.Append(aEPrev.Oriented(TopAbs_FORWARD)); + } bFirstFound = true; } else if (ap.Distance(theLastPoint) < aTolerance1) { if (theOrientedList.IsEmpty()) + { theOrientedList.Append(aEPrev.Oriented(TopAbs_REVERSED)); + } bLastFound = true; } ap = aCurve->Value(l); @@ -1644,18 +1758,24 @@ bool CheckAndOrientEdges(const NCollection_List& theOrderedList, if (ap.Distance(theLastPoint) < aTolerance2) { if (theOrientedList.IsEmpty()) + { theOrientedList.Append(aEPrev.Oriented(TopAbs_FORWARD)); + } bLastFound = true; } else if (ap.Distance(theFirstPoint) < aTolerance2) { if (theOrientedList.IsEmpty()) + { theOrientedList.Append(aEPrev.Oriented(TopAbs_REVERSED)); + } bFirstFound = true; } if (!theOrientedList.IsEmpty()) + { aEPrev = TopoDS::Edge(theOrientedList.Last()); + } for (; anIt.More(); anIt.Next()) { @@ -1717,12 +1837,16 @@ bool FindVertex( { if (!theHistMap.IsBound(theEdge)) + { return false; + } const NCollection_List& lst = theHistMap.Find(theEdge); if (lst.IsEmpty()) + { return false; + } TopoDS_Edge aNewEdge = TopoDS::Edge(lst.First()); double f, l; @@ -1983,7 +2107,9 @@ bool FindFromVEdge( if (FindVertex(theUE2Old, theRank, theDS, theHistMap, atmpVertex, aPaveOfE2)) { if (thePrevPave.IsEqual(aPaveOfE2)) + { return true; + } } } @@ -2172,7 +2298,9 @@ bool FindFromVEdge( aTolerance = (utol > vtol) ? utol : vtol; if (p2.Distance(p3) < aTolerance) + { blin = true; + } } } @@ -2315,7 +2443,9 @@ bool FindFromVEdge( TopoDS_Edge aESplit; // get split if (!GetPave(theBoundEdgeIndex, false, theDS, aPave2)) + { return false; + } // aPBIt.Initialize(theDS->PaveBlocks(theBoundEdgeIndex)); for (; aPBIt.More(); aPBIt.Next()) @@ -2353,7 +2483,9 @@ bool FindFromVEdge( TopoDS_Edge aESplit; // get split if (!GetPave(theBoundEdgeIndex, false, theDS, aPave2)) + { return false; + } NCollection_List>::Iterator aPBIt; aPBIt.Initialize(theDS->PaveBlocks(theBoundEdgeIndex)); @@ -2509,7 +2641,9 @@ static double ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWire, gp_Ax2 Axe; GeomLib::AxeOfInertia(Pnts, Axe, IsSingular); if (IsSingular) + { return -1; + } thePlane = gp_Pln(Axe); double MaxDeviation = 0; @@ -2517,7 +2651,9 @@ static double ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWire, { double dist = thePlane.Distance(Pnts(i)); if (dist > MaxDeviation) + { MaxDeviation = dist; + } } return MaxDeviation; } @@ -2550,9 +2686,13 @@ static void UpdateSectionEdge(TopoDS_Edge& theEdge, double fpar, lpar; BRep_Tool::Range(F_Edge, fpar, lpar); if (OrOfVertex == TopAbs_FORWARD) + { fpar = theParam; + } else + { lpar = theParam; + } BB.Range(F_Edge, fpar, lpar); F_Edge.Free(true); @@ -2575,13 +2715,17 @@ static TopoDS_Edge FindEdgeCloseToBisectorPlane(const TopoDS_Vertex& theVertex, TopoDS_Edge MinEdge; if (!VEmap.Contains(theVertex)) + { return MinEdge; + } BRep_Builder BB; const NCollection_List& Edges = VEmap.FindFromKey(theVertex); if (Edges.Extent() == 1) + { MinEdge = TopoDS::Edge(Edges.First()); + } else { NCollection_List::Iterator itl(Edges); @@ -2606,14 +2750,18 @@ static TopoDS_Edge FindEdgeCloseToBisectorPlane(const TopoDS_Vertex& theVertex, gp_Ax1 EdgeAxis(FirstPnt, EdgeVec); anAngle = EdgeAxis.Direction().Angle(theAxis.Direction()); if (anAngle > M_PI / 2) + { anAngle = M_PI - anAngle; + } anAngle = M_PI / 2 - anAngle; } else { anAngle = aPln.Axis().Angle(theAxis); if (anAngle > M_PI / 2) + { anAngle = M_PI - anAngle; + } } if (anAngle < MinAngle) @@ -2638,10 +2786,14 @@ static bool FindMiddleEdges(const TopoDS_Vertex& theVertex1, VEmap; TopExp::MapShapesAndAncestors(theComp, TopAbs_VERTEX, TopAbs_EDGE, VEmap); if (VEmap.IsEmpty()) + { return false; + } if (!VEmap.Contains(theVertex1) || !VEmap.Contains(theVertex2)) + { return false; + } TopoDS_Vertex CurVertex = theVertex1; for (;;) @@ -2650,7 +2802,9 @@ static bool FindMiddleEdges(const TopoDS_Vertex& theVertex1, CurEdge = FindEdgeCloseToBisectorPlane(CurVertex, theComp, theAxis); if (CurEdge.IsNull()) + { return false; + } TopoDS_Vertex V1, V2; TopExp::Vertices(CurEdge, V1, V2); @@ -2658,7 +2812,9 @@ static bool FindMiddleEdges(const TopoDS_Vertex& theVertex1, theElist.Append(CurEdge); if (CurVertex.IsSame(theVertex2)) + { return true; + } } } diff --git a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimSurfaceTool.cxx b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimSurfaceTool.cxx index bd73b04f81..03a3958b83 100644 --- a/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimSurfaceTool.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepFill/BRepFill_TrimSurfaceTool.cxx @@ -143,9 +143,13 @@ static double EvalPhase(const TopoDS_Edge& Edge, gp_Pnt P = GAS.Value(0., V); if (gp_Vec(Axis.Location(), P).Dot(Axis.XDirection()) < 0.) + { return M_PI; + } else + { return 0.; + } } //================================================================================================= @@ -304,10 +308,14 @@ static void EvalParameters(const TopoDS_Edge& Edge, // modified by NIZHNY-EAP Wed Jan 12 11:41:40 2000 ___END___ UBis = Bis->LastParameter(); if (UBis >= Precision::Infinite()) + { return; + } PBis = Bis->Value(UBis); if (PBis.Distance(P2d) > Tol) + { return; + } } // evaluate parameter intersection. @@ -360,7 +368,9 @@ static void EvalParameters(const TopoDS_Edge& Edge, double U = Axis.XDirection().AngleWithRef(D1, Axis.XDirection() ^ Axis.YDirection()); U += Phase; if (U < 0.) + { U += 2 * M_PI; + } P = gp_Pnt(Bis->FirstParameter(), U, 0.); Seq.Append(P); @@ -406,7 +416,9 @@ bool BRepFill_TrimSurfaceTool::IsOnFace(const gp_Pnt2d& Point) const // modified by NIZHNY-EAP Fri Jan 21 09:49:09 2000 ___BEGIN___ Inter.Init(myFace1, Line, 1e-6); // Precision::PConfusion()); if (Inter.More()) + { return true; + } // eval if is on face 2 Inter.Init(myFace2, Line, 1e-6); // Precision::PConfusion()); diff --git a/src/ModelingAlgorithms/TKBool/BRepProj/BRepProj_Projection.cxx b/src/ModelingAlgorithms/TKBool/BRepProj/BRepProj_Projection.cxx index 047ccb3e91..17a48f358a 100644 --- a/src/ModelingAlgorithms/TKBool/BRepProj/BRepProj_Projection.cxx +++ b/src/ModelingAlgorithms/TKBool/BRepProj/BRepProj_Projection.cxx @@ -90,7 +90,9 @@ void BRepProj_Projection::BuildSection(const TopoDS_Shape& theShape, const TopoD TopoDS_Shape aShape; if (theShape.ShapeType() == TopAbs_FACE || theShape.ShapeType() == TopAbs_SHELL || theShape.ShapeType() == TopAbs_SOLID || theShape.ShapeType() == TopAbs_COMPSOLID) + { aShape = theShape; + } else if (theShape.ShapeType() == TopAbs_COMPOUND) { TopoDS_Compound C; @@ -99,13 +101,17 @@ void BRepProj_Projection::BuildSection(const TopoDS_Shape& theShape, const TopoD for (; exp.More(); exp.Next()) { if (C.IsNull()) + { B.MakeCompound(C); + } B.Add(C, exp.Current()); } aShape = C; } if (aShape.IsNull()) + { throw Standard_ConstructionError(__FILE__ ": target shape has no faces"); + } // build section computing p-curves on both shapes to get higher precision BRepAlgoAPI_Section aSectionTool(aShape, theTool, false); @@ -118,18 +124,24 @@ void BRepProj_Projection::BuildSection(const TopoDS_Shape& theShape, const TopoD // check for successful work of the section tool if (!aSectionTool.IsDone()) + { return; + } // get edges of the result occ::handle> anEdges = new NCollection_HSequence; TopExp_Explorer exp(aSectionTool.Shape(), TopAbs_EDGE); for (; exp.More(); exp.Next()) + { anEdges->Append(exp.Current()); + } // if no edges are found, this means that this section yields no result if (anEdges->Length() <= 0) + { return; + } // connect edges to wires using ShapeAnalysis functionality mySection = ShapeAnalysis_FreeBounds::ConnectEdgesToWires(anEdges, Precision::Confusion(), true); @@ -141,7 +153,9 @@ void BRepProj_Projection::BuildSection(const TopoDS_Shape& theShape, const TopoD BRep_Builder B; B.MakeCompound(myShape); for (int i = 1; i <= mySection->Length(); i++) + { B.Add(myShape, mySection->Value(i)); + } // initialize iteration (for compatibility with previous versions) myItr = 1; @@ -159,7 +173,9 @@ BRepProj_Projection::BRepProj_Projection(const TopoDS_Shape& Wire, // Check the input Standard_NullObject_Raise_if((Wire.IsNull() || Shape.IsNull()), __FILE__ ": null input shape"); if (Wire.ShapeType() != TopAbs_EDGE && Wire.ShapeType() != TopAbs_WIRE) + { throw Standard_ConstructionError(__FILE__ ": projected shape is neither wire nor edge"); + } // compute the "length" of the cylindrical surface to build double mdis = DistanceIn(Wire, Shape); @@ -192,7 +208,9 @@ BRepProj_Projection::BRepProj_Projection(const TopoDS_Shape& Wire, // Check the input Standard_NullObject_Raise_if((Wire.IsNull() || Shape.IsNull()), __FILE__ ": null input shape"); if (Wire.ShapeType() != TopAbs_EDGE && Wire.ShapeType() != TopAbs_WIRE) + { throw Standard_ConstructionError(__FILE__ ": projected shape is neither wire nor edge"); + } // if Wire is only an edge, transform it into a Wire TopoDS_Wire aWire; @@ -203,7 +221,9 @@ BRepProj_Projection::BRepProj_Projection(const TopoDS_Shape& Wire, BB.Add(aWire, Wire); } else + { aWire = TopoDS::Wire(Wire); + } // compute the "length" of the conical surface to build double mdis = DistanceIn(Wire, Shape); @@ -218,7 +238,9 @@ BRepProj_Projection::BRepProj_Projection(const TopoDS_Shape& Wire, // compute the ratio of the scale transformation double Scale = PC.Distance(P); if (std::abs(Scale) < Precision::Confusion()) + { throw Standard_ConstructionError("Projection"); + } Scale = 1. + mdis / Scale; // move the base of the conical surface by scaling it with ratio Scale diff --git a/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Cut_Test.cxx b/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Cut_Test.cxx index 2f958ddf45..95feed5ac8 100644 --- a/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Cut_Test.cxx +++ b/src/ModelingAlgorithms/TKBool/GTests/BRepAlgoAPI_Cut_Test.cxx @@ -47,7 +47,9 @@ static double runHollowBoxMeshTest(double theMeshDelta) // Cut inner from outer BRepAlgoAPI_Cut aCut(aFullSolid, anInnerSolid); if (!aCut.IsDone()) + { return -1.0; + } // Extract the single solid from the cut result TopoDS_Solid aCutSolid; @@ -63,14 +65,18 @@ static double runHollowBoxMeshTest(double theMeshDelta) } } if (aNbSolids != 1) + { return -1.0; + } // Calculate original volume GProp_GProps aVProps; BRepGProp::VolumeProperties(aCutSolid, aVProps); const double anOriginalVolume = aVProps.Mass(); if (anOriginalVolume <= 0.0) + { return -1.0; + } // Build bounding box and extend by small delta Bnd_Box aBndBox; @@ -87,13 +93,19 @@ static double runHollowBoxMeshTest(double theMeshDelta) // Grid the bounding box int aNx = (int)((aXmax - aXmin) / theMeshDelta); if (aNx <= 0) + { aNx = 1; + } int aNy = (int)((aYmax - aYmin) / theMeshDelta); if (aNy <= 0) + { aNy = 1; + } int aNz = (int)((aZmax - aZmin) / theMeshDelta); if (aNz <= 0) + { aNz = 1; + } const double aStepX = (aXmax - aXmin) / aNx; const double aStepY = (aYmax - aYmin) / aNy; @@ -127,7 +139,9 @@ static double runHollowBoxMeshTest(double theMeshDelta) const TopoDS_Shape aCopySolid = BRepBuilderAPI_Copy(aCutSolid).Shape(); BRepAlgoAPI_Common aCommon(aCopySolid, aSubvols(l)); if (!aCommon.IsDone()) + { continue; + } int aNbCommon = 0; TopoDS_Shape aFoundSolid; @@ -145,7 +159,9 @@ static double runHollowBoxMeshTest(double theMeshDelta) BRepGProp::VolumeProperties(aFoundSolid, aVProps); const double aVol = aVProps.Mass(); if (aVol > 0.0 && aVol <= aSubvolVols(l)) + { anAccumulated += aVol; + } } } @@ -191,7 +207,9 @@ TEST(BRepAlgoAPI_CutTest, HollowBox_SurfaceAreaAndValidity) TopoDS_Solid aCutSolid; TopExp_Explorer anExp; for (anExp.Init(aCut.Shape(), TopAbs_SOLID); anExp.More(); anExp.Next()) + { aCutSolid = TopoDS::Solid(anExp.Current()); + } ASSERT_FALSE(aCutSolid.IsNull()); // Surface area: outer box 6*900=5400, inner box adds 6*100=600 => total=6000 diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Bipoint.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Bipoint.cxx index 6d999cd095..fa9e14692d 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Bipoint.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Bipoint.cxx @@ -32,13 +32,17 @@ TopOpeBRep_Bipoint::TopOpeBRep_Bipoint(const int I1, const int I2) int TopOpeBRep_Bipoint::I1() const { if (myI1 <= 0) + { throw Standard_ProgramError("TopOpeBRep_Bipoint I1=0"); + } return myI1; } int TopOpeBRep_Bipoint::I2() const { if (myI2 <= 0) + { throw Standard_ProgramError("TopOpeBRep_Bipoint I2=0"); + } return myI2; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_DSFiller.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_DSFiller.cxx index c9b81696b6..8062c9ee42 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_DSFiller.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_DSFiller.cxx @@ -145,10 +145,7 @@ TopOpeBRep_DSFiller::TopOpeBRep_DSFiller() TopOpeBRep_DSFiller::~TopOpeBRep_DSFiller() { - if (myPShapeClassifier) - { - delete myPShapeClassifier; - } + delete myPShapeClassifier; } // modified by NIZNHY-PKV Mon Dec 16 11:12:41 2002 t @@ -183,28 +180,38 @@ void BREP_correctgbound(const occ::handle& HDS) const TopoDS_Shape& s = BDS.Shape(i); TopAbs_ShapeEnum t = s.ShapeType(); if (t != TopAbs_EDGE) + { continue; + } NCollection_List>::Iterator it; it.Initialize(BDS.ChangeShapeInterferences(s)); if (!it.More()) + { continue; + } for (; it.More(); it.Next()) { const occ::handle& I = it.Value(); occ::handle SSI = occ::down_cast(I); if (SSI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GK = SSI->GeometryType(); if (GK != TopOpeBRepDS_VERTEX) + { continue; + } ehassiv = true; break; } // it.More if (!ehassiv) + { continue; + } // l'arete s a au moins une shapeshapeinterference de geometrie VERTEX. // on verifie l'information GBound de toutes ses shapeshapeinterferences. @@ -218,11 +225,15 @@ void BREP_correctgbound(const occ::handle& HDS) occ::handle SSI = occ::down_cast(I); if (SSI.IsNull()) + { continue; + } int GI = SSI->Geometry(); TopOpeBRepDS_Kind GK = SSI->GeometryType(); if (GK != TopOpeBRepDS_VERTEX) + { continue; + } const TopoDS_Shape& v = BDS.Shape(GI); bool vofe = imev.Contains(v); @@ -237,18 +248,26 @@ void BREP_correctgbound(const occ::handle& HDS) occ::handle SSI = occ::down_cast(I); if (SSI.IsNull()) + { continue; + } int GI = SSI->Geometry(); TopOpeBRepDS_Kind GK = SSI->GeometryType(); if (GK != TopOpeBRepDS_VERTEX) + { continue; + } const TopoDS_Shape& v = BDS.Shape(GI); bool vhassd = HDS->HasSameDomain(v); if (!vhassd) + { continue; + } int ivref = BDS.SameDomainRef(v); if (ivref == GI) + { continue; + } const TopoDS_Shape& vref = BDS.Shape(ivref); bool vrefofe = imev.Contains(vref); @@ -256,7 +275,6 @@ void BREP_correctgbound(const occ::handle& HDS) SSI->SetGBound(vrefofe); } // it.More } // i - return; } // correctGBound //================================================================================================= @@ -304,10 +322,14 @@ static bool FUN_shareNOG(const occ::handle& HDS, int G = I1->Geometry(); TopOpeBRepDS_Kind GT = I1->GeometryType(); if (GT != TopOpeBRepDS_EDGE) + { continue; + } const TopoDS_Shape& EG = BDS.Shape(G); if (map2.Contains(EG)) + { return false; + } } const NCollection_List>& lIF2 = BDS.ShapeInterferences(F2); NCollection_List>::Iterator it2(lIF2); @@ -317,10 +339,14 @@ static bool FUN_shareNOG(const occ::handle& HDS, int G = I2->Geometry(); TopOpeBRepDS_Kind GT = I2->GeometryType(); if (GT != TopOpeBRepDS_EDGE) + { continue; + } const TopoDS_Shape& EG = BDS.Shape(G); if (map1.Contains(EG)) + { return false; + } } TopExp_Explorer ex1(F1, TopAbs_EDGE); @@ -335,7 +361,9 @@ static bool FUN_shareNOG(const occ::handle& HDS, { const TopoDS_Shape& e2 = itsd1.Value(); if (map2.Contains(e2)) + { return false; + } } } @@ -348,10 +376,14 @@ static bool FUN_shareNOG(const occ::handle& HDS, int S1 = I1->Support(); TopOpeBRepDS_Kind ST1 = I1->SupportType(); if (ST1 != TopOpeBRepDS_EDGE) + { continue; + } const TopoDS_Edge& e2 = TopoDS::Edge(BDS.Shape(S1)); if (!map2.Contains(e2)) + { continue; + } TopOpeBRepDS_Kind GT1 = I1->GeometryType(); if (GT1 == TopOpeBRepDS_POINT) @@ -373,13 +405,17 @@ static bool FUN_shareNOG(const occ::handle& HDS, double dot = gp_Dir(tge1).Dot(gp_Dir(tge2)); double x = std::abs(1 - std::abs(dot)); if (x > tola) + { return false; // e1,e2 not tangent + } gp_Vec xxF1 = FUN_tool_getgeomxx(F1, e1, par1); gp_Vec xxF2 = FUN_tool_getgeomxx(F2, e2, par2); dot = gp_Dir(xxF1).Dot(gp_Dir(xxF2)); if (dot > 0) + { return false; // F1,F2 share geometric domain near G1 + } } } // it1.More() } // ex1(F1,EDGE) @@ -413,7 +449,9 @@ void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& FC2D_Prepare(aS1, aS2); if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } myFacesFiller.SetPShapeClassifier(myPShapeClassifier); #ifdef OCCT_DEBUG @@ -495,12 +533,16 @@ void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& TopExp::MapShapes(S2, TopAbs_SOLID, aMapOfSolids); if (!aMapOfSolids.IsEmpty()) + { myShapeIntersector.RejectedFaces(S1, S2, aListObj); + } aMapOfSolids.Clear(); TopExp::MapShapes(S1, TopAbs_SOLID, aMapOfSolids); if (!aMapOfSolids.IsEmpty()) + { myShapeIntersector.RejectedFaces(S2, S1, aListTool); + } // modified by NIZHNY-MKK Fri Apr 14 09:37:32 2000.END // 2.Insert all rejected faces, wires, edges of Object in DS: @@ -550,7 +592,9 @@ void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& if (unfill) { if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } unfill = BREP_UnfillSameDomain(lFF1, lFF2, HDS, *myPShapeClassifier); } @@ -629,18 +673,26 @@ void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& // FFsamdom = true : rien que des faces tangentes // codage des aretes de section des aretes samedomain if (FFsamdom) + { FUN_ds_FillSDMFaces(HDS); // xpu060598 - // xpu280199 : On stocke les edges sdm comme edges de section aussi ! - CTS21801 - + // xpu280199 : On stocke les edges sdm comme edges de section aussi ! - CTS21801 - + } else + { FUN_ds_addSEsdm1d(HDS); + } if (FFsamdom) + { HDS->ChangeDS().Isfafa(true); // xpu120598 + } if (islFFsamdom && !isEE) { if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } unfill = BREP_UnfillSameDomain(lFF1, lFF2, HDS, *myPShapeClassifier); } @@ -707,7 +759,9 @@ void TopOpeBRep_DSFiller::CompleteDS(const occ::handleAddAncestors(S1); -xpu100798 (is done before FDSCNX_Prepare) // HDS->AddAncestors(S2); -xpu100798 @@ -769,7 +823,9 @@ void TopOpeBRep_DSFiller::RemoveUnsharedGeometry( processNOG = false; #endif if (!processNOG) + { return; + } // xpu290998 : PRO15369 (f5,f20 only share geometric point (vertex)) // end processing for all information on shapes is given. @@ -779,13 +835,19 @@ void TopOpeBRep_DSFiller::RemoveUnsharedGeometry( { TopoDS_Shape S = BDS.Shape(i); if (S.ShapeType() != TopAbs_FACE) + { continue; + } bool hsd = HDS->HasSameDomain(S); if (!hsd) + { continue; + } int rkS = BDS.AncestorRank(S); if (rkS != 1) + { continue; + } const NCollection_List& lSsd = BDS.ShapeSameDomain(S); NCollection_List::Iterator itsd(lSsd); for (; itsd.More(); itsd.Next()) @@ -793,14 +855,18 @@ void TopOpeBRep_DSFiller::RemoveUnsharedGeometry( TopoDS_Shape Ssd = itsd.Value(); // xpuxpu int rkSsd = BDS.AncestorRank(Ssd); if (rkSsd == 1) + { continue; + } bool unfill = ::FUN_shareNOG(HDS, S, Ssd); unfill = unfill && FUN_ds_sdm(BDS, S, Ssd) && FUN_ds_sdm(BDS, Ssd, S); if (unfill) { if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } unfill = BREP_UnfillSameDomain(S, Ssd, HDS, *myPShapeClassifier); } } @@ -848,7 +914,9 @@ void TopOpeBRep_DSFiller::InsertIntersection2d(const TopoDS_Shape& myFacesFiller.SetPShapeClassifier(myPShapeClassifier); if (!ClearShapeSameDomain(aS1, aS2, HDS)) + { return; + } const TopoDS_Shape& S1 = aS1; const TopoDS_Shape& S2 = aS2; @@ -877,7 +945,9 @@ void TopOpeBRep_DSFiller::InsertIntersection2d(const TopoDS_Shape& if (unfill) { if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } // NYI : mettre en champs un ShapeClassifier commun a tous // NYI : les fillers TopAbs_State st1 = TopAbs_UNKNOWN, st2 = TopAbs_UNKNOWN; @@ -890,7 +960,9 @@ void TopOpeBRep_DSFiller::InsertIntersection2d(const TopoDS_Shape& { TopOpeBRepDS_DataStructure& BDS2 = HDS->ChangeDS(); if (!lFF1.IsNull() && !lFF2.IsNull()) + { BDS2.UnfillShapesSameDomain(lFF1, lFF2); + } } } @@ -931,7 +1003,9 @@ void TopOpeBRep_DSFiller::CompleteDS2d(const occ::handleAddAncestors(S1); HDS->AddAncestors(S2); @@ -1014,16 +1088,22 @@ void TopOpeBRep_DSFiller::Insert1d(const TopoDS_Shape& const bool orientFORWARD) { if (!CheckInsert(aS1, aS2)) + { return; + } TopoDS_Shape S1 = aS1; TopoDS_Shape S2 = aS2; if (orientFORWARD) { if (S1.Orientation() == TopAbs_REVERSED) + { S1.Orientation(TopAbs_FORWARD); + } if (S2.Orientation() == TopAbs_REVERSED) + { S2.Orientation(TopAbs_FORWARD); + } } TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); @@ -1067,27 +1147,33 @@ bool TopOpeBRep_DSFiller::ClearShapeSameDomain(const TopoDS_Shape& TopOpeBRepDS_DataStructure& DS = HDS->ChangeDS(); const bool b = false; if (!CheckInsert(aS1, aS2)) + { return b; + } TopExp_Explorer exp1(aS1, TopAbs_FACE), exp2(aS2, TopAbs_FACE); for (; exp1.More(); exp1.Next()) { const TopoDS_Shape& Shape1 = exp1.Current(); if (!HDS->HasShape(Shape1)) + { if (HDS->HasSameDomain(Shape1)) { NCollection_List& los = DS.ChangeShapeSameDomain(Shape1); los.Clear(); } + } } for (; exp2.More(); exp2.Next()) { const TopoDS_Shape& Shape2 = exp2.Current(); if (HDS->HasShape(Shape2)) + { if (HDS->HasSameDomain(Shape2)) { NCollection_List& los = DS.ChangeShapeSameDomain(Shape2); los.Clear(); } + } } return true; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesFiller.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesFiller.cxx index c7a1ab32ee..de9ce42b02 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesFiller.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesFiller.cxx @@ -82,12 +82,16 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& bool esd = myPEI->SameDomain(); if (esd) + { myPDS->FillShapesSameDomain(E1, E2); + } // exit if no point. myPEI->InitPoint(); if (!myPEI->MorePoint()) + { return; + } // --- Add in BDS int E1index = myPDS->AddShape(E1, 1); @@ -108,9 +112,13 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& double par1 = P2D.Parameter(1); double par2 = P2D.Parameter(2); if (!myF1.IsNull()) + { myPDS->AddShape(myF1, 1); + } if (!myF2.IsNull()) + { myPDS->AddShape(myF2, 2); + } TopOpeBRepDS_Transition T1 = P2D.Transition(1); TopOpeBRepDS_Transition T2 = P2D.Transition(2); @@ -120,11 +128,15 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& bool isvertex1 = P2D.IsVertex(1); TopoDS_Vertex V1; if (isvertex1) + { V1 = P2D.Vertex(1); + } bool isvertex2 = P2D.IsVertex(2); TopoDS_Vertex V2; if (isvertex2) + { V2 = P2D.Vertex(2); + } bool isvertex = isvertex1 || isvertex2; #ifdef OCCT_DEBUG @@ -158,7 +170,9 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& TopOpeBRepDS_Kind K; bool found = GetGeometry(itloI1, P2D, G, K); if (!found) + { MakeGeometry(P2D, G, K); + } bool foundpoint = (found) && (K == TopOpeBRepDS_POINT); bool isnewpoint = (!found) && (K == TopOpeBRepDS_POINT); @@ -188,7 +202,9 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& { const TopoDS_Shape& s = myPDS->Shape(is); if (s.ShapeType() != TopAbs_EDGE) + { continue; + } const TopoDS_Edge& e = TopoDS::Edge(s); NCollection_List> linew; @@ -218,9 +234,13 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& int gevi = 0; if (isvertex1) + { gevi = myPDS->AddShape(V1, 1); + } else if (isvertex2) + { gevi = myPDS->AddShape(V2, 2); + } bool bevi = false; TopOpeBRepDS_Config cevi = TopOpeBRepDS_UNSHGEOMETRY; double pevi = epi->Parameter(); @@ -289,7 +309,9 @@ void TopOpeBRep_EdgesFiller::Insert(const TopoDS_Shape& NCollection_List>::Iterator itEIL1(EIL1); EPIfound = GetGeometry(itEIL1, P2D, DSPindex, KKK); if (!EPIfound) + { MakeGeometry(P2D, DSPindex, KKK); + } SetShapeTransition(P2D, T1, T2); @@ -362,13 +384,21 @@ void TopOpeBRep_EdgesFiller::SetShapeTransition(const TopOpeBRep_Point2d& P2D, T2.ShapeBefore(TopAbs_EDGE); T2.ShapeAfter(TopAbs_EDGE); if (!myE1.IsNull()) + { ie1 = myPDS->AddShape(myE1, 1); + } if (!myE2.IsNull()) + { ie2 = myPDS->AddShape(myE2, 2); + } if (!myE2.IsNull()) + { T1.Index(ie2); + } if (!myE1.IsNull()) + { T2.Index(ie1); + } } else { @@ -377,13 +407,21 @@ void TopOpeBRep_EdgesFiller::SetShapeTransition(const TopOpeBRep_Point2d& P2D, T2.ShapeBefore(TopAbs_FACE); T2.ShapeAfter(TopAbs_FACE); if (!myF1.IsNull()) + { if1 = myPDS->AddShape(myF1, 1); + } if (!myF2.IsNull()) + { if2 = myPDS->AddShape(myF2, 2); + } if (!myF1.IsNull()) + { T2.Index(if1); + } if (!myF2.IsNull()) + { T1.Index(if2); + } } } @@ -439,11 +477,17 @@ bool TopOpeBRep_EdgesFiller::MakeGeometry(const TopOpeBRep_Point2d& P2D, void TopOpeBRep_EdgesFiller::Face(const int ISI, const TopoDS_Shape& F) { if (ISI == 1) + { myF1 = TopoDS::Face(F); + } else if (ISI == 2) + { myF2 = TopoDS::Face(F); + } else + { throw Standard_Failure("Face(i,f) : ISI incorrect"); + } } //================================================================================================= @@ -451,11 +495,17 @@ void TopOpeBRep_EdgesFiller::Face(const int ISI, const TopoDS_Shape& F) const TopoDS_Shape& TopOpeBRep_EdgesFiller::Face(const int ISI) const { if (ISI == 1) + { return myF1; + } else if (ISI == 2) + { return myF2; + } else + { throw Standard_Failure("Face(i) : ISI incorrect"); + } } //================================================================================================= @@ -477,13 +527,19 @@ occ::handle TopOpeBRep_EdgesFiller::StorePI( param); TopoDS_Shape Emother; if (IEmother == 1) + { Emother = myE1; + } else if (IEmother == 2) + { Emother = myE2; + } myHDS->StoreInterference(I, Emother); bool b = ToRecompute(P2D, I, IEmother); if (b) + { StoreRecompute(I, IEmother); + } return I; } @@ -503,13 +559,19 @@ occ::handle TopOpeBRep_EdgesFiller::StoreVI( TopOpeBRepDS_InterferenceTool::MakeEdgeVertexInterference(T, EI, VI, VisB, C, param); TopoDS_Shape Emother; if (IEmother == 1) + { Emother = myE1; + } else if (IEmother == 2) + { Emother = myE2; + } myHDS->StoreInterference(I, Emother); bool b = ToRecompute(P2D, I, IEmother); if (b) + { StoreRecompute(I, IEmother); + } return I; } @@ -532,9 +594,13 @@ void TopOpeBRep_EdgesFiller::StoreRecompute(const occ::handle>& LI) { if (LI.IsEmpty()) + { return; + } TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI); @@ -558,7 +626,9 @@ void TopOpeBRep_EdgesFiller::RecomputeInterferences( NCollection_List> Rloi; int nloi = loi.Extent(); if (nloi == 0) + { continue; + } occ::handle& iloi = loi.First(); TopOpeBRepDS_Transition& TU = iloi->ChangeTransition(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector.cxx index 1f30301a83..f077bcca56 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector.cxx @@ -239,7 +239,9 @@ static bool IsTangentSegment(const IntRes2d_IntersectionPoint& P1, double aResol2 = aC2.Resolution(aTolConf); if (aParDist1 * aParDist1 <= aResol1 && aParDist2 * aParDist2 <= aResol2) + { return true; + } } } @@ -279,7 +281,9 @@ bool EdgesIntersector_checkT1D(const TopoDS_Edge& E1, TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED; bool sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(E1, E2); if (!sso) + { C = TopOpeBRepDS_DIFFORIENTED; + } bool SO = (C == TopOpeBRepDS_SAMEORIENTED); bool DO = (C == TopOpeBRepDS_DIFFORIENTED); @@ -293,9 +297,13 @@ bool EdgesIntersector_checkT1D(const TopoDS_Edge& E1, bool reversed = (SO && first) || (DO && last); bool forward = (SO && last) || (DO && first); if (reversed) + { newT.Set(TopAbs_REVERSED); + } if (forward) + { newT.Set(TopAbs_FORWARD); + } return (reversed || forward); } // EdgesIntersector_checkT1D @@ -335,7 +343,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, // modified by NIZNHY-PKV Thu Nov 4 15:44:13 1999 to if (PC1.IsNull()) + { throw Standard_Failure("EdgesIntersector::Perform : no 2d curve"); + } myCurve1.Load(PC1); BRep_Tool::UVPoints(myEdge1, myFace1, pfirst, plast); @@ -359,7 +369,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, const occ::handle S1 = BRep_Tool::Surface(myFace1, L1); const occ::handle S2 = BRep_Tool::Surface(myFace2, L2); if (S1 == S2 && L1 == L2) + { memesupport = true; + } if (mySurfaceType1 == GeomAbs_Plane || memesfaces || memesupport) { @@ -395,7 +407,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, double d; bool ok = FUN_tool_projPonF(pt2, myFace1, uv2, d); if (!ok) + { return; // nyiRaise + } occ::handle aSurf1 = BRep_Tool::Surface(myFace1); bool apex = FUN_tool_onapex(uv2, aSurf1); @@ -422,7 +436,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, const TopoDS_Edge& ee = TopoDS::Edge(it.Value()); bool dgee = BRep_Tool::Degenerated(ee); if (!dgee) + { continue; + } // double f,l; PC2on1 = BRep_Tool::CurveOnSurface(ee, myFace1, first, last); } @@ -474,7 +490,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, #endif } else + { return; + } } // compute the intersection @@ -517,9 +535,13 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, // for (int p=1; p<=nbp; p++) mylpnt.Append(myIntersector.Point(p)); int p; for (p = 1; p <= nbp; p++) + { mylpnt.Append(myIntersector.Point(p)); + } for (int s = 1; s <= nbs; s++) + { mylseg.Append(myIntersector.Segment(s)); + } bool filter = true; #ifdef OCCT_DEBUG @@ -558,9 +580,13 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, fin = false; if (aTrans.TransitionType() == IntRes2d_Touch) + { mylpnt.Remove(p); + } else + { mylpnt.Remove(p + 1); + } nbp--; } // Modified by Sergey KHROMOV - Fri Jan 11 10:31:39 2002 End @@ -584,7 +610,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, MakePoints2d(); if (ReduceSegment) + { ReduceSegments(); + } // xpu010998 : cto900J1, e5 sdm e13, IntPatch (Touch,Inside) -> // faulty INTERNAL transition at G=v9 : @@ -614,7 +642,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, TopOpeBRepDS_Transition newT; bool computed = ::EdgesIntersector_checkT1D(myEdge1, myEdge2, V2, newT); if (computed) + { T1.Set(newT.Orientation(TopAbs_IN)); + } } bool T2INT = (T2.Orientation(TopAbs_IN) == TopAbs_INTERNAL); @@ -626,7 +656,9 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, TopOpeBRepDS_Transition newT; bool computed = ::EdgesIntersector_checkT1D(myEdge2, myEdge1, V1, newT); if (computed) + { T2.Set(newT.Orientation(TopAbs_IN)); + } } // xpu121098 : cto900I7 (e12on,vG14) @@ -634,12 +666,16 @@ void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1, bool clE2 = TopOpeBRepTool_TOOL::ClosedE(myEdge2, vcl2); bool nT1 = (!T1INT && clE2 && isvertex22 && vcl2.IsSame(P2D.Vertex(2))); if (nT1) + { T1.Set(TopAbs_INTERNAL); + } TopoDS_Vertex vcl1; bool clE1 = TopOpeBRepTool_TOOL::ClosedE(myEdge1, vcl1); bool nT2 = (!T2INT && clE1 && isvertex11 && vcl1.IsSame(P2D.Vertex(1))); if (nT2) + { T2.Set(TopAbs_INTERNAL); + } } // (isvertex && esd) } // MorePoint @@ -677,14 +713,20 @@ bool TopOpeBRep_EdgesIntersector::ComputeSameDomain() GeomAbs_CurveType t2 = C2.GetType(); if (!myHasSegment) + { return SetSameDomain(false); + } bool tt = (t1 == t2); if (!tt) + { return SetSameDomain(false); + } if (t1 == GeomAbs_Line) + { return SetSameDomain(true); + } if (t1 != GeomAbs_Circle) { @@ -702,7 +744,8 @@ bool TopOpeBRep_EdgesIntersector::ComputeSameDomain() // bool rr = (r1 == r2); // clang-format off bool rr = (std::abs(r1-r2) < Precision::Confusion()); //xpu281098 (cto019D2) tolerance a revoir - if (!rr) return SetSameDomain(false); + if (!rr) { return SetSameDomain(false); +} const gp_Pnt2d& p1 = c1.Location(); const gp_Pnt2d& p2 = c2.Location(); @@ -717,7 +760,9 @@ bool TopOpeBRep_EdgesIntersector::ComputeSameDomain() double tol = tol1 + tol2; bool esd = (dpp <= tol); if (esd) + { return SetSameDomain(true); + } return SetSameDomain(false); } // ComputeSameDomain @@ -749,11 +794,15 @@ void TopOpeBRep_EdgesIntersector::MakePoints2d() bool isv1 = IsVertex1(1); p2d.SetIsVertex(1, isv1); if (isv1) + { p2d.SetVertex(1, TopoDS::Vertex(Vertex1(1))); + } bool isv2 = IsVertex1(2); p2d.SetIsVertex(2, isv2); if (isv2) + { p2d.SetVertex(2, TopoDS::Vertex(Vertex1(2))); + } p2d.SetIsPointOfSegment(IsPointOfSegment1()); p2d.SetSegmentAncestors(0, 0); p2d.SetStatus(Status1()); @@ -841,16 +890,24 @@ bool TopOpeBRep_EdgesIntersector::ReduceSegment(TopOpeBRep_Point2d& psa, bool isvpsa1 = psa.IsVertex(1); if (isvpsa1) + { Pn.SetVertex(1, psa.Vertex(1)); + } bool isvpsa2 = psa.IsVertex(2); if (isvpsa2) + { Pn.SetVertex(2, psa.Vertex(2)); + } bool isvpsb1 = psb.IsVertex(1); if (isvpsb1) + { Pn.SetVertex(1, psb.Vertex(1)); + } bool isvpsb2 = psb.IsVertex(2); if (isvpsb2) + { Pn.SetVertex(2, psb.Vertex(2)); + } } return reduced; @@ -862,7 +919,9 @@ void TopOpeBRep_EdgesIntersector::ReduceSegments() { bool condredu = (myHasSegment && !mySameDomain); if (!condredu) + { return; + } int ip = 1; int np = mynp2d; @@ -913,11 +972,17 @@ bool TopOpeBRep_EdgesIntersector::SameDomain() const const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Edge(const int Index) const { if (Index == 1) + { return myEdge1; + } else if (Index == 2) + { return myEdge2; + } else + { throw Standard_Failure("TopOpeBRep_EdgesIntersector::Edge"); + } } //================================================================================================= @@ -925,11 +990,17 @@ const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Edge(const int Index) const const Geom2dAdaptor_Curve& TopOpeBRep_EdgesIntersector::Curve(const int Index) const { if (Index == 1) + { return myCurve1; + } else if (Index == 2) + { return myCurve2; + } else + { throw Standard_Failure("TopOpeBRep_EdgesIntersector::Curve"); + } } //================================================================================================= @@ -937,11 +1008,17 @@ const Geom2dAdaptor_Curve& TopOpeBRep_EdgesIntersector::Curve(const int Index) c const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Face(const int Index) const { if (Index == 1) + { return myFace1; + } else if (Index == 2) + { return myFace2; + } else + { throw Standard_Failure("TopOpeBRep_EdgesIntersector::Face"); + } } //================================================================================================= @@ -949,11 +1026,17 @@ const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Face(const int Index) const const BRepAdaptor_Surface& TopOpeBRep_EdgesIntersector::Surface(const int Index) const { if (Index == 1) + { return *mySurface1; + } else if (Index == 2) + { return *mySurface2; + } else + { throw Standard_Failure("TopOpeBRep_EdgesIntersector::Surface"); + } } //================================================================================================= @@ -1006,9 +1089,13 @@ void TopOpeBRep_EdgesIntersector::Find() { bool kf = mysp2d(myip2d).Keep(); if (kf) + { break; + } else + { myip2d++; + } } else { @@ -1036,7 +1123,9 @@ const TopOpeBRep_Point2d& TopOpeBRep_EdgesIntersector::Point() const const TopOpeBRep_Point2d& TopOpeBRep_EdgesIntersector::Point(const int I) const { if (I < 1 || I > mysp2d.Length()) + { throw Standard_Failure("TopOpeBRep_EdgesIntersector::Point(I)"); + } return mysp2d(I); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector_1.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector_1.cxx index 424078f471..0279eb6122 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector_1.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_EdgesIntersector_1.cxx @@ -32,7 +32,9 @@ const IntRes2d_IntersectionSegment& TopOpeBRep_EdgesIntersector::Segment1() const { if (!IsPointOfSegment1()) + { throw Standard_Failure("TopOpeBRep_EdgesIntersector : Not a segment point"); + } int iseg = 1 + (myPointIndex - myNbPoints - 1) / 2; return mylseg.Value(iseg); } @@ -81,9 +83,13 @@ const IntRes2d_IntersectionPoint& TopOpeBRep_EdgesIntersector::Point1() const { // point is a point of segment int i = myPointIndex - myNbPoints - 1; if (i % 2 == 0) + { return Segment1().FirstPoint(); + } else + { return Segment1().LastPoint(); + } } } @@ -99,9 +105,13 @@ TopOpeBRep_P2Dstatus TopOpeBRep_EdgesIntersector::Status1() const { // point is a point of segment int i = myPointIndex - myNbPoints - 1; if (i % 2 == 0) + { return TopOpeBRep_P2DSGF; + } else + { return TopOpeBRep_P2DSGL; + } } } @@ -222,8 +232,10 @@ TopOpeBRepDS_Transition TopOpeBRep_EdgesIntersector::Transition1( staB = staINON; staA = staINON; } - else // Middle/Middle is impossible + else + { // Middle/Middle is impossible throw Standard_Failure("TopOpeBRep_EdgesIntersector : Situation Unknown MM"); + } } else { // posother = Head or End @@ -335,9 +347,13 @@ TopOpeBRepDS_Transition TopOpeBRep_EdgesIntersector::Transition1( double TopOpeBRep_EdgesIntersector::Parameter1(const int Index) const { if (Index == 1) + { return Point1().ParamOnFirst(); + } else + { return Point1().ParamOnSecond(); + } } //================================================================================================= @@ -347,15 +363,21 @@ bool TopOpeBRep_EdgesIntersector::IsVertex1(const int Index) // check if last IsVertex1() call has been performed // on current point and with same . if (myIsVertexPointIndex == myPointIndex && myIsVertexIndex == Index) + { return myIsVertexValue; + } // search if current point is a vertex of edge myIsVertexValue = false; IntRes2d_Position pos; if (Index == 1) + { pos = Point1().TransitionOfFirst().PositionOnCurve(); + } else + { pos = Point1().TransitionOfSecond().PositionOnCurve(); + } if (pos == IntRes2d_Middle) { @@ -386,9 +408,13 @@ bool TopOpeBRep_EdgesIntersector::IsVertex1(const int Index) { // pos = head or end TopoDS_Vertex V1, V2; if (Index == 1) + { TopExp::Vertices(myEdge1, V1, V2); + } else + { TopExp::Vertices(myEdge2, V1, V2); + } if (pos == IntRes2d_Head && !V1.IsNull()) { myIsVertexValue = true; @@ -416,7 +442,9 @@ bool TopOpeBRep_EdgesIntersector::IsVertex1(const int Index) const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Vertex1(const int Index) { if (!IsVertex1(Index)) + { throw Standard_Failure("TopOpeBRep_EdgesIntersector : Vertex1"); + } return myIsVertexVertex; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FFTransitionTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FFTransitionTool.cxx index c7df789f35..cbdf0d0a6f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FFTransitionTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FFTransitionTool.cxx @@ -110,7 +110,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessLineTransition( if (Odefined) { if (EdgeOrientation == TopAbs_REVERSED) + { O = TopAbs::Complement(O); + } TT.Set(O); } else @@ -145,11 +147,17 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessLineTransition( double par = P.ParameterOnLine(); if (par == par1) + { result = TopAbs_FORWARD; + } else if (par == parn) + { result = TopAbs_REVERSED; + } else + { result = TopAbs_INTERNAL; + } TT.Set(result); return TT; @@ -177,16 +185,22 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessEdgeTransition( { IntSurf_Transition T; if (Index == 1) + { T = P.TransitionOnS1(); + } else if (Index == 2) + { T = P.TransitionOnS2(); + } TopAbs_Orientation O; bool defined = ::TransitionToOrientation(T, O); if (defined) { if (FaceTransition == TopAbs_REVERSED) + { O = TopAbs::Complement(O); + } TT.Set(O); } else @@ -269,7 +283,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessFaceTransition( if (Odefined) { if (FaceOrientation == TopAbs_REVERSED) + { O = TopAbs::Complement(O); + } TT.Set(O); } else @@ -389,9 +405,13 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessEdgeONTransition( const occ::handle& S = BRep_Tool::Surface(F); double U = 0., V = 0.; if (ShapeIndex == 1) + { VP.ParametersOnS1(U, V); + } else if (ShapeIndex == 2) + { VP.ParametersOnS2(U, V); + } double fE, lE; const occ::handle& CE = BRep_Tool::Curve(E, fE, lE); @@ -406,7 +426,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FFTransitionTool::ProcessEdgeONTransition( { // Trans : transition sur R en croisant l'arete E orientee dans la face F if (oriE == TopAbs_REVERSED) + { Trans = Trans.Complement(); + } } return Trans; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeFiller.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeFiller.cxx index 1e8d6f521a..07a52477ab 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeFiller.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeFiller.cxx @@ -48,7 +48,9 @@ void TopOpeBRep_FaceEdgeFiller::Insert(const TopoDS_Shape& // exit if no point. FEINT.InitPoint(); if (!FEINT.MorePoint()) + { return; + } TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); @@ -97,7 +99,9 @@ void TopOpeBRep_FaceEdgeFiller::Insert(const TopoDS_Shape& NCollection_List>::Iterator itEIL1(EIL1); EPIfound = GetGeometry(itEIL1, FEINT, DSPindex, BDS); if (!EPIfound) + { DSPindex = MakeGeometry(FEINT, BDS); + } // sur FF // NYI : FacePointInterference : on ajoute un point INTERNAL a F @@ -190,7 +194,9 @@ bool TopOpeBRep_FaceEdgeFiller::ScanInterfList( int DSPG = IT.Value()->Geometry(); const TopOpeBRepDS_Point& otherDSP = BDS.Point(DSPG); if (TopOpeBRep_PointGeomTool::IsEqual(DSP, otherDSP)) + { return true; + } } return false; } @@ -206,7 +212,9 @@ bool TopOpeBRep_FaceEdgeFiller::GetGeometry( TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(FEINT); bool found = ScanInterfList(IT, DSP, BDS); if (found) + { G = IT.Value()->Geometry(); + } return found; } @@ -221,9 +229,13 @@ bool TopOpeBRep_FaceEdgeFiller::GetGeometry( NCollection_List>::Iterator itI(L); bool Ifound = ScanInterfList(itI, DSP, BDS); if (Ifound) + { G = itI.Value()->Geometry(); + } else + { G = BDS.AddPoint(DSP); + } return Ifound; // interference found or not } @@ -288,11 +300,17 @@ int TopOpeBRep_FaceEdgeFiller::MakeGeometry(TopOpeBRep_FaceEdgeIntersector& FEIN if (isvertex) { if (isvertexF) + { G = BDS.AddShape(V1, 1); + } else if (isvertexE) + { G = BDS.AddShape(V2, 2); + } } else + { G = BDS.AddPoint(TopOpeBRep_PointGeomTool::MakePoint(FEINT)); + } return G; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeIntersector.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeIntersector.cxx index 2fa439f741..74fef3f153 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeIntersector.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FaceEdgeIntersector.cxx @@ -75,7 +75,9 @@ void TopOpeBRep_FaceEdgeIntersector::Perform(const TopoDS_Shape& SF, const TopoD { ResetIntersection(); if (!myForceTolerance) + { ShapeTolerances(SF, SE); + } myTol = BRep_Tool::Tolerance(TopoDS::Edge(SE)); #ifdef OCCT_DEBUG if (TopOpeBRep_GettraceFITOL()) @@ -137,11 +139,17 @@ bool TopOpeBRep_FaceEdgeIntersector::IsEmpty() const TopoDS_Shape& TopOpeBRep_FaceEdgeIntersector::Shape(const int Index) const { if (Index == 1) + { return myFace; + } else if (Index == 2) + { return myEdge; + } else + { throw Standard_ProgramError("TopOpeBRep_FaceEdgeIntersector::Shape"); + } } //================================================================================================= @@ -270,13 +278,21 @@ TopOpeBRepDS_Transition TopOpeBRep_FaceEdgeIntersector::Transition( TopOpeBRepDS_Transition TR; TopAbs_ShapeEnum onB = TopAbs_FACE, onA = TopAbs_FACE; if (FaceOrientation == TopAbs_FORWARD) + { TR.Set(stB, stA, onB, onA); + } else if (FaceOrientation == TopAbs_REVERSED) + { TR.Set(stA, stB, onA, onB); + } else if (FaceOrientation == TopAbs_EXTERNAL) + { TR.Set(TopAbs_OUT, TopAbs_OUT, onA, onB); + } else if (FaceOrientation == TopAbs_INTERNAL) + { TR.Set(TopAbs_IN, TopAbs_IN, onA, onB); + } return TR; } @@ -301,7 +317,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FaceEdgeIntersector::Transition( } else + { throw Standard_ProgramError("FEINT Transition Index"); + } } //================================================================================================= @@ -337,9 +355,13 @@ bool TopOpeBRep_FaceEdgeIntersector::IsVertex(const int I, TopoDS_Vertex& VR) bool isv = false; gp_Pnt P = Value(); if (I == 1) + { isv = IsVertex(myFace, P, myTol, VR); + } else if (I == 2) + { isv = IsVertex(myEdge, P, myTol, VR); + } return isv; } @@ -380,12 +402,16 @@ double TopOpeBRep_FaceEdgeIntersector::ToleranceMax(const TopoDS_Shape& S, { TopExp_Explorer e(S, T); if (!e.More()) + { return Precision::Intersection(); + } else { double tol = RealFirst(); for (; e.More(); e.Next()) + { tol = std::max(tol, TopOpeBRepTool_ShapeTool::Tolerance(e.Current())); + } return tol; } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller.cxx index 9550abaa20..6a72c377c0 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller.cxx @@ -59,9 +59,13 @@ Standard_EXPORT bool FUN_projPonL(const gp_Pnt& P, { BRepAdaptor_Curve2d BAC2D; if (Esi == 1) + { BAC2D.Initialize(E, FF.Face(1)); + } else if (Esi == 2) + { BAC2D.Initialize(E, FF.Face(2)); + } paramLdef = FUN_tool_projPonC2D(P, BAC2D, paramL, dist); } return paramLdef; @@ -122,7 +126,9 @@ void TopOpeBRep_FacesFiller::Insert(const TopoDS_Shape& myHDS = HDS; myDS = &(HDS->ChangeDS()); if (myPShapeClassifier == nullptr) + { myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier(); + } #ifdef OCCT_DEBUG int exF1, exF2; @@ -197,7 +203,9 @@ void TopOpeBRep_FacesFiller::LoadLine(TopOpeBRep_LineInter& L) L.SetOK(bchk); myLineOK = bchk; if (!myLineOK) + { return; + } L.ComputeFaceFaceTransition(); } // LoadLine @@ -236,7 +244,9 @@ bool TopOpeBRep_FacesFiller::CheckLine(TopOpeBRep_LineInter& L) const { const TopOpeBRep_VPointInter& VP = VPI.CurrentVP(); if (VP.Keep()) + { np++; + } } if (np != 2) { @@ -249,28 +259,42 @@ bool TopOpeBRep_FacesFiller::CheckLine(TopOpeBRep_LineInter& L) const { const TopOpeBRep_VPointInter& VP = VPI.CurrentVP(); if (!VP.Keep()) + { continue; + } np++; if (np == 1) + { A = VP; + } if (np == 2) + { B = VP; + } } bool isAV1 = A.IsVertexOnS1(); bool isAV2 = A.IsVertexOnS2(); TopoDS_Shape V1; if (isAV1) + { V1 = A.VertexOnS1(); + } if (isAV2) + { V1 = A.VertexOnS2(); + } bool isBV1 = B.IsVertexOnS1(); bool isBV2 = B.IsVertexOnS2(); TopoDS_Shape V2; if (isBV1) + { V2 = B.VertexOnS1(); + } if (isBV2) + { V2 = B.VertexOnS2(); + } if (!V1.IsNull() && (V1.IsSame(V2))) { @@ -359,7 +383,9 @@ void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_FacesIntersector&) const TopOpeBRep_TypeLineCurve tl = L.TypeLineCurve(); bool ok = (tl == TopOpeBRep_RESTRICTION); if (ok) + { VP_Position(L); + } } for (myFacesIntersector->InitLine(); myFacesIntersector->MoreLine(); @@ -369,7 +395,9 @@ void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_FacesIntersector&) const TopOpeBRep_TypeLineCurve tl = L.TypeLineCurve(); bool ok = (tl != TopOpeBRep_RESTRICTION); if (ok) + { VP_Position(L); + } } } @@ -381,9 +409,13 @@ void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_LineInter& L) bool isrest = (L.TypeLineCurve() == TopOpeBRep_RESTRICTION); if (!isrest) + { VP_PositionOnL(L); + } else + { VP_PositionOnR(L); + } L.SetVPBounds(); } @@ -408,11 +440,15 @@ void TopOpeBRep_FacesFiller::VP_PositionOnL(TopOpeBRep_LineInter& L) for (iOL = 1; iOL <= n; iOL++) { if (iOL == Lindex) + { continue; + } TopOpeBRep_LineInter& OL = FI.ChangeLine(iOL); VPequalVPONRESTRICTION = PequalVPonR(P3D, VPsi, VP, OL); if (VPequalVPONRESTRICTION) + { break; + } } if (!VPequalVPONRESTRICTION) @@ -436,14 +472,20 @@ void TopOpeBRep_FacesFiller::VP_PositionOnR(TopOpeBRep_LineInter& L) const TopoDS_Edge& earc = TopoDS::Edge(L.Arc()); bool hasc3d = FC2D_HasC3D(earc); if (hasc3d) + { isline = FUN_tool_line(earc); + } else { BRepAdaptor_Curve2d BAC2D; if (Esi == 1) + { BAC2D.Initialize(earc, myF1); + } else if (Esi == 2) + { BAC2D.Initialize(earc, myF2); + } GeomAbs_CurveType t = BAC2D.GetType(); isline = (t == GeomAbs_Line); } @@ -456,14 +498,18 @@ void TopOpeBRep_FacesFiller::VP_PositionOnR(TopOpeBRep_LineInter& L) if (isvertex) { if (!isline) + { VP_Position(VP, VPC); + } continue; } bool OOisvertex = VP.IsVertex(OOEsi); if (OOisvertex) { if (!isline) + { VP_Position(VP, VPC); + } continue; } @@ -538,7 +584,9 @@ void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_VPointInter& VP, bool AssumeINON = false; if (myLine) + { AssumeINON = (myLine->TypeLineCurve() != TopOpeBRep_RESTRICTION); + } // modified by NIZHNY-MKK Fri Oct 27 14:50:28 2000.BEGIN // double tol = Precision::Confusion(); @@ -549,9 +597,13 @@ void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_VPointInter& VP, // modified by NIZHNY-MKK Fri Oct 27 14:50:36 2000.END if (c1) + { VPC.VPointPosition(myF1, VP, 1, myPointClassifier, AssumeINON, tol); + } if (c2) + { VPC.VPointPosition(myF2, VP, 2, myPointClassifier, AssumeINON, tol); + } } //================================================================================================= @@ -564,7 +616,9 @@ bool TopOpeBRep_FacesFiller::PequalVPonR(const gp_Pnt& P3D, const TopOpeBRep_TypeLineCurve tOL = Lrest.TypeLineCurve(); bool OLok = (tOL == TopOpeBRep_RESTRICTION); if (!OLok) + { return false; + } bool VPequalVPONRESTRICTION = false; const TopoDS_Edge& EOL = TopoDS::Edge(Lrest.Arc()); @@ -579,15 +633,21 @@ bool TopOpeBRep_FacesFiller::PequalVPonR(const gp_Pnt& P3D, bool VPOLisvertex = false; VPOLisvertex = VPOL.IsVertex(1); if (VPOLisvertex) + { continue; + } bool diffsi = (VPOLsi != VPsi); if (diffsi) + { continue; + } TopAbs_State stateEsi = VPOL.State(EOLsi); if (stateEsi != TopAbs_ON) + { continue; + } const gp_Pnt& P3DOL = VPOL.Value(); double tolE = BRep_Tool::Tolerance(EOL); @@ -630,9 +690,13 @@ TopOpeBRepDS_DataStructure& TopOpeBRep_FacesFiller::ChangeDataStructure() const TopoDS_Face& TopOpeBRep_FacesFiller::Face(const int I) const { if (I == 1) + { return myF1; + } else if (I == 2) + { return myF2; + } throw Standard_ProgramError("FacesFiller::Face"); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller_1.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller_1.cxx index 4d22a4a1f4..a0c5770bee 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller_1.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesFiller_1.cxx @@ -123,7 +123,9 @@ static bool FUN_IwithsuppiS(const NCollection_List& I = it.Value(); if (I->Support() == iS) + { loIfound.Append(I); + } } bool ok = (loIfound.Extent() > 0); return ok; @@ -138,7 +140,9 @@ static bool FUN_IwithsuppkS(const NCollection_List& I = it.Value(); if (I->SupportType() == kS) + { loIfound.Append(I); + } } bool ok = (loIfound.Extent() > 0); return ok; @@ -153,7 +157,9 @@ static bool FUN_IwithToniS(const NCollection_List& I = it.Value(); if (I->Transition().Index() == iS) + { loIfound.Append(I); + } } bool ok = (loIfound.Extent() > 0); return ok; @@ -168,7 +174,9 @@ static bool FUN_supponF(const TopOpeBRepDS_PDataStructure // = list of support S / I in : I = (T,G,S = Edge on ); bool ok = (0 < iF) && (iF <= pDS->NbShapes()); if (!ok) + { return false; + } NCollection_IndexedMap MOOE; TopExp::MapShapes(pDS->Shape(iF), TopAbs_EDGE, MOOE); @@ -180,7 +188,9 @@ static bool FUN_supponF(const TopOpeBRepDS_PDataStructure TopOpeBRepDS_Kind skind = I->SupportType(); bool add = false; if (skind == TopOpeBRepDS_EDGE) + { add = MOOE.Contains(pDS->Shape(iS)); + } if (add) { losupp.Append(iS); @@ -231,7 +241,9 @@ static bool FUN_findTF(const TopOpeBRepDS_PDataStructure pDS, NCollection_List> lITonOOF; bool ok = FUN_IwithToniS(pDS->ShapeInterferences(iE), iOOF, lITonOOF); if (!ok) + { return false; + } NCollection_List> lITOOFskFACE; bool found = FUN_IwithsuppkS(lITonOOF, TopOpeBRepDS_FACE, lITOOFskFACE); if (found) @@ -249,7 +261,9 @@ static bool FUN_findTF(const TopOpeBRepDS_PDataStructure pDS, bool done = false; NCollection_List> lITOOFskEDGE; if (!found) + { done = FUN_IwithsuppkS(lITonOOF, TopOpeBRepDS_EDGE, lITOOFskEDGE); + } if (done) { // Ifound on : Ifound = (T(on face OOF), S=FACE, G=POINT/VERTEX on ) @@ -260,7 +274,9 @@ static bool FUN_findTF(const TopOpeBRepDS_PDataStructure pDS, double paronE; bool OOdone = FDS_Parameter(Ifound, paronE); if (!OOdone) + { return false; + } const TopoDS_Edge& E = TopoDS::Edge(pDS->Shape(iE)); const TopoDS_Face& OOF = TopoDS::Face(pDS->Shape(iOOF)); @@ -276,29 +292,39 @@ static bool FUN_findTF(const TopOpeBRepDS_PDataStructure pDS, double oopar; bool ok1 = FUN_tool_parE(E, paronE, OOE, oopar); if (!ok1) + { return false; + } gp_Pnt2d uv; ok1 = FUN_tool_paronEF(OOE, oopar, OOF, uv); if (!ok1) + { return false; + } ok = MKT.Initialize(E, f, l, paronE, OOF, uv, factor); if (ok) + { ok = MKT.SetRest(OOE, oopar); + } } else { gp_Pnt2d uv; bool ok1 = FUN_tool_parF(E, paronE, OOF, uv); if (!ok1) + { return false; + } ok = MKT.Initialize(E, f, l, paronE, OOF, uv, factor); } TopAbs_State stb, sta; ok = MKT.MkTonE(stb, sta); if (!ok) + { return false; + } TF.Before(stb); TF.After(sta); return true; @@ -336,13 +362,19 @@ static bool FUN_findTOOF(const TopOpeBRepDS_PDataStructure pDS, { NCollection_List>::Iterator it(lIsuppOOE); for (; it.More(); it.Next()) + { liOOEGonE.Append(it.Value()->Support()); + } } } else + { ok = FUN_supponF(pDS, loIE, iOOF, lIsuppOOE, liOOEGonE); + } if (!ok) + { return false; + } // TopAbs_Orientation oritransOOE; @@ -372,7 +404,9 @@ static bool FUN_findTOOF(const TopOpeBRepDS_PDataStructure pDS, double paronE; OOdone = FDS_Parameter(Ifound, paronE); if (!OOdone) + { return false; + } const TopoDS_Edge& E = TopoDS::Edge(pDS->Shape(iE)); const TopoDS_Face& F = TopoDS::Face(pDS->Shape(iF)); @@ -380,11 +414,15 @@ static bool FUN_findTOOF(const TopOpeBRepDS_PDataStructure pDS, double oopar; bool ok1 = FUN_tool_parE(E, paronE, OOE, oopar); if (!ok1) + { return false; + } gp_Pnt2d uv; ok1 = FUN_tool_paronEF(E, paronE, F, uv); if (!ok1) + { return false; + } double f, l; FUN_tool_bounds(OOE, f, l); @@ -392,9 +430,13 @@ static bool FUN_findTOOF(const TopOpeBRepDS_PDataStructure pDS, TopOpeBRepTool_makeTransition MKT; OOdone = MKT.Initialize(OOE, f, l, oopar, F, uv, factor); if (OOdone) + { OOdone = MKT.SetRest(E, paronE); + } if (OOdone) + { OOdone = MKT.MkTonE(stb, sta); + } if (OOdone) { TOOF.Before(stb); @@ -409,7 +451,7 @@ Standard_EXPORT bool GLOBAL_btcx = false; Standard_EXPORT void debtcxmess(int f1, int f2, int il) { - std::cout << "f1,f2,il : " << f1 << "," << f2 << "," << il << std::endl; + std::cout << "f1,f2,il : " << f1 << "," << f2 << "," << il << '\n'; std::cout.flush(); } @@ -419,18 +461,26 @@ void TopOpeBRep_FacesFiller::ProcessLine() { bool reject = (!myLineOK || myLine == nullptr); if (reject) + { return; + } ResetDSC(); bool HasVPonR = myLine->HasVPonR(); if (HasVPonR) + { FillLineVPonR(); + } else + { FillLine(); + } bool inl = myLine->INL(); if (inl) + { return; + } myHDS->SortOnParameter(myDSCIL); @@ -490,7 +540,9 @@ void TopOpeBRep_FacesFiller::ProcessVPnotonR(const TopOpeBRep_VPointInter& VP) { bool found = GetFFGeometry(VP, PVKind, PVIndex); if (!found) + { PVIndex = MakeGeometry(VP, ShapeIndex, PVKind); + } } TopOpeBRepDS_Transition transLine; @@ -503,9 +555,13 @@ void TopOpeBRep_FacesFiller::ProcessVPnotonR(const TopOpeBRep_VPointInter& VP) else { if (iVP == iINON1) + { transLine.Set(TopAbs_FORWARD); + } else if (iVP == iINONn) + { transLine.Set(TopAbs_REVERSED); + } } double parline = VP.ParameterOnLine(); @@ -532,7 +588,9 @@ void TopOpeBRep_FacesFiller::ProcessVPR(TopOpeBRep_FacesFiller& FF, // --- check interiority of VPoint to the restrictions bool tokeep = VP.Keep(); if (!tokeep) + { return; + } int ShapeIndex = VP.ShapeIndex(); @@ -556,7 +614,9 @@ void TopOpeBRep_FacesFiller::ProcessVPR(TopOpeBRep_FacesFiller& FF, int shin1 = 1; if (isV2 && !isV1) + { shin1 = 2; + } if (shin1 == 1) { @@ -593,12 +653,16 @@ void TopOpeBRep_FacesFiller::ProcessRLine() bool addIFE = true; if (!addIFE) + { return; + } const TopoDS_Edge& Erest = TopoDS::Edge(myLine->Arc()); bool FIisrest = myFacesIntersector->IsRestriction(Erest); if (!FIisrest) + { return; + } bool isedge1 = myLine->ArcIsEdge(1); bool isedge2 = myLine->ArcIsEdge(2); @@ -644,9 +708,13 @@ void TopOpeBRep_FacesFiller::ProcessRLine() if (OOTok) { if (OOrank == 1) + { FDS_SetT(T1, T); + } else + { FDS_SetT(T2, T); + } } } // !findTOOF if (findTF) @@ -658,9 +726,13 @@ void TopOpeBRep_FacesFiller::ProcessRLine() if (Tok) { if (rank == 1) + { FDS_SetT(T1, T); + } else + { FDS_SetT(T2, T); + } } } T1unk = T1.IsUnknown(); @@ -694,7 +766,9 @@ void TopOpeBRep_FacesFiller::ProcessRLine() double parRest; bool okR = VP.ParonE(Erest, parRest); if (!okR) + { parRest = VP.ParameterOnLine(); + } bool on2edges = (absindex == 3) || (absindex == OOrank); if (!on2edges) @@ -781,7 +855,9 @@ void TopOpeBRep_FacesFiller::ProcessRLine() // xpu091198 : 1d interf done in EdgesFiller processing (cto cylcong *) bool sdmeds = FUN_ds_sdm((*myDS), Erest, OOE); if (sdmeds) + { continue; + } // clang-format off int obRest = TopOpeBRepTool_TOOL::OnBoundary(parRest,Erest); //vertex can be missed @@ -871,18 +947,26 @@ void TopOpeBRep_FacesFiller::ProcessRLine() if (condmake) { if (SIisvertex) + { PVIndex = MakeGeometry(VP, ShapeIndex, PVKind); + } else if (OOisvertex) + { PVIndex = MakeGeometry(VP, OOShapeIndex, PVKind); + } else + { PVIndex = MakeGeometry(VP, ShapeIndex, PVKind); + } } } // transEdge : // ---------- if (OOedgeIndex == 0) + { OOedgeIndex = myDS->AddShape(OOedge, OOShapeIndex); + } const TopOpeBRepDS_Transition& llt1 = FaceFaceTransition(1); const TopOpeBRepDS_Transition& llt2 = FaceFaceTransition(2); TopOpeBRepDS_Transition Trans = (ShapeIndex == 1) ? llt1 : llt2; @@ -927,14 +1011,20 @@ void TopOpeBRep_FacesFiller::ProcessRLine() TopAbs_Orientation oOO; bool ok = FUN_tool_orientEinFFORWARD(OOedge, OOFace, oOO); if (!ok) + { continue; + } if (M_INTERNAL(oOO)) + { OVP = TopAbs_INTERNAL; + } // xpu240399 : cto015I2 (e15,v16) // edge and OOedge are tangent, we do not keep the orientation if (!tgeds) + { transEdge.Set(OVP); + } } else { @@ -951,14 +1041,18 @@ void TopOpeBRep_FacesFiller::ProcessRLine() myERL, Tr); if (!ok) + { continue; + } transEdge.Before(Tr.Before()); transEdge.After(Tr.After()); } } // Tunk Tunk = FDS_hasUNK(transEdge); if (Tunk) + { continue; + } TopAbs_Orientation otransEdge = transEdge.Orientation(TopAbs_IN); const NCollection_List>& lIedge = @@ -968,7 +1062,9 @@ void TopOpeBRep_FacesFiller::ProcessRLine() NCollection_List> l1, l2; int nfound = FUN_selectGIinterference(copy, PVIndex, l1); if (OOedgeIndex != 0) + { nfound = FUN_selectSIinterference(l1, OOedgeIndex, l2); + } if (nfound) { if (sdmeds) @@ -976,18 +1072,26 @@ void TopOpeBRep_FacesFiller::ProcessRLine() NCollection_List> l3, l4; nfound = FUN_selectITRASHAinterference(l2, OOedgeIndex, l3); if (nfound != 0) + { nfound = FUN_selectTRAORIinterference(l3, otransEdge, l4); + } if (nfound) + { continue; // has I1d=(transEdge(OOedgeIndex),PVIndex,OOedgeIndex); + } } else if (iOOFace != 0) { NCollection_List> l3, l4; nfound = FUN_selectITRASHAinterference(l2, iOOFace, l3); if (nfound != 0) + { nfound = FUN_selectTRAORIinterference(l3, otransEdge, l4); + } if (nfound) + { continue; // has I2d=(transEdge(iOOFace),PVIndex,OOedgeIndex) + } } } // nfound @@ -996,7 +1100,9 @@ void TopOpeBRep_FacesFiller::ProcessRLine() occ::handle EPI; { if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } TopOpeBRepDS_Transition T = transEdge; T.Index(iOOFace); EPI = MakeEPVInterference(T, OOedgeIndex, PVIndex, paredge, PVKind, SIisvertex); @@ -1024,7 +1130,9 @@ static bool FUN_haslastvpon0(const TopOpeBRep_LineInter& L) { const bool wline = (L.TypeLineCurve() == TopOpeBRep_WALKING); if (!wline) + { return false; + } int iINON1, iINONn, nINON; L.VPBounds(iINON1, iINONn, nINON); @@ -1037,7 +1145,9 @@ static bool FUN_haslastvpon0(const TopOpeBRep_LineInter& L) const int absindex = VP.ShapeIndex(); const int iVP = VP.Index(); if (iVP == iINONn && absindex == 0) + { return true; + } } return false; } @@ -1113,7 +1223,9 @@ void TopOpeBRep_FacesFiller::FillLine() int iINON1, iINONn, nINON; myLine->VPBounds(iINON1, iINONn, nINON); if (nINON == 0) + { return; + } int ShapeIndex = 0; occ::handle CPI; @@ -1124,7 +1236,9 @@ void TopOpeBRep_FacesFiller::FillLine() const TopOpeBRep_VPointInter& VP = VPI.CurrentVP(); if (!VP.Keep()) + { continue; + } int PVIndex; TopOpeBRepDS_Kind PVKind; @@ -1135,7 +1249,9 @@ void TopOpeBRep_FacesFiller::FillLine() { bool found = GetFFGeometry(VP, PVKind, PVIndex); if (!found) + { PVIndex = MakeGeometry(VP, ShapeIndex, PVKind); + } } TopOpeBRepDS_Transition transLine; @@ -1143,12 +1259,18 @@ void TopOpeBRep_FacesFiller::FillLine() { int iVP = VPI.CurrentVPIndex(); if (iVP == iINON1) + { transLine.Set(TopAbs_FORWARD); + } else if (iVP == iINONn) + { transLine.Set(TopAbs_REVERSED); + } } else + { transLine = itCPIL.Value()->Transition().Complement(); + } double parline = VPI.CurrentVP().ParameterOnLine(); CPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference(transLine, @@ -1169,11 +1291,15 @@ void TopOpeBRep_FacesFiller::AddShapesLine() { bool dscilemp = myDSCIL.IsEmpty(); if (dscilemp) + { return; + } bool inl = myLine->INL(); if (inl) + { return; + } TopOpeBRepDS_Curve& DSC = myDS->ChangeCurve(myDSCIndex); @@ -1241,7 +1367,9 @@ void TopOpeBRep_FacesFiller::AddShapesLine() } } if (onsampt) + { id = true; + } } if (id) @@ -1356,7 +1484,9 @@ bool TopOpeBRep_FacesFiller::GetFFGeometry(const TopOpeBRepDS_Point& DSP, const TopOpeBRepDS_Point& OODSP = myDS->Point(i); found = TopOpeBRep_PointGeomTool::IsEqual(DSP, OODSP); if (found) + { break; + } } if (found) { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesIntersector.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesIntersector.cxx index 66efaa71c2..b5329db6d2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesIntersector.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_FacesIntersector.cxx @@ -175,7 +175,9 @@ void TopOpeBRep_FacesIntersector::Perform(const TopoDS_Shape& F1, ResetIntersection(); if (!myForceTolerances) + { ShapeTolerances(F1, F2); + } myFace1 = TopoDS::Face(F1); myFace1.Orientation(TopAbs_FORWARD); @@ -231,7 +233,9 @@ void TopOpeBRep_FacesIntersector::Perform(const TopoDS_Shape& F1, // xpu180998 : cto900Q1 bool done = myIntersector.IsDone(); if (!done) + { return; + } PrepareLines(); myIntersectionDone = true; @@ -272,11 +276,15 @@ void TopOpeBRep_FacesIntersector::Perform(const TopoDS_Shape& F1, const TopoDS_S bool TopOpeBRep_FacesIntersector::IsEmpty() { if (!myIntersectionDone) + { return false; + } bool done = myIntersector.IsDone(); bool empty = myIntersector.IsEmpty(); if (!done || empty) + { return true; + } else { // ElemIntersector is done and is not empty @@ -286,7 +294,9 @@ bool TopOpeBRep_FacesIntersector::IsEmpty() { empty = (CurrentLine().NbVPoint() == 0); if (!empty) + { break; + } } return empty; } @@ -304,7 +314,9 @@ bool TopOpeBRep_FacesIntersector::IsDone() const bool TopOpeBRep_FacesIntersector::SameDomain() const { if (!myIntersectionDone) + { throw Standard_ProgramError("FacesIntersector : bad SameDomain"); + } bool sd = myIntersector.TangentFaces(); @@ -319,11 +331,17 @@ bool TopOpeBRep_FacesIntersector::SameDomain() const const TopoDS_Shape& TopOpeBRep_FacesIntersector::Face(const int Index) const { if (Index == 1) + { return myFace1; + } else if (Index == 2) + { return myFace2; + } else + { throw Standard_ProgramError("TopOpeBRep_FacesIntersector::Face"); + } } //================================================================================================= @@ -365,7 +383,9 @@ void TopOpeBRep_FacesIntersector::PrepareLines() // modified by NIZHNY-MKK Mon Apr 2 12:14:58 2001.BEGIN if (n == 0) + { return; + } // modified by NIZHNY-MKK Mon Apr 2 12:15:09 2001.END bool newV = true; @@ -490,16 +510,22 @@ void TopOpeBRep_FacesIntersector::FindLine() { myLineFound = false; if (!myIntersectionDone) + { return; + } while (myLineIndex <= myLineNb) { const TopOpeBRep_LineInter& L = myHAL->Value(myLineIndex); myLineFound = L.OK(); if (myLineFound) + { break; + } else + { myLineIndex++; + } } } @@ -604,12 +630,16 @@ double TopOpeBRep_FacesIntersector::ToleranceMax(const TopoDS_Shape& S, { TopExp_Explorer e(S, T); if (!e.More()) + { return Precision::Intersection(); + } else { double tol = RealFirst(); for (; e.More(); e.Next()) + { tol = std::max(tol, TopOpeBRepTool_ShapeTool::Tolerance(e.Current())); + } return tol; } } @@ -633,9 +663,13 @@ static bool TestWLineAlongRestriction(const occ::handle& th const IntSurf_PntOn2S& Pmid = theWLine->Point(i); double u = 0., v = 0.; if (theRank == 1) + { Pmid.ParametersOnS1(u, v); + } else + { Pmid.ParametersOnS2(u, v); + } //------------------------------------------ gp_Pnt ap; gp_Vec ad1u, ad1v; @@ -654,11 +688,15 @@ static bool TestWLineAlongRestriction(const occ::handle& th // } if (theDomain->IsThePointOn(gp_Pnt2d(u, v), theTolArc)) + { along++; + } // if(along!=i) break; } if (along == NbPnts) + { result = true; + } return result; } @@ -672,7 +710,9 @@ static occ::handle BuildRLineBasedOnWLine( occ::handle anRLine; if ((theRank != 1) && (theRank != 2)) + { return anRLine; + } gp_Pnt2d aPOnLine; double u = 0., v = 0.; @@ -706,7 +746,9 @@ static occ::handle BuildRLineBasedOnWLine( double tol = (Vtx1.Tolerance() > Vtx2.Tolerance()) ? Vtx1.Tolerance() : Vtx2.Tolerance(); if (std::abs(par1 - par2) < theArc->Resolution(tol)) + { return anRLine; + } bool IsOnFirst = (theRank == 1); @@ -848,7 +890,9 @@ static occ::handle BuildRLine( // avoid closed and degenerated edges if (aV1->IsSame(aV2)) + { return anRLine; + } for (theDomain->Init(); theDomain->More(); theDomain->Next()) { @@ -862,9 +906,13 @@ static occ::handle BuildRLine( { if (!foundVertex1 && aV1->IsSame(theDomain->Vertex())) + { foundVertex1 = true; + } if (!foundVertex2 && aV2->IsSame(theDomain->Vertex())) + { foundVertex2 = true; + } } if (foundVertex1 && foundVertex2) @@ -878,7 +926,9 @@ static occ::handle BuildRLine( int indexpnt = aWLine->NbPnts() / 2; if (indexpnt < 1) + { buildrline = false; + } else { double u = RealLast(), v = RealLast(); @@ -903,13 +953,21 @@ static occ::handle BuildRLine( nad1u = ad1u.Magnitude(); nad1v = ad1v.Magnitude(); if (nad1u > 1e-12) + { tolu = theTolArc / nad1u; + } else + { tolu = 0.1; + } if (nad1v > 1e-12) + { tolv = theTolArc / nad1v; + } else + { tolv = 0.1; + } double aTolerance = (tolu > tolv) ? tolv : tolu; if (aPOnArc.Distance(aPOnLine) > aTolerance) @@ -1018,7 +1076,9 @@ static void TestWLinesToAnArc(NCollection_Sequence>& for (int i = 1; i <= slin.Length(); i++) { if (slin.Value(i)->ArcType() != IntPatch_Walking) + { continue; + } const occ::handle& aWLine = *((occ::handle*)&(slin.Value(i))); int nbvtx = aWLine->NbVertex(); const IntPatch_Point& Vtx1 = aWLine->Vertex(1); @@ -1026,9 +1086,13 @@ static void TestWLinesToAnArc(NCollection_Sequence>& bool isvertex = false, wlineWasAppended = false; if (rank == 1) + { isvertex = Vtx1.IsVertexOnS1(); + } else + { isvertex = Vtx1.IsVertexOnS2(); + } if (isvertex) { @@ -1051,12 +1115,16 @@ static void TestWLinesToAnArc(NCollection_Sequence>& } wlineWasAppended = appendwline; if (appendwline) + { aSeqOfWLine.Append(aWLine); + } } else { if (aSeqOfWLine.Length() == 0) + { continue; + } const occ::handle& aLastWLine = *((occ::handle*)&(aSeqOfWLine.Value(aSeqOfWLine.Length()))); const IntPatch_Point& aLastPoint = aLastWLine->Vertex(aLastWLine->NbVertex()); @@ -1083,7 +1151,9 @@ static void TestWLinesToAnArc(NCollection_Sequence>& } wlineWasAppended = appendwline; if (appendwline) + { aSeqOfWLine.Append(aWLine); + } } else { @@ -1093,9 +1163,13 @@ static void TestWLinesToAnArc(NCollection_Sequence>& isvertex = false; if (rank == 1) + { isvertex = Vtx2.IsVertexOnS1(); + } else + { isvertex = Vtx2.IsVertexOnS2(); + } if (wlineWasAppended && isvertex) { @@ -1170,7 +1244,9 @@ static void MergeWLinesIfAllSegmentsAlongRestriction( for (i = 1; i <= theSlin.Length(); i++) { if (theSlin.Value(i)->ArcType() != IntPatch_Walking) + { continue; + } NbWLines++; const occ::handle& aWLine = *((occ::handle*)&(theSlin.Value(i))); @@ -1182,32 +1258,48 @@ static void MergeWLinesIfAllSegmentsAlongRestriction( sqVertexPoints.Append(Vtx1.Value()); sqVertexPoints.Append(Vtx2.Value()); if (TestWLineAlongRestriction(aWLine, rank, theSurface1, theDomain1, theTolArc)) + { WLOnRS1++; + } } else { if (TestWLineAlongRestriction(aWLine, rank, theSurface2, theDomain2, theTolArc)) + { WLOnRS2++; + } } } if (NbWLines == WLOnRS1 || NbWLines == WLOnRS2) + { break; + } } int WLineRank = 0; // not possible to merge WLines if (WLOnRS1 == NbWLines) + { WLineRank = 1; // create merged WLine based on arc of S1 + } else if (WLOnRS2 == NbWLines) + { WLineRank = 2; // create merged WLine based on arc of S2 + } else + { return; + } // avoid closed (degenerated) edges if (sqVertexPoints.Length() <= 2) + { return; + } if (sqVertexPoints.Value(1).IsEqual(sqVertexPoints.Value(sqVertexPoints.Length()), tol)) + { return; + } double TolVrtx = 1.e-5; int testPointIndex = (sqVertexPoints.Length() > 3) ? ((int)sqVertexPoints.Length() / 2) : 2; @@ -1286,12 +1378,16 @@ static int GetArc(NCollection_Sequence>& theSlin, void* anEAddress = theDomainObj->Edge(); if (anEAddress == nullptr) + { continue; + } TopoDS_Edge* anE = (TopoDS_Edge*)anEAddress; occ::handle aCEdge = BRep_Tool::Curve(*anE, firstES1, lastES1); - if (aCEdge.IsNull()) // e.g. degenerated edge, see OCC21770 + if (aCEdge.IsNull()) + { // e.g. degenerated edge, see OCC21770 continue; + } GeomAdaptor_Curve CE; CE.Load(aCEdge); Extrema_ExtPC epc(theTestPoint, CE, 1.e-7); @@ -1310,7 +1406,9 @@ static int GetArc(NCollection_Sequence>& theSlin, } if (ArcNumber == 0) + { return 0; + } // 2. load parameters of founded edge and its arc. CurArc = 0; @@ -1325,14 +1423,18 @@ static int GetArc(NCollection_Sequence>& theSlin, { CurArc++; if (CurArc != ArcNumber) + { continue; + } arc = theDomainObj->Value(); for (i = 1; i <= theSlin.Length(); i++) { if (theSlin.Value(i)->ArcType() != IntPatch_Walking) + { continue; + } const occ::handle& aWLine = *((occ::handle*)&(theSlin.Value(i))); @@ -1369,7 +1471,9 @@ static int GetArc(NCollection_Sequence>& theSlin, for (j = i; j <= WLVertexParameters.Length(); j++) { if (j == i) + { continue; + } if (WLVertexParameters.Value(i) > WLVertexParameters.Value(j)) { @@ -1446,7 +1550,9 @@ static int GetArc(NCollection_Sequence>& theSlin, } if (!classifyOK) + { break; + } // if classification gaps OK, fill sequence by the points from arc (edge) double ParamFirst = WLVertexParameters.Value(1); @@ -1456,7 +1562,9 @@ static int GetArc(NCollection_Sequence>& theSlin, for (i = 0; i < 100; i++) { if (i == 99) + { cParam = ParamLast; + } gp_Pnt cPnt; aCEdge->D0(cParam, cPnt); @@ -1468,7 +1576,9 @@ static int GetArc(NCollection_Sequence>& theSlin, } if (!classifyOK) + { return 0; + } // Initialize extrema projectors for both surfaces Extrema_ExtPS anExtPSObj; @@ -1533,7 +1643,9 @@ static bool IsPointOK(Extrema_ExtPS& theExtPS, const gp_Pnt& theTestPnt, const d } } if (MinDist2 <= theTol * theTol) + { result = true; + } } return result; } @@ -1595,15 +1707,21 @@ static occ::handle GetMergedWLineOnRestriction( for (i = 1; i <= theSlin.Length(); i++) { if (theSlin.Value(i)->ArcType() != IntPatch_Walking) + { continue; + } const occ::handle& aWLine = *((occ::handle*)&(theSlin.Value(i))); if (aWLine->TransitionOnS1() != IntSurf_Undecided && aWLine->TransitionOnS1() != IntSurf_Touch) + { trans1 = aWLine->TransitionOnS1(); + } if (aWLine->TransitionOnS2() != IntSurf_Undecided && aWLine->TransitionOnS2() != IntSurf_Touch) + { trans2 = aWLine->TransitionOnS2(); + } } mWLine = new IntPatch_WLine(theLineOn2S, false, trans1, trans2); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_GeomTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_GeomTool.cxx index b2740f95c4..79efe4b72f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_GeomTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_GeomTool.cxx @@ -56,9 +56,13 @@ void TopOpeBRep_GeomTool::MakeCurves(const double min, PC1 = MakeBSpline1fromWALKING2d(L, 1); PC2 = MakeBSpline1fromWALKING2d(L, 2); if (!PC1.IsNull()) + { C.Curve1(PC1); + } if (!PC2.IsNull()) + { C.Curve2(PC2); + } IsWalk = true; break; } @@ -112,13 +116,21 @@ void TopOpeBRep_GeomTool::MakeCurve(const double min, case TopOpeBRep_HYPERBOLA: if (typeline == TopOpeBRep_CIRCLE) + { C3D = L.Curve(); + } else if (typeline == TopOpeBRep_ELLIPSE) + { C3D = L.Curve(); + } else if (typeline == TopOpeBRep_PARABOLA) + { C3D = L.Curve(min, max); // Trimmed + } else if (typeline == TopOpeBRep_HYPERBOLA) + { C3D = L.Curve(min, max); // Trimmed + } break; @@ -163,9 +175,13 @@ occ::handle TopOpeBRep_GeomTool::MakeBSpline1fromWALKING2d( for (ip = 1, itW.Init(); itW.More(); ip++, itW.Next()) { if (SI == 1) + { points2d.SetValue(ip, itW.CurrentWP().ValueOnS1()); + } else if (SI == 2) + { points2d.SetValue(ip, itW.CurrentWP().ValueOnS2()); + } } occ::handle C = TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d(points2d); return C; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxee2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxee2d.cxx index 8b85ed31c4..5a9a4822e7 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxee2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxee2d.cxx @@ -62,7 +62,9 @@ void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1, occ::handle PC1; PC1 = FC2D_CurveOnSurface(myEdge1, F1, first, last, tolpc); if (PC1.IsNull()) + { throw Standard_Failure("TopOpeBRep_Hctxee2d::SetEdges : no 2d curve"); + } myCurve1.Load(PC1); BRep_Tool::UVPoints(myEdge1, F1, pfirst, plast); tole = BRep_Tool::Tolerance(myEdge1); @@ -85,7 +87,9 @@ void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1, const occ::handle S1 = BRep_Tool::Surface(F1, L1); const occ::handle S2 = BRep_Tool::Surface(F2, L2); if (S1 == S2 && L1 == L2) + { memesupport = true; + } if (ST1 == GeomAbs_Plane || memesfaces || memesupport) { @@ -120,7 +124,9 @@ void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1, double d; bool ok = FUN_tool_projPonF(pt2, F1, uv2, d); if (!ok) + { return; // nyiRaise + } occ::handle aS1 = BRep_Tool::Surface(F1); bool apex = FUN_tool_onapex(uv2, aS1); if (apex) @@ -144,7 +150,9 @@ void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1, const TopoDS_Edge& ee = TopoDS::Edge(it.Value()); bool dgee = BRep_Tool::Degenerated(ee); if (!dgee) + { continue; + } PC2on1 = BRep_Tool::CurveOnSurface(ee, F1, first, last); } } @@ -193,11 +201,17 @@ void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1, const TopoDS_Shape& TopOpeBRep_Hctxee2d::Edge(const int Index) const { if (Index == 1) + { return myEdge1; + } else if (Index == 2) + { return myEdge2; + } else + { throw Standard_Failure("TopOpeBRep_Hctxee2d::Edge"); + } } //================================================================================================= @@ -205,11 +219,17 @@ const TopoDS_Shape& TopOpeBRep_Hctxee2d::Edge(const int Index) const const Geom2dAdaptor_Curve& TopOpeBRep_Hctxee2d::Curve(const int Index) const { if (Index == 1) + { return myCurve1; + } else if (Index == 2) + { return myCurve2; + } else + { throw Standard_Failure("TopOpeBRep_Hctxee2d::Curve"); + } } //================================================================================================= @@ -217,9 +237,15 @@ const Geom2dAdaptor_Curve& TopOpeBRep_Hctxee2d::Curve(const int Index) const const IntRes2d_Domain& TopOpeBRep_Hctxee2d::Domain(const int Index) const { if (Index == 1) + { return myDomain1; + } else if (Index == 2) + { return myDomain2; + } else + { throw Standard_Failure("TopOpeBRep_Hctxee2d::Domain"); + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxff2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxff2d.cxx index b35168a373..6ebe82aca8 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxff2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Hctxff2d.cxx @@ -44,19 +44,25 @@ void TopOpeBRep_Hctxff2d::SetFaces(const TopoDS_Face& F1, const TopoDS_Face& F2) bool newf2 = !F2.IsEqual(myFace2); bool yaduneuf = (newf1 || newf2); if (!yaduneuf) + { return; + } bool computerestriction = false; if (newf1) { if (mySurface1.IsNull()) + { mySurface1 = new BRepAdaptor_Surface(); + } mySurface1->Initialize(F1, computerestriction); } if (newf2) { if (mySurface2.IsNull()) + { mySurface2 = new BRepAdaptor_Surface(); + } mySurface2->Initialize(F2, computerestriction); } SetHSurfacesPrivate(); @@ -70,12 +76,18 @@ void TopOpeBRep_Hctxff2d::SetHSurfaces(const occ::handle& H bool newf1 = false; bool newf2 = false; if (!HS1.IsNull()) + { newf1 = !HS1->Face().IsEqual(myFace1); + } if (!HS2.IsNull()) + { newf2 = !HS2->Face().IsEqual(myFace2); + } bool yaduneuf = (newf1 || newf2); if (!yaduneuf) + { return; + } mySurface1 = HS1; mySurface2 = HS2; @@ -166,11 +178,17 @@ double TopOpeBRep_Hctxff2d::GetMaxTolerance() const const TopoDS_Face& TopOpeBRep_Hctxff2d::Face(const int Index) const { if (Index == 1) + { return myFace1; + } else if (Index == 2) + { return myFace2; + } else + { throw Standard_Failure("TopOpeBRep_Hctxff2d::Face"); + } } //================================================================================================= @@ -178,11 +196,17 @@ const TopoDS_Face& TopOpeBRep_Hctxff2d::Face(const int Index) const occ::handle TopOpeBRep_Hctxff2d::HSurface(const int Index) const { if (Index == 1) + { return mySurface1; + } else if (Index == 2) + { return mySurface2; + } else + { throw Standard_Failure("TopOpeBRep_Hctxff2d::HSurface"); + } } //================================================================================================= @@ -204,9 +228,15 @@ bool TopOpeBRep_Hctxff2d::FacesSameOriented() const bool TopOpeBRep_Hctxff2d::FaceSameOrientedWithRef(const int Index) const { if (Index == 1) + { return myf1surf1F_sameoriented; + } else if (Index == 2) + { return myf2surf1F_sameoriented; + } else + { throw Standard_Failure("TopOpeBRep_Hctxff2d::FSO"); + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_LineInter.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_LineInter.cxx index 5d20f2b147..cd88dbcb4b 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_LineInter.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_LineInter.cxx @@ -134,7 +134,9 @@ void TopOpeBRep_LineInter::SetLine(const occ::handle& L, FUN_ALINETOWLINE(myILA, new BRepAdaptor_Surface(S1), new BRepAdaptor_Surface(S2), aSLin); if (aSLin.Length() > 0) + { myILW = occ::down_cast(aSLin.Value(1)); + } myTypeLineCurve = TopOpeBRep_WALKING; } @@ -342,9 +344,13 @@ void TopOpeBRep_LineInter::SetVPBounds() n++; const int i = VPI.CurrentVPIndex(); if (i < f) + { f = i; + } if (i > l) + { l = i; + } } } @@ -430,7 +436,9 @@ bool TopOpeBRep_LineInter::HasVInternal() for (; VPI.More(); VPI.Next()) { if (VPI.CurrentVP().IsInternal()) + { return true; + } } return false; } @@ -539,7 +547,9 @@ const TopoDS_Shape& TopOpeBRep_LineInter::Arc() const } } else + { return myNullShape; + } } //================================================================================================= @@ -559,7 +569,9 @@ bool TopOpeBRep_LineInter::ArcIsEdge(const int Index) const bool TopOpeBRep_LineInter::HasFirstPoint() const { if (myILG.IsNull()) + { throw Standard_ProgramError("TopOpeBRep_LineInter::HasFirstPoint sur line != GLine"); + } return myILG->HasFirstPoint(); } @@ -568,7 +580,9 @@ bool TopOpeBRep_LineInter::HasFirstPoint() const bool TopOpeBRep_LineInter::HasLastPoint() const { if (myILG.IsNull()) + { throw Standard_ProgramError("TopOpeBRep_LineInter::HasLastPoint sur line != GLine"); + } return myILG->HasLastPoint(); } @@ -587,9 +601,13 @@ void TopOpeBRep_LineInter::ComputeFaceFaceTransition() const TopOpeBRepDS_Transition& TopOpeBRep_LineInter::FaceFaceTransition(const int I) const { if (I == 1) + { return myLineTonF1; + } if (I == 2) + { return myLineTonF2; + } throw Standard_ProgramError("TopOpeBRep_LineInter::FaceFaceTransition"); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Point2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Point2d.cxx index 71a4337c1e..76745ec39f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Point2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_Point2d.cxx @@ -45,13 +45,21 @@ TopOpeBRep_Point2d::TopOpeBRep_Point2d() const TopoDS_Vertex& TopOpeBRep_Point2d::Vertex(const int Index) const { if (!IsVertex(Index)) + { throw Standard_Failure("TopOpeBRep_Point2d::Vertex"); + } if (Index == 1) + { return myvertex1; + } else if (Index == 2) + { return myvertex2; + } else + { throw Standard_Failure("TopOpeBRep_Point2d::Vertex"); + } } //================================================================================================= @@ -59,11 +67,17 @@ const TopoDS_Vertex& TopOpeBRep_Point2d::Vertex(const int Index) const const TopOpeBRepDS_Transition& TopOpeBRep_Point2d::Transition(const int Index) const { if (Index == 1) + { return mytransition1; + } else if (Index == 2) + { return mytransition2; + } else + { throw Standard_Failure("TopOpeBRep_Point2d::Transition"); + } } //================================================================================================= @@ -71,11 +85,17 @@ const TopOpeBRepDS_Transition& TopOpeBRep_Point2d::Transition(const int Index) c TopOpeBRepDS_Transition& TopOpeBRep_Point2d::ChangeTransition(const int Index) { if (Index == 1) + { return mytransition1; + } else if (Index == 2) + { return mytransition2; + } else + { throw Standard_Failure("TopOpeBRep_Point2d::ChangeTransition"); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_PointGeomTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_PointGeomTool.cxx index c5a9bd1e15..06b5f726c2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_PointGeomTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_PointGeomTool.cxx @@ -52,9 +52,13 @@ TopOpeBRepDS_Point TopOpeBRep_PointGeomTool::MakePoint(const TopOpeBRep_VPointIn double t2 = BRep_Tool::Tolerance(E2); // tolout = std::max(t1,t2); if (t1 > 0.9) + { t1 = 0.9; + } if (t1 > 0.9) + { t1 = 0.9; + } tolout = 2.5 * (t1 + t2); } tolout = std::max(tolout, tolip); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessGR.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessGR.cxx index 39d19857d8..676312076e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessGR.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessGR.cxx @@ -73,9 +73,13 @@ TopAbs_State TopOpeBRep_FacesFiller::StBipVPonF(const TopOpeBRep_VPointInter& vp bool isin = M_IN(stf); isin = isin || M_IN(stl); if (isout) + { return TopAbs_OUT; + } if (isin) + { return TopAbs_IN; + } bool isperiodic; const TopoDS_Edge& EArc = TopoDS::Edge(Lrest.Arc()); @@ -101,9 +105,13 @@ TopAbs_State TopOpeBRep_FacesFiller::StBipVPonF(const TopOpeBRep_VPointInter& vp int IArc = 0; if (Lrest.ArcIsEdge(1)) + { IArc = 1; + } if (Lrest.ArcIsEdge(2)) + { IArc = 2; + } if (IArc == 0) { #ifdef OCCT_DEBUG @@ -134,9 +142,13 @@ TopAbs_State TopOpeBRep_FacesFiller::StBipVPonF(const TopOpeBRep_VPointInter& vp TopoDS_Shape F; if (isonedge1) + { F = myF2; + } else + { F = myF1; + } double uf = TopOpeBRep_FacesFiller::VPParamOnER(vpff, Lrest); double ul = TopOpeBRep_FacesFiller::VPParamOnER(vpll, Lrest); @@ -152,9 +164,13 @@ TopAbs_State TopOpeBRep_FacesFiller::StBipVPonF(const TopOpeBRep_VPointInter& vp if (isperiodic) { if (uf == l) + { uf = f; + } if (ul == f) + { ul = l; + } } } @@ -176,19 +192,29 @@ TopAbs_State TopOpeBRep_FacesFiller::StateVPonFace(const TopOpeBRep_VPointInter& { int iVP = VP.ShapeIndex(); if (iVP == 3) + { return TopAbs_ON; + } int iother = (iVP == 1) ? 2 : 1; TopoDS_Shape F; if (iother == 1) + { F = myF1; + } else + { F = myF2; + } double u, v; if (iother == 1) + { VP.ParametersOnS1(u, v); + } else + { VP.ParametersOnS2(u, v); + } myPShapeClassifier->SetReference(TopoDS::Face(F)); myPShapeClassifier->StateP2DReference(gp_Pnt2d(u, v)); @@ -238,7 +264,9 @@ bool TopOpeBRep_FacesFiller::LSameDomainERL(const TopOpeBRep_LineInter& { bool isone = false; if (L.TypeLineCurve() == TopOpeBRep_WALKING) + { return isone; + } double f, l; TopOpeBRep_FacesFiller::Lminmax(L, f, l); @@ -247,12 +275,16 @@ bool TopOpeBRep_FacesFiller::LSameDomainERL(const TopOpeBRep_LineInter& { bool idINL = (L.INL() && (d == 0)); // null length line, made of VPoints only if (idINL) + { return false; + } } // INL bool id = (d <= Precision::PConfusion()); if (id) + { return false; + } occ::handle CL; TopOpeBRep_GeomTool::MakeCurve(f, l, L, CL); @@ -295,7 +327,9 @@ bool TopOpeBRep_FacesFiller::IsVPtransLok(const TopOpeBRep_LineInter& L, bool VPonEd = (is1 && VP.IsOnDomS1()); VPonEd = VPonEd || (!is1 && VP.IsOnDomS2()); if (!VPonEd) + { return false; + } const TopoDS_Edge& E = TopoDS::Edge(VP.Edge(SI12)); TopAbs_Orientation O = E.Orientation(); @@ -319,9 +353,13 @@ bool TopOpeBRep_FacesFiller::TransvpOK(const TopOpeBRep_LineInter& L, TopAbs_State stb = T.Before(); TopAbs_State sta = T.After(); if (isINOUT) + { ok = M_INOUT(stb, sta); + } else + { ok = M_OUTIN(stb, sta); + } } return ok; } @@ -350,9 +388,13 @@ double TopOpeBRep_FacesFiller::VPParamOnER(const TopOpeBRep_VPointInter& vp, } // vp is an intersection point,and we get it's parameter. if (isedge1 && vp.IsOnDomS1()) + { return vp.ParameterOnArc1(); + } if (isedge2 && vp.IsOnDomS2()) + { return vp.ParameterOnArc2(); + } // Else,we have to project the point on the edge restriction double tolee = BRep_Tool::Tolerance(E); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessSectionEdges.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessSectionEdges.cxx index aed0760ae2..70a01cf246 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessSectionEdges.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ProcessSectionEdges.cxx @@ -107,11 +107,15 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool TopOpeBRep_TypeLineCurve t = L.TypeLineCurve(); bool isrest = (t == TopOpeBRep_RESTRICTION); if (!isrest) + { return false; + } const TopoDS_Edge& EL = TopoDS::Edge(L.Arc()); bool isdg = BRep_Tool::Degenerated(EL); if (isdg) + { return false; + } // look for a vpoint with transition IN/OUT or OUT/IN TopOpeBRep_VPointInterIterator VPI; @@ -122,7 +126,9 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool bool keeprline; bool isedge1 = L.ArcIsEdge(1); if (!VPI.More()) + { return false; + } bool samevp = true; const TopOpeBRep_VPointInter& vpf = VPI.CurrentVP(); @@ -130,7 +136,9 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool TopOpeBRep_VPointInter vpl; VPI.Init(L, checkkeep); if (VPI.More()) + { VPI.Next(); + } bool middle = false; // xpu011098 : cto012U1 TopoDS_Vertex vv; @@ -159,9 +167,13 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool vpl = VPI.CurrentVP(); bool samept = FUN_EqualPonR(L, vpf, vpl); if (samept) + { continue; + } else + { break; + } } } } @@ -169,13 +181,17 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool { VPI.Init(L, checkkeep); if (VPI.More()) + { VPI.Next(); + } for (; VPI.More(); VPI.Next()) { vpl = VPI.CurrentVP(); samevp = FUN_EqualponR(L, vpf, vpl); if (!samevp) + { break; + } } } @@ -199,10 +215,14 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool double d = ptf.Distance(ptclo); bool sameclo = (d < std::max(tolvclo, tolf)); if (!sameclo) + { return false; + } } else + { return false; + } } } @@ -226,9 +246,13 @@ bool TopOpeBRep_FacesFiller::KeepRLine(const TopOpeBRep_LineInter& L, const bool bool bl = (sl == TopAbs_IN || sl == TopAbs_ON); // bfl = bf && bl; if ((sf == TopAbs_UNKNOWN) || (sl == TopAbs_UNKNOWN)) + { bfl = bf || bl; + } else + { bfl = bf && bl; + } out = !bfl; } @@ -322,7 +346,9 @@ void TopOpeBRep_FacesFiller::ProcessSectionEdges() bool isdg = BRep_Tool::Degenerated(E); // xpu290698 if (isdg) + { continue; // xpu290698 + } myDS->AddSectionEdge(E); myDS->Shape(E); @@ -344,7 +370,9 @@ void TopOpeBRep_FacesFiller::ProcessSectionEdges() { TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine(); if (L.TypeLineCurve() != TopOpeBRep_RESTRICTION) + { continue; + } ELI = TopoDS::Edge(L.Arc()); if (ELI.IsEqual(ELES)) { @@ -357,9 +385,13 @@ void TopOpeBRep_FacesFiller::ProcessSectionEdges() if (toappend) { if (is1) + { LOI.Append(1); + } else if (is2) + { LOI.Append(2); + } } } @@ -382,7 +414,9 @@ void TopOpeBRep_FacesFiller::ProcessSectionEdges() int iE1 = myDS->Shape(E1); int rE1 = myDS->AncestorRank(iE1); if (rE1 != 1) + { continue; + } NCollection_List thelist; mapELE.Bind(E1, thelist); @@ -393,7 +427,9 @@ void TopOpeBRep_FacesFiller::ProcessSectionEdges() int iE2 = myDS->Shape(E2); int rE2 = myDS->AncestorRank(iE2); if (rE2 == 0 || iE1 == iE2 || rE2 == rE1) + { continue; + } bool toappend = FUN_brep_sdmRE(E1, E2); if (toappend) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ShapeIntersector.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ShapeIntersector.cxx index 733b73b9c0..04a28eb372 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ShapeIntersector.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_ShapeIntersector.cxx @@ -123,37 +123,57 @@ const TopoDS_Shape& TopOpeBRep_ShapeIntersector::CurrentGeomShape(const int Inde if (myFFDone) { if (Index == 1) + { return myFaceScanner.Current(); + } else if (Index == 2) + { return myFaceExplorer.Current(); + } } else if (myEEFFDone) { if (Index == 1) + { return myEdgeScanner.Current(); + } else if (Index == 2) + { return myEdgeExplorer.Current(); + } } else if (myFEDone) { if (Index == 1) + { return myFaceScanner.Current(); + } else if (Index == 2) + { return myEdgeExplorer.Current(); + } } else if (myEFDone) { if (Index == 1) + { return myEdgeScanner.Current(); + } else if (Index == 2) + { return myFaceExplorer.Current(); + } } else if (myEEDone) { if (Index == 1) + { return myEdgeScanner.Current(); + } else if (Index == 2) + { return myEdgeExplorer.Current(); + } } } @@ -258,7 +278,9 @@ void TopOpeBRep_ShapeIntersector::RejectedFaces(const TopoDS_Shape& const TopoDS_Shape& shape = it.Value(); if (shape.ShapeType() != TopAbs_EDGE) + { continue; + } const TopoDS_Edge& edgel = TopoDS::Edge(shape); if (edgef.IsSame(edgel)) @@ -274,7 +296,9 @@ void TopOpeBRep_ShapeIntersector::RejectedFaces(const TopoDS_Shape& const TopoDS_Shape& shape = it.Value(); if (shape.ShapeType() != TopAbs_FACE) + { continue; + } const TopoDS_Face& facel = TopoDS::Face(shape); if (facel.IsSame(newRejectFace)) @@ -351,15 +375,21 @@ void TopOpeBRep_ShapeIntersector::InitIntersection(const TopoDS_Shape& S1, const InitFFIntersection(); if (MoreFFCouple()) + { return; + } InitFEIntersection(); if (MoreFECouple()) + { return; + } InitEFIntersection(); if (MoreEFCouple()) + { return; + } } //================================================================================================= @@ -767,9 +797,13 @@ void TopOpeBRep_ShapeIntersector::FindEEFFIntersection() myEEFFDone = !(myEEIntersector.IsEmpty()); if (myEEFFDone) + { break; + } else + { NextEEFFCouple(); + } } SetIntersectionDone(); } @@ -828,9 +862,13 @@ void TopOpeBRep_ShapeIntersector::FindFEIntersection() myFEIntersector.Perform(GS1, GS2); myFEDone = !(myFEIntersector.IsEmpty()); if (myFEDone) + { break; + } else + { NextFECouple(); + } } SetIntersectionDone(); } @@ -889,9 +927,13 @@ void TopOpeBRep_ShapeIntersector::FindEFIntersection() myFEIntersector.Perform(GS2, GS1); myEFDone = !(myFEIntersector.IsEmpty()); if (myEFDone) + { break; + } else + { NextEFCouple(); + } } SetIntersectionDone(); } @@ -957,9 +999,13 @@ void TopOpeBRep_ShapeIntersector::FindEEIntersection() myEEIntersector.Perform(GS1, GS2); myEEDone = !(myEEIntersector.IsEmpty()); if (myEEDone) + { break; + } else + { NextEECouple(); + } } SetIntersectionDone(); } @@ -990,9 +1036,13 @@ void TopOpeBRep_ShapeIntersector::NextEECouple() const TopoDS_Shape& TopOpeBRep_ShapeIntersector::Shape(const int Index) const { if (Index == 1) + { return myShape1; + } else if (Index == 2) + { return myShape2; + } throw Standard_Failure("ShapeIntersector : no shape"); } @@ -1046,15 +1096,23 @@ static int OneShapeIsHalfSpace(const TopoDS_Shape& S1, const TopoDS_Shape& S2) int NbFacesSol2 = 0; for (; ExpSol1.More(); ExpSol1.Next()) + { NbFacesSol1++; + } for (; ExpSol2.More(); ExpSol2.Next()) + { NbFacesSol2++; + } - if (NbFacesSol1 == 0 || NbFacesSol2 == 0) // strange solids!!! + if (NbFacesSol1 == 0 || NbFacesSol2 == 0) + { // strange solids!!! return result; - if (NbFacesSol1 == 1 && NbFacesSol2 == 1) // both shapes are half spaces ??? + } + if (NbFacesSol1 == 1 && NbFacesSol2 == 1) + { // both shapes are half spaces ??? return result; + } if ((NbFacesSol1 == 1 && NbFacesSol2 >= 2) || (NbFacesSol2 == 1 && NbFacesSol1 >= 2)) { @@ -1074,12 +1132,16 @@ static int OneShapeIsHalfSpace(const TopoDS_Shape& S1, const TopoDS_Shape& S2) if (NbFacesSol1 == 1) { for (SolidExplorer.Init(S1, TopAbs_FACE); SolidExplorer.More(); SolidExplorer.Next()) + { testFace = TopoDS::Face(SolidExplorer.Current()); + } } else { for (SolidExplorer.Init(S2, TopAbs_FACE); SolidExplorer.More(); SolidExplorer.Next()) + { testFace = TopoDS::Face(SolidExplorer.Current()); + } } BRepAdaptor_Surface FSurf(testFace); @@ -1113,7 +1175,9 @@ static int OneShapeIsHalfSpace(const TopoDS_Shape& S1, const TopoDS_Shape& S2) } if (SolidIsSphereOrTorus) + { return result; + } bool SecondShellOk = true; NCollection_IndexedDataMapIsVertexOnS1()) + { throw Standard_DomainError("TopOpeBRep_VPointInter::VertexOnS1"); + } const occ::handle* HBRTAHV = (occ::handle*)&(myPPOI->VertexOnS1()); @@ -85,7 +95,9 @@ const TopoDS_Shape& TopOpeBRep_VPointInter::VertexOnS1() const const TopoDS_Shape& TopOpeBRep_VPointInter::VertexOnS2() const { if (!myPPOI->IsVertexOnS2()) + { throw Standard_DomainError("TopOpeBRep_VPointInter::VertexOnS2"); + } const occ::handle* HBRTAHV = (occ::handle*)&(myPPOI->VertexOnS2()); @@ -97,11 +109,17 @@ const TopoDS_Shape& TopOpeBRep_VPointInter::VertexOnS2() const void TopOpeBRep_VPointInter::State(const TopAbs_State S, const int I) { if (I == 1) + { myState1 = S; + } else if (I == 2) + { myState2 = S; + } else + { throw Standard_DomainError("TopOpeBRep_VPointInter::State"); + } UpdateKeep(); } @@ -110,9 +128,13 @@ void TopOpeBRep_VPointInter::State(const TopAbs_State S, const int I) TopAbs_State TopOpeBRep_VPointInter::State(const int I) const { if (I == 1) + { return myState1; + } else if (I == 2) + { return myState2; + } else { throw Standard_DomainError("TopOpeBRep_VPointInter::State"); @@ -140,11 +162,17 @@ void TopOpeBRep_VPointInter::EdgeON(const TopoDS_Shape& Eon, const double Par, c const TopoDS_Shape& TopOpeBRep_VPointInter::EdgeON(const int I) const { if (I == 1) + { return myEdgeON1; + } else if (I == 2) + { return myEdgeON2; + } else + { throw Standard_DomainError("TopOpeBRep_VPointInter::EdgeON"); + } } //================================================================================================= @@ -152,11 +180,17 @@ const TopoDS_Shape& TopOpeBRep_VPointInter::EdgeON(const int I) const double TopOpeBRep_VPointInter::EdgeONParameter(const int I) const { if (I == 1) + { return myEdgeONPar1; + } else if (I == 2) + { return myEdgeONPar2; + } else + { throw Standard_DomainError("TopOpeBRep_VPointInter::EdgeONParameter"); + } } //================================================================================================= @@ -164,9 +198,13 @@ double TopOpeBRep_VPointInter::EdgeONParameter(const int I) const const TopoDS_Shape& TopOpeBRep_VPointInter::Edge(const int I) const { if (I == 1 && IsOnDomS1()) + { return ArcOnS1(); + } else if (I == 2 && IsOnDomS2()) + { return ArcOnS2(); + } return myNullShape; } @@ -176,9 +214,13 @@ const TopoDS_Shape& TopOpeBRep_VPointInter::Edge(const int I) const double TopOpeBRep_VPointInter::EdgeParameter(const int I) const { if (I == 1 && IsOnDomS1()) + { return ParameterOnArc1(); + } else if (I == 2 && IsOnDomS2()) + { return ParameterOnArc2(); + } return 0.; } @@ -190,9 +232,13 @@ gp_Pnt2d TopOpeBRep_VPointInter::SurfaceParameters(const int I) const // if (I == 1 && IsOnDomS1() ) ParametersOnS1(u,v); // else if (I == 2 && IsOnDomS1() ) ParametersOnS2(u,v); if (I == 1) + { ParametersOnS1(u, v); + } else if (I == 2) + { ParametersOnS2(u, v); + } gp_Pnt2d p2d(u, v); return p2d; } @@ -202,11 +248,17 @@ gp_Pnt2d TopOpeBRep_VPointInter::SurfaceParameters(const int I) const bool TopOpeBRep_VPointInter::IsVertex(const int I) const { if (I == 0) + { return false; + } if (I == 1 && IsVertexOnS1()) + { return true; + } else if (I == 2 && IsVertexOnS2()) + { return true; + } return false; } @@ -215,9 +267,13 @@ bool TopOpeBRep_VPointInter::IsVertex(const int I) const const TopoDS_Shape& TopOpeBRep_VPointInter::Vertex(const int I) const { if (I == 1 && IsVertexOnS1()) + { return VertexOnS1(); + } else if (I == 2 && IsVertexOnS2()) + { return VertexOnS2(); + } return myNullShape; } @@ -235,13 +291,21 @@ void TopOpeBRep_VPointInter::UpdateKeep() bool condition = false; if (SI == 1) + { condition = M_SINON(pos2); + } else if (SI == 2) + { condition = M_SINON(pos1); + } else if (SI == 0) + { condition = M_SINON(pos1) && M_SINON(pos2); + } else if (SI == 3) + { condition = M_SINON(pos1) && M_SINON(pos2); + } // NYI : SI == 3 --> le VP devrait toujours etre Keep() (par definition) myKeep = condition; @@ -274,7 +338,9 @@ bool TopOpeBRep_VPointInter::ParonE(const TopoDS_Edge& E, double& par) const if (IsOnDomS1()) { if (E.IsSame(ArcOnS1())) + { found = true; + } if (found) { par = ParameterOnArc1(); @@ -284,7 +350,9 @@ bool TopOpeBRep_VPointInter::ParonE(const TopoDS_Edge& E, double& par) const if (IsOnDomS2()) { if (E.IsSame(ArcOnS2())) + { found = true; + } if (found) { par = ParameterOnArc2(); @@ -295,7 +363,9 @@ bool TopOpeBRep_VPointInter::ParonE(const TopoDS_Edge& E, double& par) const for (int i = 1; i <= 2; i++) { if (State(i) != TopAbs_ON) + { continue; + } if (EdgeON(i).IsSame(E)) { par = EdgeONParameter(i); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterClassifier.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterClassifier.cxx index 10ef69eb32..c560bbd606 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterClassifier.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterClassifier.cxx @@ -198,9 +198,13 @@ const TopoDS_Shape& TopOpeBRep_VPointInterClassifier::Edge() const double TopOpeBRep_VPointInterClassifier::EdgeParameter() const { if (myState == TopAbs_ON) + { return mySlowFaceClassifier.EdgeParameter(); + } else + { return 0; + } } // modified by NIZHNY-MKK Mon Jun 19 11:47:23 2000.BEGIN @@ -230,10 +234,14 @@ static TopAbs_State SlowClassifyOnBoundary(const gp_Pnt& thePointToC double aVertexTolerance = BRep_Tool::Tolerance(aVertex); gp_Pnt anEdgeVertexPoint = BRep_Tool::Pnt(aVertex); if (thePointToClassify.IsEqual(anEdgeVertexPoint, aVertexTolerance)) + { samewithvertex = true; + } } if (samewithvertex) + { return TopAbs_ON; + } GeomAPI_ProjectPointOnCurve aProjTool(thePointToClassify, anEdgeCurve); @@ -260,9 +268,13 @@ static TopAbs_State SlowClassifyOnBoundary(const gp_Pnt& thePointToC double aTol2d = thePoint2dToClassify.Distance(aPoint2dOnEdge) / 3; theSlowClassifier.Perform(theFace, thePoint2dToClassify, aTol2d); if (theSlowClassifier.State() == TopAbs_IN) + { return TopAbs_IN; + } else + { return TopAbs_OUT; + } } else { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterIterator.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterIterator.cxx index ec4ab27f6e..132e840ade 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterIterator.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_VPointInterIterator.cxx @@ -56,9 +56,13 @@ void TopOpeBRep_VPointInterIterator::Init() { const TopOpeBRep_VPointInter& VP = CurrentVP(); if (VP.Keep()) + { break; + } else + { myVPointIndex++; + } } } } @@ -81,9 +85,13 @@ void TopOpeBRep_VPointInterIterator::Next() { const TopOpeBRep_VPointInter& VP = CurrentVP(); if (VP.Keep()) + { break; + } else + { myVPointIndex++; + } } } } @@ -93,7 +101,9 @@ void TopOpeBRep_VPointInterIterator::Next() const TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::CurrentVP() { if (!More()) + { throw Standard_ProgramError("TopOpeBRep_VPointInterIterator::CurrentVP"); + } const TopOpeBRep_VPointInter& VP = myLineInter->VPoint(myVPointIndex); return VP; } @@ -103,7 +113,9 @@ const TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::CurrentVP() TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::ChangeCurrentVP() { if (!More()) + { throw Standard_ProgramError("TopOpeBRep_VPointInterIterator::ChangeCurrentVP"); + } TopOpeBRep_VPointInter& VP = myLineInter->ChangeVPoint(myVPointIndex); return VP; } @@ -113,7 +125,9 @@ TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::ChangeCurrentVP() int TopOpeBRep_VPointInterIterator::CurrentVPIndex() const { if (!More()) + { throw Standard_ProgramError("TopOpeBRep_VPointInterIterator::CurrentVPIndex"); + } return myVPointIndex; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_WPointInterIterator.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_WPointInterIterator.cxx index ab2039049b..880d9ac156 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_WPointInterIterator.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_WPointInterIterator.cxx @@ -69,7 +69,9 @@ void TopOpeBRep_WPointInterIterator::Next() const TopOpeBRep_WPointInter& TopOpeBRep_WPointInterIterator::CurrentWP() { if (!More()) + { throw Standard_ProgramError("TopOpeBRep_WPointInterIterator::Current"); + } const TopOpeBRep_WPointInter& WP = myLineInter->WPoint(myWPointIndex); return WP; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_kpart.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_kpart.cxx index d2cbc506ca..94b16fbaa2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_kpart.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_kpart.cxx @@ -170,9 +170,13 @@ bool FUNBREP_topowalki_new(const occ::handle& // we assume transition for first vp on non oriented edge to be FORWARD // last vp on non oriented edge to be REVERSED if (iVP == iINON1) + { transLine = TopOpeBRepDS_Transition(TopAbs_OUT, TopAbs_IN); + } if (iVP == iINONn) + { transLine = TopOpeBRepDS_Transition(TopAbs_IN, TopAbs_OUT); + } } // no last defined transition : @@ -180,9 +184,13 @@ bool FUNBREP_topowalki_new(const occ::handle& if (!LITdefinie) { if (onsort) + { return false; + } if (iVP == iINONn) + { return false; + } } // has last defined transition : @@ -198,7 +206,9 @@ bool FUNBREP_topowalki_new(const occ::handle& bool entrantsortant = LprecIsEntrant && onsort; if (EFR && !entrantsortant) + { keep = false; + } if (couture) { @@ -311,7 +321,9 @@ bool FUNBREP_topowalki(const occ::handle& LIT = I->Transition(); LITdefinie = !LIT.IsUnknown(); if (LITdefinie) + { LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD); + } } bool keep = true; @@ -334,10 +346,14 @@ bool FUNBREP_topowalki(const occ::handle& } // end debug 971216 : else + { keep = false; + } } if (iVP == iINONn) + { keep = false; + } if (!EFR) { // E INTERNAL ou EXTERNAL if (iVP == iINON1) @@ -436,7 +452,9 @@ bool FUNBREP_topowalki(const occ::handle& } // keep && LITdefinie if (keep) + { STATIC_lastVPind = iVP; + } return keep; } // FUNBREP_topowalki @@ -472,7 +490,9 @@ bool FUNBREP_topogline_new(const NCollection_List : for unknown current transition // ------------ @@ -489,7 +509,9 @@ bool FUNBREP_topogline_new(const NCollection_ListTransition(); LITdefinie = !LIT.IsUnknown(); if (LITdefinie) + { LITonsort = M_FORWARD(LIT.Orientation(TopAbs_OUT)); + } } bool trliunk = transLine.IsUnknown(); bool isfirstvp = (iVP == iINON1); @@ -497,9 +519,13 @@ bool FUNBREP_topogline_new(const NCollection_List same CPI bool fermee = L.IsVClosed(); if (!fermee && samegp) + { keep = false; + } if (fermee && samegp) { // 2 vp describing a closing line describe the same 3dpoint @@ -566,7 +600,9 @@ bool FUNBREP_topogline_new(const NCollection_List& Ifou if (!EFR) { // E INTERNAL ou EXTERNAL if (iVP == iINON1) + { transLine = TopOpeBRepDS_Transition(TopAbs_OUT, TopAbs_IN); + } if (iVP == iINONn) + { transLine = TopOpeBRepDS_Transition(TopAbs_IN, TopAbs_OUT); + } } bool onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD); @@ -637,7 +677,9 @@ static bool FUNBREP_topogline(const occ::handle& Ifou { bool notkept = !dscilempty && (iVP == 1); if (notkept) + { return false; + } } // 28-05-97 : xpu if (!dscilempty) @@ -646,7 +688,9 @@ static bool FUNBREP_topogline(const occ::handle& Ifou LIT = I->Transition(); LITdefinie = !LIT.IsUnknown(); if (LITdefinie) + { LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD); + } } // xpu : 21-05-97 (see TopOpeBRep_FacesFiller::ProcessVPonR) @@ -664,11 +708,13 @@ static bool FUNBREP_topogline(const occ::handle& Ifou onsort = false; } if (islastvp) + { if (LITdefinie && !LITonsort) { transLine = LIT.Complement(); onsort = true; } + } } // 21-05-97 :xpu bool hasfp = L.HasFirstPoint(); @@ -680,16 +726,22 @@ static bool FUNBREP_topogline(const occ::handle& Ifou if (!LITdefinie) { if (onsort) + { keep = false; + } if (iVP == iINONn) + { keep = false; + } } if (LITdefinie) { bool LprecIsEntrant = (LITdefinie && !LITonsort); bool entrantsortant = LprecIsEntrant && onsort; if (!entrantsortant) + { keep = false; + } bool sameparoncouture = samepar && couture; if (sameparoncouture && hasfol) @@ -713,7 +765,9 @@ static bool FUNBREP_topogline(const occ::handle& Ifou samegp = samegp && sameUVon1 && sameUVon2; } if (samegp) + { keep = false; + } } } if (sameparoncouture && !hasfol) @@ -723,12 +777,16 @@ static bool FUNBREP_topogline(const occ::handle& Ifou FUNBREP_Periodize(L, Ifound, PIfound, parline); TopOpeBRepDS_InterferenceTool::Parameter(Ifound, PIfound); if (LITdefinie) + { transLine = LIT.Complement(); + } } } if (keep) + { STATIC_lastVPind = iVP; + } return keep; } // end of FUNBREP_topogline @@ -741,11 +799,15 @@ static bool TopoParameter(const TopOpeBRep_LineInter& L, //----------------------------------------------------------------------- { if (I.IsNull()) + { return false; + } bool samepar = false; double pCPI = TopOpeBRepDS_InterferenceTool::Parameter(I); if (!closingedge) + { samepar = (std::abs(parline - pCPI) < Precision::PConfusion()); + } else { // trouve et couture et courbe periodique : @@ -787,13 +849,19 @@ Standard_EXPORT bool FUNBREP_topokpart( bool samepar = false; // = True if current VPoint falls on an existing geometry with an equal parameter. // clang-format on if (!CPIfound) + { samepar = false; + } else + { samepar = CPIfound ? TopoParameter(L, Ifound, parline, couture) : false; + } TopOpeBRepDS_Transition lasttransLine; if (!DSCIL.IsEmpty()) + { lasttransLine = DSCIL.Last()->Transition(); // xpu12-12-97 + } // A line is valid if at least it has VPi1 and VPi2 with i1 < i2 and : // transition on line for VPi1 : OUT/IN and for VPi2 : IN/OUT. diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_mergePDS.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_mergePDS.cxx index 564f16ee5a..95f125ca22 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_mergePDS.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_mergePDS.cxx @@ -63,7 +63,9 @@ void BREP_mergePDS(const occ::handle& HDS) TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); TopOpeBRepDS_CurveExplorer cex(BDS); if (!cex.More()) + { return; + } NCollection_IndexedDataMap Mvp1; NCollection_IndexedDataMap Mvp2; @@ -76,7 +78,9 @@ void BREP_mergePDS(const occ::handle& HDS) NCollection_List>::Iterator itI; itI.Initialize(BDS.ChangeCurveInterferences(ic)); if (!itI.More()) + { continue; + } const TopoDS_Face& f1 = TopoDS::Face(c.Shape1()); #ifdef OCCT_DEBUG @@ -100,14 +104,20 @@ void BREP_mergePDS(const occ::handle& HDS) occ::handle CPI = occ::down_cast(ITF); if (CPI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GK = CPI->GeometryType(); if (GK != TopOpeBRepDS_POINT) + { continue; + } int GI = CPI->Geometry(); //**! if (GI > BDS.NbPoints()) + { continue; + } //**! const TopOpeBRepDS_Point& PDS = BDS.Point(GI); @@ -138,7 +148,9 @@ void BREP_mergePDS(const occ::handle& HDS) } if (ivp1 && ivp2) + { BDS.FillShapesSameDomain(v1, v2); + } bool editITF = (ivp1 || ivp2); if (editITF) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_sort.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_sort.cxx index 8ea92dd073..06a0404a90 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_sort.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_sort.cxx @@ -26,24 +26,36 @@ static int compll(const void* v1, const void* v2) BOA_t l1 = *(BOA_t*)v1; BOA_t l2 = *(BOA_t*)v2; if (l1->Extent() == 0) + { return (0); + } else if (l2->Extent() == 0) + { return (0); + } occ::handle i1 = occ::down_cast(l1->First()); if (i1.IsNull()) + { return 0; + } occ::handle i2 = occ::down_cast(l2->First()); if (i2.IsNull()) + { return 0; + } double p1 = i1->Parameter(); double p2 = i2->Parameter(); if (p1 < p2) + { return (-1); + } else if (p1 > p2) + { return (1); + } return 0; } @@ -53,14 +65,18 @@ static void BREP_sortonparameter2(NCollection_ListShape(i); if (s.ShapeType() != TopAbs_EDGE) + { continue; + } NCollection_List>& LOI = BDS.ChangeShapeInterferences(s); BREP_sortonparameter2(LOI); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vpr.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vpr.cxx index 01f33a258c..3ad343c82a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vpr.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vpr.cxx @@ -152,8 +152,12 @@ static bool FUN_INlos(const TopoDS_Shape& S, const NCollection_List::Iterator it(loS); for (; it.More(); it.Next()) + { if (it.Value().IsSame(S)) + { return true; + } + } return false; } @@ -183,14 +187,20 @@ static void FUN_transForWL(const TopOpeBRep_LineInter& L, const TopOpeBRep_VPointInter& VPbis = VPIbis.CurrentVP(); bool tokeep = VPbis.Keep(); if (!tokeep) + { continue; + } int iVPbis = VPIbis.CurrentVPIndex(); if (iVPbis <= iVP) + { continue; + } int absindexbis = VPbis.ShapeIndex(); // 0,1,2,3 int shapeindexbis = (absindexbis == 3) ? ShapeIndex : absindexbis; if (shapeindexbis == 0) + { continue; + } const TopoDS_Shape& edgebis = VPbis.Edge(shapeindexbis); TopAbs_Orientation edgeoribis = edgebis.Orientation(); TopOpeBRepDS_Transition transLinebis; @@ -198,7 +208,9 @@ static void FUN_transForWL(const TopOpeBRep_LineInter& L, TopOpeBRep_FFTransitionTool::ProcessLineTransition(VPbis, shapeindexbis, edgeoribis); bool trliunkbis = transLinebis.IsUnknown(); if (trliunkbis) + { continue; + } transLine = transLinebis.Complement(); break; } @@ -260,13 +272,17 @@ static void FUN_VPgeometryfound( EPIfound = FUN_GetGonParameter(itEPIL, par, tolp, PVIndex, PVKind); } if (EPIfound) + { IEPI = itEPIL.Value(); + } } NCollection_List>::Iterator itCPIL(DSCIL); CPIfound = FF.GetGeometry(itCPIL, VP, PVIndex, PVKind); if (CPIfound) + { ICPI = itCPIL.Value(); + } // - is of shapeindex 3 : is on and , // - is of shapeindex and is given ON another edge @@ -275,24 +291,36 @@ static void FUN_VPgeometryfound( bool hasOOedge = true; if (on2edges) + { hasOOedge = true; + } else + { hasOOedge = (VP.State(OOShapeIndex) == TopAbs_ON); + } if (hasOOedge) { TopoDS_Shape OOedge; if (on2edges) + { OOedge = (rkErest == OOShapeIndex) ? Erest : VP.Edge(OOShapeIndex); + } else + { OOedge = VP.EdgeON(OOShapeIndex); + } double OOpar = 0.; if (on2edges) + { OOpar = (rkErest == OOShapeIndex) ? parErest : VP.EdgeParameter(OOShapeIndex); + } else + { OOpar = VP.EdgeONParameter(OOShapeIndex); + } double tolOOe = FUN_tool_maxtol(OOedge); double OOtolp = Precision::Parametric(tolOOe); @@ -308,7 +336,9 @@ static void FUN_VPgeometryfound( FUN_GetGonParameter(OOitEPIL, OOpar, OOtolp, PVIndex, PVKind); } if (OOEPIfound) + { IOOEPI = OOitEPIL.Value(); + } } } } @@ -366,11 +396,12 @@ Standard_EXPORT void FUN_VPIndex( // JMB 27 Dec 1999 // modified by NIZHNY-MZV Tue Apr 25 09:27:15 2000 if (!EPIfound && !CPIfound && !OOEPIfound) - PVIndex = - 0; // if we just want to find (M_FINDVP) then we must readjust PVIndex to 0 - // because OOEPIfound is not treated in the upper function. The upper function - // will detect that we found a geometry because PVIndex != 0 but as EPIfound and - // CPIfound are FALSE, the resulting VP geometry give unpredictable results. + { + PVIndex = 0; // if we just want to find (M_FINDVP) then we must readjust PVIndex to 0 + } + // because OOEPIfound is not treated in the upper function. The upper function + // will detect that we found a geometry because PVIndex != 0 but as EPIfound and + // CPIfound are FALSE, the resulting VP geometry give unpredictable results. return; } } @@ -382,25 +413,37 @@ Standard_EXPORT void FUN_VPIndex( bool on2edges = (VP.ShapeIndex() == 3); bool hasOOedge = true; if (on2edges) + { hasOOedge = true; + } else + { hasOOedge = (VP.State(OOShapeIndex) == TopAbs_ON); + } // If v shares same domain with a vertex of the other shape, // v has already been stored in the DS if (PVIndex == 0) + { PVKind = (SIisvertex || OOisvertex) ? TopOpeBRepDS_VERTEX : TopOpeBRepDS_POINT; + } if (hasOOedge && !Gfound) { if (!OOEPIfound) { if (SIisvertex) + { PVIndex = FF.MakeGeometry(VP, ShapeIndex, PVKind); + } else if (OOisvertex) + { PVIndex = FF.MakeGeometry(VP, OOShapeIndex, PVKind); + } else + { PVIndex = FF.MakeGeometry(VP, ShapeIndex, PVKind); + } } } if (!hasOOedge && !Gfound) @@ -409,11 +452,17 @@ Standard_EXPORT void FUN_VPIndex( if (!found) { if (SIisvertex) + { PVIndex = FF.MakeGeometry(VP, ShapeIndex, PVKind); + } else if (OOisvertex) + { PVIndex = FF.MakeGeometry(VP, OOShapeIndex, PVKind); + } else + { PVIndex = FF.MakeGeometry(VP, ShapeIndex, PVKind); + } } } } // FUN_VPIndex @@ -436,7 +485,9 @@ static bool FUN_LineRestF(const TopoDS_Face& F, { const TopoDS_Shape& e = itER.Value(); if (mapE.Contains(e)) + { ERLonF.Append(e); + } } itER.Initialize(ERLonF); NCollection_List ERLonFonL; @@ -447,11 +498,15 @@ static bool FUN_LineRestF(const TopoDS_Face& F, eL.Append(e); bool isonL = TopOpeBRep_FacesFiller::LSameDomainERL(L, eL); if (isonL) + { ERLonFonL.Append(e); + } } // is on at most one edge restriction. if (ERLonFonL.Extent() != 1) + { return false; + } ER = TopoDS::Edge(ERLonFonL.First()); return true; } @@ -491,15 +546,20 @@ Standard_EXPORT bool FUN_newtransEdge(const occ::handleHasShape(edge)) { bool isonper; if (PVIndex == 0) + { FDS_getupperlower(HDS, HDS->DS().Shape(edge), paredge, par1, par2); + } else + { FDS_LOIinfsup(HDS->DS(), edge, paredge, @@ -509,9 +569,12 @@ Standard_EXPORT bool FUN_newtransEdge(const occ::handle& I = it.Value(); if (I->Geometry() == G) + { lIonG.Append(I); + } } bool noIfound = lIonG.IsEmpty(); return !noIfound; @@ -684,7 +771,9 @@ static bool FUN_sameGsameS(const NCollection_ListGeometry(); int SEPI = EPI->Support(); if (GEPI == G && SEPI == S) + { loIfound.Append(EPI); + } } return (loIfound.Extent() > 0); } @@ -721,7 +810,9 @@ static void FUN_processCPI(TopOpeBRep_FacesFiller& FF, double par = FDS_Parameter(DSCIL.Last()); // parameter on curve double dd = std::abs(par - parline); // en fait, ce sont des entiers if (dd == 0) + { return; + } } // dist(p2d1,p2d2) < toluv => p2d1, p2d2 are considered equal. @@ -733,18 +824,26 @@ static void FUN_processCPI(TopOpeBRep_FacesFiller& FF, { keptVPnbr++; if (keptVPnbr > 2) + { keep = false; + } } if (!keep) + { return; + } occ::handle CPI; { TopOpeBRepDS_Kind GKCPV; if (Gfound) + { GKCPV = PVKind; + } else + { GKCPV = (SIisvertex || OOisvertex) ? TopOpeBRepDS_VERTEX : TopOpeBRepDS_POINT; + } CPI = ::MakeCPVInterference(ttransLine, 0, PVIndex, parline, GKCPV); FF.StoreCurveInterference(CPI); @@ -791,17 +890,23 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, TopoDS_Face Face = (*this).Face(ShapeIndex); int iSIFace = myDS->Shape(Face); if (iSIFace == 0) + { iSIFace = myDS->AddShape(Face, ShapeIndex); + } TopoDS_Face OOFace = (*this).Face(OOShapeIndex); int iOOFace = myDS->Shape(OOFace); if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } // current VPoint is on int SIedgeIndex = 0; const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); if (myDS->HasShape(edge)) + { SIedgeIndex = myDS->Shape(edge); + } double paredge = VP.EdgeParameter(ShapeIndex); bool isrest = myDS->IsSectionEdge(edge); bool closing = TopOpeBRepTool_ShapeTool::Closed(edge, Face); @@ -817,17 +922,27 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (hasOOedge) { if (on2edges) + { OOparedge = VP.EdgeParameter(OOShapeIndex); + } else + { OOparedge = VP.EdgeONParameter(OOShapeIndex); + } TopoDS_Shape OOe; if (on2edges) + { OOe = VP.Edge(OOShapeIndex); + } else + { OOe = VP.EdgeON(OOShapeIndex); + } OOedge = TopoDS::Edge(OOe); if (myDS->HasShape(OOedge)) + { OOedgeIndex = myDS->Shape(OOedge); + } OOisrest = myDS->IsSectionEdge(OOedge); OOclosing = TopOpeBRepTool_ShapeTool::Closed(OOedge, OOFace); dgOOe = BRep_Tool::Degenerated(OOedge); @@ -876,11 +991,15 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, double par = FDS_Parameter(myDSCIL.Last()); // parameter on curve double dd = std::abs(par - parline); // en fait, ce sont des entiers if (dd == 0) + { setlastonwl = false; + } } TopOpeBRepDS_Transition lasttransLine; if (setlastonwl) + { lasttransLine = myDSCIL.Last()->Transition(); + } // edgeori, transLine // ------------------ @@ -924,9 +1043,13 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (wline) { if (setlastonwl) + { transLine = lasttransLine.Complement(); + } else + { ::FUN_transForWL(*myLine, iVP, ShapeIndex, transLine); + } // walki vpfirst on 3, vplast on 0, nvpkept = 2 kept if (transLine.IsUnknown()) @@ -934,10 +1057,14 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // modified by NIZHNY-MKK Mon Jul 3 11:30:03 2000.BEGIN bool keepvpfirst = dscilempty && isfirstvp && (nINON == 2); if (absindex == 3) + { keepvpfirst = keepvpfirst && myLastVPison0; + } // modified by NIZHNY-MKK Mon Jul 3 11:30:21 2000.END if (keepvpfirst) + { transLine.Set(TopAbs_FORWARD); + } ret1 = false; } } @@ -946,11 +1073,15 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // if (islastvp) keepvp = !dscilempty; // if (isfirstvp) keepvp = true; if (isfirstvp) + { keepvp = true; + } else { if (islastvp) + { keepvp = !dscilempty; + } else { if (!dge && !dgOOe && (VP.IsVertexOnS1() || VP.IsVertexOnS2())) @@ -997,11 +1128,15 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, ret1 = !keepvp; } else + { ret1 = true; + } } trliunk = transLine.IsUnknown(); if (ret1) + { return; + } // Transori, transEdge // ------------------- @@ -1019,9 +1154,13 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, const NCollection_List>& lIedge = myDS->ShapeInterferences(edge); if (PVIndex == 0) + { ::FUN_ScanInterfList(PDS, myHDS, lIedge, lI); + } else + { ::FUN_selectGinterference(lIedge, PVIndex, lI); + } found = ::FUN_selectTRAISHAinterference(lI, iOOFace, lITOOFonVP); } @@ -1085,12 +1224,18 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (tredunk) { if (!trliunk) + { transEdge = transLine.Complement(); + } if (trliunk && !keepvp) + { ret2 = true; + } } if (ret2) + { return; + } tredunk = transEdge.IsUnknown(); // =================================================================== @@ -1100,7 +1245,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // OO*** : data issued from other shape if (SIedgeIndex == 0) + { SIedgeIndex = myDS->AddShape(edge, ShapeIndex); + } bool SIisvertex = VP.IsVertex(ShapeIndex); bool OOisvertex = VP.IsVertex(OOShapeIndex); @@ -1117,6 +1264,7 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // if (!foundPVIndex) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in if (!foundPVIndex || ismultiplekind) + { FUN_VPIndex((*this), (*myLine), VP, @@ -1131,6 +1279,7 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, CPIfound, ICPI, // out M_MKNEWVP); + } if (PVIndex == 0) { #ifdef OCCT_DEBUG @@ -1140,7 +1289,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, bool VPonedge = false; if (PVKind == TopOpeBRepDS_VERTEX) + { VPonedge = ::FUN_onedge(PDS, edge); + } if (myLineINL) { double tolang = Precision::Angular() * 1.e5; //=1.e-7 NYITOLXPU @@ -1159,16 +1310,24 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, } gp_Vec ntOOF; if (ok) + { ntOOF = FUN_tool_nggeomF(OOuv, OOFace); + } if (OOFace.Orientation() == TopAbs_REVERSED) + { ntOOF.Reverse(); + } double tol = 1.e-7; if (ok) + { ok = (tgE.Magnitude() > tol) && (ntOOF.Magnitude() > tol); + } double dot = 1.e7; if (ok) + { dot = gp_Dir(tgE).Dot(gp_Dir(ntOOF)); + } occ::handle su = BRep_Tool::Surface(OOFace); bool apex = FUN_tool_onapex(OOuv, su); @@ -1184,7 +1343,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // xpu231098 : cto904C8(edge11) // xpu131198 : CTS21802(edge31) if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } occ::handle EPIf; { T.Index(iOOFace); @@ -1195,7 +1356,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (on2edges || hasONedge) { if (OOedgeIndex == 0) + { OOedgeIndex = myDS->AddShape(OOedge, OOShapeIndex); + } occ::handle EPI; { T.Index(iOOFace); @@ -1266,13 +1429,17 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (condi2 && (!dge)) { if (OOedgeIndex == 0) + { OOedgeIndex = myDS->AddShape(OOedge, OOShapeIndex); + } occ::handle EPI; { TopOpeBRepDS_Transition T = transEdge; if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } T.Index(iOOFace); EPI = MakeEPVInterference(T, OOedgeIndex, PVIndex, paredge, PVKind, SIisvertex); } @@ -1310,7 +1477,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, if (correctON) { if (OOedgeIndex == 0) + { OOedgeIndex = myDS->AddShape(OOedge, OOShapeIndex); + } // VP a ete classifie ON sur l'edge . // calcul de la transition sur l'arete @@ -1347,15 +1516,19 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, { TopExp_Explorer ex; for (ex.Init(Face, TopAbs_EDGE); ex.More(); ex.Next()) + { if (FUN_ds_sdm(*myDS, ex.Current(), OOedge)) { EsdmEofF = true; break; } + } } bool OOEtgF = true; if (!EsdmEofF) + { OOEtgF = FUN_tool_EtgF(OOparedge, OOedge, OOuv, Face, tola); + } bool OOrest = FUN_INlos(edge, myERL); bool interf2d = OOEtgF && (OOisrest || OOrest); @@ -1375,7 +1548,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, occ::handle OOEPIe; { if (iSIFace == 0) + { iSIFace = myDS->AddShape(Face, ShapeIndex); + } TopOpeBRepDS_Transition OOT = tOOedge; OOT.Index(iSIFace); OOEPIe = MakeEPVInterference(OOT, SIedgeIndex, PVIndex, OOparedge, PVKind, OOisvertex); @@ -1389,7 +1564,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, NCollection_List dummy; bool hsd3d = FDS_HasSameDomain3d(*myDS, OOedge, &dummy); if (hsd3d) + { addEPIf = false; + } if (addEPIf) { TopOpeBRepDS_Transition OOT = tOOedge; @@ -1465,16 +1642,24 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, { TopAbs_Orientation oEPI = PI.Value()->Transition().Orientation(TopAbs_IN); if (!memorifound) + { memorifound = (oEPI == anOtransEdge); + } if (!opporifound) + { opporifound = (oEPI == TopAbs::Complement(anOtransEdge)); + } addEPI = (opporifound && !memorifound); if (addEPI) + { break; + } } } if (!ok) + { addEPI = true; + } } // EPIfound #ifdef OCCT_DEBUG @@ -1491,7 +1676,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, bool EtgOOF = FUN_tool_EtgF(paredge, edge, uv, OOFace, tola); bool inERL = FUN_INlos(edge, myERL); if (EtgOOF && inERL) + { return; // cto904A3 + } } if (addEPI && (!dge)) @@ -1501,7 +1688,9 @@ void TopOpeBRep_FacesFiller::ProcessVPonR(const TopOpeBRep_VPointInter& VP, // le Support de l'interference est l'autre // face (OOShapeIndex) / ShapeIndex if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } occ::handle EPIf; { TopOpeBRepDS_Transition T = transEdge; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprclo.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprclo.cxx index 7c22335665..599d0b8d3e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprclo.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprclo.cxx @@ -61,8 +61,12 @@ static bool FUN_INlos(const TopoDS_Shape& S, const NCollection_List::Iterator it(loS); for (; it.More(); it.Next()) + { if (it.Value().IsSame(S)) + { return true; + } + } return false; } @@ -85,7 +89,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VP bool on2edges = (vpsind == 3); bool isvalid = on2edges || (vpsind == ShapeIndex); if (!isvalid) + { throw Standard_Failure("TopOpeBRep_FacesFiller::GetEdgeTrans"); + } const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); double paredge = VP.EdgeParameter(ShapeIndex); @@ -99,14 +105,22 @@ TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VP if (hasOOedge) { if (on2edges) + { OOparedge = VP.EdgeParameter(OOShapeIndex); + } else + { OOparedge = VP.EdgeONParameter(OOShapeIndex); + } TopoDS_Shape OOe; if (on2edges) + { OOe = VP.Edge(OOShapeIndex); + } else + { OOe = VP.EdgeON(OOShapeIndex); + } OOedge = TopoDS::Edge(OOe); } gp_Pnt2d OOuv = VP.SurfaceParameters(OOShapeIndex); @@ -128,7 +142,9 @@ TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VP isonboundper); } else + { FUN_tool_bounds(edge, par1, par2); + } TopOpeBRepDS_Transition T; // xpu : 16-01-98 @@ -145,18 +161,26 @@ TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VP TopOpeBRepTool_makeTransition MKT; bool ok = MKT.Initialize(edge, par1, par2, paredge, F, OOuv, factor); if (!ok) + { return T; + } bool isT2d = MKT.IsT2d(); interf2d = interf2d && isT2d; if (interf2d) + { ok = MKT.SetRest(OOedge, OOparedge); + } if (!ok) + { return T; + } TopAbs_State stb, sta; ok = MKT.MkTonE(stb, sta); if (!ok) + { return T; + } T.Before(stb); T.After(sta); return T; @@ -191,12 +215,16 @@ void TopOpeBRep_FacesFiller::ProcessVPonclosingR( TopoDS_Face OOFace = (*this).Face(OOShapeIndex); int iOOFace = myDS->Shape(OOFace); if (iOOFace == 0) + { iOOFace = myDS->AddShape(OOFace, OOShapeIndex); + } // current VPoint is on const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); if (!myDS->HasShape(edge)) + { myDS->AddShape(edge, ShapeIndex); + } double paredge = VP.EdgeParameter(ShapeIndex); @@ -207,14 +235,22 @@ void TopOpeBRep_FacesFiller::ProcessVPonclosingR( { TopoDS_Shape OOe; if (on2edges) + { OOe = VP.Edge(OOShapeIndex); + } else + { OOe = VP.EdgeON(OOShapeIndex); + } OOedge = TopoDS::Edge(OOe); if (myDS->HasShape(OOedge)) + { OOedgeIndex = myDS->Shape(OOedge); + } else + { OOedgeIndex = myDS->AddShape(OOedge, OOShapeIndex); + } } // =================================================================== @@ -230,9 +266,13 @@ void TopOpeBRep_FacesFiller::ProcessVPonclosingR( TopOpeBRepDS_Transition transAdd; bool newtransEdge = Tunk; if (newtransEdge) + { transAdd = GetEdgeTrans(VP, PVKind, PVIndex, ShapeIndex, OOFace); + } else + { transAdd = transEdge; + } // !!! if the compute of fails, we add transEdge. // hasOOedge : is ON edge and ON diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprdeg.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprdeg.cxx index 59418d19c0..82f7111df3 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprdeg.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRep/TopOpeBRep_vprdeg.cxx @@ -110,12 +110,16 @@ Standard_EXPORT void FUN_FillVof12(const TopOpeBRep_LineInter& L, TopOpeBRepDS_P const TopOpeBRep_VPointInter& vp = itvp.CurrentVP(); int sind = vp.ShapeIndex(); if (sind != 3) + { continue; + } bool isvon1 = vp.IsVertexOnS1(); bool isvon2 = vp.IsVertexOnS2(); bool isvon12 = isvon1 && isvon2; if (!isvon12) + { continue; + } const TopoDS_Shape& v1 = vp.VertexOnS1(); const TopoDS_Shape& v2 = vp.VertexOnS2(); pDS->FillShapesSameDomain(v1, v2); @@ -157,11 +161,13 @@ static void FUN_addmapve( bool found = false; NCollection_List::Iterator it(mapve.Find(v)); for (; it.More(); it.Next()) + { if (it.Value().IsSame(e)) { found = true; break; } + } if (!found) { mapve.ChangeFind(v).Append(e); @@ -196,7 +202,9 @@ Standard_EXPORT void FUN_GetdgData( bool isv1 = vp.IsVertex(1), isv2 = vp.IsVertex(2); bool isv = isv1 || isv2; if (!isv) + { continue; + } int sind = vp.ShapeIndex(); TopoDS_Shape v = isv1 ? vp.Vertex(1) : vp.Vertex(2); @@ -222,11 +230,17 @@ Standard_EXPORT void FUN_GetdgData( isdg = BRep_Tool::Degenerated(e); if (!isdg) + { iscl = TopOpeBRepTool_ShapeTool::Closed(e, f); + } if (isdg) + { FUN_addmapve(mapved, v, e); + } if (iscl) + { FUN_addmapve(mapvec, v, e); + } } // ison } // i = 1..2 } // itvp @@ -238,7 +252,9 @@ Standard_EXPORT void FUN_GetdgData( { const TopoDS_Shape& v = itm.Key(); if (v.ShapeType() != TopAbs_VERTEX) + { continue; + } int rkv = shaperk.Find(v); NCollection_List::Iterator ite(itm.Value()); @@ -265,7 +281,9 @@ Standard_EXPORT void FUN_GetdgData( int rk = shaperk.Find(dge); TopoDS_Face f = (rk == 1) ? F1 : F2; if (dge.ShapeType() != TopAbs_EDGE) + { continue; + } TopExp_Explorer ex(dge, TopAbs_VERTEX); const TopoDS_Vertex& v = TopoDS::Vertex(ex.Current()); @@ -273,7 +291,9 @@ Standard_EXPORT void FUN_GetdgData( bool hassd = mapvvsd.IsBound(v); TopoDS_Vertex vsd; if (hassd) + { vsd = TopoDS::Vertex(mapvvsd.Find(v)); + } bool hasecl = false; TopoDS_Shape cle; @@ -294,10 +314,14 @@ Standard_EXPORT void FUN_GetdgData( { const TopoDS_Edge& ee = TopoDS::Edge(iteds.Value()); if (ee.IsSame(dge)) + { continue; + } bool iscl = TopOpeBRepTool_ShapeTool::Closed(ee, f); if (!iscl) + { continue; + } isbv = true; cle = ee; hasecl = true; @@ -309,7 +333,9 @@ Standard_EXPORT void FUN_GetdgData( TopoDS_Vertex vv = isbv ? v : vsd; NCollection_List::Iterator ite; if (isbv) + { ite.Initialize(mapvec.Find(v)); + } for (; ite.More(); ite.Next()) { const TopoDS_Shape& e = ite.Value(); @@ -323,7 +349,9 @@ Standard_EXPORT void FUN_GetdgData( } } if (!hasecl) + { continue; + } TopoDS_Vertex vv = (rkv == rk) ? v : vsd; NCollection_List ls; @@ -384,16 +412,22 @@ static int FUN_putInterfonDegenEd( { bool isv = (ShapeIndex == 1) ? (VP.IsVertexOnS1()) : (VP.IsVertexOnS2()); if (!isv) + { continue; + } v = (ShapeIndex == 1) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2()); bool hasdegened = DataforDegenEd.IsBound(v); if (!hasdegened) + { continue; + } rkv = ShapeIndex; break; } // ShapeIndex = 1..2 if (rkv == 0) + { return NOI; // compute interference once only. + } bool isvsd = HDS->HasSameDomain(v); // edges dge, cle on shape @@ -403,14 +437,20 @@ static int FUN_putInterfonDegenEd( dgE = dge; int rkdg = 0; if (BDS.HasShape(dge)) + { rkdg = BDS.AncestorRank(dge); + } else { bool vindge = FUN_tool_inS(v, dge); if (vindge) + { rkdg = rkv; + } else + { rkdg = (rkv == 1) ? 2 : 1; + } } is = rkdg; int rki = (rkdg == 1) ? 2 : 1; @@ -425,9 +465,13 @@ static int FUN_putInterfonDegenEd( // modified by NIZHNY-MKK Tue Nov 21 17:44:56 2000.BEGIN double upar, vpar; if (rki == 1) + { VP.ParametersOnS1(upar, vpar); + } else + { VP.ParametersOnS2(upar, vpar); + } uvi = gp_Pnt2d(upar, vpar); // modified by NIZHNY-MKK Tue Nov 21 17:44:59 2000.END fi = (rki == 1) ? F1 : F2; @@ -436,15 +480,21 @@ static int FUN_putInterfonDegenEd( TopOpeBRepTool_mkTondgE mktdg; bool ok = mktdg.Initialize(dge, f, uvi, fi); if (!ok) + { return NOI; + } ok = mktdg.SetclE(cle); if (!ok) + { return NOI; + } if (onv12 || isvsd) { if (onv12) + { ov = (rkv == 2) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2()); + } else { // modified by NIZHNY-MKK Tue Nov 21 17:45:46 2000.BEGIN @@ -452,7 +502,9 @@ static int FUN_putInterfonDegenEd( // if (!ok) return false; bool found = FUN_ds_getoov(v, HDS, ov); if (!found) + { return NOI; + } // modified by NIZHNY-MKK Tue Nov 21 17:45:50 2000.END } // clang-format off @@ -470,7 +522,9 @@ static int FUN_putInterfonDegenEd( mktdg.SetRest(pari, ei); ok = mktdg.MkTonE(ei, mkt, par1, par2); if ((!ok) || (mkt == NOI)) + { return NOI; + } OOEi = ei; paronOOEi = pari; hasOOEi = true; @@ -541,7 +595,9 @@ static int FUN_putInterfonDegenEd( } // modified by NIZHNY-MKK Tue Nov 21 17:31:36 2000.END if ((!ok) || (mkt == NOI)) + { return NOI; + } } isT2d = mktdg.IsT2d(); @@ -584,6 +640,7 @@ bool TopOpeBRep_FacesFiller::ProcessVPondgE(const TopOpeBRep_VPointInter& occ::handle& ICPI) // out { if (PVIndex == 0) + { FUN_VPIndex((*this), (*myLine), VP, @@ -597,6 +654,7 @@ bool TopOpeBRep_FacesFiller::ProcessVPondgE(const TopOpeBRep_VPointInter& CPIfound, ICPI, // out M_FINDVP); + } // kpart : sphere/box, with one sphere's degenerated edge lying on one boxe's // face, IN or ON the face @@ -649,6 +707,7 @@ bool TopOpeBRep_FacesFiller::ProcessVPondgE(const TopOpeBRep_VPointInter& // ------------------------------------------------------------------- if (PVIndex == 0) + { FUN_VPIndex((*this), (*myLine), VP, @@ -662,6 +721,7 @@ bool TopOpeBRep_FacesFiller::ProcessVPondgE(const TopOpeBRep_VPointInter& CPIfound, ICPI, // out M_MKNEWVP); + } // ------------------------------------------------------------------- // --- EVI on degenerated edge --- @@ -672,9 +732,13 @@ bool TopOpeBRep_FacesFiller::ProcessVPondgE(const TopOpeBRep_VPointInter& // TopoDS_Shape dgEd = VP.Edge(rankdg); TopoDS_Face Fi; if (rankFi == 1) + { Fi = myF1; + } else + { Fi = myF2; + } int iFi = myDS->AddShape(Fi, rankFi); myDS->AddShape(dgEd, rankdg); // int iOOEi = 0; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.cxx index c08ce337c0..7e0d1da501 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.cxx @@ -116,13 +116,19 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { const NCollection_List>& aArea = AreaIter.Value(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_BLOCK); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -155,13 +161,19 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { NCollection_List>& aArea = AreaIter.ChangeValue(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_ANYLOOP); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -174,7 +186,9 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { state = LC.Compare(LoopIter.Value(), L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); // not OUT + } loopoutside = (state == TopAbs_OUT); if (loopoutside) { @@ -234,13 +248,17 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& ashapeinside = ablockinside = false; state = LC.Compare(LoopIter.Value(), L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ashapeinside = (state == TopAbs_IN); if (ashapeinside) { state = LC.Compare(L, LoopIter.Value()); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ablockinside = (state == TopAbs_IN); } if (ashapeinside && ablockinside) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area2dBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area2dBuilder.cxx index ae3a01273d..151e37793e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area2dBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area2dBuilder.cxx @@ -77,13 +77,19 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { NCollection_List>& aArea = AreaIter.ChangeValue(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_BLOCK); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -116,13 +122,19 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { NCollection_List>& aArea = AreaIter.ChangeValue(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_ANYLOOP); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -135,7 +147,9 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { state = LC.Compare(LoopIter.Value(), L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); // not OUT + } loopoutside = (state == TopAbs_OUT); if (loopoutside) { @@ -197,13 +211,17 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& const occ::handle& lb = LoopIter.Value(); state = LC.Compare(lb, L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ashapeinside = (state == TopAbs_IN); if (ashapeinside) { state = LC.Compare(L, lb); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ablockinside = (state == TopAbs_IN); } if (ashapeinside && ablockinside) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area3dBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area3dBuilder.cxx index 6c336a1955..32a62de6f5 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area3dBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Area3dBuilder.cxx @@ -73,13 +73,19 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { NCollection_List>& aArea = AreaIter.ChangeValue(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_BLOCK); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -112,13 +118,19 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { NCollection_List>& aArea = AreaIter.ChangeValue(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_ANYLOOP); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -132,7 +144,9 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& const occ::handle& LLI1 = LoopIter.Value(); state = LC.Compare(LLI1, L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); // not OUT + } loopoutside = (state == TopAbs_OUT); if (loopoutside) { @@ -193,14 +207,18 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& const occ::handle& LLI2 = LoopIter.Value(); state = LC.Compare(LLI2, L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ashapeinside = (state == TopAbs_IN); if (ashapeinside) { const occ::handle& LLI3 = LoopIter.Value(); state = LC.Compare(L, LLI3); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ablockinside = (state == TopAbs_IN); } if (ashapeinside && ablockinside) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.cxx index 5eb9b46597..29f263aaf0 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.cxx @@ -67,7 +67,9 @@ TopAbs_State TopOpeBRepBuild_AreaBuilder::CompareLoopWithListOfLoop( NCollection_List>::Iterator LoopIter; if (LOL.IsEmpty()) + { return TopAbs_OUT; + } for (LoopIter.Initialize(LOL); LoopIter.More(); LoopIter.Next()) { @@ -90,8 +92,10 @@ TopAbs_State TopOpeBRepBuild_AreaBuilder::CompareLoopWithListOfLoop( { state = LC.Compare(L, curL); if (state == TopAbs_OUT) + { // is out of at least one Loop of : stop to explore break; + } } } @@ -157,13 +161,19 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { const NCollection_List>& aArea = AreaIter.Value(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_BLOCK); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -196,13 +206,19 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { const NCollection_List>& aArea = AreaIter.Value(); if (aArea.IsEmpty()) + { continue; + } state = CompareLoopWithListOfLoop(LC, L, aArea, TopOpeBRepBuild_ANYLOOP); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } Loopinside = (state == TopAbs_IN); if (Loopinside) + { break; + } } // end of Area scan if (Loopinside) @@ -215,7 +231,9 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& { state = LC.Compare(LoopIter.Value(), L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); // not OUT + } loopoutside = (state == TopAbs_OUT); if (loopoutside) { @@ -275,13 +293,17 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder(TopOpeBRepBuild_LoopSet& ashapeinside = ablockinside = false; state = LC.Compare(LoopIter.Value(), L); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ashapeinside = (state == TopAbs_IN); if (ashapeinside) { state = LC.Compare(L, LoopIter.Value()); if (state == TopAbs_UNKNOWN) + { Atomize(state, TopAbs_IN); + } ablockinside = (state == TopAbs_IN); } if (ashapeinside && ablockinside) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BlockBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BlockBuilder.cxx index dce53136e8..37f87cdebf 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BlockBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BlockBuilder.cxx @@ -98,7 +98,9 @@ void TopOpeBRepBuild_BlockBuilder::MakeBlock(TopOpeBRepBuild_ShapeSet& SS) CurNei = SS.MaxNumberSubShape(E1); bool condregu = true; if (CurNei > 2) + { condregu = false; + } IsRegular = IsRegular && condregu; // compute neighbours of E : add them to M to increase M.Extent(). SS.InitNeighbours(E1); @@ -167,7 +169,9 @@ const TopoDS_Shape& TopOpeBRepBuild_BlockBuilder::Element( { bool isbound = BI.More(); if (!isbound) + { throw Standard_Failure("OutOfRange"); + } int index = BI.Value(); const TopoDS_Shape& E = myOrientedShapeMap(index); @@ -178,7 +182,9 @@ const TopoDS_Shape& TopOpeBRepBuild_BlockBuilder::Element(const int index) const { bool isbound = myOrientedShapeMapIsValid.IsBound(index); if (!isbound) + { throw Standard_Failure("OutOfRange"); + } const TopoDS_Shape& E = myOrientedShapeMap(index); return E; @@ -188,7 +194,9 @@ int TopOpeBRepBuild_BlockBuilder::Element(const TopoDS_Shape& E) const { bool isbound = myOrientedShapeMap.Contains(E); if (!isbound) + { throw Standard_Failure("OutOfRange"); + } int I = myOrientedShapeMap.FindIndex(E); return I; @@ -200,7 +208,9 @@ bool TopOpeBRepBuild_BlockBuilder::ElementIsValid(const TopOpeBRepBuild_BlockIte { bool isbound = BI.More(); if (!isbound) + { return false; + } int Sindex = BI.Value(); int isb = myOrientedShapeMapIsValid.Find(Sindex); @@ -213,7 +223,9 @@ bool TopOpeBRepBuild_BlockBuilder::ElementIsValid(const int Sindex) const { bool isbound = myOrientedShapeMapIsValid.IsBound(Sindex); if (!isbound) + { return false; + } int isb = myOrientedShapeMapIsValid.Find(Sindex); bool isvalid = isb == 1; @@ -238,7 +250,9 @@ void TopOpeBRepBuild_BlockBuilder::SetValid(const TopOpeBRepBuild_BlockIterator& { bool isbound = BI.More(); if (!isbound) + { return; + } int Sindex = BI.Value(); int i = (isvalid) ? 1 : 0; @@ -249,7 +263,9 @@ void TopOpeBRepBuild_BlockBuilder::SetValid(const int Sindex, const bool isvalid { bool isbound = myOrientedShapeMapIsValid.IsBound(Sindex); if (!isbound) + { return; + } int i = (isvalid) ? 1 : 0; myOrientedShapeMapIsValid.Bind(Sindex, i); @@ -262,6 +278,8 @@ bool TopOpeBRepBuild_BlockBuilder::CurrentBlockIsRegular() bool b = false; int i = myBlocksIsRegular.Value(myBlockIndex); if (i == 1) + { b = true; + } return b; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildEdges.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildEdges.cxx index e75ad59657..32de52b36b 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildEdges.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildEdges.cxx @@ -61,7 +61,9 @@ void TopOpeBRepBuild_Builder::BuildEdges(const int TopOpeBRepBuild_PaveClassifier VCL(anEdge); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } bool closvert = PVS.ClosedVertices(); VCL.ClosedVertices(closvert); PVS.InitLoop(); @@ -79,7 +81,9 @@ void TopOpeBRepBuild_Builder::BuildEdges(const int TopoDS_Edge& newEdge = TopoDS::Edge(It.ChangeValue()); myBuildTool.RecomputeCurves(curC, TopoDS::Edge(anEdge), newEdge, inewC, HDS); if (inewC != -1) + { ChangeNewEdges(inewC).Append(newEdge); + } } if (inewC != -1) { @@ -131,7 +135,9 @@ void TopOpeBRepBuild_Builder::BuildEdges(const occ::handleGeometry(); TopOpeBRepDS_Kind kg = I->GeometryType(); if (kg == TopOpeBRepDS_POINT && ig <= np) + { tp.ChangeValue(ig) = tp.Value(ig) + 1; + } } { int is = I->Support(); TopOpeBRepDS_Kind ks = I->SupportType(); if (ks == TopOpeBRepDS_POINT) + { tp.ChangeValue(is) = tp.Value(is) + 1; + } } } } @@ -167,10 +177,14 @@ void TopOpeBRepBuild_Builder::BuildEdges(const occ::handle>::Iterator it( BDS.ShapeInterferences(is)); for (; it.More(); it.Next()) @@ -180,17 +194,25 @@ void TopOpeBRepBuild_Builder::BuildEdges(const occ::handleGeometry(); TopOpeBRepDS_Kind kg = I->GeometryType(); if (kg == TopOpeBRepDS_POINT) + { tp.ChangeValue(ig) = tp.Value(ig) + 1; + } } { int is1 = I->Support(); TopOpeBRepDS_Kind ks = I->SupportType(); if (ks == TopOpeBRepDS_POINT) + { tp.ChangeValue(is1) = tp.Value(is1) + 1; + } } } } for (ip = 1; ip <= np; ip++) + { if (tp.Value(ip) == 0) + { BDS.RemovePoint(ip); + } + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildFaces.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildFaces.cxx index 20cce47c93..53c131cfb4 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildFaces.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuildFaces.cxx @@ -101,5 +101,7 @@ void TopOpeBRepBuild_Builder::BuildFaces(const occ::handleNbSurfaces(); myNewFaces = new NCollection_HArray1>(0, n); for (iS = 1; iS <= n; iS++) + { BuildFaces(iS, HDS); + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx index 4eb96b1f45..d866d860a2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx @@ -165,7 +165,9 @@ void TopOpeBRepBuild_Builder::AddIntersectionEdges(TopoDS_Shape& aFa TopAbs_Orientation newori = Orient(ori, RevOri1); if (newori == TopAbs_EXTERNAL) + { continue; + } myBuildTool.Orientation(anEdge, newori); const occ::handle& PC = FCurves.PCurve(); @@ -199,7 +201,9 @@ void TopOpeBRepBuild_Builder::Clear() { bool isse = BDS.IsSectionEdge(TopoDS::Edge(e)); if (!isse) + { mySplitOUT.ChangeFind(e).Clear(); + } } } for (NCollection_DataMap* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &mySplitOUT; + } else if (ToBuild == TopAbs_IN) + { p = &mySplitIN; + } else if (ToBuild == TopAbs_ON) + { p = &mySplitON; + } if (p == nullptr) + { return; + } TopOpeBRepDS_ListOfShapeOn1State thelist; if (!(*p).IsBound(S)) + { (*p).Bind(S, thelist); + } TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).ChangeFind(S); losos.Split(Bval); @@ -364,13 +382,21 @@ bool TopOpeBRepBuild_Builder::IsSplit(const TopoDS_Shape& S, const TopAbs_State TopOpeBRepDS_ListOfShapeOn1State, TopTools_ShapeMapHasher>* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &mySplitOUT; + } else if (ToBuild == TopAbs_IN) + { p = &mySplitIN; + } else if (ToBuild == TopAbs_ON) + { p = &mySplitON; + } if (p == nullptr) + { return res; + } if ((*p).IsBound(S)) { @@ -393,13 +419,21 @@ const NCollection_List& TopOpeBRepBuild_Builder::Splits( TopOpeBRepDS_ListOfShapeOn1State, TopTools_ShapeMapHasher>* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &mySplitOUT; + } else if (ToBuild == TopAbs_IN) + { p = &mySplitIN; + } else if (ToBuild == TopAbs_ON) + { p = &mySplitON; + } if (p == nullptr) + { return myEmptyShapeList; + } if ((*p).IsBound(S)) { @@ -431,16 +465,26 @@ NCollection_List& TopOpeBRepBuild_Builder::ChangeSplit(const TopoD NCollection_DataMap* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &mySplitOUT; + } else if (ToBuild == TopAbs_IN) + { p = &mySplitIN; + } else if (ToBuild == TopAbs_ON) + { p = &mySplitON; + } if (p == nullptr) + { return myEmptyShapeList; + } TopOpeBRepDS_ListOfShapeOn1State thelist1; if (!(*p).IsBound(S)) + { (*p).Bind(S, thelist1); + } TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).ChangeFind(S); NCollection_List& L = losos.ChangeListOnState(); return L; @@ -462,7 +506,9 @@ TopAbs_State TopOpeBRepBuild_Builder::ShapePosition(const TopoDS_Shape& const NCollection_List* PLOS = &myEmptyShapeList; TopAbs_ShapeEnum tS = S.ShapeType(); if (tS == TopAbs_FACE) + { PLOS = &myEdgeAvoid; + } // NYI : idem with myFaceAvoid if (tS == TopAbs_SOLID) for (NCollection_List::Iterator Iti(LS); Iti.More(); Iti.Next()) @@ -473,10 +519,14 @@ TopAbs_State TopOpeBRepBuild_Builder::ShapePosition(const TopoDS_Shape& #endif state = myShapeClassifier.StateShapeShape(S, (*PLOS), SLS); if (state != TopAbs_OUT && state != TopAbs_UNKNOWN) + { return state; + } } if (state == TopAbs_UNKNOWN) + { return state; + } return TopAbs_OUT; } @@ -496,7 +546,9 @@ bool TopOpeBRepBuild_Builder::KeepShape(const TopoDS_Shape& S1 { TopAbs_State pos2 = ShapePosition(S1, LS2); if (pos2 != ToBuild1) + { keep = false; + } } return keep; } @@ -513,35 +565,51 @@ TopAbs_ShapeEnum TopOpeBRepBuild_Builder::TopType(const TopoDS_Shape& S) t = TopAbs_COMPOUND; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_COMPSOLID; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_SOLID; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_SHELL; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_FACE; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_WIRE; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_EDGE; e.Init(S, t); if (e.More()) + { return t; + } t = TopAbs_VERTEX; e.Init(S, t); if (e.More()) + { return t; + } return TopAbs_SHAPE; } @@ -554,9 +622,13 @@ bool TopOpeBRepBuild_Builder::Reverse(const TopAbs_State ToBuild1, const TopAbs_ { bool rev; if (ToBuild1 == TopAbs_IN && ToBuild2 == TopAbs_IN) + { rev = false; + } else + { rev = (ToBuild1 == TopAbs_IN); + } return rev; } @@ -645,7 +717,9 @@ void TopOpeBRepBuild_Builder::FindSameDomainSameOrientation( FindSameDomain(L1, L2); NCollection_List::Iterator it(L1); if (!it.More()) + { return; + } const TopoDS_Shape& sref = it.Value(); #ifdef OCCT_DEBUG @@ -660,9 +734,13 @@ void TopOpeBRepBuild_Builder::FindSameDomainSameOrientation( const TopoDS_Shape& s = it.Value(); TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s); if (o == oref && !Contains(s, LL1)) + { LL1.Append(s); + } else if (o != oref && !Contains(s, LL2)) + { LL2.Append(s); + } } for (it.Initialize(L2); it.More(); it.Next()) @@ -670,9 +748,13 @@ void TopOpeBRepBuild_Builder::FindSameDomainSameOrientation( const TopoDS_Shape& s = it.Value(); TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s); if (o == oref && !Contains(s, LL1)) + { LL1.Append(s); + } else if (o != oref && !Contains(s, LL2)) + { LL2.Append(s); + } } L1 = LL1; @@ -687,9 +769,13 @@ void TopOpeBRepBuild_Builder::MapShapes(const TopoDS_Shape& S1, const TopoDS_Sha bool S2null = S2.IsNull(); ClearMaps(); if (!S1null) + { TopExp::MapShapes(S1, myMAP1); + } if (!S2null) + { TopExp::MapShapes(S2, myMAP2); + } } //================================================================================================= @@ -733,9 +819,13 @@ bool TopOpeBRepBuild_Builder::IsShapeOf(const TopoDS_Shape& s, const int i) cons { bool b = false; if (i == 1) + { b = myMAP1.Contains(s); + } else if (i == 2) + { b = myMAP2.Contains(s); + } return b; } @@ -751,7 +841,9 @@ bool TopOpeBRepBuild_Builder::Contains(const TopoDS_Shape& S, const TopoDS_Shape& SL = it.Value(); bool issame = SL.IsSame(S); if (issame) + { return true; + } } return false; } @@ -794,11 +886,17 @@ const NCollection_DataMap& EL = ChangeSplit(Ecur, ToBuild1); if (ConnectTo1) + { EL = EdgeList; + } } // connect new edges as edges built on LE2 edges @@ -962,7 +1071,9 @@ void TopOpeBRepBuild_Builder::SplitEdge1(const TopoDS_Shape& Eoriented, MarkSplit(Ecur, ToBuild2); NCollection_List& EL = ChangeSplit(Ecur, ToBuild2); if (ConnectTo2) + { EL = EdgeList; + } } } // SplitEdge1 @@ -975,7 +1086,9 @@ void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented, { bool tosplit = ToSplit(Eoriented, ToBuild1); if (!tosplit) + { return; + } // work on a FORWARD edge TopoDS_Shape Eforward = Eoriented; @@ -1004,7 +1117,9 @@ void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented, TopOpeBRepBuild_PaveClassifier VCL(Eforward); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } // ------------------------------------------ // before return if PVS has no vertices, @@ -1049,7 +1164,6 @@ void TopOpeBRepBuild_Builder::SplitFace(const TopoDS_Shape& Foriented, } #endif SplitFace1(Foriented, ToBuild1, ToBuild2); - return; } //================================================================================================= @@ -1068,7 +1182,9 @@ void TopOpeBRepBuild_Builder::SplitFace1(const TopoDS_Shape& Foriented, // bool tosplit = ToSplit(Foriented, ToBuild1); if (!tosplit) + { return; + } bool RevOri1 = Reverse(ToBuild1, ToBuild2); bool RevOri2 = Reverse(ToBuild2, ToBuild1); @@ -1089,9 +1205,13 @@ void TopOpeBRepBuild_Builder::SplitFace1(const TopoDS_Shape& Foriented, // SplitFace on a face having other same domained faces on the // other shape : do not reverse orientation of faces in FillFace if (!n2) + { RevOri1 = false; + } if (!n1) + { RevOri2 = false; + } // Create an edge set connected by vertices // ---------------------------------------------- @@ -1159,7 +1279,9 @@ void TopOpeBRepBuild_Builder::SplitFace1(const TopoDS_Shape& Foriented, MarkSplit(Fcur, ToBuild1); NCollection_List& FL = ChangeSplit(Fcur, ToBuild1); if (ConnectTo1) + { FL = FaceList; + } } // connect new faces as faces built on LF2 faces @@ -1170,7 +1292,9 @@ void TopOpeBRepBuild_Builder::SplitFace1(const TopoDS_Shape& Foriented, MarkSplit(Fcur, ToBuild2); NCollection_List& FL = ChangeSplit(Fcur, ToBuild2); if (ConnectTo2) + { FL = FaceList; + } } } // SplitFace1 @@ -1191,7 +1315,9 @@ void TopOpeBRepBuild_Builder::SplitFace2(const TopoDS_Shape& Foriented, // bool tosplit = ToSplit(Foriented, ToBuild1); if (!tosplit) + { return; + } bool RevOri1 = Reverse(ToBuild1, ToBuild2); bool RevOri2 = Reverse(ToBuild2, ToBuild1); @@ -1224,9 +1350,13 @@ void TopOpeBRepBuild_Builder::SplitFace2(const TopoDS_Shape& Foriented, // SplitFace on a face having other same domained faces on the // other shape : do not reverse orientation of faces in FillFace if (!n2) + { RevOri1 = false; + } if (!n1) + { RevOri2 = false; + } NCollection_List LFSO; // liste des faces de 1,2 samedomainsameorientation NCollection_List LFOO; // liste des faces de 1,2 samedomainoppositeorient @@ -1326,7 +1456,9 @@ void TopOpeBRepBuild_Builder::SplitFace2(const TopoDS_Shape& Foriented, MarkSplit(Fcur, ToBuild1); NCollection_List& FL = ChangeSplit(Fcur, ToBuild1); if (ConnectTo1) + { FL = FaceList1; + } } // -------------------------------------------------------------------- @@ -1391,7 +1523,9 @@ void TopOpeBRepBuild_Builder::SplitFace2(const TopoDS_Shape& Foriented, MarkSplit(Fcur, ToBuild2); NCollection_List& FL = ChangeSplit(Fcur, ToBuild2); if (ConnectTo2) + { FL = FaceList2; + } } } // SplitFace2 @@ -1414,14 +1548,20 @@ void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, const TopoDS_Shape& sh = ex.Current(); tosplit = ToSplit(sh, ToBuild1); if (tosplit) + { break; + } } } else + { tosplit = ToSplit(S1oriented, ToBuild1); + } if (!tosplit) + { return; + } // end IFV bool RevOri1 = Reverse(ToBuild1, ToBuild2); @@ -1441,9 +1581,13 @@ void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, int n2 = LS2.Extent(); if (!n2) + { RevOri1 = false; + } if (!n1) + { RevOri2 = false; + } // Create a face set connected by edges // ----------------------------------------- @@ -1518,9 +1662,13 @@ void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, // -------------------------- NCollection_List& SolidList = ChangeMerged(S1oriented, ToBuild1); if (IsShell) + { MakeShells(SOBU, SolidList); + } else + { MakeSolids(SOBU, SolidList); + } // connect list of new solids as solids built on LS1 solids // -------------------------------------------------------------------- @@ -1531,7 +1679,9 @@ void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, MarkSplit(Scur, ToBuild1); NCollection_List& SL = ChangeSplit(Scur, ToBuild1); if (ConnectTo1) + { SL = SolidList; + } } // connect list of new solids as solids built on LS2 solids @@ -1542,7 +1692,9 @@ void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, MarkSplit(Scur, ToBuild2); NCollection_List& SL = ChangeSplit(Scur, ToBuild2); if (ConnectTo2) + { SL = SolidList; + } } } // SplitSolid @@ -1577,13 +1729,21 @@ void TopOpeBRepBuild_Builder::SplitShapes(TopOpeBRepTool_ShapeExplorer& Ex, TopAbs_ShapeEnum t = aShape.ShapeType(); if (t == TopAbs_SOLID || t == TopAbs_SHELL) + { SplitSolid(aShape, ToBuild1, ToBuild2); + } else if (t == TopAbs_FACE) + { SplitFace(aShape, ToBuild1, ToBuild2); + } else if (t == TopAbs_EDGE) + { SplitEdge(aShape, ToBuild1, ToBuild2); + } else + { continue; + } if (IsSplit(aShape, ToBuild1)) { @@ -1621,7 +1781,9 @@ void TopOpeBRepBuild_Builder::SplitShapes(TopOpeBRepTool_ShapeExplorer& Ex, add = KeepShape(newShape, myListOfFace, ToBuild1); } if (add) + { aSet.AddStartElement(newShape); + } } else { @@ -1646,7 +1808,9 @@ void TopOpeBRepBuild_Builder::SplitShapes(TopOpeBRepTool_ShapeExplorer& Ex, // -> testkeep bool istouched = isedge && (!hs) && (!hg); if (istouched) + { istouched = FUN_touched(myDataStructure->DS(), TopoDS::Edge(aShape)); + } testkeep = testkeep || istouched; if (testkeep) @@ -1662,9 +1826,13 @@ void TopOpeBRepBuild_Builder::SplitShapes(TopOpeBRepTool_ShapeExplorer& Ex, // E dans la DS et E a ete purgee de ses interfs car en bout TopoDS_Shape sol; if (STATIC_SOLIDINDEX == 1) + { sol = myShape2; + } else + { sol = myShape1; + } if (!sol.IsNull()) { double first, last; @@ -1844,10 +2012,14 @@ void TopOpeBRepBuild_Builder::FillVertexSetOnValue(const TopOpeBRepDS_PointItera //**! // if (ispoint) V = NewVertex(ind); if (ispoint && ind <= myDataStructure->NbPoints()) + { V = NewVertex(ind); - //**! + //**! + } else + { V = myDataStructure->Shape(ind); + } double par = IT.Parameter(); TopAbs_Orientation ori = IT.Orientation(ToBuild); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx index 7a0038c389..febfc1810f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx @@ -129,7 +129,9 @@ void TopOpeBRepBuild_Builder1::Perform(const occ::handleHasSameDomain(FOR); if (hsd && !mySameDomMap.Contains(FOR)) + { GFillFaceSameDomSFS(FOR, LSO2, G1, SFS); + } } // 2 Process all other faces @@ -287,7 +291,9 @@ void TopOpeBRepBuild_Builder1::GFillShellSFS(const TopoDS_Shape& { const TopoDS_Shape& FOR = exFace.Current(); if (!myDataStructure->HasShape(FOR) || myDataStructure->HasSameDomain(FOR)) + { continue; + } GFillFaceNotSameDomSFS(FOR, LSO2, G1, SFS); } } // GFillShellSFS @@ -323,7 +329,9 @@ void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomSFS(const TopoDS_Shape& { bool toRevOri = Opefus(); for (it.Initialize(WES.StartElements()); it.More(); it.Next()) + { anEdgesON.Append(toRevOri ? it.Value().Reversed() : it.Value()); + } myONElemMap.Clear(); } @@ -348,8 +356,12 @@ void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomSFS(const TopoDS_Shape& // prepare the map of used edges to not take the same matter two times NCollection_IndexedMap aMapOE; for (it.Initialize(LOF); it.More(); it.Next()) + { for (TopExp_Explorer ex(it.Value(), TopAbs_EDGE); ex.More(); ex.Next()) + { aMapOE.Add(ex.Current()); + } + } FillOnPatches(anEdgesON, FOR, aMapOE); myONElemMap.Clear(); @@ -397,9 +409,13 @@ void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomWES(const TopoDS_Shape& TopAbs_Orientation neworiW = Orient(oriW, RevOri1); W.Orientation(neworiW); if (keep) + { WES.AddShape(W); + } else + { myONElemMap.Add(W); + } mySourceShapes.Add(W); } } @@ -408,7 +424,6 @@ void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomWES(const TopoDS_Shape& GFillWireNotSameDomWES(W, LFclass, G1, WES); } } - return; } // GFillFaceWES //================================================================================================= @@ -441,9 +456,13 @@ void TopOpeBRepBuild_Builder1::GFillWireNotSameDomWES(const TopoDS_Shape& TopAbs_Orientation neworiE = Orient(oriE, RevOri1); EOR.Orientation(neworiE); if (keep) + { WES.AddElement(EOR); + } else + { myONElemMap.Add(EOR); + } mySourceShapes.Add(EOR); } } @@ -524,7 +543,9 @@ void TopOpeBRepBuild_Builder1::GFillFaceSameDomSFS(const TopoDS_Shape& // we process all same domain faces during cycling through the Shape1 if (myDataStructure->DS().AncestorRank(FOR) != 1) + { return; + } const TopOpeBRepBuild_GTopo& G1 = Gin; @@ -571,10 +592,14 @@ void TopOpeBRepBuild_Builder1::GFillFaceSameDomSFS(const TopoDS_Shape& } } if (OrigRev) + { aFace.Reverse(); + } if (rev) + { aFace.Reverse(); + } oriLOF.Append(aFace); SFS.AddStartElement(aFace); @@ -638,7 +663,9 @@ void TopOpeBRepBuild_Builder1::GFillFaceSameDomWES( RevOri = G1.IsToReverse2(); TB = TB2; if (RevOri) + { GFTW = G1.CopyPermuted(); + } } // we need to pass GTopo according to ancestor rank GFillCurveTopologyWES(curFF, GFTW, WES); @@ -665,9 +692,11 @@ void TopOpeBRepBuild_Builder1::GFillFaceSameDomWES( TopAbs_Orientation neworiW = Orient(oriW, RevOri); if (myBaseFaceToFill != mySDFaceToFill) + { TopOpeBRepBuild_Tools::UpdatePCurves(TopoDS::Wire(W), TopoDS::Face(mySDFaceToFill), TopoDS::Face(myBaseFaceToFill)); + } else { mySourceShapes.Add(W); @@ -711,7 +740,6 @@ void TopOpeBRepBuild_Builder1::GFillFaceSameDomWES( } } } - return; } // GFillFaceWES //================================================================================================= @@ -868,7 +896,9 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& NCollection_List aListOfPieces, aListOfFaces, aListOfPieceOut2d; // Out 2d pieces we compute only one time : for the Object if (myProcessedPartsOut2d.Contains(eON)) + { continue; + } flag = PerformPieceOn2D(eON, mySDFaceToFill, nEOR, aListOfPieces, aListOfFaces, aListOfPieceOut2d); NCollection_List::Iterator aPIt2d(aListOfPieceOut2d); @@ -899,7 +929,9 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& stateOfFaceOri); // if edge was in not the right orientation we need to reverse it if (!IsRev) + { aPieceToKeep.Reverse(); + } myMapOfEdgeWithFaceState.Bind(aPieceToKeep, stateOfFaceOri); @@ -907,8 +939,10 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& } aFIt.Next(); } - if (flag) // if flag == 0 we should go to the IN2D or OUT2D + if (flag) + { // if flag == 0 we should go to the IN2D or OUT2D continue; + } } // do IN 2D computation @@ -940,7 +974,9 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& // we should process all same domain edges (ON2D) in the code above // and we can not process edges with UNKNOWN state if (aState == TopAbs_ON || aState == TopAbs_UNKNOWN) + { continue; + } // OUT2D computation if (aState == TopAbs_OUT || aSDShape.IsNull()) @@ -966,7 +1002,9 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& for (; aEFIt.More(); aEFIt.Next()) { if (mySDFaceToFill.IsSame(aEFIt.Value())) + { continue; + } else { if (myDataStructure->HasSameDomain(aEFIt.Value())) @@ -995,11 +1033,15 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& gp_Vec aTg, aN1, aN2, aN3, aBiN; TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aSDToAdjFace), aSplitP, aN2); if (aSDToAdjFace.Orientation() == TopAbs_REVERSED) + { aN2.Reverse(); + } TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aAdjSDFace), aSplitP, aN3); if (aAdjSDFace.Orientation() == TopAbs_REVERSED) + { aN3.Reverse(); + } TopOpeBRepBuild_Tools::GetTangentToEdge(aSplitP, aTg); if (aSplitP.Orientation() == TopAbs_REVERSED) @@ -1013,7 +1055,9 @@ void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(mySDFaceToFill), aSplitP, aN1); if (mySDFaceToFill.Orientation() == TopAbs_REVERSED) + { aN1.Reverse(); + } scalarPr = aBiN * aN1; if (fabs(scalarPr) <= 1e-10) // try to step inside @@ -1138,24 +1182,32 @@ void TopOpeBRepBuild_Builder1::PerformONParts( occ::down_cast(I); if (SSI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(SSI, GT, GI, ST, SI); if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE) + { continue; + } const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->DS().Shape(GI, false)); // we process only the edges which are not from the current SD faces if (mySDEdgeMap.Contains(EG)) + { continue; + } // take ON splits of the edge const NCollection_List& splON = myDataStructure->DS().GetShapeWithState(EG).Part(TopAbs_ON); if (!splON.Extent()) + { continue; + } const TopOpeBRepDS_Transition& aTr = SSI->Transition(); @@ -1186,7 +1238,9 @@ void TopOpeBRepBuild_Builder1::PerformONParts( aState = ClassifyEdgeToFaceByOnePoint(TopoDS::Edge(newE), TopoDS::Face(FOR1)); if (aState != TopAbs_IN && aState != TopAbs_ON) + { continue; + } bool keep = false; TopoDS_Face aSDFace = TopoDS::Face(aSDShape); @@ -1203,11 +1257,15 @@ void TopOpeBRepBuild_Builder1::PerformONParts( { EOR = Exp.Current(); if (EG.IsSame(EOR)) + { break; + } } if (EOR.IsNull()) + { continue; + } // else we have found a face , we process it oriE = EOR.Orientation(); @@ -1217,7 +1275,9 @@ void TopOpeBRepBuild_Builder1::PerformONParts( gp_Vec aTg, aN2, aN3, aBiN; TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(FOR), TopoDS::Edge(newE), aN2); if (FOR.Orientation() == TopAbs_REVERSED) + { aN2.Reverse(); + } TopOpeBRepBuild_Tools::GetTangentToEdge(TopoDS::Edge(newE), aTg); if (newE.Orientation() == TopAbs_REVERSED) { @@ -1225,7 +1285,9 @@ void TopOpeBRepBuild_Builder1::PerformONParts( } TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(aSDFace, TopoDS::Edge(newE), aN3); if (aSDFace.Orientation() == TopAbs_REVERSED) + { aN3.Reverse(); + } keep = false; aBiN = aTg ^ aN2; double scalarPr = 0.; @@ -1237,16 +1299,22 @@ void TopOpeBRepBuild_Builder1::PerformONParts( TopoDS::Edge(newE), aN2); if (FOR.Orientation() == TopAbs_REVERSED) + { aN2.Reverse(); + } aBiN = aTg ^ aN2; scalarPr = aBiN * aN3; if (fabs(scalarPr) <= 1e-10) + { continue; + } } TopAbs_State aPartState = (scalarPr > 0) ? TopAbs_IN : TopAbs_OUT; keep = aPartState == ETB; if (keep) + { break; + } } if (keep) @@ -1259,13 +1327,17 @@ void TopOpeBRepBuild_Builder1::PerformONParts( // TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aSDFace), TopoDS::Edge(newE), // aNsf); if (aSDFace.Orientation() == TopAbs_REVERSED) + { aNsf.Reverse(); + } TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(myBaseFaceToFill), TopoDS::Edge(newE), OrigNormalbf); aNbf = OrigNormalbf; if (myBaseFaceToFill.Orientation() == TopAbs_REVERSED) + { aNbf.Reverse(); + } if (aNsf * aNbf < 0) { @@ -1316,7 +1388,9 @@ void TopOpeBRepBuild_Builder1::GWESMakeFaces(const TopoDS_Shape& FF, } } else + { corrLOF.Assign(LOF); + } LOF.Clear(); LOF.Assign(corrLOF); @@ -1362,17 +1436,25 @@ void TopOpeBRepBuild_Builder1::PerformPieceIn2D(const TopoDS_Edge& Edg TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(toFace, EdgeToPerform, aN2); if (O2 == TopAbs_REVERSED) + { aN2.Reverse(); + } TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(edgeFace, EdgeToPerform, aN3); if (O1 == TopAbs_REVERSED) + { aN3.Reverse(); + } TopOpeBRepBuild_Tools::GetTangentToEdge(EdgeToPerform, aTg); if (oriE == TopAbs_REVERSED) + { aTg.Reverse(); + } if (O1 == TopAbs_REVERSED) + { aTg.Reverse(); + } aBiN = aTg ^ aN2; const NCollection_List& aFEL = myMapOfEdgeFaces.FindFromKey(EOR); @@ -1385,13 +1467,17 @@ void TopOpeBRepBuild_Builder1::PerformPieceIn2D(const TopoDS_Edge& Edg for (; aEFIt.More(); aEFIt.Next()) { if (edgeFace.IsSame(aEFIt.Value())) + { continue; + } else { // compute bi-normal state TopoDS_Face aAdjF = TopoDS::Face(aEFIt.Value()); TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(aAdjF, EdgeToPerform, aN1); if (aAdjF.Orientation() == TopAbs_REVERSED) + { aN1.Reverse(); + } scalarPr = aBiN * aN1; if (fabs(scalarPr) <= 1e-10) @@ -1400,17 +1486,23 @@ void TopOpeBRepBuild_Builder1::PerformPieceIn2D(const TopoDS_Edge& Edg // TopOpeBRepBuild_Tools::GetNormalInNearestPoint(TopoDS::Face(aAdjF), EdgeToPerform, // aN1); if (aAdjF.Orientation() == TopAbs_REVERSED) + { aN1.Reverse(); + } scalarPr = aBiN * aN1; if (fabs(scalarPr) <= 1e-10) + { continue; + } } TopAbs_State aPartState = (scalarPr > 0) ? TopAbs_IN : TopAbs_OUT; keep = aPartState == TB; if (keep) + { break; + } } } } @@ -1424,9 +1516,13 @@ void TopOpeBRepBuild_Builder1::PerformPieceIn2D(const TopoDS_Edge& Edg keep = aN3 * aN2 > 0; } if (Opec12() || Opec21()) + { keep = aN3 * aN2 < 0; + } if (Opecom()) + { keep = aN3 * aN2 > 0; + } } } @@ -1446,7 +1542,9 @@ int TopOpeBRepBuild_Builder1::PerformPieceOn2D(const TopoDS_Shape& a int iRef = myDataStructure->DS().AncestorRank(aFaceObj); if (!myDataStructure->HasSameDomain(aFaceObj)) + { return -1; + } // Main DataStructure TopOpeBRepDS_DataStructure& aDS = myDataStructure->ChangeDS(); @@ -1478,7 +1576,9 @@ int TopOpeBRepBuild_Builder1::PerformPieceOn2D(const TopoDS_Shape& a { const TopoDS_Shape& anExpEdgeTool = anExpEdges.Current(); if (!anExpEdgeTool.IsSame(anEdgeTool)) + { continue; + } anEdgeTool.Orientation(anExpEdgeTool.Orientation()); @@ -1539,10 +1639,14 @@ int TopOpeBRepBuild_Builder1::PerformPieceOn2D(const TopoDS_Shape& a if (flag > 1) { if (aCasesMap.Contains(14) && aCasesMap.Contains(12) && Opefus()) + { aListOfPieces.Clear(); + } // eap 30 May occ417, add : if (aCasesMap.Contains(11) && aCasesMap.Contains(13) && (Opec12() || Opec21())) + { aListOfPieces.Clear(); + } } return flag; // Ok } @@ -1556,7 +1660,9 @@ int TopOpeBRepBuild_Builder1::TwoPiecesON(const NCollection_Sequence aTol) + { aScPrFlag1 = true; + } if (fabs(aScProductObj) > aTol) + { aScPrFlag2 = true; + } } // Management @@ -1727,9 +1849,13 @@ int TopOpeBRepBuild_Builder1::TwoPiecesON(const NCollection_Sequence& NCollection_List& aListOfPiecesOut2d) { if (aSeq.Length() < 6) + { return 0; + } TopoDS_Shape aFaceObj = aSeq(1); TopoDS_Shape anEdgeObj = aSeq(2); @@ -2004,11 +2136,15 @@ int TopOpeBRepBuild_Builder1::IsSame2d(const NCollection_Sequence& BRepAdaptor_Surface aBAS(aFObj); if (!(aBAS.IsUPeriodic() || aBAS.IsVPeriodic())) + { return 1; + } // we process here only fully closed edges (Vf == Vl) if (!BRep_Tool::IsClosed(anEdgeObj) || !BRep_Tool::IsClosed(anEdgeTool)) + { return 1; + } double f = 0., l = 0., tolpc = 0., par = 0., parOri = 0., f1 = 0., l1 = 0., parP = 0., gp_Resolution = 1.e-10; @@ -2062,16 +2198,22 @@ int TopOpeBRepBuild_Builder1::IsSame2d(const NCollection_Sequence& C2DEdgeObj->D0(lo, aOLuv); gp_Vec2d aOVec(aOFuv, aOLuv); if (anEObj.Orientation() == TopAbs_REVERSED) + { aOVec.Reverse(); + } IsTrFirst = aTrVec * aOVec <= 0; BRep_Builder BB; double tolE = BRep_Tool::Tolerance(aPTool); if (IsTrFirst) + { BB.UpdateEdge(aPTool, aTrC2D, C2DPieceTool, aFObj, tolE); + } else + { BB.UpdateEdge(aPTool, C2DPieceTool, aTrC2D, aFObj, tolE); + } aListOfPiecesOut2d.Append(aPTool); return 0; @@ -2113,27 +2255,41 @@ void TopOpeBRepBuild_Builder1::OrientateEdgeOnFace(TopoDS_Edge& TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(edgeFace, EdgeToPerform, aN1); if (faceOri == TopAbs_REVERSED) + { aN1.Reverse(); + } TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(baseFace, EdgeToPerform, aN2); if (baseOri == TopAbs_REVERSED) + { aN2.Reverse(); + } if (aN1 * aN2 < 0) + { stateOfFaceOri = true; + } - if (faceRef == 2) // for tool we need to reverse face in cut + if (faceRef == 2) + { // for tool we need to reverse face in cut if (Opec12() || Opec21()) + { stateOfFaceOri = !stateOfFaceOri; + } + } // orientate edge with neworiE EdgeToPerform.Orientation(neworiE); if (currOri != baseOri) + { EdgeToPerform.Reverse(); + } if (stateOfFaceOri) + { EdgeToPerform.Reverse(); + } } /////////////// STATIC FUNCTIONS @@ -2147,7 +2303,9 @@ static TopAbs_State ClassifyEdgeToFaceByOnePoint(const TopoDS_Edge& E, const Top gp_Pnt2d aP2d; if (C2D.IsNull()) + { return TopAbs_UNKNOWN; + } C2D->D0(par, aP2d); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_1.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_1.cxx index 8894db4e7e..90e1eea430 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_1.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_1.cxx @@ -211,7 +211,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates() NCollection_List::Iterator anIt; const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if (E.IsNull()) + { continue; + } const NCollection_List& SplitsON = Splits(E, TopAbs_ON); anIt.Initialize(SplitsON); @@ -279,7 +281,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates() { const TopoDS_Shape& aFace = aMapOfRejectedShapesObj(i); if (aFace.ShapeType() != TopAbs_FACE) + { continue; + } NCollection_IndexedMap aWiresMap; TopExp::MapShapes(aFace, TopAbs_WIRE, aWiresMap); @@ -292,7 +296,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates() TopExp::MapShapes(aWire, TopAbs_EDGE, anEdgesMap); nE = anEdgesMap.Extent(); for (j = 1; j <= nE; j++) + { aMapOfShapeWithStateObj.Add(anEdgesMap(j), aShapeWithState); // add edge + } aMapOfShapeWithStateObj.Add(aWire, aShapeWithState); // add wire } @@ -304,7 +310,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates() const TopoDS_Shape& aFace = aMapOfRejectedShapesTool(i); // modified by NIZHNY-MZV Wed Apr 5 10:27:18 2000 if (aFace.ShapeType() != TopAbs_FACE) + { continue; + } NCollection_IndexedMap aWiresMap; TopExp::MapShapes(aFace, TopAbs_WIRE, aWiresMap); nW = aWiresMap.Extent(); @@ -316,7 +324,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates() TopExp::MapShapes(aWire, TopAbs_EDGE, anEdgesMap); nE = anEdgesMap.Extent(); for (j = 1; j <= nE; j++) + { aMapOfShapeWithStateTool.Add(anEdgesMap(j), aShapeWithState); // add edge + } aMapOfShapeWithStateTool.Add(aWire, aShapeWithState); // add wire } @@ -360,7 +370,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates(const TopoDS_Shape& anObj, NCollection_IndexedDataMap& aMapOfShapeWithState = aDS.ChangeMapOfShapeWithState(anObj, aFlag); if (!aFlag) + { return; + } // int i, j, k, nS, nF, nE; @@ -377,8 +389,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates(const TopoDS_Shape& anObj, const TopoDS_Shape& aShell = aShellsMap(i); if (aMapOfShapeWithState.Contains(aShell)) + { continue; - + } else if (!myDataStructure->HasShape(aShell)) { // Shell has no interference. @@ -423,7 +436,9 @@ void TopOpeBRepBuild_Builder1::PerformShapeWithStates(const TopoDS_Shape& anObj, continue; } else if (myDataStructure->HasShape(aFace)) + { aFacesWithInterferencesMap.Add(aFace); + } else { aFacesToRestMap.Add(aFace); @@ -460,7 +475,9 @@ void TopOpeBRepBuild_Builder1::PerformFacesWithStates( NCollection_IndexedDataMap& aMapOfShapeWithState = aDS.ChangeMapOfShapeWithState(anObj, aFlag); if (!aFlag) + { return; + } // int i, j, k, nF, nW, nE; @@ -548,12 +565,16 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( NCollection_IndexedDataMap& aMapOfShapeWithState = aDS.ChangeMapOfShapeWithState(anObj, aFlag); if (!aFlag) + { return; + } // int i, nE = anEdgesToSplitMap.Extent(); if (!nE) + { return; + } NCollection_DataMap aSplEdgesState; NCollection_List::Iterator anIt; @@ -574,17 +595,23 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( const NCollection_List& SplitsON = aSWS.Part(TopAbs_ON); anIt.Initialize(SplitsON); for (; anIt.More(); anIt.Next()) + { aSplEdgesState.Bind(anIt.Value(), TopAbs_ON); + } const NCollection_List& SplitsOUT = aSWS.Part(TopAbs_OUT); anIt.Initialize(SplitsOUT); for (; anIt.More(); anIt.Next()) + { aSplEdgesState.Bind(anIt.Value(), TopAbs_OUT); + } const NCollection_List& SplitsIN = aSWS.Part(TopAbs_IN); anIt.Initialize(SplitsIN); for (; anIt.More(); anIt.Next()) + { aSplEdgesState.Bind(anIt.Value(), TopAbs_IN); + } } } continue; @@ -718,12 +745,16 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( // propagation of state. myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vf)); if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON) + { theUnkStateVer.Add(Vf); + } if (!Vf.IsSame(Vl)) { myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vl)); if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON) + { theUnkStateVer.Add(Vl); + } } } } @@ -744,7 +775,9 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( // if edge is degenerated we trust that it have IN state without classify if (aState == TopAbs_IN && !isdegen) + { aState = ClassifyEdgeToSolidByOnePoint(TopoDS::Edge(aS), myShapeClassifier); + } //////////////////////////////////////////////////////////////////////////// aShapeWithState.AddPart(aS, aState); @@ -760,12 +793,16 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( // MSV: clarify state of vertices (see my above comment) myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vf)); if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON) + { theUnkStateVer.Add(Vf); + } if (!Vf.IsSame(Vl)) { myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vl)); if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON) + { theUnkStateVer.Add(Vl); + } } } } @@ -805,6 +842,7 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( } if (nE) + { // Propagate the status for anEdgesToRestMap edges TopOpeBRepBuild_Tools::PropagateState(aSplEdgesState, anEdgesToRestMap, @@ -813,6 +851,7 @@ void TopOpeBRepBuild_Builder1::StatusEdgesToSplit( myShapeClassifier, aMapOfShapeWithState, theUnkStateVer); + } } //================================================================================================= @@ -894,17 +933,29 @@ void TopOpeBRepBuild_Builder1::SplitEdge( bool takeFirst = true; if (HasSDV1) + { ; + } else if (HasSDV2) + { takeFirst = false; + } else if (UsedV1) + { ; + } else if (UsedV2) + { takeFirst = false; + } else if (Int3d1) + { ; + } else + { takeFirst = false; + } TopoDS_Shape aVer; bool HasSDV; TopAbs_Orientation anOriOpp; @@ -928,7 +979,9 @@ void TopOpeBRepBuild_Builder1::SplitEdge( // MSV: save orientation of removed vertex NCollection_List thelist; if (!aVerOriMap.IsBound(aVer)) + { aVerOriMap.Bind(aVer, thelist); + } NCollection_List& anOriList = aVerOriMap(aVer); anOriList.Append(takeFirst); anOriList.Append(anOriOpp); @@ -976,7 +1029,9 @@ void TopOpeBRepBuild_Builder1::SplitEdge( aPVSit.Next(); if (!aPVSit.More()) + { break; + } occ::handle aPave2 = aPVSit.Value(); TopoDS_Shape aV2 = aPave2->Vertex(); @@ -999,7 +1054,9 @@ void TopOpeBRepBuild_Builder1::SplitEdge( // MSV: avoid creation of an edge with invalid range if (aPar1 > aPar2) + { continue; + } bool HasSDV1 = myDataStructure->HasSameDomain(aV1); bool HasSDV2 = myDataStructure->HasSameDomain(aV2); @@ -1031,14 +1088,22 @@ void TopOpeBRepBuild_Builder1::SplitEdge( TopAbs_State aState = TopAbs_IN; if (anOr1 == TopAbs_FORWARD && anOr2 == TopAbs_REVERSED) + { aState = TopAbs_OUT; + } if (anOr1 == TopAbs_FORWARD && anOr2 == TopAbs_INTERNAL) + { aState = TopAbs_OUT; + } if (anOr1 == TopAbs_INTERNAL && anOr2 == TopAbs_REVERSED) + { aState = TopAbs_OUT; + } ///* Added if (anOr1 == TopAbs_INTERNAL && anOr2 == TopAbs_INTERNAL) + { aState = TopAbs_OUT; + } // printf(" anOr1=%d, anOr2=%d\n", anOr1, anOr2); // set old orientation to new edge; @@ -1062,7 +1127,9 @@ static TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& // it means that we are in degenerated edge const TopoDS_Vertex& fv = TopExp::FirstVertex(E); if (fv.IsNull()) + { return TopAbs_UNKNOWN; + } aP3d = BRep_Tool::Pnt(fv); } else diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_2.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_2.cxx index 59abb22dc1..7d15168a90 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_2.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1_2.cxx @@ -36,10 +36,14 @@ int TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult) { int aNb = myMapOfCorrect2dEdges.Extent(); if (!aNb) + { return 0; + } if (aResult.ShapeType() != TopAbs_SOLID) + { return 0; + } // // 1. Map Of sources' subshapes . @@ -126,12 +130,16 @@ int TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult) bool free = anEdge.Free(); anEdge.Free(true); for (; anExpVertices.More(); anExpVertices.Next()) + { BB.Add(anEdge, anExpVertices.Current()); + } anEdge.Free(free); } else + { anEdge = E; + } anEdge.Orientation(E.Orientation()); BB.Add(aWire, anEdge); @@ -169,7 +177,9 @@ int TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult) corrLSE.Append(newE); } else + { corrLSE.Append(E); + } } LSE.Clear(); LSE.Append(corrLSE); @@ -183,7 +193,9 @@ int TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult) { const TopoDS_Shape& es = BDS.SectionEdge(i); if (es.IsNull()) + { continue; + } for (int j = 0; j <= 2; j++) { @@ -200,7 +212,9 @@ int TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult) corrLSE.Append(newE); } else + { corrLSE.Append(E); + } } LSE.Clear(); LSE.Append(corrLSE); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuilderON.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuilderON.cxx index 04506ed947..5a36cffb44 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuilderON.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_BuilderON.cxx @@ -194,13 +194,17 @@ bool TopOpeBRepBuild_BuilderON::GFillONCheckI(const occ::handle SSI = occ::down_cast(I); if (SSI.IsNull()) + { return false; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(SSI, GT, GI, ST, SI); if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE) + { return false; + } #ifdef OCCT_DEBUG // int iFOR=BDS.Shape(myFace); #endif @@ -216,17 +220,23 @@ bool TopOpeBRepBuild_BuilderON::GFillONCheckI(const occ::handleTransition(); TopAbs_ShapeEnum shab = TFE.ShapeBefore(), shaa = TFE.ShapeAfter(); if (shaa != ShapeInterf || shab != ShapeInterf) + { return false; + } bool isrest = BDS.IsSectionEdge(EG); bool issplit = myPB->IsSplit(EG, TopAbs_ON); bool keep = (isrest && issplit); if (!keep) + { return false; + } const NCollection_List& lEspON = myPB->Splits(EG, TopAbs_ON); if (lEspON.Extent() == 0) + { return false; + } #ifdef OCCT_DEBUG // const TopoDS_Shape& EspON=lEspON.First(); @@ -251,7 +261,9 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES1(const occ::handleOpecom(); TopAbs_State sta = TopAbs_UNKNOWN; if (opeFus) + { sta = TopAbs_OUT; + } if (opeCom) + { sta = TopAbs_IN; + } if (opec12) + { sta = (rank == 1) ? TopAbs_OUT : TopAbs_IN; + } if (opec21) + { sta = (rank == 2) ? TopAbs_OUT : TopAbs_IN; + } return sta; } @@ -419,11 +447,17 @@ static bool FUN_Kpart0(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType bool quad2 = cyli2 || cone2 || sphe2 || (ST2 == GeomAbs_Torus); if (plane1 && quad2) + { return true; + } if (cyli1 && sphe2) + { return true; + } if (cone1 && sphe2) + { return true; + } return false; } @@ -431,10 +465,14 @@ static int FUN_Kpart(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType& { bool kpart0 = FUN_Kpart0(ST1, ST2); if (kpart0) + { return 1; + } kpart0 = FUN_Kpart0(ST2, ST1); if (kpart0) + { return 2; + } return 0; } @@ -451,16 +489,22 @@ static int FUN_findeSD(const TopOpeBRepDS_DataStructure& BDS, FUN_tool_findPinE(EspON, ptON, parON); NCollection_List lesdSD; if (D == 3) + { FDS_HasSameDomain3d(BDS, EG, &lesdSD); + } if (D == 2) + { FDS_HasSameDomain2d(BDS, EG, &lesdSD); + } for (NCollection_List::Iterator it(lesdSD); it.More(); it.Next()) { TopoDS_Edge eSD = TopoDS::Edge(it.Value()); TopAbs_Orientation oesd; bool eSDofFOR = FUN_tool_orientEinFFORWARD(eSD, FOR, oesd); if (!eSDofFOR) + { continue; + } TopAbs_State staeSD = FUN_tool_staPinE(ptON, eSD); if (staeSD == TopAbs_IN) { @@ -480,10 +524,14 @@ static bool ComputeFaceCrvtInSec(const TopoDS_Face& aFace, BRepAdaptor_Surface aSurf(aFace); int cn = BRepLProp_SurfaceTool::Continuity(aSurf); if (cn < 2) + { return false; + } BRepLProp_SLProps aProp(aSurf, aP2d.X(), aP2d.Y(), 2, Precision::Confusion()); if (!aProp.IsCurvatureDefined()) + { return false; + } if (aProp.IsUmbilic()) { @@ -573,9 +621,13 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle> lIGesd; int nGesd = FUN_selectGIinterference(lIcopy, Iesd, lIGesd); if (nGesd != 0) + { yap00 = false; // ES has interference on G=edge(Iesd) + } } bool yap0 = true; @@ -746,39 +808,59 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle eps && absCrvFS > eps) { double tolR = tolON; double rcrvFOR = 1. / crvFOR, rcrvFS = 1. / crvFS; if (std::abs(rcrvFOR - rcrvFS) <= tolR) + { return; + } } // if we are here the curvatures are different } @@ -914,12 +1036,16 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle ssi( occ::down_cast(itssi.Value())); if (ssi.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT1, ST1; int G1, S1; FDS_data(ssi, GT1, G1, ST1, S1); @@ -1640,17 +1868,29 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle projection) @@ -1725,7 +2003,9 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle 0); if (toreverse) + { neworiE = TopAbs::Complement(neworiE); + } } } // FFinSDDO && ok @@ -2057,12 +2411,18 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handleDataStructure(), iFOR, iFCX, GI, TopoDS::Edge(EspON), shareG); if (!ok) + { return; // nyiFUNRAISE + } if (SO) { @@ -2134,9 +2496,13 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle 1) + { return; // NYIRaise (invalid shape) + } else { const TopoDS_Face& FF = TopoDS::Face(lfor.First()); @@ -2144,45 +2510,65 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle M_PI if (fsinfPI && forinfPI) + { b = false; + } else { // (!fsinfPI) || (!forinfPI) bool sammat = (std::abs(matfs - matfor) < tola1); if (sammat) + { b = false; + } else + { b = (matfs < matfor); + } } } if (b) + { forcekeep = true; + } } // NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYIXPU /*if (shareG) b = true; @@ -2202,9 +2588,13 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handle lfcFk; FDSCNX_FaceEdgeConnexFaces(FOR, Esd, HDS, lfcFk); if (lfcFk.Extent() != 1) + { return; // shape bizarre + } double parEsd; ok = FUN_tool_parE(eON, parON, Esd, parEsd, tolEG); if (!ok) + { return; + } const TopoDS_Face& OOFOR = TopoDS::Face(lfcFk.First()); gp_Pnt2d uv; double dummy = 0; ok = FUN_tool_paronEF(Esd, parEsd, OOFOR, uv, dummy); // rkEsd=rkOOFOR gp_Vec ntOOFOR = FUN_tool_nggeomF(uv, OOFOR); if (OOFOR.Orientation() == TopAbs_REVERSED) + { ntOOFOR.Reverse(); + } // xxFCX : #ifdef OCCT_DEBUG // double t1 =factor*BRep_Tool::Tolerance(Esd); @@ -2269,24 +2679,34 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handleIsSplit(ee, TopAbs_IN); if (issp) + { addtwice = !myPB->Splits(ee, TopAbs_IN).IsEmpty(); + } if (addtwice) + { break; + } } } if (addtwice) @@ -2394,30 +2826,40 @@ void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const occ::handleDataStructure()->DS(); if (GLOBAL_DS2d == nullptr) + { GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure) new TopOpeBRepDS_DataStructure(); + } const NCollection_List>& lFEI = GLOBAL_DS2d->ShapeInterferences(FOR); @@ -229,17 +231,25 @@ void TopOpeBRepBuild_BuilderON::GFillONParts2dWES2(const occ::handleDataStructure(), iFOR, iFCX, GI, TopoDS::Edge(EspON), shareG); + } else if (EGBoundFOR) + { ok = FUN_ds_shareG(myPB->DataStructure(), iFCX, iFOR, GI, TopoDS::Edge(EspON), shareG); + } if (!ok) + { return; // nyiFUNRAISE + } #ifdef OCCT_DEBUG if (tFOR) std::cout << " shareG=" << shareG << std::endl; @@ -249,14 +259,22 @@ void TopOpeBRepBuild_BuilderON::GFillONParts2dWES2(const occ::handleElement(Bit2); if (!CompareElement(s2)) + { break; + } } state = State(); } @@ -116,7 +120,9 @@ TopAbs_State TopOpeBRepBuild_CompositeClassifier::Compare( if (state == TopAbs_UNKNOWN) { if (Bit1.More()) + { Bit1.Next(); + } yena1 = Bit1.More(); } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_CorrectFace2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_CorrectFace2d.cxx index 1e6dc6aaa9..de65dcd1b3 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_CorrectFace2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_CorrectFace2d.cxx @@ -288,7 +288,9 @@ void TopOpeBRepBuild_CorrectFace2d::CheckFace() NCollection_IndexedMap aEM; TopExp::MapShapes(aVoidWires(i), TopAbs_EDGE, aEM); if (aEM.Extent()) + { myCopyAvoidMap.Add(aEM(1)); + } } // III. Check all wires to know whether they are closed or not @@ -346,7 +348,9 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( int priz; priz = MakeRightWire(); if (priz) + { return priz; + } // // 2. Define the First Edge on the Wire from aCopyAvoidMap int i, aNbEdges = 0, aNbAvoidEdgesOnWire; @@ -362,15 +366,21 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( { const TopoDS_Shape& anEdge = aWExp.Current(); if (aCopyAvoidMap.Contains(anEdge)) + { anAvoidMap.Add(anEdge); + } } - if (aNbEdges == 1) // nothing to do with this wire. + if (aNbEdges == 1) + { // nothing to do with this wire. return 0; + } aNbAvoidEdgesOnWire = anAvoidMap.Extent(); - if (aNbAvoidEdgesOnWire == aNbEdges) // nothing to do. all edges on wire are good. + if (aNbAvoidEdgesOnWire == aNbEdges) + { // nothing to do. all edges on wire are good. return 0; + } // if at least one non-degenerated edge exists // among anAvoidMap set it as aFirstEdge @@ -429,7 +439,9 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( NCollection_List::Iterator anIt; anIt.Initialize(HeadList); for (; anIt.More(); anIt.Next()) + { aSeqEdges.Append(anIt.Value()); + } aNbEdges = aSeqEdges.Length(); // @@ -483,14 +495,18 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( // printf(" (fmod(fabs(V), 2*M_PI) > 1e-7)=%lf\n", (fmod(fabs(V), 2*M_PI))); if (nonPU && nonPV && !BRep_Tool::Degenerated(anEdge)) + { return 1; + } // End modified by NIZHNY-MZV Mon Mar 27 16:04:11 2000 if (BRep_Tool::IsClosed(anEdge, aCopyFace)) { // a. Closed edge <---> if (anEdMap.Contains(anEdge)) + { continue; + } anEdMap.Add(anEdge); TopAbs_Orientation anOri = anEdge.Orientation(); @@ -515,11 +531,14 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( TranslateCurve2d(anEF, aCopyFace, aTrV, aTrCF); TranslateCurve2d(anER, aCopyFace, aTrV, aTrCR); - if (aTryFlag) // Use Builder in a trying case + if (aTryFlag) + { // Use Builder in a trying case BB.UpdateEdge(anEdge, aTrCF, aTrCR, aCopyFace, myFaceTolerance); - - else // Use "False-Builder" otherwise + } + else + { // Use "False-Builder" otherwise UpdateEdge(anEdge, aTrCF, aTrCR, aCopyFace, myFaceTolerance); + } } else @@ -528,9 +547,13 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( TranslateCurve2d(anEdge, aCopyFace, aTrV, aTrC); if (aTryFlag) + { BB.UpdateEdge(anEdge, aTrC, aCopyFace, myFaceTolerance); + } else + { UpdateEdge(anEdge, aTrC, aCopyFace, myFaceTolerance); + } } GetP2dFL(aCopyFace, anEdge, PF, PL); @@ -547,7 +570,9 @@ int TopOpeBRepBuild_CorrectFace2d::ConnectWire( { aD = PA1.Distance(PB); if (aD > aDTolerance) + { return 1; + } } } //////////////////////////////////////////// @@ -574,7 +599,9 @@ void TopOpeBRepBuild_CorrectFace2d::Perform() // 1. Check the input face first CheckFace(); if (myIsDone) + { return; + } // // 2. Make all wires connected @@ -626,7 +653,9 @@ int TopOpeBRepBuild_CorrectFace2d::MakeRightWire() TopExp_Explorer aWExp; aWExp.Init(myCurrentWire, TopAbs_EDGE); for (; aWExp.More(); aWExp.Next()) + { aNbEdgesReally++; + } // 2. We'll use TopOpeBRepBuild_Tools::Path NCollection_List aL; @@ -643,7 +672,9 @@ int TopOpeBRepBuild_CorrectFace2d::MakeRightWire() NCollection_List aFL; NCollection_List::Iterator lit(aL); for (; lit.More(); lit.Next()) + { aFL.Prepend(lit.Value()); + } myOrderedWireList = aFL; // End modified by NIZNHY-PKV Tue Apr 25 12:06:45 2000 @@ -686,11 +717,17 @@ void TopOpeBRepBuild_CorrectFace2d::MakeHeadList(const TopoDS_Shape& const TopoDS_Shape& anEdge = anIt.Value(); // modified by NIZHNY-MZV Mon Mar 27 11:40:00 2000 if (aFE.IsNull() && !BRep_Tool::Degenerated(TopoDS::Edge(anEdge))) + { aFE = anEdge; + } if (anEdge == aFE) + { aFlag = 1; // turn the switch ON + } if (aFlag) + { HeadList.Append(anEdge); + } } anIt.Initialize(myOrderedWireList); @@ -698,7 +735,9 @@ void TopOpeBRepBuild_CorrectFace2d::MakeHeadList(const TopoDS_Shape& { const TopoDS_Shape& anEdge = anIt.Value(); if (anEdge == aFE) + { break; + } aTailList.Append(anEdge); } HeadList.Append(aTailList); @@ -871,7 +910,9 @@ void TopOpeBRepBuild_CorrectFace2d::BndBoxWire(const TopoDS_Wire& aWire, Bnd_Box void TopOpeBRepBuild_CorrectFace2d::MoveWire2d(TopoDS_Wire& aWire, const gp_Vec2d& aTrV) { if (aTrV.Magnitude() < Precision::Confusion()) + { return; + } int i, aNbEdges; NCollection_Sequence aSeqEdges; @@ -896,7 +937,9 @@ void TopOpeBRepBuild_CorrectFace2d::MoveWire2d(TopoDS_Wire& aWire, const gp_Vec2 { // a. Closed edge <---> if (anEdMap.Contains(anEdge)) + { continue; + } anEdMap.Add(anEdge); TopAbs_Orientation anOri = anEdge.Orientation(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_End.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_End.cxx index 1070304d58..40d6dc9ec2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_End.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_End.cxx @@ -71,7 +71,9 @@ void TopOpeBRepBuild_Builder::End() const TopoDS_Shape& SH = exs.Current(); bool SHhassha = BDS.HasShape(SH); if (!SHhassha) + { continue; + } bool Fhassam = false; TopExp_Explorer exf; @@ -80,10 +82,14 @@ void TopOpeBRepBuild_Builder::End() // for (TopExp_Explorer exf(SH,TopAbs_FACE);exf.More(); exf.Next()) { Fhassam = myDataStructure->HasSameDomain(exf.Current()); if (Fhassam) + { break; + } } if (!Fhassam) + { continue; + } NCollection_IndexedDataMap, @@ -95,10 +101,14 @@ void TopOpeBRepBuild_Builder::End() { const TopoDS_Edge& E = TopoDS::Edge(M.FindKey(iE)); if (IsSplit(E, sta)) + { continue; + } const NCollection_List& LF = M.FindFromIndex(iE); if (LF.Extent() < 2) + { continue; + } // NYI : > 2 faces connexes par E : iterer sur tous les couples NCollection_List::Iterator itLF(LF); @@ -107,52 +117,72 @@ void TopOpeBRepBuild_Builder::End() const TopoDS_Face& F2 = TopoDS::Face(itLF.Value()); GeomAbs_Shape C = BRep_Tool::Continuity(E, F1, F2); if (C == GeomAbs_C0) + { continue; + } bool F1hassam = myDataStructure->HasSameDomain(F1); bool F2hassam = myDataStructure->HasSameDomain(F2); if (!F1hassam && !F2hassam) + { continue; + } bool F1issplit = IsSplit(F1, sta); bool F2issplit = IsSplit(F2, sta); F1issplit &= (Splits(F1, sta).Extent() != 0); F2issplit &= (Splits(F2, sta).Extent() != 0); if (!F1issplit && !F2issplit) + { continue; + } TopoDS_Face FF1 = F1, FF2 = F2; for (int ii = 1; ii <= 2; ii++) { if ((ii == 1 && !F1issplit) || (ii == 2 && !F2issplit)) + { continue; + } TopoDS_Face F; if (ii == 1) + { F = F1; + } else + { F = F2; + } bool f = false; NCollection_List::Iterator it; for (it.Initialize(Splits(F, sta)); it.More(); it.Next()) { const TopoDS_Shape& SF = it.Value(); if (SF.ShapeType() != TopAbs_FACE) + { continue; + } TopExp_Explorer ex; for (ex.Init(SF, TopAbs_EDGE); ex.More(); ex.Next()) { if (ex.Current().IsSame(E)) { if (ii == 1) + { FF1 = TopoDS::Face(it.Value()); + } else + { FF2 = TopoDS::Face(it.Value()); + } f = true; break; } } if (f) + { break; + } } } BRep_Builder B; @@ -189,7 +219,9 @@ void TopOpeBRepBuild_Builder::End() const NCollection_List& lmergesha1 = Merged(myShape1, myState1); NCollection_List::Iterator it(lmergesha1); for (; it.More(); it.Next()) + { B.Add(R, it.Value()); + } const NCollection_List& LOES = Section(); #ifdef OCCT_DEBUG // int nLOES = LOES.Extent(); @@ -210,7 +242,9 @@ void TopOpeBRepBuild_Builder::End() TopTools_ShapeMapHasher> idmovloes; for (NCollection_List::Iterator I(LOES); I.More(); I.Next()) + { TopExp::MapShapesAndAncestors(I.Value(), TopAbs_VERTEX, TopAbs_EDGE, idmovloes); + } int iv, nv = idmovloe.Extent(); for (iv = 1; iv <= nv; iv++) { @@ -218,7 +252,9 @@ void TopOpeBRepBuild_Builder::End() const TopoDS_Vertex& V = TopoDS::Vertex(idmovloe.FindKey(iv)); bool isbe = idmovloes.Contains(V); if (!isbe) + { continue; + } const NCollection_List& loe = idmovloe.FindFromIndex(iv); @@ -262,7 +298,9 @@ void TopOpeBRepBuild_Builder::End() { C2D = FC2D_CurveOnSurface(E, F, f, l, tolpc); if (C2D.IsNull()) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::End 1"); + } double tolE = BRep_Tool::Tolerance(E); double tol = std::max(tolE, tolpc); B.UpdateEdge(E, C2D, F, tol); @@ -278,7 +316,9 @@ void TopOpeBRepBuild_Builder::End() double anEdgeTol = BRep_Tool::Tolerance(E); double aFaceTol = BRep_Tool::Tolerance(F); if (anEdgeTol < aFaceTol) + { B.UpdateEdge(E, aFaceTol); + } } // modified by NIZHNY-MKK Fri Sep 29 16:08:32 2000.END } @@ -288,7 +328,9 @@ void TopOpeBRepBuild_Builder::End() double aVertexTol = BRep_Tool::Tolerance(V); double anEdgeTol = BRep_Tool::Tolerance(E); if (aVertexTol < anEdgeTol) + { B.UpdateVertex(V, anEdgeTol); + } } // modified by NIZHNY-MKK Fri Sep 29 16:54:12 2000.END } @@ -426,9 +468,13 @@ void TopOpeBRepBuild_Builder::UpdateSplitAndMerged( // edit the list of merged TopAbs_State stateMerged; if (ShapeRank(e) == 1) + { stateMerged = myState1; + } else + { stateMerged = myState2; + } NCollection_List LstMerged; LstMerged.Append(mre(iLst)); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FREGU.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FREGU.cxx index 9d4c81d1c7..8cd175acb4 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FREGU.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FREGU.cxx @@ -60,7 +60,9 @@ void TopOpeBRepBuild_Builder::RegularizeFaces(const TopoDS_Shape& int nr = myMemoSplit.Extent(); if (nr == 0) + { return; + } // lfsdFF = faces SameDomain de FF NCollection_List lfsdFF, lfsdFF1, lfsdFF2; @@ -91,11 +93,15 @@ void TopOpeBRepBuild_Builder::RegularizeFaces(const TopoDS_Shape& TopAbs_State stae = staeope; if (iiista == 2) + { stae = TopAbs_ON; + } bool issplite = IsSplit(e, stae); if (!issplite) + { continue; + } NCollection_List& lspe = ChangeSplit(e, stae); #ifdef OCCT_DEBUG @@ -107,7 +113,9 @@ void TopOpeBRepBuild_Builder::RegularizeFaces(const TopoDS_Shape& const TopoDS_Shape& esp = itl1.Value(); bool espmemo = myMemoSplit.Contains(esp); if (!espmemo) + { newlspe.Append(esp); + } else { const NCollection_List& lspesp = Splits(esp, stae); @@ -248,7 +256,9 @@ void TopOpeBRepBuild_Builder::RegularizeFace(const TopoDS_Shape& FF, // LOF = nouvelles faces regularisees de newFace NCollection_List::Iterator itlnf(newfaces); for (; itlnf.More(); itlnf.Next()) + { LOF.Append(TopoDS::Face(itlnf.Value())); + } // mise a jour des aretes decoupees // Edge(FF) = {E}, E-->Split(E) = {E'}, E'-->myESplits(E') = {E''} @@ -310,7 +320,9 @@ void TopOpeBRepBuild_Builder::RegularizeFace(const TopoDS_Shape& FF, { TopAbs_State stafsdFFe = stafsdFF; if (iiista == 2) + { stafsdFFe = TopAbs_ON; + } NCollection_List& lspfsdFFe = ChangeSplit(fsdFFe, stafsdFFe); #ifdef OCCT_DEBUG @@ -326,7 +338,9 @@ void TopOpeBRepBuild_Builder::RegularizeFace(const TopoDS_Shape& FF, const TopoDS_Shape& espfsdFFe = it.Value(); bool inmenf = menf.Contains(espfsdFFe); if (!inmenf) + { continue; + } // fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe // espfsdFFe est une arete de Split(fsdFFe) ET figure dans newFace (Cf supra E') diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FaceBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FaceBuilder.cxx index 447060782c..4d2996217e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FaceBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_FaceBuilder.cxx @@ -96,7 +96,9 @@ void FUN_DetectVerticesOn1Edge( { const TopoDS_Shape& V = mapVedges.FindKey(i); if (V.Orientation() == TopAbs_INTERNAL) + { continue; + } const NCollection_List& loE = mapVedges.FindFromIndex(i); if (loE.Extent() < 2) @@ -105,7 +107,9 @@ void FUN_DetectVerticesOn1Edge( const TopoDS_Shape& E = loE.First(); TopAbs_Orientation oriE = E.Orientation(); if ((oriE == TopAbs_INTERNAL) || (oriE == TopAbs_EXTERNAL)) + { continue; + } mapVon1E.Add(V, E); } } @@ -135,11 +139,17 @@ int FUN_AnalyzemapVon1E( bool Eclosed = BRep_Tool::IsClosed(E); bool dgE = BRep_Tool::Degenerated(TopoDS::Edge(E)); if (dgE) + { res = ISVERTEX; + } else if (Eclosed) + { res = CLOSEDW; + } else + { res = UNCLOSEDW; + } } else { @@ -171,14 +181,21 @@ int FUN_AnalyzemapVon1E( // useless chains of hanging edges that can be removed to // achieve a closed wire. if (nVV > 0) + { res = GCLOSEDW; + } #else if (nVV == nV) + { res = GCLOSEDW; + } #endif else + { res = UNCLOSEDW; + } } + return res; } // FUN_AnalyzemapVon1E @@ -210,14 +227,18 @@ void TopOpeBRepBuild_FaceBuilder::DetectUnclosedWire( { bool isold = IsOldWire(); if (isold) + { continue; + } TopoDS_Compound cmp; BRep_Builder BB; BB.MakeCompound(cmp); InitEdge(); for (; MoreEdge(); NextEdge()) + { AddEdgeWire(Edge(), cmp); + } TopoDS_Shape W = cmp; // binds vertices of connexity 1 attached to one non-closed,non-degenerated edge. @@ -344,7 +365,9 @@ void TopOpeBRepBuild_FaceBuilder::CorrectGclosedWire( const TopoDS_Vertex& Vref = TopoDS::Vertex(mapVVref.FindFromIndex(i)); if (V.IsSame(Vref)) + { continue; + } TopoDS_Edge E = TopoDS::Edge(mapVon1Edge.FindFromKey(V)); double paronE = BRep_Tool::Parameter(V, E); @@ -377,10 +400,14 @@ void TopOpeBRepBuild_FaceBuilder::DetectPseudoInternalEdge( { bool isold = IsOldWire(); if (isold) + { continue; + } InitEdge(); for (; MoreEdge(); NextEdge()) + { AddEdgeWire(Edge(), cmp); + } } // MoreWire } // MoreFace @@ -503,9 +530,13 @@ void TopOpeBRepBuild_FaceBuilder::FindNextValidElement() const int i = myBlockIterator.Value(); found = myBlockBuilder.ElementIsValid(i); if (found) + { break; + } else + { myBlockIterator.Next(); + } } } @@ -515,7 +546,9 @@ int TopOpeBRepBuild_FaceBuilder::InitEdge() { const occ::handle& L = myFaceAreaBuilder.Loop(); if (L->IsShape()) + { throw Standard_DomainError("TopOpeBRepBuild_FaceBuilder:InitEdge"); + } else { myBlockIterator = L->BlockIterator(); @@ -547,12 +580,16 @@ void TopOpeBRepBuild_FaceBuilder::NextEdge() const TopoDS_Shape& TopOpeBRepBuild_FaceBuilder::Edge() const { if (!myBlockIterator.More()) + { throw Standard_Failure("OutOfRange"); + } const int i = myBlockIterator.Value(); bool isvalid = myBlockBuilder.ElementIsValid(i); if (!isvalid) + { throw Standard_Failure("Edge not Valid"); + } const TopoDS_Shape& E = myBlockBuilder.Element(i); return E; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GIter.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GIter.cxx index 8d573ab25e..8e44fc1f00 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GIter.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GIter.cxx @@ -38,7 +38,9 @@ void TopOpeBRepBuild_GIter::Find() { bool b = MYGTOPO.Value(myII); if (b) + { break; + } myII++; } } @@ -63,7 +65,9 @@ bool TopOpeBRepBuild_GIter::More() const return b; } else + { return false; + } } void TopOpeBRepBuild_GIter::Next() @@ -88,10 +92,12 @@ void TopOpeBRepBuild_GIter::Current(TopAbs_State& s1, TopAbs_State& s2) const void TopOpeBRepBuild_GIter::Dump(Standard_OStream& OS) const { if (!More()) + { return; + } TopAbs_State s1, s2; Current(s1, s2); bool b = MYGTOPO.Value(s1, s2); TopOpeBRepBuild_GTopo::DumpSSB(OS, s1, s2, b); - OS << std::endl; + OS << '\n'; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTool.cxx index 7cebfc722d..8eebb4e02f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTool.cxx @@ -208,30 +208,40 @@ void TopOpeBRepBuild_GTool::Dump(Standard_OStream& OS) g = TopOpeBRepBuild_GTool::GFusUnsh(TopAbs_FACE, TopAbs_FACE); g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) + { gi.Dump(OS); - OS << std::endl; + } + OS << '\n'; g = TopOpeBRepBuild_GTool::GFusSame(TopAbs_FACE, TopAbs_FACE); g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) + { gi.Dump(OS); - OS << std::endl; + } + OS << '\n'; g = TopOpeBRepBuild_GTool::GFusDiff(TopAbs_FACE, TopAbs_FACE); g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) + { gi.Dump(OS); - OS << std::endl; + } + OS << '\n'; g = TopOpeBRepBuild_GTool::GCutDiff(TopAbs_FACE, TopAbs_EDGE); g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) + { gi.Dump(OS); - OS << std::endl; + } + OS << '\n'; g = g.CopyPermuted(); g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) + { gi.Dump(OS); - OS << std::endl; + } + OS << '\n'; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTopo.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTopo.cxx index 2d26d31a90..35f1cd734e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTopo.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GTopo.cxx @@ -171,13 +171,21 @@ void TopOpeBRepBuild_GTopo::ChangeValue(const TopAbs_State s1, const TopAbs_Stat int TopOpeBRepBuild_GTopo::GIndex(const TopAbs_State s) const { if (s == TopAbs_IN) + { return 0; + } else if (s == TopAbs_ON) + { return 1; + } else if (s == TopAbs_OUT) + { return 2; + } else + { throw Standard_ProgramError("GIndex : bad input"); + } } //================================================================================================= @@ -185,13 +193,21 @@ int TopOpeBRepBuild_GTopo::GIndex(const TopAbs_State s) const TopAbs_State TopOpeBRepBuild_GTopo::GState(const int i) const { if (i == 0) + { return TopAbs_IN; + } else if (i == 1) + { return TopAbs_ON; + } else if (i == 2) + { return TopAbs_OUT; + } else + { throw Standard_ProgramError("GState : bad input"); + } } //================================================================================================= @@ -281,45 +297,55 @@ void TopOpeBRepBuild_GTopo::Dump(Standard_OStream& OS, void* const a) const TopOpeBRepDS::Print(myConfig1, OS); OS << " "; TopOpeBRepDS::Print(myConfig2, OS); - OS << std::endl; + OS << '\n'; if (myReverseForce) - OS << "reverse value : " << myReverseValue << std::endl; + { + OS << "reverse value : " << myReverseValue << '\n'; + } if (s) + { OS << s; + } OS << "\\ I N O"; - OS << std::endl; + OS << '\n'; if (s) + { OS << s; + } OS << "I "; DumpVal(OS, TopAbs_IN, TopAbs_IN); OS << " "; DumpVal(OS, TopAbs_IN, TopAbs_ON); OS << " "; DumpVal(OS, TopAbs_IN, TopAbs_OUT); - OS << std::endl; + OS << '\n'; if (s) + { OS << s; + } OS << "N "; DumpVal(OS, TopAbs_ON, TopAbs_IN); OS << " "; DumpVal(OS, TopAbs_ON, TopAbs_ON); OS << " "; DumpVal(OS, TopAbs_ON, TopAbs_OUT); - OS << std::endl; + OS << '\n'; if (s) + { OS << s; + } OS << "O "; DumpVal(OS, TopAbs_OUT, TopAbs_IN); OS << " "; DumpVal(OS, TopAbs_OUT, TopAbs_ON); OS << " "; DumpVal(OS, TopAbs_OUT, TopAbs_OUT); - OS << std::endl; + OS << '\n'; } //================================================================================================= @@ -328,15 +354,23 @@ void TopOpeBRepBuild_GTopo::StatesON(TopAbs_State& s1, TopAbs_State& s2) const { s1 = TopAbs_UNKNOWN; if (Value(TopAbs_ON, TopAbs_IN)) + { s1 = TopAbs_IN; + } else if (Value(TopAbs_ON, TopAbs_OUT)) + { s1 = TopAbs_OUT; + } s2 = TopAbs_UNKNOWN; if (Value(TopAbs_IN, TopAbs_ON)) + { s2 = TopAbs_IN; + } else if (Value(TopAbs_OUT, TopAbs_ON)) + { s2 = TopAbs_OUT; + } if (s1 == TopAbs_UNKNOWN || s2 == TopAbs_UNKNOWN) { @@ -358,9 +392,13 @@ bool TopOpeBRepBuild_GTopo::IsToReverse1() const StatesON(s1, s2); bool IsToRev; if (s1 == TopAbs_IN && s2 == TopAbs_IN) + { IsToRev = false; + } else + { IsToRev = (s1 == TopAbs_IN); + } return IsToRev; } // throw Standard_ProgramError("GTopo::IsToReverse1"); @@ -381,9 +419,13 @@ bool TopOpeBRepBuild_GTopo::IsToReverse2() const StatesON(s1, s2); bool IsToRev; if (s1 == TopAbs_IN && s2 == TopAbs_IN) + { IsToRev = false; + } else + { IsToRev = (s2 == TopAbs_IN); + } return IsToRev; } } @@ -401,7 +443,9 @@ void TopOpeBRepBuild_GTopo::SetReverse(const bool rev) bool TopOpeBRepBuild_GTopo::Reverse() const { if (myReverseForce) + { return myReverseValue; + } throw Standard_ProgramError("GTopo::ReverseValue undefined"); } @@ -415,10 +459,16 @@ TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTopo::CopyPermuted() const g.ChangeConfig(myConfig2, myConfig1); int i, j; for (i = 0; i < 3; i++) + { for (j = 0; j < 3; j++) + { g.ChangeValue(j, i, Value(i, j)); + } + } if (myReverseForce) + { g.SetReverse(myReverseValue); + } return g; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Grid.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Grid.cxx index 6d07d48493..b60d6f7fd9 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Grid.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Grid.cxx @@ -128,13 +128,21 @@ bool TopOpeBRepBuild_Builder::GTakeCommonOfSame(const TopOpeBRepBuild_GTopo& G) G.StatesON(t1, t2); bool sam = false; if (t1 == TopAbs_OUT && t2 == TopAbs_OUT) + { sam = true; + } else if (t1 == TopAbs_OUT && t2 == TopAbs_IN) + { sam = false; + } else if (t1 == TopAbs_IN && t2 == TopAbs_OUT) + { sam = false; + } else if (t1 == TopAbs_IN && t2 == TopAbs_IN) + { sam = true; + } return sam; } @@ -147,13 +155,21 @@ bool TopOpeBRepBuild_Builder::GTakeCommonOfDiff(const TopOpeBRepBuild_GTopo& G) G.StatesON(t1, t2); bool dif = false; if (t1 == TopAbs_OUT && t2 == TopAbs_OUT) + { dif = false; + } else if (t1 == TopAbs_OUT && t2 == TopAbs_IN) + { dif = true; + } else if (t1 == TopAbs_IN && t2 == TopAbs_OUT) + { dif = true; + } else if (t1 == TopAbs_IN && t2 == TopAbs_IN) + { dif = false; + } return dif; } @@ -259,7 +275,9 @@ void TopOpeBRepBuild_Builder::GFindSamDomSODO(NCollection_List& LS NCollection_List::Iterator it; it.Initialize(LSO); if (!it.More()) + { return; + } const TopoDS_Shape& sref = it.Value(); #ifdef OCCT_DEBUG // int iref = myDataStructure->SameDomainReference(sref); @@ -291,9 +309,13 @@ void TopOpeBRepBuild_Builder::GFindSamDomSODO(NCollection_List& LS // int iS = myDataStructure->Shape(s); #endif if (o == oref && !GContains(s, LLSO)) + { LLSO.Append(s); + } else if (o != oref && !GContains(s, LLDO)) + { LLDO.Append(s); + } } for (it.Initialize(LDO); it.More(); it.Next()) @@ -304,9 +326,13 @@ void TopOpeBRepBuild_Builder::GFindSamDomSODO(NCollection_List& LS // int iS = myDataStructure->Shape(s); #endif if (o == oref && !GContains(s, LLSO)) + { LLSO.Append(s); + } else if (o != oref && !GContains(s, LLDO)) + { LLDO.Append(s); + } } LSO = LLSO; @@ -321,9 +347,13 @@ void TopOpeBRepBuild_Builder::GMapShapes(const TopoDS_Shape& S1, const TopoDS_Sh bool S2null = S2.IsNull(); GClearMaps(); if (!S1null) + { TopExp::MapShapes(S1, myMAP1); + } if (!S2null) + { TopExp::MapShapes(S2, myMAP2); + } } //================================================================================================= @@ -369,12 +399,18 @@ int TopOpeBRepBuild_Builder::GShapeRank(const TopoDS_Shape& S) const bool TopOpeBRepBuild_Builder::GIsShapeOf(const TopoDS_Shape& S, const int I) const { if (S.IsNull()) + { return false; + } bool b = false; if (I == 1) + { b = myMAP1.Contains(S); + } else if (I == 2) + { b = myMAP2.Contains(S); + } return b; } @@ -390,7 +426,9 @@ bool TopOpeBRepBuild_Builder::GContains(const TopoDS_Shape& S, const TopoDS_Shape& SL = it.Value(); bool issame = SL.IsSame(S); if (issame) + { return true; + } } return false; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridEE.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridEE.cxx index 79b8b31184..974b6936c6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridEE.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridEE.cxx @@ -62,7 +62,9 @@ void TopOpeBRepBuild_Builder::GMergeEdges(const NCollection_List& const TopOpeBRepBuild_GTopo& G1) { if (LE1.IsEmpty()) + { return; + } TopAbs_State TB1, TB2; G1.StatesON(TB1, TB2); @@ -91,7 +93,9 @@ void TopOpeBRepBuild_Builder::GMergeEdges(const NCollection_List& TopOpeBRepBuild_PaveClassifier VCL(E1F); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } TopOpeBRepBuild_EdgeBuilder EDBU(PVS, VCL); // Build the new edges LEM @@ -124,7 +128,9 @@ void TopOpeBRepBuild_Builder::GFillEdgesPVS(const NCollection_List TopOpeBRepBuild_PaveSet& PVS) { if (LE1.IsEmpty()) + { return; + } TopAbs_State TB1, TB2; G1.StatesON(TB1, TB2); @@ -152,7 +158,9 @@ void TopOpeBRepBuild_Builder::GFillEdgesPVS(const NCollection_List #endif if (!ismerged) + { GFillEdgePVS(E11, LE2, G1, PVS); + } } TopOpeBRepBuild_GTopo G2 = G1.CopyPermuted(); @@ -178,7 +186,9 @@ void TopOpeBRepBuild_Builder::GFillEdgesPVS(const NCollection_List #endif if (!ismerged) + { GFillEdgePVS(E2, LE1, G2, PVS); + } } } // GFillEdgesPVS @@ -222,7 +232,9 @@ static bool FUN_MoreSHAINT(TopOpeBRepDS_PointIterator& EPit, const TopAbs_ShapeE TopAbs_ShapeEnum b = T.ShapeBefore(), a = T.ShapeAfter(); bool rejet = ((b != SHA) || (a != SHA)); if (rejet) + { EPit.Next(); + } else { more = true; @@ -282,11 +294,9 @@ void debfillp2(const int i) // Standard_IMPORT extern bool GLOBAL_faces2d; extern bool GLOBAL_faces2d; -Standard_EXPORT bool FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS, - const int SI, - const occ::handle& I); -// Standard_IMPORT extern bool GLOBAL_IEtoMERGE; // xpu240498 -Standard_IMPORT bool GLOBAL_IEtoMERGE; // xpu240498 +Standard_EXPORT + // Standard_IMPORT extern bool GLOBAL_IEtoMERGE; // xpu240498 + Standard_IMPORT bool GLOBAL_IEtoMERGE; // xpu240498 // Standard_IMPORT extern int GLOBAL_issp; extern int GLOBAL_issp; // Standard_IMPORT extern int GLOBAL_hassd; @@ -375,7 +385,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& bool isspin = (GLOBAL_issp == TheIN), isspou = (GLOBAL_issp == TheOUT), isspon = (GLOBAL_issp == TheON); if (isSE && (GLOBAL_issp == 0)) + { return; // splits done in process ProcessSectionEdges + } #ifdef OCCT_DEBUG // int iefil = BDS.Shape(E); @@ -405,7 +417,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& // - dont la transition est definie / shape = ShapeInterf NCollection_List> loiSHAINT; if (scanall) + { FDS_assign(lIE, loiSHAINT); + } else { TopOpeBRepDS_PointIterator EPit(lIE); @@ -455,7 +469,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& tki.Next(); } if (nG == 1) + { kp1 = 0; // we have only one interf on vGclo -> keep the interf + } } // kp1 // - kp6 - nyiReducing @@ -472,11 +488,15 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& const occ::handle& I = it.Value(); TopOpeBRepDS_Kind ST = I->SupportType(); if (ST != TopOpeBRepDS_FACE) + { continue; + } TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN); bool FORREV = (O == TopAbs_FORWARD) || (O == TopAbs_REVERSED); if (!FORREV) + { continue; + } bool Gb1 = ::FUN_isonbound(myDataStructure, I); if (!Gb1) { @@ -500,7 +520,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& bool vertex = (Kcur == TopOpeBRepDS_VERTEX); // xpu170498 TopoDS_Shape vGsd; if (vertex) + { FUN_ds_getoov(BDS.Shape(Gcur), myDataStructure, vGsd); // xpu221098 + } // recall : I3d=(I3dF,I3dFE) : I3dF=(T(F),G,F), I3dFE=(T(F),G,E) // I2d=I2dFE @@ -605,9 +627,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& INb = bIN3d; INa = aIN3d; if (INb) + { newT.Index(isb); + } else + { newT.Index(isa); + } newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } @@ -621,9 +647,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& INb = !bOUT3d; INa = !aOUT3d; if (bOUT3d) + { newT.Index(isb); + } else + { newT.Index(isa); + } newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } @@ -653,7 +683,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& // xpu200598 interference 2d at GPOINT bool kp3 = (n2d > 0) && point; if (kp3) + { l2dFEcur.First()->Transition().Orientation(TopAbs_IN); + } TopOpeBRepDS_PointIterator itCur(LICur); while (itCur.More()) @@ -723,14 +755,18 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& { bool Gb1 = ::FUN_isonbound(myDataStructure, I1); if (!Gb1) + { GFillPointTopologyPVS(E, itCur, G, PVS); + } } else { GFillPointTopologyPVS(E, itCur, G, PVS); } if (!dgE) + { break; // xpu140498 + } } // keepinterf1 itCur.Next(); } // itCur.More @@ -772,12 +808,18 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& bool ispoint = EPit.IsPoint(); TopoDS_Vertex VIG; // NYI pointer if (ispoint) + { VIG = TopoDS::Vertex(NewVertex(iG)); + } else + { VIG = TopoDS::Vertex(myDataStructure->Shape(iG)); + } if (VIG.IsNull()) + { return; // PMN 17/02/99 Nothing to add. + } bool hasVSD = false; int iVRE = 0; @@ -794,9 +836,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& TopoDS_Vertex VPV; // NYI pointer on VRE or VIG if (hasVSD) + { VPV = TopoDS::Vertex(VRE); + } else + { VPV = VIG; + } // else VPV = TopoDS::Vertex(VIG); double par = EPit.Parameter(); @@ -809,13 +855,17 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& bool samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(E, EPVS); if (Conf == TopOpeBRepDS_DIFFORIENTED) + { ori = TopAbs::Complement(ori); + } #ifdef OCCT_DEBUG if (!TopOpeBRepBuild_GetcontextNOSG()) { #endif if (!samegeom) + { ori = TopAbs::Complement(ori); + } #ifdef OCCT_DEBUG } #endif @@ -862,7 +912,9 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& TopoDS_Shape VSD; bool ok = FUN_ds_getoov(VIG, myDataStructure->DS(), VSD); if (ok) + { kpbound = vclo.IsSame(VSD); + } } } } @@ -878,9 +930,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& const TopoDS_Shape& VSD = myDataStructure->DS().ShapeSameDomain(VPV).First(); int iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) + { PV->SameDomain(VIG); + } else + { PV->SameDomain(VSD); + } } // modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PV->InterferenceType() = ST1; @@ -923,9 +979,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& const TopoDS_Shape& VSD = myDataStructure->DS().ShapeSameDomain(VPV).First(); int iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) + { PVF->SameDomain(VIG); + } else + { PVF->SameDomain(VSD); + } } // modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PVF->InterferenceType() = ST1; @@ -959,9 +1019,13 @@ void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& const TopoDS_Shape& VSD = myDataStructure->DS().ShapeSameDomain(VPV).First(); int iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) + { PVR->SameDomain(VIG); + } else + { PVR->SameDomain(VSD); + } } // modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PVR->InterferenceType() = ST1; @@ -1019,7 +1083,9 @@ bool TopOpeBRepBuild_Builder::GParamOnReference(const TopoDS_Vertex& V, occ::handle C2D; C2D = FC2D_CurveOnSurface(myEdgeReference, myFaceReference, f, l, tolpc); if (C2D.IsNull()) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::GParamOnReference"); + } // double U; Geom2dAdaptor_Curve AC(C2D); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridFF.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridFF.cxx index 6d21c25b16..e7b347b125 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridFF.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridFF.cxx @@ -156,7 +156,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, int rkF = BDS.AncestorRank(F); bool hasspE = BU.IsSplit(E, TopAbs_ON); if (hasspE) + { hasspE = (BU.Splits(E, TopAbs_ON).Extent() > 0); + } NCollection_Map Ffound; NCollection_List Fsdm; @@ -166,7 +168,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& f = itf.Value(); int rkf = BDS.AncestorRank(f); if (rkf == rkF) + { continue; + } Fsdm.Append(f); } @@ -181,18 +185,24 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, int G, S; FDS_Idata(I, SB, IB, SA, IA, GT, G, ST, S); if (ST != TopOpeBRepDS_EDGE) + { return false; + } TopoDS_Face FTRA; int ITRA = IB; if (SB == TopAbs_FACE) + { FTRA = TopoDS::Face(BDS.Shape(IB)); + } else if (SB == TopAbs_EDGE) { bool ok = FUN_tool_findAncestor(Fsdm, TopoDS::Edge(BDS.Shape(S)), FTRA); ITRA = BDS.Shape(FTRA); if (!ok) + { return false; + } } bool found = Ffound.Contains(FTRA); @@ -208,7 +218,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S)); bool hasspES = BU.IsSplit(ES, TopAbs_ON); if (hasspES) + { hasspE = (BU.Splits(ES, TopAbs_ON).Extent() > 0); + } bool sdm = FUN_ds_sdm(BDS, E, ES); bool mkTonEsdm = sdm && hasspE && !found; @@ -241,7 +253,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, double parES; bool ok = FUN_tool_parE(E, parE, ES, parES); if (!ok) + { continue; + } ok = FUN_ds_mkTonFsdm(BU.DataStructure(), ITRA, IF, IE, S, parES, dummy, true, newT); if (ok) { @@ -271,7 +285,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, double parES; bool ok = FUN_tool_parE(E, parE, ES, parES); if (!ok) + { continue; + } TopoDS_Edge dummy; TopOpeBRepDS_Transition newT; @@ -303,7 +319,9 @@ bool FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, const TopoDS_Edge& E = TopoDS::Edge(ex.Current()); bool ok = FUN_computeLIFfaces2d(BU, F, E, pDS2d); if (!ok) + { return false; + } } return true; } @@ -319,9 +337,13 @@ void TopOpeBRepBuild_Builder::GMergeFaces(const NCollection_List& const TopOpeBRepBuild_GTopo& G1) { if (LF1.IsEmpty()) + { return; + } if (GLOBAL_DS2d == nullptr) + { GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure) new TopOpeBRepDS_DataStructure(); + } GLOBAL_DS2d->Init(); TopAbs_State TB1, TB2; @@ -345,12 +367,16 @@ void TopOpeBRepBuild_Builder::GMergeFaces(const NCollection_List& // GLOBAL_DS2d->AddShape(itF1.Value(),1); NCollection_List::Iterator itF1(LF1); for (; itF1.More(); itF1.Next()) + { GLOBAL_DS2d->AddShape(itF1.Value(), 1); + } // for (NCollection_List::Iterator itF2(LF2); itF2.More(); itF2.Next()) // GLOBAL_DS2d->AddShape(itF2.Value(),2); NCollection_List::Iterator itF2(LF2); for (; itF2.More(); itF2.Next()) + { GLOBAL_DS2d->AddShape(itF2.Value(), 2); + } // for (itF1.Initialize(LF1); itF1.More(); itF1.Next()){ itF1.Initialize(LF1); @@ -429,7 +455,9 @@ void TopOpeBRepBuild_Builder::GMergeFaces(const NCollection_List& const TopoDS_Shape& F2 = it2.Value(); bool tomerge = !IsMerged(F2, TB2); if (tomerge) + { ChangeMerged(F2, TB2) = LFM; + } } } // GMergeFaces @@ -453,14 +481,20 @@ static bool FUN_validF1edge(const TopoDS_Shape& F) { const TopoDS_Shape& e = exE.Current(); if (mEt.Contains(e)) + { continue; + } mEt.Add(e); nE++; if (nE > 2) + { break; + } } if (nE > 1) + { return true; + } if (nE == 1) { exE.Init(F, TopAbs_EDGE); @@ -482,7 +516,9 @@ void TopOpeBRepBuild_Builder::GFillFacesWESMakeFaces(const NCollection_List LF1; @@ -495,9 +531,13 @@ void TopOpeBRepBuild_Builder::GFillFacesWESMakeFaces(const NCollection_ListShape(iFF).Orientation(); for (NCollection_List::Iterator itt(LOFS); itt.More(); itt.Next()) + { itt.ChangeValue().Orientation(odsFF); + } NCollection_List::Iterator it1; for (it1.Initialize(LF1); it1.More(); it1.Next()) @@ -613,7 +659,9 @@ void TopOpeBRepBuild_Builder::GFillFaceWES(const TopoDS_Shape& bool ComOfCut = opeCut && (TB1 == TB2) && (TB1 == TopAbs_IN); // xpu200598 bool hsdm = myDataStructure->HasSameDomain(FOR1); // xpu200598 if (hsdm && ComOfCut) + { return; // xpu200598 + } // work on a FORWARD face FF TopoDS_Shape FF = FOR1; @@ -639,7 +687,9 @@ void TopOpeBRepBuild_Builder::GFillFaceWES(const TopoDS_Shape& WES.AddShape(W); } else if (myProcessON && pos == TopAbs_ON) + { myONElemMap.Add(W); + } } else { // wire W has edges(s) with geometry : split W edges @@ -652,7 +702,6 @@ void TopOpeBRepBuild_Builder::GFillFaceWES(const TopoDS_Shape& GdumpSHASTA(iF, TB1, WES, "--- GFillFaceWES", "END"); #endif - return; } // GFillFaceWES //================================================================================================= @@ -760,7 +809,9 @@ static void FUN_samgeomori(const TopOpeBRepDS_DataStructure& BDS, TopAbs_Orientation oref = BDS.Shape(iref).Orientation(), ofil = BDS.Shape(ifil).Orientation(); samgeomori = (cfill == TopOpeBRepDS_SAMEORIENTED); if (oref == TopAbs::Complement(ofil)) + { samgeomori = !samgeomori; + } } #define UNKNOWN (0) @@ -809,7 +860,9 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& FUN_samgeomori(BDS, iref, ifil, samegeomori); reverse = (!samegeomori); if (oref == TopAbs_REVERSED) + { reverse = !reverse; + } } // TopAbs_Orientation oref=myFaceReference.Orientation(), // ofill=myFaceToFill.Orientation(); bool reverse = (oref != ofill); @@ -817,16 +870,22 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& TopAbs_Orientation oEinfillTOref = reverse ? TopAbs::Complement(oEinfill) : oEinfill; bool same = (oEinF == oEinfillTOref); if (!same && (oEinF != TopAbs_INTERNAL) && (oEinF != TopAbs_EXTERNAL)) + { oEinF = oEinfillTOref; + } } } else + { Oinref = FUN_ds_oriEinF(BDS, TopoDS::Edge(EOR), myFaceToFill, oEinF); // xpu060598 - bool newO = (Oinref == ONSAMESHA) || (Oinref == ONOPPOSHA); // xpu060598 + } + bool newO = (Oinref == ONSAMESHA) || (Oinref == ONOPPOSHA); // xpu060598 bool isfafa = (myIsKPart == 3); if (isfafa) + { newO = false; // xpu110598 + } // if (fus) : faces are SDSO : we keep original edge's orientation // if (com) : faces are SDSO : we keep original edge's orientation @@ -887,9 +946,13 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& // xpu200598 : never add spIN in fusion bool opeFus = Opefus(); // xpu200598 - if (opeFus) // xpu200598 + if (opeFus) + { // xpu200598 if (TB1 == TopAbs_IN) + { return; // xpu200598 + } + } bool issplit = IsSplit(EOR, TB1); if (issplit) @@ -938,7 +1001,9 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& } //! dgE && hsdmE } // xpu060598 else + { newE.Orientation(neworiE); + } #ifdef OCCT_DEBUG if (tSPS) @@ -978,9 +1043,13 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& TopAbs_State pos; bool keepse = GKeepShape1(EOR, LSclass, TB1, pos); if (keepse) + { add = true; + } else if (myProcessON && pos == TopAbs_ON) + { addON = true; + } } #ifdef OCCT_DEBUG @@ -1019,9 +1088,13 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& { bool testON = (!LSclass.IsEmpty()); if (testON) + { testON = (LSclass.First().ShapeType() == TopAbs_SOLID); + } if (testON) + { keep = (pos == TopAbs_ON); + } addON = myProcessON && keep; } add = keep; @@ -1033,13 +1106,17 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& TopoDS_Shape newE = EOR; if (newO) + { newE.Orientation(oEinF); // xpu060598 // clang-format off - else if (Oinref == FORREVOPPO) newE.Orientation(TopAbs_INTERNAL);// xpu120898 (PRO14785 : e36 shared by f34 & f39, + } else if (Oinref == FORREVOPPO) { newE.Orientation(TopAbs_INTERNAL);// xpu120898 (PRO14785 : e36 shared by f34 & f39, // faces sdm with f16) // clang-format on + } else + { newE.Orientation(neworiE); + } #ifdef OCCT_DEBUG if (tSPS) { @@ -1107,11 +1184,15 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& #endif } if (!so) + { newE.Reverse(); + } } } else + { newE.Orientation(neworiE); + } myONElemMap.Add(newE); } } @@ -1121,7 +1202,6 @@ void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& GdumpSHASTA(iEOR, TB1, WES, "--- GSplitEdgeWES", "END"); #endif - return; } // GSplitEdgeWES Standard_IMPORT bool FUN_ismotheropedef(); @@ -1154,10 +1234,14 @@ void TopOpeBRepBuild_Builder::GMergeEdgeWES(const TopoDS_Shape& EOR, bool closing = BRep_Tool::IsClosed(TopoDS::Edge(EOR), myFaceToFill); // xpu050598 if (closing) + { return; // xpu050598 + } if (Opefus()) + { return; + } // const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); TopAbs_State TB1, TB2; @@ -1168,7 +1252,9 @@ void TopOpeBRepBuild_Builder::GMergeEdgeWES(const TopoDS_Shape& EOR, bool hassame = myDataStructure->HasSameDomain(EOR); if (!hassame) + { return; + } bool Eisref = false; if (hassame) @@ -1180,13 +1266,17 @@ void TopOpeBRepBuild_Builder::GMergeEdgeWES(const TopoDS_Shape& EOR, TopAbs_State TBEOR = (Eisref) ? TB1 : TB2; if (TBEOR == TopAbs_OUT) + { return; // xpu040598 + } bool ismerged = IsMerged(EOR, TBEOR); if (ismerged) { if (!Eisref) + { return; + } const NCollection_List& ME = Merged(EOR, TBEOR); NCollection_List::Iterator it(ME); @@ -1220,7 +1310,9 @@ void TopOpeBRepBuild_Builder::GMergeEdgeWES(const TopoDS_Shape& EOR, bool issplit = IsSplit(EOR, stspEOR); if (!issplit) + { return; + } ChangeMerged(EOR, TBEOR) = Splits(EOR, stspEOR); @@ -1320,7 +1412,9 @@ void TopOpeBRepBuild_Builder::GSplitEdge(const TopoDS_Shape& E bool novertex = LOE.IsEmpty(); if (novertex) + { return; + } NCollection_List& SEL = ChangeSplit(EF, TB1); SEL.Clear(); @@ -1347,9 +1441,13 @@ void TopOpeBRepBuild_Builder::GSplitEdge(const TopoDS_Shape& E int r = GShapeRank(EOR); TopoDS_Shape oos = myShape1; if (r == 1) + { oos = myShape2; + } if (!oos.IsNull()) + { loos.Append(oos); // PMN 5/03/99 Nothing to append + } pls = &loos; } else if (toclass) @@ -1368,9 +1466,13 @@ void TopOpeBRepBuild_Builder::GSplitEdge(const TopoDS_Shape& E const TopoDS_Shape& aE = it.Value(); TopAbs_State pos; if (GKeepShape1(aE, *pls, TB1, pos)) + { SEL.Append(aE); + } else if (myProcessON && pos == TopAbs_ON) + { aLON.Append(aE); + } } if (!aLON.IsEmpty()) @@ -1401,7 +1503,9 @@ TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E, const TopoDS_Sh // it means that we are in degenerated edge const TopoDS_Vertex& fv = TopExp::FirstVertex(E); if (fv.IsNull()) + { return TopAbs_UNKNOWN; + } aP3d = BRep_Tool::Pnt(fv); } else diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridSS.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridSS.cxx index c8b74ce3c7..d0eb53109e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridSS.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_GridSS.cxx @@ -77,12 +77,11 @@ Standard_EXPORT void debspanc(const int i) int GLOBAL_iexF = 0; #endif -Standard_EXPORT occ::handle BASISCURVE2D(const occ::handle& C); -Standard_EXPORT void TopOpeBRepDS_SetThePCurve(const BRep_Builder& B, - TopoDS_Edge& E, - const TopoDS_Face& F, - const TopAbs_Orientation O, - const occ::handle& C); +Standard_EXPORT Standard_EXPORT void TopOpeBRepDS_SetThePCurve(const BRep_Builder& B, + TopoDS_Edge& E, + const TopoDS_Face& F, + const TopAbs_Orientation O, + const occ::handle& C); // Standard_IMPORT int FUN_tool_outofUVbounds //(const TopoDS_Face& fF,const TopoDS_Edge& E,double& splitpar); @@ -100,7 +99,9 @@ static int FUN_getG(const gp_Pnt& const occ::handle& I = ILI.Value(); SSI = occ::down_cast(I); if (SSI.IsNull()) + { continue; + } int GI = SSI->Geometry(); iEinterf = SSI->Support(); const TopOpeBRepDS_Point& DSP = HDS->Point(GI); @@ -108,7 +109,9 @@ static int FUN_getG(const gp_Pnt& double tolp = DSP.Tolerance(); bool sameP = P3d.IsEqual(P, tolp); if (sameP) + { return GI; + } } return 0; } @@ -149,12 +152,16 @@ static bool FUN_EPIforEvisoONperiodicF( int recadre = CORRISO.EdgeOUTofBoundsUV(E, onU, tolu, parone); // int recadre = FUN_tool_outofUVbounds(F,E,parone); if (recadre != SPLITEDGE) + { return false; + } gp_Pnt p3d; bool ok = FUN_tool_value(parone, E, p3d); if (!ok) + { return false; // nyi FUN_Raise + } int iEinterf = 0; int iG = FUN_getG(p3d, EPIlist, HDS, iEinterf); if (iG == 0) @@ -162,7 +169,9 @@ static bool FUN_EPIforEvisoONperiodicF( return false; } if (HDS->Shape(iEinterf).ShapeType() != TopAbs_EDGE) + { iEinterf = 0; + } // else V2pi = TopoDS::Vertex(newV->Array1().Value(iG)); // : @@ -235,12 +244,16 @@ static void FUN_getEPI(const NCollection_List& I = ILI.Value(); CPI = occ::down_cast(I); if (CPI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(CPI, GT, GI, ST, SI); if (GT != TopOpeBRepDS_POINT || ST != TopOpeBRepDS_FACE) + { continue; + } EPI.Append(I); } } @@ -271,7 +284,9 @@ void TopOpeBRepBuild_Builder::GMergeSolids(const NCollection_List& const TopOpeBRepBuild_GTopo& G1) { if (LSO1.IsEmpty()) + { return; + } TopAbs_State TB1, TB2; G1.StatesON(TB1, TB2); @@ -310,7 +325,9 @@ void TopOpeBRepBuild_Builder::GMergeSolids(const NCollection_List& const TopoDS_Shape& aSO1 = it1.Value(); bool ismerged = IsMerged(aSO1, TB1); if (ismerged) + { continue; + } NCollection_List& SOL = ChangeMerged(aSO1, TB1); SOL = LSOM; } @@ -322,7 +339,9 @@ void TopOpeBRepBuild_Builder::GMergeSolids(const NCollection_List& const TopoDS_Shape& SO2 = it2.Value(); bool ismerged = IsMerged(SO2, TB2); if (ismerged) + { continue; + } NCollection_List& SOL = ChangeMerged(SO2, TB2); SOL = LSOM; } @@ -338,7 +357,9 @@ void TopOpeBRepBuild_Builder::GFillSolidsSFS(const NCollection_List& _IM) { for (NCollection_List::Iterator it(LOFS); it.More(); it.Next()) + { FUNBUILD_MAPSUBSHAPES(it.Value(), T, _IM); + } } // ---------------------------------------------------------------------- @@ -651,7 +682,9 @@ static void FUNBUILD_MAPANCSPLSHAPES( const TopoDS_Shape& sps = it.Value(); // sps = split result of S on state STATE NCollection_List thelist; if (!_IDM.Contains(sps)) + { _IDM.Add(sps, thelist); + } _IDM.ChangeFromKey(sps).Append(S); } } @@ -677,7 +710,9 @@ static void FUNBUILD_MAPANCSPLSHAPES( { int n = M.Extent(); for (int i = 1; i <= n; i++) + { FUNBUILD_MAPANCSPLSHAPES(B, M(i), _IDM); + } } static NCollection_IndexedMap stabuild_IMELF1; @@ -724,7 +759,9 @@ Standard_EXPORT void FUNBUILD_ANCESTORRANKGET(TopOpeBRepBuild_Builder& /*B*/, const TopoDS_Shape& e = stabuild_IMEF(ief); of1 = stabuild_IDMEALF1.Contains(e); if (of1) + { break; + } } of2 = false; for (ief = 1; ief <= nef; ief++) @@ -732,7 +769,9 @@ Standard_EXPORT void FUNBUILD_ANCESTORRANKGET(TopOpeBRepBuild_Builder& /*B*/, const TopoDS_Shape& e = stabuild_IMEF(ief); of2 = stabuild_IDMEALF2.Contains(e); if (of2) + { break; + } } } @@ -752,9 +791,13 @@ Standard_EXPORT void FUNBUILD_ORIENTLOFS(TopOpeBRepBuild_Builder& B, bool r21 = TopOpeBRepBuild_Builder::Reverse(TB2, TB1); bool rf = false; if (of1 && !of2) + { rf = r12; + } else if (of2 && !of1) + { rf = r21; + } TopAbs_Orientation neworif = TopOpeBRepBuild_Builder::Orient(orif, rf); f.Orientation(neworif); } @@ -865,16 +908,24 @@ void TopOpeBRepBuild_Builder::GSplitFaceSFS(const TopoDS_Shape& // xpu280598 : cto100G1 spIN(f21) TopAbs_State TBAnc = TopAbs_UNKNOWN; if (opec12) + { TBAnc = (rkAnc == 1) ? TopAbs_OUT : TopAbs_IN; + } if (opec21) + { TBAnc = (rkAnc == 2) ? TopAbs_OUT : TopAbs_IN; + } // if TBAnc == OUT : we keep orientation // else we reverse it if (TBAnc == TopAbs_OUT) + { neworiF = oAnc; + } else + { neworiF = TopAbs::Complement(oAnc); + } } else if (opeFus) { @@ -888,16 +939,24 @@ void TopOpeBRepBuild_Builder::GSplitFaceSFS(const TopoDS_Shape& bool samegeom = false; TopOpeBRepDS_Config cAnc = BDS.SameDomainOri(iAnc); if (cAnc == TopOpeBRepDS_SAMEORIENTED) + { samegeom = true; + } else if (cAnc == TopOpeBRepDS_DIFFORIENTED) + { samegeom = false; + } TopAbs_Orientation orefAnc = BDS.Shape(irefAnc).Orientation(); if (oAnc != orefAnc) + { samegeom = !samegeom; + } reverse = !samegeom; } if (reverse) + { neworiF = TopAbs::Complement(neworiF); + } } // hasoridef } @@ -986,7 +1045,9 @@ void TopOpeBRepBuild_Builder::GMergeFaceSFS(const TopoDS_Shape& FOR, bool tomerge = GToMerge(FOR); if (!tomerge) + { return; + } TopAbs_State TB1, TB2; G1.StatesON(TB1, TB2); @@ -1001,7 +1062,9 @@ void TopOpeBRepBuild_Builder::GMergeFaceSFS(const TopoDS_Shape& FOR, bool makecomsam = GTakeCommonOfSame(G1); bool makecomdif = GTakeCommonOfDiff(G1); if (!makecomsam && !makecomdif) + { return; + } // LFSO,LFDO (samedom,sameori),(samedom,diffori) des 2 shapes peres // LFSO1,LFDO1 (samedom,sameori),(samedom,diffori) du shape pere de F @@ -1124,25 +1187,35 @@ static bool FUN_SplitEvisoONperiodicF(const occ::handle>& LLI = HDS->DS().ShapeInterferences(FF); if (LLI.Extent() == 0) + { return true; + } NCollection_List> LI; NCollection_List>::Iterator ILI(LLI); for (; ILI.More(); ILI.Next()) + { LI.Append(ILI.Value()); + } // LI3 = {I3 = (T(FACE),EG=EDGE,FS=FACE)} NCollection_List> LI1; int nIGtEDGE = FUN_selectGKinterference(LI, TopOpeBRepDS_EDGE, LI1); if (nIGtEDGE < 1) + { return true; + } NCollection_List> LI2; int nIStFACE = FUN_selectSKinterference(LI1, TopOpeBRepDS_FACE, LI2); if (nIStFACE < 1) + { return true; + } NCollection_List> LI3; int nITRASHAFACE = FUN_selectTRASHAinterference(LI2, TopAbs_FACE, LI3); if (nITRASHAFACE < 1) + { return true; + } occ::handle SSI; ILI.Initialize(LI3); @@ -1159,13 +1232,17 @@ static bool FUN_SplitEvisoONperiodicF(const occ::handleShape(GI)); HDS->Shape(EG); bool isrest = HDS->DS().IsSectionEdge(EG); if (!isrest) + { continue; + } // -------------------------------------------------- // has no representation on face yet, @@ -1178,7 +1255,9 @@ static bool FUN_SplitEvisoONperiodicF(const occ::handleShape(i); bool isface = (FOR.ShapeType() == TopAbs_FACE); if (!isface) + { continue; + } TopLoc_Location loc; const occ::handle& S = BRep_Tool::Surface(TopoDS::Face(FOR), loc); bool periodic = S->IsUPeriodic() || S->IsVPeriodic(); if (!periodic) + { continue; + } TopoDS_Shape FF = FOR; FF.Orientation(TopAbs_FORWARD); bool ok = FUN_SplitEvisoONperiodicF(myDataStructure, FF); if (!ok) + { throw Standard_ProgramError("_Builder::SplitONVisolineonCyl"); + } } // i } @@ -1305,7 +1392,9 @@ void TopOpeBRepBuild_Builder::GSplitFace(const TopoDS_Shape& F { bool toRevOri = Opefus(); for (it.Initialize(WES.StartElements()); it.More(); it.Next()) + { anEdgesON.Append(toRevOri ? it.Value().Reversed() : it.Value()); + } myONElemMap.Clear(); } @@ -1342,8 +1431,12 @@ void TopOpeBRepBuild_Builder::GSplitFace(const TopoDS_Shape& F // prepare the map of used edges to not take the same matter two times NCollection_IndexedMap aMapOE; for (it.Initialize(LOF); it.More(); it.Next()) + { for (TopExp_Explorer ex(it.Value(), TopAbs_EDGE); ex.More(); ex.Next()) + { aMapOE.Add(ex.Current()); + } + } FillOnPatches(anEdgesON, FOR, aMapOE); myONElemMap.Clear(); @@ -1382,10 +1475,14 @@ void TopOpeBRepBuild_Builder::AddONPatchesSFS(const TopOpeBRepBuild_GTopo& G1, { const TopoDS_Edge& aE = TopoDS::Edge(aMapE1(k)); if (!BRep_Tool::Degenerated(aE)) + { aChkEdge = aE; + } } if (aChkEdge.IsNull()) + { continue; + } // find a point and a normal BRepAdaptor_Curve2d aBAC1(aChkEdge, aFace1); gp_Pnt2d aP2d; @@ -1399,10 +1496,14 @@ void TopOpeBRepBuild_Builder::AddONPatchesSFS(const TopOpeBRepBuild_GTopo& G1, aN1 = aDU ^ aDV; double norm = aN1.Magnitude(); if (norm < Precision::Confusion()) + { continue; + } aN1 /= norm; if (aFace1.Orientation() == TopAbs_REVERSED) + { aN1.Reverse(); + } // iterate on faces from the second shape bool ok = true; @@ -1417,13 +1518,21 @@ void TopOpeBRepBuild_Builder::AddONPatchesSFS(const TopOpeBRepBuild_GTopo& G1, NCollection_IndexedMap aMapE2; TopExp::MapShapes(aFace2, TopAbs_EDGE, aMapE2); if (aMapE1.Extent() != aMapE2.Extent()) + { continue; + } bool sameBnd = true; for (k = 1; k <= aMapE2.Extent() && sameBnd; k++) + { if (!aMapE1.Contains(aMapE2(k))) + { sameBnd = false; + } + } if (!sameBnd) + { continue; + } // check if it is needed to have a patch here; // for that the normals should be oriented in the same sense. @@ -1441,7 +1550,9 @@ void TopOpeBRepBuild_Builder::AddONPatchesSFS(const TopOpeBRepBuild_GTopo& G1, } aN2 /= norm; if (aFace2.Orientation() == TopAbs_REVERSED) + { aN2.Reverse(); + } double scal = aN1 * aN2; if (scal < scalMin) { @@ -1499,7 +1610,9 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase TopAbs_Orientation anEdgeOri = theEdge.Orientation(); if (anEdgeOri != TopAbs_FORWARD && anEdgeOri != TopAbs_REVERSED) + { return false; + } bool reverse = (anEdgeOri == TopAbs_REVERSED); TopoDS_Face aBaseFace = TopoDS::Face(theBaseFace); @@ -1515,7 +1628,9 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase { PCref = FC2D_CurveOnSurface(anEdge, aBaseFace, pf, pl, tol, trim3d); if (PCref.IsNull()) + { return false; + } tol = BRep_Tool::Tolerance(anEdge); BB.UpdateEdge(anEdge, PCref, aBaseFace, tol); } @@ -1526,9 +1641,13 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase gp_Vec2d d1; PCref->D1(pm, pt, d1); if (d1.Magnitude() < gp::Resolution()) + { return false; + } if (reverse) + { d1.Reverse(); + } gp_Vec2d vecInside(-d1.Y(), d1.X()); gp_Lin2d aLin(pt, vecInside); @@ -1548,11 +1667,15 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase const TopoDS_Edge& aE = TopoDS::Edge(it.Value()); double tolE = BRep_Tool::Tolerance(aE); if (tolE > maxDist) + { maxDist = tolE; + } if (aE.IsEqual(anEdge) || (aE.Orientation() != TopAbs_FORWARD && aE.Orientation() != TopAbs_REVERSED && aE.IsSame(anEdge))) + { continue; // the same pcurve + } occ::handle PC = BRep_Tool::CurveOnSurface(aE, aBaseFace, pf, pl); if (PC.IsNull()) { @@ -1586,7 +1709,9 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase aIS.HasFirstPoint() ? aIS.FirstPoint().ParamOnFirst() : -Precision::Infinite(); double pLinL = aIS.HasLastPoint() ? aIS.LastPoint().ParamOnFirst() : Precision::Infinite(); if (pLinF < tol2d && pLinL > -tol2d) + { isError = true; + } else if (pLinF > tol2d && pLinF < pLinMin) { pLinMin = pLinF; @@ -1596,7 +1721,9 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase } } if (isError || !hasInt) + { return false; + } // create a point in the area and get the normal to aBaseFace at it gp_Pnt2d aP2d = ElCLib::Value(pLinMin * T, aLin); @@ -1607,9 +1734,13 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase gp_Vec aNormBase = d1u ^ d1v; double mag = aNormBase.Magnitude(); if (mag < gp::Resolution()) + { return false; + } if (aBaseFace.Orientation() == TopAbs_REVERSED) + { mag = -mag; + } aNormBase /= mag; // project the point aPnt to the second face aFace @@ -1618,23 +1749,31 @@ static bool AreFacesCoincideInArea(const TopoDS_Shape& theBase BRepTools::UVBounds(aFace, umin, umax, vmin, vmax); GeomAPI_ProjectPointOnSurf aProj(aPnt, aSurf, umin, umax, vmin, vmax); if (!aProj.NbPoints() || aProj.LowerDistance() > maxDist) + { return false; + } double u, v; aProj.LowerDistanceParameters(u, v); aSurf->D1(u, v, aPnt, d1u, d1v); gp_Vec aNorm = d1u ^ d1v; mag = aNorm.Magnitude(); if (mag < gp::Resolution()) + { return false; + } if (aFace.Orientation() == TopAbs_REVERSED) + { mag = -mag; + } aNorm /= mag; // check normales double dot = aNormBase * aNorm; const double minDot = 0.9999; if (std::abs(dot) < minDot) + { return false; + } isSameOri = (dot > 0.); return true; @@ -1651,11 +1790,17 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List int rankBF = ShapeRank(aBaseFace); int rankOpp; if (rankBF == 1) + { rankOpp = 2; + } else if (rankBF == 2) + { rankOpp = 1; + } else + { return; + } TopOpeBRepBuild_WireEdgeSet WES(FF, this); NCollection_Map aMapON, aMapON1; @@ -1682,11 +1827,13 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List if (aE.ShapeType() == TopAbs_WIRE) { for (itW.Initialize(aE); itW.More(); itW.Next()) + { if (!avoidMap.Contains(itW.Value())) { allEdges.Append(itW.Value()); hasWires = true; } + } } else if (!avoidMap.Contains(aE)) { @@ -1699,7 +1846,9 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List // add elements from anEdgesON (they come from BuilderON) NCollection_DataMap anAncMap; if (!aMapON.IsEmpty()) + { FillSecEdgeAncestorMap(rankOpp, aMapON, anAncMap); + } if (!anAncMap.IsEmpty()) { for (it.Initialize(anEdgesON); it.More(); it.Next()) @@ -1722,10 +1871,14 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List { int state = aMapFState(aF); if (state) + { isOnFace = true; + } } else + { aFacesToCheck.Append(aF); + } } for (itF.Initialize(aFacesToCheck); itF.More() && !isOnFace; itF.Next()) { @@ -1747,17 +1900,23 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List isSameOri); } else + { ok = AreFacesCoincideInArea(aBaseFace, aF, aE, allEdges, isSameOri); + } if (ok && isSameOri) { aMapFState.Bind(aF, 1); isOnFace = true; } else + { aMapFState.Bind(aF, 0); + } } if (isOnFace) + { WES.AddStartElement(aE); + } } } } @@ -1766,7 +1925,9 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List // add elements from myONElemMap (consisting of parts of the boundary of aBaseFace) anAncMap.Clear(); if (!aMapON1.IsEmpty()) + { FillSecEdgeAncestorMap(rankBF, aMapON1, anAncMap); + } if (hasWires || !anAncMap.IsEmpty()) { for (i = 1; i <= myONElemMap.Extent(); i++) @@ -1780,9 +1941,13 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List { const TopoDS_Edge& e = TopoDS::Edge(itW.Value()); if (avoidMap.Contains(e)) + { break; + } if (!BRep_Tool::Degenerated(e)) + { anEdge = anAncE = e; + } } } else if (anAncMap.IsBound(aE) && !avoidMap.Contains(aE)) @@ -1796,7 +1961,9 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List NCollection_List aFaces; FDSCNX_FaceEdgeConnexFaces(aBaseFace, anAncE, myDataStructure, aFaces); if (aFaces.IsEmpty()) + { continue; + } TopoDS_Shape aCnxF = aFaces.First(); aFaces.Clear(); FindFacesTouchingEdge(aCnxF, anAncE, rankOpp, aFaces); @@ -1812,10 +1979,14 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List { int state = aMapFState(aF); if (state) + { isOnFace = true; + } } else + { aFacesToCheck.Append(aF); + } } for (itF.Initialize(aFacesToCheck); itF.More() && !isOnFace; itF.Next()) { @@ -1828,14 +1999,20 @@ void TopOpeBRepBuild_Builder::FillOnPatches(const NCollection_List isOnFace = true; } else + { aMapFState.Bind(aF, 0); + } } if (isOnFace) { if (aE.ShapeType() == TopAbs_WIRE) + { WES.AddShape(aE); + } else + { WES.AddStartElement(aE); + } } } } @@ -1866,7 +2043,9 @@ void TopOpeBRepBuild_Builder::FindFacesTouchingEdge(const TopoDS_Shape& const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); int anEdgeInd = BDS.Shape(anEdge); if (!anEdgeInd) + { return; + } const NCollection_List>& LI = BDS.ShapeInterferences(aFace); @@ -1877,20 +2056,30 @@ void TopOpeBRepBuild_Builder::FindFacesTouchingEdge(const TopoDS_Shape& occ::handle SSI = occ::down_cast(I); if (SSI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(SSI, GT, GI, ST, SI); if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE) + { continue; + } if (GI != anEdgeInd) + { continue; + } const TopOpeBRepDS_Transition& TFE = SSI->Transition(); if (TFE.ShapeBefore() != TopAbs_FACE || TFE.ShapeAfter() != TopAbs_FACE) + { continue; + } const TopoDS_Shape& FS = BDS.Shape(SI); if (ShapeRank(FS) != aShRank) + { continue; + } aFaces.Append(FS); } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Griddump.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Griddump.cxx index 48a5274dd1..334c129202 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Griddump.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Griddump.cxx @@ -320,7 +320,7 @@ void TopOpeBRepBuild_Builder::GdumpSAMDOM(const NCollection_List& void* const astr) const { TopOpeBRepDS_Dumper Dumper(myDataStructure); - std::cout << Dumper.SPrintShapeRefOri(L, (char*)astr) << std::endl; + std::cout << Dumper.SPrintShapeRefOri(L, (char*)astr) << '\n'; std::cout.flush(); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx index 2af142e9ad..4dfcd9ba82 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx @@ -215,7 +215,9 @@ void TopOpeBRepBuild_HBuilder::InitExtendedSectionDS(const int k) myMakeCurveAncestorIsDone = false; } else + { return; + } } //================================================================================================= @@ -223,20 +225,32 @@ void TopOpeBRepBuild_HBuilder::InitExtendedSectionDS(const int k) void TopOpeBRepBuild_HBuilder::InitSection(const int k) { if (PLE == nullptr) + { PLE = new NCollection_List(); + } if (PITLE == nullptr) + { PITLE = new NCollection_List::Iterator(); + } PLE->Clear(); PITLE->Initialize(*PLE); InitExtendedSectionDS(k); if (k == 1) + { myBuilder.SectionCurves(*PLE); + } else if (k == 2) + { myBuilder.SectionEdges(*PLE); + } else if (k == 3) + { myBuilder.Section(*PLE); + } else + { return; + } PITLE->Initialize(*PLE); } @@ -245,7 +259,9 @@ void TopOpeBRepBuild_HBuilder::InitSection(const int k) bool TopOpeBRepBuild_HBuilder::MoreSection() const { if (PITLE == nullptr) + { return false; + } bool b = PITLE->More(); return b; } @@ -255,9 +271,13 @@ bool TopOpeBRepBuild_HBuilder::MoreSection() const void TopOpeBRepBuild_HBuilder::NextSection() { if (PITLE == nullptr) + { return; + } if (PITLE->More()) + { PITLE->Next(); + } } //================================================================================================= @@ -265,9 +285,13 @@ void TopOpeBRepBuild_HBuilder::NextSection() const TopoDS_Shape& TopOpeBRepBuild_HBuilder::CurrentSection() const { if (PITLE == nullptr) + { throw Standard_ProgramError("no more CurrentSection"); + } if (!PITLE->More()) + { throw Standard_ProgramError("no more CurrentSection"); + } return PITLE->Value(); } @@ -276,7 +300,9 @@ const TopoDS_Shape& TopOpeBRepBuild_HBuilder::CurrentSection() const void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() { if (myMakeEdgeAncestorIsDone) + { return; + } mySectEdgeDSEdges1.Clear(); mySectEdgeDSEdges2.Clear(); myDSEdgesDSFaces1.Clear(); @@ -300,24 +326,34 @@ void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() ei = DS.Shape(ShaSpl); re = DS.AncestorRank(ShaSpl); if (!re) + { continue; + } TopOpeBRepDS_ListOfShapeOn1State& losos1s = (*(TopOpeBRepDS_ListOfShapeOn1State*)&it.Value()); NCollection_List& los = losos1s.ChangeListOnState(); its.Initialize(los); if (re == 1) + { for (; its.More(); its.Next()) { const TopoDS_Shape& SecEdg = its.Value(); if (!mySectEdgeDSEdges1.IsBound(SecEdg)) + { mySectEdgeDSEdges1.Bind(SecEdg, ei); + } } + } else if (re == 2) + { for (; its.More(); its.Next()) { const TopoDS_Shape& SecEdg = its.Value(); if (!mySectEdgeDSEdges2.IsBound(SecEdg)) + { mySectEdgeDSEdges2.Bind(SecEdg, ei); + } } + } } // bool gb; @@ -326,9 +362,13 @@ void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() { const TopoDS_Shape& fds = DS.Shape(fi); if (fds.IsNull()) + { continue; + } if (fds.ShapeType() != TopAbs_FACE) + { continue; + } NCollection_List>::Iterator it1( DS.ShapeInterferences(fds)); for (; it1.More(); it1.Next()) @@ -336,14 +376,20 @@ void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() occ::handle SSI = occ::down_cast(it1.Value()); if (SSI.IsNull()) + { continue; + } gk = SSI->GeometryType(); gi = SSI->Geometry(); if (gk != TopOpeBRepDS_EDGE) + { continue; + } rf = DS.AncestorRank(fds); if (!rf) + { continue; + } // if (!MF.Contains(fds) ) { // MF.Add(fds); if (rf == 1) @@ -374,20 +420,26 @@ void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() int TopOpeBRepBuild_HBuilder::GetDSEdgeFromSectEdge(const TopoDS_Shape& E, const int rank) { if (!myMakeEdgeAncestorIsDone) + { MakeEdgeAncestorMap(); + } int i = 0; if (rank == 1) { if (mySectEdgeDSEdges1.IsBound(E)) + { i = mySectEdgeDSEdges1.Find(E); + } } if (rank == 2) { if (mySectEdgeDSEdges2.IsBound(E)) + { i = mySectEdgeDSEdges2.Find(E); + } } return i; } @@ -398,7 +450,9 @@ NCollection_List& TopOpeBRepBuild_HBuilder::GetDSFaceFromDSEdge(const int i const int rank) { if (!myMakeEdgeAncestorIsDone) + { MakeEdgeAncestorMap(); + } if (rank == 1) { @@ -426,7 +480,9 @@ NCollection_List& TopOpeBRepBuild_HBuilder::GetDSFaceFromDSEdge(const int i void TopOpeBRepBuild_HBuilder::MakeCurveAncestorMap() { if (myMakeCurveAncestorIsDone) + { return; + } mySectEdgeDSCurve.Clear(); myMakeCurveAncestorIsDone = true; const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); @@ -453,7 +509,9 @@ int TopOpeBRepBuild_HBuilder::GetDSCurveFromSectEdge(const TopoDS_Shape& SectEdg { int i = 0; if (!myMakeCurveAncestorIsDone) + { MakeCurveAncestorMap(); + } if (mySectEdgeDSCurve.IsBound(SectEdge)) { @@ -468,7 +526,9 @@ int TopOpeBRepBuild_HBuilder::GetDSFaceFromDSCurve(const int indexCur, const int { int i = 0; if (!myMakeCurveAncestorIsDone) + { MakeCurveAncestorMap(); + } const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); if (rank == 1) @@ -501,13 +561,17 @@ int TopOpeBRepBuild_HBuilder::GetDSPointFromNewVertex(const TopoDS_Shape& NewVer { const TopoDS_Shape& Vertex = NewVertex(i); if (!Vertex.IsNull()) + { myNewVertexDSPoint.Bind(Vertex, i); + } } } int iPnt = 0; if (myNewVertexDSPoint.IsBound(NewVert)) + { iPnt = myNewVertexDSPoint.Find(NewVert); + } return iPnt; } @@ -528,7 +592,9 @@ bool TopOpeBRepBuild_HBuilder::EdgeCurveAncestors(const TopoDS_Shape& E, // NCollection_List::Iterator itloe; IC = GetDSCurveFromSectEdge(E); if (!IC) + { return false; + } int iF1, iF2; iF1 = GetDSFaceFromDSCurve(IC, 1); @@ -548,7 +614,9 @@ bool TopOpeBRepBuild_HBuilder::EdgeSectionAncestors(const TopoDS_Shape& NCollection_List& LE2) { if (E.ShapeType() != TopAbs_EDGE) + { return false; + } LF1.Clear(); LF2.Clear(); @@ -619,9 +687,13 @@ bool TopOpeBRepBuild_HBuilder::EdgeSectionAncestors(const TopoDS_Shape& const TopOpeBRepDS_DataStructure& DS = myBuilder.DataStructure()->DS(); if (ie1) + { LE1.Append(DS.Shape(ie1)); + } if (ie2) + { LE2.Append(DS.Shape(ie2)); + } for (it.Initialize(f1); it.More(); it.Next()) { @@ -653,7 +725,9 @@ void TopOpeBRepBuild_HBuilder::MergeKPart(const TopAbs_State TB1, const TopAbs_S { int kp = IsKPart(); if (kp) + { myBuilder.MergeKPart(TB1, TB2); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_KPart.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_KPart.cxx index 41ee22ea9c..a61c205b2e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_KPart.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_KPart.cxx @@ -273,7 +273,9 @@ static void FUN_addf(const TopAbs_State sta, #endif TopoDS_Shape fori = ftoadd; if (sta == TopAbs_IN) + { fori.Complement(); + } map.Bind(fori, fori); } @@ -293,15 +295,21 @@ static int FUN_comparekoletgesh(TopOpeBRepTool_ShapeClassifier& SC, { const TopoDS_Face& f1 = TopoDS::Face(exf.Current()); if (f1.IsSame(fkole1)) + { continue; + } gp_Pnt pnt1; BRepClass3d_SolidExplorer::FindAPointInTheFace(f1, pnt1); SC.StateP3DReference(pnt1); TopAbs_State stpnt1 = SC.State(); if (stpnt1 == TopAbs_IN) + { return 2; + } if (stpnt1 == TopAbs_OUT) + { return 1; + } } return 0; } @@ -310,10 +318,14 @@ static bool FUN_changev(const occ::handle& HDS, con { bool changev = HDS->HasShape(v); if (!changev) + { return false; + } changev = HDS->HasSameDomain(v); if (!changev) + { return false; + } int rankv = HDS->DS().AncestorRank(v); changev = (rankv == 2); return changev; @@ -333,7 +345,9 @@ static bool FUN_updatev(const occ::handle& HDS, TopoDS_Shape oov; bool ok = FUN_ds_getoov(v, HDS, oov); if (!ok) + { return false; + } oov.Orientation(oriv); BB.Add(newed, oov); BT.Parameter(newed, oov, parv); @@ -399,10 +413,14 @@ static bool FUN_makefaces( BT.CopyEdge(ed.Oriented(TopAbs_FORWARD), newed); bool ok = ::FUN_updatev(HDS, newed, vf, TopAbs_FORWARD, ff, changevf); if (!ok) + { return false; + } ok = ::FUN_updatev(HDS, newed, vl, TopAbs_REVERSED, l, changevl); if (!ok) + { return false; + } newed.Orientation(oe); NCollection_List led; led.Append(newed); @@ -415,12 +433,16 @@ static bool FUN_makefaces( { const NCollection_List& speds = BU.Splits(ed, TopAbs_ON); if (speds.Extent() == 0) + { return false; + } const TopoDS_Edge& spe = TopoDS::Edge(speds.First()); bool sameori = FUN_tool_SameOri(ed, spe); TopAbs_Orientation orisp = spe.Orientation(); if (!sameori) + { orisp = TopAbs::Complement(orisp); + } NCollection_List::Iterator it(speds); for (; it.More(); it.Next()) @@ -428,7 +450,9 @@ static bool FUN_makefaces( TopoDS_Edge esp = TopoDS::Edge(it.Value()); bool ok = FUN_tool_pcurveonF(TopoDS::Face(f), esp); if (!ok) + { return false; + } TopoDS_Shape ee = esp.Oriented(orisp); loe.Append(ee); } @@ -438,17 +462,23 @@ static bool FUN_makefaces( const NCollection_List& neweds = EnewE.ChangeFind(ed); NCollection_List::Iterator itnes(neweds); for (; itnes.More(); itnes.Next()) + { loe.Append(itnes.Value().Oriented(oe)); + } } else + { loe.Append(ed); + } } TopoDS_Wire newW; //--------------- BB.MakeWire(newW); for (NCollection_List::Iterator itee(loe); itee.More(); itee.Next()) + { BB.Add(newW, itee.Value()); + } // the new face : // -------------- @@ -463,20 +493,28 @@ static bool FUN_makefaces( { const TopoDS_Wire OOw = TopoDS::Wire(exw.Current()); if (OOw.IsSame(outerwf)) + { continue; + } BB.Add(newf, OOw); } if (M_REVERSED(of)) + { newf.Orientation(TopAbs_REVERSED); + } // xpu140898 : CTS21251 TopoDS_Face Newf = newf; bool ok = TopOpeBRepTool::CorrectONUVISO(TopoDS::Face(f), Newf); if (ok) + { newfaces.Append(Newf); + } else + { newfaces.Append(newf); + } return true; } @@ -513,7 +551,9 @@ static bool FUN_rebuildfc( // prequesitory : ed in {edges of Owk} // ed's faces ancestor = {Fk,fofj} if (lfcFk.Extent() != 1) + { return false; + } // purpose : Building up new topologies on connexed faces // attached to outer wire's edges. @@ -521,7 +561,9 @@ static bool FUN_rebuildfc( NCollection_List newfcFk; bool ok = FUN_makefaces(BU, HDS, EnewE, fcFk, Owk, newfcFk); if (!ok) + { return false; + } fcnewfc.Add(fcFk, newfcFk); } return true; @@ -608,7 +650,9 @@ void TopOpeBRepBuild_Builder::MergeKPartiskoletge() // getting greater rgre = ::FUN_comparekoletgesh(myShapeClassifier, myShape1, myShape2, fac1, fac2); if (rgre == 0) + { rgre = FUN_tool_comparebndkole(myShape1, myShape2); + } } if (rgre == 0) { @@ -733,9 +777,13 @@ void TopOpeBRepBuild_Builder::MergeKPartiskoletge() { const TopoDS_Shape& ff = exSMA.Current(); if (fcnewfcSMA.Contains(ff)) + { continue; + } if (ff.IsSame(*pfSMA)) + { continue; + } lOOfSMA.Append(ff); // DEB ::FUN_addf(staSMA, ff, addedfaces); } @@ -744,9 +792,13 @@ void TopOpeBRepBuild_Builder::MergeKPartiskoletge() { const TopoDS_Shape& ff = exGRE.Current(); if (fcnewfcGRE.Contains(ff)) + { continue; + } if (ff.IsSame(*pfGRE)) + { continue; + } lOOfGRE.Append(ff); // DEB ::FUN_addf(staGRE, ff, addedfaces); } @@ -794,7 +846,9 @@ void TopOpeBRepBuild_Builder::MergeKPartisdisj() #endif if (myIsKPart != 2) + { return; // isdisj + } NCollection_List& lmergesha1 = ChangeMerged(myShape1, myState1); /* NCollection_List& lmergesha2 =*/ChangeMerged(myShape2, myState2); @@ -814,10 +868,14 @@ void TopOpeBRepBuild_Builder::MergeKPartisdisj() { anExp.Init(myShape1, (TopAbs_ShapeEnum)i, TopAbs_SOLID); if (anExp.More()) + { hasnotsol1 = true; + } anExp.Init(myShape2, (TopAbs_ShapeEnum)i, TopAbs_SOLID); if (anExp.More()) + { hasnotsol2 = true; + } } soldisj = !(hasnotsol1 || hasnotsol2); // modified by NIZHNY-MKK Fri May 19 16:18:16 2000.END @@ -840,22 +898,30 @@ void TopOpeBRepBuild_Builder::MergeKPartisdisj() if (Opefus()) { if (!disjPerformFuse(aMapOfSolid1, aMapOfSolid2, aMapOfResult)) + { return; + } } else if (Opec12()) { if (!disjPerformCut(aMapOfSolid1, aMapOfSolid2, aMapOfResult)) + { return; + } } else if (Opec21()) { if (!disjPerformCut(aMapOfSolid2, aMapOfSolid1, aMapOfResult)) + { return; + } } else if (Opecom()) { if (!disjPerformCommon(aMapOfSolid1, aMapOfSolid2, aMapOfResult)) + { return; + } } for (int ii = 1; ii <= aMapOfResult.Extent(); ii++) { @@ -955,12 +1021,12 @@ void TopOpeBRepBuild_Builder::MergeKPartisdisj() lmergesha1.Append(myShape2); } else + { return; + } } // ( !soldisj ) - return; - } // MergeKPartisdisj //================================================================================================= @@ -979,11 +1045,15 @@ void TopOpeBRepBuild_Builder::MergeKPartisfafa() TopExp_Explorer ex; ex.Init(myShape1, TopAbs_FACE); if (!ex.More()) + { return; + } TopoDS_Shape F1 = ex.Current(); ex.Init(myShape2, TopAbs_FACE); if (!ex.More()) + { return; + } TopoDS_Shape F2 = ex.Current(); NCollection_List LF1, LF2; @@ -992,15 +1062,25 @@ void TopOpeBRepBuild_Builder::MergeKPartisfafa() TopAbs_ShapeEnum tf = TopAbs_FACE; TopOpeBRepBuild_GTopo G; if (Opec12()) + { G = TopOpeBRepBuild_GTool::GCutSame(tf, tf); + } else if (Opec21()) + { G = TopOpeBRepBuild_GTool::GCutSame(tf, tf).CopyPermuted(); + } else if (Opecom()) + { G = TopOpeBRepBuild_GTool::GComSame(tf, tf); + } else if (Opefus()) + { G = TopOpeBRepBuild_GTool::GFusSame(tf, tf); + } else + { return; + } GMapShapes(myShape1, myShape2); GMergeFaces(LF1, LF2, G); @@ -1040,7 +1120,9 @@ void TopOpeBRepBuild_Builder::MergeKPartissoso() { ex.Init(myShape1, TopAbs_SOLID); if (!ex.More()) + { return; + } SO1 = ex.Current(); } @@ -1049,12 +1131,16 @@ void TopOpeBRepBuild_Builder::MergeKPartissoso() { ex.Init(myShape2, TopAbs_SOLID); if (!ex.More()) + { return; + } SO2 = ex.Current(); } if (SO1.IsNull()) + { return; + } NCollection_List LSO1, LSO2; GFindSamDom(SO1, LSO1, LSO2); @@ -1062,15 +1148,25 @@ void TopOpeBRepBuild_Builder::MergeKPartissoso() TopAbs_ShapeEnum tf = TopAbs_FACE; // NYI TopAbs_SOLID TopOpeBRepBuild_GTopo G; if (Opec12()) + { G = TopOpeBRepBuild_GTool::GCutSame(tf, tf); + } else if (Opec21()) + { G = TopOpeBRepBuild_GTool::GCutSame(tf, tf).CopyPermuted(); + } else if (Opecom()) + { G = TopOpeBRepBuild_GTool::GComSame(tf, tf); + } else if (Opefus()) + { G = TopOpeBRepBuild_GTool::GFusSame(tf, tf); + } else + { return; + } GMapShapes(myShape1, myShape2); GMergeSolids(LSO1, LSO2, G); @@ -1108,13 +1204,17 @@ static bool sectionedgesON( const TopoDS_Shape& e1 = ex1.Current(); NCollection_List::Iterator it2 = HDS->SameDomain(e1); if (!it2.More()) + { return false; // xpu231098 : cto904C7 : e1 !hsd + } for (; it2.More(); it2.Next()) { const TopoDS_Shape& e2 = it2.Value(); bool isbound = mape2.Contains(e2); if (!isbound) + { return false; + } } } return true; @@ -1138,7 +1238,9 @@ static bool allIonsectionedges( const TopoDS_Shape& e1 = HDS->Shape(G1); bool isbound = isgbound ? mape1.Contains(e1) : mape2.Contains(e1); if (!isbound) + { return false; + } } return true; } @@ -1159,32 +1261,44 @@ int TopOpeBRepBuild_Builder::KPiskoletge() bool iskp1 = KPiskoletgesh(myShape1, lShsd1, lfhsd1); if (!iskp1) + { return 0; + } NCollection_List lplhsd1, lcyhsd1; ::FUN_sortplcy(lfhsd1, lplhsd1, lcyhsd1); int nplhsd1 = lplhsd1.Extent(); int ncyhsd1 = lcyhsd1.Extent(); if (nplhsd1 != 1) + { return 0; + } if (ncyhsd1 > 1) + { return 0; + } bool iskp2 = KPiskoletgesh(myShape2, lShsd2, lfhsd2); if (!iskp2) + { return 0; + } NCollection_List lplhsd2, lcyhsd2; ::FUN_sortplcy(lfhsd2, lplhsd2, lcyhsd2); int nplhsd2 = lplhsd2.Extent(); int ncyhsd2 = lcyhsd2.Extent(); if (nplhsd2 != 1) + { return 0; + } // Si l'un des objets est constitue de plusieurs solides on passe // dans le cas general. int nshsd1 = lShsd1.Extent(); int nshsd2 = lShsd2.Extent(); if (nshsd1 > 1 || nshsd2 > 1) + { return 0; + } // NYI : (nplhsd1 > 1) || (nplhsd2 > 1) // ------------------------------------ @@ -1222,19 +1336,27 @@ int TopOpeBRepBuild_Builder::KPiskoletge() bool se1ONouterw2 = ::sectionedgesON(myDataStructure, outerw1, mape2); if (!se1ONouterw2) + { return 0; + } bool se2ONouterw1 = ::sectionedgesON(myDataStructure, outerw2, mape1); if (!se2ONouterw1) + { return 0; + } // NYI : interferes with faces of on edges different from outerw's edges // -------=----------------------------------------------------------------------- bool allI1onseouterw = ::allIonsectionedges(myDataStructure, f1, mape1, mape2); if (!allI1onseouterw) + { return 0; + } bool allI2onseouterw = ::allIonsectionedges(myDataStructure, f2, mape2, mape1); if (!allI2onseouterw) + { return 0; + } // NYI : (ncyhsd1 > 1) || (ncyhsd2 > 1) // ------------------------------------ @@ -1243,14 +1365,20 @@ int TopOpeBRepBuild_Builder::KPiskoletge() { bool cycy = (ncyhsd1 == 1) && (ncyhsd2 == 1); if (!cycy) + { return 0; + } bool isbound1 = FUN_tool_inS(outerw1, f1); if (!isbound1) + { return 0; + } bool isbound2 = FUN_tool_inS(outerw2, f2); if (!isbound2) + { return 0; + } } return 1; @@ -1270,9 +1398,13 @@ int TopOpeBRepBuild_Builder::KPisdisj() // if (nsh != 2) return 0; if (!DS.HasShape(myShape1)) + { return 0; + } if (!DS.HasShape(myShape2)) + { return 0; + } int isdisj1 = KPisdisjsh(myShape1); int isdisj2 = KPisdisjsh(myShape2); @@ -1495,7 +1627,9 @@ bool TopOpeBRepBuild_Builder::KPiskoletgesh(const TopoDS_Shape& Sarg const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); bool iskolesh = FUNKP_KPiskolesh((*this), BDS, Sarg, lShsd, lfhsd); if (!iskolesh) + { return false; + } #ifdef OCCT_DEBUG int nfhsd = @@ -1508,13 +1642,19 @@ bool TopOpeBRepBuild_Builder::KPiskoletgesh(const TopoDS_Shape& Sarg bool isplan = FUN_tool_plane(fac); bool iscylinder = FUN_tool_cylinder(fac); if (iscylinder) + { continue; + } if (!isplan) + { return false; + } TopoDS_Wire outerw = BRepTools::OuterWire(fac); if (outerw.IsNull()) + { return false; + } TopExp_Explorer exe(outerw, TopAbs_EDGE); // int ne = 0; @@ -1524,9 +1664,13 @@ bool TopOpeBRepBuild_Builder::KPiskoletgesh(const TopoDS_Shape& Sarg bool isse = BDS.IsSectionEdge(ed); const NCollection_List& sp = (*this).Splits(ed, TopAbs_ON); if (sp.Extent() == 0) + { return false; + } if (!isse) + { return false; + } // ne++; } // if (ne > 1) return false; @@ -1642,22 +1786,30 @@ void TopOpeBRepBuild_Builder::KPSameDomain(NCollection_List& L1, int TopOpeBRepBuild_Builder::KPisdisjsh(const TopoDS_Shape& Sarg) const { if (Sarg.IsNull()) + { return 0; + } TopExp_Explorer ex; int nhg; nhg = KPlhg(Sarg, TopAbs_SOLID); if (nhg != 0) + { return 0; + } nhg = KPlhg(Sarg, TopAbs_FACE); if (nhg != 0) + { return 0; + } nhg = KPlhg(Sarg, TopAbs_EDGE); if (nhg != 0) + { return 0; + } // un seul niveau de HasSameDomain int n1, n2; @@ -1672,7 +1824,9 @@ int TopOpeBRepBuild_Builder::KPisdisjsh(const TopoDS_Shape& Sarg) const const TopoDS_Shape& s = it.Value(); n2 = KPlhsd(s, TopAbs_FACE); if (n2 != 0) + { return 0; + } } } @@ -1685,7 +1839,9 @@ int TopOpeBRepBuild_Builder::KPisdisjsh(const TopoDS_Shape& Sarg) const const TopoDS_Shape& s = it.Value(); n2 = KPlhsd(s, TopAbs_EDGE); if (n2 != 0) + { return 0; + } } } @@ -1703,20 +1859,28 @@ int TopOpeBRepBuild_Builder::KPissososh(const TopoDS_Shape& Sarg) const int nsol1 = 0; TopExp_Explorer ex1(Sarg, TopAbs_SOLID); for (; ex1.More(); ex1.Next()) + { nsol1++; + } int nsol2 = 0; TopExp_Explorer ex2(Sarg, TopAbs_SOLID, TopAbs_COMPSOLID); for (; ex2.More(); ex2.Next()) + { nsol2++; + } if (nsol1 && (nsol1 != nsol2)) + { return 0; + } // toutes les solides sont HasSameDomain() int nhsd = KPlhsd(Sarg, TopAbs_SOLID); if (nhsd != nsol1) + { return 0; + } int n; TopExp_Explorer ex; @@ -1724,30 +1888,46 @@ int TopOpeBRepBuild_Builder::KPissososh(const TopoDS_Shape& Sarg) const // pas de shell volant n = 0; for (ex.Init(Sarg, TopAbs_SHELL, TopAbs_SOLID); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } // pas de face volant n = 0; for (ex.Init(Sarg, TopAbs_FACE, TopAbs_SHELL); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } // pas d'edge volant n = 0; for (ex.Init(Sarg, TopAbs_EDGE, TopAbs_WIRE); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } // pas de vertex volant n = 0; for (ex.Init(Sarg, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } return 1; } @@ -1763,20 +1943,28 @@ int TopOpeBRepBuild_Builder::KPisfafash(const TopoDS_Shape& Sarg) const int nfac1 = 0; TopExp_Explorer ex1(Sarg, TopAbs_FACE); for (; ex1.More(); ex1.Next()) + { nfac1++; + } int nfac2 = 0; TopExp_Explorer ex2(Sarg, TopAbs_FACE, TopAbs_SHELL); for (; ex2.More(); ex2.Next()) + { nfac2++; + } if (nfac1 && (nfac1 != nfac2)) + { return 0; + } // toutes les faces sont HasSameDomain() int nhsd = KPlhsd(Sarg, TopAbs_FACE); if (nhsd != nfac1) + { return 0; + } int n; TopExp_Explorer ex; @@ -1784,23 +1972,35 @@ int TopOpeBRepBuild_Builder::KPisfafash(const TopoDS_Shape& Sarg) const // pas de wire volant n = 0; for (ex.Init(Sarg, TopAbs_WIRE, TopAbs_FACE); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } // pas d'edge volant n = 0; for (ex.Init(Sarg, TopAbs_EDGE, TopAbs_WIRE); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } // pas de vertex volant n = 0; for (ex.Init(Sarg, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) + { n++; + } if (n) + { return 0; + } return 1; } @@ -1831,8 +2031,10 @@ void TopOpeBRepBuild_Builder::KPiskoletgeanalyse(const TopOpeBRepDS_Config confi if (DiffOriented) { if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_IN) + { // if (com) ires = RESNULL; ires = RESNULL; + } if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN) { @@ -1849,8 +2051,10 @@ void TopOpeBRepBuild_Builder::KPiskoletgeanalyse(const TopOpeBRepDS_Config confi } if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) + { // if (fus) ires = RESNEWSOL; ires = RESNEWSOL; + } } // DiffOriented if (SameOriented) @@ -1860,8 +2064,10 @@ void TopOpeBRepBuild_Builder::KPiskoletgeanalyse(const TopOpeBRepDS_Config confi // ============================== if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_IN) + { // if (com) ires = RESSHAPE1; ires = RESSHAPE1; + } if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN) { @@ -1878,8 +2084,10 @@ void TopOpeBRepBuild_Builder::KPiskoletgeanalyse(const TopOpeBRepDS_Config confi } if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) + { // if (fus) ires = RESSHAPE2; ires = RESSHAPE2; + } } // SameOriented #ifdef OCCT_DEBUG @@ -2035,9 +2243,13 @@ int TopOpeBRepBuild_Builder::KPls(const TopoDS_Shape& S, TopAbs_State TopOpeBRepBuild_Builder::KPclassF(const TopoDS_Shape& F1, const TopoDS_Shape& F2) { if (F1.IsNull()) + { return TopAbs_UNKNOWN; + } if (F2.IsNull()) + { return TopAbs_UNKNOWN; + } TopoDS_Face F1F = TopoDS::Face(F1); F1F.Orientation(TopAbs_FORWARD); @@ -2047,7 +2259,9 @@ TopAbs_State TopOpeBRepBuild_Builder::KPclassF(const TopoDS_Shape& F1, const Top NCollection_List le1; int ne1 = KPls(F1F, TopAbs_EDGE, le1); if (ne1 == 0) + { return TopAbs_UNKNOWN; + } const TopoDS_Edge& e1 = TopoDS::Edge(le1.First()); int isamdom = 1; @@ -2117,9 +2331,13 @@ bool TopOpeBRepBuild_Builder::KPiskoleFF(const TopoDS_Shape& F1, bool st2ok = (St2 == TopAbs_OUT || St2 == TopAbs_IN); if (!st1ok) + { return false; + } if (!st2ok) + { return false; + } bool stok = (St1 != St2); return stok; } @@ -2137,7 +2355,9 @@ bool TopOpeBRepBuild_Builder::KPContains(const TopoDS_Shape& S const TopoDS_Shape& SL = it.Value(); bool issame = SL.IsSame(S); if (issame) + { return true; + } } return false; } // KPContains @@ -2256,7 +2476,7 @@ static void LocalKPisdisjanalyse(const TopAbs_State Stsol1, break; } default: { - std::cout << "Warning: given operation is unknown" << std::endl; + std::cout << "Warning: given operation is unknown" << '\n'; break; } } // end switch @@ -2324,19 +2544,31 @@ static TopoDS_Solid BuildNewSolid(const TopoDS_Solid& sol1, bool garde = true; if (icla == SHEAUCU) + { garde = false; + } else if (icla == SHEGARDAUTR || icla == SHECLASAUTR) + { garde = !isoutsha; + } if (!garde) + { continue; + } bool add = false; if (icla == SHEGARDCOUR) + { add = true; + } else if (icla == SHEGARDAUTR) + { add = true; + } else if (icla == SHEGARDTOUS) + { add = true; + } else if (icla == SHECLASAUTR) { TopAbs_State state = aShapeClassifier.StateShapeShape(shacur, Snull, othersol); @@ -2347,7 +2579,9 @@ static TopoDS_Solid BuildNewSolid(const TopoDS_Solid& sol1, TopoDS_Shell shaori = shacur; bool r = (solstate == TopAbs_IN); if (r) + { shaori.Complement(); + } if (!isdisjmap.Contains(shaori)) { isdisjmap.Add(shaori); @@ -2373,19 +2607,31 @@ static TopoDS_Solid BuildNewSolid(const TopoDS_Solid& sol1, bool garde = true; if (icla == SHEAUCU) + { garde = false; + } else if (icla == SHEGARDAUTR || icla == SHECLASAUTR) + { garde = !isoutsha; + } if (!garde) + { continue; + } bool add = false; if (icla == SHEGARDCOUR) + { add = true; + } else if (icla == SHEGARDAUTR) + { add = true; + } else if (icla == SHEGARDTOUS) + { add = true; + } else if (icla == SHECLASAUTR) { TopAbs_State state = aShapeClassifier.StateShapeShape(shacur, Snull, othersol); @@ -2396,7 +2642,9 @@ static TopoDS_Solid BuildNewSolid(const TopoDS_Solid& sol1, TopoDS_Shell shaori = shacur; bool r = (solstate == TopAbs_IN); if (r) + { shaori.Complement(); + } aBuildTool.AddSolidShell(newsol, shaori); } } @@ -2439,12 +2687,16 @@ static bool disjPerformFuse( { const TopoDS_Shape& localshape1 = aMapOfSolid(i); if (localshape1.ShapeType() != TopAbs_SOLID) + { return false; + } sol1 = TopoDS::Solid(localshape1); acurrentsolid = sol1; if (aMapOfUsedSolids.Contains(localshape1)) + { continue; + } int j = 1, acheckiterator = 0; while (j <= aMapOfSolid.Extent() && (acheckiterator <= aMaxNumberOfIterations)) @@ -2457,7 +2709,9 @@ static bool disjPerformFuse( } const TopoDS_Shape& localshape2 = aMapOfSolid(j); if (localshape2.ShapeType() != TopAbs_SOLID) + { return false; + } j++; // increase iterator @@ -2480,11 +2734,13 @@ static bool disjPerformFuse( icla2); if (ires == RESUNDEF || icla1 == SHEUNDEF || icla2 == SHEUNDEF || ires == RESNULL) { - std::cout << "Warning: disjPerformFuse: can not determine solid's states" << std::endl; + std::cout << "Warning: disjPerformFuse: can not determine solid's states" << '\n'; continue; } if (ires == RESSHAPE12) + { continue; + } if (ires == RESNEWSHA1 || ires == RESNEWSHA2) { @@ -2501,12 +2757,14 @@ static bool disjPerformFuse( acurrentsolid = newsol; aMapOfUsedSolids.Add(localshape2); if (acurrentsolid.IsNull()) + { return false; + } } } // end while(j) if (acheckiterator > aMaxNumberOfIterations) { - std::cout << "disjPerformFuse: programming error" << std::endl; + std::cout << "disjPerformFuse: programming error" << '\n'; return false; } theMapOfResult.Add(acurrentsolid); @@ -2543,7 +2801,9 @@ static bool disjPerformCommon( { const TopoDS_Shape& localshape1 = aMapOfSeparatedSolid1(i); if (localshape1.ShapeType() != TopAbs_SOLID) + { return false; + } sol1 = TopoDS::Solid(localshape1); outsha1 = BRepClass3d::OuterShell(sol1); @@ -2551,7 +2811,9 @@ static bool disjPerformCommon( { const TopoDS_Shape& localshape2 = aMapOfSeparatedSolid2(j); if (localshape2.ShapeType() != TopAbs_SOLID) + { return false; + } sol2 = TopoDS::Solid(localshape2); outsha2 = BRepClass3d::OuterShell(sol2); @@ -2567,7 +2829,7 @@ static bool disjPerformCommon( icla2); if (ires == RESUNDEF || icla1 == SHEUNDEF || icla2 == SHEUNDEF) { - std::cout << "Warning: disjPerformCommon: can not determine solid's states" << std::endl; + std::cout << "Warning: disjPerformCommon: can not determine solid's states" << '\n'; continue; } switch (ires) @@ -2634,7 +2896,9 @@ static bool disjPerformCut( { const TopoDS_Shape& localshape1 = aMapOfSeparatedSolid1(i); if (localshape1.ShapeType() != TopAbs_SOLID) + { return false; + } sol1 = TopoDS::Solid(localshape1); acurrentsolid = sol1; @@ -2644,7 +2908,9 @@ static bool disjPerformCut( { const TopoDS_Shape& localshape2 = aMapOfSeparatedSolid2(j); if (localshape2.ShapeType() != TopAbs_SOLID) + { return false; + } sol2 = TopoDS::Solid(localshape2); outsha2 = BRepClass3d::OuterShell(sol2); outsha1 = BRepClass3d::OuterShell(acurrentsolid); @@ -2660,7 +2926,7 @@ static bool disjPerformCut( icla2); if (ires == RESUNDEF || icla1 == SHEUNDEF || icla2 == SHEUNDEF) { - std::cout << "Warning: disjPerformCut: can not determine solid's states" << std::endl; + std::cout << "Warning: disjPerformCut: can not determine solid's states" << '\n'; continue; } switch (ires) @@ -2702,7 +2968,9 @@ static bool disjPerformCut( if (!NullResult) { if (acurrentsolid.IsNull()) + { return false; + } theMapOfResult.Add(acurrentsolid); } } // end for(i) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Merge.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Merge.cxx index 3321c420b2..f55ad88363 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Merge.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Merge.cxx @@ -55,11 +55,15 @@ static void CorrectEdgeOrientation(TopoDS_Shape& aWire) TopoDS_Iterator tdi(aWire, false, false); for (; tdi.More(); tdi.Next()) + { anEdgeList.Append(tdi.Value()); + } int n = anEdgeList.Extent(); if (n <= 1) + { return; + } NCollection_List::Iterator anIt(anEdgeList); @@ -118,13 +122,17 @@ static void CorrectEdgeOrientation(TopoDS_Shape& aWire) } if (n > 0) + { aTrueEdgeList.Append(anEdgeList); + } aWire.Nullify(); BB.MakeWire(TopoDS::Wire(aWire)); anIt.Initialize(aTrueEdgeList); for (; anIt.More(); anIt.Next()) + { BB.Add(aWire, anIt.Value()); + } } static void CorrectUnclosedWire(TopoDS_Shape& aWire) @@ -246,7 +254,9 @@ void TopOpeBRepBuild_Builder::MergeShapes(const TopoDS_Shape& S1, ex1.Init(S1, tex1); } else + { ex1.Init(S1, tex1); + } SplitShapes(ex1, ToBuild1, ToBuild2, SFS, RevOri1); } @@ -283,7 +293,9 @@ void TopOpeBRepBuild_Builder::MergeShapes(const TopoDS_Shape& S1, ex2.Init(S2, tex2); } else + { ex2.Init(S2, tex2); + } SplitShapes(ex2, ToBuild2, ToBuild1, SFS, RevOri2); } @@ -371,7 +383,9 @@ void TopOpeBRepBuild_Builder::MakeSolids(TopOpeBRepBuild_SolidBuilder& SOBU, { bool isold = SOBU.IsOldShell(); if (isold) + { newShell = SOBU.OldShell(); + } else { myBuildTool.MakeShell(newShell); @@ -400,7 +414,9 @@ void TopOpeBRepBuild_Builder::MakeShells(TopOpeBRepBuild_SolidBuilder& SOBU, { bool isold = SOBU.IsOldShell(); if (isold) + { newShell = SOBU.OldShell(); + } else { myBuildTool.MakeShell(newShell); @@ -451,7 +467,9 @@ void TopOpeBRepBuild_Builder::MakeFaces(const TopoDS_Shape& aFace, { bool isold = FABU.IsOldWire(); if (isold) + { newWire = FABU.OldWire(); + } else { myBuildTool.MakeWire(newWire); @@ -459,7 +477,9 @@ void TopOpeBRepBuild_Builder::MakeFaces(const TopoDS_Shape& aFace, { const TopoDS_Shape& E = FABU.Edge(); if (hns) + { myBuildTool.UpdateSurface(E, aFace, newFace); + } myBuildTool.AddWireEdge(newWire, E); } } @@ -510,9 +530,13 @@ void TopOpeBRepBuild_Builder::MakeEdges(const TopoDS_Shape& anEdge, // 1 vertex sur edge courante => suppression edge int nloop = 0; for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) + { nloop++; + } if (nloop <= 1) + { continue; + } myBuildTool.CopyEdge(anEdge, newEdge); @@ -591,7 +615,9 @@ void TopOpeBRepBuild_Builder::MakeEdges(const TopoDS_Shape& anEdge, #endif if (hasvertex) + { L.Append(newEdge); + } } // loop on EDBU edges } // MakeEdges @@ -603,13 +629,21 @@ bool TopOpeBRepBuild_Builder::IsMerged(const TopoDS_Shape& S, const TopAbs_State TopOpeBRepDS_ListOfShapeOn1State, TopTools_ShapeMapHasher>* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &myMergedOUT; + } else if (ToBuild == TopAbs_IN) + { p = &myMergedIN; + } else if (ToBuild == TopAbs_ON) + { p = &myMergedON; + } if (p == nullptr) + { return false; + } bool notbound = !(*p).IsBound(S); if (notbound) @@ -634,13 +668,21 @@ const NCollection_List& TopOpeBRepBuild_Builder::Merged( TopOpeBRepDS_ListOfShapeOn1State, TopTools_ShapeMapHasher>* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &myMergedOUT; + } else if (ToBuild == TopAbs_IN) + { p = &myMergedIN; + } else if (ToBuild == TopAbs_ON) + { p = &myMergedON; + } if (p == nullptr) + { return myEmptyShapeList; + } if (!(*p).IsBound(S)) { @@ -661,13 +703,21 @@ NCollection_List& TopOpeBRepBuild_Builder::ChangeMerged(const Topo NCollection_DataMap* p = nullptr; if (ToBuild == TopAbs_OUT) + { p = &myMergedOUT; + } else if (ToBuild == TopAbs_IN) + { p = &myMergedIN; + } else if (ToBuild == TopAbs_ON) + { p = &myMergedON; + } if (p == nullptr) + { return myEmptyShapeList; + } if (!(*p).IsBound(S)) { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_PaveClassifier.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_PaveClassifier.cxx index 2e2ebffa94..c8df6c865c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_PaveClassifier.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_PaveClassifier.cxx @@ -125,23 +125,35 @@ TopAbs_State TopOpeBRepBuild_PaveClassifier::CompareOnNonPeriodic() if (myP1 == myP2) { if (myO1 == myO2) + { state = TopAbs_IN; + } else + { state = TopAbs_OUT; + } } else if (myP1 < myP2) { if (lower) + { state = TopAbs_IN; + } else + { state = TopAbs_OUT; + } } else { if (lower) + { state = TopAbs_OUT; + } else + { state = TopAbs_IN; + } } } @@ -209,7 +221,9 @@ double TopOpeBRepBuild_PaveClassifier::AdjustCase(const double p1, void TopOpeBRepBuild_PaveClassifier::AdjustOnPeriodic() { if (!ToAdjustOnPeriodic()) + { return; + } #ifdef OCCT_DEBUG double p1 = myP1, p2 = myP2; @@ -225,9 +239,13 @@ void TopOpeBRepBuild_PaveClassifier::AdjustOnPeriodic() else if (myO1 != myO2) { if (myO1 == TopAbs_FORWARD) + { myP2 = AdjustCase(myP2, myO2, myP1, myPeriod, tol, myCas2); + } if (myO2 == TopAbs_FORWARD) + { myP1 = AdjustCase(myP1, myO1, myP2, myPeriod, tol, myCas1); + } } #ifdef OCCT_DEBUG @@ -323,9 +341,13 @@ TopAbs_State TopOpeBRepBuild_PaveClassifier::Compare(const occ::handle& PV = it.Value(); @@ -208,13 +214,17 @@ void TopOpeBRepBuild_PaveSet::Prepare() bool hasVSD = PV->HasSameDomain(); TopoDS_Vertex VSD; if (hasVSD) + { VSD = TopoDS::Vertex(PV->SameDomain()); + } TopAbs_Orientation VIori = VI.Orientation(); bool visameve = (VI.IsSame(VE)); bool vsdsameve = false; if (hasVSD) + { vsdsameve = (VSD.IsSame(VE)); + } bool samevertexprocessing = (visameve || vsdsameve) && !isEd; if (samevertexprocessing) @@ -242,7 +252,9 @@ void TopOpeBRepBuild_PaveSet::Prepare() myVertices.Remove(it); // ofv bool islook = FUN_islook(myEdge); if ((VEbound && (vsdsameve || visameve)) && islook) + { add = true; // ofv + } } break; } @@ -304,7 +316,6 @@ void TopOpeBRepBuild_PaveSet::Prepare() #endif myPrepareDone = true; - return; } //================================================================================================= @@ -312,7 +323,9 @@ void TopOpeBRepBuild_PaveSet::Prepare() void TopOpeBRepBuild_PaveSet::InitLoop() { if (!myPrepareDone) + { Prepare(); + } myVerticesIt.Initialize(myVertices); } @@ -362,7 +375,9 @@ bool TopOpeBRepBuild_PaveSet::HasEqualParameters() { const TopoDS_Shape& v2 = it2.Value()->Vertex(); if (v2.IsEqual(v1)) + { continue; + } p2 = it2.Value()->Parameter(); double d = std::abs(p1 - p2); @@ -389,7 +404,9 @@ bool TopOpeBRepBuild_PaveSet::HasEqualParameters() double ff, ll; occ::handle CmyEdge = BRep_Tool::Curve(myEdge, loc, ff, ll); if (CmyEdge.IsNull()) + { rd = false; + } else { f = ff; @@ -445,7 +462,9 @@ double TopOpeBRepBuild_PaveSet::EqualParameters() const bool TopOpeBRepBuild_PaveSet::ClosedVertices() { if (myVertices.IsEmpty()) + { return false; + } TopoDS_Shape Vmin, Vmax; double parmin = RealLast(), parmax = RealFirst(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SREGU.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SREGU.cxx index 497a6296f9..89ab2e49fd 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SREGU.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SREGU.cxx @@ -61,7 +61,9 @@ void TopOpeBRepBuild_Builder::RegularizeSolids(const TopoDS_Shape& #endif int nr = myMemoSplit.Extent(); if (nr == 0) + { return; + } // lsosdSO = solids SameDomain de SO NCollection_List lsosdSO, lsosdSO1, lsosdSO2; @@ -83,7 +85,9 @@ void TopOpeBRepBuild_Builder::RegularizeSolids(const TopoDS_Shape& TopAbs_State staf = (rankf == 1) ? myState1 : myState2; bool issplitf = IsSplit(f, staf); if (!issplitf) + { continue; + } NCollection_List newlspf; NCollection_List& lspf = ChangeSplit(f, staf); @@ -95,7 +99,9 @@ void TopOpeBRepBuild_Builder::RegularizeSolids(const TopoDS_Shape& const TopoDS_Shape& fsp = itl1.Value(); bool fspmemo = myMemoSplit.Contains(fsp); if (!fspmemo) + { newlspf.Append(fsp); + } else { NCollection_List& lspfsp = ChangeSplit(fsp, staf); @@ -224,7 +230,9 @@ void TopOpeBRepBuild_Builder::RegularizeSolid(const TopoDS_Shape& SS // LOSO = nouvelles Solids regularisees de newSolid NCollection_List::Iterator itlnf(newSolids); for (; itlnf.More(); itlnf.Next()) + { LOSO.Append(TopoDS::Solid(itlnf.Value())); + } // mise a jour des faces decoupees // Face(SS) = {E}, E-->Split(E) = {E'}, E'-->myFSplits(E') = {E''} @@ -292,7 +300,9 @@ void TopOpeBRepBuild_Builder::RegularizeSolid(const TopoDS_Shape& SS bool inmfns = mfns.Contains(fspssdSSf); if (!inmfns) + { continue; + } // ssdSSf est une face de ssdSS (Cf supra E) // fspssdSSf de Split(ssdSSf) figure dans newSolid (Cf supra E') diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Section.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Section.cxx index d0b34ff978..3c388a6ca7 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Section.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Section.cxx @@ -86,19 +86,29 @@ static bool FUN_periodicS(const TopoDS_Shape& F) //--------------------------------------------- { if (F.IsNull()) + { return false; + } if (F.ShapeType() != TopAbs_FACE) + { return false; + } occ::handle SSS = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); GeomAdaptor_Surface GAS(SSS); GeomAbs_SurfaceType styp = GAS.GetType(); bool periodic = false; if (styp == GeomAbs_Cylinder) + { periodic = true; + } if (styp == GeomAbs_Cone) + { periodic = true; + } if (styp == GeomAbs_Sphere) + { periodic = true; + } // NYI : for Torus,SurfaceOfRevolution.. return periodic; } @@ -119,7 +129,9 @@ static bool FUN_onboundsper(const gp_Pnt2d& uv, const TopoDS_Face& F) bool uclo = su->IsUPeriodic(); bool vclo = su->IsVPeriodic(); if (!uclo && !vclo) + { return false; + } double u1, u2, v1, v2; su->Bounds(u1, u2, v1, v2); @@ -154,7 +166,9 @@ static bool FUN_onboundsper(const TopoDS_Edge& E, const TopoDS_Face& F, gp_Pnt2d double tolF = BRep_Tool::Tolerance(F) * 1.e2; // nyitol bool ok = FUN_tool_parF(E, par, F, uv, tolF); if (!ok) + { return false; + } bool onbp = ::FUN_onboundsper(uv, F); return onbp; @@ -216,11 +230,17 @@ static bool FUN_EstaEE(const TopoDS_Edge& E, const TopAbs_State sta, const TopoD gp_Pnt P = CE->Value(p); EinEE = FUN_PinE(P, EE); if (sta == TopAbs_IN) + { return EinEE; + } else if (sta == TopAbs_OUT) + { return !EinEE; + } else + { throw Standard_ProgramError("TopOpeBRepBuild FUN_EstaEE on invalid state"); + } } //================================================================================================= @@ -252,7 +272,9 @@ static void FUN_selLEE(NCollection_List& LE, LE.Remove(it); } else + { it.Next(); + } } } @@ -282,7 +304,9 @@ bool FUN_FindEinSLOS(const TopoDS_Shape& E void TopOpeBRepBuild_Builder::SplitSectionEdges() { if (mySplitSectionEdgesDone) + { return; + } const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); int i, n = BDS.NbSectionEdges(); @@ -291,7 +315,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() { // 1 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if (E.IsNull()) + { continue; + } SplitSectionEdge(E); } // 1 @@ -305,7 +331,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() { // 2 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if (E.IsNull()) + { continue; + } int iE = myDataStructure->Shape(E); int rE = BDS.AncestorRank(E); @@ -318,11 +346,15 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool isspliton = IsSplit(E, TopAbs_ON); if (!isspliton) + { continue; + } const NCollection_List& LESD = BDS.ShapeSameDomain(E); if (LESD.IsEmpty()) + { continue; + } const NCollection_List& LEspon = Splits(E, TopAbs_ON); NCollection_List LEoutLESD; @@ -387,9 +419,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() } if (pE1 == nullptr || pE2 == nullptr) + { continue; + } if (plos1 == nullptr || plos2 == nullptr) + { continue; + } const TopoDS_Edge& E1 = *pE1; const TopoDS_Edge& E2 = *pE2; @@ -409,7 +445,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool E1b = MEIN.IsBound(E1); NCollection_List thelist; if (!E1b) + { MEIN.Bind(E1, thelist); + } NCollection_List& LE1loslos = MEIN.ChangeFind(E1); #ifdef OCCT_DEBUG // int nLE1 = LE1loslos.Extent(); @@ -418,7 +456,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool E2b = MEIN.IsBound(E2); NCollection_List thelist2; if (!E2b) + { MEIN.Bind(E2, thelist2); + } NCollection_List& LE2loslos = MEIN.ChangeFind(E2); #ifdef OCCT_DEBUG // int nLE2 = LE2loslos.Extent(); @@ -438,9 +478,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() NCollection_List newle; bool ok = TopOpeBRepTool_TOOL::SplitE(e, newle); if (ok) + { LR.Append(newle); + } else + { LR.Append(e); + } } { TopOpeBRepBuild_ShapeListOfShape thelist3; @@ -473,7 +517,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() { // 3 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if (E.IsNull()) + { continue; + } #ifdef OCCT_DEBUG int iE = myDataStructure->Shape(E); // int rE = GShapeRank(E); @@ -484,16 +530,22 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool isspliton = IsSplit(E, TopAbs_ON); if (!isspliton) + { continue; + } const NCollection_List& LESD = BDS.ShapeSameDomain(E); if (LESD.IsEmpty()) + { continue; + } bool isbMEOUT = MEOUT.IsBound(E); bool isbMEIN = MEIN.IsBound(E); if (!isbMEOUT && !isbMEIN) + { continue; + } NCollection_List& LEspon = ChangeSplit(E, TopAbs_ON); LEspon.Clear(); @@ -530,7 +582,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() { // 4 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if (E.IsNull()) + { continue; + } #ifdef OCCT_DEBUG int idebE; bool tSPS = GtraceSPS(E, idebE); @@ -539,7 +593,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() #endif const NCollection_List& lesd = BDS.ShapeSameDomain(E); if (lesd.IsEmpty()) + { continue; + } int iE = BDS.Shape(E); #ifdef OCCT_DEBUG @@ -547,7 +603,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() #endif int RE = BDS.SameDomainRef(E); if (iE != RE) + { continue; + } NCollection_List lF; NCollection_List::Iterator itlesd; @@ -598,7 +656,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() } } if (besdF) + { break; + } } NCollection_List::Iterator itlon(lon); @@ -608,7 +668,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() double f, l; bool hasPC = FC2D_HasCurveOnSurface(eon, F); if (hasPC) + { continue; + } #ifdef OCCT_DEBUG if (TopOpeBRepTool_GettraceC2D()) { @@ -623,7 +685,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() // clang-format on hasPC = (!PC.IsNull()); if (!hasPC) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE null PC on F"); + } double tol = std::max(tolE, tolpc); BB.UpdateEdge(eon, PC, F, tol); } @@ -636,7 +700,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() const TopoDS_Shape& FOR = myDataStructure->Shape(i); bool isface = (FOR.ShapeType() == TopAbs_FACE); if (!isface) + { continue; + } const TopoDS_Face& FF = TopoDS::Face(FOR); #ifdef OCCT_DEBUG // int iFF = BDS.Shape(FF); @@ -644,30 +710,40 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() const NCollection_List>& LI = BDS.ShapeInterferences(FF); int nLI = LI.Extent(); if (nLI == 0) + { continue; + } for (NCollection_List>::Iterator ILI(LI); ILI.More(); ILI.Next()) { occ::handle SSI( occ::down_cast(ILI.Value())); if (SSI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(SSI, GT, GI, ST, SI); if (ST != TopOpeBRepDS_FACE) + { continue; + } const TopOpeBRepDS_Transition& TFE = SSI->Transition(); TopAbs_ShapeEnum shab = TFE.ShapeBefore(), shaa = TFE.ShapeAfter(); if (shaa != TopAbs_FACE || shab != TopAbs_FACE) + { continue; + } const TopoDS_Face& FS = TopoDS::Face(myDataStructure->Shape(SI)); #ifdef OCCT_DEBUG // int iFS = myDataStructure->Shape(FS); #endif bool FSisper = FUN_periodicS(FS); if (!FSisper) + { continue; + } const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI)); #ifdef OCCT_DEBUG @@ -675,22 +751,30 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() #endif bool isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) + { continue; + } #ifdef OCCT_DEBUG // double tolE = BRep_Tool::Tolerance(EG); #endif bool haspc = FC2D_HasCurveOnSurface(EG, FS); if (haspc) + { continue; + } bool hasc3d = FC2D_HasC3D(EG); if (!hasc3d) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE EG without C3D"); + } double pf, pl, tolpc; occ::handle PC; bool trim3d = true; PC = FC2D_CurveOnSurface(EG, FS, pf, pl, tolpc, trim3d); if (PC.IsNull()) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE EG without PC on FS"); + } } } // 5 @@ -700,7 +784,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() const TopoDS_Shape& FOR = myDataStructure->Shape(i); bool isface = (FOR.ShapeType() == TopAbs_FACE); if (!isface) + { continue; + } const TopoDS_Face& FF = TopoDS::Face(FOR); #ifdef OCCT_DEBUG // int iFF = BDS.Shape(FF); @@ -708,27 +794,37 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool FFuper, FFvper; bool FFisper = FUN_periodic(FF, FFuper, FFvper); if (!FFisper) + { continue; + } const NCollection_List>& LI = BDS.ShapeInterferences(FF); int nLI = LI.Extent(); if (nLI == 0) + { continue; + } for (NCollection_List>::Iterator ILI(LI); ILI.More(); ILI.Next()) { occ::handle SSI( occ::down_cast(ILI.Value())); if (SSI.IsNull()) + { continue; + } TopOpeBRepDS_Kind GT, ST; int GI, SI; FDS_data(SSI, GT, GI, ST, SI); if (ST != TopOpeBRepDS_FACE) + { continue; + } bool GB = SSI->GBound(); if (GB == 1) + { continue; + } const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI)); #ifdef OCCT_DEBUG @@ -736,7 +832,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() #endif bool isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) + { continue; + } // xpu191198 : cto016* double pf, pl, tolpc; @@ -765,7 +863,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() bool ISOon = TopOpeBRepTool_TOOL::UVISO(PCon, isouon, isovon, d2don, o2don); bool PCko = !ISOon || ((isoU && !isouon) || (isoV && !isovon)); if (PCko) + { throw Standard_ProgramError("TopOpeBRepBuild_Builder::splitON"); + } bool test = (FFuper && isoU) || (FFvper && isoV); if (!test) @@ -799,7 +899,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges() double mag = tr.Magnitude(); double toluv = 1.e-8 * 1.e2; // NYINYI if (mag > toluv) + { TopOpeBRepTool_TOOL::TrslUVModifE(tr, FF, eon); + } } newlON.Append(eon); } // itON @@ -853,9 +955,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) GLOBAL_hassd = 0; // initializing if (hsd3d) + { GLOBAL_hassd = 3; //++ + } if (hsd2d) + { GLOBAL_hassd = 2; //++ + } if (mySplitSectionEdgesDone) { @@ -907,11 +1013,15 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) TopoDS_Shape oov; bool hsdmv = FUN_ds_getoov(v, myDataStructure, oov); if (!hsdmv) + { allGb1 = false; + } allGb1 = (oov.IsSame(vf) || oov.IsSame(vl)); } if (!allGb1) + { break; + } } // tki bool mke = !cond; @@ -938,9 +1048,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) int ivref = 0; bool hsd = false; if (iv != 0) + { hsd = myDataStructure->HasSameDomain(v); + } if (hsd) + { ivref = myDataStructure->SameDomainReference(v); + } bool setref = hsd && (iv != ivref); TopoDS_Vertex vref = TopoDS::Vertex(BDS.Shape(ivref)); if (!setref) @@ -955,9 +1069,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) FUN_ds_Parameter(newEOR, vref, parv); } if (hasnewEOR) + { LON.Append(newEOR); + } else + { LON.Append(EOR); + } return; } // mke @@ -994,7 +1112,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) TopOpeBRepBuild_PaveClassifier VCL(EF); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } TopOpeBRepBuild_EdgeBuilder EDBU; EDBU.InitEdgeBuilder(PVS, VCL); @@ -1013,9 +1133,13 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) bool ok = TopOpeBRepTool_TOOL::SplitE(esp, lspe); bool nonwesp = (!ok) || (lspe.Extent() < 2); if (nonwesp) + { newLEM.Append(esp); + } else + { newLEM.Append(lspe); + } } LEM.Clear(); LEM.Append(newLEM); @@ -1049,7 +1173,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) TopOpeBRepBuild_PaveClassifier VCL(EF); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } TopOpeBRepBuild_EdgeBuilder EDBU; EDBU.InitEdgeBuilder(PVS, VCL); @@ -1084,7 +1210,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) TopOpeBRepBuild_PaveClassifier VCL(EF); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } TopOpeBRepBuild_EdgeBuilder EDBU; EDBU.InitEdgeBuilder(PVS, VCL); @@ -1106,7 +1234,9 @@ void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) const NCollection_List& TopOpeBRepBuild_Builder::Section() { if (mySectionDone) + { return mySection; + } mySectionDone = true; SectionCurves(mySection); SectionEdges(mySection); @@ -1151,7 +1281,9 @@ void TopOpeBRepBuild_Builder::SectionEdges(NCollection_List& LSE) const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); // modif fbi 16-09-97: case possible if RemoveSectionEdge was called if (E.IsNull()) + { continue; + } // end modif fbi LSE.Append(E); } @@ -1170,7 +1302,9 @@ void TopOpeBRepBuild_Builder::SectionEdges(NCollection_List& LSE) const TopoDS_Shape& es = BDS.SectionEdge(i); // modif fbi 16-09-97: case possible if RemoveSectionEdge was called if (es.IsNull()) + { continue; + } // end modif fbi bool issplitIN = IsSplit(es, TopAbs_IN); bool issplitON = IsSplit(es, TopAbs_ON); @@ -1230,7 +1364,9 @@ void TopOpeBRepBuild_Builder::FillSecEdgeAncestorMap( { const TopoDS_Shape& es = BDS.SectionEdge(i); if (es.IsNull() || ShapeRank(es) != aShapeRank) + { continue; + } if (aMapON.Contains(es)) { anAncMap.Bind(es, es); @@ -1247,7 +1383,9 @@ void TopOpeBRepBuild_Builder::FillSecEdgeAncestorMap( { const TopoDS_Shape& aS = it.Value(); if (aMapON.Contains(aS)) + { anAncMap.Bind(aS, es); + } } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx index 651e947a7c..c60409ab97 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShapeSet.cxx @@ -39,11 +39,17 @@ TopOpeBRepBuild_ShapeSet::TopOpeBRepBuild_ShapeSet(const TopAbs_ShapeEnum SubSha myCheckShape(checkshape) { if (SubShapeType == TopAbs_EDGE) + { myShapeType = TopAbs_FACE; + } else if (SubShapeType == TopAbs_VERTEX) + { myShapeType = TopAbs_EDGE; + } else + { throw Standard_ProgramError("ShapeSet : bad ShapeType"); + } myDEBNumber = 0; myCheckShape = false; // temporary NYI @@ -61,7 +67,9 @@ void TopOpeBRepBuild_ShapeSet::AddShape(const TopoDS_Shape& S) #endif if (!chk) + { return; + } ProcessAddShape(S); } @@ -75,7 +83,9 @@ void TopOpeBRepBuild_ShapeSet::AddStartElement(const TopoDS_Shape& S) #endif if (!chk) + { return; + } ProcessAddStartElement(S); } @@ -89,7 +99,9 @@ void TopOpeBRepBuild_ShapeSet::AddElement(const TopoDS_Shape& S) #endif if (!chk) + { return; + } ProcessAddElement(S); } @@ -130,7 +142,9 @@ void TopOpeBRepBuild_ShapeSet::ProcessAddElement(const TopoDS_Shape& S) const TopoDS_Shape& subshape = Ex.Current(); bool b = (!mySubShapeMap.Contains(subshape)); if (b) + { mySubShapeMap.Add(subshape, Lemp); + } mySubShapeMap.ChangeFromKey(subshape).Append(S); } } @@ -271,9 +285,13 @@ void TopOpeBRepBuild_ShapeSet::FindNeighbours() myIncidentShapesIter.Initialize(l); if (myIncidentShapesIter.More()) + { break; + } else + { mySubShapeExplorer.Next(); + } } } @@ -342,7 +360,9 @@ bool TopOpeBRepBuild_ShapeSet::CheckShape() const bool TopOpeBRepBuild_ShapeSet::CheckShape(const TopoDS_Shape& S, const bool checkgeom) { if (!myCheckShape) + { return true; + } BRepCheck_Analyzer ana(S, checkgeom); bool val = ana.IsValid(); @@ -373,7 +393,9 @@ void TopOpeBRepBuild_ShapeSet::DumpCheck(Standard_OStream&, ) const { if (!myCheckShape) + { return; + } #ifdef OCCT_DEBUG TopAbs_ShapeEnum t = S.ShapeType(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShellToSolid.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShellToSolid.cxx index cc504bbc79..3684aebdfd 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShellToSolid.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ShellToSolid.cxx @@ -47,7 +47,9 @@ void TopOpeBRepBuild_ShellToSolid::MakeSolids(const TopoDS_Solid& So TopOpeBRepBuild_ShellFaceSet sfs(So); for (NCollection_List::Iterator it(myLSh); it.More(); it.Next()) + { sfs.AddShape(it.Value()); + } bool ForceClass = true; TopOpeBRepBuild_SolidBuilder SB; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SolidBuilder.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SolidBuilder.cxx index 92952de26d..e8c54b302e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SolidBuilder.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_SolidBuilder.cxx @@ -113,7 +113,9 @@ int TopOpeBRepBuild_SolidBuilder::InitFace() { const occ::handle& L = mySolidAreaBuilder.Loop(); if (L->IsShape()) + { throw Standard_DomainError("TopOpeBRepBuild_SolidBuilder:InitFace"); + } else { myBlockIterator = L->BlockIterator(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools.cxx index 9ae5e71c96..8e785e183c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools.cxx @@ -114,8 +114,12 @@ void TopOpeBRepBuild_Tools::PropagateState( TopExp::MapShapes(aShape, aSubshEnum, aSubshapes); nSub = aSubshapes.Extent(); for (j = 1; j <= nSub; j++) - if (!anAvoidSubshMap.Contains(aSubshapes(j))) // MSV: enforce subshapes avoidance + { + if (!anAvoidSubshMap.Contains(aSubshapes(j))) + { // MSV: enforce subshapes avoidance aMapSS.Bind(aSubshapes(j), aState); + } + } } aMapSS1 = aMapSS; @@ -125,7 +129,9 @@ void TopOpeBRepBuild_Tools::PropagateState( aMapSubshAnc; nRest = aShapesToRestMap.Extent(); for (j = 1; j <= nRest; j++) + { TopExp::MapShapesAndAncestors(aShapesToRestMap(j), aSubshEnum, aShapeEnum, aMapSubshAnc); + } // 2. Make Map Of all subshapes aMapSS NCollection_Map aProcessedSubshapes; @@ -181,7 +187,9 @@ void TopOpeBRepBuild_Tools::PropagateState( NCollection_Map::Iterator aMapIt; aMapIt.Initialize(aNonPassedShapes); for (; aMapIt.More(); aMapIt.Next()) + { TopExp::MapShapesAndAncestors(aMapIt.Key(), aSubshEnum, aShapeEnum, aMapSubshAnc); + } aMapSS.Clear(); aMapIt.Initialize(aNonPassedShapes); @@ -203,18 +211,28 @@ void TopOpeBRepBuild_Tools::PropagateState( TopExp::MapShapes(aNonPassedShape, aSubshEnum, aTmpMap); TopoDS_Shape aFirstSubsh; for (j = 1; j <= aTmpMap.Extent() && aFirstSubsh.IsNull(); j++) + { if (!anAvoidSubshMap.Contains(aTmpMap(j))) + { aFirstSubsh = aTmpMap(j); + } + } if (aFirstSubsh.IsNull()) + { continue; + } aMapSS.Bind(aFirstSubsh, aState); // Propagation of aState for subshapes NCollection_Map aMapProcessedSubsh; if (aSubshEnum == TopAbs_EDGE) + { FindState1(aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); - else // if (aSubshEnum==TopAbs_VERTEX) + } + else + { // if (aSubshEnum==TopAbs_VERTEX) FindState2(aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS); + } } } @@ -226,7 +244,9 @@ void TopOpeBRepBuild_Tools::PropagateState( { aShapeWithState.SetState(anII.Value()); if (anII.Key().ShapeType() != TopAbs_VERTEX) + { aMapOfShapeWithState.Add(anII.Key(), aShapeWithState); + } } } } @@ -292,7 +312,9 @@ void TopOpeBRepBuild_Tools::FindState1( TopExp::MapShapes(aShape, TopAbs_WIRE, aWireMap); nW = aWireMap.Extent(); for (j = 1; j <= nW; j++) + { aMapSS.Bind(aWireMap(j), aState); + } // Edge NCollection_IndexedMap aSubshMap; TopExp::MapShapes(aShape, TopAbs_EDGE, aSubshMap); @@ -325,16 +347,24 @@ TopAbs_State TopOpeBRepBuild_Tools::FindStateThroughVertex( TopoDS_Shape aSubsh; int i; for (i = 1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++) + { if (!anAvoidSubshMap.Contains(aSubshMap(i))) + { aSubsh = aSubshMap(i); + } + } if (aSubsh.IsNull()) { // try an edge aSubshMap.Clear(); TopExp::MapShapes(aShape, TopAbs_EDGE, aSubshMap); for (i = 1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++) + { if (!anAvoidSubshMap.Contains(aSubshMap(i))) + { aSubsh = aSubshMap(i); + } + } if (aSubsh.IsNull()) { #ifdef OCCT_DEBUG @@ -564,7 +594,9 @@ bool TopOpeBRepBuild_Tools::GetTangentToEdgeEdge(const TopoDS_Face&, // aFObj, // printf(" aNP ={%lf, %lf, %lf}\n", aNP.X(), aNP.Y(), aNP.Z()); // printf(" aPOri={%lf, %lf, %lf}\n", aPOri.X(), aPOri.Y(), aPOri.Z()); if (aEd.Orientation() == TopAbs_REVERSED) + { aTangent.Reverse(); + } if (aTgOri * aTgPiece < 0.) { @@ -712,7 +744,9 @@ void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeT aN2); if (aN1 * aN2 < 0) + { DiffOriented = true; + } double tolE = BRep_Tool::Tolerance(newE); double f2 = 0., l2 = 0., tolpc = 0., tol = 0.; @@ -742,9 +776,13 @@ void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeT oldC2DRev->D0(fr, aUVr); if (!DiffOriented) + { aTrV = gp_Vec2d(aUVf, aUVr); + } else + { aTrV = gp_Vec2d(aUVr, aUVf); + } gp_Vec2d aux(gp_Pnt2d(0., 0.), gp_Pnt2d(1., 1.)); double scalar = aux * aTrV; @@ -766,7 +804,9 @@ void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeT firstOrder = scalar >= 0.; } else + { firstOrder = scalar <= 0.; + } occ::handle aTrC = occ::down_cast(C2D->Copy()); aTrC->Translate(aTrV); @@ -774,16 +814,24 @@ void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeT if (dir) { if (firstOrder) + { BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol); + } else + { BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol); + } } else { if (!firstOrder) + { BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol); + } else + { BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol); + } } } @@ -796,7 +844,9 @@ bool TopOpeBRepBuild_Tools::IsDegEdgesTheSame(const TopoDS_Shape& anE1, const To TopExp::MapShapes(anE2, TopAbs_VERTEX, aVMap2); if (!aVMap1.Extent() || !aVMap2.Extent()) + { return false; + } return aVMap1(1).IsSame(aVMap2(1)); } @@ -835,7 +885,9 @@ void TopOpeBRepBuild_Tools::NormalizeFace(const TopoDS_Shape& oldFace, TopoDS_Sh TopoDS_Shape anEdge = aWExp.Current(); if (anEdge.Orientation() == TopAbs_EXTERNAL || anEdge.Orientation() == TopAbs_INTERNAL) + { continue; + } BB.Add(aNewWire, TopoDS::Edge(anEdge)); NbGoodEdges++; @@ -843,8 +895,10 @@ void TopOpeBRepBuild_Tools::NormalizeFace(const TopoDS_Shape& oldFace, TopoDS_Sh // keep wire orientation aNewWire.Orientation(aFExp.Current().Orientation()); // aWire.Orientation()); - if (NbGoodEdges) // we add new wire only if it contains at least one edge + if (NbGoodEdges) + { // we add new wire only if it contains at least one edge BB.Add(aNewFace, aNewWire); + } } // keep face orientation aNewFace.Orientation(oldFace.Orientation()); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools2d.cxx index 601bf7bf4d..1478785232 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools2d.cxx @@ -46,7 +46,9 @@ void TopOpeBRepBuild_Tools2d::Path(const TopoDS_Wire& aWire, TopExp_Explorer ex(aWire, TopAbs_EDGE); for (; ex.More(); ex.Next()) + { aNbEdges++; + } myResList.Clear(); @@ -80,7 +82,9 @@ void BuildPath( TopoDS_Vertex myVertex; if (aBreakFlag == 1) + { return; + } TopOpeBRepBuild_VertexInfo& aVInfo = M.ChangeFromKey(myInputVertex); // @@ -88,7 +92,9 @@ void BuildPath( aVInfo.Prepare(myResList); aNbCases = aVInfo.NbCases(); if (!aNbCases) + { aBreakFlag = 2; + } for (j = 1; j <= aNbCases; j++) { @@ -168,15 +174,21 @@ void TopOpeBRepBuild_Tools2d::MakeMapOfShapeVertexInfo( const TopoDS_Vertex& aVertex = TopoDS::Vertex(exs.Current()); int index = M.FindIndex(aVertex); if (!index) + { index = M.Add(aVertex, empty); + } TopOpeBRepBuild_VertexInfo& aVInfo = M(index); aVInfo.SetVertex(aVertex); TopAbs_Orientation anOr = aVertex.Orientation(); if (anOr == TopAbs_FORWARD) + { aVInfo.AddOut(anEdge); + } else if (anOr == TopAbs_REVERSED) + { aVInfo.AddIn(anEdge); + } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools_1.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools_1.cxx index c77ca7e1a0..d12b8a4e1c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools_1.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Tools_1.cxx @@ -203,7 +203,9 @@ void CorrectEdgeTolerance(const TopoDS_Edge& myShape, const TopoDS_Face& S, cons // 2. Tolerances in InContext { if (myCref.IsNull()) + { return; + } bool ok = true; double Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape)); @@ -245,7 +247,9 @@ void CorrectEdgeTolerance(const TopoDS_Edge& myShape, const TopoDS_Face& S, cons { // printf("(Edge,1) Tolerance=%15.10lg\n", aNewTol); if (aNewTol < aMaxTol) + { TE->UpdateTolerance(aNewTol); + } } if (cr->IsCurveOnClosedSurface()) { @@ -256,7 +260,9 @@ void CorrectEdgeTolerance(const TopoDS_Edge& myShape, const TopoDS_Face& S, cons if (ok) { if (aNewTol < aMaxTol) + { TE->UpdateTolerance(aNewTol); + } } } } @@ -308,7 +314,9 @@ void CorrectEdgeTolerance(const TopoDS_Edge& myShape, const TopoDS_Face& S, cons if (ok) { if (aNewTol < aMaxTol) + { TE->UpdateTolerance(aNewTol); + } } } } // end of if (!pcurvefound) { @@ -490,7 +498,9 @@ void CheckEdge(const TopoDS_Edge& Ed, const double aMaxTol) { aNewTolerance = sqrt(aD2) + dd; if (aNewTolerance < aMaxTol) + { TV->UpdateTolerance(aNewTolerance); + } } } itpr.Next(); @@ -502,9 +512,13 @@ void CheckEdge(const TopoDS_Edge& Ed, const double aMaxTol) occ::handle GC(occ::down_cast(cr)); if (orv == TopAbs_FORWARD) + { Controlp = C->Value(GC->First()); + } else + { Controlp = C->Value(GC->Last()); + } Controlp.Transform(L.Transformation()); aD2 = prep.SquareDistance(Controlp); @@ -513,7 +527,9 @@ void CheckEdge(const TopoDS_Edge& Ed, const double aMaxTol) { aNewTolerance = sqrt(aD2) + dd; if (aNewTolerance < aMaxTol) + { TV->UpdateTolerance(aNewTolerance); + } } } } @@ -535,7 +551,9 @@ bool TopOpeBRepBuild_Tools::CheckFaceClosed2d(const TopoDS_Face& theFace) BRepCheck_Wire aWChk(aW); BRepCheck_Status aStatus = aWChk.Orientation(theFace); if (aStatus != BRepCheck_NoError) + { isClosed = false; + } } return isClosed; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_VertexInfo.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_VertexInfo.cxx index e934d1ae50..250dcb2c72 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_VertexInfo.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_VertexInfo.cxx @@ -162,7 +162,9 @@ void TopOpeBRepBuild_VertexInfo::Prepare(const NCollection_List& a { const TopoDS_Shape& aE = myEdgesOut(i); if (!tmpMap.Contains(aE)) + { myLocalEdgesOut.Add(aE); + } } tmpMap.Clear(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeClassifier.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeClassifier.cxx index 1602ad0614..7212721d05 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeClassifier.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeClassifier.cxx @@ -88,7 +88,9 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::Compare( if (state == TopAbs_UNKNOWN) { if (Bit1.More()) + { Bit1.Next(); + } yena1 = Bit1.More(); } } @@ -128,7 +130,9 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::Compare( if (state == TopAbs_UNKNOWN) { if (Bit1.More()) + { Bit1.Next(); + } yena1 = Bit1.More(); } } @@ -138,10 +142,14 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::Compare( { TopoDS_Shape s1 = LoopToShape(L1); if (s1.IsNull()) + { return state; + } TopoDS_Shape s2 = LoopToShape(L2); if (s2.IsNull()) + { return state; + } TopOpeBRepTool_ShapeClassifier& SC = FSC_GetPSC(); int samedomain = SC.SameDomain(); SC.SameDomain(1); @@ -163,7 +171,9 @@ TopoDS_Shape TopOpeBRepBuild_WireEdgeClassifier::LoopToShape( TopOpeBRepBuild_BlockIterator Bit = L->BlockIterator(); Bit.Initialize(); if (!Bit.More()) + { return myShape; + } TopoDS_Shape aLocalShape = myBCEdge.Face(); const TopoDS_Face& F1 = TopoDS::Face(aLocalShape); @@ -207,9 +217,13 @@ static gp_Vec FUN_tgINE(const TopoDS_Vertex& v, const TopoDS_Vertex& vl, const T gp_Vec tg; bool ok = TopOpeBRepTool_TOOL::TggeomE(par, e, tg); if (!ok) + { return gp_Vec(0., 0., 0.); // NYIRAISE + } if (v.IsSame(vl)) + { tg.Reverse(); + } return tg; } @@ -234,7 +248,9 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::CompareShapes(const TopoDS_Shap TopAbs_State state = TopAbs_UNKNOWN; TopExp_Explorer ex1(B1, TopAbs_EDGE); if (!ex1.More()) + { return state; + } for (; ex1.More(); ex1.Next()) { const TopoDS_Edge& e1 = TopoDS::Edge(ex1.Current()); @@ -267,9 +283,13 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::CompareShapes(const TopoDS_Shap { // xpu101198 TopoDS_Vertex vshared; if (hasf) + { vshared = vf; + } if (hasl) + { vshared = vl; + } gp_Vec tg1 = FUN_tgINE(vshared, vl1, e1); gp_Vec tg = FUN_tgINE(vshared, vl, E); double dot = tg1.Dot(tg); @@ -306,7 +326,9 @@ TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::CompareShapes(const TopoDS_Shap { const TopoDS_Edge& E2 = TopoDS::Edge(ex2.Current()); if (mape1.Contains(E2)) + { continue; + } const TopoDS_Face& theFace = myBCEdge.Face(); BRep_Builder BB; @@ -420,7 +442,9 @@ void TopOpeBRepBuild_WireEdgeClassifier::ResetElement(const TopoDS_Shape& EE) C2D = FC2D_CurveOnSurface(E, F, f2, l2, tolpc); if (C2D.IsNull()) + { throw Standard_ProgramError("WEC : ResetElement"); + } double t = 0.397891143689; double par = ((1 - t) * f2 + t * l2); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx index 1db527a3c3..17773c57b5 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireEdgeSet.cxx @@ -66,14 +66,20 @@ void TopOpeBRepBuild_WireEdgeSet::AddShape(const TopoDS_Shape& S) bool uc = bas.IsUClosed(); bool vc = bas.IsVClosed(); if (uc || vc) + { tocheck = false; + } } bool chk = true; if (tocheck) + { chk = CheckShape(S); + } if (!chk) + { return; + } ProcessAddShape(S); } @@ -95,10 +101,14 @@ void TopOpeBRepBuild_WireEdgeSet::AddStartElement(const TopoDS_Shape& S) } bool chk = true; if (tocheck) + { chk = CheckShape(S); + } if (!chk) + { return; + } ProcessAddStartElement(S); } @@ -145,9 +155,13 @@ void TopOpeBRepBuild_WireEdgeSet::FindNeighbours() myIncidentShapesIter.Initialize(l); if (myIncidentShapesIter.More()) + { break; + } else + { mySubShapeExplorer.Next(); + } } } @@ -201,13 +215,19 @@ const NCollection_List& TopOpeBRepBuild_WireEdgeSet::MakeNeighbour occ::handle PCE = FC2D_CurveOnSurface(E, F, fiE, laE, tolpc, trim3d); if (!PCE.IsNull()) + { PCE->D1(parE, pE, d1E); + } else + { LocalD1(F, E, V, pE, d1E); + } TopAbs_Orientation Eori = E.Orientation(); if (Eori == TopAbs_REVERSED) + { d1E.Reverse(); + } NCollection_List::Iterator lclo(myCurrentShapeNeighbours); while (lclo.More()) @@ -226,13 +246,19 @@ const NCollection_List& TopOpeBRepBuild_WireEdgeSet::MakeNeighbour occ::handle PCEE = FC2D_CurveOnSurface(EE, F, fiEE, laEE, tolpc1, trim3d); if (!PCEE.IsNull()) + { PCEE->D1(parEE, pEE, d1EE); + } else + { LocalD1(F, EE, V, pEE, d1EE); + } TopAbs_Orientation EEori = EE.Orientation(); if (EEori == TopAbs_REVERSED) + { d1EE.Reverse(); + } double cross = d1E.Crossed(d1EE); TopAbs_Orientation oVE, oVEE; @@ -281,7 +307,9 @@ bool TopOpeBRepBuild_WireEdgeSet::VertexConnectsEdges(const TopoDS_Shape& V, o1 = ex1.Current().Orientation(); o2 = ex2.Current().Orientation(); if (o1 != o2) + { return true; + } } } } @@ -368,7 +396,9 @@ int TopOpeBRepBuild_WireEdgeSet::NbClosingShapes(const NCollection_List TheType = PC->DynamicType(); if (TheType == STANDARD_TYPE(Geom2d_Line)) @@ -447,9 +479,13 @@ void TopOpeBRepBuild_WireEdgeSet::IsUVISO(const TopoDS_Edge& E, double tol = Precision::Angular(); if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::Y), tol)) + { uiso = true; + } else if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::X), tol)) + { viso = true; + } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireToFace.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireToFace.cxx index a2d4edb185..bc94a6c04f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireToFace.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_WireToFace.cxx @@ -46,7 +46,9 @@ void TopOpeBRepBuild_WireToFace::MakeFaces(const TopoDS_Face& F, NCollection_Lis TopOpeBRepBuild_WireEdgeSet wes(F); for (NCollection_List::Iterator it(myLW); it.More(); it.Next()) + { wes.AddShape(it.Value()); + } bool ForceClass = true; TopOpeBRepBuild_FaceBuilder FB; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_fctwes.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_fctwes.cxx index fb71282bad..7904177c6f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_fctwes.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_fctwes.cxx @@ -114,20 +114,23 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopoDS_Shape& const TopOpeBRepDS_Transition& T = I->Transition(); TopAbs_ShapeEnum shab = T.ShapeBefore(), shaa = T.ShapeAfter(); if ((shaa != ShapeInterf) || (shab != ShapeInterf)) + { continue; + } // modified by NIZHNY-MZV Thu Feb 24 09:14:31 2000 int si = I->Support(); TopoDS_Shape SS = myDataStructure->Shape(si); // see comment above if (aSDMap.Contains(SS)) + { continue; + } // End modified by NIZHNY-MZV Thu Feb 24 09:21:34 2000 } GFillCurveTopologyWES(FCit, G1, WES); } - return; } // GFillCurveTopologyWES //================================================================================================= @@ -138,7 +141,9 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIter { bool more = FCit.More(); if (!more) + { return; + } TopAbs_State TB1, TB2; G1.StatesON(TB1, TB2); @@ -187,7 +192,9 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIter #endif if (ComOfCut) + { return; + } int iG = FCit.Current(); const NCollection_List& LnewE = NewEdges(iG); @@ -199,7 +206,9 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIter // modified by NIZHNY-MZV Fri Mar 17 12:51:03 2000 if (BRep_Tool::Degenerated(E)) + { continue; + } // TopAbs_Orientation neworiE = FCit.Orientation(TB); E.Orientation(neworiE); @@ -211,7 +220,9 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIter FC2D_HasCurveOnSurface(E, FTF); // modified by NIZHNY-MZV Mon Mar 27 15:24:39 2000 if (!EhasPConFTF) + { myBuildTool.PCurve(FTF, E, PC); + } bool EhasPConWESF = FC2D_HasCurveOnSurface(E, WESF); @@ -222,7 +233,9 @@ void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIter occ::handle C2D; C2D = FC2D_CurveOnSurface(E, WESF, f2, l2, tolpc); if (C2D.IsNull()) + { throw Standard_ProgramError("GFillCurveTopologyWES"); + } #ifdef OCCT_DEBUG // double tol = std::max(tolE,tolpc); #endif diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffsfs.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffsfs.cxx index ed7b646821..b2ad230de7 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffsfs.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffsfs.cxx @@ -123,24 +123,32 @@ static int FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B, const TopoDS_Face& f = TopoDS::Face(itf.Value()); TopAbs_State st = SC.StateShapeShape(fsp, f, 1); if ((st == TopAbs_UNKNOWN) || (st == TopAbs_OUT)) + { continue; + } if (st == TopAbs_ON) { if (!p3ddef) { bool ok = BRepClass3d_SolidExplorer::FindAPointInTheFace(TopoDS::Face(fsp), p3d); if (!ok) + { return 0; + } p3ddef = true; } gp_Pnt2d p2d; double dd = 0.; bool ok = FUN_tool_projPonF(p3d, f, p2d, dd); if (!ok) + { return 0; + } double tolf = BRep_Tool::Tolerance(f) * 1.e1; if (dd > tolf) + { return 0; + } double TolClass = 1e-8; BRepTopAdaptor_FClass2d FClass2d(f, TolClass); st = FClass2d.Perform(p2d); @@ -167,9 +175,13 @@ static int FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B, FUNBUILD_ANCESTORRANKGET(B, fsp, of1, of2); int rkfsp = 0; if (of1 && !of2) + { rkfsp = 1; + } else if (of2 && !of1) + { rkfsp = 2; + } bool unk = (rkfsp == 0); int rkf1 = BDS.AncestorRank(LF1.First()); @@ -182,23 +194,37 @@ static int FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B, int ianc1 = 0, ianc2 = 0; if (ison1 || unk) + { ianc1 = FUN_getAncestorFsp(B, SC, LF1, fsp, p3ddef, p3d); + } if (ison1) + { return ianc1; + } if (ison2 || unk) + { ianc2 = FUN_getAncestorFsp(B, SC, LF2, fsp, p3ddef, p3d); + } if (ison2) + { return ianc2; + } if (ianc1 + ianc2 > 0) { if (ianc1 == 0) + { return ianc2; + } else if (ianc2 == 0) + { return ianc1; + } else + { return 0; // fsp has 2 ancestor faces + } } return 0; } @@ -215,18 +241,26 @@ static void FUN_getAncestorFsp( NCollection_DataMap* SplitAnc) { if (SplitAnc == nullptr) + { return; + } bool issplitIN = B.IsSplit(FOR, TopAbs_IN); bool issplitOU = B.IsSplit(FOR, TopAbs_OUT); if (!issplitIN && !issplitOU) + { return; + } NCollection_List spFOR; if (issplitIN) + { FDS_copy(B.Splits(FOR, TopAbs_IN), spFOR); + } if (issplitOU) + { FDS_copy(B.Splits(FOR, TopAbs_OUT), spFOR); + } for (NCollection_List::Iterator itsp(spFOR); itsp.More(); itsp.Next()) { @@ -234,7 +268,9 @@ static void FUN_getAncestorFsp( bool isbound = SplitAnc->IsBound(fsp); if (isbound) + { continue; + } int ianc = FUN_getAncestorFsp(B, SC, LF1, LF2, fsp); if (ianc != 0) @@ -326,7 +362,9 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& if (GLOBAL_lfrtoprocess) { if (GLOBAL_lfr1 == nullptr) + { GLOBAL_lfr1 = (NCollection_List*)new NCollection_List(); + } GLOBAL_lfr1->Clear(); } } @@ -335,11 +373,13 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& // . fsp = spIN/OU(fanc), // . fanc hsdm is the unique ancestor face if (GLOBAL_SplitAnc == nullptr) + { GLOBAL_SplitAnc = (NCollection_DataMap*)new NCollection_DataMap< TopoDS_Shape, int, TopTools_ShapeMapHasher>(); + } GLOBAL_SplitAnc->Clear(); NCollection_List LFSO, LFDO, LFSO1, LFDO1, LFSO2, LFDO2; @@ -388,12 +428,14 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& TopOpeBRepDS_SAMEORIENTED, TopOpeBRepDS_SAMEORIENTED); if (hsd) + { FUN_getAncestorFsp((*this), myShapeClassifier, LF1, LF2, FOR, GLOBAL_SplitAnc); // xpu280598 + } // GLOBAL_lfrtoprocess = t // ==> on ne stocke PAS les faces 'startelement' dans le SFS @@ -404,7 +446,8 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& // ici : GLOBAL_lfrtoprocess = t // clang-format off - if (GLOBAL_lfr1==nullptr) GLOBAL_lfr1=(NCollection_List*)new NCollection_List(); //flo150998 + if (GLOBAL_lfr1==nullptr) { GLOBAL_lfr1=(NCollection_List*)new NCollection_List(); //flo150998 +} // clang-format on GLOBAL_lfr1->Clear(); GSplitFaceSFS(FOR, LSO2, GM, SFS); @@ -457,12 +500,14 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& TopOpeBRepDS_SAMEORIENTED, TopOpeBRepDS_DIFFORIENTED); if (hsd) + { FUN_getAncestorFsp((*this), myShapeClassifier, LF1, LF2, FOR, GLOBAL_SplitAnc); // xpu280598 + } if (Opecom()) { @@ -479,7 +524,9 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& const TopoDS_Shape& f = it.Value(); bool issplit = IsSplit(f, TopAbs_IN); if (issplit) + { ChangeSplit(f, TopAbs_IN).Clear(); + } } it.Initialize(LF2); for (; it.More(); it.Next()) @@ -487,7 +534,9 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& const TopoDS_Shape& f = it.Value(); bool issplit = IsSplit(f, TopAbs_IN); if (issplit) + { ChangeSplit(f, TopAbs_IN).Clear(); + } } ChangeSplit(FOR, TopAbs_IN).Append(spFORcopy); // keep split for reference } // issplitIN @@ -539,12 +588,14 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& TopOpeBRepDS_SAMEORIENTED, TopOpeBRepDS_DIFFORIENTED); if (hsd) + { FUN_getAncestorFsp((*this), myShapeClassifier, LF1, LF2, FOR, GLOBAL_SplitAnc); // xpu280598 + } GSplitFaceSFS(FOR, LSO2, GM, SFS); GLOBAL_revownsplfacori = false; } @@ -586,7 +637,9 @@ void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& fufa.PerformFace(); bool isdone = fufa.IsDone(); if (!isdone) + { return; + } #ifdef OCCT_DEBUG // bool ismodified = fufa.IsModified(); #endif diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffwesk.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffwesk.cxx index 451c7cd4d8..ea555aaef6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffwesk.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_ffwesk.cxx @@ -51,7 +51,9 @@ void TopOpeBRepBuild_Builder::GFillFacesWESK(const NCollection_ListShape(S); bool tomerge = !IsMerged(S, TB); if (!tomerge) + { continue; + } // lors de l'insertion des composantes (edges splitees) de S dans le WES : // - faces de meme orientation geometrique : @@ -140,7 +144,9 @@ void TopOpeBRepBuild_Builder::GFillFacesWESK(const NCollection_ListShape(S); bool tomerge = !IsMerged(S, TB); if (!tomerge) + { continue; + } // Modified by Sergey KHROMOV - Sat Apr 27 14:38:33 2002 Begin // const TopoDS_Shape& Fref = WES.Face(); @@ -220,7 +228,9 @@ void TopOpeBRepBuild_Builder::GFillFacesWESK(const NCollection_List*)&itm1.Value(); + } if (pfOU == nullptr) + { pfOU = &itm1.Key(); + } if (pfIN == nullptr) + { pfIN = &plfIN->First(); + } for (NCollection_List::Iterator it(los); it.More(); it.Next()) + { LFIN.Append(it.Value()); + } } } if (plfIN == nullptr) + { return; + } if (pfOU == nullptr) + { return; + } if (pfIN == nullptr) + { return; + } #ifdef OCCT_DEBUG int ifOU; @@ -163,22 +181,34 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() int rankpfOU = GShapeRank(*pfOU); int rankpfIN = GShapeRank(*pfIN); if (rankpfOU != 1 && rankpfOU != 2) + { return; + } if (rankpfIN != 1 && rankpfIN != 2) + { return; + } // solfOU = solide dont la face *pfOU est OUT / faces LFIN // solfIN = solide dont les faces *plfIN sont IN / face *pfOU TopoDS_Shape solfOU; if (rankpfOU == 1) + { solfOU = sol1; + } else + { solfOU = sol2; + } TopoDS_Shape solfIN; if (rankpfIN == 1) + { solfIN = sol1; + } else + { solfIN = sol2; + } TopAbs_State stsolfOU = KPclasSS(solfOU, *pfOU, solfIN); TopAbs_State stsolfIN = KPclasSS(solfIN, LFIN, solfOU); TopAbs_State stfOU = TopAbs_OUT; @@ -209,9 +239,13 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() int ires, icla1, icla2; KPiskoleanalyse(stfac1, stfac2, stsol1, stsol2, ires, icla1, icla2); if (ires == RESUNDEF) + { return; + } if (icla1 == SHEUNDEF || icla2 == SHEUNDEF) + { return; + } TopoDS_Shape she1; // she1 = shell accedant fac1 NCollection_IndexedDataMap, TopTools_ShapeMapHasher> @@ -306,7 +340,9 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() itm1.Initialize(myKPMAPf1f2); if (!itm1.More()) + { return; + } NCollection_DataMap addedfaces; for (; itm1.More(); itm1.Next()) @@ -315,7 +351,9 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() const TopoDS_Shape& f1 = itm1.Key(); const NCollection_List& lf2 = itm1.Value(); if (lf2.IsEmpty()) + { continue; + } NCollection_List::Iterator it2; it2.Initialize(lf2); @@ -328,37 +366,57 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() int rankf1 = GShapeRank(f1); int rankf2 = GShapeRank(f2); if (rankf1 == 0) + { continue; + } if (rankf2 == 0) + { continue; + } TopAbs_State stf1, stf2; KPclassFF(f1, f2, stf1, stf2); if (rankf1 == 1) + { KPiskoleanalyse(stf1, stf2, stsol1, stsol2, ires, ibid, ibid); + } if (rankf1 == 2) + { KPiskoleanalyse(stf2, stf1, stsol2, stsol1, ires, ibid, ibid); + } if (ires == RESUNDEF) + { continue; + } bool r1 = (stsol1 == TopAbs_IN); bool r2 = (stsol2 == TopAbs_IN); TopoDS_Shape fac; if (rankf1 == 1) + { fac = KPmakeface(f1, lf2, stf1, stf2, r1, r2); + } if (rankf1 == 2) + { fac = KPmakeface(f1, lf2, stf1, stf2, r2, r1); + } if (fac.IsNull()) + { continue; + } if (!fac.IsNull()) + { addedfaces.Bind(fac, fac); + } TopAbs_State statemergef1 = (rankf1 == 1) ? myState1 : myState2; TopAbs_State statemergef2 = (rankf2 == 2) ? myState2 : myState1; ChangeMerged(f1, statemergef1).Append(fac); it2.Initialize(lf2); for (; it2.More(); it2.Next()) + { ChangeMerged(it2.Value(), statemergef2).Append(fac); + } // les faces de she1 sauf les tangentes et celles deja ajoutees TopOpeBRepTool_ShapeExplorer fex1; @@ -374,7 +432,9 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() { TopoDS_Shape fori = facur; if (stsol1 == TopAbs_IN) + { fori.Complement(); + } addedfaces.Bind(fori, fori); } } @@ -393,7 +453,9 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() { TopoDS_Shape fori = facur; if (stsol2 == TopAbs_IN) + { fori.Complement(); + } addedfaces.Bind(fori, fori); } } @@ -438,12 +500,16 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() { const TopoDS_Shape& shecur = ex1.Current(); if (she1.IsEqual(shecur)) + { continue; + } if (icla1 == SHECLASAUTR) { TopAbs_State state1 = KPclasSS(shecur, fac1, sol2); if (state1 == myState1) + { loshe1.Append(shecur); + } } else if (icla1 == SHEGARDAUTR) { @@ -470,12 +536,16 @@ void TopOpeBRepBuild_Builder::MergeKPartiskole() { const TopoDS_Shape& shecur = ex2.Current(); if (she2.IsEqual(shecur)) + { continue; + } if (icla2 == SHECLASAUTR) { TopAbs_State state2 = KPclasSS(shecur, fac2, sol1); if (state2 == myState2) + { loshe2.Append(shecur); + } } else if (icla2 == SHEGARDAUTR) { @@ -511,17 +581,25 @@ int TopOpeBRepBuild_Builder::KPiskole() bool iskp1 = KPiskolesh(myShape1, lShsd1, lfhsd1); if (!iskp1) + { return 0; + } int nfhsd1 = lfhsd1.Extent(); if (nfhsd1 == 0) + { return 0; + } bool iskp2 = KPiskolesh(myShape2, lShsd2, lfhsd2); if (!iskp2) + { return 0; + } int nfhsd2 = lfhsd2.Extent(); if (nfhsd2 == 0) + { return 0; + } // Si l'un des objets est constitue de plusieur solides on passe // dans le cas general , sinon on obtient @@ -532,7 +610,9 @@ int TopOpeBRepBuild_Builder::KPiskole() int nshsd1 = lShsd1.Extent(); int nshsd2 = lShsd2.Extent(); if (nshsd1 > 1 || nshsd2 > 1) + { return 0; + } NCollection_List lf1, lf2; NCollection_List les; // section @@ -574,7 +654,9 @@ int TopOpeBRepBuild_Builder::KPiskole() TopAbs_State state1, state2; bool classok = KPiskoleFF(f1, f2, state1, state2); if (!classok) + { return 0; + } // on va reconstuire la face OUT if (state1 == TopAbs_OUT && state2 == TopAbs_IN) @@ -617,15 +699,23 @@ int TopOpeBRepBuild_Builder::KPiskole() // les aretes de la face IN sont des aretes de section TopoDS_Shape fw; if (state1 == TopAbs_IN) + { fw = f1; + } else if (state2 == TopAbs_IN) + { fw = f2; + } if (fw.IsNull()) + { continue; + } TopOpeBRepTool_ShapeExplorer ex(fw, TopAbs_EDGE); for (; ex.More(); ex.Next()) + { les.Append(ex.Current()); + } } } @@ -634,7 +724,9 @@ int TopOpeBRepBuild_Builder::KPiskole() DS.InitSectionEdges(); NCollection_List::Iterator it(les); for (; it.More(); it.Next()) + { DS.AddSectionEdge(TopoDS::Edge(it.Value())); + } return 1; } // TopOpeBRepBuild_Builder::KPiskole @@ -816,7 +908,9 @@ Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& wicur = wex1.Current(); TopoDS_Wire wori = TopoDS::Wire(wicur); if (R1) + { wori.Complement(); + } wtof.AddWire(wori); // myBuildTool.AddFaceWire(fac,wori); } @@ -830,7 +924,9 @@ Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& wicur = wex2.Current(); TopoDS_Wire wori = TopoDS::Wire(wicur); if (R2) + { wori.Complement(); + } wtof.AddWire(wori); // myBuildTool.AddFaceWire(fac,wori); } @@ -842,7 +938,6 @@ Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, // int nlres = Lres.Extent(); // DEB #endif - return; } // FUNKP_KPmakefaces //================================================================================================= @@ -910,7 +1005,9 @@ TopoDS_Shape TopOpeBRepBuild_Builder::KPmakeface(const TopoDS_Shape& const TopoDS_Shape& wicur = wex1.Current(); TopoDS_Shape wori = wicur; if (R1) + { wori.Complement(); + } myBuildTool.AddFaceWire(fac, wori); } @@ -923,7 +1020,9 @@ TopoDS_Shape TopOpeBRepBuild_Builder::KPmakeface(const TopoDS_Shape& const TopoDS_Shape& wicur = wex2.Current(); TopoDS_Shape wori = wicur; if (R2) + { wori.Complement(); + } myBuildTool.AddFaceWire(fac, wori); } } @@ -941,11 +1040,15 @@ Standard_EXPORT bool FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU, // : the list of 's same domain faces, none of the list carries geometric interf { if (Sarg.IsNull()) + { return false; + } int nsol = BU.KPlhsd(Sarg, TopAbs_SOLID, lShsd); if (nsol == 0) + { return false; + } const TopoDS_Shape& sol = lShsd.First(); NCollection_List lfhg; @@ -989,7 +1092,9 @@ bool TopOpeBRepBuild_Builder::KPiskolesh(const TopoDS_Shape& Sarg, const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); bool iskolesh = FUNKP_KPiskolesh(*this, BDS, Sarg, lShsd, lfhsd); if (!iskolesh) + { return false; + } #ifdef OCCT_DEBUG int nfhsd = @@ -1001,16 +1106,22 @@ bool TopOpeBRepBuild_Builder::KPiskolesh(const TopoDS_Shape& Sarg, const TopoDS_Shape& fac = it.Value(); bool isplan = FUN_tool_plane(fac); // pro7993 BUG if (!isplan) + { return false; + } int nw = KPls(fac, TopAbs_WIRE); if (nw > 1) + { return false; + } NCollection_List lehg; int nehg = KPlhg(fac, TopAbs_EDGE, lehg); if (nehg != 0) + { return false; + } #ifdef OCCT_DEBUG int isol = myDataStructure->Shape(Sarg); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makeedges.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makeedges.cxx index 0f543a1134..9b97bb8140 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makeedges.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makeedges.cxx @@ -52,7 +52,9 @@ void TopOpeBRepBuild_Builder::GPVSMakeEdges(const TopoDS_Shape& EF, TopOpeBRepBuild_PaveClassifier VCL(EF); bool equalpar = PVS.HasEqualParameters(); if (equalpar) + { VCL.SetFirstParameter(PVS.EqualParameters()); + } PVS.InitLoop(); bool novertex = (!PVS.MoreLoop()); @@ -61,7 +63,9 @@ void TopOpeBRepBuild_Builder::GPVSMakeEdges(const TopoDS_Shape& EF, std::cout << "#--- GPVSMakeEdges : no vertex from edge " << iE << std::endl; #endif if (novertex) + { return; + } TopOpeBRepBuild_EdgeBuilder EDBU; bool ForceClass = false; @@ -102,10 +106,14 @@ void TopOpeBRepBuild_Builder::GEDBUMakeEdges(const TopoDS_Shape& EF, int nloop = 0; bool tosplit = false; for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) + { nloop++; + } // 0 ou 1 vertex sur edge courante => suppression edge if (nloop <= 1) + { continue; + } myBuildTool.CopyEdge(EF, newEdge); @@ -130,7 +138,9 @@ void TopOpeBRepBuild_Builder::GEDBUMakeEdges(const TopoDS_Shape& EF, TopAbs_Orientation oriV = V.Orientation(); if (oriV == TopAbs_EXTERNAL) + { continue; + } bool equafound = false; TopExp_Explorer exE(newEdge, TopAbs_VERTEX); @@ -169,16 +179,22 @@ void TopOpeBRepBuild_Builder::GEDBUMakeEdges(const TopoDS_Shape& EF, { nVF++; if (nVF == 1) + { VF = V; + } } if (Vori == TopAbs_REVERSED) { nVR++; if (nVR == 1) + { VR = V; + } } if (oriV == TopAbs_INTERNAL) + { tosplit = true; + } double parV = EDBU.Parameter(); myBuildTool.AddEdgeVertex(newEdge, V); myBuildTool.Parameter(newEdge, V, parV); @@ -194,12 +210,18 @@ void TopOpeBRepBuild_Builder::GEDBUMakeEdges(const TopoDS_Shape& EF, NCollection_List loe; bool ok = TopOpeBRepTool_TOOL::SplitE(TopoDS::Edge(newEdge), loe); if (!ok) + { tosplit = false; + } else + { LOE.Append(loe); + } } if (!tosplit) + { LOE.Append(newEdge); + } } } // EDBU.InitEdge : loop on EDBU edges diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makefaces.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makefaces.cxx index 065ea53254..4da5aa8d5e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makefaces.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makefaces.cxx @@ -148,9 +148,13 @@ void TopOpeBRepBuild_Builder::GWESMakeFaces(const TopoDS_Shape& FF, bool otherRef = (rankVsameG != 0 && rankV != 1); if (otherRef) + { BDS.FillShapesSameDomain(VsameG, V); + } else + { BDS.FillShapesSameDomain(V, VsameG); + } hsdm = myDataStructure->HasSameDomain(V); } @@ -180,7 +184,9 @@ void TopOpeBRepBuild_Builder::GWESMakeFaces(const TopoDS_Shape& FF, const TopoDS_Face& FA = TopoDS::Face(FF); bool puok = TopOpeBRepTool::PurgeClosingEdges(FA, LOF, MWisOld, MshNOK); if (!puok) + { throw Standard_Failure("TopOpeBRepBuild::GWESMakeFaces"); + } topurge = !MshNOK.IsEmpty(); #ifdef OCCT_DEBUG @@ -194,7 +200,9 @@ void TopOpeBRepBuild_Builder::GWESMakeFaces(const TopoDS_Shape& FF, NCollection_List LOFF; bool puok = TopOpeBRepTool::MakeFaces(TopoDS::Face(FF), LOF, MshNOK, LOFF); if (!puok) + { throw Standard_Failure("TopOpeBRepBuild::GWESMakeFaces"); + } LOF.Clear(); LOF.Assign(LOFF); } @@ -242,7 +250,9 @@ static bool FUN_purgeFon1nonoriE(const TopoDS_Shape& newFace) TopExp_Explorer ex(newFace, TopAbs_EDGE); int nE = 0; for (; ex.More(); ex.Next()) + { nE++; + } if (nE == 1) { ex.Init(newFace, TopAbs_EDGE); @@ -250,11 +260,15 @@ static bool FUN_purgeFon1nonoriE(const TopoDS_Shape& newFace) TopAbs_Orientation ori = ed.Orientation(); bool hasori = (ori == TopAbs_FORWARD) || (ori == TopAbs_REVERSED); if (!hasori) + { return true; + } //// modified by jgv, 6.06.02 for OCC424 //// TopoDS_Edge theEdge = TopoDS::Edge(ed); if (BRep_Tool::Degenerated(theEdge)) + { return true; + } ///////////////////////////////////////////// } return false; @@ -280,24 +294,40 @@ static TopAbs_Orientation FUN_ReOrientIntExtEdge(const TopoDS_Edge& FRE, if (OFRE == TopAbs_FORWARD) { if (Vl1.IsSame(Vf2)) + { result = TopAbs_FORWARD; + } if (Vl1.IsSame(Vl2)) + { result = TopAbs_REVERSED; + } if (Vf1.IsSame(Vf2)) + { result = TopAbs_REVERSED; + } if (Vf1.IsSame(Vl2)) + { result = TopAbs_FORWARD; + } } if (OFRE == TopAbs_REVERSED) { if (Vl1.IsSame(Vf2)) + { result = TopAbs_REVERSED; + } if (Vl1.IsSame(Vl2)) + { result = TopAbs_FORWARD; + } if (Vf1.IsSame(Vf2)) + { result = TopAbs_FORWARD; + } if (Vf1.IsSame(Vl2)) + { result = TopAbs_REVERSED; + } } return result; } @@ -309,15 +339,23 @@ static int FUN_CheckORI(TopAbs_Orientation O1, TopAbs_Orientation O2) int result; if ((O1 == TopAbs_INTERNAL || O1 == TopAbs_EXTERNAL) && (O2 == TopAbs_INTERNAL || O2 == TopAbs_EXTERNAL)) + { result = 0; + } else if ((O1 == TopAbs_INTERNAL || O1 == TopAbs_EXTERNAL) && (O2 == TopAbs_FORWARD || O2 == TopAbs_REVERSED)) + { result = 1; + } else if ((O1 == TopAbs_FORWARD || O1 == TopAbs_REVERSED) && (O2 == TopAbs_INTERNAL || O2 == TopAbs_EXTERNAL)) + { result = 2; + } else + { result = 4; + } return result; } @@ -415,9 +453,13 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( TopAbs_Orientation oE = newEdge.Orientation(); if (oE == TopAbs_INTERNAL) + { neINTERNAL++; + } else if (oE == TopAbs_EXTERNAL) + { neEXTERNAL++; + } // clang-format off bool hasPC = FC2D_HasCurveOnSurface(newEdge,newFace); // jyl980402+ @@ -427,7 +469,8 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( double f2,l2,tolpc; occ::handle C2D; // jyl980402+ //C2D = FC2D_CurveOnSurface(newEdge,newFace,f2,l2,tolpc); // jyl980402+ C2D = FC2D_CurveOnSurface(newEdge,newFace,f2,l2,tolpc, true); // xpu051198 (CTS21701) - if(C2D.IsNull()) throw Standard_ProgramError("TopOpeBRepBuild_Builder::GFABUMakeFaces null PC"); // jyl980402+ + if(C2D.IsNull()) { throw Standard_ProgramError("TopOpeBRepBuild_Builder::GFABUMakeFaces null PC"); // jyl980402+ +} double tol = std::max(tolE,tolpc); // jyl980402+ BRep_Builder BB_PC; BB_PC.UpdateEdge(newEdge,C2D,newFace,tol); // jyl980402+ } // jyl980402+ @@ -445,7 +488,9 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( EdgeEx.Next(); TopoDS_Edge nEdge2 = TopoDS::Edge(EdgeEx.Current()); if (nEdge1.IsSame(nEdge2)) + { return; + } } for (EdgeEx.Init(CmpOfEdges, TopAbs_EDGE); EdgeEx.More(); EdgeEx.Next()) { @@ -541,9 +586,13 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( if (ori == TopAbs_REVERSED || ori == TopAbs_FORWARD) { if (O1 == TopAbs_INTERNAL) + { neINTERNAL--; + } else + { neEXTERNAL--; + } } } if (chkORI == 2) @@ -560,9 +609,13 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( if (ori == TopAbs_REVERSED || ori == TopAbs_FORWARD) { if (O2 == TopAbs_INTERNAL) + { neINTERNAL--; + } else + { neEXTERNAL--; + } } } @@ -570,17 +623,25 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( { FABU.AddEdgeWire(E1, newWire); if (!IsSameE1) + { LofAddE.Append(E1); + } else + { naddsame++; + } } if (AddE2) { FABU.AddEdgeWire(E2, newWire); if (!IsSameE2) + { LofAddE.Append(E2); + } else + { naddsame++; + } } } // for StepMap } // while ne > @@ -605,11 +666,17 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( if (!isold) { if (ne == 0) + { continue; + } else if (nbw == 1 && (ne == neINTERNAL + neEXTERNAL)) + { continue; + } else + { nbnewWwithe++; + } } // caractere Closed() du nouveau wire newWire @@ -648,13 +715,21 @@ void TopOpeBRepBuild_Builder::GFABUMakeFaces( double umin, umax, vmin, vmax; BRepTools::UVBounds(newFace, umin, umax, vmin, vmax); if (umin < oumin) + { oumin = umin; + } if (umax > oumax) + { oumax = umax; + } if (vmin < ovmin) + { ovmin = vmin; + } if (vmax > ovmax) + { ovmax = vmax; + } hrts->SetTrim(oumin, oumax, ovmin, ovmax, true, true); } lnewFace.Append(newFace); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makesolids.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makesolids.cxx index abcb1cf0c2..568acd382a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makesolids.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_makesolids.cxx @@ -88,7 +88,9 @@ void TopOpeBRepBuild_Builder::GSOBUMakeSolids(const TopoDS_Shape& SO { bool isold = SOBU.IsOldShell(); if (isold) + { newShell = SOBU.OldShell(); + } else { myBuildTool.MakeShell(newShell); @@ -115,11 +117,15 @@ void TopOpeBRepBuild_Builder::GSOBUMakeSolids(const TopoDS_Shape& SO const TopoDS_Shape& E = edgemap.FindKey(iedge); TopAbs_Orientation oE = E.Orientation(); if (oE == TopAbs_INTERNAL || oE == TopAbs_EXTERNAL) + { continue; + } const TopoDS_Edge& EE = TopoDS::Edge(E); bool degen = BRep_Tool::Degenerated(EE); if (degen) + { continue; + } int nbf = edgemap(iedge).Extent(); if (nbf < 2) { @@ -156,7 +162,9 @@ void TopOpeBRepBuild_Builder::GSOBUMakeSolids(const TopoDS_Shape& SO } newSolidOK = hasnondegenerated; if (!newSolidOK) + { continue; + } } NCollection_List newSolidLOS; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_on.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_on.cxx index a94df81101..b1f663d0e7 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_on.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_on.cxx @@ -32,15 +32,19 @@ void TopOpeBRepBuild_Builder::GFillONPartsWES(const TopoDS_Shape& { TopOpeBRepBuild_BuilderON BON; if (GLOBAL_faces2d) + { BON.Perform2d(this, FOR, (TopOpeBRepBuild_PGTopo)&G, (TopOpeBRepTool_Plos)&LSclass, (TopOpeBRepBuild_PWireEdgeSet)&WES); + } else + { BON.Perform(this, FOR, (TopOpeBRepBuild_PGTopo)&G, (TopOpeBRepTool_Plos)&LSclass, (TopOpeBRepBuild_PWireEdgeSet)&WES); + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS.cxx index 46292cdb8d..fc89d1c83f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS.cxx @@ -103,7 +103,9 @@ TCollection_AsciiString TopOpeBRepDS::SPrint(const TopOpeBRepDS_Kind k, { TCollection_AsciiString si = ""; if (i >= 0 && i <= 9) + { si = " "; + } TCollection_AsciiString s = S1 + "(" + TopOpeBRepDS::SPrint(k) + "," + si + TCollection_AsciiString(i) + ")" + S2; return s; @@ -279,7 +281,9 @@ TopAbs_ShapeEnum TopOpeBRepDS::KindToShape(const TopOpeBRepDS_Kind K) { TopAbs_ShapeEnum res = TopAbs_SHAPE; // bidon if (!TopOpeBRepDS::IsTopology(K)) + { return res; + } switch (K) { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Association.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Association.cxx index 7b7fe23876..dd2c000dc9 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Association.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Association.cxx @@ -28,7 +28,9 @@ static bool Contains(const NCollection_ListHasSameGeometry(it.Value())) + { return true; + } } return false; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx index 2b9901247d..809e12c5d1 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx @@ -62,7 +62,9 @@ Standard_EXPORT occ::handle BASISCURVE2D(const occ::handle& PC) { if (PC.IsNull()) + { return false; + } occ::handle SSS = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); occ::handle LLL = ::BASISCURVE2D(PC); @@ -322,9 +324,13 @@ void TopOpeBRepDS_BuildTool::GetOrientedEdgeVertices(TopoDS_Edge& E, double& Parmax) const { if (E.Orientation() == TopAbs_FORWARD) + { TopExp::Vertices(E, Vmin, Vmax); + } else + { TopExp::Vertices(E, Vmax, Vmin); + } if (!Vmin.IsNull() && !Vmax.IsNull()) { Parmin = BRep_Tool::Parameter(Vmin, E); @@ -352,7 +358,9 @@ void TopOpeBRepDS_BuildTool::UpdateEdgeCurveTol { if (C3Dnew.IsNull()) + { return; + } BRep_Builder BB; // newtol = max des tolerances atteintes en 3d @@ -385,10 +393,14 @@ void TopOpeBRepDS_BuildTool::UpdateEdgeCurveTol double tolmin = BRep_Tool::Tolerance(Vmin); if (newtol > tolmin) + { tolmin = newtol; + } double tolmax = BRep_Tool::Tolerance(Vmax); if (newtol > tolmax) + { tolmax = newtol; + } // newparmin=C3Dnew->FirstParameter(); // -merge 04-07-97 // newparmax=C3Dnew->LastParameter(); // -merge 04-07-97 @@ -436,7 +448,9 @@ void TopOpeBRepDS_BuildTool::UpdateEdgeCurveTol { const TopoDS_Vertex& vi = TopoDS::Vertex(exi.Current()); if (vi.Orientation() != TopAbs_INTERNAL) + { continue; + } gp_Pnt P = BRep_Tool::Pnt(vi); double tolvi = TopOpeBRepTool_ShapeTool::Tolerance(vi); GeomAPI_ProjectPointOnCurve dm(P, C3Dnew, newparmin, newparmax); @@ -529,9 +543,13 @@ void TopOpeBRepDS_BuildTool::ApproxCurves(const TopOpeBRepDS_Curve& } if (!PC1new.IsNull()) + { newC.Curve1(PC1new); + } if (!PC2new.IsNull()) + { newC.Curve2(PC2new); + } } //================================================================================================= @@ -546,7 +564,9 @@ bool FUN_getUV(const occ::handle& surf, C3D->D0(par3d, P3d); GeomAPI_ProjectPointOnSurf pons(P3d, surf); if (pons.NbPoints() < 1) + { return false; + } pons.LowerDistanceParameters(u0, v0); return true; } @@ -595,19 +615,29 @@ bool FUN_makeUisoLineOnSphe(const TopoDS_Face& F, // with geometry t double uinf, vinf, usup, vsup; occ::handle surf = BRep_Tool::Surface(F); if (!FUN_getUV(surf, C3D, par3dinf, uinf, vinf)) + { return false; + } if (!FUN_getUV(surf, C3D, par3dsup, usup, vsup)) + { return false; + } double tol = Precision::Parametric(tol3d); if (std::abs(uinf - usup) > tol) + { return false; + } bool isvgrowing = (vsup - vinf > -tol); gp_Dir2d vdir; if (isvgrowing) + { vdir = gp_Dir2d(gp_Dir2d::D::Y); + } else + { vdir = gp_Dir2d(gp_Dir2d::D::NY); + } gp_Pnt2d origin(uinf, vinf); origin.Translate(gp_Vec2d(vdir).Scaled(p3df - par3dinf)); @@ -645,9 +675,13 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, double tolreached2d1 = Precision::Confusion(), tolreached2d2 = Precision::Confusion(), tol = Precision::Confusion(); if (comppc1) + { PC1new = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F1, C3D, tolreached2d1); + } if (comppc2) + { PC2new = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F2, C3D, tolreached2d2); + } double r1 = TopOpeBRepTool_ShapeTool::Resolution3d(F1, tolreached2d1); double r2 = TopOpeBRepTool_ShapeTool::Resolution3d(F2, tolreached2d2); @@ -656,9 +690,13 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, newC.Tolerance(tol); if (!PC1new.IsNull()) + { newC.Curve1(PC1new); + } if (!PC2new.IsNull()) + { newC.Curve2(PC2new); + } return; } @@ -684,7 +722,9 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, parmax = l; ElCLib::AdjustPeriodic(f, f + period, Precision::PConfusion(), parmin, parmax); if (compc3d) + { C3Dnew = new Geom_TrimmedCurve(C3D, parmin, parmax); + } } double tolreached3d = C.Tolerance(); @@ -692,9 +732,13 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, double tolreached2d2 = C.Tolerance(); if (comppc1) + { PC1new = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F1, C3Dnew, tolreached2d1); + } if (comppc2) + { PC2new = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F2, C3Dnew, tolreached2d2); + } double newtol, newparmin, newparmax; UpdateEdgeCurveTol(F1, @@ -716,12 +760,16 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, bool UisoLineOnSphe1 = false; UisoLineOnSphe1 = ::FUN_UisoLineOnSphe(F1, PC1new); if (UisoLineOnSphe1) + { ::FUN_makeUisoLineOnSphe(F1, C3Dnew, PC1new, newtol); + } bool UisoLineOnSphe2 = false; UisoLineOnSphe2 = ::FUN_UisoLineOnSphe(F2, PC2new); if (UisoLineOnSphe2) + { ::FUN_makeUisoLineOnSphe(F2, C3Dnew, PC2new, newtol); + } // xpu : 17-06-97 // xpu : suite merge : 07-07-97 @@ -731,9 +779,13 @@ void TopOpeBRepDS_BuildTool::ComputePCurves(const TopOpeBRepDS_Curve& C, newC.SetRange(newparmin, newparmax); } if (!PC1new.IsNull()) + { newC.Curve1(PC1new); + } if (!PC2new.IsNull()) + { newC.Curve2(PC2new); + } } //================================================================================================= @@ -779,20 +831,30 @@ void TopOpeBRepDS_BuildTool::RecomputeCurves( const occ::handle& C3D = C.Curve(); if (comppc1 && C.Shape1().IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 2"); + } if (comppc2 && C.Shape2().IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 3"); + } TopoDS_Vertex Vmin, Vmax; TopExp::Vertices(E, Vmin, Vmax); if (Vmin.IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 4"); + } if (Vmax.IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 5"); + } if (iswalk && approx) { if (compc3d && C3D.IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 1"); + } ApproxCurves(C, E, inewC, HDS); TopOpeBRepDS_Curve& newC = HDS->ChangeCurve(inewC); PutPCurves(newC, E, comppc1, comppc2); @@ -813,12 +875,16 @@ void TopOpeBRepDS_BuildTool::RecomputeCurves( if (iswalk && !approx) { if (compc3d && C3D.IsNull()) + { throw Standard_ProgramError("TopOpeBRepDS_BuildTool::RecomputeCurve 1"); + } newC.Curve1(C.Curve1()); newC.Curve2(C.Curve2()); } else + { ComputePCurves(C, E, newC, comppc1, comppc2, compc3d); + } PutPCurves(newC, E, comppc1, comppc2); } } @@ -945,7 +1011,9 @@ void TopOpeBRepDS_BuildTool::UpdateEdge(const TopoDS_Shape& Ein, TopoDS_Shape& E occ::handle Cin = BRep_Tool::Curve(TopoDS::Edge(Ein), loc, f1, l1); occ::handle Cou = BRep_Tool::Curve(TopoDS::Edge(Eou), loc, f2, l2); if (Cin.IsNull() || Cou.IsNull()) + { return; + } if (Cou->IsPeriodic()) { @@ -1021,7 +1089,9 @@ void TopOpeBRepDS_BuildTool::TranslateOnPeriodic(TopoDS_Shape& F, if (C3D->IsPeriodic()) { if (last < first) + { last += std::abs(first - last); + } } // jyl-xpu : 13-06-97 : @@ -1049,13 +1119,19 @@ void TopOpeBRepDS_BuildTool::TranslateOnPeriodic(TopoDS_Shape& F, occ::handle surf = BRep_Tool::Surface(TopoDS::Face(F)); GeomAPI_ProjectPointOnSurf pons(p3dtest, surf); if (!(pons.NbPoints() < 1)) + { pons.LowerDistanceParameters(u2, v2); + } } else + { TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(F, u2, v2); + } } if (!newv) + { TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(F, u2, v2); + } du = u2 - u1, dv = v2 - v1; if (du != 0. || dv != 0.) @@ -1082,19 +1158,27 @@ Standard_EXPORT void TopOpeBRepDS_SetThePCurve(const BRep_Builder& TopLoc_Location SL; occ::handle GP = occ::down_cast(BRep_Tool::Surface(F, SL)); if (GP.IsNull()) + { OC = BRep_Tool::CurveOnSurface(E, F, f, l); + } if (OC.IsNull()) + { B.UpdateEdge(E, C, F, Precision::Confusion()); + } else { bool degen = BRep_Tool::Degenerated(E); if (!degen) { if (O == TopAbs_REVERSED) + { B.UpdateEdge(E, OC, C, F, Precision::Confusion()); + } else + { B.UpdateEdge(E, C, OC, F, Precision::Confusion()); + } } } } @@ -1122,12 +1206,18 @@ void TopOpeBRepDS_BuildTool::PCurve(TopoDS_Shape& F, // xpu : 13-06-97 if (tran) + { TranslateOnPeriodic(F, E, PCT); + } if (overwrite) + { myBuilder.UpdateEdge(EE, PCT, FF, 0); + } else + { TopOpeBRepDS_SetThePCurve(myBuilder, EE, FF, E.Orientation(), PCT); + } // parametrage sur la nouvelle courbe 2d TopExp_Explorer exi(E, TopAbs_VERTEX); @@ -1135,7 +1225,9 @@ void TopOpeBRepDS_BuildTool::PCurve(TopoDS_Shape& F, { const TopoDS_Vertex& vi = TopoDS::Vertex(exi.Current()); if (vi.Orientation() != TopAbs_INTERNAL) + { continue; + } double tolvi = TopOpeBRepTool_ShapeTool::Tolerance(vi); // NYI tester l'existence d'au moins // NYI un parametrage de vi sur EE (en 3d ou en 2d) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Check.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Check.cxx index a668bbe9f6..d5d17262f8 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Check.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Check.cxx @@ -133,37 +133,49 @@ bool TopOpeBRepDS_Check::CheckDS(const int I, const TopOpeBRepDS_Kind K) if (myHDS->NbSurfaces() < I) { if (myMapSurfaceStatus.IsBound(I)) + { myMapSurfaceStatus.UnBind(I); + } myMapSurfaceStatus.Bind(I, TopOpeBRepDS_NOK); return false; } if (!myMapSurfaceStatus.IsBound(I)) + { myMapSurfaceStatus.Bind(I, TopOpeBRepDS_OK); + } return true; } case TopOpeBRepDS_CURVE: { if (myHDS->NbCurves() < I) { if (myMapCurveStatus.IsBound(I)) + { myMapCurveStatus.UnBind(I); + } myMapCurveStatus.Bind(I, TopOpeBRepDS_NOK); return false; } if (!myMapCurveStatus.IsBound(I)) + { myMapCurveStatus.Bind(I, TopOpeBRepDS_OK); + } return true; } case TopOpeBRepDS_POINT: { if (myHDS->NbPoints() < I) { if (myMapPointStatus.IsBound(I)) + { myMapPointStatus.UnBind(I); + } myMapPointStatus.Bind(I, TopOpeBRepDS_NOK); return false; } if (!myMapPointStatus.IsBound(I)) + { myMapPointStatus.Bind(I, TopOpeBRepDS_OK); + } return true; } default: @@ -174,7 +186,9 @@ bool TopOpeBRepDS_Check::CheckDS(const int I, const TopOpeBRepDS_Kind K) if (myHDS->NbShapes() < I) { if (myMapShapeStatus.IsBound(I)) + { myMapShapeStatus.UnBind(I); + } myMapShapeStatus.Bind(I, TopOpeBRepDS_NOK); return false; } @@ -208,12 +222,16 @@ bool TopOpeBRepDS_Check::CheckDS(const int I, const TopOpeBRepDS_Kind K) if (S.ShapeType() != se) { if (myMapShapeStatus.IsBound(I)) + { myMapShapeStatus.UnBind(I); + } myMapShapeStatus.Bind(I, TopOpeBRepDS_NOK); return false; } if (!myMapShapeStatus.IsBound(I)) + { myMapShapeStatus.Bind(I, TopOpeBRepDS_OK); + } return true; } @@ -290,7 +308,9 @@ bool TopOpeBRepDS_Check::CheckShapes(const NCollection_List& LS) c const TopoDS_Shape& itS = it.Value(); index = myHDS->Shape(itS); if (!index) + { return false; + } it.Next(); } return true; @@ -313,7 +333,9 @@ bool TopOpeBRepDS_Check::OneVertexOnPnt() { const TopoDS_Shape& S = myHDS->Shape(i); if ((S.ShapeType() == TopAbs_VERTEX) && myHDS->HasShape(S)) + { vert.Add(i); + } } NbVe = vert.Extent(); for (i = 1; i <= NbVe; i++) @@ -437,8 +459,8 @@ bool CheckEdgeParameter(const occ::handle& myHDS) Standard_OStream& TopOpeBRepDS_Check::PrintIntg(Standard_OStream& OS) { - OS << std::endl << std::endl << "************************************************" << std::endl; - OS << "state of the DS : (only the tested elements)" << std::endl << std::endl; + OS << '\n' << '\n' << "************************************************" << '\n'; + OS << "state of the DS : (only the tested elements)" << '\n' << '\n'; // Display of the geometry PrintMap(myMapSurfaceStatus, "Surface", OS); @@ -483,7 +505,7 @@ Standard_OStream& TopOpeBRepDS_Check::PrintIntg(Standard_OStream& OS) PrintMap(MapFace, "Face", OS); PrintMap(MapSolid, "Solid", OS); - OS << std::endl << std::endl; + OS << '\n' << '\n'; return OS; } @@ -503,10 +525,14 @@ Standard_OStream& TopOpeBRepDS_Check::PrintMap( PrintElts(MapStat, TopOpeBRepDS_OK, b, OS); if (!b) - OS << " = OK" << std::endl; + { + OS << " = OK" << '\n'; + } PrintElts(MapStat, TopOpeBRepDS_NOK, b, OS); if (!b) - OS << " = NOK" << std::endl; + { + OS << " = NOK" << '\n'; + } } return OS; } @@ -533,7 +559,9 @@ Standard_OStream& TopOpeBRepDS_Check::PrintElts( if (s == Stat) { if (b) + { b = !b; + } if (bb) { OS << "\t\tnumber "; @@ -605,7 +633,7 @@ Standard_OStream& TopOpeBRepDS_Check::PrintShape(const int index, Standard_OStre } if (!myMapShapeStatus.IsBound(index)) { - OS << "NO CHECK HAS PROCESSING" << std::endl; + OS << "NO CHECK HAS PROCESSING" << '\n'; return OS; } OS << " "; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_CurveExplorer.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_CurveExplorer.cxx index 343b50b755..991242558c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_CurveExplorer.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_CurveExplorer.cxx @@ -67,9 +67,13 @@ void TopOpeBRepDS_CurveExplorer::Find() myFound = IsCurve(myIndex); } if (myFound) + { break; + } else + { myIndex++; + } } } @@ -120,7 +124,9 @@ bool TopOpeBRepDS_CurveExplorer::IsCurveKeep(const int I) const { bool b = MYDS.myCurves.IsBound(I); if (b) + { b = MYDS.Curve(I).Keep(); + } return b; } @@ -150,7 +156,9 @@ int TopOpeBRepDS_CurveExplorer::NbCurve() Find(); int n = 0; for (; More(); Next()) + { n++; + } return n; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_DataStructure.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_DataStructure.cxx index 5f4b2e7bbb..ef564cf9a6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_DataStructure.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_DataStructure.cxx @@ -138,9 +138,13 @@ void TopOpeBRepDS_DataStructure::RemoveCurve(const int I) const occ::handle& I1 = C.GetSCI1(); const occ::handle& I2 = C.GetSCI2(); if (!I1.IsNull()) + { RemoveShapeInterference(S1, I1); + } if (!I2.IsNull()) + { RemoveShapeInterference(S2, I2); + } C.ChangeKeep(false); // NYI : nullify interferences I1,I2 @@ -279,9 +283,13 @@ bool TopOpeBRepDS_DataStructure::KeepShape(const int I, const bool FindKeep) con { const TopoDS_Shape& S = myShapes.FindKey(I); if (FindKeep) + { b = KeepShape(S); + } else + { b = true; + } } return b; } @@ -295,9 +303,13 @@ bool TopOpeBRepDS_DataStructure::KeepShape(const TopoDS_Shape& S, const bool Fin { const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromKey(S); if (FindKeep) + { b = SD.Keep(); + } else + { b = true; + } } return b; } @@ -337,7 +349,9 @@ int TopOpeBRepDS_DataStructure::AddSectionEdge(const TopoDS_Edge& E) { int iE = mySectionEdges.FindIndex(E); if (iE == 0) + { iE = mySectionEdges.Add(E); + } return iE; } @@ -445,7 +459,9 @@ const NCollection_List>& TopOpeBRepDS_Dat ShapeInterferences(const TopoDS_Shape& S, const bool FindKeep) const { if (HasShape(S, FindKeep)) + { return myShapes.FindFromKey(S).myInterferences; + } return myEmptyListOfInterference; } @@ -455,7 +471,9 @@ NCollection_List>& TopOpeBRepDS_DataStruc ChangeShapeInterferences(const TopoDS_Shape& S) { if (!HasShape(S)) + { return myEmptyListOfInterference; + } TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); return SD.myInterferences; } @@ -466,7 +484,9 @@ const NCollection_List>& TopOpeBRepDS_Dat ShapeInterferences(const int I, const bool FindKeep) const { if (FindKeep && !KeepShape(I)) + { return myEmptyListOfInterference; + } return myShapes.FindFromIndex(I).myInterferences; } @@ -485,12 +505,14 @@ const NCollection_List& TopOpeBRepDS_DataStructure::ShapeSameDomai const TopoDS_Shape& S) const { if (!S.IsNull()) + { if (myShapes.Contains(S)) { const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromKey(S); const NCollection_List& l = SD.mySameDomain; return l; } + } return myEmptyListOfShape; } @@ -562,9 +584,13 @@ void TopOpeBRepDS_DataStructure::RemoveShapeSameDomain(const TopoDS_Shape& S, const TopoDS_Shape& itS = it.Value(); bool remove = itS.IsSame(SSD); if (remove) + { L.Remove(it); + } else + { it.Next(); + } } } @@ -584,7 +610,9 @@ int TopOpeBRepDS_DataStructure::SameDomainRef(const int I) const int TopOpeBRepDS_DataStructure::SameDomainRef(const TopoDS_Shape& S) const { if (S.IsNull()) + { return 0; + } if (myShapes.Contains(S)) { return myShapes.FindFromKey(S).mySameDomainRef; @@ -608,7 +636,9 @@ void TopOpeBRepDS_DataStructure::SameDomainRef(const int I, const int Ref) void TopOpeBRepDS_DataStructure::SameDomainRef(const TopoDS_Shape& S, const int Ref) { if (S.IsNull()) + { return; + } if (myShapes.Contains(S)) { TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); @@ -632,10 +662,12 @@ TopOpeBRepDS_Config TopOpeBRepDS_DataStructure::SameDomainOri(const int I) const TopOpeBRepDS_Config TopOpeBRepDS_DataStructure::SameDomainOri(const TopoDS_Shape& S) const { if (!S.IsNull()) + { if (myShapes.Contains(S)) { return myShapes.FindFromKey(S).mySameDomainOri; } + } return TopOpeBRepDS_UNSHGEOMETRY; } @@ -655,11 +687,13 @@ void TopOpeBRepDS_DataStructure::SameDomainOri(const int I, const TopOpeBRepDS_C void TopOpeBRepDS_DataStructure::SameDomainOri(const TopoDS_Shape& S, const TopOpeBRepDS_Config Ori) { if (!S.IsNull()) + { if (myShapes.Contains(S)) { TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); SD.mySameDomainOri = Ori; } + } } //================================================================================================= @@ -678,10 +712,12 @@ int TopOpeBRepDS_DataStructure::SameDomainInd(const int I) const int TopOpeBRepDS_DataStructure::SameDomainInd(const TopoDS_Shape& S) const { if (!S.IsNull()) + { if (myShapes.Contains(S)) { return myShapes.FindFromKey(S).mySameDomainInd; } + } return 0; } @@ -701,7 +737,9 @@ void TopOpeBRepDS_DataStructure::SameDomainInd(const int I, const int Ind) void TopOpeBRepDS_DataStructure::SameDomainInd(const TopoDS_Shape& S, const int Ind) { if (S.IsNull()) + { return; + } if (myShapes.Contains(S)) { TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); @@ -725,7 +763,9 @@ int TopOpeBRepDS_DataStructure::AncestorRank(const int I) const int TopOpeBRepDS_DataStructure::AncestorRank(const TopoDS_Shape& S) const { if (S.IsNull()) + { return 0; + } if (myShapes.Contains(S)) { return myShapes.FindFromKey(S).myAncestorRank; @@ -749,7 +789,9 @@ void TopOpeBRepDS_DataStructure::AncestorRank(const int I, const int Ianc) void TopOpeBRepDS_DataStructure::AncestorRank(const TopoDS_Shape& S, const int Ianc) { if (S.IsNull()) + { return; + } if (myShapes.Contains(S)) { TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); @@ -795,7 +837,9 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, bool isdef1 = SD1.myOrientationDef; bool todef1 = (!isdef1); if (isdef1 && SD1.mySameDomainOri == TopOpeBRepDS_UNSHGEOMETRY) + { todef1 = true; + } if (todef1) { SD1.myOrientation = o1; @@ -807,7 +851,9 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, bool isdef2 = SD2.myOrientationDef; bool todef2 = (!isdef2); if (isdef2 && SD2.mySameDomainOri == TopOpeBRepDS_UNSHGEOMETRY) + { todef2 = true; + } if (todef2) { SD2.myOrientation = o2; @@ -839,11 +885,17 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, // r1 != i1 r2 == i2 : S1 has a SameDomain reference : give it to S2 // r1 != i1 r2 != i2 : S1,S2 have SameDomain reference : check equality if (r1 == iS1 && r2 == iS2) + { r = (refFirst ? iS1 : iS2); + } else if (r1 == iS1 && r2 != iS2) + { r = r2; + } else if (r1 != iS1 && r2 == iS2) + { r = r1; + } else if (r1 != iS1 && r2 != iS2) { if (r1 != r2) @@ -870,7 +922,9 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, { bool sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(S1, Sr); if (!sso) + { o = TopOpeBRepDS_DIFFORIENTED; + } } SameDomainRef(iS1, r); SameDomainOri(iS1, o); @@ -883,7 +937,9 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, { bool sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(S2, Sr); if (!sso) + { o = TopOpeBRepDS_DIFFORIENTED; + } } SameDomainRef(iS2, r); SameDomainOri(iS2, o); @@ -907,14 +963,18 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& bool isdef1 = SD1.myOrientationDef; bool todef1 = true; if (c1 == TopOpeBRepDS_UNSHGEOMETRY && isdef1) + { todef1 = false; + } int iS2 = AddShape(S2, 2); TopOpeBRepDS_ShapeData& SD2 = myShapes.ChangeFromIndex(iS2); bool isdef2 = SD2.myOrientationDef; bool todef2 = true; if (c2 == TopOpeBRepDS_UNSHGEOMETRY && isdef2) + { todef2 = false; + } if (todef1 || todef2) { @@ -922,9 +982,13 @@ void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& } if (todef1 && c1 == TopOpeBRepDS_UNSHGEOMETRY) + { SameDomainOri(S1, TopOpeBRepDS_UNSHGEOMETRY); + } if (todef2 && c2 == TopOpeBRepDS_UNSHGEOMETRY) + { SameDomainOri(S2, TopOpeBRepDS_UNSHGEOMETRY); + } } //================================================================================================= @@ -988,9 +1052,13 @@ int TopOpeBRepDS_DataStructure::NbSectionEdges() const const TopOpeBRepDS_Surface& TopOpeBRepDS_DataStructure::Surface(const int I) const { if (mySurfaces.IsBound(I)) + { return mySurfaces(I).mySurface; + } else + { return myEmptySurface; + } } //================================================================================================= @@ -998,9 +1066,13 @@ const TopOpeBRepDS_Surface& TopOpeBRepDS_DataStructure::Surface(const int I) con TopOpeBRepDS_Surface& TopOpeBRepDS_DataStructure::ChangeSurface(const int I) { if (mySurfaces.IsBound(I)) + { return mySurfaces(I).mySurface; + } else + { return myEmptySurface; + } } //================================================================================================= @@ -1014,7 +1086,9 @@ const TopOpeBRepDS_Curve& TopOpeBRepDS_DataStructure::Curve(const int I) const return C; } else + { return myEmptyCurve; + } } //================================================================================================= @@ -1040,9 +1114,13 @@ const TopOpeBRepDS_Point& TopOpeBRepDS_DataStructure::Point(const int I) const } if (myPoints.IsBound(I)) + { return myPoints(I).myPoint; + } else + { return myEmptyPoint; + } } //================================================================================================= @@ -1055,9 +1133,13 @@ TopOpeBRepDS_Point& TopOpeBRepDS_DataStructure::ChangePoint(const int I) } if (myPoints.IsBound(I)) + { return myPoints(I).myPoint; + } else + { return myEmptyPoint; + } } //================================================================================================= @@ -1091,7 +1173,9 @@ const TopoDS_Edge& TopOpeBRepDS_DataStructure::SectionEdge(const int I, const bo { const TopoDS_Shape& S = mySectionEdges.FindKey(I); if (HasShape(S, FindKeep)) + { return TopoDS::Edge(S); + } return TopoDS::Edge(myEmptyShape); } @@ -1101,7 +1185,9 @@ int TopOpeBRepDS_DataStructure::SectionEdge(const TopoDS_Edge& S, const bool Fin { int i = 0; if (KeepShape(S, FindKeep)) + { i = mySectionEdges.FindIndex(S); + } return i; } @@ -1158,7 +1244,9 @@ bool TopOpeBRepDS_DataStructure::HasNewSurface(const TopoDS_Shape& F) const const occ::handle& TopOpeBRepDS_DataStructure::NewSurface(const TopoDS_Shape& F) const { if (HasNewSurface(F)) + { return myNewSurface.Find(F); + } return myEmptyGSurface; } @@ -1169,8 +1257,12 @@ bool TopOpeBRepDS_DataStructure::FindInterference( const occ::handle& I) const { for (; IT.More(); IT.Next()) + { if (IT.Value() == I) + { return true; + } + } return false; } @@ -1217,10 +1309,14 @@ NCollection_IndexedDataMapDS(); if (!TopOpeBRepDS::IsTopology(K)) + { return SS; + } TopAbs_ShapeEnum t = TopOpeBRepDS::KindToShape(K); if (DS.Shape(I, fk).ShapeType() != t) + { return SS; + } const TopoDS_Shape& S = myHDS->Shape(I, fk); int r = myHDS->SameDomainReference(S); TopOpeBRepDS_Config o = myHDS->SameDomainOrientation(S); @@ -75,7 +79,9 @@ TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const int IS) const TCollection_AsciiString SS; const TopOpeBRepDS_DataStructure& BDS = myHDS->DS(); if (IS < 1 || IS > BDS.NbShapes()) + { return SS; + } SS = SPrintShape(BDS.Shape(IS)); return SS; } @@ -124,14 +130,18 @@ TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri( TCollection_AsciiString SS; NCollection_List::Iterator it(L); if (!it.More()) + { return SS; + } SS = SS + astr; TCollection_AsciiString bst(astr.Length(), ' '); for (int il = 0; it.More(); it.Next(), il++) { TCollection_AsciiString ss = SPrintShapeRefOri(it.Value()); if (il) + { ss = bst + ss; + } SS = SS + ss + "\n"; } return SS; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EIR.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EIR.cxx index 76e08df30b..2b88ea2081 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EIR.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EIR.cxx @@ -67,7 +67,9 @@ static void FDS_reduceONFACEinterferences( { hasONFACE = FUN_hasStateShape(I1->Transition(), TopAbs_ON, TopAbs_FACE); if (hasONFACE) + { break; + } } } @@ -89,10 +91,14 @@ static void FDS_reduceONFACEinterferences( LI.Remove(it1); } else + { it1.Next(); + } } else + { it1.Next(); + } } } } @@ -111,7 +117,9 @@ static void FUN_ReducerEdge3d(const int int n3d = LI.Extent(); if (n3d <= 1) + { return; + } const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX)); int rankE = BDS.AncestorRank(E); TopoDS_Shape OOv; @@ -141,16 +149,24 @@ static void FUN_ReducerEdge3d(const int TopAbs_Orientation o; bool ok = FUN_tool_orientEinFFORWARD(EE, FF, o); if (ok && (o == TopAbs_EXTERNAL)) + { torem = true; + } } if (torem) + { LI.Remove(it1); + } else + { it1.Next(); + } } nLI = LI.Extent(); if (nLI <= 1) + { return; + } } // --> jyl 231198 : cts21797 @@ -185,9 +201,13 @@ static void FUN_ReducerEdge3d(const int NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else + { return; + } while (it2.More()) { @@ -216,7 +236,9 @@ static void FUN_ReducerEdge3d(const int bool sameG = (GT2 == GT1) && (G2 == G1); if (!sameG) + { break; + } // , if (GT1 == TopOpeBRepDS_VERTEX) @@ -233,7 +255,9 @@ static void FUN_ReducerEdge3d(const int else { // vG on E if (G1hsd) + { OOv = BDS.Shape(sdG1); + } Gsta = G1hsd ? 3 : 1; } } @@ -247,7 +271,9 @@ static void FUN_ReducerEdge3d(const int TopoDS_Shape Eshared; bool foundsh = FUN_tool_Eshared(OOv, F1, F2, Eshared); if (!foundsh) + { return; + } // modified by NIZHNY-MKK Mon Apr 2 15:37:12 2001.BEGIN if (!BDS.HasShape(Eshared)) @@ -287,7 +313,9 @@ static void FUN_ReducerEdge3d(const int // !!!KK a revoir!!!! if (!isComplex) + { EFITool.InitPointVertex(Gsta, OOv); + } isComplex = true; EFITool.Init(E, E1, F1, I1); EFITool.Add(E, E1, F1, I1); @@ -339,7 +367,9 @@ static void FUN_ReducerEdge3d(const int } } else + { it1.Next(); + } } // it1 } @@ -366,7 +396,9 @@ static void FUN_ReducerSDEdge(const int int nI = LI.Extent(); if (nI <= 1) + { return; + } NCollection_List> newLI; const TopoDS_Shape& EIX = BDS.Shape(SIX); @@ -398,9 +430,13 @@ static void FUN_ReducerSDEdge(const int bool complex1d = false; NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else + { break; + } TopOpeBRepDS_Transition T(TopAbs_IN, TopAbs_IN, TopAbs_EDGE, TopAbs_EDGE); while (it2.More()) @@ -524,7 +560,9 @@ static void FUN_reclSE2(const int bool hascO = false; NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else { it1.Next(); @@ -562,7 +600,9 @@ static void FUN_reclSE2(const int LI.Remove(it1); } else + { it1.Next(); + } } // it1 } // FUN_reclSE2 @@ -583,15 +623,21 @@ Standard_EXPORT void FUN_reclSE(const int int G; tki.Value(K, G); if (K != TopOpeBRepDS_VERTEX) + { continue; + } NCollection_List>& loi = tki.ChangeValue(K, G); NCollection_List> Rloi; int nloi = loi.Extent(); if (nloi == 0) + { continue; + } else if (nloi == 1) + { LOI.Append(loi); + } else { FUN_reclSE2(EIX, BDS, loi, Rloi); @@ -695,19 +741,25 @@ static void FUN_reducepure2dI0(NCollection_ListINT/EXT (cto009B1(es6,p1,f9)) + } // recall : G1==G2 && ST1==ST2==EDGE bool ok = (G1 == G2); ok = ok && (tsb1 == TopAbs_FACE) && (tsb1 == tsb2) && (isb1 == isa1) && (isb2 == isa2); if (!ok) + { return; + } bool int12 = M_REVERSED(O1) && M_FORWARD(O2); bool int21 = M_REVERSED(O2) && M_FORWARD(O1); ok = int12 || int21; if (!ok) + { return; + } TopOpeBRepDS_Transition newT(TopAbs_INTERNAL); int bef = int12 ? isb1 : isb2; @@ -735,7 +787,9 @@ static void FUN_reducepure2dI(NCollection_List>& LI = BDS.ChangeShapeInterferences(EIX); TopOpeBRepDS_TKI newtki; @@ -925,15 +983,21 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) tki.Value(K, G); const NCollection_List>& loi = tki.Value(K, G); if (K == TopOpeBRepDS_POINT) + { continue; + } const TopoDS_Shape& vG = BDS.Shape(G); TopoDS_Shape oovG; bool sdm = FUN_ds_getoov(vG, BDS, oovG); if (!sdm) + { continue; + } int OOG = BDS.Shape(oovG); if (OOG == 0) + { continue; // NYIRaise + } bool isb = newtki.IsBound(K, OOG); @@ -956,13 +1020,17 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) } newtki.ChangeInterferences(K, G).Clear(); if (!isb) + { newtki.Add(K, OOG); + } newtki.ChangeInterferences(K, OOG).Append(newloi); continue; } if (!isb) + { continue; + } NCollection_List>& li = newtki.ChangeInterferences(K, OOG); newtki.ChangeInterferences(K, G).Append(li); @@ -984,7 +1052,9 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) bool performPNC = false; // JYL 28/09/98 : temporaire if (!performPNC) + { return; + } // suppression des I/G(I) n'est accede par aucune courbe // portee par une des faces cnx a EIX. @@ -1021,7 +1091,9 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) BDS.ShapeInterferences(fx); NCollection_List>::Iterator itlifx(lifx); if (!itlifx.More()) + { continue; + } occ::handle I1; TopOpeBRepDS_Kind GT1; @@ -1033,13 +1105,17 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) FDS_data(itlifx, I1, GT1, G1, ST1, S1); bool isfci = (GT1 == TopOpeBRepDS_CURVE); if (!isfci) + { continue; + } NCollection_List>& lic = BDS.ChangeCurveInterferences(G1); NCollection_List>::Iterator itlic(lic); if (!itlic.More()) + { continue; + } occ::handle I2; TopOpeBRepDS_Kind GT2; @@ -1051,19 +1127,27 @@ void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const int EIX) FDS_data(itlic, I2, GT2, G2, ST2, S2); bool isp = (GT2 == TopOpeBRepDS_POINT); if (!isp) + { continue; + } if (G2 != G) + { continue; + } curvefound = true; break; } // itlic.More() if (curvefound) + { break; + } } // itlifx.More() if (curvefound) + { break; + } } // itlfx.More() if (curvefound) @@ -1106,14 +1190,18 @@ static bool CheckInterferenceIsValid(const occ::handle BRep_Tool::Tolerance(theSupportEdge)) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EXPORT.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EXPORT.cxx index 261c0c4d5f..c0590ae705 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EXPORT.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EXPORT.cxx @@ -82,7 +82,9 @@ Standard_EXPORT void FDS_copy(const NCollection_List>::Iterator it(LI); it.More(); it.Next()) + { LII.Append(it.Value()); + } } //------------------------------------------------------ @@ -91,7 +93,9 @@ Standard_EXPORT void FDS_copy(const NCollection_List& LI, //------------------------------------------------------ { for (NCollection_List::Iterator it(LI); it.More(); it.Next()) + { LII.Append(it.Value()); + } } //------------------------------------------------------ Standard_EXPORT void FDS_assign(const NCollection_List>& LI, @@ -130,7 +134,9 @@ Standard_EXPORT void FUN_ds_samRk(const TopOpeBRepDS_DataStructure& BDS, LI.Remove(it); } else + { it.Next(); + } } } @@ -144,7 +150,9 @@ Standard_EXPORT void FDS_Tdata int& IA) { if (I.IsNull()) + { return; + } const TopOpeBRepDS_Transition T = I->Transition(); SB = T.ShapeBefore(); IB = T.IndexBefore(); @@ -162,7 +170,9 @@ Standard_EXPORT void FDS_data int& S1) { if (I.IsNull()) + { return; + } GT1 = I->GeometryType(); G1 = I->Geometry(); ST1 = I->SupportType(); @@ -181,7 +191,9 @@ Standard_EXPORT bool FDS_data int& S1) { if (!it1.More()) + { return false; + } I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition(); FDS_data(I1, GT1, G1, ST1, S1); @@ -203,7 +215,9 @@ Standard_EXPORT void FDS_Idata int& S1) { if (I.IsNull()) + { return; + } FDS_Tdata(I, SB, IB, SA, IA); FDS_data(I, GT1, G1, ST1, S1); } @@ -218,14 +232,18 @@ Standard_EXPORT bool FUN_ds_getVsdm(const TopOpeBRepDS_DataStructure& BDS, const int imax = BDS.NbShapes(); bool undef = (iV < 1) || (iV > imax); if (undef) + { return false; + } const TopoDS_Shape& V = BDS.Shape(iV); NCollection_List::Iterator issdm(BDS.ShapeSameDomain(V)); for (; issdm.More(); issdm.Next()) { const TopoDS_Shape& VV = issdm.Value(); if (V.IsSame(VV)) + { continue; + } iVsdm = BDS.Shape(VV); found = true; break; @@ -240,12 +258,18 @@ Standard_EXPORT bool FUN_ds_sdm(const TopOpeBRepDS_DataStructure& BDS, //------------------------------------------------------ { if (!BDS.HasShape(s1) || !BDS.HasShape(s2)) + { return false; + } const NCollection_List& sdm1 = BDS.ShapeSameDomain(s1); NCollection_List::Iterator it1(sdm1); for (; it1.More(); it1.Next()) + { if (it1.Value().IsSame(s2)) + { return true; + } + } return false; } @@ -269,7 +293,9 @@ Standard_EXPORT bool FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Shape& ss = it.Value(); trfa_samdom = ss.IsSame(F2); if (trfa_samdom) + { break; + } } if (!trfa_samdom) { @@ -310,13 +336,19 @@ Standard_EXPORT bool FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS, bool trfa_samdom = false; const TopoDS_Shape& ES = BDS.Shape(SI); // edge de F1 et F2 if (ES.ShapeType() != TopAbs_EDGE) + { return false; + } const TopoDS_Shape& F1 = BDS.Shape(isb1); if (F1.ShapeType() != TopAbs_FACE) + { return false; + } const TopoDS_Shape& F2 = BDS.Shape(isb2); if (F2.ShapeType() != TopAbs_FACE) + { return false; + } trfa_samdom = FDS_aresamdom(BDS, ES, F1, F2); return trfa_samdom; } @@ -331,7 +363,9 @@ Standard_EXPORT bool FDS_EdgeIsConnexToSameDomainFaces( const NCollection_List& lf = FDSCNX_EdgeConnexitySameShape(E, HDS); int nlf = lf.Extent(); if (nlf < 2) + { return false; + } bool samdom = false; NCollection_List::Iterator i1(lf); @@ -344,10 +378,14 @@ Standard_EXPORT bool FDS_EdgeIsConnexToSameDomainFaces( const TopoDS_Shape& f2 = i2.Value(); samdom = FDS_aresamdom(BDS, E, f1, f2); if (samdom) + { break; + } } if (samdom) + { break; + } } return samdom; } // not used @@ -361,9 +399,13 @@ Standard_EXPORT bool FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& //---------------------------------------------------- { if (SI == 0) + { return false; + } if (I.IsNull()) + { return false; + } bool ya = false; TopAbs_ShapeEnum SB1 = TopAbs_SHAPE, SA1 = TopAbs_SHAPE; @@ -425,7 +467,9 @@ Standard_EXPORT bool FDS_Parameter(const occ::handle& bool isEVI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)); bool isCPI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)); if (!isEVI && !isCPI) + { return false; + } par = FDS_Parameter(I); return true; } @@ -436,9 +480,13 @@ Standard_EXPORT double FDS_Parameter(const occ::handleIsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference))) + { p = occ::down_cast(I)->Parameter(); + } else if (I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference))) + { p = occ::down_cast(I)->Parameter(); + } else { throw Standard_Failure("FDS_Parameter"); @@ -455,9 +503,13 @@ Standard_EXPORT bool FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS, const NCollection_List& lssd = BDS.ShapeSameDomain(E); bool hsd = (!lssd.IsEmpty()); if (PLSD != nullptr) + { PLSD->Clear(); + } if (!hsd) + { return false; + } bool hsd3d = false; NCollection_List::Iterator it(lssd); @@ -471,9 +523,13 @@ Standard_EXPORT bool FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS, { hsd3d = true; if (PLSD != nullptr) + { PLSD->Append(esd); + } else + { break; + } } } return hsd3d; @@ -492,16 +548,22 @@ Standard_EXPORT bool FDS_Config3d(const TopoDS_Shape& E1, bool ok1 = FUN_tool_findPinE(TopoDS::Edge(E1), PE1, pE1); gp_Vec VE1; if (ok1) + { ok1 = TopOpeBRepTool_TOOL::TggeomE(pE1, TopoDS::Edge(E1), VE1); + } double pE2, dE2; bool ok2 = FUN_tool_projPonE(PE1, TopoDS::Edge(E2), pE2, dE2); gp_Vec VE2; if (ok2) + { ok2 = TopOpeBRepTool_TOOL::TggeomE(pE2, TopoDS::Edge(E2), VE2); + } if (!ok1 || !ok2) + { return false; + } gp_Dir DE1(VE1); gp_Dir DE2(VE2); @@ -520,9 +582,13 @@ Standard_EXPORT bool FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS, const NCollection_List& lssd = BDS.ShapeSameDomain(E); bool hsd = (!lssd.IsEmpty()); if (PLSD != nullptr) + { PLSD->Clear(); + } if (!hsd) + { return false; + } bool hsd2d = false; NCollection_List::Iterator it(lssd); @@ -535,9 +601,13 @@ Standard_EXPORT bool FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS, { hsd2d = true; if (PLSD != nullptr) + { PLSD->Append(esd); + } else + { break; + } } } return hsd2d; @@ -563,9 +633,13 @@ Standard_EXPORT void FDS_getupperlower(const occ::handle p1), parinfe = (par < paredge); bool parinf2 = (par < p2), parsupe = (par > paredge); if (parsup1 && parinfe) + { p1 = par; + } if (parinf2 && parsupe) + { p2 = par; + } } } @@ -584,7 +658,9 @@ Standard_EXPORT bool FUN_ds_getoov(const TopoDS_Shape& v, { const TopoDS_Shape& vcur = itlov.Value(); if (vcur.IsSame(v)) + { continue; + } oov = vcur; return true; } @@ -607,7 +683,9 @@ Standard_EXPORT bool FUN_ds_getoov(const TopoDS_Shape& { const TopoDS_Shape& vcur = itlov.Value(); if (vcur.IsSame(v)) + { continue; + } oov = vcur; return true; } @@ -626,7 +704,9 @@ Standard_EXPORT bool FUN_selectTRAINTinterference( const occ::handle& I = it.Value(); const TopAbs_Orientation ori = I->Transition().Orientation(TopAbs_IN); if (M_INTERNAL(ori)) + { liINTERNAL.Append(I); + } } bool hasINT = !liINTERNAL.IsEmpty(); return hasINT; @@ -646,7 +726,9 @@ static bool FUN_ds_hasSDMancestorfaces(const occ::handle mapfcE2; NCollection_List::Iterator it2(lFcE2); for (; it2.More(); it2.Next()) + { mapfcE2.Add(it2.Value()); + } NCollection_List::Iterator it1(lFcE1); for (; it1.More(); it1.Next()) @@ -654,7 +736,9 @@ static bool FUN_ds_hasSDMancestorfaces(const occ::handleHasSameDomain(fcE1); if (!hsdm1) + { continue; + } const NCollection_List& fsdm2 = BDS.ShapeSameDomain(fcE1); it2.Initialize(fsdm2); for (; it2.More(); it2.Next()) @@ -662,7 +746,9 @@ static bool FUN_ds_hasSDMancestorfaces(const occ::handle>& LI = BDS.ShapeInterferences(E); @@ -698,16 +788,22 @@ Standard_EXPORT void FUN_ds_PURGEforE9(const occ::handle> l3dF; int n3dF = FUN_selectSKinterference(LIcopy, TopOpeBRepDS_FACE, l3dF); if (n3dF == 0) + { continue; + } const NCollection_List& lfcxE = FDSCNX_EdgeConnexitySameShape(E, HDS); int nlfcxE = lfcxE.Extent(); if (nlfcxE == 0) + { continue; // NYIRaise + } NCollection_List::Iterator itf(lfcxE); NCollection_IndexedMap mapf; for (; itf.More(); itf.Next()) + { mapf.Add(itf.Value()); + } bool removed = false; NCollection_List>::Iterator it(l3dF); @@ -733,11 +829,13 @@ Standard_EXPORT void FUN_ds_PURGEforE9(const occ::handle::Iterator issdm(BDS.ShapeSameDomain(F)); bool foundinsdm = false; for (; issdm.More(); issdm.Next()) + { if (mapf.Contains(issdm.Value())) { foundinsdm = true; break; } + } if (!foundinsdm) { it.Next(); @@ -750,7 +848,9 @@ Standard_EXPORT void FUN_ds_PURGEforE9(const occ::handle>& LII = BDS.ChangeShapeInterferences(E); LII.Clear(); LII.Append(LIcopy); @@ -797,15 +897,21 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handle> lI1; bool hasINT = ::FUN_selectTRAINTinterference(loicopy, lI1); if (!hasINT) + { continue; + } NCollection_List> lI2; int nI = FUN_selectTRASHAinterference(lI1, TopAbs_FACE, lI2); if (nI < 1) + { continue; + } NCollection_List> lI3; nI = FUN_selectSKinterference(lI2, TopOpeBRepDS_EDGE, lI3); if (nI < 1) + { continue; + } bool keepI = false; // for (NCollection_List>::Iterator it(lI3) @@ -816,10 +922,14 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handle& I = it.Value(); keepI = FDS_SIisGIofIofSBAofTofI(BDS, ISE, I); if (keepI) + { break; + } } if (keepI) + { continue; + } // ISE = (INTERNAL(F),G,ES), F has no I with G==SE // find fSE / fSE (SE's ancestor face) has IfSE = (T,SE,support) @@ -839,7 +949,9 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handle>& LIf = @@ -849,7 +961,9 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handle> LIfound; int nfound = FUN_selectGIinterference(LIfcopy, ISE, LIfound); if (nfound < 1) + { continue; + } // cto 009 B1 : Ifor=(FORWARD(IfES),G1,S) && Irev=(REVERSED(IfES),G1,S) // -> do NOT reduce to I = (INTERNAL(IfES),G1,S) (we can have EXTERNAL Tr) @@ -863,7 +977,9 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handle 0) || (nREV > 0); if (hasFORREV) + { break; + } // newI : // ----- @@ -873,7 +989,9 @@ Standard_EXPORT void FUN_ds_completeforSE1(const occ::handleIsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)); bool B = false; if (isevi) + { B = occ::down_cast(I)->GBound(); + } occ::handle newI = MakeEPVInterference(newT, S, G1, par, K, TopOpeBRepDS_EDGE, B); HDS->StoreInterference(newI, SE); @@ -929,12 +1047,18 @@ Standard_EXPORT void FUN_ds_completeforSE2(const occ::handle> lF; int nF = FUN_selectSKinterference(l1, TopOpeBRepDS_FACE, lF); if (nF > 1) + { continue; + } NCollection_List> lFE; int nFE = FUN_selectSKinterference(l1, TopOpeBRepDS_EDGE, lFE); if (nFE == 0) + { continue; + } // I = (T(FTRA),G not Gbound, ES) const occ::handle& I = lFE.First(); @@ -971,13 +1099,17 @@ Standard_EXPORT void FUN_ds_completeforSE2(const occ::handle> l2; int n2 = FUN_selectITRASHAinterference(lFE, IFCX, l2); if (n2 > 0) + { continue; + } double OOpar = 0.; if (point) @@ -1037,7 +1169,9 @@ Standard_EXPORT void FUN_ds_completeforSE2(const occ::handle(I)->GBound(); + } newI = MakeEPVInterference(newT, IFCX, G, par, K, TopOpeBRepDS_FACE, B); HDS->StoreInterference(newI, SE); } // itfcx @@ -1095,7 +1235,9 @@ static bool FUN_ds_completeforSE3( TopOpeBRepDS_Transition& Tr) { if (K == TopOpeBRepDS_VERTEX) + { return false; + } int ISE = BDS.Shape(SE); NCollection_List> loicopy; @@ -1106,7 +1248,9 @@ static bool FUN_ds_completeforSE3( int nEXT = FUN_selectTRAORIinterference(loicopy, TopAbs_EXTERNAL, lEXT); int n1 = nINT + nEXT; if (n1 < 1) + { return false; + } NCollection_List> l1; l1.Append(lINT); l1.Append(lEXT); @@ -1115,7 +1259,9 @@ static bool FUN_ds_completeforSE3( NCollection_List> l2; int n2 = FUN_selectTRASHAinterference(l1, TopAbs_FACE, l2); if (n2 < 1) + { return false; + } bool okb = false; for (NCollection_List>::Iterator it2(l2); it2.More(); it2.Next()) @@ -1123,10 +1269,14 @@ static bool FUN_ds_completeforSE3( const occ::handle& I2 = it2.Value(); okb = FDS_SIisGIofIofSBAofTofI(BDS, ISE, I2); if (okb) + { break; + } } if (!okb) + { return false; + } // a. I3d = IFE+IF NCollection_List> l2e; @@ -1134,12 +1284,16 @@ static bool FUN_ds_completeforSE3( NCollection_List> l2f; int n2f = FUN_selectSKinterference(l2, TopOpeBRepDS_FACE, l2f); if ((n2e == 0) || (n2f == 0)) + { return false; + } int sI3d = l2f.First()->Support(); NCollection_List> l3d; int n3d = FUN_selectITRASHAinterference(l2e, sI3d, l3d); if (n3d < 1) + { return false; + } // Tr //--- @@ -1177,9 +1331,13 @@ static bool FUN_ds_completeforSE3( TopAbs_State stb = TopAbs_UNKNOWN, sta = TopAbs_UNKNOWN; ok = MKT.Initialize(SE, par1, par2, parE, F, uv, factor); if (ok) + { ok = MKT.SetRest(Eline, parline); + } if (ok) + { ok = MKT.MkTonE(stb, sta); + } if (!ok) { return false; @@ -1274,7 +1432,9 @@ Standard_EXPORT bool FUN_ds_shareG(const occ::handleDS(); bool hsdm = HDS->HasSameDomain(BDS.Shape(iE2)); if (!hsdm) + { return false; + } const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1)); const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2)); @@ -1288,23 +1448,33 @@ Standard_EXPORT bool FUN_ds_shareG(const occ::handle tol) + { return false; + } gp_Vec nggeomF2; ok = FUN_tool_nggeomF(par2, E2, F2, nggeomF2); if (!ok) + { return false; + } gp_Dir nxx2; ok = FUN_tool_getxx(F2, E2, par2, nggeomF2, nxx2); if (!ok) + { return false; + } NCollection_IndexedMap mE1; TopExp::MapShapes(F1, TopAbs_EDGE, mE1); @@ -1314,24 +1484,34 @@ Standard_EXPORT bool FUN_ds_shareG(const occ::handle tol) + { continue; + } // E1 on F1, E2 on F2, E1 and E2 share split Esp(nyi : check it) gp_Vec nggeomF1; ok = FUN_tool_nggeomF(par1, E1, F1, nggeomF1); if (!ok) + { return false; + } gp_Dir nxx1; ok = FUN_tool_getxx(F1, E1, par1, nggeomF1, nxx1); if (!ok) + { return false; + } double prod = nxx1.Dot(nxx2); shareG = (prod > 0.); @@ -1367,7 +1547,9 @@ Standard_EXPORT bool FUN_ds_mkTonFsdm(const occ::handleDS(); bool hsdm = HDS->HasSameDomain(BDS.Shape(iE2)); if (!hsdm) + { return false; + } const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1)); const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2)); @@ -1383,7 +1565,9 @@ Standard_EXPORT bool FUN_ds_mkTonFsdm(const occ::handle tol) + { return false; + } } ok = FUN_tool_value(parEG, EG, P); if (!ok) + { return false; + } gp_Vec tgtEG; ok = TopOpeBRepTool_TOOL::TggeomE(parEG, EG, tgtEG); if (!ok) + { return false; + } gp_Vec ngF1; ok = FUN_tool_nggeomF(parEG, EG, F1, ngF1); if (!ok) + { return false; + } gp_Vec beafter = ngF1 ^ tgtEG; // nxx2 : // ------ double par2 = 0.0; if (EGisE2) + { par2 = parEG; + } else { double d2 = 0.0; ok = FUN_tool_projPonE(P, E2, par2, d2); if (!ok) + { return false; + } if (d2 > tol) + { return false; + } } gp_Vec ngF2; ok = FUN_tool_nggeomF(par2, E2, F2, ngF2); if (!ok) + { return false; + } gp_Dir nxx2; ok = FUN_tool_getxx(F2, E2, par2, ngF2, nxx2); if (!ok) + { return false; + } // T : // --- bool sdmEGE2 = EGisE2; if (!sdmEGE2) + { sdmEGE2 = FUN_ds_sdm(BDS, EG, E2); + } if (!sdmEGE2) + { return false; + } double prod = beafter.Dot(nxx2); double tola = Precision::Angular() * 1.e3; ok = (std::abs(1 - std::abs(prod)) < tola); if (!ok) + { return false; + } if (prod > 0.) + { T = TopOpeBRepDS_Transition(TopAbs_OUT, TopAbs_IN); + } else + { T = TopOpeBRepDS_Transition(TopAbs_IN, TopAbs_OUT); + } return true; } @@ -1485,12 +1699,18 @@ Standard_EXPORT int FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, { bool iscE = BRep_Tool::IsClosed(EE, FF); if (iscE) + { return CLOSESAME; + } else + { return ONSAMESHA; + } } else + { return UNKNOWN; + } } else { @@ -1511,34 +1731,50 @@ Standard_EXPORT int FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, int iFsdm = BDS.Shape(Fsdm); int rksdm = BDS.AncestorRank(Fsdm); if (rksdm == rkF) + { continue; + } bool samsha = FUN_tool_orientEinFFORWARD(EE, Fsdm, O); if (!samsha) + { continue; + } bool iscE = BRep_Tool::IsClosed(EE, Fsdm); if (iscE) + { return CLOSEOPPO; + } else { TopOpeBRepDS_Config Csdm = BDS.SameDomainOri(Fsdm); bool toreverse1 = (Csdm != C) && (!M_INTERNAL(O)) && (!M_EXTERNAL(O)); if (toreverse1) + { O = TopAbs::Complement(O); + } TopAbs_Orientation oFsdm = BDS.Shape(iFsdm).Orientation(); bool toreverse2 = (oF != oFsdm) && (!M_INTERNAL(oFsdm)) && (!M_EXTERNAL(oFsdm)); if (toreverse2) + { O = TopAbs::Complement(O); + } if (!hasFOR) + { hasFOR = M_FORWARD(O); + } if (!hasREV) + { hasREV = M_REVERSED(O); + } } } // it(sdmFs) if (hasFOR && hasREV) + { return FORREVOPPO; + } if (hasFOR || hasREV) { O = hasFOR ? TopAbs_FORWARD : TopAbs_REVERSED; @@ -1546,7 +1782,9 @@ Standard_EXPORT int FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, } } else + { return UNKNOWN; + } } return UNKNOWN; } @@ -1571,13 +1809,19 @@ static int FUN_EisSE2(const TopOpeBRepDS_DataStructure& BDS, int G = 0, S = 0; FDS_Idata(I, SB, IB, SA, IA, GT, G, ST, S); if (GT != TopOpeBRepDS_VERTEX) + { return NONE; + } if (M_EXTERNAL(O)) + { return NONE; + } // E sdm ES if (SB != TopAbs_EDGE) + { return NONE; + } // BDS.Shape(S); int rkE = BDS.AncestorRank(E); @@ -1590,25 +1834,37 @@ static int FUN_EisSE2(const TopOpeBRepDS_DataStructure& BDS, { const TopoDS_Vertex& VGsd = TopoDS::Vertex(BDS.Shape(Gsd)); if (rkE == rkG) + { oGinE = FUN_tool_orientVinE(VG, E); + } else + { oGinE = FUN_tool_orientVinE(VGsd, E); + } } else + { oGinE = FUN_tool_orientVinE(VG, E); + } if (oGinE == 0) + { return EREFandESUP; // G in IN E + } bool noshare = ((oGinE == LAST) && M_FORWARD(O)); noshare = noshare || ((oGinE == FIRST) && M_REVERSED(O)); if (noshare) + { return NONE; + } if (SB == TopAbs_EDGE) { // E sdm edge(ST) if (!Ghsd) + { return EREFandESUP; + } return EREFandESUP; } @@ -1624,7 +1880,9 @@ Standard_EXPORT void FUN_ds_FillSDMFaces(const occ::handle Fsdm; @@ -1634,11 +1892,15 @@ Standard_EXPORT void FUN_ds_FillSDMFaces(const occ::handle 0); if (!hsd) + { continue; + } TopExp_Explorer ex(S, TopAbs_EDGE); for (; ex.More(); ex.Next()) @@ -1646,15 +1908,21 @@ Standard_EXPORT void FUN_ds_FillSDMFaces(const occ::handle>& LI = BDS.ShapeInterferences(E); int nI = LI.Extent(); if (nI < 1) + { continue; + } NCollection_List>::Iterator it; for (it.Initialize(LI); it.More(); it.Next()) @@ -1662,7 +1930,9 @@ Standard_EXPORT void FUN_ds_FillSDMFaces(const occ::handle& I = it.Value(); int isSE2 = FUN_EisSE2(BDS, Fsdm, E, I); if (isSE2 == NONE) + { continue; + } BDS.AddSectionEdge(E); if (isSE2 == EREFandESUP) { @@ -1684,29 +1954,43 @@ Standard_EXPORT void FUN_ds_addSEsdm1d(const occ::handle lsd; TopOpeBRepDS_TOOL::EShareG(HDS, E, lsd); NCollection_List::Iterator itsd(lsd); if (itsd.More()) + { shareG = true; + } for (; itsd.More(); itsd.Next()) + { BDS.AddSectionEdge(TopoDS::Edge(itsd.Value())); + } if (shareG) + { BDS.AddSectionEdge(E); + } } // i=1..ns } // FUN_ds_addSEsdm1d @@ -1749,7 +2033,9 @@ Standard_EXPORT int FUN_ds_hasI2d( int GF = 0, SF = 0; FDS_data(IF, GTF, GF, STF, SF); if (GE != GF) + { continue; + } if (SF == isb) { is3d = true; @@ -1757,7 +2043,9 @@ Standard_EXPORT int FUN_ds_hasI2d( } } // itF if (!is3d) + { LI2d.Append(IE); + } } // itE int nLI2d = LI2d.Extent(); return nLI2d; @@ -1790,7 +2078,9 @@ Standard_EXPORT void FUN_ds_completeforSE4(const occ::handle>& loi = tki.Value(K, G); if (K != TopOpeBRepDS_POINT) + { continue; + } NCollection_List> loicopy; FDS_assign(loi, loicopy); @@ -1799,7 +2089,9 @@ Standard_EXPORT void FUN_ds_completeforSE4(const occ::handle> l2; int n2 = FUN_selectTRASHAinterference(l1, TopAbs_FACE, l2); if (n2 < 1) + { continue; + } const occ::handle& I = l2.First(); TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; @@ -1813,7 +2105,9 @@ Standard_EXPORT void FUN_ds_completeforSE4(const occ::handle>::Iterator it(l2); it.More(); @@ -1828,17 +2122,27 @@ Standard_EXPORT void FUN_ds_completeforSE4(const occ::handleTransition().Orientation(TopAbs_IN); if (!hasFOR) + { hasFOR = M_FORWARD(O2); + } if (!hasREV) + { hasREV = M_REVERSED(O2); + } } if (!hasFOR && !hasREV) + { continue; + } if (hasFOR && hasREV) + { continue; + } TopAbs_Orientation newO = hasFOR ? TopAbs_REVERSED : TopAbs_FORWARD; TopOpeBRepDS_Transition newT(newO); newT.Index(isb); @@ -1881,7 +2185,9 @@ Standard_EXPORT void FUN_ds_completeforSE5(const occ::handle> LI; int nI = FUN_selectSKinterference(LOIc, TopOpeBRepDS_EDGE, LI); if (nI < 1) + { continue; + } NCollection_List> newLI; bool hasnewLI = false; @@ -1946,16 +2252,22 @@ Standard_EXPORT void FUN_ds_completeforSE5(const occ::handle I3d = hasext ? lext.First() : lint.First(); int iF3 = I3d->Transition().Index(); @@ -1964,27 +2276,39 @@ Standard_EXPORT void FUN_ds_completeforSE5(const occ::handle 0); // as F and FCX are tangent, dot= +1 or -1 if (positive) + { continue; + } TopAbs_Orientation newO = hasfor ? TopAbs_FORWARD : TopAbs_REVERSED; if (hasint) + { newO = TopAbs::Complement(newO); + } NCollection_List>::Iterator it; if (hasint) + { it.Initialize(lint); + } else + { it.Initialize(lext); + } for (; it.More(); it.Next()) { const occ::handle& I = it.Value(); @@ -2027,7 +2351,9 @@ Standard_EXPORT void FUN_ds_completeforSE6(const occ::handle lEsd3d; bool hassd3d = FDS_HasSameDomain3d(BDS, SE, &lEsd3d); if (!hassd3d) + { continue; + } const NCollection_List>& LI = BDS.ShapeInterferences(SE); NCollection_List> LIcopy; @@ -2035,7 +2361,9 @@ Standard_EXPORT void FUN_ds_completeforSE6(const occ::handle> LIb; for (NCollection_List>::Iterator it(LIa); it.More(); it.Next()) @@ -2045,7 +2373,9 @@ Standard_EXPORT void FUN_ds_completeforSE6(const occ::handle> l2dFE; @@ -2065,7 +2395,9 @@ Standard_EXPORT void FUN_ds_completeforSE6(const occ::handle> l1dG; FUN_selectGIinterference(l1dE, G, l1dG); NCollection_List> l2dG; int n2dG = FUN_selectGIinterference(l2dFE, G, l2dG); if (n2dG == 0) + { continue; // no 2dI at G + } NCollection_List> l1dGEsd; int n1dGEsd = FUN_selectITRASHAinterference(l1dG, iEsd, l1dGEsd); if (n1dGEsd != 0) + { continue; // 1dI(Esd) at G exists already + } for (NCollection_List>::Iterator it2d(l2dG); it2d.More(); @@ -2106,14 +2446,18 @@ Standard_EXPORT void FUN_ds_completeforSE6(const occ::handle>& LI = BDS.ShapeInterferences(E); @@ -2195,7 +2543,9 @@ Standard_EXPORT void FUN_ds_completeforE7(const occ::handle> lREV; int nREV = FUN_selectTRAORIinterference(l1, TopAbs_REVERSED, lREV); if ((nFOR == 0) || (nREV == 0)) + { continue; + } NCollection_List> lnewI; int iFS = 0; @@ -2208,7 +2558,9 @@ Standard_EXPORT void FUN_ds_completeforE7(const occ::handle> lFS; int nFS = FUN_selectSIinterference(loicopy, IFS, lREV); if (nFS == 0) + { continue; + } NCollection_List> lFSE; int nFSE = FUN_selectITRASHAinterference(loicopy, IFS, lFSE); @@ -2235,7 +2587,9 @@ Standard_EXPORT void FUN_ds_completeforE7(const occ::handle(IFOR)->GBound(); + } occ::handle newI = MakeEPVInterference(newT, IFS, G, par, K, TopOpeBRepDS_FACE, B); lnewI.Append(newI); @@ -2354,7 +2714,9 @@ Standard_EXPORT void FUN_ds_completeforSE8(const occ::handleHasSameDomain(BDS.Shape(GG)); if (Ghsdm) + { continue; + } } // li -> l1dE + l2dFE + lFE(<=>l3dFE) + li(<=>lFF) NCollection_List> li; @@ -2397,7 +2759,9 @@ Standard_EXPORT void FUN_ds_completeforSE8(const occ::handle>& LII = BDS.ChangeShapeInterferences(SE); LII.Clear(); @@ -2428,9 +2792,13 @@ Standard_EXPORT void FUN_ds_completeforSE9(const occ::handleHasSameDomain(SE); if (!hsd) + { continue; + } if (!BDS.ShapeInterferences(SE).IsEmpty()) + { continue; + } const NCollection_List& EsdSE = BDS.ShapeSameDomain(SE); NCollection_List::Iterator ite(EsdSE); @@ -2440,11 +2808,15 @@ Standard_EXPORT void FUN_ds_completeforSE9(const occ::handle>& LI = BDS.ShapeInterferences(Esd); if (LI.IsEmpty()) + { continue; + } NCollection_List> LIcopy; FDS_assign(LI, LIcopy); @@ -2462,10 +2834,14 @@ Standard_EXPORT void FUN_ds_completeforSE9(const occ::handleHasSameDomain(vG); if (hsd1) + { continue; // nyixpu011098 + } int rkG = BDS.AncestorRank(G); if (rkG != rkSE) + { continue; // nyixpu011098 + } // newI : // ----- @@ -2508,10 +2884,14 @@ Standard_EXPORT void FUN_ds_PointToVertex(const occ::handle>& LI = BDS.ShapeInterferences(s); if (LI.IsEmpty()) + { continue; + } TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI); @@ -2521,7 +2901,9 @@ Standard_EXPORT void FUN_ds_PointToVertex(const occ::handle>& loi = tki.Value(K, G); if (K == TopOpeBRepDS_VERTEX) + { continue; + } int Scur = 0; bool Gfaulty = false; @@ -2533,7 +2915,9 @@ Standard_EXPORT void FUN_ds_PointToVertex(const occ::handle>& LI = BDS.ShapeInterferences(s); if (LI.IsEmpty()) + { continue; + } NCollection_List> newLI; int rks = BDS.AncestorRank(s); @@ -2607,7 +3001,9 @@ Standard_EXPORT void FUN_ds_PointToVertex(const occ::handle CPI( occ::down_cast(I)); if (CPI.IsNull()) + { continue; + } double par = CPI->Parameter(); TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; @@ -2619,7 +3015,9 @@ Standard_EXPORT void FUN_ds_PointToVertex(const occ::handle newI = @@ -2661,22 +3059,32 @@ static bool FUN_redusamshaonE(const TopOpeBRepDS_DataStructure& BDS, double parES = 0.0; bool ok = FUN_tool_parE(E, parE, ES, parES); if (!ok) + { return false; + } gp_Pnt2d uv; ok = FUN_tool_paronEF(ES, parES, FTRA, uv); if (!ok) + { return false; + } double factor = 1.e-2; TopAbs_State stb = TopAbs_UNKNOWN, sta = TopAbs_UNKNOWN; TopOpeBRepTool_makeTransition MKT; ok = MKT.Initialize(E, f, l, parE, FTRA, uv, factor); if (ok) + { ok = MKT.SetRest(ES, parES); + } if (ok) + { ok = MKT.MkTonE(stb, sta); + } if (!ok) + { return false; + } TopOpeBRepDS_Transition newT; newT.Index(IB); newT.Before(stb); @@ -2684,11 +3092,15 @@ static bool FUN_redusamshaonE(const TopOpeBRepDS_DataStructure& BDS, ok = FDS_stateEwithF2d(BDS, E, parE, GT, G, FTRA, newT); if (!ok) + { return false; + } bool B = false; if (GT == TopOpeBRepDS_VERTEX) + { B = occ::down_cast(I)->GBound(); + } newI = MakeEPVInterference(newT, S, G, parE, GT, TopOpeBRepDS_EDGE, B); return true; } // FUN_redusamshaonE @@ -2707,7 +3119,9 @@ Standard_EXPORT void FUN_ds_redusamsha(const occ::handle>& li = tkis.ChangeValue(k, s); int nli = li.Extent(); if (nli < 2) + { continue; + } occ::handle newI; NCollection_List>::Iterator it1(li); @@ -2819,10 +3237,14 @@ Standard_EXPORT void FUN_ds_redusamsha(const occ::handleHasShape(F); if (!hasF) + { return false; + } const NCollection_List>& LI = pDS2d->ShapeInterferences(F); for (NCollection_List>::Iterator it(LI); it.More(); @@ -2874,7 +3298,9 @@ Standard_EXPORT bool FUN_ds_hasFEI(const TopOpeBRepDS_PDataStructure& pDS2d, FDS_data(I, GT, G, ST, S); bool found = (G == GI) && (T.Index() == ITRA); if (found) + { return true; + } } return false; } // FUN_ds_hasFEI @@ -2893,7 +3319,9 @@ Standard_EXPORT bool FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, gp_Pnt p3d; bool ok = FUN_tool_value(par, TopoDS::Edge(EspON), p3d); if (!ok) + { return false; + } for (; it.More(); it.Next()) { @@ -2901,11 +3329,15 @@ Standard_EXPORT bool FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, double d = 0., parp; ok = FUN_tool_projPonE(p3d, esd, parp, d); if (!ok) + { continue; + } double tolesd = BRep_Tool::Tolerance(esd); ok = (d < tolesd * 1.e3); // nyi checktole if (!ok) + { continue; + } IEsd = BDS.Shape(esd); return true; } @@ -3009,7 +3441,9 @@ Standard_EXPORT bool FDS_LOIinfsup( paft = l; int n = LOI.Extent(); if (n == 0) + { return true; + } NCollection_List> LOIsansGDS; TopOpeBRepDS_TKI tki; @@ -3022,12 +3456,16 @@ Standard_EXPORT bool FDS_LOIinfsup( tki.Value(K, G); bool PV = (K == TopOpeBRepDS_POINT) || (K == TopOpeBRepDS_VERTEX); if (!PV) + { continue; + } bool mk = (K == KDS); bool mg = (G == GDS); bool mkg = (mk && mg); if (mkg) + { continue; + } NCollection_List>& loi = tki.ChangeValue(K, G); @@ -3041,15 +3479,21 @@ Standard_EXPORT bool FDS_LOIinfsup( int isb1, isa1; FDS_Idata(I, tsb1, isb1, tsa1, isa1, GT1, G1, ST1, S1); if (tsb1 != TopAbs_FACE) + { continue; + } if (tsa1 != TopAbs_FACE) + { continue; + } occ::handle cpi( occ::down_cast(I)); occ::handle evi( occ::down_cast(I)); if (cpi.IsNull() && evi.IsNull()) + { continue; + } LOIsansGDS.Append(I); break; } @@ -3057,7 +3501,9 @@ Standard_EXPORT bool FDS_LOIinfsup( n = LOIsansGDS.Extent(); if (n == 0) + { return true; + } TopoDS_Vertex v; bool Eclosed = TopOpeBRepTool_TOOL::ClosedE(E, v); @@ -3069,7 +3515,9 @@ Standard_EXPORT bool FDS_LOIinfsup( double tolv = BRep_Tool::Tolerance(v); tolv = Precision::Parametric(tolv); if (tolv > tol) + { tol = tolv; + } bool pEisEf = (std::abs(pE - f) <= tol); bool pEisEl = (std::abs(pE - l) <= tol); isonboundper = pEisEf || pEisEl; @@ -3085,9 +3533,13 @@ Standard_EXPORT bool FDS_LOIinfsup( double p = FDS_Parameter(I); // pbef > paft if (p > pbef) + { pbef = p; + } if (p < paft) + { paft = p; + } } return true; } @@ -3100,9 +3552,13 @@ Standard_EXPORT bool FDS_LOIinfsup( const occ::handle& I = it.Value(); double p = FDS_Parameter(I); if (p > pbef && p < pE) + { pbef = p; + } if (p < paft && p > pE) + { paft = p; + } } } return true; @@ -3152,7 +3608,9 @@ Standard_EXPORT bool FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS, bool isonper = false; bool ok = FDS_LOIinfsup(BDS, E, pE, KDS, GDS, LOI, pbef, paft, isonper); if (!ok) + { return false; + } double t1 = 0.0, t2 = 0.0; ok = FDS_parbefaft(BDS, E, pE, pbef, paft, isonper, t1, t2); gp_Pnt P1; @@ -3160,7 +3618,9 @@ Standard_EXPORT bool FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS, gp_Pnt P2; bool ok2 = FUN_tool_value(t2, E, P2); if (!ok1 || !ok2) + { return false; + } TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(F1); TopAbs_State sta1 = FSC_StatePonFace(P1, F1, PSC); @@ -3168,9 +3628,13 @@ Standard_EXPORT bool FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS, // xpu190898 : cto014I2 (e5,fTRASHA14,vG7,eS10) if (sta1 == TopAbs_ON) + { sta1 = TopAbs_IN; + } if (sta2 == TopAbs_ON) + { sta2 = TopAbs_IN; + } TrmemeS.Before(sta1, TopAbs_FACE); TrmemeS.After(sta2, TopAbs_FACE); @@ -3197,7 +3661,9 @@ Standard_EXPORT void FUN_ds_FEIGb1TO0(occ::handle& const TopoDS_Shape& F = BDS.Shape(I); if (F.ShapeType() != TopAbs_FACE) + { continue; + } const NCollection_List>& LI = BDS.ShapeInterferences(F); NCollection_List> LGb1; // LI = LII + LGb1 (= {FEI with GB1}) @@ -3225,7 +3691,9 @@ Standard_EXPORT void FUN_ds_FEIGb1TO0(occ::handle& } // it(LII) int nGb1 = LGb1.Extent(); if (nGb1 == 0) + { continue; + } NCollection_List> LGb0; // LGb1={FEIGb1(EG,FS)} -> LGb0={FEIGb0(Esd,FS)} @@ -3280,7 +3748,9 @@ Standard_EXPORT void FUN_ds_FEIGb1TO0(occ::handle& continue; } if (conf == DIFFORIENTED) + { newO = TopAbs::Complement(newO); + } } newT.Set(newO); IGb1->SetGeometry(Gsd); @@ -3291,7 +3761,9 @@ Standard_EXPORT void FUN_ds_FEIGb1TO0(occ::handle& } // it(LGb1) if (LGb0.IsEmpty()) + { continue; + } NCollection_List>& newLI = BDS.ChangeShapeInterferences(F); newLI.Clear(); @@ -3315,15 +3787,21 @@ Standard_EXPORT void FUN_ds_complete1dForSESDM(const occ::handleHasSameDomain(SE); if (!hsd) + { continue; + } const NCollection_List& LEsd = BDS.ShapeSameDomain(SE); if (LEsd.IsEmpty()) + { continue; + } double tolSE = BRep_Tool::Tolerance(SE); // map of vertices of SE or same domain with them @@ -3332,14 +3810,18 @@ Standard_EXPORT void FUN_ds_complete1dForSESDM(const occ::handle& LV = BDS.ShapeSameDomain(VSE[i]); NCollection_List::Iterator it(LV); for (; it.More(); it.Next()) + { aGBMap.Add(it.Value()); + } } + } NCollection_List::Iterator ite(LEsd); for (; ite.More(); ite.Next()) @@ -3348,14 +3830,20 @@ Standard_EXPORT void FUN_ds_complete1dForSESDM(const occ::handle& LV = BDS.ShapeSameDomain(aV); NCollection_List::Iterator it(LV); for (; it.More(); it.Next()) + { aVGMap.Add(it.Value()); + } NCollection_List>::Iterator iti(LI2); for (; iti.More(); iti.Next()) { @@ -3414,10 +3910,14 @@ Standard_EXPORT void FUN_ds_complete1dForSESDM(const occ::handleGeometry(); const TopoDS_Shape& aVG = BDS.Shape(gi); if (aVGMap.Contains(aVG)) + { break; + } } if (iti.More()) + { continue; // has already + } } } @@ -3427,7 +3927,9 @@ Standard_EXPORT void FUN_ds_complete1dForSESDM(const occ::handle& I, double occ::handle CPI = occ::down_cast(I); if (CPI.IsNull()) + { return false; + } paronE = CPI->Parameter(); } if (vertex) @@ -75,7 +77,9 @@ static bool FUN_hasparam(const occ::handle& I, double occ::handle EVI = occ::down_cast(I); if (EVI.IsNull()) + { return false; + } paronE = EVI->Parameter(); } return true; @@ -90,7 +94,9 @@ static bool FUN_paronOOE(const TopoDS_Edge& OOE, bool ok = false; bool hasVonOO = (IsVertex > 1); if (hasVonOO) + { ok = FUN_tool_parVonE(TopoDS::Vertex(VonOO), OOE, paronOOE); + } else { double dist; @@ -99,9 +105,13 @@ static bool FUN_paronOOE(const TopoDS_Edge& OOE, double tol2 = tol1 * 1.e3; double tol = tol2; if (tol > 1.e-2) + { tol = 1.e-2; + } if (ok) + { ok = (dist <= tol); + } } return ok; } @@ -118,16 +128,22 @@ static bool FUN_keepIonF(const gp_Vec& tgref, gp_Vec tmp; bool ok = TopOpeBRepTool_TOOL::TggeomE(parE, E, tmp); if (!ok) + { return false; + } gp_Dir tgE = gp_Dir(tmp); double prod = std::abs(tgref.Dot(tgE)); if (std::abs(1 - prod) < tola) + { return false; // & are tangent edges + } gp_Vec dd; ok = FUN_tool_nggeomF(parE, E, F, dd); gp_Dir ngF(dd); if (!ok) + { return false; + } prod = std::abs((tgref ^ tgE).Dot(ngF)); return std::abs(1 - prod) >= tola; } @@ -157,7 +173,9 @@ void TopOpeBRepDS_Edge3dInterferenceTool::InitPointVertex(const int Is { myIsVertex = IsVertex; if (IsVertex > 1) + { myVonOO = VonOO; + } } //======================================================================= @@ -221,7 +239,9 @@ void TopOpeBRepDS_Edge3dInterferenceTool::Init(const TopoDS_Shape& double tola = Precision::Confusion(); bool Esdm = (std::abs(dot) < tola); if (Esdm) + { return; + } // NYI : il faut rejeter les interf I = (T,G,S=E) / E sdm with Eref // : @@ -234,7 +254,9 @@ void TopOpeBRepDS_Edge3dInterferenceTool::Init(const TopoDS_Shape& const TopAbs_Orientation& O = I->Transition().Orientation(TopAbs_IN); bool is2d = M_FORWARD(O) || M_REVERSED(O); if (is2d) + { return; + } } myrefdef = true; @@ -263,7 +285,9 @@ void TopOpeBRepDS_Edge3dInterferenceTool::Add(const TopoDS_Shape& } if (!myrefdef) + { return; + } const TopoDS_Edge& EE = TopoDS::Edge(E); const TopoDS_Face& FF = TopoDS::Face(F); @@ -271,7 +295,9 @@ void TopOpeBRepDS_Edge3dInterferenceTool::Add(const TopoDS_Shape& double pOO; bool ok = ::FUN_paronOOE(EE, myIsVertex, myVonOO, myP3d, pOO); if (!ok) + { return; + } gp_Pnt2d uv; { BRepAdaptor_Curve2d BC2d(EE, FF); @@ -284,14 +310,18 @@ void TopOpeBRepDS_Edge3dInterferenceTool::Add(const TopoDS_Shape& const TopAbs_Orientation& O = I->Transition().Orientation(TopAbs_IN); bool is2d = M_FORWARD(O) || M_REVERSED(O); if (is2d) + { return; + } } TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN); TopAbs_Orientation oritan; ok = FUN_tool_orientEinFFORWARD(EE, FF, oritan); // xpu : 30/12/97 if (!ok) + { return; + } gp_Dir Norm(FUN_tool_nggeomF(uv, FF)); myTool.Compare(myTole, Norm, oriloc, oritan); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EdgeInterferenceTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EdgeInterferenceTool.cxx index 725e347e1b..e005c18b31 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EdgeInterferenceTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_EdgeInterferenceTool.cxx @@ -35,9 +35,13 @@ static double Parameter(const occ::handle& I) { double p = 0; if (I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference))) + { p = occ::down_cast(I)->Parameter(); + } else if (I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference))) + { p = occ::down_cast(I)->Parameter(); + } else { throw Standard_ProgramError("TopOpeBRepDS_EdgeInterferenceTool1"); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Explorer.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Explorer.cxx index 4e41c309c6..9c757235e4 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Explorer.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Explorer.cxx @@ -57,7 +57,9 @@ void TopOpeBRepDS_Explorer::Init(const occ::handle& myT = T; myHDS = HDS; if (myHDS.IsNull()) + { return; + } myN = myHDS->NbShapes(); myFK = FK; Find(); @@ -84,12 +86,18 @@ void TopOpeBRepDS_Explorer::Find() const TopoDS_Shape& s = BDS.Shape(myI, false); TopAbs_ShapeEnum t = s.ShapeType(); if (t == myT || myT == TopAbs_SHAPE) + { found = true; + } else + { myI++; + } } else + { myI++; + } } myB = found; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FIR.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FIR.cxx index 30f574484b..bbc3c1fde8 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FIR.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FIR.cxx @@ -52,14 +52,18 @@ bool FUN_isPonF(const NCollection_List>& TopAbs_Orientation oEinF; bool edonfa = FUN_tool_orientEinFFORWARD(E, F, oEinF); if (edonfa) + { Pok = true; + } else { // P est NOK pour une face de LIF : arret double u, v; Pok = FUN_Parameters(P, F, u, v); if (!Pok) + { break; + } } } return Pok; @@ -116,9 +120,13 @@ bool FUN_findPonF(const TopoDS_Edge& { pardef = false; if (GT1 == TopOpeBRepDS_POINT) + { P = BDS.Point(G1).Point(); + } else if (GT1 == TopOpeBRepDS_VERTEX) + { P = BRep_Tool::Pnt(TopoDS::Vertex(BDS.Shape(G1))); + } if (pardef) { double dist; @@ -177,16 +185,22 @@ void FUN_reduceEDGEgeometry1(NCollection_List>::Iterator ili(LI); if (!ili.More()) + { return; + } // choix de l'arete Ecpx, lieu de resolution de la transition complexe const TopoDS_Face& FI = TopoDS::Face(BDS.Shape(iFI)); bool isEGsp = (!EGsp.IsNull()); TopoDS_Edge Ecpx; if (isEGsp) + { Ecpx = TopoDS::Edge(EGsp); + } else + { Ecpx = TopoDS::Edge(BDS.Shape(iEG)); + } TopOpeBRepDS_PDataStructure pbds = (TopOpeBRepDS_PDataStructure)(void*)&BDS; TopOpeBRepDS_FaceInterferenceTool FITool(pbds); @@ -196,9 +210,13 @@ void FUN_reduceEDGEgeometry1(NCollection_List= 2) { if (isEGsp) + { isPok = FUN_tool_findPinE(Ecpx, Pok, parPok); + } else + { isPok = FUN_findPonF(Ecpx, BDS, LI, Pok, parPok); // NYI pas necessaire + } if (!isPok) { LI.Clear(); @@ -311,11 +329,15 @@ void FUN_GmapS( occ::handle& I1 = it1.ChangeValue(); FDS_data(I1, GT1, G1, ST1, S1); if (GT1 != MDSke || ST1 != MDSkf) + { continue; + } const TopoDS_Shape& SG1 = BDS.Shape(G1); TopOpeBRepDS_ShapeData thedata; if (!mosd.Contains(SG1)) + { mosd.Add(SG1, thedata); + } mosd.ChangeFromKey(SG1).ChangeInterferences().Append(I1); } } @@ -352,7 +374,9 @@ void FUN_reduceEDGEgeometry(NCollection_List& MEsp) { if (!LI.Extent()) + { return; + } NCollection_IndexedDataMap mosd; FUN_GmapS(LI, BDS, mosd); @@ -459,12 +483,16 @@ void FUN_reduceEDGEgeometry(NCollection_List I( occ::down_cast(Iin)); if (I.IsNull()) + { return; + } const TopoDS_Face& FI = TopoDS::Face(FFI); const TopoDS_Edge& E = TopoDS::Edge(EE); @@ -186,7 +202,9 @@ void TopOpeBRepDS_FaceInterferenceTool::Init(const TopoDS_Shape& return; } if (cf == TopOpeBRepDS_DIFFORIENTED) + { STATIC_TOREVERSE = true; + } } // xpu150498 myFaceOrientation = FI.Orientation(); @@ -217,9 +235,13 @@ void TopOpeBRepDS_FaceInterferenceTool::Init(const TopoDS_Shape& bool ok = false; double d = 0.; if (edonfa) + { ok = FUN_tool_paronEF(E, myParOnEd, FI, uv); + } else + { ok = FUN_tool_projPonF(myPntOnEd, FI, uv, d); + } if (!ok) { FUN_RaiseError(); @@ -261,7 +283,9 @@ void TopOpeBRepDS_FaceInterferenceTool::Add(const TopoDS_Shape& occ::handle I( occ::down_cast(Iin)); if (I.IsNull()) + { return; + } const TopoDS_Face& FI = TopoDS::Face(FFI); const TopoDS_Face& FT = TopoDS::Face(FFT); const TopoDS_Edge& E = TopoDS::Edge(EE); @@ -292,7 +316,9 @@ void TopOpeBRepDS_FaceInterferenceTool::Add(const TopoDS_Shape& // cto 016 E1 bool rev = !same && (M_FORWARD(oriloc) || M_REVERSED(oriloc)); // xpu150498 if (rev) + { oriloc = TopAbs::Complement(oriloc); // xpu150498 + } TopAbs_Orientation oritan; TopAbs_Orientation oriEFT; @@ -303,13 +329,17 @@ void TopOpeBRepDS_FaceInterferenceTool::Add(const TopoDS_Shape& { oritan = oriEFT; if (EEisnew && !same) + { oritan = TopAbs::Complement(oriEFT); + } } else if (egoffi) { oritan = oriEFI; if (EEisnew && !same) + { oritan = TopAbs::Complement(oriEFI); + } } else { @@ -320,7 +350,9 @@ void TopOpeBRepDS_FaceInterferenceTool::Add(const TopoDS_Shape& gp_Pnt2d uv; bool ok = false; if (egofft) + { ok = FUN_tool_paronEF(E, myParOnEd, FT, uv); + } if (!ok) { double d; @@ -384,7 +416,9 @@ void TopOpeBRepDS_FaceInterferenceTool::Transition( TopAbs_Orientation o = T.Orientation(TopAbs_IN); bool rev = STATIC_TOREVERSE && (M_FORWARD(o) || M_REVERSED(o)); if (rev) + { o = TopAbs::Complement(o); + } T.Set(o); // xpu150498 } @@ -404,7 +438,9 @@ void TopOpeBRepDS_FaceInterferenceTool::SetEdgePntPar(const gp_Pnt& P, const dou void TopOpeBRepDS_FaceInterferenceTool::GetEdgePntPar(gp_Pnt& P, double& p) const { if (!myOnEdDef) + { throw Standard_ProgramError("GetEdgePntPar"); + } P = myPntOnEd; p = myParOnEd; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Filter.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Filter.cxx index ffa089b5d0..dfaa2c590c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Filter.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Filter.cxx @@ -45,7 +45,9 @@ void TopOpeBRepDS_Filter::ProcessEdgeInterferences() { const TopoDS_Shape& S = BDS.Shape(i); if (S.IsNull()) + { continue; + } if (S.ShapeType() == TopAbs_EDGE) { ProcessEdgeInterferences(i); @@ -67,7 +69,9 @@ void TopOpeBRepDS_Filter::ProcessFaceInterferences( { const TopoDS_Shape& S = BDS.Shape(i); if (S.IsNull()) + { continue; + } if (S.ShapeType() == TopAbs_FACE) { ProcessFaceInterferences(i, MEsp); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FilterCurveInterferences.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FilterCurveInterferences.cxx index a08cfee5ab..177a0ea0e5 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FilterCurveInterferences.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_FilterCurveInterferences.cxx @@ -55,7 +55,9 @@ void TopOpeBRepDS_Filter::ProcessCurveInterferences(const int CIX) LI.Remove(it2); } else + { it2.Next(); + } } } it1.Next(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapFiller.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapFiller.cxx index ec122a7cee..6f344d8e5d 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapFiller.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapFiller.cxx @@ -92,7 +92,9 @@ bool Contains(const TopoDS_Shape& F, const TopoDS_Shape& E) { // for (TopExp_Explorer exp(F,E.ShapeType()); exp.More(); exp.Next()){ if (exp.Current().IsSame(E)) + { return true; + } } return false; } @@ -108,7 +110,9 @@ void TopOpeBRepDS_GapFiller::FindAssociatedPoints( for (; itSI.More(); itSI.Next()) { if (myAsso->HasAssociation(itSI.Value())) + { return; + } } //------------------------------------------------------------------------ @@ -176,13 +180,17 @@ void TopOpeBRepDS_GapFiller::FindAssociatedPoints( // LI = LI && point dans la meme face Support2 //-------------------------------------------- if (!LI.IsEmpty()) + { FilterByFace(F2, LI); + } //------------------------------- // Controle et Selection metrique //------------------------------- if (!LI.IsEmpty()) + { FilterByIncidentDistance(F2, I, LI); + } if (!LI.IsEmpty()) { @@ -261,9 +269,13 @@ bool TopOpeBRepDS_GapFiller::IsOnFace(const occ::handleShape(IC->Support()); if (S1.IsSame(E)) + { return true; + } } } return false; @@ -349,13 +363,17 @@ static bool Normal(const occ::handle& A, if (F.IsSame(S1)) { if (C.Curve1().IsNull()) + { return false; + } P2d = C.Curve1()->Value(P); } else { if (C.Curve2().IsNull()) + { return false; + } P2d = C.Curve2()->Value(P); } @@ -403,7 +421,9 @@ void TopOpeBRepDS_GapFiller::FilterByIncidentDistance( const occ::handle& CI = it.Value(); if (CI->HasSameGeometry(I)) + { continue; + } bool Ok2 = Normal(myGapTool, myHDS, CI, F, N2); const TopOpeBRepDS_Point& P = myHDS->Point((CI->Geometry())); @@ -447,7 +467,9 @@ void TopOpeBRepDS_GapFiller::ReBuildGeom(const occ::handle& View) { if (!myAsso->HasAssociation(I)) + { return; + } NCollection_List>& LI = myAsso->Associated(I); NCollection_List>::Iterator it(LI); @@ -508,7 +530,9 @@ void TopOpeBRepDS_GapFiller::BuildNewGeometries() occ::handle I = it.Value(); int IP = I->Geometry(); if (View.Add(IP) && IP <= NbPoints) + { ReBuildGeom(I, View); + } } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapTool.cxx index 1b95c828fa..960915376d 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_GapTool.cxx @@ -77,7 +77,9 @@ void TopOpeBRepDS_GapTool::Init(const occ::handle& it.Next()) { if (it.Value()->GeometryType() == TopOpeBRepDS_POINT) + { StoreGToI(myGToI, it.Value()); + } } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_HDataStructure.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_HDataStructure.cxx index 3528907475..01324d6584 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_HDataStructure.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_HDataStructure.cxx @@ -44,7 +44,9 @@ static void FUN_HDS_data(const occ::handle& I, int& S1) { if (I.IsNull()) + { return; + } GT1 = I->GeometryType(); G1 = I->Geometry(); ST1 = I->SupportType(); @@ -59,7 +61,9 @@ Standard_EXPORT bool FUN_HDS_FACESINTERFER(const TopoDS_Shape& const TopOpeBRepDS_DataStructure& DS = HDS->DS(); bool ya = DS.HasShape(F1); if (!ya) + { return false; + } // DS.Shape(F1); int iF2 = DS.Shape(F2); @@ -234,7 +238,9 @@ bool TopOpeBRepDS_HDataStructure::HasShape(const TopoDS_Shape& S, const bool Fin bool TopOpeBRepDS_HDataStructure::HasSameDomain(const TopoDS_Shape& S, const bool FindKeep) const { if (!HasShape(S, FindKeep)) + { return false; + } const NCollection_List& l = myDS.ShapeSameDomain(S); bool res = !l.IsEmpty(); return res; @@ -254,7 +260,9 @@ NCollection_List::Iterator TopOpeBRepDS_HDataStructure::SameDomain TopOpeBRepDS_Config TopOpeBRepDS_HDataStructure::SameDomainOrientation(const TopoDS_Shape& S) const { if (!HasShape(S)) + { return TopOpeBRepDS_UNSHGEOMETRY; + } return myDS.SameDomainOri(S); } @@ -263,7 +271,9 @@ TopOpeBRepDS_Config TopOpeBRepDS_HDataStructure::SameDomainOrientation(const Top int TopOpeBRepDS_HDataStructure::SameDomainReference(const TopoDS_Shape& S) const { if (!HasShape(S)) + { return 0; + } return myDS.SameDomainRef(S); } @@ -338,18 +348,26 @@ int TopOpeBRepDS_HDataStructure::MakeCurve(const TopOpeBRepDS_Curve& curC, TopOp const occ::handle& I2 = curC.GetSCI2(); occ::handle SCI1, SCI2; if (!I1.IsNull()) + { SCI1 = new TopOpeBRepDS_SurfaceCurveInterference(I1); + } if (!I2.IsNull()) + { SCI2 = new TopOpeBRepDS_SurfaceCurveInterference(I2); + } const TopoDS_Shape& S1 = curC.Shape1(); const TopoDS_Shape& S2 = curC.Shape2(); // add the new SCIs in the lists of SCIs connected to the shapes if (!SCI1.IsNull()) + { myDS.AddShapeInterference(S1, SCI1); + } if (!SCI2.IsNull()) + { myDS.AddShapeInterference(S2, SCI2); + } // the shapes of the new curve are the shapes of curve curC newC.SetShapes(S1, S2); @@ -365,9 +383,13 @@ int TopOpeBRepDS_HDataStructure::MakeCurve(const TopOpeBRepDS_Curve& curC, TopOp // the geometry of the new surface/curve interf. is new curve inewC if (!SCI1.IsNull()) + { SCI1->Geometry(inewC); + } if (!SCI2.IsNull()) + { SCI2->Geometry(inewC); + } return inewC; } @@ -384,7 +406,9 @@ void TopOpeBRepDS_HDataStructure::RemoveCurve(const int icurC) int TopOpeBRepDS_HDataStructure::NbGeometry(const TopOpeBRepDS_Kind K) const { if (!TopOpeBRepDS::IsGeometry(K)) + { return 0; + } int n = 0; switch (K) @@ -418,15 +442,23 @@ int TopOpeBRepDS_HDataStructure::NbTopology() const int TopOpeBRepDS_HDataStructure::NbTopology(const TopOpeBRepDS_Kind K) const { if (!TopOpeBRepDS::IsTopology(K)) + { return 0; + } int res = 0; const bool FindKeep = false; TopAbs_ShapeEnum S = TopOpeBRepDS::KindToShape(K); for (int i = 1; i <= NbTopology(); i++) + { if (myDS.KeepShape(i, FindKeep)) + { if (myDS.Shape(i, FindKeep).ShapeType() == S) + { res++; + } + } + } return res; } @@ -462,7 +494,9 @@ Standard_EXPORT void FUN_TopOpeBRepDS_SortOnParameter( int iIntf = 0, nIntf = List.Extent(); if (nIntf == 0) + { return; + } occ::handle> HT; HT = new NCollection_HArray1(1, nIntf, false); @@ -521,10 +555,14 @@ void TopOpeBRepDS_HDataStructure::SortOnParameter( L1.Append(I); } else + { L2.Append(I); + } } else + { L1.Append(I); + } } SList.Clear(); @@ -590,14 +628,18 @@ bool TopOpeBRepDS_HDataStructure::ScanInterfList( const TopOpeBRepDS_Point& OOPDS = myDS.Point(G); bool iseq = PDS.IsEqual(OOPDS); if (iseq) + { return iseq; + } } else if (GT == TopOpeBRepDS_VERTEX) { TopOpeBRepDS_Point OOPDS(myDS.Shape(G)); bool iseq = PDS.IsEqual(OOPDS); if (iseq) + { return iseq; + } } } return false; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_InterferenceIterator.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_InterferenceIterator.cxx index 8594f1a123..2619e31134 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_InterferenceIterator.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_InterferenceIterator.cxx @@ -92,7 +92,9 @@ void TopOpeBRepDS_InterferenceIterator::Match() myIterator.Next(); } else + { break; + } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ListOfShapeOn1State.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ListOfShapeOn1State.cxx index 195ade58fd..50648e0e00 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ListOfShapeOn1State.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ListOfShapeOn1State.cxx @@ -51,7 +51,9 @@ bool TopOpeBRepDS_ListOfShapeOn1State::IsSplit() const { bool res = false; if (mySplits & 1) + { res = true; + } return res; } @@ -61,7 +63,11 @@ void TopOpeBRepDS_ListOfShapeOn1State::Split(const bool B) { int mask = 1; if (B) + { mySplits |= mask; + } else + { mySplits &= ~mask; + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Marker.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Marker.cxx index 3e343abbab..d7bf30f92a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Marker.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Marker.cxx @@ -37,7 +37,9 @@ void TopOpeBRepDS_Marker::Set(const int ie, const bool b) { Allocate(ie); if (ie < 1 || ie > myne) + { return; + } myhe->SetValue(ie, b); } @@ -47,18 +49,28 @@ void TopOpeBRepDS_Marker::Set(const bool b, const int na, void* const aa) // int ia,ie; int ia; if (!na) + { myhe->Init(b); + } else + { for (ia = 0; ia < na; ia++) + { Set(atoi(a[ia]), b); + } + } } bool TopOpeBRepDS_Marker::GetI(const int ie) const { if (myhe.IsNull()) + { return false; + } if (ie < 1 || ie > myne) + { return false; + } return myhe->Value(ie); } @@ -69,10 +81,14 @@ void TopOpeBRepDS_Marker::Allocate(const int n) if (all) { if (myne == 0) + { nall = 1000; + } myhe = new NCollection_HArray1(0, nall); myhe->Init(false); } if (nall) + { myne = nall; + } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_PointExplorer.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_PointExplorer.cxx index c953586720..8334ca368e 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_PointExplorer.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_PointExplorer.cxx @@ -66,9 +66,13 @@ void TopOpeBRepDS_PointExplorer::Find() myFound = IsPoint(myIndex); } if (myFound) + { break; + } else + { myIndex++; + } } } @@ -115,7 +119,9 @@ bool TopOpeBRepDS_PointExplorer::IsPointKeep(const int I) const { bool b = MYDS.myPoints.IsBound(I); if (b) + { b = MYDS.Point(I).Keep(); + } return b; } @@ -142,7 +148,9 @@ int TopOpeBRepDS_PointExplorer::NbPoint() Find(); int n = 0; for (; More(); Next()) + { n++; + } return n; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessEdgeInterferences.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessEdgeInterferences.cxx index 1330b43622..8bf5da2a13 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessEdgeInterferences.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessEdgeInterferences.cxx @@ -40,12 +40,14 @@ Standard_EXPORT bool FUN_vertexofedge bool isv = false; TopExp_Explorer ex; for (ex.Init(E, TopAbs_VERTEX); ex.More(); ex.Next()) + { // for (TopExp_Explorer ex(E,TopAbs_VERTEX); ex.More(); ex.Next()) if (ex.Current().IsSame(V)) { isv = true; break; } + } return isv; } @@ -120,7 +122,9 @@ static bool FUN_keepEinterference double f, l; BRep_Tool::Range(TopoDS::Edge(E), f, l); if (std::abs(par - f) < eps || std::abs(par - l) < eps) + { res = false; + } } return res; @@ -253,7 +257,9 @@ Standard_EXPORT void FUN_unkeepEsymetrictransitions isEd = BRep_Tool::Degenerated(TopoDS::Edge(E)); if (isEd) + { return; + } NCollection_List>::Iterator it1; @@ -308,9 +314,13 @@ Standard_EXPORT void FUN_unkeepEsymetrictransitions bool sym; if (newV) + { sym = idshape && oppostate; + } else + { sym = idshape && !idstate; + } if (sym) { // les 2 interferences ne different que leurs etats (symetriques) @@ -318,10 +328,14 @@ Standard_EXPORT void FUN_unkeepEsymetrictransitions it1toremove = true; } else + { it2.Next(); + } } else + { it2.Next(); + } } if (it1toremove) { @@ -374,9 +388,13 @@ Standard_EXPORT void FUN_orderFFsamedomain } if (ffsd) + { LIffsd.Append(I1); + } else + { LIother.Append(I1); + } LI.Remove(it1); } // it1.More() @@ -417,9 +435,13 @@ Standard_EXPORT void FUN_orderSTATETRANSonG bool steq = (tsb1 == tsa1 && isb1 == isa1 && stab1 == staa1); if (steq) + { L1.Append(I1); + } else + { L2.Append(I1); + } it1.Next(); } // it1.More() @@ -484,7 +506,9 @@ Standard_EXPORT void FUN_resolveEUNKNOWN const TopOpeBRepDS_Transition& T1 = I1->Transition(); bool isunk = T1.IsUnknown(); if (!isunk) + { continue; + } TopOpeBRepDS_Kind GT1, ST1; int G1, S1; @@ -496,16 +520,22 @@ Standard_EXPORT void FUN_resolveEUNKNOWN bool idi = (isb1 == S1 && isa1 == S1); bool etgf = idt && idi; // edge tangent a une face en 1 point if (!etgf) + { continue; + } occ::handle cpi = MAKECPI(I1); if (cpi.IsNull()) + { continue; + } double bid; occ::handle CE = BRep_Tool::Curve(EE, bid, bid); if (CE.IsNull()) + { continue; // NYI : get points from 2d curve + } double parcpi = cpi->Parameter(); double ttb = 0.8; @@ -531,7 +561,9 @@ Standard_EXPORT void FUN_resolveEUNKNOWN PSC.StateP3DReference(Pa); TopAbs_State statea = PSC.State(); if (stateb == TopAbs_UNKNOWN || statea == TopAbs_UNKNOWN) + { continue; + } TopOpeBRepDS_Transition& newT1 = I1->ChangeTransition(); newT1.Set(stateb, statea, tsb1, tsa1); @@ -559,7 +591,9 @@ Standard_EXPORT void FUN_purgeDSonSE(const occ::handle fsdmFancSE; // --------------- @@ -572,12 +606,16 @@ Standard_EXPORT void FUN_purgeDSonSE(const occ::handle> newLI; // --------- @@ -631,9 +669,13 @@ Standard_EXPORT void FUN_purgeDSonSE(const occ::handleTransition(); bool isunk = T1.IsUnknown(); if (!isunk) + { continue; + } TopOpeBRepDS_Kind GT1, ST1; int G1, S1; @@ -291,7 +315,9 @@ Standard_EXPORT void FUN_resolveFUNKNOWN bool idi = (isb1 == S1 && isa1 == S1); bool etgf = idt && idi; // face tangent a une face en 1 edge if (!etgf) + { continue; + } const TopoDS_Edge& EE = TopoDS::Edge(BDS.Shape(G1)); double fE, lE; @@ -299,7 +325,9 @@ Standard_EXPORT void FUN_resolveFUNKNOWN occ::handle fei = MAKEFEI(I1); if (fei.IsNull()) + { continue; + } const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S1)); @@ -326,7 +354,9 @@ Standard_EXPORT void FUN_resolveFUNKNOWN { EEsp = TopoDS::Edge(los.First()); if (!EEsp.IsSame(EE)) + { isEEGB = false; + } if (n > 1) { // MSV: treat the case of multiple splits: @@ -352,8 +382,12 @@ Standard_EXPORT void FUN_resolveFUNKNOWN } bool isSO = true; if (!EEsp.IsSame(EE)) + { if (!FUN_tool_curvesSO(EEsp, EE, isSO)) + { continue; + } + } TopAbs_State stateb, statea; TopOpeBRepDS_Transition T; @@ -383,7 +417,9 @@ Standard_EXPORT void FUN_resolveFUNKNOWN FUN_UNKFstasta(FF, FS, EEsp, isEEGB, stateb, statea, pClass); } if (stateb == TopAbs_UNKNOWN || statea == TopAbs_UNKNOWN) + { continue; + } TopOpeBRepDS_Transition& newT1 = I1->ChangeTransition(); if (!isSO) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessInterferencesTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessInterferencesTool.cxx index 545b3aae37..0104a23916 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessInterferencesTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_ProcessInterferencesTool.cxx @@ -129,7 +129,9 @@ Standard_EXPORT int FUN_selectTRASHAinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -144,7 +146,9 @@ Standard_EXPORT int FUN_selectITRASHAinterference NCollection_List>& L2) { if (Index == 0) + { return 0; + } NCollection_List>::Iterator it1(L1); while (it1.More()) { @@ -157,7 +161,9 @@ Standard_EXPORT int FUN_selectITRASHAinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -182,7 +188,9 @@ Standard_EXPORT int FUN_selectTRAUNKinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -209,7 +217,9 @@ Standard_EXPORT int FUN_selectTRAORIinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -232,7 +242,9 @@ Standard_EXPORT int FUN_selectGKinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -256,7 +268,9 @@ Standard_EXPORT int FUN_selectSKinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -271,7 +285,9 @@ Standard_EXPORT int FUN_selectGIinterference NCollection_List>& L2) { if (GI == 0) + { return 0; + } NCollection_List>::Iterator it1(L1); while (it1.More()) { @@ -282,7 +298,9 @@ Standard_EXPORT int FUN_selectGIinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -297,7 +315,9 @@ Standard_EXPORT int FUN_selectSIinterference NCollection_List>& L2) { if (SI == 0) + { return 0; + } NCollection_List>::Iterator it1(L1); while (it1.More()) { @@ -308,7 +328,9 @@ Standard_EXPORT int FUN_selectSIinterference L1.Remove(it1); } else + { it1.Next(); + } } int n2 = L2.Extent(); return n2; @@ -435,10 +457,14 @@ Standard_EXPORT void FUN_reducedoublons { onvclo = vG.IsSame(vG); if (hasOO && !onvclo) + { onvclo = vG.IsSame(OOv); + } } if (onvclo) + { idT = true; + } else { // xpu100697 : if interf are EVI compare parameters @@ -458,10 +484,14 @@ Standard_EXPORT void FUN_reducedoublons LI.Remove(it2); } else + { it2.Next(); + } } else + { it2.Next(); + } } it1.Next(); } // it1.More() @@ -491,7 +521,9 @@ Standard_EXPORT void FUN_unkeepUNKNOWN LI.Remove(it1); } else + { it1.Next(); + } } // it1.More() } // unkeepUNKNOWN @@ -508,7 +540,9 @@ static int FUN_select3dI(const int int n3d = 0; int nFE = lFE.Extent(); if (nFE <= 1) + { return n3d; + } const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX)); int rankE = BDS.AncestorRank(E); @@ -538,9 +572,13 @@ static int FUN_select3dI(const int NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else + { break; + } // , if (vertex1) @@ -556,7 +594,9 @@ static int FUN_select3dI(const int else // vG on E { if (G1hsd) + { OOv = BDS.Shape(OOG); + } Gsta = G1hsd ? 3 : 1; } } @@ -573,7 +613,9 @@ static int FUN_select3dI(const int bool sameG = (GT2 == GT1); if (!sameG) + { break; + } sameG = (G2 == G1) || (G2 == OOG); const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(IB1)); @@ -635,7 +677,9 @@ static int FUN_select3dI(const int complex3d = true; } else + { it2.Next(); + } } // it2(it1); if (complex3d) @@ -644,7 +688,9 @@ static int FUN_select3dI(const int lFE.Remove(it1); } else + { it1.Next(); + } } // it1(lFE); // xpu170898 : cto009H1 (I1(T1(F),G,S1),I1'(T2(F),G,S2), I2) @@ -652,7 +698,9 @@ static int FUN_select3dI(const int n3d = l3dFE.Extent(); int nresi = lFEresi.Extent(); if (nresi == 0) + { return n3d; + } if (n3d != 0) { @@ -666,13 +714,19 @@ static int FUN_select3dI(const int NCollection_List> lfound; int nfound = FUN_selectITRASHAinterference(lcopy, TRA, lfound); if (nfound == 0) + { lFE.Remove(it); + } else + { it.Next(); + } } } else + { lFE.Append(lFEresi); + } return n3d; } @@ -704,9 +758,13 @@ static bool FUN_find3dISEsameISF( bool sameT = (SB1 == SB2) && (IB1 == IB2) && (O1 == O2); bool sameG = (GT1 == GT2) && (G1 == G2); if (sameT && sameG) + { return true; + } else + { it2.Next(); + } } // it2 return false; } @@ -772,9 +830,13 @@ static int FUN_select3dISEsameISF( found = FUN_find3dISEsameISF(I1, it3); if (found) + { l3dFEresi.Append(I1); + } else + { lFE.Append(I1); + } l3dFE.Remove(it1); } } // it1 @@ -796,7 +858,9 @@ Standard_EXPORT int FUN_select2dI(const int int n2d = 0; int nFE = lI.Extent(); if (nFE <= 1) + { return n2d; + } bool TonFace = (TRASHAk == TopAbs_FACE); @@ -808,7 +872,9 @@ Standard_EXPORT int FUN_select2dI(const int FUN_selectSKinterference(lIE, TopOpeBRepDS_FACE, l3dF); for (NCollection_List>::Iterator itt(l3dF); itt.More(); itt.Next()) + { mapftra.Add(itt.Value()->Support()); + } NCollection_List> lII; NCollection_List>::Iterator it1(lI); while (it1.More()) @@ -846,9 +912,13 @@ Standard_EXPORT int FUN_select2dI(const int bool complex2d = false; NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else + { break; + } while (it2.More()) { const occ::handle& I2 = it2.Value(); @@ -888,7 +958,9 @@ Standard_EXPORT int FUN_select2dI(const int lII.Remove(it2); } else + { it2.Next(); + } } // it2 if (complex2d) { @@ -896,7 +968,9 @@ Standard_EXPORT int FUN_select2dI(const int lII.Remove(it1); } else + { it1.Next(); + } } // it1 lI.Append(lII); n2d = l2dI.Extent(); @@ -964,7 +1038,9 @@ Standard_EXPORT int FUN_select1dI(const int int n1d = 0; int nFE = LI.Extent(); if (nFE <= 1) + { return n1d; + } NCollection_List> newLI; const TopoDS_Shape& EIX = BDS.Shape(SIX); @@ -1016,9 +1092,13 @@ Standard_EXPORT int FUN_select1dI(const int bool complex1d = false; NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else + { break; + } while (it2.More()) { const occ::handle& I2 = it2.Value(); @@ -1053,7 +1133,9 @@ Standard_EXPORT int FUN_select1dI(const int it1.Next(); } else + { it1.Next(); + } } // it1 } // tki LI.Clear(); @@ -1078,7 +1160,9 @@ Standard_EXPORT void FUN_select3dinterference( const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX)); bool isdg = BRep_Tool::Degenerated(E); if (isdg) + { return; + } l3dF.Clear(); l3dFE.Clear(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_SurfaceExplorer.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_SurfaceExplorer.cxx index 4ee74e3287..25cbceb325 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_SurfaceExplorer.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_SurfaceExplorer.cxx @@ -65,9 +65,13 @@ void TopOpeBRepDS_SurfaceExplorer::Find() myFound = IsSurface(myIndex); } if (myFound) + { break; + } else + { myIndex++; + } } } @@ -114,7 +118,9 @@ bool TopOpeBRepDS_SurfaceExplorer::IsSurfaceKeep(const int I) const { bool b = MYDS.mySurfaces.IsBound(I); if (b) + { b = MYDS.Surface(I).Keep(); + } return b; } @@ -141,7 +147,9 @@ int TopOpeBRepDS_SurfaceExplorer::NbSurface() Find(); int n = 0; for (; More(); Next()) + { n++; + } return n; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TKI.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TKI.cxx index 20933b182a..ecb7d6d1db 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TKI.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TKI.cxx @@ -55,7 +55,9 @@ void TopOpeBRepDS_TKI::Reset() mydelta = f - ip; // k + mydelta = i in [f,l]; TopOpeBRepDS_POINT,SOLID + mydelta = f,l if (myT.IsNull()) + { myT = new MDShaodmoiloi(f, l); + } Clear(); myK = TopOpeBRepDS_UNKNOWN; myG = 0; @@ -67,7 +69,9 @@ void TopOpeBRepDS_TKI::Clear() { int i = myT->Lower(), n = myT->Upper(); for (; i <= n; i++) + { myT->ChangeValue(i).Clear(); + } } //================================================================================================= @@ -107,7 +111,9 @@ void TopOpeBRepDS_TKI::FillOnSupport( bool TopOpeBRepDS_TKI::IsBound(const TopOpeBRepDS_Kind K, const int G) const { if (!IsValidKG(K, G)) + { return false; + } int TI = KindToTableIndex(K); bool in = myT->Value(TI).IsBound(G); return in; @@ -122,7 +128,9 @@ const NCollection_List>& TopOpeBRepDS_TKI bool in = IsBound(K, G); int TI = KindToTableIndex(K); if (in) + { return myT->Value(TI).Find(G); + } return myEmptyLOI; } @@ -135,7 +143,9 @@ NCollection_List>& TopOpeBRepDS_TKI::Chan bool in = IsBound(K, G); int TI = KindToTableIndex(K); if (in) + { return myT->ChangeValue(TI).ChangeFind(G); + } return myEmptyLOI; } @@ -168,7 +178,9 @@ void TopOpeBRepDS_TKI::Add(const TopOpeBRepDS_Kind K, const int G) int TI = KindToTableIndex(K); NCollection_List> thelist; if (!in) + { myT->ChangeValue(TI).Bind(G, thelist); + } } //================================================================================================= @@ -179,7 +191,9 @@ void TopOpeBRepDS_TKI::Add(const TopOpeBRepDS_Kind K, { bool ok = IsValidKG(K, G); if (!ok) + { throw Standard_ProgramError("TopOpeBRepDS_TKI : Add K G HI"); + } Add(K, G); ChangeInterferences(K, G).Append(HI); @@ -210,7 +224,9 @@ void TopOpeBRepDS_TKI::Init() myK = TopOpeBRepDS_UNKNOWN; myG = 0; if (myT.IsNull()) + { return; + } myTI = myT->Lower(); myK = TableIndexToKind(myTI); myITM.Initialize(myT->Value(myTI)); @@ -252,7 +268,9 @@ const NCollection_List>& TopOpeBRepDS_TKI int& G) const { if (!More()) + { return myEmptyLOI; + } K = myK; G = myG; return Interferences(K, G); @@ -265,7 +283,9 @@ NCollection_List>& TopOpeBRepDS_TKI::Chan int& G) { if (!More()) + { return myEmptyLOI; + } K = myK; G = myG; return ChangeInterferences(K, G); @@ -305,9 +325,13 @@ void TopOpeBRepDS_TKI::FindITM() myG = myITM.Key(); f = HasInterferences(myK, myG); if (f) + { break; + } else + { myITM.Next(); + } } } @@ -316,7 +340,9 @@ void TopOpeBRepDS_TKI::FindITM() void TopOpeBRepDS_TKI::NextITM() { if (!MoreITM()) + { return; + } myITM.Next(); FindITM(); } @@ -333,10 +359,14 @@ void TopOpeBRepDS_TKI::Find() FindITM(); f = HasInterferences(myK, myG); if (f) + { break; + } } if (f) + { break; + } else { NextTI(); @@ -371,7 +401,9 @@ TopOpeBRepDS_Kind TopOpeBRepDS_TKI::TableIndexToKind(const int TI) const bool TopOpeBRepDS_TKI::IsValidTI(const int TI) const { if (myT.IsNull()) + { return false; + } bool nok = (TI < myT->Lower() || TI > myT->Upper()); return !nok; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TOOL.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TOOL.cxx index deb5e033b6..5d6d851a36 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TOOL.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_TOOL.cxx @@ -61,9 +61,13 @@ static void FDS_sortGb(const occ::handle& } if (gb1) + { LIGb1.Append(I); + } else + { LIGb0.Append(I); + } } // it(LI) } @@ -85,10 +89,14 @@ int TopOpeBRepDS_TOOL::EShareG(const occ::handle& H { bool hsd = HDS->HasSameDomain(E); if (!hsd) + { return 0; + } NCollection_List::Iterator itsd(HDS->SameDomain(E)); for (; itsd.More(); itsd.Next()) + { lEsd.Append(itsd.Value()); + } return lEsd.Extent(); } @@ -99,18 +107,24 @@ int TopOpeBRepDS_TOOL::EShareG(const occ::handle& H NCollection_List> L1d; int n1d = FUN_selectTRASHAinterference(LII, TopAbs_EDGE, L1d); if (n1d == 0) + { return 0; + } NCollection_Map mapesd; NCollection_List> l1gb0, l1gb1, l1gbsd; FDS_sortGb(HDS, L1d, l1gb0, l1gb1, l1gbsd); NCollection_List>::Iterator it0(l1gb0); for (; it0.More(); it0.Next()) + { mapesd.Add(BDS.Shape(it0.Value()->Support())); + } NCollection_List>::Iterator it1(l1gb1); for (; it1.More(); it1.Next()) + { mapesd.Add(BDS.Shape(it1.Value()->Support())); + } NCollection_List>::Iterator itsd(l1gbsd); for (; itsd.More(); itsd.Next()) @@ -119,14 +133,18 @@ int TopOpeBRepDS_TOOL::EShareG(const occ::handle& H const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(I->Support())); bool isb = mapesd.Contains(Esd); if (isb) + { continue; + } int G = I->Geometry(); const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G)); TopoDS_Vertex vsd; bool ok = FUN_ds_getoov(vG, BDS, vsd); if (!ok) + { continue; + } bool Gb1 = occ::down_cast(I)->GBound(); TopoDS_Vertex vE = Gb1 ? vG : vsd; TopoDS_Vertex vEsd = Gb1 ? vsd : vG; @@ -135,12 +153,16 @@ int TopOpeBRepDS_TOOL::EShareG(const occ::handle& H gp_Vec tgE; ok = TopOpeBRepTool_TOOL::TgINSIDE(vE, E, tgE, ovE); if (!ok) + { continue; + } int ovEsd; gp_Vec tgEsd; ok = TopOpeBRepTool_TOOL::TgINSIDE(vEsd, Esd, tgEsd, ovEsd); if (!ok) + { continue; + } bool inE = (ovE == CLOSING) || (ovE == INTERNAL); bool inEsd = (ovEsd == CLOSING) || (ovEsd == INTERNAL); if (inE || inEsd) @@ -150,11 +172,15 @@ int TopOpeBRepDS_TOOL::EShareG(const occ::handle& H } double dot = gp_Dir(tgE).Dot(gp_Dir(tgEsd)); if (dot > 0.) + { mapesd.Add(Esd); + } } NCollection_Map::Iterator itm(mapesd); for (; itm.More(); itm.Next()) + { lEsd.Append(itm.Key()); + } return (lEsd.Extent()); } @@ -169,13 +195,17 @@ bool TopOpeBRepDS_TOOL::ShareG(const occ::handle& H bool hsd1 = HDS->HasSameDomain(s1); if (!hsd1) + { return false; + } NCollection_List::Iterator it1(HDS->SameDomain(s1)); for (; it1.More(); it1.Next()) { bool same = it1.Value().IsSame(s2); if (!same) + { continue; + } return true; } return false; @@ -198,10 +228,14 @@ bool TopOpeBRepDS_TOOL::GetEsd(const occ::handle& H const TopoDS_Shape& e = ex.Current(); bool hs = HDS->HasShape(e); if (!hs) + { continue; + } bool hsd = HDS->HasSameDomain(e); if (!hsd) + { continue; + } mesdS.Add(e); // NCollection_List::Iterator itt(HDS->SameDomain(e)); // for (; itt.More(); itt.Next()) mesdS.Add(itt.Value()); @@ -213,7 +247,9 @@ bool TopOpeBRepDS_TOOL::GetEsd(const occ::handle& H const TopoDS_Shape& esd = it.Value(); bool isb = mesdS.Contains(esd); if (!isb) + { continue; + } iesd = HDS->Shape(esd); return true; } @@ -233,7 +269,9 @@ bool TopOpeBRepDS_TOOL::ShareSplitON(const occ::handleShape(i1); const TopoDS_Shape& s2 = HDS->Shape(i2); @@ -241,24 +279,34 @@ bool TopOpeBRepDS_TOOL::ShareSplitON(const occ::handle& lsp1 = los1.ListOnState(); int nsp1 = lsp1.Extent(); if (nsp1 == 0) + { return false; + } NCollection_Map mesp1; // map of splits on of NCollection_List::Iterator it(lsp1); for (; it.More(); it.Next()) + { mesp1.Add(it.Value()); + } const TopOpeBRepDS_ListOfShapeOn1State& los2 = MEspON.Find(s2); bool issp2 = los2.IsSplit(); if (!issp2) + { return false; + } const NCollection_List& lsp2 = los2.ListOnState(); int nsp2 = lsp2.Extent(); if (nsp2 == 0) + { return false; + } it.Initialize(lsp2); for (; it.More(); it.Next()) @@ -266,7 +314,9 @@ bool TopOpeBRepDS_TOOL::ShareSplitON(const occ::handle config = 0; bool shareg = TopOpeBRepDS_TOOL::ShareG(HDS, ie, iesd); if (!shareg) + { return false; + } const TopoDS_Edge& e = TopoDS::Edge(HDS->Shape(ie)); TopAbs_Orientation oe = e.Orientation(); @@ -305,9 +357,13 @@ bool TopOpeBRepDS_TOOL::GetConfig(const occ::handle { bool sameori = (conf == confsd); if (M_REVERSED(oe)) + { sameori = !sameori; + } if (M_REVERSED(oesd)) + { sameori = !sameori; + } config = sameori ? SAMEORIENTED : DIFFORIENTED; return true; } @@ -315,7 +371,9 @@ bool TopOpeBRepDS_TOOL::GetConfig(const occ::handle TopoDS_Shape eON; shareg = TopOpeBRepDS_TOOL::ShareSplitON(HDS, MEspON, ie, iesd, eON); if (!shareg) + { return false; + } double f, l; FUN_tool_bounds(TopoDS::Edge(eON), f, l); @@ -325,16 +383,22 @@ bool TopOpeBRepDS_TOOL::GetConfig(const occ::handle double pare; bool ok = FUN_tool_parE(TopoDS::Edge(eON), parON, e, pare, tole); if (!ok) + { return false; + } double tolesd = BRep_Tool::Tolerance(TopoDS::Edge(esd)); double paresd; ok = FUN_tool_parE(TopoDS::Edge(eON), parON, esd, paresd, tolesd); if (!ok) + { return false; + } bool so; ok = FUN_tool_curvesSO(e, pare, esd, paresd, so); if (!ok) + { return false; + } config = (so) ? SAMEORIENTED : DIFFORIENTED; return true; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Transition.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Transition.cxx index f6c4d7b115..84ee8356d1 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Transition.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_Transition.cxx @@ -180,7 +180,9 @@ TopAbs_ShapeEnum TopOpeBRepDS_Transition::ShapeAfter() const int TopOpeBRepDS_Transition::Index() const { if (myIndexAfter != myIndexBefore) + { throw Standard_Failure("Transition::Index() on different shapes"); + } return myIndexBefore; } @@ -240,16 +242,24 @@ TopAbs_Orientation TopOpeBRepDS_Transition::Orientation(const TopAbs_State S if (myStateBefore == S) { if (myStateAfter == S) + { return TopAbs_INTERNAL; + } else + { return TopAbs_REVERSED; + } } else { if (myStateAfter == S) + { return TopAbs_FORWARD; + } else + { return TopAbs_EXTERNAL; + } } } } @@ -264,25 +274,39 @@ TopAbs_Orientation TopOpeBRepDS_Transition::OrientationON(const TopAbs_State S, if (myStateBefore == TopAbs_ON && myStateAfter == TopAbs_ON) { if (S == TopAbs_IN) + { result = TopAbs_INTERNAL; + } else if (S == TopAbs_OUT) + { result = TopAbs_EXTERNAL; + } else if (S == TopAbs_ON) + { result = TopAbs_INTERNAL; + } } else if (myStateBefore == TopAbs_ON) { if (myStateAfter == S) + { return TopAbs_FORWARD; + } else + { return TopAbs_REVERSED; + } } else if (myStateAfter == TopAbs_ON) { if (myStateBefore == S) + { return TopAbs_REVERSED; + } else + { return TopAbs_FORWARD; + } } return result; @@ -311,14 +335,22 @@ TopOpeBRepDS_Transition TopOpeBRepDS_Transition::Complement() const else { TopAbs_Orientation o = Orientation(TopAbs_IN); - if (o == TopAbs_FORWARD) // (OUT,IN) --> (IN,OUT) + if (o == TopAbs_FORWARD) + { // (OUT,IN) --> (IN,OUT) T.Set(TopAbs_IN, TopAbs_OUT, myShapeBefore, myShapeAfter); - else if (o == TopAbs_REVERSED) // (IN,OUT) --> (OUT,IN) + } + else if (o == TopAbs_REVERSED) + { // (IN,OUT) --> (OUT,IN) T.Set(TopAbs_OUT, TopAbs_IN, myShapeBefore, myShapeAfter); - else if (o == TopAbs_EXTERNAL) // (OUT,OUT) --> (IN,IN) + } + else if (o == TopAbs_EXTERNAL) + { // (OUT,OUT) --> (IN,IN) T.Set(TopAbs_IN, TopAbs_IN, myShapeBefore, myShapeAfter); - else if (o == TopAbs_INTERNAL) // (IN,IN) --> (OUT,OUT) + } + else if (o == TopAbs_INTERNAL) + { // (IN,IN) --> (OUT,OUT) T.Set(TopAbs_OUT, TopAbs_OUT, myShapeBefore, myShapeAfter); + } } return T; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_connex.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_connex.cxx index a0f4b7edfb..90af76ea78 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_connex.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_connex.cxx @@ -63,21 +63,33 @@ Standard_EXPORT const NCollection_List& FDSCNX_EdgeConnexityShapeI const int SI) { if (HDS.IsNull()) + { return *GLOBAL_los; + } if (!GLOBAL_FDSCNX_prepared) + { return *GLOBAL_los; + } if (SI != 1 && SI != 2) + { return *GLOBAL_los; + } const TopOpeBRepDS_DataStructure& BDS = HDS->DS(); TopAbs_ShapeEnum t = E.ShapeType(); if (t != TopAbs_EDGE) + { return *GLOBAL_los; + } bool has = FDSCNX_HasConnexFace(E, HDS); if (!has) + { return *GLOBAL_los; + } int re = BDS.AncestorRank(E); if (re == 0) + { return *GLOBAL_los; + } NCollection_DataMap, TopTools_ShapeMapHasher>* pelf = (SI == 1) ? GLOBAL_elf1 : GLOBAL_elf2; NCollection_DataMap, TopTools_ShapeMapHasher>& elf = @@ -123,28 +135,36 @@ Standard_EXPORT void FDSCNX_Prepare(const TopoDS_Shape& /*S1*/, } const TopOpeBRepDS_DataStructure& BDS = HDS->DS(); if (GLOBAL_elf1 == nullptr) + { GLOBAL_elf1 = (NCollection_DataMap< TopoDS_Shape, NCollection_List, TopTools_ShapeMapHasher>*)new NCollection_DataMap, TopTools_ShapeMapHasher>(); + } if (GLOBAL_elf2 == nullptr) + { GLOBAL_elf2 = (NCollection_DataMap< TopoDS_Shape, NCollection_List, TopTools_ShapeMapHasher>*)new NCollection_DataMap, TopTools_ShapeMapHasher>(); + } if (GLOBAL_fle == nullptr) + { GLOBAL_fle = (NCollection_DataMap< TopoDS_Shape, NCollection_List, TopTools_ShapeMapHasher>*)new NCollection_DataMap, TopTools_ShapeMapHasher>(); + } if (GLOBAL_los == nullptr) + { GLOBAL_los = (NCollection_List*)new NCollection_List(); + } GLOBAL_elf1->Clear(); GLOBAL_elf2->Clear(); GLOBAL_fle->Clear(); @@ -155,10 +175,14 @@ Standard_EXPORT void FDSCNX_Prepare(const TopoDS_Shape& /*S1*/, { const TopoDS_Shape& f = BDS.Shape(i); if (f.ShapeType() != TopAbs_FACE) + { continue; + } int rf = BDS.AncestorRank(f); if (rf == 0) + { continue; + } // BDS.Shape(f); NCollection_DataMap, TopTools_ShapeMapHasher>& fle = *GLOBAL_fle; @@ -173,7 +197,9 @@ Standard_EXPORT void FDSCNX_Prepare(const TopoDS_Shape& /*S1*/, // bool se = BDS.IsSectionEdge(TopoDS::Edge(e)); if (!se) continue; bool hs = BDS.HasShape(TopoDS::Edge(e)); if (!hs) + { continue; + } NCollection_List* aListFle = fle.ChangeSeek(f); if (aListFle == nullptr) @@ -359,7 +385,7 @@ Standard_EXPORT void FDSCNX_Dump(const occ::handle& { std::cout << "tsee f " << BDS.Shape(ils.Value()) << ";"; } - std::cout << "tsee e " << is << ";### edge " << is << " connexity" << std::endl; + std::cout << "tsee e " << is << ";### edge " << is << " connexity" << '\n'; } else if (ts == TopAbs_FACE) { @@ -386,7 +412,7 @@ Standard_EXPORT void FDSCNX_Dump(const occ::handle& { std::cout << "tsee f " << BDS.Shape(ilf.Value()) << ";"; } - std::cout << "tsee e " << ie << ";### face " << is << " connexity" << std::endl; + std::cout << "tsee e " << ie << ";### face " << is << " connexity" << '\n'; } } } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_funk.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_funk.cxx index 3660877ce1..2284f733d6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_funk.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_funk.cxx @@ -50,15 +50,21 @@ static TopAbs_State FUN_staPinF3d(const gp_Pnt& P, const TopoDS_Face& F) double d = 1.e2; bool ok = FUN_tool_projPonboundedF(P, F, UV, d); if (!ok) + { return st; + } double tolF = BRep_Tool::Tolerance(F); if (d < tolF) + { return TopAbs_IN; // TopAbs_ON; + } gp_Pnt pF; FUN_tool_value(UV, F, pF); gp_Dir ntF = FUN_tool_nggeomF(UV, F); if (F.Orientation() == TopAbs_REVERSED) + { ntF.Reverse(); + } gp_Dir PpF(gp_Vec(P, pF)); double dot = ntF.Dot(PpF); st = (dot > 0) ? TopAbs_IN : TopAbs_OUT; @@ -80,7 +86,9 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, occ::handle CEE = BRep_Tool::Curve(EE, fE, lE); if (CEE.IsNull()) + { return; // NYI : get points from 2d curve + } occ::handle SFF = BRep_Tool::Surface(FF); double ttE = 0.41237118973; @@ -91,9 +99,13 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, GeomAPI_ProjectPointOnSurf PonS(PE, SFF); if (!PonS.Extrema().IsDone()) + { return; + } if (PonS.NbPoints() == 0) + { return; + } double u, v; PonS.Parameters(1, u, v); @@ -149,7 +161,9 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, // modified by NIZHNY-MKK Mon Apr 2 15:41:31 2001.END } if (CEEFFx.IsNull()) + { return; + } TopoDS_Edge EEx; BB.MakeEdge(EEx, CEE, BRep_Tool::Tolerance(EE)); @@ -180,9 +194,13 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, double up = u; double vp = v; if (EisoV) + { up += paru; + } else if (EisoU) + { vp += parv; + } else { up += paru; @@ -194,9 +212,13 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, double um = u; double vm = v; if (EisoV) + { um -= paru; + } else if (EisoU) + { vm -= parv; + } else { um -= paru; @@ -212,19 +234,25 @@ Standard_EXPORT void FUN_UNKFstasta(const TopoDS_Face& FF, { dot = VEcroN.Dot(d1u); if (dot < 0.) + { permute = true; + } } else if (EisoU) { dot = VEcroN.Dot(d1v); if (dot < 0.) + { permute = true; + } } else { dot = VEcroN.Dot(d1v); if (dot < 0.) + { permute = true; + } } if (permute) { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_redu.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_redu.cxx index 0f7a36e3d7..63b90845c9 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_redu.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_redu.cxx @@ -76,7 +76,9 @@ Standard_EXPORT bool FUN_ds_redu2d1d( newT2d.Set(O2); bool ok2 = (IB2 == IA2) && (SB2 == TopAbs_FACE) && (GT2 == TopOpeBRepDS_VERTEX); if (!ok2) + { return false; + } const TopoDS_Edge& SE = TopoDS::Edge(BDS.Shape(ISE)); // clang-format off @@ -94,19 +96,27 @@ Standard_EXPORT bool FUN_ds_redu2d1d( double parE; bool ok = FUN_tool_parE(SE, parSE, E, parE, tolE); if (!ok) + { return false; + } gp_Pnt2d uv; ok = FUN_tool_paronEF(E, parE, F, uv, tolF); if (!ok) + { return false; + } TopOpeBRepTool_makeTransition MKT; TopAbs_State stb1 = TopAbs_UNKNOWN, sta1 = TopAbs_UNKNOWN; ok = MKT.Initialize(SE, pbef, paft, parSE, F, uv, factor); if (ok) + { ok = MKT.SetRest(E, parE); + } if (ok) + { ok = MKT.MkTonE(stb1, sta1); + } if (ok) { newT2d.Before(stb1); @@ -129,28 +139,42 @@ Standard_EXPORT bool FUN_ds_redu2d1d( int G1, S1; FDS_Idata(I1d, SB1, IB1, SA1, IA1, GT1, G1, ST1, S1); if (IB1 != IA1) + { continue; + } TopAbs_Orientation O1 = I1d->Transition().Orientation(TopAbs_IN); const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(IB1)); bool isedgeF = FUN_tool_inS(Esd, F); if (!isedgeF) + { continue; + } bool bIN = M_INTERNAL(O1) || M_REVERSED(O1); bool aIN = M_INTERNAL(O1) || M_FORWARD(O1); if (bIN && aIN) + { return false; // NYIRAISE I1d INTERNAL -> NO I2d!! + } if (bIN) + { beforeIN1d = true; + } if (aIN) + { afterIN1d = true; + } } // it1 if (beforeIN1d) + { newT2d.Before(TopAbs_IN); + } if (afterIN1d) + { newT2d.After(TopAbs_IN); + } return true; } // redu2d1d diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_repvg.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_repvg.cxx index 3173a6716a..4d5c9417a2 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_repvg.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_repvg.cxx @@ -46,7 +46,9 @@ Standard_EXPORT void FDS_repvg2(const TopOpeBRepDS_DataStructure& const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX)); bool isEd = BRep_Tool::Degenerated(E); if (isEd) + { return; + } bool ispoint = (GT == TopOpeBRepDS_POINT); bool isvertex = (GT == TopOpeBRepDS_VERTEX); @@ -99,11 +101,17 @@ Standard_EXPORT void FDS_repvg2(const TopOpeBRepDS_DataStructure& TopOpeBRepDS_Point PDS; TopoDS_Shape VDS; if (ispoint) + { PDS = BDS.Point(G1); + } else if (isvertex) + { VDS = BDS.Shape(G1); + } else + { throw Standard_Failure("TopOpeBRepDS FDS_repvg2 1"); + } bool isEd1 = BRep_Tool::Degenerated(E1); if (isEd1) @@ -113,7 +121,9 @@ Standard_EXPORT void FDS_repvg2(const TopOpeBRepDS_DataStructure& } NCollection_List>::Iterator it2(it1); if (it2.More()) + { it2.Next(); + } else { it1.Next(); @@ -180,17 +190,25 @@ Standard_EXPORT void FDS_repvg2(const TopOpeBRepDS_DataStructure& isComplex = true; EITool.Init(E, I1); if (ispoint) + { EITool.Add(E, PDS, I1); + } else if (isvertex) + { EITool.Add(E1, VDS, I1); + } } // !isComplex && !memeS if (isComplex && !memeS) { if (ispoint) + { EITool.Add(E, PDS, I2); + } else if (isvertex) + { EITool.Add(E2, VDS, I2); + } LI.Remove(it2); } // (isComplex && !memeS) @@ -250,7 +268,9 @@ Standard_EXPORT void FDS_repvg(const TopOpeBRepDS_DataStructure& mapITRASHA.Bind(isa, loi); } else + { mapITRASHA.ChangeFind(isa).Append(I); + } it.Next(); } @@ -262,7 +282,9 @@ Standard_EXPORT void FDS_repvg(const TopOpeBRepDS_DataStructure& NCollection_List>& loi = mapITRASHA.ChangeFind(isa); int nloi = loi.Extent(); if (nloi < 2) + { continue; + } NCollection_List> rloi; FDS_repvg2(BDS, EIX, GT, loi, rloi); LOI.Append(loi); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_samdom.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_samdom.cxx index d2461ab820..4dec21a1ed 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_samdom.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepDS/TopOpeBRepDS_samdom.cxx @@ -80,12 +80,18 @@ Standard_EXPORT void FDSSDM_prepare(const occ::handleShape(i); bool hsd = HDS->HasSameDomain(s); if (!hsd) + { continue; + } NCollection_List thelist, thelist1; if (!Gps1->Contains(s)) + { Gps1->Add(s, thelist); + } if (!Gps2->Contains(s)) + { Gps2->Add(s, thelist1); + } NCollection_List& LS1 = Gps1->ChangeFromKey(s); NCollection_List& LS2 = Gps2->ChangeFromKey(s); FDSSDM_makes1s2(s, LS1, LS2); @@ -168,7 +174,9 @@ Standard_EXPORT void FDSSDM_s1s2makesordor(const NCollection_List& // modified by NIZNHY-PKV Sun Dec 15 17:59:43 2002 t NCollection_List::Iterator it(LS1); if (!it.More()) + { return; + } const TopoDS_Shape& sref = it.Value(); HDS->SameDomainReference(sref); TopOpeBRepDS_Config oref = HDS->SameDomainOrientation(sref); @@ -179,9 +187,13 @@ Standard_EXPORT void FDSSDM_s1s2makesordor(const NCollection_List& TopOpeBRepDS_Config o = HDS->SameDomainOrientation(s); // HDS->Shape(s); if (o == oref && !FDSSDM_contains(s, LSO)) + { LSO.Append(s); + } else if (o != oref && !FDSSDM_contains(s, LDO)) + { LDO.Append(s); + } } for (it.Initialize(LS2); it.More(); it.Next()) @@ -190,9 +202,13 @@ Standard_EXPORT void FDSSDM_s1s2makesordor(const NCollection_List& TopOpeBRepDS_Config o = HDS->SameDomainOrientation(s); // HDS->Shape(s); if (o == oref && !FDSSDM_contains(s, LSO)) + { LSO.Append(s); + } else if (o != oref && !FDSSDM_contains(s, LDO)) + { LDO.Append(s); + } } } // s1s2makesordor @@ -241,7 +257,9 @@ Standard_EXPORT bool FDSSDM_contains(const TopoDS_Shape& S, const NCollection_Li const TopoDS_Shape& SL = it.Value(); bool issame = SL.IsSame(S); if (issame) + { return true; + } } return false; } // contains diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_2d.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_2d.cxx index fe3dc1702c..d3f8d663d0 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_2d.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_2d.cxx @@ -61,9 +61,11 @@ Standard_EXPORT occ::handle MakePCurve(const ProjLib_ProjectedCurv static const TopoDS_Face& FC2D_FancestorE(const TopoDS_Edge& E) { if (GLOBAL_pmosloc2df == nullptr) + { GLOBAL_pmosloc2df = new NCollection_DataMap, TopTools_ShapeMapHasher>(); + } int ancemp = (*GLOBAL_pidmoslosc2df).Extent(); if (ancemp == 0) { @@ -78,10 +80,14 @@ static const TopoDS_Face& FC2D_FancestorE(const TopoDS_Edge& E) } bool Eb = (*GLOBAL_pidmoslosc2df).Contains(E); if (!Eb) + { return *GLOBAL_pFc2df; + } const NCollection_List& lf = (*GLOBAL_pidmoslosc2df).FindFromKey(E); if (lf.IsEmpty()) + { return *GLOBAL_pFc2df; + } const TopoDS_Face& F = TopoDS::Face(lf.First()); return F; } @@ -90,28 +96,38 @@ static const TopoDS_Face& FC2D_FancestorE(const TopoDS_Edge& E) Standard_EXPORT int FC2D_Prepare(const TopoDS_Shape& S1, const TopoDS_Shape& S2) { if (GLOBAL_pmosloc2df == nullptr) + { GLOBAL_pmosloc2df = new NCollection_DataMap, TopTools_ShapeMapHasher>(); + } GLOBAL_pmosloc2df->Clear(); GLOBAL_C2D_i = 0; if (GLOBAL_pidmoslosc2df == nullptr) + { GLOBAL_pidmoslosc2df = new NCollection_IndexedDataMap, TopTools_ShapeMapHasher>(); + } GLOBAL_pidmoslosc2df->Clear(); if (GLOBAL_pFc2df == nullptr) + { GLOBAL_pFc2df = new TopoDS_Face(); + } GLOBAL_pFc2df->Nullify(); if (GLOBAL_pS1c2df == nullptr) + { GLOBAL_pS1c2df = new TopoDS_Shape(); + } *GLOBAL_pS1c2df = S1; if (GLOBAL_pS2c2df == nullptr) + { GLOBAL_pS2c2df = new TopoDS_Shape(); + } *GLOBAL_pS2c2df = S2; return 0; @@ -166,10 +182,14 @@ static TopOpeBRepTool_C2DF* FC2D_PNewCurveOnSurface(const TopoDS_Edge& E, const { TopOpeBRepTool_C2DF* pc2df = nullptr; if (GLOBAL_pmosloc2df == nullptr) + { return nullptr; + } bool Eisb = GLOBAL_pmosloc2df->IsBound(E); if (!Eisb) + { return nullptr; + } NCollection_List::Iterator it(GLOBAL_pmosloc2df->Find(E)); for (; it.More(); it.Next()) { @@ -194,7 +214,9 @@ Standard_EXPORT bool FC2D_HasNewCurveOnSurface(const TopoDS_Edge& E, const TopOpeBRepTool_C2DF* pc2df = FC2D_PNewCurveOnSurface(E, F); bool hasnew = (pc2df != nullptr); if (hasnew) + { C2D = pc2df->PC(f2d, l2d, tol); + } return hasnew; } @@ -216,10 +238,14 @@ int FC2D_AddNewCurveOnSurface(const occ::handle& C2D, const double& tol) { if (C2D.IsNull()) + { return 1; + } TopOpeBRepTool_C2DF c2df(C2D, f2d, l2d, tol, F); if (GLOBAL_pmosloc2df == nullptr) + { return 1; + } NCollection_List thelist; GLOBAL_pmosloc2df->Bind(E, thelist); NCollection_List& lc2df = GLOBAL_pmosloc2df->ChangeFind(E); @@ -244,7 +270,9 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, { occ::handle C2D = BRep_Tool::CurveOnSurface(E, F, f2d, l2d); if (!C2D.IsNull()) + { return C2D; + } // pas de 2D double f3d, l3d; @@ -257,9 +285,13 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, bool elocid = eloc.IsIdentity(); occ::handle C2; if (elocid) + { C2 = C1; + } else + { C2 = occ::down_cast(C1->Transformed(eloc.Transformation())); + } double f = 0., l = 0.; if (trim3d) { @@ -277,7 +309,9 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, // une face accedant a E : FE const TopoDS_Face& FE = FC2D_FancestorE(E); if (FE.IsNull()) + { return C2D; + } bool compminmaxUV = false; BRepAdaptor_Surface BAS(F, compminmaxUV); occ::handle BAHS = new BRepAdaptor_Surface(BAS); @@ -403,7 +437,9 @@ static void FC2D_translate(const occ::handle& C2D, { gp_Vec2d transl(1., 0.); if (isviso) + { transl = gp_Vec2d(0., 1.); + } transl.Multiply(factor); C2D->Translate(transl); } @@ -429,7 +465,9 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, { occ::handle C2D = BRep_Tool::CurveOnSurface(E, F, f2d, l2d); if (!C2D.IsNull()) + { return C2D; + } // pas de 2D double f3d, l3d; @@ -442,9 +480,13 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, bool elocid = eloc.IsIdentity(); occ::handle C2; if (elocid) + { C2 = C1; + } else + { C2 = occ::down_cast(C1->Transformed(eloc.Transformation())); + } double f = 0., l = 0.; if (trim3d) { @@ -463,7 +505,9 @@ static occ::handle FC2D_make2d(const TopoDS_Edge& E, // une face accedant a E : FE const TopoDS_Face& FE = FC2D_FancestorE(E); if (FE.IsNull()) + { return C2D; + } bool compminmaxUV = false; BRepAdaptor_Surface BAS(F, compminmaxUV); occ::handle BAHS = new BRepAdaptor_Surface(BAS); @@ -503,7 +547,9 @@ Standard_EXPORT occ::handle FC2D_CurveOnSurface(const TopoDS_Edge& bool hasold = FC2D_HasOldCurveOnSurface(E, F, C2D, f2d, l2d, tol); if (hasold) + { return C2D; + } TopOpeBRepTool_C2DF* pc2df = FC2D_PNewCurveOnSurface(E, F); if (pc2df != nullptr) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_BoxSort.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_BoxSort.cxx index a605981b95..c56a76cb9f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_BoxSort.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_BoxSort.cxx @@ -103,7 +103,9 @@ void TopOpeBRepTool_BoxSort::AddBoxes(const TopoDS_Shape& S, const TopAbs_ShapeEnum TA) { if (myHBT.IsNull()) + { myHBT = new TopOpeBRepTool_HBoxTool(); + } myHBT->AddBoxes(S, TS, TA); } @@ -120,7 +122,9 @@ void TopOpeBRepTool_BoxSort::MakeHAB(const TopoDS_Shape& S, int n = 0; TopExp_Explorer ex; for (ex.Init(S, TS, TA); ex.More(); ex.Next()) + { n++; + } myHAB = new NCollection_HArray1(0, n); NCollection_Array1& AB = myHAB->ChangeArray1(); @@ -134,7 +138,9 @@ void TopOpeBRepTool_BoxSort::MakeHAB(const TopoDS_Shape& S, const TopoDS_Shape& ss = ex.Current(); bool hb = myHBT->HasBox(ss); if (!hb) + { myHBT->AddBox(ss); + } int im = myHBT->Index(ss); const Bnd_Box& B = myHBT->Box(ss); AI.ChangeValue(i) = im; @@ -222,14 +228,18 @@ void TopOpeBRepTool_BoxSort::AddBoxesMakeCOB(const TopoDS_Shape& S, const MTClioloi& TopOpeBRepTool_BoxSort::Compare(const TopoDS_Shape& S) { if (myHBT.IsNull()) + { myHBT = new TopOpeBRepTool_HBoxTool(); + } gp_Pln P; bool isPlane = false; TopAbs_ShapeEnum t = S.ShapeType(); bool hasb = myHBT->HasBox(S); if (!hasb) + { myHBT->AddBox(S); + } myLastCompareShape = S; myLastCompareShapeBox.SetVoid(); @@ -245,7 +255,9 @@ const MTClioloi& TopOpeBRepTool_BoxSort::Compare(const TopoDS_Shape& S) GeomAbs_SurfaceType suty = GAS.GetType(); isPlane = (suty == GeomAbs_Plane); if (isPlane) + { P = GAS.Plane(); + } else { myLastCompareShapeBox = myHBT->Box(F); @@ -274,9 +286,13 @@ const MTClioloi& TopOpeBRepTool_BoxSort::Compare(const TopoDS_Shape& S) const NCollection_List* L; if (isPlane) + { L = &myBSB.Compare(P); + } else + { L = &myBSB.Compare(myLastCompareShapeBox); + } myIterator.Initialize(*L); #ifdef OCCT_DEBUG diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CLASSI.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CLASSI.cxx index f69e84a980..6d8041fa24 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CLASSI.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CLASSI.cxx @@ -65,11 +65,15 @@ bool TopOpeBRepTool_CLASSI::HasInit2d() const bool TopOpeBRepTool_CLASSI::Add2d(const TopoDS_Shape& S) { if (!HasInit2d()) + { return false; + } bool isb = mymapsbox2d.Contains(S); if (isb) + { return true; + } Bnd_Box2d B2d; TopExp_Explorer exe(S, TopAbs_EDGE); @@ -80,7 +84,9 @@ bool TopOpeBRepTool_CLASSI::Add2d(const TopoDS_Shape& S) bool haspc = FC2D_HasCurveOnSurface(E, myFref); if (!haspc) + { return false; + } BRepAdaptor_Curve2d BC2d(E, myFref); double tol2d = BC2d.Resolution(tolE); BndLib_Add2dCurve::Add(BC2d, tol2d, B2d); @@ -95,9 +101,13 @@ bool TopOpeBRepTool_CLASSI::GetBox2d(const TopoDS_Shape& S, Bnd_Box2d& B2d) { bool isb = mymapsbox2d.Contains(S); if (!isb) + { isb = Add2d(S); + } if (!isb) + { return false; + } B2d = mymapsbox2d.FindFromKey(S); return true; } @@ -112,23 +122,33 @@ int TopOpeBRepTool_CLASSI::ClassiBnd2d(const TopoDS_Shape& S1, NCollection_Array1 B(1, 2); bool isb = mymapsbox2d.Contains(S1); if (!isb) + { isb = Add2d(S1); + } if (!isb) + { return false; + } B(1) = mymapsbox2d.FindFromKey(S1); isb = mymapsbox2d.Contains(S2); if (!isb) + { isb = Add2d(S2); + } if (!isb) + { return false; + } B(2) = mymapsbox2d.FindFromKey(S2); NCollection_Array2 UV(1, 2, 1, 4); // for (int i = 1; i <= 2; i++) int i; for (i = 1; i <= 2; i++) + { // (Umin(i), Vmin(i), Umax(i), Vmax(i)) B(i).Get(UV(i, 1), UV(i, 3), UV(i, 2), UV(i, 4)); + } #ifdef OCCT_DEBUG bool trc = false; @@ -152,7 +172,9 @@ int TopOpeBRepTool_CLASSI::ClassiBnd2d(const TopoDS_Shape& S1, // chklarge = True. bool disjoint = chklarge ? (diff >= -tol) : (diff > 0.); if (disjoint) + { return DIFF; + } } } @@ -182,7 +204,9 @@ int TopOpeBRepTool_CLASSI::ClassiBnd2d(const TopoDS_Shape& S1, } if (same) + { return SAME; + } if (smaller) { int sta = (ii == 1) ? oneINtwo : twoINone; @@ -209,12 +233,18 @@ static int FUN_thegreatest(const TopoDS_Face& F1, BRepClass_FaceClassifier& clas gp_Pnt2d uv1; bool ok1 = FUN_tool_paronEF(e1, p1, F1, uv1, tolf1); if (!ok1) + { continue; + } TopAbs_State sta12 = class2.State(); if (M_IN(sta12)) + { return oneINtwo; + } else if (M_OUT(sta12)) + { return twoINone; + } } return UNKNOWN; } @@ -226,19 +256,25 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, const int stabnd2d12) { if (!HasInit2d()) + { return UNKNOWN; + } bool bnd2dUNK = (stabnd2d12 == UNKNOWN) || (stabnd2d12 == SAME); // fa1,ffi1,finite1 : TopOpeBRepTool_face fa1; bool isb1 = mymapsface.IsBound(S1); if (isb1) + { fa1 = mymapsface.Find(S1); + } else { bool ok1 = fa1.Init(TopoDS::Wire(S1), myFref); if (!ok1) + { return UNKNOWN; + } mymapsface.Bind(S1, fa1); } const TopoDS_Face& ffi1 = fa1.Ffinite(); @@ -248,12 +284,16 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, TopOpeBRepTool_face fa2; bool isb2 = mymapsface.IsBound(S2); if (isb2) + { fa2 = mymapsface.Find(S2); + } else { bool ok2 = fa2.Init(TopoDS::Wire(S2), myFref); if (!ok2) + { return UNKNOWN; + } mymapsface.Bind(S2, fa2); } const TopoDS_Face& ffi2 = fa2.Ffinite(); @@ -263,7 +303,9 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, double u1, v1; bool ok1 = BRepClass3d_SolidExplorer::FindAPointInTheFace(ffi1, u1, v1); if (!ok1) + { return UNKNOWN; + } gp_Pnt2d p2d1(u1, v1); // sta12 = status(p2d1 / ffi2) : @@ -295,22 +337,34 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, if (sta12 == TopAbs_IN) { // 2 possible states : oneINtwo || twoINone if (stabnd2d12 == oneINtwo) + { staffi12 = oneINtwo; // Bnd2d(S1) IN Bnd2d(S2) + } else if (stabnd2d12 == twoINone) + { staffi12 = twoINone; // Bnd2d(S2) IN Bnd2d(S1) + } else + { try21 = true; + } } else if (sta12 == TopAbs_OUT) { // 2 possible states : twoINone || DIFF if (stabnd2d12 == twoINone) + { staffi12 = twoINone; - // else if (stabnd2d12 == DIFF) staffi12 = DIFF; + // else if (stabnd2d12 == DIFF) staffi12 = DIFF; + } else + { try21 = true; + } } else + { return UNKNOWN; // NYIxpu140199 + } } if (try21) @@ -319,7 +373,9 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, double u2, v2; bool ok2 = BRepClass3d_SolidExplorer::FindAPointInTheFace(ffi2, u2, v2); if (!ok2) + { return UNKNOWN; + } gp_Pnt2d p2d2(u2, v2); // sta21 : @@ -330,30 +386,46 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, if (bnd2dUNK) { if (M_OUT(sta12) && M_OUT(sta21)) + { staffi12 = DIFF; + } else if (M_IN(sta12) && M_OUT(sta21)) + { staffi12 = oneINtwo; + } else if (M_OUT(sta12) && M_IN(sta21)) + { staffi12 = twoINone; + } else if (M_IN(sta12) && M_IN(sta21)) + { staffi12 = ::FUN_thegreatest(ffi1, class2); + } } else { if (sta12 == TopAbs_IN) { // 2 possible states : oneINtwo || twoINone if (sta21 == TopAbs_OUT) + { staffi12 = oneINtwo; + } } else if (sta12 == TopAbs_OUT) { // 2 possible states : twoINone || DIFF if (sta21 == TopAbs_OUT) + { staffi12 = DIFF; + } else if (sta21 == TopAbs_IN) + { staffi12 = twoINone; + } } else + { return UNKNOWN; // NYIxpu140199 + } } } // try21 @@ -361,23 +433,33 @@ int TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, if (staffi12 == DIFF) { if (finite1 && finite2) + { return DIFF; + } if (finite1 && !finite2) + { return twoINone; + } if (!finite1 && finite2) + { return oneINtwo; + } return oneINtwo; // !!!!!!! or twoINone } else if (staffi12 == oneINtwo) { if (!finite1 && !finite2) + { return twoINone; + } return oneINtwo; } else if (staffi12 == twoINone) { if (!finite1 && !finite2) + { return oneINtwo; + } return twoINone; } return UNKNOWN; @@ -389,7 +471,9 @@ bool TopOpeBRepTool_CLASSI::Getface(const TopoDS_Shape& S, TopOpeBRepTool_face& { bool isb = mymapsface.IsBound(S); if (!isb) + { return false; + } fa = mymapsface.Find(S); return true; } @@ -402,12 +486,16 @@ Standard_EXPORT void FUN_addOwlw(const TopoDS_Shape& Ow, { int nw = lw.Extent(); if (nw == 0) + { lresu.Append(Ow); + } else { NCollection_List::Iterator it(lw); for (; it.More(); it.Next()) + { lresu.Append(it.Value()); + } } } @@ -425,18 +513,24 @@ bool TopOpeBRepTool_CLASSI::Classilist( mapgreasma.Clear(); NCollection_List::Iterator anIterW(lS); for (; anIterW.More(); anIterW.Next()) + { mapgreasma.Bind(anIterW.Value(), null); + } int nw = lw.Extent(); if (nw <= 1) + { return true; + } int nite = 0, nitemax = int(nw * (nw - 1) / 2); while (nite <= nitemax) { nw = lw.Extent(); if (nw <= 1) + { break; + } // wi1 : TopoDS_Shape wi1; @@ -446,7 +540,9 @@ bool TopOpeBRepTool_CLASSI::Classilist( wi1 = itw.Value(); bool isb1 = mapgreasma.IsBound(wi1); if (!isb1) + { continue; // wi1 stored as smaller shape + } break; } @@ -454,11 +550,15 @@ bool TopOpeBRepTool_CLASSI::Classilist( { // compare wi1 with all wi(k) (k>1) bool isb1 = mapgreasma.IsBound(wi1); if (!isb1) + { break; + } itw.Next(); if (!itw.More()) + { break; + } // wi2, sta12 : int sta12 = UNKNOWN; @@ -469,7 +569,9 @@ bool TopOpeBRepTool_CLASSI::Classilist( wi2 = itw.Value(); bool isb2 = mapgreasma.IsBound(wi2); if (!isb2) + { continue; + } int stabnd2d12 = ClassiBnd2d(wi1, wi2, toluv, true); sta12 = Classip2d(wi1, wi2, stabnd2d12); @@ -503,7 +605,9 @@ bool TopOpeBRepTool_CLASSI::Classilist( // nothing's done } else + { return false; + } } // itw.More() lw.RemoveFirst(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CORRISO.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CORRISO.cxx index b4d4ca5413..b315fd9a75 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CORRISO.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CORRISO.cxx @@ -133,7 +133,9 @@ bool TopOpeBRepTool_CORRISO::Init(const TopoDS_Shape& S) myVEds.Clear(); if (S.IsNull()) + { return false; + } myS = S; TopExp_Explorer ex(S, TopAbs_EDGE); @@ -155,9 +157,13 @@ bool TopOpeBRepTool_CORRISO::Init(const TopoDS_Shape& S) bool hasold = FC2D_HasOldCurveOnSurface(E, myFref, PC); PC = FC2D_EditableCurveOnSurface(E, myFref, f, l, tol); if (!hasold) + { FC2D_AddNewCurveOnSurface(PC, E, myFref, f, l, tol); + } if (PC.IsNull()) + { return false; + } TopOpeBRepTool_C2DF C2DF(PC, f, l, tol, myFref); myERep2d.Bind(E, C2DF); @@ -172,7 +178,9 @@ bool TopOpeBRepTool_CORRISO::Init(const TopoDS_Shape& S) #endif bool isb = myVEds.IsBound(v); if (isb) + { myVEds.ChangeFind(v).Append(E); + } else { NCollection_List loe; @@ -204,7 +212,9 @@ bool TopOpeBRepTool_CORRISO::UVRep(const TopoDS_Edge& E, TopOpeBRepTool_C2DF& C2 { bool isb = myERep2d.IsBound(E); if (!isb) + { return false; + } C2DF = myERep2d.Find(E); return true; @@ -216,7 +226,9 @@ bool TopOpeBRepTool_CORRISO::SetUVRep(const TopoDS_Edge& E, const TopOpeBRepTool { bool isb = myERep2d.IsBound(E); if (!isb) + { return false; + } myERep2d.ChangeFind(E) = C2DF; return true; @@ -229,7 +241,9 @@ bool TopOpeBRepTool_CORRISO::Connexity(const TopoDS_Vertex& V, { bool isb = myVEds.IsBound(V); if (!isb) + { return false; + } Eds = myVEds.Find(V); return true; @@ -242,7 +256,9 @@ bool TopOpeBRepTool_CORRISO::SetConnexity(const TopoDS_Vertex& { bool isb = myVEds.IsBound(V); if (!isb) + { return false; + } myVEds.ChangeFind(V) = Eds; return true; @@ -303,14 +319,18 @@ bool TopOpeBRepTool_CORRISO::PurgeFyClosingE(const NCollection_List mapcl; NCollection_List::Iterator itce(ClEds); for (; itce.More(); itce.Next()) + { mapcl.Add(itce.Value()); + } //* one closing edge should be removed itce.Initialize(ClEds); NCollection_DataMap fyceds; bool found = EdgesWithFaultyUV(ClEds, 3, fyceds); if (!found) + { return false; + } if (fyceds.Extent() == 1) { // ivf == 3 : cto016G* @@ -334,7 +354,9 @@ bool TopOpeBRepTool_CORRISO::PurgeFyClosingE(const NCollection_List xfirst + xperiod + tolx); if (toosmall) + { recadre = INCREASE; + } if (tobig) + { recadre = DECREASE; + } return recadre; } // inX bool inY = (onU && isov) || ((!onU) && isou); // inY = !inX @@ -797,11 +869,17 @@ bool TopOpeBRepTool_CORRISO::EdgesOUTofBoundsUV(const NCollection_List vEs(1, 2); TopOpeBRepTool_TOOL::Vertices(E, vEs); @@ -851,7 +931,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault TopOpeBRepTool_C2DF C2DF; bool isb = UVRep(E, C2DF); if (!isb) + { return false; // NYIRAISE + } gp_Pnt2d UVvE = TopOpeBRepTool_TOOL::UVF(parvE, C2DF); #ifdef OCCT_DEBUG // recall in one wire, there are 2 vertices for one non-degenerated closing edge @@ -891,9 +973,13 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault #endif if (e.IsSame(E)) + { continue; + } if (M_INTERNAL(oe) || M_EXTERNAL(oe)) + { continue; + } bool isBound = myERep2d.IsBound(e); if (!isBound) @@ -910,7 +996,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault const TopoDS_Vertex& ve = TopoDS::Vertex(ves(ive)); bool samev = ve.IsSame(vE); if (!samev) + { continue; + } double pare = TopOpeBRepTool_TOOL::ParE(ive, e); gp_Pnt2d UVve = TopOpeBRepTool_TOOL::UVF(pare, aC2DF); @@ -922,7 +1010,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault } #endif if (ive == ivE) + { continue; + } double tttolve = BRep_Tool::Tolerance(ve); double tttuvve = std::max(Tol(1, tttolve), Tol(2, tttolve)); @@ -944,7 +1034,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault } } // ive if (vEok) + { break; + } } // ite(loe) if (!vEok) @@ -961,7 +1053,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const TopoDS_Edge& E, int& Ivfault } // ivE = 1..2 if (nfyv == 2) + { Ivfaulty = 3; + } #ifdef OCCT_DEBUG if (trc) { @@ -1003,7 +1097,9 @@ bool TopOpeBRepTool_CORRISO::EdgesWithFaultyUV(const NCollection_List 0); + } if (found) { FyEds.Bind(Echk, Ivfaulty); if (stopatfirst) + { return true; + } } } // itchk int n = FyEds.Extent(); // DEB @@ -1042,7 +1146,9 @@ bool TopOpeBRepTool_CORRISO::EdgeWithFaultyUV(const NCollection_List FyEds; bool found = EdgesWithFaultyUV(EdsToCheck, nfybounds, FyEds, true); if (!found) + { return false; + } NCollection_DataMap::Iterator itm(FyEds); fyE = itm.Key(); @@ -1061,7 +1167,9 @@ bool TopOpeBRepTool_CORRISO::TrslUV(const bool double uper; Refclosed(1, uper); if (!uper) + { return false; + } tt2d = gp_Vec2d(uper, 0.); } else @@ -1069,7 +1177,9 @@ bool TopOpeBRepTool_CORRISO::TrslUV(const bool double vper; Refclosed(2, vper); if (!vper) + { return false; + } tt2d = gp_Vec2d(0., vper); } NCollection_DataMap::Iterator itm(FyEds); @@ -1079,17 +1189,27 @@ bool TopOpeBRepTool_CORRISO::TrslUV(const bool TopOpeBRepTool_C2DF C2DF; bool isb = UVRep(E, C2DF); if (!isb) + { return false; + } int itt = itm.Value(); if (itt == SPLITEDGE) + { return false; + } else if (itt == INCREASE) + { TopOpeBRepTool_TOOL::TrslUV(tt2d, C2DF); + } else if (itt == DECREASE) + { TopOpeBRepTool_TOOL::TrslUV(tt2d.Multiplied(-1.), C2DF); + } else + { return false; + } SetUVRep(E, C2DF); } return true; @@ -1116,7 +1236,9 @@ bool TopOpeBRepTool_CORRISO::GetnewS(TopoDS_Face& newS) const { newS.Nullify(); if (myS.ShapeType() != TopAbs_FACE) + { return false; + } newS = TopoDS::Face(myS); BRep_Builder BB; @@ -1129,7 +1251,9 @@ bool TopOpeBRepTool_CORRISO::GetnewS(TopoDS_Face& newS) const TopOpeBRepTool_C2DF C2DF; bool isb = UVRep(E, C2DF); if (!isb) + { return false; + } double f, l, tol; const occ::handle& PC = C2DF.PC(f, l, tol); @@ -1151,10 +1275,14 @@ bool TopOpeBRepTool_CORRISO::GetnewS(TopoDS_Face& newS) const const occ::handle& PCrr = C2DFrr.PC(frr, lrr, tolrr); occ::handle curr = new Geom2d_TrimmedCurve(PCrr, frr, lrr); if (M_FORWARD(oriE)) + { BB.UpdateEdge(E, cu, curr, newS, tol); + } } else + { BB.UpdateEdge(E, cu, newS, tol); + } } return true; } @@ -1173,16 +1301,22 @@ bool TopOpeBRepTool_CORRISO::AddNewConnexity(const TopoDS_Vertex&, const TopoDS_ bool hasold = FC2D_HasOldCurveOnSurface(E, myFref, PC); PC = FC2D_EditableCurveOnSurface(E, myFref, f, l, tol); if (!hasold) + { FC2D_AddNewCurveOnSurface(PC, E, myFref, f, l, tol); + } if (PC.IsNull()) + { return false; + } TopOpeBRepTool_C2DF C2DF(PC, f, l, tol, myFref); myERep2d.Bind(E, C2DF); } // : if (!isb) + { myEds.Append(E); + } // : TopExp_Explorer exv(E, TopAbs_VERTEX); @@ -1191,7 +1325,9 @@ bool TopOpeBRepTool_CORRISO::AddNewConnexity(const TopoDS_Vertex&, const TopoDS_ const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current()); bool isbb = myVEds.IsBound(v); if (isbb) + { myVEds.ChangeFind(v).Append(E); + } else { NCollection_List loe; @@ -1210,7 +1346,9 @@ bool TopOpeBRepTool_CORRISO::RemoveOldConnexity(const TopoDS_Vertex&, const Topo // : bool isb = myERep2d.IsBound(E); if (isb) + { myERep2d.UnBind(E); + } // : if (isb) @@ -1224,7 +1362,9 @@ bool TopOpeBRepTool_CORRISO::RemoveOldConnexity(const TopoDS_Vertex&, const Topo break; } else + { it.Next(); + } } } @@ -1236,7 +1376,9 @@ bool TopOpeBRepTool_CORRISO::RemoveOldConnexity(const TopoDS_Vertex&, const Topo const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current()); bool isBoundV = myVEds.IsBound(v); if (!isBoundV) + { return false; + } NCollection_List& loe = myVEds.ChangeFind(v); NCollection_List::Iterator ite(loe); while (ite.More()) @@ -1248,7 +1390,9 @@ bool TopOpeBRepTool_CORRISO::RemoveOldConnexity(const TopoDS_Vertex&, const Topo break; } else + { ite.Next(); + } } } // exv return done; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx index acad1a7c25..e4c9021cd7 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_CurveTool.cxx @@ -146,7 +146,9 @@ static bool CheckApproxResults(const BRepApprox_Approx& Approx) int np = amc.NbPoles(); int nc = amc.NbCurves(); if (np < 2 || nc < 1) + { return false; + } // check the knots for coincidence const NCollection_Array1& knots = amc.Knots(); @@ -179,7 +181,9 @@ static bool CheckPCurve(const occ::handle& aPC, const TopoDS_Face& TopLoc_Location aLoc; occ::handle aSurf = BRep_Tool::Surface(aFace, aLoc); if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurf = (occ::down_cast(aSurf))->BasisSurface(); + } gp_Pnt2d pnt = aPC->Value((fp + lp) / 2); double u, v; @@ -190,7 +194,9 @@ static bool CheckPCurve(const occ::handle& aPC, const TopoDS_Face& double aPer = aSurf->UPeriod(); int nshift = (int)((u - umin) / aPer); if (u < umin + aPer * nshift) + { nshift--; + } umin += aPer * nshift; umax += aPer * nshift; } @@ -199,7 +205,9 @@ static bool CheckPCurve(const occ::handle& aPC, const TopoDS_Face& double aPer = aSurf->VPeriod(); int nshift = (int)((v - vmin) / aPer); if (v < vmin + aPer * nshift) + { nshift--; + } vmin += aPer * nshift; vmax += aPer * nshift; } @@ -211,7 +219,9 @@ static bool CheckPCurve(const occ::handle& aPC, const TopoDS_Face& pnt = aPC->Value(p); pnt.Coord(u, v); if (umin - u > tolU || u - umax > tolU || vmin - v > tolV || v - vmax > tolV) + { return false; + } } return true; } @@ -272,8 +282,12 @@ static occ::handle MakeCurve2DfromWLineApprox(const BRepApprox_App NCollection_Array1 poles2d(1, np); int nc = amc.NbCurves(); for (int ic = 1; ic <= nc; ic++) + { if (ic == CI) + { amc.Curve(ic, poles2d); + } + } const NCollection_Array1& knots = amc.Knots(); const NCollection_Array1& mults = amc.Multiplicities(); int degree = amc.Degree(); @@ -303,7 +317,9 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi // std::cout << "MakeCurves begin" << std::endl; if (!CompC3D) + { return false; + } bool CompPC1 = myGeomTool.CompPC1(); bool CompPC2 = myGeomTool.CompPC2(); @@ -360,9 +376,13 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi gp_Pnt P = PolC3D(ip); gp_Pnt2d P1, P2; if (CompPC1) + { P1 = PolPC1(ip); + } if (CompPC2) + { P2 = PolPC2(ip); + } for (ip = 2; ip <= nbpol; ip++) { @@ -389,7 +409,9 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi { double dd = 0.; if (ip < nbpol) + { dd = P.Distance(PolC3D(ip + 1)); + } if (ip < nbpol && dd < 10. * tol) { gce_MakeLin mkL(P, PolC3D(ip + 1)); @@ -403,23 +425,31 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi d1 = L1.SquareDistance(PolPC1(ip)); } else + { d1 = 0.; + } if (CompPC2) { gp_Lin2d L2 = gce_MakeLin2d(P2, PolPC2(ip + 1)); d2 = L2.SquareDistance(PolPC2(ip)); } else + { d2 = 0.; + } if (d > def || d1 > def2d || d2 > def2d) { NbPol++; P = PolC3D(ip); if (CompPC1) + { P1 = PolPC1(ip); + } if (CompPC2) + { P2 = PolPC2(ip); + } } else { @@ -432,9 +462,13 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi NbPol++; P = PolC3D(ip); if (CompPC1) + { P1 = PolPC1(ip); + } if (CompPC2) + { P2 = PolPC2(ip); + } } } else @@ -442,9 +476,13 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi NbPol++; P = PolC3D(ip); if (CompPC1) + { P1 = PolPC1(ip); + } if (CompPC2) + { P2 = PolPC2(ip); + } } } else @@ -481,26 +519,38 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi count++; Polc3d(count) = PolC3D(ip); if (CompPC1) + { Polpc1(count) = PolPC1(ip); + } if (CompPC2) + { Polpc2(count) = PolPC2(ip); + } knots(count) = count; } } Polc3d(NbPol) = PolC3D(nbpol); if (CompPC1) + { Polpc1(NbPol) = PolPC1(nbpol); + } if (CompPC2) + { Polpc2(NbPol) = PolPC2(nbpol); + } const_cast&>(C3D) = new Geom_BSplineCurve(Polc3d, knots, mults, 1); if (CompPC1) + { const_cast&>(PC1) = new Geom2d_BSplineCurve(Polpc1, knots, mults, 1); + } if (CompPC2) + { const_cast&>(PC2) = new Geom2d_BSplineCurve(Polpc2, knots, mults, 1); + } iparmax = NbPol; #ifdef IFV @@ -568,7 +618,9 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi kc = 1. / cir.Radius(); } else + { kc = 0.; + } Curvature(ic) = kc; ic = npol; @@ -586,7 +638,9 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi kc = 1. / cir.Radius(); } else + { kc = 0.; + } Curvature(1) = Curvature(npol) = kc; } else @@ -690,21 +744,29 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi C3Dnew = ::MakeCurve3DfromWLineApprox(Approx, 1); PC1new = ::MakeCurve2DfromWLineApproxAndPlane(Approx, BAS1.Plane()); if (CompPC2) + { PC2new = ::MakeCurve2DfromWLineApprox(Approx, 2); + } } else if (CompC3D && CompPC2 && BAS2.GetType() == GeomAbs_Plane) { C3Dnew = ::MakeCurve3DfromWLineApprox(Approx, 1); if (CompPC1) + { PC1new = ::MakeCurve2DfromWLineApprox(Approx, 2); + } PC2new = ::MakeCurve2DfromWLineApproxAndPlane(Approx, BAS2.Plane()); } else { if (CompC3D) + { C3Dnew = ::MakeCurve3DfromWLineApprox(Approx, 1); + } if (CompPC1) + { PC1new = ::MakeCurve2DfromWLineApprox(Approx, 2); + } if (CompPC2) { int i32 = (CompPC1) ? 3 : 2; @@ -714,19 +776,29 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi // check the pcurves relatively the faces bounds if (CompPC1) + { done = done && CheckPCurve(PC1new, TopoDS::Face(S1)); + } if (CompPC2) + { done = done && CheckPCurve(PC2new, TopoDS::Face(S2)); + } } if (!done) { if (CompC3D) + { C3Dnew.Nullify(); + } if (CompPC1) + { PC1new.Nullify(); + } if (CompPC2) + { PC2new.Nullify(); + } return false; } @@ -853,7 +925,9 @@ occ::handle TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt( // take point index as parameter : JYL 01/AUG/94 for (i = 1; i <= nbknots; i++) + { knots(i) = (double)i; + } occ::handle C = new Geom_BSplineCurve(Points, knots, mults, Degree); return C; } @@ -890,7 +964,9 @@ occ::handle TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d( // take point index as parameter : JYL 01/AUG/94 for (i = 1; i <= nbknots; i++) + { knots(i) = (double)i; + } occ::handle C = new Geom2d_BSplineCurve(Points, knots, mults, Degree); return C; } @@ -971,16 +1047,22 @@ occ::handle TopOpeBRepTool_CurveTool::MakePCurveOnFace( { bool trim = false; if (first < last) + { trim = true; + } const TopoDS_Face& F = TopoDS::Face(S); bool compminmaxUV = false; BRepAdaptor_Surface BAS(F, compminmaxUV); GeomAdaptor_Curve GAC; if (trim) + { GAC.Load(C3D, first, last); + } else + { GAC.Load(C3D); + } occ::handle BAHS = new BRepAdaptor_Surface(BAS); occ::handle BAHC = new GeomAdaptor_Curve(GAC); ProjLib_ProjectedCurve projcurv(BAHS, BAHC); @@ -1012,14 +1094,18 @@ occ::handle TopOpeBRepTool_CurveTool::MakePCurveOnFace( gp_Trsf2d aTrsf; gp_Pnt2d po(0, -M_PI / 2); if (maxcond) + { po.SetY(M_PI / 2); + } aTrsf.SetMirror(gp_Ax2d(po, gp_Dir2d(gp_Dir2d::D::X))); PCT->Transform(aTrsf); // add translation along U direction on PI gp_Vec2d vec(M_PI, 0); double UFirst = BAS.FirstUParameter(); if (u2 - UFirst - M_PI > -1e-7) + { vec.Reverse(); + } PCT->Translate(vec); C2D = PCT; // recompute the test point @@ -1037,7 +1123,9 @@ occ::handle TopOpeBRepTool_CurveTool::MakePCurveOnFace( bool maxcond = u2 - UMax > 1e-7; bool decalu = mincond || maxcond; if (decalu) + { du = (mincond) ? BAHS->UPeriod() : -BAHS->UPeriod(); + } // bool decalu = ( u2 < UMin || u2 > UMax); // if (decalu) du = ( u2 < UMin ) ? BAHS->UPeriod() : -BAHS->UPeriod(); } @@ -1049,7 +1137,9 @@ occ::handle TopOpeBRepTool_CurveTool::MakePCurveOnFace( bool maxcond = v2 - VMax > 1e-7; bool decalv = mincond || maxcond; if (decalv) + { dv = (mincond) ? BAHS->VPeriod() : -BAHS->VPeriod(); + } // bool decalv = ( v2 < VMin || v2 > VMax); // if (decalv) dv = ( v2 < VMin ) ? BAHS->VPeriod() : -BAHS->VPeriod(); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_FuseEdges.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_FuseEdges.cxx index d4bf6c24f4..eb6fdfc1fe 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_FuseEdges.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_FuseEdges.cxx @@ -249,7 +249,9 @@ void TopOpeBRepTool_FuseEdges::BuildListEdges() && (edgecur.Orientation() == TopAbs_FORWARD || edgecur.Orientation() == TopAbs_REVERSED)) { if (myAvoidEdg.Contains(edgecur)) + { continue; // edge is not allowed to be fused + } BuildListConnexEdge(edgecur, mapUniqEdg, LstEdg); if (LstEdg.Extent() > 1) { @@ -351,10 +353,14 @@ void TopOpeBRepTool_FuseEdges::BuildListResultEdges() ME.Init(ExtC, VF, VL); if (!ME.IsDone()) + { throw Standard_ConstructionError("FuseEdges : Fusion failed"); + } } else + { throw Standard_ConstructionError("FuseEdges : Fusion failed"); + } } NewEdge = ME.Edge(); @@ -364,7 +370,9 @@ void TopOpeBRepTool_FuseEdges::BuildListResultEdges() std::cout << std::endl << "FuseEdges : Updating pcurve " << std::endl; #endif if (UpdatePCurve(OldEdge, NewEdge, LmapEdg)) + { myMapEdg.Bind(iLst, NewEdge); + } } myResultEdgesDone = true; @@ -401,7 +409,9 @@ void TopOpeBRepTool_FuseEdges::Perform() { const int& iLst = itLstEdg.Key(); if (!myMapEdg.IsBound(iLst)) + { continue; + } const NCollection_List& LmapEdg = myMapLstEdg.Find(iLst); NCollection_List::Iterator itEdg; @@ -557,7 +567,9 @@ bool TopOpeBRepTool_FuseEdges::NextConnexEdge(const TopoDS_Vertex& theVertex, } if (myAvoidEdg.Contains(theEdgeConnex)) + { HasConnex = false; // edge is not allowed to be fused + } // 2nd condition if (HasConnex) @@ -593,11 +605,15 @@ bool TopOpeBRepTool_FuseEdges::NextConnexEdge(const TopoDS_Vertex& theVertex, } } else + { HasConnex = false; + } } } else + { HasConnex = false; + } return HasConnex; } @@ -621,7 +637,9 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E // modified by NIZNHY-PKV Mon Nov 15 16:24:10 1999 // degenerated edges has no 3D curve if (C1.IsNull()) + { return false; + } if (!loc.IsIdentity()) { @@ -632,7 +650,9 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E // modified by NIZNHY-PKV Mon Nov 15 16:24:38 1999 // degenerated edges has no 3D curve if (C2.IsNull()) + { return false; + } if (!loc.IsIdentity()) { @@ -922,9 +942,13 @@ bool TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge& aFFace.Orientation(TopAbs_FORWARD); occ::handle Curv2dR = BRep_Tool::CurveOnSurface(aFEdge, aFFace, cf, cl); if (Curv2d->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2d = occ::down_cast(Curv2d)->BasisCurve(); + } if (Curv2dR->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2dR = occ::down_cast(Curv2dR)->BasisCurve(); + } B.UpdateEdge(theNewEdge, Curv2d, Curv2dR, Surf, loc, BRep_Tool::Tolerance(theNewEdge)); } @@ -932,7 +956,9 @@ bool TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge& { // update the new edge if (Curv2d->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2d = occ::down_cast(Curv2d)->BasisCurve(); + } double f, l; f = Curv2d->FirstParameter(); l = Curv2d->LastParameter(); @@ -940,7 +966,9 @@ bool TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge& { occ::handle bcurve = occ::down_cast(Curv2d); if (bcurve.IsNull()) + { bcurve = new Geom2d_TrimmedCurve(Curv2d, cf, cl); + } Geom2dConvert_CompCurveToBSplineCurve Concat(bcurve); NCollection_List::Iterator iter(theLstEdg); iter.Next(); @@ -951,10 +979,14 @@ bool TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge& occ::handle C = BRep_Tool::CurveOnSurface(E, Surf, loc, first, last); occ::handle BC = occ::down_cast(C); if (BC.IsNull()) + { BC = new Geom2d_TrimmedCurve(C, first, last); + } if (!Concat.Add(BC, Precision::PConfusion())) + { // cannot merge pcurves return false; + } } Curv2d = Concat.BSplineCurve(); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_GEOMETRY.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_GEOMETRY.cxx index 7d975707e0..8e53756885 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_GEOMETRY.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_GEOMETRY.cxx @@ -36,11 +36,17 @@ Standard_EXPORT occ::handle BASISCURVE2D(const occ::handle T = C->DynamicType(); if (T == STANDARD_TYPE(Geom2d_OffsetCurve)) + { return ::BASISCURVE2D(occ::down_cast(C)->BasisCurve()); + } else if (T == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { return ::BASISCURVE2D(occ::down_cast(C)->BasisCurve()); + } else + { return C; + } } /*// ---------------------------------------------------------------------- @@ -142,9 +148,13 @@ Standard_EXPORT gp_Dir FUN_tool_ngS(const gp_Pnt2d& p2d, const occ::handleD1(x, y, p, d1u, d1v); gp_Vec ng = d1u ^ d1v; return ng; @@ -196,15 +206,25 @@ Standard_EXPORT bool FUN_quadCT(const GeomAbs_CurveType& CT) { bool isquad = false; if (CT == GeomAbs_Line) + { isquad = true; + } if (CT == GeomAbs_Circle) + { isquad = true; + } if (CT == GeomAbs_Ellipse) + { isquad = true; + } if (CT == GeomAbs_Hyperbola) + { isquad = true; + } if (CT == GeomAbs_Parabola) + { isquad = true; + } return isquad; } @@ -213,7 +233,9 @@ Standard_EXPORT bool FUN_tool_quad(const occ::handle& C3d) { occ::handle C = TopOpeBRepTool_ShapeTool::BASISCURVE(C3d); if (C.IsNull()) + { return false; + } GeomAdaptor_Curve GC(C); GeomAbs_CurveType CT = GC.GetType(); bool quad = FUN_quadCT(CT); @@ -225,20 +247,32 @@ Standard_EXPORT bool FUN_tool_quad(const occ::handle& pc) { occ::handle pcb = BASISCURVE2D(pc); // NYI TopOpeBRepTool_ShapeTool if (pcb.IsNull()) + { return false; + } Geom2dAdaptor_Curve GC2d(pcb); GeomAbs_CurveType typ = GC2d.GetType(); bool isquad = false; if (typ == GeomAbs_Line) + { isquad = true; + } if (typ == GeomAbs_Circle) + { isquad = true; + } if (typ == GeomAbs_Ellipse) + { isquad = true; + } if (typ == GeomAbs_Hyperbola) + { isquad = true; + } if (typ == GeomAbs_Parabola) + { isquad = true; + } return isquad; } @@ -247,7 +281,9 @@ Standard_EXPORT bool FUN_tool_line(const occ::handle& pc) { occ::handle pcb = BASISCURVE2D(pc); // NYI TopOpeBRepTool_ShapeTool if (pcb.IsNull()) + { return false; + } Geom2dAdaptor_Curve GC2d(pcb); GeomAbs_CurveType typ = GC2d.GetType(); @@ -258,20 +294,32 @@ Standard_EXPORT bool FUN_tool_line(const occ::handle& pc) Standard_EXPORT bool FUN_tool_quad(const occ::handle& S) { if (S.IsNull()) + { return false; + } GeomAdaptor_Surface GAS(S); GeomAbs_SurfaceType typ = GAS.GetType(); bool isquad = false; if (typ == GeomAbs_Plane) + { isquad = true; + } if (typ == GeomAbs_Cylinder) + { isquad = true; + } if (typ == GeomAbs_Cone) + { isquad = true; + } if (typ == GeomAbs_Sphere) + { isquad = true; + } if (typ == GeomAbs_Torus) + { isquad = true; + } return isquad; } @@ -284,17 +332,27 @@ Standard_EXPORT bool FUN_tool_closed(const occ::handle& S, { uperiod = vperiod = 0.; if (S.IsNull()) + { return false; + } uclosed = S->IsUClosed(); if (uclosed) + { uclosed = S->IsUPeriodic(); // xpu261098 (BUC60382) + } if (uclosed) + { uperiod = S->UPeriod(); + } vclosed = S->IsVClosed(); if (vclosed) + { vclosed = S->IsVPeriodic(); + } if (vclosed) + { vperiod = S->VPeriod(); + } bool closed = uclosed || vclosed; return closed; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_HBoxTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_HBoxTool.cxx index 9ffebcba58..0d074f67a6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_HBoxTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_HBoxTool.cxx @@ -82,7 +82,9 @@ void TopOpeBRepTool_HBoxTool::AddBox(const TopoDS_Shape& S) S.ShapeType(); bool hasb = HasBox(S); if (hasb) + { return; + } Bnd_Box B; ComputeBox(S, B); @@ -105,17 +107,27 @@ void TopOpeBRepTool_HBoxTool::ComputeBox(const TopoDS_Shape& S, Bnd_Box& B) { TopAbs_ShapeEnum t = S.ShapeType(); if (t == TopAbs_FACE) + { BRepBndLib::Add(S, B); + } else if (t == TopAbs_EDGE) + { BRepBndLib::Add(S, B); - // modified by NIZHNY-MZV Tue Sep 21 14:04:33 1999 + // modified by NIZHNY-MZV Tue Sep 21 14:04:33 1999 + } else if (t == TopAbs_SOLID) + { BRepBndLib::Add(S, B); + } else if (t == TopAbs_COMPOUND) + { BRepBndLib::Add(S, B); - // modified by NIZHNY-MZV Wed Apr 5 10:05:53 2000 + // modified by NIZHNY-MZV Wed Apr 5 10:05:53 2000 + } else if (t == TopAbs_VERTEX) + { BRepBndLib::Add(S, B); + } else { throw Standard_ProgramError("HBT::ComputeBox : invalid type"); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PROJECT.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PROJECT.cxx index 685d3fa66d..7680333225 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PROJECT.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PROJECT.cxx @@ -158,13 +158,17 @@ Standard_EXPORT bool FUN_tool_projPonC2D(const gp_Pnt& P, const TopoDS_Face& F = BAC2D.Face(); ok = FUN_tool_projPonF(P, F, P2D, dist); if (!ok) + { return false; + } Extrema_ExtPC2d ponc2d(P2D, BAC2D, pmin, pmax); ok = ponc2d.IsDone(); int nbext = ponc2d.NbExt(); if (ok) + { ok = (nbext > 0); + } if (!ok) { for (int i = 1; i <= 2; i++) @@ -236,9 +240,13 @@ Standard_EXPORT bool FUN_tool_projPonS(const gp_Pnt& P, PonS.Perform(P); // if (!PonS.Extrema().IsDone()) + { return false; + } if (PonS.NbPoints() == 0) + { return false; + } dist = PonS.LowerDistance(); double U, V; PonS.LowerDistanceParameters(U, V); @@ -261,17 +269,23 @@ Standard_EXPORT bool FUN_tool_projPonE(const gp_Pnt& P, double last = BAC.LastParameter(); bool ok = FUN_tool_projPonC(P, tole, BAC, first, last, param, dist); if (!ok) + { return false; + } double f, l; FUN_tool_bounds(E, f, l); double tolp = Precision::Parametric(Precision::Confusion()); bool onf = std::abs(f - param) < tolp; if (onf) + { param = f; + } bool onl = std::abs(l - param) < tolp; if (onl) + { param = l; + } return true; } @@ -299,10 +313,14 @@ Standard_EXPORT bool FUN_tool_projPonboundedF(const gp_Pnt& P, TopoDS_Vertex V = mv.Vertex(); BRepExtrema_ExtPF PonF(V, F); if (!PonF.IsDone()) + { return false; + } int npt = PonF.NbExt(); if (npt == 0) + { return false; + } // tri double dmin2 = 1.e14; @@ -317,7 +335,9 @@ Standard_EXPORT bool FUN_tool_projPonboundedF(const gp_Pnt& P, } } if (imin == 0) + { return false; + } double u, v; PonF.Parameter(imin, u, v); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PURGE.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PURGE.cxx index c0c98540be..6cecddc44a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PURGE.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_PURGE.cxx @@ -61,7 +61,9 @@ static void FUN_addtomap( const TopoDS_Shape& item) { if (map.IsBound(key)) + { map.ChangeFind(key).Append(item); + } else { NCollection_List los; @@ -130,16 +132,24 @@ Standard_EXPORT bool FUN_tool_ClosedW(const TopoDS_Wire& W) const TopoDS_Shape& v = exv.Current(); TopAbs_Orientation oriv = v.Orientation(); if (M_FORWARD(oriv)) + { FUN_addtomap(mapvFine, v, e); + } if (M_REVERSED(oriv)) + { FUN_addtomap(mapvRine, v, e); + } if (M_INTERNAL(oriv)) + { FUN_addtomap(mapvIine, v, e); + } } } if (mapvFine.Extent() == 0) + { return false; // empty wire + } NCollection_Map mapvok; // a vertex is found valid if is - an internal vertex @@ -174,7 +184,9 @@ Standard_EXPORT bool FUN_tool_ClosedW(const TopoDS_Wire& W) const TopoDS_Shape& vRine = itvRine.Key(); bool vok = mapvok.Contains(vRine); if (vok) + { continue; + } bool vIine = mapvIine.IsBound(vRine); if (vIine) { @@ -192,28 +204,40 @@ Standard_EXPORT bool FUN_tool_ClosedW(const TopoDS_Wire& W) nmap++; bool vFine = (nmap == 1); if (vFine) + { itvonlyFRine.Initialize(mapvonlyFine); + } else + { itvonlyFRine.Initialize(mapvonlyRine); + } for (; itvonlyFRine.More(); itvonlyFRine.Next()) { const TopoDS_Shape& vtocheck = itvonlyFRine.Key(); NCollection_List edsvFRine; if (vFine) + { edsvFRine = mapvFine.Find(vtocheck); + } else + { edsvFRine = mapvRine.Find(vtocheck); + } if (edsvFRine.Extent() > 1) + { return false; // faulty wire + } const TopoDS_Shape& e = edsvFRine.First(); TopAbs_Orientation ovori = vFine ? TopAbs_REVERSED : TopAbs_FORWARD; TopoDS_Shape ov; bool ovfound = FUN_getv(ovori, e, ov); if (!ovfound) + { return false; // faulty edge + } // is on only one edge , // is FORWARD/REVERSED in , @@ -224,30 +248,48 @@ Standard_EXPORT bool FUN_tool_ClosedW(const TopoDS_Wire& W) // and e is not oriented TopAbs_Orientation oe = e.Orientation(); if (M_FORWARD(oe) || M_REVERSED(oe)) + { return false; + } if (!mapvok.Contains(ov)) + { return false; + } bool ovIine = mapvIine.IsBound(ov); if (ovIine) + { continue; + } bool ovFine = mapvRine.IsBound(ov); if (!ovFine) + { return false; + } bool ovRine = mapvRine.IsBound(ov); if (!ovRine) + { return false; + } const NCollection_List& edsovFine = mapvFine.Find(ov); const NCollection_List& edsovRine = mapvRine.Find(ov); if (edsovFine.Extent() > 1) + { continue; + } if (edsovRine.Extent() > 1) + { continue; + } if (edsovFine.First().IsEqual(e)) + { return false; + } if (edsovRine.First().IsEqual(e)) + { return false; + } } } // nmap return true; @@ -284,7 +326,9 @@ bool TopOpeBRepTool::PurgeClosingEdges( double vperiod; bool vclosed = CORRISO.Refclosed(2, vperiod); if (!uclosed && !vclosed) + { return false; + } bool inU = uclosed; double xmin = inU ? (CORRISO.GASref().FirstUParameter()) : (CORRISO.GASref().FirstVParameter()); double xper = inU ? uperiod : vperiod; @@ -298,7 +342,9 @@ bool TopOpeBRepTool::PurgeClosingEdges( CORRISO.Init(W); bool ok = CORRISO.UVClosed(); if (ok) + { continue; + } NCollection_List cEds; NCollection_List::Iterator ite(CORRISO.Eds()); @@ -311,18 +357,26 @@ bool TopOpeBRepTool::PurgeClosingEdges( TopOpeBRepTool_C2DF C2DF; bool isb = CORRISO.UVRep(E, C2DF); if (!isb) + { return false; // NYIRAISE + } bool onclo = TopOpeBRepTool_TOOL::IsonCLO(C2DF, inU, xmin, xper, tolx); if (onclo) + { closing = true; + } } if (closing) + { cEds.Append(E); + } } int ncE = cEds.Extent(); bool nopurge = (ncE <= 1); if (nopurge) + { return true; + } // Checking NCollection_List fyEds; @@ -331,7 +385,9 @@ bool TopOpeBRepTool::PurgeClosingEdges( { NCollection_List::Iterator it(fyEds); for (; it.More(); it.Next()) + { MshNOK.Add(it.Value()); + } MshNOK.Add(W); MshNOK.Add(FF); } @@ -354,7 +410,9 @@ bool TopOpeBRepTool::PurgeClosingEdges( { bool uvclosed = FUN_tool_closedS(Fin); if (!uvclosed) + { return true; + } NCollection_List::Iterator it(LOF); for (; it.More(); it.Next()) @@ -362,7 +420,9 @@ bool TopOpeBRepTool::PurgeClosingEdges( const TopoDS_Face& FF = TopoDS::Face(it.Value()); bool ok = TopOpeBRepTool::PurgeClosingEdges(Fin, FF, MWisOld, MshNOK); if (!ok) + { return false; + } } return true; } @@ -628,7 +688,9 @@ static bool FUN_connexX(const bool onU, double xperiod; bool xclosed = CORRISO.Refclosed(Index, xperiod); if (!xclosed) + { return false; + } double xtol = CORRISO.Tol(Index, tolF); // fy has its 2 uvbounds non-connexed @@ -637,11 +699,15 @@ static bool FUN_connexX(const bool onU, int Ify = 0; bool hasfy = CORRISO.EdgeWithFaultyUV(EdstoCheck, 2, fy, Ify); if (!hasfy) + { return false; + } TopOpeBRepTool_C2DF C2DF; bool isb = CORRISO.UVRep(TopoDS::Edge(fy), C2DF); if (!isb) + { return false; // NYIRAISE + } NCollection_Array1 vfy(1, 2); TopOpeBRepTool_TOOL::Vertices(TopoDS::Edge(fy), vfy); @@ -655,7 +721,9 @@ static bool FUN_connexX(const bool onU, NCollection_List loe; isb = CORRISO.Connexity(vff, loe); if (!isb) + { return false; // FUNRAISE + } NCollection_List::Iterator ite(loe); // iteration on connex edges of vff for (; ite.More(); ite.Next()) @@ -669,13 +737,19 @@ static bool FUN_connexX(const bool onU, const TopoDS_Vertex& ve = TopoDS::Vertex(vee(ive)); bool samev = ve.IsSame(vff); if (!samev) + { continue; + } if (ive == ii) + { continue; + } TopOpeBRepTool_C2DF C2DFe; isb = CORRISO.UVRep(ee, C2DFe); if (!isb) + { return false; // FUNRAISE + } double paree = TopOpeBRepTool_TOOL::ParE(ive, ee); gp_Pnt2d uve = TopOpeBRepTool_TOOL::UVF(paree, C2DFe); @@ -683,7 +757,9 @@ static bool FUN_connexX(const bool onU, double dxx = onU ? uve.X() - uvff.X() : uve.Y() - uvff.Y(); bool isper = (std::abs(xperiod - std::abs(dxx)) < xtol); if (!isper) + { continue; + } int recadre = (dxx > 0) ? INCREASE : DECREASE; fyEds.Bind(fy, recadre); @@ -712,12 +788,16 @@ bool TopOpeBRepTool::CorrectONUVISO(const TopoDS_Face& Fin, TopoDS_Face& Fsp) bool uclosed = CORRISO.Refclosed(1, uperiod); bool vclosed = CORRISO.Refclosed(2, vperiod); if (!uclosed && !vclosed) + { return false; + } CORRISO.Init(Fsp); bool ok = CORRISO.UVClosed(); if (ok) + { return true; // Fsp is valid + } // 1. We check connexity among all edges of // if we find on edge with 2 faulty UVbounds, we try to UVconnect it. @@ -730,13 +810,19 @@ bool TopOpeBRepTool::CorrectONUVISO(const TopoDS_Face& Fin, TopoDS_Face& Fsp) NCollection_DataMap fyEds; ok = ::FUN_connexX(onU, CORRISO, Tocheck, fyEds); if (!ok) + { continue; + } ok = CORRISO.TrslUV(onU, fyEds); if (!ok) + { continue; + } ok = CORRISO.UVClosed(); if (!ok) + { continue; + } ok = CORRISO.GetnewS(Fsp); return ok; } @@ -748,19 +834,27 @@ bool TopOpeBRepTool::CorrectONUVISO(const TopoDS_Face& Fin, TopoDS_Face& Fsp) double xper = 0.; bool xclosed = CORRISO.Refclosed(i, xper); if (!xclosed) + { continue; + } double tolx = CORRISO.Tol(i, tolF); tolx *= 1.e2; // BUC60380 NCollection_DataMap FyEds; bool hasfy = CORRISO.EdgesOUTofBoundsUV(CORRISO.Eds(), onU, tolx, FyEds); if (!hasfy) + { continue; + } ok = CORRISO.TrslUV(onU, FyEds); if (!ok) + { return false; + } ok = CORRISO.UVClosed(); if (!ok) + { continue; + } ok = CORRISO.GetnewS(Fsp); return ok; } @@ -921,13 +1015,17 @@ bool TopOpeBRepTool::MakeFaces(const TopoDS_Face& Fin, const TopoDS_Edge& E = TopoDS::Edge(exe.Current()); valid = !MshNOK.Contains(E); if (!valid) + { continue; + } // BT.AddWireEdge(newWire,E); BB.Add(newWire, E); ne++; } // exe if (ne == 0) + { continue; + } bool closed = FUN_tool_ClosedW(newWire); // BT.Closed(newWire,closed); // BT.AddFaceWire(newFace,newWire); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUS.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUS.cxx index 4f7b716b48..7f505f3735 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUS.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUS.cxx @@ -208,7 +208,9 @@ bool TopOpeBRepTool_REGUS::MapS() const NCollection_List& lof = itm.Value(); int nf = lof.Extent(); if (nf > 2) + { mymapemult.Add(e); + } #ifdef OCCT_DEBUG if (trc) { @@ -286,7 +288,9 @@ bool TopOpeBRepTool_REGUS::SplitF(const TopoDS_Face& Fanc, NCollection_List::Iterator ite(eIs); @@ -327,18 +331,26 @@ bool TopOpeBRepTool_REGUS::SplitF(const TopoDS_Face& Fanc, NCollection_List nFs; bool ok = TopOpeBRepTool_REGUS::WireToFace(aFace, nWs, nFs); if (!ok) @@ -375,7 +389,9 @@ bool TopOpeBRepTool_REGUS::SplitF(const TopoDS_Face& Fanc, NCollection_List::Iterator itf(nFs); for (; itf.More(); itf.Next()) + { FSplits.Append(itf.Value().Oriented(oAnc)); + } return true; } @@ -399,7 +415,9 @@ bool TopOpeBRepTool_REGUS::SplitFaces() bool issp = TopOpeBRepTool_REGUS::SplitF(f, lfsp); if (!issp) + { continue; + } myFsplits.Bind(f, lfsp); @@ -432,7 +450,9 @@ bool TopOpeBRepTool_REGUS::SplitFaces() // int nf = lof.Extent(); if (nf > 2) + { mymapemult.Add(e); + } } // exe(fsp) } // itf(lfsp) @@ -463,7 +483,9 @@ static void FUN_update(const TopoDS_Shape& f { TopAbs_Orientation ofcur = fcur.Orientation(); if (M_INTERNAL(ofcur) || M_EXTERNAL(ofcur)) + { return; + } TopExp_Explorer exe(fcur, TopAbs_EDGE); for (; exe.More(); exe.Next()) @@ -471,17 +493,25 @@ static void FUN_update(const TopoDS_Shape& f const TopoDS_Shape& e = exe.Current(); TopAbs_Orientation oe = e.Orientation(); if (M_INTERNAL(oe) || M_EXTERNAL(oe)) + { continue; + } bool isclo = TopOpeBRepTool_TOOL::IsClosingE(TopoDS::Edge(e), TopoDS::Face(fcur)); if (isclo) + { continue; + } bool isb = edstoconnect.Contains(e); if (isb) + { edstoconnect.Remove(e); + } else + { edstoconnect.Add(e); + } } // exe } @@ -498,7 +528,9 @@ bool TopOpeBRepTool_REGUS::REGU() NCollection_List Splits; bool toregu = !mymapemult.IsEmpty() || (mynF != myoldnF); if (!toregu) + { return false; + } // purpose : myS -> {Blocks}, // a Block is a closed shell with "valid" edges. @@ -574,7 +606,9 @@ bool TopOpeBRepTool_REGUS::REGU() // ------------------ bool FINI = (nite == mynF); if (FINI) + { break; + } int advance = false; //* initializing a new Block @@ -583,7 +617,9 @@ bool TopOpeBRepTool_REGUS::REGU() { advance = InitBlock(); if (!advance) + { return false; + } } // startBlock||endBlock //* choosing next face @@ -600,9 +636,13 @@ bool TopOpeBRepTool_REGUS::REGU() { endBlock = myedstoconnect.IsEmpty() && (!startBlock); if (!endBlock) + { return false; + } else + { continue; + } } TopExp_Explorer exe(myf, TopAbs_EDGE); @@ -611,7 +651,9 @@ bool TopOpeBRepTool_REGUS::REGU() const TopoDS_Shape& e = exe.Current(); bool isb = mymapeFs.IsBound(e); if (!isb) + { continue; // ancestors faces of are stored in Blocks + } TopOpeBRepTool_TOOL::Remove(mymapeFs.ChangeFind(e), myf); } // exe @@ -629,13 +671,17 @@ bool TopOpeBRepTool_REGUS::InitBlock() { int nec = myedstoconnect.Extent(); if (nec != 0) + { return false; // should be empty + } NCollection_List eds; NCollection_DataMap, TopTools_ShapeMapHasher>:: Iterator itm(mymapeFs); for (; itm.More(); itm.Next()) + { eds.Append(itm.Key()); + } NCollection_List::Iterator ite(eds); for (; ite.More(); ite.Next()) @@ -673,7 +719,9 @@ bool TopOpeBRepTool_REGUS::NextinBlock() const TopoDS_Shape& e = exe.Current(); bool isb = myedstoconnect.Contains(e); if (isb) + { eds.Append(e); + } } // exe bool alleftouched = eds.IsEmpty(); if (alleftouched) @@ -701,7 +749,9 @@ bool TopOpeBRepTool_REGUS::NextinBlock() // myf = lof.First(); 130499 if (lof.Extent() == 1) + { myf = lof.First(); + } else { // looking for first face stored in the current block @@ -710,7 +760,9 @@ bool TopOpeBRepTool_REGUS::NextinBlock() NCollection_List::Iterator itff(mylFinBlock); NCollection_Map mapf; for (; itff.More(); itff.Next()) + { mapf.Add(itff.Value()); + } // lofc : the list of faces connexed to e in // lof : the list of untouched faces connexed to e in const NCollection_List& lofc = mymapeFsstatic.Find(e); @@ -737,7 +789,9 @@ bool TopOpeBRepTool_REGUS::NextinBlock() TopoDS_Face ffound; bool ok = NearestF(TopoDS::Edge(e), lof, ffound); if (!ok) + { return false; + } myf = ffound; } } @@ -774,13 +828,17 @@ bool TopOpeBRepTool_REGUS::NextinBlock() } #endif if (nf == 1) + { myf = lof.First(); + } else { TopoDS_Face ffound; bool ok = NearestF(TopoDS::Edge(e), lof, ffound); if (!ok) + { return false; + } myf = ffound; } #ifdef OCCT_DEBUG @@ -805,18 +863,24 @@ static bool FUN_vectors(const TopoDS_Face& f, { bool ok = TopOpeBRepTool_TOOL::tryNgApp(pare, e, f, tola, nt); if (!ok) + { return false; + } } else { gp_Vec tmp; bool ok = FUN_tool_nggeomF(pare, e, f, tmp); if (!ok) + { return false; + } nt = gp_Dir(tmp); } if (M_REVERSED(f.Orientation())) + { nt.Reverse(); + } // : bool ok = FUN_tool_getxx(f, e, pare, xx); return ok; @@ -915,9 +979,13 @@ bool TopOpeBRepTool_REGUS::NearestF(const TopoDS_Edge& e, return false; } if (itf.More()) + { itf.Next(); + } else + { return true; + } // selecting nearest face // ---------------------- @@ -939,7 +1007,9 @@ bool TopOpeBRepTool_REGUS::NearestF(const TopoDS_Edge& e, std::cout << " f" << FUN_adds(fref) << ",f" << FUN_adds(fi) << " not oppo" << std::endl; #endif if (!oppo) + { continue; + } if (angi < tola) { @@ -959,7 +1029,9 @@ bool TopOpeBRepTool_REGUS::NearestF(const TopoDS_Edge& e, << std::endl; #endif if (angi > angfound) + { continue; + } angfound = angi; ffound = fi; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUW.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUW.cxx index 10b5e14ee9..e1284cff5b 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUW.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_REGUW.cxx @@ -93,7 +93,9 @@ void FUN_tool_Add( const TopoDS_Shape& subitem) { if (map.IsBound(key)) + { map.ChangeFind(key).Append(subitem); + } else { NCollection_List los; @@ -153,7 +155,9 @@ void TopOpeBRepTool_REGUW::GetEsplits( Esplits) const { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } Esplits = myEsplits; } @@ -172,7 +176,9 @@ void TopOpeBRepTool_REGUW::GetOwNw( const { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } OwNw = myOwNw; } @@ -181,7 +187,9 @@ void TopOpeBRepTool_REGUW::GetOwNw( bool TopOpeBRepTool_REGUW::SplitEds() { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } #ifdef OCCT_DEBUG bool trc = TopOpeBRepTool_GettraceREGUFA(); if (trc) @@ -196,10 +204,14 @@ bool TopOpeBRepTool_REGUW::SplitEds() NCollection_List loe; int ni = co.IsInternal(loe); if (ni == 0) + { continue; + } NCollection_List::Iterator ite(loe); for (; ite.More(); ite.Next()) + { mehasIv.Add(ite.Value()); + } } for (i = 1; i <= mehasIv.Extent(); i++) @@ -209,17 +221,25 @@ bool TopOpeBRepTool_REGUW::SplitEds() bool issp = false; bool isdone = myEsplits.IsBound(e); if (isdone) + { splits.Assign(myEsplits.Find(e)); + } else + { issp = TopOpeBRepTool_TOOL::SplitE(e, splits); + } if (issp) + { hasnewsplits = true; + } #ifdef OCCT_DEBUG if (trc) std::cout << "e" << FUN_adds(e) << " gives splits =" << std::endl; #endif if (!(issp || isdone)) + { continue; // nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnyi + } // e gives splits = {esp has vertices {vv}} NCollection_List::Iterator ite(splits); @@ -239,7 +259,9 @@ bool TopOpeBRepTool_REGUW::SplitEds() TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(vv); bool isb = co.RemoveItem(INTERNAL, e); if (!isb) + { continue; + } int ivv = TopOpeBRepTool_TOOL::OriinSorclosed(vv, esp); co.AddItem(ivv, esp); } // exvv(exvv,VERTEX) @@ -257,7 +279,9 @@ bool TopOpeBRepTool_REGUW::SplitEds() const TopoDS_Shape& TopOpeBRepTool_REGUW::S() const { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } return myS; } @@ -281,7 +305,9 @@ bool TopOpeBRepTool_REGUW::HasInit() const void TopOpeBRepTool_REGUW::InitStep(const TopoDS_Shape& S) { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } TopoDS_Shape null; myCORRISO.Init(null); myCORRISO.Init(S); @@ -296,7 +322,9 @@ void TopOpeBRepTool_REGUW::InitStep(const TopoDS_Shape& S) bool TopOpeBRepTool_REGUW::MapS() { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } #ifdef OCCT_DEBUG bool trc = TopOpeBRepTool_GettraceREGUFA(); if (trc) @@ -350,7 +378,9 @@ bool TopOpeBRepTool_REGUW::MapS() bool isb = mymapvEds.Contains(v); TopOpeBRepTool_connexity theconnexity(v); if (!isb) + { mymapvEds.Add(v, theconnexity); + } TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v); if (isdgE) @@ -423,7 +453,9 @@ bool TopOpeBRepTool_REGUW::MapS() int nV = mymapvEds.Extent(); if (nV < 1) + { return false; + } int i; for (i = 1; i <= mymapvEds.Extent(); i++) @@ -432,11 +464,17 @@ bool TopOpeBRepTool_REGUW::MapS() const TopOpeBRepTool_connexity& co = mymapvEds(i); bool faulty = co.IsFaulty(); if (faulty) + { return false; + } bool multiple = co.IsMultiple(); if (multiple) + { if (mymapvmultiple.Add(v)) + { myListVmultiple.Append(v); + } + } } return true; } // MapS @@ -478,7 +516,9 @@ static void FUN_nextdata(const int iStep, } tg = gp_Dir2d(tg2d); if (M_REVERSED(e.Orientation())) + { tg.Reverse(); + } } //================================================================================================= @@ -486,7 +526,9 @@ static void FUN_nextdata(const int iStep, bool TopOpeBRepTool_REGUW::InitBlock() { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } #ifdef OCCT_DEBUG bool trc = TopOpeBRepTool_GettraceREGUFA(); #endif @@ -509,7 +551,9 @@ bool TopOpeBRepTool_REGUW::InitBlock() myListVmultiple.Remove(itmu); } else + { itmu.Next(); + } } // myv0 : @@ -540,7 +584,9 @@ bool TopOpeBRepTool_REGUW::InitBlock() myv0 = TopoDS::Vertex(myListVmultiple.First()); } if (myv0.IsNull()) + { return false; + } // myed : const TopOpeBRepTool_connexity& co = mymapvEds.FindFromKey(myv0); @@ -553,10 +599,14 @@ bool TopOpeBRepTool_REGUW::InitBlock() le.Append(leb); int ne = nea + neb; if (ne == 0) + { return false; + } if (nea > 0) + { myed = TopoDS::Edge(le.First()); + } else { // CLOSING in NCollection_List::Iterator itb(le); @@ -571,11 +621,15 @@ bool TopOpeBRepTool_REGUW::InitBlock() } int iov0 = TopOpeBRepTool_TOOL::OriinSorclosed(myv0, myed); if (iov0 != iv0e1) + { continue; + } } // itb(leb) } if (myed.IsNull()) + { return false; + } TopExp_Explorer exv(myed, TopAbs_VERTEX); for (; exv.More(); exv.Next()) @@ -593,7 +647,9 @@ bool TopOpeBRepTool_REGUW::InitBlock() TopOpeBRepTool_C2DF c2df; bool bound = myCORRISO.UVRep(myed, c2df); if (!bound) + { return false; + } double f, l, tol; const occ::handle& pc = c2df.PC(f, l, tol); double par0 = TopOpeBRepTool_TOOL::ParE(iv0e1, myed); @@ -626,7 +682,9 @@ bool TopOpeBRepTool_REGUW::NearestE(const NCollection_List& loe, #endif if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } efound.Nullify(); double fac = 0.45678; double tola = Precision::Angular(); @@ -636,23 +694,35 @@ bool TopOpeBRepTool_REGUW::NearestE(const NCollection_List& loe, NCollection_List::Iterator ite(loe); efound = TopoDS::Edge(ite.Value()); if (ite.More()) + { ite.Next(); + } else + { return true; + } TopOpeBRepTool_C2DF c2defound; bool isbfound = myCORRISO.UVRep(efound, c2defound); if (!isbfound) + { return false; + } gp_Vec2d tg2dfound = TopOpeBRepTool_TOOL::tryTg2dApp(iv0e1, efound, c2defound, fac); if (M_REVERSED(efound.Orientation())) + { tg2dfound.Reverse(); + } double angfound = 1.e7; if (iStep == 1) + { angfound = TopOpeBRepTool_TOOL::Matter(mytg2d, tg2dfound); + } else + { angfound = 2. * M_PI - TopOpeBRepTool_TOOL::Matter(tg2dfound, mytg2d); + } #ifdef OCCT_DEBUG if (trc) std::cout << "ang(e" << FUN_adds(myed) << ",e" << FUN_adds(efound) << ")=" << angfound @@ -669,21 +739,31 @@ bool TopOpeBRepTool_REGUW::NearestE(const NCollection_List& loe, const TopoDS_Edge& ei = TopoDS::Edge(ite.Value()); // for INTERNAL edge eI -> eF+eR if (ei.IsSame(myed)) + { continue; + } TopOpeBRepTool_C2DF c2dei; bool isbi = myCORRISO.UVRep(ei, c2dei); if (!isbi) + { return false; + } gp_Vec2d tg2di = TopOpeBRepTool_TOOL::tryTg2dApp(iv0e1, ei, c2dei, fac); if (M_REVERSED(ei.Orientation())) + { tg2di.Reverse(); + } double angi = 1.e7; if (iStep == 1) + { angi = TopOpeBRepTool_TOOL::Matter(mytg2d, tg2di); + } else + { angi = 2. * M_PI - TopOpeBRepTool_TOOL::Matter(tg2di, mytg2d); + } bool eq = std::abs(angi - angfound) < tola; #ifdef OCCT_DEBUG if (trc) @@ -709,7 +789,9 @@ bool TopOpeBRepTool_REGUW::NearestE(const NCollection_List& loe, bool TopOpeBRepTool_REGUW::NextinBlock() { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } #ifdef OCCT_DEBUG bool trc = TopOpeBRepTool_GettraceREGUFA(); if (trc) @@ -767,9 +849,13 @@ bool TopOpeBRepTool_REGUW::NextinBlock() // p2d(myv,ed)=p2d(myv,e) bool samep2d = p2de.IsEqual(myp2d, mytol2d); if (!samep2d) + { le.Remove(ite); + } else + { ite.Next(); + } #ifdef OCCT_DEBUG if (trc) { @@ -790,7 +876,9 @@ bool TopOpeBRepTool_REGUW::NextinBlock() // myed : ne = le.Extent(); if (ne == 1) + { myed = TopoDS::Edge(le.First()); + } else { TopoDS_Edge efound; @@ -845,7 +933,9 @@ bool TopOpeBRepTool_REGUW::REGU(const int istep, NCollection_List& Splits) { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } iStep = istep; #ifdef OCCT_DEBUG bool trc = TopOpeBRepTool_GettraceREGUFA(); @@ -901,7 +991,9 @@ bool TopOpeBRepTool_REGUW::REGU(const int istep, { TopAbs_Orientation oe = ite.Value().Orientation(); if (M_INTERNAL(oe) || M_EXTERNAL(oe)) + { nE--; + } } while (nite <= nE) @@ -960,7 +1052,9 @@ bool TopOpeBRepTool_REGUW::REGU(const int istep, le.Remove(itte); } else + { itte.Next(); + } } // itte(le) } // exv(e) } // ite(loEcur) @@ -981,7 +1075,9 @@ bool TopOpeBRepTool_REGUW::REGU(const int istep, TopoDS_Wire newW; bool wiok = FUN_tool_MakeWire(loEcur, newW); if (wiok) + { loW.Append(newW); + } else { #ifdef OCCT_DEBUG @@ -1040,7 +1136,9 @@ bool TopOpeBRepTool_REGUW::REGU(const int istep, bool TopOpeBRepTool_REGUW::REGU() { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } NCollection_List null; bool toregu = !myListVmultiple.IsEmpty(); @@ -1063,7 +1161,9 @@ bool TopOpeBRepTool_REGUW::REGU() // iStep = 2; if (loS.IsEmpty()) + { loS.Append(S()); // no new shape + } NCollection_List::Iterator it(loS); for (; it.More(); it.Next()) @@ -1086,7 +1186,9 @@ bool TopOpeBRepTool_REGUW::REGU() return false; } if (sp.IsEmpty()) + { sp.Append(Scur); // no new shape + } Splits.Append(sp); } myOwNw.Bind(S(), Splits); @@ -1098,10 +1200,14 @@ bool TopOpeBRepTool_REGUW::REGU() bool TopOpeBRepTool_REGUW::GetSplits(NCollection_List& Splits) const { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } bool isb = myOwNw.IsBound(S()); if (!isb) + { return false; + } Splits = myOwNw.Find(S()); return true; } @@ -1111,10 +1217,14 @@ bool TopOpeBRepTool_REGUW::GetSplits(NCollection_List& Splits) con bool TopOpeBRepTool_REGUW::Connexity(const TopoDS_Vertex& v, TopOpeBRepTool_connexity& co) const { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } bool isb = mymapvEds.Contains(v); if (!isb) + { return false; + } co = mymapvEds.FindFromKey(v); return true; } @@ -1126,14 +1236,20 @@ bool TopOpeBRepTool_REGUW::AddNewConnexity(const TopoDS_Vertex& v, const TopoDS_Edge& e) { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } bool isb = mymapvEds.Contains(v); if (!isb) + { return false; + } bool ok = myCORRISO.AddNewConnexity(v, e); if (!ok) + { return false; + } TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v); co.AddItem(OriKey, e); @@ -1166,10 +1282,14 @@ bool TopOpeBRepTool_REGUW::RemoveOldConnexity(const TopoDS_Vertex& v, const TopoDS_Edge& e) { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } bool isb = mymapvEds.Contains(v); if (!isb) + { return false; + } bool ok = myCORRISO.RemoveOldConnexity(v, e); // if (!ok) return false; @@ -1184,14 +1304,22 @@ bool TopOpeBRepTool_REGUW::RemoveOldConnexity(const TopoDS_Vertex& v, bool TopOpeBRepTool_REGUW::UpdateMultiple(const TopoDS_Vertex& v) { if (!HasInit()) + { throw Standard_Failure("TopOpeBRepTool_REGUW : NO INIT"); + } bool isb = mymapvEds.Contains(v); if (!isb) + { return false; + } const TopOpeBRepTool_connexity& co = mymapvEds.FindFromKey(v); bool ismult = co.IsMultiple(); if (ismult) + { if (mymapvmultiple.Add(v)) + { myListVmultiple.Append(v); + } + } return true; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeS.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeS.cxx index d4fc85acab..74598d4a3a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeS.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeS.cxx @@ -58,10 +58,14 @@ bool TopOpeBRepTool::RegularizeShells( REGUS.Init(sh); bool ok = REGUS.MapS(); if (!ok) + { return false; + } ok = REGUS.SplitFaces(); if (!ok) + { return false; + } REGUS.REGU(); } // exsh(theSolid) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeW.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeW.cxx index 91cb9a51af..914315a16b 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeW.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_RegularizeW.cxx @@ -91,7 +91,9 @@ bool TopOpeBRepTool::RegularizeWires( ESplits) // (e,esp); esp = splits of e { if (theFace.IsNull()) + { return false; + } TopoDS_Shape aLocalShape = theFace.Oriented(TopAbs_FORWARD); TopoDS_Face aFace = TopoDS::Face(aLocalShape); // TopoDS_Face aFace = TopoDS::Face(theFace.Oriented(TopAbs_FORWARD)); @@ -108,13 +110,19 @@ bool TopOpeBRepTool::RegularizeWires( REGUW.Init(W); bool ok = REGUW.MapS(); if (!ok) + { return false; + } ok = REGUW.SplitEds(); if (!ok) + { return false; + } ok = REGUW.REGU(); if (!ok) + { return false; + } } REGUW.GetEsplits(ESplits); @@ -675,7 +683,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( FUN_addOwlw(owi, low, lwresu); NCollection_List::Iterator itw(lwresu); for (; itw.More(); itw.Next()) + { mapWlow.Bind(itw.Value(), null); + } } // itm(mapOwNw) NCollection_Map mapdone; @@ -685,14 +695,18 @@ Standard_EXPORT bool FUN_tool_ClassifW( { nOw = lOws.Extent(); if (nOw == 0) + { break; + } NCollection_List::Iterator itOw(lOws); const TopoDS_Shape& Ow1 = itOw.Value(); bool isb1 = mapWlow.IsBound(Ow1); isb1 = isb1 || !mapdone.Contains(Ow1); if (!isb1) + { continue; + } const NCollection_List& lw1 = mapOwNw.Find(Ow1); @@ -714,7 +728,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( bool isb2 = mapWlow.IsBound(Ow2); isb2 = isb2 || !mapdone.Contains(Ow2); if (!isb2) + { continue; + } int stabnd2d12 = CLASSI.ClassiBnd2d(Ow1, Ow2, toluv, true); sta12 = CLASSI.Classip2d(Ow1, Ow2, stabnd2d12); if (sta12 == DIFF) @@ -723,7 +739,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( continue; } else if ((sta12 == UNKNOWN) || (sta12 == SAME)) + { return false; + } break; } if (OUTall) @@ -734,7 +752,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( FUN_addOwlw(Ow1, lw1, ldone); NCollection_List::Iterator itw(ldone); for (; itw.More(); itw.Next()) + { mapdone.Add(itw.Value()); + } #ifdef OCCT_DEBUG if (trc) std::cout << "old wires :wi" << FUN_adds(Ow1) << " is OUT all old wires" << std::endl; @@ -776,7 +796,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( bool isbsma = mapWlow.IsBound(wsma); isbsma = isbsma || !mapdone.Contains(wsma); if (!isbsma) + { continue; + } NCollection_List::Iterator itgre(lgre); for (; itgre.More(); itgre.Next()) @@ -785,7 +807,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( bool isbgre = mapWlow.IsBound(wgre); isbgre = isbgre || !mapdone.Contains(wgre); if (!isbgre) + { continue; + } int stabnd2d = CLASSI.ClassiBnd2d(wsma, wgre, toluv, true); int sta = CLASSI.Classip2d(wsma, wgre, stabnd2d); @@ -799,7 +823,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( #endif if (sta == DIFF) + { continue; + } else if (sta == oneINtwo) { // wsma IN wgre mapWlow.ChangeFind(wgre).Append(mapWlow.ChangeFind(wsma)); @@ -811,7 +837,9 @@ Standard_EXPORT bool FUN_tool_ClassifW( mapWlow.UnBind(wgre); } else + { return false; + } } // itgre } // itsma lOws.RemoveFirst(); @@ -848,7 +876,9 @@ bool TopOpeBRepTool::RegularizeFace( bool classifok = FUN_tool_ClassifW(aFace, mapoldWnewW, mapWlow); if (!classifok) + { return false; + } // // ------------- diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SC.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SC.cxx index ea89a57fa1..7de4b2060a 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SC.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SC.cxx @@ -28,7 +28,9 @@ static thread_local TopOpeBRepTool_PShapeClassifier TopOpeBRepTool_PSC = nullptr Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC() { if (TopOpeBRepTool_PSC == nullptr) + { TopOpeBRepTool_PSC = new TopOpeBRepTool_ShapeClassifier(); + } return *TopOpeBRepTool_PSC; } @@ -36,7 +38,9 @@ Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC() Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC(const TopoDS_Shape& S) { if (TopOpeBRepTool_PSC == nullptr) + { TopOpeBRepTool_PSC = new TopOpeBRepTool_ShapeClassifier(); + } TopOpeBRepTool_PSC->SetReference(S); return *TopOpeBRepTool_PSC; } @@ -53,7 +57,9 @@ Standard_EXPORT TopAbs_State FSC_StatePonFace(const gp_Pnt& P, double dist; bool ok = FUN_tool_projPonS(P, S, UV, dist); if (!ok) + { return TopAbs_UNKNOWN; + } PSC.SetReference(TopoDS::Face(F)); PSC.StateP2DReference(UV); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeClassifier.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeClassifier.cxx index 4f0d1cd0d0..c882d14d97 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeClassifier.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeClassifier.cxx @@ -130,7 +130,9 @@ void TopOpeBRepTool_ShapeClassifier::MapRef() TopoDS_Vertex v1, v2; TopExp::Vertices(E, v1, v2); if (v1.IsSame(v2)) + { mymren = 0; + } } } mymredone = true; @@ -242,14 +244,20 @@ void TopOpeBRepTool_ShapeClassifier::FindEdge(const TopoDS_Shape& S) bool isavls = HasAvLS(); bool isavs = (!myAvS.IsNull()); if (S.IsNull()) + { return; + } TopAbs_ShapeEnum tS = S.ShapeType(); TopExp_Explorer eex; if (!myFace.IsNull()) + { eex.Init(myFace, TopAbs_EDGE); + } else + { eex.Init(S, TopAbs_EDGE); + } for (; eex.More(); eex.Next()) { @@ -259,12 +267,18 @@ void TopOpeBRepTool_ShapeClassifier::FindEdge(const TopoDS_Shape& S) { toavoid = toavoid || myMapAvS.Contains(E); if (!myAvS.IsNull()) + { toavoid = toavoid || E.IsSame(myAvS); + } } else if (BRep_Tool::Degenerated(E)) + { toavoid = (tS != TopAbs_EDGE); + } if (toavoid) + { continue; + } myEdge = E; break; } @@ -286,10 +300,14 @@ void TopOpeBRepTool_ShapeClassifier::FindFace(const TopoDS_Shape& S) { toavoid = toavoid || myMapAvS.Contains(F); if (!myAvS.IsNull()) + { toavoid = toavoid || F.IsSame(myAvS); + } } if (toavoid) + { continue; + } myFace = F; break; } @@ -301,9 +319,13 @@ void TopOpeBRepTool_ShapeClassifier::Perform() { myState = TopAbs_UNKNOWN; if (myS.IsNull()) + { return; + } if (myRef.IsNull()) + { return; + } if (!mymredone) { @@ -454,7 +476,9 @@ void TopOpeBRepTool_ShapeClassifier::Perform() if (oriRef == TopAbs_EXTERNAL || oriRef == TopAbs_INTERNAL) { if (myState == TopAbs_IN) + { myState = TopAbs_OUT; + } } } @@ -465,9 +489,13 @@ void TopOpeBRepTool_ShapeClassifier::StateEdgeReference() myState = TopAbs_UNKNOWN; if (myEdge.IsNull()) + { return; + } if (myRef.IsNull()) + { return; + } occ::handle C3D; gp_Pnt P3D; @@ -488,7 +516,9 @@ void TopOpeBRepTool_ShapeClassifier::StateEdgeReference() C2D = FC2D_CurveOnSurface(myEdge, F, f2d, l2d, tol2d, trimCurve); if (C2D.IsNull()) + { throw Standard_ProgramError("StateShapeShape : no 2d curve"); + } double t = 0.127956477; double p = (1 - t) * f2d + t * l2d; @@ -507,7 +537,9 @@ void TopOpeBRepTool_ShapeClassifier::StateEdgeReference() C3D = BRep_Tool::Curve(myEdge, f3d, l3d); if (C3D.IsNull()) + { throw Standard_ProgramError("StateShapeShape : no 3d curve"); + } double t = 0.127956477; double p = (1 - t) * f3d + t * l3d; @@ -531,7 +563,9 @@ void TopOpeBRepTool_ShapeClassifier::StateEdgeReference() C3D = BRep_Tool::Curve(myEdge, f3d, l3d); if (C3D.IsNull()) + { throw Standard_ProgramError("StateShapeShape : no 3d curve"); + } double t = 0.127956477; double p = (1 - t) * f3d + t * l3d; @@ -541,7 +575,9 @@ void TopOpeBRepTool_ShapeClassifier::StateEdgeReference() } } else + { throw Standard_ProgramError("StateShapeShape : bad operands"); + } } //================================================================================================= @@ -550,7 +586,9 @@ void TopOpeBRepTool_ShapeClassifier::StateP2DReference(const gp_Pnt2d& P2D) { myState = TopAbs_UNKNOWN; if (myRef.IsNull()) + { return; + } TopAbs_ShapeEnum tR = myRef.ShapeType(); if (tR == TopAbs_FACE) @@ -564,10 +602,14 @@ void TopOpeBRepTool_ShapeClassifier::StateP2DReference(const gp_Pnt2d& P2D) TopAbs_Orientation o = x.Current().Orientation(); // if (o == TopAbs_EXTERNAL) myState == TopAbs_OUT; if (o == TopAbs_EXTERNAL) + { myState = TopAbs_OUT; - // else if (o == TopAbs_INTERNAL) myState == TopAbs_IN; + // else if (o == TopAbs_INTERNAL) myState == TopAbs_IN; + } else if (o == TopAbs_INTERNAL) + { myState = TopAbs_IN; + } else { #ifdef OCCT_DEBUG @@ -600,7 +642,9 @@ void TopOpeBRepTool_ShapeClassifier::StateP3DReference(const gp_Pnt& P3D) { myState = TopAbs_UNKNOWN; if (myRef.IsNull()) + { return; + } TopAbs_ShapeEnum tR = myRef.ShapeType(); if (tR == TopAbs_SOLID) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx index 0e423f8514..ef327f1a8f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx @@ -46,7 +46,9 @@ double TopOpeBRepTool_ShapeTool::Tolerance(const TopoDS_Shape& S) { if (S.IsNull()) + { return 0.; + } double tol = 0; switch (S.ShapeType()) { @@ -86,11 +88,17 @@ occ::handle TopOpeBRepTool_ShapeTool::BASISCURVE(const occ::handle T = C->DynamicType(); if (T == STANDARD_TYPE(Geom_OffsetCurve)) + { return BASISCURVE(occ::down_cast(C)->BasisCurve()); + } else if (T == STANDARD_TYPE(Geom_TrimmedCurve)) + { return BASISCURVE(occ::down_cast(C)->BasisCurve()); + } else + { return C; + } } occ::handle TopOpeBRepTool_ShapeTool::BASISCURVE(const TopoDS_Edge& E) @@ -98,7 +106,9 @@ occ::handle TopOpeBRepTool_ShapeTool::BASISCURVE(const TopoDS_Edge& double f, l; occ::handle C = BRep_Tool::Curve(E, f, l); if (C.IsNull()) + { return C; + } return BASISCURVE(C); } @@ -113,11 +123,17 @@ occ::handle TopOpeBRepTool_ShapeTool::BASISSURFACE(const occ::hand { occ::handle T = S->DynamicType(); if (T == STANDARD_TYPE(Geom_OffsetSurface)) + { return BASISSURFACE(occ::down_cast(S)->BasisSurface()); + } else if (T == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { return BASISSURFACE(occ::down_cast(S)->BasisSurface()); + } else + { return S; + } } occ::handle TopOpeBRepTool_ShapeTool::BASISSURFACE(const TopoDS_Face& F) @@ -201,7 +217,9 @@ void TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(const TopoDS_Shape& F, double& u // exit if surface supporting F is not periodic on U or V if (!isUperio && !isVperio) + { return; + } double UFfirst, UFlast, VFfirst, VFlast; BRepTools::UVBounds(FF, UFfirst, UFlast, VFfirst, VFlast); @@ -216,7 +234,9 @@ void TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(const TopoDS_Shape& F, double& u // ElCLib::AdjustPeriodic(UFfirst,UFfirst + Uperiod,tol,ubid,u); if (std::abs(u - UFfirst - Uperiod) > tol) + { u = ElCLib::InPeriod(u, UFfirst, UFfirst + Uperiod); + } } if (isVperio) { @@ -226,7 +246,9 @@ void TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(const TopoDS_Shape& F, double& u // ElCLib::AdjustPeriodic(VFfirst,VFfirst + Vperiod,tol,vbid,v); if (std::abs(v - VFfirst - Vperiod) > tol) + { v = ElCLib::InPeriod(v, VFfirst, VFfirst + Vperiod); + } } } @@ -241,8 +263,12 @@ bool TopOpeBRepTool_ShapeTool::Closed(const TopoDS_Shape& S1, const TopoDS_Shape { int n = 0; for (TopExp_Explorer x(F, TopAbs_EDGE); x.More(); x.Next()) + { if (x.Current().IsSame(E)) + { n++; + } + } return n >= 2; } return false; @@ -292,7 +318,9 @@ double TopOpeBRepTool_ShapeTool::PeriodizeParameter(const double par, { double periopar = par; if (!TopOpeBRepTool_ShapeTool::Closed(EE, FF)) + { return periopar; + } TopoDS_Edge E = TopoDS::Edge(EE); TopoDS_Face F = TopoDS::Face(FF); @@ -302,7 +330,9 @@ double TopOpeBRepTool_ShapeTool::PeriodizeParameter(const double par, bool isUperio = Surf->IsUPeriodic(); bool isVperio = Surf->IsVPeriodic(); if (!isUperio && !isVperio) + { return periopar; + } double Ufirst, Ulast, Vfirst, Vlast; Surf->Bounds(Ufirst, Ulast, Vfirst, Vlast); @@ -310,7 +340,9 @@ double TopOpeBRepTool_ShapeTool::PeriodizeParameter(const double par, double first, last, tolpc; const occ::handle PC = FC2D_CurveOnSurface(E, F, first, last, tolpc); if (PC.IsNull()) + { throw Standard_ProgramError("ShapeTool::PeriodizeParameter : no 2d curve"); + } occ::handle TheType = PC->DynamicType(); if (TheType == STANDARD_TYPE(Geom2d_Line)) @@ -322,9 +354,13 @@ double TopOpeBRepTool_ShapeTool::PeriodizeParameter(const double par, double tol = Precision::Angular(); bool isoU = false, isoV = false; if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::Y), tol)) + { isoU = true; + } else if (D.IsParallel(gp_Dir2d(gp_Dir2d::D::X), tol)) + { isoV = true; + } if (isoU) { periopar = ADJUST(par, Ufirst, Ulast, tol); @@ -391,9 +427,13 @@ bool TopOpeBRepTool_ShapeTool::ShapesSameOriented(const TopoDS_Shape& S1, const TopAbs_Orientation o2 = S2.Orientation(); if (o1 == TopAbs_EXTERNAL || o1 == TopAbs_INTERNAL || o2 == TopAbs_EXTERNAL || o2 == TopAbs_INTERNAL) + { so = true; + } else + { so = (o1 == o2); + } } return so; @@ -447,7 +487,9 @@ bool TopOpeBRepTool_ShapeTool::SurfacesSameOriented(const BRepAdaptor_Surface& S double dp2; bool ok = FUN_tool_projPonS(p1, HS2, p22d, dp2); if (!ok) + { return so; // NYI : raise + } double u2 = p22d.X(); double v2 = p22d.Y(); @@ -496,7 +538,9 @@ bool TopOpeBRepTool_ShapeTool::FacesSameOriented(const TopoDS_Shape& S1, const T bool so = F1.IsSame(F2) || SurfacesSameOriented(BAS1, BAS2); bool b = so; if (o1 != o2) + { b = !so; + } return b; } @@ -558,7 +602,9 @@ bool TopOpeBRepTool_ShapeTool::EdgesSameOriented(const TopoDS_Shape& S1, const T bool so = CurvesSameOriented(BAC1, BAC2); bool b = so; if (o1 != o2) + { b = !so; + } return b; } @@ -583,7 +629,9 @@ double TopOpeBRepTool_ShapeTool::EdgeData(const BRepAdaptor_Curve& BAC, double tolm = std::max(tol, std::max(tol1, tol2)); if (std::abs(C) > tolm) + { BL.Normal(N); + } return tol; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SolidClassifier.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SolidClassifier.cxx index c9b59c5786..22b7534547 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SolidClassifier.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_SolidClassifier.cxx @@ -104,7 +104,9 @@ TopAbs_State TopOpeBRepTool_SolidClassifier::Classify(const TopoDS_Solid& SOL, myState = TopAbs_UNKNOWN; LoadSolid(SOL); if (myPClassifier == nullptr) + { return myState; + } myPClassifier->Perform(P, Tol); myState = myPClassifier->State(); const TopoDS_Shape& fres = myPClassifier->Face(); @@ -119,24 +121,40 @@ TopAbs_State TopOpeBRepTool_SolidClassifier::Classify(const TopoDS_Solid& SOL, if (ofres == TopAbs_EXTERNAL) { if (myState == TopAbs_IN) + { myState = TopAbs_OUT; + } else if (myState == TopAbs_OUT) + { myState = TopAbs_OUT; + } else if (myState == TopAbs_ON) + { myState = TopAbs_ON; + } else if (myState == TopAbs_UNKNOWN) + { myState = TopAbs_OUT; + } } else if (ofres == TopAbs_INTERNAL) { if (myState == TopAbs_IN) + { myState = TopAbs_IN; + } else if (myState == TopAbs_OUT) + { myState = TopAbs_IN; + } else if (myState == TopAbs_ON) + { myState = TopAbs_ON; + } else if (myState == TopAbs_UNKNOWN) + { myState = TopAbs_IN; + } } return myState; } @@ -151,7 +169,9 @@ TopAbs_State TopOpeBRepTool_SolidClassifier::Classify(const TopoDS_Shell& SHE, myState = TopAbs_UNKNOWN; LoadShell(SHE); if (myPClassifier == nullptr) + { return myState; + } myPClassifier->Perform(P, Tol); myState = myPClassifier->State(); return myState; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOOL.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOOL.cxx index 1e87db819e..86451e4f3f 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOOL.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOOL.cxx @@ -104,7 +104,9 @@ static bool CheckEdgeLength(const TopoDS_Edge& E) anExtent = aM.Extent(); if (anExtent != 1) + { return true; + } gp_Pnt p1, p2; f = BC.FirstParameter(); @@ -117,9 +119,13 @@ static bool CheckEdgeLength(const TopoDS_Edge& E) t = f + i * dt; if (i == aN) + { BC.D0(l, p2); + } else + { BC.D0(t, p2); + } d = p1.Distance(p2); ln += d; @@ -143,23 +149,35 @@ int TopOpeBRepTool_TOOL::OriinSor(const TopoDS_Shape& sub, if (S.ShapeType() == TopAbs_EDGE) { if (sub.ShapeType() != TopAbs_VERTEX) + { return 0; + } TopoDS_Vertex vclo; Sclosed = TopOpeBRepTool_TOOL::ClosedE(TopoDS::Edge(S), vclo); if (Sclosed) + { if (sub.IsSame(vclo)) + { return CLOSING; + } + } } else if (S.ShapeType() == TopAbs_FACE) { if (sub.ShapeType() != TopAbs_EDGE) + { return 0; + } Sclosed = ClosedS(TopoDS::Face(S)); if (Sclosed) + { if (IsClosingE(TopoDS::Edge(sub), TopoDS::Face(S))) + { return CLOSING; + } + } } } @@ -169,16 +187,26 @@ int TopOpeBRepTool_TOOL::OriinSor(const TopoDS_Shape& sub, const TopoDS_Shape& ssub = ex.Current(); bool same = ssub.IsSame(sub); if (!same) + { continue; + } TopAbs_Orientation osub = ssub.Orientation(); if (M_FORWARD(osub)) + { return FORWARD; + } else if (M_REVERSED(osub)) + { return REVERSED; + } else if (M_INTERNAL(osub)) + { return INTERNAL; + } else if (M_EXTERNAL(osub)) + { return EXTERNAL; + } } return 0; } @@ -190,12 +218,16 @@ int TopOpeBRepTool_TOOL::OriinSorclosed(const TopoDS_Shape& sub, const TopoDS_Sh if (S.ShapeType() == TopAbs_EDGE) { if (sub.ShapeType() != TopAbs_VERTEX) + { return 0; + } } else if (S.ShapeType() == TopAbs_FACE) { if (sub.ShapeType() != TopAbs_EDGE) + { return 0; + } } TopoDS_Iterator it(S); for (; it.More(); it.Next()) @@ -203,12 +235,18 @@ int TopOpeBRepTool_TOOL::OriinSorclosed(const TopoDS_Shape& sub, const TopoDS_Sh const TopoDS_Shape& ssub = it.Value(); bool equal = ssub.IsEqual(sub); if (!equal) + { continue; + } TopAbs_Orientation osub = ssub.Orientation(); if (M_FORWARD(osub)) + { return FORWARD; + } else if (M_REVERSED(osub)) + { return REVERSED; + } } return 0; } @@ -221,7 +259,9 @@ bool TopOpeBRepTool_TOOL::ClosedE(const TopoDS_Edge& E, TopoDS_Vertex& vclo) // return E.IsClosed(); bool isdgE = BRep_Tool::Degenerated(E); if (isdgE) + { return false; + } TopoDS_Shape vv; vclo.Nullify(); @@ -230,9 +270,13 @@ bool TopOpeBRepTool_TOOL::ClosedE(const TopoDS_Edge& E, TopoDS_Vertex& vclo) { const TopoDS_Shape& v = ex.Current(); if (M_INTERNAL(v.Orientation())) + { continue; + } if (vv.IsNull()) + { vv = v; + } else if (v.IsSame(vv)) { vclo = TopoDS::Vertex(vv); @@ -248,13 +292,19 @@ bool TopOpeBRepTool_TOOL::ClosedS(const TopoDS_Face& F) { occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); if (S.IsNull()) + { return false; + } bool uclosed = S->IsUClosed(); if (uclosed) + { uclosed = S->IsUPeriodic(); + } bool vclosed = S->IsVClosed(); if (vclosed) + { vclosed = S->IsVPeriodic(); + } return (uclosed || vclosed); } @@ -265,10 +315,16 @@ bool TopOpeBRepTool_TOOL::IsClosingE(const TopoDS_Edge& E, const TopoDS_Face& F) int nbocc = 0; TopExp_Explorer exp(F, TopAbs_EDGE); for (; exp.More(); exp.Next()) + { if (exp.Current().IsSame(E)) + { nbocc++; + } + } if (nbocc != 2) + { return false; + } return BRep_Tool::IsClosed(E, F); } @@ -281,10 +337,16 @@ bool TopOpeBRepTool_TOOL::IsClosingE(const TopoDS_Edge& E, int nbocc = 0; TopExp_Explorer exp(W, TopAbs_EDGE); for (; exp.More(); exp.Next()) + { if (exp.Current().IsSame(E)) + { nbocc++; + } + } if (nbocc != 2) + { return false; + } return BRep_Tool::IsClosed(E, F); } @@ -353,13 +415,21 @@ int TopOpeBRepTool_TOOL::OnBoundary(const double par, const TopoDS_Edge& e) bool onl = std::abs(par - last) < tolp; bool onfl = (onf || onl); if (onfl && closed) + { return CLOSING; + } if (onf) + { return FORWARD; + } if (onl) + { return REVERSED; + } if ((first < par) && (par < last)) + { return INTERNAL; + } return EXTERNAL; } @@ -416,7 +486,9 @@ bool TopOpeBRepTool_TOOL::SplitE(const TopoDS_Edge& Eanc, NCollection_List pc; double pf, pl, tol; bool hasold = FC2D_HasOldCurveOnSurface(e, f, pc); if (!hasold) + { return 0; + } pc = FC2D_EditableCurveOnSurface(e, f, pf, pl, tol); // n2d is such that (p2d,oop2d) is oriented INSIDE F @@ -727,23 +833,31 @@ bool TopOpeBRepTool_TOOL::NgApp(const double par, occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(f); if (S.IsNull()) + { return false; + } bool fplane = FUN_tool_plane(f); if (fplane) + { return false; + } // NYI : for bspline surfaces, use a evolutive parameter // on curve to find out "significant" tangents bool fquad = FUN_tool_quad(f); if (!fquad) + { return false; + } // : occ::handle pc; double pf, pl, tol; bool hasold = FC2D_HasOldCurveOnSurface(e, f, pc); if (!hasold) + { return false; + } pc = FC2D_EditableCurveOnSurface(e, f, pf, pl, tol); // : TopoDS_Shape aLocalShape = f.Oriented(TopAbs_FORWARD); @@ -751,23 +865,31 @@ bool TopOpeBRepTool_TOOL::NgApp(const double par, // int orieinf = // TopOpeBRepTool_TOOL::tryOriEinF(par,e,TopoDS::Face(f.Oriented(TopAbs_FORWARD))); if (orieinf == 0) + { return false; + } // : gp_Pnt2d uv; bool ok = FUN_tool_paronEF(e, par, f, uv); if (!ok) + { return false; + } // : gp_Dir ng = FUN_tool_ngS(uv, S); if (!ok) + { return false; + } // : gp_Vec2d tg2d; pc->D1(par, uv, tg2d); gp_Dir2d n2dinsideS = FUN_tool_nC2dINSIDES(gp_Dir2d(tg2d)); if (orieinf == 2) + { n2dinsideS.Reverse(); + } // : ' double eps = 0.45678; gp_Vec2d duv = gp_Vec2d(n2dinsideS).Multiplied(eps); @@ -806,14 +928,18 @@ bool TopOpeBRepTool_TOOL::tryNgApp(const double par, gp_Pnt2d uv; bool ok = FUN_tool_paronEF(e, par, f, uv); if (!ok) + { return false; + } gp_Dir ng(FUN_tool_nggeomF(uv, f)); #ifdef OCCT_DEBUG gp_Dir ngApp; #endif ok = TopOpeBRepTool_TOOL::NgApp(par, e, f, tola, Ng); if (!ok) + { Ng = ng; + } return true; } @@ -855,7 +981,9 @@ bool TopOpeBRepTool_TOOL::CurvE(const TopoDS_Edge& E, BRepLProp_CLProps clprops(BAC, par, 2, Precision::Confusion()); bool tgdef = clprops.IsTangentDefined(); if (!tgdef) + { return false; + } curv = std::abs(clprops.Curvature()); double tol = Precision::Confusion() * 1.e+2; // NYITOLXPU @@ -920,7 +1048,9 @@ static bool FUN_analyticcS(const gp_Pnt2d& uv0, // then computes its curvature . occ::handle su = TopOpeBRepTool_ShapeTool::BASISSURFACE(S); if (S.IsNull()) + { return true; + } GeomAdaptor_Surface GS(su); GeomAbs_SurfaceType ST = GS.GetType(); bool plane = (ST == GeomAbs_Plane); @@ -962,7 +1092,9 @@ static bool FUN_analyticcS(const gp_Pnt2d& uv0, double prod2 = ngS.Dot(tg0); if (cyl || cone) + { nullcurv = nullcurv || FUN_nullprodv(1 - std::abs(prod2)); + } if (nullcurv) { @@ -1006,7 +1138,9 @@ bool TopOpeBRepTool_TOOL::CurvF(const TopoDS_Face& F, gp_Dir ngS = FUN_tool_nggeomF(uv, F); occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(F); if (S.IsNull()) + { return false; + } // purpose : Computes theContour's curvature, // returns false if the compute fails. @@ -1014,7 +1148,9 @@ bool TopOpeBRepTool_TOOL::CurvF(const TopoDS_Face& F, bool analyticcontour = FUN_analyticcS(uv, S, ngS, tg0, curv, direct); if (analyticcontour) + { return true; + } GeomLProp_SLProps slprops(S, uv.X(), uv.Y(), 2, Precision::Confusion()); bool curdef = slprops.IsCurvatureDefined(); @@ -1060,12 +1196,16 @@ bool TopOpeBRepTool_TOOL::UVISO(const occ::handle& PC, { isoU = isoV = false; if (PC.IsNull()) + { return false; + } occ::handle LLL = BASISCURVE2D(PC); occ::handle T2 = LLL->DynamicType(); bool isline2d = (T2 == STANDARD_TYPE(Geom2d_Line)); if (!isline2d) + { return false; + } occ::handle L = occ::down_cast(LLL); d2d = L->Direction(); @@ -1073,7 +1213,9 @@ bool TopOpeBRepTool_TOOL::UVISO(const occ::handle& PC, isoV = (std::abs(d2d.Y()) < Precision::Parametric(Precision::Confusion())); bool isoUV = isoU || isoV; if (!isoUV) + { return false; + } o2d = L->Location(); return true; @@ -1092,7 +1234,9 @@ bool TopOpeBRepTool_TOOL::UVISO(const TopoDS_Edge& E, bool hasold = FC2D_HasOldCurveOnSurface(E, F, PC); PC = FC2D_EditableCurveOnSurface(E, F, f, l, tol); if (!hasold) + { FC2D_AddNewCurveOnSurface(PC, E, F, f, l, tol); + } bool iso = UVISO(PC, isoU, isoV, d2d, o2d); return iso; @@ -1127,15 +1271,23 @@ bool TopOpeBRepTool_TOOL::IsonCLO(const occ::handle& PC, gp_Dir2d d2d; bool isouv = UVISO(PC, isou, isov, d2d, o2d); if (!isouv) + { return false; + } bool onX = (onU && isou) || ((!onU) && isov); if (!onX) + { return false; + } double dxx = 0; if (onU) + { dxx = std::abs(o2d.X() - xfirst); + } else + { dxx = std::abs(o2d.Y() - xfirst); + } bool onclo = (dxx < xtol); onclo = onclo || (std::abs(xperiod - dxx) < xtol); @@ -1171,7 +1323,9 @@ bool TopOpeBRepTool_TOOL::TrslUVModifE(const gp_Vec2d& t2d, const TopoDS_Face& F // occ::handle PC; double f,l,tol; if (PC.IsNull()) + { return false; + } PC->Translate(t2d); // occ::handle toclear; BB.UpdateEdge(E,toclear,F,tole); BRep_Builder BB; @@ -1189,14 +1343,20 @@ double TopOpeBRepTool_TOOL::Matter(const gp_Vec& d1, const gp_Vec& dR2, const gp double ang = d1.Angle(d2); bool equal = (ang < tola); if (equal) + { return 0.; + } bool oppo = ((M_PI - ang) < tola); if (oppo) + { return M_PI; + } ang = d1.AngleWithRef(d2, Ref); if (ang < 0) + { ang = 2. * M_PI + ang; + } return ang; } @@ -1244,7 +1404,9 @@ bool TopOpeBRepTool_TOOL::Matter(const gp_Dir& xx1, double dot = z2.Dot(z1); bool oppo = (dot < 0.); if (!oppo) + { return false; + } // -nti points towards 3dmatter(fi) // => zi = xxi^nti gives the opposite sense for the compute of the matter angle @@ -1256,7 +1418,9 @@ bool TopOpeBRepTool_TOOL::Matter(const gp_Dir& xx1, return true; } if (ang < 0) + { ang = 2. * M_PI + ang; + } return true; } @@ -1271,7 +1435,9 @@ bool TopOpeBRepTool_TOOL::Getduv(const TopoDS_Face& f, { bool quad = TopOpeBRepTool_TOOL::IsQuad(f); if (!quad) + { return false; + } Bnd_Box bndf; BRepBndLib::AddClose(f, bndf); double f1, f2, f3, l1, l2, l3; @@ -1287,7 +1453,9 @@ bool TopOpeBRepTool_TOOL::Getduv(const TopoDS_Face& f, double tolf = BRep_Tool::Tolerance(f); tolf *= 1.e2; // NYIXPUTOL if (d > tolf) + { return false; + } gp_Vec2d DUV(uv, uvtr); occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(f); @@ -1297,7 +1465,9 @@ bool TopOpeBRepTool_TOOL::Getduv(const TopoDS_Face& f, ElCLib::AdjustPeriodic(0., period, Precision::PConfusion(), U1, U2); double dx = U2 - U1; if (dx > period / 2.) + { dx -= period; + } DUV.SetX(dx); } if ((S->IsVPeriodic()) && (std::abs(DUV.Y()) > S->VPeriod() / 2.)) @@ -1306,7 +1476,9 @@ bool TopOpeBRepTool_TOOL::Getduv(const TopoDS_Face& f, ElCLib::AdjustPeriodic(0., period, Precision::PConfusion(), V1, V2); double dy = V2 - V1; if (dy > period / 2.) + { dy -= period; + } DUV.SetY(dy); } duv = gp_Dir2d(DUV); @@ -1325,11 +1497,15 @@ bool TopOpeBRepTool_TOOL::uvApp(const TopoDS_Face& f, // uv : bool ok = FUN_tool_paronEF(e, pare, f, uvapp); if (!ok) + { return false; + } gp_Vec2d dxx; ok = FUN_tool_getdxx(f, e, pare, dxx); if (!ok) + { return false; + } uvapp.Translate(dxx.Multiplied(eps)); return true; } @@ -1349,15 +1525,21 @@ bool TopOpeBRepTool_TOOL::XX(const gp_Pnt2d& uv, double tol = Precision::Confusion() * 1.e2; // NYITOL bool nullng = (geomxx.Magnitude() < tol); if (nullng) + { return false; + } TopAbs_Orientation oef; bool ok = FUN_tool_orientEinFFORWARD(e, f, oef); if (!ok) + { return false; + } XX = gp_Dir(geomxx); if (M_REVERSED(oef)) + { XX.Reverse(); + } return true; } @@ -1368,10 +1550,14 @@ bool TopOpeBRepTool_TOOL::Nt(const gp_Pnt2d& uv, const TopoDS_Face& f, gp_Dir& n gp_Vec nggeom; bool ok = TopOpeBRepTool_TOOL::NggeomF(uv, f, nggeom); if (!ok) + { return false; + } normt = gp_Dir(nggeom); if (M_REVERSED(f.Orientation())) + { normt.Reverse(); + } return true; } @@ -1420,9 +1606,13 @@ static bool FUN_ngF(const gp_Pnt2d& uv, const TopoDS_Face& F, gp_Vec& ngF) double vf = bs.FirstVParameter(); if (std::abs(vf - y) < tolu) + { vf += delta; + } else + { vf -= delta; + } // modified by NIZHNY-MZV Fri Nov 26 12:38:55 1999 y = vf; @@ -1482,25 +1672,37 @@ bool TopOpeBRepTool_TOOL::Matter(const TopoDS_Face& f1, gp_Pnt2d uv1; bool ok1 = FUN_tool_paronEF(e, par, f1, uv1, tolf1); if (!ok1) + { return false; + } ok1 = TopOpeBRepTool_TOOL::Nt(uv1, f1, nt1); if (!ok1) + { return false; + } ok1 = TopOpeBRepTool_TOOL::XX(uv1, f1, par, e, xx1); if (!ok1) + { return false; + } double tolf2 = BRep_Tool::Tolerance(f2) * 2.e2; // nyitolxpu gp_Pnt2d uv2; bool ok2 = FUN_tool_paronEF(e, par, f2, uv2, tolf2); if (!ok2) + { return false; + } ok2 = TopOpeBRepTool_TOOL::Nt(uv2, f2, nt2); if (!ok2) + { return false; + } ok2 = TopOpeBRepTool_TOOL::XX(uv2, f2, par, e, xx2); if (!ok2) + { return false; + } return (TopOpeBRepTool_TOOL::Matter(xx1, nt1, xx2, nt2, tola, ang)); } @@ -1526,11 +1728,15 @@ bool TopOpeBRepTool_TOOL::MatterKPtg(const TopoDS_Face& f1, gp_Dir nt1; bool ok1 = TopOpeBRepTool_TOOL::Nt(uv1, f1, nt1); if (!ok1) + { return false; + } gp_Pnt2d uvapp1; ok1 = TopOpeBRepTool_TOOL::uvApp(f1, e, pare, eps, uvapp1); if (!ok1) + { return false; + } gp_Pnt pf1; FUN_tool_value(uvapp1, f1, pf1); @@ -1540,7 +1746,9 @@ bool TopOpeBRepTool_TOOL::MatterKPtg(const TopoDS_Face& f1, gp_Pnt pf2; FUN_tool_value(uv2, f2, pf2); if (!ok2) + { return false; + } gp_Dir v12(gp_Vec(pf1, pf2)); double dot = v12.Dot(nt1); @@ -1576,7 +1784,9 @@ bool TopOpeBRepTool_TOOL::Getstp3dF(const gp_Pnt& p, double d; bool ok = FUN_tool_projPonF(p, f, uv, d); if (!ok) + { return false; + } if (d < tol3d) { st = TopAbs_ON; @@ -1586,12 +1796,16 @@ bool TopOpeBRepTool_TOOL::Getstp3dF(const gp_Pnt& p, gp_Pnt ppr; ok = FUN_tool_value(uv, f, ppr); if (!ok) + { return false; + } gp_Dir ntf; ok = TopOpeBRepTool_TOOL::Nt(uv, f, ntf); if (!ok) + { return false; + } gp_Dir dppr(gp_Vec(p, ppr)); double dot = dppr.Dot(ntf); @@ -1607,7 +1821,9 @@ void TopOpeBRepTool_TOOL::MkShell(const NCollection_List& lF, Topo BRep_Builder BB; BB.MakeShell(TopoDS::Shell(She)); for (NCollection_List::Iterator li(lF); li.More(); li.Next()) + { BB.Add(She, li.Value()); + } } //================================================================================================= @@ -1624,7 +1840,9 @@ bool TopOpeBRepTool_TOOL::Remove(NCollection_List& loS, const Topo found = true; } else + { it.Next(); + } } return found; } @@ -1659,21 +1877,37 @@ void TopOpeBRepTool_TOOL::stuvF(const gp_Pnt2d& uv, const TopoDS_Face& f, int& o bool onuf = (std::abs(uf - u) < tolu), onul = (std::abs(ul - u) < tolu); bool onvf = (std::abs(vf - v) < tolv), onvl = (std::abs(vl - v) < tolv); if (onuf) + { onU = ONFIRST; + } if (onul) + { onU = ONLAST; + } if (onvf) + { onV = ONFIRST; + } if (onvl) + { onV = ONLAST; + } if (u < (uf - tolu)) + { onU = INFFIRST; + } if (u > (ul + tolu)) + { onU = SUPLAST; + } if (v < (vf - tolv)) + { onV = INFFIRST; + } if (v > (vl + tolv)) + { onV = SUPLAST; + } } //================================================================================================= @@ -1731,7 +1965,9 @@ bool TopOpeBRepTool_TOOL::WireToFace( BB.Add(FF, wwi); } if (toreverse) + { FF.Orientation(TopAbs_REVERSED); + } lFs.Append(FF); } return true; @@ -1758,12 +1994,16 @@ bool TopOpeBRepTool_TOOL::EdgeONFace(const double par, gp_Vec tge; bool ok = TopOpeBRepTool_TOOL::TggeomE(par, ed, tge); if (!ok) + { return false; + } gp_Vec ngf = FUN_tool_nggeomF(uv, fa); double aProdDot = tge.Dot(ngf); bool etgf = std::abs(aProdDot) < tola; if (!etgf) + { return true; + } BRepAdaptor_Surface bs(fa); GeomAbs_SurfaceType st = bs.GetType(); @@ -1791,15 +2031,25 @@ bool TopOpeBRepTool_TOOL::EdgeONFace(const double par, gp_Dir ne; bool det = true; if (circle) + { ne = bc.Circle().Axis().Direction(); + } else if (ct == GeomAbs_Ellipse) + { ne = bc.Ellipse().Axis().Direction(); + } else if (ct == GeomAbs_Hyperbola) + { ne = bc.Hyperbola().Axis().Direction(); + } else if (ct == GeomAbs_Parabola) + { ne = bc.Parabola().Axis().Direction(); + } else + { det = false; + } if (det) { double prod = ne.Dot(ngf); @@ -1812,11 +2062,17 @@ bool TopOpeBRepTool_TOOL::EdgeONFace(const double par, gp_Dir ne; bool det = true; if (line) + { ne = tge; + } else if (circle) + { ne = bc.Circle().Axis().Direction(); + } else + { det = false; + } gp_Dir axicy = bs.Cylinder().Axis().Direction(); if (det) @@ -1845,7 +2101,9 @@ bool TopOpeBRepTool_TOOL::EdgeONFace(const double par, gp_Pnt2d ouv; ok = FUN_tool_parF(ed, opar, fa, ouv, tolf); if (!ok) + { return false; + } gp_Pnt ops = bs.Value(ouv.X(), ouv.Y()); double dd = opc.Distance(ops); diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOPOLOGY.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOPOLOGY.cxx index a0cea1a8c2..78121760d9 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOPOLOGY.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_TOPOLOGY.cxx @@ -122,7 +122,9 @@ Standard_EXPORT bool FUN_tool_geombounds(const TopoDS_Face& F, { const occ::handle& S = BRep_Tool::Surface(F); if (S.IsNull()) + { return false; + } S->Bounds(u1, u2, v1, v2); return true; } @@ -162,7 +164,9 @@ Standard_EXPORT bool FUN_tool_isobounds(const TopoDS_Shape& Sh, const occ::handle& S = BRep_Tool::Surface(F); if (S.IsNull()) + { return false; + } bool uclosed, vclosed; double uperiod, vperiod; @@ -184,7 +188,9 @@ Standard_EXPORT bool FUN_tool_isobounds(const TopoDS_Shape& Sh, double f, l, tol; occ::handle PC = FC2D_CurveOnSurface(E, F, f, l, tol); if (PC.IsNull()) + { return false; + } bool isou, isov; gp_Pnt2d o2d; @@ -205,7 +211,9 @@ Standard_EXPORT bool FUN_tool_isobounds(const TopoDS_Shape& Sh, v2 = std::max(p2dl.Y(), v2); } if (!isouv) + { return false; + } // ==================== } return true; @@ -221,14 +229,18 @@ Standard_EXPORT bool FUN_tool_outbounds(const TopoDS_Shape& Sh, { occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(Sh)); if (S.IsNull()) + { return false; + } double uf, ul, vf, vl; S->Bounds(uf, ul, vf, vl); outbounds = false; bool ok = FUN_tool_bounds(Sh, u1, u2, v1, v2); if (!ok) + { return false; + } const TopoDS_Face& F = TopoDS::Face(Sh); bool uclosed, vclosed; @@ -305,7 +317,9 @@ Standard_EXPORT bool FUN_tool_value(const double par, const TopoDS_Edge& E, gp_P double l = BAC.LastParameter(); bool ok = (f <= par) && (par <= l); if (!ok) + { return false; + } P = BAC.Value(par); return true; } @@ -369,11 +383,17 @@ Standard_EXPORT int FUN_tool_orientVinE(const TopoDS_Vertex& v, const TopoDS_Edg bool visf = v.IsSame(vf); bool visl = v.IsSame(vl); if (visf) + { result = FIRST; + } if (visl) + { result = LAST; + } if (visf && visl) + { result = CLOSING; + } return result; } @@ -412,7 +432,9 @@ Standard_EXPORT bool FUN_tool_orientEinFFORWARD(const TopoDS_Edge& E, TopAbs_Orientation reso; bool ok = ::FUN_tool_orientEinF(E, FF, reso); if (ok) + { oriEinF = reso; + } return ok; } @@ -422,10 +444,14 @@ Standard_EXPORT bool FUN_tool_EboundF(const TopoDS_Edge& E, const TopoDS_Face& F TopAbs_Orientation ori; bool ok = FUN_tool_orientEinFFORWARD(E, F, ori); if (!ok) + { return false; + } bool closingE = BRep_Tool::IsClosed(E, F); if (closingE) + { return true; + } bool notbound = (ori == TopAbs_INTERNAL) || (ori == TopAbs_EXTERNAL); return notbound; } @@ -457,7 +483,9 @@ Standard_EXPORT bool FUN_tool_nggeomF(const double& paronE, occ::handle c2d = FC2D_CurveOnSurface(E, F, f, l, ttol); project = c2d.IsNull(); if (!project) + { p2d = c2d->Value(paronE); + } } if (project) { @@ -474,17 +502,23 @@ Standard_EXPORT bool FUN_tool_nggeomF(const double& paronE, occ::handle c2d = FC2D_CurveOnSurface(E, F, f, l, ttol); ok = !c2d.IsNull(); if (ok) + { p2d = c2d->Value(paronE); + } } if (!ok) + { return false; + } // modified by NIZHNY-MZV Wed Dec 1 13:56:14 1999 // xpu010698 gp_Pnt p3duv; FUN_tool_value(p2d, F, p3duv); double dd = p3duv.Distance(p3d); if (dd > tol) + { return false; + } // xpu010698 } nggeomF = FUN_tool_nggeomF(p2d, F); @@ -513,7 +547,9 @@ Standard_EXPORT bool FUN_tool_EtgF(const double& paronE, gp_Vec tgE; bool ok = TopOpeBRepTool_TOOL::TggeomE(paronE, E, tgE); if (!ok) + { return false; // NYIRAISE + } gp_Vec ngF = FUN_tool_nggeomF(p2d, F); double prod = tgE.Dot(ngF); @@ -531,11 +567,15 @@ Standard_EXPORT bool FUN_tool_EtgOOE(const double& paronE, gp_Vec tgOOE; bool ok = TopOpeBRepTool_TOOL::TggeomE(paronOOE, OOE, tgOOE); if (!ok) + { return false; // NYIRAISE + } gp_Vec tgE; ok = TopOpeBRepTool_TOOL::TggeomE(paronE, E, tgE); if (!ok) + { return false; // NYIRAISE + } double prod = tgOOE.Dot(tgE); bool tg = (std::abs(1 - std::abs(prod)) < tola); return tg; @@ -558,7 +598,9 @@ Standard_EXPORT bool FUN_nearestISO(const TopoDS_Face& F, double dl = xpar - xsup; bool onl = (std::abs(dl) < tol2d); if (onf || onl) + { return true; + } bool isoV = !isoU; TopExp_Explorer ex(F, TopAbs_EDGE); @@ -570,19 +612,31 @@ Standard_EXPORT bool FUN_nearestISO(const TopoDS_Face& F, gp_Dir2d d2d; bool isouv = TopOpeBRepTool_TOOL::UVISO(E, F, isou, isov, d2d, o2d); if (!isouv) + { return false; + } bool compare = (isoU && isou) || (isoV && isov); if (!compare) + { return false; + } double xvalue = isou ? o2d.X() : o2d.Y(); if (xvalue < xpar) + { if (xinf < xvalue) + { xinf = xvalue; + } + } if (xpar < xvalue) + { if (xvalue < xsup) + { xsup = xvalue; + } + } } return true; } @@ -597,7 +651,9 @@ Standard_EXPORT bool FUN_tool_EitangenttoFe(const gp_Dir& ngFe, gp_Vec tgEi; bool ok = TopOpeBRepTool_TOOL::TggeomE(parOnEi, Ei, tgEi); if (!ok) + { return false; // NYIRAISE + } double prod = ngFe.Dot(tgEi); double tol = Precision::Parametric(Precision::Confusion()); @@ -647,7 +703,9 @@ Standard_EXPORT bool FUN_tool_closedS(const TopoDS_Shape& F, // const occ::handle& S = BRep_Tool::Surface(TopoDS::Face(F)); occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); if (S.IsNull()) + { return false; + } bool closed = FUN_tool_closed(S, uclosed, uperiod, vclosed, vperiod); return closed; } @@ -668,10 +726,14 @@ Standard_EXPORT bool FUN_tool_closedS(const TopoDS_Shape& F, bool& inU, double& double uperiod, vperiod; occ::handle S = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); if (S.IsNull()) + { return false; + } bool closed = FUN_tool_closed(S, uclosed, uperiod, vclosed, vperiod); if (!closed) + { return false; + } double u1, u2, v1, v2; S->Bounds(u1, u2, v1, v2); @@ -721,11 +783,17 @@ Standard_EXPORT bool FUN_tool_IsClosingE(const TopoDS_Edge& E, int nbocc = 0; TopExp_Explorer exp; for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) + { // for (TopExp_Explorer exp(S,TopAbs_EDGE);exp.More();exp.Next()) if (exp.Current().IsSame(E)) + { nbocc++; + } + } if (nbocc != 2) + { return false; + } return BRep_Tool::IsClosed(E, F); } @@ -786,13 +854,17 @@ Standard_EXPORT bool FUN_tool_Eshared(const TopoDS_Shape& v, bool e1ok = false; TopExp_Explorer exv(e1, TopAbs_VERTEX); for (; exv.More(); exv.Next()) + { if (exv.Current().IsSame(v)) { e1ok = true; break; } + } if (e1ok) + { e1s.Append(e1); + } } ex.Init(F2, TopAbs_EDGE); for (; ex.More(); ex.Next()) @@ -800,11 +872,13 @@ Standard_EXPORT bool FUN_tool_Eshared(const TopoDS_Shape& v, const TopoDS_Shape& e2 = ex.Current(); NCollection_List::Iterator it1(e1s); for (; it1.More(); it1.Next()) + { if (it1.Value().IsSame(e2)) { Eshared = e2; return true; } + } } return false; } @@ -845,7 +919,9 @@ Standard_EXPORT bool FUN_tool_parVonE(const TopoDS_Vertex& v, const TopoDS_Edge& Extrema_ExtPC pro(pt, BAC); bool done = pro.IsDone() && (pro.NbExt() > 0); if (!done) + { return false; + } int i = FUN_tool_getindex(pro); par = pro.Point(i).Parameter(); } @@ -862,12 +938,16 @@ Standard_EXPORT bool FUN_tool_parE(const TopoDS_Edge& E0, gp_Pnt P; bool ok = FUN_tool_value(par0, E0, P); if (!ok) + { return false; + } double dist; ok = FUN_tool_projPonE(P, E, par, dist); if (!ok) + { return false; + } ok = (dist < tol); return ok; @@ -896,12 +976,16 @@ Standard_EXPORT bool FUN_tool_parF(const TopoDS_Edge& E, gp_Pnt P; bool ok = FUN_tool_value(par, E, P); if (!ok) + { return false; + } double dist; ok = FUN_tool_projPonF(P, F, UV, dist); if (!ok) + { return false; + } ok = (dist < tol3d); return ok; @@ -934,7 +1018,9 @@ Standard_EXPORT bool FUN_tool_paronEF(const TopoDS_Edge& E, } bool ok = (f <= par) && (par <= l); if (!ok) + { return false; + } UV = PC->Value(par); return true; } @@ -964,7 +1050,9 @@ Standard_EXPORT gp_Vec FUN_tool_tggeomE(const double paronE, const TopoDS_Edge& { bool isdgE = BRep_Tool::Degenerated(E); if (isdgE) + { return gp_Vec(0, 0, 0); + } gp_Vec dirE(FUN_tool_dirC(paronE, E)); return dirE; } @@ -991,15 +1079,25 @@ Standard_EXPORT bool FUN_tool_quad(const BRepAdaptor_Curve& BAC) GeomAbs_CurveType CT = BAC.GetType(); bool isquad = false; if (CT == GeomAbs_Line) + { isquad = true; + } if (CT == GeomAbs_Circle) + { isquad = true; + } if (CT == GeomAbs_Ellipse) + { isquad = true; + } if (CT == GeomAbs_Hyperbola) + { isquad = true; + } if (CT == GeomAbs_Parabola) + { isquad = true; + } return isquad; } @@ -1062,13 +1160,21 @@ Standard_EXPORT bool FUN_tool_maxtol(const TopoDS_Shape& S, const TopoDS_Shape& ss = ex.Current(); double tolss = 0.; if (face) + { tolss = BRep_Tool::Tolerance(TopoDS::Face(ss)); + } if (edge) + { tolss = BRep_Tool::Tolerance(TopoDS::Edge(ss)); + } if (vertex) + { tolss = BRep_Tool::Tolerance(TopoDS::Vertex(ss)); + } if (tolss > maxtol) + { maxtol = tolss; + } } return hasshatyp; } @@ -1090,7 +1196,9 @@ Standard_EXPORT int FUN_tool_nbshapes(const TopoDS_Shape& S, const TopAbs_ShapeE TopExp_Explorer ex(S, typ); int i = 0; for (; ex.More(); ex.Next()) + { i++; + } return i; } @@ -1101,7 +1209,9 @@ Standard_EXPORT void FUN_tool_shapes(const TopoDS_Shape& S, { TopExp_Explorer ex(S, typ); for (; ex.More(); ex.Next()) + { ltyp.Append(ex.Current()); + } } // ---------------------------------------------------------------------- @@ -1118,7 +1228,9 @@ Standard_EXPORT int FUN_tool_comparebndkole(const TopoDS_Shape& sh1, const TopoD bnd2.SetGap(0.); if (bnd1.IsOut(bnd2)) + { return 0; + } NCollection_Array1 xyz1(1, 6), xyz2(1, 6); bnd1.Get(xyz1(1), xyz1(2), xyz1(3), xyz1(4), xyz1(5), xyz1(6)); bnd2.Get(xyz2(1), xyz2(2), xyz2(3), xyz2(4), xyz2(5), xyz2(6)); @@ -1138,7 +1250,9 @@ Standard_EXPORT int FUN_tool_comparebndkole(const TopoDS_Shape& sh1, const TopoD continue; } if (d < 0.) + { n2sup++; + } } for (i = 4; i <= 6; i++) { @@ -1150,12 +1264,18 @@ Standard_EXPORT int FUN_tool_comparebndkole(const TopoDS_Shape& sh1, const TopoD continue; } if (d > 0.) + { n2sup++; + } } if (n2sup + neq != 6) + { return 0; + } if (neq == 6) + { return 0; + } int ires = (n2sup > 0) ? 2 : 1; return ires; @@ -1175,11 +1295,15 @@ Standard_EXPORT bool FUN_tool_SameOri(const TopoDS_Edge& E1, const TopoDS_Edge& gp_Vec tmp; bool ok = TopOpeBRepTool_TOOL::TggeomE(mid, E2, tmp); if (!ok) + { return false; + } gp_Dir tgE2(tmp); TopAbs_Orientation oriE2 = E2.Orientation(); if (M_REVERSED(oriE2)) + { tgE2.Reverse(); + } double pE1, dist; ok = FUN_tool_projPonE(Pmid, E1, pE1, dist); @@ -1187,16 +1311,24 @@ Standard_EXPORT bool FUN_tool_SameOri(const TopoDS_Edge& E1, const TopoDS_Edge& double tol2 = BRep_Tool::Tolerance(E2); double tol = std::max(tol1, tol2) * 10.; if (dist > tol) + { return false; + } if (!ok) + { return false; + } ok = TopOpeBRepTool_TOOL::TggeomE(pE1, E1, tmp); if (!ok) + { return false; + } gp_Dir tgE1(tmp); TopAbs_Orientation oriE1 = E1.Orientation(); if (M_REVERSED(oriE1)) + { tgE1.Reverse(); + } bool sameori = (tgE2.Dot(tgE1) > 0.); return sameori; @@ -1217,12 +1349,16 @@ Standard_EXPORT bool FUN_tool_pcurveonF(const TopoDS_Face& F, TopoDS_Edge& E) double f, l; occ::handle C3d = BRep_Tool::Curve(E, f, l); if (C3d.IsNull()) + { return false; + } double tolReached2d; occ::handle C2d = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F, C3d, tolReached2d, f, l); if (C2d.IsNull()) + { return false; + } double tolE = BRep_Tool::Tolerance(E); BRep_Builder BB; @@ -1276,11 +1412,15 @@ Standard_EXPORT bool FUN_tool_pcurveonF(const TopoDS_Face& fF, TopoDS_Wire neww; bool ok = FUN_tool_MakeWire(loe, neww); if (!ok) + { return false; + } low.Append(neww); } else + { low.Append(w); + } } // exw if (hasnewf) { @@ -1311,20 +1451,30 @@ Standard_EXPORT bool FUN_tool_curvesSO(const TopoDS_Edge& E1, gp_Vec tg1; bool ok = TopOpeBRepTool_TOOL::TggeomE(p1, E1, tg1); if (!ok) + { return false; // NYIRAISE + } gp_Vec tg2; ok = TopOpeBRepTool_TOOL::TggeomE(p2, E2, tg2); if (!ok) + { return false; // NYIRAISE + } double tola = Precision::Angular() * 1.e3; bool oppo = tg1.IsOpposite(tg2, tola); bool samo = tg1.IsParallel(tg2, tola); if (oppo) + { so = false; + } else if (samo) + { so = true; + } else + { return false; + } return true; } @@ -1337,7 +1487,9 @@ Standard_EXPORT bool FUN_tool_curvesSO(const TopoDS_Edge& E1, double p2 = 0.; bool ok = FUN_tool_parE(E1, p1, E2, p2); if (!ok) + { return false; + } ok = FUN_tool_curvesSO(E1, p1, E2, p2, so); return ok; } @@ -1354,19 +1506,31 @@ Standard_EXPORT bool FUN_tool_curvesSO(const TopoDS_Edge& E1, const TopoDS_Edge& bool closed2 = vf2.IsSame(vl2); bool project = false; if (closed1 || closed2) + { project = true; + } else { if (vf1.IsSame(vf2)) + { so = true; + } else if (vl1.IsSame(vl2)) + { so = true; + } else if (vf1.IsSame(vl2)) + { so = false; + } else if (vl1.IsSame(vf2)) + { so = false; + } else + { project = true; + } } if (project) { diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_connexity.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_connexity.cxx index db92af26d8..67a321946c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_connexity.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_connexity.cxx @@ -135,7 +135,9 @@ bool TopOpeBRepTool_connexity::RemoveItem(const int OriKey, const TopoDS_Shape& return true; } else + { it.Next(); + } } return false; } @@ -149,7 +151,9 @@ bool TopOpeBRepTool_connexity::RemoveItem(const TopoDS_Shape& Item) { bool found = RemoveItem(i, Item); if (found) + { removed = true; + } } return removed; } @@ -206,9 +210,13 @@ int TopOpeBRepTool_connexity::IsInternal(NCollection_List& Item) c } int oKey1 = TopOpeBRepTool_TOOL::OriinSor(theKey, item1.Oriented(TopAbs_FORWARD)); if (oKey1 != INTERNAL) + { lINT.Remove(it1); + } else + { it1.Next(); + } } NCollection_List lEXT; @@ -225,7 +233,9 @@ int TopOpeBRepTool_connexity::IsInternal(NCollection_List& Item) c } int oKey2 = TopOpeBRepTool_TOOL::OriinSor(theKey, item2.Oriented(TopAbs_FORWARD)); if (oKey2 == INTERNAL) + { lINT.Append(item2); + } it2.Next(); } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_face.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_face.cxx index 06e27f6580..741f7025f6 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_face.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_face.cxx @@ -66,9 +66,13 @@ bool TopOpeBRepTool_face::Init(const TopoDS_Wire& W, const TopoDS_Face& Fref) // : if (myfinite) + { myFfinite = fres; + } else + { FUN_reverse(fres, myFfinite); + } return true; } @@ -84,7 +88,9 @@ bool TopOpeBRepTool_face::IsDone() const bool TopOpeBRepTool_face::Finite() const { if (!IsDone()) + { throw Standard_Failure("TopOpeBRepTool_face NOT DONE"); + } return myfinite; } @@ -93,7 +99,9 @@ bool TopOpeBRepTool_face::Finite() const const TopoDS_Face& TopOpeBRepTool_face::Ffinite() const { if (!IsDone()) + { throw Standard_Failure("TopOpeBRepTool_face NOT DONE"); + } return myFfinite; } @@ -112,7 +120,9 @@ const TopoDS_Wire& TopOpeBRepTool_face::W() const TopoDS_Face TopOpeBRepTool_face::RealF() const { if (myfinite) + { return myFfinite; + } TopoDS_Face realf; FUN_reverse(myFfinite, realf); return realf; diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_faulty.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_faulty.cxx index 01b6edecf3..959782d2f1 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_faulty.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_faulty.cxx @@ -56,12 +56,16 @@ Standard_EXPORT void FUN_tool_tori(const TopAbs_Orientation Or) Standard_EXPORT void FUN_tool_trace(const int Index) { if (Index == 1) + { std::cout << "FORWARD "; + } if (Index == 2) + { std::cout << "REVERSED "; + } } Standard_EXPORT void FUN_tool_trace(const gp_Pnt2d p2d) { - std::cout << " = (" << p2d.X() << " " << p2d.Y() << ")" << std::endl; + std::cout << " = (" << p2d.X() << " " << p2d.Y() << ")" << '\n'; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx index d5fabfbeca..f4c99c33a3 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx @@ -75,7 +75,9 @@ bool TopOpeBRepTool_makeTransition::Initialize(const TopoDS_Edge& E, { bool isdge = BRep_Tool::Degenerated(E); if (isdge) + { return false; + } myE = E; mypb = pbef; @@ -88,7 +90,9 @@ bool TopOpeBRepTool_makeTransition::Initialize(const TopoDS_Edge& E, bool facko = (factor < 0.) || (factor > 1.); if (facko) + { return false; + } bool ok = TopOpeBRepTool_TOOL::EdgeONFace(mypE, myE, myuv, FS, isT2d); return ok; @@ -121,7 +125,9 @@ bool TopOpeBRepTool_makeTransition::SetRest(const TopoDS_Edge& ES, const double { bool isdge = BRep_Tool::Degenerated(ES); if (isdge) + { return false; + } hasES = true; myES = ES; @@ -155,19 +161,31 @@ static int FUN_mkT2dquad(const double curvC1, const double curvC2) bool nullc1 = FUN_nullcurv(curvC1); bool nullc2 = FUN_nullcurv(curvC2); if (nullc2 && nullc1) + { return isON2; + } if (nullc2) + { return isINifh1; // is IN if (dot=tg1(pt after).xx2 > 0) + } if (nullc1) + { return isINifh2; // is IN if (dot=tg2(pt after).xx2 < 0) + } bool samec = (std::abs(curvC2 - curvC1) < 1.e-2); // NYITOLXPU kpartkoletge if (samec) + { return isON2ifss; // is ON if curves are on same side/tg line + } if (curvC1 > curvC2) + { return isIN2ifss; // is IN if curves are on same side/tg line + } else + { return isOU2ifss; // is OU if curves are on same side/tg line + } // return 0; } @@ -185,9 +203,13 @@ static bool FUN_getnearpar(const TopoDS_Edge& e, bool onf = (std::abs(par - f) < tol1d); bool onl = (std::abs(par - l) < tol1d); if (onf && (sta == BEFORE)) + { return false; + } if (onl && (sta == AFTER)) + { return false; + } // nearpar = (sta == BEFORE) ? ((1-factor)*par - factor*f) : ((1-factor)*par - factor*l); nearpar = (sta == BEFORE) ? (par - factor * (l - f)) : (par + factor * (l - f)); return true; @@ -205,15 +227,21 @@ static bool FUN_tg(const TopoDS_Edge& e, for (int nite = 1; nite <= 2; nite++) { if (nite == 2) + { st = AFTER; + } double pn = 0.; bool mkp = FUN_getnearpar(e, par, f, l, factor, st, pn); if (!mkp) + { continue; + } gp_Vec tmp; bool ok = TopOpeBRepTool_TOOL::TggeomE(pn, e, tmp); if (!ok) + { continue; + } tg = gp_Dir(tmp); return true; } @@ -296,7 +324,9 @@ static bool FUN_mkT2dquad(const TopoDS_Edge& e1, gp_Dir tgnear1; bool ok = FUN_tg(e1, par1, f1, l1, factor, tgnear1, st1); if (!ok) + { return false; + } tga1 = (st1 == AFTER) ? tgnear1 : tgnear1.Reversed(); } bool mk2 = (mkt == isINifh2) || (mkt == isON2ifss) || (mkt == isOU2ifss); @@ -308,7 +338,9 @@ static bool FUN_mkT2dquad(const TopoDS_Edge& e1, gp_Dir tgnear2; bool ok = FUN_tg(e2, par2, f2, l2, factor, tgnear2, st2); if (!ok) + { return false; + } tga2 = (st2 == AFTER) ? tgnear2 : tgnear2.Reversed(); } return (FUN_getsta(mkt, tga1, tga2, xx2, sta)); @@ -319,7 +351,9 @@ static bool FUN_mkT2dquad(const TopoDS_Edge& e1, bool TopOpeBRepTool_makeTransition::MkT2donE(TopAbs_State& Stb, TopAbs_State& Sta) const { if (!isT2d) + { return false; + } // E is IN 2d(FS), meets no restriction at given point : if (!hasES) @@ -331,7 +365,9 @@ bool TopOpeBRepTool_makeTransition::MkT2donE(TopAbs_State& Stb, TopAbs_State& St // E is IN 2d(FS), meets restriction ES at given point : int oriESFS = TopOpeBRepTool_TOOL::OriinSor(myES, myFS, true); if (oriESFS == 0) + { return false; + } // ES is closing edge for FS, or ES is INTERNAL in FS : if (oriESFS == INTERNAL) @@ -348,12 +384,16 @@ bool TopOpeBRepTool_makeTransition::MkT2donE(TopAbs_State& Stb, TopAbs_State& St gp_Vec tmp; bool ok = TopOpeBRepTool_TOOL::TggeomE(mypE, myE, tmp); if (!ok) + { return false; + } gp_Dir tgE(tmp); gp_Dir xxES; ok = TopOpeBRepTool_TOOL::XX(myuv, myFS, mypES, myES, xxES); if (!ok) + { return false; + } double tola = FUN_tolang(); double dot = tgE.Dot(xxES); @@ -383,15 +423,21 @@ bool TopOpeBRepTool_makeTransition::MkT2donE(TopAbs_State& Stb, TopAbs_State& St gp_Dir ntFS; ok = TopOpeBRepTool_TOOL::Nt(myuv, myFS, ntFS); if (!ok) + { return false; + } double curvE; ok = TopOpeBRepTool_TOOL::CurvE(myE, mypE, ntFS, curvE); if (!ok) + { return false; + } double curvES; ok = TopOpeBRepTool_TOOL::CurvE(myES, mypES, ntFS, curvES); if (!ok) + { return false; + } bool quadE = TopOpeBRepTool_TOOL::IsQuad(myE); bool quadES = TopOpeBRepTool_TOOL::IsQuad(myES); @@ -424,7 +470,9 @@ static bool FUN_getnearuv(const TopoDS_Face& f, gp_Vec2d xuv = gp_Vec2d(duv).Multiplied(factor); if (sta == BEFORE) + { xuv.Reverse(); + } nearuv = uv.Translated(xuv); int onu, onv; @@ -432,7 +480,9 @@ static bool FUN_getnearuv(const TopoDS_Face& f, bool uok = (onu == 0); bool vok = (onv == 0); if (uok && vok) + { return true; + } double nearu = nearuv.X(), nearv = nearuv.Y(); @@ -440,24 +490,36 @@ static bool FUN_getnearuv(const TopoDS_Face& f, { bool ucl = bs.IsUClosed(); if (!ucl) + { return false; + } double uper = bs.UPeriod(); if (onu == INFFIRST) + { nearu += uper; + } else + { nearu -= uper; + } } if ((onv == INFFIRST) || (onv == SUPLAST)) { bool vcl = bs.IsVClosed(); if (!vcl) + { return false; + } double vper = bs.VPeriod(); if (onv == INFFIRST) + { nearv += vper; + } else + { nearv -= vper; + } } nearuv = gp_Pnt2d(nearu, nearv); return true; @@ -477,16 +539,22 @@ static bool FUN_tgef(const TopoDS_Face& f, for (int nite = 1; nite <= 2; nite++) { if (nite == 2) + { st = AFTER; + } gp_Pnt2d nearuv; // double pn; bool mkp = FUN_getnearuv(f, uv, factor, st, duv, nearuv); if (!mkp) + { continue; + } gp_Dir nt; bool ok = TopOpeBRepTool_TOOL::Nt(nearuv, f, nt); if (!ok) + { return false; + } // recall : ntf^tge = tg0, (tgef(uv) = tge) // => near interference point, we assume nt^tgef(nearuv) = tg0 tgef = tg0.Crossed(nt); @@ -522,7 +590,9 @@ static bool FUN_mkT3dquad(const TopoDS_Edge& e, gp_Dir tgnear; bool ok = FUN_tg(e, par, pf, pl, factor, tgnear, st); if (!ok) + { return false; + } tgae = (st == AFTER) ? tgnear : tgnear.Reversed(); } bool mkef = (mkt == isINifh2) || (mkt == isON2ifss) || (mkt == isOU2ifss); @@ -533,12 +603,16 @@ static bool FUN_mkT3dquad(const TopoDS_Edge& e, gp_Dir2d duv; bool ok = TopOpeBRepTool_TOOL::Getduv(f, uv, tge, fac3d, duv); if (!ok) + { return false; + } gp_Dir tgnear; int st = 0; ok = FUN_tgef(f, uv, duv, factor, tge, tg0, tgnear, st); if (!ok) + { return false; + } tgaef = (st == AFTER) ? tgnear : tgnear.Reversed(); } return (FUN_getsta(mkt, tgae, tgaef, xxef, sta)); @@ -556,12 +630,18 @@ static TopAbs_State FUN_stawithES(const gp_Dir& tgE, const gp_Dir& xxES, const i double prod = tgE.Dot(xxES); double tola = FUN_tolang(); if (std::abs(prod) < tola) + { return TopAbs_UNKNOWN; + } bool positive = (prod > 0.); if (positive) + { sta = (st == BEFORE) ? TopAbs_OUT : TopAbs_IN; // T.Set(TopAbs_FORWARD); + } else + { sta = (st == BEFORE) ? TopAbs_IN : TopAbs_OUT; // T.Set(TopAbs_REVERSED); + } // sta = (iP == BEFORE) ? T.Before() : T.After(); return sta; } // FUN_stawithES @@ -573,12 +653,16 @@ static TopAbs_State FUN_stawithES(const gp_Dir& tgE, { TopAbs_State str = TopAbs_UNKNOWN; if (M_UNKNOWN(stt)) + { return str; + } TopAbs_State stES = FUN_stawithES(tgE, xxES, st); // we keep statx as IN or ON if xwithline is IN if (M_IN(stt) || M_ON(stt)) + { str = M_IN(stES) ? stt : TopAbs_OUT; + } return str; } @@ -594,11 +678,15 @@ static bool FUN_staproj(const TopoDS_Edge& e, double par = 0.; bool ok = FUN_getnearpar(e, pe, pf, pl, factor, st, par); if (!ok) + { return false; + } gp_Pnt pt; ok = FUN_tool_value(par, e, pt); if (!ok) + { return false; + } gp_Pnt2d uv; ok = TopOpeBRepTool_TOOL::Getstp3dF(pt, f, uv, sta); return ok; @@ -614,7 +702,9 @@ bool TopOpeBRepTool_makeTransition::MkT3dproj(TopAbs_State& Stb, TopAbs_State& S Stb = Sta = TopAbs_UNKNOWN; bool okb = FUN_staproj(myE, mypb, mypa, mypE, myfactor, BEFORE, myFS, Stb); if (!okb) + { return false; + } bool oka = FUN_staproj(myE, mypb, mypa, mypE, myfactor, AFTER, myFS, Sta); return oka; } @@ -638,16 +728,22 @@ bool TopOpeBRepTool_makeTransition::MkT3dproj(TopAbs_State& Stb, TopAbs_State& S bool TopOpeBRepTool_makeTransition::MkT3onE(TopAbs_State& Stb, TopAbs_State& Sta) const { if (isT2d) + { return false; + } gp_Vec tmp; bool ok = TopOpeBRepTool_TOOL::TggeomE(mypE, myE, tmp); if (!ok) + { return false; + } gp_Dir tgE(tmp); gp_Dir ntFS; ok = TopOpeBRepTool_TOOL::Nt(myuv, myFS, ntFS); if (!ok) + { return false; + } double tola = FUN_tolang(); double dot = tgE.Dot(ntFS); @@ -666,12 +762,16 @@ bool TopOpeBRepTool_makeTransition::MkT3onE(TopAbs_State& Stb, TopAbs_State& Sta double curE; ok = TopOpeBRepTool_TOOL::CurvE(myE, mypE, tg0, curE); if (!ok) + { return false; + } double curFS; bool direct; ok = TopOpeBRepTool_TOOL::CurvF(myFS, myuv, tg0, curFS, direct); if (!ok) + { return false; + } bool quadE = TopOpeBRepTool_TOOL::IsQuad(myE); bool quadFS = TopOpeBRepTool_TOOL::IsQuad(myFS); @@ -687,7 +787,9 @@ bool TopOpeBRepTool_makeTransition::MkT3onE(TopAbs_State& Stb, TopAbs_State& Sta gp_Dir xxES; bool isOK = TopOpeBRepTool_TOOL::XX(myuv, myFS, mypES, myES, xxES); if (!isOK) + { return false; + } Stb = FUN_stawithES(tgE, xxES, BEFORE, sta); Sta = FUN_stawithES(tgE, xxES, AFTER, sta); } @@ -710,24 +812,32 @@ bool TopOpeBRepTool_makeTransition::MkTonE(TopAbs_State& Stb, TopAbs_State& Sta) { Stb = Sta = TopAbs_UNKNOWN; if (isT2d) + { return (MkT2donE(Stb, Sta)); + } bool ok = MkT3onE(Stb, Sta); if (!ok) + { ok = MkT3dproj(Stb, Sta); + } // if (!ok) return false; gp_Vec tmp; ok = TopOpeBRepTool_TOOL::TggeomE(mypE, myE, tmp); if (!ok) + { return false; + } gp_Dir tgE(tmp); gp_Dir xxES; if (hasES && ok) { ok = TopOpeBRepTool_TOOL::XX(myuv, myFS, mypES, myES, xxES); if (!ok) + { return false; + } } double delta = (1. - myfactor) / 5.; @@ -737,7 +847,9 @@ bool TopOpeBRepTool_makeTransition::MkTonE(TopAbs_State& Stb, TopAbs_State& Sta) kob = (Stb == TopAbs_ON) || (Stb == TopAbs_UNKNOWN); koa = (Sta == TopAbs_ON) || (Sta == TopAbs_UNKNOWN); if (!koa && !kob) + { return true; + } bool okb = true, oka = true; if (kob) diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_matter.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_matter.cxx index 6c2542c5c5..5d1c9fbe56 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_matter.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_matter.cxx @@ -78,7 +78,9 @@ Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face&, gp_Vec tgEi; bool ok = TopOpeBRepTool_TOOL::TggeomE(parEi, Ei, tgEi); if (!ok) + { return gp_Vec(0., 0., 0.); // NYIRAISE + } gp_Dir XX = FUN_tool_nCinsideS(tgEi, ngFi); return XX; } @@ -92,7 +94,9 @@ Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& Fi, gp_Pnt2d uvi; bool ok = FUN_tool_paronEF(Ei, parOnEi, Fi, uvi); if (!ok) + { return xx; // nyiRaise + } gp_Vec ngFi = FUN_tool_nggeomF(uvi, Fi); xx = FUN_tool_getgeomxx(Fi, Ei, parOnEi, ngFi); return xx; @@ -107,14 +111,20 @@ Standard_EXPORT bool FUN_tool_getxx(const TopoDS_Face& Fi, { gp_Vec xx = FUN_tool_getgeomxx(Fi, Ei, parEi, ngFi); if (xx.Magnitude() < gp::Resolution()) + { return false; + } XX = gp_Dir(xx); TopAbs_Orientation oriEinF; bool ok = FUN_tool_orientEinFFORWARD(Ei, Fi, oriEinF); if (!ok) + { return false; + } if (M_REVERSED(oriEinF)) + { XX.Reverse(); + } return true; } @@ -128,7 +138,9 @@ Standard_EXPORT bool FUN_tool_getxx(const TopoDS_Face& Fi, gp_Pnt2d uv; bool ok = FUN_tool_parF(Ei, parEi, Fi, uv, tolFi); if (!ok) + { return false; + } gp_Vec ng = FUN_tool_nggeomF(uv, Fi); ok = FUN_tool_getxx(Fi, Ei, parEi, ng, XX); return ok; @@ -148,20 +160,28 @@ Standard_EXPORT bool FUN_tool_getdxx( TopAbs_Orientation oEinFF; bool ok = FUN_tool_orientEinFFORWARD(E, F, oEinFF); if (!ok) + { return false; + } if (M_INTERNAL(oEinFF) || M_EXTERNAL(oEinFF)) + { return false; + } bool isoU, isoV; gp_Dir2d d2d; gp_Pnt2d o2d; bool iso = TopOpeBRepTool_TOOL::UVISO(E, F, isoU, isoV, d2d, o2d); if (!iso) + { return false; + } double u1, u2, v1, v2; ok = FUN_tool_isobounds(F, u1, u2, v1, v2); if (!ok) + { return false; + } double xpar = isoU ? o2d.X() : o2d.Y(); double xinf = isoU ? u1 : v1; @@ -169,26 +189,42 @@ Standard_EXPORT bool FUN_tool_getdxx( ok = ::FUN_nearestISO(F, xpar, isoU, xinf, xsup); if (!ok) + { return false; + } double ypar = isoU ? d2d.Y() : d2d.X(); bool matterAFTERxpar = false; if (isoU) + { matterAFTERxpar = (ypar < 0.); + } if (isoV) + { matterAFTERxpar = (ypar > 0.); + } if (oEinFF == TopAbs_REVERSED) + { matterAFTERxpar = !matterAFTERxpar; + } double dx = 0.; if (matterAFTERxpar) + { dx = xsup - xpar; + } else + { dx = xinf - xpar; + } if (isoU) + { dxx = gp_Vec2d(dx, 0.); + } if (isoV) + { dxx = gp_Vec2d(0., dx); + } return true; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_mkTondgE.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_mkTondgE.cxx index 044fcfae66..c84bcd675c 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_mkTondgE.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_mkTondgE.cxx @@ -75,19 +75,25 @@ bool TopOpeBRepTool_mkTondgE::Initialize(const TopoDS_Edge& dgE, gp_Pnt2d uv; bool ok = FUN_tool_paronEF(mydgE, par, myF, uv); if (!ok) + { return false; + } gp_Vec tmp; ok = TopOpeBRepTool_TOOL::NggeomF(uv, myF, tmp); myngf = gp_Dir(tmp); if (!ok) + { return false; + } myuvi = uvi; myFi = Fi; bool oki = TopOpeBRepTool_TOOL::NggeomF(myuvi, myFi, tmp); myngfi = gp_Dir(tmp); if (!oki) + { return false; + } double dot = myngf.Dot(myngfi); isT2d = (std::abs(1 - std::abs(dot)) < FUN_tola()); @@ -141,7 +147,9 @@ int TopOpeBRepTool_mkTondgE::GetAllRest(NCollection_List& lEi) const TopoDS_Edge& ei = TopoDS::Edge(ex.Current()); bool cli = TopOpeBRepTool_TOOL::IsClosingE(ei, myFi); if (cli) + { continue; + } bool isbi = myEpari.IsBound(ei); if (isbi) @@ -155,15 +163,23 @@ int TopOpeBRepTool_mkTondgE::GetAllRest(NCollection_List& lEi) gp_Pnt2d o2d; bool uviso = TopOpeBRepTool_TOOL::UVISO(ei, myFi, isou, isov, d2d, o2d); if (!uviso) + { continue; + } bool ok = false; if (isou) + { ok = std::abs(o2d.X() - myuvi.X()) < tolu; + } if (isov) + { ok = std::abs(o2d.Y() - myuvi.Y()) < tolv; + } if (!ok) + { continue; + } double parei; TopOpeBRepTool_TOOL::ParISO(myuvi, ei, myFi, parei); @@ -182,7 +198,9 @@ static bool FUN_getEc(const TopoDS_Face& f, const TopoDS_Vertex& v, TopoDS_Edge& const TopoDS_Edge& e = TopoDS::Edge(exe.Current()); bool closed = TopOpeBRepTool_TOOL::IsClosingE(e, f); if (!closed) + { continue; + } TopExp_Explorer exv(e, TopAbs_VERTEX); for (; exv.More(); exv.Next()) { @@ -227,13 +245,19 @@ static bool FUN_MkTonE(const gp_Vec& faxis, else { if (!isONi) + { ang = TopOpeBRepTool_TOOL::Matter(dirINcle, tgi.Reversed(), faxis); + } // double dot = isONi ? 0 : (dirINcle^tgi).Dot(ngf); double dot = isONi ? 0 : (dirINcle ^ tgi).Dot(faxis); if (dot1 < 0) + { outin = (dot > 0); + } else + { outin = (dot < 0); + } } //! isONi double Cang = (ang > M_PI) ? ang - M_PI : ang + M_PI; @@ -247,7 +271,9 @@ static bool FUN_MkTonE(const gp_Vec& faxis, bool TopOpeBRepTool_mkTondgE::MkTonE(int& mkT, double& par1, double& par2) { if (isT2d) + { return false; + } mkT = NOI; par1 = par2 = 1.e7; @@ -259,7 +285,9 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(int& mkT, double& par1, double& par2) { bool find = FUN_getEc(myF, v, myclE); if (!find) + { return false; + } } // dirINcle : tangent to cle at v oriented INSIDE 1d(cle) @@ -267,26 +295,36 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(int& mkT, double& par1, double& par2) gp_Vec dirINcle; bool ok = TopOpeBRepTool_TOOL::TgINSIDE(v, myclE, dirINcle, ovcle); if (!ok) + { return NOI; + } // faxis : describes f's axis for parametrization of gp_Vec faxis = myngf; if (ovcle == FORWARD) + { faxis.Reverse(); + } // xxi : normal to fi oriented INSIDE 3d(fi) gp_Vec xxi; ok = TopOpeBRepTool_TOOL::NggeomF(myuvi, myFi, xxi); if (!ok) + { return false; + } if (M_FORWARD(myFi.Orientation())) + { xxi.Reverse(); + } // mkT, par1, par2 : bool outin; ok = FUN_MkTonE(faxis, dirINcle, xxi, myngf, par1, par2, outin); if (ok) + { mkT = MKI12; + } return ok; } @@ -311,7 +349,9 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa par1 = par2 = 1.e7; hasRest = myEpari.IsBound(ei); if (!hasRest) + { return false; + } const double pari = myEpari.Find(ei); double pfi, pli; @@ -321,9 +361,13 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa gp_Vec tgin1di; bool ok = TopOpeBRepTool_TOOL::TggeomE(pari, ei, tgin1di); if (!ok) + { return false; + } if (onli) + { tgin1di.Reverse(); + } // v : TopExp_Explorer exv(mydgE, TopAbs_VERTEX); @@ -333,7 +377,9 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa { bool find = FUN_getEc(myF, v, myclE); if (!find) + { return false; + } } // dirINcle : tangent to cle at v oriented INSIDE 1d(cle) @@ -341,15 +387,21 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa gp_Vec dirINcle; ok = TopOpeBRepTool_TOOL::TgINSIDE(v, myclE, dirINcle, ovcle); if (!ok) + { return NOI; + } if (isT2d && !hasRest) + { return false; // no transition to compute + } // faxis : describes f's axis for parametrization of gp_Vec faxis = myngf; if (ovcle == FORWARD) + { faxis.Reverse(); + } gp_Dir xxi; // isT2d=true : normal to ei oriented INSIDE 2d(fi) // normal to fi oriented INSIDE 3d(fi) @@ -364,12 +416,16 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa // xxi : ok = TopOpeBRepTool_TOOL::XX(myuvi, myFi, pari, ei, xxi); if (!ok) + { return false; + } // mkT,par1,par2 ok = FUN_MkTonE(faxis, dirINcle, xxi, myngf, par1, par2, outin); if (!ok) + { return false; + } // clang-format off if (!onfi && !onli) {mkT = MKI12; return true;}// => the same for all edges of lei @190499 @@ -391,19 +447,27 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa ok = TopOpeBRepTool_TOOL::NggeomF(myuvi, myFi, tmp); xxi = gp_Dir(tmp); if (!ok) + { return false; + } if (M_FORWARD(myFi.Orientation())) + { xxi.Reverse(); + } // mkT,par1,par2 ok = FUN_MkTonE(faxis, dirINcle, xxi, myngf, par1, par2, outin); if (!ok) + { return false; + } //// modified by jgv, 21.11.01 for BUC61053 //// ok = TopOpeBRepTool_TOOL::XX(myuvi, myFi, pari, ei, xxri); if (!ok) + { return false; + } mkT = MKI12; // without restrictions. gp_Vec tgi = xxi.Crossed(faxis); // tgi /(tgi,xxi,faxis) is direct : @@ -416,13 +480,19 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa return true; } else + { dot = tgi.Dot(tgin1di); + } } bool keepang = (dot > 0); if (keepang) + { mkT = outin ? MKI1 : MKI2; + } else + { mkT = outin ? MKI2 : MKI1; + } return true; //////////////////////////////////////////////// /* @@ -448,9 +518,13 @@ bool TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, int& mkT, double& pa double dot = tgi.Dot(xxri); bool keepang = (dot > 0); if (keepang) + { mkT = outin ? MKI1 : MKI2; + } else + { mkT = outin ? MKI2 : MKI1; + } return true; } diff --git a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_tol.cxx b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_tol.cxx index 64ece2fde4..58b2c57d85 100644 --- a/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_tol.cxx +++ b/src/ModelingAlgorithms/TKBool/TopOpeBRepTool/TopOpeBRepTool_tol.cxx @@ -78,11 +78,17 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, double _dy = y1 - y0; double _dz = z1 - z0; if (_dx > dx) + { dx = _dx; + } if (_dy > dy) + { dy = _dy; + } if (_dz > dz) + { dz = _dz; + } } } else @@ -100,11 +106,17 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, } } if (dx < dy) + { dx = dy; + } if (dx < dz) + { dx = dz; + } if (dx > 1000000.0) + { dx = 1000000.0; //-- if(dx>10000.0) dx=10000.0; + } TopExp_Explorer ex; double tolef1 = Precision::Confusion(); @@ -112,18 +124,24 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, { double tole = BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())); if (tole > tolef1) + { tolef1 = tole; + } } double tolef2 = Precision::Confusion(); for (ex.Init(myFace2, TopAbs_EDGE); ex.More(); ex.Next()) { double tole = BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())); if (tole > tolef2) + { tolef2 = tole; + } } double tolef = tolef1; if (tolef2 > tolef) + { tolef = tolef2; + } // jmb le 30 juillet 99. on ne multiplie pas la tolerance par la dimension de la piece Deflection = 0.01; @@ -141,9 +159,13 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, DP1 = MU1 - MU0; DP2 = MV1 - MV0; if (DP2 < DP1) + { DP = DP2; + } else + { DP = DP1; //-- DP + petit + } MU0 = mySurface2.FirstUParameter(); MU1 = mySurface2.LastUParameter(); @@ -152,9 +174,13 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, DP1 = MU1 - MU0; DP2 = MV1 - MV0; if (DP2 > DP1) + { DP1 = DP2; //-- DP1 + petit + } if (DP1 < DP) + { DP = DP1; //-- DP + petit + } DP *= 0.01; // jmb le 30 juillet 99 @@ -167,14 +193,22 @@ Standard_EXPORT void FTOL_FaceTolerances(const Bnd_Box& B1, #endif if (MMAXUV < 1e-3) + { MMAXUV = 1e-3; + } if (MDEFLECTION < 1e-3) + { MDEFLECTION = 1e-3; + } if (MMAXUV > 0.01) + { MMAXUV = 0.01; + } if (MDEFLECTION > 0.1) + { MDEFLECTION = 0.1; + } #ifdef OCCT_DEBUG // printf("TOL1 = %5.5eg TOL2=%5.5eg DEFL=%5.5eg MAXUV=%5.5eg\n",MTOL1,MTOL2,MDEFLECTION,MMAXUV); diff --git a/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedExpression.cxx b/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedExpression.cxx index 20be0c2444..e860fbd48e 100644 --- a/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedExpression.cxx +++ b/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedExpression.cxx @@ -55,7 +55,9 @@ bool Expr_NamedExpression::IsIdentical(const occ::handle // AGV 22.03.12: Comparison should be based on names rather than Handles const Expr_NamedExpression* pOther = static_cast(theOther.get()); if (pOther == this || pOther->GetName().IsEqual(myName)) + { aResult = true; + } } return aResult; } diff --git a/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedUnknown.cxx b/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedUnknown.cxx index 900c7fe986..283e84af73 100644 --- a/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedUnknown.cxx +++ b/src/ModelingAlgorithms/TKExpress/Expr/Expr_NamedUnknown.cxx @@ -111,7 +111,9 @@ bool Expr_NamedUnknown::Contains(const occ::handle& exp) { const occ::handle expNamed = occ::down_cast(exp); if (expNamed.IsNull() || expNamed->IsAssigned()) + { return false; + } // AGV 22.03.12: Comparison based on name coincidence return IsIdentical(expNamed); } diff --git a/src/ModelingAlgorithms/TKExpress/ExprIntrp/ExprIntrp.cxx b/src/ModelingAlgorithms/TKExpress/ExprIntrp/ExprIntrp.cxx index 7c2ec28b5f..6150db602b 100644 --- a/src/ModelingAlgorithms/TKExpress/ExprIntrp/ExprIntrp.cxx +++ b/src/ModelingAlgorithms/TKExpress/ExprIntrp/ExprIntrp.cxx @@ -29,7 +29,9 @@ bool ExprIntrp::Parse(const occ::handle& gen, { ExprIntrp_Recept.SetMaster(gen); if (str.Length() == 0) + { return false; + } ExprIntrp_thestring = str; ExprIntrp_start_string(ExprIntrp_thestring.ToCString()); diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat.cxx index ffad9a1e5d..dd35da07ce 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat.cxx @@ -395,7 +395,9 @@ static void PutInBoundsU(double umin, double d1 = maxC - umax; double d2 = umin - minC + period; if (d2 < d1) + { du = -period; + } if (du != 0.) { gp_Vec2d T2(du, 0.); @@ -449,7 +451,9 @@ static void PutInBoundsV(double vmin, double d1 = maxC - vmax; double d2 = vmin - minC + period; if (d2 < d1) + { dv = -period; + } if (dv != 0.) { gp_Vec2d T2(0., dv); @@ -498,9 +502,13 @@ bool BRepFeat::IsInside(const TopoDS_Face& F1, const TopoDS_Face& F2) double eps = BRep_Tool::Tolerance(E); BRep_Tool::Range(E, f1, l1); if (flagu == 1) + { PutInBoundsU(umin, umax, eps, uperiod, f1, l1, C); + } if (flagv == 1) + { PutInBoundsV(vmin, vmax, eps, vperiod, f1, l1, C); + } } Geom2dAdaptor_Curve AC(C, f1, l1); if (!IsIn(FC, AC)) @@ -542,13 +550,21 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase, TopoDS_Face& FUntil) gp_Pnt aP(x[i], y[j], z[k]); ElSLib::Parameters(aPln, aP, u, v); if (u < umin) + { umin = u; + } if (u > umax) + { umax = u; + } if (v < vmin) + { vmin = v; + } if (v > vmax) + { vmax = v; + } } } } @@ -571,9 +587,13 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase, TopoDS_Face& FUntil) gp_Pnt aP(x[i], y[j], z[k]); ElSLib::Parameters(aCyl, aP, u, v); if (v < vmin) + { vmin = v; + } if (v > vmax) + { vmax = v; + } } } } @@ -594,9 +614,13 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase, TopoDS_Face& FUntil) gp_Pnt aP(x[i], y[j], z[k]); ElSLib::Parameters(aCon, aP, u, v); if (v < vmin) + { vmin = v; + } if (v > vmax) + { vmax = v; + } } } } diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Builder.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Builder.cxx index 8c51721825..fce70e6065 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Builder.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Builder.cxx @@ -207,7 +207,9 @@ void BRepFeat_Builder::PerformResult(const Message_ProgressRange& theRange) NCollection_Array1 aSteps(0, aSize - 1); { for (int i = 0; i < aSize; ++i) + { aSteps(i) = 0.; + } NbShapes aNbShapes = getNbShapes(); double aTreatFaces = 5 * aNbShapes.NbFaces(); @@ -814,9 +816,13 @@ void BRepFeat_Builder::FillIn3DParts( for (; itL.More();) { if (myRemoved.Contains(itL.Value())) + { aList.Remove(itL); + } else + { itL.Next(); + } } } } diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Form.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Form.cxx index 4ac9941ce4..29c3bbce8d 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Form.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Form.cxx @@ -273,18 +273,26 @@ void BRepFeat_Form::GlobalPerform() else if (ASI2.IsDone()) { if (ASI2.NbPoints(jj) <= 0) + { continue; + } // for base case prism on mySUntil -> ambivalent direction // -> preferable direction = 1 if (sens != 1) { if (ASI2.Point(jj, 1).Parameter() * ASI2.Point(jj, ASI2.NbPoints(jj)).Parameter() <= 0) + { sens = 1; + } else if (ASI2.Point(jj, 1).Parameter() < 0.) + { sens = -1; + } else + { sens = 1; + } } int ku; @@ -405,13 +413,17 @@ void BRepFeat_Form::GlobalPerform() { myMap(fac) = trP.Modified(fac); if (myMap(fac).IsEmpty()) + { myMap(fac).Append(fac); + } } else { locmap(fac) = trP.Modified(fac); if (locmap(fac).IsEmpty()) + { locmap(fac).Append(fac); + } } } } // if(!mySFrom.IsNull()) @@ -440,13 +452,17 @@ void BRepFeat_Form::GlobalPerform() { myMap(fac) = trP.Modified(fac); if (myMap(fac).IsEmpty()) + { myMap(fac).Append(fac); + } } else { locmap(fac) = trP.Modified(fac); if (locmap(fac).IsEmpty()) + { locmap(fac).Append(fac); + } } } } // if(!mySUntil.IsNull()) @@ -465,7 +481,9 @@ void BRepFeat_Form::GlobalPerform() { ldsc = trP.Modified(gl); if (ldsc.IsEmpty()) + { ldsc.Append(gl); + } } const TopoDS_Face& glface = TopoDS::Face(itm.Value()); for (it.Initialize(ldsc); it.More(); it.Next()) @@ -746,7 +764,9 @@ void BRepFeat_Form::GlobalPerform() { myMap(fac) = trP.Modified(fac); if (myMap(fac).IsEmpty()) + { myMap(fac).Append(fac); + } } } } @@ -768,7 +788,9 @@ void BRepFeat_Form::GlobalPerform() { myMap(fac) = trP.Modified(fac); if (myMap.IsEmpty()) + { myMap(fac).Append(fac); + } } } } @@ -848,7 +870,9 @@ void BRepFeat_Form::GlobalPerform() double prbmin1, prbmax1, prbmin2, prbmax2; if (!myJustFeat && sens == 0) + { sens = 1; + } if (sens == 0) { myStatusError = BRepFeat_IncDirection; @@ -1231,7 +1255,9 @@ const NCollection_List& BRepFeat_Form::Modified(const TopoDS_Shape { myGenerated.Clear(); if (!IsDone()) + { return myGenerated; + } if (mySbase.IsEqual(F)) { @@ -1246,7 +1272,9 @@ const NCollection_List& BRepFeat_Form::Modified(const TopoDS_Shape { const TopoDS_Shape& sh = ite.Value(); if (!sh.IsSame(F) && sh.ShapeType() == F.ShapeType()) + { myGenerated.Append(sh); + } } } return myGenerated; // empty list @@ -1258,7 +1286,9 @@ const NCollection_List& BRepFeat_Form::Generated(const TopoDS_Shap { myGenerated.Clear(); if (!IsDone()) + { return myGenerated; + } if (myMap.IsBound(S) && S.ShapeType() != TopAbs_FACE) { // check if filter on face or not NCollection_List::Iterator ite(myMap(S)); @@ -1266,7 +1296,9 @@ const NCollection_List& BRepFeat_Form::Generated(const TopoDS_Shap { const TopoDS_Shape& sh = ite.Value(); if (!sh.IsSame(S)) + { myGenerated.Append(sh); + } } return myGenerated; } @@ -1352,11 +1384,17 @@ bool BRepFeat_Form::TransformShapeFU(const int flag) TopoDS_Shape shapefu; if (flag == 0) + { shapefu = mySFrom; + } else if (flag == 1) + { shapefu = mySUntil; + } else + { return Trf; + } TopExp_Explorer exp(shapefu, TopAbs_FACE); if (!exp.More()) @@ -1499,7 +1537,9 @@ void BRepFeat_Form::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP, { const TopoDS_Shape& sh = it.Value(); if (sh.ShapeType() != TopAbs_FACE) + { continue; + } const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) { diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Gluer.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Gluer.cxx index 57483d5d87..d40b42f241 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Gluer.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_Gluer.cxx @@ -52,7 +52,9 @@ const NCollection_List& BRepFeat_Gluer::Modified(const TopoDS_Shap if (!LS.IsEmpty()) { if (!LS.First().IsSame(F)) + { return myGluer.DescendantFaces(TopoDS::Face(F)); + } } } static NCollection_List LIM; diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeCylindricalHole.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeCylindricalHole.cxx index 4dd6109fab..88baa54f0c 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeCylindricalHole.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeCylindricalHole.cxx @@ -763,10 +763,14 @@ bool GetOffset(const LocOpe_PntFace& PntInfo, CSLib_NormalStatus stat; CSLib::Normal(D1U, D1V, Precision::Angular(), stat, NormF); if (stat != CSLib_Defined) + { return false; + } double angle = Axis.Direction().Angle(NormF); if (std::abs(M_PI / 2. - angle) < Precision::Angular()) + { return false; + } outOff = Radius * std::abs(tan(angle)); return true; } @@ -786,9 +790,13 @@ void CreateCyl(const LocOpe_PntFace& PntInfoFirst, double Heigth = Last - First; if (!GetOffset(PntInfoFirst, Radius, Axis, offF)) + { offF = Radius; + } if (!GetOffset(PntInfoLast, Radius, Axis, offL)) + { offL = Radius; + } // create cylinder along the axis (myAxis); // from 'First - offF' to 'Last + offL' params diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeDPrism.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeDPrism.cxx index 46f6208893..7e4e8ebae6 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeDPrism.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeDPrism.cxx @@ -370,7 +370,9 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& Until) bB.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { bB.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiDPrism, Comp); UpdateDescendants(trP, trP.Shape(), false); @@ -432,14 +434,18 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& myJustGluer = true; Perform(Until); if (myJustGluer) + { return; + } } else if (Until.IsSame(mySkface)) { myJustGluer = true; Perform(From); if (myJustGluer) + { return; + } } } // myPbase.Orientation(TopAbs_FORWARD); @@ -563,7 +569,9 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, OrU); if (!S.IsNull()) + { B.Add(Comp, S); + } else { NotDone(); @@ -572,7 +580,9 @@ void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& } TopoDS_Solid SS = BRepFeat::Tool(mySFrom, FFrom, OrF); if (!SS.IsNull()) + { B.Add(Comp, SS); + } else { NotDone(); @@ -722,7 +732,9 @@ void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until) OrU = ASI1.Point(1, 1).Orientation(); double prm = ASI1.Point(1, 1).Parameter(); if (prm < 0) + { OrU = TopAbs::Reverse(OrU); + } FUntil = ASI1.Point(1, 1).Face(); } @@ -759,7 +771,9 @@ void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until) B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid Sol = BRepFeat::Tool(mySUntil, FUntil, OrU); if (!Sol.IsNull()) + { B.Add(Comp, Sol); + } else { NotDone(); @@ -769,7 +783,9 @@ void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until) TopoDS_Solid Sol1 = BRepFeat::Tool(mySFrom, FFrom, OrF); if (!Sol1.IsNull()) + { B.Add(Comp, Sol1); + } else { NotDone(); @@ -953,7 +969,9 @@ void BRepFeat_MakeDPrism::PerformUntilHeight(const TopoDS_Shape& Until, const do B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiDPrism, Comp); if (myFuse == 1) { @@ -1100,7 +1118,9 @@ void BRepFeat_MakeDPrism::BossEdges(const int signature) for (itMap.Initialize(MapE); itMap.More(); itMap.Next()) { if (!BRep_Tool::Degenerated(TopoDS::Edge(itMap.Key()))) + { myLatEdges.Append(itMap.Key()); + } } } } diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeLinearForm.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeLinearForm.cxx index 43f3169aee..0e957f3a91 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeLinearForm.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeLinearForm.cxx @@ -143,7 +143,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, { const double& tol = BRep_Tool::Tolerance(TopoDS::Vertex(exx.Current())); if (tol > myTol) + { myTol = tol; + } } exx.Init(Sbase, TopAbs_VERTEX); @@ -151,7 +153,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, { const double& tol = BRep_Tool::Tolerance(TopoDS::Vertex(exx.Current())); if (tol > myTol) + { myTol = tol; + } } // ---Control of directions @@ -468,7 +472,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, ee1 = TopoDS::Edge(aLocalShape); // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation())); if (counter == 1) + { theFV = TopExp::FirstVertex(ee1, true); + } myLFMap(E).Append(ee1); BB.Add(w, ee1); thePreviousEdge = ee1; @@ -515,7 +521,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, myLFMap(E).Append(E11); BB.Add(w, E11); if (counter == 1) + { theFV = TopExp::FirstVertex(E11, true); + } counter++; } else @@ -542,7 +550,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, BB.Add(w, ee); myLFMap(E).Append(ee); if (counter == 1) + { theFV = TopExp::FirstVertex(ee, true); + } thePreviousEdge = ee; counter++; break; @@ -568,7 +578,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, occ::handle ccc = BRep_Tool::Curve(edg, f, l); occ::handle cc = new Geom_TrimmedCurve(ccc, f, l); if (edg.Orientation() == TopAbs_REVERSED) + { cc->Reverse(); + } fp = cc->Value(cc->FirstParameter()); lp = cc->Value(cc->LastParameter()); @@ -641,13 +653,17 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, thePreviousEdge = eeee; BB.Add(w, eeee); if (counter == 1) + { theFV = TopExp::FirstVertex(eeee, true); + } counter1++; NewListOfEdges.Append(edg); theEdge = eeee; if (dist <= myTol) + { theFEdge = edg; + } theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge, true)); } @@ -667,7 +683,9 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, LastOK = false; } else if (it.More()) + { it.Next(); + } else { Sliding = false; @@ -909,9 +927,13 @@ void BRepFeat_MakeLinearForm::Perform() myGluedF.Clear(); if (!mySUntil.IsNull()) + { myPerfSelection = BRepFeat_SelectionU; + } else + { myPerfSelection = BRepFeat_NoSelection; + } gp_Dir dir(myDir); gp_Vec V = Length * dir; @@ -919,9 +941,13 @@ void BRepFeat_MakeLinearForm::Perform() LocOpe_LinearForm theForm; if (myDir1.IsEqual(nulldir, Precision::Confusion(), Precision::Confusion())) + { theForm.Perform(myPbase, V, myFirstPnt, myLastPnt); + } else + { theForm.Perform(myPbase, V, myDir1, myFirstPnt, myLastPnt); + } TopoDS_Shape VraiForm = theForm.Shape(); // primitive of the rib @@ -1057,13 +1083,21 @@ bool BRepFeat_MakeLinearForm::Propagate(NCollection_List& SliList, { eb = ec; if (c1f || c1l) + { v1OK = true; + } if (c2f || c2l) + { v2OK = true; + } if (c1f || c2f) + { FirstOK = true; + } if (c1l || c2l) + { LastOK = true; + } break; } } @@ -1150,7 +1184,9 @@ bool BRepFeat_MakeLinearForm::Propagate(NCollection_List& SliList, { gp_Pnt pe2 = perp.Point(1); if (pe1.Distance(pe2) <= BRep_Tool::Tolerance(rfe)) + { result = true; + } } } } @@ -1190,7 +1226,9 @@ bool BRepFeat_MakeLinearForm::Propagate(NCollection_List& SliList, v1OK = p1.Distance(ptprev) <= t1; v2OK = p2.Distance(ptprev) <= t2; if (v1OK || v2OK) + { break; + } } if (v1OK) diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakePrism.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakePrism.cxx index b08588ebaa..620996029b 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakePrism.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakePrism.cxx @@ -259,7 +259,9 @@ void BRepFeat_MakePrism::Perform(const double Length) } } if (found) + { break; + } } } @@ -272,7 +274,9 @@ void BRepFeat_MakePrism::Perform(const double Length) NCollection_DataMap, TopTools_ShapeMapHasher> sl; if (!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace)) + { break; + } } } } @@ -387,14 +391,18 @@ void BRepFeat_MakePrism::Perform(const TopoDS_Shape& Until) Or = ASI.Point(1, ASI.NbPoints(1)).Orientation(); } if (sens == -1) + { Or = TopAbs::Reverse(Or); + } TopoDS_Face FUntil = ASI.Point(1, 1).Face(); TopoDS_Shape Comp; BRep_Builder B; B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiPrism, Comp); UpdateDescendants(trP, trP.Shape(), false); // @@ -448,14 +456,18 @@ void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U myJustGluer = true; Perform(Until); if (myJustGluer) + { return; + } } else if (Until.IsSame(mySkface)) { myJustGluer = true; Perform(From); if (myJustGluer) + { return; + } } } @@ -549,7 +561,9 @@ void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U OrU = ASI1.Point(1, ASI1.NbPoints(1)).Orientation(); } if (sens == -1) + { OrU = TopAbs::Reverse(OrU); + } FUntil = ASI1.Point(1, 1).Face(); ParU = ASI1.Point(1, 1).Parameter(); } @@ -563,7 +577,9 @@ void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U { OrF = ASI2.Point(1, 1).Orientation(); if (sens == 1) + { OrF = TopAbs::Reverse(OrF); + } FFrom = ASI2.Point(1, 1).Face(); ParF = ASI2.Point(1, 1).Parameter(); } @@ -948,14 +964,18 @@ void BRepFeat_MakePrism::PerformUntilHeight(const TopoDS_Shape& Until, const dou Or = ASI.Point(1, ASI.NbPoints(1)).Orientation(); } if (sens == -1) + { Or = TopAbs::Reverse(Or); + } TopoDS_Face FUntil = ASI.Point(1, 1).Face(); TopoDS_Shape Comp; BRep_Builder B; B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiPrism, Comp); UpdateDescendants(trP, trP.Shape(), false); @@ -1033,7 +1053,9 @@ static double HeightMax(const TopoDS_Shape& theSbase, } } if (!FacRevolInfini) + { BRepBndLib::Add(theSFrom, Box); + } } if (!theSUntil.IsNull()) { @@ -1051,7 +1073,9 @@ static double HeightMax(const TopoDS_Shape& theSbase, } } if (!FacRevolInfini) + { BRepBndLib::Add(theSUntil, Box); + } } double c[6]; @@ -1061,9 +1085,13 @@ static double HeightMax(const TopoDS_Shape& theSbase, for (int i = 0; i < 6; i++) { if (c[i] > parmax) + { parmax = c[i]; + } if (c[i] < parmin) + { parmin = c[i]; + } } // #ifndef OCCT_DEBUG double Height = fabs(2. * (parmax - parmin)); @@ -1211,9 +1239,13 @@ static bool ToFuse(const TopoDS_Face& F1, const TopoDS_Face& F2) // apply locations if (!loc1.IsIdentity()) + { pl1.Transform(loc1.Transformation()); + } if (!loc2.IsIdentity()) + { pl2.Transform(loc2.Transformation()); + } if (pl1.Position().IsCoplanar(pl2.Position(), tollin, tolang)) { diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevol.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevol.cxx index 1a02df7d96..e7bb4038c3 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevol.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevol.cxx @@ -231,9 +231,13 @@ void BRepFeat_MakeRevol::Perform(const double Angle) mySkface.Nullify(); } if (angledec == 0.) + { theRevol.Perform(myPbase, myAxis, Angle); + } else + { theRevol.Perform(myPbase, myAxis, Angle, angledec); + } TopoDS_Shape VraiRevol = theRevol.Shape(); @@ -274,7 +278,9 @@ void BRepFeat_MakeRevol::Perform(const double Angle) } } if (found) + { break; + } } } @@ -287,7 +293,9 @@ void BRepFeat_MakeRevol::Perform(const double Angle) NCollection_DataMap, TopTools_ShapeMapHasher> sl; if (!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace)) + { break; + } } } } @@ -418,7 +426,9 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until) B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiRevol, Comp); TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); @@ -478,7 +488,9 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U myJustGluer = true; Perform(Until); if (myJustGluer) + { return; + } } else if (Until.IsSame(mySkface)) { @@ -486,7 +498,9 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U myAxis.Reverse(); Perform(From); if (myJustGluer) + { return; + } } } @@ -590,10 +604,14 @@ void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, const TopoDS_Shape& U B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF); if (!SF.IsNull()) + { B.Add(Comp, SF); + } TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU); if (!SU.IsNull()) + { B.Add(Comp, SU); + } BRepAlgoAPI_Cut trP(VraiRevol, Comp); TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); @@ -731,7 +749,9 @@ void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until, const doub B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiRevol, Comp); TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); @@ -824,7 +844,9 @@ static void VerifGluedFaces( B.MakeCompound(TopoDS::Compound(Comp)); TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or); if (!S.IsNull()) + { B.Add(Comp, S); + } BRepAlgoAPI_Cut trP(VraiRevol, Comp); TopoDS_Shape Cutsh = trP.Shape(); TopExp_Explorer ex(Cutsh, TopAbs_SOLID); @@ -839,13 +861,19 @@ static void VerifGluedFaces( { const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current()); if (fac1.IsSame(fac2)) + { break; + } } if (ex2.More()) + { break; + } } if (ex1.More()) + { continue; + } GluedFaces = false; break; } diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevolutionForm.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevolutionForm.cxx index a9b62296bd..7d2732b367 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevolutionForm.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_MakeRevolutionForm.cxx @@ -175,23 +175,33 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, double par2 = proj2.Distance(1); double Par = std::min(par1, par2); if (Par < L) + { L = Par; + } if (L < Rad && L > 0.) + { Rad = L; + } } double height = std::min(H1, H2); if (Rad <= height) + { Rad = height + 0.01 * height; + } myAngle1 = asin(H1 / Rad) + M_PI / 10.; myAngle2 = asin(H2 / Rad) + M_PI / 10.; if ((myAngle1 - M_PI / 2) > Precision::Confusion()) + { myAngle1 = M_PI / 2; + } if ((myAngle2 - M_PI / 2) > Precision::Confusion()) + { myAngle2 = M_PI / 2; + } mySkface.Nullify(); myPbase.Nullify(); @@ -215,7 +225,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, { const double& tol = BRep_Tool::Tolerance(TopoDS::Vertex(exx.Current())); if (tol > myTol) + { myTol = tol; + } } exx.Init(Sbase, TopAbs_VERTEX); @@ -223,7 +235,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, { const double& tol = BRep_Tool::Tolerance(TopoDS::Vertex(exx.Current())); if (tol > myTol) + { myTol = tol; + } } TopoDS_Shape aLocalShapeW = W.Oriented(TopAbs_FORWARD); @@ -337,7 +351,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, && s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) && s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) && s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) + { Sliding = false; + } } if (Sliding) @@ -351,7 +367,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, && ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) && ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) && ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) + { Sliding = false; + } } // Control only start and end points no control at the middle to improve @@ -416,20 +434,26 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, { BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace); if (ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion()) + { Sliding = false; + } } if (Sliding && !PtOnLastEdge) { BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces if (ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion()) + { Sliding = false; + } } if (Sliding && PtOnFirstEdge) { double f, l; FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l); if (FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) + { Sliding = false; + } else { occ::handle C1 = occ::down_cast(FirstCrv); @@ -437,7 +461,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, FirstCircle = Circ; gp_Ax1 circax = FirstCircle.Axis(); if (!circax.IsCoaxial(myAxe, Precision::Confusion(), Precision::Confusion())) + { Sliding = false; + } else { // #ifndef OCCT_DEBUG @@ -446,7 +472,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, // if(abs(FirstCircle.Radius()-FirstRayon) >= // #endif Precision::Confusion()) + { Sliding = false; + } } } } @@ -456,7 +484,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, double f, l; LastCrv = BRep_Tool::Curve(OnLastEdge, f, l); if (LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) + { Sliding = false; + } else { occ::handle C1 = occ::down_cast(LastCrv); @@ -464,7 +494,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, LastCircle = Circ; gp_Ax1 circax = LastCircle.Axis(); if (!circax.IsCoaxial(myAxe, Precision::Confusion(), Precision::Confusion())) + { Sliding = false; + } else { double rad = LastCircle.Radius(); @@ -601,7 +633,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, ee1 = TopoDS::Edge(aLocalShape); // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation())); if (counter == 1) + { theFV = TopExp::FirstVertex(ee1, true); + } myLFMap(E).Append(ee1); BB.Add(w, ee1); thePreviousEdge = ee1; @@ -648,7 +682,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, myLFMap(E).Append(E11); BB.Add(w, E11); if (counter == 1) + { theFV = TopExp::FirstVertex(E11, true); + } counter++; } else @@ -675,7 +711,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, BB.Add(w, ee); myLFMap(E).Append(ee); if (counter == 1) + { theFV = TopExp::FirstVertex(ee, true); + } thePreviousEdge = ee; counter++; break; @@ -701,7 +739,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, occ::handle ccc = BRep_Tool::Curve(edg, f, l); occ::handle cc = new Geom_TrimmedCurve(ccc, f, l); if (edg.Orientation() == TopAbs_REVERSED) + { cc->Reverse(); + } fp = cc->Value(cc->FirstParameter()); lp = cc->Value(cc->LastParameter()); @@ -772,13 +812,17 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, thePreviousEdge = eeee; BB.Add(w, eeee); if (counter == 1) + { theFV = TopExp::FirstVertex(eeee, true); + } counter1++; NewListOfEdges.Append(edg); theEdge = eeee; if (dist <= myTol) + { theFEdge = edg; + } theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge, true)); } @@ -797,7 +841,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, LastOK = false; } else if (it.More()) + { it.Next(); + } else { Sliding = false; @@ -932,7 +978,9 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, } if (VV.IsNull() && NewV1.IsNull()) + { continue; + } if (!VV.IsNull() && NewV1.IsNull()) { @@ -1257,9 +1305,13 @@ void BRepFeat_MakeRevolutionForm::Perform() TopoDS_Solid S1 = BRepFeat::Tool(f1, FF1, Ori1); TopoDS_Solid S2 = BRepFeat::Tool(f2, FF2, Ori2); if (!S1.IsNull()) + { B.Add(Comp, S1); + } if (!S2.IsNull()) + { B.Add(Comp, S2); + } BRepAlgoAPI_Cut trP(VraiForm, Comp); // coupe de la nervure par deux plans parallels @@ -1275,7 +1327,9 @@ void BRepFeat_MakeRevolutionForm::Perform() { const TopoDS_Shape& orig = it1.Key(); if (it1.Value().IsEmpty()) + { continue; + } const TopoDS_Shape& sh = it1.Value().First(); exx.Init(VraiForm, TopAbs_FACE); for (; exx.More(); exx.Next()) @@ -1324,9 +1378,13 @@ void BRepFeat_MakeRevolutionForm::Perform() { const NCollection_List& desfaces = trP.Modified(fac); if (!desfaces.IsEmpty()) + { SlidingMap(fac) = desfaces; + } else + { SlidingMap(fac).Append(fac); + } } } @@ -1336,9 +1394,13 @@ void BRepFeat_MakeRevolutionForm::Perform() VraiForm = trP.Shape(); // primitive cut if (!myGluedF.IsEmpty()) + { myPerfSelection = BRepFeat_NoSelection; + } else + { myPerfSelection = BRepFeat_SelectionSh; + } exx.Init(myPbase, TopAbs_EDGE); for (; exx.More(); exx.Next()) @@ -1613,13 +1675,19 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL // find edge connected to v1: gp_Pnt pt; if (!v1.IsNull()) + { pt = BRep_Tool::Pnt(v1); + } gp_Pnt ptprev; if (!Vprevious.IsNull()) + { ptprev = BRep_Tool::Pnt(Vprevious); + } gp_Pnt ptpreprev; if (!Vpreprevious.IsNull()) + { ptpreprev = BRep_Tool::Pnt(Vpreprevious); + } if ((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) || (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) @@ -1682,7 +1750,9 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1, true)); if (ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) || ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1)) + { break; + } } NCollection_List thelist3; @@ -1691,9 +1761,13 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL myListOfEdges.Append(edg1); if (!edg1.IsNull()) + { SliList.Prepend(CurrentFace); + } else + { return false; + } Vert = TopExp::FirstVertex(edg1, true); gp_Pnt PP = BRep_Tool::Pnt(Vert); @@ -1701,7 +1775,9 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL double tol = BRep_Tool::Tolerance(edg1); double tol1 = BRep_Tool::Tolerance(v1); if (tol1 > tol) + { tol = tol1; + } double dist = PP.Distance(FP); if (dist <= tol) { @@ -1734,13 +1810,19 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL // find edge connected to v2: gp_Pnt pt; if (!v2.IsNull()) + { pt = BRep_Tool::Pnt(v2); + } gp_Pnt ptprev; if (!Vprevious.IsNull()) + { ptprev = BRep_Tool::Pnt(Vprevious); + } gp_Pnt ptpreprev; if (!Vpreprevious.IsNull()) + { ptpreprev = BRep_Tool::Pnt(Vpreprevious); + } if ((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) || (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) @@ -1804,7 +1886,9 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2, true)); if (ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) || ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2)) + { break; + } } NCollection_List thelist4; mySlface.Bind(CurrentFace, thelist4); @@ -1812,9 +1896,13 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL myListOfEdges.Append(edg2); if (!edg2.IsNull()) + { SliList.Append(CurrentFace); + } else + { return false; + } Vert = TopExp::FirstVertex(edg2, true); gp_Pnt PP = BRep_Tool::Pnt(Vert); @@ -1838,7 +1926,9 @@ bool BRepFeat_MakeRevolutionForm::Propagate(NCollection_List& SliL } } if (!e1.IsNull()) + { myListOfEdges.Append(e1); + } return result; } @@ -1925,10 +2015,14 @@ static void SetGluedFaces( const TopoDS_Face& ff = TopoDS::Face(iterm.Key()); const NCollection_List& lfaces = iterm.Value(); if (lfaces.IsEmpty()) + { continue; + } const TopoDS_Face& fff = TopoDS::Face(lfaces.First()); if (gfac.First().IsSame(ff)) + { theMap.Bind(fff, fac); + } } } } diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_RibSlot.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_RibSlot.cxx index 98f63778d1..44a42c5c25 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_RibSlot.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_RibSlot.cxx @@ -283,7 +283,9 @@ const NCollection_List& BRepFeat_RibSlot::Modified(const TopoDS_Sh { const TopoDS_Shape& sh = ite.Value(); if (!sh.IsSame(F)) + { list.Append(sh); + } } return list; } @@ -313,12 +315,16 @@ const NCollection_List& BRepFeat_RibSlot::Generated(const TopoDS_S { const TopoDS_Shape& sh = ite.Value(); if (!sh.IsSame(S)) + { list.Append(sh); + } } return list; } else + { return myGenerated; + } } else { @@ -335,7 +341,9 @@ const NCollection_List& BRepFeat_RibSlot::Generated(const TopoDS_S { const TopoDS_Shape& sh = it1.Value(); if (!sh.IsSame(S)) + { list.Append(sh); + } } } } @@ -343,7 +351,9 @@ const NCollection_List& BRepFeat_RibSlot::Generated(const TopoDS_S } } else + { return myGenerated; + } } //================================================================================================= @@ -453,7 +463,9 @@ gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e, cc->D1(par, pp, tgt); if (e.Orientation() == TopAbs_REVERSED) + { tgt.Reverse(); + } gp_Vec D = -tgt.Crossed(Pln->Pln().Position().Direction()) / 10.; pp.Translate(D); @@ -510,7 +522,9 @@ gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F, const gp_Pnt& P) CSLib_DerivativeStatus St; CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N); if (F.Orientation() == TopAbs_FORWARD) + { N.Reverse(); + } return N; } @@ -523,7 +537,9 @@ double BRepFeat_RibSlot::IntPar(const occ::handle& C, const gp_Pnt& { if (C.IsNull()) + { return 0.; + } GeomAdaptor_Curve AC(C); double U; @@ -667,7 +683,9 @@ TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(NCollection_List& face LocOpe_CSIntersector ASI(f); ASI.Perform(scur); if (!ASI.IsDone()) + { continue; + } for (int jj = 1; jj <= Counter; jj++) { if (ASI.NbPoints(jj) >= 1) @@ -712,7 +730,9 @@ double BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase, for (int i = 0; i < 6; i++) { if (c[i] > bnd) + { bnd = c[i]; + } } p1.SetCoord(c[0] - 2. * bnd, c[1] - 2. * bnd, c[2] - 2. * bnd); p2.SetCoord(c[3] + 2. * bnd, c[4] + 2. * bnd, c[5] + 2. * bnd); @@ -831,7 +851,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if (!Map.Add(fx)) + { continue; + } ex5.Init(ex4.Current(), TopAbs_EDGE); for (; ex5.More(); ex5.Next()) { @@ -846,7 +868,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar + bnd / 50., bnd / 50., Pln); if (!FFF.IsNull()) + { FirstFace = FFF; + } } } else if (PtOnFirstVertex) @@ -862,7 +886,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if (!Map.Add(fx)) + { continue; + } ex5.Init(ex4.Current(), TopAbs_VERTEX); for (; ex5.More(); ex5.Next()) { @@ -878,7 +904,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar + bnd / 50., bnd / 50., Pln); if (!FFF.IsNull()) + { FirstFace = FFF; + } } } FirstEdge = E; @@ -902,7 +930,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if (!Map.Add(fx)) + { continue; + } ex5.Init(ex4.Current(), TopAbs_EDGE); for (; ex5.More(); ex5.Next()) { @@ -918,7 +948,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar - bnd / 50., bnd / 50., Pln); if (!FFF.IsNull()) + { LastFace = FFF; + } } } else if (PtOnLastEdge && PtOnLastVertex) @@ -934,7 +966,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { const TopoDS_Face& fx = TopoDS::Face(ex4.Current()); if (!Map.Add(fx)) + { continue; + } ex5.Init(ex4.Current(), TopAbs_VERTEX); for (; ex5.More(); ex5.Next()) { @@ -950,7 +984,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, { TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar - bnd / 50., bnd / 50., Pln); if (!FFF.IsNull()) + { LastFace = FFF; + } } } LastEdge = E; @@ -1074,7 +1110,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, GeomAdaptor_Curve aGAC(curve); inter.Init(aCurFace, aGAC, BRep_Tool::Tolerance(aCurFace)); if (!inter.More()) + { continue; + } for (; inter.More(); inter.Next()) { gp_Pnt thePoint = inter.Pnt(); @@ -1144,7 +1182,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, } TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar + bnd / 10., bnd / 10., Pln); if (!FFF.IsNull()) + { FirstFace = FFF; + } } else if (PtOnEdge && PtOnVertex) { @@ -1169,7 +1209,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, } TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar + bnd / 10., bnd / 10., Pln); if (!FFF.IsNull()) + { FirstFace = FFF; + } } if (!FirstEdge.IsNull() && !FirstFace.IsNull() && !FirstVertex.IsNull()) { @@ -1207,7 +1249,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, } TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar - bnd / 10., bnd / 10., Pln); if (!FFF.IsNull()) + { LastFace = FFF; + } } else if (PtOnEdge && PtOnVertex) { @@ -1232,7 +1276,9 @@ bool BRepFeat_RibSlot::ExtremeFaces(const bool RevolRib, } TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar - bnd / 10., bnd / 10., Pln); if (!FFF.IsNull()) + { LastFace = FFF; + } } if (!LastEdge.IsNull() && !LastFace.IsNull() && !LastVertex.IsNull()) { @@ -1307,11 +1353,15 @@ void BRepFeat_RibSlot::PtOnEdgeVertex(const bool RevolRib, { const TopoDS_Edge& e = TopoDS::Edge(EXP.Current()); if (!Map.Add(e)) + { continue; + } if (!RevolRib) { if (BRep_Tool::Degenerated(e)) + { continue; + } } double fff, lll; occ::handle ccc = BRep_Tool::Curve(e, fff, lll); @@ -1324,12 +1374,16 @@ void BRepFeat_RibSlot::PtOnEdgeVertex(const bool RevolRib, if (!RevolRib) { if (proj.NbPoints() == 1) + { TestOK = true; + } } else { if (proj.NbPoints() >= 1) + { TestOK = true; + } } if (TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) { @@ -1432,7 +1486,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, if (d1.IsEqual(d2, myTol)) { if (Concavite == 3) + { TestOK = false; + } } } @@ -1444,7 +1500,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, myPln->D0(P.X(), P.Y(), Pt); double par = IntPar(ln1, Pt); if (par > 0) + { Concavite = 1; // concave + } } } @@ -1505,7 +1563,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, } } if (!BndEdge1.IsNull() && !BndEdge2.IsNull()) + { break; + } } if (BndEdge1.IsNull() || BndEdge2.IsNull()) @@ -1557,10 +1617,14 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, { explo.Next(); if (explo.Current().IsNull()) + { explo.Init(BndWire); + } } else + { explo.Init(BndWire); + } // Check if this is BndEdge2 // -> if yes : it is required to turn to join FirstPnt @@ -1595,7 +1659,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, } } else + { explo.Init(BndWire); + } } BRepLib_MakeEdge e3(BndPnt2, myFirstPnt); @@ -1622,7 +1688,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, { const TopoDS_Edge& E = EX.Current(); if (E.IsSame(FirstEdge)) + { break; + } } EX.Next(); for (; EX.More(); EX.Next()) @@ -1633,7 +1701,9 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, WW.Add(E); } else + { break; + } } occ::handle LastCurve = BRep_Tool::Curve(LastEdge, ff, ll); TopoDS_Vertex LFVert = TopExp::FirstVertex(LastEdge, true); @@ -1648,9 +1718,13 @@ bool BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, double lpar = IntPar(FirstCurve, myLastPnt); occ::handle c; if (fpar > lpar) + { c = FirstCurve->Reversed(); + } else + { c = FirstCurve; + } BRepLib_MakeEdge ef(c, myFirstPnt, myLastPnt); WW.Add(ef); @@ -1782,12 +1856,16 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, double par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt); double par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt); if (par1 >= myTol || par2 >= myTol) + { Concavite = 2; // parallel and concave + } } if (d1.IsEqual(d2, myTol)) { if (Concavite == 3) + { TestOK = false; + } } } @@ -1799,7 +1877,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, myPln->D0(P.X(), P.Y(), Pt); double par = IntPar(firstln, Pt); if (par > 0) + { Concavite = 1; // concave + } } } @@ -1817,7 +1897,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, cc->D1(f, firstpoint, firstvect); lastln = new Geom_Line(firstpoint, -firstvect); if (FirstEdge.IsSame(LastEdge)) + { FalseOnlyOne = FalseFirstEdge; + } ln2d2 = GeomAPI::To2d(lastln, myPln->Pln()); } if (OnLastFace) @@ -1830,7 +1912,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, else { if (FalseOnlyOne.IsNull()) + { FalseOnlyOne = LastEdge; + } FalseLastEdge = FalseOnlyOne; } EdgeExtention(FalseLastEdge, bnd, false); @@ -1890,7 +1974,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, } } if (!BndEdge1.IsNull() && !BndEdge2.IsNull()) + { break; + } } if (BndEdge1.IsNull() || BndEdge2.IsNull()) @@ -2008,10 +2094,14 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, { explo.Next(); if (explo.Current().IsNull()) + { explo.Init(BndWire); + } } else + { explo.Init(BndWire); + } bool Fin = false; while (!Fin) { @@ -2076,7 +2166,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, } } else + { explo.Init(BndWire); + } } TopoDS_Edge eee3; @@ -2148,7 +2240,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseOnlyOne, true); + } BRepLib_MakeEdge e(cc, v1, v2); theEdge = TopoDS::Edge(e.Shape()); } @@ -2162,14 +2256,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseOnlyOne, true); + } BRepLib_MakeEdge e(cc, v1, v2); theEdge = TopoDS::Edge(e.Shape()); } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(theEdge, true); + } theLastEdge = theEdge; } else @@ -2188,7 +2286,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FirstEdge); + } BRepLib_MakeEdge e(cc, v1, v2); theEdge = TopoDS::Edge(e.Shape()); } @@ -2202,14 +2302,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FirstEdge, true); + } BRepLib_MakeEdge e(cc, v1, v2); theEdge = TopoDS::Edge(e.Shape()); } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(theEdge, true); + } theLastEdge = theEdge; } } @@ -2239,7 +2343,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(theEdge, true); + } theLastEdge = theEdge; } else @@ -2261,7 +2367,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(theEdge, true); + } theLastEdge = theEdge; } @@ -2270,7 +2378,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, { const TopoDS_Edge& E = ex.Current(); if (E.IsSame(FirstEdge)) + { break; + } } ex.Next(); @@ -2302,11 +2412,15 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, myLFMap(E).Append(eee); BB.Add(w, eee); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(eee, true); + } theLastEdge = eee; } else + { break; + } } if (!OnLastFace) @@ -2332,7 +2446,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(edg, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } @@ -2346,14 +2462,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(edg, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } myLFMap(edg).Append(eee); BB.Add(w, eee); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(eee, true); + } theLastEdge = eee; } else @@ -2376,7 +2496,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseOnlyOne, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } @@ -2390,14 +2512,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseOnlyOne, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } myLFMap(LastEdge).Append(eee); BB.Add(w, eee); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(eee, true); + } theLastEdge = eee; } } @@ -2421,7 +2547,9 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseLastEdge, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } @@ -2435,14 +2563,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, v2 = theFV; } else + { v2 = TopExp::LastVertex(FalseLastEdge, true); + } BRepLib_MakeEdge e(cc, v1, v2); eee = TopoDS::Edge(e.Shape()); } myLFMap(LastEdge).Append(eee); BB.Add(w, eee); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(eee, true); + } theLastEdge = eee; } } @@ -2461,14 +2593,18 @@ bool BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, BRepLib_MakeVertex vv(Pt); TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape()); if (!theFV.IsNull() && Pt.Distance(theFirstpoint) <= myTol) + { v2 = theFV; + } BRepLib_MakeEdge ef(v1, v2); eef = TopoDS::Edge(ef.Shape()); } BB.Add(w, eef); if (theFV.IsNull()) + { theFV = TopExp::FirstVertex(eef, true); + } theLastEdge = eef; } @@ -2558,7 +2694,9 @@ void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBO { const TopoDS_Shape& sh = it.Value(); if (sh.ShapeType() != TopAbs_FACE) + { continue; + } const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) { diff --git a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_SplitShape.cxx b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_SplitShape.cxx index 9bd647e717..f37120985a 100644 --- a/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_SplitShape.cxx +++ b/src/ModelingAlgorithms/TKFeat/BRepFeat/BRepFeat_SplitShape.cxx @@ -63,7 +63,9 @@ const NCollection_List& BRepFeat_SplitShape::Right() const { const TopoDS_Shape& aFace = anExplorer.Current(); if (!aMapOfLeft.Contains(aFace)) + { myRight.Append(aFace); + } } } return myRight; diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx index 9840841835..0f9ea33cfd 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx @@ -166,18 +166,26 @@ bool LocOpe::TgtFaces(const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_ HS1->D1(p.X(), p.Y(), pp1, du, dv); d1 = (du.Crossed(dv)).Normalized(); if (rev1) + { d1.Reverse(); + } HC2d2->D0(u, p); p.Coord(uu, vv); HS2->D1(uu, vv, pp1, du, dv); d2 = (du.Crossed(dv)).Normalized(); if (rev2) + { d2.Reverse(); + } ang = d1.Angle(d2); if (ang <= angmin) + { angmin = ang; + } if (ang >= angmax) + { angmax = ang; + } } return (angmax <= ta); } diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_DPrism.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_DPrism.cxx index 85ee8c9397..be355555c5 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_DPrism.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_DPrism.cxx @@ -128,7 +128,9 @@ LocOpe_DPrism::LocOpe_DPrism(const TopoDS_Face& Spine, for (it.Initialize(lffs); it.More(); it.Next()) { if (View.Add(it.Value())) + { B.Add(C, it.Value()); + } } } @@ -189,7 +191,9 @@ LocOpe_DPrism::LocOpe_DPrism(const TopoDS_Face& Spine, for (it.Initialize(lfls); it.More(); it.Next()) { if (View.Add(it.Value())) + { B.Add(D, it.Value()); + } } } @@ -403,7 +407,9 @@ LocOpe_DPrism::LocOpe_DPrism(const TopoDS_Face& Spine, const double Height, cons for (it.Initialize(lffs); it.More(); it.Next()) { if (View.Add(it.Value())) + { B.Add(C, it.Value()); + } } } @@ -464,7 +470,9 @@ LocOpe_DPrism::LocOpe_DPrism(const TopoDS_Face& Spine, const double Height, cons for (it.Initialize(lfls); it.More(); it.Next()) { if (View.Add(it.Value())) + { B.Add(D, it.Value()); + } } } diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_FindEdges.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_FindEdges.cxx index fe54ca8686..b5bdfcc698 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_FindEdges.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_FindEdges.cxx @@ -130,7 +130,9 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo) double prm1 = ElCLib::Parameter(cit, p1); double Tol2d = Precision::PConfusion(); if (std::abs(prm1 - ft) <= Tol2d) + { prm1 = ft; + } prm1 = ElCLib::InPeriod(prm1, ft, ft + 2. * M_PI); ElCLib::D1(prm1, cit, p1, tgt); diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Generator.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Generator.cxx index ac279a9032..a00232f984 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Generator.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Generator.cxx @@ -379,7 +379,9 @@ void LocOpe_Generator::Perform(const occ::handle& G) } } if (OK) + { theEEMap(edg).Append(edgbis); + } itl.Initialize(theEFMap.FindFromKey(edg)); bool FuseEdge = ToFuse(edg, fac, vtx, toRemove); diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Gluer.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Gluer.cxx index 2acd6105b2..dac75bbcae 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Gluer.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Gluer.cxx @@ -342,7 +342,9 @@ const NCollection_List& LocOpe_Gluer::DescendantFaces(const TopoDS throw StdFail_NotDone(); } if (myDescF.IsBound(F)) + { return myDescF(F); + } static NCollection_List nullList; return nullList; } @@ -490,7 +492,9 @@ void LocOpe_Gluer::AddEdges() { TopoDS_Edge e = TopoDS::Edge(exp.Current()); if (MapE.Contains(e)) + { continue; + } flag = 0; vexp.Init(e, TopAbs_VERTEX); for (; vexp.More(); vexp.Next()) @@ -532,11 +536,15 @@ void LocOpe_Gluer::AddEdges() break; } else + { flag = 1; + } } } else + { flag = 1; + } } if (flag == 1) { diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitDrafts.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitDrafts.cxx index f397bbee3b..e122304cd8 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitDrafts.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitDrafts.cxx @@ -147,7 +147,7 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, if (!FinS) { - std::cout << "LocOpe_SplitDrafts:!Fins throw Standard_ConstructionError()" << std::endl; + std::cout << "LocOpe_SplitDrafts:!Fins throw Standard_ConstructionError()" << '\n'; throw Standard_ConstructionError(); } @@ -188,7 +188,9 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, thePipe.Init(theLinePipe, i2s.Line(1)); thePipe.Perform(true); if (!thePipe.IsDone()) + { throw Standard_ConstructionError("GeomFill_Pipe : Cannot make a surface"); + } occ::handle Spl = thePipe.Surface(); HAS->Load(Spl); @@ -432,7 +434,9 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, thePipe.Init(theLinePipe, C); thePipe.Perform(true); if (!thePipe.IsDone()) + { throw Standard_ConstructionError("GeomFill_Pipe : Cannot make a surface"); + } occ::handle thePS = thePipe.Surface(); if (thePS->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) @@ -710,7 +714,7 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, } if (!itl.More()) { - std::cout << "LocOpe_SplitDrafts: betite probleme " << std::endl; + std::cout << "LocOpe_SplitDrafts: betite probleme " << '\n'; return; } } @@ -1529,7 +1533,7 @@ static bool NewPlane(const TopoDS_Face& F, } } } - std::cout << "fin newplane return standard_false" << std::endl; + std::cout << "fin newplane return standard_false" << '\n'; return false; } @@ -1602,7 +1606,7 @@ static void MakeFace(TopoDS_Face& F, NCollection_List& ledg) } if (C2d.IsNull()) { - std::cout << "Ca merde violemment" << std::endl; + std::cout << "Ca merde violemment" << '\n'; } } } @@ -1703,7 +1707,7 @@ static void MakeFace(TopoDS_Face& F, NCollection_List& ledg) } else { - std::cout << "Not yet implemented : nbwire >= 2" << std::endl; + std::cout << "Not yet implemented : nbwire >= 2" << '\n'; } } diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx index 5d8ce2e087..64debc9883 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_SplitShape.cxx @@ -78,9 +78,13 @@ inline bool SameUV(const gp_Pnt2d& P1, { bool isSame = true; if (theBAS.IsUPeriodic()) + { isSame = (fabs(P1.X() - P2.X()) < theBAS.UPeriod() * 0.5); + } if (theBAS.IsVPeriodic()) + { isSame = (isSame && (fabs(P1.Y() - P2.Y()) < theBAS.VPeriod() * 0.5)); + } return isSame; // return P1.SquareDistance(P2) < tol * tol; //IFV } @@ -284,7 +288,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const } } if (aLInside.Extent()) + { break; + } } if (!aLInside.Extent() || !itl.More()) { @@ -299,7 +305,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const NCollection_DataMap SectionsTimes; for (itl.Initialize(aLInside); itl.More(); itl.Next()) + { SectionsTimes.Bind(itl.Value(), 2); + } NCollection_List BreakVertices; NCollection_List BreakOnWires; @@ -315,7 +323,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const for (i = 0; i < 2; i++) { if (VerWireMap.IsBound(Ver[i])) + { continue; + } for (ExploF.Init(FaceRef, TopAbs_WIRE); ExploF.More(); ExploF.Next()) { const TopoDS_Shape& aWire = ExploF.Current(); @@ -324,7 +334,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const { aVer = ExploW.Current(); if (aVer.IsSame(Ver[i])) + { break; + } } if (aVer.IsSame(Ver[i])) { @@ -344,10 +356,14 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const TopExp::Vertices(aWire, V1, V2); NCollection_List LW1, LW2; if (!VerSecMap.IsBound(V1)) + { VerSecMap.Bind(V1, LW1); + } VerSecMap(V1).Append(aWire); if (!VerSecMap.IsBound(V2)) + { VerSecMap.Bind(V2, LW2); + } VerSecMap(V2).Append(aWire); } @@ -369,11 +385,15 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const TopoDS_Vertex aBreakVertex; wexp.Next(); if (!wexp.More()) + { wexp.Init(CurWire, FaceRef); + } for (;;) { if (MW->Wire().Closed()) + { break; + } CurVertex = wexp.CurrentVertex(); if (VerSecMap.IsBound(CurVertex)) { @@ -387,7 +407,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const LastEdge = CurEdge; wexp.Next(); if (!wexp.More()) + { wexp.Init(CurWire, FaceRef); + } } if (MW->Wire().Closed()) { @@ -398,7 +420,9 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const BreakOnWires.RemoveFirst(); wexp.Init(CurWire, FaceRef); while (!wexp.CurrentVertex().IsSame(theStartVertex)) + { wexp.Next(); + } MW = new BRepLib_MakeWire(); continue; } @@ -410,19 +434,25 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const MW->Add(aSectionWire); (SectionsTimes(aSectionWire))--; if (SectionsTimes(aSectionWire) == 0) + { SectionsTimes.UnBind(aSectionWire); + } if (MW->Wire().Closed()) { NewWires.Append(MW->Wire()); if (SectionsTimes.IsEmpty()) + { break; + } theStartVertex = TopoDS::Vertex(BreakVertices.First()); BreakVertices.RemoveFirst(); CurWire = TopoDS::Wire(BreakOnWires.First()); BreakOnWires.RemoveFirst(); wexp.Init(CurWire, FaceRef); while (!wexp.CurrentVertex().IsSame(theStartVertex)) + { wexp.Next(); + } MW = new BRepLib_MakeWire(); break; } @@ -435,11 +465,15 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const wexp.Init(CurWire, FaceRef); while (!wexp.CurrentVertex().IsSame(aStartVertex)) + { wexp.Next(); + } const NCollection_List& Lsections = VerSecMap(aStartVertex); if (Lsections.Extent() == 1) + { break; + } // else: choose the way TopoDS_Wire NextSectionWire = TopoDS::Wire( @@ -449,8 +483,12 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const NCollection_DataMap::Iterator itVW( VerWireMap); for (; itVW.More(); itVW.Next()) + { if (itVW.Value().IsSame(CurWire)) + { Times++; + } + } if (Times == 1) // it is inner touching wire { // InnerTouchingWiresOnVertex.Bind(aWire, aStartVertex); @@ -464,14 +502,18 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const Ldirs.Append(NextSectionWire); TopoDS_Shape theDirection = ChooseDirection(aSectionWire, aStartVertex, FaceRef, Ldirs); if (theDirection.IsSame(aStartEdge)) + { break; + } } aSectionWire = NextSectionWire; aBreakVertex = aStartVertex; } // end of else (MW is not closed) } // end of for (;;) (loop on section wires) if (SectionsTimes.IsEmpty()) + { break; + } } // end of global for (;;) NCollection_List NewFaces; @@ -505,10 +547,14 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const } } if (found) + { break; + } } if (!found) + { Holes.Append(aWire); + } } NCollection_List::Iterator itlNewF; for (itl.Initialize(Holes); itl.More(); itl.Next()) @@ -538,6 +584,7 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const // JAG 10.11.95 Codage des regularites for (itl.Initialize(aLInside); itl.More(); itl.Next()) + { for (ExploW.Init(itl.Value(), TopAbs_EDGE); ExploW.More(); ExploW.Next()) { const TopoDS_Edge& edg = TopoDS::Edge(ExploW.Current()); @@ -546,6 +593,7 @@ bool LocOpe_SplitShape::Add(const NCollection_List& Lwires, const BB.Continuity(edg, F, F, GeomAbs_CN); } } + } return true; } @@ -571,12 +619,16 @@ bool LocOpe_SplitShape::Add(const TopoDS_Wire& W, const TopoDS_Face& F) if (!LocOpe::Closed(W, F)) { if (!AddOpenWire(W, F)) + { return false; + } } else { if (!AddClosedWire(W, F)) + { return false; + } } } catch (Standard_Failure const&) @@ -708,14 +760,18 @@ static bool checkOverlapping(const TopoDS_Edge& theEdge1, proj.Init(aP2d, aCrv1, aF1, aL1); // check intermediate points if (!proj.NbPoints() || proj.LowerDistance() > aMaxTol2d) + { return false; + } double par1 = proj.LowerDistanceParameter(); gp_Pnt2d aP2d1; gp_Vec2d aV1; aCrv1->D1(par1, aP2d1, aV1); if (!aV1.IsParallel(aV2, aTolAng)) + { return false; + } } return true; } @@ -878,7 +934,9 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) { const TopoDS_Edge& edg = TopoDS::Edge(exp.Current()); if (nbE > 1 && edg.IsSame(LastEdge)) + { continue; + } for (exp2.Init(edg, TopAbs_VERTEX); exp2.More(); exp2.Next()) { if (exp2.Current().IsSame(Vlast)) @@ -923,7 +981,9 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) if ((orient == TopAbs_FORWARD && Vlast.IsSame(vdeb)) || (orient == TopAbs_REVERSED && Vlast.IsSame(vfin))) + { PossE.Add(edg); + } } nbPoss = PossE.Extent(); if (nbPoss == 0) @@ -944,7 +1004,9 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) TopoDS_Shape aLocalFaceTemp = FaceRef.Oriented(wfirst.Orientation()); if (!ChoixUV(LastEdge, TopoDS::Face(aLocalFaceTemp), PossE, aNextEdge, plast, dlast)) + { return false; + } } if (nbPoss >= 1) @@ -956,7 +1018,9 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) } if (MapE.Contains(aNextEdge)) + { break; + } B.Add(newW1, aNextEdge); MapE.Add(aNextEdge); LastEdge = aNextEdge; @@ -976,7 +1040,7 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) // MODIFICATION PIERRE SMEYERS : si pas de possibilite, on sort avec erreur else { - std::cout << "erreur Spliter : pas de chainage du wire" << std::endl; + std::cout << "erreur Spliter : pas de chainage du wire" << '\n'; return false; } // fin MODIF. @@ -996,18 +1060,26 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) MapE.Add(edg); nbAddBound++; if (anE1.IsNull()) + { anE1 = edg; + } else + { anE2 = edg; + } } } // check overlapping edges for second face if (nbAddBound < 2) + { return false; + } if (nbAddBound == 2 && !anE1.IsNull() && !anE2.IsNull()) { if (checkOverlapping(TopoDS::Edge(anE1), TopoDS::Edge(anE2), FaceRef)) + { return false; + } } nbAddBound = 0; @@ -1017,20 +1089,30 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) for (; anItE.More(); anItE.Next()) { if (anItE.Value().ShapeType() != TopAbs_EDGE) + { continue; + } nbAddBound++; if (anE11.IsNull()) + { anE11 = anItE.Value(); + } else + { anE12 = anItE.Value(); + } } // check overlapping edges for first face if (nbAddBound < 2) + { return false; + } if (nbAddBound == 2 && !anE11.IsNull() && !anE12.IsNull()) { if (checkOverlapping(TopoDS::Edge(anE11), TopoDS::Edge(anE12), FaceRef)) + { return false; + } } TopoDS_Face newF1, newF2; @@ -1063,7 +1145,7 @@ bool LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W, const TopoDS_Face& F) // Ce wire est ni dans newF2 ni dans newF1 // Peut etre faut il construire une troisieme face std::cout << "WARNING: LocOpe_SPlitShape : Ce wire est ni dans newF2 ni dans newF1" - << std::endl; + << '\n'; } } } @@ -1299,10 +1381,14 @@ static void updateToleraces( for (; aExpE.More(); aExpE.Next()) { if (!theMap.IsBound(aExpE.Current())) + { continue; + } const NCollection_List& lEdges = theMap(aExpE.Current()); if (lEdges.Extent() <= 1) + { continue; + } NCollection_List::Iterator itrE(lEdges); ShapeAnalysis_Edge aSae; @@ -1326,7 +1412,9 @@ bool LocOpe_SplitShape::Rebuild(const TopoDS_Shape& S) { if (S.ShapeType() == TopAbs_FACE) + { updateToleraces(TopoDS::Face(S), myMap); + } NCollection_List::Iterator itr(myMap(S)); if (itr.More()) { @@ -1354,7 +1442,9 @@ bool LocOpe_SplitShape::Rebuild(const TopoDS_Shape& S) } // Assign "Closed" flag for Wires and Shells only if (result.ShapeType() == TopAbs_WIRE || result.ShapeType() == TopAbs_SHELL) + { result.Closed(BRep_Tool::IsClosed(result)); + } myMap(S).Append(result); } else @@ -1462,7 +1552,9 @@ static bool IsInside(const TopoDS_Face& F, const TopoDS_Wire& W) TopAbs_State stat = classif.Perform(pt2d); // return (classif.Perform(pt2d) != TopAbs_OUT); if (stat == TopAbs_OUT) + { return false; + } if (stat == TopAbs_ON) { @@ -1477,14 +1569,22 @@ static bool IsInside(const TopoDS_Face& F, const TopoDS_Wire& W) pt2d = C2d->Value(prm); stat = classif.Perform(pt2d); if (stat == TopAbs_OUT) + { nbOut++; + } else if (stat == TopAbs_IN) + { nbIn++; + } else + { nbOn++; + } } if (nbOut > nbIn + nbOn) + { return false; + } } } return true; @@ -1521,7 +1621,9 @@ static void GetDirection(const TopoDS_Edge& theEdge, theDir = gp_Vec2d(aPrevPnt, thePnt); } if (anOr == TopAbs_REVERSED) + { theDir.Reverse(); + } } //================================================================================================= @@ -1553,7 +1655,9 @@ bool ChoixUV(const TopoDS_Edge& GetDirection(anEdge, F, p2d, v2d, true); if (!SameUV(plst, p2d, surf)) + { continue; + } surf.D0(p2d.X(), p2d.Y(), aPCur); @@ -1619,7 +1723,9 @@ static TopoDS_Shape ChooseDirection(const TopoDS_Shape& RefDir double RefPar = (anOr == TopAbs_FORWARD) ? RefLast : RefFirst; RefCurve->D1(RefPar, RefPnt, RefVec); if (anOr == TopAbs_FORWARD) + { RefVec.Reverse(); + } occ::handle aCurve; double aFirst, aLast, aPar; @@ -1650,10 +1756,14 @@ static TopoDS_Shape ChooseDirection(const TopoDS_Shape& RefDir aPar = (anOr == TopAbs_FORWARD) ? aFirst : aLast; aCurve->D1(aPar, RefPnt, aVec); if (anOr == TopAbs_REVERSED) + { aVec.Reverse(); + } anAngle = aVec.Angle(RefVec); if (anAngle < 0.) + { anAngle += 2. * M_PI; + } if (anAngle < MinAngle) { diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Spliter.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Spliter.cxx index b8e3a4b67b..54dc087916 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Spliter.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_Spliter.cxx @@ -98,7 +98,9 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) { mapV.Add(vtx); if (vtx.IsSame(Vb)) + { continue; + } lsubs.Clear(); TopoDS_Vertex vsub = TopoDS::Vertex(vtx.Oriented(TopAbs_FORWARD)); gp_Pnt p1 = BRep_Tool::Pnt(vsub), p2 = BRep_Tool::Pnt(Vb); @@ -160,7 +162,9 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) { // on devrait verifier que le vtx n`existe pas deja sur l`edge if (!myMap.IsBound(Ed)) + { continue; + } Ed = TopoDS::Edge(myMap(Ed).First()); theCFace.Add(vtx, prm, Ed); } @@ -176,11 +180,15 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) { TopoDS_Face fac = PW->OnFace(); if (!myMap.IsBound(fac)) + { continue; + } bool IsFaceWithSec = PW->IsFaceWithSection(fac); fac = TopoDS::Face(myMap(fac).First()); if (IsFaceWithSec) + { theFacesWithSection.Add(fac); + } if (!mapFE.Contains(fac)) { NCollection_List thelist; @@ -202,10 +210,16 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) RebuildWires(ledges, PW); // Modified by skv - Mon May 31 12:32:54 2004 OCC5865 End if (theFacesWithSection.Contains(fac)) + { theCFace.Add(ledges, fac); + } else + { for (itl.Initialize(ledges); itl.More(); itl.Next()) + { theCFace.Add(TopoDS::Wire(itl.Value()), fac); + } + } } // Mise a jour des descendants @@ -374,14 +388,18 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) { const TopoDS_Edge& anEdge = TopoDS::Edge(Emap(i)); if (BRep_Tool::Degenerated(anEdge)) + { DegEdges.Append(anEdge); + } } NCollection_Sequence DegWires; for (;;) { if (DegEdges.IsEmpty()) + { break; + } TopoDS_Wire aDegWire; BB.MakeWire(aDegWire); BB.Add(aDegWire, DegEdges(1)); @@ -405,7 +423,9 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) } } if (!found) + { break; + } } DegWires.Append(aDegWire); } @@ -419,12 +439,16 @@ void LocOpe_Spliter::Perform(const occ::handle& PW) for (j = 2; j <= Vmap.Extent(); j++) { if (!Vmap(j).IsSame(Vmap(1))) + { theSubs.Substitute(Vmap(j), LV); + } } } theSubs.Build(myRes); if (theSubs.IsCopied(myRes)) + { myRes = theSubs.Copy(myRes).First(); + } //// myDLeft.Clear(); @@ -560,7 +584,9 @@ const NCollection_List& LocOpe_Spliter::DescendantShapes(const Top throw StdFail_NotDone(); } if (myMap.IsBound(F)) + { return myMap(F); + } else { static NCollection_List empty; diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_WiresOnShape.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_WiresOnShape.cxx index de0da60b0c..fd0f409333 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_WiresOnShape.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_WiresOnShape.cxx @@ -236,14 +236,18 @@ void LocOpe_WiresOnShape::BindAll() double pf, pl; occ::handle aPCurve = BRep_Tool::CurveOnSurface(edg, fac, pf, pl); if (aPCurve.IsNull()) + { continue; + } if (myCheckInterior) { bool isOverlapped = false; FindInternalIntersections(edg, fac, Splits, isOverlapped); if (isOverlapped) + { anOverlappedEdges.Add(edg); + } } } @@ -251,13 +255,17 @@ void LocOpe_WiresOnShape::BindAll() { TopoDS_Shape anEdge = Splits.FindKey(Ind); if (anOverlappedEdges.Contains(anEdge)) + { continue; + } TopoDS_Shape aFace = myMapEF.FindFromKey(anEdge); // Remove "anEdge" from "myMapEF" myMapEF.RemoveKey(anEdge); NCollection_List::Iterator itl(Splits(Ind)); for (; itl.More(); itl.Next()) + { myMapEF.Add(itl.Value(), aFace); + } } NCollection_DataMap aVertParam; @@ -296,10 +304,14 @@ void LocOpe_WiresOnShape::BindAll() { TopoDS_Shape aSh = myMap.Find(vtx); if (aSh.ShapeType() != TopAbs_EDGE) + { continue; + } Epro = TopoDS::Edge(myMap.Find(vtx)); if (aVertParam.IsBound(vtx)) + { prm = aVertParam.Find(vtx); + } } bool ok = Project(vtx, p2d, fac, Epro, prm); if (ok && !isProjected) @@ -339,8 +351,12 @@ void LocOpe_WiresOnShape::BindAll() // Modified by Sergey KHROMOV - Mon Feb 12 16:26:50 2001 Begin for (ite.Initialize(myMap); ite.More(); ite.Next()) + { if ((ite.Key()).ShapeType() == TopAbs_EDGE) + { myMapEF.Add(ite.Key(), ite.Value()); + } + } // Modified by Sergey KHROMOV - Mon Feb 12 16:26:52 2001 End myDone = true; @@ -445,7 +461,9 @@ bool LocOpe_WiresOnShape::OnEdge(const TopoDS_Vertex& V, Ed = TopoDS::Edge(myMap(V)); if (!myMapEF.Contains(EdgeFrom)) + { return false; + } TopoDS_Shape aShape = myMapEF.FindFromKey(EdgeFrom); double aF, aL; @@ -461,7 +479,9 @@ bool LocOpe_WiresOnShape::OnEdge(const TopoDS_Vertex& V, prm = Project(V, p2d, Ed, aFace); } else + { prm = Project(V, TopoDS::Edge(Ed)); + } return true; } @@ -495,7 +515,9 @@ bool Project(const TopoDS_Vertex& V, { aCurPar = Project(V, edg); if (Precision::IsInfinite(aCurPar)) + { continue; + } gp_Pnt aCurPBound; C->D0(aCurPar, aCurPBound); aCurDist = aCurPBound.SquareDistance(toproj); @@ -506,11 +528,15 @@ bool Project(const TopoDS_Vertex& V, // Geom2dAPI_ProjectPointOnCurve proj; occ::handle aC2d = BRep_Tool::CurveOnSurface(edg, F, f, l); if (aC2d.IsNull()) + { continue; + } aCurPar = Project(V, p2d, edg, F); if (Precision::IsInfinite(aCurPar)) + { continue; + } occ::handle PC = BRep_Tool::CurveOnSurface(edg, F, f, l); gp_Pnt2d aPProj; PC->D0(aCurPar, aPProj); @@ -528,7 +554,9 @@ bool Project(const TopoDS_Vertex& V, } } if (theEdge.IsNull()) + { return false; + } } else if (Precision::IsInfinite(param)) { @@ -613,7 +641,9 @@ bool Project(const TopoDS_Vertex& V, { double aDist3d1 = aDist2d / std::max(anUResolution, aVResolution); if (aDist3d1 > aDist3d) + { aDist3d = aDist3d1; + } } } @@ -720,12 +750,18 @@ void PutPCurve(const TopoDS_Edge& Edg, const TopoDS_Face& Fac) aC2d->D0((f + l) * 0.5, p2d); bool IsIn = true; if ((p2d.X() < Umin - Precision::PConfusion()) || (p2d.X() > Umax + Precision::PConfusion())) + { IsIn = false; + } if ((p2d.Y() < Vmin - Precision::PConfusion()) || (p2d.Y() > Vmax + Precision::PConfusion())) + { IsIn = false; + } if (IsIn) + { return; + } } TopLoc_Location Loc; @@ -747,9 +783,13 @@ void PutPCurve(const TopoDS_Edge& Edg, const TopoDS_Face& Fac) TopoDS_Vertex V1, V2; TopExp::Vertices(Edg, V1, V2); if (!V1.IsNull()) + { TolFirst = BRep_Tool::Tolerance(V1); + } if (!V2.IsNull()) + { TolLast = BRep_Tool::Tolerance(V2); + } constexpr double tol2d = Precision::Confusion(); occ::handle C2d; @@ -954,7 +994,9 @@ void PutPCurves(const TopoDS_Edge& Efrom, const TopoDS_Edge& Eto, const TopoDS_S occ::handle C2d = GeomProjLib::Curve2d(C, S, Umin, Umax, Vmin, Vmax, tol2d); if (C2d.IsNull()) + { return; + } gp_Pnt2d pf(C2d->Value(f)); gp_Pnt2d pl(C2d->Value(l)); @@ -1294,14 +1336,18 @@ void FindInternalIntersections( Bnd_Box2d aBox; BndLib_Add2dCurve::Add(aPCurve, BRep_Tool::Tolerance(anEdge), aBox); if (theBox.IsOut(aBox)) + { continue; + } const occ::handle& aCurve = BRep_Tool::Curve(anEdge, aFpar, aLpar); GeomAdaptor_Curve aGAcurve(aCurve, aFpar, aLpar); Extrema_ExtCC anExtrema(theGAcurve, aGAcurve, TolExt, TolExt); if (!anExtrema.IsDone() || !anExtrema.NbExt()) + { continue; + } int aNbExt = anExtrema.NbExt(); double MaxTol = BRep_Tool::Tolerance(anEdge); @@ -1319,9 +1365,13 @@ void FindInternalIntersections( for (i = 0; i < 4; ++i) { if (i < 2) + { j = 0; + } else + { j = 1; + } if (dists[i] < aTolVExt[j] / ext) { return; @@ -1332,7 +1382,9 @@ void FindInternalIntersections( { double aDist = anExtrema.SquareDistance(i); if (aDist > aMaxTol2) + { continue; + } Extrema_POnCurv aPOnC1, aPOnC2; anExtrema.Points(i, aPOnC1, aPOnC2); @@ -1341,7 +1393,9 @@ void FindInternalIntersections( for (j = 0; j < 2; j++) // try to find intersection on an extremity of "theEdge" { if (std::abs(theIntPar - thePar[j]) <= aTolV2d[j]) + { break; + } } // intersection found in the middle of the edge if (j >= 2) // intersection is inside "theEdge" => split @@ -1356,24 +1410,32 @@ void FindInternalIntersections( { SplitPars.Append(theIntPar); if (aDist > aDistMax) + { aDistMax = aDist; + } } } } } if (SplitPars.IsEmpty()) + { return; + } // Sort for (i = 1; i < SplitPars.Length(); i++) + { for (j = i + 1; j <= SplitPars.Length(); j++) + { if (SplitPars(i) > SplitPars(j)) { double Tmp = SplitPars(i); SplitPars(i) = SplitPars(j); SplitPars(j) = Tmp; } + } + } // Remove repeating points i = 1; while (i < SplitPars.Length()) @@ -1381,9 +1443,13 @@ void FindInternalIntersections( gp_Pnt Pnt1 = theCurve->Value(SplitPars(i)); gp_Pnt Pnt2 = theCurve->Value(SplitPars(i + 1)); if (Pnt1.SquareDistance(Pnt2) <= Precision::Confusion() * Precision::Confusion()) + { SplitPars.Remove(i + 1); + } else + { i++; + } } // Split @@ -1427,15 +1493,21 @@ void FindInternalIntersections( } if (anOrient == TopAbs_FORWARD) + { NewEdges.Append(NewEdge); + } else + { NewEdges.Prepend(NewEdge); + } FirstVertex = LastVertex; FirstPar = LastPar; } if (!NewEdges.IsEmpty()) + { Splits.Add(theEdge, NewEdges); + } } //================================================================================================= @@ -1456,7 +1528,9 @@ bool LocOpe_WiresOnShape::Add(const NCollection_Sequence& theEdges Bnd_Box aBoxE; BRepBndLib::AddClose(aCurE, aBoxE); if (aBoxE.IsVoid()) + { continue; + } double aTolE = BRep_Tool::Tolerance(TopoDS::Edge(aCurE)); aBoxE.SetGap(aTolE); anEdgeBoxes.SetValue(i, aBoxE); @@ -1472,7 +1546,9 @@ bool LocOpe_WiresOnShape::Add(const NCollection_Sequence& theEdges Bnd_Box aBoxF; BRepBndLib::Add(aCurF, aBoxF); if (aBoxF.IsVoid()) + { continue; + } BRepAdaptor_Surface anAdF(aCurF, false); NCollection_Handle aCheckStateTool; @@ -1492,10 +1568,14 @@ bool LocOpe_WiresOnShape::Add(const NCollection_Sequence& theEdges for (; i <= nb; i++) { if (anUsedEdges.Contains(i)) + { continue; + } if (aBoxF.IsOut(anEdgeBoxes(i))) + { continue; + } const TopoDS_Edge& aCurE = TopoDS::Edge(anEdges(i)); @@ -1510,7 +1590,9 @@ bool LocOpe_WiresOnShape::Add(const NCollection_Sequence& theEdges anExtr.Perform(aP); if (!anExtr.IsDone() || !anExtr.NbExt()) + { continue; + } double aTolE = BRep_Tool::Tolerance(TopoDS::Edge(aCurE)); double aTol2 = (aTolE + Precision::Confusion()) * (aTolE + Precision::Confusion()); int n = 1; @@ -1518,7 +1600,9 @@ bool LocOpe_WiresOnShape::Add(const NCollection_Sequence& theEdges { double aDist2 = anExtr.SquareDistance(n); if (aDist2 > aTol2) + { continue; + } const Extrema_POnSurf& aPS = anExtr.Point(n); double aU, aV; aPS.Parameter(aU, aV); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppFuncRoot.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppFuncRoot.cxx index 5e1673a133..d188e8fbc5 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppFuncRoot.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppFuncRoot.cxx @@ -100,7 +100,9 @@ bool BRepBlend_AppFuncRoot::D0(const double Param, Ok = SearchPoint(*Func, Param, myPnt); if (Ok) + { (*Func).Section(myPnt, Poles, Poles2d, Weigths); + } return Ok; } @@ -242,7 +244,9 @@ void BRepBlend_AppFuncRoot::GetTolerance(const double BoundTol, Func->GetTolerance(BoundTol, SurfTol, AngleTol, V3d, V1d); for (ii = 1; ii <= Tol3d.Length(); ii++) + { Tol3d(ii) = V3d(ii); + } } void BRepBlend_AppFuncRoot::SetTolerance(const double Tol3d, const double Tol2d) diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppSurface.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppSurface.cxx index 26cda0baa1..22c0fb5056 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppSurface.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_AppSurface.cxx @@ -41,7 +41,9 @@ BRepBlend_AppSurface::BRepBlend_AppSurface(const occ::handleSectionShape(NbPolSect, NbKnotSect, udeg); NCollection_Array1 W(1, NbPolSect); NCollection_Array1 P(1, NbPolSect); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_BlendTool.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_BlendTool.cxx index 8ff9ad9a60..5021150583 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_BlendTool.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_BlendTool.cxx @@ -59,7 +59,9 @@ bool BRepBlend_BlendTool::Project(const gp_Pnt2d& P, const double Tol = 1.e-5; Extrema_EPCOfExtPC2d extrema(P, *C, Nbu, epsX, Tol); if (!extrema.IsDone()) + { return true; + } const int Nbext = extrema.NbExt(); double aDist2 = Dist * Dist; @@ -91,7 +93,9 @@ bool BRepBlend_BlendTool::Inters(const gp_Pnt2d& P1, const gp_Vec2d v(P1, P2); const double mag = v.Magnitude(); if (mag < Tol) + { return false; + } gp_Dir2d d(v); occ::handle bid = new Geom2d_Line(P1, d); @@ -99,11 +103,15 @@ bool BRepBlend_BlendTool::Inters(const gp_Pnt2d& P1, Geom2dInt_GInter inter(seg, *C, Tol, Tol); if (!inter.IsDone()) + { return false; + } const int Nbint = inter.NbPoints(); if (Nbint == 0) + { return false; + } IntRes2d_IntersectionPoint ip = inter.Point(1); Param = ip.ParamOnSecond(); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_CSWalking.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_CSWalking.cxx index 64c66ab131..e41da444a7 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_CSWalking.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_CSWalking.cxx @@ -1085,7 +1085,7 @@ void BRepBlend_CSWalking::InternalPerform(Blend_CSFunction& Func, case Blend_SamePoints: { // On arrete - std::cout << " Points confondus dans le cheminement" << std::endl; + std::cout << " Points confondus dans le cheminement" << '\n'; /* Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp); Extc.SetValue(previousP.PointOnC(),sol(3),tolesp); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurve2dTool.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurve2dTool.cxx index 8d9d48a075..8fa5497d6b 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurve2dTool.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurve2dTool.cxx @@ -31,9 +31,13 @@ int BRepBlend_HCurve2dTool::NbSamples(const occ::handle& C, double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + C->Bezier()->NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { occ::handle BSC = C->BSpline(); @@ -42,9 +46,13 @@ int BRepBlend_HCurve2dTool::NbSamples(const occ::handle& C, nbs *= BSC->LastParameter() - BSC->FirstParameter(); nbs /= U1 - U0; if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurveTool.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurveTool.cxx index 7f493a620a..6e89c3ae93 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurveTool.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_HCurveTool.cxx @@ -31,9 +31,13 @@ int BRepBlend_HCurveTool::NbSamples(const occ::handle& C, double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + C->Bezier()->NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { occ::handle BSC = C->BSpline(); @@ -42,9 +46,13 @@ int BRepBlend_HCurveTool::NbSamples(const occ::handle& C, nbs *= BSC->LastParameter() - BSC->FirstParameter(); nbs /= U1 - U0; if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstConstRad.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstConstRad.cxx index 0f006449d2..ab62cbdbaa 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstConstRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstConstRad.cxx @@ -234,7 +234,9 @@ bool BRepBlend_RstRstConstRad::IsSolution(const math_Vector& Sol, const double T istangent = false; } else + { istangent = true; + } } if (!istangent) @@ -258,7 +260,9 @@ bool BRepBlend_RstRstConstRad::IsSolution(const math_Vector& Sol, const double T IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed); if (!IsCenter) + { return false; + } gp_Vec n1(Center, ptrst1), n2(Center, ptrst2); @@ -428,7 +432,9 @@ Blend_DecrochStatus BRepBlend_RstRstConstRad::Decroch(const math_Vector& Sol, centptrst.SetXYZ(PtTmp1.XYZ() - Center.XYZ()); if (centptrst.Dot(NRst1InPlane) < 0.) + { NRst1InPlane.Reverse(); + } TgRst1 = nplan.Crossed(centptrst); @@ -438,7 +444,9 @@ Blend_DecrochStatus BRepBlend_RstRstConstRad::Decroch(const math_Vector& Sol, centptrst.SetXYZ(PtTmp2.XYZ() - Center.XYZ()); if (centptrst.Dot(NRst2InPlane) < 0.) + { NRst2InPlane.Reverse(); + } TgRst2 = nplan.Crossed(centptrst); @@ -515,7 +523,9 @@ bool BRepBlend_RstRstConstRad::CenterCircleRst1Rst2(const gp_Pnt& PtRst1, } if (Dist < -1.E-07) + { return false; + } if (Dist > 1.E-07) { @@ -570,7 +580,9 @@ void BRepBlend_RstRstConstRad::Section(const double Param, Pfin = ElCLib::Parameter(C, ptrst2); } if (Pfin < Precision::PConfusion()) + { Pfin += Precision::PConfusion(); + } } //================================================================================================= @@ -782,7 +794,9 @@ bool BRepBlend_RstRstConstRad::Section(const Blend_Point& P, istgt = false; } else + { istgt = true; + } } gp_Vec med; @@ -791,7 +805,9 @@ bool BRepBlend_RstRstConstRad::Section(const Blend_Point& P, IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, med); if (!IsCenter) + { return false; + } normmed = med.Magnitude(); med.Normalize(); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstEvolRad.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstEvolRad.cxx index 2953267161..43006b3b49 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstEvolRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstEvolRad.cxx @@ -302,7 +302,9 @@ bool BRepBlend_RstRstEvolRad::IsSolution(const math_Vector& Sol, const double To istangent = false; } else + { istangent = true; + } } if (!istangent) @@ -326,7 +328,9 @@ bool BRepBlend_RstRstEvolRad::IsSolution(const math_Vector& Sol, const double To IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed); if (!IsCenter) + { return false; + } gp_Vec n1(Center, ptrst1), n2(Center, ptrst2); @@ -496,7 +500,9 @@ Blend_DecrochStatus BRepBlend_RstRstEvolRad::Decroch(const math_Vector& Sol, centptrst.SetXYZ(PtTmp1.XYZ() - Center.XYZ()); if (centptrst.Dot(NRst1InPlane) < 0.) + { NRst1InPlane.Reverse(); + } TgRst1 = nplan.Crossed(centptrst); @@ -506,7 +512,9 @@ Blend_DecrochStatus BRepBlend_RstRstEvolRad::Decroch(const math_Vector& Sol, centptrst.SetXYZ(PtTmp2.XYZ() - Center.XYZ()); if (centptrst.Dot(NRst2InPlane) < 0.) + { NRst2InPlane.Reverse(); + } TgRst2 = nplan.Crossed(centptrst); @@ -582,7 +590,9 @@ bool BRepBlend_RstRstEvolRad::CenterCircleRst1Rst2(const gp_Pnt& PtRst1, } if (Dist < -1.E-07) + { return false; + } if (Dist > 1.E-07) { @@ -638,7 +648,9 @@ void BRepBlend_RstRstEvolRad::Section(const double Param, Pfin = ElCLib::Parameter(C, ptrst2); } if (Pfin < Precision::PConfusion()) + { Pfin += Precision::PConfusion(); + } } //================================================================================================= @@ -889,7 +901,9 @@ bool BRepBlend_RstRstEvolRad::Section(const Blend_Point& P, istgt = false; } else + { istgt = true; + } } gp_Vec med; @@ -898,7 +912,9 @@ bool BRepBlend_RstRstEvolRad::Section(const Blend_Point& P, IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, med); if (!IsCenter) + { return false; + } normmed = med.Magnitude(); med.Normalize(); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstLineBuilder.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstLineBuilder.cxx index e8f62ccea9..3f082c803f 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstLineBuilder.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_RstRstLineBuilder.cxx @@ -334,7 +334,9 @@ bool BRepBlend_RstRstLineBuilder::PerformFirstSection(Blend_RstRstFunction& Fu math_FunctionSetRoot rsnld(Func, tolerance, 30); rsnld.Perform(Func, ParDep, infbound, supbound); if (!rsnld.IsDone()) + { return false; + } rsnld.Root(sol); recadrst1 = RecRst1 && Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1); @@ -362,7 +364,9 @@ bool BRepBlend_RstRstLineBuilder::PerformFirstSection(Blend_RstRstFunction& Fu } if (!recadrst1 && !recadp1 && !recadrst2 && !recadp2) + { return false; + } // it is checked if the contact was lost or domain 1 was left if (recadp1 && recadrst1) @@ -733,7 +737,9 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction& Func, decroch = Blend_NoDecroch; if (recadp1 || recadp2 || recadrst1 || recadrst2) + { echecrecad = false; + } if (!echecrecad) { @@ -1202,7 +1208,9 @@ bool BRepBlend_RstRstLineBuilder::Recadre1(Blend_RstRstFunction& Func, Func.Set(Solinv(1)); rsnld2.Perform(Func, parinit, infbound, supbound); if (!rsnld2.IsDone()) + { return false; + } rsnld2.Root(parinit); Solinv(2) = parinit(2); Solinv(3) = parinit(1); @@ -1282,7 +1290,9 @@ bool BRepBlend_RstRstLineBuilder::Recadre2(Blend_RstRstFunction& Func, Func.Set(Solinv(1)); rsnld2.Perform(Func, parinit, infbound, supbound); if (!rsnld2.IsDone()) + { return false; + } rsnld2.Root(parinit); Solinv(2) = parinit(1); Solinv(3) = parinit(2); @@ -1306,7 +1316,9 @@ bool BRepBlend_RstRstLineBuilder::Recadre1(Blend_CurvPointFuncInv& FinvP double upoint = firstrst1; if ((sol(1) - firstrst1) > (lastrst1 - sol(1))) + { upoint = lastrst1; + } p2drst1 = rst1->Value(upoint); gp_Pnt thepoint = surf1->Value(p2drst1.X(), p2drst1.Y()); @@ -1377,7 +1389,9 @@ bool BRepBlend_RstRstLineBuilder::Recadre2(Blend_CurvPointFuncInv& FinvP double vpoint = firstrst2; if ((sol(2) - firstrst2) > (lastrst2 - sol(2))) + { vpoint = lastrst2; + } p2drst2 = rst2->Value(vpoint); gp_Pnt thepoint = surf2->Value(p2drst2.X(), p2drst2.Y()); @@ -1448,7 +1462,9 @@ void BRepBlend_RstRstLineBuilder::Transition(const bool if (previousP.IsTangencyPoint()) { if (line->NbPoints() < 2) + { return; + } computetranstionaveclacorde = true; if (sens < 0) { @@ -1470,17 +1486,25 @@ void BRepBlend_RstRstLineBuilder::Transition(const bool { surf1->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnC1(); + } else + { tgline = gp_Vec(prevprev.PointOnC1(), previousP.PointOnC1()); + } } else { surf2->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnC2(); + } else + { tgline = gp_Vec(prevprev.PointOnC2(), previousP.PointOnC2()); + } } tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v); @@ -1508,14 +1532,18 @@ void BRepBlend_RstRstLineBuilder::MakeExtremity(BRepBlend_Extremity& { Extrem.SetValue(previousP.PointOnC1(), sol(1), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnC1()); + } Iter = domain1; } else { Extrem.SetValue(previousP.PointOnC2(), sol(2), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnC1()); + } Iter = domain2; } @@ -1585,7 +1613,9 @@ Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst1(const Blend_Poin gp_Vec Corde(prevP, Psurf); Norme = Corde.SquareMagnitude(); if (!prevpointistangent) + { prevNorme = prevTg.SquareMagnitude(); + } const double toler3d = 0.01 * tolpoint3d; if (Norme <= toler3d * toler3d) @@ -1672,7 +1702,9 @@ Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Poin gp_Vec Corde(prevP, Psurf); Norme = Corde.SquareMagnitude(); if (!prevpointistangent) + { prevNorme = prevTg.SquareMagnitude(); + } const double toler3d = 0.01 * tolpoint3d; if (Norme <= toler3d * toler3d) @@ -1732,7 +1764,9 @@ Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Poin static IntSurf_TypeTrans ConvOrToTra(const TopAbs_Orientation O) { if (O == TopAbs_FORWARD) + { return IntSurf_In; + } return IntSurf_Out; } @@ -1903,7 +1937,9 @@ bool BRepBlend_RstRstLineBuilder::CheckInside(Blend_RstRstFunction& Func, SituOnC1 = TopAbs_IN; } else + { SituOnC1 = TopAbs_ON; + } // face pcurve 2. v = sol(2); @@ -1916,7 +1952,9 @@ bool BRepBlend_RstRstLineBuilder::CheckInside(Blend_RstRstFunction& Func, SituOnC2 = TopAbs_IN; } else + { SituOnC2 = TopAbs_ON; + } // lost contact gp_Vec tgrst1, norst1, tgrst2, norst2; diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstConstRad.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstConstRad.cxx index 5dccf8ffac..8cdd2945ee 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstConstRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstConstRad.cxx @@ -373,7 +373,9 @@ bool BRepBlend_SurfRstConstRad::IsSolution(const math_Vector& Sol, const double istangent = false; } else + { istangent = true; + } } if (!istangent) @@ -389,7 +391,9 @@ bool BRepBlend_SurfRstConstRad::IsSolution(const math_Vector& Sol, const double // update of maxang if (ray > 0.) + { ns.Reverse(); + } ns2 = -resul.Normalized(); Cosa = ns.Dot(ns2); @@ -532,7 +536,9 @@ bool BRepBlend_SurfRstConstRad::Decroch(const math_Vector& Sol, gp_Vec& NS, gp_V Center.SetXYZ(bid.XYZ() + ray * NSInPlane.XYZ()); if (choix > 2) + { NSInPlane.Reverse(); + } TgS = nplan.Crossed(gp_Vec(Center, bid)); if (choix % 2 == 1) { @@ -547,7 +553,9 @@ bool BRepBlend_SurfRstConstRad::Decroch(const math_Vector& Sol, gp_Vec& NS, gp_V NRstInPlane.SetLinearForm(nplan.Dot(NRst) * unsurnorm, nplan, -unsurnorm, NRst); gp_Vec centptrst(Center, bid); if (centptrst.Dot(NRstInPlane) < 0.) + { NRstInPlane.Reverse(); + } TgRst = nplan.Crossed(centptrst); if (choix % 2 == 1) { @@ -644,7 +652,9 @@ void BRepBlend_SurfRstConstRad::Section(const double Param, Pfin = ElCLib::Parameter(C, ptrst); } if (Pfin < Precision::PConfusion()) + { Pfin += Precision::PConfusion(); + } } //================================================================================================= @@ -776,7 +786,9 @@ void BRepBlend_SurfRstConstRad::Section(const Blend_Point& P, ns2 = gp_Vec(Center, ptrst).Normalized(); if (ray > 0) + { ns.Reverse(); + } if (choix % 2 != 0) { nplan.Reverse(); @@ -878,7 +890,9 @@ bool BRepBlend_SurfRstConstRad::Section(const Blend_Point& P, istgt = false; } else + { istgt = true; + } } if (!istgt) diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstEvolRad.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstEvolRad.cxx index 9a93b35b4d..d1d33492ce 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstEvolRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstEvolRad.cxx @@ -434,7 +434,9 @@ bool BRepBlend_SurfRstEvolRad::IsSolution(const math_Vector& Sol, const double T istangent = false; } else + { istangent = true; + } } if (!istangent) @@ -454,7 +456,9 @@ bool BRepBlend_SurfRstEvolRad::IsSolution(const math_Vector& Sol, const double T } // update of maxang if (ray > 0.) + { ns.Reverse(); + } ns2 = -resul.Normalized(); Cosa = ns.Dot(ns2); @@ -597,7 +601,9 @@ bool BRepBlend_SurfRstEvolRad::Decroch(const math_Vector& Sol, gp_Vec& NS, gp_Ve Center.SetXYZ(bid.XYZ() + ray * NSInPlane.XYZ()); if (choix > 2) + { NSInPlane.Reverse(); + } TgS = nplan.Crossed(gp_Vec(Center, bid)); if (choix % 2 == 1) { @@ -612,7 +618,9 @@ bool BRepBlend_SurfRstEvolRad::Decroch(const math_Vector& Sol, gp_Vec& NS, gp_Ve NRstInPlane.SetLinearForm(nplan.Dot(NRst) * unsurnorm, nplan, -unsurnorm, NRst); gp_Vec centptrst(Center, bid); if (centptrst.Dot(NRstInPlane) < 0.) + { NRstInPlane.Reverse(); + } TgRst = nplan.Crossed(centptrst); if (choix % 2 == 1) { @@ -709,7 +717,9 @@ void BRepBlend_SurfRstEvolRad::Section(const double Param, Pfin = ElCLib::Parameter(C, ptrst); } if (Pfin < Precision::PConfusion()) + { Pfin += Precision::PConfusion(); + } } //================================================================================================= @@ -921,7 +931,9 @@ bool BRepBlend_SurfRstEvolRad::Section(const Blend_Point& P, istgt = false; } else + { istgt = true; + } } if (!istgt) @@ -1025,7 +1037,9 @@ bool BRepBlend_SurfRstEvolRad::Section(const Blend_Point& P, rayprim = -aDray; } else + { rayprim = aDray; + } return GeomFill::GetCircle(myTConv, ns, @@ -1123,7 +1137,9 @@ void BRepBlend_SurfRstEvolRad::Section(const Blend_Point& P, ns2 = gp_Vec(Center, ptrst).Normalized(); if (ray > 0) + { ns.Reverse(); + } if (choix % 2 != 0) { nplan.Reverse(); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstLineBuilder.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstLineBuilder.cxx index ae228e585e..7b05208bce 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstLineBuilder.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_SurfRstLineBuilder.cxx @@ -151,7 +151,9 @@ int BRepBlend_SurfRstLineBuilder::ArcToRecadre(const math_Vector& theSol, double uprev = 0., vprev = 0., prm = 0., dist = 0.; if (byinter) + { previousP.ParametersOnS(uprev, vprev); + } pt2d.SetCoord(theSol(1), theSol(2)); lastpt2d.SetCoord(uprev, vprev); domain1->Init(); @@ -166,7 +168,9 @@ int BRepBlend_SurfRstLineBuilder::ArcToRecadre(const math_Vector& theSol, BRepBlend_BlendTool::Inters(pt2d, lastpt2d, surf1, domain1->Value(), prm, dist); } if (!ok) + { ok = BRepBlend_BlendTool::Project(pt2d, surf1, domain1->Value(), prm, dist); + } if (ok && (nbarc != PrevIndex)) { @@ -176,7 +180,9 @@ int BRepBlend_SurfRstLineBuilder::ArcToRecadre(const math_Vector& theSol, ponarc = prm; IndexSol = nbarc; if (okinter && (PrevIndex == 0)) + { break; + } } } domain1->Next(); @@ -371,7 +377,9 @@ bool BRepBlend_SurfRstLineBuilder::PerformFirstSection(Blend_SurfRstFunction& F math_FunctionSetRoot rsnld(Func, tolerance, 30); rsnld.Perform(Func, ParDep, infbound, supbound); if (!rsnld.IsDone()) + { return false; + } rsnld.Root(sol); recads = RecS && Recadre(FinvC, solinvs, Arc, IsVtxs, Vtxs); @@ -390,7 +398,9 @@ bool BRepBlend_SurfRstLineBuilder::PerformFirstSection(Blend_SurfRstFunction& F wrst = solinvrst(2); } if (!recads && !recadp && !recadrst) + { return false; + } if (recadp && recadrst) { if (sens * (wrst - wp) > tolgui) @@ -675,7 +685,9 @@ void BRepBlend_SurfRstLineBuilder::InternalPerform(Blend_SurfRstFunction& Func, } decroch = false; if (recadp || recads || recadrst) + { echecrecad = false; + } if (!echecrecad) { if (recadp && recadrst) @@ -1192,7 +1204,9 @@ bool BRepBlend_SurfRstLineBuilder::Recadre(Blend_SurfRstFunction& Func, Func.Set(Solinv(2)); rsnld2.Perform(Func, parinit, infbound, supbound); if (!rsnld2.IsDone()) + { return false; + } rsnld2.Root(parinit); Solinv(3) = parinit(1); Solinv(4) = parinit(2); @@ -1215,7 +1229,9 @@ bool BRepBlend_SurfRstLineBuilder::Recadre(Blend_SurfPointFuncInv& FinvP double lastrst = rst->LastParameter(); double wpoint = firstrst; if ((sol(3) - firstrst) > (lastrst - sol(3))) + { wpoint = lastrst; + } p2drst = rst->Value(wpoint); gp_Pnt thepoint = surf2->Value(p2drst.X(), p2drst.Y()); @@ -1287,7 +1303,9 @@ void BRepBlend_SurfRstLineBuilder::Transition(const bool if (previousP.IsTangencyPoint()) { if (line->NbPoints() < 2) + { return; + } computetranstionaveclacorde = true; if (sens < 0) { @@ -1309,17 +1327,25 @@ void BRepBlend_SurfRstLineBuilder::Transition(const bool { surf1->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnS1(); + } else + { tgline = gp_Vec(prevprev.PointOnS(), previousP.PointOnS()); + } } else { surf2->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnS2(); + } else + { tgline = gp_Vec(prevprev.PointOnC(), previousP.PointOnC()); + } } tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v); @@ -1344,14 +1370,18 @@ void BRepBlend_SurfRstLineBuilder::MakeExtremity(BRepBlend_Extremity& { Extrem.SetValue(previousP.PointOnS(), sol(1), sol(2), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnS()); + } Iter = domain1; } else { Extrem.SetValue(previousP.PointOnC(), sol(3), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnC()); + } Iter = domain2; } @@ -1421,7 +1451,9 @@ Blend_Status BRepBlend_SurfRstLineBuilder::CheckDeflectionOnSurf(const Blend_Poi Norme = Corde.SquareMagnitude(); // if(!curpointistangent) curNorme = Tgsurf.SquareMagnitude(); if (!prevpointistangent) + { prevNorme = prevTg.SquareMagnitude(); + } const double toler3d = 0.01 * tolpoint3d; if (Norme <= toler3d * toler3d) @@ -1507,7 +1539,9 @@ Blend_Status BRepBlend_SurfRstLineBuilder::CheckDeflectionOnRst(const Blend_Poin Norme = Corde.SquareMagnitude(); // if(!curpointistangent) curNorme = Tgsurf.SquareMagnitude(); if (!prevpointistangent) + { prevNorme = prevTg.SquareMagnitude(); + } const double toler3d = 0.01 * tolpoint3d; if (Norme <= toler3d * toler3d) @@ -1567,7 +1601,9 @@ Blend_Status BRepBlend_SurfRstLineBuilder::CheckDeflectionOnRst(const Blend_Poin static IntSurf_TypeTrans ConvOrToTra(const TopAbs_Orientation O) { if (O == TopAbs_FORWARD) + { return IntSurf_In; + } return IntSurf_Out; } @@ -1724,7 +1760,9 @@ bool BRepBlend_SurfRstLineBuilder::CheckInside(Blend_SurfRstFunction& Func, SituOnC = TopAbs_IN; } else + { SituOnC = TopAbs_ON; + } // face surface gp_Pnt2d p2d(sol(1), sol(2)); diff --git a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_Walking.cxx b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_Walking.cxx index 03cc22c28f..46eeed63ee 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_Walking.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepBlend/BRepBlend_Walking.cxx @@ -162,9 +162,13 @@ void BRepBlend_Walking::AddSingularPoint(const Blend_Point& P) ti = jalons.Value(jj).Parameter(); } if (tp > ti) + { jalons.InsertAfter(jj, P); + } else + { jalons.InsertBefore(jj, P); + } } } @@ -184,7 +188,9 @@ void BRepBlend_Walking::Perform(Blend_Function& Func, comptra = false; bool doextremities = true; if (line.IsNull()) + { line = new BRepBlend_Line(); + } else { line->Clear(); @@ -226,15 +232,23 @@ void BRepBlend_Walking::Perform(Blend_Function& Func, rsnld.Root(sol); if (clasonS1) + { situ1 = domain1->Classify(gp_Pnt2d(sol(1), sol(2)), std::min(tolerance(1), tolerance(2)), false); + } else + { situ1 = TopAbs_IN; + } if (clasonS2) + { situ2 = domain2->Classify(gp_Pnt2d(sol(3), sol(4)), std::min(tolerance(3), tolerance(4)), false); + } else + { situ2 = TopAbs_IN; + } if (situ1 != TopAbs_IN || situ2 != TopAbs_IN) { @@ -264,7 +278,9 @@ void BRepBlend_Walking::Perform(Blend_Function& Func, // Mettre a jour la ligne. // Correct first parameter if needed if (ToCorrectOnRst1 || ToCorrectOnRst2) + { previousP.SetParameter(CorrectedParam); + } line->Append(previousP); if (doextremities) @@ -497,7 +513,9 @@ bool BRepBlend_Walking::PerformFirstSection(Blend_Function& Func, CorrectedV, CorrectedPnt, CorrectedParam)) + { ToCorrectOnRst1 = true; + } } else { // if (recad2) { @@ -527,7 +545,9 @@ bool BRepBlend_Walking::PerformFirstSection(Blend_Function& Func, CorrectedV, CorrectedPnt, CorrectedParam)) + { ToCorrectOnRst2 = true; + } } Psol = param; @@ -545,9 +565,13 @@ bool BRepBlend_Walking::PerformFirstSection(Blend_Function& Func, #endif MakeExtremity(Ext1, true, Index1, solrst1(1), Isvtx1, Vtx1); if (ToCorrectOnRst1) + { Ext2.SetValue(CorrectedPnt, CorrectedU, CorrectedV, tolpoint3d); + } else + { Ext2.SetValue(previousP.PointOnS2(), sol(3), sol(4), tolpoint3d); + } } break; @@ -559,9 +583,13 @@ bool BRepBlend_Walking::PerformFirstSection(Blend_Function& Func, } #endif if (ToCorrectOnRst2) + { Ext1.SetValue(CorrectedPnt, CorrectedU, CorrectedV, tolpoint3d); + } else + { Ext1.SetValue(previousP.PointOnS1(), sol(1), sol(2), tolpoint3d); + } MakeExtremity(Ext2, false, Index2, solrst2(1), Isvtx2, Vtx2); } break; @@ -657,9 +685,13 @@ bool BRepBlend_Walking::Continu(Blend_Function& Func, previousP.ParametersOnS2(sol(3), sol(4)); if (OnS1) + { clasonS1 = false; + } else + { clasonS2 = false; + } InternalPerform(Func, FuncInv, P); @@ -774,7 +806,9 @@ Blend_Status BRepBlend_Walking::TestArret(Blend_Function& Function, double tolsolu = tolpoint3d; if (!TestSolu) + { tolsolu *= 1000; // Ca doit toujours etre bon + } if (Function.IsSolution(sol, tolsolu)) { #ifdef OCCT_DEBUG @@ -795,9 +829,13 @@ Blend_Status BRepBlend_Walking::TestArret(Blend_Function& Function, V22d = Function.Tangent2dOnS2(); curpoint.SetValue(pt1, pt2, param, sol(1), sol(2), sol(3), sol(4), V1, V2, V12d, V22d); if (Function.TwistOnS1()) + { loctwist1 = true; + } if (Function.TwistOnS2()) + { loctwist2 = true; + } } if (TestDefl && check) @@ -825,15 +863,23 @@ Blend_Status BRepBlend_Walking::TestArret(Blend_Function& Function, curpoint.ParametersOnS1(curparamu, curparamv); previousP.ParametersOnS1(prevparamu, prevparamv); if (std::abs(curparamu - prevparamu) > sup(1)) + { State1 = Blend_StepTooLarge; + } if (std::abs(curparamv - prevparamv) > sup(2)) + { State1 = Blend_StepTooLarge; + } curpoint.ParametersOnS2(curparamu, curparamv); previousP.ParametersOnS2(prevparamu, prevparamv); if (std::abs(curparamu - prevparamu) > sup(3)) + { State2 = Blend_StepTooLarge; + } if (std::abs(curparamv - prevparamv) > sup(4)) + { State2 = Blend_StepTooLarge; + } } } @@ -857,9 +903,13 @@ Blend_Status BRepBlend_Walking::TestArret(Blend_Function& Function, // Ici seulement on peut statuer sur le twist // Car les rejet ont ete effectue (BUC60322) if (loctwist1) + { twistflag1 = true; + } if (loctwist2) + { twistflag2 = true; + } if (!comptra && !curpointistangent) { @@ -983,7 +1033,9 @@ Blend_Status BRepBlend_Walking::CheckDeflection(const bool OnFirst, const Blend_ Norme = Corde.SquareMagnitude(); // if(!curpointistangent) curNorme = Tgsurf.SquareMagnitude(); if (!prevpointistangent) + { prevNorme = prevTg.SquareMagnitude(); + } const double toler3d = 0.01 * tolpoint3d; if (Norme <= toler3d * toler3d) @@ -1027,19 +1079,27 @@ Blend_Status BRepBlend_Walking::CheckDeflection(const bool OnFirst, const Blend_ { CurPoint.ParametersOnS1(curparamu, curparamv); if (!curpointistangent) + { Tgonsurf = CurPoint.Tangent2dOnS1(); + } previousP.ParametersOnS1(prevparamu, prevparamv); if (!prevpointistangent) + { previousd2d = previousP.Tangent2dOnS1(); + } } else { CurPoint.ParametersOnS2(curparamu, curparamv); if (!curpointistangent) + { Tgonsurf = CurPoint.Tangent2dOnS2(); + } previousP.ParametersOnS2(prevparamu, prevparamv); if (!prevpointistangent) + { previousd2d = previousP.Tangent2dOnS2(); + } } Du = curparamu - prevparamu; @@ -1110,14 +1170,18 @@ int BRepBlend_Walking::ArcToRecadre(const bool OnFirst, if (OnFirst) { if (byinter) + { previousP.ParametersOnS1(uprev, vprev); + } pt2d.SetCoord(theSol(1), theSol(2)); Iter = recdomain1; } else { if (byinter) + { previousP.ParametersOnS2(uprev, vprev); + } pt2d.SetCoord(theSol(3), theSol(4)); Iter = recdomain2; } @@ -1134,7 +1198,9 @@ int BRepBlend_Walking::ArcToRecadre(const bool OnFirst, ok = okinter = BRepBlend_BlendTool::Inters(pt2d, lastpt2d, surf1, Iter->Value(), prm, dist); } if (!ok) + { ok = BRepBlend_BlendTool::Project(pt2d, surf1, Iter->Value(), prm, dist); + } } else { @@ -1143,7 +1209,9 @@ int BRepBlend_Walking::ArcToRecadre(const bool OnFirst, ok = okinter = BRepBlend_BlendTool::Inters(pt2d, lastpt2d, surf2, Iter->Value(), prm, dist); } if (!ok) + { ok = BRepBlend_BlendTool::Project(pt2d, surf2, Iter->Value(), prm, dist); + } } if (ok && (nbarc != PrevIndex)) { @@ -1153,7 +1221,9 @@ int BRepBlend_Walking::ArcToRecadre(const bool OnFirst, ponarc = prm; IndexSol = nbarc; if (okinter && (PrevIndex == 0)) + { break; + } } } Iter->Next(); @@ -1186,9 +1256,13 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, occ::handle Iter; if (OnFirst) + { Iter = recdomain1; + } else + { Iter = recdomain2; + } Indexsol = ArcToRecadre(OnFirst, theSol, 0, lastpt2d, pt2d, pmin); IsVtx = false; @@ -1268,7 +1342,9 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, Cherche = false; // Ne marche que si l'on sort simultanement } else + { Cherche = t < t2; // On s'arrete si t>=t2; + } } } if (!jalons_Trouve) @@ -1292,9 +1368,13 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, lambda = Pnt.Distance(lastpt2d); if (lambda > 1.e-12) + { lambda /= Pnt.Distance(lastpt2d) + Pnt.Distance(pt2d); + } else + { lambda = 0; + } solrst(1) = pmin; solrst(2) = (1 - lambda) * lastParam + lambda * param; solrst(3) = (1 - lambda) * Pnt1.X() + lambda * Pnt2.X(); @@ -1342,9 +1422,13 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, { occ::handle surf; if (OnFirst) + { surf = surf2; + } else + { surf = surf1; + } lastpt2d = thecur->Value(pmin); @@ -1352,17 +1436,25 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, { uperiod = surf->UPeriod(); if (solrst(3) - lastpt2d.X() > uperiod * 0.6) + { solrst(3) -= uperiod; + } if (solrst(3) - lastpt2d.X() < -uperiod * 0.6) + { solrst(3) += uperiod; + } } if (surf->IsVPeriodic()) { vperiod = surf->VPeriod(); if (solrst(4) - lastpt2d.Y() > vperiod * 0.6) + { solrst(4) -= vperiod; + } if (solrst(4) - lastpt2d.Y() < -vperiod * 0.6) + { solrst(4) += vperiod; + } } } @@ -1391,9 +1483,13 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, ok = BRepBlend_BlendTool::Project(pt2d, surf2, thearc, prm, distaux); } if (ok && (pt2d.Distance(thecur->Value(prm)) < dist)) + { solrst(1) = prm; + } else + { solrst(1) = pmin; + } } // On verifie le jalon jalons_Trouve = (FuncInv.IsSolution(solrst, tolpoint3d)); @@ -1490,7 +1586,9 @@ bool BRepBlend_Walking::Recadre(Blend_FuncInv& FuncInv, Vtx = Iter->Vertex(); vtol = 0.4 * std::abs(ulast - ufirst); // Un majorant de la tolerance if (vtol > std::max(BRepBlend_BlendTool::Tolerance(Vtx, thearc), toler(1))) + { vtol = std::max(BRepBlend_BlendTool::Tolerance(Vtx, thearc), toler(1)); + } if (std::abs(BRepBlend_BlendTool::Parameter(Vtx, thearc) - solrst(1)) <= vtol) { IsVtx = true; // On est dans la boule du vertex ou @@ -1524,7 +1622,9 @@ void BRepBlend_Walking::Transition(const bool OnFirst if (previousP.IsTangencyPoint()) { if (line->NbPoints() < 2) + { return; + } computetranstionaveclacorde = true; if (sens < 0) { @@ -1548,31 +1648,45 @@ void BRepBlend_Walking::Transition(const bool OnFirst { Adaptor3d_HSurfaceTool::D1(surf1, p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnS1(); + } else + { tgline = gp_Vec(prevprev.PointOnS1(), previousP.PointOnS1()); + } } else { Adaptor3d_HSurfaceTool::D1(surf2, p2d.X(), p2d.Y(), pbid, d1u, d1v); if (!computetranstionaveclacorde) + { tgline = previousP.TangentOnS2(); + } else + { tgline = gp_Vec(prevprev.PointOnS2(), previousP.PointOnS2()); + } } tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v); CSLib::Normal(d1u, d1v, 1.e-9, stat, thenormal); if (stat == CSLib_Defined) + { normale.SetXYZ(thenormal.XYZ()); + } else { occ::handle surf; if (OnFirst) + { surf = surf1; + } else + { surf = surf2; + } int iu, iv; NCollection_Array2 Der(0, 2, 0, 2); Adaptor3d_HSurfaceTool::D2(surf, @@ -1625,14 +1739,18 @@ void BRepBlend_Walking::MakeExtremity(BRepBlend_Extremity& Extr { Extrem.SetValue(previousP.PointOnS1(), sol(1), sol(2), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnS1()); + } Iter = recdomain1; } else { Extrem.SetValue(previousP.PointOnS2(), sol(3), sol(4), previousP.Parameter(), tolpoint3d); if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnS2()); + } Iter = recdomain2; } @@ -1648,7 +1766,9 @@ void BRepBlend_Walking::MakeExtremity(BRepBlend_Extremity& Extr Transition(OnFirst, Iter->Value(), Param, Tline, Tarc); Extrem.AddArc(Iter->Value(), Param, Tline, Tarc); if (IsVtx) + { Extrem.SetVertex(Vtx); + } } void BRepBlend_Walking::MakeSingularExtremity(BRepBlend_Extremity& Extrem, @@ -1663,12 +1783,16 @@ void BRepBlend_Walking::MakeSingularExtremity(BRepBlend_Extremity& { Iter = recdomain1; if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnS1()); + } } else { if (!previousP.IsTangencyPoint()) + { Extrem.SetTangent(previousP.TangentOnS2()); + } Iter = recdomain2; } @@ -1706,13 +1830,17 @@ static void RecadreIfPeriodic(double& NewU, { double sign = (NewU < OldU) ? 1 : -1; while (std::abs(NewU - OldU) > UPeriod / 2) + { NewU += sign * UPeriod; + } } if (VPeriod > 0.) { double sign = (NewV < OldV) ? 1 : -1; while (std::abs(NewV - OldV) > VPeriod / 2) + { NewV += sign * VPeriod; + } } } @@ -1745,18 +1873,26 @@ static void evalpinit(math_Vector& parinit, if (classonS1) { if ((u1 < infbound(1)) || (u1 > supbound(1))) + { Inside = false; + } if ((v1 < infbound(2)) || (v1 > supbound(2))) + { Inside = false; + } } u2 += step * du2; v2 += step * dv2; if (classonS2) { if ((u2 < infbound(3)) || (u2 > supbound(3))) + { Inside = false; + } if ((v2 < infbound(4)) || (v2 > supbound(4))) + { Inside = false; + } } if (Inside) @@ -1844,10 +1980,14 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, hguide->D1(param, PtOnGuide, TgOnGuide); // Check deflection on guide Cosi = PrevTgOnGuide * TgOnGuide; - if (Cosi < gp::Resolution()) // angle>=pi/2 or null magnitude + if (Cosi < gp::Resolution()) + { // angle>=pi/2 or null magnitude Cosi2 = 0.; + } else + { Cosi2 = Cosi * Cosi / PrevTgOnGuide.SquareMagnitude() / TgOnGuide.SquareMagnitude(); + } if (Cosi2 < CosRef3D) // angle 3d too great { State = Blend_StepTooLarge; @@ -1883,15 +2023,23 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, rsnld.Root(sol); if (clasonS1) + { situ1 = domain1->Classify(gp_Pnt2d(sol(1), sol(2)), std::min(tolerance(1), tolerance(2)), false); + } else + { situ1 = TopAbs_IN; + } if (clasonS2) + { situ2 = domain2->Classify(gp_Pnt2d(sol(3), sol(4)), std::min(tolerance(3), tolerance(4)), false); + } else + { situ2 = TopAbs_IN; + } } if (bonpoint && line->NbPoints() == 1 && (situ1 != TopAbs_IN || situ2 != TopAbs_IN)) { @@ -2017,7 +2165,9 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, } if (recad1 || recad2) + { echecrecad = false; + } if (!echecrecad) { @@ -2058,29 +2208,41 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, hguide->D1(SavedParams[ind], Pnt0, Dir0); double Length = Dir0.Magnitude(); if (Length <= gp::Resolution()) + { continue; + } Dir0 /= Length; gce_MakePln PlaneBuilder(Pnt0, Pnt1, Pnt2); if (!PlaneBuilder.IsDone()) + { continue; + } gp_Pln thePlane = PlaneBuilder.Value(); gp_Dir DirPlane = thePlane.Axis().Direction(); gp_Vec theProd = Dir0 ^ DirPlane; double ProdMod = theProd.Magnitude(); if (ProdMod <= TolProd) + { SameDirs[ind] = true; + } } } double theParam = Precision::Infinite(); // Choose the closest parameter if (SameDirs[0] && SameDirs[1]) + { theParam = (std::abs(param - SavedParams[0]) < std::abs(param - SavedParams[1])) ? SavedParams[0] : SavedParams[1]; + } else if (SameDirs[0]) + { theParam = SavedParams[0]; + } else if (SameDirs[1]) + { theParam = SavedParams[1]; + } double NewU, NewV, NewParam; gp_Pnt NewPnt; @@ -2089,11 +2251,15 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, if (Corrected) { if (std::abs(param - NewParam) < std::abs(param - theParam)) + { theParam = NewParam; + } } if (!Precision::IsInfinite(theParam)) + { param = theParam; + } } else if (recad1) { @@ -2193,8 +2359,10 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, // Ou bien le pas max est mal regle. On divise. // if(line->NbPoints() == 1) State = Blend_StepTooLarge; if (stepw > 2 * tolgui) + { State = Blend_StepTooLarge; - // Sinon echec recadrage. On sort avec PointsConfondus + // Sinon echec recadrage. On sort avec PointsConfondus + } else { #ifdef OCCT_DEBUG @@ -2333,7 +2501,9 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, { Ext2.SetValue(previousP.PointOnS1(), sol(3), sol(4), tolpoint3d); if (Isvtx1) + { MakeSingularExtremity(Ext2, false, Vtx1); + } } else { @@ -2358,7 +2528,9 @@ void BRepBlend_Walking::InternalPerform(Blend_Function& Func, { Ext1.SetValue(previousP.PointOnS2(), sol(1), sol(2), tolpoint3d); if (Isvtx2) + { MakeSingularExtremity(Ext1, true, Vtx2); + } } else { @@ -2448,7 +2620,9 @@ bool BRepBlend_Walking::CorrectExtremityOnOneRst(const int IndexOfRst, ChFiDS_ElSpine& theElSpine = *hguide; if (theElSpine.NbVertices() == 0) + { return false; + } occ::handle DomainOfRst = (IndexOfRst == 1) ? recdomain1 : recdomain2; occ::handle SurfOfRst = (IndexOfRst == 1) ? surf1 : surf2; @@ -2468,7 +2642,9 @@ bool BRepBlend_Walking::CorrectExtremityOnOneRst(const int IndexOfRst, gp_Pnt PntOnEnd = Adaptor3d_HSurfaceTool::Value(SurfOfRst, P2dOnEnd.X(), P2dOnEnd.Y()); Extrema_ExtPC projoncurv(PntOnEnd, theElSpine); if (!projoncurv.IsDone()) + { continue; + } double MinSqDist = Precision::Infinite(); int imin = 0; for (int ind = 1; ind <= projoncurv.NbExt(); ind++) @@ -2493,7 +2669,9 @@ bool BRepBlend_Walking::CorrectExtremityOnOneRst(const int IndexOfRst, double Period = hguide->Period(); double sign = (NewParam < theParam) ? 1 : -1; while (std::abs(NewParam - theParam) > Period / 2) + { NewParam += sign * Period; + } } // Second we find right point and tangent on guide @@ -2517,14 +2695,20 @@ bool BRepBlend_Walking::CorrectExtremityOnOneRst(const int IndexOfRst, gp_Pnt PntOnSurf2 = Adaptor3d_HSurfaceTool::Value(AnotherSurf, theU, theV); // old point gce_MakePln PlaneBuilder(thePntOnRst, OldPonGuide, PntOnSurf2); if (!PlaneBuilder.IsDone()) + { return false; + } gp_Pln OldPlane = PlaneBuilder.Value(); gp_Dir OldDir = OldPlane.Axis().Direction(); double Angle = OldDir.Angle(Dir0); if (Angle > M_PI / 2) + { Angle = M_PI - Angle; + } if (Angle > TolAng) + { return false; + } /////////////////////////////////////// // Project the point(theU,theV) on the plane(Pnt0,Dir0) gp_Vec aVec(Pnt0, PntOnSurf2); @@ -2534,14 +2718,20 @@ bool BRepBlend_Walking::CorrectExtremityOnOneRst(const int IndexOfRst, // Check new point again: does point on restriction belong to the plane? PlaneBuilder = gce_MakePln(thePntOnRst, Pnt0, PntOnPlane); if (!PlaneBuilder.IsDone()) + { return false; + } gp_Pln NewPlane = PlaneBuilder.Value(); const gp_Dir& DirOfNewPlane = NewPlane.Axis().Direction(); Angle = Dir0.Angle(DirOfNewPlane); if (Angle > M_PI / 2) + { Angle = M_PI - Angle; + } if (Angle > TolAng) + { return false; + } //////////////////////////////////////////////////////////////////////// // Project the point on the surface 2 diff --git a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeChamfer.cxx b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeChamfer.cxx index 0878e18254..2bdd343f30 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeChamfer.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeChamfer.cxx @@ -131,7 +131,9 @@ bool BRepFilletAPI_MakeChamfer::IsSymetric(const int IC) const bool ret = false; if (ChamfMeth == ChFiDS_Sym) + { ret = true; + } return ret; } @@ -144,7 +146,9 @@ bool BRepFilletAPI_MakeChamfer::IsTwoDistances(const int IC) const bool ret = false; if (ChamfMeth == ChFiDS_TwoDist) + { ret = true; + } return ret; } @@ -157,7 +161,9 @@ bool BRepFilletAPI_MakeChamfer::IsDistanceAngle(const int IC) const bool ret = false; if (ChamfMeth == ChFiDS_DistAngle) + { ret = true; + } return ret; } diff --git a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet.cxx b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet.cxx index d4c5c0aea4..f192eb5fad 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet.cxx @@ -71,7 +71,9 @@ void BRepFilletAPI_MakeFillet::Add(const double Radius, const TopoDS_Edge& E) int IinC; int IC = myBuilder.Contains(E, IinC); if (IC) + { SetRadius(Radius, IC, IinC); + } } //================================================================================================= @@ -82,7 +84,9 @@ void BRepFilletAPI_MakeFillet::Add(const double R1, const double R2, const TopoD int IinC; int IC = myBuilder.Contains(E, IinC); if (IC) + { SetRadius(R1, R2, IC, IinC); + } } //================================================================================================= @@ -94,7 +98,9 @@ void BRepFilletAPI_MakeFillet::Add(const occ::handle& L, const Top int IinC; int IC = myBuilder.Contains(E, IinC); if (IC) + { SetRadius(L, IC, IinC); + } } //================================================================================================= @@ -105,7 +111,9 @@ void BRepFilletAPI_MakeFillet::Add(const NCollection_Array1& UandR, co int IinC; int IC = myBuilder.Contains(E, IinC); if (IC) + { SetRadius(UandR, IC, IinC); + } } //================================================================================================= @@ -127,7 +135,9 @@ void BRepFilletAPI_MakeFillet::SetRadius(const double R1, double r1, r2; if (std::abs(R1 - R2) < Precision::Confusion()) + { r1 = r2 = (R1 + R2) * 0.5; + } else { r1 = R1; @@ -154,9 +164,13 @@ void BRepFilletAPI_MakeFillet::SetRadius(const NCollection_Array1& Uan const int IinC) { if (UandR.Length() == 1) + { SetRadius(UandR(UandR.Lower()).Y(), IC, IinC); + } else if (UandR.Length() == 2) + { SetRadius(UandR(UandR.Lower()).Y(), UandR(UandR.Upper()).Y(), IC, IinC); + } else { double Uf = UandR(UandR.Lower()).X(); diff --git a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet2d.cxx b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet2d.cxx index 8757445856..54bf9f29b7 100644 --- a/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet2d.cxx +++ b/src/ModelingAlgorithms/TKFillet/BRepFilletAPI/BRepFilletAPI_MakeFillet2d.cxx @@ -132,7 +132,9 @@ void BRepFilletAPI_MakeFillet2d::Build(const Message_ProgressRange& /*theRange*/ myShape = myMakeChFi2d.Result(); } else + { NotDone(); + } } //================================================================================================= @@ -157,9 +159,13 @@ const NCollection_List& BRepFilletAPI_MakeFillet2d::NewEdges(const { myGenerated.Clear(); if (I <= NbFillet()) + { myGenerated.Append(FilletEdges()(I)); + } else + { myGenerated.Append(ChamferEdges()(I - NbFillet())); + } return myGenerated; } diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc.cxx index 6fc49a83c4..309541d81e 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc.cxx @@ -165,15 +165,25 @@ bool BlendFunc::ComputeNormal(const occ::handle& Surf, NCollection_Array2 DerSurf(0, MaxOrder + 1, 0, MaxOrder + 1); for (i = 1; i <= MaxOrder + 1; i++) + { DerSurf.SetValue(i, 0, Surf->DN(U, V, i, 0)); + } for (i = 0; i <= MaxOrder + 1; i++) + { for (j = 1; j <= MaxOrder + 1; j++) + { DerSurf.SetValue(i, j, Surf->DN(U, V, i, j)); + } + } NCollection_Array2 DerNUV(0, MaxOrder, 0, MaxOrder); for (i = 0; i <= MaxOrder; i++) + { for (j = 0; j <= MaxOrder; j++) + { DerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurf)); + } + } gp_Dir thenormal; CSLib_NormalStatus stat; @@ -219,15 +229,25 @@ bool BlendFunc::ComputeDNormal(const occ::handle& Surf, NCollection_Array2 DerSurf(0, MaxOrder + 1, 0, MaxOrder + 1); for (i = 1; i <= MaxOrder + 1; i++) + { DerSurf.SetValue(i, 0, Surf->DN(U, V, i, 0)); + } for (i = 0; i <= MaxOrder + 1; i++) + { for (j = 1; j <= MaxOrder + 1; j++) + { DerSurf.SetValue(i, j, Surf->DN(U, V, i, j)); + } + } NCollection_Array2 DerNUV(0, MaxOrder, 0, MaxOrder); for (i = 0; i <= MaxOrder; i++) + { for (j = 0; j <= MaxOrder; j++) + { DerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurf)); + } + } gp_Dir thenormal; CSLib_NormalStatus stat; diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSCircular.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSCircular.cxx index 02f137837d..4ad1b2f66f 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSCircular.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSCircular.cxx @@ -215,7 +215,9 @@ bool BlendFunc_CSCircular::IsSolution(const math_Vector& Sol, const double Tol) // mise a jour de maxang if (ray > 0.) + { ns.Reverse(); + } nc = -resul.Normalized(); Cosa = ns.Dot(nc); @@ -433,7 +435,9 @@ bool BlendFunc_CSCircular::IsTangencyPoint() const const gp_Vec& BlendFunc_CSCircular::TangentOnS() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSCircular::TangentOnS"); + } return tgs; } @@ -442,7 +446,9 @@ const gp_Vec& BlendFunc_CSCircular::TangentOnS() const const gp_Vec& BlendFunc_CSCircular::TangentOnC() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSCircular::TangentOnC"); + } return tgc; } @@ -451,7 +457,9 @@ const gp_Vec& BlendFunc_CSCircular::TangentOnC() const const gp_Vec2d& BlendFunc_CSCircular::Tangent2d() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSCircular::Tangent2d"); + } return tg2d; } @@ -467,10 +475,14 @@ void BlendFunc_CSCircular::Tangent(const double U, const double V, gp_Vec& TgS, const double norm = nplan.Crossed(ns).Magnitude(); ns.SetLinearForm(nplan.Dot(ns) / norm, nplan, -1. / norm, ns); if (ray > 0.) + { ns.Reverse(); + } TgS = nplan.Crossed(ns); if (choix % 2 == 1) + { TgS.Reverse(); + } } //================================================================================================= @@ -503,7 +515,9 @@ void BlendFunc_CSCircular::Section(const double Param, C.SetRadius(std::abs(ray)); if (ray > 0.) + { ns.Reverse(); + } if (choix % 2 == 0) { @@ -814,7 +828,9 @@ void BlendFunc_CSCircular::Section(const Blend_Point& P, ns2 = gp_Vec(Center, ptc).Normalized(); if (ray > 0.) + { ns.Reverse(); + } if (choix % 2 != 0) { diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSConstRad.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSConstRad.cxx index 975cd456f4..04af0aaff7 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSConstRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_CSConstRad.cxx @@ -413,7 +413,9 @@ bool BlendFunc_CSConstRad::IsTangencyPoint() const const gp_Vec& BlendFunc_CSConstRad::TangentOnS() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSConstRad::TangentOnS"); + } return tgs; } @@ -422,7 +424,9 @@ const gp_Vec& BlendFunc_CSConstRad::TangentOnS() const const gp_Vec& BlendFunc_CSConstRad::TangentOnC() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSConstRad::TangentOnC"); + } return tgc; } @@ -431,7 +435,9 @@ const gp_Vec& BlendFunc_CSConstRad::TangentOnC() const const gp_Vec2d& BlendFunc_CSConstRad::Tangent2d() const { if (istangent) + { throw Standard_DomainError("BlendFunc_CSConstRad::Tangent2d"); + } return tg2d; } @@ -452,7 +458,9 @@ void BlendFunc_CSConstRad::Tangent(const double U, const double V, gp_Vec& TgS, gp_Pnt Center(bid.XYZ() + ray * ns.XYZ()); TgS = nplan.Crossed(gp_Vec(Center, bid)); if (choix % 2 == 1) + { TgS.Reverse(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsym.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsym.cxx index a664661bc9..66e23ee860 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsym.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsym.cxx @@ -183,7 +183,9 @@ bool BlendFunc_ChAsym::IsSolution(const math_Vector& Sol, const double Tol) istangent = false; } else + { istangent = true; + } } if (!istangent) @@ -215,7 +217,9 @@ double BlendFunc_ChAsym::GetMinimalDistance() const bool BlendFunc_ChAsym::ComputeValues(const math_Vector& X, const int DegF, const int DegL) { if (DegF > DegL) + { return false; + } gp_Vec np, d1gui, d1u1, d1v1, d2u1, d2v1, d2uv1, d1u2, d1v2, Nsurf1; gp_Pnt ptgui; @@ -226,7 +230,9 @@ bool BlendFunc_ChAsym::ComputeValues(const math_Vector& X, const int DegF, const np = nplan; if (choix % 2 != 0) + { np.Reverse(); + } if ((DegF == 0) && (DegL == 0)) { @@ -353,7 +359,9 @@ bool BlendFunc_ChAsym::IsTangencyPoint() const const gp_Vec& BlendFunc_ChAsym::TangentOnS1() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::TangentOnS1"); + } return tg1; } @@ -362,7 +370,9 @@ const gp_Vec& BlendFunc_ChAsym::TangentOnS1() const const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS1() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::Tangent2dOnS1"); + } return tg12d; } @@ -371,7 +381,9 @@ const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS1() const const gp_Vec& BlendFunc_ChAsym::TangentOnS2() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::TangentOnS2"); + } return tg2; } @@ -380,7 +392,9 @@ const gp_Vec& BlendFunc_ChAsym::TangentOnS2() const const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS2() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::Tangent2dOnS2"); + } return tg22d; } @@ -389,7 +403,9 @@ const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS2() const bool BlendFunc_ChAsym::TwistOnS1() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::TwistOnS1"); + } return tg1.Dot(nplan) < 0.; } @@ -398,7 +414,9 @@ bool BlendFunc_ChAsym::TwistOnS1() const bool BlendFunc_ChAsym::TwistOnS2() const { if (istangent) + { throw Standard_DomainError("BlendFunc_ChAsym::TwistOnS2"); + } return tg2.Dot(nplan) < 0.; } @@ -442,15 +460,23 @@ void BlendFunc_ChAsym::Tangent(const double U1, } if ((choix == 4) || (choix == 7)) + { revL = true; + } if ((choix == 3) || (choix == 8)) + { revF = true; + } if (revF) + { TgF.Reverse(); + } if (revL) + { TgL.Reverse(); + } } //================================================================================================= @@ -667,7 +693,9 @@ bool BlendFunc_ChAsym::Section(const Blend_Point& P, istangent = false; } else + { istangent = true; + } } if (!istangent) diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsymInv.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsymInv.cxx index 2ffaff633e..3a7e708e9e 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsymInv.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ChAsymInv.cxx @@ -176,7 +176,9 @@ bool BlendFunc_ChAsymInv::IsSolution(const math_Vector& Sol, const double Tol) bool BlendFunc_ChAsymInv::ComputeValues(const math_Vector& X, const int DegF, const int DegL) { if (DegF > DegL) + { return false; + } gp_Vec nplan, dnplan, d1gui, d2gui, d1u1, d1v1, d2u1, d2v1, d2uv1, d1u2, d1v2; gp_Vec Nsurf1, tsurf1; @@ -192,7 +194,9 @@ bool BlendFunc_ChAsymInv::ComputeValues(const math_Vector& X, const int DegF, co nplan = d1gui.Normalized(); if (choix % 2 != 0) + { nplan.Reverse(); + } pt2d = csurf->Value(X(1)); if (first) diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Chamfer.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Chamfer.cxx index 974853e9dc..aeab88b4b4 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Chamfer.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Chamfer.cxx @@ -67,7 +67,9 @@ bool BlendFunc_Chamfer::IsSolution(const math_Vector& Sol, const double Tol) issol = issol && corde2.IsSolution(Sol2, Tol); tol = Tol; if (issol) + { distmin = std::min(distmin, corde1.PointOnS().Distance(corde2.PointOnS())); + } return issol; } @@ -215,14 +217,22 @@ void BlendFunc_Chamfer::Tangent(const double U1, revL = true; } if ((choix == 4) || (choix == 7)) + { revL = true; + } if ((choix == 3) || (choix == 8)) + { revF = true; + } if (revF) + { TgF.Reverse(); + } if (revL) + { TgL.Reverse(); + } } //======================================================================= diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ConstRad.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ConstRad.cxx index 2847db2560..9b099dbcc9 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ConstRad.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_ConstRad.cxx @@ -257,18 +257,26 @@ bool BlendFunc_ConstRad::ComputeValues(const math_Vector& X, // gp_Vec normal; gp_Pnt2d P(X(1), X(2)); if (Order == 0) + { BlendFunc::ComputeNormal(surf1, P, nsurf1); + } else + { BlendFunc::ComputeDNormal(surf1, P, nsurf1, dns1u1, dns1v1); + } } if (nsurf2.Magnitude() < Eps) { // gp_Vec normal; gp_Pnt2d P(X(3), X(4)); if (Order == 0) + { BlendFunc::ComputeNormal(surf2, P, nsurf2); + } else + { BlendFunc::ComputeDNormal(surf2, P, nsurf2, dns1u2, dns1v2); + } } } @@ -290,7 +298,9 @@ bool BlendFunc_ConstRad::ComputeValues(const math_Vector& X, invnorm2 = ncrossns2.Magnitude(); if (invnorm1 > Eps) + { invnorm1 = ((double)1) / invnorm1; + } else { invnorm1 = 1; // Unsatisfactory, but it is not necessary to crash @@ -299,7 +309,9 @@ bool BlendFunc_ConstRad::ComputeValues(const math_Vector& X, #endif } if (invnorm2 > Eps) + { invnorm2 = ((double)1) / invnorm2; + } else { invnorm2 = 1; // Unsatisfactory, but it is not necessary to crash @@ -920,9 +932,13 @@ bool BlendFunc_ConstRad::IsSolution(const math_Vector& Sol, const double Tol) if (Sina < 0.) { if (Cosa > 0.) + { Angle = -Angle; + } else + { Angle = 2. * M_PI - Angle; + } } // std::cout << "Angle : " < Eps) + { invnorm1 = ((double)1) / invnorm1; + } else { invnorm1 = 1; // Unsatisfactory, but it is not necessary to stop @@ -361,7 +371,9 @@ bool BlendFunc_EvolRad::ComputeValues(const math_Vector& X, #endif } if (invnorm2 > Eps) + { invnorm2 = ((double)1) / invnorm2; + } else { invnorm2 = 1; // Unsatisfactory, but it is not necessary to stop @@ -972,9 +984,13 @@ bool BlendFunc_EvolRad::IsSolution(const math_Vector& Sol, const double Tol) if (Sina < 0.) { if (Cosa > 0.) + { Angle = -Angle; + } else + { Angle = 2. * M_PI - Angle; + } } if (std::abs(Angle) > maxang) @@ -1072,9 +1088,13 @@ void BlendFunc_EvolRad::Tangent(const double U1, invnorm1 = nplan.Crossed(ns1).Magnitude(); if (invnorm1 < Eps) + { invnorm1 = 1; + } else + { invnorm1 = 1. / invnorm1; + } ns1.SetLinearForm(nplan.Dot(ns1) * invnorm1, nplan, -invnorm1, ns1); Center.SetXYZ(pts1.XYZ() + sg1 * ray * ns1.XYZ()); @@ -1167,7 +1187,9 @@ void BlendFunc_EvolRad::Section(const double Param, Pfin = ElCLib::Parameter(C, pts2); } if (Pfin < Precision::PConfusion()) + { Pfin += Precision::PConfusion(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_EvolRadInv.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_EvolRadInv.cxx index c4c05f6bcd..87a31227ed 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_EvolRadInv.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_EvolRadInv.cxx @@ -186,7 +186,9 @@ bool BlendFunc_EvolRadInv::Value(const math_Vector& X, math_Vector& F) if (ns1.Magnitude() < Eps) { if (first) + { BlendFunc::ComputeNormal(surf1, pt2d, ns1); + } else { gp_Pnt2d P(X(3), X(4)); @@ -198,7 +200,9 @@ bool BlendFunc_EvolRadInv::Value(const math_Vector& X, math_Vector& F) if (ns2.Magnitude() < Eps) { if (!first) + { BlendFunc::ComputeNormal(surf2, pt2d, ns2); + } else { gp_Pnt2d P(X(3), X(4)); @@ -298,7 +302,9 @@ bool BlendFunc_EvolRadInv::Values(const math_Vector& X, math_Vector& F, math_Mat if (ns1.Magnitude() < Eps) { if (first) + { BlendFunc::ComputeNormal(surf1, p2d, ns1); + } else { gp_Pnt2d P(X(3), X(4)); @@ -310,7 +316,9 @@ bool BlendFunc_EvolRadInv::Values(const math_Vector& X, math_Vector& F, math_Mat if (ns2.Magnitude() < Eps) { if (!first) + { BlendFunc::ComputeNormal(surf2, p2d, ns2); + } else { gp_Pnt2d P(X(3), X(4)); diff --git a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Ruled.cxx b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Ruled.cxx index 3c9571e93d..e771705999 100644 --- a/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Ruled.cxx +++ b/src/ModelingAlgorithms/TKFillet/BlendFunc/BlendFunc_Ruled.cxx @@ -433,28 +433,36 @@ bool BlendFunc_Ruled::IsTangencyPoint() const const gp_Vec& BlendFunc_Ruled::TangentOnS1() const { if (istangent) + { throw Standard_DomainError("BlendFunc_Ruled::TangentOnS1"); + } return tg1; } const gp_Vec& BlendFunc_Ruled::TangentOnS2() const { if (istangent) + { throw Standard_DomainError("BlendFunc_Ruled::TangentOnS2"); + } return tg2; } const gp_Vec2d& BlendFunc_Ruled::Tangent2dOnS1() const { if (istangent) + { throw Standard_DomainError("BlendFunc_Ruled::Tangent2dOnS1"); + } return tg12d; } const gp_Vec2d& BlendFunc_Ruled::Tangent2dOnS2() const { if (istangent) + { throw Standard_DomainError("BlendFunc_Ruled::Tangent2dOnS2"); + } return tg22d; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d.cxx index d8a44dc0d6..189a250983 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d.cxx @@ -66,19 +66,27 @@ ChFi2d_ConstructionError ChFi2d::FindConnectedEdges(const TopoDS_Face& F, iterator.Next(); } // if ... else + { return ChFi2d_ConnexionError; + } if (iterator.More()) { E2 = TopoDS::Edge(iterator.Value()); iterator.Next(); } // if ... else + { return ChFi2d_ConnexionError; + } if (iterator.More()) + { return ChFi2d_ConnexionError; + } } // if (isFind) else + { return ChFi2d_ConnexionError; + } return ChFi2d_IsDone; } // FindConnectedEdges diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_AnaFilletAlgo.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_AnaFilletAlgo.cxx index 0009101855..77d2334de7 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_AnaFilletAlgo.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_AnaFilletAlgo.cxx @@ -55,10 +55,14 @@ static bool isCW(const BRepAdaptor_Curve& AC) gp_Vec startv(center, start), endv(center, end), middlev(center, m); double middlea = startv.AngleWithRef(middlev, plane.Direction()); while (middlea < 0.0) + { middlea += 2.0 * M_PI; + } double enda = startv.AngleWithRef(endv, plane.Direction()); while (enda < 0.0) + { enda += 2.0 * M_PI; + } bool is_cw = middlea > enda; return is_cw; @@ -166,23 +170,33 @@ void ChFi2d_AnaFilletAlgo::Init(const TopoDS_Wire& theWire, const gp_Pln& thePla for (; itr.More(); itr.Next()) { if (e1.IsNull()) + { e1 = TopoDS::Edge(itr.Value()); + } else if (e2.IsNull()) + { e2 = TopoDS::Edge(itr.Value()); + } } if (e1.IsNull() || e2.IsNull()) + { throw Standard_TypeMismatch( "The algorithm expects a wire consisting of two linear or circular edges."); + } // Left neighbour. BRepAdaptor_Curve AC1(e1); if (AC1.GetType() != GeomAbs_Line && AC1.GetType() != GeomAbs_Circle) + { throw Standard_TypeMismatch("A segment or an arc of circle is expected."); + } TopoDS_Vertex v1, v2; TopExp::Vertices(e1, v1, v2, true); if (v1.IsNull() || v2.IsNull()) + { throw Standard_Failure("An infinite edge."); + } gp_Pnt P1 = BRep_Tool::Pnt(v1); gp_Pnt P2 = BRep_Tool::Pnt(v2); @@ -207,11 +221,15 @@ void ChFi2d_AnaFilletAlgo::Init(const TopoDS_Wire& theWire, const gp_Pln& thePla // Right neighbour. BRepAdaptor_Curve AC2(e2); if (AC2.GetType() != GeomAbs_Line && AC2.GetType() != GeomAbs_Circle) + { throw Standard_TypeMismatch("A segment or an arc of circle is expected."); + } TopExp::Vertices(e2, v1, v2, true); if (v1.IsNull() || v2.IsNull()) + { throw Standard_Failure("An infinite edge."); + } P1 = BRep_Tool::Pnt(v1); P2 = BRep_Tool::Pnt(v2); @@ -246,7 +264,9 @@ void ChFi2d_AnaFilletAlgo::Init(const TopoDS_Edge& theEdge1, TopExp::Vertices(theEdge1, v11, v12, true); TopExp::Vertices(theEdge2, v21, v22, true); if (v11.IsNull() || v12.IsNull() || v21.IsNull() || v22.IsNull()) + { throw Standard_Failure("An infinite edge."); + } gp_Pnt p11 = BRep_Tool::Pnt(v11); gp_Pnt p12 = BRep_Tool::Pnt(v12); @@ -263,27 +283,43 @@ void ChFi2d_AnaFilletAlgo::Init(const TopoDS_Edge& theEdge1, pcommon = p12; } else + { throw Standard_Failure("The edges have no common point."); + } // Reverse the edges in case of need (to construct a wire). bool is1stReversed(false), is2ndReversed(false); if (IsEqual(pcommon, p11)) + { is1stReversed = true; + } else if (IsEqual(pcommon, p22)) + { is2ndReversed = true; + } // Make a wire. BRepBuilderAPI_MakeWire mkWire; if (is1stReversed) + { mkWire.Add(TopoDS::Edge(theEdge1.Reversed())); + } else + { mkWire.Add(theEdge1); + } if (is2ndReversed) + { mkWire.Add(TopoDS::Edge(theEdge2.Reversed())); + } else + { mkWire.Add(theEdge2); + } if (!mkWire.IsDone()) + { throw Standard_Failure("Can't make a wire."); + } const TopoDS_Wire& W = mkWire.Wire(); Init(W, thePlane); @@ -352,11 +388,15 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) } if (!bRet) + { return false; + } // Invert the fillet for left-handed plane. if (!plane.Position().Direct()) + { cw = !cw; + } // Construct a fillet. // Make circle. @@ -396,7 +436,9 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) { // Invert the fillet for left-handed planes. if (!plane.Position().Direct()) + { cw = !cw; + } // Make the circle again. center = ElSLib::Value(xc, yc, plane); @@ -424,9 +466,13 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) else { if (e1.Orientation() == TopAbs_FORWARD) + { pstart = AC1.Value(AC1.LastParameter() - start); + } else + { pstart = AC1.Value(AC1.FirstParameter() + start); + } } // end: (xend, yend) -> pend. gp_Pnt pend; @@ -437,9 +483,13 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) else { if (e2.Orientation() == TopAbs_FORWARD) + { pend = AC2.Value(AC2.FirstParameter() + end); + } else + { pend = AC2.Value(AC2.LastParameter() - end); + } } // Make arc. @@ -468,14 +518,18 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) BRepBuilderAPI_MakeEdge mkSegment1; mkSegment1.Init(AC1.Curve().Curve(), p1, p2); if (mkSegment1.IsDone()) + { shrinke1 = mkSegment1.Edge(); + } } else { BRepBuilderAPI_MakeEdge mkCirc1; mkCirc1.Init(AC1.Curve().Curve(), p1, p2); if (mkCirc1.IsDone()) + { shrinke1 = mkCirc1.Edge(); + } } // Right neighbour. @@ -495,14 +549,18 @@ bool ChFi2d_AnaFilletAlgo::Perform(const double radius) BRepBuilderAPI_MakeEdge mkSegment2; mkSegment2.Init(AC2.Curve().Curve(), p1, p2); if (mkSegment2.IsDone()) + { shrinke2 = mkSegment2.Edge(); + } } else { BRepBuilderAPI_MakeEdge mkCirc2; mkCirc2.Init(AC2.Curve().Curve(), p1, p2); if (mkCirc2.IsDone()) + { shrinke2 = mkCirc2.Edge(); + } } bRet = !shrinke1.IsNull() && !shrinke2.IsNull(); @@ -555,7 +613,9 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletSegment(const double radius, // Check bisectrissa. if (bisec.SquareMagnitude() < Precision::SquareConfusion()) + { return false; + } // Normalize the bisectrissa. bisec.Normalize(); @@ -599,7 +659,9 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletArc(const double radius, // Check length of segment. if (p11.SquareDistance(p12) < gp::Resolution()) + { return false; + } // Make 2D vectors. gp_Vec2d v1(p12, p11); @@ -607,15 +669,21 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletArc(const double radius, // Rotate the arc vector to become tangential at p21. if (cw2) + { v2.Rotate(+M_PI_2); + } else + { v2.Rotate(-M_PI_2); + } // If vectors coincide (segment and arc are tangent), // the algorithm doesn't work... double angle = v1.Angle(v2); if (fabs(angle) < Precision::Angular()) + { return false; + } // Make a bissectrisa of vectors at p12. v2.Normalize(); @@ -625,7 +693,9 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletArc(const double radius, // If segment and arc look in opposite direction, // no fillet is possible. if (bisec.SquareMagnitude() < gp::Resolution()) + { return false; + } // Define an appropriate point to choose center of fillet. bisec.Normalize(); @@ -639,18 +709,24 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletArc(const double radius, d1.Rotate(M_PI_2); line.Translate(radius * d1); if (line.Distance(nearp) > radius) + { line.Translate(-2.0 * radius * d1); + } // Make a circle of radius of the arc +/- fillet radius. gp_Ax2d axes(pc2, gp::DX2d()); gp_Circ2d circ(axes, radius2 + radius); if (radius2 > radius && circ.Distance(nearp) > radius) + { circ.SetRadius(radius2 - radius); + } // Calculate intersection of the line and the circle. IntAna2d_AnaIntersection intersector(line, circ); if (!intersector.IsDone() || !intersector.NbPoints()) + { return false; + } // Find center point of fillet. int i; @@ -686,7 +762,9 @@ bool ChFi2d_AnaFilletAlgo::SegmentFilletArc(const double radius, circ.SetRadius(radius2); intersector.Perform(line, circ); if (!intersector.IsDone() || !intersector.NbPoints()) + { return false; + } xend = DBL_MAX; yend = DBL_MAX; @@ -729,7 +807,9 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletSegment(const double radius, // Check length of segment. if (p12.SquareDistance(p22) < gp::Resolution()) + { return false; + } // Make 2D vectors. gp_Vec2d v1(p12, pc1); @@ -737,15 +817,21 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletSegment(const double radius, // Rotate the arc vector to become tangential at p21. if (cw1) + { v1.Rotate(-M_PI_2); + } else + { v1.Rotate(+M_PI_2); + } // If vectors coincide (segment and arc are tangent), // the algorithm doesn't work... double angle = v1.Angle(v2); if (fabs(angle) < Precision::Angular()) + { return false; + } // Make a bisectrissa of vectors at p12. v1.Normalize(); @@ -755,7 +841,9 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletSegment(const double radius, // If segment and arc look in opposite direction, // no fillet is possible. if (bisec.SquareMagnitude() < gp::Resolution()) + { return false; + } // Define an appropriate point to choose center of fillet. bisec.Normalize(); @@ -769,18 +857,24 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletSegment(const double radius, aD2Vec.Rotate(M_PI_2); line.Translate(radius * aD2Vec); if (line.Distance(nearPoint) > radius) + { line.Translate(-2.0 * radius * aD2Vec); + } // Make a circle of radius of the arc +/- fillet radius. gp_Ax2d axes(pc1, gp::DX2d()); gp_Circ2d circ(axes, radius1 + radius); if (radius1 > radius && circ.Distance(nearPoint) > radius) + { circ.SetRadius(radius1 - radius); + } // Calculate intersection of the line and the big circle. IntAna2d_AnaIntersection intersector(line, circ); if (!intersector.IsDone() || !intersector.NbPoints()) + { return false; + } // Find center point of fillet. int i; @@ -816,7 +910,9 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletSegment(const double radius, circ.SetRadius(radius1); intersector.Perform(line, circ); if (!intersector.IsDone() || !intersector.NbPoints()) + { return false; + } xstart = DBL_MAX; ystart = DBL_MAX; @@ -863,20 +959,30 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletArc(const double radius, // Rotate the vectors so that they are tangent to circles at p12. if (cw1) + { v1.Rotate(+M_PI_2); + } else + { v1.Rotate(-M_PI_2); + } if (cw2) + { v2.Rotate(-M_PI_2); + } else + { v2.Rotate(+M_PI_2); + } // Make a "check" point for choosing an offset circle. v1.Normalize(); v2.Normalize(); gp_Vec2d bisec = 0.5 * (v1 + v2); if (bisec.SquareMagnitude() < gp::Resolution()) + { return false; + } const gp_Pnt2d checkp = p12.Translated(radius * bisec); const gp_Lin2d checkl(p12, bisec); @@ -887,18 +993,24 @@ bool ChFi2d_AnaFilletAlgo::ArcFilletArc(const double radius, gp_Ax2d axes(pc1, gp::DX2d()); gp_Circ2d c1(axes, radius1 + radius); if (radius1 > radius && c1.Distance(checkp) > radius) + { c1.SetRadius(radius1 - radius); + } // Arc 2. axes.SetLocation(pc2); gp_Circ2d c2(axes, radius2 + radius); if (radius2 > radius && c2.Distance(checkp) > radius) + { c2.SetRadius(radius2 - radius); + } // Calculate an intersection point of these two circles // and choose the one closer to the "check" point. IntAna2d_AnaIntersection intersector(c1, c2); if (!intersector.IsDone() || !intersector.NbPoints()) + { return false; + } // Find center point of fillet. gp_Pnt2d pc; diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder.cxx index c27ccdeb3e..d643781ae2 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder.cxx @@ -88,7 +88,9 @@ ChFi2d_Builder::ChFi2d_Builder(const TopoDS_Face& F) status = ChFi2d_Ready; } else + { status = ChFi2d_NotPlanar; + } } // ChFi2d_Builder //================================================================================================= @@ -114,7 +116,9 @@ void ChFi2d_Builder::Init(const TopoDS_Face& F) status = ChFi2d_Ready; } else + { status = ChFi2d_NotPlanar; + } } // Init //================================================================================================= @@ -155,7 +159,9 @@ void ChFi2d_Builder::Init(const TopoDS_Face& RefFace, const TopoDS_Face& ModFace { const TopoDS_Edge& currentEdge = TopoDS::Edge(ex.Current()); if (!refEdgesMap.Contains(currentEdge)) + { newEdges.Append(currentEdge); + } ex.Next(); } // while (ex ... @@ -167,7 +173,9 @@ void ChFi2d_Builder::Init(const TopoDS_Face& RefFace, const TopoDS_Face& ModFace { const TopoDS_Edge& currentEdge = TopoDS::Edge(newEdges.Value(i)); if (IsIssuedFrom(currentEdge, refEdgesMap, basisEdge)) + { history.Bind(basisEdge, currentEdge); + } else { // this edge is a chamfer or a fillet @@ -238,7 +246,9 @@ TopoDS_Edge ChFi2d_Builder::AddFillet(const TopoDS_Vertex& V, const double Radiu TopoDS_Edge adjEdge1Mod, adjEdge2Mod, fillet; status = ChFi2d::FindConnectedEdges(newFace, V, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return fillet; + } if (IsAFillet(adjEdge1) || IsAChamfer(adjEdge1) || IsAFillet(adjEdge2) || IsAChamfer(adjEdge2)) { @@ -294,7 +304,9 @@ TopoDS_Vertex ChFi2d_Builder::RemoveFillet(const TopoDS_Edge& Fillet) i++; } if (!IsFind) + { return commonVertex; + } TopoDS_Vertex firstVertex, lastVertex; TopExp::Vertices(Fillet, firstVertex, lastVertex); @@ -302,23 +314,35 @@ TopoDS_Vertex ChFi2d_Builder::RemoveFillet(const TopoDS_Edge& Fillet) TopoDS_Edge adjEdge1, adjEdge2; status = ChFi2d::FindConnectedEdges(newFace, firstVertex, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return commonVertex; + } TopoDS_Edge basisEdge1, basisEdge2, E1, E2; // E1 and E2 are the adjacent edges to Fillet if (adjEdge1.IsSame(Fillet)) + { E1 = adjEdge2; + } else + { E1 = adjEdge1; + } basisEdge1 = BasisEdge(E1); status = ChFi2d::FindConnectedEdges(newFace, lastVertex, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return commonVertex; + } if (adjEdge1.IsSame(Fillet)) + { E2 = adjEdge2; + } else + { E2 = adjEdge1; + } basisEdge2 = BasisEdge(E2); TopoDS_Vertex connectionE1Fillet, connectionE2Fillet; bool hasConnection = ChFi2d::CommonVertex(basisEdge1, basisEdge2, commonVertex); @@ -350,14 +374,20 @@ TopoDS_Vertex ChFi2d_Builder::RemoveFillet(const TopoDS_Edge& Fillet) TopExp::Vertices(E1, firstVertex, lastVertex); TopExp::Vertices(basisEdge1, v1, v2); if (v1.IsSame(commonVertex)) + { v = v2; + } else + { v = v1; + } if (firstVertex.IsSame(v) || lastVertex.IsSame(v)) + { // It means the edge support only one fillet. In this case // the new edge must be the basis edge. newEdge1 = basisEdge1; + } else { // It means the edge support one fillet on each end. @@ -387,15 +417,21 @@ TopoDS_Vertex ChFi2d_Builder::RemoveFillet(const TopoDS_Edge& Fillet) TopExp::Vertices(basisEdge2, v1, v2); if (v1.IsSame(commonVertex)) + { v = v2; + } else + { v = v1; + } TopExp::Vertices(E2, firstVertex, lastVertex); if (firstVertex.IsSame(v) || lastVertex.IsSame(v)) + { // It means the edge support only one fillet. In this case // the new edge must be the basis edge. newEdge2 = basisEdge2; + } else { // It means the edge support one fillet on each end. @@ -434,13 +470,19 @@ TopoDS_Vertex ChFi2d_Builder::RemoveFillet(const TopoDS_Edge& Fillet) { const TopoDS_Edge& theEdge = TopoDS::Edge(Ex.Current()); if (!theEdge.IsSame(E1) && !theEdge.IsSame(E2) && !theEdge.IsSame(Fillet)) + { B.Add(newWire, theEdge); + } else { if (theEdge == E1) + { B.Add(newWire, newEdge1); + } else if (theEdge == E2) + { B.Add(newWire, newEdge2); + } } // else Ex.Next(); } // while ... @@ -468,15 +510,23 @@ void ChFi2d_Builder::ComputeFillet(const TopoDS_Vertex& V, bool Degen1, Degen2; Fillet = BuildFilletEdge(V, E1, E2, Radius, newExtr1, newExtr2); if (status != ChFi2d_IsDone) + { return; + } TrimE1 = BuildNewEdge(E1, V, newExtr1, Degen1); TrimE2 = BuildNewEdge(E2, V, newExtr2, Degen2); if (Degen1 && Degen2) + { status = ChFi2d_BothEdgesDegenerated; + } if (Degen1 && !Degen2) + { status = ChFi2d_FirstEdgeDegenerated; + } if (!Degen1 && Degen2) + { status = ChFi2d_LastEdgeDegenerated; + } } // ComputeFillet //================================================================================================= @@ -565,9 +615,13 @@ TopoDS_Edge ChFi2d_Builder::BuildNewEdge(const TopoDS_Edge& E1, // BRep_Tool::Curve(E1, first, last); occ::handle curve = BRep_Tool::Curve(E1, first, last); if (firstVertex.IsSame(OldExtr)) + { makeEdge.Init(curve, NewExtr, lastVertex); + } else + { makeEdge.Init(curve, firstVertex, NewExtr); + } TopoDS_Edge anEdge = makeEdge; anEdge.Orientation(E1.Orientation()); // anEdge.Location(E1.Location()); @@ -670,13 +724,21 @@ void ChFi2d_Builder::UpDateHistory(const TopoDS_Edge& E1, { if (history.IsBound(E1)) + { history.UnBind(E1); + } if (!E1.IsSame(TrimE1)) + { history.Bind(E1, TrimE1); + } if (history.IsBound(E2)) + { history.UnBind(E2); + } if (!E2.IsSame(TrimE2)) + { history.Bind(E2, TrimE2); + } } // UpDateHistory //================================================================================================= @@ -782,14 +844,22 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V, occ::handle basisC1, basisC2; occ::handle T1 = occ::down_cast(C1); if (!T1.IsNull()) + { basisC1 = T1->BasisCurve(); + } else + { basisC1 = C1; + } occ::handle T2 = occ::down_cast(C2); if (!T2.IsNull()) + { basisC2 = T2->BasisCurve(); + } else + { basisC2 = C2; + } if (basisC1->DynamicType() == STANDARD_TYPE(Geom2d_Circle)) { @@ -873,16 +943,24 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V, if (param1 > param2) { if (Sens2) + { Qual2 = GccEnt_outside; + } else + { Qual2 = GccEnt_enclosed; + } } else { if (Sens2) + { Qual2 = GccEnt_enclosed; + } else + { Qual2 = GccEnt_outside; + } } } // if (cross < 0 ... else @@ -890,30 +968,46 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V, if (param3 > param4) { if (Sens1) + { Qual1 = GccEnt_outside; + } else + { Qual1 = GccEnt_enclosed; + } } else { if (Sens1) + { Qual1 = GccEnt_enclosed; + } else + { Qual1 = GccEnt_outside; + } } if (param1 > param2) { if (Sens2) + { Qual2 = GccEnt_enclosed; + } else + { Qual2 = GccEnt_outside; + } } else { if (Sens2) + { Qual2 = GccEnt_outside; + } else + { Qual2 = GccEnt_enclosed; + } } } // else ... @@ -1144,7 +1238,9 @@ bool ChFi2d_Builder::IsAFillet(const TopoDS_Edge& E) const { const TopoDS_Edge& currentEdge = TopoDS::Edge(fillets.Value(i)); if (currentEdge.IsSame(E)) + { return true; + } i++; } return false; @@ -1159,7 +1255,9 @@ bool ChFi2d_Builder::IsAChamfer(const TopoDS_Edge& E) const { const TopoDS_Edge& currentEdge = TopoDS::Edge(chamfers.Value(i)); if (currentEdge.IsSame(E)) + { return true; + } i++; } return false; @@ -1178,9 +1276,13 @@ bool IsLineOrCircle(const TopoDS_Edge& E, const TopoDS_Face& F) occ::handle basisC; occ::handle TC = occ::down_cast(C); if (!TC.IsNull()) + { basisC = TC->BasisCurve(); + } else + { basisC = C; + } return basisC->DynamicType() == STANDARD_TYPE(Geom2d_Circle) || basisC->DynamicType() == STANDARD_TYPE(Geom2d_Line); // else ... diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder_0.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder_0.cxx index 9b8a9da7f5..3ba6b22dd9 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder_0.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_Builder_0.cxx @@ -79,7 +79,9 @@ TopoDS_Edge ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E1, bool hasConnection = ChFi2d::CommonVertex(E1, E2, commonVertex); if (!hasConnection) + { return chamfer; + } if (IsAFillet(E1) || IsAChamfer(E1) || IsAFillet(E2) || IsAChamfer(E2)) { @@ -130,7 +132,9 @@ TopoDS_Edge ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E, TopoDS_Edge aChamfer, adjEdge1, adjEdge2; status = ChFi2d::FindConnectedEdges(newFace, V, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return aChamfer; + } // adjEdge1 is a copy of E with the good orientation // on @@ -186,15 +190,23 @@ void ChFi2d_Builder::ComputeChamfer(const TopoDS_Vertex& V, bool Degen1, Degen2; Chamfer = BuildChamferEdge(V, E1, E2, D1, D2, newExtr1, newExtr2); if (status != ChFi2d_IsDone) + { return; + } TrimE1 = BuildNewEdge(E1, V, newExtr1, Degen1); TrimE2 = BuildNewEdge(E2, V, newExtr2, Degen2); if (Degen1 && Degen2) + { status = ChFi2d_BothEdgesDegenerated; + } if (Degen1 && !Degen2) + { status = ChFi2d_FirstEdgeDegenerated; + } if (!Degen1 && Degen2) + { status = ChFi2d_LastEdgeDegenerated; + } // TrimE1 = BuildNewEdge(E1, V, newExtr1); // TrimE2 = BuildNewEdge(E2, V, newExtr2); } // ComputeChamfer @@ -214,15 +226,23 @@ void ChFi2d_Builder::ComputeChamfer(const TopoDS_Vertex& V, bool Degen1, Degen2; Chamfer = BuildChamferEdge(V, E1, D, Ang, E2, newExtr1, newExtr2); if (status != ChFi2d_IsDone) + { return; + } TrimE1 = BuildNewEdge(E1, V, newExtr1, Degen1); TrimE2 = BuildNewEdge(E2, V, newExtr2, Degen2); if (Degen1 && Degen2) + { status = ChFi2d_BothEdgesDegenerated; + } if (Degen1 && !Degen2) + { status = ChFi2d_FirstEdgeDegenerated; + } if (!Degen1 && Degen2) + { status = ChFi2d_LastEdgeDegenerated; + } // TrimE1 = BuildNewEdge(E1, V, newExtr1); // TrimE2 = BuildNewEdge(E2, V, newExtr2); } // ComputeChamfer @@ -240,7 +260,9 @@ TopoDS_Edge ChFi2d_Builder::ModifyChamfer(const TopoDS_Edge& Chamfer, status = ChFi2d::FindConnectedEdges(newFace, aVertex, adjEdge1, adjEdge2); TopoDS_Edge aChamfer; if (status == ChFi2d_ConnexionError) + { return aChamfer; + } // adjEdge1 and adjEdge2 are copies of E1 and E2 with the good orientation // on @@ -268,12 +290,18 @@ TopoDS_Edge ChFi2d_Builder::ModifyChamfer(const TopoDS_Edge& Chamfer, status = ChFi2d::FindConnectedEdges(newFace, aVertex, adjEdge1, adjEdge2); TopoDS_Edge aChamfer; if (status == ChFi2d_ConnexionError) + { return aChamfer; + } if (adjEdge1.IsSame(E)) + { aChamfer = AddChamfer(adjEdge1, aVertex, D, Ang); + } else + { aChamfer = AddChamfer(adjEdge2, aVertex, D, Ang); + } return aChamfer; } // ModifyChamfer @@ -297,7 +325,9 @@ TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer) i++; } if (!IsFind) + { return commonVertex; + } TopoDS_Vertex firstVertex, lastVertex; TopExp::Vertices(Chamfer, firstVertex, lastVertex); @@ -305,23 +335,35 @@ TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer) TopoDS_Edge adjEdge1, adjEdge2; status = ChFi2d::FindConnectedEdges(newFace, firstVertex, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return commonVertex; + } TopoDS_Edge basisEdge1, basisEdge2, E1, E2; // E1 and E2 are the adjacentes edges to Chamfer if (adjEdge1.IsSame(Chamfer)) + { E1 = adjEdge2; + } else + { E1 = adjEdge1; + } basisEdge1 = BasisEdge(E1); status = ChFi2d::FindConnectedEdges(newFace, lastVertex, adjEdge1, adjEdge2); if (status == ChFi2d_ConnexionError) + { return commonVertex; + } if (adjEdge1.IsSame(Chamfer)) + { E2 = adjEdge2; + } else + { E2 = adjEdge1; + } basisEdge2 = BasisEdge(E2); TopoDS_Vertex connectionE1Chamfer, connectionE2Chamfer; bool hasConnection = ChFi2d::CommonVertex(basisEdge1, basisEdge2, commonVertex); @@ -353,14 +395,20 @@ TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer) TopExp::Vertices(E1, firstVertex, lastVertex); TopExp::Vertices(basisEdge1, v1, v2); if (v1.IsSame(commonVertex)) + { v = v2; + } else + { v = v1; + } if (firstVertex.IsSame(v) || lastVertex.IsSame(v)) + { // It means the edge support only one fillet. In this case // the new edge must be the basis edge. newEdge1 = basisEdge1; + } else { // It means the edge support one fillet on each end. @@ -390,15 +438,21 @@ TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer) TopExp::Vertices(basisEdge2, v1, v2); if (v1.IsSame(commonVertex)) + { v = v2; + } else + { v = v1; + } TopExp::Vertices(E2, firstVertex, lastVertex); if (firstVertex.IsSame(v) || lastVertex.IsSame(v)) + { // It means the edge support only one fillet. In this case // the new edge must be the basis edge. newEdge2 = basisEdge2; + } else { // It means the edge support one fillet on each end. @@ -437,13 +491,19 @@ TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer) { const TopoDS_Edge& theEdge = TopoDS::Edge(Ex.Current()); if (!theEdge.IsSame(E1) && !theEdge.IsSame(E2) && !theEdge.IsSame(Chamfer)) + { B.Add(newWire, theEdge); + } else { if (theEdge == E1) + { B.Add(newWire, newEdge1); + } else if (theEdge == E2) + { B.Add(newWire, newEdge2); + } } // else Ex.Next(); } // while ... @@ -505,16 +565,24 @@ TopoDS_Edge ChFi2d_Builder::BuildChamferEdge(const TopoDS_Vertex& V, TopoDS_Vertex V1 = TopExp::FirstVertex(AdjEdge1); TopoDS_Vertex V2 = TopExp::LastVertex(AdjEdge1); if (V1.IsSame(V)) + { NewExtr1.Orientation(V1.Orientation()); + } else + { NewExtr1.Orientation(V2.Orientation()); + } V1 = TopExp::FirstVertex(AdjEdge2); V2 = TopExp::LastVertex(AdjEdge2); if (V1.IsSame(V)) + { NewExtr2.Orientation(V1.Orientation()); + } else + { NewExtr2.Orientation(V2.Orientation()); + } B.UpdateVertex(NewExtr1, param1, AdjEdge1, tol); B.UpdateVertex(NewExtr2, param2, AdjEdge2, tol); @@ -562,11 +630,17 @@ TopoDS_Edge ChFi2d_Builder::BuildChamferEdge(const TopoDS_Vertex& V, TopExp::Vertices(AdjEdge2, v1, v2); TopAbs_Orientation orient; if (v1.IsSame(V)) + { orient = v1.Orientation(); + } else + { orient = v2.Orientation(); + } if (orient == TopAbs_REVERSED) + { tan *= -1; + } // compute the chamfer geometric support gp_Ax1 RotAxe(p1, tan ^ myVec); @@ -598,16 +672,24 @@ TopoDS_Edge ChFi2d_Builder::BuildChamferEdge(const TopoDS_Vertex& V, TopoDS_Vertex V1 = TopExp::FirstVertex(AdjEdge1); TopoDS_Vertex V2 = TopExp::LastVertex(AdjEdge1); if (V1.IsSame(V)) + { NewExtr1.Orientation(V1.Orientation()); + } else + { NewExtr1.Orientation(V2.Orientation()); + } V1 = TopExp::FirstVertex(AdjEdge2); V2 = TopExp::LastVertex(AdjEdge2); if (V1.IsSame(V)) + { NewExtr2.Orientation(V1.Orientation()); + } else + { NewExtr2.Orientation(V2.Orientation()); + } B.UpdateVertex(NewExtr1, param1, AdjEdge1, tol); B.UpdateVertex(NewExtr2, param2, AdjEdge2, tol); @@ -642,7 +724,9 @@ gp_Pnt ComputePoint(const TopoDS_Vertex& V, const TopoDS_Edge& E, const double D thePoint = p2.Translated(myVec); } // if (v2 ... else + { thePoint = p1.Translated(myVec); + } Param = ElCLib::Parameter(c.Line(), thePoint); // szv:OCC20823-begin @@ -670,9 +754,13 @@ gp_Pnt ComputePoint(const TopoDS_Vertex& V, const TopoDS_Edge& E, const double D } double deltaAlpha = D / radius; if (param1 > param2) + { Param = param1 - deltaAlpha; + } else + { Param = param1 + deltaAlpha; + } c.D0(Param, thePoint); return thePoint; } // if (C->IsKind(TYPE ... @@ -757,15 +845,23 @@ void OrientChamfer(TopoDS_Edge& chamfer, const TopoDS_Edge& E, const TopoDS_Vert TopoDS_Vertex v1, v2; TopExp::Vertices(E, v1, v2); if (v1.IsSame(V)) + { vOrient = v2.Orientation(); + } else + { vOrient = v1.Orientation(); + } if ((orient == TopAbs_FORWARD && vOrient == TopAbs_FORWARD) || (orient == TopAbs_REVERSED && vOrient == TopAbs_REVERSED)) + { chamfer.Orientation(TopAbs_FORWARD); + } else + { chamfer.Orientation(TopAbs_REVERSED); + } } // OrientChamfer //================================================================================================= @@ -781,9 +877,13 @@ bool IsLineOrCircle(const TopoDS_Edge& E, const TopoDS_Face& F) occ::handle basisC; occ::handle TC = occ::down_cast(C); if (!TC.IsNull()) + { basisC = TC->BasisCurve(); + } else + { basisC = C; + } return basisC->DynamicType() == STANDARD_TYPE(Geom2d_Circle) || basisC->DynamicType() == STANDARD_TYPE(Geom2d_Line); // else ... diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_ChamferAPI.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_ChamferAPI.cxx index b4ff59d65d..325ce1fcef 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_ChamferAPI.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_ChamferAPI.cxx @@ -64,11 +64,17 @@ void ChFi2d_ChamferAPI::Init(const TopoDS_Wire& theWire) for (; itr.More(); itr.Next()) { if (E1.IsNull()) + { E1 = TopoDS::Edge(itr.Value()); + } else if (E2.IsNull()) + { E2 = TopoDS::Edge(itr.Value()); + } else + { break; + } } Init(E1, E2); } @@ -124,9 +130,13 @@ TopoDS_Edge ChFi2d_ChamferAPI::Result(TopoDS_Edge& theEdge1, { TopoDS_Edge aResult; if (std::abs(myEnd1 - myStart1) < theLength1) + { return aResult; + } if (std::abs(myEnd2 - myStart2) < theLength2) + { return aResult; + } double aCommon1 = (myCommonStart1 ? myStart1 : myEnd1) + (((myStart1 > myEnd1) ^ myCommonStart1) ? theLength1 : -theLength1); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAPI.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAPI.cxx old mode 100755 new mode 100644 index 49a8a3bd6a..26e4f9d8dd --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAPI.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAPI.cxx @@ -51,14 +51,22 @@ void ChFi2d_FilletAPI::Init(const TopoDS_Wire& theWire, const gp_Pln& thePlane) for (; itr.More(); itr.Next()) { if (E1.IsNull()) + { E1 = TopoDS::Edge(itr.Value()); + } else if (E2.IsNull()) + { E2 = TopoDS::Edge(itr.Value()); + } else + { break; + } } if (!E1.IsNull() && !E2.IsNull()) + { myIsAnalytical = IsAnalytical(E1, E2); + } // Initialize the algorithm. myIsAnalytical ? myAnaFilletAlgo.Init(theWire, thePlane) : myFilletAlgo.Init(theWire, thePlane); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAlgo.cxx b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAlgo.cxx index ddd2a90a93..1cafd61bf1 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAlgo.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi2d/ChFi2d_FilletAlgo.cxx @@ -82,15 +82,23 @@ void ChFi2d_FilletAlgo::Init(const TopoDS_Wire& theWire, const gp_Pln& thePlane) for (; itr.More(); itr.Next()) { if (theEdge1.IsNull()) + { theEdge1 = TopoDS::Edge(itr.Value()); + } else if (theEdge2.IsNull()) + { theEdge2 = TopoDS::Edge(itr.Value()); + } else + { break; + } } if (theEdge1.IsNull() || theEdge2.IsNull()) + { throw Standard_ConstructionError( "The fillet algorithms expects a wire consisting of two edges."); + } Init(theEdge1, theEdge2, thePlane); } @@ -123,9 +131,13 @@ void ChFi2d_FilletAlgo::Init(const TopoDS_Edge& theEdge1, myCurve2 = GeomProjLib::Curve2d(aCurve2, myStart2, myEnd2, myPlane); while (myCurve1->IsPeriodic() && myStart1 >= myEnd1) + { myEnd1 += myCurve1->Period(); + } while (myCurve2->IsPeriodic() && myStart2 >= myEnd2) + { myEnd2 += myCurve2->Period(); + } if (aBAC1.GetType() == aBAC2.GetType()) { @@ -173,17 +185,25 @@ static bool IsRadiusIntersected(const occ::handle& theCurve, aPoint = anInter.Point(a); Geom2dAPI_ProjectPointOnCurve aProjInt(aPoint, theCurve, theCurveMin, theCurveMax); if (aProjInt.NbPoints() < 1 || aProjInt.LowerDistanceParameter() > Precision::Confusion()) + { continue; // point is not on edge + } if (aPoint.Distance(theStart) < Precision::Confusion()) { if (!theStartConnected) + { return true; + } } if (aPoint.Distance(theEnd) < Precision::Confusion()) + { return true; + } if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), Precision::Angular())) + { return true; + } } const occ::handle& aCurve = theCurve; for (a = anInter.NbSegments(); a > 0; a--) @@ -195,12 +215,20 @@ static bool IsRadiusIntersected(const occ::handle& theCurve, if (aProjInt.NbPoints() && aProjInt.LowerDistanceParameter() < Precision::Confusion()) { // point is on edge if (aPoint.Distance(theStart) < Precision::Confusion()) + { if (!theStartConnected) + { return true; + } + } if (aPoint.Distance(theEnd) < Precision::Confusion()) + { return true; + } if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), Precision::Angular())) + { return true; + } } aPoint = aCurve->Value(aCurve->LastParameter()); @@ -208,12 +236,20 @@ static bool IsRadiusIntersected(const occ::handle& theCurve, if (aProjInt.NbPoints() && aProjInt.LowerDistanceParameter() < Precision::Confusion()) { // point is on edge if (aPoint.Distance(theStart) < Precision::Confusion()) + { if (!theStartConnected) + { return true; + } + } if (aPoint.Distance(theEnd) < Precision::Confusion()) + { return true; + } if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), Precision::Angular())) + { return true; + } } } return false; @@ -228,16 +264,22 @@ void ChFi2d_FilletAlgo::FillPoint(FilletPoint* thePoint, const double theLimit) gp_Pnt2d aCenter, aPoint; // center of fillet and point on curve1 double aParam = thePoint->getParam(); if (theLimit < aParam) + { aStep = -aStep; + } for (aValid = false; !aValid; aParam += aStep) { if ((aParam - aStep - theLimit) * (aParam - theLimit) <= 0) + { break; // limit was exceeded + } aStep *= 2; gp_Vec2d aVec; myCurve1->D1(aParam, aPoint, aVec); if (aVec.SquareMagnitude() < Precision::Confusion()) + { continue; + } gp_Vec2d aPerp(((myStartSide) ? -1 : 1) * aVec.Y(), ((myStartSide) ? 1 : -1) * aVec.X()); aPerp.Normalize(); @@ -264,22 +306,30 @@ void ChFi2d_FilletAlgo::FillPoint(FilletPoint* thePoint, const double theLimit) for (a = aNB; a > 0; a--) { if (aPoint.SquareDistance(aProj.Point(a)) < Precision::Confusion()) + { continue; + } bool aValid2 = aValid; if (aValid2) + { aValid2 = !IsRadiusIntersected(myCurve1, myStart1, myEnd1, aCenter, aProj.Point(a), false); + } // checking the right parameter double aParamProj = aProj.Parameter(a); while (myCurve2->IsPeriodic() && aParamProj < myStart2) + { aParamProj += myCurve2->Period(); + } const double d = aProj.Distance(a); thePoint->appendValue(d * d - myRadius * myRadius, (aParamProj >= myStart2 && aParamProj <= myEnd2 && aValid2)); if (std::abs(d - myRadius) < Precision::Confusion()) + { thePoint->setParam2(aParamProj); + } } } @@ -456,7 +506,9 @@ void ChFi2d_FilletAlgo::PerformNewton(FilletPoint* theLeft, FilletPoint* theRigh { double aX0 = -aC / aB; // use extremum if (aX0 > theLeft->getParam() && aX0 < theRight->getParam()) + { ProcessPoint(theLeft, theRight, aX0); + } } else { @@ -481,22 +533,30 @@ void ChFi2d_FilletAlgo::PerformNewton(FilletPoint* theLeft, FilletPoint* theRigh aDet = sqrt(aDet); bool aRes = ProcessPoint(theLeft, theRight, (-aB + aDet) / aA); if (!aRes) + { aRes = ProcessPoint(theLeft, theRight, (-aB - aDet) / aA); + } if (!aRes) + { ProcessPoint(theLeft, theRight, theLeft->getParam() + aDX / 2.0); // linear division otherwise + } } else { // std::cout<<"%%%"< theLeft->getParam() && aX0 < theRight->getParam()) + { ProcessPoint(theLeft, theRight, aX0); + } else + { ProcessPoint(theLeft, theRight, theLeft->getParam() + aDX / 2.0); // linear division otherwise + } } } } @@ -520,7 +580,9 @@ int ChFi2d_FilletAlgo::NbResults(const gp_Pnt& thePoint) FilletPoint* aPoint = new FilletPoint(anIter.Value()); FillPoint(aPoint, anIter.Value() + 1.); if (aPoint->hasSolution(myRadius)) + { nb++; + } delete aPoint; } // for @@ -574,12 +636,16 @@ TopoDS_Edge ChFi2d_FilletAlgo::Result(const gp_Pnt& thePoint, delete aPoint; } if (iSolution == iSol) + { break; + } iSol++; } // for if (!aNearest) + { return aResult; + } // create circle edge gp_Pnt aCenter = ElSLib::PlaneValue(aNearest->getCenter().X(), @@ -613,7 +679,9 @@ TopoDS_Edge ChFi2d_FilletAlgo::Result(const gp_Pnt& thePoint, bool aIsOut = ((aParam1 < aTargetParam && aParam2 < aTargetParam) || (aParam1 > aTargetParam && aParam2 > aTargetParam)); if (aParam1 > aParam2) + { aIsOut = !aIsOut; + } BRepBuilderAPI_MakeEdge aBuilder(aCircle->Circ(), aIsOut ? aParam2 : aParam1, aIsOut ? aParam1 : aParam2); @@ -629,21 +697,31 @@ TopoDS_Edge ChFi2d_FilletAlgo::Result(const gp_Pnt& thePoint, aCircle->D1(aParam1, aPoint1, aCircleDir); if ((aCircleDir.Angle(aDir) > M_PI / 2.0) ? !aIsOut : aIsOut) + { aStart = aNearest->getParam(); + } else + { anEnd = aNearest->getParam(); + } // Check the case when start and end are identical. This happens // when the edge decreases to size 0. Old ww5 allows such // cases. So we are again bug compatible if (fabs(aStart - anEnd) < Precision::Confusion()) + { anEnd = aStart + Precision::Confusion(); + } // Divide edge BRepBuilderAPI_MakeEdge aDivider1(aCurve, aStart, anEnd); if (myEdgesExchnged) + { theEdge2 = aDivider1.Edge(); + } else + { theEdge1 = aDivider1.Edge(); + } aCurve = BRep_Tool::Curve(myEdge2, aStart, anEnd); aCurve->D1(aNearest->getParam2(), aPoint2, aDir); @@ -651,20 +729,30 @@ TopoDS_Edge ChFi2d_FilletAlgo::Result(const gp_Pnt& thePoint, aCircle->D1(aParam2, aPoint2, aCircleDir); if ((aCircleDir.Angle(aDir) > M_PI / 2.0) ? aIsOut : !aIsOut) + { aStart = aNearest->getParam2(); + } else + { anEnd = aNearest->getParam2(); + } // Check the case when start and end are identical. This happens // when the edge decreases to size 0. Old ww5 allows such // cases. So we are again bug compatible if (fabs(aStart - anEnd) < Precision::Confusion()) + { anEnd = aStart + Precision::Confusion(); + } BRepBuilderAPI_MakeEdge aDivider2(aCurve, aStart, anEnd); if (myEdgesExchnged) + { theEdge1 = aDivider2.Edge(); + } else + { theEdge2 = aDivider2.Edge(); + } delete aNearest; return aResult; @@ -703,9 +791,13 @@ bool FilletPoint::calculateDiff(FilletPoint* thePoint) { aDY = thePoint->myV.Value(a) - myV.Value(a); if (aDiffsSet) + { myD.SetValue(a, aDY / aDX); + } else + { myD.Append(aDY / aDX); + } } return true; } @@ -716,12 +808,16 @@ bool FilletPoint::calculateDiff(FilletPoint* thePoint) for (b = 1; b <= thePoint->myV.Length(); b++) { if (b == 1 || std::abs(thePoint->myV.Value(b) - myV.Value(a)) < std::abs(aDY)) + { aDY = thePoint->myV.Value(b) - myV.Value(a); + } } if (aDiffsSet) { if (std::abs(aDY / aDX) < std::abs(myD.Value(a))) + { myD.SetValue(a, aDY / aDX); + } } else { @@ -761,16 +857,20 @@ void FilletPoint::FilterPoints(FilletPoint* thePoint) if (myV.Value(a) * myD.Value(a) > 0) { if (std::abs(myD.Value(a)) > Precision::Confusion()) + { aNear = 0; + } } else { if (std::abs(myV.Value(a)) > std::abs(thePoint->myV.Value(aNear))) + { if (thePoint->myV.Value(aNear) * thePoint->myD.Value(aNear) < 0 && std::abs(thePoint->myD.Value(aNear)) > Precision::Confusion()) { aNear = 0; } + } } } } // if aNear @@ -861,7 +961,9 @@ int FilletPoint::hasSolution(const double theRadius) { if (std::abs(sqrt(std::abs(std::abs(myV.Value(a)) + theRadius * theRadius)) - theRadius) < Precision::Confusion()) + { return a; + } } return 0; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d.cxx index 9e1c1a9ef9..e76af29399 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d.cxx @@ -51,10 +51,14 @@ ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E, // For the case of seam edge TopoDS_Edge EE = E; if (F1.IsSame(F2)) + { EE.Reverse(); + } occ::handle C2 = BRep_Tool::CurveOnSurface(EE, F2, f, l); if (C1.IsNull() || C2.IsNull()) + { return ChFiDS_Other; + } BRepAdaptor_Curve C(E); f = C.FirstParameter(); @@ -77,27 +81,37 @@ ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E, T1.Reverse(); } if (F1.Orientation() == TopAbs_REVERSED) + { T1.Reverse(); + } gp_Pnt2d P = C1->Value(ParOnC); gp_Pnt P3; gp_Vec D1U, D1V; if (CorrectPoint) + { Correct2dPoint(F1, P); + } // S1->D1(P.X(), P.Y(), P3, D1U, D1V); gp_Vec DN1(D1U ^ D1V); if (F1.Orientation() == TopAbs_REVERSED) + { DN1.Reverse(); + } P = C2->Value(ParOnC); if (CorrectPoint) + { Correct2dPoint(F2, P); + } S2->D1(P.X(), P.Y(), P3, D1U, D1V); gp_Vec DN2(D1U ^ D1V); if (F2.Orientation() == TopAbs_REVERSED) + { DN2.Reverse(); + } DN1.Normalize(); DN2.Normalize(); @@ -124,7 +138,9 @@ ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E, else { if (NormProVec > gp::Resolution()) + { ProVec /= NormProVec; + } double Prod = T1.Dot(ProVec); if (Prod > 0.) { @@ -147,7 +163,9 @@ bool ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge, const GeomAbs_Shape theOrder) { if (theOrder == GeomAbs_G1 && BRep_Tool::Continuity(theEdge, theFace1, theFace2) != GeomAbs_C0) + { return true; + } double TolC0 = std::max(0.001, 1.5 * BRep_Tool::Tolerance(theEdge)); @@ -174,7 +192,9 @@ bool ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge, } } if (anEdgeInFace1.IsNull()) + { return false; + } aC2d1 = BRep_Tool::CurveOnSurface(anEdgeInFace1, aFace1, aFirst, aLast); TopoDS_Face aFace2 = theFace2; @@ -189,19 +209,25 @@ bool ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge, // For the case of seam edge TopoDS_Edge EE = theEdge; if (theFace1.IsSame(theFace2)) + { EE.Reverse(); + } aC2d2 = BRep_Tool::CurveOnSurface(EE, theFace2, aFirst, aLast); } if (aC2d1.IsNull() || aC2d2.IsNull()) + { return false; + } // Obtaining of two surfaces from adjacent faces. occ::handle aSurf1 = BRep_Tool::Surface(theFace1); occ::handle aSurf2 = BRep_Tool::Surface(theFace2); if (aSurf1.IsNull() || aSurf2.IsNull()) + { return false; + } // Computation of the number of samples on the edge. BRepAdaptor_Surface aBAS1(theFace1); @@ -222,14 +248,18 @@ bool ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge, for (i = 1, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta) { if (i == aNbSamples) + { aPar = aLast; + } LocalAnalysis_SurfaceContinuity aCont(aC2d1, aC2d2, aPar, aSurf1, aSurf2, theOrder, 0.001, TolC0, 0.1, 0.1, 0.1); if (!aCont.IsDone()) { if (theOrder == GeomAbs_C2 && aCont.StatusError() == LocalAnalysis_NullSecondDerivative) + { continue; + } nbNotDone++; continue; @@ -238,14 +268,20 @@ bool ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge, if (theOrder == GeomAbs_G1) { if (!aCont.IsG1()) + { return false; + } } else if (!aCont.IsG2()) + { return false; + } } if (nbNotDone == aNbSamples) + { return false; + } // Compare normals of tangent faces in the middle point double MidPar = (aFirst + aLast) / 2.; @@ -288,7 +324,9 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, tgE.Normalize(); tgE2 = tgE1 = tgE; if (E.Orientation() == TopAbs_REVERSED) + { tgE.Reverse(); + } TopoDS_Edge E1 = E, E2 = E; E1.Orientation(TopAbs_FORWARD); @@ -308,7 +346,9 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, if (E.IsSame(TopoDS::Edge(Exp.Current()))) { if (Exp.Current().Orientation() == TopAbs_REVERSED) + { tgE1.Reverse(); + } found = true; } } @@ -322,7 +362,9 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, if (E.IsSame(TopoDS::Edge(Exp.Current()))) { if (Exp.Current().Orientation() == TopAbs_REVERSED) + { tgE2.Reverse(); + } found = true; } } @@ -341,12 +383,16 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, ns1 = DU1.Crossed(DV1); ns1.Normalize(); if (F1.Orientation() == TopAbs_REVERSED) + { ns1.Reverse(); + } S2.D1(p2d2.X(), p2d2.Y(), pt2, DU2, DV2); ns2 = DU2.Crossed(DV2); ns2.Normalize(); if (F2.Orientation() == TopAbs_REVERSED) + { ns2.Reverse(); + } dint1 = ns1.Crossed(tgE1); dint2 = ns2.Crossed(tgE2); @@ -379,14 +425,18 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, ns1 = DU1.Crossed(DV1); ns1.Normalize(); if (F1.Orientation() == TopAbs_REVERSED) + { ns1.Reverse(); + } S2.D2(p2d2.X(), p2d2.Y(), pt2, DU2, DV2, DDU, DDV, DDUV); DU2 += (DU2 * dint2 < 0) ? -DDU : DDU; DV2 += (DV2 * dint2 < 0) ? -DDV : DDV; ns2 = DU2.Crossed(DV2); ns2.Normalize(); if (F2.Orientation() == TopAbs_REVERSED) + { ns2.Reverse(); + } dint1 = ns1.Crossed(tgE1); dint2 = ns2.Crossed(tgE2); @@ -432,11 +482,15 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, S1.D1(p2d1.X(), p2d1.Y(), pt1, DU1, DV1); ns1 = DU1.Crossed(DV1); if (F1.Orientation() == TopAbs_REVERSED) + { ns1.Reverse(); + } S2.D1(p2d2.X(), p2d2.Y(), pt2, DU2, DV2); ns2 = DU2.Crossed(DV2); if (F2.Orientation() == TopAbs_REVERSED) + { ns2.Reverse(); + } gp_Vec vref(pt1, pt2); if (ns1.Dot(vref) < 0.) { @@ -452,19 +506,29 @@ int ChFi3d::ConcaveSide(const BRepAdaptor_Surface& S1, if (Or1 == TopAbs_FORWARD) { if (Or2 == TopAbs_FORWARD) + { ChoixConge = 1; + } else + { ChoixConge = 7; + } } else { if (Or2 == TopAbs_FORWARD) + { ChoixConge = 3; + } else + { ChoixConge = 5; + } } if ((ns1.Crossed(ns2)).Dot(tgE) >= 0.) + { ChoixConge++; + } return ChoixConge; } @@ -497,13 +561,19 @@ int ChFi3d::NextSide(TopAbs_Orientation& Or1, if (Or1 == TopAbs_FORWARD) { if (Or2 == TopAbs_FORWARD) + { ChoixConge = 1; + } else { if (ChoixSave < 0) + { ChoixConge = 3; + } else + { ChoixConge = 7; + } } } else @@ -511,15 +581,23 @@ int ChFi3d::NextSide(TopAbs_Orientation& Or1, if (Or2 == TopAbs_FORWARD) { if (ChoixSave < 0) + { ChoixConge = 7; + } else + { ChoixConge = 3; + } } else + { ChoixConge = 5; + } } if (std::abs(ChoixSave) % 2 == 0) + { ChoixConge++; + } return ChoixConge; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder.cxx index e2c2e9f80c..192f69f63c 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder.cxx @@ -157,11 +157,15 @@ void ChFi3d_Builder::ExtentAnalyse() break; case 2: if (nbedges <= 3) + { ExtentTwoCorner(Vtx, myVDataMap.FindFromIndex(iv)); + } break; case 3: if (nbedges <= 3) + { ExtentThreeCorner(Vtx, myVDataMap.FindFromIndex(iv)); + } break; default: break; @@ -219,7 +223,9 @@ void ChFi3d_Builder::Compute() UpdateTolesp(); if (myListStripe.IsEmpty()) + { throw Standard_Failure("There are no suitable edges for chamfer or fillet"); + } Reset(); myDS = new TopOpeBRepDS_HDataStructure(); @@ -233,13 +239,21 @@ void ChFi3d_Builder::Compute() for (itel.Initialize(myListStripe); itel.More(); itel.Next()) { if ((itel.Value()->Spine()->FirstStatus() <= ChFiDS_BreakPoint)) + { myVDataMap.Add(itel.Value()->Spine()->FirstVertex(), itel.Value()); + } else if (itel.Value()->Spine()->FirstStatus() == ChFiDS_FreeBoundary) + { ExtentOneCorner(itel.Value()->Spine()->FirstVertex(), itel.Value()); + } if ((itel.Value()->Spine()->LastStatus() <= ChFiDS_BreakPoint)) + { myVDataMap.Add(itel.Value()->Spine()->LastVertex(), itel.Value()); + } else if (itel.Value()->Spine()->LastStatus() == ChFiDS_FreeBoundary) + { ExtentOneCorner(itel.Value()->Spine()->LastVertex(), itel.Value()); + } } // preanalysis to evaluate the extensions. ExtentAnalyse(); @@ -267,10 +281,14 @@ void ChFi3d_Builder::Compute() badstripes.Append(itel.Value()); done = true; if (itel.Value()->Spine()->ErrorStatus() == ChFiDS_Ok) + { itel.Value()->Spine()->SetErrorStatus(ChFiDS_Error); + } } if (!done) + { badstripes.Append(itel.Value()); + } done = true; } done = (badstripes.IsEmpty()); @@ -302,11 +320,15 @@ void ChFi3d_Builder::Compute() done = true; } if (!done) + { badvertices.Append(myVDataMap.FindKey(j)); + } done = true; } if (!hasresult) + { done = badvertices.IsEmpty(); + } } #ifdef OCCT_DEBUG // perf @@ -342,8 +364,10 @@ void ChFi3d_Builder::Compute() for (itel1.Initialize(myListStripe), i2 = 0; itel1.More(); itel1.Next(), i2++) { if (i2 <= i1) + { // Do not twice intersect the stripes continue; + } occ::handle aCheckStripe = itel1.Value(); try { @@ -366,7 +390,9 @@ void ChFi3d_Builder::Compute() int solidindex = st->SolidIndex(); ChFi3d_FilDS(solidindex, st, DStr, myRegul, tolapp3d, tol2d); if (!done) + { break; + } } #ifdef OCCT_DEBUG // perf @@ -387,7 +413,9 @@ void ChFi3d_Builder::Compute() double tolc = 0.; bool degen = c.Curve().IsNull(); if (!degen) + { tolc = c.Tolerance(); + } int ic = cex.Index(); TopOpeBRepDS_PointIterator It(myDS->CurvePoints(ic)); for (; It.More(); It.Next()) @@ -395,7 +423,9 @@ void ChFi3d_Builder::Compute() occ::handle II; II = occ::down_cast(It.Value()); if (II.IsNull()) + { continue; + } TopOpeBRepDS_Kind gk = II->GeometryType(); int gi = II->Geometry(); if (gk == TopOpeBRepDS_VERTEX) @@ -406,25 +436,37 @@ void ChFi3d_Builder::Compute() { tolv += 0.0003; if (tolc < tolv) + { tolc = tolv + 0.00001; + } } if (degen && tolc < tolv) + { tolc = tolv; + } else if (tolc > tolv) + { B1.UpdateVertex(v, tolc); + } } else if (gk == TopOpeBRepDS_POINT) { TopOpeBRepDS_Point& p = DStr.ChangePoint(gi); double tolp = p.Tolerance(); if (degen && tolc < tolp) + { tolc = tolp; + } else if (tolc > tolp) + { p.Tolerance(tolc); + } } } if (degen) + { c.Tolerance(tolc); + } } myCoup->Perform(myDS); NCollection_Map::Iterator It(MapIndSo); @@ -440,10 +482,14 @@ void ChFi3d_Builder::Compute() { const TopoDS_Shape S = DStr.Shape(i); if (S.ShapeType() != TopAbs_EDGE) + { continue; + } bool issplitIN = myCoup->IsSplit(S, TopAbs_IN); if (!issplitIN) + { continue; + } NCollection_List::Iterator it(myCoup->Splits(S, TopAbs_IN)); for (; it.More(); it.Next()) { @@ -455,7 +501,9 @@ void ChFi3d_Builder::Compute() const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current()); double tolv = BRep_Tool::Tolerance(v); if (tole > tolv) + { B1.UpdateVertex(v, tole); + } } } } @@ -468,7 +516,9 @@ void ChFi3d_Builder::Compute() const TopoDS_Shape& curshape = DStr.Shape(indsol); NCollection_List::Iterator its = myCoup->Merged(curshape, TopAbs_IN); if (!its.More()) + { B1.Add(myShapeResult, curshape); + } else { // If the old type of Shape is Shell, Shell is placed instead of Solid, @@ -502,7 +552,9 @@ void ChFi3d_Builder::Compute() const TopoDS_Shape& curshape = DStr.Shape(indsol); NCollection_List::Iterator its = myCoup->Merged(curshape, TopAbs_IN); if (!its.More()) + { B1.Add(badShape, curshape); + } else { while (its.More()) @@ -653,7 +705,9 @@ void ChFi3d_Builder::PerformSingularCorner(const int Index) // if yes the vertex is stored in the stripe // and the edge at end is created if (i == 0) + { Ivtx = ChFi3d_IndexPointInDS(CV1, DStr); + } double tolreached; double Pardeb, Parfin; gp_Pnt2d VOnS1, VOnS2; @@ -728,9 +782,13 @@ void ChFi3d_Builder::PerformFilletOnVertex(const int Index) const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst, 2); // Is it always degenerated ? if (CV1.Point().IsEqual(CV2.Point(), 0)) + { nondegenere = false; + } else + { toujoursdegenere = false; + } } // calcul du nombre de faces = nombre d'aretes @@ -759,7 +817,9 @@ void ChFi3d_Builder::PerformFilletOnVertex(const int Index) { case 1: { if (sp->Status(isfirst) == ChFiDS_FreeBoundary) + { return; + } if (nba > 3) { #ifdef OCCT_DEBUG // perf @@ -776,9 +836,13 @@ void ChFi3d_Builder::PerformFilletOnVertex(const int Index) ChFi3d_InitChron(cl_perform1corner); #endif if (MoreSurfdata(Index)) + { PerformMoreSurfdata(Index); + } else + { PerformOneCorner(Index); + } #ifdef OCCT_DEBUG // perf ChFi3d_ResultChron(cl_perform1corner, t_perform1corner); #endif @@ -845,9 +909,13 @@ void ChFi3d_Builder::PerformFilletOnVertex(const int Index) else { // Single case processing if (toujoursdegenere) + { PerformSingularCorner(Index); + } else + { PerformMoreThreeCorner(Index, i); // Last chance... + } } } @@ -871,7 +939,9 @@ void ChFi3d_Builder::Reset() itel.Next(); } else + { myListStripe.Remove(itel); + } } } @@ -881,9 +951,13 @@ const NCollection_List& ChFi3d_Builder::Generated(const TopoDS_Sha { myGenerated.Clear(); if (EouV.IsNull()) + { return myGenerated; + } if (EouV.ShapeType() != TopAbs_EDGE && EouV.ShapeType() != TopAbs_VERTEX) + { return myGenerated; + } if (myEVIMap.IsBound(EouV)) { const NCollection_List& L = myEVIMap.Find(EouV); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_0.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_0.cxx index 8536cb8374..2fe42a0028 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_0.cxx @@ -95,11 +95,17 @@ double ChFi3d_InPeriod(const double U, const double UFirst, const double ULast, const double period = ULast - UFirst; double u = U; while (Eps < (UFirst - u)) + { u += period; + } while (Eps > (ULast - u)) + { u -= period; + } if (u < UFirst) + { u = UFirst; + } return u; } @@ -283,12 +289,16 @@ void ChFi3d_Boite(const gp_Pnt2d& p1, static occ::handle Geometry(TopOpeBRepDS_DataStructure& DStr, const int ind) { if (ind == 0) + { return occ::handle(); + } if (ind > 0) { TopoDS_Face F = TopoDS::Face(DStr.Shape(ind)); if (F.IsNull()) + { return occ::handle(); + } occ::handle HS = new BRepAdaptor_Surface(); HS->Initialize(F, false); return HS; @@ -297,7 +307,9 @@ static occ::handle Geometry(TopOpeBRepDS_DataStructure& DStr, { occ::handle S = DStr.Surface(-ind).Surface(); if (S.IsNull()) + { return occ::handle(); + } return new GeomAdaptor_Surface(S); } } @@ -393,7 +405,9 @@ void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure& DStr, occ::handle F2 = Geometry(DStr, sd->IndexOfS2()); double p1 = fi1.Parameter(isfirst); if (!c3d1.IsNull()) + { b1.Add(c3d1->Value(p1)); + } if (!pcs1.IsNull()) { pcs1->Value(p1).Coord(u, v); @@ -410,7 +424,9 @@ void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure& DStr, } double p2 = fi2.Parameter(isfirst); if (!c3d2.IsNull()) + { b2.Add(c3d2->Value(p2)); + } if (!pcs2.IsNull()) { pcs2->Value(p2).Coord(u, v); @@ -430,9 +446,13 @@ void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure& DStr, const occ::handle& c3d = DStr.Curve(st->Curve(isfirst)).Curve(); const occ::handle& c2d = st->PCurve(isfirst); if (st->Orientation(isfirst) == TopAbs_FORWARD) + { st->Parameters(isfirst, p1, p2); + } else + { st->Parameters(isfirst, p2, p1); + } if (!c3d.IsNull()) { b1.Add(c3d->Value(p1)); @@ -472,7 +492,9 @@ void ChFi3d_conexfaces(const TopoDS_Edge& E, break; } else + { F2.Nullify(); + } } } } @@ -520,7 +542,9 @@ ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E, const ChFiDS_Map& EFMap) // if(F[0].IsNull() || F[1].IsNull() || F[2].IsNull()) sst = ChFiDS_FreeBoundary; if (F2.IsNull() || F4.IsNull() || F6.IsNull()) + { sst = ChFiDS_FreeBoundary; + } else { TopAbs_Orientation o01, o02, o11, o12, o21, o22; @@ -534,11 +558,17 @@ ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E, const ChFiDS_Map& EFMap) j = ChFi3d::ConcaveSide(F5, F6, E[2], o21, o22); if (o01 == o11 && o02 == o21 && o12 == o22) + { sst = ChFiDS_AllSame; + } else if (o12 == o22 || i == 10 || j == 10) + { sst = ChFiDS_OnDiff; + } else + { sst = ChFiDS_OnSame; + } } return sst; } @@ -554,13 +584,17 @@ GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/, { GeomAbs_Shape cont = GeomAbs_G1; if (!F1.IsSame(F2)) + { return cont; + } TopoDS_Face F = F1; F.Orientation(TopAbs_FORWARD); BRepAdaptor_Surface S(F, false); GeomAbs_SurfaceType typ = S.GetType(); if (typ != GeomAbs_Cone && typ != GeomAbs_Sphere && typ != GeomAbs_Torus) + { return cont; + } return GeomAbs_CN; } @@ -701,7 +735,9 @@ bool ChFi3d_InterPlaneEdge(const occ::handle& Plan, { CW = Intersection.Point(iip).W(); if (C->IsPeriodic()) + { CW = ElCLib::InPeriod(CW, uf - tolc, uf - tolc + C->Period()); + } if (uf - tolc <= CW && ul + tolc >= CW) { if (isol == 0) @@ -726,7 +762,9 @@ bool ChFi3d_InterPlaneEdge(const occ::handle& Plan, } } if (isol == 0) + { return false; + } return true; } @@ -773,9 +811,13 @@ void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr, nbelspine = sp->NbEdges(); occ::handle hels; if (nbelspine == 1) + { hels = sp->ElSpine(1); + } else + { hels = sp->ElSpine(p); + } if (fsp->IsConstant()) { R = fsp->Radius(); @@ -790,7 +832,9 @@ void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr, } V.Normalize(); if (sens == 1) + { V.Reverse(); + } } //======================================================================= @@ -896,13 +940,17 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, jf2 = 1; face = TopoDS::Face(DStr.Shape(fd1->Index(jf1))); if (face.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face"); + } OrSave1 = cd1->Orientation(jf1); Or = OrFace1 = face.Orientation(); OrSave2 = cd2->Orientation(jf2); const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2)); if (shape2.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape"); + } OrFace2 = shape2.Orientation(); visavis = true; sameside = ChFi3d::SameSide(Or, OrSave1, OrSave2, OrFace1, OrFace2); @@ -912,7 +960,9 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, double pref2 = fd2->Interference(kf2).Parameter(isf2); gp_Pnt2d P2d; if (Check2dDistance) + { P2d = BRep_Tool::Parameters(Vtx, face); + } if (ChFi3d_IntTraces(fd1, pref1, p1, @@ -942,13 +992,17 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, jf2 = 1; face = TopoDS::Face(DStr.Shape(fd1->Index(jf1))); if (face.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face"); + } OrSave1 = cd1->Orientation(jf1); Or = OrFace1 = face.Orientation(); OrSave2 = cd2->Orientation(jf2); const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2)); if (shape2.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape"); + } OrFace2 = shape2.Orientation(); visavis = true; sameside = ChFi3d::SameSide(Or, OrSave1, OrSave2, OrFace1, OrFace2); @@ -958,7 +1012,9 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, double pref2 = fd2->Interference(kf2).Parameter(isf2); gp_Pnt2d P2d; if (Check2dDistance) + { P2d = BRep_Tool::Parameters(Vtx, face); + } if (ChFi3d_IntTraces(fd1, pref1, p1, @@ -1012,13 +1068,17 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, jf2 = 2; face = TopoDS::Face(DStr.Shape(fd1->Index(jf1))); if (face.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face"); + } OrSave1 = cd1->Orientation(jf1); Or = OrFace1 = face.Orientation(); OrSave2 = cd2->Orientation(jf2); const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2)); if (shape2.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape"); + } OrFace2 = shape2.Orientation(); visavis = true; sameside = ChFi3d::SameSide(Or, OrSave1, OrSave2, OrFace1, OrFace2); @@ -1028,7 +1088,9 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, double pref2 = fd2->Interference(kf2).Parameter(isf2); gp_Pnt2d P2d; if (Check2dDistance) + { P2d = BRep_Tool::Parameters(Vtx, face); + } if (ChFi3d_IntTraces(fd1, pref1, p1, @@ -1082,13 +1144,17 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, jf2 = 2; face = TopoDS::Face(DStr.Shape(fd1->Index(jf1))); if (face.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face"); + } OrSave1 = cd1->Orientation(jf1); Or = OrFace1 = face.Orientation(); OrSave2 = cd2->Orientation(jf2); const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2)); if (shape2.IsNull()) + { throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape"); + } OrFace2 = shape2.Orientation(); visavis = true; sameside = ChFi3d::SameSide(Or, OrSave1, OrSave2, OrFace1, OrFace2); @@ -1098,7 +1164,9 @@ bool ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, double pref2 = fd2->Interference(kf2).Parameter(isf2); gp_Pnt2d P2d; if (Check2dDistance) + { P2d = BRep_Tool::Parameters(Vtx, face); + } if (ChFi3d_IntTraces(fd1, pref1, p1, @@ -1187,43 +1255,63 @@ bool ChFi3d_IntTraces(const occ::handle& fd1, first = fd1->Interference(jf1).FirstParameter(); last = fd1->Interference(jf1).LastParameter(); if ((last - first) < Precision::PConfusion()) + { return false; + } if (enlarge) + { delta = std::min(0.1, 0.05 * (last - first)); + } occ::handle pcf1 = fd1->Interference(jf1).PCurveOnFace(); if (pcf1.IsNull()) + { return false; + } bool isper1 = pcf1->IsPeriodic(); if (isper1) { occ::handle tr1 = occ::down_cast(pcf1); if (!tr1.IsNull()) + { pcf1 = tr1->BasisCurve(); + } C1.Load(pcf1); } else + { C1.Load(pcf1, first - delta, last + delta); + } double first1 = pcf1->FirstParameter(), last1 = pcf1->LastParameter(); first = fd2->Interference(jf2).FirstParameter(); last = fd2->Interference(jf2).LastParameter(); if ((last - first) < Precision::PConfusion()) + { return false; + } if (enlarge) + { delta = std::min(0.1, 0.05 * (last - first)); + } occ::handle pcf2 = fd2->Interference(jf2).PCurveOnFace(); if (pcf2.IsNull()) + { return false; + } bool isper2 = pcf2->IsPeriodic(); if (isper2) { occ::handle tr2 = occ::down_cast(pcf2); if (!tr2.IsNull()) + { pcf2 = tr2->BasisCurve(); + } C2.Load(pcf2); } else + { C2.Load(fd2->Interference(jf2).PCurveOnFace(), first - delta, last + delta); + } double first2 = pcf2->FirstParameter(), last2 = pcf2->LastParameter(); IntRes2d_IntersectionPoint int2d; @@ -1260,9 +1348,13 @@ bool ChFi3d_IntTraces(const occ::handle& fd1, p1 = int2d.ParamOnFirst(); p2 = int2d.ParamOnSecond(); if (isper1) + { p1 = recadre(p1, pref1, sens1, first1, last1); + } if (isper2) + { p2 = recadre(p2, pref2, sens2, first2, last2); + } for (int i = 2; i <= nbpt; i++) { int2d = Intersection.Point(i); @@ -1282,7 +1374,9 @@ bool ChFi3d_IntTraces(const occ::handle& fd1, double pp2 = int2d.ParamOnSecond(); if (isper2) + { pp2 = recadre(pp2, pref2, sens2, first2, last2); + } p1 = pp1; p2 = pp2; @@ -1306,7 +1400,9 @@ bool ChFi3d_IntTraces(const occ::handle& fd1, double pp1 = int2d.ParamOnFirst(); if (isper1) + { pp1 = recadre(pp1, pref1, sens1, first1, last1); + } p1 = pp1; p2 = pp2; @@ -1376,16 +1472,22 @@ void ChFi3d_Coefficient(const gp_Vec& V3d, void ChFi3d_ReparamPcurv(const double Uf, const double Ul, occ::handle& Pcurv) { if (Pcurv.IsNull()) + { return; + } double upcf = Pcurv->FirstParameter(); double upcl = Pcurv->LastParameter(); occ::handle basis = Pcurv; occ::handle trpc = occ::down_cast(Pcurv); if (!trpc.IsNull()) + { basis = trpc->BasisCurve(); + } occ::handle pc = occ::down_cast(basis); if (pc.IsNull()) + { return; + } if (std::abs(upcf - pc->FirstParameter()) > Precision::PConfusion() || std::abs(upcl - pc->LastParameter()) > Precision::PConfusion()) { @@ -1504,10 +1606,14 @@ bool ChFi3d_SameParameter(const occ::handle& C3d, double& tolreached) { if (ChFi3d_CheckSameParameter(C3d, Pcurv, S, tol3d, tolreached)) + { return true; + } Approx_SameParameter sp(C3d, Pcurv, S, tol3d); if (sp.IsDone() && !sp.IsSameParameter()) + { Pcurv = sp.Curve2d(); + } else if (!sp.IsDone() && !sp.IsSameParameter()) { return false; @@ -1654,10 +1760,14 @@ occ::handle ChFi3d_mkbound(const occ::handle ChFi3d_mkbound(const occ::handle ChFi3d_BuildPCurve(const gp_Pnt2d& p1, if (redresse) { if (d1.Dot(dref) < 0.) + { d1.Reverse(); + } if (d2.Dot(dref) > 0.) + { d2.Reverse(); + } } // On fait une cubique a la mords moi le noeud NCollection_Array1 pol(1, 4); @@ -1837,9 +1955,13 @@ occ::handle ChFi3d_BuildPCurve(const occ::handle 0.) + { vv2.Reverse(); + } } return ChFi3d_BuildPCurve(Surf, p1, vv1, p2, vv2, false); } @@ -2181,13 +2303,19 @@ int ChFi3d_SolidIndex(const occ::handle& sp, ChFiDS_Map& MapESh) { if (sp.IsNull() || sp->NbEdges() == 0) + { throw Standard_Failure("SolidIndex : Spine incomplete"); + } TopoDS_Shape edref = sp->Edges(1); TopoDS_Shape shellousolid; if (!MapESo(edref).IsEmpty()) + { shellousolid = MapESo(edref).First(); + } else + { shellousolid = MapESh(edref).First(); + } const int solidindex = DStr.AddShape(shellousolid); return solidindex; } @@ -2218,19 +2346,23 @@ occ::handle ChFi3d_FilPointInDS(const TopAb { occ::handle CP1; if (IsVertex) + { CP1 = new TopOpeBRepDS_CurvePointInterference(TopOpeBRepDS_Transition(Et), TopOpeBRepDS_CURVE, Ic, TopOpeBRepDS_VERTEX, Ip, Par); + } else + { CP1 = new TopOpeBRepDS_CurvePointInterference(TopOpeBRepDS_Transition(Et), TopOpeBRepDS_CURVE, Ic, TopOpeBRepDS_POINT, Ip, Par); + } return CP1; } @@ -2269,9 +2401,13 @@ static bool ChFi3d_Orientation(const NCollection_List>::Iterator itLI(LI); for (; itLI.More(); itLI.Next()) { @@ -2356,7 +2492,9 @@ static void CutEdge(const TopoDS_Vertex& V, const int ons) { if (!SD->IsOnCurve(ons)) + { return; + } int IC = SD->IndexOfC(ons); int IV = DStr.AddShape(V); NCollection_List>& LI = DStr.ChangeShapeInterferences(IC); @@ -2398,14 +2536,18 @@ static bool findIndexPoint(const TopOpeBRepDS_DataStructure& DStr, occ::handle SCI = occ::down_cast(SCIIt.Value()); if (SCI.IsNull()) + { continue; + } CPIIt.Initialize(DStr.CurveInterferences(SCI->Geometry())); for (; CPIIt.More(); CPIIt.Next()) { occ::handle CPI = occ::down_cast(CPIIt.Value()); if (CPI.IsNull()) + { continue; + } int iPoint = CPI->Geometry(); TopOpeBRepDS_Point tp = DStr.Point(iPoint); if (P.IsEqual(tp.Point(), tp.Tolerance())) @@ -2479,16 +2621,22 @@ void ChFi3d_FilDS(const int SolidIndex, const ChFiDS_FaceInterference& Fi = Fd->Interference(onS); IcFil1 = Fi.LineIndex(); if (!IcFil1) + { continue; + } double FiLen = std::abs(Fi.FirstParameter() - Fi.LastParameter()); if (FiLen > Precision::PConfusion()) + { continue; + } TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil1); cc.ChangeCurve().Nullify(); // care of CommonPoint, eap occ354 if (j != 1 && j != SeqFil.Length()) + { continue; + } bool isfirst = (j == 1); int i = isfirst ? j + 1 : j - 1; ChFiDS_CommonPoint& CP1 = SeqFil(i)->ChangeVertex(isfirst, onS); @@ -2843,7 +2991,9 @@ void ChFi3d_FilDS(const int SolidIndex, int ipoin; bool isVertex = Fd->VertexLastOnS1().IsVertex(); if (j == SeqFil.Length()) + { ipoin = CorDat->IndexLastPointOnS1(); + } else if (j == (SeqFil.Length() - 1) && /*Closed &&*/ (DStr.Curve(SeqFil.Last()->InterferenceOnS1().LineIndex()).Curve().IsNull())) { @@ -2869,15 +3019,19 @@ void ChFi3d_FilDS(const int SolidIndex, || (Fd->VertexLastOnS1().Point().IsEqual( SeqFil(SeqFil.Length())->VertexLastOnS1().Point(), 1.e-7)))) + { // Case of SurfData cut in "Triangular" way. ipoin = CorDat->IndexLastPointOnS1(); - // eap, Apr 29 2002, occ 293 + // eap, Apr 29 2002, occ 293 + } else if (isInDS2 && findIndexPoint(DStr, Fd, 1, ipoin)) { } else + { ipoin = ChFi3d_IndexPointInDS(Fd->VertexLastOnS1(), DStr); + } NCollection_List>& Li = DStr.ChangeCurveInterferences(IcFil1); @@ -2937,7 +3091,9 @@ void ChFi3d_FilDS(const int SolidIndex, int ipoin; bool isVertex = Fd->VertexLastOnS2().IsVertex(); if (j == SeqFil.Length()) + { ipoin = CorDat->IndexLastPointOnS2(); + } else if (j == (SeqFil.Length() - 1) && /*Closed &&*/ (DStr.Curve(SeqFil.Last()->InterferenceOnS2().LineIndex()).Curve().IsNull())) { @@ -2968,15 +3124,19 @@ void ChFi3d_FilDS(const int SolidIndex, || (Fd->VertexLastOnS2().Point().IsEqual( SeqFil(SeqFil.Length())->VertexLastOnS2().Point(), 1.e-7)))) + { // Case of SurfData cut in "Triangular" way. ipoin = CorDat->IndexLastPointOnS2(); - // eap, Apr 29 2002, occ 293 + // eap, Apr 29 2002, occ 293 + } else if (isInDS2 && findIndexPoint(DStr, Fd, 2, ipoin)) { } else + { ipoin = ChFi3d_IndexPointInDS(Fd->VertexLastOnS2(), DStr); + } NCollection_List>& Li = DStr.ChangeCurveInterferences(IcFil2); @@ -3107,13 +3267,19 @@ void ChFi3d_FilDS(const int SolidIndex, { OVtx = ex.Current().Orientation(); if (Closed && (NumEdge == 1)) + { Trouve = (spine->NbEdges() == 1); + } else + { Trouve = true; + } } } if (!Trouve) + { NumEdge++; // Go to the next edge + } } int IArcspine = DStr.AddShape(Arcspine); int IVtx; @@ -3190,12 +3356,18 @@ void ChFi3d_StripeEdgeInter(const occ::handle& theStripe1, { // Do not check the stripeshaving common corner points for (int iSur1 = 1; iSur1 <= 2; iSur1++) + { for (int iSur2 = 1; iSur2 <= 2; iSur2++) + { if (theStripe1->IndexPoint(false, iSur1) == theStripe2->IndexPoint(false, iSur2) || theStripe1->IndexPoint(false, iSur1) == theStripe2->IndexPoint(true, iSur2) || theStripe1->IndexPoint(true, iSur1) == theStripe2->IndexPoint(false, iSur2) || theStripe1->IndexPoint(true, iSur1) == theStripe2->IndexPoint(true, iSur2)) + { return; + } + } + } occ::handle>> aSurDat1 = theStripe1->SetOfSurfData(); @@ -3249,8 +3421,10 @@ void ChFi3d_StripeEdgeInter(const occ::handle& theStripe1, if (IsEqual(aFI1.FirstParameter(), aFI1.LastParameter()) || IsEqual(aFI2.FirstParameter(), aFI2.LastParameter()) || aFI1.PCurveOnFace().IsNull() || aFI2.PCurveOnFace().IsNull()) + { // Do not waste time on degenerates continue; + } // Examine for intersections Geom2dAdaptor_Curve aPCurve1(aFI1.PCurveOnFace(), aFI1.FirstParameter(), @@ -3260,7 +3434,9 @@ void ChFi3d_StripeEdgeInter(const occ::handle& theStripe1, aFI2.LastParameter()); anIntersector.Perform(aPCurve1, aPCurve2, tol2d, Precision::PConfusion()); if (anIntersector.NbSegments() > 0 || anIntersector.NbPoints() > 0) + { throw StdFail_NotDone("StripeEdgeInter : fillets have too big radiuses"); + } } } } @@ -3275,25 +3451,41 @@ int ChFi3d_IndexOfSurfData(const TopoDS_Vertex& V1, const occ::handleEdges(1); if (E.Orientation() == TopAbs_REVERSED) + { Vref = TopExp::LastVertex(E); + } else + { Vref = TopExp::FirstVertex(E); + } if (Vref.IsSame(V1)) + { Index = 1; + } else { const TopoDS_Edge& E1 = spine->Edges(spine->NbEdges()); if (E1.Orientation() == TopAbs_REVERSED) + { Vref = TopExp::FirstVertex(E1); + } else + { Vref = TopExp::LastVertex(E1); + } sens = -1; if (CD->SetOfSurfData().IsNull()) + { return 0; + } else if (Vref.IsSame(V1)) + { Index = CD->SetOfSurfData()->Length(); + } else + { throw Standard_ConstructionError("ChFi3d_IndexOfSurfData() - wrong construction parameters"); + } } return Index; } @@ -3309,23 +3501,37 @@ TopoDS_Edge ChFi3d_EdgeFromV1(const TopoDS_Vertex& V1, TopoDS_Vertex Vref; const TopoDS_Edge& E = spine->Edges(1); if (E.Orientation() == TopAbs_REVERSED) + { Vref = TopExp::LastVertex(E); + } else + { Vref = TopExp::FirstVertex(E); + } if (Vref.IsSame(V1)) + { return E; + } else { const TopoDS_Edge& E1 = spine->Edges(spine->NbEdges()); if (E1.Orientation() == TopAbs_REVERSED) + { Vref = TopExp::FirstVertex(E1); + } else + { Vref = TopExp::LastVertex(E1); + } sens = -1; if (Vref.IsSame(V1)) + { return E1; + } else + { throw Standard_ConstructionError("ChFi3d_IndexOfSurfData() - wrong construction parameters"); + } } } @@ -3370,13 +3576,19 @@ double ChFi3d_EvalTolReached(const occ::handle& S1, gp_Pnt pC = C->Value(t); double d = pS1.SquareDistance(pC); if (d > distmax) + { distmax = d; + } d = pS2.SquareDistance(pC); if (d > distmax) + { distmax = d; + } d = pS1.SquareDistance(pS2); if (d > distmax) + { distmax = d; + } } distmax = 1.5 * sqrt(distmax); distmax = std::max(distmax, Precision::Confusion()); @@ -3403,7 +3615,9 @@ occ::handle trsfsurf(const occ::handle& HS, occ::handle tr = occ::down_cast(res); if (!tr.IsNull()) + { res = tr->BasisSurface(); + } double U1 = HS->FirstUParameter(), U2 = HS->LastUParameter(); double V1 = HS->FirstVParameter(), V2 = HS->LastVParameter(); @@ -3415,16 +3629,24 @@ occ::handle trsfsurf(const occ::handle& HS, if (!res->IsUPeriodic()) { if (U1 < u1) + { U1 = u1; + } if (U2 > u2) + { U2 = u2; + } } if (!res->IsVPeriodic()) { if (V1 < v1) + { V1 = v1; + } if (V2 > v2) + { V2 = v2; + } } res = new Geom_RectangularTrimmedSurface(res, U1, U2, V1, V2); } @@ -3451,7 +3673,9 @@ static void CurveCleaner(occ::handle& BS, const double Tol, c for (ii = NbK; ii > 1; ii--) { if (BS->Multiplicity(ii) == Mult) + { BS->RemoveKnot(ii, Mult - 1, tol); + } } } } @@ -3487,9 +3711,13 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, double distrefdeb = pdeb1.Distance(pdeb2); // checks the worthiness double distreffin = pfin1.Distance(pfin2); // of input data if (distrefdeb < tol3d) + { distrefdeb = tol3d; + } if (distreffin < tol3d) + { distreffin = tol3d; + } gp_Pnt pdeb, pfin; pdeb.SetXYZ(0.5 * (pdeb1.XYZ() + pdeb2.XYZ())); @@ -3497,9 +3725,13 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, double distref = 0.005 * pdeb.Distance(pfin); if (distref < distrefdeb) + { distref = distrefdeb; + } if (distref < distreffin) + { distref = distreffin; + } // Some analytic cases are processed separately. // To reorientate the result of the analythic intersection, @@ -3551,7 +3783,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, Udeb = ElCLib::Parameter(C1, pdeb); gp_Pnt ptest = ElCLib::Value(Udeb, C1); if (ptest.Distance(pdeb) < tol3d) + { break; + } } Ufin = ElCLib::Parameter(C1, pfin); C3d = new Geom_Line(C1); @@ -3592,7 +3826,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, } } if (!c1line) + { ElCLib::AdjustPeriodic(0., 2 * M_PI, Precision::Angular(), Udeb, Ufin); + } occ::handle HC = new GeomAdaptor_Curve(); HC->Load(C3d, Udeb, Ufin); ChFi3d_ProjectPCurv(HC, S1, Pc1, tol3d, tolr1); @@ -3603,7 +3839,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, x = Pardeb(1) - x; y = Pardeb(2) - y; if (std::abs(x) >= tol2d || std::abs(y) >= tol2d) + { Pc1->Translate(gp_Vec2d(x, y)); + } } ChFi3d_ProjectPCurv(HC, S2, Pc2, tol3d, tolr2); if (S2->GetType() == GeomAbs_Cylinder) @@ -3613,7 +3851,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, x = Pardeb(3) - x; y = Pardeb(4) - y; if (std::abs(x) >= tol2d || std::abs(y) >= tol2d) + { Pc2->Translate(gp_Vec2d(x, y)); + } } C3d = new Geom_TrimmedCurve(C3d, Udeb, Ufin); tolreached = 1.5 * std::max(tolr1, tolr2); @@ -3708,18 +3948,30 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, failedF = failedL = false; proj.Init(pdeb1, C3d); if (proj.NbPoints() == 0 && distrefdeb > Precision::Confusion()) + { proj.Perform(pdeb2); + } if (proj.NbPoints() == 0) + { failedF = true; + } else + { Uf = proj.LowerDistanceParameter(); + } proj.Perform(pfin1); if (proj.NbPoints() == 0 && distreffin > Precision::Confusion()) + { proj.Perform(pfin2); + } if (proj.NbPoints() == 0) + { failedL = true; + } else + { Ul = proj.LowerDistanceParameter(); + } if (failedF && failedL) { @@ -3733,14 +3985,20 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, double U1 = C3d->FirstParameter(), U2 = C3d->LastParameter(); Uok = std::abs(Uok - U1) > std::abs(Uok - U2) ? U1 : U2; if (failedF) + { Uf = Uok; + } else + { Ul = Uok; + } } else { // both projected, but where? if (std::abs(Uf - Ul) < Precision::PConfusion()) + { continue; + } } ptestdeb = C3d->Value(Uf); ptestfin = C3d->Value(Ul); @@ -3792,12 +4050,16 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, x = Pardeb(1) - x; y = Pardeb(2) - y; if (std::abs(x) > tol2d || std::abs(y) > tol2d) + { Pc1->Translate(gp_Vec2d(x, y)); + } Pc2->Value(Uf).Coord(x, y); x = Pardeb(3) - x; y = Pardeb(4) - y; if (std::abs(x) > tol2d || std::abs(y) > tol2d) + { Pc2->Translate(gp_Vec2d(x, y)); + } tolreached = ChFi3d_EvalTolReached(S1, Pc1, S2, Pc2, C3d); return true; } @@ -3843,7 +4105,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, pintdep.Parameters(depart(1), depart(2), depart(3), depart(4)); IntKK.Perform(depart); if (!IntKK.IsDone()) + { return false; + } if (IntKK.NbPoints() <= 30) { Step *= 0.5; @@ -3910,7 +4174,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, } nbp = indf; if (nbp == 1) + { return false; + } // The extremities are inserted in the line if the extremity points on it // are too far and if pardeb and parfin are good. if (ddeb >= tol3d && bondeb) @@ -3982,7 +4248,9 @@ bool ChFi3d_ComputeCurves(const occ::handle& S1, // manage here the approximations that are not useful on planes! approx.Perform(S1, S2, WL, true, true, true, 1, nbp); if (!approx.IsDone()) + { return false; + } // tolreached = approx.TolReached3d(); // double tolr2d = approx.TolReached2d(); // tolreached = std::max(tolreached,ChFi3d_ConvTol2dToTol3d(S1,tolr2d)); @@ -4046,9 +4314,13 @@ bool ChFi3d_IntCS(const occ::handle& S, bool keepfirst = (wc < -1.e100), keeplast = (wc > 1.e100); double temp = 0.; if (keepfirst) + { temp = 1.e100; + } if (keeplast) + { temp = -1.e100; + } double dist = 2.e100; if (Intersection.IsDone()) { @@ -4059,9 +4331,13 @@ bool ChFi3d_IntCS(const occ::handle& S, double up = pint.U(); double vp = pint.V(); if (S->IsUPeriodic()) + { up = ChFi3d_InPeriod(up, u1, u1 + S->UPeriod(), 1.e-8); + } if (S->IsVPeriodic()) + { vp = ChFi3d_InPeriod(vp, v1, v1 + S->VPeriod(), 1.e-8); + } if (uf <= pint.W() && ul >= pint.W() && u1 <= up && u2 >= up && v1 <= vp && v2 >= vp) { if (keepfirst && pint.W() < temp) @@ -4082,14 +4358,20 @@ bool ChFi3d_IntCS(const occ::handle& S, } } if (isol == 0) + { return false; + } pint = Intersection.Point(isol); double up = pint.U(); double vp = pint.V(); if (S->IsUPeriodic()) + { up = ChFi3d_InPeriod(up, u1, u1 + S->UPeriod(), 1.e-8); + } if (S->IsVPeriodic()) + { vp = ChFi3d_InPeriod(vp, v1, v1 + S->VPeriod(), 1.e-8); + } p2dS.SetCoord(up, vp); wc = pint.W(); return true; @@ -4183,7 +4465,9 @@ occ::handle ChFi3d_BoundSurf(TopOpeBRepDS_DataStructure& S1.Load(DStr.Surface(Fd1->Surf()).Surface()); if ((IFaCo1 == 0) || (IFaArc1 == 0)) + { return HS1; + } const ChFiDS_FaceInterference& FiCo1 = Fd1->Interference(IFaCo1); const ChFiDS_FaceInterference& FiArc1 = Fd1->Interference(IFaArc1); @@ -4371,7 +4655,9 @@ bool ChFi3d_SearchFD(TopOpeBRepDS_DataStructure& DStr, } } if (fini1 && fini2) + { break; + } } return found; } @@ -4407,9 +4693,13 @@ void ChFi3d_Parameters(const occ::handle& S, const gp_Pnt& p3d, do default: { GeomAPI_ProjectPointOnSurf tool(p3d, S); if (tool.NbPoints() != 1) + { throw StdFail_NotDone("ChFi3d_Parameters() - no projection results"); + } else + { tool.Parameters(1, u, v); + } } } } @@ -4457,14 +4747,22 @@ void ChFi3d_TrimCurve(const occ::handle& gc, default: { GeomAPI_ProjectPointOnCurve tool(FirstP, gc); if (tool.NbPoints() != 1) + { throw StdFail_NotDone("ChFi3d_TrimCurve() - no projection results for the first point"); + } else + { uf = tool.Parameter(1); + } tool.Init(LastP, gc); if (tool.NbPoints() != 1) + { throw StdFail_NotDone("ChFi3d_TrimCurve() - no projection results for the second point"); + } else + { ul = tool.Parameter(1); + } } } gtc = new Geom_TrimmedCurve(gc, uf, ul); @@ -4487,7 +4785,9 @@ static bool GoodExt(const occ::handle& C, const double ang = d1.Angle(V); const double angref = a * t + 0.002; if (ang > angref) + { return false; + } } return true; } @@ -4531,7 +4831,9 @@ Standard_EXPORT void ChFi3d_PerformElSpine(occ::handle& HES, nwl = ElCLib::InPeriod(WL, tol, period + tol); IL = Spine->Index(nwl, false); if (nwl < nwf + tol) + { IL += nbed; + } } else { @@ -5125,7 +5427,9 @@ void ChFi3d_cherche_edge(const TopoDS_Vertex& V, for (i = E1.Lower(); i <= E1.Upper(); i++) { if (Ecur.IsSame(E1.Value(i))) + { same = true; + } } if (!same) { @@ -5174,10 +5478,14 @@ int ChFi3d_nbface(const NCollection_List& mapVF) for (JtF.Initialize(mapVF); JtF.More() && (kf < fj); JtF.Next(), kf++) { if (cur.IsSame(JtF.Value())) + { break; + } } if (kf == fj) + { nface++; + } } return nface; } @@ -5207,7 +5515,9 @@ void ChFi3d_edge_common_faces(const NCollection_List& mapEF, } } if (!trouve) + { F2 = F1; + } } /***********************************************************/ @@ -5227,9 +5537,13 @@ double ChFi3d_AngleEdge(const TopoDS_Vertex& Vtx, const TopoDS_Edge& E1, const T BCurv1.D1(parE1, P1, dir1); BCurv2.D1(parE2, P2, dir2); if (!Vtx.IsSame(TopExp::FirstVertex(E1))) + { dir1.Reverse(); + } if (!Vtx.IsSame(TopExp::FirstVertex(E2))) + { dir2.Reverse(); + } angle = std::abs(dir1.Angle(dir2)); return angle; } @@ -5259,7 +5573,9 @@ void ChFi3d_ChercheBordsLibres(const ChFiDS_Map& myVEMap, { const TopoDS_Edge& cur1 = TopoDS::Edge(ItE1.Value()); if (cur1.IsSame(cur)) + { nboccur++; + } } } if (nboccur == 1) @@ -5281,7 +5597,9 @@ void ChFi3d_ChercheBordsLibres(const ChFiDS_Map& myVEMap, { const TopoDS_Edge& cur1 = TopoDS::Edge(ItE1.Value()); if (cur1.IsSame(cur)) + { nboccur++; + } } } if (nboccur == 1) @@ -5306,7 +5624,9 @@ int ChFi3d_NbNotDegeneratedEdges(const TopoDS_Vertex& Vtx, const ChFiDS_Map& VEM { const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value()); if (BRep_Tool::Degenerated(cur)) + { nba--; + } } return nba; } @@ -5324,13 +5644,17 @@ int ChFi3d_NbSharpEdges(const TopoDS_Vertex& Vtx, const ChFiDS_Map& VEMap, const { const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value()); if (BRep_Tool::Degenerated(cur)) + { nba--; + } else { TopoDS_Face F1, F2; ChFi3d_conexfaces(cur, F1, F2, EFMap); if (!F2.IsNull() && ChFi3d::IsTangentFaces(cur, F1, F2, GeomAbs_G2)) + { nba--; + } } } return nba; @@ -5349,9 +5673,13 @@ int ChFi3d_NumberOfEdges(const TopoDS_Vertex& Vtx, const ChFiDS_Map& VEMap) nba = ChFi3d_NbNotDegeneratedEdges(Vtx, VEMap); ChFi3d_ChercheBordsLibres(VEMap, Vtx, bordlibre, edgelibre1, edgelibre2); if (bordlibre) + { nba = (nba - 2) / 2 + 2; + } else + { nba = nba / 2; + } return nba; } @@ -5370,9 +5698,13 @@ int ChFi3d_NumberOfSharpEdges(const TopoDS_Vertex& Vtx, nba = ChFi3d_NbSharpEdges(Vtx, VEMap, EFmap); ChFi3d_ChercheBordsLibres(VEMap, Vtx, bordlibre, edgelibre1, edgelibre2); if (bordlibre) + { nba = (nba - 2) / 2 + 2; + } else + { nba = nba / 2; + } return nba; } @@ -5473,7 +5805,9 @@ void ChFi3d_CoutureOnVertex(const TopoDS_Face& F, bool ChFi3d_IsPseudoSeam(const TopoDS_Edge& E, const TopoDS_Face& F) { if (!BRep_Tool::IsClosed(E, F)) + { return false; + } bool NeighborSeamFound = false; TopoDS_Vertex Vf, Vl, V1, V2; @@ -5506,7 +5840,9 @@ occ::handle ChFi3d_ApproxByC2(const occ::handle& NCollection_Array1 Points(1, NbPoints); double delta = (Last - First) / (NbPoints - 1); for (int i = 1; i <= NbPoints - 1; i++) + { Points(i) = C->Value(First + (i - 1) * delta); + } Points(NbPoints) = C->Value(Last); GeomAPI_PointsToBSpline Approx(Points, Approx_ChordLength, 3, 8, GeomAbs_C2, 1.000001e-3); @@ -5540,7 +5876,9 @@ bool ChFi3d_IsSmooth(const occ::handle& C) { LProp.SetParameter(t); if (!LProp.IsTangentDefined()) + { return false; + } Curvature = std::abs(LProp.Curvature()); if (Curvature > Resolution) { @@ -5560,7 +5898,9 @@ bool ChFi3d_IsSmooth(const occ::handle& C) } if (!prevVecFound) + { return true; + } // for (intrv = 1; intrv <= nbintv; intrv++) { for (intrv = intrvFound; intrv <= nbintv; intrv++) @@ -5571,7 +5911,9 @@ bool ChFi3d_IsSmooth(const occ::handle& C) { LProp.SetParameter(t); if (!LProp.IsTangentDefined()) + { return false; + } Curvature = std::abs(LProp.Curvature()); if (Curvature > Resolution) { @@ -5580,12 +5922,18 @@ bool ChFi3d_IsSmooth(const occ::handle& C) gp_Vec Vec(P1, P2); double Angle = PrevVec.Angle(Vec); if (Angle > M_PI / 3.) + { return false; + } double Ratio = Vec.Magnitude() / PrevVec.Magnitude(); if (Ratio < 1.) + { Ratio = 1. / Ratio; + } if (Ratio > 2. && (intrv != nbintv || ii != Discretisation)) + { return false; + } PrevVec = Vec; } t += step; diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx index eac12f82d4..ee5a5f36e4 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx @@ -131,7 +131,9 @@ static void ConcatCurves(NCollection_Sequence>& theCurve occ::handle aBoundedCurve = occ::down_cast(aCurve); Success = Concat.Add(aBoundedCurve, 1.e-5, true); if (!Success) + { Success = Concat.Add(aBoundedCurve, 1.e-5, false); + } if (Success) { theCurves.Remove(i); @@ -160,11 +162,15 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, S1.LastVParameter()); double Offset = -Distance; if (F1.Orientation() == TopAbs_REVERSED) + { Offset = Distance; + } occ::handle MakeOffsetSurf = new Geom_OffsetSurface(TrGS1, Offset); occ::handle OffsetTrGS1 = MakeOffsetSurf->Surface(); if (OffsetTrGS1.IsNull()) + { OffsetTrGS1 = MakeOffsetSurf; + } occ::handle GS2 = BRep_Tool::Surface(F2); occ::handle TrGS2 = new Geom_RectangularTrimmedSurface(GS2, S2.FirstUParameter(), @@ -187,7 +193,9 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, { NCollection_Sequence> Curves, NewCurves; for (int i = 1; i <= Intersector.NbLines(); i++) + { Curves.Append(Intersector.Line(i)); + } ConcatCurves(Curves, NewCurves); @@ -198,7 +206,9 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, GeomAdaptor_Curve GAcurve(NewCurves(i)); Extrema_ExtPC Projector(Ends[0], GAcurve); if (!Projector.IsDone() || Projector.NbExt() == 0) + { continue; + } for (int iext = 1; iext <= Projector.NbExt(); iext++) { double aDist = Projector.SquareDistance(iext); @@ -221,7 +231,9 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, for (int ind_end = 0; ind_end < 2; ind_end++) { if (ind_end == 1 && aBAcurve.IsClosed() /*HGuide->IsPeriodic()*/ /*HGuide->IsClosed()*/) + { break; + } Extrema_ExtPC Projector(Ends[ind_end], GAcurve); double param[4], dist[4]; gp_Pnt Pnt[4]; @@ -233,8 +245,12 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, { int imin = 1; for (int i = 2; i <= Projector.NbExt(); i++) + { if (Projector.SquareDistance(i) < Projector.SquareDistance(imin)) + { imin = i; + } + } param[3] = Projector.Point(imin).Parameter(); dist[3] = Projector.SquareDistance(imin); Pnt[3] = Projector.Point(imin).Value(); @@ -242,22 +258,32 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, int imin = 1; for (int i = 2; i <= 3; i++) + { if (dist[i] < dist[imin]) + { imin = i; + } + } Params[ind_end] = param[imin]; // Projector.Point(imin).Parameter(); } if (aBAcurve.IsClosed() /*HGuide->IsPeriodic()*/ /*HGuide->IsClosed()*/) + { Params[1] = GAcurve.LastParameter(); // temporary + } if (Params[0] > Params[1]) { bool IsClosed = false; gp_Pnt fpnt = IntCurve->Value(IntCurve->FirstParameter()); gp_Pnt lpnt = IntCurve->Value(IntCurve->LastParameter()); if (fpnt.SquareDistance(lpnt) <= Precision::SquareConfusion()) + { IsClosed = true; + } if (IsClosed) + { Params[1] = IntCurve->LastParameter(); + } else { double NewFirstPar = IntCurve->ReversedParameter(Params[0]); @@ -275,7 +301,9 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge, aBAcurve.D1(aBAcurve.FirstParameter(), aPnt, Tangent); IntCurve->D1(Params[0], anOffsetPnt, OffsetTangent); if (Tangent * OffsetTangent < 0) + { IntCurve->Reverse(); + } } /* @@ -390,13 +418,17 @@ int ChFi3d_Builder::FaultyContour(const int I) const } } if (st.IsNull()) + { return 0; + } k = 0; for (itel.Initialize(myListStripe); itel.More(); itel.Next()) { k += 1; if (st == itel.Value()) + { return k; + } } return 0; } @@ -418,12 +450,18 @@ int ChFi3d_Builder::NbComputedSurfaces(const int IC) const } } if (st.IsNull()) + { return 0; + } if (st->Spine().IsNull()) + { return 0; + } occ::handle>> hd = st->SetOfSurfData(); if (hd.IsNull()) + { return 0; + } return hd->Length(); } @@ -536,11 +574,15 @@ bool ChFi3d_Builder::FaceTangency(const TopoDS_Edge& E0, for (It.Initialize(myEFMap(E1)), Nbf = 0; It.More(); It.Next(), Nbf++) { if (Nbf > 1) + { throw Standard_ConstructionError("ChFi3d_Builder:only 2 faces"); + } F[Nbf] = TopoDS::Face(It.Value()); } if (Nbf < 2) + { return false; + } // Modified by Sergey KHROMOV - Fri Dec 21 17:44:19 2001 Begin // if (BRep_Tool::Continuity(E1,F[0],F[1]) != GeomAbs_C0) { if (ChFi3d::IsTangentFaces(E1, F[0], F[1])) @@ -558,11 +600,15 @@ bool ChFi3d_Builder::FaceTangency(const TopoDS_Edge& E0, for (It.Initialize(myEFMap(Ec)), Nbf = 0; It.More(); It.Next(), Nbf++) { if (Nbf > 1) + { throw Standard_ConstructionError("ChFi3d_Builder:only 2 faces"); + } F[Nbf] = TopoDS::Face(It.Value()); } if (Nbf < 2) + { return false; + } // Modified by Sergey KHROMOV - Tue Dec 18 18:10:40 2001 Begin // if (BRep_Tool::Continuity(Ec,F[0],F[1]) < GeomAbs_G1) { if (!ChFi3d::IsTangentFaces(Ec, F[0], F[1])) @@ -596,7 +642,9 @@ static bool TangentExtremity(const TopoDS_Vertex& V, e1.Orientation(TopAbs_FORWARD); e2.Orientation(TopAbs_FORWARD); if (f1.IsSame(f2) && BRep_Tool::IsClosed(e1, f1)) + { e2.Orientation(TopAbs_REVERSED); + } double p1 = BRep_Tool::Parameter(V, e1, f1); double p2 = BRep_Tool::Parameter(V, e2, f2); double u, v, f, l, Eps = 1.e-9; @@ -608,10 +656,14 @@ static bool TangentExtremity(const TopoDS_Vertex& V, { n1.SetXYZ(theProp1.Normal().XYZ()); if (O1 == TopAbs_REVERSED) + { n1.Reverse(); + } } else + { return false; // It is not known... + } occ::handle pc2 = BRep_Tool::CurveOnSurface(e2, f2, f, l); pc2->Value(p2).Coord(u, v); @@ -620,10 +672,14 @@ static bool TangentExtremity(const TopoDS_Vertex& V, { n2.SetXYZ(theProp2.Normal().XYZ()); if (O2 == TopAbs_REVERSED) + { n2.Reverse(); + } } else + { return false; // It is not known... + } return (n1.Angle(n2) < tang); } @@ -640,7 +696,9 @@ static bool TangentOnVertex(const TopoDS_Vertex& V, TopoDS_Face ff1, ff2; ChFi3d_conexfaces(E, ff1, ff2, EFMap); if (ff1.IsNull() || ff2.IsNull()) + { return false; + } occ::handle S1 = new (BRepAdaptor_Surface)(ff1); occ::handle S2 = new (BRepAdaptor_Surface)(ff2); return TangentExtremity(V, E, S1, S2, tang); @@ -698,7 +756,9 @@ void ChFi3d_Builder::PerformExtremity(const occ::handle& Spine) { TopoDS_Edge anEdge = TopoDS::Edge(It.Value()); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } TopoDS_Face F1, F2; ChFi3d_conexfaces(anEdge, F1, F2, myEFMap); if (!F2.IsNull() && ChFi3d::IsTangentFaces(anEdge, F1, F2, GeomAbs_G2)) // smooth edge @@ -728,7 +788,9 @@ void ChFi3d_Builder::PerformExtremity(const occ::handle& Spine) { int anInd = EdgesOfV.FindIndex(anEdge); if (anInd == 0) + { anInd = EdgesOfV.FindIndex(anEdge.Reversed()); + } anEdge = TopoDS::Edge(EdgesOfV(anInd)); anEdge.Reverse(); if (EdgesOfV.Add(anEdge)) @@ -744,16 +806,22 @@ void ChFi3d_Builder::PerformExtremity(const occ::handle& Spine) } if (EdgesOfV.Extent() != 3) + { sommetpourri = true; + } if (!sommetpourri && aLocNbG1Connections < 4) { sst = ChFi3d_EdgeState(E, myEFMap); } if (ii == 1) + { Spine->SetFirstStatus(sst); + } else + { Spine->SetLastStatus(sst); + } } } @@ -769,10 +837,14 @@ void ChFi3d_Builder::PerformExtremity(const occ::handle& Spine) for (Jt.Initialize(myVFMap(Spine->FirstVertex())); Jt.More() && (kf < jf); Jt.Next(), kf++) { if (cur.IsSame(Jt.Value())) + { break; + } } if (kf == jf) + { nbf++; + } } nbf -= NbG1Connections; if (nbf > 3) @@ -788,10 +860,14 @@ void ChFi3d_Builder::PerformExtremity(const occ::handle& Spine) for (Jt.Initialize(myVFMap(Spine->LastVertex())); Jt.More() && (kf < jf); Jt.Next(), kf++) { if (cur.IsSame(Jt.Value())) + { break; + } } if (kf == jf) + { nbf++; + } } nbf -= NbG1Connections; if (nbf > 3) @@ -823,16 +899,22 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, TopoDS_Vertex Ve1, VStart, FVEc, LVEc, FVEv, LVEv; TopoDS_Edge Ev, Ec(Spine->Edges(1)); if (BRep_Tool::Degenerated(Ec)) + { return false; + } // it is checked if the edge is a cut edge TopoDS_Face ff1, ff2; ChFi3d_conexfaces(Ec, ff1, ff2, myEFMap); if (ff1.IsNull() || ff2.IsNull()) + { return false; + } // Modified by Sergey KHROMOV - Fri Dec 21 17:46:22 2001 End // if(BRep_Tool::Continuity(Ec,ff1,ff2) != GeomAbs_C0) return 0; if (ChFi3d::IsTangentFaces(Ec, ff1, ff2)) + { return false; + } // Modified by Sergey KHROMOV - Fri Dec 21 17:46:24 2001 Begin TopoDS_Face FirstFace = ff1; @@ -918,7 +1000,9 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, Or1 = TopAbs_REVERSED; } else + { Or1 = TopAbs_FORWARD; + } Wf = BRep_Tool::Parameter(FVEv, Ev); CEv.Initialize(Ev); @@ -934,7 +1018,9 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, OnAjoute = ((!rev && av1v2 < M_PI / 2) || (rev && av1v2 > M_PI / 2)); // mate attention to the single case (cf CTS21610_1) if (OnAjoute && (degeneOnEc || TangentOnVertex(LVEc, Ev, myEFMap, ta))) + { OnAjoute = ((!rev && av1v2 < ta) || (rev && (M_PI - av1v2) < ta)); + } } if (OnAjoute) { @@ -982,7 +1068,9 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, { } if (Nbface > 1) + { CurSt = ChFiDS_BreakPoint; + } Fini = ((!rev && av1v2 < ta) || (rev && (M_PI - av1v2) < ta)); } } @@ -1037,7 +1125,9 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, { OnAjoute = ((!rev && av1v2 < M_PI / 2) || (rev && av1v2 > M_PI / 2)); if (OnAjoute && (degeneOnEc || TangentOnVertex(FVEc, Ev, myEFMap, ta))) + { OnAjoute = ((!rev && av1v2 < ta) || (rev && (M_PI - av1v2) < ta)); + } } if (OnAjoute) { @@ -1071,7 +1161,9 @@ bool ChFi3d_Builder::PerformElement(const occ::handle& Spine, { } if (Nbface > 1) + { CurSt = ChFiDS_BreakPoint; + } Fini = ((!rev && av1v2 < ta) || (rev && (M_PI - av1v2) < ta)); } } @@ -1126,7 +1218,9 @@ int ChFi3d_Builder::NbElements() const { const occ::handle& sp = itel.Value()->Spine(); if (sp.IsNull()) + { break; + } i++; } return i; @@ -1142,11 +1236,15 @@ int ChFi3d_Builder::Contains(const TopoDS_Edge& E) const { const occ::handle& sp = itel.Value()->Spine(); if (sp.IsNull()) + { break; + } for (j = 1; j <= sp->NbEdges(); j++) { if (E.IsSame(sp->Edges(j))) + { return i; + } } } return 0; @@ -1163,7 +1261,9 @@ int ChFi3d_Builder::Contains(const TopoDS_Edge& E, int& IndexInSpine) const { const occ::handle& sp = itel.Value()->Spine(); if (sp.IsNull()) + { break; + } for (j = 1; j <= sp->NbEdges(); j++) { if (E.IsSame(sp->Edges(j))) diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_2.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_2.cxx index af09efea7e..2caef49094 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_2.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_2.cxx @@ -172,13 +172,19 @@ static void ChFi3d_CoupeParPlan(const ChFiDS_CommonPoint& compoint1, Parfin = C3d->LastParameter(); } else + { plane = false; + } } else + { plane = false; + } } else + { plane = false; + } } //================================================================================================= @@ -272,7 +278,9 @@ static bool BonVoisin(const gp_Pnt& Point, } } else + { PC = getCurveOnSurface(newe, ff); + } PC->Value(winter).Coord(XDep, YDep); if (issame) { @@ -301,7 +309,9 @@ static bool BonVoisin(const gp_Pnt& Point, } } if (!found) + { bonvoisin = false; + } return bonvoisin; } @@ -318,7 +328,9 @@ static bool Projection(Extrema_ExtPC& PExt, // It is checked if it is not already a solution if (Dist2 < Tol * Tol) + { return true; + } bool Ok = false; @@ -333,7 +345,9 @@ static bool Projection(Extrema_ExtPC& PExt, Dist2 = daux2; Ok = true; if (Dist2 < Tol * Tol) + { return true; + } } } @@ -366,7 +380,9 @@ static void TgtKP(const occ::handle& CD, double wtg = CD->InterferenceOnS1().Parameter(isfirst); const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge); if (Spine->Edges(iedge).Orientation() == TopAbs_FORWARD) + { bc.D1(wtg + bc.FirstParameter(), ped, ded); + } else { bc.D1(-wtg + bc.LastParameter(), ped, ded); @@ -415,7 +431,9 @@ static bool IsInput(const gp_Vec& Vec, const TopoDS_Vertex& Ve, const TopoDS_Fac } } if (Trouve < 2) + { return false; + } // Calculate the normal and the angles in the associated vector plane gp_Vec Normal; Normal = Vec3d[0] ^ Vec3d[1]; @@ -432,7 +450,9 @@ static bool IsInput(const gp_Vec& Vec, const TopoDS_Vertex& Ve, const TopoDS_Fac amax = 0; } else + { amin = 0; + } // Projection of the vector gp_Ax3 Axe(Point, Normal, Vec3d[0]); @@ -545,15 +565,23 @@ static int SearchFaceOnV(const ChFiDS_CommonPoint& Pc, } } if (Trouve) + { Trouve = IsG1(EFMap, E, FRef, FVoi); + } if (Trouve) + { Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi); + } if (Trouve) { if (Num == 0) + { F1 = FVoi; + } else + { F2 = FVoi; + } Num++; } } @@ -590,10 +618,12 @@ static void ChangeTransition(const ChFiDS_CommonPoint& Pre } if (tochange) + { Courant.SetArc(Precision::Confusion(), Arc, Precedant.ParameterOnArc(), TopAbs::Reverse(Precedant.TransitionOnArc())); + } } } // namespace @@ -832,9 +862,13 @@ void ChFi3d_Builder::ConexFaces(const occ::handle& Spine, occ::handle& HS2) const { if (HS1.IsNull()) + { HS1 = new BRepAdaptor_Surface(); + } if (HS2.IsNull()) + { HS2 = new BRepAdaptor_Surface(); + } BRepAdaptor_Surface& Sb1 = *HS1; BRepAdaptor_Surface& Sb2 = *HS2; @@ -878,7 +912,9 @@ void ChFi3d_Builder::StartSol(const occ::handle& Stripe, int nbed = Spine->NbEdges(); int nbessaimax = 3 * nbed; if (nbessaimax < 10) + { nbessaimax = 10; + } double unsurnbessaimax = 1. / nbessaimax; double wf = 0.9981 * Spine->FirstParameter(1) + 0.0019 * Spine->LastParameter(1); double wl = 0.9973 * Spine->LastParameter(nbed) + 0.0027 * Spine->FirstParameter(nbed); @@ -955,7 +991,9 @@ void ChFi3d_Builder::StartSol(const occ::handle& Stripe, } } if (f1.IsSame(f2)) + { cured.Orientation(TopAbs_REVERSED); + } PC = getCurveOnSurface(cured, f2forward); P2 = PC->Value(woned); const occ::handle& HSon2 = HS2; // to avoid ambiguity @@ -1061,7 +1099,9 @@ void ChFi3d_Builder::StartSol(const occ::handle& Stripe, } } if (found) + { return; + } } } Spine->SetErrorStatus(ChFiDS_StartsolFailure); @@ -1434,9 +1474,13 @@ bool ChFi3d_Builder::StartSol( pons = HC->Value(W); HCref->Initialize(anArcEdge, F); if (aCommonPoint.IsVertex()) + { RecP = true; + } else + { RecRst = true; + } return true; } else @@ -1463,9 +1507,13 @@ bool ChFi3d_Builder::StartSol( HS->Initialize(F); const ChFiDS_FaceInterference& FI = SD->Interference(ons); if (FI.PCurveOnFace().IsNull()) + { pons = SD->Get2dPoints(isfirst, ons); + } else + { pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst)); + } } return true; } @@ -1479,7 +1527,9 @@ bool ChFi3d_Builder::SearchFace(const occ::handle& Spine, { bool Trouve = false; if (!Pc.IsOnArc()) + { return false; + } FVoi.Nullify(); TopoDS_Edge E; if (Pc.IsVertex()) @@ -1530,7 +1580,9 @@ bool ChFi3d_Builder::SearchFace(const occ::handle& Spine, } } if (Trouve) + { FindFace = IsG1(myEFMap, E, FRef, FVoi); + } if (FindFace) { FindFace = false; @@ -1692,15 +1744,21 @@ static void ChFi3d_SingularExtremity(occ::handle& stripe, static bool IsFree(const TopoDS_Shape& E, const ChFiDS_Map& EFMap) { if (!EFMap.Contains(E)) + { return false; + } NCollection_List::Iterator It; TopoDS_Shape Fref; for (It.Initialize(EFMap(E)); It.More(); It.Next()) { if (Fref.IsNull()) + { Fref = It.Value(); + } else if (!Fref.IsSame(It.Value())) + { return false; + } } return true; } @@ -1774,9 +1832,13 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, ChFi3d_EnlargeBox(DStr, Stripe, SDF, b1, b2, true); ChFi3d_EnlargeBox(DStr, Stripe, SDL, b1, b2, false); if (!CV1.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b1, Stripe->IndexFirstPointOnS1()); + } if (!CV2.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b2, Stripe->IndexFirstPointOnS2()); + } } else { @@ -1833,6 +1895,7 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, Parfin, plane); if (!plane) + { ChFi3d_ComputeArete(cpdeb1, SDdeb->InterferenceOnS1().PCurveOnSurf()->Value( SDdeb->InterferenceOnS1().FirstParameter()), @@ -1848,6 +1911,7 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, tol2d, tolreached, 0); + } TopOpeBRepDS_Curve Crv(C3d, tolreached); Stripe->ChangeFirstCurve(DStr.AddCurve(Crv)); Stripe->ChangeFirstParameters(Pardeb, Parfin); @@ -1863,9 +1927,13 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, } ChFi3d_EnlargeBox(DStr, Stripe, SDdeb, b1, b2, true); if (!cpdeb1.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b1, Stripe->IndexFirstPointOnS1()); + } if (!cpdeb2.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b2, Stripe->IndexFirstPointOnS2()); + } } else { // Case of a singular extremity @@ -1918,6 +1986,7 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, Parfin, plane); if (!plane) + { ChFi3d_ComputeArete(cpfin1, SDfin->InterferenceOnS1().PCurveOnSurf()->Value( SDfin->InterferenceOnS1().LastParameter()), @@ -1933,6 +2002,7 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, tol2d, tolreached, 0); + } TopOpeBRepDS_Curve Crv(C3d, tolreached); Stripe->ChangeLastCurve(DStr.AddCurve(Crv)); Stripe->ChangeLastParameters(Pardeb, Parfin); @@ -1948,9 +2018,13 @@ static void ChFi3d_MakeExtremities(occ::handle& Stripe, } ChFi3d_EnlargeBox(DStr, Stripe, SDfin, b1, b2, false); if (!cpfin1.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b1, Stripe->IndexLastPointOnS1()); + } if (!cpfin2.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, b2, Stripe->IndexLastPointOnS2()); + } } else { // Case of the single extremity @@ -1979,33 +2053,49 @@ static void ChFi3d_Purge(occ::handle& Stripe, int& intl) { if (isfirst) + { intf = 1; + } else + { intl = 1; // End. + } int opp = 3 - ons; if (!SD->Vertex(isfirst, opp).IsOnArc() || SD->TwistOnS1() || SD->TwistOnS2()) { NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); if (isfirst) + { Seq.Remove(1); + } else + { Seq.Remove(Seq.Length()); + } return; } if (ons == 1) + { SD->ChangeIndexOfS1(0); + } else + { SD->ChangeIndexOfS2(0); + } SD->ChangeVertex(!isfirst, ons) = VRef; SD->ChangeVertex(isfirst, ons) = VRef; ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons); if (isfirst) + { fi.SetFirstParameter(fi.LastParameter()); + } else + { fi.SetLastParameter(fi.FirstParameter()); + } fi.SetLineIndex(0); } @@ -2020,7 +2110,9 @@ static void InsertAfter(occ::handle& Stripe, occ::handle& Item) { if (Ref == Item) + { throw Standard_Failure("InsertAfter : twice the same surfdata."); + } NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); @@ -2048,12 +2140,16 @@ static void RemoveSD(occ::handle& Stripe, NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); if (Seq.IsEmpty()) + { return; + } int iprev = 0, inext = 0; for (int i = 1; i <= Seq.Length(); i++) { if (Seq.Value(i) == Prev) + { iprev = i + 1; + } if (Seq.Value(i) == Next) { inext = i - 1; @@ -2061,11 +2157,17 @@ static void RemoveSD(occ::handle& Stripe, } } if (Prev.IsNull()) + { iprev = 1; + } if (Next.IsNull()) + { inext = Seq.Length(); + } if (iprev <= inext) + { Seq.Remove(iprev, inext); + } } //======================================================================= @@ -2079,7 +2181,9 @@ static void InsertBefore(occ::handle& Stripe, occ::handle& Item) { if (Ref == Item) + { throw Standard_Failure("InsertBefore : twice the same surfdata."); + } NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); @@ -2119,7 +2223,9 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle { const occ::handle& aHElSpine = ILES.Value(); if (aHElSpine == HGuide) + { OffsetHGuide = ILES_offset.Value(); + } } } @@ -2263,13 +2369,17 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle { Guide.FirstParameter(wf); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->FirstParameter(wf); + } } else { Guide.LastParameter(wl); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->LastParameter(wl); + } } } } @@ -2280,7 +2390,9 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle int indf = Spine->Index(wf); int indl = Spine->Index(wl, false); if (Spine->IsPeriodic() && (indl < indf)) + { indl += nbed; + } nbed = indl - indf + 1; } // No Max at the touch : 20 points by edge at average without @@ -2310,36 +2422,52 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle if (wf < tolesp && (complete == Inside)) { if (Spine->FirstStatus() == ChFiDS_OnSame) + { intf = 2; + } else + { intf = 1; + } } if (Spine->IsTangencyExtremity(true)) { intf = 4; Guide.FirstParameter(wfsav); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->FirstParameter(wfsav); + } } if (wl - lastedlastp > -tolesp) { if (Spine->LastStatus() == ChFiDS_OnSame) + { intl = 2; + } else + { intl = 1; + } } if (Spine->IsTangencyExtremity(false)) { intl = 4; Guide.LastParameter(wlsav); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->LastParameter(wlsav); + } } } if (intf && !forward) + { Vref = Spine->FirstVertex(); + } if (intl && forward) + { Vref = Spine->LastVertex(); + } if (!ref.IsNull()) { Ok1 = StartSol(Spine, @@ -2387,28 +2515,42 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle if ((intf && !forward) || (intl && forward)) { if (!Ok1) + { ChFi3d_BuildPlane(DStr, HS1, pp1, ref, !forward, 1); + } if (!Ok2) + { ChFi3d_BuildPlane(DStr, HS2, pp2, ref, !forward, 2); + } if (intf) + { intf = 5; + } else if (intl) + { intl = 5; + } if (forward) { Guide.FirstParameter(wf); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->FirstParameter(wf); + } } else { Guide.LastParameter(wl); if (!OffsetHGuide.IsNull()) + { OffsetHGuide->LastParameter(wl); + } } } else + { throw Standard_Failure("PerformSetOfSurfOnElSpine : Chaining is impossible."); + } } // Definition of the domain of patch It1, It2 @@ -2434,9 +2576,13 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle // Calculate the criterion of Choice edge / edge if (Choix % 2 == 0) + { Choix = 4; + } else + { Choix = 1; + } SoldepCC(1) = w1; SoldepCC(2) = w2; @@ -2520,9 +2666,13 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle Stripe->OrientationOnFace2(), -Stripe->Choix()); if (Choix % 2 == 1) + { Choix++; + } else + { Choix--; + } SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y(); @@ -2703,9 +2853,13 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle done = true; Inside = false; if (forward) + { intl = 1; + } else + { intf = 1; + } } else { // Otherwise invalidation of the stripe. @@ -2724,10 +2878,14 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle SD = SeqSD(ii); SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face())); if (obstacleon1) + { SD->SetIndexOfC1(DStr.AddShape(HC1->Edge())); + } SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face())); if (obstacleon2) + { SD->SetIndexOfC2(DStr.AddShape(HC2->Edge())); + } InsertAfter(Stripe, refbis, SD); refbis = SD; } @@ -2739,22 +2897,30 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle SD = SeqSD(ii); SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face())); if (obstacleon1) + { SD->SetIndexOfC1(DStr.AddShape(HC1->Edge())); + } SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face())); if (obstacleon2) + { SD->SetIndexOfC2(DStr.AddShape(HC2->Edge())); + } InsertBefore(Stripe, refbis, SD); refbis = SD; } } if (!Ok1 && !obstacleon1) + { // clean infos on the plane of extension. ChFi3d_Purge(Stripe, SD, ref->Vertex(!forward, 1), !forward, 1, intf, intl); + } if (!Ok2 && !obstacleon2) + { // clean infos on the plane of extension. ChFi3d_Purge(Stripe, SD, ref->Vertex(!forward, 2), !forward, 2, intf, intl); + } // The end. The reference is changed. ref = refbis; @@ -2785,12 +2951,18 @@ void ChFi3d_Builder::PerformSetOfSurfOnElSpine(const occ::handle thelast = Stripe->SetOfSurfData()->Sequence().Last(); if (thefirst->VertexFirstOnS1().IsOnArc() && thelast->VertexLastOnS1().IsOnArc()) + { fini = thefirst->VertexFirstOnS1().Arc().IsSame(thelast->VertexLastOnS1().Arc()); + } if (!fini && thefirst->VertexFirstOnS2().IsOnArc() && thelast->VertexLastOnS2().IsOnArc()) + { fini = thefirst->VertexFirstOnS2().Arc().IsSame(thelast->VertexLastOnS2().Arc()); + } if (fini) + { return; // It is ended! + } } if (fini && complete) @@ -2903,7 +3075,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const LSD.Clear(); } else + { iedgelastkpart = iedge; + } if (Spine->IsPeriodic()) { // debug provisory for SD that arrive in disorder. int nbsd = LSD.Length(); @@ -2920,7 +3094,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const wwf = ChFi3d_InPeriod(wwf, wfp, wlp, tolesp); wwl = ChFi3d_InPeriod(wwl, wfp, wlp, tolesp); if (wwl <= wwf + tolesp) + { wwl += period; + } wfp = wwf; wlp = wfp + period; } @@ -2947,10 +3123,14 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const { occ::handle& curSD = LSD.ChangeValue(j); if (Simul) + { SimulKPart(curSD); + } SeqSurf.Append(curSD); if (!Simul) + { li.Append(curSD->Surf()); + } WFirst = LSD.Value(j)->FirstSpineParam(); WLast = LSD.Value(j)->LastSpineParam(); if (Spine->IsPeriodic()) @@ -2958,7 +3138,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const WFirst = ChFi3d_InPeriod(WFirst, WStartPeriodic, WEndPeriodic, tolesp); WLast = ChFi3d_InPeriod(WLast, WStartPeriodic, WEndPeriodic, tolesp); if (WLast <= WFirst + tolesp) + { WLast += Spine->Period(); + } } TgtKP(LSD.Value(j), Spine, iedge, true, PFirst, TFirst); TgtKP(LSD.Value(j), Spine, iedge, false, PLast, TLast); @@ -2972,7 +3154,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const WEndPeriodic = WStartPeriodic + Spine->Period(); WLast = ElCLib::InPeriod(WLast, WStartPeriodic, WEndPeriodic); if (WLast <= WFirst + tolesp) + { WLast += Spine->Period(); + } PEndPeriodic = PFirst; TEndPeriodic = TFirst; Spine->SetFirstParameter(WStartPeriodic); @@ -3029,7 +3213,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const } } if (!li.IsEmpty()) + { myEVIMap.Bind(Spine->Edges(iedge), li); + } } } @@ -3045,13 +3231,17 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const CurrentHE->LastParameter(WEndPeriodic); CurrentHE->SetLastPointAndTgt(PEndPeriodic, TEndPeriodic); if (!YaKPart) + { CurrentHE->SetPeriodic(true); + } Spine->AppendElSpine(CurrentHE); CurrentOffsetHE->LastParameter(WEndPeriodic); CurrentOffsetHE->SetLastPointAndTgt(PEndPeriodic, TEndPeriodic); if (!YaKPart) + { CurrentOffsetHE->SetPeriodic(true); + } Spine->AppendOffsetElSpine(CurrentOffsetHE); } } @@ -3082,7 +3272,9 @@ void ChFi3d_Builder::PerformSetOfKPart(occ::handle& Stripe, const { NCollection_List>& offsetll = Spine->ChangeOffsetElSpines(); for (ILES.Initialize(offsetll); ILES.More(); ILES.Next()) + { ChFi3d_PerformElSpine(ILES.ChangeValue(), Spine, myConti, tolesp, true); + } } Spine->SplitDone(true); } @@ -3124,7 +3316,9 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const int last = len, i; bool periodic = Spine->IsPeriodic(); if (periodic) + { last++; + } // It is attempted to reprocess the squares that bore. for (i = 1; i <= len; i++) { @@ -3136,22 +3330,30 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const if (iprev == 0) { if (periodic) + { iprev = len; + } } int inext = i + 1; if (inext > len) { if (periodic) + { inext = 1; + } else + { inext = 0; + } } // For the moment only the surfaces where the twist is // detected at the path are corrected, it is necessary to control // more subtly the ugly traces (size, curvature, inflexion... ) if (!tw1 && !tw2) + { continue; + } // It is decided (fairly at random) if the extended surface is ready for the filling. ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1(); @@ -3195,10 +3397,14 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const nextsd = SeqSurf.ChangeValue(inext); yanexton1 = !nextsd->TwistOnS1(); if (samesurfon1) + { samesurfon1 = (nextsd->IndexOfS1() == cursurf1); + } yanexton2 = !nextsd->TwistOnS2(); if (samesurfon2) + { samesurfon2 = (nextsd->IndexOfS2() == cursurf2); + } } // A contour of filling is constructed occ::handle PC1 = intf1.PCurveOnFace(); @@ -3379,11 +3585,17 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const GeomFill_ConstrainedFilling fil(11, 20); if (pointuon1) + { fil.Init(Bon2, Bfin, Bdeb, true); + } else if (pointuon2) + { fil.Init(Bon1, Bfin, Bdeb, true); + } else + { fil.Init(Bon1, Bfin, Bon2, Bdeb, true); + } ChFi3d_ReparamPcurv(0., 1., PC1); ChFi3d_ReparamPcurv(0., 1., PC2); @@ -3420,7 +3632,9 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const false, false); if (pointuon2) + { cursd->ChangeIndexOfS2(0); + } } if (tw1) { @@ -3444,51 +3658,75 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1(); ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1(); if (cursd->IsOnCurve1()) + { curs1 = cursd->IndexOfC1(); + } else + { curs1 = cursd->IndexOfS1(); + } if (cursd->IsOnCurve2()) + { curs2 = cursd->IndexOfC2(); + } else + { curs2 = cursd->IndexOfS2(); + } double tol1 = std::max(curp1.Tolerance(), nextp1.Tolerance()); ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2(); ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2(); double tol2 = std::max(curp2.Tolerance(), nextp2.Tolerance()); if (nextsd->IsOnCurve1()) + { nexts1 = nextsd->IndexOfC1(); + } else + { nexts1 = nextsd->IndexOfS1(); + } if (nextsd->IsOnCurve2()) + { nexts2 = nextsd->IndexOfC2(); + } else + { nexts2 = nextsd->IndexOfS2(); + } if (!curp1.IsOnArc() && nextp1.IsOnArc()) { curp1 = nextp1; if ((curs1 == nexts1) && !nextsd->IsOnCurve1()) + { // Case when it is not possible to pass along the border without leaving ChangeTransition(nextp1, curp1, nexts1, myDS); + } } else if (curp1.IsOnArc() && !nextp1.IsOnArc()) { nextp1 = curp1; if ((curs1 == nexts1) && !cursd->IsOnCurve1()) + { ChangeTransition(curp1, nextp1, curs1, myDS); + } } if (!curp2.IsOnArc() && nextp2.IsOnArc()) { curp2 = nextp2; if ((curs2 == nexts2) && !nextsd->IsOnCurve2()) + { ChangeTransition(nextp2, curp2, curs2, myDS); + } } else if (curp2.IsOnArc() && !nextp2.IsOnArc()) { nextp2 = curp2; if ((curs2 == nexts2) && !cursd->IsOnCurve2()) + { ChangeTransition(curp2, nextp2, curs2, myDS); + } } curp1.SetTolerance(tol1); @@ -3533,7 +3771,9 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const nwl = ElCLib::InPeriod(WL, tolesp, period + tolesp); IL = Spine->Index(nwl, false); if (nwl < nwf + tolesp) + { IL += nbed; + } } else { @@ -3545,7 +3785,9 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const // fast processing int IFloc = IF; if (periodic) + { IFloc = (IF - 1) % nbed + 1; + } const TopoDS_Edge& Ej = Spine->Edges(IFloc); for (i = 1; i <= len; i++) { @@ -3553,7 +3795,9 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const double fp = cursd->FirstSpineParam(); double lp = cursd->LastSpineParam(); if (lp < WF + tolesp || fp > WL - tolesp) + { continue; + } if (!myEVIMap.IsBound(Ej)) { NCollection_List li; @@ -3569,10 +3813,14 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const { int iloc = i; if (periodic) + { iloc = (i - 1) % nbed + 1; + } double wi = Spine->LastParameter(iloc); if (periodic) + { wi = ElCLib::InPeriod(wi, WF, WF + period); + } gp_Pnt pv = Spine->Value(wi); Extrema_LocateExtPC ext(pv, *curhels, wi, 1.e-8); wv(i) = wi; @@ -3589,24 +3837,32 @@ void ChFi3d_Builder::PerformSetOfKGen(occ::handle& Stripe, const int j; int jf = 0, jl = 0; if (lp < WF + tolesp || fp > WL - tolesp) + { continue; + } for (j = IF; j < IL; j++) { jf = j; if (fp < wv(j) - tolesp) + { break; + } } for (j = IF; j < IL; j++) { jl = j; if (lp < wv(j) + tolesp) + { break; + } } for (j = jf; j <= jl; j++) { int jloc = j; if (periodic) + { jloc = (j - 1) % nbed + 1; + } const TopoDS_Edge& Ej = Spine->Edges(jloc); if (!myEVIMap.IsBound(Ej)) { @@ -3631,10 +3887,14 @@ void ChFi3d_Builder::PerformSetOfSurf(occ::handle& Stripe, const int SI = ChFi3d_SolidIndex(sp, DStr, myESoMap, myEShMap); Stripe->SetSolidIndex(SI); if (!sp->SplitDone()) + { PerformSetOfKPart(Stripe, Simul); + } PerformSetOfKGen(Stripe, Simul); if (!Simul) + { ChFi3d_MakeExtremities(Stripe, DStr, myEFMap, tolapp3d, tol2d); + } } diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_6.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_6.cxx index 6df0cb9c5d..b4d23e9a8a 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_6.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_6.cxx @@ -96,7 +96,9 @@ static int SearchIndex(const double Value, occ::handle& Lin) int NbPnt = Lin->NbPoints(), Ind; for (Ind = 1; (Ind < NbPnt) && (Lin->Point(Ind).Parameter() < Value);) + { Ind++; + } return Ind; } @@ -120,7 +122,9 @@ static int nbedconnex(const NCollection_List& L) } } if (!dejavu) + { nb++; + } } return nb; } @@ -133,13 +137,19 @@ static bool IsVois(const TopoDS_Edge& E, const int profmax) { if (prof > profmax) + { return false; + } if (DONE.Contains(E)) + { return false; + } TopoDS_Vertex V1, V2; TopExp::Vertices(E, V1, V2); if (Vref.IsSame(V1) || Vref.IsSame(V2)) + { return true; + } DONE.Add(E); const NCollection_List& L1 = VEMap(V1); int i1 = nbedconnex(L1); @@ -150,10 +160,14 @@ static bool IsVois(const TopoDS_Edge& E, if (i1 <= 2) { if (IsVois(curE, Vref, VEMap, DONE, prof, profmax)) + { return true; + } } else if (IsVois(curE, Vref, VEMap, DONE, prof + 1, profmax)) + { return true; + } } const NCollection_List& L2 = VEMap(V2); #ifdef OCCT_DEBUG @@ -166,10 +180,14 @@ static bool IsVois(const TopoDS_Edge& E, if (i1 <= 2) { if (IsVois(curE, Vref, VEMap, DONE, prof, profmax)) + { return true; + } } else if (IsVois(curE, Vref, VEMap, DONE, prof + 1, profmax)) + { return true; + } } return false; } @@ -177,7 +195,9 @@ static bool IsVois(const TopoDS_Edge& E, static bool IsObst(const ChFiDS_CommonPoint& CP, const TopoDS_Vertex& Vref, const ChFiDS_Map& VEMap) { if (!CP.IsOnArc()) + { return false; + } const TopoDS_Edge& E = CP.Arc(); NCollection_Map DONE; int prof = 4; @@ -270,9 +290,13 @@ static void CompParam(const Geom2dAdaptor_Curve& Carc, { // It is checked if everything was calculated correctly (EDC402 C2) if (projector.LowerDistance() < distini) + { ptg = projector.LowerDistanceParameter(); + } else + { ptg = preftg; + } } } } @@ -299,12 +323,16 @@ static bool CompBlendPoint(const TopoDS_Vertex& V, param = BRep_Tool::Parameter(V, E, F1); pc = BRep_Tool::CurveOnSurface(E, F1, f, l); if (pc.IsNull()) + { return false; + } P1 = pc->Value(param); param = BRep_Tool::Parameter(V, E, F2); pc = BRep_Tool::CurveOnSurface(E, F2, f, l); if (pc.IsNull()) + { return false; + } P2 = pc->Value(param); BP.SetValue(P3d, P3d, W, P1.X(), P1.Y(), P2.X(), P2.Y()); return true; @@ -383,18 +411,28 @@ bool ChFi3d_Builder::CompleteData(occ::handle& Data, double UFirst, ULast, VFirst, VLast; Surfcoin->Bounds(UFirst, ULast, VFirst, VLast); if (!Gd1) + { Data->ChangeVertexFirstOnS1().SetPoint(Surfcoin->Value(UFirst, VFirst)); + } if (!Gd2) + { Data->ChangeVertexFirstOnS2().SetPoint(Surfcoin->Value(UFirst, VLast)); + } if (!Gf1) + { Data->ChangeVertexLastOnS1().SetPoint(Surfcoin->Value(ULast, VFirst)); + } if (!Gf2) + { Data->ChangeVertexLastOnS2().SetPoint(Surfcoin->Value(ULast, VLast)); + } // calculate curves side S1 occ::handle Crv3d1; if (!PC1.IsNull()) + { Crv3d1 = Surfcoin->VIso(VFirst); + } gp_Pnt2d pd1(UFirst, VFirst), pf1(ULast, VFirst); gp_Lin2d lfil1(pd1, gp_Dir2d(gp_Vec2d(pd1, pf1))); occ::handle PCurveOnSurf = new Geom2d_Line(lfil1); @@ -415,9 +453,13 @@ bool ChFi3d_Builder::CompleteData(occ::handle& Data, Surfcoin->D1(w, VFirst, p, du, dv); gp_Vec ns = du.Crossed(dv); if (nf.Dot(ns) > 0.) + { tra1 = TopAbs_REVERSED; + } else if (On1) + { orsurf = TopAbs::Reverse(orsurf); + } } int Index1OfCurve = DStr.AddCurve(TopOpeBRepDS_Curve(Crv3d1, tolreached)); ChFiDS_FaceInterference& Fint1 = Data->ChangeInterferenceOnS1(); @@ -427,7 +469,9 @@ bool ChFi3d_Builder::CompleteData(occ::handle& Data, // calculate curves side S2 occ::handle Crv3d2; if (!PC2.IsNull()) + { Crv3d2 = Surfcoin->VIso(VLast); + } gp_Pnt2d pd2(UFirst, VLast), pf2(ULast, VLast); gp_Lin2d lfil2(pd2, gp_Dir2d(gp_Vec2d(pd2, pf2))); PCurveOnSurf = new Geom2d_Line(lfil2); @@ -446,7 +490,9 @@ bool ChFi3d_Builder::CompleteData(occ::handle& Data, { tra2 = TopAbs_REVERSED; if (!On1) + { orsurf = TopAbs::Reverse(orsurf); + } } } int Index2OfCurve = DStr.AddCurve(TopOpeBRepDS_Curve(Crv3d2, tolreached)); @@ -597,7 +643,9 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, // Small control tools. static occ::handle checkcurve; if (checkcurve.IsNull()) + { checkcurve = new GeomAdaptor_Curve(); + } GeomAdaptor_Curve& chc = *checkcurve; double tolget3d, tolget2d, tolaux, tolC1, tolcheck; double tolC2 = 0.; @@ -738,7 +786,9 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, pppdeb = utg; } else + { pppdeb = VFirst; + } if (Gf1) { TopoDS_Face forwfac = BS1->Face(); @@ -752,15 +802,21 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, pppfin = utg; } else + { pppfin = VLast; + } ChFiDS_FaceInterference& Fint1 = Data->ChangeInterferenceOnS1(); Fint1.SetFirstParameter(pppdeb); Fint1.SetLastParameter(pppfin); TopAbs_Orientation TraOn1; if (Reversed) + { TraOn1 = ChFi3d_TrsfTrans(lin->TransitionOnS2()); + } else + { TraOn1 = ChFi3d_TrsfTrans(lin->TransitionOnS1()); + } Fint1.SetInterference(Index1OfCurve, TraOn1, PCurveOnFace, PCurveOnSurf); // SurfData is filled in what concerns S2, @@ -798,7 +854,9 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, pppdeb = utg; } else + { pppdeb = VFirst; + } if (Gf2) { TopoDS_Face forwfac = BS2->Face(); @@ -812,7 +870,9 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, pppfin = utg; } else + { pppfin = VLast; + } ChFiDS_FaceInterference& Fint2 = Data->ChangeInterferenceOnS2(); Fint2.SetFirstParameter(pppdeb); Fint2.SetLastParameter(pppfin); @@ -820,9 +880,13 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, { TopAbs_Orientation TraOn2; if (Reversed) + { TraOn2 = ChFi3d_TrsfTrans(lin->TransitionOnS1()); + } else + { TraOn2 = ChFi3d_TrsfTrans(lin->TransitionOnS2()); + } Fint2.SetInterference(Index2OfCurve, TraOn2, PCurveOnFace, PCurveOnSurf); } else @@ -868,7 +932,9 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, Du1.Cross(Dv1); if (Or1 == TopAbs_REVERSED) + { Du1.Reverse(); + } Surf->D1(UFirst, aParam, P, Du2, Dv2); Du2.Cross(Dv2); @@ -878,44 +944,58 @@ bool ChFi3d_Builder::StoreData(occ::handle& Data, aDenom++; if (std::abs(aDeltav) <= tolget2d) + { return false; + } continue; } if (Du1.Dot(Du2) > 0) + { Data->ChangeOrientation() = TopAbs_FORWARD; + } else + { Data->ChangeOrientation() = TopAbs_REVERSED; + } break; } // Modified by skv - Wed Jun 9 17:16:26 2004 OCC5898 End if (!Gd1 && !S1.IsNull()) + { ChFi3d_FilCommonPoint(lin->StartPointOnFirst(), lin->TransitionOnS1(), true, Data->ChangeVertex(true, ion1), tolC1); + } if (!Gf1 && !S1.IsNull()) + { ChFi3d_FilCommonPoint(lin->EndPointOnFirst(), lin->TransitionOnS1(), false, Data->ChangeVertex(false, ion1), tolC1); + } if (!Gd2 && !S2.IsNull()) + { ChFi3d_FilCommonPoint(lin->StartPointOnSecond(), lin->TransitionOnS2(), true, Data->ChangeVertex(true, ion2), tolC2); + } if (!Gf2 && !S2.IsNull()) + { ChFi3d_FilCommonPoint(lin->EndPointOnSecond(), lin->TransitionOnS2(), false, Data->ChangeVertex(false, ion2), tolC2); + } // Parameters on ElSpine int nbp = lin->NbPoints(); Data->FirstSpineParam(lin->Point(1).Parameter()); @@ -965,7 +1045,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, double SpLast = HGuide->LastParameter(); double Target = SpLast; if (reverse) + { Target = SpFirst; + } double Targetsov = Target; double MS = MaxStep; @@ -1075,9 +1157,13 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, } } if (Forward) + { Decroch = TheWalk.DecrochEnd(); + } else + { Decroch = TheWalk.DecrochStart(); + } Last = Lin->Point(Nbpnt).Parameter(); First = Lin->Point(1).Parameter(); return true; @@ -1129,7 +1215,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, double SpLast = HGuide->LastParameter(); double Target = SpLast; if (reverse) + { Target = SpFirst; + } double Targetsov = Target; double MS = MaxStep; @@ -1292,7 +1380,9 @@ bool ChFi3d_Builder::SimulData(occ::handle& /*Data*/, double SpLast = HGuide->LastParameter(); double Target = SpLast; if (reverse) + { Target = SpFirst; + } double Targetsov = Target; double MS = MaxStep; @@ -1397,9 +1487,13 @@ bool ChFi3d_Builder::SimulData(occ::handle& /*Data*/, } } if (Forward) + { Decroch = TheWalk.DecrochEnd(); + } else + { Decroch = TheWalk.DecrochStart(); + } Last = Lin->Point(Nbpnt).Parameter(); First = Lin->Point(1).Parameter(); return true; @@ -1450,7 +1544,9 @@ bool ChFi3d_Builder::SimulData(occ::handle& /*Data*/, double SpLast = HGuide->LastParameter(); double Target = SpLast; if (reverse) + { Target = SpFirst; + } double Targetsov = Target; double MS = MaxStep; @@ -1617,7 +1713,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, { const occ::handle& aHElSpine = ILES.Value(); if (aHElSpine == HGuide) + { OffsetHGuide = ILES_offset.Value(); + } } } @@ -1630,10 +1728,14 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, TopoDS_Face F1, F2; occ::handle HS = occ::down_cast(S1); if (!HS.IsNull()) + { F1 = HS->Face(); + } HS = occ::down_cast(S2); if (!HS.IsNull()) + { F2 = HS->Face(); + } // Path framing variables double TolGuide = tolguide; @@ -1659,13 +1761,17 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, { Target = SpFirst; if (!intf) + { Target = Last; + } } else { Target = SpLast + std::abs(SpLast); if (!intl) + { Target = Last; + } } // In case if the singularity is pre-determined, @@ -1757,11 +1863,15 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, { // Path. if (!again && (MS < 5 * TolGuide)) + { MS = 5 * TolGuide; + } else { if (5 * TolGuide > MS) + { TolGuide = MS / 5; + } } TheWalk.Perform(Func, FInv, NewFirst, Target, MS, tolapp3d, TolGuide, ParSol, Fleche, Appro); if (!TheWalk.IsDone()) @@ -1788,7 +1898,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, } bool complmnt = true; if (Inside) + { complmnt = TheWalk.Complete(Func, FInv, SpLast); + } if (!complmnt) { #ifdef OCCT_DEBUG @@ -1987,11 +2099,17 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, } bool oncontinue = !noproldeb && (narc1 != 0 || narc2 != 0); if (debobst1 || debobst2) + { oncontinue = false; + } else if (debcas1 && debcas2) + { oncontinue = false; + } else if ((!debcas1 && debarc1) || (!debcas2 && debarc2)) + { oncontinue = false; + } if (oncontinue) { @@ -2008,7 +2126,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, if (!debarc1) { if (narc1 == 0) + { backwContinueFailed = Lin->StartPointOnFirst().ParameterOnGuide() > Target; + } else { ChFi3d_FilCommonPoint(Lin->StartPointOnFirst(), @@ -2036,7 +2156,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, if (!debarc2) { if (narc2 == 0) + { backwContinueFailed = Lin->StartPointOnSecond().ParameterOnGuide() > Target; + } else { ChFi3d_FilCommonPoint(Lin->StartPointOnSecond(), @@ -2068,7 +2190,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, // check this condition const ChFiDS_CommonPoint& aCP = debarc1 ? Data->VertexFirstOnS1() : Data->VertexFirstOnS2(); if (aCP.IsOnArc() && bif.IsNull()) + { backwContinueFailed = false; + } } } } @@ -2117,11 +2241,17 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, } bool oncontinue = !noprolfin && (narc1 != 0 || narc2 != 0); if (finobst1 || finobst2) + { oncontinue = false; + } else if (fincas1 && fincas2) + { oncontinue = false; + } else if ((!fincas1 && finarc1) || (!fincas2 && finarc2)) + { oncontinue = false; + } if (oncontinue) { @@ -2138,7 +2268,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, if (!finarc1) { if (narc1 == 0) + { forwContinueFailed = Lin->EndPointOnFirst().ParameterOnGuide() < Target; + } else { ChFi3d_FilCommonPoint(Lin->EndPointOnFirst(), @@ -2161,7 +2293,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, if (!finarc2) { if (narc2 == 0) + { forwContinueFailed = Lin->EndPointOnSecond().ParameterOnGuide() < Target; + } else { ChFi3d_FilCommonPoint(Lin->EndPointOnSecond(), @@ -2188,7 +2322,9 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, // check this condition const ChFiDS_CommonPoint& aCP = finarc1 ? Data->VertexLastOnS1() : Data->VertexLastOnS2(); if (aCP.IsOnArc() && bif.IsNull()) + { forwContinueFailed = false; + } } // modified by eap Fri Feb 8 11:45:10 2002 ___END___ } @@ -2210,14 +2346,20 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, double sortie; int ind; if (debarc1) + { sortie = Data->VertexFirstOnS1().Parameter(); + } else + { sortie = Data->VertexFirstOnS2().Parameter(); + } if (sortie - First > tolesp) { ind = SearchIndex(sortie, Lin); if (Lin->Point(ind).Parameter() == sortie) + { ind--; + } if (ind >= 1) { Lin->Remove(1, ind); @@ -2235,9 +2377,13 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, { ind = SearchIndex(sortie, Lin); if (Lin->Point(ind).Parameter() == sortie) + { ind--; + } if (Nbpnt - ind < 3) + { ind = Nbpnt - 3; + } if (ind >= 1) { Lin->Remove(1, ind); @@ -2254,17 +2400,23 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, Data->FirstExtensionValue(std::abs(Lin->Point(1).Parameter() - Target)); } if (intf && !unseulsuffitdeb) + { intf = (Gd1 && Gd2) //; || backwContinueFailed; // eap + } else if (intf && unseulsuffitdeb && (intf < 5)) { intf = (Gd1 || Gd2); // It is checked if there is no new face. if (intf && ((!debcas1 && debarc1) || (!debcas2 && debarc2))) + { intf = 0; + } } else if (intf < 5) + { intf = 0; + } } if (Forward && intl) @@ -2278,14 +2430,20 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, double sortie; int ind; if (finarc1) + { sortie = Data->VertexLastOnS1().Parameter(); + } else + { sortie = Data->VertexLastOnS2().Parameter(); + } if (Last - sortie > tolesp) { ind = SearchIndex(sortie, Lin); if (Lin->Point(ind).Parameter() == sortie) + { ind++; + } if (ind <= Nbpnt) { Lin->Remove(ind, Nbpnt); @@ -2304,9 +2462,13 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, { ind = SearchIndex(sortie, Lin); if (Lin->Point(ind).Parameter() == sortie) + { ind++; + } if (ind < 3) + { ind = 3; + } if (ind <= Nbpnt) { Lin->Remove(ind, Nbpnt); @@ -2324,16 +2486,22 @@ bool ChFi3d_Builder::ComputeData(occ::handle& Data, } if (intl && !unseulsuffitfin) + { intl = (Gf1 && Gf2) //; || forwContinueFailed; // eap + } else if (intl && unseulsuffitfin && (intl < 5)) { intl = (Gf1 || Gf2); // It is checked if there is no new face. if (intl && ((!fincas1 && finarc1) || (!fincas2 && finarc2))) + { intl = 0; + } } else if (intl < 5) + { intl = 0; + } } return true; } @@ -2418,11 +2586,15 @@ bool ChFi3d_Builder::SimulData(occ::handle& /*Data*/, // When the start point is inside, the path goes first to the left // to determine the Last for the periodicals. if (!again && (MS < 5 * TolGuide)) + { MS = 5 * TolGuide; + } else { if (5 * TolGuide > MS) + { TolGuide = MS / 5; + } } TheWalk.Perform(Func, FInv, NewFirst, Target, MS, tolapp3d, TolGuide, ParSol, Fleche, Appro); @@ -2451,7 +2623,9 @@ bool ChFi3d_Builder::SimulData(occ::handle& /*Data*/, } bool complmnt = true; if (Inside) + { complmnt = TheWalk.Complete(Func, FInv, SpLast); + } if (!complmnt) { #ifdef OCCT_DEBUG diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C1.cxx index 260288135e..d7195c799f 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C1.cxx @@ -123,11 +123,17 @@ static double recadre(const double p, { double pp = p; if (isfirst) + { pp -= (last - first); + } else + { pp += (last - first); + } if (std::abs(pp - ref) < std::abs(p - ref)) + { return pp; + } return p; } @@ -209,7 +215,9 @@ static bool Update(const occ::handle& fb, { w = Intersection.Point(i).W(); if (isperiodic) + { w = recadre(w, wop, isfirst, uf, ul); + } if (uf <= w && ul >= w && std::abs(w - wop) < dist) { isol = i; @@ -241,7 +249,9 @@ static bool Update(const occ::handle& fb, p2dbout.SetCoord(pint.U(), pint.V()); w = pint.W(); if (isperiodic) + { w = ElCLib::InPeriod(w, uf, ul); + } } else { @@ -300,19 +310,29 @@ static bool IntersUpdateOnSame(occ::handle& HGs, double ul = FIop.LastParameter(); occ::handle Hc3df; if (c3dFI->IsPeriodic()) + { Hc3df = new GeomAdaptor_Curve(c3dFI); + } else + { Hc3df = new GeomAdaptor_Curve(c3dFI, uf, ul); + } if (Update(HBs, Hc3df, FIop, CPop, FprolUV, isFirst, c3dU)) + { return true; + } if (!ChFi3d::IsTangentFaces(Eprol, Fprol, Fop)) + { return false; + } occ::handle gpcprol = BRep_Tool::CurveOnSurface(Eprol, Fprol, uf, ul); if (gpcprol.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } occ::handle pcprol = new Geom2dAdaptor_Curve(gpcprol); double partemp = BRep_Tool::Parameter(Vtx, Eprol); @@ -334,7 +354,9 @@ static bool Update(const occ::handle& face, const bool isfirst) { if (!cp.IsOnArc()) + { return false; + } Adaptor3d_CurveOnSurface c1(edonface, face); double pared = cp.ParameterOnArc(); double parltg = fi.Parameter(isfirst); @@ -362,20 +384,26 @@ static bool Update(const occ::handle& face, { occ::handle aTrCurve = occ::down_cast(PConF); if (!aTrCurve.IsNull()) + { PConF = aTrCurve->BasisCurve(); + } if (!PConF->IsPeriodic()) { if (isfirst) { double fpar = PConF->FirstParameter(); if (parltg < fpar) + { parltg = fpar; + } } else { double lpar = PConF->LastParameter(); if (parltg > lpar) + { parltg = lpar; + } } } } @@ -393,13 +421,17 @@ static bool Update(const occ::handle& face, static void ChFi3d_ExtendSurface(occ::handle& S, int& prol) { if (prol) + { return; + } prol = (S->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) ? 1 : S->IsKind(STANDARD_TYPE(Geom_BezierSurface)) ? 2 : 0); if (!prol) + { return; + } double length, umin, umax, vmin, vmax; gp_Pnt P1, P2; @@ -461,7 +493,9 @@ static void ChFi3d_Recale(const BRepAdaptor_Surface& Bs, occ::handle ts = occ::down_cast(surf); if (!ts.IsNull()) + { surf = ts->BasisSurface(); + } if (surf->IsUPeriodic()) { double u1 = p1.X(), u2 = p2.X(); @@ -469,13 +503,21 @@ static void ChFi3d_Recale(const BRepAdaptor_Surface& Bs, if (fabs(u2 - u1) > 0.5 * uper) { if (u2 < u1 && refon1) + { u2 += uper; + } else if (u2 < u1 && !refon1) + { u1 -= uper; + } else if (u1 < u2 && refon1) + { u2 -= uper; + } else if (u1 < u2 && !refon1) + { u1 += uper; + } } p1.SetX(u1); p2.SetX(u2); @@ -487,13 +529,21 @@ static void ChFi3d_Recale(const BRepAdaptor_Surface& Bs, if (fabs(v2 - v1) > 0.5 * vper) { if (v2 < v1 && refon1) + { v2 += vper; + } else if (v2 < v1 && !refon1) + { v1 -= vper; + } else if (v1 < v2 && refon1) + { v2 -= vper; + } else if (v1 < v2 && !refon1) + { v1 += vper; + } } p1.SetY(v1); p2.SetY(v2); @@ -510,7 +560,9 @@ bool ChFi3d_SelectStripe(NCollection_List>::Iterator& const bool thePrepareOnSame) { if (!thePrepareOnSame) + { return true; + } for (; It.More(); It.Next()) { @@ -519,11 +571,17 @@ bool ChFi3d_SelectStripe(NCollection_List>::Iterator& ChFi3d_IndexOfSurfData(Vtx, stripe, sens); ChFiDS_State stat; if (sens == 1) + { stat = stripe->Spine()->FirstStatus(); + } else + { stat = stripe->Spine()->LastStatus(); + } if (stat == ChFiDS_OnSame) + { return true; + } } return false; @@ -563,7 +621,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa NCollection_List>::Iterator StrIt; StrIt.Initialize(myVDataMap(Index)); if (!ChFi3d_SelectStripe(StrIt, Vtx, thePrepareOnSame)) + { return; + } occ::handle stripe = StrIt.Value(); const occ::handle spine = stripe->Spine(); NCollection_Sequence>& SeqFil = @@ -602,16 +662,24 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa // ---------------------------------------------------------- ChFiDS_State stat; if (isfirst) + { stat = spine->FirstStatus(); + } else + { stat = spine->LastStatus(); + } bool onsame = (stat == ChFiDS_OnSame); TopoDS_Face Fv, Fad, Fop; TopoDS_Edge Arcpiv, Arcprol, Arcspine; if (isfirst) + { Arcspine = spine->Edges(1); + } else + { Arcspine = spine->Edges(spine->NbEdges()); + } TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD; int ICurve; occ::handle HBs = new BRepAdaptor_Surface(); @@ -638,7 +706,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa if (onsame) { if (!CV1.IsOnArc() && !CV2.IsOnArc()) + { throw Standard_ConstructionError("Corner OnSame : no point on arc"); + } else if (CV1.IsOnArc() && CV2.IsOnArc()) { bool sur1 = false, sur2 = false; @@ -665,13 +735,19 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa E[1] = CV2.Arc(); E[2] = Arcspine; if (ChFi3d_EdgeState(E, myEFMap) != ChFiDS_OnDiff) + { IFadArc = 2; + } } else if (sur2) + { IFadArc = 2; + } } else if (CV2.IsOnArc()) + { IFadArc = 2; + } IFopArc = 3 - IFadArc; Arcpiv = Fd->Vertex(isfirst, IFadArc).Arc(); @@ -718,7 +794,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa } if (Fv.IsNull()) + { throw StdFail_NotDone("OneCorner : face at end not found"); + } Fv.Orientation(TopAbs_FORWARD); Fad.Orientation(TopAbs_FORWARD); @@ -768,7 +846,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa DStr.SetNewSurface(Fv, Sface); } else + { Bs.Initialize(Fv, false); + } Bad.Initialize(Fad); Bop.Initialize(Fop); } @@ -812,7 +892,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa pced->Initialize(CPadArc.Arc(), Fv); // in the case of degenerated Fi, parameter difference can be even negative (eap, occ293) if ((FiadArc.LastParameter() - FiadArc.FirstParameter()) > 10 * tolesp) + { Update(HBs, pced, HGs, FiadArc, CPadArc, isfirst); + } if (thePrepareOnSame) { @@ -862,21 +944,29 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa gp_Pnt2d pfil1, pfac1, pfil2, pfac2; occ::handle Hc1, Hc2; if (onsame && IFopArc == 1) + { pfac1 = p2dbout; + } else { Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(), Fv, Ubid, Ubid); if (Hc1.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pfac1 = Hc1->Value(CV1.ParameterOnArc()); } if (onsame && IFopArc == 2) + { pfac2 = p2dbout; + } else { Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(), Fv, Ubid, Ubid); if (Hc2.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pfac2 = Hc2->Value(CV2.ParameterOnArc()); } if (Fi1.LineIndex() != 0) @@ -896,7 +986,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst)); } if (onsame) + { ChFi3d_Recale(Bs, pfac1, pfac2, (IFadArc == 1)); + } Pardeb(1) = pfil1.X(); Pardeb(2) = pfil1.Y(); @@ -912,7 +1004,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa ChFi3d_BoundFac(Bs, uu1, uu2, vv1, vv2); if (!ChFi3d_ComputeCurves(HGs, HBs, Pardeb, Parfin, Cc, Ps, Pc, tolapp3d, tol2d, tolreached)) + { throw Standard_Failure("OneCorner : echec calcul intersection"); + } Udeb = Cc->FirstParameter(); Ufin = Cc->LastParameter(); @@ -935,11 +1029,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa int imin = 0; double distmin2 = RealLast(); for (int i = 1; i <= extCC.NbExt(); i++) + { if (extCC.SquareDistance(i) < distmin2) { distmin2 = extCC.SquareDistance(i); imin = i; } + } if (distmin2 <= Precision::SquareConfusion()) { Extrema_POnCurv ponc1, ponc2; @@ -1040,7 +1136,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa { const occ::handle& aPCurve = aData->InterferenceOnS1().PCurveOnFace(); if (aPCurve.IsNull()) + { continue; + } anOtherPCurve.Load(aPCurve, aData->InterferenceOnS1().FirstParameter(), @@ -1050,7 +1148,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa { const occ::handle& aPCurve = aData->InterferenceOnS2().PCurveOnFace(); if (aPCurve.IsNull()) + { continue; + } anOtherPCurve.Load(aPCurve, aData->InterferenceOnS2().FirstParameter(), @@ -1062,11 +1162,15 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa continue; } if (IsEqual(anOtherPCurve.LastParameter(), anOtherPCurve.FirstParameter())) + { // Degenerates continue; + } anIntersector.Perform(aCorkPCurve, anOtherPCurve, tol2d, Precision::PConfusion()); if (anIntersector.NbSegments() > 0 || anIntersector.NbPoints() > 0) + { throw StdFail_NotDone("OneCorner : fillets have too big radiuses"); + } } } NCollection_List>::Iterator anIter( @@ -1078,18 +1182,24 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa // We need only interferences between cork face and curves // of intersection with another fillet surfaces if (anOtherIntrf.IsNull()) + { continue; + } // Look if there is an intersection between pcurves occ::handle anOtherCur = occ::down_cast(DStr.Curve(anOtherIntrf->Geometry()).Curve()); if (anOtherCur.IsNull()) + { continue; + } Geom2dAdaptor_Curve anOtherPCurve(anOtherIntrf->PCurve(), anOtherCur->FirstParameter(), anOtherCur->LastParameter()); anIntersector.Perform(aCorkPCurve, anOtherPCurve, tol2d, Precision::PConfusion()); if (anIntersector.NbSegments() > 0 || anIntersector.NbPoints() > 0) + { throw StdFail_NotDone("OneCorner : fillets have too big radiuses"); + } } // 31/01/02 akm ^^^ DStr.ChangeShapeInterferences(IShape).Append(Interfc); @@ -1107,13 +1217,17 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa bool onfirst, FirstToPar; occ::handle Hc = BRep_Tool::CurveOnSurface(CV[i].Arc(), Fv, first, last); if (Hc.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pfac1 = Hc->Value(CV[i].ParameterOnArc()); PcF = Pc->Value(Udeb); PcL = Pc->Value(Ufin); onfirst = pfac1.Distance(PcF) < pfac1.Distance(PcL); if (onfirst) + { Pc->D1(Udeb, PcF, DerPc); + } else { Pc->D1(Ufin, PcL, DerPc); @@ -1160,7 +1274,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa aLocalEdge.Reverse(); occ::handle HcR = BRep_Tool::CurveOnSurface(aLocalEdge, Fv, first, last); if (HcR.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } Interfc = ChFi3d_FilCurveInDS(indcurv, indface, HcR, aLocalEdge.Orientation()); DStr.ChangeShapeInterferences(indface).Append(Interfc); // modify degenerated edge @@ -1187,10 +1303,14 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa double fd, ld; occ::handle Cd = BRep_Tool::CurveOnSurface(Edeg, Fv, fd, ld); if (Cd.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } occ::handle tCd = occ::down_cast(Cd); if (!tCd.IsNull()) + { Cd = tCd->BasisCurve(); + } gp_Pnt2d P2d = (FirstToPar) ? Hc->Value(first) : Hc->Value(last); Geom2dAPI_ProjectPointOnCurve Projector(P2d, Cd); double par = Projector.LowerDistanceParameter(); @@ -1224,7 +1344,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa DStr.ChangeShapeInterferences(IShape).Append(InterFv); // interferences of curv1 and curv2 on Isurf if (Fd->Orientation() == Fv.Orientation()) + { Et = TopAbs::Reverse(Et); + } c2d1 = new Geom2d_TrimmedCurve(Ps, Udeb, par2); InterFv = ChFi3d_FilCurveInDS(Icurv1, Isurf, c2d1, Et); DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv); @@ -1243,9 +1365,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa pard = BRep_Tool::Parameter(Vdeb, edgecouture); parf = BRep_Tool::Parameter(Vfin, edgecouture); if (std::abs(par1 - pard) < std::abs(parf - par1)) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } Interfedge = ChFi3d_FilPointInDS(ori, Iarc, indpt, par1); DStr.ChangeShapeInterferences(Iarc).Append(Interfedge); @@ -1299,9 +1425,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa for (ex.Init(Arcprol.Oriented(TopAbs_FORWARD), TopAbs_VERTEX); ex.More(); ex.Next()) { if (Vtx.IsSame(ex.Current())) + { OVtx = ex.Current().Orientation(); + } else + { V2 = TopoDS::Vertex(ex.Current()); + } } occ::handle Hc; @@ -1314,12 +1444,16 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa gp_Pnt2d pop1, pop2, pv1, pv2; Hc = BRep_Tool::CurveOnSurface(Arcprol, Fop, Ubid, Ubid); if (Hc.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pop1 = Hc->Value(parVtx); pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst)); Hc = BRep_Tool::CurveOnSurface(Arcprol, Fv, Ubid, Ubid); if (Hc.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pv1 = Hc->Value(parVtx); pv2 = p2dbout; ChFi3d_Recale(Bs, pv1, pv2, true); @@ -1351,7 +1485,9 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa tolapp3d, tol2d, tolreached)) + { throw Standard_Failure("OneCorner : echec calcul intersection"); + } Udeb = zob3d->FirstParameter(); Ufin = zob3d->LastParameter(); @@ -1416,9 +1552,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa pard = BRep_Tool::Parameter(Vdeb, edgecouture); parf = BRep_Tool::Parameter(Vfin, edgecouture); if (std::abs(par1 - pard) < std::abs(parf - par1)) + { ori = TopAbs_REVERSED; + } else + { ori = TopAbs_FORWARD; + } Interfedge = ChFi3d_FilPointInDS(ori, Iarc, indpt, par1); DStr.ChangeShapeInterferences(Iarc).Append(Interfedge); @@ -1470,9 +1610,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa #ifdef VARIANT1 { if (IFopArc == 1) + { box1.Add(zob3d->Value(Ufin)); + } else + { box2.Add(zob3d->Value(Ufin)); + } } #else { @@ -1494,9 +1638,13 @@ void ChFi3d_Builder::PerformOneCorner(const int Index, const bool thePrepareOnSa ChFi3d_EnlargeBox(CV2.Arc(), myEFMap(CV2.Arc()), CV2.ParameterOnArc(), box2); } if (!CV1.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, box1, stripe->IndexPoint(isfirst, 1)); + } if (!CV2.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, box2, stripe->IndexPoint(isfirst, 2)); + } #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch, t_sameinter); // result perf condition if (same &&inter) @@ -1664,7 +1812,9 @@ static bool IsShrink(const Geom2dAdaptor_Curve& PC, { gp_Pnt2d P = PC.Value(aSample.GetParameter(i)); if (std::abs(P.Coord(isU ? 1 : 2) - Param) > tol) + { return false; + } } return true; } @@ -1711,9 +1861,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) nbarete = ChFi3d_NbNotDegeneratedEdges(Vtx, myVEMap); ChFi3d_ChercheBordsLibres(myVEMap, Vtx, bordlibre, edgelibre1, edgelibre2); if (bordlibre) + { nbarete = (nbarete - 2) / 2 + 2; + } else + { nbarete = nbarete / 2; + } // it is determined if there is an edge of sewing and it face TopoDS_Face facecouture; @@ -1725,7 +1879,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) TopoDS_Face fcur = TopoDS::Face(ItF.Value()); ChFi3d_CoutureOnVertex(fcur, Vtx, couture, edgecouture); if (couture) + { facecouture = fcur; + } } // it is determined if one of edges adjacent to the fillet is regular bool reg1, reg2; @@ -1756,18 +1912,26 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { ChFi3d_edge_common_faces(myEFMap(EdgeSpine), F1, F2); if (F1.IsSame(facecouture)) + { Eadj1 = edgecouture; + } else + { ChFi3d_cherche_element(Vtx, EdgeSpine, F1, Eadj1, Vbid1); + } ChFi3d_edge_common_faces(myEFMap(Eadj1), Fga, Fdr); // Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin // reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0; reg1 = ChFi3d::IsTangentFaces(Eadj1, Fga, Fdr); // Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End if (F2.IsSame(facecouture)) + { Eadj2 = edgecouture; + } else + { ChFi3d_cherche_element(Vtx, EdgeSpine, F2, Eadj2, Vbid1); + } ChFi3d_edge_common_faces(myEFMap(Eadj2), Fga, Fdr); // Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin // reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0; @@ -1785,12 +1949,16 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) if (cp1.IsOnArc()) { if (cp1.Arc().IsSame(Eadj1) || cp1.Arc().IsSame(Eadj2)) + { compoint1 = true; + } } if (cp2.IsOnArc()) { if (cp2.Arc().IsSame(Eadj1) || cp2.Arc().IsSame(Eadj2)) + { compoint2 = true; + } } if (compoint1 && compoint2) { @@ -1819,9 +1987,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) if (FindFace(Vtx, CV1, CV2, face)) { if (!couture) + { onecorner = true; + } else if (!face.IsSame(facecouture)) + { onecorner = true; + } } if (onecorner) { @@ -1897,9 +2069,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) // if (distIndexOfS2())); F3 = F1; if (couture || bordlibre) + { nface = nface + 1; + } if (nface == 3) + { nbface = 2; + } else + { nbface = nface - 2; + } if (!CV1.IsOnArc() || !CV2.IsOnArc()) { PerformMoreThreeCorner(Index, 1); @@ -1997,31 +2181,45 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { E = TopoDS::Edge(It3.Value()); if (!E.IsSame(Edge[0]) && (containE(F1, E))) + { trouve = true; + } } TopoDS_Vertex Vt, V3, V4; V1 = TopExp::FirstVertex(Edge[0]); V2 = TopExp::LastVertex(Edge[0]); if (V.IsSame(V1)) + { Vt = V2; + } else + { Vt = V1; + } dist1 = (BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx)); V3 = TopExp::FirstVertex(E); V4 = TopExp::LastVertex(E); if (V.IsSame(V3)) + { Vt = V4; + } else + { Vt = V3; + } dist2 = (BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx)); if (dist2 < dist1) { Edge[0] = E; TopAbs_Orientation ori; if (V2.IsSame(V3) || V1.IsSame(V4)) + { ori = CV1.TransitionOnArc(); + } else + { ori = TopAbs::Reverse(CV1.TransitionOnArc()); + } double par = BRep_Tool::Parameter(V, Edge[0]); double tol = CV1.Tolerance(); CV1.SetArc(tol, Edge[0], par, ori); @@ -2036,31 +2234,45 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { E = TopoDS::Edge(It3.Value()); if (!E.IsSame(Edge[2]) && (containE(F2, E))) + { trouve = true; + } } TopoDS_Vertex Vt, V3, V4; V1 = TopExp::FirstVertex(Edge[2]); V2 = TopExp::LastVertex(Edge[2]); if (V.IsSame(V1)) + { Vt = V2; + } else + { Vt = V1; + } dist1 = (BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx)); V3 = TopExp::FirstVertex(E); V4 = TopExp::LastVertex(E); if (V.IsSame(V3)) + { Vt = V4; + } else + { Vt = V3; + } dist2 = (BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx)); if (dist2 < dist1) { Edge[2] = E; TopAbs_Orientation ori; if (V2.IsSame(V3) || V1.IsSame(V4)) + { ori = CV2.TransitionOnArc(); + } else + { ori = TopAbs::Reverse(CV2.TransitionOnArc()); + } double par = BRep_Tool::Parameter(V, Edge[2]); double tol = CV2.Tolerance(); CV2.SetArc(tol, Edge[2], par, ori); @@ -2092,24 +2304,36 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) if (nface == 3) { if (CV1.IsVertex()) + { findonf1 = true; + } if (CV2.IsVertex()) + { findonf2 = true; + } if (!findonf1) { NCollection_IndexedMap MapV; TopExp::MapShapes(Edge[0], TopAbs_VERTEX, MapV); if (MapV.Extent() == 2) + { if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx)) + { findonf1 = true; + } + } } if (!findonf2) { NCollection_IndexedMap MapV; TopExp::MapShapes(Edge[2], TopAbs_VERTEX, MapV); if (MapV.Extent() == 2) + { if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx)) + { findonf2 = true; + } + } } // detect and process OnSame situatuation @@ -2126,9 +2350,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Edge[0] = threeE[0]; ChFi3d_cherche_face1(myEFMap(Edge[0]), F1, Face[0]); if (findonf2) + { findonf1 = true; // not to look for Face[0] again + } else + { Edge[1] = CV2.Arc(); + } } else { @@ -2143,9 +2371,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) if (findonf1 && !isOnSame1) { if (CV1.TransitionOnArc() == TopAbs_FORWARD) + { V1 = TopExp::FirstVertex(CV1.Arc()); + } else + { V1 = TopExp::LastVertex(CV1.Arc()); + } ChFi3d_cherche_face1(myEFMap(CV1.Arc()), F1, Face[0]); nb = 1; Ei = Edge[0]; @@ -2158,22 +2390,34 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) cherche_edge1(Face[nb - 1], Face[nb], Edge[nb]); nb++; if (nb >= nn) + { throw Standard_Failure("IntersectionAtEnd : the max number of faces reached"); + } } if (!findonf2) + { Edge[nb] = CV2.Arc(); + } } if (findonf2 && !isOnSame2) { if (!findonf1) + { nb = 1; + } V1 = Vtx; if (CV2.TransitionOnArc() == TopAbs_FORWARD) + { Vfin = TopExp::LastVertex(CV2.Arc()); + } else + { Vfin = TopExp::FirstVertex(CV2.Arc()); + } if (!findonf1) + { ChFi3d_cherche_face1(myEFMap(CV1.Arc()), F1, Face[nb - 1]); + } ChFi3d_cherche_element(V1, EdgeSpine, F2, E, V2); Ei = E; V1 = V2; @@ -2186,7 +2430,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) cherche_edge1(Face[nb - 1], Face[nb], Edge[nb]); nb++; if (nb >= nn) + { throw Standard_Failure("IntersectionAtEnd : the max number of faces reached"); + } } Edge[nb] = CV2.Arc(); } @@ -2211,12 +2457,16 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) for (ex.Init(CV1.Arc(), TopAbs_VERTEX); ex.More(); ex.Next()) { if (Vtx.IsSame(ex.Current())) + { possible1 = true; + } } for (ex.Init(CV2.Arc(), TopAbs_VERTEX); ex.More(); ex.Next()) { if (Vtx.IsSame(ex.Current())) + { possible2 = true; + } } if ((possible1 && possible2) || (!possible1 && !possible2) || (nbarete > 4)) { @@ -2224,20 +2474,32 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { nb++; if (nb >= nn) + { throw Standard_Failure("IntersectionAtEnd : the max number of faces reached"); + } if (nb != 1) + { F3 = Face[nb - 2]; + } Face[nb - 1] = F3; if (CV1.Arc().IsSame(edgelibre1)) + { cherche_face(myVFMap(Vtx), edgelibre2, F1, F2, F3, Face[nb - 1]); + } else if (CV1.Arc().IsSame(edgelibre2)) + { cherche_face(myVFMap(Vtx), edgelibre1, F1, F2, F3, Face[nb - 1]); + } else + { cherche_face(myVFMap(Vtx), Edge[nb - 1], F1, F2, F3, Face[nb - 1]); + } ChFi3d_cherche_edge(Vtx, tabedg, Face[nb - 1], Edge[nb], V); tabedg.SetValue(nb, Edge[nb]); if (Edge[nb].IsSame(CV2.Arc())) + { trouve = true; + } } nbface = nb; } @@ -2254,7 +2516,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) trouve = false; ChFi3d_cherche_vertex(Edge[0], Edge[1], Vcom, trouve); if (Vcom.IsSame(Vtx)) + { ang1 = ChFi3d_AngleEdge(Vtx, Edge[0], Edge[1]); + } if (std::abs(ang1 - M_PI) < 0.01) { oneintersection1 = true; @@ -2270,7 +2534,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) trouve = false; ChFi3d_cherche_vertex(Edge[1], Edge[2], Vcom, trouve); if (Vcom.IsSame(Vtx)) + { ang1 = ChFi3d_AngleEdge(Vtx, Edge[1], Edge[2]); + } if (std::abs(ang1 - M_PI) < 0.01) { oneintersection2 = true; @@ -2340,14 +2606,22 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) proledge[nbface] = 0; prolface[nn] = 0; if (oneintersection1 || oneintersection2) + { faceprol[1] = facesau; + } if (!isOnSame1 && !isOnSame2) + { checkShrink = false; + } // in OnSame situation we need intersect Fd with Edge[0] or Edge[nbface] as well if (isOnSame1) + { nb = 0; + } else + { nb = 1; + } bool intersOnSameFailed = false; for (; nb <= nbface; nb++) @@ -2355,16 +2629,22 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) extend = false; E2 = Edge[nb]; if (!nb) + { F = F1; + } else { F = Face[nb - 1]; if (!prolface[nb - 1]) + { faceprol[nb - 1] = F; + } } if (F.IsNull()) + { throw Standard_NullObject("IntersectionAtEnd : Trying to intersect with NULL face"); + } Sfacemoins1 = BRep_Tool::Surface(F); occ::handle cint; @@ -2382,9 +2662,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { // update interference param on Fi1 and point of CV1 if (prolface[0]) + { Bs.Initialize(faceprol[0], false); + } else + { Bs.Initialize(Face[0], false); + } const occ::handle& c3df = DStr.Curve(Fi1.LineIndex()).Curve(); double Ufi = Fi2.Parameter(isfirst); ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS1(); @@ -2400,17 +2684,23 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Fi, CV1, pfac1, - Ufi)) // out + Ufi)) + { // out throw Standard_Failure("IntersectionAtEnd: pb intersection Face - Fi"); + } Fi1 = Fi; if (intersOnSameFailed) { // probable at fillet building // look for paredge2 Geom2dAPI_ProjectPointOnCurve proj; if (C2dint2.IsNull()) + { proj.Init(pfac1, Hc1); + } else + { proj.Init(pfac1, C2dint2); + } paredge2 = proj.LowerDistanceParameter(); } // update stripe point @@ -2452,7 +2742,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) } } else + { pfac1 = Hc1->Value(CV1.ParameterOnArc()); + } } paredge1 = CV1.ParameterOnArc(); if (Fi1.LineIndex() != 0) @@ -2526,11 +2818,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { NCollection_List::Iterator itl(myEVIMap.ChangeFind(EdgeSpine)); for (; itl.More(); itl.Next()) + { if (itl.Value() == Isurf) { myEVIMap.ChangeFind(EdgeSpine).Remove(itl); break; } + } myEVIMap.ChangeFind(EdgeSpine).Append(Fd->Surf()); } else @@ -2599,7 +2893,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) if (nbp == 0) { if (nb == 0 || nb == nbface) + { intersOnSameFailed = true; + } else { PerformMoreThreeCorner(Index, 1); @@ -2627,10 +2923,14 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { cfacemoins1 = BRep_Tool::CurveOnSurface(E2, F, u2, v2); if (cfacemoins1.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } cface = BRep_Tool::CurveOnSurface(E2, Face[nb], u2, v2); if (cface.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } cfacemoins1->D0(paredge2, pfac2); cface->D0(paredge2, pint); } @@ -2646,7 +2946,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) } } else + { throw Standard_Failure("IntersectionAtEnd: pb intersection Face cb"); + } } else { @@ -2675,7 +2977,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) } } else + { pfac2 = Hc2->Value(CV2.ParameterOnArc()); + } paredge2 = CV2.ParameterOnArc(); if (Fi2.LineIndex() != 0) { @@ -2687,15 +2991,21 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) } } if (!nb) + { continue; // found paredge1 on Edge[0] in OnSame situation on F1 + } if (nb == nbface && isOnSame2) { // update interference param on Fi2 and point of CV2 if (prolface[nb - 1]) + { Bs.Initialize(faceprol[nb - 1]); + } else + { Bs.Initialize(Face[nb - 1]); + } const occ::handle& c3df = DStr.Curve(Fi2.LineIndex()).Curve(); double Ufi = Fi1.Parameter(isfirst); ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS2(); @@ -2711,17 +3021,23 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Fi, CV2, pfac2, - Ufi)) // out + Ufi)) + { // out throw Standard_Failure("IntersectionAtEnd: pb intersection Face - Fi"); + } Fi2 = Fi; if (intersOnSameFailed) { // probable at fillet building // look for paredge2 Geom2dAPI_ProjectPointOnCurve proj; if (extend) + { proj.Init(pfac2, C2dint2); + } else + { proj.Init(pfac2, BRep_Tool::CurveOnSurface(E2, Face[nbface - 1], Ubid, Ubid)); + } paredge2 = proj.LowerDistanceParameter(); } // update stripe point @@ -2736,9 +3052,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) } if (prolface[nb - 1]) + { Bs.Initialize(faceprol[nb - 1]); + } else + { Bs.Initialize(Face[nb - 1]); + } // offset of parameters if they are not in the same period @@ -2863,7 +3183,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) tpt.Tolerance(std::max(tpt.Tolerance(), to1)); } else + { Isvtx1 = true; + } } if (nb == nbface) { @@ -2874,7 +3196,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) tpt.Tolerance(std::max(tpt.Tolerance(), to2)); } else + { Isvtx2 = true; + } } else { @@ -2913,9 +3237,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) TopAbs_Orientation ori = TopAbs_FORWARD; orface = Face[nb - 1].Orientation(); if (orface == orsurfdata) + { orien = TopAbs::Reverse(orcourbe); + } else + { orien = orcourbe; + } // limitation of edges of faces if (nb == 1) { @@ -2939,37 +3267,55 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) V1 = TopExp::FirstVertex(Edge[nb]); V2 = TopExp::LastVertex(Edge[nb]); if (containV(F1, V1) || containV(F2, V1)) + { ori = TopAbs_FORWARD; + } else if (containV(F1, V2) || containV(F2, V2)) + { ori = TopAbs_REVERSED; + } else + { throw Standard_Failure("IntersectionAtEnd : pb orientation"); + } if (containV(F1, V1) && containV(F1, V2)) { dist1 = (BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx)); dist2 = (BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx)); if (dist1 < dist2) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } } if (containV(F2, V1) && containV(F2, V2)) { dist1 = (BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx)); dist2 = (BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx)); if (dist1 < dist2) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } } } else { if (TopExp::FirstVertex(Edge[nb]).IsSame(Vtx)) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } } if (!extend && !(oneintersection1 || oneintersection2)) { @@ -2980,7 +3326,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) else { if (!(oneintersection1 || oneintersection2)) + { proledge[nb] = true; + } int indp1, indp2, ind; gp_Pnt pext; double ubid, vbid; @@ -3070,9 +3418,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Ct->D0(Ct->FirstParameter(), P3); Ct->D0(Ct->LastParameter(), P4); if (P2.Distance(P3) < tolpt || P1.Distance(P4) < tolpt) + { orient = orien; + } else + { orient = TopAbs::Reverse(orien); + } if (oneintersection1 || oneintersection2) { indice = DStr.AddShape(Face[0]); @@ -3085,7 +3437,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { TopoDS_Edge aLocalEdge = edgesau; if (edgesau.Orientation() != orient) + { aLocalEdge.Reverse(); + } C2dint1 = BRep_Tool::CurveOnSurface(aLocalEdge, Face[0], ubid, vbid); } } @@ -3111,13 +3465,17 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Ct = new Geom_TrimmedCurve(csau, par1, par2); if (oneintersection1 || oneintersection2) + { tolex = 10 * BRep_Tool::Tolerance(edgesau); + } if (extend) { occ::handle H1, H2; H1 = new GeomAdaptor_Surface(Sfacemoins1); if (Sface.IsNull()) + { tolex = std::max(tolex, ChFi3d_EvalTolReached(H1, C2dint1, H1, C2dint1, Ct)); + } else { H2 = new GeomAdaptor_Surface(Sface); @@ -3138,7 +3496,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { indice = DStr.AddShape(facesau); if (facesau.Orientation() == Face[0].Orientation()) + { orient = TopAbs::Reverse(orient); + } if (extend) { ComputeCurve2d(Ct, faceprol[1], C2dint2); @@ -3147,7 +3507,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) { TopoDS_Edge aLocalEdge = edgesau; if (edgesau.Orientation() != orient) + { aLocalEdge.Reverse(); + } C2dint2 = BRep_Tool::CurveOnSurface(aLocalEdge, facesau, ubid, vbid); // Reverse for case of edgesau on closed surface (Face[0] is equal to facesau) } @@ -3157,7 +3519,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) indice = DStr.AddShape(Face[nb]); DStr.SetNewSurface(Face[nb], Sface); if (Face[nb].Orientation() == Face[nb - 1].Orientation()) + { orient = TopAbs::Reverse(orient); + } } if (!bordlibre) { @@ -3214,29 +3578,41 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) indice = DStr.AddShape(Face[nb - 1]); InterfPC[nb - 1] = ChFi3d_FilCurveInDS(indcurve[nb - 1], indice, Pc, orien); if (!shrink[nb - 1]) + { InterfPS[nb - 1] = ChFi3d_FilCurveInDS(indcurve[nb - 1], Isurf, Ps, orcourbe); + } indpoint1 = indpoint2; } // end loop on faces being intersected with ChFi if (isOnSame1) + { CV1.Reset(); + } if (isOnSame2) + { CV2.Reset(); + } for (nb = 1; nb <= nbface; nb++) { int indice = DStr.AddShape(Face[nb - 1]); DStr.ChangeShapeInterferences(indice).Append(InterfPC[nb - 1]); if (!shrink[nb - 1]) + { DStr.ChangeSurfaceInterferences(Isurf).Append(InterfPS[nb - 1]); + } if (!proledge[nb - 1]) + { DStr.ChangeShapeInterferences(Edge[nb - 1]).Append(Interfedge[nb - 1]); + } } DStr.ChangeShapeInterferences(Edge[nbface]).Append(Interfedge[nbface]); if (!isShrink) + { stripe->InDS(isfirst); + } else { // compute curves for ! end of and end of previous @@ -3245,9 +3621,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) // Bnd_Box box; gp_Pnt2d UV, UV1 = midP2d, UV2 = midP2d; if (isOnSame1) + { UV = UV2 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst)); + } else + { UV = UV1 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst)); + } double aTolreached; occ::handle C3d; occ::handle aSurf = DStr.Surface(Fd->Surf()).Surface(); @@ -3331,8 +3711,12 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) // eval its tolerance intersecting Ps and Pcurve at end. // Find end curves closest to shrinked part for (nb = 0; nb < nbface; nb++) + { if (isOnSame1 ? shrink[nb + 1] : !shrink[nb]) + { break; + } + } occ::handle Cend = DStr.Curve(indcurve[nb]).Curve(); occ::handle PCend = InterfPS[nb]->PCurve(); // point near which self intersection may occur @@ -3343,7 +3727,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const int Index) Geom2dAdaptor_Curve PC1(Ps), PC2(PCend); Geom2dInt_GInter Intersector(PC1, PC2, Precision::PConfusion(), Precision::PConfusion()); if (!Intersector.IsDone()) + { return; + } for (nb = 1; nb <= Intersector.NbPoints(); nb++) { const IntRes2d_IntersectionPoint& ip = Intersector.Point(nb); @@ -3391,7 +3777,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) double aTol3d = 1.e-4; if (aLOfStripe.IsEmpty()) + { return; + } aStripe = aLOfStripe.First(); aSpine = aStripe->Spine(); @@ -3421,9 +3809,13 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aSurfPrev = BRep_Tool::Surface(aFace); if (aSens == 1) + { anIndPrev = anInd + 1; + } else + { anIndPrev = anInd - 1; + } TopoDS_Edge anArc1; TopoDS_Edge anArc2; @@ -3435,7 +3827,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) anArc1 = TopoDS::Edge(anIter.Value()); if (containE(aFace, anArc1)) + { isFound = true; + } } isFound = false; @@ -3446,7 +3840,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) anArc2 = TopoDS::Edge(anIter.Value()); if (containE(aFace, anArc2) && !anArc2.IsSame(anArc1)) + { isFound = true; + } } // determination of common points aCP1onArc, aCP2onArc and aCP2NotonArc @@ -3477,7 +3873,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) is2ndCP1OnArc = false; } else + { return; + } aSurfData = aSeqSurfData.Value(anInd); aCP1 = aSurfData->Vertex(isFirst, 1); @@ -3495,14 +3893,20 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) } if (!aCP1onArc.IsOnArc()) + { return; + } // determination of neighbor surface int indSurface; if (is1stCP1OnArc) + { indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS1(); + } else + { indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS2(); + } aNeighborFace = TopoDS::Face(myDS->Shape(indSurface)); @@ -3516,6 +3920,7 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aSurfData = aSeqSurfData.Value(anInd); if (isFirst) + { ChFi3d_ComputeArete(aSurfData->VertexLastOnS1(), aSurfData->InterferenceOnS1().PCurveOnSurf()->Value( aSurfData->InterferenceOnS1().LastParameter()), @@ -3531,7 +3936,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) tol2d, aTolReached, 0); + } else + { ChFi3d_ComputeArete(aSurfData->VertexFirstOnS1(), aSurfData->InterferenceOnS1().PCurveOnSurf()->Value( aSurfData->InterferenceOnS1().FirstParameter()), @@ -3547,6 +3954,7 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) tol2d, aTolReached, 0); + } // calculation of the index of the line on anInd. // aPClineOnSurf is the pcurve on anInd. @@ -3554,9 +3962,13 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) ChFiDS_FaceInterference aFI; if (is1stCP1OnArc) + { aFI = aSurfData->InterferenceOnS1(); + } else + { aFI = aSurfData->InterferenceOnS2(); + } occ::handle aCline; occ::handle aPClineOnSurf; @@ -3586,7 +3998,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) bool isPextFound; if (!anInterSS.IsDone()) + { return; + } isFound = false; @@ -3605,12 +4019,16 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) // aPext2.Distance(aCP1onArc.Point())) if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d || aPext2.Distance(aCP1onArc.Point()) <= aTol3d) + { // Modified by skv - Mon Jun 7 18:38:58 2004 OCC5898 End isFound = true; + } } if (!isFound) + { return; + } if (aPext1.Distance(aCP2onArc.Point()) > aTol3d && aPext1.Distance(aCP1onArc.Point()) > aTol3d) { @@ -3637,7 +4055,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) Extrema_ExtPC anExt(aPext, aCad, aTol3d); if (!anExt.IsDone()) + { return; + } isFound = false; for (i = 1; i <= anExt.NbExt() && !isFound; i++) @@ -3678,20 +4098,30 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aCracc->D0(aCracc->FirstParameter(), aPext1); if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d) + { aPar1 = aCracc->FirstParameter(); + } else + { aPar1 = aCracc->LastParameter(); + } if (aPar1 < aPar) + { aTrCracc = new Geom_TrimmedCurve(aCracc, aPar1, aPar); + } else + { aTrCracc = new Geom_TrimmedCurve(aCracc, aPar, aPar1); + } // Second section GeomInt_IntSS anInterSS2(aSurfPrev, aSurf, 1.e-7, true, true, true); if (!anInterSS2.IsDone()) + { return; + } H1 = new GeomAdaptor_Surface(aSurfPrev); H2 = new GeomAdaptor_Surface(aSurf); @@ -3710,11 +4140,15 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) if (aPext1.Distance(aCP2onArc.Point()) <= aTol3d || aPext2.Distance(aCP2onArc.Point()) <= aTol3d) + { isFound = true; + } } if (!isFound) + { return; + } } else { @@ -3740,7 +4174,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) } if (indShape <= 0) + { return; + } TopAbs_Orientation aCurOrient; @@ -3780,7 +4216,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aSeqSurfData.Remove(anInd); if (!isFirst) + { anInd--; + } aSurfData = aSeqSurfData.Value(anInd); @@ -3876,7 +4314,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) // define the orientation of aCint2 if (aPext1.Distance(aPoint2) > aTol3d && aPext2.Distance(aPoint1) > aTol3d) + { anOrSurf = TopAbs::Reverse(anOrSurf); + } // --------------------------------------------------------------- // storage of aCint2 @@ -3892,9 +4332,13 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) // interference of aCint2 on aFace if (anOrFace == anOrSD2) + { anOrFace = TopAbs::Reverse(anOrSurf); + } else + { anOrFace = anOrSurf; + } anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint21, anOrFace); DStr.ChangeShapeInterferences(indaFace).Append(anInterfc); @@ -3934,7 +4378,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) } if (isToReverse) + { anOrSurf = TopAbs::Reverse(anOrSurf); + } // --------------------------------------------------------------- // storage of aTrCracc @@ -3954,7 +4400,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) // interference of aTrCracc on the SurfData number anInd if (anOrSD1 == anOrSD2) + { anOrSurf = TopAbs::Reverse(anOrSurf); + } anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCurv1, anOrSurf); DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc); @@ -3982,7 +4430,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aTrCracc->D0(aTrCracc->LastParameter(), aP4); if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d) + { anOrSurf = TopAbs::Reverse(anOrSurf); + } TopOpeBRepDS_Curve aTCint1(aCint1, aTolex1); indCurve = DStr.AddCurve(aTCint1); @@ -4001,9 +4451,13 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) anOrFace = aFace.Orientation(); if (anOrFace == anOrSD1) + { anOrFace = TopAbs::Reverse(anOrSurf); + } else + { anOrFace = anOrSurf; + } anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint11, anOrFace); DStr.ChangeShapeInterferences(indaFace).Append(anInterfc); @@ -4037,7 +4491,9 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) aCint1->D0(aCint1->LastParameter(), aP4); if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d) + { anOrSurf = TopAbs::Reverse(anOrSurf); + } anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve, indPoint1, aTrCline->FirstParameter()); anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve, indPoint2, aTrCline->LastParameter()); @@ -4054,9 +4510,13 @@ void ChFi3d_Builder::PerformMoreSurfdata(const int Index) anOrFace = aNeighborFace.Orientation(); if (anOrFace == anOrSD1) + { anOrFace = TopAbs::Reverse(anOrSurf); + } else + { anOrFace = anOrSurf; + } anInterfc = ChFi3d_FilCurveInDS(indCurve, indShape, aPClineOnFace, anOrFace); DStr.ChangeShapeInterferences(indShape).Append(anInterfc); @@ -4105,7 +4565,9 @@ bool ChFi3d_Builder::FindFace(const TopoDS_Vertex& V, for (Jt.Initialize(myEFMap(P2.Arc())); Jt.More() && !Found; Jt.Next()) { if (TopoDS::Face(Jt.Value()).IsSame(Fv)) + { Found = true; + } } } } @@ -4187,14 +4649,18 @@ bool ChFi3d_Builder::MoreSurfdata(const int Index) const { arc1 = TopoDS::Edge(ItE.Value()); if (containE(Fv, arc1)) + { trouve = true; + } } trouve = false; for (ItE.Initialize(myVEMap(Vtx)); ItE.More() && !trouve; ItE.Next()) { arc2 = TopoDS::Edge(ItE.Value()); if (containE(Fv, arc2) && !arc2.IsSame(arc1)) + { trouve = true; + } } occ::handle Fd1 = SeqFil.ChangeValue(num2); @@ -4206,23 +4672,31 @@ bool ChFi3d_Builder::MoreSurfdata(const int Index) const if (CV3.Arc().IsSame(arc1)) { if (CV1.Point().Distance(CV3.Point()) < 1.e-4) + { oksurf = true; + } } else if (CV3.Arc().IsSame(arc2)) { if (CV2.Point().Distance(CV3.Point()) < 1.e-4) + { oksurf = true; + } } } if (CV4.IsOnArc()) { if (CV1.Point().Distance(CV4.Point()) < 1.e-4) + { oksurf = true; + } else if (CV4.Arc().IsSame(arc2)) { if (CV2.Point().Distance(CV4.Point()) < 1.e-4) + { oksurf = true; + } } } } @@ -4283,9 +4757,13 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) TopoDS_Face Fv, Fad, Fop, Fopbis; TopoDS_Edge Arcpiv, Arcprol, Arcspine, Arcprolbis; if (isfirst) + { Arcspine = spine->Edges(1); + } else + { Arcspine = spine->Edges(spine->NbEdges()); + } TopAbs_Orientation OArcprolbis = TopAbs_FORWARD; TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD; int ICurve; @@ -4311,7 +4789,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) #endif { if (!CV1.IsOnArc() && !CV2.IsOnArc()) + { throw Standard_Failure("Corner intersmore : no point on arc"); + } else if (CV1.IsOnArc() && CV2.IsOnArc()) { bool sur2 = false; @@ -4331,10 +4811,14 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) } } if (sur2) + { IFadArc = 2; + } } else if (CV2.IsOnArc()) + { IFadArc = 2; + } IFopArc = 3 - IFadArc; Arcpiv = Fd->Vertex(isfirst, IFadArc).Arc(); @@ -4381,7 +4865,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) } if (Fv.IsNull()) + { throw StdFail_NotDone("OneCorner : face at end is not found"); + } Fv.Orientation(TopAbs_FORWARD); Fad.Orientation(TopAbs_FORWARD); @@ -4405,7 +4891,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) // Guard: Arcprol may be null if the loop above found no matching edge. if (Arcprol.IsNull()) + { throw StdFail_NotDone("IntersectMoreCorner: edge to be extended is not found"); + } // Fopbis is the face containing the trace of fillet CP.Arc() which of does not contain Vtx. // Normally Fobis is either the same as Fop (cylinder), or Fobis is G1 with Fop. @@ -4437,7 +4925,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) DStr.SetNewSurface(Fv, Sface); } else + { Bs.Initialize(Fv, false); + } Bad.Initialize(Fad); Bop.Initialize(Fop); } @@ -4484,7 +4974,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) double ff, ll; occ::handle gpcprol = BRep_Tool::CurveOnSurface(Arcprol, Fv, ff, ll); if (gpcprol.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } occ::handle pcprol = new Geom2dAdaptor_Curve(gpcprol); double partemp = BRep_Tool::Parameter(Vtx, Arcprol); inters = @@ -4518,21 +5010,29 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) gp_Pnt2d pfil1, pfac1, pfil2, pfac2; occ::handle Hc1, Hc2; if (IFopArc == 1) + { pfac1 = p2dbout; + } else { Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(), Fv, Ubid, Ubid); if (Hc1.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pfac1 = Hc1->Value(CV1.ParameterOnArc()); } if (IFopArc == 2) + { pfac2 = p2dbout; + } else { Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(), Fv, Ubid, Ubid); if (Hc2.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pfac2 = Hc2->Value(CV2.ParameterOnArc()); } if (Fi1.LineIndex() != 0) @@ -4565,7 +5065,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) ChFi3d_BoundFac(Bs, uu1, uu2, vv1, vv2); if (!ChFi3d_ComputeCurves(HGs, HBs, Pardeb, Parfin, Cc, Ps, Pc, tolapp3d, tol2d, tolreached)) + { throw Standard_Failure("OneCorner : failed calculation intersection"); + } Udeb = Cc->FirstParameter(); Ufin = Cc->LastParameter(); @@ -4588,11 +5090,13 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) int imin = 0; double dist2min = RealLast(); for (int i = 1; i <= extCC.NbExt(); i++) + { if (extCC.SquareDistance(i) < dist2min) { dist2min = extCC.SquareDistance(i); imin = i; } + } if (dist2min <= Precision::SquareConfusion()) { Extrema_POnCurv ponc1, ponc2; @@ -4690,7 +5194,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) DStr.ChangeShapeInterferences(IShape).Append(InterFv); // interferences of curv1 and curv2 on Isurf if (Fd->Orientation() == Fv.Orientation()) + { Et = TopAbs::Reverse(Et); + } c2d1 = new Geom2d_TrimmedCurve(Ps, Udeb, par2); InterFv = ChFi3d_FilCurveInDS(Icurv1, Isurf, c2d1, Et); DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv); @@ -4709,9 +5215,13 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) pard = BRep_Tool::Parameter(Vdeb, edgecouture); parf = BRep_Tool::Parameter(Vfin, edgecouture); if (std::abs(par1 - pard) < std::abs(parf - par1)) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } Interfedge = ChFi3d_FilPointInDS(ori, Iarc, indpt, par1); DStr.ChangeShapeInterferences(Iarc).Append(Interfedge); @@ -4832,12 +5342,16 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) // fin modif Hc = BRep_Tool::CurveOnSurface(Arcprolbis, Fop, Ubid, Ubid); if (Hc.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } pop1 = Hc->Value(parVtx); pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst)); Hc = BRep_Tool::CurveOnSurface(Arcprol, Fv, Ubid, Ubid); if (Hc.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } // modif parVtx = BRep_Tool::Parameter(Vtx, Arcprol); // fin modif @@ -4872,7 +5386,9 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) tolapp3d, tol2d, tolreached)) + { throw Standard_Failure("OneCorner : echec calcul intersection"); + } Udeb = zob3d->FirstParameter(); Ufin = zob3d->LastParameter(); @@ -4915,9 +5431,13 @@ void ChFi3d_Builder::IntersectMoreCorner(const int Index) ChFi3d_EnlargeBox(CV2.Arc(), myEFMap(CV2.Arc()), CV2.ParameterOnArc(), box2); } if (!CV1.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, box1, stripe->IndexPoint(isfirst, 1)); + } if (!CV2.IsVertex()) + { ChFi3d_SetPointTolerance(DStr, box2, stripe->IndexPoint(isfirst, 2)); + } #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch, t_sameinter); // result perf condition if (same &&inter) diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C2.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C2.cxx index bc27ec2a92..4b4b44745f 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C2.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_C2.cxx @@ -415,19 +415,29 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) Fd2->ChangeVertex(isfirst2, IFaCo2) = Fd1->Vertex(isfirst1, IFaCo1); Fd2->ChangeVertex(isfirst2, IFaArc2) = Fd1->Vertex(isfirst1, IFaArc1); if (IFaCo1 != IFaCo2) + { Corner2->SetOrientation(TopAbs_REVERSED, isfirst2); + } Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1, IFaCo1), isfirst2, IFaCo2); Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1, IFaArc1), isfirst2, IFaArc2); // The tolerances of points are updated. Bnd_Box bco, barc; if (IFaCo1 == 1) + { ChFi3d_EnlargeBox(DStr, Corner1, Fd1, bco, barc, isfirst1); + } else + { ChFi3d_EnlargeBox(DStr, Corner1, Fd1, barc, bco, isfirst1); + } if (IFaCo2 == 1) + { ChFi3d_EnlargeBox(DStr, Corner2, Fd2, bco, barc, isfirst2); + } else + { ChFi3d_EnlargeBox(DStr, Corner2, Fd2, barc, bco, isfirst2); + } const ChFiDS_CommonPoint& cparc = Fd1->Vertex(isfirst1, IFaArc1); ChFi3d_EnlargeBox(cparc.Arc(), myEFMap(cparc.Arc()), cparc.ParameterOnArc(), barc); ChFi3d_SetPointTolerance(DStr, barc, Corner1->IndexPoint(isfirst1, IFaArc1)); @@ -523,14 +533,18 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) { wi = temp = FiArcSma.FirstParameter(); if (UIntPCSma < temp) + { temp = UIntPCSma; + } bid.Load(ctg, temp, FiArcSma.LastParameter()); } else { wi = temp = FiArcSma.LastParameter(); if (UIntPCSma > temp) + { temp = UIntPCSma; + } bid.Load(ctg, FiArcSma.FirstParameter(), temp); } if (SmaFD->Surf() == BigFD->Surf()) @@ -598,7 +612,9 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) IpointMil = ChFi3d_IndexPointInDS(psmamil, DStr); SmaCD->SetIndexPoint(IpointMil, isfirstSma, IFaArcSma); if (IFaCoSma == 2) + { SmaCD->SetOrientation(TopAbs_REVERSED, isfirstSma); + } // For BigCD the first results are met in the DS. BigCD->SetIndexPoint(IpointCo, isfirstBig, IFaCoBig); @@ -620,9 +636,13 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) TopAbs_Orientation tracurv = TopAbs::Compose(ofac, ofil); tracurv = TopAbs::Compose(tracurv, tra); if (!isfirstBig) + { tracurv = TopAbs::Reverse(tracurv); + } if (IFaCoBig != 1) + { tracurv = TopAbs::Reverse(tracurv); + } occ::handle Interfc; int ISurf = BigFD->Surf(); @@ -632,9 +652,13 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) // The tolerances of points are updated (beginning). Bnd_Box bco, bmil, barc; if (IFaCoSma == 1) + { ChFi3d_EnlargeBox(DStr, SmaCD, SmaFD, bco, bmil, isfirstSma); + } else + { ChFi3d_EnlargeBox(DStr, SmaCD, SmaFD, bmil, bco, isfirstSma); + } ChFi3d_EnlargeBox(BigHS, PGc2, WFirst, WLast, bco, bmil); // Intersection of the big with the face at end : @@ -683,7 +707,9 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) ChFiDS_CommonPoint& cpend = BigFD->ChangeVertex(isfirstBig, IFaArcBig); TopoDS_Edge etest = cpend.Arc(); if (BRep_Tool::IsClosed(etest, F)) + { etest.Reverse(); + } BRepAdaptor_Curve2d arc(etest, F); UVi = arc.Value(cpend.ParameterOnArc()); Parfin(1) = UVi.X(); @@ -758,9 +784,13 @@ bool ChFi3d_Builder::PerformTwoCornerbyInter(const int Index) // The tolerances of points are updated (end). occ::handle bidst; if (IFaCoBig == 1) + { ChFi3d_EnlargeBox(DStr, bidst, BigFD, bco, barc, isfirstBig); + } else + { ChFi3d_EnlargeBox(DStr, bidst, BigFD, barc, bco, isfirstBig); + } ChFi3d_EnlargeBox(BigHS, PGc2, WFirst, WLast, bmil, barc); ChFi3d_EnlargeBox(HF, PGc1, WFirst, WLast, bmil, barc); ChFi3d_EnlargeBox(Gc, WFirst, WLast, bmil, barc); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_CnCrn.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_CnCrn.cxx index 7eccb11661..3e645a111c 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_CnCrn.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_CnCrn.cxx @@ -128,13 +128,21 @@ extern void ChFi3d_ResultChron(OSD_Chronometer& ch, double& time); static void Indices(const int n, const int ic, int& icplus, int& icmoins) { if (ic == (n - 1)) + { icplus = 0; + } else + { icplus = ic + 1; + } if (ic == 0) + { icmoins = n - 1; + } else + { icmoins = ic - 1; + } } //================================================================================================= @@ -146,9 +154,13 @@ static void Calcul_Param(const occ::handle& stripe, double& param) { if (jfposit == 2) + { param = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS2().Parameter(isfirst); + } else + { param = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS1().Parameter(isfirst); + } } //================================================================================================= @@ -161,9 +173,13 @@ static void Calcul_P2dOnSurf(const occ::handle& stripe, { if (jfposit == 1) + { stripe->SetOfSurfData()->Value(indice)->InterferenceOnS1().PCurveOnSurf()->D0(param, p2); + } else + { stripe->SetOfSurfData()->Value(indice)->InterferenceOnS2().PCurveOnSurf()->D0(param, p2); + } } //================================================================================================= @@ -175,9 +191,13 @@ static void Calcul_C2dOnFace(const occ::handle& stripe, { if (jfposit == 1) + { c2d = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS1().PCurveOnFace(); + } else + { c2d = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS2().PCurveOnFace(); + } } //================================================================================================= @@ -188,9 +208,13 @@ static void Calcul_Orientation(const occ::handle& stripe, TopAbs_Orientation& orient) { if (jfposit == 1) + { orient = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS1().Transition(); + } else + { orient = stripe->SetOfSurfData()->Value(indice)->InterferenceOnS2().Transition(); + } } //================================================================================================= @@ -200,11 +224,17 @@ static void RemoveSD(occ::handle& Stripe, const int num1, const i NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); if (Seq.IsEmpty()) + { return; + } if (num1 == num2) + { Seq.Remove(num1); + } else + { Seq.Remove(num1, num2); + } } //======================================================================= @@ -287,9 +317,13 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, else { if (jficmoins == 1) + { ilin = CDicmoins->SetOfSurfData()->Value(icmoins)->InterferenceOnS1().LineIndex(); + } else + { ilin = CDicmoins->SetOfSurfData()->Value(icmoins)->InterferenceOnS2().LineIndex(); + } c1 = DStr.Curve(ilin).Curve(); } if (sharpicplus) @@ -300,15 +334,23 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, { jfp = 3 - jficplus; if (jfp == 1) + { ilin = CDicplus->SetOfSurfData()->Value(icplus)->InterferenceOnS1().LineIndex(); + } else + { ilin = CDicplus->SetOfSurfData()->Value(icplus)->InterferenceOnS2().LineIndex(); + } c2 = DStr.Curve(ilin).Curve(); } if (c1.IsNull()) + { throw Standard_ConstructionError("Failed to get 3D curve of edge"); + } if (c2.IsNull()) + { throw Standard_ConstructionError("Failed to get 3D curve of edge"); + } c1->D1(picmoins, p01, d11); c2->D1(picplus, p02, d12); int size = 4; @@ -319,15 +361,23 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, double lambda = ((double)1) / std::max(d11.Magnitude() / L1, 1.e-6); Cont(1) = p01.XYZ(); if (sensicmoins == 1) + { Cont(2) = d11.XYZ() * (-lambda); + } else + { Cont(2) = d11.XYZ() * (lambda); + } lambda = ((double)1) / std::max(d12.Magnitude() / L1, 1.e-6); Cont(3) = p02.XYZ(); if (sensicplus == 1) + { Cont(4) = d12.XYZ() * (lambda); + } else + { Cont(4) = d12.XYZ() * (-lambda); + } NCollection_Array1 ExtrapPoles(1, size); NCollection_Array1 ExtraCoeffs(1, size); gp_Pnt p0(0, 0, 0); @@ -371,7 +421,9 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, OrtProj.Build(); MapE1.Clear(); if (OrtProj.IsDone()) + { TopExp::MapShapes(OrtProj.Projection(), TopAbs_EDGE, MapE1); + } } if (MapE1.Extent() != 0) { @@ -382,19 +434,27 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, E1 = TopoDS::Edge(aLocalShape); // E1=TopoDS::Edge( TopoDS_Shape (MapE1(ind))); if (!BRep_Tool::Degenerated(E1)) + { trouve = true; + } } Eproj.Append(E1); proj1 = BRep_Tool::CurveOnSurface(E1, F, up1, up2); if (proj1.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } proj2d.Append(new Geom2d_TrimmedCurve(proj1, up1, up2)); proj1c = BRep_Tool::Curve(E1, up1, up2); if (proj1c.IsNull()) + { throw Standard_ConstructionError("Failed to get 3D curve of edge"); + } cproj.Append(new Geom_TrimmedCurve(proj1c, up1, up2)); if (error > BRep_Tool::Tolerance(E1)) + { error = BRep_Tool::Tolerance(E1); + } } else { @@ -424,7 +484,9 @@ static void CurveHermite(const TopOpeBRepDS_DataStructure& DStr, Extrema_POnCurv POnC, POnL; ext.Points(1, POnC, POnL); if (POnC.Value().Distance(POnL.Value()) < Precision::Confusion()) + { param.ChangeValue(nb) = POnC.Parameter(); + } else { if (!cproj.Value(nb).IsNull()) @@ -511,26 +573,42 @@ static void CalculBatten(const occ::handle& ASurf, CL1.Tangent(dir3); CL2.Tangent(dir4); if (inverseic) + { dir3.Reverse(); + } if (inverseicplus) + { dir4.Reverse(); + } double h = p2d2.Distance(p2d1) / 20; FairCurve_Batten Bat(p2d1, p2d2, h); Bat.SetFreeSliding(true); double ang1, ang2; ang1 = dir1.Angle(dir3); if (dir1.Angle(dir4) > 0) + { ang2 = M_PI - dir1.Angle(dir4); + } else + { ang2 = -M_PI - dir1.Angle(dir4); + } if (contraint1 && contraint2) + { anglebig = (std::abs(ang1) > 1.2) || (std::abs(ang2) > 1.2); + } else if (contraint1) + { anglebig = std::abs(ang1) > 1.2; + } else if (contraint2) + { anglebig = std::abs(ang2) > 1.2; + } if (isplane && (std::abs(ang1) > M_PI / 2 || std::abs(ang2) > M_PI / 2)) + { isplane = false; + } if (anglebig && !isplane) { CalculDroite(p2d1, xdir, ydir, pcurve); @@ -538,13 +616,21 @@ static void CalculBatten(const occ::handle& ASurf, else { if (contraint1) + { Bat.SetAngle1(ang1); + } else + { Bat.SetConstraintOrder1(0); + } if (contraint2) + { Bat.SetAngle2(ang2); + } else + { Bat.SetConstraintOrder2(0); + } FairCurve_AnalysisCode Iana; bool Ok; Ok = Bat.Compute(Iana, 25, 1.e-2); @@ -567,16 +653,26 @@ static void CalculBatten(const occ::handle& ASurf, double uminc, vminc, umaxc, vmaxc; bc.Get(uminc, vminc, umaxc, vmaxc); if (uminc < umin - 1.e-7) + { Ok = false; + } if (umaxc > umax + 1.e-7) + { Ok = false; + } if (vminc < vmin - 1.e-7) + { Ok = false; + } if (vmaxc > vmax + 1.e-7) + { Ok = false; + } } if (!Ok) + { CalculDroite(p2d1, xdir, ydir, pcurve); + } } } @@ -597,16 +693,24 @@ static void OrientationIcNonVive(const occ::handle& CDic, if (sensic != 1) { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_FORWARD; + } else + { orien = TopAbs_REVERSED; + } } else { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_REVERSED; + } else + { orien = TopAbs_FORWARD; + } } } @@ -628,16 +732,24 @@ static void OrientationIcplusNonVive(const occ::handle& CDicplus, if (sensicplus == 1) { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_FORWARD; + } else + { orien = TopAbs_REVERSED; + } } else { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_REVERSED; + } else + { orien = TopAbs_FORWARD; + } } } @@ -672,16 +784,24 @@ static void OrientationAreteViveConsecutive(const TopoDS_Shape& Fviveicicplus, if (vl.IsSame(V1)) { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_FORWARD; + } else + { orien = TopAbs_REVERSED; + } } else { if (orinterf == TopAbs_FORWARD) + { orien = TopAbs_REVERSED; + } else + { orien = TopAbs_FORWARD; + } } } @@ -802,9 +922,13 @@ static void PerformTwoCornerSameExt(TopOpeBRepDS_DataStructure& DStr, Fi11.PCurveOnFace()->D0(Fi11.FirstParameter(), p2d); Stemp->D0(p2d.X(), p2d.Y(), P3); if (P1.Distance(P4) < 1.e-4 || P2.Distance(P3) < 1.e-4) + { orpcurve = trafil1; + } else + { orpcurve = TopAbs::Reverse(trafil1); + } if (Com11.Point().Distance(P1) > 1.e-4) { ind = indpoint1; @@ -818,7 +942,9 @@ static void PerformTwoCornerSameExt(TopOpeBRepDS_DataStructure& DStr, Interfc = ChFi3d_FilCurveInDS(indcurve, indic1, C2dint1, orpcurve); DStr.ChangeSurfaceInterferences(indic1).Append(Interfc); if (orsurf1 == orsurf2) + { orpcurve = TopAbs::Reverse(orpcurve); + } Interfc = ChFi3d_FilCurveInDS(indcurve, indic2, C2dint2, orpcurve); DStr.ChangeSurfaceInterferences(indic2).Append(Interfc); } @@ -844,12 +970,16 @@ static void CpOnEdge(const occ::handle& stripe, if (cp1.IsOnArc()) { if (cp1.Arc().IsSame(Eadj1) || cp1.Arc().IsSame(Eadj2)) + { compoint = true; + } } if (cp2.IsOnArc()) { if (cp2.Arc().IsSame(Eadj1) || cp2.Arc().IsSame(Eadj2)) + { compoint = true; + } } } @@ -878,19 +1008,31 @@ static void RemoveSurfData(const ChFiDS_StripeMap& myVDataMap, { num = ChFi3d_IndexOfSurfData(V1, It.Value(), sense); if (sense == 1) + { Ecur = It.Value()->Spine()->Edges(1); + } else + { Ecur = It.Value()->Spine()->Edges(nbedge); + } ChFi3d_edge_common_faces(myEFMap(Ecur), F1, F2); if (F1.IsSame(facecouture)) + { Eadj1 = edgecouture; + } else + { ChFi3d_cherche_element(V1, Ecur, F1, Eadj1, Vbid); + } ChFi3d_edge_common_faces(myEFMap(Eadj1), Fg, Fd); if (F2.IsSame(facecouture)) + { Eadj2 = edgecouture; + } else + { ChFi3d_cherche_element(V1, Ecur, F2, Eadj2, Vbid); + } ChFi3d_edge_common_faces(myEFMap(Eadj2), Fg, Fd); bool compoint = false; isfirst = (sense == 1); @@ -905,10 +1047,14 @@ static void RemoveSurfData(const ChFiDS_StripeMap& myVDataMap, { CpOnEdge(It.Value(), i, isfirst, Eadj1, Eadj2, compoint); if (compoint) + { ind = i; + } } if (ind >= 2) + { RemoveSD(It.ChangeValue(), 1, ind - 1); + } } else { @@ -920,10 +1066,14 @@ static void RemoveSurfData(const ChFiDS_StripeMap& myVDataMap, { CpOnEdge(It.Value(), i, isfirst, Eadj1, Eadj2, compoint); if (compoint) + { ind = i; + } } if (ind < num) + { RemoveSD(It.ChangeValue(), ind + 1, num); + } } } } @@ -968,17 +1118,23 @@ static void SummarizeNormal(const TopoDS_Vertex& V1, gp_Pnt2d uv1, uv2; BRep_Tool::UVPoints(Ecur, Fcur, uv1, uv2); if (!V1.IsSame(TopExp::FirstVertex(Ecur))) + { uv1 = uv2; + } gp_Pnt P; gp_Vec d1U, d1V; BRep_Tool::Surface(Fcur)->D1(uv1.X(), uv1.Y(), P, d1U, d1V); gp_Vec N = d1U.Crossed(d1V); if (Fcur.Orientation() == TopAbs_REVERSED) + { N.Reverse(); + } if (N.SquareMagnitude() <= Precision::PConfusion()) + { return; + } SumFaceNormalAtV1 += N.Normalized(); SumFaceNormalAtV1.Normalize(); @@ -1064,9 +1220,13 @@ static TopAbs_Orientation PlateOrientation( pp1 = pp3; } if (SumScal2 * SumScal1 > 0) + { return TopAbs_FORWARD; + } else + { return TopAbs_REVERSED; + } } //======================================================================= @@ -1098,7 +1258,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) droit = std::abs(angedg - M_PI) < 0.01; } else + { nedge = nedge / 2; + } int size = nedge * 2; NCollection_Array1> CD(0, size); NCollection_Array1 jf(0, size); @@ -1172,7 +1334,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) TopoDS_Face fcur = TopoDS::Face(ItF.Value()); ChFi3d_CoutureOnVertex(fcur, V1, couture, edgecouture); if (couture) + { facecouture = fcur; + } } // unused surfdata are removed @@ -1196,9 +1360,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Fvive.SetValue(1, 0, Fcur); jf.SetValue(0, 2); if (sens.Value(0) == 1) + { Ecur = CD.Value(0)->Spine()->Edges(1); + } else + { Ecur = CD.Value(0)->Spine()->Edges(CD.Value(0)->Spine()->NbEdges()); + } Evive.SetValue(0, Ecur); ChFi3d_cherche_edge(V1, Evive, Fcur, Enext, VV); trouve = !Enext.IsNull(); @@ -1215,10 +1383,14 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) nbcouture++; } else + { ChFi3d_cherche_edge(V1, Evive, Fcur, Enext, VV); + } if (Enext.IsNull()) + { throw Standard_ConstructionError( "PerformMoreThreeCorner: pb in the parsing of edges and faces"); + } if (Enext.IsSame(edgelibre1) || Enext.IsSame(edgelibre2)) { CD.SetValue(ii, cdbid); @@ -1227,7 +1399,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) TopoDS_Vertex Vref; Vref = TopExp::FirstVertex(Enext); if (Vref.IsSame(V1)) + { sens.SetValue(ii, 1); + } sharp.SetValue(ii, true); Evive.SetValue(ii, Enext); jf.SetValue(ii, 0); @@ -1238,9 +1412,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) numfa.SetValue(icplus, ii, numfa.Value(ii, icplus)); ii++; if (Enext.IsSame(edgelibre1)) + { Ecur = edgelibre2; + } else + { Ecur = edgelibre1; + } ChFi3d_edge_common_faces(myEFMap(Ecur), Fcur, Fcur); Indices(nedge, ii, icplus, icmoins); Fvive.SetValue(ii, icplus, Fcur); @@ -1252,7 +1430,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) sens.SetValue(ii, -1); Vref = TopExp::FirstVertex(Ecur); if (Vref.IsSame(V1)) + { sens.SetValue(ii, 1); + } sharp.SetValue(ii, true); Evive.SetValue(ii, Ecur); jf.SetValue(ii, 0); @@ -1266,9 +1446,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { index = ChFi3d_IndexOfSurfData(V1, It.Value(), sense); if (sense == 1) + { EE = It.Value()->Spine()->Edges(1); + } else + { EE = It.Value()->Spine()->Edges(It.Value()->Spine()->NbEdges()); + } if (Enext.IsSame(EE)) { cnext = It.Value(); @@ -1292,7 +1476,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) TopoDS_Vertex Vref; Vref = TopExp::FirstVertex(Enext); if (Vref.IsSame(V1)) + { sens.SetValue(ii, 1); + } sharp.SetValue(ii, true); Evive.SetValue(ii, Enext); jf.SetValue(ii, 0); @@ -1315,12 +1501,16 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) // numfa and Fvive are reupdated (cts16288) numface2 = SurfIndex(CD, ii, Index.Value(ii), FACE2); if (numface2 == numfa.Value(ii, icplus)) + { jf.SetValue(ii, 2); + } else { numface1 = SurfIndex(CD, ii, Index.Value(ii), FACE1); if (numface1 == numfa.Value(ii, icplus)) + { jf.SetValue(ii, 1); + } else { if (numface1 == numfa.Value(icmoins, ii)) @@ -1438,10 +1628,12 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) deuxcgnontg = nconges == 2 && nedge == 3 && !deuxconges; // pro12305 if (deuxconges) + { for (ic = 0; ic < nedge; ic++) { regul.SetValue(ic, false); } + } // Detect case of 3 edges & 2 conges: OnSame + OnDiff // (eap, Arp 9 2002, occ266) @@ -1452,17 +1644,27 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (ic = 0; ic < nedge; ic++) { if (sharp.Value(ic)) + { continue; + } ChFiDS_State stat; if (sens(ic) == 1) + { stat = CD.Value(ic)->Spine()->FirstStatus(); + } else + { stat = CD.Value(ic)->Spine()->LastStatus(); + } if (stat == ChFiDS_OnSame) + { isOnSame = true; + } else if (stat == ChFiDS_OnDiff) + { isOnDiff = true; + } } isOnSameDiff = isOnSame && isOnDiff; } @@ -1480,6 +1682,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) // to two faces adjacent to Evive (cts16288) if (!deuxconges && !isOnSameDiff) + { for (ic = 0; ic < nedge; ic++) { if (sharp.Value(ic)) @@ -1501,7 +1704,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { ChFi3d_cherche_vertex(Arc, cp1.Arc(), Vcom, trouve); if (trouve) + { angedg = std::abs(ChFi3d_AngleEdge(Vcom, Arc, cp1.Arc())); + } if (!cp1.Arc().IsSame(Arc) && std::abs(angedg - M_PI) < 0.01) { Evive.SetValue(ic, cp1.Arc()); @@ -1542,7 +1747,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) angedg = M_PI; ChFi3d_cherche_vertex(Arc, cp2.Arc(), Vcom, trouve); if (trouve) + { angedg = std::abs(ChFi3d_AngleEdge(Vcom, Arc, cp2.Arc())); + } if (!cp2.Arc().IsSame(Arc) && std::abs(angedg - M_PI) < 0.01) { Evive.SetValue(ic, cp2.Arc()); @@ -1573,6 +1780,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) } } } + } // the first free edge is restored if it exists trouve = false; @@ -1598,19 +1806,27 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (ic = 0; ic < nedge; ic++) { if (sharp.Value(ic)) + { edgemin = TopoDS::Edge(Evive.Value(ic)); + } else { if (sens.Value(ic) == 1) + { edgemin = CD.Value(ic)->Spine()->Edges(1); + } else + { edgemin = CD.Value(ic)->Spine()->Edges(CD.Value(ic)->Spine()->NbEdges()); + } } V = TopExp::FirstVertex(edgemin); V2 = TopExp::LastVertex(edgemin); dst = (BRep_Tool::Pnt(V)).Distance(BRep_Tool::Pnt(V2)) / 1.5; if (dst < distmin) + { distmin = dst; + } } // calculate intersections between stripes and determine the parameters on each pcurve @@ -1635,6 +1851,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) angedg = std::abs( ChFi3d_AngleEdge(V1, TopoDS::Edge(Evive.Value(ic)), TopoDS::Edge(Evive.Value(icplus)))); if (std::abs(angedg - M_PI) > 0.01) + { ok = ChFi3d_SearchFD(DStr, CD.Value(ic), CD.Value(icplus), @@ -1650,8 +1867,11 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) sameside, jf1, jfp); + } else + { ok = false; + } // if there is an intersection it is checked if surfdata with the intersection // corresponds to the first or the last // if this is not the case, the surfdata are removed from SD @@ -1677,9 +1897,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (nb = Index.Value(ic); nb >= i1; nb--) { if ((3 - jf1) == 1) + { iface = SurfIndex(CD, ic, nb, FACE1); + } else + { iface = SurfIndex(CD, ic, nb, FACE2); + } Fproj.Append(TopoDS::Face(myDS->Shape(iface))); } } @@ -1688,9 +1912,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (nb = Index.Value(ic); nb <= i1; nb++) { if ((3 - jf1) == 1) + { iface = SurfIndex(CD, ic, nb, FACE1); + } else + { iface = SurfIndex(CD, ic, nb, FACE2); + } Fproj.Append(TopoDS::Face(myDS->Shape(iface))); } } @@ -1720,9 +1948,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (nb = i2; nb <= Index.Value(icplus); nb++) { if ((3 - jfp) == 1) + { iface = SurfIndex(CD, icplus, nb, FACE1); + } else + { iface = SurfIndex(CD, icplus, nb, FACE2); + } Fproj.Append(TopoDS::Face(myDS->Shape(iface))); } } @@ -1731,9 +1963,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (nb = i2; nb >= Index.Value(icplus); nb--) { if ((3 - jfp) == 1) + { iface = SurfIndex(CD, icplus, nb, FACE1); + } else + { iface = SurfIndex(CD, icplus, nb, FACE2); + } Fproj.Append(TopoDS::Face(myDS->Shape(iface))); } } @@ -1746,7 +1982,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) indice = SurfIndex(CD, ic, i1, ChFiSURFACE); DStr.Surface(indice).Surface()->D0(p2.X(), p2.Y(), pic); if (pic.Distance(som) > distmin) + { distmini = true; + } jf.SetValue(ic, jf1); i.SetValue(ic, icplus, i1); i.SetValue(icplus, ic, i2); @@ -1756,7 +1994,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) oksea.SetValue(ic, ok); } if (!oksea.Value(ic)) + { inters = false; + } } // case if there are only intersections @@ -1828,6 +2068,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) double distance = 0.; gp_Pnt sommet = BRep_Tool::Pnt(V1); if (!deuxconges) + { for (ic = 0; ic < nedge; ic++) { Indices(nedge, ic, icplus, icmoins); @@ -1844,7 +2085,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.Surface(indice).Surface()->D0(p2.X(), p2.Y(), pic); dist1.SetValue(ic, sommet.Distance(pic)); if (dist1.Value(ic) > distance) + { distance = dist1.Value(ic); + } Calcul_P2dOnSurf(CD.Value(ic), jf.Value(ic), @@ -1855,15 +2098,19 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.Surface(indice).Surface()->D0(p2.X(), p2.Y(), pic); dist2.SetValue(ic, sommet.Distance(pic)); if (dist2.Value(ic) > distance) + { distance = dist2.Value(ic); + } } } + } // offset of parameters and removal of intersection points // too close to the top double ec, dist; if (!deuxconges && !deuxcgnontg) + { for (ic = 0; ic < nedge; ic++) { Indices(nedge, ic, icplus, icmoins); @@ -1872,9 +2119,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) BRepAdaptor_Curve C(TopoDS::Edge(Evive.Value(ic))); // to pass from 3D distance to a parametric distance if (!tangentregul(ic)) + { ec = distance * 100 * C.Resolution(0.01); + } else + { ec = 0.0; + } if (TopExp::FirstVertex(TopoDS::Edge(Evive.Value(ic))).IsSame(V1)) { para = p.Value(ic, icmoins) + ec; @@ -1926,17 +2177,22 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) if (sens.Value(ic) == 1) { if (parnew > parold) + { p.SetValue(ic, icplus, p.Value(ic, icmoins)); + } } else { if (parnew < parold) + { p.SetValue(ic, icplus, p.Value(ic, icmoins)); + } } } } } } + } } // it is attempted to limit the edge by a commonpoint @@ -1945,6 +2201,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) double tolcp = 0; gp_Pnt PE, sommet = BRep_Tool::Pnt(V1); if (!deuxconges) + { for (ic = 0; ic < nedge; ic++) { if (sharp.Value(ic)) @@ -1975,7 +2232,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) } bool samecompoint = false; if (!sharp.Value(icmoins) && !sharp.Value(icplus)) + { samecompoint = cp1.Point().Distance(cp2.Point()) < tolapp; + } if ((dS < d1 || dS < d2) && !samecompoint) { // step back till Common Points @@ -1990,7 +2249,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Calcul_Param(CD.Value(icplus), jfp, i.Value(icplus, ic), isfirst, para); p.SetValue(icplus, ic, para); if (cp1.Tolerance() > tolcp && cp1.Tolerance() < 1) + { tolcp = cp1.Tolerance(); + } } else if (cp2.IsOnArc()) { @@ -2001,7 +2262,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Calcul_Param(CD.Value(icmoins), jf.Value(icmoins), i.Value(icmoins, ic), isfirst, para); p.SetValue(icmoins, ic, para); if (cp2.Tolerance() > tolcp && cp2.Tolerance() < 1) + { tolcp = cp2.Tolerance(); + } } } else @@ -2021,7 +2284,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Calcul_Param(CD.Value(icplus), jfp, i.Value(icplus, ic), isfirst, para); p.SetValue(icplus, ic, para); if (cp1.Tolerance() > tolcp && cp1.Tolerance() < 1) + { tolcp = cp1.Tolerance(); + } } } if (!sharp.Value(icmoins)) @@ -2041,12 +2306,15 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) para); p.SetValue(icmoins, ic, para); if (cp2.Tolerance() > tolcp && cp2.Tolerance() < 1) + { tolcp = cp2.Tolerance(); + } } } } } } + } // in case of a free border the parameter corresponding // to the common point on the free edge is chosen. @@ -2060,9 +2328,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) ChFiDS_CommonPoint CP1; Indices(nedge, ic, icplus, icmoins); if (libre.Value(ic)) + { indic = icmoins; + } else + { indic = icplus; + } if (!sharp(indic)) { isfirst = sens.Value(indic) == 1; @@ -2106,6 +2378,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) NCollection_Array1> cproj1(0, size); NCollection_Array1> cproj2(0, size); if (!deuxconges) + { for (ic = 0; ic < nedge; ic++) { int ilin; @@ -2130,25 +2403,39 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) trouve = true; } if (ii == nedge - 1) + { ii = 0; + } else + { ii++; + } } Indices(nedge, indfin, indfinplus, indfinmoins); if (!sharp.Value(icmoins)) { if (jf.Value(icmoins) == 1) + { ilin = SurfIndex(CD, icmoins, i.Value(icmoins, ic), FACE1); + } else + { ilin = SurfIndex(CD, icmoins, i.Value(icmoins, ic), FACE2); + } Lface.Append(TopoDS::Face(DStr.Shape(ilin))); } else + { Lface.Append(Fvive(ic, icmoins)); + } if (indfin > icmoins) + { nbface = indfin - icmoins; + } else + { nbface = nedge - (icmoins - indfin); + } NCollection_Sequence Epj; NCollection_Sequence seqpr; ii = ic; @@ -2159,23 +2446,35 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Ledge.Append(TopoDS::Edge(Evive.Value(ii))); seqpr.Append(p.Value(ii, iiplus)); if (nf != nbface - 1) + { Lface.Append(Fvive(ii, iiplus)); + } if (ii == nedge - 1) + { ii = 0; + } else + { ii++; + } } if (!sharp.Value(indfin)) { jfp = 3 - jf.Value(indfin); if (jfp == 1) + { ilin = SurfIndex(CD, indfin, i.Value(indfin, indfinmoins), FACE1); + } else + { ilin = SurfIndex(CD, indfin, i.Value(indfin, indfinmoins), FACE2); + } Lface.Append(TopoDS::Face(DStr.Shape(ilin))); } else + { Lface.Append(Fvive(indfin, indfinmoins)); + } CurveHermite(DStr, CD.Value(icmoins), jf.Value(icmoins), @@ -2211,9 +2510,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) cproj1.SetValue(ii, cr.Value(ind)); cproj2.SetValue(ii, cr.Value(ind + 1)); if (ii == nedge - 1) + { ii = 0; + } else + { ii++; + } } if (!sharp.Value(icmoins) && !sharp.Value(indfin)) { @@ -2222,14 +2525,19 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { isG1.SetValue(ii, true); if (ii == nedge - 1) + { ii = 0; + } else + { ii++; + } } } ic = ic + nbface - 1; } } + } // case when the connecting curve between ic and icplus crosses many faces @@ -2237,6 +2545,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) NCollection_Sequence Eproj; NCollection_Sequence parcom; if (!deuxconges) + { for (ic = 0; ic < nedge; ic++) { int iface1, iface2; @@ -2252,18 +2561,26 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) if (!sharp.Value(ic)) { if (jf.Value(ic) == 1) + { iface1 = SurfIndex(CD, ic, i.Value(ic, icplus), FACE1); + } else + { iface1 = SurfIndex(CD, ic, i.Value(ic, icplus), FACE2); + } } face1 = TopoDS::Face(myDS->Shape(iface1)); if (!sharp.Value(icplus)) { if (jf.Value(icplus) == 1) + { iface2 = SurfIndex(CD, icplus, i.Value(icplus, ic), FACE2); + } else + { iface2 = SurfIndex(CD, icplus, i.Value(icplus, ic), FACE1); + } } face2 = TopoDS::Face(myDS->Shape(iface2)); if (!face1.IsSame(face2)) @@ -2320,6 +2637,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) } } } + } // case when two fillets have the same commonpoints // one continues then by intersection @@ -2342,7 +2660,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) for (ic = 0; ic < nedge; ic++) { if (!sharp.Value(ic) && ic != ic1) + { ic2 = ic; + } } jfp = 3 - jf.Value(ic1); Indices(nedge, ic1, icplus, icmoins); @@ -2376,7 +2696,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) sens.Value(ic2), introuve); if (introuve) + { return; + } } } @@ -2459,13 +2781,19 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { TopOpeBRepDS_Point& tpt = DStr.ChangePoint(indpoint.Value(ii, 1)); if (point1.Distance(tpt.Point()) < 1.e-4) + { trouve = true; + } } } if (trouve) + { indpoint.SetValue(ic, 0, indpoint.Value(ii - 1, 1)); + } else + { indpoint.SetValue(ic, 0, DStr.AddPoint(tpoint1)); + } trouve = false; for (ii = 0; ii < ic && (!trouve); ii++) @@ -2474,20 +2802,28 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { TopOpeBRepDS_Point& tpt = DStr.ChangePoint(indpoint.Value(ii, 0)); if (point2.Distance(tpt.Point()) < 1.e-4) + { trouve = true; + } } } if (trouve) + { indpoint.SetValue(ic, 1, indpoint.Value(ii - 1, 0)); + } else + { indpoint.SetValue(ic, 1, DStr.AddPoint(tpoint2)); + } } // update of the stripe isurf1 = 3 - jf.Value(ic); isurf2 = jf.Value(ic); if (isurf1 == 2) + { CD.Value(ic)->SetOrientation(TopAbs_REVERSED, isfirst); + } CD.Value(ic)->SetCurve(indcurve3d.Value(n3d), isfirst); CD.Value(ic)->SetIndexPoint(indpoint.Value(ic, 0), isfirst, isurf1); CD.Value(ic)->SetIndexPoint(indpoint.Value(ic, 1), isfirst, isurf2); @@ -2586,7 +2922,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { raccordbatten = true; if (regul.Value(icplus)) + { raccordbatten = false; + } } n3d++; gp_Pnt2d p2d1, p2d2; @@ -2599,31 +2937,41 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) // return the 1st curve 2d // and the 1st connection point if (sharp.Value(ic)) + { curv2d1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Evive.Value(ic)), TopoDS::Face(Fvive.Value(ic, icplus)), u1bid, u2bid); + } else + { Calcul_C2dOnFace(CD.Value(ic), jf.Value(ic), i.Value(ic, icplus), curv2d1); + } if (curv2d1.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } p2d1 = curv2d1->Value(p.Value(ic, icplus)); // recuperation de la deuxieme courbe 2d // et du deuxieme point de raccordement if (sharp.Value(icplus)) + { curv2d2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Evive.Value(icplus)), TopoDS::Face(Fvive.Value(ic, icplus)), u1bid, u2bid); + } else { jfp = 3 - jf.Value(icplus); Calcul_C2dOnFace(CD.Value(icplus), jfp, i.Value(icplus, ic), curv2d2); } if (curv2d2.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } p2d2 = curv2d2->Value(p.Value(icplus, ic)); Asurf = new GeomAdaptor_Surface(BRep_Tool::Surface(TopoDS::Face(Fvive.Value(ic, icplus)))); @@ -2631,9 +2979,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) tolu = Asurf->UResolution(1.e-3); tolv = Asurf->VResolution(1.e-3); if (tolu > tolv) + { ratio = tolu / tolv; + } else + { ratio = tolv / tolu; + } // in case of a sewing edge the parameters are reframed if (couture) @@ -2647,18 +2999,26 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { xx = p2d1.X(); if (PI2 && !PI1) + { xx = xx - 2 * M_PI; + } if (!PI2 && PI1) + { xx = xx + 2 * M_PI; + } p2d1.SetX(xx); } if (Evive.Value(icplus).IsSame(edgecouture)) { xx = p2d2.X(); if (PI2 && !PI1) + { xx = xx + 2 * M_PI; + } if (!PI2 && PI1) + { xx = xx - 2 * M_PI; + } p2d2.SetX(xx); } } @@ -2688,7 +3048,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) else { // the connection is a straight line, projection or batten if (ratio > 10 && nconges == 1) + { raccordbatten = true; + } if (ratio > 10 && raccordbatten) { CalculDroite(p2d1, xdir, ydir, pcurve); @@ -2748,10 +3110,14 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) } if (TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre1) || TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre2)) + { contraint1 = false; + } if (TopoDS::Edge(Evive.Value(icplus)).IsSame(edgelibre1) || TopoDS::Edge(Evive.Value(icplus)).IsSame(edgelibre2)) + { contraint2 = false; + } CalculBatten(Asurf, TopoDS::Face(Fvive(ic, icplus)), xdir, @@ -2781,15 +3147,25 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Order.SetValue(n3d, 0); if (!sharp.Value(ic) && !sharp.Value(icplus)) + { Order.SetValue(n3d, 1); + } if (!contraint1 && !sharp.Value(icplus)) + { Order.SetValue(n3d, 1); + } if (!contraint2 && !sharp.Value(ic)) + { Order.SetValue(n3d, 1); + } if (tangentregul(ic) || tangentregul(icplus)) + { Order.SetValue(n3d, 1); + } if (isG1.Value(ic)) + { Order.SetValue(n3d, 1); + } occ::handle Cont = new GeomPlate_CurveConstraint(HCons, Order.Value(n3d), 10, tolapp3d, angular, 0.1); PSurf.Add(Cont); @@ -2912,7 +3288,9 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) para = parcom.Value(nb); Pcom = BRep_Tool::Curve(TopoDS::Edge(Ecom.Value(nb)), up1, up2)->Value(para); if (Pf.Distance(BRep_Tool::Pnt(V1)) < Pl.Distance(BRep_Tool::Pnt(V1))) + { orvt = TopAbs_FORWARD; + } if (!Eproj.Value(nb).IsNull()) { n3d++; @@ -2921,22 +3299,32 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) up1, up2); if (proj.IsNull()) + { throw Standard_ConstructionError("Failed to get p-curve of edge"); + } proj2d = new Geom2d_TrimmedCurve(proj, up1, up2); projc = BRep_Tool::Curve(TopoDS::Edge(Eproj.Value(nb)), up1, up2); if (projc.IsNull()) + { throw Standard_ConstructionError("Failed to get 3D curve of edge"); + } cproj = new Geom_TrimmedCurve(projc, up1, up2); pardeb = cproj->FirstParameter(); parfin = cproj->LastParameter(); P1 = cproj->Value(pardeb); P2 = cproj->Value(parfin); if (P1.Distance(tpt1.Point()) < 1.e-3) + { indpoint1 = indpoint(ic, 1); + } else + { indpoint1 = ind; + } if (P2.Distance(tpt2.Point()) < 1.e-3) + { indpoint2 = indpoint(icplus, 0); + } else { TopOpeBRepDS_Point tpoint2(P2, error); @@ -3000,9 +3388,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) if (nb != nbface) { if (Eproj.Value(nb).IsNull()) + { indice = indpoint(ic, 1); + } if (Eproj.Value(nb + 1).IsNull()) + { indice = indpoint(icplus, 0); + } Indice.SetValue(n3d, indice); int Iarc1 = DStr.AddShape(TopoDS::Edge(Ecom.Value(nb))); Interfp1 = ChFi3d_FilPointInDS(orvt, Iarc1, indice, parcom.Value(nb)); @@ -3014,6 +3406,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) // case when two free borders are tangent if (droit) + { for (ic = 0; ic < nedge; ic++) { occ::handle curve, ctrim, rcurve; @@ -3092,6 +3485,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp2); } } + } #ifdef OCCT_DEBUG ChFi3d_InitChron(ch); // init performances for plate @@ -3164,6 +3558,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) int nbedge; TopExp_Explorer ex; if (deuxconges) + { for (ic = 0; ic < nedge; ic++) { if (!sharp.Value(ic)) @@ -3171,9 +3566,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) nbedge = CD.Value(ic)->Spine()->NbEdges(); TopoDS_Edge Arcspine; if (sens.Value(ic) == 1) + { Arcspine = CD.Value(ic)->Spine()->Edges(1); + } else + { Arcspine = CD.Value(ic)->Spine()->Edges(nbedge); + } int IArcspine = DStr.AddShape(Arcspine); TopAbs_Orientation OVtx = TopAbs_FORWARD; for (ex.Init(Arcspine.Oriented(TopAbs_FORWARD), TopAbs_VERTEX); ex.More(); ex.Next()) @@ -3191,6 +3590,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.ChangeShapeInterferences(IArcspine).Append(interfv); } } + } // calculate orientation of Plate orplate corresponding to surfdata // calculation corresponding to the first stripe @@ -3265,11 +3665,16 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) orpcurve = TopAbs::Compose(orpcurve, CD.Value(0)->LastPCurveOrientation()); } if (orsurfdata == orplate) + { orien = TopAbs::Reverse(orpcurve); + } else + { orien = orpcurve; + } if (!droit) + { for (ic = 0; ic <= nedge; ic++) { if (libre.Value(ic)) @@ -3322,6 +3727,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); } } + } // stockage des courbes relatives aux stripes n3d = 0; @@ -3385,9 +3791,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Pl = BRep_Tool::Pnt(Vf); sommet1 = BRep_Tool::Pnt(V1); if (Pf.Distance(sommet1) < Pl.Distance(sommet1)) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } int Iarc1 = DStr.AddShape(TopoDS::Edge(Evive.Value(ic))); Interfp1 = ChFi3d_FilPointInDS(ori, Iarc1, indpoint(ic, 1), p.Value(ic, icplus)); DStr.ChangeShapeInterferences(TopoDS::Edge(Evive.Value(ic))).Append(Interfp1); @@ -3430,6 +3840,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) { Indices(nedge, ic, icplus, icmoins); if (moresurf(ic)) + { for (nb = 1; nb <= nbface; nb++) { if (!Eproj.Value(nb).IsNull()) @@ -3456,10 +3867,12 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) } } } + } } // storage of curves in case of tangent free borders if (droit) + { for (ic = 0; ic < nedge; ic++) { Indices(nedge, ic, icplus, icmoins); @@ -3475,6 +3888,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); } } + } } else { // there is only one partial result @@ -3496,9 +3910,13 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const int Jndex, const int nconges) Pl = BRep_Tool::Pnt(Vf); sommet1 = BRep_Tool::Pnt(V1); if (Pf.Distance(sommet1) < Pl.Distance(sommet1)) + { ori = TopAbs_FORWARD; + } else + { ori = TopAbs_REVERSED; + } int Iarc1 = DStr.AddShape(TopoDS::Edge(Evive.Value(ic))); Interfp1 = ChFi3d_FilPointInDS(ori, Iarc1, indpoint(ic, 1), p.Value(ic, icplus)); DStr.ChangeShapeInterferences(TopoDS::Edge(Evive.Value(ic))).Append(Interfp1); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_SpKP.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_SpKP.cxx index ccf67ecda6..a3ee64bed2 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_SpKP.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_SpKP.cxx @@ -72,9 +72,13 @@ static TopAbs_Orientation CompTra(const TopAbs_Orientation O1, const bool isfirst) { if (isfirst) + { return TopAbs::Reverse(TopAbs::Compose(O1, O2)); + } else + { return TopAbs::Compose(O1, O2); + } } //======================================================================= @@ -116,13 +120,19 @@ static ChFiDS_FaceInterference CpInterf(TopOpeBRepDS_DataStructure& DStr, const TopOpeBRepDS_Curve& toc = DStr.Curve(FI.LineIndex()); occ::handle newC; if (!toc.Curve().IsNull()) + { newC = occ::down_cast(toc.Curve()->Copy()); + } newF.SetLineIndex(DStr.AddCurve(TopOpeBRepDS_Curve(newC, toc.Tolerance()))); if (!FI.PCurveOnFace().IsNull()) + { newF.ChangePCurveOnFace() = occ::down_cast(FI.PCurveOnFace()->Copy()); + } if (!FI.PCurveOnSurf().IsNull()) + { newF.ChangePCurveOnSurf() = occ::down_cast(FI.PCurveOnSurf()->Copy()); + } return newF; } @@ -157,15 +167,25 @@ static bool AdjustParam(const HatchGen_Domain& Dom, const double pitol) { if (Dom.HasFirstPoint()) + { f = Dom.FirstPoint().Parameter(); + } else + { f = 0.; + } if (Dom.HasSecondPoint()) + { l = Dom.SecondPoint().Parameter(); + } else + { l = period; + } if (period == 0.) + { return false; + } f = ElCLib::InPeriod(f, wref - pitol, wref + period - pitol); l = ElCLib::InPeriod(l, wref + pitol, wref + period + pitol); @@ -239,14 +259,20 @@ static double ParamOnSpine(const TopOpeBRepDS_DataStructure& DStr, bool fini = false; int sens = 1; if (Nl <= f) + { sens = -1; + } int ii = iedge + sens; if (Spine->IsPeriodic()) { if (ii <= 0) + { ii += Spine->NbEdges(); + } if (ii > Spine->NbEdges()) + { ii -= Spine->NbEdges(); + } } else if (ii < 1 || ii > Spine->NbEdges()) { @@ -270,7 +296,9 @@ static double ParamOnSpine(const TopOpeBRepDS_DataStructure& DStr, std::cout << "point ped " << point.X() << " " << point.Y() << " " << point.Z() << std::endl; #endif if (found) + { Nl = Spine->Absc(Nl, ii); + } point = Spine->Value(Nl); #ifdef OCCT_DEBUG if (found) @@ -284,9 +312,13 @@ static double ParamOnSpine(const TopOpeBRepDS_DataStructure& DStr, if (Spine->IsPeriodic()) { if (ii <= 0) + { ii += Spine->NbEdges(); + } if (ii > Spine->NbEdges()) + { ii -= Spine->NbEdges(); + } fini = (ii == iedge); } else @@ -308,18 +340,28 @@ static bool YaUnVoisin(const occ::handle& Spine, { int nbed = Spine->NbEdges(); if (nbed == 1) + { return false; + } bool periodic = Spine->IsPeriodic(); if (isfirst) + { ivois = iedge - 1; + } else + { ivois = iedge + 1; + } if (periodic) { if (ivois == 0) + { ivois = nbed; + } if (ivois == nbed + 1) + { ivois = 1; + } } return (ivois > 0 && ivois <= nbed); } @@ -382,9 +424,13 @@ void ChFi3d_Builder::Trunc(const occ::handle& SD, double dis1 = psp.Distance(ped); double dis2 = p1.Distance(p2); if (Ang > M_PI / 18.) + { tron = true; + } if (dis1 >= 0.1 * dis2) + { tron = true; + } int ivois; if (!tron && YaUnVoisin(Spine, iedge, ivois, isfirst)) { @@ -414,7 +460,9 @@ void ChFi3d_Builder::Trunc(const occ::handle& SD, nbed++; } if (nbed < 3) + { tron = true; + } } // finmodif @@ -422,7 +470,9 @@ void ChFi3d_Builder::Trunc(const occ::handle& SD, { double par = 0., x, y, dPar = 0; if (!isfirst) + { par = edglen; + } if (cntlFiOnS) { // detect the case where FaceInterference ends before the place we are @@ -444,9 +494,13 @@ void ChFi3d_Builder::Trunc(const occ::handle& SD, SD->ChangeVertex(isfirst, i).Reset(); SD->ChangeVertex(isfirst, i).SetPoint(surf->Value(x, y)); if (isfirst) + { SD->FirstSpineParam(Spine->FirstParameter(iedge) - dPar); + } else + { SD->LastSpineParam(Spine->LastParameter(iedge) - dPar); + } } } } @@ -464,7 +518,9 @@ static double ResetProl(const TopOpeBRepDS_DataStructure& DStr, const occ::handle& surf = DStr.Surface(CD->Surf()).Surface(); double par = 0., x, y; if (!isfirst) + { par = edglen; + } double sppar = 0.; for (int i = 1; i <= 2; i++) { @@ -650,14 +706,18 @@ static void FillSD(TopOpeBRepDS_DataStructure& DSt int IE = PE.Index(); occ::handle HE = occ::down_cast(M(IE)); if (HE.IsNull()) + { return; + } const TopoDS_Edge& E = HE->Edge(); if (PE.Position() != TopAbs_INTERNAL) { TopAbs_Orientation O = CD->Interference(ons).Transition(); if (isFirst) + { O = TopAbs::Reverse(O); + } CompCommonPoint(Pons, E, PE, O); } else @@ -719,15 +779,21 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& occ::handle Bc = occ::down_cast(I1->Value()); occ::handle Gc = occ::down_cast(I1->Value()); if (Bc.IsNull()) + { ie = H1.AddElement(*Gc, TopAbs_FORWARD); + } else + { ie = H1.AddElement(*Bc, Bc->Edge().Orientation()); + } M1.Bind(ie, I1->Value()); } iH1 = H1.Trim(ll1); H1.ComputeDomains(iH1); if (!H1.IsDone(iH1)) + { return false; + } Nb1 = H1.NbDomains(iH1); if (Nb1 == 0) { @@ -748,15 +814,21 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& occ::handle Bc = occ::down_cast(I2->Value()); occ::handle Gc = occ::down_cast(I2->Value()); if (Bc.IsNull()) + { ie = H2.AddElement(*Gc, TopAbs_FORWARD); + } else + { ie = H2.AddElement(*Bc, Bc->Edge().Orientation()); + } M2.Bind(ie, I2->Value()); } iH2 = H2.Trim(ll2); H2.ComputeDomains(iH2); if (!H2.IsDone(iH2)) + { return false; + } Nb2 = H2.NbDomains(iH2); if (Nb2 == 0) { @@ -783,10 +855,14 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& TopoDS_Face F1, F2; occ::handle bhs = occ::down_cast(S1); if (!bhs.IsNull()) + { F1 = bhs->Face(); + } bhs = occ::down_cast(S2); if (!bhs.IsNull()) + { F2 = bhs->Face(); + } TopoDS_Face FBID; // Restriction of SurfDatas by cut lines. @@ -818,12 +894,16 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& gp_Pnt2d p2d1 = CD->Get2dPoints(false, 1); TopAbs_State situ = I1->Classify(p2d1, 1.e-8, false); if (situ == TopAbs_OUT) + { return false; + } } // Parsing of domains by increasing parameters, if (!Tri(H2, iH2, Ind2, wref, 0., pitol, Nb2)) + { return false; + } // Filling of SurfData for (int i = 1; i <= Nb2; i++) { @@ -842,7 +922,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& intf = !SearchFace(Spine, CP2, F2, FBID); } else + { intf = false; + } } if (intl) { @@ -853,7 +935,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& intl = !SearchFace(Spine, CP2, F2, FBID); } else + { intl = false; + } } } else if (C2.IsNull() || (Nb2 == 1 && !H2.Domain(iH2, 1).HasFirstPoint())) @@ -864,12 +948,16 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& gp_Pnt2d p2d2 = CD->Get2dPoints(false, 2); TopAbs_State situ = I2->Classify(p2d2, 1.e-8, false); if (situ == TopAbs_OUT) + { return false; + } } // Parsing of domains by increasing parameters, if (!Tri(H1, iH1, Ind1, wref, 0., pitol, Nb1)) + { return false; + } // Filling of SurfData for (int i = 1; i <= Nb1; i++) { @@ -888,7 +976,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& intf = !SearchFace(Spine, CP1, F1, FBID); } else + { intf = false; + } } if (intl) { @@ -899,7 +989,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& intl = !SearchFace(Spine, CP1, F1, FBID); } else + { intl = false; + } } } else @@ -911,21 +1003,29 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& if (ll1.IsPeriodic()) { if (!Tri(H2, iH2, Ind2, wref, 0., pitol, Nb2)) + { return false; + } period1 = ll1.Period(); if (!Tri(H1, iH1, Ind1, wref, period1, pitol, Nb1)) + { return false; + } } else { if (!Tri(H1, iH1, Ind1, wref, 0., pitol, Nb1)) + { return false; + } if (ll2.IsPeriodic()) { period2 = ll2.Period(); } if (!Tri(H2, iH2, Ind2, wref, period2, pitol, Nb2)) + { return false; + } } // Filling of SurfData @@ -936,7 +1036,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& int nbcoup1 = 1; bool acheval1 = AdjustParam(Dom1, f1, l1, wref, period1, pitol); if (acheval1) + { nbcoup1 = 2; + } for (int icoup1 = 1; icoup1 <= nbcoup1; icoup1++) { for (int j = 1; j <= Nb2; j++) @@ -945,19 +1047,29 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& int nbcoup2 = 1; bool acheval2 = AdjustParam(Dom2, f2, l2, wref, period2, pitol); if (acheval2) + { nbcoup2 = 2; + } for (int icoup2 = 1; icoup2 <= nbcoup2; icoup2++) { if (f2 <= l1 && f1 <= l2) { if (f1 >= f2 - tol2d) + { FillSD(DStr, CD, M1, Dom1, f1, true, 1, pitol, bout1); + } if (f2 >= f1 - tol2d) + { FillSD(DStr, CD, M2, Dom2, f2, true, 2, pitol, bout1); + } if (l1 >= l2 - tol2d) + { FillSD(DStr, CD, M2, Dom2, l2, false, 2, pitol, bout2); + } if (l2 >= l1 - tol2d) + { FillSD(DStr, CD, M1, Dom1, l1, false, 1, pitol, bout2); + } SetData.Append(CD); CD = CpSD(DStr, CD); ion1.Append(i); @@ -1019,7 +1131,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& ion2.Remove(1, ifirst - 1); } if (SetData.IsEmpty()) + { return false; + } occ::handle& CD2 = SetData.ChangeValue(1); ChFiDS_CommonPoint& CP1 = CD2->ChangeVertexFirstOnS1(); ChFiDS_CommonPoint& CP2 = CD2->ChangeVertexFirstOnS2(); @@ -1054,7 +1168,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& } } else + { intf = false; + } } else if (CP2.IsOnArc()) { @@ -1081,7 +1197,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& } } else + { intf = false; + } } // select switcher so that to get on spine params from // Interference with a face where both edges at corner are OnSame @@ -1093,9 +1211,13 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& ChFi3d_cherche_element(bout1, support, F2, threeE[1], boutemp); threeE[2] = support; if (ChFi3d_EdgeState(threeE, myEFMap) == ChFiDS_OnSame) + { onS = 1; + } else + { onS = 2; + } #ifdef OCCT_DEBUG if (threeE[0].IsSame(threeE[1])) std::cout << "SplitKPart(), wrong corner vertex at switcher search" << std::endl; @@ -1146,7 +1268,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& ion2.Remove(ilast + 1, lll); } if (SetData.IsEmpty()) + { return false; + } occ::handle& CD4 = SetData.ChangeValue(SetData.Length()); ChFiDS_CommonPoint& CP1 = CD4->ChangeVertexLastOnS1(); ChFiDS_CommonPoint& CP2 = CD4->ChangeVertexLastOnS2(); @@ -1180,7 +1304,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& } } else + { intl = false; + } } else if (CP2.IsOnArc()) { @@ -1207,7 +1333,9 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& } } else + { intl = false; + } } // select switcher so that to get on spine params from @@ -1220,9 +1348,13 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& ChFi3d_cherche_element(bout2, support, F2, threeE[1], boutemp); threeE[2] = support; if (ChFi3d_EdgeState(threeE, myEFMap) == ChFiDS_OnSame) + { onS = 1; + } else + { onS = 2; + } #ifdef OCCT_DEBUG if (threeE[0].IsSame(threeE[1])) std::cout << "SplitKPart(), wrong corner vertex at switcher search" << std::endl; @@ -1243,9 +1375,13 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& double ltg = CD5->Interference(onS).LastParameter(); double Nl = ComputeAbscissa(Spine->CurrentElementarySpine(Iedge), ltg); if (Nl < -tolesp) + { SetData.Remove(i); + } else + { i++; + } okdoc = (SetData.IsEmpty() || i > SetData.Length()); } } @@ -1262,9 +1398,13 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& double l = Spine->LastParameter(Iedge); double Nl = ComputeAbscissa(Spine->CurrentElementarySpine(Iedge), ftg); if (Nl > (l - f + tolesp)) + { SetData.Remove(i); + } else + { i++; + } okdoc = (SetData.IsEmpty() || i > SetData.Length()); } } @@ -1279,10 +1419,14 @@ bool ChFi3d_Builder::SplitKPart(const occ::handle& double ltg = CD7->Interference(onS).LastParameter(); double fsp = ParamOnSpine(DStr, ftg, CD7, Spine, Iedge, intf, intl, tolesp, pokdeb); if (!pokdeb) + { fsp = ResetProl(DStr, CD7, Spine, Iedge, true); + } double lsp = ParamOnSpine(DStr, ltg, CD7, Spine, Iedge, intf, intl, tolesp, pokfin); if (!pokfin) + { lsp = ResetProl(DStr, CD7, Spine, Iedge, false); + } if (Spine->IsPeriodic() && Iedge == Spine->NbEdges() && lsp < fsp) { lsp += Spine->Period(); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder.cxx index 0a908d9eca..97f2cb4485 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder.cxx @@ -78,7 +78,9 @@ void SearchCommonFaces(const ChFiDS_Map& EFMap, { Fc = TopoDS::Face(It.Value()); if (F1.IsNull()) + { F1 = Fc; + } else if (!Fc.IsSame(F1)) { F2 = Fc; @@ -87,7 +89,9 @@ void SearchCommonFaces(const ChFiDS_Map& EFMap, } if (!F1.IsNull() && F2.IsNull() && BRepTools::IsReallyClosed(E, F1)) + { F2 = F1; + } } //======================================================================= @@ -120,9 +124,13 @@ void ExtentSpineOnCommonFace(occ::handle& Spine1, tg1.Normalize(); tg2.Normalize(); if (isfirst1) + { tg1.Reverse(); + } if (isfirst2) + { tg2.Reverse(); + } double cosalpha, sinalpha; cosalpha = tg1.Dot(tg2); @@ -293,7 +301,9 @@ void ChFi3d_ChBuilder::SetDist(const double Dis, const int IC, const TopoDS_Face csp->SetDist(Dis); } else + { throw Standard_DomainError("the face is not common to any of edges of the contour"); + } } } @@ -398,12 +408,18 @@ void ChFi3d_ChBuilder::SetDists(const double Dis1, Sb2.Initialize(FirstF2); ChoixConge = ChFi3d::ConcaveSide(Sb1, Sb2, csp->Edges(1), Or1, Or2); if (ChoixConge % 2 != Choix % 2) + { csp->SetDists(Dis2, Dis1); + } else + { csp->SetDists(Dis1, Dis2); + } } else + { throw Standard_DomainError("the face is not common to any of edges of the contour"); + } } } @@ -503,7 +519,9 @@ void ChFi3d_ChBuilder::SetDistAngle(const double Dis, csp->SetDistAngle(Dis, Angle); } else + { throw Standard_DomainError("the face is not common to any edges of the contour"); + } } } @@ -675,7 +693,9 @@ void ChFi3d_ChBuilder::SimulKPart(const occ::handle& SD) const double rad = Co.RefRadius(), sang = Co.SemiAngle(); int n = (int)(36. * ang / M_PI + 1); if (n < 2) + { n = 2; + } sec = new NCollection_HArray1(1, n); for (int i = 1; i <= n; i++) { @@ -718,7 +738,9 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, occ::handle chsp = occ::down_cast(Spine); if (chsp.IsNull()) + { throw Standard_ConstructionError("SimulSurf : this is not the spine of a chamfer"); + } double radius; // Flexible parameters! @@ -738,15 +760,21 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, HGuide->D2(w, Pbid, d1, d2); double temp = d2.SquareMagnitude(); if (temp > radiusspine) + { radiusspine = temp; + } } occ::handle lin; double PFirst = First; if (intf) + { First = chsp->FirstParameter(1); + } if (intl) + { Last = chsp->LastParameter(chsp->NbEdges()); + } occ::handle OffsetHGuide; @@ -797,7 +825,9 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, RecOnS2); if (!done) + { return false; + } occ::handle> sec; gp_Pnt2d pf1, pl1, pf2, pl2; @@ -915,12 +945,14 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, { const occ::handle& aHElSpine = ILES.Value(); if (aHElSpine == HGuide) + { OffsetHGuide = ILES_offset.Value(); + } } if (OffsetHGuide.IsNull()) { - std::cout << std::endl << "Construction of offset guide failed!" << std::endl; + std::cout << '\n' << "Construction of offset guide failed!" << '\n'; // exception } pFunc.reset(new BRepBlend_ConstThroatWithPenetration(S1, S2, OffsetHGuide)); @@ -955,7 +987,9 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, RecOnS2); if (!done) + { return false; + } occ::handle> sec; gp_Pnt2d pf1, pl1, pf2, pl2; @@ -1088,7 +1122,9 @@ bool ChFi3d_ChBuilder::SimulSurf(occ::handle& Data, RecOnS2); if (!done) + { return false; + } occ::handle> sec; gp_Pnt2d pf1, pl1, pf2, pl2; @@ -1295,7 +1331,9 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& occ::handle chsp = occ::down_cast(Spine); if (chsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a chamfer"); + } double TolGuide = HGuide->Resolution(tolapp3d); @@ -1332,9 +1370,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& double sign = (TgF.Crossed(d1gui)).Dot(TgL); if (Choix % 2 == 1) + { rev1 = true; + } else + { rev2 = true; + } if (sign < 0.) { @@ -1343,9 +1385,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& } if (rev1) + { TgF.Reverse(); + } if (rev2) + { TgL.Reverse(); + } temp = (TgF.XYZ()).Multiplied(dis); pt1.SetXYZ((ptgui.XYZ()).Added(temp)); @@ -1391,12 +1437,14 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& { const occ::handle& aHElSpine = ILES.Value(); if (aHElSpine == HGuide) + { OffsetHGuide = ILES_offset.Value(); + } } if (OffsetHGuide.IsNull()) { - std::cout << std::endl << "Construction of offset guide failed!" << std::endl; + std::cout << '\n' << "Construction of offset guide failed!" << '\n'; // exception } pFunc.reset(new BRepBlend_ConstThroatWithPenetration(S1, S2, OffsetHGuide)); @@ -1421,9 +1469,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& double sign = (TgF.Crossed(d1gui)).Dot(TgL); if (Choix % 2 == 1) + { rev1 = true; + } else + { rev2 = true; + } if (sign < 0.) { @@ -1432,9 +1484,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& } if (rev1) + { TgF.Reverse(); + } if (rev2) + { TgL.Reverse(); + } double aDist1 = dis1, aDist2 = dis2; if (chsp->Mode() == ChFiDS_ConstThroatWithPenetrationChamfer) @@ -1503,9 +1559,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& double sign = (TgF.Crossed(d1gui)).Dot(TgL); if (Ch % 2 == 1) + { rev1 = true; + } else + { rev2 = true; + } if (sign < 0.) { @@ -1514,9 +1574,13 @@ bool ChFi3d_ChBuilder::PerformFirstSection(const occ::handle& } if (rev1) + { TgF.Reverse(); + } if (rev2) + { TgL.Reverse(); + } temp = (TgF.XYZ()).Multiplied(dis1); pt1.SetXYZ((ptgui.XYZ()).Added(temp)); @@ -1578,16 +1642,22 @@ bool ChFi3d_ChBuilder::PerformSurf(NCollection_Sequence chsp = occ::down_cast(Spine); if (chsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a chamfer"); + } bool gd1, gd2, gf1, gf2; occ::handle lin; TopAbs_Orientation Or = S1->Face().Orientation(); double PFirst = First; if (intf) + { First = chsp->FirstParameter(1); + } if (intl) + { Last = chsp->LastParameter(chsp->NbEdges()); + } if (chsp->IsChamfer() == ChFiDS_Sym) { @@ -1638,10 +1708,14 @@ bool ChFi3d_ChBuilder::PerformSurf(NCollection_SequenceIsChamfer() == ChFiDS_TwoDist) { @@ -1667,12 +1741,14 @@ bool ChFi3d_ChBuilder::PerformSurf(NCollection_Sequence& aHElSpine = ILES.Value(); if (aHElSpine == HGuide) + { OffsetHGuide = ILES_offset.Value(); + } } if (OffsetHGuide.IsNull()) { - std::cout << std::endl << "Construction of offset guide failed!" << std::endl; + std::cout << '\n' << "Construction of offset guide failed!" << '\n'; // exception } pFunc.reset(new BRepBlend_ConstThroatWithPenetration(S1, S2, OffsetHGuide)); @@ -1711,10 +1787,14 @@ bool ChFi3d_ChBuilder::PerformSurf(NCollection_Sequence Spine = S->Spine(); ChFi3d_IndexOfSurfData(V, S, Sens); if (Spine->IsTangencyExtremity((Sens == 1))) + { return; // No extension on queue + } double dU = Spine->LastParameter(Spine->NbEdges()); if (Sens == 1) { @@ -1911,14 +1997,20 @@ void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& { ChFi3d_IndexOfSurfData(V, itel.Value(), Sens); if (!FF) + { if (Stripe[1] == itel.Value()) + { Sens = -Sens; + } + } Stripe[i] = itel.Value(); isfirst[i] = (Sens == 1); Spine[i] = Stripe[i]->Spine(); if (!isfirst[i]) + { Iedge[i] = Spine[i]->NbEdges(); + } FF = false; } @@ -1978,9 +2070,13 @@ void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& for (i = 0; i < 2; i++) { if (isfirst[i]) + { State[i] = Spine[i]->FirstStatus(); + } else + { State[i] = Spine[i]->LastStatus(); + } } if (State[0] == ChFiDS_AllSame) @@ -1999,7 +2095,9 @@ void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& // it is necessary that two chamfers touch the face at end for (j = 0; j < 2; j++) + { ExtentOneCorner(V, Stripe[j]); + } } else if ((State[0] == ChFiDS_OnSame) && (State[1] == ChFiDS_OnSame)) { @@ -2040,7 +2138,9 @@ void ChFi3d_ChBuilder::ExtentThreeCorner(const TopoDS_Vertex& isfirst[i] = (Sens == 1); Spine[i] = Stripe->Spine(); if (!isfirst[i]) + { Iedge[i] = Spine[i]->NbEdges(); + } check.Append(Stripe); } diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder_C3.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder_C3.cxx index 7c49c1f610..e198f8c634 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder_C3.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_ChBuilder_C3.cxx @@ -308,6 +308,7 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) fin = 2; // on calcule l'intersection des pcurves sans les restreindre a leur common point if (!oksea[0]) + { okinter = ChFi3d_IsInFront(DStr, CD[1], CD[2], @@ -325,6 +326,7 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) Vtx, false, true); + } } else if (oksea[2] && oksea[0] && !sameside[2] && !sameside[0]) { @@ -332,6 +334,7 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) deb = 2; fin = 0; if (!oksea[1]) + { okinter = ChFi3d_IsInFront(DStr, CD[0], CD[2], @@ -349,6 +352,7 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) Vtx, false, true); + } } else if (oksea[1] && oksea[0] && !sameside[1] && !sameside[0]) { @@ -356,6 +360,7 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) deb = 0; fin = 1; if (!oksea[2]) + { okinter = ChFi3d_IsInFront(DStr, CD[0], CD[1], @@ -373,22 +378,29 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) Vtx, false, true); + } } else if (oksea[0] && oksea[1] && oksea[2]) { // 3 concavites identiques. pivot = ChFi3d_SearchPivot(sens, p, tol2d); if (pivot < 0) + { // on prend un pivot au hasard!!!!!!!!!!!!!!! pivot = 0; + } deb = (pivot + 1) % 3; fin = (pivot + 2) % 3; CornerAllSame = true; } else + { throw Standard_Failure("FD en vis a vis non trouvees"); + } if (!okinter) + { throw Standard_Failure("Echec intersection PCurves OnCommonFace"); + } // on a le pivot, le CD deb et le CD fin (enfin on espere !?!) : // ------------------------------------------------------------- @@ -519,16 +531,22 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) double DistDebFin = (p3d[pivot]).Distance(p3d[3]); if (DistTmp > DistMin) + { DistMin = DistTmp; + } // on elargi la notion de triangle pour eviter de creer // des surfaces ecraser avec deux coins proches // attention ceci entraine un effet de seuil if (CornerAllSame) + { c1triangle = (DistDebFin < 0.3 * DistMin); + } if (c1triangle) + { p3d[pivot] = PSom; + } // on calcule la surface portant le coin //-------------------------------------- @@ -561,19 +579,27 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) gp_Dir xdir = gp_Dir(gp_Vec(p3d[fin], p3d[deb])); gp_Ax3 planAx3(p3d[pivot], ndir, xdir); if (planAx3.YDirection().Dot(v1) <= 0.) + { planAx3.YReverse(); + } occ::handle gpl = new Geom_Plane(planAx3); coin->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gpl, DStr)); // on oriente coin gp_Vec norface = norpl; if (face[pivot].Orientation() == TopAbs_REVERSED) + { norface.Reverse(); + } gp_Vec norcoin = gpl->Pln().Position().XDirection().Crossed(gpl->Pln().Position().YDirection()); if (norcoin.Dot(norface) <= 0.) + { coin->ChangeOrientation() = TopAbs_REVERSED; + } else + { coin->ChangeOrientation() = TopAbs_FORWARD; + } // on calcule les intersections occ::handle gcpiv, gcdeb, gcfin; @@ -599,16 +625,22 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) tolapp3d, tol2d, tolrcoinpiv)) + { throw StdFail_NotDone("echec calcul intersection coin-pivot"); + } gp_Vec norpiv = deru.Crossed(derv); // intersection coin-deb double tolrcoindeb; gp_Pnt2d p2d1, p2d2; if (c1triangle) + { p2d1 = fddeb->Interference(jf[deb][fin]).PCurveOnSurf()->Value(p[deb][fin]); + } else + { p2d1 = fddeb->Interference(jf[deb][fin]).PCurveOnSurf()->Value(p[deb][pivot]); + } p2d2 = fddeb->Interference(jf[deb][pivot]).PCurveOnSurf()->Value(p[deb][pivot]); @@ -628,7 +660,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) tolapp3d, tol2d, tolrcoindeb)) + { throw StdFail_NotDone("echec calcul intersection coin-deb"); + } Icf = DStr.AddCurve(TopOpeBRepDS_Curve(gcdeb, tolrcoindeb)); // intersection coin-fin @@ -661,7 +695,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) tolapp3d, tol2d, tolrcoinfin)) + { throw StdFail_NotDone("echec calcul intersection coin-face"); + } Icl = DStr.AddCurve(TopOpeBRepDS_Curve(gcfin, tolrcoinfin)); //! c1triangle: intersection coin-face[pivot] @@ -705,9 +741,13 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) coin->ChangeVertexFirstOnS1().SetPoint(p3d[pivot]); coin->ChangeVertexFirstOnS2().SetPoint(p3d[fin]); if (c1triangle) + { coin->ChangeVertexLastOnS1().SetPoint(p3d[pivot]); + } else + { coin->ChangeVertexLastOnS1().SetPoint(p3d[3]); + } coin->ChangeVertexLastOnS2().SetPoint(p3d[deb]); // avec les FaceInterference @@ -718,12 +758,18 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) // sur face[pivot] if (norcoin.Dot(norpl) <= 0.) + { trans = TopAbs_FORWARD; + } else + { trans = TopAbs_REVERSED; + } occ::handle bidpc; if (c1triangle) + { fi1.SetInterference(0, trans, bidpc, bidpc); + } else { Igcface = ChFiKPart_IndexCurveInDS(gcface, DStr); @@ -733,9 +779,13 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) } // sur le pivot if (norcoin.Dot(norpiv) <= 0.) + { trans = TopAbs_REVERSED; + } else + { trans = TopAbs_FORWARD; + } Igcpiv = ChFiKPart_IndexCurveInDS(gcpiv, DStr); fi2.SetInterference(Igcpiv, trans, pivpc1, pivpc2); fi2.SetFirstParameter(gcpiv->FirstParameter()); @@ -848,7 +898,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2(); ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1(); if (c1triangle) + { Pl1 = coin->ChangeVertexFirstOnS1(); + } const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2(); // le coin pour commencer, @@ -857,9 +909,13 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) If1 = ChFi3d_IndexPointInDS(Pf1, DStr); If2 = ChFi3d_IndexPointInDS(Pf2, DStr); if (c1triangle) + { Il1 = If1; + } else + { Il1 = ChFi3d_IndexPointInDS(Pl1, DStr); + } Il2 = ChFi3d_IndexPointInDS(Pl2, DStr); coin->ChangeIndexOfS1(DStr.AddShape(face[pivot])); @@ -951,7 +1007,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) int isurf1 = 1, isurf2 = 2; double par = p[deb][pivot], par2 = p[deb][pivot]; if (c1triangle) + { par2 = p[deb][fin]; + } if (rev) { isurf1 = 2; @@ -967,7 +1025,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) fddeb->ChangeInterference(isurf1).SetParameter(par2, isfirst); fddeb->ChangeInterference(isurf2).SetParameter(par, isfirst); if (c1plan) + { CD[deb]->ChangePCurve(isfirst) = debpc1; + } else { pp1 = fddeb->InterferenceOnS1().PCurveOnSurf()->Value(par); @@ -984,7 +1044,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) par = p[fin][pivot]; par2 = p[fin][pivot]; if (c1triangle) + { par2 = p[fin][deb]; + } if (rev) { isurf1 = 2; @@ -1000,7 +1062,9 @@ void ChFi3d_ChBuilder::PerformThreeCorner(const int Jndex) fdfin->ChangeInterference(isurf1).SetParameter(par2, isfirst); fdfin->ChangeInterference(isurf2).SetParameter(par, isfirst); if (c1plan) + { CD[fin]->ChangePCurve(isfirst) = finpc1; + } else { pp1 = fdfin->InterferenceOnS1().PCurveOnSurf()->Value(par); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder.cxx index a6dfda0610..d2b91f7239 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder.cxx @@ -82,9 +82,13 @@ static double MaxRad(const occ::handle& fsp, // 1: case of constant R if (fsp->IsConstant(IE)) + { return (fsp->Radius(IE)); - else // 2,3: case of sequence ParAndRad and(or) Laws + } + else + { // 2,3: case of sequence ParAndRad and(or) Laws return (fsp->MaxRadFromSeqAndLaws()); + } /* occ::handle HGuide = fsp->ElSpine(IE); @@ -118,7 +122,9 @@ static void SimulParams(const occ::handle& HGuide, // gp_Vec d1,d2; double radiussect; if (fsp->IsConstant()) + { radiussect = fsp->Radius(); + } else { radiussect = 0.; @@ -128,7 +134,9 @@ static void SimulParams(const occ::handle& HGuide, w = fi + i * longueur * 0.2; double temp = lc->Value(w); if (temp > radiussect) + { radiussect = temp; + } } } Fleche = radiussect * 0.05; @@ -216,7 +224,9 @@ void ChFi3d_FilBuilder::Add(const double Radius, const TopoDS_Edge& E) Add(E); int IC = Contains(E); if (IC) + { SetRadius(Radius, IC, E); + } } //================================================================================================= @@ -503,7 +513,9 @@ void ChFi3d_FilBuilder::SimulKPart(const occ::handle& SD) const double majr = To.MajorRadius(), minr = To.MinorRadius(); int n = (int)(36. * ang / M_PI + 1); if (n < 2) + { n = 2; + } sec = new NCollection_HArray1(1, n); for (int i = 1; i <= n; i++) { @@ -523,7 +535,9 @@ void ChFi3d_FilBuilder::SimulKPart(const occ::handle& SD) const double rad = Sp.Radius(); int n = (int)(36. * ang / M_PI + 1); if (n < 2) + { n = 2; + } sec = new NCollection_HArray1(1, n); for (int i = 1; i <= n; i++) { @@ -563,7 +577,9 @@ bool ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, { occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("SimulSurf : this is not the spine of the fillet"); + } occ::handle lin; #ifdef OCCT_DEBUG // TopAbs_Orientation Or = S1->Face().Orientation(); @@ -578,9 +594,13 @@ bool ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, double PFirst = First; if (intf) + { First = fsp->FirstParameter(1); + } if (intl) + { Last = fsp->LastParameter(fsp->NbEdges()); + } if (fsp->IsConstant()) { BRepBlend_ConstRad Func(S1, S2, HGuide); @@ -612,7 +632,9 @@ bool ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecOnS1, RecOnS2); if (!done) + { return false; + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -669,7 +691,9 @@ bool ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecOnS1, RecOnS2); if (!done) + { return false; + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -788,7 +812,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, { occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of the fillet"); + } occ::handle lin; // Flexible parameters! @@ -812,9 +838,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, double rad = fsp->Radius(); int petitchoix = 1; if (Or2 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(rad, Choix); finvc.Set(rad, petitchoix); finvp.Set(rad, petitchoix); @@ -890,9 +920,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, finv.Set(false, PCref1); int petitchoix = 1; if (Or2 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(Choix); finvc.Set(petitchoix); finvp.Set(petitchoix); @@ -926,7 +960,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecS, RecRst); if (!done) + { throw Standard_Failure("SimulSurf : Fail !"); + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -1008,7 +1044,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, { occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : it is not the spine of a fillet"); + } occ::handle lin; // Flexible parameters! @@ -1032,9 +1070,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, double rad = fsp->Radius(); int petitchoix = 1; if (Or1 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(rad, Choix); finvc.Set(rad, petitchoix); finvp.Set(rad, petitchoix); @@ -1069,7 +1111,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecS, RecRst); if (!done) + { throw Standard_Failure("SimulSurf : Failed Processing!"); + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -1108,9 +1152,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, finv.Set(false, PCref2); int petitchoix = 1; if (Or1 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(Choix); finvc.Set(petitchoix); finvp.Set(petitchoix); @@ -1144,7 +1192,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecS, RecRst); if (!done) + { throw Standard_Failure("SimulSurf : Fail !"); + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -1232,7 +1282,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, { occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : it is not the spine of a fillet"); + } occ::handle lin; // Flexible parameters! @@ -1262,9 +1314,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, double rad = fsp->Radius(); if (Or1 == TopAbs_REVERSED) + { ch1 = 3; + } if (Or2 == TopAbs_REVERSED) + { ch2 = 3; + } finv1.Set(rad, ch1); finvp1.Set(Choix); @@ -1305,7 +1361,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecP2, RecRst2); if (!done) + { throw Standard_Failure("SimulSurf : Failed processing!"); + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -1343,9 +1401,13 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, int ch11 = 1, ch22 = 2; if (Or1 == TopAbs_REVERSED) + { ch11 = 3; + } if (Or2 == TopAbs_REVERSED) + { ch22 = 3; + } finv1.Set(ch11); finvp1.Set(Choix); @@ -1387,7 +1449,9 @@ void ChFi3d_FilBuilder::SimulSurf(occ::handle& Data, RecRst2); if (!done) + { throw Standard_Failure("SimulSurf : Fail !"); + } int nbp = lin->NbPoints(); sec = new NCollection_HArray1(1, nbp); for (int i = 1; i <= nbp; i++) @@ -1447,7 +1511,9 @@ bool ChFi3d_FilBuilder::PerformFirstSection(const occ::handle& { occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } double TolGuide = HGuide->Resolution(tolapp3d); if (fsp->IsConstant()) { @@ -1497,15 +1563,21 @@ bool ChFi3d_FilBuilder::PerformSurf(NCollection_Sequence Data = SeqData(1); occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } bool gd1, gd2, gf1, gf2, maybesingular; occ::handle lin; TopAbs_Orientation Or = S1->Face().Orientation(); double PFirst = First; if (intf) + { First = fsp->FirstParameter(1); + } if (intl) + { Last = fsp->LastParameter(fsp->NbEdges()); + } if (fsp->IsConstant()) { BRepBlend_ConstRad Func(S1, S2, HGuide); @@ -1552,7 +1624,9 @@ bool ChFi3d_FilBuilder::PerformSurf(NCollection_Sequence Data = SeqData(1); occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } occ::handle lin; double PFirst = First; bool maybesingular; @@ -1684,9 +1768,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceRadius(); int petitchoix = 1; if (Or2 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(rad, Choix); finvc.Set(rad, petitchoix); finvp.Set(rad, petitchoix); @@ -1727,7 +1815,9 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or, true); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } else @@ -1742,9 +1832,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or, true); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } if (maybesingular) + { SplitSurf(SeqData, lin); + } } //================================================================================================= @@ -1822,7 +1920,9 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_Sequence Data = SeqData(1); occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } occ::handle lin; double PFirst = First; bool maybesingular; @@ -1841,9 +1941,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceRadius(); int petitchoix = 1; if (Or1 == TopAbs_REVERSED) + { petitchoix = 3; + } if (Choix % 2 == 0) + { petitchoix++; + } finv.Set(rad, Choix); finvc.Set(rad, petitchoix); finvp.Set(rad, petitchoix); @@ -1884,7 +1988,9 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or, false); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } else @@ -1899,9 +2005,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or, false); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } if (maybesingular) + { SplitSurf(SeqData, lin); + } } //================================================================================================= @@ -1986,7 +2100,9 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_Sequence Data = SeqData(1); occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } occ::handle lin; double PFirst = First; bool maybesingular; @@ -2010,9 +2126,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceRadius(); if (Or1 == TopAbs_REVERSED) + { ch1 = 3; + } if (Or2 == TopAbs_REVERSED) + { ch2 = 3; + } finv1.Set(rad, ch1); finvp1.Set(Choix); @@ -2059,7 +2179,9 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } else @@ -2082,9 +2204,13 @@ void ChFi3d_FilBuilder::PerformSurf(NCollection_SequenceFace().Orientation(); done = CompleteData(Data, func, lin, HS1, HS2, Or); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } maybesingular = (func.GetMinimalDistance() <= 100 * tolapp3d); } if (maybesingular) + { SplitSurf(SeqData, lin); + } } //================================================================================================= @@ -2146,7 +2276,9 @@ void ChFi3d_FilBuilder::SplitSurf(NCollection_SequenceNbPoints(); if (Nbpnt < 3) + { return; + } double UFirst, ULast, VFirst, VLast; TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); int ISurf; @@ -2175,7 +2307,9 @@ void ChFi3d_FilBuilder::SplitSurf(NCollection_SequencePoint(ii); b = P.Parameter(); courant = P.PointOnS1().Distance(P.PointOnS2()); @@ -2313,7 +2447,9 @@ void ChFi3d_FilBuilder::ExtentOneCorner(const TopoDS_Vertex& V, const occ::handl ChFi3d_IndexOfSurfData(V, S, Sens); double dU = Spine->LastParameter(Spine->NbEdges()); if (Spine->IsTangencyExtremity((Sens == 1))) + { return; // No extension in the queue + } if (Spine->Status((Sens == 1)) == ChFiDS_FreeBoundary) { @@ -2354,7 +2490,9 @@ void ChFi3d_FilBuilder::ExtentTwoCorner(const TopoDS_Vertex& dU = Spine->LastParameter(Spine->NbEdges()) * Coeff; occ::handle fsp = occ::down_cast(Spine); if (fsp->IsConstant()) + { rad = fsp->Radius(); + } else { TopoDS_Edge E = ChFi3d_EdgeFromV1(V, itel.Value(), Sens); @@ -2366,9 +2504,13 @@ void ChFi3d_FilBuilder::ExtentTwoCorner(const TopoDS_Vertex& } rad *= 1.5; if (rad > dU) + { dU = rad; + } if (dU > Eval) + { Eval = dU; + } } // One applies @@ -2376,7 +2518,9 @@ void ChFi3d_FilBuilder::ExtentTwoCorner(const TopoDS_Vertex& { ChFi3d_IndexOfSurfData(V, itel.Value(), Sens); if (!FF && Stripe == itel.Value()) + { Sens = -Sens; + } Stripe = itel.Value(); Spine = Stripe->Spine(); if (!Spine->IsTangencyExtremity((Sens == 1))) @@ -2422,7 +2566,9 @@ void ChFi3d_FilBuilder::ExtentThreeCorner(const TopoDS_Vertex& } occ::handle Spine = Stripe->Spine(); if (Spine->IsTangencyExtremity((Sens == 1))) + { return; // No extension on queue + } double dU = Spine->LastParameter(Spine->NbEdges()); if (Sens == 1) { @@ -2462,13 +2608,21 @@ void ChFi3d_FilBuilder::SetRegul() { TopoDS_Edge E = TopoDS::Edge(itc.Value()); if (reg.IsSurface1()) + { its1.Initialize(myCoup->NewFaces(reg.S1())); + } else + { its1.Initialize(myCoup->Merged(myDS->Shape(reg.S1()), TopAbs_IN)); + } if (reg.IsSurface2()) + { its2.Initialize(myCoup->NewFaces(reg.S2())); + } else + { its2.Initialize(myCoup->Merged(myDS->Shape(reg.S2()), TopAbs_IN)); + } if (its1.More() && its2.More()) { TopoDS_Face F1 = TopoDS::Face(its1.Value()); diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C2.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C2.cxx index 3599d63d26..7be2607f9d 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C2.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C2.cxx @@ -96,17 +96,25 @@ static bool ToricRotule(const BRepAdaptor_Surface& fac, occ::handle sp1 = occ::down_cast(c1->Spine()); occ::handle sp2 = occ::down_cast(c2->Spine()); if (sp1.IsNull() || sp2.IsNull()) + { return false; + } if (!sp1->IsConstant() || !sp2->IsConstant()) + { return false; + } if ((fac.GetType() != GeomAbs_Plane) || (s1.GetType() != GeomAbs_Plane) || (s2.GetType() != GeomAbs_Plane)) + { return false; + } gp_Dir df = fac.Plane().Position().Direction(); gp_Dir ds1 = s1.Plane().Position().Direction(); gp_Dir ds2 = s2.Plane().Position().Direction(); if (std::abs(df.Dot(ds1)) >= tolesp || std::abs(df.Dot(ds2)) >= tolesp) + { return false; + } double r1 = sp1->Radius(); double r2 = sp2->Radius(); return std::abs(r1 - r2) < tolesp; @@ -117,11 +125,17 @@ static void RemoveSD(occ::handle& Stripe, const int num1, const i NCollection_Sequence>& Seq = Stripe->ChangeSetOfSurfData()->ChangeSequence(); if (Seq.IsEmpty()) + { return; + } if (num1 == num2) + { Seq.Remove(num1); + } else + { Seq.Remove(num1, num2); + } } //================================================================================================= @@ -179,14 +193,22 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) // If two edges to rounded are tangent GeomPlate is called if (Sens1 == 1) + { E1 = st1->Spine()->Edges(1); + } else + { E1 = st1->Spine()->Edges(st1->Spine()->NbEdges()); + } if (Sens2 == 1) + { E2 = st2->Spine()->Edges(1); + } else + { E2 = st2->Spine()->Edges(st2->Spine()->NbEdges()); + } BRepAdaptor_Curve BCurv1(E1); BRepAdaptor_Curve BCurv2(E2); @@ -198,9 +220,13 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) CL1.Tangent(dir1); CL2.Tangent(dir2); if (Sens1 == -1) + { dir1.Reverse(); + } if (Sens2 == -1) + { dir2.Reverse(); + } double ang1; ang1 = std::abs(dir1.Angle(dir2)); if (ang1 < M_PI / 180.) @@ -301,13 +327,21 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) else { if (Sens1 == 1 && Isd1 != 1) + { RemoveSD(st1, 1, 1); + } if (Sens1 != 1 && Isd1 != nbsurf1) + { RemoveSD(st1, fin1, fin1); + } if (Sens2 == 1 && Isd2 != 1) + { RemoveSD(st2, 1, 1); + } if (Sens2 != 1 && Isd2 != nbsurf2) + { RemoveSD(st2, fin2, fin2); + } } Isd1 = ChFi3d_IndexOfSurfData(Vtx, st1, Sens1); Isd2 = ChFi3d_IndexOfSurfData(Vtx, st2, Sens2); @@ -344,7 +378,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) TopoDS_Edge pivot; bool yapiv = false; if (CP1.IsOnArc()) + { pivot = CP1.Arc(); + } else { PerformMoreThreeCorner(Index, 2); @@ -504,7 +540,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) bid = ChFi3d::NextSide(ori, OFF1, oriS, oriSFF1, bid); TopAbs_Orientation op1 = TopAbs_FORWARD, op2 = TopAbs_FORWARD; if (yapiv) + { bid = ChFi3d::ConcaveSide(BRS1, BRS2, pivot, op1, op2); + } op1 = TopAbs::Reverse(op1); op2 = TopAbs::Reverse(op2); #ifdef OCCT_DEBUG @@ -681,9 +719,13 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) If2 = ChFi3d_IndexPointInDS(Pf2, DStr); Il1 = ChFi3d_IndexPointInDS(Pl1, DStr); if (sameparam) + { Il2 = If2; + } else + { Il2 = ChFi3d_IndexPointInDS(Pl2, DStr); + } gp_Pnt2d pp1, pp2; pp1 = @@ -774,7 +816,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) coin->ChangeIndexOfS1(DStr.AddShape(FaCo)); if (sameparam) + { coin->ChangeIndexOfS2(0); + } else { coin->ChangeIndexOfS2(DStr.AddShape(FaPiv)); @@ -792,7 +836,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) sd1->ChangeVertex(isfirst1, IFaArc1) = Pf2; sd1->ChangeInterference(IFaCo1).SetParameter(par1, isfirst1); if (IFaCo1 == 2) + { st1->SetOrientation(TopAbs_REVERSED, isfirst1); + } // then the end Stripe, // ------------------------- @@ -804,7 +850,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) sd2->ChangeVertex(isfirst2, IFaArc2) = Pl2; sd2->ChangeInterference(IFaCo2).SetParameter(par2, isfirst2); if (IFaCo2 == 2) + { st2->SetOrientation(TopAbs_REVERSED, isfirst2); + } } #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch, t_t2cornerDS); // result perf update DS @@ -912,9 +960,13 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) if (std::abs(ppfacsam.X() - ppfacdif.X()) > Uperiod / 2) { if (ppfacdif.X() < ppfacsam.X()) + { ppfacdif.SetX(ppfacdif.X() + Uperiod); + } else + { ppfacdif.SetX(ppfacdif.X() - Uperiod); + } } } ////////////////// @@ -947,7 +999,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) ChFi3d_ResultChron(ch, t_remplissage); // result perf filling #endif if (!done) + { throw Standard_Failure("concavites inverted : fail"); + } #ifdef OCCT_DEBUG ChFi3d_InitChron(ch); // init perf update DS #endif @@ -999,7 +1053,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) TopAbs_Orientation OpcFopsam = sdsam->Interference(ifaopsam).Transition(); int IFopsam = sdsam->Index(ifaopsam); if (isfirstsam) + { OpcFopsam = TopAbs::Reverse(OpcFopsam); + } occ::handle interf = ChFi3d_FilCurveInDS(Icf, IFopsam, pcFopsam, OpcFopsam); DStr.ChangeShapeInterferences(IFopsam).Append(interf); @@ -1064,7 +1120,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) sdsam->ChangeInterferenceOnS1().SetParameter(uintpcsam, isfirstsam); sdsam->ChangeInterferenceOnS2().SetParameter(uintpcsam, isfirstsam); if (ifaopsam == 2) + { stsam->SetOrientation(TopAbs_REVERSED, isfirstsam); + } // then Stripe OnDiff // --------------------- @@ -1077,7 +1135,9 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index) sddif->ChangeVertex(isfirstdif, ifacodif) = Pl1; sddif->ChangeInterference(ifacodif).SetParameter(uintpcdif, isfirstdif); if (ifaopdif == 1) + { stdif->SetOrientation(TopAbs_REVERSED, isfirstdif); + } #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch, t_t2cornerDS); // result perf update DS #endif diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C3.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C3.cxx index 29b09e20c2..a33707e8bd 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C3.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_FilBuilder_C3.cxx @@ -203,7 +203,9 @@ static bool SearchFD(TopOpeBRepDS_DataStructure& DStr, } } if (fini1 && fini2) + { break; + } } return found; } @@ -434,7 +436,9 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) } } if (!c1toric) + { c1spheric = (std::abs(qr[0] - qr[1]) < tolapp3d && std::abs(qr[0] - qr[2]) < tolapp3d); + } } // Previously to avoid loops the points were always located @@ -506,18 +510,26 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) bidr); double distest = ptestdeb.Distance(ptestfin); if (distest < (Rdp + Rfp) * 0.05) + { filling = true; + } if (distest < (Rdp + Rfp) * 0.005) + { c1pointu = true; + } } if (!c1pointu) { if (!pivdif) + { c1pointu = (std::abs(p[deb][pivot] - p[deb][fin]) <= tol2d && std::abs(p[fin][pivot] - p[fin][deb]) <= tol2d); + } if (std::abs(p[pivot][deb] - p[pivot][fin]) <= tol2d) + { c1toric = ToricCorner(face[pivot], Rdeb, Rfin, Vdp); + } } // there is a pivot, the start and the end CD (finally !?!) : // ------------------------------------------------------------- @@ -608,9 +620,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) if (sens[deb] == 1) { if (choix % 2 == 1) + { choix++; + } else + { choix--; + } } } else @@ -619,9 +635,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) if (sens[deb] == -1) { if (choix % 2 == 1) + { choix++; + } else + { choix--; + } } } @@ -751,7 +771,9 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) WLast = 1.; } else + { locfleche = radpondere * (WLast - WFirst) * fleche; + } double pasmax = (WLast - WFirst) * 0.05; occ::handle cornerspine = new ChFiDS_ElSpine(); cornerspine->SetCurve(spinecoin); @@ -822,7 +844,9 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) filling = !done; } else + { filling = true; + } } else { @@ -873,7 +897,9 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) filling = !done; } else + { filling = true; + } } #ifdef OCCT_DEBUG @@ -894,6 +920,7 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) occ::handle Bdeb, Bfin, Bpiv, Bfac; occ::handle PCurveOnFace; if (!c1pointu) + { Bfac = ChFi3d_mkbound(Fac, PCurveOnFace, sens[deb], @@ -904,6 +931,7 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) vfac2, tolapp3d, 2.e-4); + } int kkk; gp_Pnt ppbid; gp_Vec vp1, vp2; @@ -958,9 +986,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) GeomFill_ConstrainedFilling fil(11, 20); if (c1pointu) + { fil.Init(Bpiv, Bfin, Bdeb, true); + } else + { fil.Init(Bpiv, Bfin, Bfac, Bdeb, true); + } occ::handle Surfcoin = fil.Surface(); Surfcoin->VReverse(); // revert to direction face surface; @@ -1005,13 +1037,17 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2(); ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1(); if (c1pointu) + { Pl1 = coin->ChangeVertexFirstOnS1(); + } const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2(); Bnd_Box bf1, bl1, bf2, bl2; Bnd_Box *pbf1 = &bf1, *pbl1 = &bl1, *pbf2 = &bf2, *pbl2 = &bl2; if (c1pointu) + { pbl1 = pbf1; + } pbf1->Add(Pf1.Point()); pbf2->Add(Pf2.Point()); pbl1->Add(Pl1.Point()); @@ -1023,16 +1059,24 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) If1 = ChFi3d_IndexPointInDS(Pf1, DStr); If2 = ChFi3d_IndexPointInDS(Pf2, DStr); if (c1pointu) + { Il1 = If1; + } else + { Il1 = ChFi3d_IndexPointInDS(Pl1, DStr); + } Il2 = ChFi3d_IndexPointInDS(Pl2, DStr); pp1 = coin->InterferenceOnS1().PCurveOnSurf()->Value(coin->InterferenceOnS1().FirstParameter()); pp2 = coin->InterferenceOnS2().PCurveOnSurf()->Value(coin->InterferenceOnS2().FirstParameter()); if (c1pointu) + { coin->ChangeIndexOfS1(0); + } else + { coin->ChangeIndexOfS1(DStr.AddShape(face[pivot])); + } coin->ChangeIndexOfS2(-fdpiv->Surf()); occ::handle C3d; @@ -1128,9 +1172,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) rev); tcdeb.Tolerance(std::max(tolrdeb, tcdeb.Tolerance())); if (rev) + { ChFi3d_EnlargeBox(DStr, CD[deb], fddeb, *pbf2, *pbf1, isfirst); + } else + { ChFi3d_EnlargeBox(DStr, CD[deb], fddeb, *pbf1, *pbf2, isfirst); + } // then the end CornerData, // ------------------------ @@ -1173,9 +1221,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) rev); tcfin.Tolerance(std::max(tolrfin, tcfin.Tolerance())); if (rev) + { ChFi3d_EnlargeBox(DStr, CD[fin], fdfin, *pbl2, *pbl1, isfirst); + } else + { ChFi3d_EnlargeBox(DStr, CD[fin], fdfin, *pbl1, *pbl2, isfirst); + } // anf finally the pivot. // ------------------ @@ -1215,9 +1267,13 @@ void ChFi3d_FilBuilder::PerformThreeCorner(const int Jndex) fdpiv->ChangeInterference(isurf2).SetParameter(p[pivot][fin], isfirst); CD[pivot]->InDS(isfirst); // filDS already does it from the corner. if (rev) + { ChFi3d_EnlargeBox(DStr, CD[pivot], fdpiv, *pbl2, *pbf2, isfirst); + } else + { ChFi3d_EnlargeBox(DStr, CD[pivot], fdpiv, *pbf2, *pbl2, isfirst); + } // To end the tolerances of points are rescaled. ChFi3d_SetPointTolerance(DStr, *pbf1, If1); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ChamfSpine.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ChamfSpine.cxx index e3c05d389b..0d8c6d0ca7 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ChamfSpine.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ChamfSpine.cxx @@ -67,7 +67,9 @@ void ChFiDS_ChamfSpine::SetDist(const double Dis) void ChFiDS_ChamfSpine::Dists(double& Dis1, double& Dis2) const { if (mChamf != ChFiDS_TwoDist) + { throw Standard_Failure("Chamfer is not a Two Dists Chamfer"); + } Dis1 = d1; Dis2 = d2; } @@ -88,7 +90,9 @@ void ChFiDS_ChamfSpine::GetDistAngle(double& Dis, double& Angle) const // bool& DisOnF1)const { if (mChamf != ChFiDS_DistAngle) + { throw Standard_Failure("Chamfer is not a Two Dists Chamfer"); + } Dis = d1; Angle = angle; // DisOnF1 = dison1; diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_CommonPoint.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_CommonPoint.cxx index 3b331f15b2..24baaa6977 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_CommonPoint.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_CommonPoint.cxx @@ -55,7 +55,9 @@ void ChFiDS_CommonPoint::SetArc(const double Tol, { isonarc = true; if (Tol > tol) + { tol = Tol; + } arc = A; prmarc = Param; traarc = TArc; diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx index 3ddf2ee0b7..6323b6d09a 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx @@ -163,7 +163,9 @@ void ChFiDS_ElSpine::SetPeriodic(const bool I) double ChFiDS_ElSpine::Period() const { if (!periodic) + { throw Standard_Failure("ElSpine non periodique"); + } return period; } @@ -228,7 +230,9 @@ void ChFiDS_ElSpine::SaveLastParameter() void ChFiDS_ElSpine::SetOrigin(const double O) { if (!periodic) + { throw Standard_Failure("Elspine non periodique"); + } occ::handle bs = occ::down_cast(curve.Curve()); if (!bs.IsNull()) { diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FaceInterference.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FaceInterference.cxx index 288924f380..7624f61b72 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FaceInterference.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FaceInterference.cxx @@ -30,9 +30,13 @@ ChFiDS_FaceInterference::ChFiDS_FaceInterference() void ChFiDS_FaceInterference::SetParameter(const double U1, const bool IsFirst) { if (IsFirst) + { SetFirstParameter(U1); + } else + { SetLastParameter(U1); + } } void ChFiDS_FaceInterference::SetTransition(const TopAbs_Orientation Trans) @@ -43,7 +47,11 @@ void ChFiDS_FaceInterference::SetTransition(const TopAbs_Orientation Trans) double ChFiDS_FaceInterference::Parameter(const bool IsFirst) const { if (IsFirst) + { return FirstParameter(); + } else + { return LastParameter(); + } } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FilSpine.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FilSpine.cxx index 3d62f424cb..a4667e7784 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FilSpine.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_FilSpine.cxx @@ -52,7 +52,9 @@ void ChFiDS_FilSpine::Reset(const bool AllData) ChFiDS_Spine::Reset(AllData); laws.Clear(); if (AllData) + { parandrad.Clear(); + } else // Complete parandrad { double spinedeb = FirstParameter(); @@ -72,7 +74,9 @@ void ChFiDS_FilSpine::Reset(const bool AllData) } if (IsPeriodic()) + { parandrad(parandrad.Length()).SetY(parandrad(1).Y()); + } } } @@ -100,12 +104,18 @@ void ChFiDS_FilSpine::UnSetRadius(const TopoDS_Edge& E) for (int i = 1; i <= parandrad.Length(); i++) { if (std::abs(parandrad(i).X() - Uf) <= gp::Resolution()) + { ifirst = i; + } if (std::abs(parandrad(i).X() - Ul) <= gp::Resolution()) + { ilast = i; + } } if (ifirst != 0 && ilast != 0) + { parandrad.Remove(ifirst, ilast); + } } //================================================================================================= @@ -134,7 +144,9 @@ void ChFiDS_FilSpine::SetRadius(const gp_XY& UandR, const int IinC) { double W; if (IinC == 0) + { W = UandR.X(); + } else { double Uf = FirstParameter(IinC); @@ -150,21 +162,31 @@ void ChFiDS_FilSpine::SetRadius(const gp_XY& UandR, const int IinC) { parandrad.ChangeValue(i).SetY(UandR.Y()); if (!splitdone) + { return; + } else + { break; + } } else if (parandrad.Value(i).X() > W) { parandrad.InsertBefore(i, pr); if (!splitdone) + { return; + } else + { break; + } } } if (i == parandrad.Length() + 1) + { parandrad.Append(pr); + } // si le split est done il faut rejouer la law // correspondant au parametre W @@ -174,7 +196,9 @@ void ChFiDS_FilSpine::SetRadius(const gp_XY& UandR, const int IinC) NCollection_List>::Iterator Itl(laws); occ::handle Els = It.Value(); if (Els->IsPeriodic()) + { Itl.ChangeValue() = ComputeLaw(Els); + } else { for (; It.More(); It.Next(), Itl.Next()) @@ -222,16 +246,20 @@ void ChFiDS_FilSpine::SetRadius(const occ::handle& C, const int /* bool ChFiDS_FilSpine::IsConstant() const { if (parandrad.IsEmpty()) + { return false; + } bool isconst = true; double Radius = parandrad(1).Y(); for (int i = 2; i <= parandrad.Length(); i++) + { if (std::abs(Radius - parandrad(i).Y()) > Precision::Confusion()) { isconst = false; break; } + } return isconst; } @@ -261,11 +289,17 @@ bool ChFiDS_FilSpine::IsConstant(const int IE) const par = parandrad(i).X(); rad = parandrad(i).Y(); if (std::abs(rad - StartRad) > Precision::Confusion()) + { return false; + } if (std::abs(Ul - par) <= gp::Resolution()) + { return true; + } if (par > Ul) + { return true; + } } return true; } @@ -304,11 +338,17 @@ double ChFiDS_FilSpine::Radius(const int IE) const par = parandrad(i).X(); rad = parandrad(i).Y(); if (std::abs(rad - StartRad) > Precision::Confusion()) + { throw Standard_DomainError("Edge is not constant"); + } if (std::abs(Ul - par) <= gp::Resolution()) + { return StartRad; + } if (par > Ul) + { return StartRad; + } } return StartRad; } @@ -318,7 +358,9 @@ double ChFiDS_FilSpine::Radius(const int IE) const double ChFiDS_FilSpine::Radius() const { if (!IsConstant()) + { throw Standard_DomainError("Spine is not constant"); + } return parandrad(1).Y(); } @@ -360,7 +402,9 @@ static void mklaw(NCollection_List>& res, const gp_XY& cur = pr.Value(i); double wcur = cur.X(); if (recadre) + { wcur = ElCLib::InPeriod(wcur, deb, fin); + } if (curdeb - tol3d <= wcur && wcur <= curfin + tol3d) { if (wcur - curdeb < tol3d) @@ -368,7 +412,9 @@ static void mklaw(NCollection_List>& res, yaunpointsurledeb = true; gp_XY ncur = cur; if (Rdeb < 0.) + { rad = cur.Y(); + } ncur.SetCoord(curdeb, rad); npr.Append(ncur); } @@ -377,12 +423,16 @@ static void mklaw(NCollection_List>& res, yaunpointsurlefin = true; gp_XY ncur = cur; if (Rfin < 0.) + { raf = cur.Y(); + } ncur.SetCoord(curfin, raf); npr.Append(ncur); } else + { npr.Append(gp_XY(wcur, cur.Y())); + } } } } @@ -390,7 +440,9 @@ static void mklaw(NCollection_List>& res, if (npr.IsEmpty()) { if (Rdeb < 0. && Rfin < 0.) + { throw Standard_DomainError("Impossible to create the law"); + } else if (Rdeb < 0. || Rfin < 0.) { double r = (Rfin < 0.) ? Rdeb : Rfin; @@ -408,9 +460,13 @@ static void mklaw(NCollection_List>& res, else { if (!yaunpointsurledeb && Rdeb >= 0.) + { npr.Append(gp_XY(curdeb, Rdeb)); + } if (!yaunpointsurlefin && Rfin >= 0.) + { npr.Append(gp_XY(curfin, Rfin)); + } int nbp = npr.Length(); // for(int i = 1; i < nbp; i++){ int i; @@ -437,7 +493,9 @@ static void mklaw(NCollection_List>& res, nbp--; } else + { i++; + } fini = (i >= nbp); } @@ -496,9 +554,13 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle ifin) + { bidfin += len; + } else if (fin > LastParameter(len) && ideb > ifin) + { bidfin += len; + } nbed = bidfin - ideb + 1; } NCollection_Array1 ind(1, nbed); @@ -530,9 +592,13 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle curloi = new Law_Constant(); curloi->Set(Rdeb, curdeb, curfin); list.Append(curloi); @@ -543,17 +609,23 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle len) { // no ! if (parandrad.IsEmpty()) + { throw Standard_DomainError("Radius not defined"); + } int nbp = parandrad.Length(); if (nbp > 1) { deb = parandrad.First().X(); fin = deb + Period(); if (parandrad.Last().X() - fin < -tol3d) + { nbp++; + } } else + { nbp++; + } NCollection_Array1 pr(1, nbp); for (int l = 1; l < nbp; l++) { @@ -586,30 +658,40 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle= curfin) + { curfin = fin; + } else + { curfin = std::min(fin, curfin); + } } else + { curfin = std::min(fin, curfin); + } } if ((curfin - curdeb) > tol3d) { @@ -711,7 +811,9 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle= curfin) + { curfin = fin; + } else + { curfin = std::min(fin, curfin); + } } // or if it is the end of spine with extension. else if (ind(icur) == len) + { curfin = fin; + } NCollection_List> temp; mklaw(temp, parandrad, curdeb, curfin, Rdeb, Rfin, IsPeriodic(), spinedeb, spinefin, tol3d); list.Append(temp); @@ -739,7 +847,9 @@ occ::handle ChFiDS_FilSpine::ComputeLaw(const occ::handle MaxRad) + { MaxRad = parandrad(i).Y(); + } + } NCollection_List>::Iterator itl(laws); for (; itl.More(); itl.Next()) @@ -800,11 +914,15 @@ double ChFiDS_FilSpine::MaxRadFromSeqAndLaws() const par = fpar + i * delta; rad = law->Value(par); if (rad > MaxRad) + { MaxRad = rad; + } } rad = law->Value(lpar); if (rad > MaxRad) + { MaxRad = rad; + } } return MaxRad; diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Regul.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Regul.cxx index 878b478443..1a0ffb268b 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Regul.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Regul.cxx @@ -37,9 +37,13 @@ void ChFiDS_Regul::SetCurve(const int IC) void ChFiDS_Regul::SetS1(const int IS1, const bool IsFace) { if (IsFace) + { is1 = std::abs(IS1); + } else + { is1 = -std::abs(IS1); + } } //================================================================================================= @@ -47,9 +51,13 @@ void ChFiDS_Regul::SetS1(const int IS1, const bool IsFace) void ChFiDS_Regul::SetS2(const int IS2, const bool IsFace) { if (IsFace) + { is2 = std::abs(IS2); + } else + { is2 = -std::abs(IS2); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Spine.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Spine.cxx index e2809667d7..7558676038 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Spine.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Spine.cxx @@ -109,14 +109,18 @@ occ::handle ChFiDS_Spine::ElSpine(const int IE) const { double wmil = 0.5 * (FirstParameter(IE) + LastParameter(IE)); if (IsPeriodic()) + { wmil = ElCLib::InPeriod(wmil, FirstParameter(), LastParameter()); + } return ElSpine(wmil); } occ::handle ChFiDS_Spine::ElSpine(const double W) const { if (elspines.Extent() == 1) + { return elspines.First(); + } else { NCollection_List>::Iterator It(elspines); @@ -126,7 +130,9 @@ occ::handle ChFiDS_Spine::ElSpine(const double W) const double uf = cur->FirstParameter(); double ul = cur->LastParameter(); if (uf <= W && W <= ul) + { return cur; + } } return occ::handle(); } @@ -180,7 +186,9 @@ void ChFiDS_Spine::Reset(const bool AllData) double ChFiDS_Spine::FirstParameter() const { if (firstprolon) + { return firstparam; + } return 0.; } @@ -189,7 +197,9 @@ double ChFiDS_Spine::FirstParameter() const double ChFiDS_Spine::LastParameter() const { if (lastprolon) + { return lastparam; + } return abscissa->Value(abscissa->Upper()); } @@ -227,7 +237,9 @@ void ChFiDS_Spine::SetLastParameter(const double Par) double ChFiDS_Spine::FirstParameter(const int IndexSpine) const { if (IndexSpine == 1) + { return 0.; + } return abscissa->Value(IndexSpine - 1); } @@ -243,7 +255,9 @@ double ChFiDS_Spine::LastParameter(const int IndexSpine) const double ChFiDS_Spine::Length(const int IndexSpine) const { if (IndexSpine == 1) + { return abscissa->Value(IndexSpine); + } return abscissa->Value(IndexSpine) - abscissa->Value(IndexSpine - 1); } @@ -267,7 +281,9 @@ TopoDS_Vertex ChFiDS_Spine::FirstVertex() const { TopoDS_Edge E = TopoDS::Edge(spine.First()); if (E.Orientation() == TopAbs_FORWARD) + { return TopExp::FirstVertex(E); + } return TopExp::LastVertex(E); } @@ -277,7 +293,9 @@ TopoDS_Vertex ChFiDS_Spine::LastVertex() const { TopoDS_Edge E = TopoDS::Edge(spine.Last()); if (E.Orientation() == TopAbs_FORWARD) + { return TopExp::LastVertex(E); + } return TopExp::FirstVertex(E); } @@ -316,7 +334,9 @@ double ChFiDS_Spine::Absc(const TopoDS_Vertex& V) const double ChFiDS_Spine::Period() const { if (!IsPeriodic()) + { throw Standard_Failure("Non-periodic Spine"); + } return abscissa->Value(abscissa->Upper()); } @@ -332,7 +352,9 @@ double ChFiDS_Spine::Resolution(const double R3d) const void ChFiDS_Spine::SetFirstTgt(const double W) { if (IsPeriodic()) + { throw Standard_Failure("No extension by tangent on periodic contours"); + } #ifdef OCCT_DEBUG if (W >= Precision::Confusion()) std::cout << "Interior extension at start of the guideline" << std::endl; @@ -351,7 +373,9 @@ void ChFiDS_Spine::SetFirstTgt(const double W) void ChFiDS_Spine::SetLastTgt(const double W) { if (IsPeriodic()) + { throw Standard_Failure("No extension by tangent periodic contours"); + } #ifdef OCCT_DEBUG double L = W - abscissa->Value(abscissa->Upper()); @@ -388,9 +412,13 @@ void ChFiDS_Spine::SetReference(const double W) hasref = true; double lll = abscissa->Value(abscissa->Upper()); if (IsPeriodic()) + { valref = ElCLib::InPeriod(W, 0., lll); + } else + { valref = W; + } } //================================================================================================= @@ -399,9 +427,13 @@ void ChFiDS_Spine::SetReference(const int I) { hasref = true; if (I == 1) + { valref = abscissa->Value(1) * 0.5; + } else + { valref = (abscissa->Value(I) + abscissa->Value(I - 1)) * 0.5; + } } //================================================================================================= @@ -413,23 +445,35 @@ int ChFiDS_Spine::Index(const double W, const bool Forward) const double f = 0., l = 0., t = std::max(tolesp, Precision::Confusion()); if (IsPeriodic() && std::abs(par) >= t && std::abs(par - last) >= t) + { par = ElCLib::InPeriod(par, 0., last); + } for (ind = 1; ind <= len; ind++) { f = l; l = abscissa->Value(ind); if (par < l || ind == len) + { break; + } } if (Forward && ind < len && std::abs(par - l) < t) + { ind++; + } else if (!Forward && ind > 1 && std::abs(par - f) < t) + { ind--; + } else if (Forward && IsPeriodic() && ind == len && std::abs(par - l) < t) + { ind = 1; + } else if (!Forward && IsPeriodic() && ind == 1 && std::abs(par - f) < t) + { ind = len; + } return ind; } @@ -440,7 +484,9 @@ int ChFiDS_Spine::Index(const TopoDS_Edge& E) const for (int IE = 1; IE <= spine.Length(); IE++) { if (E.IsSame(spine.Value(IE))) + { return IE; + } } return 0; } @@ -524,7 +570,9 @@ void ChFiDS_Spine::Parameter(const double AbsC, double& U, const bool Oriented) for (Index = 1; Index < abscissa->Length(); Index++) { if (AbsC < abscissa->Value(Index)) + { break; + } } Parameter(Index, AbsC, U, Oriented); } @@ -574,7 +622,9 @@ void ChFiDS_Spine::Prepare(double& L, int& Ind) const double last = abscissa->Value(abscissa->Upper()); int len = abscissa->Length(); if (IsPeriodic() && std::abs(L) >= tol && std::abs(L - last) >= tol) + { L = ElCLib::InPeriod(L, 0., last); + } if (hasfirsttgt && (L <= firsttgtpar)) { @@ -613,19 +663,25 @@ void ChFiDS_Spine::Prepare(double& L, int& Ind) const for (Ind = 1; Ind < len; Ind++) { if (L < abscissa->Value(Ind)) + { break; + } } if (hasref) { if (L >= valref && Ind != 1) { if (std::abs(L - abscissa->Value(Ind - 1)) <= Precision::Confusion()) + { Ind--; + } } else if (L <= valref && Ind != len) { if (std::abs(L - abscissa->Value(Ind)) <= Precision::Confusion()) + { Ind++; + } } } } @@ -730,7 +786,9 @@ void ChFiDS_Spine::D1(const double AbsC, gp_Pnt& P, gp_Vec& V1) myCurve.D1(GCP.Parameter(), P, V1); double D1 = 1. / V1.Magnitude(); if (spine.Value(Index).Orientation() == TopAbs_REVERSED) + { D1 = -D1; + } V1.Multiply(D1); } } @@ -785,7 +843,9 @@ void ChFiDS_Spine::D2(const double AbsC, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) V2.Add(Va); double D1 = 1. / N1; if (spine.Value(Index).Orientation() == TopAbs_REVERSED) + { D1 = -D1; + } V1.Multiply(D1); } } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Stripe.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Stripe.cxx index 1741688073..282702e67a 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Stripe.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_Stripe.cxx @@ -89,9 +89,13 @@ void ChFiDS_Stripe::SetParameters(const bool First, const double Pdeb, const dou int ChFiDS_Stripe::Curve(const bool First) const { if (First) + { return indexOfcurve1; + } else + { return indexOfcurve2; + } } //================================================================================================= @@ -99,9 +103,13 @@ int ChFiDS_Stripe::Curve(const bool First) const void ChFiDS_Stripe::SetCurve(const int Index, const bool First) { if (First) + { indexOfcurve1 = Index; + } else + { indexOfcurve2 = Index; + } } //======================================================================= @@ -112,9 +120,13 @@ void ChFiDS_Stripe::SetCurve(const int Index, const bool First) const occ::handle& ChFiDS_Stripe::PCurve(const bool First) const { if (First) + { return pcrv1; + } else + { return pcrv2; + } } //================================================================================================= @@ -122,9 +134,13 @@ const occ::handle& ChFiDS_Stripe::PCurve(const bool First) const occ::handle& ChFiDS_Stripe::ChangePCurve(const bool First) { if (First) + { return pcrv1; + } else + { return pcrv2; + } } //================================================================================================= @@ -132,9 +148,13 @@ occ::handle& ChFiDS_Stripe::ChangePCurve(const bool First) TopAbs_Orientation ChFiDS_Stripe::Orientation(const int OnS) const { if (OnS == 1) + { return myOr1; + } else + { return myOr2; + } } //================================================================================================= @@ -142,9 +162,13 @@ TopAbs_Orientation ChFiDS_Stripe::Orientation(const int OnS) const void ChFiDS_Stripe::SetOrientation(const TopAbs_Orientation Or, const int OnS) { if (OnS == 1) + { myOr1 = Or; + } else + { myOr2 = Or; + } } //================================================================================================= @@ -152,9 +176,13 @@ void ChFiDS_Stripe::SetOrientation(const TopAbs_Orientation Or, const int OnS) TopAbs_Orientation ChFiDS_Stripe::Orientation(const bool First) const { if (First) + { return orcurv1; + } else + { return orcurv2; + } } //================================================================================================= @@ -162,9 +190,13 @@ TopAbs_Orientation ChFiDS_Stripe::Orientation(const bool First) const void ChFiDS_Stripe::SetOrientation(const TopAbs_Orientation Or, const bool First) { if (First) + { orcurv1 = Or; + } else + { orcurv2 = Or; + } } //================================================================================================= @@ -174,16 +206,24 @@ int ChFiDS_Stripe::IndexPoint(const bool First, const int OnS) const if (First) { if (OnS == 1) + { return indexfirstPOnS1; + } else + { return indexfirstPOnS2; + } } else { if (OnS == 1) + { return indexlastPOnS1; + } else + { return indexlastPOnS2; + } } } @@ -194,16 +234,24 @@ void ChFiDS_Stripe::SetIndexPoint(const int Index, const bool First, const int O if (First) { if (OnS == 1) + { indexfirstPOnS1 = Index; + } else + { indexfirstPOnS2 = Index; + } } else { if (OnS == 1) + { indexlastPOnS1 = Index; + } else + { indexlastPOnS2 = Index; + } } } @@ -237,7 +285,11 @@ void ChFiDS_Stripe::InDS(const bool First, int ChFiDS_Stripe::IsInDS(const bool First) const { if (First) + { return begfilled; + } else + { return endfilled; + } } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_SurfData.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_SurfData.cxx index 0ffee2ba38..8f256fa734 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_SurfData.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_SurfData.cxx @@ -76,9 +76,13 @@ void ChFiDS_SurfData::Copy(const occ::handle& Other) int ChFiDS_SurfData::Index(const int OfS) const { if (OfS == 1) + { return indexOfS1; + } else + { return indexOfS2; + } } //================================================================================================= @@ -86,9 +90,13 @@ int ChFiDS_SurfData::Index(const int OfS) const const ChFiDS_FaceInterference& ChFiDS_SurfData::Interference(const int OnS) const { if (OnS == 1) + { return intf1; + } else + { return intf2; + } } //================================================================================================= @@ -96,9 +104,13 @@ const ChFiDS_FaceInterference& ChFiDS_SurfData::Interference(const int OnS) cons ChFiDS_FaceInterference& ChFiDS_SurfData::ChangeInterference(const int OnS) { if (OnS == 1) + { return intf1; + } else + { return intf2; + } } //================================================================================================= @@ -106,13 +118,21 @@ ChFiDS_FaceInterference& ChFiDS_SurfData::ChangeInterference(const int OnS) const ChFiDS_CommonPoint& ChFiDS_SurfData::Vertex(const bool First, const int OnS) const { if (First && OnS == 1) + { return pfirstOnS1; + } else if (First && OnS == 2) + { return pfirstOnS2; + } else if (!First && OnS == 1) + { return plastOnS1; + } else + { return plastOnS2; + } } //================================================================================================= @@ -120,13 +140,21 @@ const ChFiDS_CommonPoint& ChFiDS_SurfData::Vertex(const bool First, const int On ChFiDS_CommonPoint& ChFiDS_SurfData::ChangeVertex(const bool First, const int OnS) { if (First && OnS == 1) + { return pfirstOnS1; + } else if (First && OnS == 2) + { return pfirstOnS2; + } else if (!First && OnS == 1) + { return plastOnS1; + } else + { return plastOnS2; + } } //================================================================================================= @@ -225,11 +253,17 @@ gp_Pnt2d ChFiDS_SurfData::Get2dPoints(const bool First, const int OnS) const { if (First && OnS == 1) + { return p2df1; + } else if (!First && OnS == 1) + { return p2dl1; + } else if (First && OnS == 2) + { return p2df2; + } return p2dl2; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData.cxx index 7980ba8f8e..fa63593d93 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData.cxx @@ -67,18 +67,26 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, GeomAbs_CurveType ctyp; if (!Spine.IsNull()) + { ctyp = Spine->CurrentElementarySpine(Iedge).GetType(); + } else + { ctyp = CSpine->CurrentElementarySpine(Iedge).GetType(); + } // Return orientations. TopAbs_Orientation OrFace1 = TopAbs_FORWARD, OrFace2 = TopAbs_FORWARD; occ::handle HS = occ::down_cast(S1); if (!HS.IsNull()) + { OrFace1 = HS->Face().Orientation(); + } HS = occ::down_cast(S2); if (!HS.IsNull()) + { OrFace2 = HS->Face().Orientation(); + } if (!Spine.IsNull()) { @@ -99,6 +107,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder) { if (ctyp == GeomAbs_Line) + { surfok = ChFiKPart_MakeFillet(DStr, Data, S1->Plane(), @@ -112,7 +121,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } else + { surfok = ChFiKPart_MakeFillet(DStr, Data, S1->Plane(), @@ -126,10 +137,12 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } } else if (typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane) { if (ctyp == GeomAbs_Line) + { surfok = ChFiKPart_MakeFillet(DStr, Data, S2->Plane(), @@ -143,7 +156,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } else + { surfok = ChFiKPart_MakeFillet(DStr, Data, S2->Plane(), @@ -157,6 +172,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } } else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone) { @@ -223,6 +239,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -238,7 +255,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } else + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -254,10 +273,12 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } } else if (typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -273,7 +294,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } else + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -289,6 +312,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } } else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone) { @@ -353,6 +377,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -368,7 +393,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } else + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -384,10 +411,12 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace1, true); + } } else if (typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -403,7 +432,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } else + { surfok = ChFiKPart_MakeChamfer(DStr, Data, aMode, @@ -419,6 +450,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, Wref, OrFace2, false); + } } else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone) { @@ -484,6 +516,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChAsym(DStr, Data, S1->Plane(), @@ -499,7 +532,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, OrFace1, true, DisOnP); + } else + { surfok = ChFiKPart_MakeChAsym(DStr, Data, S1->Plane(), @@ -515,10 +550,12 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, OrFace1, true, DisOnP); + } } else if (typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane) { if (ctyp == GeomAbs_Circle) + { surfok = ChFiKPart_MakeChAsym(DStr, Data, S2->Plane(), @@ -534,7 +571,9 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, OrFace2, false, DisOnP); + } else + { surfok = ChFiKPart_MakeChAsym(DStr, Data, S2->Plane(), @@ -550,6 +589,7 @@ bool ChFiKPart_ComputeData::Compute(TopOpeBRepDS_DataStructure& DStr, OrFace2, false, DisOnP); + } } else if (typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone) { diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_CS.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_CS.cxx index 9afc7d9c13..a5b6235972 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_CS.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_CS.cxx @@ -61,7 +61,9 @@ void ChFiKPart_CornerSpine(const occ::handle& S1, gp_Ax2 circax2(cent, dx ^ dy, dx); gp_Ax3 cylax3(circax2); if ((du ^ dv).Dot(dx) < 0.) + { cylax3.ZReverse(); + } First = 0.; Last = ElCLib::CircleParameter(circax2, P2); circ.SetPosition(circax2); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCon.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCon.cxx index ad37b9bcea..452e882e27 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCon.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCon.cxx @@ -75,9 +75,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir Dpl = PosPl.XDirection().Crossed(PosPl.YDirection()); gp_Dir norf = Dpl; if (Ofpl == TopAbs_REVERSED) + { norf.Reverse(); + } if (Or1 == TopAbs_REVERSED) + { Dpl.Reverse(); + } // compute the origin of the conical chamfer PtPl gp_Pnt Or = Con.Location(); @@ -99,7 +103,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, ElSLib::D1(u, v, Con, PtCon, deru, derv); gp_Dir Dcon(deru.Crossed(derv)); if (Or2 == TopAbs_REVERSED) + { Dcon.Reverse(); + } bool dedans = (Dx.Dot(Dcon) <= 0.); bool ouvert = (Dpl.Dot(Dcon) >= 0.); @@ -135,7 +141,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, { ChamfRad = Spine.Radius() - Dis; if (std::abs(ChamfRad) < Precision::Confusion()) + { pointu = true; + } if (ChamfRad < 0) { #ifdef OCCT_DEBUG @@ -180,7 +188,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, Dis1 = move * std::tan(SemiAngl) - Dis * std::abs(std::sin(angCon)); if (!dedans) + { SemiAngl = -SemiAngl; + } } else { @@ -197,10 +207,14 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, } if (SemiAngl > Precision::Confusion()) + { isConPar = true; + } if (dedans) + { SemiAngl = -SemiAngl; + } } // compute the parameters of the conical chamfer @@ -209,7 +223,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, ChamfRad = Spine.Radius() - Dis1; if (std::abs(ChamfRad) < Precision::Confusion()) + { pointu = true; + } if (ChamfRad < 0) { #ifdef OCCT_DEBUG @@ -225,9 +241,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, } if (ouvert) + { dis = Dis1 + Dis * std::abs(std::sin(angCon)); + } else + { dis = Dis1 - Dis * std::abs(std::sin(angCon)); + } } Or.SetCoord(Or.X() + move * Dpl.X(), Or.Y() + move * Dpl.Y(), Or.Z() + move * Dpl.Z()); @@ -264,13 +284,19 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, torevcha = ((torevcha && !plandab) || (!torevcha && plandab)); if (torevcha) + { cylaxe.Reverse(); + } bool toreverse = (norf.Dot(cylaxe) < 0.); if ((toreverse && dedans) || (!toreverse && !dedans)) + { Data->ChangeOrientation() = TopAbs_REVERSED; + } else + { Data->ChangeOrientation() = TopAbs_FORWARD; + } // we load the faceInterference with the pcurves and // the 3d curves @@ -342,9 +368,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, // intersection cone-chamfer double Rad; if (dedans) + { Rad = ChamfRad + dis; + } else + { Rad = ChamfRad - dis; + } CirAx2.SetLocation(Or); gp_Circ CirCon(CirAx2, Rad); @@ -352,9 +382,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, // pcurve on chamfer if (plandab) + { v = sqrt(dis * dis + move * move); + } else + { v = -sqrt(dis * dis + move * move); + } p2dch.SetCoord(0., v); ElSLib::CylinderD1(0., v, ChamfAx3, ChamfRad, Pt, deru, derv); lin2dch.SetLocation(p2dch); @@ -365,20 +399,32 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, ElSLib::Parameters(Con, Pt, u, v); double tol = Precision::PConfusion(); if (u >= 2 * M_PI - tol && u <= 2 * M_PI) + { u = 0.; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ElCLib::InPeriod(u, fu, fu + 2 * M_PI); + } ElSLib::D1(u, v, Con, Pt, deru, derv); gp_Pnt2d p2dCon(u, v); gp_Dir2d d2dCon; if (deru.Dot(DSp) <= 0.) + { d2dCon = -gp::DX2d(); + } else + { d2dCon = gp::DX2d(); + } gp_Lin2d lin2dCon(p2dCon, d2dCon); occ::handle GLin2dCon = new Geom2d_Line(lin2dCon); @@ -387,7 +433,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir DirCon = (Con.Axis()).Direction(); if (angCon > Precision::Confusion()) + { DirCon.Reverse(); + } bool torevcon = (norcon.Dot(DirCon) < 0.); if ((torevcon && dedans) || (!torevcon && !dedans)) @@ -444,9 +492,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Pnt P; u = 0.; if (plandab) + { v = sqrt(dis * dis + move * move); + } else + { v = -sqrt(dis * dis + move * move); + } ElSLib::ConeD1(u, v, ChamfAx3, ChamfRad, SemiAngl, P, deru, derv); gp_Dir norchamf(deru.Crossed(derv)); @@ -454,12 +506,18 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, bool toreverse = (norf.Dot(norchamf) < 0.); if (isConPar) + { toreverse = !toreverse; + } if (toreverse) + { Data->ChangeOrientation() = TopAbs_REVERSED; + } else + { Data->ChangeOrientation() = TopAbs_FORWARD; + } // we load the faceInterference with the pcurves and // the 3d curves @@ -502,11 +560,15 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, TopAbs_Orientation trans; gp_Dir norpl = PosPl.XDirection().Crossed(PosPl.YDirection()); if (!pointu) + { norchamf.SetXYZ(deru.Crossed(derv).XYZ()); + } toreverse = (norchamf.Dot(norpl) <= 0.); if (isConPar) + { toreverse = !toreverse; + } if ((toreverse && plandab) || (!toreverse && !plandab)) { @@ -537,9 +599,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, // intersection cone-chamfer double Rad; if (dedans) + { Rad = ChamfRad + dis; + } else + { Rad = ChamfRad - dis; + } CirAx2.SetLocation(Or); gp_Circ CirCon(CirAx2, Rad); @@ -547,9 +613,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, // pcurve on chamfer if (plandab) + { v = sqrt(dis * dis + move * move); + } else + { v = -sqrt(dis * dis + move * move); + } p2dch.SetCoord(0., v); ElSLib::ConeD1(0., v, ChamfAx3, ChamfRad, SemiAngl, Pt, deru, derv); lin2dch.SetLocation(p2dch); @@ -562,20 +632,32 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, ElSLib::Parameters(Con, Pt, u, v); double tol = Precision::PConfusion(); if (u >= 2 * M_PI - tol && u <= 2 * M_PI) + { u = 0.; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ElCLib::InPeriod(u, fu, fu + 2 * M_PI); + } ElSLib::D1(u, v, Con, Pt, deru, derv); gp_Pnt2d p2dCon(u, v); gp_Dir2d d2dCon; if (deru.Dot(DSp) <= 0.) + { d2dCon = -gp::DX2d(); + } else + { d2dCon = gp::DX2d(); + } gp_Lin2d lin2dCon(p2dCon, d2dCon); occ::handle GLin2dCon = new Geom2d_Line(lin2dCon); @@ -585,9 +667,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir DirCon = (Con.Axis()).Direction(); gp_Dir DirChamf = (gcon->Axis()).Direction(); if (angCon > Precision::Confusion()) + { DirCon.Reverse(); + } if (SemiAngl > Precision::Confusion()) + { DirChamf.Reverse(); + } bool torevcon = (norcon.Dot(DirCon) > 0.); bool torevcha = (norchamf.Dot(DirChamf) > 0.); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCyl.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCyl.cxx index 64cc46da03..8f658671d3 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCyl.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnCyl.cxx @@ -85,9 +85,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir Dpl = PosPl.XDirection().Crossed(PosPl.YDirection()); gp_Dir norf = Dpl; if (Ofpl == TopAbs_REVERSED) + { norf.Reverse(); + } if (Or1 == TopAbs_REVERSED) + { Dpl.Reverse(); + } // compute the origin Or of the cone gp_Pnt Or = Cyl.Location(); @@ -109,7 +113,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, ElSLib::D1(u, v, Cyl, PtCyl, Vu, Vv); gp_Dir Dcyl(Vu.Crossed(Vv)); // normal to the cylinder in PtSp if (Or2 == TopAbs_REVERSED) + { Dcyl.Reverse(); + } bool dedans = (Dcyl.Dot(Dx) <= 0.); bool pointu = false; @@ -147,7 +153,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, { Rad = Cyl.Radius() - dis1; if (std::abs(Rad) <= Precision::Confusion()) + { pointu = true; + } if (Rad < 0) { #ifdef OCCT_DEBUG @@ -235,9 +243,13 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, // pcurve on the chamfer gp_Pnt2d p2dch; if (plandab) + { v = -sqrt(dis1 * dis1 + dis2 * dis2); + } else + { v = sqrt(dis1 * dis1 + dis2 * dis2); + } p2dch.SetCoord(0., v); ElSLib::ConeD1(0., v, ConAx3, ConRad, SemiAngl, Pt, deru, derv); gp_Lin2d lin2dch(p2dch, gp::DX2d()); @@ -292,13 +304,21 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, double tol = Precision::PConfusion(); bool careaboutsens = false; if (std::abs(lu - fu - 2 * M_PI) < tol) + { careaboutsens = true; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ChFiKPart_InPeriod(u, fu, fu + 2 * M_PI, tol); + } ElSLib::D1(u, v, Cyl, Pt, deru, derv); gp_Dir norcyl = deru.Crossed(derv); @@ -307,10 +327,14 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, { d2dCyl.Reverse(); if (careaboutsens && std::abs(fu - u) < tol) + { u = lu; + } } else if (careaboutsens && std::abs(lu - u) < tol) + { u = fu; + } gp_Pnt2d p2dCyl(u, v); gp_Lin2d lin2dCyl(p2dCyl, d2dCyl); occ::handle GLin2dCyl = new Geom2d_Line(lin2dCyl); @@ -426,7 +450,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, double cosAhOC = cosA1 * sinAl + sinA1 * cosAl; double sinAhOC = sinA1 * sinAl - cosA1 * cosAl; if (cosA1 > 0) + { sinAhOC = -sinAhOC; + } double temp1 = h / ray, temp2 = sinAhOC * sinAhOC + temp1 * cosAhOC; dis2 = temp2 + temp1 * (cosAhOC - temp1); @@ -490,7 +516,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, double cosA11 = dis2 / (2. * ray); double sinA11 = std::sqrt(1. - cosA11 * cosA11); if (cosA1 > 0) + { sinA11 = -sinA11; + } dis1 = (sinA1 + cosA1 * tgAng) * cosA11; dis1 -= (cosA1 - sinA1 * tgAng) * sinA11; dis1 = (dis2 * tgAng) / dis1; @@ -539,7 +567,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, bool PosChamfPln = DirPlnCyl.Dot(DirSPln) > 0; if (!IsDisOnP && PosChamfPln) + { toreverse = !toreverse; + } // It is checked if the orientation of the Chamfer is the same as of the plane if (toreverse) { @@ -599,7 +629,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, toreverse = (NorFil.Dot(NorCyl) <= 0.); if (IsDisOnP && PosChamfCyl) + { toreverse = !toreverse; + } trans = TopAbs_REVERSED; if ((!plandab && toreverse) || (plandab && !toreverse)) { @@ -607,14 +639,18 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, } if (plandab) + { Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } else + { Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } return true; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnPln.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnPln.cxx index cd833c40cd..a3196427c7 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnPln.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChAsymPlnPln.cxx @@ -99,11 +99,15 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir LinAx1 = Spine.Direction(); gp_Dir VecTransl1 = LinAx1.Crossed(D1); if (VecTransl1.Dot(D2) < 0.) + { VecTransl1.Reverse(); + } gp_Dir VecTransl2 = LinAx1.Crossed(D2); if (VecTransl2.Dot(D1) < 0.) + { VecTransl2.Reverse(); + } double cosP, sinP, dis1, dis2; cosP = VecTransl1.Dot(VecTransl2); @@ -146,7 +150,9 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir xdir = LinAx1; // u axis gp_Ax3 PlanAx3(Po, AxisPlan, xdir); if (PlanAx3.YDirection().Dot(D2) >= 0.) + { PlanAx3.YReverse(); + } occ::handle gpl = new Geom_Plane(PlanAx3); Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gpl, DStr)); @@ -166,12 +172,18 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, gp_Dir DirCh12(gp_Vec(P1, P2)); bool toreverse = (norplch.Dot(norface1) <= 0.); if (VecTransl1.Dot(DirCh12) > 0) + { toreverse = !toreverse; + } if (toreverse) + { Data->ChangeOrientation() = TopAbs_REVERSED; + } else + { Data->ChangeOrientation() = TopAbs_FORWARD; + } // Loading of the FaceInterferences with pcurves & 3d curves. @@ -195,11 +207,17 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, TopAbs_Orientation trans; toreverse = (norplch.Dot(norpl) <= 0.); if (VecTransl1.Dot(DirCh12) > 0) + { toreverse = !toreverse; + } if (toreverse) + { trans = TopAbs_FORWARD; + } else + { trans = TopAbs_REVERSED; + } Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(GLinPln1, DStr), trans, @@ -227,11 +245,17 @@ bool ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr, norpl = Pos2.XDirection().Crossed(Pos2.YDirection()); toreverse = (norplch.Dot(norpl) <= 0.); if (VecTransl2.Dot(DirCh12) < 0) + { toreverse = !toreverse; + } if (toreverse) + { trans = TopAbs_REVERSED; + } else + { trans = TopAbs_FORWARD; + } Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(GLinPln2, DStr), trans, diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCon.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCon.cxx index 17ba4bc5ff..9897fd541a 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCon.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCon.cxx @@ -69,7 +69,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, double Alpha = M_PI / 2 - angcon; double CosHalfAlpha = std::cos(Alpha / 2); if (theMode == ChFiDS_ConstThroatChamfer) + { Dis1 = Dis2 = theDis1 / CosHalfAlpha; + } else if (theMode == ChFiDS_ConstThroatWithPenetrationChamfer) { double aDis1 = std::min(theDis1, theDis2); @@ -91,7 +93,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, gp_Ax3 PosPl = Pln.Position(); gp_Dir Dpl = PosPl.XDirection().Crossed(PosPl.YDirection()); if (Or1 == TopAbs_REVERSED) + { Dpl.Reverse(); + } // compute the origin of the conical chamfer PtPl gp_Pnt Or = Con.Location(); @@ -115,7 +119,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, ElSLib::D1(u, v, Con, PtCon, deru, derv); gp_Dir Dcon(deru.Crossed(derv)); if (Or2 == TopAbs_REVERSED) + { Dcon.Reverse(); + } bool ouvert = (Dpl.Dot(Dcon) >= 0.); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCyl.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCyl.cxx index 88892ae1e7..24866e2d04 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCyl.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnCyl.cxx @@ -82,7 +82,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, double Dis1 = theDis1, Dis2 = theDis2; if (theMode == ChFiDS_ConstThroatChamfer) + { Dis1 = Dis2 = theDis1 * sqrt(2.); + } else if (theMode == ChFiDS_ConstThroatWithPenetrationChamfer) { double aDis2 = std::min(theDis1, theDis2); @@ -96,9 +98,13 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, gp_Dir Dpl = PosPl.XDirection().Crossed(PosPl.YDirection()); gp_Dir norf = Dpl; if (Ofpl == TopAbs_REVERSED) + { norf.Reverse(); + } if (Or1 == TopAbs_REVERSED) + { Dpl.Reverse(); + } // compute the origin Or of the cone gp_Pnt Or = Cyl.Location(); @@ -120,7 +126,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, ElSLib::D1(u, v, Cyl, PtCyl, Vu, Vv); gp_Dir Dcyl(Vu.Crossed(Vv)); // normal to the cylinder in PtSp if (Or2 == TopAbs_REVERSED) + { Dcyl.Reverse(); + } bool dedans = (Dcyl.Dot(Dx) <= 0.); bool pointu = false; @@ -139,7 +147,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, { Rad = Cyl.Radius() - Dis1; if (std::abs(Rad) <= Precision::Confusion()) + { pointu = true; + } if (Rad < 0) { #ifdef OCCT_DEBUG @@ -229,9 +239,13 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, // pcurve on the chamfer gp_Pnt2d p2dch; if (plandab) + { v = -sqrt(Dis1 * Dis1 + Dis2 * Dis2); + } else + { v = sqrt(Dis1 * Dis1 + Dis2 * Dis2); + } p2dch.SetCoord(0., v); ElSLib::ConeD1(0., v, ConAx3, ConRad, SemiAngl, Pt, deru, derv); gp_Lin2d lin2dch(p2dch, gp::DX2d()); @@ -286,13 +300,21 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, double tol = Precision::PConfusion(); bool careaboutsens = false; if (std::abs(lu - fu - 2 * M_PI) < tol) + { careaboutsens = true; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ChFiKPart_InPeriod(u, fu, fu + 2 * M_PI, tol); + } ElSLib::D1(u, v, Cyl, Pt, deru, derv); gp_Dir norcyl = deru.Crossed(derv); @@ -301,10 +323,14 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, { d2dCyl.Reverse(); if (careaboutsens && std::abs(fu - u) < tol) + { u = lu; + } } else if (careaboutsens && std::abs(lu - u) < tol) + { u = fu; + } gp_Pnt2d p2dCyl(u, v); gp_Lin2d lin2dCyl(p2dCyl, d2dCyl); occ::handle GLin2dCyl = new Geom2d_Line(lin2dCyl); @@ -366,7 +392,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, // |4 to determine the side of the material if (theMode != ChFiDS_ClassicChamfer) + { return false; + } gp_Pnt OrSpine = ElCLib::Value(First, Spine); gp_Pnt POnCyl, POnPln, OrCyl; @@ -475,7 +503,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, bool PosChamfPln = DirPlnCyl.Dot(DirSPln) > 0; if (PosChamfPln) + { toreverse = !toreverse; + } // It is checked if the orientation of the Chamfer is the same as of the plane if (toreverse) { @@ -537,7 +567,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, bool PosChamfCyl = DirPlnCyl.Dot(DirSCyl) < 0; if (PosChamfCyl) + { toreverse = !toreverse; + } trans = TopAbs_REVERSED; if ((!plandab && toreverse) || (plandab && !toreverse)) @@ -546,14 +578,18 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, } if (plandab) + { Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } else + { Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } return true; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnPln.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnPln.cxx index bcc09d57af..e356a85c9d 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnPln.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_ChPlnPln.cxx @@ -98,17 +98,23 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, gp_Dir LinAx1 = Spine.Direction(); gp_Dir VecTransl1 = LinAx1.Crossed(D1); if (VecTransl1.Dot(D2) <= 0.) + { VecTransl1.Reverse(); + } gp_Dir VecTransl2 = LinAx1.Crossed(D2); if (VecTransl2.Dot(D1) <= 0.) + { VecTransl2.Reverse(); + } double Dis1 = theDis1, Dis2 = theDis2; double Alpha = VecTransl1.Angle(VecTransl2); double CosHalfAlpha = std::cos(Alpha / 2); if (theMode == ChFiDS_ConstThroatChamfer) + { Dis1 = Dis2 = theDis1 / CosHalfAlpha; + } else if (theMode == ChFiDS_ConstThroatWithPenetrationChamfer) { double aDis1 = std::min(theDis1, theDis2); @@ -150,7 +156,9 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, gp_Dir xdir = LinAx1; // u axis gp_Ax3 PlanAx3(Po, AxisPlan, xdir); if (PlanAx3.YDirection().Dot(D2) >= 0.) + { PlanAx3.YReverse(); + } occ::handle gpl = new Geom_Plane(PlanAx3); Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gpl, DStr)); @@ -170,12 +178,18 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, gp_Dir DirCh12(gp_Vec(P1, P2)); bool toreverse = (norplch.Dot(norface1) <= 0.); if (VecTransl1.Dot(DirCh12) > 0) + { toreverse = !toreverse; + } if (toreverse) + { Data->ChangeOrientation() = TopAbs_REVERSED; + } else + { Data->ChangeOrientation() = TopAbs_FORWARD; + } // Loading of the FaceInterferences with pcurves & 3d curves. @@ -199,11 +213,17 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, TopAbs_Orientation trans; toreverse = (norplch.Dot(norpl) <= 0.); if (VecTransl1.Dot(DirCh12) > 0) + { toreverse = !toreverse; + } if (toreverse) + { trans = TopAbs_FORWARD; + } else + { trans = TopAbs_REVERSED; + } Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(GLinPln1, DStr), trans, @@ -231,11 +251,17 @@ bool ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr, norpl = Pos2.XDirection().Crossed(Pos2.YDirection()); toreverse = (norplch.Dot(norpl) <= 0.); if (VecTransl2.Dot(DirCh12) < 0) + { toreverse = !toreverse; + } if (toreverse) + { trans = TopAbs_REVERSED; + } else + { trans = TopAbs_FORWARD; + } Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(GLinPln2, DStr), trans, diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Fcts.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Fcts.cxx index d5ab8c5143..e6bfbd1ffe 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Fcts.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Fcts.cxx @@ -37,11 +37,17 @@ double ChFiKPart_InPeriod(const double U, const double UFirst, const double ULas { double u = U, period = ULast - UFirst; while (Eps < (UFirst - u)) + { u += period; + } while (Eps > (ULast - u)) + { u -= period; + } if (u < UFirst) + { u = UFirst; + } return u; } diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCon.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCon.cxx index 307a956096..ad601f21df 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCon.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCon.cxx @@ -119,7 +119,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::D1(u, v, Con, pp, dcu, dcv); gp_Dir ddc(dcv); if (ddc.Dot(Dp) < 0.) + { ddc.Reverse(); + } double Ang = ddp.Angle(ddc); double Rabio = Radius / std::tan(Ang / 2); double Maxrad = cPln.Distance(Pv); @@ -184,7 +186,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::TorusParameters(FilAx3, Rad, Radius, P, u, v); ElSLib::TorusD1(u, v, FilAx3, Rad, Radius, PP, deru, derv); if (!plandab && Ang < M_PI / 2 && dedans) + { v = v + 2 * M_PI; + } } gp_Pnt2d p2dFil(0., v); gp_Dir norFil(deru.Crossed(derv)); @@ -260,7 +264,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::TorusParameters(FilAx3, Rad, Radius, P, u, v); ElSLib::TorusD1(u, v, FilAx3, Rad, Radius, PP, deru, derv); if (plandab && Ang < M_PI / 2 && dedans) + { v = v + 2 * M_PI; + } } norFil = deru.Crossed(derv); p2dFil.SetCoord(0., v); @@ -270,13 +276,21 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, double tol = Precision::PConfusion(); bool careaboutsens = false; if (std::abs(lu - fu - 2 * M_PI) < tol) + { careaboutsens = true; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ElCLib::InPeriod(u, fu, fu + 2 * M_PI); + } ElSLib::D1(u, v, Con, PP, deru, derv); gp_Dir norCon = deru.Crossed(derv); gp_Dir2d d2dCon = gp::DX2d(); @@ -284,10 +298,14 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, { d2dCon.Reverse(); if (careaboutsens && std::abs(fu - u) < tol) + { u = lu; + } } else if (careaboutsens && std::abs(lu - u) < tol) + { u = fu; + } gp_Pnt2d p2dCon(u, v); gp_Lin2d lin2dCon(p2dCon, d2dCon); occ::handle GLin2dCon = new Geom2d_Line(lin2dCon); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCyl.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCyl.cxx index 4e41248723..71f913fe80 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCyl.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_FilPlnCyl.cxx @@ -81,7 +81,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, double ROff = Cyl.Radius(); if ((Or2 == TopAbs_FORWARD && Cyl.Direct()) || (Or2 == TopAbs_REVERSED && !Cyl.Direct())) + { ROff += Radius; + } else if (Radius < ROff) { ROff -= Radius; @@ -135,7 +137,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::Parameters(Cyl, OrFillet, UOnCyl, VOnCyl); constexpr double tesp = Precision::Confusion(); if (UOnCyl < fu - tesp || UOnCyl > lu + tesp) + { UOnCyl = ElCLib::InPeriod(UOnCyl, fu, fu + 2 * M_PI); + } ElSLib::Parameters(Pln, OrFillet, UOnPln, VOnPln); gp_Vec XDir, OtherDir; @@ -155,7 +159,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, gp_Ax3 AxFil(OrFillet, DirFillet, XDir); gp_Vec aProd = XDir.Crossed(OtherDir); if (aProd.Dot(DirFillet) < 0.) + { AxFil.YReverse(); + } occ::handle Fillet = new Geom_CylindricalSurface(AxFil, Radius); Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(Fillet, DStr)); @@ -172,7 +178,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::CylinderParameters(AxFil, Radius, POnPln, UOnFillet, V); if (UOnFillet > M_PI) + { UOnFillet = 0.; + } gp_Lin2d LOnFillet(gp_Pnt2d(UOnFillet, V), gp::DY2d()); occ::handle L3d = new Geom_Line(C3d); occ::handle LFac = new Geom2d_Line(Lin2dPln); @@ -202,27 +210,35 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, trans = TopAbs_FORWARD; } if (plandab) + { Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } else + { Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } // edge cylinder-Fillet. gp_Pnt2d PCyl2d(UOnCyl, VOnCyl); gp_Dir2d DPC = gp::DY2d(); if (DirFillet.Dot(AxCyl.Direction()) < 0.) + { DPC.Reverse(); + } gp_Lin2d Lin2dCyl(PCyl2d, DPC); gp_Pnt POnCyl = ElSLib::Value(UOnCyl, VOnCyl, Cyl); C3d = gp_Lin(POnCyl, DirFillet); ElSLib::CylinderParameters(AxFil, Radius, POnCyl, UOnFillet, V); if (UOnFillet > M_PI) + { UOnFillet = 0.; + } LOnFillet = gp_Lin2d(gp_Pnt2d(UOnFillet, V), gp::DY2d()); L3d = new Geom_Line(C3d); LFac = new Geom2d_Line(Lin2dCyl); @@ -243,15 +259,19 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, trans = TopAbs_REVERSED; } if (plandab) + { Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } else + { Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(L3d, DStr), trans, LFac, LFil); + } return true; } @@ -404,7 +424,9 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, ElSLib::SphereD1(u, v, FilAx3, cylrad, PP, deru, derv); norFil = FilAx3.XDirection().Crossed(FilAx3.YDirection()); if (v < 0.) + { norFil.Reverse(); + } } else { @@ -514,13 +536,21 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, double tol = Precision::PConfusion(); bool careaboutsens = false; if (std::abs(lu - fu - 2 * M_PI) < tol) + { careaboutsens = true; + } if (u >= fu - tol && u < fu) + { u = fu; + } if (u <= lu + tol && u > lu) + { u = lu; + } if (u < fu || u > lu) + { u = ChFiKPart_InPeriod(u, fu, fu + 2 * M_PI, tol); + } ElSLib::D1(u, v, Cyl, PP, deru, derv); gp_Dir norcyl = deru.Crossed(derv); gp_Dir2d d2dCyl = gp::DX2d(); @@ -528,10 +558,14 @@ bool ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr, { d2dCyl.Reverse(); if (careaboutsens && std::abs(fu - u) < tol) + { u = lu; + } } else if (careaboutsens && std::abs(lu - u) < tol) + { u = fu; + } gp_Pnt2d p2dCyl(u, v); gp_Lin2d lin2dCyl(p2dCyl, d2dCyl); occ::handle GLin2dCyl = new Geom2d_Line(lin2dCyl); diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Rotule.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Rotule.cxx index 6462465fc3..da039cd498 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Rotule.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Rotule.cxx @@ -96,7 +96,9 @@ bool ChFiKPart_MakeRotule(TopOpeBRepDS_DataStructure& DStr, gp_Ax3 ppos(ptor, dpl.Reversed(), dpl1); if (ppos.YDirection().Dot(dpl2) < 0.) + { ppos.YReverse(); + } occ::handle gtor = new Geom_ToroidalSurface(ppos, r, r); Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gtor, DStr)); @@ -137,7 +139,9 @@ bool ChFiKPart_MakeRotule(TopOpeBRepDS_DataStructure& DStr, occ::handle GL2d = new Geom2d_Line(p2dlin, gp::DX2d()); TopAbs_Orientation trans = TopAbs_REVERSED; if (reversecur) + { trans = TopAbs_FORWARD; + } Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(GC, DStr), trans, GC2d, diff --git a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Sphere.cxx b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Sphere.cxx index 7bce00b174..eb61c10bdf 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Sphere.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiKPart/ChFiKPart_ComputeData_Sphere.cxx @@ -70,9 +70,13 @@ bool ChFiKPart_Sphere(TopOpeBRepDS_DataStructure& DStr, gp_Dir df1 = ds1; gp_Dir dnat1 = ds1; if (Or1 == TopAbs_REVERSED) + { ds1.Reverse(); + } if (OrFace1 == TopAbs_REVERSED) + { df1.Reverse(); + } S2->D0(P1S2.X(), P1S2.Y(), p2); S2->D0(P2S2.X(), P2S2.Y(), p3); gp_Circ ci = gce_MakeCirc(p1, p2, p3); @@ -140,7 +144,9 @@ bool ChFiKPart_Sphere(TopOpeBRepDS_DataStructure& DStr, toreverse = (ddz.Dot(dnat1) <= 0.); TopAbs_Orientation trans = TopAbs_REVERSED; if (toreverse) + { trans = TopAbs_FORWARD; + } Data->ChangeInterferenceOnS1().SetInterference(ChFiKPart_IndexCurveInDS(C, DStr), trans, C2d, @@ -171,14 +177,18 @@ bool ChFiKPart_Sphere(TopOpeBRepDS_DataStructure& DStr, C2d = new Geom2d_Line(l2d); } else + { C2d = ChFiKPart_PCurve(P1S2, P2S2, 0., ang); + } gp_Pnt pp1; S2->D1(P1S2.X(), P1S2.Y(), pp1, v1, v2); gp_Dir ds2(v1.Crossed(v2)); toreverse = (ds2.Dot(dddx) <= 0.); trans = TopAbs_REVERSED; if (!toreverse) + { trans = TopAbs_FORWARD; + } Data->ChangeInterferenceOnS2().SetInterference(ChFiKPart_IndexCurveInDS(C, DStr), trans, C2d, diff --git a/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_Builder.cxx b/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_Builder.cxx index b5de4c5294..cebecc7e22 100644 --- a/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_Builder.cxx +++ b/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_Builder.cxx @@ -44,15 +44,25 @@ FilletSurf_Builder::FilletSurf_Builder(const TopoDS_Shape& S, { myisdone = FilletSurf_IsNotOk; if (add == 1) + { myerrorstatus = FilletSurf_EmptyList; + } else if (add == 2) + { myerrorstatus = FilletSurf_EdgeNotG1; + } else if (add == 3) + { myerrorstatus = FilletSurf_FacesNotG1; + } else if (add == 4) + { myerrorstatus = FilletSurf_EdgeNotOnShape; + } else if (add == 5) + { myerrorstatus = FilletSurf_NotSharpEdge; + } } } @@ -66,7 +76,9 @@ void FilletSurf_Builder::Perform() { myIntBuild.Perform(); if (myIntBuild.Done()) + { myisdone = FilletSurf_IsOk; + } else if (myIntBuild.NbSurface() != 0) { myisdone = FilletSurf_IsPartial; @@ -106,7 +118,9 @@ FilletSurf_ErrorTypeStatus FilletSurf_Builder::StatusError() const int FilletSurf_Builder::NbSurface() const { if (IsDone() != FilletSurf_IsNotOk) + { return myIntBuild.NbSurface(); + } throw StdFail_NotDone("FilletSurf_Builder::NbSurface"); } @@ -118,7 +132,9 @@ int FilletSurf_Builder::NbSurface() const const occ::handle& FilletSurf_Builder::SurfaceFillet(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::SurfaceFillet"); + } return myIntBuild.SurfaceFillet(Index); } @@ -129,7 +145,9 @@ const occ::handle& FilletSurf_Builder::SurfaceFillet(const int Ind double FilletSurf_Builder::TolApp3d(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::TolApp3d"); + } return myIntBuild.TolApp3d(Index); } @@ -140,7 +158,9 @@ double FilletSurf_Builder::TolApp3d(const int Index) const const TopoDS_Face& FilletSurf_Builder::SupportFace1(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::SupportFace1"); + } return myIntBuild.SupportFace1(Index); } @@ -151,7 +171,9 @@ const TopoDS_Face& FilletSurf_Builder::SupportFace1(const int Index) const const TopoDS_Face& FilletSurf_Builder::SupportFace2(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::SupportFace2"); + } return myIntBuild.SupportFace2(Index); } @@ -162,7 +184,9 @@ const TopoDS_Face& FilletSurf_Builder::SupportFace2(const int Index) const const occ::handle& FilletSurf_Builder::CurveOnFace1(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::CurveOnFace1"); + } return myIntBuild.CurveOnFace1(Index); } @@ -173,7 +197,9 @@ const occ::handle& FilletSurf_Builder::CurveOnFace1(const int Index) const occ::handle& FilletSurf_Builder::CurveOnFace2(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::CurveOnFace2"); + } return myIntBuild.CurveOnFace2(Index); } @@ -184,7 +210,9 @@ const occ::handle& FilletSurf_Builder::CurveOnFace2(const int Index) const occ::handle& FilletSurf_Builder::PCurveOnFace1(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::PCurveOnFace1"); + } return myIntBuild.PCurveOnFace1(Index); } @@ -195,7 +223,9 @@ const occ::handle& FilletSurf_Builder::PCurveOnFace1(const int Ind const occ::handle& FilletSurf_Builder::PCurve1OnFillet(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::PCurve1OnFillet"); + } return myIntBuild.PCurve1OnFillet(Index); } @@ -206,7 +236,9 @@ const occ::handle& FilletSurf_Builder::PCurve1OnFillet(const int I const occ::handle& FilletSurf_Builder::PCurveOnFace2(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::PCurveOnFace2"); + } return myIntBuild.PCurveOnFace2(Index); } @@ -217,7 +249,9 @@ const occ::handle& FilletSurf_Builder::PCurveOnFace2(const int Ind const occ::handle& FilletSurf_Builder::PCurve2OnFillet(const int Index) const { if ((Index < 1) || (Index > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::PCurve2OnFillet"); + } return myIntBuild.PCurve2OnFillet(Index); } @@ -228,7 +262,9 @@ const occ::handle& FilletSurf_Builder::PCurve2OnFillet(const int I double FilletSurf_Builder::FirstParameter() const { if (IsDone() == FilletSurf_IsNotOk) + { throw StdFail_NotDone("FilletSurf_Builder::FirstParameter"); + } return myIntBuild.FirstParameter(); } @@ -239,7 +275,9 @@ double FilletSurf_Builder::FirstParameter() const double FilletSurf_Builder::LastParameter() const { if (IsDone() == FilletSurf_IsNotOk) + { throw StdFail_NotDone("FilletSurf_Builder::LastParameter"); + } return myIntBuild.LastParameter(); } @@ -256,7 +294,9 @@ double FilletSurf_Builder::LastParameter() const FilletSurf_StatusType FilletSurf_Builder::StartSectionStatus() const { if (IsDone() == FilletSurf_IsNotOk) + { throw StdFail_NotDone("FilletSurf_Builder::StartSectionStatus"); + } return myIntBuild.StartSectionStatus(); } @@ -273,7 +313,9 @@ FilletSurf_StatusType FilletSurf_Builder::StartSectionStatus() const FilletSurf_StatusType FilletSurf_Builder::EndSectionStatus() const { if (IsDone() == FilletSurf_IsNotOk) + { throw StdFail_NotDone("FilletSurf_Builder::StartSectionStatus"); + } return myIntBuild.EndSectionStatus(); } @@ -288,7 +330,9 @@ void FilletSurf_Builder::Simulate() myIntBuild.Simulate(); if (myIntBuild.Done()) + { myisdone = FilletSurf_IsOk; + } else { myisdone = FilletSurf_IsNotOk; @@ -304,9 +348,13 @@ void FilletSurf_Builder::Simulate() int FilletSurf_Builder::NbSection(const int IndexSurf) const { if (IsDone() == FilletSurf_IsNotOk) + { throw StdFail_NotDone("FilletSurf_Builder::NbSection)"); + } else if ((IndexSurf < 1) || (IndexSurf > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::NbSection"); + } return myIntBuild.NbSection(IndexSurf); } @@ -320,10 +368,13 @@ occ::handle FilletSurf_Builder::Section(const int IndexSurf, const int IndexSec) const { if ((IndexSurf < 1) || (IndexSurf > NbSurface())) + { throw Standard_OutOfRange("FilletSurf_Builder::Section NbSurface"); - + } else if ((IndexSec < 1) || (IndexSec > NbSection(IndexSurf))) + { throw Standard_OutOfRange("FilletSurf_Builder::Section NbSection"); + } return myIntBuild.Section(IndexSurf, IndexSec); } diff --git a/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_InternalBuilder.cxx b/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_InternalBuilder.cxx index 830de6ab3e..61181f19a1 100644 --- a/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_InternalBuilder.cxx +++ b/src/ModelingAlgorithms/TKFillet/FilletSurf/FilletSurf_InternalBuilder.cxx @@ -62,7 +62,9 @@ static bool isinlist(const TopoDS_Shape& E, const NCollection_List for (It.Initialize(L); It.More(); It.Next()) { if (E.IsSame(It.Value())) + { return true; + } } return false; } @@ -178,15 +180,21 @@ FilletSurf_InternalBuilder::FilletSurf_InternalBuilder(const TopoDS_Shape& int FilletSurf_InternalBuilder::Add(const NCollection_List& E, const double R) { if (E.IsEmpty()) + { return 1; + } NCollection_List::Iterator It; for (It.Initialize(E); It.More(); It.Next()) { TopoDS_Edge cured = TopoDS::Edge(It.Value()); if (cured.IsNull()) + { return 4; + } if (!myEFMap.Contains(cured)) + { return 4; + } // check if the edge is a fracture edge TopoDS_Face ff1, ff2; for (It.Initialize(myEFMap(cured)); It.More(); It.Next()) @@ -205,11 +213,17 @@ int FilletSurf_InternalBuilder::Add(const NCollection_List& E, con } } if (ff1.IsNull() || ff2.IsNull()) + { return 5; + } if (ff1.IsSame(ff2)) + { return 5; + } if (BRep_Tool::Continuity(cured, ff1, ff2) != GeomAbs_C0) + { return 5; + } } TopoDS_Edge ed = TopoDS::Edge(E.First()); ed.Orientation(TopAbs_FORWARD); @@ -226,7 +240,9 @@ int FilletSurf_InternalBuilder::Add(const NCollection_List& E, con { TopoDS_Edge cured = TopoDS::Edge(It.Value()); if (!Contains(cured)) + { return 2; + } } occ::handle newsp = new ChFiDS_FilSpine(); @@ -247,10 +263,14 @@ int FilletSurf_InternalBuilder::Add(const NCollection_List& E, con newsp->SetEdges(cured); } else if (debut && !premierquinyestpas) + { premierquinyestpas = i; + } } if (!periodic && yatrou) + { return 2; + } if (periodic && yatrou) { bool vraitrou = false, aLocalDebut = false; @@ -260,11 +280,15 @@ int FilletSurf_InternalBuilder::Add(const NCollection_List& E, con if (isinlist(cured, E)) { if (vraitrou) + { return 2; + } newsp->PutInFirst(cured); } else if (aLocalDebut) + { vraitrou = true; + } aLocalDebut = true; } } @@ -340,11 +364,15 @@ bool FilletSurf_InternalBuilder::PerformSurf( occ::handle Data = SeqData(1); occ::handle fsp = occ::down_cast(Spine); if (fsp.IsNull()) + { throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); + } occ::handle lin; TopAbs_Orientation Or = S1->Face().Orientation(); if (!fsp->IsConstant()) + { throw Standard_ConstructionError("PerformSurf : no variable radiuses"); + } // bool maybesingular; //pour scinder les Surfdata singulieres occ::handle EmptyGuide; @@ -389,7 +417,9 @@ bool FilletSurf_InternalBuilder::PerformSurf( RecOnS1, RecOnS2); if (!done) + { return false; + } if (lin->StartPointOnFirst().NbPointOnRst() != 0) { ChFi3d_FilCommonPoint(lin->StartPointOnFirst(), @@ -424,7 +454,9 @@ bool FilletSurf_InternalBuilder::PerformSurf( } done = CompleteData(Data, Func, lin, S1, S2, Or, false, false, false, false); if (!done) + { throw Standard_Failure("PerformSurf : Failed approximation!"); + } // maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d); bool ok = false; if (!Forward) @@ -697,10 +729,14 @@ double FilletSurf_InternalBuilder::FirstParameter() const double p = sd->FirstSpineParam(); int ind = 1; if (sp->IsPeriodic()) + { ind = sp->Index(p); + } double ep; if (ComputeEdgeParameter(sp, ind, p, ep, tolapp3d)) + { return ep; + } return 0.0; } @@ -716,10 +752,14 @@ double FilletSurf_InternalBuilder::LastParameter() const double p = sd->LastSpineParam(); int ind = sp->NbEdges(); if (sp->IsPeriodic()) + { ind = sp->Index(p); + } double ep; if (ComputeEdgeParameter(sp, ind, p, ep, tolapp3d)) + { return ep; + } return 0.0; } diff --git a/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeChamfer_Test.cxx b/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeChamfer_Test.cxx index 80235b9008..520036d284 100644 --- a/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeChamfer_Test.cxx +++ b/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeChamfer_Test.cxx @@ -138,7 +138,9 @@ TEST(BRepFilletAPI_MakeChamferTest, ChamferAfterBooleanFusion) { const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); if (!anEdgeFaceMap.Contains(anEdge) || anEdgeFaceMap.FindFromKey(anEdge).IsEmpty()) + { continue; + } // Check if any vertex of this edge has 3+ faces. bool hasComplexVertex = false; @@ -152,7 +154,9 @@ TEST(BRepFilletAPI_MakeChamferTest, ChamferAfterBooleanFusion) } } if (!hasComplexVertex) + { continue; + } const TopoDS_Face& aFace = TopoDS::Face(anEdgeFaceMap.FindFromKey(anEdge).First()); aChamfer.Add(0.5, 0.5, anEdge, aFace); @@ -197,7 +201,9 @@ TEST(BRepFilletAPI_MakeChamferTest, SequentialChamferNoCrash) NCollection_IndexedMap anEdgeMap; TopExp::MapShapes(aShape, TopAbs_EDGE, anEdgeMap); if (anEdgeMap.IsEmpty()) + { break; + } // Verify topology actually changed after each successful chamfer. if (i > 0 && aPrevEdges > 0) diff --git a/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeFillet_Test.cxx b/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeFillet_Test.cxx index b3ed62ebcf..9a32fb53c3 100644 --- a/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeFillet_Test.cxx +++ b/src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeFillet_Test.cxx @@ -360,9 +360,13 @@ TopoDS_Shape occ1077BoolBl(BRepAlgoAPI_BooleanOperation& theBoolOp, double theRa aFill.Build(); if (aFill.IsDone()) + { aBuilder.Add(aResult, aFill.Shape()); + } else + { aBuilder.Add(aResult, aSolid); + } } return aResult; } @@ -502,7 +506,9 @@ TEST(BRepFilletAPI_MakeFilletTest, OCC426_RevolveFuseUnifyFillet) { const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeMap.FindKey(i)); if (!anEdge.IsNull()) + { aBlend.Add(1.0, anEdge); + } } try diff --git a/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_KnotTools.cxx b/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_KnotTools.cxx index d14643e818..82b648b3db 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_KnotTools.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/ApproxInt/ApproxInt_KnotTools.cxx @@ -367,7 +367,9 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence& theInds, for (; anIdx <= theInds.Length(); ++anIdx) { if (theInds(anIdx) - anIndsPrev >= theMinNbPnts) + { break; + } } anIdx--; @@ -566,11 +568,17 @@ void ApproxInt_KnotTools::BuildKnots(const NCollection_Array1& thePnts // I: Convert input data to the corresponding format. if (theApproxXYZ) + { aDim += 3; + } if (theApproxU1V1) + { aDim += 2; + } if (theApproxU2V2) + { aDim += 2; + } if (aDim == 0 || thePars.Length() < 2) { @@ -642,10 +650,14 @@ static double MaxParamRatio(const math_Vector& thePars) { double aDenom = thePars(i) - thePars(i - 1); if (std::abs(aDenom) < Precision::Computational()) + { continue; + } double aRat = (thePars(i + 1) - thePars(i)) / aDenom; if (aRat > 0. && aRat < 1.) + { aRat = 1. / aRat; + } aMaxRatio = std::max(aMaxRatio, aRat); } @@ -663,7 +675,9 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType( const bool theApproxU2V2) { if (theLpar - theFpar == 1) + { return Approx_IsoParametric; + } const int nbp3d = theApproxXYZ ? 1 : 0, nbp2d = (theApproxU1V1 ? 1 : 0) + (theApproxU2V2 ? 1 : 0); @@ -694,11 +708,17 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType( for (i = theFpar; i <= theLpar; ++i) { if (nbp3d != 0 && nbp2d != 0) + { aTestLine.Value(i, aTabPnt3d, aTabPnt2d); + } else if (nbp2d != 0) + { aTestLine.Value(i, aTabPnt2d); + } else if (nbp3d != 0) + { aTestLine.Value(i, aTabPnt3d); + } // if (nbp3d > 0) { @@ -725,11 +745,17 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType( int aDim = 0; if (theApproxXYZ) + { aDim += 3; + } if (theApproxU1V1) + { aDim += 2; + } if (theApproxU2V2) + { aDim += 2; + } int aLength = theLpar - theFpar + 1; NCollection_LocalArray aCoords(aLength * aDim); @@ -796,19 +822,25 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType( } if (aMidCurv <= eps) + { return aParType; + } double aRat = aMaxCurv / aMidCurv; if (aRat > aCritRat) { if (aRat > 5. * aCritRat) + { aParType = Approx_Centripetal; + } else { double aParRat = MaxParamRatio(aPars); if (aParRat > aCritParRat) + { aParType = Approx_Centripetal; + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Batten.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Batten.cxx index 8922385c48..6abb140a37 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Batten.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Batten.cxx @@ -62,9 +62,13 @@ FairCurve_Batten::FairCurve_Batten(const gp_Pnt2d& P1, Degree(9) { if (P1.IsEqual(P2, Precision::Confusion())) + { throw Standard_NullValue("FairCurve : P1 and P2 are confused"); + } if (Height <= 0) + { throw Standard_NegativeValue("FairCurve : Height is not positive"); + } // // Initialize by a straight line (2 poles) // @@ -137,7 +141,9 @@ void FairCurve_Batten::SetP1(const gp_Pnt2d& P1) // ================================================================== { if (P1.IsEqual(NewP2, Precision::Confusion())) + { throw Standard_NullValue("FairCurve : P1 and P2 are confused"); + } Angles(P1, NewP2); NewP1 = P1; } @@ -147,7 +153,9 @@ void FairCurve_Batten::SetP2(const gp_Pnt2d& P2) // ================================================================== { if (NewP1.IsEqual(P2, Precision::Confusion())) + { throw Standard_NullValue("FairCurve : P1 and P2 are confused"); + } Angles(NewP1, P2); NewP2 = P2; } @@ -177,21 +185,27 @@ bool FairCurve_Batten::Compute(FairCurve_AnalysisCode& ACode, Fraction = std::abs(DAngle1) / (AngleMax * std::exp(-std::abs(OldAngle1) / AngleMax) + AngleMin); if (Fraction > 1) + { Ratio = 1 / Fraction; + } } if (NewConstraintOrder2 > 0) { Fraction = std::abs(DAngle2) / (AngleMax * std::exp(-std::abs(OldAngle2) / AngleMax) + AngleMin); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } } OldDist = OldP1.Distance(OldP2); NewDist = NewP1.Distance(NewP2); Fraction = std::abs(OldDist - NewDist) / (OldDist / 3); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } gp_Vec2d DeltaP1(OldP1, NewP1), DeltaP2(OldP2, NewP2); if (Ratio == 1) @@ -211,13 +225,21 @@ bool FairCurve_Batten::Compute(FairCurve_AnalysisCode& ACode, Ok = Compute(DeltaP1, DeltaP2, DAngle1, DAngle2, ACode, NbIterations, Toler); if (ACode != FairCurve_OK) + { End = true; + } if (NewFreeSliding) + { NewSlidingFactor = OldSlidingFactor; + } if (NewConstraintOrder1 == 0) + { NewAngle1 = OldAngle1; + } if (NewConstraintOrder2 == 0) + { NewAngle2 = OldAngle2; + } } myCode = ACode; return Ok; @@ -250,7 +272,9 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1, math_Matrix HermiteCoef(1, L, 1, L); Ok = PLib::HermiteCoefficients(0, 1, NewConstraintOrder1, NewConstraintOrder2, HermiteCoef); if (!Ok) + { return false; + } // Definition of constraints of interpolation NCollection_Array1 ADelta(1, L); @@ -264,7 +288,9 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1, gp_Vec2d OldDerive(Poles->Value(Poles->Lower()), Poles->Value(Poles->Lower() + 1)); double aKnotGap1 = Knots->Value(2) - Knots->Value(1); if (std::abs(aKnotGap1) > Precision::Computational()) + { OldDerive *= Degree / aKnotGap1; + } ADelta(kk) = (OldDerive.Rotated(DeltaAngle1 - DAngleRef) - OldDerive).XY(); kk += 1; } @@ -275,7 +301,9 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1, gp_Vec2d OldDerive(Poles->Value(Poles->Upper() - 1), Poles->Value(Poles->Upper())); double aKnotGap2 = Knots->Value(Knots->Upper()) - Knots->Value(Knots->Upper() - 1); if (std::abs(aKnotGap2) > Precision::Computational()) + { OldDerive *= Degree / aKnotGap2; + } ADelta(kk) = (OldDerive.Rotated(DAngleRef - DeltaAngle2) - OldDerive).XY(); } @@ -443,7 +471,9 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1, // Prevention of infinite sliding if (NewFreeSliding && VInit(VInit.Upper()) > 2 * LReference) + { ACode = FairCurve_InfiniteSliding; + } // Eventual insertion of Nodes bool NewKnots = false; @@ -506,17 +536,27 @@ double FairCurve_Batten::SlidingOfReference(const double Dist, // case of angle without constraints if ((NewConstraintOrder1 == 0) && (NewConstraintOrder2 == 0)) + { return Dist; + } if (NewConstraintOrder1 == 0) + { a1 = std::abs(std::abs(NewAngle2) < M_PI ? Angle2 / 2 : M_PI / 2); + } else + { a1 = std::abs(Angle1); + } if (NewConstraintOrder2 == 0) + { a2 = std::abs(std::abs(NewAngle1) < M_PI ? Angle1 / 2 : M_PI / 2); + } else + { a2 = std::abs(Angle2); + } // case of angle of the same sign if (Angle1 * Angle2 >= 0) @@ -529,11 +569,15 @@ double FairCurve_Batten::SlidingOfReference(const double Dist, { double aSum = a1 + a2; if (std::abs(aSum) < Precision::Angular()) + { return Compute(Dist, a1, M_PI / 2); + } double Ratio = a1 / aSum; double AngleMilieu = pow(1 - Ratio, 2) * a1 + pow(Ratio, 2) * a2; if (AngleMilieu > M_PI / 2) + { AngleMilieu = M_PI / 2; + } return Ratio * Compute(Dist, a1, AngleMilieu) + (1 - Ratio) * Compute(Dist, a2, AngleMilieu); } @@ -592,56 +636,56 @@ void FairCurve_Batten::Dump(Standard_OStream& o) const o << " Batten |"; o.width(7); - o << "Old | New" << std::endl; + o << "Old | New" << '\n'; o << " P1 X |"; o.width(7); - o << OldP1.X() << " | " << NewP1.X() << std::endl; + o << OldP1.X() << " | " << NewP1.X() << '\n'; o << " Y |"; o.width(7); - o << OldP1.Y() << " | " << NewP1.Y() << std::endl; + o << OldP1.Y() << " | " << NewP1.Y() << '\n'; o << " P2 X |"; o.width(7); - o << OldP2.X() << " | " << NewP2.X() << std::endl; + o << OldP2.X() << " | " << NewP2.X() << '\n'; o << " Y |"; o.width(7); - o << OldP2.Y() << " | " << NewP2.Y() << std::endl; + o << OldP2.Y() << " | " << NewP2.Y() << '\n'; o << " Angle1 |"; o.width(7); - o << OldAngle1 << " | " << NewAngle1 << std::endl; + o << OldAngle1 << " | " << NewAngle1 << '\n'; o << " Angle2 |"; o.width(7); - o << OldAngle2 << " | " << NewAngle2 << std::endl; + o << OldAngle2 << " | " << NewAngle2 << '\n'; o << " Height |"; o.width(7); - o << OldHeight << " | " << NewHeight << std::endl; + o << OldHeight << " | " << NewHeight << '\n'; o << " Slope |"; o.width(7); - o << OldSlope << " | " << NewSlope << std::endl; + o << OldSlope << " | " << NewSlope << '\n'; o << " SlidingFactor |"; o.width(7); - o << OldSlidingFactor << " | " << NewSlidingFactor << std::endl; + o << OldSlidingFactor << " | " << NewSlidingFactor << '\n'; o << " FreeSliding |"; o.width(7); - o << OldFreeSliding << " | " << NewFreeSliding << std::endl; + o << OldFreeSliding << " | " << NewFreeSliding << '\n'; o << " ConstrOrder1 |"; o.width(7); - o << OldConstraintOrder1 << " | " << NewConstraintOrder1 << std::endl; + o << OldConstraintOrder1 << " | " << NewConstraintOrder1 << '\n'; o << " ConstrOrder2 |"; o.width(7); - o << OldConstraintOrder2 << " | " << NewConstraintOrder2 << std::endl; + o << OldConstraintOrder2 << " | " << NewConstraintOrder2 << '\n'; switch (myCode) { case FairCurve_OK: - o << "AnalysisCode : Ok" << std::endl; + o << "AnalysisCode : Ok" << '\n'; break; case FairCurve_NotConverged: - o << "AnalysisCode : NotConverged" << std::endl; + o << "AnalysisCode : NotConverged" << '\n'; break; case FairCurve_InfiniteSliding: - o << "AnalysisCode : InfiniteSliding" << std::endl; + o << "AnalysisCode : InfiniteSliding" << '\n'; break; case FairCurve_NullHeight: - o << "AnalysisCode : NullHeight" << std::endl; + o << "AnalysisCode : NullHeight" << '\n'; break; } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfEnergy.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfEnergy.cxx index 570842cd49..e711fdc6a1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfEnergy.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfEnergy.cxx @@ -46,8 +46,12 @@ void FairCurve_DistributionOfEnergy::SetDerivativeOrder(const int DerivativeOrde { MyNbEqua = 1; if (DerivativeOrder >= 1) + { MyNbEqua += 2 * MyPoles->Length() + MyNbValAux; + } if (DerivativeOrder >= 2) + { MyNbEqua = MyNbEqua + (MyNbEqua - 1) * MyNbEqua / 2; + } MyDerivativeOrder = DerivativeOrder; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfJerk.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfJerk.cxx index 7a70c92362..b28ed85210 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfJerk.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfJerk.cxx @@ -63,7 +63,9 @@ bool FairCurve_DistributionOfJerk::Value(const math_Vector& TParam, math_Vector& FirstNonZero, Base); if (ier != 0) + { return false; + } LastZero = FirstNonZero - 1; FirstNonZero = 2 * LastZero + 1; @@ -89,7 +91,9 @@ bool FairCurve_DistributionOfJerk::Value(const math_Vector& TParam, math_Vector& Ok = MyLaw.Value(TParam(TParam.Lower()), Hauteur); if (!Ok) + { return Ok; + } Mesure = pow(Hauteur, 3) / 12; WVal = Numerateur / Denominateur; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfSagging.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfSagging.cxx index 846739f193..e56621f598 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfSagging.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfSagging.cxx @@ -60,7 +60,9 @@ bool FairCurve_DistributionOfSagging::Value(const math_Vector& TParam, math_Vect FirstNonZero, Base); if (ier != 0) + { return false; + } LastZero = FirstNonZero - 1; FirstNonZero = 2 * LastZero + 1; @@ -80,7 +82,9 @@ bool FairCurve_DistributionOfSagging::Value(const math_Vector& TParam, math_Vect Ok = MyLaw.Value(TParam(TParam.Lower()), Hauteur); if (!Ok) + { return Ok; + } Mesure = pow(Hauteur, 3) / 12; WVal = Numerateur / Denominateur; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfTension.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfTension.cxx index 854924c53f..e8c64f61f5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfTension.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_DistributionOfTension.cxx @@ -71,7 +71,9 @@ bool FairCurve_DistributionOfTension::Value(const math_Vector& TParam, math_Vect FirstNonZero, Base); if (ier != 0) + { return false; + } LastZero = FirstNonZero - 1; FirstNonZero = 2 * LastZero + 1; @@ -93,7 +95,9 @@ bool FairCurve_DistributionOfTension::Value(const math_Vector& TParam, math_Vect { Ok = MyLaw.Value(TParam(TParam.Lower()), Hauteur); if (!Ok) + { return Ok; + } } Difference = NormeCPrim - MyLengthSliding; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Energy.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Energy.cxx index 0f922561a1..01a40720cd 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Energy.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_Energy.cxx @@ -392,8 +392,12 @@ void FairCurve_Energy::Hessian1(const math_Vector& Vect, math_Matrix& H) } // symmetry for (ii = H.LowerRow(); ii <= H.UpperRow(); ii++) + { for (jj = ii + 1; jj <= H.UpperRow(); jj++) + { H(ii, jj) = H(jj, ii); + } + } } //======================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfBatten.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfBatten.cxx index 5e08851dd4..ec90e439aa 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfBatten.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfBatten.cxx @@ -117,7 +117,9 @@ bool FairCurve_EnergyOfBatten::Compute(const int DerivativeOrder, math_Vector& R math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder); Ok = SumTension.IsDone(); if (!Ok) + { return Ok; + } math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder); Ok = SumSagging.IsDone(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfMVC.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfMVC.cxx index fe80754c2a..220d7d2bf3 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfMVC.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_EnergyOfMVC.cxx @@ -134,12 +134,16 @@ bool FairCurve_EnergyOfMVC::Compute(const int DerivativeOrder, math_Vector& Resu math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder); Ok = SumTension.IsDone(); if (!Ok) + { return Ok; + } math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder); Ok = SumJerk.IsDone(); if (!Ok) + { return Ok; + } Result += SumJerk.Value() + SumTension.Value(); // Cas purement non physique } @@ -155,17 +159,23 @@ bool FairCurve_EnergyOfMVC::Compute(const int DerivativeOrder, math_Vector& Resu math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder); Ok = SumTension.IsDone(); if (!Ok) + { return Ok; + } math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder); Ok = SumSagging.IsDone(); if (!Ok) + { return Ok; + } math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder); Ok = SumJerk.IsDone(); if (!Ok) + { return Ok; + } Result += SumJerk.Value() * (1 - MyPhysicalRatio) + SumSagging.Value() * MyPhysicalRatio + SumTension.Value(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_MinimalVariation.cxx b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_MinimalVariation.cxx index e66ab933a3..ac500051af 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_MinimalVariation.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/FairCurve/FairCurve_MinimalVariation.cxx @@ -82,34 +82,44 @@ bool FairCurve_MinimalVariation::Compute(FairCurve_AnalysisCode& ACode, Fraction = std::abs(DAngle1) / (AngleMax * std::exp(-std::abs(OldAngle1) / AngleMax) + AngleMin); if (Fraction > 1) + { Ratio = 1 / Fraction; + } } if (NewConstraintOrder2 > 0) { Fraction = std::abs(DAngle2) / (AngleMax * std::exp(-std::abs(OldAngle2) / AngleMax) + AngleMin); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } } OldDist = OldP1.Distance(OldP2); NewDist = NewP1.Distance(NewP2); Fraction = std::abs(OldDist - NewDist) / (OldDist / 3); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } if (NewConstraintOrder1 > 1) { Fraction = std::abs(DRho1) * OldDist / (2 + std::abs(OldAngle1) + std::abs(OldAngle2)); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } } if (NewConstraintOrder2 > 1) { Fraction = std::abs(DRho2) * OldDist / (2 + std::abs(OldAngle1) + std::abs(OldAngle2)); if (Fraction > 1) + { Ratio = (Ratio < 1 / Fraction ? Ratio : 1 / Fraction); + } } gp_Vec2d DeltaP1(OldP1, NewP1), DeltaP2(OldP2, NewP2); @@ -132,17 +142,29 @@ bool FairCurve_MinimalVariation::Compute(FairCurve_AnalysisCode& ACode, Ok = Compute(DeltaP1, DeltaP2, DAngle1, DAngle2, DRho1, DRho2, ACode, NbIterations, Toler); if (ACode != FairCurve_OK) + { End = true; + } if (NewFreeSliding) + { NewSlidingFactor = OldSlidingFactor; + } if (NewConstraintOrder1 == 0) + { NewAngle1 = OldAngle1; + } if (NewConstraintOrder1 < 2) + { NewCurvature1 = OldCurvature1; + } if (NewConstraintOrder2 == 0) + { NewAngle2 = OldAngle2; + } if (NewConstraintOrder2 < 2) + { NewCurvature2 = OldCurvature2; + } } myCode = ACode; return Ok; @@ -186,7 +208,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, math_Matrix HermiteCoef(1, L, 1, L); Ok = PLib::HermiteCoefficients(0, 1, NewConstraintOrder1, NewConstraintOrder2, HermiteCoef); if (!Ok) + { return false; + } // Definition of constraints of interpolation NCollection_Array1 ADelta(1, L); @@ -205,7 +229,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, gp_Vec2d OldDerive(Poles->Value(Poles->Lower()), Poles->Value(Poles->Lower() + 1)); double aKnotGapL = Knots->Value(Knots->Lower() + 1) - Knots->Value(Knots->Lower()); if (std::abs(aKnotGapL) > Precision::Computational()) + { OldDerive *= Degree / aKnotGapL; + } ADelta(kk) = (OldDerive.Rotated(DAngle1) - OldDerive).XY(); kk += 1; @@ -216,7 +242,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, - 2 * Poles->Value(Poles->Lower() + 1).XY()); double aKnotGapLSq = aKnotGapL * aKnotGapL; if (std::abs(aKnotGapLSq) > Precision::SquareComputational()) + { OldSeconde *= Degree * (Degree - 1) / aKnotGapLSq; + } double CPrim = OldDerive.Magnitude(); ADelta(kk) = (OldSeconde.Rotated(DAngle1) - OldSeconde + DeltaCurvature1 * CPrim * OldDerive.Rotated(M_PI / 2 + DAngle1)) @@ -231,7 +259,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, gp_Vec2d OldDerive(Poles->Value(Poles->Upper() - 1), Poles->Value(Poles->Upper())); double aKnotGapU = Knots->Value(Knots->Upper()) - Knots->Value(Knots->Upper() - 1); if (std::abs(aKnotGapU) > Precision::Computational()) + { OldDerive *= Degree / aKnotGapU; + } ADelta(kk) = (OldDerive.Rotated(DAngle2) - OldDerive).XY(); kk += 1; if (NewConstraintOrder2 > 1) @@ -241,7 +271,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, - 2 * Poles->Value(Poles->Upper() - 1).XY()); double aKnotGapUSq = aKnotGapU * aKnotGapU; if (std::abs(aKnotGapUSq) > Precision::SquareComputational()) + { OldSeconde *= Degree * (Degree - 1) / aKnotGapUSq; + } double CPrim = OldDerive.Magnitude(); ADelta(kk) = (OldSeconde.Rotated(DAngle2) - OldSeconde + DeltaCurvature2 * CPrim * OldDerive.Rotated(M_PI / 2 + DAngle2)) @@ -394,7 +426,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, { Tangente.SetXY(Poles->Value(Poles->Upper()).XY() - Poles->Value(Poles->Upper() - 1).XY()); if (NewConstraintOrder2 == 0) + { OldAngle2 = (-Tangente).Angle(-P1P2); + } else { OldAngle2 = Alph2; @@ -445,7 +479,9 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1, // Prevention of infinite sliding if (NewFreeSliding && VInit(VInit.Upper()) > 2 * LReference) + { ACode = FairCurve_InfiniteSliding; + } // Eventual insertion of Nodes bool NewKnots = false; @@ -498,65 +534,65 @@ void FairCurve_MinimalVariation::Dump(Standard_OStream& o) const o << " MVCurve |"; o.width(7); - o << "Old | New" << std::endl; + o << "Old | New" << '\n'; o << " P1 X |"; o.width(7); - o << OldP1.X() << " | " << NewP1.X() << std::endl; + o << OldP1.X() << " | " << NewP1.X() << '\n'; o << " Y |"; o.width(7); - o << OldP1.Y() << " | " << NewP1.Y() << std::endl; + o << OldP1.Y() << " | " << NewP1.Y() << '\n'; o << " P2 X |"; o.width(7); - o << OldP2.X() << " | " << NewP2.X() << std::endl; + o << OldP2.X() << " | " << NewP2.X() << '\n'; o << " Y |"; o.width(7); - o << OldP2.Y() << " | " << NewP2.Y() << std::endl; + o << OldP2.Y() << " | " << NewP2.Y() << '\n'; o << " Angle1 |"; o.width(7); - o << OldAngle1 << " | " << NewAngle1 << std::endl; + o << OldAngle1 << " | " << NewAngle1 << '\n'; o << " Angle2 |"; o.width(7); - o << OldAngle2 << " | " << NewAngle2 << std::endl; + o << OldAngle2 << " | " << NewAngle2 << '\n'; o << " Curvature1 |"; o.width(7); - o << OldCurvature1 << " | " << NewCurvature1 << std::endl; + o << OldCurvature1 << " | " << NewCurvature1 << '\n'; o << " Curvature2 |"; o.width(7); - o << OldCurvature2 << " | " << NewCurvature2 << std::endl; + o << OldCurvature2 << " | " << NewCurvature2 << '\n'; o << " Height |"; o.width(7); - o << OldHeight << " | " << NewHeight << std::endl; + o << OldHeight << " | " << NewHeight << '\n'; o << " Slope |"; o.width(7); - o << OldSlope << " | " << NewSlope << std::endl; + o << OldSlope << " | " << NewSlope << '\n'; o << " PhysicalRatio |"; o.width(7); - o << OldPhysicalRatio << " | " << NewPhysicalRatio << std::endl; + o << OldPhysicalRatio << " | " << NewPhysicalRatio << '\n'; o << " SlidingFactor |"; o.width(7); - o << OldSlidingFactor << " | " << NewSlidingFactor << std::endl; + o << OldSlidingFactor << " | " << NewSlidingFactor << '\n'; o << " FreeSliding |"; o.width(7); - o << OldFreeSliding << " | " << NewFreeSliding << std::endl; + o << OldFreeSliding << " | " << NewFreeSliding << '\n'; o << " ConstrOrder1 |"; o.width(7); - o << OldConstraintOrder1 << " | " << NewConstraintOrder1 << std::endl; + o << OldConstraintOrder1 << " | " << NewConstraintOrder1 << '\n'; o << " ConstrOrder2 |"; o.width(7); - o << OldConstraintOrder2 << " | " << NewConstraintOrder2 << std::endl; + o << OldConstraintOrder2 << " | " << NewConstraintOrder2 << '\n'; switch (myCode) { case FairCurve_OK: - o << "AnalysisCode : Ok" << std::endl; + o << "AnalysisCode : Ok" << '\n'; break; case FairCurve_NotConverged: - o << "AnalysisCode : NotConverged" << std::endl; + o << "AnalysisCode : NotConverged" << '\n'; break; case FairCurve_InfiniteSliding: - o << "AnalysisCode : InfiniteSliding" << std::endl; + o << "AnalysisCode : InfiniteSliding" << '\n'; break; case FairCurve_NullHeight: - o << "AnalysisCode : NullHeight" << std::endl; + o << "AnalysisCode : NullHeight" << '\n'; break; } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx index b88cfd0cc0..417703fe14 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomAPI_IntSS_Test.cxx @@ -3620,9 +3620,13 @@ TEST(GeomAPI_IntSSTest, OCC23972_TwoConesIntersection) // Intersection of two cones yields hyperbolic curves which may be unbounded; // clamp to a finite window to verify the span is non-degenerate. if (aU1 < -20.0) + { aU1 = -20.0; + } if (aU2 > 20.0) + { aU2 = 20.0; + } ASSERT_GT(aU2 - aU1, 1.0e-20) << "Degenerate parameter range for curve " << anIdx; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx index 365c14cc23..5e683c2d22 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_BSplineCurves_Test.cxx @@ -104,11 +104,17 @@ double maxTolerance(const TopoDS_Shape& theShape) { double aMaxTol = 0.0; for (TopExp_Explorer anExp(theShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) + { aMaxTol = std::max(aMaxTol, BRep_Tool::Tolerance(TopoDS::Vertex(anExp.Current()))); + } for (TopExp_Explorer anExp(theShape, TopAbs_EDGE); anExp.More(); anExp.Next()) + { aMaxTol = std::max(aMaxTol, BRep_Tool::Tolerance(TopoDS::Edge(anExp.Current()))); + } for (TopExp_Explorer anExp(theShape, TopAbs_FACE); anExp.More(); anExp.Next()) + { aMaxTol = std::max(aMaxTol, BRep_Tool::Tolerance(TopoDS::Face(anExp.Current()))); + } return aMaxTol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_Gordon_Test.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_Gordon_Test.cxx index f5b44f80dd..6faabb5f50 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_Gordon_Test.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GTests/GeomFill_Gordon_Test.cxx @@ -325,10 +325,14 @@ TEST(GeomFill_GordonBuilder, FiveByFourGrid_ProducesValidSurface) NCollection_Array1 aProfileParams(1, 5); for (int i = 0; i < 5; ++i) + { aProfileParams(i + 1) = aProfY[i]; + } NCollection_Array1 aGuideParams(1, 4); for (int j = 0; j < 4; ++j) + { aGuideParams(j + 1) = aGuidX[j]; + } GeomFill_GordonBuilder aBuilder; aBuilder.Init(aProfiles, aGuides, aProfileParams, aGuideParams, Precision::Confusion()); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_2.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_2.cxx index dd3b97bd50..c0aa47cac0 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_2.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_2.cxx @@ -118,17 +118,25 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedLin& Qualified1, gp_Dir2d dc1(originL1.XY() - pbid.XY()); double sign1 = dc1.Dot(gp_Dir2d(-L1.Direction().Y(), L1.Direction().X())); if (sign1 > 0.0) + { ok = (Qualified1.IsUnqualified() || Qualified1.IsOutside()); + } else + { ok = (Qualified1.IsUnqualified() || Qualified1.IsEnclosed()); + } // solution Outside or Enclosed / L2 gp_Dir2d dc2(originL2.XY() - pbid.XY()); double sign2 = dc2.Dot(gp_Dir2d(-L2.Direction().Y(), L2.Direction().X())); if (sign2 > 0.0) + { ok = ok && (Qualified2.IsUnqualified() || Qualified2.IsOutside()); + } else + { ok = ok && (Qualified2.IsUnqualified() || Qualified2.IsEnclosed()); + } if (ok) { @@ -136,15 +144,23 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedLin& Qualified1, dc1 = gp_Dir2d(sign1 * gp_XY(-L1.Direction().Y(), L1.Direction().X())); pnttg1sol(i) = gp_Pnt2d(pbid.XY() + Radius * dc1.XY()); if (sign1 > 0.0) + { qualifier1(i) = GccEnt_outside; + } else + { qualifier1(i) = GccEnt_enclosed; + } dc2 = gp_Dir2d(sign2 * gp_XY(-L2.Direction().Y(), L2.Direction().X())); pnttg2sol(i) = gp_Pnt2d(pbid.XY() + Radius * dc2.XY()); if (sign2 > 0.0) + { qualifier2(i) = GccEnt_outside; + } else + { qualifier2(i) = GccEnt_enclosed; + } pntcen(i) = pbid; par1sol(i) = ElCLib::Parameter(cirsol(i), pnttg1sol(i)); pararg1(i) = ElCLib::Parameter(L1, pnttg1sol(i)); @@ -156,7 +172,9 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedLin& Qualified1, { // solution to be rejected if (i == NbrSol) + { NbrSol--; + } else { for (int k = i + 1; k <= NbrSol; k++) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_8.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_8.cxx index 80f34d2ecb..8266f13c23 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_8.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanOn_8.cxx @@ -96,7 +96,9 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedCirc& Qualified1, if (d1 > Tol || d2 > Tol) { if (!SameCenter) + { pinterm = gp_Pnt2d(center1.XY() + (distcco + Ron) * dircc.XY()); + } distcc2 = pinterm.Distance(Point2); distcc1 = pinterm.Distance(center1); d1 = std::abs(distcc2 - std::abs(distcc1 - R1)); @@ -134,7 +136,9 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedCirc& Qualified1, // =========================================================== gp_Dir2d dc1; if (!SameCenter) + { dc1 = gp_Dir2d(center1.XY() - pinterm.XY()); + } if (!Qualified1.IsUnqualified()) { qualifier1(NbrSol) = Qualified1.Qualifier(); @@ -153,9 +157,13 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedCirc& Qualified1, } qualifier2(NbrSol) = GccEnt_noqualifier; if (!SameCenter) + { pnttg1sol(NbrSol) = gp_Pnt2d(pinterm.XY() + Radius(i) * dc1.XY()); + } else + { pnttg1sol(NbrSol) = gp_Pnt2d(pinterm.XY()); + } pnttg2sol(NbrSol) = Point2; pntcen(NbrSol) = cirsol(NbrSol).Location(); par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); @@ -255,7 +263,9 @@ GccAna_Circ2d2TanOn::GccAna_Circ2d2TanOn(const GccEnt_QualifiedCirc& Qualified1, continue; } if (NbrSol == 4) + { break; + } NbrSol++; cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center, dirx), Radius(k)); // ========================================================== diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanRad_1.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanRad_1.cxx index 506760c0de..6a47f31c85 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanRad_1.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d2TanRad_1.cxx @@ -492,7 +492,9 @@ GccAna_Circ2d2TanRad::GccAna_Circ2d2TanRad(const GccEnt_QualifiedCirc& Qualified for (int jcote2 = 1; jcote2 <= ncote2; jcote2++) { if (cote1(jcote1) < Tol) + { continue; + } gp_Circ2d cirint(gp_Ax2d(center1, dirx), cote1(jcote1)); gp_Lin2d linint( gp_Pnt2d(lxloc - cote2(jcote2) * ydir * Radius, lyloc + cote2(jcote2) * xdir * Radius), diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan.cxx index ee8387ec3f..3649c8682f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan.cxx @@ -100,7 +100,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, if ((std::abs(R1 - R2) <= Tolerance && center1.IsEqual(center2, Tolerance)) || (std::abs(R1 - R3) <= Tolerance && center1.IsEqual(center3, Tolerance)) || (std::abs(R2 - R3) <= Tolerance && center2.IsEqual(center3, Tolerance))) + { return; + } else { if (std::abs(dir2 ^ dir3) <= Tolerance) @@ -113,12 +115,16 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, if (std::abs(std::abs(R1 - R3) - Dist2) <= Tolerance) { if (std::abs(std::abs(R2 - R3) - Dist3) <= Tolerance) + { return; + } } else if (std::abs(R1 + R3 - Dist2) <= Tolerance) { if (std::abs(R2 + R3 - Dist3) <= Tolerance) + { return; + } } } else if (std::abs(R1 + R2 - Dist1) <= Tolerance) @@ -131,7 +137,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, { if (std::abs(std::abs(R2 - R3) - Dist3) <= Tolerance && std::abs(R1 + R3 - Dist2) <= Tolerance) + { return; + } } } } @@ -332,17 +340,23 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, if (((i == 2 || i == 5 || i == 6 || i == 8) && (Qualified1.IsEnclosed() || Qualified1.IsEnclosing())) || ((i == 1 || i == 3 || i == 4 || i == 7) && Qualified1.IsOutside())) + { continue; + } if (((i == 3 || i == 5 || i == 7 || i == 8) && (Qualified2.IsEnclosed() || Qualified2.IsEnclosing())) || ((i == 1 || i == 2 || i == 4 || i == 6) && Qualified2.IsOutside())) + { continue; + } if (((i == 4 || i == 6 || i == 7 || i == 8) && (Qualified3.IsEnclosed() || Qualified3.IsEnclosing())) || ((i == 1 || i == 2 || i == 3 || i == 5) && Qualified3.IsOutside())) + { continue; + } // Check is Cir1 a solution of this system or not // In that case equations are equal to each other @@ -366,6 +380,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, C = f2; math_DirectPolynomialRoots yRoots(A, B, C); if (yRoots.IsDone() && !yRoots.InfiniteRoots()) + { for (k = 1; k <= yRoots.NbSolutions(); k++) { // for each y solution: @@ -379,6 +394,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, C = c3 * (y * y) + 2 * e3 * y + f3; math_DirectPolynomialRoots xRoots(A, B, C); if (xRoots.IsDone() && !xRoots.InfiniteRoots()) + { for (j = 1; j <= xRoots.NbSolutions(); j++) { x = xRoots.Value(j); @@ -389,8 +405,10 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, CurSol++; } } + } } } + } // 1.2) b2y + d2 != 0 A = a3 * c2 * c2 - 4 * b2 * (b3 * c2 - b2 * c3); @@ -409,14 +427,19 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // Derivation of the equation Ay4 + By3 + Cy2 + Dy + E math_DirectPolynomialRoots yRoots1(4 * A, 3 * B, 2 * C, D); if (yRoots1.IsDone() && !yRoots1.InfiniteRoots()) + { for (k = 1; k <= yRoots1.NbSolutions(); k++) { y = yRoots1.Value(k); // Check if this value is already caught IsSame = false; for (l = 1; l < k; l++) + { if (std::abs(y - yRoots1.Value(l)) <= 10 * Tolerance) + { IsSame = true; + } + } Epsilon = (std::abs((std::abs((std::abs(4 * A * y) + std::abs(3 * B)) * y) + std::abs(2 * C)) @@ -433,10 +456,12 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, } } } + } } math_DirectPolynomialRoots yRoots1(A, B, C, D, E); if (yRoots1.IsDone() && !yRoots1.InfiniteRoots()) + { for (k = 1; k <= yRoots1.NbSolutions(); k++) { y = yRoots1.Value(k); @@ -444,8 +469,12 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, IsSame = false; FirstIndex = (i == 1) ? 1 : FirstSol(i); for (l = FirstIndex; l < CurSol; l++) + { if (std::abs(y - ySol(l)) <= 10 * Tolerance) + { IsSame = true; + } + } if (!IsSame && std::abs(b2 * y + d2) > b2 * Tolerance) { @@ -455,6 +484,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, CurSol++; } } + } } else { @@ -473,6 +503,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, { math_DirectPolynomialRoots yRoots(m, n, t); if (yRoots.IsDone() && !yRoots.InfiniteRoots()) + { for (k = 1; k <= yRoots.NbSolutions(); k++) { // for each y solution: @@ -492,6 +523,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, C = c2 * y * y + 2 * e2 * y + f2; math_DirectPolynomialRoots xRoots(A, B, C); if (xRoots.IsDone() && !xRoots.InfiniteRoots()) + { for (l = 1; l <= xRoots.NbSolutions(); l++) { // for each x solution: @@ -504,8 +536,10 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, CurSol++; } } + } } } + } } else { @@ -526,6 +560,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // Derivation of the equation Ay4 + By3 + Cy2 + Dy + E math_DirectPolynomialRoots yRoots1(4 * A, 3 * B, 2 * C, D); if (yRoots1.IsDone() && !yRoots1.InfiniteRoots()) + { for (k = 1; k <= yRoots1.NbSolutions(); k++) { y = yRoots1.Value(k); @@ -537,8 +572,12 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, IsSame = false; FirstIndex = (i == 1) ? 1 : FirstSol(i); for (l = FirstIndex; l < CurSol; l++) + { if (std::abs(y - ySol(l)) <= 10 * Tolerance) + { IsSame = true; + } + } Epsilon = (std::abs((std::abs((std::abs(4 * A * y) + std::abs(3 * B)) * y) + std::abs(2 * C)) @@ -558,6 +597,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, C = c2 * y * y + 2 * e2 * y + f2; math_DirectPolynomialRoots xRoots(A, B, C); if (xRoots.IsDone() && !xRoots.InfiniteRoots()) + { for (l = 1; l <= xRoots.NbSolutions(); l++) { // for each x solution: @@ -570,13 +610,16 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, CurSol++; } } + } } } } + } } math_DirectPolynomialRoots yRoots(A, B, C, D, E); if (yRoots.IsDone() && !yRoots.InfiniteRoots()) + { for (k = 1; k <= yRoots.NbSolutions(); k++) { // for each y solution: @@ -588,8 +631,12 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // Check if this value is already caught IsSame = false; for (l = 1; l < k; l++) + { if (std::abs(y - yRoots.Value(l)) <= 10 * Tolerance) + { IsSame = true; + } + } Epsilon = 2. * (std::abs((b2 * b2 + std::abs(a2 * c2)) * y) + std::abs(b2 * d2) @@ -602,6 +649,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, C = c2 * y * y + 2 * e2 * y + f2; math_DirectPolynomialRoots xRoots(A, B, C); if (xRoots.IsDone() && !xRoots.InfiniteRoots()) + { for (l = 1; l <= xRoots.NbSolutions(); l++) { // for each x solution: @@ -614,8 +662,10 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, CurSol++; } } + } } } + } } } } @@ -767,6 +817,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // Other cases Epsilon = 10 * (std::abs(Beta3(i)) + std::abs(Gamma3(i)) + 1.); if (i == 1 || i == 3) + { if (std::abs(R3 + Beta3(i) * x + Gamma3(i) * y + Delta3(i) - r) <= Epsilon * Tolerance) { xSol(CurSol) = x; @@ -774,7 +825,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, rSol(CurSol) = r; CurSol++; } + } if (i == 6 || i == 8) + { if (std::abs(R3 + Beta3(i) * x + Gamma3(i) * y + Delta3(i) + r) <= Epsilon * Tolerance) { xSol(CurSol) = x; @@ -782,7 +835,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, rSol(CurSol) = r; CurSol++; } + } if (i == 4 || i == 7) + { if (std::abs(Beta3(i) * x + Gamma3(i) * y + Delta3(i) - r - R3) <= Epsilon * Tolerance) { xSol(CurSol) = x; @@ -790,7 +845,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, rSol(CurSol) = r; CurSol++; } + } if (i == 2 || i == 5) + { if (std::abs(r - R3 + Beta3(i) * x + Gamma3(i) * y + Delta3(i)) <= Epsilon * Tolerance) { xSol(CurSol) = x; @@ -798,6 +855,7 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, rSol(CurSol) = r; CurSol++; } + } } } } @@ -811,17 +869,25 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, { if ((Qualified1.IsEnclosed() && rSol(j) > R1) || (Qualified1.IsEnclosing() && rSol(j) < R1)) + { continue; + } if ((Qualified2.IsEnclosed() && rSol(j) > R2) || (Qualified2.IsEnclosing() && rSol(j) < R2)) + { continue; + } if ((Qualified3.IsEnclosed() && rSol(j) > R3) || (Qualified3.IsEnclosing() && rSol(j) < R3)) + { continue; + } NbrSol++; // RLE, avoid out of range if (NbrSol > cirsol.Upper()) + { NbrSol = cirsol.Upper(); + } gp_Pnt2d Center = gp_Pnt2d(xSol(j), ySol(j)); @@ -830,76 +896,118 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // ========================================================== double distcc1 = Center.Distance(center1); if (!Qualified1.IsUnqualified()) + { qualifier1(NbrSol) = Qualified1.Qualifier(); + } else if (std::abs(distcc1 + rSol(j) - R1) <= Tol) + { qualifier1(NbrSol) = GccEnt_enclosed; + } else if (std::abs(distcc1 - R1 - rSol(j)) <= Tol) + { qualifier1(NbrSol) = GccEnt_outside; + } else + { qualifier1(NbrSol) = GccEnt_enclosing; + } double distcc2 = Center.Distance(center1); if (!Qualified2.IsUnqualified()) + { qualifier2(NbrSol) = Qualified2.Qualifier(); + } else if (std::abs(distcc2 + rSol(j) - R2) <= Tol) + { qualifier2(NbrSol) = GccEnt_enclosed; + } else if (std::abs(distcc2 - R2 - rSol(j)) <= Tol) + { qualifier2(NbrSol) = GccEnt_outside; + } else + { qualifier2(NbrSol) = GccEnt_enclosing; + } double distcc3 = Center.Distance(center1); if (!Qualified3.IsUnqualified()) + { qualifier3(NbrSol) = Qualified3.Qualifier(); + } else if (std::abs(distcc3 + rSol(j) - R3) <= Tol) + { qualifier3(NbrSol) = GccEnt_enclosed; + } else if (std::abs(distcc3 - R3 - rSol(j)) <= Tol) + { qualifier3(NbrSol) = GccEnt_outside; + } else + { qualifier3(NbrSol) = GccEnt_enclosing; + } // ========================================================== if (Center.Distance(Cir1.Location()) <= Tolerance) + { TheSame1(NbrSol) = 1; + } else { TheSame1(NbrSol) = 0; gp_Dir2d dc; if ((i == 2 || i == 5 || i == 6 || i == 8) || rSol(j) > R1) + { dc.SetXY(Cir1.Location().XY() - Center.XY()); + } else + { dc.SetXY(Center.XY() - Cir1.Location().XY()); + } pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY() + rSol(j) * dc.XY()); par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); pararg1(NbrSol) = ElCLib::Parameter(Cir1, pnttg1sol(NbrSol)); } if (Center.Distance(Cir2.Location()) <= Tolerance) + { TheSame2(NbrSol) = 1; + } else { TheSame2(NbrSol) = 0; gp_Dir2d dc; if ((i == 3 || i == 5 || i == 7 || i == 8) || rSol(j) > R2) + { dc.SetXY(Cir2.Location().XY() - Center.XY()); + } else + { dc.SetXY(Center.XY() - Cir2.Location().XY()); + } pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY() + rSol(j) * dc.XY()); par2sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg2sol(NbrSol)); pararg2(NbrSol) = ElCLib::Parameter(Cir2, pnttg2sol(NbrSol)); } if (Center.Distance(Cir3.Location()) <= Tolerance) + { TheSame3(NbrSol) = 1; + } else { TheSame3(NbrSol) = 0; gp_Dir2d dc; if ((i == 4 || i == 6 || i == 7 || i == 8) || rSol(j) > R3) + { dc.SetXY(Cir3.Location().XY() - Center.XY()); + } else + { dc.SetXY(Center.XY() - Cir3.Location().XY()); + } pnttg3sol(NbrSol) = gp_Pnt2d(Center.XY() + rSol(j) * dc.XY()); par3sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg3sol(NbrSol)); pararg3(NbrSol) = ElCLib::Parameter(Cir3, pnttg3sol(NbrSol)); @@ -924,10 +1032,14 @@ int GccAna_Circ2d3Tan::NbSolutions() const gp_Circ2d GccAna_Circ2d3Tan::ThisSolution(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } return cirsol(Index); } @@ -1040,13 +1152,19 @@ void GccAna_Circ2d3Tan::Tangency3(const int Index, bool GccAna_Circ2d3Tan::IsTheSame1(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame1(Index) == 0) + { return false; + } return true; } @@ -1054,13 +1172,19 @@ bool GccAna_Circ2d3Tan::IsTheSame1(const int Index) const bool GccAna_Circ2d3Tan::IsTheSame2(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame2(Index) == 0) + { return false; + } return true; } @@ -1068,13 +1192,19 @@ bool GccAna_Circ2d3Tan::IsTheSame2(const int Index) const bool GccAna_Circ2d3Tan::IsTheSame3(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame3(Index) == 0) + { return false; + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_1.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_1.cxx index d37bf30f6c..272ea75d8c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_1.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_1.cxx @@ -141,7 +141,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // pop : if the coordinates are too great, no creation if (Center.X() > 1e10 || Center.Y() > 1e10) + { break; + } double dist1 = Center.Distance(C1.Location()); double dist2 = Center.Distance(C2.Location()); @@ -149,7 +151,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // pop : if the coordinates are too great, no creation if (dist3 > 1e10) + { break; + } int nbsol1 = 0; int nbsol2 = 0; @@ -347,14 +351,22 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // POP for protection if cirsol(NbrSol).Location == pnttg1sol(NbrSol) if (cirsol(NbrSol).Location().IsEqual(pnttg1sol(NbrSol), Precision::Confusion())) + { par1sol(NbrSol) = 1; + } else + { par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); + } // POP for protection if C1.Location == pnttg1sol(NbrSol) if (C1.Location().IsEqual(pnttg1sol(NbrSol), Precision::Confusion())) + { pararg1(NbrSol) = 1; + } else + { pararg1(NbrSol) = ElCLib::Parameter(C1, pnttg1sol(NbrSol)); + } } if (Center.Distance(C2.Location()) <= Tolerance && std::abs(Radius(ind3) - R2) <= Tolerance) @@ -369,14 +381,22 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // POP for protection if cirsol(NbrSol).Location == pnttg1sol(NbrSol) if (cirsol(NbrSol).Location().IsEqual(pnttg1sol(NbrSol), Precision::Confusion())) + { par1sol(NbrSol) = 1; + } else + { par2sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg2sol(NbrSol)); + } // POP for protection if C2.Location == pnttg2sol(NbrSol) if (C2.Location().IsEqual(pnttg2sol(NbrSol), Precision::Confusion())) + { pararg2(NbrSol) = 1; + } else + { pararg2(NbrSol) = ElCLib::Parameter(C2, pnttg2sol(NbrSol)); + } } TheSame3(NbrSol) = 0; gp_Dir2d dc(L3.Location().XY() - Center.XY()); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_4.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_4.cxx index 14cad25341..8cd1990e52 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_4.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_4.cxx @@ -358,8 +358,10 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, TheSame1(NbrSol) = 0; gp_Dir2d dc(center1.XY() - Center.XY()); if (qualifier1(NbrSol) == GccEnt_enclosed) + { // clang-format off dc.Reverse(); // if tangent circle is inside the source circle, moving to edge of source circle +} // clang-format on pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY() + Radius(k1) * dc.XY()); par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); @@ -378,7 +380,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, // 2nd tangency point is at the other side of the circle solution double alpha = 1.; if (center1.Distance(center2) <= Tolerance) + { alpha = -1; + } pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY() + alpha * Radius(k1) * dc.XY()); par2sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg2sol(NbrSol)); pararg2(NbrSol) = ElCLib::Parameter(C2, pnttg2sol(NbrSol)); @@ -389,20 +393,28 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, pararg3(NbrSol) = 0.; WellDone = true; if (NbrSol == MaxSol) + { break; + } } } } } WellDone = true; if (NbrSol == MaxSol) + { break; + } } if (NbrSol == MaxSol) + { break; + } } if (NbrSol == MaxSol) + { break; + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_5.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_5.cxx index f2b3eb7b56..7735daedf1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_5.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_5.cxx @@ -220,12 +220,18 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, for (int k = 1; k <= nbsol3; k++) { if (NbrSol == 4) + { break; + } // pop : if the radius is too great - no creation if (Radius(k) > MaxRad) + { break; + } if (std::abs(Radius(k)) < MinRad) + { break; + } NbrSol++; cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center, dirx), Radius(k)); @@ -295,7 +301,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, WellDone = true; } if (NbrSol == 4) + { break; + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_7.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_7.cxx index 9ce039dfef..cdcefa0eda 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_7.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2d3Tan_7.cxx @@ -176,7 +176,9 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, { // for (int k = 1 ; k <= nbsol3 ; k++) { if (NbrSol >= 2) + { break; + } NbrSol++; // cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k)); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center, dirx), Radius(nbsol3)); @@ -210,8 +212,10 @@ GccAna_Circ2d3Tan::GccAna_Circ2d3Tan(const GccEnt_QualifiedCirc& Qualified1, TheSame1(NbrSol) = 0; gp_Dir2d dc(center1.XY() - Center.XY()); if (qualifier1(NbrSol) == GccEnt_enclosed) + { // clang-format off dc.Reverse(); // if tangent circle is inside the source circle, moving to edge of source circle +} // clang-format on pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY() + Radius(nbsol3) * dc.XY()); par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dBisec.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dBisec.cxx index 96dcf44975..cdc055086b 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dBisec.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dBisec.cxx @@ -179,9 +179,13 @@ occ::handle GccAna_Circ2dBisec::ThisSolution(const int Index) cons { double R; if (Index == 1) + { R = (R1 + R2) / 2.0; + } else + { R = (R1 - R2) / 2.0; + } gp_Circ2d C(acenx, R); bissol = new GccInt_BCirc(C); // ============================= @@ -402,7 +406,9 @@ bool GccAna_Circ2dBisec::IsDone() const int GccAna_Circ2dBisec::NbSolutions() const { if (!WellDone) + { throw StdFail_NotDone(); + } return NbrSol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanCen.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanCen.cxx index 6e287fc661..a0ab755ac7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanCen.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanCen.cxx @@ -339,12 +339,18 @@ void GccAna_Circ2dTanCen::Tangency1(const int Index, bool GccAna_Circ2dTanCen::IsTheSame1(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame1(Index) == 0) + { return false; + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanOnRad.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanOnRad.cxx index edb83b0e94..bce998721e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanOnRad.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Circ2dTanOnRad.cxx @@ -277,7 +277,9 @@ GccAna_Circ2dTanOnRad::GccAna_Circ2dTanOnRad(const GccEnt_QualifiedCirc& Qualifi } Center = gp_Pnt2d(xc, yc); if (OnLine.Distance(Center) > Tol) + { continue; + } NbrSol++; cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center, dirx), Radius); // ======================================================= @@ -395,13 +397,19 @@ void GccAna_Circ2dTanOnRad::CenterOn3(const int Index, double& ParArg, gp_Pnt2d& bool GccAna_Circ2dTanOnRad::IsTheSame1(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame1(Index) == 0) + { return false; + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircLin2dBisec.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircLin2dBisec.cxx index 2d0dbff8bd..7c273e27ba 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircLin2dBisec.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircLin2dBisec.cxx @@ -66,10 +66,14 @@ occ::handle GccAna_CircLin2dBisec::ThisSolution(const int Index) c { if (!WellDone) + { throw StdFail_NotDone(); + } if ((Index <= 0) || (Index > NbrSol)) + { throw Standard_OutOfRange(); + } occ::handle bissol; double xdir = line.Direction().X(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircPnt2dBisec.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircPnt2dBisec.cxx index cc53b67239..4bd0b92b61 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircPnt2dBisec.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_CircPnt2dBisec.cxx @@ -48,7 +48,9 @@ GccAna_CircPnt2dBisec::GccAna_CircPnt2dBisec(const gp_Circ2d& Circle, point = Point; myTolerance = 1.e-10; if (myTolerance < Tolerance) + { myTolerance = Tolerance; + } DefineSolutions(); } @@ -92,10 +94,14 @@ occ::handle GccAna_CircPnt2dBisec::ThisSolution(const int Index) c { if (!WellDone) + { throw StdFail_NotDone(); + } if ((Index <= 0) || (Index > NbrSol)) + { throw Standard_OutOfRange(); + } occ::handle bissol; double xpoint = point.X(); @@ -137,9 +143,13 @@ occ::handle GccAna_CircPnt2dBisec::ThisSolution(const int Index) c { gp_Dir2d dirsol; if (circle.IsDirect()) + { dirsol = gp_Dir2d(xcencir - xpoint, ycencir - ypoint); + } else + { dirsol = gp_Dir2d(xpoint - xcencir, ypoint - ycencir); + } gp_Lin2d biscirpnt(point, dirsol); bissol = new GccInt_BLine(biscirpnt); // ========================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dBisec.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dBisec.cxx index c1056e6954..7ae3627509 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dBisec.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dBisec.cxx @@ -70,7 +70,9 @@ GccAna_Lin2dBisec::GccAna_Lin2dBisec(const gp_Lin2d& Lin1, const gp_Lin2d& Lin2) double cross = gp_Vec2d(-Lin2.Direction().Y(), Lin2.Direction().X()) .Dot(gp_Vec2d(Lin2.Location(), Lin1.Location())); if (cross < 0) + { dist = -dist; + } NbrSol++; WellDone = true; linsol(NbrSol) = @@ -130,16 +132,22 @@ bool GccAna_Lin2dBisec::IsDone() const int GccAna_Lin2dBisec::NbSolutions() const { if (!WellDone) + { throw StdFail_NotDone(); + } return NbrSol; } gp_Lin2d GccAna_Lin2dBisec::ThisSolution(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } return linsol(Index); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanObl.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanObl.cxx index 8ae5babbaa..4b3964b784 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanObl.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanObl.cxx @@ -232,16 +232,22 @@ bool GccAna_Lin2dTanObl::IsDone() const int GccAna_Lin2dTanObl::NbSolutions() const { if (!WellDone) + { throw StdFail_NotDone(); + } return NbrSol; } gp_Lin2d GccAna_Lin2dTanObl::ThisSolution(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } return linsol(Index); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanPar.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanPar.cxx index b6755404b0..2ba83e7bd4 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanPar.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_Lin2dTanPar.cxx @@ -136,7 +136,9 @@ bool GccAna_Lin2dTanPar::IsDone() const int GccAna_Lin2dTanPar::NbSolutions() const { if (!WellDone) + { throw StdFail_NotDone(); + } return NbrSol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_LinPnt2dBisec.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_LinPnt2dBisec.cxx index 52ca5926be..f438a167fc 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_LinPnt2dBisec.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GccAna/GccAna_LinPnt2dBisec.cxx @@ -81,7 +81,9 @@ bool GccAna_LinPnt2dBisec::IsDone() const occ::handle GccAna_LinPnt2dBisec::ThisSolution() const { if (!WellDone) + { throw StdFail_NotDone(); + } return bissol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ExtremaCurveCurve.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ExtremaCurveCurve.cxx index 8b33d07df5..2236134344 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ExtremaCurveCurve.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ExtremaCurveCurve.cxx @@ -67,9 +67,13 @@ Geom2dAPI_ExtremaCurveCurve::Geom2dAPI_ExtremaCurveCurve(const occ::handle& C1, const int Geom2dAPI_InterCurveCurve::NbPoints() const { if (myIsDone) + { return myIntersector.NbPoints(); + } else + { return 0; + } } //================================================================================================= @@ -104,9 +108,13 @@ gp_Pnt2d Geom2dAPI_InterCurveCurve::Point(const int Index) const int Geom2dAPI_InterCurveCurve::NbSegments() const { if (myIsDone) + { return myIntersector.NbSegments(); + } else + { return 0; + } } //======================================================================= @@ -166,9 +174,13 @@ void Geom2dAPI_InterCurveCurve::Segment(const int theIndex, aU1 = anIPF.ParamOnFirst(); if (isOpposite) + { aV2 = anIPF.ParamOnSecond(); + } else + { aV1 = anIPF.ParamOnSecond(); + } } if (aSeg.HasLastPoint()) @@ -177,14 +189,22 @@ void Geom2dAPI_InterCurveCurve::Segment(const int theIndex, aU2 = anIPL.ParamOnFirst(); if (isOpposite) + { aV1 = anIPL.ParamOnSecond(); + } else + { aV2 = anIPL.ParamOnSecond(); + } } theCurve1 = new Geom2d_TrimmedCurve(myCurve1, aU1, aU2); if (myCurve2.IsNull()) + { theCurve2 = new Geom2d_TrimmedCurve(myCurve1, aV1, aV2); + } else + { theCurve2 = new Geom2d_TrimmedCurve(myCurve2, aV1, aV2); + } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_Interpolate.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_Interpolate.cxx index 98bc85f94b..c2009125d6 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_Interpolate.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_Interpolate.cxx @@ -472,6 +472,7 @@ void Geom2dAPI_Interpolate::PerformPeriodic() degree = 3; num_poles += 2; if (myTangentRequest) + { for (ii = myTangentFlags->Lower() + 1; ii <= myTangentFlags->Upper(); ii++) { if (myTangentFlags->Value(ii)) @@ -479,6 +480,7 @@ void Geom2dAPI_Interpolate::PerformPeriodic() num_poles += 1; } } + } NCollection_Array1 parameters(1, num_poles); NCollection_Array1 flatknots(1, num_poles + degree + 1); @@ -634,6 +636,7 @@ void Geom2dAPI_Interpolate::PerformNonPeriodic() degree = 3; num_poles += 2; if (myTangentRequest) + { for (ii = myTangentFlags->Lower() + 1; ii < myTangentFlags->Upper(); ii++) { if (myTangentFlags->Value(ii)) @@ -641,6 +644,7 @@ void Geom2dAPI_Interpolate::PerformNonPeriodic() num_poles += 1; } } + } } NCollection_Array1 parameters(1, num_poles); @@ -813,7 +817,9 @@ void Geom2dAPI_Interpolate::PerformNonPeriodic() const occ::handle& Geom2dAPI_Interpolate::Curve() const { if (!myIsDone) + { throw StdFail_NotDone(" "); + } return myCurve; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_PointsToBSpline.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_PointsToBSpline.cxx index 01fd1e56b6..208960b0e8 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_PointsToBSpline.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_PointsToBSpline.cxx @@ -128,7 +128,9 @@ void Geom2dAPI_PointsToBSpline::Init(const NCollection_Array1& Points, int nbit = 2; bool UseSquares = false; if (Tol2D <= 1.e-3) + { UseSquares = true; + } AppDef_BSplineCompute TheComputer(DegMin, DegMax, Tol3D, Tol2D, nbit, true, ParType, UseSquares); @@ -314,7 +316,9 @@ void Geom2dAPI_PointsToBSpline::Init(const NCollection_Array1& Points, { myIsDone = false; if (Params.Length() != Points.Length()) + { throw Standard_OutOfRange("Geom2dAPI_PointsToBSpline::Init() - invalid input"); + } double Tol3D = 0.; // dummy argument for BSplineCompute. int Nbp = Params.Length(); @@ -325,7 +329,9 @@ void Geom2dAPI_PointsToBSpline::Init(const NCollection_Array1& Points, double Uf = Params(Params.Lower()); double Ul = Params(Params.Upper()) - Uf; if (!hasMeaningfulSpan(Ul)) + { return; + } for (int i = 2; i < Nbp; i++) { @@ -385,7 +391,9 @@ void Geom2dAPI_PointsToBSpline::Init(const NCollection_Array1& Points, int nbit = 2; if (Tol2D <= 1.e-3) + { nbit = 0; + } // Variational algo @@ -468,7 +476,9 @@ void Geom2dAPI_PointsToBSpline::Init(const NCollection_Array1& Points, const occ::handle& Geom2dAPI_PointsToBSpline::Curve() const { if (!myIsDone) + { throw StdFail_NotDone(" "); + } return myCurve; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ProjectPointOnCurve.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ProjectPointOnCurve.cxx index d96af6c106..6b031cd8ec 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ProjectPointOnCurve.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dAPI/Geom2dAPI_ProjectPointOnCurve.cxx @@ -92,9 +92,13 @@ void Geom2dAPI_ProjectPointOnCurve::Init(const gp_Pnt2d& P, int Geom2dAPI_ProjectPointOnCurve::NbPoints() const { if (myIsDone) + { return myExtPC.NbExt(); + } else + { return 0; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx index 7de5a00579..270107ee8d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx @@ -1261,12 +1261,18 @@ void Geom2dGcc_Circ2d2TanOnGeo::CenterOn3(const int Index, double& ParArg, gp_Pn bool Geom2dGcc_Circ2d2TanOnGeo::IsTheSame1(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame1(Index) == 0) + { return false; + } return true; } @@ -1274,12 +1280,18 @@ bool Geom2dGcc_Circ2d2TanOnGeo::IsTheSame1(const int Index) const bool Geom2dGcc_Circ2d2TanOnGeo::IsTheSame2(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame2(Index) == 0) + { return false; + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx index fbf5a36425..a01df9557e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx @@ -1417,16 +1417,22 @@ void Geom2dGcc_Circ2d2TanOnIter::CenterOn3(double& ParArg, gp_Pnt2d& PntSol) con bool Geom2dGcc_Circ2d2TanOnIter::IsTheSame1() const { if (!WellDone) + { throw StdFail_NotDone(); + } if (TheSame1 == 0) + { return false; + } return true; } bool Geom2dGcc_Circ2d2TanOnIter::IsTheSame2() const { if (!WellDone) + { throw StdFail_NotDone(); + } return false; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx index a08a3c1ed0..1b4cd4efd9 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx @@ -691,7 +691,9 @@ static void PrecRoot(const Adaptor2d_OffsetCurve& theC1, double aSQDist = aVuv.SquareMagnitude(); if (IsEqual(aSQDist, 0.0)) + { break; + } if ((aNbIter == 1) || (aSQDist < aSQDistPrev)) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx index 1da713c5c0..049c530833 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx @@ -578,55 +578,73 @@ void Geom2dGcc_Circ2d3Tan::Results(const GccAna_Circ2d3Tan& Circ, { TheSame1(j) = i1; if (i1 == 0) + { Circ.Tangency1(j, par1sol(j), pararg1(j), pnttg1sol(j)); + } } else if (Rank1 == 2) { TheSame1(j) = i2; if (i2 == 0) + { Circ.Tangency2(j, par1sol(j), pararg1(j), pnttg1sol(j)); + } } else if (Rank1 == 3) { TheSame1(j) = i3; if (i3 == 0) + { Circ.Tangency3(j, par1sol(j), pararg1(j), pnttg1sol(j)); + } } if (Rank2 == 1) { TheSame2(j) = i1; if (i1 == 0) + { Circ.Tangency1(j, par2sol(j), pararg2(j), pnttg2sol(j)); + } } else if (Rank2 == 2) { TheSame2(j) = i2; if (i2 == 0) + { Circ.Tangency2(j, par2sol(j), pararg2(j), pnttg2sol(j)); + } } else if (Rank2 == 3) { TheSame2(j) = i3; if (i3 == 0) + { Circ.Tangency3(j, par2sol(j), pararg2(j), pnttg2sol(j)); + } } if (Rank3 == 1) { TheSame3(j) = i1; if (i1 == 0) + { Circ.Tangency1(j, par3sol(j), pararg3(j), pnttg3sol(j)); + } } else if (Rank3 == 2) { TheSame3(j) = i2; if (i2 == 0) + { Circ.Tangency2(j, par3sol(j), pararg3(j), pnttg3sol(j)); + } } else if (Rank3 == 3) { TheSame3(j) = i3; if (i3 == 0) + { Circ.Tangency3(j, par3sol(j), pararg3(j), pnttg3sol(j)); + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx index a2836674b5..cace3d4ccb 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx @@ -1530,10 +1530,14 @@ void Geom2dGcc_Circ2d3TanIter::Tangency3(double& ParSol, double& ParArg, gp_Pnt2 bool Geom2dGcc_Circ2d3TanIter::IsTheSame1() const { if (!WellDone) + { throw StdFail_NotDone(); + } if (TheSame1 == 0) + { return false; + } return true; } @@ -1541,10 +1545,14 @@ bool Geom2dGcc_Circ2d3TanIter::IsTheSame1() const bool Geom2dGcc_Circ2d3TanIter::IsTheSame2() const { if (!WellDone) + { throw StdFail_NotDone(); + } if (TheSame3 == 0) + { return false; + } return true; } @@ -1552,7 +1560,9 @@ bool Geom2dGcc_Circ2d3TanIter::IsTheSame2() const bool Geom2dGcc_Circ2d3TanIter::IsTheSame3() const { if (!WellDone) + { throw StdFail_NotDone(); + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx index b92f932068..ba6939935c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx @@ -150,7 +150,9 @@ int Geom2dGcc_Circ2dTanCenGeo::NbSolutions() const gp_Circ2d Geom2dGcc_Circ2dTanCenGeo::ThisSolution(const int Index) const { if (Index > NbrSol || Index <= 0) + { throw Standard_OutOfRange(); + } return cirsol(Index); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx index bbbf84794b..08402f6063 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx @@ -831,7 +831,9 @@ gp_Circ2d Geom2dGcc_Circ2dTanOnRadGeo::ThisSolution(const int Index) const { if (Index > NbrSol || Index <= 0) + { throw Standard_OutOfRange(); + } return cirsol(Index); } @@ -893,12 +895,18 @@ void Geom2dGcc_Circ2dTanOnRadGeo::CenterOn3(const int Index, double& ParArg, gp_ bool Geom2dGcc_Circ2dTanOnRadGeo::IsTheSame1(const int Index) const { if (!WellDone) + { throw StdFail_NotDone(); + } if (Index <= 0 || Index > NbrSol) + { throw Standard_OutOfRange(); + } if (TheSame1(Index) == 0) + { return false; + } return true; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx index be177f9e8c..6bd818fcbe 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx @@ -106,7 +106,9 @@ Geom2dGcc_Lin2d2Tan::Geom2dGcc_Lin2d2Tan(const Geom2dGcc_QualifiedCurve& Qualifi if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, Tolang, C1, C2)) + { NbrSol++; + } } Param2 += aStep2; } @@ -176,7 +178,9 @@ Geom2dGcc_Lin2d2Tan::Geom2dGcc_Lin2d2Tan(const Geom2dGcc_QualifiedCurve& Qualifi if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, Tolang, C1, Geom2dAdaptor_Curve())) + { NbrSol++; + } } Param1 += aStep; @@ -421,7 +425,9 @@ bool Geom2dGcc_Lin2d2Tan::Add(const int theIndex, for (i = 1; i < theIndex; i++) { if (std::abs(aPar1arg - pararg1(i)) <= theTol && std::abs(aPar2arg - pararg2(i)) <= theTol) + { return false; + } } gp_Dir2d aLinDir = aLin.Direction(); @@ -431,14 +437,18 @@ bool Geom2dGcc_Lin2d2Tan::Add(const int theIndex, Geom2dGcc_CurveTool::D1(theC1, aPar1arg, aPoint, aVTan); if (std::abs(aLinDir.Crossed(gp_Dir2d(aVTan))) > theTol) + { return false; + } if (!theC2.Curve().IsNull()) { Geom2dGcc_CurveTool::D1(theC2, aPar2arg, aPoint, aVTan); if (std::abs(aLinDir.Crossed(gp_Dir2d(aVTan))) > theTol) + { return false; + } } linsol(theIndex) = aLin; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx index 963e355742..fd1d9a4a80 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx @@ -289,7 +289,9 @@ bool Geom2dGcc_Lin2d2TanIter::IsDone() const gp_Lin2d Geom2dGcc_Lin2d2TanIter::ThisSolution() const { if (!WellDone) + { throw StdFail_NotDone(); + } return linsol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx index c1ad126482..178eded80f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx @@ -88,7 +88,9 @@ Geom2dGcc_Lin2dTanObl::Geom2dGcc_Lin2dTanObl(const Geom2dGcc_QualifiedCurve& Qua if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, TolAng, C1)) + { NbrSol++; + } } Param1 += aStep; @@ -255,7 +257,9 @@ bool Geom2dGcc_Lin2dTanObl::Add(const int theIndex, for (i = 1; i < theIndex; i++) { if (std::abs(aPar1arg - pararg1(i)) <= theTol && std::abs(aPar2arg - pararg2(i)) <= theTol) + { return false; + } } gp_Dir2d aLinDir = aLin.Direction(); @@ -265,7 +269,9 @@ bool Geom2dGcc_Lin2dTanObl::Add(const int theIndex, Geom2dGcc_CurveTool::D1(theC1, aPar1arg, aPoint, aVTan); if (std::abs(aLinDir.Crossed(gp_Dir2d(aVTan))) > theTol) + { return false; + } linsol(theIndex) = aLin; par1sol(theIndex) = aPar1sol; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx index 9b3f734b46..f091ed8dd2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx @@ -135,7 +135,9 @@ bool Geom2dGcc_Lin2dTanOblIter::IsDone() const gp_Lin2d Geom2dGcc_Lin2dTanOblIter::ThisSolution() const { if (!WellDone) + { throw StdFail_NotDone(); + } return linsol; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Elements.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Elements.cxx index 9541108f81..beceb77e8b 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Elements.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Elements.cxx @@ -109,7 +109,9 @@ bool Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double& for (Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) { if (i < myCurEdge) + { continue; + } Geom2dHatch_Element& Item = myMap.ChangeFind(Itertemp.Key()); Geom2dAdaptor_Curve& E = Item.ChangeCurve(); @@ -125,10 +127,14 @@ bool Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double& aLPar = 1.; } else + { aFPar = aLPar - 1.; + } } else if (Precision::IsPositiveInfinite(aLPar)) + { aLPar = aFPar + 1.; + } for (; myCurEdgePar < Probing_End; myCurEdgePar += Probing_Step) { @@ -143,7 +149,9 @@ bool Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double& gp_Dir2d aLinDir(aLinVec); double aTanMod = aTanVec.SquareMagnitude(); if (aTanMod < Precision::SquarePConfusion()) + { continue; + } aTanVec /= std::sqrt(aTanMod); double aSinA = aTanVec.Crossed(aLinDir); @@ -152,7 +160,9 @@ bool Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double& // too small angle - line and edge may be considered // as tangent which is bad for classifier if (myCurEdgePar + Probing_Step < Probing_End) + { continue; + } } L = gp_Lin2d(P, aLinDir); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatcher.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatcher.cxx index 197a40f5f6..f8399f328c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatcher.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatcher.cxx @@ -157,7 +157,9 @@ int Geom2dHatch_Hatcher::AddElement(const Geom2dAdaptor_Curve& Curve, { int IndE; for (IndE = 1; IndE <= myNbElements && myElements.IsBound(IndE); IndE++) + { ; + } if (IndE > myNbElements) { myNbElements++; @@ -204,15 +206,21 @@ void Geom2dHatch_Hatcher::RemElement(const int IndE) } } if (PntH.NbPoints() == 0) + { Hatching.RemPoint(IPntH); + } } if (DomainsToClear) + { Hatching.ClrDomains(); + } } } myElements.UnBind(IndE); if (IndE == myNbElements) + { myNbElements--; + } } //======================================================================= @@ -255,7 +263,9 @@ int Geom2dHatch_Hatcher::AddHatching(const Geom2dAdaptor_Curve& Curve) { int IndH; for (IndH = 1; IndH <= myNbHatchings && myHatchings.IsBound(IndH); IndH++) + { ; + } if (IndH > myNbHatchings) { myNbHatchings++; @@ -280,7 +290,9 @@ void Geom2dHatch_Hatcher::RemHatching(const int IndH) Hatching.ClrPoints(); myHatchings.UnBind(IndH); if (IndH == myNbHatchings) + { myNbHatchings--; + } } //======================================================================= @@ -320,8 +332,12 @@ void Geom2dHatch_Hatcher::ClrHatchings() void Geom2dHatch_Hatcher::Trim() { for (int IndH = 1; IndH <= myNbHatchings; IndH++) + { if (myHatchings.IsBound(IndH)) + { Trim(IndH); + } + } } //======================================================================= @@ -540,7 +556,9 @@ bool Geom2dHatch_Hatcher::Trim(const int IndH, const int IndE) #endif if (myIntersector.IsEmpty()) + { return true; + } #if TRACE_HATCHER std::cout << "Number of intersection points : " << std::setw(3) << (myIntersector.NbPoints()) @@ -624,17 +642,29 @@ bool Geom2dHatch_Hatcher::Trim(const int IndH, const int IndE) { Conf3d = true; if (Conf3d) + { Conf3d = TypePnt1H != IntRes2d_Touch && TypePnt1H != IntRes2d_Undecided; + } if (Conf3d) + { Conf3d = TypePnt1E != IntRes2d_Touch && TypePnt1E != IntRes2d_Undecided; + } if (Conf3d) + { Conf3d = TypePnt2H != IntRes2d_Touch && TypePnt2H != IntRes2d_Undecided; + } if (Conf3d) + { Conf3d = TypePnt2E != IntRes2d_Touch && TypePnt2E != IntRes2d_Undecided; + } if (Conf3d) + { Conf3d = TypePnt1H == TypePnt2H && TypePnt1E == TypePnt2E; + } if (Conf3d) + { Conf3d = Pnt1.Value().Distance(Pnt2.Value()) <= myConfusion3d; + } } if (Conf2d || Conf3d) @@ -916,11 +946,13 @@ bool Geom2dHatch_Hatcher::GlobalTransition(HatchGen_PointOnHatching& Point) TopAbs_Orientation LocalTransition = TopAbs_EXTERNAL; if (ElementOrientation == TopAbs_INTERNAL) + { LocalTransition = TopAbs_INTERNAL; - + } else if (ElementOrientation == TopAbs_EXTERNAL) + { LocalTransition = TopAbs_EXTERNAL; - + } else if (PntE.IntersectionType() == HatchGen_TANGENT) { if (PntE.Position() == TopAbs_INTERNAL) @@ -1096,8 +1128,12 @@ bool Geom2dHatch_Hatcher::GlobalTransition(HatchGen_PointOnHatching& Point) void Geom2dHatch_Hatcher::ComputeDomains() { for (int IndH = 1; IndH <= myNbHatchings; IndH++) + { if (myHatchings.IsBound(IndH)) + { ComputeDomains(IndH); + } + } } //======================================================================= @@ -1117,10 +1153,14 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) Hatching.IsDone(false); if (!Hatching.TrimDone()) + { Trim(IndH); + } if (Hatching.Status() != HatchGen_NoProblem) + { return; + } bool Points = myKeepPoints; bool Segments = myKeepSegments; @@ -1184,9 +1224,13 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) if (SegmentEnd && SegmentBegin) { if (StateAfter == TopAbs_UNKNOWN) + { StateAfter = TopAbs_IN; + } if (StateBefore == TopAbs_UNKNOWN) + { StateBefore = TopAbs_IN; + } if (Segments) { @@ -1197,7 +1241,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) else if (SegmentEnd) { if (StateAfter == TopAbs_UNKNOWN) + { StateAfter = TopAbs_IN; + } if (Segments) { @@ -1208,7 +1254,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) else if (SegmentBegin) { if (StateBefore == TopAbs_UNKNOWN) + { StateBefore = TopAbs_IN; + } if (StateBefore == TopAbs_IN) { SavPnt = true; @@ -1234,20 +1282,28 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) if (SegmentEnd && SegmentBegin) { if (StateAfter == TopAbs_UNKNOWN) + { StateAfter = TopAbs_IN; + } if (StateBefore == TopAbs_UNKNOWN) + { StateBefore = TopAbs_IN; + } } else if (SegmentEnd) { if (StateAfter == TopAbs_UNKNOWN) + { StateAfter = TopAbs_IN; + } } else if (SegmentBegin) { if (StateBefore == TopAbs_UNKNOWN) + { StateBefore = TopAbs_IN; + } } else { @@ -1286,7 +1342,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1337,7 +1395,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1347,7 +1407,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) if (Points) { if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1395,7 +1457,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1423,7 +1487,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1451,9 +1517,13 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) if (NbPnt == 2) { if (FirstPoint) + { StateAfter = TopAbs_IN; + } else + { StateBefore = TopAbs_IN; + } } } //-- ??????????????????????????????????????????????????????????????????????????? @@ -1503,7 +1573,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1532,7 +1604,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1558,7 +1632,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } domain.SetSecondPoint(CurPnt); ToAppend = true; @@ -1601,7 +1677,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) //----------------------------------------------------------------------- if (ToAppend) + { Hatching.AddDomain(domain); + } //----------------------------------------------------------------------- // Traitement lie au dernier point. @@ -1631,7 +1709,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } ToAppend = true; } @@ -1655,7 +1735,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } ToAppend = true; } @@ -1679,7 +1761,9 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } ToAppend = true; } @@ -1703,14 +1787,18 @@ void Geom2dHatch_Hatcher::ComputeDomains(const int IndH) } if (ISav != 0) + { domain.SetFirstPoint(Hatching.Point(ISav)); + } ToAppend = true; } } if (ToAppend) + { Hatching.AddDomain(domain); + } } } @@ -1752,61 +1840,59 @@ const HatchGen_Domain& Geom2dHatch_Hatcher::Domain(const int IndH, const int IDo void Geom2dHatch_Hatcher::Dump() const { - std::cout << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << "=== Dump of the hatcher ================================" << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << std::endl; + std::cout << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << "=== Dump of the hatcher ================================" << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << '\n'; - std::cout << "The points are " << (myKeepPoints ? " " : "not ") << "considered." - << std::endl; - std::cout << "The segments are " << (myKeepSegments ? " " : "not ") << "considered." - << std::endl; - std::cout << "2D Confusion tolerance : " << myConfusion2d << std::endl; - std::cout << "3D Confusion tolerance : " << myConfusion3d << std::endl; + std::cout << "The points are " << (myKeepPoints ? " " : "not ") << "considered." << '\n'; + std::cout << "The segments are " << (myKeepSegments ? " " : "not ") << "considered." << '\n'; + std::cout << "2D Confusion tolerance : " << myConfusion2d << '\n'; + std::cout << "3D Confusion tolerance : " << myConfusion3d << '\n'; - std::cout << myNbHatchings << " hatching" << ((myNbHatchings == 1) ? "" : "s") << std::endl; - std::cout << myNbElements << " element" << ((myNbElements == 1) ? "" : "s") << std::endl; + std::cout << myNbHatchings << " hatching" << ((myNbHatchings == 1) ? "" : "s") << '\n'; + std::cout << myNbElements << " element" << ((myNbElements == 1) ? "" : "s") << '\n'; - std::cout << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << "=== Hatchings ==========================================" << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << std::endl; + std::cout << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << "=== Hatchings ==========================================" << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << '\n'; for (int IndH = 1; IndH <= myNbHatchings; IndH++) { std::cout << "Hatching # " << IndH; if (!myHatchings.IsBound(IndH)) { - std::cout << " is not bound" << std::endl; + std::cout << " is not bound" << '\n'; } else { const Geom2dHatch_Hatching& Hatching = myHatchings.Find(IndH); int NbPnt = Hatching.NbPoints(); - std::cout << " contains " << NbPnt << " restriction points :" << std::endl; + std::cout << " contains " << NbPnt << " restriction points :" << '\n'; for (int IPnt = 1; IPnt <= NbPnt; IPnt++) { const HatchGen_PointOnHatching& PntH = Hatching.Point(IPnt); PntH.Dump(IPnt); } - std::cout << "----------------------------------------------" << std::endl; + std::cout << "----------------------------------------------" << '\n'; } } - std::cout << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << "=== Elements ===========================================" << std::endl; - std::cout << "========================================================" << std::endl; - std::cout << std::endl; + std::cout << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << "=== Elements ===========================================" << '\n'; + std::cout << "========================================================" << '\n'; + std::cout << '\n'; for (int IndE = 1; IndE <= myNbElements; IndE++) { std::cout << "Element # " << IndE; if (!myElements.IsBound(IndE)) { - std::cout << " is not bound" << std::endl; + std::cout << " is not bound" << '\n'; } else { @@ -1814,20 +1900,20 @@ void Geom2dHatch_Hatcher::Dump() const switch (Element.Orientation()) { case TopAbs_FORWARD: - std::cout << " is FORWARD" << std::endl; + std::cout << " is FORWARD" << '\n'; break; case TopAbs_REVERSED: - std::cout << " is REVERSED" << std::endl; + std::cout << " is REVERSED" << '\n'; break; case TopAbs_INTERNAL: - std::cout << " is INTERNAL" << std::endl; + std::cout << " is INTERNAL" << '\n'; break; case TopAbs_EXTERNAL: - std::cout << " is EXTERNAL" << std::endl; + std::cout << " is EXTERNAL" << '\n'; break; } } } - std::cout << std::endl; + std::cout << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatching.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatching.cxx index 601fbc1107..39d61c8990 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatching.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Hatching.cxx @@ -94,7 +94,9 @@ void Geom2dHatch_Hatching::TrimFailed(const bool Flag) { myTrimFailed = Flag; if (myTrimFailed) + { myStatus = HatchGen_TrimFailure; + } } //======================================================================= @@ -156,7 +158,9 @@ void Geom2dHatch_Hatching::AddPoint(const HatchGen_PointOnHatching& Point, const { const HatchGen_PointOnHatching& PntH = myPoints.Value(IPntH); if (!PntH.IsLower(Point, Confusion)) + { break; + } } if (IPntH > NbPoints) { @@ -179,7 +183,9 @@ void Geom2dHatch_Hatching::AddPoint(const HatchGen_PointOnHatching& Point, const } } if (myIsDone) + { ClrDomains(); + } } //======================================================================= @@ -220,7 +226,9 @@ HatchGen_PointOnHatching& Geom2dHatch_Hatching::ChangePoint(const int Index) void Geom2dHatch_Hatching::RemPoint(const int Index) { if (myIsDone) + { ClrDomains(); + } myPoints.Remove(Index); } @@ -232,7 +240,9 @@ void Geom2dHatch_Hatching::RemPoint(const int Index) void Geom2dHatch_Hatching::ClrPoints() { if (myIsDone) + { ClrDomains(); + } for (int IPntH = 1; IPntH <= myPoints.Length(); IPntH++) { HatchGen_PointOnHatching& Point = myPoints.ChangeValue(IPntH); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Intersector.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Intersector.cxx index cfdfd58c80..1f78f06f2e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Intersector.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dHatch/Geom2dHatch_Intersector.cxx @@ -41,9 +41,13 @@ void Geom2dHatch_Intersector::Perform(const gp_Lin2d& L, // double pfbid,plbid; IntRes2d_Domain DL; if (P != RealLast()) + { DL.SetValues(L.Location(), 0., Tol, ElCLib::Value(P, L), P, Tol); + } else + { DL.SetValues(L.Location(), 0., Tol, true); + } IntRes2d_Domain DE(C.Value(C.FirstParameter()), C.FirstParameter(), @@ -87,7 +91,11 @@ void Geom2dHatch_Intersector::LocalGeometry(const Geom2dAdaptor_Curve& E, } if (C > Precision::PConfusion() && C < RealLast()) + { Prop.Normal(Norm); + } else + { Norm.SetCoord(Tang.Y(), -Tang.X()); + } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx index a1886eebaf..2263b636f2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx @@ -34,7 +34,9 @@ int Geom2dInt_Geom2dCurveTool::NbSamples(const Adaptor2d_Curve2d& C, { double t1 = U1 - U0; if (t1 < 0.0) + { t1 = -t1; + } nbs = C.NbKnots(); nbs *= C.Degree(); double anb = t1 / t * nbs; @@ -42,7 +44,9 @@ int Geom2dInt_Geom2dCurveTool::NbSamples(const Adaptor2d_Curve2d& C, int aMinPntNb = std::max(C.Degree() + 1, 4); if (nbs < aMinPntNb) + { nbs = aMinPntNb; + } } } else if (typC == GeomAbs_Circle) @@ -59,7 +63,9 @@ int Geom2dInt_Geom2dCurveTool::NbSamples(const Adaptor2d_Curve2d& C, } if (nbs > 300) + { nbs = 300; + } return nbs; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveCurve.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveCurve.cxx index 86b6a754b5..1a3741b7a5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveCurve.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveCurve.cxx @@ -137,9 +137,13 @@ void GeomAPI_ExtremaCurveCurve::Init(const occ::handle& C1, int GeomAPI_ExtremaCurveCurve::NbExtrema() const { if (myIsDone) + { return myExtCC.NbExt(); + } else + { return 0; + } } //================================================================================================= @@ -232,7 +236,9 @@ bool GeomAPI_ExtremaCurveCurve::TotalNearestPoints(gp_Pnt& P1, gp_Pnt& P2) } if (myIsInfinite) + { return false; + } P1 = myTotalPoints[0]; P2 = myTotalPoints[1]; @@ -250,7 +256,9 @@ bool GeomAPI_ExtremaCurveCurve::TotalLowerDistanceParameters(double& U1, double& } if (myIsInfinite) + { return false; + } U1 = myTotalPars[0]; U2 = myTotalPars[1]; @@ -310,7 +318,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalDist = sqrt(myExtCC.SquareDistance(myIndex)); if (myTotalDist <= Precision::Confusion()) + { return; + } } gp_Pnt P11, P12, P21, P22; @@ -327,7 +337,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = u21; if (myTotalDist <= Precision::Confusion()) + { return; + } } if (aTotalDist2 > d12) @@ -339,7 +351,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = u22; if (myTotalDist <= Precision::Confusion()) + { return; + } } if (aTotalDist2 > d21) @@ -351,7 +365,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = u21; if (myTotalDist <= Precision::Confusion()) + { return; + } } if (aTotalDist2 > d22) @@ -363,7 +379,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = u22; if (myTotalDist <= Precision::Confusion()) + { return; + } } // calculate distances between extremities one curve and other curve @@ -385,7 +403,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = proj.LowerDistanceParameter(); if (myTotalDist <= Precision::Confusion()) + { return; + } } } } @@ -407,7 +427,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = proj.LowerDistanceParameter(); if (myTotalDist <= Precision::Confusion()) + { return; + } } } } @@ -429,7 +451,9 @@ void GeomAPI_ExtremaCurveCurve::TotalPerform() myTotalPars[1] = u21; if (myTotalDist <= Precision::Confusion()) + { return; + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveSurface.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveSurface.cxx index ea4436f40c..3541dd7026 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveSurface.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaCurveSurface.cxx @@ -132,9 +132,13 @@ void GeomAPI_ExtremaCurveSurface::Init(const occ::handle& Curve, int GeomAPI_ExtremaCurveSurface::NbExtrema() const { if (myIsDone) + { return myExtCS.NbExt(); + } else + { return 0; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaSurfaceSurface.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaSurfaceSurface.cxx index 7b58502531..45f83b8d2f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaSurfaceSurface.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ExtremaSurfaceSurface.cxx @@ -148,9 +148,13 @@ void GeomAPI_ExtremaSurfaceSurface::Init(const occ::handle& S1, int GeomAPI_ExtremaSurfaceSurface::NbExtrema() const { if (myIsDone) + { return myExtSS.NbExt(); + } else + { return 0; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_Interpolate.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_Interpolate.cxx index 92b1a1f6ce..52ed89ec15 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_Interpolate.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_Interpolate.cxx @@ -471,6 +471,7 @@ void GeomAPI_Interpolate::PerformPeriodic() degree = 3; num_poles += 2; if (myTangentRequest) + { for (ii = myTangentFlags->Lower() + 1; ii <= myTangentFlags->Upper(); ii++) { if (myTangentFlags->Value(ii)) @@ -478,6 +479,7 @@ void GeomAPI_Interpolate::PerformPeriodic() num_poles += 1; } } + } NCollection_Array1 parameters(1, num_poles); NCollection_Array1 flatknots(1, num_poles + degree + 1); @@ -632,6 +634,7 @@ void GeomAPI_Interpolate::PerformNonPeriodic() degree = 3; num_poles += 2; if (myTangentRequest) + { for (ii = myTangentFlags->Lower() + 1; ii < myTangentFlags->Upper(); ii++) { if (myTangentFlags->Value(ii)) @@ -639,6 +642,7 @@ void GeomAPI_Interpolate::PerformNonPeriodic() num_poles += 1; } } + } } NCollection_Array1 parameters(1, num_poles); @@ -811,7 +815,9 @@ void GeomAPI_Interpolate::PerformNonPeriodic() const occ::handle& GeomAPI_Interpolate::Curve() const { if (!myIsDone) + { throw StdFail_NotDone(" "); + } return myCurve; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSpline.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSpline.cxx index 7eaab64a2d..60b529c08c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSpline.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSpline.cxx @@ -125,7 +125,9 @@ void GeomAPI_PointsToBSpline::Init(const NCollection_Array1& Points, int nbit = 2; bool UseSquares = false; if (Tol3D <= 1.e-3) + { UseSquares = true; + } AppDef_BSplineCompute TheComputer(DegMin, DegMax, Tol3D, Tol2D, nbit, true, ParType, UseSquares); @@ -173,7 +175,9 @@ void GeomAPI_PointsToBSpline::Init(const NCollection_Array1& Points, { myIsDone = false; if (Params.Length() != Points.Length()) + { throw Standard_OutOfRange("GeomAPI_PointsToBSpline::Init() - invalid input"); + } double Tol2D = 0.; // dummy argument for BSplineCompute. int Nbp = Params.Length(); @@ -184,7 +188,9 @@ void GeomAPI_PointsToBSpline::Init(const NCollection_Array1& Points, double Uf = Params(Params.Lower()); double Ul = Params(Params.Upper()) - Uf; if (!hasMeaningfulSpan(Ul)) + { return; + } for (int i = 2; i < Nbp; i++) { @@ -246,7 +252,9 @@ void GeomAPI_PointsToBSpline::Init(const NCollection_Array1& Points, int nbit = 2; if (Tol3D <= 1.e-3) + { nbit = 0; + } // Variational algo @@ -328,7 +336,9 @@ void GeomAPI_PointsToBSpline::Init(const NCollection_Array1& Points, const occ::handle& GeomAPI_PointsToBSpline::Curve() const { if (!myIsDone) + { throw StdFail_NotDone("GeomAPI_PointsToBSpline::Curve "); + } return myCurve; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSplineSurface.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSplineSurface.cxx index 64d91f703f..d1864577e8 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSplineSurface.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_PointsToBSplineSurface.cxx @@ -187,7 +187,9 @@ static void BuildPeriodicTangent(const AppDef_MultiLine& theLine, math_Vector P2(firstp, lastpt); for (i = firstp; i <= lastpt; i++) + { P2(i) = thePars(i); + } SQ2.Perform(P2); const AppParCurves_MultiCurve& C2 = SQ2.BezierValue(); @@ -348,7 +350,9 @@ void GeomAPI_PointsToBSplineSurface::Init(const NCollection_Array2& Poin int nbit = 2; bool UseSquares = false; if (Tol3D <= 1.e-3) + { UseSquares = true; + } AppDef_BSplineCompute TheComputer(DegMin, DegMax, Tol3D, Tol2D, nbit, true, ParType, UseSquares); @@ -495,7 +499,9 @@ void GeomAPI_PointsToBSplineSurface::Init(const NCollection_Array2& Poin int nbit = 2; if (Tol3D <= 1.e-3) + { nbit = 0; + } // first approximate the U isos: int NbPointJ = Jmax - Jmin + 1; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ProjectPointOnCurve.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ProjectPointOnCurve.cxx index 8846037d2c..2f339b7a9e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ProjectPointOnCurve.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomAPI/GeomAPI_ProjectPointOnCurve.cxx @@ -161,9 +161,13 @@ void GeomAPI_ProjectPointOnCurve::Perform(const gp_Pnt& aP3D) int GeomAPI_ProjectPointOnCurve::NbPoints() const { if (myIsDone) + { return myExtPC.NbExt(); + } else + { return 0; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill.cxx index 4436dcb21b..4e4c8e0048 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill.cxx @@ -237,7 +237,9 @@ void GeomFill::GetMinimalWeights(const Convert_ParameterisationType TConv, { if (TConv == Convert_Polynomial) + { Weights.Init(1); + } else { gp_Ax2 popAx2(gp_Pnt(0, 0, 0), gp_Dir(gp_Dir::D::Z)); @@ -382,9 +384,13 @@ void GeomFill::GetCircle(const Convert_ParameterisationType TConv, if (Sina < 0.) { if (Cosa > 0.) + { Angle = -Angle; + } else + { Angle = 2. * M_PI - Angle; + } } switch (TConv) @@ -483,9 +489,13 @@ bool GeomFill::GetCircle(const Convert_ParameterisationType TConv, if (Sina < 0.) { if (Cosa > 0.) + { Angle = -Angle; + } else + { Angle = 2. * M_PI - Angle; + } } if (std::abs(Sina) > std::abs(Cosa)) @@ -648,9 +658,13 @@ bool GeomFill::GetCircle(const Convert_ParameterisationType TConv, if (Sina < 0.) { if (Cosa > 0.) + { Angle = -Angle; + } else + { Angle = 2. * M_PI - Angle; + } } if (std::abs(Sina) > std::abs(Cosa)) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BSplineCurves.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BSplineCurves.cxx index dfc461ae38..fe325dabf5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BSplineCurves.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BSplineCurves.cxx @@ -294,13 +294,21 @@ void GeomFill_BSplineCurves::Init(const occ::handle& C1, int DegU = std::max(Deg1, Deg3); int DegV = std::max(Deg2, Deg4); if (Deg1 < DegU) + { CC1->IncreaseDegree(DegU); + } if (Deg2 < DegV) + { CC2->IncreaseDegree(DegV); + } if (Deg3 < DegU) + { CC3->IncreaseDegree(DegU); + } if (Deg4 < DegV) + { CC4->IncreaseDegree(DegV); + } // Mise en conformite des distributions de noeuds int NbUPoles = SetSameDistribution(CC1, CC3); @@ -309,7 +317,9 @@ void GeomFill_BSplineCurves::Init(const occ::handle& C1, if (Type == GeomFill_CoonsStyle) { if (NbUPoles < 4 || NbVPoles < 4) + { throw Standard_ConstructionError("GeomFill_BSplineCurves: invalid filling style"); + } } const NCollection_Array1& P1 = CC1->Poles(); @@ -405,15 +415,23 @@ void GeomFill_BSplineCurves::Init(const occ::handle& C1, Tol = Tol * Tol; if (C1->StartPoint().SquareDistance(C2->StartPoint()) > Tol && C1->StartPoint().SquareDistance(C2->EndPoint()) > Tol) + { Poles(1) = C1->StartPoint(); + } else + { Poles(1) = C1->EndPoint(); + } if (C3->StartPoint().SquareDistance(C2->StartPoint()) > Tol && C3->StartPoint().SquareDistance(C2->EndPoint()) > Tol) + { Poles(2) = C3->StartPoint(); + } else + { Poles(2) = C3->EndPoint(); + } Knots(1) = C2->Knot(C2->FirstUKnotIndex()); Knots(2) = C2->Knot(C2->LastUKnotIndex()); @@ -441,9 +459,13 @@ void GeomFill_BSplineCurves::Init(const occ::handle& C1, int DegU = std::max(Deg1, Deg2); if (CC1->Degree() < DegU) + { CC1->IncreaseDegree(DegU); + } if (CC2->Degree() < DegU) + { CC2->IncreaseDegree(DegU); + } // Mise en conformite des distributions de noeuds int NbPoles = SetSameDistribution(CC1, CC2); @@ -519,7 +541,9 @@ void GeomFill_BSplineCurves::Init(const occ::handle& C1, } if (!IsOK) + { throw Standard_OutOfRange("GeomFill_BSplineCurves: Courbes non jointives"); + } int NbUPoles = CC1->NbPoles(); int NbVPoles = CC2->NbPoles(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BezierCurves.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BezierCurves.cxx index 6cabf850c0..203db13a6d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BezierCurves.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BezierCurves.cxx @@ -142,7 +142,9 @@ static bool Arrange(const occ::handle& C1, } } if (!Trouve) + { return false; + } } CC1 = GC[0]; @@ -217,13 +219,21 @@ void GeomFill_BezierCurves::Init(const occ::handle& C1, } if (CC1->Degree() < DegU) + { CC1->Increase(DegU); + } if (CC2->Degree() < DegV) + { CC2->Increase(DegV); + } if (CC3->Degree() < DegU) + { CC3->Increase(DegU); + } if (CC4->Degree() < DegV) + { CC4->Increase(DegV); + } const NCollection_Array1& P1 = CC1->Poles(); const NCollection_Array1& P2 = CC2->Poles(); @@ -302,15 +312,23 @@ void GeomFill_BezierCurves::Init(const occ::handle& C1, Tol = Tol * Tol; if (C1->StartPoint().SquareDistance(C2->StartPoint()) > Tol && C1->StartPoint().SquareDistance(C2->EndPoint()) > Tol) + { Poles(1) = C1->StartPoint(); + } else + { Poles(1) = C1->EndPoint(); + } if (C3->StartPoint().SquareDistance(C2->StartPoint()) > Tol && C3->StartPoint().SquareDistance(C2->EndPoint()) > Tol) + { Poles(2) = C3->StartPoint(); + } else + { Poles(2) = C3->EndPoint(); + } // Poles(1) = C1->StartPoint(); // Poles(2) = C1->StartPoint(); C4 = new Geom_BezierCurve(Poles); @@ -336,9 +354,13 @@ void GeomFill_BezierCurves::Init(const occ::handle& C1, int DegU = std::max(Deg1, Deg2); if (CC1->Degree() < DegU) + { CC1->Increase(DegU); + } if (CC2->Degree() < DegU) + { CC2->Increase(DegU); + } NCollection_Array2 Poles(1, DegU + 1, 1, 2); const NCollection_Array1& P1 = CC1->Poles(); @@ -393,7 +415,9 @@ void GeomFill_BezierCurves::Init(const occ::handle& C1, } if (!IsOK) + { throw Standard_OutOfRange("GeomFill_BezierCurves: Courbes non jointives"); + } const NCollection_Array1& P1 = CC1->Poles(); const NCollection_Array1& P2 = CC2->Poles(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BoundWithSurf.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BoundWithSurf.cxx index 8bfe0accfc..887bc15703 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BoundWithSurf.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_BoundWithSurf.cxx @@ -46,7 +46,9 @@ gp_Pnt GeomFill_BoundWithSurf::Value(const double U) const { double x = U; if (!myPar.IsNull()) + { x = myPar->Value(U); + } return myConS.Value(x); } @@ -56,7 +58,9 @@ void GeomFill_BoundWithSurf::D1(const double U, gp_Pnt& P, gp_Vec& V) const { double x = U, dx = 1.; if (!myPar.IsNull()) + { myPar->D1(U, x, dx); + } myConS.D1(x, P, V); V.Multiply(dx); } @@ -74,14 +78,18 @@ gp_Vec GeomFill_BoundWithSurf::Norm(const double U) const { // voir s il ne faudrait pas utiliser LProp ou autre. if (!HasNormals()) + { throw Standard_Failure("BoundWithSurf Norm : pas de contrainte"); + } // occ::handle& S = myConS.GetSurface(); // occ::handle& C2d = myConS.GetCurve(); double x, y; double w = U; if (!myPar.IsNull()) + { w = myPar->Value(U); + } myConS.GetCurve()->Value(w).Coord(x, y); gp_Pnt P; gp_Vec Su, Sv; @@ -96,7 +104,9 @@ gp_Vec GeomFill_BoundWithSurf::Norm(const double U) const void GeomFill_BoundWithSurf::D1Norm(const double U, gp_Vec& N, gp_Vec& DN) const { if (!HasNormals()) + { throw Standard_Failure("BoundWithSurf Norm : pas de contrainte"); + } // occ::handle& S = myConS.GetSurface(); // occ::handle& C2d = myConS.GetCurve(); gp_Pnt2d P2d; @@ -104,7 +114,9 @@ void GeomFill_BoundWithSurf::D1Norm(const double U, gp_Vec& N, gp_Vec& DN) const double x, y, dx, dy; double w = U, dw = 1.; if (!myPar.IsNull()) + { myPar->D1(U, w, dw); + } myConS.GetCurve()->D1(w, P2d, V2d); P2d.Coord(x, y); V2d.Multiply(dw); @@ -165,7 +177,9 @@ void GeomFill_BoundWithSurf::Reparametrize(const double First, void GeomFill_BoundWithSurf::Bounds(double& First, double& Last) const { if (!myPar.IsNull()) + { myPar->Bounds(First, Last); + } else { First = myConS.FirstParameter(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CircularBlendFunc.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CircularBlendFunc.cxx index 8e6afb91e8..f1e8badc97 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CircularBlendFunc.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CircularBlendFunc.cxx @@ -125,11 +125,17 @@ GeomFill_CircularBlendFunc::GeomFill_CircularBlendFunc(const occ::handle 0.65 * M_PI) + { myTConv = Convert_QuasiAngular; // car c'est Continue + } else + { myTConv = Convert_TgtThetaOver2; + } // car c'est le plus performant // On en deduit la structure @@ -200,9 +206,13 @@ void GeomFill_CircularBlendFunc::Discret() } Angle = std::abs(std::acos(Cosa)); if (Angle > maxang) + { maxang = Angle; + } if (Angle < minang) + { minang = Angle; + } distmin = std::min(distmin, P1.Distance(P2)); myBary.ChangeCoord() += (P1.XYZ() + P2.XYZ()); } @@ -223,13 +233,19 @@ void GeomFill_CircularBlendFunc::Discret() ns2.Normalize(); Cosa = ns1.Dot(ns2); if (Cosa > 1.) + { Cosa = 1.; + } Angle = std::abs(std::acos(Cosa)); if (Angle > maxang) + { maxang = Angle; + } if (Angle < minang) + { minang = Angle; + } distmin = std::min(distmin, P1.Distance(P2)); myBary.ChangeCoord() += (P1.XYZ() + P2.XYZ()); } @@ -267,12 +283,16 @@ bool GeomFill_CircularBlendFunc::D0(const double Param, ns1.SetXYZ(Center.XYZ() - P1.XYZ()); ns2.SetXYZ(Center.XYZ() - P2.XYZ()); if (!ns1.IsParallel(ns2, TolAng)) + { nplan = ns1.Crossed(ns2); + } else { myTPath->D1(Param, Center, nplan); if (myreverse) + { nplan.Reverse(); + } } // Normalisation @@ -568,7 +588,9 @@ int GeomFill_CircularBlendFunc::NbIntervals(const GeomAbs_Shape S) const NCollection_Array1 ICbs(1, Inter.Length()); for (ii = 1; ii <= ICbs.Length(); ii++) + { ICbs(ii) = Inter(ii); + } Inter.Clear(); GeomFillFusInt(ICenter, ICbs, Inter); @@ -597,14 +619,18 @@ void GeomFill_CircularBlendFunc::Intervals(NCollection_Array1& T, NCollection_Array1 ICbs(1, Inter.Length()); for (ii = 1; ii <= ICbs.Length(); ii++) + { ICbs(ii) = Inter(ii); + } Inter.Clear(); GeomFillFusInt(ICenter, ICbs, Inter); // Recopie du resultat for (ii = 1; ii <= Inter.Length(); ii++) + { T(ii) = Inter(ii); + } } void GeomFill_CircularBlendFunc::SetInterval(const double First, const double Last) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstantBiNormal.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstantBiNormal.cxx index 9844b67930..5cc8f214d7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstantBiNormal.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstantBiNormal.cxx @@ -63,7 +63,9 @@ occ::handle GeomFill_ConstantBiNormal::Copy() const { occ::handle copy = new GeomFill_ConstantBiNormal(gp_Dir(BN)); if (!myCurve.IsNull()) + { copy->SetCurve(myCurve); + } return copy; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstrainedFilling.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstrainedFilling.cxx index 6a5df3aab6..fe70c81b7c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstrainedFilling.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_ConstrainedFilling.cxx @@ -116,9 +116,13 @@ static void sortbounds(const int nb, for (i = 0; i < nb - 1; i++) { if (!rev[i]) + { bound[i]->Points(pf, pl); + } else + { bound[i]->Points(pl, pf); + } for (j = i + 1; j <= nb - 1; j++) { bound[j]->Points(qf, ql); @@ -151,9 +155,13 @@ static void sortbounds(const int nb, } } if (!rev[nb - 1]) + { bound[nb - 1]->Points(pf, pl); + } else + { bound[nb - 1]->Points(pl, pf); + } bound[0]->Points(qf, ql); stat[0].Gap(pl.Distance(qf)); @@ -166,19 +174,31 @@ static void sortbounds(const int nb, { int next = (i + 1) % nb; if (!rev[i]) + { bound[i]->Bounds(fi, li); + } else + { bound[i]->Bounds(li, fi); + } bound[i]->D1(li, pbid, tgi); if (rev[i]) + { tgi.Reverse(); + } if (!rev[next]) + { bound[next]->Bounds(fn, ln); + } else + { bound[next]->Bounds(ln, fn); + } bound[next]->D1(fn, pbid, tgn); if (rev[next]) + { tgn.Reverse(); + } double ang = M_PI - tgi.Angle(tgn); stat[next].TgtAng(ang); if (bound[i]->HasNormals() && bound[next]->HasNormals()) @@ -217,7 +237,9 @@ static void coonscnd(const int nb, an = M_PI - an; } if (an > tolang) + { stat[i].DoKill(0.); + } else { double fact = 0.5 * 27. / 4; @@ -226,21 +248,31 @@ static void coonscnd(const int nb, gp_Pnt pbid; double fp, lp, fi, li; if (!rev[ip]) + { bound[ip]->Bounds(fp, lp); + } else + { bound[ip]->Bounds(lp, fp); + } bound[ip]->D1(lp, pbid, tgp); bound[ip]->D1Norm(lp, vbid, dnorp); if (!rev[i]) + { bound[i]->Bounds(fi, li); + } else + { bound[i]->Bounds(li, fi); + } bound[i]->D1(fi, pbid, tgi); bound[i]->D1Norm(fi, vbid, dnori); double scal1 = tgp.Dot(dnori); double scal2 = tgi.Dot(dnorp); if (!twist) + { scal2 *= -1.; + } scal1 = std::abs(scal1 + scal2); if (scal1 > tolang) { @@ -398,17 +430,25 @@ void GeomFill_ConstrainedFilling::Init(const occ::handle& B1, occ::handle ttgalg[3]; if (bound[0]->HasNormals()) + { ttgalg[0] = tgalg[0] = new GeomFill_TgtOnCoons(ptch, 0); + } if (bound[1]->HasNormals()) + { ttgalg[1] = tgalg[1] = new GeomFill_TgtOnCoons(ptch, 1); + } if (bound[2]->HasNormals()) + { ttgalg[2] = tgalg[3] = new GeomFill_TgtOnCoons(ptch, 3); + } for (i = 0; i <= 3; i++) { mig[i] = 1.; if (!tgalg[i].IsNull()) + { MinTgte(i); + } } if (!NoCheck) @@ -492,7 +532,9 @@ void GeomFill_ConstrainedFilling::Init(const occ::handle& B1, for (i = 0; i <= 3; i++) { if (bound[i]->HasNormals()) + { tgalg[i] = new GeomFill_TgtOnCoons(ptch, i); + } } // on calcule le min de chacun des champs tangents pour l evaluation // des tolerances. @@ -500,7 +542,9 @@ void GeomFill_ConstrainedFilling::Init(const occ::handle& B1, { mig[i] = 1.; if (!tgalg[i].IsNull()) + { MinTgte(i); + } } if (!NoCheck) @@ -540,13 +584,21 @@ void GeomFill_ConstrainedFilling::SetDomain(const double const occ::handle& B) { if (B == ptch->Bound(0)) + { dom[0] = std::min(1., std::abs(l)); + } else if (B == ptch->Bound(1)) + { dom[1] = std::min(1., std::abs(l)); + } else if (B == ptch->Bound(2)) + { dom[2] = std::min(1., std::abs(l)); + } else if (B == ptch->Bound(3)) + { dom[3] = std::min(1., std::abs(l)); + } } //================================================================================================= @@ -554,7 +606,9 @@ void GeomFill_ConstrainedFilling::SetDomain(const double void GeomFill_ConstrainedFilling::ReBuild() { if (!appdone) + { throw Standard_Failure("GeomFill_ConstrainedFilling::ReBuild Approx non faite"); + } MatchKnots(); PerformS0(); PerformS1(); @@ -601,7 +655,9 @@ void GeomFill_ConstrainedFilling::Build() appclock.Start(); #endif if (nbd3) + { PerformApprox(); + } #ifdef OCCT_DEBUG appclock.Stop(); #endif @@ -640,7 +696,9 @@ void GeomFill_ConstrainedFilling::PerformApprox() int ii; occ::handle> tol3d, tol2d, tol1d; if (nbd3) + { tol3d = new NCollection_HArray1(1, nbd3); + } int i3d = 0; for (ii = 0; ii <= 1; ii++) { @@ -1030,7 +1088,9 @@ void GeomFill_ConstrainedFilling::PerformS1() for (i = 0; i <= 3; i++) { if (ntpol[i].IsNull()) + { nt[i] = nullptr; + } else { double z = 0; @@ -1179,26 +1239,42 @@ void GeomFill_ConstrainedFilling::PerformS1() { double pq1 = 0, pq3 = 0; if (nt[1]) + { pq1 = -pq[1]->Value(i); + } if (nt[3]) + { pq3 = pq[3]->Value(i); + } gp_XYZ t0, t2; if (nt[0]) + { t0 = nt[0][i - 1]; + } if (nt[2]) + { t2 = nt[2][i - 1]; + } for (j = 1; j <= nj; j++) { double pq0 = 0, pq2 = 0; if (nt[0]) + { pq0 = pq[0]->Value(j); + } if (nt[2]) + { pq2 = -pq[2]->Value(j); + } gp_XYZ t1, t3; if (nt[1]) + { t1 = nt[1][j - 1]; + } if (nt[3]) + { t3 = nt[3][j - 1]; + } gp_XYZ tpolij(0., 0., 0.), temp; if (nt[0]) @@ -1282,7 +1358,9 @@ bool GeomFill_ConstrainedFilling::CheckTgte(const int I) { occ::handle bou = ptch->Bound(I); if (!bou->HasNormals()) + { return true; + } // On prend 13 points le long du bord et on verifie que le triedre // forme par la tangente a la courbe la normale et la tangente du // peigne ne change pas d orientation. @@ -1296,12 +1374,16 @@ bool GeomFill_ConstrainedFilling::CheckTgte(const int I) gp_Vec norm = bou->Norm(uu); gp_Vec vfield = tgalg[I]->Value(uu); if (iu == 0) + { pmix = vfield.Dot(tgte.Crossed(norm)); + } else { double pmixcur = vfield.Dot(tgte.Crossed(norm)); if (pmix * pmixcur < 0.) + { return false; + } } } return true; @@ -1312,7 +1394,9 @@ bool GeomFill_ConstrainedFilling::CheckTgte(const int I) void GeomFill_ConstrainedFilling::MinTgte(const int I) { if (!ptch->Bound(I)->HasNormals()) + { return; + } double minmag = RealLast(); double ll = 0.02; for (int iu = 0; iu <= 30; iu++) @@ -1321,7 +1405,9 @@ void GeomFill_ConstrainedFilling::MinTgte(const int I) gp_Vec vv = tgalg[I]->Value(uu); double temp = vv.SquareMagnitude(); if (temp < minmag) + { minmag = temp; + } } mig[I] = sqrt(minmag); } @@ -1422,9 +1508,13 @@ void GeomFill_ConstrainedFilling::CheckCoonsAlgPatch(const int I) { pbound = bou->Value(ww); if (enu) + { vptch = ptch->D1U(uu, vv); + } else + { vptch = ptch->D1V(uu, vv); + } uu += duu; vv += dvv; ww += dww; @@ -1436,7 +1526,9 @@ void GeomFill_ConstrainedFilling::CheckCoonsAlgPatch(const int I) void GeomFill_ConstrainedFilling::CheckTgteField(const int I) { if (tgalg[I].IsNull()) + { return; + } gp_Pnt p1; gp_Vec d1; bool caplisse = false; @@ -1451,23 +1543,31 @@ void GeomFill_ConstrainedFilling::CheckTgteField(const int I) gp_Vec vcros = d1.Crossed(vnor); vcros.Normalize(); if (iu == 0) + { pmix = vtg.Dot(vcros); + } else { pmixcur = vtg.Dot(vcros); if (pmix * pmixcur < 0.) + { caplisse = true; + } } if (vnor.Magnitude() > 1.e-15 && vtg.Magnitude() > 1.e-15) { double alpha = std::abs(M_PI / 2. - std::abs(vnor.Angle(vtg))); if (std::abs(alpha) > maxang) + { maxang = std::abs(alpha); + } } } - std::cout << "KAlgo angle max sur bord " << I << " : " << maxang << std::endl; + std::cout << "KAlgo angle max sur bord " << I << " : " << maxang << '\n'; if (caplisse) - std::cout << "sur bord " << I << " le champ tangent change de cote!" << std::endl; + { + std::cout << "sur bord " << I << " le champ tangent change de cote!" << '\n'; + } } //================================================================================================= @@ -1511,18 +1611,22 @@ void GeomFill_ConstrainedFilling::CheckApprox(const int I) { double alpha = std::abs(M_PI / 2. - std::abs(vbound.Angle(vapp))); if (std::abs(alpha) > maxang) + { maxang = std::abs(alpha); + } } } if (papp.Distance(pbound) > maxdist) + { maxdist = papp.Distance(pbound); + } } - std::cout << "Controle approx/contrainte sur bord " << I << " : " << std::endl; - std::cout << "Distance max : " << maxdist << std::endl; + std::cout << "Controle approx/contrainte sur bord " << I << " : " << '\n'; + std::cout << "Distance max : " << maxdist << '\n'; if (donor) { maxang = maxang * 180. / M_PI; - std::cout << "Angle max : " << maxang << " deg" << std::endl; + std::cout << "Angle max : " << maxang << " deg" << '\n'; } } @@ -1569,7 +1673,9 @@ void GeomFill_ConstrainedFilling::CheckResult(const int I) { pbound[k] = bou->Value(ww); if (!donor) + { surf->D0(uu, vv, pres[k]); + } else { vbound[k] = bou->Norm(ww); @@ -1581,20 +1687,24 @@ void GeomFill_ConstrainedFilling::CheckResult(const int I) double alpha = std::abs(vres[k].Angle(vbound[k])); alpha = std::min(alpha, std::abs(M_PI - alpha)); if (alpha > maxang) + { maxang = alpha; + } } } if (pres[k].Distance(pbound[k]) > maxdist) + { maxdist = pres[k].Distance(pbound[k]); + } uu += duu; vv += dvv; ww += dww; } - std::cout << "Controle resultat/contrainte sur bord " << I << " : " << std::endl; - std::cout << "Distance max : " << maxdist << std::endl; + std::cout << "Controle resultat/contrainte sur bord " << I << " : " << '\n'; + std::cout << "Distance max : " << maxdist << '\n'; if (donor) { double angdeg = maxang * 180. / M_PI; - std::cout << "Angle max : " << angdeg << " deg" << std::endl; + std::cout << "Angle max : " << angdeg << " deg" << '\n'; } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CornerState.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CornerState.cxx index 1e37f80371..77306485a2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CornerState.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CornerState.cxx @@ -90,7 +90,9 @@ bool GeomFill_CornerState::IsToKill(double& Scal) const { Scal = scal; if (!isconstrained) + { return false; + } return !coonscnd; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CorrectedFrenet.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CorrectedFrenet.cxx index 004a5c201d..c7440c58a9 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CorrectedFrenet.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CorrectedFrenet.cxx @@ -65,9 +65,13 @@ static double ComputeTorsion(const double Param, const occ::handle& Law, { // Une premiere passe tolerance serres B = BS->RemoveKnot(ii, 0, tol); if (B) + { Ok = true; + } } if (Ok) @@ -104,11 +110,15 @@ static void smoothlaw(occ::handle& Law, { d = std::abs(BS->Value(Param->Value(ii)) - Points->Value(ii)); if (d > tol) + { tol = d; + } Ok = (tol <= Tol); } if (Ok) + { tol = (Tol - tol) / 2; + } else { #ifdef OCCT_DEBUG @@ -123,7 +133,9 @@ static void smoothlaw(occ::handle& Law, } if (Ok) + { Law = BS; + } Ok = false; // Une deuxieme passe tolerance desserre Nbk = BS->NbKnots(); @@ -131,7 +143,9 @@ static void smoothlaw(occ::handle& Law, { B = BS->RemoveKnot(ii, 0, tol); if (B) + { Ok = true; + } } if (Ok) @@ -141,7 +155,9 @@ static void smoothlaw(occ::handle& Law, { d = std::abs(BS->Value(Param->Value(ii)) - Points->Value(ii)); if (d > tol) + { tol = d; + } Ok = (tol <= Tol); } if (!Ok) @@ -152,7 +168,9 @@ static void smoothlaw(occ::handle& Law, } } if (Ok) + { Law = BS; + } #ifdef OCCT_DEBUG if (Affich) @@ -201,7 +219,9 @@ static bool FindPlane(const occ::handle& theC, occ::handle GC = theC->Bezier(); int nbp = GC->NbPoles(); if (nbp < 2) + { found = false; + } else if (nbp == 2) { found = false; @@ -217,7 +237,9 @@ static bool FindPlane(const occ::handle& theC, occ::handle GC = theC->BSpline(); int nbp = GC->NbPoles(); if (nbp < 2) + { found = false; + } else if (nbp == 2) { found = false; @@ -301,7 +323,9 @@ occ::handle GeomFill_CorrectedFrenet::Copy() const { occ::handle copy = new (GeomFill_CorrectedFrenet)(); if (!myCurve.IsNull()) + { copy->SetCurve(myCurve); + } return copy; } @@ -375,12 +399,16 @@ void GeomFill_CorrectedFrenet::Init() SeqNormal)) { if (isFrenet) + { isFrenet = false; + } } occ::down_cast(EvolAroundT)->ChangeLaws().Append(Func); } if (myTrimmed->IsPeriodic()) + { occ::down_cast(EvolAroundT)->SetPeriodic(); + } TLaw = EvolAroundT; // OCC78 @@ -479,16 +507,24 @@ bool GeomFill_CorrectedFrenet::InitInterval(const double First, angleAT = CalcAngleAT(Tangent, Normal, prevTangent, prevNormal); if (isConst && i > 1) + { if (std::abs(angleAT) > Precision::PConfusion()) + { isConst = false; + } + } angleAT += (i > 1) ? EvolAT(i - 1) : startAng; EvolAT.Append(angleAT); prevNormal = Normal; if (isZero) + { if (std::abs(angleAT) > Precision::PConfusion()) + { isZero = false; + } + } aT += Tangent; cross = Tangent.Crossed(Normal); @@ -580,11 +616,17 @@ double GeomFill_CorrectedFrenet::CalcAngleAT(const gp_Vec& Tangent, + (1 - cos(angle)) * cross.Crossed(cross.Crossed(Normal)); } else + { Normal_rot = Normal; + } double angleAT = Normal_rot.Angle(prevNormal); if (angleAT > Precision::Angular() && M_PI - angleAT > Precision::Angular()) + { if (Normal_rot.Crossed(prevNormal).IsOpposite(prevTangent, Precision::Angular())) + { angleAT = -angleAT; + } + } return angleAT; } @@ -613,21 +655,31 @@ double GeomFill_CorrectedFrenet::GetAngleAT(const double Param) const // Search index of low margin from poles of TLaw by bisection method int iB = 1, iE = HArrPoles->Length(), iC = (iE + iB) / 2; if (Param == HArrPoles->Value(iB)) + { return TLaw->Value(Param); + } if (Param > HArrPoles->Value(iE)) + { iC = iE; + } if (iC < iE) { while (HArrPoles->Value(iC) > Param || Param > HArrPoles->Value(iC + 1)) { if (HArrPoles->Value(iC) < Param) + { iB = iC; + } else + { iE = iC; + } iC = (iE + iB) / 2; }; if (HArrPoles->Value(iC) == Param || Param == HArrPoles->Value(iC + 1)) + { return TLaw->Value(Param); + } }; // Calculate differentiation between approximated and local values of AngleAT double AngP = TLaw->Value(Param), AngPo = HArrAngle->Value(iC), dAng = AngP - AngPo; @@ -652,7 +704,9 @@ bool GeomFill_CorrectedFrenet::D0(const double Param, { frenet->D0(Param, Tangent, Normal, BiNormal); if (isFrenet) + { return true; + } double angleAT; // angleAT = TLaw->Value(Param); @@ -683,7 +737,9 @@ bool GeomFill_CorrectedFrenet::D1(const double Param, { frenet->D1(Param, Tangent, DTangent, Normal, DNormal, BiNormal, DBiNormal); if (isFrenet) + { return true; + } double angleAT, d_angleAT; double sina, cosa; @@ -750,7 +806,9 @@ bool GeomFill_CorrectedFrenet::D2(const double Param, DBiNormal, D2BiNormal); if (isFrenet) + { return true; + } double angleAT, d_angleAT, d2_angleAT; double sina, cosa; @@ -848,11 +906,15 @@ int GeomFill_CorrectedFrenet::NbIntervals(const GeomAbs_Shape S) const int NbFrenet, NbLaw; NbFrenet = frenet->NbIntervals(S); if (isFrenet) + { return NbFrenet; + } NbLaw = EvolAroundT->NbIntervals(S); if (NbFrenet == 1) + { return NbLaw; + } NCollection_Array1 FrenetInt(1, NbFrenet + 1); NCollection_Array1 LawInt(1, NbLaw + 1); @@ -893,7 +955,9 @@ void GeomFill_CorrectedFrenet::Intervals(NCollection_Array1& T, const Ge GeomLib::FuseIntervals(FrenetInt, LawInt, Fusion, Precision::PConfusion(), true); for (int i = 1; i <= Fusion.Length(); i++) + { T.ChangeValue(i) = Fusion.Value(i); + } } //================================================================================================= @@ -903,7 +967,9 @@ void GeomFill_CorrectedFrenet::SetInterval(const double First, const double Last GeomFill_TrihedronLaw::SetInterval(First, Last); frenet->SetInterval(First, Last); if (!isFrenet) + { TLaw = EvolAroundT->Trim(First, Last, Precision::PConfusion() / 2); + } } //================================================================================================= @@ -911,7 +977,9 @@ void GeomFill_CorrectedFrenet::SetInterval(const double First, const double Last GeomFill_Trihedron GeomFill_CorrectedFrenet::EvaluateBestMode() { if (EvolAroundT.IsNull()) + { return GeomFill_IsFrenet; // Frenet + } const double MaxAngle = 3. * M_PI / 4.; const double MaxTorsion = 100.; @@ -931,7 +999,9 @@ GeomFill_Trihedron GeomFill_CorrectedFrenet::EvaluateBestMode() tmax = Int(i + 1); double Torsion = ComputeTorsion(tmin, myTrimmed); if (std::abs(Torsion) > MaxTorsion) + { return GeomFill_IsDiscreteTrihedron; // DiscreteTrihedron + } occ::handle trimmedlaw = EvolAroundT->Trim(tmin, tmax, Precision::PConfusion() / 2); @@ -948,7 +1018,9 @@ GeomFill_Trihedron GeomFill_CorrectedFrenet::EvaluateBestMode() { double theAngle = PrevVec.Angle(aVec); if (std::abs(theAngle) > MaxAngle) + { return GeomFill_IsDiscreteTrihedron; // DiscreteTrihedron + } } PrevVec = aVec; } @@ -965,7 +1037,9 @@ GeomFill_Trihedron GeomFill_CorrectedFrenet::EvaluateBestMode() void GeomFill_CorrectedFrenet::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, gp_Vec& ABiNormal) { if (isFrenet) + { frenet->GetAverageLaw(ATangent, ANormal, ABiNormal); + } else { ATangent = AT; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CurveAndTrihedron.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CurveAndTrihedron.cxx index 1db9101bfa..ab2dafd3b1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CurveAndTrihedron.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_CurveAndTrihedron.cxx @@ -77,9 +77,15 @@ void GeomFill_CurveAndTrihedron::SetTrsf(const gp_Mat& Transfo) Aux -= Trans; WithTrans = false; // Au cas ou Trans = I for (int ii = 1; ii <= 3 && !WithTrans; ii++) + { for (int jj = 1; jj <= 3 && !WithTrans; jj++) + { if (std::abs(Aux.Value(ii, jj)) > 1.e-14) + { WithTrans = true; + } + } + } } //================================================================================================= @@ -239,7 +245,9 @@ void GeomFill_CurveAndTrihedron::Intervals(NCollection_Array1& T, GeomLib::FuseIntervals(IntC, IntL, Inter, Precision::PConfusion() * 0.99); for (int ii = 1; ii <= Inter.Length(); ii++) + { T(ii) = Inter(ii); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Darboux.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Darboux.cxx index aec68fd427..e1312d7bf3 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Darboux.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Darboux.cxx @@ -102,16 +102,20 @@ static void NormalD0(const double U, } for (i = 0; i <= MaxOrder + 1; i++) + { for (j = 1; j <= MaxOrder + 1; j++) { DerSurf.SetValue(i, j, Surf->DN(U, V, i, j)); } + } for (i = 0; i <= MaxOrder; i++) + { for (j = 0; j <= MaxOrder; j++) { DerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurf)); } + } CSLib::Normal(MaxOrder, DerNUV, @@ -171,9 +175,13 @@ static void NormalD1(const double U, CSLib::Normal(D1UNormal, D1VNormal, MagTol, NStatus, Normal); int MaxOrder; if (NStatus == CSLib_Defined) + { MaxOrder = 0; + } else + { MaxOrder = 3; + } int OrderU, OrderV; NCollection_Array2 DerNUV(0, MaxOrder + 1, 0, MaxOrder + 1); NCollection_Array2 DerSurf(0, MaxOrder + 2, 0, MaxOrder + 2); @@ -190,19 +198,27 @@ static void NormalD1(const double U, DerSurf.SetValue(2, 0, d2u); DerSurf.SetValue(0, 2, d2v); for (i = 0; i <= MaxOrder + 1; i++) + { for (j = i; j <= MaxOrder + 2; j++) + { if (i + j > 2) { DerSurf.SetValue(i, j, Surf->DN(U, V, i, j)); if (i != j) + { DerSurf.SetValue(j, i, Surf->DN(U, V, j, i)); + } } + } + } for (i = 0; i <= MaxOrder + 1; i++) + { for (j = 0; j <= MaxOrder + 1; j++) { DerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurf)); } + } CSLib::Normal(MaxOrder, DerNUV, @@ -218,7 +234,9 @@ static void NormalD1(const double U, OrderU, OrderV); if (NStatus != CSLib_Defined) + { throw Geom_UndefinedValue(); + } D1UNormal = CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV); D1VNormal = CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV); @@ -255,9 +273,13 @@ static void NormalD2(const double U, CSLib::Normal(D1UNormal, D1VNormal, MagTol, NStatus, Normal); int MaxOrder; if (NStatus == CSLib_Defined) + { MaxOrder = 0; + } else + { MaxOrder = 3; + } int OrderU, OrderV; NCollection_Array2 DerNUV(0, MaxOrder + 2, 0, MaxOrder + 2); NCollection_Array2 DerSurf(0, MaxOrder + 3, 0, MaxOrder + 3); @@ -279,19 +301,27 @@ static void NormalD2(const double U, DerSurf.SetValue(1, 2, d3uvv); DerSurf.SetValue(0, 3, d3v); for (i = 0; i <= MaxOrder + 2; i++) + { for (j = i; j <= MaxOrder + 3; j++) + { if (i + j > 3) { DerSurf.SetValue(i, j, Surf->DN(U, V, i, j)); if (i != j) + { DerSurf.SetValue(j, i, Surf->DN(U, V, j, i)); + } } + } + } for (i = 0; i <= MaxOrder + 2; i++) + { for (j = 0; j <= MaxOrder + 2; j++) { DerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurf)); } + } CSLib::Normal(MaxOrder, DerNUV, @@ -307,7 +337,9 @@ static void NormalD2(const double U, OrderU, OrderV); if (NStatus != CSLib_Defined) + { throw Geom_UndefinedValue(); + } D1UNormal = CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV); D1VNormal = CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV); @@ -322,7 +354,9 @@ occ::handle GeomFill_Darboux::Copy() const { occ::handle copy = new (GeomFill_Darboux)(); if (!myCurve.IsNull()) + { copy->SetCurve(myCurve); + } return copy; } @@ -500,7 +534,9 @@ void GeomFill_Darboux::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, gp_Vec& { Param = myTrimmed->FirstParameter() + i * Step; if (Param > myTrimmed->LastParameter()) + { Param = myTrimmed->LastParameter(); + } D0(Param, T, N, BN); ATangent += T; ANormal += N; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DiscreteTrihedron.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DiscreteTrihedron.cxx old mode 100755 new mode 100644 index cfd2e2cd9d..b0bcac6ea9 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DiscreteTrihedron.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DiscreteTrihedron.cxx @@ -47,7 +47,9 @@ occ::handle GeomFill_DiscreteTrihedron::Copy() const { occ::handle copy = new (GeomFill_DiscreteTrihedron)(); if (!myCurve.IsNull()) + { copy->SetCurve(myCurve); + } return copy; } @@ -119,7 +121,9 @@ void GeomFill_DiscreteTrihedron::Init() { double subdelta = (myKnots->Value(i + 1) - myKnots->Value(i)) / NbSamples; if (subdelta < Precision::PConfusion()) + { subdelta = myKnots->Value(i + 1) - myKnots->Value(i); + } SubPnt = myTrimmed->Value(Param + subdelta); Tangent.SetXYZ(SubPnt.XYZ() - Pnt.XYZ()); } @@ -139,14 +143,18 @@ void GeomFill_DiscreteTrihedron::Init() if (AxisOfRotation.Magnitude() <= gp::Resolution()) // tangents are equal or opposite { double ScalarProduct = LastTangent * Tangent; - if (ScalarProduct > 0.) // tangents are equal + if (ScalarProduct > 0.) + { // tangents are equal myTrihedrons->Append(LastAxis); + } else // tangents are opposite { double NewParam = (myKnots->Value(i - 1) + myKnots->Value(i)) / 2.; if (NewParam - myKnots->Value(i - 1) < gp::Resolution()) + { throw Standard_ConstructionError( "GeomFill_DiscreteTrihedron : impassable singularities on path curve"); + } myKnots->InsertBefore(i, NewParam); i--; } @@ -194,21 +202,31 @@ bool GeomFill_DiscreteTrihedron::D0(const double Param, { i = (I1 + I2) / 2; if (Param <= myKnots->Value(i)) + { I2 = i; + } else + { I1 = i; + } if (I2 - I1 <= 1) + { break; + } } Index = I1; if (std::abs(Param - myKnots->Value(I2)) < TolPar) + { Index = I2; + } double PrevParam = myKnots->Value(Index); gp_Ax2 PrevAxis = myTrihedrons->Value(Index); gp_Ax2 theAxis; if (std::abs(Param - PrevParam) < TolPar) + { theAxis = PrevAxis; + } else // is between knots { myTrimmed->D1(Param, myPoint, Tangent); @@ -217,7 +235,9 @@ bool GeomFill_DiscreteTrihedron::D0(const double Param, { double subdelta = (myKnots->Value(Index + 1) - Param) / NbSamples; if (subdelta < Precision::PConfusion()) + { subdelta = myKnots->Value(Index + 1) - Param; + } gp_Pnt SubPnt = myTrimmed->Value(Param + subdelta); Tangent.SetXYZ(SubPnt.XYZ() - myPoint.XYZ()); } @@ -339,7 +359,9 @@ void GeomFill_DiscreteTrihedron::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal { Param = myTrimmed->FirstParameter() + i * Step; if (Param > myTrimmed->LastParameter()) + { Param = myTrimmed->LastParameter(); + } D0(Param, T, N, BN); ATangent += T; ANormal += N; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DraftTrihedron.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DraftTrihedron.cxx index 2b3019a8ab..63731bd2af 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DraftTrihedron.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_DraftTrihedron.cxx @@ -76,7 +76,9 @@ bool GeomFill_DraftTrihedron::D0(const double Param, b /= normb; if (normb < 1.e-12) + { return false; + } gp_Vec v = b.Crossed(T); @@ -123,7 +125,9 @@ bool GeomFill_DraftTrihedron::D1(const double Param, gp_Vec db, b = T.Crossed(B); normb = b.Magnitude(); if (normb < 1.e-12) + { return false; + } b /= normb; aux = DT.Crossed(B); db.SetLinearForm(-(b.Dot(aux)), b, aux); @@ -184,7 +188,9 @@ bool GeomFill_DraftTrihedron::D2(const double Param, gp_Vec db, d2b, b = T.Crossed(B); normb = b.Magnitude(); if (normb < 1.e-12) + { return false; + } aux = DT.Crossed(B); aux2 = D2T.Crossed(B); @@ -303,7 +309,9 @@ void GeomFill_DraftTrihedron::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, g { Param = myTrimmed->FirstParameter() + i * Step; if (Param > myTrimmed->LastParameter()) + { Param = myTrimmed->LastParameter(); + } D0(Param, T, N, BN); ATangent += T; ANormal += N; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_EvolvedSection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_EvolvedSection.cxx index d449c199ad..957c2b0b11 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_EvolvedSection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_EvolvedSection.cxx @@ -304,7 +304,9 @@ double GeomFill_EvolvedSection::MaximalSection() const { val = myLaw->Value(U); if (val > max) + { max = val; + } } return L * max; } @@ -326,7 +328,9 @@ occ::handle GeomFill_EvolvedSection::ConstantSection() const { double Err, scale; if (!IsConstant(Err)) + { throw StdFail_NotDone("The Law is not Constant!"); + } gp_Trsf T; gp_Pnt P(0, 0, 0); scale = myLaw->Value(First) + myLaw->Value((First + Last) / 2) + myLaw->Value(Last); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Fixed.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Fixed.cxx index feb50f2016..34d50f1dae 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Fixed.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Fixed.cxx @@ -26,7 +26,9 @@ IMPLEMENT_STANDARD_RTTIEXT(GeomFill_Fixed, GeomFill_TrihedronLaw) GeomFill_Fixed::GeomFill_Fixed(const gp_Vec& Tangent, const gp_Vec& Normal) { if (Tangent.IsParallel(Normal, 0.01)) + { throw Standard_ConstructionError("GeomFill_Fixed : Two parallel vectors !"); + } T = Tangent; T.Normalize(); N = Normal; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Frenet.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Frenet.cxx index 29f721661a..efe6d1a699 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Frenet.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Frenet.cxx @@ -74,16 +74,22 @@ static double CosAngle(const gp_Vec& theV1, const gp_Vec& theV2) const double aTol = gp::Resolution(); const double m1 = theV1.Magnitude(), m2 = theV2.Magnitude(); - if ((m1 <= aTol) || (m2 <= aTol)) // Vectors are codirectional + if ((m1 <= aTol) || (m2 <= aTol)) + { // Vectors are codirectional return 1.0; + } double aCAng = theV1.Dot(theV2) / (m1 * m2); if (aCAng > 1.0) + { aCAng = 1.0; + } if (aCAng < -1.0) + { aCAng = -1.0; + } return aCAng; } @@ -101,7 +107,9 @@ occ::handle GeomFill_Frenet::Copy() const { occ::handle copy = new (GeomFill_Frenet)(); if (!myCurve.IsNull()) + { copy->SetCurve(myCurve); + } return copy; } @@ -165,7 +173,9 @@ void GeomFill_Frenet::Init() { Func.D0(myC2Disc->Value(i) + (j - 1) * Step, C); if (j == 1) + { C1 = C; + } modulus = C.XYZ().Modulus(); if (modulus > Tol) { @@ -217,26 +227,36 @@ void GeomFill_Frenet::Init() { NCollection_Array1 anArray(1, SeqArray[i - 1].Length()); for (j = 1; j <= anArray.Length(); j++) + { anArray(j) = SeqArray[i - 1](j); + } std::sort(anArray.begin(), anArray.end()); for (j = 1; j <= anArray.Length(); j++) + { SeqArray[i - 1](j) = anArray(j); + } } } } // Filling SnglSeq by first sets of roots for (i = 0; i < NbIntC2; i++) + { for (j = 1; j <= SeqArray[i].Length(); j++) + { SnglSeq.Append(SeqArray[i](j)); + } + } // Extrema works bad, need to pass second time for (i = 0; i < NbIntC2; i++) + { if (!SeqArray[i].IsEmpty()) { SeqArray[i].Prepend(myC2Disc->Value(i + 1)); SeqArray[i].Append(myC2Disc->Value(i + 2)); Func.SetRatio(1. / AveFunc(i + 1)); // Normalization for (j = 1; j < SeqArray[i].Length(); j++) + { if (SeqArray[i](j + 1) - SeqArray[i](j) > PTol) { Ext.Initialize(Func, SeqArray[i](j), SeqArray[i](j + 1), TolF); @@ -250,12 +270,16 @@ void GeomFill_Frenet::Init() { t = Ext.Point(k).Parameter(); if (t - SeqArray[i](j) > PTol && SeqArray[i](j + 1) - t > PTol) + { SnglSeq.Append(t); + } } } } } + } } + } delete[] SeqArray; @@ -264,10 +288,14 @@ void GeomFill_Frenet::Init() // sorting NCollection_Array1 anArray(1, SnglSeq.Length()); for (i = 1; i <= SnglSeq.Length(); i++) + { anArray(i) = SnglSeq(i); + } std::sort(anArray.begin(), anArray.end()); for (i = 1; i <= SnglSeq.Length(); i++) + { SnglSeq(i) = anArray(i); + } // discard repeating elements bool found = true; @@ -276,6 +304,7 @@ void GeomFill_Frenet::Init() { found = false; for (i = j; i < SnglSeq.Length(); i++) + { if (SnglSeq(i + 1) - SnglSeq(i) <= PTol) { SnglSeq.Remove(i + 1); @@ -283,11 +312,14 @@ void GeomFill_Frenet::Init() found = true; break; } + } } mySngl = new NCollection_HArray1(1, SnglSeq.Length()); for (i = 1; i <= mySngl->Length(); i++) + { mySngl->ChangeValue(i) = SnglSeq(i); + } // computation of length of singular interval mySnglLen = new NCollection_HArray1(1, mySngl->Length()); @@ -297,11 +329,17 @@ void GeomFill_Frenet::Init() { Func.D2(mySngl->Value(i), C, SnglDer, SnglDer2); if ((norm = SnglDer.Magnitude()) > gp::Resolution()) + { mySnglLen->ChangeValue(i) = std::min(NullTol / norm, MaxSingular); + } else if ((norm = SnglDer2.Magnitude()) > gp::Resolution()) + { mySnglLen->ChangeValue(i) = std::min(std::sqrt(2 * NullTol / norm), MaxSingular); + } else + { mySnglLen->ChangeValue(i) = MaxSingular; + } } #ifdef OCCT_DEBUG for (i = 1; i <= mySngl->Length(); i++) @@ -327,7 +365,9 @@ void GeomFill_Frenet::Init() tmpSeq.ChangeValue(tmpSeq.Length()) = gp_Pnt2d((U11 + U22) / 2, (U22 - U11) / 2); } else + { tmpSeq.Append(gp_Pnt2d(mySngl->Value(i), mySnglLen->Value(i))); + } } mySngl = new NCollection_HArray1(1, tmpSeq.Length()); mySnglLen = new NCollection_HArray1(1, tmpSeq.Length()); @@ -348,7 +388,9 @@ void GeomFill_Frenet::Init() isSngl = true; } else + { isSngl = false; + } } //======================================================================= @@ -368,10 +410,14 @@ bool GeomFill_Frenet::RotateTrihedron(gp_Vec& Tangent, gp_Vec anAxis = Tangent.Crossed(NewTangent); const double NT = anAxis.Magnitude(); if (NT <= aTol) + { // No rotation required return true; + } else + { anAxis /= NT; // Normalization + } const double aPx = anAxis.X(), aPy = anAxis.Y(), aPz = anAxis.Z(); const double aCAng = CosAngle(Tangent, NewTangent); // cosine @@ -433,8 +479,12 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, int Index; double Delta = 0.; if (IsSingular(theParam, Index)) + { if (SingularD0(theParam, Index, Tangent, Normal, BiNormal, Delta)) + { return true; + } + } double aParam = theParam + Delta; myTrimmed->D2(aParam, P, Tangent, BiNormal); @@ -466,9 +516,13 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, double u; if (theParam - anUinfium < aDelta) + { u = theParam + aDelta; + } else + { u = theParam - aDelta; + } gp_Pnt P1, P2; myTrimmed->D0(std::min(theParam, u), P1); @@ -478,7 +532,9 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, double aDirFactor = aTn.Dot(V1); if (aDirFactor < 0.0) + { aTn = -aTn; + } } // if(IsDeriveFound) else { @@ -506,9 +562,13 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec V1(Ptemp, P1), V2(Ptemp, P2), V3(Ptemp, P3); if (IsParameterGrown) + { aTn = -3 * V1 + 4 * V2 - V3; + } else + { aTn = V1 - 4 * V2 + 3 * V3; + } } // else of "if(IsDeriveFound)" condition Ndu = aTn.Magnitude(); gp_Pnt Pt = P; @@ -519,12 +579,16 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, if (theParam - anUinfium < dPar) { if (!D0(aParam + dPar, Tangent, Normal, BiNormal)) + { return false; + } } else { if (!D0(aParam - dPar, Tangent, Normal, BiNormal)) + { return false; + } } P = Pt; @@ -548,7 +612,9 @@ bool GeomFill_Frenet::D0(const double theParam, gp_Vec& Tangent, gp_Vec& Normal, BiNormal.SetXYZ(Axe.YDirection().XYZ()); } else + { BiNormal.Normalize(); + } Normal = BiNormal; Normal.Cross(Tangent); @@ -570,8 +636,12 @@ bool GeomFill_Frenet::D1(const double Param, int Index; double Delta = 0.; if (IsSingular(Param, Index)) + { if (SingularD1(Param, Index, Tangent, DTangent, Normal, DNormal, BiNormal, DBiNormal, Delta)) + { return true; + } + } // double Norma; double theParam = Param + Delta; @@ -591,7 +661,9 @@ bool GeomFill_Frenet::D1(const double Param, return true; } else + { BiNormal = Tangent.Crossed(DC2).Normalized(); + } Normal = BiNormal.Crossed(Tangent); @@ -622,6 +694,7 @@ bool GeomFill_Frenet::D2(const double Param, int Index; double Delta = 0.; if (IsSingular(Param, Index)) + { if (SingularD2(Param, Index, Tangent, @@ -634,7 +707,10 @@ bool GeomFill_Frenet::D2(const double Param, DBiNormal, D2BiNormal, Delta)) + { return true; + } + } // double Norma; double theParam = Param + Delta; @@ -659,7 +735,9 @@ bool GeomFill_Frenet::D2(const double Param, return true; } else + { BiNormal = Tangent.Crossed(DC2).Normalized(); + } Normal = BiNormal.Crossed(Tangent); @@ -707,7 +785,9 @@ int GeomFill_Frenet::NbIntervals(const GeomAbs_Shape S) const NbTrimmed = myCurve->NbIntervals(tmpS); if (!isSngl) + { return NbTrimmed; + } NCollection_Array1 TrimInt(1, NbTrimmed + 1); myCurve->Intervals(TrimInt, tmpS); @@ -755,7 +835,9 @@ void GeomFill_Frenet::Intervals(NCollection_Array1& T, const GeomAbs_Sha GeomLib::FuseIntervals(TrimInt, mySngl->Array1(), Fusion, Precision::PConfusion(), true); for (int i = 1; i <= Fusion.Length(); i++) + { T.ChangeValue(i) = Fusion.Value(i); + } } void GeomFill_Frenet::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, gp_Vec& ABiNormal) @@ -771,7 +853,9 @@ void GeomFill_Frenet::GetAverageLaw(gp_Vec& ATangent, gp_Vec& ANormal, gp_Vec& A { Param = myTrimmed->FirstParameter() + i * Step; if (Param > myTrimmed->LastParameter()) + { Param = myTrimmed->LastParameter(); + } D0(Param, T, N, BN); ATangent += T; ANormal += N; @@ -805,7 +889,9 @@ bool GeomFill_Frenet::IsSingular(const double U, int& Index) const { int i; if (!isSngl) + { return false; + } for (i = 1; i <= mySngl->Length(); i++) { if (std::abs(U - mySngl->Value(i)) < mySnglLen->Value(i)) @@ -840,15 +926,21 @@ bool GeomFill_Frenet::DoSingular(const double U, BNFlag = 1; GetInterval(A, B); if (U >= (A + B) / 2) + { h = -h; + } for (i = 1; i <= MaxN; i++) { Tangent = myTrimmed->DN(U, i); if (Tangent.Magnitude() > Precision::Confusion()) + { break; + } } if (i > MaxN) + { return false; + } Tangent.Normalize(); n = i; @@ -882,9 +974,13 @@ bool GeomFill_Frenet::DoSingular(const double U, D0(U + h, T, N, BN); if (Tangent.Angle(T) > M_PI / 2) + { TFlag = -1; + } if (BiNormal.Angle(BN) > M_PI / 2) + { BNFlag = -1; + } return true; } @@ -898,7 +994,9 @@ bool GeomFill_Frenet::SingularD0(const double Param, { int n, k, TFlag, BNFlag; if (!DoSingular(Param, Index, Tangent, BiNormal, n, k, TFlag, BNFlag, Delta)) + { return false; + } Tangent *= TFlag; BiNormal *= BNFlag; @@ -920,7 +1018,9 @@ bool GeomFill_Frenet::SingularD1(const double Param, { int n, k, TFlag, BNFlag; if (!DoSingular(Param, Index, Tangent, BiNormal, n, k, TFlag, BNFlag, Delta)) + { return false; + } gp_Vec F, DF, Dtmp; F = myTrimmed->DN(Param, n); @@ -965,7 +1065,9 @@ bool GeomFill_Frenet::SingularD2(const double Param, { int n, k, TFlag, BNFlag; if (!DoSingular(Param, Index, Tangent, BiNormal, n, k, TFlag, BNFlag, Delta)) + { return false; + } gp_Vec F, DF, D2F, Dtmp1, Dtmp2; F = myTrimmed->DN(Param, n); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_FunctionGuide.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_FunctionGuide.cxx index f42087b5f8..e4834c44a8 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_FunctionGuide.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_FunctionGuide.cxx @@ -106,9 +106,13 @@ void GeomFill_FunctionGuide::SetParam(const double, NCollection_Array1 Weights(1, NbPoles); TheLaw->D0(TheUonS, Poles, Weights); if (TheLaw->IsRational()) + { TheCurve = new (Geom_BSplineCurve)(Poles, Weights, Knots, Mult, Deg, TheLaw->IsUPeriodic()); + } else + { TheCurve = new (Geom_BSplineCurve)(Poles, Knots, Mult, Deg, TheLaw->IsUPeriodic()); + } } gp_Ax1 Axe(C, Dir); @@ -243,7 +247,7 @@ void GeomFill_FunctionGuide::DSDT(const double U, gp_XYZ &Q = Pc.ChangeCoord(), DQ(0, 0, 0); // Q if (!isconst) { - std::cout << "Not implemented" << std::endl; + std::cout << "Not implemented" << '\n'; } Q.Subtract(Centre); // CQ diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Gordon.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Gordon.cxx index c3e32ee983..de1810bf99 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Gordon.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Gordon.cxx @@ -1035,7 +1035,9 @@ bool GeomFill_Gordon::sortNetwork() // Helper lambdas for swapping. auto swapProfiles = [this, aNbGuid](int aProfileIdx1, int aProfileIdx2) { if (aProfileIdx1 == aProfileIdx2) + { return; + } std::swap(myProfiles(aProfileIdx1), myProfiles(aProfileIdx2)); for (int aGuideIdx = 1; aGuideIdx <= aNbGuid; ++aGuideIdx) { @@ -1046,7 +1048,9 @@ bool GeomFill_Gordon::sortNetwork() auto swapGuides = [this, aNbProf](int aGuideIdx1, int aGuideIdx2) { if (aGuideIdx1 == aGuideIdx2) + { return; + } std::swap(myGuides(aGuideIdx1), myGuides(aGuideIdx2)); for (int aProfileIdx = 1; aProfileIdx <= aNbProf; ++aProfileIdx) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronAC.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronAC.cxx index 842d5ddf86..d9322ce53a 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronAC.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronAC.cxx @@ -214,7 +214,9 @@ bool GeomFill_GuideTrihedronAC::D2(const double Param, double Norma = TN.Magnitude(); if (Norma > 1.e-9) + { TN /= Norma; + } BiNormal = TN; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronPlan.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronPlan.cxx index 594e533083..f8bd6beb5e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronPlan.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GuideTrihedronPlan.cxx @@ -55,9 +55,13 @@ static void InGoodPeriod(const double Prec, const double Period, double& Current Current -= nb * Period; Diff = Current - Prec; if (Diff > Period / 2) + { Current -= Period; + } else if (Diff < -Period / 2) + { Current += Period; + } } //================================================================================================= @@ -192,7 +196,9 @@ bool GeomFill_GuideTrihedronPlan::SetCurve(const occ::handle& C { myCurve = C; if (!myCurve.IsNull()) + { Init(); + } return true; } @@ -491,7 +497,9 @@ bool GeomFill_GuideTrihedronPlan::IsConstant() const double Angle; Angle = myCurve->Line().Angle(myGuide->Line()); if ((Angle < 1.e-12) || ((2 * M_PI - Angle) < 1.e-12)) + { return true; + } } return false; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationDraft.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationDraft.cxx index 626b4769b7..700c7d791c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationDraft.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationDraft.cxx @@ -68,7 +68,9 @@ occ::handle GeomFill_LocationDraft::Copy() const copy->SetCurve(myCurve); copy->SetStopSurf(mySurf); if (WithTrans) + { copy->SetTrsf(Trans); + } return copy; } @@ -83,9 +85,15 @@ void GeomFill_LocationDraft::SetTrsf(const gp_Mat& Transfo) Aux -= Trans; WithTrans = false; // Au cas ou Trans = I for (int ii = 1; ii <= 3 && !WithTrans; ii++) + { for (int jj = 1; jj <= 3 && !WithTrans; jj++) + { if (std::abs(Aux.Value(ii, jj)) > 1.e-14) + { WithTrans = true; + } + } + } } //================================================================== @@ -168,7 +176,9 @@ void GeomFill_LocationDraft::Prepare() { P2 = Int.Point(jj); if (P1.W() > P2.W()) + { P1 = P2; // point le plus proche + } } // for_jj gp_Pnt2d p(P1.W(), t); // point de la courbe @@ -204,7 +214,9 @@ bool GeomFill_LocationDraft::D0(const double Param, gp_Mat& M, gp_Vec& V) Ok = myLaw->D0(Param, T, N, B); if (!Ok) + { return Ok; + } M.SetCols(N.XYZ(), B.XYZ(), T.XYZ()); if (WithTrans) @@ -233,7 +245,9 @@ bool GeomFill_LocationDraft::D0(const double Param, V.SetXYZ(P.XYZ()); Ok = myLaw->D0(Param, T, N, B); if (!Ok) + { return Ok; + } M.SetCols(N.XYZ(), B.XYZ(), T.XYZ()); if (WithTrans) @@ -257,7 +271,9 @@ bool GeomFill_LocationDraft::D0(const double Param, // on recherche l'intervalle auquel appartient Param while (ii < 2 * myNbPts && myPoles2d->Value(ii).Coord(2) < Param) + { ii = ii + 2; + } if (ii < 2 * myNbPts && !IsEqual(myPoles2d->Value(ii).Coord(2), Param)) { @@ -346,7 +362,9 @@ bool GeomFill_LocationDraft::D1(const double Param, Ok = myLaw->D1(Param, T, DT, N, DN, B, DB); if (!Ok) + { return false; + } M.SetCols(N.XYZ(), B.XYZ(), T.XYZ()); DM.SetCols(DN.XYZ(), DB.XYZ(), DT.XYZ()); @@ -374,7 +392,9 @@ bool GeomFill_LocationDraft::D1(const double Param, // on recherche l'intervalle auquel appartient Param while (ii < 2 * myNbPts && myPoles2d->Value(ii).Coord(2) < Param) + { ii = ii + 2; + } if (ii < 2 * myNbPts && !IsEqual(myPoles2d->Value(ii).Coord(2), Param)) { @@ -481,7 +501,9 @@ bool GeomFill_LocationDraft::D2(const double Param, Ok = myLaw->D2(Param, T, DT, D2T, N, DN, D2N, B, DB, D2B); if (!Ok) + { return Ok; + } M.SetCols(N.XYZ(), B.XYZ(), T.XYZ()); DM.SetCols(DN.XYZ(), DB.XYZ(), DT.XYZ()); @@ -509,7 +531,9 @@ bool GeomFill_LocationDraft::D2(const double Param, // on recherche l'intervalle auquel appartient Param while (ii < 2 * myNbPts && myPoles2d->Value(ii).Coord(2) < Param) + { ii = ii + 2; + } if (ii < 2 * myNbPts && !IsEqual(myPoles2d->Value(ii).Coord(2), Param)) { @@ -640,9 +664,13 @@ bool GeomFill_LocationDraft::HasLastRestriction() const int GeomFill_LocationDraft::TraceNumber() const { if (Intersec) + { return 1; + } else + { return 0; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationGuide.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationGuide.cxx index 6e4ab675af..b15d72c587 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationGuide.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationGuide.cxx @@ -132,9 +132,13 @@ static void InGoodPeriod(const double Prec, const double Period, double& Current Current -= nb * Period; Diff = Current - Prec; if (Diff > Period / 2) + { Current -= Period; + } else if (Diff < -Period / 2) + { Current += Period; + } } //================================================================================================= @@ -180,7 +184,9 @@ GeomFill_LocationGuide::GeomFill_LocationGuide( void GeomFill_LocationGuide::SetRotation(const double PrecAngle, double& LastAngle) { if (myCurve.IsNull()) + { throw Standard_ConstructionError("GeomFill_LocationGuide::The path is not set !!"); + } // repere fixe gp_Ax3 Rep(gp::Origin(), gp::DZ(), gp::DX()); @@ -250,7 +256,9 @@ void GeomFill_LocationGuide::SetRotation(const double PrecAngle, double& LastAng // JALONNEMENT if (uperiodic) + { UPeriod = Ul - Uf; + } for (ii = 1; ii <= myNbPts; ii++) { @@ -284,18 +292,22 @@ void GeomFill_LocationGuide::SetRotation(const double PrecAngle, double& LastAng U = myFirstS + (t - myCurve->FirstParameter()) * ratio; mySec->D0(U, Poles->ChangeArray1(), Weights->ChangeArray1()); if (israt) + { mySection = new (Geom_BSplineCurve)(Poles->Array1(), Weights->Array1(), Knots->Array1(), Mult->Array1(), Deg, mySec->IsUPeriodic()); + } else + { mySection = new (Geom_BSplineCurve)(Poles->Array1(), Knots->Array1(), Mult->Array1(), Deg, mySec->IsUPeriodic()); + } S = new (Geom_TrimmedCurve)(mySection, Uf, Ul); } else @@ -469,15 +481,23 @@ void GeomFill_LocationGuide::Set(const occ::handle& Section myLastS = SLast; LastAngle = PrecAngle; if (myCurve.IsNull()) + { ratio = 0.; + } else + { ratio = (SLast - SFirst) / (myCurve->LastParameter() - myCurve->FirstParameter()); + } mySec = Section; if (rotat) + { SetRotation(PrecAngle, LastAngle); + } else + { rotation = false; + } } //================================================================================================= @@ -486,7 +506,9 @@ void GeomFill_LocationGuide::EraseRotation() { rotation = false; if (myStatus == GeomFill_ImpossibleContact) + { myStatus = GeomFill_PipeOk; + } } //================================================================================================= @@ -522,7 +544,9 @@ bool GeomFill_LocationGuide::SetCurve(const occ::handle& C) myStatus = myLaw->ErrorStatus(); if (rotation) + { SetRotation(myPoles2d->Value(1, 1).X(), LastAngle); + } } return myStatus == GeomFill_PipeOk; } @@ -544,9 +568,15 @@ void GeomFill_LocationGuide::SetTrsf(const gp_Mat& Transfo) Aux -= Trans; WithTrans = false; // Au cas ou Trans = I for (int ii = 1; ii <= 3 && !WithTrans; ii++) + { for (int jj = 1; jj <= 3 && !WithTrans; jj++) + { if (std::abs(Aux.Value(ii, jj)) > 1.e-14) + { WithTrans = true; + } + } + } } //================================================================================================= @@ -1196,7 +1226,9 @@ void GeomFill_LocationGuide::Intervals(NCollection_Array1& T, const Geom GeomLib::FuseIntervals(IntC, IntL, Inter, Precision::PConfusion() * 0.99); for (int ii = 1; ii <= Inter.Length(); ii++) + { T(ii) = Inter(ii); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationLaw.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationLaw.cxx index b02bcd0bf4..a4a96cd016 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationLaw.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_LocationLaw.cxx @@ -54,9 +54,13 @@ int GeomFill_LocationLaw::Nb2dCurves() const { int N = TraceNumber(); if (HasFirstRestriction()) + { N++; + } if (HasLastRestriction()) + { N++; + } return N; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_NSections.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_NSections.cxx index 88d6c4aa82..e4b44583aa 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_NSections.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_NSections.cxx @@ -153,7 +153,9 @@ static void ResultEval(const occ::handle& surf, bool rational = surf->IsVRational(); int gap = 3; if (rational) + { gap++; + } int Cdeg = surf->VDegree(), Cdim = surf->NbUPoles() * gap, NbP = surf->NbVPoles(); // les noeuds plats @@ -318,17 +320,23 @@ bool GeomFill_NSections::D1(const double V, NCollection_Array1& DWeights) { if (mySurface.IsNull()) + { return false; + } bool ok = D0(V, Poles, Weights); if (!ok) + { return false; + } int L = Poles.Length(), derivative_request = 1; bool rational = mySurface->IsVRational(); int gap = 3; if (rational) + { gap++; + } int dimResult = mySurface->NbUPoles() * gap; occ::handle surf_deper; @@ -352,7 +360,9 @@ bool GeomFill_NSections::D1(const double V, constexpr double EpsW = 10 * Precision::PConfusion(); bool NullWeight = false; if (!rational) + { DWeights.Init(0.); + } int indice = 1, ii; // recopie des poles du resultat sous forme de points 3D et de poids @@ -391,22 +401,30 @@ bool GeomFill_NSections::D2(const double V, NCollection_Array1& D2Weights) { if (mySurface.IsNull()) + { return false; + } // pb dans BSplCLib::Eval() pour les surfaces rationnelles de degre 1 // si l'ordre de derivation est egal a 2. if (mySurface->VDegree() < 2) + { return false; + } bool ok = D1(V, Poles, DPoles, Weights, DWeights); if (!ok) + { return false; + } int L = Poles.Length(), derivative_request = 2; bool rational = mySurface->IsVRational(); int gap = 3; if (rational) + { gap++; + } int dimResult = mySurface->NbUPoles() * gap; occ::handle surf_deper; @@ -430,7 +448,9 @@ bool GeomFill_NSections::D2(const double V, constexpr double EpsW = 10 * Precision::PConfusion(); bool NullWeight = false; if (!rational) + { D2Weights.Init(0.); + } int indice = 1, ii; // recopie des poles du resultat sous forme de points 3D et de poids @@ -580,14 +600,22 @@ void GeomFill_NSections::ComputeSurface() int i1, i2; myRefSurf->LocateU(Ui1, Precision::PConfusion(), i1, i2); if (std::abs(Ui1 - myRefSurf->UKnot(i1)) <= Precision::PConfusion()) + { Ui1 = myRefSurf->UKnot(i1); + } if (std::abs(Ui1 - myRefSurf->UKnot(i2)) <= Precision::PConfusion()) + { Ui1 = myRefSurf->UKnot(i2); + } myRefSurf->LocateU(Ui2, Precision::PConfusion(), i1, i2); if (std::abs(Ui2 - myRefSurf->UKnot(i1)) <= Precision::PConfusion()) + { Ui2 = myRefSurf->UKnot(i1); + } if (std::abs(Ui2 - myRefSurf->UKnot(i2)) <= Precision::PConfusion()) + { Ui2 = myRefSurf->UKnot(i2); + } V0 = myRefSurf->VKnot(myRefSurf->FirstVKnotIndex()); V1 = myRefSurf->VKnot(myRefSurf->LastVKnotIndex()); BS->CheckAndSegment(Ui1, Ui2, V0, V1); @@ -612,7 +640,9 @@ void GeomFill_NSections::ComputeSurface() void GeomFill_NSections::SectionShape(int& NbPoles, int& NbKnots, int& Degree) const { if (mySurface.IsNull()) + { return; + } NbPoles = mySurface->NbUPoles(); NbKnots = mySurface->NbUKnots(); @@ -625,7 +655,9 @@ void GeomFill_NSections::SectionShape(int& NbPoles, int& NbKnots, int& Degree) c void GeomFill_NSections::Knots(NCollection_Array1& TKnots) const { if (!mySurface.IsNull()) + { TKnots = mySurface->UKnots(); + } } //======================================================= @@ -634,7 +666,9 @@ void GeomFill_NSections::Knots(NCollection_Array1& TKnots) const void GeomFill_NSections::Mults(NCollection_Array1& TMults) const { if (!mySurface.IsNull()) + { TMults = mySurface->UMultiplicities(); + } } //======================================================= @@ -643,7 +677,9 @@ void GeomFill_NSections::Mults(NCollection_Array1& TMults) const bool GeomFill_NSections::IsRational() const { if (!mySurface.IsNull()) + { return mySurface->IsURational(); + } return false; } @@ -654,7 +690,9 @@ bool GeomFill_NSections::IsRational() const bool GeomFill_NSections::IsUPeriodic() const { if (!mySurface.IsNull()) + { return mySurface->IsUPeriodic(); + } return false; } @@ -665,7 +703,9 @@ bool GeomFill_NSections::IsUPeriodic() const bool GeomFill_NSections::IsVPeriodic() const { if (!mySurface.IsNull()) + { return mySurface->IsVPeriodic(); + } return false; } @@ -676,7 +716,9 @@ bool GeomFill_NSections::IsVPeriodic() const int GeomFill_NSections::NbIntervals(const GeomAbs_Shape S) const { if (mySurface.IsNull()) + { return 0; + } GeomAdaptor_Surface AdS(mySurface); return AdS.NbVIntervals(S); @@ -688,7 +730,9 @@ int GeomFill_NSections::NbIntervals(const GeomAbs_Shape S) const void GeomFill_NSections::Intervals(NCollection_Array1& T, const GeomAbs_Shape S) const { if (mySurface.IsNull()) + { return; + } GeomAdaptor_Surface AdS(mySurface); AdS.VIntervals(T, S); @@ -750,7 +794,9 @@ gp_Pnt GeomFill_NSections::BarycentreOfSurf() const Bary.SetCoord(0., 0., 0.); if (mySurface.IsNull()) + { return Bary; + } int ii, jj; double U0, U1, V0, V1; @@ -782,7 +828,9 @@ double GeomFill_NSections::MaximalSection() const GeomAdaptor_Curve AC(mySections(ii)); L = GCPnts_AbscissaPoint::Length(AC); if (L > Lmax) + { Lmax = L; + } } return Lmax; } @@ -793,7 +841,9 @@ double GeomFill_NSections::MaximalSection() const void GeomFill_NSections::GetMinimalWeight(NCollection_Array1& Weights) const { if (mySurface.IsNull()) + { return; + } if (mySurface->IsURational()) { @@ -812,7 +862,9 @@ void GeomFill_NSections::GetMinimalWeight(NCollection_Array1& Weights) c for (j = 2; j <= NbV; j++) { if (min > WSurf(i, j)) + { min = WSurf(i, j); + } } Weights.SetValue(i, min); } @@ -913,10 +965,14 @@ bool GeomFill_NSections::IsConicalLaw(double& Error) const { gp_Circ C1 = AC1.Circle(); if (!myTrsfs.IsEmpty()) + { C1.Transform(myTrsfs(1).Inverted()); + } gp_Circ C2 = AC2.Circle(); if (!myTrsfs.IsEmpty()) + { C2.Transform(myTrsfs(2).Inverted()); + } double Tol = 1.e-7; // bool samedir, linearrad, sameaxis; isconic = (C1.Axis().IsParallel(C2.Axis(), 1.e-4)); @@ -963,7 +1019,9 @@ occ::handle GeomFill_NSections::CirclSection(const double V) const { double Err; if (!IsConicalLaw(Err)) + { throw StdFail_NotDone("The Law is not Conical!"); + } GeomAdaptor_Curve AC1(mySections(1)); GeomAdaptor_Curve AC2(mySections(mySections.Length())); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Pipe.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Pipe.cxx index 4883a9aa6b..9195e89032 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Pipe.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Pipe.cxx @@ -93,7 +93,9 @@ static bool CheckSense(const NCollection_Sequence>& Seq1 C1->D0(u, Tab(iP)); u += h; if ((u - f) * (u - l) > 0.0) + { u = l; + } } gp_Ax2 AxeRef, Axe; gp_Pnt Pos; @@ -102,7 +104,9 @@ static bool CheckSense(const NCollection_Sequence>& Seq1 // si la section est une droite, ca ne marche pas if (sing) + { no_sing = false; + } Pos = AxeRef.Location(); double alpha1, alpha2, alpha3; @@ -134,13 +138,17 @@ static bool CheckSense(const NCollection_Sequence>& Seq1 C2->D0(u, Tab(iP)); u += h; if ((u - f) * (u - l) > 0.0) + { u = l; + } } GeomLib::AxeOfInertia(Tab, Axe, sing); // si la section est une droite, ca ne marche pas if (sing) + { no_sing = false; + } Pos = Axe.Location(); double beta1, beta2, beta3; @@ -169,22 +177,38 @@ static bool CheckSense(const NCollection_Sequence>& Seq1 if (pasnul1 && pasnul2 && pasnul3) { if (alpha1 * beta1 > 0.0) + { ok = (alpha2 * beta2 > 0.0) || (alpha3 * beta3 > 0.0); + } else + { ok = (alpha2 * beta2 > 0.0) && (alpha3 * beta3 > 0.0); + } } else if (pasnul1 && pasnul2 && !pasnul3) + { ok = (alpha1 * beta1 > 0.0) || (alpha2 * beta2 > 0.0); + } else if (pasnul1 && !pasnul2 && pasnul3) + { ok = (alpha1 * beta1 > 0.0) || (alpha3 * beta3 > 0.0); + } else if (!pasnul1 && pasnul2 && pasnul3) + { ok = (alpha2 * beta2 > 0.0) || (alpha3 * beta3 > 0.0); + } else if (pasnul1) + { ok = (alpha1 * beta1 > 0.0); + } else if (pasnul2) + { ok = (alpha2 * beta2 > 0.0); + } else if (pasnul3) + { ok = (alpha3 * beta3 > 0.0); + } if (no_sing && !ok) { @@ -379,7 +403,9 @@ void GeomFill_Pipe::Init(const occ::handle& Path, myAdpPath->LastParameter()); if (rotat) + { TheLoc->Set(mySec, rotat, myAdpPath->FirstParameter(), myAdpPath->LastParameter(), 0., angle); + } myLoc = TheLoc; } @@ -609,7 +635,9 @@ void GeomFill_Pipe::Init(const occ::handle& Pa // verification des orientations NCollection_Sequence> NewSeq; if (CheckSense(SeqC, NewSeq)) + { SeqC = NewSeq; + } // verification des parametres bool play_again = true; @@ -688,7 +716,9 @@ void GeomFill_Pipe::Init(const occ::handle& Path, // orientation verification NCollection_Sequence> NewSeq; if (CheckSense(SeqC, NewSeq)) + { SeqC = NewSeq; + } // creation of the NSections double deb, fin; @@ -732,7 +762,9 @@ void GeomFill_Pipe::Perform(const bool WithParameters, const bool Polynomial) return; } if (!KPartT4()) + { ApproxSurf(WithParameters); + } } //================================================================================================= @@ -873,7 +905,9 @@ bool GeomFill_Pipe::KPartT4() gp_Dir V2(gp_Vec(P0, P2)); if (std::abs(V1.Dot(D0)) > Precision::Confusion() || std::abs(V2.Dot(D0)) > Precision::Confusion()) + { return Ok; + } // the result is a cylindrical surface. gp_Dir X(V1), Y(V2), ZRef; @@ -881,7 +915,9 @@ bool GeomFill_Pipe::KPartT4() gp_Ax3 Axis(A0.Location(), D0, X); if (ZRef.Dot(D0) < 0.) + { Axis.YReverse(); + } // rotate the surface to set the iso U = 0 not in the result. Axis.Rotate(gp_Ax1(P0, ZRef), -M_PI / 2.); @@ -908,7 +944,9 @@ bool GeomFill_Pipe::KPartT4() if (std::abs(Alp0 - Alp1) > Precision::Angular() || std::abs(Alp0 - Alp2) > Precision::Angular()) + { return Ok; + } gp_Ax2 A0 = myAdpPath->Circle().Position(); gp_Ax2 A1 = myAdpFirstSect->Circle().Position(); @@ -922,13 +960,17 @@ bool GeomFill_Pipe::KPartT4() // les 3 directions doivent etre egales. if (!D0.IsEqual(D1, Precision::Angular()) || !D1.IsEqual(D2, Precision::Angular())) + { return Ok; + } // les 3 ax1 doivent etre confondus. gp_Lin L(A0.Axis()); if (!L.Contains(A1.Location(), Precision::Confusion()) || !L.Contains(A2.Location(), Precision::Confusion())) + { return Ok; + } // les 3 premiers points doivent etre dans la meme section. gp_Dir V1(gp_Vec(P0, P1)); @@ -937,7 +979,9 @@ bool GeomFill_Pipe::KPartT4() gp_Vec YRef = ElCLib::CircleDN(myAdpPath->FirstParameter(), A0, Ci.Radius(), 1); if (std::abs(V1.Dot(YRef)) > Precision::Confusion() || std::abs(V2.Dot(YRef)) > Precision::Confusion()) + { return Ok; + } // OK it`s a Toroidal Surface !! OUF !! gp_Torus T(A0, Ci.Radius(), myRadius); @@ -975,7 +1019,9 @@ void GeomFill_Pipe::ApproxSurf(const bool WithParameters) // and approximate this sequence. if (myType != 4) + { throw Standard_ConstructionError("GeomFill_Pipe"); + } GeomFill_SweepSectionGenerator Section(myAdpPath, myAdpFirstSect, myAdpLastSect, myRadius); Section.Perform(myPolynomial); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_PolynomialConvertor.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_PolynomialConvertor.cxx index b460155a80..f2defd46d2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_PolynomialConvertor.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_PolynomialConvertor.cxx @@ -41,7 +41,9 @@ bool GeomFill_PolynomialConvertor::Initialized() const void GeomFill_PolynomialConvertor::Init() { if (myinit) + { return; + } // BH = B * H where B is the monomial-to-BSpline conversion matrix on [-1,1], degree 7, // and H is the Hermite coefficients matrix. Both are mathematical constants computed once. @@ -55,7 +57,9 @@ void GeomFill_PolynomialConvertor::Init() aTrueInter.SetValue(2, 1); aCoeffs.Init(0); for (int ii = 1; ii <= anOrdre; ii++) + { aCoeffs.SetValue(ii + (ii - 1) * anOrdre, 1); + } Convert_CompPolynomialToPoles aConverter(anOrdre, anOrdre - 1, @@ -66,15 +70,21 @@ void GeomFill_PolynomialConvertor::Init() const NCollection_Array2& aPoles = aConverter.Poles(); math_Matrix aB(1, anOrdre, 1, anOrdre); for (int jj = 1; jj <= anOrdre; jj++) + { for (int ii = 1; ii <= anOrdre; ii++) { double aTerm = aPoles.Value(ii, jj); if (std::abs(aTerm - 1) < 1.e-9) + { aTerm = 1; + } if (std::abs(aTerm + 1) < 1.e-9) + { aTerm = -1; + } aB(ii, jj) = aTerm; } + } math_Matrix aH(1, anOrdre, 1, anOrdre); PLib::HermiteCoefficients(-1, 1, anOrdre / 2 - 1, anOrdre / 2 - 1, aH); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Profiler.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Profiler.cxx index 11ff9561e6..6955153a5c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Profiler.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Profiler.cxx @@ -128,15 +128,21 @@ void GeomFill_Profiler::AddCurve(const occ::handle& Curve) //// modified by jgv, 19.01.05 for OCC7354 //// occ::handle theCurve = Curve; if (theCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { theCurve = occ::down_cast(theCurve)->BasisCurve(); + } if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic))) { GeomConvert_ApproxCurve appr(Curve, Precision::Confusion(), GeomAbs_C1, 16, 14); if (appr.HasResult()) + { C = appr.Curve(); + } } if (C.IsNull()) + { C = GeomConvert::CurveToBSplineCurve(Curve); + } /* if ( Curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { C = occ::down_cast(Curve->Copy()); @@ -150,7 +156,9 @@ void GeomFill_Profiler::AddCurve(const occ::handle& Curve) mySequence.Append(C); if (myIsPeriodic && !C->IsPeriodic()) + { myIsPeriodic = false; + } } //================================================================================================= @@ -208,23 +216,31 @@ void GeomFill_Profiler::Perform(const double PTol) NCollection_Sequence> theCurves; for (i = 1; i <= mySequence.Length(); i++) + { theCurves.Append(occ::down_cast(mySequence(i)->Copy())); + } UnifyByInsertingAllKnots(theCurves, PTol); bool Unified = true; int theNbKnots = (occ::down_cast(theCurves(1)))->NbKnots(); for (i = 2; i <= theCurves.Length(); i++) + { if ((occ::down_cast(theCurves(i)))->NbKnots() != theNbKnots) { Unified = false; break; } + } if (Unified) + { mySequence = theCurves; + } else + { UnifyBySettingMiddleKnots(mySequence); + } myIsDone = true; } @@ -234,7 +250,9 @@ void GeomFill_Profiler::Perform(const double PTol) int GeomFill_Profiler::Degree() const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } occ::handle C = occ::down_cast(mySequence(1)); return C->Degree(); @@ -245,7 +263,9 @@ int GeomFill_Profiler::Degree() const int GeomFill_Profiler::NbPoles() const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } occ::handle C = occ::down_cast(mySequence(1)); return C->NbPoles(); @@ -256,7 +276,9 @@ int GeomFill_Profiler::NbPoles() const void GeomFill_Profiler::Poles(const int Index, NCollection_Array1& Poles) const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } Standard_DomainError_Raise_if(Poles.Length() != NbPoles(), "GeomFill_Profiler::Poles"); Standard_DomainError_Raise_if(Index < 1 || Index > mySequence.Length(), @@ -272,7 +294,9 @@ void GeomFill_Profiler::Poles(const int Index, NCollection_Array1& Poles void GeomFill_Profiler::Weights(const int Index, NCollection_Array1& Weights) const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } Standard_DomainError_Raise_if(Weights.Length() != NbPoles(), "GeomFill_Profiler::Weights"); Standard_DomainError_Raise_if(Index < 1 || Index > mySequence.Length(), @@ -288,7 +312,9 @@ void GeomFill_Profiler::Weights(const int Index, NCollection_Array1& Wei int GeomFill_Profiler::NbKnots() const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } occ::handle C = occ::down_cast(mySequence(1)); @@ -301,7 +327,9 @@ void GeomFill_Profiler::KnotsAndMults(NCollection_Array1& Knots, NCollection_Array1& Mults) const { if (!myIsDone) + { throw StdFail_NotDone("GeomFill_Profiler::Degree"); + } #ifndef No_Exception int n = NbKnots(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_QuasiAngularConvertor.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_QuasiAngularConvertor.cxx index 538980fcaa..6e77079693 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_QuasiAngularConvertor.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_QuasiAngularConvertor.cxx @@ -71,7 +71,9 @@ bool GeomFill_QuasiAngularConvertor::Initialized() const void GeomFill_QuasiAngularConvertor::Init() { if (myinit) + { return; + } // B is the monomial-to-BSpline conversion matrix on [-1,1], degree 6. // It is a mathematical constant computed once. @@ -85,7 +87,9 @@ void GeomFill_QuasiAngularConvertor::Init() aTrueInter.SetValue(2, 1); aCoeffs.Init(0); for (int ii = 1; ii <= anOrdre; ii++) + { aCoeffs.SetValue(ii + (ii - 1) * anOrdre, 1); + } Convert_CompPolynomialToPoles aConverter(anOrdre, anOrdre - 1, @@ -96,15 +100,21 @@ void GeomFill_QuasiAngularConvertor::Init() const NCollection_Array2& aPoles = aConverter.Poles(); math_Matrix aResult(1, anOrdre, 1, anOrdre); for (int jj = 1; jj <= anOrdre; jj++) + { for (int ii = 1; ii <= anOrdre; ii++) { double aTerm = aPoles.Value(ii, jj); if (std::abs(aTerm - 1) < 1.e-9) + { aTerm = 1; + } if (std::abs(aTerm + 1) < 1.e-9) + { aTerm = -1; + } aResult(ii, jj) = aTerm; } + } return aResult; }(); @@ -165,7 +175,9 @@ void GeomFill_QuasiAngularConvertor::Section(const gp_Pnt& FirstPn } } else + { b = ((double)-1) / beta2; + } c = ((double)1) / 3 + b; b2 = b * b; c2 = c * c; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx index ffe030833a..8821b5a154 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SectionPlacement.cxx @@ -63,7 +63,9 @@ static void Tangente(const Adaptor3d_Curve& Path, const double Param, gp_Pnt& P, } if (Norm > 100 * gp::Resolution()) + { Tang /= Norm; + } } static double Penalite(const double angle, const double dist) @@ -71,11 +73,17 @@ static double Penalite(const double angle, const double dist) double penal; if (dist < 1) + { penal = std::sqrt(dist); + } else if (dist < 2) + { penal = std::pow(dist, 2); + } else + { penal = dist + 2; + } if (angle > 1.e-3) { @@ -94,7 +102,9 @@ static double EvalAngle(const gp_Vec& V1, const gp_Vec& V2) double angle; angle = V1.Angle(V2); if (angle > M_PI / 2) + { angle = M_PI - angle; + } return angle; } @@ -175,9 +185,13 @@ GeomFill_SectionPlacement::GeomFill_SectionPlacement(const occ::handle aCurve = myAdpSection.Curve(); if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { aCurve = (occ::down_cast(aCurve))->BasisCurve(); + } double Ufirst = aCurve->FirstParameter(); double aPeriod = aCurve->Period(); double U1 = Ufirst + std::floor((first - Ufirst) / aPeriod) * aPeriod; double U2 = U1 + aPeriod; if (std::abs(first - U1) <= Precision::PConfusion()) + { first = U1; + } if (std::abs(last - U2) <= Precision::PConfusion()) + { last = U2; + } } double t, delta; if (myAdpSection.GetType() == GeomAbs_BSplineCurve) @@ -269,13 +289,21 @@ GeomFill_SectionPlacement::GeomFill_SectionPlacement(const occ::handleKnot(I3)) + { NbPnts += NbLocalPnts; + } if (!myAdpSection.IsClosed()) + { NbPnts++; + } Pnts = new NCollection_HArray1(1, NbPnts); int nb = 1; if (I1 != I2) @@ -309,13 +337,17 @@ GeomFill_SectionPlacement::GeomFill_SectionPlacement(const occ::handleSetValue(nb, myAdpSection.Value(last)); + } } else // other type { int NbPnts = NbPoles - 1; if (!myAdpSection.IsClosed()) + { NbPnts++; + } Pnts = new NCollection_HArray1(1, NbPnts); delta = (last - first) / (NbPoles - 1); for (i = 0; i < NbPoles - 1; i++) @@ -324,7 +356,9 @@ GeomFill_SectionPlacement::GeomFill_SectionPlacement(const occ::handleSetValue(i + 1, myAdpSection.Value(t)); } if (!myAdpSection.IsClosed()) + { Pnts->SetValue(NbPnts, myAdpSection.Value(last)); + } } bool issing; @@ -398,7 +432,9 @@ void GeomFill_SectionPlacement::Perform(const occ::handle& Path } AngleMax = EvalAngle(VRef, dp1); if (isplan) + { AngleMax = M_PI / 2 - AngleMax; + } bool Trouve = false; int ii; @@ -410,7 +446,9 @@ void GeomFill_SectionPlacement::Perform(const occ::handle& Path gp_Vec V1(PonPath, TheAxe.Location()); DistPlan = std::abs(V1.Dot(VRef)); if (DistPlan <= IntTol) + { DistCenter = V1.Magnitude(); + } gp_Pnt Plast = Path->Value(Path->LastParameter()); V1.SetXYZ(TheAxe.Location().XYZ() - Plast.XYZ()); @@ -707,7 +745,9 @@ void GeomFill_SectionPlacement::Perform(const double Param, const double Tol) } AngleMax = EvalAngle(VRef, dp1); if (isplan) + { AngleMax = M_PI / 2 - AngleMax; + } } done = true; @@ -770,9 +810,13 @@ gp_Trsf GeomFill_SectionPlacement::Transformation(const bool WithTranslation, if (WithTranslation || WithCorrection) { if (myIsPoint) + { PSection = myPoint; + } else + { PSection = mySection->Value(SecParam); + } } // modified by NIZHNY-MKK Wed Oct 8 15:03:19 2003.BEGIN gp_Trsf Rot; @@ -782,7 +826,9 @@ gp_Trsf GeomFill_SectionPlacement::Transformation(const bool WithTranslation, double angle; if (!isplan) + { throw Standard_Failure("Illegal usage: can't rotate non-planar profile"); + } gp_Dir ProfileNormal = TheAxe.Direction(); gp_Dir SpineStartDir = Paxe.Direction(); @@ -913,18 +959,24 @@ bool GeomFill_SectionPlacement::Choix(const double dist, const double angle) con evolangle = angle - AngleMax; // (1) Si la gain en distance est > que le gabarit, on prend if (evoldist < -Gabarit) + { return true; + } // (2) si l'ecart en distance est de l'ordre du gabarit if (std::abs(evoldist) < Gabarit) { // (2.1) si le gain en angle est important on garde if (evolangle > 0.5) + { return true; + } // (2.2) si la variation d'angle est moderee on evalue // une fonction de penalite if (Penalite(angle, dist / Gabarit) < Penalite(AngleMax, Dist / Gabarit)) + { return true; + } } return false; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SimpleBound.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SimpleBound.cxx index 06c23cd814..d973f5a96d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SimpleBound.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SimpleBound.cxx @@ -41,7 +41,9 @@ gp_Pnt GeomFill_SimpleBound::Value(const double U) const { double x = U; if (!myPar.IsNull()) + { x = myPar->Value(U); + } return myC3d->Value(x); } @@ -51,7 +53,9 @@ void GeomFill_SimpleBound::D1(const double U, gp_Pnt& P, gp_Vec& V) const { double x = U, dx = 1.; if (!myPar.IsNull()) + { myPar->D1(U, x, dx); + } myC3d->D1(x, P, V); V.Multiply(dx); } @@ -77,7 +81,9 @@ void GeomFill_SimpleBound::Reparametrize(const double First, void GeomFill_SimpleBound::Bounds(double& First, double& Last) const { if (!myPar.IsNull()) + { myPar->Bounds(First, Last); + } else { First = myC3d->FirstParameter(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Sweep.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Sweep.cxx index 9f69709fdc..955bdbe1ae 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Sweep.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Sweep.cxx @@ -197,7 +197,9 @@ void GeomFill_Sweep::Build(const occ::handle& Section, // Traitement des KPart if (myKPart) + { isKPart = BuildKPart(); + } if (!isKPart) { @@ -341,7 +343,9 @@ bool GeomFill_Sweep::BuildAll(const GeomAbs_Shape Continuity, const int Degmax, } ifin += myLoc->TraceNumber(); if (myLoc->HasLastRestriction()) + { ifin++; + } for (ii = ideb, kk = 1; ii <= ifin; ii++, kk++) { @@ -394,7 +398,9 @@ bool GeomFill_Sweep::BuildProduct(const GeomAbs_Shape Continuity, occ::handle BSurf = occ::down_cast(mySec->BSplineSurface()->Copy()); if (BSurf.IsNull()) + { return Ok; // Ce mode de construction est impossible + } int NbIntervalC2, NbIntervalC3; GeomFill_LocFunction Func(myLoc); @@ -636,7 +642,9 @@ bool GeomFill_Sweep::BuildKPart() { // Modified by skv - Thu Feb 5 11:39:06 2004 OCC5073 Begin if (!IsSweepParallelSpine(myLoc, mySec, Tol)) + { return false; + } // Modified by skv - Thu Feb 5 11:39:08 2004 OCC5073 End gp_Lin L = AC.Line(); L.Transform(Tf2); @@ -651,7 +659,9 @@ bool GeomFill_Sweep::BuildKPart() S = new (Geom_Plane)(AxisOfPlane); } else + { SError = 0.; + } } // (1.1.b) Cas Cylindrique @@ -683,7 +693,9 @@ bool GeomFill_Sweep::BuildKPart() } } else + { SError = 0.; + } } // (1.1.c) C'est bien une extrusion @@ -750,7 +762,9 @@ bool GeomFill_Sweep::BuildKPart() if ((Angle > 0.01) && (Angle < M_PI / 2 - 0.01)) { if (R2 < R1) + { Angle = -Angle; + } SError = error; gp_Ax3 Axis(Centre0, Dir, N); S = new (Geom_ConicalSurface)(Axis, Angle, C.Radius()); @@ -765,7 +779,9 @@ bool GeomFill_Sweep::BuildKPart() gp_Pnt pbis; S->VIso(VLast)->D1(0, pbis, diso); if (diso.Magnitude() > 1.e-9 && dsection.Magnitude() > 1.e-9) + { isUReversed = diso.IsOpposite(dsection, 0.1); + } if (isUReversed) { double f, l; @@ -800,9 +816,13 @@ bool GeomFill_Sweep::BuildKPart() DS.SetXYZ(V.XYZ() - Centre.XYZ()); RotRadius = DS.Magnitude(); if (RotRadius > 1.e-15) + { DS.Normalize(); + } else + { return false; // Pas de KPart, rotation degeneree + } DN = DS ^ DP; DN.Normalize(); DP = DN ^ DS; @@ -855,9 +875,13 @@ bool GeomFill_Sweep::BuildKPart() DC.SetXYZ(C.Location().XYZ() - Centre.XYZ()); Radius = DC.Magnitude(); // grand Rayon du tore if ((Radius > Tol) && (DC.Dot(DS) < 0)) + { IsGoodSide = false; + } if (Radius < Tol / 100) + { DC = DS; // Pour definir le tore + } // On verifie d'abord que le plan de la section est // a // l'axe de rotation @@ -964,7 +988,9 @@ bool GeomFill_Sweep::BuildKPart() // Attention l'arete de couture dans le cas periodique // n'est peut etre pas a la bonne place... if (isUPeriodic && std::abs(UFirst) > Precision::PConfusion()) + { isUPeriodic = false; // Pour trimmer la surface... + } Ok = true; } } @@ -1021,9 +1047,13 @@ bool GeomFill_Sweep::BuildKPart() // On evalue l'angle du cone double Angle = std::abs(Dir.Angle(L)); if (Angle > M_PI / 2) + { Angle = M_PI - Angle; + } if (reverse) + { Angle = -Angle; + } aux = DS.Dot(DL); if (aux < 0) { @@ -1061,7 +1091,9 @@ bool GeomFill_Sweep::BuildKPart() } } else + { SError = 0.; + } } // (2.3) Revolution @@ -1098,16 +1130,24 @@ bool GeomFill_Sweep::BuildKPart() } if (!isUPeriodic && !isVPeriodic) + { mySurface = new (Geom_RectangularTrimmedSurface)(S, UFirst, ULast, VFirst, VLast); + } else if (isUPeriodic) { if (isVPeriodic) + { mySurface = S; + } else + { mySurface = new (Geom_RectangularTrimmedSurface)(S, VFirst, VLast, false); + } } else + { mySurface = new (Geom_RectangularTrimmedSurface)(S, UFirst, ULast, true); + } #ifdef OCCT_DEBUG if (isUPeriodic && !mySurface->IsUPeriodic()) @@ -1144,9 +1184,13 @@ void GeomFill_Sweep::ErrorOnRestriction(const bool IsFirst, double& UError, doub { int ind; if (IsFirst) + { ind = 1; + } else + { ind = myCurve2d->Length(); + } UError = CError->Value(1, ind); VError = CError->Value(2, ind); @@ -1158,7 +1202,9 @@ void GeomFill_Sweep::ErrorOnTrace(const int IndexOfTrace, double& UError, double { int ind = IndexOfTrace + 1; if (IndexOfTrace > myLoc->TraceNumber()) + { throw Standard_OutOfRange(" GeomFill_Sweep::ErrorOnTrace"); + } UError = CError->Value(1, ind); VError = CError->Value(2, ind); @@ -1176,7 +1222,9 @@ occ::handle GeomFill_Sweep::Surface() const occ::handle GeomFill_Sweep::Restriction(const bool IsFirst) const { if (IsFirst) + { return myCurve2d->Value(1); + } return myCurve2d->Value(myCurve2d->Length()); } @@ -1193,6 +1241,8 @@ occ::handle GeomFill_Sweep::Trace(const int IndexOfTrace) const { int ind = IndexOfTrace + 1; if (IndexOfTrace > myLoc->TraceNumber()) + { throw Standard_OutOfRange(" GeomFill_Sweep::Trace"); + } return myCurve2d->Value(ind); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepFunction.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepFunction.cxx index 7c78ecd84f..850ee1d9a7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepFunction.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepFunction.cxx @@ -62,10 +62,14 @@ bool GeomFill_SweepFunction::D0(const double Param, Ok = myLoc->D0(Param, M, V, Poles2d); if (!Ok) + { return Ok; + } Ok = mySec->D0(T, Poles, Weigths); if (!Ok) + { return Ok; + } for (ii = 1; ii <= L; ii++) { @@ -96,10 +100,14 @@ bool GeomFill_SweepFunction::D1(const double Param, Ok = myLoc->D1(Param, M, V, DM, DV, Poles2d, DPoles2d); if (!Ok) + { return Ok; + } Ok = mySec->D1(T, Poles, DPoles, Weigths, DWeigths); if (!Ok) + { return Ok; + } for (ii = 1; ii <= L; ii++) { @@ -141,10 +149,14 @@ bool GeomFill_SweepFunction::D2(const double Param, Ok = myLoc->D2(Param, M, V, DM, DV, D2M, D2V, Poles2d, DPoles2d, D2Poles2d); if (!Ok) + { return Ok; + } Ok = mySec->D2(T, Poles, DPoles, D2Poles, Weigths, DWeigths, D2Weigths); if (!Ok) + { return Ok; + } for (ii = 1; ii <= L; ii++) { @@ -282,7 +294,9 @@ void GeomFill_SweepFunction::Intervals(NCollection_Array1& T, const Geom GeomLib::FuseIntervals(IntS, IntL, Inter, Precision::PConfusion() * 0.99); for (ii = 1; ii <= Inter.Length(); ii++) + { T(ii) = Inter(ii); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepSectionGenerator.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepSectionGenerator.cxx index bfad8d3ef5..dbfed0c68d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepSectionGenerator.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SweepSectionGenerator.cxx @@ -100,7 +100,9 @@ void GeomFill_SweepSectionGenerator::Init(const occ::handle& Path, c myType = 4; } else + { myType = 1; + } if (Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { myPath = occ::down_cast(Path->Copy()); @@ -127,7 +129,9 @@ void GeomFill_SweepSectionGenerator::Init(const occ::handle& Path, } else + { myType = 2; + } if (Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { @@ -147,7 +151,9 @@ void GeomFill_SweepSectionGenerator::Init(const occ::handle& Path, myFirstSect = GeomConvert::CurveToBSplineCurve(FirstSect, Convert_QuasiAngular); } if (myFirstSect->IsPeriodic()) + { myFirstSect->SetNotPeriodic(); + } } //================================================================================================= @@ -167,7 +173,9 @@ void GeomFill_SweepSectionGenerator::Init(const occ::handle& Path, myType = 6; } else + { myType = 3; + } if (Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { @@ -197,9 +205,13 @@ void GeomFill_SweepSectionGenerator::Init(const occ::handle& Path, } if (myFirstSect->IsPeriodic()) + { myFirstSect->SetNotPeriodic(); + } if (myLastSect->IsPeriodic()) + { myLastSect->SetNotPeriodic(); + } // JAG @@ -313,7 +325,9 @@ void GeomFill_SweepSectionGenerator::Perform(const bool Polynomial) U = Parameters(i) + U1; if (i == myNbSections) + { U = U2; + } myPath->D1(U, P, D1); @@ -327,12 +341,14 @@ void GeomFill_SweepSectionGenerator::Perform(const bool Polynomial) Rot.SetRotation(gp_Ax1(P, gp_Dir(D1Ref ^ D1)), D1Ref.AngleWithRef(D1, D1Ref ^ D1)); } else if (D1Ref.IsOpposite(D1, Precision::Angular())) + { #ifdef OCCT_DEBUG std::cout << "Que fais-je ???? " << std::endl; #endif - // TR is the transformation between (i-1) section and the i-th. - TR = Rot * Trans; + // TR is the transformation between (i-1) section and the i-th. + TR = Rot * Trans; + } // cumulTR is the transformation between and // the i-th section. cumulTR = TR * cumulTR; @@ -445,7 +461,9 @@ bool GeomFill_SweepSectionGenerator::Section(const int P, // pour les tuyaux sur aretes pour l'instant on ne calcule pas les derivees if (myType == 0) + { return false; // a voir pour mieux. + } // calcul des derivees sur la surface // on calcule les derivees en approximant le path au voisinage du point @@ -463,7 +481,9 @@ bool GeomFill_SweepSectionGenerator::Section(const int P, U = myPath->LastParameter(); } else + { return false; + } gp_Vec D1, D2; gp_Pnt Pt; @@ -472,7 +492,9 @@ bool GeomFill_SweepSectionGenerator::Section(const int P, double l = D1.Magnitude(); if (l < Epsilon(1.)) + { return false; + } gp_Dir T = D1; double m = D2.Dot(T); @@ -548,7 +570,9 @@ void GeomFill_SweepSectionGenerator::Section(const int P, } for (int i = 1; i <= Poles.Length(); i++) + { Poles(i).Transform(cumulTR); + } } } else @@ -626,9 +650,13 @@ void GeomFill_SweepSectionGenerator::Section(const int P, occ::handle CT = new Geom_TrimmedCurve(Circ, 0., Angle); occ::handle BS; if (myPolynomial) + { BS = GeomConvert::CurveToBSplineCurve(CT, Convert_Polynomial); + } else + { BS = GeomConvert::CurveToBSplineCurve(CT, Convert_QuasiAngular); + } Poles = BS->Poles(); Weigths = BS->WeightsArray(); @@ -641,7 +669,9 @@ void GeomFill_SweepSectionGenerator::Section(const int P, const gp_Trsf& GeomFill_SweepSectionGenerator::Transformation(const int Index) const { if (Index > myTrsfs.Length()) + { throw Standard_RangeError("GeomFill_SweepSectionGenerator::Transformation"); + } return myTrsfs(Index); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS.cxx index ec5ae2ab60..e7c6a1393a 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS.cxx @@ -30,9 +30,13 @@ void GeomInt_IntSS::Perform(const occ::handle& S1, { myHS1 = new GeomAdaptor_Surface(S1); if (S1 == S2) + { myHS2 = myHS1; + } else + { myHS2 = new GeomAdaptor_Surface(S2); + } InternalPerform(Tol, Approx, ApproxS1, ApproxS2, false, 0., 0., 0., 0.); } @@ -53,9 +57,13 @@ void GeomInt_IntSS::Perform(const occ::handle& S1, { myHS1 = new GeomAdaptor_Surface(S1); if (S1 == S2) + { myHS2 = myHS1; + } else + { myHS2 = new GeomAdaptor_Surface(S2); + } InternalPerform(Tol, Approx, ApproxS1, ApproxS2, true, U1, V1, U2, V2); } @@ -176,9 +184,13 @@ gp_Pnt2d GeomInt_IntSS::Pnt2d(const int Index, const bool OnFirst) const const IntPatch_Point& thept = myIntersector.Point(Index); double U, V; if (OnFirst) + { thept.ParametersOnS1(U, V); + } else + { thept.ParametersOnS2(U, V); + } return gp_Pnt2d(U, V); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS_1.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS_1.cxx index 13767033ea..73c08a9df4 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS_1.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_IntSS_1.cxx @@ -56,7 +56,9 @@ static void AdjustUPeriodic(const occ::handle& aS, const occ::handle& aC2D) { if (aC2D.IsNull() || !aS->IsUPeriodic()) + { return; + } // constexpr double aEps = Precision::PConfusion(); // 1.e-9 const double aEpsilon = Epsilon(10.); // 1.77e-15 @@ -72,9 +74,13 @@ static void AdjustUPeriodic(const occ::handle& aS, // double aUx = aPx.X(); if (fabs(aUx) < aEpsilon) + { aUx = 0.; + } if (fabs(aUx - aPeriod) < aEpsilon) + { aUx = aPeriod; + } // double dU = 0.; while (aUx < (umin - aEps)) @@ -147,7 +153,9 @@ static bool ParametersOfNearestPointOnSurface(const Extrema_ExtPS& theExtr, double& theV) { if (!theExtr.IsDone() || !theExtr.NbExt()) + { return false; + } int anIndex = 1; double aMinSQDist = theExtr.SquareDistance(anIndex); @@ -199,19 +207,25 @@ static void IntersectCurveAndBoundary(const occ::handle& the NCollection_DynamicArray& theArrayOfParameters) { if (theC2d.IsNull()) + { return; + } Geom2dAdaptor_Curve anAC1(theC2d); for (int aCurID = 0; aCurID < theNumberOfCurves; aCurID++) { if (theArrBounds[aCurID].IsNull()) + { continue; + } Geom2dAdaptor_Curve anAC2(theArrBounds[aCurID]); Geom2dInt_GInter anIntCC2d(anAC1, anAC2, theTol, theTol); if (!anIntCC2d.IsDone() || anIntCC2d.IsEmpty()) + { continue; + } for (int aPntID = 1; aPntID <= anIntCC2d.NbPoints(); aPntID++) { @@ -246,7 +260,9 @@ static bool isDegenerated(const occ::handle& theGAHS, theGAHS->D0(aP2d.X(), aP2d.Y(), aP2); if (aP1.SquareDistance(aP2) > aSqTol) + { return false; + } theAHC2d->D0(0.5 * (theFirstPar + theLastPar), aP2d); theGAHS->D0(aP2d.X(), aP2d.Y(), aP2); @@ -926,7 +942,9 @@ void GeomInt_IntSS::MakeCurve(const int Index, { // Avoid creating B-splines containing two coincident poles only if (mbspc.Degree() == 1 && nbpoles == 2) + { continue; + } if (!BS->IsClosed() && !BS->IsPeriodic()) { @@ -994,7 +1012,9 @@ void GeomInt_IntSS::MakeCurve(const int Index, TreatRLine(RL, myHS1, myHS2, aC3d, aC2d1, aC2d2, aTolReached); if (aC3d.IsNull()) + { break; + } Bnd_Box2d aBox1, aBox2; @@ -1024,7 +1044,9 @@ void GeomInt_IntSS::MakeCurve(const int Index, const double aParF = anArrayOfParameters(anInd), aParL = anArrayOfParameters(anInd + 1); if ((aParL - aParF) <= Precision::PConfusion()) + { continue; + } const double aPar = 0.5 * (aParF + aParL); gp_Pnt2d aPt; @@ -1035,10 +1057,14 @@ void GeomInt_IntSS::MakeCurve(const int Index, aC2d1->D0(aPar, aPt); if (aBox1.IsOut(aPt)) + { continue; + } if (myApprox1) + { aCurv2d1 = new Geom2d_TrimmedCurve(aC2d1, aParF, aParL); + } } if (!aC2d2.IsNull()) @@ -1046,10 +1072,14 @@ void GeomInt_IntSS::MakeCurve(const int Index, aC2d2->D0(aPar, aPt); if (aBox2.IsOut(aPt)) + { continue; + } if (myApprox2) + { aCurv2d2 = new Geom2d_TrimmedCurve(aC2d2, aParF, aParL); + } } occ::handle aCurv3d = new Geom_TrimmedCurve(aC3d, aParF, aParL); @@ -1105,7 +1135,9 @@ void GeomInt_IntSS::TreatRLine(const occ::handle& theRL, // Restriction line can correspond to a degenerated edge. // In this case we return null-curve. if (isDegenerated(aGAHS, anAHC2d, tf, tl)) + { return; + } // // To provide sameparameter it is necessary to get 3d curve as @@ -1115,7 +1147,9 @@ void GeomInt_IntSS::TreatRLine(const occ::handle& theRL, Approx_CurveOnSurface anApp(anAHC2d, aGAHS, tf, tl, Precision::Confusion()); anApp.Perform(aMaxSeg, aMaxDeg, GeomAbs_C1, true, false); if (!anApp.HasResult()) + { return; + } theC3d = anApp.Curve3d(); theTolReached = anApp.MaxError3d(); @@ -1323,14 +1357,18 @@ void GeomInt_IntSS::TrimILineOnSurfBoundaries( aCurS1Bounds[0] = new Geom2d_Line(gp_Pnt2d(aU1f, aV1f), gp_Dir2d(gp_Dir2d::D::Y)); if (!Precision::IsInfinite(aDelta)) + { aCurS1Bounds[0] = new Geom2d_TrimmedCurve(aCurS1Bounds[0], 0, aDelta); + } } if (!Precision::IsInfinite(aU1l)) { aCurS1Bounds[1] = new Geom2d_Line(gp_Pnt2d(aU1l, aV1f), gp_Dir2d(gp_Dir2d::D::Y)); if (!Precision::IsInfinite(aDelta)) + { aCurS1Bounds[1] = new Geom2d_TrimmedCurve(aCurS1Bounds[1], 0, aDelta); + } } } @@ -1341,14 +1379,18 @@ void GeomInt_IntSS::TrimILineOnSurfBoundaries( { aCurS1Bounds[2] = new Geom2d_Line(gp_Pnt2d(aU1f, aV1f), gp_Dir2d(gp_Dir2d::D::X)); if (!Precision::IsInfinite(aDelta)) + { aCurS1Bounds[2] = new Geom2d_TrimmedCurve(aCurS1Bounds[2], 0, aDelta); + } } if (!Precision::IsInfinite(aV1l)) { aCurS1Bounds[3] = new Geom2d_Line(gp_Pnt2d(aU1f, aV1l), gp_Dir2d(gp_Dir2d::D::X)); if (!Precision::IsInfinite(aDelta)) + { aCurS1Bounds[3] = new Geom2d_TrimmedCurve(aCurS1Bounds[3], 0, aDelta); + } } } @@ -1359,14 +1401,18 @@ void GeomInt_IntSS::TrimILineOnSurfBoundaries( { aCurS2Bounds[0] = new Geom2d_Line(gp_Pnt2d(aU2f, aV2f), gp_Dir2d(gp_Dir2d::D::Y)); if (!Precision::IsInfinite(aDelta)) + { aCurS2Bounds[0] = new Geom2d_TrimmedCurve(aCurS2Bounds[0], 0, aDelta); + } } if (!Precision::IsInfinite(aU2l)) { aCurS2Bounds[1] = new Geom2d_Line(gp_Pnt2d(aU2l, aV2f), gp_Dir2d(gp_Dir2d::D::Y)); if (!Precision::IsInfinite(aDelta)) + { aCurS2Bounds[1] = new Geom2d_TrimmedCurve(aCurS2Bounds[1], 0, aDelta); + } } } @@ -1377,14 +1423,18 @@ void GeomInt_IntSS::TrimILineOnSurfBoundaries( { aCurS2Bounds[2] = new Geom2d_Line(gp_Pnt2d(aU2f, aV2f), gp_Dir2d(gp_Dir2d::D::X)); if (!Precision::IsInfinite(aDelta)) + { aCurS2Bounds[2] = new Geom2d_TrimmedCurve(aCurS2Bounds[2], 0, aDelta); + } } if (!Precision::IsInfinite(aV2l)) { aCurS2Bounds[3] = new Geom2d_Line(gp_Pnt2d(aU2f, aV2l), gp_Dir2d(gp_Dir2d::D::X)); if (!Precision::IsInfinite(aDelta)) + { aCurS2Bounds[3] = new Geom2d_TrimmedCurve(aCurS2Bounds[3], 0, aDelta); + } } } @@ -1435,9 +1485,13 @@ occ::handle GeomInt_IntSS::MakeBSpline2d( { double U, V; if (onFirst) + { theWLine->Point(ipidebm1).ParametersOnS1(U, V); + } else + { theWLine->Point(ipidebm1).ParametersOnS2(U, V); + } poles(i).SetCoord(U, V); mults(i) = 1; knots(i) = i - 1; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineConstructor.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineConstructor.cxx index fc982ccaaa..2215d7a01f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineConstructor.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineConstructor.cxx @@ -707,7 +707,9 @@ void GeomInt_LineConstructor::TreatCircle(const occ::handle& theL const double aT2 = aVtxArr(i + 1).Getvertex().ParameterOnLine(); if (aT2 == RealLast()) + { break; + } const double aTmid = (aT1 + aT2) * 0.5; GLinePoint(aType, aGLine, aTmid, aPmid); @@ -936,7 +938,9 @@ void RejectDuplicates(NCollection_Array1& theVtxArr) const double aPrmi = aVi.ParameterOnLine(); if (aPrmi == RealLast()) + { continue; + } for (int j = i + 1; j <= theVtxArr.Upper() - 1; j++) { @@ -963,7 +967,9 @@ void RejectDuplicates(NCollection_Array1& theVtxArr) const double aPrmi = aVi.ParameterOnLine(); if (aPrmi == RealLast()) + { continue; + } if ((aMaxPrm - aPrmi) < aTolPC) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineTool.cxx index 4b93667090..ea717b27be 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomInt/GeomInt_LineTool.cxx @@ -156,7 +156,9 @@ static bool IsPointOnBoundary(const double theParameter, { IsOnFirstBoundary = true; if (fabs(theParameter - theFirstBoundary) < theResolution) + { return true; + } if (fabs(theParameter - theSecondBoundary) < theResolution) { IsOnFirstBoundary = false; @@ -192,9 +194,13 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, anOtherVecNormal.SetY(0.); if (i < 2) + { aprojpoint.SetX(theUmin); + } else + { aprojpoint.SetX(theUmax); + } } else { @@ -204,16 +210,22 @@ static bool FindPoint(const gp_Pnt2d& theFirstPoint, anOtherVecNormal.SetY(1.); if (i < 2) + { aprojpoint.SetY(theVmin); + } else + { aprojpoint.SetY(theVmax); + } } gp_Vec2d anormvec = aVec; anormvec.Normalize(); double adot1 = anormvec.Dot(anOtherVecNormal); if (fabs(adot1) < Precision::Angular()) + { continue; + } double adist = 0.; if ((i % 2) == 0) @@ -310,11 +322,15 @@ double GeomInt_LineTool::FirstParameter(const occ::handle& L) case IntPatch_Analytic: { occ::handle alin = occ::down_cast(L); if (alin->HasFirstPoint()) + { return alin->FirstPoint().ParameterOnLine(); + } bool included; double firstp = alin->FirstParameter(included); if (!included) + { firstp += Epsilon(firstp); + } return firstp; } @@ -333,7 +349,9 @@ double GeomInt_LineTool::FirstParameter(const occ::handle& L) default: { occ::handle glin = occ::down_cast(L); if (glin->HasFirstPoint()) + { return glin->FirstPoint().ParameterOnLine(); + } switch (typl) { case IntPatch_Lin: @@ -358,11 +376,15 @@ double GeomInt_LineTool::LastParameter(const occ::handle& L) case IntPatch_Analytic: { occ::handle alin = occ::down_cast(L); if (alin->HasLastPoint()) + { return alin->LastPoint().ParameterOnLine(); + } bool included; double lastp = alin->LastParameter(included); if (!included) + { lastp -= Epsilon(lastp); + } return lastp; } @@ -381,7 +403,9 @@ double GeomInt_LineTool::LastParameter(const occ::handle& L) default: { occ::handle glin = occ::down_cast(L); if (glin->HasLastPoint()) + { return glin->LastPoint().ParameterOnLine(); + } switch (typl) { case IntPatch_Lin: @@ -696,9 +720,13 @@ bool GeomInt_LineTool::DecompositionOfWLine( double nU1, nV1; if (surfit == 0) + { aNeighbourPoint.ParametersOnS1(nU1, nV1); + } else + { aNeighbourPoint.ParametersOnS2(nU1, nV1); + } double adist1 = (bIsUBoundary) ? fabs(nU1 - U) : fabs(nV1 - V); double adist2 = (bIsUBoundary) ? fabs(nU1 - anotherPar) : fabs(nV1 - anotherPar); @@ -744,9 +772,13 @@ bool GeomInt_LineTool::DecompositionOfWLine( double nU2, nV2; if (surfit == 0) + { aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); + } else + { aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); + } gp_Vec2d aVecOld(gp_Pnt2d(nU2, nV2), gp_Pnt2d(nU1, nV1)); if (aVecOld.SquareMagnitude() <= (gp::Resolution() * gp::Resolution())) @@ -796,9 +828,13 @@ bool GeomInt_LineTool::DecompositionOfWLine( double nU1, nV1; if (surfit == 0) + { aNeighbourPoint.ParametersOnS1(nU1, nV1); + } else + { aNeighbourPoint.ParametersOnS2(nU1, nV1); + } gp_Pnt2d ap1(nU1, nV1); gp_Pnt2d ap2(nU1, nV1); int aneighbourpointindex2 = aneighbourpointindex1; @@ -812,9 +848,13 @@ bool GeomInt_LineTool::DecompositionOfWLine( double nU2, nV2; if (surfit == 0) + { aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); + } else + { aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); + } ap2.SetX(nU2); ap2.SetY(nV2); @@ -847,9 +887,13 @@ bool GeomInt_LineTool::DecompositionOfWLine( aProjector.LowerDistanceParameters(foundU, foundV); if (surfit == 0) + { aNewP.SetValue(aP3d, anewpoint.X(), anewpoint.Y(), foundU, foundV); + } else + { aNewP.SetValue(aP3d, foundU, foundV, anewpoint.X(), anewpoint.Y()); + } } } } @@ -961,7 +1005,9 @@ bool GeomInt_LineTool::DecompositionOfWLine( for (; anIt.More(); anIt.Next()) { if ((anIt.Value() < ifprm) || (anIt.Value() > ilprm)) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); aLineOn2S->Add(aP); } @@ -977,7 +1023,9 @@ bool GeomInt_LineTool::DecompositionOfWLine( for (; anIt.More(); anIt.Next()) { if (anIt.Value() < ifprm) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); aLineOn2S->Add(aP); } @@ -1027,7 +1075,9 @@ bool GeomInt_LineTool::DecompositionOfWLine( for (; anIt.More(); anIt.Next()) { if (anIt.Value() > ilprm) + { continue; + } const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); aLineOn2S->Add(aP); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildAveragePlane.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildAveragePlane.cxx index ae19831e8f..22abcb5417 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildAveragePlane.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildAveragePlane.cxx @@ -82,13 +82,21 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( { ElSLib::Parameters(P, myPts->Value(i), U, V); if (myUmax < U) + { myUmax = U; + } if (myUmin > U) + { myUmin = U; + } if (myVmax < V) + { myVmax = V; + } if (myVmin > V) + { myVmin = V; + } } } @@ -109,7 +117,9 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( int NN = Normals.Length(); if (NN == 1) + { BestVec = Normals(1); + } else if (NN == 2) { BestVec = Normals(1) + Normals(2); @@ -119,9 +129,13 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( const double aSq1 = Normals(1).SquareMagnitude(), aSq2 = Normals(2).SquareMagnitude(); if (aSq1 > aSq2) + { BestVec = Normals(1).Normalized(); + } else + { BestVec = Normals(2).Normalized(); + } } else { @@ -132,12 +146,16 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( { double MaxAngle = 0.; for (i = 1; i <= NN - 1; i++) + { for (j = i + 1; j <= NN; j++) { double Angle = Normals(i).Angle(Normals(j)); if (Angle > MaxAngle) + { MaxAngle = Angle; + } } + } MaxAngle *= 1.2; MaxAngle /= 2.; int Nint = 50; @@ -149,6 +167,7 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( k = 1; for (i = 1; i <= NN - 1; i++) + { for (j = i + 1; j <= NN; j++, k++) { OptScal(k) = RealFirst(); @@ -180,7 +199,9 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( { double Scal = Vec1 * Normals(m); if (Scal < minScal) + { minScal = Scal; + } } if (minScal > OptScal(k)) { @@ -189,16 +210,19 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( } } } // for i, for j + } // Find maximum among all maximums double BestScal = RealFirst(); int Index = 0; for (k = 1; k <= OptScal.Length(); k++) + { if (OptScal(k) > BestScal) { BestScal = OptScal(k); Index = k; } + } BestVec = OptVec(Index); } @@ -207,7 +231,9 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( bool IsSingular; NCollection_Array1 PtsArray(1, myPts->Length()); for (i = 1; i <= myPts->Length(); i++) + { PtsArray(i) = myPts->Value(i); + } GeomLib::AxeOfInertia(PtsArray, Axe, IsSingular); gp_Dir BestDir(BestVec); gp_Dir XDir = BestDir ^ Axe.XDirection(); @@ -228,17 +254,23 @@ GeomPlate_BuildAveragePlane::GeomPlate_BuildAveragePlane( gp_Vec NormVec = Pln.Axis().Direction(); NormVec = (aVec * NormVec) * NormVec; - // clang-format off - ElSLib::Parameters( Pln, myPts->Value(i).Translated( -NormVec ), U, V ); //????? Real projecting? - // clang-format on + ElSLib::Parameters(Pln, myPts->Value(i).Translated(-NormVec), U, V); if (U > myUmax) + { myUmax = U; + } if (U < myUmin) + { myUmin = U; + } if (V > myVmax) + { myVmax = V; + } if (V < myVmin) + { myVmin = V; + } } // Initializing myOX, myOY myOX = myPlane->Pln().XAxis().Direction(); @@ -318,9 +350,13 @@ gp_Vec GeomPlate_BuildAveragePlane::DefPlan(const int NOption) gp_Vec OZ1 = A; double theAngle = OZ.Angle(OZ1); if (theAngle > M_PI / 2) + { theAngle = M_PI - theAngle; + } if (theAngle > M_PI / 3) + { OZ = OZ1; + } } } @@ -505,7 +541,9 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& // 2 Cross = NewNormals(1) ^ NewNormals(2); if (Cross.SquareMagnitude() <= SquareTol) + { return false; + } Cross.Normalize(); Bset.Append(GeomPlate_Aij(1, 2, Cross)); @@ -520,14 +558,20 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& // 3 double Scal; for (j = 1; j <= Bset.Length(); j++) + { if ((Scal = Bset(j).Vec * NewNormals(i)) >= -LinTol) + { B2set.Append(Bset(j)); + } + } int ii = Normals.Length() + 1; for (j = 1; j <= ii - 1; j++) { if (Normals(j).SquareMagnitude() == 0.) + { continue; + } // 4 Cross = NewNormals(i) ^ Normals(j); if (Cross.SquareMagnitude() <= SquareTol) @@ -539,6 +583,7 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& Cross.Normalize(); bool isNew = true; for (k = 1; k <= B2set.Length(); k++) + { if (B2set(k).Vec.IsOpposite(-Cross, AngTol)) // if (B2set(k).Vec.IsEqual( Cross, LinTol, AngTol )) { @@ -575,17 +620,23 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& B2set(k).Ind1 = ii; } else + { B2set(k).Ind1 = ii; + } } isNew = false; break; } + } if (isNew) + { B1set.Append(GeomPlate_Aij(ii, j, Cross)); + } Cross.Reverse(); isNew = true; for (k = 1; k <= B2set.Length(); k++) + { if (B2set(k).Vec.IsOpposite(-Cross, AngTol)) // if (B2set(k).Vec.IsEqual( Cross, LinTol, AngTol )) { @@ -622,13 +673,18 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& B2set(k).Ind1 = ii; } else + { B2set(k).Ind1 = ii; + } } isNew = false; break; } + } if (isNew) + { B1set.Append(GeomPlate_Aij(ii, j, Cross)); + } } // 5 @@ -638,7 +694,9 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& for (k = 1; k <= Normals.Length(); k++) { if (Normals(k).SquareMagnitude() == 0.) + { continue; + } if (B1set(j).Vec * Normals(k) < -LinTol) { isGEnull = false; @@ -646,7 +704,9 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& } } if (isGEnull) + { B2set.Append(B1set(j)); + } } // 6 @@ -667,16 +727,22 @@ bool GeomPlate_BuildAveragePlane::HalfSpace(const NCollection_Sequence& for (j = 1; j <= Normals.Length(); j++) { if (Normals(j).SquareMagnitude() == 0.) + { continue; + } bool isFound = false; for (k = 1; k <= Bset.Length(); k++) + { if (j == Bset(k).Ind1 || j == Bset(k).Ind2) { isFound = true; break; } + } if (!isFound) + { Normals(j) = NullVec; + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildPlateSurface.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildPlateSurface.cxx index 66bb07afa3..e431ffbac1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildPlateSurface.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_BuildPlateSurface.cxx @@ -102,12 +102,18 @@ GeomPlate_BuildPlateSurface::GeomPlate_BuildPlateSurface( myLinCont = new NCollection_HSequence>; myPntCont = new NCollection_HSequence>; if (myNbIter < 1) + { throw Standard_ConstructionError("GeomPlate : Number of iteration must be >= 1"); + } if (NTCurve == 0) + { throw Standard_ConstructionError("GeomPlate : the bounds Array is null"); + } if (Tang->Length() == 0) + { throw Standard_ConstructionError("GeomPlate : the constraints Array is null"); + } int nbp = 0; int i; for (i = 1; i <= NTCurve; i++) @@ -115,10 +121,14 @@ GeomPlate_BuildPlateSurface::GeomPlate_BuildPlateSurface( nbp += NPoints->Value(i); } if (nbp == 0) + { throw Standard_ConstructionError( "GeomPlate : the resolution is impossible if the number of constraints points is 0"); + } if (myDegree < 2) + { throw Standard_ConstructionError("GeomPlate ; the degree resolution must be upper of 2"); + } // Filling fields passing from the old constructor to the new one for (i = 1; i <= NTCurve; i++) { @@ -156,9 +166,13 @@ GeomPlate_BuildPlateSurface::GeomPlate_BuildPlateSurface(const occ::handle= 1"); + } if (myDegree < 2) + { throw Standard_ConstructionError("GeomPlate : the degree must be above 2"); + } myLinCont = new NCollection_HSequence>; myPntCont = new NCollection_HSequence>; mySurfInitIsGive = true; @@ -189,9 +203,13 @@ GeomPlate_BuildPlateSurface::GeomPlate_BuildPlateSurface(const int Degree, myNbBounds(0) { if (myNbIter < 1) + { throw Standard_ConstructionError("GeomPlate : Number of iteration must be >= 1"); + } if (myDegree < 2) + { throw Standard_ConstructionError("GeomPlate : the degree resolution must be upper of 2"); + } myLinCont = new NCollection_HSequence>; myPntCont = new NCollection_HSequence>; mySurfInitIsGive = false; @@ -224,7 +242,9 @@ static void TrierTab(occ::handle>& Tab) int Nb = Tab->Length(); NCollection_Array1 TabTri(1, Nb); for (int i = 1; i <= Nb; i++) + { TabTri.SetValue(Tab->Value(i), i); + } Tab->ChangeArray1() = TabTri; } @@ -427,7 +447,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre #endif if (myNbBounds == 0) + { myNbBounds = myLinCont->Length(); + } myPlate.Init(); //===================================================================== @@ -452,7 +474,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre { ComputeSurfInit(aPS.Next(10)); if (aPS.UserBreak()) + { return; + } } else @@ -461,7 +485,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre { // Table of transformations to preserve the initial order, see TrierTab myInitOrder = new NCollection_HArray1(1, NTLinCont); for (int l = 1; l <= NTLinCont; l++) + { myInitOrder->SetValue(l, l); + } if (!CourbeJointive(myTol3d)) { // throw Standard_Failure("Curves are not joined"); #ifdef OCCT_DEBUG @@ -494,6 +520,7 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre //====================================================================== bool Ok = true; for (int i = 1; i <= NTLinCont; i++) + { if (myLinCont->Value(i)->Curve2dOnSurf().IsNull()) { occ::handle Curve2d = ProjectCurve(myLinCont->Value(i)->Curve3d()); @@ -504,6 +531,7 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre } myLinCont->ChangeValue(i)->SetCurve2dOnSurf(Curve2d); } + } if (!Ok) { GeomPlate_MakeApprox App(myGeomPlateSurface, myTol3d, 1, 3, 15 * myTol3d, -1, GeomAbs_C0, 1.3); @@ -537,7 +565,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre myProj.Initialize(SurfNew, u1, v1, u2, v2, myTolU, myTolV); for (int i = 1; i <= NTLinCont; i++) + { myLinCont->ChangeValue(i)->SetCurve2dOnSurf(ProjectCurve(myLinCont->Value(i)->Curve3d())); + } } else { // Project the points @@ -567,7 +597,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre // Number of points by curve //====================================================================== if ((NTLinCont != 0) && (myNbPtsOnCur != 0)) + { CalculNbPtsInit(); + } //====================================================================== // Management of incompatibilites between curves @@ -607,8 +639,12 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre //==================================================================== int NPointMax = 0; for (int i = 1; i <= NTLinCont; i++) + { if ((myLinCont->Value(i)->NbPoints()) > NPointMax) + { NPointMax = (int)(myLinCont->Value(i)->NbPoints()); + } + } //==================================================================== // Discretization of curves //==================================================================== @@ -618,7 +654,9 @@ void GeomPlate_BuildPlateSurface::Perform(const Message_ProgressRange& theProgre //==================================================================== LoadCurve(NbBoucle); if (myPntCont->Length() != 0) + { LoadPoint(NbBoucle); + } //==================================================================== // Construction of the surface //==================================================================== @@ -719,9 +757,13 @@ void GeomPlate_BuildPlateSurface::EcartContraintesMil( int NbPt = myParCont->Value(c).Length(); double U; if (NbPt < 3) + { NbPt = 4; + } else + { NbPt = myParCont->Value(c).Length(); + } gp_Vec v1i, v1f, v2i, v2f, v3i, v3f; gp_Pnt Pi, Pf; gp_Pnt2d P2d; @@ -735,13 +777,19 @@ void GeomPlate_BuildPlateSurface::EcartContraintesMil( U = (myParCont->Value(c).Value(i) + myParCont->Value(c).Value(i + 1)) / 2; LinCont->D0(U, Pi); if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value(U); + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value(U); + } else + { P2d = ProjectPoint(Pi); + } } myGeomPlateSurface->D0(P2d.Coord(1), P2d.Coord(2), Pf); an->Init(0); @@ -755,13 +803,19 @@ void GeomPlate_BuildPlateSurface::EcartContraintesMil( U = (myParCont->Value(c).Value(i) + myParCont->Value(c).Value(i + 1)) / 2; LinCont->D1(U, Pi, v1i, v2i); if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value(U); + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value(U); + } else + { P2d = ProjectPoint(Pi); + } } myGeomPlateSurface->D1(P2d.Coord(1), P2d.Coord(2), Pf, v1f, v2f); d->ChangeValue(i) = Pf.Distance(Pi); @@ -769,9 +823,13 @@ void GeomPlate_BuildPlateSurface::EcartContraintesMil( v3f = v1f ^ v2f; double angle = v3f.Angle(v3i); if (angle > (M_PI / 2)) + { an->ChangeValue(i) = M_PI - angle; + } else + { an->ChangeValue(i) = angle; + } courb->Init(0); } break; @@ -783,13 +841,19 @@ void GeomPlate_BuildPlateSurface::EcartContraintesMil( U = (myParCont->Value(c).Value(i) + myParCont->Value(c).Value(i + 1)) / 2; LinCont->D0(U, Pi); if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value(U); + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value(U); + } else + { P2d = ProjectPoint(Pi); + } } GeomLProp_SLProps Prop(Splate, P2d.Coord(1), P2d.Coord(2), 2, 0.001); CG2.ComputeAnalysis(Prop, myLinCont->Value(c)->LPropSurf(U), GeomAbs_G2); @@ -828,6 +892,7 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, myProj.Initialize(Surf, u1, v1, u2, v2, myTolU, myTolV); for (i = 1; i <= NTPntCont; i++) + { if (myPntCont->Value(i)->Order() != -1) { P2d = myPntCont->Value(i)->Pnt2dOnSurf(); @@ -835,6 +900,7 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, UV.SetY(P2d.Coord(2)); Seq2d.Append(UV); } + } for (i = 1; i <= NTCurve; i++) { occ::handle LinCont = myLinCont->Value(i); @@ -843,13 +909,15 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, int NbPt = myParCont->Value(i).Length(); // first point of constraint (j=0) if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value(myParCont->Value(i).Value(1)); - + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value(myParCont->Value(i).Value(1)); - + } else { LinCont->D0(myParCont->Value(i).Value(1), PP); @@ -864,13 +932,15 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, { double Uj = myParCont->Value(i).Value(j), Ujp1 = myParCont->Value(i).Value(j + 1); if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value((Ujp1 + 3 * Uj) / 4); - + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value((Ujp1 + 3 * Uj) / 4); - + } else { LinCont->D0((Ujp1 + 3 * Uj) / 4, PP); @@ -882,13 +952,15 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, Seq2d.Append(UV); // point 1/2 previous if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value((Ujp1 + Uj) / 2); - + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value((Ujp1 + Uj) / 2); - + } else { LinCont->D0((Ujp1 + Uj) / 2, PP); @@ -901,13 +973,15 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, Seq2d.Append(UV); // point 3/4 previous if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value((3 * Ujp1 + Uj) / 4); - + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value((3 * Ujp1 + Uj) / 4); - + } else { LinCont->D0((3 * Ujp1 + Uj) / 4, PP); @@ -920,13 +994,15 @@ void GeomPlate_BuildPlateSurface::Disc2dContour(const int /*nbp*/, Seq2d.Append(UV); // current constraint point if (!LinCont->ProjectedCurve().IsNull()) + { P2d = LinCont->ProjectedCurve()->Value(Ujp1); - + } else { if (!LinCont->Curve2dOnSurf().IsNull()) + { P2d = LinCont->Curve2dOnSurf()->Value(Ujp1); - + } else { LinCont->D0(Ujp1, PP); @@ -971,6 +1047,7 @@ void GeomPlate_BuildPlateSurface::Disc3dContour(const int /*nbp*/, int i; for (i = 1; i <= NTPntCont; i++) + { if (myPntCont->Value(i)->Order() != -1) { if (iordre == 0) @@ -991,8 +1068,10 @@ void GeomPlate_BuildPlateSurface::Disc3dContour(const int /*nbp*/, Seq3d.Append(Pos); } } + } for (i = 1; i <= NTCurve; i++) + { if (myLinCont->Value(i)->Order() != -1) { @@ -1080,6 +1159,7 @@ void GeomPlate_BuildPlateSurface::Disc3dContour(const int /*nbp*/, } } } + } } //--------------------------------------------------------- @@ -1114,7 +1194,9 @@ occ::handle> GeomPlate_BuildPlateSurface::Sense() const int NTCurve = myLinCont->Length(); occ::handle> Sens = new NCollection_HArray1(1, NTCurve); for (int i = 1; i <= NTCurve; i++) + { Sens->SetValue(i, mySense->Value(myInitOrder->Value(i))); + } return Sens; } @@ -1129,7 +1211,9 @@ occ::handle>> GeomPlate_BuildPlate new NCollection_HArray1>(1, NTCurve); for (int i = 1; i <= NTCurve; i++) + { C2dfin->SetValue(i, myLinCont->Value(myInitOrder->Value(i))->Curve2dOnSurf()); + } return C2dfin; } @@ -1141,7 +1225,9 @@ occ::handle> GeomPlate_BuildPlateSurface::Order() const occ::handle> result = new NCollection_HArray1(1, myLinCont->Length()); for (int i = 1; i <= myLinCont->Length(); i++) + { result->SetValue(myInitOrder->Value(i), i); + } return result; } @@ -1182,8 +1268,12 @@ double GeomPlate_BuildPlateSurface::G0Error(const int Index) EcartContraintesMil(Index, tdistance, tangle, tcurvature); double MaxDistance = 0.; for (int i = 1; i <= myNbPtsOnCur; i++) + { if (tdistance->Value(i) > MaxDistance) + { MaxDistance = tdistance->Value(i); + } + } return MaxDistance; } @@ -1200,8 +1290,12 @@ double GeomPlate_BuildPlateSurface::G1Error(const int Index) EcartContraintesMil(Index, tdistance, tangle, tcurvature); double MaxAngle = 0.; for (int i = 1; i <= myNbPtsOnCur; i++) + { if (tangle->Value(i) > MaxAngle) + { MaxAngle = tangle->Value(i); + } + } return MaxAngle; } @@ -1218,8 +1312,12 @@ double GeomPlate_BuildPlateSurface::G2Error(const int Index) EcartContraintesMil(Index, tdistance, tangle, tcurvature); double MaxCurvature = 0.; for (int i = 1; i <= myNbPtsOnCur; i++) + { if (tcurvature->Value(i) > MaxCurvature) + { MaxCurvature = tcurvature->Value(i); + } + } return MaxCurvature; } @@ -1280,7 +1378,9 @@ bool GeomPlate_BuildPlateSurface::CourbeJointive(const double tolerance) Uinit2 = myLinCont->Value(i)->FirstParameter(); Ufinal2 = myLinCont->Value(i)->LastParameter(); if (mySense->Value(j) == 1) + { Ufinal1 = Uinit1; + } myLinCont->Value(j)->D0(Ufinal1, P1); myLinCont->Value(i)->D0(Uinit2, P2); if (P1.Distance(P2) < tolerance) @@ -1339,7 +1439,9 @@ bool GeomPlate_BuildPlateSurface::CourbeJointive(const double tolerance) return ((result)); } else + { return false; + } } //================================================================================================= @@ -1362,7 +1464,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t { myInitOrder = new NCollection_HArray1(1, NTLinCont); for (int i = 1; i <= NTLinCont; i++) + { myInitOrder->SetValue(i, i); + } } bool CourbeJoint = (NTLinCont != 0) && CourbeJointive(myTol3d); @@ -1401,7 +1505,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t myLinCont->Value(i)->D1(Uinit, P, Vec1, Vec2); Normal = Vec1 ^ Vec2; if (LastVec.IsOpposite(Normal, AngTol)) + { ToReverse = true; + } } for (int j = 0; j <= NbPoint; j++) @@ -1409,38 +1515,52 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t // Linear distribution double Inter = j * Uif / (NbPoint); if (Order < GeomAbs_G1 || j % Discr != 0) + { myLinCont->Value(i)->D0(Uinit + Inter, Pts->ChangeValue(++pnum)); + } else { myLinCont->Value(i)->D1(Uinit + Inter, Pts->ChangeValue(++pnum), Vec1, Vec2); Normal = Vec1 ^ Vec2; Normal.Normalize(); if (ToReverse) + { Normal.Reverse(); + } bool isNew = true; int k; for (k = 1; k <= Vecs.Length(); k++) + { if (Vecs(k).IsEqual(Normal, LinTol, AngTol)) { isNew = false; break; } + } if (isNew) + { for (k = 1; k <= NewVecs.Length(); k++) + { if (NewVecs(k).IsEqual(Normal, LinTol, AngTol)) { isNew = false; break; } + } + } if (isNew) + { NewVecs.Append(Normal); + } } } if (Order >= GeomAbs_G1) { isHalfSpace = GeomPlate_BuildAveragePlane::HalfSpace(NewVecs, Vecs, Aset, LinTol, AngTol); if (!isHalfSpace) + { break; + } LastVec = Normal; } } // for (i = 1; i <= NTLinCont; i++) @@ -1454,7 +1574,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t NewVecs.Clear(); gp_Vec Vec1, Vec2, Normal; if (Order < GeomAbs_G1) + { myPntCont->Value(i)->D0(Pts->ChangeValue(++pnum)); + } else { myPntCont->Value(i)->D1(Pts->ChangeValue(++pnum), Vec1, Vec2); @@ -1462,11 +1584,13 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t Normal.Normalize(); bool isNew = true; for (int k = 1; k <= Vecs.Length(); k++) + { if (Vecs(k).IsEqual(Normal, LinTol, AngTol)) { isNew = false; break; } + } if (isNew) { NewVecs.Append(Normal); @@ -1479,7 +1603,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t GeomPlate_BuildAveragePlane::HalfSpace(NewVecs, Vecs, Aset, LinTol, AngTol); } if (!isHalfSpace) + { break; + } } } } // for (i = 1; i <= NTPntCont; i++) @@ -1491,12 +1617,14 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t { NullExist = false; for (i = 1; i <= Vecs.Length(); i++) + { if (Vecs(i).SquareMagnitude() == 0.) { NullExist = true; Vecs.Remove(i); break; } + } } GeomPlate_BuildAveragePlane BAP(Vecs, Pts); double u1, u2, v1, v2; @@ -1522,12 +1650,16 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t } // if (NTLinCont != 0 && (CourbeJoint = CourbeJointive( myTol3d )) && IsOrderG1()) if (NTLinCont != 0) + { TrierTab(myInitOrder); // Reorder the table of transformations + } if (nopt != 3) { if (NTPntCont != 0) + { nopt = 1; // Calculate by the method of plane of inertia + } else if (!CourbeJoint || NTLinCont != myNbBounds) { // throw Standard_Failure("Curves are not joined"); #ifdef OCCT_DEBUG @@ -1541,12 +1673,16 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t int NTPoint = 20 * NTLinCont; int i; for (i = 1; i <= NTLinCont; i++) + { LenT += myLinCont->Value(i)->Length(); + } for (i = 1; i <= NTLinCont; i++) { int NbPoint = (int)(NTPoint * (myLinCont->Value(i)->Length()) / LenT); if (NbPoint < 10) + { NbPoint = 10; + } (void)Npt; // unused but set for debug Npt += NbPoint; @@ -1582,7 +1718,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t Pts->SetValue(Np++, P); } if (!CourbeJoint) + { myNbBounds = 0; + } GeomPlate_BuildAveragePlane BAP(Pts, NbPoint * myNbBounds, myTol3d / 1000, popt, nopt); if (!BAP.IsPlane()) { @@ -1678,8 +1816,12 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t //====================================================================== int i; for (i = 1; i <= NTLinCont; i++) + { if (myLinCont->Value(i)->Curve2dOnSurf().IsNull()) + { myLinCont->ChangeValue(i)->SetCurve2dOnSurf(ProjectCurve(myLinCont->Value(i)->Curve3d())); + } + } //====================================================================== // Projection of points @@ -1689,14 +1831,18 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t gp_Pnt P; myPntCont->Value(i)->D0(P); if (!myPntCont->Value(i)->HasPnt2dOnSurf()) + { myPntCont->ChangeValue(i)->SetPnt2dOnSurf(ProjectPoint(P)); + } } //====================================================================== // Number of points by curve //====================================================================== if ((NTLinCont != 0) && (myNbPtsOnCur != 0)) + { CalculNbPtsInit(); + } //====================================================================== // Management of incompatibilities between curves @@ -1719,7 +1865,9 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Message_ProgressRange& t //==================================================================== LoadCurve(0, 0); if (myPntCont->Length() != 0) + { LoadPoint(0, 0); + } //==================================================================== // Construction of the surface //==================================================================== @@ -1783,9 +1931,13 @@ void GeomPlate_BuildPlateSurface::Intersect( { Cj.Load(myLinCont->Value(j)->Curve2dOnSurf()); if (i == j) + { Intersection.Perform(Ci, myTol2d * 10, myTol2d * 10); + } else + { Intersection.Perform(Ci, Cj, myTol2d * 10, myTol2d * 10); + } if (!Intersection.IsEmpty()) { // there is one intersection @@ -1818,12 +1970,18 @@ void GeomPlate_BuildPlateSurface::Intersect( { aux = myTol3d / aux; if (aux > 100 * tolint) + { tolint *= 100; + } else + { tolint = aux; + } } else + { tolint *= 100; + } PntInter->ChangeValue(i).Append(int2d.ParamOnFirst() - tolint); PntInter->ChangeValue(i).Append(int2d.ParamOnFirst() + tolint); @@ -1837,7 +1995,9 @@ void GeomPlate_BuildPlateSurface::Intersect( v26 = v21 ^ v22; double ant = v16.Angle(v26); if (ant > (M_PI / 2)) + { ant = M_PI - ant; + } if ((std::abs(v16 * v15 - v16 * v25) > (myTol3d / 1000)) || (std::abs(ant) > myTol3d / 1000)) // Non-compatible ==> remove zone in constraint G1 @@ -1852,9 +2012,13 @@ void GeomPlate_BuildPlateSurface::Intersect( myLinCont->Value(j)->Curve2dOnSurf()->D1(int2d.ParamOnSecond(), P2temp, V2); A1 = V1.Angle(V2); if (A1 > (M_PI / 2)) + { A1 = M_PI - A1; + } if (std::abs(std::abs(A1) - M_PI) < myTolAng) + { Tol = 100000 * myTol3d; + } #ifdef OCCT_DEBUG if (Affich) std::cout << "Angle between curves " << i << "," << j << " " @@ -1907,9 +2071,13 @@ void GeomPlate_BuildPlateSurface::Intersect( myLinCont->Value(j)->Curve2dOnSurf()->D1(int2d.ParamOnSecond(), P2temp, V2); A1 = V1.Angle(V2); if (A1 > M_PI / 2) + { A1 = M_PI - A1; + } if (std::abs(std::abs(A1) - M_PI) < myTolAng) + { Tol = 100000 * myTol3d; + } #ifdef OCCT_DEBUG if (Affich) std::cout << "Angle entre Courbe " << i << "," << j << " " @@ -2022,7 +2190,9 @@ void GeomPlate_BuildPlateSurface::Discretise( { // Construct a law close to curvilinear abscissa if (!C2d.IsNull()) + { AC2d.Load(C2d); + } // AC2d.Load(LinCont->Curve2dOnSurf()); int ii, Nbint = 20; double U; @@ -2069,7 +2239,9 @@ void GeomPlate_BuildPlateSurface::Discretise( // To avoid points of accumulation in 2D // Inter=Uinit+(Uif)*((-cos(M_PI*((j-1)/(NbPnt_i-1)))+1)/2); if (j == NbPnt_i) + { Inter = Ufinal; // to avoid bug on Sun + } else if (ACR) { CurLength = Length2d * (1 - std::cos((j - 1) * M_PI / (NbPnt_i - 1))) / 2; @@ -2175,8 +2347,10 @@ void GeomPlate_BuildPlateSurface::Discretise( { if (((!mySurfInitIsGive) && (Geom2dAdaptor_Curve(LinCont->Curve2dOnSurf()).GetType() != GeomAbs_Circle)) - || ((j > 1) && (j < NbPnt_i))) // exclude extremities + || ((j > 1) && (j < NbPnt_i))) + { // exclude extremities myPlateCont->ChangeValue(i).Append(Inter); // add the point + } } } } @@ -2197,7 +2371,9 @@ void GeomPlate_BuildPlateSurface::CalculNbPtsInit() int i; for (i = 1; i <= NTLinCont; i++) + { LenT += myLinCont->Value(i)->Length(); + } for (i = 1; i <= NTLinCont; i++) { int Cont = myLinCont->Value(i)->Order(); @@ -2217,7 +2393,9 @@ void GeomPlate_BuildPlateSurface::CalculNbPtsInit() break; } if (myLinCont->Value(i)->NbPoints() < 3) + { myLinCont->ChangeValue(i)->SetNbPoints(3); + } } } @@ -2241,18 +2419,24 @@ void GeomPlate_BuildPlateSurface::LoadCurve(const int NbBoucle, const int OrderM Tang = std::min(CC->Order(), OrderMax); Nt = myPlateCont->Value(i).Length(); if (Tang != -1) + { for (j = 1; j <= Nt; j++) { // Loading of points G0 on boundaries CC->D0(myPlateCont->Value(i).Value(j), P3d); if (!CC->ProjectedCurve().IsNull()) + { P2d = CC->ProjectedCurve()->Value(myPlateCont->Value(i).Value(j)); - + } else { if (!CC->Curve2dOnSurf().IsNull()) + { P2d = CC->Curve2dOnSurf()->Value(myPlateCont->Value(i).Value(j)); + } else + { P2d = ProjectPoint(P3d); + } } mySurfInit->D0(P2d.Coord(1), P2d.Coord(2), PP); Pdif.SetCoord(-PP.Coord(1) + P3d.Coord(1), @@ -2288,7 +2472,9 @@ void GeomPlate_BuildPlateSurface::LoadCurve(const int NbBoucle, const int OrderM // Normal.Normalize(); double norm = Normal.Magnitude(); if (norm > 1.e-12) + { Normal /= norm; + } DerPlateU = myPrevPlate.EvaluateDerivative(P2d.XY(), 1, 0); DerPlateV = myPrevPlate.EvaluateDerivative(P2d.XY(), 0, 1); @@ -2324,6 +2510,7 @@ void GeomPlate_BuildPlateSurface::LoadCurve(const int NbBoucle, const int OrderM // } } } + } } } } @@ -2417,7 +2604,9 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) { int NbPts_i = myParCont->Value(i).Length(); if (NbPts_i < 3) + { NbPts_i = 4; + } occ::handle> tdist = new NCollection_HArray1(1, NbPts_i - 1); occ::handle> tang = @@ -2434,28 +2623,44 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) for (int j = 1; j < NbPts_i; j++) { if (tdist->Value(j) > myG0Error) + { myG0Error = tdist->Value(j); + } if (tang->Value(j) > myG1Error) + { myG1Error = tang->Value(j); + } if (tcourb->Value(j) > myG2Error) + { myG2Error = tcourb->Value(j); + } double U; if (myParCont->Value(i).Length() > 3) + { U = (myParCont->Value(i).Value(j) + myParCont->Value(i).Value(j + 1)) / 2; + } else + { U = LinCont->FirstParameter() + (LinCont->LastParameter() - LinCont->FirstParameter()) * (j - 1) / (NbPts_i - 2); + } double diffDist = tdist->Value(j) - LinCont->G0Criterion(U), diffAng; if (LinCont->Order() > 0) + { diffAng = tang->Value(j) - LinCont->G1Criterion(U); + } else + { diffAng = 0; + } // find the maximum variation of error and calculate the average if (diffDist > 0) { diffDist = diffDist / LinCont->G0Criterion(U); if (diffDist > diffDistMax) + { diffDistMax = diffDist; + } // SdiffDist+=diffDist; NdiffDist++; } @@ -2463,7 +2668,9 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) { diffAng = diffAng / myLinCont->Value(i)->G1Criterion(U); if (diffAng > diffAngMax) + { diffAngMax = diffAng; + } // SdiffAng+=diffAng; NdiffAng++; } @@ -2473,13 +2680,19 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) { // at least one point is not acceptable in G0 double Coef; if (LinCont->Order() == 0) + { Coef = 0.6 * std::log(diffDistMax + 7.4); - // 7.4 corresponds to the calculation of min. coefficient = 1.2 is e^1.2/0.6 + // 7.4 corresponds to the calculation of min. coefficient = 1.2 is e^1.2/0.6 + } else + { Coef = std::log(diffDistMax + 3.3); + } // 3.3 corresponds to calculation of min. coefficient = 1.2 donc e^1.2 if (Coef > 3) + { Coef = 3; + } // experimentally after the coefficient becomes bad for L cases if ((NbBoucle > 1) && (diffDistMax > 2)) { @@ -2487,7 +2700,9 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) } if (LinCont->NbPoints() >= std::floor(LinCont->NbPoints() * Coef)) + { Coef = 2; // to provide increase of the number of points + } LinCont->SetNbPoints(int(LinCont->NbPoints() * Coef)); Result = false; @@ -2496,7 +2711,9 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) { double Coef = 1.5; if ((LinCont->NbPoints() + 1) >= std::floor(LinCont->NbPoints() * Coef)) + { Coef = 2; + } LinCont->SetNbPoints(int(LinCont->NbPoints() * Coef)); Result = false; @@ -2506,7 +2723,9 @@ bool GeomPlate_BuildPlateSurface::VerifSurface(const int NbBoucle) if (!Result) { if (myFree && NbBoucle == 1) + { myPrevPlate = myPlate; + } myPlate.Init(); } return Result; @@ -2544,7 +2763,9 @@ void GeomPlate_BuildPlateSurface::VerifPoints(double& Dist, double& Ang, double& v3f = v1f ^ v2f; Ang = v3f.Angle(v3i); if (Ang > (M_PI / 2)) + { Ang = M_PI - Ang; + } break; case 2: occ::handle Splate(myGeomPlateSurface); @@ -2568,17 +2789,21 @@ double GeomPlate_BuildPlateSurface::ComputeAnisotropie() const return 1.0; } else + { return 1.0; + } } bool GeomPlate_BuildPlateSurface::IsOrderG1() const { bool result = true; for (int i = 1; i <= myLinCont->Length(); i++) + { if (myLinCont->Value(i)->Order() < 1) { result = false; break; } + } return result; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_CurveConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_CurveConstraint.cxx index fe45cb7f76..4528e05b63 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_CurveConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_CurveConstraint.cxx @@ -69,7 +69,9 @@ GeomPlate_CurveConstraint ::GeomPlate_CurveConstraint(const occ::handle 2)) + { throw Standard_Failure("GeomPlate : The continuity is not G0 G1 or G2"); + } myNbPoints = NPt; myConstG0 = true; myConstG1 = true; @@ -118,11 +120,17 @@ GeomPlate_CurveConstraint ::GeomPlate_CurveConstraint(const occ::handleFirstParameter(); + } else if (my3dCurve.IsNull()) + { return myFrontiere->FirstParameter(); + } else + { return my3dCurve->FirstParameter(); + } } //--------------------------------------------------------- @@ -131,11 +139,17 @@ double GeomPlate_CurveConstraint ::FirstParameter() const double GeomPlate_CurveConstraint ::LastParameter() const { if (!myHCurve2d.IsNull()) + { return myHCurve2d->LastParameter(); + } else if (my3dCurve.IsNull()) + { return myFrontiere->LastParameter(); + } else + { return my3dCurve->LastParameter(); + } } //--------------------------------------------------------- @@ -174,7 +188,9 @@ void GeomPlate_CurveConstraint ::D0(const double U, gp_Pnt& P) const myFrontiere->GetSurface()->D0(P2d.Coord(1), P2d.Coord(2), P); } else + { my3dCurve->D0(U, P); + } } //--------------------------------------------------------- @@ -184,7 +200,9 @@ void GeomPlate_CurveConstraint ::D1(const double U, gp_Pnt& P, gp_Vec& V1, gp_Ve { gp_Pnt2d P2d; if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } P2d = myFrontiere->GetCurve()->Value(U); myFrontiere->GetSurface()->D1(P2d.Coord(1), P2d.Coord(2), P, V1, V2); @@ -203,7 +221,9 @@ void GeomPlate_CurveConstraint ::D2(const double U, { gp_Pnt2d P2d; if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } P2d = myFrontiere->GetCurve()->Value(U); myFrontiere->GetSurface()->D2(P2d.Coord(1), P2d.Coord(2), P, V1, V2, V3, V4, V5); @@ -224,7 +244,9 @@ void GeomPlate_CurveConstraint ::SetG0Criterion(const occ::handle& void GeomPlate_CurveConstraint ::SetG1Criterion(const occ::handle& G1Crit) { if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } myG1Crit = G1Crit; myConstG1 = false; } @@ -235,7 +257,9 @@ void GeomPlate_CurveConstraint ::SetG1Criterion(const occ::handle& void GeomPlate_CurveConstraint ::SetG2Criterion(const occ::handle& G2Crit) { if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } myG2Crit = G2Crit; myConstG2 = false; } @@ -246,9 +270,13 @@ void GeomPlate_CurveConstraint ::SetG2Criterion(const occ::handle& double GeomPlate_CurveConstraint ::G0Criterion(const double U) const { if (myConstG0) + { return myTolDist; + } else + { return myG0Crit->Value(U); + } } //--------------------------------------------------------- @@ -257,11 +285,17 @@ double GeomPlate_CurveConstraint ::G0Criterion(const double U) const double GeomPlate_CurveConstraint ::G1Criterion(const double U) const { if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } if (myConstG1) + { return myTolAng; + } else + { return myG1Crit->Value(U); + } } //--------------------------------------------------------- @@ -270,11 +304,17 @@ double GeomPlate_CurveConstraint ::G1Criterion(const double U) const double GeomPlate_CurveConstraint ::G2Criterion(const double U) const { if (!my3dCurve.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } if (myConstG2) + { return myTolCurv; + } else + { return myG2Crit->Value(U); + } } //--------------------------------------------------------- @@ -300,7 +340,9 @@ occ::handle GeomPlate_CurveConstraint ::Curve2dOnSurf() const return C2d; } else + { return my2dCurve; + } } //--------------------------------------------------------- @@ -337,9 +379,13 @@ void GeomPlate_CurveConstraint ::SetProjectedCurve(const occ::handle GeomPlate_CurveConstraint ::Curve3d() const { if (my3dCurve.IsNull()) + { return occ::handle(myFrontiere); + } else + { return my3dCurve; + } } //------------------------------------------------------------ @@ -380,7 +426,9 @@ void GeomPlate_CurveConstraint::SetOrder(const int Order) GeomLProp_SLProps& GeomPlate_CurveConstraint::LPropSurf(const double U) { if (myFrontiere.IsNull()) + { throw Standard_Failure("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); + } gp_Pnt2d P2d = myFrontiere->GetCurve()->Value(U); myLProp.SetParameters(P2d.X(), P2d.Y()); return myLProp; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_PointConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_PointConstraint.cxx index 5706290f06..b34d1daf5d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_PointConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_PointConstraint.cxx @@ -42,7 +42,9 @@ GeomPlate_PointConstraint::GeomPlate_PointConstraint(const gp_Pnt& Pt, hasPnt2dOnSurf(false) { if ((myOrder > 1) || (myOrder < -1)) + { throw Standard_Failure("GeomPlate_PointConstraint : the constraint must 0 or -1 with a point"); + } } //--------------------------------------------------------- diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_Surface.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_Surface.cxx index 1a3c53edcc..d07c8c27b1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_Surface.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomPlate/GeomPlate_Surface.cxx @@ -97,7 +97,9 @@ gp_GTrsf2d GeomPlate_Surface::ParametricTransformation(const gp_Trsf&) const void GeomPlate_Surface::Bounds(double& U1, double& U2, double& V1, double& V2) const { if (mySurfinit->DynamicType() == STANDARD_TYPE(GeomPlate_Surface)) + { mySurfinit->Bounds(U1, U2, V1, V2); + } else { U1 = myUmin; @@ -279,9 +281,13 @@ void GeomPlate_Surface::SetBounds(const double Umin, const double Vmax) { if ((Umin > Umax) || (Vmin > Vmax)) + { throw Standard_Failure("Bounds haven't the good sense"); + } if ((Umin == Umax) || (Vmin == Vmax)) + { throw Standard_Failure("Bounds are equal"); + } myUmin = Umin; myUmax = Umax; myVmin = Vmin; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Hatch/Hatch_Hatcher.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Hatch/Hatch_Hatcher.cxx index c98f896bef..2095b1a779 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Hatch/Hatch_Hatcher.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Hatch/Hatch_Hatcher.cxx @@ -96,23 +96,31 @@ void Hatch_Hatcher::Trim(const gp_Lin2d& L, const double Start, const double End Pinter = Inters.Point(1); double linePar = Pinter.ParamOnSecond(); if (linePar - Start < -myToler) + { continue; + } if (linePar - End > myToler) + { continue; + } double norm = L.Direction() ^ myLines(iLine).myLin.Direction(); if (linePar - Start < myToler) { // on the limit of the trimming segment // accept if the other extremity is on the left if (norm < 0) + { continue; + } } if (linePar - End > -myToler) { // on the limit of the trimming segment // accept if the other extremity is on the left if (norm > 0) + { continue; + } } // insert the parameter myLines(iLine).AddIntersection(Pinter.ParamOnFirst(), @@ -131,9 +139,13 @@ void Hatch_Hatcher::Trim(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const int Index { gp_Vec2d V(P1, P2); if (std::abs(V.X()) > .9 * RealLast()) + { V.Multiply(1 / V.X()); + } else if (std::abs(V.Y()) > .9 * RealLast()) + { V.Multiply(1 / V.Y()); + } if (V.Magnitude() > myToler) { gp_Dir2d D(V); @@ -148,7 +160,9 @@ int Hatch_Hatcher::NbIntervals() const { int i, nb = 0; for (i = 1; i <= myLines.Length(); i++) + { nb += NbIntervals(i); + } return nb; } @@ -199,13 +213,19 @@ int Hatch_Hatcher::NbIntervals(const int I) const { int l = myLines(I).myInters.Length(); if (l == 0) + { l = myOrient ? 1 : 0; + } else { l = l / 2; if (myOrient) + { if (!myLines(I).myInters(1).myStart) + { l++; + } + } } return l; } @@ -217,16 +237,22 @@ double Hatch_Hatcher::Start(const int I, const int J) const if (myLines(I).myInters.IsEmpty()) { if (J != 1 || !myOrient) + { throw Standard_OutOfRange(); + } return RealFirst(); } else { int jj = 2 * J - 1; if (!myLines(I).myInters(1).myStart && myOrient) + { jj--; + } if (jj == 0) + { return RealFirst(); + } return myLines(I).myInters(jj).myPar1; } } @@ -238,7 +264,9 @@ void Hatch_Hatcher::StartIndex(const int I, const int J, int& Index, double& Par if (myLines(I).myInters.IsEmpty()) { if (J != 1) + { throw Standard_OutOfRange(); + } Index = 0; Par2 = 0; } @@ -246,7 +274,9 @@ void Hatch_Hatcher::StartIndex(const int I, const int J, int& Index, double& Par { int jj = 2 * J - 1; if (!myLines(I).myInters(1).myStart && myOrient) + { jj--; + } if (jj == 0) { Index = 0; @@ -267,16 +297,22 @@ double Hatch_Hatcher::End(const int I, const int J) const if (myLines(I).myInters.IsEmpty()) { if (J != 1 || !myOrient) + { throw Standard_OutOfRange(); + } return RealLast(); } else { int jj = 2 * J; if (!myLines(I).myInters(1).myStart && myOrient) + { jj--; + } if (jj > myLines(I).myInters.Length()) + { return RealLast(); + } return myLines(I).myInters(jj).myPar1; } } @@ -288,7 +324,9 @@ void Hatch_Hatcher::EndIndex(const int I, const int J, int& Index, double& Par2) if (myLines(I).myInters.IsEmpty()) { if (J != 1) + { throw Standard_OutOfRange(); + } Index = 0; Par2 = 0; } @@ -296,7 +334,9 @@ void Hatch_Hatcher::EndIndex(const int I, const int J, int& Index, double& Par2) { int jj = 2 * J; if (!myLines(I).myInters(1).myStart && myOrient) + { jj--; + } if (jj > myLines(I).myInters.Length()) { Index = 0; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_Domain.cxx b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_Domain.cxx index 4cb3d585e5..0c11b191cc 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_Domain.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_Domain.cxx @@ -71,7 +71,7 @@ void HatchGen_Domain::Dump(const int Index) const { std::cout << "======"; } - std::cout << "=============================" << std::endl; + std::cout << "=============================" << '\n'; if (myHasFirstPoint) { @@ -79,7 +79,7 @@ void HatchGen_Domain::Dump(const int Index) const } else { - std::cout << " Has not a first point" << std::endl; + std::cout << " Has not a first point" << '\n'; } if (myHasSecondPoint) @@ -88,8 +88,8 @@ void HatchGen_Domain::Dump(const int Index) const } else { - std::cout << " Has not a second point" << std::endl; + std::cout << " Has not a second point" << '\n'; } - std::cout << "==============================================" << std::endl; + std::cout << "==============================================" << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnElement.cxx b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnElement.cxx index 681c0baae2..f1b9df1e34 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnElement.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnElement.cxx @@ -214,10 +214,10 @@ void HatchGen_PointOnElement::Dump(const int Index) const { std::cout << "------"; } - std::cout << "---------------" << std::endl; + std::cout << "---------------" << '\n'; - std::cout << " Index of the element = " << myIndex << std::endl; - std::cout << " Parameter on element = " << myParam << std::endl; + std::cout << " Index of the element = " << myIndex << '\n'; + std::cout << " Parameter on element = " << myParam << '\n'; std::cout << " Position on element = "; switch (myPosit) { @@ -234,7 +234,7 @@ void HatchGen_PointOnElement::Dump(const int Index) const std::cout << "EXTERNAL (i.e. UNKNOWN)"; break; } - std::cout << std::endl; + std::cout << '\n'; std::cout << " Intersection Type = "; switch (myType) { @@ -251,7 +251,7 @@ void HatchGen_PointOnElement::Dump(const int Index) const std::cout << "UNDETERMINED"; break; } - std::cout << std::endl; + std::cout << '\n'; std::cout << " State Before = "; switch (myBefore) { @@ -268,7 +268,7 @@ void HatchGen_PointOnElement::Dump(const int Index) const std::cout << "UNKNOWN"; break; } - std::cout << std::endl; + std::cout << '\n'; std::cout << " State After = "; switch (myAfter) { @@ -285,9 +285,9 @@ void HatchGen_PointOnElement::Dump(const int Index) const std::cout << "UNKNOWN"; break; } - std::cout << std::endl; - std::cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << std::endl; - std::cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << std::endl; + std::cout << '\n'; + std::cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << '\n'; + std::cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << '\n'; - std::cout << " ------------------------------------------" << std::endl; + std::cout << " ------------------------------------------" << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnHatching.cxx b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnHatching.cxx index 34b07cec0a..173719df7b 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnHatching.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/HatchGen/HatchGen_PointOnHatching.cxx @@ -64,9 +64,13 @@ void HatchGen_PointOnHatching::AddPoint(const HatchGen_PointOnElement& Point, // for (int IPnt = 1 ; int IPnt; for (IPnt = 1; IPnt <= NbPnt && myPoints(IPnt).IsDifferent(Point, Confusion); IPnt++) + { ; + } if (IPnt > NbPnt) + { myPoints.Append(Point); + } } //======================================================================= @@ -156,10 +160,10 @@ void HatchGen_PointOnHatching::Dump(const int Index) const { std::cout << "------"; } - std::cout << "------------------" << std::endl; + std::cout << "------------------" << '\n'; - std::cout << " Index of the hatching = " << myIndex << std::endl; - std::cout << " Parameter on hatching = " << myParam << std::endl; + std::cout << " Index of the hatching = " << myIndex << '\n'; + std::cout << " Parameter on hatching = " << myParam << '\n'; std::cout << " Position on hatching = "; switch (myPosit) { @@ -176,7 +180,7 @@ void HatchGen_PointOnHatching::Dump(const int Index) const std::cout << "EXTERNAL (i.e. UNKNOWN)"; break; } - std::cout << std::endl; + std::cout << '\n'; std::cout << " State Before = "; switch (myBefore) { @@ -193,7 +197,7 @@ void HatchGen_PointOnHatching::Dump(const int Index) const std::cout << "UNKNOWN"; break; } - std::cout << std::endl; + std::cout << '\n'; std::cout << " State After = "; switch (myAfter) { @@ -210,18 +214,18 @@ void HatchGen_PointOnHatching::Dump(const int Index) const std::cout << "UNKNOWN"; break; } - std::cout << std::endl; - std::cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << std::endl; - std::cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << std::endl; + std::cout << '\n'; + std::cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << '\n'; + std::cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << '\n'; int NbPnt = myPoints.Length(); if (NbPnt == 0) { - std::cout << " No points on element" << std::endl; + std::cout << " No points on element" << '\n'; } else { - std::cout << " Contains " << NbPnt << " points on element" << std::endl; + std::cout << " Contains " << NbPnt << " points on element" << '\n'; for (int IPnt = 1; IPnt <= NbPnt; IPnt++) { const HatchGen_PointOnElement& Point = myPoints.Value(IPnt); @@ -229,5 +233,5 @@ void HatchGen_PointOnHatching::Dump(const int Index) const } } - std::cout << "----------------------------------------------" << std::endl; + std::cout << "----------------------------------------------" << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IConicTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IConicTool.cxx index c9d0801f4d..ed10b40c2a 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IConicTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IConicTool.cxx @@ -263,9 +263,13 @@ double IntCurve_IConicTool::Distance(const gp_Pnt2d& ThePoint) const gp_Pnt2d P = ThePoint; P.Transform(Abs_To_Object); if (P.X() > 0.0) + { return ((P.X() * P.X()) / Hypr_aa - (P.Y() * P.Y()) / Hypr_bb - 1.0); + } else + { return ((-P.X() * P.X()) / Hypr_aa - (P.Y() * P.Y()) / Hypr_bb - 1.0); + } } default: { std::cout << "### Erreur sur le type de la courbe ###"; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic.cxx index bd3256d44a..239e87bba8 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic.cxx @@ -125,7 +125,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, double bsup = -Precision::Infinite(); double maxtol = (Tol > TolConf) ? Tol : TolConf; if (maxtol < 1.e-7) + { maxtol = 1.e-7; + } bool wasSet = false; gp_Pnt2d Pntinf, Pntsup; @@ -213,7 +215,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, } } if (!wasSet) + { this->SetValues(Inter); + } } else { @@ -240,12 +244,18 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, double binf = Precision::Infinite(), bsup = -Precision::Infinite(), maxtol; gp_Pnt2d Pntinf, Pntsup; if (Tol > TolConf) + { maxtol = Tol; + } else + { maxtol = TolConf; + } maxtol *= 100.0; if (maxtol < 0.000001) + { maxtol = 0.000001; + } gp_Vec2d Offset(maxtol * H.XAxis().Direction().X(), maxtol * H.XAxis().Direction().Y()); gp_Hypr2d Hp(H.Translated(Offset)); IntAna2d_AnaIntersection theIntAna2d; @@ -588,12 +598,18 @@ void IntCurve_IntConicConic::Perform(const gp_Parab2d& P1, double binf = Precision::Infinite(), bsup = -Precision::Infinite(), maxtol; gp_Pnt2d Pntinf, Pntsup; if (Tol > TolConf) + { maxtol = Tol; + } else + { maxtol = TolConf; + } maxtol *= 100.0; if (maxtol < 0.000001) + { maxtol = 0.000001; + } gp_Vec2d Offset(maxtol * P2.MirrorAxis().Direction().X(), maxtol * P2.MirrorAxis().Direction().Y()); gp_Parab2d Pp(P2.Translated(Offset)); @@ -697,9 +713,13 @@ void IntCurve_IntConicConic::Perform(const gp_Elips2d& E, double binf = Precision::Infinite(), bsup = -Precision::Infinite(), maxtol; gp_Pnt2d Pntinf, Pntsup; if (Tol > TolConf) + { maxtol = Tol; + } else + { maxtol = TolConf; + } maxtol = E.MinorRadius() / 10.0; gp_Elips2d Ep(E); @@ -802,12 +822,18 @@ void IntCurve_IntConicConic::Perform(const gp_Parab2d& P, double binf = Precision::Infinite(), bsup = -Precision::Infinite(), maxtol; gp_Pnt2d Pntinf, Pntsup; if (Tol > TolConf) + { maxtol = Tol; + } else + { maxtol = TolConf; + } maxtol *= 100.0; if (maxtol < 0.000001) + { maxtol = 0.000001; + } gp_Vec2d Offset(maxtol * H.XAxis().Direction().X(), maxtol * H.XAxis().Direction().Y()); gp_Hypr2d Hp(H.Translated(Offset)); IntAna2d_AnaIntersection theIntAna2d; @@ -1055,12 +1081,18 @@ void IntCurve_IntConicConic::Perform(const gp_Hypr2d& H1, double binf = Precision::Infinite(), bsup = -Precision::Infinite(), maxtol; gp_Pnt2d Pntinf, Pntsup; if (Tol > TolConf) + { maxtol = Tol; + } else + { maxtol = TolConf; + } maxtol *= 100.0; if (maxtol < 0.000001) + { maxtol = 0.000001; + } gp_Vec2d Offset(maxtol * H2.XAxis().Direction().X(), maxtol * H2.XAxis().Direction().Y()); gp_Hypr2d Hp(H2.Translated(Offset)); IntAna2d_AnaIntersection theIntAna2d; @@ -1163,7 +1195,9 @@ void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection& theIntAna2d, double NormeD1 = V.Magnitude(); double dparam = 100.0 * maxtol / NormeD1; if (dparam < 1e-3) + { dparam = 1e-3; + } param -= dparam; if (param < binf) @@ -1209,7 +1243,9 @@ void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection& theIntAna2d, double NormeD1 = V.Magnitude(); double dparam = 100.0 * maxtol / NormeD1; if (dparam < 1e-3) + { dparam = 1e-3; + } param -= dparam; if (param < binf) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_1.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_1.cxx index 8dfb306c07..d61b8a3c91 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_1.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_1.cxx @@ -66,7 +66,9 @@ void ProjectOnC2AndIntersectWithC2Domain(const gp_Circ2d& Circle1, { if (C1DomainAndRes.IsNull()) + { return; + } //------------------------------------------------------------------------- //-- On cherche l intervalle correspondant sur C2 //-- Puis on intersecte l intervalle avec le domaine de C2 @@ -84,12 +86,16 @@ void ProjectOnC2AndIntersectWithC2Domain(const gp_Circ2d& Circle1, if (!IdentCircles) { if (C2Inter.Length() > M_PI) + { C2Inter.Complement(); + } } else { if (C2sup <= C2inf) + { C2sup += PIpPI; + } if (C2inf >= PIpPI) { C2sup -= PIpPI; @@ -121,7 +127,9 @@ void ProjectOnC2AndIntersectWithC2Domain(const gp_Circ2d& Circle1, if (!IdentCircles) { if (SolutionC1[NbSolTotal].Length() > M_PI) + { SolutionC1[NbSolTotal].Complement(); + } } else { @@ -256,13 +264,21 @@ void CircleCircleGeometricIntersection(const gp_Circ2d& C1, || ((C1_bsup1 <= C1_bsup2) && (C1_bsup1 >= C1_binf2))) { if (C1_binf1 > C1_binf2) + { C1_binf1 = C1_binf2; + } if (C1_binf1 > C1_bsup2) + { C1_binf1 = C1_bsup2; + } if (C1_bsup1 < C1_binf2) + { C1_bsup1 = C1_binf2; + } if (C1_bsup1 < C1_bsup2) + { C1_bsup1 = C1_bsup2; + } nbsol = 1; } } @@ -298,9 +314,13 @@ void CircleCircleGeometricIntersection(const gp_Circ2d& C1, double dAngle1; if (AxeO1O2.Magnitude() <= gp::Resolution()) + { dAngle1 = Axe1.Angle(C2.XAxis().Direction()); + } else + { dAngle1 = Axe1.Angle(AxeO1O2); + } if (!C1.IsDirect()) { @@ -315,7 +335,9 @@ void CircleCircleGeometricIntersection(const gp_Circ2d& C1, C1_Res1.SetValues(C1_binf1, C1_bsup1); if (C1_Res1.Length() > M_PI) + { C1_Res1.Complement(); + } if (nbsol == 2) { @@ -323,7 +345,9 @@ void CircleCircleGeometricIntersection(const gp_Circ2d& C1, C1_bsup2 += dAngle1; C1_Res2.SetValues(C1_binf2, C1_bsup2); if (C1_Res2.Length() > M_PI) + { C1_Res2.Complement(); + } } else { @@ -347,7 +371,9 @@ void ProjectOnLAndIntersectWithLDomain(const gp_Circ2d& Circle, { if (CDomainAndRes.IsNull()) + { return; + } //------------------------------------------------------------------------- //-- On cherche l intervalle correspondant sur C2 //-- Puis on intersecte l intervalle avec le domaine de C2 @@ -406,7 +432,9 @@ void ProjectOnLAndIntersectWithLDomain(const gp_Circ2d& Circle, } CircleSolution[NbSolTotal] = PeriodicInterval(Cinf, Csup); if (CircleSolution[NbSolTotal].Length() > M_PI) + { CircleSolution[NbSolTotal].Complement(); + } LineSolution[NbSolTotal] = LInterAndDomain; NbSolTotal++; @@ -526,14 +554,22 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line, d = a * Circle.Location().X() + b * Circle.Location().Y() + c; if (d > 0.0) + { dAngle1 += PIsur2; + } else + { dAngle1 -= PIsur2; + } if (dAngle1 < 0.0) + { dAngle1 += PIpPI; + } else if (dAngle1 > PIpPI) + { dAngle1 -= PIpPI; + } binf1 += dAngle1; bsup1 += dAngle1; @@ -552,7 +588,9 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line, CInt1.SetValues(binf1, bsup1); if (CInt1.Length() > M_PI) + { CInt1.Complement(); + } if (nbsol == 2) { @@ -570,7 +608,9 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line, CInt2.SetValues(binf2, bsup2); if (CInt2.Length() > M_PI) + { CInt2.Complement(); + } } // Modified by Sergey KHROMOV - Thu Oct 26 17:51:05 2000 Begin else @@ -583,10 +623,14 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line, binf1 = 0.; CInt1.SetValues(binf1, CInt1.Bsup - PIpPI); if (CInt1.Length() > M_PI) + { CInt1.Complement(); + } CInt2.SetValues(binf2, bsup2); if (CInt2.Length() > M_PI) + { CInt2.Complement(); + } } } // Modified by Sergey KHROMOV - Thu Oct 26 17:51:13 2000 End @@ -717,9 +761,13 @@ void LineLineGeometricIntersection(const gp_Lin2d& L1, //------------------- Calcul du Sin du demi angle entre L1 et L2 //---- if (D < 0.0) + { D = -D; + } if (D > 1.0) + { D = 1.0; //-- Deja vu ! + } SinDemiAngle = std::sin(0.5 * std::asin(D)); nbsol = 1; } @@ -804,9 +852,13 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, } while (C1Domain.Binf >= PIpPI) + { C1Domain.Binf -= PIpPI; + } while (C1Domain.Binf < 0.0) + { C1Domain.Binf += PIpPI; + } C1Domain.Bsup = C1Domain.Binf + deltat; @@ -818,9 +870,13 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, } while (C2Domain.Binf >= PIpPI) + { C2Domain.Binf -= PIpPI; + } while (C2Domain.Binf < 0.0) + { C2Domain.Binf += PIpPI; + } C2Domain.Bsup = C2Domain.Binf + deltat; @@ -922,7 +978,9 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, // des segments int i; if (Tol < (1e-10)) + { Tol2 = 1e-10; + } for (i = 0; i < NbSolTotal; i++) { @@ -1045,7 +1103,9 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, //-- On traite un intervalle non reduit a un point double C1sup = NormalizeOnCircleDomain(SolutionC1[i].Bsup, DomainCirc1); if (C1sup < C1inf) + { C1sup += PIpPI; + } C2sup = NormalizeOnCircleDomain(C2sup, DomainCirc2); ElCLib::CircleD2(C1sup, Axis2C1, R1, P1b, Tan1, Norm1); @@ -1063,7 +1123,9 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, if (nbsol != 3) { if (C2inf < C2sup) + { C2inf += PIpPI; + } } } else @@ -1071,7 +1133,9 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, if (nbsol != 3) { if (C2sup < C2inf) + { C2sup += PIpPI; + } } } @@ -1100,7 +1164,9 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, //-- On traite un intervalle non reduit a un point double C1sup = NormalizeOnCircleDomain(SolutionC1[i].Bsup, DomainCirc1); if (C1sup < C1inf) + { C1sup += PIpPI; + } C2sup = NormalizeOnCircleDomain(C2sup, DomainCirc2); ElCLib::CircleD2(C1sup, Axis2C1, R1, P1b, Tan1, Norm1); @@ -1115,12 +1181,16 @@ void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1, if (isOpposite) { if (C2inf < C2sup) + { C2inf += PIpPI; + } } else { if (C2sup < C2inf) + { C2sup += PIpPI; + } } IntRes2d_IntersectionPoint NewPoint2(P1b, C1sup, C2sup, T1b, T2b, false); @@ -1195,7 +1265,9 @@ static bool computeIntPoint(const IntRes2d_Domain& theCurDomain, IntRes2d_IntersectionPoint& theNewPoint) { if (fabs(theResSup - theParCur) > fabs(theResInf - theParCur)) + { theResSup = theResInf; + } double aRes2 = theParOther + (theResSup - theParCur) * theCosT1T2; @@ -1273,9 +1345,13 @@ static bool computeIntPoint(const IntRes2d_Domain& theCurDomain, gp_Pnt2d aPres((ElCLib::Value(aResU1, theCurLin).XY() + ElCLib::Value(aResU2, theOtherLin).XY()) * 0.5); if (theNum == 1) + { theNewPoint.SetValues(aPres, aResU1, aResU2, aT1, aT2, false); + } else + { theNewPoint.SetValues(aPres, aResU2, aResU1, aT2, aT1, false); + } return true; } @@ -1293,7 +1369,9 @@ static bool CheckLLCoincidence(const gp_Lin2d& L1, bool isFirst1 = (Domain1.HasFirstPoint() && L2.Distance(Domain1.FirstPoint()) < theTol); bool isLast1 = (Domain1.HasLastPoint() && L2.Distance(Domain1.LastPoint()) < theTol); if (isFirst1 && isLast1) + { return true; + } bool isFirst2 = (Domain2.HasFirstPoint() && L1.Distance(Domain2.FirstPoint()) < theTol); bool isLast2 = (Domain2.HasLastPoint() && L1.Distance(Domain2.LastPoint()) < theTol); return isFirst2 && isLast2; @@ -1319,7 +1397,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, double aHalfSinL1L2; double Tol = TolR; if (Tol < Precision::PConfusion()) + { Tol = Precision::PConfusion(); + } LineLineGeometricIntersection(L1, L2, Tol, U1, U2, aHalfSinL1L2, nbsol); @@ -1332,7 +1412,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, done = true; if (nbsol == 1 && CheckLLCoincidence(L1, L2, Domain1, Domain2, Tol)) + { nbsol = 2; + } if (nbsol == 1) { @@ -1456,7 +1538,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, 1, aCurTrans, NewPoint1)) + { Append(NewPoint1); + } //------------------------------------------------------ @@ -1720,9 +1804,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, else { //-- Pos1a == Pos2a == Middle if (Pos1b == IntRes2d_Middle) + { Pos1b = Pos1a; + } if (Pos2b == IntRes2d_Middle) + { Pos2b = Pos2a; + } if (ResultIsAPoint) { //-- Middle sur le segment A @@ -1880,7 +1968,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, 2, aCurTrans, NewPoint1)) + { Append(NewPoint1); + } } } } @@ -1931,22 +2021,34 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1, //== 2 : L2 borne //== 1 : L1 borne if (Domain1.HasFirstPoint()) + { ResHasFirstPoint = 1; + } if (Domain1.HasLastPoint()) + { ResHasLastPoint = 1; + } if (isOpposite) { if (Domain2.HasLastPoint()) + { ResHasFirstPoint += 2; + } if (Domain2.HasFirstPoint()) + { ResHasLastPoint += 2; + } } else { if (Domain2.HasLastPoint()) + { ResHasLastPoint += 2; + } if (Domain2.HasFirstPoint()) + { ResHasFirstPoint += 2; + } } if (ResHasFirstPoint == 0 && ResHasLastPoint == 0) { @@ -2172,16 +2274,22 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& Line, CInt1.SetValues(CInt2.Binf, CInt2.Bsup); } else if (CInt2.Bsup == PIpPI && LastBound + LastTol < CInt2.Binf) + { nbsol = 1; + } } // Modified by Sergey KHROMOV - Mon Dec 18 11:13:20 2000 End PeriodicInterval CDomain(CIRC_Domain); double deltat = CDomain.Bsup - CDomain.Binf; while (CDomain.Binf >= PIpPI) + { CDomain.Binf -= PIpPI; + } while (CDomain.Binf < 0.0) + { CDomain.Binf += PIpPI; + } CDomain.Bsup = CDomain.Binf + deltat; //------------------------------------------------------------ @@ -2206,9 +2314,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& Line, } deltat = CDomain.Bsup - CDomain.Binf; while (CDomain.Binf >= PIpPI) + { CDomain.Binf -= PIpPI; + } while (CDomain.Binf < 0.0) + { CDomain.Binf += PIpPI; + } CDomain.Bsup = CDomain.Binf + deltat; //-- ------------------------------------------------------------ @@ -2293,9 +2405,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& Line, int i; double MaxTol = TolConf; if (MaxTol < Tol) + { MaxTol = Tol; + } if (MaxTol < 1.0e-10) + { MaxTol = 1.0e-10; + } for (i = 0; i < NbSolTotal; i++) { @@ -2673,7 +2789,9 @@ void ProjectOnLAndIntersectWithLDomain(const gp_Elips2d& Ellipse, { if (EDomainAndRes.IsNull()) + { return; + } //------------------------------------------------------------------------- //-- On cherche l intervalle correspondant sur C2 //-- Puis on intersecte l intervalle avec le domaine de C2 @@ -2729,7 +2847,9 @@ void ProjectOnLAndIntersectWithLDomain(const gp_Elips2d& Ellipse, } EllipseSolution[NbSolTotal] = PeriodicInterval(Einf, Esup); if (EllipseSolution[NbSolTotal].Length() > M_PI) + { EllipseSolution[NbSolTotal].Complement(); + } LineSolution[NbSolTotal] = LInterAndDomain; NbSolTotal++; @@ -2779,9 +2899,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, PeriodicInterval EDomain(DE); double deltat = EDomain.Bsup - EDomain.Binf; while (EDomain.Binf >= PIpPI) + { EDomain.Binf -= PIpPI; + } while (EDomain.Binf < 0.0) + { EDomain.Binf += PIpPI; + } EDomain.Bsup = EDomain.Binf + deltat; // double BinfModif = EDomain.Binf; @@ -2803,9 +2927,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, } deltat = EDomain.Bsup - EDomain.Binf; while (EDomain.Binf >= PIpPI) + { EDomain.Binf -= PIpPI; + } while (EDomain.Binf < 0.0) + { EDomain.Binf += PIpPI; + } EDomain.Bsup = EDomain.Binf + deltat; // Interval LDomain(DL); @@ -2878,9 +3006,13 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L, int i; double MaxTol = TolConf; if (MaxTol < Tol) + { MaxTol = Tol; + } if (MaxTol < 1.0e-10) + { MaxTol = 1.0e-10; + } for (i = 0; i < NbSolTotal; i++) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_Tool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_Tool.cxx index a4297430c3..75f8c95599 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_Tool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_IntConicConic_Tool.cxx @@ -119,9 +119,13 @@ PeriodicInterval PeriodicInterval::FirstIntersection(PeriodicInterval& PInter) else { if (Length() >= PIpPI) + { return (PeriodicInterval(PInter.Binf, PInter.Bsup)); + } if (PInter.Length() >= PIpPI) + { return (PeriodicInterval(Binf, Bsup)); + } if (PInter.Bsup <= Binf) { while (PInter.Binf <= Binf && PInter.Bsup <= Binf) @@ -219,14 +223,18 @@ Interval::Interval(const IntRes2d_Domain& Domain) Binf = Domain.FirstParameter() - Domain.FirstTolerance(); } else + { HasFirstBound = false; + } if (Domain.HasLastPoint()) { HasLastBound = true; Bsup = Domain.LastParameter() + Domain.LastTolerance(); } else + { HasLastBound = false; + } } Interval::Interval(const double a, const bool hf, const double b, const bool hl) @@ -251,7 +259,9 @@ Interval Interval::IntersectionWithBounded(const Interval& Inter) return (PourSGI); } if (!(HasFirstBound || HasLastBound)) + { return (Interval(Inter.Binf, Inter.Bsup)); + } double a, b; if (HasFirstBound) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_ProjectOnPConicTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_ProjectOnPConicTool.cxx index 23beafd285..edfdff03a7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_ProjectOnPConicTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_ProjectOnPConicTool.cxx @@ -78,9 +78,13 @@ double IntCurve_ProjectOnPConicTool::FindParameter(const IntCurve_PConic& ThePCo if (ParamInf != ParamSup) { if (Param < ParamInf) + { return (ParamInf); + } if (Param > ParamSup) + { return (ParamSup); + } } return (Param); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Inter.pxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Inter.pxx index f633962880..1591225f04 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Inter.pxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Inter.pxx @@ -206,9 +206,13 @@ void PerformPolygon(const CurveType& theCurve, int nbsu = SurfaceTool::NbSamplesU(theSurface, u1, u2); int nbsv = SurfaceTool::NbSamplesV(theSurface, v1, v2); if (nbsu > 40) + { nbsu = 40; + } if (nbsv > 40) + { nbsv = 40; + } PolyhedronType polyhedron(theSurface, nbsu, nbsv, u1, v1, u2, v2); thePerformPoly(theCurve, thePolygon, theSurface, polyhedron); } @@ -463,9 +467,13 @@ void InternalPerformPolygonBounds(const CurveType& theCurve, int nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2); int nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2); if (nbsu > 40) + { nbsu = 40; + } if (nbsv > 40) + { nbsv = 40; + } PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2); theInternalPerformPoly(theCurve, thePolygon, @@ -568,7 +576,9 @@ void PerformConicSurfLine(const gp_Lin& theLine, } } else + { isAnaProcessed = false; + } break; } case GeomAbs_Cone: { @@ -580,7 +590,9 @@ void PerformConicSurfLine(const gp_Lin& theLine, theAppendIntAna(theCurve, theSurface, LinCone); } else + { isAnaProcessed = false; + } break; } default: @@ -592,9 +604,13 @@ void PerformConicSurfLine(const gp_Lin& theLine, int nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2); int nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2); if (nbsu < 1) + { nbsu = 1; + } if (nbsv < 1) + { nbsv = 1; + } bool U1inf = Precision::IsInfinite(theU1); bool U2inf = Precision::IsInfinite(theU2); @@ -658,12 +674,18 @@ void PerformConicSurfLine(const gp_Lin& theLine, } if (NoIntersection) + { return; + } if (nbsu < 20) + { nbsu = 20; + } if (nbsv < 20) + { nbsv = 20; + } PolyhedronType polyhedron(theSurface, nbsu, nbsv, U1new, V1new, U2new, V2new); Intf_Tool bndTool; @@ -835,9 +857,13 @@ void PerformConicSurfParabola(const gp_Parab& theParab, int nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2); int nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2); if (nbsu > 40) + { nbsu = 40; + } if (nbsv > 40) + { nbsv = 40; + } PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2); Intf_Tool bndTool; Bnd_Box boxParab; @@ -909,9 +935,13 @@ void PerformConicSurfHyperbola(const gp_Hypr& theHypr, int nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2); int nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2); if (nbsu > 40) + { nbsu = 40; + } if (nbsv > 40) + { nbsv = 40; + } PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2); Intf_Tool bndTool; Bnd_Box boxHypr; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_InterUtils.pxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_InterUtils.pxx index e5d4e394b1..38770c8c95 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_InterUtils.pxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_InterUtils.pxx @@ -165,14 +165,20 @@ void EstLimForInfExtr(const gp_Lin& Line, occ::handle aBasSurf; if (IsOffSurf) + { aBasSurf = SurfaceTool::BasisSurface(surface); + } gp_Dir aDirOfExt; if (IsOffSurf) + { aDirOfExt = aBasSurf->Direction(); + } else + { aDirOfExt = SurfaceTool::Direction(surface); + } double tolang = THE_TOLERANCE_ANGULAIRE; @@ -201,7 +207,9 @@ void EstLimForInfExtr(const gp_Lin& Line, Extrema_ExtElC aExtr(aL, Line, tolang); if (!aExtr.IsDone()) + { return; + } if (aExtr.IsParallel()) { @@ -235,16 +243,22 @@ void EstLimForInfExtr(const gp_Lin& Line, occ::handle aBasCurv; if (IsOffSurf) + { aBasCurv = aBasSurf->BasisCurve(); + } else + { aBasCurv = SurfaceTool::BasisCurve(surface); + } ProjLib_Plane Projector(aRefPln); Projector.Project(Line); if (!Projector.IsDone()) + { return; + } gp_Lin2d Line2d = Projector.Line(); @@ -255,14 +269,18 @@ void EstLimForInfExtr(const gp_Lin& Line, Projector.Project(aBasCurv->Line()); if (!Projector.IsDone()) + { return; + } gp_Lin2d aL2d = Projector.Line(); IntAna2d_AnaIntersection anInter(Line2d, aL2d); if (!anInter.IsDone()) + { return; + } if (anInter.IsEmpty() || anInter.IdenticalElements() || anInter.ParallelElements()) { @@ -282,7 +300,9 @@ void EstLimForInfExtr(const gp_Lin& Line, { Projector.Project(aBasCurv->Parabola()); if (!Projector.IsDone()) + { return; + } const gp_Parab2d& aP2d = Projector.Parabola(); @@ -292,14 +312,18 @@ void EstLimForInfExtr(const gp_Lin& Line, { Projector.Project(aBasCurv->Hyperbola()); if (!Projector.IsDone()) + { return; + } const gp_Hypr2d& aH2d = Projector.Hyperbola(); anInter.Perform(aH2d, aCon); } if (!anInter.IsDone()) + { return; + } if (anInter.IsEmpty()) { @@ -367,11 +391,17 @@ void EstLimForInfRevl(const gp_Lin& Line, if (U1inf || U2inf) { if (U1inf) + { U1new = std::max(0., U1new); + } else + { U2new = std::min(2 * M_PI, U2new); + } if (!V1inf && !V2inf) + { return; + } } occ::handle aBasisCurve = SurfaceTool::BasisCurve(surface); @@ -388,8 +418,10 @@ void EstLimForInfRevl(const gp_Lin& Line, aU += 1.; P = aBasisCurve->Value(aU); if (aU > 3) + { // basis curve is a line coinciding with aXVec, P is any not on aXVec P = gp_Pnt(aU, aU + 1, aU + 2); + } } gp_Vec aNVec = aXVec ^ gp_Vec(O, P); gp_Pln aPln(gp_Ax3(O, aNVec, aXVec)); @@ -426,7 +458,9 @@ void EstLimForInfRevl(const gp_Lin& Line, aNVec = aXVec ^ gp_Vec(O, P); } else + { aNVec = aXVec.Crossed(Line.Direction()); + } aPln = gp_Pln(gp_Ax3(O, aNVec, aXVec)); @@ -450,9 +484,13 @@ void EstLimForInfRevl(const gp_Lin& Line, aVmax = aVmax + std::abs(aVmax) + 10; if (V1inf) + { V1new = aVmin; + } if (V2inf) + { V2new = aVmax; + } } //! Estimate limits for infinite offset surfaces. @@ -489,7 +527,9 @@ void EstLimForInfOffs(const gp_Lin& Line, IntAna_IntConicQuad LinPlane(Line, aPln, THE_TOLERANCE_ANGULAIRE); if (!LinPlane.IsDone()) + { return; + } if (LinPlane.IsParallel() || LinPlane.IsInQuadric()) { @@ -512,9 +552,13 @@ void EstLimForInfOffs(const gp_Lin& Line, gp_Ax3 anA = aCyl.Position(); if (anA.Direct()) + { aR += anOffVal; + } else + { aR -= anOffVal; + } if (aR >= THE_TOLTANGENCY) { @@ -535,7 +579,9 @@ void EstLimForInfOffs(const gp_Lin& Line, IntAna_IntConicQuad LinCylinder(Line, aCyl); if (!LinCylinder.IsDone()) + { return; + } if (LinCylinder.IsParallel() || LinCylinder.IsInQuadric()) { @@ -579,7 +625,9 @@ void EstLimForInfOffs(const gp_Lin& Line, IntAna_IntConicQuad LinCone(Line, aCon); if (!LinCone.IsDone()) + { return; + } if (LinCone.IsParallel() || LinCone.IsInQuadric()) { @@ -619,7 +667,9 @@ void EstLimForInfOffs(const gp_Lin& Line, NoIntersection); if (NoIntersection) + { return; + } if (U1inf || U2inf) { @@ -895,20 +945,32 @@ void DoSurface(const SurfaceType& theSurface, for (iU = 0; iU < 50; iU++) { if (iU == 0) + { U = theU0; + } else if (iU == 49) + { U = theU1; + } else + { U = theU0 + dU * ((double)iU); + } for (iV = 0; iV < 50; iV++) { if (iV == 0) + { V = theV0; + } else if (iV == 49) + { V = theV1; + } else + { V = theV0 + dV * ((double)iV); + } SurfaceTool::D0(theSurface, U, V, aPnt); theBoxSurface.Add(aPnt); @@ -972,13 +1034,21 @@ void DoNewBounds(const SurfaceType& theSurface, } } if (diU > 0 && diU < iUmin) + { iUmin = diU; + } if (diU > 0 && diU > iUmax) + { iUmax = diU; + } if (diV > 0 && diV < iVmin) + { iVmin = diV; + } if (diV > 0 && diV > iVmax) + { iVmax = diV; + } } } } @@ -1005,16 +1075,24 @@ void DoNewBounds(const SurfaceType& theSurface, USmin -= 1.5 * dU; if (USmin < theU0) + { USmin = theU0; + } USmax += 1.5 * dU; if (USmax > theU1) + { USmax = theU1; + } VSmin -= 1.5 * dV; if (VSmin < theV0) + { VSmin = theV0; + } VSmax += 1.5 * dV; if (VSmax > theV1) + { VSmax = theV1; + } if (checkU) { @@ -1060,7 +1138,9 @@ bool ComputeAppendPoint(const CurveType& theCurve, } if ((W0 - w) >= THE_TOLTANGENCY || (w - W1) >= THE_TOLTANGENCY) + { return false; + } GeomAbs_SurfaceType aSType = SurfaceTool::GetType(theSurface); if (SurfaceTool::IsUPeriodic(theSurface) || aSType == GeomAbs_Cylinder || aSType == GeomAbs_Cone @@ -1075,9 +1155,13 @@ bool ComputeAppendPoint(const CurveType& theCurve, } if ((U0 - u) >= THE_TOLTANGENCY || (u - U1) >= THE_TOLTANGENCY) + { return false; + } if ((V0 - v) >= THE_TOLTANGENCY || (v - V1) >= THE_TOLTANGENCY) + { return false; + } IntCurveSurface_TransitionOnCurve TransOnCurve; ComputeTransitions(theCurve, @@ -1297,7 +1381,9 @@ inline void SortStartPoints(SortedStartPoints& thePoints) { int NbStartPoints = thePoints.Size(); if (NbStartPoints == 0) + { return; + } double ptol = 10 * Precision::PConfusion(); @@ -1388,7 +1474,9 @@ void ProcessSortedPoints(ExactInterType& int NbStartPoints = thePoints.Size(); if (NbStartPoints == 0) + { return; + } double ptol = 10 * Precision::PConfusion(); double su = 0, sv = 0, sw = 0; @@ -1527,13 +1615,21 @@ inline void ClampUVParameters(double& theU1, double& theU2, double& theV1, doubl { constexpr double THE_PARAM_LIMIT = 1.0e50; if (theU1 < -THE_PARAM_LIMIT) + { theU1 = -THE_PARAM_LIMIT; + } if (theU2 > THE_PARAM_LIMIT) + { theU2 = THE_PARAM_LIMIT; + } if (theV1 < -THE_PARAM_LIMIT) + { theV1 = -THE_PARAM_LIMIT; + } if (theV2 > THE_PARAM_LIMIT) + { theV2 = THE_PARAM_LIMIT; + } } } // namespace IntCurveSurface_InterUtils diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Intersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Intersection.cxx index 1501c74223..7084cc6719 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Intersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_Intersection.cxx @@ -198,6 +198,6 @@ void IntCurveSurface_Intersection::Dump() const } else { - std::cout << " Intersection NotDone" << std::endl; + std::cout << " Intersection NotDone" << '\n'; } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionPoint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionPoint.cxx index f991c4674d..1b497150b2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionPoint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionPoint.cxx @@ -72,9 +72,9 @@ void IntCurveSurface_IntersectionPoint::Values(gp_Pnt& void IntCurveSurface_IntersectionPoint::Dump() const { std::cout << "IntersectionPoint: P(" << myP.X() << "," << myP.Y() << "," << myP.Z() << ")" - << std::endl; + << '\n'; std::cout << " : USurf(" << myUSurf << ") VSurf(" << myVSurf << ") UCurve(" - << myUCurv << ")" << std::endl; + << myUCurv << ")" << '\n'; std::cout << " : TransitionOnSurf "; switch (myTrOnCurv) @@ -92,5 +92,5 @@ void IntCurveSurface_IntersectionPoint::Dump() const default: std::cout << " XXXXX "; } - std::cout << std::endl; + std::cout << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionSegment.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionSegment.cxx index b2917d053c..f08f79a9ba 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionSegment.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_IntersectionSegment.cxx @@ -70,8 +70,8 @@ const IntCurveSurface_IntersectionPoint& IntCurveSurface_IntersectionSegment::Se //================================================================================ void IntCurveSurface_IntersectionSegment::Dump() const { - std::cout << "\nIntersectionSegment : " << std::endl; + std::cout << "\nIntersectionSegment : " << '\n'; myP1.Dump(); myP2.Dump(); - std::cout << std::endl; + std::cout << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx index 42c67b283f..6d8311a5b1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx @@ -217,7 +217,9 @@ inline double ComputeBorderDeflection(GeomGridEval_Surface& theEval, const double aDist = (aPMid - aPParMid).Modulus(); if (aDist > aDeflection) + { aDeflection = aDist; + } } return aDeflection; @@ -289,11 +291,17 @@ inline int TriConnex(const int theTriang, ligE = (thePedge - 1) / nbdeltaVp1; colE = (thePedge - 1) - (ligE * nbdeltaVp1); if (ligP == ligE) + { typE = 1; + } else if (colP == colE) + { typE = 2; + } else + { typE = 3; + } } int linT = 0, colT = 0; @@ -383,9 +391,13 @@ inline int TriConnex(const int theTriang, linT = (1 > ligP) ? 1 : ligP; colT = (1 > (colP + colP)) ? 1 : (colP + colP); if (ligP == 0) + { linO = ligP + 1; + } else + { linO = ligP - 1; + } colO = colP; } else @@ -608,11 +620,17 @@ inline double ComputeDeflectionWithCenter(const gp_Pnt& theP1, { // Check for degenerate triangles if (theP1.SquareDistance(theP2) <= THE_MIN_EDGE_LENGTH_SQUARED) + { return 0.0; + } if (theP1.SquareDistance(theP3) <= THE_MIN_EDGE_LENGTH_SQUARED) + { return 0.0; + } if (theP2.SquareDistance(theP3) <= THE_MIN_EDGE_LENGTH_SQUARED) + { return 0.0; + } // Compute normal vector const gp_XYZ XYZ1 = theP2.XYZ() - theP1.XYZ(); @@ -622,7 +640,9 @@ inline double ComputeDeflectionWithCenter(const gp_Pnt& theP1, const double aNormLen = NormalVector.Magnitude(); if (aNormLen < gp::Resolution()) + { return 0.0; + } NormalVector.Divide(aNormLen); @@ -644,7 +664,9 @@ double ComputeMaxDeflection(const Adaptor3d_Surface& theSurface, const int theNbTriangles) { if (theNbTriangles <= 0) + { return 0.0; + } double tol = 0.0; for (int i = 1; i <= theNbTriangles; ++i) @@ -665,7 +687,9 @@ double ComputeMaxDeflection(const Adaptor3d_Surface& theSurface, const double tol1 = ComputeDeflectionWithCenter(P1, P2, P3, aCenter); if (tol1 > tol) + { tol = tol1; + } } return tol; } @@ -692,22 +716,30 @@ inline double ComputeMaxBorderDeflection(GeomGridEval_Surface& theEval, // Lower bound (U-isoline at U=U0, V varies from V0 to V1) double aDeflection = ComputeBorderDeflection(theEval, theU0, theV0, theV1, true, theNbDeltaV); if (aDeflection > maxDeflection) + { maxDeflection = aDeflection; + } // Upper bound (U-isoline at U=U1, V varies from V0 to V1) aDeflection = ComputeBorderDeflection(theEval, theU1, theV0, theV1, true, theNbDeltaV); if (aDeflection > maxDeflection) + { maxDeflection = aDeflection; + } // Lower bound (V-isoline at V=V0, U varies from U0 to U1) aDeflection = ComputeBorderDeflection(theEval, theV0, theU0, theU1, false, theNbDeltaU); if (aDeflection > maxDeflection) + { maxDeflection = aDeflection; + } // Upper bound (V-isoline at V=V1, U varies from U0 to U1) aDeflection = ComputeBorderDeflection(theEval, theV1, theU0, theU1, false, theNbDeltaU); if (aDeflection > maxDeflection) + { maxDeflection = aDeflection; + } return maxDeflection; } @@ -728,15 +760,21 @@ inline bool IsOnBound(const int theIndex1, const int aDiff = std::abs(theIndex1 - theIndex2); if (aDiff != 1 && aDiff != theNbDeltaV + 1) + { return false; + } for (int i = 0; i <= theNbDeltaU; ++i) { if ((theIndex1 == 1 + i * (theNbDeltaV + 1)) && (theIndex2 == theIndex1 - 1)) + { return false; + } if ((theIndex1 == (1 + i) * (theNbDeltaV + 1)) && (theIndex2 == theIndex1 + 1)) + { return false; + } } return (theIsOnBounds[theIndex1] && theIsOnBounds[theIndex2]); @@ -750,14 +788,22 @@ inline bool IsOnBound(const int theIndex1, inline void Destroy(void*& thePnts, void*& theU, void*& theV, void*& theIsOnBounds) { if (thePnts) + { delete[] static_cast(thePnts); + } if (theU) + { delete[] static_cast(theU); + } if (theV) + { delete[] static_cast(theV); + } if (theIsOnBounds) + { delete[] static_cast(theIsOnBounds); - thePnts = theU = theV = theIsOnBounds = NULL; + } + thePnts = theU = theV = theIsOnBounds = nullptr; } //! Allocate polyhedron arrays. diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_TheHCurveTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_TheHCurveTool.cxx index b50371e346..f11a9f09c9 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_TheHCurveTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_TheHCurveTool.cxx @@ -40,9 +40,13 @@ int IntCurveSurface_TheHCurveTool::NbSamples(const occ::handle& double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + C->NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { nbs = C->NbKnots(); @@ -50,12 +54,18 @@ int IntCurveSurface_TheHCurveTool::NbSamples(const occ::handle& nbs *= C->LastParameter() - C->FirstParameter(); double aRange = U1 - U0; if (std::abs(aRange) > Precision::PConfusion()) + { nbs /= aRange; + } if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } @@ -72,7 +82,9 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) { nbs = 3 + C->NbPoles(); @@ -81,7 +93,9 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa if (typC != GeomAbs_BSplineCurve) { if (nbs > 50) + { nbs = 50; + } int nnbs = (int)nbs; Pars = new NCollection_HArray1(1, nnbs); @@ -158,9 +172,13 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa for (i = ui1 + 1; i <= ui2; ++i) { if (i == ui2) + { t2 = U1; + } else + { t2 = aBC->Knot(i); + } dt = (t2 - t1) / nbi; j = 1; do @@ -202,7 +220,9 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa gp_Pnt p2 = aBC->Value(t2); if (p1.SquareDistance(p2) <= tol) + { continue; + } gce_MakeLin MkLin(p1, p2); const gp_Lin& lin = MkLin.Value(); @@ -219,7 +239,9 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa double d = lin.SquareDistance(pp); if (d <= aDefl2) + { continue; + } ok = false; break; @@ -241,7 +263,9 @@ occ::handle> IntCurveSurface_TheHCurveTool::SamplePa } if (k >= nbsu) + { bCont = false; + } } if (NbSamples < myMinPnts) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_ThePolygonToolOfHInter.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_ThePolygonToolOfHInter.cxx index 12a7f2b95d..b4afdb0a69 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_ThePolygonToolOfHInter.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_ThePolygonToolOfHInter.cxx @@ -28,17 +28,16 @@ void IntCurveSurface_ThePolygonToolOfHInter::Dump(const IntCurveSurface_ThePolyg static int num = 0; num++; int nbs = IntCurveSurface_ThePolygonToolOfHInter::NbSegments(L); - std::cout << "\npol2d " << num << " " << nbs << std::endl; + std::cout << "\npol2d " << num << " " << nbs << '\n'; std::cout << "Deflection " << IntCurveSurface_ThePolygonToolOfHInter::DeflectionOverEstimation(L) - << std::endl; + << '\n'; for (int i = 1; i <= nbs; i++) { gp_Pnt P(IntCurveSurface_ThePolygonToolOfHInter::BeginOfSeg(L, i)); - std::cout << "pnt " << num << " " << i << " " << P.X() << " " << P.Y() << " " << P.Z() - << std::endl; + std::cout << "pnt " << num << " " << i << " " << P.X() << " " << P.Y() << " " << P.Z() << '\n'; } gp_Pnt PF(IntCurveSurface_ThePolygonToolOfHInter::EndOfSeg(L, nbs)); std::cout << "pnt " << num << " " << nbs << " " << PF.X() << " " << PF.Y() << " " << PF.Z() - << std::endl; + << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ComputeTangence.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ComputeTangence.cxx index 3db03ace5a..5a5a2e963d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ComputeTangence.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntImp/IntImp_ComputeTangence.cxx @@ -121,7 +121,9 @@ bool IntImp_ComputeTangence(const gp_Vec DPuv[], { double t = N1.Dot(N2); if (t < 0.0) + { t = -t; + } if (t > 0.999999999) { tangent = true; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen.cxx index f2f05039fb..65fcbe6d1f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen.cxx @@ -70,7 +70,9 @@ void IntImpParGen::DeterminePosition(IntRes2d_Position& Pos1, { if (std::abs(Param1 - TheDomain.LastParameter()) < std::abs(Param1 - TheDomain.FirstParameter())) + { Pos1 = IntRes2d_End; + } } else { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen_Tool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen_Tool.cxx index 7f5d397c20..9c7e3402de 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen_Tool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntImpParGen/IntImpParGen_Tool.cxx @@ -71,7 +71,9 @@ void Determine_Position(IntRes2d_Position& Pos1, { if (std::abs(Param1 - TheDomain.LastParameter()) < std::abs(Param1 - TheDomain.FirstParameter())) + { Pos1 = IntRes2d_End; + } } else { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALine.cxx index 4395c55f8a..5f1a84bbb8 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALine.cxx @@ -133,7 +133,9 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) nbvtx = NbVertex(); if (nbvtx <= 0) + { return; + } do { SortIsOK = true; @@ -146,16 +148,24 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (fipt) { if (indf == i) + { indf = i - 1; + } else if (indf == i - 1) + { indf = i; + } } if (lapt) { if (indl == i) + { indl = i - 1; + } else if (indl == i - 1) + { indl = i; + } } } } @@ -187,12 +197,16 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -231,12 +245,16 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -269,16 +287,24 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (fipt) { if (indf == i) + { indf = i - 1; + } else if (indf == i - 1) + { indf = i; + } } if (lapt) { if (indl == i) + { indl = i - 1; + } else if (indl == i - 1) + { indl = i; + } } } } @@ -389,16 +415,24 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (lapt) { if (indl > i) + { indl--; + } else if (indl == i) + { indl = j; + } } if (fipt) { if (indf > i) + { indf--; + } else if (indf == i) + { indf = j; + } } svtx.Remove(i); nbvtx--; @@ -409,16 +443,24 @@ void IntPatch_ALine::ComputeVertexParameters(const double Tol) if (lapt) { if (indl > j) + { indl--; + } else if (indl == j) + { indl = i - 1; + } } if (fipt) { if (indf > j) + { indf--; + } else if (indf == j) + { indf = i - 1; + } } svtx.Remove(j); nbvtx--; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALineToWLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALineToWLine.cxx index 9e9601e460..919519826c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALineToWLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ALineToWLine.cxx @@ -35,7 +35,9 @@ static inline void AddPointIntoLine(occ::handle& theLine, if (theLine->NbPoints() > 0) { if (thePoint.IsSame(theLine->Value(theLine->NbPoints()), Precision::Confusion())) + { return; + } IntPatch_SpecialPoints::AdjustPointAndVertex(theLine->Value(theLine->NbPoints()), theArrPeriods, @@ -279,17 +281,23 @@ void IntPatch_ALineToWLine::CorrectEndPoint(occ::handle& theLi const gp_Cone aCone = aQuad.Cone(); const gp_Pnt anApex = aCone.Apex(); if (anApex.SquareDistance(aPntOn2S.Value()) > aSqTol) + { continue; + } } else if (aQuad.TypeQuadric() == GeomAbs_Sphere) { double aU, aV; aPntOn2S.ParametersOnSurface(anIsOnFirst, aU, aV); if (std::abs(aV - M_PI / 2) > aTol && std::abs(aV + M_PI / 2) > aTol) + { continue; + } } else + { continue; + } gp_Pnt2d PrevPrevP2d = theLine->Value(anIndFirst).ValueOnSurface(anIsOnFirst); gp_Pnt2d PrevP2d = theLine->Value(anIndSecond).ValueOnSurface(anIsOnFirst); @@ -299,7 +307,9 @@ void IntPatch_ALineToWLine::CorrectEndPoint(occ::handle& theLi aPntOn2S.ParametersOnSurface(anIsOnFirst, aXend, aYend); if (std::abs(aDir.Y()) < gp::Resolution()) + { continue; + } double aNewXend = aDir.X() / aDir.Y() * (aYend - aY0) + aX0; @@ -440,7 +450,9 @@ void IntPatch_ALineToWLine::MakeWLine( { double aStep = (theLPar - aParameter) / (double)(myNbPointsInWline - 1); if (aStep < Epsilon(theLPar)) + { break; + } bool isStepReduced = false; double aLPar = theLPar; @@ -448,11 +460,15 @@ void IntPatch_ALineToWLine::MakeWLine( for (int i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++) { if (hasVertexBeenChecked(i)) + { continue; + } aLPar = aVertexParams(i); if (std::abs(aLPar - aParameter) < aPrmTol) + { continue; + } break; } @@ -499,8 +515,10 @@ void IntPatch_ALineToWLine::MakeWLine( // We cannot compute 2D-parameters of // aPOn2S correctly. - if (anIsLastDegenerated) // the current last point is wrong + if (anIsLastDegenerated) + { // the current last point is wrong aLinOn2S->RemovePoint(aLinOn2S->NbPoints()); + } isPointValid = false; } @@ -536,7 +554,9 @@ void IntPatch_ALineToWLine::MakeWLine( const double aParam = aVertexParams(i); if (aParam <= aPrevParam) + { continue; + } if ((aParam - aPrevParam) < aPrmTol) { @@ -619,7 +639,9 @@ void IntPatch_ALineToWLine::MakeWLine( for (int i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++) { if (hasVertexBeenChecked(i)) + { continue; + } const IntPatch_Point& aVP = theALine->Vertex(i); const double aParam = aVertexParams(i); @@ -725,9 +747,13 @@ void IntPatch_ALineToWLine::MakeWLine( { // set corresponding status: to be corrected later if (aLinOn2S->NbPoints() == 1) + { anIsFirstDegenerated = true; + } else + { anIsLastDegenerated = true; + } } const double aCurVertParam = aVtx.ParameterOnLine(); @@ -771,7 +797,9 @@ void IntPatch_ALineToWLine::MakeWLine( for (int i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++) { if (hasVertexBeenChecked(i)) + { continue; + } const gp_Pnt aP2(theALine->Value(aVertexParams(i))); @@ -781,11 +809,14 @@ void IntPatch_ALineToWLine::MakeWLine( aLVtx.SetValue(aVertP2S); aLVtx.SetTolerance(aVertToler); double aParam = aLVtx.ParameterOnLine(); - if (std::abs(aParam - theLPar) - <= Precision::PConfusion()) // in the case of closed curve, - aLVtx.SetParameter(-1); // we don't know yet the number of points in the curve + if (std::abs(aParam - theLPar) <= Precision::PConfusion()) + { // in the case of closed curve, + aLVtx.SetParameter(-1); // we don't know yet the number of points in the curve + } else + { aLVtx.SetParameter(aNewVertexParam); + } aSeqVertex(++aNewVertID) = aLVtx; hasVertexBeenChecked(i) = true; isFound = true; @@ -798,7 +829,9 @@ void IntPatch_ALineToWLine::MakeWLine( } if ((aPrePointExist != IntPatch_SPntNone) && (aLinOn2S->NbPoints() > 1)) + { break; + } if (isStepReduced) { @@ -806,17 +839,23 @@ void IntPatch_ALineToWLine::MakeWLine( aStep = (theLPar - aParameter) / (double)(myNbPointsInWline - 1); if (aStep < Epsilon(theLPar)) + { break; + } aLPar = aVertexParams(aNbVert); for (int i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++) { if (hasVertexBeenChecked(i)) + { continue; + } aLPar = aVertexParams(i); if (std::abs(aLPar - aParameter) < aPrmTol) + { continue; + } break; } @@ -842,9 +881,13 @@ void IntPatch_ALineToWLine::MakeWLine( if (aLinOn2S->NbPoints() >= 3) { if (anIsFirstDegenerated) + { CorrectEndPoint(aLinOn2S, 1); + } if (anIsLastDegenerated) + { CorrectEndPoint(aLinOn2S, aLinOn2S->NbPoints()); + } } //----------------------------------------------------------------- @@ -896,8 +939,10 @@ void IntPatch_ALineToWLine::MakeWLine( for (int i = aSeqVertex.Lower(); i <= aNewVertID; i++) { IntPatch_Point aVtx = aSeqVertex(i); - if (aVtx.ParameterOnLine() == -1) // in the case of closed curve, + if (aVtx.ParameterOnLine() == -1) + { // in the case of closed curve, aVtx.SetParameter(aWLine->NbPnts()); // we set the last parameter + } aWLine->AddVertex(aVtx); } @@ -929,15 +974,21 @@ int IntPatch_ALineToWLine::CheckDeflection(const gp_XYZ& theMidPt, { double aDist = std::abs(myQuad1.Distance(theMidPt)); if (aDist > theMaxDeflection) + { return 1; + } aDist = std::max(std::abs(myQuad2.Distance(theMidPt)), aDist); if (aDist > theMaxDeflection) + { return 1; + } if ((aDist + aDist) < theMaxDeflection) + { return -1; + } return 0; } @@ -955,7 +1006,9 @@ bool IntPatch_ALineToWLine::StepComputing(const occ::handle& the double& theStep) const { if (theTgMagnitude < Precision::Confusion()) + { return false; + } const double anEps = myTol3D; @@ -1004,7 +1057,9 @@ bool IntPatch_ALineToWLine::StepComputing(const occ::handle& the const int aStatus = CheckDeflection(0.5 * (aP1 + aP2), theMaxDeflection); if (aStatus == 0) + { break; + } if (aStatus < 0) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_BVHTraversal.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_BVHTraversal.cxx index 116141a1fd..ddf3f8bfd4 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_BVHTraversal.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_BVHTraversal.cxx @@ -18,8 +18,7 @@ //================================================================================================== IntPatch_BVHTraversal::IntPatch_BVHTraversal() - : BVH_PairTraverse(), - mySet1(nullptr), + : mySet1(nullptr), mySet2(nullptr), mySelfInterference(false) { @@ -27,7 +26,7 @@ IntPatch_BVHTraversal::IntPatch_BVHTraversal() //================================================================================================== -IntPatch_BVHTraversal::~IntPatch_BVHTraversal() {} +IntPatch_BVHTraversal::~IntPatch_BVHTraversal() = default; //================================================================================================== diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_GLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_GLine.cxx index db682ce9ff..54793a2dea 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_GLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_GLine.cxx @@ -375,9 +375,13 @@ void IntPatch_GLine::AddVertex(const IntPatch_Point& Pnt) if (fipt && lapt) { while (par < pf) + { par += M_PI + M_PI; + } while (par > pl) + { par -= M_PI + M_PI; + } if (par < pf) { constexpr double PrecisionPConfusion(Precision::PConfusion() * 1000.0); @@ -397,7 +401,9 @@ void IntPatch_GLine::AddVertex(const IntPatch_Point& Pnt) if (fipt && lapt) { if (pl < par || par < pf) + { return; + } } } } @@ -455,12 +461,16 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > j) + { indl--; + } } if (fipt) { if (indf > j) + { indf--; + } } APointDeleted = true; } @@ -497,12 +507,16 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > j) + { indl--; + } } if (fipt) { if (indf > j) + { indf--; + } } } else @@ -512,12 +526,16 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > i) + { indl--; + } } if (fipt) { if (indf > i) + { indf--; + } } } APointDeleted = true; @@ -556,12 +574,16 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > j) + { indl--; + } } if (fipt) { if (indf > j) + { indf--; + } } } else @@ -571,12 +593,16 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > i) + { indl--; + } } if (fipt) { if (indf > i) + { indf--; + } } } APointDeleted = true; @@ -614,16 +640,24 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (fipt) { if (indf == i) + { indf = i - 1; + } else if (indf == i - 1) + { indf = i; + } } if (lapt) { if (indl == i) + { indl = i - 1; + } else if (indl == i - 1) + { indl = i; + } } } } @@ -632,7 +666,9 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) //// modified by jgv, 2.11.01 for BUC61033 //// if (ToBreak) + { break; + } /////////////////////////////////////////////// SortAgain = false; @@ -759,17 +795,25 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > i) + { indl--; + } else if (indl == i) + { indl = j; + } } if (fipt) { if (indf > i) + { indf--; + } else if (indf == i) + { indf = j; + } } svtx.Remove(i); @@ -781,17 +825,25 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) if (lapt) { if (indl > j) + { indl--; + } else if (indl == j) + { indl = i - 1; + } } if (fipt) { if (indf > j) + { indf--; + } else if (indf == j) + { indf = i - 1; + } } svtx.Remove(j); @@ -814,15 +866,23 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) bool is2PI = (std::abs(ponline - PiPi) <= PrecisionPConfusion); if (nbvtx > 2 && // do this check if seam edge only gives vertices - !is2PI) // but always change 2PI -> 0 + !is2PI) + { // but always change 2PI -> 0 continue; + } if (is2PI) + { newParam = 0; + } else if (std::abs(ponline) <= PrecisionPConfusion) + { newParam = PiPi; + } else + { newParam -= PiPi; + } // if( (std::abs(ponline)<=PrecisionPConfusion) // ||(std::abs(ponline-M_PI-M_PI) <=PrecisionPConfusion)) @@ -834,15 +894,23 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) int flag = 0; if ((std::abs(u1a - u1b) <= PrecisionPConfusion)) + { flag |= 1; + } if ((std::abs(v1a - v1b) <= PrecisionPConfusion)) + { flag |= 2; + } if ((std::abs(u2a - u2b) <= PrecisionPConfusion)) + { flag |= 4; + } if ((std::abs(v2a - v2b) <= PrecisionPConfusion)) + { flag |= 8; + } bool TestOn1 = false; bool TestOn2 = false; @@ -887,9 +955,13 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) else { if (std::abs(U1A - u1min) > PrecisionPConfusion) + { ToBreak = true; + } if (std::abs(U1B - u1max) > PrecisionPConfusion) + { ToBreak = true; + } } /////////////////////////////////////////////// // eap, =>> @@ -948,10 +1020,14 @@ void IntPatch_GLine::ComputeVertexParameters(const double /*Tol*/) else { if (std::abs(U2A - u2min) > PrecisionPConfusion) + { ToBreak = true; + } if (std::abs(U2B - u2max) > PrecisionPConfusion) + { ToBreak = true; + } } /////////////////////////////////////////////// // eap, =>> diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HCurve2dTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HCurve2dTool.cxx index 9dcc9be24b..203a7cee8d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HCurve2dTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HCurve2dTool.cxx @@ -38,13 +38,17 @@ int IntPatch_HCurve2dTool::NbSamples(const occ::handle& C, nbs *= U1 - U0; nbs /= C->LastParameter() - C->FirstParameter(); if (nbs < 2.0) + { nbs = 2.0; + } } break; default: return 25; } if (nbs > 50.0) + { return 50; + } return ((int)nbs); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HInterTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HInterTool.cxx index a598487e92..5e5f4dad52 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HInterTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_HInterTool.cxx @@ -48,9 +48,13 @@ int IntPatch_HInterTool::NbSamplesV(const occ::handle& S, int nbs = S->NbVKnots(); nbs *= S->VDegree(); if (!S->IsVRational()) + { nbs *= 2; + } if (nbs < 4) + { nbs = 4; + } return nbs; } break; @@ -83,9 +87,13 @@ int IntPatch_HInterTool::NbSamplesU(const occ::handle& S, int nbs = S->NbUKnots(); nbs *= S->UDegree(); if (!S->IsURational()) + { nbs *= 2; + } if (nbs < 4) + { nbs = 4; + } return nbs; } case GeomAbs_Torus: diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpImpIntersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpImpIntersection.cxx index 05c45bf9fc..6155d0eb51 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpImpIntersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpImpIntersection.cxx @@ -142,7 +142,9 @@ bool IntersectionWithAnArc(gp_Pnt& PSurf, dtheta = (u1alin - u0alin) * 0.01; double du = 0.000000001; if (du >= dtheta) + { du = dtheta / 2; + } double distmin = RealLast(); double thetamin = 0.; @@ -249,13 +251,21 @@ bool IntersectionWithAnArc(gp_Pnt& PSurf, //-- double dr = -PaPr.Dot(d2d); if (da < -damax) + { da = -damax; + } else if (da > damax) + { da = damax; + } if (dr < -drmax) + { dr = -drmax; + } else if (dr > drmax) + { dr = drmax; + } if (std::abs(da) < 1e-10 && std::abs(dr) < 1e-10) { @@ -473,7 +483,9 @@ void PutPointsOnLine(const occ::handle& NCollection_Array1 UsedLine(1, nblin); NCollection_Array1 Done(1, nbpnt); for (i = 1; i <= nbpnt; i++) + { Done(i) = 0; //-- Initialisation a la main + } for (i = 1; i <= nbpnt; i++) { @@ -513,7 +525,9 @@ void PutPointsOnLine(const occ::handle& for (int indiceline = 1; indiceline <= slin.Length(); indiceline++) { if (UsedLine(indiceline) != 0) + { continue; + } linenumber = indiceline; //-- Attention , les points peuvent etre deplaces @@ -540,7 +554,9 @@ void PutPointsOnLine(const occ::handle& if (aNorm1.Magnitude() > gp::Resolution() && aNorm2.Magnitude() > gp::Resolution()) { if (aNorm1.IsParallel(aNorm2, aTolAng)) + { tolerance = std::sqrt(tolerance); + } } // } // Modified by skv - Thu Jan 15 15:57:15 2004 OCC4455 End @@ -1077,7 +1093,9 @@ bool FindLine(gp_Pnt& Psurf, double& theOutputToler) { if ((QuadSurf1.Distance(Psurf) > Tol) || (QuadSurf2.Distance(Psurf) > Tol)) + { return false; + } // Traitement du point de depart ayant pour representation Psurf // dans l espace. On recherche la ligne d intersection contenant ce point. @@ -1314,7 +1332,9 @@ bool FindLine(gp_Pnt& Psurf, } if (aSqDistMin == RealLast()) + { return false; + } theOutputToler = std::max(theOutputToler, std::sqrt(aSqDistMin)); @@ -1934,18 +1954,26 @@ static bool IsRLineGood(const IntSurf_Quadric& Quad1, } if (aNbPntsM1 < 1) + { return false; + } Extrema_ExtPC anExtr; GeomAdaptor_Curve anAC; occ::handle aCurv; if (aGType == IntPatch_Ellipse) + { aCurv = new Geom_Ellipse(theGLine->Ellipse()); + } else if (aGType == IntPatch_Parabola) + { aCurv = new Geom_Parabola(theGLine->Parabola()); + } else if (aGType == IntPatch_Hyperbola) + { aCurv = new Geom_Hyperbola(theGLine->Hyperbola()); + } if (!aCurv.IsNull()) { @@ -1990,7 +2018,9 @@ static bool IsRLineGood(const IntSurf_Quadric& Quad1, const double aSQDist = SquareDistance(theGLine, aP, anExtr); if (aSQDist > aSQTol) + { return true; + } } return false; @@ -2011,7 +2041,9 @@ void ProcessRLine(NCollection_Sequence>& slin, double TolArc = 100.0 * _TolArc; if (TolArc > 0.1) + { TolArc = 0.1; + } int i, j, k; int Nblin, Nbvtx, Nbpt; @@ -2602,10 +2634,14 @@ void IntPatch_ImpImpIntersection::Perform(const occ::handle& const double anUperiod = 2.0 * M_PI; if (aU1l - aU1f > anUperiod) + { aU1l = aU1f + anUperiod; + } if (aU2l - aU2f > anUperiod) + { aU2l = aU2f + anUperiod; + } aBox1.Add(gp_Pnt2d(aU1f, S1->FirstVParameter())); aBox1.Add(gp_Pnt2d(aU1l, S1->LastVParameter())); @@ -2735,7 +2771,9 @@ void IntPatch_ImpImpIntersection::Perform(const occ::handle& if (bEmpty) { if (myDone == IntStatus_Fail) + { myDone = IntStatus_OK; + } return; } @@ -4280,7 +4318,9 @@ public: const IntSurf_Quadric& GetQSurface(const int theIdx) const { if (theIdx <= 1) + { return myQuad1; + } return myQuad2; } @@ -4589,7 +4629,9 @@ static bool StepComputing(const math_Matrix& theMatr, { // Det1 if (anAbsD1 <= aNulValue) + { return isSuccess; + } theDeltaU1Found = std::abs(aFree(1) * theMatr(2, 4) - aFree(2) * theMatr(1, 4)) / anAbsD1; isSuccess = true; @@ -4598,7 +4640,9 @@ static bool StepComputing(const math_Matrix& theMatr, { // Det3 if (anAbsD3 <= aNulValue) + { return isSuccess; + } theDeltaU1Found = std::abs(aFree(2) * theMatr(3, 4) - aFree(3) * theMatr(2, 4)) / anAbsD3; isSuccess = true; @@ -4610,7 +4654,9 @@ static bool StepComputing(const math_Matrix& theMatr, { // Det2 if (anAbsD2 <= aNulValue) + { return isSuccess; + } theDeltaU1Found = std::abs(aFree(1) * theMatr(3, 4) - aFree(3) * theMatr(1, 4)) / anAbsD2; isSuccess = true; @@ -4619,7 +4665,9 @@ static bool StepComputing(const math_Matrix& theMatr, { // Det3 if (anAbsD3 <= aNulValue) + { return isSuccess; + } theDeltaU1Found = std::abs(aFree(2) * theMatr(3, 4) - aFree(3) * theMatr(2, 4)) / anAbsD3; isSuccess = true; @@ -5283,7 +5331,9 @@ bool ComputationMethods::CylCylComputeParameters(const double theU1par, const double aTol = 1.0 - aTol0; if (theWLIndex < 0 || theWLIndex > 1) + { return false; + } const double aSign = theWLIndex ? -1.0 : 1.0; @@ -5293,14 +5343,18 @@ bool ComputationMethods::CylCylComputeParameters(const double theU1par, if (anArg >= aTol) { if (theDelta) + { *theDelta = 0.0; + } anArg = 1.0; } else if (anArg <= -aTol) { if (theDelta) + { *theDelta = 0.0; + } anArg = -1.0; } @@ -5377,10 +5431,14 @@ bool ComputationMethods::CylCylComputeParameters(const double theU1par, double& theV2) { if (!CylCylComputeParameters(theU1par, theWLIndex, theCoeffs, theU2)) + { return false; + } if (!CylCylComputeParameters(theU1par, theU2, theCoeffs, theV1, theV2)) + { return false; + } return true; } @@ -5520,14 +5578,20 @@ static bool ExcludeNearElements(double theArr[], // Here, anA >= anB if (Precision::IsInfinite(anA)) + { break; + } if ((anA - anB) < theTol) { if ((anB != 0.0) && (anB != theUSurf1f) && (anB != theUSurf1l)) + { anA = (anA + anB) / 2.0; + } else + { anA = anB; + } // Make this element infinite an forget it //(we will not use it in next iterations). @@ -5586,7 +5650,9 @@ static bool AddPointIntoWL(const IntSurf_Quadric& theQuad1, theTol2D, thePeriodOfSurf1, aU1par > 0.5 * (theUfSurf1 + theUlSurf1))) + { return false; + } if ((theLine->NbPoints() > 0) && ((theUlSurf1 - theUfSurf1) >= (thePeriodOfSurf1 - theTol2D)) && (((aU1par + thePeriodOfSurf1 - theUlSurf1) <= theTol2D) @@ -5615,15 +5681,21 @@ static bool AddPointIntoWL(const IntSurf_Quadric& theQuad1, double aU2par = thePntOnSurf2.X(); if (!InscribePoint(theUfSurf2, theUlSurf2, aU2par, theTol2D, thePeriodOfSurf1, false)) + { return false; + } double aV1par = thePntOnSurf1.Y(); if ((aV1par - theVlSurf1 > theTol2D) || (theVfSurf1 - aV1par > theTol2D)) + { return false; + } double aV2par = thePntOnSurf2.Y(); if ((aV2par - theVlSurf2 > theTol2D) || (theVfSurf2 - aV2par > theTol2D)) + { return false; + } // Get intersection point and add it in the WL IntSurf_PntOn2S aPnt; @@ -5643,9 +5715,13 @@ static bool AddPointIntoWL(const IntSurf_Quadric& theQuad1, double aUl = 0.0, aVl = 0.0; const IntSurf_PntOn2S aPlast = theLine->Value(aNbPnts); if (isTheReverse) + { aPlast.ParametersOnS2(aUl, aVl); + } else + { aPlast.ParametersOnS1(aUl, aVl); + } if (!theFlBefore && (aU1par <= aUl)) { @@ -5665,7 +5741,9 @@ static bool AddPointIntoWL(const IntSurf_Quadric& theQuad1, } if (theOnlyCheck) + { return true; + } // theTol2D is minimal step along parameter changed. // Therefore, if we apply this minimal step two @@ -5679,12 +5757,16 @@ static bool AddPointIntoWL(const IntSurf_Quadric& theQuad1, } if (theOnlyCheck) + { return true; + } theLine->Add(aPnt); if (!isThePrecise) + { return true; + } // Try to precise existing WLine aNbPnts = theLine->NbPoints(); @@ -5780,7 +5862,9 @@ void WorkWithBoundaries::AddBoundaryPoint(const occ::handle& the { double aU2 = 0.0, aV1 = 0.0, aV2 = 0.0; if (!ComputationMethods::CylCylComputeParameters(theX, WLIndex, Coeffs, aU2, aV1, aV2)) + { return false; + } theF = (IsV1 ? aV1 : aV2) - VBound; return true; } @@ -5792,11 +5876,15 @@ void WorkWithBoundaries::AddBoundaryPoint(const occ::handle& the const double theUHi, double& theU1Star) -> bool { if (!(theULo < theUHi)) + { return false; + } VBoundDelta aFunc{myCoeffs, theWLIndex, theIsV1, theVBound}; double aFlo = 0.0, aFhi = 0.0; if (!aFunc.Value(theULo, aFlo) || !aFunc.Value(theUHi, aFhi)) + { return false; + } if (aFlo == 0.0) { theU1Star = theULo; @@ -5808,13 +5896,17 @@ void WorkWithBoundaries::AddBoundaryPoint(const occ::handle& the return true; } if (aFlo * aFhi > 0.0) + { return false; // no bracketed crossing + } MathUtils::Config aCfg; aCfg.XTolerance = Precision::PConfusion(); const MathUtils::ScalarResult aRes = MathRoot::Brent(aFunc, theULo, theUHi, aCfg); if (aRes.Status != MathUtils::Status::OK || !aRes.Root.has_value()) + { return false; + } theU1Star = *aRes.Root; return true; }; @@ -5872,9 +5964,13 @@ void WorkWithBoundaries::AddBoundaryPoint(const occ::handle& the // Point on true V-boundary. if (aTS == SearchV1) + { aV1 = anArrVzad[anIndex]; - else // if(aTS[anIndex] == SearchV2) + } + else + { // if(aTS[anIndex] == SearchV2) aV2 = anArrVzad[anIndex]; + } } } } @@ -5888,7 +5984,9 @@ void WorkWithBoundaries::AddBoundaryPoint(const occ::handle& the for (int i = 0; i < aSize; i++) { if (aUVPoint[i].myU1 == RealLast()) + { break; + } if (!AddPointIntoWL(myQuad1, myQuad2, @@ -5946,7 +6044,9 @@ static void SeekAdditionalPoints(const IntSurf_Quadric& theQua const bool isTheReverse) { if (theLine.IsNull()) + { return; + } int aNbPoints = theEndPointOnLine - theStartPointOnLine + 1; @@ -6099,9 +6199,13 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg = -(theCoeffs.mC + 1) / theCoeffs.mB; if (anArg > 1.0) + { anArg = 1.0; + } if (anArg < -1.0) + { anArg = -1.0; + } const double aDAngle = acos(anArg); theURange[0].Add(theCoeffs.mFI1); @@ -6116,9 +6220,13 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg = (1 - theCoeffs.mC) / theCoeffs.mB; if (anArg > 1.0) + { anArg = 1.0; + } if (anArg < -1.0) + { anArg = -1.0; + } const double aDAngle = acos(anArg); theURange[0].Add(aDAngle + theCoeffs.mFI1); @@ -6135,14 +6243,22 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg1 = (1 - theCoeffs.mC) / theCoeffs.mB, anArg2 = -(theCoeffs.mC + 1) / theCoeffs.mB; if (anArg1 > 1.0) + { anArg1 = 1.0; + } if (anArg1 < -1.0) + { anArg1 = -1.0; + } if (anArg2 > 1.0) + { anArg2 = 1.0; + } if (anArg2 < -1.0) + { anArg2 = -1.0; + } const double aDAngle1 = acos(anArg1), aDAngle2 = acos(anArg2); //(U=[aDAngle1;aDAngle2]+aFI1) || @@ -6180,9 +6296,13 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg = (1 - theCoeffs.mC) / theCoeffs.mB; if (anArg > 1.0) + { anArg = 1.0; + } if (anArg < -1.0) + { anArg = -1.0; + } const double aDAngle = acos(anArg); theURange[0].Add(theCoeffs.mFI1); @@ -6197,9 +6317,13 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg = -(theCoeffs.mC + 1) / theCoeffs.mB; if (anArg > 1.0) + { anArg = 1.0; + } if (anArg < -1.0) + { anArg = -1.0; + } const double aDAngle = acos(anArg); theURange[0].Add(aDAngle + theCoeffs.mFI1); @@ -6215,14 +6339,22 @@ bool WorkWithBoundaries::BoundariesComputing(const ComputationMethods::stCoeffsV double anArg1 = -(theCoeffs.mC + 1) / theCoeffs.mB, anArg2 = (1 - theCoeffs.mC) / theCoeffs.mB; if (anArg1 > 1.0) + { anArg1 = 1.0; + } if (anArg1 < -1.0) + { anArg1 = -1.0; + } if (anArg2 > 1.0) + { anArg2 = 1.0; + } if (anArg2 < -1.0) + { anArg2 = -1.0; + } const double aDAngle1 = acos(anArg1), aDAngle2 = acos(anArg2); theURange[0].Add(aDAngle1 + theCoeffs.mFI1); @@ -6279,9 +6411,13 @@ static void CriticalPointsComputing(const ComputationMethods::stCoeffsValue& the { double anArg = (aCOS - theCoeffs.mC) / theCoeffs.mB; if (anArg > 1.0) + { anArg = 1.0; + } if (anArg < -1.0) + { anArg = -1.0; + } theU1crit[4] = -acos(anArg) + theCoeffs.mFI1; theU1crit[5] = acos(anArg) + theCoeffs.mFI1; @@ -6321,7 +6457,9 @@ static void CriticalPointsComputing(const ComputationMethods::stCoeffsValue& the theU1crit[i] = fmod(theU1crit[i], thePeriod); if (theU1crit[i] < 0.0) + { theU1crit[i] += thePeriod; + } } // Here all not infinite elements of theU1crit are in [0, thePeriod) range @@ -6345,7 +6483,9 @@ static void CriticalPointsComputing(const ComputationMethods::stCoeffsValue& the // 1st not infinte element is found if (theNbCritPointsMax == 1) + { break; + } // Here theNbCritPointsMax > 1 @@ -6389,7 +6529,9 @@ void WorkWithBoundaries::BoundaryEstimation(const gp_Cylinder& theCy1, // If sine is small then it can be compared with angle. if (aSqSinA < Precision::Angular() * Precision::Angular()) + { return; + } // Half of delta V. Delta V is a distance between // projections of two opposite parallelogram vertices @@ -6447,7 +6589,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( Bnd_Range aRangeS1, aRangeS2; theBW.BoundaryEstimation(theCyl1, theCyl2, aRangeS1, aRangeS2); if (aRangeS1.IsVoid() || aRangeS2.IsVoid()) + { return IntPatch_ImpImpIntersection::IntStatus_OK; + } { // Quotation of the message from issue #26894 (author MSV): @@ -6459,7 +6603,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( const double aF = 1.0e+5; const double aMaxV1Range = aF * theCyl1.Radius(), aMaxV2Range = aF * theCyl2.Radius(); if ((aRangeS1.Delta() > aMaxV1Range) || (aRangeS2.Delta() > aMaxV2Range)) + { return IntPatch_ImpImpIntersection::IntStatus_InfiniteSectionCurve; + } } // bool isGoodIntersection = false; @@ -6554,7 +6700,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( for (int i = 0; i < theNbOfRanges; i++) { if (theRange[i].IsVoid()) + { continue; + } InscribeInterval(aUSurf1f, aUSurf1l, theRange[i], aTol2D, aPeriod); } @@ -6621,11 +6769,15 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( // Process every continuous region bool isAddedIntoWL[aNbWLines]; for (int i = 0; i < aNbWLines; i++) + { isAddedIntoWL[i] = false; + } double anUf = 1.0, anUl = 0.0; if (!theRange[aCurInterval].GetBounds(anUf, anUl)) + { continue; + } const bool isDeltaPeriod = IsEqual(anUl - anUf, aPeriod); @@ -6749,13 +6901,21 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( aTol = std::max(aTol, aTol2D); if (std::abs(aU2[i]) <= aTol) + { aU2[i] = 0.0; + } else if (std::abs(aU2[i] - aPeriod) <= aTol) + { aU2[i] = aPeriod; + } else if (std::abs(aU2[i] - aUSurf2f) <= aTol) + { aU2[i] = aUSurf2f; + } else if (std::abs(aU2[i] - aUSurf2l) <= aTol) + { aU2[i] = aUSurf2l; + } } else { @@ -6803,16 +6963,24 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( { // end of the line double aU2prev = 0.0, aV2prev = 0.0; if (isReversed) + { aWLine[i]->Curve()->Value(aNbPntsWL).ParametersOnS1(aU2prev, aV2prev); + } else + { aWLine[i]->Curve()->Value(aNbPntsWL).ParametersOnS2(aU2prev, aV2prev); + } if (2.0 * std::abs(aU2prev - aU2[i]) > aPeriod) { if (aU2prev > aU2[i]) + { aU2[i] += aPeriod; + } else + { aU2[i] -= aPeriod; + } } } } @@ -6861,7 +7029,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( } if (aWLFindStatus[i] == WLFStatus_Broken) + { isBroken = true; + } if (!isBoundIntersect) { @@ -6943,9 +7113,13 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( { double aU2p = 0.0, aV2p = 0.0; if (isReversed) + { aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS1(aU2p, aV2p); + } else + { aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS2(aU2p, aV2p); + } const double aDelta = aU2[i] - aU2p; @@ -7007,7 +7181,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( } if (aWLFindStatus[i] == WLFStatus_Broken) + { isBroken = true; + } } // for(int i = 0; i < aNbWLines; i++) if (isBroken) @@ -7050,9 +7226,13 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( { double aU2p = 0.0, aV2p = 0.0; if (isReversed) + { aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS1(aU2p, aV2p); + } else + { aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS2(aU2p, aV2p); + } const double aDelta = aU2[i] - aU2p; @@ -7109,13 +7289,19 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( for (int i = 0; i < aNbWLines; i++) { if ((aWLFindStatus[i] == WLFStatus_Absent) || (aWLine[i]->NbPnts() == 0)) + { continue; + } double aU1c = 0.0, aV1c = 0.0; if (isReversed) + { aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS2(aU1c, aV1c); + } else + { aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS1(aU1c, aV1c); + } anUmaxAdded = std::max(anUmaxAdded, aU1c); isChanged = true; @@ -7249,10 +7435,14 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( } if (aStepTmp < aStepMin) + { aStepTmp = aStepMin; + } if (aStepTmp > aStepMax) + { aStepTmp = aStepMax; + } anUexpect[i] = anU1 + aStepTmp; aMinUexp = std::min(aMinUexp, anUexpect[i]); @@ -7263,14 +7453,18 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( } if (Precision::PConfusion() >= (anUl - anU1)) + { anU1 = anUl; + } anUf = anU1; for (int i = 0; i < aNbWLines; i++) { if (aWLine[i]->NbPnts() != 1) + { isAddedIntoWL[i] = false; + } if (anU1 == anUl) { // strictly equal. Tolerance is considered above. @@ -7310,7 +7504,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( const IntSurf_PntOn2S& aPl = aWLine[i]->Point(2); if (aPf.IsSame(aPl, Precision::Confusion())) + { isGood = false; + } } else if (aWLine[i]->NbPnts() > 2) { @@ -7373,7 +7569,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( double anAngle = aDir.Angle(aTg); if (anAngle > M_PI_2) + { anAngle -= M_PI; + } if (std::abs(anAngle) > 0.25) // ~ 14deg. { @@ -7507,7 +7705,9 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( { double anU2t = 0.0; if (!ComputationMethods::CylCylComputeParameters(anUmid, i, anEquationCoeffs, anU2t)) + { continue; + } double aDU2 = fmod(std::abs(anU2t - aCurU2), aPeriod); aDU2 = std::min(aDU2, std::abs(aDU2 - aPeriod)); @@ -7560,16 +7760,24 @@ static IntPatch_ImpImpIntersection::IntStatus CyCyNoGeometric( if (isDone) { if (std::abs(aV1 - aVSurf1f) <= aTol2D) + { aV1 = aVSurf1f; + } if (std::abs(aV1 - aVSurf1l) <= aTol2D) + { aV1 = aVSurf1l; + } if (std::abs(aV2 - aVSurf2f) <= aTol2D) + { aV2 = aVSurf2f; + } if (std::abs(aV2 - aVSurf2l) <= aTol2D) + { aV2 = aVSurf2l; + } isDone = AddPointIntoWL(aQuad1, aQuad2, @@ -7742,10 +7950,14 @@ IntPatch_ImpImpIntersection::IntStatus IntCyCy( Bnd_Range anURange[2][aNbOfBoundaries]; // const if (!WorkWithBoundaries::BoundariesComputing(anEquationCoeffs1, aPeriod, anURange[0])) + { return IntPatch_ImpImpIntersection::IntStatus_OK; + } if (!WorkWithBoundaries::BoundariesComputing(anEquationCoeffs2, aPeriod, anURange[1])) + { return IntPatch_ImpImpIntersection::IntStatus_OK; + } // anURange[*] can be in different periodic regions in // compare with First-Last surface. E.g. the surface @@ -7807,7 +8019,9 @@ IntPatch_ImpImpIntersection::IntStatus IntCyCy( // to inscribe [Ufirst, Ulast] in the boundaries of aCurrRange. double aF = 1.0, aL = 0.0; if (!aCurrRange.GetBounds(aF, aL)) + { continue; + } if ((aL < aUSBou[aCID][0])) { @@ -8417,7 +8631,9 @@ bool ExploreCurve(const gp_Cone& theCo, double aPrm = anItr.Value(); if ((aPrm - aT1) < Precision::PConfusion()) + { continue; + } bool isLast = false; if ((aT2 - aPrm) < Precision::PConfusion()) @@ -8437,7 +8653,9 @@ bool ExploreCurve(const gp_Cone& theCo, } if (isLast) + { break; + } } if (theLC.IsEmpty()) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpPrmIntersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpPrmIntersection.cxx index 1d1fc2020f..120e0e1021 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpPrmIntersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_ImpPrmIntersection.cxx @@ -90,7 +90,9 @@ static IntPatch_SpecPntType IsSeamOrPole(const occ::handle& t const double theDeltaMax) { if ((theRefIndex < 1) || (theRefIndex >= theLine->NbPoints())) + { return IntPatch_SPntNone; + } // Parameters on Quadric and on parametric for reference point double aUQRef, aVQRef, aUPRef, aVPRef; @@ -135,7 +137,9 @@ static IntPatch_SpecPntType IsSeamOrPole(const occ::handle& t const double aDeltaU = std::abs(aUQRef - aUQNext); if ((aType != GeomAbs_Torus) && (aDeltaU < theDeltaMax)) + { return IntPatch_SPntNone; + } switch (aType) { @@ -146,13 +150,19 @@ static IntPatch_SpecPntType IsSeamOrPole(const occ::handle& t const double aDeltaV = std::abs(aVQRef - aVQNext); if ((aDeltaU >= theDeltaMax) && (aDeltaV >= theDeltaMax)) + { return IntPatch_SPntSeamUV; + } if (aDeltaU >= theDeltaMax) + { return IntPatch_SPntSeamU; + } if (aDeltaV >= theDeltaMax) + { return IntPatch_SPntSeamV; + } } break; @@ -477,17 +487,25 @@ void Recadre(const bool, { case GeomAbs_Torus: while (V1 < (V1p - 1.5 * M_PI)) + { V1 += M_PI + M_PI; + } while (V1 > (V1p + 1.5 * M_PI)) + { V1 -= M_PI + M_PI; + } [[fallthrough]]; case GeomAbs_Cylinder: case GeomAbs_Cone: case GeomAbs_Sphere: while (U1 < (U1p - 1.5 * M_PI)) + { U1 += M_PI + M_PI; + } while (U1 > (U1p + 1.5 * M_PI)) + { U1 -= M_PI + M_PI; + } break; default: break; @@ -496,17 +514,25 @@ void Recadre(const bool, { case GeomAbs_Torus: while (V2 < (V2p - 1.5 * M_PI)) + { V2 += M_PI + M_PI; + } while (V2 > (V2p + 1.5 * M_PI)) + { V2 -= M_PI + M_PI; + } [[fallthrough]]; case GeomAbs_Cylinder: case GeomAbs_Cone: case GeomAbs_Sphere: while (U2 < (U2p - 1.5 * M_PI)) + { U2 += M_PI + M_PI; + } while (U2 > (U2p + 1.5 * M_PI)) + { U2 -= M_PI + M_PI; + } break; default: break; @@ -689,9 +715,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& // double aLocalPas = Pas; if (reversed) + { aLocalPas = GetLocalStep(Surf1, Pas); + } else + { aLocalPas = GetLocalStep(Surf2, Pas); + } Func.SetImplicitSurface(Quad); Func.Set(IntSurf_QuadricTool::Tolerance(Quad)); @@ -786,16 +816,24 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& if (!reversed) { if (myIsStartPnt) + { solins.Perform(Func, Surf2, myUStart, myVStart); + } else + { solins.Perform(Func, Surf2, D2, TolTang); + } } else { if (myIsStartPnt) + { solins.Perform(Func, Surf1, myUStart, myVStart); + } else + { solins.Perform(Func, Surf1, D1, TolTang); + } } NbPointIns = solins.NbPoints(); for (int i = 1; i <= NbPointIns; i++) @@ -882,9 +920,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& Quad.Parameters(valpt, AnU1, V1); if ((V1 < Vmin) && (Vmin - V1 < TolV)) + { V1 = Vmin; + } if ((V1 > Vmax) && (V1 - Vmax < TolV)) + { V1 = Vmax; + } if (reversed) { @@ -962,9 +1004,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& case GeomAbs_Sphere: case GeomAbs_Torus: while (U2 < (AnU2 - 1.5 * M_PI)) + { U2 += M_PI + M_PI; + } while (U2 > (AnU2 + 1.5 * M_PI)) + { U2 -= M_PI + M_PI; + } break; default: break; @@ -972,9 +1018,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& if (typeS2 == GeomAbs_Torus) { while (V2 < (AnV2 - 1.5 * M_PI)) + { V2 += M_PI + M_PI; + } while (V2 > (AnV2 + 1.5 * M_PI)) + { V2 -= M_PI + M_PI; + } } thelin->SetUV(k, true, U2, V2); } @@ -990,9 +1040,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& case GeomAbs_Sphere: case GeomAbs_Torus: while (U2 < (AnU2 - 1.5 * M_PI)) + { U2 += M_PI + M_PI; + } while (U2 > (AnU2 + 1.5 * M_PI)) + { U2 -= M_PI + M_PI; + } break; default: break; @@ -1000,9 +1054,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& if (typeS2 == GeomAbs_Torus) { while (V2 < (AnV2 - 1.5 * M_PI)) + { V2 += M_PI + M_PI; + } while (V2 > (AnV2 + 1.5 * M_PI)) + { V2 -= M_PI + M_PI; + } } thelin->SetUV(k, false, U2, V2); } @@ -1034,9 +1092,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& Quad.Parameters(PPoint.Value(), U1, V1); if ((V1 < Vmin) && (Vmin - V1 < TolV)) + { V1 = Vmin; + } if ((V1 > Vmax) && (V1 - Vmax < TolV)) + { V1 = Vmax; + } PPoint.Parameters(themult, U2, V2); Surf2->D1(U2, V2, ptbid, d1u, d1v); //-- @@@@ @@ -1046,9 +1108,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& Quad.Parameters(PPoint.Value(), U2, V2); if ((V2 < Vmin) && (Vmin - V2 < TolV)) + { V2 = Vmin; + } if ((V2 > Vmax) && (V2 - Vmax < TolV)) + { V2 = Vmax; + } PPoint.Parameters(themult, U1, V1); Surf1->D1(U1, V1, ptbid, d1u, d1v); //-- @@@@ @@ -1132,9 +1198,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& Quad.Parameters(PPoint.Value(), U1, V1); if ((V1 < Vmin) && (Vmin - V1 < TolV)) + { V1 = Vmin; + } if ((V1 > Vmax) && (V1 - Vmax < TolV)) + { V1 = Vmax; + } PPoint.Parameters(themult, U2, V2); Surf2->D1(U2, V2, ptbid, d1u, d1v); //-- @@@@ @@ -1145,9 +1215,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& Quad.Parameters(PPoint.Value(), U2, V2); if ((V2 < Vmin) && (Vmin - V2 < TolV)) + { V2 = Vmin; + } if ((V2 > Vmax) && (V2 - Vmax < TolV)) + { V2 = Vmax; + } PPoint.Parameters(themult, U1, V1); Surf1->D1(U1, V1, ptbid, d1u, d1v); //-- @@@@ @@ -1316,9 +1390,13 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& } } if (dofirst) + { wlin1->Replace(indfirst, ptdeb); + } if (dolast) + { wlin1->Replace(indlast, ptfin); + } } } } // if (seqpdep.Length() != 0 || seqpins.Length() != 0) { @@ -1390,7 +1468,9 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& gp_Pnt2d _p2d = thesegm.Curve()->Value(paramf); occ::handle _vtx; if (!PStartf.IsNew()) + { _vtx = PStartf.Vertex(); + } const gp_Pnt& _Pp = PStartf.Value(); _thepointAtBeg.SetValue(_Pp, PStartf.Tolerance(), false); if (!reversed) @@ -1408,7 +1488,9 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& _thepointAtBeg.SetParameters(_u1, _v1, _u2, _v2); _thepointAtBeg.SetParameter(paramf); if (!PStartf.IsNew()) + { _thepointAtBeg.SetVertex(reversed, _vtx); + } _thepointAtBeg.SetArc(reversed, thesegm.Curve(), paramf, TLineUnk, TArcUnk); gp_Vec d1u1, d1v1, d1u2, d1v2; @@ -1455,7 +1537,9 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& gp_Pnt2d _p2d = thesegm.Curve()->Value(paraml); occ::handle _vtx; if (!PStartl.IsNew()) + { _vtx = PStartl.Vertex(); + } const gp_Pnt& _Pp = PStartl.Value(); IntPatch_Point _thepoint; _thepointAtEnd.SetValue(_Pp, PStartl.Tolerance(), false); @@ -1474,7 +1558,9 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& _thepointAtEnd.SetParameters(_u1, _v1, _u2, _v2); _thepointAtEnd.SetParameter(paraml); if (!PStartl.IsNew()) + { _thepointAtEnd.SetVertex(reversed, _vtx); + } _thepointAtEnd.SetArc(reversed, thesegm.Curve(), paraml, TLineUnk, TArcUnk); gp_Vec d1u1, d1v1, d1u2, d1v2; @@ -1686,15 +1772,21 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& occ::handle aL = occ::down_cast(slin(i)); if (!reversed) + { IntPatch_RstInt::PutVertexOnLine(aL, Surf1, D1, Surf2, true, TolTang); + } else + { IntPatch_RstInt::PutVertexOnLine(aL, Surf2, D2, Surf1, false, TolTang); + } if (aL->NbPnts() <= 2) { bool aCond = aL->NbPnts() < 2; if (!aCond) + { aCond = (aL->Point(1).IsSame(aL->Point(2), Precision::Confusion())); + } if (aCond) { @@ -1824,14 +1916,18 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& done = true; if (slin.Length() == 0) + { return; + } bool isDecomposeRequired = (Quad.TypeQuadric() == GeomAbs_Cone) || (Quad.TypeQuadric() == GeomAbs_Sphere) || (Quad.TypeQuadric() == GeomAbs_Cylinder) || (Quad.TypeQuadric() == GeomAbs_Torus); if (!isDecomposeRequired) + { return; + } // post processing for cones and spheres @@ -1856,11 +1952,15 @@ void IntPatch_ImpPrmIntersection::Perform(const occ::handle& } if (!isDecompose) + { return; + } slin.Clear(); for (int i = 1; i <= dslin.Length(); i++) + { slin.Append(dslin(i)); + } } // correct U parameter of the start point of line on Quadric @@ -1871,22 +1971,34 @@ static double AdjustUFirst(double U1, double U2) // case: no adjustment if (U1 > 0. && U1 < (2. * M_PI)) + { return u; + } // case: near '0' if (U1 == 0. || fabs(U1) <= 1.e-9) { if (U2 > 0. && U2 < (2. * M_PI)) + { u = (U2 < ((2. * M_PI) - U2)) ? 0. : (2. * M_PI); + } else { double uu = U2; if (U2 > (2. * M_PI)) + { while (uu > (2. * M_PI)) + { uu -= (2. * M_PI); + } + } else + { while (uu < 0.) + { uu += (2. * M_PI); + } + } u = (uu < ((2. * M_PI) - uu)) ? 0. : (2. * M_PI); } @@ -1895,16 +2007,26 @@ static double AdjustUFirst(double U1, double U2) else if (U1 == (2. * M_PI) || fabs((2. * M_PI) - fabs(U1)) <= 1.e-9) { if (U2 > 0. && U2 < (2. * M_PI)) + { u = (U2 < ((2. * M_PI) - U2)) ? 0. : (2. * M_PI); + } else { double uu = U2; if (U2 > (2. * M_PI)) + { while (uu > (2. * M_PI)) + { uu -= (2. * M_PI); + } + } else + { while (uu < 0.) + { uu += (2. * M_PI); + } + } u = (uu < ((2. * M_PI) - uu)) ? 0. : (2. * M_PI); } @@ -1913,11 +2035,19 @@ static double AdjustUFirst(double U1, double U2) else { if (U1 < 0.) + { while (u < 0.) + { u += 2. * M_PI; + } + } if (U1 > (2. * M_PI)) + { while (u > (2. * M_PI)) + { u -= (2. * M_PI); + } + } } return u; @@ -1944,7 +2074,9 @@ static occ::handle GetVertices(const occ::handleVertex(i); @@ -1952,7 +2084,9 @@ static occ::handle GetVertices(const occ::handleVertex(k); @@ -1968,19 +2102,29 @@ static occ::handle GetVertices(const occ::handle GetVertices(const occ::handleAdd(thePLine->Vertex(i).PntOn2S()); } return vertices; @@ -2029,11 +2175,19 @@ static inline double AdjustU(const double U) if (u < 0. || u > DBLPI) { if (u < 0.) + { while (u < 0.) + { u += DBLPI; + } + } else + { while (u > DBLPI) + { u -= DBLPI; + } + } } return u; } @@ -2052,13 +2206,21 @@ static inline void Correct2DBounds(const double UF, double dVF = fabs(V - VF); double dVL = fabs(V - VL); if (dUF <= TOL2D && dUF > Eps) + { U = UF; + } if (dUL <= TOL2D && dUL > Eps) + { U = UL; + } if (dVF <= TOL2D && dVF > Eps) + { V = VF; + } if (dVL <= TOL2D && dVL > Eps) + { V = VL; + } } static void AdjustLine(occ::handle& Line, @@ -2108,9 +2270,13 @@ static bool InsertSeamVertices(occ::handle& Line, { const IntSurf_PntOn2S& aP = Line->Value(ip); if (IsReversed) + { aP.ParametersOnS2(U, V); // S2 - quadric + } else + { aP.ParametersOnS1(U, V); // S1 - quadric + } U = AdjustU(U); if (IsSeamParameter(U, TOL2D)) { @@ -2119,9 +2285,13 @@ static bool InsertSeamVertices(occ::handle& Line, double U1 = 0., V1 = 0.; int ipp = (ip == 1) ? (ip + 1) : (ip - 1); if (IsReversed) + { Line->Value(ipp).ParametersOnS2(U1, V1); // S2 - quadric + } else + { Line->Value(ipp).ParametersOnS1(U1, V1); // S1 - quadric + } double u = AdjustUFirst(U, U1); if (fabs(u - U) >= 1.5 * M_PI) { @@ -2233,12 +2403,16 @@ static void ToSmooth(const occ::handle& Line, double& D3D) { if (Line->NbPoints() <= 10) + { return; + } D3D = 0.; int NbTestPnts = Line->NbPoints() / 5; if (NbTestPnts < 5) + { NbTestPnts = 5; + } int startp = (IsFirst) ? 2 : (Line->NbPoints() - NbTestPnts - 2); int ip = 0; @@ -2296,7 +2470,9 @@ static void ToSmooth(const occ::handle& Line, if (!doU && Quad.TypeQuadric() == GeomAbs_Sphere) { if (fabs(fabs(U1) - fabs(U2)) > (M_PI / 16.)) + { doU = true; + } if (doU && (fabs(U1) <= 1.e-9 || fabs(U1 - 2. * M_PI) <= 1.e-9)) { @@ -2316,7 +2492,9 @@ static void ToSmooth(const occ::handle& Line, Quad.Parameters(Quad.Cone().Apex(), Uapx, Vapx); if (fabs(fabs(U1) - fabs(U2)) > M_PI / 32.) + { doU = true; + } if (doU && (fabs(U1) <= 1.e-9 || fabs(U1 - 2. * M_PI) <= 1.e-9)) { @@ -2335,9 +2513,13 @@ static void ToSmooth(const occ::handle& Line, double dU = std::min((DDU / 10.), 5.e-8); double U = (U2 > U3) ? (U2 + dU) : (U2 - dU); if (IsReversed) + { Line->SetUV(Index1, false, U, V1); + } else + { Line->SetUV(Index1, true, U, V1); + } U1 = U; } } @@ -2365,7 +2547,9 @@ static bool TestMiddleOnPrm(const IntSurf_PntOn2S& aP, gp_Pnt2d a2DPntM(Um, Vm); TopAbs_State PosM = PDomain->Classify(a2DPntM, ArcTol); if (PosM == TopAbs_ON || PosM == TopAbs_IN) + { result = true; + } return result; } @@ -2431,9 +2615,13 @@ static void VerifyVertices(const occ::handle& Line, { double Uv = 0., Vv = 0.; if (IsReversed) + { aV.ParametersOnS2(Uv, Vv); + } else + { aV.ParametersOnS1(Uv, Vv); + } gp_Pnt2d a2DV(Uv, Vv); double Dist = a2DV.Distance(a2DPF); if (Dist < DistMinF) @@ -2441,7 +2629,9 @@ static void VerifyVertices(const occ::handle& Line, DistMinF = Dist; FIndexNear = iv; if (FConjugated != 0) + { FConjugated = 0; + } } if (IsSeamParameter(Uv, TOL2D)) { @@ -2470,9 +2660,13 @@ static void VerifyVertices(const occ::handle& Line, { double Uv = 0., Vv = 0.; if (IsReversed) + { aV.ParametersOnS2(Uv, Vv); + } else + { aV.ParametersOnS1(Uv, Vv); + } gp_Pnt2d a2DV(Uv, Vv); double Dist = a2DV.Distance(a2DPL); if (Dist < DistMinL) @@ -2480,7 +2674,9 @@ static void VerifyVertices(const occ::handle& Line, DistMinL = Dist; LIndexNear = iv; if (LConjugated != 0) + { LConjugated = 0; + } } if (IsSeamParameter(Uv, TOL2D)) { @@ -2507,9 +2703,13 @@ static void VerifyVertices(const occ::handle& Line, const IntSurf_PntOn2S& aV = Vertices->Value(FIndexNear); double Uv = 0., Vv = 0.; if (IsReversed) + { aV.ParametersOnS2(Uv, Vv); + } else + { aV.ParametersOnS1(Uv, Vv); + } if (IsSeamParameter(Uv, TOL2D)) { double Ucv = (fabs(Uv) < fabs(2. * M_PI - Uv)) ? (2. * M_PI) : 0.; @@ -2523,9 +2723,13 @@ static void VerifyVertices(const occ::handle& Line, aV.ParametersOnS1(U2, V2); // S1 - prm VrtF.SetValue(true, U2, V2); if (FConjugated == 0) + { VrtF.SetValue(false, Uv, Vv); + } else + { VrtF.SetValue(false, Ucv, Vv); + } } else { @@ -2533,9 +2737,13 @@ static void VerifyVertices(const occ::handle& Line, aV.ParametersOnS2(U2, V2); // S2 - prm VrtF.SetValue(false, U2, V2); if (FConjugated == 0) + { VrtF.SetValue(true, Uv, Vv); + } else + { VrtF.SetValue(true, Ucv, Vv); + } } double Dist3D = VrtF.Value().Distance(aPF.Value()); if (Dist3D > 1.5e-7 && DistMinF > TOL2D) @@ -2558,9 +2766,13 @@ static void VerifyVertices(const occ::handle& Line, const IntSurf_PntOn2S& aV = Vertices->Value(LIndexNear); double Uv = 0., Vv = 0.; if (IsReversed) + { aV.ParametersOnS2(Uv, Vv); + } else + { aV.ParametersOnS1(Uv, Vv); + } if (IsSeamParameter(Uv, TOL2D)) { double Ucv = (fabs(Uv) < fabs(2. * M_PI - Uv)) ? (2. * M_PI) : 0.; @@ -2574,9 +2786,13 @@ static void VerifyVertices(const occ::handle& Line, aV.ParametersOnS1(U2, V2); // S1 - prm VrtL.SetValue(true, U2, V2); if (LConjugated == 0) + { VrtL.SetValue(false, Uv, Vv); + } else + { VrtL.SetValue(false, Ucv, Vv); + } } else { @@ -2584,9 +2800,13 @@ static void VerifyVertices(const occ::handle& Line, aV.ParametersOnS2(U2, V2); // S2 - prm VrtL.SetValue(false, U2, V2); if (LConjugated == 0) + { VrtL.SetValue(true, Uv, Vv); + } else + { VrtL.SetValue(true, Ucv, Vv); + } } double Dist3D = VrtL.Value().Distance(aPL.Value()); if (Dist3D > 1.5e-7 && DistMinL > TOL2D) @@ -2642,7 +2862,9 @@ static void PutIntVertices(const occ::handle& Line, int nbp = Result->NbPoints(), nbv = Vertices->NbPoints(); if (nbp < 3) + { return; + } const occ::handle aRLine = occ::down_cast(Line); @@ -2705,7 +2927,9 @@ static bool HasInternals(occ::handle& Line, bool result = false; if (nbp < 3) + { return result; + } for (ip = 2; ip <= (nbp - 1); ip++) { @@ -2720,7 +2944,9 @@ static bool HasInternals(occ::handle& Line, } } if (result) + { break; + } } return result; @@ -2739,7 +2965,9 @@ static occ::handle MakeSplitWLine(occ::handle& W int ip = 0; for (ip = ParFirst; ip <= ParLast; ip++) + { sline->Add(SLine->Value(ip)); + } occ::handle wline = new IntPatch_WLine(sline, Tang, Trans1, Trans2); wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLImpPrm); @@ -2788,14 +3016,18 @@ static bool SplitOnSegments(occ::handle& WL int firstPar = (int)WLine->Vertex(iv).ParameterOnLine(); int lastPar = (int)WLine->Vertex(iv + 1).ParameterOnLine(); if ((lastPar - firstPar) <= 1) + { continue; + } else { occ::handle splitwline = MakeSplitWLine(WLine, Tang, Trans1, Trans2, ArcTol, firstPar, lastPar); Segments.Append(splitwline); if (!result) + { result = true; + } } } } @@ -2956,7 +3188,9 @@ static bool DecomposeResult(const occ::handle& theLine, occ::handle aSSLine(aSLine); if (aSSLine->NbPoints() <= 1) + { return false; + } AdjustLine(aSSLine, IsReversed, theQSurf, aTOL2D); @@ -3247,7 +3481,9 @@ static bool DecomposeResult(const occ::handle& theLine, if (!aNewPoint.IsSame(aRefPt, aCompareTol3D, aCompareTol2D)) { if (isOnBoundary) + { break; + } sline->Add(aNewPoint); aPrePointExist = aLastType; @@ -3296,7 +3532,9 @@ static bool DecomposeResult(const occ::handle& theLine, flNextLine = true; if (aFindex < aBindex) + { aFindex = aBindex; + } // Go to the next part of aSSLine // because we cannot create the line @@ -3389,7 +3627,9 @@ static bool DecomposeResult(const occ::handle& theLine, int nbsegms = segm.Length(); int iseg = 0; for (iseg = 1; iseg <= nbsegms; iseg++) + { theLines.Append(segm(iseg)); + } } } else @@ -3568,7 +3808,9 @@ bool IsCoincide(IntPatch_TheSurfFunction& theFunc, double aParam1 = ElCLib::Parameter(aLin1, aP1), aParam2 = ElCLib::Parameter(aLin1, aP2); if (CheckSegmSegm(aRf, aRl, aParam1, aParam2)) + { return true; + } // Lines are parallel. Therefore, there is no point in // projecting points to another line in order to check @@ -3590,9 +3832,13 @@ bool IsCoincide(IntPatch_TheSurfFunction& theFunc, { double aUf = 0.0, aVf = 0.0; if (isTheSurface1Using) + { theLine->Point(aPtID).ParametersOnS1(aUf, aVf); + } else + { theLine->Point(aPtID).ParametersOnS2(aUf, aVf); + } // Take 2d-point in parametric surface (because theArc is // 2d-line in parametric surface). @@ -3601,7 +3847,9 @@ bool IsCoincide(IntPatch_TheSurfFunction& theFunc, const double aRParam = ElCLib::Parameter(anArcLin, aPloc); if ((aRParam < aUAf) || (aRParam > aUAl)) + { return false; + } const gp_Pnt2d aPmin(ElCLib::Value(aRParam, anArcLin)); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_InterferencePolyhedron.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_InterferencePolyhedron.cxx index 15365732b0..5ca3c14e64 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_InterferencePolyhedron.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_InterferencePolyhedron.cxx @@ -64,7 +64,9 @@ IntPatch_InterferencePolyhedron::IntPatch_InterferencePolyhedron( Tolerance = IntPatch_PolyhedronTool::DeflectionOverEstimation(FirstPol) + IntPatch_PolyhedronTool::DeflectionOverEstimation(SeconPol); if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } Interference(FirstPol, SeconPol); } } @@ -82,7 +84,9 @@ IntPatch_InterferencePolyhedron::IntPatch_InterferencePolyhedron(const IntPatch_ memset(deOpT, 0, sizeof(deOpT)); Tolerance = IntPatch_PolyhedronTool::DeflectionOverEstimation(Objet) * 2; if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } Interference(Objet, Objet); //-- lbr le 5 juillet 96 } @@ -98,7 +102,9 @@ void IntPatch_InterferencePolyhedron::Perform(const IntPatch_Polyhedron& FirstPo Tolerance = IntPatch_PolyhedronTool::DeflectionOverEstimation(FirstPol) + IntPatch_PolyhedronTool::DeflectionOverEstimation(SeconPol); if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } Interference(FirstPol, SeconPol); } } @@ -110,7 +116,9 @@ void IntPatch_InterferencePolyhedron::Perform(const IntPatch_Polyhedron& Objet) SelfInterference(true); Tolerance = IntPatch_PolyhedronTool::DeflectionOverEstimation(Objet) * 2; if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } Interference(Objet); } @@ -158,7 +166,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, { if (OI[0] == TI[0] || OI[0] == TI[1] || OI[0] == TI[2] || OI[1] == TI[0] || OI[1] == TI[1] || OI[1] == TI[2] || OI[2] == TI[0] || OI[2] == TI[1] || OI[2] == TI[2]) + { return; + } } // The precision of intersections includes two values ; @@ -227,7 +237,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, if (TangentZoneValue(TheTZ, FirstPol, Tri1, SeconPol, Tri2)) { if (!Insert(TheTZ)) + { myTZones.Append(TheTZ); + } } } @@ -315,7 +327,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, { parT[iToo] = dpOpT[iObj][iToo] / (dpOpT[iObj][iToo] + dpOpT[iObj][inext]); if (TI[iToo] > TI[inext]) + { parT[iToo] = 1. - parT[iToo]; + } piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]), Intf_VERTEX, OI[iObj], @@ -356,7 +370,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, { parO[iObj] = dpOpT[iObj][iToo] / (dpOpT[iObj][iToo] + dpOpT[inext][iToo]); if (OI[iObj] > OI[inext]) + { parO[iObj] = 1. - parO[iObj]; + } piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(SeconPol, TI[iToo]), Intf_EDGE, std::min(OI[iObj], OI[inext]), @@ -460,7 +476,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, + (voo[iObj].Reversed() * parO[iObj]); } else + { Pb = true; + } } else { @@ -472,7 +490,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, + (voo[iObj] * parO[iObj]); } else + { Pb = true; + } } if (TI[iToo] > TI[jnext]) { @@ -484,7 +504,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, + (vtt[iToo].Reversed() * parT[iToo]); } else + { Pb = true; + } } else { @@ -496,7 +518,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, + (vtt[iToo] * parT[iToo]); } else + { Pb = true; + } } if (!Pb) { @@ -540,7 +564,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, piO = (IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]).XYZ()) + (voo[iObj] * parO[iObj]); if (OI[iObj] > OI[inext]) + { parO[iObj] = 1. - parO[iObj]; + } piOT.Append(Intf_SectionPoint(piO, Intf_EDGE, std::min(OI[iObj], OI[inext]), @@ -570,7 +596,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, piO = (IntPatch_PolyhedronTool::Point(SeconPol, TI[iToo]).XYZ()) + (vtt[iToo] * parT[iToo]); if (TI[iToo] > TI[jnext]) + { parT[iToo] = 1. - parT[iToo]; + } piOT.Append(Intf_SectionPoint(piO, Intf_FACE, Tri1, @@ -620,7 +648,9 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, id[iPs] = di; } else + { break; + } } } } @@ -641,15 +671,21 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, { pivo = 0; if (parO[1] == 0.) + { pedg = 1; + } else if (parO[2] == 0.) + { pedg = 2; + } } else if (parO[1] == 0.) { pivo = 1; if (parO[2] == 0.) + { pedg = 2; + } } if (pivo >= 0 && pedg >= 0) { @@ -669,15 +705,21 @@ void IntPatch_InterferencePolyhedron::Intersect(const int Tri1, { pivo = 0; if (parT[1] == 0.) + { pedg = 1; + } else if (parT[2] == 0.) + { pedg = 2; + } } else if (parT[1] == 0.) { pivo = 1; if (parT[2] == 0.) + { pedg = 2; + } } if (pivo >= 0 && pedg >= 0) { @@ -851,7 +893,9 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& { par = dpOpT[nob][nou] / (dpOpT[nob][nou] + dpOpT[nob][nou2]); if (TI[nou] > TI[nou2]) + { par = 1. - par; + } Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[nob]), Intf_VERTEX, OI[nob], @@ -910,7 +954,9 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& { par = dpOpT[nob][nou] / (dpOpT[nob][nou] + dpOpT[nob2][nou]); if (OI[nob] > OI[nob2]) + { par = 1. - par; + } Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(SeconPol, TI[nou]), Intf_EDGE, std::min(OI[nob], OI[nob2]), @@ -951,14 +997,20 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& } } if (tTP[0] != Intf_EXTERNAL && tTP[1] != Intf_EXTERNAL && tTP[2] != Intf_EXTERNAL) + { finished = true; + } } else + { finished = true; + } // Insertion of the points of intersection in the zone of tangency : for (nob = 1; nob <= nbpInt; nob++) + { TheTZ.Append(Tpi(nob)); + } if (!finished) { @@ -995,9 +1047,13 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& gp_Pnt lepi = IntPatch_PolyhedronTool::Point(SeconPol, TI[nou]) .Translated(gp_Vec(vtt[nou] * parT[nbpInt])); if (OI[nob] > OI[nob2]) + { parO[nbpInt] = 1. - parO[nbpInt]; + } if (TI[nou] > TI[nou2]) + { parT[nbpInt] = 1. - parT[nbpInt]; + } Tpi.Append(Intf_SectionPoint(lepi, Intf_EDGE, std::min(OI[nob], OI[nob2]), @@ -1018,7 +1074,9 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& } } if (nbpInt >= 5) + { break; // Number of pi passed in TZ ! + } } nob = nbNoInserted - 1; while (nob >= 0) @@ -1027,7 +1085,9 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& { nob--; if (nob < 0) + { break; + } } if (nob >= 0) { @@ -1050,7 +1110,9 @@ bool IntPatch_InterferencePolyhedron::TangentZoneValue(Intf_TangentZone& } } if (nbpInt < 3) + { nbpInt = 0; + } return nbpInt > 0; } @@ -1074,7 +1136,9 @@ void IntPatch_InterferencePolyhedron::CoupleCharacteristics(const IntPatch_Polyh gp_XYZ vvec = (voo[0] ^ voo[1]) + (voo[1] ^ voo[2]) + (voo[2] ^ voo[0]); gp_XYZ vnorT = (vtt[0] ^ vtt[1]) + (vtt[1] ^ vtt[2]) + (vtt[2] ^ vtt[0]); if (vnorT.Modulus() > vvec.Modulus()) + { vvec = vnorT; + } for (n1 = 0; n1 < 3; n1++) { @@ -1094,7 +1158,9 @@ void IntPatch_InterferencePolyhedron::CoupleCharacteristics(const IntPatch_Polyh dpOeT[n1][n2] = vv.Modulus() / lg; } else + { dpOeT[n1][n2] = dpOpT[n1][n2]; + } lg = voo[n1].Modulus(); if (lg > 1e-16) @@ -1104,7 +1170,9 @@ void IntPatch_InterferencePolyhedron::CoupleCharacteristics(const IntPatch_Polyh deOpT[n1][n2] = vv.Modulus() / lg; } else + { deOpT[n1][n2] = dpOpT[n1][n2]; + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Intersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Intersection.cxx index 1f33115150..358043b330 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Intersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Intersection.cxx @@ -86,13 +86,21 @@ IntPatch_Intersection::IntPatch_Intersection(const occ::handle 0.5) + { myTolArc = 0.5; + } if (myTolTang > 0.5) + { myTolTang = 0.5; + } Perform(S1, D1, S2, D2, TolArc, TolTang); } @@ -133,20 +141,34 @@ void IntPatch_Intersection::SetTolerances(const double TolArc, myUVMaxStep = UVMaxStep; myFleche = Fleche; if (myTolArc < 1e-8) + { myTolArc = 1e-8; + } if (myTolTang < 1e-8) + { myTolTang = 1e-8; + } if (myTolArc > 0.5) + { myTolArc = 0.5; + } if (myTolTang > 0.5) + { myTolTang = 0.5; + } if (myFleche < 1.0e-3) + { myFleche = 1e-3; + } // if(myUVMaxStep<1.0e-3) myUVMaxStep=1e-3; if (myFleche > 10) + { myFleche = 10; + } if (myUVMaxStep > 0.5) + { myUVMaxStep = 0.5; + } } //====================================================================== @@ -160,9 +182,13 @@ void IntPatch_Intersection::Perform(const occ::handle& S1, myTolArc = TolArc; myTolTang = TolTang; if (myFleche == 0.0) + { myFleche = 0.01; + } if (myUVMaxStep == 0.0) + { myUVMaxStep = 0.01; + } done = true; spnt.Clear(); @@ -213,7 +239,9 @@ void IntPatch_Intersection::Perform(const occ::handle& S1, empt = interpp.IsEmpty(); const int nblm = interpp.NbLines(); for (int i = 1; i <= nblm; i++) + { slin.Append(interpp.Line(i)); + } } } break; @@ -306,13 +334,21 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, const Extrema_POnSurf& pons = anExtPS.Point(i); pons.Parameter(cU, cV); if (cU > Umax) + { Umax = cU; + } if (cU < Umin) + { Umin = cU; + } if (cV > Vmax) + { Vmax = cV; + } if (cV < Vmin) + { Vmin = cV; + } } } @@ -326,13 +362,21 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, const Extrema_POnSurf& pons = anExtPS.Point(i); pons.Parameter(cU, cV); if (cU > Umax) + { Umax = cU; + } if (cU < Umin) + { Umin = cU; + } if (cV > Vmax) + { Vmax = cV; + } if (cV < Vmin) + { Vmin = cV; + } } } @@ -374,20 +418,32 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, { TmpSS = TrimS; if (Uinf && Usup) + { TrimS = TmpSS->UTrim(-tp, tp, 1.0e-7); + } if (Uinf && !Usup) + { TrimS = TmpSS->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); + } if (!Uinf && Usup) + { TrimS = TmpSS->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); + } } else { if (Uinf && Usup) + { TrimS = InfSurf->UTrim(-tp, tp, 1.0e-7); + } if (Uinf && !Usup) + { TrimS = InfSurf->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); + } if (!Uinf && Usup) + { TrimS = InfSurf->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); + } } } } @@ -408,7 +464,9 @@ static void FUN_GetUiso(const occ::handle& GS, { occ::handle gc = GS->UIso(U); if (IsVP && (FirstV == 0.0 && LastV == (2. * M_PI))) + { I = gc; + } else { occ::handle gtc = new Geom_TrimmedCurve(gc, FirstV, LastV); @@ -428,7 +486,9 @@ static void FUN_GetUiso(const occ::handle& GS, { occ::handle gc = gos->UIso(U); if (IsVP && (FirstV == 0.0 && LastV == (2 * M_PI))) + { I = gc; + } else { occ::handle gtc = new Geom_TrimmedCurve(gc, FirstV, LastV); @@ -462,14 +522,18 @@ static void FUN_GetUiso(const occ::handle& GS, if (FirstV >= 0. && LastV >= 0.) { if (FirstV > 4.) + { return; + } VmTr = FirstV; VMTr = (LastV > 4.) ? 4. : LastV; } else if (FirstV < 0. && LastV < 0.) { if (LastV < -4.) + { return; + } VMTr = LastV; VmTr = (FirstV < -4.) ? -4. : FirstV; } @@ -503,7 +567,9 @@ static void FUN_GetViso(const occ::handle& GS, { occ::handle gc = GS->VIso(V); if (IsUP && (FirstU == 0.0 && LastU == (2 * M_PI))) + { I = gc; + } else { occ::handle gtc = new Geom_TrimmedCurve(gc, FirstU, LastU); @@ -523,7 +589,9 @@ static void FUN_GetViso(const occ::handle& GS, { occ::handle gc = gos->VIso(V); if (IsUP && (FirstU == 0.0 && LastU == (2 * M_PI))) + { I = gc; + } else { occ::handle gtc = new Geom_TrimmedCurve(gc, FirstU, LastU); @@ -557,14 +625,18 @@ static void FUN_GetViso(const occ::handle& GS, if (FirstU >= 0. && LastU >= 0.) { if (FirstU > 4.) + { return; + } UmTr = FirstU; UMTr = (LastU > 4.) ? 4. : LastU; } else if (FirstU < 0. && LastU < 0.) { if (LastU < -4.) + { return; + } UMTr = LastU; UmTr = (FirstU < -4.) ? -4. : FirstU; } @@ -609,11 +681,15 @@ static void FUN_PL_Intersection(const occ::handle& S1, MS2[0] = 0.5 * (S2->LastUParameter() + S2->FirstUParameter()); MS2[1] = 0.5 * (S2->LastVParameter() + S2->FirstVParameter()); if (T1 == GeomAbs_SurfaceOfExtrusion) + { isoS1isLine[0] = true; + } else if (!S1->IsVPeriodic() && !S1->IsVClosed()) { if (T1 != GeomAbs_OffsetSurface) + { C1 = gs1->UIso(MS1[0]); + } else { const occ::handle gos = occ::down_cast(gs1); @@ -622,12 +698,16 @@ static void FUN_PL_Intersection(const occ::handle& S1, } GeomAdaptor_Curve gac(C1); if (gac.GetType() == GeomAbs_Line) + { isoS1isLine[0] = true; + } } if (!S1->IsUPeriodic() && !S1->IsUClosed()) { if (T1 != GeomAbs_OffsetSurface) + { C1 = gs1->VIso(MS1[1]); + } else { const occ::handle gos = occ::down_cast(gs1); @@ -636,14 +716,20 @@ static void FUN_PL_Intersection(const occ::handle& S1, } GeomAdaptor_Curve gac(C1); if (gac.GetType() == GeomAbs_Line) + { isoS1isLine[1] = true; + } } if (T2 == GeomAbs_SurfaceOfExtrusion) + { isoS2isLine[0] = true; + } else if (!S2->IsVPeriodic() && !S2->IsVClosed()) { if (T2 != GeomAbs_OffsetSurface) + { C2 = gs2->UIso(MS2[0]); + } else { const occ::handle gos = occ::down_cast(gs2); @@ -652,12 +738,16 @@ static void FUN_PL_Intersection(const occ::handle& S1, } GeomAdaptor_Curve gac(C2); if (gac.GetType() == GeomAbs_Line) + { isoS2isLine[0] = true; + } } if (!S2->IsUPeriodic() && !S2->IsUClosed()) { if (T2 != GeomAbs_OffsetSurface) + { C2 = gs2->VIso(MS2[1]); + } else { const occ::handle gos = occ::down_cast(gs2); @@ -666,7 +756,9 @@ static void FUN_PL_Intersection(const occ::handle& S1, } GeomAdaptor_Curve gac(C2); if (gac.GetType() == GeomAbs_Line) + { isoS2isLine[1] = true; + } } bool IsBothLines = ((isoS1isLine[0] || isoS1isLine[1]) && (isoS2isLine[0] || isoS2isLine[1])); if (!IsBothLines) @@ -769,13 +861,17 @@ static void FUN_PL_Intersection(const occ::handle& S1, IsOk = true; // 3. Make intersections of V(U)isos if (C1.IsNull() || C2.IsNull()) + { return; + } DV = derS1[iso]; occ::handle GPln = new Geom_Plane(gp_Pln(puvS1, gp_Dir(DV))); occ::handle C1Prj = GeomProjLib::ProjectOnPlane(C1, GPln, gp_Dir(DV), true); occ::handle C2Prj = GeomProjLib::ProjectOnPlane(C2, GPln, gp_Dir(DV), true); if (C1Prj.IsNull() || C2Prj.IsNull()) + { return; + } occ::handle C1Prj2d = GeomProjLib::Curve2d(C1Prj, GPln); occ::handle C2Prj2d = GeomProjLib::Curve2d(C2Prj, GPln); Geom2dAPI_InterCurveCurve ICC(C1Prj2d, C2Prj2d, 1.0e-7); @@ -835,14 +931,18 @@ static void FUN_NewFirstLast(const GeomAbs_CurveType& ga_ct, if (Fst >= 0. && Lst >= 0.) { if (Fst > 4.) + { return; + } NewFst = Fst; NewLst = (Lst > 4.) ? 4. : Lst; } if (Fst < 0. && Lst < 0.) { if (Lst < -4.) + { return; + } NewLst = Lst; NewFst = (Fst < -4.) ? -4. : Fst; } @@ -928,9 +1028,13 @@ static void FUN_TrimBothSurf(const occ::handle& S1, FUN_NewFirstLast(GA_U2, S2->FirstVParameter(), S2->LastVParameter(), TV, V1S2, V2S2, TrmV2); FUN_NewFirstLast(GA_V2, S2->FirstUParameter(), S2->LastUParameter(), TV, U1S2, U2S2, TrmU2); if (TrmV1) + { NS1 = S1->VTrim(V1S1, V2S1, 1.0e-7); + } if (TrmV2) + { NS2 = S2->VTrim(V1S2, V2S2, 1.0e-7); + } if (TrmU1) { if (TrmV1) @@ -939,7 +1043,9 @@ static void FUN_TrimBothSurf(const occ::handle& S1, NS1 = TS->UTrim(U1S1, U2S1, 1.0e-7); } else + { NS1 = S1->UTrim(U1S1, U2S1, 1.0e-7); + } } if (TrmU2) { @@ -949,7 +1055,9 @@ static void FUN_TrimBothSurf(const occ::handle& S1, NS2 = TS->UTrim(U1S2, U2S2, 1.0e-7); } else + { NS2 = S2->UTrim(U1S2, U2S2, 1.0e-7); + } } } @@ -968,9 +1076,13 @@ void IntPatch_Intersection::Perform(const occ::handle& theS myTolArc = TolArc; myTolTang = TolTang; if (myFleche <= Precision::PConfusion()) + { myFleche = 0.01; + } if (myUVMaxStep <= Precision::PConfusion()) + { myUVMaxStep = 0.01; + } done = false; spnt.Clear(); @@ -1132,9 +1244,13 @@ void IntPatch_Intersection::Perform(const occ::handle& theS if (TreatAsBiParametric) { if (typs1 == GeomAbs_Cone && typs2 == GeomAbs_Plane) + { typs1 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector + } else if (typs1 == GeomAbs_Plane && typs2 == GeomAbs_Cone) + { typs2 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector + } else { // Using Prm-Prm Intersector @@ -1223,7 +1339,9 @@ void IntPatch_Intersection::Perform(const occ::handle& theS } if (!theIsReqToPostWLProc) + { return; + } for (int i = NCollection_Sequence>::Lower(); i <= slin.Upper(); i++) @@ -1231,16 +1349,22 @@ void IntPatch_Intersection::Perform(const occ::handle& theS occ::handle aWL = occ::down_cast(slin.Value(i)); if (aWL.IsNull()) + { continue; + } if (!aWL->IsPurgingAllowed()) + { continue; + } occ::handle aRW = IntPatch_WLineTool::ComputePurgedWLine(aWL, theS1, theS2, theD1, theD2); if (aRW.IsNull()) + { continue; + } slin.InsertAfter(i, aRW); slin.Remove(i); @@ -1263,9 +1387,13 @@ void IntPatch_Intersection::Perform(const occ::handle& theS myTolArc = TolArc; myTolTang = TolTang; if (myFleche <= Precision::PConfusion()) + { myFleche = 0.01; + } if (myUVMaxStep <= Precision::PConfusion()) + { myUVMaxStep = 0.01; + } done = false; spnt.Clear(); slin.Clear(); @@ -1494,7 +1622,9 @@ void IntPatch_Intersection::Perform(const occ::handle& theS } if (!theIsReqToPostWLProc) + { return; + } for (int i = NCollection_Sequence>::Lower(); i <= slin.Upper(); i++) @@ -1502,16 +1632,22 @@ void IntPatch_Intersection::Perform(const occ::handle& theS occ::handle aWL = occ::down_cast(slin.Value(i)); if (aWL.IsNull()) + { continue; + } if (!aWL->IsPurgingAllowed()) + { continue; + } occ::handle aRW = IntPatch_WLineTool::ComputePurgedWLine(aWL, theS1, theS2, theD1, theD2); if (aRW.IsNull()) + { continue; + } slin.InsertAfter(i, aRW); slin.Remove(i); @@ -1598,7 +1734,9 @@ void IntPatch_Intersection::ParamParamPerfom(const occ::handleArcType() != IntPatch_Walking) + { slin.Append(interpp.Line(i)); + } } for (int i = 1; i <= interpp.NbLines(); i++) { if (interpp.Line(i)->ArcType() == IntPatch_Walking) + { slin.Append(interpp.Line(i)); + } } } } @@ -1666,7 +1808,9 @@ void IntPatch_Intersection::GeomGeomPerfom(const occ::handle& tgte = interii.TangentFaces(); if (tgte) + { oppo = interii.OppositeFaces(); + } bool isWLExist = false; IntPatch_ALineToWLine AToW(theS1, theS2, aNbPointsInALine); @@ -1687,7 +1831,9 @@ void IntPatch_Intersection::GeomGeomPerfom(const occ::handle& } if ((line->ArcType() != IntPatch_Restriction) || theIsReqToKeepRLine) + { slin.Append(line); + } } } @@ -1772,9 +1918,13 @@ void IntPatch_Intersection::GeomParamPerfom(const occ::handle if (myIsStartPnt) { if (isNotAnalitical /*ts1 == 0*/) + { interip.SetStartPoint(myU1Start, myV1Start); + } else + { interip.SetStartPoint(myU2Start, myV2Start); + } } if (theD1->DomainIsInfinite() && theD2->DomainIsInfinite()) @@ -1798,7 +1948,9 @@ void IntPatch_Intersection::GeomParamPerfom(const occ::handle done = true; } else + { done = false; + } return; } @@ -1811,7 +1963,9 @@ void IntPatch_Intersection::GeomParamPerfom(const occ::handle } } else + { interip.Perform(theS1, theD1, theS2, theD2, myTolArc, myTolTang, myFleche, myUVMaxStep); + } if (interip.IsDone()) { @@ -1824,17 +1978,23 @@ void IntPatch_Intersection::GeomParamPerfom(const occ::handle for (int i = 1; i <= aNbLines; i++) { if (interip.Line(i)->ArcType() != IntPatch_Walking) + { slin.Append(interip.Line(i)); + } } for (int i = 1; i <= aNbLines; i++) { if (interip.Line(i)->ArcType() == IntPatch_Walking) + { slin.Append(interip.Line(i)); + } } for (int i = 1; i <= interip.NbPnts(); i++) + { spnt.Append(interip.Point(i)); + } } } } @@ -1904,7 +2064,9 @@ void IntPatch_Intersection::Perform(const occ::handle& S1, const int nblm = interpp.NbLines(); int i = 1; for (; i <= nblm; i++) + { slin.Append(interpp.Line(i)); + } } } @@ -1914,15 +2076,21 @@ void IntPatch_Intersection::Perform(const occ::handle& S1, occ::handle aWL = occ::down_cast(slin.Value(i)); if (aWL.IsNull()) + { continue; + } if (!aWL->IsPurgingAllowed()) + { continue; + } occ::handle aRW = IntPatch_WLineTool::ComputePurgedWLine(aWL, S1, S2, D1, D2); if (aRW.IsNull()) + { continue; + } slin.InsertAfter(i, aRW); slin.Remove(i); @@ -2155,15 +2323,21 @@ bool IntPatch_Intersection::CheckSingularPoints(const occ::handleValue(t); theS1->D1(aP1.X(), aP1.Y(), aPP1, aDU, aDV); if (isU) + { aD1NormMax = std::max(aD1NormMax, aDU.Magnitude()); + } else + { aD1NormMax = std::max(aD1NormMax, aDV.Magnitude()); + } aPmid += aPP1.XYZ(); aNb++; if (aD1NormMax > aTol) + { break; + } } if (aD1NormMax <= aTol) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_LineConstructor.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_LineConstructor.cxx index 4ce9594ac9..3144577b8d 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_LineConstructor.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_LineConstructor.cxx @@ -386,13 +386,21 @@ static double ComputeParametricTolerance(const double theTol3d, double nad1v = theD1v.Magnitude(); double tolu = 0., tolv = 0.; if (nad1u > 1e-12) + { tolu = theTol3d / nad1u; + } else + { tolu = 0.1; + } if (nad1v > 1e-12) + { tolv = theTol3d / nad1v; + } else + { tolv = 0.1; + } double aTolerance = (tolu > tolv) ? tolu : tolv; return aTolerance; } @@ -422,7 +430,9 @@ static int AppendSameVertexA(occ::handle& alig, const IntPatch_Point& Vtxi = L->Vertex(i); double thetol2 = Vtxi.Tolerance(); if (thetol2 < thetol1) + { thetol2 = thetol1; + } double d_4 = Vtxindex.Value().Distance(Vtxi.Value()); if (d_4 <= thetol2) { @@ -458,7 +468,9 @@ static int AppendSameVertexG(occ::handle& glig, aajouter = false; double thetol2 = Vtxi.Tolerance(); if (thetol2 < thetol1) + { thetol2 = thetol1; + } d = Vtxindex.Value().Distance(Vtxi.Value()); if (d <= thetol2) { @@ -511,7 +523,9 @@ static int AppendSameVertexW(occ::handle& wlig, double d_2 = Pntindex.Distance(Vtxi.Value()); double thetol2 = Vtxi.Tolerance(); if (thetol2 < thetol1) + { thetol2 = thetol1; + } //-- le debugger voit 2 fois la variable d ici. ???? -> d_2 if (d_2 <= thetol2) { @@ -550,7 +564,9 @@ static int AppendSameVertexR(occ::handle& rlig, double d_3 = Vtxindex.Value().Distance(Vtxi.Value()); double thetol2 = Vtxi.Tolerance(); if (thetol2 < thetol1) + { thetol2 = thetol1; + } if (d_3 < thetol2) { if (Vtxi.ParameterOnLine() != Vtxindex.ParameterOnLine()) @@ -596,15 +612,21 @@ static void AddLine(const occ::handle& L, occ::handle ALine(occ::down_cast(L)); occ::handle alig; if (L->TransitionOnS1() == IntSurf_Undecided) + { alig = new IntPatch_ALine(ALine->Curve(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { alig = new IntPatch_ALine(ALine->Curve(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { alig = new IntPatch_ALine(ALine->Curve(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } alig->AddVertex(ALine->Vertex(i)); IndexLastVertex += AppendSameVertexA(alig, ALine, i, TabIndex); if (i != j) @@ -629,12 +651,18 @@ static void AddLine(const occ::handle& L, } occ::handle wlig; if (L->TransitionOnS1() == IntSurf_Undecided) + { wlig = new IntPatch_WLine(LineOn2S, L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { wlig = new IntPatch_WLine(LineOn2S, L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { wlig = new IntPatch_WLine(LineOn2S, L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } if (WLine->HasArcOnS1()) { wlig->SetArcOnS1(WLine->GetArcOnS1()); @@ -669,11 +697,17 @@ static void AddLine(const occ::handle& L, IndexFirstVertex = 1; occ::handle rlig; if (L->TransitionOnS1() == IntSurf_Undecided) + { rlig = new IntPatch_RLine(L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { rlig = new IntPatch_RLine(L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { rlig = new IntPatch_RLine(L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } if (RLine->IsArcOnS1()) { rlig->SetArcOnS1(RLine->ArcOnS1()); @@ -716,72 +750,102 @@ static void AddLine(const occ::handle& L, { case IntPatch_Lin: if (L->TransitionOnS1() == IntSurf_Undecided) + { glig = new IntPatch_GLine(GLine->Line(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { glig = new IntPatch_GLine(GLine->Line(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { glig = new IntPatch_GLine(GLine->Line(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } break; case IntPatch_Parabola: if (L->TransitionOnS1() == IntSurf_Undecided) + { glig = new IntPatch_GLine(GLine->Parabola(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { glig = new IntPatch_GLine(GLine->Parabola(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { glig = new IntPatch_GLine(GLine->Parabola(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } break; case IntPatch_Hyperbola: if (L->TransitionOnS1() == IntSurf_Undecided) + { glig = new IntPatch_GLine(GLine->Hyperbola(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { glig = new IntPatch_GLine(GLine->Hyperbola(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { glig = new IntPatch_GLine(GLine->Hyperbola(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } break; case IntPatch_Circle: if (L->TransitionOnS1() == IntSurf_Undecided) + { glig = new IntPatch_GLine(GLine->Circle(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { glig = new IntPatch_GLine(GLine->Circle(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { glig = new IntPatch_GLine(GLine->Circle(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } break; case IntPatch_Ellipse: default: if (L->TransitionOnS1() == IntSurf_Undecided) + { glig = new IntPatch_GLine(GLine->Ellipse(), L->IsTangent()); + } else if (L->TransitionOnS1() == IntSurf_Touch) + { glig = new IntPatch_GLine(GLine->Ellipse(), L->IsTangent(), L->SituationS1(), L->SituationS2()); + } else + { glig = new IntPatch_GLine(GLine->Ellipse(), L->IsTangent(), L->TransitionOnS1(), L->TransitionOnS2()); + } break; } glig->AddVertex(GLine->Vertex(i)); @@ -857,7 +921,9 @@ static bool IsSegmentSmall(const occ::handle& WLine, int ipF = (int)vtxF.ParameterOnLine(); int ipL = (int)vtxL.ParameterOnLine(); if (ipF >= ipL) + { return true; + } double tolF = GetVertexTolerance(vtxF); double tolL = GetVertexTolerance(vtxL); @@ -870,7 +936,9 @@ static bool IsSegmentSmall(const occ::handle& WLine, const gp_Pnt& p2 = WLine->Point(i).Value(); len += p1.Distance(p2); if (len > tol) + { break; + } p1 = p2; } return len <= tol; @@ -885,7 +953,9 @@ static bool TestWLineIsARLine(const NCollection_SequenceNbPnts(); int indicepnt = nbpnt / 2; if (indicepnt < 1) + { return (false); + } const IntSurf_PntOn2S& POn2S = wlin->Point(indicepnt); const IntSurf_PntOn2S& POn2S1 = wlin->Point(indicepnt + 1); int lastl = slinref.Length(); @@ -961,7 +1031,9 @@ static bool TestIfWLineIsRestriction( S1->D1(u1, v1, ap, ad1u, ad1v); tol = ComputeParametricTolerance(TolArc, ad1u, ad1v); if (tol > tol2d1) + { tol2d1 = tol; + } //-- if (allon1 + 1 == i && D1->IsThePointOn(gp_Pnt2d(u1, v1), tol)) { @@ -971,14 +1043,18 @@ static bool TestIfWLineIsRestriction( S2->D1(u2, v2, ap, ad1u, ad1v); tol = ComputeParametricTolerance(TolArc, ad1u, ad1v); if (tol > tol2d2) + { tol2d2 = tol; + } //-- if (allon2 + 1 == i && D2->IsThePointOn(gp_Pnt2d(u2, v2), tol)) { allon2++; } if (allon1 != i && allon2 != i) + { break; + } } if (allon1 == NbPnts || allon2 == NbPnts) { @@ -1030,11 +1106,15 @@ static void TestWLineToRLine(const NCollection_SequenceNbVertex(); if (nbvtx < 2) + { return; + } int ParamMinOnLine = (int)WLine->Vertex(1).ParameterOnLine(); int ParamMaxOnLine = (int)WLine->Vertex(nbvtx).ParameterOnLine(); if (ParamMinOnLine >= ParamMaxOnLine) + { return; + } int midInd = (ParamMaxOnLine + ParamMinOnLine) / 2; NCollection_Sequence indicesV1, indicesV2; @@ -1043,9 +1123,13 @@ static void TestWLineToRLine(const NCollection_SequenceVertex(iv).ParameterOnLine(); if (plin == ParamMinOnLine) + { indicesV1.Append(iv); + } else if (plin == ParamMaxOnLine) + { indicesV2.Append(iv); + } } bool isRLine = false; @@ -1121,22 +1205,34 @@ static void TestWLineToRLine(const NCollection_Sequence arc; if ((WLine->Vertex(iv).*pIsOnDomS)()) + { arc = (WLine->Vertex(iv).*pArcOnS)(); + } else + { arc = occ::down_cast(arcsResolved(iv)); + } if (!arc.IsNull()) + { mapArcsV1.Add(arc); + } } for (i = 1; i <= indicesV2.Length(); i++) { iv = indicesV2(i); occ::handle arc; if ((WLine->Vertex(iv).*pIsOnDomS)()) + { arc = (WLine->Vertex(iv).*pArcOnS)(); + } else + { arc = occ::down_cast(arcsResolved(iv)); + } if (!arc.IsNull() && mapArcsV1.Contains(arc)) + { mapArcs.Add(arc); + } } // for each common arc @@ -1150,22 +1246,34 @@ static void TestWLineToRLine(const NCollection_Sequence arc1; if ((WLine->Vertex(iv).*pIsOnDomS)()) + { arc1 = (WLine->Vertex(iv).*pArcOnS)(); + } else + { arc1 = occ::down_cast(arcsResolved(iv)); + } if (!arc1.IsNull() && arc1 == arc) + { iv1 = iv; + } } for (i = 1; i <= indicesV2.Length() && iv2 == 0; i++) { iv = indicesV2(i); occ::handle arc1; if ((WLine->Vertex(iv).*pIsOnDomS)()) + { arc1 = (WLine->Vertex(iv).*pArcOnS)(); + } else + { arc1 = occ::down_cast(arcsResolved(iv)); + } if (!arc1.IsNull() && arc1 == arc) + { iv2 = iv; + } } if (!iv1 || !iv2) { @@ -1205,9 +1313,13 @@ static void TestWLineToRLine(const NCollection_Sequence rlig = new IntPatch_RLine(true, IntSurf_Unknown, IntSurf_Unknown); if (onFirst) + { rlig->SetArcOnS1(arc); + } else + { rlig->SetArcOnS2(arc); + } occ::handle LineOn2S = new IntSurf_LineOn2S(); const occ::handle& Lori = WLine->Curve(); @@ -1247,9 +1359,13 @@ static void TestWLineToRLine(const NCollection_SequenceVertex(ivmin); VtxFirst.SetParameter(parmin); if (!arcsResolved(ivmin).IsNull()) + { VtxFirst.SetArc(onFirst, arc, parmin, TransitionUndecided, TransitionUndecided); + } if (reverse) + { VtxFirst.ReverseTransition(); //-- inversion des transitions + } rlig->AddVertex(VtxFirst); for (i = 1; i <= pIndVmin->Length(); i++) { @@ -1259,9 +1375,13 @@ static void TestWLineToRLine(const NCollection_SequenceVertex(iv); Vtx.SetParameter(parmin); if (!arcsResolved(iv).IsNull()) + { Vtx.SetArc(onFirst, arc, parmin, TransitionUndecided, TransitionUndecided); + } if (reverse) + { Vtx.ReverseTransition(); + } rlig->AddVertex(Vtx); } } @@ -1273,18 +1393,26 @@ static void TestWLineToRLine(const NCollection_SequenceVertex(iv); Vtx.SetParameter(parmax); if (!arcsResolved(iv).IsNull()) + { Vtx.SetArc(onFirst, arc, parmax, TransitionUndecided, TransitionUndecided); + } if (reverse) + { Vtx.ReverseTransition(); + } rlig->AddVertex(Vtx); } } IntPatch_Point VtxLast = WLine->Vertex(ivmax); VtxLast.SetParameter(parmax); if (!arcsResolved(ivmax).IsNull()) + { VtxLast.SetArc(onFirst, arc, parmax, TransitionUndecided, TransitionUndecided); + } if (reverse) + { VtxLast.ReverseTransition(); + } rlig->AddVertex(VtxLast); rlig->SetFirstPoint(1); rlig->SetLastPoint(indicesV1.Length() + indicesV2.Length()); @@ -1411,7 +1539,9 @@ void IntPatch_LineConstructor::Perform( int int_lastp = (int)lastp; int int_firstp = (int)firstp; if (pmid == int_lastp) + { pmid = int_firstp; + } const IntSurf_PntOn2S& Pmid = WLine->Point(pmid); Pmid.Parameters(u1, v1, u2, v2); Recadre(mySurf1, mySurf2, u1, v1, u2, v2); @@ -1627,9 +1757,13 @@ void IntPatch_LineConstructor::Perform( // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN // --purpose: section algo with infinite prism works now!!! if (in1 == TopAbs_UNKNOWN) + { in1 = TopAbs_OUT; + } if (in2 == TopAbs_UNKNOWN) + { in2 = TopAbs_OUT; + } // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END if (in1 == TopAbs_OUT || in2 == TopAbs_OUT) { @@ -1681,9 +1815,13 @@ void IntPatch_LineConstructor::Perform( // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN // --purpose: section algo with infinite prism works now!!! if (in1 == TopAbs_UNKNOWN) + { in1 = TopAbs_OUT; + } if (in2 == TopAbs_UNKNOWN) + { in2 = TopAbs_OUT; + } // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END if (in1 == TopAbs_OUT || in2 == TopAbs_OUT) { @@ -1772,7 +1910,9 @@ void IntPatch_LineConstructor::Perform( mySurf2->D1(U2, V2, P, D1u, D1v); myDom2->Init(); if (myDom2->More()) + { Tol = ComputeParametricTolerance(myDom2->Tol3d(myDom2->Value()), D1u, D1v); + } //-- le 23 mars 1999 TopAbs_State bornin = myDom2->Classify(gp_Pnt2d(U2, V2), Tol, false); @@ -1783,7 +1923,9 @@ void IntPatch_LineConstructor::Perform( bornin = myDom2->Classify(gp_Pnt2d(U2t, V2t), Tol, false); } if (bornin == TopAbs_OUT) + { continue; + } //-- Attention , on faisait une estimatoin de deltau et deltav //-- Maintenant : @@ -1862,7 +2004,9 @@ void IntPatch_LineConstructor::Perform( mySurf1->D1(U1, V1, P, D1u, D1v); myDom1->Init(); if (myDom2->More()) + { Tol = ComputeParametricTolerance(myDom1->Tol3d(myDom1->Value()), D1u, D1v); + } //-- le 23 mars 1999 TopAbs_State bornin = myDom1->Classify(gp_Pnt2d(U1, V1), Tol, false); @@ -1873,7 +2017,9 @@ void IntPatch_LineConstructor::Perform( bornin = myDom1->Classify(gp_Pnt2d(U1t, V1t), Tol, false); } if (bornin == TopAbs_OUT) + { continue; + } //-- Attention , on faisait une estimatoin de deltau et deltav //-- Maintenant : diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Point.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Point.cxx index b61b2842b4..6611dc9b91 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Point.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Point.cxx @@ -143,32 +143,52 @@ static void DumpTransition(const IntSurf_Transition& T) { IntSurf_TypeTrans typetrans = T.TransitionType(); if (typetrans == IntSurf_In) + { std::cout << " In "; + } else if (typetrans == IntSurf_Out) + { std::cout << " Out "; + } else if (typetrans == IntSurf_Undecided) + { std::cout << " Und."; + } else if (typetrans == IntSurf_Touch) { std::cout << " Touch "; if (T.Situation() == IntSurf_Inside) + { std::cout << " Inside "; + } else if (T.Situation() == IntSurf_Outside) + { std::cout << " Outside"; + } else + { std::cout << " Unknown"; + } if (T.IsOpposite()) + { std::cout << " Opposite "; + } else + { std::cout << " Non_Opposite "; + } } if (typetrans != IntSurf_Undecided) { if (T.IsTangent()) + { std::cout << " Tangent "; + } else + { std::cout << " Non_Tangent"; + } } } @@ -176,7 +196,7 @@ static void DumpTransition(const IntSurf_Transition& T) void IntPatch_Point::Dump() const { - std::cout << "----------- IntPatch_Point : " << std::endl; + std::cout << "----------- IntPatch_Point : " << '\n'; double u1, v1, u2, v2; pt.Parameters(u1, v1, u2, v2); @@ -191,18 +211,30 @@ void IntPatch_Point::Dump() const (double)v2, (double)para); if (onS1) + { printf("*OnS1* par=%+10.20f arc1=%10p", (double)prm1, (void*)arcS1.operator->()); + } if (vtxonS1) + { printf(" *Vtx1* vtx1=%10p", (void*)vS1.operator->()); + } if (onS1 || vtxonS1) + { printf("\n"); + } if (onS2) + { printf("*OnS2* par=%+10.20f arc2=%10p", (double)prm2, (void*)arcS2.operator->()); + } if (vtxonS2) + { printf(" *Vtx2* vtx2=%10p", (void*)vS2.operator->()); + } if (onS2 || vtxonS2) + { printf("\n"); + } fflush(stdout); if (onS1 || onS2) @@ -222,8 +254,8 @@ void IntPatch_Point::Dump() const std::cout << " -tra2 : "; DumpTransition(tra2); } - std::cout << std::endl; + std::cout << '\n'; } std::cout << "\nToler = " << Tolerance(); - std::cout << std::endl; + std::cout << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyArc.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyArc.cxx index d14bbc9e97..5e4113e576 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyArc.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyArc.cxx @@ -130,9 +130,13 @@ IntPatch_PolyArc::IntPatch_PolyArc(const occ::handle& Line, // if(IndexInf>i) IndexInf=i-1; // if(IndexSup i) + { IndexInf = std::max(i - 2, 1); + } if (IndexSup < i) + { IndexSup = std::min(i + 1, NbSample); + } } myBox.Add(brise(i)); @@ -173,7 +177,9 @@ IntPatch_PolyArc::IntPatch_PolyArc(const occ::handle& Line, } while ((IndexInf > IndexSup) && nbloop <= 10); myError *= 1.2; if (myError < 0.00000001) + { myError = 0.00000001; + } myBox.Enlarge(myError); ferme = (Line->Value(aPdeb).Distance(Line->Value(aPfin)) <= 1e-7); @@ -192,7 +198,9 @@ int IntPatch_PolyArc::NbPoints() const gp_Pnt2d IntPatch_PolyArc::Point(const int Index) const { if (offsetx == 0.0 && offsety == 0.0) + { return (brise(Index)); + } const gp_Pnt2d& P = brise(Index); return (gp_Pnt2d(P.X() + offsetx, P.Y() + offsety)); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyLine.cxx index 4bb819d328..d869420a28 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PolyLine.cxx @@ -84,9 +84,13 @@ void IntPatch_PolyLine::Prepare() gp_XY V12 = P2.XY() - P1.XY(); double d13_2 = V13.SquareModulus(), d_2; if (d13_2 > eps_2) + { d_2 = V13.CrossSquareMagnitude(V12) / d13_2; + } else + { d_2 = eps_2; + } if (d_2 > myError * myError) { // try to compute deflection more precisely using parabola interpolation @@ -123,13 +127,19 @@ void IntPatch_PolyLine::Prepare() double d1 = std::abs(A1 * xt1 + B1 * yt1 + C1); double d2 = std::abs(A2 * xt2 + B2 * yt2 + C2); if (d2 > d1) + { d1 = d2; + } // select min deflection from linear and parabolic ones if (d1 * d1 < d_2) + { d_2 = d1 * d1; + } } if (d_2 > myError * myError) + { myError = std::sqrt(d_2); + } } P1 = P2; P2 = P3; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polygo.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polygo.cxx index ec580c4cc0..8df7c2061e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polygo.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polygo.cxx @@ -29,19 +29,19 @@ void IntPatch_Polygo::Dump() const { static int num = 0; num++; - std::cout << "\n#------------- D u m p B o x 2 d (" << num << ")" << std::endl; + std::cout << "\n#------------- D u m p B o x 2 d (" << num << ")" << '\n'; Bounding().Dump(); - std::cout << "\n#-----------------------------------------------" << std::endl; + std::cout << "\n#-----------------------------------------------" << '\n'; const int nbs = NbSegments(); std::cout << "\npol2d " << num << " " << nbs << " "; - std::cout << DeflectionOverEstimation() << std::endl; + std::cout << DeflectionOverEstimation() << '\n'; gp_Pnt2d P, PF; for (int i = 1; i <= nbs; i++) { Segment(i, P, PF); - std::cout << "pnt2d " << num << " " << P.X() << " " << P.Y() << std::endl; + std::cout << "pnt2d " << num << " " << P.X() << " " << P.Y() << '\n'; } - std::cout << "pnt2d " << num << " " << PF.X() << " " << PF.Y() << std::endl; + std::cout << "pnt2d " << num << " " << PF.X() << " " << PF.Y() << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polyhedron.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polyhedron.cxx index 7deb8f51b7..689d5e3771 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polyhedron.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polyhedron.cxx @@ -319,13 +319,19 @@ int IntPatch_Polyhedron::TriConnex(const int Triang, colE = (Pedge - 1) - (ligE * nbdeltaVp1); // Horizontal if (ligP == ligE) + { typE = 1; - // Vertical + // Vertical + } else if (colP == colE) + { typE = 2; - // Oblique + // Oblique + } else + { typE = 3; + } } else { @@ -421,9 +427,13 @@ int IntPatch_Polyhedron::TriConnex(const int Triang, linT = (1 > ligP) ? 1 : ligP; //--linT=Max(1, ligP); colT = (1 > (colP + colP)) ? 1 : (colP + colP); //--colT=Max(1, colP+colP); if (ligP == 0) + { linO = ligP + 1; + } else + { linO = ligP - 1; + } colO = colP; } else diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PrmPrmIntersection.cxx index b894a32e12..22606e88b1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -74,7 +74,9 @@ static void SeveralWlinesProcessing(const occ::handle& theSur occ::handle& theWLline) { if (theSLin.Length() == 0) + { return; + } double aU1 = 0.0, aV1 = 0.0, aU2 = 0.0, aV2 = 0.0; @@ -94,7 +96,9 @@ static void SeveralWlinesProcessing(const occ::handle& theSur const occ::handle& aSLine = theSLin.Value(iL); IntPatch_IType aType = aSLine->ArcType(); if (aType != IntPatch_Walking) + { continue; + } const occ::handle aWLine = occ::down_cast(aSLine); int tnbV = aWLine->NbVertex(); int tiV; @@ -163,7 +167,9 @@ static void SeveralWlinesProcessing(const occ::handle& theSur { removeNext = true; for (iPo = (ciV + 1); iPo <= cnbV; iPo++) + { VPold.SetValue(iPo, VPold.Value(iPo) - 1); + } } } else if (ciV == cnbV) @@ -191,16 +197,24 @@ static void SeveralWlinesProcessing(const occ::handle& theSur for (iPo = (ciV + 1); iPo <= cnbV; iPo++) { if (dParMi > 10) + { VPold.SetValue(iPo, VPold.Value(iPo) - 2); + } else + { VPold.SetValue(iPo, VPold.Value(iPo) - 1); + } } } else { if (dParMi > 10) + { for (iPo = (ciV + 1); iPo <= cnbV; iPo++) + { VPold.SetValue(iPo, VPold.Value(iPo) - 1); + } + } } } @@ -215,11 +229,17 @@ static void SeveralWlinesProcessing(const occ::handle& theSur newL2s->Add(newPnt); } else if (removeNext && iP == (pI + 1)) + { continue; + } else if (removePrev && iP == (pI - 1)) + { continue; + } else + { newL2s->Add(theWLline->Point(iP)); + } } IntPatch_Point newVtx; @@ -235,7 +255,9 @@ static void SeveralWlinesProcessing(const occ::handle& theSur for (iV = 1; iV <= cnbV; iV++) { if (iV == ciV) + { NWLine->AddVertex(newVtx); + } else { IntPatch_Point theVtx = theWLline->Vertex(iV); @@ -389,7 +411,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& int* TabL = new int[nbLigSec + 1]; int ls; for (ls = 1; ls <= nbLigSec; ls++) + { TabL[ls] = ls; + } bool triok; do @@ -417,7 +441,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& int* TabPtDep = new int[nbp + 1]; int ilig; for (ilig = 1; ilig <= nbp; ilig++) + { TabPtDep[ilig] = 0; + } double UminLig1, VminLig1, UmaxLig1, VmaxLig1; double UminLig2, VminLig2, UmaxLig2, VmaxLig2; @@ -440,22 +466,38 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& SectionPointToParameters(LineSec.GetPoint(ilig), Poly1, Poly2, U1, V1, U2, V2); if (U1 > UmaxLig1) + { UmaxLig1 = U1; + } if (V1 > VmaxLig1) + { VmaxLig1 = V1; + } if (U2 > UmaxLig2) + { UmaxLig2 = U2; + } if (V2 > VmaxLig2) + { VmaxLig2 = V2; + } if (U1 < UminLig1) + { UminLig1 = U1; + } if (V1 < VminLig1) + { VminLig1 = V1; + } if (U2 < UminLig2) + { UminLig2 = U2; + } if (V2 < VminLig2) + { VminLig2 = V2; + } } int nbps2 = (nbp > 3) ? (nbp / 2) : 1; @@ -494,7 +536,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } if (nbp < 3) + { NombreDePointsDeDepartDuCheminement = 3; + } IndicePointdeDepart1 = nbps2; } @@ -514,9 +558,13 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& else if (NombreDePointsDeDepartDuCheminement == 3) { if (IndicePointdeDepart1 == nbp) + { nbps2 = (IndicePointdeDepart1 + IndicePointdeDepart2) / 2; + } else + { nbps2 = nbp; + } } else { @@ -634,10 +682,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { @@ -691,22 +743,38 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& SectionPointToParameters(TangentZone.GetPoint(pz), Poly1, Poly2, U1, V1, U2, V2); if (U1 > UmaxLig1) + { UmaxLig1 = U1; + } if (V1 > VmaxLig1) + { VmaxLig1 = V1; + } if (U2 > UmaxLig2) + { UmaxLig2 = U2; + } if (V2 > VmaxLig2) + { VmaxLig2 = V2; + } if (U1 < UminLig1) + { UminLig1 = U1; + } if (V1 < VminLig1) + { VminLig1 = V1; + } if (U2 < UminLig2) + { UminLig2 = U2; + } if (V2 < VminLig2) + { VminLig2 = V2; + } } } @@ -821,10 +889,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { @@ -933,7 +1005,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } if (nbp < 3) + { NombreDePointsDeDepartDuCheminement = 3; + } IndicePointdeDepart1 = nbps2; } @@ -953,9 +1027,13 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& else { if (IndicePointdeDepart1 == nbp) + { nbps2 = (IndicePointdeDepart1 + IndicePointdeDepart2) / 2; + } else + { nbps2 = nbp; + } } SectionPointToParameters(LineSec.GetPoint(nbps2), Poly1, Poly1, U1, V1, U2, V2); @@ -1007,11 +1085,15 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& Bv1 += 1.0e-7; if ((pu1 >= Au1) && (pu1 <= Bu1) && (pv1 >= Av1) && (pv1 <= Bv1)) + { dminiPointLigne = 0.0; + } else { if ((pu2 >= Au1) && (pu2 <= Bu1) && (pv2 >= Av1) && (pv2 <= Bv1)) + { dminiPointLigne = 0.0; + } } } // for( ll ... } // if ... @@ -1086,7 +1168,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& && (std::abs(u1 - u2) <= 1e-6 && std::abs(v1 - v2) <= 1e-6)); if (imin > 2) + { imin--; + } i = nbpw + 1; do @@ -1098,13 +1182,17 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } while ((i > 2) && (std::abs(u1 - u2) <= 1e-6 && std::abs(v1 - v2) <= 1e-6)); if (imax < nbpw) + { imax++; + } if (imin < imax) { occ::handle PWLine = new IntSurf_LineOn2S(); for (i = imin; i <= imax; i++) + { PWLine->Add(PW.Line()->Value(i)); + } double TolTang = TolTangency; occ::handle wline = @@ -1126,7 +1214,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf1, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { IntPatch_Point vtx; @@ -1211,11 +1301,15 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& Bu1 += 1.0e-7; Bv1 += 1.0e-7; if ((pu1 >= Au1) && (pu1 <= Bu1) && (pv1 >= Av1) && (pv1 <= Bv1)) + { dminiPointLigne = 0.0; + } else { if ((pu2 >= Au1) && (pu2 <= Bu1) && (pv2 >= Av1) && (pv2 <= Bv1)) + { dminiPointLigne = 0.0; + } } } // for( ll ... } // if ... @@ -1289,7 +1383,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } while ((i < nbp) && (std::abs(u1 - u2) <= 1e-6 && std::abs(v1 - v2) <= 1e-6)); if (imin > 2) + { imin--; + } i = nbp + 1; do @@ -1301,13 +1397,17 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } while ((i > 2) && (std::abs(u1 - u2) <= 1e-6 && std::abs(v1 - v2) <= 1e-6)); if (imax < nbp) + { imax++; + } if (imin < imax) { occ::handle PWLine = new IntSurf_LineOn2S(); for (i = imin; i <= imax; i++) + { PWLine->Add(PW.Line()->Value(i)); + } double TolTang = TolTangency; occ::handle wline = @@ -1330,7 +1430,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf1, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { @@ -1375,7 +1477,9 @@ occ::handle IntPatch_PrmPrmIntersection::NewLine( { int NbPnts = NbPntsToInsert + High - Low; if (NumLine > NbLines() || NumLine < 1 || Low >= High) + { throw Standard_OutOfRange(" IntPatch_PrmPrmIntersection NewLine "); + } //------------------------------------------------------------------ //-- Indice : Low Low+1 I I+1 High -- //-- -- @@ -1457,10 +1561,14 @@ occ::handle IntPatch_PrmPrmIntersection::NewLine( bool HasStartPoint = PW.PerformFirstPoint(StartParams, StartPOn2S); if (HasStartPoint) + { ResultPntOn2SLine->Add(StartPOn2S); + } } else + { s += dsmin; + } } ResultPntOn2SLine->Add(TheLine->Point(High)); @@ -1590,20 +1698,28 @@ void IntPatch_PrmPrmIntersection::RemplitLin(const int int xg, yg, zg; xg = x1 - x2; if (xg < 0) + { xg = -xg; + } yg = y1 - y2; if (yg < 0) + { yg = -yg; + } zg = z1 - z2; if (zg < 0) + { zg = -zg; + } if (DansGrille(x1) && DansGrille(y1) && DansGrille(z1)) { int t = GrilleInteger(x1, y1, z1); Map.Add(t); } if (xg <= 1 && yg <= 1 && zg <= 1) + { return; + } xg = (x1 + x2) >> 1; yg = (y1 + y2) >> 1; zg = (z1 + z2) >> 1; @@ -1662,11 +1778,17 @@ void IntPatch_PrmPrmIntersection::RemplitTri(const int Map.Add(t); } if (xg != x3 || yg != y3 || zg != z3) + { RemplitTri(x1, y1, z1, x2, y2, z2, xg, yg, zg, Map); + } if (xg != x1 || yg != y1 || zg != z1) + { RemplitTri(xg, yg, zg, x2, y2, z2, x3, y3, z3, Map); + } if (xg != x2 || yg != y2 || zg != z2) + { RemplitTri(x1, y1, z1, xg, yg, zg, x3, y3, z3, Map); + } } } @@ -1679,11 +1801,17 @@ void IntPatch_PrmPrmIntersection::Remplit(const int a, { int iax, iay, iaz, ibx, iby, ibz, icx, icy, icz; if (a != -1) + { Map.Add(a); + } if (b != -1) + { Map.Add(b); + } if (c != -1) + { Map.Add(c); + } if (a != -1 && b != -1 && c != -1) { @@ -1818,9 +1946,13 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& aNewPnt.Parameters(NewU1, NewV1, NewU2, NewV2); if (std::abs(U1 - NewU1) <= TolPar && std::abs(V1 - NewV1) <= TolPar && std::abs(U2 - NewU2) <= TolPar && std::abs(V2 - NewV2) <= TolPar) + { AdditionalPnts.Remove(iter2); + } else + { iter2.Next(); + } } } @@ -1832,22 +1964,38 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& IntSurf_PntOn2S Pnt = IterLOP1.Value(); Pnt.Parameters(U1, V1, U2, V2); if (U1 > UmaxLig1) + { UmaxLig1 = U1; + } if (V1 > VmaxLig1) + { VmaxLig1 = V1; + } if (U2 > UmaxLig2) + { UmaxLig2 = U2; + } if (V2 > VmaxLig2) + { VmaxLig2 = V2; + } if (U1 < UminLig1) + { UminLig1 = U1; + } if (V1 < VminLig1) + { VminLig1 = V1; + } if (U2 < UminLig2) + { UminLig2 = U2; + } if (V2 < VminLig2) + { VminLig2 = V2; + } } double SeuildPointLigne = 15.0 * Increment * Increment; @@ -1974,10 +2122,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { @@ -2017,7 +2169,6 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& } // HasStartPoint } // for( IterLOP ... done = true; - return; } //================================================================================================= @@ -2137,10 +2288,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { return; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { return; + } //--------------- if (wline->NbVertex() == 0) @@ -2313,9 +2468,13 @@ IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt, if (std::abs(NewParams[i] - OldParams[i]) >= 0.5 * Periods[i]) { if (NewParams[i] < OldParams[i]) + { NewParams[i] += Periods[i]; + } else + { NewParams[i] -= Periods[i]; + } } } } @@ -2476,22 +2635,38 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& Interference.GetLinePoint(TabL[ls], ilig, _x, _y, _z, U1, V1, U2, V2, incidence); // if (U1 > UmaxLig1) + { UmaxLig1 = U1; + } if (V1 > VmaxLig1) + { VmaxLig1 = V1; + } if (U2 > UmaxLig2) + { UmaxLig2 = U2; + } if (V2 > VmaxLig2) + { VmaxLig2 = V2; + } // if (U1 < UminLig1) + { UminLig1 = U1; + } if (V1 < VminLig1) + { VminLig1 = V1; + } if (U2 < UminLig2) + { UminLig2 = U2; + } if (V2 < VminLig2) + { VminLig2 = V2; + } } // for( ilig = 2; ilig <= nbp; ilig++ ) { // //---------------------------------------- @@ -2509,7 +2684,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& case 1: nbps2 = (nbp > 1) ? nbp / 2 : 1; if (nbp < 3) + { NombreDePointsDeDepartDuCheminement = NbDePointsDeDepartDuChmLimit; + } break; case 2: @@ -2590,7 +2767,9 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& PW.PutToBoundary(Surf1, Surf2); // if (PW.NbPoints() < 3) + { continue; + } const int aMinNbPoints = 40; if (PW.NbPoints() < aMinNbPoints) @@ -2704,10 +2883,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } if (wline->NbVertex() == 0) { IntPatch_Point vtx; @@ -2783,22 +2966,38 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& Interference.GetTangentZonePoint(z, pz, _x, _y, _z, U1, V1, U2, V2); if (U1 > UmaxLig1) + { UmaxLig1 = U1; + } if (V1 > VmaxLig1) + { VmaxLig1 = V1; + } if (U2 > UmaxLig2) + { UmaxLig2 = U2; + } if (V2 > VmaxLig2) + { VmaxLig2 = V2; + } if (U1 < UminLig1) + { UminLig1 = U1; + } if (V1 < VminLig1) + { VminLig1 = V1; + } if (U2 < UminLig2) + { UminLig2 = U2; + } if (V2 < VminLig2) + { VminLig2 = V2; + } //} } @@ -2945,10 +3144,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } //--------------- if (wline->NbVertex() == 0) @@ -3006,11 +3209,17 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& NCollection_Array1 StartParams(1, 4); int MaxOscill = NbU1; if (MaxOscill < NbU2) + { MaxOscill = NbU2; + } if (MaxOscill < NbV1) + { MaxOscill = NbV1; + } if (MaxOscill < NbV2) + { MaxOscill = NbV2; + } double nIncrement = Increment; // if(MaxOscill>10) @@ -3150,10 +3359,14 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle& // the method PutVertexOnLine can reduce the number of points in IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, true, TolTang); if (wline->NbPnts() < 2) + { continue; + } IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, false, TolTang); if (wline->NbPnts() < 2) + { continue; + } //--------------- if (wline->NbVertex() == 0) diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RLine.cxx index 80210a9f02..7867a60eed 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RLine.cxx @@ -83,9 +83,13 @@ void IntPatch_RLine::ParamOnS1(double& a, double& b) const { double p = svtx(i).ParameterOnLine(); if (p < a) + { a = p; + } if (p > b) + { b = p; + } } } else @@ -104,9 +108,13 @@ void IntPatch_RLine::ParamOnS2(double& a, double& b) const { double p = svtx(i).ParameterOnLine(); if (p < a) + { a = p; + } if (p > b) + { b = p; + } } } else @@ -171,12 +179,16 @@ void IntPatch_RLine::ComputeVertexParameters(const double) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -215,12 +227,16 @@ void IntPatch_RLine::ComputeVertexParameters(const double) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -419,7 +435,7 @@ void IntPatch_RLine::ComputeVertexParameters(const double) void IntPatch_RLine::Dump(const int theMode) const { - std::cout << " ----------- D u m p I n t P a t c h _ R L i n e -(begin)------" << std::endl; + std::cout << " ----------- D u m p I n t P a t c h _ R L i n e -(begin)------" << '\n'; const int aNbPoints = NbPnts(); const int aNbVertex = NbVertex(); @@ -452,7 +468,7 @@ void IntPatch_RLine::Dump(const int theMode) const { std::cout << "----> IntSurf_PntOn2S : " << polr << ", Pnt (" << Vertex(pol).Value().X() << "," << Vertex(pol).Value().Y() << "," << Vertex(pol).Value().Z() << ")" - << std::endl; + << '\n'; } } @@ -489,5 +505,5 @@ void IntPatch_RLine::Dump(const int theMode) const break; } - std::cout << "\n--------------------------------------------------- (end) -------" << std::endl; + std::cout << "\n--------------------------------------------------- (end) -------" << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RstInt.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RstInt.cxx index 4071f7531d..3309b7347b 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RstInt.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_RstInt.cxx @@ -57,9 +57,13 @@ static void Recadre(GeomAbs_SurfaceType typeS1, { int nbpnts = wlin->NbPnts(); if (Param < 1) + { Param = 1; + } else if (Param > nbpnts) + { Param = nbpnts; + } double U1p, V1p, U2p, V2p; wlin->Point(Param).Parameters(U1p, V1p, U2p, V2p); @@ -70,9 +74,13 @@ static void Recadre(GeomAbs_SurfaceType typeS1, case GeomAbs_Sphere: case GeomAbs_Torus: while (U1 < (U1p - 1.5 * M_PI)) + { U1 += M_PI + M_PI; + } while (U1 > (U1p + 1.5 * M_PI)) + { U1 -= M_PI + M_PI; + } break; default: break; @@ -80,9 +88,13 @@ static void Recadre(GeomAbs_SurfaceType typeS1, if (typeS1 == GeomAbs_Torus) { while (V1 < (V1p - 1.5 * M_PI)) + { V1 += M_PI + M_PI; + } while (V1 > (V1p + 1.5 * M_PI)) + { V1 -= M_PI + M_PI; + } } switch (typeS2) @@ -92,9 +104,13 @@ static void Recadre(GeomAbs_SurfaceType typeS1, case GeomAbs_Sphere: case GeomAbs_Torus: while (U2 < (U2p - 1.5 * M_PI)) + { U2 += M_PI + M_PI; + } while (U2 > (U2p + 1.5 * M_PI)) + { U2 -= M_PI + M_PI; + } break; default: break; @@ -102,9 +118,13 @@ static void Recadre(GeomAbs_SurfaceType typeS1, if (typeS2 == GeomAbs_Torus) { while (V2 < (V1p - 1.5 * M_PI)) + { V2 += M_PI + M_PI; + } while (V2 > (V2p + 1.5 * M_PI)) + { V2 -= M_PI + M_PI; + } } } @@ -216,7 +236,9 @@ static void GetLinePoint2d(const occ::handle& L, par = 1.0; } else + { par = std::abs(param - par); + } double us1, vs1, us2, vs2; if (typL == IntPatch_Walking) @@ -387,7 +409,9 @@ static bool FindParameter(const occ::handle& L, } } if (found) + { return true; + } } else { @@ -467,8 +491,10 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, throw Standard_DomainError(); } if (!Domain->Has3d()) + { // don't use computed deflection in the mode of pure geometric intersection PLin.ResetError(); + } const bool SurfaceIsUClosed = Surf->IsUClosed(); const bool SurfaceIsVClosed = Surf->IsVClosed(); @@ -480,13 +506,21 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, if (possiblyClosed) { if (SurfaceIsUClosed) + { tolUClosed = (Surf->LastUParameter() - Surf->FirstUParameter()) * 0.01; + } if (SurfaceIsVClosed) + { tolVClosed = (Surf->LastVParameter() - Surf->FirstVParameter()) * 0.01; + } if (OSurfaceIsUClosed) + { tolOUClosed = (OtherSurf->LastUParameter() - OtherSurf->FirstUParameter()) * 0.01; + } if (OSurfaceIsVClosed) + { tolOVClosed = (OtherSurf->LastVParameter() - OtherSurf->FirstVParameter()) * 0.01; + } } //------------------------------------------------------------------------ @@ -523,9 +557,13 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, IntPatch_HInterTool::Bounds(arc, PFirst, PLast); if (Precision::IsNegativeInfinite(PFirst)) + { PFirst = -myInfinite; + } if (Precision::IsPositiveInfinite(PLast)) + { PLast = myInfinite; + } // if (Precision::IsNegativeInfinite(PFirst) || // Precision::IsPositiveInfinite(PLast)) { // //-- std::cout<<" IntPatch_RstInt::PutVertexOnLine ---> Restrictions Infinies @@ -583,9 +621,13 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, case GeomAbs_BezierCurve: { NbEchant = (3 + arc->NbPoles()); if (NbEchant < 10) + { NbEchant = 10; + } else if (NbEchant > 50) + { NbEchant = 50; + } } break; case GeomAbs_BSplineCurve: { @@ -595,9 +637,13 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, / (arc->LastParameter() - arc->FirstParameter()); NbEchant = (nbs < 2.0 ? 2 : (int)nbs); if (NbEchant < 10) + { NbEchant = 10; + } else if (NbEchant > 50) + { NbEchant = 50; + } } break; default: { @@ -633,23 +679,31 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, do { if (IndiceOffsetBiPeriodic == 1) + { OffsetV = aRefOV - M_PI - M_PI; + } else if (IndiceOffsetBiPeriodic == 2) + { OffsetV = aRefOV + M_PI + M_PI; + } do { if (IndiceOffsetPeriodic == 1) + { OffsetU = aRefOU - M_PI - M_PI; + } else if (IndiceOffsetPeriodic == 2) + { OffsetU = aRefOU + M_PI + M_PI; + } Brise.SetOffset(OffsetU, OffsetV); static int debug_polygon2d = 0; if (debug_polygon2d) { - std::cout << " ***** Numero Restriction : " << NumeroEdge << " *****" << std::endl; + std::cout << " ***** Numero Restriction : " << NumeroEdge << " *****" << '\n'; PLin.Dump(); Brise.Dump(); } @@ -727,7 +781,9 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, locpt2(j).Coord(U, V); if ((OSurfaceIsUClosed && std::abs(U - U2) > tolOUClosed) || (OSurfaceIsVClosed && std::abs(V - V2) > tolOVClosed)) + { continue; + } } duplicate = true; break; @@ -744,9 +800,13 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, if (typL == IntPatch_Walking && SurfaceIsPeriodic) { if (OnFirst) + { Recadre(TypeS1, TypeS2, wlin, ParamApproxOnLine, U1, V1, U2, V2); + } else + { Recadre(TypeS1, TypeS2, wlin, ParamApproxOnLine, U2, V2, U1, V1); + } } locpt.Append(ptsommet); locpt2.Append(gp_Pnt2d(U2, V2)); @@ -769,14 +829,18 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, GetLinePoint2d(L, paramline, OnFirst, U, V); if ((SurfaceIsUClosed && std::abs(U - U1) > tolUClosed) || (SurfaceIsVClosed && std::abs(V - V1) > tolVClosed)) + { found = false; + } } if (found && (OSurfaceIsUClosed || OSurfaceIsVClosed)) { GetLinePoint2d(L, paramline, !OnFirst, U, V); if ((OSurfaceIsUClosed && std::abs(U - U2) > tolOUClosed) || (OSurfaceIsVClosed && std::abs(V - V2) > tolOVClosed)) + { found = false; + } } } if (!found) @@ -790,10 +854,14 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, { vtxTol = Tol3d(vtxarc, Domain); if (edgeTol > vtxTol) + { vtxTol = edgeTol; + } } else + { vtxTol = edgeTol; + } //-- It is necessary to test that the point does not already exist //-- - It can be already a point on arc @@ -815,22 +883,34 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, if (SurfaceIsUClosed || SurfaceIsVClosed) { if (OnFirst) + { Rptline.ParametersOnS1(U, V); + } else + { Rptline.ParametersOnS2(U, V); + } if ((SurfaceIsUClosed && std::abs(U - U1) > tolUClosed) || (SurfaceIsVClosed && std::abs(V - V1) > tolVClosed)) + { continue; + } } if (OSurfaceIsUClosed || OSurfaceIsVClosed) { if (OnFirst) + { Rptline.ParametersOnS2(U, V); + } else + { Rptline.ParametersOnS1(U, V); + } if ((OSurfaceIsUClosed && std::abs(U - U2) > tolOUClosed) || (OSurfaceIsVClosed && std::abs(V - V2) > tolOVClosed)) + { continue; + } } } double dist = ptsommet.Distance(Rptline.Value()); @@ -869,14 +949,18 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, { double tol = Tol3d(vtxarc, Domain); if (tol > vtxTol) + { vtxTol = tol; + } } } } } if (typL == IntPatch_Walking) + { VerifyTgline(wlin, (int)paramline, edgeTol, tgline); + } Surf->D1(U1, V1, ptbid, d1u, d1v); tgrst.SetLinearForm(d2d.X(), d1u, d2d.Y(), d1v); @@ -888,19 +972,27 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, transarc.SetValue(true, IntSurf_Undecided); } else + { IntSurf::MakeTransition(tgline, tgrst, normsurf, transline, transarc); + } nbTreated++; if (!ivtx) { Sommet.SetValue(ptsommet, vtxTol, false); // pour tangence if (OnFirst) + { Sommet.SetParameters(U1, V1, U2, V2); + } else + { Sommet.SetParameters(U2, V2, U1, V1); + } if (VtxOnArc) + { Sommet.SetVertex(OnFirst, vtxarc); + } //--------------------------------------------------------- //-- lbr : On remplace le point d indice paramline sur la - @@ -954,7 +1046,9 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, ptline.SetArc(OnFirst, arc, paramarc, transline, transarc); // ptline.SetParameter(paramline); //-- rajout lbr le 20 nov 97 if (VtxOnArc) + { ptline.SetVertex(OnFirst, vtxarc); + } if (typL == IntPatch_Walking) { if (OnDifferentRst) @@ -986,7 +1080,9 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, Sommet = ptline; Sommet.SetArc(OnFirst, arc, paramarc, transline, transarc); if (VtxOnArc) + { Sommet.SetVertex(OnFirst, vtxarc); + } if (typL == IntPatch_Walking) { wlin->AddVertex(Sommet); @@ -1011,7 +1107,9 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, { ptline.SetArc(OnFirst, arc, paramarc, transline, transarc); if (VtxOnArc) + { ptline.SetVertex(OnFirst, vtxarc); + } if (typL == IntPatch_Walking) { wlin->Replace(ivtx, ptline); @@ -1022,6 +1120,7 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, } for (k = 1; k <= Nbvtx; k++) + { if (k != ivtx) { if (typL == IntPatch_Walking) @@ -1040,10 +1139,14 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, : (ptline.VertexOnS2()))) { if (ptline.Tolerance() < vtxTol) + { ptline.SetTolerance(vtxTol); + } ptline.SetArc(OnFirst, arc, paramarc, transline, transarc); if (VtxOnArc) + { ptline.SetVertex(OnFirst, vtxarc); + } if (typL == IntPatch_Walking) { wlin->Replace(k, ptline); @@ -1055,6 +1158,7 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, } } } + } } else if ((OnFirst && ptline.IsVertexOnS2()) || (!OnFirst && ptline.IsVertexOnS1())) @@ -1073,6 +1177,7 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, Nbvtx++; } for (k = 1; k <= Nbvtx; k++) + { if (k != ivtx) { if (typL == IntPatch_Walking) @@ -1091,7 +1196,9 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, : (ptline.VertexOnS2()))) { if (ptline.Tolerance() < vtxTol) + { ptline.SetTolerance(vtxTol); + } Sommet = ptline; Sommet.SetArc(OnFirst, arc, paramarc, transline, transarc); if (typL == IntPatch_Walking) @@ -1109,6 +1216,7 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, } } } + } } else { @@ -1123,9 +1231,13 @@ void IntPatch_RstInt::PutVertexOnLine(const occ::handle& L, // We processed a tangent zone, and both ends have been treated. // So mark WLine as having arc if (OnFirst) + { wlin->SetArcOnS1(arc); + } else + { wlin->SetArcOnS2(arc); + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_SpecialPoints.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_SpecialPoints.cxx index b52cf352b4..4de1a84757 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_SpecialPoints.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_SpecialPoints.cxx @@ -104,10 +104,14 @@ public: bool Values(const math_Vector& theX, math_Vector& theF, math_Matrix& theD) override { if (!Value(theX, theF)) + { return false; + } if (!Derivatives(theX, theD)) + { return false; + } return true; } @@ -245,9 +249,13 @@ bool IntPatch_SpecialPoints::AddCrossUVIsoPoint(const occ::handleValue(aU0, aV0)); if (theIsReversed) + { theAddedPoint.SetValue(0.5 * (aP0.XYZ() + aPQuad.XYZ()), aU0, aV0, aUquad, aVquad); + } else + { theAddedPoint.SetValue(0.5 * (aP0.XYZ() + aPQuad.XYZ()), aUquad, aVquad, aU0, aV0); + } AdjustPointAndVertex(theRefPt, anArrOfPeriod, theAddedPoint); return true; @@ -453,9 +469,13 @@ bool IntPatch_SpecialPoints::ProcessSphere(const IntSurf_PntOn2S& thePtIso, #endif double aUIso = 0.0, aVIso = 0.0; if (theIsReversed) + { thePtIso.ParametersOnS2(aUIso, aVIso); + } else + { thePtIso.ParametersOnS1(aUIso, aVIso); + } theUquad = aUIso; theIsIsoChoosen = true; @@ -478,9 +498,13 @@ bool IntPatch_SpecialPoints::ProcessSphere(const IntSurf_PntOn2S& thePtIso, aV1.Normalize(); if (std::abs(aV1.X()) > std::abs(aV1.Y())) + { theUquad = std::copysign(asin(aV1.Y()), theVquad); + } else + { theUquad = std::copysign(acos(aV1.X()), theVquad); + } } return true; @@ -597,9 +621,13 @@ bool IntPatch_SpecialPoints::ProcessCone(const IntSurf_PntOn2S& thePtIso, const double aPeriod = M_PI + M_PI; double aUIso = 0.0, aVIso = 0.0; if (theIsReversed) + { thePtIso.ParametersOnS2(aUIso, aVIso); + } else + { thePtIso.ParametersOnS1(aUIso, aVIso); + } aUIso = ElCLib::InPeriod(aUIso, 0.0, aPeriod); @@ -648,7 +676,9 @@ bool IntPatch_SpecialPoints::ProcessCone(const IntSurf_PntOn2S& thePtIso, anUq = ElCLib::InPeriod(anUq, 0.0, aPeriod); double aDelta = std::abs(anUq - aUIso); if (aDelta > M_PI) + { aDelta = aPeriod - aDelta; + } if (aDelta < aMinDelta) { @@ -669,9 +699,13 @@ bool IntPatch_SpecialPoints::ProcessCone(const IntSurf_PntOn2S& thePtIso, double aUIso = 0.0, aVIso = 0.0; if (theIsReversed) + { thePtIso.ParametersOnS2(aUIso, aVIso); + } else + { thePtIso.ParametersOnS1(aUIso, aVIso); + } theUquad = aUIso; return true; @@ -783,9 +817,13 @@ bool IntPatch_SpecialPoints::AddSingularPole(const occ::handle Tol) + { Tol = VTXi.Tolerance(); //-- 9 oct 97 + } if ((VTXi.IsOnDomS1()) && (!VTXi.IsOnDomS2())) { for (j = 1; (j <= nbvtx) && (!APointDeleted); j++) @@ -513,12 +515,16 @@ void IntPatch_WLine::ComputeVertexParameters(const double RTol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -554,12 +560,16 @@ void IntPatch_WLine::ComputeVertexParameters(const double RTol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -1071,12 +1081,16 @@ void IntPatch_WLine::ComputeVertexParameters(const double RTol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -1125,12 +1139,16 @@ void IntPatch_WLine::ComputeVertexParameters(const double RTol) if (lapt) { if (indl >= j) + { indl--; + } } if (fipt) { if (indf >= j) + { indf--; + } } APointDeleted = true; } @@ -1227,7 +1245,7 @@ const occ::handle& IntPatch_WLine::GetArcOnS2() const void IntPatch_WLine::Dump(const int theMode) const { - std::cout << " ----------- D u m p I n t P a t c h _ W L i n e -(begin)------" << std::endl; + std::cout << " ----------- D u m p I n t P a t c h _ W L i n e -(begin)------" << '\n'; const int aNbPoints = NbPnts(); const int aNbVertex = NbVertex(); @@ -1260,7 +1278,7 @@ void IntPatch_WLine::Dump(const int theMode) const { std::cout << "----> IntSurf_PntOn2S : " << polr << ", Pnt (" << Vertex(pol).Value().X() << "," << Vertex(pol).Value().Y() << "," << Vertex(pol).Value().Z() << ")" - << std::endl; + << '\n'; } } @@ -1297,5 +1315,5 @@ void IntPatch_WLine::Dump(const int theMode) const break; } - std::cout << "\n--------------------------------------------------- (end) -------" << std::endl; + std::cout << "\n--------------------------------------------------- (end) -------" << '\n'; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_WLineTool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_WLineTool.cxx index e4d6e53c43..a54e888c81 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_WLineTool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_WLineTool.cxx @@ -77,7 +77,9 @@ static void FillPointsHash(const occ::handle& theWLine, int i, v; for (i = 1; i <= theWLine->NbPnts(); i++) + { thePointsHash.SetValue(i, 0); + } for (v = 1; v <= theWLine->NbVertex(); v++) { @@ -192,16 +194,24 @@ static occ::handle MakeNewWLine(const occ::handle& theS1, double& U1, double& V1) { if (U1 < theS1->FirstUParameter()) + { U1 = theS1->FirstUParameter(); + } if (U1 > theS1->LastUParameter()) + { U1 = theS1->LastUParameter(); + } if (V1 < theS1->FirstVParameter()) + { V1 = theS1->FirstVParameter(); + } if (V1 > theS1->LastVParameter()) + { V1 = theS1->LastVParameter(); + } } //========================================================================= @@ -222,7 +232,9 @@ static occ::handle DeleteOuterPoints( FillPointsHash(theWLine, aDelOuterPointsHash); if (theS1->IsUPeriodic() || theS1->IsVPeriodic() || theS2->IsUPeriodic() || theS2->IsVPeriodic()) + { return theWLine; + } gp_Pnt2d aPntOnF1, aPntOnF2; double aX1, aY1, aX2, aY2; @@ -252,7 +264,9 @@ static occ::handle DeleteOuterPoints( aFirstGeomIdx = std::max(i - 1, 1); if (aDelOuterPointsHash(i) == -1) + { aFirstGeomIdx = i; // Use data what lies in (i) point / vertex. + } aDelOuterPointsHash(i) = -1; break; @@ -287,7 +301,9 @@ static occ::handle DeleteOuterPoints( { aLastGeomIdx = std::min(i + 1, theWLine->NbPnts()); if (aDelOuterPointsHash(i) == -1) + { aLastGeomIdx = i; // Use data what lies in (i) point / vertex. + } aDelOuterPointsHash(i) = -1; break; @@ -351,7 +367,9 @@ static bool IsInsideIn2d(const gp_Pnt2d& aBasePnt, // d*d = (basevec^(nextpnt-basepnt))**2 / basevec**2 double aSqMag = aBaseVec.SquareMagnitude(); if (aSqMag < Precision::SquareComputational()) + { return false; + } double aCross = aVec2d.Crossed(aBaseVec); double aSquareDist = aCross * aCross / aSqMag; @@ -373,7 +391,9 @@ static bool IsInsideIn3d(const gp_Pnt& aBasePnt, // d*d = (basevec^(nextpnt-basepnt))**2 / basevec**2 double aSqMag = aBaseVec.SquareMagnitude(); if (aSqMag < Precision::SquareComputational()) + { return false; + } double aSquareDist = aVec.CrossSquareMagnitude(aBaseVec) / aSqMag; return (aSquareDist <= aSquareMaxDist); @@ -421,7 +441,9 @@ static occ::handle DeleteByTube(const occ::handleNbPnts() <= 2) + { return theWLine; + } NCollection_Array1 aNewPointsHash(1, theWLine->NbPnts()); FillPointsHash(theWLine, aNewPointsHash); @@ -483,7 +505,9 @@ static occ::handle DeleteByTube(const occ::handle DeleteByTube(const occ::handle& theWline, { IntPatch_Point& aVert = theWline->ChangeVertex(i); if (aVert.ParameterOnLine() != 1) + { break; + } aVert.SetParameters(aU1, aV1, aU2, aV2); aVert.SetValue(theAddedPt.Value()); @@ -833,7 +873,9 @@ static void ExtendLast(const occ::handle& theWline, { IntPatch_Point& aVert = theWline->ChangeVertex(i); if (aVert.ParameterOnLine() != aNbPnts) + { break; + } aVert.SetParameters(aU1, aV1, aU2, aV2); aVert.SetValue(theAddedPt.Value()); @@ -1066,7 +1108,9 @@ bool CheckArgumentsToJoin(const occ::handle& theS1, const gp_Vec aV12f(theP1, theP2), aV12l(theP2, theP3); if (aV12f.Angle(aV12l) > IntPatch_WLineTool::myMaxConcatAngle) + { return false; + } const gp_Vec aV13(theP1, theP3); const double aSq13 = aV13.SquareMagnitude(); @@ -1110,9 +1154,13 @@ static void ExtendTwoWLFirstFirst(const occ::handle& theS1, theArrPeriods); if (aCheckRes != IntPatchWT_NotConnected) + { theCheckResult |= (IntPatchWT_DisFirstLast | IntPatchWT_DisLastFirst); + } else + { return; + } IntPatch_SpecialPoints::AdjustPointAndVertex(thePtWL1, theArrPeriods, aPOn2S); ExtendFirst(theWLine1, aPOn2S); @@ -1120,15 +1168,21 @@ static void ExtendTwoWLFirstFirst(const occ::handle& theS1, ExtendFirst(theWLine2, aPOn2S); if (theHasBeenJoined || (aCheckRes == IntPatchWT_Singular)) + { return; + } double aPrm = theWLine1->Vertex(1).ParameterOnLine(); while (theWLine1->Vertex(1).ParameterOnLine() == aPrm) + { theWLine1->RemoveVertex(1); + } aPrm = theWLine2->Vertex(1).ParameterOnLine(); while (theWLine2->Vertex(1).ParameterOnLine() == aPrm) + { theWLine2->RemoveVertex(1); + } const int aNbPts = theWLine2->NbPnts(); for (int aNPt = 2; aNPt <= aNbPts; aNPt++) @@ -1191,9 +1245,13 @@ static void ExtendTwoWLFirstLast(const occ::handle& theS1, theArrPeriods); if (aCheckRes != IntPatchWT_NotConnected) + { theCheckResult |= IntPatchWT_DisLastLast; + } else + { return; + } IntPatch_SpecialPoints::AdjustPointAndVertex(thePtWL1, theArrPeriods, aPOn2S); ExtendFirst(theWLine1, aPOn2S); @@ -1201,15 +1259,21 @@ static void ExtendTwoWLFirstLast(const occ::handle& theS1, ExtendLast(theWLine2, aPOn2S); if (theHasBeenJoined || (aCheckRes == IntPatchWT_Singular)) + { return; + } double aPrm = theWLine1->Vertex(1).ParameterOnLine(); while (theWLine1->Vertex(1).ParameterOnLine() == aPrm) + { theWLine1->RemoveVertex(1); + } aPrm = theWLine2->Vertex(theWLine2->NbVertex()).ParameterOnLine(); while (theWLine2->Vertex(theWLine2->NbVertex()).ParameterOnLine() == aPrm) + { theWLine2->RemoveVertex(theWLine2->NbVertex()); + } const int aNbPts = theWLine2->NbPnts(); for (int aNPt = aNbPts - 1; aNPt >= 1; aNPt--) @@ -1270,9 +1334,13 @@ static void ExtendTwoWLLastFirst(const occ::handle& theS1, theArrPeriods); if (aCheckRes != IntPatchWT_NotConnected) + { theCheckResult |= IntPatchWT_DisLastLast; + } else + { return; + } IntPatch_SpecialPoints::AdjustPointAndVertex(thePtWL1, theArrPeriods, aPOn2S); ExtendLast(theWLine1, aPOn2S); @@ -1286,11 +1354,15 @@ static void ExtendTwoWLLastFirst(const occ::handle& theS1, double aPrm = theWLine1->Vertex(theWLine1->NbVertex()).ParameterOnLine(); while (theWLine1->Vertex(theWLine1->NbVertex()).ParameterOnLine() == aPrm) + { theWLine1->RemoveVertex(theWLine1->NbVertex()); + } aPrm = theWLine2->Vertex(1).ParameterOnLine(); while (theWLine2->Vertex(1).ParameterOnLine() == aPrm) + { theWLine2->RemoveVertex(1); + } const int aNbPts = theWLine1->NbPnts(); for (int aNPt = 2; aNPt <= theWLine2->NbPnts(); aNPt++) @@ -1343,9 +1415,13 @@ static void ExtendTwoWLLastLast(const occ::handle& theS1, theArrPeriods); if (aCheckRes != IntPatchWT_NotConnected) + { theCheckResult |= IntPatchWT_DisLastLast; + } else + { return; + } IntPatch_SpecialPoints::AdjustPointAndVertex(thePtWL1, theArrPeriods, aPOn2S); ExtendLast(theWLine1, aPOn2S); @@ -1353,15 +1429,21 @@ static void ExtendTwoWLLastLast(const occ::handle& theS1, ExtendLast(theWLine2, aPOn2S); if (theHasBeenJoined || (aCheckRes == IntPatchWT_Singular)) + { return; + } double aPrm = theWLine1->Vertex(theWLine1->NbVertex()).ParameterOnLine(); while (theWLine1->Vertex(theWLine1->NbVertex()).ParameterOnLine() == aPrm) + { theWLine1->RemoveVertex(theWLine1->NbVertex()); + } aPrm = theWLine2->Vertex(theWLine2->NbVertex()).ParameterOnLine(); while (theWLine2->Vertex(theWLine2->NbVertex()).ParameterOnLine() == aPrm) + { theWLine2->RemoveVertex(theWLine2->NbVertex()); + } const int aNbPts = theWLine1->NbPnts() + theWLine2->NbPnts(); for (int aNPt = theWLine2->NbPnts() - 1; aNPt >= 1; aNPt--) @@ -1399,7 +1481,9 @@ occ::handle IntPatch_WLineTool::ComputePurgedWLine( const IntSurf_PntOn2S& p1 = theWLine->Point(1); const IntSurf_PntOn2S& p2 = theWLine->Point(2); if (p1.Value().IsEqual(p2.Value(), gp::Resolution())) + { return aResult; + } } occ::handle aLocalWLine; @@ -1408,10 +1492,14 @@ occ::handle IntPatch_WLineTool::ComputePurgedWLine( aLocalWLine = new IntPatch_WLine(aLineOn2S, false); aLocalWLine->SetCreatingWayInfo(theWLine->GetCreatingWay()); for (i = 1; i <= nb; i++) + { aLineOn2S->Add(theWLine->Point(i)); + } for (v = 1; v <= nbvtx; v++) + { aLocalWLine->AddVertex(theWLine->Vertex(v)); + } // I: Delete equal points for (i = 1; i <= aLineOn2S->NbPoints(); i++) @@ -1422,7 +1510,9 @@ occ::handle IntPatch_WLineTool::ComputePurgedWLine( anEndIndex = (anEndIndex > nb) ? nb : anEndIndex; if ((aStartIndex > nb) || (anEndIndex <= 1)) + { continue; + } k = aStartIndex; @@ -1441,7 +1531,9 @@ occ::handle IntPatch_WLineTool::ComputePurgedWLine( for (int anIdx = 1; anIdx < 8; anIdx++) { if (aMax < std::abs(UV[anIdx])) + { aMax = std::abs(UV[anIdx]); + } } if (p1.Value().IsEqual(p2.Value(), gp::Resolution()) @@ -1475,9 +1567,13 @@ occ::handle IntPatch_WLineTool::ComputePurgedWLine( if (aLineOn2S->NbPoints() <= 2) { if (aLineOn2S->NbPoints() == 2) + { return aLocalWLine; + } else + { return aResult; + } } // Avoid purge in case of C0 continuity: @@ -1513,7 +1609,9 @@ void IntPatch_WLineTool::JoinWLines(NCollection_SequenceCylinder().Radius(), theS2->Cylinder().Radius()); @@ -1567,12 +1665,16 @@ void IntPatch_WLineTool::JoinWLines(NCollection_Sequence aWLine2(occ::down_cast(theSlin.Value(aN2))); if (aWLine2.IsNull()) + { continue; + } isFirstConnected = isLastConnected = false; @@ -1779,7 +1881,9 @@ void IntPatch_WLineTool::ExtendTwoWLines(NCollection_Sequence& theListOfCriticalPoints) { if (theSlin.Length() < 2) + { return; + } gp_Vec aVec1, aVec2, aVec3; @@ -1804,10 +1908,14 @@ void IntPatch_WLineTool::ExtendTwoWLines(NCollection_SequenceNbPnts(); if (aWLine1->Vertex(1).ParameterOnLine() != 1) + { continue; + } if (aWLine1->Vertex(aWLine1->NbVertex()).ParameterOnLine() != aWLine1->NbPnts()) + { continue; + } const IntSurf_PntOn2S& aPntFWL1 = aWLine1->Point(1); const IntSurf_PntOn2S& aPntFp1WL1 = aWLine1->Point(2); @@ -1834,7 +1942,9 @@ void IntPatch_WLineTool::ExtendTwoWLines(NCollection_Sequence(theSlin.Value(aNumOfLine2))); if (aWLine2.IsNull()) + { continue; + } const IntSurf_PntOn2S& aPntFWL2 = aWLine2->Point(1); const IntSurf_PntOn2S& aPntLWL2 = aWLine2->Point(aWLine2->NbPnts()); @@ -1901,7 +2011,9 @@ void IntPatch_WLineTool::ExtendTwoWLines(NCollection_Sequence(theSlin.Value(aNumOfLine2))); if (aWLine2.IsNull()) + { continue; + } if (aWLine2->Vertex(1).ParameterOnLine() != 1) + { continue; + } if (aWLine2->Vertex(aWLine2->NbVertex()).ParameterOnLine() != aWLine2->NbPnts()) + { continue; + } bool hasBeenJoined = false; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_Intersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_Intersection.cxx index f515cc41f7..01f376fe07 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_Intersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_Intersection.cxx @@ -223,7 +223,9 @@ void IntPolyh_Intersection::Perform(const NCollection_Array1& theUPars1, { // Advanced intersection not done or no intersection is found -> use standard intersection if (nbCouplesStd > 0) + { pMaillageStd->StartPointsChain(mySectionLines, myTangentZones); + } } // Clean up @@ -331,10 +333,12 @@ bool IntPolyh_Intersection::PerformAdv(const NCollection_Array1& theUPar // Merge couples if (theNbCouples > 0) + { MergeCouples(theMaillageFF->GetCouples(), theMaillageFR->GetCouples(), theMaillageRF->GetCouples(), theMaillageRR->GetCouples()); + } } return isDone; @@ -459,7 +463,9 @@ void IntPolyh_Intersection::MergeCouples(NCollection_List& anAr bool IntPolyh_Intersection::IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillage) { if (!theMaillage) + { return true; + } // Interfering triangles NCollection_List& Couples = theMaillage->GetCouples(); @@ -468,12 +474,16 @@ bool IntPolyh_Intersection::IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillag // Flag to define whether advanced intersection is required or not bool isAdvReq = (aNbCouples == 0) && !IsParallel(); if (isAdvReq) + { // No interfering triangles are found -> perform advanced intersection return isAdvReq; + } if (aNbCouples > 10) + { // Enough interfering triangles are found -> no need to perform advanced intersection return isAdvReq; + } const double anEps = .996; //~ cos of 5 deg NCollection_List::Iterator aIt(Couples); @@ -498,7 +508,9 @@ bool IntPolyh_Intersection::IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillag int ComputeIntersection(IntPolyh_PMaillageAffinage& theMaillage) { if (!theMaillage) + { return 0; + } // Compute common box and mark the points inside that box theMaillage->CommonBox(); @@ -524,7 +536,9 @@ int ComputeIntersection(IntPolyh_PMaillageAffinage& theMaillage) bool IntPolyh_Intersection::AnalyzeIntersection(IntPolyh_PMaillageAffinage& theMaillage) { if (!theMaillage) + { return false; + } NCollection_List& Couples = theMaillage->GetCouples(); int FinTTC = Couples.Extent(); @@ -537,7 +551,9 @@ bool IntPolyh_Intersection::AnalyzeIntersection(IntPolyh_PMaillageAffinage& theM { double cosa = std::abs(aIt.Value().Angle()); if (cosa > eps) + { ++npara; + } } if (npara >= theMaillage->GetArrayOfTriangles(1).NbItems() diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_MaillageAffinage.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_MaillageAffinage.cxx index 09f5a89b0a..464b5111ff 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_MaillageAffinage.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_MaillageAffinage.cxx @@ -209,13 +209,17 @@ static void GetInterferingTriangles(IntPolyh_ArrayOfTriangles& { IntPolyh_Triangle& aT = aTriangles[j]; if (!aT.IsIntersectionPossible() || aT.IsDegenerated()) + { continue; + } aBBTree.Add(j, Bnd_Tools::Bnd2BVH(aT.BoundingBox(aPoints))); } if (!aBBTree.Size()) + { return; + } } // 2. Construct BVH trees aBBTree1.Build(); @@ -235,7 +239,9 @@ static void GetInterferingTriangles(IntPolyh_ArrayOfTriangles& const IntPolyh_BoxBndTreeSelector::PairIDs& aPair = aPairs[i]; NCollection_List* pTriangles2 = theCouples.ChangeSeek(aPair.ID1); if (!pTriangles2) + { pTriangles2 = &theCouples(theCouples.Add(aPair.ID1, NCollection_List())); + } pTriangles2->Append(aPair.ID2); } } @@ -289,19 +295,23 @@ void IntPolyh_MaillageAffinage::MakeSampling(const int SurfID, NCollection_Array1& theVPars) { if (SurfID == 1) + { IntPolyh_Tools::MakeSampling(MaSurface1, NbSamplesU1, NbSamplesV1, myEnlargeZone, theUPars, theVPars); + } else + { IntPolyh_Tools::MakeSampling(MaSurface2, NbSamplesU2, NbSamplesV2, myEnlargeZone, theUPars, theVPars); + } } //======================================================================= @@ -416,7 +426,9 @@ void IntPolyh_MaillageAffinage::FillArrayOfPnt(const int int aJD1(0), aJD2(0), aID1(0), aID2(0); DegeneratedIndex(theVPars, aNbV, aS, 1, aJD1, aJD2); if (!(aJD1 || aJD2)) + { DegeneratedIndex(theUPars, aNbU, aS, 2, aID1, aID2); + } bool bDegI, bDeg; int iCnt(0), i, j; @@ -435,7 +447,9 @@ void IntPolyh_MaillageAffinage::FillArrayOfPnt(const int const IntPolyh_PointNormal& aPN = thePointsNorm.Value(iCnt); gp_Vec aNorm = aPN.Normal.Multiplied(1.5 * theDeflTol); if (!isShiftFwd) + { aNorm.Reverse(); + } gp_Pnt aP = aPN.Point.Translated(aNorm); IntPolyh_Point& aIP = TPoints[iCnt]; @@ -443,7 +457,9 @@ void IntPolyh_MaillageAffinage::FillArrayOfPnt(const int aIP.Set(aX, aY, aZ, aU, aV); bDeg = bDegI || (aJD1 == j || aJD2 == j); if (bDeg) + { aIP.SetDegenerated(bDeg); + } ++iCnt; aBox.Add(aP); @@ -525,46 +541,70 @@ void IntPolyh_MaillageAffinage::CommonBox(const Bnd_Box&, else { if (x11 <= x21) + { XMax = x11; + } else { if (x21 <= x11) + { XMax = x21; + } } if (x20 <= x10) + { XMin = x10; + } else { if (x10 <= x20) + { XMin = x20; + } } if (y11 <= y21) + { YMax = y11; + } else { if (y21 <= y11) + { YMax = y21; + } } if (y20 <= y10) + { YMin = y10; + } else { if (y10 <= y20) + { YMin = y20; + } } if (z11 <= z21) + { ZMax = z11; + } else { if (z21 <= z11) + { ZMax = z21; + } } if (z20 <= z10) + { ZMin = z10; + } else { if (z10 <= z20) + { ZMin = z20; + } } if (((XMin == XMax) && (!(YMin == YMax) && !(ZMin == ZMax))) @@ -580,25 +620,43 @@ void IntPolyh_MaillageAffinage::CommonBox(const Bnd_Box&, Z = ZMax - ZMin; // extension of the box if ((X == 0) && (Y != 0)) + { X = Y * 0.1; + } else if ((X == 0) && (Z != 0)) + { X = Z * 0.1; + } else + { X *= 0.1; + } if ((Y == 0) && (X != 0)) + { Y = X * 0.1; + } else if ((Y == 0) && (Z != 0)) + { Y = Z * 0.1; + } else + { Y *= 0.1; + } if ((Z == 0) && (X != 0)) + { Z = X * 0.1; + } else if ((Z == 0) && (Y != 0)) + { Z = Y * 0.1; + } else + { Z *= 0.1; + } if ((X == 0) && (Y == 0) && (Z == 0)) { @@ -927,8 +985,10 @@ void IntPolyh_MaillageAffinage::FillArrayOfTriangles(const int SurfID) & (TPoints[PntInit + NbSamplesV + 1].PartOfCommon())) && ((TPoints[PntInit + NbSamplesV + 1].PartOfCommon()) & (TPoints[PntInit].PartOfCommon()))) + { // IF NOT IP=0 TTriangles[CpteurTabTriangles].SetIntersectionPossible(false); + } CpteurTabTriangles++; @@ -941,7 +1001,9 @@ void IntPolyh_MaillageAffinage::FillArrayOfTriangles(const int SurfID) && ((TPoints[PntInit + NbSamplesV + 1].PartOfCommon()) & (TPoints[PntInit + NbSamplesV].PartOfCommon())) && ((TPoints[PntInit + NbSamplesV].PartOfCommon()) & (TPoints[PntInit].PartOfCommon()))) + { TTriangles[CpteurTabTriangles].SetIntersectionPossible(false); + } CpteurTabTriangles++; @@ -967,14 +1029,18 @@ void IntPolyh_MaillageAffinage::CommonPartRefinement() for (int i = 0; i < FinInit1; i++) { if (TTriangles1[i].IsIntersectionPossible()) + { TTriangles1[i].MiddleRefinement(i, MaSurface1, TPoints1, TTriangles1, TEdges1); + } } int FinInit2 = TTriangles2.NbItems(); for (int ii = 0; ii < FinInit2; ii++) { if (TTriangles2[ii].IsIntersectionPossible()) + { TTriangles2[ii].MiddleRefinement(ii, MaSurface2, TPoints2, TTriangles2, TEdges2); + } } } @@ -991,7 +1057,9 @@ void IntPolyh_MaillageAffinage::LocalSurfaceRefinement(const int SurfID) for (int i = 0; i < FinInit1; i++) { if (TTriangles1[i].IsIntersectionPossible()) + { TTriangles1[i].MiddleRefinement(i, MaSurface1, TPoints1, TTriangles1, TEdges1); + } } } // @@ -1001,7 +1069,9 @@ void IntPolyh_MaillageAffinage::LocalSurfaceRefinement(const int SurfID) for (int ii = 0; ii < FinInit2; ii++) { if (TTriangles2[ii].IsIntersectionPossible()) + { TTriangles2[ii].MiddleRefinement(ii, MaSurface2, TPoints2, TTriangles2, TEdges2); + } } } } @@ -1032,9 +1102,13 @@ void IntPolyh_MaillageAffinage::ComputeDeflections(const int SurfID) IntPolyh_Triangle& aTriangle = TTriangles[i]; double Fleche = aTriangle.ComputeDeflection(aSurface, TPoints); if (Fleche > FlecheMax) + { FlecheMax = Fleche; + } if (Fleche < FlecheMin) + { FlecheMin = Fleche; + } } } @@ -1169,7 +1243,9 @@ static void LargeTrianglesDeflectionsRefinement(const occ::handle dy) ? dy : dx; if (diag > dd) + { diag = dd; + } // calculation of the criterion of refining double CritereAffinage = 0.0; @@ -1318,9 +1394,13 @@ inline double maxSR(const double a, const double b, const double c) { double t = a; if (b > t) + { t = b; + } if (c > t) + { t = c; + } return t; } @@ -1332,9 +1412,13 @@ inline double minSR(const double a, const double b, const double c) { double t = a; if (b < t) + { t = b; + } if (c < t) + { t = c; + } return t; } @@ -1363,9 +1447,13 @@ int project6(const IntPolyh_Point& ax, double mn2 = minSR(Q1, Q2, Q3); if (mn1 > mx2) + { return 0; + } if (mn2 > mx1) + { return 0; + } return 1; } @@ -1390,18 +1478,30 @@ int IntPolyh_MaillageAffinage::TriContact(const IntPolyh_Point& P1, Outwards are (g1,g2,g3) and (h1,h2,h3).*/ if (maxSR(P1.X(), P2.X(), P3.X()) < minSR(Q1.X(), Q2.X(), Q3.X())) + { return (0); + } if (maxSR(P1.Y(), P2.Y(), P3.Y()) < minSR(Q1.Y(), Q2.Y(), Q3.Y())) + { return (0); + } if (maxSR(P1.Z(), P2.Z(), P3.Z()) < minSR(Q1.Z(), Q2.Z(), Q3.Z())) + { return (0); + } if (minSR(P1.X(), P2.X(), P3.X()) > maxSR(Q1.X(), Q2.X(), Q3.X())) + { return (0); + } if (minSR(P1.Y(), P2.Y(), P3.Y()) > maxSR(Q1.Y(), Q2.Y(), Q3.Y())) + { return (0); + } if (minSR(P1.Z(), P2.Z(), P3.Z()) > maxSR(Q1.Z(), Q2.Z(), Q3.Z())) + { return (0); + } IntPolyh_Point p1, p2, p3; IntPolyh_Point q1, q2, q3; @@ -1483,41 +1583,75 @@ int IntPolyh_MaillageAffinage::TriContact(const IntPolyh_Point& P1, // Now the testing is done if (!project6(n1, p1, p2, p3, q1, q2, q3)) + { return 0; // T2 is not higher or lower than T1 + } if (!project6(m1, p1, p2, p3, q1, q2, q3)) + { return 0; // T1 is not higher of lower than T2 + } if (!project6(ef11, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef12, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef13, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef21, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef22, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef23, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef31, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef32, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(ef33, p1, p2, p3, q1, q2, q3)) + { return 0; + } if (!project6(g1, p1, p2, p3, q1, q2, q3)) + { return 0; // T2 is outside of T1 in the plane of T1 + } if (!project6(g2, p1, p2, p3, q1, q2, q3)) + { return 0; // T2 is outside of T1 in the plane of T1 + } if (!project6(g3, p1, p2, p3, q1, q2, q3)) + { return 0; // T2 is outside of T1 in the plane of T1 + } if (!project6(h1, p1, p2, p3, q1, q2, q3)) + { return 0; // T1 is outside of T2 in the plane of T2 + } if (!project6(h2, p1, p2, p3, q1, q2, q3)) + { return 0; // T1 is outside of T2 in the plane of T2 + } if (!project6(h3, p1, p2, p3, q1, q2, q3)) + { return 0; // T1 is outside of T2 in the plane of T2 + } // Calculation of cosinus angle between two normals double SqModn1 = -1.0; @@ -1572,9 +1706,13 @@ void TestNbPoints(const int, else if ((NbPoints == 1) && (NbPointsTotal == 2)) { if ((SP1.CheckSameSP(Pt1)) || (SP2.CheckSameSP(Pt1))) + { NbPointsTotal = 2; + } else + { NbPointsTotal = 3; + } } else if ((NbPoints == 2) && (NbPointsTotal == 0)) { @@ -1595,19 +1733,27 @@ void TestNbPoints(const int, NbPointsTotal = 2; } else + { NbPointsTotal = 3; /// case SP1!=Pt1 && SP1!=Pt2! + } } else if ((NbPoints == 2) && (NbPointsTotal == 2)) { // there is also SP1!=SP2 if ((SP1.CheckSameSP(Pt1)) || (SP1.CheckSameSP(Pt2))) { if ((SP2.CheckSameSP(Pt1)) || (SP2.CheckSameSP(Pt2))) + { NbPointsTotal = 2; + } else + { NbPointsTotal = 3; + } } else + { NbPointsTotal = 3; + } } } } @@ -1736,9 +1882,13 @@ int IntPolyh_MaillageAffinage::StartingPointsResearch(const int T1, SP2.SetCoupleValue(T1, T2); } else if (NbPointsTotal == 1) + { SP1.SetCoupleValue(T1, T2); + } else if (NbPointsTotal == 3) + { SP1.SetCoupleValue(T1, T2); + } return (NbPointsTotal); } @@ -1758,7 +1908,9 @@ int IntPolyh_MaillageAffinage::NextStartingPointsResearch(const int int EdgeInit1 = SPInit.E1(); int EdgeInit2 = SPInit.E2(); if ((T1 < 0) || (T2 < 0)) + { NbPointsTotal = 0; + } else { @@ -1867,7 +2019,9 @@ int IntPolyh_MaillageAffinage::NextStartingPointsResearch(const int if (NbPointsTotal == 1) { if (SP1.CheckSameSP(SPInit)) + { NbPointsTotal = 0; + } else { SPNext = SP1; @@ -1945,20 +2099,32 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, { } IntPolyh_Point PIE; - if (std::abs(lambda) < MyConfusionPrecision) // lambda=0 + if (std::abs(lambda) < MyConfusionPrecision) + { // lambda=0 PIE = PE1; - else if (std::abs(lambda) > 1.0 - MyConfusionPrecision) // lambda=1 + } + else if (std::abs(lambda) > 1.0 - MyConfusionPrecision) + { // lambda=1 PIE = PE2; + } else + { PIE = PE1 + Edge * lambda; + } double alpha = RealLast(); if (Cote.X() != 0) + { alpha = (PIE.X() - PT1.X()) / Cote.X(); + } else if (Cote.Y() != 0) + { alpha = (PIE.Y() - PT1.Y()) / Cote.Y(); + } else if (Cote.Z() != 0) + { alpha = (PIE.Z() - PT1.Z()) / Cote.Z(); + } else { } @@ -1991,9 +2157,13 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP1.SetUV2(PIE.U(), PIE.V()); SP1.SetEdge1(Tri1.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP1.SetLambda1(alpha); + } else + { SP1.SetLambda1(1.0 - alpha); + } } NbPoints++; } @@ -2017,9 +2187,13 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP1.SetUV2(PT1.U() + Cote.U() * alpha, PT1.V() + Cote.V() * alpha); SP1.SetEdge2(Tri2.GetEdgeNumber(CoteIndex)); if (Tri2.GetEdgeOrientation(CoteIndex) > 0) + { SP1.SetLambda2(alpha); + } else + { SP1.SetLambda2(1.0 - alpha); + } } NbPoints++; } @@ -2051,9 +2225,13 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP2.SetUV2(PIE.U(), PIE.V()); SP2.SetEdge1(Tri1.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP2.SetLambda1(alpha); + } else + { SP2.SetLambda1(1.0 - alpha); + } } NbPoints++; } @@ -2077,9 +2255,13 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP2.SetUV2(PT1.U() + Cote.U() * alpha, PT1.V() + Cote.V() * alpha); SP2.SetEdge2(Tri2.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP2.SetLambda2(alpha); + } else + { SP2.SetLambda2(1.0 - alpha); + } } NbPoints++; } @@ -2220,14 +2402,22 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP1.SetEdge1(Tri1.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP1.SetLambda1(alpha1); + } else + { SP1.SetLambda1(1.0 - alpha1); + } if (Tri2.GetEdgeOrientation(EdgeIndex) > 0) + { SP1.SetLambda2(lambda1); + } else + { SP1.SetLambda2(1.0 - lambda1); + } } if (TriSurfID == 2) { /// cote appartient a Tri2 @@ -2236,20 +2426,30 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP1.SetEdge2(Tri2.GetEdgeNumber(CoteIndex)); if (Tri2.GetEdgeOrientation(CoteIndex) > 0) + { SP1.SetLambda1(alpha1); + } else + { SP1.SetLambda1(1.0 - alpha1); + } if (Tri1.GetEdgeOrientation(EdgeIndex) > 0) + { SP1.SetLambda2(lambda1); + } else + { SP1.SetLambda2(1.0 - lambda1); + } } // It is checked if PEP1!=PEP2 if ((NbPoints == 2) && (std::abs(PEP1.U() - PEP2.U()) < MyConfusionPrecision) && (std::abs(PEP1.V() - PEP2.V()) < MyConfusionPrecision)) + { NbPoints = 1; + } if (NbPoints == 2) { SP2.SetXYZ(PEP2.X(), PEP2.Y(), PEP2.Z()); @@ -2260,14 +2460,22 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP2.SetEdge1(Tri1.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP2.SetLambda1(alpha1); + } else + { SP2.SetLambda1(1.0 - alpha1); + } if (Tri2.GetEdgeOrientation(EdgeIndex) > 0) + { SP2.SetLambda2(lambda1); + } else + { SP2.SetLambda2(1.0 - lambda1); + } } if (TriSurfID == 2) { @@ -2276,14 +2484,22 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, SP2.SetEdge2(Tri2.GetEdgeNumber(CoteIndex)); if (Tri1.GetEdgeOrientation(CoteIndex) > 0) + { SP2.SetLambda1(alpha1); + } else + { SP2.SetLambda1(1.0 - alpha1); + } if (Tri2.GetEdgeOrientation(EdgeIndex) > 0) + { SP2.SetLambda2(lambda1); + } else + { SP2.SetLambda2(1.0 - lambda1); + } } } } @@ -2292,24 +2508,40 @@ void CalculPtsInterTriEdgeCoplanaires(const int TriSurfID, if (NbPoints > 0) { if (std::abs(SP1.Lambda1()) < MyConfusionPrecision) + { SP1.SetEdge1(-1); + } if (std::abs(SP1.Lambda1() - 1) < MyConfusionPrecision) + { SP1.SetEdge1(-1); + } if (std::abs(SP1.Lambda2()) < MyConfusionPrecision) + { SP1.SetEdge2(-1); + } if (std::abs(SP1.Lambda2() - 1) < MyConfusionPrecision) + { SP1.SetEdge2(-1); + } } if (NbPoints == 2) { if (std::abs(SP2.Lambda1()) < MyConfusionPrecision) + { SP2.SetEdge1(-1); + } if (std::abs(SP2.Lambda1() - 1) < MyConfusionPrecision) + { SP2.SetEdge1(-1); + } if (std::abs(SP2.Lambda2()) < MyConfusionPrecision) + { SP2.SetEdge2(-1); + } if (std::abs(SP2.Lambda2() - 1) < MyConfusionPrecision) + { SP2.SetEdge2(-1); + } } } @@ -2414,10 +2646,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS if ((NbPoints > 1) && (std::abs(SP2.U1() - SP1.U1()) < MyConfusionPrecision) && (std::abs(SP1.V1() - SP2.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } // second side if (NbPoints < 2) + { CalculPtsInterTriEdgeCoplanaires(TriSurfID, NormaleT, Tri1, @@ -2433,14 +2668,18 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS SP1, SP2, NbPoints); + } } if ((NbPoints > 1) && (std::abs(SP1.U1() - SP2.U1()) < MyConfusionPrecision) && (std::abs(SP1.V2() - SP2.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } if (NbPoints >= 2) + { return (NbPoints); - + } else if ((((pp2 >= ppe1) && (pp1 <= ppe1) && (pp3 <= ppe1)) || ((pp2 <= ppe1) && (pp1 >= ppe1) && (pp3 >= ppe1))) && (NbPoints < 2)) @@ -2466,10 +2705,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS if ((NbPoints > 1) && (std::abs(SP2.U1() - SP1.U1()) < MyConfusionPrecision) && (std::abs(SP1.V1() - SP2.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } // second side if (NbPoints < 2) + { CalculPtsInterTriEdgeCoplanaires(TriSurfID, NormaleT, Tri1, @@ -2485,13 +2727,17 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS SP1, SP2, NbPoints); + } } if ((NbPoints > 1) && (std::abs(SP2.U1() - SP1.U1()) < MyConfusionPrecision) && (std::abs(SP1.V1() - SP2.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } if (NbPoints >= 2) + { return (NbPoints); - + } else if ((((pp3 >= ppe1) && (pp1 <= ppe1) && (pp2 <= ppe1)) || ((pp3 <= ppe1) && (pp1 >= ppe1) && (pp2 >= ppe1))) && (NbPoints < 2)) @@ -2517,10 +2763,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS if ((NbPoints > 1) && (std::abs(SP2.U1() - SP1.U1()) < MyConfusionPrecision) && (std::abs(SP1.V1() - SP2.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } // second side if (NbPoints < 2) + { CalculPtsInterTriEdgeCoplanaires(TriSurfID, NormaleT, Tri1, @@ -2536,12 +2785,17 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS SP1, SP2, NbPoints); + } } if ((NbPoints > 1) && (std::abs(SP2.U1() - SP1.U1()) < MyConfusionPrecision) && (std::abs(SP2.V1() - SP1.V1()) < MyConfusionPrecision)) + { NbPoints = 1; + } if (NbPoints >= 2) + { return (NbPoints); + } } } @@ -2559,17 +2813,25 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS { // lambda==0 PI = PE1; if (TriSurfID == 1) + { SP1.SetEdge2(-1); + } else + { SP1.SetEdge1(-1); + } } else if (std::abs(lambda - 1.0) < MyConfusionPrecision) { // lambda==1 PI = PE2; if (TriSurfID == 1) + { SP1.SetEdge2(-1); + } else + { SP1.SetEdge1(-1); + } } else { @@ -2577,16 +2839,24 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS if (TriSurfID == 1) { if (Tri2.GetEdgeOrientation(EdgeIndex) > 0) + { SP1.SetLambda2(lambda); + } else + { SP1.SetLambda2(1.0 - lambda); + } } if (TriSurfID == 2) { if (Tri1.GetEdgeOrientation(EdgeIndex) > 0) + { SP1.SetLambda1(lambda); + } else + { SP1.SetLambda1(1.0 - lambda); + } } } @@ -2605,9 +2875,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS /// It is checked if 1.0>=alpha>=0.0 if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); + } else + { beta = (PI.X() - PT1.X() - alpha * Cote12.X()) / Cote23X; + } } // Combination Eq1 and Eq2 with Cote23.X()==0 else if ((std::abs(Cote12.X()) > MyConfusionPrecision) @@ -2616,12 +2890,17 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS alpha = (PI.X() - PT1.X()) / Cote12.X(); if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); - + } else if (std::abs(Cote23.Y()) > MyConfusionPrecision) + { beta = (PI.Y() - PT1.Y() - alpha * Cote12.Y()) / Cote23.Y(); + } else if (std::abs(Cote23.Z()) > MyConfusionPrecision) + { beta = (PI.Z() - PT1.Z() - alpha * Cote12.Z()) / Cote23.Z(); + } else { } @@ -2635,9 +2914,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS alpha = (PI.Z() - PT1.Z() - (PI.X() - PT1.X()) * Cote23.Z() / Cote23.X()) / D3; if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); + } else + { beta = (PI.X() - PT1.X() - alpha * Cote12.X()) / Cote23.X(); + } } // Combination Eq2 and Eq3 else if ((std::abs(Cote23.Y()) > MyConfusionPrecision) @@ -2648,9 +2931,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS alpha = (PI.Z() - PT1.Z() - (PI.Y() - PT1.Y()) * Cote23.Z() / Cote23.Y()) / D4; if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); + } else + { beta = (PI.Y() - PT1.Y() - alpha * Cote12.Y()) / Cote23.Y(); + } } // Combination Eq2 and Eq3 with Cote23.Y()==0 else if ((std::abs(Cote12.Y()) > MyConfusionPrecision) @@ -2659,11 +2946,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS alpha = (PI.Y() - PT1.Y()) / Cote12.Y(); if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); - + } else if (std::abs(Cote23.Z()) > MyConfusionPrecision) + { beta = (PI.Z() - PT1.Z() - alpha * Cote12.Z()) / Cote23.Z(); - + } else { printf("\nCote PT2PT3 nul1\n"); @@ -2678,11 +2967,13 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS alpha = (PI.Z() - PT1.Z()) / Cote12.Z(); if ((alpha < -MyConfusionPrecision) || (alpha > (1.0 + MyConfusionPrecision))) + { return (0); - + } else if (std::abs(Cote23.X()) > MyConfusionPrecision) + { beta = (PI.X() - PT1.X() - alpha * Cote12.X()) / Cote23.X(); - + } else { } @@ -2696,7 +2987,9 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS } if ((beta < -MyConfusionPrecision) || (beta > (alpha + MyConfusionPrecision))) + { return (0); + } else { SP1.SetXYZ(PI.X(), PI.Y(), PI.Z()); @@ -2730,25 +3023,37 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS { // beta==0 SP1.SetEdge1(Tri1.GetEdgeNumber(1)); if (Tri1.GetEdgeOrientation(1) > 0) + { SP1.SetLambda1(alpha); + } else + { SP1.SetLambda1(1.0 - alpha); + } } else if (std::abs(beta - alpha) < MyConfusionPrecision) { // beta==alpha SP1.SetEdge1(Tri1.GetEdgeNumber(3)); if (Tri1.GetEdgeOrientation(3) > 0) + { SP1.SetLambda1(1.0 - alpha); + } else + { SP1.SetLambda1(alpha); + } } else if (std::abs(alpha - 1) < MyConfusionPrecision) { // alpha==1 SP1.SetEdge1(Tri1.GetEdgeNumber(2)); if (Tri1.GetEdgeOrientation(2) > 0) + { SP1.SetLambda1(beta); + } else + { SP1.SetLambda1(1.0 - beta); + } } } else if (TriSurfID == 2) @@ -2780,25 +3085,37 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS { // beta==0 SP1.SetEdge2(Tri2.GetEdgeNumber(1)); if (Tri2.GetEdgeOrientation(1) > 0) + { SP1.SetLambda2(alpha); + } else + { SP1.SetLambda2(1.0 - alpha); + } } else if (std::abs(beta - alpha) < MyConfusionPrecision) { // beta==alpha SP1.SetEdge2(Tri2.GetEdgeNumber(3)); if (Tri2.GetEdgeOrientation(3) > 0) + { SP1.SetLambda2(1.0 - alpha); + } else + { SP1.SetLambda2(alpha); + } } else if (std::abs(alpha - 1) < MyConfusionPrecision) { // alpha==1 SP1.SetEdge2(Tri2.GetEdgeNumber(2)); if (Tri2.GetEdgeOrientation(2) > 0) + { SP1.SetLambda2(alpha); + } else + { SP1.SetLambda2(1.0 - alpha); + } } } else @@ -2807,7 +3124,9 @@ int IntPolyh_MaillageAffinage::TriangleEdgeContact(const int TriS } } else + { return 0; + } } return (NbPoints); } @@ -2990,7 +3309,9 @@ int CheckNextStartPoint(IntPolyh_SectionLine& SectionLine, else if (Test) { if (Prepend) + { SectionLine.Prepend(SP); + } else { SectionLine[SectionLine.NbStartPoints()] = SP; @@ -3024,13 +3345,19 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS int SectionLineIndex = TSectionLines.NbItems(); // fill last section line if still empty (eap) if (SectionLineIndex > 0 && TSectionLines[SectionLineIndex - 1].NbStartPoints() == 0) + { SectionLineIndex -= 1; + } else + { TSectionLines.IncrementNbItems(); + } IntPolyh_SectionLine& MySectionLine = TSectionLines[SectionLineIndex]; - if (MySectionLine.GetN() == 0) // eap - MySectionLine.Init(10000); // Initialisation of array of StartPoint + if (MySectionLine.GetN() == 0) + { // eap + MySectionLine.Init(10000); // Initialisation of array of StartPoint + } int NbPoints = -1; int T1I, T2I; @@ -3059,9 +3386,13 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { //&&(SP1.E2()!=-1) already tested if the point is not a top int NextTriangle1 = 0; if (TEdges1[SP1.E1()].FirstTriangle() != T1I) + { NextTriangle1 = TEdges1[SP1.E1()].FirstTriangle(); + } else + { NextTriangle1 = TEdges1[SP1.E1()].SecondTriangle(); + } double Angle = -2.0; if (CheckCoupleAndGetAngle(NextTriangle1, T2I, Angle, TTrianglesContacts)) @@ -3084,12 +3415,18 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { SPNext1.SetChainList(SectionLineIndex); if (CheckNextStartPoint(MySectionLine, TTangentZones, SPNext1)) + { SP11 = SPNext1; + } else + { EndChainList = 0; + } } else + { EndChainList = 0; // There is no next point + } } } } @@ -3115,9 +3452,13 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { //&&(SP1.E1()!=-1) already tested int NextTriangle2; if (TEdges2[SP1.E2()].FirstTriangle() != T2I) + { NextTriangle2 = TEdges2[SP1.E2()].FirstTriangle(); + } else + { NextTriangle2 = TEdges2[SP1.E2()].SecondTriangle(); + } double Angle = -2.0; if (CheckCoupleAndGetAngle(T1I, NextTriangle2, Angle, TTrianglesContacts)) @@ -3145,12 +3486,18 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { SPNext1.SetChainList(SectionLineIndex); if (CheckNextStartPoint(MySectionLine, TTangentZones, SPNext1, Prepend)) + { SP12 = SPNext1; + } else + { EndChainList = 0; + } } else + { EndChainList = 0; // there is no next point + } } } @@ -3193,12 +3540,18 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { SPNext2.SetChainList(SectionLineIndex); if (CheckNextStartPoint(MySectionLine, TTangentZones, SPNext2)) + { SP1 = SPNext2; + } else + { EndChainList = 0; + } } else + { EndChainList = 0; // there is no next point + } } } @@ -3222,12 +3575,18 @@ int IntPolyh_MaillageAffinage::StartPointsChain(IntPolyh_ArrayOfSectionLines& TS { SPNext2.SetChainList(SectionLineIndex); if (CheckNextStartPoint(MySectionLine, TTangentZones, SPNext2, Prepend)) + { SP2 = SPNext2; + } else + { EndChainList = 0; + } } else + { EndChainList = 0; // there is no next point + } } } } @@ -3267,9 +3626,13 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& // case if the point is on edge of T1 int NextTriangle1; if (TEdges1[SP.E1()].FirstTriangle() != SP.T1()) + { NextTriangle1 = TEdges1[SP.E1()].FirstTriangle(); + } else + { NextTriangle1 = TEdges1[SP.E1()].SecondTriangle(); + } // If is checked if two triangles intersect double Angle = -2.0; if (CheckCoupleAndGetAngle(NextTriangle1, SP.T2(), Angle, TTrianglesContacts)) @@ -3278,7 +3641,9 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& if (NbPoints != 1) { if (NbPoints > 1) + { CheckNextStartPoint(MySectionLine, TTangentZones, SPNext, Prepend); + } else { @@ -3286,19 +3651,27 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& } } else + { SPNext.SetAngle(Angle); + } } else + { NbPoints = 0; // this couple does not intersect + } } else if ((SP.E1() == -2) && (SP.E2() >= 0)) { // case if the point is on edge of T2 int NextTriangle2; if (TEdges2[SP.E2()].FirstTriangle() != SP.T2()) + { NextTriangle2 = TEdges2[SP.E2()].FirstTriangle(); + } else + { NextTriangle2 = TEdges2[SP.E2()].SecondTriangle(); + } double Angle = -2.0; if (CheckCoupleAndGetAngle(SP.T1(), NextTriangle2, Angle, TTrianglesContacts)) { @@ -3306,7 +3679,9 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& if (NbPoints != 1) { if (NbPoints > 1) + { CheckNextStartPoint(MySectionLine, TTangentZones, SPNext, Prepend); + } else { @@ -3314,10 +3689,14 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& } } else + { SPNext.SetAngle(Angle); + } } else + { NbPoints = 0; + } } else if ((SP.E1() == -2) && (SP.E2() == -2)) { @@ -3330,14 +3709,22 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& /// the point is located on two edges int NextTriangle1; if (TEdges1[SP.E1()].FirstTriangle() != SP.T1()) + { NextTriangle1 = TEdges1[SP.E1()].FirstTriangle(); + } else + { NextTriangle1 = TEdges1[SP.E1()].SecondTriangle(); + } int NextTriangle2; if (TEdges2[SP.E2()].FirstTriangle() != SP.T2()) + { NextTriangle2 = TEdges2[SP.E2()].FirstTriangle(); + } else + { NextTriangle2 = TEdges2[SP.E2()].SecondTriangle(); + } double Angle = -2.0; NCollection_List::Iterator aItCT11, aItCT22; @@ -3369,13 +3756,19 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& { // NbPoints==1 SPNext.SetAngle(Angle); if (aItCT11.More()) + { aItCT11.ChangeValue().SetAnalyzed(true); + } if (aItCT22.More()) + { aItCT22.ChangeValue().SetAnalyzed(true); + } } } else + { NbPoints = 0; + } } else if ((SP.E1() == -1) || (SP.E2() == -1)) { @@ -3390,7 +3783,9 @@ int IntPolyh_MaillageAffinage::GetNextChainStartPoint(const IntPolyh_StartPoint& const IntPolyh_ArrayOfPoints& IntPolyh_MaillageAffinage::GetArrayOfPoints(const int SurfID) const { if (SurfID == 1) + { return (TPoints1); + } return (TPoints2); } @@ -3399,7 +3794,9 @@ const IntPolyh_ArrayOfPoints& IntPolyh_MaillageAffinage::GetArrayOfPoints(const const IntPolyh_ArrayOfEdges& IntPolyh_MaillageAffinage::GetArrayOfEdges(const int SurfID) const { if (SurfID == 1) + { return (TEdges1); + } return (TEdges2); } @@ -3409,7 +3806,9 @@ const IntPolyh_ArrayOfTriangles& IntPolyh_MaillageAffinage::GetArrayOfTriangles( const int SurfID) const { if (SurfID == 1) + { return (TTriangles1); + } return (TTriangles2); } @@ -3418,7 +3817,9 @@ const IntPolyh_ArrayOfTriangles& IntPolyh_MaillageAffinage::GetArrayOfTriangles( Bnd_Box IntPolyh_MaillageAffinage::GetBox(const int SurfID) const { if (SurfID == 1) + { return (MyBox1); + } return (MyBox2); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_SectionLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_SectionLine.cxx index 9b1d2541a1..8f5a217682 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_SectionLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_SectionLine.cxx @@ -41,7 +41,9 @@ void IntPolyh_SectionLine::Init(const int /*N*/) // ptr = (void*) (new IntPolyh_StartPoint [N]); // n=N; if (!mySeqOfSPoints.Length()) + { IncrementNbStartPoints(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_StartPoint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_StartPoint.cxx index ee119cde6a..80e4f34c97 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_StartPoint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_StartPoint.cxx @@ -198,7 +198,9 @@ int IntPolyh_StartPoint::GetEdgePoints(const IntPolyh_Triangle& Triangle, SurfID = 2; } else + { SurfID = 0; + } return (SurfID); } @@ -270,7 +272,9 @@ int IntPolyh_StartPoint::CheckSameSP(const IntPolyh_StartPoint& SP) const < MyConfusionPrecision)) // lambda1!=-1 && lambda1==SP.lambda2 || ((lambda2 > -MyConfusionPrecision) && (std::abs(lambda2 - SP.lambda2) < MyConfusionPrecision))) + { Test = 1; + } // if( (std::abs(u1-SP.u1)& theSurf, // Enlarge surface intersection zone if necessary if (theEnlargeZone) + { EnlargeZone(theSurf, u0, u1, v0, v1); + } int aNbSamplesU1 = theNbSU - 1; int aNbSamplesV1 = theNbSV - 1; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntRes2d/IntRes2d_Intersection.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntRes2d/IntRes2d_Intersection.cxx index 83dbd65f88..cb5d8c20e0 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntRes2d/IntRes2d_Intersection.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntRes2d/IntRes2d_Intersection.cxx @@ -424,7 +424,9 @@ void InternalVerifyPosition(IntRes2d_Transition& T1, if (!(PARAMEQUAL(PParamOnFirst, FirstParam1) || PARAMEQUAL(PParamOnFirst, LastParam1))) { if ((PParamOnFirst > FirstParam1) && (PParamOnFirst < LastParam1)) + { T1.SetPosition(IntRes2d_Middle); + } } } if (T2.PositionOnCurve() != IntRes2d_Middle) @@ -432,7 +434,9 @@ void InternalVerifyPosition(IntRes2d_Transition& T1, if (!(PARAMEQUAL(PParamOnSecond, FirstParam2) || PARAMEQUAL(PParamOnSecond, LastParam2))) { if ((PParamOnSecond > FirstParam2) && (PParamOnSecond < LastParam2)) + { T2.SetPosition(IntRes2d_Middle); + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_PntOn2S.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_PntOn2S.cxx index aefca61fbb..18ab57d4f1 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_PntOn2S.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_PntOn2S.cxx @@ -58,9 +58,13 @@ gp_Pnt2d IntSurf_PntOn2S::ValueOnSurface(const bool OnFirst) const { gp_Pnt2d PointOnSurf; if (OnFirst) + { PointOnSurf.SetCoord(u1, v1); + } else + { PointOnSurf.SetCoord(u2, v2); + } return PointOnSurf; } @@ -83,7 +87,9 @@ bool IntSurf_PntOn2S::IsSame(const IntSurf_PntOn2S& theOterPoint, const double theTol2D) const { if (pt.SquareDistance(theOterPoint.Value()) > theTol3D * theTol3D) + { return false; + } if (theTol2D < 0.0) { // We need not compare 2D-coordinates of the points @@ -96,7 +102,9 @@ bool IntSurf_PntOn2S::IsSame(const IntSurf_PntOn2S& theOterPoint, gp_Pnt2d aP1(u1, v1), aP2(aU1, aV1); if (!aP1.IsEqual(aP2, theTol2D)) + { return false; + } aP1.SetCoord(u2, v2); aP2.SetCoord(aU2, aV2); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_Quadric.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_Quadric.cxx index 7e94a52239..a868a1f74e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_Quadric.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntSurf/IntSurf_Quadric.cxx @@ -486,9 +486,13 @@ gp_Vec IntSurf_Quadric::Normale(const double U, const double V) const { case GeomAbs_Plane: if (ax3direc) + { return ax3.Direction(); + } else + { return ax3.Direction().Reversed(); + } case GeomAbs_Cylinder: return Normale(Value(U, V)); case GeomAbs_Sphere: @@ -523,9 +527,13 @@ gp_Vec IntSurf_Quadric::Normale(const gp_Pnt& P) const { case GeomAbs_Plane: if (ax3direc) + { return ax3.Direction(); + } else + { return ax3.Direction().Reversed(); + } case GeomAbs_Cylinder: { if (ax3direc) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/IntWalk/IntWalk_PWalking.cxx b/src/ModelingAlgorithms/TKGeomAlgo/IntWalk/IntWalk_PWalking.cxx index 42bf4d9047..eef4634dd5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/IntWalk/IntWalk_PWalking.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/IntWalk/IntWalk_PWalking.cxx @@ -54,24 +54,40 @@ void IntWalk_PWalking::ComputePasInit(const double theDeltaU1, //-- theDeltaU1 : On box of Inter //-- aDeltaU1 : On parametric space if (!Precision::IsInfinite(aDeltaU1)) + { pasuv[0] = std::max(Increment * std::max(theDeltaU1, aRangePart * aDeltaU1), pasuv[0]); + } else + { pasuv[0] = std::max(Increment * theDeltaU1, pasuv[0]); + } if (!Precision::IsInfinite(aDeltaV1)) + { pasuv[1] = std::max(Increment * std::max(theDeltaV1, aRangePart * aDeltaV1), pasuv[1]); + } else + { pasuv[1] = std::max(Increment * theDeltaV1, pasuv[1]); + } if (!Precision::IsInfinite(aDeltaU2)) + { pasuv[2] = std::max(Increment * std::max(theDeltaU2, aRangePart * aDeltaU2), pasuv[2]); + } else + { pasuv[2] = std::max(Increment * theDeltaU2, pasuv[2]); + } if (!Precision::IsInfinite(aDeltaV2)) + { pasuv[3] = std::max(Increment * std::max(theDeltaV2, aRangePart * aDeltaV2), pasuv[3]); + } else + { pasuv[3] = std::max(Increment * theDeltaV2, pasuv[3]); + } const double ResoU1tol = Adaptor3d_HSurfaceTool::UResolution(Caro1, tolconf); const double ResoV1tol = Adaptor3d_HSurfaceTool::VResolution(Caro1, tolconf); @@ -130,25 +146,39 @@ static void IsParallel(const occ::handle& theLine, { // Fix possible "out of parameter" case. if (aNPoint > aNbLinePnts) + { aNPoint = aNbLinePnts; + } double u, v; if (theCheckSurf1) + { theLine->Value(RealToInt(aNPoint)).ParametersOnS1(u, v); + } else + { theLine->Value(RealToInt(aNPoint)).ParametersOnS2(u, v); + } if (u < aUmin) + { aUmin = u; + } if (u > aUmax) + { aUmax = u; + } if (v < aVmin) + { aVmin = v; + } if (v > aVmax) + { aVmax = v; + } } theIsVparallel = ((aUmax - aUmin) < theToler); @@ -235,7 +265,9 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, MAXVAL = std::abs(Um1); MAXVAL2 = std::abs(UM1); if (MAXVAL2 > MAXVAL) + { MAXVAL = MAXVAL2; + } NEWRESO = ResoU1 * MAXVAL; if (NEWRESO > ResoU1 && NEWRESO < 10) { @@ -245,7 +277,9 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, MAXVAL = std::abs(Um2); MAXVAL2 = std::abs(UM2); if (MAXVAL2 > MAXVAL) + { MAXVAL = MAXVAL2; + } NEWRESO = ResoU2 * MAXVAL; if (NEWRESO > ResoU2 && NEWRESO < 10) { @@ -255,7 +289,9 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, MAXVAL = std::abs(Vm1); MAXVAL2 = std::abs(VM1); if (MAXVAL2 > MAXVAL) + { MAXVAL = MAXVAL2; + } NEWRESO = ResoV1 * MAXVAL; if (NEWRESO > ResoV1 && NEWRESO < 10) { @@ -265,7 +301,9 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, MAXVAL = std::abs(Vm2); MAXVAL2 = std::abs(VM2); if (MAXVAL2 > MAXVAL) + { MAXVAL = MAXVAL2; + } NEWRESO = ResoV2 * MAXVAL; if (NEWRESO > ResoV2 && NEWRESO < 10) { @@ -278,13 +316,21 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, pasuv[3] = pasMax * std::abs(VM2 - Vm2); if (ResoU1 > 0.0001 * pasuv[0]) + { ResoU1 = 0.00001 * pasuv[0]; + } if (ResoV1 > 0.0001 * pasuv[1]) + { ResoV1 = 0.00001 * pasuv[1]; + } if (ResoU2 > 0.0001 * pasuv[2]) + { ResoU2 = 0.00001 * pasuv[2]; + } if (ResoV2 > 0.0001 * pasuv[3]) + { ResoV2 = 0.00001 * pasuv[3]; + } if (!Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)) { @@ -360,7 +406,9 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, for (int i = 0; i <= 3; i++) { if (pasuv[i] > 10) + { pasuv[i] = 10; + } pasInit[i] = pasSav[i] = pasuv[i]; } } @@ -539,13 +587,21 @@ IntWalk_PWalking::IntWalk_PWalking(const occ::handle& Caro1, } if (ResoU1 > 0.0001 * pasuv[0]) + { ResoU1 = 0.00001 * pasuv[0]; + } if (ResoV1 > 0.0001 * pasuv[1]) + { ResoV1 = 0.00001 * pasuv[1]; + } if (ResoU2 > 0.0001 * pasuv[2]) + { ResoU2 = 0.00001 * pasuv[2]; + } if (ResoV2 > 0.0001 * pasuv[3]) + { ResoV2 = 0.00001 * pasuv[3]; + } myStepMin[0] = 100.0 * ResoU1; myStepMin[1] = 100.0 * ResoV1; @@ -615,7 +671,9 @@ static double SQDistPointSurface(const gp_Pnt& thePnt, aExtPS.Perform(thePnt, theU0, theV0); if (!aExtPS.IsDone()) + { return RealLast(); + } return aExtPS.SquareDistance(); } @@ -645,7 +703,9 @@ static bool IsTangentExtCheck(const occ::handle& theSurf1, const double aDP = aN1.Dot(aN2), aSQ1 = aN1.SquareMagnitude(), aSQ2 = aN2.SquareMagnitude(); if ((aSQ1 < RealSmall()) || (aSQ2 < RealSmall())) + { return true; // Tangent + } if (aDP * aDP < 0.9998 * aSQ1 * aSQ2) { // cos(ang N1<->N2) < 0.9999 @@ -666,7 +726,9 @@ static bool IsTangentExtCheck(const occ::handle& theSurf1, gp_Pnt aP(theSurf1->Value(aParUS1[i], aParVS1[i])); const double aSqDist = SQDistPointSurface(aP, *theSurf2, theU20, theV20); if (aSqDist > aSQToler) + { return false; + } } for (int i = 0; i < aNbItems; i++) @@ -674,7 +736,9 @@ static bool IsTangentExtCheck(const occ::handle& theSurf1, gp_Pnt aP(theSurf2->Value(aParUS2[i], aParVS2[i])); const double aSqDist = SQDistPointSurface(aP, *theSurf1, theU10, theV10); if (aSqDist > aSQToler) + { return false; + } } return true; @@ -792,7 +856,9 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, previousPoint.Parameters(Param(1), Param(2), Param(3), Param(4)); if (IsTangentExtCheck(Caro1, Caro2, Param(1), Param(2), Param(3), Param(4), myTolTang, pasuv)) + { return; + } AddAPoint(previousPoint); // @@ -920,9 +986,13 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, for (int i = 0; i < 4; i++) { if (std::abs(aNewPnt[i] - aParMin[i]) < aTol[i]) + { aNewPnt[i] = aParMin[i]; + } else if (std::abs(aNewPnt[i] - aParMax[i]) < aTol[i]) + { aNewPnt[i] = aParMax[i]; + } } if (aNewPnt[0] < Um1 || aNewPnt[0] > UM1 || aNewPnt[1] < Vm1 || aNewPnt[1] > VM1 @@ -1123,7 +1193,9 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, } } // aStatus==IntWalk_OK else + { NbPasOKConseq = 0; + } // switch (aStatus) // 007 @@ -1144,7 +1216,9 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, for (int i = 0; i < 4; i++) { if (pasSav[i] > pasInit[i]) + { continue; + } const double aDelta = (pasInit[i] - pasSav[i]) * 0.25; @@ -1310,9 +1384,13 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, { IncKey++; if (IncKey == 5000) + { return; + } else + { continue; + } } else { @@ -1418,9 +1496,13 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, { IncKey++; if (IncKey == 5000) + { return; + } else + { continue; + } } else { @@ -1536,9 +1618,13 @@ void IntWalk_PWalking::Perform(const NCollection_Array1& ParDep, IncKey++; if (IncKey == 5000) + { return; + } else + { continue; + } } else { @@ -1837,7 +1923,9 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th } if (f < 0.1) + { f = 0.1; + } previousPoint.Parameters(Param(1), Param(2), Param(3), Param(4)); @@ -1847,13 +1935,21 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th double dP4 = sensCheminement * pasuv[3] * previousd2.Y() / f; if (theChoixIso == IntImp_UIsoparametricOnCaro1 && std::abs(dP1) < 1.e-7) + { dP1 *= (5. * (double)dIncKey); + } if (theChoixIso == IntImp_VIsoparametricOnCaro1 && std::abs(dP2) < 1.e-7) + { dP2 *= (5. * (double)dIncKey); + } if (theChoixIso == IntImp_UIsoparametricOnCaro2 && std::abs(dP3) < 1.e-7) + { dP3 *= (5. * (double)dIncKey); + } if (theChoixIso == IntImp_VIsoparametricOnCaro2 && std::abs(dP4) < 1.e-7) + { dP4 *= (5. * (double)dIncKey); + } Param(1) += dP1; Param(2) += dP2; @@ -1918,7 +2014,9 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th } if (bDecrease) + { nbIterWithoutAppend--; + } break; } case IntWalk_PointConfondu: { @@ -1968,7 +2066,9 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th if (u1 <= UM1 && u2 <= UM2 && v1 <= VM1 && v2 <= VM2 && u1 >= Um1 && u2 >= Um2 && v1 >= Vm1 && v2 >= Vm2) + { pointisvalid = true; + } if (pointisvalid) { @@ -1992,9 +2092,13 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th { dIncKey++; if (dIncKey == 5000) + { return bOutOfTangentZone; + } else + { bAddPoint = false; + } } } @@ -2019,16 +2123,24 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th // otherwise the same calculations will be // repeated several times if ((u1 > UM1) || (u1 < Um1)) + { pasuv[0] *= 0.5; + } if ((v1 > VM1) || (v1 < Vm1)) + { pasuv[1] *= 0.5; + } if ((u2 > UM2) || (u2 < Um2)) + { pasuv[2] *= 0.5; + } if ((v2 > VM2) || (v2 < Vm2)) + { pasuv[3] *= 0.5; + } } } // end if(!bStop) else @@ -2062,7 +2174,9 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th if (u1 <= UM1 && u2 <= UM2 && v1 <= VM1 && v2 <= VM2 && u1 >= Um1 && u2 >= Um2 && v1 >= Vm1 && v2 >= Vm2) + { pointisvalid = true; + } if (pointisvalid) { @@ -2076,9 +2190,13 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th { dIncKey++; if (dIncKey == 5000) + { return bOutOfTangentZone; + } else + { bAddPoint = false; + } } } @@ -2107,19 +2225,27 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th for (pit = 0; !bExtendLine && (pit < 2); pit++) { if (pit == 0) + { previousPoint.Parameters(u1, v1, u2, v2); + } else { if (aSeqOfNewPoint.Length() > 0) + { aSeqOfNewPoint.Value(aSeqOfNewPoint.Length()).Parameters(u1, v1, u2, v2); + } else + { break; + } } if (((u1 - Um1) < ResoU1) || ((UM1 - u1) < ResoU1) || ((u2 - Um2) < ResoU2) || ((UM2 - u2) < ResoU2) || ((v1 - Vm1) < ResoV1) || ((VM1 - v1) < ResoV1) || ((v2 - Vm2) < ResoV2) || ((VM2 - v2) < ResoV2)) + { bExtendLine = true; + } } if (!bExtendLine) @@ -2149,13 +2275,21 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th int indexofiso = 0; if (theChoixIso == IntImp_UIsoparametricOnCaro1) + { indexofiso = 0; + } if (theChoixIso == IntImp_VIsoparametricOnCaro1) + { indexofiso = 1; + } if (theChoixIso == IntImp_UIsoparametricOnCaro2) + { indexofiso = 2; + } if (theChoixIso == IntImp_VIsoparametricOnCaro2) + { indexofiso = 3; + } int afirstindex = (indexofiso < 2) ? 0 : 2; gp_Vec2d aTangentZoneDir( @@ -2165,7 +2299,9 @@ bool IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric th gp_Dir2d anIsoDir(gp_Dir2d::D::Y); if ((indexofiso == 1) || (indexofiso == 3)) + { anIsoDir = gp_Dir2d(gp_Dir2d::D::X); + } if (aTangentZoneDir.SquareMagnitude() > gp::Resolution()) { @@ -2276,10 +2412,14 @@ bool IntWalk_PWalking::DistanceMinimizeByGradient(const occ::handleGetType() != GeomAbs_BezierSurface && theASurf1->GetType() != GeomAbs_BSplineSurface) + { return true; + } if (theASurf2->GetType() != GeomAbs_BezierSurface && theASurf2->GetType() != GeomAbs_BSplineSurface) + { return true; + } bool aStatus = false; @@ -2413,7 +2553,9 @@ bool IntWalk_PWalking::DistanceMinimizeByExtrema(const occ::handle= aSQDistPrev) + { break; + } aSQDistPrev = aSQDist; theU0 = aU; @@ -2421,7 +2563,9 @@ bool IntWalk_PWalking::DistanceMinimizeByExtrema(const occ::handleValue(aLowBorder[iu], aPars[iv]); if (aPInt.SquareDistance(aP) < aTol2) + { aPars[iu] = aLowBorder[iu]; + } } else if (std::abs(aUppBorder[iu] - aPars[iu]) < aTolU) { aP = aSurfs[k]->Value(aUppBorder[iu], aPars[iv]); if (aPInt.SquareDistance(aP) < aTol2) + { aPars[iu] = aUppBorder[iu]; + } } } aMod = aDV.Magnitude(); @@ -2517,13 +2669,17 @@ bool IntWalk_PWalking::HandleSingleSingularPoint(const occ::handleValue(aPars[iu], aLowBorder[iv]); if (aPInt.SquareDistance(aP) < aTol2) + { aPars[iv] = aLowBorder[iv]; + } } else if (std::abs(aUppBorder[iv] - aPars[iv]) < aTolV) { aP = aSurfs[k]->Value(aPars[iu], aUppBorder[iv]); if (aPInt.SquareDistance(aP) < aTol2) + { aPars[iv] = aUppBorder[iv]; + } } } } @@ -2546,7 +2702,9 @@ bool IntWalk_PWalking::HandleSingleSingularPoint(const occ::handle& aNbIter--; aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, aPnt); if (aStatus && !AdjustToDomain(4, &aPnt(1), &aLowBorder[0], &aUppBorder[0])) + { break; + } aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(aPnt(3), aPnt(4)), aPnt(1), aPnt(2)); if (aStatus && !AdjustToDomain(2, &aPnt(1), &aLowBorder[0], &aUppBorder[0])) + { break; + } aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(aPnt(1), aPnt(2)), aPnt(3), aPnt(4)); if (aStatus && !AdjustToDomain(2, &aPnt(3), &aLowBorder[2], &aUppBorder[2])) + { break; + } } while (!aStatus && (aNbIter > 0)); // Handle singular points. bool aSingularStatus = HandleSingleSingularPoint(theASurf1, theASurf2, aTol, aSingularPnt); if (aSingularStatus) + { aPnt = aSingularPnt; + } if (!aStatus && !aSingularStatus) { @@ -2687,7 +2853,9 @@ bool IntWalk_PWalking::SeekPointOnBoundary(const occ::handle& { aP2.SetXYZ(line->Value(aPInd).Value().XYZ()); if (aP1.SquareDistance(aP2) > Precision::SquareConfusion()) + { break; + } } if (aPInd > aNbPnts) @@ -2743,7 +2911,9 @@ bool IntWalk_PWalking::SeekPointOnBoundary(const occ::handle& { aPPrev.SetXYZ(line->Value(aPInd).Value().XYZ()); if (aPCurr.SquareDistance(aPPrev) > Precision::SquareConfusion()) + { break; + } } if (aPInd < 1) @@ -2801,7 +2971,9 @@ bool IntWalk_PWalking::PutToBoundary(const occ::handle& theAS aTol = std::min(aTol, aV2bLast - aV2bFirst) * 1.0e-3; if (aTol <= 2.0 * aTolMin) + { return hasBeenAdded; + } bool isNeedAdding = false; bool isU1parallel = false, isV1parallel = false; @@ -2991,7 +3163,9 @@ bool IntWalk_PWalking::SeekAdditionalPoints(const occ::handle const double aTol = 1.0e-14; int aNbPoints = line->NbPoints(); if (aNbPoints > theMinNbPoints) + { return true; + } const double aU1bFirst = theASurf1->FirstUParameter(); const double aU1bLast = theASurf1->LastUParameter(); @@ -3022,27 +3196,43 @@ bool IntWalk_PWalking::SeekAdditionalPoints(const occ::handle aPnt(1) = 0.5 * (U1f + U1l); if (aPnt(1) < aU1bFirst) + { aPnt(1) = aU1bFirst; + } if (aPnt(1) > aU1bLast) + { aPnt(1) = aU1bLast; + } aPnt(2) = 0.5 * (V1f + V1l); if (aPnt(2) < aV1bFirst) + { aPnt(2) = aV1bFirst; + } if (aPnt(2) > aV1bLast) + { aPnt(2) = aV1bLast; + } aPnt(3) = 0.5 * (U2f + U2l); if (aPnt(3) < aU2bFirst) + { aPnt(3) = aU2bFirst; + } if (aPnt(3) > aU2bLast) + { aPnt(3) = aU2bLast; + } aPnt(4) = 0.5 * (V2f + V2l); if (aPnt(4) < aV2bFirst) + { aPnt(4) = aV2bFirst; + } if (aPnt(4) > aV2bLast) + { aPnt(4) = aV2bLast; + } bool aStatus = false; int aNbIter = 5; @@ -3089,7 +3279,9 @@ bool IntWalk_PWalking::SeekAdditionalPoints(const occ::handle isPrecise = true; if (++aNbPoints >= theMinNbPoints) + { break; + } } else { @@ -3190,7 +3382,9 @@ void IntWalk_PWalking::RepartirOuDiviser(bool& DejaReparti, } } else + { Arrive = true; + } } else { @@ -3270,9 +3464,13 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop pasuv[3] *= 0.5; STATIC_PRECEDENT_INFLEXION += 3; if (pasuv[0] < ResoU1 && pasuv[1] < ResoV1 && pasuv[2] < ResoU2 && pasuv[3] < ResoV2) + { return IntWalk_ArretSurPointPrecedent; + } else + { return IntWalk_PasTropGrand; + } } else { @@ -3305,9 +3503,13 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop { double CurU, CurV; if (choixIso == IntImp_UIsoparametricOnCaro1 || choixIso == IntImp_VIsoparametricOnCaro1) + { previousPoint.ParametersOnS1(CurU, CurV); + } else + { previousPoint.ParametersOnS2(CurU, CurV); + } gp_Pnt CurPnt = (choixIso == IntImp_UIsoparametricOnCaro1 || choixIso == IntImp_VIsoparametricOnCaro1) ? Adaptor3d_HSurfaceTool::Value(Caro1, CurU, CurV) @@ -3333,9 +3535,13 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop double RefDist = CurPnt.Distance(OffsetPnt); double LocalResol = 0.; if (RefDist > gp::Resolution()) + { LocalResol = pasuv[choixIso] * tolconf / RefDist; + } if (pasuv[choixIso] < 2 * LocalResol) + { pasuv[choixIso] = pasInit[choixIso] = 2 * LocalResol; + } } //////////////////////////////////////// aStatus = IntWalk_PointConfondu; @@ -3373,7 +3579,9 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop double tolArea = 100.0; if (ResoU1 < Precision::PConfusion() || ResoV1 < Precision::PConfusion() || ResoU2 < Precision::PConfusion() || ResoV2 < Precision::PConfusion()) + { tolArea = tolArea * 2.0; + } double Cosi1, CosRef1, Ang1, AngRef1, ResoUV1, Duv1, d1, tolCoeff1; double Cosi2, CosRef2, Ang2, AngRef2, ResoUV2, Duv2, d2, tolCoeff2; @@ -3455,9 +3663,13 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop pasuv[2] *= 0.5; pasuv[3] *= 0.5; if (pasuv[0] < ResoU1 && pasuv[1] < ResoV1 && pasuv[2] < ResoU2 && pasuv[3] < ResoV2) + { return (IntWalk_ArretSurPoint); + } else + { return (IntWalk_PasTropGrand); + } } } //<-OCC431(apo) @@ -3493,35 +3705,59 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop //-- Epsilon << DeltaU. if (pasuv[0] < AbsDu1) + { pasuv[0] = AbsDu1; + } if (pasuv[1] < AbsDv1) + { pasuv[1] = AbsDv1; + } if (pasuv[2] < AbsDu2) + { pasuv[2] = AbsDu2; + } if (pasuv[3] < AbsDv2) + { pasuv[3] = AbsDv2; + } if (pasuv[0] < ResoU1) + { pasuv[0] = ResoU1; + } if (pasuv[1] < ResoV1) + { pasuv[1] = ResoV1; + } if (pasuv[2] < ResoU2) + { pasuv[2] = ResoU2; + } if (pasuv[3] < ResoV2) + { pasuv[3] = ResoV2; + } //-- if(Ratio>10.0 ) { Ratio=10.0; } double R1, R = pasInit[0] / pasuv[0]; R1 = pasInit[1] / pasuv[1]; if (R1 < R) + { R = R1; + } R1 = pasInit[2] / pasuv[2]; if (R1 < R) + { R = R1; + } R1 = pasInit[3] / pasuv[3]; if (R1 < R) + { R = R1; + } if (Ratio > R) + { Ratio = R; + } pasuv[0] = std::min(Ratio * pasuv[0], pasInit[0]); pasuv[1] = std::min(Ratio * pasuv[1], pasInit[1]); pasuv[2] = std::min(Ratio * pasuv[2], pasInit[2]); @@ -3673,7 +3909,9 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIsop pasuv[3] = std::max(myStepMin[3], std::min(std::min(Ratio * AbsDv2, pasuv[3]), pasInit[3])); if (aStatus == IntWalk_OK) + { STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0; + } return aStatus; } @@ -3851,6 +4089,8 @@ bool IntWalk_PWalking::TestArret(const bool DejaReparti, return close; } else + { return false; + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Interference.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Interference.cxx index a8af8067d3..5a065e58a2 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Interference.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Interference.cxx @@ -50,7 +50,9 @@ void Intf_Interference::SelfInterference(const bool Self) bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) { if (myTZones.Length() <= 0) + { return false; + } int lzin = 0; // Index in the list of the zone of interest. int lunp = 0; // Index of the 1st stop point in this zone. int lotp = 0; // Index of the 2nd stop point in this zone. @@ -72,7 +74,9 @@ bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) { Ipz0 = Ipz1 - 1; if (Ipz0 <= 0) + { Ipz0 = npcz; + } Ipz2 = (Ipz1 % npcz) + 1; // Loop on edges of the new TangentZone and search of the @@ -113,10 +117,14 @@ bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) } } if (lotp != 0) + { break; + } } if (lotp != 0) + { break; + } } int Ilc; @@ -126,7 +134,9 @@ bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) { myTZones(lzin).InsertBefore(lotp, LaZone.GetPoint(((Ilc - 1) % nplz) + 1)); if (!same) + { lotp++; + } } } @@ -138,7 +148,9 @@ bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) myTZones(lzin).InsertBefore(lunp, LaZone.GetPoint((((Ilc - 1) % nplz) + 1))); lunp++; if (loop && (((Ilc - 1) % nplz) + 1) == lunl) + { break; + } loop = true; } } @@ -153,7 +165,9 @@ bool Intf_Interference::Insert(const Intf_TangentZone& LaZone) Intf_TangentZone theNew = myTZones(lzin); myTZones.Remove(lzin); if (!Insert(theNew)) + { myTZones.Append(theNew); + } } return Inserted; } @@ -176,7 +190,9 @@ void Intf_Interference::Insert(const Intf_SectionPoint& pdeb, const Intf_Section if (nd == 1) { if (nf > 1) + { SL.Close(); + } Inserted = true; TheLS = ils; Begin = true; @@ -185,7 +201,9 @@ void Intf_Interference::Insert(const Intf_SectionPoint& pdeb, const Intf_Section else if (nd > 1) { if (nf == 1) + { SL.Close(); + } Inserted = true; TheLS = ils; Begin = false; @@ -251,9 +269,13 @@ void Intf_Interference::Insert(const Intf_SectionPoint& pdeb, const Intf_Section else { if (Begin) + { mySLines(TheLS).Prepend(TheBout); + } else + { mySLines(TheLS).Append(TheBout); + } } } } @@ -267,13 +289,17 @@ bool Intf_Interference::Contains(const Intf_SectionPoint& LePnt) const for (int l = 1; l <= mySLines.Length(); l++) { if (mySLines(l).Contains(LePnt)) + { return true; + } } for (int t = 1; t <= myTZones.Length(); t++) { //-- myTZones(t).Dump(2); if (myTZones(t).Contains(LePnt)) + { return true; + } } return false; } @@ -283,17 +309,17 @@ bool Intf_Interference::Contains(const Intf_SectionPoint& LePnt) const //---------------------------------------------------- void Intf_Interference::Dump() const { - std::cout << "Mes SectionPoint :" << std::endl; + std::cout << "Mes SectionPoint :" << '\n'; for (int p = 1; p <= mySPoins.Length(); p++) { mySPoins(p).Dump(2); } - std::cout << "Mes SectionLine :" << std::endl; + std::cout << "Mes SectionLine :" << '\n'; for (int l = 1; l <= mySLines.Length(); l++) { mySLines(l).Dump(2); } - std::cout << "Mes TangentZone :" << std::endl; + std::cout << "Mes TangentZone :" << '\n'; for (int t = 1; t <= myTZones.Length(); t++) { myTZones(t).Dump(2); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_InterferencePolygon2d.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_InterferencePolygon2d.cxx index 3024247259..0fd6a0fac0 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_InterferencePolygon2d.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_InterferencePolygon2d.cxx @@ -57,7 +57,9 @@ Intf_InterferencePolygon2d::Intf_InterferencePolygon2d(const Intf_Polygon2d& Obj { Tolerance = Obje1.DeflectionOverEstimation() + Obje2.DeflectionOverEstimation(); if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } nbso = Obje1.NbSegments(); oClos = Obje1.Closed(); tClos = Obje2.Closed(); @@ -79,7 +81,9 @@ Intf_InterferencePolygon2d::Intf_InterferencePolygon2d(const Intf_Polygon2d& Obj { Tolerance = Obje.DeflectionOverEstimation() * 2; if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } oClos = Obje.Closed(); tClos = oClos; Interference(Obje); @@ -95,7 +99,9 @@ void Intf_InterferencePolygon2d::Perform(const Intf_Polygon2d& Obje1, const Intf { Tolerance = Obje1.DeflectionOverEstimation() + Obje2.DeflectionOverEstimation(); if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } nbso = Obje1.NbSegments(); oClos = Obje1.Closed(); tClos = Obje2.Closed(); @@ -111,7 +117,9 @@ void Intf_InterferencePolygon2d::Perform(const Intf_Polygon2d& Obje) SelfInterference(true); Tolerance = Obje.DeflectionOverEstimation() * 2; if (Tolerance == 0.) + { Tolerance = Epsilon(1000.); + } oClos = Obje.Closed(); tClos = oClos; Interference(Obje); @@ -157,7 +165,9 @@ void Intf_InterferencePolygon2d::Interference(const Intf_Polygon2d& Obje1, bST.Add(p2e); bST.Enlarge(d2); if (!bSO.IsOut(bST)) + { Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e); + } } } } @@ -191,7 +201,9 @@ void Intf_InterferencePolygon2d::Interference(const Intf_Polygon2d& Obje) bST.Add(p2e); bST.Enlarge(d); if (!bSO.IsOut(bST)) + { Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e); + } } } } @@ -226,9 +238,13 @@ void Intf_InterferencePolygon2d::Clean() myTZones(ltz - decal).ParamOnSecond(pr2mi, pr2ma); delta2 = pr2ma - pr2mi; if (delta1 < 1. && delta2 < 1.) + { Only1Seg = true; + } if (delta1 == 0. || delta2 == 0.) + { Only1Seg = true; + } for (lpi = 1; lpi <= myTZones(ltz - decal).NumberOfPoints(); lpi++) { @@ -300,7 +316,9 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, if (SelfIntf) { if (std::abs(iObje1 - iObje2) <= 1) + { return; //-- Ajout du 15 jan 98 + } } int nbpi = 0; @@ -313,10 +331,14 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, // If the length of segment is zero, nothing is done double lgT = std::sqrt(segT * segT); if (lgT <= 0.) + { return; + } double lgO = std::sqrt(segO * segO); if (lgO <= 0.) + { return; + } // Direction of parsing of segments double sigPS = (segO * segT) > 0.0 ? 1.0 : -1.0; @@ -328,7 +350,9 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, double sinTeta = (segO.CrossMagnitude(segT) / lgO) / lgT; double rayIntf = 0.; if (sinTeta > 0.) + { rayIntf = Tolerance / sinTeta; + } // Interference double dbOT = ((BegO.XY() - BegT.XY()) ^ segT) / lgT; @@ -446,7 +470,9 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, edgeSP = true; } else if (nbpi == 0) + { return; + } // If there is no interference it is necessary to take the points segment by segment if (nbpi == 0 && sinTeta > PRCANG) @@ -677,13 +703,17 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, { bool contains = false; for (int i = 1; i <= mySPoins.Length(); i++) + { if (thePi(1).IsEqual(mySPoins(i))) { contains = true; break; } + } if (!contains) + { mySPoins.Append(thePi(1)); + } } else if (iObje2 - iObje1 != 1 && (!oClos || (iObje1 != 1 && iObje2 != nbso))) { @@ -707,9 +737,13 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, for (lpj = 2; lpj <= nbpi; lpj++) { if (parO[lpj] < parO[lmin]) + { lmin = lpj; + } else if (parO[lpj] > parO[lmax]) + { lmax = lpj; + } } TheTZ.PolygonInsert(thePi(lmin)); TheTZ.PolygonInsert(thePi(lmax)); @@ -719,17 +753,26 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, for (lpj = 2; lpj <= nbpi; lpj++) { if (parT[lpj] < parT[ltmin]) + { ltmin = lpj; + } else if (parT[lpj] > parT[ltmax]) + { ltmax = lpj; + } } if (ltmin != lmin && ltmin != lmax) + { TheTZ.PolygonInsert(thePi(ltmin)); + } if (ltmax != lmin && ltmax != lmax) + { TheTZ.PolygonInsert(thePi(ltmax)); + } } if (edgeSP) + { TheTZ.PolygonInsert( Intf_SectionPoint(gp_Pnt2d(BegO.X() + (segO.X() * parOSP), BegO.Y() + (segO.Y() * parOSP)), Intf_EDGE, @@ -739,6 +782,7 @@ void Intf_InterferencePolygon2d::Intersect(const int iObje1, iObje2, parTSP, sinTeta)); + } int nbtz = myTZones.Length(); NCollection_List LIndex; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_SectionLine.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_SectionLine.cxx index d8ce95889d..1372b147a5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_SectionLine.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_SectionLine.cxx @@ -99,8 +99,12 @@ bool Intf_SectionLine::IsClosed() const bool Intf_SectionLine::Contains(const Intf_SectionPoint& ThePI) const { for (int i = 1; i <= myPoints.Length(); i++) + { if (ThePI.IsEqual(myPoints(i))) + { return true; + } + } return false; } @@ -109,9 +113,13 @@ bool Intf_SectionLine::Contains(const Intf_SectionPoint& ThePI) const int Intf_SectionLine::IsEnd(const Intf_SectionPoint& ThePI) const { if (myPoints.First().IsEqual(ThePI)) + { return 1; + } if (myPoints.Last().IsEqual(ThePI)) + { return myPoints.Length(); + } return 0; } @@ -120,10 +128,16 @@ int Intf_SectionLine::IsEnd(const Intf_SectionPoint& ThePI) const bool Intf_SectionLine::IsEqual(const Intf_SectionLine& Other) const { if (myPoints.Length() != Other.myPoints.Length()) + { return false; + } for (int i = 1; i <= myPoints.Length(); i++) + { if (!myPoints(i).IsEqual(Other.myPoints(i))) + { return false; + } + } return true; } @@ -132,12 +146,18 @@ bool Intf_SectionLine::IsEqual(const Intf_SectionLine& Other) const void Intf_SectionLine::Dump(const int Indent) const { for (int id = 0; id < Indent; id++) + { std::cout << " "; + } std::cout << "LS "; if (IsClosed()) - std::cout << "Closed :" << std::endl; + { + std::cout << "Closed :" << '\n'; + } else - std::cout << "Open :" << std::endl; + { + std::cout << "Open :" << '\n'; + } for (int p = 1; p <= myPoints.Length(); p++) { myPoints.Value(p).Dump(Indent + 2); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_TangentZone.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_TangentZone.cxx index 3ca14a56c2..ff603e3cba 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_TangentZone.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_TangentZone.cxx @@ -38,14 +38,22 @@ void Intf_TangentZone::Append(const Intf_SectionPoint& Pi) { Result.Append(Pi); if (ParamOnFirstMin > Pi.ParamOnFirst()) + { ParamOnFirstMin = Pi.ParamOnFirst(); + } if (ParamOnSecondMin > Pi.ParamOnSecond()) + { ParamOnSecondMin = Pi.ParamOnSecond(); + } if (ParamOnFirstMax < Pi.ParamOnFirst()) + { ParamOnFirstMax = Pi.ParamOnFirst(); + } if (ParamOnSecondMax < Pi.ParamOnSecond()) + { ParamOnSecondMax = Pi.ParamOnSecond(); + } } //======================================================================= @@ -168,14 +176,22 @@ void Intf_TangentZone::InsertAfter(const int Index, const Intf_SectionPoint& Pi) { Result.InsertAfter(Index, Pi); if (ParamOnFirstMin > Pi.ParamOnFirst()) + { ParamOnFirstMin = Pi.ParamOnFirst(); + } if (ParamOnSecondMin > Pi.ParamOnSecond()) + { ParamOnSecondMin = Pi.ParamOnSecond(); + } if (ParamOnFirstMax < Pi.ParamOnFirst()) + { ParamOnFirstMax = Pi.ParamOnFirst(); + } if (ParamOnSecondMax < Pi.ParamOnSecond()) + { ParamOnSecondMax = Pi.ParamOnSecond(); + } } //================================================================================================= @@ -184,14 +200,22 @@ void Intf_TangentZone::InsertBefore(const int Index, const Intf_SectionPoint& Pi { Result.InsertBefore(Index, Pi); if (ParamOnFirstMin > Pi.ParamOnFirst()) + { ParamOnFirstMin = Pi.ParamOnFirst(); + } if (ParamOnSecondMin > Pi.ParamOnSecond()) + { ParamOnSecondMin = Pi.ParamOnSecond(); + } if (ParamOnFirstMax < Pi.ParamOnFirst()) + { ParamOnFirstMax = Pi.ParamOnFirst(); + } if (ParamOnSecondMax < Pi.ParamOnSecond()) + { ParamOnSecondMax = Pi.ParamOnSecond(); + } } //======================================================================= @@ -209,12 +233,16 @@ const Intf_SectionPoint& Intf_TangentZone::GetPoint(const int Index) const bool Intf_TangentZone::IsEqual(const Intf_TangentZone& Other) const { if (Result.Length() != Other.Result.Length()) + { return false; + } int i; for (i = 1; i <= Result.Length(); i++) { if (!Result(i).IsEqual(Other.Result(i))) + { return false; + } } return true; } @@ -225,8 +253,12 @@ bool Intf_TangentZone::Contains(const Intf_SectionPoint& ThePI) const { int i; for (i = 1; i <= Result.Length(); i++) + { if (ThePI.IsEqual(Result(i))) + { return true; + } + } return false; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Tool.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Tool.cxx index de3832b918..dfbbcfda69 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Tool.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Intf/Intf_Tool.cxx @@ -63,7 +63,9 @@ void Intf_Tool::Lin2dBox(const gp_Lin2d& L2d, const Bnd_Box2d& domain, Bnd_Box2d return; } else if (domain.IsVoid()) + { return; + } double xmin, xmax, ymin, ymax; double Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0; @@ -77,31 +79,49 @@ void Intf_Tool::Lin2dBox(const gp_Lin2d& L2d, const Bnd_Box2d& domain, Bnd_Box2d if (L2d.Direction().XY().X() > 0.) { if (domain.IsOpenXmin()) + { parmin = -Precision::Infinite(); + } else + { parmin = (xmin - L2d.Location().XY().X()) / L2d.Direction().XY().X(); + } if (domain.IsOpenXmax()) + { parmax = Precision::Infinite(); + } else + { parmax = (xmax - L2d.Location().XY().X()) / L2d.Direction().XY().X(); + } xToSet = true; } else if (L2d.Direction().XY().X() < 0.) { if (domain.IsOpenXmax()) + { parmin = -Precision::Infinite(); + } else + { parmin = (xmax - L2d.Location().XY().X()) / L2d.Direction().XY().X(); + } if (domain.IsOpenXmin()) + { parmax = Precision::Infinite(); + } else + { parmax = (xmin - L2d.Location().XY().X()) / L2d.Direction().XY().X(); + } xToSet = true; } else { // Parallel to axis X if (L2d.Location().XY().X() < xmin || xmax < L2d.Location().XY().X()) + { return; + } Xmin = L2d.Location().XY().X(); Xmax = L2d.Location().XY().X(); xToSet = false; @@ -110,35 +130,53 @@ void Intf_Tool::Lin2dBox(const gp_Lin2d& L2d, const Bnd_Box2d& domain, Bnd_Box2d if (L2d.Direction().XY().Y() > 0.) { if (domain.IsOpenYmin()) + { parcur = -Precision::Infinite(); + } else + { parcur = (ymin - L2d.Location().XY().Y()) / L2d.Direction().XY().Y(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenYmax()) + { parcur = Precision::Infinite(); + } else + { parcur = (ymax - L2d.Location().XY().Y()) / L2d.Direction().XY().Y(); + } parmax = std::min(parmax, parcur); yToSet = true; } else if (L2d.Direction().XY().Y() < 0.) { if (domain.IsOpenYmax()) + { parcur = -Precision::Infinite(); + } else + { parcur = (ymax - L2d.Location().XY().Y()) / L2d.Direction().XY().Y(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenYmin()) + { parcur = Precision::Infinite(); + } else + { parcur = (ymin - L2d.Location().XY().Y()) / L2d.Direction().XY().Y(); + } parmax = std::min(parmax, parcur); yToSet = true; } else { // Parallel to axis Y if (L2d.Location().XY().Y() < ymin || ymax < L2d.Location().XY().Y()) + { return; + } Ymin = L2d.Location().XY().Y(); Ymax = L2d.Location().XY().Y(); yToSet = false; @@ -182,7 +220,9 @@ void Intf_Tool::Hypr2dBox(const gp_Hypr2d& theHypr2d, const Bnd_Box2d& domain, B return; } else if (domain.IsVoid()) + { return; + } int nbPi = Inters2d(theHypr2d, domain); @@ -208,8 +248,12 @@ void Intf_Tool::Hypr2dBox(const gp_Hypr2d& theHypr2d, const Bnd_Box2d& domain, B { npk = npi; for (npj = npi + 1; npj < nbPi; npj++) + { if (parint[npj] < parint[npk]) + { npk = npj; + } + } if (npk != npi) { parmin = parint[npk]; @@ -270,15 +314,23 @@ void Intf_Tool::Hypr2dBox(const gp_Hypr2d& theHypr2d, const Bnd_Box2d& domain, B int ipmin; if (beginOnCurve[nbSeg - 1] < -10.) + { ipmin = -10; + } else + { ipmin = (int)(beginOnCurve[nbSeg - 1]); + } int ipmax; if (endOnCurve[nbSeg - 1] > 10.) + { ipmax = 10; + } else + { ipmax = (int)(endOnCurve[nbSeg - 1]); + } // int ipmin=Max((int)(beginOnCurve[nbSeg-1]), // -10); @@ -291,15 +343,21 @@ void Intf_Tool::Hypr2dBox(const gp_Hypr2d& theHypr2d, const Bnd_Box2d& domain, B { boxHypr2d.Add(ElCLib::Value(double(ip) / 10., theHypr2d)); if (std::abs(ip) <= 10) + { pas = 1; + } else + { pas = 10; + } } } } } if (!out && nbSeg > 0) + { endOnCurve[nbSeg - 1] = Precision::Infinite(); + } } else if (!domain.IsOut(ElCLib::Value(0., theHypr2d))) { @@ -431,7 +489,9 @@ void Intf_Tool::Parab2dBox(const gp_Parab2d& theParab2d, return; } else if (domain.IsVoid()) + { return; + } int nbPi = Inters2d(theParab2d, domain); @@ -457,8 +517,12 @@ void Intf_Tool::Parab2dBox(const gp_Parab2d& theParab2d, { npk = npi; for (npj = npi + 1; npj < nbPi; npj++) + { if (parint[npj] < parint[npk]) + { npk = npj; + } + } if (npk != npi) { parmin = parint[npk]; @@ -519,15 +583,23 @@ void Intf_Tool::Parab2dBox(const gp_Parab2d& theParab2d, int ipmin; if (beginOnCurve[nbSeg - 1] < -10.) + { ipmin = -10; + } else + { ipmin = (int)(beginOnCurve[nbSeg - 1]); + } int ipmax; if (endOnCurve[nbSeg - 1] > 10.) + { ipmax = 10; + } else + { ipmax = (int)(endOnCurve[nbSeg - 1]); + } // int ipmin=Max((int)(beginOnCurve[nbSeg-1]), // -10); @@ -540,15 +612,21 @@ void Intf_Tool::Parab2dBox(const gp_Parab2d& theParab2d, { boxParab2d.Add(ElCLib::Value(double(ip) / 10., theParab2d)); if (std::abs(ip) <= 10) + { pas = 1; + } else + { pas = 10; + } } } } } if (!out && nbSeg > 0) + { endOnCurve[nbSeg - 1] = Precision::Infinite(); + } } else if (!domain.IsOut(ElCLib::Value(0., theParab2d))) { @@ -679,7 +757,9 @@ void Intf_Tool::LinBox(const gp_Lin& L, const Bnd_Box& domain, Bnd_Box& boxLin) return; } else if (domain.IsVoid()) + { return; + } double xmin, xmax, ymin, ymax, zmin, zmax; double Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0; @@ -693,31 +773,49 @@ void Intf_Tool::LinBox(const gp_Lin& L, const Bnd_Box& domain, Bnd_Box& boxLin) if (L.Direction().XYZ().X() > 0.) { if (domain.IsOpenXmin()) + { parmin = -Precision::Infinite(); + } else + { parmin = (xmin - L.Location().XYZ().X()) / L.Direction().XYZ().X(); + } if (domain.IsOpenXmax()) + { parmax = Precision::Infinite(); + } else + { parmax = (xmax - L.Location().XYZ().X()) / L.Direction().XYZ().X(); + } xToSet = true; } else if (L.Direction().XYZ().X() < 0.) { if (domain.IsOpenXmax()) + { parmin = -Precision::Infinite(); + } else + { parmin = (xmax - L.Location().XYZ().X()) / L.Direction().XYZ().X(); + } if (domain.IsOpenXmin()) + { parmax = Precision::Infinite(); + } else + { parmax = (xmin - L.Location().XYZ().X()) / L.Direction().XYZ().X(); + } xToSet = true; } else { // Perpendiculaire a l axe X if (L.Location().XYZ().X() < xmin || xmax < L.Location().XYZ().X()) + { return; + } Xmin = L.Location().XYZ().X(); Xmax = L.Location().XYZ().X(); xToSet = false; @@ -726,35 +824,53 @@ void Intf_Tool::LinBox(const gp_Lin& L, const Bnd_Box& domain, Bnd_Box& boxLin) if (L.Direction().XYZ().Y() > 0.) { if (domain.IsOpenYmin()) + { parcur = -Precision::Infinite(); + } else + { parcur = (ymin - L.Location().XYZ().Y()) / L.Direction().XYZ().Y(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenYmax()) + { parcur = Precision::Infinite(); + } else + { parcur = (ymax - L.Location().XYZ().Y()) / L.Direction().XYZ().Y(); + } parmax = std::min(parmax, parcur); yToSet = true; } else if (L.Direction().XYZ().Y() < 0.) { if (domain.IsOpenYmax()) + { parcur = -Precision::Infinite(); + } else + { parcur = (ymax - L.Location().XYZ().Y()) / L.Direction().XYZ().Y(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenYmin()) + { parcur = Precision::Infinite(); + } else + { parcur = (ymin - L.Location().XYZ().Y()) / L.Direction().XYZ().Y(); + } parmax = std::min(parmax, parcur); yToSet = true; } else { // Perpendiculaire a l axe Y if (L.Location().XYZ().Y() < ymin || ymax < L.Location().XYZ().Y()) + { return; + } Ymin = L.Location().XYZ().Y(); Ymax = L.Location().XYZ().Y(); yToSet = false; @@ -763,35 +879,53 @@ void Intf_Tool::LinBox(const gp_Lin& L, const Bnd_Box& domain, Bnd_Box& boxLin) if (L.Direction().XYZ().Z() > 0.) { if (domain.IsOpenZmin()) + { parcur = -Precision::Infinite(); + } else + { parcur = (zmin - L.Location().XYZ().Z()) / L.Direction().XYZ().Z(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenZmax()) + { parcur = Precision::Infinite(); + } else + { parcur = (zmax - L.Location().XYZ().Z()) / L.Direction().XYZ().Z(); + } parmax = std::min(parmax, parcur); zToSet = true; } else if (L.Direction().XYZ().Z() < 0.) { if (domain.IsOpenZmax()) + { parcur = -Precision::Infinite(); + } else + { parcur = (zmax - L.Location().XYZ().Z()) / L.Direction().XYZ().Z(); + } parmin = std::max(parmin, parcur); if (domain.IsOpenZmin()) + { parcur = Precision::Infinite(); + } else + { parcur = (zmin - L.Location().XYZ().Z()) / L.Direction().XYZ().Z(); + } parmax = std::min(parmax, parcur); zToSet = true; } else { // Perpendicular to axis Z if (L.Location().XYZ().Z() < zmin || zmax < L.Location().XYZ().Z()) + { return; + } Zmin = L.Location().XYZ().Z(); Zmax = L.Location().XYZ().Z(); zToSet = false; @@ -1365,7 +1499,9 @@ void Intf_Tool::ParabBox(const gp_Parab& theParab, const Bnd_Box& domain, Bnd_Bo return; } else if (domain.IsVoid()) + { return; + } int nbPi = Inters3d(theParab, domain); @@ -1443,15 +1579,23 @@ void Intf_Tool::ParabBox(const gp_Parab& theParab, const Bnd_Box& domain, Bnd_Bo int ipmin; if (beginOnCurve[nbSeg - 1] < -10.) + { ipmin = -10; + } else + { ipmin = (int)(beginOnCurve[nbSeg - 1]); + } int ipmax; if (endOnCurve[nbSeg - 1] > 10.) + { ipmax = 10; + } else + { ipmax = (int)(endOnCurve[nbSeg - 1]); + } ipmin = ipmin * 10 + 1; ipmax = ipmax * 10 - 1; @@ -1460,15 +1604,21 @@ void Intf_Tool::ParabBox(const gp_Parab& theParab, const Bnd_Box& domain, Bnd_Bo { boxParab.Add(ElCLib::Value(double(ip) / 10., theParab)); if (std::abs(ip) <= 10) + { pas = 1; + } else + { pas = 10; + } } } } } if (!out && nbSeg > 0) + { endOnCurve[nbSeg - 1] = Precision::Infinite(); + } } else if (!domain.IsOut(ElCLib::Value(0., theParab))) { diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law.cxx index e24e49492d..168ba06c7e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law.cxx @@ -90,7 +90,9 @@ static double eval1(const double p, const bool nulr) { if ((nulr && p >= piv) || (!nulr && p <= piv)) + { return 0.; + } else if (nulr) { double a = piv - first; @@ -169,9 +171,13 @@ occ::handle Law::Reparametrize(const Adaptor3d_Curve& Curve, int i; double DDFirst = DFirst, DDLast = DLast; if (HasDF && Rev) + { DDFirst = -DFirst; + } if (HasDL && Rev) + { DDLast = -DLast; + } NCollection_Array1 cumdist(1, 2 * NbPoints); NCollection_Array1 ucourbe(1, 2 * NbPoints); gp_Pnt P1, P2; @@ -200,9 +206,13 @@ occ::handle Law::Reparametrize(const Adaptor3d_Curve& Curve, P1 = P2; } if (Rev) + { ucourbe(2 * NbPoints) = U1; + } else + { ucourbe(2 * NbPoints) = U2; + } occ::handle> point = new NCollection_HArray1(1, NbPoints); occ::handle> param = new NCollection_HArray1(1, NbPoints); @@ -221,7 +231,9 @@ occ::handle Law::Reparametrize(const Adaptor3d_Curve& Curve, for (i = 2; i < NbPoints; i++) { while (cumdist(Index) < Corde) + { Index++; + } Alpha = (Corde - cumdist(Index - 1)) / (cumdist(Index) - cumdist(Index - 1)); U = ucourbe(Index - 1) + Alpha * (ucourbe(Index) - ucourbe(Index - 1)); @@ -249,7 +261,9 @@ occ::handle Law::Reparametrize(const Adaptor3d_Curve& Curve, } inter.Perform(); if (!inter.IsDone()) + { throw Standard_Failure("Law::Reparametrize echec interpolation"); + } occ::handle bs = inter.Curve(); return bs; } @@ -266,11 +280,17 @@ static double eval2(const double p, const occ::handle& bs2) { if (hasfirst && p < mil) + { return bs1->Value(p); + } else if (haslast && p > mil) + { return bs2->Value(p); + } else + { return 1.; + } } occ::handle Law::Scale(const double First, diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpFunc.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpFunc.cxx index f5eb421a5a..62d007fccf 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpFunc.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpFunc.cxx @@ -76,13 +76,21 @@ int Law_BSpFunc::NbIntervals(const GeomAbs_Shape S) const case GeomAbs_C3: case GeomAbs_CN: { if (S == GeomAbs_C1) + { Cont = 1; + } else if (S == GeomAbs_C2) + { Cont = 2; + } else if (S == GeomAbs_C3) + { Cont = 3; + } else + { Cont = curv->Degree(); + } Law_BSplineKnotSplitting Convector(curv, Cont); int NbInt = Convector.NbSplits() - 1; NCollection_Array1 Inter(1, NbInt + 1); @@ -115,14 +123,22 @@ int Law_BSpFunc::NbIntervals(const GeomAbs_Shape S) const Index2, newLast); if (std::abs(newFirst - TK(Index1 + 1)) < Precision::PConfusion()) + { Index1++; + } if (newLast - TK(Index2) > Precision::PConfusion()) + { Index2++; + } myNbIntervals = 1; for (int i = 1; i <= NbInt; i++) + { if (Inter(i) > Index1 && Inter(i) < Index2) + { myNbIntervals++; + } + } } break; } @@ -153,13 +169,21 @@ void Law_BSpFunc::Intervals(NCollection_Array1& T, const GeomAbs_Shape S case GeomAbs_C3: case GeomAbs_CN: { if (S == GeomAbs_C1) + { Cont = 1; + } else if (S == GeomAbs_C2) + { Cont = 2; + } else if (S == GeomAbs_C3) + { Cont = 3; + } else + { Cont = curv->Degree(); + } Law_BSplineKnotSplitting Convector(curv, Cont); int NbInt = Convector.NbSplits() - 1; NCollection_Array1 Inter(1, NbInt + 1); @@ -192,9 +216,13 @@ void Law_BSpFunc::Intervals(NCollection_Array1& T, const GeomAbs_Shape S Index2, newLast); if (std::abs(newFirst - TK(Index1 + 1)) < Precision::PConfusion()) + { Index1++; + } if (newLast - TK(Index2) > Precision::PConfusion()) + { Index2++; + } Inter(1) = Index1; myNbIntervals = 1; @@ -231,17 +259,25 @@ double Law_BSpFunc::Value(const double X) { curv->LocateU(first, PosTol, Ideb, Ifin); if (Ideb < 1) + { Ideb = 1; + } if (Ideb >= Ifin) + { Ifin = Ideb + 1; + } } if (X == last) { curv->LocateU(last, PosTol, Ideb, Ifin); if (Ifin > curv->NbKnots()) + { Ifin = curv->NbKnots(); + } if (Ideb >= Ifin) + { Ideb = Ifin - 1; + } } return curv->LocalValue(X, Ideb, Ifin); } @@ -262,17 +298,25 @@ void Law_BSpFunc::D1(const double X, double& F, double& D) { curv->LocateU(first, PosTol, Ideb, Ifin); if (Ideb < 1) + { Ideb = 1; + } if (Ideb >= Ifin) + { Ifin = Ideb + 1; + } } if (X == last) { curv->LocateU(last, PosTol, Ideb, Ifin); if (Ifin > curv->NbKnots()) + { Ifin = curv->NbKnots(); + } if (Ideb >= Ifin) + { Ideb = Ifin - 1; + } } curv->LocalD1(X, Ideb, Ifin, F, D); } @@ -293,17 +337,25 @@ void Law_BSpFunc::D2(const double X, double& F, double& D, double& D2) { curv->LocateU(first, PosTol, Ideb, Ifin); if (Ideb < 1) + { Ideb = 1; + } if (Ideb >= Ifin) + { Ifin = Ideb + 1; + } } if (X == last) { curv->LocateU(last, PosTol, Ideb, Ifin); if (Ifin > curv->NbKnots()) + { Ifin = curv->NbKnots(); + } if (Ideb >= Ifin) + { Ideb = Ifin - 1; + } } curv->LocalD2(X, Ideb, Ifin, F, D, D2); } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpline.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpline.cxx index bc899b1c57..fbdf7f2e6a 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpline.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSpline.cxx @@ -89,9 +89,13 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() < 2) + { throw Standard_ConstructionError(); + } if (CKnots.Length() != CMults.Length()) + { throw Standard_ConstructionError(); + } for (int I = CKnots.Lower(); I < CKnots.Upper(); I++) { @@ -102,7 +106,9 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() != BSplCLib::NbPoles(Degree, Periodic, CMults)) + { throw Standard_ConstructionError(); + } } //================================================================================================= @@ -133,7 +139,9 @@ static void KnotAnalysis(const int Degree, else { if (CMults(1) == 1) + { KnotForm = GeomAbs_Uniform; + } } break; case BSplCLib_QuasiConstant: @@ -141,9 +149,13 @@ static void KnotAnalysis(const int Degree, { double M = CMults(2); if (M == Degree) + { KnotForm = GeomAbs_PiecewiseBezier; + } else if (M == 1) + { KnotForm = GeomAbs_QuasiUniform; + } } break; } @@ -176,7 +188,9 @@ static bool Rational(const NCollection_Array1& W) { rat = std::abs(W(i) - W(i + 1)) > gp::Resolution(); if (rat) + { break; + } } return rat; } @@ -187,14 +201,18 @@ occ::handle Law_BSpline::Copy() const { occ::handle C; if (IsRational()) + { C = new Law_BSpline(poles->Array1(), weights->Array1(), knots->Array1(), mults->Array1(), deg, periodic); + } else + { C = new Law_BSpline(poles->Array1(), knots->Array1(), mults->Array1(), deg, periodic); + } return C; } @@ -246,13 +264,17 @@ Law_BSpline::Law_BSpline(const NCollection_Array1& Poles, CheckCurveData(Poles, Knots, Mults, Degree, Periodic); if (Weights.Length() != Poles.Length()) + { throw Standard_ConstructionError("Law_BSpline"); + } int i; for (i = Weights.Lower(); i <= Weights.Upper(); i++) { if (Weights(i) <= gp::Resolution()) + { throw Standard_ConstructionError("Law_BSpline"); + } } // check really rational @@ -289,7 +311,9 @@ int Law_BSpline::MaxDegree() void Law_BSpline::IncreaseDegree(const int Degree) { if (Degree == deg) + { return; + } if (Degree < deg || Degree > Law_BSpline::MaxDegree()) { @@ -372,7 +396,9 @@ void Law_BSpline::IncreaseMultiplicity(const int I1, const int I2, const int M) NCollection_Array1 m(I1, I2); int i; for (i = I1; i <= I2; i++) + { m(i) = M - mults->Value(i); + } InsertKnots(k, m, Epsilon(1.)); } @@ -421,10 +447,14 @@ void Law_BSpline::InsertKnots(const NCollection_Array1& Knots, nbknots, Epsilon, Add)) + { throw Standard_ConstructionError("Law_BSpline::InsertKnots"); + } if (nbpoles == poles->Length()) + { return; + } occ::handle> npoles = new NCollection_HArray1(1, nbpoles); occ::handle> nknots = knots; @@ -486,7 +516,9 @@ void Law_BSpline::InsertKnots(const NCollection_Array1& Knots, bool Law_BSpline::RemoveKnot(const int Index, const int M, const double Tolerance) { if (M < 0) + { return true; + } int I1 = FirstUKnotIndex(); int I2 = LastUKnotIndex(); @@ -503,7 +535,9 @@ bool Law_BSpline::RemoveKnot(const int Index, const int M, const double Toleranc const NCollection_Array1& oldpoles = poles->Array1(); int step = mults->Value(Index) - M; if (step <= 0) + { return true; + } occ::handle> npoles = new NCollection_HArray1(1, oldpoles.Length() - step); @@ -536,7 +570,9 @@ bool Law_BSpline::RemoveKnot(const int Index, const int M, const double Toleranc nknots->ChangeArray1(), nmults->ChangeArray1(), Tolerance)) + { return false; + } GetPoles(adimnpol, npoles->ChangeArray1(), nweights->ChangeArray1()); weights = nweights; } @@ -554,7 +590,9 @@ bool Law_BSpline::RemoveKnot(const int Index, const int M, const double Toleranc nknots->ChangeArray1(), nmults->ChangeArray1(), Tolerance)) + { return false; + } } poles = npoles; @@ -576,12 +614,18 @@ void Law_BSpline::Reverse() BSplCLib::Reverse(mults->ChangeArray1()); int last; if (periodic) + { last = flatknots->Upper() - deg - 1; + } else + { last = poles->Upper(); + } BSplCLib::Reverse(poles->ChangeArray1(), last); if (rational) + { BSplCLib::Reverse(weights->ChangeArray1(), last); + } UpdateKnots(); } @@ -645,7 +689,9 @@ void Law_BSpline::Segment(const double U1, const double U2) index0, U); if (std::abs(knots->Value(index0 + 1) - U) < Eps) + { index0++; + } SetOrigin(index0); SetNotPeriodic(); } @@ -673,7 +719,9 @@ void Law_BSpline::Segment(const double U1, const double U2) index2, U); if (std::abs(knots->Value(index2 + 1) - U) < Eps) + { index2++; + } int nbknots = index2 - index1 + 1; @@ -726,7 +774,9 @@ void Law_BSpline::Segment(const double U1, const double U2) mults = nmults; poles = npoles; if (rational) + { weights = nweights; + } UpdateKnots(); } @@ -736,12 +786,16 @@ void Law_BSpline::Segment(const double U1, const double U2) void Law_BSpline::SetKnot(const int Index, const double K) { if (Index < 1 || Index > knots->Length()) + { throw Standard_OutOfRange(); + } double DK = std::abs(Epsilon(K)); if (Index == 1) { if (K >= knots->Value(2) - DK) + { throw Standard_ConstructionError(); + } } else if (Index == knots->Length()) { @@ -858,7 +912,9 @@ void Law_BSpline::SetOrigin(const int Index) int index = 1; for (i = first + 1; i <= Index; i++) + { index += mults->Value(i); + } // set the poles and weights occ::handle> npoles = new NCollection_HArray1(1, nbpoles); @@ -902,7 +958,9 @@ void Law_BSpline::SetOrigin(const int Index) knots = nknots; mults = nmults; if (rational) + { weights = nweights; + } UpdateKnots(); } @@ -968,7 +1026,9 @@ void Law_BSpline::SetNotPeriodic() void Law_BSpline::SetPole(const int Index, const double P) { if (Index < 1 || Index > poles->Length()) + { throw Standard_OutOfRange(); + } poles->SetValue(Index, P); } @@ -985,17 +1045,23 @@ void Law_BSpline::SetPole(const int Index, const double P, const double W) void Law_BSpline::SetWeight(const int Index, const double W) { if (Index < 1 || Index > poles->Length()) + { throw Standard_OutOfRange(); + } if (W <= gp::Resolution()) + { throw Standard_ConstructionError(); + } bool rat = IsRational() || (std::abs(W - 1.) > gp::Resolution()); if (rat) { if (rat && !IsRational()) + { weights = new NCollection_HArray1(1, poles->Length(), 1.); + } weights->SetValue(Index, W); @@ -1003,7 +1069,9 @@ void Law_BSpline::SetWeight(const int Index, const double W) { rat = Rational(weights->Array1()); if (!rat) + { weights.Nullify(); + } } rational = !weights.IsNull(); @@ -1038,7 +1106,9 @@ void Law_BSpline::UpdateKnots() } if (MaxKnotMult == 0) + { smooth = GeomAbs_CN; + } else { switch (deg - MaxKnotMult) @@ -1249,9 +1319,13 @@ double Law_BSpline::DN(const double U, const int N) const double Law_BSpline::EndPoint() const { if (mults->Value(knots->Upper()) == deg + 1) + { return poles->Value(poles->Upper()); + } else + { return Value(LastParameter()); + } } //================================================================================================= @@ -1259,9 +1333,13 @@ double Law_BSpline::EndPoint() const int Law_BSpline::FirstUKnotIndex() const { if (periodic) + { return 1; + } else + { return BSplCLib::FirstUKnotIndex(deg, mults->Array1()); + } } //================================================================================================= @@ -1307,9 +1385,13 @@ void Law_BSpline::KnotSequence(NCollection_Array1& K) const int Law_BSpline::LastUKnotIndex() const { if (periodic) + { return knots->Length(); + } else + { return BSplCLib::LastUKnotIndex(deg, mults->Array1()); + } } //================================================================================================= @@ -1503,9 +1585,13 @@ void Law_BSpline::Poles(NCollection_Array1& P) const double Law_BSpline::StartPoint() const { if (mults->Value(1) == deg + 1) + { return poles->Value(1); + } else + { return Value(FirstParameter()); + } } //================================================================================================= @@ -1514,9 +1600,13 @@ double Law_BSpline::Weight(const int Index) const { Standard_OutOfRange_Raise_if(Index < 1 || Index > poles->Length(), "Law_BSpline::Weight"); if (IsRational()) + { return weights->Value(Index); + } else + { return 1.; + } } //================================================================================================= @@ -1525,12 +1615,16 @@ void Law_BSpline::Weights(NCollection_Array1& W) const { Standard_DimensionError_Raise_if(W.Length() != poles->Length(), "Law_BSpline::Weights"); if (IsRational()) + { W = weights->Array1(); + } else { int i; for (i = W.Lower(); i <= W.Upper(); i++) + { W(i) = 1.; + } } } @@ -1552,9 +1646,13 @@ void Law_BSpline::LocateU(const double U, double NewU = U; occ::handle> TheKnots; if (WithKnotRepetition) + { TheKnots = flatknots; + } else + { TheKnots = knots; + } PeriodicNormalization(NewU); // Attention a la periode diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSplineKnotSplitting.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSplineKnotSplitting.cxx index f6859ef613..da3bc5aaf7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSplineKnotSplitting.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_BSplineKnotSplitting.cxx @@ -26,7 +26,9 @@ Law_BSplineKnotSplitting::Law_BSplineKnotSplitting(const occ::handleFirstUKnotIndex(); int LastIndex = BasisCurve->LastUKnotIndex(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Composite.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Composite.cxx index c912f4967b..6aaf86f9b5 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Composite.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Composite.cxx @@ -190,7 +190,9 @@ void Law_Composite::Prepare(double& W) curfunc->Bounds(f, l); if (f <= Wtest && Wtest <= l) + { return; + } if (W <= first) { curfunc = funclist.First(); @@ -207,7 +209,9 @@ void Law_Composite::Prepare(double& W) curfunc = It.Value(); curfunc->Bounds(f, l); if (f <= Wtest && Wtest <= l) + { return; + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpol.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpol.cxx index 9f9e4034c0..bb25308580 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpol.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpol.cxx @@ -41,9 +41,13 @@ void Law_Interpol::Set(const NCollection_Array1& ParAndRad, const bool occ::handle> par = new NCollection_HArray1(1, nbp); occ::handle> rad; if (Periodic) + { rad = new NCollection_HArray1(1, nbp - 1); + } else + { rad = new NCollection_HArray1(1, nbp); + } double x, y; int i; for (i = 1; i <= nbp; i++) @@ -51,7 +55,9 @@ void Law_Interpol::Set(const NCollection_Array1& ParAndRad, const bool ParAndRad(l + i - 1).Coord(x, y); par->SetValue(i, x); if (!Periodic || i != nbp) + { rad->SetValue(i, y); + } } Law_Interpolate inter(rad, par, Periodic, Precision::Confusion()); inter.Perform(); @@ -73,9 +79,13 @@ void Law_Interpol::SetInRelative(const NCollection_Array1& ParAndRad, occ::handle> par = new NCollection_HArray1(1, nbp); occ::handle> rad; if (Periodic) + { rad = new NCollection_HArray1(1, nbp - 1); + } else + { rad = new NCollection_HArray1(1, nbp); + } double x, y; int i; for (i = 1; i <= nbp; i++) @@ -83,7 +93,9 @@ void Law_Interpol::SetInRelative(const NCollection_Array1& ParAndRad, ParAndRad(l + i - 1).Coord(x, y); par->SetValue(i, (Uf * (x - wd) + Ud * (wf - x)) / (wf - wd)); if (!Periodic || i != nbp) + { rad->SetValue(i, y); + } } Law_Interpolate inter(rad, par, Periodic, Precision::Confusion()); inter.Perform(); @@ -105,9 +117,13 @@ void Law_Interpol::Set(const NCollection_Array1& ParAndRad, occ::handle> par = new NCollection_HArray1(1, nbp); occ::handle> rad; if (Periodic) + { rad = new NCollection_HArray1(1, nbp - 1); + } else + { rad = new NCollection_HArray1(1, nbp); + } double x, y; int i; for (i = 1; i <= nbp; i++) @@ -115,7 +131,9 @@ void Law_Interpol::Set(const NCollection_Array1& ParAndRad, ParAndRad(l + i - 1).Coord(x, y); par->SetValue(i, x); if (!Periodic || i != nbp) + { rad->SetValue(i, y); + } } Law_Interpolate inter(rad, par, Periodic, Precision::Confusion()); inter.Load(Dd, Df); @@ -138,9 +156,13 @@ void Law_Interpol::SetInRelative(const NCollection_Array1& ParAndRad, occ::handle> par = new NCollection_HArray1(1, nbp); occ::handle> rad; if (Periodic) + { rad = new NCollection_HArray1(1, nbp - 1); + } else + { rad = new NCollection_HArray1(1, nbp); + } double x, y; int i; for (i = 1; i <= nbp; i++) @@ -148,7 +170,9 @@ void Law_Interpol::SetInRelative(const NCollection_Array1& ParAndRad, ParAndRad(l + i - 1).Coord(x, y); par->SetValue(i, (Uf * (x - wd) + Ud * (wf - x)) / (wf - wd)); if (!Periodic || i != nbp) + { rad->SetValue(i, y); + } } Law_Interpolate inter(rad, par, Periodic, Precision::Confusion()); inter.Load(Dd, Df); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpolate.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpolate.cxx index 9c19adcf35..94767fb043 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpolate.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Law/Law_Interpolate.cxx @@ -587,7 +587,9 @@ void Law_Interpolate::PerformNonPeriodic() const occ::handle& Law_Interpolate::Curve() const { if (!myIsDone) + { throw StdFail_NotDone(" "); + } return myCurve; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis.cxx b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis.cxx index b4ed9874a3..172bdd1223 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis.cxx @@ -24,109 +24,151 @@ void LocalAnalysis::Dump(const LocalAnalysis_SurfaceContinuity& surfconti, Stand { if (!surfconti.IsDone()) { - o << "Problem in the computation " << std::endl; + o << "Problem in the computation " << '\n'; if (surfconti.StatusError() == LocalAnalysis_NullFirstDerivative) - o << "one of the first derivatives is null" << std::endl; + { + o << "one of the first derivatives is null" << '\n'; + } else if (surfconti.StatusError() == LocalAnalysis_NullSecondDerivative) - o << "one of the second derivatives is null" << std::endl; + { + o << "one of the second derivatives is null" << '\n'; + } else if (surfconti.StatusError() == LocalAnalysis_NormalNotDefined) - o << "one (or both) normal is undefined" << std::endl; + { + o << "one (or both) normal is undefined" << '\n'; + } else if (surfconti.StatusError() == LocalAnalysis_CurvatureNotDefined) - o << "one of the mean curvatures is undefined" << std::endl; + { + o << "one of the mean curvatures is undefined" << '\n'; + } } else + { switch (surfconti.ContinuityStatus()) { case GeomAbs_C0: { if (surfconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : No C0 " << std::endl; - o << " C0Value = " << surfconti.C0Value() << std::endl; + { + o << " Continuity Status : No C0 " << '\n'; + } + o << " C0Value = " << surfconti.C0Value() << '\n'; } break; case GeomAbs_C1: { if (surfconti.IsC1()) - o << " Continuity Status : C1 " << std::endl; + { + o << " Continuity Status : C1 " << '\n'; + } else { if (surfconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : NoC0 " << std::endl; + { + o << " Continuity Status : NoC0 " << '\n'; + } } - o << " C0Value = " << surfconti.C0Value() << std::endl; - o << " C1UAngle = " << surfconti.C1UAngle() << std::endl; - o << " C1URatio = " << surfconti.C1URatio() << std::endl; - o << " C1VAngle = " << surfconti.C1VAngle() << std::endl; - o << " C1VRatio = " << surfconti.C1VRatio() << std::endl; + o << " C0Value = " << surfconti.C0Value() << '\n'; + o << " C1UAngle = " << surfconti.C1UAngle() << '\n'; + o << " C1URatio = " << surfconti.C1URatio() << '\n'; + o << " C1VAngle = " << surfconti.C1VAngle() << '\n'; + o << " C1VRatio = " << surfconti.C1VRatio() << '\n'; } break; case GeomAbs_C2: { if (surfconti.IsC2()) - o << " Continuity Status : C2 " << std::endl; + { + o << " Continuity Status : C2 " << '\n'; + } else { if (surfconti.IsC1()) - o << " Continuity Status : C1 " << std::endl; + { + o << " Continuity Status : C1 " << '\n'; + } else { if (surfconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : NoC0 " << std::endl; + { + o << " Continuity Status : NoC0 " << '\n'; + } } } - o << " C0Value = " << surfconti.C0Value() << std::endl; - o << " C1UAngle = " << surfconti.C1UAngle() << std::endl; - o << " C1VAngle = " << surfconti.C1VAngle() << std::endl; - o << " C2UAngle = " << surfconti.C2UAngle() << std::endl; - o << " C2VAngle = " << surfconti.C2VAngle() << std::endl; - o << " C1URatio = " << surfconti.C1URatio() << std::endl; - o << " C1VRatio = " << surfconti.C1VRatio() << std::endl; - o << " C2URatio = " << surfconti.C2URatio() << std::endl; - o << " C2VRatio = " << surfconti.C2VRatio() << std::endl; + o << " C0Value = " << surfconti.C0Value() << '\n'; + o << " C1UAngle = " << surfconti.C1UAngle() << '\n'; + o << " C1VAngle = " << surfconti.C1VAngle() << '\n'; + o << " C2UAngle = " << surfconti.C2UAngle() << '\n'; + o << " C2VAngle = " << surfconti.C2VAngle() << '\n'; + o << " C1URatio = " << surfconti.C1URatio() << '\n'; + o << " C1VRatio = " << surfconti.C1VRatio() << '\n'; + o << " C2URatio = " << surfconti.C2URatio() << '\n'; + o << " C2VRatio = " << surfconti.C2VRatio() << '\n'; } break; case GeomAbs_G1: { if (surfconti.IsG1()) - o << " Continuity Status : G1 " << std::endl; + { + o << " Continuity Status : G1 " << '\n'; + } else { if (surfconti.IsC0()) - o << " Continuity Status : G0 " << std::endl; + { + o << " Continuity Status : G0 " << '\n'; + } else - o << " Continuity Status : NoG0 " << std::endl; + { + o << " Continuity Status : NoG0 " << '\n'; + } } - o << " G0Value = " << surfconti.C0Value() << std::endl; - o << " G1Angle = " << surfconti.G1Angle() << std::endl << std::endl; + o << " G0Value = " << surfconti.C0Value() << '\n'; + o << " G1Angle = " << surfconti.G1Angle() << '\n' << '\n'; } break; case GeomAbs_G2: { if (surfconti.IsG2()) - o << " Continuity Status : G2 " << std::endl; + { + o << " Continuity Status : G2 " << '\n'; + } else { if (surfconti.IsG1()) - o << " Continuity Status : G1 " << std::endl; + { + o << " Continuity Status : G1 " << '\n'; + } else { if (surfconti.IsC0()) - o << " Continuity Status : G0 " << std::endl; + { + o << " Continuity Status : G0 " << '\n'; + } else - o << " Continuity Status : NoG0 " << std::endl; + { + o << " Continuity Status : NoG0 " << '\n'; + } } } - o << " G0Value = " << surfconti.C0Value() << std::endl; - o << " G1Value = " << surfconti.G1Angle() << std::endl; - o << " G2CurvatureGap = " << surfconti.G2CurvatureGap() << std::endl; + o << " G0Value = " << surfconti.C0Value() << '\n'; + o << " G1Value = " << surfconti.G1Angle() << '\n'; + o << " G2CurvatureGap = " << surfconti.G2CurvatureGap() << '\n'; } break; default: { } } + } } /*********************************************************************************/ @@ -135,104 +177,146 @@ void LocalAnalysis::Dump(const LocalAnalysis_CurveContinuity& curvconti, Standar { if (!curvconti.IsDone()) { - o << "Problem in the computation " << std::endl; + o << "Problem in the computation " << '\n'; if (curvconti.StatusError() == LocalAnalysis_NullFirstDerivative) - o << "one (or both) first derivative is null" << std::endl; + { + o << "one (or both) first derivative is null" << '\n'; + } else if (curvconti.StatusError() == LocalAnalysis_NullSecondDerivative) - o << "one (or both) second derivative is null" << std::endl; + { + o << "one (or both) second derivative is null" << '\n'; + } else if (curvconti.StatusError() == LocalAnalysis_TangentNotDefined) - o << "one (or both) tangent is undefined " << std::endl; + { + o << "one (or both) tangent is undefined " << '\n'; + } else if (curvconti.StatusError() == LocalAnalysis_NormalNotDefined) - o << "one (or both) normal is undefined" << std::endl; + { + o << "one (or both) normal is undefined" << '\n'; + } } else + { switch (curvconti.ContinuityStatus()) { case GeomAbs_C0: { if (curvconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : No C0 " << std::endl; - o << " C0Value = " << curvconti.C0Value() << std::endl; + { + o << " Continuity Status : No C0 " << '\n'; + } + o << " C0Value = " << curvconti.C0Value() << '\n'; } break; case GeomAbs_C1: { if (curvconti.IsC1()) - o << " Continuity Status : C1 " << std::endl; + { + o << " Continuity Status : C1 " << '\n'; + } else { if (curvconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : NoC0 " << std::endl; + { + o << " Continuity Status : NoC0 " << '\n'; + } } - o << " C0Value = " << curvconti.C0Value() << std::endl; - o << " C1Angle = " << curvconti.C1Angle() << std::endl; - o << " C1Ratio = " << curvconti.C1Ratio() << std::endl; + o << " C0Value = " << curvconti.C0Value() << '\n'; + o << " C1Angle = " << curvconti.C1Angle() << '\n'; + o << " C1Ratio = " << curvconti.C1Ratio() << '\n'; } break; case GeomAbs_C2: { if (curvconti.IsC2()) - o << " Continuity Status : C2 " << std::endl; + { + o << " Continuity Status : C2 " << '\n'; + } else { if (curvconti.IsC1()) - o << " Continuity Status : C1 " << std::endl; + { + o << " Continuity Status : C1 " << '\n'; + } else { if (curvconti.IsC0()) - o << " Continuity Status : C0 " << std::endl; + { + o << " Continuity Status : C0 " << '\n'; + } else - o << " Continuity Status : NoC0 " << std::endl; + { + o << " Continuity Status : NoC0 " << '\n'; + } } } - o << " C0Value = " << curvconti.C0Value() << std::endl; - o << " C1Angle = " << curvconti.C1Angle() << std::endl; - o << " C2Angle = " << curvconti.C2Angle() << std::endl; - o << " C1Ratio = " << curvconti.C1Ratio() << std::endl; - o << " C2Ratio = " << curvconti.C2Ratio() << std::endl; + o << " C0Value = " << curvconti.C0Value() << '\n'; + o << " C1Angle = " << curvconti.C1Angle() << '\n'; + o << " C2Angle = " << curvconti.C2Angle() << '\n'; + o << " C1Ratio = " << curvconti.C1Ratio() << '\n'; + o << " C2Ratio = " << curvconti.C2Ratio() << '\n'; } break; case GeomAbs_G1: { if (curvconti.IsG1()) - o << " Continuity Status : G1 " << std::endl; + { + o << " Continuity Status : G1 " << '\n'; + } else { if (curvconti.IsC0()) - o << " Continuity Status : G0 " << std::endl; + { + o << " Continuity Status : G0 " << '\n'; + } else - o << " Continuity Status : NoG0 " << std::endl; + { + o << " Continuity Status : NoG0 " << '\n'; + } } - o << " G0Value = " << curvconti.C0Value() << std::endl; - o << " G1Angle = " << curvconti.G1Angle() << std::endl; + o << " G0Value = " << curvconti.C0Value() << '\n'; + o << " G1Angle = " << curvconti.G1Angle() << '\n'; } break; case GeomAbs_G2: { if (curvconti.IsG2()) - o << " Continuity Status : G2 " << std::endl; + { + o << " Continuity Status : G2 " << '\n'; + } else { if (curvconti.IsG1()) - o << " Continuity Status : G1 " << std::endl; + { + o << " Continuity Status : G1 " << '\n'; + } else { if (curvconti.IsC0()) - o << " Continuity Status : G0 " << std::endl; + { + o << " Continuity Status : G0 " << '\n'; + } else - o << " Continuity Status : NoG0 " << std::endl; + { + o << " Continuity Status : NoG0 " << '\n'; + } } } - o << " G0Value = " << curvconti.C0Value() << std::endl; - o << " G1Angle = " << curvconti.G1Angle() << std::endl; - o << " G2Angle = " << curvconti.G2Angle() << std::endl; - o << " Relative curvature variation = " << curvconti.G2CurvatureVariation() << std::endl; + o << " G0Value = " << curvconti.C0Value() << '\n'; + o << " G1Angle = " << curvconti.G1Angle() << '\n'; + o << " G2Angle = " << curvconti.G2Angle() << '\n'; + o << " Relative curvature variation = " << curvconti.G2CurvatureVariation() << '\n'; } break; default: { } } + } } /*********************************************************************************/ diff --git a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_CurveContinuity.cxx b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_CurveContinuity.cxx index eabae62231..d2a754ee28 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_CurveContinuity.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_CurveContinuity.cxx @@ -50,9 +50,13 @@ void LocalAnalysis_CurveContinuity::CurvC1(GeomLProp_CLProps& Curv1, GeomLProp_C } ang = V1.Angle(V2); if (ang > M_PI / 2) + { myContC1 = M_PI - ang; + } else + { myContC1 = ang; + } } else { @@ -94,9 +98,13 @@ void LocalAnalysis_CurveContinuity::CurvC2(GeomLProp_CLProps& Curv1, GeomLProp_C } ang = V12.Angle(V22); if (ang > M_PI / 2) + { myContC2 = M_PI - ang; + } else + { myContC2 = ang; + } } else @@ -125,9 +133,13 @@ void LocalAnalysis_CurveContinuity::CurvG1(GeomLProp_CLProps& Curv1, GeomLProp_C Curv2.Tangent(Tang2); ang = Tang1.Angle(Tang2); if (ang > M_PI / 2) + { myContG1 = M_PI - ang; + } else + { myContG1 = ang; + } } else { @@ -157,9 +169,13 @@ void LocalAnalysis_CurveContinuity::CurvG2(GeomLProp_CLProps& Curv1, GeomLProp_C Curv2.Normal(D2); ang = D1.Angle(D2); if (ang > M_PI / 2) + { myContG2 = M_PI - ang; + } else + { myContG2 = ang; + } myCourbC1 = Curv1.Curvature(); myCourbC2 = Curv2.Curvature(); myG2Variation = std::abs(myCourbC1 - myCourbC2) / sqrt(myCourbC1 * myCourbC2); @@ -299,10 +315,14 @@ bool LocalAnalysis_CurveContinuity::IsC2() const epsil1 = 0.5 * myepsC1 * myepsC1 * myLambda1; epsil2 = 0.5 * myepsC2 * myepsC2 * myLambda2; if ((std::abs(myLambda1 * myLambda1 - myLambda2)) <= (epsil1 * epsil1 + epsil2)) + { return true; + } } else + { return false; + } } return false; } @@ -338,17 +358,29 @@ bool LocalAnalysis_CurveContinuity::IsG2() const CRBNUL = 8 * myepsC0 / (myMaxLon * myMaxLon); if (myCourbC1 > CRBINF) + { IETA1 = 2; + } else if (myCourbC1 < CRBNUL) + { IETA1 = 0; + } else + { IETA1 = 1; + } if (myCourbC2 > CRBINF) + { IETA2 = 2; + } else if (myCourbC2 < CRBNUL) + { IETA2 = 0; + } else + { IETA2 = 1; + } if (IETA1 == IETA2) { if (IETA1 == 1) @@ -359,16 +391,24 @@ bool LocalAnalysis_CurveContinuity::IsG2() const return myG2Variation < myperce; } else + { return false; + } } else + { return true; + } } else + { return false; + } } else + { return false; + } } /*********************************************************************************/ diff --git a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_SurfaceContinuity.cxx b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_SurfaceContinuity.cxx index 49dd8fe028..8f9e7a8f86 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_SurfaceContinuity.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/LocalAnalysis/LocalAnalysis_SurfaceContinuity.cxx @@ -53,23 +53,39 @@ void LocalAnalysis_SurfaceContinuity::SurfC1(GeomLProp_SLProps& Surf1, GeomLProp if ((norm1u > myepsnul) && (norm2u > myepsnul) && (norm1v > myepsnul) && (norm2v > myepsnul)) { if (norm1u >= norm2u) + { myLambda1U = norm2u / norm1u; + } else + { myLambda1U = norm1u / norm2u; + } if (norm1v >= norm2v) + { myLambda1V = norm2v / norm1v; + } else + { myLambda1V = norm1v / norm2v; + } angu = V1u.Angle(V2u); if (angu > M_PI / 2) + { myContC1U = M_PI - angu; + } else + { myContC1U = angu; + } angv = V1v.Angle(V2v); if (angv > M_PI / 2) + { myContC1V = M_PI - angv; + } else + { myContC1V = angv; + } } else { @@ -111,9 +127,13 @@ void LocalAnalysis_SurfaceContinuity::SurfC2(GeomLProp_SLProps& Surf1, GeomLProp } ang = V21u.Angle(V22u); if (ang > M_PI / 2) + { myContC2U = M_PI - ang; + } else + { myContC2U = ang; + } } else { @@ -153,9 +173,13 @@ void LocalAnalysis_SurfaceContinuity::SurfC2(GeomLProp_SLProps& Surf1, GeomLProp } ang = V21v.Angle(V22v); if (ang > M_PI / 2) + { myContC2V = M_PI - ang; + } else + { myContC2V = ang; + } } else { @@ -179,9 +203,13 @@ void LocalAnalysis_SurfaceContinuity::SurfG1(GeomLProp_SLProps& Surf1, GeomLProp gp_Dir D2 = Surf2.Normal(); double ang = D1.Angle(D2); if (ang > M_PI / 2) + { myContG1 = M_PI - ang; + } else + { myContG1 = ang; + } } else { @@ -453,7 +481,9 @@ LocalAnalysis_SurfaceContinuity::LocalAnalysis_SurfaceContinuity( parf2 = curv2->LastParameter(); if ((U > parf1) || (U < pard1) || (U > parf2) || (U < pard2)) + { myIsDone = false; + } else { gp_Pnt2d pt1 = curv1->Value(U); @@ -546,18 +576,30 @@ bool LocalAnalysis_SurfaceContinuity::IsC2() const if ((myContC2U < myepsC2) && (myContC2V < myepsC2)) { if (std::abs(myLambda1U * myLambda1U - myLambda2U) <= (eps1u * eps1u + eps2u)) + { if (std::abs(myLambda1V * myLambda1V - myLambda2V) <= (eps1v * eps1v + eps2v)) + { return true; + } else + { return false; + } + } else + { return false; + } } else + { return false; + } } else + { return false; + } } /*********************************************************************************/ @@ -587,31 +629,51 @@ bool LocalAnalysis_SurfaceContinuity::IsG2() const if (IsG1()) { if ((std::abs(myETA) < EPSNL) && (std::abs(myZETA) < EPSNL)) + { return true; + } if ((std::abs(myZETA1) < EPSNL) && (std::abs(myZETA2) < EPSNL)) + { itype = 1; + } else if ((std::abs(myETA1) < EPSNL) && (std::abs(myETA2) < EPSNL)) + { itype = 1; + } else if ((std::abs(std::abs(myZETA) - std::abs(myETA))) < EPSNL) + { itype = 1; + } else if ((myETA1 < myZETA1) && (myETA2 < myZETA2)) + { itype = 1; + } else if ((myETA1 > myZETA1) && (myETA2 > myZETA2)) + { itype = 1; + } if (itype == 1) { if ((myETA >= (2 * myZETA)) && (myGap <= (myperce * (myETA - myZETA)))) + { return true; + } if ((myZETA >= myETA) && (myGap <= (myperce * myZETA))) + { return true; + } return (myZETA <= myETA) && (myETA <= (2 * myZETA)) && (myGap <= (myperce * myETA)); } else + { return false; + } } else + { return false; + } } /*********************************************************************************/ diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0Constraint.cxx index 84653bd313..ad9aa1d811 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0Constraint.cxx @@ -51,9 +51,13 @@ bool NLPlate_HPG0Constraint::IncrementalLoadAllowed() const int NLPlate_HPG0Constraint::ActiveOrder() const { if (myActiveOrder < 0) + { return myActiveOrder; + } else + { return 0; + } } bool NLPlate_HPG0Constraint::IsG0() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G1Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G1Constraint.cxx index aef4f4e6a4..0e80f48b8e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G1Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G1Constraint.cxx @@ -38,9 +38,13 @@ void NLPlate_HPG0G1Constraint::SetOrientation(const int Orient) int NLPlate_HPG0G1Constraint::ActiveOrder() const { if (myActiveOrder < 1) + { return myActiveOrder; + } else + { return 1; + } } int NLPlate_HPG0G1Constraint::Orientation() diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G2Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G2Constraint.cxx index 7f20120f60..030dcac16a 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G2Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G2Constraint.cxx @@ -34,9 +34,13 @@ NLPlate_HPG0G2Constraint::NLPlate_HPG0G2Constraint(const gp_XY& UV, int NLPlate_HPG0G2Constraint::ActiveOrder() const { if (myActiveOrder < 2) + { return myActiveOrder; + } else + { return 2; + } } const Plate_D2& NLPlate_HPG0G2Constraint::G2Target() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G3Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G3Constraint.cxx index 78c94bef86..e50811f709 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G3Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG0G3Constraint.cxx @@ -36,9 +36,13 @@ NLPlate_HPG0G3Constraint::NLPlate_HPG0G3Constraint(const gp_XY& UV, int NLPlate_HPG0G3Constraint::ActiveOrder() const { if (myActiveOrder < 3) + { return myActiveOrder; + } else + { return 3; + } } const Plate_D3& NLPlate_HPG0G3Constraint::G3Target() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG1Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG1Constraint.cxx index 4bd7cb517f..bd85a6254b 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG1Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG1Constraint.cxx @@ -47,9 +47,13 @@ bool NLPlate_HPG1Constraint::IncrementalLoadAllowed() const int NLPlate_HPG1Constraint::ActiveOrder() const { if (myActiveOrder < 1) + { return myActiveOrder; + } else + { return 1; + } } bool NLPlate_HPG1Constraint::IsG0() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG2Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG2Constraint.cxx index 8e4985735d..8d72e6d074 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG2Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG2Constraint.cxx @@ -33,9 +33,13 @@ NLPlate_HPG2Constraint::NLPlate_HPG2Constraint(const gp_XY& UV, int NLPlate_HPG2Constraint::ActiveOrder() const { if (myActiveOrder < 2) + { return myActiveOrder; + } else + { return 2; + } } const Plate_D2& NLPlate_HPG2Constraint::G2Target() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG3Constraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG3Constraint.cxx index ec3fbab697..e101a8136f 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG3Constraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_HPG3Constraint.cxx @@ -35,9 +35,13 @@ NLPlate_HPG3Constraint::NLPlate_HPG3Constraint(const gp_XY& UV, int NLPlate_HPG3Constraint::ActiveOrder() const { if (myActiveOrder < 3) + { return myActiveOrder; + } else + { return 3; + } } const Plate_D3& NLPlate_HPG3Constraint::G3Target() const diff --git a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_NLPlate.cxx b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_NLPlate.cxx index a609c0abc2..d92200443e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_NLPlate.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/NLPlate/NLPlate_NLPlate.cxx @@ -41,7 +41,9 @@ NLPlate_NLPlate::NLPlate_NLPlate(const occ::handle& InitialSurface void NLPlate_NLPlate::Load(const occ::handle& GConst) { if (!GConst.IsNull()) + { myHGPPConstraints.Append(GConst); + } OK = false; } @@ -52,7 +54,9 @@ void NLPlate_NLPlate::Solve(const int ord, const int InitialConsraintOrder) int maxOrder = MaxActiveConstraintOrder(); int ordre = ord; if (ordre < maxOrder + 2) + { ordre = maxOrder + 2; + } for (int iterOrder = InitialConsraintOrder; iterOrder <= maxOrder; iterOrder++) { @@ -72,7 +76,9 @@ void NLPlate_NLPlate::Solve2(const int ord, const int InitialConsraintOrder) int maxOrder = MaxActiveConstraintOrder(); int ordre = ord; if (ordre < maxOrder + 2) + { ordre = maxOrder + 2; + } if (Iterate(0, ord)) { mySOP.First().SetPolynomialPartOnly(true); @@ -100,7 +106,9 @@ void NLPlate_NLPlate::IncrementalSolve(const int ord, int maxOrder = MaxActiveConstraintOrder(); int ordre = ord; if (ordre < maxOrder + 2) + { ordre = maxOrder + 2; + } double IncrementalLoad = 1.; for (int increment = 0; increment < NbIncrements; increment++) @@ -116,7 +124,9 @@ void NLPlate_NLPlate::IncrementalSolve(const int ord, } } if (UVSliding) + { ConstraintsSliding(); + } } OK = true; } @@ -155,14 +165,20 @@ gp_XYZ NLPlate_NLPlate::EvaluateDerivative(const gp_XY& point2d, const int iu, c { gp_XYZ Value(0., 0., 0.); if ((iu == 0) && (iv == 0)) + { Value = myInitialSurface->Value(point2d.X(), point2d.Y()).XYZ(); + } else + { Value = myInitialSurface->DN(point2d.X(), point2d.Y(), iu, iv).XYZ(); + } for (NCollection_List::Iterator SI(mySOP); SI.More(); SI.Next()) { if (SI.Value().IsDone()) + { Value += SI.Value().EvaluateDerivative(point2d, iu, iv); + } } return Value; } @@ -175,12 +191,16 @@ int NLPlate_NLPlate::Continuity() const for (cont = -1; cont < 10; cont++) { if (!(myInitialSurface->IsCNu(cont + 1) && myInitialSurface->IsCNv(cont + 1))) + { break; + } } for (NCollection_List::Iterator SI(mySOP); SI.More(); SI.Next()) { if ((SI.Value().IsDone()) && (cont > SI.Value().Continuity())) + { cont = SI.Value().Continuity(); + } } return cont; } @@ -199,16 +219,22 @@ bool NLPlate_NLPlate::Iterate(const int ConstraintOrder, const occ::handle& HGPP = myHGPPConstraints(index); int Order = HGPP->ActiveOrder(); if (ConstraintOrder < Order) + { Order = ConstraintOrder; + } const gp_XY& UV = HGPP->UV(); if ((Order >= 0) && HGPP->IsG0()) { if (HGPP->IncrementalLoadAllowed()) + { TopP.Load( Plate_PinpointConstraint(UV, (HGPP->G0Target() - Evaluate(UV)) * IncrementalLoading)); + } else + { TopP.Load(Plate_PinpointConstraint(UV, HGPP->G0Target() - Evaluate(UV))); + } } if ((IncrementalLoading != 1.) && HGPP->IncrementalLoadAllowed() && (Order >= 1)) @@ -310,7 +336,9 @@ bool NLPlate_NLPlate::Iterate(const int ConstraintOrder, return false; } else + { return true; + } } //======================================================================= @@ -338,7 +366,9 @@ void NLPlate_NLPlate::ConstraintsSliding(const int NbIterations) mat(1, 1) = Dv * Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { break; + } math_Vector vec(0, 1); vec(0) = Du * DP; @@ -363,7 +393,9 @@ int NLPlate_NLPlate::MaxActiveConstraintOrder() const { int CAOrder = myHGPPConstraints(index)->ActiveOrder(); if (CAOrder > MaxOrder) + { MaxOrder = CAOrder; + } } return MaxOrder; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_FreeGtoCConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_FreeGtoCConstraint.cxx index a044f67140..b6fac7d696 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_FreeGtoCConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_FreeGtoCConstraint.cxx @@ -46,18 +46,24 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); if (IncrementalLoad != 1.) { gp_XYZ N0 = D1S.Du ^ D1S.Dv; if (N0.Modulus() < NORMIN) + { return; + } N0.Normalize(); gp_XYZ N1 = normale; if (orientation != 0) + { N1 *= orientation; + } double c = N0 * N1; if (orientation == 0) { @@ -70,7 +76,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, double s = N0.CrossMagnitude(N1); if ((s < 1.e-2) && (c < 0.)) + { return; + } double angle = atan2(c, s); // if (angle < 0.) angle += M_PI; @@ -110,7 +118,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints @@ -118,7 +128,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, if (normaleS.Modulus() < NORMIN) { if (IncrementalLoad != 1.) + { return; + } gp_XYZ du = D1S.Du * (-1.); gp_XYZ dv = D1S.Dv * (-1.); @@ -134,7 +146,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, gp_XYZ N0 = normaleS; gp_XYZ N1 = normale; if (orientation != 0) + { N1 *= orientation; + } double c = N0 * N1; if (orientation == 0) { @@ -147,7 +161,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, double s = N0.CrossMagnitude(N1); if ((s < 1.e-2) && (c < 0.)) + { return; + } double angle = atan2(c, s); gp_XYZ d = N0 ^ N1; @@ -197,7 +213,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, mat(1, 1) = Sv * D1T.Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; @@ -253,7 +271,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints @@ -261,7 +281,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, if (normaleS.Modulus() < NORMIN) { if (IncrementalLoad != 1.) + { return; + } gp_XYZ du = D1S.Du * (-1.); gp_XYZ dv = D1S.Dv * (-1.); @@ -277,7 +299,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, gp_XYZ N0 = normaleS; gp_XYZ N1 = normale; if (orientation != 0) + { N1 *= orientation; + } double c = N0 * N1; if (orientation == 0) { @@ -289,7 +313,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, } double s = N0.CrossMagnitude(N1); if ((s < 1.e-2) && (c < 0.)) + { return; + } double angle = atan2(c, s); gp_XYZ d = N0 ^ N1; @@ -343,7 +369,9 @@ Plate_FreeGtoCConstraint::Plate_FreeGtoCConstraint(const gp_XY& point2d, mat(1, 1) = Sv * D1T.Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GlobalTranslationConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GlobalTranslationConstraint.cxx index 3708e57c9f..93cb17198c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GlobalTranslationConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GlobalTranslationConstraint.cxx @@ -32,9 +32,13 @@ Plate_GlobalTranslationConstraint::Plate_GlobalTranslationConstraint( for (int j = 2; j <= SOfXY.Length(); j++) { if (j == (i + 1)) + { myLXYZC.SetCoeff(i, j, 1.); + } else + { myLXYZC.SetCoeff(i, j, 0.); + } } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GtoCConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GtoCConstraint.cxx index ae5dcd3c37..3ef78ad1c0 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GtoCConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_GtoCConstraint.cxx @@ -32,7 +32,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const Plate_GtoCConstraint& ref) pnt2d = ref.pnt2d; nb_PPConstraints = ref.nb_PPConstraints; for (int i = 0; i < nb_PPConstraints; i++) + { myPPC[i] = ref.myPPC[i]; + } } Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, @@ -46,7 +48,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; // alr le 12/11/96 if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints @@ -54,11 +58,15 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normaleS = D1S.Du ^ D1S.Dv; // alr le 12/11/96 if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); double cos_normales = normale * normaleS; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = normaleS * -(normale * D1S.Du) * invcos; @@ -81,24 +89,32 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du ^ D1S.Dv; if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); gp_XYZ nSP = normaleS - nP * (nP * normaleS); if (nSP.Modulus() < NORMIN) + { return; + } nSP.Normalize(); double cos_normales = normale * nSP; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = nSP * -(normale * D1S.Du) * invcos; @@ -124,19 +140,25 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; // alr le 12/11/96 if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du ^ D1S.Dv; // alr le 12/11/96 if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); double cos_normales = normale * normaleS; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = normaleS * -(normale * D1S.Du) * invcos; @@ -157,7 +179,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, mat(1, 1) = Sv * D1T.Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; @@ -204,24 +228,32 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; // alr le 12/11/96 if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du ^ D1S.Dv; // alr le 12/11/96 if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); gp_XYZ nSP = normaleS - nP * (nP * normaleS); if (nSP.Modulus() < NORMIN) + { return; + } nSP.Normalize(); double cos_normales = normale * nSP; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = nSP * -(normale * D1S.Du) * invcos; @@ -242,7 +274,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, mat(1, 1) = Sv * D1T.Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; @@ -288,18 +322,24 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du ^ D1S.Dv; if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); double cos_normales = normale * normaleS; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = normaleS * -(normale * D1S.Du) * invcos; @@ -320,7 +360,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint(const gp_XY& point2d, mat(1, 1) = Sv * D1T.Dv; math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; @@ -425,18 +467,24 @@ Plate_GtoCConstraint::Plate_GtoCConstraint( gp_XYZ normale = D1T.Du ^ D1T.Dv; if (normale.Modulus() < NORMIN) + { return; + } normale.Normalize(); // G1 Constraints gp_XYZ normaleS = D1S.Du ^ D1S.Dv; if (normaleS.Modulus() < NORMIN) + { return; + } normaleS.Normalize(); double cos_normales = normale * normaleS; if (fabs(cos_normales) < COSMIN) + { return; + } double invcos = 1. / cos_normales; gp_XYZ du = normaleS * -(normale * D1S.Du) * invcos; @@ -458,7 +506,9 @@ Plate_GtoCConstraint::Plate_GtoCConstraint( math_Gauss gauss(mat); if (!gauss.IsDone()) + { return; + } math_Vector vec(0, 1); vec(0) = Su * Su; diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LineConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LineConstraint.cxx index 71f65cbc98..7f451c4397 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LineConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LineConstraint.cxx @@ -35,7 +35,9 @@ Plate_LineConstraint::Plate_LineConstraint(const gp_XY& point2d, gp_XYZ d1 = dX ^ dir; gp_XYZ d2 = dY ^ dir; if (d2.SquareModulus() > d1.SquareModulus()) + { d1 = d2; + } d1.Normalize(); d2 = dir ^ d1; d2.Normalize(); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearScalarConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearScalarConstraint.cxx index ce3ffc904c..f82e908bac 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearScalarConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearScalarConstraint.cxx @@ -37,7 +37,9 @@ Plate_LinearScalarConstraint::Plate_LinearScalarConstraint( const NCollection_Array1& theCoeff) { if (theCoeff.Length() != thePPC.Length()) + { throw Standard_DimensionMismatch(); + } myPPC = new NCollection_HArray1(1, thePPC.Length()); myCoef = new NCollection_HArray2(1, 1, 1, theCoeff.Length()); @@ -53,7 +55,9 @@ Plate_LinearScalarConstraint::Plate_LinearScalarConstraint( const NCollection_Array2& theCoeff) { if (theCoeff.RowLength() != thePPC.Length()) + { throw Standard_DimensionMismatch(); + } myPPC = new NCollection_HArray1(1, thePPC.Length()); myCoef = new NCollection_HArray2(1, theCoeff.ColLength(), 1, theCoeff.RowLength()); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearXYZConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearXYZConstraint.cxx index 72793a4639..c01c3cd32e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearXYZConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_LinearXYZConstraint.cxx @@ -25,13 +25,17 @@ Plate_LinearXYZConstraint::Plate_LinearXYZConstraint( const NCollection_Array1& theCoeff) { if (theCoeff.Length() != thePPC.Length()) + { throw Standard_DimensionMismatch(); + } myPPC = new NCollection_HArray1(1, thePPC.Length()); myCoef = new NCollection_HArray2(1, 1, 1, theCoeff.Length()); myPPC->ChangeArray1() = thePPC; for (int i = 1; i <= theCoeff.Length(); i++) + { myCoef->ChangeValue(1, i) = theCoeff(i + theCoeff.Lower() - 1); + } } Plate_LinearXYZConstraint::Plate_LinearXYZConstraint( @@ -39,7 +43,9 @@ Plate_LinearXYZConstraint::Plate_LinearXYZConstraint( const NCollection_Array2& theCoeff) { if (theCoeff.RowLength() != thePPC.Length()) + { throw Standard_DimensionMismatch(); + } myPPC = new NCollection_HArray1(1, thePPC.Length()); myCoef = new NCollection_HArray2(1, theCoeff.ColLength(), 1, theCoeff.RowLength()); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_Plate.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_Plate.cxx index 7f40c97662..12fc030513 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_Plate.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_Plate.cxx @@ -199,7 +199,9 @@ void Plate_Plate::Load(const Plate_PinpointConstraint& PConst) myConstraints.Append(PConst); int OrdreConst = PConst.Idu() + PConst.Idv(); if (maxConstraintOrder < OrdreConst) + { maxConstraintOrder = OrdreConst; + } } void Plate_Plate::Load(const Plate_LinearXYZConstraint& LXYZConst) @@ -212,7 +214,9 @@ void Plate_Plate::Load(const Plate_LinearXYZConstraint& LXYZConst) { int OrdreConst = LXYZConst.GetPPC()(j).Idu() + LXYZConst.GetPPC()(j).Idv(); if (maxConstraintOrder < OrdreConst) + { maxConstraintOrder = OrdreConst; + } } } @@ -225,7 +229,9 @@ void Plate_Plate::Load(const Plate_LinearScalarConstraint& LScalarConst) { int OrdreConst = LScalarConst.GetPPC()(j).Idu() + LScalarConst.GetPPC()(j).Idv(); if (maxConstraintOrder < OrdreConst) + { maxConstraintOrder = OrdreConst; + } } } @@ -247,16 +253,22 @@ void Plate_Plate::Load(const Plate_SampledCurveConstraint& SCConst) void Plate_Plate::Load(const Plate_GtoCConstraint& GtoCConst) { for (int i = 0; i < GtoCConst.nb_PPC(); i++) + { Load(GtoCConst.GetPPC(i)); + } } void Plate_Plate::Load(const Plate_FreeGtoCConstraint& FGtoCConst) { int i; for (i = 0; i < FGtoCConst.nb_PPC(); i++) + { Load(FGtoCConst.GetPPC(i)); + } for (i = 0; i < FGtoCConst.nb_LSC(); i++) + { Load(FGtoCConst.LSC(i)); + } } void Plate_Plate::Load(const Plate_GlobalTranslationConstraint& GTConst) @@ -277,15 +289,25 @@ void Plate_Plate::SolveTI(const int ord, OK = false; order = ord; if (ord <= 1) + { return; + } if (ord > 9) + { return; + } if (n_el < 1) + { return; + } if (anisotropie < 1.e-6) + { return; + } if (anisotropie > 1.e+6) + { return; + } // computation of the bounding box of the 2d PPconstraints double xmin, xmax, ymin, ymax; @@ -293,32 +315,50 @@ void Plate_Plate::SolveTI(const int ord, double du = 0.5 * (xmax - xmin); if (anisotropie > 1.) + { du *= anisotropie; + } if (du < 1.e-10) + { return; + } ddu[0] = 1; int i; for (i = 1; i <= 9; i++) + { ddu[i] = ddu[i - 1] / du; + } double dv = 0.5 * (ymax - ymin); if (anisotropie < 1.) + { dv /= anisotropie; + } if (dv < 1.e-10) + { return; + } ddv[0] = 1; for (i = 1; i <= 9; i++) + { ddv[i] = ddv[i - 1] / dv; + } if (myLScalarConstraints.IsEmpty()) { if (myLXYZConstraints.IsEmpty()) + { SolveTI1(IterationNumber, theProgress); + } else + { SolveTI2(IterationNumber, theProgress); + } } else + { SolveTI3(IterationNumber, theProgress); + } } //======================================================================= @@ -338,17 +378,23 @@ void Plate_Plate::SolveTI1(const int IterationNumber, const Message_ProgressRang points = new gp_XY[n_el]; int i; for (i = 0; i < n_el; i++) + { Points(i) = myConstraints(i + 1).Pnt2d(); + } delete[] (int*)deru; deru = new int[n_el]; for (i = 0; i < n_el; i++) + { Deru(i) = myConstraints(i + 1).Idu(); + } delete[] (int*)derv; derv = new int[n_el]; for (i = 0; i < n_el; i++) + { Derv(i) = myConstraints(i + 1).Idv(); + } for (i = 0; i < n_el; i++) { @@ -356,7 +402,9 @@ void Plate_Plate::SolveTI1(const int IterationNumber, const Message_ProgressRang { double signe = 1; if (((Deru(j) + Derv(j)) % 2) == 1) + { signe = -1; + } int iu = Deru(i) + Deru(j); int iv = Derv(i) + Derv(j); mat(i, j) = signe * SolEm(Points(i) - Points(j), iu, iv); @@ -470,7 +518,9 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang int nCC2 = 0; int i; for (i = 1; i <= myLXYZConstraints.Length(); i++) + { nCC2 += myLXYZConstraints(i).Coeff().ColLength(); + } int n_dimat = nCC1 + nCC2 + order * (order + 1) / 2; @@ -490,6 +540,7 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang int k = nCC1; for (i = 1; i <= myLXYZConstraints.Length(); i++) + { for (int j = 1; j <= myLXYZConstraints(i).GetPPC().Length(); j++) { Points(k) = myLXYZConstraints(i).GetPPC()(j).Pnt2d(); @@ -497,6 +548,7 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang Derv(k) = myLXYZConstraints(i).GetPPC()(j).Idv(); k++; } + } math_Matrix mat(0, n_dimat - 1, 0, n_dimat - 1, 0.); @@ -557,8 +609,10 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) { for (int icol = 1; icol <= myLXYZConstraints(i).Coeff().RowLength(); icol++) + { sec_member(k) += myLXYZConstraints(i).Coeff()(irow, icol) * myLXYZConstraints(i).GetPPC()(icol).Value().Coord(icoor); + } k++; } } @@ -578,7 +632,9 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang // finalr for (i = 0; i < nCC1; i++) + { Solution(i).SetCoord(icoor, sol(i)); + } int kSolution = nCC1; int ksol = nCC1; @@ -589,7 +645,9 @@ void Plate_Plate::SolveTI2(const int IterationNumber, const Message_ProgressRang { double vsol = 0; for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) + { vsol += myLXYZConstraints(i).Coeff()(irow, icol) * sol(ksol + irow - 1); + } Solution(kSolution).SetCoord(icoor, vsol); kSolution++; } @@ -618,11 +676,15 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang int nCC2 = 0; int i; for (i = 1; i <= myLXYZConstraints.Length(); i++) + { nCC2 += myLXYZConstraints(i).Coeff().ColLength(); + } int nCC3 = 0; for (i = 1; i <= myLScalarConstraints.Length(); i++) + { nCC3 += myLScalarConstraints(i).Coeff().ColLength(); + } int nbm = order * (order + 1) / 2; int n_dimsousmat = nCC1 + nCC2 + nbm; @@ -644,6 +706,7 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang int k = nCC1; for (i = 1; i <= myLXYZConstraints.Length(); i++) + { for (int j = 1; j <= myLXYZConstraints(i).GetPPC().Length(); j++) { Points(k) = myLXYZConstraints(i).GetPPC()(j).Pnt2d(); @@ -651,8 +714,10 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang Derv(k) = myLXYZConstraints(i).GetPPC()(j).Idv(); k++; } + } int nPPC2 = k; for (i = 1; i <= myLScalarConstraints.Length(); i++) + { for (int j = 1; j <= myLScalarConstraints(i).GetPPC().Length(); j++) { Points(k) = myLScalarConstraints(i).GetPPC()(j).Pnt2d(); @@ -660,6 +725,7 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang Derv(k) = myLScalarConstraints(i).GetPPC()(j).Idv(); k++; } + } math_Matrix mat(0, n_dimat - 1, 0, n_dimat - 1, 0.); @@ -681,13 +747,16 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang { double signe = 1; if (((Deru(j) + Derv(j)) % 2) == 1) + { signe = -1; + } int iu = Deru(kppc + ippc - 1) + Deru(j); int iv = Derv(kppc + ippc - 1) + Derv(j); vmat(ippc) = signe * SolEm(Points(kppc + ippc - 1) - Points(j), iu, iv); } for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) + { for (int icol = 1; icol <= myLScalarConstraints(i).Coeff().RowLength(); icol++) { mat(k + irow - 1, j) += myLScalarConstraints(i).Coeff()(irow, icol).X() * vmat(icol); @@ -696,6 +765,7 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang mat(k + irow - 1, 2 * n_dimsousmat + j) += myLScalarConstraints(i).Coeff()(irow, icol).Z() * vmat(icol); } + } } int k2 = nCC1; @@ -710,20 +780,27 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang myLXYZConstraints(i2).GetPPC().Length()); for (int ippc = 1; ippc <= myLScalarConstraints(i).GetPPC().Length(); ippc++) + { for (int ippc2 = 1; ippc2 <= myLXYZConstraints(i2).GetPPC().Length(); ippc2++) { double signe = 1; if (((Deru(kppc2 + ippc2 - 1) + Derv(kppc2 + ippc2 - 1)) % 2) == 1) + { signe = -1; + } int iu = Deru(kppc + ippc - 1) + Deru(kppc2 + ippc2 - 1); int iv = Derv(kppc + ippc - 1) + Derv(kppc2 + ippc2 - 1); tmpmat(ippc, ippc2) = signe * SolEm(Points(kppc + ippc - 1) - Points(kppc2 + ippc2 - 1), iu, iv); } + } for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) + { for (int irow2 = 1; irow2 <= myLXYZConstraints(i2).Coeff().ColLength(); irow2++) + { for (int icol = 1; icol <= myLScalarConstraints(i).Coeff().RowLength(); icol++) + { for (int icol2 = 1; icol2 <= myLXYZConstraints(i2).Coeff().RowLength(); icol2++) { mat(k + irow - 1, k2 + irow2 - 1) += myLScalarConstraints(i).Coeff()(irow, icol).X() @@ -736,6 +813,9 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang myLScalarConstraints(i).Coeff()(irow, icol).Z() * myLXYZConstraints(i2).Coeff()(irow2, icol2) * tmpmat(icol, icol2); } + } + } + } k2 += myLXYZConstraints(i2).Coeff().ColLength(); kppc2 += myLXYZConstraints(i2).Coeff().RowLength(); @@ -743,6 +823,7 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang j = nCC1 + nCC2; for (int iu = 0; iu < order; iu++) + { for (int iv = 0; iu + iv < order; iv++) { @@ -755,6 +836,7 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang } for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) + { for (int icol = 1; icol <= myLScalarConstraints(i).Coeff().RowLength(); icol++) { mat(k + irow - 1, j) += myLScalarConstraints(i).Coeff()(irow, icol).X() * vmat(icol); @@ -763,9 +845,11 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang mat(k + irow - 1, 2 * n_dimsousmat + j) += myLScalarConstraints(i).Coeff()(irow, icol).Z() * vmat(icol); } + } j++; } + } k2 = 3 * n_dimsousmat; kppc2 = nPPC2; @@ -778,26 +862,36 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang myLScalarConstraints(i2).GetPPC().Length()); for (int ippc = 1; ippc <= myLScalarConstraints(i).GetPPC().Length(); ippc++) + { for (int ippc2 = 1; ippc2 <= myLScalarConstraints(i2).GetPPC().Length(); ippc2++) { double signe = 1; if (((Deru(kppc2 + ippc2 - 1) + Derv(kppc2 + ippc2 - 1)) % 2) == 1) + { signe = -1; + } int a_iu = Deru(kppc + ippc - 1) + Deru(kppc2 + ippc2 - 1); int iv = Derv(kppc + ippc - 1) + Derv(kppc2 + ippc2 - 1); tmpmat(ippc, ippc2) = signe * SolEm(Points(kppc + ippc - 1) - Points(kppc2 + ippc2 - 1), a_iu, iv); } + } for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) + { for (int irow2 = 1; irow2 <= myLScalarConstraints(i2).Coeff().ColLength(); irow2++) + { for (int icol = 1; icol <= myLScalarConstraints(i).Coeff().RowLength(); icol++) + { for (int icol2 = 1; icol2 <= myLScalarConstraints(i2).Coeff().RowLength(); icol2++) { mat(k + irow - 1, k2 + irow2 - 1) += myLScalarConstraints(i).Coeff()(irow, icol) * myLScalarConstraints(i2).Coeff()(irow2, icol2) * tmpmat(icol, icol2); } + } + } + } k2 += myLScalarConstraints(i2).Coeff().ColLength(); kppc2 += myLScalarConstraints(i2).Coeff().RowLength(); @@ -808,8 +902,12 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang } for (j = 3 * n_dimsousmat; j < n_dimat; j++) + { for (i = 0; i < j; i++) + { mat(i, j) = mat(j, i); + } + } // initialisation of the Gauss algorithm double pivot_max = 1.e-12; @@ -859,28 +957,38 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang for (icoor = 1; icoor <= 3; icoor++) { for (i = 0; i < nCC1; i++) + { sec_member((icoor - 1) * n_dimsousmat + i) = myConstraints(i + 1).Value().Coord(icoor); + } k = nCC1; for (i = 1; i <= myLXYZConstraints.Length(); i++) + { for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) { for (int icol = 1; icol <= myLXYZConstraints(i).Coeff().RowLength(); icol++) + { sec_member((icoor - 1) * n_dimsousmat + k) += myLXYZConstraints(i).Coeff()(irow, icol) * myLXYZConstraints(i).GetPPC()(icol).Value().Coord(icoor); + } k++; } + } } k = 3 * n_dimsousmat; for (i = 1; i <= myLScalarConstraints.Length(); i++) + { for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) { for (int icol = 1; icol <= myLScalarConstraints(i).Coeff().RowLength(); icol++) + { sec_member(k) += myLScalarConstraints(i).Coeff()(irow, icol) * myLScalarConstraints(i).GetPPC()(icol).Value(); + } k++; } + } algo_gauss.Solve(sec_member, sol); // iteration to refine the solution @@ -898,7 +1006,9 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang for (icoor = 1; icoor <= 3; icoor++) { for (i = 0; i < nCC1; i++) + { Solution(i).SetCoord(icoor, sol((icoor - 1) * n_dimsousmat + i)); + } int kSolution = nCC1; int ksol = nCC1; @@ -909,8 +1019,10 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang { double vsol = 0; for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) + { vsol += myLXYZConstraints(i).Coeff()(irow, icol) * sol((icoor - 1) * n_dimsousmat + ksol + irow - 1); + } Solution(kSolution).SetCoord(icoor, vsol); kSolution++; } @@ -932,7 +1044,9 @@ void Plate_Plate::SolveTI3(const int IterationNumber, const Message_ProgressRang { gp_XYZ Vsol(0., 0., 0.); for (int irow = 1; irow <= myLScalarConstraints(i).Coeff().ColLength(); irow++) + { Vsol += myLScalarConstraints(i).Coeff()(irow, icol) * sol(ksol + irow - 1); + } Solution(kSolution) = Vsol; kSolution++; } @@ -956,7 +1070,9 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, { double signe = 1; if (((Deru(j) + Derv(j)) % 2) == 1) + { signe = -1; + } int iu = Deru(i) + Deru(j); int iv = Derv(i) + Derv(j); mat(i0 + i, j0 + j) = signe * SolEm(Points(i) - Points(j), iu, iv); @@ -977,15 +1093,21 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, { double signe = 1; if (((Deru(a_j) + Derv(a_j)) % 2) == 1) + { signe = -1; + } int iu = Deru(kppc + ippc - 1) + Deru(a_j); int iv = Derv(kppc + ippc - 1) + Derv(a_j); vmat(ippc) = signe * SolEm(Points(kppc + ippc - 1) - Points(a_j), iu, iv); } for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) + { for (int icol = 1; icol <= myLXYZConstraints(i).Coeff().RowLength(); icol++) + { mat(i0 + k + irow - 1, j0 + a_j) += myLXYZConstraints(i).Coeff()(irow, icol) * vmat(icol); + } + } } int k2 = ncc1; @@ -999,24 +1121,36 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, myLXYZConstraints(i2).GetPPC().Length()); for (int ippc = 1; ippc <= myLXYZConstraints(i).GetPPC().Length(); ippc++) + { for (int ippc2 = 1; ippc2 <= myLXYZConstraints(i2).GetPPC().Length(); ippc2++) { double signe = 1; if (((Deru(kppc2 + ippc2 - 1) + Derv(kppc2 + ippc2 - 1)) % 2) == 1) + { signe = -1; + } int iu = Deru(kppc + ippc - 1) + Deru(kppc2 + ippc2 - 1); int iv = Derv(kppc + ippc - 1) + Derv(kppc2 + ippc2 - 1); tmpmat(ippc, ippc2) = signe * SolEm(Points(kppc + ippc - 1) - Points(kppc2 + ippc2 - 1), iu, iv); } + } for (int irow = 1; irow <= myLXYZConstraints(i).Coeff().ColLength(); irow++) + { for (int irow2 = 1; irow2 <= myLXYZConstraints(i2).Coeff().ColLength(); irow2++) + { for (int icol = 1; icol <= myLXYZConstraints(i).Coeff().RowLength(); icol++) + { for (int icol2 = 1; icol2 <= myLXYZConstraints(i2).Coeff().RowLength(); icol2++) + { mat(i0 + k + irow - 1, j0 + k2 + irow2 - 1) += myLXYZConstraints(i).Coeff()(irow, icol) * myLXYZConstraints(i2).Coeff()(irow2, icol2) * tmpmat(icol, icol2); + } + } + } + } k2 += myLXYZConstraints(i2).Coeff().ColLength(); kppc2 += myLXYZConstraints(i2).Coeff().RowLength(); @@ -1028,6 +1162,7 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, i = ncc1 + ncc2; for (int iu = 0; iu < order; iu++) + { for (int iv = 0; iu + iv < order; iv++) { for (int a_j = 0; a_j < ncc1; a_j++) @@ -1050,9 +1185,13 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, } for (int irow2 = 1; irow2 <= myLXYZConstraints(i2).Coeff().ColLength(); irow2++) + { for (int icol2 = 1; icol2 <= myLXYZConstraints(i2).Coeff().RowLength(); icol2++) + { mat(i0 + i, j0 + k2 + irow2 - 1) += myLXYZConstraints(i2).Coeff()(irow2, icol2) * vmat(icol2); + } + } k2 += myLXYZConstraints(i2).Coeff().ColLength(); kppc2 += myLXYZConstraints(i2).Coeff().RowLength(); @@ -1060,6 +1199,7 @@ void Plate_Plate::fillXYZmatrix(math_Matrix& mat, i++; } + } int n_dimat = ncc1 + ncc2 + order * (order + 1) / 2; @@ -1118,9 +1258,13 @@ void Plate_Plate::Init() gp_XYZ Plate_Plate::Evaluate(const gp_XY& point2d) const { if (solution == nullptr) + { return gp_XYZ(0, 0, 0); + } if (!OK) + { return gp_XYZ(0, 0, 0); + } gp_XYZ valeur(0, 0, 0); @@ -1130,17 +1274,21 @@ gp_XYZ Plate_Plate::Evaluate(const gp_XY& point2d) const { double signe = 1; if (((Deru(i) + Derv(i)) % 2) == 1) + { signe = -1; + } valeur += Solution(i) * (signe * SolEm(point2d - Points(i), Deru(i), Derv(i))); } } int i = n_el; for (int idu = 0; idu < order; idu++) + { for (int idv = 0; idu + idv < order; idv++) { valeur += Solution(i) * Polm(point2d, idu, idv, 0, 0); i++; } + } return valeur; } @@ -1149,9 +1297,13 @@ gp_XYZ Plate_Plate::Evaluate(const gp_XY& point2d) const gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const int iu, const int iv) const { if (solution == nullptr) + { return gp_XYZ(0, 0, 0); + } if (!OK) + { return gp_XYZ(0, 0, 0); + } gp_XYZ valeur(0, 0, 0); if (!PolynomialPartOnly) @@ -1160,17 +1312,21 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const int iu, const { double signe = 1; if (((Deru(i) + Derv(i)) % 2) == 1) + { signe = -1; + } valeur += Solution(i) * (signe * SolEm(point2d - Points(i), Deru(i) + iu, Derv(i) + iv)); } } int i = n_el; for (int idu = 0; idu < order; idu++) + { for (int idv = 0; idu + idv < order; idv++) { valeur += Solution(i) * Polm(point2d, idu, idv, iu, iv); i++; } + } return valeur; } @@ -1186,6 +1342,7 @@ occ::handle> Plate_Plate::CoefPol() const new NCollection_HArray2(0, order - 1, 0, order - 1, gp_XYZ(0., 0., 0.)); int i = n_el; for (int iu = 0; iu < order; iu++) + { for (int iv = 0; iu + iv < order; iv++) { aCoefs->ChangeValue(iu, iv) = Solution(i) * ddu[iu] * ddv[iv]; @@ -1193,6 +1350,7 @@ occ::handle> Plate_Plate::CoefPol() const // it is necessary to reset this line if one remove factors in method Polm. i++; } + } return aCoefs; } @@ -1243,7 +1401,9 @@ double Plate_Plate::SolEm(const gp_XY& point2d, const int iu, const int iv) cons if ((U == Uold) && (V == Vold)) { if (R < 1.e-20) + { return 0; + } } else { @@ -1252,7 +1412,9 @@ double Plate_Plate::SolEm(const gp_XY& point2d, const int iu, const int iv) cons aThis->U2 = U * U; aThis->R = U2 + V * V; if (R < 1.e-20) + { return 0; + } aThis->L = log(R); } double DUV = 0; @@ -1272,17 +1434,23 @@ double Plate_Plate::SolEm(const gp_XY& point2d, const int iu, const int iv) cons { pr = R; for (int i = 1; i < -expo; i++) + { pr *= R; + } pr = 1. / pr; } else if (expo > 0) { pr = R; for (int i = 1; i < expo; i++) + { pr *= R; + } } else + { pr = 1.; + } switch (IU) { @@ -1730,45 +1898,73 @@ void Plate_Plate::UVBox(double& UMin, double& UMax, double& VMin, double& VMax) { double x = myConstraints(i).Pnt2d().X(); if (x < UMin) + { UMin = x; + } if (x > UMax) + { UMax = x; + } double y = myConstraints(i).Pnt2d().Y(); if (y < VMin) + { VMin = y; + } if (y > VMax) + { VMax = y; + } } for (i = 1; i <= myLXYZConstraints.Length(); i++) + { for (int j = 1; j <= myLXYZConstraints(i).GetPPC().Length(); j++) { double x = myLXYZConstraints(i).GetPPC()(j).Pnt2d().X(); if (x < UMin) + { UMin = x; + } if (x > UMax) + { UMax = x; + } double y = myLXYZConstraints(i).GetPPC()(j).Pnt2d().Y(); if (y < VMin) + { VMin = y; + } if (y > VMax) + { VMax = y; + } } + } for (i = 1; i <= myLScalarConstraints.Length(); i++) + { for (int j = 1; j <= myLScalarConstraints(i).GetPPC().Length(); j++) { double x = myLScalarConstraints(i).GetPPC()(j).Pnt2d().X(); if (x < UMin) + { UMin = x; + } if (x > UMax) + { UMax = x; + } double y = myLScalarConstraints(i).GetPPC()(j).Pnt2d().Y(); if (y < VMin) + { VMin = y; + } if (y > VMax) + { VMax = y; + } } + } if (UMax - UMin < Bmin) { @@ -1791,7 +1987,9 @@ void Plate_Plate::UVConstraints(NCollection_Sequence& Seq) const for (int i = 1; i <= myConstraints.Length(); i++) { if ((myConstraints.Value(i).Idu() == 0) && (myConstraints.Value(i).Idv() == 0)) + { Seq.Append((myConstraints.Value(i)).Pnt2d()); + } } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_SampledCurveConstraint.cxx b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_SampledCurveConstraint.cxx index ef8be9c901..5b3ff634f7 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_SampledCurveConstraint.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/Plate/Plate_SampledCurveConstraint.cxx @@ -23,10 +23,14 @@ static inline double B0(double t) { double s = t; if (s < 0.) + { s = -s; + } s = 1. - s; if (s < 0.) + { s = 0; + } return s; } @@ -38,14 +42,20 @@ Plate_SampledCurveConstraint::Plate_SampledCurveConstraint( int m = SOPPC.Length(); if (n > m) + { throw Standard_DimensionMismatch(); + } for (int index = 1; index <= m; index++) + { myLXYZC.SetPPC(index, SOPPC(index)); + } double ratio = double(n + 1) / double(m + 1); for (int i = 1; i <= n; i++) + { for (int j = 1; j <= m; j++) { myLXYZC.SetCoeff(i, j, B0(ratio * j - i)); } + } } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_CurveTransition.cxx b/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_CurveTransition.cxx index 8494fccd3e..489ecef0a0 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_CurveTransition.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_CurveTransition.cxx @@ -82,9 +82,13 @@ void TopTrans_CurveTransition::Compare(const double Tole, if (S == TopAbs_INTERNAL) { if (T * myTgt < 0) + { S = TopAbs::Reverse(O); + } else + { S = O; + } } // It is the first comparison for this complex transition @@ -110,9 +114,13 @@ void TopTrans_CurveTransition::Compare(const double Tole, // Interference en milieu d'arete il faut inverser en fonction de la // position de la tangente de reference if (myTgt * T > 0) + { TgtFirst.Reverse(); + } else + { TgtLast.Reverse(); + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -132,7 +140,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, break; case TopAbs_INTERNAL: if (cosAngWithT > 0) + { cosAngWithT = -cosAngWithT; + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -154,7 +164,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, break; case TopAbs_INTERNAL: if (myTgt * T > 0) + { TgtFirst.Reverse(); + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -178,7 +190,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, break; case TopAbs_INTERNAL: if (myTgt * T > 0) + { TgtFirst.Reverse(); + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -198,7 +212,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, { // Dans les cas de tangence le premier peut etre aussi le dernier if (O == TopAbs_INTERNAL) + { cosAngWithT = -cosAngWithT; + } double cosAngWith2 = myTgt * TgtLast; switch (Compare(cosAngWithT, cosAngWith2, Tole)) @@ -214,7 +230,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, break; case TopAbs_INTERNAL: if (myTgt * T < 0) + { TgtLast.Reverse(); + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -237,7 +255,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, break; case TopAbs_INTERNAL: if (myTgt * T < 0) + { TgtLast.Reverse(); + } break; case TopAbs_FORWARD: case TopAbs_EXTERNAL: @@ -260,7 +280,9 @@ void TopTrans_CurveTransition::Compare(const double Tole, TopAbs_State TopTrans_CurveTransition::StateBefore() const { if (Init) + { return TopAbs_UNKNOWN; + } switch (TranFirst) { case TopAbs_FORWARD: @@ -281,7 +303,9 @@ TopAbs_State TopTrans_CurveTransition::StateBefore() const TopAbs_State TopTrans_CurveTransition::StateAfter() const { if (Init) + { return TopAbs_UNKNOWN; + } switch (TranLast) { case TopAbs_FORWARD: @@ -320,10 +344,14 @@ bool TopTrans_CurveTransition::IsBefore(const double Tole, // The reference is straight // The first is the interference which have the lowest curvature. if (C1 < C2) + { OneBefore = true; + } // Modified by Sergey KHROMOV - Wed Dec 27 17:08:49 2000 Begin if (CosAngl > 0) + { OneBefore = !OneBefore; + } // Modified by Sergey KHROMOV - Wed Dec 27 17:08:50 2000 End } else @@ -349,9 +377,13 @@ bool TopTrans_CurveTransition::IsBefore(const double Tole, deltaC2 = (C2 - myCurv) * (N2 * myNorm); } if (deltaC1 < deltaC2) + { OneBefore = true; + } if (CosAngl > 0) + { OneBefore = !OneBefore; + } } } else if (TN1 < 0) @@ -397,9 +429,13 @@ int TopTrans_CurveTransition::Compare(const double Ang1, const double Ang2, cons { int res = SAME; if (Ang1 - Ang2 > Tole) + { res = GREATER; + } else if (Ang2 - Ang1 > Tole) + { res = LOWER; + } return res; } diff --git a/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_SurfaceTransition.cxx b/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_SurfaceTransition.cxx index 4c452a0184..54bd31087c 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_SurfaceTransition.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/TopTrans/TopTrans_SurfaceTransition.cxx @@ -40,9 +40,13 @@ static gp_Dir FUN_nCinsideS(const gp_Dir& tgC, const gp_Dir& ngS) static int FUN_OO(const int i) { if (i == 1) + { return 2; + } if (i == 2) + { return 1; + } return 0; } @@ -55,7 +59,9 @@ static double FUN_Ang(const gp_Dir&, { gp_Dir dironF = FUN_nCinsideS(TgC, Norm); if (M_REVERSED(O)) + { dironF.Reverse(); + } double ang = beafter.AngleWithRef(dironF, TgC); return ang; @@ -68,13 +74,21 @@ static void FUN_getSTA(const double Ang, const double tola, int& i, int& j) bool nullcos = std::abs(cos) < tola; bool nullsin = std::abs(sin) < tola; if (nullcos) + { i = 0; + } else + { i = (cos > 0.) ? 1 : 2; + } if (nullsin) + { j = 0; + } else + { j = (sin > 0.) ? 1 : 2; + } } /*static void FUN_getSTA(const double Ang, const double tola, @@ -111,7 +125,9 @@ static int FUN_refnearest(const double Angref, { bool undef = (Angref == 100.); if (undef) + { return M_updateREF; + } double cosref = std::cos(Angref), cos = std::cos(Ang); double dcos = std::abs(cosref) - std::abs(cos); @@ -122,9 +138,13 @@ static int FUN_refnearest(const double Angref, // we choose INTERNAL as resulting complex transition (case EXTERNAL // referring to no logical case) if (TopAbs::Complement(Ori) == Oriref) + { return M_Ointernal; + } else + { return (int)M_Unknown; // nyi FUN_RAISE + } } int updateref = (dcos > 0.) ? M_noupdate : M_updateREF; return updateref; @@ -159,21 +179,33 @@ static int FUN_refnearest(const int i, if (i0) { if (iisj && curvneg) + { return M_noupdate; + } if (!iisj && curvpos) + { return M_noupdate; + } } if (j0) { if (!nullcsref && (j == 1) && iisj && (curvpos || nullcurv)) + { return M_updateREF; + } if (!nullcsref && (j == 1) && !iisj && (curvneg || nullcurv)) + { return M_updateREF; + } if (iisj && curvpos) + { return M_noupdate; + } if (!iisj && curvneg) + { return M_noupdate; + } } return M_updateREF; } // undef @@ -189,35 +221,51 @@ static int FUN_refnearest(const int i, if (std::abs(Curvref - Curv) < 1.e-4) { if (TopAbs::Complement(Ori) == Oriref) + { return M_Ointernal; + } else + { return (int)M_Unknown; // nyi FUN_RAISE + } } bool noupdate = false; if (iisj && (Curvref > Curv)) + { noupdate = true; + } if (!iisj && (Curvref < Curv)) + { noupdate = true; + } int updateref = noupdate ? M_noupdate : M_updateREF; if (!j0) + { return updateref; + } if (!noupdate && !nullcsref) { // check for (j==1) the face is ABOVE Sref // check for (j==2) the face is BELOW Sref if ((j == 2) && (std::abs(Curv) < CurvSref)) + { updateref = M_noupdate; + } if ((j == 1) && (std::abs(Curv) > CurvSref)) + { updateref = M_noupdate; + } } return updateref; } // samecos int updateref = (dcos > 0.) ? M_noupdate : M_updateREF; if (Oriref != Ori) + { TouchFlag = true; // eap Mar 25 2002 + } return updateref; } @@ -269,11 +317,17 @@ void TopTrans_SurfaceTransition::Reset(const gp_Dir& Tgt, } if (curismax) + { myCurvRef = std::abs(MaxCurv); + } if (curismin) + { myCurvRef = std::abs(MinCurv); + } if (myCurvRef < tola) + { myCurvRef = 0.; + } // ============================================================ // recall : is oriented OUTSIDE the "geometric matter" described @@ -283,8 +337,12 @@ void TopTrans_SurfaceTransition::Reset(const gp_Dir& Tgt, // ============================================================ for (int i = 1; i <= 2; i++) + { for (int j = 1; j <= 2; j++) + { myAng(i, j) = 100.; + } + } myTouchFlag = false; // eap Mar 25 2002 myIsDefined = true; @@ -299,8 +357,12 @@ void TopTrans_SurfaceTransition::Reset(const gp_Dir& Tgt, const gp_Dir& Norm) myTgt = Tgt; beafter = Norm ^ Tgt; for (int i = 1; i <= 2; i++) + { for (int j = 1; j <= 2; j++) + { myAng(i, j) = 100.; + } + } myCurvRef = 0.; myTouchFlag = false; // eap Mar 25 2002 @@ -317,7 +379,9 @@ void TopTrans_SurfaceTransition::Compare(const double Tole, const TopAbs_Orientation O) { if (!myIsDefined) + { return; + } double Curv = 0.; // ------ @@ -335,15 +399,23 @@ void TopTrans_SurfaceTransition::Compare(const double Tole, return; } if (curismax) + { Curv = std::abs(MaxCurv); + } if (curismin) + { Curv = std::abs(MinCurv); + } if (myCurvRef < tola) + { Curv = 0.; + } gp_Dir dironF = FUN_nCinsideS(myTgt, Norm); double prod = (dironF ^ Norm).Dot(myTgt); if (prod < 0.) + { Curv = -Curv; + } double Ang; // ----- @@ -371,9 +443,13 @@ void TopTrans_SurfaceTransition::Compare(const double Tole, for (int n = 1; n <= nmax; n++) { if (i0) + { i = n; + } if (j0) + { j = n; + } // if (curvref == 0.) : // bool iisj = (i == j); @@ -419,7 +495,9 @@ void TopTrans_SurfaceTransition::Compare(const double Tole, const TopAbs_Orientation O) { if (!myIsDefined) + { return; + } // oriented Ang(beafter,dironF), // dironF normal to the curve, oriented INSIDE F, the added oriented support @@ -446,9 +524,13 @@ void TopTrans_SurfaceTransition::Compare(const double Tole, for (int n = 1; n <= nmax; n++) { if (i0) + { i = n; + } if (j0) + { j = n; + } int refn = ::FUN_refnearest(myAng(i, j), myOri(i, j), Ang, /*O*/ S, tola); // eap if (refn == M_Unknown) @@ -478,7 +560,9 @@ static TopAbs_State FUN_getstate(const NCollection_Array2& A bool undef1 = (a1 == 100.), undef2 = (a2 == 100.); bool undef = undef1 && undef2; if (undef) + { return TopAbs_UNKNOWN; + } if (undef1 || undef2) { @@ -495,14 +579,18 @@ static TopAbs_State FUN_getstate(const NCollection_Array2& A TopAbs_State st2 = (iINDEX == BEFORE) ? TopTrans_SurfaceTransition::GetBefore(o2) : TopTrans_SurfaceTransition::GetAfter(o2); if (st1 != st2) + { return TopAbs_UNKNOWN; // Incoherent data + } return st1; } TopAbs_State TopTrans_SurfaceTransition::StateBefore() const { if (!myIsDefined) + { return TopAbs_UNKNOWN; + } // we take the state before of before orientations TopAbs_State before = ::FUN_getstate(myAng, myOri, BEFORE, BEFORE); @@ -515,9 +603,13 @@ TopAbs_State TopTrans_SurfaceTransition::StateBefore() const if (myTouchFlag) { if (before == TopAbs_OUT) + { before = TopAbs_IN; + } else if (before == TopAbs_IN) + { before = TopAbs_OUT; + } } } return before; @@ -526,7 +618,9 @@ TopAbs_State TopTrans_SurfaceTransition::StateBefore() const TopAbs_State TopTrans_SurfaceTransition::StateAfter() const { if (!myIsDefined) + { return TopAbs_UNKNOWN; + } TopAbs_State after = ::FUN_getstate(myAng, myOri, AFTER, AFTER); if (M_UNKNOWN(after)) @@ -537,9 +631,13 @@ TopAbs_State TopTrans_SurfaceTransition::StateAfter() const if (myTouchFlag) { if (after == TopAbs_OUT) + { after = TopAbs_IN; + } else if (after == TopAbs_IN) + { after = TopAbs_OUT; + } } } return after; diff --git a/src/ModelingAlgorithms/TKHLR/Contap/Contap_Contour.cxx b/src/ModelingAlgorithms/TKHLR/Contap/Contap_Contour.cxx index e92d66af4f..2693810534 100644 --- a/src/ModelingAlgorithms/TKHLR/Contap/Contap_Contour.cxx +++ b/src/ModelingAlgorithms/TKHLR/Contap/Contap_Contour.cxx @@ -320,10 +320,14 @@ static void LineConstructor(NCollection_Sequence& slin, { double aSqDist = L.Point(j).Value().SquareDistance(L.Point(j - 1).Value()); if (aSqDist > gp::Resolution()) + { LineOn2S->Add(L.Point(j)); + } } if (LineOn2S->NbPoints() < 2) + { continue; + } Contap_Line Line; Line.SetLineOn2S(LineOn2S); Contap_Point pvtx = L.Vertex(i); @@ -394,7 +398,9 @@ static void LineConstructor(NCollection_Sequence& slin, //-- std::cout<<" Circ -> "<& Domain) dx = dy = dz = 1.0; } if (dx < dy) + { dx = dy; + } if (dx < dz) + { dx = dz; + } if (dx > 10000.0) + { dx = 10000.0; + } Fleche *= dx; TolArc *= dx; //-- ******************************************************************************** @@ -2055,7 +2067,9 @@ static void PutPointsOnLine(const Contap_TheSearch& solrst, { tgtrst = d1v.Crossed(normale); if (d2d.X() < 0.0) + { tgtrst.Reverse(); + } } else { diff --git a/src/ModelingAlgorithms/TKHLR/Contap/Contap_HContTool.cxx b/src/ModelingAlgorithms/TKHLR/Contap/Contap_HContTool.cxx index d4fc1f4867..eb919ab365 100644 --- a/src/ModelingAlgorithms/TKHLR/Contap/Contap_HContTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/Contap/Contap_HContTool.cxx @@ -44,7 +44,9 @@ int Contap_HContTool::NbSamplesV(const occ::handle& S, nbs = S->NbVKnots(); nbs *= S->VDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Cylinder: @@ -86,7 +88,9 @@ int Contap_HContTool::NbSamplesU(const occ::handle& S, nbs = S->NbUKnots(); nbs *= S->UDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Torus: { @@ -160,12 +164,18 @@ int Contap_HContTool::NbSamplePoints(const occ::handle& S) { int m = (NbSamplesU(S, uinf, usup) / 3) * (NbSamplesV(S, vinf, vsup) / 3); if (m > 5) + { return (m); + } else + { return (5); + } } else + { return 5; + } } void Contap_HContTool::SamplePoint(const occ::handle& S, diff --git a/src/ModelingAlgorithms/TKHLR/Contap/Contap_HCurve2dTool.cxx b/src/ModelingAlgorithms/TKHLR/Contap/Contap_HCurve2dTool.cxx index 06f329ff46..023f1b6dd9 100644 --- a/src/ModelingAlgorithms/TKHLR/Contap/Contap_HCurve2dTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/Contap/Contap_HCurve2dTool.cxx @@ -37,12 +37,16 @@ int Contap_HCurve2dTool::NbSamples(const occ::handle& C, nbs *= C->LastParameter() - C->FirstParameter(); nbs /= U1 - U0; if (nbs < 2.0) + { nbs = 2.; + } break; default: break; } if (nbs > 50.) + { nbs = 50.; + } return ((int)nbs); } diff --git a/src/ModelingAlgorithms/TKHLR/Contap/Contap_Line.cxx b/src/ModelingAlgorithms/TKHLR/Contap/Contap_Line.cxx index 150cbd7d8b..c19a1855c5 100644 --- a/src/ModelingAlgorithms/TKHLR/Contap/Contap_Line.cxx +++ b/src/ModelingAlgorithms/TKHLR/Contap/Contap_Line.cxx @@ -65,7 +65,9 @@ void Contap_Line::Add(const Contap_Point& P) void Contap_Line::Clear() { if (!curv.IsNull()) + { curv->Clear(); + } svtx = new NCollection_HSequence(); typL = Contap_Walking; } diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeIterator.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeIterator.cxx index 48cea61541..cd7a4f88db 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeIterator.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeIterator.cxx @@ -58,7 +58,9 @@ void HLRAlgo_EdgeIterator::InitHidden(HLRAlgo_EdgeStatus& status) } if (myHidStart + myHidTolStart >= myHidEnd - myHidTolEnd && myHidEnd + myHidTolEnd >= myHidStart - myHidTolStart) + { NextHidden(); + } } //================================================================================================= @@ -66,7 +68,9 @@ void HLRAlgo_EdgeIterator::InitHidden(HLRAlgo_EdgeStatus& status) void HLRAlgo_EdgeIterator::NextHidden() { if (iHid >= myNbHid + 1) + { iHid++; + } else { double B1; @@ -78,9 +82,13 @@ void HLRAlgo_EdgeIterator::NextHidden() ((HLRAlgo_EdgeStatus*)EHid)->Bounds(B1, B2, myHidEnd, myHidTolEnd); if (myHidStart + myHidTolStart >= myHidEnd - myHidTolEnd && myHidEnd + myHidTolEnd >= myHidStart - myHidTolStart) + { iHid++; + } } else + { ((HLRAlgo_EdgeStatus*)EHid)->VisiblePart(iHid, myHidEnd, myHidTolEnd, B1, B2); + } } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeStatus.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeStatus.cxx index 8ed62c0915..a25722d664 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeStatus.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_EdgeStatus.cxx @@ -67,11 +67,17 @@ void HLRAlgo_EdgeStatus::Initialize(const double Start, int HLRAlgo_EdgeStatus::NbVisiblePart() const { if (AllHidden()) + { return 0; + } else if (AllVisible()) + { return 1; + } else + { return myVisibles.NbIntervals(); + } } //================================================================================================= @@ -83,9 +89,13 @@ void HLRAlgo_EdgeStatus::VisiblePart(const int Index, float& TolEnd) const { if (AllVisible()) + { Bounds(Start, TolStart, End, TolEnd); + } else + { myVisibles.Value(Index).Bounds(Start, TolStart, End, TolEnd); + } } //================================================================================================= @@ -106,6 +116,8 @@ void HLRAlgo_EdgeStatus::Hide(const double Start, } myVisibles.Subtract(Intrv_Interval(Start, TolStart, End, TolEnd)); if (!AllHidden()) + { AllHidden(myVisibles.NbIntervals() == 0); + } } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyAlgo.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyAlgo.cxx index 9c8b51421b..f272e452ae 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyAlgo.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyAlgo.cxx @@ -82,9 +82,13 @@ void HLRAlgo_PolyAlgo::Update() double dz = aZMax - aZMin; double precad = dx; if (precad < dy) + { precad = dy; + } if (precad < dz) + { precad = dz; + } myTriangle.Tolerance = precad * myTriangle.TolParam; precad = precad * 0.01; double SurDX = 1020 / (dx + precad); @@ -154,17 +158,29 @@ void HLRAlgo_PolyAlgo::Update() theIndices.MaxSeg <<= 10; theIndices.MaxSeg += nzMax + 0x00000200; if (xShellMin > xSegmnMin) + { xShellMin = xSegmnMin; + } if (xShellMax < xSegmnMax) + { xShellMax = xSegmnMax; + } if (yShellMin > ySegmnMin) + { yShellMin = ySegmnMin; + } if (yShellMax < ySegmnMax) + { yShellMax = ySegmnMax; + } if (zShellMin > zSegmnMin) + { zShellMin = zSegmnMin; + } if (zShellMax < zSegmnMax) + { zShellMax = zSegmnMax; + } } NCollection_Array1>& aPolyg = aPsd->PolyData(); const int nbFace = aPolyg.Upper(); @@ -213,29 +229,53 @@ void HLRAlgo_PolyAlgo::Update() yTrianMax = yTrianMin = Y1; zTrianMax = zTrianMin = Z1; if (xTrianMin > X2) + { xTrianMin = X2; + } else if (xTrianMax < X2) + { xTrianMax = X2; + } if (yTrianMin > Y2) + { yTrianMin = Y2; + } else if (yTrianMax < Y2) + { yTrianMax = Y2; + } if (zTrianMin > Z2) + { zTrianMin = Z2; + } else if (zTrianMax < Z2) + { zTrianMax = Z2; + } if (xTrianMin > X3) + { xTrianMin = X3; + } else if (xTrianMax < X3) + { xTrianMax = X3; + } if (yTrianMin > Y3) + { yTrianMin = Y3; + } else if (yTrianMax < Y3) + { yTrianMax = Y3; + } if (zTrianMin > Z3) + { zTrianMin = Z3; + } else if (zTrianMax < Z3) + { zTrianMax = Z3; + } nxMin = (int)((DecaX + xTrianMin) * SurDX); nyMin = (int)((DecaY + yTrianMin) * SurDY); nzMin = (int)((DecaZ + zTrianMin) * SurDZ); @@ -273,45 +313,81 @@ void HLRAlgo_PolyAlgo::Update() adx1 = dx1; ady1 = dy1; if (dx1 < 0) + { adx1 = -dx1; + } if (dy1 < 0) + { ady1 = -dy1; + } adx2 = dx2; ady2 = dy2; if (dx2 < 0) + { adx2 = -dx2; + } if (dy2 < 0) + { ady2 = -dy2; + } adx3 = dx3; ady3 = dy3; if (dx3 < 0) + { adx3 = -dx3; + } if (dy3 < 0) + { ady3 = -dy3; + } if (adx1 > ady1) + { aTD.Flags |= HLRAlgo_PolyMask_EMskGrALin1; + } else + { aTD.Flags &= ~HLRAlgo_PolyMask_EMskGrALin1; + } if (adx2 > ady2) + { aTD.Flags |= HLRAlgo_PolyMask_EMskGrALin2; + } else + { aTD.Flags &= ~HLRAlgo_PolyMask_EMskGrALin2; + } if (adx3 > ady3) + { aTD.Flags |= HLRAlgo_PolyMask_EMskGrALin3; + } else + { aTD.Flags &= ~HLRAlgo_PolyMask_EMskGrALin3; + } if (xPolyTMin > xTrianMin) + { xPolyTMin = xTrianMin; + } if (xPolyTMax < xTrianMax) + { xPolyTMax = xTrianMax; + } if (yPolyTMin > yTrianMin) + { yPolyTMin = yTrianMin; + } if (yPolyTMax < yTrianMax) + { yPolyTMax = yTrianMax; + } if (zPolyTMin > zTrianMin) + { zPolyTMin = zTrianMin; + } if (zPolyTMax < zTrianMax) + { zPolyTMax = zTrianMax; + } } } nxMin = (int)((DecaX + xPolyTMin) * SurDX); @@ -327,17 +403,29 @@ void HLRAlgo_PolyAlgo::Update() PolyTIndices.Max <<= 10; PolyTIndices.Max += nzMax; if (xShellMin > xPolyTMin) + { xShellMin = xPolyTMin; + } if (xShellMax < xPolyTMax) + { xShellMax = xPolyTMax; + } if (yShellMin > yPolyTMin) + { yShellMin = yPolyTMin; + } if (yShellMax < yPolyTMax) + { yShellMax = yPolyTMax; + } if (zShellMin > zPolyTMin) + { zShellMin = zPolyTMin; + } if (zShellMax < zPolyTMax) + { zShellMax = zPolyTMax; + } } } if (nbFaHi > 0) @@ -383,7 +471,9 @@ void HLRAlgo_PolyAlgo::NextHide() { mySegListIt.Next(); if (mySegListIt.More()) + { myFound = true; + } } if (!myFound) @@ -464,7 +554,9 @@ void HLRAlgo_PolyAlgo::NextShow() { mySegListIt.Next(); if (mySegListIt.More()) + { myFound = true; + } } if (!myFound) { diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyData.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyData.cxx index 561d2f8a88..b208f1b041 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyData.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyData.cxx @@ -109,26 +109,38 @@ void HLRAlgo_PolyData::HideByPolyData(const HLRAlgo_BiPoint::PointsT& thePoints, if (myFaceIndices.Index == theIndices.FaceConex1) { if (theIndices.Face1Pt1 == aTriangle.Node1) + { NotConnex = theIndices.Face1Pt2 != aTriangle.Node2 && theIndices.Face1Pt2 != aTriangle.Node3; + } else if (theIndices.Face1Pt1 == aTriangle.Node2) + { NotConnex = theIndices.Face1Pt2 != aTriangle.Node3 && theIndices.Face1Pt2 != aTriangle.Node1; + } else if (theIndices.Face1Pt1 == aTriangle.Node3) + { NotConnex = theIndices.Face1Pt2 != aTriangle.Node1 && theIndices.Face1Pt2 != aTriangle.Node2; + } } else if (myFaceIndices.Index == theIndices.FaceConex2) { if (theIndices.Face2Pt1 == aTriangle.Node1) + { NotConnex = theIndices.Face2Pt2 != aTriangle.Node2 && theIndices.Face2Pt2 != aTriangle.Node3; + } else if (theIndices.Face2Pt1 == aTriangle.Node2) + { NotConnex = theIndices.Face2Pt2 != aTriangle.Node3 && theIndices.Face2Pt2 != aTriangle.Node1; + } else if (theIndices.Face2Pt1 == aTriangle.Node3) + { NotConnex = theIndices.Face2Pt2 != aTriangle.Node1 && theIndices.Face2Pt2 != aTriangle.Node2; + } } } if (NotConnex) @@ -239,7 +251,9 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { CrosSeg = false; + } } else if (d1 < -theTriangle.Tolerance) { @@ -249,14 +263,20 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { return; + } } else { if (d2 > theTriangle.Tolerance) + { CrosSeg = false; + } else if (d2 < -theTriangle.Tolerance) + { return; + } else { CrosSeg = false; @@ -271,67 +291,107 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin pd2 = (thePoints.PntP2.Y() - theTriangle.V1.Y()) / aD.Y(); } if (pd1 < -theTriangle.TolParam) + { nn1 = 1; + } else if (pd1 < theTriangle.TolParam) + { nn1 = 2; + } else if (pd1 - 1. < -theTriangle.TolParam) + { nn1 = 3; + } else if (pd1 - 1. < theTriangle.TolParam) + { nn1 = 4; + } else + { nn1 = 5; + } if (pd2 < -theTriangle.TolParam) + { nn2 = 1; + } else if (pd2 < theTriangle.TolParam) + { nn2 = 2; + } else if (pd2 - 1. < -theTriangle.TolParam) + { nn2 = 3; + } else if (pd2 - 1. < theTriangle.TolParam) + { nn2 = 4; + } else + { nn2 = 5; + } if (nn1 == 3) { if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 1) { if (nn2 <= 2) + { return; + } else { psta = -pd1 / (pd2 - pd1); if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } } else if (nn1 == 5) { if (nn2 >= 4) + { return; + } else { psta = (pd1 - 1.) / (pd1 - pd2); if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } else if (nn1 == 2) { if (nn2 == 1) + { return; + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 4) { if (nn2 == 5) + { return; + } else if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } } @@ -339,23 +399,33 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin { double ad1 = d1; if (d1 < 0) + { ad1 = -d1; + } double ad2 = d2; if (d2 < 0) + { ad2 = -d2; + } pp = ad1 / (ad1 + ad2); if (TrFlags & HLRAlgo_PolyMask_EMskGrALin1) + { pdp = (thePoints.PntP1.X() + (thePoints.PntP2.X() - thePoints.PntP1.X()) * pp - theTriangle.V1.X()) / aD.X(); + } else + { pdp = (thePoints.PntP1.Y() + (thePoints.PntP2.Y() - thePoints.PntP1.Y()) * pp - theTriangle.V1.Y()) / aD.Y(); + } bool OutSideP = false; bool Multiple = false; if (pdp < -theTriangle.TolParam) + { OutSideP = true; + } else if (pdp < theTriangle.TolParam) { Multiple = true; @@ -407,9 +477,13 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin } } else + { OutSideP = true; + } if (OutSideP) + { npiRej++; + } else { npi++; @@ -444,7 +518,9 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { CrosSeg = false; + } } else if (d1 < -theTriangle.Tolerance) { @@ -454,14 +530,20 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { return; + } } else { if (d2 > theTriangle.Tolerance) + { CrosSeg = false; + } else if (d2 < -theTriangle.Tolerance) + { return; + } else { CrosSeg = false; @@ -476,67 +558,107 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin pd2 = (thePoints.PntP2.Y() - theTriangle.V2.Y()) / aD.Y(); } if (pd1 < -theTriangle.TolParam) + { nn1 = 1; + } else if (pd1 < theTriangle.TolParam) + { nn1 = 2; + } else if (pd1 - 1. < -theTriangle.TolParam) + { nn1 = 3; + } else if (pd1 - 1. < theTriangle.TolParam) + { nn1 = 4; + } else + { nn1 = 5; + } if (pd2 < -theTriangle.TolParam) + { nn2 = 1; + } else if (pd2 < theTriangle.TolParam) + { nn2 = 2; + } else if (pd2 - 1. < -theTriangle.TolParam) + { nn2 = 3; + } else if (pd2 - 1. < theTriangle.TolParam) + { nn2 = 4; + } else + { nn2 = 5; + } if (nn1 == 3) { if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 1) { if (nn2 <= 2) + { return; + } else { psta = -pd1 / (pd2 - pd1); if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } } else if (nn1 == 5) { if (nn2 >= 4) + { return; + } else { psta = (pd1 - 1.) / (pd1 - pd2); if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } else if (nn1 == 2) { if (nn2 == 1) + { return; + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 4) { if (nn2 == 5) + { return; + } else if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } } @@ -544,23 +666,33 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin { double ad1 = d1; if (d1 < 0) + { ad1 = -d1; + } double ad2 = d2; if (d2 < 0) + { ad2 = -d2; + } pp = ad1 / (ad1 + ad2); if (TrFlags & HLRAlgo_PolyMask_EMskGrALin2) + { pdp = (thePoints.PntP1.X() + (thePoints.PntP2.X() - thePoints.PntP1.X()) * pp - theTriangle.V2.X()) / aD.X(); + } else + { pdp = (thePoints.PntP1.Y() + (thePoints.PntP2.Y() - thePoints.PntP1.Y()) * pp - theTriangle.V2.Y()) / aD.Y(); + } bool OutSideP = false; bool Multiple = false; if (pdp < -theTriangle.TolParam) + { OutSideP = true; + } else if (pdp < theTriangle.TolParam) { Multiple = true; @@ -611,9 +743,13 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin } } else + { OutSideP = true; + } if (OutSideP) + { npiRej++; + } else { npi++; @@ -648,7 +784,9 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { CrosSeg = false; + } } else if (d1 < -theTriangle.Tolerance) { @@ -658,14 +796,20 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin CrosSeg = true; } else + { return; + } } else { if (d2 > theTriangle.Tolerance) + { CrosSeg = false; + } else if (d2 < -theTriangle.Tolerance) + { return; + } else { CrosSeg = false; @@ -680,67 +824,107 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin pd2 = (thePoints.PntP2.Y() - theTriangle.V3.Y()) / aD.Y(); } if (pd1 < -theTriangle.TolParam) + { nn1 = 1; + } else if (pd1 < theTriangle.TolParam) + { nn1 = 2; + } else if (pd1 - 1. < -theTriangle.TolParam) + { nn1 = 3; + } else if (pd1 - 1. < theTriangle.TolParam) + { nn1 = 4; + } else + { nn1 = 5; + } if (pd2 < -theTriangle.TolParam) + { nn2 = 1; + } else if (pd2 < theTriangle.TolParam) + { nn2 = 2; + } else if (pd2 - 1. < -theTriangle.TolParam) + { nn2 = 3; + } else if (pd2 - 1. < theTriangle.TolParam) + { nn2 = 4; + } else + { nn2 = 5; + } if (nn1 == 3) { if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 1) { if (nn2 <= 2) + { return; + } else { psta = -pd1 / (pd2 - pd1); if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } } else if (nn1 == 5) { if (nn2 >= 4) + { return; + } else { psta = (pd1 - 1.) / (pd1 - pd2); if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } else if (nn1 == 2) { if (nn2 == 1) + { return; + } else if (nn2 == 5) + { pend = (1. - pd1) / (pd2 - pd1); + } } else if (nn1 == 4) { if (nn2 == 5) + { return; + } else if (nn2 == 1) + { pend = pd1 / (pd1 - pd2); + } } } } @@ -748,23 +932,33 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin { double ad1 = d1; if (d1 < 0) + { ad1 = -d1; + } double ad2 = d2; if (d2 < 0) + { ad2 = -d2; + } pp = ad1 / (ad1 + ad2); if (TrFlags & HLRAlgo_PolyMask_EMskGrALin3) + { pdp = (thePoints.PntP1.X() + (thePoints.PntP2.X() - thePoints.PntP1.X()) * pp - theTriangle.V3.X()) / aD.X(); + } else + { pdp = (thePoints.PntP1.Y() + (thePoints.PntP2.Y() - thePoints.PntP1.Y()) * pp - theTriangle.V3.Y()) / aD.Y(); + } bool OutSideP = false; bool Multiple = false; if (pdp < -theTriangle.TolParam) + { OutSideP = true; + } else if (pdp < theTriangle.TolParam) { Multiple = true; @@ -815,9 +1009,13 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin } } else + { OutSideP = true; + } if (OutSideP) + { npiRej++; + } else { npi++; @@ -841,7 +1039,9 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin if (npi == -1) { if (npiRej >= 2) + { return; + } } else if (npi == 0) { @@ -875,34 +1075,54 @@ void HLRAlgo_PolyData::hideByOneTriangle(const HLRAlgo_BiPoint::PointsT& thePoin if (HideBefore) { if (theTriangle.Param - psta < theTriangle.TolParam) + { return; + } else if (theTriangle.Param < pend) + { pend = theTriangle.Param; + } } else { if (pend - theTriangle.Param < theTriangle.TolParam) + { return; + } else if (psta < theTriangle.Param) + { psta = theTriangle.Param; + } } } bool total; if (psta > 0) + { total = psta < theTriangle.TolParam; + } else + { total = psta > -theTriangle.TolParam; + } if (total) { double pfin = pend - 1.; if (pfin > 0) + { total = pfin < theTriangle.TolParam; + } else + { total = pfin > -theTriangle.TolParam; + } } if (total) + { status.HideAll(); + } else + { status.Hide(psta, (float)theTriangle.TolParam, pend, (float)theTriangle.TolParam, false, false); + } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyInternalData.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyInternalData.cxx index f7fa3d35ae..14901fa202 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyInternalData.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_PolyInternalData.cxx @@ -99,17 +99,25 @@ void HLRAlgo_PolyInternalData::UpdateLinks( if (aSegIndices->LstSg1 == n1) { if (aSegIndices->LstSg2 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg1; + } icsv = 1; } else { if (aSegIndices->LstSg1 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg2; + } icsv = 2; } } @@ -118,12 +126,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( newSeg = true; myNbPISeg++; if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { aSegIndices->Conex2 = i; + } } else { @@ -152,12 +166,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( } } if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { A2.NdSg = myNbPISeg; + } } } if (newSeg) @@ -196,17 +216,25 @@ void HLRAlgo_PolyInternalData::UpdateLinks( if (aSegIndices->LstSg1 == n1) { if (aSegIndices->LstSg2 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg1; + } icsv = 1; } else { if (aSegIndices->LstSg1 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg2; + } icsv = 2; } } @@ -215,12 +243,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( newSeg = true; myNbPISeg++; if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { aSegIndices->Conex2 = i; + } } else { @@ -249,12 +283,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( } } if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { A3.NdSg = myNbPISeg; + } } } if (newSeg) @@ -293,17 +333,25 @@ void HLRAlgo_PolyInternalData::UpdateLinks( if (aSegIndices->LstSg1 == n1) { if (aSegIndices->LstSg2 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg1; + } icsv = 1; } else { if (aSegIndices->LstSg1 == n2) + { find = iiii; + } else + { iiii = aSegIndices->NxtSg2; + } icsv = 2; } } @@ -312,12 +360,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( newSeg = true; myNbPISeg++; if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { aSegIndices->Conex2 = i; + } } else { @@ -346,12 +400,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( } } if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else + { A1.NdSg = myNbPISeg; + } } } if (newSeg) @@ -457,11 +517,17 @@ void HLRAlgo_PolyInternalData::UpdateLinks( iip2 = aSegIndices2->NxtSg1; aSegIndices2->NxtSg1 = myNbPISeg; if (iisv == 0) + { aNodIndices2.NdSg = myNbPISeg; + } else if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else { @@ -481,11 +547,17 @@ void HLRAlgo_PolyInternalData::UpdateLinks( iip2 = aSegIndices2->NxtSg2; aSegIndices2->NxtSg2 = myNbPISeg; if (iisv == 0) + { aNodIndices2.NdSg = myNbPISeg; + } else if (icsv == 1) + { aSegIndices->NxtSg1 = myNbPISeg; + } else + { aSegIndices->NxtSg2 = myNbPISeg; + } } else { @@ -630,9 +702,13 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { iNew = New[iTr]; if (iTr < 2) + { skip = iTr; + } else + { skip = iTr - 2; + } iOld = New[skip]; ip4 = itpk[skip]; if (iNew != 0) @@ -657,12 +733,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg1; + } } else { @@ -670,12 +752,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg2; + } } } } @@ -695,12 +783,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg1; + } } else { @@ -708,12 +802,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg2; + } } } } @@ -733,12 +833,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg1; + } } else { @@ -746,12 +852,18 @@ void HLRAlgo_PolyInternalData::UpdateLinks( { found = true; if (aSegIndices2->Conex1 == iOld) + { aSegIndices2->Conex1 = iNew; + } else if (aSegIndices2->Conex2 == iOld) + { aSegIndices2->Conex2 = iNew; + } } else + { iiii = aSegIndices2->NxtSg2; + } } } } @@ -779,7 +891,7 @@ void HLRAlgo_PolyInternalData::Dump() const std::cout << std::setw(20) << Nod1RValues.Point.X(); std::cout << std::setw(20) << Nod1RValues.Point.Y(); std::cout << std::setw(20) << Nod1RValues.Point.Z(); - std::cout << std::endl; + std::cout << '\n'; } for (i = 1; i <= myNbPISeg; i++) @@ -792,7 +904,7 @@ void HLRAlgo_PolyInternalData::Dump() const std::cout << std::setw(6) << aSegIndices->NxtSg2; std::cout << std::setw(6) << aSegIndices->Conex1; std::cout << std::setw(6) << aSegIndices->Conex2; - std::cout << std::endl; + std::cout << '\n'; } for (i = 1; i <= myNbTData; i++) @@ -802,7 +914,7 @@ void HLRAlgo_PolyInternalData::Dump() const std::cout << std::setw(6) << aTriangle.Node1; std::cout << std::setw(6) << aTriangle.Node2; std::cout << std::setw(6) << aTriangle.Node3; - std::cout << std::endl; + std::cout << '\n'; } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_Projector.cxx b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_Projector.cxx index 58adaa9c31..22c5a94e22 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_Projector.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRAlgo/HLRAlgo_Projector.cxx @@ -214,7 +214,9 @@ void HLRAlgo_Projector::Project(const gp_Pnt& P, gp_Pnt2d& Pout) const Pout.SetCoord(P2.X() / R, P2.Y() / R); } else + { Pout.SetCoord(P2.X(), P2.Y()); + } break; } } @@ -229,7 +231,9 @@ void HLRAlgo_Projector::Project(const gp_Pnt& P, gp_Pnt2d& Pout) const Pout.SetCoord(P2.X() / R, P2.Y() / R); } else + { Pout.SetCoord(P2.X(), P2.Y()); + } } } @@ -361,19 +365,25 @@ void HLRAlgo_Projector::SetDirection() gp_Vec V1(1, 0, 0); V1.Transform(myTrsf); if ((std::abs(V1.X()) + std::abs(V1.Y())) < Precision::Angular()) + { V1.SetCoord(1, 1, 0); + } gp_Vec2d D1(V1.X(), V1.Y()); myD1.SetCoord(-D1.Y(), D1.X()); gp_Vec V2(0, 1, 0); V2.Transform(myTrsf); if ((std::abs(V2.X()) + std::abs(V2.Y())) < Precision::Angular()) + { V2.SetCoord(1, 1, 0); + } gp_Vec2d D2(V2.X(), V2.Y()); myD2.SetCoord(-D2.Y(), D2.X()); gp_Vec V3(0, 0, 1); V3.Transform(myTrsf); if ((std::abs(V3.X()) + std::abs(V3.Y())) < Precision::Angular()) + { V3.SetCoord(1, 1, 0); + } gp_Vec2d D3(V3.X(), V3.Y()); myD3.SetCoord(-D3.Y(), D3.X()); } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep.cxx index 3760331c32..6253babb71 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep.cxx @@ -78,7 +78,9 @@ TopoDS_Edge HLRBRep::MakeEdge(const HLRBRep_Curve& ec, const double U1, const do } BRepLib_MakeEdge2d mke2d(ec2d, sta, end); if (mke2d.IsDone()) + { Edg = mke2d.Edge(); + } break; } @@ -89,7 +91,9 @@ TopoDS_Edge HLRBRep::MakeEdge(const HLRBRep_Curve& ec, const double U1, const do double fpar, lpar; occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) + { aCurve = (occ::down_cast(aCurve))->BasisCurve(); + } occ::handle BSplCurve(occ::down_cast(aCurve)); occ::handle theCurve = occ::down_cast(BSplCurve->Copy()); @@ -143,7 +147,9 @@ TopoDS_Edge HLRBRep::MakeEdge(const HLRBRep_Curve& ec, const double U1, const do } BRepLib_MakeEdge2d mke2d(ec2d, sta, end); if (mke2d.IsDone()) + { Edg = mke2d.Edge(); + } break; } default: { @@ -168,7 +174,9 @@ TopoDS_Edge HLRBRep::MakeEdge(const HLRBRep_Curve& ec, const double U1, const do occ::handle ec2d = new Geom2d_BSplineCurve(Poles, knots, mults, 1); BRepLib_MakeEdge2d mke2d(ec2d, sta, end); if (mke2d.IsDone()) + { Edg = mke2d.Edge(); + } } } return Edg; @@ -201,14 +209,18 @@ TopoDS_Edge HLRBRep::MakeEdge3d(const HLRBRep_Curve& ec, const double U1, const constexpr double Tol = Precision::PConfusion(); if (std::abs(fpar - U1) <= Tol) + { V1new = V1; + } else { gp_Pnt aPnt = BAcurve.Value(U1); V1new = BRepLib_MakeVertex(aPnt); } if (std::abs(lpar - U2) <= Tol) + { V2new = V2; + } else { gp_Pnt aPnt = BAcurve.Value(U2); @@ -232,9 +244,13 @@ void HLRBRep::PolyHLRAngleAndDeflection(const double InAngl, double& OutAngl, do OutAngl = InAngl; if (OutAngl < HAngMin) + { OutAngl = HAngMin; + } if (OutAngl > HAngMax) + { OutAngl = HAngMax; + } OutAngl = HAngLim + sqrt((OutAngl - HAngMin) * (HAngMax - HAngLim) * (HAngMax - HAngLim) / (HAngMax - HAngMin)); diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Algo.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Algo.cxx index e1942a576b..2f9b157478 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Algo.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Algo.cxx @@ -61,9 +61,13 @@ int HLRBRep_Algo::Index(const TopoDS_Shape& S) for (int i = 1; i <= n; i++) { if (ShapeBounds(i).Shape()->OriginalShape() == S) + { return i; + } if (ShapeBounds(i).Shape()->OutLinedShape() == S) + { return i; + } } return 0; diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BCurveTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BCurveTool.cxx index 60ec718f44..02fd349130 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BCurveTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BCurveTool.cxx @@ -29,9 +29,13 @@ int HLRBRep_BCurveTool::NbSamples(const BRepAdaptor_Curve& C, const double U0, c double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + C.NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { nbs = C.NbKnots(); @@ -39,10 +43,14 @@ int HLRBRep_BCurveTool::NbSamples(const BRepAdaptor_Curve& C, const double U0, c nbs *= C.LastParameter() - C.FirstParameter(); nbs /= U1 - U0; if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } @@ -55,14 +63,18 @@ void HLRBRep_BCurveTool::Poles(const BRepAdaptor_Curve& C, NCollection_Array1 aBez = C.Bezier(); const NCollection_Array1& aSrcPoles = aBez->Poles(); for (int i = T.Lower(); i <= T.Upper(); i++) + { T(i) = aSrcPoles(i); + } } else if (C.GetType() == GeomAbs_BSplineCurve) { occ::handle aBSpl = C.BSpline(); const NCollection_Array1& aSrcPoles = aBSpl->Poles(); for (int i = T.Lower(); i <= T.Upper(); i++) + { T(i) = aSrcPoles(i); + } } } @@ -78,9 +90,13 @@ void HLRBRep_BCurveTool::PolesAndWeights(const BRepAdaptor_Curve& C, const NCollection_Array1& aSrcPoles = HB->Poles(); const NCollection_Array1& aSrcWeights = HB->WeightsArray(); for (int i = T.Lower(); i <= T.Upper(); i++) + { T(i) = aSrcPoles(i); + } for (int i = W.Lower(); i <= W.Upper(); i++) + { W(i) = aSrcWeights(i); + } } else if (C.GetType() == GeomAbs_BSplineCurve) { @@ -88,9 +104,13 @@ void HLRBRep_BCurveTool::PolesAndWeights(const BRepAdaptor_Curve& C, const NCollection_Array1& aSrcPoles = HB->Poles(); const NCollection_Array1& aSrcWeights = HB->WeightsArray(); for (int i = T.Lower(); i <= T.Upper(); i++) + { T(i) = aSrcPoles(i); + } for (int i = W.Lower(); i <= W.Upper(); i++) + { W(i) = aSrcWeights(i); + } } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BSurfaceTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BSurfaceTool.cxx index aa06d6f173..9cb3bc1ac8 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BSurfaceTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_BSurfaceTool.cxx @@ -37,7 +37,9 @@ int HLRBRep_BSurfaceTool::NbSamplesU(const BRepAdaptor_Surface& S) nbs = S.NbUKnots(); nbs *= S.UDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Torus: { @@ -81,7 +83,9 @@ int HLRBRep_BSurfaceTool::NbSamplesV(const BRepAdaptor_Surface& S) nbs = S.NbVKnots(); nbs *= S.VDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Cylinder: @@ -114,9 +118,13 @@ int HLRBRep_BSurfaceTool::NbSamplesU(const BRepAdaptor_Surface& S, const double double ul = LastUParameter(S); n *= (int)((u2 - u1) / (uf - ul)); if (n > nbs) + { n = nbs; + } if (n < 5) + { n = 5; + } } return (n); } @@ -133,9 +141,13 @@ int HLRBRep_BSurfaceTool::NbSamplesV(const BRepAdaptor_Surface& S, const double double vl = LastVParameter(S); n *= (int)((v2 - v1) / (vf - vl)); if (n > nbs) + { n = nbs; + } if (n < 5) + { n = 5; + } } return (n); } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Curve.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Curve.cxx index f1aba2006e..8f60ac7ae7 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Curve.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Curve.cxx @@ -123,11 +123,13 @@ double HLRBRep_Curve::Update(double TotMin[16], double TotMax[16]) gp_Dir D1 = HLRBRep_BCurveTool::Circle(myCurve).Axis().Direction(); D1.Transform(((HLRAlgo_Projector*)myProj)->Transformation()); if (D1.IsParallel(gp::DZ(), Precision::Angular())) + { myType = GeomAbs_Circle; - else if (std::abs(D1.Dot(gp::DZ())) - < Precision::Angular() - * 10) //*10: The minor radius of ellipse should not be too small. + } + else if (std::abs(D1.Dot(gp::DZ())) < Precision::Angular() * 10) + { //*10: The minor radius of ellipse should not be too small. myType = GeomAbs_OtherCurve; + } else { myType = GeomAbs_Ellipse; @@ -155,14 +157,20 @@ double HLRBRep_Curve::Update(double TotMin[16], double TotMax[16]) case GeomAbs_BezierCurve: if (HLRBRep_BCurveTool::Degree(myCurve) == 1) + { myType = GeomAbs_Line; + } else if (!((HLRAlgo_Projector*)myProj)->Perspective()) + { myType = typ; + } break; case GeomAbs_BSplineCurve: if (!((HLRAlgo_Projector*)myProj)->Perspective()) + { myType = typ; + } break; default: @@ -208,7 +216,9 @@ double HLRBRep_Curve::Update(double TotMin[16], double TotMax[16]) myOZ = VFZ * gp_Vec(P.X() - F.X(), P.Y() - F.Y(), P.Z()); } else + { myVX = std::sqrt(V.X() * V.X() + V.Y() * V.Y()) * l3d; + } } return (UpdateMinMax(TotMin, TotMax)); } @@ -263,7 +273,9 @@ double HLRBRep_Curve::UpdateMinMax(double TotMin[16], double TotMax[16]) dz1 = za + p * dz1 - zb; dd1 = sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1); if (dd1 > tolMinMax) + { tolMinMax = dd1; + } } } } @@ -440,7 +452,9 @@ gp_Elips2d HLRBRep_Curve::Ellipse() const gp_Pnt2d p(C.Location().X(), C.Location().Y()); gp_Elips2d El(gp_Ax2d(p, d), C.Radius(), C.Radius() * rap); if (D1.Z() < 0) + { El.Reverse(); + } return El; } @@ -471,14 +485,18 @@ void HLRBRep_Curve::Poles(NCollection_Array1& TP) const occ::handle aBSpl = HLRBRep_BCurveTool::BSpline(myCurve); const NCollection_Array1& aSrcPoles = aBSpl->Poles(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } } else { occ::handle aBez = HLRBRep_BCurveTool::Bezier(myCurve); const NCollection_Array1& aSrcPoles = aBez->Poles(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } } for (int i = i1; i <= i2; i++) { @@ -498,7 +516,9 @@ void HLRBRep_Curve::Poles(const occ::handle& aCurve, //-- HLRBRep_BCurveTool::Poles(myCurve,TP3); const NCollection_Array1& aSrcPoles = aCurve->Poles(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } for (int i = i1; i <= i2; i++) { @@ -523,9 +543,13 @@ void HLRBRep_Curve::PolesAndWeights(NCollection_Array1& TP, const NCollection_Array1& aSrcPoles = HB->Poles(); const NCollection_Array1& aSrcWeights = HB->WeightsArray(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } for (int i = i1; i <= i2; i++) + { TW(i) = aSrcWeights(i); + } } else { @@ -533,9 +557,13 @@ void HLRBRep_Curve::PolesAndWeights(NCollection_Array1& TP, const NCollection_Array1& aSrcPoles = HB->Poles(); const NCollection_Array1& aSrcWeights = HB->WeightsArray(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } for (int i = i1; i <= i2; i++) + { TW(i) = aSrcWeights(i); + } } for (int i = i1; i <= i2; i++) { @@ -558,9 +586,13 @@ void HLRBRep_Curve::PolesAndWeights(const occ::handle& aCurve const NCollection_Array1& aSrcPoles = aCurve->Poles(); const NCollection_Array1& aSrcWeights = aCurve->WeightsArray(); for (int i = i1; i <= i2; i++) + { TP3(i) = aSrcPoles(i); + } for (int i = i1; i <= i2; i++) + { TW(i) = aSrcWeights(i); + } for (int i = i1; i <= i2; i++) { @@ -578,7 +610,9 @@ void HLRBRep_Curve::Knots(NCollection_Array1& kn) const occ::handle aBSpl = HLRBRep_BCurveTool::BSpline(myCurve); const NCollection_Array1& aSrcKnots = aBSpl->Knots(); for (int i = kn.Lower(); i <= kn.Upper(); i++) + { kn(i) = aSrcKnots(i); + } } } @@ -591,6 +625,8 @@ void HLRBRep_Curve::Multiplicities(NCollection_Array1& mu) const occ::handle aBSpl = HLRBRep_BCurveTool::BSpline(myCurve); const NCollection_Array1& aSrcMults = aBSpl->Multiplicities(); for (int i = mu.Lower(); i <= mu.Upper(); i++) + { mu(i) = aSrcMults(i); + } } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_CurveTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_CurveTool.cxx index 816d49b56e..c01a65a1a8 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_CurveTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_CurveTool.cxx @@ -25,18 +25,26 @@ int HLRBRep_CurveTool::NbSamples(const HLRBRep_CurvePtr C) double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + ((HLRBRep_Curve*)C)->NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { nbs = ((HLRBRep_Curve*)C)->NbKnots(); nbs *= ((HLRBRep_Curve*)C)->Degree(); if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } @@ -49,9 +57,13 @@ int HLRBRep_CurveTool::NbSamples(const HLRBRep_CurvePtr C, const double u1, cons double nbs = nbsOther; if (typC == GeomAbs_Line) + { nbs = 2; + } else if (typC == GeomAbs_BezierCurve) + { nbs = 3 + ((HLRBRep_Curve*)C)->NbPoles(); + } else if (typC == GeomAbs_BSplineCurve) { occ::handle aCurve = ((HLRBRep_Curve*)C)->Curve().Curve().Curve(); @@ -59,9 +71,13 @@ int HLRBRep_CurveTool::NbSamples(const HLRBRep_CurvePtr C, const double u1, cons nbs = GAcurve.NbIntervals(GeomAbs_CN) + 1; nbs *= ((HLRBRep_Curve*)C)->Degree(); if (nbs < 2.0) + { nbs = 2; + } } if (nbs > 50) + { nbs = 50; + } return ((int)nbs); } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Data.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Data.cxx index 638e11816e..e682fe0ebd 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Data.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Data.cxx @@ -117,7 +117,9 @@ public: std::cout << "\n@#@#@#@#@# SetDim " << n << std::endl; #endif if (UV) + { Destroy(); + } #ifdef OCCT_DEBUG StNbLect = StNbEcr = StNbMax = StNbMoy = 0; #endif @@ -329,27 +331,41 @@ public: //-- ordre decroissant int a = 0, b = nbUV[i0] - 1, ab; if (IndUV[i0][a] == -1) + { return (RealLast()); + } if (IndUV[i0][a] == j0) + { return (UV[i0][a]); + } if (IndUV[i0][b] == j0) + { return (UV[i0][b]); + } while ((IndUV[i0][a] > j0) && (IndUV[i0][b] < j0)) { ab = (a + b) >> 1; if (IndUV[i0][ab] < j0) { if (b == ab) + { return (RealLast()); + } else + { b = ab; + } } else if (IndUV[i0][ab] > j0) { if (a == ab) + { return (RealLast()); + } else + { a = ab; + } } else { @@ -487,13 +503,17 @@ static void AdjustParameter(HLRBRep_EdgeData* E, const bool h, double& p, float& { E->Status().Bounds(p, t, p2, t2); if (E->VerAtSta()) + { p = p + (p2 - p) * CutBig; + } } else { E->Status().Bounds(p1, t1, p, t); if (E->VerAtEnd()) + { p = p - (p - p1) * CutBig; + } } } @@ -574,7 +594,9 @@ void HLRBRep_Data::Write(const occ::handle& DS, int ne = eb->NbEdges(); for (int ie = 1; ie <= ne; ie++) + { eb->Edge(ie, eb->Edge(ie) + de); + } } } @@ -613,7 +635,9 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) EC.Projector(&myProj); double enl = EC.Update(TotMin, TotMax); if (enl > tolMinMax) + { tolMinMax = enl; + } } HLRAlgo::EnlargeMinMax(tolMinMax, TotMin, TotMax); double d[16]; @@ -623,17 +647,23 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) { d[i] = TotMax[i] - TotMin[i]; if (precad < d[i]) + { precad = d[i]; + } } myBigSize = precad; precad = precad * 0.0005; for (i = 0; i <= 15; i++) + { mySurD[i] = 0x00007fff / (d[i] + precad); + } precad = precad * 0.5; for (i = 0; i <= 15; i++) + { myDeca[i] = -TotMin[i] + precad; + } double tol; bool ver1, ver2; @@ -725,14 +755,18 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) Tg1.Transform(T); Tg2.Transform(T); if (std::abs(Tg1.X()) + std::abs(Tg1.Y()) < myToler * 10) + { ver1 = true; + } else { gp_Dir Dir1(Tg1); ver1 = std::abs(Dir1.X()) + std::abs(Dir1.Y()) < myToler * 10; } if (std::abs(Tg2.X()) + std::abs(Tg2.Y()) < myToler * 10) + { ver2 = true; + } else { gp_Dir Dir2(Tg2); @@ -774,7 +808,9 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) { withOutL = true; if (myFaceItr1.Double()) + { cut = true; + } } } fd.Cut(cut); @@ -786,9 +822,13 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) if (!withOutL && (iFaceType == GeomAbs_Plane || iFaceType == GeomAbs_Cylinder || iFaceType == GeomAbs_Cone || iFaceType == GeomAbs_Sphere || iFaceType == GeomAbs_Torus)) + { fd.Simple(true); + } else + { fd.Simple(false); + } fd.Plane(iFaceType == GeomAbs_Plane); fd.Cylinder(iFaceType == GeomAbs_Cylinder); @@ -842,7 +882,9 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) r = Nm.Z() * myProj.Focus() - (Nm.X() * Pt.X() + Nm.Y() * Pt.Y() + Nm.Z() * Pt.Z()); } else + { r = Nm.Z(); + } if (std::abs(r) > myToler * 10) { fd.Back(r < 0); @@ -879,7 +921,9 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) } } else + { fd.Hiding(true); + } } else { @@ -902,12 +946,18 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) myFE = myFaceItr1.Edge(); HLRBRep_EdgeData& EDataFE2 = myEData(myFE); if (!fd.Simple()) + { EDataFE2.AutoIntersectionDone(false); + } HLRAlgo::DecodeMinMax(EDataFE2.MinMax(), EdgeMin, EdgeMax); if (myFaceItr1.BeginningOfWire()) + { HLRAlgo::CopyMinMax(EdgeMin, EdgeMax, WireMin, WireMax); + } else + { HLRAlgo::AddMinMax(EdgeMin, EdgeMax, WireMin, WireMax); + } if (myFaceItr1.EndOfWire()) { HLRAlgo::EncodeMinMax(WireMin, WireMax, MinMaxWire); @@ -918,7 +968,9 @@ void HLRBRep_Data::Update(const HLRAlgo_Projector& P) HLRAlgo::CopyMinMax(WireMin, WireMax, FaceMin, FaceMax); } else + { HLRAlgo::AddMinMax(WireMin, WireMax, FaceMin, FaceMax); + } } } HLRAlgo::EncodeMinMax(FaceMin, FaceMax, MinMaxFace); @@ -1040,7 +1092,9 @@ bool HLRBRep_Data::MoreEdge() myLETol = myLEData->Tolerance(); myLEType = myLEGeom->GetType(); if (!myLEDouble) + { myLEData->HideCount(myHideCount - 1); + } return true; } else @@ -1063,12 +1117,18 @@ void HLRBRep_Data::NextEdge(const bool skip) if (skip) { if (iFaceTest) + { myFaceItr2.NextEdge(); + } else + { myCurSortEd++; + } } if (!MoreEdge()) + { return; + } if (iFaceTest) { myLE = myFaceItr2.Edge(); @@ -1083,7 +1143,9 @@ void HLRBRep_Data::NextEdge(const bool skip) myLEType = myLEGeom->GetType(); if (((HLRBRep_EdgeData*)myLEData)->Vertical() || (myLEDouble && ((HLRBRep_EdgeData*)myLEData)->HideCount() == myHideCount - 1)) + { NextEdge(); + } ((HLRBRep_EdgeData*)myLEData)->HideCount(myHideCount - 1); return; } @@ -1139,7 +1201,7 @@ void HLRBRep_Data::NextEdge(const bool skip) NextEdge(); return; } - return; // edge is OK + // edge is OK } //================================================================================================= @@ -1147,9 +1209,13 @@ void HLRBRep_Data::NextEdge(const bool skip) int HLRBRep_Data::Edge() const { if (iFaceTest) + { return myFaceItr2.Edge(); + } else + { return myEdgeIndices(myCurSortEd); + } } //================================================================================================= @@ -1318,13 +1384,21 @@ void HLRBRep_Data::NextInterference() if (mySameVertex || myLE == myFE) { if (h1) + { da1 = CutLar; + } if (e1) + { db1 = CutLar; + } if (h2) + { da2 = CutLar; + } if (e2) + { db2 = CutLar; + } } int NoInter = 0; if (myLE == myFE) @@ -1421,13 +1495,17 @@ bool HLRBRep_Data::RejectedInterference() bool firstPoint = (n & 1) != 0; int nseg = n >> 1; if (firstPoint) + { nseg++; + } double pf = ((HLRBRep_Curve*)myLEGeom) ->Parameter3d(myIntersector.Segment(nseg).FirstPoint().ParamOnFirst()); double pl = ((HLRBRep_Curve*)myLEGeom) ->Parameter3d(myIntersector.Segment(nseg).LastPoint().ParamOnFirst()); if (pf > pl) + { firstPoint = !firstPoint; + } if (firstPoint) { @@ -1455,13 +1533,19 @@ void HLRBRep_Data::LocalLEGeometry2D(const double Param, gp_Dir2d& Tg, gp_Dir2d& { myLLProps.SetParameter(Param); if (!myLLProps.IsTangentDefined()) + { throw Standard_Failure("HLRBRep_Data::LocalGeometry2D"); + } myLLProps.Tangent(Tg); Cu = myLLProps.Curvature(); if (Cu > Epsilon(1.) && !Precision::IsInfinite(Cu)) + { myLLProps.Normal(Nm); + } else + { Nm = gp_Dir2d(-Tg.Y(), Tg.X()); + } } //================================================================================================= @@ -1476,13 +1560,19 @@ void HLRBRep_Data::LocalFEGeometry2D(const int FE, myFLProps.SetCurve(aCurve); myFLProps.SetParameter(Param); if (!myFLProps.IsTangentDefined()) + { throw Standard_Failure("HLRBRep_Data::LocalGeometry2D"); + } myFLProps.Tangent(Tg); Cu = myFLProps.Curvature(); if (Cu > Epsilon(1.) && !Precision::IsInfinite(Cu)) + { myFLProps.Normal(Nm); + } else + { Nm = gp_Dir2d(-Tg.Y(), Tg.X()); + } } //================================================================================================= @@ -1522,7 +1612,9 @@ void HLRBRep_Data::EdgeState(const double p1, } V.Transform(TI); if (NrmFace.Dot(V) > 0.) + { NrmFace.Reverse(); + } const double scal = (TngEdge.SquareMagnitude() > 1.e-10) ? NrmFace.Dot(gp_Dir(TngEdge)) : 0.; @@ -1581,13 +1673,19 @@ int HLRBRep_Data::HidingStartLevel(const int { param = It.Value().Intersection().Parameter(); if (param > end) + { Loop = false; + } else { if (std::abs(param - sta) > std::abs(param - end)) + { end = param; + } else + { sta = param; + } } It.Next(); } @@ -1619,7 +1717,9 @@ int HLRBRep_Data::HidingStartLevel(const int } } else if (p > param + tolpar) + { Loop = false; + } else { #ifdef OCCT_DEBUG @@ -1665,9 +1765,13 @@ bool HLRBRep_Data::OrientOutLine(const int I, HLRBRep_FaceData& FD) myFE = eb1->Edge(ie1); HLRBRep_EdgeData& ed1 = myEData(myFE); if (eb1->Double(ie1) || eb1->IsoLine(ie1) || ed1.Vertical()) + { ed1.Used(true); + } else + { ed1.Used(false); + } if ((eb1->OutLine(ie1) || eb1->Internal(ie1)) && !ed1.Vertical()) { double p, pu, pv, r; @@ -1676,13 +1780,21 @@ bool HLRBRep_Data::OrientOutLine(const int I, HLRBRep_FaceData& FD) int vsta = ed1.VSta(); int vend = ed1.VEnd(); if (vsta == 0 && vend == 0) + { p = 0; + } else if (vsta == 0) + { p = EC.Parameter3d(EC.LastParameter()); + } else if (vend == 0) + { p = EC.Parameter3d(EC.FirstParameter()); + } else + { p = EC.Parameter3d((EC.LastParameter() + EC.FirstParameter()) / 2); + } if (HLRBRep_EdgeFaceTool::UVPoint(p, myFEGeom, iFaceGeom, pu, pv)) { gp_Pnt Pt; @@ -1714,7 +1826,9 @@ bool HLRBRep_Data::OrientOutLine(const int I, HLRBRep_FaceData& FD) #endif } if (curv > 0) + { Nm.Reverse(); + } Tg.Transform(T); Pt.Transform(T); Nm.Transform(T); @@ -1728,9 +1842,13 @@ bool HLRBRep_Data::OrientOutLine(const int I, HLRBRep_FaceData& FD) #endif } if (myProj.Perspective()) + { r = Nm.Z() * myProj.Focus() - (Nm.X() * Pt.X() + Nm.Y() * Pt.Y() + Nm.Z() * Pt.Z()); + } else + { r = Nm.Z(); + } myFEOri = (r > 0) ? TopAbs_FORWARD : TopAbs_REVERSED; if (!FD.Cut() && FD.Closed() && FirstInversion) { @@ -2083,9 +2201,13 @@ q1,(q2>32768)? (32768-q2) : q2,q&0x80008000); if (iFaceTest) { if (!myLEOutLine && !myLEInternal) + { TolZ = myBigSize * 0.001; + } else + { TolZ = myBigSize * 0.01; + } } wLim -= TolZ; double PeriodU, PeriodV, UMin = 0., UMax = 0., VMin = 0., VMax = 0.; @@ -2096,7 +2218,9 @@ q1,(q2>32768)? (32768-q2) : q2,q&0x80008000); UMax = iFaceGeom->LastUParameter(); } else + { PeriodU = 0.; + } if (iFaceGeom->IsVPeriodic()) { PeriodV = iFaceGeom->VPeriod(); @@ -2104,7 +2228,9 @@ q1,(q2>32768)? (32768-q2) : q2,q&0x80008000); VMax = iFaceGeom->LastVParameter(); } else + { PeriodV = 0; + } gp_Pnt PInter; double u, v, w; IntCurveSurface_TransitionOnCurve Tr; @@ -2116,9 +2242,13 @@ q1,(q2>32768)? (32768-q2) : q2,q&0x80008000); { double aDummyShift; if (PeriodU > 0.) + { GeomInt::AdjustPeriodic(u, UMin, UMax, PeriodU, u, aDummyShift); + } if (PeriodV > 0.) + { GeomInt::AdjustPeriodic(v, VMin, VMax, PeriodV, v, aDummyShift); + } gp_Pnt2d pnt2d(u, v); if (myClassifier->Classify(pnt2d, Precision::PConfusion()) != TopAbs_OUT) @@ -2253,7 +2383,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, if (myLE == myFE) { if (st == TopAbs_IN) + { ((HLRBRep_EdgeData*)myLEData)->Simple(false); + } } else { @@ -2261,11 +2393,15 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, { if ((st == TopAbs_ON) || (Tr1->PositionOnCurve() != IntRes2d_Middle) || (Tr2->PositionOnCurve() != IntRes2d_Middle)) + { return true; + } } } if (st == TopAbs_IN) + { iFaceSmpl = false; + } } switch (Tr1->TransitionType()) @@ -2294,7 +2430,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, } if (iFaceBack) + { Orie = TopAbs::Complement(Orie); // change the transition + } TopAbs_Orientation Ori = TopAbs_FORWARD; switch (Tr1->PositionOnCurve()) { @@ -2314,7 +2452,8 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, if (Tr2->PositionOnCurve() != IntRes2d_Middle) { // correction de la transition sur myFE // clang-format off - if (mySameVertex) return true; // si intersection a une extremite verticale ! + if (mySameVertex) { return true; // si intersection a une extremite verticale ! +} // clang-format on bool douteux = false; @@ -2331,7 +2470,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, douteux = true; ((HLRBRep_Curve*)myFEGeom)->D2(psav, Ptsav, Tgsav, Nmsav); if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE) + { Tgsav = Nmsav; + } } } else @@ -2344,7 +2485,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, douteux = true; ((HLRBRep_Curve*)myFEGeom)->D2(psav, Ptsav, Tgsav, Nmsav); if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE) + { Tgsav = Nmsav; + } } } gp_Vec2d TgFE; @@ -2354,9 +2497,13 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, if (TgFE.XY().Dot(Tgsav.XY()) < 0.0) { if (Orie == TopAbs_FORWARD) + { Orie = TopAbs_REVERSED; + } else if (Orie == TopAbs_REVERSED) + { Orie = TopAbs_FORWARD; + } } } myIntf.ChangeBoundary().Set2D(myFE, p2); @@ -2375,7 +2522,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, douteux = true; ((HLRBRep_Curve*)myLEGeom)->D2(psav, Ptsav, Tgsav, Nmsav); if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE) + { Tgsav = Nmsav; + } } } else @@ -2386,7 +2535,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, douteux = true; ((HLRBRep_Curve*)myLEGeom)->D2(psav, Ptsav, Tgsav, Nmsav); if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE) + { Tgsav = Nmsav; + } } } if (douteux) @@ -2396,9 +2547,13 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, if (TgLE.XY().Dot(Tgsav.XY()) < 0.0) { if (Orie == TopAbs_FORWARD) + { Orie = TopAbs_REVERSED; + } else if (Orie == TopAbs_REVERSED) + { Orie = TopAbs_FORWARD; + } } } } @@ -2418,7 +2573,9 @@ bool HLRBRep_Data::RejectedPoint(const IntRes2d_IntersectionPoint& PInter, { decal = 1; if (st == TopAbs_IN && Ori == TopAbs_FORWARD && Orie == TopAbs_FORWARD) + { decal = 0; + } } HLRAlgo_Intersection& inter = myIntf.ChangeIntersection(); inter.Orientation(Ori); @@ -2441,20 +2598,30 @@ bool HLRBRep_Data::SameVertex(const bool h1, const bool h2) { int v1, v2; if (h1) + { v1 = ((HLRBRep_EdgeData*)myLEData)->VSta(); + } else + { v1 = ((HLRBRep_EdgeData*)myLEData)->VEnd(); + } if (h2) + { v2 = ((HLRBRep_EdgeData*)myFEData)->VSta(); + } else + { v2 = ((HLRBRep_EdgeData*)myFEData)->VEnd(); + } bool SameV = v1 == v2; if (SameV) { myIntersected = true; // compute the intersections if ((myLEType == GeomAbs_Line || myLEType == GeomAbs_Circle || myLEType == GeomAbs_Ellipse) && (myFEType == GeomAbs_Line || myFEType == GeomAbs_Circle || myFEType == GeomAbs_Ellipse)) + { myIntersected = false; // no other intersection + } bool otherCase = true; @@ -2462,10 +2629,14 @@ bool HLRBRep_Data::SameVertex(const bool h1, const bool h2) || (!h1 && ((HLRBRep_EdgeData*)myLEData)->OutLVEnd())) { if (iFaceTest || myLEInternal) + { otherCase = false; + } } else if (iFaceTest) + { otherCase = false; + } if (otherCase) { @@ -2493,7 +2664,9 @@ bool HLRBRep_Data::IsBadFace() const double aMin = pGeom->FirstUParameter(); double aMax = pGeom->LastUParameter(); if (aPeriod * 2 < aMax - aMin) + { return true; + } } if (pGeom->IsVPeriodic()) { @@ -2501,7 +2674,9 @@ bool HLRBRep_Data::IsBadFace() const double aMin = pGeom->FirstVParameter(); double aMax = pGeom->LastVParameter(); if (aPeriod * 2 < aMax - aMin) + { return true; + } } } return false; diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeBuilder.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeBuilder.cxx index ee8b19fa50..6ec44b540c 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeBuilder.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeBuilder.cxx @@ -176,35 +176,53 @@ HLRBRep_EdgeBuilder::HLRBRep_EdgeBuilder(HLRBRep_VertexList& VList) cur = cur->Next(); // test for periodicicity if (cur == myLimits) + { break; + } } // error if no interferences Standard_DomainError_Raise_if(stat == TopAbs_UNKNOWN, "EdgeBuilder : No interferences"); // if no boundary the edge covers the whole curve if (estat == TopAbs_UNKNOWN) + { estat = TopAbs_IN; + } // propagate states cur = myLimits; while (!cur.IsNull()) { if (cur->StateBefore() == TopAbs_UNKNOWN) + { cur->StateBefore(stat); + } else + { stat = cur->StateAfter(); + } if (cur->StateAfter() == TopAbs_UNKNOWN) + { cur->StateAfter(stat); + } if (cur->EdgeBefore() == TopAbs_UNKNOWN) + { cur->EdgeBefore(estat); + } else + { estat = cur->EdgeAfter(); + } if (cur->EdgeAfter() == TopAbs_UNKNOWN) + { cur->EdgeAfter(estat); + } cur = cur->Next(); if (cur == myLimits) + { break; + } } // initialise with IN parts @@ -225,7 +243,9 @@ void HLRBRep_EdgeBuilder::NextArea() { left = right; if (!right.IsNull()) + { right = right->Next(); + } } //================================================================================================= @@ -234,7 +254,9 @@ void HLRBRep_EdgeBuilder::PreviousArea() { right = left; if (!left.IsNull()) + { left = left->Previous(); + } } //================================================================================================= @@ -242,10 +264,16 @@ void HLRBRep_EdgeBuilder::PreviousArea() bool HLRBRep_EdgeBuilder::HasArea() const { if (left.IsNull()) + { if (right.IsNull()) + { return false; + } + } if (right == myLimits) + { return false; + } return true; } @@ -255,9 +283,13 @@ TopAbs_State HLRBRep_EdgeBuilder::AreaState() const { TopAbs_State stat = TopAbs_UNKNOWN; if (!left.IsNull()) + { stat = left->StateAfter(); + } if (!right.IsNull()) + { stat = right->StateBefore(); + } return stat; } @@ -267,9 +299,13 @@ TopAbs_State HLRBRep_EdgeBuilder::AreaEdgeState() const { TopAbs_State stat = TopAbs_UNKNOWN; if (!left.IsNull()) + { stat = left->EdgeAfter(); + } if (!right.IsNull()) + { stat = right->EdgeBefore(); + } return stat; } @@ -298,9 +334,13 @@ void HLRBRep_EdgeBuilder::Builds(const TopAbs_State ToBuild) if ((AreaState() == toBuild) && (AreaEdgeState() == TopAbs_IN)) { if (left.IsNull()) + { current = 2; + } else + { current = 1; + } return; } NextArea(); @@ -321,16 +361,22 @@ void HLRBRep_EdgeBuilder::NextEdge() { // clean the current edge while (AreaState() == toBuild) + { NextArea(); + } // go to the next edge while (HasArea()) { if ((AreaState() == toBuild) && (AreaEdgeState() == TopAbs_IN)) { if (left.IsNull()) + { current = 2; + } else + { current = 1; + } return; } NextArea(); @@ -352,18 +398,26 @@ void HLRBRep_EdgeBuilder::NextVertex() { current = 2; if (right.IsNull()) + { current = 3; + } } else if (current == 2) { NextArea(); if ((AreaState() == toBuild) && (AreaEdgeState() == TopAbs_IN)) + { current = 2; + } else + { current = 3; + } } else + { throw Standard_NoSuchObject("EdgeBuilder::NextVertex : No current edge"); + } } //================================================================================================= @@ -371,11 +425,17 @@ void HLRBRep_EdgeBuilder::NextVertex() const HLRAlgo_Intersection& HLRBRep_EdgeBuilder::Current() const { if (current == 1) + { return left->Vertex(); + } else if (current == 2) + { return right->Vertex(); + } else + { throw Standard_NoSuchObject("EdgeBuilder::Current : No current vertex"); + } } //================================================================================================= @@ -383,11 +443,17 @@ const HLRAlgo_Intersection& HLRBRep_EdgeBuilder::Current() const bool HLRBRep_EdgeBuilder::IsBoundary() const { if (current == 1) + { return left->IsBoundary(); + } else if (current == 2) + { return right->IsBoundary(); + } else + { throw Standard_NoSuchObject("EdgeBuilder::IsBoundary : No current vertex"); + } } //================================================================================================= @@ -395,11 +461,17 @@ bool HLRBRep_EdgeBuilder::IsBoundary() const bool HLRBRep_EdgeBuilder::IsInterference() const { if (current == 1) + { return left->IsInterference(); + } else if (current == 2) + { return right->IsInterference(); + } else + { throw Standard_NoSuchObject("EdgeBuilder::IsInterference : No current vertex"); + } } //================================================================================================= @@ -409,17 +481,25 @@ TopAbs_Orientation HLRBRep_EdgeBuilder::Orientation() const if (current == 1) { if ((left->StateBefore() == left->StateAfter()) && (left->EdgeBefore() == left->EdgeAfter())) + { return TopAbs_INTERNAL; + } else + { return TopAbs_FORWARD; + } } else if (current == 2) { if ((right->StateBefore() == right->StateAfter()) && (right->EdgeBefore() == right->EdgeAfter())) + { return TopAbs_INTERNAL; + } else + { return TopAbs_REVERSED; + } } return TopAbs_EXTERNAL; // only for WNT. } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeFaceTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeFaceTool.cxx index ebf66c1f47..c32b0b6abe 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeFaceTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeFaceTool.cxx @@ -86,7 +86,9 @@ bool HLRBRep_EdgeFaceTool::UVPoint(const double Par, } } if (index == 0) + { return false; + } proj.Parameter(index, U, V); } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeIList.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeIList.cxx index b53b853b06..8dafd3c515 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeIList.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeIList.cxx @@ -105,7 +105,9 @@ void HLRBRep_EdgeIList::ProcessComplex(NCollection_List& I || SimilarInterference(It1.Value(), It2.Value()) #endif )) + { break; + } T.InterferenceBoundaryGeometry(It2.Value(), TgtI, NormI, CurvI); transTool.AddInterference(TolAng, diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeInterferenceTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeInterferenceTool.cxx index 9dfecbb8fd..1ca6ff72fe 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeInterferenceTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_EdgeInterferenceTool.cxx @@ -66,7 +66,9 @@ bool HLRBRep_EdgeInterferenceTool::SameInterferences(const HLRAlgo_Interference& int ind1 = I1.Intersection().Index(); int ind2 = I2.Intersection().Index(); if (ind1 != 0 && ind2 != 0) + { return ind1 == ind2; + } return false; } @@ -75,7 +77,9 @@ bool HLRBRep_EdgeInterferenceTool::SameInterferences(const HLRAlgo_Interference& bool HLRBRep_EdgeInterferenceTool::SameVertexAndInterference(const HLRAlgo_Interference& I) const { if (I.Intersection().Index() == inter[cur].Index()) + { return true; + } return I.Intersection().Orientation() == ((cur == 0) ? TopAbs_FORWARD : TopAbs_REVERSED); } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_HLRToShape.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_HLRToShape.cxx index 6580ede271..760b509b1a 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_HLRToShape.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_HLRToShape.cxx @@ -60,9 +60,13 @@ TopoDS_Shape HLRBRep_HLRToShape::InternalCompound(const int typ, int v1, v2; int index = myAlgo->Index(S); if (index == 0) + { explor = true; + } else + { myAlgo->ShapeBounds(index).Bounds(v1, v2, e1, e2, f1, f2); + } } BRep_Builder B; B.MakeCompound(TopoDS::Compound(Result)); @@ -77,7 +81,9 @@ TopoDS_Shape HLRBRep_HLRToShape::InternalCompound(const int typ, ed->HideCount(0); } else + { ed->Used(true); + } } if (explor) { @@ -89,7 +95,9 @@ TopoDS_Shape HLRBRep_HLRToShape::InternalCompound(const int typ, { int iface = Faces.FindIndex(Exp.Current()); if (iface != 0) + { DrawFace(visible, typ, iface, DS, Result, added, In3d); + } } if (typ >= 3) { @@ -113,7 +121,9 @@ TopoDS_Shape HLRBRep_HLRToShape::InternalCompound(const int typ, { for (int iface = f1; iface <= f2; iface++) + { DrawFace(visible, typ, iface, DS, Result, added, In3d); + } if (typ >= 3) { @@ -133,7 +143,9 @@ TopoDS_Shape HLRBRep_HLRToShape::InternalCompound(const int typ, DS->Projector().Scaled(false); } if (!added) + { Result = TopoDS_Shape(); + } return Result; } @@ -157,20 +169,32 @@ void HLRBRep_HLRToShape::DrawFace(const bool visible, { bool todraw; if (typ == 1) + { todraw = Itf.IsoLine(); + } else if (typ == 2) // outlines { if (In3d) + { todraw = Itf.Internal() || Itf.OutLine(); + } else + { todraw = Itf.Internal(); + } } else if (typ == 3) + { todraw = edf.Rg1Line() && !edf.RgNLine() && !Itf.OutLine(); + } else if (typ == 4) + { todraw = edf.RgNLine() && !Itf.OutLine(); + } else + { todraw = !Itf.IsoLine() && !Itf.Internal() && (!edf.Rg1Line() || Itf.OutLine()); + } if (todraw) { @@ -214,13 +238,21 @@ void HLRBRep_HLRToShape::DrawEdge(const bool visible, { bool todraw = false; if (inFace) + { todraw = true; + } else if (typ == 3) + { todraw = ed.Rg1Line() && !ed.RgNLine(); + } else if (typ == 4) + { todraw = ed.RgNLine(); + } else + { todraw = !ed.Rg1Line(); + } if (todraw) { @@ -235,9 +267,13 @@ void HLRBRep_HLRToShape::DrawEdge(const bool visible, { It.Visible(sta, tolsta, end, tolend); if (!In3d) + { E = HLRBRep::MakeEdge(ed.Geometry(), sta, end); + } else + { E = HLRBRep::MakeEdge3d(ed.Geometry(), sta, end); + } if (!E.IsNull()) { B.Add(Result, E); @@ -251,9 +287,13 @@ void HLRBRep_HLRToShape::DrawEdge(const bool visible, { It.Hidden(sta, tolsta, end, tolend); if (!In3d) + { E = HLRBRep::MakeEdge(ed.Geometry(), sta, end); + } else + { E = HLRBRep::MakeEdge3d(ed.Geometry(), sta, end); + } if (!E.IsNull()) { B.Add(Result, E); diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Hider.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Hider.cxx index e6504f2a11..e24e783941 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Hider.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Hider.cxx @@ -86,10 +86,14 @@ void HLRBRep_Hider::Hide( // ***************************************************************** myDS->InitEdge(FI, MST); - if (!myDS->MoreEdge()) // there is nothing to do - return; // ********************** + if (!myDS->MoreEdge()) + { // there is nothing to do + return; // ********************** + } if (myDS->IsBadFace()) + { return; + } HLRBRep_EdgeInterferenceTool EIT(myDS); // List of Intersections NCollection_Array1& myEData = myDS->EDataArray(); @@ -187,7 +191,9 @@ void HLRBRep_Hider::Hide( } } if (Int1.Intersection().Index() == 0 && Int2.Intersection().Index() == 0) + { nind = 0; + } if (nind != -1) { @@ -380,8 +386,10 @@ void HLRBRep_Hider::Hide( { HLRBRep_EdgeData& ed = myEData(E); TopAbs_State st = myDS->Compare(E, ed); // Classification - if (st == TopAbs_IN || st == TopAbs_ON) // ************** + if (st == TopAbs_IN || st == TopAbs_ON) + { // ************** ed.Status().HideAll(); + } } else { @@ -399,8 +407,10 @@ void HLRBRep_Hider::Hide( HLRBRep_EdgeIList::ProcessComplex // complex transition on ILHidden (ILHidden, EIT); // ****************************** int level = 0; - if (!myDS->SimpleHidingFace()) // Level at Start + if (!myDS->SimpleHidingFace()) + { // Level at Start level = myDS->HidingStartLevel(E, ed, ILHidden); // ************** + } NCollection_List::Iterator It(ILHidden); if (myDS->SimpleHidingFace()) // remove excess interferences @@ -438,6 +448,7 @@ void HLRBRep_Hider::Hide( double aParam = It.Value().Intersection().Parameter(); bool found = false; for (int i = 1; i <= ToRemove.Length(); i++) + { if (aParam == ToRemove(i)) { found = true; @@ -445,8 +456,11 @@ void HLRBRep_Hider::Hide( ToRemove.Remove(i); break; } + } if (!found) + { It.Next(); + } } } // remove excess interferences @@ -462,18 +476,26 @@ void HLRBRep_Hider::Hide( case TopAbs_FORWARD: { int decal = Int.Intersection().Level(); if (level > 0) + { ILHidden.Remove(It); + } else + { It.Next(); + } level = level + decal; } break; case TopAbs_REVERSED: { level = level - Int.Intersection().Level(); if (level > 0) + { ILHidden.Remove(It); + } else + { It.Next(); + } } break; case TopAbs_EXTERNAL: @@ -487,10 +509,14 @@ void HLRBRep_Hider::Hide( break; } } - if (ILHidden.IsEmpty()) // Edge hidden - ES.HideAll(); // *********** + if (ILHidden.IsEmpty()) + { // Edge hidden + ES.HideAll(); // *********** + } else + { foundHidden = true; + } } if (!ILHidden.IsEmpty()) @@ -520,9 +546,13 @@ void HLRBRep_Hider::Hide( allRev = allRev && (It.Value().Transition() == TopAbs_REVERSED); allInt = allInt && (It.Value().Transition() == TopAbs_INTERNAL); if (p < pmin) + { pmin = p; + } if (p > pmax) + { pmax = p; + } } } @@ -568,9 +598,13 @@ void HLRBRep_Hider::Hide( if (allInt) { if (p1 < pmin) + { p1 = pmin; + } if (p2 > pmax) + { p2 = pmax; + } // HLRBRep_EdgeData& ed = myEData(E); // TopAbs_State st = myDS->Compare(E,ed); // Classification } @@ -641,12 +675,14 @@ void HLRBRep_Hider::Hide( } if (aTestState != TopAbs_OUT) + { ES.Hide(p1, tol1, p2, tol2, false, // under the Face true); // on the boundary + } EB.NextEdge(); } @@ -655,8 +691,10 @@ void HLRBRep_Hider::Hide( if (!ILOn.IsEmpty()) { int level = 0; - if (!myDS->SimpleHidingFace()) // Level at Start + if (!myDS->SimpleHidingFace()) + { // Level at Start level = myDS->HidingStartLevel(E, ed, ILOn); // ************** + } if (level > 0) { NCollection_List::Iterator It(ILOn); @@ -672,18 +710,26 @@ void HLRBRep_Hider::Hide( case TopAbs_FORWARD: { int decal = Int.Intersection().Level(); if (level > 0) + { ILOn.Remove(It); + } else + { It.Next(); + } level = level + decal; } break; case TopAbs_REVERSED: level = level - Int.Intersection().Level(); if (level > 0) + { ILOn.Remove(It); + } else + { It.Next(); + } break; case TopAbs_EXTERNAL: case TopAbs_INTERNAL: @@ -692,8 +738,10 @@ void HLRBRep_Hider::Hide( break; } } - if (ILOn.IsEmpty() && !foundHidden) // Edge hidden - ES.HideAll(); // *********** + if (ILOn.IsEmpty() && !foundHidden) + { // Edge hidden + ES.HideAll(); // *********** + } } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_InternalAlgo.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_InternalAlgo.cxx index bf115e0647..0c3ff8406a 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_InternalAlgo.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_InternalAlgo.cxx @@ -103,8 +103,8 @@ void HLRBRep_InternalAlgo::Update() if (myDebug) { std::cout << "An exception was caught when preparing the Shape " << i; - std::cout << " and computing its OutLines " << std::endl; - std::cout << anException << std::endl; + std::cout << " and computing its OutLines " << '\n'; + std::cout << anException << '\n'; } DS[i - 1] = new HLRBRep_Data(0, 0, 0); dv = 0; @@ -119,7 +119,9 @@ void HLRBRep_InternalAlgo::Update() } if (n == 1) + { myDS = DS[0]; + } else { myDS = new HLRBRep_Data(nv, ne, nf); @@ -165,7 +167,9 @@ void HLRBRep_InternalAlgo::Update() HLRAlgo::CopyMinMax(TheMin, TheMax, ShapMin, ShapMax); } else + { HLRAlgo::AddMinMax(TheMin, TheMax, ShapMin, ShapMax); + } } for (int f = f1; f <= f2; f++) @@ -205,8 +209,12 @@ int HLRBRep_InternalAlgo::Index(const occ::handle& S) cons int n = myShapes.Length(); for (int i = 1; i <= n; i++) + { if (myShapes(i).Shape() == S) + { return i; + } + } return 0; } @@ -273,7 +281,9 @@ void HLRBRep_InternalAlgo::InitEdgeStatus() { HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); if (ed.Selected()) + { ed.Status().ShowAll(); + } } // for (int f = 1; f <= nf; f++) { int f; @@ -287,7 +297,9 @@ void HLRBRep_InternalAlgo::InitEdgeStatus() { HLRBRep_EdgeData* edf = &(myDS->EDataArray().ChangeValue(faceIt.Edge())); if (edf->Selected()) + { edf->Status().HideAll(); + } } } } @@ -299,7 +311,9 @@ void HLRBRep_InternalAlgo::InitEdgeStatus() if (fd.Selected() && fd.Closed()) { if (fd.Side()) + { visible = false; + } else if (!fd.WithOutL()) { switch (fd.Orientation()) @@ -325,7 +339,9 @@ void HLRBRep_InternalAlgo::InitEdgeStatus() int E = faceIt.Edge(); HLRBRep_EdgeData* edf = &(myDS->EDataArray().ChangeValue(E)); if (edf->Selected() && !edf->Vertical()) + { edf->Status().ShowAll(); + } } } } @@ -468,7 +484,9 @@ void HLRBRep_InternalAlgo::ShowAll(const int I) { HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); if (ed.Selected()) + { ed.Status().ShowAll(); + } } } } @@ -508,7 +526,9 @@ void HLRBRep_InternalAlgo::HideAll(const int I) { HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); if (ed.Selected()) + { ed.Status().HideAll(); + } } } } @@ -522,10 +542,14 @@ void HLRBRep_InternalAlgo::PartialHide() int i, n = myShapes.Length(); if (myDebug) - std::cout << " Partial hiding" << std::endl << std::endl; + { + std::cout << " Partial hiding" << '\n' << '\n'; + } for (i = 1; i <= n; i++) + { Hide(i); + } Select(); } @@ -540,15 +564,25 @@ void HLRBRep_InternalAlgo::Hide() int i, j, n = myShapes.Length(); if (myDebug) - std::cout << " Total hiding" << std::endl; + { + std::cout << " Total hiding" << '\n'; + } for (i = 1; i <= n; i++) + { Hide(i); + } for (i = 1; i <= n; i++) + { for (j = 1; j <= n; j++) + { if (i != j) + { Hide(i, j); + } + } + } Select(); } @@ -564,7 +598,9 @@ void HLRBRep_InternalAlgo::Hide(const int I) "HLRBRep_InternalAlgo::Hide : unknown Shape"); if (myDebug) - std::cout << " hiding the shape " << I << " by itself" << std::endl; + { + std::cout << " hiding the shape " << I << " by itself" << '\n'; + } Select(I); InitEdgeStatus(); @@ -582,7 +618,9 @@ void HLRBRep_InternalAlgo::Hide(const int I, const int J) "HLRBRep_InternalAlgo::Hide : unknown Shapes"); if (I == J) + { Hide(I); + } else { HLRAlgo_EdgesBlock::MinMaxIndices* MinMaxShBI = &myShapes(I).MinMax(); @@ -605,7 +643,7 @@ void HLRBRep_InternalAlgo::Hide(const int I, const int J) if (myDebug) { std::cout << " hiding the shape " << I; - std::cout << " by the shape : " << J << std::endl; + std::cout << " by the shape : " << J << '\n'; } SelectEdge(I); SelectFace(J); @@ -664,7 +702,9 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) { nbSelEdges++; if (!ed.Status().AllHidden()) + { nbVisEdges++; + } } } @@ -675,32 +715,42 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) { nbSelFaces++; if (fd.Hiding()) + { nbCache++; + } if (fd.Side()) + { nbFSide++; + } if (fd.Simple()) + { nbFSimp++; + } } } if (myDebug) { - std::cout << std::endl; - std::cout << "Vertices : " << std::setw(5) << myDS->NbVertices() << std::endl; + std::cout << '\n'; + std::cout << "Vertices : " << std::setw(5) << myDS->NbVertices() << '\n'; std::cout << "Edges : " << std::setw(5) << myDS->NbEdges() << " , "; std::cout << "Selected : " << std::setw(5) << nbSelEdges << " , "; - std::cout << "Visible : " << std::setw(5) << nbVisEdges << std::endl; + std::cout << "Visible : " << std::setw(5) << nbVisEdges << '\n'; std::cout << "Faces : " << std::setw(5) << myDS->NbFaces() << " , "; std::cout << "Selected : " << std::setw(5) << nbSelFaces << " , "; - std::cout << "Simple : " << std::setw(5) << nbFSimp << std::endl; + std::cout << "Simple : " << std::setw(5) << nbFSimp << '\n'; if (SideFace) + { std::cout << "Side : " << std::setw(5) << nbFSide << " , "; - std::cout << "Cachantes : " << std::setw(5) << nbCache << std::endl << std::endl; + } + std::cout << "Cachantes : " << std::setw(5) << nbCache << '\n' << '\n'; } } if (nf == 0) + { return; + } int QWE = 0, QWEQWE; QWEQWE = nf / 10; @@ -722,7 +772,9 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) { QWE = 0; if (myDebug) + { std::cout << "*"; + } } } else @@ -730,7 +782,7 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) if (myDebug && HLRBRep_InternalAlgo_TRACE) { j++; - std::cout << " OwnHiding " << j << " of face : " << f << std::endl; + std::cout << " OwnHiding " << j << " of face : " << f << '\n'; } } Cache.OwnHiding(f); @@ -748,23 +800,41 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) { HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); if (fd.Plane()) + { Val(f) = 10; + } else if (fd.Cylinder()) + { Val(f) = 9; + } else if (fd.Cone()) + { Val(f) = 8; + } else if (fd.Sphere()) + { Val(f) = 7; + } else if (fd.Torus()) + { Val(f) = 6; + } else + { Val(f) = 0; + } if (fd.Cut()) + { Val(f) -= 10; + } if (fd.Side()) + { Val(f) -= 100; + } if (fd.WithOutL()) + { Val(f) -= 20; + } Size(f) = fd.Size(); } @@ -824,11 +894,15 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) if (k < ir) { if (Val(Index(k)) > Val(Index(k + 1))) + { k++; + } else if (Val(Index(k)) == Val(Index(k + 1))) { if (Size(Index(k)) > Size(Index(k + 1))) + { k++; + } } } if (Val(rra) > Val(Index(k))) @@ -868,7 +942,9 @@ void HLRBRep_InternalAlgo::HideSelected(const int I, const bool SideFace) if (++QWE > QWEQWE) { if (myDebug) + { std::cout << "."; + } QWE = 0; } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Intersector.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Intersector.cxx index cdcc2885d7..21a29778ae 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Intersector.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Intersector.cxx @@ -108,9 +108,13 @@ void HLRBRep_Intersector::Perform(HLRBRep_EdgeData* theEdge1, theEdge1->Status().Bounds(a, ta, b, tb); d = b - a; if (theDa1 != 0) + { a = a + d * theDa1; + } if (theDb1 != 0) + { b = b - d * theDb1; + } myC1->D0(a, pa); myC1->D0(b, pb); a = myC1->Parameter2d(a); @@ -160,9 +164,13 @@ void HLRBRep_Intersector::Perform(const int /*theNA*/, tol2 = Precision::Confusion(); ////////////////////////////////////////// if (tol1 > tol2) + { tol = tol1; + } else + { tol = tol2; + } bool aPasBon; double aDecalagea1 = 100.0; @@ -175,14 +183,20 @@ void HLRBRep_Intersector::Perform(const int /*theNA*/, theEdge1->Status().Bounds(a1, ta, b1, tb); //-- -> Parametres 3d double mtol = tol; if (mtol < ta) + { mtol = ta; + } if (mtol < tb) + { mtol = tb; + } d = b1 - a1; double pdist = tol; if (pdist < 0.0000001) + { pdist = 0.0000001; + } if (theDa1 != 0) { @@ -252,18 +266,26 @@ void HLRBRep_Intersector::Perform(const int /*theNA*/, } if (ta > tol) + { ta = (float)tol; + } if (tb > tol) + { tb = (float)tol; + } IntRes2d_Domain D1(pa1, a1, (double)ta, pb1, b1, (double)tb); theEdge2->Status().Bounds(a2, ta, b2, tb); mtol = tol; if (mtol < ta) + { mtol = ta; + } if (mtol < tb) + { mtol = tb; + } d = b2 - a2; @@ -335,9 +357,13 @@ void HLRBRep_Intersector::Perform(const int /*theNA*/, } if (ta > tol) + { ta = (float)tol; + } if (tb > tol) + { tb = (float)tol; + } IntRes2d_Domain D2(pa2, a2, (double)ta, pb2, b2, (double)tb); @@ -524,42 +550,70 @@ void HLRBRep_Intersector::Perform(const gp_Lin& L, const double P) pmin = pmax = p; p = ElCLib::Parameter(L, gp_Pnt(x0, y0, z1)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x1, y0, z0)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x1, y0, z1)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x0, y1, z0)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x0, y1, z1)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x1, y1, z0)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } p = ElCLib::Parameter(L, gp_Pnt(x1, y1, z1)); if (pmin > p) + { pmin = p; + } if (pmax < p) + { pmax = p; + } pmin -= 0.000001; pmax += 0.000001; @@ -571,7 +625,9 @@ void HLRBRep_Intersector::Perform(const gp_Lin& L, const double P) else { if (pmax > P) + { pmax = P + 0.0000001; + } } HLRBRep_ThePolygonOfInterCSurf Polygon(L, pmin, pmax, 3); myCSIntersector.Perform(L, @@ -596,11 +652,17 @@ void HLRBRep_Intersector::Perform(const gp_Lin& L, const double P) bool HLRBRep_Intersector::IsDone() const { if (myTypePerform == 1) + { return myIntersector.IsDone(); + } else if (myTypePerform == 2) + { return myCSIntersector.IsDone(); + } else + { return (true); + } } //================================================================================================= @@ -608,14 +670,22 @@ bool HLRBRep_Intersector::IsDone() const int HLRBRep_Intersector::NbPoints() const { if (myTypePerform == 43) + { return (0); + } if (myTypePerform == 1) + { return myIntersector.NbPoints(); + } else if (myTypePerform == 2) + { return myCSIntersector.NbPoints(); + } else + { return (1); + } } //================================================================================================= @@ -623,9 +693,13 @@ int HLRBRep_Intersector::NbPoints() const const IntRes2d_IntersectionPoint& HLRBRep_Intersector::Point(const int N) const { if (myTypePerform == 0) + { return (mySinglePoint); + } else + { return myIntersector.Point(N); + } } //================================================================================================= @@ -640,11 +714,17 @@ const IntCurveSurface_IntersectionPoint& HLRBRep_Intersector::CSPoint(const int int HLRBRep_Intersector::NbSegments() const { if (myTypePerform == 1) + { return myIntersector.NbSegments(); + } else if (myTypePerform == 2) + { return myCSIntersector.NbSegments(); + } else + { return (0); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_PolyHLRToShape.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_PolyHLRToShape.cxx index 3e3c293415..512db1ed2f 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_PolyHLRToShape.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_PolyHLRToShape.cxx @@ -89,9 +89,13 @@ TopoDS_Shape HLRBRep_PolyHLRToShape::InternalCompound(const int typ, { TopExp_Explorer ex; for (ex.Init(S, TopAbs_EDGE); ex.More(); ex.Next()) + { Map.Add(ex.Current()); + } for (ex.Init(S, TopAbs_FACE); ex.More(); ex.Next()) + { Map.Add(ex.Current()); + } } bool todraw, reg1, regn, outl, intl; bool added = false; @@ -103,9 +107,13 @@ TopoDS_Shape HLRBRep_PolyHLRToShape::InternalCompound(const int typ, { NCollection_List::Iterator It; if (visible) + { It.Initialize(myBiPntVis); + } else + { It.Initialize(myBiPntHid); + } for (; It.More(); It.Next()) { @@ -115,16 +123,28 @@ TopoDS_Shape HLRBRep_PolyHLRToShape::InternalCompound(const int typ, outl = BP.OutLine(); intl = BP.IntLine(); if (typ == 1) + { todraw = intl; + } else if (typ == 2) + { todraw = reg1 && !regn && !outl; + } else if (typ == 3) + { todraw = regn && !outl; + } else + { todraw = !intl && (!reg1 || outl); + } if (todraw) + { if (!S.IsNull()) + { todraw = Map.Contains(BP.Shape()); + } + } if (todraw) { const gp_Pnt2d& FirstP2d = BP.P1(); @@ -146,16 +166,28 @@ TopoDS_Shape HLRBRep_PolyHLRToShape::InternalCompound(const int typ, { HLRAlgo_BiPoint::PointsT& aPoints = myAlgo->Show(SBP, reg1, regn, outl, intl); if (typ == 1) + { todraw = intl; + } else if (typ == 2) + { todraw = reg1 && !regn && !outl; + } else if (typ == 3) + { todraw = regn && !outl; + } else + { todraw = !intl && (!reg1 || outl); + } if (todraw) + { if (!S.IsNull()) + { todraw = Map.Contains(SBP); + } + } if (todraw) { gp_XYZ aSta = aPoints.Pnt1, aEnd = aPoints.Pnt2; @@ -173,6 +205,8 @@ TopoDS_Shape HLRBRep_PolyHLRToShape::InternalCompound(const int typ, } } if (!added) + { Result = TopoDS_Shape(); + } return Result; } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ShapeToHLR.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ShapeToHLR.cxx index dc89fc0674..97a91dc72f 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ShapeToHLR.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ShapeToHLR.cxx @@ -61,14 +61,18 @@ occ::handle HLRBRep_ShapeToHLR::Load( for (exface.Init(exshell.Current(), TopAbs_FACE); exface.More(); exface.Next()) { if (!FM.Contains(exface.Current())) + { FM.Add(exface.Current()); + } } } for (exface.Init(S->OutLinedShape(), TopAbs_FACE, TopAbs_SHELL); exface.More(); exface.Next()) { // faces not in a shell if (!FM.Contains(exface.Current())) + { FM.Add(exface.Current()); + } } TopExp::MapShapes(S->OutLinedShape(), TopAbs_EDGE, EM); @@ -76,8 +80,10 @@ occ::handle HLRBRep_ShapeToHLR::Load( int i; int nbEdge = EM.Extent(); - for (i = 1; i <= nbEdge; i++) // vertices back to edges + for (i = 1; i <= nbEdge; i++) + { // vertices back to edges TopExp::MapShapesAndAncestors(EM(i), TopAbs_VERTEX, TopAbs_EDGE, VerticesToEdges); + } int nbVert = VerticesToEdges.Extent(); int nbFace = FM.Extent(); @@ -94,7 +100,9 @@ occ::handle HLRBRep_ShapeToHLR::Load( occ::handle DS = new HLRBRep_Data(nbVert, nbEdge, nbFace); HLRBRep_EdgeData* ed = nullptr; if (nbEdge != 0) + { ed = &(DS->EDataArray().ChangeValue(1)); + } // ed++; for (i = 1; i <= nbFace; i++) @@ -187,7 +195,9 @@ void HLRBRep_ShapeToHLR::ExploreFace( int nw = 0; for (Ex1.Init(theFace, TopAbs_WIRE); Ex1.More(); Ex1.Next()) + { nw++; + } fd.Set(theFace, orient, closed, nw); nw = 0; @@ -201,7 +211,9 @@ void HLRBRep_ShapeToHLR::ExploreFace( { const TopoDS_Edge& anEdge = TopoDS::Edge(Ex2.Current()); if (!BRep_Tool::Degenerated(anEdge)) + { ne++; + } } fd.SetWire(nw, ne); @@ -211,7 +223,9 @@ void HLRBRep_ShapeToHLR::ExploreFace( { const TopoDS_Edge& E = TopoDS::Edge(Ex2.Current()); if (BRep_Tool::Degenerated(E)) + { continue; + } ne++; int ie = EM.FindIndex(E); TopAbs_Orientation anOrientE = E.Orientation(); @@ -249,7 +263,9 @@ void HLRBRep_ShapeToHLR::ExploreShape( int* flag = new int[nbEdge + 1]; for (ie = 1; ie <= nbEdge; ie++) + { flag[ie] = 0; + } for (exedge.Init(exshell.Current(), TopAbs_EDGE); exedge.More(); exedge.Next()) { @@ -259,15 +275,21 @@ void HLRBRep_ShapeToHLR::ExploreShape( if (!BRep_Tool::Degenerated(E)) { if (orient == TopAbs_FORWARD) + { flag[ie] += 1; + } else if (orient == TopAbs_REVERSED) + { flag[ie] -= 1; + } } } closed = true; for (ie = 1; ie <= nbEdge && closed; ie++) + { closed = (flag[ie] == 0); + } delete[] flag; flag = nullptr; } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Surface.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Surface.cxx index 36b89b4964..ece6466138 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Surface.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_Surface.cxx @@ -56,7 +56,9 @@ void HLRBRep_Surface::Surface(const TopoDS_Face& F) myType = GeomAbs_Plane; } else + { myType = typ; + } break; default: @@ -82,7 +84,9 @@ bool HLRBRep_Surface::SideRowsOfPoles(const double tol, { for (iv = 1; iv <= nbvPoles; iv++) + { Pnt(iu, iv).Transform(T); + } } result = true; @@ -97,7 +101,9 @@ bool HLRBRep_Surface::SideRowsOfPoles(const double tol, } } if (result) + { return result; + } result = true; for (iv = 1; iv <= nbvPoles && result; iv++) @@ -111,7 +117,9 @@ bool HLRBRep_Surface::SideRowsOfPoles(const double tol, } } if (result) + { return result; + } // Are the Poles in a Side Plane ? NCollection_Array1 p(1, nbuPoles * nbvPoles); @@ -129,7 +137,9 @@ bool HLRBRep_Surface::SideRowsOfPoles(const double tol, PointSetLib_Equation Pl(p, tol); if (Pl.IsPlanar()) + { result = std::abs(Pl.Plane().Axis().Direction().Z()) < 0.0001; + } return result; } @@ -155,13 +165,17 @@ bool HLRBRep_Surface::IsSide(const double tolF, const double toler) const r = D.Z() * myProj->Focus() - (D.X() * Pt.X() + D.Y() * Pt.Y() + D.Z() * Pt.Z()); } else + { r = D.Z(); + } return std::abs(r) < toler; } else if (myType == GeomAbs_Cylinder) { if (myProj->Perspective()) + { return false; + } gp_Cylinder Cyl = HLRBRep_BSurfaceTool::Cylinder(mySurf); gp_Ax1 A = Cyl.Axis(); D = A.Direction(); @@ -172,7 +186,9 @@ bool HLRBRep_Surface::IsSide(const double tolF, const double toler) const else if (myType == GeomAbs_Cone) { if (!myProj->Perspective()) + { return false; + } gp_Cone Con = HLRBRep_BSurfaceTool::Cone(mySurf); Pt = Con.Apex(); Pt.Transform(myProj->Transformation()); @@ -182,31 +198,45 @@ bool HLRBRep_Surface::IsSide(const double tolF, const double toler) const else if (myType == GeomAbs_BezierSurface) { if (myProj->Perspective()) + { return false; + } int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf); int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf); NCollection_Array2 Pnt(1, nu, 1, nv); const NCollection_Array2& aSrcPoles = HLRBRep_BSurfaceTool::Bezier(mySurf)->Poles(); for (int iu = 1; iu <= nu; iu++) + { for (int iv = 1; iv <= nv; iv++) + { Pnt(iu, iv) = aSrcPoles(iu, iv); + } + } return SideRowsOfPoles(tolF, nu, nv, Pnt); } else if (myType == GeomAbs_BSplineSurface) { if (myProj->Perspective()) + { return false; + } int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf); int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf); NCollection_Array2 Pnt(1, nu, 1, nv); const NCollection_Array2& aSrcPoles = HLRBRep_BSurfaceTool::BSpline(mySurf)->Poles(); for (int iu = 1; iu <= nu; iu++) + { for (int iv = 1; iv <= nv; iv++) + { Pnt(iu, iv) = aSrcPoles(iu, iv); + } + } return SideRowsOfPoles(tolF, nu, nv, Pnt); } else + { return false; + } } //================================================================================================= @@ -228,9 +258,13 @@ bool HLRBRep_Surface::IsAbove(const bool back, const HLRBRep_Curve* A, const dou P.Coord(x, y, z); dd = a * x + b * y + c * z + d; if (back) + { dd = -dd; + } if (dd < -tol) + { return false; + } if (A->GetType() != GeomAbs_Line) { int nbPnt = 30; @@ -242,9 +276,13 @@ bool HLRBRep_Surface::IsAbove(const bool back, const HLRBRep_Curve* A, const dou P.Coord(x, y, z); dd = a * x + b * y + c * z + d; if (back) + { dd = -dd; + } if (dd < -tol) + { return false; + } } } u = u2; @@ -252,13 +290,19 @@ bool HLRBRep_Surface::IsAbove(const bool back, const HLRBRep_Curve* A, const dou P.Coord(x, y, z); dd = a * x + b * y + c * z + d; if (back) + { dd = -dd; + } if (dd < -tol) + { return false; + } return true; } else + { return false; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_SurfaceTool.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_SurfaceTool.cxx index e35c034feb..0ed745c681 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_SurfaceTool.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_SurfaceTool.cxx @@ -37,7 +37,9 @@ int HLRBRep_SurfaceTool::NbSamplesU(const HLRBRep_Surface* theSurf) nbs = theSurf->NbUKnots(); nbs *= theSurf->UDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Torus: { @@ -81,7 +83,9 @@ int HLRBRep_SurfaceTool::NbSamplesV(const HLRBRep_Surface* theSurf) nbs = theSurf->NbVKnots(); nbs *= theSurf->VDegree(); if (nbs < 2) + { nbs = 2; + } } break; case GeomAbs_Cylinder: @@ -116,9 +120,13 @@ int HLRBRep_SurfaceTool::NbSamplesU(const HLRBRep_Surface* theSurf, const double ul = LastUParameter(theSurf); n *= (int)((theU2 - theU1) / (uf - ul)); if (n > nbs) + { n = nbs; + } if (n < 5) + { n = 5; + } } return n; } @@ -137,9 +145,13 @@ int HLRBRep_SurfaceTool::NbSamplesV(const HLRBRep_Surface* theSurf, const double vl = LastVParameter(theSurf); n *= (int)((theV2 - theV1) / (vf - vl)); if (n > nbs) + { n = nbs; + } if (n < 5) + { n = 5; + } } return n; } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ThePolygonToolOfInterCSurf_0.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ThePolygonToolOfInterCSurf_0.cxx index 146dcb947d..73f425a613 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ThePolygonToolOfInterCSurf_0.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ThePolygonToolOfInterCSurf_0.cxx @@ -28,17 +28,16 @@ void HLRBRep_ThePolygonToolOfInterCSurf::Dump(const HLRBRep_ThePolygonOfInterCSu static int num = 0; num++; int nbs = HLRBRep_ThePolygonToolOfInterCSurf::NbSegments(L); - std::cout << "\npol2d " << num << " " << nbs << std::endl; + std::cout << "\npol2d " << num << " " << nbs << '\n'; std::cout << "Deflection " << HLRBRep_ThePolygonToolOfInterCSurf::DeflectionOverEstimation(L) - << std::endl; + << '\n'; for (int i = 1; i <= nbs; i++) { gp_Pnt P(HLRBRep_ThePolygonToolOfInterCSurf::BeginOfSeg(L, i)); - std::cout << "pnt " << num << " " << i << " " << P.X() << " " << P.Y() << " " << P.Z() - << std::endl; + std::cout << "pnt " << num << " " << i << " " << P.X() << " " << P.Y() << " " << P.Z() << '\n'; } gp_Pnt PF(HLRBRep_ThePolygonToolOfInterCSurf::EndOfSeg(L, nbs)); std::cout << "pnt " << num << " " << nbs << " " << PF.X() << " " << PF.Y() << " " << PF.Z() - << std::endl; + << '\n'; } diff --git a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_VertexList.cxx b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_VertexList.cxx index 77c505fccf..62d1fd8346 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_VertexList.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_VertexList.cxx @@ -55,9 +55,13 @@ bool HLRBRep_VertexList::More() const void HLRBRep_VertexList::Next() { if (fromInterf) + { myIterator.Next(); + } if (fromEdge) + { myTool.NextVertex(); + } fromInterf = myIterator.More(); fromEdge = myTool.MoreVertices(); if (fromEdge && fromInterf) @@ -81,11 +85,17 @@ void HLRBRep_VertexList::Next() const HLRAlgo_Intersection& HLRBRep_VertexList::Current() const { if (fromEdge) + { return myTool.CurrentVertex(); + } else if (fromInterf) + { return myIterator.Value().Intersection(); + } else + { throw Standard_NoSuchObject("HLRBRep_VertexList::Current"); + } } //================================================================================================= @@ -107,9 +117,13 @@ bool HLRBRep_VertexList::IsInterference() const TopAbs_Orientation HLRBRep_VertexList::Orientation() const { if (fromEdge) + { return myTool.CurrentOrientation(); + } else + { throw Standard_DomainError("HLRBRep_VertexList::Orientation"); + } } //================================================================================================= @@ -117,9 +131,13 @@ TopAbs_Orientation HLRBRep_VertexList::Orientation() const TopAbs_Orientation HLRBRep_VertexList::Transition() const { if (fromInterf) + { return myIterator.Value().Transition(); + } else + { throw Standard_DomainError("HLRBRep_VertexList::Transition"); + } } //================================================================================================= @@ -127,7 +145,11 @@ TopAbs_Orientation HLRBRep_VertexList::Transition() const TopAbs_Orientation HLRBRep_VertexList::BoundaryTransition() const { if (fromInterf) + { return myIterator.Value().BoundaryTransition(); + } else + { throw Standard_DomainError("HLRBRep_VertexList::BoundaryTransition"); + } } diff --git a/src/ModelingAlgorithms/TKHLR/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx b/src/ModelingAlgorithms/TKHLR/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx index d08b7f3c52..9f1f92a9f9 100644 --- a/src/ModelingAlgorithms/TKHLR/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx +++ b/src/ModelingAlgorithms/TKHLR/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx @@ -98,10 +98,14 @@ void HLRTopoBRep_DSFiller::Insert( if (FO.IsDone()) { if (!FO.IsEmpty()) + { InsertFace(f, S1, FO, DS, withPCurve); + } } if (nbIso != 0) + { HLRTopoBRep_FaceIsoLiner::Perform(f, S1, DS, nbIso); + } } ex.Next(); } @@ -177,9 +181,13 @@ void HLRTopoBRep_DSFiller::InsertFace(const int /*FI*/, const Contap_Point PF = Line.Vertex(CurPoint); if (PF.IsInternal() && CurPoint != 1) + { VF = VL; + } else + { VF = MakeVertex(PF, tol, DS); + } const double parF = PF.ParameterOnLine(); if (CurPoint < NbPoints) @@ -358,17 +366,29 @@ void HLRTopoBRep_DSFiller::InsertFace(const int /*FI*/, mults.SetValue(i, 1); const gp_Pnt& P = Line.Point(i + ipF - 1).Value(); if (P.X() < Minx) + { Minx = P.X(); + } if (P.Y() < Miny) + { Miny = P.Y(); + } if (P.Z() < Minz) + { Minz = P.Z(); + } if (P.X() > Maxx) + { Maxx = P.X(); + } if (P.Y() > Maxy) + { Maxy = P.Y(); + } if (P.Z() > Maxz) + { Maxz = P.Z(); + } Points.SetValue(i, P); } mults(1) = mults(nbp) = 2; @@ -384,13 +404,21 @@ void HLRTopoBRep_DSFiller::InsertFace(const int /*FI*/, double u, v; Line.Point(i + ipF - 1).ParametersOnS2(u, v); if (u < Minu) + { Minu = u; + } if (v < Minv) + { Minv = v; + } if (u > Maxu) + { Maxu = u; + } if (v > Maxv) + { Maxv = v; + } Points2d.SetValue(i, gp_Pnt2d(u, v)); } AppC2d = new Geom2d_BSplineCurve(Points2d, knots, mults, 1); @@ -413,22 +441,36 @@ void HLRTopoBRep_DSFiller::InsertFace(const int /*FI*/, Maxu -= Minu; Maxv -= Minv; if (Maxy > Maxx) + { Maxx = Maxy; + } if (Maxz > Maxx) + { Maxx = Maxy; + } if (Maxv > Maxu) + { Maxu = Maxv; + } TOL3d = TOL * Maxx; if (TOL3d < 1e-12) + { TOL3d = 1e-12; + } else if (TOL3d > 0.1) + { TOL3d = 0.1; + } TOL2d = TOL * Maxu; if (TOL2d < 1e-12) + { TOL2d = 1e-12; + } else if (TOL2d > 0.1) + { TOL2d = 0.1; + } //-- std::cout<<"\nHLRTopoBRep_DSFiller : nbp="< nbBoundReversed) + { return TopAbs_FORWARD; + } else if (nbBoundForward < nbBoundReversed) + { return TopAbs_REVERSED; + } else if ((nbBoundReversed % 2) == 0) + { return TopAbs_EXTERNAL; + } else + { return TopAbs_EXTERNAL; + } } diff --git a/src/ModelingAlgorithms/TKHelix/HelixBRep/HelixBRep_BuilderHelix.cxx b/src/ModelingAlgorithms/TKHelix/HelixBRep/HelixBRep_BuilderHelix.cxx index e29804f2ac..e22453a670 100644 --- a/src/ModelingAlgorithms/TKHelix/HelixBRep/HelixBRep_BuilderHelix.cxx +++ b/src/ModelingAlgorithms/TKHelix/HelixBRep/HelixBRep_BuilderHelix.cxx @@ -184,7 +184,9 @@ void HelixBRep_BuilderHelix::Perform() { if (myErrorStatus != 0) + { return; + } int i; @@ -225,7 +227,9 @@ void HelixBRep_BuilderHelix::Perform() BuildPart(anAxis, aPStart, aHeight, aPitch, aTaperAngle, bIsClockwise, aPart); if (myErrorStatus != 0) + { return; + } TopoDS_Vertex V1, V2; @@ -264,7 +268,9 @@ void HelixBRep_BuilderHelix::BuildPart(const gp_Ax1& theAxis, { if (myErrorStatus != 0) + { return; + } myErrorStatus = 0; myWarningStatus = 0; @@ -415,7 +421,9 @@ void HelixBRep_BuilderHelix::BuildPart(const gp_Ax1& theAxis, } // if (myTolReached > myTolerance) + { myWarningStatus = 1; + } } //================================================================================================= @@ -423,7 +431,9 @@ void HelixBRep_BuilderHelix::BuildPart(const gp_Ax1& theAxis, void HelixBRep_BuilderHelix::Smoothing(NCollection_List& theParts) { if (theParts.Extent() == 1) + { return; + } BRepTools_WireExplorer anExpl; @@ -476,7 +486,9 @@ void HelixBRep_BuilderHelix::SmoothingEdges(TopoDS_Edge& thePrev, TopoDS_Edge& t aCNext->D1(f2, P2, V2); if (V1.Angle(V2) < EpsAng) + { return; + } V1 = 0.5 * (V1 + V2); V2 = V1; diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_BaseMeshAlgo.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_BaseMeshAlgo.cxx index a34080e180..471d2de7f7 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_BaseMeshAlgo.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_BaseMeshAlgo.cxx @@ -175,13 +175,19 @@ int BRepMesh_BaseMeshAlgo::addLinkToMesh(const int theFirstNodeId { int aLinkIndex; if (theOrientation == TopAbs_REVERSED) + { aLinkIndex = myStructure->AddLink(BRepMesh_Edge(theLastNodeId, theFirstNodeId, BRepMesh_Frontier)); + } else if (theOrientation == TopAbs_INTERNAL) + { aLinkIndex = myStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Fixed)); + } else + { aLinkIndex = myStructure->AddLink(BRepMesh_Edge(theFirstNodeId, theLastNodeId, BRepMesh_Frontier)); + } return std::abs(aLinkIndex); } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_CircleTool.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_CircleTool.cxx index dcbbbe4b1f..a4e8abb3c7 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_CircleTool.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_CircleTool.cxx @@ -85,19 +85,25 @@ bool BRepMesh_CircleTool::MakeCircle(const gp_XY& thePoint1, const_cast(thePoint3).ChangeCoord(1) - const_cast(thePoint2).ChangeCoord(1), const_cast(thePoint2).ChangeCoord(2) - const_cast(thePoint3).ChangeCoord(2)); if (aLink1.SquareModulus() < aSqPrecision) + { return false; + } gp_XY aLink2( const_cast(thePoint1).ChangeCoord(1) - const_cast(thePoint3).ChangeCoord(1), const_cast(thePoint3).ChangeCoord(2) - const_cast(thePoint1).ChangeCoord(2)); if (aLink2.SquareModulus() < aSqPrecision) + { return false; + } gp_XY aLink3( const_cast(thePoint2).ChangeCoord(1) - const_cast(thePoint1).ChangeCoord(1), const_cast(thePoint1).ChangeCoord(2) - const_cast(thePoint2).ChangeCoord(2)); if (aLink3.SquareModulus() < aSqPrecision) + { return false; + } const double aD = 2 * (const_cast(thePoint1).ChangeCoord(1) * aLink1.Y() @@ -105,7 +111,9 @@ bool BRepMesh_CircleTool::MakeCircle(const gp_XY& thePoint1, + const_cast(thePoint3).ChangeCoord(1) * aLink3.Y()); if (std::abs(aD) < gp::Resolution()) + { return false; + } const double aInvD = 1. / aD; const double aSqMod1 = thePoint1.SquareModulus(); @@ -135,7 +143,9 @@ bool BRepMesh_CircleTool::Bind(const int theIndex, gp_XY aLocation; double aRadius; if (!MakeCircle(thePoint1, thePoint2, thePoint3, aLocation, aRadius)) + { return false; + } bind(theIndex, aLocation, aRadius); return true; @@ -147,7 +157,9 @@ void BRepMesh_CircleTool::Delete(const int theIndex) { BRepMesh_Circle& aCircle = mySelector.Circle(theIndex); if (aCircle.Radius() > 0.) + { aCircle.SetRadius(-1); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Classifier.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Classifier.cxx index ef0fb0b6f1..85745471c8 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Classifier.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Classifier.cxx @@ -111,7 +111,9 @@ void BRepMesh_Classifier::RegisterWire(const NCollection_Sequence aCurve2d = BRep_Tool::CurveOnSurface(aCurrEdge, aFace, aF, aL); NCollection_Array1 aParamArray(1, aNodesNb); for (int i = 1; i <= aNodesNb; ++i) + { aParamArray.SetValue(i, myDiscretTool.Parameter(i)); + } for (int i = 1; i < aNodesNb; ++i) + { splitSegment(aSurface, aCurve2d, aParamArray(i), aParamArray(i + 1), 1); + } } } } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx index aa45b1921c..a1c69e1224 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx @@ -45,7 +45,9 @@ int BRepMesh_DataStructureOfDelaun::AddNode(const BRepMesh_Vertex& theNode, cons { const int aNodeId = myNodes->Add(theNode, isForceAdd); if (!myNodeLinks.IsBound(aNodeId)) + { myNodeLinks.Bind(aNodeId, IMeshData::ListOfInteger(myAllocator)); + } return aNodeId; } @@ -56,7 +58,9 @@ bool BRepMesh_DataStructureOfDelaun::SubstituteNode(const int theIn const BRepMesh_Vertex& theNewNode) { if (myNodes->FindIndex(theNewNode) != 0) + { return false; + } myNodes->Substitute(theIndex, theNewNode); return true; @@ -80,7 +84,9 @@ int BRepMesh_DataStructureOfDelaun::AddLink(const BRepMesh_Edge& theLink) myDelLinks.RemoveFirst(); } else + { aLinkIndex = myLinks.Add(theLink, aPair); + } const int aLinkId = std::abs(aLinkIndex); linksConnectedTo(theLink.FirstNode()).Append(aLinkId); @@ -104,7 +110,9 @@ bool BRepMesh_DataStructureOfDelaun::SubstituteLink(const int theInde } if (IndexOf(theNewLink) != 0) + { return false; + } aLink.SetMovability(BRepMesh_Deleted); myLinks.Substitute(theIndex, aLink, aPair); @@ -167,7 +175,9 @@ int BRepMesh_DataStructureOfDelaun::AddElement(const BRepMesh_Triangle& theEleme const int (&e)[3] = theElement.myEdges; for (int i = 0; i < 3; ++i) + { myLinks(e[i]).Append(aElementIndex); + } return aElementIndex; } @@ -178,7 +188,9 @@ void BRepMesh_DataStructureOfDelaun::RemoveElement(const int theIndex) { BRepMesh_Triangle& aElement = (BRepMesh_Triangle&)GetElement(theIndex); if (aElement.Movability() == BRepMesh_Deleted) + { return; + } cleanElement(theIndex, aElement); aElement.SetMovability(BRepMesh_Deleted); @@ -191,11 +203,15 @@ void BRepMesh_DataStructureOfDelaun::cleanElement(const int theIn const BRepMesh_Triangle& theElement) { if (theElement.Movability() != BRepMesh_Free) + { return; + } const int (&e)[3] = theElement.myEdges; for (int i = 0; i < 3; ++i) + { removeElementIndex(theIndex, myLinks(e[i])); + } } //================================================================================================= @@ -231,7 +247,9 @@ bool BRepMesh_DataStructureOfDelaun::SubstituteElement(const int const int (&e)[3] = theNewElement.myEdges; for (int i = 0; i < 3; ++i) + { myLinks(e[i]).Append(theIndex); + } return true; } @@ -258,9 +276,13 @@ void BRepMesh_DataStructureOfDelaun::ElementNodes(const BRepMesh_Triangle& theEl const BRepMesh_Edge& aLink2 = GetLink(e[2]); if (o[2]) + { theNodes[2] = aLink2.FirstNode(); + } else + { theNodes[2] = aLink2.LastNode(); + } } //================================================================================================= @@ -277,7 +299,9 @@ void BRepMesh_DataStructureOfDelaun::ClearDomain() const int (&e)[3] = aElement.myEdges; for (int i = 0; i < 3; ++i) + { aFreeEdges.Add(e[i]); + } cleanElement(aElementId, aElement); aElement.SetMovability(BRepMesh_Deleted); @@ -286,7 +310,9 @@ void BRepMesh_DataStructureOfDelaun::ClearDomain() IMeshData::IteratorOfMapOfInteger aEdgeIt(aFreeEdges); for (; aEdgeIt.More(); aEdgeIt.Next()) + { RemoveLink(aEdgeIt.Key()); + } } //================================================================================================= @@ -299,7 +325,9 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() while (aLastLiveItem > 0) { if (GetLink(aLastLiveItem).Movability() != BRepMesh_Deleted) + { break; + } myLinks.RemoveLast(); --aLastLiveItem; @@ -309,7 +337,9 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() myDelLinks.RemoveFirst(); if (aDelItem > aLastLiveItem) + { continue; + } BRepMesh_Edge aLink = GetLink(aLastLiveItem); BRepMesh_PairOfIndex& aPair = myLinks(aLastLiveItem); @@ -373,7 +403,9 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() while (aLastLiveItem > 0) { if (GetNode(aLastLiveItem).Movability() != BRepMesh_Deleted) + { break; + } myNodes->RemoveLast(); --aLastLiveItem; @@ -383,7 +415,9 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() aDelNodes.RemoveFirst(); if (aDelItem > aLastLiveItem) + { continue; + } BRepMesh_Vertex aNode = GetNode(aLastLiveItem); IMeshData::ListOfInteger& aLinkList = linksConnectedTo(aLastLiveItem); @@ -404,9 +438,13 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() int v[2] = {aLink.FirstNode(), aLink.LastNode()}; if (v[0] == aLastLiveItemId) + { v[0] = aDelItem; + } else if (v[1] == aLastLiveItemId) + { v[1] = aDelItem; + } myLinks.Substitute(aLinkId, BRepMesh_Edge(v[0], v[1], aLink.Movability()), aPair); } @@ -432,7 +470,9 @@ const char* BRepMesh_Dump(void* theMeshHandlePtr, const char* theFileNameStr) *(occ::handle*)theMeshHandlePtr; if (aMeshData.IsNull()) + { return "Error: mesh data is empty"; + } TopoDS_Compound aMesh; BRep_Builder aBuilder; @@ -468,14 +508,18 @@ const char* BRepMesh_Dump(void* theMeshHandlePtr, const char* theFileNameStr) } if (aPnt[0].SquareDistance(aPnt[1]) < Precision::SquareConfusion()) + { continue; + } aBuilder.Add(aMesh, BRepBuilderAPI_MakeEdge(aPnt[0], aPnt[1])); } } if (!BRepTools::Write(aMesh, theFileNameStr)) + { return "Error: write failed"; + } } catch (Standard_Failure const& anException) { diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx index 785a609a95..faaa1abff7 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx @@ -129,7 +129,9 @@ public: Frame& aFrame = myFrames.ChangeLast(); const int anElem = aFrame.Advance(); if (aFrame.IsEmpty()) + { myFrames.EraseLast(); + } return anElem; } @@ -445,11 +447,15 @@ void BRepMesh_Delaun::RemoveAuxElements() // Destruction of triangles containing a top of the super triangle BRepMesh_SelectorOfDataStructureOfDelaun aSelector(myMeshData); for (int aSupVertId = 0; aSupVertId < mySupVert.Length(); ++aSupVertId) + { aSelector.NeighboursOfNode(mySupVert[aSupVertId]); + } IMeshData::IteratorOfMapOfInteger aFreeTriangles(aSelector.Elements()); for (; aFreeTriangles.More(); aFreeTriangles.Next()) + { deleteTriangle(aFreeTriangles.Key(), aLoopEdges); + } // All edges that remain free are removed from aLoopEdges; // only the boundary edges of the triangulation remain there @@ -457,12 +463,16 @@ void BRepMesh_Delaun::RemoveAuxElements() for (; aFreeEdges.More(); aFreeEdges.Next()) { if (myMeshData->ElementsConnectedTo(aFreeEdges.Key()).IsEmpty()) + { myMeshData->RemoveLink(aFreeEdges.Key()); + } } // The tops of the super triangle are destroyed for (int aSupVertId = 0; aSupVertId < mySupVert.Length(); ++aSupVertId) + { myMeshData->RemoveNode(mySupVert[aSupVertId]); + } } //======================================================================= @@ -502,7 +512,9 @@ void BRepMesh_Delaun::createTriangles(const int theVertexI gp_XY anEdgeDir(aLastVertex.Coord() - aFirstVertex.Coord()); double anEdgeLen = anEdgeDir.Modulus(); if (anEdgeLen < Precision) + { continue; + } anEdgeDir.SetCoord(anEdgeDir.X() / anEdgeLen, anEdgeDir.Y() / anEdgeLen); @@ -540,14 +552,22 @@ void BRepMesh_Delaun::createTriangles(const int theVertexI else { if (isPositive) + { aLoopEdges.Append(anEdges.Key()); + } else + { aLoopEdges.Append(-anEdges.Key()); + } if (aFirstLinkDir.SquareModulus() > aLastLinkDir.SquareModulus()) + { anExternalEdges.Append(std::abs(anEdgesInfo[0])); + } else + { anExternalEdges.Append(std::abs(anEdgesInfo[2])); + } } } @@ -558,7 +578,9 @@ void BRepMesh_Delaun::createTriangles(const int theVertexI myMeshData->ElementsConnectedTo(std::abs(anExternalEdges.First())); if (!aPair.IsEmpty()) + { deleteTriangle(aPair.FirstIndex(), thePoly); + } anExternalEdges.RemoveFirst(); } @@ -566,7 +588,9 @@ void BRepMesh_Delaun::createTriangles(const int theVertexI for (anEdges.Initialize(thePoly); anEdges.More(); anEdges.Next()) { if (myMeshData->ElementsConnectedTo(anEdges.Key()).IsEmpty()) + { myMeshData->RemoveLink(anEdges.Key()); + } } while (!aLoopEdges.IsEmpty()) @@ -630,7 +654,9 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(IMeshData::VectorOfInteger& { // We can skip free vertex too close to the frontier edge. if (aVertex.Movability() == BRepMesh_Free) + { continue; + } // However, we should add vertex that have neighboring frontier edges. } @@ -736,14 +762,18 @@ bool BRepMesh_Delaun::isBoundToFrontier(const int theRefNodeId, const int theRef const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo(aCurrentLinkId); if (aPair.IsEmpty()) + { return false; + } const int aNbElements = aPair.Extent(); for (int anElemIt = 1; anElemIt <= aNbElements; ++anElemIt) { const int aTriId = aPair.Index(anElemIt); if (aTriId < 0) + { continue; + } const BRepMesh_Triangle& aElement = GetTriangle(aTriId); const int (&anEdges)[3] = aElement.myEdges; @@ -752,7 +782,9 @@ bool BRepMesh_Delaun::isBoundToFrontier(const int theRefNodeId, const int theRef { const int anEdgeId = anEdges[anEdgeIt]; if (anEdgeId == aCurrentLinkId) + { continue; + } const BRepMesh_Edge& anEdge = GetEdge(anEdgeId); if (anEdge.FirstNode() != theRefNodeId && anEdge.LastNode() != theRefNodeId) @@ -761,7 +793,9 @@ bool BRepMesh_Delaun::isBoundToFrontier(const int theRefNodeId, const int theRef } if (anEdge.Movability() != BRepMesh_Free) + { return true; + } if (aVisitedLinks.Add(anEdgeId)) { @@ -796,7 +830,9 @@ void BRepMesh_Delaun::cleanupMesh() const int& aFreeEdgeId = aFreeEdgesIt.Key(); const BRepMesh_Edge& anEdge = GetEdge(aFreeEdgeId); if (anEdge.Movability() == BRepMesh_Frontier) + { continue; + } const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo(aFreeEdgeId); if (aPair.IsEmpty()) @@ -815,7 +851,9 @@ void BRepMesh_Delaun::cleanupMesh() for (int aCurEdgeIdx = 0; aCurEdgeIdx < 3; ++aCurEdgeIdx) { if (anEdges[aCurEdgeIdx] != aFreeEdgeId) + { continue; + } for (int anOtherEdgeIt = 1; anOtherEdgeIt <= 2 && isCanNotBeRemoved; ++anOtherEdgeIt) { @@ -833,7 +871,9 @@ void BRepMesh_Delaun::cleanupMesh() ++aTriIdx) { if (anOtherEdgePair.Index(aTriIdx) == aTriId) + { continue; + } int v[3]; const BRepMesh_Triangle& aCurTriangle = GetTriangle(anOtherEdgePair.Index(aTriIdx)); @@ -853,7 +893,9 @@ void BRepMesh_Delaun::cleanupMesh() } if (isCanNotBeRemoved) + { continue; + } bool isConnected[2] = {false, false}; for (int aLinkNodeIt = 0; aLinkNodeIt < 2; ++aLinkNodeIt) @@ -864,7 +906,9 @@ void BRepMesh_Delaun::cleanupMesh() } if (!isConnected[0] || !isConnected[1]) + { aDelTriangles.Add(aTriId); + } } // Destruction of triangles : @@ -881,11 +925,15 @@ void BRepMesh_Delaun::cleanupMesh() for (; aLoopEdgesIt.More(); aLoopEdgesIt.Next()) { if (myMeshData->ElementsConnectedTo(aLoopEdgesIt.Key()).IsEmpty()) + { myMeshData->RemoveLink(aLoopEdgesIt.Key()); + } } if (aDeletedTrianglesNb == 0) + { break; + } } } @@ -920,7 +968,9 @@ void BRepMesh_Delaun::frontierAdjust() { const int aPriorElemId = aPair.Index(aElemIt); if (aPriorElemId < 0) + { continue; + } const BRepMesh_Triangle& aElement = GetTriangle(aPriorElemId); const int (&e)[3] = aElement.myEdges; @@ -939,7 +989,9 @@ void BRepMesh_Delaun::frontierAdjust() } if (isTriangleFound) + { break; + } } } @@ -949,7 +1001,9 @@ void BRepMesh_Delaun::frontierAdjust() { int aLoopEdgeId = aLoopEdgesIt.Key(); if (myMeshData->ElementsConnectedTo(aLoopEdgeId).IsEmpty()) + { myMeshData->RemoveLink(aLoopEdgeId); + } } // destruction of triangles crossing the boundary edges and @@ -958,12 +1012,16 @@ void BRepMesh_Delaun::frontierAdjust() { int aFrontierId = aFrontierIt.Key(); if (!myMeshData->ElementsConnectedTo(aFrontierId).IsEmpty()) + { continue; + } bool isSuccess = meshLeftPolygonOf(aFrontierId, true, aIntFrontierEdges); if (aPass == 2 && !isSuccess) + { aFailedFrontiers.Append(aFrontierId); + } } } @@ -979,7 +1037,9 @@ void BRepMesh_Delaun::frontierAdjust() { int aFrontierId = aFailedFrontiersIt.Value(); if (!myMeshData->ElementsConnectedTo(aFrontierId).IsEmpty()) + { continue; + } meshLeftPolygonOf(aFrontierId, true, aIntFrontierEdges); } @@ -1008,7 +1068,9 @@ bool BRepMesh_Delaun::meshLeftPolygonOf(const int theStart Handle(IMeshData::MapOfInteger) theSkipped) { if (!theSkipped.IsNull() && theSkipped->Contains(theStartEdgeId)) + { return true; + } const BRepMesh_Edge& aRefEdge = GetEdge(theStartEdgeId); @@ -1033,7 +1095,9 @@ bool BRepMesh_Delaun::meshLeftPolygonOf(const int theStart gp_Vec2d aRefLinkDir(aPivotVertex.Coord() - aStartEdgeVertexS.Coord()); if (aRefLinkDir.SquareMagnitude() < Precision2) + { return true; + } // Auxiliary structures. // Bounding boxes of polygon links to be used for preliminary @@ -1087,7 +1151,9 @@ bool BRepMesh_Delaun::meshLeftPolygonOf(const int theStart { // Nothing to do if (aPolygon.Length() == 1) + { return false; + } // Return to the previous point int aDeadLinkId = std::abs(aPolygon.Last()); @@ -1119,7 +1185,9 @@ bool BRepMesh_Delaun::meshLeftPolygonOf(const int theStart } if (aPolygon.Length() < 3) + { return false; + } cleanupPolygon(aPolygon, aBoxes); meshPolygon(aPolygon, aBoxes, theSkipped); @@ -1168,7 +1236,9 @@ int BRepMesh_Delaun::findNextPolygonLink(const int& bool isLeprous = theLeprousLinks.Contains(aNeighbourLinkId); if (isSkipLeprous && isLeprous) + { continue; + } const BRepMesh_Edge& aNeighbourLink = GetEdge(aNeighbourLinkId); @@ -1182,7 +1252,9 @@ int BRepMesh_Delaun::findNextPolygonLink(const int& int anOtherNode = aNeighbourLink.FirstNode(); if (anOtherNode == thePivotNode) + { anOtherNode = aNeighbourLink.LastNode(); + } gp_Vec2d aCurLinkDir(GetVertex(anOtherNode).Coord() - thePivotVertex.Coord()); @@ -1193,7 +1265,9 @@ int BRepMesh_Delaun::findNextPolygonLink(const int& } if (!isLeprous) + { theLeprousLinks.Add(aNeighbourLinkId); + } double anAngle = theRefLinkDir.Angle(aCurLinkDir); bool isFrontier = (aNeighbourLink.Movability() == BRepMesh_Frontier); @@ -1210,7 +1284,9 @@ int BRepMesh_Delaun::findNextPolygonLink(const int& } if (anAngle <= aMaxAngle) + { continue; + } bool isCheckEndPoints = (anOtherNode != theFirstNode); @@ -1260,7 +1336,9 @@ bool BRepMesh_Delaun::checkIntersection(const BRepMesh_Edge& theL int aPolyLen = thePolygon.Length(); // Don't check intersection with the last link if (isSkipLastEdge) + { --aPolyLen; + } bool isFrontier = (theLink.Movability() == BRepMesh_Frontier); @@ -1274,14 +1352,18 @@ bool BRepMesh_Delaun::checkIntersection(const BRepMesh_Edge& theL // skip intersections between frontier edges if (aPolyLink.Movability() == BRepMesh_Frontier && isFrontier) + { continue; + } gp_Pnt2d anIntPnt; BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg(theLink, aPolyLink, isConsiderEndPointTouch, isConsiderPointOnEdge, anIntPnt); if (aIntFlag != BRepMesh_GeomTool::NoIntersection) + { return false; + } } } @@ -1310,7 +1392,9 @@ void BRepMesh_Delaun::addTriangle(const int (&theEdgesId)[3], } if (!isAdded) + { myMeshData->RemoveElement(aNewTriangleId); + } } //======================================================================= @@ -1322,7 +1406,9 @@ void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePoly { int aPolyLen = thePolygon.Length(); if (aPolyLen < 3) + { return; + } occ::handle aAllocator = new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); @@ -1346,7 +1432,9 @@ void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePoly { int anElemId = aPair.Index(anElemIt); if (anElemId < 0) + { continue; + } const BRepMesh_Triangle& aElement = GetTriangle(anElemId); const int (&anEdges)[3] = aElement.myEdges; @@ -1364,7 +1452,9 @@ void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePoly } if (isTriangleFound) + { break; + } } // Skip a neighbor link to extract unique vertices each time @@ -1392,7 +1482,9 @@ void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePoly // Make closed sequence if (aPolyVertices.First() != aPolyVertices.Last()) + { aPolyVertices.Append(aPolyVertices.First()); + } IMeshData::MapOfInteger aSurvivedLinks(anIgnoredEdges); @@ -1425,10 +1517,14 @@ void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePoly { const int& aLoopEdgeId = aLoopEdgesIt.Key(); if (anIgnoredEdges.Contains(aLoopEdgeId)) + { continue; + } if (myMeshData->ElementsConnectedTo(aLoopEdgeId).IsEmpty()) + { myMeshData->RemoveLink(aLoopEdgesIt.Key()); + } } } @@ -1454,7 +1550,9 @@ void BRepMesh_Delaun::killTrianglesAroundVertex( { const int& aNeighborLinkId = aNeighborsIt.Value(); if (theSurvivedLinks.Contains(aNeighborLinkId)) + { continue; + } const BRepMesh_Edge& aNeighborLink = GetEdge(aNeighborLinkId); if (aNeighborLink.Movability() == BRepMesh_Frontier) @@ -1476,7 +1574,9 @@ void BRepMesh_Delaun::killTrianglesAroundVertex( { int anOtherNode = aNeighborLink.FirstNode(); if (anOtherNode == theZombieNodeId) + { anOtherNode = aNeighborLink.LastNode(); + } // Possible sacrifice if (!thePolyVerticesFindMap.Contains(anOtherNode)) @@ -1519,14 +1619,18 @@ bool BRepMesh_Delaun::isVertexInsidePolygon( { int aPolyLen = thePolygonVertices.Length(); if (aPolyLen < 3) + { return false; + } const gp_XY aCenterPointXY = GetVertex(theVertexId).Coord(); const BRepMesh_Vertex& aFirstVertex = GetVertex(thePolygonVertices(0)); gp_Vec2d aPrevVertexDir(aFirstVertex.Coord() - aCenterPointXY); if (aPrevVertexDir.SquareMagnitude() < Precision2) + { return true; + } double aTotalAng = 0.0; for (int aPolyIt = 1; aPolyIt < aPolyLen; ++aPolyIt) @@ -1535,7 +1639,9 @@ bool BRepMesh_Delaun::isVertexInsidePolygon( gp_Vec2d aCurVertexDir(aPolyVertex.Coord() - aCenterPointXY); if (aCurVertexDir.SquareMagnitude() < Precision2) + { return true; + } aTotalAng += aCurVertexDir.Angle(aPrevVertexDir); aPrevVertexDir = aCurVertexDir; @@ -1560,7 +1666,9 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( IMeshData::MapOfIntegerInteger& theLoopEdges) { if (theSurvivedLinks.Contains(theLinkToCheckId)) + { return; + } Bnd_B2d aBox; bool isNotIntersect = @@ -1569,7 +1677,9 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( theSurvivedLinks.Add(theLinkToCheckId); if (isNotIntersect) + { return; + } killLinkTriangles(theLinkToCheckId, theLoopEdges); @@ -1581,7 +1691,9 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( const BRepMesh_Edge& aNeighborLink = GetEdge(aNeighborLinkId); int anOtherNode = aNeighborLink.FirstNode(); if (anOtherNode == theEndPoint) + { anOtherNode = aNeighborLink.LastNode(); + } killTrianglesOnIntersectingLinks(aNeighborLinkId, aNeighborLink, @@ -1607,7 +1719,9 @@ void BRepMesh_Delaun::killLinkTriangles(const int& theLinkI { int anElemId = aPair.FirstIndex(); if (anElemId < 0) + { continue; + } deleteTriangle(anElemId, theLoopEdges); } @@ -1646,7 +1760,9 @@ void BRepMesh_Delaun::processLoop(const int theLinkFro { int aNbOfLinksInLoop = theLinkTo - theLinkFrom - 1; if (aNbOfLinksInLoop < 3) + { return; + } IMeshData::SequenceOfInteger aPolygon; IMeshData::SequenceOfBndB2d aPolyBoxes; @@ -1705,7 +1821,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, { // Check is the source polygon elementary if (meshElementaryPolygon(thePolygon)) + { return; + } // Check and correct boundary edges int aPolyLen = thePolygon.Length(); @@ -1717,7 +1835,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, int aCurEdgeId = std::abs(aCurEdgeInfo); const BRepMesh_Edge* aCurEdge = &GetEdge(aCurEdgeId); if (aCurEdge->Movability() != BRepMesh_Frontier) + { continue; + } int aCurNodes[2]; getOrientedNodes(*aCurEdge, aCurEdgeInfo > 0, aCurNodes); @@ -1734,7 +1854,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, int aNextEdgeId = std::abs(aNextEdgeInfo); const BRepMesh_Edge* aNextEdge = &GetEdge(aNextEdgeId); if (aNextEdge->Movability() != BRepMesh_Frontier) + { continue; + } int aNextNodes[2]; getOrientedNodes(*aNextEdge, aNextEdgeInfo > 0, aNextNodes); @@ -1745,7 +1867,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg(*aCurEdge, *aNextEdge, false, true, anIntPnt); if (aIntFlag == BRepMesh_GeomTool::NoIntersection) + { continue; + } bool isRemoveFromFirst = false; bool isAddReplacingEdge = true; @@ -1783,7 +1907,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, aCurPnts[1] = aNextPnts[aEndPointIndex]; if (isCloseToStart) + { --aIndexToRemoveTo; + } // In this context only intersections between frontier edges // are possible. If intersection between edges of different @@ -1793,7 +1919,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, { int aSkippedLinkIt = aPolyIt; for (; aSkippedLinkIt <= aIndexToRemoveTo; ++aSkippedLinkIt) + { theSkipped->Add(std::abs(thePolygon(aSkippedLinkIt))); + } } } else if (aIntFlag == BRepMesh_GeomTool::PointOnSegment) @@ -1875,7 +2003,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, isAddReplacingEdge = false; } else + { continue; // Not supported type + } if (isAddReplacingEdge) { @@ -1935,7 +2065,9 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, } if (aPolyStack.IsEmpty()) + { break; + } aPolygon1 = &(*aPolyStack.ChangeFirst()); aPolyBoxes1 = &(*aPolyBoxStack.ChangeFirst()); @@ -1951,9 +2083,13 @@ bool BRepMesh_Delaun::meshElementaryPolygon(const IMeshData::SequenceOfInteger& { int aPolyLen = thePolygon.Length(); if (aPolyLen < 3) + { return true; + } else if (aPolyLen > 3) + { return false; + } // Just create a triangle int anEdges[3]; @@ -2033,7 +2169,9 @@ void BRepMesh_Delaun::decomposeSimplePolygon(IMeshData::SequenceOfInteger& thePo // We have end points touch case in the polygon - ignore it if (aPivotNode == aNodes[1]) + { continue; + } gp_Pnt2d aPivotVertex = GetVertex(aPivotNode).Coord(); gp_Vec2d aDistanceDir(aRefVertices[1], aPivotVertex); @@ -2042,7 +2180,9 @@ void BRepMesh_Delaun::decomposeSimplePolygon(IMeshData::SequenceOfInteger& thePo double aAngle = std::abs(aRefEdgeDir.Angle(aDistanceDir)); double anAbsDist = std::abs(aDist); if (anAbsDist < Precision || aDist < 0.) + { continue; + } if ((anAbsDist >= aMinDist) && (aAngle <= aOptAngle || aAngle > AngDeviation90Deg)) { @@ -2065,14 +2205,18 @@ void BRepMesh_Delaun::decomposeSimplePolygon(IMeshData::SequenceOfInteger& thePo for (; aCheckLinkIt <= aPolyLen; ++aCheckLinkIt) { if (aCheckLinkIt == aLinkIt) + { continue; + } if (!aBox.IsOut(thePolyBoxes.Value(aCheckLinkIt))) { const BRepMesh_Edge& aPolyLink = GetEdge(std::abs(thePolygon(aCheckLinkIt))); if (aCheckLink.IsEqual(aPolyLink)) + { continue; + } // intersection is possible... gp_Pnt2d anIntPnt; @@ -2088,11 +2232,15 @@ void BRepMesh_Delaun::decomposeSimplePolygon(IMeshData::SequenceOfInteger& thePo } if (isIntersect) + { break; + } } if (isIntersect) + { continue; + } aOptAngle = aAngle; aMinDist = anAbsDist; @@ -2179,7 +2327,9 @@ void BRepMesh_Delaun::RemoveVertex(const BRepMesh_Vertex& theVertex) // Loop on triangles to be destroyed : IMeshData::IteratorOfMapOfInteger aTriangleIt(aSelector.Elements()); for (; aTriangleIt.More(); aTriangleIt.Next()) + { deleteTriangle(aTriangleIt.Key(), aLoopEdges); + } IMeshData::SequenceOfBndB2d aBoxes; IMeshData::SequenceOfInteger aPolygon; @@ -2205,7 +2355,9 @@ void BRepMesh_Delaun::RemoveVertex(const BRepMesh_Vertex& theVertex) aPolygon.Append(-anEdgeId); } else + { aPolygon.Append(anEdgeId); + } fillBndBox(aBoxes, GetVertex(aFirstNode), GetVertex(aPivotNode)); @@ -2230,7 +2382,9 @@ void BRepMesh_Delaun::RemoveVertex(const BRepMesh_Vertex& theVertex) aPolygon.Append(-anEdgeId); } else + { aPolygon.Append(anEdgeId); + } fillBndBox(aBoxes, GetVertex(aCurrentNode), GetVertex(aPivotNode)); @@ -2241,7 +2395,9 @@ void BRepMesh_Delaun::RemoveVertex(const BRepMesh_Vertex& theVertex) } if (aLoopEdgesCount <= 0) + { break; + } --aLoopEdgesCount; } @@ -2369,7 +2525,9 @@ Handle(IMeshData::MapOfInteger) BRepMesh_Delaun::getEdgesByType( : (GetEdge(anEdge).Movability() == theEdgeType); if (isToAdd) + { aResult->Add(anEdge); + } } return aResult; @@ -2392,7 +2550,9 @@ double BRepMesh_Delaun::calculateDist(const gp_XY theVEdges[3], { theSqModulus[i] = theVEdges[i].SquareModulus(); if (theSqModulus[i] <= Precision2) + { return -1; + } theDistance[i] = theVEdges[i] ^ (theVertex.Coord() - thePoints[i]); @@ -2453,18 +2613,26 @@ bool BRepMesh_Delaun::Contains(const int theTriangleId, int aEdgeOnId; aSqMinDist = calculateDist(aVEdges, aPoints, theVertex, aDistance, aSqModulus, aEdgeOnId); if (aSqMinDist < 0) + { return false; + } const bool isNotFree = (anEdges[aEdgeOnId]->Movability() != BRepMesh_Free); if (aSqMinDist > theSqTolerance) { if (isNotFree && aDistance[aEdgeOnId] < (aSqModulus[aEdgeOnId] / 5.)) + { theEdgeOn = e[aEdgeOnId]; + } } else if (isNotFree) + { return false; + } else + { theEdgeOn = e[aEdgeOnId]; + } return (aDistance[0] >= 0. && aDistance[1] >= 0. && aDistance[2] >= 0.); } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeDiscret.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeDiscret.cxx index 68aaf0d380..74651a4094 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeDiscret.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeDiscret.cxx @@ -235,7 +235,9 @@ void BRepMesh_EdgeDiscret::Tessellate3d( TopExp::Vertices(aEdge, aFirstVertex, aLastVertex); if (aFirstVertex.IsNull() || aLastVertex.IsNull()) + { return; + } if (theUpdateEnds) { @@ -252,7 +254,9 @@ void BRepMesh_EdgeDiscret::Tessellate3d( gp_Pnt aPoint; double aParam; if (!theTessellator->Value(i, aPoint, aParam)) + { continue; + } if (theUpdateEnds) { diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_FaceChecker.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_FaceChecker.cxx index da17a46f66..26b05c2799 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_FaceChecker.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_FaceChecker.cxx @@ -168,10 +168,14 @@ public: gp_XY aCurVec = aCurrSegment.Point2->XY() - aRefPnt; if (aCurVec.SquareModulus() < gp::Resolution()) + { continue; + } if (aPrevVec.SquareModulus() > gp::Resolution()) + { aSumS += aPrevVec ^ aCurVec; + } aPrevVec = aCurVec; } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_GeomTool.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_GeomTool.cxx index 003923f366..127233ac8a 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_GeomTool.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_GeomTool.cxx @@ -113,9 +113,13 @@ void AdjustCellsCounts(const occ::handle& theFace, { // planar, cylindrical, conical cases if (aType == GeomAbs_SurfaceOfExtrusion) + { theCellsCountU = (int)std::ceil(std::pow(2, std::log10(aSqNbVert))); + } else + { theCellsCountV = (int)std::ceil(std::pow(2, std::log10(aSqNbVert))); + } } if (aType == GeomAbs_SurfaceOfExtrusion) { @@ -197,10 +201,14 @@ bool BRepMesh_GeomTool::Value(const int theIndex, gp_Pnt2d& theUV) const { if (theIndex < 1 || theIndex > NbPoints()) + { return false; + } if (myEdge == nullptr) + { return false; + } thePoint = myDiscretTool.Value(theIndex); theParam = myDiscretTool.Parameter(theIndex); @@ -224,15 +232,21 @@ bool BRepMesh_GeomTool::Value(const int theIndex, gp_Pnt2d& theUV) const { if (theIndex < 1 || theIndex > NbPoints()) + { return false; + } thePoint = myDiscretTool.Value(theIndex); theParam = myDiscretTool.Parameter(theIndex); if (myIsoType == GeomAbs_IsoU) + { theUV.SetCoord(theIsoParam, theParam); + } else + { theUV.SetCoord(theParam, theIsoParam); + } return true; } @@ -269,12 +283,16 @@ bool BRepMesh_GeomTool::Normal(const occ::handle& theSurfac } if (!isOK) + { return false; + } const TopoDS_Face& aFace = theSurface->Face(); TopAbs_Orientation aOri = aFace.Orientation(); if (aOri == TopAbs_REVERSED) + { theNormal.Reverse(); + } return true; } @@ -301,9 +319,13 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntLinLin(const gp_XY& theStartPnt { // Just a parallel case? if (std::abs(aCrossD1D3) < aPrec) + { return BRepMesh_GeomTool::Same; + } else + { return BRepMesh_GeomTool::NoIntersection; + } } theParamOnSegment[0] = aCrossD1D3 / aCrossD1D2; @@ -343,7 +365,9 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(const gp_XY& theStartPnt else { if (isConsiderEndPointTouch) + { return BRepMesh_GeomTool::EndPointTouch; + } return BRepMesh_GeomTool::NoIntersection; } @@ -372,13 +396,21 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(const gp_XY& theStartPnt if (isConsiderPointOnSegment) { if (aPointHash[0] == 1) + { theIntPnt = theStartPnt1; + } else if (aPointHash[1] == 1) + { theIntPnt = theEndPnt1; + } else if (aPointHash[2] == 1) + { theIntPnt = theStartPnt2; + } else + { theIntPnt = theEndPnt2; + } return BRepMesh_GeomTool::PointOnSegment; } @@ -386,21 +418,29 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(const gp_XY& theStartPnt return BRepMesh_GeomTool::NoIntersection; } else if (aPosHash == 2) + { return BRepMesh_GeomTool::Glued; + } double aParam[2]; IntFlag aIntFlag = IntLinLin(theStartPnt1, theEndPnt1, theStartPnt2, theEndPnt2, theIntPnt.ChangeCoord(), aParam); if (aIntFlag == BRepMesh_GeomTool::NoIntersection) + { return BRepMesh_GeomTool::NoIntersection; + } if (aIntFlag == BRepMesh_GeomTool::Same) { if (aPosHash < -2) + { return BRepMesh_GeomTool::Same; + } else if (aPosHash == -1) + { return BRepMesh_GeomTool::Glued; + } return BRepMesh_GeomTool::NoIntersection; } @@ -412,7 +452,9 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(const gp_XY& theStartPnt for (int i = 0; i < 2; ++i) { if (aParam[i] < aPrec || aParam[i] > aEndPrec) + { return BRepMesh_GeomTool::NoIntersection; + } } return BRepMesh_GeomTool::Cross; @@ -427,7 +469,9 @@ std::pair BRepMesh_GeomTool::CellsCount( const BRepMesh_DefaultRangeSplitter* theRangeSplitter) { if (theRangeSplitter == nullptr) + { return std::pair(-1, -1); + } const GeomAbs_SurfaceType aType = theSurface->GetType(); @@ -483,15 +527,21 @@ int BRepMesh_GeomTool::classifyPoint(const gp_XY& thePoint1, { aDist = (aDist * aDist) / aP1.SquareModulus(); if (aDist > aSqPrec) + { return 0; // out + } } gp_XY aMult = aP1.Multiplied(aP2); if (aMult.X() < 0.0 || aMult.Y() < 0.0) + { return 0; // out + } if (aP1.SquareModulus() < aP2.SquareModulus()) + { return 0; // out + } if (thePointToCheck.IsEqual(thePoint1, aPrec) || thePointToCheck.IsEqual(thePoint2, aPrec)) { diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_MeshTool.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_MeshTool.cxx index 6833baed06..39c0243013 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_MeshTool.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_MeshTool.cxx @@ -312,7 +312,9 @@ void BRepMesh_MeshTool::DumpTriangles(const char* const theFileName, for (IMeshData::IteratorOfMapOfInteger aIt(aTriangles); aIt.More(); aIt.Next()) { if (theTriangles != nullptr && !theTriangles->Contains(aIt.Key())) + { continue; + } int aNodes[3]; const BRepMesh_Triangle& aTri = myStructure->GetElement(aIt.Key()); diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelHealer.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelHealer.cxx index 11eed205da..1cf0e9ee7a 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelHealer.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelHealer.cxx @@ -387,7 +387,9 @@ TopoDS_Vertex BRepMesh_ModelHealer::getCommonVertex(const IMeshData::IEdgeHandle // This shape is invalid and can lead to exception in this code. if (aVertex1_1.IsNull() || aVertex1_2.IsNull()) + { return TopoDS_Vertex(); + } if (theEdge1->GetEdge().IsSame(theEdge2->GetEdge())) { @@ -398,7 +400,9 @@ TopoDS_Vertex BRepMesh_ModelHealer::getCommonVertex(const IMeshData::IEdgeHandle TopExp::Vertices(theEdge2->GetEdge(), aVertex2_1, aVertex2_2); if (aVertex2_1.IsNull() || aVertex2_2.IsNull()) + { return TopoDS_Vertex(); + } if (isSameWithSomeOf(aVertex1_1, aVertex2_1, aVertex2_2)) { diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPostProcessor.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPostProcessor.cxx index bb4b28d14e..4eb26b6fe0 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPostProcessor.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ModelPostProcessor.cxx @@ -43,7 +43,9 @@ public: { const IMeshData::IEdgeHandle& aDEdge = myModel->GetEdge(theEdgeIndex); if (aDEdge->GetCurve()->ParametersNb() == 0) + { return; + } if (aDEdge->IsFree()) { diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx index 3a58d7f20e..f74057fbd9 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx @@ -266,7 +266,9 @@ bool toSplitIntervals(const occ::handle& theSurf, { const double aParamU = theIntervals[0].Value(aIntervalU); if (Precision::IsInfinite(aParamU)) + { continue; + } int aIntervalV = theIntervals[1].Lower(); for (; aIntervalV <= theIntervals[1].Upper(); ++aIntervalV) @@ -274,7 +276,9 @@ bool toSplitIntervals(const occ::handle& theSurf, gp_Dir aNorm; const double aParamV = theIntervals[1].Value(aIntervalV); if (Precision::IsInfinite(aParamV)) + { continue; + } if (GeomLib::NormEstim(theSurf, gp_Pnt2d(aParamU, aParamV), Precision::Confusion(), aNorm) != 0) @@ -581,7 +585,9 @@ Handle(IMeshData::SequenceOfReal) BRepMesh_NURBSRangeSplitter::filterParameters( NCollection_Array1 aParamArray(1, anInitLen); int j; for (j = 1; j <= anInitLen; j++) + { aParamArray(j) = theParams(j); + } std::sort(aParamArray.begin(), aParamArray.end()); @@ -592,7 +598,9 @@ Handle(IMeshData::SequenceOfReal) BRepMesh_NURBSRangeSplitter::filterParameters( if ((aParamArray(j) - aParamArray(aParamLength)) > theMinDist) { if (++aParamLength < j) + { aParamArray(aParamLength) = aParamArray(j); + } } } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx index 2581e25234..5c9e690f24 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx @@ -58,7 +58,9 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const int theNod IMeshData::ListOfInteger::Iterator aLinkIt(myMesh->LinksConnectedTo(theNodeIndex)); for (; aLinkIt.More(); aLinkIt.Next()) + { elementsOfLink(aLinkIt.Value()); + } } //================================================================================================= @@ -84,7 +86,9 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Trian myMesh->ElementNodes(theElement, v); for (int i = 0; i < 3; ++i) + { NeighboursOfNode(v[i]); + } } //================================================================================================= @@ -101,7 +105,9 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf( { const int (&e)[3] = theElement.myEdges; for (int i = 0; i < 3; ++i) + { elementsOfLink(e[i]); + } } //================================================================================================= @@ -110,5 +116,7 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::elementsOfLink(const int theIndex { const BRepMesh_PairOfIndex& aPair = myMesh->ElementsConnectedTo(theIndex); for (int j = 1, jn = aPair.Extent(); j <= jn; ++j) + { myElements.Add(aPair.Index(j)); + } } diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ShapeTool.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ShapeTool.cxx index 57c9106c5e..e39cdc50e6 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ShapeTool.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_ShapeTool.cxx @@ -57,7 +57,9 @@ double MaxTolerance(const TopoDS_Face& theFace) { double aTolerance = ToleranceExtractor::Get(aExplorer.Current()); if (aTolerance > aMaxTolerance) + { aMaxTolerance = aTolerance; + } } return aMaxTolerance; @@ -81,7 +83,9 @@ double BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace) void BRepMesh_ShapeTool::BoxMaxDimension(const Bnd_Box& theBox, double& theMaxDimension) { if (theBox.IsVoid()) + { return; + } double aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ; theBox.Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ); diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/delabella.cpp b/src/ModelingAlgorithms/TKMesh/BRepMesh/delabella.cpp index 654cbf57d1..8e4adba57c 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/delabella.cpp +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/delabella.cpp @@ -123,21 +123,37 @@ struct CDelaBella : IDelaBella Vert* va = (Vert*)a; Vert* vb = (Vert*)b; if (va->z < vb->z) + { return -1; + } if (va->z > vb->z) + { return 1; + } if (va->y < vb->y) + { return -1; + } if (va->y > vb->y) + { return 1; + } if (va->x < vb->x) + { return -1; + } if (va->x > vb->x) + { return 1; + } if (va->i < vb->i) + { return -1; + } if (va->i > vb->i) + { return 1; + } return 0; } }; @@ -165,11 +181,17 @@ struct CDelaBella : IDelaBella // return next face in same direction as face vertices are (cw/ccw) if (v[0] == p) + { return (Face*)f[1]; + } if (v[1] == p) + { return (Face*)f[2]; + } if (v[2] == p) + { return (Face*)f[0]; + } return nullptr; } @@ -224,17 +246,23 @@ struct CDelaBella : IDelaBella // skip dups while (r < points && Vert::overlap(vert_alloc + r, vert_alloc + r - 1)) + { r++; + } // copy next no-dups block while (r < points && !Vert::overlap(vert_alloc + r, vert_alloc + r - 1)) + { vert_alloc[w++] = vert_alloc[r++]; + } } if (points - w) { if (errlog_proc) + { errlog_proc(errlog_file, "[WRN] detected %d dups in xy array!\n", points - w); + } points = w; } } @@ -244,8 +272,10 @@ struct CDelaBella : IDelaBella if (points == 2) { if (errlog_proc) + { errlog_proc(errlog_file, "[WRN] all input points are colinear, returning single segment!\n"); + } first_hull_vert = vert_alloc + 0; vert_alloc[0].next = (DelaBella_Vertex*)(vert_alloc + 1); vert_alloc[1].next = nullptr; @@ -253,8 +283,10 @@ struct CDelaBella : IDelaBella else { if (errlog_proc) + { errlog_proc(errlog_file, "[WRN] all input points are identical, returning single point!\n"); + } first_hull_vert = vert_alloc + 0; vert_alloc[0].next = nullptr; } @@ -267,21 +299,29 @@ struct CDelaBella : IDelaBella if (max_faces < hull_faces) { if (max_faces) + { free(face_alloc); + } max_faces = 0; face_alloc = (Face*)malloc(sizeof(Face) * hull_faces); if (face_alloc) + { max_faces = hull_faces; + } else { if (errlog_proc) + { errlog_proc(errlog_file, "[ERR] Not enough memory, shop for some more RAM. See you!\n"); + } return 0; } } for (int i = 1; i < hull_faces; i++) + { face_alloc[i - 1].next = face_alloc + i; + } face_alloc[hull_faces - 1].next = nullptr; Face* cache = face_alloc; @@ -373,8 +413,10 @@ struct CDelaBella : IDelaBella if (colinear) { if (errlog_proc) + { errlog_proc(errlog_file, "[WRN] all input points are colinear, returning segment list!\n"); + } first_hull_vert = head; last->next = nullptr; // break contour, make it a list return -points; @@ -384,12 +426,16 @@ struct CDelaBella : IDelaBella if (points > 3) { if (errlog_proc) + { errlog_proc(errlog_file, "[NFO] all input points are cocircular.\n"); + } } else { if (errlog_proc) + { errlog_proc(errlog_file, "[NFO] trivial case of 3 points, thank you.\n"); + } first_dela_face = Face::Alloc(&cache); first_dela_face->next = nullptr; @@ -489,9 +535,13 @@ struct CDelaBella : IDelaBella base->f[0] = prev_base; if (prev_base) + { prev_base->f[1] = base; + } else + { first_base = base; + } prev_base = base; prev_side = side; @@ -561,9 +611,13 @@ struct CDelaBella : IDelaBella base->f[1] = prev_base; if (prev_base) + { prev_base->f[0] = base; + } else + { first_base = base; + } prev_base = base; prev_side = side; @@ -635,7 +689,9 @@ struct CDelaBella : IDelaBella _f = stack; stack = (Face*)_f->next; if (stack == _f) + { stack = nullptr; + } _f->next = nullptr; // copy parts of old face that we still need after removal @@ -672,13 +728,21 @@ struct CDelaBella : IDelaBella // change neighbour's adjacency from old visible face to cone side if (n->f[0] == _f) + { n->f[0] = s; + } else if (n->f[1] == _f) + { n->f[1] = s; + } else if (n->f[2] == _f) + { n->f[2] = s; + } else + { assert(0); + } // build silhouette needed for sewing sides in the second pass a->sew = s; @@ -690,13 +754,21 @@ struct CDelaBella : IDelaBella // so they won't be processed more than once if (n->f[0] == _f) + { n->f[0] = nullptr; + } else if (n->f[1] == _f) + { n->f[1] = nullptr; + } else if (n->f[2] == _f) + { n->f[2] = nullptr; + } else + { assert(0); + } // push neighbor face, it's visible and requires processing n->next = stack ? stack : n; @@ -800,11 +872,15 @@ struct CDelaBella : IDelaBella vert_alloc = (Vert*)malloc(sizeof(Vert) * points); if (vert_alloc) + { max_verts = points; + } else { if (errlog_proc) + { errlog_proc(errlog_file, "[ERR] Not enough memory, shop for some more RAM. See you!\n"); + } return false; } } @@ -818,16 +894,24 @@ struct CDelaBella : IDelaBella int advance_bytes = 0) override { if (!x) + { return 0; + } if (!y) + { y = x + 1; + } if (advance_bytes < static_cast(sizeof(float) * 2)) + { advance_bytes = static_cast(sizeof(float) * 2); + } if (!ReallocVerts(points)) + { return 0; + } for (int i = 0; i < points; i++) { @@ -845,16 +929,24 @@ struct CDelaBella : IDelaBella int Triangulate(int points, const double* x, const double* y, int advance_bytes) override { if (!x) + { return 0; + } if (!y) + { y = x + 1; + } if (advance_bytes < static_cast(sizeof(double) * 2)) + { advance_bytes = static_cast(sizeof(double) * 2); + } if (!ReallocVerts(points)) + { return 0; + } for (int i = 0; i < points; i++) { @@ -872,9 +964,13 @@ struct CDelaBella : IDelaBella void Destroy() override { if (face_alloc) + { free(face_alloc); + } if (vert_alloc) + { free(vert_alloc); + } delete this; } @@ -901,7 +997,9 @@ IDelaBella* IDelaBella::Create() { CDelaBella* db = new CDelaBella; if (!db) + { return nullptr; + } db->vert_alloc = nullptr; db->face_alloc = nullptr; @@ -975,16 +1073,22 @@ const DelaBella_Vertex* GetFirstHullVertex(void* db) int DelaBella(int points, const double* xy, int* abc, int (*errlog)(const char* fmt, ...)) { if (errlog) + { errlog("[WRN] Depreciated interface! errlog disabled.\n"); + } if (!xy || points <= 0) + { return 0; + } IDelaBella* db = IDelaBella::Create(); int verts = db->Triangulate(points, xy, nullptr, 0); if (!abc) + { return verts; + } if (verts > 0) { @@ -993,7 +1097,9 @@ int DelaBella(int points, const double* xy, int* abc, int (*errlog)(const char* for (int i = 0; i < tris; i++) { for (int j = 0; j < 3; j++) + { abc[3 * i + j] = dela->v[j]->i; + } dela = dela->next; } } diff --git a/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_CircleTool_Test.cxx b/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_CircleTool_Test.cxx index 1a1dc129d1..69978cdfc8 100644 --- a/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_CircleTool_Test.cxx +++ b/src/ModelingAlgorithms/TKMesh/GTests/BRepMesh_CircleTool_Test.cxx @@ -49,20 +49,26 @@ TEST(BRepMesh_CircleTool_Test, OCC24923_CircumCirclePassesThroughAllVertices) { gp_XY p[3]; for (int j = 0; j < 3; ++j) + { p[j].SetCoord(static_cast(rand()) / RAND_MAX, static_cast(rand()) / RAND_MAX); + } // Skip degenerate (nearly collinear) triangles - retry like the original. const gp_XY aV1 = p[1] - p[0]; const gp_XY aV2 = p[2] - p[0]; if (aV1.SquareModulus() <= aSqPrec || aV2.SquareModulus() <= aSqPrec || (aV1 ^ aV2) <= aMinArea) + { continue; + } ++i; gp_XY aCenter; double aRadius = 0.0; if (!BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius)) + { continue; + } if (!isOnCircle(p[0], aCenter, aRadius) || !isOnCircle(p[1], aCenter, aRadius) || !isOnCircle(p[2], aCenter, aRadius)) diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset.cxx index 102dbed309..d2dfbe24fd 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset.cxx @@ -66,9 +66,13 @@ occ::handle BRepOffset::Surface(const occ::handle& S double Radius = C->Radius(); gp_Ax3 Axis = C->Position(); if (Axis.Direct()) + { Radius += Offset; + } else + { Radius -= Offset; + } if (Radius >= Tol) { Result = new Geom_CylindricalSurface(Axis, Radius); @@ -113,9 +117,13 @@ occ::handle BRepOffset::Surface(const occ::handle& S double Radius = S->Radius(); gp_Ax3 Axis = S->Position(); if (Axis.Direct()) + { Radius += Offset; + } else + { Radius -= Offset; + } if (Radius >= Tol) { Result = new Geom_SphericalSurface(Axis, Radius); @@ -141,9 +149,13 @@ occ::handle BRepOffset::Surface(const occ::handle& S if (MinorRadius < MajorRadius) { // A FINIR if (Axis.Direct()) + { MinorRadius += Offset; + } else + { MinorRadius -= Offset; + } if (MinorRadius >= Tol) { Result = new Geom_ToroidalSurface(Axis, MajorRadius, MinorRadius); @@ -262,7 +274,9 @@ occ::handle BRepOffset::CollapseSingularities( NCollection_LocalArray isDegenerated (aDegenPnt.Extent()); // degenerated vertex // clang-format on for (size_t iDegen = 0; iDegen < isDegenerated.Size(); ++iDegen) + { isDegenerated[iDegen] = true; + } for (int iPole = 0; iPole < NbSteps[iSide]; iPole++) { const gp_Pnt& aPole = aPoles(RowStart[iSide] + iPole * RowStep[iSide], @@ -271,9 +285,13 @@ occ::handle BRepOffset::CollapseSingularities( // distance from CG double aDistCG = aCenter.Distance(aPole); if (aDistCG > gp::Resolution()) + { isCollapsed = false; + } if (aDistCG > thePrecision) + { isSingular = false; + } // distances from degenerated points NCollection_List::Iterator aDegPntIt(aDegenPnt); @@ -338,7 +356,9 @@ occ::handle BRepOffset::CollapseSingularities( } if (!aCopy.IsNull()) + { return aCopy; + } } return theSurface; diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Analyse.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Analyse.cxx index c64273a9d4..138326797f 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Analyse.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Analyse.cxx @@ -49,7 +49,9 @@ static void CorrectOrientationOfTangent(gp_Vec& TangVec, { TopoDS_Vertex Vlast = TopExp::LastVertex(anEdge); if (aVertex.IsSame(Vlast)) + { TangVec.Reverse(); + } } static bool CheckMixedContinuity(const TopoDS_Edge& theEdge, @@ -101,9 +103,13 @@ static void EdgeAnalyse(const TopoDS_Edge& E, if (isTwoPlanes) // then use only strong condition { if (BRep_Tool::Continuity(E, F1, F2) > GeomAbs_C0) + { ConnectType = ChFiDS_Tangential; + } else + { ConnectType = ChFi3d::DefineConnectType(E, F1, F2, SinTol, false); + } } else { @@ -313,7 +319,9 @@ void BRepOffset_Analyse::Perform(const TopoDS_Shape& S, const NCollection_List& L = Ancestors(E); if (L.IsEmpty()) + { continue; + } if (L.Extent() == 2) { @@ -324,7 +332,9 @@ void BRepOffset_Analyse::Perform(const TopoDS_Shape& S, // For tangent faces add artificial perpendicular face // to close the gap between them (if they have different offset values) if (myMapEdgeType(E).Last().Type() == ChFiDS_Tangential) + { aLETang.Append(E); + } } else if (L.Extent() == 1) { @@ -410,12 +420,16 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& { const TopoDS_Shape& aEMin = expE.Current(); if (aEMin.IsSame(aE)) + { continue; + } for (TopoDS_Iterator itV1(aEMin); itV1.More(); itV1.Next()) { const TopoDS_Shape& aVx = itV1.Value(); if (aV.IsSame(aVx)) + { aDMVEMin.Bind(aV, aEMin); + } } } } @@ -424,7 +438,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& } if (anEdgeOffsetMap.IsEmpty()) + { return; + } // Create map of Face ancestors for the vertices on tangent edges NCollection_DataMap, TopTools_ShapeMapHasher> @@ -439,13 +455,17 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& } const TopoDS_Shape& aE = itE.Value(); if (!anEdgeOffsetMap.IsBound(aE)) + { continue; + } NCollection_Map aMFence; { const NCollection_List& aLEA = Ancestors(aE); for (NCollection_List::Iterator itLEA(aLEA); itLEA.More(); itLEA.Next()) + { aMFence.Add(itLEA.Value()); + } } for (TopoDS_Iterator itV(aE); itV.More(); itV.Next()) @@ -458,16 +478,22 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& const TopoDS_Edge& aEA = TopoDS::Edge(itLVA.Value()); const NCollection_List* pIntervals = myMapEdgeType.Seek(aEA); if (!pIntervals || pIntervals->IsEmpty()) + { continue; + } if (pIntervals->First().Type() == ChFiDS_Tangential) + { continue; + } const NCollection_List& aLEA = Ancestors(aEA); for (NCollection_List::Iterator itLEA(aLEA); itLEA.More(); itLEA.Next()) { const TopoDS_Shape& aFA = itLEA.Value(); if (aMFence.Add(aFA)) + { pLFA->Append(aFA); + } } } } @@ -502,7 +528,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& { const TopoDS_Edge& aE1 = TopoDS::Edge(itCB1.Value()); if (!aMFence.Add(aE1)) + { continue; + } TopoDS_Compound aBlock; BRep_Builder().MakeCompound(aBlock); @@ -519,7 +547,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& { const TopoDS_Edge& aE2 = TopoDS::Edge(itCB2.Value()); if (aMFence.Contains(aE2)) + { continue; + } const NCollection_List& aLF2 = Ancestors(aE2); @@ -537,7 +567,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& // Make the prism BRepPrimAPI_MakePrism aMP(aBlock, gp_Vec(aDN1.XYZ()) * anOffset); if (!aMP.IsDone()) + { continue; + } NCollection_IndexedDataMap, @@ -597,7 +629,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& gp_Vec aBN(aPOnE, aPInF); if (aBN.Dot(aDN) < 0) + { aFNew.Reverse(); + } } // Remove the face with bigger offset value from edge ancestors @@ -672,13 +706,17 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& } if (anOriInEG == anOriInEMin) + { aEG.Reverse(); + } } } NCollection_List& aLVA = myAncestors.ChangeFromKey(aV); if (!aLVA.Contains(aEG)) + { aLVA.Append(aEG); + } aFNewEdgeMap.Add(aEG); NCollection_List& aLEGA = @@ -723,7 +761,9 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& if (aE.IsSame(aEInFToRem)) { if (BOPTools_AlgoTools::IsSplitToReverse(aEOpposite, aEInFToRem, aCtx)) + { aEOpposite.Reverse(); + } break; } } @@ -743,9 +783,11 @@ void BRepOffset_Analyse::TreatTangentFaces(const NCollection_List& NCollection_DataMap* pEEMap = myReplacement.ChangeSeek(aFToRemove); if (!pEEMap) + { pEEMap = myReplacement.Bound( aFToRemove, NCollection_DataMap()); + } pEEMap->Bind(aE, aEOpposite); // Add ancestors for the vertices @@ -771,11 +813,15 @@ const TopoDS_Edge& BRepOffset_Analyse::EdgeReplacement(const TopoDS_Face& theF, const NCollection_DataMap* pEE = myReplacement.Seek(theF); if (!pEE) + { return theE; + } const TopoDS_Shape* pE = pEE->Seek(theE); if (!pE) + { return theE; + } return TopoDS::Edge(*pE); } @@ -809,9 +855,13 @@ const NCollection_List* BRepOffset_Analyse::Descendants(const Topo NCollection_List* pLD = myDescendants.ChangeSeek(aSA); if (!pLD) + { pLD = myDescendants.Bound(aSA, NCollection_List()); + } if (!pLD->Contains(aSS)) + { pLD->Append(aSS); + } } } } @@ -864,12 +914,16 @@ void BRepOffset_Analyse::Edges(const TopoDS_Vertex& V, if (V1.IsSame(V)) { if (pIntervals->Last().Type() == T) + { LE.Append(E); + } } if (V2.IsSame(V)) { if (pIntervals->First().Type() == T) + { LE.Append(E); + } } } } @@ -893,7 +947,9 @@ void BRepOffset_Analyse::Edges(const TopoDS_Face& F, for (; it.More(); it.Next()) { if (it.Value().Type() == T) + { LE.Append(E); + } } } } @@ -914,7 +970,9 @@ void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge, VRef = C3dRef.DN(URef, 1); CorrectOrientationOfTangent(VRef, Vertex, Edge); if (VRef.SquareMagnitude() < gp::Resolution()) + { return; + } Edges.Clear(); @@ -924,13 +982,17 @@ void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge, { const TopoDS_Edge& CurE = TopoDS::Edge(it.Value()); if (CurE.IsSame(Edge)) + { continue; + } U = BRep_Tool::Parameter(Vertex, CurE); C3d = BRepAdaptor_Curve(CurE); V = C3d.DN(U, 1); CorrectOrientationOfTangent(V, Vertex, CurE); if (V.SquareMagnitude() < gp::Resolution()) + { continue; + } if (V.IsOpposite(VRef, myAngle)) { Edges.Append(CurE); @@ -1001,7 +1063,9 @@ void BRepOffset_Analyse::AddFaces(const TopoDS_Face& BRep_Builder B; const NCollection_List* pLE = Descendants(Face); if (!pLE) + { return; + } for (NCollection_List::Iterator it(*pLE); it.More(); it.Next()) { const TopoDS_Edge& E = TopoDS::Edge(it.Value()); @@ -1014,7 +1078,9 @@ void BRepOffset_Analyse::AddFaces(const TopoDS_Face& { TopoDS_Face F1 = TopoDS::Face(L.First()); if (F1.IsSame(Face)) + { F1 = TopoDS::Face(L.Last()); + } if (Map.Add(F1)) { B.Add(Co, F1); @@ -1036,7 +1102,9 @@ void BRepOffset_Analyse::AddFaces(const TopoDS_Face& BRep_Builder B; const NCollection_List* pLE = Descendants(Face); if (!pLE) + { return; + } for (NCollection_List::Iterator it(*pLE); it.More(); it.Next()) { const TopoDS_Edge& E = TopoDS::Edge(it.Value()); @@ -1049,7 +1117,9 @@ void BRepOffset_Analyse::AddFaces(const TopoDS_Face& { TopoDS_Face F1 = TopoDS::Face(L.First()); if (F1.IsSame(Face)) + { F1 = TopoDS::Face(L.Last()); + } if (Map.Add(F1)) { B.Add(Co, F1); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx index ee32420245..6f579dd001 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter2d.cxx @@ -87,9 +87,13 @@ static TopoDS_Vertex CommonVertex(TopoDS_Edge& E1, TopoDS_Edge& E2) // The first edge is the current one, the second edge is the next one. // We check last vertex of the first edge first. if (V1[1].IsSame(V2[0]) || V1[1].IsSame(V2[1])) + { return V1[1]; + } if (V1[0].IsSame(V2[0]) || V1[0].IsSame(V2[1])) + { return V1[0]; + } // return V; } @@ -107,10 +111,14 @@ static int DefineClosedness(const TopoDS_Face& theFace) gp_Vec2d aTangent = aPCurve->DN(fpar, 1); double aCrossProd1 = aTangent ^ gp::DX2d(); double aCrossProd2 = aTangent ^ gp::DY2d(); - if (std::abs(aCrossProd2) < std::abs(aCrossProd1)) // pcurve is parallel to OY + if (std::abs(aCrossProd2) < std::abs(aCrossProd1)) + { // pcurve is parallel to OY return 1; + } else + { return 2; + } } } @@ -141,12 +149,16 @@ static void GetEdgesOrientedInFace(const TopoDS_Shape& theShape, } if (theSeqEdges.Length() == 1) + { return; + } NCollection_IndexedDataMap, TopTools_ShapeMapHasher> aVEmap; for (int ii = 1; ii <= theSeqEdges.Length(); ii++) + { TopExp::MapShapesAndAncestors(theSeqEdges(ii), TopAbs_VERTEX, TopAbs_EDGE, aVEmap); + } TopoDS_Vertex aFirstVertex; TopoDS_Edge aFirstEdge; @@ -226,20 +238,30 @@ static void GetEdgesOrientedInFace(const TopoDS_Shape& theShape, { TopoDS_Vertex aLastVertex = TopExp::LastVertex(anEdge, true); // with orientation if (aLastVertex.IsSame(aFirstVertex)) + { break; + } const NCollection_List& aElist = aVEmap.FindFromKey(aLastVertex); if (aElist.Extent() == 1) + { break; + } if (aElist.First().IsSame(anEdge)) + { anEdge = TopoDS::Edge(aElist.Last()); + } else + { anEdge = TopoDS::Edge(aElist.First()); + } theSeqEdges.Append(anEdge); if (theSeqEdges.Length() == aNbEdges) + { break; + } } } @@ -273,7 +295,9 @@ static void Store( if (!IsToUpdate && aLVEx.IsEmpty()) { if (theLV.Extent()) + { theAsDes2d->Add(theEdge, theLV); + } return; } // @@ -402,7 +426,9 @@ static void EdgeInter( { if (E1.IsSame(E2)) + { return; + } double f[3], l[3]; double TolDub = 1.e-7; @@ -460,7 +486,9 @@ static void EdgeInter( { gp_Pnt P3d; if (WithDegen) + { P3d = DegPoint; + } else { gp_Pnt2d P2d = Inter2d.Point(i).Value(); @@ -534,19 +562,27 @@ static void EdgeInter( V1or = V1; V2or = V2; if (E1.Orientation() == TopAbs_REVERSED) + { V1or.Reverse(); + } if (E2.Orientation() == TopAbs_REVERSED) + { V2or.Reverse(); + } double CrossProd = V2or ^ V1; #ifdef OCCT_DEBUG if (std::abs(CrossProd) <= gp::Resolution()) std::cout << std::endl << "CrossProd = " << CrossProd << std::endl; #endif if (CrossProd > 0.) + { OO1 = TopAbs_FORWARD; + } CrossProd = V1or ^ V2; if (CrossProd > 0.) + { OO2 = TopAbs_FORWARD; + } } LV1.Append(aNewVertex.Oriented(OO1)); LV2.Append(aNewVertex.Oriented(OO2)); @@ -566,11 +602,15 @@ static void EdgeInter( for (j = 0; j < 2; j++) { if (V1[j].IsNull()) + { continue; + } for (int k = 0; k < 2; k++) { if (V2[k].IsNull()) + { continue; + } if (V1[j].IsSame(V2[k])) { if (AsDes->HasAscendant(V1[j])) @@ -633,7 +673,9 @@ static void EdgeInter( LV1.Remove(it1LV1); LV2.Remove(it1LV2); if (AffichPurge) - std::cout << "Doubles removed in EdgeInter." << std::endl; + { + std::cout << "Doubles removed in EdgeInter." << '\n'; + } Purge = true; break; } @@ -641,7 +683,9 @@ static void EdgeInter( it2LV1.Next(); } if (Purge) + { break; + } i++; } } @@ -676,9 +720,13 @@ static void RefEdgeInter( theCoincide = false; // if (E1.IsSame(E2)) + { return; + } if (E1.IsNull() || E2.IsNull()) + { return; + } double f[3], l[3]; double TolDub = 1.e-7, TolLL = 0.0; @@ -687,7 +735,9 @@ static void RefEdgeInter( occ::handle pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]); occ::handle pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]); if (pcurve1.IsNull() || pcurve2.IsNull()) + { return; + } BRepAdaptor_Curve CE1(E1, F); BRepAdaptor_Curve CE2(E2, F); @@ -756,7 +806,9 @@ static void RefEdgeInter( { gp_Pnt P3d; if (WithDegen) + { P3d = DegPoint; + } else { gp_Pnt2d P2d = Inter2d.Point(i).Value(); @@ -830,25 +882,37 @@ static void RefEdgeInter( V1or = V1; V2or = V2; if (E1.Orientation() == TopAbs_REVERSED) + { V1or.Reverse(); + } if (E2.Orientation() == TopAbs_REVERSED) + { V2or.Reverse(); + } double CrossProd = V2or ^ V1; #ifdef OCCT_DEBUG if (std::abs(CrossProd) <= gp::Resolution()) std::cout << std::endl << "CrossProd = " << CrossProd << std::endl; #endif if (CrossProd > 0.) + { OO1 = TopAbs_FORWARD; + } CrossProd = V1or ^ V2; if (CrossProd > 0.) + { OO2 = TopAbs_FORWARD; + } } if (theOr1 != TopAbs_EXTERNAL) + { OO1 = theOr1; + } if (theOr2 != TopAbs_EXTERNAL) + { OO2 = theOr2; + } LV1.Append(aNewVertex.Oriented(OO1)); LV2.Append(aNewVertex.Oriented(OO2)); @@ -867,11 +931,15 @@ static void RefEdgeInter( for (j = 0; j < 2; j++) { if (V1[j].IsNull()) + { continue; + } for (int k = 0; k < 2; k++) { if (V2[k].IsNull()) + { continue; + } if (V1[j].IsSame(V2[k])) { if (AsDes->HasAscendant(V1[j])) @@ -927,7 +995,9 @@ static void RefEdgeInter( LV1.Remove(it1LV1); LV2.Remove(it1LV2); if (AffichPurge) - std::cout << "Doubles removed in EdgeInter." << std::endl; + { + std::cout << "Doubles removed in EdgeInter." << '\n'; + } Purge = true; break; } @@ -935,7 +1005,9 @@ static void RefEdgeInter( it2LV1.Next(); } if (Purge) + { break; + } i++; } } @@ -967,7 +1039,9 @@ static void RefEdgeInter( LV1.Remove(it1LV1); LV2.Remove(it1LV2); if (!it1LV1.More()) + { break; + } } } } @@ -978,9 +1052,13 @@ static void RefEdgeInter( TopoDS_Shape aNewVertex = itl.Value(); aNewVertex.Orientation(TopAbs_FORWARD); if (theImageVV.HasImage(theVref)) + { theImageVV.Add(theVref.Oriented(TopAbs_FORWARD), aNewVertex); + } else + { theImageVV.Bind(theVref.Oriented(TopAbs_FORWARD), aNewVertex); + } } ////----------------------------------------------------- @@ -1027,7 +1105,9 @@ static bool ExtendPCurve(const occ::handle& aPCurve, { NewPCurve = aPCurve; if (NewPCurve->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { NewPCurve = occ::down_cast(NewPCurve)->BasisCurve(); + } double FirstPar = NewPCurve->FirstParameter(); double LastPar = NewPCurve->LastParameter(); @@ -1084,7 +1164,9 @@ static bool ExtendPCurve(const occ::handle& aPCurve, aSegment = new Geom2d_TrimmedCurve(aLin, 0, aDelta); if (!aCompCurve.Add(aSegment, aTol)) + { return false; + } } if (LastPar < anEl + a2Offset) @@ -1095,7 +1177,9 @@ static bool ExtendPCurve(const occ::handle& aPCurve, aSegment = new Geom2d_TrimmedCurve(aLin, 0, aDelta); if (!aCompCurve.Add(aSegment, aTol)) + { return false; + } } NewPCurve = aCompCurve.BSplineCurve(); @@ -1157,7 +1241,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const { occ::handle PCurve2 = CurveRep->PCurve2(); if (ExtendPCurve(PCurve2, anEf, anEl, a2Offset, NewPCurve)) + { CurveRep->PCurve2(NewPCurve); + } } } } @@ -1169,7 +1255,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const LastPar = anEl + delta; } else if (theCurve->IsClosed()) + { LastPar -= 0.05 * (LastPar - FirstPar); + } // check FirstPar and LastPar: the pcurve should be in its surface theCurve = CurveRep->PCurve(); @@ -1217,7 +1305,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const gp_Pnt2d aPoint = ip.Value(); if (aPoint.X() >= Umin && aPoint.X() <= Umax && aPoint.Y() >= Vmin && aPoint.Y() <= Vmax) + { params.Append(ip.ParamOnFirst()); + } } for (j = 1; j <= IntCC.NbSegments(); j++) { @@ -1228,7 +1318,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const gp_Pnt2d aPoint = ip.Value(); if (aPoint.X() >= Umin && aPoint.X() <= Umax && aPoint.Y() >= Vmin && aPoint.Y() <= Vmax) + { params.Append(ip.ParamOnFirst()); + } } if (is.HasLastPoint()) { @@ -1236,7 +1328,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const gp_Pnt2d aPoint = ip.Value(); if (aPoint.X() >= Umin && aPoint.X() <= Umax && aPoint.Y() >= Vmin && aPoint.Y() <= Vmax) + { params.Append(ip.ParamOnFirst()); + } } } } @@ -1250,10 +1344,14 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const && PntFirst.Y() <= Vmax) { if (LastPar > params(1)) + { LastPar = params(1); + } } else if (FirstPar < params(1)) + { FirstPar = params(1); + } } else { @@ -1261,14 +1359,22 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const for (i = 1; i <= params.Length(); i++) { if (params(i) < fpar) + { fpar = params(i); + } if (params(i) > lpar) + { lpar = params(i); + } } if (FirstPar < fpar) + { FirstPar = fpar; + } if (LastPar > lpar) + { LastPar = lpar; + } } } //// end of check //// @@ -1315,7 +1421,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const l += delta; } else if (C3d->IsClosed()) + { l -= 0.05 * (l - f); + } else { f = FirstParOnPC; @@ -1329,7 +1437,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const P1.Transform(aMinLocTrsf); Projector.Init(P1, C3d); if (Projector.NbPoints() > 0) + { f = Projector.LowerDistanceParameter(); + } #ifdef OCCT_DEBUG else std::cout << "ProjectPointOnCurve not done" << std::endl; @@ -1342,7 +1452,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const P2.Transform(aMinLocTrsf); Projector.Init(P2, C3d); if (Projector.NbPoints() > 0) + { l = Projector.LowerDistanceParameter(); + } #ifdef OCCT_DEBUG else std::cout << "ProjectPointOnCurve not done" << std::endl; @@ -1351,7 +1463,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const } BB.Range(NE, f, l); if (!Precision::IsInfinite(f) && !Precision::IsInfinite(l)) + { BRepLib::SameParameter(NE, Precision::Confusion(), true); + } } else if (!BRep_Tool::Degenerated(E)) // no 3d curve { @@ -1363,14 +1477,18 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const { bool IsLine = false; if (MinSurf->IsInstance(STANDARD_TYPE(Geom_Plane))) + { IsLine = true; + } else if (MinSurf->IsInstance(STANDARD_TYPE(Geom_CylindricalSurface)) || MinSurf->IsInstance(STANDARD_TYPE(Geom_ConicalSurface))) { occ::handle theLine = occ::down_cast(MinPC); gp_Dir2d LineDir = theLine->Direction(); if (LineDir.IsParallel(gp::DY2d(), Precision::Angular())) + { IsLine = true; + } } if (IsLine) { @@ -1408,6 +1526,7 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const // BB.Range( NE, FirstParOnPC, LastParOnPC ); bool ProjectionSuccess = true; if (NbPCurves > 1) + { // BRepLib::SameParameter( NE, Precision::Confusion(), true ); for (itr.Initialize((occ::down_cast(NE.TShape()))->ChangeCurves()); itr.More(); itr.Next()) @@ -1420,7 +1539,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const occ::handle theSurf = CurveRep->Surface(); TopLoc_Location theLoc = CurveRep->Location(); if (theCurve == MinPC && theSurf == MinSurf && theLoc == MinLoc) + { continue; + } FirstPar = (occ::down_cast(CurveRep))->First(); LastPar = (occ::down_cast(CurveRep))->Last(); if (std::abs(FirstPar - FirstParOnPC) > Precision::PConfusion() @@ -1454,9 +1575,13 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const occ::handle ProjPCurve = GeomProjLib::Curve2d(C3d, FirstParOnPC, LastParOnPC, theSurf); if (ProjPCurve.IsNull()) + { ProjectionSuccess = false; + } else + { CurveRep->PCurve(ProjPCurve); + } } else { @@ -1465,8 +1590,11 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const } } } + } if (ProjectionSuccess) + { BB.Range(NE, FirstParOnPC, LastParOnPC); + } else { BB.Range(NE, FirstParOnPC, LastParOnPC, true); @@ -1505,7 +1633,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const aSegment = new Geom_TrimmedCurve(aLin, 0, aDelta); if (!aCompCurve.Add(aSegment, aTol)) + { return true; + } } if (LastPar < anEl + a2Offset) @@ -1516,7 +1646,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const aSegment = new Geom_TrimmedCurve(aLin, 0, aDelta); if (!aCompCurve.Add(aSegment, aTol)) + { return true; + } } C3d = aCompCurve.BSplineCurve(); @@ -1532,7 +1664,9 @@ bool BRepOffset_Inter2d::ExtentEdge(const TopoDS_Edge& E, TopoDS_Edge& NE, const LastPar = anEl + delta; } else if (C3d->IsClosed()) + { LastPar -= 0.05 * (LastPar - FirstPar); + } BB.Range(NE, FirstPar, LastPar); } @@ -1604,7 +1738,9 @@ void BRepOffset_Inter2d::Compute( NCollection_Map EdgesOfFace; TopExp_Explorer Explo(F, TopAbs_EDGE); for (; Explo.More(); Explo.Next()) + { EdgesOfFace.Add(Explo.Current()); + } //----------------------------------------------------------- // calculate intersections2d on faces touched by @@ -1642,8 +1778,12 @@ void BRepOffset_Inter2d::Compute( const NCollection_List& aElist = theEdgeIntEdges(E1); NCollection_List::Iterator itedges(aElist); for (; itedges.More(); itedges.Next()) + { if (E2.IsSame(itedges.Value())) + { ToIntersect = false; + } + } if (ToIntersect) { @@ -1655,8 +1795,12 @@ void BRepOffset_Inter2d::Compute( const NCollection_List& aElist2 = theEdgeIntEdges(anEdge); NCollection_List::Iterator itedges2(aElist2); for (; itedges2.More(); itedges2.Next()) + { if (E2.IsSame(itedges2.Value())) + { ToIntersect = false; + } + } } } } @@ -1727,7 +1871,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( { YaBuild = Build.IsBound(itL.Value()); if (YaBuild) + { break; + } } if (YaBuild) { @@ -1735,7 +1881,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( { const TopoDS_Edge& EI = TopoDS::Edge(itL.Value()); if (EI.Orientation() != TopAbs_FORWARD && EI.Orientation() != TopAbs_REVERSED) + { continue; + } TopoDS_Shape aLocalShape = OFI.Generated(EI); const TopoDS_Edge& OE = TopoDS::Edge(aLocalShape); if (!MES.IsBound(OE) && !Build.IsBound(EI)) @@ -1752,7 +1900,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( TopoDS_Face FIO = TopoDS::Face(OFI.Face()); if (MES.IsBound(FIO)) + { FIO = TopoDS::Face(MES(FIO)); + } // BRepAdaptor_Surface BAsurf(FIO); @@ -1772,7 +1922,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( TopoDS_Shape aLocalFace = FI.Oriented(TopAbs_FORWARD); wexp.Init(TopoDS::Wire(aLocalWire), TopoDS::Face(aLocalFace)); if (!wexp.More()) + { continue; // Protection from case when explorer does not contain edges. + } CurE = FirstE = wexp.Current(); NCollection_IndexedMap Edges; @@ -1789,7 +1941,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( end = true; } if (CurE.IsSame(NextE)) + { continue; + } TopoDS_Vertex Vref = CommonVertex(CurE, NextE); @@ -1865,9 +2019,13 @@ bool BRepOffset_Inter2d::ConnexIntByInt( } if (aE1.Orientation() == TopAbs_REVERSED) + { anOr1 = TopAbs::Reverse(anOr1); + } if (aE2.Orientation() == TopAbs_REVERSED) + { anOr2 = TopAbs::Reverse(anOr2); + } RefEdgeInter(FIO, BAsurf, @@ -1884,7 +2042,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( bCoincide); if (theEdgeIntEdges.IsBound(aE1)) + { theEdgeIntEdges(aE1).Append(aE2); + } else { NCollection_List aElist; @@ -1892,7 +2052,9 @@ bool BRepOffset_Inter2d::ConnexIntByInt( theEdgeIntEdges.Bind(aE1, aElist); } if (theEdgeIntEdges.IsBound(aE2)) + { theEdgeIntEdges(aE2).Append(aE1); + } else { NCollection_List aElist; @@ -1950,7 +2112,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert( { TopoDS_Face FIO = TopoDS::Face(OFI.Face()); if (MES.IsBound(FIO)) + { FIO = TopoDS::Face(MES(FIO)); + } // NCollection_Map aME; const NCollection_List& aLE = AsDes->Descendant(FIO); @@ -1981,7 +2145,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert( TopoDS_Shape aLocalFace = FI.Oriented(TopAbs_FORWARD); wexp.Init(TopoDS::Wire(aLocalWire), TopoDS::Face(aLocalFace)); if (!wexp.More()) + { continue; // Protection from case when explorer does not contain edges. + } // CurE = FirstE = wexp.Current(); while (!end) @@ -1997,7 +2163,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert( end = true; } if (CurE.IsSame(NextE)) + { continue; + } // TopoDS_Vertex Vref = CommonVertex(CurE, NextE); if (!Build.IsBound(Vref)) diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter3d.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter3d.cxx index 66074116fe..ea272938a3 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter3d.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Inter3d.cxx @@ -161,14 +161,20 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1, TopoDS_Face NullFace; if (F1.IsSame(F2)) + { return; + } if (IsDone(F1, F2)) + { return; + } const TopoDS_Shape& InitF1 = InitOffsetFace.ImageFrom(F1); const TopoDS_Shape& InitF2 = InitOffsetFace.ImageFrom(F2); if (InitF1.IsSame(InitF2)) + { return; + } bool InterPipes = (InitF2.ShapeType() == TopAbs_EDGE && InitF1.ShapeType() == TopAbs_EDGE); bool InterFaces = (InitF1.ShapeType() == TopAbs_FACE && InitF2.ShapeType() == TopAbs_FACE); @@ -257,7 +263,9 @@ void BRepOffset_Inter3d::ConnexIntByArc(const NCollection_List& /* { ChFiDS_TypeOfConcavity OT = ChFiDS_Concave; if (mySide == TopAbs_OUT) + { OT = ChFiDS_Convex; + } TopExp_Explorer Exp(ShapeInit, TopAbs_EDGE); NCollection_List LInt1, LInt2; TopoDS_Face F1, F2; @@ -353,7 +361,9 @@ void BRepOffset_Inter3d::ConnexIntByArc(const NCollection_List& /* } if (E1.IsSame(E2) || isToSkip) + { continue; + } // Modified by skv - Fri Jan 16 16:27:54 2004 OCC4455 End if (InitOffsetFace.HasImage(E2)) { @@ -462,7 +472,9 @@ void BRepOffset_Inter3d::ConnexIntByInt( const TopoDS_Edge& aE = TopoDS::Edge(VEmap(i)); TopoDS_Shape aFGen = Analyse.Generated(aE); if (!aFGen.IsNull()) + { TopExp::MapShapes(aFGen, TopAbs_EDGE, VEmap); + } } // Add vertices for treatment @@ -470,7 +482,9 @@ void BRepOffset_Inter3d::ConnexIntByInt( for (NCollection_List::Iterator itNF(Analyse.NewFaces()); itNF.More(); itNF.Next()) + { TopExp::MapShapes(itNF.Value(), TopAbs_VERTEX, VEmap); + } } // NCollection_DataMap, TopTools_ShapeMapHasher> @@ -496,10 +510,14 @@ void BRepOffset_Inter3d::ConnexIntByInt( { const TopoDS_Shape& aEx = expE.Current(); if (aEx.Orientation() != TopAbs_FORWARD && aEx.Orientation() != TopAbs_REVERSED) + { aMEI.Add(aEx); + } } if (!aMEI.IsEmpty()) + { aDMFEI.Bind(aFx, aMEI); + } } } @@ -512,7 +530,9 @@ void BRepOffset_Inter3d::ConnexIntByInt( } const TopoDS_Shape& aS = VEmap(i); if (aS.ShapeType() != TopAbs_VERTEX) + { continue; + } // Find faces connected to the vertex NCollection_List aLF; @@ -524,13 +544,17 @@ void BRepOffset_Inter3d::ConnexIntByInt( for (NCollection_List::Iterator itLEA(aLEA); itLEA.More(); itLEA.Next()) { if (!aLF.Contains(itLEA.Value())) + { aLF.Append(itLEA.Value()); + } } } } if (aLF.Extent() < 2) + { continue; + } // build lists of faces connected to the same vertex by looking for // the pairs in which the vertex is alone (not connected to shared edges) @@ -547,13 +571,17 @@ void BRepOffset_Inter3d::ConnexIntByInt( aDMFEI.Seek(aFV1); const NCollection_List* pLE1 = Analyse.Descendants(aFV1); if (!pLE1) + { continue; + } NCollection_List::Iterator itLE1(*pLE1); for (; itLE1.More(); itLE1.Next()) { const TopoDS_Shape& aE = itLE1.Value(); if (pF1Internal && pF1Internal->Contains(aE)) + { break; + } for (TopoDS_Iterator aItV(aE); aItV.More(); aItV.Next()) { @@ -565,7 +593,9 @@ void BRepOffset_Inter3d::ConnexIntByInt( } } if (itLE1.More()) + { continue; + } // get to the next face in the list it1 = it; @@ -578,21 +608,29 @@ void BRepOffset_Inter3d::ConnexIntByInt( const NCollection_List* pLE2 = Analyse.Descendants(aFV2); if (!pLE2) + { continue; + } NCollection_List::Iterator itLE2(*pLE2); for (; itLE2.More(); itLE2.Next()) { const TopoDS_Shape& aEV2 = itLE2.Value(); if (!aME.Contains(aEV2)) + { continue; + } if (pF2Internal && pF2Internal->Contains(aEV2)) + { // Avoid intersection of faces connected by internal edge break; + } if (Analyse.HasAncestor(aEV2) && Analyse.Ancestors(aEV2).Extent() == 2) + { // Faces will be intersected through the edge break; + } } if (!itLE2.More()) @@ -643,9 +681,13 @@ void BRepOffset_Inter3d::ConnexIntByInt( } // if (OT == ChFiDS_Concave) + { CurSide = TopAbs_IN; + } else + { CurSide = TopAbs_OUT; + } //----------------------------------------------------------- // edge is of the proper type, return adjacent faces. //----------------------------------------------------------- @@ -1043,9 +1085,13 @@ void BRepOffset_Inter3d::ContextIntByInt( } const TopoDS_Face& CF = TopoDS::Face(ContextFaces(i)); if (ExtentContext) + { WCF = TopoDS::Face(MES(CF)); + } else + { WCF = CF; + } NCollection_IndexedMap VEmap; TopExp::MapShapes(CF.Oriented(TopAbs_FORWARD), TopAbs_EDGE, VEmap); @@ -1265,7 +1311,9 @@ void BRepOffset_Inter3d::ContextIntByArc( if (!Analyse.HasAncestor(E)) { if (InSide) + { myAsDes->Add(CF, E); + } else { TopoDS_Edge NE; @@ -1346,7 +1394,9 @@ void BRepOffset_Inter3d::ContextIntByArc( for (int i = 0; i < 2; i++) { if (!MV.Add(V[i])) + { continue; + } OF1.Nullify(); const NCollection_List& LE = Analyse.Ancestors(V[i]); NCollection_List::Iterator itLE(LE); @@ -1473,7 +1523,9 @@ bool BRepOffset_Inter3d::IsDone(const TopoDS_Face& F1, const TopoDS_Face& F2) co for (; it.More(); it.Next()) { if (it.Value().IsSame(F2)) + { return true; + } } } return false; diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeLoops.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeLoops.cxx index bcbc1b997d..f5b04076a9 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeLoops.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeLoops.cxx @@ -125,7 +125,9 @@ void BRepOffset_MakeLoops::Build(const NCollection_List& LF, } Loops.GetVerticesForSubstitute(myVerVerMap); if (myVerVerMap.IsEmpty()) + { return; + } BRep_Builder BB; Message_ProgressScope aPS2(aPSOuter.Next(), "Building loops", LF.Size()); for (it.Initialize(LF); it.More(); it.Next(), aPS2.Next()) @@ -147,7 +149,9 @@ void BRepOffset_MakeLoops::Build(const NCollection_List& LF, NCollection_List VList; TopoDS_Iterator VerExp(E); for (; VerExp.More(); VerExp.Next()) + { VList.Append(VerExp.Value()); + } NCollection_List::Iterator itlv(VList); for (; itlv.More(); itlv.Next()) { @@ -160,7 +164,9 @@ void BRepOffset_MakeLoops::Build(const NCollection_List& LF, occ::handle& TV = *((occ::handle*)&V.TShape()); occ::handle& NewTV = *((occ::handle*)&NewV.TShape()); if (TV->Tolerance() > NewTV->Tolerance()) + { NewTV->Tolerance(TV->Tolerance()); + } NewTV->ChangePoints().Append(TV->ChangePoints()); AsDes->Replace(V, NewV); BB.Remove(E, V); @@ -179,7 +185,9 @@ static bool IsBetweenCorks(const TopoDS_Shape& E, const NCollection_List& LContext) { if (!AsDes->HasAscendant(E)) + { return true; + } const NCollection_List& LF = AsDes->Ascendant(E); NCollection_List::Iterator it; for (it.Initialize(LF); it.More(); it.Next()) @@ -196,7 +204,9 @@ static bool IsBetweenCorks(const TopoDS_Shape& E, } } if (!found) + { return false; + } } return true; } @@ -236,10 +246,14 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& //----------------------------------------------- TopoDS_Shape aReversedF = F.Reversed(); if (InSide) + { Loops.Init(TopoDS::Face(aReversedF)); - // if (InSide) Loops.Init(TopoDS::Face(F.Reversed())); + // if (InSide) Loops.Init(TopoDS::Face(F.Reversed())); + } else + { Loops.Init(F); + } //-------------------------------------------------------- // return edges of F not modified by definition. //-------------------------------------------------------- @@ -253,9 +267,13 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& // if (!AsDes->HasAscendant(CE)) { TopoDS_Shape aReversedE = CE.Reversed(); if (InSide) + { Loops.AddConstEdge(CE); + } else + { Loops.AddConstEdge(TopoDS::Edge(aReversedE)); + } // else Loops.AddConstEdge(TopoDS::Edge(CE.Reversed())); } } @@ -285,9 +303,13 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& continue; } if (!MBound.Contains(E)) + { CE.Reverse(); + } if (InSide) + { Loops.AddConstEdge(TopoDS::Edge(CE)); + } else { TopoDS_Shape aReversedE = CE.Reversed(); @@ -321,9 +343,13 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& { TopoDS_Shape aLocalShape = E.Reversed(); if (InSide) + { Loops.AddConstEdge(E); + } else + { Loops.AddConstEdge(TopoDS::Edge(aLocalShape)); + } // if (InSide) Loops.AddConstEdge(TopoDS::Edge(E)); // else Loops.AddConstEdge(TopoDS::Edge(E.Reversed())); } @@ -331,9 +357,13 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& { TopoDS_Shape aLocalShape = E.Reversed(); if (InSide) + { Loops.AddConstEdge(TopoDS::Edge(aLocalShape)); + } else + { Loops.AddConstEdge(E); + } // if (InSide) Loops.AddConstEdge(TopoDS::Edge(E.Reversed())); // else Loops.AddConstEdge(TopoDS::Edge(E)); } @@ -372,7 +402,9 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& } Loops.GetVerticesForSubstitute(myVerVerMap); if (myVerVerMap.IsEmpty()) + { return; + } BRep_Builder BB; for (it.Initialize(LContext); it.More(); it.Next()) { @@ -389,7 +421,9 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& NCollection_List VList; TopoDS_Iterator VerExp(E); for (; VerExp.More(); VerExp.Next()) + { VList.Append(VerExp.Value()); + } NCollection_List::Iterator itlv(VList); for (; itlv.More(); itlv.Next()) { @@ -402,7 +436,9 @@ void BRepOffset_MakeLoops::BuildOnContext(const NCollection_List& occ::handle& TV = *((occ::handle*)&V.TShape()); occ::handle& NewTV = *((occ::handle*)&NewV.TShape()); if (TV->Tolerance() > NewTV->Tolerance()) + { NewTV->Tolerance(TV->Tolerance()); + } NewTV->ChangePoints().Append(TV->ChangePoints()); AsDes->Replace(V, NewV); BB.Remove(E, V); @@ -482,9 +518,13 @@ void BRepOffset_MakeLoops::BuildFaces(const NCollection_List& LF, TopExp::Vertices(E, OV1, OV2); TopExp::Vertices(CE, NV1, NV2); if (!OV1.IsSame(NV1)) + { MONV.Bind(OV1, NV1); + } if (!OV2.IsSame(NV2)) + { MONV.Bind(OV2, NV2); + } Loops.AddConstEdge(CE); } } @@ -524,7 +564,9 @@ void BRepOffset_MakeLoops::BuildFaces(const NCollection_List& LF, // l,E,BRep_Tool::Tolerance(VV)); } if (LV.IsEmpty()) + { Loops.AddConstEdge(E); + } else { Loops.AddEdge(E, LV); @@ -570,7 +612,9 @@ void BRepOffset_MakeLoops::BuildFaces(const NCollection_List& LF, } Loops.GetVerticesForSubstitute(myVerVerMap); if (myVerVerMap.IsEmpty()) + { return; + } BRep_Builder BB; for (itr.Initialize(LF); itr.More(); itr.Next()) { @@ -587,7 +631,9 @@ void BRepOffset_MakeLoops::BuildFaces(const NCollection_List& LF, NCollection_List VList; TopoDS_Iterator VerExp(E); for (; VerExp.More(); VerExp.Next()) + { VList.Append(VerExp.Value()); + } NCollection_List::Iterator itlv(VList); for (; itlv.More(); itlv.Next()) { @@ -600,7 +646,9 @@ void BRepOffset_MakeLoops::BuildFaces(const NCollection_List& LF, occ::handle& TV = *((occ::handle*)&V.TShape()); occ::handle& NewTV = *((occ::handle*)&NewV.TShape()); if (TV->Tolerance() > NewTV->Tolerance()) + { NewTV->Tolerance(TV->Tolerance()); + } NewTV->ChangePoints().Append(TV->ChangePoints()); AsDes->Replace(V, NewV); BB.Remove(E, V); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset.cxx index 41b9a636ee..8b06eebd3d 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset.cxx @@ -384,7 +384,9 @@ static bool FindParameter(const TopoDS_Vertex& V, const TopoDS_Edge& E, double& } if (!VF.IsNull()) + { orient = VF.Orientation(); + } double f, l; @@ -444,9 +446,13 @@ static bool FindParameter(const TopoDS_Vertex& V, const TopoDS_Edge& E, double& if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) { if (V.Orientation() == TopAbs_FORWARD) + { res = f; // p = f; + } else + { res = l; // p = l; + } } } } @@ -480,9 +486,13 @@ static bool FindParameter(const TopoDS_Vertex& V, const TopoDS_Edge& E, double& if ((p == PC->FirstParameter()) || (p == PC->LastParameter())) { if (V.Orientation() == TopAbs_FORWARD) + { p = PC->FirstParameter(); + } else + { p = PC->LastParameter(); + } } } // return p; @@ -546,7 +556,9 @@ static void FillContours( { const TopoDS_Edge& anEdge = Wexp.Current(); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } const NCollection_List& Lint = Analyser.Type(anEdge); if (!Lint.IsEmpty() && Lint.First().Type() == ChFiDS_FreeBound) { @@ -567,6 +579,7 @@ static void FillContours( NCollection_List aContour; aContour.Append(StartEdge); while (!CurVertex.IsSame(StartVertex)) + { for (itl.Initialize(Edges); itl.More(); itl.Next()) { TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); @@ -580,6 +593,7 @@ static void FillContours( break; } } + } Contours.Add(StartVertex, aContour); } } @@ -770,7 +784,9 @@ static void EvalMax(const TopoDS_Shape& S, double& Tol) const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current()); double TolV = BRep_Tool::Tolerance(V); if (TolV > Tol) + { Tol = TolV; + } } } @@ -783,7 +799,9 @@ void BRepOffset_MakeOffset::SetFaces() TopoDS_Face aFace = TopoDS::Face(myOriginalFaces(ii)); const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aFace); if (aPlanface) + { aFace = TopoDS::Face(*aPlanface); + } myFaces.Add(aFace); //------------- @@ -853,7 +871,9 @@ void BRepOffset_MakeOffset::MakeOffsetShape(const Message_ProgressRange& theRang myError = BRepOffset_NoError; TopAbs_State Side = TopAbs_IN; if (myOffset < 0.) + { Side = TopAbs_OUT; + } // ------------ // Preanalyse. @@ -874,7 +894,9 @@ void BRepOffset_MakeOffset::MakeOffsetShape(const Message_ProgressRange& theRang const TopoDS_Edge& anE = TopoDS::Edge(anEExp.Current()); const NCollection_List& aLI = myAnalyse.Type(anE); if (aLI.IsEmpty()) + { continue; + } if (aLI.Last().Type() == ChFiDS_Mixed) { myError = BRepOffset_MixedConnectivity; @@ -895,9 +917,13 @@ void BRepOffset_MakeOffset::MakeOffsetShape(const Message_ProgressRange& theRang UpdateFaceOffset(); if (myJoin == GeomAbs_Arc) + { BuildOffsetByArc(aPS.Next(aSteps(PIOperation_BuildOffsetBy))); + } else if (myJoin == GeomAbs_Intersection) + { BuildOffsetByInter(aPS.Next(aSteps(PIOperation_BuildOffsetBy))); + } if (myError != BRepOffset_NoError) { return; @@ -1143,7 +1169,9 @@ void BRepOffset_MakeOffset::MakeThickSolid(const Message_ProgressRange& theRange } if (myOffset > 0) + { myOffsetShape.Reverse(); + } myDone = true; } @@ -1216,7 +1244,9 @@ void BRepOffset_MakeOffset::MakeOffsetFaces( myAnalyse.Edges(V1, ChFiDS_Tangential, LE); const NCollection_List& LA = myAnalyse.Ancestors(V1); if (LE.Extent() == LA.Extent()) + { ShapeTgt.Bind(V1, OV1); + } } if (!ShapeTgt.IsBound(V2)) { @@ -1224,7 +1254,9 @@ void BRepOffset_MakeOffset::MakeOffsetFaces( myAnalyse.Edges(V2, ChFiDS_Tangential, LE); const NCollection_List& LA = myAnalyse.Ancestors(V2); if (LE.Extent() == LA.Extent()) + { ShapeTgt.Bind(V2, OV2); + } } } } @@ -1321,7 +1353,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR //------------------------------------------------------------------- bool ExtentContext = false; if (myOffset > 0) + { ExtentContext = true; + } BRepOffset_Inter3d Inter3(AsDes, Side, myTol); // Intersection between parallel faces @@ -1356,9 +1390,13 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR NCollection_List aLFaces; for (Exp.Init(myFaceComp, TopAbs_FACE); Exp.More(); Exp.Next()) + { aLFaces.Append(Exp.Current()); + } for (NCollection_List::Iterator it(myAnalyse.NewFaces()); it.More(); it.Next()) + { aLFaces.Append(it.Value()); + } //--------------------------------------------------------------------------------- // Extension of neighbor edges of new edges and intersection between neighbors. //-------------------------------------------------------------------------------- @@ -1544,9 +1582,13 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR TopoDS_Vertex CV1, CV2; TopExp::Vertices(COE, CV1, CV2); if (!CV1.IsNull()) + { myAsDes->Add(COE, CV1.Oriented(TopAbs_FORWARD)); + } if (!CV2.IsNull()) + { myAsDes->Add(COE, CV2.Oriented(TopAbs_REVERSED)); + } } } } @@ -1582,9 +1624,13 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR TopoDS_Vertex CV1, CV2; TopExp::Vertices(COE, CV1, CV2); if (!CV1.IsNull()) + { myAsDes->Add(COE, CV1.Oriented(TopAbs_FORWARD)); + } if (!CV2.IsNull()) + { myAsDes->Add(COE, CV2.Oriented(TopAbs_REVERSED)); + } } } } @@ -1616,9 +1662,13 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR TopoDS_Vertex CV1, CV2; TopExp::Vertices(COE, CV1, CV2); if (!CV1.IsNull()) + { myAsDes->Add(COE, CV1.Oriented(TopAbs_FORWARD)); + } if (!CV2.IsNull()) + { myAsDes->Add(COE, CV2.Oriented(TopAbs_REVERSED)); + } } } } @@ -1653,7 +1703,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR myInitOffsetEdge.Bind(anEdgeRef, aListNewE); } else + { myInitOffsetEdge.Bind(anEdgeRef, aNewShape); + } } else { // aNewShape != TopAbs_EDGE @@ -1669,10 +1721,14 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR NCollection_List::Iterator aNewEIter(aListNewE); for (; aNewEIter.More(); aNewEIter.Next()) + { aListNewEdge.Append(aNewEIter.Value()); + } } else + { aListNewEdge.Append(aResEdge); + } } myInitOffsetEdge.Bind(anEdgeRef, aListNewEdge); @@ -1683,7 +1739,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR TopoDS_Shape aNewEdge = MapSF(aFaceRef).Generated(anEdgeRef); if (MES.IsBound(aNewEdge)) + { aNewEdge = MES(aNewEdge); + } if (IMOE.HasImage(aNewEdge)) { @@ -1692,7 +1750,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR myInitOffsetEdge.Bind(anEdgeRef, aListNewE); } else + { myInitOffsetEdge.Bind(anEdgeRef, aNewEdge); + } } } } @@ -1732,9 +1792,13 @@ void BRepOffset_MakeOffset::BuildOffsetByInter(const Message_ProgressRange& theR TopoDS_Vertex CV1, CV2; TopExp::Vertices(COE, CV1, CV2); if (!CV1.IsNull()) + { myAsDes->Add(COE, CV1.Oriented(TopAbs_FORWARD)); + } if (!CV2.IsNull()) + { myAsDes->Add(COE, CV2.Oriented(TopAbs_REVERSED)); + } } } } @@ -1769,11 +1833,15 @@ void BRepOffset_MakeOffset::ReplaceRoots() { const TopoDS_Shape& aE = anExpE.Current(); if (!View.Add(aE)) + { continue; + } TopoDS_Shape aFGen = myAnalyse.Generated(aE); if (aFGen.IsNull()) + { continue; + } myInitOffsetFace.ReplaceRoot(aFGen, aE); @@ -1781,11 +1849,15 @@ void BRepOffset_MakeOffset::ReplaceRoots() { const TopoDS_Shape& aV = itV.Value(); if (!View.Add(aV)) + { continue; + } TopoDS_Shape aEGen = myAnalyse.Generated(aV); if (aEGen.IsNull()) + { continue; + } myInitOffsetEdge.ReplaceRoot(aEGen, aV); } @@ -1809,7 +1881,9 @@ void BRepOffset_MakeOffset::BuildFaceComp() TopAbs_Orientation anOr = aFace.Orientation(); const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aFace); if (aPlanface) + { aFace = *aPlanface; + } aBB.Add(myFaceComp, aFace.Oriented(anOr)); } } @@ -1845,7 +1919,9 @@ void BRepOffset_MakeOffset::BuildOffsetByArc(const Message_ProgressRange& theRan //-------------------------------------------------------- ChFiDS_TypeOfConcavity OT = ChFiDS_Convex; if (myOffset < 0.) + { OT = ChFiDS_Concave; + } Message_ProgressScope aPS1(aPSOuter.Next(4), "Constructing tubes on edges", 1, true); for (Exp.Init(myFaceComp, TopAbs_EDGE); Exp.More(); Exp.Next(), aPS1.Next()) @@ -1866,7 +1942,9 @@ void BRepOffset_MakeOffset::BuildOffsetByArc(const Message_ProgressRange& theRan { double CurOffset = myOffset; if (myFaceOffset.IsBound(Anc.First())) + { CurOffset = myFaceOffset(Anc.First()); + } TopoDS_Shape aLocalShapeGen = MapSF(Anc.First()).Generated(E); TopoDS_Edge EOn1 = TopoDS::Edge(aLocalShapeGen); aLocalShapeGen = MapSF(Anc.Last()).Generated(E); @@ -1962,7 +2040,9 @@ void BRepOffset_MakeOffset::BuildOffsetByArc(const Message_ProgressRange& theRan const TopoDS_Shape& FF = LLA.First(); double CurOffset = myOffset; if (myFaceOffset.IsBound(FF)) + { CurOffset = myFaceOffset(FF); + } BRepOffset_Offset OF(V, LOE, CurOffset); MapSF.Bind(V, OF); @@ -1997,14 +2077,18 @@ void BRepOffset_MakeOffset::BuildOffsetByArc(const Message_ProgressRange& theRan // Extended faces are ordered in DS and removed from MapSF. //------------------------------------------------------------ if (!myFaces.IsEmpty()) + { ToContext(MapSF); + } //------------------------------------------------------ // MAJ SD. //------------------------------------------------------ ChFiDS_TypeOfConcavity RT = ChFiDS_Concave; if (myOffset < 0.) + { RT = ChFiDS_Convex; + } NCollection_DataMap::Iterator It(MapSF); Message_ProgressScope aPS3(aPSOuter.Next(), nullptr, MapSF.Size()); for (; It.More(); It.Next(), aPS3.Next()) @@ -2161,7 +2245,9 @@ void BRepOffset_MakeOffset::ToContext( TopoDS_Face F, NF; ChFiDS_TypeOfConcavity RT = ChFiDS_Concave; if (myOffset < 0.) + { RT = ChFiDS_Convex; + } TopoDS_Shape OE, NE; TopAbs_Orientation Or; @@ -2196,9 +2282,13 @@ void BRepOffset_MakeOffset::ToContext( { NE = Created(OE); if (NE.Orientation() == TopAbs_REVERSED) + { NE.Orientation(TopAbs::Reverse(Or)); + } else + { NE.Orientation(Or); + } myAsDes->Add(NF, NE); } else @@ -2234,9 +2324,13 @@ void BRepOffset_MakeOffset::ToContext( TopoDS_Shape E = myInitOffsetEdge.ImageFrom(OE); Or = myInitOffsetEdge.Image(E).First().Orientation(); if (NE.Orientation() == TopAbs_REVERSED) + { NE.Orientation(TopAbs::Reverse(Or)); + } else + { NE.Orientation(Or); + } myInitOffsetEdge.Remove(OE); myInitOffsetEdge.Bind(E, NE); } @@ -2254,32 +2348,44 @@ void BRepOffset_MakeOffset::UpdateFaceOffset() ChFiDS_TypeOfConcavity RT = ChFiDS_Convex; if (myOffset < 0.) + { RT = ChFiDS_Concave; + } for (; it.More(); it.Next()) { const TopoDS_Face& F = TopoDS::Face(it.Key()); double CurOffset = CopiedMap(F); if (!M.Add(F)) + { continue; + } TopoDS_Compound Co; BRep_Builder Build; Build.MakeCompound(Co); NCollection_Map Dummy; Build.Add(Co, F); if (myJoin == GeomAbs_Arc) + { myAnalyse.AddFaces(F, Co, Dummy, ChFiDS_Tangential, RT); + } else + { myAnalyse.AddFaces(F, Co, Dummy, ChFiDS_Tangential); + } TopExp_Explorer exp(Co, TopAbs_FACE); for (; exp.More(); exp.Next()) { const TopoDS_Face& FF = TopoDS::Face(exp.Current()); if (!M.Add(FF)) + { continue; + } if (myFaceOffset.IsBound(FF)) + { myFaceOffset.UnBind(FF); + } myFaceOffset.Bind(FF, CurOffset); } } @@ -2331,7 +2437,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() Plast = BACurve.Value(BACurve.LastParameter()); Pmid = BACurve.Value((BACurve.FirstParameter() + BACurve.LastParameter()) / 2.); if (Pfirst.Distance(Plast) <= TolApex && Pfirst.Distance(Pmid) <= TolApex) + { continue; + } // Cones.Append( aFace ); // Circs.Append( anEdge ); // TopoDS_Vertex Vdeg = TopExp::FirstVertex( anEdge ); @@ -2386,7 +2494,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() TopoDS_Edge OrEdge = TopoDS::Edge(myInitOffsetEdge.Root(DegEdge)); TopoDS_Vertex VF = TopExp::FirstVertex(OrEdge); if (VF.IsSame(anApex)) + { break; + } } } TopoDS_Shape aLocalDegShape = DegEdge.Oriented(TopAbs_FORWARD); @@ -2421,9 +2531,13 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() TopExp::Vertices(CurEdge, v1, v2); FirstVert = CurFirstVertex; if (lPnt.Distance(FirstPoint) <= Precision::Confusion()) + { EndVert = theFirstVertex; + } else + { EndVert = BRepLib_MakeVertex(lPnt); + } CurEdge.Free(true); BB.Remove(CurEdge, v1); BB.Remove(CurEdge, v2); @@ -2434,7 +2548,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() ElSLib::Parameters(theSphere, fPnt, Uf, Vf); ElSLib::Parameters(theSphere, lPnt, Ul, Vl); if (std::abs(Ul) <= Precision::Confusion()) + { Ul = 2. * M_PI; + } occ::handle aCurv = aSphSurf->VIso(Vf); /* if (!isFirstFace) @@ -2473,7 +2589,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() TopoDS_Vertex V1, V2; TopExp::Vertices(anEdge, V1, V2); if (V1.IsSame(v1) || V2.IsSame(v1)) + { EE[j++] = anEdge; + } } } for (k = 0; k < j; k++) @@ -2520,13 +2638,21 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() p2d1 = aC2d->Value(f); p2d2 = aC2d->Value(l); if (p2d1.X() < Ufirst) + { Ufirst = p2d1.X(); + } if (p2d1.X() > Ulast) + { Ulast = p2d1.X(); + } if (p2d2.X() < Ufirst) + { Ufirst = p2d2.X(); + } if (p2d2.X() > Ulast) + { Ulast = p2d2.X(); + } } NCollection_List NewEdges; TopoDS_Edge FirstEdge; @@ -2560,7 +2686,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() EdgesOfWire.Remove(itl); } else + { itl.Next(); + } } double Vfirst, Vlast; @@ -2581,7 +2709,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() { DegEdge = TopoDS::Edge(Explo.Current()); if (BRep_Tool::Degenerated(DegEdge)) + { break; + } } TopoDS_Vertex DegVertex = TopExp::FirstVertex(DegEdge); for (Explo.Init(NewSphericalFace, TopAbs_EDGE); Explo.More(); Explo.Next()) @@ -2590,7 +2720,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() TopoDS_Vertex V1, V2; TopExp::Vertices(OldEdge, V1, V2); if (!V1.IsSame(DegVertex) && !V2.IsSame(DegVertex)) + { break; + } } TopoDS_Vertex V1, V2; TopExp::Vertices(OldEdge, V1, V2); @@ -2600,7 +2732,9 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() BRepTools_Substitution theSubstitutor; theSubstitutor.Substitute(V1.Oriented(TopAbs_FORWARD), LV1); if (!V1.IsSame(V2)) + { theSubstitutor.Substitute(V2.Oriented(TopAbs_FORWARD), LV2); + } theSubstitutor.Substitute(OldEdge.Oriented(TopAbs_FORWARD), NewEdges); theSubstitutor.Build(NewSphericalFace); if (theSubstitutor.IsCopied(NewSphericalFace)) @@ -2740,7 +2874,9 @@ void BRepOffset_MakeOffset::Intersection3D(BRepOffset_Inter3d& Inter, // BuildShellsCompleteInter is called. if (myInter && (myJoin == GeomAbs_Intersection) && myIsPlanar && !myThickening && myFaces.IsEmpty() && IsSolid(myShape)) + { return; + } NCollection_List OffsetFaces; // list of faces // created. MakeList(OffsetFaces, myInitOffsetFace, myFaces); @@ -2752,12 +2888,14 @@ void BRepOffset_MakeOffset::Intersection3D(BRepOffset_Inter3d& Inter, // between the cap and the part. if (myJoin == GeomAbs_Arc) + { Inter.ContextIntByArc(myFaces, InSide, myAnalyse, myInitOffsetFace, myInitOffsetEdge, aPS.Next()); + } } if (myInter) { @@ -2871,7 +3009,9 @@ void BRepOffset_MakeOffset::MakeLoops( for (i = 1; i <= Modif.Extent(); i++) { if (!myFaces.Contains(Modif(i))) + { LF.Append(Modif(i)); + } } // Message_ProgressScope aPS(theRange, nullptr, LF.Extent() + myFaces.Extent()); @@ -2893,11 +3033,15 @@ void BRepOffset_MakeOffset::MakeLoops( // unwinding of caps. //----------------------------------------- for (i = 1; i <= myFaces.Extent(); i++) + { LC.Append(myFaces(i)); + } bool InSide = true; if (myOffset > 0) + { InSide = false; + } myMakeLoops.BuildOnContext(LC, myAnalyse, myAsDes, myImageOffset, InSide, aPS.Next(LC.Extent())); #ifdef OCCT_DEBUG @@ -3035,7 +3179,9 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan // Check for offset existence. if (!myInitOffsetEdge.HasImage(anEdge)) + { continue; + } // Check for existence of two different vertices. NCollection_List LOE, LOE2; @@ -3130,14 +3276,22 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan { E4 = BRepLib_MakeEdge(V1, V4); if (FirstStep) + { StartEdge = E4; + } } else + { E4 = PrevEdge; + } if (V2.IsSame(StartVertex) && !ArcOnV2) + { E3 = StartEdge; + } else + { E3 = BRepLib_MakeEdge(V2, V3); + } E4.Reverse(); if (isBuildFromScratch) @@ -3190,9 +3344,10 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan if (aCirc.Axis().IsParallel(aCircOE.Axis(), Precision::Confusion()) && anAxisLine.Contains(aCircOE.Location(), Precision::Confusion())) { // cylinder, plane or cone - if (std::abs(aCirc.Radius() - aCircOE.Radius()) - <= Precision::Confusion()) // case of cylinder + if (std::abs(aCirc.Radius() - aCircOE.Radius()) <= Precision::Confusion()) + { // case of cylinder theSurf = GC_MakeCylindricalSurface(aCirc).Value(); + } else if (aCirc.Location().Distance(aCircOE.Location()) <= Precision::Confusion()) { // case of plane IsPlanar = true; @@ -3272,7 +3427,9 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan if (E3.IsSame(E4)) { if (Coeff > 0.) + { BB.UpdateEdge(E3, aLine2d, aLine2d2, theSurf, Loc, Precision::Confusion()); + } else { BB.UpdateEdge(E3, aLine2d2, aLine2d, theSurf, Loc, Precision::Confusion()); @@ -3323,7 +3480,9 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan { const TopoDS_Edge& anE = TopoDS::Edge(anItE.Value()); if (anE.IsSame(anEdge)) + { continue; + } aGC = BRep_Tool::Curve(anE, f, l); aMaxDist = ComputeMaxDist(aPln->Pln(), aGC, f, l); BB.UpdateEdge(anE, aMaxDist); @@ -3452,7 +3611,9 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan TopAbs_Orientation anOr = OrientationOfEdgeInFace(anEdge, aFaceOfEdge); TopAbs_Orientation OrInNewFace = OrientationOfEdgeInFace(anEdge, NewFace); if (OrInNewFace != TopAbs::Reverse(anOr)) + { NewFace.Reverse(); + } /////////////////// myWalls.Append(NewFace); if (ArcOnV2) @@ -3473,15 +3634,23 @@ void BRepOffset_MakeOffset::MakeMissingWalls(const Message_ProgressRange& theRan EA1 = E3; EA1.Reverse(); if (ToReverse) + { EA1.Reverse(); + } ////////////////////////////////////////////////////// if (V2.IsSame(StartVertex)) + { EA2 = StartEdge; + } else + { EA2 = BRepLib_MakeEdge(V2, arcV2); + } anArc.Orientation(((ArcReverse) ? TopAbs_REVERSED : TopAbs_FORWARD)); if (EA1.Orientation() == TopAbs_REVERSED) + { anArc.Reverse(); + } EA2.Orientation(TopAbs::Reverse(EA1.Orientation())); TopoDS_Wire arcWire; BB.MakeWire(arcWire); @@ -3544,8 +3713,10 @@ void BRepOffset_MakeOffset::MakeShells(const Message_ProgressRange& theRange) return; } TopoDS_Shape aF = it.Value(); - if (myThickening) // offsetted faces must change their orientations + if (myThickening) + { // offsetted faces must change their orientations aF.Reverse(); + } // NCollection_List Image; myImageOffset.LastImage(aF, Image); @@ -3623,7 +3794,9 @@ void BRepOffset_MakeOffset::MakeShells(const Message_ProgressRange& theRange) void BRepOffset_MakeOffset::MakeSolid(const Message_ProgressRange& theRange) { if (myOffsetShape.IsNull()) + { return; + } // Modified by skv - Mon Apr 4 18:17:27 2005 Begin // Supporting history. @@ -3652,7 +3825,9 @@ void BRepOffset_MakeOffset::MakeSolid(const Message_ProgressRange& theRange) } TopoDS_Shell Sh = TopoDS::Shell(exp.Current()); if (myThickening && myOffset > 0.) + { Sh.Reverse(); + } NbShell++; if (Sh.Closed() && aMakeSolid) { @@ -3742,7 +3917,9 @@ void BRepOffset_MakeOffset::SelectShells() // myShape has free borders and there are no caps // no unwinding 3d. if (!FreeEdges.IsEmpty() && myFaces.IsEmpty()) + { return; + } myOffsetShape = BRepOffset_Tool::Deboucle3D(myOffsetShape, FreeEdges); } @@ -3794,7 +3971,9 @@ void BRepOffset_MakeOffset::EncodeRegularity() #endif if (myOffsetShape.IsNull()) + { return; + } // find edges G1 in the result TopExp_Explorer exp(myOffsetShape, TopAbs_EDGE); @@ -3808,10 +3987,14 @@ void BRepOffset_MakeOffset::EncodeRegularity() TopoDS_Edge ROE = OE; if (!MS.Add(OE)) + { continue; + } if (myImageOffset.IsImage(OE)) + { ROE = TopoDS::Edge(myImageOffset.Root(OE)); + } const NCollection_List& LofOF = myAsDes->Ascendant(ROE); @@ -3827,7 +4010,9 @@ void BRepOffset_MakeOffset::EncodeRegularity() const TopoDS_Face& F2 = TopoDS::Face(LofOF.Last()); if (F1.IsNull() || F2.IsNull()) + { continue; + } const TopoDS_Shape& Root1 = myInitOffsetFace.Root(F1); const TopoDS_Shape& Root2 = myInitOffsetFace.Root(F2); @@ -3999,7 +4184,9 @@ double ComputeMaxDist(const gp_Pln& thePlane, } aDist2 = thePlane.SquareDistance(aP); if (aDist2 > aMaxDist) + { aMaxDist = aDist2; + } } return sqrt(aMaxDist) * 1.05; } @@ -4287,7 +4474,9 @@ bool BRepOffset_MakeOffset::CheckInputData(const Message_ProgressRange& theRange myError = checkSinglePoint(aUParam, aVParam, aSurf, aBad3dPnts); if (myError != BRepOffset_NoError) + { return false; + } } } @@ -4300,7 +4489,9 @@ bool BRepOffset_MakeOffset::CheckInputData(const Message_ProgressRange& theRange myError = checkSinglePoint(aPnt2d.X(), aPnt2d.Y(), aSurf, aBad3dPnts); if (myError != BRepOffset_NoError) + { return false; + } } } @@ -4579,7 +4770,9 @@ bool TrimEdges( NCollection_List aLFaces; for (Exp.Init(theShape, TopAbs_FACE); Exp.More(); Exp.Next()) + { aLFaces.Append(Exp.Current()); + } NCollection_Map aMFGenerated; NCollection_IndexedDataMap, TopTools_ShapeMapHasher> @@ -4638,7 +4831,9 @@ bool TrimEdges( if (theNewEdges.Add(NE)) { if (!TrimEdge(TopoDS::Edge(NE), theAsDes2d, theAsDes, theETrimEInf)) + { return false; + } } } else @@ -4656,7 +4851,9 @@ bool TrimEdges( if (!theAsDes2d->Descendant(NEC).IsEmpty()) { if (!TrimEdge(NEC, theAsDes2d, theAsDes, theETrimEInf)) + { return false; + } } else { @@ -4676,7 +4873,9 @@ bool TrimEdges( continue; } if (aMFGenerated.Contains(FI) && aDMEF.FindFromKey(aS).Extent() == 1) + { continue; + } NE = theMapSF(FI).Generated(aS); //// modified by jgv, 19.12.03 for OCC4455 //// @@ -4696,7 +4895,9 @@ bool TrimEdges( if (theNewEdges.Add(NE)) { if (!TrimEdge(TopoDS::Edge(NE), theAsDes2d, theAsDes, theETrimEInf)) + { return false; + } } } else @@ -4755,7 +4956,9 @@ bool TrimEdge( { TopoDS_Vertex V = TopoDS::Vertex(it.Value()); if (NE.Orientation() == TopAbs_REVERSED) + { V.Reverse(); + } // V.Orientation(TopAbs_INTERNAL); if (!FindParameter(V, NE, U)) { @@ -5041,7 +5244,9 @@ const NCollection_List& BRepOffset_MakeOffset::Generated(const Top { const TopoDS_Shape& aE = itLA.Value(); if (!myInitOffsetEdge.HasImage(aE)) + { continue; + } NCollection_List aLEIm; myInitOffsetEdge.LastImage(aE, aLEIm); NCollection_List::Iterator itLEIm(aLEIm); @@ -5072,7 +5277,9 @@ const NCollection_List& BRepOffset_MakeOffset::Generated(const Top TopoDS_Shape aS = theS; const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aS); if (aPlanface) + { aS = TopoDS::Face(*aPlanface); + } if (!myFaces.Contains(aS) && myInitOffsetFace.HasImage(aS)) { @@ -5084,14 +5291,18 @@ const NCollection_List& BRepOffset_MakeOffset::Generated(const Top // Useful only for faces without influence on others. NCollection_List::Iterator it(myGenerated); for (; it.More(); it.Next()) + { it.ChangeValue().Reverse(); + } } } break; } case TopAbs_SOLID: { if (theS.IsSame(myShape)) + { myGenerated.Append(myOffsetShape); + } break; } default: @@ -5099,14 +5310,20 @@ const NCollection_List& BRepOffset_MakeOffset::Generated(const Top } if (myResMap.IsEmpty()) + { TopExp::MapShapes(myOffsetShape, myResMap); + } for (NCollection_List::Iterator it(myGenerated); it.More();) { if (myResMap.Contains(it.Value())) + { it.Next(); + } else + { myGenerated.Remove(it); + } } return myGenerated; @@ -5123,7 +5340,9 @@ const NCollection_List& BRepOffset_MakeOffset::Modified(const Topo TopoDS_Shape aS = theShape; const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aS); if (aPlanface) + { aS = TopoDS::Face(*aPlanface); + } if (myFaces.Contains(aS) && myInitOffsetFace.HasImage(aS)) { @@ -5135,7 +5354,9 @@ const NCollection_List& BRepOffset_MakeOffset::Modified(const Topo // Useful only for faces without influence on others. NCollection_List::Iterator it(myGenerated); for (; it.More(); it.Next()) + { it.ChangeValue().Reverse(); + } } } } @@ -5148,10 +5369,14 @@ const NCollection_List& BRepOffset_MakeOffset::Modified(const Topo bool BRepOffset_MakeOffset::IsDeleted(const TopoDS_Shape& theS) { if (myResMap.IsEmpty()) + { TopExp::MapShapes(myOffsetShape, myResMap); + } if (myResMap.Contains(theS)) + { return false; + } return Generated(theS).IsEmpty() && Modified(theS).IsEmpty(); } @@ -5230,7 +5455,9 @@ bool BRepOffset_MakeOffset::IsPlanar() const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current(); BRepAdaptor_Surface aBAS(aF, false); if (aBAS.GetType() == GeomAbs_Plane) + { continue; + } if (myIsLinearizationAllowed) { @@ -5310,10 +5537,14 @@ bool BRepOffset_MakeOffset::IsPlanar() } } else + { aIsNonPlanarFound = true; + } } else + { aIsNonPlanarFound = true; + } } return (!aIsNonPlanarFound); @@ -5335,25 +5566,35 @@ void RemoveSeamAndDegeneratedEdges(const TopoDS_Face& theFace, const TopoDS_Face { const TopoDS_Edge& anEdge = TopoDS::Edge(anExplo.Current()); if (BRep_Tool::Degenerated(anEdge) || BRepTools::IsReallyClosed(anEdge, theOldFace)) + { aIsDegOrSeamFound = true; + } else + { aEseq.Append(anEdge); + } } if (!aIsDegOrSeamFound) + { return; + } // Reconstruct wires BRep_Builder aBB; NCollection_List aWlist; TopoDS_Iterator anItFace(aFace); for (; anItFace.More(); anItFace.Next()) + { aWlist.Append(anItFace.Value()); + } aFace.Free(true); NCollection_List::Iterator anItl(aWlist); for (; anItl.More(); anItl.Next()) + { aBB.Remove(aFace, anItl.Value()); + } while (!aEseq.IsEmpty()) { @@ -5373,10 +5614,14 @@ void RemoveSeamAndDegeneratedEdges(const TopoDS_Face& theFace, const TopoDS_Face aCurEdge = TopoDS::Edge(aEseq(ind)); TopExp::Vertices(aCurEdge, aV1, aV2, true); // with orientation if (aV1.IsSame(aCurVertex)) + { break; + } } - if (ind > aEseq.Length()) // error occurred: wire is not closed + if (ind > aEseq.Length()) + { // error occurred: wire is not closed break; + } aBB.Add(aNewWire, aCurEdge); aEseq.Remove(ind); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset_1.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset_1.cxx index 29f03c982a..e88f0f9d74 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset_1.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeOffset_1.cxx @@ -136,14 +136,18 @@ static bool TakeModified( { const TopoDS_Shape& aSIm = itLSIm.Value(); if (!theMFence || AddToContainer(aSIm, *theMFence)) + { AddToContainer(aSIm, theContainer); + } } return true; } else { if (!theMFence || AddToContainer(theS, *theMFence)) + { AddToContainer(theS, theContainer); + } return false; } } @@ -1884,7 +1888,9 @@ bool BRepOffset_BuildOffsetFaces::GetEdges( const TopoDS_Edge& aEIm = TopoDS::Edge(aItLEIm.Value()); // if (!aMEFence.Add(aEIm)) + { continue; + } if (myEdgesToAvoid.Contains(aEIm)) { @@ -2134,16 +2140,22 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( // back map from original edges to their offset images const NCollection_List* pLOr = myEdgesOrigins->Seek(aE); if (!pLOr) + { continue; + } for (NCollection_List::Iterator itOr(*pLOr); itOr.More(); itOr.Next()) { const TopoDS_Shape& aSOr = itOr.Value(); TopoDS_Shape aSInF; if (!FindShape(aSOr, aFOr, myAnalyzer, aSInF)) + { continue; + } NCollection_List* pImages = anImages.ChangeSeek(aSInF); if (!pImages) + { pImages = anImages.Bound(aSInF, NCollection_List()); + } AppendToList(*pImages, aE); } } @@ -2195,7 +2207,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( } } if (aNbVOr > 1 && (pLEOr->Extent() - aNbVOr) > 1) + { continue; + } // NCollection_Map aME, aMV, aMF; bool bInvalid = false, bChecked = false; @@ -2242,10 +2256,14 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( gp_Vec aVCur = GetAverageTangent(aEOr, aNbP); if (!aVRef.IsParallel(aVCur, Precision::Angular())) + { bAllTgt = false; + } } if (!bAllTgt) + { aEOrF = aCEOr; + } } } else @@ -2276,14 +2294,18 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( const TopoDS_Shape& aEOr = it.Value(); const NCollection_List* aLIm = anImages.Seek(aEOr); if (!aLIm) + { continue; + } ++aNbChecked; NCollection_IndexedDataMap, TopTools_ShapeMapHasher> aMVLoc; for (NCollection_List::Iterator itLIM(*aLIm); itLIM.More(); itLIM.Next()) + { TopExp::MapShapesAndAncestors(itLIM.Value(), TopAbs_VERTEX, TopAbs_EDGE, aMVLoc); + } for (int i = 1; i <= aMVLoc.Extent(); ++i) { if (aMVLoc(i).Extent() > 1 && !aMVTotal.Add(aMVLoc.FindKey(i))) @@ -2294,12 +2316,18 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( } } if (bInvalid) + { break; + } } if (!bInvalid && aNbChecked < 2) + { continue; + } else + { theEdgesValidByVertex.Add(aEIm); + } } else { @@ -2335,7 +2363,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( for (NCollection_List::Iterator itFA(myAnalyzer->Ancestors(aEOrF)); itFA.More(); itFA.Next()) + { aMF.Add(itFA.Value()); + } } // if (aCos < Precision::Confusion()) @@ -2373,24 +2403,36 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( { NCollection_List::Iterator itE(aDMVE.FindFromKey(itV.Value())); for (; itE.More(); itE.Next()) + { if (aDMEF.FindFromKey(itE.Value()).Extent() < 2) + { break; + } + } if (itE.More()) + { break; + } } bSkip = itV.More(); } } if (bSkip) + { continue; + } else + { bLocalOnly = true; + } } // if (bInvalid) { if (!bLocalOnly) + { myInvalidEdges.Add(aEIm); + } aMIE.Add(aEIm); aMEInv.Add(aEIm); continue; @@ -2402,7 +2444,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( if (!bInverted || !aNbVOr) { if (!bLocalOnly) + { myValidEdges.Add(aEIm); + } aMVE.Add(aEIm); aMEVal.Add(aEIm); } @@ -2500,15 +2544,19 @@ static void addAsNeutral(const TopoDS_Shape& theE, NCollection_IndexedMap* pMEInv = theLocInvEdges.ChangeSeek(theFInv); if (!pMEInv) + { pMEInv = theLocInvEdges.Bound(theFInv, NCollection_IndexedMap()); + } pMEInv->Add(theE); NCollection_Map* pMEVal = theLocValidEdges.ChangeSeek(theFVal); if (!pMEVal) + { pMEVal = theLocValidEdges.Bound(theFVal, NCollection_Map()); + } pMEVal->Add(theE); } @@ -2544,14 +2592,18 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( { NCollection_Map aMapNewTmp; for (NCollection_List::Iterator it(myAnalyzer->NewFaces()); it.More(); it.Next()) + { aMapNewTmp.Add(it.Value()); + } for (NCollection_List::Iterator it(theLFOffset); it.More(); it.Next()) { const TopoDS_Shape& aFOffset = it.Value(); const TopoDS_Shape& aFOrigin = myFacesOrigins->Find(aFOffset); if (aMapNewTmp.Contains(aFOrigin)) + { aNewFaces.Add(aFOffset); + } } } @@ -2561,7 +2613,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( { const TopoDS_Shape& aF = itLFO.Value(); if (aNewFaces.Contains(aF)) + { continue; + } const NCollection_List& aLFImages = myOFImages.FindFromKey(aF); for (NCollection_List::Iterator itLF(aLFImages); itLF.More(); itLF.Next()) @@ -2588,8 +2642,10 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( NCollection_Map* pMap = aMEUnclassified.ChangeSeek(aE); if (!pMap) + { pMap = &aMEUnclassified( aMEUnclassified.Add(aE, NCollection_Map())); + } pMap->Add(aFIm); aFSplitFOffset.Bind(aFIm, aF); @@ -2600,7 +2656,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( } if (aMEUnclassified.IsEmpty()) + { return; + } // Analyze unclassified edges const int aNbE = aMEUnclassified.Extent(); @@ -2616,7 +2674,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( { const TopoDS_Shape& aFClassified = itLF.Value(); if (aMFUnclassified.Contains(aFClassified)) + { continue; + } BOPTools_Set anEdgeSetClass; anEdgeSetClass.Add(aFClassified, TopAbs_EDGE); @@ -2668,7 +2728,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( TopAbs_Orientation anOriUnclass = aEUnclassified.Orientation(); if (!isSameOri) + { anOriUnclass = TopAbs::Reverse(anOriUnclass); + } if (anOriClass != anOriUnclass) { @@ -2676,9 +2738,11 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( NCollection_Map* pMENeutral = theNeutralEdges.ChangeSeek(aFOffset); if (!pMENeutral) + { pMENeutral = theNeutralEdges.Bound(aFOffset, NCollection_Map()); + } pMENeutral->Add(aE); if (isInvalid && isSameOri) @@ -2695,7 +2759,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidEdges( } } if (itLFSp.More()) + { break; + } } } } @@ -2710,7 +2776,9 @@ void BRepOffset_BuildOffsetFaces::MakeInvertedEdgesInvalid( const NCollection_List& theLFOffset) { if (myInvalidEdges.IsEmpty() || myInvertedEdges.IsEmpty()) + { return; + } // Map all invalid edges TopoDS_Compound aCBEInv; @@ -2746,7 +2814,9 @@ void BRepOffset_BuildOffsetFaces::MakeInvertedEdgesInvalid( } } if (!isClosed) + { continue; + } // Bind loop to each vertex of the loop for (int iV = 1; iV <= aDMVE.Extent(); ++iV) @@ -2868,7 +2938,9 @@ void BRepOffset_BuildOffsetFaces::FindInvalidFaces( // skip not-boundary edges originated from vertex if ((theEdgesInvalidByVertex.Contains(aEIm) || theEdgesValidByVertex.Contains(aEIm)) && aDMEF.FindFromKey(aEIm).Extent() != 1) + { continue; + } ++aNbChecked; // @@ -3209,23 +3281,31 @@ void BRepOffset_BuildOffsetFaces::FindFacesInsideHoleWires( const NCollection_List& aLFHoles = anEFHolesMap(i); // Check if the edge is outer for holes if (aLFHoles.Extent() != 1) + { continue; + } const TopoDS_Shape& aFHole = aLFHoles.First(); if (!theMFHoles.Contains(aFHole)) + { // Already removed continue; + } // Check if the edge is not outer for splits const NCollection_List& aLSplits = anEFSplitsMap.FindFromKey(anEdge); if (aLSplits.Extent() == 1) + { continue; + } // Check if edge is only connected to splits of the current offset face const NCollection_List& aLFAll = theEFMap.FindFromKey(anEdge); if (aLFAll.Extent() == 2) + { // Avoid removal of the hole from the splits theMFHoles.Remove(aFHole); + } } } @@ -3910,7 +3990,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInvalidSplitsFromValid( const TopoDS_Shape& aF = aDMIFOF.Find(aFCB); NCollection_List* pList = aDMFF.ChangeSeek(aF); if (!pList) + { pList = aDMFF.Bound(aF, NCollection_List()); + } pList->Append(aFCB); } @@ -3935,16 +4017,22 @@ void BRepOffset_BuildOffsetFaces::RemoveInvalidSplitsFromValid( { const TopoDS_Shape& aECB = aExpE.Current(); if (pValidInverted && pValidInverted->Contains(aECB)) + { break; + } if (aDMEF.FindFromKey(aECB).Extent() > 1) { if (!myInvertedEdges.Contains(aECB)) + { break; + } } } if (!aExpE.More()) + { // if one removed - remove all break; + } } if (itL.More()) { @@ -3992,12 +4080,16 @@ static void buildPairs(const NCollection_IndexedMap()); + } } for (int it1 = 1; it1 <= aNbS; ++it1) @@ -4068,9 +4160,13 @@ static void buildIntersectionPairs( const TopoDS_Shape& aFIm = itIm.Value(); if (theMFRemoved.Contains(aFIm)) + { BRep_Builder().Add(aCFRem, aFIm); + } else + { BRep_Builder().Add(aCF, aFIm); + } } } } @@ -4079,7 +4175,9 @@ static void buildIntersectionPairs( BOPTools_AlgoTools::MakeConnexityBlocks(aCF, TopAbs_EDGE, TopAbs_FACE, aLCB); if (aLCB.IsEmpty()) + { continue; + } NCollection_DataMap, @@ -4100,7 +4198,9 @@ static void buildIntersectionPairs( const TopoDS_Shape& aCS = exp.Current(); const NCollection_List* pLFV = aDMVF.Seek(aCS); if (!pLFV) + { continue; + } for (NCollection_List::Iterator itFV(*pLFV); itFV.More(); itFV.Next()) { @@ -4112,7 +4212,9 @@ static void buildIntersectionPairs( { const TopoDS_Shape* pFOr = theFOrigins.Seek(itOr.Value()); if (pFOr) + { aMFInter.Add(*pFOr); + } } } } @@ -4125,7 +4227,9 @@ static void buildIntersectionPairs( BOPTools_AlgoTools::MakeConnexityBlocks(aCFRem, TopAbs_EDGE, TopAbs_FACE, aLCB); if (aLCB.IsEmpty()) + { continue; + } for (NCollection_List::Iterator itCB(aLCB); itCB.More(); itCB.Next()) { @@ -4140,7 +4244,9 @@ static void buildIntersectionPairs( const TopoDS_Shape& aCS = exp.Current(); const NCollection_List* pLFV = aDMVF.Seek(aCS); if (!pLFV) + { continue; + } for (NCollection_List::Iterator itFV(*pLFV); itFV.More(); itFV.Next()) { @@ -4153,7 +4259,9 @@ static void buildIntersectionPairs( { const NCollection_List& aLFConnected = aDMEF(iE); if (aLFConnected.Extent() < 2) + { continue; + } NCollection_IndexedMap aMFInter; for (NCollection_List::Iterator itLF(aLFConnected); itLF.More(); itLF.Next()) @@ -4166,7 +4274,9 @@ static void buildIntersectionPairs( { const TopoDS_Shape* pFOr = theFOrigins.Seek(itOr.Value()); if (pFOr) + { aMFInter.Add(*pFOr); + } } } @@ -4256,7 +4366,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInsideFaces( aMV.SetIntersect(true); aMV.Perform(aPS.Next(9)); if (aMV.HasErrors()) + { return; + } // // get shapes connection for using in the rebuilding process @@ -4333,7 +4445,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInsideFaces( break; } if (!bFaceKept && bInvalid && !bConnected) + { bConnected = aMESols.Contains(aExpE.Current()); + } } } // @@ -4374,7 +4488,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInsideFaces( // Take into account the faces invalid by inverted edges for (NCollection_List::Iterator itLF(theInvertedFaces); itLF.More(); itLF.Next()) + { TakeModified(itLF.Value(), aMVIms, aMFInv); + } // check if the invalid faces inside the holes are really invalid: // check its normal direction - if it has changed relatively the @@ -4450,7 +4566,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInsideFaces( } if (aMFToRem.Contains(aFS)) + { continue; + } bAllRemoved = false; bAllInv &= aMFInv.Contains(aFS); @@ -4512,7 +4630,9 @@ void BRepOffset_BuildOffsetFaces::RemoveInsideFaces( // build all possible intersection pairs basing on the intersection results // taking into account removed faces. if (aMFToRem.Extent()) + { buildIntersectionPairs(myOFImages, myInvalidFaces, aMV, aMFToRem, aDMFImF, myIntersectionPairs); + } } //======================================================================= @@ -4724,10 +4844,14 @@ void BRepOffset_BuildOffsetFaces::ShapesConnections( const TopoDS_Shape& aFOpposite = !iF ? *pF2 : *pF1; if (!myArtInvalidFaces.IsBound(aFArt)) + { continue; + } if (myInvalidFaces.Contains(aFOpposite) && !myArtInvalidFaces.IsBound(aFOpposite)) + { continue; + } // Collect own invalid edges of the face and the invalid edges connected to those // own invalid edges to be avoided in the check for intersection. @@ -4790,7 +4914,9 @@ void BRepOffset_BuildOffsetFaces::ShapesConnections( if (aEF.Contains(nE) && aEF.Contains(nFOp)) { if (aEF.CommonPart().Type() == TopAbs_VERTEX) + { aLV.Append(pDS->Shape(aEF.IndexNew())); + } } } @@ -4873,7 +4999,9 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( NCollection_List aLCBHangs; BOPTools_AlgoTools::MakeConnexityBlocks(aCFHangs, TopAbs_EDGE, TopAbs_FACE, aLCBHangs); if (aLCBHangs.IsEmpty()) + { return; + } // To be removed, the block should contain invalid splits of offset faces and should // meet one of the following conditions: @@ -4893,12 +5021,16 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( NCollection_Map aMEInv; int i, aNbE = myInvalidEdges.Extent(); for (i = 1; i <= aNbE; ++i) + { TakeModified(myInvalidEdges(i), aMVIms, aMEInv); + } // Update inverted edges with intersection results NCollection_Map aMEInverted; for (int iInv = 1; iInv <= myInvertedEdges.Extent(); ++iInv) + { TakeModified(myInvertedEdges(iInv), aMVIms, aMEInverted); + } // Tool for getting the origins of the splits const NCollection_DataMap, TopTools_ShapeMapHasher>& @@ -4942,7 +5074,9 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( const TopoDS_Shape& aF = anExpF.Current(); // Check block to contain invalid face if (!bHasInvalidFace) + { bHasInvalidFace = theMFInv.Contains(aF); + } // Check block for connectivity to invalid parts if (!bIsConnected) @@ -4957,7 +5091,9 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( { NCollection_List::Iterator aItLF(*pLF); for (; aItLF.More() && !bIsConnected; aItLF.Next()) + { bIsConnected = theMFInv.Contains(aItLF.Value()); + } } } // check vertices @@ -4972,7 +5108,9 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( { NCollection_List::Iterator aItLE(*pLE); for (; aItLE.More() && !bIsConnected; aItLE.Next()) + { bIsConnected = !aBlockME.Contains(aItLE.Value()) && aMEInv.Contains(aItLE.Value()); + } } } } @@ -4987,21 +5125,27 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( { const TopoDS_Shape* pFOffset = theDMFImF.Seek(aItLFOr.Value()); if (pFOffset) + { aMOffsetF.Add(*pFOffset); + } } } else { const TopoDS_Shape* pFOffset = theDMFImF.Seek(aF); if (pFOffset) + { aMOffsetF.Add(*pFOffset); + } } } bool bRemove = bHasInvalidFace && (!bIsConnected || aMOffsetF.Extent() == 1); if (bRemove) + { aBlocksToRemove.Append(aCBH); + } } // remove the invalidated blocks @@ -5011,7 +5155,9 @@ void BRepOffset_BuildOffsetFaces::RemoveHangingParts( const TopoDS_Shape& aCBH = aItLCBH.Value(); TopExp_Explorer anExpF(aCBH, TopAbs_FACE); for (; anExpF.More(); anExpF.Next()) + { theMFToRem.Add(anExpF.Current()); + } } } @@ -5332,15 +5478,23 @@ void BRepOffset_BuildOffsetFaces::FilterInvalidFaces( { aDMEFAll = theDMEF; for (int iF = 1; iF <= aNb; ++iF) + { for (NCollection_List::Iterator itLFInv(myInvalidFaces(iF)); itLFInv.More(); itLFInv.Next()) + { TopExp::MapShapesAndAncestors(itLFInv.Value(), TopAbs_EDGE, TopAbs_FACE, aDMEFAll); + } + } } NCollection_Map aLocalSplits; for (int j = 0; j < 2; ++j) + { for (aItLF.Initialize((!j ? aLFIm : aLFInv)); aItLF.More(); aItLF.Next()) + { aLocalSplits.Add(aItLF.Value()); + } + } // Check if all invalid edges are located inside the split and do not touch // any other faces both invalid and valid @@ -5359,21 +5513,29 @@ void BRepOffset_BuildOffsetFaces::FilterInvalidFaces( for (; itLF.More(); itLF.Next()) { if (!aLocalSplits.Contains(itLF.Value())) + { break; + } } if (itLF.More()) + { break; + } } } if (aExp.More()) + { break; + } } bInvalid = aItLF.More(); if (!bInvalid) { aItLF.Initialize(aLFInv); for (; aItLF.More(); aItLF.Next()) + { AppendToList(aLFIm, aItLF.Value()); + } } } // @@ -5398,7 +5560,9 @@ void BRepOffset_BuildOffsetFaces::CheckEdgesCreatedByVertex() { const TopoDS_Shape& aF = myInvalidFaces.FindKey(i); if (myArtInvalidFaces.IsBound(aF)) + { continue; + } const NCollection_List& aLFIm = myInvalidFaces(i); for (NCollection_List::Iterator it(aLFIm); it.More(); it.Next()) @@ -5415,12 +5579,16 @@ void BRepOffset_BuildOffsetFaces::CheckEdgesCreatedByVertex() // check if this edges is not created from vertex and mark it as invalid const NCollection_List* pLEOr = myEdgesOrigins->Seek(aE); if (!pLEOr) + { continue; + } NCollection_List::Iterator itLEO(*pLEOr); for (; itLEO.More(); itLEO.Next()) { if (itLEO.Value().ShapeType() != TopAbs_VERTEX) + { break; + } } if (!itLEO.More()) { @@ -6179,18 +6347,24 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces( // const NCollection_List* aLFImi = myOFImages.Seek(aFi); if (!aLFImi) + { continue; + } // NCollection_List* aLFEi = aFLE.ChangeSeek(aFi); if (!aLFEi) + { continue; + } // NCollection_List& aLFDone = aMDone.ChangeFind(aFi); // const NCollection_Map* pInterFi = !pMFInter ? nullptr : pMFInter->Seek(aFi); if (pMFInter && !pInterFi) + { continue; + } // create map of edges and vertices for aLFImi NCollection_Map aMEVIm; @@ -6209,15 +6383,21 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces( } // if (pInterFi && !pInterFi->Contains(aFj)) + { continue; + } const NCollection_List* aLFImj = myOFImages.Seek(aFj); if (!aLFImj) + { continue; + } // NCollection_List* aLFEj = aFLE.ChangeSeek(aFj); if (!aLFEj) + { continue; + } // create map of edges and vertices for aLFImi aMEVIm.Clear(); @@ -6238,7 +6418,9 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces( FindCommonParts(*aLFImi, *aLFImj, aLVC, TopAbs_VERTEX); if (aLVC.IsEmpty()) + { continue; + } } // // if there are some common edges between faces @@ -6360,7 +6542,9 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces( const TopoDS_Shape& aE = anExpE.Current(); NCollection_List* pLEToInt = aDMOENEdges.ChangeSeek(aE); if (!pLEToInt) + { pLEToInt = &aDMOENEdges(aDMOENEdges.Add(aE, NCollection_List())); + } AppendToList(*pLEToInt, aEInt); } } @@ -6518,7 +6702,9 @@ void BRepOffset_BuildOffsetFaces::FindVerticesToAvoid( } if (!aMFence.Add(aE)) + { continue; + } NCollection_IndexedDataMap, @@ -6549,11 +6735,15 @@ void BRepOffset_BuildOffsetFaces::FindVerticesToAvoid( for (j = 1; j <= aNbV; ++j) { if (aMVEEdges(j).Extent() != 1) + { continue; + } const TopoDS_Shape& aV = aMVEEdges.FindKey(j); if (!aMFence.Add(aV)) + { continue; + } const NCollection_List* pLE = theDMVEFull.Seek(aV); if (!pLE) { @@ -6573,10 +6763,14 @@ void BRepOffset_BuildOffsetFaces::FindVerticesToAvoid( const TopoDS_Shape& aEV = aItLE.Value(); if (myInvertedEdges.Contains(aEV)) + { ++iNbEInverted; + } if (bAllEdgesInv) + { bAllEdgesInv = myInvalidEdges.Contains(aEV); + } } if (iNbEInverted > 1 || bAllEdgesInv) @@ -7586,7 +7780,9 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( int aNbE = theOENEdges.Extent(); for (i = 1; i <= aNbE; ++i) + { aBB.Add(aCEAll, theOENEdges.FindKey(i)); + } // Separate the edges into blocks NCollection_List aLBlocks; @@ -7622,13 +7818,17 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( for (; aItLEInt.More(); aItLEInt.Next()) { if (aMEFence.Add(aItLEInt.Value())) + { aBlockLENew.Append(aItLEInt.Value()); + } } } } if (aBlockLENew.IsEmpty()) + { continue; + } // Get the splits of new edges to intersect NCollection_List aLSplits; @@ -7639,18 +7839,25 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( const TopoDS_Shape& aE = aItLE.Value(); NCollection_List* pLEIm = theEImages.ChangeSeek(aE); if (!pLEIm || pLEIm->IsEmpty()) + { continue; + } NCollection_List::Iterator aItLEIm(*pLEIm); for (; aItLEIm.More(); aItLEIm.Next()) + { aLSplits.Append(aItLEIm.Value()); + } } if (aLSplits.IsEmpty()) + { continue; + } TopoDS_Shape aCE; if (aLSplits.Extent() > 1) + { // Intersect the new splits among themselves to avoid self-intersections IntersectEdges(aLSplits, aBlockLENew, @@ -7662,8 +7869,11 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( aDMEOr, aMELF, aCE); + } else + { aCE = aLSplits.First(); + } aMBlocksSp.Add(aCE, aBlockLENew); } @@ -7699,10 +7909,14 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( { const NCollection_List* pLF = aMELF.Seek(aItLE.Value()); if (!pLF) + { continue; + } NCollection_List::Iterator aItLF(*pLF); for (; aItLF.More(); aItLF.Next()) + { AppendToList(aLFaces, aItLF.Value()); + } } // Localized bounds of the splits of the offset faces @@ -7742,7 +7956,9 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( } if (bKept) + { aLValBlocks.Append(aCEVal); + } } // Filter the images of edges after the first filtering stage @@ -7774,11 +7990,14 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( { const TopoDS_Shape& aEIm = anExp.Current(); if (aMENew.Contains(aEIm) && !aMEVal.Contains(aEIm)) + { aLValBlocks.Append(aEIm); + } } } if (aLValBlocks.Extent() > 1) + { // intersect the new splits among themselves to avoid self-intersections IntersectEdges(aLValBlocks, aLE, @@ -7790,8 +8009,11 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( aDMEOr, aMELF, aSplits1); + } else + { aSplits1 = aLValBlocks.First(); + } aPSOuter.Next(); if (!aPSOuter.More()) @@ -7802,7 +8024,9 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( // Get all faces to get the bounds from their splits NCollection_List aLFaces; for (i = 1; i <= myOFImages.Extent(); ++i) + { aLFaces.Append(myOFImages.FindKey(i)); + } // Bounds of the splits of the offset faces to filter the new splits TopoDS_Shape aFilterBounds; @@ -7951,7 +8175,9 @@ void BRepOffset_BuildOffsetFaces::UpdateValidEdges( for (; aItLPB.More(); aItLPB.Next()) { if (pDS->PaveBlocks(aItLPB.Value()->OriginalEdge()).Extent() > 1) + { break; + } } bKeep = !aItLPB.More(); } @@ -8226,7 +8452,9 @@ void BRepOffset_BuildOffsetFaces::IntersectEdges( { TopExp_Explorer anExpE(aIt.Value(), TopAbs_EDGE); for (; anExpE.More(); anExpE.Next()) + { aLEInput.Append(anExpE.Current()); + } } // update new edges @@ -8235,16 +8463,22 @@ void BRepOffset_BuildOffsetFaces::IntersectEdges( { const TopoDS_Shape& aE = aIt.Value(); if (!theMENew.Contains(aE)) + { continue; + } const NCollection_List& aLEIm = aGFA.Modified(aE); if (aLEIm.IsEmpty()) + { continue; + } theMENew.Remove(aE); aIt1.Initialize(aLEIm); for (; aIt1.More(); aIt1.Next()) + { theMENew.Add(aIt1.Value()); + } } // // update edges after intersection for extended checking @@ -8331,7 +8565,9 @@ void BRepOffset_BuildOffsetFaces::GetBounds( { const NCollection_List* pLFIm = myOFImages.Seek(aItLF.Value()); if (!pLFIm) + { continue; + } NCollection_List::Iterator aIt(*pLFIm); for (; aIt.More(); aIt.Next()) { @@ -8515,7 +8751,9 @@ void BRepOffset_BuildOffsetFaces::GetInvalidEdgesByBounds( // const NCollection_List* pLEIm = theEImages.Seek(aEOr); if (!pLEIm) + { continue; + } NCollection_List::Iterator aItLEIm(*pLEIm); for (; aItLEIm.More(); aItLEIm.Next()) { @@ -8774,7 +9012,9 @@ void BRepOffset_BuildOffsetFaces::FilterSplits( const TopoDS_Shape& aE = aItLE.Value(); NCollection_List* pLEIm = theEImages.ChangeSeek(aE); if (!pLEIm) + { continue; + } NCollection_List::Iterator aItLEIm(*pLEIm); for (; aItLEIm.More();) @@ -8787,12 +9027,16 @@ void BRepOffset_BuildOffsetFaces::FilterSplits( } if (aMFence.Add(aEIm)) + { BRep_Builder().Add(aSplits, aEIm); + } aItLEIm.Next(); } if (pLEIm->IsEmpty()) + { theEImages.UnBind(aE); + } } theSplits = aSplits; } @@ -9054,7 +9298,9 @@ void BRepOffset_BuildOffsetFaces::FillGaps(const Message_ProgressRange& theRange { int aNbF = myOFImages.Extent(); if (!aNbF) + { return; + } Message_ProgressScope aPS(theRange, "Filling gaps", 2 * aNbF); @@ -9073,7 +9319,9 @@ void BRepOffset_BuildOffsetFaces::FillGaps(const Message_ProgressRange& theRange NCollection_List::Iterator itLF(myOFImages(i)); for (; itLF.More(); itLF.Next()) + { TopExp::MapShapesAndAncestors(itLF.Value(), TopAbs_EDGE, TopAbs_FACE, anEFMap); + } } // Analyze images of each offset face on the presence of free edges @@ -9087,7 +9335,9 @@ void BRepOffset_BuildOffsetFaces::FillGaps(const Message_ProgressRange& theRange NCollection_List& aLFImages = myOFImages(i); if (aLFImages.IsEmpty()) + { continue; + } // Collect all edges from the splits TopoDS_Compound anEdges; @@ -9104,20 +9354,26 @@ void BRepOffset_BuildOffsetFaces::FillGaps(const Message_ProgressRange& theRange { const TopoDS_Shape& aE = anExpE.Current(); if (aE.Orientation() != TopAbs_FORWARD && aE.Orientation() != TopAbs_REVERSED) + { // Skip internals continue; + } const NCollection_List& aLF = anEFMap.FindFromKey(aE); if (aLF.Extent() == 1) + { aFreeEdgesMap.Add(aE.Reversed()); + } BRep_Builder().Add(anEdges, aE); } } if (aFreeEdgesMap.IsEmpty()) + { // No free edges continue; + } // Free edges are found - fill the gaps by creating new splits // of the face using these free edges @@ -9183,9 +9439,13 @@ void BRepOffset_BuildOffsetFaces::FillHistory() // Add the splits to history map const TopoDS_Shape& aF = myOFImages.FindKey(i); if (myImage->HasImage(aF)) + { myImage->Add(aF, aLFImages); + } else + { myImage->Bind(aF, aLFImages); + } // Collect edges from splits NCollection_List::Iterator itLF(aLFImages); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx index a24ead1995..507e7113bf 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx @@ -132,11 +132,15 @@ void BRepOffset_MakeSimpleOffset::Clear() double BRepOffset_MakeSimpleOffset::GetSafeOffset(const double theExpectedToler) { if (myInputShape.IsNull()) + { return 0.0; // Input shape is null. + } // Compute max angle in faces junctions. - if (myMaxAngle == 0.0) // Non-initialized. + if (myMaxAngle == 0.0) + { // Non-initialized. ComputeMaxAngle(); + } double aMaxTol = 0.0; aMaxTol = BRep_Tool::MaxTolerance(myInputShape, TopAbs_VERTEX); @@ -160,8 +164,10 @@ void BRepOffset_MakeSimpleOffset::Perform() return; } - if (myMaxAngle == 0.0) // Non-initialized. + if (myMaxAngle == 0.0) + { // Non-initialized. ComputeMaxAngle(); + } myBuilder.Init(myInputShape); occ::handle aMapper = @@ -184,7 +190,9 @@ void BRepOffset_MakeSimpleOffset::Perform() const TopoDS_Edge& aCurrEdge = TopoDS::Edge(anExpSE.Current()); if (!BRep_Tool::Degenerated(aCurrEdge)) + { continue; + } const TopoDS_Edge& anEdge = TopoDS::Edge(myBuilder.ModifiedShape(aCurrEdge)); aBB.Degenerated(anEdge, true); @@ -192,7 +200,9 @@ void BRepOffset_MakeSimpleOffset::Perform() // Restore walls for solid. if (myIsBuildSolid && !BuildMissingWalls()) + { return; + } myIsDone = true; } @@ -213,10 +223,14 @@ static void tgtfaces(const TopoDS_Edge& Ed, occ::handle aCurve; aCurve = BRep_Tool::CurveOnSurface(Ed, F1, aFirst, aLast); if (aCurve.IsNull()) + { return; + } aCurve = BRep_Tool::CurveOnSurface(Ed, F2, aFirst, aLast); if (aCurve.IsNull()) + { return; + } double u; TopoDS_Edge E = Ed; @@ -226,15 +240,21 @@ static void tgtfaces(const TopoDS_Edge& Ed, occ::handle HS1 = new BRepAdaptor_Surface(aBAS1); occ::handle HS2; if (couture) + { HS2 = HS1; + } else + { HS2 = new BRepAdaptor_Surface(aBAS2); + } // case when edge lies on the one face E.Orientation(TopAbs_FORWARD); BRepAdaptor_Curve2d C2d1(E, F1); if (couture) + { E.Orientation(TopAbs_REVERSED); + } BRepAdaptor_Curve2d C2d2(E, F2); bool rev1 = (F1.Orientation() == TopAbs_REVERSED); @@ -265,22 +285,34 @@ static void tgtfaces(const TopoDS_Edge& Ed, d1 = (du1.Crossed(dv1)); norm = d1.Magnitude(); if (norm > 1.e-12) + { d1 /= norm; + } else + { continue; // skip degenerated point + } if (rev1) + { d1.Reverse(); + } C2d2.D0(u, p); HS2->D1(p.X(), p.Y(), pp2, du2, dv2); d2 = (du2.Crossed(dv2)); norm = d2.Magnitude(); if (norm > 1.e-12) + { d2 /= norm; + } else + { continue; // skip degenerated point + } if (rev2) + { d2.Reverse(); + } // Compute angle. double aCurrentAng = d1.Angle(d2); @@ -421,12 +453,16 @@ bool BRepOffset_MakeSimpleOffset::BuildMissingWalls() // Add old faces the result. TopExp_Explorer anExpSF(myInputShape, TopAbs_FACE); for (; anExpSF.More(); anExpSF.Next()) + { aBB.Add(aResCompound, anExpSF.Current()); + } // Add new faces the result. anExpSF.Init(myResShape, TopAbs_FACE); for (; anExpSF.More(); anExpSF.Next()) + { aBB.Add(aResCompound, anExpSF.Current()); + } // Add wall faces to the result. TopExp_Explorer anExpCF(aNewFaces, TopAbs_FACE); @@ -511,7 +547,9 @@ TopoDS_Face BRepOffset_MakeSimpleOffset::BuildWallFace(const TopoDS_Edge& theOri BRepLib_MakeEdge aME1(TopoDS::Vertex(aV2.Oriented(TopAbs_FORWARD)), TopoDS::Vertex(aNewV2.Oriented(TopAbs_REVERSED))); if (!aME1.IsDone()) + { return aResFace; + } aWall1 = aME1.Edge(); myMapVE.Bind(aForwardV2, aWall1); @@ -530,7 +568,9 @@ TopoDS_Face BRepOffset_MakeSimpleOffset::BuildWallFace(const TopoDS_Edge& theOri BRepLib_MakeEdge aME2(TopoDS::Vertex(aV1.Oriented(TopAbs_FORWARD)), TopoDS::Vertex(aNewV1.Oriented(TopAbs_REVERSED))); if (!aME2.IsDone()) + { return aResFace; + } aWall2 = aME2.Edge(); myMapVE.Bind(aForwardV1, aWall2); @@ -558,7 +598,9 @@ TopoDS_Face BRepOffset_MakeSimpleOffset::BuildWallFace(const TopoDS_Edge& theOri // Call of face maker is wrapped by try/catch since it generates exceptions sometimes. BRepLib_MakeFace aFM(aWire, true); if (aFM.IsDone()) + { aF = aFM.Face(); + } } catch (Standard_Failure const&) { @@ -633,7 +675,9 @@ const TopoDS_Shape BRepOffset_MakeSimpleOffset::Generated(const TopoDS_Shape& th aRes = myBuilder.ModifiedShape(theShape); if (aRes.IsNull()) + { return aRes; + } // Shape modifications obtained in scope of shape healing. aRes = myReShape->Apply(aRes); @@ -651,7 +695,9 @@ const TopoDS_Shape BRepOffset_MakeSimpleOffset::Modified(const TopoDS_Shape& the int aModStatus = myReShape->Status(theShape, aRes); if (aModStatus == 0) + { return anEmptyShape; // No modifications are applied to the shape or its sub-shapes. + } return aRes; } diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx index fd73156fce..0075283278 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Offset.cxx @@ -91,6 +91,7 @@ static gp_Pnt GetFarestCorner(const TopoDS_Wire& aWire) double MaxDist = 0.; gp_Pnt thePoint; for (int i = 1; i <= Vertices.Extent(); i++) + { for (int j = 1; j <= Vertices.Extent(); j++) { const TopoDS_Vertex& V1 = TopoDS::Vertex(Vertices(i)); @@ -104,6 +105,7 @@ static gp_Pnt GetFarestCorner(const TopoDS_Wire& aWire) thePoint = P1; } } + } return thePoint; } @@ -162,13 +164,21 @@ static void UpdateEdge(const TopoDS_Edge& E, occ::handle BC1 = occ::down_cast(C1); occ::handle BC2 = occ::down_cast(C2); if (!BC1.IsNull()) + { NC1 = BC1->BasisCurve(); + } else + { NC1 = C1; + } if (!BC2.IsNull()) + { NC2 = BC2->BasisCurve(); + } else + { NC2 = C2; + } B.UpdateEdge(E, NC1, NC2, F, Tol); } @@ -219,7 +229,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); } IsComputed = true; @@ -235,7 +247,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); IsComputed = true; } @@ -250,7 +264,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); IsComputed = true; } @@ -265,7 +281,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); IsComputed = true; } @@ -292,7 +310,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); IsComputed = true; } @@ -306,7 +326,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, L.Translate(Tr); occ::handle Line = new Geom_Line(L); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Line->Reverse(); + } UpdateEdge(Edge, Line, Loc, Tol); IsComputed = true; } @@ -320,7 +342,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, L.Translate(Tr); occ::handle Line = new Geom_Line(L); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Line->Reverse(); + } UpdateEdge(Edge, Line, Loc, Tol); IsComputed = true; } @@ -334,7 +358,9 @@ static void ComputeCurve3d(const TopoDS_Edge& Edge, occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Circle->Reverse(); + } UpdateEdge(Edge, Circle, Loc, Tol); IsComputed = true; } @@ -447,7 +473,9 @@ void BRepOffset_Offset::Init( myShape = Face; double myOffset = Offset; if (Face.Orientation() == TopAbs_REVERSED) + { myOffset *= -1.; + } TopLoc_Location L; occ::handle S = BRep_Tool::Surface(Face, L); @@ -455,7 +483,9 @@ void BRepOffset_Offset::Init( occ::handle RT = occ::down_cast(S); if (!RT.IsNull()) + { S = RT->BasisSurface(); + } bool IsTransformed = false; if ((S->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) || S->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) @@ -478,11 +508,17 @@ void BRepOffset_Offset::Init( double UU1, UU2, VV1, VV2; BRepTools::UVBounds(Face, UU1, UU2, VV1, VV2); if (VV2 < Vc && Co->SemiAngle() > 0) + { myOffset *= -1; + } else if (VV1 > Vc && Co->SemiAngle() < 0) + { myOffset *= -1; + } if (!Co->Position().Direct()) + { myOffset *= -1; + } } occ::handle TheSurf = BRepOffset::Surface(S, myOffset, myStatus); @@ -535,7 +571,9 @@ void BRepOffset_Offset::Init( gp_Pnt2d fp2d = aCurve->Value(fpar); gp_Pnt2d lp2d = aCurve->Value(lpar); if (std::abs(fp2d.X() - lp2d.X()) <= Precision::PConfusion()) + { UisoDegen = true; + } if (DegEdges.Length() == 2) { @@ -555,16 +593,24 @@ void BRepOffset_Offset::Init( if (UisoDegen) { if (std::abs(fp2d.X() - uf1) <= Precision::Confusion()) + { UminDegen = true; + } else + { UmaxDegen = true; + } } else { if (std::abs(fp2d.Y() - vf1) <= Precision::Confusion()) + { VminDegen = true; + } else + { VmaxDegen = true; + } } } if (TheSurf->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) @@ -765,9 +811,13 @@ void BRepOffset_Offset::Init( BRep_Builder myBuilder; myBuilder.MakeFace(myFace); if (!IsTransformed) + { myBuilder.UpdateFace(myFace, TheSurf, L, BRep_Tool::Tolerance(Face)); + } else + { myBuilder.UpdateFace(myFace, TheSurf, TopLoc_Location(), BRep_Tool::Tolerance(Face)); + } NCollection_DataMap MapSS; @@ -787,25 +837,35 @@ void BRepOffset_Offset::Init( TopoDS_Vertex V1, V2, OV1, OV2; TopExp::Vertices(E, V1, V2); if (HasSingularity && BRep_Tool::Degenerated(E)) + { VonDegen.Add(V1); + } if (Created.IsBound(E)) { const TopoDS_Edge& OE = TopoDS::Edge(Created(E)); TopExp::Vertices(OE, OV1, OV2); if (!MapSS.IsBound(V1)) + { MapSS.Bind(V1, OV1); + } if (!MapSS.IsBound(V2)) + { MapSS.Bind(V2, OV2); + } } if (Created.IsBound(V1)) { if (!MapSS.IsBound(V1)) + { MapSS.Bind(V1, Created(V1)); + } } if (Created.IsBound(V2)) { if (!MapSS.IsBound(V2)) + { MapSS.Bind(V2, Created(V2)); + } } } @@ -836,9 +896,13 @@ void BRepOffset_Offset::Init( // occ::handle C2d_1 = // BRep_Tool::CurveOnSurface(TopoDS::Edge(E.Reversed()),CurFace,f,l); if (E.Orientation() == TopAbs_FORWARD) + { UpdateEdge(OE, C2d, C2d_1, myFace, BRep_Tool::Tolerance(E)); + } else + { UpdateEdge(OE, C2d_1, C2d, myFace, BRep_Tool::Tolerance(E)); + } myBuilder.Range(OE, f, l); } else @@ -864,7 +928,9 @@ void BRepOffset_Offset::Init( { TheSurf->D0(P2d1.X(), P2d1.Y(), P1); if (!L.IsIdentity() && !IsTransformed) + { P1.Transform(L.Transformation()); + } vstart = P2d1.Y(); } if (VonDegen.Contains(V2)) @@ -884,7 +950,9 @@ void BRepOffset_Offset::Init( { TheSurf->D0(P2d2.X(), P2d2.Y(), P2); if (!L.IsIdentity() && !IsTransformed) + { P2.Transform(L.Transformation()); + } vend = P2d2.Y(); } // E a-t-il ume image dans la Map des Created ? @@ -892,8 +960,10 @@ void BRepOffset_Offset::Init( { OE = TopoDS::Edge(Created(E)); } - else if (MapSS.IsBound(E)) // seam edge + else if (MapSS.IsBound(E)) + { // seam edge OE = TopoDS::Edge(MapSS(E)); + } else { myBuilder.MakeEdge(OE); @@ -940,9 +1010,13 @@ void BRepOffset_Offset::Init( if (VonDegen.Contains(V1) || VonDegen.Contains(V2)) { if (VonDegen.Contains(V1)) + { P2d1.SetY(vstart); + } if (VonDegen.Contains(V2)) + { P2d2.SetY(vend); + } C2d = new Geom2d_Line(P2d1, gp_Vec2d(P2d1, P2d2)); f = 0.; l = P2d1.Distance(P2d2); @@ -950,12 +1024,18 @@ void BRepOffset_Offset::Init( { occ::handle C2d_1 = BRep_Tool::CurveOnSurface(OE, myFace, f, l); if (E.Orientation() == TopAbs_FORWARD) + { UpdateEdge(OE, C2d, C2d_1, myFace, BRep_Tool::Tolerance(E)); + } else + { UpdateEdge(OE, C2d_1, C2d, myFace, BRep_Tool::Tolerance(E)); + } } else + { UpdateEdge(OE, C2d, myFace, BRep_Tool::Tolerance(E)); + } // myBuilder.Range(OE,f,l); myBuilder.Range(OE, myFace, f, l); if (!BRep_Tool::Degenerated(E) && TheSurf->IsUClosed()) @@ -966,14 +1046,22 @@ void BRepOffset_Offset::Init( P2d1 = C2d_1->Value(BRep_Tool::Parameter(V1, E, CurFace)); P2d2 = C2d_1->Value(BRep_Tool::Parameter(V2, E, CurFace)); if (VonDegen.Contains(V1)) + { P2d1.SetY(vstart); + } if (VonDegen.Contains(V2)) + { P2d2.SetY(vend); + } C2d_1 = new Geom2d_Line(P2d1, gp_Vec2d(P2d1, P2d2)); if (E.Orientation() == TopAbs_FORWARD) + { UpdateEdge(OE, C2d, C2d_1, myFace, BRep_Tool::Tolerance(E)); + } else + { UpdateEdge(OE, C2d_1, C2d, myFace, BRep_Tool::Tolerance(E)); + } } /* if (!BRep_Tool::Degenerated(E)) @@ -990,7 +1078,9 @@ void BRepOffset_Offset::Init( // ComputeCurve3d(OE,C2d,TheSurf,L,BRep_Tool::Tolerance(E)); } if (!BRep_Tool::Degenerated(OE)) + { ComputeCurve3d(OE, C2d, TheSurf, L, BRep_Tool::Tolerance(E)); + } MapSS.Bind(E, OE); } myBuilder.Add(OW, OE.Oriented(E.Orientation())); @@ -1104,7 +1194,9 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, GeomFill_Pipe Pipe(HCP, HEdge1, HEdge2, std::abs(Offset)); Pipe.Perform(Tol, Polynomial, Conti); if (!Pipe.IsDone()) + { throw Standard_ConstructionError("GeomFill_Pipe : Cannot make a surface"); + } double ErrorPipe = Pipe.ErrorOnSurf(); occ::handle S = Pipe.Surface(); @@ -1129,7 +1221,9 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, U1 = f1; U2 = l1; if (!C1is3D) + { C1 = S->VIso(f2); + } } else { @@ -1137,12 +1231,16 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, U1 = f2; U2 = l2; if (!C1is3D) + { C1 = S->UIso(f1); + } } occ::handle Dummy; if (!C1is3D) + { UpdateEdge(Edge1, C1, Id, BRep_Tool::Tolerance(Edge1)); + } else if (C1Denerated) { UpdateEdge(Edge1, Dummy, Id, BRep_Tool::Tolerance(Edge1)); @@ -1176,7 +1274,9 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, U1 = f1; U2 = l1; if (!C2is3D) + { C2 = S->VIso(l2); + } } else { @@ -1184,11 +1284,15 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, U1 = f2; U2 = l2; if (!C2is3D) + { C2 = S->UIso(l1); + } } if (!C2is3D) + { UpdateEdge(Edge2, C2, Id, BRep_Tool::Tolerance(Edge2)); + } else if (C2Denerated) { UpdateEdge(Edge2, Dummy, Id, BRep_Tool::Tolerance(Edge2)); @@ -1201,7 +1305,9 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, // mise a same range de la nouvelle pcurve. myBuilder.SameRange(Edge2, false); if (!C2is3D && !C2Denerated) + { myBuilder.Range(Edge2, U1, U2, true); + } myBuilder.Range(Edge2, myFace, U1, U2); BRepLib::SameRange(Edge2); @@ -1264,7 +1370,9 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, } if (IsClosed) + { Edge4 = Edge3; + } constexpr double TolApp = Precision::Approximation(); @@ -1298,9 +1406,13 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, UpdateEdge(Edge3, L1, L2, myFace, PathTol); myBuilder.Range(Edge3, myFace, U1, U2); if (StartDegenerated) + { myBuilder.Degenerated(Edge3, true); - else if (FirstEdge.IsNull()) // then the 3d curve has not been yet computed + } + else if (FirstEdge.IsNull()) + { // then the 3d curve has not been yet computed ComputeCurve3d(Edge3, L1, S, Id, TolApp); + } } else { @@ -1360,9 +1472,13 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, UpdateEdge(Edge3, L1, myFace, PathTol); myBuilder.Range(Edge3, myFace, U1, U2); if (StartDegenerated) + { myBuilder.Degenerated(Edge3, true); - else if (FirstEdge.IsNull()) // then the 3d curve has not been yet computed + } + else if (FirstEdge.IsNull()) + { // then the 3d curve has not been yet computed ComputeCurve3d(Edge3, L1, S, Id, TolApp); + } if (ExchUV) { @@ -1386,9 +1502,13 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, UpdateEdge(Edge4, L2, myFace, PathTol); myBuilder.Range(Edge4, myFace, U1, U2); if (EndDegenerated) + { myBuilder.Degenerated(Edge4, true); - else if (LastEdge.IsNull()) // then the 3d curve has not been yet computed + } + else if (LastEdge.IsNull()) + { // then the 3d curve has not been yet computed ComputeCurve3d(Edge4, L2, S, Id, TolApp); + } } // SameParameter ?? @@ -1422,12 +1542,16 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, myBuilder.Add(myFace, W); if (ExchUV) + { myFace.Reverse(); + } BRepTools::Update(myFace); if (Edge1.Orientation() == TopAbs_REVERSED) + { myFace.Reverse(); + } } //================================================================================================= @@ -1546,7 +1670,9 @@ void BRepOffset_Offset::Init(const TopoDS_Vertex& Vertex, // set the u firstpoint in [0,2*pi] gp_Vec2d Tr(M_PI, 0.); if (P2d.X() > M_PI) + { Tr.Reverse(); + } PCurve->Translate(Tr); } @@ -1584,13 +1710,17 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Edge, const double Offset) GeomFill_Pipe Pipe(CP, myOffset); Pipe.Perform(); if (!Pipe.IsDone()) + { throw Standard_ConstructionError("GeomFill_Pipe : Cannot make a surface"); + } BRepLib_MakeFace MF(Pipe.Surface(), Precision::Confusion()); myFace = MF.Face(); if (Offset < 0.) + { myFace.Reverse(); + } } //================================================================================================= @@ -1616,9 +1746,13 @@ TopoDS_Shape BRepOffset_Offset::Generated(const TopoDS_Shape& Shape) const if (Shape.IsSame(exp.Current())) { if (myShape.Orientation() == TopAbs_REVERSED) + { aShape = expo.Current().Reversed(); + } else + { aShape = expo.Current(); + } break; } } @@ -1639,20 +1773,30 @@ TopoDS_Shape BRepOffset_Offset::Generated(const TopoDS_Shape& Shape) const if (V2.IsSame(Shape)) { if (expf.Current().Orientation() == TopAbs_REVERSED) + { aShape = expo.Current().Reversed(); + } else + { aShape = expo.Current(); + } } else { expo.Next(); if (expf.Current().Orientation() == TopAbs_REVERSED) + { aShape = expo.Current().Reversed(); + } else + { aShape = expo.Current(); + } } if (myFace.Orientation() == TopAbs_REVERSED) + { aShape.Reverse(); + } } break; default: diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_SimpleOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_SimpleOffset.cxx index 8d08f352fd..a8edc19bdb 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_SimpleOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_SimpleOffset.cxx @@ -56,7 +56,9 @@ bool BRepOffset_SimpleOffset::NewSurface(const TopoDS_Face& F, bool& RevFace) { if (!myFaceInfo.IsBound(F)) + { return false; + } const NewFaceData& aNFD = myFaceInfo.Find(F); @@ -77,7 +79,9 @@ bool BRepOffset_SimpleOffset::NewCurve(const TopoDS_Edge& E, double& Tol) { if (!myEdgeInfo.IsBound(E)) + { return false; + } const NewEdgeData& aNED = myEdgeInfo.Find(E); @@ -93,7 +97,9 @@ bool BRepOffset_SimpleOffset::NewCurve(const TopoDS_Edge& E, bool BRepOffset_SimpleOffset::NewPoint(const TopoDS_Vertex& V, gp_Pnt& P, double& Tol) { if (!myVertexInfo.IsBound(V)) + { return false; + } const NewVertexData& aNVD = myVertexInfo.Find(V); @@ -118,7 +124,9 @@ bool BRepOffset_SimpleOffset::NewCurve2d(const TopoDS_Edge& E, Tol = BRep_Tool::Tolerance(E); if (myEdgeInfo.IsBound(E)) + { Tol = myEdgeInfo.Find(E).myTol; + } return true; } @@ -135,7 +143,9 @@ bool BRepOffset_SimpleOffset::NewParameter(const TopoDS_Vertex& V, Tol = BRep_Tool::Tolerance(V); if (myVertexInfo.IsBound(V)) + { Tol = myVertexInfo.Find(V).myTol; + } return true; } @@ -210,7 +220,9 @@ void BRepOffset_SimpleOffset::FillFaceData(const TopoDS_Face& theFace) // Take into account face orientation. double aMult = 1.0; if (theFace.Orientation() == TopAbs_REVERSED) + { aMult = -1.0; + } BRepOffset_Status aStatus; // set by BRepOffset::Surface(), could be used to check result... aNFD.myOffsetS = BRepOffset::Surface(aS, aMult * myOffsetValue, aStatus, true); @@ -232,13 +244,17 @@ void BRepOffset_SimpleOffset::FillEdgeData( const NCollection_List& aFacesList = theEdgeFaceMap(theIdx); if (aFacesList.Size() == 0) + { return; // Free edges are skipped. + } // Get offset surface. const TopoDS_Face& aCurrFace = TopoDS::Face(aFacesList.First()); if (!myFaceInfo.IsBound(aCurrFace)) + { return; + } // No need to deal with transformation - it is applied in fill faces data method. const NewFaceData& aNFD = myFaceInfo.Find(aCurrFace); @@ -267,7 +283,9 @@ void BRepOffset_SimpleOffset::FillEdgeData( const TopoDS_Face& aCurFace = TopoDS::Face(anIter.Value()); if (!myFaceInfo.IsBound(aCurFace)) + { continue; + } // Create offset curve on surface. const occ::handle aC2dNew = BRep_Tool::CurveOnSurface(theEdge, aCurFace, aF, aL); @@ -315,7 +333,9 @@ void BRepOffset_SimpleOffset::FillVertexData( const NCollection_List& aEdgesList = theVertexEdgeMap(theIdx); if (aEdgesList.Size() == 0) + { return; // Free verices are skipped. + } // Array to store offset points. NCollection_DynamicArray anOffsetPointVec; @@ -329,7 +349,9 @@ void BRepOffset_SimpleOffset::FillVertexData( const TopoDS_Edge& aCurrEdge = TopoDS::Edge(anIterEdges.Value()); if (!myEdgeInfo.IsBound(aCurrEdge)) + { continue; // Skip shared edges with wrong orientation. + } // Find the closest bound. double aF, aL; @@ -337,7 +359,9 @@ void BRepOffset_SimpleOffset::FillVertexData( // Protection from degenerated edges. if (aC3d.IsNull()) + { continue; + } const gp_Pnt aPntF = aC3d->Value(aF); const gp_Pnt aPntL = aC3d->Value(aL); @@ -386,7 +410,9 @@ void BRepOffset_SimpleOffset::FillVertexData( { const double aSqDist = aCenter.SquareDistance(anOffsetPointVec.Value(i)); if (aSqDist > aSqMaxDist) + { aSqMaxDist = aSqDist; + } } const double aResTol = std::max(aMaxEdgeTol, std::sqrt(aSqMaxDist)); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Tool.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Tool.cxx index 3d5ada67ef..cde0d94ad4 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Tool.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_Tool.cxx @@ -164,11 +164,15 @@ static void FindPeriod(const TopoDS_Face& F, double& umin, double& umax, double& double pf, pl; const occ::handle C = BRep_Tool::CurveOnSurface(E, F, pf, pl); if (C.IsNull()) + { return; + } Geom2dAdaptor_Curve PC(C, pf, pl); double i, nbp = 20; if (PC.GetType() == GeomAbs_Line) + { nbp = 2; + } double step = (pl - pf) / nbp; gp_Pnt2d P; PC.D0(pf, P); @@ -207,7 +211,9 @@ static void PutInBounds(const TopoDS_Face& F, const TopoDS_Edge& E, occ::handle< // Recadre en U. //--------------- if (!S->IsUPeriodic() && !S->IsVPeriodic()) + { return; + } FindPeriod(F, umin, umax, vmin, vmax); @@ -244,7 +250,9 @@ static void PutInBounds(const TopoDS_Face& F, const TopoDS_Edge& E, occ::handle< double d1 = maxC - umax; double d2 = umin - minC + period; if (d2 < d1) + { du = -period; + } if (du != 0.) { gp_Vec2d T2(du, 0.); @@ -288,7 +296,9 @@ static void PutInBounds(const TopoDS_Face& F, const TopoDS_Edge& E, occ::handle< double d1 = maxC - vmax; double d2 = vmin - minC + period; if (d2 < d1) + { dv = -period; + } if (dv != 0.) { gp_Vec2d T2(0., dv); @@ -319,7 +329,9 @@ static void BuildPCurves(const TopoDS_Edge& E, const TopoDS_Face& F) double ff, ll; occ::handle C2d = BRep_Tool::CurveOnSurface(E, F, ff, ll); if (!C2d.IsNull()) + { return; + } // double Tolerance = std::max(Precision::Confusion(),BRep_Tool::Tolerance(E)); constexpr double Tolerance = Precision::Confusion(); @@ -331,7 +343,9 @@ static void BuildPCurves(const TopoDS_Edge& E, const TopoDS_Face& F) occ::handle theSurf = BRep_Tool::Surface(F); occ::handle typS = theSurf->DynamicType(); if (typS == STANDARD_TYPE(Geom_OffsetSurface)) + { typS = occ::down_cast(theSurf)->BasisSurface()->DynamicType(); + } if (typS == STANDARD_TYPE(Geom_BezierSurface) || typS == STANDARD_TYPE(Geom_BSplineSurface)) { gp_Pnt fpoint = AC.Value(AC.FirstParameter()); @@ -347,7 +361,9 @@ static void BuildPCurves(const TopoDS_Edge& E, const TopoDS_Face& F) BRepAdaptor_Curve aCurve(anEdge); Extrema_ExtPC fextr(fpoint, aCurve); if (!fextr.IsDone() || fextr.NbExt() < 1) + { continue; + } double dist2, dist2min = RealLast(); int i; for (i = 1; i <= fextr.NbExt(); i++) @@ -360,10 +376,14 @@ static void BuildPCurves(const TopoDS_Edge& E, const TopoDS_Face& F) } } if (dist2min > TolProj * TolProj) + { continue; + } Extrema_ExtPC lextr(lpoint, aCurve); if (!lextr.IsDone() || lextr.NbExt() < 1) + { continue; + } dist2min = RealLast(); for (i = 1; i <= lextr.NbExt(); i++) { @@ -395,7 +415,9 @@ static void BuildPCurves(const TopoDS_Edge& E, const TopoDS_Face& F) C2d = new Geom2d_TrimmedCurve(C2d, U1, U2); if (theSurf->IsUPeriodic() || theSurf->IsVPeriodic()) + { PutInBounds(F, E, C2d); + } BRep_Builder B; B.UpdateEdge(E, C2d, F, BRep_Tool::Tolerance(E)); @@ -482,9 +504,13 @@ void BRepOffset_Tool::OrientSection(const TopoDS_Edge& E, double ParOnC; if (AP.IsDone()) + { ParOnC = AP.Parameter(); + } else + { ParOnC = BOPTools_AlgoTools2D::IntermediatePoint(f, l); + } gp_Vec T1 = C->DN(ParOnC, 1).Transformed(L.Transformation()); if (T1.SquareMagnitude() > gp::Resolution()) @@ -499,13 +525,17 @@ void BRepOffset_Tool::OrientSection(const TopoDS_Edge& E, S1->D1(P.X(), P.Y(), P3, D1U, D1V); gp_Vec DN1(D1U ^ D1V); if (F1.Orientation() == TopAbs_REVERSED) + { DN1.Reverse(); + } P = C2->Value(ParOnC); S2->D1(P.X(), P.Y(), P3, D1U, D1V); gp_Vec DN2(D1U ^ D1V); if (F2.Orientation() == TopAbs_REVERSED) + { DN2.Reverse(); + } gp_Vec ProVec = DN2 ^ T1; double Prod = DN1.Dot(ProVec); @@ -528,9 +558,13 @@ void BRepOffset_Tool::OrientSection(const TopoDS_Edge& E, O2 = TopAbs_REVERSED; } if (F1.Orientation() == TopAbs_REVERSED) + { O1 = TopAbs::Reverse(O1); + } if (F2.Orientation() == TopAbs_REVERSED) + { O2 = TopAbs::Reverse(O2); + } } //================================================================================================= @@ -593,9 +627,13 @@ static bool ToSmall(const occ::handle& C) gp_Pnt P2 = C->Value(C->LastParameter()); gp_Pnt P3 = C->Value(m); if (P1.Distance(P2) > Tol) + { return false; + } if (P2.Distance(P3) > Tol) + { return false; + } return true; } @@ -627,7 +665,9 @@ static bool IsOnSurface(const occ::handle& C, ElSLib::PlaneParameters(Ax, P, U, V); TolReached = P.Distance(ElSLib::PlaneValue(U, V, Ax)); if (TolReached > TolConf) + { return false; + } } break; } @@ -640,7 +680,9 @@ static bool IsOnSurface(const occ::handle& C, ElSLib::CylinderParameters(Ax, Rad, P, U, V); TolReached = P.Distance(ElSLib::CylinderValue(U, V, Ax, Rad)); if (TolReached > TolConf) + { return false; + } } break; } @@ -654,7 +696,9 @@ static bool IsOnSurface(const occ::handle& C, ElSLib::ConeParameters(Ax, Rad, Alp, P, U, V); TolReached = P.Distance(ElSLib::ConeValue(U, V, Ax, Rad, Alp)); if (TolReached > TolConf) + { return false; + } } break; } @@ -667,7 +711,9 @@ static bool IsOnSurface(const occ::handle& C, ElSLib::SphereParameters(Ax, Rad, P, U, V); TolReached = P.Distance(ElSLib::SphereValue(U, V, Ax, Rad)); if (TolReached > TolConf) + { return false; + } } break; } @@ -681,7 +727,9 @@ static bool IsOnSurface(const occ::handle& C, ElSLib::TorusParameters(Ax, R1, R2, P, U, V); TolReached = P.Distance(ElSLib::TorusValue(U, V, Ax, R1, R2)); if (TolReached > TolConf) + { return false; + } } break; } @@ -719,7 +767,9 @@ void BRepOffset_Tool::PipeInter(const TopoDS_Face& F1, { CI = Inter.Line(i); if (ToSmall(CI)) + { continue; + } TopoDS_Edge E = BRepLib_MakeEdge(CI); if (Inter.HasLineOnS1(i)) { @@ -773,7 +823,9 @@ static bool IsAutonomVertex(const TopoDS_Shape& theVertex, const BOPDS_FaceInfo& aFaceInfo = thePDS->FaceInfo(nF[i]); const NCollection_Map& IndMap = aFaceInfo.VerticesOn(); if (IndMap.Contains(nV)) + { return false; + } } return true; @@ -898,15 +950,21 @@ static bool BSplineEdges(const TopoDS_Edge& E1, occ::handle C1 = BRep_Tool::Curve(E1, first1, last1); if (C1->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { C1 = occ::down_cast(C1)->BasisCurve(); + } occ::handle C2 = BRep_Tool::Curve(E2, first2, last2); if (C2->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { C2 = occ::down_cast(C2)->BasisCurve(); + } if (!C1->IsInstance(STANDARD_TYPE(Geom_BSplineCurve)) || !C2->IsInstance(STANDARD_TYPE(Geom_BSplineCurve))) + { return false; + } Param1 = (par1 == 0) ? first1 : last1; Param2 = (par2 == 0) ? first2 : last2; @@ -917,9 +975,13 @@ static bool BSplineEdges(const TopoDS_Edge& E1, C2->D1(Param2, Pnt2, Der2); if (Der1.Magnitude() <= gp::Resolution() || Der2.Magnitude() <= gp::Resolution()) + { angle = M_PI / 2.; + } else + { angle = Der1.Angle(Der2); + } return true; } @@ -953,9 +1015,13 @@ static double AngleWireEdge(const TopoDS_Wire& aWire, const TopoDS_Edge& anEdge) Angle = M_PI - Angle; } else if (V11.IsSame(CV) && V22.IsSame(CV)) + { BSplineEdges(FirstEdge, anEdge, 0, 1, Angle); + } else if (V12.IsSame(CV) && V21.IsSame(CV)) + { BSplineEdges(FirstEdge, anEdge, 1, 0, Angle); + } else { BSplineEdges(FirstEdge, anEdge, 1, 1, Angle); @@ -1010,11 +1076,15 @@ static occ::handle ConcatPCurves(const TopoDS_Edge& E1, PCurve1 = BRep_Tool::CurveOnSurface(E1, F, first1, last1); if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { PCurve1 = occ::down_cast(PCurve1)->BasisCurve(); + } PCurve2 = BRep_Tool::CurveOnSurface(E2, F, first2, last2); if (PCurve2->IsInstance(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { PCurve2 = occ::down_cast(PCurve2)->BasisCurve(); + } if (PCurve1 == PCurve2) { @@ -1079,7 +1149,9 @@ static occ::handle ConcatPCurves(const TopoDS_Edge& E1, { Geom2dConvert_ApproxCurve Approx2d(newPCurve, Tol, Continuity, MaxSeg, MaxDeg); if (Approx2d.HasResult()) + { newPCurve = Approx2d.Curve(); + } } newFirst = newPCurve->FirstParameter(); newLast = newPCurve->LastParameter(); @@ -1115,11 +1187,15 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, C1 = BRep_Tool::Curve(E1, first1, last1); if (C1->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { C1 = occ::down_cast(C1)->BasisCurve(); + } C2 = BRep_Tool::Curve(E2, first2, last2); if (C2->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { C2 = occ::down_cast(C2)->BasisCurve(); + } if (C1 == C2) { @@ -1139,13 +1215,17 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, occ::handle TC2 = new Geom_TrimmedCurve(C2, first2, last2); GeomConvert_CompCurveToBSplineCurve Concat(TC1); if (!Concat.Add(TC2, theGlueTol, After)) + { return newEdge; + } newCurve = Concat.BSplineCurve(); if (newCurve->Continuity() < GeomAbs_C1) { GeomConvert_ApproxCurve Approx3d(newCurve, Tol, Continuity, MaxSeg, MaxDeg); if (Approx3d.HasResult()) + { newCurve = Approx3d.Curve(); + } } fparam = newCurve->FirstParameter(); lparam = newCurve->LastParameter(); @@ -1154,9 +1234,13 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, BRep_Builder BB; if (IsCanonic) + { newEdge = BRepLib_MakeEdge(newCurve, Vfirst, Vlast); + } else + { newEdge = BRepLib_MakeEdge(newCurve, Vfirst, Vlast, fparam, lparam); + } double newFirst, newLast; if (addPCurve1) @@ -1215,14 +1299,18 @@ static void CheckIntersFF(const BOPDS_PDS& } if (nbe == 0) + { return; + } NCollection_List CompList; BOPTools_AlgoTools::MakeConnexityBlocks(Edges, TopAbs_VERTEX, TopAbs_EDGE, CompList); TopoDS_Shape NearestCompound; if (CompList.Extent() == 1) + { NearestCompound = CompList.First(); + } else { BRepAdaptor_Curve BAcurve(RefEdge); @@ -1236,7 +1324,9 @@ static void CheckIntersFF(const BOPDS_PDS& BRepExtrema_DistShapeShape Projector(Vref, aCompound); if (!Projector.IsDone() || Projector.NbSolution() == 0) + { continue; + } double aDist = Projector.Value(); if (aDist < MinDist) @@ -1286,7 +1376,9 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS, Vfirst = Vlast = V1; } else + { return NullEdge; + } } else { @@ -1324,15 +1416,21 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS, } } else + { return NullEdge; + } } // end of else (open wire) TopoDS_Edge NewEdge = Glue(CurEdge, anEdge, Vfirst, Vlast, After, F1, addPCurve1, F2, addPCurve2, aGlueTol); if (NewEdge.IsNull()) + { return NullEdge; + } else + { CurEdge = NewEdge; + } } // end of for (int j = 2; j <= EdgesForConcat.Length(); j++) return CurEdge; @@ -1384,7 +1482,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, NCollection_IndexedMap TrueEdges; if (!RefEdge.IsNull()) + { CheckIntersFF(aPF.PDS(), RefEdge, TrueEdges); + } bool addPCurve1 = true; bool addPCurve2 = true; @@ -1422,14 +1522,18 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, int nSect = aPB->Edge(); const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&pDS->Shape(nSect); if (!TrueEdges.IsEmpty() && !TrueEdges.Contains(anEdge)) + { continue; + } double f, l; const occ::handle& aC3DE = BRep_Tool::Curve(anEdge, f, l); occ::handle aC3DETrim; if (!aC3DE.IsNull()) + { aC3DETrim = new Geom_TrimmedCurve(aC3DE, f, l); + } double aTolEdge = BRep_Tool::Tolerance(anEdge); @@ -1491,19 +1595,31 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, occ::handle aSurf = BRep_Tool::Surface(F1); if (aSurf->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurf = occ::down_cast(aSurf)->BasisSurface(); + } if (aSurf->IsInstance(STANDARD_TYPE(Geom_Plane))) + { addPCurve1 = false; + } else if (aSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { isEl1 = true; + } aSurf = BRep_Tool::Surface(F2); if (aSurf->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurf = occ::down_cast(aSurf)->BasisSurface(); + } if (aSurf->IsInstance(STANDARD_TYPE(Geom_Plane))) + { addPCurve2 = false; + } else if (aSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { isEl2 = true; + } if (L1.Extent() > 1 && (!isEl1 || !isEl2) && !theRefFace1.IsNull()) { @@ -1593,13 +1709,21 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, if (!TrueEdges.IsEmpty()) { for (i = TrueEdges.Extent(); i >= 1; i--) + { EdgesForConcat.Append(TrueEdges(i)); + } TopoDS_Edge AssembledEdge = AssembleEdge(pDS, F1, F2, addPCurve1, addPCurve2, EdgesForConcat); if (AssembledEdge.IsNull()) + { for (i = TrueEdges.Extent(); i >= 1; i--) + { eseq.Append(TrueEdges(i)); + } + } else + { eseq.Append(AssembledEdge); + } } else { @@ -1607,7 +1731,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, NCollection_Sequence edges; NCollection_List::Iterator itl(L1); for (; itl.More(); itl.Next()) + { edges.Append(itl.Value()); + } while (!edges.IsEmpty()) { TopoDS_Edge anEdge = TopoDS::Edge(edges.First()); @@ -1638,7 +1764,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, BB.MakeWire(aWire); BB.Add(aWire, anEdge); if (AreConnex(resWire, aWire)) + { Candidates.Append(j); + } } int minind = 1; if (Candidates.Length() > 1) @@ -1677,7 +1805,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, { TopoDS_Edge anEdge = TopoDS::Edge(itw.Value()); if (StartFound) + { Elist.Append(anEdge); + } else { TopoDS_Vertex V1, V2; @@ -1695,7 +1825,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, StartFound = true; } else + { Elist.Append(anEdge); + } } } // end of for (; itw.More(); itw.Next()) if (!StartFound) @@ -1736,16 +1868,24 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, { BRepTools_WireExplorer Wexp(aWire); for (; Wexp.More(); Wexp.Next()) + { aLocalEdgesForConcat.Append(Wexp.Current()); + } } TopoDS_Edge AssembledEdge = AssembleEdge(pDS, F1, F2, addPCurve1, addPCurve2, aLocalEdgesForConcat); if (AssembledEdge.IsNull()) + { for (j = aLocalEdgesForConcat.Length(); j >= 1; j--) + { eseq.Append(aLocalEdgesForConcat(j)); + } + } else + { eseq.Append(AssembledEdge); + } } // for (i = 1; i <= wseq.Length(); i++) } // end of else (when TrueEdges is empty) @@ -1763,7 +1903,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, std::cout << "Tolerance of glued E = " << EdgeTol << std::endl; #endif if (EdgeTol > 1.e-2) + { continue; + } if (EdgeTol >= 1.e-4) { @@ -1836,7 +1978,9 @@ bool BRepOffset_Tool::TryProject(const TopoDS_Face& F1, } C = new Geom_TrimmedCurve(C, f, l); if (!L.IsIdentity()) + { C->Transform(L); + } double TolReached; isOk = IsOnSurface(C, Bouchon, TolConf, TolReached); @@ -1854,7 +1998,9 @@ bool BRepOffset_Tool::TryProject(const TopoDS_Face& F1, LInt2.Append(CurE.Oriented(O2)); } else + { Ok = false; + } } return Ok; } @@ -1903,7 +2049,9 @@ void BRepOffset_Tool::InterOrExtent(const TopoDS_Face& F1, CI = Inter.Line(i); if (ToSmall(CI)) + { continue; + } TopoDS_Edge E = BRepLib_MakeEdge(CI); BuildPCurves(E, F1); BuildPCurves(E, F2); @@ -1959,9 +2107,13 @@ static void ExtentEdge(const TopoDS_Face& F, double tx, ty, tmin; tx = ty = Precision::Infinite(); if (std::abs(Tang.X()) > Precision::Confusion()) + { tx = std::min(std::abs((umax - P.X()) / Tang.X()), std::abs((umin - P.X()) / Tang.X())); + } if (std::abs(Tang.Y()) > Precision::Confusion()) + { ty = std::min(std::abs((vmax - P.Y()) / Tang.Y()), std::abs((vmin - P.Y()) / Tang.Y())); + } tmin = std::min(tx, ty); Tang = tmin * Tang; gp_Pnt2d PF2d(P.X() - Tang.X(), P.Y() - Tang.Y()); @@ -1969,9 +2121,13 @@ static void ExtentEdge(const TopoDS_Face& F, C2d->D1(CE.LastParameter(), P, Tang); tx = ty = Precision::Infinite(); if (std::abs(Tang.X()) > Precision::Confusion()) + { tx = std::min(std::abs((umax - P.X()) / Tang.X()), std::abs((umin - P.X()) / Tang.X())); + } if (std::abs(Tang.Y()) > Precision::Confusion()) + { ty = std::min(std::abs((vmax - P.Y()) / Tang.Y()), std::abs((vmin - P.Y()) / Tang.Y())); + } tmin = std::min(tx, ty); Tang = tmin * Tang; gp_Pnt2d PL2d(P.X() + Tang.X(), P.Y() + Tang.Y()); @@ -1982,7 +2138,9 @@ static void ExtentEdge(const TopoDS_Face& F, occ::handle ExtC = occ::down_cast(CC); if (ExtC.IsNull()) + { return; + } GeomLib::ExtendCurveToPoint(ExtC, PF, 1, false); GeomLib::ExtendCurveToPoint(ExtC, PL, 1, true); @@ -2123,9 +2281,13 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, int NbPC1 = 1, NbPC2 = 1; if (BRep_Tool::IsClosed(E1, F)) + { NbPC1++; + } if (BRep_Tool::IsClosed(E2, F)) + { NbPC2++; + } occ::handle S = BRep_Tool::Surface(F); occ::handle C1, C2; @@ -2138,9 +2300,13 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, { TopoDS_Shape aLocalEdgeReversedE1 = E1.Reversed(); if (i == 1) + { C1 = BRep_Tool::CurveOnSurface(E1, F, fl1[0], fl1[1]); + } else + { C1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalEdgeReversedE1), F, fl1[0], fl1[1]); + } // if (i == 1) C1 = BRep_Tool::CurveOnSurface(E1,F,fl1[0],fl1[1]); // else C1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(E1.Reversed()), // F,fl1[0],fl1[1]); @@ -2148,9 +2314,13 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, { TopoDS_Shape aLocalEdge = E2.Reversed(); if (j == 1) + { C2 = BRep_Tool::CurveOnSurface(E2, F, fl2[0], fl2[1]); + } else + { C2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalEdge), F, fl2[0], fl2[1]); + } // if (j == 1) C2 = BRep_Tool::CurveOnSurface(E2,F,fl2[0],fl2[1]); // else C2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(E2.Reversed()), // F,fl2[0],fl2[1]); @@ -2202,6 +2372,7 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, } } if (!YaSol) + { for (i1 = 0; i1 < 2; i1++) { Extrema_ExtPC2d extr(P1[i1], AC2); @@ -2229,7 +2400,9 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, } } } + } if (!YaSol) + { for (int i2 = 0; i2 < 2; i2++) { Extrema_ExtPC2d extr(P2[i2], AC1); @@ -2257,6 +2430,7 @@ void BRepOffset_Tool::Inter2d(const TopoDS_Face& F, } } } + } } if (!YaSol) @@ -2429,7 +2603,9 @@ static void MakeFace(const occ::handle& S, bool vmindegen = isVminDegen, vmaxdegen = isVmaxDegen; occ::handle theSurf = S; if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { theSurf = occ::down_cast(S)->BasisSurface(); + } if (theSurf->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) { occ::handle ConicalS = occ::down_cast(theSurf); @@ -2438,9 +2614,13 @@ static void MakeFace(const occ::handle& S, double Uapex, Vapex; ElSLib::Parameters(theCone, theApex, Uapex, Vapex); if (std::abs(VMin - Vapex) <= Precision::Confusion()) + { vmindegen = true; + } if (std::abs(VMax - Vapex) <= Precision::Confusion()) + { vmaxdegen = true; + } } // compute vertices @@ -2452,16 +2632,24 @@ static void MakeFace(const occ::handle& S, if (!umininf) { if (!vmininf) + { B.MakeVertex(V00, S->Value(UMin, VMin), tol); + } if (!vmaxinf) + { B.MakeVertex(V01, S->Value(UMin, VMax), tol); + } } if (!umaxinf) { if (!vmininf) + { B.MakeVertex(V10, S->Value(UMax, VMin), tol); + } if (!vmaxinf) + { B.MakeVertex(V11, S->Value(UMax, VMax), tol); + } } if (uclosed) @@ -2477,20 +2665,32 @@ static void MakeFace(const occ::handle& S, } if (vmindegen) + { V10 = V00; + } if (vmaxdegen) + { V11 = V01; + } // make the lines occ::handle Lumin, Lumax, Lvmin, Lvmax; if (!umininf) + { Lumin = new Geom2d_Line(gp_Pnt2d(UMin, 0), gp_Dir2d(gp_Dir2d::D::Y)); + } if (!umaxinf) + { Lumax = new Geom2d_Line(gp_Pnt2d(UMax, 0), gp_Dir2d(gp_Dir2d::D::Y)); + } if (!vmininf) + { Lvmin = new Geom2d_Line(gp_Pnt2d(0, VMin), gp_Dir2d(gp_Dir2d::D::X)); + } if (!vmaxinf) + { Lvmax = new Geom2d_Line(gp_Pnt2d(0, VMax), gp_Dir2d(gp_Dir2d::D::X)); + } occ::handle Cumin, Cumax, Cvmin, Cvmax; double TolApex = 1.e-5; @@ -2499,20 +2699,28 @@ static void MakeFace(const occ::handle& S, if (hasiso) { if (!umininf) + { Cumin = S->UIso(UMin); + } if (!umaxinf) + { Cumax = S->UIso(UMax); + } if (!vmininf) { Cvmin = S->VIso(VMin); if (BRepOffset_Tool::Gabarit(Cvmin) <= TolApex) + { vmindegen = true; + } } if (!vmaxinf) { Cvmax = S->VIso(VMax); if (BRepOffset_Tool::Gabarit(Cvmax) <= TolApex) + { vmaxdegen = true; + } } } @@ -2525,13 +2733,21 @@ static void MakeFace(const occ::handle& S, if (!umininf) { if (hasiso) + { B.MakeEdge(eumin, Cumin, tol); + } else + { B.MakeEdge(eumin); + } if (uclosed) + { B.UpdateEdge(eumin, Lumax, Lumin, F, tol); + } else + { B.UpdateEdge(eumin, Lumin, F, tol); + } if (!vmininf) { V00.Orientation(TopAbs_FORWARD); @@ -2548,13 +2764,19 @@ static void MakeFace(const occ::handle& S, if (!umaxinf) { if (uclosed) + { eumax = eumin; + } else { if (hasiso) + { B.MakeEdge(eumax, Cumax, tol); + } else + { B.MakeEdge(eumax); + } B.UpdateEdge(eumax, Lumax, F, tol); if (!vmininf) { @@ -2573,13 +2795,21 @@ static void MakeFace(const occ::handle& S, if (!vmininf) { if (hasiso && !vmindegen) + { B.MakeEdge(evmin, Cvmin, tol); + } else + { B.MakeEdge(evmin); + } if (vclosed) + { B.UpdateEdge(evmin, Lvmin, Lvmax, F, tol); + } else + { B.UpdateEdge(evmin, Lvmin, F, tol); + } if (!umininf) { V00.Orientation(TopAbs_FORWARD); @@ -2592,19 +2822,27 @@ static void MakeFace(const occ::handle& S, } B.Range(evmin, UMin, UMax); if (vmindegen) + { B.Degenerated(evmin, true); + } } if (!vmaxinf) { if (vclosed) + { evmax = evmin; + } else { if (hasiso && !vmaxdegen) + { B.MakeEdge(evmax, Cvmax, tol); + } else + { B.MakeEdge(evmax); + } B.UpdateEdge(evmax, Lvmax, F, tol); if (!umininf) { @@ -2618,7 +2856,9 @@ static void MakeFace(const occ::handle& S, } B.Range(evmax, UMin, UMax); if (vmaxdegen) + { B.Degenerated(evmax, true); + } } } @@ -2657,13 +2897,21 @@ static void MakeFace(const occ::handle& S, // one wire B.MakeWire(W); if (!umininf) + { B.Add(W, eumin); + } if (!vmininf) + { B.Add(W, evmin); + } if (!umaxinf) + { B.Add(W, eumax); + } if (!vmaxinf) + { B.Add(W, evmax); + } B.Add(F, W); W.Closed(!umininf && !umaxinf && !vmininf && !vmaxinf); F.Closed(uclosed && vclosed); @@ -2719,14 +2967,22 @@ static bool EnlargeGeometry(occ::handle& S, theLenBeforeVfirst, theLenAfterVlast); if (!theGlobalEnlargeVfirst) + { V1 = vf1; + } if (!theGlobalEnlargeVlast) + { V2 = vf2; + } if (!theGlobalEnlargeVfirst || !theGlobalEnlargeVlast) + { // Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->SetTrim( U1, U2, V1, V2 ); S = new Geom_RectangularTrimmedSurface(BS, U1, U2, V1, V2); + } else + { S = BS; + } SurfaceChange = true; } else if (S->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) @@ -2771,7 +3027,9 @@ static bool EnlargeGeometry(occ::handle& S, enlargeU = false; } else if (S->IsUClosed()) + { enlargeU = false; + } else { viso = S->VIso(vf1); @@ -2782,9 +3040,13 @@ static bool EnlargeGeometry(occ::handle& S, uiso1 = S->UIso(uf1); uiso2 = S->UIso(uf2); if (BRepOffset_Tool::Gabarit(uiso1) <= TolApex) + { enlargeUfirst = false; + } if (BRepOffset_Tool::Gabarit(uiso2) <= TolApex) + { enlargeUlast = false; + } } if (Precision::IsInfinite(v1) || Precision::IsInfinite(v2)) { @@ -2794,7 +3056,9 @@ static bool EnlargeGeometry(occ::handle& S, enlargeV = false; } else if (S->IsVClosed()) + { enlargeV = false; + } else { uiso = S->UIso(uf1); @@ -2819,16 +3083,24 @@ static bool EnlargeGeometry(occ::handle& S, if (enlargeU) { if (enlargeUfirst && du_first != 0.) + { GeomLib::ExtendSurfByLength(aSurf, du_first, 1, true, false); + } if (enlargeUlast && du_last != 0.) + { GeomLib::ExtendSurfByLength(aSurf, du_last, 1, true, true); + } } if (enlargeV) { if (enlargeVfirst && dv_first != 0.) + { GeomLib::ExtendSurfByLength(aSurf, dv_first, 1, false, false); + } if (enlargeVlast && dv_last != 0.) + { GeomLib::ExtendSurfByLength(aSurf, dv_last, 1, false, true); + } } S = aSurf; S->Bounds(U1, U2, V1, V2); @@ -2841,9 +3113,13 @@ static bool EnlargeGeometry(occ::handle& S, bool enlargeUfirst = enlargeU, enlargeUlast = enlargeU; bool enlargeVfirst = theGlobalEnlargeVfirst, enlargeVlast = theGlobalEnlargeVlast; if (S->IsUClosed()) + { enlargeU = false; + } if (S->IsVClosed()) + { enlargeV = false; + } double duf = uf2 - uf1, dvf = vf2 - vf1; double u1, u2, v1, v2; @@ -2862,9 +3138,13 @@ static bool EnlargeGeometry(occ::handle& S, gabarit_viso1 = BRepOffset_Tool::Gabarit(viso1); gabarit_viso2 = BRepOffset_Tool::Gabarit(viso2); if (gabarit_viso1 <= TolApex || gabarit_viso2 <= TolApex) + { enlargeU = false; + } if (gabarit_uiso1 <= TolApex || gabarit_uiso2 <= TolApex) + { enlargeV = false; + } GeomAdaptor_Curve gac; if (enlargeU) @@ -2874,9 +3154,13 @@ static bool EnlargeGeometry(occ::handle& S, du_first = (theLenBeforeUfirst == -1) ? du_default : theLenBeforeUfirst; du_last = (theLenAfterUlast == -1) ? du_default : theLenAfterUlast; if (gabarit_uiso1 <= TolApex) + { enlargeUfirst = false; + } if (gabarit_uiso2 <= TolApex) + { enlargeUlast = false; + } } if (enlargeV) { @@ -2900,16 +3184,24 @@ static bool EnlargeGeometry(occ::handle& S, if (enlargeU) { if (enlargeUfirst && uf1 - u1 < duf && du_first != 0.) + { GeomLib::ExtendSurfByLength(aSurf, du_first, 1, true, false); + } if (enlargeUlast && u2 - uf2 < duf && du_last != 0.) + { GeomLib::ExtendSurfByLength(aSurf, du_last, 1, true, true); + } } if (enlargeV) { if (enlargeVfirst && vf1 - v1 < dvf && dv_first != 0.) + { GeomLib::ExtendSurfByLength(aSurf, dv_first, 1, false, false); + } if (enlargeVlast && v2 - vf2 < dvf && dv_last != 0.) + { GeomLib::ExtendSurfByLength(aSurf, dv_last, 1, false, true); + } } S = aSurf; @@ -3003,9 +3295,13 @@ static void CompactUVBounds(const TopoDS_Face& F, } if (!B.IsVoid()) + { B.Get(UMin, VMin, UMax, VMax); + } else + { BRep_Tool::Surface(F)->Bounds(UMin, UMax, VMin, VMax); + } } //================================================================================================= @@ -3029,7 +3325,9 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, occ::handle theSurf = BRep_Tool::Surface(F); if (theSurf->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { theSurf = occ::down_cast(theSurf)->BasisSurface(); + } if (theSurf->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion) || theSurf->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution) @@ -3049,11 +3347,15 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, double fpar, lpar; occ::handle aCurve = BRep_Tool::CurveOnSurface(anEdge, F, fpar, lpar); if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { aCurve = occ::down_cast(aCurve)->BasisCurve(); + } occ::handle theLine; if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_Line)) + { theLine = occ::down_cast(aCurve); + } else if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BezierCurve) || aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve)) { @@ -3076,25 +3378,37 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, if (BRep_Tool::Degenerated(anEdge)) { if (std::abs(theLine->Location().Y() - VF1) <= Precision::Confusion()) + { enlargeVfirst = false; - else // theLine->Location().Y() is near VF2 + } + else + { // theLine->Location().Y() is near VF2 enlargeVlast = false; + } } else { if (theLine->Location().Y() < Vfirst) + { Vfirst = theLine->Location().Y(); + } if (theLine->Location().Y() > Vlast) + { Vlast = theLine->Location().Y(); + } } } else if (theDir.IsParallel(gp::DY2d(), Precision::Angular())) { Ubound++; if (theLine->Location().X() < Ufirst) + { Ufirst = theLine->Location().X(); + } if (theLine->Location().X() > Ulast) + { Ulast = theLine->Location().X(); + } } } } @@ -3106,7 +3420,9 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, { if (Ubound >= 2 && std::abs(UF1 - Ufirst) <= Precision::Confusion() && std::abs(UF2 - Ulast) <= Precision::Confusion()) + { enlargeU = false; + } if (Vbound >= 2 && std::abs(VF1 - Vfirst) <= Precision::Confusion() && std::abs(VF2 - Vlast) <= Precision::Confusion()) { @@ -3232,7 +3548,9 @@ bool BRepOffset_Tool::EnLargeFace(const TopoDS_Face& F, // Special treatment for conical surfaces occ::handle theSurf = S; if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { theSurf = occ::down_cast(S)->BasisSurface(); + } if (theSurf->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) { occ::handle ConicalS = occ::down_cast(theSurf); @@ -3244,10 +3562,14 @@ bool BRepOffset_Tool::EnLargeFace(const TopoDS_Face& F, { // consider that VF1 and VF2 are on the same side from apex double TolApex = 1.e-5; - if (Vapex - VF1 >= TolApex || Vapex - VF2 >= TolApex) // if (VF1 < Vapex || VF2 < Vapex) + if (Vapex - VF1 >= TolApex || Vapex - VF2 >= TolApex) + { // if (VF1 < Vapex || VF2 < Vapex) VV2 = Vapex; + } else + { VV1 = Vapex; + } } } @@ -3257,17 +3579,25 @@ bool BRepOffset_Tool::EnLargeFace(const TopoDS_Face& F, UU2 = UF2; } if (!theEnlargeVfirst) + { VV1 = VF1; + } if (!theEnlargeVlast) + { VV2 = VF2; + } // Detect closedness in U and V directions bool uclosed = false, vclosed = false; BRepTools::DetectClosedness(F, uclosed, vclosed); if (uclosed && !uperiodic && (theLenBeforeUfirst != 0. || theLenAfterUlast != 0.)) + { uclosed = false; + } if (vclosed && !vperiodic && (theLenBeforeVfirst != 0. && theLenAfterVlast != 0.)) + { vclosed = false; + } MakeFace(S, UU1, UU2, VV1, VV2, uclosed, vclosed, isVV1degen, isVV2degen, BF); BF.Location(L); @@ -3525,17 +3855,23 @@ void BRepOffset_Tool::ExtentFace( // BRep_Tool::CurveOnSurface(TopoDS::Edge(CE.Reversed()),F,f,l); B.UpdateEdge(CE, C2, C2R, EF, BRep_Tool::Tolerance(CE)); if (!Ecs.IsNull()) + { B.UpdateEdge(Ecs, C2, C2R, EF, BRep_Tool::Tolerance(CE)); + } } else { B.UpdateEdge(CE, C2, EF, BRep_Tool::Tolerance(CE)); if (!Ecs.IsNull()) + { B.UpdateEdge(Ecs, C2, EF, BRep_Tool::Tolerance(CE)); + } } B.Range(CE, f, l); if (!Ecs.IsNull()) + { B.Range(Ecs, f, l); + } } } } @@ -3560,7 +3896,9 @@ void BRepOffset_Tool::ExtentFace( { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); if (ConstShapes.IsBound(E)) + { ToBuild.UnBind(E); + } if (ToBuild.IsBound(E)) { NCollection_List LOE; @@ -3573,7 +3911,9 @@ void BRepOffset_Tool::ExtentFace( Side, TolConf) && !LInt1.IsEmpty()) + { ToBuild.UnBind(E); + } } } @@ -3581,7 +3921,9 @@ void BRepOffset_Tool::ExtentFace( { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); if (ConstShapes.IsBound(E)) + { ToBuild.UnBind(E); + } if (ToBuild.IsBound(E)) { EnLargeFace(TopoDS::Face(ToBuild(E)), StopFace, false); @@ -3591,7 +3933,9 @@ void BRepOffset_Tool::ExtentFace( // its neighbour offsetted cylindrical face, if the offset is directed so that // the radius of the cylinder becomes smaller. if (LInt1.IsEmpty()) + { continue; + } if (LInt1.Extent() > 1) { // l intersection est en plusieurs edges (franchissement de couture) @@ -3643,7 +3987,9 @@ void BRepOffset_Tool::ExtentFace( if (Build.IsBound(NEOnV1) && (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV1))) { if (E.IsSame(NEOnV1)) + { V = TopExp::FirstVertex(TopoDS::Edge(Build(E))); + } else { //--------------- @@ -3680,7 +4026,9 @@ void BRepOffset_Tool::ExtentFace( { V.Orientation(TopAbs_FORWARD); if (Build(E).Orientation() == TopAbs_REVERSED) + { V.Orientation(TopAbs_REVERSED); + } ProjectVertexOnEdge(V, TopoDS::Edge(Build(E)), TolConf); } @@ -3694,12 +4042,18 @@ void BRepOffset_Tool::ExtentFace( //------------ V = V1; if (ConstShapes.IsBound(V1)) + { V = TopoDS::Vertex(ConstShapes(V1)); + } V.Orientation(TopAbs_FORWARD); if (Build(E).Orientation() == TopAbs_REVERSED) + { V.Orientation(TopAbs_REVERSED); + } if (!TryParameter(E, V, TopoDS::Edge(Build(E)), TolConf)) + { ProjectVertexOnEdge(V, TopoDS::Edge(Build(E)), TolConf); + } } ConstShapes.Bind(V1, V); @@ -3708,7 +4062,9 @@ void BRepOffset_Tool::ExtentFace( if (Build.IsBound(NEOnV2) && (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV2))) { if (E.IsSame(NEOnV2)) + { V = TopExp::LastVertex(TopoDS::Edge(Build(E))); + } else { //-------------- @@ -3746,7 +4102,9 @@ void BRepOffset_Tool::ExtentFace( { V.Orientation(TopAbs_REVERSED); if (Build(E).Orientation() == TopAbs_REVERSED) + { V.Orientation(TopAbs_FORWARD); + } ProjectVertexOnEdge(V, TopoDS::Edge(Build(E)), TolConf); } @@ -3760,12 +4118,18 @@ void BRepOffset_Tool::ExtentFace( //------------ V = V2; if (ConstShapes.IsBound(V2)) + { V = TopoDS::Vertex(ConstShapes(V2)); + } V.Orientation(TopAbs_REVERSED); if (Build(E).Orientation() == TopAbs_REVERSED) + { V.Orientation(TopAbs_FORWARD); + } if (!TryParameter(E, V, TopoDS::Edge(Build(E)), TolConf)) + { ProjectVertexOnEdge(V, TopoDS::Edge(Build(E)), TolConf); + } } ConstShapes.Bind(V2, V); Build.Bind(V2, V); @@ -3839,9 +4203,13 @@ void BRepOffset_Tool::ExtentFace( if (U1 > U2) { if (std::abs(U1 - l) < eps) + { U1 = f; + } if (std::abs(U2 - f) < eps) + { U2 = l; + } } TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD); B.Add(NE, TopoDS::Vertex(aLocalVertex)); @@ -3858,9 +4226,13 @@ void BRepOffset_Tool::ExtentFace( if (U2 > U1) { if (std::abs(U2 - l) < eps) + { U2 = f; + } if (std::abs(U1 - f) < eps) + { U1 = l; + } } TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD); B.Add(NE, TopoDS::Vertex(aLocalVertex)); @@ -3994,11 +4366,15 @@ TopoDS_Shape BRepOffset_Tool::Deboucle3D( } } if (!Boundary.Contains(anEdge) && !BRep_Tool::Degenerated(anEdge)) + { JeGarde = false; + } } } if (JeGarde) + { SS = S; + } } break; @@ -4114,7 +4490,9 @@ void BRepOffset_Tool::CorrectOrientation( if (Offset > 0) { if (IsInOut(FC, AC, TopAbs_OUT)) + { OE.Reverse(); + } } // else { // if (IsInOut(FC,AC,TopAbs_IN)) OE.Reverse(); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_DraftAngle.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_DraftAngle.cxx index 3d0d3d221f..feba2408c4 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_DraftAngle.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_DraftAngle.cxx @@ -95,7 +95,9 @@ void BRepOffsetAPI_DraftAngle::Add(const TopoDS_Face& F, { // POP-DPF : protection if (std::abs(Angle) <= 1.e-04) + { return; + } Standard_NullObject_Raise_if(myInitialShape.IsNull(), "BRepOffsetAPI_DraftAngle::Add() - initial shape is not set"); occ::down_cast(myModification)->Add(F, D, Angle, Plane, Flag); @@ -288,7 +290,9 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() NCollection_Map emap; eit.Initialize(CurWire); for (; eit.More(); eit.Next()) + { emap.Add(eit.Value()); + } NCollection_Map::Iterator mapit(emap); for (; mapit.More(); mapit.Next()) { @@ -361,7 +365,9 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() // Wadd = true; if (!WFmap.IsBound(aWire)) + { WFmap.Bind(aWire, CurFace); + } int ind = 0; for (j = 1; j <= NonSeam.Length(); j++) { @@ -508,8 +514,12 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() TopoDS_Edge SeamEdge = TopoDS::Edge(Seam(i)(1)); // Find the face for (j = 1; j <= Eseq.Length(); j++) + { if (SeamEdge.IsSame(Eseq(j))) + { break; + } + } TopoDS_Face theFace = TopoDS::Face(Fseq(j)); TopLoc_Location L; occ::handle theSurf = BRep_Tool::Surface(theFace, L); @@ -682,9 +692,13 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() firstind = 2; fpar = Seq(1); if (Seq.Length() > 2) + { lpar = Seq(2); + } else + { onepoint = true; + } } } if (!onepoint) @@ -744,7 +758,9 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() fpar = Seq(i); lpar = LastPar; if (std::abs(fpar - lpar) <= Precision::Confusion()) + { continue; + } TopoDS_Shape aLocalShape = anEdge.EmptyCopied(); NewE = TopoDS::Edge(aLocalShape); // NewE = TopoDS::Edge( anEdge.EmptyCopied() ); @@ -781,7 +797,9 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() { TopoDS_Edge CurE = TopoDS::Edge(eit.Value()); if (CurE.IsSame(E)) + { continue; + } TopoDS_Vertex Vfirst, Vlast; TopExp::Vertices(CurE, Vfirst, Vlast); if (Vfirst.IsSame(V) || Vlast.IsSame(V)) @@ -802,7 +820,9 @@ void BRepOffsetAPI_DraftAngle::CorrectWires() { const NCollection_List& listSh = aSub.Copy(myShape); if (!listSh.IsEmpty()) + { myShape = listSh.First(); + } } // Reconstruction of wires @@ -913,11 +933,15 @@ void BRepOffsetAPI_DraftAngle::CorrectVertexTol() const TopoDS_Shape& anE = anExp.Current(); // Skip old (not modified) edges if (anInitEdges.Contains(anE)) + { continue; + } // // Skip processed edges if (aNewEdges.Contains(anE)) + { continue; + } // aNewEdges.Add(anE); // diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeDraft.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeDraft.cxx index 4f54343052..dd05e37465 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeDraft.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeDraft.cxx @@ -32,7 +32,9 @@ void BRepOffsetAPI_MakeDraft::SetOptions(const BRepBuilderAPI_TransitionMode Sty { BRepFill_TransitionStyle style = BRepFill_Right; if (Style == BRepBuilderAPI_RoundCorner) + { style = BRepFill_Round; + } myDraft.SetOptions(style, AngleMin, AngleMax); } diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeEvolved.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeEvolved.cxx index 6034c008b6..65e83dbfbb 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeEvolved.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeEvolved.cxx @@ -72,7 +72,9 @@ BRepOffsetAPI_MakeEvolved::BRepOffsetAPI_MakeEvolved(const TopoDS_Shape& Spin bool POS; BRepFill::Axe(Spine, Profil, Axis, POS, std::max(Tol, Precision::Confusion())); if (ProfOnSpine && !POS) + { return; + } } if (Spine.ShapeType() == TopAbs_WIRE) { @@ -139,7 +141,9 @@ const NCollection_List& BRepOffsetAPI_MakeEvolved::GeneratedShapes const TopoDS_Shape& ProfShape) const { if (!myEvolved.IsDone()) + { return anEmptyList; + } return myEvolved.GeneratedShapes(SpineShape, ProfShape); } diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx index ce902ca43c..1a94f8d6c6 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx @@ -52,7 +52,9 @@ static bool NeedsConvertion(const TopoDS_Wire& theWire) BRepAdaptor_Curve aBAcurve(anEdge); GeomAbs_CurveType aType = aBAcurve.GetType(); if (aType != GeomAbs_Line && aType != GeomAbs_Circle) + { return true; + } } return false; @@ -184,7 +186,9 @@ static void BuildDomains(TopoDS_Face& myFace, { myFace = BRepBuilderAPI_MakeFace(TopoDS::Wire(WorkWires.First()), true); if (myFace.IsNull()) + { throw StdFail_NotDone("BRepOffsetAPI_MakeOffset : the wire is not planar"); + } } // Modified by Sergey KHROMOV - Thu Apr 26 16:04:43 2001 Begin TopExp_Explorer anExp(myFace, TopAbs_WIRE); @@ -376,7 +380,9 @@ void BRepOffsetAPI_MakeOffset::Perform(const double Offset, const double Alt) myWires.Clear(); TopoDS_Iterator anIter(myFace); for (; anIter.More(); anIter.Next()) + { myWires.Append(anIter.Value()); + } } } @@ -404,7 +410,9 @@ void BRepOffsetAPI_MakeOffset::Perform(const double Offset, const double Alt) { B.Add(Res, isWasReversed ? Algo.Shape().Reversed() : Algo.Shape()); if (i == 1) + { myShape = isWasReversed ? Algo.Shape().Reversed() : Algo.Shape(); + } i++; } @@ -429,7 +437,9 @@ void BRepOffsetAPI_MakeOffset::Perform(const double Offset, const double Alt) B.Add(Res, isWasReversed ? Algo.Shape().Reversed() : Algo.Shape()); if (i == 1) + { myShape = isWasReversed ? Algo.Shape().Reversed() : Algo.Shape(); + } i++; } @@ -437,12 +447,18 @@ void BRepOffsetAPI_MakeOffset::Perform(const double Offset, const double Alt) } if (i > 2) + { myShape = Res; + } if (myShape.IsNull()) + { NotDone(); + } else + { Done(); + } } catch (Standard_Failure const& anException) { diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffsetShape.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffsetShape.cxx index 942c24e2b1..6ebf04f959 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffsetShape.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeOffsetShape.cxx @@ -44,7 +44,9 @@ void BRepOffsetAPI_MakeOffsetShape::PerformByJoin(const TopoDS_Shape& S myOffsetShape.MakeOffsetShape(theRange); if (!myOffsetShape.IsDone()) + { return; + } myShape = myOffsetShape.Shape(); Done(); @@ -62,7 +64,9 @@ void BRepOffsetAPI_MakeOffsetShape::PerformBySimple(const TopoDS_Shape& theS, mySimpleOffsetShape.Perform(); if (!mySimpleOffsetShape.IsDone()) + { return; + } myShape = mySimpleOffsetShape.GetResultShape(); Done(); @@ -93,7 +97,9 @@ const NCollection_List& BRepOffsetAPI_MakeOffsetShape::Generated( { TopoDS_Shape aGenShape = mySimpleOffsetShape.Generated(S); if (!aGenShape.IsNull() && !aGenShape.IsSame(S)) + { myGenerated.Append(aGenShape); + } } return myGenerated; @@ -112,7 +118,9 @@ const NCollection_List& BRepOffsetAPI_MakeOffsetShape::Modified(co { TopoDS_Shape aGenShape = mySimpleOffsetShape.Modified(S); if (!aGenShape.IsNull() && !aGenShape.IsSame(S)) + { myGenerated.Append(aGenShape); + } } return myGenerated; diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cxx index a21aabd060..e356bf1e51 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cxx @@ -72,9 +72,13 @@ void BRepOffsetAPI_MakePipe::Build(const Message_ProgressRange& /*theRange*/) NCollection_IndexedMap theMap; TopExp::MapShapes(myShape, theMap); if (theMap.Extent() == 1) + { NotDone(); + } else + { Done(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.cxx index bae84c9388..8a4411de6d 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.cxx @@ -215,7 +215,9 @@ void BRepOffsetAPI_MakePipeShell::Build(const Message_ProgressRange& /*theRange* Done(); } else + { NotDone(); + } } //================================================================================================= @@ -223,11 +225,15 @@ void BRepOffsetAPI_MakePipeShell::Build(const Message_ProgressRange& /*theRange* bool BRepOffsetAPI_MakePipeShell::MakeSolid() { if (!IsDone()) + { throw StdFail_NotDone("BRepOffsetAPI_MakePipeShell::MakeSolid"); + } bool Ok; Ok = myPipe->MakeSolid(); if (Ok) + { myShape = myPipe->Shape(); + } return Ok; } diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeThickSolid.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeThickSolid.cxx index 3c4f23fdff..a5162399fb 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeThickSolid.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MakeThickSolid.cxx @@ -47,11 +47,15 @@ void BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin( .Initialize(S, Offset, Tol, Mode, Intersection, SelfInter, Join, false, RemoveIntEdges); NCollection_List::Iterator it(ClosingFaces); for (; it.More(); it.Next()) + { myOffsetShape.AddFace(TopoDS::Face(it.Value())); + } myOffsetShape.MakeThickSolid(theRange); if (!myOffsetShape.IsDone()) + { return; + } myShape = myOffsetShape.Shape(); Done(); @@ -69,7 +73,9 @@ void BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple(const TopoDS_Shape& th mySimpleOffsetShape.Perform(); if (!mySimpleOffsetShape.IsDone()) + { return; + } myShape = mySimpleOffsetShape.GetResultShape(); Done(); @@ -95,14 +101,18 @@ const NCollection_List& BRepOffsetAPI_MakeThickSolid::Modified(con // Useful only for faces without influence on others. NCollection_List::Iterator it(myGenerated); for (; it.More(); it.Next()) + { it.ChangeValue().Reverse(); + } } } else if (myLastUsedAlgo == OffsetAlgo_SIMPLE) { TopoDS_Shape aModShape = mySimpleOffsetShape.Modified(F); if (!aModShape.IsNull()) + { myGenerated.Append(aModShape); + } } return myGenerated; diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx index bd7a70b10b..5debda949b 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx @@ -62,7 +62,9 @@ static bool IsLinear(const TopoDS_Edge& anEdge, gp_Lin& aLine) double fpar, lpar; occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { aCurve = occ::down_cast(aCurve)->BasisCurve(); + } gp_Pnt Pnt1, Pnt2; if (aCurve->IsKind(STANDARD_TYPE(Geom_Line))) @@ -100,7 +102,9 @@ static GeomAbs_CurveType TypeOfEdge(const TopoDS_Edge& anEdge) { gp_Lin aLin; if (IsLinear(anEdge, aLin)) + { return GeomAbs_Line; + } BRepAdaptor_Curve BAcurve(anEdge); return BAcurve.GetType(); @@ -115,15 +119,21 @@ static gp_Vec TangentOfEdge(const TopoDS_Shape& aShape, const bool OnFirst) occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); double thePar; if (OnFirst) + { thePar = (anOr == TopAbs_FORWARD) ? fpar : lpar; + } else + { thePar = (anOr == TopAbs_FORWARD) ? lpar : fpar; + } gp_Pnt thePoint; gp_Vec theTangent; aCurve->D1(thePar, thePoint, theTangent); if (anOr == TopAbs_REVERSED) + { theTangent.Reverse(); + } return theTangent; } @@ -147,11 +157,15 @@ static bool IsValidEdge(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace) { BRepExtrema_SupportType theType = DistMini.SupportTypeShape2(i); if (theType == BRepExtrema_IsOnEdge) + { return false; + } // theType is "IsVertex" TopoDS_Shape aVertex = DistMini.SupportOnShape2(i); if (!(aVertex.IsSame(V1) || aVertex.IsSame(V2))) + { return false; + } } } } @@ -264,7 +278,9 @@ static TopoDS_Wire GetUnifiedWire(const TopoDS_Wire& theWire, const TopoDS_Shape& aShape = anIt.Value(); // wire shouldn't contain duplicated generated edges if (aGeneratedEdges.Add(aShape)) + { aWMaker.Add(TopoDS::Edge(aShape)); + } } } else @@ -293,7 +309,9 @@ BRepOffsetAPI_MiddlePath::BRepOffsetAPI_MiddlePath(const TopoDS_Shape& aShape, aStartWire = BRepTools::OuterWire(StartFace); } else + { aStartWire = TopoDS::Wire(StartShape); + } if (EndShape.ShapeType() == TopAbs_FACE) { @@ -301,7 +319,9 @@ BRepOffsetAPI_MiddlePath::BRepOffsetAPI_MiddlePath(const TopoDS_Shape& aShape, anEndWire = BRepTools::OuterWire(EndFace); } else + { anEndWire = TopoDS::Wire(EndShape); + } myStartWire = GetUnifiedWire(aStartWire, Unifier); myEndWire = GetUnifiedWire(anEndWire, Unifier); @@ -329,7 +349,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) EdgeSeq.Append(wexp.Current()); } if (!myClosedSection) + { StartVertices.Append(wexp.CurrentVertex()); + } SectionsEdges.Append(EdgeSeq); for (wexp.Init(myEndWire); wexp.More(); wexp.Next()) @@ -338,13 +360,19 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) EndEdges.Add(wexp.Current()); } if (!myClosedSection) + { EndVertices.Add(wexp.CurrentVertex()); + } TopoDS_Iterator itw(myStartWire); for (; itw.More(); itw.Next()) + { myStartWireEdges.Add(itw.Value()); + } for (itw.Initialize(myEndWire); itw.More(); itw.Next()) + { myEndWireEdges.Add(itw.Value()); + } NCollection_IndexedDataMap, TopTools_ShapeMapHasher> VEmap; @@ -370,7 +398,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) { TopExp::Vertices(anEdge, V1, V2, true); if (V1.IsSame(StartVertices(i))) + { CurVertices.Add(V2); + } else { anEdge.Reverse(); @@ -381,9 +411,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } } if (!Edges.IsEmpty()) + { myPaths.Append(Edges); + } else + { return; + } } // Filling of "myPaths" @@ -407,29 +441,39 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } if (EndVertices.Contains(theVertex)) + { continue; + } const NCollection_List& LE = VEmap.FindFromKey(theVertex); NCollection_Map NextEdgeCandidates; for (itl.Initialize(LE); itl.More(); itl.Next()) { anEdge = TopoDS::Edge(itl.Value()); if (anEdge.IsSame(theEdge)) + { continue; + } TopExp::Vertices(anEdge, V1, V2, true); if (V1.IsSame(theVertex)) + { NextVertex = V2; + } else { anEdge.Reverse(); NextVertex = V1; } if (!CurVertices.Contains(NextVertex)) + { NextEdgeCandidates.Add(anEdge); + } } if (!NextEdgeCandidates.IsEmpty()) { if (NextEdgeCandidates.Extent() > 1) + { myPaths(i).Append(theVertex); // punctual segment of path + } else { NCollection_Map::Iterator mapit( @@ -442,9 +486,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } } if (NextVertices.IsEmpty()) + { break; + } for (itl.Initialize(NextVertices); itl.More(); itl.Next()) + { CurVertices.Add(itl.Value()); + } NextVertices.Clear(); } @@ -476,19 +524,25 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) int NbPaths = myPaths.Length(); int NbVer = myPaths.Length(); if (myClosedSection) + { NbVer++; + } i = 1; for (;;) { for (j = 1; j <= EdgeSeq.Length(); j++) + { EdgeSeq(j).Nullify(); + } bool ToInsertVertex = false; for (j = 2; j <= NbVer; j++) { if (!EdgeSeq(j - 1).IsNull()) + { continue; + } // for the end of initial shape if (myPaths(j - 1).Length() < i) @@ -524,9 +578,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) TopoDS_Edge E1, E2; if (myPaths(j - 1)(i).ShapeType() == TopAbs_EDGE) + { E1 = TopoDS::Edge(myPaths(j - 1)(i)); + } if (myPaths((j <= NbPaths) ? j : 1)(i).ShapeType() == TopAbs_EDGE) + { E2 = TopoDS::Edge(myPaths((j <= NbPaths) ? j : 1)(i)); + } TopoDS_Edge E12 = TopoDS::Edge(SectionsEdges(i)(j - 1)); // Find the face on which (E1 or E2) and E12 lie TopoDS_Shape E1orE2 = (E1.IsNull()) ? E2 : E1; @@ -552,7 +610,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } } if (!theFace.IsNull()) + { break; + } } TopoDS_Vertex PrevVertex = @@ -600,9 +660,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) if (E1.IsNull() || E2.IsNull()) { if (E1.IsNull()) + { E1 = TopoDS::Edge(myPaths(j - 1)(i - 1)); + } if (E2.IsNull()) + { E2 = TopoDS::Edge(myPaths((j <= NbPaths) ? j : 1)(i - 1)); + } double fpar1, lpar1, fpar2, lpar2; double LastPar1, LastPar2; occ::handle PCurve1 = BRep_Tool::CurveOnSurface(E1, theFace, fpar1, lpar1); @@ -694,16 +758,24 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) if (type_E1 == type_E2) //! good_ne { if (good_ne1) + { ChooseEdge = 1; + } else + { ChooseEdge = 2; + } } else // types are different { if (type_E1 == GeomAbs_Line) + { ChooseEdge = 1; + } else if (type_E2 == GeomAbs_Line) + { ChooseEdge = 2; + } else // to be developed later... { } @@ -720,7 +792,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) EdgeSeq(j - 1) = NewEdge1; EFmap.Add(NewEdge1, ListOneFace); for (k = 1; k < j - 1; k++) + { EdgeSeq(k).Nullify(); + } for (k = 1; k <= j - 1; k++) { TopoDS_Edge aLastEdge = TopoDS::Edge(myPaths(k)(i)); @@ -756,10 +830,16 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) // check for exit from for(;;) int NbEndEdges = 0; for (j = 1; j <= EdgeSeq.Length(); j++) + { if (EndEdges.Contains(EdgeSeq(j))) + { NbEndEdges++; + } + } if (NbEndEdges == NbE) + { break; + } i++; } // for (;;) @@ -784,9 +864,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) TopoDS_Wire aWire = MW.Wire(); BRepLib_MakeFace MF(aWire, true); // Only plane if (MF.IsDone()) + { SecFaces(i) = MF.Face(); + } else + { SecFaces(i) = aWire; + } } NCollection_Array1 Centers(1, NbSecFaces); @@ -794,9 +878,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) { GProp_GProps Properties; if (SecFaces(i).ShapeType() == TopAbs_FACE) + { BRepGProp::SurfaceProperties(SecFaces(i), Properties); - else // wire + } + else + { // wire BRepGProp::LinearProperties(SecFaces(i), Properties); + } Centers(i) = Properties.CentreOfMass(); } @@ -819,7 +907,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) anEdge = TopoDS::Edge(aShape); GeomAbs_CurveType aType = TypeOfEdge(anEdge); if (j == 1) + { TypeOfMidEdge = aType; + } else { if (aType != TypeOfMidEdge) @@ -830,7 +920,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } } if (TypeOfMidEdge == GeomAbs_Line) + { MidEdges(i) = BRepLib_MakeEdge(Centers(i), Centers(i + 1)); + } else if (TypeOfMidEdge == GeomAbs_Circle) { gp_Ax1 theAxis; @@ -844,7 +936,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) double fpar, lpar; occ::handle aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) + { aCurve = occ::down_cast(aCurve)->BasisCurve(); + } Pnt1 = aCurve->Value(fpar); Pnt2 = aCurve->Value(lpar); occ::handle aCircle = occ::down_cast(aCurve); @@ -858,7 +952,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) double theParam = (anEdge.Orientation() == TopAbs_FORWARD) ? fpar : lpar; aCurve->D1(theParam, Pnt1, theTangent); if (anEdge.Orientation() == TopAbs_REVERSED) + { theTangent.Reverse(); + } } else { @@ -896,9 +992,13 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) double anAngle = Vec1.AngleWithRef(Vec2, theAxis.Direction()); if (anAngle < 0.) + { anAngle += 2. * M_PI; + } if (std::abs(anAngle - theAngle) > AngTol) + { theAxis.Reverse(); + } gp_Ax2 theAx2(theCenterOfCirc, theAxis.Direction(), Vec1); occ::handle theCircle = GC_MakeCircle(theAx2, Vec1.Magnitude()); gp_Vec aTangent; @@ -925,7 +1025,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) for (j = i + 1; j < NbSecFaces; j++) { if (!MidEdges(j).IsNull()) + { break; + } } // from i to j-1 all edges are null occ::handle> thePoints = @@ -933,7 +1035,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) NCollection_Array1 theTangents(1, j - i + 1); occ::handle> theFlags = new NCollection_HArray1(1, j - i + 1); for (k = i; k <= j; k++) + { thePoints->SetValue(k - i + 1, Centers(k)); + } for (k = i; k <= j; k++) { NCollection_Sequence PntSeq; @@ -943,20 +1047,26 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) if (k == i) { if (myPaths(indp)(k).ShapeType() == TopAbs_VERTEX) + { continue; + } aTangent = TangentOfEdge(myPaths(indp)(k), true); // at begin } else if (k == j) { if (myPaths(indp)(k - 1).ShapeType() == TopAbs_VERTEX) + { continue; + } aTangent = TangentOfEdge(myPaths(indp)(k - 1), false); // at end } else { if (myPaths(indp)(k - 1).ShapeType() == TopAbs_VERTEX || myPaths(indp)(k).ShapeType() == TopAbs_VERTEX) + { continue; + } gp_Vec Tangent1 = TangentOfEdge(myPaths(indp)(k - 1), false); // at end gp_Vec Tangent2 = TangentOfEdge(myPaths(indp)(k), true); // at begin aTangent = Tangent1 + Tangent2; @@ -967,7 +1077,9 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) } NCollection_Array1 PntArray(1, PntSeq.Length()); for (int ip = 1; ip <= PntSeq.Length(); ip++) + { PntArray(ip) = PntSeq(ip); + } gp_Pnt theBary; gp_Dir xdir, ydir; double xgap, ygap, zgap; @@ -982,7 +1094,7 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) Interpol.Perform(); if (!Interpol.IsDone()) { - std::cout << std::endl << "Interpolation failed" << std::endl; + std::cout << '\n' << "Interpolation failed" << '\n'; } occ::handle InterCurve(Interpol.Curve()); MidEdges(i) = BRepLib_MakeEdge(InterCurve); @@ -992,8 +1104,12 @@ void BRepOffsetAPI_MiddlePath::Build(const Message_ProgressRange& /*theRange*/) BRepLib_MakeWire MakeFinalWire; for (i = 1; i < NbSecFaces; i++) + { if (!MidEdges(i).IsNull()) + { MakeFinalWire.Add(TopoDS::Edge(MidEdges(i))); + } + } TopoDS_Wire FinalWire = MakeFinalWire.Wire(); myShape = MakeFinalWire.Wire(); diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx index 937b16beca..6e60f68e9f 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx @@ -124,10 +124,14 @@ static bool PerformPlan(const TopoDS_Wire& W, const double presPln, TopoDS_Face& { const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value()); if (!BRep_Tool::Degenerated(anEdge)) + { isDegen = false; + } } if (isDegen) + { return true; + } bool Ok = false; if (!W.IsNull()) @@ -173,7 +177,9 @@ static bool IsSameOriented(const TopoDS_Shape& aFace, const TopoDS_Shape& aShell { theEdge = Explo.Current(); if (theEdge.IsSame(anEdge)) + { break; + } } TopAbs_Orientation Or2 = theEdge.Orientation(); @@ -190,7 +196,9 @@ static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, TopoDS_Face& face2) { if (shell.IsNull()) + { throw StdFail_NotDone("Thrusections is not build"); + } bool B = shell.Closed(); BRep_Builder BB; @@ -204,14 +212,22 @@ static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, if (B) { if (!face1.IsNull() && !IsSameOriented(face1, shell)) + { face1.Reverse(); + } if (!face2.IsNull() && !IsSameOriented(face2, shell)) + { face2.Reverse(); + } if (!face1.IsNull()) + { BB.Add(shell, face1); + } if (!face2.IsNull()) + { BB.Add(shell, face2); + } shell.Closed(true); } @@ -386,7 +402,9 @@ void BRepOffsetAPI_ThruSections::Build(const Message_ProgressRange& /*theRange*/ // we save its splits int IndFirstSec = 1; if (Georges.IsDegeneratedFirstSection()) + { IndFirstSec = 2; + } TopoDS_Wire aWorkingSection = TopoDS::Wire(WorkingSections(IndFirstSec)); myNbEdgesInSection += aWorkingSection.NbChildren(); for (int ii = 1; ii <= myWires.Length(); ii++) @@ -425,9 +443,13 @@ void BRepOffsetAPI_ThruSections::Build(const Message_ProgressRange& /*theRange*/ TopoDS_Vertex NewVfirst, NewVlast; TopExp::Vertices(aNewEdge, NewVfirst, NewVlast); if (NewVfirst.IsSame(Vfirst) && !myVertexIndex.IsBound(Vfirst)) + { myVertexIndex.Bind(Vfirst, aSign * inde); + } if (NewVlast.IsSame(Vlast) && !myVertexIndex.IsBound(Vlast)) + { myVertexIndex.Bind(Vlast, aSign * (-inde)); + } } } myEdgeNewIndices.Bind(anEdge, IList); @@ -459,19 +481,29 @@ void BRepOffsetAPI_ThruSections::Build(const Message_ProgressRange& /*theRange*/ TopoDS_Vertex V1, V2; TopExp::Vertices(anEdge, V1, V2); if (!myVertexIndex.IsBound(V1)) + { myVertexIndex.Bind(V1, inde); + } if (!myVertexIndex.IsBound(V2)) + { myVertexIndex.Bind(V2, -inde); + } } inde--; if (inde > myNbEdgesInSection) + { myNbEdgesInSection = inde; + } if (inde == 1 && BRep_Tool::Degenerated(anEdge)) { if (ii == 1) + { myDegen1 = true; + } else + { myDegen2 = true; + } } } } @@ -648,15 +680,23 @@ void BRepOffsetAPI_ThruSections::CreateRuled() } if (!degen1) + { anExp1.Next(); + } if (!degen2) + { anExp2.Next(); + } tantque = anExp1.More() && anExp2.More(); if (degen1) + { tantque = anExp2.More(); + } if (degen2) + { tantque = anExp1.More(); + } } } } @@ -686,7 +726,9 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed() bool vClosed = false; // check if the first wire is the same as last if (myWires(1).IsSame(myWires(myWires.Length()))) + { vClosed = true; + } // find the dimension int nbEdges = 0; @@ -719,7 +761,9 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed() TopoDS_Vertex V1, V2; TopExp::Vertices(wire, V1, V2); if (!V1.IsSame(V2)) + { uClosed = false; + } } if ((i == 1 && w1Point) || (i == nbSects && w2Point)) { @@ -793,13 +837,17 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed() edge = TopoDS::Edge(shapes(i)); TopExp::Vertices(edge, v1f, v1l); if (edge.Orientation() == TopAbs_REVERSED) + { TopExp::Vertices(edge, v1l, v1f); + } firstEdge = edge; edge = TopoDS::Edge(shapes((nbSects - 1) * nbEdges + i)); TopExp::Vertices(edge, v2f, v2l); if (edge.Orientation() == TopAbs_REVERSED) + { TopExp::Vertices(edge, v2l, v2f); + } // make the face B.MakeFace(face, surface, Precision::Confusion()); @@ -832,11 +880,15 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed() // processing of looping sections // store edges of the 1st section if (vClosed) + { vcouture(i) = edge1; + } // --- edge 2 if (vClosed) + { edge2 = TopoDS::Edge(vcouture(i)); + } else { if (w2Point) @@ -961,7 +1013,9 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed() } if (uClosed && w1Point && w2Point) + { shell.Closed(true); + } if (myIsSolid) { @@ -1112,16 +1166,22 @@ static occ::handle EdgeToBSpline(const TopoDS_Edge& theEdge) const occ::handle& aCurveTrimmed = aTrimCurve; // to avoid ambiguity GeomConvert_ApproxCurve anAppr(aCurveTrimmed, Precision::Confusion(), GeomAbs_C1, 16, 14); if (anAppr.HasResult()) + { aBSCurve = anAppr.Curve(); + } } // general case if (aBSCurve.IsNull()) + { aBSCurve = GeomConvert::CurveToBSplineCurve(aTrimCurve); + } // apply transformation if needed if (!aLoc.IsIdentity()) + { aBSCurve->Transform(aLoc.Transformation()); + } // reparameterize to [0,1] NCollection_Array1 aKnots(aBSCurve->Knots()); @@ -1131,7 +1191,9 @@ static occ::handle EdgeToBSpline(const TopoDS_Edge& theEdge) // reverse curve if edge is reversed if (theEdge.Orientation() == TopAbs_REVERSED) + { aBSCurve->Reverse(); + } return aBSCurve; } @@ -1252,7 +1314,9 @@ occ::handle BRepOffsetAPI_ThruSections::TotalSurf( int nbIt = 3; if (myPres3d <= 1.e-3) + { nbIt = 0; + } int degmin = 2, degmax = std::max(myDegMax, degmin); bool SpApprox = true; @@ -1309,12 +1373,16 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons NCollection_Sequence AllFaces; TopExp_Explorer Explo(myShape, TopAbs_FACE); for (; Explo.More(); Explo.Next()) + { AllFaces.Append(Explo.Current()); + } if (S.ShapeType() == TopAbs_EDGE) { if (!myEdgeNewIndices.IsBound(S)) + { return myGenerated; + } const NCollection_List& Indices = myEdgeNewIndices(S); // Append the faces corresponding to @@ -1331,8 +1399,10 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons } if (myIsRuled) + { // Append the next faces corresponding to for (int i = 2; i < myWires.Length(); i++) + { for (itl.Initialize(Indices); itl.More(); itl.Next()) { int IndOfFace = itl.Value(); @@ -1343,11 +1413,15 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons } myGenerated.Append(AllFaces(IndOfFace)); } + } + } } else if (S.ShapeType() == TopAbs_VERTEX) { if (!myVertexIndex.IsBound(S)) + { return myGenerated; + } NCollection_IndexedDataMap, @@ -1363,9 +1437,13 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons for (int i = 0; i < 2; i++) { if (i == 0 && !myDegen1) + { continue; + } if (i == 1 && !myDegen2) + { continue; + } Explo.Init(EndSections[i], TopAbs_VERTEX); const TopoDS_Shape& aVertex = Explo.Current(); @@ -1434,7 +1512,9 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons { NextEdge = TopoDS::Edge(aListIterator.Value()); if (!NextEdge.IsSame(anEdge) && !EmapOfSection.Contains(NextEdge)) + { break; + } } myGenerated.Append(NextEdge); anEdge = NextEdge; @@ -1494,16 +1574,24 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons if (Vindex == 0) { if (VV[0].IsSame(FirstVertexOfFirstEdge)) + { FirstVertex = VV[0]; + } else + { FirstVertex = VV[1]; + } } else // Vindex == 1 { if (VV[0].IsSame(FirstVertexOfFirstEdge)) + { FirstVertex = VV[1]; + } else + { FirstVertex = VV[0]; + } } const NCollection_List& Elist = VEmap.FindFromKey(FirstVertex); NCollection_List::Iterator itl(Elist); @@ -1513,11 +1601,14 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons anEdge = TopoDS::Edge(itl.Value()); if (!anEdge.IsSame(FirstEdgeInFace) && !BRep_Tool::Degenerated(anEdge) && anEdge.Orientation() == anEdgeOr) + { break; + } } } myGenerated.Append(anEdge); if (myIsRuled) + { // Find the chain of longitudinal edges from first to last for (int i = 2; i < myWires.Length(); i++) { @@ -1535,6 +1626,7 @@ const NCollection_List& BRepOffsetAPI_ThruSections::Generated(cons : TopoDS::Edge(Elist2.First()); myGenerated.Append(anEdge); } + } } return myGenerated; diff --git a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_Blend.cxx b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_Blend.cxx index 43f6630962..d05e4f0eaa 100644 --- a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_Blend.cxx +++ b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_Blend.cxx @@ -163,7 +163,9 @@ static void Add(const TopoDS_Edge& E // It is checked that the border is not free. const NCollection_List& L = Analyse.Ancestors(OriE); if (L.Extent() == 1) + { break; // Nothing is done. + } } Map.Add(exp.Current()); break; @@ -198,8 +200,12 @@ static bool IsInFace(const TopoDS_Edge& E, const TopoDS_Face& F) { TopExp_Explorer exp(F, TopAbs_EDGE); for (; exp.More(); exp.Next()) + { if (E.IsSame(exp.Current())) + { return true; + } + } return false; } @@ -246,7 +252,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol); } } @@ -261,7 +269,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol); } else if (STy == GeomAbs_Cone) @@ -275,7 +285,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol); } else if (STy == GeomAbs_Torus) @@ -289,7 +301,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, Ci.Rotate(AxeRev, P.X()); occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DX2d(), Precision::Angular())) + { Circle->Reverse(); + } TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol); } } @@ -315,7 +329,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, occ::handle Circle = new Geom_Circle(Ci); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Circle->Reverse(); + } TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol); } else if (STy == GeomAbs_Cylinder) @@ -328,7 +344,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, L.Translate(Tr); occ::handle Line = new Geom_Line(L); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Line->Reverse(); + } TheBuilder.UpdateEdge(Edge, Line, Loc, Tol); } else if (STy == GeomAbs_Cone) @@ -341,7 +359,9 @@ static void KPartCurve3d(const TopoDS_Edge& Edge, L.Translate(Tr); occ::handle Line = new Geom_Line(L); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { Line->Reverse(); + } TheBuilder.UpdateEdge(Edge, Line, Loc, Tol); } else if (STy == GeomAbs_Torus) @@ -473,7 +493,6 @@ static void Touched(const BRepOffset_Analyse&, TouchedByCork.Add(L.First()); } }*/ - return; } //================================================================================================= @@ -503,7 +522,9 @@ static TopoDS_Vertex FindVertex(const gp_Pnt& gp_Pnt P1 = BRep_Tool::Pnt(VV[i]); Dist = P.SquareDistance(P1); if (Dist <= Tol2) + { return VV[i]; + } // otherwise with the required tolerance. if (TolCarre > Tol2) { @@ -578,7 +599,9 @@ static TopAbs_Orientation Orientation(const TopoDS_Edge& E, } } if (F.Orientation() == TopAbs_REVERSED) + { Orien = TopAbs::Reverse(Orien); + } return Orien; } @@ -596,7 +619,9 @@ static TopoDS_Edge FindCreatedEdge( { TopoDS_Edge E1; if (!CenterAnalyse.HasAncestor(V1)) + { return E1; // return a Null Shape. + } NCollection_List TangE; CenterAnalyse.TangentEdges(E, V1, TangE); @@ -627,14 +652,20 @@ static TopoDS_Edge FindCreatedEdge( } occ::handle Circ = occ::down_cast(CET); if (Circ.IsNull()) + { continue; + } if (std::abs(Circ->Radius() - std::abs(Radius)) > Tol) + { continue; + } TopoDS_Vertex U1, U2; TopExp::Vertices(ET, U1, U2); if (U1.IsSame(V1)) + { U1 = U2; + } NCollection_List Tang2; CenterAnalyse.TangentEdges(ET, U1, Tang2); NCollection_List::Iterator it2(Tang2); @@ -762,18 +793,24 @@ void BiTgte_Blend::Perform(const bool BuildShape) BRepLib::BuildCurves3d(myShape); TopExp_Explorer expf(myShape, TopAbs_FACE); for (; expf.More(); expf.Next()) + { Sew->Add(expf.Current()); + } Sew->Perform(); TopoDS_Shape SewedShape = Sew->SewedShape(); if (SewedShape.IsNull()) + { throw Standard_Failure("Sewing aux fraises"); + } // Check if the sewing modified the orientation. expf.Init(myShape, TopAbs_FACE); TopoDS_Face FaceRef = TopoDS::Face(expf.Current()); TopAbs_Orientation OriRef = FaceRef.Orientation(); if (Sew->IsModified(FaceRef)) + { FaceRef = TopoDS::Face(Sew->Modified(FaceRef)); + } expf.Init(SewedShape, TopAbs_FACE); for (; expf.More(); expf.Next()) { @@ -876,7 +913,9 @@ void BiTgte_Blend::Perform(const bool BuildShape) #endif if (myBuildShape) + { ComputeShape(); + } #ifdef OCCT_DEBUG ChFi3d_ResultChron(ch, t_shape); @@ -945,7 +984,9 @@ void BiTgte_Blend::CenterLines(NCollection_List& LC) const LC.Clear(); int Nb = NbSurfaces(); for (int i = 1; i <= Nb; i++) + { LC.Append(myCenters(i)); + } } //================================================================================================= @@ -1154,7 +1195,9 @@ occ::handle BiTgte_Blend::PCurve2OnFillet(const int /*Index*/) con int BiTgte_Blend::NbBranches() { if (myNbBranches != -1) + { return myNbBranches; + } // else, compute the Branches. BRepTools_Quilt Glue; @@ -1162,7 +1205,9 @@ int BiTgte_Blend::NbBranches() int NbFaces = myCenters.Extent(); if (NbFaces == 0) + { return 0; + } int i; for (i = 1; i <= NbFaces; i++) @@ -1256,7 +1301,9 @@ void BiTgte_Blend::ComputeCenters() // ----------------------- TopAbs_State Side = TopAbs_IN; if (myRadius < 0.) + { Side = TopAbs_OUT; + } BRepOffset_Inter3d Inter(myAsDes, Side, myTol); NCollection_DataMap MapSBox; @@ -1293,7 +1340,9 @@ void BiTgte_Blend::ComputeCenters() { const TopoDS_Edge& E = TopoDS::Edge(myEdges(i)); if (BRep_Tool::Degenerated(E)) + { continue; + } const NCollection_List& L = myAncestors.FindFromKey(E); if (L.Extent() == 1) @@ -1311,7 +1360,9 @@ void BiTgte_Blend::ComputeCenters() { const TopoDS_Shape& Sh = itl.Value(); if (!myStopFaces.Contains(Sh)) + { myFaces.Add(itl.Value()); + } } } } @@ -1325,7 +1376,9 @@ void BiTgte_Blend::ComputeCenters() { const TopoDS_Shape& AS = myFaces(i); if (myMapSF.IsBound(AS)) + { continue; + } BRepOffset_Offset OF1; TopoDS_Face BigF; @@ -1376,7 +1429,9 @@ void BiTgte_Blend::ComputeCenters() myAnalyse.Edges(V1, ChFiDS_Tangential, LE); const NCollection_List& LA = myAnalyse.Ancestors(V1); if (LE.Extent() == LA.Extent()) + { EdgeTgt.Bind(V1, OV1); + } } if (!EdgeTgt.IsBound(V2)) { @@ -1384,14 +1439,18 @@ void BiTgte_Blend::ComputeCenters() myAnalyse.Edges(V2, ChFiDS_Tangential, LE); const NCollection_List& LA = myAnalyse.Ancestors(V2); if (LE.Extent() == LA.Extent()) + { EdgeTgt.Bind(V2, OV2); + } } } } // end of map created tangent if (OF1.Status() == BRepOffset_Reversed || OF1.Status() == BRepOffset_Degenerated) + { continue; + } const TopoDS_Face& F1 = OF1.Face(); @@ -1409,7 +1468,9 @@ void BiTgte_Blend::ComputeCenters() Fini = !Intersect(AS, F1, MapSBox, OF1, Inter); if (AS.ShapeType() == TopAbs_FACE) + { B.Add(Co, AS); + } myMapSF.Bind(AS, OF1); } @@ -1423,7 +1484,9 @@ void BiTgte_Blend::ComputeCenters() //-------------------------------------------------------- ChFiDS_TypeOfConcavity OT = ChFiDS_Convex; if (myRadius < 0.) + { OT = ChFiDS_Concave; + } NCollection_IndexedDataMap, @@ -1437,7 +1500,9 @@ void BiTgte_Blend::ComputeCenters() { const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); if (myMapSF.IsBound(E)) + { continue; + } const NCollection_List& Anc = Map.FindFromKey(E); if (Anc.Extent() == 2) @@ -1522,7 +1587,9 @@ void BiTgte_Blend::ComputeCenters() aDMVV; ChFiDS_TypeOfConcavity OT = ChFiDS_Concave; if (myRadius < 0.) + { OT = ChFiDS_Convex; + } NCollection_List LOF; // it.Initialize(myFaces); @@ -1532,10 +1599,14 @@ void BiTgte_Blend::ComputeCenters() // tube on free border, it is undesirable. if (myStopFaces.Contains(CurS)) + { continue; + } if (!myMapSF.IsBound(CurS)) + { continue; // inverted or degenerated + } const TopoDS_Face& CurOF = myMapSF(CurS).Face(); LOF.Append(CurOF); @@ -1598,13 +1669,17 @@ void BiTgte_Blend::ComputeCenters() { const TopoDS_Shape& CurS = It.Key(); if (CurS.ShapeType() == TopAbs_FACE) + { continue; + } const TopoDS_Face& CurOF = It.Value().Face(); // no unwinding by tubes on free border. if (myStopFaces.Contains(CurS)) + { continue; + } LOF.Append(CurOF); @@ -1654,7 +1729,9 @@ void BiTgte_Blend::ComputeCenters() const TopoDS_Shape& CurLOF = itLOF.Value(); if (!myImageOffset.HasImage(CurLOF)) + { continue; + } NCollection_List Lim; myImageOffset.LastImage(CurLOF, Lim); @@ -1664,7 +1741,9 @@ void BiTgte_Blend::ComputeCenters() // If a face is its own image, it is not set const TopoDS_Shape& CurLIM = itLim.Value(); if (CurLIM.IsSame(CurLOF)) + { break; + } B.Add(myResult, CurLIM); } @@ -1726,7 +1805,9 @@ void BiTgte_Blend::ComputeSurfaces() const NCollection_List& L = myAsDes->Ascendant(CurE); if (L.Extent() != 2) + { continue; + } // -------------------------------------------------------------- // F1 and F2 = 2 parallel faces intersecting in CurE. @@ -1778,7 +1859,9 @@ void BiTgte_Blend::ComputeSurfaces() // and the vertexes are not managed (Intersections with sphere); // ---------------------------------------------------------------- if (OF1.IsNull() && OE1.IsNull()) + { continue; + } bool OF2isEdge = false; @@ -1799,7 +1882,9 @@ void BiTgte_Blend::ComputeSurfaces() // and the vertexes are not managed (Intersections with sphere); // ---------------------------------------------------------------- if (OF2.IsNull() && OE2.IsNull()) + { continue; + } NCollection_List CurL; @@ -1809,8 +1894,10 @@ void BiTgte_Blend::ComputeSurfaces() { // if I don't have the image, possibly CurL.Append(CurE); // I'm on intersection tube-tube } // See comment on the call to - else // MakeLoops + else + { // MakeLoops continue; + } } else { @@ -1859,10 +1946,14 @@ void BiTgte_Blend::ComputeSurfaces() gp_Pnt P2 = C->Value(C->LastParameter()); VfOnE1 = FindVertex(P1, MapOnV1f, myTol); if (VfOnE1.IsNull()) + { VfOnE1 = FindVertex(P1, MapOnV1l, myTol); + } VlOnE1 = FindVertex(P2, MapOnV1l, myTol); if (VlOnE1.IsNull()) + { VlOnE1 = FindVertex(P2, MapOnV1f, myTol); + } if (P1.SquareDistance(P2) < myTol * myTol) { // BRepOffset_Offset manages degenerated KPart @@ -1885,10 +1976,12 @@ void BiTgte_Blend::ComputeSurfaces() VlOnE1 = FindVertex(P2, MapOnV1l, myTol); BRepLib_MakeEdge MKE(PC1, GS1, VfOnE1, VlOnE1, f1, l1); if (MKE.IsDone()) + { E1 = MKE.Edge(); + } else { - std::cout << "Edge Not Done" << std::endl; + std::cout << "Edge Not Done" << '\n'; E1 = MKE.Edge(); } @@ -1903,10 +1996,14 @@ void BiTgte_Blend::ComputeSurfaces() gp_Pnt P2 = C->Value(C->LastParameter()); VfOnE2 = FindVertex(P1, MapOnV1f, myTol); if (VfOnE2.IsNull()) + { VfOnE2 = FindVertex(P1, MapOnV1l, myTol); + } VlOnE2 = FindVertex(P2, MapOnV1l, myTol); if (VlOnE2.IsNull()) + { VlOnE2 = FindVertex(P2, MapOnV1f, myTol); + } if (P1.SquareDistance(P2) < myTol * myTol) { // BRepOffset_Offset manages degenerated KParts @@ -1929,10 +2026,12 @@ void BiTgte_Blend::ComputeSurfaces() VlOnE2 = FindVertex(P2, MapOnV1l, myTol); BRepLib_MakeEdge MKE(PC2, GS2, VfOnE2, VlOnE2, f2, l2); if (MKE.IsDone()) + { E2 = MKE.Edge(); + } else { - std::cout << "edge not Done" << std::endl; + std::cout << "edge not Done" << '\n'; E2 = MKE.Edge(); } KPartCurve3d(E2, PC2, GS2); @@ -2090,7 +2189,9 @@ void BiTgte_Blend::ComputeSurfaces() { const TopoDS_Vertex& V = TopoDS::Vertex(Map.FindKey(j)); if (Map(j).Extent() != 3) + { continue; + } NCollection_List LOE; NCollection_List::Iterator it; @@ -2099,9 +2200,13 @@ void BiTgte_Blend::ComputeSurfaces() { bool Reverse = true; if (Reverse) + { LOE.Append(myMapSF(it.Value()).Generated(V).Reversed()); + } else + { LOE.Append(myMapSF(it.Value()).Generated(V)); + } } BRepOffset_Offset OFT(V, LOE, -myRadius, myNubs, myTol, GeomAbs_C2); @@ -2143,17 +2248,23 @@ void BiTgte_Blend::ComputeShape() const TopoDS_Face& CurF = TopoDS::Face(exp.Current()); if (!myFaces.Contains(CurF)) + { continue; // so the face is not touched + } // so the faces are unwinded if (!myMapSF.IsBound(CurF)) + { continue; // inverted or degenerated + } const BRepOffset_Offset& Offset = myMapSF(CurF); const TopoDS_Face& CurOF = myMapSF(CurF).Face(); - if (!myImageOffset.HasImage(CurOF)) // face disappears in unwinding + if (!myImageOffset.HasImage(CurOF)) + { // face disappears in unwinding continue; + } TopExp_Explorer exp2(CurF, TopAbs_EDGE); for (; exp2.More(); exp2.Next()) @@ -2164,7 +2275,9 @@ void BiTgte_Blend::ComputeShape() // const TopoDS_Edge& CurOE = TopoDS::Edge(Offset.Generated(CurE)); if (!myImageOffset.HasImage(CurOE)) + { continue; + } // CurOE disappears const TopoDS_Edge& ImE = TopoDS::Edge(myImageOffset.Image(CurOE).First()); @@ -2196,12 +2309,16 @@ void BiTgte_Blend::ComputeShape() { // so the faces are unwindeds if (!myMapSF.IsBound(CurF)) + { continue; // inverted or degenerated + } const TopoDS_Face& CurOF = myMapSF(CurF).Face(); - if (!myImageOffset.HasImage(CurOF)) // face disappears in unwinding + if (!myImageOffset.HasImage(CurOF)) + { // face disappears in unwinding continue; + } // List of faces generated by a face in the unwinding NCollection_List Lim; @@ -2238,9 +2355,13 @@ void BiTgte_Blend::ComputeShape() const TopoDS_Edge& OE = TopoDS::Edge(myCreated(E)(CurF).First()); TopExp::Vertices(OE, OV1, OV2); if (!myCreated.IsBound(V1)) + { myCreated.Bind(V1, EmptyMap); + } if (!myCreated.IsBound(V2)) + { myCreated.Bind(V2, EmptyMap); + } if (!myCreated(V1).IsBound(CurF)) { myCreated(V1).Bind(CurF, Empty); @@ -2279,9 +2400,13 @@ void BiTgte_Blend::ComputeShape() // BRep_Tool::CurveOnSurface(TopoDS::Edge(E.Reversed()), // Face,f,l); if (E.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(OE, C2d, C2d_1, NewF, BRep_Tool::Tolerance(E)); + } else + { B.UpdateEdge(OE, C2d_1, C2d, NewF, BRep_Tool::Tolerance(E)); + } B.Range(OE, f, l); } else @@ -2359,7 +2484,9 @@ void BiTgte_Blend::ComputeShape() exp.Init(myResult, TopAbs_FACE); for (; exp.More(); exp.Next()) + { Sew->Add(exp.Current()); + } Sew->Perform(); @@ -2407,10 +2534,14 @@ bool BiTgte_Blend::Intersect( const TopoDS_Face& F2 = OF2.Face(); if (Box1.IsOut(MapSBox(F2))) + { continue; + } if (Inter.IsDone(Face, F2)) + { continue; + } // 2 tubes created on free border are not intersected. const TopoDS_Shape& InitShape2 = OF2.InitialShape(); @@ -2425,7 +2556,9 @@ bool BiTgte_Blend::Intersect( #endif if (F1surBordLibre && F2surBordLibre) + { continue; + } // ------------------------------------------------------- // Tubes are not intersected with neighbor faces. @@ -2435,7 +2568,9 @@ bool BiTgte_Blend::Intersect( if (Init.ShapeType() == TopAbs_EDGE) { if (ItKey.ShapeType() == TopAbs_FACE && IsInFace(TopoDS::Edge(Init), TopoDS::Face(ItKey))) + { continue; + } } Inter.FaceInter(Face, F2, myInitOffsetFace); diff --git a/src/ModelingAlgorithms/TKOffset/Draft/Draft_FaceInfo.cxx b/src/ModelingAlgorithms/TKOffset/Draft/Draft_FaceInfo.cxx index abb9d407fd..98f04c2b9e 100644 --- a/src/ModelingAlgorithms/TKOffset/Draft/Draft_FaceInfo.cxx +++ b/src/ModelingAlgorithms/TKOffset/Draft/Draft_FaceInfo.cxx @@ -30,9 +30,13 @@ Draft_FaceInfo::Draft_FaceInfo(const occ::handle& S, const bool Ha { occ::handle T = occ::down_cast(S); if (!T.IsNull()) + { myGeom = T->BasisSurface(); + } else + { myGeom = S; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx index ab885cf4a6..031e6d0400 100644 --- a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx +++ b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification.cxx @@ -141,7 +141,9 @@ void Draft_Modification::Remove(const TopoDS_Face& F) { const TopoDS_Edge& theE = myEMap.FindKey(i); if (myEMap.FindFromKey(theE).RootFace().IsSame(curFace)) + { conneF.Append(theE); + } } ltod.Initialize(conneF); while (ltod.More()) @@ -266,11 +268,15 @@ bool Draft_Modification::NewCurve(const TopoDS_Edge& E, } if (!myEMap.Contains(E)) + { return false; + } const Draft_EdgeInfo& Einf = myEMap.FindFromKey(E); if (!myEMap.FindFromKey(E).NewGeometry()) + { return false; + } Tol = Einf.Tolerance(); Tol = std::max(Tol, BRep_Tool::Tolerance(E)); @@ -372,7 +378,9 @@ bool Draft_Modification::NewCurve2d(const TopoDS_Edge& E, occ::handle aC = occ::down_cast(SB)->BasisCurve(); occ::handle typc = aC->DynamicType(); if (typc == STANDARD_TYPE(Geom_Circle)) + { JeRecadre = true; + } } JeRecadre = JeRecadre || (typs == STANDARD_TYPE(Geom_CylindricalSurface)) @@ -466,7 +474,9 @@ bool Draft_Modification::NewParameter(const TopoDS_Vertex& V, paramf = FirstPar; FV.Orientation(E.Orientation()); if (V.IsEqual(FV)) + { P = paramf; + } } FV.Orientation(E.Orientation()); diff --git a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification_1.cxx b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification_1.cxx index 4daa04f8f7..d9c8f50280 100644 --- a/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification_1.cxx +++ b/src/ModelingAlgorithms/TKOffset/Draft/Draft_Modification_1.cxx @@ -376,7 +376,9 @@ bool Draft_Modification::InternalAdd(const TopoDS_Face& F, occ::handle T = occ::down_cast(NewC); if (!T.IsNull()) + { NewC = T->BasisCurve(); + } EInf.ChangeGeometry() = NewC; EInf.RootFace(curFace); @@ -423,7 +425,9 @@ bool Draft_Modification::Propagate() { if (!badShape.IsNull()) + { return false; + } // Set all edges and vertices of modified faces TopoDS_Face F; @@ -704,7 +708,9 @@ bool Draft_Modification::Propagate() void Draft_Modification::Perform() { if (!badShape.IsNull()) + { throw Standard_ConstructionError(); + } if (!myComp) { @@ -786,7 +792,9 @@ void Draft_Modification::Perform() } if (extrdir.Dot(DirRef) < 0.) + { extrdir.Reverse(); + } // it is possible to accelerate speed by storing the info during // InternalAdd --> modification of FaceInfo to preserve the circle @@ -917,7 +925,9 @@ void Draft_Modification::Perform() { // very temporary on circles !!! aCirc = occ::down_cast(TheNewCurve); if (aCirc.IsNull()) + { KPart = false; + } else { gp_Dir AxofCirc = aCirc->Position().Direction(); @@ -940,9 +950,13 @@ void Draft_Modification::Perform() new Geom2d_Line(gp_Pnt2d(0., aLocalReal / Cos), gp::DX2d()); if (PC1) + { Einf.ChangeFirstPC() = L2d; + } else + { Einf.ChangeSecondPC() = L2d; + } } else { @@ -1015,13 +1029,17 @@ void Draft_Modification::Perform() if (detrompeur == 1) { if (S1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { S1 = occ::down_cast(S1)->BasisSurface(); + } theSurf = S1; } else if (detrompeur == 2) { if (S2->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { S2 = occ::down_cast(S2)->BasisSurface(); + } theSurf = S2; } if (detrompeur != 0 && detrompeur != 4) @@ -1046,7 +1064,9 @@ void Draft_Modification::Perform() ElSLib::Parameters(cy, pfvprim, ufprim, vfprim); } else + { detrompeur = 4; + } if (detrompeur == 1 || detrompeur == 2) { @@ -1114,20 +1134,26 @@ void Draft_Modification::Perform() bool YaRev = d1fv.Dot(newd1) < 0.; if (YaRev) + { newC->Reverse(); + } if (i2s.HasLineOnS1(imin)) { Einf.ChangeFirstPC() = i2s.LineOnS1(imin); if (YaRev) + { Einf.ChangeFirstPC()->Reverse(); + } } if (i2s.HasLineOnS2(imin)) { Einf.ChangeSecondPC() = i2s.LineOnS2(imin); if (YaRev) + { Einf.ChangeSecondPC()->Reverse(); + } } } // if (i2s.Line(1)->DynamicType() != STANDARD_TYPE(Geom_BSplineCurve)) else // i2s.Line(1) is BSplineCurve @@ -1146,7 +1172,9 @@ void Draft_Modification::Perform() projector.LowerDistanceParameters(U, V); if (std::abs(U) <= Precision::Confusion() || std::abs(U - 2. * M_PI) <= Precision::Confusion()) + { Candidates.Append(aCurve); + } else { Pnt = aCurve->Value(aCurve->LastParameter()); @@ -1167,13 +1195,17 @@ void Draft_Modification::Perform() // badShape = TopoDS::Edge(ite.Key()); // return; for (i = 1; i <= i2s.NbLines(); i++) + { Candidates.Append(i2s.Line(i)); + } } } else { for (i = 1; i <= i2s.NbLines(); i++) + { Candidates.Append(i2s.Line(i)); + } } occ::handle FirstCurve; @@ -1193,13 +1225,19 @@ void Draft_Modification::Perform() } } else + { FirstCurve = Candidates(1); + } // Glueing NCollection_Sequence> Curves; for (i = 1; i <= i2s.NbLines(); i++) + { if (FirstCurve != i2s.Line(i)) + { Curves.Append(i2s.Line(i)); + } + } NCollection_Sequence> ToGlue; gp_Pnt EndPoint = FirstCurve->Value(FirstCurve->LastParameter()); @@ -1243,9 +1281,11 @@ void Draft_Modification::Perform() GeomConvert_CompCurveToBSplineCurve Concat( occ::down_cast(FirstCurve)); for (i = 1; i <= ToGlue.Length(); i++) + { Concat.Add(occ::down_cast(ToGlue(i)), Precision::Confusion(), true); + } newC = Concat.BSplineCurve(); @@ -1268,7 +1308,9 @@ void Draft_Modification::Perform() bool YaRev = d1fv.Dot(newd1) < 0.; if (YaRev) + { newC->Reverse(); + } /* if (i2s.HasLineOnS1(imin)) { Einf.ChangeFirstPC() = i2s.LineOnS1(imin); @@ -1383,7 +1425,9 @@ void Draft_Modification::Perform() occ::handle T = occ::down_cast(newC); if (!T.IsNull()) + { newC = T->BasisCurve(); + } Einf.ChangeGeometry() = newC; } else if (!Einf.NewGeometry()) @@ -1391,7 +1435,9 @@ void Draft_Modification::Perform() // set existing curve 3D occ::handle T = occ::down_cast(C); if (!T.IsNull()) + { C = T->BasisCurve(); + } Einf.ChangeGeometry() = C; } } @@ -1469,7 +1515,9 @@ void Draft_Modification::Perform() SmartParameter(Einf2, BRep_Tool::Tolerance(Edg2), pvt, done, S1, S2); } else + { Vinf.ChangeParameter(Edg2) = param; + } } Vinf.ChangeGeometry() = pvt; @@ -1484,7 +1532,9 @@ void Draft_Modification::Perform() SmartParameter(Einf1, BRep_Tool::Tolerance(Edg1), pvt, done, S1, S2); } else + { Vinf.ChangeParameter(Edg1) = param; + } continue; } @@ -1627,19 +1677,27 @@ void Draft_Modification::Perform() double aSqMagn = aDirNF.SquareMagnitude(); if (aSqMagn > Precision::SquareConfusion()) + { aDirNF.Divide(sqrt(aSqMagn)); + } aSqMagn = aDirNL.SquareMagnitude(); if (aSqMagn > Precision::SquareConfusion()) + { aDirNL.Divide(sqrt(aSqMagn)); + } aSqMagn = aDirOF.SquareMagnitude(); if (aSqMagn > Precision::SquareConfusion()) + { aDirOF.Divide(sqrt(aSqMagn)); + } aSqMagn = aDirOL.SquareMagnitude(); if (aSqMagn > Precision::SquareConfusion()) + { aDirOL.Divide(sqrt(aSqMagn)); + } const double aCosF = aDirNF.Dot(aDirOF), aCosL = aDirNL.Dot(aDirOL); const double aCosMax = std::abs(aCosF) > std::abs(aCosL) ? aCosF : aCosL; @@ -1686,9 +1744,13 @@ void Draft_Modification::Perform() double FirstPar = theCurve->FirstParameter(), LastPar = theCurve->LastParameter(); constexpr double pconf = Precision::PConfusion(); if (std::abs(pf - LastPar) <= pconf) + { pf = FirstPar; + } else if (std::abs(pl - FirstPar) <= pconf) + { pl = LastPar; + } if (pl <= pf) { @@ -1703,9 +1765,13 @@ void Draft_Modification::Perform() } } if (myVMap.Contains(Vf)) + { myVMap.ChangeFromKey(Vf).ChangeParameter(edg) = pf; + } if (myVMap.Contains(Vl)) + { myVMap.ChangeFromKey(Vl).ChangeParameter(edg) = pl; + } } } @@ -2034,7 +2100,9 @@ static bool Choose( prm = SmartParameter(Einf, BRep_Tool::Tolerance(Eref), BRep_Tool::Pnt(Vtx), done, S1, S2); } else + { prm = param; + } C->D1(prm, ptbid, tgref); Vinf.InitEdgeIterator(); @@ -2062,7 +2130,9 @@ static bool Choose( SmartParameter(Einfo, BRep_Tool::Tolerance(Edg), BRep_Tool::Pnt(Vtx), anewdone, S1, S2); } else + { prm = anewparam; + } gp_Vec tg; C->D1(prm, ptbid, tg); if (tg.CrossMagnitude(tgref) > Precision::Confusion()) @@ -2242,7 +2312,9 @@ static double SmartParameter(Draft_EdgeInfo& Einf, NewC2d = Einf.FirstPC(); if (NewC2d->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { NewC2d = (occ::down_cast(NewC2d))->BasisCurve(); + } gp_Pnt2d P2d(U, V); Geom2dAPI_ProjectPointOnCurve Projector2d(P2d, NewC2d); @@ -2250,9 +2322,13 @@ static double SmartParameter(Draft_EdgeInfo& Einf, { occ::handle BCurve; if (NewC2d->DynamicType() != STANDARD_TYPE(Geom2d_BSplineCurve)) + { BCurve = Geom2dConvert::CurveToBSplineCurve(NewC2d); + } else + { BCurve = occ::down_cast(NewC2d); + } if (sign == -1) { NCollection_Array1 PntArray(1, 2); @@ -2293,9 +2369,13 @@ static double SmartParameter(Draft_EdgeInfo& Einf, Einf.SetNewGeometry(true); if (sign == -1) + { return Einf.Geometry()->FirstParameter(); + } else + { return Einf.Geometry()->LastParameter(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx b/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx index 64f385834e..2fdad8c9a8 100644 --- a/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx +++ b/src/ModelingAlgorithms/TKOffset/GTests/BRepOffsetAPI_MakePipeShell_Test.cxx @@ -79,7 +79,9 @@ bool buildBentTube(double theWallThickness, { const double aBendAngle = theLength / theMajorRadius; if (aBendAngle >= M_PI) + { return false; + } const double aRadiusL = theDia1 / 2.0; const double aRadiusR = theDia2 / 2.0; @@ -113,7 +115,9 @@ bool buildBentTube(double theWallThickness, BRepBuilderAPI_MakeEdge aMkEdge(aSpineCurve); if (!aMkEdge.IsDone()) + { return false; + } TopoDS_Wire aSpineWire = BRepBuilderAPI_MakeWire(aMkEdge.Edge()).Wire(); BRepOffsetAPI_MakePipeShell aMkPipe1(aSpineWire); @@ -121,14 +125,18 @@ bool buildBentTube(double theWallThickness, aMkPipe1.SetLaw(aWire1, aLaw1, false, false); aMkPipe1.Build(); if (!aMkPipe1.IsDone()) + { return false; + } BRepOffsetAPI_MakePipeShell aMkPipe2(aSpineWire); aMkPipe2.SetTolerance(1.0e-8, 1.0e-8, 1.0e-6); aMkPipe2.SetLaw(anOutWire, aLaw2, false, false); aMkPipe2.Build(); if (!aMkPipe2.IsDone()) + { return false; + } // Build opening face at start of bend (annular ring) BRepBuilderAPI_MakeFace aMkFace; @@ -137,7 +145,9 @@ bool buildBentTube(double theWallThickness, aMkFace.Add(TopoDS::Wire(aMkPipe2.FirstShape())); aMkFace.Add(TopoDS::Wire(aMkPipe1.FirstShape().Reversed())); if (!aMkFace.IsDone()) + { return false; + } TopoDS_Face aFace1 = aMkFace.Face(); // Build opening face at end of bend (annular ring) @@ -146,7 +156,9 @@ bool buildBentTube(double theWallThickness, aMkFace.Add(TopoDS::Wire(aMkPipe2.LastShape())); aMkFace.Add(TopoDS::Wire(aMkPipe1.LastShape().Reversed())); if (!aMkFace.IsDone()) + { return false; + } TopoDS_Face aFace2 = aMkFace.Face(); // Assemble tube shell from inner pipe face, outer pipe face, and two annular ring faces @@ -156,7 +168,9 @@ bool buildBentTube(double theWallThickness, TopExp_Explorer aFaceExp(aMkPipe1.Shape(), TopAbs_FACE); if (aFaceExp.More()) + { aBuilder.Add(aTubeShell, aFaceExp.Current().Reversed()); + } // Extract the gas solid before modifying mkPipe1 to a solid aMkPipe1.MakeSolid(); @@ -164,7 +178,9 @@ bool buildBentTube(double theWallThickness, aFaceExp.Init(aMkPipe2.Shape(), TopAbs_FACE); if (aFaceExp.More()) + { aBuilder.Add(aTubeShell, aFaceExp.Current()); + } aBuilder.Add(aTubeShell, aFace1.Reversed()); aBuilder.Add(aTubeShell, aFace2); @@ -210,7 +226,9 @@ TEST(BRepOffsetAPI_MakePipeShellTest, Bug332_BentTubeWithScalingLaw) { const double aLen = wireLength(TopoDS::Wire(anExp.Current())); if (aLen > Precision::Confusion()) + { aWireLengths.Append(aLen); + } } // Expected circular circumferences from the TCL test (pi * diameter): @@ -231,7 +249,9 @@ TEST(BRepOffsetAPI_MakePipeShellTest, Bug332_BentTubeWithScalingLaw) for (const double aLen : aWireLengths) { if (std::abs(aLen - theExpected) / theExpected <= aTol) + { ++aCount; + } } return aCount; }; diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Builder.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Builder.cxx index 458fab6602..30dfcf20c9 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Builder.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Builder.cxx @@ -147,7 +147,9 @@ void BRepPrim_Builder::AddEdgeVertex(TopoDS_Edge& E, { TopoDS_Vertex VV = V; if (!direct) + { VV.Reverse(); + } myBuilder.Add(E, VV); myBuilder.UpdateVertex(VV, P, E, Precision::Confusion()); } @@ -183,7 +185,9 @@ void BRepPrim_Builder::AddWireEdge(TopoDS_Wire& W, const TopoDS_Edge& E, const b { TopoDS_Edge EE = E; if (!direct) + { EE.Reverse(); + } myBuilder.Add(W, EE); } diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Cone.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Cone.cxx index c278475590..200a0c4268 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Cone.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_Cone.cxx @@ -37,11 +37,17 @@ BRepPrim_Cone::BRepPrim_Cone(const double Angle, myRadius(Radius) { if (Height < Precision::Confusion()) + { throw Standard_DomainError("cone with null height"); + } if (myHalfAngle * Height < Precision::Confusion()) + { throw Standard_DomainError("cone with null angle"); + } if ((M_PI / 2 - myHalfAngle) * Height < Precision::Confusion()) + { throw Standard_DomainError("cone with angle > PI/2"); + } // cut at top VMax(Height / std::cos(myHalfAngle)); @@ -57,7 +63,9 @@ BRepPrim_Cone::BRepPrim_Cone(const double Angle) myRadius(0.) { if ((Angle < 0) || (Angle > M_PI / 2)) + { throw Standard_DomainError("cone with angle <0 or > PI/2"); + } VMin(0.); SetMeridian(); } @@ -70,7 +78,9 @@ BRepPrim_Cone::BRepPrim_Cone(const double Angle, const gp_Pnt& Apex) myRadius(0.) { if ((Angle < 0) || (Angle > M_PI / 2)) + { throw Standard_DomainError("cone with angle <0 or > PI/2"); + } VMin(0.); SetMeridian(); } @@ -82,7 +92,9 @@ BRepPrim_Cone::BRepPrim_Cone(const double Angle, const gp_Ax2& Axes) myHalfAngle(Angle) { if ((Angle < 0) || (Angle > M_PI / 2)) + { throw Standard_DomainError("cone with angle <0 or > PI/2"); + } VMin(0.); SetMeridian(); } @@ -144,11 +156,17 @@ void BRepPrim_Cone::SetMeridian() void BRepPrim_Cone::SetParameters(const double R1, const double R2, const double H) { if (((R1 != 0) && (R1 < Precision::Confusion())) || ((R2 != 0) && (R2 < Precision::Confusion()))) + { throw Standard_DomainError("cone with negative or too small radius"); + } if (std::abs(R1 - R2) < Precision::Confusion()) + { throw Standard_DomainError("cone with two identic radii"); + } if (H < Precision::Confusion()) + { throw Standard_DomainError("cone with negative or null height"); + } myRadius = R1; myHalfAngle = std::atan((R2 - R1) / H); diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_FaceBuilder.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_FaceBuilder.cxx index 16e8b37a2f..eed5b3aad7 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_FaceBuilder.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_FaceBuilder.cxx @@ -74,17 +74,29 @@ void BRepPrim_FaceBuilder::Init(const BRep_Builder& B, S->Bounds(USMin, USMax, VSMin, VSMax); if (UMin >= UMax) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } if (VMin >= VMax) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } if (UMin < USMin) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } if (UMax > USMax) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } if (VMin < VSMin) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } if (VMax > VSMax) + { throw Standard_ConstructionError("BRepPrim_FaceBuilder"); + } // Make the vertices B.MakeVertex(myVertex[0], S->Value(UMin, VMin), Precision::Confusion()); @@ -152,7 +164,9 @@ void BRepPrim_FaceBuilder::Init(const BRep_Builder& B, // set the natural restriction flag if (UMin == USMin && UMax == USMax && VMin == VSMin && VMax == VSMax) + { B.NaturalRestriction(myFace, true); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_GWedge.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_GWedge.cxx index 83b2e85f27..f16b4553d0 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_GWedge.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_GWedge.cxx @@ -62,7 +62,9 @@ static int BRepPrim_Wedge_NumDir2(const BRepPrim_Direction d1, const BRepPrim_Di int i1 = BRepPrim_Wedge_NumDir1(d1); int i2 = BRepPrim_Wedge_NumDir1(d2); if (i1 / 2 == i2 / 2) + { throw Standard_DomainError(); + } return tab[i1][i2]; } @@ -79,7 +81,9 @@ static int BRepPrim_Wedge_NumDir3(const BRepPrim_Direction d1, int i2 = BRepPrim_Wedge_NumDir1(d2); int i3 = BRepPrim_Wedge_NumDir1(d3); if ((i1 / 2 == i2 / 2) || (i2 / 2 == i3 / 2) || (i3 / 2 == i1 / 2)) + { throw Standard_DomainError(); + } return val[i1] + val[i2] + val[i3]; } @@ -92,17 +96,33 @@ static void BRepPrim_Wedge_Check(const bool V[], const bool E[], const bool W[], { int i; for (i = 0; i < NBVERTICES; i++) + { if (V[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBEDGES; i++) + { if (E[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBWIRES; i++) + { if (W[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBFACES; i++) + { if (F[i]) + { throw Standard_DomainError(); + } + } } //================================================================================================= @@ -112,13 +132,21 @@ static void BRepPrim_Wedge_Init(bool& S, bool V[], bool E[], bool W[], bool F[]) int i; S = false; for (i = 0; i < NBVERTICES; i++) + { V[i] = false; + } for (i = 0; i < NBEDGES; i++) + { E[i] = false; + } for (i = 0; i < NBWIRES; i++) + { W[i] = false; + } for (i = 0; i < NBFACES; i++) + { F[i] = false; + } } BRepPrim_GWedge::BRepPrim_GWedge() @@ -329,24 +357,38 @@ bool BRepPrim_GWedge::IsInfinite(const BRepPrim_Direction d1) const const TopoDS_Shell& BRepPrim_GWedge::Shell() { if (IsDegeneratedShape()) + { throw Standard_DomainError(); + } if (!ShellBuilt) { myBuilder.MakeShell(myShell); if (HasFace(BRepPrim_XMin)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_XMin)); + } if (HasFace(BRepPrim_XMax)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_XMax)); + } if (HasFace(BRepPrim_YMin)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_YMin)); + } if (HasFace(BRepPrim_YMax)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_YMax)); + } if (HasFace(BRepPrim_ZMin)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_ZMin)); + } if (HasFace(BRepPrim_ZMax)) + { myBuilder.AddShellFace(myShell, Face(BRepPrim_ZMax)); + } myShell.Closed(BRep_Tool::IsClosed(myShell)); myBuilder.CompleteShell(myShell); @@ -364,7 +406,9 @@ bool BRepPrim_GWedge::HasFace(const BRepPrim_Direction d1) const { bool state = !myInfinite[BRepPrim_Wedge_NumDir1(d1)]; if (d1 == BRepPrim_YMax) + { state = state && (Z2Max != Z2Min) && (X2Max != X2Min); + } return state; } @@ -406,7 +450,9 @@ gp_Pln BRepPrim_GWedge::Plane(const BRepPrim_Direction d1) Y = YMin; Z = ZMin; if (X2Min != XMin) + { D = gp_Dir((YMax - YMin) * VX + (XMin - X2Min) * VY); + } break; case 1: @@ -415,7 +461,9 @@ gp_Pln BRepPrim_GWedge::Plane(const BRepPrim_Direction d1) Y = YMin; Z = ZMin; if (X2Max != XMax) + { D = gp_Dir((YMax - YMin) * VX + (XMax - X2Max) * VY); + } break; case 2: @@ -438,7 +486,9 @@ gp_Pln BRepPrim_GWedge::Plane(const BRepPrim_Direction d1) Y = YMin; Z = ZMin; if (Z2Min != ZMin) + { D = gp_Dir((YMax - YMin) * VZ + (ZMin - Z2Min) * VY); + } break; case 5: @@ -447,7 +497,9 @@ gp_Pln BRepPrim_GWedge::Plane(const BRepPrim_Direction d1) Y = YMin; Z = ZMax; if (Z2Max != ZMax) + { D = gp_Dir((YMax - YMin) * VZ + (ZMax - Z2Max) * VY); + } break; }; @@ -471,9 +523,13 @@ const TopoDS_Face& BRepPrim_GWedge::Face(const BRepPrim_Direction d1) gp_Pln P = Plane(d1); myBuilder.MakeFace(myFaces[i], P); if (HasWire(d1)) + { myBuilder.AddFaceWire(myFaces[i], Wire(d1)); + } if (i % 2 == 0) + { myBuilder.ReverseFace(myFaces[i]); + } // pcurves @@ -569,7 +625,9 @@ bool BRepPrim_GWedge::HasWire(const BRepPrim_Direction d1) const int i = BRepPrim_Wedge_NumDir1(d1); if (myInfinite[i]) + { return false; + } BRepPrim_Direction dd1 = BRepPrim_XMin, dd2 = BRepPrim_YMax, dd3 = BRepPrim_XMax, dd4 = BRepPrim_ZMin; @@ -653,13 +711,21 @@ const TopoDS_Wire& BRepPrim_GWedge::Wire(const BRepPrim_Direction d1) myBuilder.MakeWire(myWires[i]); if (HasEdge(d1, dd4)) + { myBuilder.AddWireEdge(myWires[i], Edge(d1, dd4), false); + } if (HasEdge(d1, dd3)) + { myBuilder.AddWireEdge(myWires[i], Edge(d1, dd3), false); + } if (HasEdge(d1, dd2)) + { myBuilder.AddWireEdge(myWires[i], Edge(d1, dd2), true); + } if (HasEdge(d1, dd1)) + { myBuilder.AddWireEdge(myWires[i], Edge(d1, dd1), true); + } myBuilder.CompleteWire(myWires[i]); WiresBuilt[i] = true; @@ -675,9 +741,13 @@ bool BRepPrim_GWedge::HasEdge(const BRepPrim_Direction d1, const BRepPrim_Direct bool state = !(myInfinite[BRepPrim_Wedge_NumDir1(d1)] || myInfinite[BRepPrim_Wedge_NumDir1(d2)]); int i = BRepPrim_Wedge_NumDir2(d1, d2); if (i == 6 || i == 7) + { state = state && (X2Max != X2Min); + } else if (i == 1 || i == 3) + { state = state && (Z2Max != Z2Min); + } return state; } @@ -686,7 +756,9 @@ bool BRepPrim_GWedge::HasEdge(const BRepPrim_Direction d1, const BRepPrim_Direct gp_Lin BRepPrim_GWedge::Line(const BRepPrim_Direction d1, const BRepPrim_Direction d2) { if (!HasEdge(d1, d2)) + { throw Standard_DomainError(); + } int i = BRepPrim_Wedge_NumDir2(d1, d2); @@ -829,7 +901,9 @@ gp_Lin BRepPrim_GWedge::Line(const BRepPrim_Direction d1, const BRepPrim_Directi const TopoDS_Edge& BRepPrim_GWedge::Edge(const BRepPrim_Direction d1, const BRepPrim_Direction d2) { if (!HasEdge(d1, d2)) + { throw Standard_DomainError(); + } int i = BRepPrim_Wedge_NumDir2(d1, d2); @@ -929,7 +1003,9 @@ gp_Pnt BRepPrim_GWedge::Point(const BRepPrim_Direction d1, const BRepPrim_Direction d3) { if (!HasVertex(d1, d2, d3)) + { throw Standard_DomainError(); + } int i = BRepPrim_Wedge_NumDir3(d1, d2, d3); @@ -1001,7 +1077,9 @@ const TopoDS_Vertex& BRepPrim_GWedge::Vertex(const BRepPrim_Direction d1, const BRepPrim_Direction d3) { if (!HasVertex(d1, d2, d3)) + { throw Standard_DomainError(); + } int i = BRepPrim_Wedge_NumDir3(d1, d2, d3); diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_OneAxis.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_OneAxis.cxx index 5591f4d3f8..2e35bc9d27 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_OneAxis.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrim/BRepPrim_OneAxis.cxx @@ -100,17 +100,33 @@ static void BRepPrim_OneAxis_Check(const bool V[], const bool E[], const bool W[ { int i; for (i = 0; i < NBVERTICES; i++) + { if (V[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBEDGES; i++) + { if (E[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBWIRES; i++) + { if (W[i]) + { throw Standard_DomainError(); + } + } for (i = 0; i < NBFACES; i++) + { if (F[i]) + { throw Standard_DomainError(); + } + } } } // namespace @@ -132,13 +148,21 @@ BRepPrim_OneAxis::BRepPrim_OneAxis(const BRepPrim_Builder& B, int i; ShellBuilt = false; for (i = 0; i < NBVERTICES; i++) + { VerticesBuilt[i] = false; + } for (i = 0; i < NBEDGES; i++) + { EdgesBuilt[i] = false; + } for (i = 0; i < NBWIRES; i++) + { WiresBuilt[i] = false; + } for (i = 0; i < NBFACES; i++) + { FacesBuilt[i] = false; + } } //================================================================================================= @@ -213,9 +237,13 @@ bool BRepPrim_OneAxis::MeridianOnAxis(const double V) const bool BRepPrim_OneAxis::MeridianClosed() const { if (VMaxInfinite()) + { return false; + } if (VMinInfinite()) + { return false; + } return MeridianValue(myVMin).IsEqual(MeridianValue(myVMax), Precision::Confusion()); } @@ -265,11 +293,17 @@ bool BRepPrim_OneAxis::areHeightsEqual() const bool BRepPrim_OneAxis::HasTop() const { if (VMaxInfinite()) + { return false; + } if (MeridianClosed()) + { return false; + } if (MeridianOnAxis(myVMax)) + { return false; + } return true; } @@ -278,11 +312,17 @@ bool BRepPrim_OneAxis::HasTop() const bool BRepPrim_OneAxis::HasBottom() const { if (VMinInfinite()) + { return false; + } if (MeridianClosed()) + { return false; + } if (MeridianOnAxis(myVMin)) + { return false; + } return true; } @@ -303,9 +343,13 @@ const TopoDS_Shell& BRepPrim_OneAxis::Shell() myBuilder.AddShellFace(myShell, LateralFace()); if (HasTop()) + { myBuilder.AddShellFace(myShell, TopFace()); + } if (HasBottom()) + { myBuilder.AddShellFace(myShell, BottomFace()); + } if (HasSides()) { myBuilder.AddShellFace(myShell, StartFace()); @@ -337,7 +381,9 @@ const TopoDS_Face& BRepPrim_OneAxis::LateralFace() myBuilder.AddFaceWire(myFaces[FLATERAL], LateralEndWire()); } else + { myBuilder.AddFaceWire(myFaces[FLATERAL], LateralWire()); + } // put the parametric curves if (MeridianClosed()) @@ -503,7 +549,9 @@ const TopoDS_Face& BRepPrim_OneAxis::StartFace() } if (VMaxInfinite() && VMinInfinite()) + { myBuilder.AddFaceWire(myFaces[FSTART], AxisStartWire()); + } myBuilder.AddFaceWire(myFaces[FSTART], StartWire()); @@ -511,23 +559,29 @@ const TopoDS_Face& BRepPrim_OneAxis::StartFace() SetMeridianPCurve(myEdges[ESTART], myFaces[FSTART]); // Skip AxisEdge pcurve when heights are equal since the edge is not in the wire if (EdgesBuilt[EAXIS] && !areHeightsEqual()) + { myBuilder.SetPCurve(myEdges[EAXIS], myFaces[FSTART], gp_Lin2d(gp_Pnt2d(0, 0), gp_Dir2d(gp_Dir2d::D::Y))); + } // When heights are equal, the pcurves for TopStart and BotStart edges // would overlap at Y = height. Use small offsets to separate them. const double aPCurveOffset = areHeightsEqual() ? Precision::Confusion() * THE_PCURVE_OFFSET_FACTOR : 0.0; if (EdgesBuilt[ETOPSTART]) + { myBuilder.SetPCurve( myEdges[ETOPSTART], myFaces[FSTART], gp_Lin2d(gp_Pnt2d(0, MeridianValue(myVMax).Y() + aPCurveOffset), gp_Dir2d(gp_Dir2d::D::X))); + } if (EdgesBuilt[EBOTSTART]) + { myBuilder.SetPCurve( myEdges[EBOTSTART], myFaces[FSTART], gp_Lin2d(gp_Pnt2d(0, MeridianValue(myVMin).Y() - aPCurveOffset), gp_Dir2d(gp_Dir2d::D::X))); + } myBuilder.CompleteFace(myFaces[FSTART]); FacesBuilt[FSTART] = true; @@ -561,30 +615,38 @@ const TopoDS_Face& BRepPrim_OneAxis::EndFace() } if (VMaxInfinite() && VMinInfinite()) + { myBuilder.AddFaceWire(myFaces[FEND], AxisEndWire()); + } myBuilder.AddFaceWire(myFaces[FEND], EndWire()); // parametric curves SetMeridianPCurve(myEdges[EEND], myFaces[FEND]); // Skip AxisEdge pcurve when heights are equal since the edge is not in the wire if (EdgesBuilt[EAXIS] && !areHeightsEqual()) + { myBuilder.SetPCurve(myEdges[EAXIS], myFaces[FEND], gp_Lin2d(gp_Pnt2d(0, 0), gp_Dir2d(gp_Dir2d::D::Y))); + } // When heights are equal, the pcurves for TopEnd and BotEnd edges // would overlap at Y = height. Use small offsets to separate them. const double aPCurveOffset = areHeightsEqual() ? Precision::Confusion() * THE_PCURVE_OFFSET_FACTOR : 0.0; if (EdgesBuilt[ETOPEND]) + { myBuilder.SetPCurve( myEdges[ETOPEND], myFaces[FEND], gp_Lin2d(gp_Pnt2d(0, MeridianValue(myVMax).Y() + aPCurveOffset), gp_Dir2d(gp_Dir2d::D::X))); + } if (EdgesBuilt[EBOTEND]) + { myBuilder.SetPCurve( myEdges[EBOTEND], myFaces[FEND], gp_Lin2d(gp_Pnt2d(0, MeridianValue(myVMin).Y() - aPCurveOffset), gp_Dir2d(gp_Dir2d::D::X))); + } myBuilder.CompleteFace(myFaces[FEND]); FacesBuilt[FEND] = true; @@ -604,10 +666,14 @@ const TopoDS_Wire& BRepPrim_OneAxis::LateralWire() myBuilder.MakeWire(myWires[WLATERAL]); if (!VMaxInfinite()) + { myBuilder.AddWireEdge(myWires[WLATERAL], TopEdge(), false); + } myBuilder.AddWireEdge(myWires[WLATERAL], EndEdge(), true); if (!VMinInfinite()) + { myBuilder.AddWireEdge(myWires[WLATERAL], BottomEdge(), true); + } myBuilder.AddWireEdge(myWires[WLATERAL], StartEdge(), false); myBuilder.CompleteWire(myWires[WLATERAL]); @@ -726,16 +792,22 @@ const TopoDS_Wire& BRepPrim_OneAxis::StartWire() const bool heightsEqual = areHeightsEqual(); if (HasBottom()) + { myBuilder.AddWireEdge(myWires[WSTART], StartBottomEdge(), true); + } if (!MeridianClosed() && !heightsEqual) { if (!VMaxInfinite() || !VMinInfinite()) + { myBuilder.AddWireEdge(myWires[WSTART], AxisEdge(), isInverted); + } } if (HasTop()) + { myBuilder.AddWireEdge(myWires[WSTART], StartTopEdge(), false); + } myBuilder.AddWireEdge(myWires[WSTART], StartEdge(), true); myBuilder.CompleteWire(myWires[WSTART]); @@ -792,7 +864,9 @@ const TopoDS_Wire& BRepPrim_OneAxis::EndWire() const bool heightsEqual = areHeightsEqual(); if (HasTop()) + { myBuilder.AddWireEdge(myWires[WEND], EndTopEdge(), true); + } if (!MeridianClosed() && !heightsEqual) { if (!VMaxInfinite() || !VMinInfinite()) @@ -801,7 +875,9 @@ const TopoDS_Wire& BRepPrim_OneAxis::EndWire() } } if (HasBottom()) + { myBuilder.AddWireEdge(myWires[WEND], EndBottomEdge(), false); + } myBuilder.AddWireEdge(myWires[WEND], EndEdge(), false); myBuilder.CompleteWire(myWires[WEND]); @@ -871,9 +947,13 @@ const TopoDS_Edge& BRepPrim_OneAxis::AxisEdge() const double yMin = MeridianValue(myVMin).Y(); if (!VMaxInfinite()) + { myBuilder.AddEdgeVertex(myEdges[EAXIS], AxisTopVertex(), yMax, isInverted); + } if (!VMinInfinite()) + { myBuilder.AddEdgeVertex(myEdges[EAXIS], AxisBottomVertex(), yMin, !isInverted); + } } myBuilder.CompleteEdge(myEdges[EAXIS]); @@ -894,8 +974,9 @@ const TopoDS_Edge& BRepPrim_OneAxis::StartEdge() // is it shared with the EndEdge if (!HasSides() && EdgesBuilt[EEND]) + { myEdges[ESTART] = myEdges[EEND]; - + } else { // build the empty Edge @@ -945,8 +1026,9 @@ const TopoDS_Edge& BRepPrim_OneAxis::EndEdge() // is it shared with the start edge if (!HasSides() && EdgesBuilt[ESTART]) + { myEdges[EEND] = myEdges[ESTART]; - + } else { // build the empty Edge @@ -1126,7 +1208,9 @@ const TopoDS_Edge& BRepPrim_OneAxis::TopEdge() myBuilder.MakeEdge(myEdges[ETOP], C); } else + { myBuilder.MakeDegeneratedEdge(myEdges[ETOP]); + } if (!HasSides()) { @@ -1176,7 +1260,9 @@ const TopoDS_Edge& BRepPrim_OneAxis::BottomEdge() myBuilder.MakeEdge(myEdges[EBOTTOM], C); } else + { myBuilder.MakeDegeneratedEdge(myEdges[EBOTTOM]); + } if (!HasSides()) { @@ -1207,15 +1293,19 @@ const TopoDS_Vertex& BRepPrim_OneAxis::AxisTopVertex() // deduct from others if (MeridianOnAxis(myVMax) && VerticesBuilt[VTOPSTART]) + { myVertices[VAXISTOP] = myVertices[VTOPSTART]; - + } else if (MeridianOnAxis(myVMax) && VerticesBuilt[VTOPEND]) + { myVertices[VAXISTOP] = myVertices[VTOPEND]; - // Share with AxisBottomVertex if heights are equal (handles case when bottom is built first) + // Share with AxisBottomVertex if heights are equal (handles case when bottom is built first) + } else if (VerticesBuilt[VAXISBOT] && areHeightsEqual()) + { myVertices[VAXISTOP] = myVertices[VAXISBOT]; - + } else { Standard_DomainError_Raise_if(MeridianClosed(), "BRepPrim_OneAxis::AxisTopVertex"); @@ -1243,15 +1333,19 @@ const TopoDS_Vertex& BRepPrim_OneAxis::AxisBottomVertex() // deduct from others if (MeridianOnAxis(myVMin) && VerticesBuilt[VBOTSTART]) + { myVertices[VAXISBOT] = myVertices[VBOTSTART]; - + } else if (MeridianOnAxis(myVMin) && VerticesBuilt[VBOTEND]) + { myVertices[VAXISBOT] = myVertices[VBOTEND]; - // Share with AxisTopVertex if heights are equal (within tolerance) + // Share with AxisTopVertex if heights are equal (within tolerance) + } else if (VerticesBuilt[VAXISTOP] && areHeightsEqual()) + { myVertices[VAXISBOT] = myVertices[VAXISTOP]; - + } else { Standard_DomainError_Raise_if(MeridianClosed(), "BRepPrim_OneAxis::AxisBottomVertex"); @@ -1279,14 +1373,21 @@ const TopoDS_Vertex& BRepPrim_OneAxis::TopStartVertex() // deduct from others if (MeridianOnAxis(myVMax) && VerticesBuilt[VAXISTOP]) + { myVertices[VTOPSTART] = myVertices[VAXISTOP]; + } else if ((MeridianOnAxis(myVMax) || !HasSides()) && VerticesBuilt[VTOPEND]) + { myVertices[VTOPSTART] = myVertices[VTOPEND]; + } else if (MeridianClosed() && VerticesBuilt[VBOTSTART]) + { myVertices[VTOPSTART] = myVertices[VBOTSTART]; + } else if ((MeridianClosed() && !HasSides()) && VerticesBuilt[VBOTEND]) + { myVertices[VTOPSTART] = myVertices[VBOTEND]; - + } else { gp_Pnt2d mp = MeridianValue(myVMax); @@ -1315,14 +1416,21 @@ const TopoDS_Vertex& BRepPrim_OneAxis::TopEndVertex() // deduct from others if (MeridianOnAxis(myVMax) && VerticesBuilt[VAXISTOP]) + { myVertices[VTOPEND] = myVertices[VAXISTOP]; + } else if ((MeridianOnAxis(myVMax) || !HasSides()) && VerticesBuilt[VTOPSTART]) + { myVertices[VTOPEND] = myVertices[VTOPSTART]; + } else if (MeridianClosed() && VerticesBuilt[VBOTEND]) + { myVertices[VTOPEND] = myVertices[VBOTEND]; + } else if ((MeridianClosed() && !HasSides()) && VerticesBuilt[VBOTSTART]) + { myVertices[VTOPEND] = myVertices[VBOTSTART]; - + } else { gp_Pnt2d mp = MeridianValue(myVMax); @@ -1352,14 +1460,21 @@ const TopoDS_Vertex& BRepPrim_OneAxis::BottomStartVertex() // deduct from others if (MeridianOnAxis(myVMin) && VerticesBuilt[VAXISBOT]) + { myVertices[VBOTSTART] = myVertices[VAXISBOT]; + } else if ((MeridianOnAxis(myVMin) || !HasSides()) && VerticesBuilt[VBOTEND]) + { myVertices[VBOTSTART] = myVertices[VBOTEND]; + } else if (MeridianClosed() && VerticesBuilt[VTOPSTART]) + { myVertices[VBOTSTART] = myVertices[VTOPSTART]; + } else if ((MeridianClosed() && !HasSides()) && VerticesBuilt[VTOPEND]) + { myVertices[VBOTSTART] = myVertices[VTOPEND]; - + } else { gp_Pnt2d mp = MeridianValue(myVMin); @@ -1388,14 +1503,21 @@ const TopoDS_Vertex& BRepPrim_OneAxis::BottomEndVertex() // deduct from others if (MeridianOnAxis(myVMin) && VerticesBuilt[VAXISBOT]) + { myVertices[VBOTEND] = myVertices[VAXISBOT]; + } else if ((MeridianOnAxis(myVMin) || !HasSides()) && VerticesBuilt[VBOTSTART]) + { myVertices[VBOTEND] = myVertices[VBOTSTART]; + } else if (MeridianClosed() && VerticesBuilt[VTOPEND]) + { myVertices[VBOTEND] = myVertices[VTOPEND]; + } else if (MeridianClosed() && !HasSides() && VerticesBuilt[VTOPSTART]) + { myVertices[VBOTEND] = myVertices[VTOPSTART]; - + } else { gp_Pnt2d mp = MeridianValue(myVMin); diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeBox.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeBox.cxx index 8516a561a2..3655f95e26 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeBox.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeBox.cxx @@ -26,11 +26,17 @@ inline gp_Pnt pmin(const gp_Pnt& p, const double dx, const double dy, const doub { gp_Pnt P = p; if (dx < 0) + { P.SetX(P.X() + dx); + } if (dy < 0) + { P.SetY(P.Y() + dy); + } if (dz < 0) + { P.SetZ(P.Z() + dz); + } return P; } diff --git a/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeHalfSpace.cxx b/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeHalfSpace.cxx index 19acbcc959..9ddaf5197c 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeHalfSpace.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepPrimAPI/BRepPrimAPI_MakeHalfSpace.cxx @@ -39,7 +39,9 @@ static gp_Dir getNormalOnFace(const TopoDS_Face& theFace, const double theU, con BRepLProp_SLProps aProps(BRepAdaptor_Surface(theFace), theU, theV, 2, aPrec); gp_Dir aNormal = aProps.Normal(); if (theFace.Orientation() == TopAbs_REVERSED) + { aNormal.Reverse(); + } return aNormal; } @@ -131,7 +133,9 @@ static bool FindExtrema(const gp_Pnt& thePnt, BRepExtrema_DistShapeShape ext(aRefVertex, theShape); if (!ext.IsDone() || ext.NbSolution() == 0) + { return false; + } // the point projection exist int nbext = ext.NbSolution(); @@ -159,14 +163,18 @@ static bool FindExtrema(const gp_Pnt& thePnt, ext.ParOnEdgeS2(iext, aPar); TopoDS_Edge aE = TopoDS::Edge(ext.SupportOnShape2(iext)); if (getNormalFromEdge(theShape, aE, aPar, theNormal)) + { return true; + } } else if (ext.SupportTypeShape2(iext) == BRepExtrema_IsVertex) { theMinPnt = ext.PointOnShape2(iext); TopoDS_Vertex aV = TopoDS::Vertex(ext.SupportOnShape2(iext)); if (getNormalFromVertex(theShape, aV, theNormal)) + { return true; + } } } return false; diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx index 2704b86216..7026809e6e 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx @@ -62,7 +62,9 @@ BRepSweep_NumLinearRegularSweep::~BRepSweep_NumLinearRegularSweep() = default; TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape() { if (HasShape(myGenShape, myDirWire)) + { return Shape(myGenShape, myDirWire); + } else { TopoDS_Shape bidon; @@ -78,7 +80,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape() TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape(const TopoDS_Shape& aGenS) { if (myGenShapeTool.Index(aGenS) != 0 && HasShape(aGenS, myDirWire)) + { return Shape(aGenS, myDirWire); + } else { TopoDS_Shape bidon; @@ -380,7 +384,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape(const TopoDS_Shape& aGenS, TopAbs_Orientation ShellOri = DirectSolid(aGenS, aDirS); Lt.Init(temp); if (Lt.More()) + { Lt.Next(); + } if (Lt.More()) { for (Lt.Init(temp); Lt.More(); Lt.Next()) @@ -389,7 +395,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape(const TopoDS_Shape& aGenS, } } else + { myBuilder.Add(myShapes(iGenS, iDirS), newShell, ShellOri); + } } } else if (myDirShapeTool.Type(aDirS) == TopAbs_WIRE) @@ -445,7 +453,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape(const TopoDS_Shape& aGenS, // Change the "Closed" flag only for Wires and Shells if (myShapes(iGenS, iDirS).ShapeType() == TopAbs_WIRE || myShapes(iGenS, iDirS).ShapeType() == TopAbs_SHELL) + { myShapes(iGenS, iDirS).Closed(BRep_Tool::IsClosed(myShapes(iGenS, iDirS))); + } return myShapes(iGenS, iDirS); } @@ -460,7 +470,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::FirstShape() if (myDirShapeTool.HasFirstVertex()) { if (HasShape(myGenShape, myDirShapeTool.FirstVertex())) + { result = Shape(myGenShape, myDirShapeTool.FirstVertex()); + } } return result; } @@ -476,7 +488,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::LastShape() if (myDirShapeTool.HasLastVertex()) { if (HasShape(myGenShape, myDirShapeTool.LastVertex())) + { result = Shape(myGenShape, myDirShapeTool.LastVertex()); + } } return result; } @@ -492,7 +506,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::FirstShape(const TopoDS_Shape& aGe if (myDirShapeTool.HasFirstVertex()) { if (HasShape(aGenS, myDirShapeTool.FirstVertex())) + { result = Shape(aGenS, myDirShapeTool.FirstVertex()); + } } return result; } @@ -508,7 +524,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::LastShape(const TopoDS_Shape& aGen if (myDirShapeTool.HasLastVertex()) { if (HasShape(aGenS, myDirShapeTool.LastVertex())) + { result = Shape(aGenS, myDirShapeTool.LastVertex()); + } } return result; } diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Revol.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Revol.cxx index de33c3c62e..2a7aa86162 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Revol.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Revol.cxx @@ -123,7 +123,9 @@ gp_Ax1 BRepSweep_Revol::Axe(const gp_Ax1& Ax, const double D) const { gp_Ax1 A = Ax; if (D < 0.) + { A.Reverse(); + } return A; } diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Rotation.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Rotation.cxx index 3b83acc82e..91c1d4f9f5 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Rotation.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Rotation.cxx @@ -74,7 +74,9 @@ static double ComputeTolerance(TopoDS_Edge& E, { if (BRep_Tool::Degenerated(E)) + { return BRep_Tool::Tolerance(E); + } double first, last; @@ -99,11 +101,15 @@ static double ComputeTolerance(TopoDS_Edge& E, } double temp = Pc3d.SquareDistance(Pcons); if (temp > d2) + { d2 = temp; + } } d2 = 1.5 * sqrt(d2); if (d2 < 1.e-7) + { d2 = 1.e-7; + } return d2; } @@ -119,15 +125,23 @@ static void SetThePCurve(const BRep_Builder& B, TopLoc_Location SL; occ::handle GP = occ::down_cast(BRep_Tool::Surface(F, SL)); if (GP.IsNull()) + { OC = BRep_Tool::CurveOnSurface(E, F, f, l); + } if (OC.IsNull()) + { B.UpdateEdge(E, C, F, ComputeTolerance(E, F, C)); + } else { if (O == TopAbs_REVERSED) + { B.UpdateEdge(E, OC, C, F, ComputeTolerance(E, F, C)); + } else + { B.UpdateEdge(E, C, OC, F, ComputeTolerance(E, F, C)); + } } } @@ -158,7 +172,9 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex(const TopoDS_Shape& aGenV, gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV)); TopoDS_Vertex V; if (aDirV.Index() == 2) + { P.Transform(myLocation.Transformation()); + } ////// modified by jgv, 1.10.01, for buc61005 ////// // myBuilder.Builder().MakeVertex(V,P,Precision::Confusion()); myBuilder.Builder().MakeVertex(V, P, BRep_Tool::Tolerance(TopoDS::Vertex(aGenV))); @@ -226,7 +242,9 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyGeneratingEdge(const TopoDS_Shape& a { C->Transform(Loc.Transformation()); if (aDirV.Index() == 2) + { C->Transform(myLocation.Transformation()); + } } myBuilder.Builder().MakeEdge(E, C, BRep_Tool::Tolerance(TopoDS::Edge(aGenE))); } @@ -358,7 +376,9 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyFace(const TopoDS_Shape& aGenS, S = occ::down_cast(S->Copy()); S->Transform(Tr); if (aDirS.Index() == 2) + { S->Transform(myLocation.Transformation()); + } } myBuilder.Builder().MakeFace(F, S, toler); return F; @@ -447,7 +467,9 @@ void BRepSweep_Rotation::SetGeneratingPCurve(const TopoDS_Shape& aNewFace, // u = 0.; v = ElCLib::InPeriod(v, 0., 2 * M_PI); if ((2 * M_PI - v) <= Precision::PConfusion()) + { v -= 2 * M_PI; + } if (aDirV.Index() == 2) { double uLeft = u - myAng; @@ -472,7 +494,9 @@ void BRepSweep_Rotation::SetGeneratingPCurve(const TopoDS_Shape& aNewFace, ElSLib::SphereParameters(sph.Position(), sph.Radius(), point, u, v); u = 0.; if (aDirV.Index() == 2) + { u = myAng; + } pnt2d.SetCoord(u, v - U); L.SetLocation(pnt2d); L.SetDirection(gp::DY2d()); @@ -481,7 +505,9 @@ void BRepSweep_Rotation::SetGeneratingPCurve(const TopoDS_Shape& aNewFace, { double anAngleTemp = 0; if (aDirV.Index() == 2) + { anAngleTemp = myAng; + } L.SetLocation(gp_Pnt2d(anAngleTemp, 0)); L.SetDirection(gp::DY2d()); } @@ -785,16 +811,22 @@ bool BRepSweep_Rotation::HasShape(const TopoDS_Shape& aGenS, const Sweep_NumShap const TopoDS_Edge& anEdge = TopoDS::Edge(aGenS); // if (BRep_Tool::Degenerated(anEdge)) + { return false; + } double aPFirst, aPLast; TopLoc_Location aLoc; occ::handle aCurve = BRep_Tool::Curve(anEdge, aLoc, aPFirst, aPLast); if (aCurve.IsNull()) + { return false; + } if (IsInvariant(aGenS)) + { return false; + } // Check seem edge TopExp_Explorer FaceExp(myGenShape, TopAbs_FACE); @@ -802,7 +834,9 @@ bool BRepSweep_Rotation::HasShape(const TopoDS_Shape& aGenS, const Sweep_NumShap { TopoDS_Face F = TopoDS::Face(FaceExp.Current()); if (BRepTools::IsReallyClosed(anEdge, F)) + { return false; + } } return true; @@ -828,7 +862,9 @@ bool BRepSweep_Rotation::IsInvariant(const TopoDS_Shape& aGenS) const if (IsInvariant(V1) && IsInvariant(V2)) { if (aC.GetType() == GeomAbs_Line) + { return true; + } double aTol = std::max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2)); gp_Lin Lin(myAxe.Location(), myAxe.Direction()); @@ -838,7 +874,9 @@ bool BRepSweep_Rotation::IsInvariant(const TopoDS_Shape& aGenS) const for (int i = aPoles.Lower(); i <= aPoles.Upper(); i++) { if (Lin.Distance(aPoles(i)) > aTol) + { return false; + } } return true; } diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Tool.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Tool.cxx index bca7333609..6fb3544719 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Tool.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Tool.cxx @@ -37,7 +37,9 @@ int BRepSweep_Tool::NbShapes() const int BRepSweep_Tool::Index(const TopoDS_Shape& aShape) const { if (!myMap.Contains(aShape)) + { return 0; + } return myMap.FindIndex(aShape); } diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Translation.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Translation.cxx index e889385a0f..63989af272 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Translation.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Translation.cxx @@ -61,15 +61,23 @@ static void SetThePCurve(const BRep_Builder& B, TopLoc_Location SL; occ::handle GP = occ::down_cast(BRep_Tool::Surface(F, SL)); if (GP.IsNull()) + { OC = BRep_Tool::CurveOnSurface(E, F, f, l); + } if (OC.IsNull()) + { B.UpdateEdge(E, C, F, Precision::Confusion()); + } else { if (O == TopAbs_REVERSED) + { B.UpdateEdge(E, OC, C, F, Precision::Confusion()); + } else + { B.UpdateEdge(E, C, OC, F, Precision::Confusion()); + } } } @@ -100,7 +108,9 @@ TopoDS_Shape BRepSweep_Translation::MakeEmptyVertex(const TopoDS_Shape& aGenV, Standard_ConstructionError_Raise_if(!myCopy, "BRepSweep_Translation::MakeEmptyVertex"); gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV)); if (aDirV.Index() == 2) + { P.Transform(myLocation.Transformation()); + } TopoDS_Vertex V; ////// modified by jgv, 5.10.01, for buc61008 ////// // myBuilder.Builder().MakeVertex(V,P,Precision::Confusion()); @@ -146,7 +156,9 @@ TopoDS_Shape BRepSweep_Translation::MakeEmptyGeneratingEdge(const TopoDS_Shape& C = occ::down_cast(C->Copy()); C->Transform(L.Transformation()); if (aDirV.Index() == 2) + { C->Transform(myLocation.Transformation()); + } } myBuilder.Builder().MakeEdge(newE, C, BRep_Tool::Tolerance(TopoDS::Edge(aGenE))); } @@ -180,7 +192,9 @@ void BRepSweep_Translation::SetDirectingParameter(const TopoDS_Shape& aNewEdge, { double param = 0; if (aDirV.Index() == 2) + { param = myVec.Magnitude(); + } myBuilder.Builder().UpdateVertex(TopoDS::Vertex(aNewVertex), param, TopoDS::Edge(aNewEdge), @@ -256,7 +270,9 @@ TopoDS_Shape BRepSweep_Translation::MakeEmptyFace(const TopoDS_Shape& aGenS, S = occ::down_cast(S->Copy()); S->Transform(Tr); if (aDirS.Index() == 2) + { S->Translate(myVec); + } } myBuilder.Builder().MakeFace(F, S, toler); return F; @@ -350,7 +366,9 @@ void BRepSweep_Translation::SetGeneratingPCurve(const TopoDS_Shape& aNewFace, { double v = 0; if (aDirV.Index() == 2) + { v = -myVec.Magnitude(); + } L.SetLocation(gp_Pnt2d(0, v)); L.SetDirection(gp_Dir2d(gp_Dir2d::D::X)); // } @@ -488,7 +506,9 @@ bool BRepSweep_Translation::HasShape(const TopoDS_Shape& aGenS, const Sweep_NumS { TopoDS_Face F = TopoDS::Face(FaceExp.Current()); if (BRepTools::IsReallyClosed(E, F)) + { return false; + } } // modified by NIZHNY-EAP Fri Dec 24 11:13:21 1999 ___END___ } diff --git a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Trsf.cxx b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Trsf.cxx index d07330038a..167867c0ce 100644 --- a/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Trsf.cxx +++ b/src/ModelingAlgorithms/TKPrim/BRepSweep/BRepSweep_Trsf.cxx @@ -74,13 +74,17 @@ bool BRepSweep_Trsf::Process(const TopoDS_Shape& aGenS, const Sweep_NumShape& aD for (Jt.Init(aGenS); Jt.More(); Jt.Next()) { if (Process(Jt.Value(), aDirV)) + { touch = true; + } } if (!touch || !dotrsf) { TopoDS_Shape newShape = aGenS; if (dotrsf) + { newShape.Move(myLocation); + } myShapes(iG, iD) = newShape; myBuiltShapes(iG, iD) = true; } diff --git a/src/ModelingAlgorithms/TKPrim/Sweep/Sweep_NumShapeTool.cxx b/src/ModelingAlgorithms/TKPrim/Sweep/Sweep_NumShapeTool.cxx index c443c41b00..11e5503b7d 100644 --- a/src/ModelingAlgorithms/TKPrim/Sweep/Sweep_NumShapeTool.cxx +++ b/src/ModelingAlgorithms/TKPrim/Sweep/Sweep_NumShapeTool.cxx @@ -100,7 +100,9 @@ TopAbs_Orientation Sweep_NumShapeTool::Orientation(const Sweep_NumShape& aShape) bool Sweep_NumShapeTool::HasFirstVertex() const { if (myNumShape.Type() == TopAbs_EDGE) + { return !myNumShape.BegInfinite(); + } return true; } @@ -109,7 +111,9 @@ bool Sweep_NumShapeTool::HasFirstVertex() const bool Sweep_NumShapeTool::HasLastVertex() const { if (myNumShape.Type() == TopAbs_EDGE) + { return !myNumShape.EndInfinite(); + } return true; } @@ -124,7 +128,9 @@ Sweep_NumShape Sweep_NumShapeTool::FirstVertex() const return Sweep_NumShape(1, TopAbs_VERTEX, myNumShape.Closed(), false, false); } else + { throw Standard_ConstructionError("infinite Shape"); + } } return myNumShape; } @@ -140,7 +146,9 @@ Sweep_NumShape Sweep_NumShapeTool::LastVertex() const return Sweep_NumShape(NbShapes() - 1, TopAbs_VERTEX, myNumShape.Closed(), false, false); } else + { throw Standard_ConstructionError("infinite Shape"); + } } return myNumShape; } diff --git a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeBuild_ReShape_Test.cxx b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeBuild_ReShape_Test.cxx index a1761e4506..3b85f60839 100644 --- a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeBuild_ReShape_Test.cxx +++ b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeBuild_ReShape_Test.cxx @@ -65,7 +65,9 @@ TEST(ShapeBuild_ReShapeTest, Apply_PerformsVertexReplacementOnCompound) for (TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) { if (anIt.Value().TShape() == aV2Repl.TShape()) + { aFoundReplacement = true; + } EXPECT_FALSE(anIt.Value().TShape() == aV2.TShape()); } EXPECT_TRUE(aFoundReplacement); @@ -161,9 +163,13 @@ TEST(ShapeBuild_ReShapeTest, Apply_DiamondSharedVertexInTwoCompounds) for (TopExp_Explorer anExp(aResult, TopAbs_VERTEX); anExp.More(); anExp.Next()) { if (anExp.Current().TShape() == aSharedNew.TShape()) + { ++aNbReplVerts; + } if (anExp.Current().TShape() == aShared.TShape()) + { ++aNbOriginals; + } } EXPECT_EQ(aNbOriginals, 0) << "Original vertex must be substituted everywhere"; EXPECT_EQ(aNbReplVerts, 2) << "Replacement must appear in both parentA and parentB"; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo.cxx index db56ac84b0..216147e4b2 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo.cxx @@ -25,7 +25,9 @@ void ShapeAlgo::Init() { static bool init = false; if (init) + { return; + } init = true; theContainer = new ShapeAlgo_AlgoContainer; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo_AlgoContainer.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo_AlgoContainer.cxx index 34645dc775..c617c65717 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo_AlgoContainer.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAlgo/ShapeAlgo_AlgoContainer.cxx @@ -68,7 +68,9 @@ bool ShapeAlgo_AlgoContainer::ConnectNextWire(const occ::handleNbEdges() == 0) + { return true; + } occ::handle sewd = saw->WireData(); // add edges into empty WireData @@ -104,7 +106,9 @@ bool ShapeAlgo_AlgoContainer::ConnectNextWire(const occ::handleLastCheckStatus(ShapeExtend_FAIL); if (OK) + { sewd->Add(nextsewd); + } return OK; } @@ -510,9 +514,13 @@ bool ShapeAlgo_AlgoContainer::HomoWires(const TopoDS_Wire& wireIn1, bool IsToReverse1 = false; bool IsToReverse2 = false; if (edge1.Orientation() == TopAbs_REVERSED) + { IsToReverse1 = true; + } if (edge2.Orientation() == TopAbs_REVERSED) + { IsToReverse2 = true; + } crv1 = BRep_Tool::Curve(edge1, loc1, first1, last1); crv2 = BRep_Tool::Curve(edge2, loc2, first2, last2); delta1 = last1 - first1; @@ -579,9 +587,13 @@ bool ShapeAlgo_AlgoContainer::HomoWires(const TopoDS_Wire& wireIn1, edge1.Move(loc1); edge2.Move(loc2); if (IsToReverse1) + { edge1.Reverse(); + } if (IsToReverse2) + { edge2.Reverse(); + } makeWire1.Add(edge1); makeWire2.Add(edge2); @@ -589,7 +601,9 @@ bool ShapeAlgo_AlgoContainer::HomoWires(const TopoDS_Wire& wireIn1, { TopoDS_Iterator Copernic = Cook; if (Copernic.More()) + { Copernic.Next(); + } if (!Copernic.More()) { wireOut1 = makeWire1.Wire(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis.cxx index 9ceafe0272..2a94b7c20a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis.cxx @@ -51,9 +51,13 @@ double ShapeAnalysis::AdjustByPeriod(const double Val, const double ToVal, const double D = std::abs(diff); double P = std::abs(Period); if (D <= 0.5 * P) + { return 0.; + } if (P < 1e-100) + { return diff; + } return (diff > 0 ? -P : P) * floor(D / P + 0.5); } @@ -92,7 +96,9 @@ void ShapeAnalysis::FindBounds(const TopoDS_Shape& shape, TopoDS_Vertex& V1, Top V2 = EA.LastVertex(TopoDS::Edge(shape)); } else if (shape.ShapeType() == TopAbs_VERTEX) + { V1 = V2 = TopoDS::Vertex(shape); + } } //================================================================================================= @@ -122,7 +128,9 @@ double ShapeAnalysis::TotCross2D(const occ::handle& sewd, NCollection_Sequence SeqPnt; ShapeAnalysis_Curve::GetSamplePoints(c2d, f2d, l2d, SeqPnt); if (edge.Orientation() == 1) + { ReverseSeq(SeqPnt); + } if (nbc == 1) { fuv = SeqPnt.Value(1); @@ -163,10 +171,14 @@ double ShapeAnalysis::ContourArea(const TopoDS_Wire& theWire) NCollection_Sequence aSeqPnt; if (!ShapeAnalysis_Curve::GetSamplePoints(c3d, first, last, aSeqPnt)) + { continue; + } nbc++; if (edge.Orientation() == TopAbs_REVERSED) + { ReverseSeq(aSeqPnt); + } if (nbc == 1) { fuv = aSeqPnt.Value(1); @@ -236,13 +248,17 @@ TopoDS_Wire ShapeAnalysis::OuterWire(const TopoDS_Face& theFace) // if current wire is the last one, return it without analysis if (!anIt.More()) + { return aWire; + } // Check if the wire has positive area occ::handle aSEWD = new ShapeExtend_WireData(aWire); double anArea2d = ShapeAnalysis::TotCross2D(aSEWD, aF); if (anArea2d >= 0.) + { return aWire; + } } return TopoDS_Wire(); } @@ -274,7 +290,9 @@ void ShapeAnalysis::GetFaceUVBounds(const TopoDS_Face& F, occ::handle c2d; double f, l; if (!sae.PCurve(edge, F, c2d, f, l, false)) + { continue; + } sac.FillBndBox(c2d, f, l, 20, true, B); } B.Get(UMin, VMin, UMax, VMax); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx index f8e80fadee..9a6f66730a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx @@ -38,11 +38,15 @@ bool ShapeAnalysis_BoxBndTreeSelector::Reject(const Bnd_Box& theBnd) const bool ShapeAnalysis_BoxBndTreeSelector::Accept(const int& theObj) { if (theObj < 1 || theObj > mySeq->Length()) + { throw Standard_NoSuchObject( "ShapeAnalysis_BoxBndTreeSelector::Accept : no such object for current index"); + } bool IsAccept = false; if (myList.Contains(theObj)) + { return false; + } enum { @@ -86,7 +90,9 @@ bool ShapeAnalysis_BoxBndTreeSelector::Accept(const int& theObj) myArrIndices(First) = theObj; } else + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } } } } @@ -95,11 +101,15 @@ bool ShapeAnalysis_BoxBndTreeSelector::Accept(const int& theObj) { SetNb(theObj); if (myArrIndices(Last)) + { myStop = true; + } return true; } else + { myStop = false; + } } else @@ -128,13 +138,17 @@ bool ShapeAnalysis_BoxBndTreeSelector::Accept(const int& theObj) double min3d; min3d = std::min(dm1, dm2); if (min3d > myMin3d) + { return false; + } int minInd = (dm1 > dm2 ? First : Last); int maxInd = (dm1 > dm2 ? Last : First); myArrIndices(minInd) = theObj; if ((min3d - myMin3d) > RealSmall()) + { myArrIndices(maxInd) = 0; + } myMin3d = min3d; if (min3d > myTol) @@ -147,7 +161,9 @@ bool ShapeAnalysis_BoxBndTreeSelector::Accept(const int& theObj) SetNb(anObj); if (min3d == 0 && minInd == Last) + { myStop = true; + } if (dm1 > dm2) { diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CanonicalRecognition.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CanonicalRecognition.cxx index 4dd732f453..562d4f426e 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CanonicalRecognition.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CanonicalRecognition.cxx @@ -162,14 +162,18 @@ bool ShapeAnalysis_CanonicalRecognition::IsElementarySurf(const GeomAbs_SurfaceT NCollection_Array1& theParams) { if (myStatus != 0) + { return false; + } // if (mySType == TopAbs_FACE) { occ::handle anElemSurf = GetSurface(TopoDS::Face(myShape), theTol, GeomConvert_Target, theTarget, myGap, myStatus); if (anElemSurf.IsNull()) + { return false; + } // bool isOK = SetSurfParams(theTarget, anElemSurf, thePos, theParams); if (!isOK) @@ -262,7 +266,9 @@ bool ShapeAnalysis_CanonicalRecognition::IsPlane(const double theTol, gp_Pln& th return true; } else + { myStatus = 1; + } } return false; } @@ -416,7 +422,9 @@ bool ShapeAnalysis_CanonicalRecognition::IsConic(const GeomAbs_CurveType the NCollection_Array1& theParams) { if (myStatus != 0) + { return false; + } if (mySType == TopAbs_EDGE) { @@ -424,7 +432,9 @@ bool ShapeAnalysis_CanonicalRecognition::IsConic(const GeomAbs_CurveType the GetCurve(TopoDS::Edge(myShape), theTol, GeomConvert_Target, theTarget, myGap, myStatus); if (aConic.IsNull()) + { return false; + } bool isOK = SetConicParameters(theTarget, aConic, thePos, theParams); @@ -567,10 +577,14 @@ occ::handle ShapeAnalysis_CanonicalRecognition::GetSurface( aConv.SetTarget(theTarget); occ::handle anAnaSurf = aConv.ConvertToAnalytical(theTol); if (anAnaSurf.IsNull()) + { return anAnaSurf; + } // if (!aLoc.IsIdentity()) + { anAnaSurf->Transform(aLoc.Transformation()); + } // theGap = aConv.Gap(); return anAnaSurf; @@ -667,10 +681,14 @@ occ::handle ShapeAnalysis_CanonicalRecognition::GetSurface( aConv.SetTarget(theTarget); occ::handle anAnaSurf = aConv.ConvertToAnalytical(theTol); if (anAnaSurf.IsNull()) + { continue; + } // if (!aLoc.IsIdentity()) + { anAnaSurf->Transform(aLoc.Transformation()); + } // aGaps.Append(aConv.Gap()); aSurfs.Append(anAnaSurf); @@ -801,7 +819,9 @@ bool ShapeAnalysis_CanonicalRecognition::GetSurfaceByLS(const TopoDS_Wire& occ::handle> aPoints; int aNbMaxInt = 100; if (!GetSamplePoints(theWire, theTol, aNbMaxInt, aPoints)) + { return false; + } theGap = GetLSGap(aPoints, theTarget, thePos, theParams); if (theGap <= theTol) @@ -812,13 +832,21 @@ bool ShapeAnalysis_CanonicalRecognition::GetSurfaceByLS(const TopoDS_Wire& int aNbVar = 0; if (theTarget == GeomAbs_Sphere) + { aNbVar = 4; + } else if (theTarget == GeomAbs_Cylinder) + { aNbVar = 4; + } else if (theTarget == GeomAbs_Cone) + { aNbVar = 5; + } else + { return false; + } math_Vector aFBnd(1, aNbVar), aLBnd(1, aNbVar), aStartPoint(1, aNbVar); @@ -849,7 +877,9 @@ bool ShapeAnalysis_CanonicalRecognition::GetSurfaceByLS(const TopoDS_Wire& aPFunc = (math_MultipleVarFunction*)&aFuncCon; } else + { aPFunc = nullptr; + } // math_Vector aSteps(1, aNbVar); int aNbInt = 10; @@ -872,7 +902,9 @@ bool ShapeAnalysis_CanonicalRecognition::GetSurfaceByLS(const TopoDS_Wire& // math_Matrix aDirMatrix(1, aNbVar, 1, aNbVar, 0.0); for (i = 1; i <= aNbVar; i++) + { aDirMatrix(i, i) = 1.0; + } if (theTarget == GeomAbs_Cylinder || theTarget == GeomAbs_Cone) { @@ -902,10 +934,14 @@ bool ShapeAnalysis_CanonicalRecognition::GetSurfaceByLS(const TopoDS_Wire& theGap = GetLSGap(aPoints, theTarget, thePos, theParams); theStatus = 0; if (theGap <= theTol) + { return true; + } } else + { theStatus = 1; + } return false; } @@ -935,10 +971,14 @@ occ::handle ShapeAnalysis_CanonicalRecognition::GetCurve( occ::handle anAnaCurv; aConv.ConvertToAnalytical(theTol, anAnaCurv, f, l, nf, nl); if (anAnaCurv.IsNull()) + { return anAnaCurv; + } // if (!aLoc.IsIdentity()) + { anAnaCurv->Transform(aLoc.Transformation()); + } // theGap = aConv.Gap(); return anAnaCurv; @@ -1002,10 +1042,14 @@ bool SetConicParameters(const GeomAbs_CurveType theTarget, NCollection_Array1& theParams) { if (theConic.IsNull()) + { return false; + } GeomAdaptor_Curve aGAC(theConic); if (aGAC.GetType() != theTarget) + { return false; + } if (theTarget == GeomAbs_Line) { @@ -1026,7 +1070,9 @@ bool SetConicParameters(const GeomAbs_CurveType theTarget, theParams(2) = anElips.MinorRadius(); } else + { return false; + } return true; } @@ -1044,13 +1090,17 @@ bool CompareConicParams(const GeomAbs_CurveType theTarget, for (i = 1; i <= aNbPars; ++i) { if (std::abs(theRefParams(i) - theParams(i)) > theTol) + { return false; + } } double anAngTol = theTol / (2. * M_PI); double aTol = theTol; if (theTarget == GeomAbs_Line) + { aTol = Precision::Infinite(); + } const gp_Ax1& aRef = theRefPos.Axis(); const gp_Ax1& anAx1 = thePos.Axis(); @@ -1068,14 +1118,20 @@ bool SetSurfParams(const GeomAbs_SurfaceType theTarget, { // if (theElemSurf.IsNull()) + { return false; + } GeomAdaptor_Surface aGAS(theElemSurf); if (aGAS.GetType() != theTarget) + { return false; + } double aNbPars = GetNbPars(theTarget); if (theParams.Length() < aNbPars) + { return false; + } if (theTarget == GeomAbs_Plane) { @@ -1205,7 +1261,9 @@ bool GetSamplePoints(const TopoDS_Wire& theWire, { const TopoDS_Edge& anE = TopoDS::Edge(anEIter.Value()); if (BRep_Tool::Degenerated(anE)) + { continue; + } BRepAdaptor_Curve aBAC(anE); double aClength = GCPnts_AbscissaPoint::Length(aBAC, aTol); aTotalLength += aClength; @@ -1214,7 +1272,9 @@ bool GetSamplePoints(const TopoDS_Wire& theWire, } if (aTotalLength < theTol) + { return false; + } int i, aNb = aLengths.Length(); for (i = 0; i < aNb; ++i) @@ -1225,7 +1285,9 @@ bool GetSamplePoints(const TopoDS_Wire& theWire, aNbPoints = std::max(2, aNbPoints); GCPnts_QuasiUniformAbscissa aPointGen(aC, aNbPoints); if (!aPointGen.IsDone()) + { continue; + } aNbPoints = aPointGen.NbPoints(); int j; for (j = 1; j <= aNbPoints; ++j) @@ -1237,7 +1299,9 @@ bool GetSamplePoints(const TopoDS_Wire& theWire, } if (aPoints.Length() < 1) + { return false; + } thePoints = new NCollection_HArray1(1, aPoints.Length()); for (i = 0; i < aPoints.Length(); ++i) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx index be94e8f6de..00a5eaf6b3 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx @@ -84,17 +84,29 @@ static void MinMaxPnt(const gp_Pnt& p, else { if (minx > x) + { minx = x; + } if (maxx < x) + { maxx = x; + } if (miny > y) + { miny = y; + } if (maxy < y) + { maxy = y; + } if (minz > z) + { minz = z; + } if (maxz < z) + { maxz = z; + } } nb++; } @@ -134,7 +146,9 @@ int ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F, for (TopoDS_Iterator itw(F, false); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire w1 = TopoDS::Wire(itw.Value()); if (!w1.IsNull()) { @@ -143,7 +157,9 @@ int ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F, } } if (!isWir) + { return true; + } int nbv = 0; double minx = 0, miny = 0, minz = 0, maxx = Precision::Infinite(), maxy = Precision::Infinite(), maxz = Precision::Infinite(); @@ -153,11 +169,15 @@ int ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F, { TopoDS_Vertex V = TopoDS::Vertex(iv.Current()); if (V0.IsNull()) + { V0 = V; + } else if (same) { if (!V0.IsSame(V)) + { same = false; + } } gp_Pnt pnt = BRep_Tool::Pnt(V); @@ -168,13 +188,17 @@ int ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F, { tolv = BRep_Tool::Tolerance(V); if (tolv > toler) + { toler = tolv; + } } } // Now, testing if (!MinMaxSmall(minx, miny, minz, maxx, maxy, maxz, toler)) + { return 0; + } // All vertices are confused // Check edges (a closed edge may be a non-null length edge !) @@ -185,11 +209,15 @@ int ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F, double cf, cl; occ::handle C3D = BRep_Tool::Curve(E, cf, cl); if (C3D.IsNull()) + { continue; + } gp_Pnt debut = C3D->Value(cf); gp_Pnt milieu = C3D->Value((cf + cl) / 2); if (debut.SquareDistance(milieu) > toler * toler) + { return 0; + } } spot.SetCoord((minx + maxx) / 2., (miny + maxy) / 2., (minz + maxz) / 2.); @@ -209,7 +237,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckSpotFace(const TopoDS_Face& F, const dou double spotol; int stat = IsSpotFace(F, spot, spotol, tol); if (!stat) + { return false; + } switch (stat) { case 1: @@ -231,12 +261,16 @@ bool ShapeAnalysis_CheckSmallFace::IsStripSupport(const TopoDS_Face& F, const do double toler = tol; if (toler < 0) + { toler = 1.e-07; // ?? better to compute tolerance zones + } TopLoc_Location loc; occ::handle surf = BRep_Tool::Surface(F, loc); if (surf.IsNull()) + { return false; + } // Checking on poles for bezier-bspline // A more general way is to check Values by scanning ISOS (slower) @@ -322,7 +356,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckStripEdges(const TopoDS_Edge& E1, { double tole = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2); if (toler < tole / 2.) + { toler = tole / 2.; + } } // We project a list of points from each curve, on the opposite one, @@ -336,7 +372,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckStripEdges(const TopoDS_Edge& E1, C1 = BRep_Tool::Curve(E1, cf1, cl1); C2 = BRep_Tool::Curve(E2, cf2, cl2); if (C1.IsNull() || C2.IsNull()) + { return false; + } cf1 = std::max(cf1, C1->FirstParameter()); cl1 = std::min(cl1, C1->LastParameter()); occ::handle C1T = new Geom_TrimmedCurve(C1, cf1, cl1, true); @@ -377,11 +415,17 @@ bool ShapeAnalysis_CheckSmallFace::CheckStripEdges(const TopoDS_Edge& E1, double dist = SAC.Project(GAC, p1, toler, p2, para); // pdn check if parameter of projection is in the domain of the edge. if (para < f || para > l) + { return false; + } if (dist > dmax) + { dmax = dist; + } if (dist > toler) + { return false; + } u += cd1; } } @@ -403,7 +447,9 @@ bool ShapeAnalysis_CheckSmallFace::FindStripEdges(const TopoDS_Face& F, { TopoDS_Edge E = TopoDS::Edge(ex.Current()); if (nb == 1 && E.IsSame(E1)) + { continue; // ignore seam edge + } TopoDS_Vertex V1, V2; TopExp::Vertices(E, V1, V2); gp_Pnt p1, p2; @@ -411,7 +457,9 @@ bool ShapeAnalysis_CheckSmallFace::FindStripEdges(const TopoDS_Face& F, p2 = BRep_Tool::Pnt(V2); double toler = tol; if (toler <= 0) + { toler = (BRep_Tool::Tolerance(V1) + BRep_Tool::Tolerance(V2)) / 2.; + } // Extremities double dist = p1.Distance(p2); @@ -424,24 +472,36 @@ bool ShapeAnalysis_CheckSmallFace::FindStripEdges(const TopoDS_Face& F, { gp_Pnt pp = CC->Value((cf + cl) / 2.); if (pp.Distance(p1) < toler && pp.Distance(p2) < toler) + { continue; + } isNullLength = false; } if (dist <= toler && isNullLength) + { continue; // smh + } nb++; if (nb == 1) + { E1 = E; + } else if (nb == 2) + { E2 = E; + } else + { return false; + } } // Now, check these two edge to define a strip ! if (!E1.IsNull() && !E2.IsNull()) { if (!CheckStripEdges(E1, E2, tol, dmax)) + { return false; + } else { myStatusStrip = ShapeExtend::EncodeStatus(ShapeExtend_DONE3); @@ -469,15 +529,25 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, { TopoDS_Vertex V = TopoDS::Vertex(itv.Current()); if (V1.IsNull()) + { V1 = V; + } else if (V1.IsSame(V)) + { continue; + } else if (V2.IsNull()) + { V2 = V; + } else if (V2.IsSame(V)) + { continue; + } else + { return false; + } } // Checking edges @@ -487,7 +557,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, { TopoDS_Edge E = TopoDS::Edge(ite.Current()); if (nb == 1 && E.IsSame(E1)) + { continue; // ignore seam edge + } TopoDS_Vertex VA, VB; TopExp::Vertices(E, VA, VB); if (tol < 0) @@ -495,10 +567,14 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, double tolv; tolv = BRep_Tool::Tolerance(VA); if (toler < tolv) + { toler = tolv; + } tolv = BRep_Tool::Tolerance(VB); if (toler < tolv) + { toler = tolv; + } } // Edge on same vertex : small one ? @@ -507,9 +583,13 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, double cf = 0., cl = 0.; occ::handle C3D; if (!BRep_Tool::Degenerated(E)) + { C3D = BRep_Tool::Curve(E, cf, cl); + } if (C3D.IsNull()) + { continue; // DGNR + } int np = 0; gp_Pnt deb = C3D->Value(cf); MinMaxPnt(deb, np, minx, miny, minz, maxx, maxy, maxz); @@ -518,14 +598,18 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, gp_Pnt mid = C3D->Value((cf + cl) / 2.); MinMaxPnt(mid, np, minx, miny, minz, maxx, maxy, maxz); if (!MinMaxSmall(minx, miny, minz, maxx, maxy, maxz, toler)) + { return false; + } } else { // Other case : two maximum allowed nb++; if (nb > 2) + { return false; + } if (nb == 1) { V1 = VA; @@ -535,23 +619,33 @@ bool ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F, else if (nb == 2) { if (V1.IsSame(VA) && !V2.IsSame(VB)) + { return false; + } if (V1.IsSame(VB) && !V2.IsSame(VA)) + { return false; + } E2 = E; } else + { return false; + } } } if (nb < 2) + { return false; // only one vertex : cannot be a strip ... + } // Checking if E1 and E2 define a Strip double dmax; if (!CheckStripEdges(E1, E2, tol, dmax)) + { return false; + } myStatusStrip = ShapeExtend::EncodeStatus(ShapeExtend_DONE3); return true; } @@ -566,7 +660,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckStripFace(const TopoDS_Face& F, // int stat; if (CheckSingleStrip(F, E1, E2, tol)) + { return true; // it is a strip + } // IsStripSupport used as rejection. But this kind of test may be done // on ANY face, once we are SURE that FindStripEdges is reliable (and fast @@ -597,10 +693,14 @@ int ShapeAnalysis_CheckSmallFace::CheckSplittingVertices( // theBuilder.MakeCompound(theAllVert); TopExp_Explorer itv; // svv Jan11 2000 : porting on DEC for (itv.Init(F, TopAbs_VERTEX); itv.More(); itv.Next()) + { nbv++; + } if (nbv == 0) + { return 0; + } NCollection_Array1 vtx(1, nbv); NCollection_Array1 vtp(1, nbv); NCollection_Array1 vto(1, nbv); @@ -615,7 +715,9 @@ int ShapeAnalysis_CheckSmallFace::CheckSplittingVertices( vtp.SetValue(nbp, unp); double unt = myPrecision; if (unt < 0) + { unt = BRep_Tool::Tolerance(unv); + } vto.SetValue(nbp, unt); } nbv = nbp; @@ -637,27 +739,37 @@ int ShapeAnalysis_CheckSmallFace::CheckSplittingVertices( double cf, cl; occ::handle C3D = BRep_Tool::Curve(E, cf, cl); if (C3D.IsNull()) + { continue; + } if (V.IsSame(V1) || V.IsSame(V2)) + { continue; + } gp_Pnt unp = vtp.Value(iv); double unt = vto.Value(iv); gp_Pnt proj; double param; double dist = SAC.Project(C3D, unp, unt * 10., proj, param, cf, cl); if (dist == 0.0) + { continue; // smh + } // Splitting Vertex to record ? if (dist < unt) { // If Split occurs at beginning or end, it is not a split ... double fpar, lpar, eps = 1.e-06; if (param >= cl || param <= cf) + { continue; // Out of range + } fpar = param - cf; lpar = param - cl; if ((std::abs(fpar) < eps) || (std::abs(lpar) < eps)) + { continue; // Near end or start + } listEdge.Append(E); listParam.Append(param); issplit = true; @@ -672,7 +784,9 @@ int ShapeAnalysis_CheckSmallFace::CheckSplittingVertices( } } if (nbp != 0) + { myStatusSplitVert = ShapeExtend::EncodeStatus(ShapeExtend_DONE); + } return nbp; } @@ -689,14 +803,22 @@ static int IsoStat(const NCollection_Array2& poles, for (i = i0; i <= i1; i++) { if (uorv == 1) + { MinMaxPnt(poles(rank, i), np, xmin, ymin, zmin, xmax, ymax, zmax); + } else + { MinMaxPnt(poles(i, rank), np, xmin, ymin, zmin, xmax, ymax, zmax); + } } if (MinMaxSmall(xmin, ymin, zmin, xmax, ymax, zmax, tolpin)) + { return 0; + } if (MinMaxSmall(xmin, ymin, zmin, xmax, ymax, zmax, toler)) + { return 1; + } return 2; } @@ -709,10 +831,14 @@ static bool CheckPoles(const NCollection_Array2& poles, int uorv, int ra if (uorv == 1) { if (poles(rank, i).IsEqual(poles(rank, i + 1), 1e-15)) + { return true; + } } else if (poles(i, rank).IsEqual(poles(i + 1, rank), 1e-15)) + { return true; + } } return false; } @@ -724,11 +850,15 @@ bool ShapeAnalysis_CheckSmallFace::CheckPin(const TopoDS_Face& F, int& whatrow, TopLoc_Location loc; occ::handle surf = BRep_Tool::Surface(F, loc); if (surf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { return false; + } double toler = myPrecision; if (toler < 0) + { toler = 1.e-4; + } double tolpin = 1.e-9; // for sharp sharp pin // Checking the poles @@ -748,13 +878,19 @@ bool ShapeAnalysis_CheckSmallFace::CheckPin(const TopoDS_Face& F, int& whatrow, nbv = bz->NbVPoles(); } if (nbu == 0 || nbv == 0) + { return false; + } const NCollection_Array2* allpolesPtr = nullptr; if (!bs.IsNull()) + { allpolesPtr = &bs->Poles(); + } if (!bz.IsNull()) + { allpolesPtr = &bz->Poles(); + } const NCollection_Array2& allpoles = *allpolesPtr; // Check each natural bound if it is a singularity (i.e. a pin) @@ -791,7 +927,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckPin(const TopoDS_Face& F, int& whatrow, } if (!sens) + { return false; // no pin + } switch (stat) { @@ -811,7 +949,9 @@ bool ShapeAnalysis_CheckSmallFace::CheckPin(const TopoDS_Face& F, int& whatrow, // bool EqualPoles = false; if (CheckPoles(allpoles, 2, nbv) || CheckPoles(allpoles, 2, 1) || CheckPoles(allpoles, 1, nbu) || CheckPoles(allpoles, 1, 1)) + { myStatusPin = ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } } return true; @@ -836,11 +976,15 @@ bool ShapeAnalysis_CheckSmallFace::CheckTwisted(const TopoDS_Face& F, TopLoc_Location loc; occ::handle surf = BRep_Tool::Surface(F, loc); if (surf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { return false; + } double toler = myPrecision; if (toler < 0) + { toler = 1.e-4; + } //// GeomLProp_SLProps GLS (surf,2,toler); GeomAdaptor_Surface GAS(surf); @@ -938,9 +1082,13 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinFace( int nb = wi.NbEdges(); int i = 0; for (i = 1; i <= nb; i++) + { newedges->Append(sbwd->Edge(wi.Ordered(i))); + } for (i = 1; i <= nb; i++) + { sbwd->Set(TopoDS::Edge(newedges->Value(i)), i); + } // sfw.Init(theCurWire, F, Precision::Confusion()); // sfw.FixReorder(); // theCurWire = sfw.Wire(); @@ -962,17 +1110,27 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinFace( p1 = BRep_Tool::Pnt(V1); p2 = BRep_Tool::Pnt(V2); tol = std::max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2)); - if (toler > 0) // tol = std::max(tol, toler); gka + if (toler > 0) + { // tol = std::max(tol, toler); gka tol = toler; + } d1 = p1.Distance(p2); if (d1 == 0) + { return false; + } if (d1 / tol >= 1) + { coef1 = d1 / tol; + } else + { continue; + } if (coef1 <= 3) + { continue; + } i++; continue; } @@ -984,23 +1142,39 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinFace( p1 = BRep_Tool::Pnt(V1); p2 = BRep_Tool::Pnt(V2); if (toler == -1) + { tol = std::max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2)); + } else + { tol = toler; + } if (p1.Distance(p2) > tol) + { continue; + } // If there are two pin edges, record them in diagnostic d2 = p1.Distance(p2); // gka if (d2 == 0) + { return false; + } if (d2 / tol >= 1) + { coef2 = d2 / tol; + } else + { continue; + } if (coef2 <= 3) + { continue; + } if (coef1 > coef2 * 10) + { continue; + } if (coef2 > coef1 * 10) { theFirstEdge = theSecondEdge; @@ -1050,18 +1224,30 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinEdges(const TopoDS_Edge& theFirstEdge double paramc1 = 0, paramc2 = 0; // =0 for deleting warning (skl) TopoDS_Vertex theSharedV = TopExp::LastVertex(theFirstEdge); if (toler == -1) + { tol = BRep_Tool::Tolerance(theSharedV); + } else + { tol = toler; + } pv = BRep_Tool::Pnt(theSharedV); if (pv.Distance(p1) <= tol) + { paramc1 = cf1; + } else if (pv.Distance(p2) <= tol) + { paramc1 = cl1; + } if (pv.Distance(pp1) <= tol) + { paramc2 = cf2; + } else if (pv.Distance(pp2) <= tol) + { paramc2 = cl2; + } // Computing first derivative vectors and compare angle // gp_Vec V11, V12, V21, V22; // gp_Pnt tmp; @@ -1085,9 +1271,13 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinEdges(const TopoDS_Edge& theFirstEdge { C3 = C1; if (paramc1 == cf1) + { proj = C1->Value(paramc1 + (coef1 - 3) * d1); + } else + { proj = C1->Value(paramc1 - 3 * d1); + } // proj = C1->Value(paramc1 + 9*d1); // else proj = C1->Value(paramc1-d1); } @@ -1095,9 +1285,13 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinEdges(const TopoDS_Edge& theFirstEdge { C3 = C2; if (paramc2 == cf2) + { proj = C2->Value(paramc2 + (coef2 - 3) * d2); + } else + { proj = C2->Value(paramc2 - 3 * d2); + } // proj = C2->Value(paramc2 + 9*d2); // else proj = C2->Value(paramc2 -d2); } @@ -1110,9 +1304,13 @@ bool ShapeAnalysis_CheckSmallFace::CheckPinEdges(const TopoDS_Edge& theFirstEdge double dist = SAC.Project(GAC, proj, tol, result, param); // pdn check if parameter of projection is in the domain of the edge. if (param < f || param > l) + { return false; + } if (dist > tol) + { return false; + } if (dist <= tol) { // Computing first derivative vectors and compare angle diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Curve.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Curve.cxx index 49eded2724..dcc6e860d6 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Curve.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Curve.cxx @@ -133,9 +133,13 @@ double ShapeAnalysis_Curve::Project(const occ::handle& C3D, double uMin = C3D->FirstParameter(); double uMax = C3D->LastParameter(); if (uMin < uMax) + { return Project(C3D, P3D, preci, proj, param, uMin, uMax, AdjustToEnds); + } else + { return Project(C3D, P3D, preci, proj, param, uMax, uMin, AdjustToEnds); + } } //================================================================================================= @@ -211,7 +215,9 @@ double ShapeAnalysis_Curve::Project(const Adaptor3d_Curve& C3D, double uMax = C3D.LastParameter(); if (Precision::IsInfinite(uMin) && Precision::IsInfinite(uMax)) + { return ProjectAct(C3D, P3D, preci, proj, param); + } double distmin_L = Precision::Infinite(), distmin_H = Precision::Infinite(); // clang-format off @@ -239,7 +245,9 @@ double ShapeAnalysis_Curve::Project(const Adaptor3d_Curve& C3D, double distProj = ProjectAct(C3D, P3D, preci, proj, param); if (distProj < distmin_L + Precision::Confusion() && distProj < distmin_H + Precision::Confusion()) + { return distProj; + } if (distmin_L < distmin_H) { @@ -626,21 +634,29 @@ bool ShapeAnalysis_Curve::ValidateRange(const occ::handle& theCurve, // Last = cf au lieu de Last = cl if (std::abs(Last - cf) < Precision::PConfusion() /*preci*/) + { Last = cl; - // First = cl au lieu de First = cf + // First = cl au lieu de First = cf + } else if (std::abs(First - cl) < Precision::PConfusion() /*preci*/) + { First = cf; - // on se trouve dans un cas ou l origine est traversee - // illegal sur une courbe fermee non periodique - // on inverse quand meme les parametres !!!!!! + // on se trouve dans un cas ou l origine est traversee + // illegal sur une courbe fermee non periodique + // on inverse quand meme les parametres !!!!!! + } else { //: S4136 abv 20 Apr 99: r0701_ug.stp #6230: add check in 3d if (theCurve->Value(First).Distance(theCurve->Value(cf)) < preci) + { First = cf; + } if (theCurve->Value(Last).Distance(theCurve->Value(cl)) < preci) + { Last = cl; + } if (First > Last) { double tmp = First; @@ -662,14 +678,18 @@ bool ShapeAnalysis_Curve::ValidateRange(const occ::handle& theCurve, // Last = cf au lieu de Last = cl if (std::abs(Last - cf) < Precision::PConfusion() /*preci*/) + { Last = cl; - // First = cl au lieu de First = cf + // First = cl au lieu de First = cf + } else if (std::abs(First - cl) < Precision::PConfusion() /*preci*/) + { First = cf; - // on se trouve dans un cas ou l origine est traversee - // illegal sur une courbe fermee non periodique - // on inverse quand meme les parametres !!!!!! + // on se trouve dans un cas ou l origine est traversee + // illegal sur une courbe fermee non periodique + // on inverse quand meme les parametres !!!!!! + } else { double tmp = First; @@ -735,22 +755,30 @@ static int SearchForExtremum(const occ::handle& C2d, C2d->D2(par, res, D1, D2); double Det = (D2 * dir); if (std::abs(Det) < 1e-10) + { return true; + } par -= (D1 * dir) / Det; if (std::abs(par - prevpar) < Precision::PConfusion()) + { return true; + } if (par < First) { if (nbOut++ > 2 || prevpar == First) + { return false; + } par = First; } if (par > Last) { if (nbOut++ > 2 || prevpar == Last) + { return false; + } par = Last; } } @@ -784,12 +812,16 @@ void ShapeAnalysis_Curve::FillBndBox(const occ::handle& C2d, int nbSamples = (nbInt < 2 ? NPoints - 1 : nbInt); NCollection_Array1 aParams(1, nbSamples + 1); if (nbSamples == nbInt) + { anAC.Intervals(aParams, GeomAbs_C2); + } else { double step = (Last - First) / nbSamples; for (int i = 0; i <= nbSamples; i++) + { aParams(i + 1) = First + i * step; + } } for (int i = 1; i <= nbSamples + 1; i++) { @@ -831,12 +863,16 @@ int ShapeAnalysis_Curve::SelectForwardSeam(const occ::handle& C1, // if we have BoundedCurve, create a line from C1 occ::handle BC1 = occ::down_cast(C1); if (BC1.IsNull()) + { return theCurveIndice; + } gp_Pnt2d StartBC1 = BC1->StartPoint(); gp_Pnt2d EndBC1 = BC1->EndPoint(); gp_Vec2d VecBC1(StartBC1, EndBC1); if (VecBC1.SquareMagnitude() < gp::Resolution()) + { return theCurveIndice; + } L1 = new Geom2d_Line(StartBC1, VecBC1); } @@ -846,12 +882,16 @@ int ShapeAnalysis_Curve::SelectForwardSeam(const occ::handle& C1, // if we have BoundedCurve, creates a line from C2 occ::handle BC2 = occ::down_cast(C2); if (BC2.IsNull()) + { return theCurveIndice; + } gp_Pnt2d StartBC2 = BC2->StartPoint(); gp_Pnt2d EndBC2 = BC2->EndPoint(); gp_Vec2d VecBC2(StartBC2, EndBC2); if (VecBC2.SquareMagnitude() < gp::Resolution()) + { return theCurveIndice; + } L2 = new Geom2d_Line(StartBC2, VecBC2); } @@ -883,31 +923,47 @@ int ShapeAnalysis_Curve::SelectForwardSeam(const occ::handle& C1, { // max of Loc1.X() Loc2.X() if (theLoc1.X() > theLoc2.X()) + { theCurveIndice = 1; + } else + { theCurveIndice = 2; + } } else if (VdirNeg) { if (theLoc1.X() > theLoc2.X()) + { theCurveIndice = 2; + } else + { theCurveIndice = 1; + } } else if (UdirPos) { // min of Loc1.X() Loc2.X() if (theLoc1.Y() < theLoc2.Y()) + { theCurveIndice = 1; + } else + { theCurveIndice = 2; + } } else if (UdirNeg) { if (theLoc1.Y() < theLoc2.Y()) + { theCurveIndice = 2; + } else + { theCurveIndice = 1; + } } return theCurveIndice; @@ -923,15 +979,21 @@ static gp_XYZ GetAnyNormal(const gp_XYZ& orig) { gp_XYZ Norm; if (std::abs(orig.Z()) < Precision::Confusion()) + { Norm.SetCoord(0, 0, 1); + } else { Norm.SetCoord(orig.Z(), 0, -orig.X()); double nrm = Norm.Modulus(); if (nrm < Precision::Confusion()) + { Norm.SetCoord(0, 0, 1); + } else + { Norm = Norm / nrm; + } } return Norm; } @@ -1010,14 +1072,18 @@ static void AppendControlPoles(NCollection_Sequence& seq, occ::handle BSpline = occ::down_cast(curve); const NCollection_Array1& Poles = BSpline->Poles(); for (int i = 1; i <= Poles.Length(); i++) + { seq.Append(Poles(i)); + } } else if (curve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) { occ::handle Bezier = occ::down_cast(curve); const NCollection_Array1& Poles = Bezier->Poles(); for (int i = 1; i <= Poles.Length(); i++) + { seq.Append(Poles(i)); + } } } @@ -1053,7 +1119,9 @@ bool ShapeAnalysis_Curve::IsPlanar(const NCollection_Array1& pnts, gp_XYZ aCenter(0, 0, 0); int i = 1; for (; i <= pnts.Length(); i++) + { aCenter += pnts(i).XYZ(); + } aCenter /= pnts.Length(); aMaxDir = pnts(1).XYZ() - aCenter; @@ -1063,11 +1131,15 @@ bool ShapeAnalysis_Curve::IsPlanar(const NCollection_Array1& pnts, { gp_XYZ aTmpDir = pnts(i + 1).XYZ() - aCenter; if (aTmpDir.SquareModulus() > aMaxDir.SquareModulus()) + { aMaxDir = aTmpDir; + } gp_XYZ aDelta = (pnts(i).XYZ() - aCenter) ^ (pnts(i + 1).XYZ() - aCenter); if (Normal * aDelta < 0) + { aDelta *= -1; + } Normal += aDelta; } } @@ -1086,9 +1158,13 @@ bool ShapeAnalysis_Curve::IsPlanar(const NCollection_Array1& pnts, { dev = pnts(i).XYZ() * Normal; if (dev < mind) + { mind = dev; + } if (dev > maxd) + { maxd = dev; + } } return ((maxd - mind) <= precision); @@ -1163,10 +1239,14 @@ bool ShapeAnalysis_Curve::IsPlanar(const occ::handle& curve, NCollection_Sequence sequence; int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= Complex->NbCurves(); i++) + { AppendControlPoles(sequence, Complex->Curve(i)); + } NCollection_Array1 Poles(1, sequence.Length()); for (i = 1; i <= sequence.Length(); i++) + { Poles(i) = sequence(i); + } return IsPlanar(Poles, Normal, precision); } @@ -1182,22 +1262,29 @@ bool ShapeAnalysis_Curve::GetSamplePoints(const occ::handle& curve, { double adelta = curve->LastParameter() - curve->FirstParameter(); if (!adelta) + { return false; + } int aK = (int)ceil((last - first) / adelta); int nbp = 100 * aK; if (curve->IsKind(STANDARD_TYPE(Geom_Line))) + { nbp = 2; + } else if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) + { nbp = 360 * aK; - + } else if (curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { occ::handle aBspl = occ::down_cast(curve); nbp = aBspl->NbKnots() * aBspl->Degree() * aK; if (nbp < 2.0) + { nbp = 2; + } } else if (curve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) { @@ -1218,7 +1305,9 @@ bool ShapeAnalysis_Curve::GetSamplePoints(const occ::handle& curve, GeomAdaptor_Curve GAC(curve); double step = (last - first) / (double)(nbp - 1); for (int i = 0; i < nbp - 1; ++i) + { seq.Append(GAC.Value(first + step * i)); + } seq.Append(GAC.Value(last)); return true; } @@ -1236,10 +1325,14 @@ bool ShapeAnalysis_Curve::GetSamplePoints(const occ::handle& curve int nbs = Geom2dInt_Geom2dCurveTool::NbSamples(C); //-- Attention aux bsplines rationnelles de degree 3. (bouts de cercles entre autres) if (nbs > 2) + { nbs *= 4; + } double step = (last - first) / (double)(nbs - 1); for (int i = 0; i < nbs - 1; ++i) + { seq.Append(C.Value(first + step * i)); + } seq.Append(C.Value(last)); return true; /* @@ -1331,7 +1424,9 @@ bool ShapeAnalysis_Curve::GetSamplePoints(const occ::handle& curve bool ShapeAnalysis_Curve::IsClosed(const occ::handle& theCurve, const double preci) { if (theCurve->IsClosed()) + { return true; + } double prec = std::max(preci, Precision::Confusion()); @@ -1340,7 +1435,9 @@ bool ShapeAnalysis_Curve::IsClosed(const occ::handle& theCurve, cons l = theCurve->LastParameter(); if (Precision::IsInfinite(f) || Precision::IsInfinite(l)) + { return false; + } double aClosedVal = theCurve->Value(f).SquareDistance(theCurve->Value(l)); double preci2 = prec * prec; @@ -1360,9 +1457,13 @@ bool ShapeAnalysis_Curve::IsPeriodic(const occ::handle& theCurve) || (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)))) { if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } } return aTmpCurve->IsPeriodic(); } @@ -1377,9 +1478,13 @@ bool ShapeAnalysis_Curve::IsPeriodic(const occ::handle& theCurve) || (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))) { if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } } return aTmpCurve->IsPeriodic(); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Edge.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Edge.cxx index 5a59941467..f73ae1a369 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Edge.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Edge.cxx @@ -79,7 +79,9 @@ bool ShapeAnalysis_Edge::BoundUV(const TopoDS_Edge& edge, occ::handle c2d; double uf, ul; if (!PCurve(edge, surface, location, c2d, uf, ul)) + { return false; + } first = c2d->Value(uf); last = c2d->Value(ul); return true; @@ -129,9 +131,13 @@ bool ShapeAnalysis_Edge::IsClosed3d(const TopoDS_Edge& edge) const double cf, cl; occ::handle c3d = BRep_Tool::Curve(edge, cf, cl); if (c3d.IsNull()) + { return false; + } if (!c3d->IsClosed()) + { return false; + } return FirstVertex(edge).IsSame(LastVertex(edge)); } @@ -343,12 +349,16 @@ bool ShapeAnalysis_Edge::GetEndTangent2d(const TopoDS_Edge& edge, c2d->D0((atend2 ? cf : cl), p2); v = p2.XY() - pnt.XY(); if (v.SquareMagnitude() < Precision::PConfusion() * Precision::PConfusion()) + { return false; + } } } } if (edge.Orientation() == TopAbs_REVERSED) + { v.Reverse(); + } } // if ( edge.Orientation() == TopAbs_REVERSED ) v.Reverse(); @@ -373,7 +383,9 @@ bool ShapeAnalysis_Edge::CheckCurve3dWithPCurve(const TopoDS_Edge& myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (surface->IsKind(STANDARD_TYPE(Geom_Plane))) + { return false; + } occ::handle c2d; double f2d, l2d; // szv#4:S4163:12Mar99 moved down f3d, l3d @@ -395,7 +407,9 @@ bool ShapeAnalysis_Edge::CheckCurve3dWithPCurve(const TopoDS_Edge& TopoDS_Vertex aLastVert = LastVertex(edge); if (aFirstVert.IsNull() || aLastVert.IsNull()) + { return false; + } double preci1 = BRep_Tool::Tolerance(aFirstVert), preci2 = BRep_Tool::Tolerance(aLastVert); @@ -421,9 +435,13 @@ bool ShapeAnalysis_Edge::CheckPoints(const gp_Pnt& P1A, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (P1A.SquareDistance(P2A) <= preci1 * preci1 && P1B.SquareDistance(P2B) <= preci2 * preci2) + { return false; + } else if (P1A.Distance(P2B) + (P1B.Distance(P2A)) < P1A.Distance(P2A) + (P1B.Distance(P2B))) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } return true; } @@ -455,7 +473,9 @@ bool ShapeAnalysis_Edge::CheckVerticesWithCurve3d(const TopoDS_Edge& edge, gp_Pnt p13d = c3d->Value(cf); // szv#4:S4163:12Mar99 optimized if (p1v.Distance(p13d) > (preci < 0 ? BRep_Tool::Tolerance(V1) : preci)) + { myStatus |= ShapeExtend_DONE1; + } } if (vtx != 1) @@ -464,7 +484,9 @@ bool ShapeAnalysis_Edge::CheckVerticesWithCurve3d(const TopoDS_Edge& edge, gp_Pnt p23d = c3d->Value(cl); // szv#4:S4163:12Mar99 optimized if (p2v.Distance(p23d) > (preci < 0 ? BRep_Tool::Tolerance(V2) : preci)) + { myStatus |= ShapeExtend_DONE2; + } } return Status(ShapeExtend_DONE); @@ -513,10 +535,14 @@ bool ShapeAnalysis_Edge::CheckVerticesWithPCurve(const TopoDS_Edge& gp_Pnt2d p1uv = c2d->Value(cf); gp_Pnt p12d = surf->Value(p1uv.X(), p1uv.Y()); if (!loc.IsIdentity()) + { p12d.Transform(loc.Transformation()); + } // szv#4:S4163:12Mar99 optimized if (p1v.Distance(p12d) > (preci < 0 ? BRep_Tool::Tolerance(V1) : preci)) + { myStatus |= ShapeExtend_DONE1; + } } if (vtx != 1) @@ -524,10 +550,14 @@ bool ShapeAnalysis_Edge::CheckVerticesWithPCurve(const TopoDS_Edge& gp_Pnt2d p2uv = c2d->Value(cl); gp_Pnt p22d = surf->Value(p2uv.X(), p2uv.Y()); if (!loc.IsIdentity()) + { p22d.Transform(loc.Transformation()); + } // szv#4:S4163:12Mar99 optimized if (p2v.Distance(p22d) > (preci < 0 ? BRep_Tool::Tolerance(V2) : preci)) + { myStatus |= ShapeExtend_DONE2; + } } return Status(ShapeExtend_DONE); @@ -562,7 +592,9 @@ static int CheckVertexTolerance(const TopoDS_Edge& edge, if (!sae.Curve3d(edge, c3d, a, b, true)) { if (!BRep_Tool::Degenerated(edge)) + { Status |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } toler1 = toler2 = 0.; // return false; } @@ -581,7 +613,9 @@ static int CheckVertexTolerance(const TopoDS_Edge& edge, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle pcurve; occ::handle S = GC->Surface(); TopLoc_Location L = edge.Location() * GC->Location(); @@ -611,7 +645,9 @@ static int CheckVertexTolerance(const TopoDS_Edge& edge, toler2 = std::max(toler2, pnt2.SquareDistance(P2)); } else + { Status |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } } //: o8 abv 19 Feb 99: CTS18541.stp #18559: coeff 1.0001 added @@ -620,9 +656,13 @@ static int CheckVertexTolerance(const TopoDS_Edge& edge, toler1 = std::max(1.0000001 * std::sqrt(toler1), tole); toler2 = std::max(1.0000001 * std::sqrt(toler2), tole); if (toler1 > old1) + { Status |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (toler2 > old2) + { Status |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } return Status; } @@ -668,7 +708,9 @@ bool ShapeAnalysis_Edge::CheckSameParameter(const TopoDS_Edge& edge, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (BRep_Tool::Degenerated(edge)) + { return false; + } maxdev = 0; @@ -700,7 +742,9 @@ bool ShapeAnalysis_Edge::CheckSameParameter(const TopoDS_Edge& edge, occ::handle aFaceSurf; TopLoc_Location aFaceLoc; if (!face.IsNull()) + { aFaceSurf = BRep_Tool::Surface(face, aFaceLoc); + } bool IsPCurveFound = false; int i = 1; @@ -716,8 +760,10 @@ bool ShapeAnalysis_Edge::CheckSameParameter(const TopoDS_Edge& edge, BRep_Tool::CurveOnSurface(edge, aPC, aS, aLoc, f, l, i); if (aPC.IsNull()) + { // No more curves break; + } ++i; @@ -780,9 +826,13 @@ bool ShapeAnalysis_Edge::CheckSameParameter(const TopoDS_Edge& edge, } if (maxdev > TE->Tolerance()) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (!SameParameter) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } return Status(ShapeExtend_DONE); } @@ -818,9 +868,13 @@ static bool IsOverlapPartEdges(const TopoDS_Edge& theFirstEdge, aS, aAdCurve1.FirstParameter()); if (aAbsPoint.IsDone()) + { aAdCurve1.D0(aAbsPoint.Parameter(), aPoint); + } else + { continue; + } } BRep_Builder aB; TopoDS_Vertex aV; @@ -828,7 +882,9 @@ static bool IsOverlapPartEdges(const TopoDS_Edge& theFirstEdge, aMinDist.LoadS2(aV); aMinDist.Perform(); if (aMinDist.IsDone() && aMinDist.Value() >= theTolerance) + { return false; + } } return true; } @@ -864,7 +920,9 @@ bool ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1, return isOverlap; } if (theDomainDist == 0.0) + { return isOverlap; + } // check overalpping between edges on segment with length less than theDomainDist @@ -876,7 +934,9 @@ bool ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1, { aresTol = aMinDist.Value(); if (aresTol >= theTolOverlap) + { return false; + } int NbSol = aMinDist.NbSolution(); for (int i = 1; i <= NbSol && !isOverlap; i++) { @@ -888,9 +948,13 @@ bool ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1, TopoDS_Vertex aV1, aV2; TopExp::Vertices(aFirstEdge, aV1, aV2, true); if (aV1.IsSame(aSupportShape1)) + { aLengthP = 0.0; + } else + { aLengthP = aLength; + } } else if (aType1 == BRepExtrema_IsOnEdge) { @@ -901,7 +965,9 @@ bool ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1, aLengthP = GCPnts_AbscissaPoint::Length(anAdaptor, aFirst, aParam1); } else + { continue; + } aStartLength = aLengthP - aDomainTol / 2; if (aStartLength < 0.0) { @@ -920,7 +986,9 @@ bool ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1, } } if (isOverlap) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } theTolOverlap = aresTol; return isOverlap; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx index 2a713a909c..adc4957e4c 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx @@ -67,7 +67,9 @@ void ShapeAnalysis_FreeBoundData::Clear() void ShapeAnalysis_FreeBoundData::AddNotch(const TopoDS_Wire& notch, const double width) { if (myNotchesParams.IsBound(notch)) + { return; + } myNotches->Append(notch); myNotchesParams.Bind(notch, width); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx index ce732dcd15..a22f25a134 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx @@ -69,7 +69,9 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, { BRepBuilderAPI_Sewing Sew(toler, false, false); for (TopoDS_Iterator S(shape); S.More(); S.Next()) + { Sew.Add(S.Value()); + } Sew.Perform(); // // Extract free edges. @@ -81,7 +83,9 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, { anEdge = TopoDS::Edge(Sew.FreeEdge(iedge)); if (!BRep_Tool::Degenerated(anEdge)) + { edges->Append(anEdge); + } } // // Chainage. @@ -89,8 +93,6 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, occ::handle> wires = ConnectEdgesToWires(edges, toler, false); DispatchWires(wires, myWires, myEdges); SplitWires(); - - return; } //================================================================================================= @@ -108,7 +110,9 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, BRep_Builder aB; aB.MakeShell(aTmpShell); for (TopExp_Explorer aExpFace(shape, TopAbs_FACE); aExpFace.More(); aExpFace.Next()) + { aB.Add(aTmpShell, aExpFace.Current()); + } ShapeAnalysis_Shell sas; sas.CheckOrientedShells(aTmpShell, true, checkinternaledges); @@ -149,8 +153,12 @@ occ::handle> ShapeAnalysis_FreeBounds::Conne ConnectWiresToWires(iwires, toler, shared); for (i = 1; i <= edges->Length(); i++) + { if (iwires->Value(i).Orientation() == TopAbs_REVERSED) + { edges->ChangeValue(i).Reverse(); + } + } return wires; } @@ -198,12 +206,16 @@ static void connectWiresToWiresImpl( NCollection_DataMap& vertices) { if (iwires.IsNull() || !iwires->Length()) + { return; + } occ::handle> arrwires = new NCollection_HArray1(1, iwires->Length()); int i; for (i = 1; i <= arrwires->Length(); i++) + { arrwires->SetValue(i, iwires->Value(i)); + } owires = new NCollection_HSequence; double tolerance = std::max(toler, Precision::Confusion()); @@ -268,7 +280,9 @@ static void connectWiresToWiresImpl( aSel.DefineBoxes(FVBox, LVBox); if (shared) + { aSel.DefineVertexes(Vf, Vl); + } else { aSel.DefinePnt(pf, pl); @@ -289,12 +303,16 @@ static void connectWiresToWiresImpl( if (found) { if (!direct) + { arrwires->ChangeValue(lwire).Reverse(); + } occ::handle acurwd = new ShapeExtend_WireData(TopoDS::Wire(arrwires->Value(lwire)), true, isUsedManifoldMode); if (!acurwd->NbEdges()) + { continue; + } sewd->Add(acurwd, (tail ? 0 : 1)); } else @@ -313,7 +331,9 @@ static void connectWiresToWiresImpl( Vfol = sae.FirstVertex(E2); if (saw->LastCheckStatus(ShapeExtend_DONE1)) + { V = Vprev; + } else { ShapeBuild_Vertex sbv; @@ -324,12 +344,16 @@ static void connectWiresToWiresImpl( ShapeBuild_Edge sbe; if (saw->NbEdges() < 2) + { sewd->Set(sbe.CopyReplaceVertices(E2, V, V), n2); + } else { sewd->Set(sbe.CopyReplaceVertices(E2, V, TopoDS_Vertex()), n2); if (!saw->LastCheckStatus(ShapeExtend_DONE1)) + { sewd->Set(sbe.CopyReplaceVertices(E1, TopoDS_Vertex(), V), n1); + } } } } @@ -338,7 +362,9 @@ static void connectWiresToWiresImpl( if (isUsedManifoldMode) { if (!saw->CheckConnected(1) && saw->LastCheckStatus(ShapeExtend_OK)) + { wire.Closed(true); + } } else { @@ -355,7 +381,9 @@ static void connectWiresToWiresImpl( if (V.Orientation() == TopAbs_FORWARD || V.Orientation() == TopAbs_REVERSED) { if (!vmap.Add(V)) + { vmap.Remove(V); + } } } } @@ -379,13 +407,17 @@ static void connectWiresToWiresImpl( aSel.LoadList(lwire); if (sewd->NbEdges() > 0) + { break; + } sewd->Clear(); } } if (lwire == -1) + { done = true; + } } } @@ -447,6 +479,7 @@ static void SplitWire(const TopoDS_Wire& wire, // building closed wires int i; // svv #1 for (i = 1; i <= nbedges; i++) + { if (statuses.Value(i) == 0) { ces.Append(i); @@ -474,7 +507,9 @@ static void SplitWire(const TopoDS_Wire& wire, TopoDS_Vertex fv = sae.FirstVertex(sewd->Edge(ces.Value(j))); gp_Pnt fp = BRep_Tool::Pnt(fv); if ((shared && lvertex.IsSame(fv)) || (!shared && lpoint.IsEqual(fp, tolerance))) + { found = true; + } } if (found) @@ -492,7 +527,9 @@ static void SplitWire(const TopoDS_Wire& wire, closed->Append(wire1); ces.Remove(j, ces.Length()); if (ces.IsEmpty()) + { break; + } } } @@ -503,13 +540,17 @@ static void SplitWire(const TopoDS_Wire& wire, lpoint = BRep_Tool::Pnt(lvertex); int j; // svv #1 for (j = 1; (j <= nbedges) && !found; j++) + { if (statuses.Value(j) == 0) { TopoDS_Vertex fv = sae.FirstVertex(sewd->Edge(j)); gp_Pnt fp = BRep_Tool::Pnt(fv); if ((shared && lvertex.IsSame(fv)) || (!shared && lpoint.IsEqual(fp, tolerance))) + { found = true; + } } + } if (found) { @@ -524,15 +565,22 @@ static void SplitWire(const TopoDS_Wire& wire, statuses.SetValue(ces.Last(), 3); ces.Remove(ces.Length()); if (ces.IsEmpty()) + { break; + } } } + } // building open wires occ::handle> edges = new NCollection_HSequence; for (i = 1; i <= nbedges; i++) + { if (statuses.Value(i) != 2) + { edges->Append(sewd->Edge(i)); + } + } open = ShapeAnalysis_FreeBounds::ConnectEdgesToWires(edges, toler, shared); } @@ -565,17 +613,29 @@ void ShapeAnalysis_FreeBounds::DispatchWires( { BRep_Builder B; if (closed.IsNull()) + { B.MakeCompound(closed); + } if (open.IsNull()) + { B.MakeCompound(open); + } if (wires.IsNull()) + { return; + } for (int iw = 1; iw <= wires->Length(); iw++) + { if (wires->Value(iw).Closed()) + { B.Add(closed, wires->Value(iw)); + } else + { B.Add(open, wires->Value(iw)); + } + } } //======================================================================= @@ -588,7 +648,9 @@ void ShapeAnalysis_FreeBounds::DispatchWires( void ShapeAnalysis_FreeBounds::SplitWires() { if (!mySplitClosed && !mySplitOpen) + { return; // nothing to do + } ShapeExtend_Explorer see; occ::handle> closedwires, cw1, cw2, openwires, ow1, ow2; @@ -596,7 +658,9 @@ void ShapeAnalysis_FreeBounds::SplitWires() openwires = see.SeqFromCompound(myEdges, false); if (mySplitClosed) + { SplitWires(closedwires, myTolerance, myShared, cw1, ow1); + } else { cw1 = closedwires; @@ -604,7 +668,9 @@ void ShapeAnalysis_FreeBounds::SplitWires() } if (mySplitOpen) + { SplitWires(openwires, myTolerance, myShared, cw2, ow2); + } else { cw2 = new NCollection_HSequence; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx index a43407d766..1ec03eda32 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx @@ -56,7 +56,9 @@ static void ContourProperties(const TopoDS_Wire& wire, double& countourArea, dou occ::handle c3d; ShapeAnalysis_Edge sae; if (!sae.Curve3d(Edge, c3d, First, Last)) + { continue; + } int ibeg = 0; if (nbe == 1) @@ -185,7 +187,9 @@ bool ShapeAnalysis_FreeBoundsProperties::Perform() bool ShapeAnalysis_FreeBoundsProperties::DispatchBounds() { if (!IsLoaded()) + { return false; + } TopoDS_Compound tmpClosedBounds, tmpOpenBounds; if (myTolerance > 0.) @@ -253,13 +257,17 @@ bool ShapeAnalysis_FreeBoundsProperties::CheckNotches( { ShapeExtend_WireData swd(fbData->FreeBound()); if (swd.NbEdges() > 1) + { for (int j = 1; j <= swd.NbEdges(); j++) { TopoDS_Wire notch; double dMax; if (CheckNotches(fbData->FreeBound(), j, notch, dMax, prec)) + { fbData->AddNotch(notch, dMax); + } } + } return true; } @@ -298,7 +306,9 @@ bool ShapeAnalysis_FreeBoundsProperties::CheckNotches(const TopoDS_Wire& wire, B.MakeWire(notch); if ((num <= 0) || (num > wdt->NbEdges())) + { return false; + } int n1 = (num > 0 ? num : wdt->NbEdges()); int n2 = (n1 < wdt->NbEdges() ? n1 + 1 : 1); @@ -323,16 +333,22 @@ bool ShapeAnalysis_FreeBoundsProperties::CheckNotches(const TopoDS_Wire& wire, ShapeAnalysis_Edge sae; // szv#4:S4163:12Mar99 optimized if (!sae.Curve3d(E1, c3d1, First1, Last1) || !sae.Curve3d(E2, c3d2, First2, Last2)) + { return false; + } gp_Pnt pnt; gp_Vec vec1, vec2; c3d1->D1(Last1, pnt, vec1); c3d2->D1(First2, pnt, vec2); if (E1.Orientation() == TopAbs_REVERSED) + { vec1.Reverse(); + } if (E2.Orientation() == TopAbs_REVERSED) + { vec2.Reverse(); + } double angl = std::abs(vec1.Angle(vec2)); if (angl > 0.95 * M_PI) @@ -359,7 +375,9 @@ bool ShapeAnalysis_FreeBoundsProperties::CheckNotches(const TopoDS_Wire& wire, GeomAPI_ProjectPointOnCurve ppc(pntCurr, c3d2, p1, p2); double newDist = (ppc.NbPoints() ? ppc.LowerDistance() : 0); if (newDist > distMax) + { distMax = newDist; + } } return true; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Geom.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Geom.cxx index e666304a92..77d036cfc4 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Geom.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Geom.cxx @@ -46,23 +46,35 @@ bool ShapeAnalysis_Geom::NearestPlane(const NCollection_Array1& thePnts, { case 1: { if ((2.0 * aDev1 > aDev2) || (2.0 * aDev1 > aDev3)) + { anAxis = 0; + } else + { thePln = gp_Pln(anEq.Barycentre(), anEq.PrincipalAxis(1)); + } break; } case 2: { if ((2.0 * aDev2 > aDev1) || (2.0 * aDev2 > aDev3)) + { anAxis = 0; + } else + { thePln = gp_Pln(anEq.Barycentre(), anEq.PrincipalAxis(2)); + } break; } case 3: { if ((2.0 * aDev3 > aDev2) || (2.0 * aDev3 > aDev1)) + { anAxis = 0; + } else + { thePln = gp_Pln(anEq.Barycentre(), anEq.PrincipalAxis(3)); + } break; } } @@ -74,7 +86,9 @@ bool ShapeAnalysis_Geom::NearestPlane(const NCollection_Array1& thePnts, { const double aD = thePln.Distance(thePnts(i)); if (theMaxDist < aD) + { theMaxDist = aD; + } } } @@ -93,7 +107,9 @@ bool ShapeAnalysis_Geom::PositionTrsf(const occ::handle pmm || std::abs(m2 - mm) > pmm || std::abs(m3 - mm) > pmm) + { return false; + } v1.Divide(m1); v2.Divide(m2); v3.Divide(m3); if (std::abs(v1.Dot(v2)) > prec || std::abs(v2.Dot(v3)) > prec || std::abs(v3.Dot(v1)) > prec) + { return false; + } if (v1.X() != 1 || v1.Y() != 0 || v1.Z() != 0 || v2.X() != 0 || v2.Y() != 1 || v2.Z() != 0 || v3.X() != 0 || v3.Y() != 0 || v3.Z() != 1) @@ -132,17 +154,25 @@ bool ShapeAnalysis_Geom::PositionTrsf(const occ::handle prec) + { trsf.SetScale(gp_Pnt(0, 0, 0), mm); + } gp_Vec tp(gtrsf.TranslationPart()); if (unit != 1.) + { tp.Multiply(unit); + } if (tp.X() != 0 || tp.Y() != 0 || tp.Z() != 0) + { trsf.SetTranslationPart(tp); + } return result; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx index 15d4f3f71f..6592a5103d 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx @@ -124,9 +124,13 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) mapsh.Add(sol); int nbs = 0; for (TopExp_Explorer shel(sol, TopAbs_SHELL); shel.More(); shel.Next()) + { nbs++; + } if (nbs > 1) + { myNbSolidsWithVoids++; + } myNbSolids++; } myNbSharedSolids = mapsh.Extent(); @@ -142,7 +146,9 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) she.Location(TopLoc_Location()); mapsh.Add(she); for (TopExp_Explorer shel(she, TopAbs_FACE); shel.More(); shel.Next()) + { nbfaceshell++; + } } myNbSharedShells = mapsh.Extent(); // On note pour les FACES pas mal de choses (surface, topologie) @@ -184,7 +190,9 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) { myNbBigSplines++; if (myBigSplineMode) + { myBigSplineSec->Append(face); + } } } occ::handle els = occ::down_cast(surf); @@ -194,14 +202,18 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) { myNbIndirectSurf++; if (myIndirectMode) + { myIndirectSec->Append(face); + } } } if (surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { myNbOffsetSurf++; if (myOffsetSurfaceMode) + { myOffsetSurfaceSec->Append(face); + } } else if (surf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { @@ -219,7 +231,9 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) TopoDS_Edge edge = TopoDS::Edge(edg.Current()); double first, last; if (BRep_Tool::IsClosed(edge, face)) + { nbseam++; + } occ::handle c3d = BRep_Tool::Curve(edge, first, last); if (!c3d.IsNull()) { @@ -227,34 +241,50 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) { myNbTrimmedCurve3d++; if (myTrimmed3dMode) + { myTrimmed3dSec->Append(face); + } } } occ::handle c2d = BRep_Tool::CurveOnSurface(edge, face, first, last); if (c2d.IsNull()) + { myNbNoPCurve++; + } else if (c2d->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) { myNbOffsetCurves++; if (myOffsetCurveMode) + { myOffsetCurveSec->Append(face); + } } else if (c2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { myNbTrimmedCurve2d++; if (myTrimmed2dMode) + { myTrimmed2dSec->Append(face); + } } } if (nbseam > maxseam) + { maxseam = nbseam; + } } if (maxseam == 1) + { myNbWireWitnSeam++; + } else if (maxseam > 1) + { myNbWireWithSevSeams++; + } if (nbwires > 1) + { myNbFaceWithSevWires++; + } } myNbSharedFaces = mapsh.Extent(); @@ -285,10 +315,14 @@ void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape) { myNbOffsetCurves++; if (myOffsetCurveMode) + { myOffsetCurveSec->Append(edge); + } } if (!c3d.IsNull() && !c3d->IsCN(1)) + { myNbC0Curves++; + } } myNbSharedEdges = mapsh.Extent(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx index f18b152d85..6cf466db76 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx @@ -33,13 +33,19 @@ static void AddTol(const double tol, int& nbt, double& cmin, double& cmoy, doubl { nbt++; if (nbt == 1) + { cmin = cmoy = cmax = tol; + } else { if (cmin > tol) + { cmin = tol; + } if (cmax < tol) + { cmax = tol; + } // cmoy += tol; // Calcul en moyenne geometrique entre 1 et 1e-7 int mult = 1; @@ -77,9 +83,13 @@ occ::handle> ShapeAnalysis_ShapeTolerance::O const TopAbs_ShapeEnum type) const { if (value >= 0) + { return InTolerance(shape, value, 0., type); + } else + { return InTolerance(shape, 0., value, type); + } } //================================================================================================= @@ -105,7 +115,9 @@ occ::handle> ShapeAnalysis_ShapeTolerance::I { tol = BRep_Tool::Tolerance(TopoDS::Face(myExp.Current())); if (tol >= valmin && (over || (tol <= valmax))) + { sl->Append(myExp.Current()); + } myExp.Next(); } } @@ -119,7 +131,9 @@ occ::handle> ShapeAnalysis_ShapeTolerance::I { tol = BRep_Tool::Tolerance(TopoDS::Edge(myExp.Current())); if (tol >= valmin && (over || (tol <= valmax))) + { sl->Append(myExp.Current()); + } myExp.Next(); } } @@ -133,7 +147,9 @@ occ::handle> ShapeAnalysis_ShapeTolerance::I { tol = BRep_Tool::Tolerance(TopoDS::Vertex(myExp.Current())); if (tol >= valmin && (over || (tol >= valmax))) + { sl->Append(myExp.Current()); + } myExp.Next(); } } @@ -161,7 +177,9 @@ occ::handle> ShapeAnalysis_ShapeTolerance::I } } if (iashell) + { sl->Append(ash); + } myExp.Next(); } @@ -171,26 +189,36 @@ occ::handle> ShapeAnalysis_ShapeTolerance::I { bool iaface = false; if (mapface.Contains(myExp.Current())) + { continue; + } tol = BRep_Tool::Tolerance(TopoDS::Face(myExp.Current())); if (tol >= valmin && (over || (tol <= valmax))) + { iaface = true; + } else { // les edges contenues ? occ::handle> fl = InTolerance(myExp.Current(), valmin, valmax, TopAbs_EDGE); if (fl->Length() > 0) + { iaface = true; + } else { fl = InTolerance(myExp.Current(), valmin, valmax, TopAbs_VERTEX); if (fl->Length() > 0) + { iaface = true; + } } } if (iaface) + { sl->Append(myExp.Current()); + } } } @@ -256,11 +284,17 @@ void ShapeAnalysis_ShapeTolerance::AddTolerance(const TopoDS_Shape& shape, // Resultat : attention en mode cumul if (nbt == 0) + { return; + } if (myNbTol == 0 || myTols[0] > cmin) + { myTols[0] = cmin; + } if (myNbTol == 0 || myTols[2] < cmax) + { myTols[2] = cmax; + } myTols[1] += cmoy; myNbTol += nbt; } @@ -274,16 +308,24 @@ double ShapeAnalysis_ShapeTolerance::GlobalTolerance(const int mode) const if (myNbTol != 0.) { if (mode < 0) + { result = myTols[0]; + } else if (mode == 0) { if (myTols[0] == myTols[2]) + { result = myTols[0]; + } else + { result = myTols[1] / myNbTol; + } } else + { result = myTols[2]; + } } return result; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Shell.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Shell.cxx index ab81c89acc..cd9f8a79e4 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Shell.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Shell.cxx @@ -45,10 +45,14 @@ void ShapeAnalysis_Shell::Clear() void ShapeAnalysis_Shell::LoadShells(const TopoDS_Shape& shape) { if (shape.IsNull()) + { return; + } if (shape.ShapeType() == TopAbs_SHELL) + { myShells.Add(shape); // szv#4:S4163:12Mar99 i = + } else { for (TopExp_Explorer exs(shape, TopAbs_SHELL); exs.More(); exs.Next()) @@ -78,20 +82,26 @@ static bool CheckEdges(const TopoDS_Shape& for (TopoDS_Iterator it(shape); it.More(); it.Next()) { if (CheckEdges(it.Value(), bads, dirs, revs, ints)) + { res = true; + } } } else { TopoDS_Edge E = TopoDS::Edge(shape); if (BRep_Tool::Degenerated(E)) + { return false; + } if (shape.Orientation() == TopAbs_FORWARD) { // szv#4:S4163:12Mar99 optimized if (dirs.FindIndex(shape) == 0) + { dirs.Add(shape); + } else { bads.Add(shape); @@ -102,7 +112,9 @@ static bool CheckEdges(const TopoDS_Shape& { // szv#4:S4163:12Mar99 optimized if (revs.FindIndex(shape) == 0) + { revs.Add(shape); + } else { bads.Add(shape); @@ -112,7 +124,9 @@ static bool CheckEdges(const TopoDS_Shape& if (shape.Orientation() == TopAbs_INTERNAL) { if (ints.FindIndex(shape) == 0) + { ints.Add(shape); + } // else { bads.Add (shape); res = true; } } } @@ -128,7 +142,9 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, { myConex = false; if (shape.IsNull()) + { return false; + } bool res = false; NCollection_IndexedMap dirs, revs, ints; @@ -137,13 +153,19 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, const TopoDS_Shape& sh = exs.Current(); // szv#4:S4163:12Mar99 optimized if (CheckEdges(sh, myBad, dirs, revs, ints)) + { if (myShells.Add(sh)) + { res = true; + } + } } // Resteraient a faire les FreeEdges if (!alsofree) + { return res; + } // Free Edges. Ce sont les edges d une map pas dans l autre // et lycee de Versailles (les maps dirs et revs) @@ -163,7 +185,9 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, myFree.Add(sh); } else + { myConex = true; + } } else { @@ -171,10 +195,14 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, } } else + { myConex = true; + } } else + { myConex = true; + } } nb = revs.Extent(); @@ -192,7 +220,9 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, myFree.Add(sh); } else + { myConex = true; + } } else { @@ -200,10 +230,14 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, } } else + { myConex = true; + } } else + { myConex = true; + } } return res; @@ -214,7 +248,9 @@ bool ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape, bool ShapeAnalysis_Shell::IsLoaded(const TopoDS_Shape& shape) const { if (shape.IsNull()) + { return false; + } return myShells.Contains(shape); } @@ -248,7 +284,9 @@ TopoDS_Compound ShapeAnalysis_Shell::BadEdges() const B.MakeCompound(C); int n = myBad.Extent(); for (int i = 1; i <= n; i++) + { B.Add(C, myBad.FindKey(i)); + } return C; } @@ -268,7 +306,9 @@ TopoDS_Compound ShapeAnalysis_Shell::FreeEdges() const B.MakeCompound(C); int n = myFree.Extent(); for (int i = 1; i <= n; i++) + { B.Add(C, myFree.FindKey(i)); + } return C; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx index 0c27152986..db866cb00b 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx @@ -124,7 +124,9 @@ ShapeAnalysis_Surface::ShapeAnalysis_Surface(const occ::handle& S) void ShapeAnalysis_Surface::Init(const occ::handle& theSurface) { if (mySurf == theSurface) + { return; + } // Bug 33895: Prevent crash when surface is null if (theSurface.IsNull()) { @@ -180,11 +182,15 @@ void ShapeAnalysis_Surface::ComputeSingularities() { // rln S4135 if (myNbDeg >= 0) + { return; + } //: 51 abv 22 Dec 97: allow forcing: if (myNbDeg >= 0) return; // CKY 27-FEV-98 : en appel direct on peut forcer. En appel interne on optimise if (mySurf.IsNull()) + { return; + } double su1, sv1, su2, sv2; // mySurf->Bounds(su1, su2, sv1, sv2); @@ -299,11 +305,17 @@ bool ShapeAnalysis_Surface::HasSingularities(const double preci) int ShapeAnalysis_Surface::NbSingularities(const double preci) { if (myNbDeg < 0) + { ComputeSingularities(); + } int Nb = 0; for (int i = 1; i <= myNbDeg; i++) + { if (myPreci[i - 1] <= preci) + { Nb++; + } + } return Nb; } @@ -320,9 +332,13 @@ bool ShapeAnalysis_Surface::Singularity(const int num, { // ATTENTION, les champs sont des tableaux C, n0s partent de 0. num part de 1 if (myNbDeg < 0) + { ComputeSingularities(); + } if (num < 1 || num > myNbDeg) + { return false; + } P3d = myP3d[num - 1]; preci = myPreci[num - 1]; firstP2d = myFirstP2d[num - 1]; @@ -338,13 +354,17 @@ bool ShapeAnalysis_Surface::Singularity(const int num, bool ShapeAnalysis_Surface::IsDegenerated(const gp_Pnt& P3d, const double preci) { if (myNbDeg < 0) + { ComputeSingularities(); + } for (int i = 0; i < myNbDeg && myPreci[i] <= preci; i++) { myGap = myP3d[i].Distance(P3d); // rln S4135 if (myGap <= preci) + { return true; + } } return false; } @@ -360,7 +380,9 @@ bool ShapeAnalysis_Surface::DegeneratedValues(const gp_Pnt& P3d, const bool /*forward*/) { if (myNbDeg < 0) + { ComputeSingularities(); + } // #77 rln S4135: returning singularity which has minimum gap between singular point and input 3D // point int indMin = -1; @@ -370,11 +392,13 @@ bool ShapeAnalysis_Surface::DegeneratedValues(const gp_Pnt& P3d, myGap = myP3d[i].Distance(P3d); // rln S4135 if (myGap <= preci) + { if (gapMin > myGap) { gapMin = myGap; indMin = i; } + } } if (indMin >= 0) { @@ -396,7 +420,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const gp_Pnt& P3d, gp_Pnt2d& result) { if (myNbDeg < 0) + { ComputeSingularities(); + } // added by rln on 03/12/97 //: c1 abv 23 Feb 98: preci (3d) -> Resolution (2d) // #77 rln S4135 @@ -406,7 +432,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const gp_Pnt& P3d, { double gap2 = myP3d[i].SquareDistance(P3d); if (gap2 > preci * preci) + { gap2 = std::min(gap2, myP3d[i].SquareDistance(Value(result))); + } // rln S4135 if (gap2 <= preci * preci && gapMin > gap2) { @@ -415,12 +443,18 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const gp_Pnt& P3d, } } if (indMin < 0) + { return false; + } myGap = std::sqrt(gapMin); if (!myUIsoDeg[indMin]) + { result.SetX(neighbour.X()); + } else + { result.SetY(neighbour.Y()); + } return true; } @@ -434,7 +468,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int const bool direct) { if (myNbDeg < 0) + { ComputeSingularities(); + } int step = (direct ? 1 : -1); // #77 rln S4135 @@ -445,7 +481,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int { double gap2 = myP3d[i].SquareDistance(points(j)); if (gap2 > prec2) + { gap2 = std::min(gap2, myP3d[i].SquareDistance(Value(pnt2d(j)))); + } if (gap2 <= prec2 && gapMin > gap2) { gapMin = gap2; @@ -453,7 +491,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int } } if (indMin < 0) + { return false; + } myGap = std::sqrt(gapMin); gp_Pnt2d pk; @@ -464,7 +504,9 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int pk = pnt2d(k); gp_Pnt P1 = points(k); if (myP3d[indMin].SquareDistance(P1) > prec2 && myP3d[indMin].SquareDistance(Value(pk)) > prec2) + { break; + } } //: p8 abv 11 Mar 99: PRO7226 #489490: if whole pcurve is degenerate, distribute evenly @@ -477,9 +519,13 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int // szv#4:S4163:12Mar99 warning - possible div by zero double x = (x1 * (nbrPnt - j) + x2 * (j - 1)) / (nbrPnt - 1); if (!myUIsoDeg[indMin]) + { pnt2d(j).SetX(x); + } else + { pnt2d(j).SetY(x); + } } return true; } @@ -487,9 +533,13 @@ bool ShapeAnalysis_Surface::ProjectDegenerated(const int for (j = k - step; j <= nbrPnt && j >= 1; j -= step) { if (!myUIsoDeg[indMin]) + { pnt2d(j).SetX(pk.X()); + } else + { pnt2d(j).SetY(pk.Y()); + } } return true; } @@ -506,14 +556,18 @@ bool ShapeAnalysis_Surface::IsDegenerated(const gp_Pnt2d& p2d1, gp_Pnt pm = Value(0.5 * (p2d1.XY() + p2d2.XY())); double max3d = std::max(p1.Distance(p2), std::max(pm.Distance(p1), pm.Distance(p2))); if (max3d > tol) + { return false; + } GeomAdaptor_Surface& SA = *Adaptor3d(); double RU = SA.UResolution(1.); double RV = SA.VResolution(1.); if (RU < Precision::PConfusion() || RV < Precision::PConfusion()) + { return false; + } double du = std::abs(p2d1.X() - p2d2.X()) / RU; double dv = std::abs(p2d1.Y() - p2d2.Y()) / RV; max3d *= ratio; @@ -531,9 +585,13 @@ static occ::handle ComputeIso(const occ::handle& surf, { OCC_CATCH_SIGNALS if (utype) + { iso = surf->UIso(par); + } else + { iso = surf->VIso(par); + } } catch (Standard_Failure const& anException) { @@ -554,7 +612,9 @@ static occ::handle ComputeIso(const occ::handle& surf, void ShapeAnalysis_Surface::ComputeBoundIsos() { if (myIsos) + { return; + } myIsos = true; myIsoUF = ComputeIso(mySurf, true, myUF); myIsoUL = ComputeIso(mySurf, true, myUL); @@ -1031,7 +1091,9 @@ int ShapeAnalysis_Surface::SurfaceNewton(const gp_Pnt2d& p2dPrev, gp_Vec n = ru ^ rv; double nrm2 = n.SquareMagnitude(); if (nrm2 < 1e-10 || Precision::IsPositiveInfinite(nrm2)) + { break; // n == 0, use standard + } // descriminant gp_Vec rs = P3D.XYZ() - Value(U, V).XYZ(); @@ -1040,7 +1102,9 @@ int ShapeAnalysis_Surface::SurfaceNewton(const gp_Pnt2d& p2dPrev, double rSuv = (rs * ruv); double D = -nrm2 + rv2 * rSuu + ru2 * rSvv - 2 * rSuv * (ru * rv) + rSuv * rSuv - rSuu * rSvv; if (fabs(D) < 1e-10) + { break; // bad case; use standard + } // compute step double fract = 1. / D; @@ -1049,7 +1113,9 @@ int ShapeAnalysis_Surface::SurfaceNewton(const gp_Pnt2d& p2dPrev, U += du; V += dv; if (U < UF || U > UL || V < VF || V > VL) + { break; + } // check that iterations do not diverge // pdn double rs2 = rs.SquareMagnitude(); // if ( rs2 > 4.*rs2p ) break; @@ -1058,18 +1124,24 @@ int ShapeAnalysis_Surface::SurfaceNewton(const gp_Pnt2d& p2dPrev, // test the step by uv and deviation from the solution double aResolution = std::max(1e-12, (U + V) * 10e-16); if (fabs(du) + fabs(dv) > aResolution) + { continue; // Precision::PConfusion() continue; + } // if ( U < UF || U > UL || V < VF || V > VL ) break; // pdn PRO10109 4517: protect against wrong result double rs2 = rs.SquareMagnitude(); if (rs2 > rsfirst.SquareMagnitude()) + { break; + } double rsn = rs * n; if (rs2 - rsn * rsn / nrm2 > Tol2) + { break; + } // if ( rs2 > 100 * preci * preci ) { fail = 6; break; } @@ -1119,7 +1191,9 @@ gp_Pnt2d ShapeAnalysis_Surface::NextValueOfUV(const gp_Pnt2d& p2dPrev, { double aKnot = aBSpline->UKnot(anIdx); if (std::abs(aKnot - p2dPrev.X()) < Precision::Confusion()) + { return ValueOfUV(P3D, preci); + } } } @@ -1132,7 +1206,9 @@ gp_Pnt2d ShapeAnalysis_Surface::NextValueOfUV(const gp_Pnt2d& p2dPrev, { double aKnot = aBSpline->VKnot(anIdx); if (std::abs(aKnot - p2dPrev.Y()) < Precision::Confusion()) + { return ValueOfUV(P3D, preci); + } } } } @@ -1149,7 +1225,9 @@ gp_Pnt2d ShapeAnalysis_Surface::NextValueOfUV(const gp_Pnt2d& p2dPrev, myGap = UVFromIso(P3D, preci, U, V); // gp_Pnt2d p = ValueOfUV ( P3D, preci ); if (gap >= myGap) + { return gp_Pnt2d(U, V); + } } myGap = gap; return sol; @@ -1252,9 +1330,13 @@ gp_Pnt2d ShapeAnalysis_Surface::ValueOfUV(const gp_Pnt& P3D, const double preci) // if (IsUClosed()) du = 0; if (IsVClosed()) dv = 0; // Forcer appel a IsU-VClosed if (myUCloseVal < 0) + { IsUClosed(); + } if (myVCloseVal < 0) + { IsVClosed(); + } double du = 0., dv = 0.; // extension of the surface range is limited to non-offset surfaces as the latter // can throw exception (e.g. Geom_UndefinedValue) when computing value - see id23943 @@ -1318,6 +1400,7 @@ gp_Pnt2d ShapeAnalysis_Surface::ValueOfUV(const gp_Pnt& P3D, const double preci) } } if (disSurf < 10 * preci) + { if (mySurf->Continuity() != GeomAbs_C0) { constexpr double Tol = Precision::Confusion(); @@ -1334,6 +1417,7 @@ gp_Pnt2d ShapeAnalysis_Surface::ValueOfUV(const gp_Pnt& P3D, const double preci) possLockal = (dist < Tol * Tol); } } + } if (!possLockal) { DistMinOnIso = UVFromIso(P3D, preci, UU, VV); @@ -1420,7 +1504,9 @@ gp_Pnt2d ShapeAnalysis_Surface::ValueOfUV(const gp_Pnt& P3D, const double preci) if (computed) { if (myGap <= 0) + { myGap = P3D.Distance(SurfAdapt.Value(S, T)); + } } else { @@ -1450,7 +1536,9 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d theMin = depart.Distance(P3d); if (theMin < preci / 10) + { return theMin; // c etait deja OK + } ComputeBoxes(); if (myIsoUF.IsNull() || myIsoUL.IsNull() || myIsoVF.IsNull() || myIsoVL.IsNull()) { @@ -1518,7 +1606,9 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d if (!Precision::IsInfinite(par) && !iso.IsNull()) { if (anIsoBox && anIsoBox->Distance(aPBox) > theMin) + { continue; + } Cf = iso->FirstParameter(); Cl = iso->LastParameter(); @@ -1582,7 +1672,9 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d break; } if (anIsoBox && anIsoBox->Distance(aPBox) > theMin) + { continue; + } dist = ShapeAnalysis_Curve().Project(*anAdaptor, P3d, preci, pntres, other); if (dist < theMin) { @@ -1622,9 +1714,13 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d { theMin = dist; if (UV) + { VV = other; + } else + { UU = other; + } } } UV = !UV; @@ -1648,9 +1744,13 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d { theMin = dist; if (UV) + { VV = other; + } else + { UU = other; + } } } UV = !UV; @@ -1682,9 +1782,13 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d { theMin = dist; if (UV) + { VV = other; + } else + { UU = other; + } } UV = !UV; if (UV) @@ -1705,9 +1809,13 @@ double ShapeAnalysis_Surface::UVFromIso(const gp_Pnt& P3d, const double preci, d { theMin = dist; if (UV) + { VV = other; + } else + { UU = other; + } } UV = !UV; Iters++; @@ -1741,11 +1849,13 @@ void ShapeAnalysis_Surface::SortSingularities() double minPreci = myPreci[i]; int minIndex = i; for (int j = i + 1; j < myNbDeg; j++) + { if (minPreci > myPreci[j]) { minPreci = myPreci[j]; minIndex = j; } + } if (minIndex != i) { myPreci[minIndex] = myPreci[i]; @@ -1788,17 +1898,27 @@ void ShapeAnalysis_Surface::SetDomain(const double U1, void ShapeAnalysis_Surface::ComputeBoxes() { if (myIsoBoxes) + { return; + } myIsoBoxes = true; ComputeBoundIsos(); if (!myIsoUF.IsNull()) + { BndLib_Add3dCurve::Add(GeomAdaptor_Curve(myIsoUF), Precision::Confusion(), myBndUF); + } if (!myIsoUL.IsNull()) + { BndLib_Add3dCurve::Add(GeomAdaptor_Curve(myIsoUL), Precision::Confusion(), myBndUL); + } if (!myIsoVF.IsNull()) + { BndLib_Add3dCurve::Add(GeomAdaptor_Curve(myIsoVF), Precision::Confusion(), myBndVF); + } if (!myIsoVL.IsNull()) + { BndLib_Add3dCurve::Add(GeomAdaptor_Curve(myIsoVL), Precision::Confusion(), myBndVL); + } } const Bnd_Box& ShapeAnalysis_Surface::GetBoxUF() diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx index 3c0166173a..624fe7bf2f 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx @@ -64,7 +64,9 @@ void ShapeAnalysis_TransferParameters::Init(const TopoDS_Edge& E, const TopoDS_F myLast2d = l2d; myFace = F; if (curve3d.IsNull() || curve2d.IsNull()) + { return; + } double ln2d = l2d - f2d; double ln3d = l - f; @@ -87,7 +89,9 @@ occ::handle> ShapeAnalysis_TransferParameters::Per { occ::handle> res = new NCollection_HSequence; for (int i = 1; i <= Params->Length(); i++) + { res->Append(Perform(Params->Value(i), To2d)); + } return res; } @@ -97,9 +101,13 @@ double ShapeAnalysis_TransferParameters::Perform(const double Param, const bool { double NewParam; if (To2d) + { NewParam = myShift + Param * myScale; + } else + { NewParam = -myShift / myScale + Param * 1. / myScale; + } return NewParam; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx index de4e10d55d..1f55c06192 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx @@ -83,7 +83,9 @@ void ShapeAnalysis_TransferParametersProj::Init(const TopoDS_Edge& E, const Topo } if (F.IsNull()) + { return; + } double f2d, l2d; ShapeAnalysis_Edge sae; @@ -109,7 +111,9 @@ occ::handle> ShapeAnalysis_TransferParametersProj: // pdn if (!myInitOK || (!myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge))) + { return ShapeAnalysis_TransferParameters::Perform(Knots, To2d); + } occ::handle> resKnots = new NCollection_HSequence; @@ -128,30 +132,44 @@ occ::handle> ShapeAnalysis_TransferParametersProj: double par = PreformSegment(Knots->Value(j), To2d, prevPar, lastPar); prevPar = par; if (prevPar > lastPar) + { prevPar -= preci; + } resKnots->Append(par); if (par > maxPar) + { maxPar = par; + } } // pdn correcting on periodic if (myCurve->IsClosed()) { for (j = len; j >= 1; j--) + { if (resKnots->Value(j) < maxPar) + { resKnots->SetValue(j, (To2d ? myAC3d.LastParameter() : myCurve->LastParameter()) - (len - j) * preci); + } else + { break; + } + } } // pdn correction on range for (j = 1; j <= len; j++) { if (resKnots->Value(j) < first) + { resKnots->SetValue(j, first); + } if (resKnots->Value(j) > last) + { resKnots->SetValue(j, last); + } } return resKnots; @@ -167,7 +185,9 @@ double ShapeAnalysis_TransferParametersProj::PreformSegment(const double Param, double linPar = ShapeAnalysis_TransferParameters::Perform(Param, To2d); if (!myInitOK || (!myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge))) + { return linPar; + } double linDev, projDev; @@ -191,7 +211,9 @@ double ShapeAnalysis_TransferParametersProj::PreformSegment(const double Param, } if (linDev <= projDev || (linDev < myPrecision && linDev <= 2 * projDev)) + { ppar = linPar; + } return ppar; } @@ -201,21 +223,31 @@ double ShapeAnalysis_TransferParametersProj::Perform(const double Knot, const bo { if (!myInitOK || (!myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge))) + { return ShapeAnalysis_TransferParameters::Perform(Knot, To2d); + } double res; if (To2d) + { res = PreformSegment(Knot, To2d, myAC3d.FirstParameter(), myAC3d.LastParameter()); + } else + { res = PreformSegment(Knot, To2d, myFirst, myLast); + } // pdn correction on range double first = (To2d ? myAC3d.FirstParameter() : myFirst); double last = (To2d ? myAC3d.LastParameter() : myLast); if (res < first) + { res = first; + } if (res > last) + { res = last; + } return res; } @@ -240,7 +272,9 @@ static double CorrectParameter(const occ::handle& crv, const doubl { double valknot = bspline->Knot(j); if (std::abs(valknot - param) < Precision::PConfusion()) + { return valknot; + } } } return param; @@ -340,7 +374,9 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, { toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull()) + { continue; + } TopLoc_Location loc = (EdgeLoc * toGC->Location()).Inverted(); if (toGC->IsCurve3D()) { @@ -353,7 +389,9 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, { occ::handle C3d = toGC->Curve3D(); if (C3d.IsNull()) + { continue; + } double first = toGC->First(); double last = toGC->Last(); double len = last - first; @@ -373,9 +411,13 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, double d01 = pos1.Distance(ploc1); double d02 = pos2.Distance(ploc2); if (useLinearFirst || useLinear || d01 <= dist1 || (d01 < myPrecision && d01 <= 2 * dist1)) + { ppar1 = linFirst; + } if (useLinearLast || useLinear || d02 <= dist2 || (d02 < myPrecision && d02 <= 2 * dist2)) + { ppar2 = linLast; + } } if (ppar1 > ppar2) { @@ -386,9 +428,13 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, if (ppar2 - ppar1 < preci) { if (ppar1 - toGC->First() < preci) + { ppar2 += 2 * preci; + } else if (toGC->Last() - ppar2 < preci) + { ppar1 -= 2 * preci; + } else { ppar1 -= preci; @@ -399,7 +445,9 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, // if(fabs(ppar1- firstPar) > Precision::PConfusion() || // fabs(ppar2 - lastPar) >Precision::PConfusion()) // by LSS if (ppar1 != firstPar || ppar2 != lastPar) + { samerange = false; + } } else if (toGC->IsCurveOnSurface()) { // continue; || @@ -429,18 +477,26 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, bool isLastOnEnd = (last - ppar2) / len < Precision::PConfusion(); bool useLinear = std::abs(ppar1 - ppar2) < Precision::PConfusion(); if (isFirstOnEnd && !localLinearFirst) + { localLinearFirst = true; + } if (isLastOnEnd && !localLinearLast) + { localLinearLast = true; + } gp_Pnt pos1 = Ad1.Value(linFirst); gp_Pnt pos2 = Ad1.Value(linLast); double d01 = pos1.Distance(ploc1); double d02 = pos2.Distance(ploc2); if (localLinearFirst || useLinear || d01 <= dist1 || (d01 < myPrecision && d01 <= 2 * dist1)) + { ppar1 = linFirst; + } if (localLinearLast || useLinear || d02 <= dist2 || (d02 < myPrecision && d02 <= 2 * dist2)) + { ppar2 = linLast; + } if (ppar1 > ppar2) { @@ -453,9 +509,13 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, if (ppar2 - ppar1 < preci) { if (ppar1 - toGC->First() < preci) + { ppar2 += 2 * preci; + } else if (toGC->Last() - ppar2 < preci) + { ppar1 -= 2 * preci; + } else { ppar1 -= preci; @@ -466,7 +526,9 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, // if(fabs(ppar1 - firstPar) > Precision::PConfusion() || // fabs(ppar2 -lastPar) > Precision::PConfusion())// by LSS if (ppar1 != firstPar || ppar2 != lastPar) + { samerange = false; + } } } B.SameRange(newEdge, samerange); @@ -479,9 +541,13 @@ bool ShapeAnalysis_TransferParametersProj::IsSameRange() const if (!myInitOK || (!myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge))) + { return ShapeAnalysis_TransferParameters::IsSameRange(); + } else + { return false; + } } //================================================================================================= @@ -499,7 +565,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { TopoDS_Vertex anewV; if (theV.Orientation() != TopAbs_INTERNAL && theV.Orientation() != TopAbs_EXTERNAL) + { return anewV; + } TopLoc_Location fromLoc; double f1, l1; @@ -524,7 +592,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { const occ::handle& pr = itpr.Value(); if (pr.IsNull()) + { continue; + } if (pr->IsPointOnCurve(C1, fromLoc)) { aOldPar = pr->Parameter(); @@ -551,7 +621,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { occ::handle fromGC = occ::down_cast(fromitcr.Value()); if (fromGC.IsNull() || !fromGC->IsCurveOnSurface()) + { continue; + } TopLoc_Location aL = fromGC->Location().Predivided(theV.Location()); occ::handle surface1 = fromGC->Surface(); @@ -566,7 +638,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve } } if (found) + { continue; + } } if (pr->IsPointOnCurve()) { @@ -593,7 +667,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve ShapeAnalysis_Curve sae; double adist = sae.Project(C2, apv, Precision::Confusion(), projP, apar); if (aTol < adist) + { aTol = adist; + } } BRep_Builder aB; aB.UpdateVertex(anewV, apar, toedge, aTol); @@ -609,7 +685,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { occ::handle toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull() || !toGC->IsCurveOnSurface()) + { continue; + } TopLoc_Location aL = (toLoc * toGC->Location()).Predivided(theV.Location()); // aL.Predivided(theV.Location()); @@ -626,7 +704,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve } } if (needUpdate) + { aB.UpdateVertex(anewV, aTol); + } return anewV; } @@ -638,7 +718,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { TopoDS_Vertex anewV; if (theV.Orientation() != TopAbs_INTERNAL && theV.Orientation() != TopAbs_EXTERNAL) + { return anewV; + } TopLoc_Location fromLoc; TopLoc_Location toLoc; @@ -661,7 +743,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve { const occ::handle& pr = itpr.Value(); if (pr.IsNull()) + { continue; + } TopLoc_Location aLoc = pr->Location(); if (pr->IsPointOnCurveOnSurface()) { @@ -705,7 +789,9 @@ TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex(const TopoDS_Ve apar2 = aP2d.Y(); if (aTol < aSurfTool->Gap()) + { aTol = aSurfTool->Gap() + 0.1 * Precision::Confusion(); + } // occ::handle aPS = new // BRep_PointOnSurface(aP2d.X(),aP2d.Y(),toSurf,toLoc); alistrep.Append(aPS); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Wire.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Wire.cxx index d13af81d3f..a378cb2a0c 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Wire.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Wire.cxx @@ -270,7 +270,9 @@ bool ShapeAnalysis_Wire::CheckEdgeCurves() { myStatusEdgeCurves = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } int i, nb = myWire->NbEdges(); ShapeAnalysis_Edge SAE; @@ -281,46 +283,74 @@ bool ShapeAnalysis_Wire::CheckEdgeCurves() SAE.CheckCurve3dWithPCurve(E, myFace); if (SAE.Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (SAE.Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } SAE.CheckVerticesWithPCurve(E, myFace); if (SAE.Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (SAE.Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } SAE.CheckVerticesWithCurve3d(E); if (SAE.Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } if (SAE.Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } CheckSeam(i); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL4); + } CheckGap3d(i); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE5); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL5); + } CheckGap2d(i); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE6); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL6); + } double maxdev = 0.0; SAE.CheckSameParameter(myWire->Edge(i), maxdev); if (SAE.Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE7); + } if (SAE.Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL7); + } } return StatusEdgeCurves(ShapeExtend_DONE); } @@ -343,21 +373,31 @@ bool ShapeAnalysis_Wire::CheckSelfIntersection() { myStatusSelfIntersection = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } int i, nb = myWire->NbEdges(); for (i = 1; i <= nb; i++) { CheckSelfIntersectingEdge(i); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } CheckIntersectingEdges(i); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } } NCollection_Array1 boxes(1, nb); @@ -384,19 +424,27 @@ bool ShapeAnalysis_Wire::CheckSelfIntersection() { int fin = nb; if (CheckClosed(Precision::Confusion()) && 1 == num1) + { fin = nb - 1; + } for (int num2 = num1 + 2; num2 <= fin; num2++) + { if (!boxes(num1).IsOut(boxes(num2))) { CheckIntersectingEdges(num1, num2); isFail |= LastCheckStatus(ShapeExtend_FAIL1); isDone |= LastCheckStatus(ShapeExtend_DONE1); } + } } if (isFail) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } if (isDone) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } return StatusSelfIntersection(ShapeExtend_DONE); } @@ -406,7 +454,9 @@ bool ShapeAnalysis_Wire::CheckSelfIntersection() bool ShapeAnalysis_Wire::CheckLacking() { if (!IsReady() || NbEdges() < 2) + { return false; + } for (int i = 1; i <= myWire->NbEdges(); i++) { CheckLacking(i); @@ -421,19 +471,29 @@ bool ShapeAnalysis_Wire::CheckClosed(const double prec) { myStatusClosed = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 1) + { return false; + } CheckConnected(1, prec); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } CheckDegenerated(1); if (LastCheckStatus(ShapeExtend_DONE)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (LastCheckStatus(ShapeExtend_FAIL)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return StatusClosed(ShapeExtend_DONE); } @@ -444,7 +504,9 @@ bool ShapeAnalysis_Wire::CheckGaps3d() { myStatusGaps3d = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() < 1) + { return false; // gka IsLoaded + } double dist, maxdist = 0.; @@ -456,7 +518,9 @@ bool ShapeAnalysis_Wire::CheckGaps3d() { dist = MinDistance3d(); if (maxdist < dist) + { maxdist = dist; + } } } myMin3d = myMax3d = maxdist; @@ -470,7 +534,9 @@ bool ShapeAnalysis_Wire::CheckGaps2d() { myStatusGaps2d = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 1) + { return false; + } double dist, maxdist = 0.; @@ -482,7 +548,9 @@ bool ShapeAnalysis_Wire::CheckGaps2d() { dist = MinDistance2d(); if (maxdist < dist) + { maxdist = dist; + } } } myMin2d = myMax2d = maxdist; @@ -496,7 +564,9 @@ bool ShapeAnalysis_Wire::CheckCurveGaps() { myStatusCurveGaps = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 1) + { return false; + } double dist, maxdist = 0.; @@ -508,7 +578,9 @@ bool ShapeAnalysis_Wire::CheckCurveGaps() { dist = MinDistance3d(); if (maxdist < dist) + { maxdist = dist; + } } } myMin3d = myMax3d = maxdist; @@ -622,7 +694,9 @@ bool ShapeAnalysis_Wire::CheckConnected(const int num, const double prec) { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() < 1) + { return false; + } int n2 = (num > 0 ? num : NbEdges()); int n1 = (n2 > 1 ? n2 - 1 : NbEdges()); @@ -640,29 +714,41 @@ bool ShapeAnalysis_Wire::CheckConnected(const int num, const double prec) return false; } if (V1.IsSame(V2)) + { return false; + } gp_Pnt p1 = BRep_Tool::Pnt(V1); gp_Pnt p2 = BRep_Tool::Pnt(V2); myMin3d = p1.Distance(p2); if (myMin3d <= gp::Resolution()) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } else if (myMin3d <= myPrecision) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } else if (myMin3d <= prec) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } else { // et en inversant la derniere edge ? if (n1 == n2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } else { V2 = sae.LastVertex(E2); p2 = BRep_Tool::Pnt(V2); double dist = p1.Distance(p2); if (dist > myPrecision) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } else { myMin3d = dist; @@ -680,7 +766,9 @@ bool ShapeAnalysis_Wire::CheckSmall(const int num, const double precsmall) { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() <= 1) + { return false; + } TopoDS_Edge E = myWire->Edge(num ? num : NbEdges()); ShapeAnalysis_Edge sae; @@ -690,7 +778,9 @@ bool ShapeAnalysis_Wire::CheckSmall(const int num, const double precsmall) //: n2 abv 22 Jan 99: ma-test5.igs -> IGES (brep) -> read (pref3d): // degen edge with no pcurve should be removed if (!myFace.IsNull() && sae.HasPCurve(E, Face())) + { return false; + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } @@ -706,7 +796,9 @@ bool ShapeAnalysis_Wire::CheckSmall(const int num, const double precsmall) double dist = p1.Distance(p2); double prec = precsmall; // Min ( myPrecision, precsmall ); if (dist > prec) + { return false; // not small enough + } // The 3D curve now: is it CLOSED or ZERO LENGTH...??? // To do this, we take the midpoint (is there anything better?) @@ -734,7 +826,9 @@ bool ShapeAnalysis_Wire::CheckSmall(const int num, const double precsmall) } } if (aMidpoint.Distance(p1) > prec || aMidpoint.Distance(p2) > prec) + { return false; + } myStatus |= ShapeExtend::EncodeStatus(V1.IsSame(V2) ? ShapeExtend_DONE1 : ShapeExtend_DONE2); return true; @@ -750,13 +844,19 @@ bool ShapeAnalysis_Wire::CheckSeam(const int num, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } int n = num; if (n == 0) + { n = NbEdges(); + } TopoDS_Edge E = myWire->Edge(n); if (!ShapeAnalysis_Edge().IsSeam(E, myFace)) + { return false; + } // Extract the Two PCurves of the Seam TopoDS_Face ForwardFace = myFace; ForwardFace.Orientation(TopAbs_FORWARD); @@ -766,13 +866,17 @@ bool ShapeAnalysis_Wire::CheckSeam(const int num, C1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(EF), ForwardFace, cf, cl); C2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(ER), ForwardFace, cf, cl); if (C1.IsNull() || C2.IsNull()) + { return false; + } // SelectForward est destine a devenir un outil distinct int theCurveIndice = ShapeAnalysis_Curve().SelectForwardSeam(C1, C2); if (theCurveIndice != 2) + { return false; + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); return true; @@ -793,7 +897,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 1) + { return false; + } int n2 = (num > 0) ? num : NbEdges(); int n1 = (n2 > 1) ? n2 - 1 : NbEdges(); @@ -835,7 +941,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 //: abv 13.05.02: OCC320 - fail (to remove edge) if two consecutive degenerated edges w/o //: pcurves if (BRep_Tool::Degenerated(E2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return false; } @@ -845,7 +953,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 TopoDS_Vertex V2 = sae.LastVertex(E2); if (Vp.IsNull() || V0.IsNull() || V1.IsNull() || V2.IsNull()) + { return false; + } gp_Pnt pp = BRep_Tool::Pnt(Vp); //: i9 gp_Pnt p0 = BRep_Tool::Pnt(V0); @@ -873,7 +983,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 { gp_Pnt p = C3d->Value(0.5 * (a + b)); if (p.SquareDistance(p1) > precVtx * precVtx) + { dgnr = false; + } } } } @@ -882,7 +994,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 //: i9 abv 23 Sep 98: CTS20315-2 #63231: check that previous edge is not degenerated if (n1 != n2 && p1.Distance(pp) <= precFirst && mySurf->IsDegenerated(pp, precFirst) && !BRep_Tool::Degenerated(E1)) + { return false; + } // rln S4135 ShapeAnalysis_Surface new algorithms for singularities //: 45 by abv 16 Dec 97: BUC60035 2659: precision increased to vertex tolerance // double prec = Max ( myPrecision, BRep_Tool::Tolerance(V1) ); @@ -906,11 +1020,13 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 mySurf->Singularity(i, tmpPreci, tmpP3d, p2d1, p2d2, par1, par2, tmpUIsoDeg); double gap2 = p1.SquareDistance(tmpP3d); if (gap2 <= precVtx * precVtx) + { if (gapMin2 > gap2) { gapMin2 = gap2; indMin = i; } + } } if (indMin >= 1) { @@ -928,14 +1044,18 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 //: abv 29.08.01: if singularity not detected but edge is marked // as degenerated, report fail if (BRep_Tool::Degenerated(E2) && !sae.HasPCurve(E2, Face())) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return false; } // OK, degenerated case detected; we will find its start and end in 2d if (lack) + { forward = true; + } //: 24 by abv 28 Nov 97: // make degenerative pcurve parametrized exactly from end of pcurve of the @@ -950,14 +1070,18 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 p2d1 = c2d->Value(b); } else + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } // pdn pcurves (fixing regression in f0 in degenerated case) if (sae.PCurve((dgnr ? E3 : E2), myFace, c2d, a, b, true)) { p2d2 = c2d->Value(a); } else + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } } // #84 rln 18.03.99 if pcurve is not degenerate anymore, the fix is postponned @@ -967,7 +1091,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 //: abv 24.05.02: OCC320 - fail (to remove edge) if two consecutive degenerated edges w/o //: pcurves if (BRep_Tool::Degenerated(E2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return false; } @@ -977,7 +1103,9 @@ bool ShapeAnalysis_Wire::CheckDegenerated(const int num, gp_Pnt2d& p2d1, gp_Pnt2 GeomAdaptor_Surface& Ads = *mySurf->Adaptor3d(); double max = std::max(Ads.UResolution(myPrecision), Ads.VResolution(myPrecision)); if (p2d1.Distance(p2d2) /*Abs (par1 - par2)*/ <= max + gp::Resolution()) + { return false; + } myStatus = ShapeExtend::EncodeStatus(dgnr ? ShapeExtend_DONE2 : ShapeExtend_DONE1); return true; @@ -998,7 +1126,9 @@ bool ShapeAnalysis_Wire::CheckGap3d(const int num) myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); // szv#4:S4163:12Mar99 optimized if (!IsLoaded() || NbEdges() < 1) + { return false; // szvsh was nbedges < 2 + } int n2 = (num > 0 ? num : NbEdges()); int n1 = (n2 > 1 ? n2 - 1 : NbEdges()); TopoDS_Edge E1 = myWire->Edge(n1); @@ -1015,7 +1145,9 @@ bool ShapeAnalysis_Wire::CheckGap3d(const int num) gp_Pnt p2 = C2->Value(uf2); myMin3d = myMax3d = p1.Distance(p2); if (myMin3d > myPrecision) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } return LastCheckStatus(ShapeExtend_DONE); } @@ -1032,7 +1164,9 @@ bool ShapeAnalysis_Wire::CheckGap2d(const int num) myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); // szv#4:S4163:12Mar99 optimized if (!IsReady() || NbEdges() < 1) + { return false; // szvsh was nbedges < 2 + } int n2 = (num > 0 ? num : NbEdges()); int n1 = (n2 > 1 ? n2 - 1 : NbEdges()); TopoDS_Edge E1 = myWire->Edge(n1); @@ -1051,7 +1185,9 @@ bool ShapeAnalysis_Wire::CheckGap2d(const int num) GeomAdaptor_Surface& SA = *mySurf->Adaptor3d(); if (myMin2d > (std::max(SA.UResolution(myPrecision), SA.VResolution(myPrecision)) + Precision::PConfusion())) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } return LastCheckStatus(ShapeExtend_DONE); } @@ -1061,7 +1197,9 @@ bool ShapeAnalysis_Wire::CheckCurveGap(const int num) { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() < 1) + { return false; + } int n = (num > 0 ? num : NbEdges()); TopoDS_Edge E = myWire->Edge(n); double cuf, cul, pcuf, pcul; @@ -1090,11 +1228,15 @@ bool ShapeAnalysis_Wire::CheckCurveGap(const int num) pcpnt = ACS.Value(pcuf + i * (pcul - pcuf) / (nbp - 1)); dist = cpnt.SquareDistance(pcpnt); if (maxdist < dist) + { maxdist = dist; + } } myMin3d = myMax3d = std::sqrt(maxdist); if (myMin3d > myPrecision) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } return LastCheckStatus(ShapeExtend_DONE); } @@ -1114,7 +1256,9 @@ static gp_Pnt GetPointOnEdge(const TopoDS_Edge& edge, TopLoc_Location L; const occ::handle ConS = BRep_Tool::Curve(edge, L, f, l); if (!ConS.IsNull()) + { return ConS->Value(param).Transformed(L.Transformation()); + } } gp_Pnt2d aP2d = Crv2d.Value(param); return surf->Adaptor3d()->Value(aP2d.X(), aP2d.Y()); @@ -1131,7 +1275,9 @@ bool ShapeAnalysis_Wire::CheckSelfIntersectingEdge( points3d.Clear(); myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } TopoDS_Edge edge = WireData()->Edge(num > 0 ? num : NbEdges()); ShapeAnalysis_Edge sae; @@ -1144,7 +1290,9 @@ bool ShapeAnalysis_Wire::CheckSelfIntersectingEdge( return false; } if (std::abs(a - b) <= ::Precision::PConfusion()) + { return false; + } double tolint = 1.0e-10; // szv#4:S4163:12Mar99 warning @@ -1153,7 +1301,9 @@ bool ShapeAnalysis_Wire::CheckSelfIntersectingEdge( Geom2dInt_GInter Inter(AC, domain, tolint, tolint); if (!Inter.IsDone()) + { return false; + } TopoDS_Vertex V1 = sae.FirstVertex(edge); TopoDS_Vertex V2 = sae.LastVertex(edge); @@ -1174,7 +1324,9 @@ bool ShapeAnalysis_Wire::CheckSelfIntersectingEdge( const IntRes2d_Transition& Tr1 = IP.TransitionOfFirst(); const IntRes2d_Transition& Tr2 = IP.TransitionOfSecond(); if (Tr1.PositionOnCurve() != IntRes2d_Middle && Tr2.PositionOnCurve() != IntRes2d_Middle) + { continue; + } gp_Pnt pint = GetPointOnEdge(edge, mySurf, AC, IP.ParamOnFirst()); double dist21 = pnt1.SquareDistance(pint); double dist22 = pnt2.SquareDistance(pint); @@ -1216,7 +1368,9 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( errors.Clear(); myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 2) + { return false; + } // szv#4:S4163:12Mar99 optimized int n2 = (num > 0) ? num : NbEdges(); @@ -1255,7 +1409,8 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( } if (std::abs(a1 - b1) <= ::Precision::PConfusion() || // clang-format off - std::abs( a2 - b2 ) <= ::Precision::PConfusion() ) return false; //:f7 abv 6 May 98: BUC50070 on #42276 + std::abs( a2 - b2 ) <= ::Precision::PConfusion() ) { return false; //:f7 abv 6 May 98: BUC50070 on #42276 +} // clang-format on bool isForward1 = (edge1.Orientation() == TopAbs_FORWARD); @@ -1283,11 +1438,17 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( // NOTE: Tr1 and Tr2 are not reordered because they are used in the same manner Geom2dInt_GInter Inter; if (num == 1) + { Inter.Perform(C2, d2, C1, d1, tolint, tolint); + } else + { Inter.Perform(C1, d1, C2, d2, tolint, tolint); + } if (!Inter.IsDone()) + { return false; + } //: 86 abv 22 Jan 98: fix self-intersection even if tolerance of vertex is enough // to annihilate it. This is done to prevent wrong effects if vertex tolerance @@ -1305,23 +1466,31 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( IntRes2d_IntersectionPoint IP; IntRes2d_Transition Tr1, Tr2; if (i <= NbPoints) + { IP = Inter.Point(i); + } else { const IntRes2d_IntersectionSegment& Seg = Inter.Segment(i - NbPoints); if (!Seg.HasFirstPoint() || !Seg.HasLastPoint()) + { continue; + } IP = Seg.FirstPoint(); Tr1 = IP.TransitionOfFirst(); Tr2 = IP.TransitionOfSecond(); if (Tr1.PositionOnCurve() == IntRes2d_Middle || Tr2.PositionOnCurve() == IntRes2d_Middle) + { IP = Seg.LastPoint(); + } } Tr1 = IP.TransitionOfFirst(); Tr2 = IP.TransitionOfSecond(); if (Tr1.PositionOnCurve() != IntRes2d_Middle && Tr2.PositionOnCurve() != IntRes2d_Middle) + { continue; + } double param1, param2; param1 = (num == 1 ? IP.ParamOnSecond() : IP.ParamOnFirst()); param2 = (num == 1 ? IP.ParamOnFirst() : IP.ParamOnSecond()); @@ -1329,7 +1498,9 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( //: r6 abv 8 Apr 99: r_47-sd.stp #173850: protect against working out of curve range if (a1 - param1 > ::Precision::PConfusion() || param1 - b1 > ::Precision::PConfusion() || a2 - param2 > ::Precision::PConfusion() || param2 - b2 > ::Precision::PConfusion()) + { continue; + } //: 82 abv 21 Jan 98: point of intersection on Crv1 and Crv2 is different // clang-format off @@ -1392,7 +1563,9 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } occ::handle sbwd = WireData(); int n2 = (num2 > 0 ? num2 : sbwd->NbEdges()); int n1 = (num1 > 0 ? num1 : sbwd->NbEdges()); @@ -1417,7 +1590,9 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( if (std::abs(a1 - b1) <= ::Precision::PConfusion() || std::abs(a2 - b2) <= ::Precision::PConfusion()) + { return false; + } points2d.Clear(); points3d.Clear(); @@ -1442,7 +1617,9 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( Geom2dInt_GInter Inter; Inter.Perform(C1, d1, C2, d2, tolint, tolint); if (!Inter.IsDone()) + { return false; + } // #83 rln 19.03.99 sim2.igs, entity 4292 // processing also segments as in BRepCheck @@ -1452,22 +1629,30 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( IntRes2d_IntersectionPoint IP; IntRes2d_Transition Tr1, Tr2; if (i <= NbPoints) + { IP = Inter.Point(i); + } else { const IntRes2d_IntersectionSegment& Seg = Inter.Segment(i - NbPoints); if (!Seg.HasFirstPoint() || !Seg.HasLastPoint()) + { continue; + } IP = Seg.FirstPoint(); Tr1 = IP.TransitionOfFirst(); Tr2 = IP.TransitionOfSecond(); if (Tr1.PositionOnCurve() == IntRes2d_Middle || Tr2.PositionOnCurve() == IntRes2d_Middle) + { IP = Seg.LastPoint(); + } } Tr1 = IP.TransitionOfFirst(); Tr2 = IP.TransitionOfSecond(); if (Tr1.PositionOnCurve() != IntRes2d_Middle && Tr2.PositionOnCurve() != IntRes2d_Middle) + { continue; + } double param1 = IP.ParamOnFirst(); double param2 = IP.ParamOnSecond(); // clang-format off @@ -1481,14 +1666,18 @@ bool ShapeAnalysis_Wire::CheckIntersectingEdges( { double di1 = pi1.SquareDistance(vertexPoints(j)); if (di1 < vertexTolers(j) * vertexTolers(j)) + { OK1 = true; + } } for (int j = 3; (j <= 4) && !OK2; j++) { double di2 = pi2.SquareDistance(vertexPoints(j)); if (di2 < vertexTolers(j) * vertexTolers(j)) + { OK2 = true; + } } if (!OK1 || !OK2) @@ -1526,7 +1715,9 @@ bool ShapeAnalysis_Wire::CheckLacking(const int num, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } // szv#4:S4163:12Mar99 optimized int n2 = (num > 0) ? num : NbEdges(); @@ -1560,7 +1751,9 @@ bool ShapeAnalysis_Wire::CheckLacking(const int num, Geom2dAdaptor_Curve anAdapt(c2d); anAdapt.D1(b, p2d1, v1); if (E1.Orientation() == TopAbs_REVERSED) + { v1.Reverse(); + } if (!sae.PCurve(E2, myFace, c2d, a, b, true)) { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); @@ -1569,7 +1762,9 @@ bool ShapeAnalysis_Wire::CheckLacking(const int num, anAdapt.Load(c2d); anAdapt.D1(a, p2d2, v2); if (E2.Orientation() == TopAbs_REVERSED) + { v2.Reverse(); + } v12 = p2d2.XY() - p2d1.XY(); myMax2d = v12.SquareMagnitude(); @@ -1580,7 +1775,9 @@ bool ShapeAnalysis_Wire::CheckLacking(const int num, double tol2d = 2 * std::max(Ads.UResolution(tol), Ads.VResolution(tol)); if ( // tol2d < gp::Resolution() || //#2 smh 26.03.99 S4163 Zero divide myMax2d < tol2d * tol2d) + { return false; + } myMax2d = std::sqrt(myMax2d); myMax3d = tol * myMax2d / std::max(tol2d, gp::Resolution()); @@ -1589,7 +1786,9 @@ bool ShapeAnalysis_Wire::CheckLacking(const int num, if (myMax2d < Precision::PConfusion() || //: abv 03.06.02 CTS21866.stp (v1.SquareMagnitude() > gp::Resolution() && std::abs(v12.Angle(v1)) > 0.9 * M_PI) || (v2.SquareMagnitude() > gp::Resolution() && std::abs(v12.Angle(v2)) > 0.9 * M_PI)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } return true; } @@ -1607,20 +1806,28 @@ bool ShapeAnalysis_Wire::CheckOuterBound(const bool APIMake) { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } TopoDS_Wire wire; if (APIMake) + { wire = myWire->WireAPIMake(); + } else + { wire = myWire->Wire(); + } TopoDS_Shape sh = myFace.EmptyCopied(); // szv#4:S4163:12Mar99 SGI warns TopoDS_Face face = TopoDS::Face(sh); BRep_Builder B; B.Add(face, wire); if (ShapeAnalysis::IsOuterBound(face)) + { return false; + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); return true; } @@ -1661,7 +1868,9 @@ bool ShapeAnalysis_Wire::CheckNotchedEdges(const int num, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } int n2 = (num > 0) ? num : NbEdges(); int n1 = (n2 > 1) ? n2 - 1 : NbEdges(); @@ -1669,7 +1878,9 @@ bool ShapeAnalysis_Wire::CheckNotchedEdges(const int num, TopoDS_Edge E2 = myWire->Edge(n2); if (BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2)) + { return false; + } ShapeAnalysis_Edge sae; TopoDS_Vertex V1 = sae.LastVertex(E1); @@ -1697,7 +1908,9 @@ bool ShapeAnalysis_Wire::CheckNotchedEdges(const int num, } if (E1.Orientation() == TopAbs_REVERSED) + { c2d1->D1(a1, p2d1, v1); + } else { c2d1->D1(b1, p2d1, v1); @@ -1715,13 +1928,19 @@ bool ShapeAnalysis_Wire::CheckNotchedEdges(const int num, v2.Reverse(); } else + { c2d2->D1(a2, p2d2, v2); + } if (v2.Magnitude() < gp::Resolution() || v1.Magnitude() < gp::Resolution()) + { return false; + } if (std::abs(v2.Angle(v1)) > 0.1 || p2d1.Distance(p2d2) > Tolerance) + { return false; + } occ::handle AC2d1 = new Geom2dAdaptor_Curve(c2d1, a1, b1); occ::handle AdS1 = new GeomAdaptor_Surface(new Geom_Plane(gp_Pln())); @@ -1744,7 +1963,9 @@ bool ShapeAnalysis_Wire::CheckNotchedEdges(const int num, double dist2 = ProjectInside(Ad2, gp_Pnt(p2d1.X(), p2d1.Y(), 0), Tolerance, Proj2, param2, false); if (dist1 > Tolerance && dist2 > Tolerance) + { return false; + } if (dist1 < dist2) { @@ -1786,7 +2007,9 @@ bool ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire) const int aNbControl = 23; const int NbEdges = myWire->NbEdges(); if (!IsReady() || NbEdges < 1) + { return false; + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); double aF, aL, aLength(0.0); @@ -1894,7 +2117,9 @@ bool ShapeAnalysis_Wire::CheckShapeConnect(double& tailhead, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); if (!IsLoaded() || shape.IsNull()) + { return false; + } TopoDS_Vertex V1, V2; TopoDS_Edge E; TopoDS_Wire W; @@ -1911,7 +2136,9 @@ bool ShapeAnalysis_Wire::CheckShapeConnect(double& tailhead, ShapeAnalysis::FindBounds(W, V1, V2); } else + { return false; + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); // on va comparer les points avec ceux de thevfirst et thevlast gp_Pnt p1 = BRep_Tool::Pnt(V1); @@ -1960,12 +2187,18 @@ bool ShapeAnalysis_Wire::CheckShapeConnect(double& tailhead, break; } if (!res1) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE5); + } if (!res2) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE6); + } if (myMin3d > std::max(myPrecision, prec)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return LastCheckStatus(ShapeExtend_DONE); } @@ -1981,9 +2214,13 @@ bool isMultiVertex(const NCollection_List& for (; lIt1.More(); lIt1.Next()) { if (aMapSmallEdges.Contains(lIt1.Value())) + { nbNotAccount++; + } else if (aMapSeemEdges.Contains(lIt1.Value())) + { nbNotAccount++; + } } return ((alshape.Extent() - nbNotAccount) > 2); } @@ -1997,7 +2234,9 @@ bool ShapeAnalysis_Wire::CheckLoop( { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() < 2) + { return false; + } double aSavPreci = Precision(); SetPrecision(Precision::Infinite()); int i = 1; @@ -2014,11 +2253,17 @@ bool ShapeAnalysis_Wire::CheckLoop( } bool isSame = aV1.IsSame(aV2); if (myWire->IsSeam(i)) + { aMapSeemEdges.Add(aedge); /// continue; + } else if (BRep_Tool::Degenerated(aedge)) + { aMapSmallEdges.Add(aedge); + } else if (isSame && CheckSmall(i, BRep_Tool::Tolerance(aV1))) + { aMapSmallEdges.Add(aedge); + } if (!aMapVertexEdges.IsBound(aV1)) { @@ -2036,18 +2281,24 @@ bool ShapeAnalysis_Wire::CheckLoop( alshape.Append(aedge); alshape.Append(aedge); if (alshape.Extent() > 2 && isMultiVertex(alshape, aMapSmallEdges, aMapSeemEdges)) + { aMapLoopVertices.Add(aV1); + } } else { NCollection_List& alshape = aMapVertexEdges.ChangeFind(aV1); alshape.Append(aedge); if (alshape.Extent() > 2 && isMultiVertex(alshape, aMapSmallEdges, aMapSeemEdges)) + { aMapLoopVertices.Add(aV1); + } NCollection_List& alshape2 = aMapVertexEdges.ChangeFind(aV2); alshape2.Append(aedge); if (alshape2.Extent() > 2 && isMultiVertex(alshape2, aMapSmallEdges, aMapSeemEdges)) + { aMapLoopVertices.Add(aV2); + } } } SetPrecision(aSavPreci); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx index 8fb34dce01..391530c241 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx @@ -708,7 +708,9 @@ int ShapeAnalysis_WireOrder::Status() const int ShapeAnalysis_WireOrder::Ordered(const int theIdx) const { if (myOrd.IsNull() || myOrd->Upper() < theIdx) + { return theIdx; + } int anOldIdx = myOrd->Value(theIdx); return (anOldIdx == 0 ? theIdx : anOldIdx); } @@ -744,7 +746,9 @@ void ShapeAnalysis_WireOrder::XY(const int theIdx, gp_XY& theStart2D, gp_XY& the double ShapeAnalysis_WireOrder::Gap(const int num) const { if (num == 0) + { return myGap; + } int n1 = Ordered(num); int n0 = Ordered(num == 1 ? NbEdges() : num - 1); // Distance entre fin (n0) et debut (n1) @@ -759,7 +763,9 @@ void ShapeAnalysis_WireOrder::SetChains(const double gap) { int n0, n1, n2, nb = NbEdges(); // szv#4:S4163:12Mar99 o0,o1,o2 not needed if (nb == 0) + { return; + } NCollection_Sequence chain; n0 = 0; chain.Append(1); // On demarre la partie @@ -785,10 +791,14 @@ void ShapeAnalysis_WireOrder::SetChains(const double gap) } nb = chain.Length(); if (nb == 0) + { return; + } myChains = new NCollection_HArray1(1, nb); for (n1 = 1; n1 <= nb; n1++) + { myChains->SetValue(n1, chain.Value(n1)); + } } //================================================================================================= @@ -804,15 +814,23 @@ void ShapeAnalysis_WireOrder::Chain(const int num, int& n1, int& n2) const { n1 = n2 = 0; if (myChains.IsNull()) + { return; + } int nb = myChains->Upper(); if (num == 0 || num > nb) + { return; + } n1 = myChains->Value(num); if (num == nb) + { n2 = NbEdges(); + } else + { n2 = myChains->Value(num + 1) - 1; + } } //================================================================================================= @@ -837,10 +855,14 @@ void ShapeAnalysis_WireOrder::Couple(const int num, int& n1, int& n2) const { n1 = n2 = 0; if (myCouples.IsNull()) + { return; + } int nb = myCouples->Upper(); if (num == 0 || num * 2 > nb) + { return; + } n1 = myCouples->Value(2 * num - 1); n2 = myCouples->Value(2 * num); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx index 737fbec1ae..4db580dcf5 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx @@ -49,7 +49,9 @@ void ShapeAnalysis_WireVertex::Init(const occ::handle& sbw { int nb = sbwd->NbEdges(); if (nb == 0) + { return; + } myDone = false; myWire = sbwd; myStat = new NCollection_HArray1(1, nb); @@ -88,7 +90,9 @@ void ShapeAnalysis_WireVertex::SetPrecision(const double preci) void ShapeAnalysis_WireVertex::Analyze() { if (myStat.IsNull()) + { return; + } myDone = true; // Analyse des vertex qui se suivent occ::handle c1, c2; @@ -111,7 +115,9 @@ void ShapeAnalysis_WireVertex::Analyze() EA.Curve3d(myWire->Edge(i), c1, cf, upre); EA.Curve3d(myWire->Edge(j), c2, ufol, cl); if (c1.IsNull() || c2.IsNull()) + { continue; // on ne peut rien faire ... + } gp_Pnt P1 = c1->Value(upre); gp_Pnt P2 = c2->Value(ufol); @@ -120,14 +126,20 @@ void ShapeAnalysis_WireVertex::Analyze() double d2 = PV2.Distance(P2); double dd = PV1.Distance(PV2); if (d1 <= tol1 && d2 <= tol2 && dd <= (tol1 + tol2)) + { stat = 1; + } else if (d1 <= myPreci && d2 <= myPreci && dd <= myPreci) + { stat = 2; + } myStat->SetValue(i, -1); // par defaut if (stat > 0) { if (V1 == V2) + { stat = 0; + } } if (stat >= 0) { @@ -293,8 +305,12 @@ int ShapeAnalysis_WireVertex::NextStatus(const int stat, const int num) const { int i, nb = myStat->Length(); for (i = num + 1; i <= nb; i++) + { if (myStat->Value(i) == stat) + { return i; + } + } } return 0; } @@ -313,7 +329,9 @@ int ShapeAnalysis_WireVertex::NextCriter(const int crit, const int num) const if ((crit == -1 && stat < 0) || (crit == 0 && stat == 0) || (crit == 1 && stat > 0) || (crit == 2 && (stat >= 0 && stat <= 2)) || (crit == 3 && (stat == 1 || stat == 2)) || (crit == 4 && stat > 2)) + { return i; + } } } return 0; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild.cxx index 50be88358c..9f56adf10c 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild.cxx @@ -24,6 +24,8 @@ occ::handle ShapeBuild::PlaneXOY() { static occ::handle xoy; if (xoy.IsNull()) + { xoy = new Geom_Plane(0, 0, 1, 0); + } return xoy; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_Edge.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_Edge.cxx index f8329338b7..c45bc2a0d8 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_Edge.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_Edge.cxx @@ -79,15 +79,21 @@ TopoDS_Edge ShapeBuild_Edge::CopyReplaceVertices(const TopoDS_Edge& edge, if (V.Orientation() == TopAbs_FORWARD) { if (newV1.IsNull()) + { newV1 = V; + } } else if (V.Orientation() == TopAbs_REVERSED) { if (newV2.IsNull()) + { newV2 = V; + } } else if (V1.IsNull() && V2.IsNull()) + { aNMVertices.Append(V); + } } } newV1.Orientation(TopAbs_FORWARD); @@ -99,14 +105,20 @@ TopoDS_Edge ShapeBuild_Edge::CopyReplaceVertices(const TopoDS_Edge& edge, BRep_Builder B; if (!newV1.IsNull()) + { B.Add(E, newV1); + } if (!newV2.IsNull()) + { B.Add(E, newV2); + } // addition of the internal or external vertices to edge int i = 1; for (; i <= aNMVertices.Length(); i++) + { B.Add(E, TopoDS::Vertex(aNMVertices.Value(i))); + } // S4054, rln 17.11.98 annie_surf.igs entity D77, 3D and pcurve have different // ranges, after B.Range all the ranges become as 3D @@ -139,9 +151,13 @@ static double AdjustByPeriod(const double Val, const double ToVal, const double double D = std::abs(diff); double P = std::abs(Period); if (D <= 0.5 * P) + { return 0.; + } if (P < 1e-100) + { return diff; + } return (diff > 0 ? -P : P) * (int)(D / P + 0.5); } @@ -155,9 +171,13 @@ static bool IsPeriodic(const occ::handle& theCurve) || (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)))) { if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } if (aTmpCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } } return aTmpCurve->IsPeriodic(); } @@ -172,9 +192,13 @@ bool IsPeriodic(const occ::handle& theCurve) || (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))) { if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } if (aTmpCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { aTmpCurve = occ::down_cast(aTmpCurve)->BasisCurve(); + } } return aTmpCurve->IsPeriodic(); } @@ -204,21 +228,28 @@ void ShapeBuild_Edge::CopyRanges(const TopoDS_Edge& toedge, { occ::handle fromGC = occ::down_cast(fromitcr.Value()); if (fromGC.IsNull()) + { continue; + } bool isC3d = fromGC->IsCurve3D(); if (isC3d) { if (fromGC->Curve3D().IsNull()) + { continue; + } } else { if (fromGC->PCurve().IsNull()) + { continue; + } } // clang-format off - if ( ! isC3d && ! fromGC->IsCurveOnSurface()) continue; // only 3d curves and pcurves are treated + if ( ! isC3d && ! fromGC->IsCurveOnSurface()) { continue; // only 3d curves and pcurves are treated +} // clang-format on occ::handle surface; @@ -238,14 +269,20 @@ void ShapeBuild_Edge::CopyRanges(const TopoDS_Edge& toedge, { toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull()) + { continue; + } if (isC3d) { if (!toGC->IsCurve3D()) + { continue; + } } else if (!toGC->IsCurveOnSurface() || surface != toGC->Surface() || L != toGC->Location()) + { continue; + } double first = fromGC->First(); double last = fromGC->Last(); double len = last - first; @@ -310,7 +347,9 @@ void ShapeBuild_Edge::SetRange3d(const TopoDS_Edge& edge, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurve3D()) + { continue; + } GC->SetRange(first, last); break; } @@ -329,7 +368,9 @@ void ShapeBuild_Edge::CopyPCurves(const TopoDS_Edge& toedge, const TopoDS_Edge& { occ::handle fromGC = occ::down_cast(fromitcr.Value()); if (fromGC.IsNull()) + { continue; + } if (fromGC->IsCurveOnSurface()) { occ::handle surface = fromGC->Surface(); @@ -345,7 +386,9 @@ void ShapeBuild_Edge::CopyPCurves(const TopoDS_Edge& toedge, const TopoDS_Edge& toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull() || !toGC->IsCurveOnSurface() || surface != toGC->Surface() || L != toGC->Location()) + { continue; + } found = true; break; } @@ -376,7 +419,9 @@ TopoDS_Edge ShapeBuild_Edge::Copy(const TopoDS_Edge& edge, const bool sharepcurv TopoDS_Vertex dummy1, dummy2; TopoDS_Edge newedge = CopyReplaceVertices(edge, dummy1, dummy2); if (!sharepcurves) + { CopyPCurves(newedge, edge); + } return newedge; } @@ -388,9 +433,13 @@ void ShapeBuild_Edge::RemovePCurve(const TopoDS_Edge& edge, const TopoDS_Face& f occ::handle c2dNull; //: S4136 double tol = BRep_Tool::Tolerance ( edge ); if (BRep_Tool::IsClosed(edge, face)) + { B.UpdateEdge(edge, c2dNull, c2dNull, face, 0.); //: S4136: tol + } else + { B.UpdateEdge(edge, c2dNull, face, 0.); //: S4136: tol + } } //================================================================================================= @@ -411,9 +460,13 @@ void ShapeBuild_Edge::RemovePCurve(const TopoDS_Edge& edge, occ::handle c2dNull; //: S4136 double tol = BRep_Tool::Tolerance ( edge ); if (BRep_Tool::IsClosed(edge, surf, loc)) + { B.UpdateEdge(edge, c2dNull, c2dNull, surf, loc, 0.); //: S4136: tol + } else + { B.UpdateEdge(edge, c2dNull, surf, loc, 0.); //: S4136: tol + } } //================================================================================================= @@ -438,9 +491,13 @@ void ShapeBuild_Edge::ReplacePCurve(const TopoDS_Edge& edge, else { // seam if (edge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(edge, pcurve, c2d, face, 0); + } else + { B.UpdateEdge(edge, c2d, pcurve, face, 0); + } } B.Range(edge, face, f, l); } @@ -463,7 +520,9 @@ static int CountPCurves(const TopoDS_Edge& edge, const TopoDS_Face& face) { occ::handle GC = occ::down_cast(itcr.Value()); if (!GC.IsNull() && GC->IsCurveOnSurface(S, l)) + { return (GC->IsCurveOnClosedSurface() ? 2 : 1); + } } return 0; } @@ -479,9 +538,13 @@ bool ShapeBuild_Edge::ReassignPCurve(const TopoDS_Edge& edge, occ::handle pc; pc = BRep_Tool::CurveOnSurface(edge, old, f, l); if (pc.IsNull()) + { return false; + } else if (npcurves == 0) + { npcurves = 1; // gka + } BRep_Builder B; @@ -496,12 +559,16 @@ bool ShapeBuild_Edge::ReassignPCurve(const TopoDS_Edge& edge, B.Range(edge, old, f, l); } else + { RemovePCurve(edge, old); + } // if edge does not have yet pcurves on sub, just add; else add as first int npcs = CountPCurves(edge, sub); if (npcs < 1) + { B.UpdateEdge(edge, pc, sub, 0.); + } else { // smh#8 Porting AIX @@ -509,11 +576,14 @@ bool ShapeBuild_Edge::ReassignPCurve(const TopoDS_Edge& edge, TopoDS_Edge erev = TopoDS::Edge(tmpshape); double cf, cl; occ::handle pcs = BRep_Tool::CurveOnSurface(erev, sub, cf, cl); - if (edge.Orientation() - == TopAbs_REVERSED) // because B.UpdateEdge does not check edge orientation + if (edge.Orientation() == TopAbs_REVERSED) + { // because B.UpdateEdge does not check edge orientation B.UpdateEdge(edge, pcs, pc, sub, 0.); + } else + { B.UpdateEdge(edge, pc, pcs, sub, 0.); + } } B.Range(edge, sub, f, l); @@ -537,7 +607,9 @@ occ::handle ShapeBuild_Edge::TransformPCurve(const occ::handleTransformedParameter(aLast, trans); } if (uFact == 1.) + { return result; + } if (result->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { @@ -594,9 +666,13 @@ occ::handle ShapeBuild_Edge::TransformPCurve(const occ::handleFirstParameter(); aLast = aBSpline2d->LastParameter(); } @@ -605,7 +681,9 @@ occ::handle ShapeBuild_Edge::TransformPCurve(const occ::handle(result); + } // transform the Poles of the BSplineCurve int nbPol = aBSpline2d->NbPoles(); @@ -656,7 +734,9 @@ bool ShapeBuild_Edge::BuildCurve3d(const TopoDS_Edge& edge) const double f, l; c3d = BRep_Tool::Curve(edge, f, l); if (c3d.IsNull()) + { return false; + } // 15.11.2002 PTV OCC966 if (!IsPeriodic(c3d)) { @@ -732,7 +812,6 @@ void ShapeBuild_Edge::MakeEdge(TopoDS_Edge& edge, B.UpdateVertex(V2, P2.Transformed(L.Transformation()), 0.); } edge = E; - return; } //================================================================================================= @@ -799,5 +878,4 @@ void ShapeBuild_Edge::MakeEdge(TopoDS_Edge& edge, B.UpdateVertex(V2, P2.Transformed(L.Transformation()), 0.); } edge = E; - return; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_ReShape.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_ReShape.cxx index c37c7e481e..dc170a79ef 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_ReShape.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeBuild/ShapeBuild_ReShape.cxx @@ -40,14 +40,20 @@ TopoDS_Shape ShapeBuild_ReShape::Apply(const TopoDS_Shape& shape, const int buildmode) { if (shape.IsNull()) + { return shape; + } TopoDS_Shape newsh; if (Status(shape, newsh, false) != 0) + { return newsh; + } TopAbs_ShapeEnum st = shape.ShapeType(); if (st == until) + { return newsh; // critere d arret + } int modif = 0; if (st == TopAbs_COMPOUND || st == TopAbs_COMPSOLID) @@ -60,12 +66,18 @@ TopoDS_Shape ShapeBuild_ReShape::Apply(const TopoDS_Shape& shape, const TopoDS_Shape& sh = it.Value(); int stat = Status(sh, newsh, false); if (stat != 0) + { modif = 1; + } if (stat >= 0) + { B.Add(C, newsh); + } } if (modif == 0) + { return shape; + } return C; } @@ -94,22 +106,30 @@ TopoDS_Shape ShapeBuild_ReShape::Apply(const TopoDS_Shape& shape, nbsub++; } if (nbsub == 0) + { modif = -1; + } B.Add(C, newsh); // c est tout } else { if (modif == 0 && !sh.IsEqual(newsh)) + { modif = 1; + } B.Add(C, newsh); B.Add(S, newsh); } } if ((modif < 0 && buildmode < 2) || (modif == 0 && buildmode < 1)) + { return C; + } else + { return S; + } } if (st == TopAbs_SHELL) @@ -137,26 +157,32 @@ TopoDS_Shape ShapeBuild_ReShape::Apply(const TopoDS_Shape& shape, nbsub++; } if (nbsub == 0) + { modif = -1; + } B.Add(C, newsh); // c est tout } else { if (modif == 0 && !sh.IsEqual(newsh)) + { modif = 1; + } B.Add(C, newsh); B.Add(S, newsh); } } if ((modif < 0 && buildmode < 2) || (modif == 0 && buildmode < 1)) + { return C; + } else { S.Closed(BRep_Tool::IsClosed(S)); return S; } } - std::cout << "BRepTools_ReShape::Apply NOT YET IMPLEMENTED" << std::endl; + std::cout << "BRepTools_ReShape::Apply NOT YET IMPLEMENTED" << '\n'; return shape; } @@ -177,7 +203,9 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (theShape.IsNull()) + { return theShape; + } // Apply direct replacement TopoDS_Shape aNewShape = Value(theShape); @@ -193,7 +221,9 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& // stack, its replacement must be a compound that transitively contains it. // Return the direct replacement without descending to break the cycle. if (theInFlight.Contains(theShape.TShape())) + { return aNewShape; + } // If shape was replaced, apply modifications to the result recursively. bool aConsLoc = ModeConsiderLocation(); @@ -208,9 +238,13 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& TopAbs_ShapeEnum aST = theShape.ShapeType(); if (aST >= theUntil) + { return aNewShape; // stop criterion + } if (aST == TopAbs_VERTEX || aST == TopAbs_SHAPE) + { return theShape; + } BRep_Builder aBuilder; @@ -229,7 +263,9 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& if (aNewShape != aSh) { if (ShapeExtend::DecodeStatus(myStatus, ShapeExtend_DONE4)) + { aLocStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } aModif = true; } if (aNewShape.IsNull()) @@ -249,16 +285,24 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& { const TopoDS_Shape& aSubSh = aSubIt.Value(); if (aSubSh.ShapeType() == aSh.ShapeType()) + { aBuilder.Add(aResult, aSubSh); + } else + { aLocStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } } if (!aNbItems) + { aLocStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } } theInFlight.Remove(theShape.TShape()); if (!aModif) + { return theShape; + } // Restore range on edge broken by EmptyCopied() if (aST == TopAbs_EDGE) @@ -267,7 +311,9 @@ TopoDS_Shape ShapeBuild_ReShape::applyImpl(const TopoDS_Shape& anSBE.CopyRanges(TopoDS::Edge(aResult), TopoDS::Edge(theShape)); } else if (aST == TopAbs_WIRE || aST == TopAbs_SHELL) + { aResult.Closed(BRep_Tool::IsClosed(aResult)); + } aResult.Orientation(anOrient); myStatus = aLocStatus; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct.cxx index 3eb9a546e6..8c7db0beca 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct.cxx @@ -70,11 +70,15 @@ occ::handle ShapeConstruct::ConvertCurveToBSpline( int MaxDeg = MaxDegree; occ::handle aBSpline; if (C3D->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) + { aBSpline = occ::down_cast(C3D); + } else { if (C3D->IsKind(STANDARD_TYPE(Geom_Conic))) + { MaxDeg = std::min(MaxDeg, 6); + } // clang-format off occ::handle tcurve = new Geom_TrimmedCurve(C3D,First,Last); //protection against parabols ets @@ -84,9 +88,13 @@ occ::handle ShapeConstruct::ConvertCurveToBSpline( OCC_CATCH_SIGNALS GeomConvert_ApproxCurve approx(tcurve, Tol3d, Continuity, MaxSegments, MaxDeg); if (approx.HasResult()) + { aBSpline = approx.Curve(); + } else + { aBSpline = GeomConvert::CurveToBSplineCurve(C3D, Convert_QuasiAngular); + } } catch (Standard_Failure const& anException) { @@ -121,16 +129,22 @@ occ::handle ShapeConstruct::ConvertCurveToBSpline( // clang-format on Geom2dConvert_ApproxCurve approx(tcurve, Tol2d, Continuity, MaxSegments, MaxDegree); if (approx.HasResult()) + { aBSpline2d = approx.Curve(); + } else + { aBSpline2d = Geom2dConvert::CurveToBSplineCurve(tcurve, Convert_QuasiAngular); + } } else if (!C2D->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { aBSpline2d = Geom2dConvert::CurveToBSplineCurve(C2D, Convert_QuasiAngular); } else + { aBSpline2d = occ::down_cast(C2D); + } return aBSpline2d; } @@ -266,7 +280,9 @@ occ::handle ShapeConstruct::ConvertSurfaceToBSpline( else { if (anApprox.HasResult()) + { errSpl = anApprox.Surface(); + } #ifdef OCCT_DEBUG std::cout << "\terror = " << anApprox.MaxError() << std::endl; #endif @@ -283,7 +299,9 @@ occ::handle ShapeConstruct::ConvertSurfaceToBSpline( #endif (void)anException; if (cnt > 0) + { cnt--; + } continue; } } @@ -311,7 +329,9 @@ bool ShapeConstruct::JoinPCurves(const occ::handle(aGeomSurf)->BasisSurface(); } if (aGeomSurf->IsKind(STANDARD_TYPE(Geom_Plane))) + { return true; + } bool IsEdgeSeam = false; occ::handle aCrvRes1, aCrvRes2; @@ -323,17 +343,25 @@ bool ShapeConstruct::JoinPCurves(const occ::handleValue(i)); if (i == 1) + { IsEdgeSeam = sae.IsSeam(Edge, theFace); + } else if (IsEdgeSeam && (!sae.IsSeam(Edge, theFace))) + { break; // different cases + } else if (!IsEdgeSeam && (sae.IsSeam(Edge, theFace))) + { break; // different cases + } resOrient = TopAbs_FORWARD; occ::handle c2d, c2d2; double first, last, first2, last2; if (!sae.PCurve(Edge, theFace, c2d, first, last, false)) + { break; + } if (IsEdgeSeam) { @@ -367,7 +395,9 @@ bool ShapeConstruct::JoinPCurves(const occ::handleLastParameter(); newl += (last - first); if (fp2d > newf) + { newf = fp2d; + } if (lp2d < newl) + { newl = lp2d; + } } } if (IsEdgeSeam) + { B.UpdateEdge(theEdge, aCrvRes1, aCrvRes2, theFace, 0); + } else + { B.UpdateEdge(theEdge, aCrvRes1, theFace, 0); + } B.Range(theEdge, theFace, newf, newl); B.SameRange(theEdge, false); B.SameParameter(theEdge, false); @@ -445,10 +485,14 @@ static inline void SegmentCurve(HCurve& curve, const double first, const double || curve->LastParameter() > last + Precision::PConfusion()) { if (curve->IsPeriodic()) + { curve->Segment(first, last); + } else + { curve->Segment(std::max(curve->FirstParameter(), first), std::min(curve->LastParameter(), last)); + } } } @@ -511,7 +555,9 @@ bool ShapeConstruct::JoinCurves(const occ::handle& ac3d1, // newl = last1 + last2 - first2; if (bsplc1.IsNull() || bsplc2.IsNull()) + { return false; + } SegmentCurve(bsplc1, first1, last1); SegmentCurve(bsplc2, first2, last2); @@ -530,14 +576,18 @@ bool ShapeConstruct::JoinCurves(const occ::handle& ac3d1, bsplc1->Reverse(); } if (isRev2) + { bsplc2->Reverse(); + } gp_Pnt pmid = 0.5 * (bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ()); bsplc1->SetPole(bsplc1->NbPoles(), pmid); bsplc2->SetPole(1, pmid); GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); if (!connect3d.Add(bsplc2, Precision::Confusion(), After, false)) + { return false; + } c3dOut = connect3d.BSplineCurve(); return true; } @@ -569,7 +619,9 @@ bool ShapeConstruct::JoinCurves(const occ::handle& aC2d1, scc.ConvertToBSpline(c2d2, first2, last2, Precision::Confusion()); if (bsplc12d.IsNull() || bsplc22d.IsNull()) + { return false; + } SegmentCurve(bsplc12d, first1, last1); SegmentCurve(bsplc22d, first2, last2); @@ -590,7 +642,9 @@ bool ShapeConstruct::JoinCurves(const occ::handle& aC2d1, bsplc12d->Reverse(); } if (isRev2) + { bsplc22d->Reverse(); + } //--------------------------------------------------------- // protection against invalid topology Housing(sam1296.brep(face 707) - bugmergeedges4.brep) @@ -603,7 +657,9 @@ bool ShapeConstruct::JoinCurves(const occ::handle& aC2d1, double leng = pp1.Distance(pp2); bool isCircle = (leng < pp1.Distance(pp3) + Precision::PConfusion()); if ((pp1.Distance(bsplc22d->Pole(1)) < leng) && !isCircle) + { return false; + } } //------------------------------------------------------- gp_Pnt2d pmid1 = 0.5 * (bsplc12d->Pole(bsplc12d->NbPoles()).XY() + bsplc22d->Pole(1).XY()); @@ -623,7 +679,9 @@ bool ShapeConstruct::JoinCurves(const occ::handle& aC2d1, occ::down_cast(GeomAPI::To3d(bsplc22d, vPln)); GeomConvert_CompCurveToBSplineCurve connect2d(bspl1); if (!connect2d.Add(bspl2, Precision::PConfusion(), After, false)) + { return false; + } C2dOut = GeomAPI::To2d(connect2d.BSplineCurve(), vPln); return true; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_Curve.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_Curve.cxx index 8d63ab5c06..2a4f0e8e7e 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_Curve.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_Curve.cxx @@ -48,15 +48,21 @@ bool ShapeConstruct_Curve::AdjustCurve(const occ::handle& C3D, const bool take2) const { if (!take1 && !take2) + { return true; + } if (C3D->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { occ::handle BSPL = occ::down_cast(C3D); if (take1) + { BSPL->SetPole(1, P1); + } if (take2) + { BSPL->SetPole(BSPL->NbPoles(), P2); + } return true; } @@ -90,7 +96,9 @@ bool ShapeConstruct_Curve::AdjustCurveSegment(const occ::handle& C3D // Forcer l extremite c est bien // Propager sur le reste, c est pas mal non plus if (U1 >= U2) + { return false; + } double UU1 = std::max(U1, BSPL->FirstParameter()); double UU2 = std::min(U2, BSPL->LastParameter()); BSPL->Segment(UU1, UU2); @@ -125,15 +133,21 @@ bool ShapeConstruct_Curve::AdjustCurve2d(const occ::handle& C2D, const bool take2) const { if (!take1 && !take2) + { return true; + } if (C2D->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { occ::handle BSPL = occ::down_cast(C2D); if (take1) + { BSPL->SetPole(1, P1); + } if (take2) + { BSPL->SetPole(BSPL->NbPoles(), P2); + } return true; } @@ -202,7 +216,9 @@ occ::handle ShapeConstruct_Curve::ConvertToBSpline( segment = true; } if (!segment) + { return bspl; + } try { OCC_CATCH_SIGNALS @@ -233,7 +249,9 @@ occ::handle ShapeConstruct_Curve::ConvertToBSpline( OCC_CATCH_SIGNALS Approx_Curve3d Conv(new GeomAdaptor_Curve(newc, first, last), prec, GeomAbs_C1, 9, 1000); if (Conv.IsDone() || Conv.HasResult()) + { bspl = Conv.Curve(); + } } catch (Standard_Failure const& anException) { @@ -297,7 +315,9 @@ occ::handle ShapeConstruct_Curve::ConvertToBSpline( segment = true; } if (!segment) + { return bspl; + } try { OCC_CATCH_SIGNALS @@ -335,7 +355,9 @@ occ::handle ShapeConstruct_Curve::ConvertToBSpline( 9, 1000); if (Conv.IsDone() || Conv.HasResult()) + { bspl = Conv.Curve(); + } } catch (Standard_Failure const& anException) { diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_MakeTriangulation.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_MakeTriangulation.cxx index 6500cb91fa..0bca2cd1e9 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_MakeTriangulation.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_MakeTriangulation.cxx @@ -43,12 +43,16 @@ bool IsRightContour(const NCollection_Sequence& pts, const double prec) { int len = pts.Length(); if (len < 4) + { return true; + } NCollection_Array1 thePts(1, len); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= len; i++) + { thePts(i) = pts(i); + } gp_XYZ Norm(0, 0, 0); if (ShapeAnalysis_Curve::IsPlanar(thePts, Norm, prec)) @@ -57,7 +61,9 @@ bool IsRightContour(const NCollection_Sequence& pts, const double prec) // Make polygonal wire from points BRepBuilderAPI_MakePolygon mkPoly; for (i = 1; i <= len; i++) + { mkPoly.Add(thePts(i)); + } mkPoly.Close(); mkPoly.Build(); if (mkPoly.IsDone()) @@ -66,7 +72,9 @@ bool IsRightContour(const NCollection_Sequence& pts, const double prec) // Create mean plane gp_XYZ center(0, 0, 0); for (i = 1; i <= len; i++) + { center += thePts(i).XYZ(); + } center /= len; gp_Pnt pc(center); gp_Dir pd(Norm); @@ -92,12 +100,16 @@ gp_Vec MeanNormal(const NCollection_Array1& pts) { int len = pts.Length(); if (len < 3) + { return gp_Vec(0, 0, 0); + } int i; gp_XYZ theCenter(0, 0, 0); for (i = 1; i <= len; i++) + { theCenter += pts(i).XYZ(); + } theCenter /= len; gp_XYZ theNorm(0, 0, 0); @@ -121,7 +133,9 @@ ShapeConstruct_MakeTriangulation::ShapeConstruct_MakeTriangulation( // Make polygonal wire from points BRepBuilderAPI_MakePolygon mkPoly; for (int i = pnts.Lower(); i <= pnts.Upper(); i++) + { mkPoly.Add(pnts(i)); + } mkPoly.Close(); mkPoly.Build(); if (mkPoly.IsDone()) @@ -149,7 +163,9 @@ void ShapeConstruct_MakeTriangulation::Build(const Message_ProgressRange& /*theR { // Triangulate polygonal wire if (!myWire.IsNull()) + { Triangulate(myWire); + } } } @@ -168,11 +184,15 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) occ::handle> theEdges = new NCollection_HSequence; for (TopoDS_Iterator ite(wire); ite.More(); ite.Next()) + { theEdges->Append(ite.Value()); + } int NbEdges = theEdges->Length(); if (NbEdges < 4) + { AddFacet(wire); + } else { @@ -180,14 +200,18 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) ShapeAnalysis_Edge sae; occ::handle> theAPnt = new NCollection_HArray1(1, NbEdges); for (int i = 1; i <= NbEdges; i++) + { theAPnt->SetValue(i, BRep_Tool::Pnt(sae.FirstVertex(TopoDS::Edge(theEdges->Value(i))))); + } TopoDS_Wire theNewWire; // Check planarity on array of points gp_XYZ Norm(0, 0, 0); if (ShapeAnalysis_Curve::IsPlanar(theAPnt->Array1(), Norm, myPrecision)) + { AddFacet(wire); + } else { @@ -206,11 +230,15 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) int llimit = llimits(seqFlag); int rlimit = rlimits(seqFlag); if (rlimit <= llimit) + { rlimit += NbEdges; + } // Check stop condition if ((rlimit - llimit) > (NbEdges - 2)) + { break; + } NCollection_Sequence theSPnt; @@ -233,17 +261,25 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) } int cid = cindex; if (rlimit > NbEdges && cid <= llimit) + { cid += NbEdges; + } if (cid > llimit && cid < rlimit) + { isGood = false; + } if (isGood) { theSPnt.Prepend(theAPnt->Value(cindex)); isGood = IsRightContour(theSPnt, myPrecision); if (isGood) + { lindex = cindex; + } else + { theSPnt.Remove(1); + } } } @@ -259,17 +295,25 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) } int cid = cindex; if (rlimit > NbEdges && cid <= llimit) + { cid += NbEdges; + } if (cid > llimit && cid < rlimit) + { isGood = false; + } if (isGood) { theSPnt.Append(theAPnt->Value(cindex)); isGood = IsRightContour(theSPnt, myPrecision); if (isGood) + { rindex = cindex; + } else + { theSPnt.Remove(theSPnt.Length()); + } } } @@ -281,7 +325,9 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) cindex = rindex; rlimits(seqFlag) = rindex; if (llimit > NbEdges) + { llimits(seqFlag) = lindex; + } // Set up sequence index seqFlag = (seqFlag == 1) ? 2 : 1; @@ -308,13 +354,19 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) theArr(j) = theAPnt->Value(lindex); lindex++; if (lindex > NbEdges) + { lindex = 1; + } } theC = theBaseNorm * MeanNormal(theArr); if (ii % 2) + { theC2 += theC; + } else + { theC1 += theC; + } } int best1 = ((theC1 > theC2) ? 0 : 2); @@ -355,25 +407,35 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) TopoDS_Edge theNEdge = TopoDS::Edge(theEdges->Value(cur_edge)); B.Add(theFacetWire, theNEdge); if (cur_edge == NbEdges) + { cur_edge = 1; + } else + { cur_edge++; + } } AddFacet(theFacetWire); if (!special) { // Add edges to the new wire if (theNewWire.IsNull()) + { B.MakeWire(theNewWire); + } cur_edge = pindex; while (cur_edge != lindex) { TopoDS_Edge theNEdge = TopoDS::Edge(theEdges->Value(cur_edge)); B.Add(theNewWire, theNEdge); if (cur_edge == NbEdges) + { cur_edge = 1; + } else + { cur_edge++; + } } B.Add(theNewWire, theLEdge); pindex = rindex; @@ -387,7 +449,9 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) // Triangulate the rest of edges if (!theNewWire.IsNull()) + { Triangulate(theNewWire); + } } } } @@ -397,16 +461,22 @@ void ShapeConstruct_MakeTriangulation::Triangulate(const TopoDS_Wire& wire) void ShapeConstruct_MakeTriangulation::AddFacet(const TopoDS_Wire& wire) { if (wire.IsNull()) + { return; + } // Fill sequence of points ShapeAnalysis_Edge sae; NCollection_Sequence pts; for (TopoDS_Iterator ite(wire); ite.More(); ite.Next()) + { pts.Append(BRep_Tool::Pnt(sae.FirstVertex(TopoDS::Edge(ite.Value())))); + } int i, nbp = pts.Length(); if (nbp < 3) + { return; + } // Create mean plane double cMod, maxMod = 0.0; @@ -417,7 +487,9 @@ void ShapeConstruct_MakeTriangulation::AddFacet(const TopoDS_Wire& wire) gp_XYZ v1(pts(i == nbp ? 1 : i + 1).XYZ() - vb); cMod = v1.SquareModulus(); if (cMod == 0.0) + { continue; + } else if (cMod > maxMod) { maxMod = cMod; @@ -426,7 +498,9 @@ void ShapeConstruct_MakeTriangulation::AddFacet(const TopoDS_Wire& wire) gp_XYZ v2(pts(i == 1 ? nbp : i - 1).XYZ() - vb); cMod = v2.SquareModulus(); if (cMod == 0.0) + { continue; + } else if (cMod > maxMod) { maxMod = cMod; @@ -437,13 +511,21 @@ void ShapeConstruct_MakeTriangulation::AddFacet(const TopoDS_Wire& wire) if (Normal.SquareModulus() == 0.0) { if (maxMod == 0.0) + { Normal = gp_XYZ(0, 0, 1); + } else if (maxVec.X() != 0.0) + { Normal = gp_XYZ(-maxVec.Y() / maxVec.X(), 1, 0); + } else if (maxVec.Y() != 0.0) + { Normal = gp_XYZ(0, -maxVec.Z() / maxVec.Y(), 1); + } else + { Normal = gp_XYZ(1, 0, 0); + } } gp_Pln Pln(pts(1), gp_Dir(Normal)); @@ -457,7 +539,9 @@ void ShapeConstruct_MakeTriangulation::AddFacet(const TopoDS_Wire& wire) // Add new face to the shell if (myShape.IsNull()) + { myShape = theFace; + } else { if (myShape.ShapeType() == TopAbs_FACE) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx index be1b510d99..55441ff25e 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx @@ -85,7 +85,9 @@ public: : mySurf(theSurf) { if (theSurf.IsNull()) + { return; + } occ::handle aBSplineSurf = occ::down_cast(theSurf->Surface()); @@ -332,14 +334,20 @@ bool fixPeriodicityTroubles(gp_Pnt2d* thePnt, { if (aMaxParam - aParam < Precision::PConfusion() || aParam - aMinParam < Precision::PConfusion()) + { aParam = aFixIsoParam; + } } else { if (aMaxParam - aParam < Precision::PConfusion()) + { aParam = aMaxParam; + } if (aParam - aMinParam < Precision::PConfusion()) + { aParam = aMinParam; + } } thePnt[i].SetCoord(theIdx, aParam); @@ -364,33 +372,43 @@ bool fixPeriodicityTroubles(gp_Pnt2d* thePnt, } if (!isJump) + { return false; + } if (aSumDiff > 0) { for (int i = aSavedPoint; i > 0; i--) + { if (thePnt[i].Coord(theIdx) > thePnt[i - 1].Coord(theIdx)) { thePnt[i - 1].SetCoord(theIdx, thePnt[i - 1].Coord(theIdx) + thePeriod); } + } for (int i = aSavedPoint; i < 3; i++) + { if (thePnt[i].Coord(theIdx) < thePnt[i + 1].Coord(theIdx)) { thePnt[i + 1].SetCoord(theIdx, thePnt[i + 1].Coord(theIdx) - thePeriod); } + } } else { for (int i = aSavedPoint; i > 0; i--) + { if (thePnt[i].Coord(theIdx) < thePnt[i - 1].Coord(theIdx)) { thePnt[i - 1].SetCoord(theIdx, thePnt[i - 1].Coord(theIdx) - thePeriod); } + } for (int i = aSavedPoint; i < 3; i++) + { if (thePnt[i].Coord(theIdx) > thePnt[i + 1].Coord(theIdx)) { thePnt[i + 1].SetCoord(theIdx, thePnt[i + 1].Coord(theIdx) + thePeriod); } + } } return true; @@ -414,7 +432,9 @@ bool isBSplineCurveInvalid(const occ::handle& theCurve, { theBSpline = extractBSplineCurve(theCurve); if (theBSpline.IsNull()) + { return false; + } // Compute parametrization speed on each knot interval inside [theFirst, theLast]. // If quotient = (MaxSpeed / MinSpeed) >= aMaxQuotientCoeff then use PerformByProjLib. @@ -452,7 +472,9 @@ bool isBSplineCurveInvalid(const occ::handle& theCurve, { aNbIntPnts = int(aLenRatio / aLenThres * aNbIntPnts); if (aNbIntPnts < 2) + { aNbIntPnts = 2; + } } } @@ -477,7 +499,9 @@ bool isBSplineCurveInvalid(const occ::handle& theCurve, const double aCoeff = aLength3d / (aLastParam - aFirstParam); if (std::abs(aCoeff) > gp::Resolution()) + { aKnotCoeffs.Append(aCoeff); + } aFirstParam = aLastParam; } @@ -540,11 +564,17 @@ int generateCurvePoints(const occ::handle& theCu { double aParam; if (i == 1) + { aParam = theFirst; + } else if (i == aNbPini) + { aParam = theLast; + } else + { aParam = theFirst + (i - 1) * aDeltaParam; + } gp_Pnt aPoint; theCurve->D0(aParam, aPoint); @@ -645,7 +675,9 @@ void ShapeConstruct_ProjectCurveOnSurface::SetSurface( const occ::handle& theSurf) { if (mySurf == theSurf) + { return; + } mySurf = theSurf; myCache = CacheArray(); } @@ -827,12 +859,16 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::projectAnalytic( occ::handle aRTS = occ::down_cast(aSurf); if (!aRTS.IsNull()) + { aPlane = occ::down_cast(aRTS->BasisSurface()); + } else { occ::handle anOS = occ::down_cast(aSurf); if (!anOS.IsNull()) + { aPlane = occ::down_cast(anOS->BasisSurface()); + } } } @@ -845,7 +881,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::projectAnalytic( aResult = Geom2dAdaptor::MakeCurve(aProj); if (aResult.IsNull()) + { return aResult; + } if (aResult->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { @@ -891,7 +929,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( aTol2 = aTolWorking * aTolWorking; } if (aTol2 < Precision::SquareConfusion()) + { aTol2 = Precision::SquareConfusion(); + } const double anOldTol2 = aTol2; int aSavedPointNum = -1; @@ -914,7 +954,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( aSavedPointNum = theIndex; aSavedPoint = aCachePnt.second; if (theIndex == 0) + { theIsFromCache = true; + } return; } } @@ -931,7 +973,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( const double aDist = aProjector.Gap(); const double aCurDist = aDist * aDist; if (aTol2 < aCurDist) + { aTol2 = aCurDist; + } } if (isPeriodicU || isPeriodicV) @@ -944,7 +988,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( const double aDist = aProjector.Gap(); const double aCurDist = aDist * aDist; if (aTol2 < aCurDist) + { aTol2 = aCurDist; + } } if (isPeriodicU) @@ -979,7 +1025,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( const double dPar = theParams(aNb) - theParams(1); if (std::abs(dPar) < Precision::PConfusion()) + { return nullptr; + } const gp_Vec2d aVec0(aP2d[0], aP2d[3]); const gp_Vec2d aVec = aVec0 / dPar; @@ -1003,7 +1051,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( const gp_Lin aNormalLine(aCurP, gp_Dir(aNormalVec)); const double aDist = aNormalLine.Distance(thePoints(i)); if (aDist > aTolWorking) + { return nullptr; + } } } @@ -1020,7 +1070,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::getLine( const double aDist1 = aCurP.SquareDistance(thePoints(i)); if (std::abs(aFirstPointDist - aDist1) > aTol2) + { return nullptr; + } } } @@ -1101,7 +1153,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int occ::handle sType = mySurf->Surface()->DynamicType(); bool isAnalytic = true; if (sType == STANDARD_TYPE(Geom_BezierSurface) || sType == STANDARD_TYPE(Geom_BSplineSurface)) + { isAnalytic = false; + } double uf, ul, vf, vl; mySurf->Surface()->Bounds(uf, ul, vf, vl); @@ -1109,7 +1163,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int ArrayOfReal pout(1, theNbPnt); for (int i = 1; i <= theNbPnt; i++) + { pout.SetValue(i, 0.0); + } isoParam = isAnIsoparametric(theNbPnt, thePoints, @@ -1156,34 +1212,54 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int Cf = cIso->FirstParameter(); Cl = cIso->LastParameter(); if (Precision::IsInfinite(Cf)) + { Cf = -1000; + } if (Precision::IsInfinite(Cl)) + { Cl = +1000; + } tdeb = pout(2); if (isoClosed && (isoPar1 == parf || isoPar1 == parl)) { if (std::abs(tdeb - parf) < std::abs(tdeb - parl)) + { isoPar1 = parf; + } else + { isoPar1 = parl; + } if (isoTypeU) + { valueP1.SetY(isoPar1); + } else + { valueP1.SetX(isoPar1); + } } if (isoClosed && (isoPar2 == parf || isoPar2 == parl)) { tfin = pout(theNbPnt - 1); if (std::abs(tfin - parf) < std::abs(tfin - parl)) + { isoPar2 = parf; + } else + { isoPar2 = parl; + } if (isoTypeU) + { valueP2.SetY(isoPar2); + } else + { valueP2.SetX(isoPar2); + } } if (!isoClosed) @@ -1223,7 +1299,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int && myCache(0).first.Distance(thePoints(1)) > myCache(0).first.Distance(thePoints(theNbPnt))) { if (myCache(0).first.Distance(thePoints(theNbPnt)) < Precision::Confusion()) + { aChangeCycle = true; + } } bool needResolveUJump = false; @@ -1241,16 +1319,24 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int if (isoPar2d3d) { if (isoPar2 > isoPar1) + { tPar = theParams(aPntIndex); + } else + { tPar = t1 + t2 - theParams(aPntIndex); + } } else if (!isAnalytic) { if (aPntIndex == 1) + { tPar = isoPar1; + } else if (aPntIndex == theNbPnt) + { tPar = isoPar2; + } else { tPar = pout(aPntIndex); @@ -1260,9 +1346,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int if (!isoPar2d3d && isAnalytic) { if (aPntIndex == 1) + { p2d = valueP1; + } else if (aPntIndex == theNbPnt) + { p2d = valueP2; + } else { p2d = mySurf->NextValueOfUV(p2d, p3d, myPreci, Precision::Confusion() + 1000 * gap); @@ -1286,9 +1376,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int else { if ((aPntIndex == 1) && p1OnIso) + { p2d = valueP1; + } else if ((aPntIndex == theNbPnt) && p2OnIso) + { p2d = valueP2; + } else { if (aPntIndex == 1 || aPntIndex == theNbPnt) @@ -1360,9 +1454,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int if (ii > 1) { if (aChangeCycle) + { p2d.SetXY(2. * p2d.XY() - thePoints2d(aPntIndex + 1).XY()); + } else + { p2d.SetXY(2. * p2d.XY() - thePoints2d(aPntIndex - 1).XY()); + } } } @@ -1385,7 +1483,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int gp_Pnt2d aFirstP2d, aLastP2d; bool IsUiso; if (!mySurf->Singularity(i, aPreci, aP3d, aFirstP2d, aLastP2d, aFirstPar, aLastPar, IsUiso)) + { break; + } if (aPreci <= Precision::Confusion() && aPointFirst.Distance(aP3d) <= aTolFirst) { correctExtremity(theC3D, theParams, thePoints2d, true, aFirstP2d, IsUiso); @@ -1460,9 +1560,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int } prevX = CurX; if (minX > CurX) + { minX = CurX; + } else if (maxX < CurX) + { maxX = CurX; + } } if (!isFromCache) @@ -1470,12 +1574,20 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int double midX = 0.5 * (minX + maxX); double shiftX = 0.; if (midX > ul) + { shiftX = -Up; + } else if (midX < uf) + { shiftX = Up; + } if (shiftX != 0.) + { for (int aPntIter = 1; aPntIter <= thePoints2d.Length(); ++aPntIter) + { thePoints2d.ChangeValue(aPntIter).SetX(thePoints2d(aPntIter).X() + shiftX); + } + } } } @@ -1540,9 +1652,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int } prevY = CurY; if (minY > CurY) + { minY = CurY; + } else if (maxY < CurY) + { maxY = CurY; + } } if (!isFromCache) @@ -1550,12 +1666,20 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int double midY = 0.5 * (minY + maxY); double shiftY = 0.; if (midY > vl) + { shiftY = -Vp; + } else if (midY < vf) + { shiftY = Vp; + } if (shiftY != 0.) + { for (int aPntIter = 1; aPntIter <= thePoints2d.Length(); ++aPntIter) + { thePoints2d.ChangeValue(aPntIter).SetY(thePoints2d(aPntIter).Y() + shiftY); + } + } } } @@ -1636,11 +1760,15 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int { double CurX = thePoints2d(ind).X(); if (mySurf->IsDegenerated(thePoints(ind), Precision::Confusion())) + { continue; + } OnBound = (std::abs(std::abs(CurX - 0.5 * (ul + uf)) - Up / 2) <= Precision::PConfusion()); if (!start && std::abs(std::abs(CurX - PrevX) - Up / 2) <= 0.01 * Up) + { break; + } start = false; PrevX = CurX; PrevOnBound = OnBound; @@ -1702,11 +1830,15 @@ bool ShapeConstruct_ProjectCurveOnSurface::approxPCurve(const int { double CurY = thePoints2d(ind).Y(); if (mySurf->IsDegenerated(thePoints(ind), Precision::Confusion())) + { continue; + } OnBound = (std::abs(std::abs(CurY - 0.5 * (vl + vf)) - Vp / 2) <= Precision::PConfusion()); if (!start && std::abs(std::abs(CurY - PrevY) - Vp / 2) <= 0.01 * Vp) + { break; + } start = false; PrevY = CurY; PrevOnBound = OnBound; @@ -1816,16 +1948,22 @@ void ShapeConstruct_ProjectCurveOnSurface::correctExtremity(const occ::handle FinishCoord && SecondPointOfLine.Coord(3 - IndCoord) > FinishCoord) + { return; + } if (SingularityCoord < FinishCoord && SecondPointOfLine.Coord(3 - IndCoord) < FinishCoord) + { return; + } { const double aPrevDist = std::abs(SecondPointOfLine.Coord(IndCoord) - FirstPointOfLine.Coord(IndCoord)); const double aCurDist = std::abs(EndPoint.Coord(IndCoord) - SecondPointOfLine.Coord(IndCoord)); if (aCurDist <= 2 * aPrevDist) + { return; + } } gp_Pnt2d FinishPoint = (theIsUIso) ? gp_Pnt2d(FinishCoord, SecondPointOfLine.Y()) @@ -1835,12 +1973,16 @@ void ShapeConstruct_ProjectCurveOnSurface::correctExtremity(const occ::handleD0(SecondParam, aP3d); SecondPointOfLine = mySurf->NextValueOfUV(FirstPointOfLine, aP3d, myPreci, Precision::Confusion()); if (IsPeriodic) + { adjustSecondToFirstPoint(FirstPointOfLine, SecondPointOfLine, mySurf->Surface()); + } const double aPrevDist = std::abs(FirstPointOfLine.Coord(IndCoord) - PrevPoint.Coord(IndCoord)); const double aCurDist = std::abs(SecondPointOfLine.Coord(IndCoord) - FirstPointOfLine.Coord(IndCoord)); if (aCurDist > 2 * aPrevDist) + { break; + } } if (theIsFirstPoint) + { thePoints2d.ChangeValue(1) = FinishPoint; + } else + { thePoints2d.ChangeValue(NbPnt) = FinishPoint; + } } //================================================================================================= @@ -1917,9 +2071,13 @@ void ShapeConstruct_ProjectCurveOnSurface::insertAdditionalPointOrAdjust( LastCoord = tmp; } if (LastCoord - FirstCoord <= theTolOnPeriod) + { theToAdjust = true; + } else if (FirstCoord <= MidCoord && MidCoord <= LastCoord) + { theToAdjust = true; + } else { bool Success = true; @@ -1935,9 +2093,13 @@ void ShapeConstruct_ProjectCurveOnSurface::insertAdditionalPointOrAdjust( break; } if (std::abs(MidCoord - thePrevCoord) >= thePeriod / 2 - theTolOnPeriod) + { LastT = (FirstT + LastT) / 2; + } else + { FirstT = (FirstT + LastT) / 2; + } MidPar = (FirstT + LastT) / 2; theC3D->D0(MidPar, MidP3d); MidP2d = mySurf->ValueOfUV(MidP3d, myPreci); @@ -1973,7 +2135,9 @@ void ShapeConstruct_ProjectCurveOnSurface::insertAdditionalPointOrAdjust( theIndex++; } else + { theToAdjust = true; + } } } if (theToAdjust) @@ -2015,7 +2179,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::interpolatePCurv checkPoints2d(aTmpPnts2d, aTmpParams, aPreci); if (aTmpPnts2d.Length() < 2) + { return aC2D; + } // Rebuild HArrays if points were removed if (aTmpPnts2d.Length() != theNbPnt) @@ -2032,7 +2198,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::interpolatePCurv Geom2dAPI_Interpolate myInterPol2d(aPnts2d, aParams, false, aPreci); myInterPol2d.Perform(); if (myInterPol2d.IsDone()) + { aC2D = myInterPol2d.Curve(); + } } catch (Standard_Failure const& anException) { @@ -2067,7 +2235,9 @@ occ::handle ShapeConstruct_ProjectCurveOnSurface::approximatePCurv const int numberPnt = aTmpPnts2d.Length(); if (numberPnt < 2) + { return aC2D; + } NCollection_Array1 points3d(1, numberPnt); NCollection_Array1 params(1, numberPnt); @@ -2130,7 +2300,9 @@ void ShapeConstruct_ProjectCurveOnSurface::checkPoints(ArrayOfPnt& thePoints, NCollection_Array1 tmpParam(firstElem, lastElem); for (int i = firstElem; i <= lastElem; i++) + { tmpParam.SetValue(i, 1); + } double DistMin2 = RealLast(); gp_Pnt Prev = thePoints.Value(lastValid); @@ -2143,28 +2315,40 @@ void ShapeConstruct_ProjectCurveOnSurface::checkPoints(ArrayOfPnt& thePoints, { nbPntDropped++; if (i == lastElem) + { tmpParam.SetValue(lastValid, 0); + } else + { tmpParam.SetValue(i, 0); + } } else { if (CurDist2 < DistMin2) + { DistMin2 = CurDist2; + } lastValid = i; Prev = Curr; } } if (DistMin2 < RealLast()) + { thePreci = 0.9 * std::sqrt(DistMin2); + } if (nbPntDropped == 0) + { return; + } const int newLast = lastElem - nbPntDropped; if ((newLast - firstElem + 1) < 2) + { return; + } ArrayOfPnt newPnts(firstElem, newLast); ArrayOfReal newParams(firstElem, newLast); @@ -2198,7 +2382,9 @@ void ShapeConstruct_ProjectCurveOnSurface::checkPoints2d(ArrayOfPnt2d& thePoints NCollection_Array1 tmpParam(firstElem, lastElem); for (int i = firstElem; i <= lastElem; i++) + { tmpParam.SetValue(i, 1); + } double DistMin2 = RealLast(); gp_Pnt2d Prev = thePoints2d.Value(lastValid); @@ -2211,24 +2397,34 @@ void ShapeConstruct_ProjectCurveOnSurface::checkPoints2d(ArrayOfPnt2d& thePoints { nbPntDropped++; if (i == lastElem) + { tmpParam.SetValue(lastValid, 0); + } else + { tmpParam.SetValue(i, 0); + } } else { if (CurDist2 < DistMin2) + { DistMin2 = CurDist2; + } lastValid = i; Prev = Curr; } } if (DistMin2 < RealLast()) + { thePreci = 0.9 * std::sqrt(DistMin2); + } if (nbPntDropped == 0) + { return; + } int newLast = lastElem - nbPntDropped; if ((newLast - firstElem + 1) < 2) @@ -2317,7 +2513,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int if (j == 1) { if (Precision::IsInfinite(U1)) + { continue; + } cI = mySurf->UIso(U1); isoU = true; isoVal = U1; @@ -2326,7 +2524,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int else if (j == 2) { if (Precision::IsInfinite(U2)) + { continue; + } cI = mySurf->UIso(U2); isoU = true; isoVal = U2; @@ -2335,7 +2535,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int else if (j == 3) { if (Precision::IsInfinite(V1)) + { continue; + } cI = mySurf->VIso(V1); isoU = false; isoVal = V1; @@ -2344,14 +2546,18 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int else if (j == 4) { if (Precision::IsInfinite(V2)) + { continue; + } cI = mySurf->VIso(V2); isoU = false; isoVal = V2; aBox = &mySurf->GetBoxVL(); } if (cI.IsNull()) + { continue; + } if (isoU) { @@ -2371,7 +2577,9 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int gp_Pnt extmi; cI->D0((tt1 + tt2) / 2, extmi); if (ext1.IsEqual(ext2, prec) && ext1.IsEqual(extmi, prec)) + { continue; + } bool PtEQext1 = false; bool PtEQext2 = false; @@ -2408,14 +2616,20 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int } if (aBox->IsOut(thePoints(k))) + { continue; + } double Cf = cI->FirstParameter(); double Cl = cI->LastParameter(); if (Precision::IsInfinite(Cf)) + { Cf = -1000; + } if (Precision::IsInfinite(Cl)) + { Cl = +1000; + } ShapeAnalysis_Curve sac; const double dist = sac.Project(cI, thePoints(k), prec, pt, t, Cf, Cl); @@ -2428,16 +2642,22 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int } if (mp[0] > 0 && mp[1] > 0 && std::abs(tp[0] - tp[1]) < Precision::PConfusion()) + { continue; + } if (mp[0] > 0 && (!theP1OnIso || currd2[0] < mind2[0])) { theP1OnIso = true; mind2[0] = currd2[0]; if (isoU) + { theValueP1.SetCoord(isoVal, tp[0]); + } else + { theValueP1.SetCoord(tp[0], isoVal); + } } if (mp[1] > 0 && (!theP2OnIso || currd2[1] < mind2[1])) @@ -2445,17 +2665,25 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int theP2OnIso = true; mind2[1] = currd2[1]; if (isoU) + { theValueP2.SetCoord(isoVal, tp[1]); + } else + { theValueP2.SetCoord(tp[1], isoVal); + } } if (mp[0] <= 0 || mp[1] <= 0) + { continue; + } const double md2 = currd2[0] + currd2[1]; if (mindist2 <= md2) + { continue; + } mindist2 = md2; mpt[0] = mp[0]; @@ -2489,17 +2717,25 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int for (int i = 2; i < theNbPnt && theIsoPar2d3d; i++) { if (tpar[1] > tpar[0]) + { t = theParams(i); + } else + { t = theT1 + theT2 - theParams(i); + } theCIso->D0(t, pt); if (!thePoints(i).IsEqual(pt, prec)) + { theIsoPar2d3d = false; + } } } if (theIsoPar2d3d) + { isoParam = true; + } else { double prevParam = tpar[0]; @@ -2508,9 +2744,13 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int Cf = theCIso->FirstParameter(); Cl = theCIso->LastParameter(); if (Precision::IsInfinite(Cf)) + { Cf = -1000; + } if (Precision::IsInfinite(Cl)) + { Cl = +1000; + } ShapeAnalysis_Curve sac; for (int i = 2; i < theNbPnt && isoByDistance; i++) @@ -2520,10 +2760,14 @@ bool ShapeConstruct_ProjectCurveOnSurface::isAnIsoparametric(const int prevParam = t; theParamsOut(i) = t; if ((dist > prec) || (t < Cf) || (t > Cl)) + { isoByDistance = false; + } } if (isoByDistance) + { isoParam = true; + } } } return isoParam; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom.cxx index 70beb695f2..ac95809b9c 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom.cxx @@ -178,7 +178,9 @@ TopoDS_Shape ShapeCustom::ApplyModifier( MD.Perform(M, aPS.Next()); if (!aPS.More() || !MD.IsDone()) + { return S; + } TopoDS_Shape aResult = MD.ModifiedShape(SF); aResult.Orientation(S.Orientation()); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_BSplineRestriction.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_BSplineRestriction.cxx index 591260abe7..9548bf8bbb 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_BSplineRestriction.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_BSplineRestriction.cxx @@ -127,9 +127,13 @@ static bool IsConvertCurve3d(const occ::handle& const occ::handle& aParameters) { if (aCurve.IsNull()) + { return false; + } if (aParameters->ConvertCurve3d()) + { return true; + } if (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { occ::handle tmp = occ::down_cast(aCurve); @@ -140,7 +144,9 @@ static bool IsConvertCurve3d(const occ::handle& if (aCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) { if (aParameters->ConvertOffsetCurv3d()) + { return true; + } occ::handle tmp = occ::down_cast(aCurve); occ::handle BasCurve = tmp->BasisCurve(); return IsConvertCurve3d(BasCurve, Degree, NbSeg, myRational, aParameters); @@ -149,13 +155,17 @@ static bool IsConvertCurve3d(const occ::handle& { occ::handle BsC = occ::down_cast(aCurve); if (BsC->Degree() > Degree || ((BsC->NbKnots() - 1) >= NbSeg)) + { return true; + } return myRational && BsC->IsRational(); } if (aCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve)) && (occ::down_cast(aCurve)->Degree() > Degree || (myRational && occ::down_cast(aCurve)->IsRational()))) + { return true; + } // else return false; return false; } @@ -167,19 +177,29 @@ static bool IsConvertSurface(const occ::handle& const occ::handle& aParameters) { if (aSurface.IsNull()) + { return false; + } if (aSurface->IsKind(STANDARD_TYPE(Geom_Plane))) { return aParameters->ConvertPlane(); } else if (aSurface->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) + { return aParameters->ConvertConicalSurf(); + } else if (aSurface->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) + { return aParameters->ConvertSphericalSurf(); + } else if (aSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) + { return aParameters->ConvertCylindricalSurf(); + } else if (aSurface->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) + { return aParameters->ConvertToroidalSurf(); + } // else if(aSurface->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) { // return aParameters->ConvertElementarySurf(); @@ -188,10 +208,14 @@ static bool IsConvertSurface(const occ::handle& { if (aSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) && aParameters->ConvertRevolutionSurf()) + { return true; + } if (aSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) && aParameters->ConvertExtrusionSurf()) + { return true; + } occ::handle aSurf = occ::down_cast(aSurface); occ::handle BasCurve = aSurf->BasisCurve(); return IsConvertCurve3d(BasCurve, Degree, NbSeg, myRational, aParameters); @@ -206,7 +230,9 @@ static bool IsConvertSurface(const occ::handle& if (aSurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { if (aParameters->ConvertOffsetSurf()) + { return true; + } occ::handle aSurf = occ::down_cast(aSurface); occ::handle theSurf = aSurf->BasisSurface(); return IsConvertSurface(theSurf, Degree, NbSeg, myRational, aParameters); @@ -216,23 +242,35 @@ static bool IsConvertSurface(const occ::handle& occ::handle theSurf = occ::down_cast(aSurface); if (theSurf->UDegree() > Degree || theSurf->VDegree() > Degree) + { return true; + } if ((theSurf->NbUKnots() - 1) * (theSurf->NbVKnots() - 1) > NbSeg) + { return true; + } if (myRational && (theSurf->IsURational() || theSurf->IsVRational())) + { return true; + } return false; } if (aSurface->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { if (aParameters->ConvertBezierSurf()) + { return true; + } occ::handle theSurf = occ::down_cast(aSurface); if (theSurf->UDegree() > Degree || theSurf->VDegree() > Degree) + { return true; + } if (myRational && (theSurf->IsURational() || theSurf->IsVRational())) + { return true; + } return false; } return false; @@ -245,9 +283,13 @@ static bool IsConvertCurve2d(const occ::handle& const occ::handle& aParameters) { if (aCurve.IsNull()) + { return false; + } if (aParameters->ConvertCurve2d()) + { return true; + } if (aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { occ::handle tmp = occ::down_cast(aCurve); @@ -257,7 +299,9 @@ static bool IsConvertCurve2d(const occ::handle& if (aCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) { if (aParameters->ConvertOffsetCurv2d()) + { return true; + } occ::handle tmp = occ::down_cast(aCurve); occ::handle BasCurve = tmp->BasisCurve(); return IsConvertCurve2d(BasCurve, Degree, NbSeg, myRational, aParameters); @@ -266,11 +310,15 @@ static bool IsConvertCurve2d(const occ::handle& && ((occ::down_cast(aCurve)->Degree() > Degree || ((occ::down_cast(aCurve)->NbKnots() - 1) > NbSeg)) || (myRational && occ::down_cast(aCurve)->IsRational()))) + { return true; + } if (aCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve)) && ((occ::down_cast(aCurve)->Degree() > Degree) || (myRational && occ::down_cast(aCurve)->IsRational()))) + { return true; + } // else return false; return false; } @@ -372,16 +420,22 @@ bool ShapeCustom_BSplineRestriction::NewSurface(const TopoDS_Face& F, bool& RevFace) { if (!myApproxSurfaceFlag) + { return false; + } RevWires = false; RevFace = false; myConvert = false; occ::handle aSurface = BRep_Tool::Surface(F, L); if (aSurface.IsNull()) + { return false; + } bool IsOf = true; if (myParameters->ConvertOffsetSurf()) + { IsOf = false; + } double UF, UL, VF, VL; aSurface->Bounds(UF, UL, VF, VL); double Umin, Umax, Vmin, Vmax; @@ -416,12 +470,18 @@ bool ShapeCustom_BSplineRestriction::NewSurface(const TopoDS_Face& F, occ::handle rts = occ::down_cast(aSurface); if (!rts.IsNull()) + { wasBSpline = rts->BasisSurface()->IsKind(STANDARD_TYPE(Geom_BSplineSurface)); + } if (wasBSpline) + { SendMsg(F, Message_Msg("BSplineRestriction.NewSurface.MSG1")); + } else + { SendMsg(F, Message_Msg("BSplineRestriction.NewSurface.MSG0")); + } } return IsConv; @@ -480,7 +540,9 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle aSurf = aSurface; if (aSurf->IsKind(STANDARD_TYPE(Geom_Plane)) && myParameters->ConvertPlane()) @@ -547,7 +609,9 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) @@ -591,7 +655,9 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) @@ -609,7 +675,9 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsKind(STANDARD_TYPE(Geom_OffsetSurface)) && IsOf) { @@ -624,12 +692,18 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsKind(STANDARD_TYPE(Geom_BezierSurface)) && myParameters->ConvertBezierSurf()) { @@ -650,7 +724,9 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsVRational(); bool IsR = (myRational && (URat || VRat)); if (UDeg <= myMaxDegree && VDeg <= myMaxDegree && NbSeg <= myNbMaxSeg && !IsR) + { return false; + } } if (aSurf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { @@ -685,11 +763,15 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleIsVRational(); bool IsR = (myRational && (URat || VRat)); if (UDeg <= myMaxDegree && VDeg <= myMaxDegree && NbSeg <= myNbMaxSeg && !IsR) + { return false; + } } GeomAbs_Shape Cont = myContinuity3d; if (aSurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) + { Cont = GeomAbs_C0; + } /* bool IsR = (myRational && (URat || VRat)); if( UDeg <= myMaxDegree && VDeg <= myMaxDegree && NbSeg <= myNbMaxSeg && !IsR ) { return false; @@ -745,9 +827,13 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handleContinuity())); int aCV = std::min(ContToInteger(Cont), ContToInteger(aSurf->Continuity())); if (!aCU) + { aCU = ContToInteger(Cont); + } if (!aCV) + { aCV = ContToInteger(Cont); + } for (;;) { @@ -783,9 +869,13 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle Bsc = occ::down_cast(S); if (aSurface->IsUPeriodic()) + { Bsc->SetUPeriodic(); + } if (aSurface->IsVPeriodic()) + { Bsc->SetVPeriodic(); + } // int DegU = Bsc->UDegree(); // DegU not used (skl) // int DegV = Bsc->VDegree(); // DegV not used (skl) // int nbVK = Bsc->NbVKnots(); // nbVK not used (skl) @@ -797,14 +887,18 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle uknots(Bsc->UKnots()); for (int j = 1; j <= uknots.Length(); j++) + { uknots(j) += ShiftU; + } Bsc->SetUKnots(uknots); } if (std::abs(ShiftV) > Precision::PConfusion()) { NCollection_Array1 vknots(Bsc->VKnots()); for (int j = 1; j <= vknots.Length(); j++) + { vknots(j) += ShiftV; + } Bsc->SetVKnots(vknots); } @@ -826,17 +920,27 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle 0) + { aCU--; + } if (aCV > 0) + { aCV--; + } } } if (prevTol <= newTol) + { break; + } else + { prevTol = newTol; + } } // int GMaxDegree = 15;//Geom_BSplineSurface::MaxDegree(); @@ -847,16 +951,26 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle 0) + { aCV--; + } if (aCU > 0) + { aCU--; + } } else + { MaxSeg = 2 * MaxSeg; // myGMaxSeg; + } if (MaxSeg > myParameters->GMaxSeg()) + { MaxSeg = myParameters->GMaxSeg(); + } else + { continue; + } } else { @@ -896,7 +1010,9 @@ bool ShapeCustom_BSplineRestriction::NewCurve(const TopoDS_Edge& E, double& Tol) { if (!myApproxCurve3dFlag) + { return false; + } double First, Last; occ::handle aCurve = BRep_Tool::Curve(E, L, First, Last); double TolCur = BRep_Tool::Tolerance(E); @@ -909,7 +1025,9 @@ bool ShapeCustom_BSplineRestriction::NewCurve(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle aSurface = GC->Surface(); occ::handle aCurve2d = GC->PCurve(); if ((myApproxSurfaceFlag @@ -930,11 +1048,15 @@ bool ShapeCustom_BSplineRestriction::NewCurve(const TopoDS_Edge& E, return true; } else + { return false; + } } bool IsOf = true; if (myParameters->ConvertOffsetCurv3d()) + { IsOf = false; + } bool IsConv = ConvertCurve(aCurve, C, IsConvert, First, Last, TolCur, IsOf); Tol = BRep_Tool::Tolerance(E); // TolCur; @@ -943,12 +1065,18 @@ bool ShapeCustom_BSplineRestriction::NewCurve(const TopoDS_Edge& E, bool wasBSpline = aCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)); occ::handle tc = occ::down_cast(aCurve); if (!tc.IsNull()) + { wasBSpline = tc->BasisCurve()->IsKind(STANDARD_TYPE(Geom_BSplineCurve)); + } if (wasBSpline) + { SendMsg(E, Message_Msg("BSplineRestriction.NewCurve.MSG1")); + } else + { SendMsg(E, Message_Msg("BSplineRestriction.NewCurve.MSG0")); + } } return IsConv; } @@ -1022,16 +1150,22 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve(const occ::handle& myNbMaxSeg, 6); if (approx.HasResult()) + { aBSpline = approx.Curve(); + } else + { aBSpline = GeomConvert::CurveToBSplineCurve(tcurve, Convert_QuasiAngular); + } double Shift = First - aBSpline->FirstParameter(); if (std::abs(Shift) > Precision::PConfusion()) { NCollection_Array1 newKnots(aBSpline->Knots()); for (int i = 1; i <= newKnots.Length(); i++) + { newKnots(i) += Shift; + } aBSpline->SetKnots(newKnots); } occ::handle ResCurve; @@ -1079,7 +1213,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve(const occ::handle& return true; } else if (ConvertCurve(aCurve, C, IsConvert, First, Last, TolCur, false)) + { return true; + } else { if (IsConvert) @@ -1122,7 +1258,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve(const occ::handle& return true; } else + { return false; + } } } if (aCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) @@ -1139,27 +1277,39 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve(const occ::handle& return true; } else + { return false; + } } } occ::handle aCurve1; double pf = aCurve->FirstParameter(), pl = aCurve->LastParameter(); // 15.11.2002 PTV OCC966 if (ShapeAnalysis_Curve::IsPeriodic(aCurve) && (First != Last)) + { aCurve1 = new Geom_TrimmedCurve(aCurve, First, Last); + } else if (pf < (First - Precision::PConfusion()) || pl > (Last + Precision::PConfusion())) { double F = std::max(First, pf), L = std::min(Last, pl); if (F != L) + { aCurve1 = new Geom_TrimmedCurve(aCurve, F, L); + } else + { aCurve1 = aCurve; + } } else + { aCurve1 = aCurve; + } int aC = std::min(ContToInteger(myContinuity3d), ContToInteger(aCurve->Continuity())); if (!aC) + { aC = ContToInteger(myContinuity3d); + } // aC = std::min(aC,(Deg -1)); int MaxSeg = myNbMaxSeg; int MaxDeg = myMaxDegree; @@ -1266,7 +1416,9 @@ bool ShapeCustom_BSplineRestriction::NewCurve2d(const TopoDS_Edge& E, double& Tol) { if (!myApproxCurve2dFlag && !myApproxSurfaceFlag) + { return false; + } double First, Last, F1, L1; TopLoc_Location L, Loc1; occ::handle aSurface = BRep_Tool::Surface(F, L); @@ -1275,7 +1427,9 @@ bool ShapeCustom_BSplineRestriction::NewCurve2d(const TopoDS_Edge& E, std::min(AdS.UResolution(BRep_Tool::Tolerance(E)), AdS.VResolution(BRep_Tool::Tolerance(E))); occ::handle aCurve = BRep_Tool::CurveOnSurface(E, F, First, Last); if (aCurve.IsNull()) + { return false; + } occ::handle aCur3d = BRep_Tool::Curve(E, Loc1, F1, L1); // bool IsConvert = (IsConvertSurface(aSurface,myMaxDegree,myNbMaxSeg) || // !E.IsSame(NewE)); @@ -1295,7 +1449,9 @@ bool ShapeCustom_BSplineRestriction::NewCurve2d(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle aSurf = GC->Surface(); occ::handle aCur2d = GC->PCurve(); if ((myApproxSurfaceFlag @@ -1316,17 +1472,23 @@ bool ShapeCustom_BSplineRestriction::NewCurve2d(const TopoDS_Edge& E, return true; } else + { return false; + } } bool IsOf = true; if (myParameters->ConvertOffsetCurv2d()) + { IsOf = false; + } bool IsConv = ConvertCurve2d(aCurve, C, IsConvert, First, Last, TolCur, IsOf); Tol = BRep_Tool::Tolerance(E); // TolCur; BRep_Builder B; if (!IsConv && !NewE.IsSame(E)) + { B.Range(NewE, First, Last); + } return IsConv; } @@ -1366,7 +1528,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handleFirstParameter(); if (std::abs(Shift) > Precision::PConfusion()) { NCollection_Array1 newKnots(aBSpline2d->Knots()); for (int i = 1; i <= newKnots.Length(); i++) + { newKnots(i) += Shift; + } aBSpline2d->SetKnots(newKnots); } occ::handle ResCurve; @@ -1451,7 +1621,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handleIsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) @@ -1496,7 +1672,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handleIsKind(STANDARD_TYPE(Geom2d_BezierCurve))) @@ -1513,28 +1691,40 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handle aCurve1; double pf = aCurve->FirstParameter(), pl = aCurve->LastParameter(); // 15.11.2002 PTV OCC966 if (ShapeAnalysis_Curve::IsPeriodic(aCurve) && (First != Last)) + { aCurve1 = new Geom2d_TrimmedCurve(aCurve, First, Last); + } else if (aCurve->FirstParameter() < (First - Precision::PConfusion()) || aCurve->LastParameter() > (Last + Precision::PConfusion())) { double F = std::max(First, pf), L = std::min(Last, pl); if (F != L) + { aCurve1 = new Geom2d_TrimmedCurve(aCurve, F, L); + } else + { aCurve1 = aCurve; + } } else + { aCurve1 = aCurve; + } int aC = std::min(ContToInteger(myContinuity2d), ContToInteger(aCurve->Continuity())); if (!aC) + { aC = ContToInteger(myContinuity2d); + } // aC = std::min(aC,(Deg -1)); int aC1 = aC; // GeomAbs_Shape aCont =IntegerToGeomAbsShape(aC); @@ -1629,7 +1819,9 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handle& if (SS->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { if (myOffsetMode) + { return true; + } else { occ::handle OS = occ::down_cast(SS); @@ -74,11 +76,17 @@ bool ShapeCustom_ConvertToBSpline::IsToConvert(const occ::handle& } } if (SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) + { return myExtrMode; + } if (SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) + { return myRevolMode; + } if (SS->IsKind(STANDARD_TYPE(Geom_Plane))) + { return myPlaneMode; + } return false; } @@ -109,7 +117,9 @@ bool ShapeCustom_ConvertToBSpline::NewSurface(const TopoDS_Face& F, occ::handle surf; if (!IsToConvert(S, surf)) + { return false; + } occ::handle res; if (surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface)) && !myOffsetMode) @@ -134,7 +144,9 @@ bool ShapeCustom_ConvertToBSpline::NewSurface(const TopoDS_Face& F, { GeomAbs_Shape cnt = surf->Continuity(); if (surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) + { cnt = GeomAbs_C0; // pdn 30.06.99 because of hang-up in GeomConvert_ApproxSurface + } res = ShapeConstruct::ConvertSurfaceToBSpline(surf, U1, U2, @@ -154,7 +166,9 @@ bool ShapeCustom_ConvertToBSpline::NewSurface(const TopoDS_Face& F, S = new Geom_RectangularTrimmedSurface(res, UF, UL, VF, VL); } else + { S = res; + } SendMsg(F, Message_Msg("ConvertToBSpline.NewSurface.MSG0")); @@ -180,15 +194,21 @@ bool ShapeCustom_ConvertToBSpline::NewCurve(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle S = GC->Surface(); occ::handle ES; if (!IsToConvert(S, ES)) + { continue; + } double f, l; C = BRep_Tool::Curve(E, L, f, l); if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } Tol = BRep_Tool::Tolerance(E); SendMsg(E, Message_Msg("ConvertToBSpline.NewCurve.MSG0")); return true; @@ -220,12 +240,16 @@ bool ShapeCustom_ConvertToBSpline::NewCurve2d(const TopoDS_Edge& E, // just copy pcurve if either its surface is changing or edge was copied if (!IsToConvert(S, ES) && E.IsSame(NewE)) + { return false; + } double f, l; C = BRep_Tool::CurveOnSurface(E, F, f, l); if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } Tol = BRep_Tool::Tolerance(E); return true; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx index 9351d6dc31..65ef385cd5 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx @@ -63,7 +63,9 @@ static bool IsToConvert(const occ::handle& S, occ::handle(OS->BasisSurface()); } if (ES.IsNull()) + { return false; + } } return ES->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) @@ -85,7 +87,9 @@ bool ShapeCustom_ConvertToRevolution::NewSurface(const TopoDS_Face& F, occ::handle ES; if (!IsToConvert(S, ES)) + { return false; + } // remove location if it contains inversion /* @@ -147,13 +151,17 @@ bool ShapeCustom_ConvertToRevolution::NewSurface(const TopoDS_Face& F, if ( ( neg != det ) == isdir ) Axis.Reverse(); */ if (!Ax3.Direct()) + { Axis.Reverse(); + } occ::handle Rev = new Geom_SurfaceOfRevolution(BasisCurve, Axis); // set resulting surface and restore trimming or offsetting if necessary if (ES == S) + { S = Rev; + } else { if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) @@ -170,7 +178,9 @@ bool ShapeCustom_ConvertToRevolution::NewSurface(const TopoDS_Face& F, S = new Geom_OffsetSurface(Rev, OS->Offset()); } else + { S = Rev; + } } SendMsg(F, Message_Msg("ConvertToRevolution.NewSurface.MSG0")); @@ -196,15 +206,21 @@ bool ShapeCustom_ConvertToRevolution::NewCurve(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle S = GC->Surface(); occ::handle ES; if (!IsToConvert(S, ES)) + { continue; + } double f, l; C = BRep_Tool::Curve(E, L, f, l); if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } Tol = BRep_Tool::Tolerance(E); return true; } @@ -236,7 +252,9 @@ bool ShapeCustom_ConvertToRevolution::NewCurve2d(const TopoDS_Edge& E, // just copy pcurve if either its surface is changing or edge was copied if (!IsToConvert(S, ES) && E.IsSame(NewE)) + { return false; + } double f, l; C = BRep_Tool::CurveOnSurface(E, F, f, l); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve.cxx index 8003b968ee..45a922826a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve.cxx @@ -43,13 +43,17 @@ occ::handle ShapeCustom_Curve::ConvertToPeriodic(const bool substi occ::handle newCurve; occ::handle BSpl = occ::down_cast(myCurve); if (BSpl.IsNull()) + { return newCurve; + } // PTV 13.02.02: check if curve closed with tolerance bool closed = ShapeAnalysis_Curve::IsClosed(myCurve, preci); if (!closed) + { return newCurve; + } bool converted = false; //: p6 @@ -90,7 +94,9 @@ occ::handle ShapeCustom_Curve::ConvertToPeriodic(const bool substi } else if (BSpl->Multiplicity(1) > BSpl->Degree() || BSpl->Multiplicity(BSpl->NbKnots()) > BSpl->Degree() + 1) + { set = false; + } if (set) { BSpl->SetPeriodic(); // make periodic @@ -102,9 +108,13 @@ occ::handle ShapeCustom_Curve::ConvertToPeriodic(const bool substi << std::endl; #endif if (!converted) + { return newCurve; + } newCurve = BSpl; if (substitute) + { myCurve = newCurve; + } return newCurve; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve2d.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve2d.cxx index eda8168a48..c48c94fecc 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve2d.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Curve2d.cxx @@ -53,13 +53,16 @@ bool ShapeCustom_Curve2d::IsLinear(const NCollection_Array1& thePoles, { int nbPoles = thePoles.Length(); if (nbPoles < 2) + { return false; + } double dMax = 0; int iMax1 = 0, iMax2 = 0; int i; for (i = 1; i < nbPoles; i++) + { for (int j = i + 1; j <= nbPoles; j++) { double dist = thePoles(i).SquareDistance(thePoles(j)); @@ -70,10 +73,13 @@ bool ShapeCustom_Curve2d::IsLinear(const NCollection_Array1& thePoles, iMax2 = j; } } + } constexpr double dPreci = Precision::PConfusion() * Precision::PConfusion(); if (dMax < dPreci) + { return false; + } double tol2 = tolerance * tolerance; gp_Vec2d avec(thePoles(iMax1), thePoles(iMax2)); @@ -85,9 +91,13 @@ bool ShapeCustom_Curve2d::IsLinear(const NCollection_Array1& thePoles, { double dist = alin.SquareDistance(thePoles(i)); if (dist > tol2) + { return false; + } if (dist > aMax) + { aMax = dist; + } } Deviation = sqrt(aMax); @@ -110,13 +120,17 @@ occ::handle ShapeCustom_Curve2d::ConvertToLine2d( gp_Pnt2d P2 = theCurve->Value(c2); double dPreci = theTolerance * theTolerance; if (P1.SquareDistance(P2) < dPreci) + { return aLine2d; // it is not a line + } occ::handle bsc = occ::down_cast(theCurve); if (!bsc.IsNull()) { if (!ShapeCustom_Curve2d::IsLinear(bsc->Poles(), theTolerance, theDeviation)) + { return aLine2d; // non + } gp_Lin2d alin = GetLine(P1, P2, c1, cf, cl); aLine2d = new Geom2d_Line(alin); return aLine2d; @@ -126,7 +140,9 @@ occ::handle ShapeCustom_Curve2d::ConvertToLine2d( if (!bzc.IsNull()) { if (!ShapeCustom_Curve2d::IsLinear(bzc->Poles(), theTolerance, theDeviation)) + { return aLine2d; // non + } gp_Lin2d alin = GetLine(P1, P2, c1, cf, cl); aLine2d = new Geom2d_Line(alin); return aLine2d; @@ -172,7 +188,9 @@ bool ShapeCustom_Curve2d::SimplifyBSpline2d(occ::handle& th NbK = theBSpline2d->NbKnots(); if (aKnotIndx == 1 || aKnotIndx == NbK) + { IsToRemove = false; + } } return (aInitNbK > NbK); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_DirectModification.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_DirectModification.cxx index ee60fec465..19b200f8bc 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_DirectModification.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_DirectModification.cxx @@ -53,7 +53,9 @@ static int IsIndirectSurface(occ::handle& S, TopLoc_Location& L) occ::handle TS = S; while (TS->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { TS = occ::down_cast(TS)->BasisSurface(); + } occ::handle ES = occ::down_cast(TS); if (!ES.IsNull()) @@ -64,16 +66,22 @@ static int IsIndirectSurface(occ::handle& S, TopLoc_Location& L) bool det = (t.VectorialPart().Determinant() < 0.0); bool dir = ES->Position().Direct(); if ((neg != det) == dir) + { result = 1; + } occ::handle CS = occ::down_cast(ES); if (!CS.IsNull()) { // does the cone have negative semiangle ? if (CS->SemiAngle() < 0.0) + { result += 2; + } } if (result) + { S = TS; + } } return result; @@ -141,15 +149,21 @@ bool ShapeCustom_DirectModification::NewCurve(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle S = GC->Surface(); TopLoc_Location Loc = GC->Location(); if (!IsIndirectSurface(S, Loc)) + { continue; + } double f, l; C = BRep_Tool::Curve(E, L, f, l); if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } Tol = BRep_Tool::Tolerance(E); return true; } @@ -180,7 +194,9 @@ bool ShapeCustom_DirectModification::NewCurve2d(const TopoDS_Edge& E, int result = IsIndirectSurface(S, L); if (!result && E.IsSame(NewE)) + { return false; + } double f, l; C = BRep_Tool::CurveOnSurface(E, F, f, l); @@ -235,7 +251,9 @@ bool ShapeCustom_DirectModification::NewCurve2d(const TopoDS_Edge& E, { //: p5 abv 26 Feb 99: force copying of pcurves if edge was copied if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } } return true; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Modification.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Modification.cxx index 6182aa0a2b..5e9cddf302 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Modification.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Modification.cxx @@ -41,5 +41,7 @@ void ShapeCustom_Modification::SendMsg(const TopoDS_Shape& shape, const Message_Gravity gravity) const { if (!myMsgReg.IsNull()) + { myMsgReg->Send(shape, message, gravity); + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Surface.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Surface.cxx index c84bfcebf5..fb0a027718 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Surface.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_Surface.cxx @@ -84,7 +84,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double VDeg = theBezierS->VDegree(); } else + { return newSurf; // non reconnu : terminus + } } else { // BSpline : @@ -108,14 +110,20 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double if (nUP == 2 && nVP == 2) { if (UDeg == 1 && VDeg == 1) + { aPlanar = true; + } } else if (mySurf->IsUClosed()) { // VRAI IsUClosed if (mySurf->IsVClosed()) + { aToroid = true; + } else + { aCySpCo = true; + } } else { @@ -139,7 +147,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double // ICI, on fabrique le plan, et zou if (It == 0 || myGap /*Dmax*/ > tol) + { return newSurf; // pas un plan + } // IL RESTE a verifier l orientation ... // On regarde sur chaque surface les vecteurs P(U0->U1),P(V0->V1) @@ -185,16 +195,26 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double for (i = 1; i <= 3; i++) { if (i == 1) + { V = V1; + } else if (i == 2) + { V = V2; + } else if (i == 3) + { V = 0.5 * (V1 + V2); + } if (uClosed) + { iso = mySurf->VIso(V); + } else + { iso = mySurf->UIso(V); + } iso->D0(U1, p1(i)); iso->D0(0.5 * (U1 + U2), p2(i)); @@ -232,7 +252,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double // gp_Ax3 aAx3(p3(3), aDir); occ::handle anObject = new Geom_SphericalSurface(aAx3, R(3)); if (!uClosed) + { anObject->UReverse(); + } newSurf = anObject; } } @@ -246,7 +268,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double { occ::handle anObject = new Geom_CylindricalSurface(aAx3, R(1)); if (!uClosed) + { anObject->UReverse(); + } newSurf = anObject; } else @@ -293,11 +317,17 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double for (i = 1; i <= 3; i++) { if (i == 1) + { U = U1; + } else if (i == 2) + { U = 0.5 * (U1 + U2); + } else if (i == 3) + { U = 0.25 * (U1 + U2); + } iso = mySurf->UIso(U); @@ -319,7 +349,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double aVec ^= aVec2; if (aVec.Magnitude() <= gp::Resolution()) + { aVec.SetCoord(0., 0., 1.); + } gp_Dir aDir(aVec); @@ -335,7 +367,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double } occ::handle anObject = new Geom_ToroidalSurface(aAx3, RR1, RR2); if (j == 2) + { anObject->UReverse(); + } anObject->D1(0., 0., resPnt, resD1U, resD1V); #ifdef OCCT_DEBUG if (resD1U.Dot(origD1U) < 0 && j != 2) @@ -347,7 +381,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double } } if (newSurf.IsNull()) + { return newSurf; + } //--------------------------------------------------------------------- // verification @@ -371,9 +407,13 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double V = V1 + DV * (j - 1); if (uClosed) + { iso = mySurf->VIso(V); + } else + { iso = mySurf->UIso(V); + } for (i = 1; i <= NP; i++) { @@ -410,7 +450,9 @@ occ::handle ShapeCustom_Surface::ConvertToAnalytical(const double dis = P3d.Distance(P3d2); if (dis > myGap) + { myGap = dis; + } if (dis > tol) { @@ -436,14 +478,18 @@ occ::handle ShapeCustom_Surface::ConvertToPeriodic(const bool su occ::handle newSurf; occ::handle BSpl = occ::down_cast(mySurf); if (BSpl.IsNull()) + { return newSurf; + } ShapeAnalysis_Surface sas(mySurf); bool uclosed = sas.IsUClosed(preci); bool vclosed = sas.IsVClosed(preci); if (!uclosed && !vclosed) + { return newSurf; + } bool converted = false; //: p6 @@ -490,7 +536,9 @@ occ::handle ShapeCustom_Surface::ConvertToPeriodic(const bool su } else if (BSpl->UMultiplicity(1) > BSpl->UDegree() || BSpl->UMultiplicity(BSpl->NbUKnots()) > BSpl->UDegree() + 1) + { set = false; + } if (set) { BSpl->SetUPeriodic(); // make periodic @@ -541,7 +589,9 @@ occ::handle ShapeCustom_Surface::ConvertToPeriodic(const bool su } else if (BSpl->VMultiplicity(1) > BSpl->VDegree() || BSpl->VMultiplicity(BSpl->NbVKnots()) > BSpl->VDegree() + 1) + { set = false; + } if (set) { BSpl->SetVPeriodic(); // make periodic @@ -554,9 +604,13 @@ occ::handle ShapeCustom_Surface::ConvertToPeriodic(const bool su << std::endl; #endif if (!converted) + { return newSurf; + } newSurf = BSpl; if (substitute) + { mySurf = newSurf; + } return newSurf; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_SweptToElementary.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_SweptToElementary.cxx index e2e7aecd6d..22b7c04874 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_SweptToElementary.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeCustom/ShapeCustom_SweptToElementary.cxx @@ -73,7 +73,9 @@ static bool IsToConvert(const occ::handle& S, occ::handleBasisSurface(); } if (Stmp.IsNull()) + { return false; + } if (S->IsKind(STANDARD_TYPE(Geom_SweptSurface))) { SS = occ::down_cast(Stmp); @@ -94,7 +96,9 @@ bool ShapeCustom_SweptToElementary::NewSurface(const TopoDS_Face& F, S = BRep_Tool::Surface(F, L); occ::handle SS; if (!IsToConvert(S, SS)) + { return false; + } // case SurfaceOfRevolution if (SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) @@ -189,15 +193,21 @@ bool ShapeCustom_SweptToElementary::NewCurve(const TopoDS_Edge& E, { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle S = GC->Surface(); occ::handle SS; if (!IsToConvert(S, SS)) + { continue; + } double f, l; C = BRep_Tool::Curve(E, L, f, l); if (!C.IsNull()) + { C = occ::down_cast(C->Copy()); + } Tol = BRep_Tool::Tolerance(E); return true; } @@ -229,7 +239,9 @@ bool ShapeCustom_SweptToElementary::NewCurve2d(const TopoDS_Edge& E, // just copy pcurve if either its surface is changing or edge was copied if (!IsToConvert(S, SS) && E.IsSame(NewE)) + { return false; + } double f, l; C = BRep_Tool::CurveOnSurface(E, F, f, l); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend.cxx index 3c921e95b9..dd26888209 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend.cxx @@ -28,7 +28,9 @@ void ShapeExtend::Init() { static bool init = false; if (init) + { return; + } init = true; @@ -100,6 +102,8 @@ int ShapeExtend::EncodeStatus(const ShapeExtend_Status status) bool ShapeExtend::DecodeStatus(const int flag, const ShapeExtend_Status status) { if (status == ShapeExtend_OK) + { return (flag == 0); + } return ((flag & ShapeExtend::EncodeStatus(status)) != 0); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_ComplexCurve.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_ComplexCurve.cxx index eb9e17e33d..d055f7f017 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_ComplexCurve.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_ComplexCurve.cxx @@ -36,7 +36,9 @@ ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve() void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T) { for (int i = 1; i <= NbCurves(); i++) + { Curve(i)->Transform(T); + } } //================================================================================================= @@ -92,7 +94,9 @@ gp_Vec ShapeExtend_ComplexCurve::EvalDN(const double U, const int N) const const int anInd = LocateParameter(U, UOut); gp_Vec aResult = Curve(anInd)->EvalDN(UOut, N); if (N) + { TransformDN(aResult, anInd, N); + } return aResult; } @@ -105,7 +109,9 @@ bool ShapeExtend_ComplexCurve::CheckConnectivity(const double Preci) for (int i = 1; i < NbC; i++) { if (i == 1) + { myClosed = Value(FirstParameter()).IsEqual(Value(LastParameter()), Preci); + } ok &= Curve(i) ->Value(Curve(i)->LastParameter()) .IsEqual(Curve(i + 1)->Value(Curve(i + 1)->FirstParameter()), Preci); @@ -123,5 +129,7 @@ void ShapeExtend_ComplexCurve::TransformDN(gp_Vec& V, const int ind, const int N { double fact = GetScaleFactor(ind); for (int i = 1; i <= N; i++) + { V *= fact; + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_CompositeSurface.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_CompositeSurface.cxx index 1ee9ca88b6..f2e1eb6b27 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_CompositeSurface.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_CompositeSurface.cxx @@ -57,7 +57,9 @@ bool ShapeExtend_CompositeSurface::Init( const ShapeExtend_Parametrisation param) { if (GridSurf.IsNull()) + { return false; + } myPatches = GridSurf; ComputeJointValues(param); return CheckConnectivity(Precision::Confusion()); @@ -71,7 +73,9 @@ bool ShapeExtend_CompositeSurface::Init( const NCollection_Array1& VJoints) { if (GridSurf.IsNull()) + { return false; + } myPatches = GridSurf; bool ok = true; @@ -150,7 +154,9 @@ bool ShapeExtend_CompositeSurface::SetUJointValues(const NCollection_Array1> UJointValues = new NCollection_HArray1(1, NbU + 1); @@ -158,7 +164,9 @@ bool ShapeExtend_CompositeSurface::SetUJointValues(const NCollection_Array1SetValue(i, UJoints(j)); if (i > 1 && UJoints(j) - UJoints(j - 1) < Precision::PConfusion()) + { return false; + } } myUJointValues = UJointValues; return true; @@ -170,7 +178,9 @@ bool ShapeExtend_CompositeSurface::SetVJointValues(const NCollection_Array1> VJointValues = new NCollection_HArray1(1, NbV + 1); @@ -178,7 +188,9 @@ bool ShapeExtend_CompositeSurface::SetVJointValues(const NCollection_Array1SetValue(i, VJoints(j)); if (i > 1 && VJoints(j) - VJoints(j - 1) < Precision::PConfusion()) + { return false; + } } myVJointValues = VJointValues; return true; @@ -189,7 +201,9 @@ bool ShapeExtend_CompositeSurface::SetVJointValues(const NCollection_Array1Value(1); int NbU = myUJointValues->Length(); @@ -204,7 +218,9 @@ void ShapeExtend_CompositeSurface::SetUFirstValue(const double UFirst) void ShapeExtend_CompositeSurface::SetVFirstValue(const double VFirst) { if (myVJointValues.IsNull()) + { return; + } double shift = VFirst - myVJointValues->Value(1); int NbV = myVJointValues->Length(); @@ -220,8 +236,12 @@ int ShapeExtend_CompositeSurface::LocateUParameter(const double U) const { int nbPatch = NbUPatches(); for (int i = 2; i <= nbPatch; i++) + { if (U < myUJointValues->Value(i)) + { return i - 1; + } + } return nbPatch; } @@ -231,8 +251,12 @@ int ShapeExtend_CompositeSurface::LocateVParameter(const double V) const { int nbPatch = NbVPatches(); for (int i = 2; i <= nbPatch; i++) + { if (V < myVJointValues->Value(i)) + { return i - 1; + } + } return nbPatch; } @@ -357,9 +381,13 @@ bool ShapeExtend_CompositeSurface::GlobalToLocalTransformation(const int i, uFact = scaleu / scalev; gp_Trsf2d Shift, Scale; if (shift.X() != 0. || shift.Y() != 0.) + { Shift.SetTranslation(shift); + } if (scalev != 1.) + { Scale.SetScale(gp_Pnt2d(0, 0), scalev); + } Trsf = Scale * Shift; return uFact != 1. || Trsf.Form() != gp_Identity; } @@ -373,10 +401,16 @@ bool ShapeExtend_CompositeSurface::GlobalToLocalTransformation(const int i, void ShapeExtend_CompositeSurface::Transform(const gp_Trsf& T) { if (myPatches.IsNull()) + { return; + } for (int i = 1; i <= NbUPatches(); i++) + { for (int j = 1; j <= NbVPatches(); j++) + { Patch(i, j)->Transform(T); + } + } } //================================================================================================= @@ -385,13 +419,19 @@ occ::handle ShapeExtend_CompositeSurface::Copy() const { occ::handle surf = new ShapeExtend_CompositeSurface; if (myPatches.IsNull()) + { return surf; + } occ::handle>> patches = new NCollection_HArray2>(1, NbUPatches(), 1, NbVPatches()); for (int i = 1; i <= NbUPatches(); i++) + { for (int j = 1; j <= NbVPatches(); j++) + { patches->SetValue(i, j, occ::down_cast(Patch(i, j)->Copy())); + } + } surf->Init(patches); return surf; } @@ -575,7 +615,9 @@ void ShapeExtend_CompositeSurface::ComputeJointValues(const ShapeExtend_Parametr { myPatches->Value(i, 1)->Bounds(U1, U2, V1, V2); if (i == 1) + { myUJointValues->SetValue(1, U = U1); + } U += (U2 - U1); myUJointValues->SetValue(i + 1, U); } @@ -583,7 +625,9 @@ void ShapeExtend_CompositeSurface::ComputeJointValues(const ShapeExtend_Parametr { myPatches->Value(1, i)->Bounds(U1, U2, V1, V2); if (i == 1) + { myVJointValues->SetValue(1, V = V1); + } V += (V2 - V1); myVJointValues->SetValue(i + 1, V); } @@ -598,9 +642,13 @@ void ShapeExtend_CompositeSurface::ComputeJointValues(const ShapeExtend_Parametr } int i; // svv Jan 10 2000 : porting on DEC for (i = 0; i <= NbU; i++) + { myUJointValues->SetValue(i + 1, i * stepu); + } for (i = 0; i <= NbV; i++) + { myVJointValues->SetValue(i + 1, i * stepv); + } } } @@ -652,13 +700,19 @@ bool ShapeExtend_CompositeSurface::CheckConnectivity(const double Prec) double pari = Vi1 + stepi * isample; double dist2 = sj->Value(Uj2, parj).SquareDistance(si->Value(Ui1, pari)); if (maxdist2 < dist2) + { maxdist2 = dist2; + } } } if (i == 1) + { myUClosed = (maxdist2 <= Prec * Prec); + } else if (maxdist2 > Prec * Prec) + { ok = false; + } } // check in v direction @@ -681,13 +735,19 @@ bool ShapeExtend_CompositeSurface::CheckConnectivity(const double Prec) double pari = Ui1 + stepi * isample; double dist2 = sj->Value(parj, Vj2).SquareDistance(si->Value(pari, Vi1)); if (maxdist2 < dist2) + { maxdist2 = dist2; + } } } if (i == 1) + { myVClosed = (maxdist2 <= Prec * Prec); + } else if (maxdist2 > Prec * Prec) + { ok = false; + } } #ifdef OCCT_DEBUG diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_Explorer.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_Explorer.cxx index 309b82e78f..ce7256c0c7 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_Explorer.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_Explorer.cxx @@ -37,7 +37,9 @@ TopoDS_Shape ShapeExtend_Explorer::CompoundFromSeq( B.MakeCompound(C); int i, n = seqval->Length(); for (i = 1; i <= n; i++) + { B.Add(C, seqval->Value(i)); + } return C; } @@ -51,11 +53,17 @@ static void FillList(const occ::handle>& lis { const TopoDS_Shape& sub = it.Value(); if (sub.ShapeType() != TopAbs_COMPOUND) + { list->Append(sub); + } else if (!expcomp) + { list->Append(sub); + } else + { FillList(list, sub, expcomp); + } } } @@ -65,7 +73,9 @@ occ::handle> ShapeExtend_Explorer::SeqFromCo { occ::handle> list = new NCollection_HSequence(); if (comp.IsNull()) + { return list; + } if (comp.ShapeType() != TopAbs_COMPOUND) { list->Append(comp); @@ -83,12 +93,18 @@ void ShapeExtend_Explorer::ListFromSeq( const bool clear) const { if (clear) + { lisval.Clear(); + } if (seqval.IsNull()) + { return; + } int i, nb = seqval->Length(); for (i = 1; i <= nb; i++) + { lisval.Append(seqval->Value(i)); + } } //================================================================================================= @@ -100,7 +116,9 @@ occ::handle> ShapeExtend_Explorer::SeqFromLi new NCollection_HSequence(); NCollection_List::Iterator it; for (it.Initialize(lisval); it.More(); it.Next()) + { seqval->Append(it.Value()); + } return seqval; } @@ -110,32 +128,52 @@ TopAbs_ShapeEnum ShapeExtend_Explorer::ShapeType(const TopoDS_Shape& shape, const bool compound) const { if (shape.IsNull()) + { return TopAbs_SHAPE; + } TopAbs_ShapeEnum res = shape.ShapeType(); if (!compound || res != TopAbs_COMPOUND) + { return res; + } res = TopAbs_SHAPE; for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) { const TopoDS_Shape& sh = iter.Value(); if (sh.IsNull()) + { continue; + } TopAbs_ShapeEnum typ = sh.ShapeType(); if (typ == TopAbs_COMPOUND) + { typ = ShapeType(sh, compound); + } if (res == TopAbs_SHAPE) + { res = typ; - // Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL + // Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL + } else if (res == TopAbs_EDGE && typ == TopAbs_WIRE) + { res = typ; + } else if (res == TopAbs_WIRE && typ == TopAbs_EDGE) + { continue; + } else if (res == TopAbs_FACE && typ == TopAbs_SHELL) + { res = typ; + } else if (res == TopAbs_SHELL && typ == TopAbs_FACE) + { continue; + } else if (res != typ) + { return TopAbs_COMPOUND; + } } return res; } @@ -148,7 +186,9 @@ TopoDS_Shape ShapeExtend_Explorer::SortedCompound(const TopoDS_Shape& shape, const bool compound) const { if (shape.IsNull()) + { return shape; + } TopAbs_ShapeEnum typ = shape.ShapeType(); TopoDS_Shape sh, sh0; int nb = 0; @@ -163,7 +203,9 @@ TopoDS_Shape ShapeExtend_Explorer::SortedCompound(const TopoDS_Shape& shape, { sh0 = SortedCompound(it.Value(), type, explore, compound); if (sh0.IsNull()) + { continue; + } sh = sh0; typ = sh.ShapeType(); if (typ == TopAbs_COMPOUND && !compound) @@ -182,15 +224,21 @@ TopoDS_Shape ShapeExtend_Explorer::SortedCompound(const TopoDS_Shape& shape, } } if (nb == 0) + { C.Nullify(); + } else if (nb == 1) + { return sh; + } return C; } // Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL if (typ == type) + { return shape; + } if (typ == TopAbs_EDGE && type == TopAbs_WIRE) { BRep_Builder B; @@ -226,15 +274,21 @@ TopoDS_Shape ShapeExtend_Explorer::SortedCompound(const TopoDS_Shape& shape, { sh0 = SortedCompound(it.Value(), type, explore, compound); if (sh0.IsNull()) + { continue; + } sh = sh0; nb++; B.Add(C, sh); } if (nb == 0) + { C.Nullify(); + } else if (nb == 1) + { return sh; + } return C; } @@ -250,9 +304,13 @@ TopoDS_Shape ShapeExtend_Explorer::SortedCompound(const TopoDS_Shape& shape, BB.Add(CC, sh); } if (nb == 0) + { CC.Nullify(); + } else if (nb == 1) + { return sh; + } return CC; } @@ -270,30 +328,50 @@ void ShapeExtend_Explorer::DispatchList( occ::handle>& compounds) const { if (list.IsNull()) + { return; + } if (vertices.IsNull()) + { vertices = new NCollection_HSequence(); + } if (edges.IsNull()) + { edges = new NCollection_HSequence(); + } if (wires.IsNull()) + { wires = new NCollection_HSequence(); + } if (faces.IsNull()) + { faces = new NCollection_HSequence(); + } if (shells.IsNull()) + { shells = new NCollection_HSequence(); + } if (solids.IsNull()) + { solids = new NCollection_HSequence(); + } if (compsols.IsNull()) + { compsols = new NCollection_HSequence(); + } if (compounds.IsNull()) + { compounds = new NCollection_HSequence(); + } int i, nb = list->Length(); for (i = 1; i <= nb; i++) { TopoDS_Shape sh = list->Value(i); if (sh.IsNull()) + { continue; + } switch (sh.ShapeType()) { case TopAbs_VERTEX: diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_WireData.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_WireData.cxx index 3aed7999ac..34cb2e00ae 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_WireData.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeExtend/ShapeExtend_WireData.cxx @@ -58,10 +58,14 @@ void ShapeExtend_WireData::Init(const occ::handle& other) Clear(); int i, nb = other->NbEdges(); for (i = 1; i <= nb; i++) + { Add(other->Edge(i)); + } nb = other->NbNonManifoldEdges(); for (i = 1; i <= nb; i++) + { Add(other->NonmanifoldEdge(i)); + } myManifoldMode = other->ManifoldMode(); } @@ -89,9 +93,13 @@ bool ShapeExtend_WireData::Init(const TopoDS_Wire& wire, const bool chained, con { TopoDS_Vertex V = TopoDS::Vertex(itv.Value()); if (V.Orientation() == TopAbs_FORWARD) + { V1 = V; + } else if (V.Orientation() == TopAbs_REVERSED) + { V2 = V; + } } // chainage? Si pas bon et chained False on repart sur WireExplorer @@ -99,13 +107,19 @@ bool ShapeExtend_WireData::Init(const TopoDS_Wire& wire, const bool chained, con { OK = false; if (!chained) + { break; + } } Vlast = V2; if (wire.Orientation() == TopAbs_REVERSED) + { myEdges->Prepend(E); + } else + { myEdges->Append(E); + } } if (!myManifoldMode) @@ -113,16 +127,22 @@ bool ShapeExtend_WireData::Init(const TopoDS_Wire& wire, const bool chained, con int nb = myNonmanifoldEdges->Length(); int i = 1; for (; i <= nb; i++) + { myEdges->Append(myNonmanifoldEdges->Value(i)); + } myNonmanifoldEdges->Clear(); } // refaire chainage ? Par WireExplorer if (OK || chained) + { return OK; + } Clear(); for (BRepTools_WireExplorer we(wire); we.More(); we.Next()) + { myEdges->Append(TopoDS::Edge(we.Current())); + } return OK; } @@ -143,7 +163,9 @@ void ShapeExtend_WireData::Clear() void ShapeExtend_WireData::ComputeSeams(const bool enforce) { if (mySeamF >= 0 && !enforce) + { return; + } mySeams = new NCollection_HSequence(); mySeamF = mySeamR = 0; @@ -170,10 +192,14 @@ void ShapeExtend_WireData::ComputeSeams(const bool enforce) { S = Edge(i); if (S.Orientation() == TopAbs_REVERSED) + { continue; + } int num = ME.FindIndex(S); if (num <= 0) + { continue; + } if (mySeamF == 0) { mySeamF = i; @@ -200,7 +226,9 @@ void ShapeExtend_WireData::ComputeSeams(const bool enforce) void ShapeExtend_WireData::SetLast(const int num) { if (num == 0) + { return; + } int i, nb = NbEdges(); for (i = nb; i > num; i--) { @@ -238,7 +266,9 @@ void ShapeExtend_WireData::Add(const TopoDS_Edge& edge, const int atnum) } if (edge.IsNull()) + { return; + } if (atnum == 0) { myEdges->Append(edge); @@ -255,7 +285,9 @@ void ShapeExtend_WireData::Add(const TopoDS_Edge& edge, const int atnum) void ShapeExtend_WireData::Add(const TopoDS_Wire& wire, const int atnum) { if (wire.IsNull()) + { return; + } int n = atnum; NCollection_Sequence aNMEdges; for (TopoDS_Iterator it(wire); it.More(); it.Next()) @@ -264,9 +296,13 @@ void ShapeExtend_WireData::Add(const TopoDS_Wire& wire, const int atnum) if (edge.Orientation() != TopAbs_REVERSED && edge.Orientation() != TopAbs_FORWARD) { if (myManifoldMode) + { myNonmanifoldEdges->Append(edge); + } else + { aNMEdges.Append(edge); + } continue; } if (n == 0) @@ -281,7 +317,9 @@ void ShapeExtend_WireData::Add(const TopoDS_Wire& wire, const int atnum) } int i = 1, nb = aNMEdges.Length(); for (; i <= nb; i++) + { myEdges->Append(aNMEdges.Value(i)); + } mySeamF = -1; } @@ -290,7 +328,9 @@ void ShapeExtend_WireData::Add(const TopoDS_Wire& wire, const int atnum) void ShapeExtend_WireData::Add(const occ::handle& wire, const int atnum) { if (wire.IsNull()) + { return; + } NCollection_Sequence aNMEdges; int n = atnum; int i = 1; @@ -316,17 +356,22 @@ void ShapeExtend_WireData::Add(const occ::handle& wire, co // non-manifold edges for non-manifold wire should be added at end for (i = 1; i <= aNMEdges.Length(); i++) + { myEdges->Append(aNMEdges.Value(i)); + } for (i = 1; i <= wire->NbNonManifoldEdges(); i++) { if (myManifoldMode) + { myNonmanifoldEdges->Append(wire->NonmanifoldEdge(i)); + } else { if (n == 0) + { myEdges->Append(wire->Edge(i)); - + } else { myEdges->InsertBefore(n, wire->Edge(i)); @@ -343,9 +388,13 @@ void ShapeExtend_WireData::Add(const occ::handle& wire, co void ShapeExtend_WireData::Add(const TopoDS_Shape& shape, const int atnum) { if (shape.ShapeType() == TopAbs_EDGE) + { Add(TopoDS::Edge(shape), atnum); + } else if (shape.ShapeType() == TopAbs_WIRE) + { Add(TopoDS::Wire(shape), atnum); + } } //================================================================================================= @@ -353,10 +402,14 @@ void ShapeExtend_WireData::Add(const TopoDS_Shape& shape, const int atnum) void ShapeExtend_WireData::AddOriented(const TopoDS_Edge& edge, const int mode) { if (edge.IsNull() || mode < 0) + { return; + } TopoDS_Edge E = edge; if (mode == 1 || mode == 3) + { E.Reverse(); + } Add(E, mode / 2); // mode = 0,1 -> 0 mode = 2,3 -> 1 } @@ -365,19 +418,27 @@ void ShapeExtend_WireData::AddOriented(const TopoDS_Edge& edge, const int mode) void ShapeExtend_WireData::AddOriented(const TopoDS_Wire& wire, const int mode) { if (wire.IsNull() || mode < 0) + { return; + } TopoDS_Wire W = wire; if (mode == 1 || mode == 3) + { W.Reverse(); + } Add(W, mode / 2); // mode = 0,1 -> 0 mode = 2,3 -> 1 } void ShapeExtend_WireData::AddOriented(const TopoDS_Shape& shape, const int mode) { if (shape.ShapeType() == TopAbs_EDGE) + { AddOriented(TopoDS::Edge(shape), mode); + } else if (shape.ShapeType() == TopAbs_WIRE) + { AddOriented(TopoDS::Wire(shape), mode); + } } //================================================================================================= @@ -398,13 +459,19 @@ void ShapeExtend_WireData::Set(const TopoDS_Edge& edge, const int num) && myManifoldMode) { if (num <= myNonmanifoldEdges->Length()) + { myNonmanifoldEdges->SetValue(num, edge); + } else + { myNonmanifoldEdges->Append(edge); + } } else + { myEdges->SetValue((num > 0 ? num : NbEdges()), edge); + } mySeamF = -1; } @@ -445,9 +512,13 @@ static void SwapSeam(const TopoDS_Shape& S, const TopoDS_Face& F) { TopoDS_Edge E = TopoDS::Edge(S); if (E.IsNull() || F.IsNull()) + { return; + } if (E.Orientation() == TopAbs_REVERSED) + { return; // ne le faire qu une fois ! + } TopoDS_Face theface = F; theface.Orientation(TopAbs_FORWARD); @@ -461,7 +532,9 @@ static void SwapSeam(const TopoDS_Shape& S, const TopoDS_Face& F) E.Orientation(TopAbs_REVERSED); c2dr = BRep_Tool::CurveOnSurface(E, theface, ufr, ulr); if (c2df.IsNull() || c2dr.IsNull()) + { return; //: q0 + } // On permute E.Orientation(TopAbs_FORWARD); BRep_Builder B; @@ -473,7 +546,9 @@ void ShapeExtend_WireData::Reverse(const TopoDS_Face& face) { Reverse(); if (face.IsNull()) + { return; + } // ATTENTION aux coutures // Une edge de couture est presente deux fois, FWD et REV @@ -481,9 +556,13 @@ void ShapeExtend_WireData::Reverse(const TopoDS_Face& face) // Il faut donc aussi permuter leurs pcurves ComputeSeams(true); if (mySeamF > 0) + { SwapSeam(myEdges->Value(mySeamF), face); + } if (mySeamR > 0) + { SwapSeam(myEdges->Value(mySeamR), face); + } int nb = (mySeams.IsNull() ? 0 : mySeams->Length()); for (int i = 1; i <= nb; i++) { @@ -525,7 +604,9 @@ TopoDS_Edge ShapeExtend_WireData::NonmanifoldEdge(const int num) const { TopoDS_Edge E; if (num < 0) + { return E; + } return TopoDS::Edge(myNonmanifoldEdges->Value(num)); } @@ -535,8 +616,12 @@ TopoDS_Edge ShapeExtend_WireData::NonmanifoldEdge(const int num) const int ShapeExtend_WireData::Index(const TopoDS_Edge& edge) { for (int i = 1; i <= NbEdges(); i++) + { if (Edge(i).IsSame(edge) && (Edge(i).Orientation() == edge.Orientation() || !IsSeam(i))) + { return i; + } + } return 0; } @@ -545,12 +630,18 @@ int ShapeExtend_WireData::Index(const TopoDS_Edge& edge) bool ShapeExtend_WireData::IsSeam(const int num) { if (mySeamF < 0) + { ComputeSeams(); + } if (mySeamF == 0) + { return false; + } if (num == mySeamF || num == mySeamR) + { return true; + } // Use hash set for O(1) lookup instead of O(n) linear search return mySeamsCache.Contains(num); } @@ -568,7 +659,9 @@ TopoDS_Wire ShapeExtend_WireData::Wire() const { TopoDS_Edge aE = Edge(i); if (aE.Orientation() != TopAbs_FORWARD && aE.Orientation() != TopAbs_REVERSED) + { ismanifold = false; + } B.Add(W, aE); } if (ismanifold) @@ -576,13 +669,17 @@ TopoDS_Wire ShapeExtend_WireData::Wire() const TopoDS_Vertex vf, vl; TopExp::Vertices(W, vf, vl); if (!vf.IsNull() && !vl.IsNull() && vf.IsSame(vl)) + { W.Closed(true); + } } if (myManifoldMode) { nb = NbNonManifoldEdges(); for (i = 1; i <= nb; i++) + { B.Add(W, NonmanifoldEdge(i)); + } } return W; } @@ -595,15 +692,21 @@ TopoDS_Wire ShapeExtend_WireData::WireAPIMake() const BRepBuilderAPI_MakeWire MW; int i, nb = NbEdges(); for (i = 1; i <= nb; i++) + { MW.Add(Edge(i)); + } if (myManifoldMode) { nb = NbNonManifoldEdges(); for (i = 1; i <= nb; i++) + { MW.Add(NonmanifoldEdge(i)); + } } if (MW.IsDone()) + { W = MW.Wire(); + } return W; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix.cxx index ad477d36cf..b07d12e6bf 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix.cxx @@ -76,12 +76,16 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& // Calculate number of edges int aNbEdges = 0; for (TopExp_Explorer anEdgeExp(shape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) + { ++aNbEdges; + } // Calculate number of faces int aNbFaces = 0; for (TopExp_Explorer anEdgeExp(shape, TopAbs_FACE); anEdgeExp.More(); anEdgeExp.Next()) + { ++aNbFaces; + } NCollection_IndexedDataMap, TopTools_ShapeMapHasher> aMapEF; @@ -119,7 +123,9 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& ex.Next(); if (!iatol) + { tol = BRep_Tool::Tolerance(E); + } if (enforce) { B.SameRange(E, false); @@ -167,7 +173,9 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& // Halt algorithm in case of user's abort if (!aPS.More()) + { return false; + } } } @@ -188,9 +196,13 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& occ::handle GRTS = occ::down_cast(Surf); if (!GRTS.IsNull()) + { plane = occ::down_cast(GRTS->BasisSurface()); + } if (plane.IsNull()) + { continue; + } } occ::handle AS = new GeomAdaptor_Surface(plane); @@ -200,11 +212,15 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& double f, l; occ::handle crv = BRep_Tool::Curve(edge, f, l); if (crv.IsNull()) + { continue; + } occ::handle c2d = BRep_Tool::CurveOnSurface(edge, face, f, l); if (c2d.IsNull()) + { continue; + } occ::handle GHPC = new Geom2dAdaptor_Curve(c2d, f, l); Adaptor3d_CurveOnSurface ACS(GHPC, AS); @@ -242,7 +258,9 @@ bool ShapeFix::SameParameter(const TopoDS_Shape& } // Halt algorithm in case of user's abort if (!aPS.More()) + { return false; + } } if (!status) @@ -339,7 +357,9 @@ static double getNearPoint(const NCollection_Sequence& aSeq1, gp_Pnt p2 = aSeq2.Value(j); double d = p1.Distance(p2); if (fabs(d - mindist) <= Precision::Confusion()) + { continue; + } if (d < mindist) { mindist = d; @@ -349,7 +369,9 @@ static double getNearPoint(const NCollection_Sequence& aSeq1, } } if (ind1 && ind2) + { acent = (aSeq1.Value(ind1).XYZ() + aSeq2.Value(ind2).XYZ()) / 2.0; + } return mindist; } @@ -366,7 +388,9 @@ static bool getNearestEdges(NCollection_List& theLEdges, gp_XYZ& thecenterreject) { if (theLEdges.IsEmpty()) + { return false; + } NCollection_Map aMapEdges; NCollection_List atempList; @@ -386,14 +410,22 @@ static bool getNearestEdges(NCollection_List& theLEdges, if (!aCurve1.IsNull()) { if (isFirst1) + { p11 = aCurve1->Value(aFirst1); + } else if (!isSame1) + { p11 = aCurve1->Value(aLast1); + } if (isSame1) + { p12 = aCurve1->Value(aLast1); + } } else + { return false; + } alIter.Next(); NCollection_Sequence aseqreject; NCollection_Sequence aseqsuit; @@ -430,11 +462,17 @@ static bool getNearestEdges(NCollection_List& theLEdges, gp_Pnt p1; gp_Pnt p2; if (isFirst) + { p1 = aCurve->Value(aFirst); + } else + { p1 = aCurve->Value(aLast); + } if (isSame) + { p2 = aCurve->Value(aLast); + } double aMinDist = RealLast(); gp_XYZ acent; if (!isSame && !isSame1) @@ -448,17 +486,23 @@ static bool getNearestEdges(NCollection_List& theLEdges, NCollection_Sequence aSeq2; aSeq1.Append(p11); if (isSame1) + { aSeq1.Append(p12); + } aSeq2.Append(p1); if (isSame) + { aSeq2.Append(p2); + } aMinDist = getNearPoint(aSeq1, aSeq2, acent); } if (aMinDist > theTolerance) { if (!aseqreject.Length()) + { thecenterreject = acent; + } aseqreject.Append(aEdge); } else @@ -469,11 +513,17 @@ static bool getNearestEdges(NCollection_List& theLEdges, aseqsuit.Append(aEdge); } else if (!isSame1) + { aseqsuit.Append(aEdge); + } else if ((thecentersuit - acent).Modulus() < theTolerance) + { aseqsuit.Append(aEdge); + } else + { aseqreject.Append(aEdge); + } } } atempList.Remove(alIter); @@ -503,7 +553,9 @@ static bool getNearestEdges(NCollection_List& theLEdges, } } else + { theRejectEdges.Append(aEdge1); + } return isDone; } @@ -526,11 +578,17 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape { const TopoDS_Shape& aVert = aExp3.Value(); if (nV == 1) + { aVert1 = aVert; + } else if (aVert1.IsSame(aVert)) + { continue; + } if (aMapVertEdges.Contains(aVert)) + { aMapVertEdges.ChangeFromKey(aVert).Append(aExp1.Current()); + } else { NCollection_List alEdges; @@ -546,7 +604,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape TopoDS_Vertex aVert = TopoDS::Vertex(aMapVertEdges.FindKey(i)); double aTolVert = BRep_Tool::Tolerance(aVert); if (aTolVert <= theTolerance) + { continue; + } BRep_Builder aB1; aB1.UpdateVertex(aVert, theTolerance); @@ -558,7 +618,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape NCollection_List aledges; aledges = aMapVertEdges.FindFromIndex(i); if (aledges.Extent() == 1) + { continue; + } // if tolerance of vertex is more than specified tolerance // check distance between curves and vertex @@ -569,7 +631,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape theTolerance, acenter, acenterreject)) + { continue; + } // update vertex by nearest point bool isAdd = false; @@ -584,7 +648,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape bool isFirst = (aVert1.IsSame(aVert)); bool isLast = (aVert2.IsSame(aVert)); if (!isFirst && !isLast) + { continue; + } double aFirst, aLast; occ::handle aCurve; TopoDS_Edge aEdge = TopoDS::Edge(thecontext->Apply(aEdgeOld)); @@ -615,9 +681,13 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape { TopoDS_Edge enew; if (p1.Distance(acenter) < p2.Distance(acenter)) + { enew = ReplaceVertex(aEdge, p2, false); + } else + { enew = ReplaceVertex(aEdge, p1, true); + } thecontext->Replace(aEdge, enew); isDone = true; } @@ -633,9 +703,13 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape { TopoDS_Edge enew; if (p1.Distance(acenter) < p2.Distance(acenter)) + { enew = ReplaceVertex(aEdge, p2, false); + } else + { enew = ReplaceVertex(aEdge, p1, true); + } thecontext->Replace(aEdge, enew); isDone = true; } @@ -668,7 +742,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape bool isFirst = (aVert1.IsSame(aVert)); bool isLast = (aVert2.IsSame(aVert)); if (!isFirst && !isLast) + { continue; + } bool isSame = aVert1.IsSame(aVert2); occ::handle aCurve; TopoDS_Edge aEdge = TopoDS::Edge(thecontext->Apply(aEdgeOld)); @@ -687,13 +763,17 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape { enew = ReplaceVertex(aEdge, p1, true); if (isSame) + { enew = ReplaceVertex(enew, p2, false); + } } else { enew = ReplaceVertex(aEdge, p2, false); if (isSame) + { enew = ReplaceVertex(enew, p1, true); + } } thecontext->Replace(aEdge, enew); @@ -702,7 +782,9 @@ bool ShapeFix::FixVertexPosition(TopoDS_Shape& theshape } } if (isDone) + { theshape = thecontext->Apply(theshape); + } return isDone; } @@ -726,7 +808,9 @@ double ShapeFix::LeastEdgeSize(TopoDS_Shape& theShape) bb.Get(x1, y1, z1, x2, y2, z2); size = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); if (size < aRes) + { aRes = size; + } } } aRes = sqrt(aRes); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ComposeShell.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ComposeShell.cxx index 36d411ee2e..946ec8ffaa 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ComposeShell.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ComposeShell.cxx @@ -119,28 +119,42 @@ void ShapeFix_ComposeShell::Init(const occ::handle theSurface->Bounds(U0, U1, V0, V1); if (::Precision::IsInfinite(U0) || ::Precision::IsInfinite(U1) || ::Precision::IsInfinite(V0) || ::Precision::IsInfinite(V1)) + { BRepTools::UVBounds(Face, GU0, GU1, GV0, GV1); + } if (myUClosed) { if (::Precision::IsInfinite(V0)) + { V0 = GV0; + } if (::Precision::IsInfinite(V1)) + { V1 = GV1; + } gp_Pnt P0 = theSurface->Value(U0, (V0 + V1) / 2.); gp_Pnt P1 = theSurface->Value(U1, (V0 + V1) / 2.); if (P0.Distance(P1) > Precision::Confusion() * 10) + { myUClosed = false; + } } if (myVClosed) { if (::Precision::IsInfinite(U0)) + { U0 = GU0; + } if (::Precision::IsInfinite(U1)) + { U1 = GU1; + } gp_Pnt P0 = theSurface->Value((U0 + U1) / 2., V0); gp_Pnt P1 = theSurface->Value((U0 + U1) / 2., V1); if (P0.Distance(P1) > Precision::Confusion() * 10) + { myVClosed = false; + } } } // DTK-CKY 100531 end @@ -168,15 +182,23 @@ void ShapeFix_ComposeShell::Init(const occ::handle double ures = GAS.UResolution(1.) * uRange / (u2 - u1); double vres = GAS.VResolution(1.) * vRange / (v2 - v1); if (ures > 0. && myUResolution > ures) + { myUResolution = ures; + } if (vres > 0. && myVResolution > vres) + { myVResolution = vres; + } } } if (myUResolution == RealLast()) + { myUResolution = ::Precision::Parametric(1.); + } if (myVResolution == RealLast()) + { myVResolution = ::Precision::Parametric(1.); + } } //================================================================================================= @@ -217,11 +239,15 @@ bool ShapeFix_ComposeShell::Perform() BRep_Builder B; B.MakeShell(S); for (int i = 1; i <= faces.Length(); i++) + { B.Add(S, faces(i)); + } myResult = S; } else + { myResult = faces(1); + } myResult.Orientation(myOrient); myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); @@ -323,14 +349,20 @@ static double ParamPointsOnLine(const gp_Pnt2d& p1, const gp_Pnt2d& p2, const gp if (std::abs(dist1) < ::Precision::PConfusion()) { if (std::abs(dist2) < ::Precision::PConfusion()) + { return 0.5 * (ParamPointOnLine(p1, line) + ParamPointOnLine(p2, line)); + } return ParamPointOnLine(p1, line); } if (std::abs(dist2) < ::Precision::PConfusion()) + { return ParamPointOnLine(p2, line); + } // just protection if (dist2 * dist1 > 0) + { return 0.5 * (ParamPointOnLine(p1, line) + ParamPointOnLine(p2, line)); + } // else compute intersection return (ParamPointOnLine(p1, line) * dist2 - ParamPointOnLine(p2, line) * dist1) / (dist2 - dist1); @@ -355,7 +387,9 @@ static int ApplyContext(ShapeFix_WireSegment& wire, TopoDS_Shape res = context->Apply(edge); if (res.IsSame(edge)) + { return 1; + } if (res.ShapeType() == TopAbs_EDGE) { @@ -371,7 +405,9 @@ static int ApplyContext(ShapeFix_WireSegment& wire, { TopoDS_Edge E = TopoDS::Edge(it.Value()); if (!E.IsNull()) + { segw->Add(E); + } #ifdef OCCT_DEBUG else std::cout << "Error: ShapeFix_ComposeShell, ApplyContext: wrong mapping of edge" << std::endl; @@ -391,9 +427,13 @@ static int ApplyContext(ShapeFix_WireSegment& wire, : segw->NbEdges() - i + 1); TopoDS_Edge aE = segw->Edge(ind); if (i == 1) + { wire.SetEdge(index, aE); + } else + { wire.AddEdge(index, aE, iumin, iumax, ivmin, ivmax); + } } } #ifdef OCCT_DEBUG @@ -432,7 +472,9 @@ static int GetPatchIndex(const double Param, double period = Params->Value(NP) - Params->Value(1); double shift = 0; if (isClosed) + { shift = ShapeAnalysis::AdjustToPeriod(Param, Params->Value(1), Params->Value(NP)); + } double p = Param + shift; // locate patch: the same algo as in SE_CS::LocateParameter() @@ -441,7 +483,9 @@ static int GetPatchIndex(const double Param, { // double par = Params->Value(i); if (p < Params->Value(i)) + { break; + } } i--; @@ -511,9 +555,13 @@ void ShapeFix_ComposeShell::LoadWires(NCollection_Sequence { TopoDS_Edge E = TopoDS::Edge(aIt.Value()); if (E.Orientation() == TopAbs_FORWARD || E.Orientation() == TopAbs_REVERSED) + { sbwdM->Add(E); + } else + { sbwdNM->Add(E); + } } int nbMEdges = sbwdM->NbEdges(); @@ -547,7 +595,9 @@ void ShapeFix_ComposeShell::LoadWires(NCollection_Sequence // smh#8 TopoDS_Shape tmpF = myFace.Oriented(TopAbs_FORWARD); if (!sae.PCurve(sbwdM->Edge(i), TopoDS::Face(tmpF), c2d, f, l)) + { continue; + } sawo.Add(c2d->Value(f).XY(), c2d->Value(l).XY()); } @@ -558,7 +608,9 @@ void ShapeFix_ComposeShell::LoadWires(NCollection_Sequence sfw->FixReorder(); if (sfw->StatusReorder(ShapeExtend_DONE3)) + { stat = -1; + } if (stat < 0) { @@ -573,7 +625,9 @@ void ShapeFix_ComposeShell::LoadWires(NCollection_Sequence B.Add(face, w); bool isOuterAfter = ShapeAnalysis::IsOuterBound(face); if (isOuter != isOuterAfter) + { sbwdM->Reverse(face); + } } // clang-format off @@ -611,7 +665,9 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& ? 1 : 0); if (!special && begInd == endInd && begPar == endPar && (myClosedMode || isInternal)) + { special = 1; + } // for tracking cases in closed mode bool begin = true; @@ -629,7 +685,9 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& for (i = begInd;; i++) { if (i > nb) + { i = 1; + } TopoDS_Edge edge = wire->Edge(i); occ::handle c2d; @@ -656,17 +714,25 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& if (myUClosed && std::abs(line.Direction().X()) < ::Precision::PConfusion()) { if (begin) + { shift = ShapeAnalysis::AdjustByPeriod(p2d.X(), line.Location().X(), myUPeriod); + } else if (!j) + { shift = ShapeAnalysis::AdjustByPeriod(p2d.X() - p2d0.X(), 0., myUPeriod); + } p2d.SetX(p2d.X() + shift); } if (myVClosed && std::abs(line.Direction().Y()) < ::Precision::PConfusion()) { if (begin) + { shift = ShapeAnalysis::AdjustByPeriod(p2d.Y(), line.Location().Y(), myVPeriod); + } else if (!j) + { shift = ShapeAnalysis::AdjustByPeriod(p2d.Y() - p2d0.Y(), 0., myVPeriod); + } p2d.SetY(p2d.Y() + shift); } begin = false; @@ -674,7 +740,9 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& p2d0 = p2d; int pos = PointLinePosition(p2d, line); if (pos == IOR_UNDEF) + { continue; + } // analyse the deviation gp_Pnt2d p2dl = ProjectPointOnLine(p2d, line); @@ -699,9 +767,13 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& if (i == endInd) { if (special <= 0) + { break; + } else + { special = -1; + } } } if (myClosedMode) @@ -716,10 +788,14 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& { code = IOR_BOTH; if (dev > 0) + { code |= IOR_POS; + } } else if (code == IOR_BOTH) + { code = IOR_UNDEF; + } } if (myVClosed && std::abs(line.Direction().Y()) < ::Precision::PConfusion()) { @@ -727,16 +803,22 @@ int ShapeFix_ComposeShell::ComputeCode(const occ::handle& { code = IOR_BOTH; if (dev > 0) + { code |= IOR_POS; + } } else if (code == IOR_BOTH) + { code = IOR_UNDEF; + } } } return code; } if (i) + { code = IOR_UNDEF; // tangency + } else if (code == IOR_BOTH) { // parity error in intersector code = IOR_LEFT; @@ -772,15 +854,21 @@ static void DistributeSplitPoints(const occ::handle& sbwd, } for (i = 1; i <= indexes.Length() && indexes(i) < index; i++) + { ; + } for (int shift = 1; i <= indexes.Length() && indexes(i) == index; i++) { while (shift < nsplit && isreversed != (values(i) > params(shift))) + { shift++; + } indexes.SetValue(i, index + shift - 1); } for (; i <= indexes.Length(); i++) + { indexes.SetValue(i, indexes(i) + nsplit - 1); + } } //================================================================================================= @@ -792,10 +880,14 @@ static int CheckByCurve3d(const gp_Pnt& pos, const double tol) { if (c3d.IsNull()) + { return true; + } gp_Pnt p = c3d->Value(param); if (T.Form() != gp_Identity) + { p.Transform(T); + } return pos.SquareDistance(p) <= tol * tol; } @@ -811,16 +903,24 @@ static void DefinePatch(ShapeFix_WireSegment& wire, if (isCutByU) { if (!(code & IOR_LEFT)) + { wire.DefineIUMin(nb, cutIndex); + } if (!(code & IOR_RIGHT)) + { wire.DefineIUMax(nb, cutIndex); + } } else { if (!(code & IOR_RIGHT)) + { wire.DefineIVMin(nb, cutIndex); + } if (!(code & IOR_LEFT)) + { wire.DefineIVMax(nb, cutIndex); + } } } @@ -857,7 +957,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& TopAbs_Orientation anWireOrient = wire.Orientation(); gp_Trsf T; if (!myLoc.IsIdentity()) + { T = myLoc.Inverted().Transformation(); + } // Processing edge by edge (assuming that split points are sorted along the wire) for (int i = 1; i <= wire.NbEdges(); i++) @@ -888,13 +990,16 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& // Defining split parameters on edge int stop = start; while (stop <= nbSplits && indexes(stop) == i) + { stop++; + } if (stop == start) { result.AddEdge(0, edge, iumin, iumax, ivmin, ivmax); - if (code != 0 - || wire.Orientation() != TopAbs_EXTERNAL) // pdn 0 code handling for extertnal wires + if (code != 0 || wire.Orientation() != TopAbs_EXTERNAL) + { // pdn 0 code handling for extertnal wires DefinePatch(result, code, isCutByU, cutIndex); + } continue; } // find non-manifold vertices on edge @@ -904,7 +1009,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& { if (aIt.Value().Orientation() != TopAbs_FORWARD && aIt.Value().Orientation() != TopAbs_REVERSED) + { aNMVertices.Append(aIt.Value()); + } } // Collect data on edge @@ -1071,7 +1178,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& uRes, vRes, lastVTol)) + { doCut = false; + } } else if (currPnt.Distance(prevVPnt) <= prevVTol && // Tolerance is increased to prevent degenerated cuts in cases where all vertex @@ -1121,7 +1230,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& } // classification code for current segment if (j > start) + { code = SegmentCodes(j > 1 ? j - 1 : SegmentCodes.Length()); + } // if not adjusted, make new vertex if (V.IsNull()) @@ -1133,13 +1244,19 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& else if (!doCut) { for (; j < stop; j++) + { vertices.Append(lastV); + } if (!splitted) + { break; // no splitting at all + } currPar = lastPar; } else + { vertices.Append(V); + } // When edge is about to be split, copy end vertices to protect // original shape from increasing tolerance after fixing SameParameter @@ -1164,9 +1281,13 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& Context()->Replace(lastV, lV); } if (V.IsSame(lastV)) + { V = lV; + } else if (V.IsSame(prevV)) + { V = fV; + } lastV = lV; prevV = fV; } @@ -1180,7 +1301,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& bool ismanifold = (edge.Orientation() == TopAbs_FORWARD || edge.Orientation() == TopAbs_REVERSED); if (!ismanifold) + { anInitEdge.Orientation(TopAbs_FORWARD); + } TopoDS_Edge newEdge = sbe.CopyReplaceVertices(anInitEdge, prevV, V); // addition internal vertices if they exists on edge @@ -1222,14 +1345,20 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& if (!ismanifold) { - if (code == IOR_UNDEF) // tangential segment + if (code == IOR_UNDEF) + { // tangential segment newEdge.Orientation(TopAbs_EXTERNAL); + } else + { newEdge.Orientation(edge.Orientation()); + } } if (!sp && !BRep_Tool::Degenerated(newEdge)) + { B.SameRange(newEdge, false); + } // pdn take into account 0 codes (if ext) if (code == 0 && wire.Orientation() == TopAbs_EXTERNAL) { @@ -1257,9 +1386,13 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& for (int k = NbEdgesStart; k < result.NbEdges(); k++) { if (edge.Orientation() == TopAbs_FORWARD || edge.Orientation() == TopAbs_INTERNAL) + { B.Add(resWire, result.Edge(k + 1)); + } else + { B.Add(resWire, result.Edge(result.NbEdges() - k + NbEdgesStart)); + } } Context()->Replace(edge, resWire); } @@ -1269,7 +1402,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& { ShapeBuild_Edge sbe; if (edge.Orientation() == TopAbs_INTERNAL) + { edge.Orientation(TopAbs_FORWARD); + } TopoDS_Edge e1 = sbe.Copy(edge, false); occ::handle C2d2 = occ::down_cast(C2d->Copy()); B.UpdateEdge(e1, C2d, C2d2, myFace, 0.); @@ -1278,7 +1413,9 @@ ShapeFix_WireSegment ShapeFix_ComposeShell::SplitWire(ShapeFix_WireSegment& result.AddEdge(0, e1, iumin, iumax, ivmin, ivmax); } else + { result.AddEdge(0, edge, iumin, iumax, ivmin, ivmax); + } if (code == 0 && wire.Orientation() == TopAbs_EXTERNAL) { // pdn defining code for intersection of two isos @@ -1322,7 +1459,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire double dev = 0.; int code = PointLinePosition(aP2d, line, dev); if (code != IOR_UNDEF) + { return false; + } double par = ParamPointOnLine(aP2d, line); SplitLinePar.Append(par); // splitting codes for non-manifold topology should be tangential @@ -1345,9 +1484,13 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire if (myClosedMode) { if (myUClosed && std::abs(line.Direction().X()) < ::Precision::PConfusion()) + { closedDir = -1; + } else if (myVClosed && std::abs(line.Direction().Y()) < ::Precision::PConfusion()) + { closedDir = 1; + } } double halfPeriod = 0.5 * (closedDir ? closedDir < 0 ? myUPeriod : myVPeriod : 0.); @@ -1364,7 +1507,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire double f, l; occ::handle c2d; if (!sae.PCurve(E, myFace, c2d, f, l, false)) + { continue; + } occ::handle c2d_sav = c2d; // get end points @@ -1501,7 +1646,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire if (iter < nbIter) { if (iter == 1) + { c2d = occ::down_cast(c2d->Copy()); + } pppf += shiftNext.XY(); pppl += shiftNext.XY(); c2d->Translate(shiftNext); @@ -1515,24 +1662,34 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire for (i = start; i <= IntEdgePar.Length(); i++) { if (IntEdgePar(i) < f) + { IntEdgePar.SetValue(i, f); + } else if (IntEdgePar(i) > l) + { IntEdgePar.SetValue(i, l); + } } // Sort by parameter on edge for (i = IntEdgePar.Length(); i > start; i--) + { for (int j = start; j < i; j++) { if (isreversed == (IntEdgePar(j + 1) < IntEdgePar(j))) + { continue; + } IntLinePar.Exchange(j, j + 1); IntEdgePar.Exchange(j, j + 1); } + } // and fill indices for (i = start; i <= IntEdgePar.Length(); i++) + { IntEdgeInd.Append(iedge); + } // Detect intersection at closing point // Only wires which are not EXTERNAL are considered (as closed) @@ -1568,7 +1725,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire for (i = 1; i <= IntEdgePar.Length();) { if (i == j) + { break; + } if (IntEdgeInd(i) == IntEdgeInd(j) && std::abs(IntEdgePar(i) - IntEdgePar(j)) < ::Precision::PConfusion()) { @@ -1576,7 +1735,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire IntEdgePar.Remove(i); IntEdgeInd.Remove(i); if (j > i) + { j--; + } continue; } else if (nbe == 1 || IntEdgeInd(i) == (IntEdgeInd(j) % nbe) + 1) @@ -1595,7 +1756,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire IntEdgePar.Remove(i); IntEdgeInd.Remove(i); if (j > i) + { j--; + } continue; } } @@ -1646,7 +1809,9 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire // overlaps with spur edge [ACIS22539] if (myClosedMode && (IntLinePar(i) - IntLinePar(j)) * (IntLinePar(k) - IntLinePar(i)) <= 0.) + { continue; + } IntEdgeInd.Remove(i); IntEdgePar.Remove(i); @@ -1674,38 +1839,60 @@ bool ShapeFix_ComposeShell::SplitByLine(ShapeFix_WireSegment& wire int codei = SegmentCodes(i); if (myClosedMode) { - if ((codej & IOR_BOTH) == IOR_BOTH) // IOR_LEFT : IOR_RIGHT + if ((codej & IOR_BOTH) == IOR_BOTH) + { // IOR_LEFT : IOR_RIGHT codej = (codej & IOR_POS ? IOR_RIGHT : IOR_LEFT); - if ((codei & IOR_BOTH) == IOR_BOTH) // IOR_RIGHT : IOR_LEFT + } + if ((codei & IOR_BOTH) == IOR_BOTH) + { // IOR_RIGHT : IOR_LEFT codei = (codei & IOR_POS ? IOR_LEFT : IOR_RIGHT); + } aNewSegCodes.Append(codei); if (IntEdgeInd(i) == IntEdgeInd(j)) + { aNewSegCodes.Append(codej); + } } else + { aNewSegCodes.Append(codei); + } int ipcode = (codej | codei); if (codej == IOR_UNDEF) { // previous segment was tangency if (IntLinePar(i) > IntLinePar(j)) + { ipcode |= ITP_ENDSEG; // end of segment + } else + { ipcode |= ITP_BEGSEG; // beginning of segment + } } else if (codei == IOR_UNDEF) { // current segment is tangency if (IntLinePar(i < IntLinePar.Length() ? i + 1 : 1) > IntLinePar(i)) + { ipcode |= ITP_BEGSEG; // beginning of segment + } else + { ipcode |= ITP_ENDSEG; // end of segment + } } // internal wire can be only tangent else if (i == j) + { ipcode |= ((ipcode & IOR_BOTH) == IOR_BOTH && !isnonmanifold ? ITP_INTER : ITP_TANG); + } else if (codei == codej || isnonmanifold) + { ipcode |= ITP_TANG; // tangency in-point + } else + { ipcode |= ITP_INTER; // standard crossing + } IntCode.Append(ipcode); } } @@ -1746,6 +1933,7 @@ void ShapeFix_ComposeShell::SplitByLine(NCollection_Sequence 1; i--) + { for (int j = 1; j < i; j++) { if (SplitLinePar(j) > SplitLinePar(j + 1)) @@ -1755,13 +1943,16 @@ void ShapeFix_ComposeShell::SplitByLine(NCollection_Sequence ::Precision::PConfusion() && !SplitLineVertex(i).IsSame(SplitLineVertex(i + 1))) + { continue; + } if ((SplitLineCode(i) & ITP_ENDSEG && SplitLineCode(i + 1) & ITP_BEGSEG) || (SplitLineCode(i) & ITP_BEGSEG && SplitLineCode(i + 1) & ITP_ENDSEG)) { @@ -1791,17 +1982,25 @@ void ShapeFix_ComposeShell::SplitByLine(NCollection_Sequence sbwd = seqw(i).WireData(); for (int j = 1; j <= sbwd->NbEdges(); j++) @@ -2101,7 +2312,9 @@ void ShapeFix_ComposeShell::BreakWires(NCollection_Sequence& sbwd = wire.WireData(); // find first vertex for split @@ -2110,10 +2323,14 @@ void ShapeFix_ComposeShell::BreakWires(NCollection_SequenceEdge(j)); if (splitVertices.Contains(V)) + { break; + } } if (j > sbwd->NbEdges()) + { continue; // splitting not needed + } // if first split of closed edge is not its start, make permutation int shift = 0; @@ -2121,7 +2338,9 @@ void ShapeFix_ComposeShell::BreakWires(NCollection_SequenceEdge(1)); if (!splitVertices.Contains(V)) + { shift = j - 1; + } // wire.SetLast ( j-1 ); } @@ -2181,7 +2400,9 @@ static int IsShortSegment(const ShapeFix_WireSegment& seg, { TopoDS_Vertex Vf = seg.FirstVertex(); if (!Vf.IsSame(seg.LastVertex())) + { return 0; + } gp_Pnt pnt = BRep_Tool::Pnt(Vf); double tol = BRep_Tool::Tolerance(Vf); @@ -2194,24 +2415,34 @@ static int IsShortSegment(const ShapeFix_WireSegment& seg, { TopoDS_Edge edge = sbwd->Edge(i); if (!Vf.IsSame(sae.LastVertex(edge))) + { return 0; + } occ::handle c2d; double f, l; if (!sae.PCurve(edge, myFace, c2d, f, l)) + { continue; + } // check 2d gp_Pnt2d endPnt = c2d->Value(l); gp_Pnt2d midPnt = c2d->Value((f + l) / 2); if (!IsCoincided(endPnt, midPnt, UResolution, VResolution, tol)) + { code = -1; + } // check 3d gp_Pnt midPnt3d = myGrid->Value(midPnt.X(), midPnt.Y()); if (!myLoc.IsIdentity()) + { midPnt3d.Transform(myLoc.Transformation()); + } if (midPnt3d.SquareDistance(pnt) > tol2) + { return 0; + } } return code; } @@ -2234,13 +2465,21 @@ static bool IsSamePatch(const ShapeFix_WireSegment& wire, // shift to the same period int du = 0, dv = 0; if (jumin - iumin > NU) + { du = -(jumin - iumin) / NU; + } else if (iumin - jumin > NU) + { du = (iumin - jumin) / NU; + } if (jvmin - ivmin > NV) + { dv = -(jvmin - ivmin) / NV; + } else if (ivmin - jvmin > NV) + { dv = (ivmin - jvmin) / NV; + } if (du) { jumin += du * NU; @@ -2332,20 +2571,30 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence 0) + { continue; + } if (anOr == TopAbs_EXTERNAL) + { continue; + } if (anOr == TopAbs_FORWARD) + { reverse = true; + } index = i; seg.GetPatchIndex(1, iumin, iumax, ivmin, ivmax); @@ -2360,7 +2609,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence wire->NbEdges()) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } if (myClosedMode) { @@ -2432,7 +2689,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence 0 ? M_PI : endTan.Angle(lVec)); if (myClosedMode && shorts(i) <= 0 && M_PI - ang < ::Precision::Angular()) + { ang = 0.; // abv 21 Mar 00: trj3_s1-md-214.stp #2471: avoid going back + } // abv 05 Feb 02: face from Parasolid: use tolerance of edges for check // for coincidence (instead of vertex tolerance) in order @@ -2447,7 +2706,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence angle ? 1 : 0); int tail2 = (!connected && (dist > mindist) ? 2 : 0) + (ang < angle ? 1 : 0); if (w1 + tail1 <= weigth + tail2) + { continue; + } index = i; reverse = j != 0; @@ -2466,10 +2727,14 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_SequenceAdd(seg.WireData()); + } else { occ::handle wire = new ShapeExtend_WireData; @@ -2499,13 +2768,19 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_SequenceAdd(wire); } if (seg.Orientation() == TopAbs_EXTERNAL) + { seg.Orientation(reverse ? TopAbs_REVERSED : TopAbs_FORWARD); + } else + { seg.Orientation(TopAbs_INTERNAL); + } seqw.SetValue(index, seg); } else if (sbwd.IsNull()) + { break; // stop when no free segments available + } // for first segment, remember start point if (endV.IsNull()) { @@ -2525,15 +2800,25 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_SequenceNbEdges(); k >= 1; k--) + { // if ( sae.GetEndTangent2d ( sbwd->Edge ( k ), myFace, true, endPnt, endTan ) ) if (sae.GetEndTangent2d(sbwd->Edge(k), myFace, true, endPnt, endTan, 1.e-3)) + { break; + } + } if (k < 1) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } if (myUClosed) + { endPnt.SetX(endPnt.X() + dsu); + } if (myVClosed) + { endPnt.SetY(endPnt.Y() + dsv); + } } // if closed or no next segment found, add to wires @@ -2569,7 +2854,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence wd = seqw(i).WireData(); @@ -2590,7 +2877,8 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_SequenceNbEdges(); k++) { // clang-format off - if ( !V.IsSame ( sae.FirstVertex ( sbwd->Edge(k) ) ) ) continue; //pdn I suppose that short segment should be inserted into the SAME vertex. + if ( !V.IsSame ( sae.FirstVertex ( sbwd->Edge(k) ) ) ) { continue; //pdn I suppose that short segment should be inserted into the SAME vertex. +} // clang-format on bool sp = IsSamePatch(wires(j), @@ -2601,7 +2889,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_SequenceEdge(k), myFace, false, pp, vec); double dist = pp.SquareDistance(p2d); @@ -2636,7 +2926,9 @@ void ShapeFix_ComposeShell::CollectWires(NCollection_Sequence sbwd = wires(minj).WireData(); for (int n = 1; n <= wd->NbEdges(); n++) + { sbwd->Add(wd->Edge(n), mink++); + } // wires.Remove ( i ); // i--; @@ -2673,7 +2965,9 @@ static gp_Pnt2d GetMiddlePoint(const ShapeFix_WireSegment& wire, const TopoDS_Fa } } if (box.IsVoid()) + { return gp_Pnt2d(0., 0.); + } double aXmin, aYmin, aXmax, aYmax; box.Get(aXmin, aYmin, aXmax, aYmax); return gp_Pnt2d(0.5 * (aXmax + aXmin), 0.5 * (aYmax + aYmin)); @@ -2694,7 +2988,9 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& B.MakeFace(newFace, surf, myLoc, ::Precision::Confusion()); const TopoDS_Shape& aSH = loops.Value(1); if (aSH.ShapeType() != TopAbs_WIRE) + { return; + } TopoDS_Wire wire = TopoDS::Wire(loops.Value(1)); B.Add(newFace, wire); @@ -2729,39 +3025,55 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& TopoDS_Shape aShape = loops(i); if (aShape.ShapeType() != TopAbs_WIRE || (aShape.Orientation() != TopAbs_FORWARD && aShape.Orientation() != TopAbs_REVERSED)) + { continue; + } wr = TopoDS::Wire(loops(i)); TopoDS_Iterator ew(wr); if (!ew.More()) + { continue; + } TopoDS_Edge ed = TopoDS::Edge(ew.Value()); while (ed.Orientation() != TopAbs_FORWARD && ed.Orientation() != TopAbs_REVERSED) { ew.Next(); if (ew.More()) + { ed = TopoDS::Edge(ew.Value()); + } else + { break; + } } if (!ew.More()) + { continue; + } double cf, cl; occ::handle cw = BRep_Tool::CurveOnSurface(ed, pf, cf, cl); if (cw.IsNull()) + { continue; + } unp = cw->Value(0.5 * (cf + cl)); int j; // svv #1 for (j = 1; j <= loops.Length(); j++) { if (i == j) + { continue; + } TopoDS_Shape aShape2 = loops(j); if (aShape2.ShapeType() != TopAbs_WIRE || (aShape2.Orientation() != TopAbs_FORWARD && aShape2.Orientation() != TopAbs_REVERSED)) + { continue; + } TopoDS_Wire w1 = TopoDS::Wire(aShape2); TopoDS_Wire awtmp; B.MakeWire(awtmp); @@ -2778,7 +3090,9 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& } } if (!nbe) + { continue; + } TopoDS_Face fc; B.MakeFace(fc, surf, myLoc, ::Precision::Confusion()); B.Add(fc, awtmp); @@ -2795,21 +3109,31 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& { stPoint = clas.Perform(aCW->Value(aCL), false); if (!ew.More()) + { break; + } ew.Next(); if (!ew.More()) + { break; + } TopoDS_Edge edge = TopoDS::Edge(ew.Value()); if (edge.Orientation() != TopAbs_FORWARD && edge.Orientation() != TopAbs_REVERSED) + { continue; + } occ::handle c2d = BRep_Tool::CurveOnSurface(edge, pf, aCF, aCL); if (!c2d.IsNull()) + { aCW = c2d; + } } } TopAbs_State stInfin = clas.PerformInfinitePoint(); if (stPoint != stInfin) + { break; + } } if (j > loops.Length()) { @@ -2820,12 +3144,16 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& // And remove them from the list of loops for (i = 1; i <= loops.Length(); i++) + { for (int j = 1; j <= roots.Length(); j++) + { if (loops(i).IsSame(roots(j))) { loops.Remove(i--); break; } + } + } // check for lost wires, and if they are, make them roots if (roots.Length() <= 0 && loops.Length() > 0) @@ -2870,12 +3198,16 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& TopoDS_Wire bw = TopoDS::Wire(loops(j)); TopoDS_Iterator ew(bw); if (!ew.More()) + { continue; + } TopoDS_Edge ed = TopoDS::Edge(ew.Value()); double cf, cl; occ::handle cw = BRep_Tool::CurveOnSurface(ed, pf, cf, cl); if (cw.IsNull()) + { continue; + } unp = cw->Value(0.5 * (cf + cl)); } else if (loops(j).ShapeType() == TopAbs_VERTEX) @@ -2885,7 +3217,9 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& unp = aSurfTool->ValueOfUV(aP, Precision::Confusion()); } else + { continue; + } TopAbs_State state = clas.Perform(unp, false); if ((state == TopAbs_OUT) == reverse) { @@ -2909,7 +3243,9 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& B.Add(newFace, aNewV); } else + { B.Add(newFace, holes(j)); + } } faces.Append(newFace); @@ -2925,7 +3261,9 @@ void ShapeFix_ComposeShell::MakeFacesOnPatch(NCollection_Sequence& TopoDS_Shape aSh = loops(j); if (aSh.ShapeType() == TopAbs_WIRE && (aSh.Orientation() == TopAbs_FORWARD || aSh.Orientation() == TopAbs_REVERSED)) + { roots.Append(loops(j)); + } } loops.Clear(); } @@ -2951,7 +3289,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& for (i = 1; i <= wires.Length(); i++) { if (wires(i).IsVertex()) + { continue; + } occ::handle sbwd = wires(i).WireData(); for (int jL = 1; jL <= sbwd->NbEdges(); jL++) @@ -2973,9 +3313,13 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& { gp_Vec2d shift(0., 0.); if (myUClosed && std::abs(pf2.X() - pl2.X()) < ::Precision::PConfusion()) + { shift.SetX(myUPeriod); + } if (myVClosed && std::abs(pf2.Y() - pl2.Y()) < ::Precision::PConfusion()) + { shift.SetY(myVPeriod); + } c22->Translate(shift); } } @@ -2985,7 +3329,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& for (i = 1; i <= wires.Length(); i++) { if (wires(i).IsVertex()) + { continue; + } occ::handle sbwd = wires(i).WireData(); //: abv 30.08.01: torHalf2.sat: if wire contains single degenerated @@ -3004,7 +3350,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& for (int jL = 1; jL <= sbwd->NbEdges(); jL++) { if (BRep_Tool::Degenerated(sbwd->Edge(jL))) + { sbe.RemovePCurve(sbwd->Edge(jL), myFace); + } // sfw.FixDegenerated(jL); } sfw.FixDegenerated(); @@ -3017,11 +3365,15 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& // pdn protection on empty sequence if (nb == 0) + { return; + } int i; // svv #1 for (i = 1; i <= nb; i++) + { mPnts.Append(GetMiddlePoint(wires(i), myFace)); + } // Put each wire on its own surface patch (by reassigning pcurves) // and build 3d curve if necessary @@ -3062,7 +3414,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& needT = true; } if (wires(i).IsVertex()) + { continue; + } occ::handle surf = myGrid->Patch(indU, indV); TopoDS_Face face; B.MakeFace(face, surf, myLoc, ::Precision::Confusion()); @@ -3090,11 +3444,15 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& else { if (!ismanifold) + { anInitEdge.Orientation(TopAbs_FORWARD); + } newEdge = sbe.Copy(anInitEdge, false); if (!ismanifold) + { newEdge.Orientation(edge.Orientation()); + } rs.Replace(edge, newEdge); Context()->Replace(edge, newEdge); } @@ -3120,18 +3478,28 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& if (sae.PCurve(e2, face, c2d2, cf, cl, false)) { if (newEdge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(newEdge, c2dnew, c2d2, face, 0.); + } else + { B.UpdateEdge(newEdge, c2d2, c2dnew, face, 0.); + } } else + { B.UpdateEdge(newEdge, c2dnew, face, 0.); + } } else + { B.UpdateEdge(newEdge, c2dnew, face, 0.); + } B.Range(newEdge, face, newf, newl); if ((newf != f || newl != l) && !BRep_Tool::Degenerated(newEdge)) + { B.SameRange(newEdge, false); + } } } @@ -3144,7 +3512,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& etmp = sbe.Copy(afe, false); } else + { etmp = sbe.Copy(newEdge, false); + } sfe->FixAddCurve3d(etmp); double cf, cl; occ::handle c3d; @@ -3155,7 +3525,9 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& } } else + { sfe->FixAddCurve3d(newEdge); + } sewd->Set(newEdge, j); } } @@ -3171,29 +3543,41 @@ void ShapeFix_ComposeShell::DispatchWires(NCollection_Sequence& for (i = 1; i <= nb; i++) { if (used(i)) + { continue; + } occ::handle S = myGrid->Patch(mPnts(i)); if (Surf.IsNull()) + { Surf = S; + } else if (S != Surf) + { continue; + } used(i) = true; ShapeFix_WireSegment aSeg = wires(i); if (aSeg.IsVertex()) { TopoDS_Vertex aVert = aSeg.GetVertex(); if (aVert.Orientation() == TopAbs_INTERNAL) + { loops.Append(wires(i).GetVertex()); + } } else { const occ::handle& aWD = aSeg.WireData(); if (!aWD.IsNull()) + { loops.Append(aWD->Wire()); + } } } if (Surf.IsNull()) + { break; + } MakeFacesOnPatch(faces, Surf, loops); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Edge.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Edge.cxx index 6ece0a5951..243d1f1a91 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Edge.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Edge.cxx @@ -92,7 +92,9 @@ bool ShapeFix_Edge::FixRemovePCurve(const TopoDS_Edge& edge, ShapeAnalysis_Edge EA; bool result = EA.CheckVerticesWithPCurve(edge, surface, location); if (result) + { ShapeBuild_Edge().RemovePCurve(edge, surface, location); + } return result; } @@ -104,7 +106,9 @@ bool ShapeFix_Edge::FixRemoveCurve3d(const TopoDS_Edge& edge) ShapeAnalysis_Edge EA; bool result = EA.CheckVerticesWithCurve3d(edge); if (result) + { ShapeBuild_Edge().RemoveCurve3d(edge); + } return result; } @@ -185,9 +189,13 @@ static occ::handle TranslatePCurve(const occ::handle if (std::abs(theDir.X()) <= aTol && std::abs(theDir.Y()) >= aTol) { if (std::abs(theLoc.X() - uf) < std::abs(theLoc.X() - ul)) + { newLoc.SetCoord(theLoc.X() + (ul - uf), theLoc.Y()); + } else + { newLoc.SetCoord(theLoc.X() - (ul - uf), theLoc.Y()); + } theNewL2d = new Geom2d_Line(newLoc, theDir); } /* // case UClosed and line in U = UFirst @@ -213,9 +221,13 @@ static occ::handle TranslatePCurve(const occ::handle if (std::abs(theDir.X()) >= aTol && std::abs(theDir.Y()) <= aTol) { if (std::abs(theLoc.Y() - vf) < std::abs(theLoc.Y() - vl)) + { newLoc.SetCoord(theLoc.X(), theLoc.Y() + (vl - vf)); + } else + { newLoc.SetCoord(theLoc.X(), theLoc.Y() - (vl - vf)); + } theNewL2d = new Geom2d_Line(newLoc, theDir); } /* // case VClosed and line in V = VFirst @@ -266,9 +278,13 @@ static occ::handle TranslatePCurve(const occ::handle if (theVector.IsParallel(VectIsoUF, aTol)) { if (std::abs(FirstPoint.X() - uf) < std::abs(FirstPoint.X() - ul)) + { T.SetTranslation(p00, p10); + } else + { T.SetTranslation(p10, p00); + } newC->Transform(T); return newC; } @@ -293,9 +309,13 @@ static occ::handle TranslatePCurve(const occ::handle else if (theVector.IsParallel(VectIsoVF, aTol)) { if (std::abs(FirstPoint.Y() - vf) < std::abs(FirstPoint.Y() - vl)) + { T.SetTranslation(p00, p01); + } else + { T.SetTranslation(p01, p00); + } newC->Transform(T); return newC; } @@ -328,7 +348,9 @@ static void TempSameRange(const TopoDS_Edge& AnEdge, const double Tolerance) const occ::handle C = BRep_Tool::Curve(AnEdge, LocalLoc, current_first, current_last); if (!C.IsNull()) + { first_time_in = false; + } while (an_Iterator.More()) { @@ -456,11 +478,15 @@ bool ShapeFix_Edge::FixAddPCurve(const TopoDS_Edge& edge, myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if ((!isSeam && sae.HasPCurve(edge, surf, location)) || (isSeam && sae.IsSeam(edge, surf, location))) + { return false; + } // PCurve on Plane not computed if (surf->IsKind(STANDARD_TYPE(Geom_Plane))) + { return false; + } // double step = 0; try @@ -496,15 +522,21 @@ bool ShapeFix_Edge::FixAddPCurve(const TopoDS_Edge& edge, TopoDS_Vertex V1, V2; TopExp::Vertices(edge, V1, V2); if (!V1.IsNull()) + { TolFirst = BRep_Tool::Tolerance(V1); + } if (!V2.IsNull()) + { TolLast = BRep_Tool::Tolerance(V2); + } myProjector->Init(sas, preci); myProjector->Perform(c3d, First, Last, c2d, TolFirst, TolLast); // stat = 2 : reinterpoler la c3d ? if (myProjector->Status(ShapeExtend_DONE4)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } a1 = First; b1 = Last; } @@ -588,9 +620,13 @@ bool ShapeFix_Edge::FixAddCurve3d(const TopoDS_Edge& edge) myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); ShapeAnalysis_Edge EA; if (BRep_Tool::Degenerated(edge) || EA.HasCurve3d(edge)) + { return false; + } if (!BRep_Tool::SameRange(edge)) + { TempSameRange(edge, Precision::PConfusion()); + } if (!ShapeBuild_Edge().BuildCurve3d(edge)) { @@ -621,11 +657,17 @@ bool ShapeFix_Edge::FixVertexTolerance(const TopoDS_Edge& edge, const TopoDS_Fac double toler1, toler2; if (!sae.CheckVertexTolerance(anEdgeCopy, face, toler1, toler2)) + { return false; + } if (sae.Status(ShapeExtend_DONE1)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (sae.Status(ShapeExtend_DONE2)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } BRep_Builder B; TopoDS_Vertex V1 = sae.FirstVertex(anEdgeCopy); TopoDS_Vertex V2 = sae.LastVertex(anEdgeCopy); @@ -661,11 +703,17 @@ bool ShapeFix_Edge::FixVertexTolerance(const TopoDS_Edge& edge) } double toler1, toler2; if (!sae.CheckVertexTolerance(anEdgeCopy, toler1, toler2)) + { return false; + } if (sae.Status(ShapeExtend_DONE1)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (sae.Status(ShapeExtend_DONE2)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } BRep_Builder B; TopoDS_Vertex V1 = sae.FirstVertex(anEdgeCopy); TopoDS_Vertex V2 = sae.LastVertex(anEdgeCopy); @@ -702,11 +750,17 @@ bool ShapeFix_Edge::FixReversed2d(const TopoDS_Edge& edge, ShapeAnalysis_Edge EA; EA.CheckCurve3dWithPCurve(edge, surface, location); if (EA.Status(ShapeExtend_FAIL1)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } if (EA.Status(ShapeExtend_FAIL2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } if (!EA.Status(ShapeExtend_DONE)) + { return false; + } occ::handle c2d; double f, l; @@ -751,7 +805,9 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, { BRep_Builder B; if (!BRep_Tool::SameRange(edge)) + { TempSameRange(edge, Precision::PConfusion()); + } B.SameParameter(edge, true); return false; } @@ -773,7 +829,9 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, { OCC_CATCH_SIGNALS if (!BRep_Tool::SameRange(edge)) + { TempSameRange(edge, Precision::PConfusion()); + } // #81 rln 15.03.99 S4135: for not SP edge choose the best result (either BRepLib or deviation // only) if (!wasSP) @@ -792,7 +850,9 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, BRepLib::SameParameter(copyedge, (tolerance >= Precision::Confusion() ? tolerance : tol)); SP = BRep_Tool::SameParameter(copyedge); if (!SP) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } } } catch (Standard_Failure const& anException) @@ -821,7 +881,9 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, sae.CheckSameParameter(edge, aFace, maxdev); if (sae.Status(ShapeExtend_FAIL2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } // if BRepLib was OK, compare and select the best variant if (SP) @@ -830,13 +892,17 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, sae.CheckSameParameter(copyedge, BRLDev); myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); if (BRLTol < BRLDev) + { BRLTol = BRLDev; + } // chose the best result if (BRLTol < maxdev) { if (sae.Status(ShapeExtend_FAIL2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } // copy pcurves and tolerances from copyedge ShapeBuild_Edge().CopyPCurves(edge, copyedge); maxdev = BRLTol; @@ -847,9 +913,13 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, // restore tolerances because they could be modified by BRepLib if (!V1.IsNull()) + { SFST.SetTolerance(V1, std::max(maxdev, TolFV), TopAbs_VERTEX); + } if (!V2.IsNull()) + { SFST.SetTolerance(V2, std::max(maxdev, TolLV), TopAbs_VERTEX); + } if (maxdev > tol) { @@ -859,7 +929,9 @@ bool ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge, } if (!wasSP && !SP) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } return Status(ShapeExtend_DONE); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeConnect.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeConnect.cxx index e719db4ad1..7cb8aba7f3 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeConnect.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeConnect.cxx @@ -144,7 +144,9 @@ void ShapeFix_EdgeConnect::Add(const TopoDS_Shape& aShape) } // Connect first and last edges if wire is closed if (theWire.Closed()) + { Add(theEdge, theFirst); + } } } } @@ -194,7 +196,9 @@ void ShapeFix_EdgeConnect::Build() { occ::handle GC = occ::down_cast(theCIterator.Value()); if (GC.IsNull()) + { continue; + } // Calculate vertex position for this curve double theFParam, theLParam; GC->Range(theFParam, theLParam); @@ -229,25 +233,41 @@ void ShapeFix_EdgeConnect::Build() { thePosition = thePositions.Value(i); if (i == 1) + { theLBound = theRBound = thePosition; + } double val = thePosition.X(); if (val < theLBound.X()) + { theLBound.SetX(val); + } else if (val > theRBound.X()) + { theRBound.SetX(val); + } val = thePosition.Y(); if (val < theLBound.Y()) + { theLBound.SetY(val); + } else if (val > theRBound.Y()) + { theRBound.SetY(val); + } val = thePosition.Z(); if (val < theLBound.Z()) + { theLBound.SetZ(val); + } else if (val > theRBound.Z()) + { theRBound.SetZ(val); + } } if (theNbPos > 1) + { thePosition = (theLBound + theRBound) / 2.; + } #endif // Calculate maximal deviation @@ -257,11 +277,15 @@ void ShapeFix_EdgeConnect::Build() { double theDeviation = (thePosition - thePositions.Value(i)).Modulus(); if (theDeviation > theMaxDev) + { theMaxDev = theDeviation; + } } theMaxDev *= 1.0001; // To avoid numerical roundings if (theMaxDev < Precision::Confusion()) + { theMaxDev = Precision::Confusion(); + } // Update shared vertex theBuilder.UpdateVertex(theSharedVertex, gp_Pnt(thePosition), theMaxDev); @@ -283,9 +307,13 @@ void ShapeFix_EdgeConnect::Build() // Prepare vertex to remove TopoDS_Vertex theOldVertex; if (use_start) + { theOldVertex = theStart; // start is preferred for closed edges + } else + { theOldVertex = theEnd; + } // Prepare vertex to add TopoDS_Vertex theNewVertex; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeProjAux.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeProjAux.cxx index b514484d00..7ac3291deb 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeProjAux.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_EdgeProjAux.cxx @@ -186,7 +186,9 @@ static bool FindParameterWithExt(const gp_Pnt& Pt1, return true; } else + { return false; + } } // end try catch (Standard_Failure const& anException) { @@ -211,7 +213,9 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) occ::handle theSurface = BRep_Tool::Surface(myFace); occ::handle theCurve2d = BRep_Tool::CurveOnSurface(myEdge, myFace, cf, cl); if (theCurve2d.IsNull()) + { return; //: r5 abv 6 Apr 99: ec_turbine-A.stp, #4313 + } myFirstParam = 0.; myLastParam = 0.; TopoDS_Vertex V1, V2; @@ -345,7 +349,9 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) if (dir.X() != 0) { if (dir.Y() == 0) + { parU = true; + } gp_Pnt2d pnt = lin->Location(); // szv#4:S4163:12Mar99 moved double cfi = (uf - pnt.X()) / dir.X(); double cli = (ul - pnt.X()) / dir.X(); @@ -415,7 +421,9 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) double dist = sac.Project(COnS, Pt1, preci, pnt, w1, false); // if distance is infinite then projection is not performed if (Precision::IsInfinite(dist)) + { return; + } myFirstDone = true; myFirstParam = w1; @@ -423,7 +431,9 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) dist = sac.Project(COnS, Pt2, preci, pnt, w2, false); if (Precision::IsInfinite(dist)) + { return; + } myLastDone = true; myLastParam = w2; @@ -431,11 +441,15 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) if (fabs(w1 - w2) < Precision::PConfusion()) { if (!theSurface->IsUPeriodic() && !theSurface->IsVPeriodic()) + { return; + } } if (myFirstParam == Uinf && myLastParam == Usup) + { return; + } if (myFirstParam == Usup && myLastParam == Uinf) { myFirstParam = theCurve2d->ReversedParameter(Usup); @@ -452,11 +466,15 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) // 18.11.2002 SKL OCC630 compare values with tolerance Precision::PConfusion() instead of "==" if (std::abs(myFirstParam - Uinf) < ::Precision::PConfusion() && std::abs(myLastParam - Uinf) < ::Precision::PConfusion()) + { myLastParam = w2 = Usup; - // 18.11.2002 SKL OCC630 compare values with tolerance Precision::PConfusion() instead of "==" + // 18.11.2002 SKL OCC630 compare values with tolerance Precision::PConfusion() instead of "==" + } else if (std::abs(myFirstParam - Usup) < ::Precision::PConfusion() && std::abs(myLastParam - Usup) < ::Precision::PConfusion()) + { myFirstParam = w1 = Uinf; + } } // pdn adjust parameters in periodic case @@ -482,9 +500,13 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) if (w1 >= w2) { if (w2 > wmid) + { myFirstParam -= period; + } else if (w1 > wmid) + { UpdateParam2d(theCurve2d); + } else { myLastParam += period; @@ -511,7 +533,6 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci) } } UpdateParam2d(theCurve2d); - return; } //================================================================================================= @@ -524,7 +545,9 @@ void ShapeFix_EdgeProjAux::Init3d(const double preci) occ::handle theSurface = BRep_Tool::Surface(myFace); occ::handle theCurve2d = BRep_Tool::CurveOnSurface(myEdge, myFace, cf, cl); if (theCurve2d.IsNull()) + { return; //: r5 abv 6 Apr 99: ec_turbine-A.stp, #4313 + } TopoDS_Vertex V1, V2; V1 = TopExp::FirstVertex(myEdge); @@ -596,7 +619,9 @@ void ShapeFix_EdgeProjAux::Init3d(const double preci) void ShapeFix_EdgeProjAux::UpdateParam2d(const occ::handle& theCurve2d) { if (myFirstParam < myLastParam) + { return; + } double cf = theCurve2d->FirstParameter(); double cl = theCurve2d->LastParameter(); @@ -612,9 +637,13 @@ void ShapeFix_EdgeProjAux::UpdateParam2d(const occ::handle& theCur { // szv#4:S4163:12Mar99 optimized if (std::abs(myFirstParam - cl) <= preci2d) + { myFirstParam = cf; + } else if (std::abs(myLastParam - cf) <= preci2d) + { myLastParam = cl; + } else { #ifdef OCCT_DEBUG @@ -632,9 +661,13 @@ void ShapeFix_EdgeProjAux::UpdateParam2d(const occ::handle& theCur if (aBSpline2d->StartPoint().Distance(aBSpline2d->EndPoint()) <= preci2d) { if (std::abs(myFirstParam - cl) <= preci2d) + { myFirstParam = cf; + } else if (std::abs(myLastParam - cf) <= preci2d) + { myLastParam = cl; + } } } else diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Face.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Face.cxx index 60a4434dae..20879a1db7 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Face.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Face.cxx @@ -199,7 +199,9 @@ void ShapeFix_Face::Init(const occ::handle& surf, myShape = myFace; myFwd = fwd; if (!fwd) + { myFace.Orientation(TopAbs_REVERSED); + } } //================================================================================================= @@ -223,7 +225,9 @@ void ShapeFix_Face::Init(const TopoDS_Face& theFace) void ShapeFix_Face::Add(const TopoDS_Wire& wire) { if (wire.IsNull()) + { return; + } BRep_Builder B; // szv#4:S4163:12Mar99 SGI warns TopoDS_Shape fc = myFace.Oriented(TopAbs_FORWARD); //: l2 abv 10 Jan 99: Oriented() @@ -246,7 +250,9 @@ static bool SplitWire(const TopoDS_Face& face, for (i = 1; i <= sewd->NbEdges(); i++) { if (UsedEdges.Contains(i)) + { continue; + } TopoDS_Edge E1 = sewd->Edge(i); UsedEdges.Add(i); TopoDS_Vertex V0, V1, V2; @@ -261,7 +267,9 @@ static bool SplitWire(const TopoDS_Face& face, for (k = 2; k <= sewd->NbEdges(); k++) { if (UsedEdges.Contains(k)) + { continue; + } E2 = sewd->Edge(k); TopoDS_Vertex V21 = sae.FirstVertex(E2); TopoDS_Vertex V22 = sae.LastVertex(E2); @@ -285,13 +293,19 @@ static bool SplitWire(const TopoDS_Face& face, occ::handle curve1 = BRep_Tool::CurveOnSurface(E1, face, a1, b1); occ::handle curve2 = BRep_Tool::CurveOnSurface(E2, face, a2, b2); if (curve1.IsNull() || curve2.IsNull()) + { continue; + } gp_Pnt2d v0, v1; if (E1.Orientation() == TopAbs_REVERSED) + { a1 = b1; + } if (E2.Orientation() == TopAbs_REVERSED) + { b2 = a2; + } curve1->D0(a1, v0); curve2->D0(b2, v1); GeomAdaptor_Surface anAdaptor(BRep_Tool::Surface(face)); @@ -311,7 +325,9 @@ static bool SplitWire(const TopoDS_Face& face, aResWires.Append(sewd1->Wire()); } if (UsedEdges.Extent() == sewd->NbEdges()) + { break; + } } return true; @@ -325,7 +341,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) myFixWire->SetContext(Context()); occ::handle theAdvFixWire = myFixWire; if (theAdvFixWire.IsNull()) + { return false; + } BRep_Builder B; TopoDS_Shape aInitFace = myFace; @@ -351,7 +369,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) bool fixed = false; TopoDS_Shape S = myFace; if (!Context().IsNull()) + { S = Context()->Apply(myFace); + } TopoDS_Shape emptyCopied = S.EmptyCopied(); TopoDS_Face tmpFace = TopoDS::Face(emptyCopied); tmpFace.Orientation(TopAbs_FORWARD); @@ -383,7 +403,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (theAdvFixWire->NbEdges() == 0) { if (theAdvFixWire->WireData()->NbNonManifoldEdges()) + { B.Add(tmpFace, wire); + } else { fixed = true; @@ -406,7 +428,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (fixed) { if (!Context().IsNull()) + { Context()->Replace(wire, w); + } if (theAdvFixWire->NbEdges() == 0) { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE5); @@ -414,7 +438,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) } } else if (!wire.IsSame(w)) + { aMapReorderedWires.Bind(wire, w); + } wire = w; } @@ -424,12 +450,16 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) theAdvFixWire->FixLackingMode() = usFixLackingMode; theAdvFixWire->FixSelfIntersectionMode() = usFixSelfIntersectionMode; if (!myFwd) + { tmpFace.Orientation(TopAbs_REVERSED); + } if (fixed) { if (!Context().IsNull()) + { Context()->Replace(S, tmpFace); + } isReplaced = true; } if (fixed || isfixReorder) @@ -447,7 +477,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) // Specific case for conic surfaces if (NeedFix(myFixPeriodicDegenerated)) + { this->FixPeriodicDegenerated(); + } // fix missing seam if (NeedFix(myFixMissingSeamMode)) @@ -483,7 +515,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) bool fixed = false; TopoDS_Shape S = myFace; if (!Context().IsNull()) + { S = Context()->Apply(myFace); + } TopoDS_Shape emptyCopied = S.EmptyCopied(); TopoDS_Face tmpFace = TopoDS::Face(emptyCopied); tmpFace.Orientation(TopAbs_FORWARD); @@ -500,7 +534,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (theAdvFixWire->NbEdges() == 0) { if (theAdvFixWire->WireData()->NbNonManifoldEdges()) + { B.Add(tmpFace, wire); + } else { fixed = true; @@ -519,32 +555,44 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (fixed) { if (!Context().IsNull()) + { Context()->Replace(wire, w); + } } else if (!wire.IsSame(w)) + { aMapReorderedWires.Bind(wire, w); + } wire = w; } if (theAdvFixWire->StatusRemovedSegment()) + { NeedCheckSplitWire = true; + } // fix for loop of wire NCollection_Sequence aLoopWires; if (NeedFix(myFixLoopWiresMode) && FixLoopWire(aLoopWires)) { if (aLoopWires.Length() > 1) + { // clang-format off SendWarning ( wire, Message_Msg ( "FixAdvFace.FixLoopWire.MSG0" ) );// Wire was split on several wires +} // clang-format on myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE7); fixed = true; int k = 1; for (; k <= aLoopWires.Length(); k++) + { B.Add(tmpFace, aLoopWires.Value(k)); + } } else + { B.Add(tmpFace, wire); + } } theAdvFixWire->FixSmallMode() = usFixSmallMode; @@ -555,12 +603,17 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (fixed) { if (!myFwd) + { tmpFace.Orientation(TopAbs_REVERSED); - if (!isReplaced && !aInitFace.IsSame(myResult) - && !Context().IsNull()) // gka 06.09.04 BUG 6555 + } + if (!isReplaced && !aInitFace.IsSame(myResult) && !Context().IsNull()) + { // gka 06.09.04 BUG 6555 Context()->Replace(aInitFace, savShape); + } if (!Context().IsNull()) + { Context()->Replace(S, tmpFace); + } myFace = tmpFace; myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); } @@ -572,7 +625,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) // in ShapeFix_Wire::FixSelfIntersection() TopoDS_Shape S = myFace; if (!Context().IsNull()) + { S = Context()->Apply(myFace); + } TopoDS_Shape emptyCopied = S.EmptyCopied(); TopoDS_Face tmpFace = TopoDS::Face(emptyCopied); tmpFace.Orientation(TopAbs_FORWARD); @@ -598,9 +653,13 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (nbw < aWires.Length()) { for (int iw = 1; iw <= aWires.Length(); iw++) + { B.Add(tmpFace, aWires.Value(iw)); + } if (!Context().IsNull()) + { Context()->Replace(S, tmpFace); + } myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE8); myFace = tmpFace; } @@ -608,7 +667,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) // fix intersecting wires if (FixWiresTwoCoincEdges()) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE7); + } if (NeedFix(myFixIntersectingWiresMode)) { if (FixIntersectingWires()) @@ -624,7 +685,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (NeedFix(myFixOrientationMode)) { if (FixOrientation(MapWires)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } } BRepTools::Update(myFace); @@ -641,7 +704,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) if (NeedFix(myFixSplitFaceMode) && NeedSplit && MapWires.Extent() > 1) { if (FixSplitFace(MapWires)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE8); + } } } @@ -660,7 +725,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) { const bool isRemoveFace = NeedFix(myRemoveSmallAreaFaceMode, false); if (FixSmallAreaWire(isRemoveFace)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } } } @@ -688,7 +755,9 @@ bool ShapeFix_Face::Perform(const Message_ProgressRange& theProgress) myResult = Context()->Apply(aInitFace); // gka 06.09.04 } else if (!Status(ShapeExtend_DONE)) + { myResult = aInitFace; + } return Status(ShapeExtend_DONE); } @@ -714,7 +783,9 @@ static void Shift2dWire(const TopoDS_Wire& w, occ::handle C2d; double cf, cl; if (!sae.PCurve(edge, f, C2d, cf, cl, true)) + { continue; + } C2d->Transform(tr2d); if (recompute3d) { @@ -732,7 +803,9 @@ static bool CutInterval(NCollection_Sequence& intervals, const double period) { if (intervals.Length() <= 0) + { return false; + } for (int j = 0; j < 2; j++) { // try twice, align to bottom and to top for (int i = 1; i <= intervals.Length(); i++) @@ -744,7 +817,9 @@ static bool CutInterval(NCollection_Sequence& intervals, period); gp_Pnt2d toAdd(toAddI.X() + shift, toAddI.Y() + shift); if (toAdd.Y() <= interval.X() || toAdd.X() >= interval.Y()) + { continue; + } if (toAdd.X() > interval.X()) { if (toAdd.Y() < interval.Y()) @@ -759,7 +834,9 @@ static bool CutInterval(NCollection_Sequence& intervals, intervals.ChangeValue(i).SetX(toAdd.Y()); } else + { intervals.Remove(i--); + } } } return true; @@ -773,7 +850,9 @@ static double FindBestInterval(NCollection_Sequence& intervals) { gp_Pnt2d interval = intervals(i); if (interval.Y() - interval.X() <= max) + { continue; + } max = interval.Y() - interval.X(); shift = interval.X() + 0.5 * max; } @@ -809,9 +888,13 @@ bool ShapeFix_Face::FixAddNaturalBound() if (wi.Value().ShapeType() == TopAbs_WIRE && (wi.Value().Orientation() == TopAbs_FORWARD || wi.Value().Orientation() == TopAbs_REVERSED)) + { ws.Append(wi.Value()); + } else + { vs.Append(wi.Value()); + } } // deal with the case of an empty face: just create a new face by a standard tool @@ -823,7 +906,9 @@ bool ShapeFix_Face::FixAddNaturalBound() aNewFace.Orientation(myFace.Orientation()); if (!Context().IsNull()) + { Context()->Replace(myFace, aNewFace); + } // taking into account orientation myFace = aNewFace; @@ -873,18 +958,26 @@ bool ShapeFix_Face::FixAddNaturalBound() // PTV 01.11.2002 ACIS907, OCC921 end if (mySurf->IsUClosed()) + { CutInterval(intU, gp_Pnt2d(Umin, Umax), SUL - SUF); + } if (mySurf->IsVClosed()) + { CutInterval(intV, gp_Pnt2d(Vmin, Vmax), SVL - SVF); + } centers.Append(gp_Pnt2d(0.5 * (Umin + Umax), 0.5 * (Vmin + Vmax))); } // find best interval and thus compute shift gp_Pnt2d shift(0., 0.); if (mySurf->IsUClosed()) + { shift.SetX(FindBestInterval(intU)); + } if (mySurf->IsVClosed()) + { shift.SetY(FindBestInterval(intV)); + } // Adjust all other wires to be inside outer one gp_Pnt2d center(shift.X() + 0.5 * (SUL - SUF), shift.Y() + 0.5 * (SVL - SVF)); @@ -893,9 +986,13 @@ bool ShapeFix_Face::FixAddNaturalBound() TopoDS_Wire wire = TopoDS::Wire(ws.Value(i)); gp_Pnt2d sh(0., 0.); if (mySurf->IsUClosed()) + { sh.SetX(ShapeAnalysis::AdjustByPeriod(centers(i).X(), center.X(), SUL - SUF)); + } if (mySurf->IsVClosed()) + { sh.SetY(ShapeAnalysis::AdjustByPeriod(centers(i).Y(), center.Y(), SVL - SVF)); + } Shift2dWire(wire, myFace, sh.XY(), mySurf); } @@ -908,11 +1005,15 @@ bool ShapeFix_Face::FixAddNaturalBound() for (wi.Initialize(ftmp, false); wi.More(); wi.Next()) { if (wi.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wire = TopoDS::Wire(wi.Value()); ws.Append(wire); if (shift.XY().Modulus() < ::Precision::PConfusion()) + { continue; + } Shift2dWire(wire, myFace, shift.XY(), mySurf, true); } @@ -929,7 +1030,9 @@ bool ShapeFix_Face::FixAddNaturalBound() for (int j = 1; j <= sbwd->NbEdges(); j++) { if (!BRep_Tool::Degenerated(sbwd->Edge(j))) + { continue; + } // find corresponding place in boundary ShapeAnalysis_Edge sae; TopoDS_Vertex V = sae.FirstVertex(sbwd->Edge(j)); @@ -937,12 +1040,18 @@ bool ShapeFix_Face::FixAddNaturalBound() for (k = 1; k <= bnd->NbEdges(); k++) { if (!BRep_Tool::Degenerated(bnd->Edge(k))) + { continue; + } if (BRepTools::Compare(V, sae.FirstVertex(bnd->Edge(k)))) + { break; + } } if (k > bnd->NbEdges()) + { continue; + } // and insert hole to that place BRep_Builder B; B.Degenerated(sbwd->Edge(j), false); @@ -966,13 +1075,21 @@ bool ShapeFix_Face::FixAddNaturalBound() TopoDS_Shape S = myFace.EmptyCopied(); S.Orientation(TopAbs_FORWARD); for (i = 1; i <= ws.Length(); i++) + { B.Add(S, ws.Value(i)); + } for (i = 1; i <= vs.Length(); i++) + { B.Add(S, vs.Value(i)); + } if (!myFwd) + { S.Orientation(TopAbs_REVERSED); + } if (!Context().IsNull()) + { Context()->Replace(myFace, S); + } myFace = TopoDS::Face(S); BRepTools::Update(myFace); @@ -1096,17 +1213,23 @@ bool ShapeFix_Face::FixOrientation( } } else + { length = 0; + } if (length > ::Precision::Confusion()) { ws.Append(wi.Value()); allSubShapes.Append(wi.Value()); } else + { VerySmallWires.Append(wi.Value()); + } } if (VerySmallWires.Length() > 0) + { done = true; + } int nb = ws.Length(); int nbAll = allSubShapes.Length(); @@ -1114,7 +1237,9 @@ bool ShapeFix_Face::FixOrientation( // if no wires, just do nothing if (nb <= 0) + { return false; + } bool isAddNaturalBounds = isNeedAddNaturalBound(ws); NCollection_Sequence aSeqReversed; @@ -1195,7 +1320,9 @@ bool ShapeFix_Face::FixOrientation( gac.Load(cw); } else + { gac.Load(cw, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), aBox); } @@ -1211,9 +1338,13 @@ bool ShapeFix_Face::FixOrientation( { double xShift = 0, yShift = 0; if (mySurf->IsUClosed()) + { xShift = ShapeAnalysis::AdjustByPeriod(0.5 * (aXMin + aXMax), uMiddle, uRange); + } if (mySurf->IsVClosed()) + { yShift = ShapeAnalysis::AdjustByPeriod(0.5 * (aYMin + aYMax), vMiddle, vRange); + } aBox.Update(aXMin + xShift, aYMin + yShift, aXMax + xShift, aYMax + yShift); } aWireBoxes.ChangeValue(i) = aBox; @@ -1244,7 +1375,9 @@ bool ShapeFix_Face::FixOrientation( // if(i==j) continue; TopoDS_Shape aSh2 = allSubShapes.Value(j); if (aw == aSh2) + { continue; + } TopAbs_State stb = TopAbs_UNKNOWN; if (aSh2.ShapeType() == TopAbs_VERTEX) { @@ -1274,7 +1407,9 @@ bool ShapeFix_Face::FixOrientation( // int numin =0; Bnd_Box2d aBox2 = aWireBoxes.Value(aWireIt); if (aBox2.IsOut(aBox1)) + { continue; + } TopoDS_Iterator ew(bw); for (; ew.More(); ew.Next()) @@ -1283,7 +1418,9 @@ bool ShapeFix_Face::FixOrientation( double cf, cl; occ::handle cw = BRep_Tool::CurveOnSurface(ed, myFace, cf, cl); if (cw.IsNull()) + { continue; + } gp_Pnt2d unp = cw->Value((cf + cl) / 2.); TopAbs_State ste = clas.Perform(unp, false); if (ste == TopAbs_OUT || ste == TopAbs_IN) @@ -1333,19 +1470,25 @@ bool ShapeFix_Face::FixOrientation( if (!found && uclosed && vclosed) { for (double dX = -1.0; dX <= 1.0 && !found; dX += 2.0) + { for (double dY = -1.0; dY <= 1.0 && !found; dY += 2.0) { unp1.SetCoord(unp.X() + uRange * dX, unp.Y() + vRange * dY); found = (staout != clas.Perform(unp1, false)); } + } } } if (found) { if (stb == TopAbs_IN) + { stb = TopAbs_OUT; + } else + { stb = TopAbs_IN; + } Shift2dWire(bw, myFace, unp1.XY() - unp.XY(), mySurf); } } @@ -1395,9 +1538,13 @@ bool ShapeFix_Face::FixOrientation( else { if (staout == TopAbs_OUT) + { SI.Bind(aw, 2); + } else + { SI.Bind(aw, 3); + } } } } @@ -1425,7 +1572,9 @@ bool ShapeFix_Face::FixOrientation( MapWires.Bind(ws.Value(i), IW); } else + { MapWires.Bind(aw, IW); + } } else { @@ -1447,7 +1596,9 @@ bool ShapeFix_Face::FixOrientation( } if (isAddNaturalBounds && nb == aSeqReversed.Length()) + { done = false; + } // Should I rebuild? if myRebil is set if (done) @@ -1456,7 +1607,9 @@ bool ShapeFix_Face::FixOrientation( S.Orientation(TopAbs_FORWARD); int i = 1; for (; i <= nb; i++) + { B.Add(S, ws.Value(i)); + } if (nb < nbAll) { @@ -1465,14 +1618,20 @@ bool ShapeFix_Face::FixOrientation( const TopoDS_Shape& aS2 = allSubShapes.Value(i); if (aS2.ShapeType() != TopAbs_WIRE || (aS2.Orientation() != TopAbs_FORWARD && aS2.Orientation() != TopAbs_REVERSED)) + { B.Add(S, aS2); + } } } if (!myFwd) + { S.Orientation(TopAbs_REVERSED); + } if (!Context().IsNull()) + { Context()->Replace(myFace, S); + } myFace = TopoDS::Face(S); BRepTools::Update(myFace); } @@ -1502,11 +1661,15 @@ static bool CheckWire(const TopoDS_Wire& wire, { TopoDS_Edge edge = TopoDS::Edge(ed.Value()); if (!BRep_Tool::Degenerated(edge)) + { isDeg = false; + } occ::handle c2d; double f, l; if (!sae.PCurve(edge, face, c2d, f, l, true)) + { return false; + } vec += c2d->Value(l).XY() - c2d->Value(f).XY(); } @@ -1560,7 +1723,9 @@ bool ShapeFix_Face::FixMissingSeam() bool vclosed = mySurf->IsVClosed(); if (!uclosed && !vclosed) + { return false; + } if (!Context().IsNull()) { @@ -1573,7 +1738,9 @@ bool ShapeFix_Face::FixMissingSeam() { occ::handle BSpl = occ::down_cast(mySurf->Surface()); if (!BSpl->IsUPeriodic() && !BSpl->IsVPeriodic()) + { return false; + } } double URange, VRange, SUF, SUL, SVF, SVL; @@ -1585,29 +1752,45 @@ bool ShapeFix_Face::FixMissingSeam() if (::Precision::IsInfinite(SUF) || ::Precision::IsInfinite(SUL)) { if (::Precision::IsInfinite(SUF)) + { SUF = fU1; + } if (::Precision::IsInfinite(SUL)) + { SUL = fU2; + } if (std::abs(SUL - SUF) < ::Precision::PConfusion()) { if (::Precision::IsInfinite(SUF)) + { SUF -= 1000.; + } else + { SUL += 1000.; + } } } if (::Precision::IsInfinite(SVF) || ::Precision::IsInfinite(SVL)) { if (::Precision::IsInfinite(SVF)) + { SVF = fV1; + } if (::Precision::IsInfinite(SVL)) + { SVL = fV2; + } if (std::abs(SVL - SVF) < ::Precision::PConfusion()) { if (::Precision::IsInfinite(SVF)) + { SVF -= 1000.; + } else + { SVL += 1000.; + } } } @@ -1639,7 +1822,9 @@ bool ShapeFix_Face::FixMissingSeam() int isuopen, isvopen; bool isdeg; if (!CheckWire(wire, myFace, URange, VRange, isuopen, isvopen, isdeg)) + { continue; + } if (w1.IsNull()) { w1 = wire; @@ -1701,7 +1886,9 @@ bool ShapeFix_Face::FixMissingSeam() } if (w1.IsNull()) + { return false; + } else if (w2.IsNull()) { // For spheres and BSpline cone-like surfaces(bug 24055): @@ -1735,12 +1922,18 @@ bool ShapeFix_Face::FixMissingSeam() double uCoord; if (mySurf->Value(SUF, SVF).Distance(mySurf->Value(SUF, (SVF + SVL) / 2)) < ::Precision::Confusion()) + { uCoord = SUF; + } else if (mySurf->Value(SUL, SVF).Distance(mySurf->Value(SUL, (SVF + SVL) / 2)) < ::Precision::Confusion()) + { uCoord = SUL; + } else + { return false; + } p.SetCoord(uCoord, (ismodev < 0 ? 0. : VRange)); d.SetCoord(0., -ismodev); @@ -1751,12 +1944,18 @@ bool ShapeFix_Face::FixMissingSeam() double vCoord; if (mySurf->Value(SUF, SVF).Distance(mySurf->Value((SUF + SUL) / 2, SVF)) < ::Precision::Confusion()) + { vCoord = SVF; + } else if (mySurf->Value(SUL, SVL).Distance(mySurf->Value((SUF + SUL) / 2, SVL)) < ::Precision::Confusion()) + { vCoord = SVL; + } else + { return false; + } p.SetCoord((ismodeu < 0 ? 0. : URange), vCoord); double aXCoord = -ismodeu; @@ -1764,7 +1963,9 @@ bool ShapeFix_Face::FixMissingSeam() aRange = URange; } else + { return false; + } occ::handle line = new Geom2d_Line(p, d); TopoDS_Edge edge; @@ -1833,9 +2034,13 @@ bool ShapeFix_Face::FixMissingSeam() { TopoDS_Wire wire = TopoDS::Wire(ws.Value(i)); if (wire.IsSame(w1)) + { wire = w11; + } else if (wire.IsSame(w2)) + { wire = w21; + } else { // other wires (not boundary) are considered as holes; make sure to have them oriented @@ -1844,7 +2049,9 @@ bool ShapeFix_Face::FixMissingSeam() B.Add(curface, wire); curface.Orientation(myFace.Orientation()); if (ShapeAnalysis::IsOuterBound(TopoDS::Face(curface))) + { wire.Reverse(); + } } B.Add(tmpF, wire); } @@ -1865,14 +2072,19 @@ bool ShapeFix_Face::FixMissingSeam() for (TopoDS_Iterator it(tmpF, false); it.More(); it.Next()) { if (it.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire w = TopoDS::Wire(it.Value()); if (w == w11) + { continue; + } double shift; if (w == w21) + { shift = shiftw2; - + } else { S = tmpF.EmptyCopied(); @@ -1893,7 +2105,9 @@ bool ShapeFix_Face::FixMissingSeam() occ::handle C; double a, b; if (!sae.PCurve(E, tmpF, C, a, b)) + { continue; + } C->Translate(V); } } @@ -1904,9 +2118,13 @@ bool ShapeFix_Face::FixMissingSeam() { double other = 0.5 * (m1[coord][0] + m1[coord][1] - period); if (ismodeu) + { vf = other; + } else + { uf = other; + } } } @@ -1922,7 +2140,9 @@ bool ShapeFix_Face::FixMissingSeam() occ::handle c2d; double f, l; if (!sae.PCurve(edge1, tmpF, c2d, f, l, true)) + { return false; + } gp_Pnt2d pos1 = c2d->Value(l).XY(); // the best place is end of edge which is nearest to 0 bool skipU = !uclosed; @@ -1930,7 +2150,9 @@ bool ShapeFix_Face::FixMissingSeam() { pos1.SetX(pos1.X() + ShapeAnalysis::AdjustByPeriod(pos1.X(), SUF, URange)); if (foundU == 2 && std::abs(pos1.X()) > std::abs(uf)) + { skipU = true; + } else if (!foundU || (foundU == 1 && std::abs(pos1.X()) < std::abs(uf))) { foundU = 1; @@ -1942,7 +2164,9 @@ bool ShapeFix_Face::FixMissingSeam() { pos1.SetY(pos1.Y() + ShapeAnalysis::AdjustByPeriod(pos1.Y(), SVF, VRange)); if (foundV == 2 && std::abs(pos1.Y()) > std::abs(vf)) + { skipV = true; + } else if (!foundV || (foundV == 1 && std::abs(pos1.Y()) < std::abs(vf))) { foundV = 1; @@ -1952,16 +2176,22 @@ bool ShapeFix_Face::FixMissingSeam() if (skipU && skipV) { if (i1 <= nb1) + { continue; + } else + { break; + } } // or yet better - if it is end of some edges on both wires for (int i2 = 1; i1 <= nb1 && i2 <= nb2; i2++) { TopoDS_Edge edge2 = wd2->Edge(i2); if (!sae.PCurve(edge2, tmpF, c2d, f, l, true)) + { return false; + } gp_Pnt2d pos2 = c2d->Value(f).XY(); if (uclosed && ismodeu) { @@ -1988,9 +2218,13 @@ bool ShapeFix_Face::FixMissingSeam() // pdn fixing RTS on offsets if (uf < SUF || uf > SUL) + { uf += ShapeAnalysis::AdjustToPeriod(uf, SUF, SUF + URange); + } if (vf < SVF || vf > SVL) + { vf += ShapeAnalysis::AdjustToPeriod(vf, SVF, SVF + VRange); + } // Create fictive grid and call ComposeShell to insert a seam occ::handle RTS = @@ -2004,12 +2238,16 @@ bool ShapeFix_Face::FixMissingSeam() // addition non-manifold topology int j = 1; for (; j <= aSeqNonManif.Length(); j++) + { B.Add(tmpF, aSeqNonManif.Value(j)); + } ShapeFix_ComposeShell CompShell; CompShell.Init(G, L, tmpF, ::Precision::Confusion()); // myPrecision if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } CompShell.ClosedMode() = true; CompShell.SetContext(Context()); CompShell.SetMaxTolerance(MaxTolerance()); @@ -2036,7 +2274,9 @@ bool ShapeFix_Face::FixMissingSeam() ShapeFix_Wire aSfw(TopoDS::Wire(aExpW.Value()), aFace, Precision()); aSfw.SetContext(Context()); if (aSfw.NbEdges()) + { aSfw.FixSmall(true, Precision()); + } if (!aSfw.NbEdges()) { Context()->Remove(aExpW.Value()); @@ -2057,13 +2297,17 @@ bool ShapeFix_Face::FixMissingSeam() { myFace = TopoDS::Face(Context()->Apply(exp.Current())); if (myFace.IsNull()) + { continue; + } if (nbFaces > 1) { FixSmallAreaWire(true); TopoDS_Shape aShape = Context()->Apply(myFace); if (aShape.IsNull()) + { continue; + } myFace = TopoDS::Face(aShape); } BRepTools::Update(myFace); //: p4 @@ -2119,18 +2363,24 @@ bool ShapeFix_Face::FixSmallAreaWire(const bool theIsRemoveSmallFace) } if (nbRemoved <= 0) + { return false; + } if (nbWires <= 0) { if (theIsRemoveSmallFace && !Context().IsNull()) + { Context()->Remove(myFace); + } return false; } aFace.Orientation(myFace.Orientation()); if (!Context().IsNull()) + { Context()->Replace(myFace, aFace); + } myFace = aFace; return true; @@ -2162,9 +2412,13 @@ static void FindNext( } if (!isFind && !aMapSmallEdges.Contains(ainitEdge)) + { return; + } if (isFind && aMapVertices.Contains(anextVert)) + { return; + } const NCollection_List& aledges = aMapVertexEdges.Find(anextVert); NCollection_List::Iterator liter(aledges); @@ -2177,7 +2431,9 @@ static void FindNext( anextEdge = liter.Value(); aWireData->Add(anextEdge); if (aMapSeemEdges.Contains(anextEdge)) + { aWireData->Add(anextEdge.Reversed()); + } isFind = true; aMapEdges.Add(anextEdge); FindNext(anextVert, @@ -2190,7 +2446,6 @@ static void FindNext( aWireData); } } - return; } static bool isClosed2D(const TopoDS_Face& aFace, const TopoDS_Wire& aWire) @@ -2224,7 +2479,9 @@ bool ShapeFix_Face::FixLoopWire(NCollection_Sequence& aResWires) aMapVertexEdges, aMapSmallEdges, aMapSeemEdges)) + { return false; + } NCollection_Map aMapEdges; NCollection_Sequence aSeqWires; @@ -2240,12 +2497,16 @@ bool ShapeFix_Face::FixLoopWire(NCollection_Sequence& aResWires) { TopoDS_Edge Edge = TopoDS::Edge(liter.Value()); if (aMapEdges.Contains(Edge)) + { continue; + } occ::handle aWireData = new ShapeExtend_WireData; aWireData->Add(Edge); if (aMapSeemEdges.Contains(Edge)) + { aWireData->Add(Edge.Reversed()); + } aMapEdges.Add(Edge); FindNext(aVert, Edge, @@ -2256,7 +2517,9 @@ bool ShapeFix_Face::FixLoopWire(NCollection_Sequence& aResWires) aMapEdges, aWireData); if (aWireData->NbEdges() == 1 && aMapSmallEdges.Contains(aWireData->Edge(1))) + { continue; + } TopoDS_Vertex aV1, aV2; TopoDS_Wire aWire = aWireData->Wire(); TopExp::Vertices(aWire, aV1, aV2); @@ -2271,7 +2534,9 @@ bool ShapeFix_Face::FixLoopWire(NCollection_Sequence& aResWires) aResWires.Append(awire2); } else + { aSeqWires.Append(aWireData->Wire()); + } } } @@ -2307,12 +2572,16 @@ bool ShapeFix_Face::FixLoopWire(NCollection_Sequence& aResWires) } } if (j <= aSeqWires.Length()) + { aSeqWires.Remove(i--); + } } if (aSeqWires.Length() < 3) { for (i = 1; i <= aSeqWires.Length(); i++) + { aResWires.Append(aSeqWires.Value(i)); + } } else { @@ -2385,7 +2654,9 @@ bool ShapeFix_Face::SplitEdge( wd->Add(newE1); wd->Add(newE2); if (!Context().IsNull()) + { Context()->Replace(edge, wd->Wire()); + } for (TopExp_Explorer exp(wd->Wire(), TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); @@ -2395,9 +2666,13 @@ bool ShapeFix_Face::SplitEdge( // change sewd and boxes sewd->Set(newE1, num); if (num == sewd->NbEdges()) + { sewd->Add(newE2); + } else + { sewd->Add(newE2, num + 1); + } boxes.UnBind(edge); TopLoc_Location L; @@ -2417,7 +2692,9 @@ bool ShapeFix_Face::SplitEdge( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE1, box); } @@ -2433,7 +2710,9 @@ bool ShapeFix_Face::SplitEdge( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE2, box); } @@ -2463,7 +2742,9 @@ bool ShapeFix_Face::SplitEdge( wd->Add(newE1); wd->Add(newE2); if (!Context().IsNull()) + { Context()->Replace(edge, wd->Wire()); + } for (TopExp_Explorer exp(wd->Wire(), TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); @@ -2473,9 +2754,13 @@ bool ShapeFix_Face::SplitEdge( // change sewd and boxes sewd->Set(newE1, num); if (num == sewd->NbEdges()) + { sewd->Add(newE2); + } else + { sewd->Add(newE2, num + 1); + } boxes.UnBind(edge); TopLoc_Location L; @@ -2495,7 +2780,9 @@ bool ShapeFix_Face::SplitEdge( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE1, box); } @@ -2511,7 +2798,9 @@ bool ShapeFix_Face::SplitEdge( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE2, box); } @@ -2556,7 +2845,9 @@ bool ShapeFix_Face::FixWiresTwoCoincEdges() nbWires++; } if (nbWires < 2) + { return false; + } bool isFixed = false; for (TopoDS_Iterator wi(myFace, false); wi.More(); wi.Next()) { @@ -2580,7 +2871,9 @@ bool ShapeFix_Face::FixWiresTwoCoincEdges() B.Add(face, wire); } else + { isFixed = true; + } } else { @@ -2591,7 +2884,9 @@ bool ShapeFix_Face::FixWiresTwoCoincEdges() { face.Orientation(ori); if (!Context().IsNull()) + { Context()->Replace(myFace, face); + } myFace = face; } @@ -2608,14 +2903,18 @@ bool ShapeFix_Face::FixSplitFace( NCollection_Sequence faces; TopoDS_Shape S = myFace; if (!Context().IsNull()) + { S = Context()->Apply(myFace); + } int NbWires = 0, NbWiresNew = 0, NbEdges; for (TopoDS_Iterator iter(S, false); iter.More(); iter.Next()) { const TopoDS_Shape& aShape = iter.Value(); if (aShape.ShapeType() != TopAbs_WIRE || (aShape.Orientation() != TopAbs_FORWARD && aShape.Orientation() != TopAbs_REVERSED)) + { continue; + } TopoDS_Wire wire = TopoDS::Wire(aShape); NbWires++; if (MapWires.IsBound(wire)) @@ -2655,26 +2954,36 @@ bool ShapeFix_Face::FixSplitFace( BRepTopAdaptor_FClass2d clas(aFace, ::Precision::PConfusion()); TopAbs_State staout = clas.PerformInfinitePoint(); if (staout == TopAbs_IN) + { B.Add(tmpFace, liter.Value()); + } else + { B.Add(tmpFace, liter.Value().Reversed()); + } NbWiresNew++; } if (!myFwd) + { tmpFace.Orientation(TopAbs_REVERSED); + } faces.Append(tmpFace); } } if (NbWires != NbWiresNew) + { return false; + } if (faces.Length() > 1) { TopoDS_Compound Comp; B.MakeCompound(Comp); for (int i = 1; i <= faces.Length(); i++) + { B.Add(Comp, faces(i)); + } myResult = Comp; if (!Context().IsNull()) @@ -2709,7 +3018,9 @@ static bool IsPeriodicConicalLoop(const occ::handle& theSur bool& isUDecrease) { if (theSurf.IsNull()) + { return false; + } ShapeAnalysis_Edge aSAE; TopLoc_Location aLoc; @@ -2731,7 +3042,9 @@ static bool IsPeriodicConicalLoop(const occ::handle& theSur aSAE.PCurve(aCurrentEdge, theSurf, aLoc, aC2d, aPFirst, aPLast, true); if (aC2d.IsNull()) + { return false; + } gp_Pnt2d aUVFirst = aC2d->Value(aPFirst), aUVLast = aC2d->Value(aPLast); @@ -2742,13 +3055,21 @@ static bool IsPeriodicConicalLoop(const occ::handle& theSur double aCurMaxV = std::max(aVFirst, aVLast), aCurMinV = std::min(aVFirst, aVLast); if (aCurMinU < aMinU) + { aMinU = aCurMinU; + } if (aCurMaxU > aMaxU) + { aMaxU = aCurMaxU; + } if (aCurMinV < aMinV) + { aMinV = aCurMinV; + } if (aCurMaxV > aMaxV) + { aMaxV = aCurMaxV; + } double aDeltaU = aULast - aUFirst; @@ -2793,7 +3114,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() const TopoDS_Shape& aSubSh = aWireIt.Value(); if (aSubSh.ShapeType() != TopAbs_WIRE || (aSubSh.Orientation() != TopAbs_FORWARD && aSubSh.Orientation() != TopAbs_REVERSED)) + { continue; + } aWireSeq.Append(aWireIt.Value()); } @@ -2805,7 +3128,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() // Only single wires on conical surfaces are checked if (aNbWires != 1 || aSurface.IsNull() || aSurface->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface)) + { return false; + } // Get the single wire TopoDS_Wire aSoleWire = TopoDS::Wire(aWireSeq.Value(1)); @@ -2825,7 +3150,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() isUDecrease); if (!isConicLoop) + { return false; + } /* =============== * Retrieve apex @@ -2840,7 +3167,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() double aSemiAngle = aConeSurf->SemiAngle(); if (fabs(aSemiAngle) <= Precision::Confusion()) + { return false; // Bad surface + } // Find the V parameter of the apex double aConeBaseH = aConeBaseR / std::sin(aSemiAngle); @@ -2861,7 +3190,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() // line in 2D is going to be consistent if (fabs(anApexV - aMinLoopV) <= Precision() || fabs(anApexV - aMaxLoopV) <= Precision() || (anApexV < aMaxLoopV && anApexV > aMinLoopV)) + { return false; + } occ::handle anApexCurve2d; @@ -2870,7 +3201,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() { anApexCurve2d = new Geom2d_Line(gp_Pnt2d(aMinLoopU, anApexV), gp_Dir2d(gp_Dir2d::D::X)); if (!isUDecrease) + { aSoleWire.Reverse(); + } } // Apex curve above the wire @@ -2878,7 +3211,9 @@ bool ShapeFix_Face::FixPeriodicDegenerated() { anApexCurve2d = new Geom2d_Line(gp_Pnt2d(aMaxLoopU, anApexV), gp_Dir2d(gp_Dir2d::D::NX)); if (isUDecrease) + { aSoleWire.Reverse(); + } } // Create degenerated edge & wire for apex diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FaceConnect.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FaceConnect.cxx index d2d5230a0f..e56f4c9eae 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FaceConnect.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FaceConnect.cxx @@ -66,8 +66,12 @@ bool ShapeFix_FaceConnect::Add(const TopoDS_Face& aFirst, const TopoDS_Face& aSe // Append second face to the first list NCollection_List::Iterator theIter; for (theIter.Initialize(theFirstList); theIter.More(); theIter.Next()) + { if (theIter.Value().IsSame(aSecond)) + { return true; + } + } theFirstList.Append(aSecond); } else @@ -131,9 +135,13 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, { theEdge = expe.Current(); if (theFreeEdges.IsBound(theEdge)) + { theFreeEdges.UnBind(theEdge); + } else + { theFreeEdges.Bind(theEdge, theFace); + } } } @@ -263,8 +271,12 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, for (theProcCnxListIter.Initialize(theProcCnxList); theProcCnxListIter.More() && !skip_pair; theProcCnxListIter.Next()) + { if (theFirstFace.IsSame(theProcCnxListIter.Value())) + { skip_pair = true; + } + } } if (!skip_pair) { @@ -278,7 +290,9 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, #endif } else + { theNumOfFacesToSew = 2; + } NCollection_DataMap theSewerWires; @@ -328,8 +342,12 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, } } if (sewing_ok) + { if (theSewer.SewedShape().IsNull()) + { sewing_ok = false; + } + } if (sewing_ok) { @@ -368,13 +386,17 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, theResultEdges.UnBind(theAuxE); } else + { theResultEdges.Bind(theAuxE, theOrigE); + } } // Remove modified free edge from the list theOldFreeList.Remove(theResultsIter); } else + { theResultsIter.Next(); + } } } } @@ -463,9 +485,13 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, { // Select list of free or shared edges if (i == 1) + { theResultsIter.Initialize(myResFreeEdges(theOldE)); + } else + { theResultsIter.Initialize(myResSharEdges(theOldE)); + } // Iterate on new edges for (; theResultsIter.More(); theResultsIter.Next()) { @@ -517,13 +543,17 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, NCollection_List::Iterator theIter1; bool found = false; for (theIter1.Initialize(theList1); theIter1.More(); theIter1.Next()) + { if (theIter1.Value().IsSame(theNewV1)) { found = true; break; } + } if (!found) + { theList1.Append(theNewV1); + } } else { @@ -540,13 +570,17 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, NCollection_List::Iterator theIter2; bool found = false; for (theIter2.Initialize(theList2); theIter2.More(); theIter2.Next()) + { if (theIter2.Value().IsSame(theNewV2)) { found = true; break; } + } if (!found) + { theList2.Append(theNewV2); + } } else { @@ -615,7 +649,9 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, for (TopoDS_Iterator itw(newface); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire theWire = TopoDS::Wire(itw.Value()); sewd = new ShapeExtend_WireData(theWire); @@ -626,7 +662,9 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, // smh#8 TopoDS_Shape tmpFace = EmpFace.Oriented(TopAbs_FORWARD); if (!SAE.PCurve(sewd->Edge(i), TopoDS::Face(tmpFace), c2d, f, l)) + { continue; + } SAWO.Add(c2d->Value(f).XY(), c2d->Value(l).XY()); } SAWO.Perform(); @@ -652,7 +690,9 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, MapWires; MapWires.Clear(); if (SFF->FixOrientation(MapWires)) + { EmpFace = SFF->Face(); + } theBuilder.Add(theShell, EmpFace); } theShell.Closed(BRep_Tool::IsClosed(theShell)); @@ -724,19 +764,31 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, thePosition = BRep_Tool::Pnt(TopoDS::Vertex(theN2Iter.Value())); double val = thePosition.X(); if (val < theLBound.X()) + { theLBound.SetX(val); + } else if (val > theRBound.X()) + { theRBound.SetX(val); + } val = thePosition.Y(); if (val < theLBound.Y()) + { theLBound.SetY(val); + } else if (val > theRBound.Y()) + { theRBound.SetY(val); + } val = thePosition.Z(); if (val < theLBound.Z()) + { theLBound.SetZ(val); + } else if (val > theRBound.Z()) + { theRBound.SetZ(val); + } } thePosition = gp_Pnt((theLBound.XYZ() + theRBound.XYZ()) / 2.); double theTolerance = 0., curtoler; @@ -747,12 +799,16 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, curtoler = thePosition.Distance(BRep_Tool::Pnt(theOldVert)) + BRep_Tool::Tolerance(theOldVert); if (curtoler > theTolerance) + { theTolerance = curtoler; + } } curtoler = thePosition.Distance(BRep_Tool::Pnt(theNewVert)) + BRep_Tool::Tolerance(theNewVert); if (curtoler > theTolerance) + { theTolerance = curtoler; + } theBuilder.UpdateVertex(theNewVert, thePosition, theTolerance); } @@ -762,8 +818,10 @@ TopoDS_Shell ShapeFix_FaceConnect::Build(const TopoDS_Shell& shell, theNVIter(theOldVertices); theNVIter.More(); theNVIter.Next()) + { theReShape->Replace(theNVIter.Key().Oriented(TopAbs_FORWARD), theNVIter.Value().Oriented(TopAbs_FORWARD)); + } // smh#8 TopoDS_Shape tmpshape = theReShape->Apply(result); result = TopoDS::Shell(tmpshape); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallFace.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallFace.cxx index e982c64d13..de8680fbc6 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallFace.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallFace.cxx @@ -64,7 +64,9 @@ void ShapeFix_FixSmallFace::Init(const TopoDS_Shape& S) { myShape = S; if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } myResult = myShape; Context()->Apply(myShape); } @@ -91,7 +93,9 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixSpotFace() TopoDS_Shape tmpFace = Context()->Apply(itf.Current()); TopoDS_Face F = TopoDS::Face(tmpFace); if (F.IsNull()) + { continue; + } if (myAnalyzer.CheckSpotFace(F, Precision())) { ReplaceVerticesInCaseOfSpot(F, Precision()); @@ -105,7 +109,9 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixSpotFace() if (done) { if (myShape.IsNull()) + { return myShape; + } /*ShapeFix_Wire sfw; sfw.SetContext(Context()); sfw.SetPrecision(Precision::Confusion()); @@ -147,7 +153,9 @@ bool ShapeFix_FixSmallFace::ReplaceVerticesInCaseOfSpot(TopoDS_Face& F, const do for (TopoDS_Iterator itw(F, false); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire w1 = TopoDS::Wire(itw.Value()); if (!w1.IsNull()) { @@ -156,14 +164,18 @@ bool ShapeFix_FixSmallFace::ReplaceVerticesInCaseOfSpot(TopoDS_Face& F, const do } } if (!isWir) + { return true; + } // Accumulating positions and maximal vertex tolerance for (TopExp_Explorer iter_vertex(F, TopAbs_VERTEX); iter_vertex.More(); iter_vertex.Next()) { TopoDS_Vertex V = TopoDS::Vertex(iter_vertex.Current()); thePoint = BRep_Tool::Pnt(V); if (theMaxTol <= (BRep_Tool::Tolerance(V))) + { theMaxTol = BRep_Tool::Tolerance(V); + } thePositions.Append(thePoint.XYZ()); } // Calculate common vertex position @@ -171,9 +183,13 @@ bool ShapeFix_FixSmallFace::ReplaceVerticesInCaseOfSpot(TopoDS_Face& F, const do int theNbPos = thePositions.Length(); int i; // svv Jan11 2000 : porting on DEC for (i = 1; i <= theNbPos; i++) + { thePosition += thePositions.Value(i); + } if (theNbPos > 1) + { thePosition /= theNbPos; + } // Calculate maximal deviation theMaxDev = 0.; @@ -181,7 +197,9 @@ bool ShapeFix_FixSmallFace::ReplaceVerticesInCaseOfSpot(TopoDS_Face& F, const do { double theDeviation = (thePosition - thePositions.Value(i)).Modulus(); if (theDeviation > theMaxDev) + { theMaxDev = theDeviation; + } } theMaxDev *= 1.00001; @@ -228,7 +246,9 @@ bool ShapeFix_FixSmallFace::RemoveFacesInCaseOfSpot(const TopoDS_Face& F) const TopoDS_Shape ShapeFix_FixSmallFace::FixStripFace(const bool wasdone) { if (myShape.IsNull()) + { return myShape; + } TopAbs_ShapeEnum st = myShape.ShapeType(); // BRep_Builder theBuilder; bool done = wasdone; @@ -242,13 +262,17 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixStripFace(const bool wasdone) TopoDS_Shape tmpFace = Context()->Apply(F); F = TopoDS::Face(tmpFace); if (F.IsNull()) + { continue; + } // double dmax = 1; TopoDS_Edge E1, E2; if (myAnalyzer.CheckStripFace(F, E1, E2, Precision())) { if (ReplaceInCaseOfStrip(F, E1, E2, Precision())) + { RemoveFacesInCaseOfStrip(F); + } myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); done = true; } @@ -272,7 +296,9 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixStripFace(const bool wasdone) if (done) { if (myShape.IsNull()) + { return myShape; + } TopoDS_Shape theResult; myShape = FixShape(); // myShape = Context()->Apply(myShape); @@ -289,7 +315,9 @@ bool ShapeFix_FixSmallFace::ReplaceInCaseOfStrip(TopoDS_Face& F, const double tol) const { if (E1.IsNull() || E2.IsNull()) + { return false; + } TopoDS_Edge theSharedEdge; TopoDS_Face F1, F2; // smh#8 @@ -301,22 +329,32 @@ bool ShapeFix_FixSmallFace::ReplaceInCaseOfStrip(TopoDS_Face& F, TopoDS_Shape tmpShape = Context()->Apply(expf.Current()); TopoDS_Face tempF = TopoDS::Face(tmpShape); if (tempF.IsNull() || tempF.IsSame(F)) + { continue; + } for (TopExp_Explorer expe(tempF, TopAbs_EDGE); expe.More(); expe.Next()) { TopoDS_Edge tempE = TopoDS::Edge(expe.Current()); if (tempE.IsSame(E1)) + { F1 = tempF; + } if (tempE.IsSame(E2)) + { F2 = tempF; + } if (!F1.IsNull()) + { break; // && !F2.IsNull()) break; + } } } // Compute shared edge for this face if (F1.IsNull() && F2.IsNull()) + { return true; + } TopoDS_Edge E1tmp = E1; TopoDS_Edge E2tmp = E2; if (F1.IsNull()) @@ -328,22 +366,32 @@ bool ShapeFix_FixSmallFace::ReplaceInCaseOfStrip(TopoDS_Face& F, theSharedEdge = ComputeSharedEdgeForStripFace(F, E1tmp, E2tmp, F1, tol); // Replace two long edges by new one if (theSharedEdge.IsNull()) + { return false; + } if (E1.Orientation() == TopAbs_REVERSED) { Context()->Replace(E1tmp, theSharedEdge.Oriented(TopAbs_REVERSED)); if (F.Orientation() == F1.Orientation()) + { Context()->Replace(E2tmp, theSharedEdge); + } else + { Context()->Replace(E2tmp, theSharedEdge.Oriented(TopAbs_REVERSED)); + } } else { Context()->Replace(E1tmp, theSharedEdge); if (F.Orientation() == F1.Orientation()) + { Context()->Replace(E2tmp, theSharedEdge.Oriented(TopAbs_REVERSED)); + } else + { Context()->Replace(E2tmp, theSharedEdge); + } } // Remove short edges @@ -351,7 +399,9 @@ bool ShapeFix_FixSmallFace::ReplaceInCaseOfStrip(TopoDS_Face& F, { TopoDS_Edge shortedge = TopoDS::Edge(exp_e.Current()); if (!shortedge.IsSame(E1tmp) && !shortedge.IsSame(E2tmp)) + { Context()->Remove(shortedge); + } } return true; @@ -392,10 +442,11 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa if ((dev <= BRep_Tool::Tolerance(V1)) || (dev <= BRep_Tool::Tolerance(V3)) || (dev <= tol)) { if (V1.IsSame(V3)) + { // #ifdef AIX CKY : applies to all platforms theFirstVer = V1; - // theFirstVer = TopoDS::Vertex(V1); - + // theFirstVer = TopoDS::Vertex(V1); + } else { dev = (dev / 2) * 1.0001; @@ -405,16 +456,26 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa // already recorded in map else //take recorded vertex // if(theRepVert->Status(V3, temp) != 0) theFirstVer = TopoDS::Vertex (temp); if (V1.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V1, theFirstVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V1, theFirstVer.Oriented(TopAbs_REVERSED)); + } if (V3.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V3, theFirstVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V3, theFirstVer.Oriented(TopAbs_REVERSED)); + } } if (V1.IsSame(V2) || V3.IsSame(V4)) + { theSecondVer = theFirstVer; + } else { if (!V2.IsSame(V4)) @@ -431,18 +492,28 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa // if(theRepVert->Status(V4, temp) != 0) theSecondVer = TopoDS::Vertex (temp); } else + { theSecondVer = V2; + } } if (!V2.IsSame(theSecondVer)) { if (V2.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V2, theSecondVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V2, theSecondVer.Oriented(TopAbs_REVERSED)); + } if (V4.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V4, theSecondVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V4, theSecondVer.Oriented(TopAbs_REVERSED)); + } } } else @@ -452,10 +523,11 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa if ((dev <= BRep_Tool::Tolerance(V1)) || (dev <= BRep_Tool::Tolerance(V4)) || (dev <= tol)) { if (V1.IsSame(V4)) + { // #ifdef AIX CKY : applies to all platforms theFirstVer = V1; - // theFirstVer = TopoDS::Vertex(V1); - + // theFirstVer = TopoDS::Vertex(V1); + } else { dev = (dev / 2) * 1.0001; @@ -466,16 +538,26 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa // else // if(theRepVert->Status(V4, temp) != 0) theFirstVer = TopoDS::Vertex (temp); if (V1.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V1, theFirstVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V1, theFirstVer.Oriented(TopAbs_REVERSED)); + } if (V4.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V4, theFirstVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V4, theFirstVer.Oriented(TopAbs_REVERSED)); + } } if (V1.IsSame(V2) || V3.IsSame(V4)) + { theSecondVer = theFirstVer; + } else { @@ -488,7 +570,9 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa theBuilder.UpdateVertex(theSecondVer, gp_Pnt(thePosition), dev); } else + { theSecondVer = V2; + } } // if(theRepVert->Status(V2, temp) != 0) theSecondVer = TopoDS::Vertex (temp); //If this // vertex already recorded in map @@ -497,13 +581,21 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa if (!V2.IsSame(theSecondVer)) { if (V2.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V2, theSecondVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V2, theSecondVer.Oriented(TopAbs_REVERSED)); + } if (V3.Orientation() == TopAbs_FORWARD) + { Context()->Replace(V3, theSecondVer.Oriented(TopAbs_FORWARD)); + } else + { Context()->Replace(V3, theSecondVer.Oriented(TopAbs_REVERSED)); + } } } else @@ -515,7 +607,9 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa } } if (theFirstVer.IsNull() || theSecondVer.IsNull()) + { return theNewEdge; + } // Create new edge theBuilder.MakeEdge(theNewEdge); double f, l, fp1, lp1 /*, fp2, lp2*/; @@ -527,7 +621,9 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa { the2dcurve1 = BRep_Tool::CurveOnSurface(E1, F1, fp1, lp1); if (!the2dcurve1.IsNull() && fp1 != f && lp1 != l) + { GeomLib::SameRange(Precision::Confusion(), the2dcurve1, fp1, lp1, f, l, thenew1); + } } /* if (!F2.IsNull()) @@ -539,9 +635,13 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa double maxdev; if ((BRep_Tool::Tolerance(theFirstVer)) <= (BRep_Tool::Tolerance(theSecondVer))) + { maxdev = (BRep_Tool::Tolerance(theSecondVer)); + } else + { maxdev = (BRep_Tool::Tolerance(theFirstVer)); + } theBuilder.UpdateVertex(theFirstVer, maxdev); theBuilder.UpdateVertex(theSecondVer, maxdev); // bool IsFree = true; @@ -575,7 +675,9 @@ TopoDS_Edge ShapeFix_FixSmallFace::ComputeSharedEdgeForStripFace(const TopoDS_Fa TopoDS_Shape ShapeFix_FixSmallFace::FixSplitFace(const TopoDS_Shape& /*S*/) { if (myShape.IsNull()) + { return myShape; + } TopAbs_ShapeEnum st = myShape.ShapeType(); bool done = false; TopoDS_Compound theSplittedFaces; @@ -596,7 +698,9 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixSplitFace(const TopoDS_Shape& /*S*/) } } if (done) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } myShape = Context()->Apply(myShape); myResult = myShape; return myShape; @@ -618,13 +722,17 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl TopoDS_Wire tempwire; // Take information about splitting vertices if (theAllVert.IsNull()) + { return false; + } // int i; TopoDS_Vertex V; TopExp_Explorer itc(theAllVert, TopAbs_VERTEX); V = TopoDS::Vertex(itc.Current()); if (V.IsNull()) + { return false; + } gp_Pnt proj; gp_Pnt vp = BRep_Tool::Pnt(V); TopoDS_Vertex theNewVertex; @@ -642,14 +750,20 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl double cf, cl; occ::handle C3D = BRep_Tool::Curve(E, cf, cl); if (C3D.IsNull()) + { continue; + } if (V.IsSame(V1) || V.IsSame(V2)) + { continue; + } double vt = BRep_Tool::Tolerance(V); double param; double dist = SAC.Project(C3D, vp, vt * 10., proj, param, cf, cl); if (dist == 0) + { continue; // Projection on same curve but on other edge ? + } if (dist <= vt) { theBuilder.MakeVertex(theNewVertex); @@ -694,7 +808,9 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl } } if (theNewVertex.IsNull()) + { return false; + } // Create split edge TopoDS_Edge theSplitEdge; gp_Lin lin(vp, gp_Dir(gp_Vec(vp, proj))); @@ -716,7 +832,9 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl wireonface = TopoDS::Wire(itw.Current()); itw.Next(); if (itw.More()) + { return false; // if face contains more than one wire + } occ::handle sfw = new ShapeFix_Wire; sfw->Init(wireonface, F, Precision::Confusion()); sfw->FixReorder(); @@ -746,9 +864,13 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl TopoDS_Edge ce = TopoDS::Edge(itere.Current()); TopoDS_Vertex thecontrol; if (ce.Orientation() == TopAbs_FORWARD) + { thecontrol = TopExp::LastVertex(ce); + } else + { thecontrol = TopExp::FirstVertex(ce); + } theBuilder.Add(w1, ce); if (thecontrol.IsSame(V)) { @@ -766,7 +888,9 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl } } if (w1.IsNull() || w2.IsNull()) + { return false; + } // Create two new faces and replace old one TopoDS_Face F1; TopoDS_Face F2; @@ -780,9 +904,13 @@ bool ShapeFix_FixSmallFace::SplitOneFace(TopoDS_Face& F, TopoDS_Compound& theSpl theBuilder.Add(tf, F2); // Call recursive spliteoneface() for each face if (!SplitOneFace(F1, theSplittedFaces)) + { theBuilder.Add(theSplittedFaces, F1); + } if (!SplitOneFace(F2, theSplittedFaces)) + { theBuilder.Add(theSplittedFaces, F2); + } } return true; } @@ -822,7 +950,9 @@ TopoDS_Shape ShapeFix_FixSmallFace::FixShape() { TopoDS_Shape FixSh; if (myShape.IsNull()) + { return FixSh; + } /*ShapeFix_Shape sfs; sfs.SetContext(Context()); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallSolid.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallSolid.cxx index 166d750013..67dc2909ca 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallSolid.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FixSmallSolid.cxx @@ -72,7 +72,9 @@ void ShapeFix_FixSmallSolid::SetWidthFactorThreshold(const double theThreshold) static bool IsValidInput(const TopoDS_Shape& theShape) { if (theShape.IsNull()) + { return false; + } switch (theShape.ShapeType()) { @@ -94,7 +96,9 @@ TopoDS_Shape ShapeFix_FixSmallSolid::Remove(const TopoDS_Shape& { // Check if at least one smallness criterion is set and the shape is valid if (!IsThresholdsSet() || !IsValidInput(theShape)) + { return theShape; + } // Find and remove all small solids TopExp_Explorer aSolidIter(theShape, TopAbs_SOLID); @@ -149,7 +153,9 @@ static void AddToMap( theMap.Bind(theKey, aList); } else + { aListPtr->Append(theItem); + } } //================================================================================================= @@ -162,13 +168,19 @@ static void AddToMap( NCollection_List& theItems) { if (theItems.IsEmpty()) + { return; + } NCollection_List* aListPtr = theMap.ChangeSeek(theKey); if (aListPtr == nullptr) + { theMap.Bind(theKey, theItems); + } else + { aListPtr->Append(theItems); + } } //================================================================================================= @@ -184,17 +196,23 @@ static void MapFacesToShells( { const TopoDS_Shape& aShell = aShellIter.Value(); if (aShell.ShapeType() != TopAbs_SHELL) + { continue; + } TopoDS_Iterator aFaceIter(aShell); for (; aFaceIter.More(); aFaceIter.Next()) { const TopoDS_Shape& aFace = aFaceIter.Value(); if (aFace.ShapeType() != TopAbs_FACE) + { continue; + } if (!theMap.Bind(aFace, aShell)) + { theMap.UnBind(aFace); + } } } } @@ -222,7 +240,9 @@ static bool FindMostSharedShell( { const TopoDS_Shape& aSolidShell = aShellIter.Value(); if (aSolidShell.ShapeType() != TopAbs_SHELL) + { continue; + } theOtherSolidShells.Append(aSolidShell); @@ -231,21 +251,29 @@ static bool FindMostSharedShell( { const TopoDS_Shape& aFace = aFaceIter.Value(); if (aFace.ShapeType() != TopAbs_FACE) + { continue; + } // find an outer shell that shares the current face const TopoDS_Shape* anOuterShellPtr = theMapFacesToOuterShells.Seek(aFace); if (anOuterShellPtr == nullptr) + { continue; + } const TopoDS_Shape& anOuterShell = *anOuterShellPtr; // add the face area to the sum shared area for the outer shell double anArea = ShapeArea(aFace); double* aSharedAreaPtr = aSharedAreas.ChangeSeek(anOuterShell); if (aSharedAreaPtr == nullptr) + { aSharedAreas.Bind(anOuterShell, anArea); + } else + { anArea = (*aSharedAreaPtr) += anArea; + } // if this outer shell currently has maximum shared area, // remember it and the current solid's shell @@ -260,7 +288,9 @@ static bool FindMostSharedShell( // return nothing if no adjanced outer shells were found if (aMostSharedSolidShellPtr == nullptr) + { return false; + } // compose return values theMostSharedOuterShell = *aMostSharedOuterShellPtr; @@ -269,7 +299,9 @@ static bool FindMostSharedShell( // remove the most shared solid's shell from the returned list of its other shells NCollection_List::Iterator anOtherShellIter(theOtherSolidShells); while (!anOtherShellIter.Value().IsSame(theMostSharedSolidShell)) + { anOtherShellIter.Next(); + } theOtherSolidShells.Remove(anOtherShellIter); return true; @@ -320,16 +352,24 @@ static TopoDS_Shape MergeShells( if (anOuterShellPtr != nullptr) { if (anOuterShellPtr->IsSame(theBaseShell)) + { aRemoveFaces.Add(aFace); // face shared with the base shell + } else + { aBuilder.Add(aNewShell, aFace); // face shared with another outer shell + } } else { if (aNewFreeFaces.Contains(aFace)) + { aNewFreeFaces.Remove(aFace); // face shared with another merged shell + } else + { aNewFreeFaces.Add(aFace); // face not shared + } } } } @@ -351,12 +391,16 @@ static TopoDS_Shape MergeShells( { const TopoDS_Shape& aFace = aBaseFaceIter.Value(); if (!aRemoveFaces.Contains(aFace)) + { aBuilder.Add(aNewShell, aFace); + } } // If there are no elements in the new shell, return null shape if (aNewShell.NbChildren() == 0) + { return TopoDS_Shape(); + } return aNewShell; } @@ -374,12 +418,16 @@ static TopoDS_Compound AddShells(const TopoDS_Shape& theBaseShell, // Add the base shell to the compound if (!theBaseShell.IsNull()) + { aBuilder.Add(aCompound, theBaseShell); + } // Add other shells to the compound NCollection_List::Iterator aShellIter(theShellsToAdd); for (; aShellIter.More(); aShellIter.Next()) + { aBuilder.Add(aCompound, aShellIter.Value()); + } theShellsToAdd.Clear(); @@ -391,7 +439,9 @@ TopoDS_Shape ShapeFix_FixSmallSolid::Merge(const TopoDS_Shape& { // Check if at least one smallness criterion is set and the shape is valid if (!IsThresholdsSet() || !IsValidInput(theShape)) + { return theShape; + } // Find all small solids and put them in a list; // Build a map of faces belonging to non-small solids @@ -404,9 +454,13 @@ TopoDS_Shape ShapeFix_FixSmallSolid::Merge(const TopoDS_Shape& { const TopoDS_Shape& aSolid = aSolidIter.Current(); if (IsSmall(aSolid)) + { aSmallSolids.Append(aSolid); + } else + { MapFacesToShells(aSolid, aMapFacesToShells); + } } // Merge all small solids adjacent to at least one non-small one; @@ -451,12 +505,16 @@ TopoDS_Shape ShapeFix_FixSmallSolid::Merge(const TopoDS_Shape& aSmallSolids.Remove(aSmallIter); } else + { aSmallIter.Next(); + } } // stop if no solids can be merged if (aShellsToMerge.IsEmpty()) + { break; + } // update needed non-small solids' shells by // merging and adding the listed small solids' shells to them @@ -477,7 +535,9 @@ TopoDS_Shape ShapeFix_FixSmallSolid::Merge(const TopoDS_Shape& // add new shells if needed if (aShellsToBeAddedPtr != nullptr) + { aNewShell = AddShells(aNewShell, *aShellsToBeAddedPtr); + } // replace the current non-small solid's shell with the new one(s) theContext->Replace(aBaseShell, aNewShell); @@ -512,7 +572,9 @@ bool ShapeFix_FixSmallSolid::IsSmall(const TopoDS_Shape& theSolid) const // threshold value, consider the solid as not small double aVolume = ShapeVolume(theSolid); if (IsUsedVolumeThreshold() && aVolume > myVolumeThreshold) + { return false; + } // If the width factor threshold is used and set, // and the solid's width factor exceeds threshold value, @@ -521,7 +583,9 @@ bool ShapeFix_FixSmallSolid::IsSmall(const TopoDS_Shape& theSolid) const { double anArea = ShapeArea(theSolid); if (aVolume > myWidthFactorThreshold * anArea * 0.5) + { return false; + } } // Both thresholds are met - consider the solid as small diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FreeBounds.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FreeBounds.cxx index 66dee96bf9..6189eb57d5 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FreeBounds.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_FreeBounds.cxx @@ -81,9 +81,13 @@ bool ShapeFix_FreeBounds::Perform() { ShapeAnalysis_FreeBounds safb; if (myShared) + { safb = ShapeAnalysis_FreeBounds(myShape, mySplitClosed, mySplitOpen); + } else + { safb = ShapeAnalysis_FreeBounds(myShape, mySewToler, mySplitClosed, mySplitOpen); + } myWires = safb.GetClosedWires(); myEdges = safb.GetOpenWires(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_IntersectionTool.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_IntersectionTool.cxx index a76721ab07..b5bb2dc52d 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_IntersectionTool.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_IntersectionTool.cxx @@ -74,7 +74,9 @@ static gp_Pnt GetPointOnEdge(const TopoDS_Edge& edge, TopLoc_Location L; const occ::handle ConS = BRep_Tool::Curve(edge, L, f, l); if (!ConS.IsNull()) + { return ConS->Value(param).Transformed(L.Transformation()); + } } gp_Pnt2d aP2d = Crv2d.Value(param); return surf->Adaptor3d()->Value(aP2d.X(), aP2d.Y()); @@ -96,12 +98,16 @@ bool ShapeFix_IntersectionTool::SplitEdge(const TopoDS_Edge& edge, TopoDS_Vertex V1 = sae.FirstVertex(edge); TopoDS_Vertex V2 = sae.LastVertex(edge); if (V1.IsSame(vert) || V2.IsSame(vert)) + { return false; + } occ::handle c2d; sae.PCurve(edge, face, c2d, a, b, true); if (std::abs(a - param) < 0.01 * preci || std::abs(b - param) < 0.01 * preci) + { return false; + } // check distance between edge and new vertex gp_Pnt P1; TopLoc_Location L; @@ -110,10 +116,14 @@ bool ShapeFix_IntersectionTool::SplitEdge(const TopoDS_Edge& edge, double f, l; const occ::handle c3d = BRep_Tool::Curve(edge, L, f, l); if (c3d.IsNull()) + { return false; + } P1 = c3d->Value(param); if (!L.IsIdentity()) + { P1 = P1.Transformed(L.Transformation()); + } } else { @@ -121,7 +131,9 @@ bool ShapeFix_IntersectionTool::SplitEdge(const TopoDS_Edge& edge, occ::handle sas = new ShapeAnalysis_Surface(surf); P1 = sas->Value(c2d->Value(param)); if (!L.IsIdentity()) + { P1 = P1.Transformed(L.Transformation()); + } } gp_Pnt P2 = BRep_Tool::Pnt(vert); if (P1.Distance(P2) > preci) @@ -186,13 +198,17 @@ bool ShapeFix_IntersectionTool::CutEdge(const TopoDS_Edge& edge, bool& iscutline) const { if (std::abs(cut - pend) < 10. * Precision::PConfusion()) + { return false; + } double aRange = std::abs(cut - pend); double a, b; BRep_Tool::Range(edge, a, b); if (aRange < 10. * Precision::PConfusion()) + { return false; + } // case pcurve is trimm of line if (!BRep_Tool::SameParameter(edge)) @@ -231,9 +247,13 @@ bool ShapeFix_IntersectionTool::CutEdge(const TopoDS_Edge& edge, // det-study on 03/12/01 checking the old and new ranges if (std::abs(std::abs(a - b) - aRange) < Precision::PConfusion()) + { return false; + } if (aRange < 10. * Precision::PConfusion()) + { return false; + } BRep_Builder B; B.Range(edge, std::min(pend, cut), std::max(pend, cut)); @@ -261,14 +281,18 @@ bool ShapeFix_IntersectionTool::SplitEdge1( TopoDS_Edge edge = sewd->Edge(num); TopoDS_Edge newE1, newE2; if (!SplitEdge(edge, param, vert, face, newE1, newE2, preci)) + { return false; + } // change context occ::handle wd = new ShapeExtend_WireData; wd->Add(newE1); wd->Add(newE2); if (!myContext.IsNull()) + { myContext->Replace(edge, wd->Wire()); + } for (TopExp_Explorer exp(wd->Wire(), TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); @@ -278,9 +302,13 @@ bool ShapeFix_IntersectionTool::SplitEdge1( // change sewd sewd->Set(newE1, num); if (num == sewd->NbEdges()) + { sewd->Add(newE2); + } else + { sewd->Add(newE2, num + 1); + } // change boxes boxes.UnBind(edge); @@ -301,7 +329,9 @@ bool ShapeFix_IntersectionTool::SplitEdge1( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE1, box); } @@ -317,7 +347,9 @@ bool ShapeFix_IntersectionTool::SplitEdge1( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE2, box); } @@ -346,7 +378,9 @@ bool ShapeFix_IntersectionTool::SplitEdge2( TopoDS_Edge newE1, newE2; double param = (param1 + param2) / 2; if (!SplitEdge(edge, param, vert, face, newE1, newE2, preci)) + { return false; + } // cut new edges by param1 and param2 bool IsCutLine; occ::handle Crv1, Crv2; @@ -390,7 +424,9 @@ bool ShapeFix_IntersectionTool::SplitEdge2( wd->Add(newE1); wd->Add(newE2); if (!myContext.IsNull()) + { myContext->Replace(edge, wd->Wire()); + } for (TopExp_Explorer exp(wd->Wire(), TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); @@ -400,9 +436,13 @@ bool ShapeFix_IntersectionTool::SplitEdge2( // change sewd sewd->Set(newE1, num); if (num == sewd->NbEdges()) + { sewd->Add(newE2); + } else + { sewd->Add(newE2, num + 1); + } // change boxes boxes.UnBind(edge); @@ -422,7 +462,9 @@ bool ShapeFix_IntersectionTool::SplitEdge2( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE1, box); } @@ -438,7 +480,9 @@ bool ShapeFix_IntersectionTool::SplitEdge2( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(newE2, box); } @@ -495,13 +539,21 @@ bool ShapeFix_IntersectionTool::UnionVertexes( // replace vertex in other edge int num21, num22; if (num2 > 1) + { num21 = num2 - 1; + } else + { num21 = sewd->NbEdges(); + } if (num2 < sewd->NbEdges()) + { num22 = num2 + 1; + } else + { num22 = 1; + } TopoDS_Edge edge21 = sewd->Edge(num21); TopoDS_Edge edge22 = sewd->Edge(num22); TopoDS_Vertex V21F = sae.FirstVertex(edge21); @@ -513,7 +565,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V1F, V21L); // NewE = sbe.CopyReplaceVertices(edge21,V,V21L); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -522,7 +576,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V21F, V1F); // NewE = sbe.CopyReplaceVertices(edge21,V21F,V); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -531,7 +587,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V1F, V22L); // NewE = sbe.CopyReplaceVertices(edge22,V,V22L); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -540,7 +598,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V22F, V1F); // NewE = sbe.CopyReplaceVertices(edge22,V22F,V); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -569,13 +629,21 @@ bool ShapeFix_IntersectionTool::UnionVertexes( // replace vertex in other edge int num21, num22; if (num2 > 1) + { num21 = num2 - 1; + } else + { num21 = sewd->NbEdges(); + } if (num2 < sewd->NbEdges()) + { num22 = num2 + 1; + } else + { num22 = 1; + } TopoDS_Edge edge21 = sewd->Edge(num21); TopoDS_Edge edge22 = sewd->Edge(num22); TopoDS_Vertex V21F = sae.FirstVertex(edge21); @@ -587,7 +655,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V1F, V21L); // NewE = sbe.CopyReplaceVertices(edge21,V,V21L); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -596,7 +666,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V21F, V1F); // NewE = sbe.CopyReplaceVertices(edge21,V21F,V); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -605,7 +677,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V1F, V22L); // NewE = sbe.CopyReplaceVertices(edge22,V,V22L); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -614,7 +688,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V22F, V1F); // NewE = sbe.CopyReplaceVertices(edge22,V22F,V); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -642,13 +718,21 @@ bool ShapeFix_IntersectionTool::UnionVertexes( // replace vertex in other edge int num21, num22; if (num2 > 1) + { num21 = num2 - 1; + } else + { num21 = sewd->NbEdges(); + } if (num2 < sewd->NbEdges()) + { num22 = num2 + 1; + } else + { num22 = 1; + } TopoDS_Edge edge21 = sewd->Edge(num21); TopoDS_Edge edge22 = sewd->Edge(num22); TopoDS_Vertex V21F = sae.FirstVertex(edge21); @@ -660,7 +744,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V1L, V21L); // NewE = sbe.CopyReplaceVertices(edge21,V,V21L); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -669,7 +755,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V21F, V1L); // NewE = sbe.CopyReplaceVertices(edge21,V21F,V); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -678,7 +766,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V1L, V22L); // NewE = sbe.CopyReplaceVertices(edge22,V,V22L); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -687,7 +777,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V22F, V1L); // NewE = sbe.CopyReplaceVertices(edge22,V22F,V); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -715,13 +807,21 @@ bool ShapeFix_IntersectionTool::UnionVertexes( // replace vertex in other edge int num21, num22; if (num2 > 1) + { num21 = num2 - 1; + } else + { num21 = sewd->NbEdges(); + } if (num2 < sewd->NbEdges()) + { num22 = num2 + 1; + } else + { num22 = 1; + } TopoDS_Edge edge21 = sewd->Edge(num21); TopoDS_Edge edge22 = sewd->Edge(num22); TopoDS_Vertex V21F = sae.FirstVertex(edge21); @@ -733,7 +833,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V1L, V21L); // NewE = sbe.CopyReplaceVertices(edge21,V,V21L); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -742,7 +844,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge21, V21F, V1L); // NewE = sbe.CopyReplaceVertices(edge21,V21F,V); if (boxes.IsBound(edge21)) + { boxes.Bind(NewE, boxes.Find(edge21)); // update boxes + } myContext->Replace(edge21, NewE); sewd->Set(NewE, num21); } @@ -751,7 +855,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V1L, V22L); // NewE = sbe.CopyReplaceVertices(edge22,V,V22L); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -760,7 +866,9 @@ bool ShapeFix_IntersectionTool::UnionVertexes( NewE = sbe.CopyReplaceVertices(edge22, V22F, V1L); // NewE = sbe.CopyReplaceVertices(edge22,V22F,V); if (boxes.IsBound(edge22)) + { boxes.Bind(NewE, boxes.Find(edge22)); // update boxes + } myContext->Replace(edge22, NewE); sewd->Set(NewE, num22); } @@ -800,7 +908,9 @@ static Bnd_Box2d CreateBoxes2d( gac.Load(c2d); } else + { gac.Load(c2d, cf, cl); + } BndLib_Add2dCurve::Add(gac, ::Precision::Confusion(), box); boxes.Bind(E, box); aTotalBox.Add(box); @@ -824,18 +934,26 @@ static void SelectIntPnt(const Geom2dInt_GInter& Inter, // possible second point is better? int status1 = 0, status2 = 0; if (Tr1.PositionOnCurve() == IntRes2d_Middle) + { status1 += 1; + } if (Tr2.PositionOnCurve() == IntRes2d_Middle) + { status1 += 2; + } IntRes2d_IntersectionPoint IP2; IntRes2d_Transition Tr12, Tr22; IP2 = Inter.Point(2); Tr12 = IP2.TransitionOfFirst(); Tr22 = IP2.TransitionOfSecond(); if (Tr12.PositionOnCurve() == IntRes2d_Middle) + { status2 += 1; + } if (Tr22.PositionOnCurve() == IntRes2d_Middle) + { status2 += 2; + } if (status2 > status1) { IP = IP2; @@ -915,7 +1033,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handleNbEdges()) + { continue; + } TopoDS_Edge edge1 = sewd->Edge(num1); TopoDS_Edge edge2 = sewd->Edge(num2); if (edge1.IsSame(edge2)) + { continue; + } if (BRep_Tool::Degenerated(edge1) || BRep_Tool::Degenerated(edge2)) + { continue; + } if (!boxes.IsBound(edge1) || !boxes.IsBound(edge2)) + { continue; + } Bnd_Box2d B1 = boxes.Find(edge1); Bnd_Box2d B2 = boxes.Find(edge2); if (!B1.IsOut(B2)) @@ -966,9 +1094,13 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle Crv1, Crv2; if (!sae.PCurve(edge1, face, Crv1, a1, b1, false)) + { return false; + } if (!sae.PCurve(edge2, face, Crv2, a2, b2, false)) + { return false; + } double tolint = 1.0e-10; Geom2dAdaptor_Curve C1(Crv1), C2(Crv2); IntRes2d_Domain d1(C1.Value(a1), a1, tolint, C1.Value(b1), b1, tolint); @@ -976,7 +1108,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle 0 && Inter.NbPoints() < 3) { @@ -1021,7 +1155,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle distb) ? a1 : b1), param1, face, IsCutLine); if (ModifE1) + { NbCut++; + } // not needed split edge, if one of parts is too small ModifE1 = ModifE1 || distmin < Precision::Confusion(); } @@ -1054,7 +1190,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle distb) ? a2 : b2), param2, face, IsCutLine); if (ModifE2) + { NbCut++; + } // not needed split edge, if one of parts is too small ModifE2 = ModifE2 || distmin < Precision::Confusion(); } @@ -1095,7 +1233,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handlemyPreci || Pnt12.Distance(Pnt22)>myPreci ) continue; if (Pnt11.Distance(Pnt21) > MaxTolVert || Pnt12.Distance(Pnt22) > MaxTolVert) + { continue; + } // analysis for edge1 TopoDS_Vertex V1 = sae.FirstVertex(edge1); gp_Pnt PV1 = BRep_Tool::Pnt(V1); @@ -1181,9 +1325,13 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle distb) + { pend = a1; + } else + { pend = b1; + } if (std::abs(pend - p11) > std::abs(pend - p12)) + { cut = p12; + } else + { cut = p11; + } bool IsCutLine; if (CutEdge(edge1, pend, cut, face, IsCutLine)) + { NbCut++; + } if (newtol > BRep_Tool::Tolerance(NewV)) { B.UpdateVertex(NewV, newtol); } else + { newtol = BRep_Tool::Tolerance(NewV); + } } // analysis for edge2 TopoDS_Vertex V12 = sae.FirstVertex(edge2); @@ -1244,9 +1408,13 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle distb) + { pend = a2; + } else + { pend = b2; + } if (std::abs(pend - p21) > std::abs(pend - p22)) + { cut = p22; + } else + { cut = p21; + } bool IsCutLine; if (CutEdge(edge2, pend, cut, face, IsCutLine)) + { NbCut++; + } if (newtol > BRep_Tool::Tolerance(NewV)) { B.UpdateVertex(NewV, newtol); } else + { newtol = BRep_Tool::Tolerance(NewV); + } } if (IsModified1 && !IsModified2) @@ -1362,7 +1546,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle MaxTolVert || tolV2 > MaxTolVert) + { continue; + } TopoDS_Vertex NewV1, NewV2; /* // parameters for splitting: a1..p11..p12..b1 and a2..p21..p22..b2 @@ -1419,13 +1605,19 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handle 1 || akey2 > 1) + { continue; + } int dnum1 = 0, numseg1 = num1; // prepare vertices if (akey1 == 0) + { B.MakeVertex(NewV1, P01, tolV1); + } if (akey2 == 0) + { B.MakeVertex(NewV2, P02, tolV2); + } // split if (akey1 == 0 && akey2 > 0) { @@ -1643,7 +1835,9 @@ bool ShapeFix_IntersectionTool::FixSelfIntersectWire(occ::handleApply(face); // TopoDS_Shape SF = TopoDS::Face(S); TopoDS_Shape SF = face; @@ -1663,10 +1857,14 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const TopoDS_Wire wire = TopoDS::Wire(iter.Value()); // Prevent duplicate wires from being added to the sequence if (anAddedWires.Add(wire)) + { SeqWir.Append(wire); + } } if (SeqWir.Length() < 2) + { return false; // gka 06.09.04 + } double MaxTolVert = 0.0; for (TopExp_Explorer exp(SF, TopAbs_VERTEX); exp.More(); exp.Next()) @@ -1724,11 +1922,17 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const // for each edge from second wire TopoDS_Edge edge2 = sewd2->Edge(num2); if (edge1.IsSame(edge2)) + { continue; + } if (BRep_Tool::Degenerated(edge1) || BRep_Tool::Degenerated(edge2)) + { continue; + } if (!boxes1.IsBound(edge1) || !boxes2.IsBound(edge2)) + { continue; + } Bnd_Box2d B1 = boxes1.Find(edge1); Bnd_Box2d B2 = boxes2.Find(edge2); if (!B1.IsOut(B2)) @@ -1737,9 +1941,13 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const double a1, b1, a2, b2; occ::handle Crv1, Crv2; if (!sae.PCurve(edge1, face, Crv1, a1, b1, false)) + { continue; // return false; gka 06.09.04 + } if (!sae.PCurve(edge2, face, Crv2, a2, b2, false)) + { continue; // return false;gka 06.09.04 + } double tolint = 1.0e-10; Geom2dAdaptor_Curve C1(Crv1), C2(Crv2); IntRes2d_Domain d1(C1.Value(a1), a1, tolint, C1.Value(b1), b1, tolint); @@ -1747,7 +1955,9 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const Geom2dInt_GInter Inter; Inter.Perform(C1, d1, C2, d2, tolint, tolint); if (!Inter.IsDone()) + { continue; + } // intersection is point if (Inter.NbPoints() > 0 && Inter.NbPoints() < 3) { @@ -1783,7 +1993,9 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const break; } if (isSplitEdge2) + { continue; + } } if (Tr1.PositionOnCurve() == IntRes2d_Middle && Tr2.PositionOnCurve() != IntRes2d_Middle) @@ -1830,7 +2042,9 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const { // union vertexes if (UnionVertexes(sewd2, edge1, edge2, num2, boxes2, B2)) + { nbReplaced++; // gka 06.09.04 + } } } hasModifWire = (hasModifWire || NbModif || nbReplaced); @@ -1866,9 +2080,13 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const double maxdist = std::max(dist1, dist2); double pdist; if (edge1.Orientation() == TopAbs_REVERSED) + { pdist = std::max(std::abs(b1 - p11), std::abs(b1 - p12)); + } else + { pdist = std::max(std::abs(a1 - p11), std::abs(a1 - p12)); + } if (maxdist < MaxTolVert || pdist < std::abs(b1 - a1) * 0.01) { newtol = maxdist; @@ -1879,9 +2097,13 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const dist2 = Pnt12.Distance(PV2); maxdist = std::max(dist1, dist2); if (edge1.Orientation() == TopAbs_REVERSED) + { pdist = std::max(std::abs(a1 - p11), std::abs(a1 - p12)); + } else + { pdist = std::max(std::abs(b1 - p11), std::abs(b1 - p12)); + } if (maxdist < MaxTolVert || pdist < std::abs(b1 - a1) * 0.01) { if ((IsModified1 && maxdist < newtol) || !IsModified1) @@ -1898,13 +2120,21 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const double distb = std::abs(b1 - p11) + std::abs(b1 - p12); double pend, cut; if (dista > distb) + { pend = a1; + } else + { pend = b1; + } if (std::abs(pend - p11) > std::abs(pend - p12)) + { cut = p12; + } else + { cut = p11; + } bool IsCutLine; if (!CutEdge(edge1, pend, cut, face, IsCutLine)) { @@ -1926,9 +2156,13 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const dist2 = Pnt22.Distance(PV12); maxdist = std::max(dist1, dist2); if (edge2.Orientation() == TopAbs_REVERSED) + { pdist = std::max(std::abs(b2 - p21), std::abs(b2 - p22)); + } else + { pdist = std::max(std::abs(a2 - p21), std::abs(a2 - p22)); + } if (maxdist < MaxTolVert || pdist < std::abs(b2 - a2) * 0.01) { newtol = maxdist; @@ -1939,9 +2173,13 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const dist2 = Pnt22.Distance(PV22); maxdist = std::max(dist1, dist2); if (edge2.Orientation() == TopAbs_REVERSED) + { pdist = std::max(std::abs(a2 - p21), std::abs(a2 - p22)); + } else + { pdist = std::max(std::abs(b2 - p21), std::abs(b2 - p22)); + } if (maxdist < MaxTolVert || pdist < std::abs(b2 - a2) * 0.01) { if ((IsModified2 && maxdist < newtol) || !IsModified2) @@ -1958,13 +2196,21 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const double distb = std::abs(b2 - p21) + std::abs(b2 - p22); double pend, cut; if (dista > distb) + { pend = a2; + } else + { pend = b2; + } if (std::abs(pend - p21) > std::abs(pend - p22)) + { cut = p22; + } else + { cut = p21; + } bool IsCutLine; if (!CutEdge(edge2, pend, cut, face, IsCutLine)) { @@ -2004,7 +2250,9 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const double tolV2 = std::max(Pnt12.Distance(P02), Pnt22.Distance(P02)); tolV2 = std::max(tolV2, Precision::Confusion()) * 1.00001; if (tolV1 > MaxTolVert || tolV2 > MaxTolVert) + { continue; + } hasModifWire = true; // gka 06.09.04 TopoDS_Vertex NewV1, NewV2; @@ -2016,14 +2264,18 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const { NewV1 = V1; if (tolV1 > BRep_Tool::Tolerance(V1)) + { B.UpdateVertex(NewV1, tolV1); + } akey1++; } if (P01.Distance(PV2) < std::max(tolV1, BRep_Tool::Tolerance(V2))) { NewV1 = V2; if (tolV1 > BRep_Tool::Tolerance(V2)) + { B.UpdateVertex(NewV1, tolV1); + } akey1++; } // analysis fo P02 @@ -2031,23 +2283,33 @@ bool ShapeFix_IntersectionTool::FixIntersectingWires(TopoDS_Face& face) const { NewV2 = V1; if (tolV2 > BRep_Tool::Tolerance(V1)) + { B.UpdateVertex(NewV2, tolV2); + } akey2++; } if (P02.Distance(PV2) < std::max(tolV2, BRep_Tool::Tolerance(V2))) { NewV2 = V2; if (tolV2 > BRep_Tool::Tolerance(V2)) + { B.UpdateVertex(NewV2, tolV2); + } akey2++; } if (akey1 > 1 || akey2 > 1) + { continue; + } // prepare vertices if (akey1 == 0) + { B.MakeVertex(NewV1, P01, tolV1); + } if (akey2 == 0) + { B.MakeVertex(NewV2, P02, tolV2); + } // split int numseg1 = num1; if (akey1 == 0 && akey2 > 0) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Root.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Root.cxx index e659a931f8..33723eac7a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Root.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Root.cxx @@ -59,9 +59,13 @@ void ShapeFix_Root::SetPrecision(const double preci) { myPrecision = preci; if (myMaxTol < myPrecision) + { myMaxTol = myPrecision; + } if (myMinTol > myPrecision) + { myMinTol = myPrecision; + } } //================================================================================================= @@ -85,5 +89,7 @@ void ShapeFix_Root::SendMsg(const TopoDS_Shape& shape, const Message_Gravity gravity) const { if (!myMsgReg.IsNull()) + { myMsgReg->Send(shape, message, gravity); + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shape.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shape.cxx index a2d4c408dc..39ced4414a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shape.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shape.cxx @@ -116,7 +116,9 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) myShape.Location(L, false); TopoDS_Shape S = Context()->Apply(myShape); if (NeedFix(myFixVertexPositionMode)) + { ShapeFix::FixVertexPosition(S, Precision(), Context()); + } st = S.ShapeType(); @@ -141,10 +143,14 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) { myShape = anIter.Value(); if (Perform(aPSSubShape.Next())) + { status = true; + } } if (!aPSSubShape.More()) + { return false; // aborted execution + } myFixSameParameterMode = savFixSameParameterMode; myFixVertexTolMode = savFixVertexTolMode; @@ -153,32 +159,42 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) } case TopAbs_SOLID: { if (!NeedFix(myFixSolidMode)) + { break; + } myFixSolid->Init(TopoDS::Solid(S)); myFixSolid->SetContext(Context()); if (myFixSolid->Perform(aPS.Next())) + { status = true; + } myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); break; } case TopAbs_SHELL: { if (!NeedFix(myFixShellMode)) + { break; + } occ::handle sfsh = FixShellTool(); sfsh->Init(TopoDS::Shell(S)); sfsh->SetContext(Context()); if (sfsh->Perform(aPS.Next())) + { status = true; + } myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); break; } case TopAbs_FACE: { if (!NeedFix(myFixFaceMode)) + { break; + } occ::handle sff = FixFaceTool(); bool savTopoMode = sff->FixWireTool()->ModifyTopologyMode(); sff->FixWireTool()->ModifyTopologyMode() = true; @@ -195,13 +211,17 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) } case TopAbs_WIRE: { if (!NeedFix(myFixWireMode)) + { break; + } occ::handle sfw = FixWireTool(); bool savTopoMode = sfw->ModifyTopologyMode(); bool savClosedMode = sfw->ClosedWireMode(); sfw->ModifyTopologyMode() = true; if (!S.Closed()) + { sfw->ClosedWireMode() = false; + } sfw->SetFace(TopoDS_Face()); sfw->Load(TopoDS::Wire(S)); sfw->SetContext(Context()); @@ -219,7 +239,9 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) occ::handle sfe = FixEdgeTool(); sfe->SetContext(Context()); if (sfe->FixVertexTolerance(TopoDS::Edge(S))) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } break; } case TopAbs_VERTEX: @@ -228,7 +250,9 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) break; } if (!aPS.More()) + { return false; // aborted execution + } myResult = Context()->Apply(S); @@ -236,14 +260,18 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) { SameParameter(myResult, false, aPS.Next()); if (!aPS.More()) + { return false; // aborted execution + } } if (NeedFix(myFixVertexTolMode)) { int nbF = 0; TopExp_Explorer anExpF(myResult, TopAbs_FACE); for (; anExpF.More() && nbF <= 1; anExpF.Next()) + { nbF++; + } if (nbF > 1) { // fix for bug 0025455 @@ -257,7 +285,9 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) TopoDS_Face aF = TopoDS::Face(anExpF.Current()); TopExp_Explorer anExpE(aF, TopAbs_EDGE); for (; anExpE.More(); anExpE.Next()) + { sfe->FixVertexTolerance(TopoDS::Edge(anExpE.Current()), aF); + } } } } @@ -265,7 +295,9 @@ bool ShapeFix_Shape::Perform(const Message_ProgressRange& theProgress) myResult = Context()->Apply(myResult); if (!fft.IsNull()) + { fft->FixSmallAreaWireMode() = savFixSmallAreaWireMode; + } return status; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ShapeTolerance.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ShapeTolerance.cxx index 0d58b2536e..465379184d 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ShapeTolerance.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_ShapeTolerance.cxx @@ -38,7 +38,9 @@ bool ShapeFix_ShapeTolerance::LimitTolerance(const TopoDS_Shape& shape, const TopAbs_ShapeEnum styp) const { if (shape.IsNull() || tmin < 0) + { return false; + } bool iamax = (tmax >= tmin); double prec; bool fait = false; @@ -53,9 +55,13 @@ bool ShapeFix_ShapeTolerance::LimitTolerance(const TopoDS_Shape& shape, TopoDS_Vertex V = TopoDS::Vertex(sh); prec = BRep_Tool::Tolerance(V); if (iamax && prec > tmax) + { newtol = 1; + } else if (prec < tmin) + { newtol = -1; + } if (newtol) { const occ::handle& TV = *((occ::handle*)&V.TShape()); @@ -68,9 +74,13 @@ bool ShapeFix_ShapeTolerance::LimitTolerance(const TopoDS_Shape& shape, TopoDS_Edge E = TopoDS::Edge(sh); prec = BRep_Tool::Tolerance(E); if (iamax && prec > tmax) + { newtol = 1; + } else if (prec < tmin) + { newtol = -1; + } if (newtol) { const occ::handle& TE = *((occ::handle*)&E.TShape()); @@ -83,9 +93,13 @@ bool ShapeFix_ShapeTolerance::LimitTolerance(const TopoDS_Shape& shape, TopoDS_Face F = TopoDS::Face(sh); prec = BRep_Tool::Tolerance(F); if (iamax && prec > tmax) + { newtol = 1; + } else if (prec < tmin) + { newtol = -1; + } if (newtol) { const occ::handle& TF = *((occ::handle*)&F.TShape()); @@ -105,9 +119,13 @@ bool ShapeFix_ShapeTolerance::LimitTolerance(const TopoDS_Shape& shape, TopoDS_Vertex V1, V2; TopExp::Vertices(E, V1, V2); if (!V1.IsNull()) + { fait |= LimitTolerance(V1, tmin, tmax, TopAbs_VERTEX); + } if (!V2.IsNull()) + { fait |= LimitTolerance(V2, tmin, tmax, TopAbs_VERTEX); + } } } else @@ -129,7 +147,9 @@ void ShapeFix_ShapeTolerance::SetTolerance(const TopoDS_Shape& shape, // WIRE : EDGE + VERTEX // Autres : TOUT (donc == WIRE + FACE) if (shape.IsNull() || preci <= 0) + { return; + } if (styp == TopAbs_VERTEX || styp == TopAbs_EDGE || styp == TopAbs_FACE) { for (TopExp_Explorer ex(shape, styp); ex.More(); ex.Next()) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shell.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shell.cxx index 922f4ecc40..0a97fb36c1 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shell.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Shell.cxx @@ -102,7 +102,9 @@ bool ShapeFix_Shell::Perform(const Message_ProgressRange& theProgress) { bool status = false; if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } myFixFace->SetContext(Context()); if (NeedFix(myFixFaceMode)) @@ -129,12 +131,16 @@ bool ShapeFix_Shell::Perform(const Message_ProgressRange& theProgress) // Halt algorithm in case of user's abort if (!aPS.More()) + { return false; + } } TopoDS_Shape newsh = Context()->Apply(myShell); if (NeedFix(myFixOrientationMode)) + { FixFaceOrientation(TopoDS::Shell(newsh), true, myNonManifold); + } TopoDS_Shape aNewsh = Context()->Apply(newsh); ShapeAnalysis_Shell aSas; @@ -157,9 +163,13 @@ bool ShapeFix_Shell::Perform(const Message_ProgressRange& theProgress) } if (status) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (Status(ShapeExtend_DONE2)) + { status = true; + } return status; } @@ -174,9 +184,13 @@ static bool GetFreeEdges(const TopoDS_Shape& { TopoDS_Edge edge = TopoDS::Edge(aExpE.Current()); if (!MapEdges.Contains(edge)) + { MapEdges.Add(edge); + } else + { MapEdges.Remove(edge); + } } } return !MapEdges.IsEmpty(); @@ -410,7 +424,9 @@ static bool GetShells( // if multiconnexity mode is equal to true faces contains // the same multiconnexity edges are not added to one shell. if (anIsMultiConnex && theMapMultiConnectEdges.Contains(edge)) + { continue; + } std::pair* aProcessedEdgeIt = aProcessedEdges.ChangeSeek(edge); @@ -467,7 +483,9 @@ static bool GetShells( } if (!aBadOrientationCount && !aGoodOrientationCount && aTempProcessedEdges.IsEmpty()) + { continue; + } // if face can not be added to shell it added to sequence of error faces. @@ -569,7 +587,9 @@ static bool GetShells( } bool isContains = false; for (int k = 1; k <= theSeqShells.Length() && !isContains; k++) + { isContains = nshell.IsSame(theSeqShells.Value(k)); + } if (!isContains) { int numFace = 0; @@ -583,13 +603,17 @@ static bool GetShells( { // close all closed shells in no multi connex mode if (!anIsMultiConnex) + { nshell.Closed(BRep_Tool::IsClosed(nshell)); + } theSeqShells.Append(nshell); } else if (numFace == 1) { if (theMapFaceShells.IsBound(aFace)) + { theMapFaceShells.UnBind(aFace); + } aProcessingFaces.Append(aFace); } } @@ -601,7 +625,9 @@ static bool GetShells( aGroupIter.Next(), ++aGroupIndex) { if (aGroupIndex == 1) + { continue; // Skip first group (already processed) + } const NCollection_Sequence& aUnprocessedGroup = aGroupIter.Value(); for (int anUnprocFaceIdx = 1; anUnprocFaceIdx <= aUnprocessedGroup.Length(); ++anUnprocFaceIdx) @@ -658,16 +684,24 @@ static bool AddMultiConexityFaces( { const TopoDS_Shape& edge = aItEdges.Value(); if (!aMapMultiConnectEdges.Contains(edge)) + { continue; + } aNbMultEdges++; } if (!aNbMultEdges) + { continue; + } if (aNbMultEdges == aNbEdges) + { AddShapes.Append(aShape); + } else + { llPosibleShells.Append(aShape); + } } } @@ -692,10 +726,14 @@ static bool AddMultiConexityFaces( amapIter.Next()) { if (aMapMultiConnectEdges.Contains(amapIter.Key())) + { nbedge++; + } } if (nbedge && nbedge == mapEdges.Extent()) + { AddShapes.Append(aSh); + } } } } @@ -709,7 +747,9 @@ static bool AddMultiConexityFaces( const TopoDS_Shape& aSh = AddShapes.Value(k1); NCollection_Map mapEdges; if (!GetFreeEdges(aSh, mapEdges)) + { continue; + } NCollection_List lfaces; // Fill MapOtherShells which will contain shells with orientation in which selected shape aSh @@ -720,12 +760,18 @@ static bool AddMultiConexityFaces( amapIter.Next()) { if (!aMapMultiConnectEdges.Contains(amapIter.Key())) + { continue; + } TopoDS_Edge edge = TopoDS::Edge(amapIter.Key()); if (edge.Orientation() == TopAbs_FORWARD) + { dire.Add(edge); + } else + { reve.Add(edge); + } NCollection_List lf; lf = aMapEdgeFaces.FindFromKey(edge); lfaces.Append(lf); @@ -734,14 +780,20 @@ static bool AddMultiConexityFaces( { TopoDS_Shape aF = aItl.Value(); if (!aMapFaceShells.IsBound(aF)) + { continue; + } TopoDS_Shape aOthershell; aOthershell = aMapFaceShells.Find(aF); if (MapOtherShells.IsBound(aOthershell)) + { continue; + } if (!NonManifold && BRep_Tool::IsClosed(aOthershell)) + { continue; + } NCollection_Map mapShellEdges; GetFreeEdges(aOthershell, mapShellEdges); @@ -749,10 +801,14 @@ static bool AddMultiConexityFaces( for (NCollection_Map::Iterator amapIter1(mapEdges); amapIter1.More() && isAdd; amapIter1.Next()) + { isAdd = mapShellEdges.Contains(amapIter1.Key()); + } if (!isAdd) + { continue; + } int nbdir = 0, nbrev = 0; // add only free face whome all edges contains in the shell as open boundary. @@ -762,13 +818,19 @@ static bool AddMultiConexityFaces( { TopoDS_Edge edgeS = TopoDS::Edge(aIte.Key()); if (!aMapMultiConnectEdges.Contains(edgeS)) + { continue; + } if ((edgeS.Orientation() == TopAbs_FORWARD && dire.Contains(edgeS)) || (edgeS.Orientation() == TopAbs_REVERSED && reve.Contains(edgeS))) + { nbrev++; + } else if ((edgeS.Orientation() == TopAbs_FORWARD && reve.Contains(edgeS)) || (edgeS.Orientation() == TopAbs_REVERSED && dire.Contains(edgeS))) + { nbdir++; + } } if (nbdir && nbrev) { @@ -798,7 +860,9 @@ static bool AddMultiConexityFaces( for (int l = 1; l <= SeqShells.Length(); l++) { if (!MapOtherShells.IsBound(SeqShells.Value(l))) + { continue; + } ind++; int isRev = MapOtherShells.Find(SeqShells.Value(l)); TopoDS_Shape anewShape = (isRev ? aSh.Reversed() : aSh); @@ -813,7 +877,9 @@ static bool AddMultiConexityFaces( FirstInd = l; } for (TopExp_Explorer aE(anewShape, TopAbs_FACE); aE.More(); aE.Next()) + { aB1.Add(aShell, aE.Current()); + } SeqShells.ChangeValue(l) = aShell; } else if (NonManifold) @@ -837,7 +903,9 @@ static bool AddMultiConexityFaces( for (int kk = 1; kk <= Lface.Length(); kk++) { if (aEt.Current().IsSame(Lface.Value(kk))) + { Lface.Remove(kk--); + } } } } @@ -857,13 +925,19 @@ static int BoxIn(const Bnd_Box& theBox1, const Bnd_Box& theBox2) theBox2.Get(aXmin2, aYmin2, aZmin2, aXmax2, aYmax2, aZmax2); if (aXmin1 == aXmin2 && aXmax1 == aXmax2 && aYmin1 == aYmin2 && aYmax1 == aYmax2 && aZmin1 == aZmin2 && aZmax1 == aZmax2) + { aNumIn = 0; + } else if (aXmin1 >= aXmin2 && aXmax1 <= aXmax2 && aYmin1 >= aYmin2 && aYmax1 <= aYmax2 && aZmin1 >= aZmin2 && aZmax1 <= aZmax2) + { aNumIn = 1; + } else if (aXmin1 <= aXmin2 && aXmax1 >= aXmax2 && aYmin1 <= aYmin2 && aYmax1 >= aYmax2 && aZmin1 <= aZmin2 && aZmax1 >= aZmax2) + { aNumIn = 2; + } return aNumIn; } @@ -905,7 +979,9 @@ static void GetClosedShells(NCollection_Sequence& Shells, for (int i1 = 1; i1 <= Shells.Length(); i1++) { if (!aMapNum.Contains(i1)) + { aRemainShells.Append(Shells.Value(i1)); + } } } @@ -925,7 +1001,9 @@ static void GlueClosedCandidate( NCollection_Map mapEdges1; NCollection_Map dire, reve; if (!GetFreeEdges(aShell, mapEdges1)) + { continue; + } for (NCollection_Map::Iterator aIte(mapEdges1); aIte.More(); @@ -933,14 +1011,22 @@ static void GlueClosedCandidate( { TopoDS_Edge edge1 = TopoDS::Edge(aIte.Key()); if (!aMapMultiConnectEdges.Contains(edge1)) + { break; + } if (edge1.Orientation() == TopAbs_FORWARD) + { dire.Add(edge1); + } else if (edge1.Orientation() == TopAbs_REVERSED) + { reve.Add(edge1); + } } if (mapEdges1.Extent() > (dire.Extent() + reve.Extent())) + { continue; + } // Filling map MapOtherShells which contains candidate to creation of closed shell // with aShell. @@ -952,7 +1038,9 @@ static void GlueClosedCandidate( NCollection_Map mapEdges2; const TopoDS_Shape& aShell2 = OpenShells.Value(j); if (!GetFreeEdges(aShell2, mapEdges2)) + { continue; + } for (NCollection_Map::Iterator aIte2(mapEdges2); aIte2.More() && isAddShell; aIte2.Next()) @@ -967,15 +1055,21 @@ static void GlueClosedCandidate( isAddShell = (dire.Contains(edge2) || reve.Contains(edge2)); if ((edge2.Orientation() == TopAbs_FORWARD && dire.Contains(edge2)) || (edge2.Orientation() == TopAbs_REVERSED && reve.Contains(edge2))) + { isReversed = true; + } } if (!isAddShell) + { continue; + } MapOtherShells.Bind(OpenShells.Value(j), isReversed); } if (MapOtherShells.IsEmpty()) + { continue; + } if (!MapOtherShells.IsEmpty()) { @@ -1004,7 +1098,9 @@ static void GlueClosedCandidate( BRep_Builder aB; aB.MakeShell(aNewSh); for (TopoDS_Iterator aIt1(aSeqCandidate.Value(k), false); aIt1.More(); aIt1.Next()) + { aB.Add(aNewSh, aIt1.Value()); + } bool isRev = MapOtherShells.Find(aSeqCandidate.Value(l)); if (k != 1) { @@ -1027,7 +1123,9 @@ static void GlueClosedCandidate( for (int j1 = i + 1; j1 <= OpenShells.Length(); j1++) { if (!MapOtherShells.IsBound(OpenShells.Value(j1))) + { continue; + } OpenShells.Remove(j1--); } } @@ -1040,7 +1138,9 @@ static void GlueClosedCandidate( for (int j1 = i + 1; j1 <= OpenShells.Length(); j1++) { if (!MapOtherShells.Find(OpenShells.Value(j1), isReversed)) + { continue; + } addShell = OpenShells.Value(j1); OpenShells.Remove(j1); break; @@ -1050,7 +1150,9 @@ static void GlueClosedCandidate( { TopoDS_Shape aFace = aExpF.Current(); if (isReversed) + { aFace.Reverse(); + } aB.Add(aNewShell, aFace); } aSeqNewShells.Append(aNewShell); @@ -1089,7 +1191,9 @@ static void CreateNonManifoldShells( if (medeg.Contains(ae)) { if (aMap.Contains(ae)) + { aMap.ChangeFromKey(ae).Append(aShell); + } else { NCollection_List al; @@ -1127,7 +1231,9 @@ static void CreateNonManifoldShells( { const TopoDS_Shape& ss = aMapShells.FindFromKey(arshell); if (ss.IsSame(arshell)) + { break; + } arshell = ss; } @@ -1147,13 +1253,17 @@ static void CreateNonManifoldShells( { const TopoDS_Shape& ss = aMapShells.FindFromKey(arshell); if (ss.IsSame(arshell)) + { break; + } arshell = ss; } if (num == 1) { for (TopExp_Explorer aEf(arshell, TopAbs_FACE); aEf.More(); aEf.Next()) + { aB.Add(aNewShell, aEf.Current()); + } mapmerge.Add(arshell); } @@ -1193,7 +1303,9 @@ static void CreateNonManifoldShells( { const TopoDS_Shape& ss = aMapShells.FindFromKey(aNewShell); if (ss.IsSame(aNewShell)) + { break; + } aNewShell = ss; } MapNewShells.Add(aNewShell); @@ -1202,7 +1314,9 @@ static void CreateNonManifoldShells( } } for (int ii = 1; ii <= MapNewShells.Extent(); ii++) + { SeqShells.Append(MapNewShells.FindKey(ii)); + } } //======================================================================= @@ -1229,42 +1343,62 @@ static void CreateClosedShell( NCollection_Map mapEdges1; NCollection_Map dire, reve; if (!GetFreeEdges(aShell, mapEdges1)) + { break; + } for (NCollection_Map::Iterator aIte(mapEdges1); aIte.More(); aIte.Next()) { TopoDS_Edge edge1 = TopoDS::Edge(aIte.Key()); if (!aMapMultiConnectEdges.Contains(edge1)) + { continue; + } if (edge1.Orientation() == TopAbs_FORWARD) + { dire.Add(edge1); + } else if (edge1.Orientation() == TopAbs_REVERSED) + { reve.Add(edge1); + } } if (dire.IsEmpty() && reve.IsEmpty()) + { break; + } NCollection_Map mapEdges2; TopoDS_Shape aShell2 = OpenShells.Value(j); if (!GetFreeEdges(aShell2, mapEdges2)) + { continue; + } for (NCollection_Map::Iterator aIte2(mapEdges2); aIte2.More(); aIte2.Next()) { TopoDS_Edge edge2 = TopoDS::Edge(aIte2.Key()); if (!aMapMultiConnectEdges.Contains(edge2)) + { continue; + } if (!dire.Contains(edge2) && !reve.Contains(edge2)) + { continue; + } isAddShell = true; if ((edge2.Orientation() == TopAbs_FORWARD && dire.Contains(edge2)) || (edge2.Orientation() == TopAbs_REVERSED && reve.Contains(edge2))) + { isReversed = true; + } } if (!isAddShell) + { continue; + } BRep_Builder aB; for (TopExp_Explorer aExpF21(OpenShells.Value(j), TopAbs_FACE); aExpF21.More(); @@ -1272,7 +1406,9 @@ static void CreateClosedShell( { TopoDS_Shape aFace = aExpF21.Current(); if (isReversed) + { aFace.Reverse(); + } aB.Add(aShell, aFace); } @@ -1304,10 +1440,14 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, for (TopoDS_Iterator iter(shell); iter.More(); iter.Next(), nbF++) { if (aMapAdded.Add(iter.Value())) + { Lface.Append(iter.Value()); + } } if (Lface.Length() < nbF) + { done = true; + } NCollection_IndexedDataMap, TopTools_ShapeMapHasher> aMapEdgeFaces; @@ -1321,11 +1461,15 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, { TopoDS_Edge E = TopoDS::Edge(aMapEdgeFaces.FindKey(k)); if (!BRep_Tool::Degenerated(E)) + { isFreeBoundaries = true; + } } // Finds multishared edges else if (isAccountMultiConex && aFaceCount > 2) + { aMapMultiConnectEdges.Add(aMapEdgeFaces.FindKey(k)); + } } if (BRep_Tool::IsClosed(myShell) ? isFreeBoundaries : !isFreeBoundaries) { @@ -1345,17 +1489,23 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, } isGetShells = !aTmpSeqShells.IsEmpty(); if (isGetShells) + { aSeqShells.Append(aTmpSeqShells); + } } if (!done) + { done = (aSeqShells.Length() > 1); + } bool aIsDone = false; if (Lface.Length() > 0 && aSeqShells.Length()) { for (int jj = 1; jj <= Lface.Length(); jj++) { if (aMapFaceShells.IsBound(Lface.Value(jj))) + { aMapFaceShells.UnBind(Lface.Value(jj)); + } } // Addition of faces having only multiconnexity boundary to shells having holes @@ -1378,7 +1528,9 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, TopoDS_Compound aCompShells; B.MakeCompound(aCompShells); for (int n = 1; n <= aErrFaces.Length(); n++) + { B.Add(myErrFaces, aErrFaces.Value(n)); + } if (aNumMultShell) { if (aNumMultShell == 1) @@ -1396,7 +1548,9 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, else { for (int i = 1; i <= aSeqShells.Length(); i++) + { B.Add(aCompShells, aSeqShells.Value(i)); + } for (int n1 = 1; n1 <= aErrFaces.Length(); n1++) { TopoDS_Shell aSh; @@ -1428,8 +1582,10 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, } } if (OpenShells.Length() > 1) + { // Attempt of creation closed shell from open shells with taking into account multiconnexity. CreateClosedShell(OpenShells, aMapMultiConnectEdges); + } aSeqShells.Append(OpenShells); } @@ -1452,7 +1608,9 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, CreateNonManifoldShells(aSeqShells, aMapMultiConnectEdges); } if (!done) + { done = (aSeqShells.Length() > 1 || aIsDone); + } if (aSeqShells.Length() == 1) { myShell = TopoDS::Shell(aSeqShells.Value(1)); @@ -1465,7 +1623,9 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, TopoDS_Compound aCompShells; B.MakeCompound(aCompShells); for (int i = 1; i <= aSeqShells.Length(); i++) + { B.Add(aCompShells, aSeqShells.Value(i)); + } myShape = aCompShells; myNbShells = aSeqShells.Length(); } @@ -1473,17 +1633,23 @@ bool ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell, { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); if (!Context().IsNull()) + { Context()->Replace(shell, myShape); + } if (myNbShells == 1) + { // clang-format off SendWarning ( Message_Msg ( "FixAdvShell.FixOrientation.MSG0" ) );// Faces were incorrectly oriented in the shell, corrected - else + } else { SendWarning ( Message_Msg ( "FixAdvShell.FixOrientation.MSG30" ) );// Improperly connected shell split into parts +} // clang-format on return true; } else + { return false; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Solid.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Solid.cxx index 3505d62b95..b8681e540b 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Solid.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Solid.cxx @@ -133,7 +133,9 @@ static void CollectSolids( TopoDS_Shell aShell1 = TopoDS::Shell(aSeqShells.Value(i)); TopExp_Explorer aExpEdges(aShell1, TopAbs_EDGE); if (!BRep_Tool::IsClosed(aShell1) || !aExpEdges.More()) + { continue; + } TopoDS_Solid solid; BRep_Builder B; B.MakeSolid(solid); @@ -151,34 +153,50 @@ static void CollectSolids( infinstatus = bsc3d.State(); if (infinstatus != TopAbs_UNKNOWN && infinstatus != TopAbs_ON) + { st = (infinstatus == TopAbs_IN ? 1 : 2); + } theMapStatus.Bind(aShell1, st); } else { st = theMapStatus.Find(aShell1); if (st) + { infinstatus = (theMapStatus.Find(aShell1) == 1 ? TopAbs_IN : TopAbs_OUT); + } } if (!st) + { continue; + } for (int j = 1; j <= aSeqShells.Length(); j++) { if (i == j) + { continue; + } const TopoDS_Shape& aShell2 = aSeqShells.Value(j); if (!BRep_Tool::IsClosed(aShell2)) + { continue; + } if (aMapHoles.Contains(aShell2)) + { continue; + } if (aMapShellHoles.IsBound(aShell2)) { bool isAnalysis = false; const NCollection_List& ls = aMapShellHoles.Find(aShell2); for (NCollection_List::Iterator li(ls); li.More() && !isAnalysis; li.Next()) + { isAnalysis = li.Value().IsSame(aShell1); + } if (isAnalysis) + { continue; + } } TopAbs_State pointstatus = TopAbs_UNKNOWN; int numon = 0; @@ -186,7 +204,9 @@ static void CollectSolids( for (TopExp_Explorer aExpVert(aShell2, TopAbs_VERTEX); aExpVert.More() && amapVert.Extent() < 10; aExpVert.Next()) + { amapVert.Add(aExpVert.Current()); + } for (int k = 1; k <= amapVert.Extent() && (pointstatus == TopAbs_UNKNOWN || (pointstatus == TopAbs_ON && numon < 3)); @@ -197,7 +217,9 @@ static void CollectSolids( bsc3d.Perform(aPf, Precision::Confusion()); pointstatus = bsc3d.State(); if (pointstatus == TopAbs_ON) + { numon++; + } } if (numon == 3 && pointstatus == TopAbs_ON) @@ -213,9 +235,13 @@ static void CollectSolids( { aMapShellHoles.ChangeFind(aShell1).Append(aShell2); if (aMapHoles.Contains(aShell2)) + { aMapHoles.Remove(aShell2); + } else + { aMapHoles.Add(aShell2); + } } } } @@ -235,10 +261,14 @@ static void CollectSolids( for (; aItShellHoles.More(); aItShellHoles.Next()) { if (aMapHoles.Contains(aItShellHoles.Key())) + { continue; + } const NCollection_List& lHoles = aItShellHoles.Value(); if (lHoles.IsEmpty()) + { continue; + } for (NCollection_List::Iterator lItHoles(lHoles); lItHoles.More(); lItHoles.Next()) { @@ -247,14 +277,18 @@ static void CollectSolids( const NCollection_List& lUnHoles = aMapShellHoles.Find(lItHoles.Value()); for (NCollection_List::Iterator lItUnHoles(lUnHoles); lItUnHoles.More(); lItUnHoles.Next()) + { aMapHoles.Remove(lItUnHoles.Value()); + } } } } for (NCollection_Map::Iterator aIterHoles(aMapHoles); aIterHoles.More(); aIterHoles.Next()) + { aMapShellHoles.UnBind(aIterHoles.Key()); + } for (int i = 1; i <= aSeqShells.Length(); ++i) { @@ -304,7 +338,9 @@ static bool CreateSolids(const TopoDS_Shape& { int st = aMapStatus.Find(aShell); if (st) + { infinstatus = (aMapStatus.Find(aShell) == 1 ? TopAbs_IN : TopAbs_OUT); + } } else @@ -374,7 +410,9 @@ static bool CreateSolids(const TopoDS_Shape& { const NCollection_List& lshells = aMapFaceShells.FindFromIndex(i); if (lshells.Extent() < 2) + { continue; + } TopoDS_CompSolid aCompSolid; BRep_Builder aB; aB.MakeCompSolid(aCompSolid); @@ -400,13 +438,19 @@ static bool CreateSolids(const TopoDS_Shape& for (NCollection_List::Iterator lItSh1(lshells); lItSh1.More(); lItSh1.Next()) { if (ShellSolid.Contains(lItSh1.Value())) + { ShellSolid.ChangeFromKey(lItSh1.Value()) = aCompSolid; + } } } } for (int kk = 1; kk <= ShellSolid.Extent(); kk++) + { if (!aMapSolids.Contains(ShellSolid.FindFromIndex(kk))) + { aMapSolids.Add(ShellSolid.FindFromIndex(kk)); + } + } isDone = (aMapSolids.Extent() > 1 || isDone); return isDone; } @@ -418,7 +462,9 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) bool status = false; if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } myFixShell->SetContext(Context()); int NbShells = 0; @@ -427,7 +473,9 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) // Calculate number of underlying shells int aNbShells = 0; for (TopExp_Explorer aExpSh(S, TopAbs_SHELL); aExpSh.More(); aExpSh.Next()) + { aNbShells++; + } // Start progress scope (no need to check if progress exists -- it is safe) Message_ProgressScope aPS(theProgress, "Fixing solid stage", 2); @@ -454,7 +502,9 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) // Halt algorithm in case of user's abort if (!aPSFixShell.More()) + { return false; + } } else { @@ -481,9 +531,13 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) int numedge = 0; TopExp_Explorer aExp1(aC1, TopAbs_EDGE); for (; aExp1.More(); aExp1.Next()) + { numedge++; + } for (aExp1.Init(aC2, TopAbs_EDGE); aExp1.More(); aExp1.Next()) + { numedge++; + } isClosed = (!numedge); aShtmp.Closed(isClosed); } @@ -493,7 +547,9 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) TopoDS_Iterator itersh(tmpShape); TopoDS_Shell aShell; if (itersh.More() && itersh.Value().ShapeType() == TopAbs_SHELL) + { aShell = TopoDS::Shell(itersh.Value()); + } if (!aShell.IsNull()) { TopoDS_Solid aSol = SolidFromShell(aShell); @@ -540,8 +596,10 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) { mySolid = aResSol; if (aResSol.ShapeType() == TopAbs_SHELL) + { // clang-format off SendFail (Message_Msg ("FixAdvSolid.FixShell.MSG10")); // Solid can not be created from open shell. +} } Context()->Replace(aResShape,mySolid); } @@ -566,13 +624,17 @@ bool ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) aResSh = solid; } else if (aResShape.ShapeType() == TopAbs_SHELL) + { // clang-format off SendFail(Message_Msg ("FixAdvSolid.FixShell.MSG10")); // Solid can not be created from open shell. +} // clang-format on aB.Add(aComp, aResSh); } if (!aPSCreatingSolid.More()) + { return false; // aborted execution + } Context()->Replace(aResShape, aComp); } } @@ -594,7 +656,9 @@ TopoDS_Solid ShapeFix_Solid::SolidFromShell(const TopoDS_Shell& shell) { TopoDS_Shell sh = shell; if (!sh.Free()) + { sh.Free(true); + } TopoDS_Solid solid; BRep_Builder B; @@ -614,7 +678,9 @@ TopoDS_Solid ShapeFix_Solid::SolidFromShell(const TopoDS_Shell& shell) // (l inversion du solide n est pas bien prise en compte) sh = shell; if (!sh.Free()) + { sh.Free(true); + } TopoDS_Solid soli2; B.MakeSolid(soli2); // on recommence sh.Reverse(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitCommonVertex.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitCommonVertex.cxx index 95751ae854..0d56ce3747 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitCommonVertex.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitCommonVertex.cxx @@ -50,7 +50,9 @@ void ShapeFix_SplitCommonVertex::Init(const TopoDS_Shape& S) { myShape = S; if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } myResult = myShape; Context()->Apply(myShape); } @@ -61,23 +63,31 @@ void ShapeFix_SplitCommonVertex::Perform() { TopAbs_ShapeEnum st = myShape.ShapeType(); if (st > TopAbs_FACE) + { return; + } for (TopExp_Explorer itf(myShape, TopAbs_FACE); itf.More(); itf.Next()) { TopoDS_Shape tmpFace = Context()->Apply(itf.Current()); TopoDS_Face F = TopoDS::Face(tmpFace); if (F.IsNull()) + { continue; + } // analys face and split if necessary NCollection_Sequence wires; for (TopoDS_Iterator itw(F, false); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } wires.Append(itw.Value()); } if (wires.Length() < 2) + { continue; + } NCollection_DataMap MapVV; MapVV.Clear(); for (int nw1 = 1; nw1 < wires.Length(); nw1++) @@ -141,7 +151,9 @@ void ShapeFix_SplitCommonVertex::Perform() } } if (!MapVV.IsEmpty()) + { SendWarning(Message_Msg("Fix.SplitCommonVertex.MSG0")); + } } myShape = Context()->Apply(myShape); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitTool.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitTool.cxx index 46fb354c02..2c5d22c4ac 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitTool.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_SplitTool.cxx @@ -57,7 +57,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, occ::handle c2d; sae.PCurve(edge, face, c2d, a, b, true); if (std::abs(a - param) < tol2d || std::abs(b - param) < tol2d) + { return false; + } // check distance between edge and new vertex gp_Pnt P1; TopLoc_Location L; @@ -66,10 +68,14 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, double f, l; const occ::handle c3d = BRep_Tool::Curve(edge, L, f, l); if (c3d.IsNull()) + { return false; + } P1 = c3d->Value(param); if (!L.IsIdentity()) + { P1 = P1.Transformed(L.Transformation()); + } } else { @@ -77,7 +83,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, occ::handle sas = new ShapeAnalysis_Surface(surf); P1 = sas->Value(c2d->Value(param)); if (!L.IsIdentity()) + { P1 = P1.Transformed(L.Transformation()); + } } gp_Pnt P2 = BRep_Tool::Pnt(vert); if (P1.Distance(P2) > tol3d) @@ -202,13 +210,17 @@ bool ShapeFix_SplitTool::CutEdge(const TopoDS_Edge& edge, bool& iscutline) const { if (std::abs(cut - pend) < 10. * Precision::PConfusion()) + { return false; + } double aRange = std::abs(cut - pend); double a, b; BRep_Tool::Range(edge, a, b); iscutline = false; if (aRange < 10. * Precision::PConfusion()) + { return false; + } // case pcurve is trimm of line if (!BRep_Tool::SameParameter(edge)) @@ -229,7 +241,9 @@ bool ShapeFix_SplitTool::CutEdge(const TopoDS_Edge& edge, { // cut from the beginning double cut3d = (cut - fp) * (b - a) / (lp - fp); if (cut3d <= Precision::PConfusion()) + { return false; + } B.Range(edge, a + cut3d, b, true); iscutline = true; } @@ -237,7 +251,9 @@ bool ShapeFix_SplitTool::CutEdge(const TopoDS_Edge& edge, { // cut from the end double cut3d = (lp - cut) * (b - a) / (lp - fp); if (cut3d <= Precision::PConfusion()) + { return false; + } B.Range(edge, a, b - cut3d, true); iscutline = true; } @@ -249,9 +265,13 @@ bool ShapeFix_SplitTool::CutEdge(const TopoDS_Edge& edge, // det-study on 03/12/01 checking the old and new ranges if (std::abs(std::abs(a - b) - aRange) < Precision::PConfusion()) + { return false; + } if (aRange < 10. * Precision::PConfusion()) + { return false; + } occ::handle c = BRep_Tool::Curve(edge, a, b); ShapeAnalysis_Curve sac; @@ -296,7 +316,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, const double tol2d) const { if (fabs(lp - fp) < tol2d) + { return false; + } aNum = 0; SeqE.Clear(); BRep_Builder B; @@ -335,7 +357,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, { double newtol = tolVF + PVF.Distance(PV2); if (tolV2 < newtol) + { B.UpdateVertex(V2, newtol); + } if (VF.Orientation() == V2.Orientation()) { context->Replace(VF, V2); @@ -348,7 +372,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, } newtol = tolVL + PVL.Distance(PV1); if (tolV1 < newtol) + { B.UpdateVertex(V1, newtol); + } if (VL.Orientation() == V1.Orientation()) { context->Replace(VL, V1); @@ -364,7 +390,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, { double newtol = tolVF + PVF.Distance(PV1); if (tolV1 < newtol) + { B.UpdateVertex(V1, newtol); + } if (VF.Orientation() == V1.Orientation()) { context->Replace(VF, V1); @@ -377,7 +405,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, } newtol = tolVL + PVL.Distance(PV2); if (tolV2 < newtol) + { B.UpdateVertex(V2, newtol); + } if (VL.Orientation() == V2.Orientation()) { context->Replace(VL, V2); @@ -399,10 +429,14 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, if (IsReverse) { if (!SplitEdge(edge, par2, V1, face, newE1, newE2, tol3d, tol2d)) + { return false; + } double newtol = tolVF + PVF.Distance(PV2); if (tolV2 < newtol) + { B.UpdateVertex(V2, newtol); + } if (VF.Orientation() == V2.Orientation()) { context->Replace(VF, V2); @@ -417,10 +451,14 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, else { if (!SplitEdge(edge, par2, V2, face, newE1, newE2, tol3d, tol2d)) + { return false; + } double newtol = tolVF + PVF.Distance(PV1); if (tolV1 < newtol) + { B.UpdateVertex(V1, newtol); + } if (VF.Orientation() == V1.Orientation()) { context->Replace(VF, V1); @@ -443,10 +481,14 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, if (IsReverse) { if (!SplitEdge(edge, par1, V2, face, newE1, newE2, tol3d, tol2d)) + { return false; + } double newtol = tolVL + PVL.Distance(PV1); if (tolV1 < newtol) + { B.UpdateVertex(V1, newtol); + } if (VL.Orientation() == V1.Orientation()) { context->Replace(VL, V1); @@ -461,10 +503,14 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, else { if (!SplitEdge(edge, par1, V1, face, newE1, newE2, tol3d, tol2d)) + { return false; + } double newtol = tolVL + PVL.Distance(PV2); if (tolV2 < newtol) + { B.UpdateVertex(V2, newtol); + } if (VL.Orientation() == V2.Orientation()) { context->Replace(VL, V2); @@ -487,16 +533,24 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, if (IsReverse) { if (!SplitEdge(edge, par1, V2, face, newE1, newE2, tol3d, tol2d)) + { return false; + } if (!SplitEdge(newE2, par2, V1, face, newE3, newE4, tol3d, tol2d)) + { return false; + } } else { if (!SplitEdge(edge, par1, V1, face, newE1, newE2, tol3d, tol2d)) + { return false; + } if (!SplitEdge(newE2, par2, V2, face, newE3, newE4, tol3d, tol2d)) + { return false; + } } SeqE.Append(newE1); SeqE.Append(newE3); @@ -505,7 +559,9 @@ bool ShapeFix_SplitTool::SplitEdge(const TopoDS_Edge& edge, } if (aNum == 0) + { return false; + } occ::handle sewd = new ShapeExtend_WireData; for (int i = 1; i <= SeqE.Length(); i++) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire.cxx index df36a20afb..03c7ba07f2 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire.cxx @@ -266,7 +266,9 @@ void ShapeFix_Wire::Load(const occ::handle& sbwd) ClearStatuses(); myAnalyzer->Load(sbwd); if (!Context().IsNull()) + { UpdateWire(); + } myShape.Nullify(); } @@ -296,10 +298,14 @@ bool ShapeFix_Wire::Perform(const Message_ProgressRange& theProgress) { ClearStatuses(); if (!IsLoaded()) + { return false; + } if (!Context().IsNull()) + { myFixEdge->SetContext(Context()); + } bool Fixed = false; @@ -312,12 +318,16 @@ bool ShapeFix_Wire::Perform(const Message_ProgressRange& theProgress) if (NeedFix(myFixReorderMode, !ReorderOK)) { if (FixReorder()) + { Fixed = true; + } ReorderOK = !StatusReorder(ShapeExtend_FAIL); } if (theProgress.UserBreak()) + { return false; + } // FixSmall is allowed to change topology only if mode is set and FixReorder // did not failed @@ -336,50 +346,70 @@ bool ShapeFix_Wire::Perform(const Message_ProgressRange& theProgress) } if (theProgress.UserBreak()) + { return false; + } if (NeedFix(myFixConnectedMode, ReorderOK)) { if (FixConnected()) + { Fixed = true; + } } if (theProgress.UserBreak()) + { return false; + } if (NeedFix(myFixEdgeCurvesMode)) { int savFixShiftedMode = myFixShiftedMode; // turn out FixShifted if reorder not done if (myFixShiftedMode == -1 && !ReorderOK) + { myFixShiftedMode = 0; + } if (FixEdgeCurves()) + { Fixed = true; + } myFixShiftedMode = savFixShiftedMode; } if (theProgress.UserBreak()) + { return false; + } if (NeedFix(myFixDegeneratedMode)) { if (FixDegenerated()) + { Fixed = true; // ?? if ! ReorderOK ?? + } } if (theProgress.UserBreak()) + { return false; + } // pdn - temporary to test if (myFixTailMode <= 0 && NeedFix(myFixNotchedEdgesMode, ReorderOK)) { Fixed |= FixNotchedEdges(); if (Fixed) + { FixShifted(); // skl 07.03.2002 for OCC180 + } } if (theProgress.UserBreak()) + { return false; + } if (myFixTailMode != 0) { @@ -391,31 +421,43 @@ bool ShapeFix_Wire::Perform(const Message_ProgressRange& theProgress) } if (theProgress.UserBreak()) + { return false; + } if (NeedFix(myFixSelfIntersectionMode, myClosedMode)) { int savFixIntersectingEdgesMode = myFixIntersectingEdgesMode; // switch off FixIntEdges if reorder not done if (myFixIntersectingEdgesMode == -1 && !ReorderOK) + { myFixIntersectingEdgesMode = 0; + } if (FixSelfIntersection()) + { Fixed = true; + } FixReorder(); myFixIntersectingEdgesMode = savFixIntersectingEdgesMode; } if (theProgress.UserBreak()) + { return false; + } if (NeedFix(myFixLackingMode, ReorderOK)) { if (FixLacking()) + { Fixed = true; + } } if (theProgress.UserBreak()) + { return false; + } // TEMPORARILY without special mode !!! occ::handle sbwd = WireData(); @@ -428,10 +470,14 @@ bool ShapeFix_Wire::Perform(const Message_ProgressRange& theProgress) } if (theProgress.UserBreak()) + { return false; + } if (!Context().IsNull()) + { UpdateWire(); + } return Fixed; } @@ -493,7 +539,9 @@ int ShapeFix_Wire::FixSmall(const bool lockvtx, const double precsmall) { myStatusSmall = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded()) + { return false; + } for (int i = NbEdges(); i > 0; i--) { @@ -510,7 +558,9 @@ bool ShapeFix_Wire::FixConnected(const double prec) { myStatusConnected = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded()) + { return false; + } int stop = (myClosedMode ? 0 : 1); for (int i = NbEdges(); i > stop; i--) @@ -523,7 +573,9 @@ bool ShapeFix_Wire::FixConnected(const double prec) // Update wire once after all connections are fixed // Using Value() in UpdateWire() prevents edge explosion from replacement chains if (!Context().IsNull()) + { UpdateWire(); + } return StatusConnected(ShapeExtend_DONE); } @@ -534,7 +586,9 @@ bool ShapeFix_Wire::FixEdgeCurves() { myStatusEdgeCurves = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded()) + { return false; + } bool isReady = IsReady(); occ::handle sbwd = WireData(); @@ -542,7 +596,9 @@ bool ShapeFix_Wire::FixEdgeCurves() TopoDS_Face face = Face(); occ::handle theAdvFixEdge = myFixEdge; if (theAdvFixEdge.IsNull()) + { myFixReversed2dMode = false; + } // fix revesred 2d / 3d curves if (isReady && NeedFix(myFixReversed2dMode)) @@ -551,9 +607,13 @@ bool ShapeFix_Wire::FixEdgeCurves() { theAdvFixEdge->FixReversed2d(sbwd->Edge(i), face); if (theAdvFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (theAdvFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } } } @@ -564,9 +624,13 @@ bool ShapeFix_Wire::FixEdgeCurves() { myFixEdge->FixRemovePCurve(sbwd->Edge(i), face); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } } } @@ -581,9 +645,13 @@ bool ShapeFix_Wire::FixEdgeCurves() myAnalyzer->Surface(), Precision()); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } // if ( !sbwd->IsSeam(i) && myFixEdge->Status ( ShapeExtend_DONE2 ) // && BRep_Tool::SameParameter(sbwd->Edge(i)) ) { @@ -623,10 +691,14 @@ bool ShapeFix_Wire::FixEdgeCurves() break; } else if (split < seq(k) + ::Precision::PConfusion()) + { break; + } } if (k > seq.Length()) + { seq.Append(split); + } } } } @@ -644,7 +716,9 @@ bool ShapeFix_Wire::FixEdgeCurves() // 10.04.2003 skl for using trimmed lines as pcurves ShapeAnalysis_Edge sae; if (BRep_Tool::SameParameter(sbwd->Edge(i))) + { sbe.RemovePCurve(E, face); + } else { if (sae.HasPCurve(E, face)) @@ -654,7 +728,9 @@ bool ShapeFix_Wire::FixEdgeCurves() if (sae.PCurve(E, face, C2d, fp2d, lp2d)) { if (!C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { sbe.RemovePCurve(E, face); + } } } } @@ -750,7 +826,9 @@ bool ShapeFix_Wire::FixEdgeCurves() double cf, cl; occ::handle c2d; if (!sae.PCurve(sbwd->Edge(k), face, c2d, cf, cl, true)) + { break; + } vec += c2d->Value(cl).XY() - c2d->Value(cf).XY(); } if (k > nb && std::abs(std::abs(vec.X()) - URange) < 0.1 * URange) @@ -776,9 +854,13 @@ bool ShapeFix_Wire::FixEdgeCurves() { myFixEdge->FixRemoveCurve3d(sbwd->Edge(i)); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL4); + } } } if (NeedFix(myFixAddCurve3dMode)) @@ -787,7 +869,9 @@ bool ShapeFix_Wire::FixEdgeCurves() { myFixEdge->FixAddCurve3d(sbwd->Edge(i)); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE5); + } if (myFixEdge->Status(ShapeExtend_FAIL)) { //: abv 29.08.01: Spatial_firex_lofting.sat: if 3d curve cannot @@ -826,9 +910,13 @@ bool ShapeFix_Wire::FixEdgeCurves() { FixSeam(i); if (LastFixStatus(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE6); + } if (LastFixStatus(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL6); + } } } @@ -837,9 +925,13 @@ bool ShapeFix_Wire::FixEdgeCurves() { FixShifted(); if (LastFixStatus(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE7); + } if (LastFixStatus(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL7); + } } // fix same parameter @@ -875,17 +967,25 @@ bool ShapeFix_Wire::FixEdgeCurves() myAnalyzer->Surface(), Precision()); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } } } } myFixEdge->FixSameParameter(sbwd->Edge(i), Face()); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE8); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL8); + } } } @@ -897,12 +997,18 @@ bool ShapeFix_Wire::FixEdgeCurves() { myFixEdge->FixVertexTolerance(sbwd->Edge(i), Face()); if (myFixEdge->Status(ShapeExtend_DONE)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_DONE8); + } if (myFixEdge->Status(ShapeExtend_FAIL)) + { myStatusEdgeCurves |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL8); + } } if (!Context().IsNull()) + { UpdateWire(); + } } return StatusEdgeCurves(ShapeExtend_DONE); @@ -914,7 +1020,9 @@ bool ShapeFix_Wire::FixDegenerated() { myStatusDegenerated = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } // if ( ! myAnalyzer->Surface()->HasSingularities ( Precision() ) ) return; @@ -927,19 +1035,25 @@ bool ShapeFix_Wire::FixDegenerated() //: r0 abv 19 Mar 99: PRO7226.stp #489490: remove duplicated degenerated edges int coded = (LastFixStatus(ShapeExtend_DONE2) ? 1 : 0); if (lastcoded == -1) + { lastcoded = coded; + } if (coded && (prevcoded || (i == 1 && lastcoded)) && NbEdges() > 1) { occ::handle sbwd = WireData(); BRep_Builder B; sbwd->Remove(i); if (!prevcoded) + { i = NbEdges(); + } B.Degenerated(sbwd->Edge(i++), false); prevcoded = 0; } else + { prevcoded = coded; + } } return StatusDegenerated(ShapeExtend_DONE); @@ -955,7 +1069,9 @@ bool ShapeFix_Wire::FixSelfIntersection() { myStatusSelfIntersection = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } occ::handle sbwd = WireData(); int nb = sbwd->NbEdges(); @@ -963,11 +1079,13 @@ bool ShapeFix_Wire::FixSelfIntersection() if (NeedFix(myFixSelfIntersectingEdgeMode)) { if (myRemoveLoopMode < 1) + { for (int num = 1; num <= nb; num++) { FixSelfIntersectingEdge(num); myStatusSelfIntersection |= myLastFixStatus; } + } else if (myRemoveLoopMode == 1) { for (int num = 1; num <= nb; num++) @@ -975,7 +1093,9 @@ bool ShapeFix_Wire::FixSelfIntersection() FixSelfIntersectingEdge(num); myStatusSelfIntersection |= myLastFixStatus; if (nb < sbwd->NbEdges()) + { num--; + } nb = sbwd->NbEdges(); } FixClosed(Precision()); @@ -989,18 +1109,30 @@ bool ShapeFix_Wire::FixSelfIntersection() { FixIntersectingEdges(num); if (LastFixStatus(ShapeExtend_FAIL1)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } if (LastFixStatus(ShapeExtend_FAIL2)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } if (!LastFixStatus(ShapeExtend_DONE)) + { continue; + } if (LastFixStatus(ShapeExtend_DONE1)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (LastFixStatus(ShapeExtend_DONE2)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (LastFixStatus(ShapeExtend_DONE6)) + { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE6); + } if (/*! myTopoMode ||*/ nb < 3) { @@ -1009,15 +1141,21 @@ bool ShapeFix_Wire::FixSelfIntersection() //%15 pdn 06.04.99 repeat until fixed CTS18546-2 entity 777 // if the tolerance was modified we should recheck the result, if it was enough - if (LastFixStatus(ShapeExtend_DONE7)) // num--; + if (LastFixStatus(ShapeExtend_DONE7)) + { // num--; FixIntersectingEdges(num); + } continue; } if (LastFixStatus(ShapeExtend_DONE4)) + { sbwd->Remove(num); + } if (LastFixStatus(ShapeExtend_DONE3)) + { sbwd->Remove(num > 1 ? num - 1 : nb + num - 1); + } if (LastFixStatus(ShapeExtend_DONE4) || LastFixStatus(ShapeExtend_DONE3)) { myStatusSelfIntersection |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); @@ -1038,7 +1176,9 @@ bool ShapeFix_Wire::FixSelfIntersection() } } if (!Context().IsNull()) + { UpdateWire(); + } } // pdn 17.03.99 S4135 to avoid regression fixing not adjacent intersection @@ -1054,12 +1194,16 @@ bool ShapeFix_Wire::FixSelfIntersection() if (NbSplit > 0 || NbRemoved > 0) { if (NbRemoved > 0) + { myStatusRemovedSegment = true; + } // Load(sbwd); commented by skl 29.12.2004 for OCC7624, instead this // string inserted following three strings: myAnalyzer->Load(sbwd); if (!Context().IsNull()) + { UpdateWire(); + } myShape.Nullify(); } #ifdef OCCT_DEBUG @@ -1126,7 +1270,9 @@ bool ShapeFix_Wire::FixLacking(const bool force) { myStatusLacking = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } int start = (myClosedMode ? 1 : 2); for (int i = start; i <= NbEdges(); i++) @@ -1144,25 +1290,39 @@ bool ShapeFix_Wire::FixClosed(const double prec) { myStatusClosed = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() < 1) + { return false; + } FixConnected(1, prec); if (LastFixStatus(ShapeExtend_DONE)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (LastFixStatus(ShapeExtend_FAIL)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } FixDegenerated(1); if (LastFixStatus(ShapeExtend_DONE)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (LastFixStatus(ShapeExtend_FAIL)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } FixLacking(1); if (LastFixStatus(ShapeExtend_DONE)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } if (LastFixStatus(ShapeExtend_FAIL)) + { myStatusClosed |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } return StatusClosed(ShapeExtend_DONE); } @@ -1177,11 +1337,15 @@ bool ShapeFix_Wire::FixReorder(const ShapeAnalysis_WireOrder& wi) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded()) + { return false; + } int status = wi.Status(); if (status == 0) + { return false; + } if (status <= -10) { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); @@ -1208,9 +1372,13 @@ bool ShapeFix_Wire::FixReorder(const ShapeAnalysis_WireOrder& wi) occ::handle> newedges = new NCollection_HSequence(); for (i = 1; i <= nb; i++) + { newedges->Append(sbwd->Edge(wi.Ordered(i))); + } for (i = 1; i <= nb; i++) + { sbwd->Set(TopoDS::Edge(newedges->Value(i)), i); + } myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); return true; @@ -1222,12 +1390,16 @@ bool ShapeFix_Wire::FixSmall(const int num, const bool lockvtx, const double pre { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() <= 1) + { return false; + } // analysis: occ::handle theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) + { return false; + } int n = (num > 0 ? num : NbEdges()); theAdvAnalyzer->CheckSmall(n, precsmall); if (theAdvAnalyzer->LastCheckStatus(ShapeExtend_FAIL)) @@ -1237,7 +1409,9 @@ bool ShapeFix_Wire::FixSmall(const int num, const bool lockvtx, const double pre } if (!theAdvAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } // OUI cette edge est NULLE @@ -1252,11 +1426,15 @@ bool ShapeFix_Wire::FixSmall(const int num, const bool lockvtx, const double pre myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); } else + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } // action: remove edge if (!Context().IsNull()) + { Context()->Remove(WireData()->Edge(n)); + } // clang-format off SendWarning ( WireData()->Edge ( n ), Message_Msg ( "FixAdvWire.FixSmall.MSG0" ) ); //Small edge(s) removed // clang-format on @@ -1269,7 +1447,9 @@ bool ShapeFix_Wire::FixSmall(const int num, const bool lockvtx, const double pre // #43 rln 20.11.98 S4054 CTS18544 entity 21734 removing last edge FixConnected(n <= NbEdges() ? n : 1, precsmall); if (LastFixStatus(ShapeExtend_FAIL)) + { savLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL3); + } myLastFixStatus = savLastFixStatus; } @@ -1282,7 +1462,9 @@ bool ShapeFix_Wire::FixConnected(const int num, const double prec, const bool th { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsLoaded() || NbEdges() <= 0) + { return false; + } // analysis myAnalyzer->CheckConnected(num, prec < 0 ? MaxTolerance() : prec); @@ -1291,7 +1473,9 @@ bool ShapeFix_Wire::FixConnected(const int num, const double prec, const bool th myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } if (!myAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } // action: replacing vertex occ::handle sbwd = WireData(); @@ -1313,21 +1497,29 @@ bool ShapeFix_Wire::FixConnected(const int num, const double prec, const bool th { V = V2; if (!Context().IsNull()) + { Context()->Replace(V1, V.Oriented(V1.Orientation())); + } } else { V = V1; if (!Context().IsNull()) + { Context()->Replace(V2, V.Oriented(V2.Orientation())); + } } } else { // on moyenne ... if (myAnalyzer->LastCheckStatus(ShapeExtend_DONE2)) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } else + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } ShapeBuild_Vertex sbv; V = sbv.CombineVertex(V1, V2, 1.0001); if (!Context().IsNull()) @@ -1354,7 +1546,9 @@ bool ShapeFix_Wire::FixConnected(const int num, const double prec, const bool th TopoDS_Edge tmpE = sbe.CopyReplaceVertices(E2, V, V); sbwd->Set(tmpE, n2); if (!Context().IsNull()) + { Context()->Replace(E2, tmpE); + } } } else @@ -1376,21 +1570,27 @@ bool ShapeFix_Wire::FixConnected(const int num, const double prec, const bool th TopoDS_Edge tmpE2 = sbe.CopyReplaceVertices(E2, V, TopoDS_Vertex()); sbwd->Set(tmpE2, n2); if (!Context().IsNull()) + { Context()->Replace(E2, tmpE2); + } if (!myAnalyzer->LastCheckStatus(ShapeExtend_DONE1) || sae.FirstVertex(E2).IsSame(sae.LastVertex(E2))) { TopoDS_Edge tmpE1 = sbe.CopyReplaceVertices(E1, TopoDS_Vertex(), V); sbwd->Set(tmpE1, n1); if (!Context().IsNull()) + { Context()->Replace(E1, tmpE1); + } } } } // Optionally update wire data with context replacements if (theUpdateWire && !Context().IsNull()) + { UpdateWire(); + } return true; } @@ -1401,12 +1601,16 @@ bool ShapeFix_Wire::FixSeam(const int num) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } occ::handle C1, C2; double cf, cl; if (!myAnalyzer->CheckSeam(num, C1, C2, cf, cl)) + { return false; + } BRep_Builder B; TopoDS_Edge E = WireData()->Edge(num > 0 ? num : NbEdges()); @@ -1443,7 +1647,9 @@ bool ShapeFix_Wire::FixShifted() { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } occ::handle surf = myAnalyzer->Surface(); // #78 rln 12.03.99 S4135: checking spatial closure with Precision @@ -1466,9 +1672,13 @@ bool ShapeFix_Wire::FixShifted() || (aBaseCrv->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)))) { if (aBaseCrv->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) + { aBaseCrv = occ::down_cast(aBaseCrv)->BasisCurve(); + } if (aBaseCrv->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { aBaseCrv = occ::down_cast(aBaseCrv)->BasisCurve(); + } } if (aBaseCrv->IsPeriodic()) { @@ -1483,7 +1693,9 @@ bool ShapeFix_Wire::FixShifted() } // PTV 26.06.2002 end if (!uclosed && !vclosed) + { return false; + } double URange, /*VRange,*/ SUF, SUL, SVF, SVL; surf->Surface()->Bounds(SUF, SUL, SVF, SVL); @@ -1491,15 +1703,23 @@ bool ShapeFix_Wire::FixShifted() SUMid = 0.5 * (SUF + SUL); SVMid = 0.5 * (SVF + SVL); if (uclosed) + { URange = std::abs(SUL - SUF); + } else + { URange = RealLast(); + } if (!IsVCrvClosed) { if (vclosed) + { VRange = std::abs(SVL - SVF); + } else + { VRange = RealLast(); + } } double UTol = 0.2 * URange, VTol = 0.2 * VRange; @@ -1510,7 +1730,9 @@ bool ShapeFix_Wire::FixShifted() { TopoDS_Edge E1 = sbwdOring->Edge(i); if (BRep_Tool::Degenerated(E1) && !sae.HasPCurve(E1, Face())) + { continue; + } sbwd->Add(E1); } @@ -1528,9 +1750,13 @@ bool ShapeFix_Wire::FixShifted() for (int n2 = 1, n1 = nb; !end; n1 = n2++) { if (n2 > nb) + { n2 = 1; + } if (n2 == stop) + { end = true; + } TopoDS_Edge E1 = sbwd->Edge(n1); TopoDS_Edge E2 = sbwd->Edge(n2); @@ -1547,7 +1773,9 @@ bool ShapeFix_Wire::FixShifted() TopoDS_Vertex V = sae.FirstVertex(E2); if (V.IsNull()) + { continue; + } gp_Pnt p = BRep_Tool::Pnt(V); @@ -1567,7 +1795,9 @@ bool ShapeFix_Wire::FixShifted() degP2, degT1, degT2)) + { isDeg = (std::abs(degP1.X() - degP2.X()) > std::abs(degP1.Y() - degP2.Y()) ? 1 : 2); + } // abv 23 Feb 00: UKI60107-6 210: additional check for near-degenerated case // smh#15 PRO19800. Check if the surface is surface of revolution. @@ -1576,30 +1806,32 @@ bool ShapeFix_Wire::FixShifted() if (!isDeg && !vclosed) { if (c2d1.IsNull() && !sae.PCurve(E1, Face(), c2d1, a1, b1, true)) + { continue; + } gp_Pnt2d p1(SUF, c2d1->Value(b1).Y()); gp_Pnt2d p2(SUL, c2d1->Value(b1).Y()); if (surf->IsDegenerated(p1, p2, MaxTolerance(), 10) - && !surf->IsDegenerated(c2d1->Value(a1), - c2d1->Value(b1), - MaxTolerance(), - 10)) // abv 31.07.00: trj4_pm1-ec-214.stp #31274: still allow - // work if edge already exists + && !surf->IsDegenerated(c2d1->Value(a1), c2d1->Value(b1), MaxTolerance(), 10)) + { // abv 31.07.00: trj4_pm1-ec-214.stp #31274: still allow + // work if edge already exists isDeg = 1; + } } if (!isDeg && !uclosed) { if (c2d1.IsNull() && !sae.PCurve(E1, Face(), c2d1, a1, b1, true)) + { continue; + } gp_Pnt2d p1(c2d1->Value(b1).X(), SVF); gp_Pnt2d p2(c2d1->Value(b1).X(), SVL); if (surf->IsDegenerated(p1, p2, MaxTolerance(), 10) - && !surf->IsDegenerated(c2d1->Value(a1), - c2d1->Value(b1), - MaxTolerance(), - 10)) // abv 31.07.00: trj4_pm1-ec-214.stp #31274: still allow - // work if edge already exists + && !surf->IsDegenerated(c2d1->Value(a1), c2d1->Value(b1), MaxTolerance(), 10)) + { // abv 31.07.00: trj4_pm1-ec-214.stp #31274: still allow + // work if edge already exists isDeg = 2; + } } } @@ -1692,12 +1924,18 @@ bool ShapeFix_Wire::FixShifted() for (int k = degn2;; k++) { if (k > nb) + { k = 1; + } if (k == n2) + { break; + } TopoDS_Edge edge = sbwd->Edge(k); if (!sae.PCurve(edge, Face(), cx1, ax1, bx1, true)) + { continue; + } // cx1->Transform ( Shift ); // skl 15.05.2002 for OCC208 (if few edges have reference to one pcurve) occ::handle cx1new = @@ -1766,20 +2004,30 @@ bool ShapeFix_Wire::FixShifted() { double dx = std::abs(p2d2.X() - p2d1.X()); if (dx > URange - UTol) + { du = ShapeAnalysis::AdjustByPeriod(p2d2.X(), p2d1.X(), URange); + } else if (dx > UTol && stop == nb) + { stop = n2; //: abv 29.08.01: torCuts2.stp + } } if (vclosed && isDeg != 2) { double dy = std::abs(p2d2.Y() - p2d1.Y()); if (dy > VRange - VTol) + { dv = ShapeAnalysis::AdjustByPeriod(p2d2.Y(), p2d1.Y(), VRange); + } else if (dy > VTol && stop == nb) + { stop = n2; + } } if (du == 0. && dv == 0.) + { continue; + } myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); gp_Trsf2d Shift; @@ -1791,13 +2039,17 @@ bool ShapeFix_Wire::FixShifted() UpdateEdgeUVPoints(E2, Face()); } if (box.IsVoid()) + { return false; // #3 smh 01.04.99. S4163: Overflow, when box is void. + } double umin, vmin, umax, vmax; box.Get(umin, vmin, umax, vmax); if (std::abs(umin + umax - SUF - SUL) < URange && std::abs(vmin + vmax - SVF - SVL) < VRange && !LastFixStatus(ShapeExtend_DONE)) + { return false; + } box.SetVoid(); int n; // svv Jan11 2000 : porting on DEC @@ -1806,7 +2058,9 @@ bool ShapeFix_Wire::FixShifted() double a, b; occ::handle c2d; if (!sae.PCurve(sbwd->Edge(n), Face(), c2d, a, b, true)) + { continue; + } box.Add(c2d->Value(a)); box.Add(c2d->Value(0.5 * (a + b))); } @@ -1830,7 +2084,9 @@ bool ShapeFix_Wire::FixShifted() } if (du == 0. && dv == 0.) + { return true; + } myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); @@ -1843,7 +2099,9 @@ bool ShapeFix_Wire::FixShifted() occ::handle c2d; TopoDS_Edge ed = sbwdOring->Edge(n); if (!sae.PCurve(ed, Face(), c2d, a, b, true)) + { continue; + } // skl 15.05.2002 for OCC208 (if few edges have reference to one pcurve) occ::handle c2d2 = occ::down_cast(c2d->Transformed(Shift)); sbe.ReplacePCurve(ed, c2d2, Face()); @@ -1858,7 +2116,9 @@ bool ShapeFix_Wire::FixDegenerated(const int num) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } // analysis gp_Pnt2d p2d1, p2d2; @@ -1876,7 +2136,9 @@ bool ShapeFix_Wire::FixDegenerated(const int num) return true; } if (!myAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } // action: create degenerated edge and insert it (or replace) @@ -1945,7 +2207,9 @@ static bool TryNewPCurve(const TopoDS_Edge& E, double f, l; occ::handle crv = BRep_Tool::Curve(E, f, l); if (crv.IsNull()) + { return false; + } // make temp edge and compute tolerance BRepBuilderAPI_MakeEdge mkedge(crv, f, l); @@ -1954,7 +2218,9 @@ static bool TryNewPCurve(const TopoDS_Edge& E, SBE.SetRange3d(mkedge, f, l); // skl 17.07.2001 if (!mkedge.IsDone()) + { return false; + } TopoDS_Edge edge = mkedge; BRep_Builder B; @@ -1988,7 +2254,9 @@ static int howMuchPCurves(const TopoDS_Edge& E) { const occ::handle& cr = itcr.Value(); if (cr->IsCurveOnSurface()) + { count++; + } itcr.Next(); } @@ -2006,7 +2274,9 @@ static bool RemoveLoop(TopoDS_Edge& E, { bool loopRemoved3d; if (BRep_Tool::IsClosed(E, face)) + { return false; + } double f, l; occ::handle crv = BRep_Tool::Curve(E, f, l); @@ -2024,7 +2294,9 @@ static bool RemoveLoop(TopoDS_Edge& E, double a, b; occ::handle c2d; if (!sae.PCurve(E, face, c2d, a, b, false)) + { return false; + } #ifdef OCCT_DEBUG std::cout << "Cut Loop: params (" << t1 << ", " << t2; @@ -2056,7 +2328,9 @@ static bool RemoveLoop(TopoDS_Edge& E, Pln = aPlaneSurf->Pln(); } else + { pcurve3d = GeomAPI::To3d(c2d, Pln); + } // first segment // occ::handle pcurve3d = GeomAPI::To3d ( c2d, Pln ); @@ -2079,18 +2353,24 @@ static bool RemoveLoop(TopoDS_Edge& E, occ::handle patch = new Geom_BSplineCurve(Poles, Knots, Mults, 1); if (!connect.Add(patch, ::Precision::PConfusion(), true, false)) + { return false; + } // last segment if (!connect.Add(trim, ::Precision::PConfusion(), true, false)) + { return false; + } // PTV OCC884 // keep created 3d curve occ::handle aNew3dCrv = connect.BSplineCurve(); occ::handle bs = GeomAPI::To2d(aNew3dCrv, Pln); if (bs.IsNull()) + { return false; + } // make temp edge and compute tolerance BRep_Builder B; @@ -2101,9 +2381,13 @@ static bool RemoveLoop(TopoDS_Edge& E, // OCC901 int nbC2d = howMuchPCurves(E); if (nbC2d <= 1 && !aPlaneSurf.IsNull()) + { B.UpdateEdge(E, bs, face, 0); + } else if (!TryNewPCurve(E, face, bs, a, b, newtol)) + { return false; + } double tol = BRep_Tool::Tolerance(E); #ifdef OCCT_DEBUG @@ -2111,18 +2395,24 @@ static bool RemoveLoop(TopoDS_Edge& E, << std::endl; #endif if (newtol > std::max(prec, tol)) + { return false; + } //: s2 bs = BRep_Tool::CurveOnSurface ( edge, face, a, b ); if (std::abs(a - f) > ::Precision::PConfusion() || // smth strange, cancel std::abs(b - l) > ::Precision::PConfusion()) + { return false; + } // PTV OCC884 if (!aPlaneSurf.IsNull()) { B.UpdateEdge(E, aNew3dCrv, std::max(newtol, tol)); // OCC901 if (!TryNewPCurve(E, face, bs, a, b, newtol)) + { return false; + } } B.UpdateEdge(E, bs, face, newtol); B.UpdateVertex(sae.FirstVertex(E), newtol); @@ -2184,21 +2474,29 @@ static bool RemoveLoop(TopoDS_Edge& E, occ::handle patch1 = new Geom_BSplineCurve(Poles1, Knots1, Mults1, 1); if (!connect1.Add(patch1, ::Precision::PConfusion(), true, false)) + { return false; + } // last segment if (!connect1.Add(trim1, ::Precision::PConfusion(), true, false)) + { return false; + } bs1 = connect1.BSplineCurve(); if (bs1.IsNull()) + { return false; + } } // double oldtol = BRep_Tool::Tolerance ( E ); if (!loopRemoved3d) + { B.UpdateEdge(E, bs1, L, 0.); + } B.UpdateEdge(E, bs, face, 0.); B.Range(E, face, f, l); B.SameRange(E, false); @@ -2222,7 +2520,9 @@ static bool RemoveLoop(TopoDS_Edge& E, #endif if (BRep_Tool::IsClosed(E, face)) + { return false; + } double f, l; occ::handle crv = BRep_Tool::Curve(E, f, l); @@ -2249,18 +2549,24 @@ static bool RemoveLoop(TopoDS_Edge& E, double a, b; occ::handle c2d; if (!sae.PCurve(E, face, c2d, a, b, false)) + { return false; + } // first segment for 2d curve occ::handle trim1; if ((t1 - a) > Precision::PConfusion()) + { trim1 = new Geom2d_TrimmedCurve(c2d, a, t1); + } // second segment for 2d curve occ::handle trim2 = new Geom2d_TrimmedCurve(c2d, t2, b); // if ( trim1.IsNull() || trim2.IsNull() ) if (trim2.IsNull()) + { return false; + } TopLoc_Location L; occ::handle S = BRep_Tool::Surface(face, L); @@ -2303,13 +2609,17 @@ static bool RemoveLoop(TopoDS_Edge& E, // trim for 3d curve 'crv' with parameters from 'f' to 'l' occ::handle trim3; if (!trim1.IsNull()) + { trim3 = new Geom_TrimmedCurve(crv, f, ftrim); + } // second segment for 3d curve occ::handle trim4 = new Geom_TrimmedCurve(crv, ltrim, l); // if ( trim3.IsNull() || trim4.IsNull() ) if (trim4.IsNull()) + { return false; + } // create a point for middle vertex gp_Pnt pnt1 = crv->Value(ftrim); @@ -2320,14 +2630,20 @@ static bool RemoveLoop(TopoDS_Edge& E, // create new copies for E1 and E2 if (!trim1.IsNull()) + { E1 = TopoDS::Edge(E.EmptyCopied()); + } E2 = TopoDS::Edge(E.EmptyCopied()); // initialize middle vertex Vmid if (trim1.IsNull()) + { B.MakeVertex(Vmid, pnt2, 0.); + } else + { B.MakeVertex(Vmid, Pmid, 0.); + } ShapeBuild_Edge sbe; @@ -2335,13 +2651,17 @@ static bool RemoveLoop(TopoDS_Edge& E, if (E.Orientation() == TopAbs_FORWARD) { if (!E1.IsNull()) + { E1 = sbe.CopyReplaceVertices(E1, Vfirst, Vmid); + } E2 = sbe.CopyReplaceVertices(E2, Vmid, Vlast); } else { if (!E1.IsNull()) + { E1 = sbe.CopyReplaceVertices(E1, Vmid, Vlast); + } E2 = sbe.CopyReplaceVertices(E2, Vfirst, Vmid); } @@ -2374,21 +2694,27 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } // analysis NCollection_Sequence points2d; NCollection_Sequence points3d; occ::handle theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) + { return false; + } theAdvAnalyzer->CheckSelfIntersectingEdge(num, points2d, points3d); if (theAdvAnalyzer->LastCheckStatus(ShapeExtend_FAIL)) { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } if (!theAdvAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } // action: increase tolerance of vertex @@ -2420,18 +2746,24 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) double dist21 = pnt1.SquareDistance(pint); double dist22 = pnt2.SquareDistance(pint); if (dist21 < tol1 * tol1 || dist22 < tol2 * tol2) + { continue; + } newtol = 1.001 * std::sqrt(std::min(dist21, dist22)); //: f8 //: k3 abv 24 Dec 98: BUC50070 #26682 and #30087: try to remove loop if (myGeomMode) { if (c2d.IsNull()) + { sae.PCurve(E, Face(), c2d, f2d, l2d, false); + } double firstpar = points2d.Value(i).ParamOnFirst(); double lastpar = points2d.Value(i).ParamOnSecond(); if (firstpar > prevFirst && lastpar < prevLast) + { continue; + } if (RemoveLoop(E, Face(), points2d.Value(i), @@ -2451,12 +2783,18 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); BRep_Builder B; if (dist21 < dist22) + { B.UpdateVertex(V1, tol1 = newtol); + } else + { B.UpdateVertex(V2, tol2 = newtol); + } } else + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } } // after RemoveLoop, check that self-intersection disappeared @@ -2466,7 +2804,9 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) NCollection_Sequence pnts3d; theAdvAnalyzer->CheckSelfIntersectingEdge(num, pnts2d, pnts3d); if (!theAdvAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { break; + } // points3d.Append(pnts3d); // points2d.Append(pnts2d); points3d = pnts3d; @@ -2499,7 +2839,9 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) if (myGeomMode) { if (c2d.IsNull()) + { sae.PCurve(E, Face(), c2d, f2d, l2d, false); + } TopoDS_Edge E1; if (RemoveLoop(E, Face(), points2d.Value(1), E1, E2)) { @@ -2511,14 +2853,18 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) newtol = std::max(BRep_Tool::Tolerance(E1), BRep_Tool::Tolerance(E2)); } else + { newtol = BRep_Tool::Tolerance(E2); + } } } TTSS->Append(E2); if (newtol > MaxTolerance()) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } ShapeExtend_WireData sewd; for (int i = 1; i <= TTSS->Length(); i++) @@ -2536,7 +2882,9 @@ bool ShapeFix_Wire::FixSelfIntersectingEdge(const int num) WireData()->Add(sewd.Wire(), num > 0 ? num : NbEdges()); } if (loopRemoved) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE8); + } } if (LastFixStatus(ShapeExtend_DONE) && !myShape.IsNull()) @@ -2562,7 +2910,9 @@ static double ComputeLocalDeviation(const TopoDS_Edge& edge, occ::handle c3d; double a, b; if (!sae.Curve3d(edge, c3d, a, b, false)) + { return RealLast(); + } gp_Lin line(pint, gp_Vec(pint, pnt)); @@ -2589,7 +2939,9 @@ static double ComputeLocalDeviation(const TopoDS_Edge& edge, gp_Pnt p = c3d->Value(f + i * step); double d = line.Distance(p); if (dev < d) + { dev = d; + } } return dev; } @@ -2600,7 +2952,9 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady() || NbEdges() < 2) + { return false; + } // analysis NCollection_Sequence points2d; @@ -2608,14 +2962,18 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) NCollection_Sequence errors; occ::handle theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) + { return false; + } theAdvAnalyzer->CheckIntersectingEdges(num, points2d, points3d, errors); if (theAdvAnalyzer->LastCheckStatus(ShapeExtend_FAIL)) { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } if (!theAdvAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } // rln 03/02/98: CSR#BUC50004 entity 56 (to avoid later inserting lacking edge) //: l0 bool isLacking = myAnalyzer->CheckLacking ( num ); @@ -2665,7 +3023,9 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) double newRange1 = std::abs((isForward1 ? a1 : b1) - param1); double newRange2 = std::abs((isForward2 ? b2 : a2) - param2); if (newRange1 > prevRange1 && newRange2 > prevRange2) + { continue; + } gp_Pnt pint = points3d.Value(i); double rad = errors.Value(i); @@ -2759,22 +3119,34 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) if (!aTool.CutEdge(E1, (isForward1 ? a1 : b1), param1, Face(), IsCutLine)) { if (V1.IsSame(Vp)) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } else + { locMayEdit = false; + } } else + { cutEdge1 = true; //: h4 + } if (!aTool.CutEdge(E2, (isForward2 ? b2 : a2), param2, Face(), IsCutLine)) { if (V2.IsSame(Vn)) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE4); + } else + { locMayEdit = false; + } } else + { cutEdge2 = true; //: h4 + } } if (locMayEdit && newRange1 <= prevRange1 && newRange2 <= prevRange2 && // rln 09/01/98 @@ -2817,7 +3189,9 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) } if (!LastFixStatus(ShapeExtend_DONE)) + { return false; + } if (isChangedEdge) { @@ -2849,13 +3223,17 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num) if (cutEdge1) { if (!Context().IsNull()) + { E1 = TopoDS::Edge(Context()->Apply(E1)); + } myFixEdge->FixSameParameter(E1); } if (cutEdge2 && !IsCutLine) { if (!Context().IsNull()) + { E2 = TopoDS::Edge(Context()->Apply(E2)); + } myFixEdge->FixSameParameter(E2); } if (cutEdge1 || cutEdge2) @@ -2879,20 +3257,26 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num1, const int num2) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } NCollection_Sequence points2d; NCollection_Sequence points3d; NCollection_Sequence errors; occ::handle theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) + { return false; + } theAdvAnalyzer->CheckIntersectingEdges(num1, num2, points2d, points3d, errors); if (theAdvAnalyzer->LastCheckStatus(ShapeExtend_FAIL)) { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } if (!theAdvAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } NCollection_Array1 vertexPoints(1, 4); NCollection_Array1 vertexTolers(1, 4); NCollection_Array1 newTolers(1, 4); @@ -2903,7 +3287,9 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num1, const int num2) int n2 = (num1 > 0 ? num1 : sbwd->NbEdges()); int n1 = (num2 > 1 ? num2 : sbwd->NbEdges()); if (n1 == n2) + { return false; + } TopoDS_Edge edge1 = sbwd->Edge(n1); TopoDS_Edge edge2 = sbwd->Edge(n2); @@ -2963,7 +3349,9 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num1, const int num2) // if aMinDist lower than resolution than the intersection point lyes inside the vertex if (aMinDist < gp::Resolution()) + { continue; + } double aMaxEdgeTol1 = 0.0, aMaxEdgeTol2 = 0.0; if (aMinDist < RealLast() && !aCurve1.IsNull() && !aCurve2.IsNull()) @@ -2981,17 +3369,23 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num1, const int num2) P1.Transform(L1.Transformation()); double d1 = aLig.Distance(P1) * 2.0000001; if (d1 > tole1 && d1 > aMaxEdgeTol1) + { aMaxEdgeTol1 = d1; + } u = aVtx2Param + aPointsC * du2; gp_Pnt P2 = aCurve2->Value(u); P2.Transform(L2.Transformation()); double d2 = aLig.Distance(P2) * 2.0000001; if (d2 > tole2 && d2 > aMaxEdgeTol2) + { aMaxEdgeTol2 = d2; + } } if (aMaxEdgeTol1 == 0.0 && aMaxEdgeTol2 == 0.0) + { continue; + } // if the vertexies are far than tolerances so // we do not need to increase edge tolerance if (aNecessaryVtxTole > std::max(aMaxEdgeTol1, tole1) @@ -3041,22 +3435,34 @@ bool ShapeFix_Wire::FixIntersectingEdges(const int num1, const int num2) if (aNewTolEdge1 > 0) { for (i = 1; i <= 2; i++) + { if (aNewTolEdge1 > std::max(vertexTolers(i), newTolers(i))) + { newTolers(i) = aNewTolEdge1; + } + } B.UpdateEdge(edge1, aNewTolEdge1); } if (aNewTolEdge2 > 0) { for (i = 3; i <= 4; i++) + { if (aNewTolEdge2 > std::max(vertexTolers(i), newTolers(i))) + { newTolers(i) = aNewTolEdge2; + } + } B.UpdateEdge(edge2, aNewTolEdge2); } // update of tolerances of vertexies for (i = 1; i <= 4; i++) + { if (newTolers(i) > 0) + { B.UpdateVertex(TopoDS::Vertex(vertices(i)), newTolers(i)); + } + } if (!myShape.IsNull()) { @@ -3119,7 +3525,9 @@ static bool TryBendingPCurve(const TopoDS_Edge& E, { ShapeAnalysis_Edge sae; if (!sae.PCurve(E, face, c2d, first, last, false)) + { return false; + } { try @@ -3127,38 +3535,54 @@ static bool TryBendingPCurve(const TopoDS_Edge& E, OCC_CATCH_SIGNALS occ::handle bs; if (c2d->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) + { bs = occ::down_cast(c2d->Copy()); + } else // if ( c2d->IsKind(STANDARD_TYPE(Geom2d_Line)) ) { occ::handle trim = new Geom2d_TrimmedCurve(c2d, first, last); bs = Geom2dConvert::CurveToBSplineCurve(trim); } if (bs.IsNull()) + { return false; + } double par = (end ? last : first); if (fabs(bs->FirstParameter() - par) < ::Precision::PConfusion() && bs->Multiplicity(1) > bs->Degree()) + { bs->SetPole(1, p2d); + } else if (fabs(bs->LastParameter() - par) < ::Precision::PConfusion() && bs->Multiplicity(bs->NbKnots()) > bs->Degree()) + { bs->SetPole(bs->NbPoles(), p2d); + } else { bs->Segment(first, last); if (fabs(bs->FirstParameter() - par) < ::Precision::PConfusion() && bs->Multiplicity(1) > bs->Degree()) + { bs->SetPole(1, p2d); + } else if (fabs(bs->LastParameter() - par) < ::Precision::PConfusion() && bs->Multiplicity(bs->NbKnots()) > bs->Degree()) + { bs->SetPole(bs->NbPoles(), p2d); + } else + { return false; + } } c2d = bs; if (!TryNewPCurve(E, face, c2d, first, last, tol)) + { return false; + } } catch (Standard_Failure const&) { @@ -3179,7 +3603,9 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } //============= // First phase: analysis whether the problem (gap) exists @@ -3190,7 +3616,9 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); } if (!myAnalyzer->LastCheckStatus(ShapeExtend_DONE)) + { return false; + } //============= // Second phase: collection of data necessary for further analysis @@ -3265,7 +3693,9 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) bendtol2); } if (!ok1 && !ok2) + { bendc1.Nullify(); + } } //============= @@ -3282,13 +3712,17 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) if (!bendc1.IsNull() && !bendc2.IsNull() && ((bendtol1 < BRep_Tool::Tolerance(E1) && bendtol2 < BRep_Tool::Tolerance(E2)) || (inctol < Prec && bendtol1 < inctol && bendtol2 < inctol))) + { doBend = true; - // is it OK just to increase tolerance (to a value less than preci)? + // is it OK just to increase tolerance (to a value less than preci)? + } else if (inctol < Prec) + { doIncrease = true; - // If increase is not OK or force, try to find other solutions (adding edge) + // If increase is not OK or force, try to find other solutions (adding edge) + } else if (!BRep_Tool::Degenerated(E2) && !BRep_Tool::Degenerated(E1)) { @@ -3333,9 +3767,13 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) && !myAnalyzer->Surface()->IsDegenerated(p2d1, p2d2, 2. * tol, 10.)) { //: p7 if (!bendc1.IsNull() && !bendc2.IsNull() && bendtol1 < inctol && bendtol2 < inctol) + { doBend = true; + } else + { doIncrease = true; + } } else @@ -3347,9 +3785,13 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) double dist = pV.Distance(pm); if (dist <= tol) + { doAddDegen = true; + } else if (myTopoMode) + { doAddClosed = true; + } else if (dist <= MaxTolerance()) { //: r7 abv 12 Apr 99: t3d_opt.stp #14245 after S4136 doAddDegen = true; @@ -3396,7 +3838,9 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) TopoDS_Edge edge; B.MakeEdge(edge); if (doAddDegen) + { B.Degenerated(edge, true); // sln: do it before adding curve + } gp_Vec2d v12(p2d1, p2d2); occ::handle theLine2d = new Geom2d_Line(p2d1, gp_Dir2d(v12)); B.UpdateEdge(edge, theLine2d, face, ::Precision::Confusion()); @@ -3435,10 +3879,14 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) TopoDS_Edge edge2 = sbe.CopyReplaceVertices(E2, newV2, TopoDS_Vertex()); sbwd->Set(edge2, n2); if (!Context().IsNull()) + { Context()->Replace(E2, edge2); + } } if (!Context().IsNull()) + { UpdateWire(); + } } // insert new edge @@ -3461,9 +3909,13 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) else if (inctol > tol && inctol < MaxTolerance()) { if (!bendc1.IsNull() && !bendc2.IsNull() && bendtol1 < inctol && bendtol2 < inctol) + { doBend = true; + } else + { doIncrease = true; + } } // bend pcurves @@ -3497,7 +3949,9 @@ bool ShapeFix_Wire::FixLacking(const int num, const bool force) } if (LastFixStatus(ShapeExtend_DONE)) + { return true; + } myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); return false; @@ -3509,12 +3963,16 @@ bool ShapeFix_Wire::FixNotchedEdges() { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } occ::handle theAdvAnalyzer = myAnalyzer; TopoDS_Face face = Face(); if (!Context().IsNull()) + { UpdateWire(); + } occ::handle sewd = WireData(); for (int i = 1; i <= NbEdges() && NbEdges() > 2; i++) @@ -3619,8 +4077,10 @@ bool ShapeFix_Wire::FixNotchedEdges() } i--; - if (!Context().IsNull()) // skl 07.03.2002 for OCC180 + if (!Context().IsNull()) + { // skl 07.03.2002 for OCC180 UpdateWire(); + } myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); } } @@ -3643,7 +4103,9 @@ static void CopyReversePcurves(const TopoDS_Edge& toedge, { occ::handle fromGC = occ::down_cast(fromitcr.Value()); if (fromGC.IsNull()) + { continue; + } if (fromGC->IsCurveOnSurface()) { occ::handle surface = fromGC->Surface(); @@ -3659,7 +4121,9 @@ static void CopyReversePcurves(const TopoDS_Edge& toedge, toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull() || !toGC->IsCurveOnSurface() || surface != toGC->Surface() || L != toGC->Location()) + { continue; + } found = true; break; } @@ -3750,7 +4214,9 @@ void ShapeFix_Wire::FixDummySeam(const int num) // creating new edge with pcurves and new vertex TopoDS_Vertex Vs = sae.FirstVertex(E2); if (Vs.IsSame(V1) || Vs.IsSame(V2)) + { Vs = Vm; + } TopoDS_Edge newEdge = sbe.CopyReplaceVertices(E2, Vs, Vm); CopyReversePcurves(newEdge, E1, E1.Orientation() == E2.Orientation()); BRep_Builder B; @@ -3780,12 +4246,16 @@ void ShapeFix_Wire::FixDummySeam(const int num) TopoDS_Edge tmpE1 = sbe.CopyReplaceVertices(prevE, TopoDS_Vertex(), Vm); sewd->Set(tmpE1, prev); if (!Context().IsNull()) + { Context()->Replace(prevE, tmpE1); + } tmpE1 = sbe.CopyReplaceVertices(nextE, Vm, TopoDS_Vertex()); sewd->Set(tmpE1, next); if (!Context().IsNull()) + { Context()->Replace(nextE, tmpE1); + } // removing edges from wire int n1, n2; @@ -3815,9 +4285,13 @@ void ShapeFix_Wire::UpdateWire() // so a previously-split edge is not re-expanded on subsequent Perform() passes. TopoDS_Shape S = Context()->ValueLeaf(E); if (!S.IsNull() && S.IsEqual(E)) + { continue; + } for (TopExp_Explorer exp(S, TopAbs_EDGE); exp.More(); exp.Next()) + { sbwd->Add(exp.Current(), i++); + } sbwd->Remove(i--); } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireSegment.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireSegment.cxx index 54a61de94e..aa304caeba 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireSegment.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireSegment.cxx @@ -58,7 +58,9 @@ void ShapeFix_WireSegment::Load(const occ::handle& wire) Clear(); myWire->ManifoldMode() = wire->ManifoldMode(); for (int i = 1; i <= wire->NbEdges(); i++) + { AddEdge(i, wire->Edge(i)); + } } //================================================================================================= @@ -188,7 +190,9 @@ void ShapeFix_WireSegment::SetPatchIndex(const int i, void ShapeFix_WireSegment::DefineIUMin(const int i, const int iumin) { if (myIUMin->Value(i) < iumin) + { myIUMin->SetValue(i, iumin); + } #ifdef OCCT_DEBUG if (myIUMin->Value(i) > myIUMax->Value(i)) std::cout << "Warning: ShapeFix_WireSegment::DefineIUMin: indexation error" << std::endl; @@ -200,7 +204,9 @@ void ShapeFix_WireSegment::DefineIUMin(const int i, const int iumin) void ShapeFix_WireSegment::DefineIUMax(const int i, const int iumax) { if (myIUMax->Value(i) > iumax) + { myIUMax->SetValue(i, iumax); + } #ifdef OCCT_DEBUG int iun = myIUMin->Value(i), iux = myIUMax->Value(i); if (iun > iux) @@ -213,7 +219,9 @@ void ShapeFix_WireSegment::DefineIUMax(const int i, const int iumax) void ShapeFix_WireSegment::DefineIVMin(const int i, const int ivmin) { if (myIVMin->Value(i) < ivmin) + { myIVMin->SetValue(i, ivmin); + } #ifdef OCCT_DEBUG int ivn = myIVMin->Value(i), ivx = myIVMax->Value(i); if (ivn > ivx) @@ -226,7 +234,9 @@ void ShapeFix_WireSegment::DefineIVMin(const int i, const int ivmin) void ShapeFix_WireSegment::DefineIVMax(const int i, const int ivmax) { if (myIVMax->Value(i) > ivmax) + { myIVMax->SetValue(i, ivmax); + } #ifdef OCCT_DEBUG int ivn = myIVMin->Value(i), ivx = myIVMax->Value(i); if (ivn > ivx) diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireVertex.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireVertex.cxx index 506dffd287..959942c2db 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireVertex.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_WireVertex.cxx @@ -84,7 +84,9 @@ int ShapeFix_WireVertex::FixSame() // FixSame : prend les status "SameCoord" et "Close" et les force a "Same" // reprendre l edge et forcer le vertex. Evt changer sa tolerance. Et voila if (!myAnalyzer.IsDone()) + { return 0; + } int nbfix = 0; BRep_Builder B; @@ -97,7 +99,9 @@ int ShapeFix_WireVertex::FixSame() int j = (i == nb ? 1 : i + 1); int stat = myAnalyzer.Status(i); if (stat != 1 && stat != 2) + { continue; + } // Ici on prend un vertex et on le generalise aux deux edges TopoDS_Edge E1 = sbwd->Edge(i); TopoDS_Edge E2 = sbwd->Edge(j); @@ -145,7 +149,9 @@ int ShapeFix_WireVertex::Fix() // auxquelles on remet les Vertex (assez facile) // Donc deux passes : 1 refaire les VTX et 2 les remettre dans les edges if (!myAnalyzer.IsDone()) + { return 0; + } occ::handle sbwd = myAnalyzer.WireData(); @@ -156,10 +162,14 @@ int ShapeFix_WireVertex::Fix() // On note les valeurs // szv#4:S4163:12Mar99 optimized if (myAnalyzer.Status(i) > 0) + { nbfix++; + } } if (nbfix == 0) + { return 0; + } BRep_Builder B; @@ -211,7 +221,9 @@ int ShapeFix_WireVertex::Fix() } if (nbfix == 0) + { return nbfix; + } // EmptyCopy pas bon : KK sur les Range (dommage, le reste est bon) // Donc on garde l original mais on change les vertex @@ -246,7 +258,9 @@ int ShapeFix_WireVertex::Fix() double ufol = UJ->Value(j); if (stat > 2) + { B.UpdateVertex(V1, gp_Pnt(myAnalyzer.Position(i)), Prec); + } // ce qui suit : seulement si vertex a reprendre if (stat > 0) @@ -271,7 +285,9 @@ int ShapeFix_WireVertex::Fix() // pour finir, MAJ du STW for (i = 1; i <= nb; i++) + { sbwd->Set(TopoDS::Edge(EF->Value(i)), i); + } return nbfix; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire_1.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire_1.cxx index e277ac3982..3577cc9bb5 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire_1.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wire_1.cxx @@ -135,12 +135,18 @@ static double AdjustOnPeriodic3d(const occ::handle& c, double T = c->Period(); double shift = -std::trunc(first / T) * T; if (first < 0.) + { shift += T; + } double sfirst = first + shift, slast = last + shift; if (takefirst && (param > slast) && (param > sfirst)) + { return param - T - shift; + } if (!takefirst && (param < slast) && (param < sfirst)) + { return param + T - shift; + } } return param; } @@ -155,7 +161,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) //============= if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } double preci = Precision(); @@ -181,7 +189,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) gp_Pnt cpnt1 = C1->Value(clast1), cpnt2 = C2->Value(cfirst2); double gap = cpnt1.Distance(cpnt2); if (!convert && gap <= preci) + { return false; + } //============= // Second phase: collecting data necessary for further analysis @@ -238,7 +248,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) offset1 = true; } else + { basic = true; + } } basic = false; bool trimmed2 = false, offset2 = false; @@ -258,13 +270,19 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) offset2 = true; } else + { basic = true; + } } // Restore offset curves if (offset1) + { c1 = new Geom_OffsetCurve(c1, offval1.Modulus(), gp_Dir(offval1)); + } if (offset2) + { c2 = new Geom_OffsetCurve(c2, offval2.Modulus(), gp_Dir(offval2)); + } bool done1 = false, done2 = false; @@ -272,7 +290,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) { // Check that gap satisfies the precision - in this case no conversion produced if (cpnt1.Distance(vpnt) < preci && cpnt2.Distance(vpnt) < preci) + { return false; + } occ::handle bsp1, bsp2; occ::handle c; @@ -290,10 +310,14 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) if (n1 == n2) { if (cpnt2.Distance(vpnt) < preci) + { continue; + } } else + { continue; + } } c = c1; first = first1; @@ -302,7 +326,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) else { if (cpnt2.Distance(vpnt) < preci) + { continue; + } c = c2; first = first2; last = last2; /*trim = trimmed2;*/ // skl @@ -328,7 +354,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) segment = true; } if (segment) + { bsp = GeomConvert::SplitBSplineCurve(bsp, fbsp, lbsp, ::Precision::Confusion()); + } } else if (c->IsKind(STANDARD_TYPE(Geom_Conic))) { @@ -338,7 +366,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) 9, 1000); if (Conv.IsDone() || Conv.HasResult()) + { bsp = Conv.Curve(); + } } else { @@ -349,11 +379,15 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) OCC_CATCH_SIGNALS // 15.11.2002 PTV OCC966 if (!ShapeAnalysis_Curve::IsPeriodic(c)) + { tc = new Geom_TrimmedCurve(c, std::max(first, c->FirstParameter()), std::min(last, c->LastParameter())); + } else + { tc = new Geom_TrimmedCurve(c, first, last); + } bsp = GeomConvert::CurveToBSplineCurve(tc); } catch (Standard_Failure const& anException) @@ -369,21 +403,31 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) } if (j == 1) + { bsp1 = bsp; + } else + { bsp2 = bsp; + } } // Take curves ends if could not convert if (bsp1.IsNull()) + { vpnt = cpnt1; + } else if (bsp2.IsNull()) + { vpnt = cpnt2; + } if (!bsp1.IsNull()) { if (bsp1->Degree() == 1) + { bsp1->IncreaseDegree(2); // gka + } if (n1 == n2) { bsp1->SetPole(1, vpnt); @@ -392,9 +436,13 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) else { if (reversed1) + { bsp1->SetPole(1, vpnt); + } else + { bsp1->SetPole(bsp1->NbPoles(), vpnt); + } } first1 = bsp1->FirstParameter(); last1 = bsp1->LastParameter(); @@ -404,11 +452,17 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) if (!bsp2.IsNull()) { if (bsp2->Degree() == 1) + { bsp2->IncreaseDegree(2); // gka + } if (reversed2) + { bsp2->SetPole(bsp2->NbPoles(), vpnt); + } else + { bsp2->SetPole(1, vpnt); + } first2 = bsp2->FirstParameter(); last2 = bsp2->LastParameter(); c2 = bsp2; @@ -444,9 +498,13 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) { double diff = domlast1 - domfirst1; if (reversed1) + { domfirst1 -= 10. * diff; + } else + { domlast1 += 10. * diff; + } } else if (c1->IsKind(STANDARD_TYPE(Geom_Circle)) || c1->IsKind(STANDARD_TYPE(Geom_Ellipse))) { @@ -465,9 +523,13 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) { double diff = domlast2 - domfirst2; if (reversed2) + { domlast2 += 10. * diff; + } else + { domfirst2 -= 10. * diff; + } } else if (c2->IsKind(STANDARD_TYPE(Geom_Circle)) || c2->IsKind(STANDARD_TYPE(Geom_Ellipse))) { @@ -598,12 +660,16 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) Extr.Parameters(index2, uu1, uu2); pp2 = gp_Pnt((c1->Value(uu1).XYZ() + c2->Value(uu2).XYZ()) * 0.5); if (pp2.Distance(vpnt) < pp1.Distance(vpnt)) + { index1 = index2; + } } Extr.Parameters(index1, uu1, uu2); } else + { Extr.LowerDistanceParameters(uu1, uu2); + } // Adjust parameters on periodic curves uu1 = AdjustOnPeriodic3d(c1, reversed1, first1, last1, uu1); uu2 = AdjustOnPeriodic3d(c2, !reversed2, first2, last2, uu2); @@ -631,14 +697,20 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) if (done1) { if (ipar1 == clast1) + { done1 = false; + } else { // Set up new bounds for curve if (reversed1) + { first1 = ipar1; + } else + { last1 = ipar1; + } // Set new trim for old curve if (trimmed1) { @@ -651,14 +723,20 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) if (done2) { if (ipar2 == cfirst2) + { done2 = false; + } else { // Set up new bounds for curve if (reversed2) + { last2 = ipar2; + } else + { first2 = ipar2; + } // Set new trim for old curve if (trimmed2) { @@ -775,7 +853,9 @@ bool ShapeFix_Wire::FixGap3d(const int num, const bool convert) myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); } else if (convert) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return (done1 || done2); } @@ -794,12 +874,18 @@ static double AdjustOnPeriodic2d(const occ::handle& pc, double T = pc->Period(); double shift = -std::trunc(first / T) * T; if (first < 0.) + { shift += T; + } double sfirst = first + shift, slast = last + shift; if (takefirst && (param > slast) && (param > sfirst)) + { return param - T - shift; + } if (!takefirst && (param < slast) && (param < sfirst)) + { return param + T - shift; + } } return param; } @@ -808,14 +894,18 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) { myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (!IsReady()) + { return false; + } //============= // First phase: analysis whether the problem (gap) exists //============= if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } constexpr double preci = ::Precision::PConfusion(); // double preci = Precision(); @@ -845,7 +935,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) gp_Pnt2d cpnt1 = PC1->Value(clast1), cpnt2 = PC2->Value(cfirst2); double gap = cpnt1.Distance(cpnt2); if (gap <= preci) + { return false; + } //============= // Second phase: collecting data necessary for further analysis @@ -897,7 +989,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) offset1 = true; } else + { basic = true; + } } basic = false; bool trimmed2 = false, offset2 = false; @@ -917,13 +1011,19 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) offset2 = true; } else + { basic = true; + } } // Restore offset curves if (offset1) + { pc1 = new Geom2d_OffsetCurve(pc1, offval1); + } if (offset2) + { pc2 = new Geom2d_OffsetCurve(pc2, offval2); + } bool done1 = false, done2 = false; @@ -973,7 +1073,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) segment = true; } if (segment) + { bsp = Geom2dConvert::SplitBSplineCurve(bsp, fbsp, lbsp, ::Precision::PConfusion()); + } } else if (pc->IsKind(STANDARD_TYPE(Geom2d_Conic))) { @@ -989,7 +1091,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) 9, 1000); if (Conv.IsDone() || Conv.HasResult()) + { bsp = Conv.Curve(); + } } else { @@ -1000,11 +1104,15 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) occ::handle c; // 15.11.2002 PTV OCC966 if (!ShapeAnalysis_Curve::IsPeriodic(pc)) + { c = new Geom2d_TrimmedCurve(pc, std::max(first, pc->FirstParameter()), std::min(last, pc->LastParameter())); + } else + { c = new Geom2d_TrimmedCurve(pc, first, last); + } bsp = Geom2dConvert::CurveToBSplineCurve(c); } catch (Standard_Failure const& anException) @@ -1020,22 +1128,32 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) } if (j == 1) + { bsp1 = bsp; + } else + { bsp2 = bsp; + } } // Take curves ends if could not convert gp_Pnt2d mpnt((cpnt1.XY() + cpnt2.XY()) * 0.5); if (bsp1.IsNull()) + { mpnt = cpnt1; + } else if (bsp2.IsNull()) + { mpnt = cpnt2; + } if (!bsp1.IsNull()) { if (bsp1->Degree() == 1) + { bsp1->IncreaseDegree(2); + } if (n1 == n2) { bsp1->SetPole(1, mpnt); @@ -1044,9 +1162,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) else { if (reversed1) + { bsp1->SetPole(1, mpnt); + } else + { bsp1->SetPole(bsp1->NbPoles(), mpnt); + } } first1 = bsp1->FirstParameter(); last1 = bsp1->LastParameter(); @@ -1056,11 +1178,17 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if (!bsp2.IsNull()) { if (bsp2->Degree() == 1) + { bsp2->IncreaseDegree(2); + } if (reversed2) + { bsp2->SetPole(bsp2->NbPoles(), mpnt); + } else + { bsp2->SetPole(1, mpnt); + } first2 = bsp2->FirstParameter(); last2 = bsp2->LastParameter(); pc2 = bsp2; @@ -1097,9 +1225,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) { double diff = domlast1 - domfirst1; if (reversed1) + { domfirst1 -= 10. * diff; + } else + { domlast1 += 10. * diff; + } } else if (pc1->IsKind(STANDARD_TYPE(Geom2d_Circle)) || pc1->IsKind(STANDARD_TYPE(Geom2d_Ellipse))) @@ -1120,9 +1252,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) { double diff = domlast2 - domfirst2; if (reversed2) + { domlast2 += 10. * diff; + } else + { domfirst2 -= 10. * diff; + } } else if (pc2->IsKind(STANDARD_TYPE(Geom2d_Circle)) || pc2->IsKind(STANDARD_TYPE(Geom2d_Ellipse))) @@ -1190,9 +1326,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if ((j == 1 && IS.HasFirstPoint()) || (j == 2 && IS.HasLastPoint())) { if (j == 1) + { IP = IS.FirstPoint(); + } else + { IP = IS.LastPoint(); + } // Adjust parameters on periodic curves double u1 = AdjustOnPeriodic2d(pc1, reversed1, first1, last1, IP.ParamOnFirst()); double u2 = AdjustOnPeriodic2d(pc2, !reversed2, first2, last2, IP.ParamOnSecond()); @@ -1218,24 +1358,36 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) // take intersection closer to mean point gp_Pnt2d pt1, pt2; if (flag1 == 0) + { pt1 = Inter.Point(index1).Value(); + } else { IS = Inter.Segment(index1); if (flag1 == 1) + { pt1 = IS.FirstPoint().Value(); + } else + { pt1 = IS.LastPoint().Value(); + } } if (flag2 == 0) + { pt2 = Inter.Point(index2).Value(); + } else { IS = Inter.Segment(index2); if (flag2 == 1) + { pt2 = IS.FirstPoint().Value(); + } else + { pt2 = IS.LastPoint().Value(); + } } gp_Pnt2d mpnt((cpnt1.XY() + cpnt2.XY()) * 0.5); if (pt2.Distance(mpnt) < pt1.Distance(mpnt)) @@ -1245,14 +1397,20 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) } } if (flag1 == 0) + { IP = Inter.Point(index1); + } else { IS = Inter.Segment(index1); if (flag1 == 1) + { IP = IS.FirstPoint(); + } else + { IP = IS.LastPoint(); + } } // Adjust parameters on periodic curves double u1 = AdjustOnPeriodic2d(pc1, reversed1, first1, last1, IP.ParamOnFirst()); @@ -1388,9 +1546,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) else { if (cpnt1.Distance(ipnt2) < cpnt2.Distance(ipnt1)) + { u1 = ipar1; + } else + { u2 = ipar2; + } } // Adjust parameters on periodic curves u1 = AdjustOnPeriodic2d(pc1, reversed1, first1, last1, u1); @@ -1423,13 +1585,21 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) double fumin, fumax, fvmin, fvmax; BRepTools::UVBounds(face, fumin, fumax, fvmin, fvmax); if (::Precision::IsInfinite(umin)) + { umin = fumin - preci; + } if (::Precision::IsInfinite(umax)) + { umax = fumax + preci; + } if (::Precision::IsInfinite(vmin)) + { vmin = fvmin - preci; + } if (::Precision::IsInfinite(vmax)) + { vmax = fvmax + preci; + } } gp_Pnt2d ipnt, P1, P2; @@ -1442,13 +1612,17 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if (j == 1) { if (ipar1 >= first1 && ipar1 <= last1) + { continue; + } ipnt = pc1->Value(ipar1); } else { if (ipar2 >= first2 && ipar2 <= last2) + { continue; + } ipnt = pc2->Value(ipar2); } @@ -1473,7 +1647,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) P2 = gp_Pnt2d(umax, vmax); } else + { out = false; + } } else { @@ -1488,7 +1664,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) P2 = gp_Pnt2d(umax, vmax); } else + { out = false; + } } if (out) @@ -1563,9 +1741,13 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if ((jj == 1 && IS.HasFirstPoint()) || (jj == 2 && IS.HasLastPoint())) { if (jj == 1) + { IP = IS.FirstPoint(); + } else + { IP = IS.LastPoint(); + } // Adjust parameters on periodic curve uu = AdjustOnPeriodic2d(pc, (jj == 1 ? reversed1 : !reversed2), @@ -1583,14 +1765,20 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) } } if (flag == 0) + { IP = Inter.Point(index); + } else { IS = Inter.Segment(index); if (flag == 1) + { IP = IS.FirstPoint(); + } else + { IP = IS.LastPoint(); + } } // Adjust parameters on periodic curve uu = AdjustOnPeriodic2d(pc, @@ -1619,12 +1807,16 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if (reversed1) { if (ipar1 > first1) + { ipar1 = first1; + } } else { if (ipar1 < last1) + { ipar1 = last1; + } } } else @@ -1632,12 +1824,16 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if (reversed2) { if (ipar2 < last2) + { ipar2 = last2; + } } else { if (ipar2 > first2) + { ipar2 = first2; + } } } } @@ -1649,33 +1845,49 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) if (done1) { if (ipar1 == clast1) + { done1 = false; + } else { // Set up new bounds for pcurve if (reversed1) + { first1 = ipar1; + } else + { last1 = ipar1; + } // Set new trim for old pcurve if (trimmed1) + { pc1 = new Geom2d_TrimmedCurve(pc1, first1, last1); + } } } if (done2) { if (ipar2 == cfirst2) + { done2 = false; + } else { // Set up new bounds for pcurve if (reversed2) + { last2 = ipar2; + } else + { first2 = ipar2; + } // Set new trim for old pcurve if (trimmed2) + { pc2 = new Geom2d_TrimmedCurve(pc2, first2, last2); + } } } } @@ -1785,7 +1997,9 @@ bool ShapeFix_Wire::FixGap2d(const int num, const bool convert) myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); } else if (convert) + { myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } return (done1 || done2); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wireframe.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wireframe.cxx index 910e4997c8..e22623d372 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wireframe.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Wireframe.cxx @@ -93,10 +93,14 @@ bool ShapeFix_Wireframe::FixWireGaps() { myStatusWireGaps = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (myShape.IsNull()) + { return false; + } if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } else { TopoDS_Shape shape = myShape; @@ -131,7 +135,9 @@ bool ShapeFix_Wireframe::FixWireGaps() cont.Bind(myShape, res); } if (!res.IsSame(shape1)) + { locModified = true; + } res.Location(L); B.Add(C, res); } @@ -154,27 +160,41 @@ bool ShapeFix_Wireframe::FixWireGaps() TopoDS_Shape tmpF = Context()->Apply(anExpf1.Current()); face = TopoDS::Face(tmpF); if (face.Orientation() == TopAbs_REVERSED) + { face.Orientation(TopAbs_FORWARD); + } for (TopoDS_Iterator itw(face); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } // smh#8 TopoDS_Shape tmpW = Context()->Apply(itw.Value()); sfw->Init(TopoDS::Wire(tmpW), face, prec); sfw->FixReorder(); sfw->FixGaps3d(); if (sfw->StatusGaps3d(ShapeExtend_DONE)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (sfw->StatusGaps3d(ShapeExtend_FAIL)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } sfw->FixGaps2d(); if (sfw->StatusGaps2d(ShapeExtend_DONE)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (sfw->StatusGaps2d(ShapeExtend_FAIL)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } if (sfw->StatusGaps3d(ShapeExtend_DONE) || sfw->StatusGaps2d(ShapeExtend_DONE)) + { SendWarning(itw.Value(), Message_Msg("FixWireframe.FixFixWireGaps.MSG0")); + } } } @@ -191,11 +211,17 @@ bool ShapeFix_Wireframe::FixWireGaps() sfw->FixReorder(); sfw->FixGaps3d(); if (sfw->StatusGaps3d(ShapeExtend_DONE)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (sfw->StatusGaps3d(ShapeExtend_FAIL)) + { myStatusWireGaps |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } if (sfw->StatusGaps3d(ShapeExtend_DONE)) + { SendWarning(expw.Current(), Message_Msg("FixWireframe.FixFixWireGaps.MSG0")); + } } // End Part1======================================================== @@ -212,17 +238,23 @@ bool ShapeFix_Wireframe::FixWireGaps() { face = TopoDS::Face(anExpf2.Current()); if (face.Orientation() == TopAbs_REVERSED) + { face.Orientation(TopAbs_FORWARD); + } for (TopoDS_Iterator itw(face); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } wire = TopoDS::Wire(itw.Value()); sfw->Init(wire, face, prec); sfw->FixReorder(); sfw->FixSelfIntersection(); for (TopoDS_Iterator ite(wire); ite.More(); ite.Next()) + { sfe->FixVertexTolerance(TopoDS::Edge(ite.Value())); + } } } @@ -235,7 +267,9 @@ bool ShapeFix_Wireframe::FixWireGaps() sfw->FixReorder(); sfw->FixSelfIntersection(); for (TopoDS_Iterator ite(wire); ite.More(); ite.Next()) + { sfe->FixVertexTolerance(TopoDS::Edge(ite.Value())); + } } // End Part 2 @@ -275,9 +309,13 @@ static bool JoinEdges(const TopoDS_Edge& E1, { OCC_CATCH_SIGNALS if (!sae.Curve3d(E1, c3d1, cf1, cl1, false)) + { return ReplaceFirst; + } if (!sae.Curve3d(E2, c3d2, cf2, cl2, false)) + { return ReplaceFirst; + } B.Add(newedge, V11.Oriented(TopAbs_FORWARD)); B.Add(newedge, V22.Oriented(TopAbs_REVERSED)); @@ -296,10 +334,14 @@ static bool JoinEdges(const TopoDS_Edge& E1, CRes, isRev1, isRev2)) + { return ReplaceFirst; + } // if(isRev1 || isRev2) if (!isSame && (isRev1 || isRev2)) + { return ReplaceFirst; + } ReplaceFirst = (!isRev1); double newf = cf1; @@ -309,7 +351,9 @@ static bool JoinEdges(const TopoDS_Edge& E1, bool ismanifold = (OrEdge1 == TopAbs_FORWARD || OrEdge1 == TopAbs_REVERSED); bool ismanifold2 = (OrEdge2 == TopAbs_FORWARD || OrEdge2 == TopAbs_REVERSED); if (ismanifold != ismanifold2) + { return ReplaceFirst; + } if (ismanifold) { @@ -327,9 +371,13 @@ static bool JoinEdges(const TopoDS_Edge& E1, double fp = CRes->FirstParameter(); double lp = CRes->LastParameter(); if (fp > newf) + { newf = fp; + } if (lp < newl) + { newl = lp; + } B.Range(newedge, newf, newl); // merging pcurves @@ -337,9 +385,13 @@ static bool JoinEdges(const TopoDS_Edge& E1, { TopoDS_Face face = TopoDS::Face(iter.Value()); if (!sae.PCurve(E1, face, c2d1, first1, last1, false)) + { return ReplaceFirst; + } if (!sae.PCurve(E2, face, c2d2, first2, last2, false)) + { return ReplaceFirst; + } occ::handle C2dRes; bool isRev12, isRev22; @@ -355,22 +407,32 @@ static bool JoinEdges(const TopoDS_Edge& E1, isRev12, isRev22, isSame)) + { return ReplaceFirst; + } if (ismanifold && (!isSame && (isRev12 || isRev22))) + { return ReplaceFirst; + } if (isRev12) + { ReplaceFirst = false; + } double fp2d = C2dRes->FirstParameter(); double lp2d = C2dRes->LastParameter(); // B.UpdateEdge(newedge,C2dRes,face,0); double newf1 = first1; double newl1 = last1 + (last2 - first2); if (fp2d > newf1) + { newf1 = fp2d; + } if (lp2d < newl1) + { newl1 = lp2d; + } // dealing with seams: the same again if (sae.IsSeam(E1, face) && sae.IsSeam(E2, face)) @@ -396,18 +458,28 @@ static bool JoinEdges(const TopoDS_Edge& E1, isRev12, isRev22, isSame)) + { return ReplaceFirst; + } if (!isSame && (isRev1 || isRev2)) + { return ReplaceFirst; + } B.UpdateEdge(newedge, C2dRes, C2dRes2, face, 0); } else if (sae.IsSeam(E1, face) || sae.IsSeam(E2, face)) + { return ReplaceFirst; + } else if (!sae.IsSeam(E1, face) && !sae.IsSeam(E2, face)) + { B.UpdateEdge(newedge, C2dRes, face, 0); + } B.Range(newedge, face, newf1, newl1); if (!ismanifold) + { newedge.Orientation(ReplaceFirst ? OrEdge1 : OrEdge2); + } } B.SameRange(newedge, false); @@ -433,10 +505,14 @@ bool ShapeFix_Wireframe::FixSmallEdges() { myStatusSmallEdges = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (myShape.IsNull()) + { return false; + } if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } else { TopoDS_Shape shape = myShape; @@ -469,11 +545,15 @@ bool ShapeFix_Wireframe::FixSmallEdges() cont.Bind(myShape, res); } if (!res.IsSame(shape1)) + { locModified = true; + } // check if resulting shape if not empty if (res.IsNull()) + { continue; + } res.Location(L); B.Add(C, res); @@ -516,11 +596,15 @@ bool ShapeFix_Wireframe::CheckSmallEdges( TopoDS_Face facet = TopoDS::Face(anExpf1.Current()); face = facet; if (facet.Orientation() == TopAbs_REVERSED) + { face = TopoDS::Face(facet.Oriented(TopAbs_FORWARD)); + } for (TopoDS_Iterator itw(face); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire aW = TopoDS::Wire(itw.Value()); occ::handle aswd = new ShapeExtend_WireData(aW, true, false); SAW.Init(aswd, face, Precision()); @@ -531,9 +615,13 @@ bool ShapeFix_Wireframe::CheckSmallEdges( { edge = SAW.WireData()->Edge(i); if (EdgeMap.IsBound(edge)) + { EdgeMap.ChangeFind(edge)++; + } else + { EdgeMap.Bind(edge, 1); + } } for (i = 1; i <= SAW.NbEdges(); i++) @@ -542,7 +630,9 @@ bool ShapeFix_Wireframe::CheckSmallEdges( if (EdgeMap.Find(edge) != 1) { if (!SAW.WireData()->IsSeam(i)) + { theMultyEdges.Add(edge); + } continue; } // Append current face to the list @@ -558,7 +648,9 @@ bool ShapeFix_Wireframe::CheckSmallEdges( } // Check if current edge is small if (theSmallEdges.Contains(edge)) + { theEdgeList.Append(edge); + } else if (SAW.CheckSmall(i, Precision())) { theSmallEdges.Add(edge); @@ -568,7 +660,9 @@ bool ShapeFix_Wireframe::CheckSmallEdges( } // Add current face to the map if has small edges if (theEdgeList.Extent()) + { theFaceWithSmall.Bind(facet, theEdgeList); + } } //========================================================================= @@ -591,9 +685,13 @@ bool ShapeFix_Wireframe::CheckSmallEdges( { edge = SAW.WireData()->Edge(i); if (EdgeMap.IsBound(edge)) + { EdgeMap.ChangeFind(edge)++; + } else + { EdgeMap.Bind(edge, 1); + } } for (i = 1; i <= SAW.NbEdges(); i++) @@ -602,13 +700,17 @@ bool ShapeFix_Wireframe::CheckSmallEdges( if (EdgeMap.Find(edge) != 1) { if (!SAW.WireData()->IsSeam(i)) + { theMultyEdges.Add(edge); + } continue; } // Check if current edge is small if (theSmallEdges.Contains(edge)) + { theEdgeList.Append(edge); + } else if (SAW.CheckSmall(i, Precision())) { theSmallEdges.Add(edge); @@ -684,10 +786,14 @@ bool ShapeFix_Wireframe::MergeSmallEdges( for (TopoDS_Iterator itw(face); itw.More(); itw.Next()) { if (itw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire aWire = TopoDS::Wire(itw.Value()); if (face.Orientation() == TopAbs_REVERSED) + { face = TopoDS::Face(facet.Oriented(TopAbs_FORWARD)); + } occ::handle aswd = new ShapeExtend_WireData(aWire, true, false); // SFW->Load(aWire); SFW->Load(aswd); @@ -732,24 +838,40 @@ bool ShapeFix_Wireframe::MergeSmallEdges( C1->D1(last1, P, Vec1); C2->D1(first2, P, Vec2); if (edge1.Orientation() == TopAbs_REVERSED) + { Vec1.Reverse(); + } if (edge2.Orientation() == TopAbs_REVERSED) + { Vec2.Reverse(); + } constexpr double tol2 = Precision::SquareConfusion(); if (Vec1.SquareMagnitude() < tol2 || Vec2.SquareMagnitude() < tol2) + { Ang1 = M_PI / 2.; + } else + { Ang1 = std::abs(Vec1.Angle(Vec2)); + } C2->D1(last2, P, Vec1); C3->D1(first3, P, Vec2); if (edge2.Orientation() == TopAbs_REVERSED) + { Vec1.Reverse(); + } if (edge3.Orientation() == TopAbs_REVERSED) + { Vec2.Reverse(); + } if (Vec1.SquareMagnitude() < tol2 || Vec2.SquareMagnitude() < tol2) + { Ang2 = M_PI / 2.; + } else + { Ang2 = std::abs(Vec1.Angle(Vec2)); + } // isLimAngle = (theLimitAngle != -1 && std::min(Ang1,Ang2) > theLimitAngle); // take_next = (Ang2 theList1, theList2, theList3; if (theEdgeToFaces.IsBound(edge1)) + { theList1 = theEdgeToFaces(edge1); + } if (theEdgeToFaces.IsBound(edge2)) + { theList2 = theEdgeToFaces(edge2); + } if (theEdgeToFaces.IsBound(edge3)) + { theList3 = theEdgeToFaces(edge3); + } bool same_set = false; // gka protection against joining seem edges with other edges @@ -783,14 +911,18 @@ bool ShapeFix_Wireframe::MergeSmallEdges( NCollection_Map theSetOfFaces; for (NCollection_List::Iterator itf1(theList2); itf1.More(); itf1.Next()) + { theSetOfFaces.Add(itf1.Value()); + } if (same_set1) { // Add all faces of the first edge to the current set for (NCollection_List::Iterator itf2(theList1); (itf2.More() && same_set1); itf2.Next()) + { same_set1 = theSetOfFaces.Contains(itf2.Value()); + } } if (same_set2) { @@ -798,13 +930,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( for (NCollection_List::Iterator itf2(theList3); (itf2.More() && same_set2); itf2.Next()) + { same_set2 = theSetOfFaces.Contains(itf2.Value()); + } } if (same_set1 && same_set2) { same_set = true; if (fabs(Ang2 - Ang1) > Precision::Angular()) + { take_next = (Ang2 < Ang1); + } if (take_next) { edge1 = edge2; @@ -835,13 +971,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( aItF.Next()) { if (aItF.Value().IsSame(anExpf2.Current())) + { continue; + } TopoDS_Shape aF = Context()->Apply(aItF.Value()); // aF = aF.Oriented(TopAbs_FORWARD); for (TopoDS_Iterator aIw(aF); aIw.More(); aIw.Next()) { if (aIw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wt = TopoDS::Wire(aIw.Value()); occ::handle SFW1 = new ShapeFix_Wire; SFW1->Load(wt); @@ -871,7 +1011,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( ReplaceFirst = JoinEdges(edge1, edge2, edge3, aListF); } else + { edge3 = TopoDS_Edge(); + } if (edge3.IsNull()) { index++; @@ -888,12 +1030,14 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theNewVertices.Bind(oldV1, TopoDS::Vertex(emptyCopiedV1)); } if (!oldV1.IsSame(oldV2)) + { if (!theNewVertices.IsBound(oldV2)) // smh#8 { TopoDS_Shape emptyCopiedV2 = oldV2.EmptyCopied(); theNewVertices.Bind(oldV2, TopoDS::Vertex(emptyCopiedV2)); } + } // To keep NM vertices belonging initial edges TopoDS_Iterator aItv(edge1, false); @@ -960,11 +1104,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdgeToFaces.UnBind(edge2); theEdgeToFaces.Bind(edge3, theList); if (theSmallEdges.Contains(edge1)) + { theSmallEdges.Remove(edge1); + } if (theSmallEdges.Contains(edge2)) + { theSmallEdges.Remove(edge2); + } if (newsmall) + { theSmallEdges.Add(edge3); + } for (NCollection_List::Iterator itlf(theList); itlf.More(); itlf.Next()) { @@ -973,19 +1123,27 @@ bool ShapeFix_Wireframe::MergeSmallEdges( { NCollection_List& theEdges = theFaceWithSmall(curface); if (newsmall) + { theEdges.Append(edge3); + } NCollection_List::Iterator ite(theEdges); while (ite.More()) { TopoDS_Shape iedge = ite.Value(); if (iedge.IsSame(edge1) || iedge.IsSame(edge2)) + { theEdges.Remove(ite); + } else + { ite.Next(); + } } // Remove face without small edges from the map if (!theEdges.Extent()) + { theFaceWithSmall.UnBind(curface); + } } } myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); @@ -998,9 +1156,13 @@ bool ShapeFix_Wireframe::MergeSmallEdges( tempWire->Add(SFW->Wire()); TopoDS_Edge remedge; if (take_next) + { remedge = edge1; + } else + { remedge = edge2; + } tempWire->Remove(index); tempSaw.Load(tempWire); int newindex = (index <= tempSaw.NbEdges() ? index : 1); @@ -1013,10 +1175,14 @@ bool ShapeFix_Wireframe::MergeSmallEdges( tempWire->Edge(newindex == 1 ? tempSaw.NbEdges() : (newindex - 1)); NCollection_List aL1; if (theEdgeToFaces.IsBound(tmpedge1)) + { aL1 = theEdgeToFaces.Find(tmpedge1); + } NCollection_List aL2; if (theEdgeToFaces.IsBound(tmpedge2)) + { aL2 = theEdgeToFaces.Find(tmpedge2); + } SFW->FixConnected(newindex <= SFW->NbEdges() ? newindex : 1, Precision()); SFW->FixDegenerated(newindex <= SFW->NbEdges() ? newindex : 1); TopoDS_Shape aTmpShape = Context()->Apply(tmpedge1); // for porting @@ -1026,7 +1192,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(remedge); SendWarning(remedge, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(remedge)) + { theSmallEdges.Remove(remedge); + } theEdgeToFaces.UnBind(remedge); theEdgeToFaces.UnBind(tmpedge1); theEdgeToFaces.UnBind(tmpedge2); @@ -1051,7 +1219,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdges.Append(anewedge1); } else + { ite.Next(); + } } } } @@ -1074,14 +1244,18 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdges.Append(anewedge2); } else + { ite.Next(); + } } } } myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); } else + { index++; + } } else { @@ -1112,12 +1286,16 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(edge1); SendWarning(edge1, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(edge1)) + { theSmallEdges.Remove(edge1); + } theEdgeToFaces.UnBind(edge1); myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); } else + { index++; + } } else if (!take_next && theList2.Extent() == 1) { @@ -1128,19 +1306,27 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(edge2); SendWarning(edge2, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(edge2)) + { theSmallEdges.Remove(edge2); + } theEdgeToFaces.UnBind(edge2); myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); } else + { index++; + } } else + { index++; + } } } else + { index++; + } } if (SFW->NbEdges() == 1 && aModeDrop) { @@ -1221,24 +1407,40 @@ bool ShapeFix_Wireframe::MergeSmallEdges( C1->D1(last1, P, Vec1); C2->D1(first2, P, Vec2); if (edge1.Orientation() == TopAbs_REVERSED) + { Vec1.Reverse(); + } if (edge2.Orientation() == TopAbs_REVERSED) + { Vec2.Reverse(); + } constexpr double tol2 = Precision::SquareConfusion(); if (Vec1.SquareMagnitude() < tol2 || Vec2.SquareMagnitude() < tol2) + { Ang1 = M_PI / 2.; + } else + { Ang1 = std::abs(Vec1.Angle(Vec2)); + } C2->D1(last2, P, Vec1); C3->D1(first3, P, Vec2); if (edge2.Orientation() == TopAbs_REVERSED) + { Vec1.Reverse(); + } if (edge3.Orientation() == TopAbs_REVERSED) + { Vec2.Reverse(); + } if (Vec1.SquareMagnitude() < tol2 || Vec2.SquareMagnitude() < tol2) + { Ang2 = M_PI / 2.; + } else + { Ang2 = std::abs(Vec1.Angle(Vec2)); + } // isLimAngle = (theLimitAngle != -1 && std::min(Ang1,Ang2) > theLimitAngle); // take_next = (Ang2 theList1, theList2, theList3; if (theEdgeToFaces.IsBound(edge1)) + { theList1 = theEdgeToFaces(edge1); + } if (theEdgeToFaces.IsBound(edge2)) + { theList2 = theEdgeToFaces(edge2); + } if (theEdgeToFaces.IsBound(edge3)) + { theList3 = theEdgeToFaces(edge3); + } bool same_set = false; // gka protection against joining seem edges with other edges @@ -1271,14 +1479,18 @@ bool ShapeFix_Wireframe::MergeSmallEdges( && ((!isSeam && !isSeam2) || (isSeam && isSeam2))); NCollection_Map theSetOfFaces; for (NCollection_List::Iterator itf1(theList2); itf1.More(); itf1.Next()) + { theSetOfFaces.Add(itf1.Value()); + } if (same_set1) { // Add all faces of the first edge to the current set for (NCollection_List::Iterator itf2(theList1); (itf2.More() && same_set1); itf2.Next()) + { same_set1 = theSetOfFaces.Contains(itf2.Value()); + } } if (same_set2) { @@ -1286,13 +1498,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( for (NCollection_List::Iterator itf2(theList3); (itf2.More() && same_set2); itf2.Next()) + { same_set2 = theSetOfFaces.Contains(itf2.Value()); + } } if (same_set1 && same_set2) { same_set = true; if (fabs(Ang2 - Ang1) > Precision::Angular()) + { take_next = (Ang2 < Ang1); + } if (take_next) { edge1 = edge2; @@ -1322,13 +1538,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( aItF.Next()) { if (aItF.Value().IsSame(anExpf2.Current())) + { continue; + } TopoDS_Shape aF = Context()->Apply(aItF.Value()); // aF = aF.Oriented(TopAbs_FORWARD); for (TopoDS_Iterator aIw(aF); aIw.More(); aIw.Next()) { if (aIw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wt = TopoDS::Wire(aIw.Value()); occ::handle SFW1 = new ShapeFix_Wire; SFW1->Load(wt); @@ -1357,7 +1577,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( ReplaceFirst = JoinEdges(edge1, edge2, edge3, aListF); } else + { edge3 = TopoDS_Edge(); + } if (edge3.IsNull()) { index++; @@ -1374,12 +1596,14 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theNewVertices.Bind(oldV1, TopoDS::Vertex(emptyCopiedV1)); } if (!oldV1.IsSame(oldV2)) + { if (!theNewVertices.IsBound(oldV2)) // smh#8 { TopoDS_Shape emptyCopiedV2 = oldV2.EmptyCopied(); theNewVertices.Bind(oldV2, TopoDS::Vertex(emptyCopiedV2)); } + } // To keep NM vertices belonging initial edges TopoDS_Iterator aItv(edge1, false); for (; aItv.More(); aItv.Next()) @@ -1445,11 +1669,17 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdgeToFaces.UnBind(edge2); theEdgeToFaces.Bind(edge3, theList); if (theSmallEdges.Contains(edge1)) + { theSmallEdges.Remove(edge1); + } if (theSmallEdges.Contains(edge2)) + { theSmallEdges.Remove(edge2); + } if (newsmall) + { theSmallEdges.Add(edge3); + } for (NCollection_List::Iterator itlf(theList); itlf.More(); itlf.Next()) { TopoDS_Shape curface = itlf.Value(); @@ -1457,19 +1687,27 @@ bool ShapeFix_Wireframe::MergeSmallEdges( { NCollection_List& theEdges = theFaceWithSmall(curface); if (newsmall) + { theEdges.Append(edge3); + } NCollection_List::Iterator ite(theEdges); while (ite.More()) { TopoDS_Shape iedge = ite.Value(); if (iedge.IsSame(edge1) || iedge.IsSame(edge2)) + { theEdges.Remove(ite); + } else + { ite.Next(); + } } // Remove face without small edges from the map if (!theEdges.Extent()) + { theFaceWithSmall.UnBind(curface); + } } } myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); @@ -1482,9 +1720,13 @@ bool ShapeFix_Wireframe::MergeSmallEdges( tempWire->Add(SFW->Wire()); TopoDS_Edge remedge; if (take_next) + { remedge = edge1; + } else + { remedge = edge2; + } tempWire->Remove(index); tempSaw.Load(tempWire); int newindex = (index <= tempSaw.NbEdges() ? index : 1); @@ -1497,10 +1739,14 @@ bool ShapeFix_Wireframe::MergeSmallEdges( tempWire->Edge(newindex == 1 ? tempSaw.NbEdges() : (newindex - 1)); NCollection_List aL1; if (theEdgeToFaces.IsBound(tmpedge1)) + { aL1 = theEdgeToFaces.Find(tmpedge1); + } NCollection_List aL2; if (theEdgeToFaces.IsBound(tmpedge2)) + { aL2 = theEdgeToFaces.Find(tmpedge2); + } SFW->FixConnected(newindex <= SFW->NbEdges() ? newindex : 1, Precision()); SFW->FixDegenerated(newindex <= SFW->NbEdges() ? newindex : 1); TopoDS_Shape aTmpShape = Context()->Apply(tmpedge1); // for porting @@ -1510,7 +1756,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(remedge); SendWarning(remedge, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(remedge)) + { theSmallEdges.Remove(remedge); + } theEdgeToFaces.UnBind(remedge); theEdgeToFaces.UnBind(tmpedge1); theEdgeToFaces.UnBind(tmpedge2); @@ -1534,7 +1782,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdges.Append(anewedge1); } else + { ite.Next(); + } } } } @@ -1556,14 +1806,18 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theEdges.Append(anewedge2); } else + { ite.Next(); + } } } } myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); } else + { index++; + } } else { @@ -1594,12 +1848,16 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(edge1); SendWarning(edge1, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(edge1)) + { theSmallEdges.Remove(edge1); + } theEdgeToFaces.UnBind(edge1); myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); } else + { index++; + } } else if (!take_next && theList2.Extent() == 1) { @@ -1610,19 +1868,27 @@ bool ShapeFix_Wireframe::MergeSmallEdges( Context()->Remove(edge2); SendWarning(edge2, Message_Msg("FixWireframe.FixSmallEdges.MSG0")); if (theSmallEdges.Contains(edge2)) + { theSmallEdges.Remove(edge2); + } theEdgeToFaces.UnBind(edge2); myStatusSmallEdges |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); } else + { index++; + } } else + { index++; + } } } else + { index++; + } } if (SFW->NbEdges() == 1 && aModeDrop) { @@ -1651,7 +1917,9 @@ bool ShapeFix_Wireframe::MergeSmallEdges( theNewVertices); itv.More(); itv.Next()) + { Context()->Replace(itv.Key(), itv.Value()); + } TopoDS_Shape shape = myShape; myShape.Nullify(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess.cxx index 16850929ab..854e838318 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess.cxx @@ -115,7 +115,9 @@ bool ShapeProcess::Perform(const occ::handle& context, { oper = sequence.Token(" \t,;", i); if (oper.Length() <= 0) + { break; + } sequenceOfOperators.Append(oper); } @@ -127,7 +129,9 @@ bool ShapeProcess::Perform(const occ::handle& context, for (int i1 = 1; i1 <= sequenceOfOperators.Length(); i1++) { if (i1 > 1) + { Seq += ","; + } Seq += sequenceOfOperators.Value(i1); } SMSG0.Arg(Seq.ToCString()); @@ -165,7 +169,9 @@ bool ShapeProcess::Perform(const occ::handle& context, { OCC_CATCH_SIGNALS if (op->Perform(context, aRange)) + { isDone = true; + } } catch (Standard_Failure const& anException) { diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_Context.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_Context.cxx index 59384e0208..20dac3d918 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_Context.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_Context.cxx @@ -119,10 +119,14 @@ occ::handle ShapeProcess_Context::LoadResourceManager(const ch isFileModified = true; } if (isFileModified) + { sRC.Nullify(); + } } else + { sRC.Nullify(); + } } if (sRC.IsNull()) { @@ -156,7 +160,9 @@ const occ::handle& ShapeProcess_Context::ResourceManager() con void ShapeProcess_Context::SetScope(const char* const scope) { if (myScope.IsNull()) + { myScope = new NCollection_HSequence>; + } occ::handle str; if (myScope->Length() > 0) { @@ -165,7 +171,9 @@ void ShapeProcess_Context::SetScope(const char* const scope) str->AssignCat(scope); } else + { str = new TCollection_HAsciiString(scope); + } myScope->Append(str); } @@ -174,7 +182,9 @@ void ShapeProcess_Context::SetScope(const char* const scope) void ShapeProcess_Context::UnSetScope() { if (!myScope.IsNull() && myScope->Length() > 0) + { myScope->Remove(myScope->Length()); + } } //================================================================================================= @@ -191,7 +201,9 @@ static occ::handle MakeName( str->AssignCat(param); } else + { str = new TCollection_HAsciiString(param); + } return str; } @@ -205,7 +217,9 @@ bool ShapeProcess_Context::IsParamSet(const char* const param) const bool ShapeProcess_Context::GetString(const char* const param, TCollection_AsciiString& str) const { if (myRC.IsNull()) + { return false; + } occ::handle pname = MakeName(myScope, param); if (!myRC->Find(pname->ToCString())) { @@ -224,11 +238,15 @@ bool ShapeProcess_Context::GetString(const char* const param, TCollection_AsciiS bool ShapeProcess_Context::GetReal(const char* const param, double& val) const { if (myRC.IsNull()) + { return false; + } TCollection_AsciiString str; if (!GetString(param, str)) + { return false; + } if (str.IsRealValue()) { @@ -270,11 +288,15 @@ bool ShapeProcess_Context::GetReal(const char* const param, double& val) const bool ShapeProcess_Context::GetInteger(const char* const param, int& val) const { if (myRC.IsNull()) + { return false; + } TCollection_AsciiString str; if (!GetString(param, str)) + { return false; + } if (str.IsIntegerValue()) { @@ -316,7 +338,9 @@ bool ShapeProcess_Context::GetInteger(const char* const param, int& val) const bool ShapeProcess_Context::GetBoolean(const char* const param, bool& val) const { if (myRC.IsNull()) + { return false; + } try { OCC_CATCH_SIGNALS @@ -364,7 +388,9 @@ int ShapeProcess_Context::IntegerVal(const char* const param, const int def) con const char* ShapeProcess_Context::StringVal(const char* const param, const char* const def) const { if (myRC.IsNull()) + { return def; + } try { OCC_CATCH_SIGNALS @@ -387,9 +413,13 @@ const char* ShapeProcess_Context::StringVal(const char* const param, const char* void ShapeProcess_Context::SetMessenger(const occ::handle& messenger) { if (messenger.IsNull()) + { myMessenger = Message::DefaultMessenger(); + } else + { myMessenger = messenger; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_OperLibrary.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_OperLibrary.cxx index 0959769454..ca27155f88 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_OperLibrary.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_OperLibrary.cxx @@ -77,20 +77,25 @@ TopoDS_Shape ShapeProcess_OperLibrary::ApplyModifier( shape.Location(nullLoc); TopoDS_Shape res; if (map.IsBound(shape)) + { res = map.Find(shape).Oriented(shape.Orientation()); - + } else { res = ApplyModifier(shape, context, M, map, nullptr, theMutableInput); map.Bind(shape, res); } if (!res.IsSame(shape)) + { locModified = true; + } res.Location(L, false); B.Add(C, res); } if (!locModified) + { return S; + } map.Bind(SF, C); return C.Oriented(S.Orientation()); @@ -111,12 +116,16 @@ static bool directfaces(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle DM = new ShapeCustom_DirectModification; DM->SetMsgRegistrator(msg); @@ -135,12 +144,16 @@ static bool sameparam(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } ShapeFix::SameParameter(ctx->Result(), ctx->BooleanVal("Force", false), @@ -163,7 +176,9 @@ static bool settol(const occ::handle& context, const Messa { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } double val; if (ctx->IntegerVal("Mode", 0) > 0 && ctx->GetReal("Value", val)) @@ -180,7 +195,9 @@ static bool settol(const occ::handle& context, const Messa double reg; if (ctx->GetReal("Regularity", reg)) + { BRepLib::EncodeRegularity(ctx->Result(), reg); + } // WARNING: no update of context yet! return true; @@ -193,12 +210,16 @@ static bool splitangle(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } ShapeUpgrade_ShapeDivideAngle SDA(ctx->RealVal("Angle", 2 * M_PI), ctx->Result()); SDA.SetMaxTolerance(ctx->RealVal("MaxTolerance", 1.)); @@ -224,12 +245,16 @@ static bool bsplinerestriction(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } bool ModeSurf = ctx->BooleanVal("SurfaceMode", true); bool ModeC3d = ctx->BooleanVal("Curve3dMode", true); @@ -295,12 +320,16 @@ static bool torevol(const occ::handle& context, const Mess { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle CR = new ShapeCustom_ConvertToRevolution(); CR->SetMsgRegistrator(msg); @@ -319,12 +348,16 @@ static bool swepttoelem(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle SE = new ShapeCustom_SweptToElementary(); SE->SetMsgRegistrator(msg); @@ -343,12 +376,16 @@ static bool shapetobezier(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } bool ModeC3d = ctx->BooleanVal("Curve3dMode", false); bool ModeC2d = ctx->BooleanVal("Curve2dMode", false); @@ -384,13 +421,19 @@ static bool shapetobezier(const occ::handle& context, double maxTol, minTol; if (ctx->GetReal("MaxTolerance", maxTol)) + { SCB.SetMaxTolerance(maxTol); + } if (ctx->GetReal("MinCurveLength", minTol)) + { SCB.SetMinTolerance(minTol); + } bool EdgeMode; if (ctx->GetBoolean("EdgeMode", EdgeMode)) + { SCB.SetEdgeMode(EdgeMode); + } if (!SCB.Perform() && SCB.Status(ShapeExtend_FAIL)) { @@ -412,12 +455,16 @@ static bool converttobspline(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } bool extrMode = ctx->BooleanVal("LinearExtrusionMode", true); bool revolMode = ctx->BooleanVal("RevolutionMode", true); @@ -444,12 +491,16 @@ static bool splitcontinuity(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } double aTol = ctx->RealVal("Tolerance3d", 1.e-7); double aTol2D = ctx->RealVal("Tolerance2d", 1.e-9); @@ -467,7 +518,9 @@ static bool splitcontinuity(const occ::handle& context, double maxTol; if (ctx->GetReal("MaxTolerance", maxTol)) + { tool.SetMaxTolerance(maxTol); + } if (!tool.Perform() && tool.Status(ShapeExtend_FAIL)) { @@ -489,23 +542,31 @@ static bool splitclosedfaces(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } ShapeUpgrade_ShapeDivideClosed tool(ctx->Result()); tool.SetMsgRegistrator(msg); double closeTol; if (ctx->GetReal("CloseTolerance", closeTol)) + { tool.SetPrecision(closeTol); + } double maxTol; if (ctx->GetReal("MaxTolerance", maxTol)) + { tool.SetMaxTolerance(maxTol); + } int num = ctx->IntegerVal("NbSplitPoints", 1); bool hasSeg = true; @@ -533,12 +594,16 @@ static bool fixfacesize(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle reshape = new ShapeBuild_ReShape; ShapeFix_FixSmallFace FSC; @@ -548,7 +613,9 @@ static bool fixfacesize(const occ::handle& context, double aTol; if (ctx->GetReal("Tolerance", aTol)) + { FSC.SetPrecision(aTol); + } FSC.Perform(); TopoDS_Shape newsh = FSC.Shape(); @@ -568,12 +635,16 @@ static bool fixwgaps(const occ::handle& context, const Mes { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } double aTol3d = ctx->RealVal("Tolerance3d", Precision::Confusion()); @@ -600,12 +671,16 @@ static bool dropsmallsolids(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } ShapeFix_FixSmallSolid FSS; FSS.SetMsgRegistrator(msg); @@ -613,11 +688,17 @@ static bool dropsmallsolids(const occ::handle& context, double aThreshold; int aMode; if (ctx->GetInteger("FixMode", aMode)) + { FSS.SetFixMode(aMode); + } if (ctx->GetReal("VolumeThreshold", aThreshold)) + { FSS.SetVolumeThreshold(aThreshold); + } if (ctx->GetReal("WidthFactorThreshold", aThreshold)) + { FSS.SetWidthFactorThreshold(aThreshold); + } bool aMerge = false; ctx->GetBoolean("MergeSolids", aMerge); @@ -626,9 +707,13 @@ static bool dropsmallsolids(const occ::handle& context, TopoDS_Shape aResult; if (aMerge) + { aResult = FSS.Merge(ctx->Result(), aReShape); + } else + { aResult = FSS.Remove(ctx->Result(), aReShape); + } if (aResult != ctx->Result()) { @@ -669,12 +754,16 @@ static bool mergesmalledges(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } double aTol3d = ctx->RealVal("Tolerance3d", Precision::Confusion()); @@ -698,12 +787,16 @@ static bool fixshape(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle sfs = new ShapeFix_Shape; occ::handle sff = sfs->FixFaceTool(); @@ -813,12 +906,16 @@ static bool spltclosededges(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } int nbSplits = ctx->IntegerVal("NbSplitPoints", 1); @@ -850,12 +947,16 @@ static bool splitcommonvertex(const occ::handle& context, { occ::handle ctx = occ::down_cast(context); if (ctx.IsNull()) + { return false; + } // activate message mechanism if it is supported by context occ::handle msg; if (!ctx->Messages().IsNull()) + { msg = new ShapeExtend_MsgRegistrator; + } occ::handle reshape = new ShapeBuild_ReShape; ShapeFix_SplitCommonVertex SCV; @@ -882,7 +983,9 @@ void ShapeProcess_OperLibrary::Init() { static bool done = false; if (done) + { return; + } done = true; ShapeExtend::Init(); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_ShapeContext.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_ShapeContext.cxx index 408b768e7f..8f2dcb8fea 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_ShapeContext.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeProcess/ShapeProcess_ShapeContext.cxx @@ -150,7 +150,9 @@ static void RecModif( r.Location(aNullLoc); if (map.IsBound(r)) + { r = map.Find(r); + } if (!r.IsNull()) { TopoDS_Shape res = r; @@ -162,7 +164,9 @@ static void RecModif( // hence, if it is reversed, result should be reversed too // INTERNAL or EXTERNAL orientations are not allowed if (r.Orientation() != TopAbs_FORWARD) + { res.Reverse(); + } } // Treat special case: if S was split, r will be a compound of // resulting shapes, each to be checked separately @@ -180,22 +184,30 @@ static void RecModif( { const TopoDS_Shape& newsh = repl.Find(sh); if (!newsh.IsNull()) + { B.Add(result, newsh); + } modif = true; } else + { B.Add(result, sh); + } } if (modif) { if (result.ShapeType() == TopAbs_WIRE || result.ShapeType() == TopAbs_SHELL) + { result.Closed(BRep_Tool::IsClosed(result)); + } res = result; } } if (res != r) + { map.Bind(S.Located(aNullLoc), res); + } } // update messages (messages must be taken from each level in the substitution map) @@ -207,18 +219,24 @@ static void RecModif( { const NCollection_List& msglist = msgmap.Find(r); for (NCollection_List::Iterator iter(msglist); iter.More(); iter.Next()) + { myMsg->Send(S, iter.Value(), Message_Warning); + } } else if (msgmap.IsBound(S)) { const NCollection_List& msglist = msgmap.Find(S); for (NCollection_List::Iterator iter(msglist); iter.More(); iter.Next()) + { myMsg->Send(S, iter.Value(), Message_Warning); + } } } if (until == TopAbs_SHAPE || S.ShapeType() >= until) + { return; + } for (TopoDS_Iterator it(S); it.More(); it.Next()) { @@ -231,10 +249,14 @@ void ShapeProcess_ShapeContext::RecordModification( const occ::handle& msg) { if (repl.Extent() <= 0) + { return; + } RecModif(myShape, repl, msg, myMap, myMsg, myUntil); if (myMap.IsBound(myShape)) + { myResult = myMap.Find(myShape); + } #ifdef OCCT_DEBUG // std::cout << "Modifier: " << std::endl; DumpMap (myMap); #endif @@ -250,27 +272,35 @@ static void RecModif(const TopoDS_Shape& const TopAbs_ShapeEnum until) { if (S.IsNull()) + { return; + } // gka -modification to keep history for shape with location (OCC21617) TopLoc_Location aNullLoc; TopoDS_Shape aS = S.Located(aNullLoc); TopoDS_Shape r = aS; if (map.IsBound(r)) + { r = map.Find(r); + } if (!r.IsNull()) { TopoDS_Shape res; if (repl->Status(r, res, true) && res != r) + { map.Bind(aS, res); - // Treat special case: if S was split, r will be a compound of - // resulting shapes, recursive procedure should be applied + // Treat special case: if S was split, r will be a compound of + // resulting shapes, recursive procedure should be applied + } else if (r.ShapeType() < S.ShapeType()) { res = repl->Apply(r, (TopAbs_ShapeEnum)((int)S.ShapeType() + 1)); if (res != r) + { map.Bind(aS, res); + } } } @@ -281,7 +311,9 @@ static void RecModif(const TopoDS_Shape& const NCollection_DataMap, TopTools_ShapeMapHasher>& msgmap = msg->MapShape(); if (msgmap.IsBound(S)) + { next = S; + } // Map to prevent infinite loops in case of cyclic replacements. NCollection_Map aVisitedShapes; @@ -306,7 +338,9 @@ static void RecModif(const TopoDS_Shape& } if (until == TopAbs_SHAPE || S.ShapeType() >= until) + { return; + } for (TopoDS_Iterator it(S, false /*,false*/); it.More(); it.Next()) { @@ -345,7 +379,9 @@ void ShapeProcess_ShapeContext::AddMessage(const TopoDS_Shape& S, const Message_Gravity grv) { if (!myMsg.IsNull()) + { myMsg->Send(S, msg, grv); + } } //================================================================================================= @@ -363,7 +399,9 @@ static void ExplodeModifier( map.Bind(S, res); } if (until == TopAbs_SHAPE || S.ShapeType() >= until) + { return; + } for (TopoDS_Iterator it(S); it.More(); it.Next()) { ExplodeModifier(it.Value(), repl, map, until); @@ -386,28 +424,46 @@ bool ShapeProcess_ShapeContext::GetContinuity(const char* const param, GeomAbs_S { TCollection_AsciiString str; if (!GetString(param, str)) + { return false; + } str.LeftAdjust(); str.RightAdjust(); str.UpperCase(); if (str.IsEqual("C0")) + { cont = GeomAbs_C0; + } else if (str.IsEqual("G1")) + { cont = GeomAbs_G1; + } else if (str.IsEqual("C1")) + { cont = GeomAbs_C1; + } else if (str.IsEqual("G2")) + { cont = GeomAbs_G2; + } else if (str.IsEqual("C2")) + { cont = GeomAbs_C2; + } else if (str.IsEqual("C3")) + { cont = GeomAbs_C3; + } else if (str.IsEqual("CN")) + { cont = GeomAbs_CN; + } else + { return false; + } return true; } @@ -431,18 +487,30 @@ void ShapeProcess_ShapeContext::PrintStatistics() const { TopoDS_Shape keyshape = It.Key(), valueshape = It.Value(); if (keyshape.ShapeType() == TopAbs_SHELL) + { if (valueshape.IsNull()) + { SN++; + } else + { SS++; + } + } else if (keyshape.ShapeType() == TopAbs_FACE) { if (valueshape.IsNull()) + { FN++; + } else if (valueshape.ShapeType() == TopAbs_SHELL) + { FS++; + } else + { FF++; + } } } @@ -477,9 +545,13 @@ void ShapeProcess_ShapeContext::PrintStatistics() const int STotalR = SS, FTotalR = FF + FS; int NbS = STotalR + SN, NbF = FTotalR + FN; if (NbS > 0) + { SPR = 1. * (NbS - SN) / NbS; + } if (NbF > 0) + { FPR = 1. * (NbF - FN) / NbF; + } Message_Msg PMSG200("PrResult.Print.MSG200"); // Preparation ratio: Messenger()->Send(PMSG200, Message_Info); Message_Msg PMSG205("PrResult.Print.MSG205"); // Shells: %d per cent diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeProcessAPI/ShapeProcessAPI_ApplySequence.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeProcessAPI/ShapeProcessAPI_ApplySequence.cxx index 0d1d80d4b0..437fe247f4 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeProcessAPI/ShapeProcessAPI_ApplySequence.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeProcessAPI/ShapeProcessAPI_ApplySequence.cxx @@ -55,7 +55,9 @@ TopoDS_Shape ShapeProcessAPI_ApplySequence::PrepareShape(const TopoDS_Shape& sha const Message_ProgressRange& theProgress) { if (shape.IsNull()) + { return shape; + } occ::handle rsc = myContext->ResourceManager(); myContext->Init(shape); @@ -98,18 +100,28 @@ void ShapeProcessAPI_ApplySequence::PrintPreparationResult() const if (keyshape.ShapeType() == TopAbs_SHELL) { if (valueshape.IsNull()) + { SN++; + } else + { SS++; + } } else if (keyshape.ShapeType() == TopAbs_FACE) { if (valueshape.IsNull()) + { FN++; + } else if (valueshape.ShapeType() == TopAbs_SHELL) + { FS++; + } else + { FF++; + } } } @@ -146,9 +158,13 @@ void ShapeProcessAPI_ApplySequence::PrintPreparationResult() const int STotalR = SS, FTotalR = FF + FS; int NbS = STotalR + SN, NbF = FTotalR + FN; if (NbS > 0) + { SPR = 1. * (NbS - SN) / NbS; + } if (NbF > 0) + { FPR = 1. * (NbF - FN) / NbF; + } Message_Msg PMSG200("PrResult.Print.MSG200"); // Preparation ratio: aMessenger->Send(PMSG200, Message_Info); Message_Msg PMSG205("PrResult.Print.MSG205"); // Shells: %d per cent diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade.cxx index de71cebecb..d9b66eb83f 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade.cxx @@ -42,7 +42,9 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve( occ::handle>>& seqBS) { if (BS.IsNull() || (BS->IsCN(1))) + { return false; + } seqBS = new NCollection_HSequence>; BS->SetNotPeriodic(); // to have equation NbPoles = NbKnots with Multiplicities - degree - 1 @@ -60,7 +62,9 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve( for (EndKnotIndex = StartKnotIndex + 1; EndKnotIndex <= BS->LastUKnotIndex(); EndKnotIndex++) { if ((Mults(EndKnotIndex) < deg) && (EndKnotIndex < BS->LastUKnotIndex())) + { continue; + } int StartFlatIndex = BSplCLib::FlatIndex(deg, StartKnotIndex, Mults, false); // StartFlatIndex += Mults (StartKnotIndex) - 1; @@ -74,16 +78,26 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve( TempKnots(TempKnotIndex) = KnotSequence(StartFlatIndex - deg); for (j = StartFlatIndex - deg + 1; j <= EndFlatIndex + deg; j++) + { if (std::abs(KnotSequence(j) - KnotSequence(j - 1)) <= gp::Resolution()) + { TempMults(TempKnotIndex)++; + } else + { TempKnots(++TempKnotIndex) = KnotSequence(j); + } + } int TempStartIndex = 1, TempEndIndex = TempKnotIndex; if (TempMults(TempStartIndex) == 1) + { TempMults(++TempStartIndex)++; + } if (TempMults(TempEndIndex) == 1) + { TempMults(--TempEndIndex)++; + } int NewNbKnots = TempEndIndex - TempStartIndex + 1; NCollection_Array1 newMults(1, NewNbKnots); @@ -128,7 +142,9 @@ static occ::handle BSplineCurve2dTo3d(const occ::handle Poles3d(1, NbPoles); for (int i = 1; i <= NbPoles; i++) + { Poles3d(i) = gp_Pnt(Poles2d(i).X(), Poles2d(i).Y(), 0); + } occ::handle BS3d = new Geom_BSplineCurve(Poles3d, Weights, Knots, Mults, deg, BS->IsPeriodic()); @@ -146,7 +162,9 @@ static occ::handle BSplineCurve3dTo2d(const occ::handle Poles2d(1, NbPoles); for (int i = 1; i <= NbPoles; i++) + { Poles2d(i) = gp_Pnt2d(Poles3d(i).X(), Poles3d(i).Y()); + } occ::handle BS2d = new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults, deg, BS->IsPeriodic()); @@ -158,7 +176,9 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve( occ::handle>>& seqBS) { if (BS.IsNull() || (BS->IsCN(1))) + { return false; + } occ::handle BS3d = BSplineCurve2dTo3d(BS); occ::handle>> seqBS3d; @@ -167,7 +187,9 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve( { seqBS = new NCollection_HSequence>; for (int i = 1; i <= seqBS3d->Length(); i++) + { seqBS->Append(BSplineCurve3dTo2d(occ::down_cast(seqBS3d->Value(i)))); + } } return result; } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedEdgeDivide.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedEdgeDivide.cxx index ea191d1db8..48ab83eee1 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedEdgeDivide.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedEdgeDivide.cxx @@ -96,7 +96,9 @@ bool ShapeUpgrade_ClosedEdgeDivide::Compute(const TopoDS_Edge& anEdge) return true; } else + { return false; + } } if (myHasCurve2d) @@ -129,11 +131,15 @@ bool ShapeUpgrade_ClosedEdgeDivide::Compute(const TopoDS_Edge& anEdge) return true; } else + { return false; + } } return false; } else + { return false; + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedFaceDivide.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedFaceDivide.cxx index 7260db3e46..bbb118c278 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedFaceDivide.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ClosedFaceDivide.cxx @@ -63,7 +63,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) { occ::handle SplitSurf = GetSplitSurfaceTool(); if (SplitSurf.IsNull()) + { return false; + } if (myResult.IsNull() || myResult.ShapeType() != TopAbs_FACE) { @@ -77,7 +79,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) // 01.10.99 pdn Porting on DEC if (::Precision::IsInfinite(Uf) || ::Precision::IsInfinite(Ul) || ::Precision::IsInfinite(Vf) || ::Precision::IsInfinite(Vl)) + { return false; + } TopLoc_Location L; occ::handle surf; @@ -90,10 +94,13 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) for (TopoDS_Iterator iter(face); iter.More() && !doSplit; iter.Next()) { if (iter.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wire = TopoDS::Wire(iter.Value()); occ::handle sewd = new ShapeExtend_WireData(wire); for (int i = 1; i <= sewd->NbEdges() && !doSplit; i++) + { if (sewd->IsSeam(i)) { doSplit = true; @@ -102,13 +109,19 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) occ::handle c1, c2; double f1, f2, l1, l2; if (!sae.PCurve(edge, face, c1, f1, l1, false)) + { continue; + } // smh#8 TopoDS_Shape tmpE = edge.Reversed(); if (!sae.PCurve(TopoDS::Edge(tmpE), face, c2, f2, l2, false)) + { continue; + } if (c2 == c1) + { continue; + } // splitting ShapeAnalysis_Curve sac; Bnd_Box2d B1, B2; @@ -147,7 +160,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) double step = dU / (myNbSplit + 1); double val = xf + step; for (int j = 1; j <= myNbSplit; j++, val += step) + { split->Append(val); + } isUSplit = true; } else @@ -155,10 +170,13 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) double step = dV / (myNbSplit + 1); double val = yf + step; for (int j = 1; j <= myNbSplit; j++, val += step) + { split->Append(val); + } isUSplit = false; } } + } } if (!doSplit) @@ -184,7 +202,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) double step = (Ul - Uf) / (myNbSplit + 1); double val = Uf + step; for (int i = 1; i <= myNbSplit; i++, val += step) + { split->Append(val); + } isUSplit = true; } #ifdef OCCT_DEBUG @@ -209,7 +229,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) double step = (Vl - Vf) / (myNbSplit + 1); double val = Vf + step; for (int i = 1; i <= myNbSplit; i++, val += step) + { split->Append(val); + } isUSplit = false; } #ifdef OCCT_DEBUG @@ -221,17 +243,25 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) } if (!doSplit) + { return false; + } SplitSurf->Init(surf, Uf, Ul, Vf, Vl); if (isUSplit) + { SplitSurf->SetUSplitValues(split); + } else + { SplitSurf->SetVSplitValues(split); + } SplitSurf->Perform(mySegmentMode); if (!SplitSurf->Status(ShapeExtend_DONE)) + { return false; + } occ::handle Grid = SplitSurf->ResSurfaces(); ShapeFix_ComposeShell CompShell; @@ -240,7 +270,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) CompShell.SetContext(Context()); CompShell.Perform(); if (CompShell.Status(ShapeExtend_FAIL) || !CompShell.Status(ShapeExtend_DONE)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } TopoDS_Shape res = CompShell.Result(); myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); @@ -251,7 +283,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) TopoDS_Face f = TopoDS::Face(tempf); myResult = f; if (SplitSurface()) + { Context()->Replace(f, myResult); + } } myResult = Context()->Apply(res); return true; @@ -262,7 +296,9 @@ bool ShapeUpgrade_ClosedFaceDivide::SplitSurface(const double) void ShapeUpgrade_ClosedFaceDivide::SetNbSplitPoints(const int num) { if (num > 0) + { myNbSplit = num; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx index 63bb814937..4ba727dbfb 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx @@ -147,9 +147,13 @@ void ShapeUpgrade_ConvertCurve2dToBezier::Compute() // clang-format on Geom2dConvert_ApproxCurve approx(tcurve, Precision::Approximation(), GeomAbs_C1, 100, 6); if (approx.HasResult()) + { aBSpline2d = approx.Curve(); + } else + { aBSpline2d = Geom2dConvert::CurveToBSplineCurve(tcurve, Convert_QuasiAngular); + } Shift = First - aBSpline2d->FirstParameter(); First = aBSpline2d->FirstParameter(); @@ -160,14 +164,20 @@ void ShapeUpgrade_ConvertCurve2dToBezier::Compute() aBSpline2d = Geom2dConvert::CurveToBSplineCurve(myCurve, Convert_QuasiAngular); } else + { aBSpline2d = occ::down_cast(myCurve); + } double bf = aBSpline2d->FirstParameter(); double bl = aBSpline2d->LastParameter(); if (std::abs(First - bf) < precision) + { First = bf; + } if (std::abs(Last - bl) < precision) + { Last = bl; + } if (First < bf) { #ifdef OCCT_DEBUG @@ -238,9 +248,13 @@ void ShapeUpgrade_ConvertCurve2dToBezier::Compute() { double valknot = knots(i) + Shift; if (valknot <= First + precision) + { continue; + } if (valknot >= Last - precision) + { break; + } mySplitValues->InsertBefore(j++, valknot); } First = Last; @@ -263,10 +277,16 @@ void ShapeUpgrade_ConvertCurve2dToBezier::Build(const bool /*Segment*/) { double par = mySplitValues->Value(i); for (; j <= mySplitParams->Length(); j++) + { if (mySplitParams->Value(j) + prec > par) + { break; + } else + { prevPar = 0.; + } + } occ::handle bes = occ::down_cast(mySegments->Value(j - 1)->Copy()); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx index 7c78f37fc7..646ad33d6f 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx @@ -127,7 +127,9 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Compute() // clang-format on GeomConvert_ApproxCurve approx(tcurve, Precision::Approximation(), GeomAbs_C1, 100, 6); if (approx.HasResult()) + { aBSpline = approx.Curve(); + } else { occ::handle t3d = new Geom_TrimmedCurve(myCurve, First, Last); @@ -142,14 +144,20 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Compute() aBSpline = GeomConvert::CurveToBSplineCurve(myCurve, Convert_QuasiAngular); } else + { aBSpline = occ::down_cast(myCurve); + } double bf = aBSpline->FirstParameter(); double bl = aBSpline->LastParameter(); if (std::abs(First - bf) < precision) + { First = bf; + } if (std::abs(Last - bl) < precision) + { Last = bl; + } if (First < bf) { #ifdef OCCT_DEBUG @@ -191,9 +199,13 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Compute() { double valknot = knots(i) + Shift; if (valknot <= First + precision) + { continue; + } if (valknot >= Last - precision) + { break; + } mySplitValues->InsertBefore(j++, valknot); } First = Last; @@ -216,10 +228,16 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Build(const bool /*Segment*/) { double par = mySplitValues->Value(i); for (; j <= mySplitParams->Length(); j++) + { if (mySplitParams->Value(j) + prec > par) + { break; + } else + { prevPar = 0.; + } + } occ::handle crv = occ::down_cast(mySegments->Value(j - 1)->Copy()); if (crv->IsKind(STANDARD_TYPE(Geom_BezierCurve))) @@ -233,7 +251,9 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Build(const bool /*Segment*/) myResultingCurves->SetValue(i - 1, bes); } else + { myResultingCurves->SetValue(i - 1, crv); + } } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertSurfaceToBezierBasis.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertSurfaceToBezierBasis.cxx index 132e727749..6321f33856 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertSurfaceToBezierBasis.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ConvertSurfaceToBezierBasis.cxx @@ -61,13 +61,21 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) double UF, UL, VF, VL; mySurface->Bounds(UF, UL, VF, VL); if (!Precision::IsInfinite(UF)) + { myUSplitValues->SetValue(1, UF); + } if (!Precision::IsInfinite(UL)) + { myUSplitValues->SetValue(myUSplitValues->Length(), UL); + } if (!Precision::IsInfinite(VF)) + { myVSplitValues->SetValue(1, VF); + } if (!Precision::IsInfinite(VL)) + { myVSplitValues->SetValue(myVSplitValues->Length(), VL); + } } double UFirst = myUSplitValues->Value(1); @@ -191,25 +199,33 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) UFilteredJoints.Append(UJoints(1)); int i; for (i = 2; i <= nbUPatches + 1; i++) + { if (UJoints(i) - UJoints(i - 1) < precision) { NbUFiltered++; UReject(i - 1) = true; } else + { UFilteredJoints.Append(UJoints(i)); + } + } converter.VKnots(VJoints); NCollection_Sequence VFilteredJoints; VFilteredJoints.Append(VJoints(1)); for (i = 2; i <= nbVPatches + 1; i++) + { if (VJoints(i) - VJoints(i - 1) < precision) { NbVFiltered++; VReject(i - 1) = true; } else + { VFilteredJoints.Append(VJoints(i)); + } + } #ifdef OCCT_DEBUG if (NbVFiltered || NbUFiltered) @@ -228,13 +244,17 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) for (int ind1 = 1; ind1 <= nbUPatches; ind1++) { if (UReject(ind1)) + { continue; + } indApp1++; int indApp2 = 0; for (int ind2 = 1; ind2 <= nbVPatches; ind2++) { if (VReject(ind2)) + { continue; + } indApp2++; srf->SetValue(indApp1, indApp2, Surfaces(ind1, ind2)); } @@ -242,11 +262,15 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) NCollection_Array1 uj(1, UFilteredJoints.Length()); for (i = 1; i <= UFilteredJoints.Length(); i++) + { uj(i) = UFilteredJoints.Value(i); + } NCollection_Array1 vj(1, VFilteredJoints.Length()); for (i = 1; i <= VFilteredJoints.Length(); i++) + { vj(i) = VFilteredJoints.Value(i); + } mySegments = new ShapeExtend_CompositeSurface(srf, uj, vj); @@ -258,9 +282,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) { double valknot = UJoints(ii); if (valknot - UFirst <= precision) + { continue; + } if (ULast - valknot <= precision) + { break; + } myUSplitValues->InsertBefore(j++, valknot); } UFirst = ULast; @@ -272,9 +300,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) { double valknot = VJoints(ii); if (valknot - VFirst <= precision) + { continue; + } if (VLast - valknot <= precision) + { break; + } myVSplitValues->InsertBefore(j++, valknot); } VFirst = VLast; @@ -306,9 +338,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) converter.Init(bas, VFirst, VLast); converter.Perform(true); if (converter.Status(ShapeExtend_DONE)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } else + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); + } vPar->ChangeSequence() = converter.SplitParams()->Sequence(); vSVal->ChangeSequence() = converter.SplitValues()->Sequence(); @@ -327,9 +363,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) converter.Init(basis, VFirst, VLast); converter.Perform(true); if (converter.Status(ShapeExtend_DONE)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } else + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); + } vPar->ChangeSequence() = converter.SplitParams()->Sequence(); vSVal->ChangeSequence() = converter.SplitValues()->Sequence(); @@ -348,7 +388,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) occ::handle rev = new Geom_SurfaceOfRevolution(curves->Value(i), axis); if (UFirst - Umin < Precision::PConfusion() && Umax - ULast < Precision::PConfusion()) + { surf->SetValue(1, i, rev); + } else { occ::handle rect = @@ -361,7 +403,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) UJoints(1) = UFirst; UJoints(2) = ULast; for (i = 1; i <= nbCurves + 1; i++) + { VJoints(i) = vPar->Value(i); + } mySegments = new ShapeExtend_CompositeSurface(surf, UJoints, VJoints); @@ -372,9 +416,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) { double valknot = vSVal->Value(ii); if (valknot - VFirst <= precision) + { continue; + } if (VLast - valknot <= precision) + { break; + } myVSplitValues->InsertBefore(j++, valknot); } VFirst = VLast; @@ -427,7 +475,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) VJoints(1) = VFirst; VJoints(2) = VLast; for (i = 1; i <= nbCurves + 1; i++) + { UJoints(i) = uPar->Value(i); + } mySegments = new ShapeExtend_CompositeSurface(surf, UJoints, VJoints); @@ -438,9 +488,13 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) { double valknot = uSVal->Value(ii); if (valknot + UFirst <= precision) + { continue; + } if (ULast - valknot <= precision) + { break; + } myUSplitValues->InsertBefore(j++, valknot); } UFirst = ULast; @@ -463,7 +517,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment) occ::handle S; if (U1 - UFirst < precision && ULast - U2 < precision && V2 - VFirst < precision && VLast - V2 < precision) + { S = mySurface; + } else { occ::handle rts = @@ -490,7 +546,9 @@ static occ::handle GetSegment(const occ::handle& sur occ::handle bezier = occ::down_cast(surf->Copy()); constexpr double prec = Precision::PConfusion(); if (U1 < prec && U2 > 1 - prec && V1 < prec && V2 > 1 - prec) + { return bezier; + } // pdn K4L+ (work around) // double u1 = 2*U1 - 1; // double u2 = 2*U2 - 1; @@ -513,7 +571,9 @@ static occ::handle GetSegment(const occ::handle& sur S = rect->BasisSurface(); } else + { S = surf; + } if (S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { @@ -541,7 +601,9 @@ static occ::handle GetSegment(const occ::handle& sur } if (std::abs(U1 - Umin) < Precision::PConfusion() && std::abs(U2 - Umax) < Precision::PConfusion()) + { return revol; + } occ::handle res = new Geom_RectangularTrimmedSurface(revol, U1, U2, true); @@ -553,7 +615,9 @@ static occ::handle GetSegment(const occ::handle& sur surf->Bounds(Umin, Umax, Vmin, Vmax); if (U1 - Umin < Precision::PConfusion() && Umax - U2 < Precision::PConfusion() && V1 - Vmin < Precision::PConfusion() && Vmax - V2 < Precision::PConfusion()) + { return surf; + } occ::handle res = new Geom_RectangularTrimmedSurface(surf, U1, U2, V1, V2); @@ -575,7 +639,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Build(const bool /*Segment*/) S = Surface->BasisSurface(); } else + { S = mySurface; + } if (S->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { occ::handle offSur = occ::down_cast(S); @@ -599,7 +665,9 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Build(const bool /*Segment*/) { double param = myUSplitParams->Value(j1); if (parU - param < prec) + { break; + } } int j2 = 2; @@ -607,8 +675,12 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Build(const bool /*Segment*/) { double parV = myVSplitValues->Value(i2); for (; j2 <= myVSplitParams->Length(); j2++) + { if (parV - myVSplitParams->Value(j2) < prec) + { break; + } + } occ::handle patch = mySegments->Patch(j1 - 1, j2 - 1); double U1, U2, V1, V2; @@ -640,11 +712,15 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Build(const bool /*Segment*/) NCollection_Array1 UJoints(1, nbU); int i; // svv #1 for (i = 1; i <= nbU; i++) + { UJoints(i) = myUSplitValues->Value(i); + } NCollection_Array1 VJoints(1, nbV); for (i = 1; i <= nbV; i++) + { VJoints(i) = myVSplitValues->Value(i); + } myResSurfaces = new ShapeExtend_CompositeSurface(resSurfaces, UJoints, VJoints); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivide.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivide.cxx index c94d5c2941..9efa6598e8 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivide.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivide.cxx @@ -80,9 +80,13 @@ bool ShapeUpgrade_FaceDivide::Perform(const double theArea) { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK); if (myFace.IsNull()) + { return false; + } if (Context().IsNull()) + { SetContext(new ShapeBuild_ReShape); + } myResult = myFace; SplitSurface(theArea); SplitCurves(); @@ -95,7 +99,9 @@ bool ShapeUpgrade_FaceDivide::SplitSurface(const double theArea) { occ::handle SplitSurf = GetSplitSurfaceTool(); if (SplitSurf.IsNull()) + { return false; + } // myResult should be face; else return with FAIL if (myResult.IsNull() || myResult.ShapeType() != TopAbs_FACE) @@ -114,7 +120,9 @@ bool ShapeUpgrade_FaceDivide::SplitSurface(const double theArea) ShapeAnalysis::GetFaceUVBounds(face, Uf, Ul, Vf, Vl); if (Precision::IsInfinite(Uf) || Precision::IsInfinite(Ul) || Precision::IsInfinite(Vf) || Precision::IsInfinite(Vl)) + { return false; + } // make little extension to ensure all pcurves fit inside new surface bounds double aSUf, aSUl, aSVf, aSVl; @@ -123,17 +131,25 @@ bool ShapeUpgrade_FaceDivide::SplitSurface(const double theArea) { double dU = (Ul - Uf) * 0.01; if (Uf > aSUf) + { Uf -= std::min(dU, Uf - aSUf); + } if (Ul < aSUl) + { Ul += std::min(dU, aSUl - Ul); + } } if (!surf->IsVPeriodic()) { double dV = (Vl - Vf) * 0.01; if (Vf > aSVf) + { Vf -= std::min(dV, Vf - aSVf); + } if (Vl < aSVl) + { Vl += std::min(dV, aSVl - Vl); + } } SplitSurf->Init(surf, Uf, Ul, Vf, Vl, theArea); @@ -141,20 +157,26 @@ bool ShapeUpgrade_FaceDivide::SplitSurface(const double theArea) // If surface was neither split nor modified, do nothing if (!SplitSurf->Status(ShapeExtend_DONE)) + { return false; + } // if surface was modified, force copying all vertices (and edges as consequence) // to protect original shape from increasing tolerance after SameParameter if (SplitSurf->Status(ShapeExtend_DONE3)) + { for (TopExp_Explorer exp(face, TopAbs_VERTEX); exp.More(); exp.Next()) { if (Context()->IsRecorded(exp.Current())) + { continue; + } // smh#8 TopoDS_Shape emptyCopied = exp.Current().EmptyCopied(); TopoDS_Vertex V = TopoDS::Vertex(emptyCopied); Context()->Replace(exp.Current(), V); } + } occ::handle Grid = SplitSurf->ResSurfaces(); @@ -164,10 +186,14 @@ bool ShapeUpgrade_FaceDivide::SplitSurface(const double theArea) CompShell.SetMaxTolerance(MaxTolerance()); occ::handle SplitWire = GetWireDivideTool(); if (!SplitWire.IsNull()) + { CompShell.SetTransferParamTool(GetWireDivideTool()->GetTransferParamTool()); + } CompShell.Perform(); if (CompShell.Status(ShapeExtend_FAIL) || !CompShell.Status(ShapeExtend_DONE)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL2); + } myResult = CompShell.Result(); myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); @@ -181,7 +207,9 @@ bool ShapeUpgrade_FaceDivide::SplitCurves() { occ::handle SplitWire = GetWireDivideTool(); if (SplitWire.IsNull()) + { return false; + } SplitWire->SetMaxTolerance(MaxTolerance()); for (TopExp_Explorer explf(myResult, TopAbs_FACE); explf.More(); explf.Next()) @@ -202,13 +230,17 @@ bool ShapeUpgrade_FaceDivide::SplitCurves() // TopoDS_Wire wire = TopoDS::Wire ( wi.Value() ); // modifications already defined in context are to be applied inside SplitWire if (wi.Value().ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wire = TopoDS::Wire(wi.Value()); SplitWire->Load(wire); SplitWire->SetContext(Context()); SplitWire->Perform(); if (SplitWire->Status(ShapeExtend_FAIL)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1); + } if (SplitWire->Status(ShapeExtend_DONE)) { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivideArea.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivideArea.cxx index 7bfaeb2c8f..5b2f46d50a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivideArea.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FaceDivideArea.cxx @@ -70,15 +70,21 @@ bool ShapeUpgrade_FaceDivideArea::Perform(const double) } if ((anArea - myMaxArea) < Precision::Confusion()) + { return false; + } if (anbParts == 0) + { anbParts = RealToInt(ceil(anArea / myMaxArea)); + } occ::handle aSurfTool = occ::down_cast(GetSplitSurfaceTool()); if (aSurfTool.IsNull()) + { return false; + } aSurfTool->NbParts() = anbParts; if (myIsSplittingByNumber) { @@ -86,11 +92,15 @@ bool ShapeUpgrade_FaceDivideArea::Perform(const double) aSurfTool->SetNumbersUVSplits(myUnbSplit, myVnbSplit); } if (!ShapeUpgrade_FaceDivide::Perform(anArea)) + { return false; + } TopoDS_Shape aResult = Result(); if (aResult.ShapeType() == TopAbs_FACE) + { return false; + } int aStatus = myStatus; if (!myIsSplittingByNumber) @@ -111,15 +121,21 @@ bool ShapeUpgrade_FaceDivideArea::Perform(const double) TopoDS_Shape aRes = Result(); TopExp_Explorer aExpR(aRes, TopAbs_FACE); for (; aExpR.More(); aExpR.Next()) + { aB.Add(aCopyRes, aExpR.Current()); + } } else + { aB.Add(aCopyRes, aFace); + } } if (isModified) { if (aCopyRes.ShapeType() == TopAbs_WIRE || aCopyRes.ShapeType() == TopAbs_SHELL) + { aCopyRes.Closed(BRep_Tool::IsClosed(aCopyRes)); + } Context()->Replace(aResult, aCopyRes); } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FixSmallBezierCurves.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FixSmallBezierCurves.cxx index 6156852500..7a5439d1de 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FixSmallBezierCurves.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_FixSmallBezierCurves.cxx @@ -58,13 +58,19 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 if (sae.Curve3d(myEdge, c3d, f, l, false)) { if (First < f) + { First = f; + } if (Last > l) + { Last = l; + } occ::handle trc = new Geom_TrimmedCurve(c3d, First, Last); GeomAbs_Shape aCont = (GeomAbs_Shape)trc->Continuity(); if (aCont == GeomAbs_C3 || aCont == GeomAbs_CN) + { aCont = GeomAbs_C2; + } try { OCC_CATCH_SIGNALS @@ -79,7 +85,9 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 occ::handle>> theSegments3d; theSegments3d = mySplitCurve3dTool->GetCurves(); if (theSegments3d->Length() > 1) + { return false; + } Curve3d = theSegments3d->Value(1); } } @@ -97,7 +105,9 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 } } if (myFace.IsNull()) + { return true; + } occ::handle c2d; TopLoc_Location L; occ::handle aSurf = BRep_Tool::Surface(myFace, L); @@ -106,9 +116,13 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 if (sae.PCurve(myEdge, myFace, c2d, f, l, false)) { if (First < f) + { First = f; + } if (Last > l) + { Last = l; + } occ::handle trc2d = new Geom2d_TrimmedCurve(c2d, First, Last); GeomAbs_Shape aCont = (GeomAbs_Shape)trc2d->Continuity(); try @@ -121,11 +135,15 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 mySplitCurve2dTool->Init(AproxCurve2d.Curve(), First, Last); mySplitCurve2dTool->Perform(true); if (mySplitCurve2dTool->Status(ShapeExtend_FAIL)) + { return false; + } occ::handle>> theSegments2d; theSegments2d = mySplitCurve2dTool->GetCurves(); if (theSegments2d->Length() > 1) + { return false; // ShapeAnalysis_Surface + } Curve2d = theSegments2d->Value(1); } } @@ -152,9 +170,13 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 if (sae.PCurve(erev, myFace, c2, f2, l2, false)) { if (First > f) + { First = f; + } if (Last > l) + { Last = l; + } occ::handle trc2d = new Geom2d_TrimmedCurve(c2, First, Last); GeomAbs_Shape aCont = trc2d->Continuity(); Geom2dConvert_ApproxCurve AproxCurve2d(trc2d, prec, aCont, 1, 9); @@ -167,11 +189,15 @@ bool ShapeUpgrade_FixSmallBezierCurves::Approx(occ::handle& Curve3 mySplitCurve2dTool->Init(AproxCurve2d.Curve(), First, Last); mySplitCurve2dTool->Perform(true); if (!mySplitCurve2dTool->Status(ShapeExtend_DONE)) + { return false; + } occ::handle>> theSegments2d; theSegments2d = mySplitCurve2dTool->GetCurves(); if (theSegments2d->Length() > 1) + { return false; // ShapeAnalysis_Surface + } Curve2dR = theSegments2d->Value(1); } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveInternalWires.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveInternalWires.cxx index 3e844f25b1..a32b4b2b1b 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveInternalWires.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveInternalWires.cxx @@ -82,7 +82,9 @@ bool ShapeUpgrade_RemoveInternalWires::Perform() removeSmallWire(aF, TopoDS_Wire()); } if (myRemoveFacesMode) + { removeSmallFaces(); + } myResult = Context()->Apply(myShape); return Status(ShapeExtend_DONE); @@ -106,22 +108,30 @@ bool ShapeUpgrade_RemoveInternalWires::Perform( { const TopoDS_Shape& aS = theSeqShapes.Value(i); if (aS.ShapeType() == TopAbs_FACE) + { removeSmallWire(aS, TopoDS_Wire()); + } else if (aS.ShapeType() == TopAbs_WIRE) { if (!aWireFaces.Extent()) + { TopExp::MapShapesAndAncestors(myShape, TopAbs_WIRE, TopAbs_FACE, aWireFaces); + } if (aWireFaces.Contains(aS)) { const NCollection_List& alfaces = aWireFaces.FindFromKey(aS); NCollection_List::Iterator liter(alfaces); for (; liter.More(); liter.Next()) + { removeSmallWire(liter.Value(), aS); + } } } } if (myRemoveFacesMode) + { removeSmallFaces(); + } myResult = Context()->Apply(myShape); return Status(ShapeExtend_DONE); } @@ -137,11 +147,15 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallWire(const TopoDS_Shape& theFa for (; aIt.More(); aIt.Next()) { if (aIt.Value().ShapeType() != TopAbs_WIRE || aIt.Value().IsSame(anOutW)) + { continue; + } // occ::handle asewd = new ShapeExtend_WireData(); TopoDS_Wire aW = TopoDS::Wire(aIt.Value()); if (!theWire.IsNull() && !theWire.IsSame(aW)) + { continue; + } double anArea = ShapeAnalysis::ContourArea(aW); if (anArea < myMinArea - Precision::Confusion()) { @@ -149,14 +163,18 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallWire(const TopoDS_Shape& theFa myRemoveWires.Append(aW); myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); if (!myRemoveFacesMode) + { continue; + } TopoDS_Iterator aIte(aW, false); for (; aIte.More(); aIte.Next()) { const TopoDS_Shape& aE = aIte.Value(); if (myRemoveEdges.IsBound(aE)) + { myRemoveEdges.ChangeFind(aE).Append(aF); + } else { NCollection_List alfaces; @@ -197,7 +215,9 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallFaces() { TopoDS_Shape aF = Context()->Apply(aliter.Value()); if (aF.IsNull()) + { continue; + } bool isFind = false; for (; aliter2.More() && !isFind; aliter2.Next()) { @@ -211,9 +231,13 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallFaces() bool isOuter = false; TopoDS_Iterator aIter(aWout, false); for (; aIter.More() && !isOuter; aIter.Next()) + { isOuter = aEdge.IsSame(aIter.Value()); + } if (isOuter) + { aFaceCandidates.Add(aF); + } } } } @@ -234,7 +258,9 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallFaces() for (; n <= nbE; n++) { if (asewd->IsSeam(n)) + { continue; + } TopoDS_Edge aE = asewd->Edge(n); if (!myRemoveEdges.IsBound(aE)) { @@ -244,9 +270,13 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallFaces() { TopoDS_Shape aF2 = Context()->Apply(aliter3.Value()); if (aF2.IsNull()) + { continue; + } if (!aF.IsSame(aF2) && !aFaceCandidates.Contains(aF2)) + { nbNotRemoved++; + } } } } @@ -260,7 +290,9 @@ void ShapeUpgrade_RemoveInternalWires::removeSmallFaces() } if (myRemovedFaces.Length()) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveLocations.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveLocations.cxx index 1e0929d65f..85a68fe477 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveLocations.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_RemoveLocations.cxx @@ -106,7 +106,9 @@ static bool RebuildShape(const TopoDS_Edge& theEdge, } theNewEdge.Orientation(theEdge.Orientation()); if (BRep_Tool::Degenerated(theEdge)) + { aB.Degenerated(theNewEdge, true); + } isRebuild = true; } if (!theFace.IsNull()) @@ -127,19 +129,29 @@ static bool RebuildShape(const TopoDS_Edge& theEdge, TopAbs_Orientation OrEdge = theNewEdge.Orientation(); if (theFace.Orientation() == TopAbs_REVERSED) + { OrEdge = (OrEdge == TopAbs_FORWARD ? TopAbs_REVERSED : TopAbs_FORWARD); + } if (OrEdge == TopAbs_FORWARD) + { aB.UpdateEdge(theNewEdge, c2d, c2d1, theNewFace, 0); + } else + { aB.UpdateEdge(theNewEdge, c2d1, c2d, theNewFace, 0); + } } } else + { aB.UpdateEdge(theNewEdge, c2d, theNewFace, 0); + } if (!c2d.IsNull() || !c2d1.IsNull()) + { aB.Range(theNewEdge, theNewFace, First2d, Last2d); + } } } return isRebuild; @@ -201,7 +213,9 @@ bool ShapeUpgrade_RemoveLocations::MakeNewShape(const TopoDS_Shape& theShape, bool aRebuild = false; TopoDS_Shape anAncShape = theAncShape; if (shtype == TopAbs_FACE) + { anAncShape = aShape; + } if (isRemoveLoc && (!aShape.Location().IsIdentity() || shtype == TopAbs_EDGE || shtype == TopAbs_FACE)) { @@ -229,10 +243,14 @@ bool ShapeUpgrade_RemoveLocations::MakeNewShape(const TopoDS_Shape& theShape, F = TopoDS::Face(anAncShape); newFace = F; if (myMapNewShapes.IsBound(F)) + { newFace = TopoDS::Face(myMapNewShapes.Find(F)); + } } if (isBound) + { anewEdge = TopoDS::Edge(aNewShape); + } aRebuild = RebuildShape(oldEdge, anewEdge, F, newFace, isBound); aNewShape = anewEdge; } @@ -242,7 +260,9 @@ bool ShapeUpgrade_RemoveLocations::MakeNewShape(const TopoDS_Shape& theShape, TopoDS_Vertex aV = TopoDS::Vertex(aShape); aRebuild = RebuildShape(aV, aVnew); if (aRebuild) + { aNewShape = aVnew; + } } } isDone = aRebuild; @@ -260,7 +280,9 @@ bool ShapeUpgrade_RemoveLocations::MakeNewShape(const TopoDS_Shape& theShape, TopLoc_Location oldLoc, nullloc; oldLoc = theShape.Location(); if (!oldLoc.IsIdentity()) + { aNewShape.Location(nullloc); + } TopAbs_Orientation orient = theShape.Orientation(); aNewShape.Orientation(TopAbs_FORWARD); TopoDS_Iterator aIt(aShape, false, isRemoveLoc); @@ -273,12 +295,18 @@ bool ShapeUpgrade_RemoveLocations::MakeNewShape(const TopoDS_Shape& theShape, aB.Add(aNewShape, anewsubshape); } if (isDone) + { aNewShape.Orientation(orient); + } else + { aNewShape = aShape; + } myMapNewShapes.Bind(aShape, aNewShape); if (!theRemoveLoc && !oldLoc.IsIdentity()) + { aNewShape.Location(oldLoc); + } } theNewShape = aNewShape; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeConvertToBezier.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeConvertToBezier.cxx index c12edfcad1..4e51755b7f 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeConvertToBezier.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeConvertToBezier.cxx @@ -112,7 +112,9 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) } } else + { res = ShapeUpgrade_ShapeDivide::Perform(newContext); + } // pdn Hereafter the fix on GeomLib:SameParameter. // In order to fix this bug all edges that are based on // bezier curves (2d or 3d) and have range not equal to [0,1] @@ -166,22 +168,32 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) gp_Pnt p1v = BRep_Tool::Pnt(V1); gp_Pnt p2v = BRep_Tool::Pnt(V2); if (p1.Distance(p1v) > Precision::Confusion()) + { bezier->SetPole(1, p1v); + } if (p2.Distance(p2v) > Precision::Confusion()) + { bezier->SetPole(bezier->NbPoles(), p2v); + } B.UpdateEdge(edge, bezier, 0.); } } else if (my2dMode) + { B.SameRange(edge, true); + } } occ::handle c2d, c2drev; occ::handle bezier, bezierR; bool isSeam = BRep_Tool::IsClosed(edge, face); if (!sae.PCurve(edge, face, c2d, first, last, false)) + { continue; + } if (!c2d->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) + { continue; + } occ::handle newRevCurve, newCurve; bezier = occ::down_cast(c2d); if (isSeam) @@ -207,7 +219,9 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) newCurve = bezier; } else + { GeomLib::SameRange(preci, c2d, first, last, 0, 1, newCurve); + } if (isSeam) { if (!bezierR.IsNull()) @@ -216,11 +230,17 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) newRevCurve = bezierR; } else if (!c2drev.IsNull()) + { GeomLib::SameRange(preci, c2drev, first, last, 0, 1, newRevCurve); + } if (edge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(edge, newCurve, newRevCurve, face, 0.); + } else + { B.UpdateEdge(edge, newRevCurve, newCurve, face, 0.); + } } } B.Range(edge, face, 0, 1); @@ -231,9 +251,13 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) double first2, last2; occ::handle beziernext, bezierRnext; if (!sae.PCurve(edgenext, face, c2dnext, first2, last2, false)) + { continue; + } if (!c2dnext->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) + { continue; + } beziernext = occ::down_cast(c2dnext); // occ::handle newRevCurve; if (isSeam) @@ -259,7 +283,9 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) newnextCurve = beziernext; } else + { GeomLib::SameRange(preci, c2dnext, first2, last2, 0, 1, newnextCurve); + } if (isSeam) { if (!bezierRnext.IsNull()) @@ -268,18 +294,25 @@ bool ShapeUpgrade_ShapeConvertToBezier::Perform(const bool newContext) newRevCurve = bezierRnext; } else if (!c2drevnext.IsNull()) + { GeomLib::SameRange(preci, c2drevnext, first2, last2, 0, 1, newRevCurve); + } if (edge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(edgenext, newnextCurve, newRevCurve, face, 0.); + } else + { B.UpdateEdge(edgenext, newRevCurve, newnextCurve, face, 0.); + } } } B.Range(edgenext, face, 0, 1); } // clang-format off - if(bezier.IsNull() || beziernext.IsNull() ) continue; //gka fix against small edges ; merging ends of pcurves + if(bezier.IsNull() || beziernext.IsNull() ) { continue; //gka fix against small edges ; merging ends of pcurves +} // clang-format on double f1, l1, f2, l2; f1 = bezier->FirstParameter(); @@ -361,7 +394,9 @@ occ::handle ShapeUpgrade_ShapeConvertToBezier::GetSplit wtool->SetSplitCurve3dTool(curve3dConverter); } if (my2dMode) + { wtool->SetSplitCurve2dTool(new ShapeUpgrade_ConvertCurve2dToBezier); + } wtool->SetEdgeMode(myEdgeMode); occ::handle FixSmallBezierCurvesTool = new ShapeUpgrade_FixSmallBezierCurves; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx index 7ae0cb430f..ca8e257d90 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx @@ -118,7 +118,9 @@ bool ShapeUpgrade_ShapeDivide::Perform(const bool newContext) } if (newContext || myContext.IsNull()) + { myContext = new ShapeBuild_ReShape; + } // Process COMPOUNDs separately in order to handle sharing in assemblies // NOTE: not optimized: subshape can be processed twice (second time - no modif) @@ -141,7 +143,9 @@ bool ShapeUpgrade_ShapeDivide::Perform(const bool newContext) myShape = myContext->Apply(shape); Perform(false); if (myContext->ModeConsiderLocation()) + { myResult.Location(L); + } myResult.Orientation(TopAbs::Compose(myResult.Orientation(), savShape.Orientation())); B.Add(C, myResult); locStatus |= myStatus; @@ -277,7 +281,9 @@ bool ShapeUpgrade_ShapeDivide::Perform(const bool newContext) TopoDS_Vertex V1, V2; TopExp::Vertices(E, V2, V1); if (V1.IsNull() && V2.IsNull()) + { continue; // skl 27.10.2004 for OCC5624 + } TopoDS_Shape sh = myContext->Apply(E, TopAbs_SHAPE); for (TopExp_Explorer exp2(sh, TopAbs_EDGE); exp2.More(); exp2.Next()) { @@ -375,7 +381,9 @@ void ShapeUpgrade_ShapeDivide::SendMsg(const TopoDS_Shape& shape, const Message_Gravity gravity) const { if (!myMsgReg.IsNull()) + { myMsgReg->Send(shape, message, gravity); + } } Message_Msg ShapeUpgrade_ShapeDivide::GetFaceMsg() const diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivideAngle.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivideAngle.cxx index 09dfdc7d86..a6bc8bb4d8 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivideAngle.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShapeDivideAngle.cxx @@ -59,7 +59,9 @@ double ShapeUpgrade_ShapeDivideAngle::MaxAngle() const { occ::handle faceTool = GetSplitFaceTool(); if (faceTool.IsNull()) + { return 0.; + } occ::handle tool = occ::down_cast(faceTool->GetSplitSurfaceTool()); return (tool.IsNull() ? 0. : tool->MaxAngle()); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShellSewing.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShellSewing.cxx index 4d164d266c..a54229f3e6 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShellSewing.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_ShellSewing.cxx @@ -36,9 +36,13 @@ ShapeUpgrade_ShellSewing::ShapeUpgrade_ShellSewing() void ShapeUpgrade_ShellSewing::Init(const TopoDS_Shape& shape) { if (shape.IsNull()) + { return; + } if (shape.ShapeType() == TopAbs_SHELL) + { myShells.Add(shape); + } else { for (TopExp_Explorer exs(shape, TopAbs_SHELL); exs.More(); exs.Next()) @@ -59,7 +63,9 @@ int ShapeUpgrade_ShellSewing::Prepare(const double tol) BRepBuilderAPI_Sewing ss(tol); TopExp_Explorer exp(sl, TopAbs_FACE); for (; exp.More(); exp.Next()) + { ss.Add(exp.Current()); + } ss.Perform(); TopoDS_Shape newsh = ss.SewedShape(); if (!newsh.IsNull()) @@ -76,7 +82,9 @@ int ShapeUpgrade_ShellSewing::Prepare(const double tol) TopoDS_Shape ShapeUpgrade_ShellSewing::Apply(const TopoDS_Shape& shape, const double tol) { if (shape.IsNull() || myShells.Extent() == 0) + { return shape; + } TopoDS_Shape res = myReShape->Apply(shape, TopAbs_FACE, 2); @@ -97,7 +105,9 @@ TopoDS_Shape ShapeUpgrade_ShellSewing::Apply(const TopoDS_Shape& shape, const do // szv#4:S4163:12Mar99 optimized if (ns != 0) + { res = myReShape->Apply(res, TopAbs_SHELL, 2); + } return res; } @@ -107,7 +117,9 @@ TopoDS_Shape ShapeUpgrade_ShellSewing::Apply(const TopoDS_Shape& shape, const do TopoDS_Shape ShapeUpgrade_ShellSewing::ApplySewing(const TopoDS_Shape& shape, const double tol) { if (shape.IsNull()) + { return shape; + } double t = tol; if (t <= 0.) @@ -118,7 +130,9 @@ TopoDS_Shape ShapeUpgrade_ShellSewing::ApplySewing(const TopoDS_Shape& shape, co Init(shape); if (Prepare(t)) + { return Apply(shape, t); + } return TopoDS_Shape(); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve.cxx index 28462b58e3..a6b66f3858 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve.cxx @@ -59,9 +59,13 @@ void ShapeUpgrade_SplitCurve::SetSplitValues( { constexpr double precision = Precision::PConfusion(); if (SplitValues.IsNull()) + { return; + } if (SplitValues->Length() == 0) + { return; + } double First = mySplitValues->Value(1), Last = mySplitValues->Value(mySplitValues->Length()); int i = 1; @@ -72,9 +76,13 @@ void ShapeUpgrade_SplitCurve::SetSplitValues( for (; i <= len; i++) { if ((First + precision) >= SplitValues->Value(i)) + { continue; + } if ((Last - precision) <= SplitValues->Value(i)) + { break; + } mySplitValues->InsertBefore(k++, SplitValues->Value(i)); } First = Last; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx index 3180f22586..b0163f08d9 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2d.cxx @@ -59,16 +59,22 @@ void ShapeUpgrade_SplitCurve2d::Init(const occ::handle& C, double lastPar = Last; occ::handle aCurve = myCurve; if (aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { aCurve = occ::down_cast(aCurve)->BasisCurve(); + } // 15.11.2002 PTV OCC966 if (!ShapeAnalysis_Curve::IsPeriodic(C)) { double fP = aCurve->FirstParameter(); double lP = aCurve->LastParameter(); if (std::abs(firstPar - fP) < precision) + { firstPar = fP; + } if (std::abs(lastPar - lP) < precision) + { lastPar = lP; + } if (firstPar < fP) { #ifdef OCCT_DEBUG @@ -84,7 +90,9 @@ void ShapeUpgrade_SplitCurve2d::Init(const occ::handle& C, lastPar = lP; } if ((lastPar - firstPar) < precision) + { lastPar = firstPar + 2 * precision; + } } ShapeUpgrade_SplitCurve::Init(firstPar, lastPar); @@ -104,7 +112,9 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) double Last = mySplitValues->Value(mySplitValues->Length()); // PrepareKnots(); if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (myCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { occ::handle tmp = occ::down_cast(myCurve); @@ -123,7 +133,9 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) myResultingCurves->SetValue(1, NewTrimCurve); } else + { myResultingCurves = spc.GetCurves(); + } myStatus |= spc.myStatus; return; } @@ -155,8 +167,9 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) bool filled = true; if (std::abs(myCurve->FirstParameter() - First) < Precision::PConfusion() && std::abs(myCurve->LastParameter() - Last) < Precision::PConfusion()) + { myResultingCurves->SetValue(1, myCurve); - + } else if (!Segment || (!myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) && !myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) @@ -170,9 +183,13 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) { OCC_CATCH_SIGNALS if (myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) + { occ::down_cast(theNewCurve)->Segment(First, Last); + } else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) + { occ::down_cast(theNewCurve)->Segment(First, Last); + } } catch (Standard_Failure const& anException) { @@ -195,9 +212,13 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) } } else + { filled = false; + } if (filled) + { return; + } } if (myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) @@ -211,13 +232,19 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) for (; j <= LastInd; j++) { if (spval > BsCurve->Knot(j) + Precision::PConfusion()) + { continue; + } if (spval < BsCurve->Knot(j) - Precision::PConfusion()) + { break; + } mySplitValues->SetValue(ii, BsCurve->Knot(j)); } if (j == LastInd) + { break; + } } } for (int i = 1; i <= myNbCurves; i++) @@ -236,9 +263,13 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) { OCC_CATCH_SIGNALS if (myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) + { occ::down_cast(theNewCurve)->Segment(Firstt, Lastt); + } else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) + { occ::down_cast(theNewCurve)->Segment(Firstt, Lastt); + } myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); } catch (Standard_Failure const& anException) @@ -254,8 +285,10 @@ void ShapeUpgrade_SplitCurve2d::Build(const bool Segment) } } else + { theNewCurve = new Geom2d_TrimmedCurve(occ::down_cast(myCurve->Copy()), Firstt, Lastt); + } } myResultingCurves->SetValue(i, theNewCurve); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2dContinuity.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2dContinuity.cxx index 4ad24d2428..68d23153c1 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2dContinuity.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve2dContinuity.cxx @@ -77,9 +77,13 @@ void ShapeUpgrade_SplitCurve2dContinuity::SetTolerance(const double Tol) void ShapeUpgrade_SplitCurve2dContinuity::Compute() { if (myCurve->Continuity() < myCriterion) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } constexpr double precision = Precision::PConfusion(); double First = mySplitValues->Value(1); double Last = mySplitValues->Value(mySplitValues->Length()); @@ -162,9 +166,13 @@ void ShapeUpgrade_SplitCurve2dContinuity::Compute() { double valknot = MyBSpline->Knot(iknot); if (valknot <= First + precision) + { continue; + } if (valknot >= Last - precision) + { break; + } int Continuity = Deg - MyBSpline->Multiplicity(iknot); // double tt = MyBSpline->Knot(iknot); // tt not used (skl) if (Continuity < myCont) @@ -173,7 +181,9 @@ void ShapeUpgrade_SplitCurve2dContinuity::Compute() bool corrected = false; int newMultiplicity = Deg - myCont; if (newMultiplicity < 0) + { newMultiplicity = 0; + } { try { @@ -211,5 +221,7 @@ void ShapeUpgrade_SplitCurve2dContinuity::Compute() } if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx index 47c13212e1..4b02a4459b 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3d.cxx @@ -58,16 +58,22 @@ void ShapeUpgrade_SplitCurve3d::Init(const occ::handle& C, double lastPar = Last; occ::handle aCurve = myCurve; if (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) + { aCurve = occ::down_cast(aCurve)->BasisCurve(); + } // 15.11.2002 PTV OCC966 if (!ShapeAnalysis_Curve::IsPeriodic(C)) { double fP = aCurve->FirstParameter(); double lP = aCurve->LastParameter(); if (std::abs(firstPar - fP) < precision) + { firstPar = fP; + } if (std::abs(lastPar - lP) < precision) + { lastPar = lP; + } if (firstPar < fP) { #ifdef OCCT_DEBUG @@ -83,7 +89,9 @@ void ShapeUpgrade_SplitCurve3d::Init(const occ::handle& C, lastPar = lP; } if ((lastPar - firstPar) < precision) + { lastPar = firstPar + 2 * precision; + } } ShapeUpgrade_SplitCurve::Init(firstPar, lastPar); @@ -103,7 +111,9 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) double Last = mySplitValues->Value(mySplitValues->Length()); if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (myCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { occ::handle tmp = occ::down_cast(myCurve); @@ -121,7 +131,9 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) myResultingCurves->SetValue(1, NewTrimCurve); } else + { myResultingCurves = spc.GetCurves(); + } myStatus |= spc.myStatus; return; } @@ -156,9 +168,13 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) double firstPar = myCurve->FirstParameter(); double lastPar = myCurve->LastParameter(); if (std::abs(First - firstPar) < precision) + { First = firstPar; + } if (std::abs(Last - lastPar) < precision) + { Last = lastPar; + } if (First < firstPar) { #ifdef OCCT_DEBUG @@ -184,8 +200,9 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) bool filled = true; if (std::abs(myCurve->FirstParameter() - First) < Precision::PConfusion() && std::abs(myCurve->LastParameter() - Last) < Precision::PConfusion()) + { myResultingCurves->SetValue(1, myCurve); - + } else if (!Segment || (!myCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) && !myCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) @@ -218,9 +235,13 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) // } } else + { filled = false; + } if (filled) + { return; + } } if (myCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { @@ -233,13 +254,19 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) for (; j <= LastInd; j++) { if (spval > BsCurve->Knot(j) + Precision::PConfusion()) + { continue; + } if (spval < BsCurve->Knot(j) - Precision::PConfusion()) + { break; + } mySplitValues->SetValue(ii, BsCurve->Knot(j)); } if (j == LastInd) + { break; + } } } @@ -258,9 +285,13 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) { OCC_CATCH_SIGNALS if (myCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) + { occ::down_cast(theNewCurve)->Segment(Firstt, Lastt); + } else if (myCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) + { occ::down_cast(theNewCurve)->Segment(Firstt, Lastt); + } myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); } catch (Standard_Failure const& anException) @@ -276,8 +307,10 @@ void ShapeUpgrade_SplitCurve3d::Build(const bool Segment) } } else + { theNewCurve = new Geom_TrimmedCurve(occ::down_cast(myCurve->Copy()), Firstt, Lastt); + } } myResultingCurves->SetValue(i, theNewCurve); } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3dContinuity.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3dContinuity.cxx index baccdc5a39..ce3a102d8a 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3dContinuity.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitCurve3dContinuity.cxx @@ -81,9 +81,13 @@ void ShapeUpgrade_SplitCurve3dContinuity::Compute() double Last = mySplitValues->Value(mySplitValues->Length()); constexpr double precision = Precision::PConfusion(); if (myCurve->Continuity() < myCriterion) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (myCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { occ::handle tmp = occ::down_cast(myCurve); @@ -165,9 +169,13 @@ void ShapeUpgrade_SplitCurve3dContinuity::Compute() { double valknot = MyBSpline->Knot(iknot); if (valknot <= First + precision) + { continue; + } if (valknot > Last - precision) + { break; + } int Continuity = Deg - MyBSpline->Multiplicity(iknot); if (Continuity < myCont) { @@ -175,7 +183,9 @@ void ShapeUpgrade_SplitCurve3dContinuity::Compute() bool corrected = false; int newMultiplicity = Deg - myCont; if (newMultiplicity < 0) + { newMultiplicity = 0; + } { try { @@ -220,7 +230,9 @@ void ShapeUpgrade_SplitCurve3dContinuity::Compute() } if (mySplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx index 218d077aea..7dd4f11151 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx @@ -176,7 +176,9 @@ void ShapeUpgrade_SplitSurface::SetUSplitValues( const occ::handle>& UValues) { if (UValues.IsNull()) + { return; + } constexpr double precision = Precision::PConfusion(); double UFirst = myUSplitValues->Value(1), ULast = myUSplitValues->Value(myUSplitValues->Length()); int i = 1; @@ -188,9 +190,13 @@ void ShapeUpgrade_SplitSurface::SetUSplitValues( for (; i <= len; i++) { if ((UFirst + precision) >= UValues->Value(i)) + { continue; + } if ((ULast - precision) <= UValues->Value(i)) + { break; + } myUSplitValues->InsertBefore(ku++, UValues->Value(i)); } UFirst = ULast; @@ -203,7 +209,9 @@ void ShapeUpgrade_SplitSurface::SetVSplitValues( const occ::handle>& VValues) { if (VValues.IsNull()) + { return; + } constexpr double precision = Precision::PConfusion(); double VFirst = myVSplitValues->Value(1), VLast = myVSplitValues->Value(myVSplitValues->Length()); int i = 1; @@ -214,9 +222,13 @@ void ShapeUpgrade_SplitSurface::SetVSplitValues( for (; i <= len; i++) { if ((VFirst + precision) >= VValues->Value(i)) + { continue; + } if ((VLast - precision) <= VValues->Value(i)) + { break; + } myVSplitValues->InsertBefore(kv++, VValues->Value(i)); } VFirst = VLast; @@ -234,7 +246,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) double VLast = myVSplitValues->Value(myVSplitValues->Length()); if (myUSplitValues->Length() > 2 || myVSplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } double U1, U2, V1, V2; mySurface->Bounds(U1, U2, V1, V2); @@ -284,7 +298,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) new Geom_SurfaceOfRevolution(spc.GetCurves()->Value(nc), Surface->Axis()); NewSurfaceRev->Bounds(U1, U2, V1, V2); if (UFirst == U1 && ULast == U2) + { Surfaces->SetValue(1, nc, NewSurfaceRev); + } else { occ::handle NewSurf = @@ -301,11 +317,17 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) myResSurfaces->SetUFirstValue(myUSplitValues->Sequence().First()); myResSurfaces->SetVFirstValue(myVSplitValues->Sequence().First()); if (spc.Status(ShapeExtend_DONE1)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (spc.Status(ShapeExtend_DONE2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (spc.Status(ShapeExtend_DONE3)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } return; } @@ -355,7 +377,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) new Geom_SurfaceOfLinearExtrusion(spc.GetCurves()->Value(nc1), Surface->Direction()); NewSurfaceEx->Bounds(U1, U2, V1, V2); if (VFirst == V1 && VLast == V2) + { Surfaces->SetValue(nc1, 1, NewSurfaceEx); + } else { occ::handle NewSurf = @@ -372,11 +396,17 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) myResSurfaces->SetUFirstValue(myUSplitValues->Sequence().First()); myResSurfaces->SetVFirstValue(myVSplitValues->Sequence().First()); if (spc.Status(ShapeExtend_DONE1)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (spc.Status(ShapeExtend_DONE2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (spc.Status(ShapeExtend_DONE3)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } return; } @@ -448,7 +478,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) && std::abs(U2 - ULast) < Precision::PConfusion() && std::abs(V1 - VFirst) < Precision::PConfusion() && std::abs(V2 - VLast) < Precision::PConfusion()) + { Surfaces->SetValue(1, 1, mySurface); + } else if (!Segment || !mySurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) || !Status(ShapeExtend_DONE2)) { @@ -459,7 +491,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) Surfaces->SetValue(1, 1, Surf); } else + { filled = false; + } if (filled) { myResSurfaces->Init(Surfaces); @@ -480,13 +514,19 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) for (; j <= LastInd; j++) { if (spval > BsSurface->UKnot(j) + Precision::PConfusion()) + { continue; + } if (spval < BsSurface->UKnot(j) - Precision::PConfusion()) + { break; + } myUSplitValues->ChangeValue(ii) = BsSurface->UKnot(j); } if (j == LastInd) + { break; + } } FirstInd = BsSurface->FirstVKnotIndex(), LastInd = BsSurface->LastVKnotIndex(); j = FirstInd; @@ -496,13 +536,19 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) for (; j <= LastInd; j++) { if (spval > BsSurface->VKnot(j) + Precision::PConfusion()) + { continue; + } if (spval < BsSurface->VKnot(j) - Precision::PConfusion()) + { break; + } myVSplitValues->ChangeValue(ii1) = BsSurface->VKnot(j); } if (j == LastInd) + { break; + } } } U1 = myUSplitValues->Value(1); @@ -525,7 +571,9 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) { OCC_CATCH_SIGNALS if (isBSpline) + { occ::down_cast(theNew)->Segment(U1, U2, V1, V2); + } else if (isBezier) { // pdn K4L+ (work around) @@ -572,12 +620,16 @@ void ShapeUpgrade_SplitSurface::Build(const bool Segment) NCollection_Array1 UJoints(1, nbU); int i; // svv Jan 10 2000 : porting on DEC for (i = 1; i <= nbU; i++) + { UJoints(i) = myUSplitValues->Value(i); + } int nbV = myVSplitValues->Length(); NCollection_Array1 VJoints(1, nbV); for (i = 1; i <= nbV; i++) + { VJoints(i) = myVSplitValues->Value(i); + } myResSurfaces->Init(Surfaces, UJoints, VJoints); // if (ShapeUpgrade::Debug()) std::cout<<"SplitSurface::Build - end"<BasisSurface(); } else + { S = mySurface; + } if (S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) || S->IsKind(STANDARD_TYPE(Geom_ConicalSurface)) @@ -88,13 +90,19 @@ void ShapeUpgrade_SplitSurfaceAngle::Compute(const bool /*Segment*/) double uLength = ULast - UFirst; int nbSegments = int((uLength - Precision::Angular()) / maxAngle) + 1; if (nbSegments == 1) + { if (!isRect || !(uLength < maxAngle) || !((U2 - U1) < maxAngle)) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } + } double segAngle = uLength / nbSegments; double currAngle = segAngle + UFirst; occ::handle> splitValues = new NCollection_HSequence; for (int i = 1; i < nbSegments; i++, currAngle += segAngle) + { splitValues->Append(currAngle); + } SetUSplitValues(splitValues); } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceArea.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceArea.cxx index 956f6d3fdd..a4598f91a2 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceArea.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceArea.cxx @@ -34,7 +34,9 @@ ShapeUpgrade_SplitSurfaceArea::ShapeUpgrade_SplitSurfaceArea() void ShapeUpgrade_SplitSurfaceArea::Compute(const bool /*Segment*/) { if (myNbParts <= 1) + { return; + } GeomAdaptor_Surface ads(mySurface, myUSplitValues->Value(1), @@ -44,9 +46,13 @@ void ShapeUpgrade_SplitSurfaceArea::Compute(const bool /*Segment*/) double aKoefU = ads.UResolution(1.); double aKoefV = ads.VResolution(1.); if (aKoefU == 0) + { aKoefU = 1.; + } if (aKoefV == 0) + { aKoefV = 1.; + } double aUSize = fabs(myUSplitValues->Value(2) - myUSplitValues->Value(1)) / aKoefU; double aVSize = fabs(myVSplitValues->Value(2) - myVSplitValues->Value(1)) / aKoefV; double aNbUV = aUSize / aVSize; @@ -56,7 +62,9 @@ void ShapeUpgrade_SplitSurfaceArea::Compute(const bool /*Segment*/) (aNbUV < 1. ? myUSplitValues : myVSplitValues); bool anIsUFirst = (aNbUV > 1.); if (aNbUV < 1) + { aNbUV = 1. / aNbUV; + } bool anIsFixedUVnbSplits = (myUnbSplit > 0 && myVnbSplit > 0); int nbSplitF, nbSplitS; @@ -68,9 +76,13 @@ void ShapeUpgrade_SplitSurfaceArea::Compute(const bool /*Segment*/) myUnbSplit = (int)(myUsize / aSquareSize); myVnbSplit = (int)(myVsize / aSquareSize); if (myUnbSplit == 0) + { myUnbSplit = 1; + } if (myVnbSplit == 0) + { myVnbSplit = 1; + } } if (anIsUFirst) @@ -90,9 +102,13 @@ void ShapeUpgrade_SplitSurfaceArea::Compute(const bool /*Segment*/) nbSplitS = (aNbUV >= myNbParts ? 0 : RealToInt(ceil((double)myNbParts / (double)nbSplitF))); } if (nbSplitS == 1 && !anIsFixedUVnbSplits) + { nbSplitS++; + } if (!nbSplitF) + { return; + } double aStep = (aFirstSplit->Value(2) - aFirstSplit->Value(1)) / nbSplitF; double aPrevPar = aFirstSplit->Value(1); int i = 1; diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceContinuity.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceContinuity.cxx index 1aa7bf90f4..460a6c5574 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceContinuity.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_SplitSurfaceContinuity.cxx @@ -78,13 +78,21 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) double UF, UL, VF, VL; mySurface->Bounds(UF, UL, VF, VL); if (!Precision::IsInfinite(UF)) + { myUSplitValues->SetValue(1, UF); + } if (!Precision::IsInfinite(UL)) + { myUSplitValues->SetValue(myUSplitValues->Length(), UL); + } if (!Precision::IsInfinite(VF)) + { myVSplitValues->SetValue(1, VF); + } if (!Precision::IsInfinite(VL)) + { myVSplitValues->SetValue(myVSplitValues->Length(), VL); + } } double UFirst = myUSplitValues->Value(1); @@ -94,9 +102,13 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) constexpr double precision = Precision::Confusion(); // if (ShapeUpgrade::Debug()) std::cout << "SplitSurfaceContinuity::Build" << std::endl; if (mySurface->Continuity() < myCriterion) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (myUSplitValues->Length() > 2 || myVSplitValues->Length() > 2) + { myStatus = ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (mySurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { @@ -117,11 +129,17 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) myVSplitValues->Clear(); myVSplitValues->ChangeSequence() = spc.SplitValues()->Sequence(); if (spc.Status(ShapeExtend_DONE1)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (spc.Status(ShapeExtend_DONE2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (spc.Status(ShapeExtend_DONE3)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); + } return; } if (mySurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) @@ -143,9 +161,13 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) myUSplitValues->Clear(); myUSplitValues->ChangeSequence() = spc.SplitValues()->Sequence(); if (spc.Status(ShapeExtend_DONE1)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } if (spc.Status(ShapeExtend_DONE2)) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE2); + } if (spc.Status(ShapeExtend_DONE3)) { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE3); @@ -231,7 +253,9 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) occ::handle MyBSpline; if (mySurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) + { MyBSpline = occ::down_cast(mySurface->Copy()); + } if (MyBSpline.IsNull()) { // if (ShapeUpgrade::Debug()) std::cout<<". Surface is not a Bspline"<UKnot(iknot); if (valknot <= UFirst + precision) + { continue; + } if (valknot >= ULast - precision) + { break; + } int Continuity = UDeg - MyBSpline->UMultiplicity(iknot); if (Continuity < myCont) { @@ -273,7 +301,9 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) int newMultiplicity = UDeg - myCont; bool corrected = false; if (newMultiplicity >= 0) + { corrected = MyBSpline->RemoveUKnot(iknot, newMultiplicity, myTolerance); + } if (corrected && newMultiplicity > 0) { Continuity = UDeg - MyBSpline->UMultiplicity(iknot); @@ -318,9 +348,13 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) { double valknot = MyBSpline->VKnot(iknot); if (valknot <= VFirst + precision) + { continue; + } if (valknot >= VLast - precision) + { break; + } int Continuity = VDeg - MyBSpline->VMultiplicity(iknot); if (Continuity < myCont) { @@ -328,7 +362,9 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) int newMultiplicity = VDeg - myCont; bool corrected = false; if (newMultiplicity >= 0) + { corrected = MyBSpline->RemoveVKnot(iknot, newMultiplicity, myTolerance); + } if (corrected && newMultiplicity > 0) { Continuity = VDeg - MyBSpline->VMultiplicity(iknot); @@ -366,5 +402,7 @@ void ShapeUpgrade_SplitSurfaceContinuity::Compute(const bool Segment) } if (myUSplitValues->Length() > 2 || myVSplitValues->Length() > 2) + { myStatus |= ShapeExtend::EncodeStatus(ShapeExtend_DONE1); + } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index a80e3e74a8..a7bcb81266 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -97,7 +97,9 @@ static bool IsOnSingularity(const NCollection_List& theEdgeList) { const TopoDS_Edge& anEdge = TopoDS::Edge(anItl.Value()); if (BRep_Tool::Degenerated(anEdge)) + { return true; + } } return false; @@ -145,7 +147,9 @@ static void SplitWire(const TopoDS_Wire& static double TrueValueOfOffset(const double theValue, const double thePeriod) { if (theValue > 0.) + { return thePeriod; + } return (-thePeriod); } @@ -185,14 +189,18 @@ static TopoDS_Face GetFaceFromSeq( const TopoDS_Edge& anEdge = TopoDS::Edge(anExplo.Current()); const NCollection_List& aFaceList = theMapEF.FindFromKey(anEdge); if (aFaceList.Extent() < 2) + { continue; + } const TopoDS_Face& aFace = (aFaceList.First().IsSame(aUsedFace)) ? TopoDS::Face(aFaceList.Last()) : TopoDS::Face(aFaceList.First()); if (theUsedFaces.Contains(aFace)) + { continue; + } if (BRep_Tool::IsClosed(anEdge, theRefFace)) { @@ -210,16 +218,20 @@ static TopoDS_Face GetFaceFromSeq( : TopoDS::Face(aFaceList.First()); } if (!aTargetFace.IsNull()) + { break; + } } theUsedFaces.Add(aTargetFace); for (int ii = 2; ii <= theFaces.Length(); ii++) + { if (theFaces(ii).IsSame(aTargetFace)) { theIndFace = ii; break; } + } return aTargetFace; } @@ -242,10 +254,14 @@ static void UpdateBoundaries(const occ::handle& thePCurve, gp_Pnt2d aPoint = thePCurve->Value(aParam); if (aPoint.Coord(theIndCoord) < theMinCoord) + { theMinCoord = aPoint.Coord(theIndCoord); + } if (aPoint.Coord(theIndCoord) > theMaxCoord) + { theMaxCoord = aPoint.Coord(theIndCoord); + } } } @@ -260,7 +276,9 @@ static bool TryMakeLine(const occ::handle& thePCurve, double aSqLen = aVec.SquareMagnitude(); double aSqParamLen = (theLast - theFirst) * (theLast - theFirst); if (std::abs(aSqLen - aSqParamLen) > Precision::Confusion()) + { return false; + } gp_Dir2d aDir = aVec; gp_Vec2d anOffset = -aDir; @@ -276,7 +294,9 @@ static bool TryMakeLine(const occ::handle& thePCurve, gp_Pnt2d aPnt = thePCurve->Value(aParam); double aDist = aLin.Distance(aPnt); if (aDist > Precision::Confusion()) + { return false; + } } theLine = new Geom2d_Line(aLin); @@ -398,7 +418,9 @@ static bool FindCoordBounds( { const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); if (!theEdgesMap.Contains(anEdge)) + { continue; + } double fpar, lpar; occ::handle aPCurve = BRep_Tool::CurveOnSurface(anEdge, theRefFace, fpar, lpar); if (aPCurve.IsNull()) @@ -409,7 +431,9 @@ static bool FindCoordBounds( } if (Precision::IsInfinite(aMinCoord) || Precision::IsInfinite(aMaxCoord)) + { continue; + } if (aMaxCoord > aSimpleMax) { @@ -454,9 +478,13 @@ static bool FindCoordBounds( { std::pair anInterval(aMinCoord, aMaxCoord); if (!aPairSeq.IsEmpty() && aMaxCoord < aPairSeq(1).first) + { aPairSeq.Prepend(anInterval); + } else + { aPairSeq.Append(anInterval); + } } } @@ -646,9 +674,13 @@ static void RelocatePCurvesToNewUorigin( anOffset = TrueValueOfOffset(anOffset, thePeriod); gp_Vec2d aVec; if (theIndCoord == 1) + { aVec.SetCoord(anOffset, 0.); + } else + { aVec.SetCoord(0., anOffset); + } occ::handle aNewPCurve = occ::down_cast(aPCurve->Copy()); aNewPCurve->Translate(aVec); aPCurve = aNewPCurve; @@ -733,7 +765,9 @@ static TopoDS_Face FindCommonFace( theOrOfE2OnFace = anEdge.Orientation(); } if (e1found && e2found) + { return aFace; + } } } @@ -758,7 +792,9 @@ static bool FindClosestPoints(const TopoDS_Edge& { theCommonFace = FindCommonFace(theEdge1, theEdge2, theVFmap, OrOfE1OnFace, OrOfE2OnFace); if (theCommonFace.IsNull()) + { return false; + } double fpar1, lpar1, fpar2, lpar2; occ::handle PCurve1 = @@ -773,6 +809,7 @@ static bool FindClosestPoints(const TopoDS_Edge& theIndOnE1 = -1; theIndOnE2 = -1; for (int ind1 = 0; ind1 < 2; ind1++) + { for (int ind2 = 0; ind2 < 2; ind2++) { double aSqDist = PointsOnEdge1[ind1].SquareDistance(PointsOnEdge2[ind2]); @@ -783,6 +820,7 @@ static bool FindClosestPoints(const TopoDS_Edge& theIndOnE2 = ind2; } } + } return true; } @@ -806,11 +844,15 @@ static void ReconstructMissedSeam(const NCollection_Sequence& theR { TopoDS_Edge anEdge = TopoDS::Edge(theRemovedEdges(i)); if (anEdge.IsSame(theCurEdge)) + { continue; + } double Param1, Param2; occ::handle aPC = BRep_Tool::CurveOnSurface(anEdge, theFrefFace, Param1, Param2); if (aPC.IsNull()) + { continue; + } TopoDS_Vertex aFirstVertex, aLastVertex; TopExp::Vertices(anEdge, aFirstVertex, aLastVertex, true); @@ -1019,11 +1061,15 @@ static void TransformPCurves( { occ::handle RefSurf = BRep_Tool::Surface(theRefFace); if (RefSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { RefSurf = (occ::down_cast(RefSurf))->BasisSurface(); + } occ::handle SurfFace = BRep_Tool::Surface(theFace); if (SurfFace->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { SurfFace = (occ::down_cast(SurfFace))->BasisSurface(); + } bool ToModify = false, ToTranslate = false, ToRotate = false, X_Reverse = false, Y_Reverse = false, ToProject = false; @@ -1045,7 +1091,9 @@ static void TransformPCurves( double aParam = ElCLib::LineParameter(AxisOfSurfFace.Axis(), OriginRefSurf); if (std::abs(aParam) > Precision::PConfusion()) + { aTranslation = -aParam; + } gp_Dir VdirSurfFace = AxisOfSurfFace.Direction(); gp_Dir VdirRefSurf = AxisOfRefSurf.Direction(); @@ -1055,21 +1103,29 @@ static void TransformPCurves( gp_Dir CrossProd1 = AxisOfRefSurf.XDirection() ^ AxisOfRefSurf.YDirection(); gp_Dir CrossProd2 = AxisOfSurfFace.XDirection() ^ AxisOfSurfFace.YDirection(); if (CrossProd1 * CrossProd2 < 0.) + { X_Reverse = true; + } double ScalProd = VdirSurfFace * VdirRefSurf; if (ScalProd < 0.) + { Y_Reverse = true; + } if (!X_Reverse && !Y_Reverse) { gp_Dir DirRef = VdirRefSurf; if (!AxisOfRefSurf.Direct()) + { DirRef.Reverse(); + } anAngle = XdirRefSurf.AngleWithRef(XdirSurfFace, DirRef); } else + { anAngle = XdirRefSurf.Angle(XdirSurfFace); + } ToRotate = (std::abs(anAngle) > Precision::PConfusion()); @@ -1092,13 +1148,19 @@ static void TransformPCurves( { TopoDS_Edge anEdge = TopoDS::Edge(Explo.Current()); if (BRep_Tool::Degenerated(anEdge) && ToModify) + { continue; + } if (ToProject && BRep_Tool::IsClosed(anEdge, theFace)) + { continue; + } if (!aEmap.Add(anEdge)) + { continue; + } TopAbs_Orientation anOr = anEdge.Orientation(); @@ -1110,8 +1172,10 @@ static void TransformPCurves( { anEdge.Reverse(); PCurve2 = BRep_Tool::CurveOnSurface(anEdge, theRefFace, fpar, lpar); - if (PCurve2 != PCurveOnRef) // two pcurves + if (PCurve2 != PCurveOnRef) + { // two pcurves continue; + } } occ::handle PCurves[2], NewPCurves[2]; @@ -1137,16 +1201,22 @@ static void TransformPCurves( NewPCurves[ii] = occ::down_cast(PCurves[ii]->Copy()); } if (ToTranslate) + { NewPCurves[ii]->Translate(gp_Vec2d(0., aTranslation)); + } if (Y_Reverse) + { NewPCurves[ii]->Mirror(gp::OX2d()); + } if (X_Reverse) { NewPCurves[ii]->Mirror(gp::OY2d()); NewPCurves[ii]->Translate(gp_Vec2d(2 * M_PI, 0.)); } if (ToRotate) + { NewPCurves[ii]->Translate(gp_Vec2d(anAngle, 0.)); + } } anEdge.Orientation(TopAbs_FORWARD); @@ -1173,9 +1243,13 @@ static void TransformPCurves( occ::handle NullPCurve; BB.UpdateEdge(anEdge, NullPCurve, theRefFace, 0.); if (anOr == TopAbs_FORWARD) + { BB.UpdateEdge(anEdge, NewPCurves[0], PCurveOnRef, theRefFace, 0.); + } else + { BB.UpdateEdge(anEdge, PCurveOnRef, NewPCurves[0], theRefFace, 0.); + } theMapEdgesWithTemporaryPCurves.Add(anEdge); } @@ -1202,14 +1276,18 @@ static void AddPCurves( GeomAbs_SurfaceType aType = RefBAsurf.GetType(); if (aType == GeomAbs_Plane) + { return; + } for (int i = 1; i <= theFaces.Length(); i++) { TopoDS_Face aFace = TopoDS::Face(theFaces(i)); aFace.Orientation(TopAbs_FORWARD); if (aFace.IsSame(theRefFace)) + { continue; + } TransformPCurves(theRefFace, aFace, theMapEdgesWithTemporaryPCurves); } @@ -1237,7 +1315,9 @@ static bool AddOrdinaryEdges(NCollection_Sequence& edges, theRemovedEdges.Append(edge); } else + { aNewEdges.Add(edge); + } } bool isDropped = false; @@ -1264,7 +1344,9 @@ static bool AddOrdinaryEdges(NCollection_Sequence& edges, // add edges to the sequence for (i = 1; i <= aNewEdges.Extent(); i++) + { edges.Append(aNewEdges(i)); + } return isDropped; } @@ -1387,12 +1469,16 @@ static bool GetNormalToSurface(const TopoDS_Face& theFace, } } if (anEdgeInFace.IsNull()) + { return false; + } aC2d = BRep_Tool::CurveOnSurface(anEdgeInFace, aFace, f, l); } else + { aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, f, l); + } if (aC2d.IsNull()) { @@ -1443,7 +1529,9 @@ static bool IsSameDomain(const TopoDS_Face& aFace S2 = BRep_Tool::Surface(aCheckedFace, L2); if (S1 == S2 && L1 == L2) + { return true; + } S1 = BRep_Tool::Surface(aFace); S2 = BRep_Tool::Surface(aCheckedFace); @@ -1473,11 +1561,17 @@ static bool IsSameDomain(const TopoDS_Face& aFace { occ::handle aPlaneOfFaces; if (theFacePlaneMap.IsBound(aFace)) + { aPlaneOfFaces = theFacePlaneMap(aFace); + } else if (theFacePlaneMap.IsBound(aCheckedFace)) + { aPlaneOfFaces = theFacePlaneMap(aCheckedFace); + } else + { aPlaneOfFaces = new Geom_Plane(aPln1); + } theFacePlaneMap.Bind(aFace, aPlaneOfFaces); theFacePlaneMap.Bind(aCheckedFace, aPlaneOfFaces); @@ -1503,7 +1597,9 @@ static bool IsSameDomain(const TopoDS_Face& aFace { IntPatch_ImpImpIntersection anIIInt(aGA1, aTT1, aGA2, aTT2, theLinTol, theLinTol); if (!anIIInt.IsDone() || anIIInt.IsEmpty()) + { return false; + } return anIIInt.TangentFaces(); } @@ -1558,7 +1654,9 @@ static void UpdateMapOfShapes( const TopoDS_Shape& aShape = it.Value(); TopoDS_Shape aContextShape = theContext->Apply(aShape); if (!aContextShape.IsSame(aShape)) + { theMapOfShapes.Add(aContextShape); + } } } @@ -1670,16 +1768,22 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aSurf = BRep_Tool::Surface(aFace, aLoc); @@ -1696,7 +1800,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aPCurve = BRep_Tool::CurveOnSurface(anEdge, TopoDS::Face(aFaceSeq(j)), aFirst, aLast); if (aPCurve.IsNull()) + { continue; + } if (aFaceSeq.Length() == 1) { @@ -1748,7 +1858,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aLine; if (aType == GeomAbs_BSplineCurve || aType == GeomAbs_BezierCurve) + { TryMakeLine(aPCurve, aFirst, aLast, aLine); + } if (!aLine.IsNull()) { aPCurve = aLine; @@ -1760,7 +1872,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aCopyPCurve = occ::down_cast(aPCurve->Copy()); if (aCopyPCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { aCopyPCurve = (occ::down_cast(aCopyPCurve))->BasisCurve(); + } aPCurveSeq.Append(aCopyPCurve); aFirstsSeq.Append(aFirst); @@ -1831,15 +1945,21 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aCopyPCurve = occ::down_cast(aPCurve->Copy()); if (aCopyPCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) + { aCopyPCurve = (occ::down_cast(aCopyPCurve))->BasisCurve(); + } aPCurveSeq.Append(aCopyPCurve); aFirstsSeq.Append(aFirst); @@ -1892,7 +2012,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aMaxTol) + { aMaxTol = aTol; + } } occ::handle>> @@ -1911,7 +2033,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_SequenceValue(concatc2d->Lower())); for (int i = concatc2d->Lower() + 1; i <= concatc2d->Upper(); i++) + { Concat2d.Add(concatc2d->Value(i), aMaxTol, true); + } concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve()); } @@ -1934,7 +2058,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aMaxTol) + { IsBadRange = true; + } } if (IsBadRange) @@ -1948,7 +2074,9 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence aNewPCurve; if (aToolProj.Perform(aCurve, aFirst3d, aLast3d, aNewPCurve)) + { ResPCurves(ii) = aNewPCurve; + } else { // Reparametrize pcurve @@ -2020,10 +2148,12 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_SequenceIsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { @@ -2132,10 +2266,14 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( occ::handle L1 = occ::down_cast(c3d1); occ::handle L2 = occ::down_cast(c3d2); if (!aDir1.IsParallel(aDir2, myAngTol)) + { IsUnionOfLinesPossible = false; + } } else + { IsUnionOfLinesPossible = false; + } if (c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle))) { occ::handle C1 = occ::down_cast(c3d1); @@ -2143,13 +2281,19 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( gp_Pnt P01 = C1->Location(); gp_Pnt P02 = C2->Location(); if (P01.Distance(P02) > Precision::Confusion()) + { IsUnionOfCirclesPossible = false; + } } else + { IsUnionOfCirclesPossible = false; + } } if (IsUnionOfLinesPossible && IsUnionOfCirclesPossible) + { return false; + } // union of lines is possible if (IsUnionOfLinesPossible) @@ -2171,7 +2315,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( V[k] = Vcopy; } else + { V[k] = TopoDS::Vertex(myContext->Apply(V[k])); + } } } occ::handle L = new Geom_Line(gp_Ax1(PV1, Vec)); @@ -2247,9 +2393,13 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( { GC_MakeCircle MC1(adef.Value(FP), adef.Value((FP + LP) * 0.5), adef.Value(LP)); if (MC1.IsDone()) + { Cir1 = MC1.Value(); + } else + { return false; + } B.MakeEdge(E, Cir1, Precision::Confusion()); B.Add(E, V[0]); B.Add(E, V[1]); @@ -2272,13 +2422,17 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( V[k] = Vcopy; } else + { V[k] = TopoDS::Vertex(myContext->Apply(V[k])); + } } } gp_Pnt PointFirst = BRep_Tool::Pnt(V[0]); while (std::abs(ParamLast - ParamFirst) > 7 * M_PI / 8) + { ParamLast = (ParamFirst + ParamLast) / 2; + } BRepAdaptor_Curve BAcurveFE(FE); gp_Pnt PointLast = BAcurveFE.Value(ParamLast); gp_Pnt Origin = Cir->Circ().Location(); @@ -2291,7 +2445,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( gp_Dir DirLastInChain = gp_Vec(Origin, PointLastInChain); double lpar = Dir1.AngleWithRef(DirLastInChain, Vdir); if (lpar < 0.) + { lpar += 2 * M_PI; + } occ::handle tc = new Geom_TrimmedCurve(aNewCircle, 0., lpar); B.MakeEdge(E, tc, Precision::Confusion()); @@ -2319,7 +2475,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( TopLoc_Location Loc; occ::handle c3d = BRep_Tool::Curve(edge, Loc, fp1, lp1); if (c3d.IsNull()) + { continue; + } if (c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { occ::handle tc = occ::down_cast(c3d); @@ -2327,7 +2485,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeSubSeq( } if ((c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)))) + { continue; + } NeedUnion = false; break; } @@ -2380,19 +2540,27 @@ static bool IsMergingPossible( IndOnE2, PointsOnEdge1, PointsOnEdge2)) + { return false; + } if (MinSqDist <= Precision::SquareConfusion()) + { return true; + } return false; } else if (IsDegE1 || IsDegE2) + { return false; + } TopoDS_Vertex CV = TopExp::LastVertex(edge1, true); if (CV.IsNull() || AvoidEdgeVrt.Contains(CV)) + { return false; + } BRepAdaptor_Curve ade1(edge1); BRepAdaptor_Curve ade2(edge2); @@ -2403,7 +2571,9 @@ static bool IsMergingPossible( if (t1 == GeomAbs_Circle && t2 == GeomAbs_Circle) { if (ade1.Circle().Location().Distance(ade2.Circle().Location()) > Precision::Confusion()) + { return false; + } } gp_Dir aDir1, aDir2; @@ -2411,12 +2581,16 @@ static bool IsMergingPossible( && ((t1 != GeomAbs_BezierCurve && t1 != GeomAbs_BSplineCurve) || (t2 != GeomAbs_BezierCurve && t2 != GeomAbs_BSplineCurve)) && t1 != t2) + { return false; + } gp_Vec Diff1, Diff2; gp_Pnt P1, P2; if (edge1.Orientation() == TopAbs_FORWARD) + { ade1.D1(ade1.LastParameter(), P1, Diff1); + } else { ade1.D1(ade1.FirstParameter(), P1, Diff1); @@ -2424,7 +2598,9 @@ static bool IsMergingPossible( } if (edge2.Orientation() == TopAbs_FORWARD) + { ade2.D1(ade2.FirstParameter(), P2, Diff2); + } else { ade2.D1(ade2.LastParameter(), P2, Diff2); @@ -2432,7 +2608,9 @@ static bool IsMergingPossible( } if (Diff1.Angle(Diff2) > theAngTol) + { return false; + } if (theLineDirectionOk && t2 == GeomAbs_Line) { @@ -2442,14 +2620,18 @@ static bool IsMergingPossible( gp_Vec aCurV(theFirstPoint, ade2.Value(aLast)); double aDD = theDirectionVec.CrossSquareMagnitude(aCurV); if (aDD > theLinTol * theLinTol) + { return false; + } // Check that the accumulated angle does not exceed the angular tolerance. // For symmetry, check the angle between vectors of: // - first edge and resulting curve, and // - the last edge and resulting curve. if (theDirectionVec.Angle(aCurV) > theAngTol || Diff2.Angle(aCurV) > theAngTol) + { return false; + } } return true; @@ -2464,14 +2646,20 @@ static bool GetLineEdgePoints(const TopoDS_Edge& theInpEdge, double f, l; occ::handle aCur = BRep_Tool::Curve(theInpEdge, f, l); if (aCur.IsNull()) + { return false; + } occ::handle aTC = occ::down_cast(aCur); if (!aTC.IsNull()) + { aCur = aTC->BasisCurve(); + } if (aCur->DynamicType() != STANDARD_TYPE(Geom_Line)) + { return false; + } if (theInpEdge.Orientation() == TopAbs_REVERSED) { @@ -2538,7 +2726,9 @@ void ShapeUpgrade_UnifySameDomain::generateSubSeq( isLineDirectionOk = GetLineEdgePoints(edge2, aFirstPoint, aDirectionVec); } else + { SeqOfSubSeqOfEdges.ChangeLast().SeqsEdges.Append(edge2); + } } /// check first and last chain segments if (IsClosed && SeqOfSubSeqOfEdges.Length() > 1) @@ -2586,7 +2776,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( if (aV.Orientation() == TopAbs_FORWARD || aV.Orientation() == TopAbs_REVERSED) { if (!aMapVE.Contains(aV)) + { aMapVE.Add(aV, NCollection_List()); + } aMapVE.ChangeFromKey(aV).Append(anEdge); } } @@ -2600,7 +2792,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( { TopoDS_Edge edge = TopoDS::Edge(SeqEdges(iE)); if (!aUsedEdges.Add(edge)) + { continue; + } // make chain for unite NCollection_Sequence aChain; @@ -2616,7 +2810,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( { isAdded = false; if (V[j].IsNull()) + { break; + } const NCollection_List& aLE = aMapVE.FindFromKey(V[j]); for (NCollection_List::Iterator itL(aLE); itL.More(); itL.Next()) { @@ -2629,9 +2825,13 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( if (V2[1 - j].IsEqual(V[j].Reversed())) { if (j == 0) + { aChain.Prepend(edge); + } else + { aChain.Append(edge); + } aUsedEdges.Add(edge); V[j] = V2[j]; isAdded = true; @@ -2643,11 +2843,15 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( } if (aChain.Length() < 2) + { continue; + } bool IsClosed = false; if (V[0].IsSame(V[1])) + { IsClosed = true; + } // split chain by vertices at which merging is not possible NCollection_Sequence aOneSeq; @@ -2661,9 +2865,13 @@ bool ShapeUpgrade_UnifySameDomain::MergeEdges( { TopoDS_Edge UE; if (SeqOfSubSeqOfEdges(i).SeqsEdges.Length() < 2) + { continue; + } if (MergeSubSeq(SeqOfSubSeqOfEdges(i).SeqsEdges, theVFmap, UE)) + { SeqOfSubSeqOfEdges(i).UnionEdges = UE; + } } return true; } @@ -2686,7 +2894,9 @@ bool ShapeUpgrade_UnifySameDomain::MergeSeq( for (int i = 1; i <= SeqOfSubsSeqOfEdges.Length(); i++) { if (SeqOfSubsSeqOfEdges(i).UnionEdges.IsNull()) + { continue; + } myContext->Merge(SeqOfSubsSeqOfEdges(i).SeqsEdges, SeqOfSubsSeqOfEdges(i).UnionEdges); } @@ -2716,9 +2926,13 @@ static void CheckSharedVertices( TopoDS_Vertex aV1 = sae.FirstVertex(TopoDS::Edge(theSeqEdges(k))); TopoDS_Vertex aV2 = sae.LastVertex(TopoDS::Edge(theSeqEdges(k))); if (!MapVertexes.Add(aV1)) + { SeqVertexes.Append(aV1); + } if (!MapVertexes.Add(aV2)) + { SeqVertexes.Append(aV2); + } } for (int k = 1; k <= SeqVertexes.Length() /* && !IsSharedVertexPresent*/; k++) @@ -2726,7 +2940,9 @@ static void CheckSharedVertices( const NCollection_List& ListEdgesV1 = theMapEdgesVertex.FindFromKey(SeqVertexes(k)); if (ListEdgesV1.Extent() > 2 || theMapKeepShape.Contains(SeqVertexes(k))) + { theShareVertMap.Add(SeqVertexes(k)); + } } // return theShareVertMap.IsEmpty() ? false : true; } @@ -2806,7 +3022,9 @@ void ShapeUpgrade_UnifySameDomain::SetSafeInputMode(bool theValue) void ShapeUpgrade_UnifySameDomain::KeepShape(const TopoDS_Shape& theShape) { if (theShape.ShapeType() == TopAbs_EDGE || theShape.ShapeType() == TopAbs_VERTEX) + { myKeepShapes.Add(theShape); + } } //================================================================================================= @@ -2818,7 +3036,9 @@ void ShapeUpgrade_UnifySameDomain::KeepShapes( it.Next()) { if (it.Value().ShapeType() == TopAbs_EDGE || it.Value().ShapeType() == TopAbs_VERTEX) + { myKeepShapes.Add(it.Value()); + } } } @@ -2833,7 +3053,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() NCollection_IndexedMap aFaceMap; TopExp::MapShapes(myShape, TopAbs_FACE, aFaceMap); for (int i = 1; i <= aFaceMap.Extent(); i++) + { TopExp::MapShapesAndAncestors(aFaceMap(i), TopAbs_EDGE, TopAbs_FACE, aGMapEdgeFaces); + } // creating map of face shells for the whole shape to avoid // unification of faces belonging to the different shells @@ -2874,14 +3096,18 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() const TopoDS_Edge& anEdge = TopoDS::Edge(aEFmap.FindKey(ii)); const NCollection_List& aFaceList = aEFmap(ii); if (!BRep_Tool::Degenerated(anEdge) && aFaceList.Extent() == 1) + { aFreeBoundMap.Add(anEdge); + } } } // unify faces in each shell separately TopExp_Explorer exps; for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next()) + { IntUnifyFaces(exps.Current(), aGMapEdgeFaces, aGMapFaceShells, aFreeBoundMap); + } // gather all faces out of shells in one compound and unify them at once BRep_Builder aBB; @@ -2889,7 +3115,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() aBB.MakeCompound(aCmp); int nbf = 0; for (exps.Init(myShape, TopAbs_FACE, TopAbs_SHELL); exps.More(); exps.Next(), nbf++) + { aBB.Add(aCmp, exps.Current()); + } if (nbf > 0) { @@ -3026,7 +3254,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { TopoDS_Edge edge = TopoDS::Edge(edges(i)); if (BRep_Tool::Degenerated(edge)) + { continue; + } // get connectivity of the edge in the global shape const NCollection_List& aGList = theGMapEdgeFaces.FindFromKey(edge); @@ -3048,7 +3278,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( // for a planar face create and store pcurve of edge on face // to speed up all operations if (!mySafeInputMode && aBaseSurface->IsKind(STANDARD_TYPE(Geom_Plane))) + { BRepLib::BuildPCurveForEdgeOnPlane(edge, aFace); + } // get normal of the face to compare it with normals of other faces gp_Dir aDN1; @@ -3067,10 +3299,14 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopoDS_Face aCheckedFace = TopoDS::Face(anIter.Value()); if (aCheckedFace.IsSame(aFace)) + { continue; + } if (aProcessed.Contains(aCheckedFace)) + { continue; + } // Get shells connected to the checked face const NCollection_Map* pFShells2 = @@ -3184,7 +3420,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( for (it.Init(aLF); it.More() && !hasConnectAnotherFaces; it.Next()) { if (!anAvoidFaces.Contains(it.Value())) + { hasConnectAnotherFaces = true; + } } } } @@ -3210,7 +3448,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( const TopoDS_Shape& aE = it.Value(); const NCollection_List& aLF = aMapEF.FindFromKey(aE); if (aLF.Extent() < 2) + { continue; + } if (aMapFaces.Contains(aLF.First()) && aMapFaces.Contains(aLF.Last())) { for (i = 1; i <= faces.Length(); i++) @@ -3244,7 +3484,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopTools_ShapeMapHasher> aMapEF; for (i = 1; i <= faces.Length(); i++) + { TopExp::MapShapesAndUniqueAncestors(faces(i), TopAbs_EDGE, TopAbs_FACE, aMapEF); + } // Correct orientation of edges for (int ii = 1; ii <= edges.Length(); ii++) @@ -3253,10 +3495,14 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( int indE = aMapEF.FindIndex(anEdge); const NCollection_List& aLF = aMapEF(indE); if (myAllowInternal && myKeepShapes.Contains(anEdge) && aLF.Extent() == 2) + { edges(ii).Orientation(TopAbs_INTERNAL); + } if (anEdge.Orientation() != TopAbs_INTERNAL) + { edges(ii) = aMapEF.FindKey(indE); + } } // Exclude internal edges @@ -3271,12 +3517,18 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( edges.Remove(ind_e); } else + { ind_e++; + } } if (RefFaceOrientation == TopAbs_REVERSED) + { for (int ii = 1; ii <= edges.Length(); ii++) + { edges(ii).Reverse(); + } + } TopoDS_Face F_RefFace = RefFace; F_RefFace.Orientation(TopAbs_FORWARD); @@ -3294,7 +3546,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopTools_ShapeMapHasher> VEmap; for (int ind = 1; ind <= edges.Length(); ind++) + { TopExp::MapShapesAndUniqueAncestors(edges(ind), TopAbs_VERTEX, TopAbs_EDGE, VEmap); + } // Try to find seam edge and an edge that is not seam but has 2 pcurves on the surface bool SeamFound = false, UseamFound = false, VseamFound = false; @@ -3312,12 +3566,18 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( if (BRepTools::IsReallyClosed(anEdge, face_ii)) { if (IsUiso(anEdge, face_ii)) + { UseamFound = true; + } else + { VseamFound = true; + } } else + { EdgeWith2pcurves = anEdge; + } } } } @@ -3347,9 +3607,13 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( bool anIsUclosed = (std::abs(aPnt1.X() - aPnt2.X()) > std::abs(aPnt1.Y() - aPnt2.Y())); bool aToMakeUPeriodic = false, aToMakeVPeriodic = false; if (anIsUclosed && Uperiod == 0.) + { aToMakeUPeriodic = true; + } if (!anIsUclosed && Vperiod == 0.) + { aToMakeVPeriodic = true; + } if (aToMakeUPeriodic || aToMakeVPeriodic) { @@ -3391,7 +3655,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( occ::handle aPCurve = BRep_Tool::CurveOnSurface(anEdge, OldRefFace, aFirst, aLast); if (MapEdgesWithTemporaryPCurves.Contains(anEdge)) + { BB.UpdateEdge(anEdge, NullPCurve, OldRefFace, 0.); + } BB.UpdateEdge(anEdge, aPCurve, RefFace, 0.); } F_RefFace = RefFace; @@ -3408,6 +3674,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( aBaseSurface->Bounds(aSurfMin[0], aSurfMax[0], aSurfMin[1], aSurfMax[1]); for (int ii = 0; ii < 2; ii++) + { if (aPeriods[ii] != 0.) { // if seam edge exists, do nothing @@ -3432,7 +3699,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( } if (aMaxCoord - aMinCoord > aPeriods[ii] - 1.e-5) + { anIsSeamFound[ii] = true; + } else if (aNumberOfIntervals == 2) { NCollection_Map UsedEdges; @@ -3466,7 +3735,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( // Restore VEmap VEmap.Clear(); for (int ind = 1; ind <= edges.Length(); ind++) + { TopExp::MapShapesAndUniqueAncestors(edges(ind), TopAbs_VERTEX, TopAbs_EDGE, VEmap); + } // Find NewUmin and NewUmax double NewCoordMin = RealLast(), NewCoordMax = RealFirst(); @@ -3493,16 +3764,22 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( double RestSpaceInCoord = aPeriods[ii] - (NewCoordMax - NewCoordMin); double NewCoordOrigin = NewCoordMin - RestSpaceInCoord / 2; if (NewCoordOrigin < aSurfMin[ii]) + { NewCoordOrigin = aSurfMin[ii]; + } occ::handle NewSurf; bool anIsInU = (ii == 0); if (NewCoordOrigin == aSurfMin[ii]) + { NewSurf = aBaseSurface; + } else + { NewSurf = new Geom_RectangularTrimmedSurface(aBaseSurface, NewCoordOrigin, NewCoordOrigin + aPeriods[ii], anIsInU); // trim in U or V + } TopoDS_Face OldRefFace = RefFace; occ::handle NullPCurve; RefFace.Nullify(); @@ -3511,7 +3788,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { TopoDS_Edge anEdge = TopoDS::Edge(edges(jj)); if (MapEdgesWithTemporaryPCurves.Contains(anEdge)) + { BB.UpdateEdge(anEdge, NullPCurve, OldRefFace, 0.); + } const occ::handle& aPCurve = EdgeNewPCurve(anEdge); BB.UpdateEdge(anEdge, aPCurve, RefFace, 0.); } @@ -3519,6 +3798,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( } // else (Umax - Umin < Uperiod - 1.e-5, no Useam) } // if (!UseamFound) } // if (Uperiod != 0.) + } UseamFound = anIsSeamFound[0]; VseamFound = anIsSeamFound[1]; //////////////////////////////////// @@ -3533,13 +3813,19 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopLoc_Location aLoc; occ::handle aSurf = BRep_Tool::Surface(RefFace, aLoc); if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurf = (occ::down_cast(aSurf))->BasisSurface(); + } double Ufirst, Ulast, Vfirst, Vlast; aSurf->Bounds(Ufirst, Ulast, Vfirst, Vlast); if (Uperiod == 0 && aSurf->IsUClosed()) + { Uperiod = Ulast - Ufirst; + } if (Vperiod == 0 && aSurf->IsVClosed()) + { Vperiod = Vlast - Vfirst; + } } NCollection_Map UsedEdges; @@ -3559,14 +3845,22 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( gp_Pnt2d aLastPoint = aBAcurve.Value(aBAcurve.LastParameter()); if (aFirstPoint.X() < FaceUmin) + { FaceUmin = aFirstPoint.X(); + } if (aLastPoint.X() < FaceUmin) + { FaceUmin = aLastPoint.X(); + } if (aFirstPoint.Y() < FaceVmin) + { FaceVmin = aFirstPoint.Y(); + } if (aLastPoint.Y() < FaceVmin) + { FaceVmin = aLastPoint.Y(); + } } // Building new wires from @@ -3621,7 +3915,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( NCollection_List Elist; // const NCollection_List& Elist = VEmap.FindFromKey(CurVertex); if (VEmap.Contains(CurVertex)) + { Elist = VEmap.FindFromKey(CurVertex); + } NCollection_List::Iterator itl(Elist); if (Elist.IsEmpty()) { @@ -3657,7 +3953,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( bool anIsOnSingularity = IsOnSingularity(Elist); if (!anIsOnSingularity && Elist.Extent() > 1) + { SplittingVertices.Add(CurVertex); + } NCollection_List TmpElist, TrueElist; // will be the list of candidates to become @@ -3665,14 +3963,20 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value()); if (UsedEdges.Contains(anEdge)) + { continue; + } TopoDS_Vertex aFirstVertex = TopExp::FirstVertex(anEdge, true); if (!aFirstVertex.IsSame(CurVertex)) + { continue; + } TmpElist.Append(anEdge); } if (TmpElist.Extent() <= 1 || (Uperiod != 0. || Vperiod != 0)) + { TrueElist.Assign(TmpElist); + } else { // we must choose the closest direction - the biggest angle @@ -3685,7 +3989,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( CurPCurve->D1(CurParam, CurPoint, CurDir); CurDir.Normalize(); if (CurEdge.Orientation() == TopAbs_REVERSED) + { CurDir.Reverse(); + } for (itl.Initialize(TmpElist); itl.More(); itl.Next()) { const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value()); @@ -3697,7 +4003,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( aPCurve->D1(aParam, aPoint, aDir); aDir.Normalize(); if (anEdge.Orientation() == TopAbs_REVERSED) + { aDir.Reverse(); + } double anAngle = CurDir.Angle(aDir); if (anAngle > MaxAngle) { @@ -3719,12 +4027,14 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( gp_Pnt2d aPoint = aPCurve->Value(aParam); double DiffU = std::abs(aPoint.X() - CurPoint.X()); double DiffV = std::abs(aPoint.Y() - CurPoint.Y()); - if (Uperiod != 0. && DiffU > CoordTol - && std::abs(DiffU - Uperiod) > CoordTol) // may be it is a deg.vertex + if (Uperiod != 0. && DiffU > CoordTol && std::abs(DiffU - Uperiod) > CoordTol) + { // may be it is a deg.vertex continue; - if (Vperiod != 0. && DiffV > CoordTol - && std::abs(DiffV - Vperiod) > CoordTol) // may be it is a deg.vertex + } + if (Vperiod != 0. && DiffV > CoordTol && std::abs(DiffV - Vperiod) > CoordTol) + { // may be it is a deg.vertex continue; + } // Check: may be and are on Period from each other if ((Uperiod != 0. && DiffU > Uperiod / 2) @@ -3746,7 +4056,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( // Check: may be it is the end if (LastVertexOfSeam.IsSame(StartVertex) && std::abs(StartPoint.X() - StartOfNextEdge.X()) < Uperiod / 2) + { EndOfWire = true; + } break; } @@ -3760,7 +4072,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( } // for (itl.Initialize(TrueElist); itl.More(); itl.Next()) if (EndOfWire) + { break; + } } if (NextEdge.IsNull()) @@ -3770,7 +4084,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( if (CurVertex.IsSame(StartVertex) && (Uperiod == 0. || std::abs(StartPoint.X() - CurPoint.X()) < Uperiod / 2) && (Vperiod == 0. || std::abs(StartPoint.Y() - CurPoint.Y()) < Vperiod / 2)) + { break; // end of wire + } ReconstructMissedSeam(RemovedEdges, F_RefFace, @@ -3787,7 +4103,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( } } else + { return; + } } CurPoint = NextPoint; CurEdge = NextEdge; @@ -3805,9 +4123,13 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( while (ind <= edges.Length()) { if (UsedEdges.Contains(edges(ind))) + { edges.Remove(ind); + } else + { ind++; + } } // add just built wire to current face or save it in the sequence of wires @@ -3836,9 +4158,13 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { // split this wire if needed if (!SplittingVertices.IsEmpty()) + { SplitWire(aNewWire, F_RefFace, SplittingVertices, NewWires); + } else + { NewWires.Append(aNewWire); + } } } // while (!edges.IsEmpty()) @@ -3848,7 +4174,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopTools_ShapeMapHasher> IntVEmap; for (int ii = 1; ii <= InternalEdges.Extent(); ii++) + { TopExp::MapShapesAndAncestors(InternalEdges(ii), TopAbs_VERTEX, TopAbs_EDGE, IntVEmap); + } NCollection_Sequence InternalWires; while (!InternalEdges.IsEmpty()) { @@ -3864,8 +4192,10 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopExp::Vertices(aFirstEdge, VV[0], VV[1]); for (;;) { - if (VV[0].IsSame(VV[1])) // closed wire + if (VV[0].IsSame(VV[1])) + { // closed wire break; + } bool found = false; for (int ii = 0; ii < 2; ii++) { @@ -3875,7 +4205,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); if (anEdge.IsSame(EndEdges[ii])) + { continue; + } found = true; InternalEdges.RemoveKey(anEdge); RemoveEdgeFromMap(anEdge, IntVEmap); @@ -3887,8 +4219,10 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( break; } } - if (!found) // end of open wire + if (!found) + { // end of open wire break; + } } InternalWires.Append(anInternalWire); } @@ -3902,26 +4236,38 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( TopoDS_Face aResult; BB.MakeFace(aResult, aSurf, aLoc, 0.); for (int ii = 1; ii <= NewWires.Length(); ii++) + { BB.Add(aResult, NewWires(ii)); + } for (int ii = 1; ii <= InternalWires.Length(); ii++) + { BB.Add(aResult, InternalWires(ii)); + } aResult.Orientation(RefFaceOrientation); myContext->Merge(faces, aResult); // Update the map Face-NewFace for (int jj = 1; jj <= faces.Length(); jj++) + { myFaceNewFace.Bind(faces(jj), aResult); + } } else if (NewFaces.Length() == 1) { TopoDS_Shape aNewFace = NewFaces(1).Oriented(TopAbs_FORWARD); for (int ii = 1; ii <= NewWires.Length(); ii++) + { BB.Add(aNewFace, NewWires(ii)); + } for (int ii = 1; ii <= InternalWires.Length(); ii++) + { BB.Add(aNewFace, InternalWires(ii)); + } myContext->Merge(faces, NewFaces(1)); // Update the map Face-NewFace for (int jj = 1; jj <= faces.Length(); jj++) + { myFaceNewFace.Bind(faces(jj), NewFaces(1)); + } } else { @@ -3945,18 +4291,28 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces( { const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); if (BRep_Tool::Degenerated(anEdge) || BRep_Tool::IsClosed(anEdge, RefFace)) + { continue; + } int jj; for (jj = 1; jj <= Emaps.Length(); jj++) + { if (Emaps(jj).Contains(anEdge)) + { break; + } + } if (UsedFaces.Add(faces(jj))) + { facesForThisFace.Append(faces(jj)); + } } myContext->Merge(facesForThisFace, NewFaces(ii)); // Update the map Face-NewFace for (int jj = 1; jj <= facesForThisFace.Length(); jj++) + { myFaceNewFace.Bind(facesForThisFace(jj), NewFaces(ii)); + } } } } // if (faces.Length() > 1) @@ -3982,13 +4338,17 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() TopExp::MapShapesAndUniqueAncestors(aRes, TopAbs_VERTEX, TopAbs_FACE, aVFmap); if (mySafeInputMode) + { UpdateMapOfShapes(myKeepShapes, myContext); + } // Sequence of the edges of the shape NCollection_Sequence aSeqEdges; const int aNbE = aMapEdgeFaces.Extent(); for (int i = 1; i <= aNbE; ++i) + { aSeqEdges.Append(aMapEdgeFaces.FindKey(i)); + } // Prepare map of shared vertices (with the number of connected edges greater then 2) NCollection_Map aSharedVert; @@ -4006,7 +4366,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() { NCollection_List::Iterator it(aMapEdgeFaces(i)); for (; it.More(); it.Next()) + { aChangedFaces.Add(it.Value()); + } } } } @@ -4017,7 +4379,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() { TopoDS_Face aFace = TopoDS::Face(myContext->Apply(aChangedFaces.FindKey(i))); if (aFace.IsNull()) + { continue; + } // for a planar face create and store pcurve of edge on face // to speed up all operations; but this is allowed only when non-safe mode in force @@ -4030,14 +4394,18 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() { NCollection_List aLE; for (TopExp_Explorer anEx(aFace, TopAbs_EDGE); anEx.More(); anEx.Next()) + { aLE.Append(anEx.Current()); + } BRepLib::BuildPCurveForEdgesOnPlane(aLE, aFace); } } ShapeFix_Face sff(aFace); if (mySafeInputMode) + { sff.SetContext(myContext); + } sff.SetPrecision(aPrec); sff.SetMinTolerance(aPrec); sff.SetMaxTolerance(std::max(1., aPrec * 1000.)); @@ -4072,7 +4440,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() } } if (isChanged) + { aRes1 = myContext->Apply(aRes1); + } myContext->Replace(myShape, aRes1); } @@ -4086,9 +4456,13 @@ void ShapeUpgrade_UnifySameDomain::Build() TopExp::MapShapesAndAncestors(myInitShape, TopAbs_EDGE, TopAbs_FACE, myEFmap); if (myUnifyFaces) + { UnifyFaces(); + } if (myUnifyEdges) + { UnifyEdges(); + } // Fill the history of modifications during the operation FillHistory(); @@ -4101,8 +4475,10 @@ void ShapeUpgrade_UnifySameDomain::Build() void ShapeUpgrade_UnifySameDomain::FillHistory() { if (myHistory.IsNull()) + { // History is not requested return; + } // Only Vertices, Edges and Faces can be modified during unification. // Thus, only these kind of shapes should be checked. @@ -4162,8 +4538,10 @@ void ShapeUpgrade_UnifySameDomain::FillHistory() if (aMapResultShapes.Contains(aSIm)) { if (!aSIm.IsSame(aS)) + { // Image is found in the result, thus the shape has been modified aUSDHistory->AddModified(aS, aSIm); + } bRemoved = false; } } @@ -4192,13 +4570,19 @@ void SplitWire(const TopoDS_Wire& { const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value()); if (!aEmap.Add(anEdge)) + { continue; + } if (anEdge.Orientation() != TopAbs_FORWARD && anEdge.Orientation() != TopAbs_REVERSED) + { continue; + } const TopoDS_Vertex& aVertex = TopExp::FirstVertex(anEdge, true); // with orientation if (aVEmap.IsBound(aVertex)) + { aVEmap(aVertex).Append(anEdge); + } else { NCollection_List aElist; @@ -4228,14 +4612,20 @@ void SplitWire(const TopoDS_Wire& const TopoDS_Vertex& aVertex = TopExp::LastVertex (CurEdge, true); //with orientation // clang-format on if (aVertex.IsSame(anOrigin)) + { break; + } if (!aVEmap.IsBound(aVertex)) + { break; + } NCollection_List& aElist = aVEmap(aVertex); if (aElist.Extent() == 0) + { break; + } if (aElist.Extent() == 1) { @@ -4253,7 +4643,9 @@ void SplitWire(const TopoDS_Wire& aPCurve->D1(aParam, aPoint, CurDir); CurDir.Normalize(); if (CurEdge.Orientation() == TopAbs_REVERSED) + { CurDir.Reverse(); + } // choose the rightest direction - the smallest angle double MinAngle = RealLast(); TopoDS_Edge NextEdge; @@ -4267,7 +4659,9 @@ void SplitWire(const TopoDS_Wire& aPCurve->D1(aParam, aPoint, aDir); aDir.Normalize(); if (anEdge.Orientation() == TopAbs_REVERSED) + { aDir.Reverse(); + } double anAngle = CurDir.Angle(aDir); if (anAngle < MinAngle) { @@ -4278,11 +4672,13 @@ void SplitWire(const TopoDS_Wire& CurEdge = NextEdge; // Remove from list for (aLocalIter.Initialize(aElist); aLocalIter.More(); aLocalIter.Next()) + { if (CurEdge.IsSame(aLocalIter.Value())) { aElist.Remove(aLocalIter); break; } + } } // else (more than one edge) } // for (;;) theWireSeq.Append(aNewWire); diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx index 23e43274f4..7937581b1c 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeUpgrade/ShapeUpgrade_WireDivide.cxx @@ -111,7 +111,9 @@ void ShapeUpgrade_WireDivide::Load(const TopoDS_Edge& E) { BRepLib_MakeWire MakeWire(E); if (MakeWire.IsDone()) + { Load(MakeWire.Wire()); + } } //================================================================================================= @@ -161,8 +163,12 @@ static void CorrectSplitValues(const occ::handle>& double par = new2d->Value(i); int index = 0; for (int j = 1; j <= len2d && !index; j++) + { if (std::abs(par - orig2d->Value(j)) < preci) + { index = j; + } + } if (index && !fixNew3d(index)) { double newPar = orig2d->Value(index); @@ -179,8 +185,12 @@ static void CorrectSplitValues(const occ::handle>& double par = new3d->Value(i); int index = 0; for (int j = 1; j <= len3d && !index; j++) + { if (std::abs(par - orig3d->Value(j)) < preci) + { index = j; + } + } if (index && !fixNew2d(index)) { double newPar = orig3d->Value(index); @@ -208,14 +218,18 @@ static void CorrectSplitValues(const occ::handle>& fixNew2d(i + 1) = false; } else + { new2d->SetValue(i + 1, new2d->Value(i) + dpreci); + } } } if (new2d->Value(len3d) > Last3d) { int ind; // svv #1 for (ind = len3d; ind > 1 && !fixNew2d(ind); ind--) + { ; + } double lastFix = new2d->Value(ind); for (i = len3d; i >= ind; i--) { @@ -239,14 +253,18 @@ static void CorrectSplitValues(const occ::handle>& fixNew3d(i + 1) = false; } else + { new3d->SetValue(i + 1, new3d->Value(i) + dpreci); + } } } if (new3d->Value(len2d) > Last2d) { int ind; // svv #1 for (ind = len2d; ind > 1 && !fixNew3d(ind); ind--) + { ; + } double lastFix = new3d->Value(ind); for (i = len2d; i >= ind; i--) { @@ -271,25 +289,33 @@ void ShapeUpgrade_WireDivide::Perform() TopLoc_Location Loc; occ::handle Surf; if (!myFace.IsNull()) + { Surf = BRep_Tool::Surface(myFace, Loc); + } bool isSplit3d = true; switch (myEdgeMode) { case 0: if (!myFace.IsNull()) + { isSplit3d = false; + } break; case 1: if (myFace.IsNull()) + { isSplit3d = false; + } break; default: break; } myEdgeDivide->SetFace(myFace); if (isSplit3d) + { myEdgeDivide->SetSplitCurve3dTool(GetSplitCurve3dTool()); + } myEdgeDivide->SetSplitCurve2dTool(GetSplitCurve2dTool()); for (TopoDS_Iterator ItW(myWire, false); ItW.More(); ItW.Next()) { @@ -360,16 +386,24 @@ void ShapeUpgrade_WireDivide::Perform() } // get 2d and 3d split values which should be the same if (myEdgeDivide->HasCurve2d()) + { theKnots2d = theSplit2dTool->SplitValues(); + } if (myEdgeDivide->HasCurve3d()) + { theKnots3d = theSplit3dTool->SplitValues(); + } bool isSeam = false; if (!myFace.IsNull()) + { isSeam = BRep_Tool::IsClosed(E, myFace); + } occ::handle>> theSegments2d; if (myEdgeDivide->HasCurve2d()) + { theSegments2d = theSplit2dTool->GetCurves(); + } occ::handle>> theSegments2dR; if (isSeam) { @@ -382,7 +416,9 @@ void ShapeUpgrade_WireDivide::Perform() { theSplit2dTool->Init(c2, f2, l2); if (!theKnots2d.IsNull()) + { theSplit2dTool->SetSplitValues(theKnots2d); + } theSplit2dTool->Perform(true); occ::handle> revKnots2d = theSplit2dTool->SplitValues(); if (revKnots2d->Length() != theKnots2d->Length()) @@ -395,10 +431,14 @@ void ShapeUpgrade_WireDivide::Perform() #endif } else + { theSegments2dR = theSplit2dTool->GetCurves(); + } } else + { isSeam = false; + } } // Exploring theEdge @@ -434,7 +474,9 @@ void ShapeUpgrade_WireDivide::Perform() occ::handle c3d; Adaptor3d_CurveOnSurface AdCS; if (myEdgeDivide->HasCurve3d()) + { sae.Curve3d(E, c3d, af, al, false); + } else if (myEdgeDivide->HasCurve2d() && !Surf.IsNull()) { occ::handle c2d; @@ -459,9 +501,13 @@ void ShapeUpgrade_WireDivide::Perform() double ppar; gp_Pnt pproj; if (!c3d.IsNull()) + { sac.Project(c3d, aP, Precision(), pproj, ppar, af, al, false); + } else + { sac.Project(AdCS, aP, Precision(), pproj, ppar); + } aSeqParNM.Append(ppar); } } @@ -469,7 +515,9 @@ void ShapeUpgrade_WireDivide::Perform() // creating new edge(s) occ::handle>> theSegments3d; if (myEdgeDivide->HasCurve3d()) + { theSegments3d = theSplit3dTool->GetCurves(); + } int nbc = 0; if (!theSegments3d.IsNull()) @@ -488,8 +536,10 @@ void ShapeUpgrade_WireDivide::Perform() } } } - else if (!theSegments2d.IsNull()) // if theSegments have different length ??? + else if (!theSegments2d.IsNull()) + { // if theSegments have different length ??? nbc = theSegments2d->Length(); + } if (nbc <= 1 && !theSplit3dTool->Status(ShapeExtend_DONE) && !theSplit2dTool->Status(ShapeExtend_DONE)) @@ -525,14 +575,20 @@ void ShapeUpgrade_WireDivide::Perform() occ::handle theNewCurve3d; if (!theSegments3d.IsNull()) + { theNewCurve3d = theSegments3d->Value(icurv); + } occ::handle theNewPCurve1; if (!theSegments2d.IsNull()) + { theNewPCurve1 = theSegments2d->Value(icurv); + } occ::handle revPCurve; if (isSeam) + { revPCurve = theSegments2dR->Value(icurv); + } // construction of the intermediate Vertex TopoDS_Vertex V; if (icurv <= nbc && nbc != 1 && !isDeg) @@ -561,7 +617,9 @@ void ShapeUpgrade_WireDivide::Perform() else { if (Surf.IsNull()) + { Surf = BRep_Tool::Surface(myFace, Loc); + } if (theNewPCurve1->IsKind(STANDARD_TYPE(Geom2d_BoundedCurve))) { par = theNewPCurve1->LastParameter(); @@ -641,7 +699,9 @@ void ShapeUpgrade_WireDivide::Perform() pntV1 = P; } else + { V = V2; + } // else V2; // } // if (ShapeUpgrade::Debug()) std::cout <<"... New intermediate Vertex (" @@ -666,9 +726,13 @@ void ShapeUpgrade_WireDivide::Perform() } sbe.CopyPCurves(newEdge, E); if (!theNewCurve3d.IsNull()) + { B.UpdateEdge(newEdge, theNewCurve3d, 0.); + } else if (isDeg) + { B.Degenerated(newEdge, true); + } // if(isSeam) { // occ::handle revPCurve = theSegments2dR->Value(icurv); // if(newEdge.Orientation()==TopAbs_FORWARD) @@ -681,7 +745,9 @@ void ShapeUpgrade_WireDivide::Perform() double f3d = 0., l3d = 0.; if (!Savnum) + { Savnum = icurv; + } bool srNew; if (!theNewCurve3d.IsNull()) { @@ -699,7 +765,9 @@ void ShapeUpgrade_WireDivide::Perform() } } else + { srNew = true; + } double f2d = 0, l2d = 0; if (!theNewPCurve1.IsNull()) @@ -718,15 +786,19 @@ void ShapeUpgrade_WireDivide::Perform() } // if(!Savnum) Savnum = icurv; if (!theNewCurve3d.IsNull()) + { theTransferParamTool->TransferRange(newEdge, theKnots3d->Value(Savnum), theKnots3d->Value(icurv + 1), false); + } else + { theTransferParamTool->TransferRange(newEdge, theKnots2d->Value(Savnum), theKnots2d->Value(icurv + 1), true); + } /* double alpha = (theKnots3d->Value (icurv) - f)/(l - f); double beta = (theKnots3d->Value (icurv + 1) - f)/(l - f); @@ -735,15 +807,21 @@ void ShapeUpgrade_WireDivide::Perform() occ::handle c2dTmp; double setF, setL; if (!myFace.IsNull() && sae.PCurve(newEdge, myFace, c2dTmp, setF, setL, false)) + { srNew &= ((setF == f2d) && (setL == l2d)); + } if (isSeam) { // Handle(Geom2d_Curve revPCurve = theSegments2dR->Value(icurv); if (newEdge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(newEdge, theNewPCurve1, revPCurve, myFace, 0.); + } else + { B.UpdateEdge(newEdge, revPCurve, theNewPCurve1, myFace, 0.); + } } else if (!myFace.IsNull()) { @@ -751,7 +829,9 @@ void ShapeUpgrade_WireDivide::Perform() } if (!theNewCurve3d.IsNull()) + { sbe.SetRange3d(newEdge, f3d, l3d); + } if (!theNewPCurve1.IsNull()) { B.Range(newEdge, myFace, f2d, l2d); @@ -808,7 +888,9 @@ void ShapeUpgrade_WireDivide::Perform() Context()->Replace(E, resWire); } else + { Context()->Remove(E); + } } } if (Status(ShapeExtend_DONE)) diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepApprox/BRepApprox_ApproxLine.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepApprox/BRepApprox_ApproxLine.cxx index 32ec77a8ff..f5db8f58da 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepApprox/BRepApprox_ApproxLine.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepApprox/BRepApprox_ApproxLine.cxx @@ -47,11 +47,17 @@ BRepApprox_ApproxLine::BRepApprox_ApproxLine(const occ::handle int BRepApprox_ApproxLine::NbPnts() const { if (!myCurveXYZ.IsNull()) + { return (myCurveXYZ->NbPoles()); + } if (!myCurveUV1.IsNull()) + { return (myCurveUV1->NbPoles()); + } if (!myCurveUV2.IsNull()) + { return (myCurveUV2->NbPoles()); + } return (myLineOn2S->NbPoints()); } @@ -69,11 +75,17 @@ IntSurf_PntOn2S BRepApprox_ApproxLine::Point(const int Index) gp_Pnt2d P1, P2; gp_Pnt P; if (!myCurveXYZ.IsNull()) + { P = myCurveXYZ->Pole(Index); + } if (!myCurveUV1.IsNull()) + { P1 = myCurveUV1->Pole(Index); + } if (!myCurveUV2.IsNull()) + { P2 = myCurveUV2->Pole(Index); + } IntSurf_PntOn2S aPntOn2S; aPntOn2S.SetValue(P, P1.X(), P1.Y(), P2.X(), P2.Y()); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib.cxx index a12719bc99..11a7d84aa1 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib.cxx @@ -158,9 +158,13 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, bool useTriangulation) for (i = 1; i <= nbNodes; i++) { if (l.IsIdentity()) + { B.Add(Nodes[i]); + } else + { B.Add(Nodes[i].Transformed(l)); + } } // B.Enlarge(P3d->Deflection()); B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E)); @@ -360,9 +364,13 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, for (i = 1; i <= nbNodes; i++) { if (l.IsIdentity()) + { aLocBox.Add(Nodes[i]); + } else + { aLocBox.Add(Nodes[i].Transformed(l)); + } } double Tol = useShapeTolerance ? BRep_Tool::Tolerance(E) : 0.; aLocBox.Enlarge(P3d->Deflection() + Tol); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib_1.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib_1.cxx index ec1f4cfb0c..735f942597 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib_1.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBndLib/BRepBndLib_1.cxx @@ -80,7 +80,9 @@ static bool IsPlanar(const Adaptor3d_Surface& theS) if ((aST == GeomAbs_BSplineSurface) || (aST == GeomAbs_BezierSurface)) { if ((theS.UDegree() != 1) || (theS.VDegree() != 1)) + { return false; + } // Indeed, surfaces with C0-continuity and degree==1, may be // represented with set of points. It will be possible made @@ -133,7 +135,9 @@ static int PointsForOBB(const TopoDS_Shape& theS, } if (aRetVal == 0) + { return 0; + } // analyze the faces of the shape on planarity and existence of triangulation TopLoc_Location aLoc; @@ -145,8 +149,10 @@ static int PointsForOBB(const TopoDS_Shape& theS, if (!IsPlanar(anAS)) { if (!theIsTriangulationUsed) + { // not planar and triangulation usage disabled return 0; + } } else { @@ -160,8 +166,10 @@ static int PointsForOBB(const TopoDS_Shape& theS, if (!IsLinear(anAC)) { if (!theIsTriangulationUsed) + { // not linear and triangulation usage disabled return 0; + } break; } @@ -169,8 +177,10 @@ static int PointsForOBB(const TopoDS_Shape& theS, } if (!anExpE.More()) + { // skip planar face with linear edges as its vertices have already been added continue; + } } // Use triangulation of the face @@ -217,12 +227,16 @@ static int PointsForOBB(const TopoDS_Shape& theS, } if (!theIsTriangulationUsed) + { // not linear and triangulation usage disabled return 0; + } const occ::handle& aPolygon = BRep_Tool::Polygon3D(anE, aLoc); if (aPolygon.IsNull()) + { return 0; + } const int aCNode = aPolygon->NbNodes(); const NCollection_Array1& aNodesArr = aPolygon->Nodes(); @@ -260,13 +274,19 @@ static int IsWCS(const gp_Dir& theDir) const double aVx = aY * aY + aZ * aZ, aVy = aX * aX + aZ * aZ, aVz = aX * aX + aY * aY; if (aVz < aToler) + { return 3; // Z-axis + } if (aVy < aToler) + { return 2; // Y-axis + } if (aVx < aToler) + { return 1; // X-axis + } return 0; } @@ -286,7 +306,9 @@ static bool CheckPoints(const TopoDS_Shape& theS, const int aNbPnts = PointsForOBB(theS, theIsTriangulationUsed); if (aNbPnts < 1) + { return false; + } NCollection_Array1 anArrPnts(0, theOBB.IsVoid() ? aNbPnts - 1 : aNbPnts + 7); NCollection_Array1 anArrOfTolerances; @@ -467,7 +489,9 @@ void BRepBndLib::AddOBB(const TopoDS_Shape& theS, const bool theIsShapeToleranceUsed) { if (CheckPoints(theS, theIsTriangulationUsed, theIsOptimal, theIsShapeToleranceUsed, theOBB)) + { return; + } ComputePCA(theS, theOBB, theIsTriangulationUsed, theIsOptimal, theIsShapeToleranceUsed); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Collect.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Collect.cxx index ae5633968e..cf51b9f24c 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Collect.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Collect.cxx @@ -68,7 +68,9 @@ static void Replace(NCollection_List& L, break; } if (it.More()) + { it.Next(); + } } //--------------------------- // Ajout de New a L. @@ -131,7 +133,9 @@ static void Update( { const TopoDS_Shape& S = exp.Current(); if (!DejaVu.Add(S)) + { continue; + } //--------------------------------------- // Recuperation de l image de S par MKS. @@ -279,7 +283,9 @@ static void FilterByShape( bool YaEdge = false; bool YaVertex = false; for (exp.Init(SF, TopAbs_FACE); exp.More(); exp.Next()) + { MSF.Add(exp.Current()); + } //------------------------------------------------------------- // Suppression de toutes les images qui ne sont pas dans MSF. @@ -324,7 +330,9 @@ static void FilterByShape( LNS.Remove(itl); } else if (itl.More()) + { itl.Next(); + } } } #ifdef OCCT_DEBUG diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Command.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Command.cxx index a095290be6..fe77f02dff 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Command.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Command.cxx @@ -40,7 +40,9 @@ bool BRepBuilderAPI_Command::IsDone() const void BRepBuilderAPI_Command::Check() const { if (!myDone) + { throw StdFail_NotDone("BRep_API: command not done"); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FastSewing.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FastSewing.cxx index 72090e8205..a3d8d09d6a 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FastSewing.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FastSewing.cxx @@ -57,13 +57,17 @@ static int IntersectionOfSets(const NCollection_List& theSet1, { // theIntersectionResult.Append(aVal1); if (aVal1 < aRetVal) + { aRetVal = aVal1; + } } } } if (aRetVal == anIntMax) + { return -1; + } return aRetVal; } @@ -78,7 +82,9 @@ static occ::handle Get2DCurve(const int theIndex, const bool theIsReverse = false) { if ((theIndex < 0) || (theIndex > 3)) + { throw Standard_OutOfRange("BRepBuilderAPI_FastSewing.cxx, Get2DCurve(): OUT of Range"); + } occ::handle a2dCurv; @@ -456,7 +462,9 @@ BRepBuilderAPI_FastSewing::FS_VARStatuses BRepBuilderAPI_FastSewing::GetStatuses Standard_OStream* const theOS) { if (!theOS) + { return myStatusList; + } if (!myStatusList) { @@ -470,7 +478,9 @@ BRepBuilderAPI_FastSewing::FS_VARStatuses BRepBuilderAPI_FastSewing::GetStatuses for (int i = 1; i <= aNumMax; i++, anIDS = static_cast(anIDS << 1)) { if ((anIDS & myStatusList) == 0) + { continue; + } switch (anIDS) { @@ -518,7 +528,9 @@ double BRepBuilderAPI_FastSewing::Compute3DRange() FS_Face& aFace = myFaceVec.ChangeValue(i); const occ::handle aSurf = BRep_Tool::Surface(aFace.mySrcFace); if (aSurf.IsNull()) + { continue; + } double aUf = 0.0, aUl = 0.0, aVf = 0.0, aVl = 0.0; aSurf->Bounds(aUf, aUl, aVf, aVl); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FindPlane.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FindPlane.cxx index b79b8c2e32..a5c99106e0 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FindPlane.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_FindPlane.cxx @@ -61,7 +61,9 @@ void BRepBuilderAPI_FindPlane::Init(const TopoDS_Shape& S, const double Tol) { double t = BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())); if (t > tolerance) + { tolerance = t; + } } double tol2 = tolerance * tolerance; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_GTransform.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_GTransform.cxx index 564bcceb36..8c5b55044b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_GTransform.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_GTransform.cxx @@ -69,7 +69,9 @@ const NCollection_List& BRepBuilderAPI_GTransform::Modified(const NCollection_List Li; NCollection_List::Iterator itL(M(F)); for (; itL.More(); itL.Next()) + { Li.Assign(BRepBuilderAPI_ModifyShape::Modified(itL.Value())); + } } return myGenerated; } @@ -88,7 +90,9 @@ TopoDS_Shape BRepBuilderAPI_GTransform::ModifiedShape(const TopoDS_Shape& S) con int aNbShapes = aListModShape.Extent(); if (aNbShapes > 0) + { aShape = aListModShape.First(); + } } return BRepBuilderAPI_ModifyShape::ModifiedShape(aShape); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakePolygon.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakePolygon.cxx index 10933da4ec..fa5cf66727 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakePolygon.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakePolygon.cxx @@ -120,7 +120,9 @@ void BRepBuilderAPI_MakePolygon::Add(const gp_Pnt& P) { Done(); if (!LastVertex().IsNull()) + { myShape = myMakePolygon.Shape(); + } } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx index ccfa821972..3adbfdf54b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx @@ -80,7 +80,9 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange // Cannot reconstruct anything from null or empty mesh. if (myMesh.IsNull() || myMesh->NbNodes() == 0 || myMesh->NbTriangles() == 0) + { return; + } const int aNbNodes = myMesh->NbNodes(); const int aNbTriangles = myMesh->NbTriangles(); @@ -98,7 +100,9 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange { aPS.Next(); if (aPS.UserBreak()) + { return; + } const gp_Pnt aP = myMesh->Node(i); const TopoDS_Vertex aV = BRepBuilderAPI_MakeVertex(aP); @@ -111,7 +115,9 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange { aPS.Next(); if (aPS.UserBreak()) + { return; + } int anIdx[3]; const Poly_Triangle& aTriangle = myMesh->Triangle(i); @@ -119,7 +125,9 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange // Skip degenerated triangles. if (anIdx[0] == anIdx[1] || anIdx[0] == anIdx[2] || anIdx[1] == anIdx[2]) + { continue; + } const gp_Pnt aP1 = myMesh->Node(anIdx[0]); const gp_Pnt aP2 = myMesh->Node(anIdx[1]); @@ -149,15 +157,21 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange TopoDS_Edge aTE1 = aMaker1.Edge(); if (anIdx[1] < anIdx[0]) + { aTE1.Reverse(); + } TopoDS_Edge aTE2 = aMaker2.Edge(); if (anIdx[2] < anIdx[1]) + { aTE2.Reverse(); + } TopoDS_Edge aTE3 = aMaker3.Edge(); if (anIdx[0] < anIdx[2]) + { aTE3.Reverse(); + } anEdgeToTEgeMap.Add(aMeshEdge1, aTE1); anEdgeToTEgeMap.Add(aMeshEdge2, aTE2); @@ -172,7 +186,9 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange { aPS.Next(); if (aPS.UserBreak()) + { return; + } int anIdx[3]; const Poly_Triangle& aTriangle = myMesh->Triangle(i); @@ -191,17 +207,25 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange && anEdgeToTEgeMap.Contains(aMeshEdge2) && anEdgeToTEgeMap.Contains(aMeshEdge3); if (!aHasAllEdges) + { continue; + } TopoDS_Edge aTEdge1 = anEdgeToTEgeMap.FindFromKey(aMeshEdge1); if (isReversed1) + { aTEdge1.Reverse(); + } TopoDS_Edge aTEdge2 = anEdgeToTEgeMap.FindFromKey(aMeshEdge2); if (isReversed2) + { aTEdge2.Reverse(); + } TopoDS_Edge aTEdge3 = anEdgeToTEgeMap.FindFromKey(aMeshEdge3); if (isReversed3) + { aTEdge3.Reverse(); + } BRepBuilderAPI_MakeWire aWireMaker; aWireMaker.Add(aTEdge1); @@ -217,11 +241,17 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange const gp_Dir aD2 = aC2.Line().Direction(); gp_XYZ aN = aD1.XYZ().Crossed(aD2.XYZ()); if (aN.SquareModulus() < Precision::SquareConfusion()) + { continue; + } if (aTEdge1.Orientation() == TopAbs_REVERSED) + { aN.Reverse(); + } if (aTEdge2.Orientation() == TopAbs_REVERSED) + { aN.Reverse(); + } const gp_Dir aNorm(aN); gp_Pln aPln(myMesh->Node(anIdx[0]), aNorm); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeSolid.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeSolid.cxx index 8c8029926f..acfe5e7a0d 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeSolid.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_MakeSolid.cxx @@ -142,7 +142,9 @@ bool BRepBuilderAPI_MakeSolid::IsDeleted(const TopoDS_Shape& S) BRepLib_ShapeModification aStatus = myMakeSolid.FaceStatus(TopoDS::Face(S)); if (aStatus == BRepLib_Deleted) + { return true; + } } return false; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx index cb0d2608d1..0fee393a8a 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx @@ -147,14 +147,20 @@ TopoDS_Face BRepBuilderAPI_Sewing::WhichFace(const TopoDS_Edge& theEdg, const in { TopoDS_Shape bound = theEdg; if (mySectionBound.IsBound(bound)) + { bound = mySectionBound(bound); + } if (myBoundFaces.Contains(bound)) { int i = 1; NCollection_List::Iterator itf(myBoundFaces.FindFromKey(bound)); for (; itf.More(); itf.Next(), i++) + { if (i == index) + { return TopoDS::Face(itf.Value()); + } + } } return TopoDS_Face(); } @@ -171,13 +177,19 @@ static bool IsClosedShape(const TopoDS_Shape& theshape, { TopoDS_Edge aedge = TopoDS::Edge(aexp.Current()); if (aedge.IsNull()) + { continue; + } TopoDS_Vertex ve1, ve2; TopExp::Vertices(aedge, ve1, ve2); if (!ve1.IsSame(v1) && !ve1.IsSame(v2)) + { continue; + } if (BRep_Tool::Degenerated(aedge)) + { continue; + } double first, last; occ::handle c3d = BRep_Tool::Curve(TopoDS::Edge(aedge), first, last); if (!c3d.IsNull()) @@ -186,7 +198,9 @@ static bool IsClosedShape(const TopoDS_Shape& theshape, double length = GCPnts_AbscissaPoint::Length(cAdapt, first, last); TotLength += length; if (ve2.IsSame(v1) || ve2.IsSame(v2)) + { break; + } } } if (TotLength > 0.0) @@ -250,9 +264,13 @@ bool BRepBuilderAPI_Sewing::IsUClosedSurface(const occ::handle& su { occ::handle tmpsurf = surf; if (tmpsurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { tmpsurf = occ::down_cast(surf)->BasisSurface(); + } else if (tmpsurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) + { tmpsurf = occ::down_cast(surf)->BasisSurface(); + } else { bool isClosed = tmpsurf->IsUClosed(); @@ -262,7 +280,9 @@ bool BRepBuilderAPI_Sewing::IsUClosedSurface(const occ::handle& su occ::handle acrv2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge), surf, theloc, f2d, l2d); if (!acrv2d.IsNull()) + { isClosed = IsClosedByIsos(tmpsurf, acrv2d, f2d, l2d, false); + } } return isClosed; } @@ -278,9 +298,13 @@ bool BRepBuilderAPI_Sewing::IsVClosedSurface(const occ::handle& su { occ::handle tmpsurf = surf; if (tmpsurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { tmpsurf = occ::down_cast(surf)->BasisSurface(); + } else if (tmpsurf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) + { tmpsurf = occ::down_cast(surf)->BasisSurface(); + } else { bool isClosed = tmpsurf->IsVClosed(); @@ -290,7 +314,9 @@ bool BRepBuilderAPI_Sewing::IsVClosedSurface(const occ::handle& su occ::handle acrv2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge), surf, theloc, f2d, l2d); if (!acrv2d.IsNull()) + { isClosed = IsClosedByIsos(tmpsurf, acrv2d, f2d, l2d, true); + } } return isClosed; } @@ -341,7 +367,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( TopoDS_Edge Edge1 = TopoDS::Edge(aTmpShape); aTmpShape = locReShape->Apply(Edge1); if (locReShape != myReShape) + { Edge1 = TopoDS::Edge(aTmpShape); + } bool isDone = false; // Create data structures for temporary merged edges @@ -354,13 +382,19 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( // Fill MergedFaces with faces of Edge1 TopoDS_Shape bnd1 = edge; if (mySectionBound.IsBound(bnd1)) + { bnd1 = mySectionBound(bnd1); + } if (myBoundFaces.Contains(bnd1)) { NCollection_List::Iterator itf(myBoundFaces.FindFromKey(bnd1)); for (; itf.More(); itf.Next()) + { if (MergedFaces.Add(itf.Value())) + { listFaces1.Append(itf.Value()); + } + } } } else @@ -370,9 +404,13 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( TopoDS_Vertex V1, V2; TopExp::Vertices(Edge1, V1, V2); if (myVertexNode.Contains(V1)) + { V1 = TopoDS::Vertex(myVertexNode.FindFromKey(V1)); + } if (myVertexNode.Contains(V2)) + { V2 = TopoDS::Vertex(myVertexNode.FindFromKey(V2)); + } TopoDS_Edge NewEdge = Edge1; NewEdge.EmptyCopy(); @@ -402,36 +440,52 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( TopoDS_Edge Edge2 = TopoDS::Edge(aTmpShape); aTmpShape = locReShape->Apply(Edge2); if (locReShape != myReShape) + { Edge2 = TopoDS::Edge(aTmpShape); + } // Calculate relative orientation bool Orientation = seqForward(i); if (!isForward) + { Orientation = !Orientation; + } // Retrieve faces information for the second edge TopoDS_Shape bnd2 = oedge2; if (mySectionBound.IsBound(bnd2)) + { bnd2 = mySectionBound(bnd2); + } if (!myBoundFaces.Contains(bnd2)) + { continue; // Skip floating edge + } const NCollection_List& listFaces2 = myBoundFaces.FindFromKey(bnd2); int whichSec = 1; // Indicates on which edge the pCurve has been reported TopoDS_Edge NewEdge = SameParameterEdge(Edge1, Edge2, listFaces1, listFaces2, Orientation, whichSec); if (NewEdge.IsNull()) + { continue; + } // Record faces information for the temporary merged edge NCollection_List::Iterator itf(listFaces2); for (; itf.More(); itf.Next()) + { if (MergedFaces.Add(itf.Value())) + { listFaces1.Append(itf.Value()); + } + } // Record merged section orientation if (!Orientation && whichSec != 1) + { isForward = !isForward; + } Edge1 = NewEdge; } @@ -440,7 +494,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( isDone = true; if (!myNonmanifold) + { break; + } } if (isDone) @@ -449,7 +505,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( Edge1.Orientation(isForward ? TopAbs_FORWARD : TopAbs_REVERSED); } else + { Edge1.Nullify(); + } return Edge1; } @@ -465,11 +523,15 @@ static bool findNMVertices(const TopoDS_Edge& theEdge, { if (aItV.Value().Orientation() == TopAbs_INTERNAL || aItV.Value().Orientation() == TopAbs_EXTERNAL) + { theSeqNMVert.Append(aItV.Value()); + } } int nbV = theSeqNMVert.Length(); if (!nbV) + { return false; + } double first, last; occ::handle c3d = BRep_Tool::Curve(theEdge, first, last); GeomAdaptor_Curve GAC(c3d); @@ -501,7 +563,9 @@ static bool findNMVertices(const TopoDS_Edge& theEdge, } } if (indMin) + { apar = locProj.Point(indMin).Parameter(); + } theSeqPars.Append(apar); } @@ -554,7 +618,6 @@ static void ComputeToleranceVertex(TopoDS_Vertex theV1, TopoDS_Vertex theV2, Top // aBB.MakeVertex(theNewV, aPr, aRr); } - return; } static void ComputeToleranceVertex(TopoDS_Vertex theV1, @@ -587,12 +650,13 @@ static void ComputeToleranceVertex(TopoDS_Vertex theV1, aDi = aCenter.Distance(aP[i]); aDi += aR[i]; if (aDi > aDmax) + { aDmax = aDi; + } } BRep_Builder aBB; aBB.MakeVertex(theNewV, aCenter, aDmax); - return; } TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( @@ -606,7 +670,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( { // Do not process floating edges if (!listFacesFirst.Extent() || !listFacesLast.Extent()) + { return TopoDS_Edge(); + } // Sort input edges TopoDS_Edge edge1, edge2; @@ -696,12 +762,16 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( if (secForward) { if (V11.IsSame(V22) || V12.IsSame(V21)) + { return TopoDS_Edge(); + } } else { if (V11.IsSame(V21) || V12.IsSame(V22)) + { return TopoDS_Edge(); + } } } @@ -761,10 +831,14 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( } } if (isOldFirst) + { V1New = V11; + } if (isOldLast) + { V2New = V12; + } } // Add the vertices in the good sense TopoDS_Shape anEdge = edge.Oriented(TopAbs_FORWARD); @@ -777,7 +851,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( int k = 1; for (; k <= aSeqNMVert.Length(); k++) + { aBuilder.Add(anEdge, aSeqNMVert.Value(k)); + } } // Retrieve second PCurves @@ -789,9 +865,13 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( NCollection_List::Iterator itf2; if (whichSec == 1) + { itf2.Initialize(listFacesLast); + } else + { itf2.Initialize(listFacesFirst); + } bool isResEdge = false; TopoDS_Face fac2; for (; itf2.More(); itf2.Next()) @@ -806,13 +886,17 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( if (isSeam2) { if (!myNonmanifold) + { return TopoDS_Edge(); + } TopoDS_Shape aTmpShape = edge2.Reversed(); // for porting c2d21 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aTmpShape), fac2, firstOld, lastOld); } c2d2 = BRep_Tool::CurveOnSurface(edge2, fac2, firstOld, lastOld); if (c2d2.IsNull() && c2d21.IsNull()) + { continue; + } if (!c2d21.IsNull()) { @@ -820,7 +904,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( if (!secForward) { if (c2d21->IsKind(STANDARD_TYPE(Geom2d_Line))) + { c2d21 = new Geom2d_TrimmedCurve(c2d21, firstOld, lastOld); + } double first2d = firstOld; // c2dTmp->FirstParameter(); BUG USA60321 double last2d = lastOld; // c2dTmp->LastParameter(); firstOld = c2d21->ReversedParameter(last2d); @@ -836,7 +922,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( if (!secForward) { if (c2d2->IsKind(STANDARD_TYPE(Geom2d_Line))) + { c2d2 = new Geom2d_TrimmedCurve(c2d2, firstOld, lastOld); + } double first2d = firstOld; double last2d = lastOld; firstOld = c2d2->ReversedParameter(last2d); @@ -846,7 +934,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( c2d2 = SameRange(c2d2, firstOld, lastOld, first, last); if (c2d2.IsNull()) + { continue; + } // Add second PCurve bool isSeam = false; @@ -855,9 +945,13 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( NCollection_List::Iterator itf1; if (whichSec == 1) + { itf1.Initialize(listFacesFirst); + } else + { itf1.Initialize(listFacesLast); + } for (; itf1.More() && !isSeam; itf1.Next()) { occ::handle c2d1, c2d11; @@ -872,25 +966,37 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( c2d1 = BRep_Tool::CurveOnSurface(edge1, fac1, first2d, last2d); Ori = edge1.Orientation(); if (fac1.Orientation() == TopAbs_REVERSED) + { Ori = TopAbs::Reverse(Ori); + } if (isSeam1) { if (!myNonmanifold) + { return TopoDS_Edge(); + } TopoDS_Shape aTmpShape = edge1.Reversed(); // for porting c2d11 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aTmpShape), fac1, first2d, last2d); // if(fac1.Orientation() == TopAbs_REVERSED) // if (Ori == TopAbs_FORWARD) + { aBuilder.UpdateEdge(edge, c2d1, c2d11, fac1, 0); + } else + { aBuilder.UpdateEdge(edge, c2d11, c2d1, fac1, 0); + } } else + { aBuilder.UpdateEdge(edge, c2d1, fac1, 0); + } if (c2d1.IsNull() && c2d11.IsNull()) + { continue; + } if (surf2 == surf1) { @@ -912,7 +1018,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( isSeam = ((uclosed && aDist > 0.75 * (fabs(U2 - U1))) || (vclosed && aDist > 0.75 * (fabs(V2 - V1)))); if (!isSeam && BRep_Tool::IsClosed(TopoDS::Edge(edge), fac1)) + { continue; + } } } } @@ -921,9 +1029,13 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( if (isSeam) { if (Ori == TopAbs_FORWARD) + { aBuilder.UpdateEdge(edge, c2d1, c2d2, surf2, loc2, Precision::Confusion()); + } else + { aBuilder.UpdateEdge(edge, c2d2, c2d1, surf2, loc2, Precision::Confusion()); + } } else if (isSeam2) { @@ -936,12 +1048,18 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( SecOri = TopAbs::Reverse(SecOri); } if (!secForward) + { InitOri = TopAbs::Reverse(InitOri); + } if (InitOri == TopAbs_FORWARD) + { aBuilder.UpdateEdge(edge, c2d2, c2d21, surf2, loc2, Precision::Confusion()); + } else + { aBuilder.UpdateEdge(edge, c2d21, c2d2, surf2, loc2, Precision::Confusion()); + } } else { @@ -954,7 +1072,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( try { if (isResEdge) + { SameParameter(edge); + } if (BRep_Tool::SameParameter(edge)) { @@ -1002,7 +1122,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( double deltaT = (last3d - first3d) / (nbp - 1); NCollection_Array1 c3dpnt(1, nbp); for (i = 1; i <= nbp; i++) + { c3dpnt(i) = c3dAdapt.Value(first3d + (i - 1) * deltaT); + } double dist = 0., maxTol = -1.0; bool more = true; @@ -1017,7 +1139,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( { occ::handle aS = surf2; if (!loc2.IsIdentity()) + { aS = occ::down_cast(surf2->Transformed(loc2)); + } double dist2 = 0.; deltaT = (last - first) / (nbp - 1); @@ -1029,7 +1153,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( gp_Pnt aP1 = c3dpnt(i); dist = aP2.SquareDistance(aP1); if (dist > dist2) + { dist2 = dist; + } } maxTol = std::max(sqrt(dist2) * (1. + 1e-7), Precision::Confusion()); } @@ -1053,7 +1179,9 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge( double tolEdge1 = BRep_Tool::Tolerance(edge); if (tolEdge1 > MaxTolerance()) + { edge.Nullify(); + } return edge; } @@ -1084,7 +1212,9 @@ void BRepBuilderAPI_Sewing::EvaluateAngulars(NCollection_Sequence& TopoDS_Shape bnd = edge; if (mySectionBound.IsBound(bnd)) + { bnd = mySectionBound(bnd); + } if (myBoundFaces.Contains(bnd)) { face = TopoDS::Face(myBoundFaces.FindFromKey(bnd).First()); @@ -1097,9 +1227,13 @@ void BRepBuilderAPI_Sewing::EvaluateAngulars(NCollection_Sequence& c2d = BRep_Tool::CurveOnSurface(edge, face, first, last); } else if (i == indRef) + { return; + } else + { continue; + } c3d = BRep_Tool::Curve(edge, loc, first, last); if (!loc.IsIdentity()) @@ -1123,19 +1257,25 @@ void BRepBuilderAPI_Sewing::EvaluateAngulars(NCollection_Sequence& surf->D1(P.X(), P.Y(), unused, w1, w2); gp_Vec n = w1 ^ w2; // Compute the normal vector if (i == indRef) + { normRef(j) = n; + } else if ((n.Magnitude() > gp::Resolution()) && (normRef(j).Magnitude() > gp::Resolution())) { nbComputedAngle++; double angular = n.Angle(normRef(j)); if (angular > M_PI / 2.) + { angular = M_PI - angular; + } cumulateAngular += angular; } } if (nbComputedAngle) + { tabAng(i) = cumulateAngular / ((double)nbComputedAngle); + } } } @@ -1175,7 +1315,9 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(NCollection_Sequence double first, last; occ::handle c3d = BRep_Tool::Curve(sec, loc, first, last); if (c3d.IsNull()) + { continue; + } if (!loc.IsIdentity()) { c3d = occ::down_cast(c3d->Copy()); @@ -1201,11 +1343,17 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(NCollection_Sequence // Uniform parameter on curve if (j == 1) + { T = first; + } else if (j == npt) + { T = last; + } else + { T = first + (j - 1) * deltaT; + } // Take point on curve gp_Pnt pt = c3d->Value(T); @@ -1214,26 +1362,38 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(NCollection_Sequence { ptsRef(j) = pt; if (j > 1) + { aLenSec2 += pt.SquareDistance(ptsRef(j - 1)); + } } else { ptsSec(j) = pt; // protection to avoid merging with small sections if (j > 1) + { aLenSec2 += pt.SquareDistance(ptsSec(j - 1)); + } // To evaluate mutual orientation and distance dist = pt.Distance(ptsRef(j)); if (aMinDist > dist) + { aMinDist = dist; + } if (distFor < dist) + { distFor = dist; + } dist = pt.Distance(ptsRef(npt - j + 1)); if (aMinDist > dist) + { aMinDist = dist; + } if (distRev < dist) + { distRev = dist; + } // Check that point lays between vertices of reference curve const gp_Pnt& p11 = ptsRef(1); @@ -1242,7 +1402,9 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(NCollection_Sequence const gp_Vec aVec2(pt, p12); const gp_Vec aVecRef(p11, p12); if ((aVecRef * aVec1) * (aVecRef * aVec2) < 0.) + { nbFound++; + } } } @@ -1267,17 +1429,27 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(NCollection_Sequence NCollection_Array1 arrProj(1, npt); NCollection_Array1 arrDist(1, npt), arrPara(1, npt); if (arrLen(indRef) >= arrLen(i)) + { ProjectPointsOnCurve(ptsSec, c3dRef, firstRef, lastRef, arrDist, arrPara, arrProj, false); + } else + { ProjectPointsOnCurve(ptsRef, c3d, first, last, arrDist, arrPara, arrProj, false); + } for (j = 1; j <= npt; j++) { if (arrDist(j) < 0.) + { continue; + } if (dist < arrDist(j)) + { dist = arrDist(j); + } if (aMinDist > arrDist(j)) + { aMinDist = arrDist(j); + } nbFound++; } if (nbFound > 1) @@ -1361,7 +1533,9 @@ bool BRepBuilderAPI_Sewing::IsMergedClosed(const TopoDS_Edge& Edge1, bool isUClosed = IsUClosedSurface(surf, Edge1, loc); bool isVClosed = IsVClosedSurface(surf, Edge1, loc); if (!isUClosed && !isVClosed) + { return false; + } // Check condition on closed surface /* double first1,last1,first2,last2; @@ -1373,7 +1547,9 @@ bool BRepBuilderAPI_Sewing::IsMergedClosed(const TopoDS_Edge& Edge1, occ::handle C2d1 = BRep_Tool::CurveOnSurface(Edge1, face, first2d1, last2d1); occ::handle C2d2 = BRep_Tool::CurveOnSurface(Edge2, face, first2d2, last2d2); if (C2d1.IsNull() || C2d2.IsNull()) + { return false; + } /* gp_Pnt p1 = C3d1->Value(0.5*(first1 + last1)); gp_Pnt p2 = C3d1->Value(0.5*(first2 + last2)); @@ -1416,7 +1592,9 @@ bool BRepBuilderAPI_Sewing::IsMergedClosed(const TopoDS_Edge& Edge1, double distInner = std::max((C2Umin - C1Umax), (C1Umin - C2Umax)); double distOuter = (SUmax - SUmin) - std::max((C2Umax - C1Umin), (C1Umax - C2Umin)); if (distOuter <= distInner) + { return true; + } } } if (isVClosed && isULongC1 && isULongC2) @@ -1428,7 +1606,9 @@ bool BRepBuilderAPI_Sewing::IsMergedClosed(const TopoDS_Edge& Edge1, double distInner = std::max((C2Vmin - C1Vmax), (C1Vmin - C2Vmax)); double distOuter = (SVmax - SVmin) - std::max((C2Vmax - C1Vmin), (C1Vmax - C2Vmin)); if (distOuter <= distInner) + { return true; + } } } return false; @@ -1448,15 +1628,23 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( TopoDS_Shape bnd = workedge; NCollection_List workfaces; if (mySectionBound.IsBound(bnd)) + { bnd = mySectionBound(bnd); + } if (myBoundFaces.Contains(bnd)) + { workfaces = myBoundFaces.FindFromKey(bnd); + } if (workfaces.IsEmpty()) + { return; + } NCollection_Map mapFaces; NCollection_List::Iterator lIt; for (lIt.Initialize(workfaces); lIt.More(); lIt.Next()) + { mapFaces.Add(lIt.Value()); + } NCollection_Sequence seqNotCandidate; NCollection_Sequence seqNewForward; // Separates edges belonging the same face as work edge @@ -1477,7 +1665,9 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( { TopoDS_Shape bnd2 = sequenceSec.Value(index); if (mySectionBound.IsBound(bnd2)) + { bnd2 = mySectionBound(bnd2); + } if (myBoundFaces.Contains(bnd2)) { @@ -1511,12 +1701,18 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( } } if (!isRemove) + { i++; + } } if (seqIndCandidate.Length() == 0 || seqNotCandidate.Length() == 1) + { return; + } if (!evalDist) + { return; + } NCollection_Array2 TotTabDist(1, seqNotCandidate.Length(), 1, seqIndCandidate.Length()); NCollection_Map MapIndex; NCollection_Sequence seqForward; @@ -1530,7 +1726,9 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( NCollection_Sequence tmpSeq; tmpSeq.Append(edge); for (int kk = 1; kk <= seqIndCandidate.Length(); kk++) + { tmpSeq.Append(sequenceSec.Value(seqIndCandidate.Value(kk))); + } int lengSec = tmpSeq.Length(); NCollection_Array1 tabForward(1, lengSec); @@ -1538,7 +1736,9 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( NCollection_Array1 arrLen(1, lengSec); NCollection_Array1 tabMinDist(1, lengSec); for (int i1 = 1; i1 <= lengSec; i1++) + { tabDist(i1) = -1; + } EvaluateDistances(tmpSeq, tabForward, tabDist, arrLen, tabMinDist, 1); if (k == 1) @@ -1559,7 +1759,9 @@ void BRepBuilderAPI_Sewing::AnalysisNearestEdges( for (int n = 1; n < lengSec; n++) { if (tabDist(n) == -1 || tabDist(n) > myTolerance) + { continue; + } if (tabDist(n + 1) < TotTabDist(1, n)) { MapIndex.Add(n); @@ -1588,7 +1790,9 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s { int i, nbSections = seqSections.Length(); if (nbSections <= 1) + { return false; + } // Retrieve last reference index int indReference = mapReference(mapReference.Extent()); int nbCandidates = 0; @@ -1602,12 +1806,16 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s { // szv: Use brackets to destroy local variables TopoDS_Shape bnd = Edge1; if (mySectionBound.IsBound(bnd)) + { bnd = mySectionBound(bnd); + } if (myBoundFaces.Contains(bnd)) { NCollection_List::Iterator itf1(myBoundFaces.FindFromKey(bnd)); for (; itf1.More(); itf1.Next()) + { Faces1.Add(itf1.Value()); + } } } @@ -1675,16 +1883,22 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s nbCandidates = seqCandidates.Length(); if (!nbCandidates) + { return false; // Section has no candidates to merge + } // Replace candidate indices for (i = 1; i <= nbCandidates; i++) + { seqCandidates(i) = seqCandidatesNew(seqCandidates(i)); + } } if (!nbCandidates) + { return false; // Section has no candidates to merge + } if (myNonmanifold && nbCandidates > 1) { @@ -1696,7 +1910,9 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s { AnalysisNearestEdges(seqSections, seqCandidates, seqOrientations, (k == 1)); if (k == 1 && !seqCandidates.Length()) + { return false; + } if (seqCandidates.Length()) { seqNewCandidates.Append(seqCandidates.First()); @@ -1794,7 +2010,9 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s int indCandidate = seqCandidates.First(); // Candidate is approved if it is in the map if (mapReference.Contains(indCandidate)) + { break; + } // Find candidates for candidate #indCandidate mapReference.Add(indCandidate); // Push candidate in the map NCollection_Sequence seqCandidates1; @@ -1802,14 +2020,18 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s bool isFound = FindCandidates(seqSections, mapReference, seqCandidates1, seqOrientations1); mapReference.RemoveLast(); // Pop candidate from the map if (isFound) + { isFound = (seqCandidates1.Length() > 0); + } if (isFound) { int indCandidate1 = seqCandidates1.First(); // If indReference is the best candidate for indCandidate // then indCandidate is the best candidate for indReference if (indCandidate1 == indReference) + { break; + } // If some other reference in the map is the best candidate for indCandidate // then assume that reference is the best candidate for indReference if (mapReference.Contains(indCandidate1)) @@ -1836,7 +2058,9 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s TopoDS_Edge Edge2 = TopoDS::Edge(seqSections(anInd)); TopoDS_Shape bnd = Edge2; if (mySectionBound.IsBound(bnd)) + { bnd = mySectionBound(bnd); + } // gka if (myBoundFaces.Contains(bnd)) { @@ -1848,10 +2072,14 @@ bool BRepBuilderAPI_Sewing::FindCandidates(NCollection_Sequence& s // Check whether condition is satisfied isOK = !Faces1.Contains(Face2); if (!isOK) + { isOK = IsMergedClosed(Edge1, Edge2, Face2); + } } if (!isOK) + { return false; + } } } return (nbCandidates > 0); @@ -1889,7 +2117,9 @@ void BRepBuilderAPI_Sewing::Init(const double tolerance, // Set min and max tolerances myMinTolerance = myTolerance * 1e-4; // szv: proposal if (myMinTolerance < Precision::Confusion()) + { myMinTolerance = Precision::Confusion(); + } myMaxTolerance = Precision::Infinite(); // Set other modes myFaceMode = true; @@ -1908,9 +2138,13 @@ void BRepBuilderAPI_Sewing::Load(const TopoDS_Shape& theShape) { myReShape->Clear(); if (theShape.IsNull()) + { myShape.Nullify(); + } else + { myShape = myReShape->Apply(theShape); + } mySewedShape.Nullify(); // Nullify flags and counters myNbShapes = myNbEdges = myNbVertices = 0; @@ -1937,7 +2171,9 @@ void BRepBuilderAPI_Sewing::Load(const TopoDS_Shape& theShape) void BRepBuilderAPI_Sewing::Add(const TopoDS_Shape& aShape) { if (aShape.IsNull()) + { return; + } TopoDS_Shape oShape = myReShape->Apply(aShape); myOldShapes.Add(aShape, oShape); myNbShapes = myOldShapes.Extent(); @@ -1970,7 +2206,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) #endif FaceAnalysis(aPS.Next()); if (!aPS.More()) + { return; + } #ifdef OCCT_DEBUG chr_local.Stop(); chr_local.Show(t_analysis); @@ -1993,7 +2231,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) #endif VerticesAssembling(aPS.Next()); if (!aPS.More()) + { return; + } #ifdef OCCT_DEBUG chr_local.Stop(); chr_local.Show(t_assembling); @@ -2008,7 +2248,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) #endif Cutting(aPS.Next()); if (!aPS.More()) + { return; + } #ifdef OCCT_DEBUG chr_local.Stop(); chr_local.Show(t_cutting); @@ -2022,7 +2264,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) #endif Merging(true, aPS.Next()); if (!aPS.More()) + { return; + } #ifdef OCCT_DEBUG chr_local.Stop(); chr_local.Show(t_merging); @@ -2033,10 +2277,14 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) { aPS.Next(); if (myCutting) + { aPS.Next(); + } aPS.Next(); if (!aPS.More()) + { return; + } } if (mySewing) @@ -2048,7 +2296,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) // examine the multiple edges if any and process sameparameter for edges if necessary EdgeProcessing(aPS.Next()); if (!aPS.More()) + { return; + } CreateSewedShape(); if (!aPS.More()) { @@ -2059,7 +2309,9 @@ void BRepBuilderAPI_Sewing::Perform(const Message_ProgressRange& theProgress) EdgeRegularity(aPS.Next()); if (mySameParameterMode && myFaceMode) + { SameParameterShape(); + } if (!aPS.More()) { mySewedShape.Nullify(); @@ -2216,18 +2468,26 @@ bool BRepBuilderAPI_Sewing::IsDegenerated(const TopoDS_Shape& aShape) const TopoDS_Shape NewShape = myReShape->Apply(aShape); // Degenerated face if (aShape.ShapeType() == TopAbs_FACE) + { return NewShape.IsNull(); + } if (NewShape.IsNull()) + { return false; + } // Degenerated edge if (NewShape.ShapeType() == TopAbs_EDGE) + { return BRep_Tool::Degenerated(TopoDS::Edge(NewShape)); + } // Degenerated wire if (NewShape.ShapeType() == TopAbs_WIRE) { bool isDegenerated = true; for (TopoDS_Iterator aIt(NewShape); aIt.More() && isDegenerated; aIt.Next()) + { isDegenerated = BRep_Tool::Degenerated(TopoDS::Edge(aIt.Value())); + } return isDegenerated; } return false; @@ -2239,9 +2499,13 @@ bool BRepBuilderAPI_Sewing::IsModified(const TopoDS_Shape& aShape) const { TopoDS_Shape NewShape = aShape; if (myOldShapes.Contains(aShape)) + { NewShape = myOldShapes.FindFromKey(aShape); + } if (!NewShape.IsSame(aShape)) + { return true; + } return false; } @@ -2250,7 +2514,9 @@ bool BRepBuilderAPI_Sewing::IsModified(const TopoDS_Shape& aShape) const const TopoDS_Shape& BRepBuilderAPI_Sewing::Modified(const TopoDS_Shape& aShape) const { if (myOldShapes.Contains(aShape)) + { return myOldShapes.FindFromKey(aShape); + } // if (myOldFaces.Contains(aShape)) return myOldFaces.FindFromKey(aShape); return aShape; } @@ -2280,9 +2546,13 @@ void BRepBuilderAPI_Sewing::Dump() const { TopoDS_Shape bound = myBoundFaces.FindKey(i); if (myBoundSections.IsBound(bound)) + { NbSections += myBoundSections(bound).Extent(); + } else + { NbSections++; + } TopExp_Explorer aExp(myReShape->Apply(bound), TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { @@ -2294,23 +2564,23 @@ void BRepBuilderAPI_Sewing::Dump() const mapVertices.Add(V2); } } - std::cout << " " << std::endl; - std::cout << " Information " << std::endl; - std::cout << " ===========================================================" << std::endl; - std::cout << " " << std::endl; - std::cout << " Number of input shapes : " << myOldShapes.Extent() << std::endl; - std::cout << " Number of actual shapes : " << myNbShapes << std::endl; - std::cout << " Number of Bounds : " << NbBounds << std::endl; - std::cout << " Number of Sections : " << NbSections << std::endl; - std::cout << " Number of Edges : " << mapEdges.Extent() << std::endl; - std::cout << " Number of Vertices : " << myNbVertices << std::endl; - std::cout << " Number of Nodes : " << mapVertices.Extent() << std::endl; - std::cout << " Number of Free Edges : " << myFreeEdges.Extent() << std::endl; - std::cout << " Number of Contiguous Edges : " << myContigousEdges.Extent() << std::endl; - std::cout << " Number of Multiple Edges : " << myMultipleEdges.Extent() << std::endl; - std::cout << " Number of Degenerated Edges : " << myDegenerated.Extent() << std::endl; - std::cout << " ===========================================================" << std::endl; - std::cout << " " << std::endl; + std::cout << " " << '\n'; + std::cout << " Information " << '\n'; + std::cout << " ===========================================================" << '\n'; + std::cout << " " << '\n'; + std::cout << " Number of input shapes : " << myOldShapes.Extent() << '\n'; + std::cout << " Number of actual shapes : " << myNbShapes << '\n'; + std::cout << " Number of Bounds : " << NbBounds << '\n'; + std::cout << " Number of Sections : " << NbSections << '\n'; + std::cout << " Number of Edges : " << mapEdges.Extent() << '\n'; + std::cout << " Number of Vertices : " << myNbVertices << '\n'; + std::cout << " Number of Nodes : " << mapVertices.Extent() << '\n'; + std::cout << " Number of Free Edges : " << myFreeEdges.Extent() << '\n'; + std::cout << " Number of Contiguous Edges : " << myContigousEdges.Extent() << '\n'; + std::cout << " Number of Multiple Edges : " << myMultipleEdges.Extent() << '\n'; + std::cout << " Number of Degenerated Edges : " << myDegenerated.Extent() << '\n'; + std::cout << " ===========================================================" << '\n'; + std::cout << " " << '\n'; } //======================================================================= @@ -2360,7 +2630,9 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres // Retrieve current wire aTmpShape = witer.Value(); // for porting if (aTmpShape.ShapeType() != TopAbs_WIRE) + { continue; + } TopoDS_Wire wire = TopoDS::Wire(aTmpShape); // Build replacing wire @@ -2410,7 +2682,9 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres { dist = cp.Distance(c3d->Value(first + idx * delta)); if (maxdist < dist) + { maxdist = dist; + } } isSmall = (2. * maxdist <= MinTolerance()); /*try { @@ -2513,7 +2787,9 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres isWireChanged = true; } else + { B.Add(nwire, edge); // Old edge kept + } } // Record wire in the new face @@ -2523,7 +2799,9 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres isFaceChanged = true; } else + { B.Add(nface, wire); + } } // Remove small face @@ -2568,10 +2846,14 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres { double vtol = BRep_Tool::Tolerance(TopoDS::Vertex(liter2.Value())); if (mtol < vtol) + { mtol = vtol; + } vtol = vp.Distance(BRep_Tool::Pnt(TopoDS::Vertex(liter2.Value()))); if (tol < vtol) + { tol = vtol; + } } B.UpdateVertex(vnew, vp, tol + mtol); } @@ -2579,7 +2861,9 @@ void BRepBuilderAPI_Sewing::FaceAnalysis(const Message_ProgressRange& theProgres // Update input shapes for (i = 1; i <= myOldShapes.Extent(); i++) + { myOldShapes(i) = myReShape->Apply(myOldShapes(i)); + } } //======================================================================= @@ -2606,7 +2890,9 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() { TopoDS_Shape newShape = myReShape->Apply(myShape); if (!newShape.IsNull()) + { NewShapes.Add(newShape); + } } } // Create map Edge -> Faces @@ -2618,7 +2904,9 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() // Retrieve new shape const TopoDS_Shape& shape = myOldShapes(i); if (shape.IsNull()) + { continue; + } NewShapes.Add(shape); // Explore shape to find all boundaries for (TopExp_Explorer eExp(shape, TopAbs_EDGE); eExp.More(); eExp.Next()) @@ -2642,14 +2930,20 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() { const TopoDS_Shape& face = fExp.Current(); if (mapFaces.Contains(face)) + { continue; + } else + { mapFaces.Add(face); + } // Explore face to find all boundaries for (TopoDS_Iterator aIw(face); aIw.More(); aIw.Next()) { if (aIw.Value().ShapeType() != TopAbs_WIRE) + { continue; + } for (TopoDS_Iterator aIIe(aIw.Value()); aIIe.More(); aIIe.Next()) { @@ -2679,7 +2973,9 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() int nbFaces = listFaces.Extent(); TopoDS_Shape edge = anIterEF.Key(); if (edge.Orientation() == TopAbs_INTERNAL) + { continue; + } bool isSeam = false; if (nbFaces == 1) { @@ -2694,7 +2990,9 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() TopoDS_Shape anewEdge = edge.EmptyCopied(); TopoDS_Iterator aItV(edge); for (; aItV.More(); aItV.Next()) + { aB.Add(anewEdge, aItV.Value()); + } double first2d, last2d; occ::handle c2dold = @@ -2725,7 +3023,9 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() { // Ignore degenerated edge if (BRep_Tool::Degenerated(TopoDS::Edge(edge))) + { continue; + } // Ignore edge with internal vertices // int nbVtx = 0; // for (TopExp_Explorer vExp(edge,TopAbs_VERTEX); vExp.More(); vExp.Next()) nbVtx++; @@ -2738,24 +3038,36 @@ void BRepBuilderAPI_Sewing::FindFreeBoundaries() TopoDS_Vertex vFirst, vLast; TopExp::Vertices(TopoDS::Edge(edge), vFirst, vLast); if (vFirst.IsNull() || vLast.IsNull()) + { continue; + } if (vFirst.Orientation() == TopAbs_INTERNAL || vLast.Orientation() == TopAbs_INTERNAL) + { continue; + } if (isBound) { // Add to VertexNode if (!myVertexNode.Contains(vFirst)) + { myVertexNode.Add(vFirst, vFirst); + } if (!myVertexNode.Contains(vLast)) + { myVertexNode.Add(vLast, vLast); + } } else { // Add to VertexNodeFree if (!myVertexNodeFree.Contains(vFirst)) + { myVertexNodeFree.Add(vFirst, vFirst); + } if (!myVertexNodeFree.Contains(vLast)) + { myVertexNodeFree.Add(vLast, vLast); + } } } } @@ -2794,7 +3106,9 @@ static bool CreateNewNodes( const TopoDS_Shape& oldnode2 = anIter.Value(); // Second node should also be in the map if (!NodeNearestNode.Contains(oldnode2)) + { continue; + } // Get new node for old node #1 if (OldNodeNewNode.IsBound(oldnode1)) { @@ -2849,7 +3163,9 @@ static bool CreateNewNodes( // Stop if no new nodes created if (!NewNodeOldNodes.Extent()) + { return false; + } NCollection_IndexedDataMap, @@ -2904,7 +3220,9 @@ static bool CreateNewNodes( const TopoDS_Vertex& vertex = TopoDS::Vertex(itv.Value()); double t = center.Distance(BRep_Tool::Pnt(vertex)) + BRep_Tool::Tolerance(vertex); if (toler < t) + { toler = t; + } } // Update new node parameters B.UpdateVertex(newnode, center, toler); @@ -2921,7 +3239,9 @@ static int IsMergedVertices(const TopoDS_Shape& face1, { // Case of floating edges if (face1.IsNull()) + { return (!IsClosedShape(e1, vtx1, vtx2)); + } // Find wires containing given edges TopoDS_Shape wire1, wire2; @@ -2932,9 +3252,13 @@ static int IsMergedVertices(const TopoDS_Shape& face1, for (; ite.More() && (wire1.IsNull() || wire2.IsNull()); ite.Next()) { if (wire1.IsNull() && e1.IsSame(ite.Value())) + { wire1 = itw.Current(); + } if (wire2.IsNull() && e2.IsSame(ite.Value())) + { wire2 = itw.Current(); + } } } int Status = 0; @@ -2947,7 +3271,9 @@ static int IsMergedVertices(const TopoDS_Shape& face1, TopoDS_Vertex ve1, ve2; TopExp::Vertices(TopoDS::Edge(aIte.Value()), ve1, ve2); if ((ve1.IsSame(vtx1) && ve2.IsSame(vtx2)) || (ve2.IsSame(vtx1) && ve1.IsSame(vtx2))) + { return (IsClosedShape(aIte.Value(), vtx1, vtx2) ? 0 : 1); + } } if (IsClosedShape(wire1, vtx1, vtx2)) { @@ -2956,13 +3282,19 @@ static int IsMergedVertices(const TopoDS_Shape& face1, bool isEndVertex = ((V1.IsSame(vtx1) && V2.IsSame(vtx2)) || (V2.IsSame(vtx1) && V1.IsSame(vtx2))); if (!isEndVertex) + { Status = 1; + } } else + { Status = 1; + } } else + { Status = -1; + } } return Status; } @@ -3015,11 +3347,13 @@ static bool GlueVertices( // Find near nodes gp_Pnt pt1 = BRep_Tool::Pnt(node1); anInspector.SetCurrent(pt1.XYZ()); - gp_XYZ aPntMin = anInspector.Shift(pt1.XYZ(), -Tolerance); - gp_XYZ aPntMax = anInspector.Shift(pt1.XYZ(), Tolerance); + gp_XYZ aPntMin = BRepBuilderAPI_VertexInspector::Shift(pt1.XYZ(), -Tolerance); + gp_XYZ aPntMax = BRepBuilderAPI_VertexInspector::Shift(pt1.XYZ(), Tolerance); aFilter.Inspect(aPntMin, aPntMax, anInspector); if (anInspector.ResInd().IsEmpty()) + { continue; + } // Retrieve list of edges for the first node const NCollection_List& ledges1 = aNodeEdges(node1); // Explore list of near nodes and fill the sequence of glued nodes @@ -3031,7 +3365,9 @@ static bool GlueVertices( { const TopoDS_Vertex& node2 = TopoDS::Vertex(NodeVertices.FindKey(iter1.Value())); if (node1 == node2) + { continue; + } // Retrieve list of edges for the second node const NCollection_List& ledges2 = aNodeEdges(node2); // Check merging condition for the pair of nodes @@ -3049,12 +3385,16 @@ static bool GlueVertices( if (aVertexNode.Contains(ov1)) { if (node1.IsSame(aVertexNode.FindFromKey(ov1))) + { v1 = ov1; + } } if (aVertexNode.Contains(ov2)) { if (node1.IsSame(aVertexNode.FindFromKey(ov2))) + { v1 = ov2; + } } } // Create map of faces for e1 @@ -3064,8 +3404,12 @@ static bool GlueVertices( { NCollection_List::Iterator itf(lfac1); for (; itf.More(); itf.Next()) + { if (!itf.Value().IsNull()) + { Faces1.Add(itf.Value()); + } + } } // Explore edges of the second node NCollection_List::Iterator Ie2(ledges2); @@ -3080,12 +3424,16 @@ static bool GlueVertices( if (aVertexNode.Contains(ov1)) { if (node2.IsSame(aVertexNode.FindFromKey(ov1))) + { v2 = ov1; + } } if (aVertexNode.Contains(ov2)) { if (node2.IsSame(aVertexNode.FindFromKey(ov2))) + { v2 = ov2; + } } } // Explore faces for e2 @@ -3100,9 +3448,13 @@ static bool GlueVertices( { int stat = IsMergedVertices(itf.Value(), e1, e2, v1, v2); if (stat == 1) + { isSameEdge = true; + } else + { Status = stat; + } } } } @@ -3110,17 +3462,25 @@ static bool GlueVertices( { int stat = IsMergedVertices(TopoDS_Face(), e1, e1, v1, v2); if (stat == 1) + { isSameEdge = true; + } else + { Status = stat; + } break; } } } if (Status) + { continue; + } if (isSameEdge) + { listNodesSameEdge.Append(node2); + } // Append near node to the sequence gp_Pnt pt2 = BRep_Tool::Pnt(node2); double dist = pt1.Distance(pt2); @@ -3137,7 +3497,9 @@ static bool GlueVertices( } } if (!isIns) + { SeqNodes.Append(node2); + } } } if (SeqNodes.Length()) @@ -3168,14 +3530,18 @@ static bool GlueVertices( } // Bind nearest node if at least one exists if (SeqNodes.Length()) + { NodeNearestNode.Add(node1, SeqNodes.First()); + } } anInspector.ClearResList(); } // Create new nodes for chained nearest nodes if (NodeNearestNode.IsEmpty()) + { return false; + } return CreateNewNodes(NodeNearestNode, NodeVertices, aVertexNode, aNodeEdges); } @@ -3196,7 +3562,9 @@ void BRepBuilderAPI_Sewing::VerticesAssembling(const Message_ProgressRange& theP { const TopoDS_Shape& node = itv.Value(); if (myNodeSections.IsBound(node)) + { myNodeSections(node).Append(bound); + } else { NCollection_List lbnd; @@ -3212,17 +3580,23 @@ void BRepBuilderAPI_Sewing::VerticesAssembling(const Message_ProgressRange& theP std::cout << "Assemble " << nbVert << " vertices on faces..." << std::endl; #endif while (GlueVertices(myVertexNode, myNodeSections, myBoundFaces, myTolerance, aPS.Next())) + { ; + } } if (!aPS.More()) + { return; + } if (nbVertFree) { #ifdef OCCT_DEBUG std::cout << "Assemble " << nbVertFree << " vertices on floating edges..." << std::endl; #endif while (GlueVertices(myVertexNodeFree, myNodeSections, myBoundFaces, myTolerance, aPS.Next())) + { ; + } } } } @@ -3241,13 +3615,17 @@ static void replaceNMVertices(const TopoDS_Edge& theEdge, NCollection_Sequence aSeqNMPars; bool hasNMVert = findNMVertices(theEdge, aSeqNMVert, aSeqNMPars); if (!hasNMVert) + { return; + } double first, last; BRep_Tool::Range(theEdge, first, last); TopLoc_Location aLoc; occ::handle c3d = BRep_Tool::Curve(theEdge, aLoc, first, last); if (c3d.IsNull()) + { return; + } NCollection_Sequence aEdVert; NCollection_Sequence aEdParams; int i = 1, nb = aSeqNMPars.Length(); @@ -3313,7 +3691,9 @@ static void replaceNMVertices(const TopoDS_Edge& theEdge, aB.Add(anewEdge, theV2); for (i = 1; i <= aEdVert.Length(); i++) + { aB.Add(anewEdge, aEdVert.Value(i)); + } anewEdge.Orientation(anOri); theReShape->Replace(theEdge, anewEdge); } @@ -3331,7 +3711,9 @@ static void ReplaceEdge(const TopoDS_Shape& oldEdge, TopoDS_Shape oldShape = aReShape->Apply(oldEdge); TopoDS_Shape newShape = aReShape->Apply(theNewShape); if (oldShape.IsSame(newShape) || aReShape->IsRecorded(newShape)) + { return; + } aReShape->Replace(oldShape, newShape); TopoDS_Vertex V1old, V2old, V1new, V2new; @@ -3355,7 +3737,9 @@ static void ReplaceEdge(const TopoDS_Shape& oldEdge, TopExp::Vertices(ed, aV1, aV2); replaceNMVertices(ed, aV1, aV2, aReShape); if (V1new.IsNull()) + { V1new = aV1; + } V2new = aV2; } } @@ -3372,18 +3756,26 @@ static void ReplaceEdge(const TopoDS_Shape& oldEdge, V1new.Orientation(V1old.Orientation()); V2new.Orientation(V2old.Orientation()); if (!V1old.IsSame(V1new) && !V1old.IsSame(V2new) && !aReShape->IsRecorded(V1new)) + { aReShape->Replace(V1old, V1new); + } if (!V2old.IsSame(V2new) && !V2old.IsSame(V1new) && !aReShape->IsRecorded(V2new)) + { aReShape->Replace(V2old, V2new); + } } else { V1new.Orientation(V2old.Orientation()); V2new.Orientation(V1old.Orientation()); if (!V1old.IsSame(V2new) && !V1old.IsSame(V1new) && !aReShape->IsRecorded(V2new)) + { aReShape->Replace(V1old, V2new); + } if (!V2old.IsSame(V2new) && !V2old.IsSame(V1new) && !aReShape->IsRecorded(V1new)) + { aReShape->Replace(V2old, V1new); + } } } @@ -3410,7 +3802,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, // If bound was already merged - continue if (myMergedEdges.Contains(bound)) + { continue; + } if (!anIterB.Value().Extent()) { @@ -3419,9 +3813,13 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, TopExp::Vertices(TopoDS::Edge(bound), no1, no2); TopoDS_Shape nno1 = no1, nno2 = no2; if (myVertexNodeFree.Contains(no1)) + { nno1 = myVertexNodeFree.FindFromKey(no1); + } if (myVertexNodeFree.Contains(no2)) + { nno2 = myVertexNodeFree.FindFromKey(no2); + } if (!no1.IsSame(nno1)) { nno1.Orientation(no1.Orientation()); @@ -3451,7 +3849,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, TopoDS_Shape section = its.Value(); B.Add(BoundWire, section); if (myMergedEdges.Contains(section)) + { isPrevSplit = true; + } } } @@ -3523,7 +3923,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, myReShape); bool isForward = false; if (!MergedEdge.IsNull()) + { isForward = (MergedEdge.Orientation() == TopAbs_FORWARD); + } // Process actually merged edges int nbActuallyMerged = 0; for (ii = 1; ii <= nbMerged; ii++) @@ -3535,27 +3937,37 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, // Record merged edge in the map TopAbs_Orientation orient = iedge.Orientation(); if (!isForward) + { orient = TopAbs::Reverse(orient); + } if (!seqMergedWithBoundOri(ii)) + { orient = TopAbs::Reverse(orient); + } MergedWithBound.ChangeFromKey(iedge) = MergedEdge.Oriented(orient); } else + { MergedWithBound.RemoveKey(iedge); + } } if (nbActuallyMerged) { // Record merged bound in the map TopAbs_Orientation orient = bound.Orientation(); if (!isForward) + { orient = TopAbs::Reverse(orient); + } MergedWithBound.ChangeFromKey(bound) = MergedEdge.Oriented(orient); } nbMerged = nbActuallyMerged; } // Remove bound from the map if not finally merged if (!nbMerged) + { MergedWithBound.RemoveKey(bound); + } } } const bool isMerged = !MergedWithBound.IsEmpty(); @@ -3574,7 +3986,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, TopoDS_Shape section = its.Value(); // Skip section if already merged if (myMergedEdges.Contains(section)) + { continue; + } // Merge cutting section NCollection_Sequence seqMergedWithSection; NCollection_Sequence seqMergedWithSectionOri; @@ -3639,7 +4053,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, SectionsReShape); bool isForward = false; if (!MergedEdge.IsNull()) + { isForward = (MergedEdge.Orientation() == TopAbs_FORWARD); + } // Process actually merged edges int nbActuallyMerged = 0; for (ii = 1; ii <= nbMerged; ii++) @@ -3651,22 +4067,30 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, // Record merged edge in the map TopAbs_Orientation orient = iedge.Orientation(); if (!isForward) + { orient = TopAbs::Reverse(orient); + } if (!seqMergedWithSectionOri(ii)) + { orient = TopAbs::Reverse(orient); + } const TopoDS_Shape& oedge = MergedEdge.Oriented(orient); MergedWithSections.ChangeFromKey(iedge) = oedge; ReplaceEdge(myReShape->Apply(iedge), oedge, SectionsReShape); } else + { MergedWithSections.RemoveKey(iedge); + } } if (nbActuallyMerged) { // Record merged section in the map TopAbs_Orientation orient = section.Orientation(); if (!isForward) + { orient = TopAbs::Reverse(orient); + } const TopoDS_Shape& oedge = MergedEdge.Oriented(orient); MergedWithSections.ChangeFromKey(section) = oedge; ReplaceEdge(myReShape->Apply(section), oedge, SectionsReShape); @@ -3675,7 +4099,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, } // Remove section from the map if not finally merged if (!nbMerged) + { MergedWithSections.RemoveKey(section); + } } else if (isMerged) { @@ -3725,7 +4151,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, const TopoDS_Shape& edge = anItm1.Key(); // Remove edge from the map if (MapSplitEdges.Contains(edge)) + { MapSplitEdges.RemoveKey(edge); + } if (myBoundSections.IsBound(edge)) { // Edge has cutting sections @@ -3735,7 +4163,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, const TopoDS_Shape& sec = its.Value(); // Remove section from the map if (MapSplitEdges.Contains(sec)) + { MapSplitEdges.RemoveKey(sec); + } } } } @@ -3768,7 +4198,9 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, ReplaceEdge(myReShape->Apply(oldedge), newedge, myReShape); myMergedEdges.Add(oldedge); if (myBoundSections.IsBound(oldedge)) + { myBoundSections.UnBind(oldedge); + } } } else @@ -3784,12 +4216,18 @@ void BRepBuilderAPI_Sewing::Merging(const bool /* firstTime */, ReplaceEdge(myReShape->Apply(oldedge), newedge, myReShape); myMergedEdges.Add(oldedge); if (myBoundSections.IsBound(oldedge)) + { myBoundSections.UnBind(oldedge); + } } if (myBoundSections.IsBound(bound)) + { myBoundSections.UnBind(bound); + } if (!myMergedEdges.Contains(bound)) + { myMergedEdges.Add(bound); + } } } @@ -3813,9 +4251,13 @@ bool BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& bool isNode1 = myVertexNode.Contains(no1); bool isNode2 = myVertexNode.Contains(no2); if (isNode1) + { nno1 = myVertexNode.FindFromKey(no1); + } if (isNode2) + { nno2 = myVertexNode.FindFromKey(no2); + } // Fill map of nodes connected to the node #1 NCollection_IndexedMap mapVert1; @@ -3870,23 +4312,32 @@ bool BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& { const TopoDS_Shape& node1 = mapVert1.FindKey(i); if (!myNodeSections.IsBound(node1)) + { continue; + } NCollection_List::Iterator ilsec(myNodeSections(node1)); for (; ilsec.More(); ilsec.Next()) { TopoDS_Shape sec = ilsec.Value(); if (sec.IsSame(edge)) + { continue; + } // Retrieve section nodes TopoDS_Vertex vs1, vs2; TopExp::Vertices(TopoDS::Edge(sec), vs1, vs2); TopoDS_Shape vs1n = vs1, vs2n = vs2; if (myVertexNode.Contains(vs1)) + { vs1n = myVertexNode.FindFromKey(vs1); + } if (myVertexNode.Contains(vs2)) + { vs2n = myVertexNode.FindFromKey(vs2); + } if ((mapVert1.Contains(vs1n) && mapVert2.Contains(vs2n)) || (mapVert1.Contains(vs2n) && mapVert2.Contains(vs1n))) + { if (mapEdges.Add(sec)) { // Check for rejected cutting @@ -3899,7 +4350,9 @@ bool BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& TopoDS_Shape section = its.Value(); if (myMergedEdges.Contains(section)) + { isRejected = true; + } } } if (!isRejected && mySectionBound.IsBound(sec)) @@ -3909,8 +4362,11 @@ bool BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& } if (!isRejected) + { seqEdges.Append(sec); + } } + } } } @@ -3963,7 +4419,9 @@ bool BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& SeqMergedEdge.Append(iedge); SeqMergedOri.Append(ori); if (!myNonmanifold) + { break; + } } success = (nbCandidates != 0); } @@ -3984,7 +4442,9 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) { int i, nbVertices = myVertexNode.Extent(); if (!nbVertices) + { return; + } // Create a box tree with vertices double eps = myTolerance * 0.5; NCollection_UBTree aTree; @@ -4014,11 +4474,15 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) const TopoDS_Edge& bound = TopoDS::Edge(anIterB.Key()); // Do not cut floating edges if (!anIterB.Value().Extent()) + { continue; + } // Obtain bound curve c3d = BRep_Tool::Curve(bound, loc, first, last); if (c3d.IsNull()) + { continue; + } if (!loc.IsIdentity()) { c3d = occ::down_cast(c3d->Copy()); @@ -4040,7 +4504,9 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) aTree.Select(aSelector); // Skip bound if no node is in the boundind box if (!aSelector.ResInd().Extent()) + { continue; + } // Retrieve bound nodes TopExp::Vertices(bound, V1, V2); const TopoDS_Shape& Node1 = myVertexNode.FindFromKey(V1); @@ -4061,12 +4527,16 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) } int nbCandidates = CandidateVertices.Extent(); if (!nbCandidates) + { continue; + } // Project vertices on curve NCollection_Array1 arrPara(1, nbCandidates), arrDist(1, nbCandidates); NCollection_Array1 arrPnt(1, nbCandidates), arrProj(1, nbCandidates); for (int j = 1; j <= nbCandidates; j++) + { arrPnt(j) = BRep_Tool::Pnt(TopoDS::Vertex(CandidateVertices(j))); + } ProjectPointsOnCurve(arrPnt, c3d, first, last, arrDist, arrPara, arrProj, true); // Create cutting nodes NCollection_Sequence seqNode; @@ -4081,7 +4551,9 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) seqNode, seqPara); if (!seqPara.Length()) + { continue; + } // Create cutting sections CreateSections(bound, seqNode, seqPara, listSections); } @@ -4099,10 +4571,14 @@ void BRepBuilderAPI_Sewing::Cutting(const Message_ProgressRange& theProgress) TopoDS_Shape vertex = itv.Value(); // Convert vertex to node if (myVertexNode.Contains(vertex)) + { vertex = TopoDS::Vertex(myVertexNode.FindFromKey(vertex)); + } // Update node sections if (myNodeSections.IsBound(vertex)) + { myNodeSections.ChangeFind(vertex).Append(section); + } else { NCollection_List lsec; @@ -4143,21 +4619,29 @@ static void GetSeqEdges( { const TopoDS_Shape& edge1 = lIt.Value(); if (edge1.IsSame(edge)) + { continue; + } bool isContained = false; int i, index = 1; for (i = 1; i <= seqEdges.Length() && !isContained; i++) { isContained = seqEdges.Value(i).IsSame(edge1); if (!isContained && seqEdges.Value(i).IsSame(edge)) + { index = i; + } } if (!isContained) { if (numV == 1) + { seqEdges.InsertBefore(index, edge1); + } else + { seqEdges.InsertAfter(index, edge1); + } GetSeqEdges(edge1, seqEdges, VertEdge); } } @@ -4182,7 +4666,9 @@ void BRepBuilderAPI_Sewing::GetFreeWires( { const TopoDS_Vertex& V1 = TopoDS::Vertex(Iv.Value()); if (VertEdge.IsBound(V1)) + { VertEdge.ChangeFind(V1).Append(edge); + } else { NCollection_List ls; @@ -4198,7 +4684,9 @@ void BRepBuilderAPI_Sewing::GetFreeWires( NCollection_Sequence seqEdges; const TopoDS_Shape& edge = seqFreeEdges.Value(i); if (!MapFreeEdges.Contains(edge)) + { continue; + } seqEdges.Append(edge); GetSeqEdges(edge, seqEdges, VertEdge); TopoDS_Wire wire; @@ -4210,7 +4698,9 @@ void BRepBuilderAPI_Sewing::GetFreeWires( } seqWires.Append(wire); if (MapFreeEdges.IsEmpty()) + { break; + } } } @@ -4219,7 +4709,9 @@ void BRepBuilderAPI_Sewing::GetFreeWires( static bool IsDegeneratedWire(const TopoDS_Shape& wire) { if (wire.ShapeType() != TopAbs_WIRE) + { return false; + } // Get maximal vertices tolerance TopoDS_Vertex V1, V2; // TopExp::Vertices(TopoDS::Wire(wire),V1,V2); @@ -4243,13 +4735,21 @@ static bool IsDegeneratedWire(const TopoDS_Shape& wire) else { if (Ve1.IsSame(V1)) + { V1 = Ve2; + } else if (Ve1.IsSame(V2)) + { V2 = Ve2; + } if (Ve2.IsSame(V1)) + { V1 = Ve1; + } else if (Ve2.IsSame(V2)) + { V2 = Ve1; + } } occ::handle c3d = BRep_Tool::Curve(TopoDS::Edge(aIt.Value()), loc, first, last); if (!c3d.IsNull()) @@ -4275,12 +4775,16 @@ static bool IsDegeneratedWire(const TopoDS_Shape& wire) } double tole = BRep_Tool::Tolerance(Ve1) + BRep_Tool::Tolerance(Ve2); if (length <= tole) + { isSmall++; + } wireLength += length; } } if (isSmall == nume) + { return true; + } // clang-format off double tol = BRep_Tool::Tolerance(V1)+BRep_Tool::Tolerance(V2);//Max(BRep_Tool::Tolerance(V1),BRep_Tool::Tolerance(V2)); // clang-format on @@ -4297,7 +4801,9 @@ static TopoDS_Edge DegeneratedSection(const TopoDS_Shape& section, const TopoDS_ { // Return if section is already degenerated if (BRep_Tool::Degenerated(TopoDS::Edge(section))) + { return TopoDS::Edge(section); + } // Retrieve edge curve TopLoc_Location loc; @@ -4351,9 +4857,13 @@ static TopoDS_Edge DegeneratedSection(const TopoDS_Shape& section, const TopoDS_ { TopoDS_Vertex newVertex; if (p1.Distance(p3) < BRep_Tool::Tolerance(v1)) + { newVertex = v1; + } else if (p1.Distance(p3) < BRep_Tool::Tolerance(v2)) + { newVertex = v2; + } else { double d1 = BRep_Tool::Tolerance(v1) + p2.Distance(p1); @@ -4379,7 +4889,9 @@ static TopoDS_Edge DegeneratedSection(const TopoDS_Shape& section, const TopoDS_ aBuilder.UpdateEdge(edge, aC3dNew, 0); occ::handle aC2dn = BRep_Tool::CurveOnSurface(edge, TopoDS::Face(face), af, al); if (aC2dn.IsNull()) + { aBuilder.UpdateEdge(edge, aC2dt, TopoDS::Face(face), 0); + } } return edge; @@ -4453,21 +4965,31 @@ void BRepBuilderAPI_Sewing::EdgeProcessing(const Message_ProgressRange& theProgr { const TopoDS_Wire& wire = TopoDS::Wire(seqWires.Value(j)); if (!IsDegeneratedWire(wire)) + { continue; + } for (TopoDS_Iterator Ie(wire, false); Ie.More(); Ie.Next()) { TopoDS_Shape aTmpShape = myReShape->Apply(Ie.Value()); // for porting const TopoDS_Edge& edge = TopoDS::Edge(aTmpShape); TopoDS_Shape face; if (EdgeFace.IsBound(edge)) + { face = EdgeFace.Find(edge); + } TopoDS_Shape degedge = DegeneratedSection(edge, face); if (degedge.IsNull()) + { continue; + } if (!degedge.IsSame(edge)) + { ReplaceEdge(edge, degedge, myReShape); + } if (BRep_Tool::Degenerated(TopoDS::Edge(degedge))) + { myDegenerated.Add(degedge); + } } } } @@ -4493,9 +5015,11 @@ void BRepBuilderAPI_Sewing::EdgeRegularity(const Message_ProgressRange& theProgr const NCollection_List* aFaces = aMapEF.Seek(anEdge); // encode regularity if and only if edges is shared by two faces if (aFaces && aFaces->Extent() == 2) + { BRepLib::EncodeRegularity(anEdge, TopoDS::Face(aFaces->First()), TopoDS::Face(aFaces->Last())); + } } myMergedEdges.Clear(); @@ -4526,7 +5050,9 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() sh = myReShape->Apply(sh); anIter.ChangeValue() = sh; if (!isLocal) + { aQuilt.Add(sh); + } } } TopoDS_Shape aNewShape = aQuilt.Shells(); @@ -4544,7 +5070,9 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() if (sh.ShapeType() == TopAbs_SHELL) { if (myNonmanifold) + { hasEdges = !OldShells.Contains(sh); + } else { TopoDS_Shape face; @@ -4555,11 +5083,17 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() numf++; } if (numf == 1) + { aB.Add(aComp, face); + } else if (numf > 1) + { aB.Add(aComp, sh); + } if (numf) + { numsh++; + } } } else if (sh.ShapeType() == TopAbs_FACE) @@ -4584,7 +5118,9 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() numsh++; } if (hasEdges) + { OldShells.Add(sh); + } } // Process collected shells if (myNonmanifold) @@ -4602,11 +5138,17 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() numf++; } if (numf == 1) + { aB.Add(aComp, face); + } else if (numf > 1) + { aB.Add(aComp, sh); + } if (numf) + { numsh++; + } } else if (nbOldShells) { @@ -4619,14 +5161,18 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() for (int i = 1; i <= nbOldShells; i++) { if (IndexMerged.Contains(i)) + { continue; + } const TopoDS_Shell& shell = TopoDS::Shell(OldShells.FindKey(i)); if (NewShell.IsNull()) { aB.MakeShell(NewShell); TopoDS_Iterator aItSS(shell); for (; aItSS.More(); aItSS.Next()) + { aB.Add(NewShell, aItSS.Value()); + } // Fill map of edges for (TopExp_Explorer eexp(shell, TopAbs_EDGE); eexp.More(); eexp.Next()) { @@ -4640,7 +5186,9 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() bool hasSharedEdge = false; TopExp_Explorer eexp(shell, TopAbs_EDGE); for (; eexp.More() && !hasSharedEdge; eexp.Next()) + { hasSharedEdge = NewEdges.Contains(eexp.Current()); + } if (hasSharedEdge) { // Add edges to the map @@ -4669,11 +5217,17 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() numf++; } if (numf == 1) + { aB.Add(aComp, face); + } else if (numf > 1) + { aB.Add(aComp, NewShell); + } if (numf) + { numsh++; + } } } } @@ -4684,7 +5238,9 @@ void BRepBuilderAPI_Sewing::CreateSewedShape() mySewedShape = aIt.Value(); } else + { mySewedShape = aComp; + } } //======================================================================= @@ -4712,7 +5268,9 @@ void BRepBuilderAPI_Sewing::CreateOutputInformations() const TopoDS_Shape& bound = myBoundFaces.FindKey(i); NCollection_List lsect; if (myBoundSections.IsBound(bound)) + { lsect = myBoundSections(bound); + } TopExp_Explorer aExp(myReShape->Apply(bound), TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { @@ -4729,7 +5287,9 @@ void BRepBuilderAPI_Sewing::CreateOutputInformations() } } if (edgeSections.Contains(edge)) + { edgeSections.ChangeFromKey(edge).Append(sec); + } else { NCollection_List listSec; @@ -4750,9 +5310,13 @@ void BRepBuilderAPI_Sewing::CreateOutputInformations() if (listSection.Extent() == 1) { if (BRep_Tool::Degenerated(TopoDS::Edge(edge))) + { myDegenerated.Add(edge); + } else + { myFreeEdges.Add(edge); + } } else if (listSection.Extent() == 2) { @@ -4777,14 +5341,22 @@ void BRepBuilderAPI_Sewing::CreateOutputInformations() { const TopoDS_Shape& section = iter.Value(); if (!myMergedEdges.Contains(section)) + { continue; + } // if (!myReShape->IsRecorded(section)) continue; // section is free TopoDS_Shape nedge = myReShape->Apply(section); if (nedge.IsNull()) + { continue; // szv debug + } if (!bound.IsSame(section)) + { if (myContigousEdges.Contains(nedge)) + { myContigSecBound.Bind(section, bound); + } + } } } } @@ -4926,7 +5498,9 @@ void BRepBuilderAPI_Sewing::CreateCuttingNodes( { double distProj = arrDist(i); if (distProj < 0.0) + { continue; // Skip vertex if not projected + } bool isInserted = false; for (j = 1; j <= seqOrderedIndex.Length() && !isInserted; j++) { @@ -4946,7 +5520,9 @@ void BRepBuilderAPI_Sewing::CreateCuttingNodes( } nbProj = seqOrderedIndex.Length(); if (!nbProj) + { return; + } BRep_Builder aBuilder; @@ -4985,7 +5561,9 @@ void BRepBuilderAPI_Sewing::CreateCuttingNodes( // Skip node if already bound to cutting vertex TopoDS_Shape node = myVertexNode.FindFromKey(MapVert(index)); if (NodeCuttingVertex.Contains(node)) + { continue; + } // Find the closest vertex int indexMin = 1; @@ -5049,7 +5627,9 @@ void BRepBuilderAPI_Sewing::CreateCuttingNodes( TopoDS_Shape cnode = aMIt.Value(); // Skip secondary nodes if (cnode.IsNull()) + { continue; + } // Obtain vertex node const TopoDS_Shape& node = aMIt.Key(); if (myVertexNode.Contains(cnode)) @@ -5164,7 +5744,9 @@ void BRepBuilderAPI_Sewing::CreateSections(const TopoDS_Shape& const NCollection_List& listFaces = myBoundFaces.FindFromKey(sec); if (!listFaces.Extent()) + { return; + } double tolEdge = BRep_Tool::Tolerance(sec); @@ -5179,7 +5761,9 @@ void BRepBuilderAPI_Sewing::CreateSections(const TopoDS_Shape& double first2d = 0., last2d = 0., first2d1 = 0, last2d1 = 0.; occ::handle c2d = BRep_Tool::CurveOnSurface(sec, fac, first2d, last2d); if (c2d.IsNull()) + { continue; + } occ::handle c2d1; bool isSeam = BRep_Tool::IsClosed(sec, fac); @@ -5211,7 +5795,9 @@ void BRepBuilderAPI_Sewing::CreateSections(const TopoDS_Shape& c2d1 = BRep_Tool::CurveOnSurface(secRev, fac, first2d1, last2d1); if (c2d1.IsNull()) + { continue; + } /*if (c2d1->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { c2dBSP1 = occ::down_cast(c2d1); @@ -5267,17 +5853,25 @@ void BRepBuilderAPI_Sewing::CreateSections(const TopoDS_Shape& }*/ if (!isSeam && c2d1New.IsNull()) + { aBuilder.UpdateEdge(edge, c2dNew, fac, tolEdge); + } else { TopAbs_Orientation Ori = edge.Orientation(); if (fac.Orientation() == TopAbs_REVERSED) + { Ori = TopAbs::Reverse(Ori); + } if (Ori == TopAbs_FORWARD) + { aBuilder.UpdateEdge(edge, c2dNew, c2d1New, fac, tolEdge); + } else + { aBuilder.UpdateEdge(edge, c2d1New, c2dNew, fac, tolEdge); + } } } } @@ -5288,7 +5882,9 @@ void BRepBuilderAPI_Sewing::CreateSections(const TopoDS_Shape& void BRepBuilderAPI_Sewing::SameParameterShape() { if (!mySameParameterMode) + { return; + } TopExp_Explorer exp(mySewedShape, TopAbs_EDGE); // Le flag sameparameter est a false pour chaque edge cousue for (; exp.More(); exp.Next()) @@ -5329,7 +5925,9 @@ NCollection_CellFilter_Action BRepBuilderAPI_VertexInspector::Inspect(const int aDz = myCurrent.Z() - aPnt.Z(); if ((aDx * aDx <= myTol) && (aDy * aDy <= myTol) && (aDz * aDz <= myTol)) + { myResInd.Append(theTarget); + } return CellFilter_Keep; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Analyzer.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Analyzer.cxx index 6eda8150dc..c9e3115754 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Analyzer.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Analyzer.cxx @@ -523,7 +523,9 @@ bool BRepCheck_Analyzer::ValidSub(const TopoDS_Shape& S, const TopAbs_ShapeEnum } if (!RV->MoreShapeInContext()) + { break; + } for (itl.Initialize(RV->StatusOnShape()); itl.More(); itl.Next()) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Edge.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Edge.cxx index ee16c7125f..2cf31eeb81 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Edge.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Edge.cxx @@ -316,9 +316,13 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) if (!SameParameter || !SameRange) { if (!SameParameter) + { BRepCheck::Add(lst, BRepCheck_InvalidSameParameterFlag); + } if (!SameRange) + { BRepCheck::Add(lst, BRepCheck_InvalidSameRangeFlag); + } return; } @@ -689,7 +693,9 @@ double BRepCheck_Edge::Tolerance() } dist2 = center.SquareDistance(othP); if (dist2 > tolCal) + { tolCal = dist2; + } } if (tol2 > tolCal) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Face.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Face.cxx index b718c5730e..24d9d31224 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Face.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Face.cxx @@ -494,7 +494,9 @@ BRepCheck_Status BRepCheck_Face::OrientationOfWires(const bool Update) if (Wext.IsNull() && !Infinite) { if (Nbwire > 0) + { myOrires = BRepCheck_InvalidImbricationOfWires; + } if (Update) { BRepCheck::Add(aStatusList, myOrires); @@ -634,12 +636,16 @@ static bool Intersect(const TopoDS_Wire& wir1, NCollection_Map MapW1; NCollection_Sequence CommonVertices; for (exp1.Init(wir1, TopAbs_VERTEX); exp1.More(); exp1.Next()) + { MapW1.Add(exp1.Current()); + } for (exp2.Init(wir2, TopAbs_VERTEX); exp2.More(); exp2.Next()) { const TopoDS_Shape& V = exp2.Current(); if (MapW1.Contains(V)) + { CommonVertices.Append(V); + } } // MSV 03.04.2002: create pure surface adaptor to avoid UVBounds computation @@ -670,9 +676,13 @@ static bool Intersect(const TopoDS_Wire& wir1, C1.Load(BRep_Tool::CurveOnSurface(edg1, F, first1, last1)); // To avoid exception in Segment if C1 is BSpline - IFV if (C1.FirstParameter() > first1) + { first1 = C1.FirstParameter(); + } if (C1.LastParameter() < last1) + { last1 = C1.LastParameter(); + } Box1.SetVoid(); if (theMapEdgeBox.IsBound(edg1)) @@ -692,9 +702,13 @@ static bool Intersect(const TopoDS_Wire& wir1, C2.Load(BRep_Tool::CurveOnSurface(edg2, F, first2, last2)); // To avoid exception in Segment if C2 is BSpline - IFV if (C2.FirstParameter() > first2) + { first2 = C2.FirstParameter(); + } if (C2.LastParameter() < last2) + { last2 = C2.LastParameter(); + } Box2.SetVoid(); if (theMapEdgeBox.IsBound(edg2)) @@ -713,18 +727,24 @@ static bool Intersect(const TopoDS_Wire& wir1, myDomain2.SetValues(pfirst2, first2, Inter2dTol, plast2, last2, Inter2dTol); Inter.Perform(C1, myDomain1, C2, myDomain2, Inter2dTol, Inter2dTol); if (!Inter.IsDone()) + { return true; + } if (Inter.NbSegments() > 0) { if (PntSeq.IsEmpty()) + { return true; + } else { int NbCoinc = 0; for (i = 1; i <= Inter.NbSegments(); i++) { if (!Inter.Segment(i).HasFirstPoint() || !Inter.Segment(i).HasLastPoint()) + { return true; + } gp_Pnt2d FirstP2d = Inter.Segment(i).FirstPoint().Value(); gp_Pnt2d LastP2d = Inter.Segment(i).LastPoint().Value(); gp_Pnt FirstP = Surf.Value(FirstP2d.X(), FirstP2d.Y()); @@ -745,7 +765,9 @@ static bool Intersect(const TopoDS_Wire& wir1, if (Inter.NbPoints() > 0) { if (PntSeq.IsEmpty()) + { return true; + } else { int NbCoinc = 0; @@ -868,7 +890,9 @@ bool CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f) } if (nbE != 2) + { return false; + } TopoDS_Edge e1 = TopoDS::Edge(lE.First()); TopoDS_Edge e2 = TopoDS::Edge(lE.Last()); @@ -877,19 +901,29 @@ bool CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f) TopExp::Vertices(e2, v3, v4); if (v1.IsNull() || v2.IsNull() || v3.IsNull() || v4.IsNull()) + { return false; + } if (v1.IsSame(v2) || v3.IsSame(v4)) + { return false; + } bool sF = false, sL = false; if (v1.IsSame(v3) || v1.IsSame(v4)) + { sF = true; + } if (v2.IsSame(v3) || v2.IsSame(v4)) + { sL = true; + } if (!sF || !sL) + { return false; + } TopAbs_Orientation e1or = e1.Orientation(); TopAbs_Orientation e2or = e2.Orientation(); @@ -899,7 +933,9 @@ bool CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f) occ::handle pc2 = BRep_Tool::CurveOnSurface(e2, aF, f2, l2); if (pc1.IsNull() || pc2.IsNull()) + { return false; + } double d1 = std::abs(l1 - f1) / 100.; double d2 = std::abs(l2 - f2) / 100.; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Shell.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Shell.cxx index 594a6eacce..f20626f914 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Shell.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Shell.cxx @@ -61,7 +61,9 @@ static void Propagate(const NCollection_IndexedDataMap* aList = mapEF.Seek(edg); if (aList == nullptr) + { continue; + } for (NCollection_List::Iterator itl(*aList); itl.More(); itl.Next()) { @@ -80,9 +82,13 @@ Standard_EXPORT int BRepCheck_Trace(const int phase) { static int BRC_Trace = 0; if (phase < 0) + { BRC_Trace = 0; + } else if (phase > 0) + { BRC_Trace = phase; + } return BRC_Trace; } @@ -92,7 +98,7 @@ void PrintShape(const TopoDS_Shape& theShape) { size_t code = TopTools_ShapeMapHasher{}(theShape); std::cout << TopAbs::ShapeTypeToString(theShape.ShapeType()) << " : " << code << " " - << TopAbs::ShapeOrientationToString(theShape.Orientation()) << std::endl; + << TopAbs::ShapeOrientationToString(theShape.Orientation()) << '\n'; } } @@ -524,7 +530,9 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const bool Update) const TopoDS_Edge& edg = TopoDS::Edge(myMapEF.FindKey(i)); if (BRep_Tool::Degenerated(edg)) + { continue; + } NCollection_List& lface = myMapEF(i); NCollection_List::Iterator lite(lface); @@ -647,10 +655,12 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const bool Update) Fcur.Orientation(orf); for (ede.Init(Fcur, TopAbs_EDGE); ede.More(); ede.Next()) + { if (ede.Current().IsSame(edg)) { break; } + } if (Fmap.Contains(Fcur)) // edge is "closed" on Fcur, we meet Fcur twice { ede.Next(); @@ -896,7 +906,9 @@ int BRepCheck_Shell::NbConnectedSet(NCollection_List& theSets) NCollection_Map theFaces; TopExp_Explorer exsh(myShape, TopAbs_FACE); for (; exsh.More(); exsh.Next()) + { theFaces.Add(exsh.Current()); + } // The edges that are not oriented or have more than 2 connections are missing int iCur; NCollection_Map theMultiEd; @@ -905,9 +917,13 @@ int BRepCheck_Shell::NbConnectedSet(NCollection_List& theSets) { const TopoDS_Edge& Ed = TopoDS::Edge(parents.FindKey(iCur)); if (parents(iCur).Extent() > 2) + { theMultiEd.Add(Ed); + } if (Ed.Orientation() != TopAbs_REVERSED && Ed.Orientation() != TopAbs_FORWARD) + { theUnOriEd.Add(Ed); + } } // Starting from multiconnected edges propagation by simple connections NCollection_List::Iterator lconx1, lconx2; @@ -932,7 +948,9 @@ int BRepCheck_Shell::NbConnectedSet(NCollection_List& theSets) theFaces.Remove(adFac); newCur = false; if (theFaces.IsEmpty()) + { break; + } lesCur.Append(adFac); while (!lesCur.IsEmpty()) { @@ -952,13 +970,17 @@ int BRepCheck_Shell::NbConnectedSet(NCollection_List& theSets) theFaces.Remove(adFac); newCur = false; if (theFaces.IsEmpty()) + { break; + } lesCur.Append(adFac); } } } if (theFaces.IsEmpty()) + { break; + } } } if (!newCur) @@ -971,11 +993,15 @@ int BRepCheck_Shell::NbConnectedSet(NCollection_List& theSets) } } if (theFaces.IsEmpty()) + { break; + } } } if (theFaces.IsEmpty()) + { break; + } } return theSets.Extent(); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Vertex.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Vertex.cxx index 3ad722f9af..f54f8162ca 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Vertex.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Vertex.cxx @@ -359,7 +359,9 @@ double BRepCheck_Vertex::Tolerance() if (pr->IsPointOnCurve()) { if (!pr->Curve().IsNull()) + { Controlp = pr->Curve()->Value(pr->Parameter()); + } } else if (pr->IsPointOnCurveOnSurface()) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Wire.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Wire.cxx index 3093aba5ec..7d7323fa37 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Wire.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepCheck/BRepCheck_Wire.cxx @@ -453,7 +453,9 @@ static bool IsDistanceIn2DTolerance(const BRepAdaptor_Surface& aFaceSurface, double dvmin = std::abs(thePnt.Y() - thePntRef.Y()); if ((dumin < dumax) && (dvmin < dvmax)) + { return true; + } #ifdef OCCT_DEBUG if (PrintWarnings) @@ -560,7 +562,9 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace, const bool for (; anEdgeExp.More(); anEdgeExp.Next()) { if (IsOriented(anEdgeExp.Current())) + { aNbOrirntedEdges++; + } } if (aNbOrirntedEdges == 0) @@ -609,14 +613,18 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace, const bool BRep_Tool::Range(aFirstEdge, aF, aL); if ((anOri == TopAbs_FORWARD && Precision::IsNegativeInfinite(aF)) || (anOri == TopAbs_REVERSED && Precision::IsPositiveInfinite(aL))) + { isFirstInfinite = true; + } anOri = aLastEdge.Orientation(); BRep_Tool::Range(aLastEdge, aF, aL); if ((anOri == TopAbs_FORWARD && Precision::IsPositiveInfinite(aL)) || (anOri == TopAbs_REVERSED && Precision::IsNegativeInfinite(aF))) + { isLastInfinite = true; + } if (isFirstInfinite && isLastInfinite) { @@ -643,7 +651,9 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace, const bool // get last point BRep_Tool::UVPoints(aLastEdge, theFace, aP_temp, aP_last); if (aLastEdge.Orientation() == TopAbs_REVERSED) + { aP_last = aP_temp; + } // Modified by Sergey KHROMOV - Mon Apr 22 10:36:33 2002 Begin // double aTol, aUResol, aVResol; @@ -654,9 +664,13 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace, const bool // get first point if (aFirstEdge.Orientation() == TopAbs_REVERSED) + { BRep_Tool::UVPoints(aFirstEdge, theFace, aP_temp, aP_first); + } else + { BRep_Tool::UVPoints(aFirstEdge, theFace, aP_first, aP_temp); + } // Modified by Sergey KHROMOV - Thu Jun 20 10:55:42 2002 OCC325 Begin // Check 2d distance for periodic faces with seam edge @@ -684,10 +698,14 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace, const bool gp_Pnt aPnt = BRep_Tool::Pnt(aWireExp.CurrentVertex()); if (!(IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d))) + { aClosedStat = BRepCheck_NotClosed; + } if (!IsDistanceIn3DTolerance(aPntRef, aPnt, aTol3d)) + { aClosedStat = BRepCheck_NotClosed; + } if (Update) { @@ -757,7 +775,9 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up } } if (VF.IsNull() && VL.IsNull()) + { theOstat = BRepCheck_InvalidDegeneratedFlag; + } break; } } @@ -770,7 +790,9 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up bool isGoFwd = true; if (VL.IsNull()) + { isGoFwd = false; + } // Modified by Sergey KHROMOV - Tue May 21 17:12:45 2002 End while (Index < nbOriNoDegen) @@ -801,10 +823,13 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up orient = edg.Orientation(); if (mapS.Contains(edg)) + { ortmp = GetOrientation(mapS, edg); + } // Add to list already passed outcoming edges if (mapS.Contains(edg) && ortmp == orient && !edg.IsSame(theEdge)) + { for (vte.Init(edg, TopAbs_VERTEX); vte.More(); vte.Next()) { TopAbs_Orientation vto = vte.Current().Orientation(); @@ -825,6 +850,7 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up } } } + } if (!mapS.Contains(edg) || ortmp != orient) { @@ -838,7 +864,9 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up // If the processing is in 2d (face not null) or // if the edge is not degenerated it is added if (!F.IsNull() || !BRep_Tool::Degenerated(edg)) + { ledge.Append(edg); + } break; } } @@ -849,7 +877,9 @@ BRepCheck_Status BRepCheck_Wire::Orientation(const TopoDS_Face& F, const bool Up // // If the processing is in 2d (face not null) or // if the edge is not degenerated it is added if (!F.IsNull() || !BRep_Tool::Degenerated(edg)) + { ledge.Append(edg); + } break; } } @@ -1325,7 +1355,9 @@ BRepCheck_Status BRepCheck_Wire::SelfIntersect(const TopoDS_Face& F, || IP_ParamOnFirst - l1 > ::Precision::PConfusion() || f2 - IP_ParamOnSecond > ::Precision::PConfusion() || IP_ParamOnSecond - l2 > ::Precision::PConfusion()) + { continue; + } double tolvtt = 0.; // Modified by Sergey KHROMOV - Mon Apr 15 12:34:22 2002 Begin if (!ConS.IsNull()) @@ -1759,7 +1791,9 @@ static void Propagate(const NCollection_IndexedDataMap C2d = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirstParam, aLastParam); - if (C2d.IsNull()) // JAG 10.12.96 + if (C2d.IsNull()) + { // JAG 10.12.96 return; + } aVOrientation = theVertex.Orientation(); anEdgOrientation = theEdge.Orientation(); @@ -1850,7 +1890,9 @@ void ChoixUV(const TopoDS_Vertex& theVertex, CurveDirForParameter(C2d, aParPiv, aPntRef, aDerRef); if (aVOrientation != anEdgOrientation) + { aDerRef.Reverse(); + } It.Initialize(theLOfShape); @@ -1860,28 +1902,38 @@ void ChoixUV(const TopoDS_Vertex& theVertex, const TopoDS_Edge& anE = TopoDS::Edge(It.Value()); C2d = BRep_Tool::CurveOnSurface(anE, theFace, aFirstParam, aLastParam); if (C2d.IsNull()) + { continue; + } Geom2dAdaptor_Curve aCA(C2d); aParam = (aVOrientation != anE.Orientation()) ? aFirstParam : aLastParam; aPnt = aCA.Value(aParam); if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, false)) + { continue; + } CurveDirForParameter(aCA, aParam, aPnt, aDer); if (aVOrientation == anE.Orientation()) + { aDer.Reverse(); + } if ((aDerRef.Magnitude() <= a_gpResolution) || (aDer.Magnitude() <= a_gpResolution)) + { // Vector length is too small continue; + } anAngle = -aDerRef.Angle(aDer); if (anAngle < 0.) + { anAngle += 2. * M_PI; + } if (theFace.Orientation() == TopAbs_FORWARD) { @@ -1903,15 +1955,20 @@ void ChoixUV(const TopoDS_Vertex& theVertex, // Update edge if (anIndMin == 0) + { if (theLOfShape.Extent() == 1) { bool IsFound = true; // all right anEFound = TopoDS::Edge(theLOfShape.First()); if (anEFound.IsNull() || BRep_Tool::Degenerated(theEdge) || BRep_Tool::Degenerated(anEFound)) + { IsFound = false; // bad + } else if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d)) + { IsFound = false; // bad + } else // clousureness in 3D { @@ -1933,6 +1990,7 @@ void ChoixUV(const TopoDS_Vertex& theVertex, { theLOfShape.Clear(); } + } else { anIndex = 1; @@ -1947,7 +2005,9 @@ void ChoixUV(const TopoDS_Vertex& theVertex, It.Next(); while (It.More()) + { theLOfShape.Remove(It); + } } } // End of function @@ -2000,12 +2060,16 @@ static bool GetPnt2d(const TopoDS_Vertex& theVertex, TopExp::Vertices(theEdge, aFirstVtx, aLastVtx); if (!theVertex.IsSame(aFirstVtx) && !theVertex.IsSame(aLastVtx)) + { return false; + } aPCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFPar, aLPar); if (aPCurve.IsNull()) + { return false; + } aParOnEdge = BRep_Tool::Parameter(theVertex, theEdge); aPnt = aPCurve->Value(aParOnEdge); @@ -2035,7 +2099,9 @@ static bool IsClosed2dForPeriodicFace(const TopoDS_Face& theFace, TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current()); if (NotSeams.Contains(anEdge)) + { continue; + } if (!IsOriented(anEdge) || !BRep_Tool::IsClosed(anEdge, theFace)) { @@ -2044,11 +2110,15 @@ static bool IsClosed2dForPeriodicFace(const TopoDS_Face& theFace, } if (!ClosedEdges.Add(anEdge)) + { aSeamEdges.Append(anEdge); + } } if (aSeamEdges.Extent() == 0) + { return true; + } // check if theVertex lies on one of the seam edges BRepAdaptor_Surface aFaceSurface(theFace, false); @@ -2078,18 +2148,24 @@ static bool IsClosed2dForPeriodicFace(const TopoDS_Face& theFace, double a2dTol; if (!GetPnt2d(theVertex, aSeamEdge, theFace, aPnt1)) + { continue; + } aSeamEdge = TopoDS::Edge(aSeamEdge.Reversed()); if (!GetPnt2d(theVertex, aSeamEdge, theFace, aPnt2)) + { continue; + } a2dTol = aPnt1.Distance(aPnt2) * 1.e-2; a2dTol = std::max(a2dTol, aVicinity); if (aDistP1P2 > a2dTol) + { return false; + } } } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_FaceExplorer.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_FaceExplorer.cxx index a4840e50c3..5d4a4201dd 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_FaceExplorer.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_FaceExplorer.cxx @@ -132,7 +132,9 @@ bool BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double for (i = 1; anExpF.More(); anExpF.Next(), i++) { if (i != myCurEdgeInd) + { continue; + } const TopoDS_Shape& aLocalShape = anExpF.Current(); const TopAbs_Orientation anOrientation = aLocalShape.Orientation(); @@ -159,7 +161,9 @@ bool BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double } } else if (Precision::IsPositiveInfinite(aLPar)) + { aLPar = aFPar + 1.; + } for (; myCurEdgePar < Probing_End; myCurEdgePar += Probing_Step) { @@ -176,7 +180,9 @@ bool BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double double aTanMod = aTanVec.SquareMagnitude(); if (aTanMod < aTolParConf2) + { continue; + } aTanVec /= std::sqrt(aTanMod); double aSinA = aTanVec.Crossed(aLinDir.XY()); const double SmallAngle = 0.001; @@ -190,7 +196,9 @@ bool BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P, gp_Lin2d& L, double // no tangent. If there tangent is preserved then leave the last point in // order to get this edge chance to participate in classification. if (myCurEdgePar + Probing_Step < Probing_End) + { continue; + } } L = gp_Lin2d(P, aLinDir); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_Intersector.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_Intersector.cxx index 7bd60928d3..ac891ef5dd 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_Intersector.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass/BRepClass_Intersector.cxx @@ -459,12 +459,18 @@ void BRepClass_Intersector::LocalGeometry(const BRepClass_Edge& E, C = Prop.Curvature(); } else + { GetTangentAsChord(aPCurve, Tang, U, fpar, lpar); + } if (C > Precision::PConfusion() && !Precision::IsInfinite(C)) + { Prop.Normal(Norm); + } else + { Norm.SetCoord(Tang.Y(), -Tang.X()); + } } //================================================================================================= @@ -519,19 +525,27 @@ void GetTangentAsChord(const occ::handle& thePCurve, { double Offset = 0.1 * (theLast - theFirst); - if (theLast - theParam < Precision::PConfusion()) // theParam == theLast + if (theLast - theParam < Precision::PConfusion()) + { // theParam == theLast Offset *= -1; - else if (theParam + Offset > theLast) // is close to + } + else if (theParam + Offset > theLast) + { // is close to Offset = 0.5 * (theLast - theParam); + } gp_Pnt2d aPnt2d = thePCurve->Value(theParam); gp_Pnt2d OffsetPnt2d = thePCurve->Value(theParam + Offset); gp_Vec2d aChord(aPnt2d, OffsetPnt2d); if (Offset < 0.) + { aChord.Reverse(); + } double SqLength = aChord.SquareMagnitude(); if (SqLength > Precision::SquarePConfusion()) + { theTangent = aChord; + } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d.cxx index 62a834281b..6796efabdc 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d.cxx @@ -56,7 +56,9 @@ TopoDS_Shell BRepClass3d::OuterShell(const TopoDS_Solid& aSolid) aShell = *((TopoDS_Shell*)&aSx); aShellCounter++; if (aShellCounter >= 2) + { break; + } } } if (aShellCounter == 0) diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_BndBoxTree.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_BndBoxTree.cxx index 4f54952e19..f1d73855a8 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_BndBoxTree.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_BndBoxTree.cxx @@ -26,7 +26,9 @@ bool BRepClass3d_BndBoxTreeSelectorPoint::Accept(const int& theObj) { // Box-point collision. if (theObj > myMapOfShape.Extent()) + { return false; + } const TopoDS_Shape& shp = myMapOfShape(theObj); TopAbs_ShapeEnum sht = shp.ShapeType(); if (sht == TopAbs_EDGE) @@ -43,11 +45,13 @@ bool BRepClass3d_BndBoxTreeSelectorPoint::Accept(const int& theObj) if (ExtPC.IsDone() && ExtPC.NbExt() > 0) { for (int i = 1; i <= ExtPC.NbExt(); i++) + { if (ExtPC.SquareDistance(i) < EdgeTSq) { myStop = true; // exit from selector return true; } + } } } else if (sht == TopAbs_VERTEX) @@ -72,7 +76,9 @@ bool BRepClass3d_BndBoxTreeSelectorLine::Accept(const int& theObj) { // box-line collision if (theObj > myMapOfShape.Extent()) + { return false; + } const TopoDS_Shape& shp = myMapOfShape(theObj); TopAbs_ShapeEnum sht = shp.ShapeType(); if (sht == TopAbs_EDGE) @@ -113,7 +119,9 @@ bool BRepClass3d_BndBoxTreeSelectorLine::Accept(const int& theObj) } } if (IsInside) + { return true; + } } } } @@ -129,6 +137,7 @@ bool BRepClass3d_BndBoxTreeSelectorLine::Accept(const int& theObj) -Precision::Infinite(), Precision::Infinite()); if (ExtPL.IsDone() && ExtPL.NbExt() > 0) + { if (ExtPL.SquareDistance(1) < VertTSq) { Extrema_POnCurv PP; @@ -141,6 +150,7 @@ bool BRepClass3d_BndBoxTreeSelectorLine::Accept(const int& theObj) myVP.Append(VP); return true; } + } } return false; } \ No newline at end of file diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_Intersector3d.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_Intersector3d.cxx index c713f87b05..91defdc37e 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_Intersector3d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_Intersector3d.cxx @@ -130,9 +130,13 @@ void BRepClass3d_Intersector3d::Perform(const gp_Lin& L, if (Face.Orientation() == TopAbs_REVERSED) { if (transition == IntCurveSurface_In) + { transition = IntCurveSurface_Out; + } else + { transition = IntCurveSurface_In; + } } } } //-- classifier state is IN or ON diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SClassifier.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SClassifier.cxx index e7235a4676..a7bed33d08 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SClassifier.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SClassifier.cxx @@ -134,7 +134,9 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aS aParam = 0.1 + 0.8 * aRandomGenerator.NextReal(); // random number in range [0.1, 0.9] bFound = BRepClass3d_SolidExplorer::FindAPointInTheFace(aF, aPoint, aU, aV, aParam); if (!bFound || !FaceNormal(aF, aU, aV, aDN)) + { continue; + } gp_Lin aLin(aPoint, -aDN); double parmin = RealLast(); @@ -157,8 +159,12 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aS { int imin = 1; for (int i = 2; i <= Intersector3d.NbPnt(); i++) + { if (Intersector3d.WParameter(i) < Intersector3d.WParameter(imin)) + { imin = i; + } + } parmin = Intersector3d.WParameter(imin); aState = Intersector3d.State(imin); aTransition = Intersector3d.Transition(imin); @@ -168,7 +174,9 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aS } } else + { myState = 1; + } } // end of loop on the whole solid if (aState == TopAbs_IN) @@ -249,14 +257,20 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, while (isFaultyLine) { if (anIndFace == 0) + { iFlag = SolidExplorer.Segment(P, L, Par); + } else + { iFlag = SolidExplorer.OtherSegment(P, L, Par); + } int aCurInd = SolidExplorer.GetFaceSegmentIndex(); if (aCurInd > anIndFace) + { anIndFace = aCurInd; + } else { myState = 1; // Faulty. @@ -278,7 +292,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, // Check if the point is ON surface but OUT of the face. // Just skip this face because it is bad for classification. if (iFlag == 3) + { continue; + } isFaultyLine = false; parmin = RealLast(); @@ -304,7 +320,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, LVInts.Add(V); if (std::abs(LP) < std::abs(NearFaultPar)) + { NearFaultPar = LP; + } } double param = 0.0; @@ -316,7 +334,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, aSelectorLine.GetEdgeParam(i, EE, param, Lpar); const NCollection_List& ffs = mapEF.FindFromKey(EE); // ffs size == 2 if (ffs.Extent() != 2) + { continue; + } TopoDS_Face f1 = TopoDS::Face(ffs.First()); TopoDS_Face f2 = TopoDS::Face(ffs.Last()); TopoDS_Vertex V1, V2; @@ -334,7 +354,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, Trans(parmin, tran, myState); } else if (std::abs(Lpar) < std::abs(NearFaultPar)) + { NearFaultPar = Lpar; + } } } @@ -470,7 +492,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, } } //-- Face has not been rejected else + { myState = 1; + } } } //-- Exploration of the faces if (myState == 2) @@ -479,7 +503,9 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, } } //-- Shell has not been rejected else + { myState = 1; + } } //-- Exploration of the shells if (NearFaultPar != RealLast() @@ -499,11 +525,17 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer, TopAbs_State BRepClass3d_SClassifier::State() const { if (myState == 2) + { return (TopAbs_ON); + } else if (myState == 3) + { return (TopAbs_IN); + } else if (myState == 4) + { return (TopAbs_OUT); + } // return OUT state when there is an error during execution. return (TopAbs_OUT); @@ -555,10 +587,14 @@ double GetAddToParam(const gp_Lin& L, const double P, const Bnd_Box& B) gp_Pnt aP(x[i], y[j], z[k]); double par = ElCLib::Parameter(L, aP); if (par > Par) + { Par = par; + } } else + { return 1.e+20; + } } } } @@ -577,7 +613,9 @@ bool FaceNormal(const TopoDS_Face& aF, const double U, const double V, gp_Dir& a aS->D1(U, V, aPnt, aD1U, aD1V); aN = aD1U.Crossed(aD1V); if (aN.Magnitude() <= gp::Resolution()) + { return false; + } aN.Normalize(); aDN.SetXYZ(aN.XYZ()); @@ -600,9 +638,13 @@ static bool GetNormalOnFaceBound(const TopoDS_Edge& E, gp_Pnt2d P2d; occ::handle c2d = BRep_Tool::CurveOnSurface(E, F, f, l); if (c2d.IsNull()) + { return false; + } if (param < f || param > l) + { return false; + } c2d->D0(param, P2d); return FaceNormal(F, P2d.X(), P2d.Y(), OutDir); } @@ -622,9 +664,13 @@ static int GetTransi(const TopoDS_Face& f1, //-1 => probably a faulty line gp_Dir nf1, nf2; if (!GetNormalOnFaceBound(e, f1, param, nf1)) + { return -1; + } if (!GetNormalOnFaceBound(e, f2, param, nf2)) + { return -1; + } const gp_Dir& LDir = L.Direction(); @@ -640,11 +686,17 @@ static int GetTransi(const TopoDS_Face& f1, { double angD = nf1.Dot(LDir); if (std::abs(angD) < Precision::Angular()) + { return -1; + } else if (angD > 0) + { trans = IntCurveSurface_Out; - else // angD < -Precision::Angular()) + } + else + { // angD < -Precision::Angular()) trans = IntCurveSurface_In; + } return 1; } @@ -657,11 +709,17 @@ static int GetTransi(const TopoDS_Face& f1, double sAD = nf2.Dot(ProjL); if (fAD < -Precision::Angular() && sAD < -Precision::Angular()) + { trans = IntCurveSurface_In; + } else if (fAD > Precision::Angular() && sAD > Precision::Angular()) + { trans = IntCurveSurface_Out; + } else + { return 0; + } return 1; } @@ -671,12 +729,18 @@ static void Trans(const double parmin, IntCurveSurface_TransitionOnCurve& tran, { // if parmin is negative we should reverse transition if (parmin < 0) + { tran = (tran == IntCurveSurface_Out ? IntCurveSurface_In : IntCurveSurface_Out); + } if (tran == IntCurveSurface_Out) + { //-- The line is going from inside the solid to outside //-- the solid. state = 3; // IN + } else + { state = 4; // OUT + } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SolidExplorer.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SolidExplorer.cxx index f3771c3a47..c92cb6e48b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SolidExplorer.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepClass3d/BRepClass3d_SolidExplorer.cxx @@ -90,7 +90,9 @@ bool BRepClass3d_SolidExplorer::FindAPointInTheFace(const TopoDS_Face& _face, TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current()); BRepAdaptor_Curve2d c(Edge, face); if (c.Curve().IsNull()) + { continue; + } c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(), P, T); @@ -162,17 +164,23 @@ bool BRepClass3d_SolidExplorer::FindAPointInTheFace(const TopoDS_Face& _face, gp_Pnt2d aPnt2d(u_, v_); TopAbs_State StateOfResultingPoint = Classifier.Perform(aPnt2d); if (StateOfResultingPoint != TopAbs_IN) + { return false; + } BRepAdaptor_Surface s; s.Initialize(face, false); s.D1(u_, v_, APoint_, theVecD1U, theVecD1V); if (theVecD1U.CrossMagnitude(theVecD1V) > gp::Resolution()) + { return true; + } if (ParamInit < Precision::PConfusion()) + { return false; + } } } return false; @@ -247,9 +255,13 @@ bool BRepClass3d_SolidExplorer::PointInTheFace(const TopoDS_Face& double u, du = (U2 - U1) / 6.0; double v, dv = (V2 - V1) / 6.0; if (du < 1e-12) + { du = 1e-12; + } if (dv < 1e-12) + { dv = 1e-12; + } bool IsNotUper = !surf->IsUPeriodic(), IsNotVper = !surf->IsVPeriodic(); int NbPntCalc = 0; if (myMapOfInter.IsBound(Face)) @@ -273,7 +285,9 @@ bool BRepClass3d_SolidExplorer::PointInTheFace(const TopoDS_Face& gp_Pnt aPnt; surf->D1(u_, v_, aPnt, theVecD1U, theVecD1V); if (aPnt.SquareDistance(APoint_) < Precision::Confusion() * Precision::Confusion()) + { return true; + } } //-- Take 4 points in each Quarter of surface @@ -355,9 +369,13 @@ bool BRepClass3d_SolidExplorer::PointInTheFace(const TopoDS_Face& du = (U2 - U1) / 37.0; dv = (V2 - V1) / 37.0; if (du < 1e-12) + { du = 1e-12; + } if (dv < 1e-12) + { dv = 1e-12; + } for (u = du + U1; u < U2; u += du) { @@ -414,13 +432,21 @@ static void LimitInfiniteUV(double& U1, double& V1, double& U2, double& V2) infU2 = Precision::IsPositiveInfinite(U2), infV2 = Precision::IsPositiveInfinite(V2); if (infU1) + { U1 = -1e10; + } if (infV1) + { V1 = -1e10; + } if (infU2) + { U2 = 1e10; + } if (infV2) + { V2 = 1e10; + } } //================================================================================================= @@ -430,16 +456,24 @@ static int IsInfiniteUV(double& U1, double& V1, double& U2, double& V2) int aVal = 0; if (Precision::IsInfinite(U1)) + { aVal |= 1; + } if (Precision::IsInfinite(V1)) + { aVal |= 2; + } if (Precision::IsInfinite(U2)) + { aVal |= 4; + } if (Precision::IsInfinite(V2)) + { aVal |= 8; + } return aVal; } @@ -488,7 +522,9 @@ int BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P, gp_Lin& L, double& // Modified by skv - Thu Sep 4 14:31:12 2003 OCC578 End NbFacesInSolid++; if (myFirstFace > NbFacesInSolid) + { continue; + } face = TopoDS::Face(faceexplorer.Current()); occ::handle surf = new BRepAdaptor_Surface(); @@ -701,22 +737,38 @@ int BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P, gp_Lin& L, double& } myFirstFace = 0; if (myParamOnEdge == 0.512345) + { myParamOnEdge = 0.4; + } else if (myParamOnEdge == 0.4) + { myParamOnEdge = 0.6; + } else if (myParamOnEdge == 0.6) + { myParamOnEdge = 0.3; + } else if (myParamOnEdge == 0.3) + { myParamOnEdge = 0.7; + } else if (myParamOnEdge == 0.7) + { myParamOnEdge = 0.2; + } else if (myParamOnEdge == 0.2) + { myParamOnEdge = 0.8; + } else if (myParamOnEdge == 0.8) + { myParamOnEdge = 0.1; + } else if (myParamOnEdge == 0.1) + { myParamOnEdge = 0.9; - // + // + } else { myParamOnEdge *= 0.5; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistShapeShape.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistShapeShape.cxx index 2720e7fe73..ff87906d2b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistShapeShape.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistShapeShape.cxx @@ -832,7 +832,9 @@ bool BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange& theRange) mySolutionsShape2.Clear(); if (myShape1.IsNull() || myShape2.IsNull()) + { return false; + } // Treatment of solids bool anIsSolid1 = @@ -913,7 +915,9 @@ bool BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange& theRange) myDistRef = DistanceInitiale(V1, V2); } else + { myDistRef = 1.e30; // szv:!!! + } if (!DistanceVertVert(myMapV1, myMapV2, aRootScope.Next())) { @@ -959,11 +963,13 @@ bool BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange& theRange) // Modified by Sergey KHROMOV - Tue Mar 6 11:55:03 2001 Begin int i = 1; for (; i <= mySolutionsShape1.Length(); i++) + { if (mySolutionsShape1.Value(i).Dist() > myDistRef + myEps) { mySolutionsShape1.Remove(i); mySolutionsShape2.Remove(i); } + } // Modified by Sergey KHROMOV - Tue Mar 6 11:55:04 2001 End myIsDone = (mySolutionsShape1.Length() > 0); } @@ -976,7 +982,9 @@ bool BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange& theRange) double BRepExtrema_DistShapeShape::Value() const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::Value: There's no solution "); + } return myDistRef; } @@ -986,7 +994,9 @@ double BRepExtrema_DistShapeShape::Value() const TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const int N) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::SupportOnShape1: There's no solution "); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape1.Value(N); switch (sol.SupportKind()) @@ -1006,7 +1016,9 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const int N) const TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const int N) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::SupportOnShape2: There's no solution "); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape2.Value(N); switch (sol.SupportKind()) @@ -1026,12 +1038,16 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const int N) const void BRepExtrema_DistShapeShape::ParOnEdgeS1(const int N, double& t) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnEdgeS1: There's no solution"); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape1.Value(N); if (sol.SupportKind() != BRepExtrema_IsOnEdge) + { throw BRepExtrema_UnCompatibleShape( "BRepExtrema_DistShapeShape::ParOnEdgeS1: ParOnEdgeS1 is impossible without EDGE"); + } sol.EdgeParameter(t); } @@ -1041,12 +1057,16 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS1(const int N, double& t) const void BRepExtrema_DistShapeShape::ParOnEdgeS2(const int N, double& t) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnEdgeS2: There's no solution"); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape2.Value(N); if (sol.SupportKind() != BRepExtrema_IsOnEdge) + { throw BRepExtrema_UnCompatibleShape( "BRepExtrema_DistShapeShape::ParOnEdgeS2: ParOnEdgeS2 is impossible without EDGE"); + } sol.EdgeParameter(t); } @@ -1056,12 +1076,16 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS2(const int N, double& t) const void BRepExtrema_DistShapeShape::ParOnFaceS1(const int N, double& u, double& v) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnFaceS1: There's no solution"); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape1.Value(N); if (sol.SupportKind() != BRepExtrema_IsInFace) + { throw BRepExtrema_UnCompatibleShape( "BRepExtrema_DistShapeShape::ParOnFaceS1: ParOnFaceS1 is impossible without FACE"); + } sol.FaceParameter(u, v); } @@ -1071,12 +1095,16 @@ void BRepExtrema_DistShapeShape::ParOnFaceS1(const int N, double& u, double& v) void BRepExtrema_DistShapeShape::ParOnFaceS2(const int N, double& u, double& v) const { if (!myIsDone) + { throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnFaceS2: There's no solution"); + } const BRepExtrema_SolutionElem& sol = mySolutionsShape2.Value(N); if (sol.SupportKind() != BRepExtrema_IsInFace) + { throw BRepExtrema_UnCompatibleShape( "BRepExtrema_DistShapeShape::ParOnFaceS2:ParOnFaceS2 is impossible without FACE "); + } sol.FaceParameter(u, v); } @@ -1088,22 +1116,20 @@ void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const int i; double r1, r2; - o << "the distance value is : " << Value() << std::endl; - o << "the number of solutions is :" << NbSolution() << std::endl; - o << std::endl; + o << "the distance value is : " << Value() << '\n'; + o << "the number of solutions is :" << NbSolution() << '\n'; + o << '\n'; for (i = 1; i <= NbSolution(); i++) { - o << "solution number " << i << ": " << std::endl; - o << "the type of the solution on the first shape is " << int(SupportTypeShape1(i)) - << std::endl; - o << "the type of the solution on the second shape is " << int(SupportTypeShape2(i)) - << std::endl; - o << "the coordinates of the point on the first shape are: " << std::endl; + o << "solution number " << i << ": " << '\n'; + o << "the type of the solution on the first shape is " << int(SupportTypeShape1(i)) << '\n'; + o << "the type of the solution on the second shape is " << int(SupportTypeShape2(i)) << '\n'; + o << "the coordinates of the point on the first shape are: " << '\n'; o << "X=" << PointOnShape1(i).X() << " Y=" << PointOnShape1(i).Y() - << " Z=" << PointOnShape1(i).Z() << std::endl; - o << "the coordinates of the point on the second shape are: " << std::endl; + << " Z=" << PointOnShape1(i).Z() << '\n'; + o << "the coordinates of the point on the second shape are: " << '\n'; o << "X=" << PointOnShape2(i).X() << " Y=" << PointOnShape2(i).Y() - << " Z=" << PointOnShape2(i).Z() << std::endl; + << " Z=" << PointOnShape2(i).Z() << '\n'; switch (SupportTypeShape1(i)) { @@ -1111,11 +1137,11 @@ void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const break; case BRepExtrema_IsOnEdge: ParOnEdgeS1(i, r1); - o << "parameter on the first edge : t= " << r1 << std::endl; + o << "parameter on the first edge : t= " << r1 << '\n'; break; case BRepExtrema_IsInFace: ParOnFaceS1(i, r1, r2); - o << "parameters on the first face : u= " << r1 << " v=" << r2 << std::endl; + o << "parameters on the first face : u= " << r1 << " v=" << r2 << '\n'; break; } switch (SupportTypeShape2(i)) @@ -1124,13 +1150,13 @@ void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const break; case BRepExtrema_IsOnEdge: ParOnEdgeS2(i, r1); - o << "parameter on the second edge : t=" << r1 << std::endl; + o << "parameter on the second edge : t=" << r1 << '\n'; break; case BRepExtrema_IsInFace: ParOnFaceS2(i, r1, r2); - o << "parameters on the second face : u= " << r1 << " v=" << r2 << std::endl; + o << "parameters on the second face : u= " << r1 << " v=" << r2 << '\n'; break; } - o << std::endl; + o << '\n'; } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx index 96608614a9..a285be0673 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_DistanceSS.cxx @@ -105,7 +105,9 @@ static void TRIM_INFINIT_EDGE(const TopoDS_Edge& S1, bool& bIsTrim2) { if (BRep_Tool::Degenerated(S1) || BRep_Tool::Degenerated(S2)) + { return; + } aResEdge = S2; double aFirst1, aLast1, aFirst2, aLast2; @@ -114,7 +116,9 @@ static void TRIM_INFINIT_EDGE(const TopoDS_Edge& S1, if (Precision::IsInfinite(aFirst1) && Precision::IsInfinite(aLast1) && Precision::IsInfinite(aFirst2) && Precision::IsInfinite(aLast2)) + { return; + } double Umin = 0., Umax = 0.; bool bUmin, bUmax; @@ -155,9 +159,13 @@ static void TRIM_INFINIT_EDGE(const TopoDS_Edge& S1, { Bnd_Box aEdgeBox; if (bIsTrim1) + { BRepBndLib::Add(S2, aEdgeBox); + } if (bIsTrim2) + { BRepBndLib::Add(S1, aEdgeBox); + } double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; aEdgeBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); @@ -189,26 +197,38 @@ static void TRIM_INFINIT_EDGE(const TopoDS_Edge& S1, arrU[7] = aProj.LowerDistanceParameter(); if (!bUmin) + { Umin = arrU[0]; + } if (!bUmax) + { Umax = arrU[0]; + } int i = 0; while (i < 8) { const double aU = arrU[i++]; if (aU < Umin) + { Umin = aU; + } else if (aU > Umax) + { Umax = aU; + } } double tol = Precision::Confusion(); if (bIsTrim1) + { tol = BRep_Tool::Tolerance(S1); + } else if (bIsTrim2) + { tol = BRep_Tool::Tolerance(S2); + } const double EpsU = GeomAdaptor_Curve(pCurv).Resolution(3. * tol); if (fabs(Umin - Umax) < EpsU) @@ -241,14 +261,18 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, { aE = TopoDS::Edge(S1); if (BRep_Tool::Degenerated(aE)) + { return; + } aF = TopoDS::Face(S2); } else if (Type2 == TopAbs_EDGE && Type1 == TopAbs_FACE) { aE = TopoDS::Edge(S2); if (BRep_Tool::Degenerated(aE)) + { return; + } aF = TopoDS::Face(S1); } else @@ -272,7 +296,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, { pSurf->Bounds(U1, U2, V1, V2); if (Precision::IsInfinite(U1)) + { bIsTrim = true; + } else { Umin = U1; @@ -280,7 +306,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, } if (Precision::IsInfinite(U2)) + { bIsTrim = true; + } else { Umax = U2; @@ -288,7 +316,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, } if (Precision::IsInfinite(V1)) + { bIsTrim = true; + } else { Vmin = V1; @@ -296,7 +326,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, } if (Precision::IsInfinite(V2)) + { bIsTrim = true; + } else { Vmax = V2; @@ -308,7 +340,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, BRepTools::UVBounds(aF, U1, U2, V1, V2); if (Precision::IsInfinite(U1) && Precision::IsInfinite(U2) && Precision::IsInfinite(V1) && Precision::IsInfinite(V2)) + { bIsTrim = true; + } } if (bIsTrim) @@ -317,7 +351,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, BRepBndLib::Add(aE, aEdgeBox); if (aEdgeBox.IsWhole()) + { return; + } double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; aEdgeBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); @@ -334,52 +370,84 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, double arrU[8], arrV[8]; GeomAPI_ProjectPointOnSurf aProj(aPnt0, pSurf); /*szv:aProj.Perform(aPnt0);*/ if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[0], arrV[0]); + } aProj.Perform(aPnt1); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[1], arrV[1]); + } aProj.Perform(aPnt2); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[2], arrV[2]); + } aProj.Perform(aPnt3); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[3], arrV[3]); + } aProj.Perform(aPnt4); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[4], arrV[4]); + } aProj.Perform(aPnt5); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[5], arrV[5]); + } aProj.Perform(aPnt6); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[6], arrV[6]); + } aProj.Perform(aPnt7); if (aProj.IsDone()) + { aProj.LowerDistanceParameters(arrU[7], arrV[7]); + } if (!bUmin) + { Umin = arrU[0]; + } if (!bUmax) + { Umax = arrU[0]; + } if (!bVmin) + { Vmin = arrV[0]; + } if (!bVmax) + { Vmax = arrV[0]; + } int i = 0; while (i < 8) { const double aU = arrU[i]; if (aU < Umin) + { Umin = aU; + } else if (aU > Umax) + { Umax = aU; + } const double aV = arrV[i]; if (aV < Vmin) + { Vmin = aV; + } else if (aV > Vmax) + { Vmax = aV; + } i++; } @@ -408,7 +476,9 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, bIsInfinit = true; } else + { bIsInfinit = false; + } } //================================================================================================= @@ -422,7 +492,9 @@ static void PERFORM_C0(const TopoDS_Edge& S1, const double Eps) { if (BRep_Tool::Degenerated(S1) || BRep_Tool::Degenerated(S2)) + { return; + } int iE; for (iE = 0; iE < 2; iE++) @@ -482,11 +554,14 @@ static void PERFORM_C0(const TopoDS_Edge& S1, { const double sDst = Ext.SquareDistance(ii); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < DstRef - Eps) || (fabs(Dstmin - DstRef) < Eps)) + { for (ii = 1; ii <= NbExtrema; ii++) { if (fabs(Dstmin - sqrt(Ext.SquareDistance(ii))) < Eps) @@ -507,7 +582,9 @@ static void PERFORM_C0(const TopoDS_Edge& S1, if ((fabs(t - Udeb) >= epsP) && (fabs(t - Ufin) > epsP)) { if (mDstRef > Dstmin) + { mDstRef = Dstmin; + } const BRepExtrema_SolutionElem Sol1(Dstmin, aPnt, BRepExtrema_IsOnEdge, @@ -524,6 +601,7 @@ static void PERFORM_C0(const TopoDS_Edge& S1, } } } + } } for (int i2 = 1; i2 <= arrInterOther.Length(); i2++) { @@ -533,7 +611,9 @@ static void PERFORM_C0(const TopoDS_Edge& S1, if ((Dst < DstRef - Eps) || (fabs(Dst - DstRef) < Eps)) { if (mDstRef > Dst) + { mDstRef = Dst; + } const BRepExtrema_SolutionElem Sol1(Dst, aPnt, BRepExtrema_IsOnEdge, E, aParameter); const BRepExtrema_SolutionElem Sol2(Dst, aPntOther, @@ -632,9 +712,13 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& theS1, bool bIsTrim2 = false; TRIM_INFINIT_EDGE(aE1, aE2, aTrimEdge, bIsTrim1, bIsTrim2); if (bIsTrim1) + { aE1 = aTrimEdge; + } if (bIsTrim2) + { aE2 = aTrimEdge; + } Perform(aE1, aE2, mySeqSolShape1, mySeqSolShape2); break; } @@ -644,7 +728,9 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& theS1, bool bIsInfinit; TRIM_INFINIT_FACE(aE1, aF2, aTrimFace, bIsInfinit); if (bIsInfinit) + { aF2 = aTrimFace; + } Perform(aE1, aF2, mySeqSolShape1, mySeqSolShape2); break; } @@ -668,7 +754,9 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& theS1, bool bIsInfinit; TRIM_INFINIT_FACE(aF1, aE2, aTrimFace, bIsInfinit); if (bIsInfinit) + { aF1 = aTrimFace; + } Perform(aE2, aF1, mySeqSolShape2, mySeqSolShape1); break; } @@ -702,7 +790,9 @@ void BRepExtrema_DistanceSS::Perform( if ((Dst < myDstRef - myEps) || (fabs(Dst - myDstRef) < myEps)) { if (myDstRef > Dst) + { myDstRef = Dst; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dst, aP1, BRepExtrema_IsVertex, theS1); const BRepExtrema_SolutionElem Sol2(Dst, aP2, BRepExtrema_IsVertex, theS2); @@ -720,7 +810,9 @@ void BRepExtrema_DistanceSS::Perform( NCollection_Sequence& theSeqSolShape2) { if (BRep_Tool::Degenerated(theS2)) + { return; + } BRepExtrema_ExtPC Ext(theS1, theS2); const int NbExtrema = Ext.IsDone() ? Ext.NbExt() : 0; @@ -733,7 +825,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = Ext.SquareDistance(i); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps)) @@ -753,7 +847,9 @@ void BRepExtrema_DistanceSS::Perform( if (!isOnBoundary(theS2, Pt, t, epsP)) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, P1, BRepExtrema_IsVertex, theS1); const BRepExtrema_SolutionElem Sol2(Dstmin, Pt, BRepExtrema_IsOnEdge, theS2, t); @@ -786,7 +882,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = Ext.SquareDistance(i); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps)) @@ -810,7 +908,9 @@ void BRepExtrema_DistanceSS::Perform( if (classifier.State() == TopAbs_IN) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, P1, BRepExtrema_IsVertex, theS1); const BRepExtrema_SolutionElem Sol2(Dstmin, Pt, BRepExtrema_IsInFace, theS2, U, V); @@ -833,7 +933,9 @@ void BRepExtrema_DistanceSS::Perform( NCollection_Sequence& theSeqSolShape2) { if (BRep_Tool::Degenerated(theS1) || BRep_Tool::Degenerated(theS2)) + { return; + } const double DstRef = myDstRef; @@ -848,7 +950,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = Ext.SquareDistance(i); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps)) @@ -871,7 +975,9 @@ void BRepExtrema_DistanceSS::Perform( if (!isOnBoundary(theS1, Pt1, t1, epsP) && !isOnBoundary(theS2, Pt2, t2, epsP)) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, Pt1, BRepExtrema_IsOnEdge, theS1, t1); const BRepExtrema_SolutionElem Sol2(Dstmin, Pt2, BRepExtrema_IsOnEdge, theS2, t2); @@ -893,7 +999,9 @@ void BRepExtrema_DistanceSS::Perform( NCollection_Sequence seqSol2; if (SeqSolution1.Length() > 0 && SeqSolution2.Length() > 0) + { MIN_SOLUTION(SeqSolution1, SeqSolution2, myDstRef, myEps, seqSol1, seqSol2); + } if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) { @@ -922,7 +1030,9 @@ void BRepExtrema_DistanceSS::Perform( NCollection_Sequence& theSeqSolShape2) { if (BRep_Tool::Degenerated(theS1)) + { return; + } BRepClass_FaceClassifier classifier; @@ -937,7 +1047,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = Ext.SquareDistance(i); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps)) @@ -966,7 +1078,9 @@ void BRepExtrema_DistanceSS::Perform( if (classifier.State() == TopAbs_IN) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, Pt1, BRepExtrema_IsOnEdge, theS1, t1); const BRepExtrema_SolutionElem Sol2(Dstmin, Pt2, BRepExtrema_IsInFace, theS2, U, V); @@ -1014,7 +1128,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = ExtPF.SquareDistance(ii); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); @@ -1031,7 +1147,9 @@ void BRepExtrema_DistanceSS::Perform( if (classifier.State() == TopAbs_IN) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, aPnt, @@ -1056,7 +1174,9 @@ void BRepExtrema_DistanceSS::Perform( NCollection_Sequence seqSol1; NCollection_Sequence seqSol2; if (SeqSolution1.Length() > 0 && SeqSolution2.Length() > 0) + { MIN_SOLUTION(SeqSolution1, SeqSolution2, myDstRef, myEps, seqSol1, seqSol2); + } if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) { @@ -1085,7 +1205,9 @@ void BRepExtrema_DistanceSS::Perform( { const double sDst = Ext.SquareDistance(i); if (sDst < Dstmin) + { Dstmin = sDst; + } } Dstmin = sqrt(Dstmin); if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps)) @@ -1118,7 +1240,9 @@ void BRepExtrema_DistanceSS::Perform( if (classifier.State() == TopAbs_IN) { if (myDstRef > Dstmin) + { myDstRef = Dstmin; + } myModif = true; const BRepExtrema_SolutionElem Sol1(Dstmin, Pt1, diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCC.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCC.cxx index a2aaaa1c25..9107977aba 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCC.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCC.cxx @@ -33,7 +33,9 @@ BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2) { if (!BRep_Tool::IsGeometric(E2)) + { return; // protect against non-geometric type (e.g. polygon) + } double V1, V2; BRepAdaptor_Curve Curv(E2); myHC = new BRepAdaptor_Curve(Curv); @@ -49,7 +51,9 @@ void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2) void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1) { if (!BRep_Tool::IsGeometric(E1)) + { return; // protect against non-geometric type (e.g. polygon) + } double U1, U2; BRepAdaptor_Curve Curv(E1); occ::handle HC = new BRepAdaptor_Curve(Curv); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCF.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCF.cxx index 8a5ba18bdc..65eeac8052 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCF.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtCF.cxx @@ -37,7 +37,9 @@ void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F) { BRepAdaptor_Surface Surf(F); if (Surf.GetType() == GeomAbs_OtherSurface || !BRep_Tool::IsGeometric(E)) + { return; // protect against non-geometric type (e.g. triangulation) + } BRepAdaptor_Curve aC(E); myHS = new BRepAdaptor_Surface(Surf); double aTolC, aTolS; @@ -64,7 +66,9 @@ void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2) myPointsOnC.Clear(); if (myHS.IsNull()) + { return; // protect against non-geometric type (e.g. triangulation) + } double U1, U2; BRep_Tool::Range(E, U1, U2); @@ -74,10 +78,14 @@ void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2) myExtCS.Perform(*HC, U1, U2); if (!myExtCS.IsDone()) + { return; + } if (myExtCS.IsParallel()) + { mySqDist.Append(myExtCS.SquareDistance(1)); + } else { // Exploration of points and classification diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtFF.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtFF.cxx index 172954967b..3b81361b7d 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtFF.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtFF.cxx @@ -40,7 +40,9 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2) { BRepAdaptor_Surface Surf(F2); if (Surf.GetType() == GeomAbs_OtherSurface) + { return; // protect against non-geometric type (e.g. triangulation) + } myHS = new BRepAdaptor_Surface(Surf); double Tol = std::min(BRep_Tool::Tolerance(F2), Precision::Confusion()); @@ -61,7 +63,9 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2) BRepAdaptor_Surface Surf1(F1); if (myHS.IsNull() || Surf1.GetType() == GeomAbs_OtherSurface) + { return; // protect against non-geometric type (e.g. triangulation) + } occ::handle HS1 = new BRepAdaptor_Surface(Surf1); double Tol1 = std::min(BRep_Tool::Tolerance(F1), Precision::Confusion()); @@ -72,10 +76,14 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2) myExtSS.Perform(*HS1, U1, U2, V1, V2, Tol1); if (!myExtSS.IsDone()) + { return; + } if (myExtSS.IsParallel()) + { mySqDist.Append(myExtSS.SquareDistance(1)); + } else { // Exploration of points and classification diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPC.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPC.cxx index 33bb620022..41b5b7f944 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPC.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPC.cxx @@ -32,7 +32,9 @@ BRepExtrema_ExtPC::BRepExtrema_ExtPC(const TopoDS_Vertex& V, const TopoDS_Edge& void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E) { if (!BRep_Tool::IsGeometric(E)) + { return; // protect against non-geometric type (e.g. polygon) + } double U1, U2; myHC = new BRepAdaptor_Curve(E); double Tol = std::min(BRep_Tool::Tolerance(E), Precision::Confusion()); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPF.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPF.cxx index bfdf8fb781..2753724e94 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPF.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ExtPF.cxx @@ -48,7 +48,9 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace, mySurf.Initialize(TheFace, false); if (mySurf.GetType() == GeomAbs_OtherSurface) + { return; // protect against non-geometric type (e.g. triangulation) + } double Tol = std::min(BRep_Tool::Tolerance(TheFace), Precision::Confusion()); double aTolU, aTolV; @@ -70,7 +72,9 @@ void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Fac const gp_Pnt P = BRep_Tool::Pnt(TheVertex); if (mySurf.GetType() == GeomAbs_OtherSurface) + { return; // protect against non-geometric type (e.g. triangulation) + } myExtPS.Perform(P); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_Poly.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_Poly.cxx index 19420a8841..f1351a5010 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_Poly.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_Poly.cxx @@ -45,10 +45,14 @@ bool BRepExtrema_Poly::Distance(const TopoDS_Shape& S1, const TopoDS_Face& F = TopoDS::Face(exFace.Current()); Tr = BRep_Tool::Triangulation(F, L); if (!Tr.IsNull()) + { nbn1 += Tr->NbNodes(); + } } if (nbn1 == 0) + { return false; + } int nbn2 = 0; for (exFace.Init(S2, TopAbs_FACE); exFace.More(); exFace.Next()) @@ -56,10 +60,14 @@ bool BRepExtrema_Poly::Distance(const TopoDS_Shape& S1, const TopoDS_Face& F = TopoDS::Face(exFace.Current()); Tr = BRep_Tool::Triangulation(F, L); if (!Tr.IsNull()) + { nbn2 += Tr->NbNodes(); + } } if (nbn2 == 0) + { return false; + } int i, n; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityDistTool.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityDistTool.cxx index bc93418c67..fa8405a899 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityDistTool.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityDistTool.cxx @@ -116,7 +116,9 @@ void BRepExtrema_ProximityDistTool::goThroughtSet1(const BVH_Array3d& theVertice ComputeDistance(); if (!IsDone() && myProxDist < 0.) + { return; + } if (IsDone() && myDistance > myProxDist) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityValueTool.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityValueTool.cxx index 5bd39a2802..42f90fbba7 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityValueTool.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityValueTool.cxx @@ -82,7 +82,9 @@ void BRepExtrema_ProximityValueTool::LoadTriangleSets( static double calcEdgeRefinementStep(const TopoDS_Edge& theEdge, const int theNbNodes) { if (theNbNodes < 2) + { return 0; + } BRepAdaptor_Curve aBAC(theEdge); double aLen = GCPnts_AbscissaPoint::Length(aBAC); @@ -97,7 +99,9 @@ static double calcEdgeRefinementStep(const TopoDS_Edge& theEdge, const int theNb static double calcFaceRefinementStep(const TopoDS_Face& theFace, const int theNbTrg) { if (theNbTrg < 1) + { return 0; + } GProp_GProps props; BRepGProp::SurfaceProperties(theFace, props); @@ -219,7 +223,9 @@ double BRepExtrema_ProximityValueTool::computeProximityDist( aProxDistTool.Perform(); if (!aProxDistTool.IsDone()) + { return -1.; + } aProxDistTool.ProximityPoints(thePoint1, thePoint2); aProxDistTool.ProximityPointsStatus(thePointStatus1, thePointStatus2); @@ -250,7 +256,9 @@ bool BRepExtrema_ProximityValueTool::getEdgeAdditionalVertices( GCPnts_QuasiUniformAbscissa aGCPnts(aBAC, std::max(3, aNbSamplePoints)); if (!aGCPnts.IsDone()) + { return false; + } int aNbNodes = aGCPnts.NbPoints(); for (int aVertIdx = 2; aVertIdx < aNbNodes; ++aVertIdx) // don't add extreme points @@ -290,7 +298,9 @@ void BRepExtrema_ProximityValueTool::doRecurTrgSplit( double aTrgArea = 0.5 * aTrgSide1.CrossMagnitude(aTrgSide2); if (aTrgArea - theStep < Precision::SquareConfusion()) + { return; + } double aD[3]{theTrg[0].Distance(theTrg[1]), theTrg[1].Distance(theTrg[2]), @@ -525,11 +535,15 @@ bool BRepExtrema_ProximityValueTool::getShapesAdditionalVertices() void BRepExtrema_ProximityValueTool::Perform(double& theTolerance) { if (!myIsInitS1 || !myIsInitS2 || (myShapeType1 != myShapeType2)) + { return; + } // get vertices on shapes with refining a coarser mesh if it's needed if (!getShapesAdditionalVertices()) + { return; + } // max(min) dist from the 1st shape to the 2nd one BVH_Vec3d aP1_1, aP1_2; @@ -549,7 +563,9 @@ void BRepExtrema_ProximityValueTool::Perform(double& theTolerance) aPointStatus1_2); if (aProximityDist1 < 0.) + { return; + } // max(min) dist from the 2nd shape to t he 1st one BVH_Vec3d aP2_1, aP2_2; @@ -569,7 +585,9 @@ void BRepExtrema_ProximityValueTool::Perform(double& theTolerance) aPointStatus2_1); if (aProximityDist2 < 0.) + { return; + } // min dist of the two max(min) dists if (aProximityDist1 < aProximityDist2) @@ -608,7 +626,9 @@ NCollection_CellFilter_Action BRepExtrema_VertexInspector::Inspect(const int the aDz = myCurrent.Z() - aPnt.Z(); if ((aDx * aDx <= myTol) && (aDy * aDy <= myTol) && (aDz * aDz <= myTol)) + { myIsNeedAdd = false; + } return CellFilter_Keep; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ShapeProximity.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ShapeProximity.cxx index df9e48dfbf..52fb336c10 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ShapeProximity.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ShapeProximity.cxx @@ -36,7 +36,9 @@ static bool initSubShapes(const TopoDS_Shape& theShape, } if (theTriangleSet.IsNull()) + { theTriangleSet = new BRepExtrema_TriangleSet; + } return theTriangleSet->Init(theSubshapesList); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_TriangleSet.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_TriangleSet.cxx index d57c8f086f..ac2d15d65a 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_TriangleSet.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_TriangleSet.cxx @@ -220,9 +220,13 @@ bool BRepExtrema_TriangleSet::Init(const NCollection_DynamicArray& for (int aShapeIdx = 0; aShapeIdx < theShapes.Length() && isOK; ++aShapeIdx) { if (theShapes(aShapeIdx).ShapeType() == TopAbs_FACE) + { isOK = initFace(TopoDS::Face(theShapes(aShapeIdx)), aShapeIdx); + } else if (theShapes(aShapeIdx).ShapeType() == TopAbs_EDGE) + { isOK = initEdge(TopoDS::Edge(theShapes(aShapeIdx)), aShapeIdx); + } } int aNumTrg = static_cast(myTriangles.Size()); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp.cxx index 87e26ca64a..5249c10241 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp.cxx @@ -87,7 +87,9 @@ static gp_Pnt roughBaryCenter(const TopoDS_Shape& S) TopExp_Explorer ex; gp_XYZ xyz(0, 0, 0); for (ex.Init(S, TopAbs_VERTEX), i = 0; ex.More(); ex.Next(), i++) + { xyz += BRep_Tool::Pnt(TopoDS::Vertex(ex.Current())).XYZ(); + } if (i > 0) { xyz /= i; @@ -223,7 +225,9 @@ static double surfaceProperties(const TopoDS_Shape& S, BF.Load(F); bool IsNatRestr = (F.NbChildren() == 0); if (!IsNatRestr) + { BD.Init(F); + } if (Eps < 1.0) { G.Perform(BF, BD, Eps); @@ -239,9 +243,13 @@ static double surfaceProperties(const TopoDS_Shape& S, else { if (IsNatRestr) + { G.Perform(BF); + } else + { G.Perform(BF, BD); + } } Props.Add(G); #ifdef OCCT_DEBUG @@ -359,7 +367,9 @@ static double volumePropertiesFaces(const TopoDS_Shape& S, BF.Load(F); bool IsNatRestr = (F.NbChildren() == 0); if (!IsNatRestr) + { BD.Init(F); + } if (Eps < 1.0) { G.Perform(BF, BD, Eps); @@ -375,9 +385,13 @@ static double volumePropertiesFaces(const TopoDS_Shape& S, else { if (IsNatRestr) + { G.Perform(BF); + } else + { G.Perform(BF, BD); + } } Props.Add(G); #ifdef OCCT_DEBUG @@ -560,11 +574,15 @@ void BRepGProp::VolumeProperties(const TopoDS_Shape& S, continue; } if (BRep_Tool::IsClosed(Sh)) + { volumeProperties(Sh, Props, 1.0, SkipShared, UseTriangulation); + } } } else + { volumeProperties(S, Props, 1.0, SkipShared, UseTriangulation); + } } //================================================================================================= @@ -609,7 +627,9 @@ double BRepGProp::VolumeProperties(const TopoDS_Shape& S, } } else + { ErrorMax = volumeProperties(S, Props, Eps, SkipShared, false); + } #ifdef OCCT_DEBUG if (AffichEps) std::cout << "\n\n===================" << iErrorMax << ":\tMaxEpsVolume = " << ErrorMax << "\n"; @@ -680,7 +700,9 @@ static double volumePropertiesGK(const TopoDS_Shape& theShape, bool IsNatRestr = (aFace.NbChildren() == 0); if (IsNatRestr) + { aLocalError = aVProps.Perform(aPropFace, aTol, CGFlag, IFlag); + } else { aPropDomain.Init(aFace); @@ -688,7 +710,9 @@ static double volumePropertiesGK(const TopoDS_Shape& theShape, } if (aLocalError < 0.) + { return aLocalError; + } anError += aLocalError; theProps.Add(aVProps); @@ -736,11 +760,15 @@ double BRepGProp::VolumePropertiesGK(const TopoDS_Shape& S, BRepCheck_Status aStatus = aChecker.Closed(false); if (aStatus == BRepCheck_NoError) + { aClosedShells.Append(aShell); + } } if (aClosedShells.IsEmpty()) + { return -1.; + } // Compute the properties for each closed shell. double aTol = Eps; @@ -754,17 +782,23 @@ double BRepGProp::VolumePropertiesGK(const TopoDS_Shape& S, aLocalError = volumePropertiesGK(aShell, Props, aTol, IsUseSpan, CGFlag, IFlag, SkipShared); if (aLocalError < 0) + { return aLocalError; + } anError += aLocalError; } } else + { anError = volumePropertiesGK(S, Props, Eps, IsUseSpan, CGFlag, IFlag, SkipShared); + } double vol = Props.Mass(); if (vol > Epsilon(1.)) + { anError /= vol; + } return anError; } @@ -829,7 +863,9 @@ static double volumePropertiesGK(const TopoDS_Shape& theShape, bool IsNatRestr = (aFace.NbChildren() == 0); if (IsNatRestr) + { aLocalError = aVProps.Perform(aPropFace, thePln, aTol, CGFlag, IFlag); + } else { aPropDomain.Init(aFace); @@ -837,7 +873,9 @@ static double volumePropertiesGK(const TopoDS_Shape& theShape, } if (aLocalError < 0.) + { return aLocalError; + } anError += aLocalError; theProps.Add(aVProps); @@ -886,11 +924,15 @@ double BRepGProp::VolumePropertiesGK(const TopoDS_Shape& S, BRepCheck_Status aStatus = aChecker.Closed(false); if (aStatus == BRepCheck_NoError) + { aClosedShells.Append(aShell); + } } if (aClosedShells.IsEmpty()) + { return -1.; + } // Compute the properties for each closed shell. double aTol = Eps; @@ -905,17 +947,23 @@ double BRepGProp::VolumePropertiesGK(const TopoDS_Shape& S, volumePropertiesGK(aShell, Props, thePln, aTol, IsUseSpan, CGFlag, IFlag, SkipShared); if (aLocalError < 0) + { return aLocalError; + } anError += aLocalError; } } else + { anError = volumePropertiesGK(S, Props, thePln, Eps, IsUseSpan, CGFlag, IFlag, SkipShared); + } double vol = Props.Mass(); if (vol > Epsilon(1.)) + { anError /= vol; + } return anError; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Cinert.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Cinert.cxx index 04275b87e6..f8abb7c633 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Cinert.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Cinert.cxx @@ -146,9 +146,13 @@ void BRepGProp_Cinert::Perform(const BRepAdaptor_Curve& C) inertia = gp_Mat(gp_XYZ(Ixx, -Ixy, -Ixz), gp_XYZ(-Ixy, Iyy, -Iyz), gp_XYZ(-Ixz, -Iyz, Izz)); if (std::abs(dim) < gp::Resolution()) + { g = P; + } else + { g.SetCoord(Ix / dim, Iy / dim, Iz / dim); + } } BRepGProp_Cinert::BRepGProp_Cinert(const BRepAdaptor_Curve& C, const gp_Pnt& CLocation) diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Domain.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Domain.cxx index b417a5aa12..517a45e90c 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Domain.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Domain.cxx @@ -31,7 +31,9 @@ void BRepGProp_Domain::Next() { TopAbs_Orientation Or = myExplorer.Current().Orientation(); if ((Or == TopAbs_FORWARD) || (Or == TopAbs_REVERSED)) + { return; + } myExplorer.Next(); } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Face.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Face.cxx index 6f6703f1f6..343e0d6eca 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Face.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Face.cxx @@ -204,7 +204,9 @@ void BRepGProp_Face::Normal(const double U, const double V, gp_Pnt& P, gp_Vec& V mySurface.D1(U, V, P, D1U, D1V); VNor = D1U.Crossed(D1V); if (mySReverse) + { VNor.Reverse(); + } } // APO 17.04.2002 (OCC104) @@ -359,7 +361,9 @@ void BRepGProp_Face::UKnots(NCollection_Array1& Knots) const const NCollection_Array1& aSrcKnots = (*((occ::handle*)&((mySurface.GeomSurfaceOriginal()))))->UKnots(); for (int i = Knots.Lower(); i <= Knots.Upper(); i++) + { Knots(i) = aSrcKnots(i); + } } break; default: @@ -396,7 +400,9 @@ void BRepGProp_Face::VKnots(NCollection_Array1& Knots) const const NCollection_Array1& aSrcKnots = (*((occ::handle*)&((mySurface.GeomSurfaceOriginal()))))->VKnots(); for (int i = Knots.Lower(); i <= Knots.Upper(); i++) + { Knots(i) = aSrcKnots(i); + } } break; default: @@ -515,7 +521,9 @@ void BRepGProp_Face::LKnots(NCollection_Array1& Knots) const const NCollection_Array1& aSrcKnots = (*((occ::handle*)&(myCurve.Curve())))->Knots(); for (int i = Knots.Lower(); i <= Knots.Upper(); i++) + { Knots(i) = aSrcKnots(i); + } } break; default: @@ -570,7 +578,9 @@ void BRepGProp_Face::Load(const bool IsFirstParam, const GeomAbs_IsoType theIsoT } } else + { return; + } occ::handle aLin = new Geom2d_Line(aLoc, aDir); @@ -593,17 +603,25 @@ static void GetRealKnots(const double theMin, while (++i < iU) { if (aStartI == 0 && theKnots->Value(i) > theMin + aTol) + { aStartI = i; + } if (aEndI == 0 && theKnots->Value(i + 1) > theMax - aTol) + { aEndI = i; + } if (aStartI != 0 && aEndI != 0) + { break; + } } if (aStartI == 0) + { aStartI = iU; + } int aNbNode = std::max(0, aEndI - aStartI + 1) + 2; int j; @@ -613,7 +631,9 @@ static void GetRealKnots(const double theMin, theRealKnots->SetValue(aNbNode, theMax); for (i = 2, j = aStartI; j <= aEndI; i++, j++) + { theRealKnots->SetValue(i, theKnots->Value(j)); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Gauss.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Gauss.cxx index ff2b8bb080..853f746f75 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Gauss.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_Gauss.cxx @@ -43,33 +43,49 @@ static double AddInf(const double theA, const double theB) if (Precision::IsPositiveInfinite(theA)) { if (Precision::IsNegativeInfinite(theB)) + { return 0.0; + } else + { return Precision::Infinite(); + } } if (Precision::IsPositiveInfinite(theB)) { if (Precision::IsNegativeInfinite(theA)) + { return 0.0; + } else + { return Precision::Infinite(); + } } if (Precision::IsNegativeInfinite(theA)) { if (Precision::IsPositiveInfinite(theB)) + { return 0.0; + } else + { return -Precision::Infinite(); + } } if (Precision::IsNegativeInfinite(theB)) { if (Precision::IsPositiveInfinite(theA)) + { return 0.0; + } else + { return -Precision::Infinite(); + } } return theA + theB; @@ -82,39 +98,57 @@ static double Mult(const double theA, const double theB) static double MultInf(const double theA, const double theB) { - if ((theA == 0.0) || (theB == 0.0)) // strictly zerro (without any tolerances) + if ((theA == 0.0) || (theB == 0.0)) + { // strictly zerro (without any tolerances) return 0.0; + } if (Precision::IsPositiveInfinite(theA)) { if (theB < 0.0) + { return -Precision::Infinite(); + } else + { return Precision::Infinite(); + } } if (Precision::IsPositiveInfinite(theB)) { if (theA < 0.0) + { return -Precision::Infinite(); + } else + { return Precision::Infinite(); + } } if (Precision::IsNegativeInfinite(theA)) { if (theB < 0.0) + { return +Precision::Infinite(); + } else + { return -Precision::Infinite(); + } } if (Precision::IsNegativeInfinite(theB)) { if (theA < 0.0) + { return +Precision::Infinite(); + } else + { return -Precision::Infinite(); + } } return theA * theB; @@ -174,7 +208,9 @@ void BRepGProp_Gauss::Init(NCollection_Handle& theOutVec, else { for (int i = theFirst; i <= theLast; ++i) + { theOutVec->Value(i) = theValue; + } } } @@ -186,7 +222,9 @@ void BRepGProp_Gauss::InitMass(const double theValue, InertiaArray& theArray) { if (theArray.IsNull()) + { return; + } int aFirst = theFirst; int aLast = theLast; @@ -198,7 +236,9 @@ void BRepGProp_Gauss::InitMass(const double theValue, } for (int i = aFirst; i <= aLast; ++i) + { theArray->ChangeValue(i).Mass = theValue; + } } //================================================================================================= @@ -223,7 +263,9 @@ int BRepGProp_Gauss::FillIntervalBounds(const double theA, theError = new math_Vector(1, aSize, 0.0); if (!theCommonError.IsNull()) + { theCommonError = new math_Vector(1, aSize, 0.0); + } } int j = 1, k = 1; @@ -241,7 +283,9 @@ int BRepGProp_Gauss::FillIntervalBounds(const double theA, theParam2->Value(k++) = kn; } else + { break; + } } } @@ -688,21 +732,31 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, Dul = Vuv.Y() * LGaussW[iGL]->Value(iL); // Dul = Du / Dl if (std::abs(Dul) < EPS_PARAM) + { continue; + } v = Puv.Y(); u2 = Puv.X(); // Check on cause out off bounds of value current parameter if (v < BV1) + { v = BV1; + } else if (v > BV2) + { v = BV2; + } if (u2 < BU1) + { u2 = BU1; + } else if (u2 > BU2) + { u2 = BU2; + } } ErrUL->Value(iLS) = 0.0; @@ -710,7 +764,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, JU = 0; if (std::abs(u2 - u1) < EPS_PARAM) + { continue; + } NCollection_Handle aDummy; iUSubEnd = @@ -718,7 +774,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, UMaxSubs = BRepGProp_Gauss::MaxSubs(iUSubEnd); if (UMaxSubs > SM) + { UMaxSubs = SM; + } BRepGProp_Gauss::InitMass(0.0, 1, UMaxSubs, anInertiaU); BRepGProp_Gauss::Init(ErrU, 0.0, 1, UMaxSubs); @@ -736,9 +794,12 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, U2->Value(IU) = U1->Value(JU); } else + { URange[0] = IU = JU; + } if (JU == UMaxSubs || std::abs(U2->Value(JU) - U1->Value(JU)) < EPS_PARAM) + { if (kUEnd == 1) { ErrU->Value(JU) = 0.0; @@ -752,6 +813,7 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, EpsL = 0.9 * Eps; break; } + } else { gp_Pnt aPoint; @@ -789,7 +851,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, else { if (iGU > 0) + { aLocal[iGU].Mass += (w * aNormal.Magnitude()); + } else { computeSInertiaOfElementaryPart(aPoint, @@ -814,7 +878,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, } if (iGL > 0) + { continue; + } double aDMass = std::abs(aLocal[1].Mass - aLocal[0].Mass); @@ -873,7 +939,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, } if (iGL > 0) + { continue; + } ErrUL->Value(iLS) = ErrorU * std::abs((u2 - u1) * Dul); @@ -941,7 +1009,9 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, double DDim = 0.0; for (i = 1; i <= JL; ++i) + { DDim += anInertiaL->Value(i).Mass; + } #ifndef IS_MIN_DIM { @@ -985,15 +1055,21 @@ double BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface, } if (isNaturalRestriction) + { break; + } theDomain.Next(); } if (myType == Vinert) + { convert(anInertia, theCoeff, theIsByPoint, theOutGravityCenter, theOutInertia, theOutMass); + } else + { convert(anInertia, theOutGravityCenter, theOutInertia, theOutMass); + } if (iGLEnd == 2) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_MeshCinert.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_MeshCinert.cxx index 6ed865f5e4..4cb0bb0725 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_MeshCinert.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_MeshCinert.cxx @@ -124,9 +124,13 @@ void BRepGProp_MeshCinert::Perform(const NCollection_Array1& theNodes) inertia = gp_Mat(gp_XYZ(Ixx, -Ixy, -Ixz), gp_XYZ(-Ixy, Iyy, -Iyz), gp_XYZ(-Ixz, -Iyz, Izz)); if (std::abs(dim) < gp::Resolution()) + { g = P; + } else + { g.SetCoord(Ix / dim, Iy / dim, Iz / dim); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_TFunction.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_TFunction.cxx index 26f26ebd3f..083559aabc 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_TFunction.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_TFunction.cxx @@ -84,23 +84,31 @@ bool BRepGProp_TFunction::Value(const double X, double& F) if (myValueType == GProp_Mass) { if (myIsByPoint) + { aCoeff /= 3.; + } } else if (myValueType == GProp_CenterMassX || myValueType == GProp_CenterMassY || myValueType == GProp_CenterMassZ) { if (myIsByPoint) + { aCoeff *= 0.25; + } } else if (myValueType == GProp_InertiaXX || myValueType == GProp_InertiaYY || myValueType == GProp_InertiaZZ || myValueType == GProp_InertiaXY || myValueType == GProp_InertiaXZ || myValueType == GProp_InertiaYZ) { if (myIsByPoint) + { aCoeff *= 0.2; + } } else + { return false; + } double aAbsCoeff = std::abs(aCoeff); @@ -134,12 +142,16 @@ bool BRepGProp_TFunction::Value(const double X, double& F) double aU2 = aUKnots->Value(i); if (aU2 - aU1 < tolU) + { continue; + } anIntegral.Perform(myUFunction, aU1, aU2, aNbPntsStart, aTol, aNbMaxIter); if (!anIntegral.IsDone()) + { return false; + } F += anIntegral.Value(); aLocalErr += anIntegral.AbsolutError(); @@ -154,7 +166,9 @@ bool BRepGProp_TFunction::Value(const double X, double& F) myTolReached += aLocalErr; if (std::abs(F) > Epsilon(1.)) + { aLocalErr /= std::abs(F); + } myErrReached = std::max(myErrReached, aLocalErr); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_UFunction.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_UFunction.cxx index 3146ce925c..d0fd37690a 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_UFunction.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_UFunction.cxx @@ -54,13 +54,17 @@ bool BRepGProp_UFunction::Value(const double X, double& F) // Center of mass computation if (myValueType == GProp_CenterMassX || myValueType == GProp_CenterMassY || myValueType == GProp_CenterMassZ) + { return CenterMassValue(X, F); + } // Inertia computation if (myValueType == GProp_InertiaXX || myValueType == GProp_InertiaYY || myValueType == GProp_InertiaZZ || myValueType == GProp_InertiaXY || myValueType == GProp_InertiaXZ || myValueType == GProp_InertiaYZ) + { return InertiaValue(X, F); + } return false; } @@ -84,7 +88,9 @@ double BRepGProp_UFunction::VolumeValue(const double X, // Volume computation for ByPoint mode. if (myIsByPoint) + { return thePMP0.Dot(aNorm.XYZ()); + } // Volume and additional coefficients computation for ByPlane mode. const double* aCoeff = myCoeffs; @@ -189,9 +195,13 @@ bool BRepGProp_UFunction::InertiaValue(const double X, double& F) if (myValueType == GProp_InertiaXX || myValueType == GProp_InertiaYY || myValueType == GProp_InertiaZZ) + { F *= aParam1 * aParam1 + aParam2 * aParam2; + } else + { F *= -aParam1 * aParam2; + } return true; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_VinertGK.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_VinertGK.cxx index c21dffba59..a19c717d17 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_VinertGK.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepGProp/BRepGProp_VinertGK.cxx @@ -271,13 +271,17 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, // If the pointer to the domain is NULL, there is only one curve to treat: // U isoline with the UMax parameter. if (thePtrDomain == nullptr) + { aNbCurves = 1; + } else { aPDomain = (BRepGProp_Domain*)thePtrDomain; for (aPDomain->Init(); aPDomain->More(); aPDomain->Next()) + { aNbCurves++; + } } if (aNbCurves == 0) @@ -333,7 +337,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, theSurface.Bounds(aUMin, aUMax, aTMin, aTMax); if (thePtrDomain == nullptr) + { isMore = true; + } else { aPDomain->Init(); @@ -346,9 +352,13 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, // U isoline with the UMax parameter. if (thePtrDomain == nullptr) + { theSurface.Load(false, GeomAbs_IsoU); + } else + { theSurface.Load(aPDomain->Value()); + } aTMin = theSurface.FirstParameter(); aTMax = theSurface.LastParameter(); @@ -377,7 +387,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, { if (!CFlags(k)) + { continue; + } int i = aTKnots->Lower(); @@ -429,7 +441,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, double aT2 = aTKnots->Value(i); if (aT2 - aT1 < aTTol) + { continue; + } aTFunc.SetNbKronrodPoints(aNbPnts); aTFunc.Init(); @@ -459,7 +473,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, // If the pointer to the domain is NULL, there is only one curve to treat: // U isoline with the UMax parameter. if (thePtrDomain == nullptr) + { isMore = false; + } else { aPDomain->Next(); @@ -474,7 +490,9 @@ double BRepGProp_VinertGK::PrivatePerform(BRepGProp_Face& theSurface, double anAbsDim = std::abs(dim); double aVolTol = Epsilon(myAbsolutError); if (anAbsDim >= aVolTol) + { myErrorReached /= anAbsDim; + } if (theCGFlag || theIFlag) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx index e4b98ba05d..3030046b65 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx @@ -83,7 +83,9 @@ void BRepIntCurveSurface_Inter::Load(const TopoDS_Shape& theShape, const double myTolerance = theTol; TopExp_Explorer explorer(theShape, TopAbs_FACE); for (; explorer.More(); explorer.Next()) + { myFaces.Append(explorer.Current()); + } } //================================================================================================= @@ -114,7 +116,9 @@ bool BRepIntCurveSurface_Inter::More() const void BRepIntCurveSurface_Inter::Next() { if (myCurrentnbpoints) + { myCurrentindex++; + } Find(); } @@ -123,7 +127,9 @@ void BRepIntCurveSurface_Inter::Next() void BRepIntCurveSurface_Inter::Find() { if (myCurrentnbpoints && myCurrentindex <= myCurrentnbpoints && FindPoint()) + { return; + } myCurrentnbpoints = 0; myCurrentindex = 0; @@ -133,7 +139,9 @@ void BRepIntCurveSurface_Inter::Find() { TopoDS_Shape aCurface = myFaces(i); if (myFaceBoxes.IsNull()) + { myFaceBoxes = new NCollection_HArray1(1, myFaces.Length()); + } Bnd_Box& aFaceBox = myFaceBoxes->ChangeValue(i); if (aFaceBox.IsVoid()) { @@ -144,19 +152,25 @@ void BRepIntCurveSurface_Inter::Find() ? aFaceBox.IsOut(myCurve->Line()) : (!myCurveBox.IsVoid() ? aFaceBox.IsOut(myCurveBox) : false)); if (isOut) + { continue; + } occ::handle aSurfForFastClass = new BRepAdaptor_Surface(TopoDS::Face(aCurface)); myIntcs.Perform(myCurve, aSurfForFastClass); myCurrentnbpoints = myIntcs.NbPoints(); if (!myCurrentnbpoints) + { continue; + } const occ::handle& aSurf = aSurfForFastClass; // to avoid ambiguity myFastClass->Initialize(aSurf); myIndFace = i; if (FindPoint()) + { return; + } myCurrentnbpoints = 0; } @@ -197,7 +211,9 @@ bool BRepIntCurveSurface_Inter::FindPoint() IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } const IntCurveSurface_IntersectionPoint& ICPS = myIntcs.Point(myCurrentindex); return (IntCurveSurface_IntersectionPoint(ICPS.Pnt(), myCurrentU, // ICPS.U(), @@ -212,7 +228,9 @@ IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const double BRepIntCurveSurface_Inter::U() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } //-- return(myIntcs.Point(myCurrentindex).U()); return (myCurrentU); } @@ -222,7 +240,9 @@ double BRepIntCurveSurface_Inter::U() const double BRepIntCurveSurface_Inter::V() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } //-- return(myIntcs.Point(myCurrentindex).V()); return (myCurrentV); } @@ -232,7 +252,9 @@ double BRepIntCurveSurface_Inter::V() const double BRepIntCurveSurface_Inter::W() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } return (myIntcs.Point(myCurrentindex).W()); } @@ -241,7 +263,9 @@ double BRepIntCurveSurface_Inter::W() const TopAbs_State BRepIntCurveSurface_Inter::State() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } //-- return(classifier.State()); return (myCurrentstate); } @@ -251,7 +275,9 @@ TopAbs_State BRepIntCurveSurface_Inter::State() const IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } return (myIntcs.Point(myCurrentindex).Transition()); } @@ -267,6 +293,8 @@ const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const const gp_Pnt& BRepIntCurveSurface_Inter::Pnt() const { if (myCurrentindex == 0) + { throw StdFail_NotDone(); + } return (myIntcs.Point(myCurrentindex).Pnt()); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib.cxx index f946628b6d..dfcd49f46b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib.cxx @@ -138,7 +138,9 @@ void BRepLib::Plane(const occ::handle& P) const occ::handle& BRepLib::Plane() { if (thePlane.IsNull()) + { thePlane = new Geom_Plane(gp::XOY()); + } return thePlane; } @@ -272,7 +274,9 @@ static int evaluateMaxSegment(const int aMaxSegment, const Adaptor3d_CurveOnSurface& aCurveOnSurface) { if (aMaxSegment != 0) + { return aMaxSegment; + } const occ::handle& aSurf = aCurveOnSurface.GetSurface(); const occ::handle& aCurv2d = aCurveOnSurface.GetCurve(); @@ -316,7 +320,9 @@ bool BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, const occ::handle C = BRep_Tool::Curve(AnEdge, LocalLoc, f, l); if (!C.IsNull()) + { return true; + } // // this should not exists but UpdateEdge makes funny things // if the edge is not same range @@ -355,7 +361,9 @@ bool BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, gp_Ax2 axes = P->Position().Ax2(); occ::handle C3d = GeomLib::To3d(axes, PC); if (C3d.IsNull()) + { return false; + } // update the edge double First, Last; @@ -426,7 +434,9 @@ bool BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, // max_deviation = std::max(tolerance, max_deviation) ; max_deviation = std::max(tolerance, Tolerance); if (NewCurvePtr.IsNull()) + { return false; + } B.UpdateEdge(TopoDS::Edge(AnEdge), NewCurvePtr, L[0], max_deviation); if (jj == 1) { @@ -496,10 +506,14 @@ bool BRepLib::UpdateEdgeTol(const TopoDS_Edge& AnEdge, occ::handle geometric_representation_ptr; if (BRep_Tool::Degenerated(AnEdge)) + { return false; + } coded_edge_tolerance = BRep_Tool::Tolerance(AnEdge); if (coded_edge_tolerance > MaxToleranceToCheck) + { return false; + } const occ::handle& TE = *((occ::handle*)&AnEdge.TShape()); NCollection_List>& list_curve_rep = TE->ChangeCurves(); @@ -715,7 +729,9 @@ static void GetEdgeTol(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, d { const occ::handle& cr = itcr.Value(); if (cr->IsCurveOnSurface(S, l)) + { return; + } itcr.Next(); } @@ -723,9 +739,13 @@ static void GetEdgeTol(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, d occ::handle GRTS; GRTS = occ::down_cast(S); if (!GRTS.IsNull()) + { GP = occ::down_cast(GRTS->BasisSurface()); + } else + { GP = occ::down_cast(S); + } occ::handle HC = new GeomAdaptor_Curve(); occ::handle HS = new GeomAdaptor_Surface(); @@ -764,7 +784,9 @@ static void GetEdgeTol(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, d temp = 0.; } if (temp > d2) + { d2 = temp; + } } d2 = 1.05 * sqrt(d2); theEdTol = d2; @@ -782,19 +804,29 @@ static void UpdTolMap( TopAbs_ShapeEnum aSt = theSh.ShapeType(); double aShTol; if (aSt == TopAbs_VERTEX) + { aShTol = BRep_Tool::Tolerance(TopoDS::Vertex(theSh)); + } else if (aSt == TopAbs_EDGE) + { aShTol = BRep_Tool::Tolerance(TopoDS::Edge(theSh)); + } else + { return; + } // if (theNewTol > aShTol) { const double* anOldtol = theShToTol.Seek(theSh); if (!anOldtol) + { theShToTol.Bind(theSh, theNewTol); + } else + { theShToTol(theSh) = std::max(*anOldtol, theNewTol); + } } } @@ -820,14 +852,18 @@ static void UpdShTol( const TopoDS_Shape& aVsh = theReshaper.Value(aSh); bool UseOldSh = IsMutableInput || theReshaper.IsNewShape(aSh) || !aVsh.IsSame(aSh); if (UseOldSh) + { aNsh = aVsh; + } else { aNsh = aSh.EmptyCopied(); // add subshapes from the original shape TopoDS_Iterator sit(aSh); for (; sit.More(); sit.Next()) + { aB.Add(aNsh, sit.Value()); + } // aNsh.Free(aSh.Free()); aNsh.Checked(aSh.Checked()); @@ -851,9 +887,13 @@ static void UpdShTol( case TopAbs_VERTEX: { const occ::handle& aTV = *((occ::handle*)&aNsh.TShape()); if (theVForceUpdate) + { aTV->Tolerance(aTol); + } else + { aTV->UpdateTolerance(aTol); + } aTV->Modified(true); break; } @@ -862,7 +902,9 @@ static void UpdShTol( } // if (!UseOldSh) + { theReshaper.Replace(aSh, aNsh); + } } } @@ -893,7 +935,9 @@ static void InternalSameParameter(const TopoDS_Shape& theSh, aNE = TopoDS::Edge(aCE.EmptyCopied()); TopoDS_Iterator sit(aCE); for (; sit.More(); sit.Next()) + { aB.Add(aNE, sit.Value()); + } theReshaper.Replace(aCE, aNE); UseOldEdge = true; } @@ -903,16 +947,22 @@ static void InternalSameParameter(const TopoDS_Shape& theSh, double aNewTol = -1; TopoDS_Edge aResEdge = BRepLib::SameParameter(aNE, theTol, aNewTol, UseOldEdge); if (!UseOldEdge && !aResEdge.IsNull()) + { // NE have been empty-copied theReshaper.Replace(aNE, aResEdge); + } if (aNewTol > 0) { TopoDS_Vertex aV1, aV2; TopExp::Vertices(aCE, aV1, aV2); if (!aV1.IsNull()) + { UpdTolMap(aV1, aNewTol, aShToTol); + } if (!aV2.IsNull()) + { UpdTolMap(aV2, aNewTol, aShToTol); + } } } ex.Next(); @@ -924,22 +974,30 @@ static void InternalSameParameter(const TopoDS_Shape& theSh, { const TopoDS_Face& curface = TopoDS::Face(ex.Current()); if (!Done.Add(curface)) + { continue; + } BS.Initialize(curface); if (BS.GetType() != GeomAbs_Plane) + { continue; + } TopExp_Explorer ex2; for (ex2.Init(curface, TopAbs_EDGE); ex2.More(); ex2.Next()) { const TopoDS_Edge& E = TopoDS::Edge(ex2.Current()); if (BRep_Tool::Degenerated(E)) + { continue; + } TopoDS_Shape aNe = theReshaper.Value(E); double aNewEtol = -1; GetEdgeTol(TopoDS::Edge(aNe), curface, aNewEtol); - if (aNewEtol >= 0) // not equal to -1 + if (aNewEtol >= 0) + { // not equal to -1 UpdTolMap(E, aNewEtol, aShToTol); + } } } @@ -998,7 +1056,9 @@ static bool EvalTol(const occ::handle& pc, { double dist2 = Projector.SquareDistance(); if (dist2 > tolbail * tolbail) + { tolbail = sqrt(dist2); + } ok++; } } @@ -1163,9 +1223,13 @@ void UpdateVTol(const TopoDS_Vertex& theV1, const TopoDS_Vertex& theV2, double t { BRep_Builder aB; if (!theV1.IsNull()) + { aB.UpdateVertex(theV1, theTol); + } if (!theV2.IsNull()) + { aB.UpdateVertex(theV2, theTol); + } } //================================================================================================= @@ -1190,14 +1254,18 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, bool IsUseOldEdge) { if (BRep_Tool::SameParameter(theEdge)) + { return TopoDS_Edge(); + } double f3d = 0., l3d = 0.; TopLoc_Location L3d; occ::handle C3d; NCollection_List> CList; GetCurve3d(theEdge, C3d, f3d, l3d, L3d, CList); if (C3d.IsNull()) + { return TopoDS_Edge(); + } BRep_Builder B; TopoDS_Edge aNE; @@ -1215,8 +1283,10 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, // clang-format on aNTE = *((occ::handle*)&aNE.TShape()); TopoDS_Iterator sit(theEdge); - for (; sit.More(); sit.Next()) // add vertices from old edge to the new ones + for (; sit.More(); sit.Next()) + { // add vertices from old edge to the new ones B.Add(aNE, sit.Value()); + } } NCollection_List>::Iterator It(CList); @@ -1250,9 +1320,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, if (!m_TrimmedPeriodical) { if (Udeb > f3d) + { f3d = Udeb; + } if (l3d > Ufin) + { l3d = Ufin; + } } // modified by NIZHNY-OCC486 Tue Aug 27 17:17:55 2002 . } @@ -1307,7 +1381,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, occ::handle curPC = PC[i]; bool updatepc = false; if (curPC.IsNull()) + { break; + } if (!SameRange) { GeomLib::SameRange(TolSameRange, PC[i], GCurve->First(), GCurve->Last(), f3d, l3d, curPC); @@ -1355,7 +1431,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, bs2d->D0(Knotbs2d(Index), NewOriginPoint); if (std::abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || std::abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion()) + { continue; + } bs2d->SetOrigin(Index); break; @@ -1405,7 +1483,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, bs2d->D0(Knotbs2d(Index), NewOriginPoint); if (std::abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || std::abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion()) + { continue; + } bs2d->SetOrigin(Index); break; @@ -1421,7 +1501,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, } } else + { goodpc = false; + } } if (goodpc) @@ -1470,12 +1552,18 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, dtmin = std::min(dtmin, dtcur); if (IsBad) + { continue; + } if (dtcur > dtprev) + { dtratio = dtcur / dtprev; + } else + { dtratio = dtprev / dtcur; + } if (dtratio > critratio) { IsBad = true; @@ -1487,7 +1575,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, // To avoid failures in Approx_CurvilinearParameter bs2d->Resolution(std::max(1.e-3, theTolerance), dtcur); if (dtmin < dtcur) + { IsBad = false; + } } } @@ -1497,10 +1587,14 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, // GeomAbs_Shape cont = bs2d->Continuity(); if (cont > GeomAbs_C2) + { cont = GeomAbs_C2; + } int maxdeg = bs2d->Degree(); if (maxdeg == 1) + { maxdeg = 14; + } Approx_CurvilinearParameter AppCurPar(HC2d, HS, std::max(1.e-3, theTolerance), @@ -1542,9 +1636,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, if (updatepc) { if (i == 0) + { GCurve->PCurve(curPC); + } else + { GCurve->PCurve2(curPC); + } } } else if (SameP.IsDone()) @@ -1563,9 +1661,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, if (updatepc) { if (i == 0) + { GCurve->PCurve(curPC); + } else + { GCurve->PCurve2(curPC); + } } } else @@ -1582,15 +1684,21 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, curPC); if (i == 0) + { GCurve->PCurve(curPC); + } else + { GCurve->PCurve2(curPC); + } IsSameP = false; } } else + { IsSameP = false; + } // Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin if (!IsSameP) @@ -1684,19 +1792,31 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, aB.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); dMax = 1.; if (!aB.IsOpenXmin() && !aB.IsOpenXmax()) + { dMax = aXmax - aXmin; + } if (!aB.IsOpenYmin() && !aB.IsOpenYmax()) + { aYmin = aYmax - aYmin; + } if (!aB.IsOpenZmin() && !aB.IsOpenZmax()) + { aZmin = aZmax - aZmin; + } if (aYmin > dMax) + { dMax = aYmin; + } if (aZmin > dMax) + { dMax = aZmin; + } tol = tol * dMax; // Do not process tolerances > 1. if (tol > 1.) + { tol = 0.99; + } } aShToTol.Bind(curf, tol); } @@ -1716,17 +1836,23 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, { const TopoDS_Face& FF = TopoDS::Face(lConx.Value()); double Ftol; - if (IsVerifyTolerance && aShToTol.IsBound(FF)) // first condition for speed-up + if (IsVerifyTolerance && aShToTol.IsBound(FF)) + { // first condition for speed-up Ftol = aShToTol(FF); + } else + { Ftol = BRep_Tool::Tolerance(FF); // tolerance have not been updated + } tol = std::max(tol, Ftol); } // Update can only increase tolerance, so if the edge has a greater // tolerance than its faces it is not concerned const TopoDS_Edge& EK = TopoDS::Edge(parents.FindKey(iCur)); if (tol > BRep_Tool::Tolerance(EK)) + { aShToTol.Bind(EK, tol); + } } // Vertices are processed @@ -1749,9 +1875,13 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, const double* aNtol = aShToTol.Seek(E); tol = std::max(tol, aNtol ? *aNtol : BRep_Tool::Tolerance(E)); if (tol > BigTol) + { continue; + } if (!BRep_Tool::SameRange(E)) + { continue; + } double par = BRep_Tool::Parameter(V, E); occ::handle& TE = *((occ::handle*)&E.TShape()); NCollection_List>::Iterator itcr(TE->Curves()); @@ -1771,7 +1901,9 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, p3d.Transform(L.Transformation()); double aDist = p3d.SquareDistance(aPV); if (aDist > aMaxDist) + { aMaxDist = aDist; + } } } else if (cr->IsCurveOnSurface()) @@ -1788,7 +1920,9 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, p3d.Transform(L.Transformation()); double aDist = p3d.SquareDistance(aPV); if (aDist > aMaxDist) + { aMaxDist = aDist; + } if (!PC2.IsNull()) { p2d = PC2->Value(par); @@ -1796,7 +1930,9 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, p3d.Transform(L.Transformation()); aDist = p3d.SquareDistance(aPV); if (aDist > aMaxDist) + { aMaxDist = aDist; + } } } itcr.Next(); @@ -1817,7 +1953,9 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, } //'Initialized' map is not used anywhere outside this block if (anUpdTol || toAdd) + { aShToTol.Bind(V, tol); + } } UpdShTol(aShToTol, IsMutableInput, theReshaper, true); @@ -1866,9 +2004,13 @@ void BRepLib::UpdateInnerTolerances(const TopoDS_Shape& aShape) occ::handle anHCurve = new BRepAdaptor_Curve(); anHCurve->Initialize(anEdge); if (!V1.IsNull()) + { Pnt1 = BRep_Tool::Pnt(V1); + } if (!V2.IsNull()) + { Pnt2 = BRep_Tool::Pnt(V2); + } if (!BRep_Tool::Degenerated(anEdge) && EFmap(i).Extent() > 0) { @@ -1901,7 +2043,9 @@ void BRepLib::UpdateInnerTolerances(const TopoDS_Shape& aShape) // aDist *= 1.1; aDist += 2. * Epsilon(aDist); if (aDist > MaxDist) + { MaxDist = aDist; + } // Update tolerances of vertices if (k == 0 && !V1.IsNull()) @@ -1950,7 +2094,9 @@ bool BRepLib::OrientClosedSolid(TopoDS_Solid& solid) solid.Reverse(); } else if (where.State() == TopAbs_ON || where.State() == TopAbs_UNKNOWN) + { return false; + } return true; } @@ -1989,10 +2135,14 @@ public: gp_Vec2d anOrtho(-myCurveTangent.Y(), myCurveTangent.X()); double aLen = anOrtho.Magnitude(); if (aLen < Precision::Confusion()) + { return aDeriv; + } anOrtho /= aLen; if (myIsReversed) + { anOrtho.Reverse(); + } aDeriv.SetLinearForm(anOrtho.X(), mySurfaceProps.D1U(), anOrtho.Y(), mySurfaceProps.D1V()); return aDeriv.Transformed(mySurfaceTrsf); @@ -2073,7 +2223,9 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, } } if (anEdgeInFace1.IsNull()) + { return GeomAbs_C0; + } aCurve1 = BRep_Tool::CurveOnSurface(anEdgeInFace1, aFace1, aFirst, aLast); TopoDS_Face aFace2 = theFace2; @@ -2089,12 +2241,16 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, aCurve1 = BRep_Tool::CurveOnSurface(anEdgeInFace1, theFace1, aFirst, aLast); // For the case of seam edge if (theFace1.IsSame(theFace2)) + { anEdgeInFace2.Reverse(); + } aCurve2 = BRep_Tool::CurveOnSurface(anEdgeInFace2, theFace2, aFirst, aLast); } if (aCurve1.IsNull() || aCurve2.IsNull()) + { return GeomAbs_C0; + } TopLoc_Location aLoc1, aLoc2; occ::handle aSurface1 = BRep_Tool::Surface(theFace1, aLoc1); @@ -2103,9 +2259,13 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, const gp_Trsf& aSurf2Trsf = aLoc2.Transformation(); if (aSurface1->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurface1 = occ::down_cast(aSurface1)->BasisSurface(); + } if (aSurface2->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { aSurface2 = occ::down_cast(aSurface2)->BasisSurface(); + } // seam edge on elementary surface is always CN bool isElementary = (aSurface1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) @@ -2161,13 +2321,19 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, { gp_Dir aNormal1 = aSP1.Normal(); if (theFace1.Orientation() == TopAbs_REVERSED) + { aNormal1.Reverse(); + } gp_Dir aNormal2 = aSP2.Normal(); if (theFace2.Orientation() == TopAbs_REVERSED) + { aNormal2.Reverse(); + } if (aNormal1 * aNormal2 < 0.) + { return GeomAbs_C0; + } } if (!isSmoothSuspect) @@ -2193,14 +2359,20 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, { aCurCont = GeomAbs_G1; if (std::abs(std::sqrt(aSqLen1) - std::sqrt(aSqLen2)) < Precision::Confusion() - && aDer1.Dot(aDer2) > Precision::SquareConfusion()) // <= check vectors are codirectional + && aDer1.Dot(aDer2) > Precision::SquareConfusion()) + { // <= check vectors are codirectional aCurCont = GeomAbs_C1; + } } else + { return GeomAbs_C0; + } if (aCont < GeomAbs_G2) + { continue; // no need further processing, because maximal continuity is less than G2 + } // Check conditions for G2 and C2 continuity: // * calculate principal curvatures on each surface @@ -2220,21 +2392,29 @@ GeomAbs_Shape BRepLib::ContinuityOfFaces(const TopoDS_Edge& theEdge, { if (aCurCont == GeomAbs_C1 && aCrvDir1[0].Dot(aCrvDir2[aStep]) > Precision::Confusion() && aCrvDir1[1].Dot(aCrvDir2[1 - aStep]) > Precision::Confusion()) + { aCurCont = GeomAbs_C2; + } else + { aCurCont = GeomAbs_G2; + } break; } } if (aCurCont < aCont) + { aCont = aCurCont; + } } // according to the list of supported elementary surfaces, // if the continuity is C2, than it is totally CN if (isElementary && aCont == GeomAbs_C2) + { aCont = GeomAbs_CN; + } return aCont; } @@ -2256,12 +2436,16 @@ static void EncodeRegularity( TopLoc_Location aNullLoc; aShape.Location(aNullLoc); // nullify location if (!theMap.Add(aShape)) + { return; // do not need to process shape twice + } if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) { for (TopoDS_Iterator it(aShape); it.More(); it.Next()) + { EncodeRegularity(it.Value(), theTolAng, theMap, theEdgesToEncode); + } return; } @@ -2286,7 +2470,9 @@ static void EncodeRegularity( TopoDS_Shape aPureEdge = E.Located(aNullLoc); aPureEdge.Orientation(TopAbs_FORWARD); if (!theEdgesToEncode.Contains(aPureEdge)) + { continue; + } } bool found = false; @@ -2322,7 +2508,9 @@ static void EncodeRegularity( } } if (found) + { BRepLib::EncodeRegularity(E, F1, F2, theTolAng); + } } } catch (Standard_Failure const& anException) @@ -2421,11 +2609,15 @@ bool BRepLib::EnsureNormalConsistency(const TopoDS_Shape& theShape, const TopoDS_Face& aFace = TopoDS::Face(anExpFace.Current()); const occ::handle aSurf = BRep_Tool::Surface(aFace); if (aSurf.IsNull()) + { continue; + } TopLoc_Location aLoc; const occ::handle& aPT = BRep_Tool::Triangulation(aFace, aLoc); if (aPT.IsNull()) + { continue; + } if (!theForceComputeNormals && aPT->HasNormals()) { isNormalsFound = true; @@ -2475,7 +2667,9 @@ bool BRepLib::EnsureNormalConsistency(const TopoDS_Shape& theShape, const TopoDS_Edge& anEdg = TopoDS::Edge(aMapEF.FindKey(anInd)); const NCollection_List& anEdgList = aMapEF.FindFromIndex(anInd); if (anEdgList.Extent() != 2) + { continue; + } NCollection_List::Iterator anItF(anEdgList); const TopoDS_Face aFace1 = TopoDS::Face(anItF.Value()); anItF.Next(); @@ -2485,10 +2679,14 @@ bool BRepLib::EnsureNormalConsistency(const TopoDS_Shape& theShape, const occ::handle& aPT2 = BRep_Tool::Triangulation(aFace2, aLoc2); if (aPT1.IsNull() || aPT2.IsNull()) + { continue; + } if (!aPT1->HasNormals() || !aPT2->HasNormals()) + { continue; + } const occ::handle& aPTEF1 = BRep_Tool::PolygonOnTriangulation(anEdg, aPT1, aLoc1); @@ -2497,7 +2695,9 @@ bool BRepLib::EnsureNormalConsistency(const TopoDS_Shape& theShape, if (aPTEF1->Nodes().Lower() != aPTEF2->Nodes().Lower() || aPTEF1->Nodes().Upper() != aPTEF2->Nodes().Upper()) + { continue; + } for (int anEdgNode = aPTEF1->Nodes().Lower(); anEdgNode <= aPTEF1->Nodes().Upper(); anEdgNode++) { @@ -2737,7 +2937,9 @@ void BRepLib::SortFaces(const TopoDS_Shape& Sh, NCollection_List& } } else + { LTri.Append(F); + } } LF.Append(LPlan); LF.Append(LCyl); @@ -2793,7 +2995,9 @@ void BRepLib::ReverseSortFaces(const TopoDS_Shape& Sh, NCollection_ListBounds(aSUMin, aSUMax, aSVMin, aSVMax); if (isExtUMin) + { aFUMin = aSUMin; + } if (isExtUMax) + { aFUMax = aSUMax; + } if (isExtVMin) + { aFVMin = aSVMin; + } if (isExtVMax) + { aFVMax = aSVMax; + } } BRepLib_MakeFace aMF(aS, aFUMin, aFUMax, aFVMin, aFVMax, aTol); theFExtended = *(TopoDS_Face*)&aMF.Shape(); if (theF.Orientation() == TopAbs_REVERSED) + { theFExtended.Reverse(); + } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_1.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_1.cxx index c843a9510a..05cc3357ce 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_1.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_1.cxx @@ -42,12 +42,16 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, double aStartU = theFirst; double anEndU = theLast; if (!isFirst) + { std::swap(aStartU, anEndU); + } gp_Pnt aP = theCurve.Value(aStartU); const double aSqTol = theTol * theTol; if (aP.SquareDistance(theVertPnt) > aSqTol) + { // the vertex does not cover the corresponding to this vertex end of the curve return false; + } // 2. Find a nearest point that is outside @@ -56,7 +60,9 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, // the general step is computed using general curve resolution double aStep = theCurve.Resolution(theTol) * 1.01; if (aStep < theEps) + { aStep = theEps; + } // aD1Mag is a threshold to consider local derivative magnitude too small // and to accelerate going out of sphere // (inverse of resolution is the maximal derivative); @@ -75,7 +81,9 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, aD1Mag *= aD1Mag; } if (!isFirst) + { aStep = -aStep; + } bool isOut = false; double anUIn = aStartU; double anUOut = anUIn; @@ -90,8 +98,10 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, aP = theCurve.Value(anEndU); isOut = (aP.SquareDistance(theVertPnt) > aSqTol); if (!isOut) + { // all range is inside sphere return false; + } anUOut = anEndU; break; } @@ -109,15 +119,19 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, aStepLocal *= 2.; anUOut += aStepLocal; if ((isFirst && anUOut < anEndU) || (!isFirst && anUOut > anEndU)) + { // still in range continue; + } // went out of range, so check if the end point has out state anUOut = anEndU; aP = theCurve.Value(anUOut); isOut = (aP.SquareDistance(theVertPnt) > aSqTol); if (!isOut) + { // all range is inside sphere return false; + } } break; } @@ -127,7 +141,9 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, aP = theCurve.Value(anUOut); } if (!isOut) + { isOut = (aP.SquareDistance(theVertPnt) > aSqTol); + } } // 3. Precise solution with binary search @@ -139,9 +155,13 @@ static bool findNearestValidPoint(const Adaptor3d_Curve& theCurve, aP = theCurve.Value(aMidU); isOut = (aP.SquareDistance(theVertPnt) > aSqTol); if (isOut) + { anUOut = aMidU; + } else + { anUIn = aMidU; + } aDelta = std::abs(anUOut - anUIn); } thePar = (anUIn + anUOut) * 0.5; @@ -162,21 +182,29 @@ bool BRepLib::FindValidRange(const Adaptor3d_Curve& theCurve, double& theLast) { if (theParV2 - theParV1 < Precision::PConfusion()) + { return false; + } bool isInfParV1 = Precision::IsInfinite(theParV1), isInfParV2 = Precision::IsInfinite(theParV2); double aMaxPar = 0.0; if (!isInfParV1) + { aMaxPar = std::abs(theParV1); + } if (!isInfParV2) + { aMaxPar = std::max(aMaxPar, std::abs(theParV2)); + } double anEps = std::max(std::max(theCurve.Resolution(theTolE) * 0.1, Epsilon(aMaxPar)), Precision::PConfusion()); if (isInfParV1) + { theFirst = theParV1; + } else { if (!findNearestValidPoint(theCurve, @@ -187,13 +215,19 @@ bool BRepLib::FindValidRange(const Adaptor3d_Curve& theCurve, theTolV1, anEps, theFirst)) + { return false; + } if (theParV2 - theFirst < anEps) + { return false; + } } if (isInfParV2) + { theLast = theParV2; + } else { if (!findNearestValidPoint(theCurve, @@ -204,9 +238,13 @@ bool BRepLib::FindValidRange(const Adaptor3d_Curve& theCurve, theTolV2, anEps, theLast)) + { return false; + } if (theLast - theParV1 < anEps) + { return false; + } } // check found parameters @@ -226,11 +264,15 @@ bool BRepLib::FindValidRange(const TopoDS_Edge& theEdge, double& theFirst, doubl TopLoc_Location aLoc; double f, l; if (BRep_Tool::Curve(theEdge, aLoc, f, l).IsNull()) + { return false; + } BRepAdaptor_Curve anAC(theEdge); double aParV[2] = {anAC.FirstParameter(), anAC.LastParameter()}; if (aParV[1] - aParV[0] < Precision::PConfusion()) + { return false; + } // get vertices TopoDS_Vertex aV[2]; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_Command.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_Command.cxx index 00f7cc2aef..873615c363 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_Command.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_Command.cxx @@ -38,7 +38,9 @@ bool BRepLib_Command::IsDone() const void BRepLib_Command::Check() const { if (!myDone) + { throw StdFail_NotDone("BRep_API: command not done"); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FindSurface.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FindSurface.cxx index 3fed5077d9..24537c7359 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FindSurface.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FindSurface.cxx @@ -60,7 +60,9 @@ static double Controle(const NCollection_Sequence& thePoints, const gp_XYZ& xyz = thePoints(ii).XYZ(); dist = std::abs(a * xyz.X() + b * xyz.Y() + c * xyz.Z() + d); if (dist > dfMaxDist) + { dfMaxDist = dist; + } } return dfMaxDist; @@ -188,14 +190,18 @@ static void fillParams(const NCollection_Array1& theKnots, ++i) { if (theKnots(i + 1) < theParMin + Precision::PConfusion()) + { continue; + } double aStep = (theKnots(i + 1) - theKnots(i)) / aNbP; for (int k = 1; k <= aNbP; ++k) { double aPar = theKnots(i) + k * aStep; if (aPar > theParMax - Precision::PConfusion()) + { break; + } if (aPar > aPrevPar + Precision::PConfusion()) { @@ -224,7 +230,9 @@ static void fillPoints(const BRepAdaptor_Curve& theCurve, aDistNext = aPPrev.Distance(aPNext); } else + { aDistNext = 0.0; + } thePoints.Append(aPPrev); theWeights.Append(aDistPrev + aDistNext); @@ -255,13 +263,17 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, { double t = BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())); if (t > myTolerance) + { myTolerance = t; + } } // search an existing surface ex.Init(S, TopAbs_EDGE); if (!ex.More()) + { return; // no edges .... + } TopoDS_Edge E = TopoDS::Edge(ex.Current()); double f, l, ff, ll; @@ -312,15 +324,21 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, if (OnlyPlane && !mySurface.IsNull()) { if (mySurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) + { mySurface = occ::down_cast(mySurface)->BasisSurface(); + } mySurface = occ::down_cast(mySurface); } if (!mySurface.IsNull()) + { // if S is e.g. the bottom face of a cylinder, mySurface can be the // lateral (cylindrical) face of the cylinder; reject an improper mySurface if (!OnlyClosed || Is2DClosed(S, mySurface, myLocation)) + { break; + } + } } if (!mySurface.IsNull()) @@ -388,7 +406,9 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, default: { // Put some points on other curves if (iNbPoints == 0) + { iNbPoints = 15 + c.NbIntervals(GeomAbs_C3); + } NCollection_Array1 aBounds(1, 2); aBounds.SetValue(1, dfUf); @@ -520,14 +540,18 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, } if (!isSolved) + { return; + } // Removing very small values double aMaxV = std::max(std::abs(aVec(1)), std::max(std::abs(aVec(2)), std::abs(aVec(3)))); double eps = Epsilon(aMaxV); for (i = 1; i <= 3; ++i) { if (std::abs(aVec(i)) <= eps) + { aVec(i) = 0.; + } } gp_Vec aN(aVec(1), aVec(2), aVec(3)); occ::handle aPlane = new Geom_Plane(aBaryCenter, aN); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FuseEdges.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FuseEdges.cxx index fe0ea94c9e..d3de01def8 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FuseEdges.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_FuseEdges.cxx @@ -82,7 +82,9 @@ static void BCSmoothing(occ::handle& theC, m = m - theCont; if (m < 1) + { return; + } aKnotIndex.Clear(); @@ -102,7 +104,9 @@ static void BCSmoothing(occ::handle& theC, int aNbAdd = aKnotIndex.Length(); if (aNbAdd == 0) + { return; + } aKnotIns.Clear(); @@ -139,9 +143,9 @@ static void BCSmoothing(occ::handle& theC, } if (iter > aNbIter) + { BCSmoothing(theC, theCont, 1.e10); - - return; + } } static void MakeClosedCurve(occ::handle& C, const gp_Pnt& PF, double& f, double& l) @@ -387,7 +391,9 @@ void BRepLib_FuseEdges::BuildListEdges() && (edgecur.Orientation() == TopAbs_FORWARD || edgecur.Orientation() == TopAbs_REVERSED)) { if (myAvoidEdg.Contains(edgecur)) + { continue; // edge is not allowed to be fused + } BuildListConnexEdge(edgecur, mapUniqEdg, LstEdg); if (LstEdg.Extent() > 1) { @@ -521,16 +527,22 @@ void BRepLib_FuseEdges::BuildListResultEdges() ME.Init(ExtC, VF, VL); if (!ME.IsDone()) + { throw Standard_ConstructionError("FuseEdges : Fusion failed"); + } } else + { throw Standard_ConstructionError("FuseEdges : Fusion failed"); + } } NewEdge = ME.Edge(); if (UpdatePCurve(OldEdge, NewEdge, LmapEdg)) + { myMapEdg.Bind(iLst, NewEdge); + } } myResultEdgesDone = true; @@ -557,7 +569,9 @@ void BRepLib_FuseEdges::Perform() { const int& iLst = itLstEdg.Key(); if (!myMapEdg.IsBound(iLst)) + { continue; + } const NCollection_List& LmapEdg = myMapLstEdg.Find(iLst); NCollection_List::Iterator itEdg; @@ -703,7 +717,9 @@ bool BRepLib_FuseEdges::NextConnexEdge(const TopoDS_Vertex& theVertex, } if (myAvoidEdg.Contains(theEdgeConnex)) + { HasConnex = false; // edge is not allowed to be fused + } // 2nd condition if (HasConnex) @@ -739,11 +755,15 @@ bool BRepLib_FuseEdges::NextConnexEdge(const TopoDS_Vertex& theVertex, } } else + { HasConnex = false; + } } } else + { HasConnex = false; + } return HasConnex; } @@ -767,7 +787,9 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2 // modified by NIZNHY-PKV Mon Nov 15 16:24:10 1999 // degenerated edges has no 3D curve if (C1.IsNull()) + { return false; + } if (!loc.IsIdentity()) { @@ -778,7 +800,9 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2 // modified by NIZNHY-PKV Mon Nov 15 16:24:38 1999 // degenerated edges has no 3D curve if (C2.IsNull()) + { return false; + } if (!loc.IsIdentity()) { @@ -869,13 +893,21 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2 C2->D1(l2, aPl2, aDl2); if (aPl1.Distance(aPf2) <= tollin && aDl1.IsParallel(aDf2, tolang)) + { return true; + } if (aPl2.Distance(aPf1) <= tollin && aDl2.IsParallel(aDf1, tolang)) + { return true; + } if (aPf1.Distance(aPf2) <= tollin && aDf1.IsParallel(aDf2, tolang)) + { return true; + } if (aPl1.Distance(aPl2) <= tollin && aDl1.IsParallel(aDl2, tolang)) + { return true; + } } // we must ensure that before fuse two bsplines, the end of one curve does not // corresponds to the beginning of the second. @@ -1086,9 +1118,13 @@ bool BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl aFFace.Orientation(TopAbs_FORWARD); occ::handle Curv2dR = BRep_Tool::CurveOnSurface(aFEdge, aFFace, cf, cl); if (Curv2d->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2d = occ::down_cast(Curv2d)->BasisCurve(); + } if (Curv2dR->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2dR = occ::down_cast(Curv2dR)->BasisCurve(); + } B.UpdateEdge(theNewEdge, Curv2d, Curv2dR, Surf, loc, BRep_Tool::Tolerance(theNewEdge)); } @@ -1096,7 +1132,9 @@ bool BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl { // update the new edge if (Curv2d->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { Curv2d = occ::down_cast(Curv2d)->BasisCurve(); + } double f, l; f = Curv2d->FirstParameter(); l = Curv2d->LastParameter(); @@ -1104,7 +1142,9 @@ bool BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl { occ::handle bcurve = occ::down_cast(Curv2d); if (bcurve.IsNull()) + { bcurve = new Geom2d_TrimmedCurve(Curv2d, cf, cl); + } Geom2dConvert_CompCurveToBSplineCurve Concat(bcurve); NCollection_List::Iterator iter(theLstEdg); iter.Next(); @@ -1115,10 +1155,14 @@ bool BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl occ::handle C = BRep_Tool::CurveOnSurface(E, Surf, loc, first, last); occ::handle BC = occ::down_cast(C); if (BC.IsNull()) + { BC = new Geom2d_TrimmedCurve(C, first, last); + } if (!Concat.Add(BC, Precision::PConfusion())) + { // cannot merge pcurves return false; + } } Curv2d = Concat.BSplineCurve(); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge.cxx index 0a6fb36178..8f78fc9ad2 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge.cxx @@ -527,9 +527,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, const gp_Pnt& P1, TopoDS_Vertex V1, V2; B.MakeVertex(V1, P1, Tol); if (P1.Distance(P2) < Tol) + { V2 = V1; + } else + { B.MakeVertex(V2, P2, Tol); + } Init(C, V1, V2); } @@ -545,14 +549,18 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, double p1, p2; if (V1.IsNull()) + { p1 = C->FirstParameter(); + } else if (!Project(C, V1, p1)) { myError = BRepLib_PointProjectionFailed; return; } if (V2.IsNull()) + { p2 = C->LastParameter(); + } else if (!Project(C, V2, p2)) { myError = BRepLib_PointProjectionFailed; @@ -576,9 +584,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, TopoDS_Vertex V1, V2; B.MakeVertex(V1, P1, Tol); if (P1.Distance(P2) < Tol) + { V2 = V1; + } else + { B.MakeVertex(V2, P2, Tol); + } Init(C, V1, V2, p1, p2); } @@ -657,9 +669,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, bool p2inf = Precision::IsPositiveInfinite(p2); gp_Pnt P1, P2; if (!p1inf) + { P1 = aCA.Value(p1); + } if (!p2inf) + { P2 = aCA.Value(p2); + } double preci = BRepLib::Precision(); BRep_Builder B; @@ -668,7 +684,9 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, bool closed = false; bool degenerated = false; if (!p1inf && !p2inf) + { closed = (P1.Distance(P2) <= preci); + } // check if the vertices are on the curve if (closed) @@ -679,9 +697,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, V2 = V1; } else if (V1.IsNull()) + { V1 = V2; + } else if (V2.IsNull()) + { V2 = V1; + } else { if (!V1.IsSame(V2)) @@ -698,7 +720,9 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, { gp_Pnt PM = aCA.Value((p1 + p2) / 2); if (P1.Distance(PM) < preci) + { degenerated = true; + } } } } @@ -805,9 +829,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, TopoDS_Vertex V1, V2; B.MakeVertex(V1, P1, Tol); if (P1.Distance(P2) < Tol) + { V2 = V1; + } else + { B.MakeVertex(V2, P2, Tol); + } Init(C, S, V1, V2); } @@ -824,14 +852,18 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, double p1, p2; if (V1.IsNull()) + { p1 = C->FirstParameter(); + } else if (!Project(C, S, V1, p1)) { myError = BRepLib_PointProjectionFailed; return; } if (V2.IsNull()) + { p2 = C->LastParameter(); + } else if (!Project(C, S, V2, p2)) { myError = BRepLib_PointProjectionFailed; @@ -856,9 +888,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& C, TopoDS_Vertex V1, V2; B.MakeVertex(V1, P1, Tol); if (P1.Distance(P2) < Tol) + { V2 = V1; + } else + { B.MakeVertex(V2, P2, Tol); + } Init(C, S, V1, V2, p1, p2); } @@ -950,7 +986,9 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, // check for closed curve bool closed = false; if (!p1inf && !p2inf) + { closed = (P1.Distance(P2) <= preci); + } // check if the vertices are on the curve if (closed) @@ -961,9 +999,13 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, V2 = V1; } else if (V1.IsNull()) + { V1 = V2; + } else if (V2.IsNull()) + { V2 = V1; + } else { if (!V1.IsSame(V2)) @@ -1045,7 +1087,9 @@ void BRepLib_MakeEdge::Init(const occ::handle& CC, B.Range(E, p1, p2); if (reverse) + { E.Orientation(TopAbs_REVERSED); + } myError = BRepLib_EdgeDone; Done(); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge2d.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge2d.cxx index 674320ea5b..1bdd30c7f4 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge2d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeEdge2d.cxx @@ -100,7 +100,9 @@ static bool Project(const occ::handle& C, const TopoDS_Vertex& V, } } else + { return false; + } } return true; } @@ -390,9 +392,13 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& C, TopoDS_Vertex V1, V2; B.MakeVertex(V1, Point(P1), Precision::Confusion()); if (P1.Distance(P2) < Precision::Confusion()) + { V2 = V1; + } else + { B.MakeVertex(V2, Point(P2), Precision::Confusion()); + } Init(C, V1, V2); } @@ -407,14 +413,18 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& C, double p1, p2; if (V1.IsNull()) + { p1 = C->FirstParameter(); + } else if (!Project(C, V1, p1)) { myError = BRepLib_PointProjectionFailed; return; } if (V2.IsNull()) + { p2 = C->LastParameter(); + } else if (!Project(C, V2, p2)) { myError = BRepLib_PointProjectionFailed; @@ -437,9 +447,13 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& C, TopoDS_Vertex V1, V2; B.MakeVertex(V1, Point(P1), Precision::Confusion()); if (P1.Distance(P2) < Precision::Confusion()) + { V2 = V1; + } else + { B.MakeVertex(V2, Point(P2), Precision::Confusion()); + } Init(C, V1, V2, p1, p2); } @@ -510,9 +524,13 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& CC, bool p2inf = Precision::IsPositiveInfinite(p2); gp_Pnt2d P1, P2; if (!p1inf) + { P1 = C->Value(p1); + } if (!p2inf) + { P2 = C->Value(p2); + } constexpr double preci = Precision::Confusion(); BRep_Builder B; @@ -520,7 +538,9 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& CC, // check for closed curve bool closed = false; if (!p1inf && !p2inf) + { closed = (P1.Distance(P2) <= preci); + } // check if the vertices are on the curve if (closed) @@ -531,9 +551,13 @@ void BRepLib_MakeEdge2d::Init(const occ::handle& CC, V2 = V1; } else if (V1.IsNull()) + { V1 = V2; + } else if (V2.IsNull()) + { V2 = V1; + } else { if (!V1.IsSame(V2)) diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeFace.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeFace.cxx index d8094bea1a..1e45b649f9 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeFace.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeFace.cxx @@ -252,7 +252,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, const bool OnlyPlane) BRepLib::SameParameter(myShape, tol, true); // if (BRep_Tool::IsClosed(aW)) + { CheckInside(); + } } //================================================================================================= @@ -263,7 +265,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P, const TopoDS_Wire& W, const Init(Pl, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -274,7 +278,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C, const TopoDS_Wire& W, c Init(GC, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -285,7 +291,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C, const TopoDS_Wire& W, const Init(GC, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -296,7 +304,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S, const TopoDS_Wire& W, con Init(GS, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -307,7 +317,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T, const TopoDS_Wire& W, cons Init(GT, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -319,7 +331,9 @@ BRepLib_MakeFace::BRepLib_MakeFace(const occ::handle& S, Init(S, false, Precision::Confusion()); Add(W); if (Inside && BRep_Tool::IsClosed(W)) + { CheckInside(); + } } //================================================================================================= @@ -388,7 +402,9 @@ bool BRepLib_MakeFace::IsDegenerated(const occ::handle& theCurve, { gp_Circ Circ = AC.Circle(); if (Circ.Radius() > theMaxTol) + { return false; + } theActTol = std::max(Circ.Radius(), aConfusion); return true; } @@ -404,9 +420,13 @@ bool BRepLib_MakeFace::IsDegenerated(const occ::handle& theCurve, P2 = BS->Pole(i); double aPoleDist2 = P1.SquareDistance(P2); if (aPoleDist2 > aMaxTol2) + { return false; + } if (aPoleDist2 > aMaxPoleDist2) + { aMaxPoleDist2 = aPoleDist2; + } } theActTol = std::max(1.000001 * std::sqrt(aMaxPoleDist2), aConfusion); return true; @@ -423,9 +443,13 @@ bool BRepLib_MakeFace::IsDegenerated(const occ::handle& theCurve, P2 = BZ->Pole(i); double aPoleDist2 = P1.SquareDistance(P2); if (aPoleDist2 > aMaxTol2) + { return false; + } if (aPoleDist2 > aMaxPoleDist2) + { aMaxPoleDist2 = aPoleDist2; + } } theActTol = std::max(1.000001 * std::sqrt(aMaxPoleDist2), aConfusion); return true; @@ -456,7 +480,9 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, occ::handle RS = occ::down_cast(S); if (!RS.IsNull()) + { BS = RS->BasisSurface(); + } bool OffsetSurface = (BS->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)); @@ -474,14 +500,20 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (Base->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) { if (Precision::IsInfinite(umin) || Precision::IsInfinite(umax)) + { S = new Geom_RectangularTrimmedSurface(OS, UMin, UMax, VMin, VMax); + } else + { S = new Geom_RectangularTrimmedSurface(OS, VMin, VMax, false); + } } else if (Base->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution)) { if (Precision::IsInfinite(vmin) || Precision::IsInfinite(vmax)) + { S = new Geom_RectangularTrimmedSurface(OS, VMin, VMax, false); + } } } @@ -567,16 +599,24 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (!umininf) { if (!vmininf) + { B.MakeVertex(V00, S->Value(UMin, VMin), std::max(uminTol, vminTol)); + } if (!vmaxinf) + { B.MakeVertex(V01, S->Value(UMin, VMax), std::max(uminTol, vmaxTol)); + } } if (!umaxinf) { if (!vmininf) + { B.MakeVertex(V10, S->Value(UMax, VMin), std::max(umaxTol, vminTol)); + } if (!vmaxinf) + { B.MakeVertex(V11, S->Value(UMax, VMax), std::max(umaxTol, vmaxTol)); + } } if (uclosed) @@ -592,24 +632,40 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, } if (Dumin) + { V00 = V01; + } if (Dumax) + { V10 = V11; + } if (Dvmin) + { V00 = V10; + } if (Dvmax) + { V01 = V11; + } // make the lines occ::handle Lumin, Lumax, Lvmin, Lvmax; if (!umininf) + { Lumin = new Geom2d_Line(gp_Pnt2d(UMin, 0), gp_Dir2d(gp_Dir2d::D::Y)); + } if (!umaxinf) + { Lumax = new Geom2d_Line(gp_Pnt2d(UMax, 0), gp_Dir2d(gp_Dir2d::D::Y)); + } if (!vmininf) + { Lvmin = new Geom2d_Line(gp_Pnt2d(0, VMin), gp_Dir2d(gp_Dir2d::D::X)); + } if (!vmaxinf) + { Lvmax = new Geom2d_Line(gp_Pnt2d(0, VMax), gp_Dir2d(gp_Dir2d::D::X)); + } // make the face TopoDS_Face& F = TopoDS::Face(myShape); @@ -621,13 +677,21 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (!umininf) { if (!Dumin) + { B.MakeEdge(eumin, Cumin, uminTol); + } else + { B.MakeEdge(eumin); + } if (uclosed) + { B.UpdateEdge(eumin, Lumax, Lumin, F, std::max(uminTol, umaxTol)); + } else + { B.UpdateEdge(eumin, Lumin, F, uminTol); + } B.Degenerated(eumin, Dumin); if (!vmininf) { @@ -645,13 +709,19 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (!umaxinf) { if (uclosed) + { eumax = eumin; + } else { if (!Dumax) + { B.MakeEdge(eumax, Cumax, umaxTol); + } else + { B.MakeEdge(eumax); + } B.UpdateEdge(eumax, Lumax, F, umaxTol); B.Degenerated(eumax, Dumax); if (!vmininf) @@ -671,13 +741,21 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (!vmininf) { if (!Dvmin) + { B.MakeEdge(evmin, Cvmin, vminTol); + } else + { B.MakeEdge(evmin); + } if (vclosed) + { B.UpdateEdge(evmin, Lvmin, Lvmax, F, std::max(vminTol, vmaxTol)); + } else + { B.UpdateEdge(evmin, Lvmin, F, vminTol); + } B.Degenerated(evmin, Dvmin); if (!umininf) { @@ -695,13 +773,19 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, if (!vmaxinf) { if (vclosed) + { evmax = evmin; + } else { if (!Dvmax) + { B.MakeEdge(evmax, Cvmax, vmaxTol); + } else + { B.MakeEdge(evmax); + } B.UpdateEdge(evmax, Lvmax, F, vmaxTol); B.Degenerated(evmax, Dvmax); if (!umininf) @@ -753,13 +837,21 @@ void BRepLib_MakeFace::Init(const occ::handle& SS, // one wire B.MakeWire(W); if (!umininf) + { B.Add(W, eumin); + } if (!vmininf) + { B.Add(W, evmin); + } if (!umaxinf) + { B.Add(W, eumax); + } if (!vmaxinf) + { B.Add(W, evmax); + } B.Add(F, W); W.Closed(!umininf && !umaxinf && !vmininf && !vmaxinf); F.Closed(uclosed && vclosed); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakePolygon.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakePolygon.cxx index 1d4854a35e..9fcd1a963b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakePolygon.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakePolygon.cxx @@ -49,7 +49,9 @@ BRepLib_MakePolygon::BRepLib_MakePolygon(const gp_Pnt& P1, Add(P2); Add(P3); if (Cl) + { Close(); + } } //================================================================================================= @@ -65,7 +67,9 @@ BRepLib_MakePolygon::BRepLib_MakePolygon(const gp_Pnt& P1, Add(P3); Add(P4); if (Cl) + { Close(); + } } //================================================================================================= @@ -87,7 +91,9 @@ BRepLib_MakePolygon::BRepLib_MakePolygon(const TopoDS_Vertex& V1, Add(V2); Add(V3); if (Cl) + { Close(); + } } //================================================================================================= @@ -103,7 +109,9 @@ BRepLib_MakePolygon::BRepLib_MakePolygon(const TopoDS_Vertex& V1, Add(V3); Add(V4); if (Cl) + { Close(); + } } //================================================================================================= @@ -148,7 +156,9 @@ void BRepLib_MakePolygon::Add(const TopoDS_Vertex& V) myShape.Closed(true); } else + { myLastVertex = V; + } } BRepLib_MakeEdge ME(last, myLastVertex); @@ -162,9 +172,13 @@ void BRepLib_MakePolygon::Add(const TopoDS_Vertex& V) { // restore the previous last vertex if (second) + { myLastVertex.Nullify(); + } else + { myLastVertex = last; + } } } } @@ -181,11 +195,15 @@ bool BRepLib_MakePolygon::Added() const void BRepLib_MakePolygon::Close() { if (myFirstVertex.IsNull() || myLastVertex.IsNull()) + { return; + } // check not already closed if (myShape.Closed()) + { return; + } // build the last edge BRep_Builder B; diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeShell.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeShell.cxx index b541c0351b..e3884c0eb1 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeShell.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeShell.cxx @@ -93,7 +93,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, bool vperiodic = GS.IsVPeriodic(); if (nu == 0 || nv == 0) + { return; + } // arrays of parameters and pcurves NCollection_Array1 upars(1, nu + 1); @@ -109,7 +111,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, { double u = upars(iu); if (!Precision::IsInfinite(u)) + { uisos(iu) = new Geom2d_Line(gp_Pnt2d(u, 0.), dv); + } } GS.VIntervals(vpars, GeomAbs_C2); @@ -118,7 +122,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, { double v = vpars(iv); if (!Precision::IsInfinite(v)) + { visos(iv) = new Geom2d_Line(gp_Pnt2d(0., v), du); + } } // create row by row @@ -144,7 +150,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, if (!Precision::IsInfinite(vpars(1))) { if (!Precision::IsInfinite(upars(1))) + { B.MakeVertex(vrt, S->Value(upars(1), vpars(1)), tol); + } fbotvertices(1) = botvertices(1) = vrt; for (iu = 1; iu <= nu; iu++) @@ -152,9 +160,13 @@ void BRepLib_MakeShell::Init(const occ::handle& S, vlt = vrt; if (uperiodic && iu == nu) + { vrt = TopoDS::Vertex(botvertices(1)); + } else if (!Precision::IsInfinite(upars(iu + 1))) + { B.MakeVertex(vrt, S->Value(upars(iu + 1), vpars(1)), tol); + } fbotvertices(iu + 1) = botvertices(iu + 1) = vrt; B.MakeEdge(etop); @@ -188,7 +200,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, if (!Precision::IsInfinite(vpars(iv + 1))) { if (!Precision::IsInfinite(upars(1))) + { B.MakeVertex(vrt, S->Value(upars(1), vpars(iv + 1)), tol); + } } } @@ -240,14 +254,18 @@ void BRepLib_MakeShell::Init(const occ::handle& S, vlt = vrt; if (uperiodic && iu == nu) + { vrt = fvlt; + } else { vrt.Nullify(); if (!Precision::IsInfinite(vpars(iv + 1))) { if (!Precision::IsInfinite(upars(iu + 1))) + { B.MakeVertex(vrt, S->Value(upars(iu + 1), vpars(iv + 1)), tol); + } } } @@ -259,7 +277,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, eleft = eright; if (uperiodic && iu == nu) + { eright = feleft; + } else { eright.Nullify(); @@ -304,7 +324,9 @@ void BRepLib_MakeShell::Init(const occ::handle& S, ebot = TopoDS::Edge(botedges(iu)); if (vperiodic && iv == nv) + { etop = TopoDS::Edge(fbotedges(iu)); + } else { etop.Nullify(); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeSolid.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeSolid.cxx index 53aab47782..6b957eb40f 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeSolid.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeSolid.cxx @@ -115,7 +115,9 @@ BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So) B.MakeSolid(TopoDS::Solid(myShape)); TopExp_Explorer ex; for (ex.Init(So, TopAbs_SHELL); ex.More(); ex.Next()) + { B.Add(myShape, ex.Current()); + } Done(); } @@ -127,7 +129,9 @@ BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So, const TopoDS_Shell& B.MakeSolid(TopoDS::Solid(myShape)); TopExp_Explorer ex; for (ex.Init(So, TopAbs_SHELL); ex.More(); ex.Next()) + { B.Add(myShape, ex.Current()); + } B.Add(myShape, S); Done(); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire.cxx index b47103cd14..56c090e26c 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire.cxx @@ -99,7 +99,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Wire& W) { Add(TopoDS::Edge(it.Value())); if (myError != BRepLib_WireDone) + { break; + } } } @@ -141,7 +143,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) // add the vertices for (it.Initialize(myEdge); it.More(); it.Next()) + { myVertices.Add(it.Value()); + } } else @@ -159,7 +163,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) if (myError != BRepLib_NonManifoldWire) { if (VF.IsNull() || VL.IsNull()) + { myError = BRepLib_NonManifoldWire; + } } for (it.Initialize(EE); it.More(); it.Next()) @@ -179,26 +185,38 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) { // Orientation indetermined (in 3d) : Preserve the initial if (!VF.IsSame(VE)) + { myError = BRepLib_NonManifoldWire; + } } else { if (VF.IsSame(VE)) { if (VE.Orientation() == TopAbs_FORWARD) + { reverse = true; + } else + { forward = true; + } } else if (VL.IsSame(VE)) { if (VE.Orientation() == TopAbs_REVERSED) + { reverse = true; + } else + { forward = true; + } } else + { myError = BRepLib_NonManifoldWire; + } } } } @@ -223,26 +241,38 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) { // Orientation indetermined (in 3d) : Preserve the initial if (!VF.IsSame(VW)) + { myError = BRepLib_NonManifoldWire; + } } else { if (VF.IsSame(VW)) { if (VE.Orientation() == TopAbs_FORWARD) + { reverse = true; + } else + { forward = true; + } } else if (VL.IsSame(VW)) { if (VE.Orientation() == TopAbs_REVERSED) + { reverse = true; + } else + { forward = true; + } } else + { myError = BRepLib_NonManifoldWire; + } } } break; @@ -267,7 +297,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) { myEdge = EE; for (it.Initialize(EE); it.More(); it.Next()) + { myVertices.Add(it.Value()); + } } else { @@ -342,7 +374,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) // closed wire, internal vertex ... // reverse and forward are true : closed or degenerated edge if (((forward == reverse) && (E.Orientation() == TopAbs_REVERSED)) || (reverse && !forward)) + { myEdge.Reverse(); + } } // add myEdge to myShape @@ -351,7 +385,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) // Initialize VF, VL if (init) + { TopExp::Vertices(TopoDS::Wire(myShape), VF, VL); + } else { if (myError == BRepLib_WireDone) @@ -359,9 +395,13 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) TopoDS_Vertex V1, V2, VRef; TopExp::Vertices(myEdge, V1, V2); if (V1.IsSame(myVertex)) + { VRef = V2; + } else if (V2.IsSame(myVertex)) + { VRef = V1; + } else { #ifdef OCCT_DEBUG @@ -381,9 +421,13 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) else { // General case if (VF.IsSame(myVertex)) + { VF = VRef; + } else if (VL.IsSame(myVertex)) + { VL = VRef; + } else { #ifdef OCCT_DEBUG @@ -400,7 +444,9 @@ void BRepLib_MakeWire::Add(const TopoDS_Edge& E, bool IsCheckGeometryProximity) } // Test myShape is closed if (!VF.IsNull() && !VL.IsNull() && VF.IsSame(VL)) + { myShape.Closed(true); + } myError = BRepLib_WireDone; Done(); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire_1.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire_1.cxx index aea9559807..51dfdffd56 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire_1.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepLib/BRepLib_MakeWire_1.cxx @@ -95,7 +95,9 @@ void BRepLib_MakeWire::Add(const NCollection_List& L) NCollection_List::Iterator anItL1, anItL2; for (anItL1.Initialize(aNewEList); anItL1.More(); anItL1.Next()) + { TopExp::MapShapesAndAncestors(anItL1.Value(), TopAbs_VERTEX, TopAbs_EDGE, aMapVE); + } while (!anActEdges.IsEmpty()) { @@ -125,7 +127,9 @@ void BRepLib_MakeWire::Add(const NCollection_List& L) } } if (aLSize == aRefSize) + { Done(); + } else { NotDone(); @@ -138,12 +142,16 @@ void BRepLib_MakeWire::Add(const NCollection_List& L) bool BRepLib_MakeWire::BRepLib_BndBoxVertexSelector::Accept(const int& theObj) { if (theObj > myMapOfShape.Extent()) + { return false; + } const TopoDS_Vertex& aV = TopoDS::Vertex(myMapOfShape(theObj)); if (theObj == myVInd) + { return false; + } gp_Pnt aVPnt = BRep_Tool::Pnt(aV); @@ -189,7 +197,9 @@ void BRepLib_MakeWire::CollectCoincidentVertices( NCollection_List::Iterator anItL(theL); for (; anItL.More(); anItL.Next()) + { TopExp::MapShapes(anItL.Value(), TopAbs_VERTEX, anAllV); + } // aV2CV : vertex <-> its coincident vertices NCollection_DataMap> aV2CV; @@ -215,7 +225,9 @@ void BRepLib_MakeWire::CollectCoincidentVertices( { const TopoDS_Vertex& aV = TopoDS::Vertex(anAllV(i)); if (myVertices.Contains(aV)) + { continue; + } aSelector.SetCurrentVertex(BRep_Tool::Pnt(aV), BRep_Tool::Tolerance(aV), i); aNbColl = aTree.Select(aSelector); if (aNbColl > 0) @@ -229,7 +241,9 @@ void BRepLib_MakeWire::CollectCoincidentVertices( if (myVertices.Contains(aCV)) { if (aV2CV.IsBound(aCV)) + { aV2CV(aCV).Add(aV); + } else { aV2CV.Bound(aCV, NCollection_Map())->Add(aV); @@ -238,7 +252,9 @@ void BRepLib_MakeWire::CollectCoincidentVertices( } } if (!aVM->IsEmpty()) + { aNonGroupedV.Add(aV); // vertexes to be grouped; store only coincident vertices + } } aSelector.ClearResInds(); } @@ -314,7 +330,9 @@ void BRepLib_MakeWire::CreateNewVertices( const TopoDS_Vertex& aVV = itLV.Value(); aValList.Append(aVV); if (myVertices.Contains(aVV)) + { aNewV = aVV; + } } BRepLib::BoundingVertex(aValList, aNewC, aNewTol); @@ -326,8 +344,10 @@ void BRepLib_MakeWire::CreateNewVertices( aBB.UpdateVertex(aNewV, aNewTol); } else + { // update already existing vertex aBB.UpdateVertex(aNewV, gp_Pnt(aNewC), aNewTol); + } // fill the map of old->new vertices itLV.Initialize(aVal); @@ -368,17 +388,23 @@ void BRepLib_MakeWire::CreateNewListOfEdges( aVList.Append(TopoDS::Vertex(theO2NV(aVal).Oriented(aVal.Orientation()))); } else + { aVList.Append(aVal); + } } if (IsNewEdge) { TopoDS_Shape NewE = aCE.EmptyCopied(); NCollection_List::Iterator it(aVList); for (; it.More(); it.Next()) + { aBB.Add(NewE, it.Value()); + } theNewEList.Append(TopoDS::Edge(NewE)); } else + { theNewEList.Append(aCE); + } } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx index 052506093b..a5c222f2b9 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx @@ -109,13 +109,19 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, // Initialisation et execution de l algorithme. // -------------------------------------------- if (IsOpenResult) + { TheMAT.CreateMatOpen(theTool); + } else + { TheMAT.CreateMat(theTool); + } isDone = TheMAT.IsDone(); if (!isDone) + { return; + } // ---------------------------------------------------------------- // Recuperation du resultat de l algorithme et creation du graphe. @@ -284,7 +290,9 @@ Bisector_Bisec BRepMAT2d_BisectingLocus::GeomBis(const occ::handle& anA gp_Pnt2d PL = Bis->Value(Bis->LastParameter()); gp_Pnt2d PNode = GeomElt(anArc->FirstNode()); if (PNode.SquareDistance(PF) > PNode.SquareDistance(PL)) + { Reverse = true; + } } return theTool.GeomBis(anArc->GeomIndex()); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_Explorer.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_Explorer.cxx index 65529958f4..017e89a09e 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_Explorer.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_Explorer.cxx @@ -113,7 +113,9 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, // Modified by skv - Wed Jun 23 12:23:02 2004 Integration End NCollection_IndexedDataMap anOldNewE; if (!anExp.More()) + { return; + } // Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin // This method is totally rewroted to include check @@ -143,7 +145,9 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, CT2d = new Geom2d_TrimmedCurve(C2d, UFirst, ULast); if (aFirstEdge.Orientation() == TopAbs_REVERSED) + { CT2d->Reverse(); + } aPFirst = CT2d->Value(CT2d->FirstParameter()); aPLast = CT2d->Value(CT2d->LastParameter()); @@ -162,7 +166,9 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, CT2d = new Geom2d_TrimmedCurve(C2d, UFirst, ULast); if (anEdge.Orientation() == TopAbs_REVERSED) + { CT2d->Reverse(); + } aPCurFirst = CT2d->Value(CT2d->FirstParameter()); // @@ -193,9 +199,13 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, TopoDS_Vertex aVl = TopExp::LastVertex(anEdge); if (anEdge.Orientation() == TopAbs_FORWARD) + { aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl); + } else + { aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl); + } aNewEdge.Orientation(anEdge.Orientation()); @@ -212,9 +222,13 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge); if (aPrevEdge.Orientation() == TopAbs_FORWARD) + { aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl); + } else + { aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl); + } aNewEdge.Orientation(aPrevEdge.Orientation()); @@ -251,9 +265,13 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge); if (aFirstEdge.Orientation() == TopAbs_FORWARD) + { aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl); + } else + { aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl); + } aNewEdge.Orientation(aFirstEdge.Orientation()); @@ -270,9 +288,13 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge); if (aPrevEdge.Orientation() == TopAbs_FORWARD) + { aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl); + } else + { aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl); + } aNewEdge.Orientation(aPrevEdge.Orientation()); @@ -300,7 +322,9 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, } if (myIsClosed(currentContour)) + { aNewWire.Closed(true); + } // Modified by skv - Fri Nov 12 17:22:12 2004 Integration Begin // The orientation of wire is already taken into account. @@ -309,7 +333,9 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, myModifShapes.Add(Spine, aNewWire); } else + { aNewWire = Spine; + } aBuilder.Add(aNewFace, aNewWire); // Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx index c1aec6c82f..6687741e5d 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx @@ -87,9 +87,13 @@ void BRepMAT2d_LinkTopoBilo::Init(const TopoDS_Shape& S) isEmpty = false; current = 1; if (myMap.IsBound(S)) + { myKey = S; + } else + { isEmpty = true; + } } //================================================================================================= @@ -97,7 +101,9 @@ void BRepMAT2d_LinkTopoBilo::Init(const TopoDS_Shape& S) bool BRepMAT2d_LinkTopoBilo::More() { if (isEmpty) + { return false; + } return (current <= myMap(myKey).Length()); } @@ -178,9 +184,13 @@ void BRepMAT2d_LinkTopoBilo::LinkToWire(const TopoDS_Wire& W, TopExp::Vertices(TopoDS::Edge(S), VF, VL); } if (KC > 0) + { S = VL; + } else + { S = VF; + } } if (!myMap.IsBound(S)) { @@ -189,9 +199,13 @@ void BRepMAT2d_LinkTopoBilo::LinkToWire(const TopoDS_Wire& W, myMap(S).Append(BE); if (KC < 0) + { myBEShape.Bind(BE, S.Oriented(TopAbs::Reverse(S.Orientation()))); + } else + { myBEShape.Bind(BE, S); + } } } @@ -291,7 +305,9 @@ void LinkToContour(const BRepMAT2d_Explorer& Explo, { IndOnCont--; if (IndOnCont != 0) + { NbSect = BiLo.NumberOfSections(IndC, IndOnCont); + } LastPoint = false; } else diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx index 1d285434e2..e604cc312b 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx @@ -122,7 +122,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const TopExp_Explorer Explorer; for (Explorer.Init(aFaceExplorer.Current(), TopAbs_EDGE); Explorer.More(); Explorer.Next()) + { NbEdges++; + } aNbE = NbEdges; gp_Pnt Ancienpnt3d(0, 0, 0); @@ -138,10 +140,14 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { double pfbid, plbid; if (BRep_Tool::CurveOnSurface(edge, Face, pfbid, plbid).IsNull()) + { return; + } if (std::abs(plbid - pfbid) < 1.e-9) + { continue; + } bool degenerated = false; if (BRep_Tool::Degenerated(edge)) @@ -174,11 +180,15 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const int nbs = Geom2dInt_Geom2dCurveTool::NbSamples(aCurveAdaptor2D); //-- Attention to rational bsplines of degree 3. (ends of circles among others) if (nbs > 2) + { nbs *= 4; + } double du = (plbid - pfbid) / (double)(nbs - 1); double u = 0.0; if (Or == TopAbs_FORWARD) + { u = pfbid; + } else { u = plbid; @@ -191,19 +201,29 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const //-- Try to remote the first point of the current edge //-- from the last saved point if (firstpoint == 2) + { u += du; + } int Avant = nbpnts; for (int e = firstpoint; e <= nbs; e++) { gp_Pnt2d P2d = aCurveAdaptor2D.Value(u); if (P2d.X() < Umin) + { Umin = P2d.X(); + } if (P2d.X() > Umax) + { Umax = P2d.X(); + } if (P2d.Y() < Vmin) + { Vmin = P2d.Y(); + } if (P2d.Y() > Vmax) + { Vmax = P2d.Y(); + } double dist3dptcourant_ancienpnt = 1e+20; // RealLast(); gp_Pnt P3d; @@ -211,14 +231,18 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { P3d = aCurveAdaptor3D.Value(u); if (nbpnts > 1 && Ancienpnt3dinitialise) + { dist3dptcourant_ancienpnt = P3d.Distance(Ancienpnt3d); + } } bool IsRealCurve3d = true; // patch if (dist3dptcourant_ancienpnt < Precision::Confusion()) { gp_Pnt MidP3d = aCurveAdaptor3D.Value(u - du / 2.); if (P3d.Distance(MidP3d) < Precision::Confusion()) + { IsRealCurve3d = false; + } } if (IsRealCurve3d) { @@ -247,13 +271,19 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const double dV = std::abs(Pp.Y() - SeqPnt2d(ii - 1).Y()); //-- printf(" (du=%7.5g dv=%7.5g)",dU,dV); if (dU > FlecheU) + { FlecheU = dU; + } if (dV > FlecheV) + { FlecheV = dV; + } } } // for(e=firstpoint if (firstpoint == 1) + { firstpoint = 2; + } WireIsNotEmpty = true; } // if(Or==FORWARD,REVERSED } //-- Edges -> for(Ware.Explorer @@ -297,7 +327,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { // if(im2>=nbpnts) im2=1; if (im1 >= nbpnts) + { im1 = 1; + } PClass(ii) = SeqPnt2d.Value(ii); // gp_Vec2d A(PClass(im2),PClass(im1)); // gp_Vec2d B(PClass(im1),PClass(im0)); @@ -331,11 +363,15 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const double pfbid, plbid; BRep_Tool::Range(edge, Face, pfbid, plbid); if (std::abs(plbid - pfbid) < 1.e-9) + { continue; + } BRepAdaptor_Curve2d C(edge, Face); GCPnts_QuasiUniformDeflection aDiscr(C, aDiscrDefl); if (!aDiscr.IsDone()) + { break; + } int nbp = aDiscr.NbPoints(); int iStep = 1, i = 1, iEnd = nbp + 1; if (Or == TopAbs_REVERSED) @@ -345,7 +381,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const iEnd = 0; } if (firstpoint == 2) + { i += iStep; + } for (; i != iEnd; i += iStep) { gp_Pnt2d aP2d = C.Value(aDiscr.Parameter(i)); @@ -360,9 +398,13 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const double dU = std::abs(Pp.X() - SeqPnt2d(ii - 1).X()); double dV = std::abs(Pp.Y() - SeqPnt2d(ii - 1).Y()); if (dU > FlecheU) + { FlecheU = dU; + } if (dV > FlecheV) + { FlecheV = dV; + } } firstpoint = 2; } @@ -378,7 +420,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const for (int ii = 1; ii < nbpnts; ii++, im0++, im1++) { if (im1 >= nbpnts) + { im1 = 1; + } PClass(ii) = SeqPnt2d.Value(ii); square += (PClass(im0).X() - PClass(im1).X()) * (PClass(im0).Y() + PClass(im1).Y()) * .5; @@ -402,9 +446,13 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const } if (FlecheU < Toluv) + { FlecheU = Toluv; + } if (FlecheV < Toluv) + { FlecheV = Toluv; + } TabClass.Append(CSLib_Class2d(PClass, FlecheU, FlecheV, Umin, Vmin, Umax, Vmax)); } // if(nbpoints>3 else @@ -425,7 +473,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { //-- If an error was detected on a wire: set all TabOrien to -1 if (anIsBadWire) + { TabOrien(1) = -1; + } if (surf->GetType() == GeomAbs_Cone || surf->GetType() == GeomAbs_Cylinder || surf->GetType() == GeomAbs_Torus || surf->GetType() == GeomAbs_Sphere @@ -434,7 +484,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { double uuu = M_PI + M_PI - (Umax - Umin); if (uuu < 0) + { uuu = 0; + } U1 = 0.0; // modified by NIZHNY-OFV Thu May 31 14:24:10 2001 ---> //Umin-uuu*0.5; U2 = 2 * M_PI; // modified by NIZHNY-OFV Thu May 31 14:24:35 2001 ---> //U1+M_PI+M_PI; } @@ -447,7 +499,9 @@ BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace, const { double uuu = M_PI + M_PI - (Vmax - Vmin); if (uuu < 0) + { uuu = 0; + } V1 = 0.0; // modified by NIZHNY-OFV Thu May 31 14:24:55 2001 ---> //Vmin-uuu*0.5; V2 = 2 * M_PI; // modified by NIZHNY-OFV Thu May 31 14:24:59 2001 ---> //V1+M_PI+M_PI; } @@ -498,24 +552,36 @@ TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv, if (IsUPer) { if (uu < Umin) + { while (uu < Umin) + { uu += uperiod; + } + } else { while (uu >= Umin) + { uu -= uperiod; + } uu += uperiod; } } if (IsVPer) { if (vv < Vmin) + { while (vv < Vmin) + { vv += vperiod; + } + } else { while (vv >= Vmin) + { vv -= vperiod; + } vv += vperiod; } } @@ -578,9 +644,13 @@ TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv, } if (!RecadreOnPeriodic || (!IsUPer && !IsVPer)) + { return aStatus; + } if (aStatus == TopAbs_IN || aStatus == TopAbs_ON) + { return aStatus; + } if (!urecadre) { @@ -588,7 +658,9 @@ TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv, urecadre = true; } else if (IsUPer) + { u += uperiod; + } if (u > Umax || !IsUPer) { if (!vrecadre) @@ -597,12 +669,16 @@ TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv, vrecadre = true; } else if (IsVPer) + { v += vperiod; + } u = uu; if (v > Vmax || !IsVPer) + { return aStatus; + } } } // for (;;) } @@ -638,24 +714,36 @@ TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, if (IsUPer) { if (uu < Umin) + { while (uu < Umin) + { uu += uperiod; + } + } else { while (uu >= Umin) + { uu -= uperiod; + } uu += uperiod; } } if (IsVPer) { if (vv < Vmin) + { while (vv < Vmin) + { vv += vperiod; + } + } else { while (vv >= Vmin) + { vv -= vperiod; + } vv += vperiod; } } @@ -714,9 +802,13 @@ TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, } if (!RecadreOnPeriodic || (!IsUPer && !IsVPer)) + { return aStatus; + } if (aStatus == TopAbs_IN || aStatus == TopAbs_ON) + { return aStatus; + } if (!urecadre) { @@ -724,7 +816,9 @@ TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, urecadre = true; } else if (IsUPer) + { u += uperiod; + } if (u > Umax || !IsUPer) { if (!vrecadre) @@ -733,12 +827,16 @@ TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, vrecadre = true; } else if (IsVPer) + { v += vperiod; + } u = uu; if (v > Vmax || !IsVPer) + { return aStatus; + } } } // for (;;) } diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx index d8ce4174ea..62b6ca6fa3 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx @@ -77,22 +77,34 @@ double BRepTopAdaptor_HVertex::Resolution(const occ::handle& // 10 million*tolerance of the point if (tv > 1.e7 * mag) + { ResUV = 1.e7; + } else + { ResUV = tv / mag; + } // Control if (Or == TopAbs_REVERSED) + { pp = p + ResUV; + } else + { pp = p - ResUV; + } double UMin = C->FirstParameter(); double UMax = C->LastParameter(); if (pp > UMax) + { pp = UMax; + } if (pp < UMin) + { pp = UMin; + } C->D0(pp, p2d); S.D0(p2d.X(), p2d.Y(), P1); @@ -103,14 +115,22 @@ double BRepTopAdaptor_HVertex::Resolution(const occ::handle& // Refine if possible double Dist1; if (Or == TopAbs_REVERSED) + { pp = p + tv / Dist; + } else + { pp = p - tv / Dist; + } if (pp > UMax) + { pp = UMax; + } if (pp < UMin) + { pp = UMin; + } C->D1(pp, p2d, v2d); S.D1(p2d.X(), p2d.Y(), P1, DU, DV); @@ -125,16 +145,26 @@ double BRepTopAdaptor_HVertex::Resolution(const occ::handle& mag = DC.Magnitude(); if (tv > 1.e7 * mag) + { mag = tv * 1.e-7; + } if (Or == TopAbs_REVERSED) + { pp = p + tv / mag; + } else + { pp = p - tv / mag; + } if (pp > UMax) + { pp = UMax; + } if (pp < UMin) + { pp = UMin; + } C->D0(pp, p2d); S.D0(p2d.X(), p2d.Y(), P1); diff --git a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx index fae969e65b..548751d5e9 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx @@ -176,7 +176,9 @@ TopAbs_State BRepTopAdaptor_TopolTool::Classify(const gp_Pnt2d& P, const bool RecadreOnPeriodic) { if (myFace.IsNull()) + { return TopAbs_UNKNOWN; + } if (myFClass2d == nullptr) { myFClass2d = (void*)new BRepTopAdaptor_FClass2d(myFace, Tol); @@ -330,7 +332,9 @@ void Analyse(const NCollection_Array2& array2, } } if (locnbch > nbch) + { nbch = locnbch; + } } } myNbSamplesU = nbch + 5; @@ -403,11 +407,15 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints() nbsv = myS->NbVKnots(); nbsv *= myS->VDegree(); if (nbsv < 4) + { nbsv = 4; + } nbsu = myS->NbUKnots(); nbsu *= myS->UDegree(); if (nbsu < 4) + { nbsu = 4; + } } break; case GeomAbs_Cylinder: @@ -419,13 +427,21 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints() nbsu = (int)(8 * (usup - uinf)); nbsv = (int)(7 * (vsup - vinf)); if (nbsu < 5) + { nbsu = 5; + } if (nbsv < 5) + { nbsv = 5; + } if (nbsu > 30) + { nbsu = 30; // modif HRT buc60462 + } if (nbsv > 15) + { nbsv = 15; + } //-- printf("\n nbsu=%d nbsv=%d\n",nbsu,nbsv); } break; @@ -447,9 +463,13 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints() //-- if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } myNbSamplesU = nbsu; myNbSamplesV = nbsv; @@ -482,9 +502,13 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints() } if (nbsu < 10) + { nbsu = 10; + } if (nbsv < 10) + { nbsv = 10; + } myNbSamplesU = nbsu; myNbSamplesV = nbsv; @@ -551,13 +575,21 @@ bool BRepTopAdaptor_TopolTool::DomainIsInfinite() vinf = myS->FirstVParameter(); vsup = myS->LastVParameter(); if (Precision::IsNegativeInfinite(uinf)) + { return (true); + } if (Precision::IsPositiveInfinite(usup)) + { return (true); + } if (Precision::IsNegativeInfinite(vinf)) + { return (true); + } if (Precision::IsPositiveInfinite(vsup)) + { return (true); + } return (false); } @@ -580,7 +612,9 @@ double BRepTopAdaptor_TopolTool::Tol3d(const occ::handle& C) const TopoDS_Edge& edge = brhc->Edge(); if (edge.IsNull()) + { throw Standard_DomainError("BRepTopAdaptor_TopolTool: arc has no 3d representation"); + } return BRep_Tool::Tolerance(edge); } @@ -590,10 +624,14 @@ double BRepTopAdaptor_TopolTool::Tol3d(const occ::handle& V) { occ::handle brhv = occ::down_cast(V); if (brhv.IsNull()) + { throw Standard_DomainError("BRepTopAdaptor_TopolTool: vertex has no 3d representation"); + } const TopoDS_Vertex& ver = brhv->Vertex(); if (ver.IsNull()) + { throw Standard_DomainError("BRepTopAdaptor_TopolTool: vertex has no 3d representation"); + } return BRep_Tool::Tolerance(ver); } @@ -603,9 +641,13 @@ gp_Pnt BRepTopAdaptor_TopolTool::Pnt(const occ::handle& V) co { occ::handle brhv = occ::down_cast(V); if (brhv.IsNull()) + { throw Standard_DomainError("BRepTopAdaptor_TopolTool: vertex has no 3d representation"); + } const TopoDS_Vertex& ver = brhv->Vertex(); if (ver.IsNull()) + { throw Standard_DomainError("BRepTopAdaptor_TopolTool: vertex has no 3d representation"); + } return BRep_Tool::Pnt(ver); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Bisec.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Bisec.cxx index 8136ab47a6..8f7f38d043 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Bisec.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Bisec.cxx @@ -162,7 +162,9 @@ void Bisector_Bisec::Perform(const occ::handle& afirstcurve, // if (Fd.Dot(Sd) < Precision::Angular() - 1.) { // if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch if (Fd.Dot(Sd) < std::sqrt(2. * Precision::Angular()) - 1.) + { IsLine = true; + } } if (IsLine) { @@ -371,14 +373,20 @@ void Bisector_Bisec::Perform(const occ::handle& afirstcurve, Bis = BisAna; } else + { Bis = BisPC; + } } } } if (UFirst < Bis->FirstParameter()) + { UFirst = Bis->FirstParameter(); + } if (ULast > Bis->LastParameter()) + { ULast = Bis->LastParameter(); + } thebisector = new Geom2d_TrimmedCurve(Bis, UFirst, ULast); } @@ -508,7 +516,9 @@ void Bisector_Bisec::Perform(const occ::handle& afirstpoint, Bis = BisAna; } else + { Bis = BisPC; + } } } } @@ -577,13 +587,17 @@ static void ReplaceByLineIfIsToSmall(occ::handle& Bis, { if (std::abs(ULast - UFirst) > 2. * Precision::PConfusion() * 10.) + { return; // patch + } gp_Pnt2d PF = Bis->Value(UFirst); gp_Pnt2d PL = Bis->Value(ULast); if (PF.Distance(PL) > Precision::Confusion() * 10.) + { return; + } gp_Vec2d T1 = Bis->DN(UFirst, 1); @@ -638,9 +652,13 @@ static bool IsMaxRC(const occ::handle& C, double U, double& R) if (KL < KF) { if (KL == 0.0) + { R = Precision::Infinite(); + } else + { R = 1 / KL; + } IsMax = true; } } @@ -649,9 +667,13 @@ static bool IsMaxRC(const occ::handle& C, double U, double& R) if (KF < KL) { if (KF == 0.0) + { R = Precision::Infinite(); + } else + { R = 1 / KF; + } IsMax = true; } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecAna.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecAna.cxx index 5905d29fa9..732f6c875f 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecAna.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecAna.cxx @@ -172,26 +172,34 @@ double Bisector_BisecAna::Distance(const gp_Pnt2d& apoint, if ((afirstdir ^ secdirrev) * adirection < -0.1) { // input if ((afirstdir ^ tangdir) * adirection < aTol && (secdirrev ^ tangdir) * adirection < aTol) + { asense = false; + } } else if ((afirstdir ^ secdirrev) * adirection > 0.1) { // output if ((afirstdir ^ tangdir) * adirection < aTol || (secdirrev ^ tangdir) * adirection < aTol) + { asense = false; + } } else { // flat if (afirstdir.Dot(secdirrev) > 0.) { // tangent if ((afirstdir ^ tangdir) * adirection < 0.) + { asense = false; + } } else { // turn back // Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002 // if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = false; if (afirstdir.Dot(tangdir) < 0.) + { asense = false; + } // Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002 } } @@ -200,7 +208,9 @@ double Bisector_BisecAna::Distance(const gp_Pnt2d& apoint, { gp_Dir2d DirRef = VecRef; if (tangdir * DirRef < 0.) + { asense = false; + } } /////////////////// // Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End @@ -260,14 +270,22 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, tan1.Reverse(); if (type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { CurveF = occ::down_cast(afirstcurve)->BasisCurve(); + } else + { CurveF = afirstcurve; + } if (type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) + { CurveE = occ::down_cast(asecondcurve)->BasisCurve(); + } else + { CurveE = asecondcurve; + } type1 = CurveF->DynamicType(); type2 = CurveE->DynamicType(); @@ -299,7 +317,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, } else { - std::cout << "Not yet implemented" << std::endl; + std::cout << "Not yet implemented" << '\n'; } } else if (type1 == STANDARD_TYPE(Geom2d_Line)) @@ -322,12 +340,12 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, } else { - std::cout << "Not yet implemented" << std::endl; + std::cout << "Not yet implemented" << '\n'; } } else { - std::cout << "Not yet implemented" << std::endl; + std::cout << "Not yet implemented" << '\n'; } switch (cas) @@ -383,9 +401,12 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, // afirstvector,asecondvector, // adirection,parameter,sense,ok); if (oncurve) + { distanceptsol = Distance(apoint, solution, tan2, tan1, LineBisVec, adirection, parameter, sense, ok); + } else + { distanceptsol = Distance(apoint, solution, afirstvector, @@ -395,10 +416,13 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End occ::handle bisectorcurve = new Geom2d_Line(line); if (!sense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, parameter, -Precision::Infinite()); + } else { double parameter2; @@ -481,6 +505,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, // afirstvector,asecondvector, // adirection,parameter,sense,ok); if (oncurve) + { distanceptsol = Distance(apoint, solution, tan2, @@ -490,7 +515,9 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } else + { distanceptsol = Distance(apoint, solution, afirstvector, @@ -500,6 +527,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (distanceptsol <= distancemini) { @@ -521,7 +549,9 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, double secondparameter = Precision::Infinite(); if (!thesense) + { secondparameter = -Precision::Infinite(); + } if (oncurve) { @@ -568,16 +598,24 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, if (!thesense) { if (MaxPar < firstparameter) + { secondparameter = MaxPar - 1.E-8; + } else if (MinPar < firstparameter) + { secondparameter = MinPar - 1.E-8; + } } else { if (MinPar > firstparameter) + { secondparameter = MinPar + 1.E-8; + } else if (MaxPar > firstparameter) + { secondparameter = MaxPar + 1.E-8; + } } } } @@ -589,39 +627,51 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, { bisectorcurve = new Geom2d_Circle(TheSol->Circle()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter - 2.0 * M_PI, firstparameter, thesense); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, firstparameter + 2.0 * M_PI, thesense); + } } else if (type == GccInt_Hpr) { bisectorcurve = new Geom2d_Hyperbola(TheSol->Hyperbola()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, Precision::Infinite()); + } } else if (type == GccInt_Ell) { bisectorcurve = new Geom2d_Ellipse(TheSol->Ellipse()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter - 2.0 * M_PI, firstparameter, thesense); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, firstparameter + 2.0 * M_PI, thesense); + } } } } @@ -670,6 +720,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, // afirstvector,asecondvector, // adirection,parameter,sense,ok); if (oncurve) + { distanceptsol = Distance(apoint, solution, tan2, @@ -679,7 +730,9 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } else + { distanceptsol = Distance(apoint, solution, afirstvector, @@ -689,6 +742,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (distanceptsol <= distancemini) { @@ -757,18 +811,20 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, if (!thesense) { if (ajointype == GeomAbs_Intersection && TolPar < firstparameter - && ChordLen - >= circle1.Radius()) // first parameter is too far from peak of parabola + && ChordLen >= circle1.Radius()) + { // first parameter is too far from peak of parabola secondparameter = 0.; + } thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, -secondparameter); } else { if (ajointype == GeomAbs_Intersection && firstparameter < -TolPar - && ChordLen - >= circle1.Radius()) // first parameter is too far from peak of parabola + && ChordLen >= circle1.Radius()) + { // first parameter is too far from peak of parabola secondparameter = 0.; + } thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, secondparameter); } } @@ -794,9 +850,13 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, { // Modified by Sergey KHROMOV - Tue Sep 10 15:58:45 2002 End if (line1.Distance(line2.Location()) / 2. <= Precision::Confusion()) + { line = gp_Lin2d(apoint, gp_Dir2d(-line1.Direction().Y(), line1.Direction().X())); + } else + { line = gp_Lin2d(apoint, line2.Direction()); + } occ::handle solution = new GccInt_BLine(line); // Modified by skv - Wed Jul 7 17:21:09 2004 IDEM(Airbus) Begin @@ -812,9 +872,12 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, // afirstvector,asecondvector, // adirection,parameter,sense,ok); if (oncurve) + { distanceptsol = Distance(apoint, solution, tan2, tan1, LineBisVec, adirection, parameter, sense, ok); + } else + { distanceptsol = Distance(apoint, solution, afirstvector, @@ -824,17 +887,22 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, parameter, sense, ok); + } // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End // if (distanceptsol <= distancemini) { firstparameter = parameter; occ::handle bisectorcurve; bisectorcurve = new Geom2d_Line(line); if (!sense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, Precision::Infinite()); + } // } // } // Modified by skv - Wed Jul 7 17:21:09 2004 IDEM(Airbus) End @@ -850,9 +918,12 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, // afirstvector,asecondvector, // adirection,parameter,sense,ok); if (oncurve) + { distanceptsol = Distance(apoint, solution, tan2, tan1, LineBisVec, adirection, parameter, sense, isOk); + } else + { distanceptsol = Distance(apoint, solution, afirstvector, @@ -863,6 +934,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, sense, isOk, true); + } // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (isOk || !oncurve) { @@ -873,9 +945,13 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, occ::handle bisectorcurve; bisectorcurve = new Geom2d_Line(TheSol->Line()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, 0., -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, 0., Precision::Infinite()); + } } } break; @@ -948,7 +1024,7 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, } else { - std::cout << "Not yet implemented" << std::endl; + std::cout << "Not yet implemented" << '\n'; } switch (cas) @@ -1035,39 +1111,51 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, { bisectorcurve = new Geom2d_Circle(TheSol->Circle()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter - 2.0 * M_PI, firstparameter, thesense); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, firstparameter + 2.0 * M_PI, thesense); + } } else if (aSolType == GccInt_Hpr) { bisectorcurve = new Geom2d_Hyperbola(TheSol->Hyperbola()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, Precision::Infinite()); + } } else if (aSolType == GccInt_Ell) { bisectorcurve = new Geom2d_Ellipse(TheSol->Ellipse()); if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter - 2.0 * M_PI, firstparameter, thesense); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, firstparameter + 2.0 * M_PI, thesense); + } } } } @@ -1116,15 +1204,19 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstcurve, } if (!thesense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, Precision::Infinite()); + } } break; default: { - std::cout << "Not yet implemented" << std::endl; + std::cout << "Not yet implemented" << '\n'; break; } } @@ -1201,9 +1293,13 @@ void Bisector_BisecAna::Perform(const occ::handle& afirstpoint, { occ::handle bisectorcurve = new Geom2d_Line(line); if (!sense) + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, parameter, -Precision::Infinite()); + } else + { thebisector = new Geom2d_TrimmedCurve(bisectorcurve, parameter, Precision::Infinite()); + } } } @@ -1608,7 +1704,9 @@ int Bisector_BisecAna::NbIntervals() const double Bisector_BisecAna::IntervalFirst(const int I) const { if (I != 1) + { throw Standard_OutOfRange(); + } return FirstParameter(); } @@ -1617,7 +1715,9 @@ double Bisector_BisecAna::IntervalFirst(const int I) const double Bisector_BisecAna::IntervalLast(const int I) const { if (I != 1) + { throw Standard_OutOfRange(); + } return LastParameter(); } @@ -1719,7 +1819,7 @@ static void Indent(const int Offset) void Bisector_BisecAna::Dump(const int, const int Offset) const { Indent(Offset); - std::cout << "Bisector_BisecAna" << std::endl; + std::cout << "Bisector_BisecAna" << '\n'; Indent(Offset); // thebisector->Dump(); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecCC.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecCC.cxx index d34f53f635..825fe3cd74 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecCC.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecCC.cxx @@ -203,7 +203,9 @@ void Bisector_BisecCC::Perform(const occ::handle& Cu1, if (Dist < Precision::Infinite()) { if (P.Distance(prevPnt) > Precision::Confusion()) + { myPolygon.Append(Bisector_PointOnBis(UC1, UC2, U, Dist, P)); + } } else { @@ -211,7 +213,9 @@ void Bisector_BisecCC::Perform(const occ::handle& Cu1, P = ValueByInt(USol, UC1, UC2, Dist); endIntervals.SetValue(1, USol); if (P.Distance(prevPnt) > Precision::Confusion()) + { myPolygon.Append(Bisector_PointOnBis(UC1, UC2, USol, Dist, P)); + } break; } U += dU; @@ -234,7 +238,9 @@ void Bisector_BisecCC::Perform(const occ::handle& Cu1, if (isConvex1 && isConvex2) { if (YaPoly) + { pointEnd = myPolygon.Last().Point(); + } } else { @@ -309,10 +315,14 @@ void Bisector_BisecCC::Perform(const occ::handle& Cu1, } } if (!YaPoly && !extensionStart && !extensionEnd) + { isEmpty = true; + } // modified by NIZHNY-EAP Mon Jan 17 17:32:40 2000 ___BEGIN___ if (myPolygon.Length() <= 2) + { isEmpty = true; + } // modified by NIZHNY-EAP Mon Jan 17 17:32:42 2000 ___END___ } @@ -541,7 +551,9 @@ bool Bisector_BisecCC::IsClosed() const { if (startIntervals.First() == curve1->FirstParameter() && endIntervals.Last() == curve1->LastParameter()) + { return true; + } } return false; } @@ -679,9 +691,13 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist(const double U, double& U1, double& U2, math_FunctionRoot SolRoot(H, VInit, EpsH, VMin - EpsH100, VMax + EpsH100); if (SolRoot.IsDone()) + { U2 = SolRoot.Root(); + } else + { Valid = false; + } } } } @@ -942,7 +958,9 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt(const double U, double& U1, double& U2, do if (K1 != 0.) { if (Dist > 1 / (K1 * K1)) + { YaSol = false; + } } } if (YaSol) @@ -953,7 +971,9 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt(const double U, double& U1, double& U2, do if (K2 != 0.) { if (Dist > 1 / (K2 * K2)) + { YaSol = false; + } } } } @@ -1016,7 +1036,9 @@ Geom2d_Curve::ResD3 Bisector_BisecCC::EvalD3(const double U) const gp_Vec2d Bisector_BisecCC::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative("Bisector_BisecCC::EvalDN"); + } gp_Pnt2d P; gp_Vec2d V1(0., 0.); gp_Vec2d V2(0., 0.); @@ -1092,7 +1114,9 @@ void Bisector_BisecCC::Values(const double U, P = ValueAndDist(U, U0, V0, Dist); if (N == 0) + { return; + } //------------------------------------------------------------------ // Return point, tangent, normal to C1 by parameter U0. //------------------------------------------------------------------- @@ -1177,7 +1201,9 @@ void Bisector_BisecCC::Values(const double U, } } if (N == 1) + { return; + } } //============================================================================= @@ -1286,7 +1312,9 @@ gp_Pnt2d Bisector_BisecCC::Extension(const double U, Tang = T1; } if (T1.Dot(Tang) < 0.) + { Tang = -Tang; + } } T = Tang.Normalized(); @@ -1428,7 +1456,9 @@ static bool PointByInt(const occ::handle& CA, if (K1 != 0.) { if (Dist > std::abs(1 / K1)) + { YaSol = false; + } } } if (YaSol) @@ -1439,7 +1469,9 @@ static bool PointByInt(const occ::handle& CA, if (K2 != 0.) { if (Dist > std::abs(1 / K2)) + { YaSol = false; + } } } } @@ -1482,11 +1514,17 @@ void Bisector_BisecCC::SupLastParameter() occ::handle Bisector_BisecCC::Curve(const int I) const { if (I == 1) + { return curve1; + } else if (I == 2) + { return curve2; + } else + { throw Standard_OutOfRange(); + } } //================================================================================================= @@ -1551,20 +1589,20 @@ double Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const void Bisector_BisecCC::Dump(const int, const int Offset) const { Indent(Offset); - std::cout << "Bisector_BisecCC :" << std::endl; + std::cout << "Bisector_BisecCC :" << '\n'; Indent(Offset); // std::cout <<"Curve1 :"<& C) { if (I == 1) + { curve1 = C; + } else if (I == 2) + { curve2 = C; + } else + { throw Standard_OutOfRange(); + } } //================================================================================================= @@ -1584,11 +1628,17 @@ void Bisector_BisecCC::Curve(const int I, const occ::handle& C) void Bisector_BisecCC::Sign(const int I, const double S) { if (I == 1) + { sign1 = S; + } else if (I == 2) + { sign2 = S; + } else + { throw Standard_OutOfRange(); + } } //================================================================================================= @@ -1610,11 +1660,17 @@ void Bisector_BisecCC::DistMax(const double D) void Bisector_BisecCC::IsConvex(const int I, const bool IsConvex) { if (I == 1) + { isConvex1 = IsConvex; + } else if (I == 2) + { isConvex2 = IsConvex; + } else + { throw Standard_OutOfRange(); + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecPC.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecPC.cxx index 7b75e81bb5..9efb870a5c 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecPC.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_BisecPC.cxx @@ -97,7 +97,9 @@ void Bisector_BisecPC::Perform(const occ::handle& Cu, //-------------------------------------------- ComputeIntervals(); if (isEmpty) + { return; + } //------------------------- // Construction extensions. @@ -288,7 +290,9 @@ bool Bisector_BisecPC::IsClosed() const // ----------------------------------------------------------------------- if (startIntervals.First() == curve->FirstParameter() && endIntervals.First() == curve->LastParameter()) + { return true; + } } return false; } @@ -316,7 +320,9 @@ void Bisector_BisecPC::Extension(const double U, if (U < startIntervals.Value(bisInterval)) { if (pointStartBis.IsEqual(point, Precision::PConfusion())) + { P = pointStartBis; + } else { dU = U - startIntervals.Value(bisInterval); @@ -328,7 +334,9 @@ void Bisector_BisecPC::Extension(const double U, else if (U > endIntervals.Value(bisInterval)) { if (pointEndBis.IsEqual(point, Precision::PConfusion())) + { P = pointEndBis; + } else { dU = U - endIntervals.Value(bisInterval); @@ -406,7 +414,9 @@ void Bisector_BisecPC::Values(const double U, } if (N == 0) + { return; // End Calculation Point; + } gp_Vec2d Nu(-Tuu.Y(), Tuu.X()); // derivative of the normal by U. double NuPPC = Nu.Dot(aPPC); @@ -418,7 +428,9 @@ void Bisector_BisecPC::Values(const double U, V1 = Tu - A1 * Nu - A2 * Nor; //-------------------------- if (N == 1) + { return; // End calculation D1. + } gp_Vec2d Nuu(-T3u.Y(), T3u.X()); @@ -581,7 +593,9 @@ Geom2d_Curve::ResD3 Bisector_BisecPC::EvalD3(const double U) const gp_Vec2d Bisector_BisecPC::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative("Bisector_BisecPC::EvalDN"); + } gp_Pnt2d P = point; gp_Vec2d V1(0., 0.); gp_Vec2d V2(0., 0.); @@ -854,17 +868,17 @@ void Bisector_BisecPC::Init(const occ::handle& Curve, void Bisector_BisecPC::Dump(const int, const int Offset) const { Indent(Offset); - std::cout << "Bisector_BisecPC :" << std::endl; + std::cout << "Bisector_BisecPC :" << '\n'; Indent(Offset); - std::cout << "Point :" << std::endl; - std::cout << " X = " << point.X() << std::endl; - std::cout << " Y = " << point.Y() << std::endl; - std::cout << "Sign :" << sign << std::endl; - std::cout << "Number Of Intervals :" << startIntervals.Length() << std::endl; + std::cout << "Point :" << '\n'; + std::cout << " X = " << point.X() << '\n'; + std::cout << " Y = " << point.Y() << '\n'; + std::cout << "Sign :" << sign << '\n'; + std::cout << "Number Of Intervals :" << startIntervals.Length() << '\n'; for (int i = 1; i <= startIntervals.Length(); i++) { std::cout << "Interval number :" << i << "Start :" << startIntervals.Value(i) - << " end :" << endIntervals.Value(i) << std::endl; + << " end :" << endIntervals.Value(i) << '\n'; } - std::cout << "Index Current Interval :" << currentInterval << std::endl; + std::cout << "Index Current Interval :" << currentInterval << '\n'; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Inter.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Inter.cxx index 91d1003a4c..8ca95443fc 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Inter.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_Inter.cxx @@ -375,9 +375,13 @@ void Bisector_Inter::NeighbourPerform(const occ::handle& Bis1, aSolution.Perform(Fint, UMin, UMax, 20); if (aSolution.IsDone()) + { USol = aSolution.Root(); + } else + { return; + } PSol = BisTemp->ValueAndDist(USol, U1, U2, Dist); @@ -430,7 +434,9 @@ void Bisector_Inter::TestBound(const occ::handle& Bis1, // Modified by skv - Mon May 5 14:48:14 2003 OCC616 End // PF est sur L1 if (BisecAlgo) + { PF = ElCLib::Value(U1, L1); + } PointInterSol.SetValues(PF, U1, D2.FirstParameter(), Trans1, Trans2, Reverse); Append(PointInterSol); } @@ -447,7 +453,9 @@ void Bisector_Inter::TestBound(const occ::handle& Bis1, { // Modified by skv - Mon May 5 15:05:49 2003 OCC616 End if (BisecAlgo) + { PL = ElCLib::Value(U1, L1); + } PointInterSol.SetValues(PL, U1, D2.LastParameter(), Trans1, Trans2, Reverse); Append(PointInterSol); } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PointOnBis.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PointOnBis.cxx index ba4b5988c8..8b08d94e4d 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PointOnBis.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PointOnBis.cxx @@ -132,8 +132,8 @@ bool Bisector_PointOnBis::IsInfinite() const void Bisector_PointOnBis::Dump() const { - std::cout << "Param1 :" << param1 << std::endl; - std::cout << "Param2 :" << param2 << std::endl; - std::cout << "Param Bis :" << paramBis << std::endl; - std::cout << "Distance :" << distance << std::endl; + std::cout << "Param1 :" << param1 << '\n'; + std::cout << "Param2 :" << param2 << '\n'; + std::cout << "Param Bis :" << paramBis << '\n'; + std::cout << "Distance :" << distance << '\n'; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PolyBis.cxx b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PolyBis.cxx index 6a713a672e..30da1081b3 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PolyBis.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/Bisector/Bisector_PolyBis.cxx @@ -86,7 +86,9 @@ int Bisector_PolyBis::Interval(const double U) const } double dU = (Last().ParamOnBis() - First().ParamOnBis()) / (nbPoints - 1); if (dU <= gp::Resolution()) + { return 1; + } int IntU = int(std::abs(U - First().ParamOnBis()) / dU); IntU++; diff --git a/src/ModelingAlgorithms/TKTopAlgo/IntCurvesFace/IntCurvesFace_Intersector.cxx b/src/ModelingAlgorithms/TKTopAlgo/IntCurvesFace/IntCurvesFace_Intersector.cxx index 459de63519..d1176bf2c0 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/IntCurvesFace/IntCurvesFace_Intersector.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/IntCurvesFace/IntCurvesFace_Intersector.cxx @@ -164,13 +164,21 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face, double dU = (U1 - U0) / aURes; double dV = (V1 - V0) / aVRes; if (nbsu < aMinSamples) + { nbsu = aMinSamples; + } if (nbsv < aMinSamples) + { nbsv = aMinSamples; + } if (nbsu > aMaxSamples) + { nbsu = aMaxSamples; + } if (nbsv > aMaxSamples) + { nbsv = aMaxSamples; + } if (dU > Precision::Confusion() && dV > Precision::Confusion()) { @@ -179,7 +187,9 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face, aMinSamples = 10; nbsu = (int)(std::sqrt(dU / dV) * aMaxSamples); if (nbsu < aMinSamples) + { nbsu = aMinSamples; + } nbsv = aMaxSamples2 / nbsu; if (nbsv < aMinSamples) { @@ -292,9 +302,13 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter& HICS, if (transition != IntCurveSurface_Tangent && face.Orientation() == TopAbs_REVERSED) { if (transition == IntCurveSurface_In) + { transition = IntCurveSurface_Out; + } else + { transition = IntCurveSurface_In; + } } //----- Insertion du point if (nbpnt == 0) @@ -379,7 +393,9 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L, const double ParMin, co Bnd_Box boxLine; bndTool.LinBox(L, myPolyhedron->Bounding(), boxLine); if (bndTool.NbSegments() == 0) + { return; + } for (int nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++) { double pinf = bndTool.BeginParam(nbseg); @@ -400,9 +416,13 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L, const double ParMin, co else { if (parinf > pinf) + { parinf = pinf; + } if (parsup < psup) + { parsup = psup; + } } } if (parinf > ParMax) @@ -414,11 +434,17 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L, const double ParMin, co return; } if (parinf < ParMin) + { parinf = ParMin; + } if (parsup > ParMax) + { parsup = ParMax; + } if (parinf > (parsup - 1e-9)) + { return; + } IntCurveSurface_ThePolygonOfHInter polygon(HLL, parinf, parsup, 2); #if OPTIMISATION if (!myBndBounding) @@ -469,11 +495,17 @@ void IntCurvesFace_Intersector::Perform(const occ::handle& HCu, parinf = IntCurveSurface_TheHCurveTool::FirstParameter(HCu); parsup = IntCurveSurface_TheHCurveTool::LastParameter(HCu); if (parinf < ParMin) + { parinf = ParMin; + } if (parsup > ParMax) + { parsup = ParMax; + } if (parinf > (parsup - 1e-9)) + { return; + } int nbs; nbs = IntCurveSurface_TheHCurveTool::NbSamples(HCu, parinf, parsup); diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Arc.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Arc.cxx index 36c74ae195..6dfc5b5d50 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Arc.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Arc.cxx @@ -85,9 +85,13 @@ occ::handle MAT_Arc::SecondNode() const occ::handle MAT_Arc::TheOtherNode(const occ::handle& aNode) const { if (FirstNode() == aNode) + { return SecondNode(); + } else if (SecondNode() == aNode) + { return FirstNode(); + } else { throw Standard_DomainError("MAT_Arc::TheOtherNode"); @@ -102,19 +106,27 @@ bool MAT_Arc::HasNeighbour(const occ::handle& aNode, const MAT_Side aS { // if (aNode == FirstNode()) return (!firstArcLeft == NULL); if (aNode == FirstNode()) + { return (firstArcLeft != nullptr); + } // if (aNode == SecondNode()) return (!secondArcLeft == NULL); if (aNode == SecondNode()) + { return (secondArcLeft != nullptr); + } } else { // if (aNode == FirstNode()) return (!firstArcRight == NULL); if (aNode == FirstNode()) + { return (firstArcRight != nullptr); + } // if (aNode == SecondNode()) return (!secondArcRight == NULL); if (aNode == SecondNode()) + { return (secondArcRight != nullptr); + } } throw Standard_DomainError("MAT_Arc::HasNeighbour"); } @@ -128,16 +140,24 @@ occ::handle MAT_Arc::Neighbour(const occ::handle& aNode, if (aSide == MAT_Left) { if (aNode == FirstNode()) + { return (MAT_Arc*)firstArcLeft; + } if (aNode == SecondNode()) + { return (MAT_Arc*)secondArcLeft; + } } else { if (aNode == FirstNode()) + { return (MAT_Arc*)firstArcRight; + } if (aNode == SecondNode()) + { return (MAT_Arc*)secondArcRight; + } } throw Standard_DomainError("MAT_Arc::Neighbour"); } @@ -189,9 +209,13 @@ void MAT_Arc::SetSecondNode(const occ::handle& aNode) void MAT_Arc::SetFirstArc(const MAT_Side aSide, const occ::handle& anArc) { if (aSide == MAT_Left) + { firstArcLeft = anArc.get(); + } else + { firstArcRight = anArc.get(); + } } //================================================================================================= @@ -199,9 +223,13 @@ void MAT_Arc::SetFirstArc(const MAT_Side aSide, const occ::handle& anAr void MAT_Arc::SetSecondArc(const MAT_Side aSide, const occ::handle& anArc) { if (aSide == MAT_Left) + { secondArcLeft = anArc.get(); + } else + { secondArcRight = anArc.get(); + } } //================================================================================================= @@ -213,19 +241,31 @@ void MAT_Arc::SetNeighbour(const MAT_Side aSide, if (aSide == MAT_Left) { if (aNode == FirstNode()) + { firstArcLeft = anArc.get(); + } else if (aNode == SecondNode()) + { secondArcLeft = anArc.get(); + } else + { throw Standard_DomainError("MAT_Arc::SetNeighbour"); + } } else { if (aNode == FirstNode()) + { firstArcRight = anArc.get(); + } else if (aNode == SecondNode()) + { secondArcRight = anArc.get(); + } else + { throw Standard_DomainError("MAT_Arc::SetNeighbour"); + } } } diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Bisector.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Bisector.cxx index 4841ccd8b9..5342e542b1 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Bisector.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Bisector.cxx @@ -175,23 +175,31 @@ void MAT_Bisector::Dump(const int ashift, const int alevel) const int i; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " BISECTOR : " << thebisectornumber << std::endl; + } + std::cout << " BISECTOR : " << thebisectornumber << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " First edge : " << thefirstedge->EdgeNumber() << std::endl; + } + std::cout << " First edge : " << thefirstedge->EdgeNumber() << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; - std::cout << " Second edge : " << thesecondedge->EdgeNumber() << std::endl; + } + std::cout << " Second edge : " << thesecondedge->EdgeNumber() << '\n'; for (i = 0; i < ashift; i++) + { std::cout << " "; + } if (alevel) { if (!thelistofbisectors->More()) { - std::cout << " Bisectors List : " << std::endl; + std::cout << " Bisectors List : " << '\n'; thelistofbisectors->Dump(ashift + 1, 1); } } - std::cout << std::endl; + std::cout << '\n'; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Graph.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Graph.cxx index 6aeb63a877..bbb6e01793 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Graph.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Graph.cxx @@ -233,7 +233,9 @@ void MAT_Graph::FusionOfBasicElts(const int IndexElt1, occ::handle Elt2 = theBasicElts(IndexElt2); if (Elt1 == Elt2) + { return; + } int i; occ::handle Zone2 = new MAT_Zone(Elt2); @@ -381,9 +383,13 @@ void MAT_Graph::FusionOfArcs(const occ::handle& Arc1, const occ::handle { occ::handle BE; if (i == 1) + { BE = theBasicElts(anArc2->FirstElement()->Index()); + } else + { BE = theBasicElts(anArc2->SecondElement()->Index()); + } if (BE->StartArc() == anArc2) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Zone.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Zone.cxx index afb2d9c3f9..1396e925e7 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Zone.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT/MAT_Zone.cxx @@ -49,7 +49,9 @@ void MAT_Zone::Perform(const occ::handle& aBasicElt) // Si le premier arc correspondant a la zone est Null => Sequence vide. // ------------------------------------------------------------------------ if (aBasicElt->EndArc().IsNull()) + { return; + } // ---------------------------- // Angle rentrant => Zone Vide. diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Circuit.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Circuit.cxx index cb688d021b..615b80d0aa 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Circuit.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Circuit.cxx @@ -77,9 +77,13 @@ void MAT2d_Circuit::Perform( occ::handle ConnexionNul; if (Trigo) + { direction = 1.; + } else + { direction = -1.; + } //--------------------- // Reinitialisation SD. @@ -103,11 +107,17 @@ void MAT2d_Circuit::Perform( // if ( P1.IsEqual(P2,Precision::Confusion())) Open(i) = false; // else Open(i) = true; if (IsClosed(i)) + { Open(i) = false; + } else if (P1.IsEqual(P2, Precision::Confusion())) + { Open(i) = false; + } else + { Open(i) = true; + } // Modified by Sergey KHROMOV - Wed Mar 6 16:59:04 2002 End } @@ -164,9 +174,13 @@ void MAT2d_Circuit::Perform( { occ::handle CF; if (Road.IsRoot(i)) + { CF = ConnexionNul; + } else + { CF = Road.Father(i); + } if (Road.IsConnexionsFrom(i)) { DoubleLine(FigItem.ChangeValue(i), Road.ConnexionsFrom(i), CF, direction); @@ -233,9 +247,13 @@ bool MAT2d_Circuit::IsSharpCorner(const occ::handle& Geom1, while (NbTest <= 10) { if ((ProVec)*Direction < -TolAng) + { return true; // Saillant. + } if ((ProVec)*Direction > TolAng) + { return false; // Rentrant. + } else { if (DotProd > 0) @@ -270,7 +288,9 @@ bool MAT2d_Circuit::IsSharpCorner(const occ::handle& Geom1, D /= 10; if (Direction < 0.) + { D = -D; + } occ::handle HC1 = new Geom2dAdaptor_Curve(C1); occ::handle HC2 = new Geom2dAdaptor_Curve(C2); @@ -301,16 +321,22 @@ bool MAT2d_Circuit::IsSharpCorner(const occ::handle& Geom1, DotProd = Dir1.Dot(Dir2); ProVec = Dir1 ^ Dir2; if ((ProVec)*Direction < -TolAng) + { return true; // Saillant. + } if ((ProVec)*Direction > TolAng) + { return false; // Rentrant. + } NbTest++; } return false; } else + { return false; + } } return false; } @@ -612,7 +638,9 @@ void MAT2d_Circuit::DoubleLine(NCollection_Sequence for (i = 1; i < 2 * NbItems - 2; i++) { if (Corres(i) == 0) + { Corres(i) = Corres(2 * NbItems - i); + } } #ifdef OCCT_DEBUG @@ -714,7 +742,9 @@ void MAT2d_Circuit::SortRefToEqui(const MAT2d_BiInt& BiRef) for (i = 1; i <= S.Length(); i++) { if (!ConnexionOn(S.Value(i))) + { break; + } } if (i > 1 && i <= S.Length()) { @@ -750,9 +780,13 @@ double MAT2d_Circuit::Side(const occ::handle& Curve = occ::down_cast(Line.Value(C1->IndexItemOnFirst())); gp_Vec2d Vect2 = Curve->DN(C1->ParameterOnFirst(), 1); if ((Vect1 ^ Vect2) > 0.) + { return -1.; + } else + { return 1.; + } } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Connexion.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Connexion.cxx index ac8befac6b..59967fbc91 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Connexion.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Connexion.cxx @@ -247,28 +247,28 @@ void MAT2d_Connexion::Dump(const int, const int Offset) const { int MyOffset = Offset; Indent(Offset); - std::cout << "MAT2d_Connexion :" << std::endl; + std::cout << "MAT2d_Connexion :" << '\n'; MyOffset++; Indent(MyOffset); - std::cout << "IndexFirstLine :" << lineA << std::endl; + std::cout << "IndexFirstLine :" << lineA << '\n'; Indent(MyOffset); - std::cout << "IndexSecondLine :" << lineB << std::endl; + std::cout << "IndexSecondLine :" << lineB << '\n'; Indent(MyOffset); - std::cout << "IndexItemOnFirst :" << itemA << std::endl; + std::cout << "IndexItemOnFirst :" << itemA << '\n'; Indent(MyOffset); - std::cout << "IndexItemOnSecond :" << itemB << std::endl; + std::cout << "IndexItemOnSecond :" << itemB << '\n'; Indent(MyOffset); - std::cout << "ParameterOnFirst :" << parameterOnA << std::endl; + std::cout << "ParameterOnFirst :" << parameterOnA << '\n'; Indent(MyOffset); - std::cout << "ParameterOnSecond :" << parameterOnB << std::endl; + std::cout << "ParameterOnSecond :" << parameterOnB << '\n'; Indent(MyOffset); - std::cout << "PointOnFirst :" << std::endl; - std::cout << " X = " << pointA.X() << std::endl; - std::cout << " Y = " << pointA.Y() << std::endl; + std::cout << "PointOnFirst :" << '\n'; + std::cout << " X = " << pointA.X() << '\n'; + std::cout << " Y = " << pointA.Y() << '\n'; Indent(MyOffset); - std::cout << "PointOnSecond :" << std::endl; - std::cout << " X = " << pointB.X() << std::endl; - std::cout << " Y = " << pointB.Y() << std::endl; + std::cout << "PointOnSecond :" << '\n'; + std::cout << " X = " << pointB.X() << '\n'; + std::cout << " Y = " << pointB.Y() << '\n'; Indent(MyOffset); - std::cout << "Distance :" << distance << std::endl; + std::cout << "Distance :" << distance << '\n'; } diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Mat2d.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Mat2d.cxx index adc8edb18b..5a36bacf53 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Mat2d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Mat2d.cxx @@ -264,7 +264,9 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) // Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin if (theedgelist->Number() < 3) + { break; + } // Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End //--------------------------------------------------- @@ -283,15 +285,21 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) //-------------------------------------------------------------- if (NbIterBis <= EvenNbIterBis + 1) + { EdgeNumbers(NbIterBis) = theedgelist->Number(); + } else { for (k = 1; k <= EvenNbIterBis; k++) + { EdgeNumbers(k) = EdgeNumbers(k + 1); + } EdgeNumbers(EvenNbIterBis + 1) = theedgelist->Number(); } if (EdgeNumbers(EvenNbIterBis + 1) == EdgeNumbers(1)) + { ToNullifyNoofbisectorstoremove = true; + } for (i = 1; i < theedgelist->Number() - 1; i++) { @@ -307,7 +315,9 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) { if (firstbisector->IndexNumber() >= beginbisector || secondbisector->IndexNumber() >= beginbisector) + { Intersect(atool, 0, noofbisectorstoremove, firstbisector, secondbisector); + } } else { @@ -329,9 +339,13 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) //------------------------------- if (ToNullifyNoofbisectorstoremove) + { noofbisectorstoremove = 0; + } if (noofbisectorstoremove == 0) + { break; + } //--------------------------------------------------- // Annulation des bissectrices a effacer. (etape 2.4) @@ -417,16 +431,22 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) //----------------------------------------------------------- if (bisectortoremove->BisectorNumber() == bisectortwotoremove(i)->BisectorNumber()) + { break; + } //----------------------- // Descente dans l arbre. //----------------------- if (typeofbisectortoremove(i) == 1) + { bisectortoremove = bisectortoremove->FirstBisector(); + } else + { bisectortoremove = bisectortoremove->LastBisector(); + } } //---------------------------------------------------- // Fin boucle d annulation des bissectrices issue de @@ -618,12 +638,16 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) shift = 0; all = 0; if (narea == 1 && noofarea(0) == theedgelist->Number()) + { all = 1; + } for (i = 0; i < narea; i++) { if (i == 1) + { shift = shift - compact; + } theedgelist->First(); theedgelist->Next(); edgetoremove = theedgelist->Brackets(firstarea(i) - shift); @@ -729,7 +753,9 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) //---------------------------------------------- if (interrupt) + { semiInfinite = true; + } else { semiInfinite = false; @@ -754,11 +780,15 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) if (atool.TrimBisector(edge->SecondBisector(), edge->FirstBisector()->IssuePoint())) { if (edge->SecondBisector()->EndPoint() == 0) + { edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint()); + } bisectormap(noofbisectors - 1)->AddBisector(edge->SecondBisector()); } else + { semiInfinite = true; + } // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End } else @@ -767,11 +797,15 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool) if (atool.TrimBisector(edge->FirstBisector(), edge->SecondBisector()->IssuePoint())) { if (edge->FirstBisector()->EndPoint() == 0) + { edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint()); + } bisectormap(noofbisectors - 1)->AddBisector(edge->FirstBisector()); } else + { semiInfinite = true; + } // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End } if (!semiInfinite) @@ -1002,7 +1036,9 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) // Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin if (theedgelist->Number() < 3) + { break; + } // Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End //--------------------------------------------------- @@ -1020,15 +1056,21 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) //-------------------------------------------------------------- if (NbIterBis <= EvenNbIterBis + 1) + { EdgeNumbers(NbIterBis) = theedgelist->Number(); + } else { for (k = 1; k <= EvenNbIterBis; k++) + { EdgeNumbers(k) = EdgeNumbers(k + 1); + } EdgeNumbers(EvenNbIterBis + 1) = theedgelist->Number(); } if (EdgeNumbers(EvenNbIterBis + 1) == EdgeNumbers(1)) + { ToNullifyNoofbisectorstoremove = true; + } for (i = 0; i < theedgelist->Number(); i++) { @@ -1044,7 +1086,9 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) { if (firstbisector->IndexNumber() >= beginbisector || secondbisector->IndexNumber() >= beginbisector) + { Intersect(atool, 0, noofbisectorstoremove, firstbisector, secondbisector); + } } else { @@ -1066,9 +1110,13 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) //------------------------------- if (ToNullifyNoofbisectorstoremove) + { noofbisectorstoremove = 0; + } if (noofbisectorstoremove == 0) + { break; + } //--------------------------------------------------- // Annulation des bissectrices a effacer. (etape 2.4) @@ -1154,16 +1202,22 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) //----------------------------------------------------------- if (bisectortoremove->BisectorNumber() == bisectortwotoremove(i)->BisectorNumber()) + { break; + } //----------------------- // Descente dans l arbre. //----------------------- if (typeofbisectortoremove(i) == 1) + { bisectortoremove = bisectortoremove->FirstBisector(); + } else + { bisectortoremove = bisectortoremove->LastBisector(); + } } //---------------------------------------------------- // Fin boucle d annulation des bissectrices issue de @@ -1361,12 +1415,16 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) shift = 0; all = 0; if (narea == 1 && noofarea(0) == theedgelist->Number()) + { all = 1; + } for (i = 0; i < narea; i++) { if (i == 1) + { shift = shift - compact; + } theedgelist->First(); edgetoremove = theedgelist->Brackets(firstarea(i) - shift); @@ -1471,7 +1529,9 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) //---------------------------------------------- if (interrupt) + { semiInfinite = true; + } else { semiInfinite = false; @@ -1496,11 +1556,15 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) if (atool.TrimBisector(edge->SecondBisector(), edge->FirstBisector()->IssuePoint())) { if (edge->SecondBisector()->EndPoint() == 0) + { edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint()); + } bisectormap(noofbisectors - 1)->AddBisector(edge->SecondBisector()); } else + { semiInfinite = true; + } // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End } else @@ -1509,11 +1573,15 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool) if (atool.TrimBisector(edge->FirstBisector(), edge->SecondBisector()->IssuePoint())) { if (edge->FirstBisector()->EndPoint() == 0) + { edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint()); + } bisectormap(noofbisectors - 1)->AddBisector(edge->FirstBisector()); } else + { semiInfinite = true; + } // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End } if (!semiInfinite) @@ -1581,11 +1649,17 @@ void MAT2d_Mat2d::LoadBisectorsToRemove(int& noofbis lastbisectortoremove[1] = lastbisectortoremove2; if (distance1 < Precision::Infinite() && distance2 == Precision::Infinite()) + { index = 0; + } else if (distance2 < Precision::Infinite() && distance1 == Precision::Infinite()) + { index = 1; + } else + { index = -1; + } if (index != -1) { @@ -1598,7 +1672,9 @@ void MAT2d_Mat2d::LoadBisectorsToRemove(int& noofbis found = j; if (bisectortwotoremove(j)->BisectorNumber() < lastbisectortoremove[index]->BisectorNumber()) + { found = -1; + } break; } } @@ -1615,7 +1691,9 @@ void MAT2d_Mat2d::LoadBisectorsToRemove(int& noofbis typeofbisectortoremove.Bind(found, index + 1); if (found == noofbisectorstoremove) + { noofbisectorstoremove++; + } } } } @@ -1657,9 +1735,13 @@ void MAT2d_Mat2d::Intersect(MAT2d_Tool2d& atool, if (aside == 0) { if (bisectornumber == 0) + { firstbisectortoremove[bisectornumber] = secondbisector; + } else + { firstbisectortoremove[bisectornumber] = firstbisector; + } } else if (aside == 1) { @@ -1679,12 +1761,18 @@ void MAT2d_Mat2d::Intersect(MAT2d_Tool2d& atool, else { if (firstbisectortoremove[bisectornumber]->List()->IsEmpty()) + { continue; + } if (bisectornumber == 0) + { previousbisector = firstbisectortoremove[bisectornumber]->FirstBisector(); + } else + { previousbisector = firstbisectortoremove[bisectornumber]->LastBisector(); + } } distant = distance[bisectornumber]; @@ -1692,9 +1780,13 @@ void MAT2d_Mat2d::Intersect(MAT2d_Tool2d& atool, { if (bisectornumber == 0) + { previousbisector = previousbisector->FirstBisector(); + } else + { previousbisector = previousbisector->LastBisector(); + } if (aside == 1 || (aside == 0 && bisectornumber == 0)) { diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_MiniPath.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_MiniPath.cxx index 37f4079682..23e3429347 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_MiniPath.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_MiniPath.cxx @@ -55,7 +55,9 @@ void MAT2d_MiniPath::Perform( indStart = IndStart; theDirection = 1.; if (Sense) + { theDirection = -1.; + } //---------------------------------------------------------------------- // Calcul des connexions qui realisent le minimum de distance entre les @@ -176,7 +178,6 @@ void MAT2d_MiniPath::Append(const occ::handle& C) Seq.InsertBefore(IndexAfter, C); } theFather.Bind(C->IndexSecondLine(), C); - return; } //============================================================================ @@ -250,7 +251,9 @@ void MAT2d_MiniPath::ExploSons(NCollection_Sequence int Index = CRef->IndexSecondLine(); if (!theConnexions.IsBound(Index)) + { return; + } const NCollection_Sequence>& SC = theConnexions(Index); occ::handle CRR = CRef->Reverse(); diff --git a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Tool2d.cxx b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Tool2d.cxx index dbe7f3eb8d..dd73a4b7fb 100644 --- a/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Tool2d.cxx +++ b/src/ModelingAlgorithms/TKTopAlgo/MAT2d/MAT2d_Tool2d.cxx @@ -109,9 +109,13 @@ void MAT2d_Tool2d::InitItems(const occ::handle& EquiCircuit) void MAT2d_Tool2d::Sense(const MAT_Side aside) { if (aside == MAT_Left) + { theDirection = 1.; + } else + { theDirection = -1.; + } } //================================================================================================= @@ -178,9 +182,13 @@ int MAT2d_Tool2d::TangentBefore(const int anitem, const bool IsOpenResult) theNumberOfVecs++; if (!IsOpenResult) + { item = (anitem == theCircuit->NumberOfItems()) ? 1 : (anitem + 1); + } else + { item = (anitem == theCircuit->NumberOfItems()) ? (anitem - 1) : (anitem + 1); + } if (theCircuit->ConnexionOn(item)) { double x1, y1, x2, y2; @@ -237,9 +245,13 @@ int MAT2d_Tool2d::TangentAfter(const int anitem, const bool IsOpenResult) else { if (!IsOpenResult) + { item = (anitem == 1) ? theCircuit->NumberOfItems() : (anitem - 1); + } else + { item = (anitem == 1) ? 2 : (anitem - 1); + } curve = occ::down_cast(theCircuit->Value(item)); double param = (IsOpenResult && anitem == 1) ? curve->FirstParameter() : curve->LastParameter(); @@ -274,7 +286,9 @@ void MAT2d_Tool2d::CreateBisector(const occ::handle& abisector) bool InitialNeighbour = ontheline; if (theCircuit->ConnexionOn(edge2number)) + { ontheline = false; + } elt1 = theCircuit->Value(edge1number); elt2 = theCircuit->Value(edge2number); @@ -449,7 +463,9 @@ void MAT2d_Tool2d::TrimBisec(Bisector_Bisec& B1, } } if (Line1.IsNull() && Line2.IsNull()) + { return; + } //----------------------------------------------------------------------- // Restriction de la bisectrice par les demi-droites liees aux connexions @@ -493,7 +509,9 @@ bool MAT2d_Tool2d::TrimBisector(const occ::handle& abisector) param = bisector->BasisCurve()->LastParameter(); } if (bisector->FirstParameter() == param) + { return false; + } bisector->SetTrim(bisector->FirstParameter(), param); return true; @@ -515,12 +533,18 @@ bool MAT2d_Tool2d::TrimBisector(const occ::handle& abisector, cons if (Bisector->BasisCurve()->IsPeriodic()) { if (Bisector->FirstParameter() > Param) + { Param = Param + 2 * M_PI; + } } if (Bisector->FirstParameter() >= Param) + { return false; + } if (Bisector->LastParameter() < Param) + { return false; + } Bisector->SetTrim(Bisector->FirstParameter(), Param); #ifdef OCCT_DEBUG @@ -582,7 +606,9 @@ bool MAT2d_Tool2d::Projection(const int IEdge, const gp_Pnt2d& PCom, double& Dis double R = C1.Circle().Radius(); double EpsCirc = 100. * Eps; if (R < 1.) + { EpsCirc = Eps / R; + } if (((ParamMax - ParamMin + 2 * EpsCirc) < 2 * M_PI)) { ParamMax = ParamMax + EpsCirc; @@ -671,18 +697,30 @@ bool MAT2d_Tool2d::IsSameDistance(const occ::handle& BisectorOne, bool isDone3 = true, isDone4 = true; if (IEdge3 == IEdge1) + { Dist(3) = Dist(1); + } else if (IEdge3 == IEdge2) + { Dist(3) = Dist(2); + } else + { isDone3 = Projection(IEdge3, PCom, Dist(3)); + } if (IEdge4 == IEdge1) + { Dist(4) = Dist(1); + } else if (IEdge4 == IEdge2) + { Dist(4) = Dist(2); + } else + { isDone4 = Projection(IEdge4, PCom, Dist(4)); + } // if (isDone3) { @@ -722,16 +760,20 @@ bool MAT2d_Tool2d::IsSameDistance(const occ::handle& BisectorOne, if (theJoinType == GeomAbs_Intersection && Precision::IsInfinite(Distance)) { for (int i = 2; i <= 4; i++) + { if (!Precision::IsInfinite(Dist(i))) { Distance = Dist(i); break; } + } } for (int i = 1; i <= 4; i++) { if (theJoinType == GeomAbs_Intersection && Precision::IsInfinite(Dist(i))) + { continue; + } if (std::abs(Dist(i) - Distance) > EpsDist) { Distance = Precision::Infinite(); @@ -761,7 +803,9 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector ChangeGeomBis(BisectorTwo->BisectorNumber()).ChangeValue(); if (Bisector1.IsNull() || Bisector2.IsNull()) + { return Precision::Infinite(); + } //------------------------------------------------------------------------- // Si les deux bissectrices separent des elements consecutifs et qu elles @@ -782,7 +826,9 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector C2 = theCircuit->Connexion(IS2); if (C2->IndexFirstLine() == C1->IndexSecondLine() && C1->IndexFirstLine() == C2->IndexSecondLine()) + { return Precision::Infinite(); + } } // ----------------------------------------- @@ -792,9 +838,13 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector IntRes2d_Domain Domain2 = Domain(Bisector2, Tolerance); if (Domain1.LastParameter() - Domain1.FirstParameter() < Tolerance) + { return Precision::Infinite(); + } if (Domain2.LastParameter() - Domain2.FirstParameter() < Tolerance) + { return Precision::Infinite(); + } #ifdef OCCT_DEBUG bool Affich = false; @@ -841,10 +891,14 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector // ------------------------------------------------------------------------- if (!Intersect.IsDone()) + { return Precision::Infinite(); + } if (Intersect.IsEmpty()) + { return Precision::Infinite(); + } DistanceMini = Precision::Infinite(); Param1 = Precision::Infinite(); @@ -874,7 +928,9 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector { PointOnSegment = P1; if (IsSameDistance(BisectorOne, BisectorTwo, PointOnSegment, Distance)) + { PointRetenu = true; + } } else if (SegmentLength <= MaxSegmentLength) { @@ -942,7 +998,9 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector } if (!SolutionValide) + { return Precision::Infinite(); + } theNumberOfPnts++; theGeomPnts.Bind(theNumberOfPnts, PointSolution); IntPnt = theNumberOfPnts; @@ -1017,11 +1075,15 @@ double MAT2d_Tool2d::IntersectBisector(const occ::handle& Bisector if (BisectorOne->SecondParameter() < Precision::Infinite() && BisectorOne->SecondParameter() < Param1 * (1. - Tolerance)) + { return Precision::Infinite(); + } if (BisectorTwo->FirstParameter() < Precision::Infinite() && BisectorTwo->FirstParameter() < Param2 * (1. - Tolerance)) + { return Precision::Infinite(); + } BisectorOne->SecondParameter(Param1); BisectorTwo->FirstParameter(Param2); @@ -1209,11 +1271,17 @@ static occ::handle Type(const occ::handle& aGeom bool AreNeighbours(const int IEdge1, const int IEdge2, const int NbEdge) { if (std::abs(IEdge1 - IEdge2) == 1) + { return true; + } else if (std::abs(IEdge1 - IEdge2) == NbEdge - 1) + { return true; + } else + { return false; + } } //================================================================================================= @@ -1253,7 +1321,9 @@ static void SetTrim(Bisector_Bisec& Bis, const occ::handle& Line1) // parametre. // ------------------------------------------------------------------------ if (UTrim < UB2 && UTrim > UB1) + { Bisector->SetTrim(UB1, UTrim); + } } //================================================================================================= @@ -1333,9 +1403,13 @@ bool CheckEnds(const occ::handle& Elt, double df = PCom.Distance(aPf); double dl = PCom.Distance(aPl); if (std::abs(df - Distance) <= Tol) + { return true; + } if (std::abs(dl - Distance) <= Tol) + { return true; + } } return false; } diff --git a/src/ModelingData/TKBRep/BRep/BRep_Builder.cxx b/src/ModelingData/TKBRep/BRep/BRep_Builder.cxx index 418c48712f..6f1a20fdb6 100644 --- a/src/ModelingData/TKBRep/BRep/BRep_Builder.cxx +++ b/src/ModelingData/TKBRep/BRep/BRep_Builder.cxx @@ -70,7 +70,9 @@ static void UpdateCurves(NCollection_List> { GC->Range(f, l); if (GC->IsCurve3D()) + { break; + } } itcr.Next(); } @@ -268,7 +270,9 @@ static void UpdateCurves(NCollection_List> } bool iscos = GC->IsCurveOnSurface(S, L); if (iscos) + { break; + } } itcr.Next(); } @@ -332,7 +336,9 @@ static void UpdateCurves(NCollection_List> } bool iscos = GC->IsCurveOnSurface(S, L); if (iscos) + { break; + } } itcr.Next(); } @@ -380,7 +386,9 @@ static void UpdateCurves(NCollection_List> const occ::handle& cr = itcr.Value(); bool isregu = cr->IsRegularity(S1, S2, L1, L2); if (isregu) + { break; + } itcr.Next(); } @@ -407,7 +415,9 @@ static void UpdatePoints(NCollection_List> const occ::handle& pr = itpr.Value(); bool isponc = pr->IsPointOnCurve(C, L); if (isponc) + { break; + } itpr.Next(); } @@ -435,7 +445,9 @@ static void UpdatePoints(NCollection_List> const occ::handle& pr = itpr.Value(); bool isponcons = pr->IsPointOnCurveOnSurface(PC, S, L); if (isponcons) + { break; + } itpr.Next(); } @@ -463,7 +475,9 @@ static void UpdatePoints(NCollection_List> const occ::handle& pr = itpr.Value(); bool ispons = pr->IsPointOnSurface(S, L); if (ispons) + { break; + } itpr.Next(); } @@ -751,9 +765,13 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, if (itcr.Value()->IsPolygon3D()) { if (P.IsNull()) + { lcr.Remove(itcr); + } else + { itcr.Value()->Polygon3D(P); + } TE->Modified(true); return; } @@ -809,7 +827,9 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, } if (isModified) + { TE->Modified(true); + } } //================================================================================================= @@ -856,7 +876,9 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, } if (isModified) + { TE->Modified(true); + } } //================================================================================================= @@ -891,7 +913,9 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, while (itcr.More()) { if (itcr.Value()->IsPolygonOnSurface(S, l)) + { break; + } itcr.Next(); } @@ -946,7 +970,9 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, while (itcr.More()) { if (itcr.Value()->IsPolygonOnSurface(S, l)) + { break; + } itcr.Next(); } @@ -1081,7 +1107,9 @@ void BRep_Builder::Range(const TopoDS_Edge& E, { GC = occ::down_cast(itcr.Value()); if (!GC.IsNull() && (!Only3d || GC->IsCurve3D())) + { GC->SetRange(First, Last); + } itcr.Next(); } @@ -1119,7 +1147,9 @@ void BRep_Builder::Range(const TopoDS_Edge& E, } if (!itcr.More()) + { throw Standard_DomainError("BRep_Builder::Range, no pcurve"); + } TE->Modified(true); } @@ -1193,7 +1223,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const double Tol) const { if (Precision::IsPositiveInfinite(Par) || Precision::IsNegativeInfinite(Par)) + { throw Standard_DomainError("BRep_Builder::Infinite parameter"); + } const occ::handle& TV = *((occ::handle*)&V.TShape()); const occ::handle& TE = *((occ::handle*)&E.TShape()); @@ -1215,7 +1247,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, // RLE, june 94 if (!itv.More() && TE->Degenerated()) + { ori = V.Orientation(); + } while (itv.More()) { @@ -1224,7 +1258,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, { ori = Vcur.Orientation(); if (ori == V.Orientation()) + { break; + } } itv.Next(); } @@ -1239,9 +1275,13 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, if (!GC.IsNull()) { if (ori == TopAbs_FORWARD) + { GC->First(Par); + } else if (ori == TopAbs_REVERSED) + { GC->Last(Par); + } else { NCollection_List>& lpr = TV->ChangePoints(); @@ -1264,7 +1304,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, } if ((ori != TopAbs_FORWARD) && (ori != TopAbs_REVERSED)) + { TV->Modified(true); + } TV->UpdateTolerance(Tol); TE->Modified(true); } @@ -1282,7 +1324,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const double Tol) const { if (Precision::IsPositiveInfinite(Par) || Precision::IsNegativeInfinite(Par)) + { throw Standard_DomainError("BRep_Builder::Infinite parameter"); + } // Find the curve representation TopLoc_Location l = L.Predivided(V.Location()); @@ -1305,7 +1349,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, // RLE, june 94 if (!itv.More() && TE->Degenerated()) + { ori = V.Orientation(); + } while (itv.More()) { @@ -1314,7 +1360,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, { ori = Vcur.Orientation(); if (ori == V.Orientation()) + { break; + } } itv.Next(); } @@ -1332,9 +1380,13 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, if (GC->IsCurveOnSurface(S, L)) { // xpu020198 : BUC60407 if (ori == TopAbs_FORWARD) + { GC->First(Par); + } else if (ori == TopAbs_REVERSED) + { GC->Last(Par); + } else { NCollection_List>& lpr = TV->ChangePoints(); @@ -1349,7 +1401,9 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, } if (!itcr.More()) + { throw Standard_DomainError("BRep_Builder:: no pcurve"); + } TV->UpdateTolerance(Tol); TE->Modified(true); diff --git a/src/ModelingData/TKBRep/BRep/BRep_CurveOnClosedSurface.cxx b/src/ModelingData/TKBRep/BRep/BRep_CurveOnClosedSurface.cxx index c3272136c9..5688ba8461 100644 --- a/src/ModelingData/TKBRep/BRep/BRep_CurveOnClosedSurface.cxx +++ b/src/ModelingData/TKBRep/BRep/BRep_CurveOnClosedSurface.cxx @@ -123,9 +123,13 @@ occ::handle BRep_CurveOnClosedSurface::Copy() const void BRep_CurveOnClosedSurface::Update() { if (!Precision::IsNegativeInfinite(First())) + { myPCurve2->D0(First(), myUV21); + } if (!Precision::IsPositiveInfinite(Last())) + { myPCurve2->D0(Last(), myUV22); + } BRep_CurveOnSurface::Update(); } diff --git a/src/ModelingData/TKBRep/BRep/BRep_TEdge.cxx b/src/ModelingData/TKBRep/BRep/BRep_TEdge.cxx index 043f988bfe..b63d6095b2 100644 --- a/src/ModelingData/TKBRep/BRep/BRep_TEdge.cxx +++ b/src/ModelingData/TKBRep/BRep/BRep_TEdge.cxx @@ -49,9 +49,13 @@ bool BRep_TEdge::SameParameter() const void BRep_TEdge::SameParameter(const bool S) { if (S) + { myFlags |= ParameterMask; + } else + { myFlags &= ~ParameterMask; + } } //================================================================================================= @@ -66,9 +70,13 @@ bool BRep_TEdge::SameRange() const void BRep_TEdge::SameRange(const bool S) { if (S) + { myFlags |= RangeMask; + } else + { myFlags &= ~RangeMask; + } } //================================================================================================= @@ -83,9 +91,13 @@ bool BRep_TEdge::Degenerated() const void BRep_TEdge::Degenerated(const bool S) { if (S) + { myFlags |= DegeneratedMask; + } else + { myFlags &= ~DegeneratedMask; + } } //================================================================================================= diff --git a/src/ModelingData/TKBRep/BRep/BRep_Tool.cxx b/src/ModelingData/TKBRep/BRep/BRep_Tool.cxx index 50cd9f3735..e512120d6b 100644 --- a/src/ModelingData/TKBRep/BRep/BRep_Tool.cxx +++ b/src/ModelingData/TKBRep/BRep/BRep_Tool.cxx @@ -92,7 +92,9 @@ occ::handle BRep_Tool::Surface(const TopoDS_Face& F) const occ::handle& S = TF->Surface(); if (S.IsNull()) + { return S; + } TopLoc_Location L = F.Location() * TF->Location(); if (!L.IsIdentity()) @@ -138,9 +140,13 @@ double BRep_Tool::Tolerance(const TopoDS_Face& F) double p = TF->Tolerance(); constexpr double pMin = Precision::Confusion(); if (p > pMin) + { return p; + } else + { return pMin; + } } //================================================================================================= @@ -242,10 +248,14 @@ bool BRep_Tool::IsGeometric(const TopoDS_Edge& E) { occ::handle GC(occ::down_cast(cr)); if (!GC.IsNull() && !GC->Curve3D().IsNull()) + { return true; + } } else if (cr->IsCurveOnSurface()) + { return true; + } itcr.Next(); } return false; @@ -323,7 +333,9 @@ occ::handle BRep_Tool::CurveOnSurface(const TopoDS_Edge& { bool Eisreversed = (E.Orientation() == TopAbs_REVERSED); if (theIsStored) + { *theIsStored = true; + } // find the representation const BRep_TEdge* TE = static_cast(E.TShape().get()); @@ -340,9 +352,13 @@ occ::handle BRep_Tool::CurveOnSurface(const TopoDS_Edge& const BRep_GCurve* GC = static_cast(cr.get()); GC->Range(First, Last); if (GC->IsCurveOnClosedSurface() && Eisreversed) + { return GC->PCurve2(); + } else + { return GC->PCurve(); + } } itcr.Next(); } @@ -350,7 +366,9 @@ occ::handle BRep_Tool::CurveOnSurface(const TopoDS_Edge& // Curve is not found. Try projection on plane if (theIsStored) + { *theIsStored = false; + } return CurveOnPlane(E, S, L, First, Last); } @@ -371,13 +389,19 @@ occ::handle BRep_Tool::CurveOnPlane(const TopoDS_Edge& occ::handle GRTS; GRTS = occ::down_cast(S); if (!GRTS.IsNull()) + { GP = occ::down_cast(GRTS->BasisSurface()); + } else + { GP = occ::down_cast(S); + } if (GP.IsNull()) + { // not a plane return nullPCurve; + } // Check existence of 3d curve in edge double f, l; @@ -385,8 +409,10 @@ occ::handle BRep_Tool::CurveOnPlane(const TopoDS_Edge& occ::handle C3D = BRep_Tool::Curve(E, aCurveLocation, f, l); if (C3D.IsNull()) + { // no 3d curve return nullPCurve; + } aCurveLocation = aCurveLocation.Predivided(L); First = f; @@ -468,7 +494,9 @@ void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E, const int Index) { if (Index < 1) + { return; + } int i = 0; // find the representation @@ -484,11 +512,17 @@ void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E, // Compare index taking into account the fact that for the curves on // closed surfaces there are two PCurves if (i == Index) + { C = GC->PCurve(); + } else if (GC->IsCurveOnClosedSurface() && (++i == Index)) + { C = GC->PCurve2(); + } else + { continue; + } S = GC->Surface(); L = E.Location() * GC->Location(); @@ -552,9 +586,13 @@ occ::handle BRep_Tool::PolygonOnSurface(const TopoDS_Edge& if (cr->IsPolygonOnSurface(S, l)) { if (cr->IsPolygonOnClosedSurface() && Eisreversed) + { return cr->Polygon2(); + } else + { return cr->Polygon(); + } } itcr.Next(); } @@ -614,7 +652,9 @@ void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E, const BRep_PolygonOnSurface* PS = static_cast(cr.get()); i++; if (i > Index) + { break; + } if (i == Index) { P = PS->Polygon(); @@ -658,9 +698,13 @@ const occ::handle& BRep_Tool::PolygonOnTriangulatio if (cr->IsPolygonOnTriangulation(T, l)) { if (cr->IsPolygonOnClosedTriangulation() && Eisreversed) + { return cr->PolygonOnTriangulation2(); + } else + { return cr->PolygonOnTriangulation(); + } } itcr.Next(); } @@ -722,7 +766,9 @@ void BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& static_cast(cr.get()); i++; if (i > Index) + { break; + } if (i == Index) { T = PT->Triangulation(); @@ -751,7 +797,9 @@ bool BRep_Tool::IsClosed(const TopoDS_Edge& E, const TopoDS_Face& F) TopLoc_Location l; const occ::handle& S = BRep_Tool::Surface(F, l); if (IsClosed(E, S, l)) + { return true; + } const occ::handle& T = BRep_Tool::Triangulation(F, l); return IsClosed(E, T, l); } @@ -784,7 +832,9 @@ bool BRep_Tool::IsClosed(const TopoDS_Edge& E, { const occ::handle& cr = itcr.Value(); if (cr->IsCurveOnSurface(S, l) && cr->IsCurveOnClosedSurface()) + { return true; + } itcr.Next(); } return false; @@ -815,7 +865,9 @@ bool BRep_Tool::IsClosed(const TopoDS_Edge& E, { const occ::handle& cr = itcr.Value(); if (cr->IsPolygonOnTriangulation(T, l) && cr->IsPolygonOnClosedTriangulation()) + { return true; + } itcr.Next(); } return false; @@ -832,9 +884,13 @@ double BRep_Tool::Tolerance(const TopoDS_Edge& E) double p = TE->Tolerance(); constexpr double pMin = Precision::Confusion(); if (p > pMin) + { return p; + } else + { return pMin; + } } //================================================================================================= @@ -986,9 +1042,13 @@ void BRep_Tool::UVPoints(const TopoDS_Edge& E, occ::handle GRTS; GRTS = occ::down_cast(S); if (!GRTS.IsNull()) + { GP = occ::down_cast(GRTS->BasisSurface()); + } else + { GP = occ::down_cast(S); + } // end of modification from 21-05-97 if (!GP.IsNull()) { @@ -1150,7 +1210,9 @@ bool BRep_Tool::HasContinuity(const TopoDS_Edge& E, { const occ::handle& cr = itcr.Value(); if (cr->IsRegularity(S1, S2, l1, l2)) + { return true; + } itcr.Next(); } return false; @@ -1175,7 +1237,9 @@ GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E, { const occ::handle& cr = itcr.Value(); if (cr->IsRegularity(S1, S2, l1, l2)) + { return cr->Continuity(); + } itcr.Next(); } return GeomAbs_C0; @@ -1195,7 +1259,9 @@ bool BRep_Tool::HasContinuity(const TopoDS_Edge& E) { const occ::handle& CR = itcr.Value(); if (CR->IsRegularity()) + { return true; + } } return false; } @@ -1257,9 +1323,13 @@ double BRep_Tool::Tolerance(const TopoDS_Vertex& V) double p = aTVert->Tolerance(); constexpr double pMin = Precision::Confusion(); if (p > pMin) + { return p; + } else + { return pMin; + } } //================================================================================================= @@ -1308,7 +1378,9 @@ bool BRep_Tool::Parameter(const TopoDS_Vertex& theV, const TopoDS_Edge& theE, do } if (!VF.IsNull()) + { orient = VF.Orientation(); + } double f, l; @@ -1364,9 +1436,13 @@ bool BRep_Tool::Parameter(const TopoDS_Vertex& theV, const TopoDS_Edge& theE, do if (Pf.Distance(BRep_Tool::Pnt(theV)) < tol) { if (theV.Orientation() == TopAbs_FORWARD) + { res = f; // p = f; + } else + { res = l; // p = l; + } } } } @@ -1399,9 +1475,13 @@ bool BRep_Tool::Parameter(const TopoDS_Vertex& theV, const TopoDS_Edge& theE, do if ((p == PC->FirstParameter()) || (p == PC->LastParameter())) { if (theV.Orientation() == TopAbs_FORWARD) + { p = PC->FirstParameter(); + } else + { p = PC->LastParameter(); + } } } theParam = p; @@ -1424,7 +1504,9 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, const TopoDS_Edge& E) { double p; if (Parameter(V, E, p)) + { return p; + } throw Standard_NoSuchObject("BRep_Tool:: no parameter on edge"); } @@ -1463,12 +1545,16 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, if (V.IsSame(itv.Value())) { if (VF.IsNull()) + { VF = itv.Value(); + } else { rev = E.Orientation() == TopAbs_REVERSED; if (itv.Value().Orientation() == V.Orientation()) + { VF = itv.Value(); + } } } itv.Next(); @@ -1476,7 +1562,9 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, TopAbs_Orientation orient = TopAbs_INTERNAL; if (!VF.IsNull()) + { orient = VF.Orientation(); + } double f, l; @@ -1501,7 +1589,9 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, while (itpr.More()) { if (itpr.Value()->IsPointOnCurveOnSurface(PC, S, L)) + { return itpr.Value()->Parameter(); + } itpr.Next(); } } @@ -1527,9 +1617,13 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, { // Closed curves RLE 16 june 94 if (Precision::IsNegativeInfinite(f)) + { return res; + } if (Precision::IsPositiveInfinite(l)) + { return res; + } gp_Pnt Pf = C->Value(f).Transformed(L1.Transformation()); gp_Pnt Pl = C->Value(l).Transformed(L1.Transformation()); double tol = BRep_Tool::Tolerance(V); @@ -1538,9 +1632,13 @@ double BRep_Tool::Parameter(const TopoDS_Vertex& V, if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) { if (V.Orientation() == TopAbs_FORWARD) + { res = f; + } else + { res = l; + } } } } @@ -1592,9 +1690,13 @@ gp_Pnt2d BRep_Tool::Parameters(const TopoDS_Vertex& V, const TopoDS_Face& F) gp_Pnt2d Pf, Pl; UVPoints(E, F, Pf, Pl); if (V.IsSame(Vf)) + { return Pf; + } else + { return Pl; // Ambiguity (natural) for degenerated edges. + } } } throw Standard_NoSuchObject("BRep_Tool:: no parameters on surface"); @@ -1614,10 +1716,14 @@ bool BRep_Tool::IsClosed(const TopoDS_Shape& theShape) const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); if (BRep_Tool::Degenerated(E) || E.Orientation() == TopAbs_INTERNAL || E.Orientation() == TopAbs_EXTERNAL) + { continue; + } hasBound = true; if (!aMap.Add(E)) + { aMap.Remove(E); + } } return hasBound && aMap.IsEmpty(); } @@ -1630,10 +1736,14 @@ bool BRep_Tool::IsClosed(const TopoDS_Shape& theShape) { const TopoDS_Shape& V = exp.Current(); if (V.Orientation() == TopAbs_INTERNAL || V.Orientation() == TopAbs_EXTERNAL) + { continue; + } hasBound = true; if (!aMap.Add(V)) + { aMap.Remove(V); + } } return hasBound && aMap.IsEmpty(); } diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx index 185e63c4f8..20907a732c 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx @@ -110,11 +110,17 @@ void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, const bool AC) IsbyAC = AC; for (NbEdge = 0, wexp.Init(myWire); wexp.More(); wexp.Next()) + { if (!BRep_Tool::Degenerated(wexp.Current())) + { NbEdge++; + } + } if (NbEdge == 0) + { return; + } CurIndex = (NbEdge + 1) / 2; myCurves = new (NCollection_HArray1)(1, NbEdge); @@ -134,7 +140,9 @@ void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, const bool AC) myKnots->ChangeValue(ii + 1) += GCPnts_AbscissaPoint::Length(myCurves->ChangeValue(ii)); } else + { myKnots->SetValue(ii + 1, (double)ii); + } } } @@ -148,12 +156,16 @@ void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, const bool AC) if (VI.IsSame(VL)) { // The direction of parsing is always preserved if (Or == TopAbs_REVERSED) + { Forward = false; + } } else { // The direction of parsing is always reversed if (Or != TopAbs_REVERSED) + { Forward = false; + } } } @@ -183,9 +195,13 @@ void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, if (i1 == i2) { if (l > f) + { HC = occ::down_cast(myCurves->Value(i1).Trim(f, l, PTol)); + } else + { HC = occ::down_cast(myCurves->Value(i1).Trim(l, f, PTol)); + } myCurves->SetValue(i1, *HC); } else @@ -196,16 +212,24 @@ void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, k = c1.LastParameter(); if (k > f) + { HC = occ::down_cast(c1.Trim(f, k, PTol)); + } else + { HC = occ::down_cast(c1.Trim(k, f, PTol)); + } myCurves->SetValue(i1, *HC); k = c2.FirstParameter(); if (k <= l) + { HC = occ::down_cast(c2.Trim(k, l, PTol)); + } else + { HC = occ::down_cast(c2.Trim(l, k, PTol)); + } myCurves->SetValue(i2, *HC); } } @@ -237,7 +261,9 @@ double BRepAdaptor_CompCurve::LastParameter() const GeomAbs_Shape BRepAdaptor_CompCurve::Continuity() const { if (myCurves->Length() > 1) + { return GeomAbs_C0; + } return myCurves->Value(1).Continuity(); } @@ -245,7 +271,9 @@ int BRepAdaptor_CompCurve::NbIntervals(const GeomAbs_Shape S) const { int NbInt, ii; for (ii = 1, NbInt = 0; ii <= myCurves->Length(); ii++) + { NbInt += myCurves->ChangeValue(ii).NbIntervals(S); + } return NbInt; } @@ -265,12 +293,16 @@ void BRepAdaptor_CompCurve::Intervals(NCollection_Array1& T, const GeomA { // invert the direction of parsing for (kk = 1, jj = Ti->Length(); jj > 0; kk++, jj--) + { T(kk) = F + (Ti->Value(jj) - f) * delta; + } } else { for (kk = 1; kk <= Ti->Length(); kk++) + { T(kk) = F + (Ti->Value(kk) - f) * delta; + } } // and the next @@ -278,7 +310,9 @@ void BRepAdaptor_CompCurve::Intervals(NCollection_Array1& T, const GeomA { n = myCurves->ChangeValue(ii).NbIntervals(S); if (n != Ti->Length() - 1) + { Ti = new (NCollection_HArray1)(1, n + 1); + } myCurves->ChangeValue(ii).Intervals(Ti->ChangeArray1(), S); InvPrepare(ii, f, delta); F = myKnots->Value(ii); @@ -286,12 +320,16 @@ void BRepAdaptor_CompCurve::Intervals(NCollection_Array1& T, const GeomA { // invert the direction of parcing for (jj = Ti->Length() - 1; jj > 0; kk++, jj--) + { T(kk) = F + (Ti->Value(jj) - f) * delta; + } } else { for (jj = 2; jj <= Ti->Length(); kk++, jj++) + { T(kk) = F + (Ti->Value(jj) - f) * delta; + } } } } @@ -377,7 +415,9 @@ double BRepAdaptor_CompCurve::Resolution(const double R3d) const { r = myCurves->Value(ii).Resolution(R3d); if (r < Res) + { Res = r; + } } return Res; } @@ -473,25 +513,33 @@ void BRepAdaptor_CompCurve::Prepare(double& W, double& Delta, int& theCurIndex) if (myKnots->Value(theCurIndex) > Wtest) { for (ii = theCurIndex - 1; ii > 0 && !Trouve; ii--) + { if (myKnots->Value(ii) <= Wtest) { theCurIndex = ii; Trouve = true; } + } if (!Trouve) + { theCurIndex = 1; // Out of limits... + } } else if (myKnots->Value(theCurIndex + 1) <= Wtest) { for (ii = theCurIndex + 1; ii <= myCurves->Length() && !Trouve; ii++) + { if (myKnots->Value(ii + 1) > Wtest) { theCurIndex = ii; Trouve = true; } + } if (!Trouve) + { theCurIndex = myCurves->Length(); // Out of limits... + } } // Invert ? @@ -504,7 +552,9 @@ void BRepAdaptor_CompCurve::Prepare(double& W, double& Delta, int& theCurIndex) BRep_Tool::Range(E, f, l); Delta = myKnots->Value(theCurIndex + 1) - myKnots->Value(theCurIndex); if (Delta > PTol * 1.e-9) + { Delta = (l - f) / Delta; + } if (Reverse) { @@ -531,7 +581,9 @@ void BRepAdaptor_CompCurve::InvPrepare(const int index, double& First, double& D BRep_Tool::Range(E, f, l); Delta = myKnots->Value(index + 1) - myKnots->Value(index); if (l - f > PTol * 1.e-9) + { Delta /= (l - f); + } if (Reverse) { diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Surface.cxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Surface.cxx index 49b057b622..89857e4d80 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Surface.cxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Surface.cxx @@ -64,7 +64,9 @@ void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F, const bool Restrictio TopLoc_Location L; const occ::handle& aSurface = BRep_Tool::Surface(F, L); if (aSurface.IsNull()) + { return; + } if (Restriction) { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx index ed78a99784..1541649be4 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx @@ -45,7 +45,9 @@ Standard_GUID generateRandomGUID() aUUID.Data2 = static_cast(aRand1 >> 32); aUUID.Data3 = static_cast(aRand1 >> 48); for (int i = 0; i < 8; ++i) + { aUUID.Data4[i] = static_cast(aRand2 >> (i * 8)); + } return Standard_GUID(aUUID); } @@ -286,7 +288,9 @@ const NCollection_DynamicArray& BRepGraph::RootProductIds() const BRepGraphInc::BaseDef* BRepGraph::topoEntity(const BRepGraph_NodeId theId) const { if (!theId.IsValid()) + { return nullptr; + } const BRepGraphInc_Storage& aStorage = myData->myIncStorage; switch (theId.NodeKind) { @@ -344,7 +348,9 @@ const BRepGraphInc::BaseDef* BRepGraph::topoEntity(const BRepGraph_NodeId theId) BRepGraphInc::BaseDef* BRepGraph::changeTopoEntity(const BRepGraph_NodeId theId) { if (!theId.IsValid()) + { return nullptr; + } BRepGraphInc_Storage& aStorage = myData->myIncStorage; switch (theId.NodeKind) { @@ -402,14 +408,18 @@ BRepGraphInc::BaseDef* BRepGraph::changeTopoEntity(const BRepGraph_NodeId theId) void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) { if (!theNode.IsValid()) + { return; + } using Kind = BRepGraph_NodeId::Kind; const BRepGraphInc_Storage& aStorage = myData->myIncStorage; // Bounds check: ensure the node index is within the entity vector. if (topoEntity(theNode) == nullptr) + { return; + } struct StackEntry { @@ -429,7 +439,9 @@ void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) const auto aPushChild = [&](const BRepGraph_NodeId theChild, const uint32_t theDepth) { if (!theChild.IsValid()) + { return; + } aStack.Append({theChild, theDepth}); }; @@ -439,11 +451,15 @@ void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) aStack.EraseLast(); if (aCurrent.Depth > aMaxDepth || !aCurrent.Node.IsValid() || !aVisited.Add(aCurrent.Node)) + { continue; + } // Bounds check: skip nodes whose index is outside the entity vector. if (topoEntity(aCurrent.Node) == nullptr) + { continue; + } // Increment OwnGen + SubtreeGen so generation-based cache freshness detects the change. BRepGraphInc::BaseDef* anEntity = changeTopoEntity(aCurrent.Node); @@ -484,7 +500,9 @@ void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) aPushChild(aChildIt.CurrentId(), aNextDepth); } for (const BRepGraph_ChildRefId& aChildRefId : aSolidEnt.AuxChildRefIds) + { aPushChild(aStorage.ChildRef(aChildRefId).ChildDefId, aNextDepth); + } break; } case Kind::Shell: { @@ -496,7 +514,9 @@ void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) aPushChild(aChildIt.CurrentId(), aNextDepth); } for (const BRepGraph_ChildRefId& aChildRefId : aShellEnt.AuxChildRefIds) + { aPushChild(aStorage.ChildRef(aChildRefId).ChildDefId, aNextDepth); + } break; } case Kind::Face: { @@ -553,11 +573,15 @@ void BRepGraph::invalidateSubgraphImpl(const BRepGraph_NodeId theNode) void BRepGraph::markModified(const BRepGraph_NodeId theNodeId) noexcept { if (!theNodeId.IsValid()) + { return; + } BRepGraphInc::BaseDef* anEntity = changeTopoEntity(theNodeId); if (anEntity == nullptr) + { return; + } markModified(theNodeId, *anEntity); } @@ -581,7 +605,9 @@ void BRepGraph::markModified(const BRepGraph_NodeId theNodeId, // Dispatch modification event for the directly mutated node. if (myLayerRegistry.HasModificationSubscribers()) + { myLayerRegistry.DispatchNodeModified(theNodeId); + } // Propagate SubtreeGen upward to parents (mutex-free). propagateSubtreeGen(theNodeId); @@ -592,7 +618,9 @@ void BRepGraph::markModified(const BRepGraph_NodeId theNodeId, void BRepGraph::markRefModified(const BRepGraph_RefId theRefId) noexcept { if (!theRefId.IsValid()) + { return; + } BRepGraphInc::BaseRef& aRef = myData->myIncStorage.ChangeBaseRef(theRefId); markRefModified(theRefId, aRef); @@ -620,7 +648,9 @@ void BRepGraph::markRefModified(const BRepGraph_RefId theRefId, } if (!theRef.ParentId.IsValid()) + { return; + } markParentSubtreeGen(theRef.ParentId); } @@ -631,14 +661,18 @@ void BRepGraph::markParentSubtreeGen(const BRepGraph_NodeId theParentId) noexcep { BRepGraphInc::BaseDef* aParent = changeTopoEntity(theParentId); if (aParent == nullptr) + { return; + } const uint32_t aWave = myData->myPropagationWave.load(std::memory_order_relaxed); // Re-visit guard: skip if this parent was already processed in the current // propagation wave. Prevents exponential blowup on diamond topologies. if (aParent->LastPropWave == aWave) + { return; + } aParent->LastPropWave = aWave; ++aParent->SubtreeGen; // ONLY SubtreeGen - not OwnGen. @@ -660,32 +694,48 @@ void BRepGraph::propagateSubtreeGen(const BRepGraph_NodeId theNodeId) noexcept const NCollection_DynamicArray* aWires = aRevIdx.WiresOfEdge(BRepGraph_EdgeId(theNodeId)); if (aWires != nullptr) + { for (const BRepGraph_WireId& aWireId : *aWires) + { markParentSubtreeGen(aWireId); + } + } break; } case BRepGraph_NodeId::Kind::Wire: { const NCollection_DynamicArray* aFaces = aRevIdx.FacesOfWire(BRepGraph_WireId(theNodeId)); if (aFaces != nullptr) + { for (const BRepGraph_FaceId& aFaceId : *aFaces) + { markParentSubtreeGen(aFaceId); + } + } break; } case BRepGraph_NodeId::Kind::Face: { const NCollection_DynamicArray* aShells = aRevIdx.ShellsOfFace(BRepGraph_FaceId(theNodeId)); if (aShells != nullptr) + { for (const BRepGraph_ShellId& aShellId : *aShells) + { markParentSubtreeGen(aShellId); + } + } break; } case BRepGraph_NodeId::Kind::Shell: { const NCollection_DynamicArray* aSolids = aRevIdx.SolidsOfShell(BRepGraph_ShellId(theNodeId)); if (aSolids != nullptr) + { for (const BRepGraph_SolidId& aSolidId : *aSolids) + { markParentSubtreeGen(aSolidId); + } + } break; } case BRepGraph_NodeId::Kind::Occurrence: { @@ -727,7 +777,9 @@ void BRepGraph::propagateSubtreeGen(const BRepGraph_NodeId theNodeId) noexcept void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept { if (!theRepId.IsValid()) + { return; + } BRepGraphInc_Storage& aStorage = myData->myIncStorage; @@ -737,43 +789,57 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept case BRepGraph_RepId::Kind::Surface: { const BRepGraph_SurfaceRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbSurfaces())) + { ++aStorage.ChangeSurfaceRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::Curve3D: { const BRepGraph_Curve3DRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbCurves3D())) + { ++aStorage.ChangeCurve3DRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::Curve2D: { const BRepGraph_Curve2DRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbCurves2D())) + { ++aStorage.ChangeCurve2DRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::Triangulation: { const BRepGraph_TriangulationRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbTriangulations())) + { ++aStorage.ChangeTriangulationRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::Polygon3D: { const BRepGraph_Polygon3DRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbPolygons3D())) + { ++aStorage.ChangePolygon3DRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::Polygon2D: { const BRepGraph_Polygon2DRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbPolygons2D())) + { ++aStorage.ChangePolygon2DRep(aRepId).OwnGen; + } break; } case BRepGraph_RepId::Kind::PolygonOnTri: { const BRepGraph_PolygonOnTriRepId aRepId(theRepId); if (aRepId.IsValid(aStorage.NbPolygonsOnTri())) + { ++aStorage.ChangePolygonOnTriRep(aRepId).OwnGen; + } break; } default: @@ -786,22 +852,34 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept case BRepGraph_RepId::Kind::Surface: { const BRepGraph_SurfaceRepId aSurfaceRepId(theRepId); for (BRepGraph_FaceIterator aFaceIt(*this); aFaceIt.More(); aFaceIt.Next()) + { if (aFaceIt.Current().SurfaceRepId == aSurfaceRepId) + { markModified(aFaceIt.CurrentId()); + } + } break; } case BRepGraph_RepId::Kind::Curve3D: { const BRepGraph_Curve3DRepId aCurve3DRepId(theRepId); for (BRepGraph_EdgeIterator anEdgeIt(*this); anEdgeIt.More(); anEdgeIt.Next()) + { if (anEdgeIt.Current().Curve3DRepId == aCurve3DRepId) + { markModified(anEdgeIt.CurrentId()); + } + } break; } case BRepGraph_RepId::Kind::Curve2D: { const BRepGraph_Curve2DRepId aCurve2DRepId(theRepId); for (BRepGraph_CoEdgeIterator aCoEdgeIt(*this); aCoEdgeIt.More(); aCoEdgeIt.Next()) + { if (aCoEdgeIt.Current().Curve2DRepId == aCurve2DRepId) + { markModified(aCoEdgeIt.CurrentId()); + } + } break; } case BRepGraph_RepId::Kind::Triangulation: { @@ -821,15 +899,19 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept aCached->TriangulationRepIds); aTriIt.More(); aTriIt.Next()) + { if (aTriIt.Value() == aTriangulationRepId) { aFound = true; break; } + } } } if (aFound) + { markModified(aFaceId); + } } break; } @@ -844,10 +926,14 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept const BRepGraph_MeshCache::EdgeMeshEntry* aCached = myData->myMeshCache.FindEdgeMesh(anEdgeId); if (aCached != nullptr && aCached->Polygon3DRepId == aPolygon3DRepId) + { aFound = true; + } } if (aFound) + { markModified(anEdgeId); + } } break; } @@ -862,10 +948,14 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept const BRepGraph_MeshCache::CoEdgeMeshEntry* aCached = myData->myMeshCache.FindCoEdgeMesh(aCoEdgeId); if (aCached != nullptr && aCached->Polygon2DRepId == aPolygon2DRepId) + { aFound = true; + } } if (aFound) + { markModified(aCoEdgeId); + } } break; } @@ -886,15 +976,19 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept aCached->PolygonOnTriRepIds); aPolyIt.More(); aPolyIt.Next()) + { if (aPolyIt.Value() == aPolygonOnTriRepId) { aFound = true; break; } + } } } if (aFound) + { markModified(aCoEdgeId); + } } break; } @@ -1039,7 +1133,9 @@ const BRepGraph_MeshCacheStorage& BRepGraph::meshCache() const const BRepGraphInc::BaseRef* BRepGraph::refEntity(const BRepGraph_RefId theId) const { if (!theId.IsValid()) + { return nullptr; + } const BRepGraphInc_Storage& aStorage = myData->myIncStorage; switch (theId.RefKind) { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx index 7cd214f0c4..55ab188bf3 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx @@ -80,7 +80,9 @@ BRepGraph_NodeId BRepGraph_Builder::detectTopologyRoot(const BRepGraph& th { const uint32_t aNewCount = snapshotCountForKind(theGraph, theShapeType); if (aNewCount <= theOldCountOfShapeKind) + { return BRepGraph_NodeId(); + } // BRepGraphInc_Populate::Append appends entities in declaration order, so the first entity // appended for a given shape type is always the shape root (index == pre-append count). @@ -116,49 +118,87 @@ void BRepGraph_Builder::populateUIDs(BRepGraph& theGraph) BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; if (!aStorage.GetIsDone()) + { return; + } for (BRepGraph_FullVertexIterator aVertexIt(theGraph); aVertexIt.More(); aVertexIt.Next()) + { theGraph.allocateUID(aVertexIt.CurrentId()); + } for (BRepGraph_FullEdgeIterator anEdgeIt(theGraph); anEdgeIt.More(); anEdgeIt.Next()) + { theGraph.allocateUID(anEdgeIt.CurrentId()); + } for (BRepGraph_FullCoEdgeIterator aCoEdgeIt(theGraph); aCoEdgeIt.More(); aCoEdgeIt.Next()) + { theGraph.allocateUID(aCoEdgeIt.CurrentId()); + } for (BRepGraph_FullWireIterator aWireIt(theGraph); aWireIt.More(); aWireIt.Next()) + { theGraph.allocateUID(aWireIt.CurrentId()); + } for (BRepGraph_FullFaceIterator aFaceIt(theGraph); aFaceIt.More(); aFaceIt.Next()) + { theGraph.allocateUID(aFaceIt.CurrentId()); + } for (BRepGraph_FullShellIterator aShellIt(theGraph); aShellIt.More(); aShellIt.Next()) + { theGraph.allocateUID(aShellIt.CurrentId()); + } for (BRepGraph_FullSolidIterator aSolidIt(theGraph); aSolidIt.More(); aSolidIt.Next()) + { theGraph.allocateUID(aSolidIt.CurrentId()); + } for (BRepGraph_FullCompoundIterator aCompoundIt(theGraph); aCompoundIt.More(); aCompoundIt.Next()) + { theGraph.allocateUID(aCompoundIt.CurrentId()); + } for (BRepGraph_FullCompSolidIterator aCompSolidIt(theGraph); aCompSolidIt.More(); aCompSolidIt.Next()) + { theGraph.allocateUID(aCompSolidIt.CurrentId()); + } for (BRepGraph_FullProductIterator aProductIt(theGraph); aProductIt.More(); aProductIt.Next()) + { theGraph.allocateUID(aProductIt.CurrentId()); + } for (BRepGraph_FullOccurrenceIterator anOccurrenceIt(theGraph); anOccurrenceIt.More(); anOccurrenceIt.Next()) + { theGraph.allocateUID(anOccurrenceIt.CurrentId()); + } for (BRepGraph_FullShellRefIterator aShellRefIt(theGraph); aShellRefIt.More(); aShellRefIt.Next()) + { theGraph.allocateRefUID(aShellRefIt.CurrentId()); + } for (BRepGraph_FullFaceRefIterator aFaceRefIt(theGraph); aFaceRefIt.More(); aFaceRefIt.Next()) + { theGraph.allocateRefUID(aFaceRefIt.CurrentId()); + } for (BRepGraph_FullWireRefIterator aWireRefIt(theGraph); aWireRefIt.More(); aWireRefIt.Next()) + { theGraph.allocateRefUID(aWireRefIt.CurrentId()); + } for (BRepGraph_FullCoEdgeRefIterator aCoEdgeRefIt(theGraph); aCoEdgeRefIt.More(); aCoEdgeRefIt.Next()) + { theGraph.allocateRefUID(aCoEdgeRefIt.CurrentId()); + } for (BRepGraph_FullVertexRefIterator aVertexRefIt(theGraph); aVertexRefIt.More(); aVertexRefIt.Next()) + { theGraph.allocateRefUID(aVertexRefIt.CurrentId()); + } for (BRepGraph_FullSolidRefIterator aSolidRefIt(theGraph); aSolidRefIt.More(); aSolidRefIt.Next()) + { theGraph.allocateRefUID(aSolidRefIt.CurrentId()); + } for (BRepGraph_FullChildRefIterator aChildRefIt(theGraph); aChildRefIt.More(); aChildRefIt.Next()) + { theGraph.allocateRefUID(aChildRefIt.CurrentId()); + } } //================================================================================================= @@ -208,7 +248,9 @@ void BRepGraph_Builder::appendImpl(BRepGraph& t if (theOutFlatRoots != nullptr) { for (const BRepGraph_NodeId& anId : aAppendedRoots) + { theOutFlatRoots->Append(anId); + } } } else @@ -223,7 +265,9 @@ void BRepGraph_Builder::appendImpl(BRepGraph& t } if (!aStorage.GetIsDone()) + { return; + } theGraph.myData->myCurrentShapes.Clear(); @@ -267,7 +311,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, { Result aResult; if (theShape.IsNull()) + { return aResult; + } const uint32_t anOldCount = snapshotCountForKind(theGraph, theShape.ShapeType()); @@ -275,12 +321,18 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, appendImpl(theGraph, theShape, theOptions, theOptions.Flatten ? &aFlatRoots : nullptr); if (!theGraph.myData->myIncStorage.GetIsDone()) + { return aResult; + } if (theOptions.Flatten && !aFlatRoots.IsEmpty()) + { aResult.TopologyRoot = aFlatRoots.First(); + } else + { aResult.TopologyRoot = detectTopologyRoot(theGraph, theShape.ShapeType(), anOldCount); + } if (theOptions.CreateAutoProduct && aResult.TopologyRoot.IsValid()) { @@ -347,7 +399,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph { Result aResult; if (theShape.IsNull() || !theParent.IsValid()) + { return aResult; + } const uint32_t anOldCount = snapshotCountForKind(theGraph, theShape.ShapeType()); @@ -358,14 +412,22 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph appendImpl(theGraph, theShape, anInner, anInner.Flatten ? &aFlatRoots : nullptr); if (!theGraph.myData->myIncStorage.GetIsDone()) + { return aResult; + } if (anInner.Flatten && !aFlatRoots.IsEmpty()) + { aResult.TopologyRoot = aFlatRoots.First(); + } else + { aResult.TopologyRoot = detectTopologyRoot(theGraph, theShape.ShapeType(), anOldCount); + } if (!aResult.TopologyRoot.IsValid()) + { return aResult; + } switch (theParent.NodeKind) { @@ -373,7 +435,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph const BRepGraph_ProductId aChildProduct = theGraph.Editor().Products().LinkProductToTopology(aResult.TopologyRoot, TopLoc_Location()); if (!aChildProduct.IsValid()) + { return aResult; + } BRepGraph_OccurrenceRefId anOccRefId; const BRepGraph_OccurrenceId anOccId = @@ -383,7 +447,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph BRepGraph_OccurrenceId(), &anOccRefId); if (!anOccId.IsValid()) + { return aResult; + } aResult.Product = aChildProduct; aResult.Occurrence = anOccId; aResult.InsertedRef = anOccRefId; @@ -396,7 +462,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph aResult.TopologyRoot, theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; @@ -410,7 +478,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph BRepGraph_FaceId(aResult.TopologyRoot), theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; @@ -418,7 +488,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph const BRepGraph_ChildRefId aRid = theGraph.Editor().Shells().AddChild(aShell, aResult.TopologyRoot, theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; @@ -432,7 +504,9 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph BRepGraph_ShellId(aResult.TopologyRoot), theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; @@ -440,20 +514,26 @@ BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph const BRepGraph_ChildRefId aRid = theGraph.Editor().Solids().AddChild(aSolid, aResult.TopologyRoot, theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; } case BRepGraph_NodeId::Kind::CompSolid: { if (aResult.TopologyRoot.NodeKind != BRepGraph_NodeId::Kind::Solid) + { return aResult; + } const BRepGraph_SolidRefId aRid = theGraph.Editor().CompSolids().AddSolid(BRepGraph_CompSolidId(theParent), BRepGraph_SolidId(aResult.TopologyRoot), theShape.Orientation()); if (!aRid.IsValid()) + { return aResult; + } aResult.InsertedRef = aRid; aResult.Ok = true; return aResult; @@ -488,79 +568,117 @@ void BRepGraph_Builder::populateUIDsIncremental(BRepGraph& theGraph, BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; if (!aStorage.GetIsDone()) + { return; + } for (BRepGraph_FullVertexIterator aVertexIt(theGraph, BRepGraph_VertexId(theOldVtx)); aVertexIt.More(); aVertexIt.Next()) + { theGraph.allocateUID(aVertexIt.CurrentId()); + } for (BRepGraph_FullEdgeIterator anEdgeIt(theGraph, BRepGraph_EdgeId(theOldEdge)); anEdgeIt.More(); anEdgeIt.Next()) + { theGraph.allocateUID(anEdgeIt.CurrentId()); + } for (BRepGraph_FullCoEdgeIterator aCoEdgeIt(theGraph, BRepGraph_CoEdgeId(theOldCoEdge)); aCoEdgeIt.More(); aCoEdgeIt.Next()) + { theGraph.allocateUID(aCoEdgeIt.CurrentId()); + } for (BRepGraph_FullWireIterator aWireIt(theGraph, BRepGraph_WireId(theOldWire)); aWireIt.More(); aWireIt.Next()) + { theGraph.allocateUID(aWireIt.CurrentId()); + } for (BRepGraph_FullFaceIterator aFaceIt(theGraph, BRepGraph_FaceId(theOldFace)); aFaceIt.More(); aFaceIt.Next()) + { theGraph.allocateUID(aFaceIt.CurrentId()); + } for (BRepGraph_FullShellIterator aShellIt(theGraph, BRepGraph_ShellId(theOldShell)); aShellIt.More(); aShellIt.Next()) + { theGraph.allocateUID(aShellIt.CurrentId()); + } for (BRepGraph_FullSolidIterator aSolidIt(theGraph, BRepGraph_SolidId(theOldSolid)); aSolidIt.More(); aSolidIt.Next()) + { theGraph.allocateUID(aSolidIt.CurrentId()); + } for (BRepGraph_FullCompoundIterator aCompoundIt(theGraph, BRepGraph_CompoundId(theOldComp)); aCompoundIt.More(); aCompoundIt.Next()) + { theGraph.allocateUID(aCompoundIt.CurrentId()); + } for (BRepGraph_FullCompSolidIterator aCompSolidIt(theGraph, BRepGraph_CompSolidId(theOldCS)); aCompSolidIt.More(); aCompSolidIt.Next()) + { theGraph.allocateUID(aCompSolidIt.CurrentId()); + } for (BRepGraph_FullProductIterator aProductIt(theGraph, BRepGraph_ProductId(theOldProduct)); aProductIt.More(); aProductIt.Next()) + { theGraph.allocateUID(aProductIt.CurrentId()); + } for (BRepGraph_FullOccurrenceIterator anOccurrenceIt(theGraph, BRepGraph_OccurrenceId(theOldOccurrence)); anOccurrenceIt.More(); anOccurrenceIt.Next()) + { theGraph.allocateUID(anOccurrenceIt.CurrentId()); + } for (BRepGraph_FullShellRefIterator aShellRefIt(theGraph, BRepGraph_ShellRefId(theOldShellRef)); aShellRefIt.More(); aShellRefIt.Next()) + { theGraph.allocateRefUID(aShellRefIt.CurrentId()); + } for (BRepGraph_FullFaceRefIterator aFaceRefIt(theGraph, BRepGraph_FaceRefId(theOldFaceRef)); aFaceRefIt.More(); aFaceRefIt.Next()) + { theGraph.allocateRefUID(aFaceRefIt.CurrentId()); + } for (BRepGraph_FullWireRefIterator aWireRefIt(theGraph, BRepGraph_WireRefId(theOldWireRef)); aWireRefIt.More(); aWireRefIt.Next()) + { theGraph.allocateRefUID(aWireRefIt.CurrentId()); + } for (BRepGraph_FullCoEdgeRefIterator aCoEdgeRefIt(theGraph, BRepGraph_CoEdgeRefId(theOldCoEdgeRef)); aCoEdgeRefIt.More(); aCoEdgeRefIt.Next()) + { theGraph.allocateRefUID(aCoEdgeRefIt.CurrentId()); + } for (BRepGraph_FullVertexRefIterator aVertexRefIt(theGraph, BRepGraph_VertexRefId(theOldVertexRef)); aVertexRefIt.More(); aVertexRefIt.Next()) + { theGraph.allocateRefUID(aVertexRefIt.CurrentId()); + } for (BRepGraph_FullSolidRefIterator aSolidRefIt(theGraph, BRepGraph_SolidRefId(theOldSolidRef)); aSolidRefIt.More(); aSolidRefIt.Next()) + { theGraph.allocateRefUID(aSolidRefIt.CurrentId()); + } for (BRepGraph_FullChildRefIterator aChildRefIt(theGraph, BRepGraph_ChildRefId(theOldChildRef)); aChildRefIt.More(); aChildRefIt.Next()) + { theGraph.allocateRefUID(aChildRefIt.CurrentId()); + } } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ChildExplorer.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ChildExplorer.cxx index f62ec5aa68..a01e3fe8e5 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ChildExplorer.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ChildExplorer.cxx @@ -277,7 +277,9 @@ void BRepGraph_ChildExplorer::startTraversal(const TopLoc_Location& theStartLo myOrientation = theStartOri; if (!myRoot.IsValid()) + { return; + } if (matchesAvoid(myRoot)) { @@ -300,7 +302,9 @@ void BRepGraph_ChildExplorer::startTraversal(const TopLoc_Location& theStartLo // Check if root is valid and not removed. const BRepGraphInc::BaseDef* aBaseDef = myGraph->Topo().Gen().TopoEntity(myRoot); if (aBaseDef == nullptr || aBaseDef->IsRemoved) + { return; + } // Check if root itself matches the target kind (e.g., root=Edge, target=Edge). if (myConfig.TargetKind.has_value() && matchesTarget(myRoot)) @@ -382,9 +386,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -405,9 +413,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -439,9 +451,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -473,9 +489,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -507,9 +527,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -530,9 +554,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aRefId)); + } break; } } @@ -551,11 +579,17 @@ void BRepGraph_ChildExplorer::advance() { BRepGraph_VertexRefId aVRefId; if (i == 0) + { aVRefId = anEdge.StartVertexRefId; + } else if (i == 1) + { aVRefId = anEdge.EndVertexRefId; + } else + { aVRefId = anEdge.InternalVertexRefIds.Value(static_cast(i - 2)); + } if (!aVRefId.IsValid()) { @@ -566,9 +600,13 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aRefs.ChildNode(aVRefId); aStepIdx = static_cast(i); if (myConfig.AccumulateLocation) + { aChildLoc = aFrame.AccLocation * aRefs.LocalLocation(aVRefId); + } if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aRefs.Orientation(aVRefId)); + } break; } } @@ -587,7 +625,9 @@ void BRepGraph_ChildExplorer::advance() aChildNode = aCoEdge.EdgeDefId; aStepIdx = -1; if (myConfig.AccumulateOrientation) + { aChildOri = TopAbs::Compose(aFrame.AccOrientation, aCoEdge.Orientation); + } } } aFrame.NextChildIdx = 1; @@ -677,7 +717,9 @@ void BRepGraph_ChildExplorer::advance() { const BRepGraphInc::BaseDef* aPostDef = aDefs.Gen().TopoEntity(aChildNode); if (aPostDef == nullptr || aPostDef->IsRemoved) + { continue; + } StackFrame aChildFrame; aChildFrame.Node = aChildNode; @@ -693,7 +735,9 @@ void BRepGraph_ChildExplorer::advance() // Check if resolved child is valid and not removed before descending. const BRepGraphInc::BaseDef* aBaseDef = aDefs.Gen().TopoEntity(aChildNode); if (aBaseDef == nullptr || aBaseDef->IsRemoved) + { continue; + } // Descend if this kind can contain the target. if (myConfig.Mode == TraversalMode::Recursive @@ -815,7 +859,9 @@ void BRepGraph_ChildExplorer::pushFrame(const StackFrame& theFrame) // Guard against pathological cycles (e.g., self-referencing compounds). // A valid DFS path cannot exceed the total node count in the graph. if (myStackTop >= myGraph->Topo().Gen().NbNodes()) + { return; + } ++myStackTop; if (static_cast(myStackTop) >= myStack.Size()) @@ -832,7 +878,9 @@ void BRepGraph_ChildExplorer::pushFrame(const StackFrame& theFrame) void BRepGraph_ChildExplorer::popFrame() { if (myStackTop >= 0) + { --myStackTop; + } } //================================================================================================= @@ -844,11 +892,15 @@ TopLoc_Location BRepGraph_ChildExplorer::LocationOf(const BRepGraph_NodeId::Kind for (int i = 1; i <= aMaxFrame; ++i) { if (myStack[i].Node.NodeKind == theKind) + { return myStack[i].AccLocation; + } } // Check the current match. if (myHasMore && myCurrent.NodeKind == theKind) + { return myLocation; + } return TopLoc_Location(); } @@ -861,10 +913,14 @@ BRepGraph_NodeId BRepGraph_ChildExplorer::NodeOf(const BRepGraph_NodeId::Kind th for (int i = 1; i <= aMaxFrame; ++i) { if (myStack[i].Node.NodeKind == theKind) + { return myStack[i].Node; + } } if (myHasMore && myCurrent.NodeKind == theKind) + { return myCurrent; + } return BRepGraph_NodeId(); } @@ -875,7 +931,9 @@ TopLoc_Location BRepGraph_ChildExplorer::LocationAt(const int theLevel) const // Level 0 = after first step = frame[1]. const int aFrameIdx = theLevel + 1; if (myCurrentFrame >= 0 && aFrameIdx <= myCurrentFrame) + { return myStack[aFrameIdx].AccLocation; + } return TopLoc_Location(); } @@ -885,6 +943,8 @@ BRepGraph_NodeId BRepGraph_ChildExplorer::NodeAt(const int theLevel) const { const int aFrameIdx = theLevel + 1; if (myCurrentFrame >= 0 && aFrameIdx <= myCurrentFrame) + { return myStack[aFrameIdx].Node; + } return BRepGraph_NodeId(); } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx index ebb19b624c..d8d5e5b64e 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx @@ -77,7 +77,9 @@ BRepGraph_NodeId remapNodeId( const NCollection_DataMap& theCompSolidMap) { if (!theId.IsValid()) + { return BRepGraph_NodeId(); + } switch (theId.NodeKind) { @@ -559,7 +561,9 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const const BRepGraphInc::WireRef& aWR = theGraph.Refs().Wires().Entry(aRefIt.CurrentId()); const BRepGraph_WireId aRemapped = BRepGraph_WireId::FromNodeId(remapId(aWR.WireDefId)); if (!aRemapped.IsValid()) + { continue; + } if (aWR.IsOuter) { aNewOuterWire = aRemapped; @@ -682,7 +686,9 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const const BRepGraph_Curve2DRepId aNewRepId = aNewGraph.Editor().CoEdges().CreateCurve2DRep(anOldPCurve); if (aNewRepId.IsValid()) + { aNewGraph.Editor().CoEdges().SetCurve2DRepId(aNewCoEdge, aNewRepId); + } } } } @@ -953,7 +959,9 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const const BRepGraphInc::OccurrenceRef& anOldOccRef = theGraph.Refs().Occurrences().Entry(anOldOccRefId); if (anOldOccRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOldOccDef = theGraph.Topo().Occurrences().Definition(anOldOccRef.OccurrenceDefId); if (!anOldOccDef.IsRemoved && anOldOccDef.ChildDefId.IsValid() @@ -1302,27 +1310,49 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const // Build unified remap map covering all 8 topology kinds. NCollection_DataMap aRemapMap; for (const auto& [anOldId, aNewId] : aVertexMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : anEdgeMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aCoEdgeMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aWireMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aFaceMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aShellMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aSolidMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aCompoundMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aCompSolidMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : aProductMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } for (const auto& [anOldId, aNewId] : anOccurrenceMap.Items()) + { aRemapMap.Bind(anOldId, aNewId); + } theGraph.LayerRegistry().DispatchOnCompact(aRemapMap); @@ -1332,13 +1362,17 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const { const BRepGraph_NodeId* aNewId = aRemapMap.Seek(aOldId); if (aNewId != nullptr) + { theGraph.incStorage().BindTShapeToNode(aTShape, *aNewId); + } } for (const auto& [aOldId, aShape] : aOriginalBindings) { const BRepGraph_NodeId* aNewId = aRemapMap.Seek(aOldId); if (aNewId != nullptr) + { theGraph.incStorage().BindOriginal(*aNewId, aShape); + } } // Record history after swap so records survive in the new graph's history log. diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.cxx index 868de47b3f..30be605ef8 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.cxx @@ -42,21 +42,27 @@ namespace occ::handle copySurface(const occ::handle& theSurf, bool theCopyGeom) { if (theSurf.IsNull() || !theCopyGeom) + { return theSurf; + } return occ::down_cast(theSurf->Copy()); } occ::handle copyCurve(const occ::handle& theCrv, bool theCopyGeom) { if (theCrv.IsNull() || !theCopyGeom) + { return theCrv; + } return occ::down_cast(theCrv->Copy()); } occ::handle copyPCurve(const occ::handle& theCrv, bool theCopyGeom) { if (theCrv.IsNull() || !theCopyGeom) + { return theCrv; + } return occ::down_cast(theCrv->Copy()); } @@ -107,7 +113,9 @@ struct DeferredCacheTransfers const BRepGraph_NodeId theDstNode) { if (srcHasAnyCache(theSrc, theSrcNode)) + { NodePairs.Append({theSrcNode, theDstNode}); + } } void DeferRef(const BRepGraph& theSrc, @@ -115,15 +123,21 @@ struct DeferredCacheTransfers const BRepGraph_RefId theDstRef) { if (srcHasAnyCache(theSrc, theSrcRef)) + { RefPairs.Append({theSrcRef, theDstRef}); + } } void Drain(const BRepGraph& theSrc, BRepGraph& theDst) const { for (const auto& aPair : NodePairs) + { transferFreshCacheValues(theSrc, aPair.first, theDst, aPair.second); + } for (const auto& aPair : RefPairs) + { transferFreshCacheValues(theSrc, aPair.first, theDst, aPair.second); + } } }; @@ -242,10 +256,14 @@ BRepGraph_NodeId mappedNode(const GraphCopyContext& ctx, BRepGraph_NodeId srcId) BRepGraph_VertexId ensureVertex(GraphCopyContext& ctx, BRepGraph_VertexId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Vertices())) + { return BRepGraph_VertexId(); + } const BRepGraph_VertexId* anExisting = ctx.Vertices.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::VertexDef& aVtx = ctx.Source.Topo().Vertices().Definition(srcId); const BRepGraph_VertexId aNewId = ctx.Result.Editor().Vertices().Add(aVtx.Point, aVtx.Tolerance); @@ -259,10 +277,14 @@ BRepGraph_VertexId ensureVertex(GraphCopyContext& ctx, BRepGraph_VertexId srcId) BRepGraph_EdgeId ensureEdge(GraphCopyContext& ctx, BRepGraph_EdgeId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Edges())) + { return BRepGraph_EdgeId(); + } const BRepGraph_EdgeId* anExisting = ctx.Edges.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::EdgeDef& anEdge = ctx.Source.Topo().Edges().Definition(srcId); const BRepGraph_VertexId aNewStart = @@ -295,10 +317,14 @@ BRepGraph_EdgeId ensureEdge(GraphCopyContext& ctx, BRepGraph_EdgeId srcId) BRepGraph_WireId ensureWire(GraphCopyContext& ctx, BRepGraph_WireId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Wires())) + { return BRepGraph_WireId(); + } const BRepGraph_WireId* anExisting = ctx.Wires.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } NCollection_DynamicArray> aWireEdges; for (BRepGraph_RefsCoEdgeOfWire aCEIt(ctx.Source, srcId); aCEIt.More(); aCEIt.Next()) @@ -329,10 +355,14 @@ void ensurePCurvesForFace(GraphCopyContext& ctx, ctx.Source.Refs().CoEdges().Entry(aCEIt.CurrentId()).CoEdgeDefId; const BRepGraphInc::CoEdgeDef& aCoEdge = ctx.Source.Topo().CoEdges().Definition(aSrcCoEdgeId); if (!aCoEdge.Curve2DRepId.IsValid()) + { continue; + } const BRepGraph_EdgeId* aNewEdge = ctx.Edges.Seek(aCoEdge.EdgeDefId); if (aNewEdge == nullptr) + { continue; + } const occ::handle& aSrcPC = BRepGraph_Tool::CoEdge::PCurve(ctx.Source, aSrcCoEdgeId); occ::handle aNewPC = copyPCurve(aSrcPC, ctx.CopyGeom); @@ -351,10 +381,14 @@ void ensurePCurvesForFace(GraphCopyContext& ctx, BRepGraph_FaceId ensureFace(GraphCopyContext& ctx, BRepGraph_FaceId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Faces())) + { return BRepGraph_FaceId(); + } const BRepGraph_FaceId* anExisting = ctx.Faces.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::FaceDef& aFace = ctx.Source.Topo().Faces().Definition(srcId); @@ -365,9 +399,13 @@ BRepGraph_FaceId ensureFace(GraphCopyContext& ctx, BRepGraph_FaceId srcId) const BRepGraphInc::WireRef& aWR = ctx.Source.Refs().Wires().Entry(aWRIt.CurrentId()); const BRepGraph_WireId aNewWire = ensureWire(ctx, aWR.WireDefId); if (aWR.IsOuter) + { anOuterWire = aNewWire; + } else + { anInnerWires.Append(aNewWire); + } } const occ::handle& aSrcSurf = BRepGraph_Tool::Face::Surface(ctx.Source, srcId); @@ -379,7 +417,9 @@ BRepGraph_FaceId ensureFace(GraphCopyContext& ctx, BRepGraph_FaceId srcId) BRepGraph_MutGuard aG = ctx.Result.Editor().Faces().Mut(aNewId); ctx.Result.Editor().Faces().SetNaturalRestriction(aG, aFace.NaturalRestriction); if (ctx.CopyMesh) + { ctx.Result.Editor().Faces().SetTriangulationRep(aG, aFace.TriangulationRepId); + } } if (ctx.CopyMesh) @@ -408,10 +448,14 @@ BRepGraph_FaceId ensureFace(GraphCopyContext& ctx, BRepGraph_FaceId srcId) BRepGraph_ShellId ensureShell(GraphCopyContext& ctx, BRepGraph_ShellId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Shells())) + { return BRepGraph_ShellId(); + } const BRepGraph_ShellId* anExisting = ctx.Shells.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::ShellDef& aShellDef = ctx.Source.Topo().Shells().Definition(srcId); const BRepGraph_ShellId aNewId = ctx.Result.Editor().Shells().Add(); @@ -438,10 +482,14 @@ BRepGraph_ShellId ensureShell(GraphCopyContext& ctx, BRepGraph_ShellId srcId) BRepGraph_SolidId ensureSolid(GraphCopyContext& ctx, BRepGraph_SolidId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Solids())) + { return BRepGraph_SolidId(); + } const BRepGraph_SolidId* anExisting = ctx.Solids.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_SolidId aNewId = ctx.Result.Editor().Solids().Add(); ctx.Solids.Bind(srcId, aNewId); @@ -505,10 +553,14 @@ void ensureNode(GraphCopyContext& ctx, BRepGraph_NodeId srcNodeId) BRepGraph_CompoundId ensureCompound(GraphCopyContext& ctx, BRepGraph_CompoundId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().Compounds())) + { return BRepGraph_CompoundId(); + } const BRepGraph_CompoundId* anExisting = ctx.Compounds.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } // Pre-allocate an empty compound and bind it BEFORE recursing into children so a // self-referencing compound chain (A->B->A or A->A) terminates instead of recursing @@ -537,10 +589,14 @@ BRepGraph_CompoundId ensureCompound(GraphCopyContext& ctx, BRepGraph_CompoundId BRepGraph_CompSolidId ensureCompSolid(GraphCopyContext& ctx, BRepGraph_CompSolidId srcId) { if (!srcId.IsValidIn(ctx.Source.Topo().CompSolids())) + { return BRepGraph_CompSolidId(); + } const BRepGraph_CompSolidId* anExisting = ctx.CompSolids.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } NCollection_DynamicArray aSolidIds; for (BRepGraph_RefsSolidOfCompSolid aSRIt(ctx.Source, srcId); aSRIt.More(); aSRIt.Next()) @@ -563,7 +619,9 @@ BRepGraph_OccurrenceRefId ensureOccurrenceRef(GraphCopyContext& ctx, { const BRepGraph_OccurrenceRefId* anExisting = ctx.OccurrenceRefs.Seek(srcRefId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::OccurrenceRef& aSrcRef = ctx.SrcStorage->OccurrenceRef(srcRefId); const BRepGraph_OccurrenceRefId aNewId = ctx.DstStorage->AppendOccurrenceRef(); @@ -573,7 +631,9 @@ BRepGraph_OccurrenceRefId ensureOccurrenceRef(GraphCopyContext& ctx, aNewRef.IsRemoved = aSrcRef.IsRemoved; aNewRef.LocalLocation = aSrcRef.LocalLocation; if (aSrcRef.OccurrenceDefId.IsValid()) + { aNewRef.OccurrenceDefId = ensureOccurrence(ctx, aSrcRef.OccurrenceDefId); + } // ParentId is set by the caller (ensureProduct) after the ref is created. return aNewId; } @@ -584,7 +644,9 @@ BRepGraph_OccurrenceId ensureOccurrence(GraphCopyContext& ctx, BRepGraph_Occurre { const BRepGraph_OccurrenceId* anExisting = ctx.Occurrences.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraphInc::OccurrenceDef& aSrcOcc = ctx.SrcStorage->Occurrence(srcId); const BRepGraph_OccurrenceId aNewId = ctx.DstStorage->AppendOccurrence(); @@ -606,7 +668,9 @@ BRepGraph_ProductId ensureProduct(GraphCopyContext& ctx, BRepGraph_ProductId src { const BRepGraph_ProductId* anExisting = ctx.Products.Seek(srcId); if (anExisting != nullptr) + { return *anExisting; + } // Bind before iterating refs so re-entrant calls (assembly cycles) short-circuit. const BRepGraph_ProductId aNewId = ctx.DstStorage->AppendProduct(); @@ -657,7 +721,9 @@ BRepGraph BRepGraph_Copy::Perform(const BRepGraph& theGraph, const bool theCopyG { BRepGraph aResult; if (!theGraph.IsDone()) + { return aResult; + } const BRepGraph::RefsView& aRefs = theGraph.Refs(); DeferredCacheTransfers aDeferred; @@ -773,7 +839,9 @@ BRepGraph BRepGraph_Copy::Perform(const BRepGraph& theGraph, const bool theCopyG { const BRepGraphInc::CoEdgeDef& aCoEdge = theGraph.Topo().CoEdges().Definition(aCoEdgeId); if (!aCoEdge.Curve2DRepId.IsValid()) + { continue; + } const occ::handle& aCoEdgeSrcPC = BRepGraph_Tool::CoEdge::PCurve(theGraph, aCoEdgeId); @@ -886,7 +954,9 @@ BRepGraph BRepGraph_Copy::Perform(const BRepGraph& theGraph, const bool theCopyG for (; anSrcIt.More() && aDstIt.More(); anSrcIt.Next(), aDstIt.Next()) { if (anSrcIt.Value().IsValid()) + { aDstIt.ChangeValue() = anSrcIt.Value(); + } } }; @@ -965,7 +1035,9 @@ BRepGraph BRepGraph_Copy::CopyNode(const BRepGraph& theGraph, const bool theReserveCache) { if (!theGraph.IsDone()) + { return BRepGraph(); + } GraphCopyContext ctx(theGraph, theCopyGeom, theCopyMesh, theReserveCache); ctx.SrcStorage = &theGraph.incStorage(); @@ -984,13 +1056,19 @@ BRepGraph BRepGraph_Copy::CopyNode(const BRepGraph& theGraph, const BRepGraph_OccurrenceRefId aSrcRefId = aRefIt.CurrentId(); const BRepGraph_OccurrenceRefId* aDstRefPtr = ctx.OccurrenceRefs.Seek(aSrcRefId); if (aDstRefPtr == nullptr) + { continue; + } const BRepGraphInc::OccurrenceRef& aSrcRef = ctx.SrcStorage->OccurrenceRef(aSrcRefId); if (!aSrcRef.ParentId.IsValid()) + { continue; + } const BRepGraph_NodeId aMapped = mappedNode(ctx, aSrcRef.ParentId); if (aMapped.IsValid()) + { ctx.DstStorage->ChangeOccurrenceRef(*aDstRefPtr).ParentId = aMapped; + } } } @@ -1006,7 +1084,9 @@ BRepGraph BRepGraph_Copy::CopyNode(const BRepGraph& theGraph, { const BRepGraph_ProductId aChildProdId = BRepGraph_ProductId::FromNodeId(anOcc.ChildDefId); if (aChildProdId.IsValidIn(ctx.Result.Topo().Products())) + { aReferencedProducts.Add(aChildProdId); + } } } for (BRepGraph_FullProductIterator aProdIt(ctx.Result); aProdIt.More(); aProdIt.Next()) @@ -1014,13 +1094,17 @@ BRepGraph BRepGraph_Copy::CopyNode(const BRepGraph& theGraph, const BRepGraph_ProductId aProdId = aProdIt.CurrentId(); const BRepGraphInc::ProductDef& aProd = ctx.DstStorage->Product(aProdId); if (!aProd.IsRemoved && !aReferencedProducts.Contains(aProdId)) + { ctx.DstData->myRootProductIds.Append(aProdId); + } } } ctx.DstData->myIsDone = true; if (ctx.ReserveCache) + { reserveTransientCache(ctx.Result); + } ctx.Deferred.Drain(theGraph, ctx.Result); return std::move(ctx.Result); } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Deduplicate.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Deduplicate.cxx index c6b9e6d8ce..6994157224 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Deduplicate.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Deduplicate.cxx @@ -154,7 +154,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG // Skip if already canonical (idempotency: avoid re-recording same rewrite). if (aCurrentSurfRepId == aCanonSurfRepId) + { continue; + } BRepGraph_MutGuard aFaceDef = theGraph.Editor().Faces().Mut(aFaceId); theGraph.Editor().Faces().SetSurfaceRepId(aFaceDef, aCanonSurfRepId); @@ -183,7 +185,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG // Skip if already canonical (idempotency: avoid re-recording same rewrite). if (aCurrentCurveRepId == aCanonCurveRepId) + { continue; + } BRepGraph_MutGuard anEdgeDef = theGraph.Editor().Edges().Mut(anEdgeId); theGraph.Editor().Edges().SetCurve3DRepId(anEdgeDef, aCanonCurveRepId); @@ -220,7 +224,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG const BRepGraph_VertexId aVertexId = aVertexIt.CurrentId(); const BRepGraphInc::VertexDef& aVtx = theGraph.Topo().Vertices().Definition(aVertexId); if (aVtx.IsRemoved) + { continue; + } aActiveVertices.Append( std::make_pair(BRepGraph_Tool::Vertex::Pnt(theGraph, aVertexId), aVertexId)); } @@ -230,11 +236,15 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG NCollection_Array1 aPointsArr(0, std::max(0, aNbActive - 1)); int i = 0; for (const auto& aVertex : aActiveVertices) + { aPointsArr.SetValue(i++, aVertex.first); + } NCollection_KDTree aTree; if (!aPointsArr.IsEmpty()) + { aTree.Build(aPointsArr); + } // Canonical vertex map: old graph id -> canonical graph id. NCollection_DataMap aCanonicalVertex( @@ -245,7 +255,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const BRepGraph_VertexId aBaseVtxId = aActiveVertices.Value(aLocalIdx).second; if (aCanonicalVertex.IsBound(aBaseVtxId)) + { continue; + } const gp_Pnt aBaseVtxPnt = BRepGraph_Tool::Vertex::Pnt(theGraph, aBaseVtxId); const double aBaseVtxTol = BRepGraph_Tool::Vertex::Tolerance(theGraph, aBaseVtxId); @@ -253,11 +265,15 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG aTree.ForEachInRange(aBaseVtxPnt, aTol, [&](size_t theResultIdx) { const size_t anArrayIdx = theResultIdx - 1; if (anArrayIdx <= aLocalIdx) + { return; // skip self and already-processed + } const BRepGraph_VertexId aCandVtxId = aActiveVertices.Value(anArrayIdx).second; if (aCanonicalVertex.IsBound(aCandVtxId)) + { return; + } const double aCandVtxTol = BRepGraph_Tool::Vertex::Tolerance(theGraph, aCandVtxId); const double aMaxTol = std::max(aBaseVtxTol, aCandVtxTol); @@ -288,7 +304,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG BRepGraph_MutGuard anEdge = theGraph.Editor().Edges().Mut(anEdgeId); if (anEdge->IsRemoved) + { continue; + } // Resolve current vertex def ids through ref entries and update them. if (anEdge->StartVertexRefId.IsValid()) { @@ -325,7 +343,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG const BRepGraph_FaceId aFaceId = aFaceIt.CurrentId(); const BRepGraphInc::FaceDef& aFaceDef = theGraph.Topo().Faces().Definition(aFaceId); if (aFaceDef.IsRemoved) + { continue; + } for (const BRepGraph_VertexRefId& aVRefId : aFaceDef.VertexRefIds) { BRepGraph_MutGuard aVRef = @@ -391,7 +411,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId(); const BRepGraphInc::EdgeDef& anEdge = theGraph.Topo().Edges().Definition(anEdgeId); if (anEdge.IsRemoved || !BRepGraph_Tool::Edge::HasCurve(theGraph, anEdgeId)) + { continue; + } // Use canonical (forward) key: use raw pointer as a stable identity. EdgeKey aKey; @@ -404,7 +426,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG // Normalize: always use min vertex index first for undirected matching. if (aKey.StartVtx > aKey.EndVtx) + { std::swap(aKey.StartVtx, aKey.EndVtx); + } anEdgeGroups.TryBind(aKey, NCollection_DynamicArray()); anEdgeGroups.ChangeFind(aKey).Append(anEdgeId); @@ -421,7 +445,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const NCollection_DynamicArray& aGroup = aGroupIter.Value(); if (aGroup.Size() < 2) + { continue; + } const BRepGraph_EdgeId aCanonEdgeId = aGroup.Value(0); const BRepGraphInc::EdgeDef& aCanonEdge = theGraph.Topo().Edges().Definition(aCanonEdgeId); @@ -433,13 +459,19 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG // Compare parameter ranges within tolerance. if (std::abs(aCanonEdge.ParamFirst - aCandEdge.ParamFirst) > theOptions.CompTolerance) + { continue; + } if (std::abs(aCanonEdge.ParamLast - aCandEdge.ParamLast) > theOptions.CompTolerance) + { continue; + } // Check tolerance compatibility. if (aCandEdge.Tolerance > aCanonEdge.Tolerance * 10.0) + { continue; + } aCanonicalEdge.Bind(aCandEdgeId, aCanonEdgeId); } @@ -530,7 +562,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG } if (aWireACoEdges.Size() != aWireBCoEdges.Size()) + { return false; + } NCollection_DynamicArray::Iterator anItA(aWireACoEdges); NCollection_DynamicArray::Iterator anItB(aWireBCoEdges); for (; anItA.More(); anItA.Next(), anItB.Next()) @@ -541,7 +575,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG theGraph.Topo().CoEdges().Definition(anItB.Value()); if (aCoEdgeA.EdgeDefId != aCoEdgeB.EdgeDefId || aCoEdgeA.Orientation != aCoEdgeB.Orientation) + { return false; + } } return true; }; @@ -556,7 +592,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG const BRepGraph_WireId aWireId = aWireIt.CurrentId(); const BRepGraphInc::WireDef& aWire = theGraph.Topo().Wires().Definition(aWireId); if (aWire.IsRemoved) + { continue; + } const size_t aH = aHasher(aWireId, theGraph); aWireHashBuckets.TryBind(aH, NCollection_DynamicArray()); aWireHashBuckets.ChangeFind(aH).Append(aWireId); @@ -576,15 +614,21 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const BRepGraph_WireId aBaseWireId = aBucket.Value(aBaseIdx); if (aCanonicalWire.IsBound(aBaseWireId)) + { continue; + } for (size_t aCandIdx = aBaseIdx + 1; aCandIdx < aBucket.Size(); ++aCandIdx) { const BRepGraph_WireId aCandWireId = aBucket.Value(aCandIdx); if (aCanonicalWire.IsBound(aCandWireId)) + { continue; + } if (wiresEqual(aBaseWireId, aCandWireId)) + { aCanonicalWire.Bind(aCandWireId, aBaseWireId); + } } } } @@ -629,7 +673,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const BRepGraph_ShellId aShellId = aShellIt.CurrentId(); if (theGraph.Topo().Shells().Definition(aShellId).IsRemoved) + { continue; + } for (BRepGraph_RefsChildOfShell aRefIt(theGraph, aShellId); aRefIt.More(); aRefIt.Next()) { const BRepGraphInc::ChildRef& aCR = @@ -646,7 +692,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const BRepGraph_SolidId aSolidId = aSolidIt.CurrentId(); if (theGraph.Topo().Solids().Definition(aSolidId).IsRemoved) + { continue; + } for (BRepGraph_RefsChildOfSolid aRefIt(theGraph, aSolidId); aRefIt.More(); aRefIt.Next()) { const BRepGraphInc::ChildRef& aCR = @@ -723,7 +771,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG const BRepGraph_FaceId aFaceId = aFaceIt.CurrentId(); const BRepGraphInc::FaceDef& aFace = theGraph.Topo().Faces().Definition(aFaceId); if (aFace.IsRemoved || !BRepGraph_Tool::Face::HasSurface(theGraph, aFaceId)) + { continue; + } FaceKey aKey; aKey.SurfPtr = BRepGraph_Tool::Face::Surface(theGraph, aFaceId).get(); @@ -744,7 +794,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const NCollection_DynamicArray& aGroup = aGroupIter.Value(); if (aGroup.Size() < 2) + { continue; + } const BRepGraph_FaceId aCanonFaceId = aGroup.Value(0); const BRepGraphInc::FaceDef& aCanonFace = theGraph.Topo().Faces().Definition(aCanonFaceId); @@ -756,7 +808,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG // Check tolerance compatibility. if (aCandFace.Tolerance > aCanonFace.Tolerance * 10.0) + { continue; + } aCanonicalFace.Bind(aCandFaceId, aCanonFaceId); } @@ -794,7 +848,9 @@ BRepGraph_Deduplicate::Result BRepGraph_Deduplicate::Perform(BRepGraph& theG { const BRepGraph_CoEdgeId aCEId = aCEIt.CurrentId(); if (theGraph.Topo().CoEdges().Definition(aCEId).IsRemoved) + { continue; + } if (theGraph.Topo().CoEdges().Definition(aCEId).FaceDefId == anOldFaceId) { BRepGraph_MutGuard aMutCE = diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx index 3fbe58b2e5..84f332ece5 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx @@ -68,7 +68,9 @@ bool hasOtherActiveParent(const BRepGraph& theGraph, anExp.Next()) { if (anExp.Current().DefId != theExcludedParent) + { return true; + } } return false; } @@ -115,7 +117,9 @@ RefIdT findOrderedRef(const NCollection_DynamicArray& theRefIds, const R anIt.Next()) { if (anIt.Value() == theRefId) + { return theRefId; + } } return RefIdT(); } @@ -130,8 +134,10 @@ void eraseOrderedRef(const RefIdT theRefId, NCollection_DynamicArray& th if (anIt.Value() == theRefId) { for (uint32_t i = anIndex; i < static_cast(theRefIds.Size()) - 1u; ++i) + { theRefIds.ChangeValue(static_cast(i)) = theRefIds.Value(static_cast(i + 1u)); + } theRefIds.EraseLast(); return; } @@ -201,7 +207,9 @@ static bool isNodeIndexInRange(const BRepGraphInc_Storage& theStorage, const BRepGraph_NodeId theNode) { if (!theNode.IsValid()) + { return false; + } switch (theNode.NodeKind) { @@ -338,11 +346,15 @@ static void rebindCoEdgesForEdgeReplacement(BRepGraphInc_Storage& theStorage, { const BRepGraph_CoEdgeId aCoEdgeId = aCoEdgeSnapshot[aCoEdgeIdx]; if (!aCoEdgeId.IsValid(theStorage.NbCoEdges())) + { continue; + } BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.ChangeCoEdge(aCoEdgeId); if (aCoEdge.IsRemoved || aCoEdge.EdgeDefId != theSourceEdgeId) + { continue; + } theStorage.ChangeReverseIndex().UnbindEdgeFromCoEdge(theSourceEdgeId, aCoEdgeId); aCoEdge.EdgeDefId = theReplacementEdgeId; @@ -362,18 +374,26 @@ static bool isLastEdgeUsageInWire(const BRepGraphInc_Storage& theStorage, const BRepGraph_CoEdgeRefId theExcludingRef) { if (!theWire.IsValid(theStorage.NbWires()) || !theEdge.IsValid()) + { return true; + } const BRepGraphInc::WireDef& aWireDef = theStorage.Wire(theWire); for (const BRepGraph_CoEdgeRefId& aRefId : aWireDef.CoEdgeRefIds) { if (!aRefId.IsValid(theStorage.NbCoEdgeRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theStorage.CoEdgeRef(aRefId); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aRef.CoEdgeDefId); if (!aCoEdge.IsRemoved && aCoEdge.EdgeDefId == theEdge) + { return false; + } } return true; } @@ -396,11 +416,15 @@ static void unbindCoEdgesOfRemovedEdge(BRepGraphInc_Storage& theStorage, { const BRepGraph_CoEdgeId aCoEdgeId = aCoEdgeSnapshot[aCoEdgeIdx]; if (!aCoEdgeId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aCoEdgeId); if (!aCoEdge.IsRemoved && aCoEdge.EdgeDefId == theEdgeId) + { theStorage.ChangeReverseIndex().UnbindEdgeFromCoEdge(theEdgeId, aCoEdgeId); + } } } @@ -411,7 +435,9 @@ int countIterator(const BRepGraph& theGraph) { int aCount = 0; for (BRepGraph_Iterator anIt(theGraph); anIt.More(); anIt.Next()) + { ++aCount; + } return aCount; } @@ -586,8 +612,10 @@ BRepGraph_EdgeId BRepGraph::EditorView::EdgeOps::Add(const BRepGraph_VertexId anEndVtxRef.Orientation = TopAbs_REVERSED; myGraph->allocateRefUID(anEndVtxRefId); anEdgeDef.EndVertexRefId = anEndVtxRefId; - if (theEndVtx != theStartVtx) // BindVertexToEdge dedups, but skip needless work + if (theEndVtx != theStartVtx) + { // BindVertexToEdge dedups, but skip needless work aStorage.ChangeReverseIndex().BindVertexToEdge(theEndVtx, aEdgeId); + } } anEdgeDef.ParamFirst = theFirst; anEdgeDef.ParamLast = theLast; @@ -1128,17 +1156,27 @@ BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::LinkProducts( BRepGraph_OccurrenceRefId* theOutOccurrenceRefId) { if (theOutOccurrenceRefId != nullptr) + { *theOutOccurrenceRefId = BRepGraph_OccurrenceRefId(); + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!isActiveNode(aStorage, theParentProduct)) + { return BRepGraph_OccurrenceId(); + } if (!isActiveNode(aStorage, theReferencedProduct)) + { return BRepGraph_OccurrenceId(); + } if (theParentProduct == theReferencedProduct) + { return BRepGraph_OccurrenceId(); + } if (theParentOccurrence.IsValid() && !isActiveNode(aStorage, theParentOccurrence)) + { return BRepGraph_OccurrenceId(); + } if (theParentOccurrence.IsValid() && aStorage.Occurrence(theParentOccurrence).ChildDefId != BRepGraph_NodeId(theParentProduct)) { @@ -1167,7 +1205,9 @@ BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::LinkProducts( aStorage.ChangeReverseIndex().BindProductOccurrence(anOccId, theReferencedProduct); if (theOutOccurrenceRefId != nullptr) + { *theOutOccurrenceRefId = anOccRefId; + } return anOccId; } @@ -1184,7 +1224,9 @@ void BRepGraph::EditorView::GenOps::RemoveNode(const BRepGraph_NodeId theNode, const BRepGraph_NodeId theReplacement) { if (!theNode.IsValid()) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; @@ -1243,21 +1285,29 @@ void BRepGraph::EditorView::GenOps::RemoveNode(const BRepGraph_NodeId theNode, { const BRepGraph_VertexId aStartV = aStorage.VertexRef(anEdge.StartVertexRefId).VertexDefId; if (aStartV.IsValid()) + { aRI.UnbindVertexFromEdge(aStartV, anEdgeId); + } } if (anEdge.EndVertexRefId.IsValid(aStorage.NbVertexRefs())) { const BRepGraph_VertexId anEndV = aStorage.VertexRef(anEdge.EndVertexRefId).VertexDefId; if (anEndV.IsValid()) + { aRI.UnbindVertexFromEdge(anEndV, anEdgeId); + } } for (const BRepGraph_VertexRefId& anIntRefId : anEdge.InternalVertexRefIds) { if (!anIntRefId.IsValid(aStorage.NbVertexRefs())) + { continue; + } const BRepGraph_VertexId anIntV = aStorage.VertexRef(anIntRefId).VertexDefId; if (anIntV.IsValid()) + { aRI.UnbindVertexFromEdge(anIntV, anEdgeId); + } } // Keep reverse edge->coedge table coherent for pure removals too. unbindCoEdgesOfRemovedEdge(aStorage, anEdgeId); @@ -1350,7 +1400,9 @@ void BRepGraph::EditorView::GenOps::RemoveSubgraph(const BRepGraph_NodeId theNod anOccIndices.Append(aStorage.OccurrenceRef(anOccIt.CurrentId()).OccurrenceDefId.Index); } for (const int anOccIdx : anOccIndices) + { RemoveSubgraph(BRepGraph_OccurrenceId(anOccIdx)); + } } break; } @@ -1365,7 +1417,9 @@ void BRepGraph::EditorView::GenOps::RemoveSubgraph(const BRepGraph_NodeId theNod && BRepGraph_NodeId::IsTopologyKind(anOcc.ChildDefId.NodeKind)) { if (!hasAnyActiveUsage(*myGraph, anOcc.ChildDefId)) + { RemoveSubgraph(anOcc.ChildDefId); + } } // Detach from parent product's OccurrenceRefIds. // Find the parent product by scanning OccurrenceRefs. @@ -1375,11 +1429,15 @@ void BRepGraph::EditorView::GenOps::RemoveSubgraph(const BRepGraph_NodeId theNod { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aOccRefId); if (aRef.IsRemoved || aRef.OccurrenceDefId != theNode) + { continue; + } const BRepGraph_ProductId aParentProduct = BRepGraph_ProductId::FromNodeId(aRef.ParentId); if (!aParentProduct.IsValid(aStorage.NbProducts())) + { break; + } NCollection_DynamicArray& aRefIds = myGraph->myData->myIncStorage.ChangeProduct(aParentProduct).OccurrenceRefIds; @@ -1392,8 +1450,10 @@ void BRepGraph::EditorView::GenOps::RemoveSubgraph(const BRepGraph_NodeId theNod { myGraph->myData->myIncStorage.MarkRemovedRef(aOccRefId); if (anIdx < static_cast(aRefIds.Size()) - 1u) + { aRefIds.ChangeValue(static_cast(anIdx)) = aRefIds.Value(aRefIds.Size() - 1u); + } aRefIds.EraseLast(); myGraph->markModified(aParentProduct); break; @@ -1434,7 +1494,9 @@ void BRepGraph::EditorView::GenOps::RemoveSubgraph(const BRepGraph_NodeId theNod for (const BRepGraph_NodeId& aChild : aChildNodes) { if (!hasOtherActiveParent(*myGraph, aChild, theNode)) + { RemoveSubgraph(aChild); + } } break; } @@ -1465,7 +1527,9 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_RefId theRef) BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraphInc::BaseRef& aRef = aStorage.BaseRef(theRef); if (aRef.IsRemoved) + { return false; + } const BRepGraph_NodeId aParent = aRef.ParentId; BRepGraph_NodeId aChildNode; BRepGraph_NodeId aOccChildDef; @@ -1484,7 +1548,9 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_RefId theRef) case BRepGraph_RefId::Kind::CoEdge: { aChildNode = aStorage.CoEdgeRef(BRepGraph_CoEdgeRefId(theRef)).CoEdgeDefId; if (aChildNode.IsValid(aStorage.NbCoEdges())) + { aCoEdgeUnderlyingEdge = aStorage.CoEdge(BRepGraph_CoEdgeId(aChildNode)).EdgeDefId; + } break; } case BRepGraph_RefId::Kind::Vertex: @@ -1499,7 +1565,9 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_RefId theRef) case BRepGraph_RefId::Kind::Occurrence: { aChildNode = aStorage.OccurrenceRef(BRepGraph_OccurrenceRefId(theRef)).OccurrenceDefId; if (aChildNode.IsValid()) + { aOccChildDef = aStorage.Occurrence(BRepGraph_OccurrenceId(aChildNode)).ChildDefId; + } break; } default: @@ -1516,11 +1584,15 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_RefId theRef) { case BRepGraph_RefId::Kind::Face: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Shell && aChildNode.IsValid()) + { aRI.UnbindFaceFromShell(BRepGraph_FaceId(aChildNode), BRepGraph_ShellId(aParent)); + } break; case BRepGraph_RefId::Kind::Wire: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Face && aChildNode.IsValid()) + { aRI.UnbindWireFromFace(BRepGraph_WireId(aChildNode), BRepGraph_FaceId(aParent)); + } break; case BRepGraph_RefId::Kind::CoEdge: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Wire && aChildNode.IsValid()) @@ -1539,19 +1611,27 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_RefId theRef) break; case BRepGraph_RefId::Kind::Vertex: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Edge && aChildNode.IsValid()) + { aRI.UnbindVertexFromEdge(BRepGraph_VertexId(aChildNode), BRepGraph_EdgeId(aParent)); + } break; case BRepGraph_RefId::Kind::Shell: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Solid && aChildNode.IsValid()) + { aRI.UnbindShellFromSolid(BRepGraph_ShellId(aChildNode), BRepGraph_SolidId(aParent)); + } break; case BRepGraph_RefId::Kind::Solid: if (aParent.NodeKind == BRepGraph_NodeId::Kind::CompSolid && aChildNode.IsValid()) + { aRI.UnbindSolidFromCompSolid(BRepGraph_SolidId(aChildNode), BRepGraph_CompSolidId(aParent)); + } break; case BRepGraph_RefId::Kind::Child: if (aParent.NodeKind == BRepGraph_NodeId::Kind::Compound && aChildNode.IsValid()) + { aRI.UnbindCompoundChild(aChildNode, BRepGraph_CompoundId(aParent)); + } break; case BRepGraph_RefId::Kind::Occurrence: if (aChildNode.IsValid() && aOccChildDef.IsValid() @@ -1604,7 +1684,9 @@ bool BRepGraph::EditorView::GenOps::RemoveRef(const BRepGraph_NodeId theParent, void BRepGraph::EditorView::GenOps::RemoveRep(const BRepGraph_RepId theRep) { if (!theRep.IsValid()) + { return; + } if (myGraph->myData->myIncStorage.MarkRemovedRep(theRep)) { @@ -1618,7 +1700,9 @@ BRepGraph_Curve2DRepId BRepGraph::EditorView::CoEdgeOps::CreateCurve2DRep( const occ::handle& theCurve2d) { if (theCurve2d.IsNull()) + { return BRepGraph_Curve2DRepId(); + } const BRepGraph_Curve2DRepId aRepId = myGraph->myData->myIncStorage.AppendCurve2DRep(); myGraph->myData->myIncStorage.ChangeCurve2DRep(aRepId).Curve = theCurve2d; @@ -1687,14 +1771,18 @@ void BRepGraph::EditorView::BeginDeferredInvalidation() void BRepGraph::EditorView::EndDeferredInvalidation() noexcept { if (!myGraph->myData->myDeferredMode.load(std::memory_order_relaxed)) + { return; + } myGraph->myData->myDeferredMode.store(false, std::memory_order_relaxed); NCollection_DynamicArray& aDeferredList = myGraph->myData->myDeferredModified; if (aDeferredList.IsEmpty()) + { return; + } // Shape cache uses SubtreeGen validation - no bulk clear needed. // Stale entries are detected on read via StoredSubtreeGen != entity.SubtreeGen. @@ -1739,9 +1827,13 @@ void BRepGraph::EditorView::EndDeferredInvalidation() noexcept const int aKindIdx = static_cast(theNode.NodeKind); NCollection_Array1& aArr = aVisArrays[aKindIdx]; if (aArr.IsEmpty() || static_cast(theNode.Index) > aArr.Upper()) + { return false; + } if (aArr.Value(static_cast(theNode.Index))) + { return false; + } aArr.SetValue(static_cast(theNode.Index), true); return true; }; @@ -1783,18 +1875,24 @@ void BRepGraph::EditorView::EndDeferredInvalidation() noexcept const NCollection_DynamicArray* aWires = aRevIdx.WiresOfEdge(BRepGraph_EdgeId(aNodeId)); if (aWires != nullptr) + { for (const BRepGraph_WireId& aWireId : *aWires) { const BRepGraph_NodeId aParentId = aWireId; if (!markVisited(aParentId)) + { continue; + } BRepGraphInc::BaseDef* aParent = myGraph->changeTopoEntity(aParentId); if (aParent == nullptr || aParent->IsRemoved) + { continue; + } ++aParent->SubtreeGen; aAllModified.Append(aParentId); aModifiedKindsMask |= BRepGraph_Layer::KindBit(aParentId.NodeKind); } + } break; } case BRepGraph_NodeId::Kind::CoEdge: @@ -1803,54 +1901,72 @@ void BRepGraph::EditorView::EndDeferredInvalidation() noexcept const NCollection_DynamicArray* aFaces = aRevIdx.FacesOfWire(BRepGraph_WireId(aNodeId)); if (aFaces != nullptr) + { for (const BRepGraph_FaceId& aFaceId : *aFaces) { const BRepGraph_NodeId aParentId = aFaceId; if (!markVisited(aParentId)) + { continue; + } BRepGraphInc::BaseDef* aParent = myGraph->changeTopoEntity(aParentId); if (aParent == nullptr || aParent->IsRemoved) + { continue; + } ++aParent->SubtreeGen; aAllModified.Append(aParentId); aModifiedKindsMask |= BRepGraph_Layer::KindBit(aParentId.NodeKind); } + } break; } case BRepGraph_NodeId::Kind::Face: { const NCollection_DynamicArray* aShells = aRevIdx.ShellsOfFace(BRepGraph_FaceId(aNodeId)); if (aShells != nullptr) + { for (const BRepGraph_ShellId& aShellId : *aShells) { const BRepGraph_NodeId aParentId = aShellId; if (!markVisited(aParentId)) + { continue; + } BRepGraphInc::BaseDef* aParent = myGraph->changeTopoEntity(aParentId); if (aParent == nullptr || aParent->IsRemoved) + { continue; + } ++aParent->SubtreeGen; aAllModified.Append(aParentId); aModifiedKindsMask |= BRepGraph_Layer::KindBit(aParentId.NodeKind); } + } break; } case BRepGraph_NodeId::Kind::Shell: { const NCollection_DynamicArray* aSolids = aRevIdx.SolidsOfShell(BRepGraph_ShellId(aNodeId)); if (aSolids != nullptr) + { for (const BRepGraph_SolidId& aSolidId : *aSolids) { const BRepGraph_NodeId aParentId = aSolidId; if (!markVisited(aParentId)) + { continue; + } BRepGraphInc::BaseDef* aParent = myGraph->changeTopoEntity(aParentId); if (aParent == nullptr || aParent->IsRemoved) + { continue; + } ++aParent->SubtreeGen; aAllModified.Append(aParentId); aModifiedKindsMask |= BRepGraph_Layer::KindBit(aParentId.NodeKind); } + } break; } case BRepGraph_NodeId::Kind::Occurrence: { @@ -1887,7 +2003,9 @@ void BRepGraph::EditorView::EndDeferredInvalidation() noexcept // Dispatch batch modification event to subscribing layers. if (myGraph->myLayerRegistry.HasModificationSubscribers() && !aAllModified.IsEmpty()) + { myGraph->myLayerRegistry.DispatchNodesModified(aAllModified, aModifiedKindsMask); + } // Clear deferred list for next scope. aDeferredList.Clear(); @@ -2111,7 +2229,9 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit aStorage.ReverseIndex().CoEdgesOfEdge(theEdgeEntity)) { for (const BRepGraph_CoEdgeId& anId : *aSrc) + { anOrigCoEdgeIds.Append(anId); + } } const uint32_t aNbOrig = static_cast(anOrigCoEdgeIds.Size()); @@ -2134,9 +2254,13 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit { const double aPCRange = aOld.ParamLast - aOld.ParamFirst; if (aParamRange > 0.0) + { aPCSplit = aOld.ParamFirst + ((theSplitParam - aOrigParamFirst) / aParamRange) * aPCRange; + } else + { aPCSplit = 0.5 * (aOld.ParamFirst + aOld.ParamLast); + } } const BRepGraph_CoEdgeId aNewA = aStorage.AppendCoEdge(); @@ -2182,7 +2306,9 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit aNewBCoEdgeIds.Append(aNewB); aIdxOf.Bind(aOldId, i); if (aOld.FaceDefId.IsValid()) + { aOrigFaces.Append(aOld.FaceDefId); + } } // Step 3: re-establish SeamPairId linkage on new pairs. If the old @@ -2195,7 +2321,9 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit const BRepGraph_CoEdgeId aOldId = anOrigCoEdgeIds.Value(static_cast(i)); const BRepGraph_CoEdgeId aOldSeamPair = aStorage.CoEdge(aOldId).SeamPairId; if (!aOldSeamPair.IsValid() || !aIdxOf.IsBound(aOldSeamPair)) + { continue; + } int aJ = -1; aIdxOf.Find(aOldSeamPair, aJ); aStorage.ChangeCoEdge(aNewACoEdgeIds.Value(static_cast(i))).SeamPairId = @@ -2232,11 +2360,15 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit // wire's list but is filtered out of any live walk. Split must not // revive them. if (aRefEnt.IsRemoved) + { continue; + } const BRepGraph_CoEdgeId aOldCEId = aRefEnt.CoEdgeDefId; int aJ = -1; if (!aIdxOf.Find(aOldCEId, aJ)) + { continue; + } const BRepGraph_CoEdgeId aNewA = aNewACoEdgeIds.Value(aJ); const BRepGraph_CoEdgeId aNewB = aNewBCoEdgeIds.Value(aJ); const TopLoc_Location aLoc = aStorage.CoEdgeRef(aRefId).LocalLocation; @@ -2258,9 +2390,13 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit BRepGraphInc::WireDef& aWireEnt = aStorage.ChangeWire(aWireId); auto& aCoEdgeRefIds = aWireEnt.CoEdgeRefIds; if (aPos < aCoEdgeRefIds.Size()) + { aCoEdgeRefIds.InsertAfter(aPos, aNewRefId); + } else + { aCoEdgeRefIds.Append(aNewRefId); + } ++anInsertOffset; aRevIdx.UnbindCoEdgeFromWire(aOldCEId, aWireId); @@ -2289,9 +2425,13 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit // SubA/SubB based on parameter - reparenting is a follow-up when a // caller surfaces that needs it. if (aOrigStartVertexRefId.IsValid()) + { aStorage.MarkRemovedRef(aOrigStartVertexRefId); + } if (aOrigEndVertexRefId.IsValid()) + { aStorage.MarkRemovedRef(aOrigEndVertexRefId); + } // Defensive retirement of internal vertex refs. No existing test // populates InternalVertexRefIds before a Split, so the loop is a // no-op under the current suite; it guards against orphan refs the @@ -2305,7 +2445,9 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit { const BRepGraph_VertexRefId anIntRef = anIntRefIt.Value(); if (anIntRef.IsValid()) + { aStorage.MarkRemovedRef(anIntRef); + } } } @@ -2336,33 +2478,45 @@ void BRepGraph::EditorView::EdgeOps::Split(const BRepGraph_EdgeId theEdgeEntit const BRepGraph_VertexId aVtxId = aStorageRef.VertexRef(aSubAEnt.StartVertexRefId).VertexDefId; if (aVtxId.IsValid()) + { aRevIdxMut.BindVertexToEdge(aVtxId, aSubAId); + } } if (aSubAEnt.EndVertexRefId.IsValid()) { const BRepGraph_VertexId aVtxId = aStorageRef.VertexRef(aSubAEnt.EndVertexRefId).VertexDefId; if (aVtxId.IsValid()) + { aRevIdxMut.BindVertexToEdge(aVtxId, aSubAId); + } } if (aSubBEnt.StartVertexRefId.IsValid()) { const BRepGraph_VertexId aVtxId = aStorageRef.VertexRef(aSubBEnt.StartVertexRefId).VertexDefId; if (aVtxId.IsValid()) + { aRevIdxMut.BindVertexToEdge(aVtxId, aSubBId); + } } if (aSubBEnt.EndVertexRefId.IsValid()) { const BRepGraph_VertexId aVtxId = aStorageRef.VertexRef(aSubBEnt.EndVertexRefId).VertexDefId; if (aVtxId.IsValid()) + { aRevIdxMut.BindVertexToEdge(aVtxId, aSubBId); + } } // Remove old edge from vertex-to-edge index. if (aOrigStartVertexDefId.IsValid()) + { aRevIdxMut.UnbindVertexFromEdge(aOrigStartVertexDefId, BRepGraph_EdgeId(theEdgeEntity)); + } if (aOrigEndVertexDefId.IsValid()) + { aRevIdxMut.UnbindVertexFromEdge(aOrigEndVertexDefId, BRepGraph_EdgeId(theEdgeEntity)); + } // Edge-to-face: unbind the original edge and bind both sub-edges for // each face the original edge touched. aOrigFaces was captured during @@ -2412,7 +2566,9 @@ void BRepGraph::EditorView::WireOps::ReplaceEdge(const BRepGraph_WireId theWireD const BRepGraphInc::CoEdgeRef& aRef = aStorage.CoEdgeRef(aRefIt.CurrentId()); const BRepGraph_CoEdgeId aCoEdgeDefId = aRef.CoEdgeDefId; if (!aCoEdgeDefId.IsValid(aStorage.NbCoEdges())) + { continue; + } BRepGraphInc::CoEdgeDef& aCoEdge = aStorage.ChangeCoEdge(aCoEdgeDefId); if (aCoEdge.EdgeDefId == theOldEdgeEntity) @@ -2612,7 +2768,9 @@ bool BRepGraph::EditorView::ProductOps::RemoveShapeRoot(const BRepGraph_ProductI { const BRepGraphInc::OccurrenceRef& aOccRef = aStorage.OccurrenceRef(aRefId); if (aOccRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOcc = aStorage.Occurrence(aOccRef.OccurrenceDefId); if (!anOcc.IsRemoved && BRepGraph_NodeId::IsTopologyKind(anOcc.ChildDefId.NodeKind)) { @@ -3180,7 +3338,9 @@ bool BRepGraph::EditorView::EdgeOps::RemoveVertex(const BRepGraph_EdgeId th const BRepGraphInc::EdgeDef& anEdgeRO = aStorage.Edge(theEdgeDefId); auto refTargets = [&](const BRepGraph_VertexRefId theRefId) { if (!theRefId.IsValid()) + { return false; + } const BRepGraphInc::VertexRef& aVR = aStorage.VertexRef(theRefId); return !aVR.IsRemoved && aVR.VertexDefId == aVertexDefId; }; @@ -3367,7 +3527,9 @@ bool BRepGraph::EditorView::ValidateMutationBoundary( const int aCachedCnt = cachedActiveByKind(aStorage, aKind); const int anActualCnt = countActiveByKind(*myGraph, aKind); if (aCachedCnt == anActualCnt) + { continue; + } isValid = false; if (theIssues != nullptr) diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Setters.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Setters.cxx index 21f96ba0f8..3101bd5703 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Setters.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Setters.cxx @@ -36,16 +36,24 @@ bool isLastCoEdgeOfEdgeOnFace(const BRepGraphInc_Storage& theStorage, const NCollection_DynamicArray* aCoEdges = theStorage.ReverseIndex().CoEdgesOfEdge(theEdge); if (aCoEdges == nullptr) + { return true; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdges) { if (aCoEdgeId == theExcluding) + { continue; + } if (!aCoEdgeId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aCoEdgeId); if (!aCoEdge.IsRemoved && aCoEdge.FaceDefId == theFace) + { return false; + } } return true; } @@ -977,7 +985,9 @@ BRepGraph_VertexId vertexFromRef(const BRepGraphInc_Storage& theStorage, const BRepGraph_VertexRefId theRef) { if (!theRef.IsValid(theStorage.NbVertexRefs())) + { return BRepGraph_VertexId(); + } return theStorage.VertexRef(theRef).VertexDefId; } @@ -987,22 +997,32 @@ bool isLastVertexUsageOnEdge(const BRepGraphInc_Storage& theStorage, const BRepGraph_VertexRefId theExcludingRef) { if (!theEdge.IsValid(theStorage.NbEdges()) || !theVtx.IsValid()) + { return true; + } const BRepGraphInc::EdgeDef& anEdge = theStorage.Edge(theEdge); auto refResolvesTo = [&](const BRepGraph_VertexRefId aRefId) -> bool { if (!aRefId.IsValid(theStorage.NbVertexRefs()) || aRefId == theExcludingRef) + { return false; + } const BRepGraphInc::VertexRef& aRef = theStorage.VertexRef(aRefId); return !aRef.IsRemoved && aRef.VertexDefId == theVtx; }; if (refResolvesTo(anEdge.StartVertexRefId)) + { return false; + } if (refResolvesTo(anEdge.EndVertexRefId)) + { return false; + } for (const BRepGraph_VertexRefId& anIntRefId : anEdge.InternalVertexRefIds) { if (refResolvesTo(anIntRefId)) + { return false; + } } return true; } @@ -1014,7 +1034,9 @@ void rebindVertexEdge(BRepGraphInc_Storage& theStorage, const BRepGraph_VertexRefId theExcludingRef) { if (theOldVtx == theNewVtx) + { return; + } BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldVtx.IsValid() && isLastVertexUsageOnEdge(theStorage, theEdge, theOldVtx, theExcludingRef)) @@ -1022,7 +1044,9 @@ void rebindVertexEdge(BRepGraphInc_Storage& theStorage, aRI.UnbindVertexFromEdge(theOldVtx, theEdge); } if (theNewVtx.IsValid()) + { aRI.BindVertexToEdge(theNewVtx, theEdge); + } } } // namespace @@ -1032,7 +1056,9 @@ void BRepGraph::EditorView::EdgeOps::SetStartVertexRefId(const BRepGraph_EdgeId BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::EdgeDef& anEdge = aStorage.ChangeEdge(theEdge); if (anEdge.StartVertexRefId == theVertexRef) + { return; + } const BRepGraph_VertexId anOldVtx = vertexFromRef(aStorage, anEdge.StartVertexRefId); const BRepGraph_VertexId aNewVtx = vertexFromRef(aStorage, theVertexRef); anEdge.StartVertexRefId = theVertexRef; @@ -1045,7 +1071,9 @@ void BRepGraph::EditorView::EdgeOps::SetStartVertexRefId( const BRepGraph_VertexRefId theVertexRef) { if (theMut->StartVertexRefId == theVertexRef) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_VertexId anOldVtx = vertexFromRef(aStorage, theMut->StartVertexRefId); const BRepGraph_VertexId aNewVtx = vertexFromRef(aStorage, theVertexRef); @@ -1061,7 +1089,9 @@ void BRepGraph::EditorView::EdgeOps::SetEndVertexRefId(const BRepGraph_EdgeId BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::EdgeDef& anEdge = aStorage.ChangeEdge(theEdge); if (anEdge.EndVertexRefId == theVertexRef) + { return; + } const BRepGraph_VertexId anOldVtx = vertexFromRef(aStorage, anEdge.EndVertexRefId); const BRepGraph_VertexId aNewVtx = vertexFromRef(aStorage, theVertexRef); anEdge.EndVertexRefId = theVertexRef; @@ -1074,7 +1104,9 @@ void BRepGraph::EditorView::EdgeOps::SetEndVertexRefId( const BRepGraph_VertexRefId theVertexRef) { if (theMut->EndVertexRefId == theVertexRef) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_VertexId anOldVtx = vertexFromRef(aStorage, theMut->EndVertexRefId); const BRepGraph_VertexId aNewVtx = vertexFromRef(aStorage, theVertexRef); @@ -1093,20 +1125,30 @@ bool isLastCoEdgeOfEdgeInWire(const BRepGraphInc_Storage& theStorage, const BRepGraph_CoEdgeId theExcluding) { if (!theWire.IsValid(theStorage.NbWires())) + { return true; + } const BRepGraphInc::WireDef& aWireDef = theStorage.Wire(theWire); for (const BRepGraph_CoEdgeRefId& aRefId : aWireDef.CoEdgeRefIds) { if (!aRefId.IsValid(theStorage.NbCoEdgeRefs())) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theStorage.CoEdgeRef(aRefId); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } if (aRef.CoEdgeDefId == theExcluding) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aRef.CoEdgeDefId); if (!aCoEdge.IsRemoved && aCoEdge.EdgeDefId == theEdge) + { return false; + } } return true; } @@ -1119,12 +1161,18 @@ void rebindCoEdgeEdge(BRepGraphInc_Storage& theStorage, const BRepGraph_EdgeId theNewEdge) { if (theOldEdge == theNewEdge) + { return; + } BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldEdge.IsValid()) + { aRI.UnbindEdgeFromCoEdge(theOldEdge, theCoEdge); + } if (theNewEdge.IsValid()) + { aRI.BindEdgeToCoEdge(theNewEdge, theCoEdge); + } // Wires that own this coedge: rebind edge-to-wire only when no other coedge of the // same wire still references the old edge. const NCollection_DynamicArray* aWires = aRI.WiresOfCoEdge(theCoEdge); @@ -1138,7 +1186,9 @@ void rebindCoEdgeEdge(BRepGraphInc_Storage& theStorage, aRI.UnbindEdgeFromWire(theOldEdge, aWireId); } if (theNewEdge.IsValid()) + { aRI.BindEdgeToWire(theNewEdge, aWireId); + } } } // Face binding follows the (edge, face) pair; if the coedge has a face, rebind. @@ -1150,7 +1200,9 @@ void rebindCoEdgeEdge(BRepGraphInc_Storage& theStorage, aRI.UnbindEdgeFromFace(theOldEdge, theDef.FaceDefId); } if (theNewEdge.IsValid()) + { aRI.BindEdgeToFace(theNewEdge, theDef.FaceDefId); + } } } @@ -1162,14 +1214,18 @@ void rebindCoEdgeFace(BRepGraphInc_Storage& theStorage, const BRepGraph_FaceId theNewFace) { if (theOldFace == theNewFace || !theEdge.IsValid()) + { return; + } BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldFace.IsValid() && isLastCoEdgeOfEdgeOnFace(theStorage, theEdge, theOldFace, theCoEdge)) { aRI.UnbindEdgeFromFace(theEdge, theOldFace); } if (theNewFace.IsValid()) + { aRI.BindEdgeToFace(theEdge, theNewFace); + } } } // namespace @@ -1179,7 +1235,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetEdgeDefId(const BRepGraph_CoEdgeId the BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::CoEdgeDef& aDef = aStorage.ChangeCoEdge(theCoEdge); if (aDef.EdgeDefId == theEdge) + { return; + } const BRepGraph_EdgeId anOldEdge = aDef.EdgeDefId; aDef.EdgeDefId = theEdge; rebindCoEdgeEdge(aStorage, theCoEdge, aDef, anOldEdge, theEdge); @@ -1191,7 +1249,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetEdgeDefId( const BRepGraph_EdgeId theEdge) { if (theMut->EdgeDefId == theEdge) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_EdgeId anOldEdge = theMut->EdgeDefId; theMut.Internal().EdgeDefId = theEdge; @@ -1206,7 +1266,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetFaceDefId(const BRepGraph_CoEdgeId the BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::CoEdgeDef& aDef = aStorage.ChangeCoEdge(theCoEdge); if (aDef.FaceDefId == theFace) + { return; + } const BRepGraph_FaceId anOldFace = aDef.FaceDefId; const BRepGraph_EdgeId anEdge = aDef.EdgeDefId; aDef.FaceDefId = theFace; @@ -1219,7 +1281,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetFaceDefId( const BRepGraph_FaceId theFace) { if (theMut->FaceDefId == theFace) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_FaceId anOldFace = theMut->FaceDefId; const BRepGraph_EdgeId anEdge = theMut->EdgeDefId; @@ -1238,9 +1302,13 @@ void rebindVertexRef(BRepGraphInc_Storage& theStorage, const BRepGraph_VertexRefId theMutatedRef) { if (theOldVtx == theNewVtx) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Edge) + { return; + } const BRepGraph_EdgeId anEdge(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldVtx.IsValid() && isLastVertexUsageOnEdge(theStorage, anEdge, theOldVtx, theMutatedRef)) @@ -1248,7 +1316,9 @@ void rebindVertexRef(BRepGraphInc_Storage& theStorage, aRI.UnbindVertexFromEdge(theOldVtx, anEdge); } if (theNewVtx.IsValid()) + { aRI.BindVertexToEdge(theNewVtx, anEdge); + } } } // namespace @@ -1258,7 +1328,9 @@ void BRepGraph::EditorView::VertexOps::SetRefVertexDefId(const BRepGraph_VertexR BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::VertexRef& aRef = aStorage.ChangeVertexRef(theVertexRef); if (aRef.VertexDefId == theVertex) + { return; + } const BRepGraph_VertexId anOldVtx = aRef.VertexDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.VertexDefId = theVertex; @@ -1271,7 +1343,9 @@ void BRepGraph::EditorView::VertexOps::SetRefVertexDefId( const BRepGraph_VertexId theVertex) { if (theMut->VertexDefId == theVertex) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_VertexId anOldVtx = theMut->VertexDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1289,15 +1363,21 @@ bool isLastWireUsageOnFace(const BRepGraphInc_Storage& theStorage, const BRepGraph_WireRefId theExcludingRef) { if (!theFace.IsValid(theStorage.NbFaces()) || !theWire.IsValid()) + { return true; + } const BRepGraphInc::FaceDef& aFaceDef = theStorage.Face(theFace); for (const BRepGraph_WireRefId& aRefId : aFaceDef.WireRefIds) { if (!aRefId.IsValid(theStorage.NbWireRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::WireRef& aRef = theStorage.WireRef(aRefId); if (!aRef.IsRemoved && aRef.WireDefId == theWire) + { return false; + } } return true; } @@ -1309,9 +1389,13 @@ void rebindWireRef(BRepGraphInc_Storage& theStorage, const BRepGraph_WireRefId theMutatedRef) { if (theOldWire == theNewWire) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Face) + { return; + } const BRepGraph_FaceId aFace(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldWire.IsValid() && isLastWireUsageOnFace(theStorage, aFace, theOldWire, theMutatedRef)) @@ -1319,7 +1403,9 @@ void rebindWireRef(BRepGraphInc_Storage& theStorage, aRI.UnbindWireFromFace(theOldWire, aFace); } if (theNewWire.IsValid()) + { aRI.BindWireToFace(theNewWire, aFace); + } } } // namespace @@ -1329,7 +1415,9 @@ void BRepGraph::EditorView::WireOps::SetRefWireDefId(const BRepGraph_WireRefId t BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::WireRef& aRef = aStorage.ChangeWireRef(theWireRef); if (aRef.WireDefId == theWire) + { return; + } const BRepGraph_WireId anOldWire = aRef.WireDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.WireDefId = theWire; @@ -1342,7 +1430,9 @@ void BRepGraph::EditorView::WireOps::SetRefWireDefId( const BRepGraph_WireId theWire) { if (theMut->WireDefId == theWire) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_WireId anOldWire = theMut->WireDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1360,15 +1450,21 @@ bool isLastFaceUsageOnShell(const BRepGraphInc_Storage& theStorage, const BRepGraph_FaceRefId theExcludingRef) { if (!theShell.IsValid(theStorage.NbShells()) || !theFace.IsValid()) + { return true; + } const BRepGraphInc::ShellDef& aShellDef = theStorage.Shell(theShell); for (const BRepGraph_FaceRefId& aRefId : aShellDef.FaceRefIds) { if (!aRefId.IsValid(theStorage.NbFaceRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::FaceRef& aRef = theStorage.FaceRef(aRefId); if (!aRef.IsRemoved && aRef.FaceDefId == theFace) + { return false; + } } return true; } @@ -1380,9 +1476,13 @@ void rebindFaceRef(BRepGraphInc_Storage& theStorage, const BRepGraph_FaceRefId theMutatedRef) { if (theOldFace == theNewFace) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Shell) + { return; + } const BRepGraph_ShellId aShell(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldFace.IsValid() && isLastFaceUsageOnShell(theStorage, aShell, theOldFace, theMutatedRef)) @@ -1390,7 +1490,9 @@ void rebindFaceRef(BRepGraphInc_Storage& theStorage, aRI.UnbindFaceFromShell(theOldFace, aShell); } if (theNewFace.IsValid()) + { aRI.BindFaceToShell(theNewFace, aShell); + } } } // namespace @@ -1400,7 +1502,9 @@ void BRepGraph::EditorView::FaceOps::SetRefFaceDefId(const BRepGraph_FaceRefId t BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::FaceRef& aRef = aStorage.ChangeFaceRef(theFaceRef); if (aRef.FaceDefId == theFace) + { return; + } const BRepGraph_FaceId anOldFace = aRef.FaceDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.FaceDefId = theFace; @@ -1413,7 +1517,9 @@ void BRepGraph::EditorView::FaceOps::SetRefFaceDefId( const BRepGraph_FaceId theFace) { if (theMut->FaceDefId == theFace) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_FaceId anOldFace = theMut->FaceDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1431,15 +1537,21 @@ bool isLastShellUsageOnSolid(const BRepGraphInc_Storage& theStorage, const BRepGraph_ShellRefId theExcludingRef) { if (!theSolid.IsValid(theStorage.NbSolids()) || !theShell.IsValid()) + { return true; + } const BRepGraphInc::SolidDef& aSolidDef = theStorage.Solid(theSolid); for (const BRepGraph_ShellRefId& aRefId : aSolidDef.ShellRefIds) { if (!aRefId.IsValid(theStorage.NbShellRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::ShellRef& aRef = theStorage.ShellRef(aRefId); if (!aRef.IsRemoved && aRef.ShellDefId == theShell) + { return false; + } } return true; } @@ -1451,9 +1563,13 @@ void rebindShellRef(BRepGraphInc_Storage& theStorage, const BRepGraph_ShellRefId theMutatedRef) { if (theOldShell == theNewShell) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Solid) + { return; + } const BRepGraph_SolidId aSolid(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldShell.IsValid() @@ -1462,7 +1578,9 @@ void rebindShellRef(BRepGraphInc_Storage& theStorage, aRI.UnbindShellFromSolid(theOldShell, aSolid); } if (theNewShell.IsValid()) + { aRI.BindShellToSolid(theNewShell, aSolid); + } } } // namespace @@ -1472,7 +1590,9 @@ void BRepGraph::EditorView::ShellOps::SetRefShellDefId(const BRepGraph_ShellRefI BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::ShellRef& aRef = aStorage.ChangeShellRef(theShellRef); if (aRef.ShellDefId == theShell) + { return; + } const BRepGraph_ShellId anOldShell = aRef.ShellDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.ShellDefId = theShell; @@ -1485,7 +1605,9 @@ void BRepGraph::EditorView::ShellOps::SetRefShellDefId( const BRepGraph_ShellId theShell) { if (theMut->ShellDefId == theShell) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_ShellId anOldShell = theMut->ShellDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1503,15 +1625,21 @@ bool isLastSolidUsageOnCompSolid(const BRepGraphInc_Storage& theStorage, const BRepGraph_SolidRefId theExcludingRef) { if (!theCompSolid.IsValid(theStorage.NbCompSolids()) || !theSolid.IsValid()) + { return true; + } const BRepGraphInc::CompSolidDef& aCSDef = theStorage.CompSolid(theCompSolid); for (const BRepGraph_SolidRefId& aRefId : aCSDef.SolidRefIds) { if (!aRefId.IsValid(theStorage.NbSolidRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::SolidRef& aRef = theStorage.SolidRef(aRefId); if (!aRef.IsRemoved && aRef.SolidDefId == theSolid) + { return false; + } } return true; } @@ -1523,9 +1651,13 @@ void rebindSolidRef(BRepGraphInc_Storage& theStorage, const BRepGraph_SolidRefId theMutatedRef) { if (theOldSolid == theNewSolid) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::CompSolid) + { return; + } const BRepGraph_CompSolidId aCompSolid(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldSolid.IsValid() @@ -1534,7 +1666,9 @@ void rebindSolidRef(BRepGraphInc_Storage& theStorage, aRI.UnbindSolidFromCompSolid(theOldSolid, aCompSolid); } if (theNewSolid.IsValid()) + { aRI.BindSolidToCompSolid(theNewSolid, aCompSolid); + } } } // namespace @@ -1544,7 +1678,9 @@ void BRepGraph::EditorView::SolidOps::SetRefSolidDefId(const BRepGraph_SolidRefI BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::SolidRef& aRef = aStorage.ChangeSolidRef(theSolidRef); if (aRef.SolidDefId == theSolid) + { return; + } const BRepGraph_SolidId anOldSolid = aRef.SolidDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.SolidDefId = theSolid; @@ -1557,7 +1693,9 @@ void BRepGraph::EditorView::SolidOps::SetRefSolidDefId( const BRepGraph_SolidId theSolid) { if (theMut->SolidDefId == theSolid) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_SolidId anOldSolid = theMut->SolidDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1574,7 +1712,9 @@ BRepGraph_EdgeId edgeFromCoEdge(const BRepGraphInc_Storage& theStorage, const BRepGraph_CoEdgeId theCoEdge) { if (!theCoEdge.IsValid(theStorage.NbCoEdges())) + { return BRepGraph_EdgeId(); + } return theStorage.CoEdge(theCoEdge).EdgeDefId; } @@ -1585,20 +1725,30 @@ bool isLastCoEdgeRefOfEdgeInWire(const BRepGraphInc_Storage& theStorage, const BRepGraph_CoEdgeRefId theExcluding) { if (!theWire.IsValid(theStorage.NbWires())) + { return true; + } const BRepGraphInc::WireDef& aWireDef = theStorage.Wire(theWire); for (const BRepGraph_CoEdgeRefId& aRefId : aWireDef.CoEdgeRefIds) { if (aRefId == theExcluding) + { continue; + } if (!aRefId.IsValid(theStorage.NbCoEdgeRefs())) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theStorage.CoEdgeRef(aRefId); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aRef.CoEdgeDefId); if (!aCoEdge.IsRemoved && aCoEdge.EdgeDefId == theEdge) + { return false; + } } return true; } @@ -1610,15 +1760,23 @@ void rebindCoEdgeRef(BRepGraphInc_Storage& theStorage, const BRepGraph_CoEdgeId theNewCoEdge) { if (theOldCoEdge == theNewCoEdge) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Wire) + { return; + } const BRepGraph_WireId aWire(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldCoEdge.IsValid()) + { aRI.UnbindCoEdgeFromWire(theOldCoEdge, aWire); + } if (theNewCoEdge.IsValid()) + { aRI.BindCoEdgeToWire(theNewCoEdge, aWire); + } // EdgeToWires is derived from coedge.EdgeDefId x wire (deduplicated). Unbind only // when no other CoEdgeRef in the wire still references the old edge. const BRepGraph_EdgeId anOldEdge = edgeFromCoEdge(theStorage, theOldCoEdge); @@ -1630,7 +1788,9 @@ void rebindCoEdgeRef(BRepGraphInc_Storage& theStorage, aRI.UnbindEdgeFromWire(anOldEdge, aWire); } if (aNewEdge.IsValid()) + { aRI.BindEdgeToWire(aNewEdge, aWire); + } } } } // namespace @@ -1641,7 +1801,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetRefCoEdgeDefId(const BRepGraph_CoEdgeR BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::CoEdgeRef& aRef = aStorage.ChangeCoEdgeRef(theCoEdgeRef); if (aRef.CoEdgeDefId == theCoEdge) + { return; + } const BRepGraph_CoEdgeId anOldCoEdge = aRef.CoEdgeDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.CoEdgeDefId = theCoEdge; @@ -1654,7 +1816,9 @@ void BRepGraph::EditorView::CoEdgeOps::SetRefCoEdgeDefId( const BRepGraph_CoEdgeId theCoEdge) { if (theMut->CoEdgeDefId == theCoEdge) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_CoEdgeId anOldCoEdge = theMut->CoEdgeDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1672,15 +1836,21 @@ bool isLastChildUsageOnCompound(const BRepGraphInc_Storage& theStorage, const BRepGraph_ChildRefId theExcludingRef) { if (!theCompound.IsValid(theStorage.NbCompounds()) || !theChild.IsValid()) + { return true; + } const BRepGraphInc::CompoundDef& aCompDef = theStorage.Compound(theCompound); for (const BRepGraph_ChildRefId& aRefId : aCompDef.ChildRefIds) { if (!aRefId.IsValid(theStorage.NbChildRefs()) || aRefId == theExcludingRef) + { continue; + } const BRepGraphInc::ChildRef& aRef = theStorage.ChildRef(aRefId); if (!aRef.IsRemoved && aRef.ChildDefId == theChild) + { return false; + } } return true; } @@ -1692,9 +1862,13 @@ void rebindChildRef(BRepGraphInc_Storage& theStorage, const BRepGraph_ChildRefId theMutatedRef) { if (theOldChild == theNewChild) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Compound) + { return; + } const BRepGraph_CompoundId aCompound(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldChild.IsValid() @@ -1703,7 +1877,9 @@ void rebindChildRef(BRepGraphInc_Storage& theStorage, aRI.UnbindCompoundChild(theOldChild, aCompound); } if (theNewChild.IsValid()) + { aRI.BindCompoundChild(theNewChild, aCompound); + } } } // namespace @@ -1713,7 +1889,9 @@ void BRepGraph::EditorView::GenOps::SetChildRefChildDefId(const BRepGraph_ChildR BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::ChildRef& aRef = aStorage.ChangeChildRef(theChildRef); if (aRef.ChildDefId == theChild) + { return; + } const BRepGraph_NodeId anOldChild = aRef.ChildDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.ChildDefId = theChild; @@ -1726,7 +1904,9 @@ void BRepGraph::EditorView::GenOps::SetChildRefChildDefId( const BRepGraph_NodeId theChild) { if (theMut->ChildDefId == theChild) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_NodeId anOldChild = theMut->ChildDefId; const BRepGraph_NodeId aParent = theMut->ParentId; @@ -1744,15 +1924,23 @@ void rebindOccurrenceRef(BRepGraphInc_Storage& theStorage, const BRepGraph_OccurrenceId theNewOcc) { if (theOldOcc == theNewOcc) + { return; + } if (theParent.NodeKind != BRepGraph_NodeId::Kind::Product) + { return; + } const BRepGraph_ProductId aProduct(theParent); BRepGraphInc_ReverseIndex& aRI = theStorage.ChangeReverseIndex(); if (theOldOcc.IsValid()) + { aRI.UnbindProductOccurrence(theOldOcc, aProduct); + } if (theNewOcc.IsValid()) + { aRI.BindProductOccurrence(theNewOcc, aProduct); + } } } // namespace @@ -1763,7 +1951,9 @@ void BRepGraph::EditorView::OccurrenceOps::SetRefOccurrenceDefId( BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; BRepGraphInc::OccurrenceRef& aRef = aStorage.ChangeOccurrenceRef(theOccurrenceRef); if (aRef.OccurrenceDefId == theOccurrence) + { return; + } const BRepGraph_OccurrenceId anOldOcc = aRef.OccurrenceDefId; const BRepGraph_NodeId aParent = aRef.ParentId; aRef.OccurrenceDefId = theOccurrence; @@ -1776,7 +1966,9 @@ void BRepGraph::EditorView::OccurrenceOps::SetRefOccurrenceDefId( const BRepGraph_OccurrenceId theOccurrence) { if (theMut->OccurrenceDefId == theOccurrence) + { return; + } BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_OccurrenceId anOldOcc = theMut->OccurrenceDefId; const BRepGraph_NodeId aParent = theMut->ParentId; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_History.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_History.cxx index 0ac230c451..65b0f974bb 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_History.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_History.cxx @@ -80,7 +80,9 @@ void BRepGraph_History::Record(const TCollection_AsciiString& } if (aFilteredReplacements.IsEmpty()) + { return; + } if (myOriginalToDerived.IsBound(theOriginal)) { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerParam.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerParam.cxx index cd720a9c4f..17c549bbba 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerParam.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerParam.cxx @@ -37,7 +37,9 @@ void appendUnique(NCollection_DataMap& aVertices = theMap.ChangeFind(theKey); uint32_t anIdx = 0; @@ -56,15 +60,21 @@ void removeVertex(NCollection_DataMap(aVertices.Size()) - 1u) + { aVertices.ChangeValue(static_cast(anIdx)) = aVertices.Value(aVertices.Size() - 1u); + } aVertices.EraseLast(); break; } if (aVertices.IsEmpty()) + { theMap.UnBind(theKey); + } } static BRepGraph_VertexId remapVertex( @@ -73,7 +83,9 @@ static BRepGraph_VertexId remapVertex( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theVertex); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::Vertex) + { return BRepGraph_VertexId(); + } return BRepGraph_VertexId(*aNewId); } @@ -83,7 +95,9 @@ static BRepGraph_EdgeId remapEdge( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theEdge); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::Edge) + { return BRepGraph_EdgeId(); + } return BRepGraph_EdgeId(*aNewId); } @@ -93,7 +107,9 @@ static BRepGraph_FaceId remapFace( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theFace); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::Face) + { return BRepGraph_FaceId(); + } return BRepGraph_FaceId(*aNewId); } @@ -103,7 +119,9 @@ static BRepGraph_CoEdgeId remapCoEdge( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theCoEdge); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::CoEdge) + { return BRepGraph_CoEdgeId(); + } return BRepGraph_CoEdgeId(*aNewId); } @@ -155,14 +173,20 @@ bool BRepGraph_LayerParam::FindPointOnCurve(const BRepGraph_VertexId theVertex, { const VertexParams* aParams = FindVertexParams(theVertex); if (aParams == nullptr) + { return false; + } for (const PointOnCurveEntry& anEntry : aParams->PointsOnCurve) { if (anEntry.EdgeDefId != theEdge) + { continue; + } if (theParameter != nullptr) + { *theParameter = anEntry.Parameter; + } return true; } return false; @@ -176,14 +200,20 @@ bool BRepGraph_LayerParam::FindPointOnSurface(const BRepGraph_VertexId theVertex { const VertexParams* aParams = FindVertexParams(theVertex); if (aParams == nullptr) + { return false; + } for (const PointOnSurfaceEntry& anEntry : aParams->PointsOnSurface) { if (anEntry.FaceDefId != theFace) + { continue; + } if (theUV != nullptr) + { *theUV = gp_Pnt2d(anEntry.ParameterU, anEntry.ParameterV); + } return true; } return false; @@ -197,14 +227,20 @@ bool BRepGraph_LayerParam::FindPointOnPCurve(const BRepGraph_VertexId theVertex, { const VertexParams* aParams = FindVertexParams(theVertex); if (aParams == nullptr) + { return false; + } for (const PointOnPCurveEntry& anEntry : aParams->PointsOnPCurve) { if (anEntry.CoEdgeDefId != theCoEdge) + { continue; + } if (theParameter != nullptr) + { *theParameter = anEntry.Parameter; + } return true; } return false; @@ -240,7 +276,9 @@ BRepGraph_LayerParam::VertexParams& BRepGraph_LayerParam::changeVertexParams( const BRepGraph_VertexId theVertex) { if (!myVertexParams.IsBound(theVertex)) + { myVertexParams.Bind(theVertex, VertexParams()); + } return myVertexParams.ChangeFind(theVertex); } @@ -304,7 +342,9 @@ void BRepGraph_LayerParam::SetPointOnCurve(const BRepGraph_VertexId theVertex, anIt.Next()) { if (anIt.Value().EdgeDefId != theEdge) + { continue; + } anIt.ChangeValue().Parameter = theParameter; return; } @@ -328,7 +368,9 @@ void BRepGraph_LayerParam::SetPointOnSurface(const BRepGraph_VertexId theVertex, anIt.Next()) { if (anIt.Value().FaceDefId != theFace) + { continue; + } anIt.ChangeValue().ParameterU = theParameterU; anIt.ChangeValue().ParameterV = theParameterV; return; @@ -353,7 +395,9 @@ void BRepGraph_LayerParam::SetPointOnPCurve(const BRepGraph_VertexId theVertex, anIt.Next()) { if (anIt.Value().CoEdgeDefId != theCoEdge) + { continue; + } anIt.ChangeValue().Parameter = theParameter; return; } @@ -370,7 +414,9 @@ void BRepGraph_LayerParam::removePointOnCurve(const BRepGraph_VertexId theVertex const BRepGraph_EdgeId theEdge) noexcept { if (!myVertexParams.IsBound(theVertex)) + { return; + } VertexParams& aParams = myVertexParams.ChangeFind(theVertex); uint32_t anIdx = 0; @@ -379,17 +425,23 @@ void BRepGraph_LayerParam::removePointOnCurve(const BRepGraph_VertexId theVertex anIt.Next(), ++anIdx) { if (anIt.Value().EdgeDefId != theEdge) + { continue; + } if (anIdx < static_cast(aParams.PointsOnCurve.Size()) - 1u) + { aParams.PointsOnCurve.ChangeValue(static_cast(anIdx)) = aParams.PointsOnCurve.Value(aParams.PointsOnCurve.Size() - 1u); + } aParams.PointsOnCurve.EraseLast(); unbindEdgeFromVertex(theEdge, theVertex); break; } if (aParams.IsEmpty()) + { myVertexParams.UnBind(theVertex); + } } //================================================================================================= @@ -398,7 +450,9 @@ void BRepGraph_LayerParam::removePointOnSurface(const BRepGraph_VertexId theVert const BRepGraph_FaceId theFace) noexcept { if (!myVertexParams.IsBound(theVertex)) + { return; + } VertexParams& aParams = myVertexParams.ChangeFind(theVertex); uint32_t anIdx = 0; @@ -407,17 +461,23 @@ void BRepGraph_LayerParam::removePointOnSurface(const BRepGraph_VertexId theVert anIt.Next(), ++anIdx) { if (anIt.Value().FaceDefId != theFace) + { continue; + } if (anIdx < static_cast(aParams.PointsOnSurface.Size()) - 1u) + { aParams.PointsOnSurface.ChangeValue(static_cast(anIdx)) = aParams.PointsOnSurface.Value(aParams.PointsOnSurface.Size() - 1u); + } aParams.PointsOnSurface.EraseLast(); unbindFaceFromVertex(theFace, theVertex); break; } if (aParams.IsEmpty()) + { myVertexParams.UnBind(theVertex); + } } //================================================================================================= @@ -426,7 +486,9 @@ void BRepGraph_LayerParam::removePointOnPCurve(const BRepGraph_VertexId theVerte const BRepGraph_CoEdgeId theCoEdge) noexcept { if (!myVertexParams.IsBound(theVertex)) + { return; + } VertexParams& aParams = myVertexParams.ChangeFind(theVertex); uint32_t anIdx = 0; @@ -435,17 +497,23 @@ void BRepGraph_LayerParam::removePointOnPCurve(const BRepGraph_VertexId theVerte anIt.Next(), ++anIdx) { if (anIt.Value().CoEdgeDefId != theCoEdge) + { continue; + } if (anIdx < static_cast(aParams.PointsOnPCurve.Size()) - 1u) + { aParams.PointsOnPCurve.ChangeValue(static_cast(anIdx)) = aParams.PointsOnPCurve.Value(aParams.PointsOnPCurve.Size() - 1u); + } aParams.PointsOnPCurve.EraseLast(); unbindCoEdgeFromVertex(theCoEdge, theVertex); break; } if (aParams.IsEmpty()) + { myVertexParams.UnBind(theVertex); + } } //================================================================================================= @@ -454,14 +522,22 @@ void BRepGraph_LayerParam::removeVertexBindings(const BRepGraph_VertexId theVert { const VertexParams* aParams = myVertexParams.Seek(theVertex); if (aParams == nullptr) + { return; + } for (const PointOnCurveEntry& anEntry : aParams->PointsOnCurve) + { unbindEdgeFromVertex(anEntry.EdgeDefId, theVertex); + } for (const PointOnSurfaceEntry& anEntry : aParams->PointsOnSurface) + { unbindFaceFromVertex(anEntry.FaceDefId, theVertex); + } for (const PointOnPCurveEntry& anEntry : aParams->PointsOnPCurve) + { unbindCoEdgeFromVertex(anEntry.CoEdgeDefId, theVertex); + } myVertexParams.UnBind(theVertex); } @@ -471,11 +547,15 @@ void BRepGraph_LayerParam::invalidateEdgeBindings(const BRepGraph_EdgeId theEdge { const NCollection_DynamicArray* aVertices = myEdgeToVertices.Seek(theEdge); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) + { removePointOnCurve(aVtx, theEdge); + } } //================================================================================================= @@ -484,11 +564,15 @@ void BRepGraph_LayerParam::invalidateFaceBindings(const BRepGraph_FaceId theFace { const NCollection_DynamicArray* aVertices = myFaceToVertices.Seek(theFace); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) + { removePointOnSurface(aVtx, theFace); + } } //================================================================================================= @@ -498,11 +582,15 @@ void BRepGraph_LayerParam::invalidateCoEdgeBindings(const BRepGraph_CoEdgeId the const NCollection_DynamicArray* aVertices = myCoEdgeToVertices.Seek(theCoEdge); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) + { removePointOnPCurve(aVtx, theCoEdge); + } } //================================================================================================= @@ -512,7 +600,9 @@ void BRepGraph_LayerParam::migrateVertexBindings(const BRepGraph_VertexId theOld { const VertexParams* aParams = myVertexParams.Seek(theOldVertex); if (aParams == nullptr) + { return; + } const VertexParams aOldParams = *aParams; removeVertexBindings(theOldVertex); @@ -538,14 +628,18 @@ void BRepGraph_LayerParam::migrateEdgeBindings(const BRepGraph_EdgeId theOldEdge { const NCollection_DynamicArray* aVertices = myEdgeToVertices.Seek(theOldEdge); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) { double aParameter = 0.0; if (!FindPointOnCurve(aVtx, theOldEdge, &aParameter)) + { continue; + } removePointOnCurve(aVtx, theOldEdge); SetPointOnCurve(aVtx, theNewEdge, aParameter); } @@ -558,14 +652,18 @@ void BRepGraph_LayerParam::migrateFaceBindings(const BRepGraph_FaceId theOldFace { const NCollection_DynamicArray* aVertices = myFaceToVertices.Seek(theOldFace); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) { gp_Pnt2d aUV; if (!FindPointOnSurface(aVtx, theOldFace, &aUV)) + { continue; + } removePointOnSurface(aVtx, theOldFace); SetPointOnSurface(aVtx, theNewFace, aUV.X(), aUV.Y()); } @@ -579,14 +677,18 @@ void BRepGraph_LayerParam::migrateCoEdgeBindings(const BRepGraph_CoEdgeId theOld const NCollection_DynamicArray* aVertices = myCoEdgeToVertices.Seek(theOldCoEdge); if (aVertices == nullptr) + { return; + } const NCollection_DynamicArray aBoundVertices = *aVertices; for (const BRepGraph_VertexId& aVtx : aBoundVertices) { double aParameter = 0.0; if (!FindPointOnPCurve(aVtx, theOldCoEdge, &aParameter)) + { continue; + } removePointOnPCurve(aVtx, theOldCoEdge); SetPointOnPCurve(aVtx, theNewCoEdge, aParameter); } @@ -621,7 +723,9 @@ void BRepGraph_LayerParam::OnNodesModified( const NCollection_DynamicArray& theModifiedNodes) noexcept { for (const BRepGraph_NodeId& aModifiedNode : theModifiedNodes) + { OnNodeModified(aModifiedNode); + } } //================================================================================================= @@ -633,21 +737,33 @@ void BRepGraph_LayerParam::OnNodeRemoved(const BRepGraph_NodeId theNode, { case BRepGraph_NodeId::Kind::Vertex: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::Vertex && theReplacement.IsValid()) + { migrateVertexBindings(BRepGraph_VertexId(theNode), BRepGraph_VertexId(theReplacement)); + } else + { removeVertexBindings(BRepGraph_VertexId(theNode)); + } break; case BRepGraph_NodeId::Kind::Edge: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::Edge && theReplacement.IsValid()) + { migrateEdgeBindings(BRepGraph_EdgeId(theNode), BRepGraph_EdgeId(theReplacement)); + } else + { invalidateEdgeBindings(BRepGraph_EdgeId(theNode)); + } break; case BRepGraph_NodeId::Kind::Face: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::Face && theReplacement.IsValid()) + { migrateFaceBindings(BRepGraph_FaceId(theNode), BRepGraph_FaceId(theReplacement)); + } else + { invalidateFaceBindings(BRepGraph_FaceId(theNode)); + } break; case BRepGraph_NodeId::Kind::CoEdge: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::CoEdge && theReplacement.IsValid()) @@ -679,7 +795,9 @@ void BRepGraph_LayerParam::OnCompact( { const BRepGraph_VertexId aNewVertex = remapVertex(theRemapMap, aOldVertex); if (!aNewVertex.IsValid()) + { continue; + } VertexParams aNewVP; @@ -687,7 +805,9 @@ void BRepGraph_LayerParam::OnCompact( { const BRepGraph_EdgeId aNewEdge = remapEdge(theRemapMap, anOldEntry.EdgeDefId); if (!aNewEdge.IsValid()) + { continue; + } PointOnCurveEntry& anEntry = aNewVP.PointsOnCurve.Appended(); anEntry.Parameter = anOldEntry.Parameter; anEntry.EdgeDefId = aNewEdge; @@ -697,7 +817,9 @@ void BRepGraph_LayerParam::OnCompact( { const BRepGraph_FaceId aNewFace = remapFace(theRemapMap, anOldEntry.FaceDefId); if (!aNewFace.IsValid()) + { continue; + } PointOnSurfaceEntry& anEntry = aNewVP.PointsOnSurface.Appended(); anEntry.ParameterU = anOldEntry.ParameterU; anEntry.ParameterV = anOldEntry.ParameterV; @@ -708,7 +830,9 @@ void BRepGraph_LayerParam::OnCompact( { const BRepGraph_CoEdgeId aNewCoEdge = remapCoEdge(theRemapMap, anOldEntry.CoEdgeDefId); if (!aNewCoEdge.IsValid()) + { continue; + } PointOnPCurveEntry& anEntry = aNewVP.PointsOnPCurve.Appended(); anEntry.Parameter = anOldEntry.Parameter; anEntry.CoEdgeDefId = aNewCoEdge; @@ -722,11 +846,17 @@ void BRepGraph_LayerParam::OnCompact( if (anExisting != nullptr) { for (const PointOnCurveEntry& anEntry : aNewVP.PointsOnCurve) + { anExisting->PointsOnCurve.Append(anEntry); + } for (const PointOnSurfaceEntry& anEntry : aNewVP.PointsOnSurface) + { anExisting->PointsOnSurface.Append(anEntry); + } for (const PointOnPCurveEntry& anEntry : aNewVP.PointsOnPCurve) + { anExisting->PointsOnPCurve.Append(anEntry); + } } else { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegistry.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegistry.cxx index 8793cd8345..c705bdbd27 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegistry.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegistry.cxx @@ -20,7 +20,9 @@ int BRepGraph_LayerRegistry::RegisterLayer(const occ::handle& theLayer) { if (theLayer.IsNull()) + { return -1; + } const Standard_GUID& aGUID = theLayer->ID(); const uint32_t* aSlot = myGuidToSlot.Seek(aGUID); @@ -52,7 +54,9 @@ void BRepGraph_LayerRegistry::UnregisterLayer(const Standard_GUID& theGUID) { const uint32_t* aSlotPtr = myGuidToSlot.Seek(theGUID); if (aSlotPtr == nullptr) + { return; + } const uint32_t aSlot = *aSlotPtr; const uint32_t aLastSlot = static_cast(myLayers.Size()) - 1; @@ -81,7 +85,9 @@ void BRepGraph_LayerRegistry::SetOwningGraph(BRepGraph* theGraph) noexcept for (const occ::handle& aLayer : myLayers) { if (!aLayer.IsNull()) + { aLayer->setOwningGraph(theGraph); + } } } @@ -127,13 +133,17 @@ void BRepGraph_LayerRegistry::DispatchOnNodeRemoved(const BRepGraph_NodeId theNo void BRepGraph_LayerRegistry::DispatchNodeModified(const BRepGraph_NodeId theNode) noexcept { if (!HasModificationSubscribers()) + { return; + } const int aKindBit = BRepGraph_Layer::KindBit(theNode.NodeKind); for (const occ::handle& aLayer : myLayers) { if ((aLayer->SubscribedKinds() & aKindBit) != 0) + { aLayer->OnNodeModified(theNode); + } } } @@ -144,12 +154,16 @@ void BRepGraph_LayerRegistry::DispatchNodesModified( const int theModifiedKindsMask) noexcept { if (!HasModificationSubscribers() || theModifiedKindsMask == 0) + { return; + } for (const occ::handle& aLayer : myLayers) { if ((aLayer->SubscribedKinds() & theModifiedKindsMask) != 0) + { aLayer->OnNodesModified(theModifiedNodes); + } } } @@ -199,13 +213,17 @@ void BRepGraph_LayerRegistry::DispatchOnRefRemoved(const BRepGraph_RefId theRef) void BRepGraph_LayerRegistry::DispatchRefModified(const BRepGraph_RefId theRef) noexcept { if (!HasRefModificationSubscribers()) + { return; + } const int aRefKindBit = BRepGraph_Layer::RefKindBit(theRef.RefKind); for (const occ::handle& aLayer : myLayers) { if ((aLayer->SubscribedRefKinds() & aRefKindBit) != 0) + { aLayer->OnRefModified(theRef); + } } } @@ -216,12 +234,16 @@ void BRepGraph_LayerRegistry::DispatchRefsModified( const int theModifiedRefKindsMask) noexcept { if (!HasRefModificationSubscribers() || theModifiedRefKindsMask == 0) + { return; + } for (const occ::handle& aLayer : myLayers) { if ((aLayer->SubscribedRefKinds() & theModifiedRefKindsMask) != 0) + { aLayer->OnRefsModified(theModifiedRefs, theModifiedRefKindsMask); + } } } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegularity.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegularity.cxx index d996daa555..740ee171f3 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegularity.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_LayerRegularity.cxx @@ -39,7 +39,9 @@ void appendUnique( for (const BRepGraph_EdgeId& aEdge : anEdges) { if (aEdge == theEdge) + { return; + } } anEdges.Append(theEdge); } @@ -50,7 +52,9 @@ void removeEdge( const BRepGraph_EdgeId theEdge) noexcept { if (!theMap.IsBound(theFace)) + { return; + } NCollection_DynamicArray& anEdges = theMap.ChangeFind(theFace); uint32_t anIdx = 0; @@ -58,15 +62,21 @@ void removeEdge( anIt.Next(), ++anIdx) { if (anIt.Value() != theEdge) + { continue; + } if (anIdx < static_cast(anEdges.Size()) - 1u) + { anEdges.ChangeValue(static_cast(anIdx)) = anEdges.Value(anEdges.Size() - 1u); + } anEdges.EraseLast(); break; } if (anEdges.IsEmpty()) + { theMap.UnBind(theFace); + } } static BRepGraph_EdgeId remapEdge( @@ -75,7 +85,9 @@ static BRepGraph_EdgeId remapEdge( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theEdge); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::Edge) + { return BRepGraph_EdgeId(); + } return BRepGraph_EdgeId(*aNewId); } @@ -85,7 +97,9 @@ static BRepGraph_FaceId remapFace( { const BRepGraph_NodeId* aNewId = theRemapMap.Seek(theFace); if (aNewId == nullptr || aNewId->NodeKind != BRepGraph_NodeId::Kind::Face) + { return BRepGraph_FaceId(); + } return BRepGraph_FaceId(*aNewId); } @@ -134,7 +148,9 @@ void BRepGraph_LayerRegularity::normalizeFacePair(BRepGraph_FaceId& theFace1, BRepGraph_FaceId& theFace2) const noexcept { if (theFace2 < theFace1) + { std::swap(theFace1, theFace2); + } } //================================================================================================= @@ -150,14 +166,20 @@ bool BRepGraph_LayerRegularity::FindContinuity(const BRepGraph_EdgeId theEdge, const EdgeRegularities* aRegularities = FindEdgeRegularities(theEdge); if (aRegularities == nullptr) + { return false; + } for (const RegularityEntry& anEntry : aRegularities->Entries) { if (anEntry.FaceEntity1 != aFace1 || anEntry.FaceEntity2 != aFace2) + { continue; + } if (theContinuity != nullptr) + { *theContinuity = anEntry.Continuity; + } return true; } return false; @@ -177,13 +199,17 @@ GeomAbs_Shape BRepGraph_LayerRegularity::MaxContinuity(const BRepGraph_EdgeId th { const EdgeRegularities* aRegularities = FindEdgeRegularities(theEdge); if (aRegularities == nullptr) + { return GeomAbs_C0; + } GeomAbs_Shape aMaxContinuity = GeomAbs_C0; for (const RegularityEntry& anEntry : aRegularities->Entries) { if (anEntry.Continuity > aMaxContinuity) + { aMaxContinuity = anEntry.Continuity; + } } return aMaxContinuity; } @@ -194,7 +220,9 @@ BRepGraph_LayerRegularity::EdgeRegularities& BRepGraph_LayerRegularity::changeEd const BRepGraph_EdgeId theEdge) { if (!myEdgeRegularities.IsBound(theEdge)) + { myEdgeRegularities.Bind(theEdge, EdgeRegularities()); + } return myEdgeRegularities.ChangeFind(theEdge); } @@ -230,7 +258,9 @@ void BRepGraph_LayerRegularity::SetRegularity(const BRepGraph_EdgeId theEdge, anIt.Next()) { if (anIt.Value().FaceEntity1 != aFace1 || anIt.Value().FaceEntity2 != aFace2) + { continue; + } anIt.ChangeValue().Continuity = theContinuity; return; } @@ -250,7 +280,9 @@ void BRepGraph_LayerRegularity::removeRegularity(const BRepGraph_EdgeId theEdge, const BRepGraph_FaceId theFace2) noexcept { if (!myEdgeRegularities.IsBound(theEdge)) + { return; + } BRepGraph_FaceId aFace1 = theFace1; BRepGraph_FaceId aFace2 = theFace2; @@ -263,17 +295,23 @@ void BRepGraph_LayerRegularity::removeRegularity(const BRepGraph_EdgeId theEdge, anIt.Next(), ++anIdx) { if (anIt.Value().FaceEntity1 != aFace1 || anIt.Value().FaceEntity2 != aFace2) + { continue; + } if (anIdx < static_cast(aRegularities.Entries.Size()) - 1u) + { aRegularities.Entries.ChangeValue(static_cast(anIdx)) = aRegularities.Entries.Value(aRegularities.Entries.Size() - 1u); + } aRegularities.Entries.EraseLast(); aFound = true; break; } if (!aFound) + { return; + } // Only unbind a face if no remaining entry still references it on this edge. bool aFace1StillReferenced = false; @@ -281,17 +319,27 @@ void BRepGraph_LayerRegularity::removeRegularity(const BRepGraph_EdgeId theEdge, for (const RegularityEntry& anEntry : aRegularities.Entries) { if (anEntry.FaceEntity1 == aFace1 || anEntry.FaceEntity2 == aFace1) + { aFace1StillReferenced = true; + } if (anEntry.FaceEntity1 == aFace2 || anEntry.FaceEntity2 == aFace2) + { aFace2StillReferenced = true; + } } if (!aFace1StillReferenced) + { unbindFaceFromEdge(aFace1, theEdge); + } if (!aFace2StillReferenced) + { unbindFaceFromEdge(aFace2, theEdge); + } if (aRegularities.IsEmpty()) + { myEdgeRegularities.UnBind(theEdge); + } } //================================================================================================= @@ -300,7 +348,9 @@ void BRepGraph_LayerRegularity::removeEdgeBindings(const BRepGraph_EdgeId theEdg { const EdgeRegularities* aRegularities = myEdgeRegularities.Seek(theEdge); if (aRegularities == nullptr) + { return; + } for (const RegularityEntry& anEntry : aRegularities->Entries) { @@ -316,19 +366,25 @@ void BRepGraph_LayerRegularity::invalidateFaceBindings(const BRepGraph_FaceId th { const NCollection_DynamicArray* anEdges = myFaceToEdges.Seek(theFace); if (anEdges == nullptr) + { return; + } const NCollection_DynamicArray aBoundEdges = *anEdges; for (const BRepGraph_EdgeId& aEdgeId : aBoundEdges) { const EdgeRegularities* aRegularities = myEdgeRegularities.Seek(aEdgeId); if (aRegularities == nullptr) + { continue; + } const EdgeRegularities aEntries = *aRegularities; for (const RegularityEntry& anEntry : aEntries.Entries) { if (anEntry.FaceEntity1 == theFace || anEntry.FaceEntity2 == theFace) + { removeRegularity(aEdgeId, anEntry.FaceEntity1, anEntry.FaceEntity2); + } } } } @@ -340,7 +396,9 @@ void BRepGraph_LayerRegularity::migrateEdgeBindings(const BRepGraph_EdgeId theOl { const EdgeRegularities* aRegularities = myEdgeRegularities.Seek(theOldEdge); if (aRegularities == nullptr) + { return; + } const EdgeRegularities anOldRegularities = *aRegularities; removeEdgeBindings(theOldEdge); @@ -357,19 +415,25 @@ void BRepGraph_LayerRegularity::migrateFaceBindings(const BRepGraph_FaceId theOl { const NCollection_DynamicArray* anEdges = myFaceToEdges.Seek(theOldFace); if (anEdges == nullptr) + { return; + } const NCollection_DynamicArray aBoundEdges = *anEdges; for (const BRepGraph_EdgeId& aEdgeId : aBoundEdges) { const EdgeRegularities* aRegularities = myEdgeRegularities.Seek(aEdgeId); if (aRegularities == nullptr) + { continue; + } const EdgeRegularities aEntries = *aRegularities; for (const RegularityEntry& anEntry : aEntries.Entries) { if (anEntry.FaceEntity1 != theOldFace && anEntry.FaceEntity2 != theOldFace) + { continue; + } removeRegularity(aEdgeId, anEntry.FaceEntity1, anEntry.FaceEntity2); const BRepGraph_FaceId aFace1 = anEntry.FaceEntity1 == theOldFace ? theNewFace : anEntry.FaceEntity1; @@ -403,7 +467,9 @@ void BRepGraph_LayerRegularity::OnNodesModified( const NCollection_DynamicArray& theModifiedNodes) noexcept { for (const BRepGraph_NodeId& aModifiedNode : theModifiedNodes) + { OnNodeModified(aModifiedNode); + } } //================================================================================================= @@ -415,15 +481,23 @@ void BRepGraph_LayerRegularity::OnNodeRemoved(const BRepGraph_NodeId theNode, { case BRepGraph_NodeId::Kind::Edge: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::Edge && theReplacement.IsValid()) + { migrateEdgeBindings(BRepGraph_EdgeId(theNode), BRepGraph_EdgeId(theReplacement)); + } else + { removeEdgeBindings(BRepGraph_EdgeId(theNode)); + } break; case BRepGraph_NodeId::Kind::Face: if (theReplacement.NodeKind == BRepGraph_NodeId::Kind::Face && theReplacement.IsValid()) + { migrateFaceBindings(BRepGraph_FaceId(theNode), BRepGraph_FaceId(theReplacement)); + } else + { invalidateFaceBindings(BRepGraph_FaceId(theNode)); + } break; default: break; @@ -442,18 +516,26 @@ void BRepGraph_LayerRegularity::OnCompact( { const BRepGraph_EdgeId aNewEdge = remapEdge(theRemapMap, aOldEdge); if (!aNewEdge.IsValid()) + { continue; + } for (const RegularityEntry& anOldEntry : aOldRegularities.Entries) { BRepGraph_FaceId aNewFace1 = remapFace(theRemapMap, anOldEntry.FaceEntity1); BRepGraph_FaceId aNewFace2 = remapFace(theRemapMap, anOldEntry.FaceEntity2); if (!aNewFace1.IsValid() || !aNewFace2.IsValid()) + { continue; + } if (aNewFace2 < aNewFace1) + { std::swap(aNewFace1, aNewFace2); + } if (!aNewEdgeRegs.IsBound(aNewEdge)) + { aNewEdgeRegs.Bind(aNewEdge, EdgeRegularities()); + } EdgeRegularities& aRegularities = aNewEdgeRegs.ChangeFind(aNewEdge); // Deduplicate: if same face pair already exists for this edge, update continuity. @@ -470,7 +552,9 @@ void BRepGraph_LayerRegularity::OnCompact( } } if (aDuplicate) + { continue; + } RegularityEntry& anEntry = aRegularities.Entries.Appended(); anEntry.FaceEntity1 = aNewFace1; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshCache.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshCache.cxx index a1089e2b2b..eb6be50eb0 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshCache.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshCache.cxx @@ -30,7 +30,9 @@ void BRepGraph_MeshCacheStorage::ensureSize(NCollection_DynamicArray& theVec, bool BRepGraph_MeshCacheStorage::HasFaceMesh(const BRepGraph_FaceId theFace) const { if (!theFace.IsValidIn(myFaceMeshes)) + { return false; + } return myFaceMeshes.Value(static_cast(theFace.Index)).IsPresent(); } @@ -40,11 +42,15 @@ const BRepGraph_MeshCache::FaceMeshEntry* BRepGraph_MeshCacheStorage::FindFaceMe const BRepGraph_FaceId theFace) const { if (!theFace.IsValidIn(myFaceMeshes)) + { return nullptr; + } const BRepGraph_MeshCache::FaceMeshEntry& anEntry = myFaceMeshes.Value(static_cast(theFace.Index)); if (!anEntry.IsPresent()) + { return nullptr; + } return &anEntry; } @@ -72,7 +78,9 @@ void BRepGraph_MeshCacheStorage::ClearFaceMesh(const BRepGraph_FaceId theFace) bool BRepGraph_MeshCacheStorage::HasCoEdgeMesh(const BRepGraph_CoEdgeId theCoEdge) const { if (!theCoEdge.IsValidIn(myCoEdgeMeshes)) + { return false; + } return myCoEdgeMeshes.Value(static_cast(theCoEdge.Index)).IsPresent(); } @@ -82,11 +90,15 @@ const BRepGraph_MeshCache::CoEdgeMeshEntry* BRepGraph_MeshCacheStorage::FindCoEd const BRepGraph_CoEdgeId theCoEdge) const { if (!theCoEdge.IsValidIn(myCoEdgeMeshes)) + { return nullptr; + } const BRepGraph_MeshCache::CoEdgeMeshEntry& anEntry = myCoEdgeMeshes.Value(static_cast(theCoEdge.Index)); if (!anEntry.IsPresent()) + { return nullptr; + } return &anEntry; } @@ -114,7 +126,9 @@ void BRepGraph_MeshCacheStorage::ClearCoEdgeMesh(const BRepGraph_CoEdgeId theCoE bool BRepGraph_MeshCacheStorage::HasEdgeMesh(const BRepGraph_EdgeId theEdge) const { if (!theEdge.IsValidIn(myEdgeMeshes)) + { return false; + } return myEdgeMeshes.Value(static_cast(theEdge.Index)).IsPresent(); } @@ -124,11 +138,15 @@ const BRepGraph_MeshCache::EdgeMeshEntry* BRepGraph_MeshCacheStorage::FindEdgeMe const BRepGraph_EdgeId theEdge) const { if (!theEdge.IsValidIn(myEdgeMeshes)) + { return nullptr; + } const BRepGraph_MeshCache::EdgeMeshEntry& anEntry = myEdgeMeshes.Value(static_cast(theEdge.Index)); if (!anEntry.IsPresent()) + { return nullptr; + } return &anEntry; } @@ -175,14 +193,20 @@ void BRepGraph_MeshCacheStorage::OnCompact( const BRepGraph_NodeId& anOldId = anIter.Key(); const BRepGraph_NodeId& aNewId = anIter.Value(); if (anOldId.NodeKind != BRepGraph_NodeId::Kind::Face) + { continue; + } const BRepGraph_FaceId anOldFaceId(anOldId); if (!anOldFaceId.IsValidIn(myFaceMeshes)) + { continue; + } const BRepGraph_MeshCache::FaceMeshEntry& anOldEntry = myFaceMeshes.Value(static_cast(anOldFaceId.Index)); if (!anOldEntry.IsPresent()) + { continue; + } ensureSize(aNewFaces, static_cast(aNewId.Index)); aNewFaces.ChangeValue(static_cast(aNewId.Index)) = anOldEntry; } @@ -199,14 +223,20 @@ void BRepGraph_MeshCacheStorage::OnCompact( const BRepGraph_NodeId& anOldId = anIter.Key(); const BRepGraph_NodeId& aNewId = anIter.Value(); if (anOldId.NodeKind != BRepGraph_NodeId::Kind::CoEdge) + { continue; + } const BRepGraph_CoEdgeId anOldCoEdgeId(anOldId); if (!anOldCoEdgeId.IsValidIn(myCoEdgeMeshes)) + { continue; + } const BRepGraph_MeshCache::CoEdgeMeshEntry& anOldEntry = myCoEdgeMeshes.Value(static_cast(anOldCoEdgeId.Index)); if (!anOldEntry.IsPresent()) + { continue; + } ensureSize(aNewCoEdges, static_cast(aNewId.Index)); aNewCoEdges.ChangeValue(static_cast(aNewId.Index)) = anOldEntry; } @@ -223,14 +253,20 @@ void BRepGraph_MeshCacheStorage::OnCompact( const BRepGraph_NodeId& anOldId = anIter.Key(); const BRepGraph_NodeId& aNewId = anIter.Value(); if (anOldId.NodeKind != BRepGraph_NodeId::Kind::Edge) + { continue; + } const BRepGraph_EdgeId anOldEdgeId(anOldId); if (!anOldEdgeId.IsValidIn(myEdgeMeshes)) + { continue; + } const BRepGraph_MeshCache::EdgeMeshEntry& anOldEntry = myEdgeMeshes.Value(static_cast(anOldEdgeId.Index)); if (!anOldEntry.IsPresent()) + { continue; + } ensureSize(aNewEdges, static_cast(aNewId.Index)); aNewEdges.ChangeValue(static_cast(aNewId.Index)) = anOldEntry; } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshView.cxx index 08fd1b76b9..89be1d1a21 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_MeshView.cxx @@ -25,7 +25,9 @@ bool BRepGraph::MeshView::FaceOps::isFresh(const BRepGraph_FaceId theFace, { const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theFace.IsValid(aStorage.NbFaces())) + { return false; + } return theStoredGen == aStorage.Face(theFace).OwnGen; } @@ -39,12 +41,16 @@ bool BRepGraph::MeshView::FaceOps::HasTriangulation(const BRepGraph_FaceId theFa { const BRepGraph_TriangulationRepId aRepId = aCached->ActiveTriangulationRepId(); if (aRepId.IsValid()) + { return true; + } } // Fallback to persistent mesh in definition. const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theFace.IsValid(aStorage.NbFaces())) + { return false; + } const BRepGraph_TriangulationRepId aRepId = aStorage.Face(theFace).TriangulationRepId; return aRepId.IsValid(aStorage.NbTriangulations()) && !aStorage.TriangulationRep(aRepId).IsRemoved; @@ -71,10 +77,14 @@ BRepGraph_TriangulationRepId BRepGraph::MeshView::FaceOps::ActiveTriangulationRe // Fallback to persistent. if (!theFace.IsValid(aStorage.NbFaces())) + { return BRepGraph_TriangulationRepId(); + } const BRepGraph_TriangulationRepId aRepId = aStorage.Face(theFace).TriangulationRepId; if (!aRepId.IsValid(aStorage.NbTriangulations()) || aStorage.TriangulationRep(aRepId).IsRemoved) + { return BRepGraph_TriangulationRepId(); + } return aRepId; } @@ -86,7 +96,9 @@ const BRepGraph_MeshCache::FaceMeshEntry* BRepGraph::MeshView::FaceOps::CachedMe const BRepGraph_MeshCache::FaceMeshEntry* aCached = myGraph->myData->myMeshCache.FindFaceMesh(theFace); if (aCached != nullptr && isFresh(theFace, aCached->StoredOwnGen)) + { return aCached; + } return nullptr; } @@ -99,7 +111,9 @@ bool BRepGraph::MeshView::EdgeOps::isFresh(const BRepGraph_EdgeId theEdge, { const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theEdge.IsValid(aStorage.NbEdges())) + { return false; + } return theStoredGen == aStorage.Edge(theEdge).OwnGen; } @@ -112,12 +126,16 @@ bool BRepGraph::MeshView::EdgeOps::HasPolygon3D(const BRepGraph_EdgeId theEdge) if (aCached != nullptr && isFresh(theEdge, aCached->StoredOwnGen)) { if (aCached->Polygon3DRepId.IsValid()) + { return true; + } } // Fallback to persistent. const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theEdge.IsValid(aStorage.NbEdges())) + { return false; + } const BRepGraph_Polygon3DRepId aRepId = aStorage.Edge(theEdge).Polygon3DRepId; return aRepId.IsValid(aStorage.NbPolygons3D()) && !aStorage.Polygon3DRep(aRepId).IsRemoved; } @@ -143,10 +161,14 @@ BRepGraph_Polygon3DRepId BRepGraph::MeshView::EdgeOps::Polygon3DRepId( // Fallback to persistent. if (!theEdge.IsValid(aStorage.NbEdges())) + { return BRepGraph_Polygon3DRepId(); + } const BRepGraph_Polygon3DRepId aRepId = aStorage.Edge(theEdge).Polygon3DRepId; if (!aRepId.IsValid(aStorage.NbPolygons3D()) || aStorage.Polygon3DRep(aRepId).IsRemoved) + { return BRepGraph_Polygon3DRepId(); + } return aRepId; } @@ -158,7 +180,9 @@ const BRepGraph_MeshCache::EdgeMeshEntry* BRepGraph::MeshView::EdgeOps::CachedMe const BRepGraph_MeshCache::EdgeMeshEntry* aCached = myGraph->myData->myMeshCache.FindEdgeMesh(theEdge); if (aCached != nullptr && isFresh(theEdge, aCached->StoredOwnGen)) + { return aCached; + } return nullptr; } @@ -171,7 +195,9 @@ bool BRepGraph::MeshView::CoEdgeOps::isFresh(const BRepGraph_CoEdgeId theCoEdge, { const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theCoEdge.IsValid(aStorage.NbCoEdges())) + { return false; + } return theStoredGen == aStorage.CoEdge(theCoEdge).OwnGen; } @@ -182,7 +208,9 @@ bool BRepGraph::MeshView::CoEdgeOps::HasMesh(const BRepGraph_CoEdgeId theCoEdge) const BRepGraph_MeshCache::CoEdgeMeshEntry* aCached = myGraph->myData->myMeshCache.FindCoEdgeMesh(theCoEdge); if (aCached != nullptr && isFresh(theCoEdge, aCached->StoredOwnGen)) + { return true; + } return false; } @@ -194,7 +222,9 @@ const BRepGraph_MeshCache::CoEdgeMeshEntry* BRepGraph::MeshView::CoEdgeOps::Cach const BRepGraph_MeshCache::CoEdgeMeshEntry* aCached = myGraph->myData->myMeshCache.FindCoEdgeMesh(theCoEdge); if (aCached != nullptr && isFresh(theCoEdge, aCached->StoredOwnGen)) + { return aCached; + } return nullptr; } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ParentExplorer.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ParentExplorer.cxx index 8e7640fdb9..d8d6736618 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ParentExplorer.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ParentExplorer.cxx @@ -1122,7 +1122,9 @@ int BRepGraph_ParentExplorer::findSolidChildStep(const BRepGraph_SolidId thePare for (const BRepGraph_ChildRefId& aRefId : aSolid.AuxChildRefIds) { if (!aRefs.IsRemoved(aRefId) && aRefs.ChildNode(aRefId) == theChild) + { return aSolid.ShellRefIds.Length() + static_cast(aRefIdx); + } ++aRefIdx; } } @@ -1156,7 +1158,9 @@ int BRepGraph_ParentExplorer::findShellChildStep(const BRepGraph_ShellId thePare for (const BRepGraph_ChildRefId& aRefId : aShell.AuxChildRefIds) { if (!aRefs.IsRemoved(aRefId) && aRefs.ChildNode(aRefId) == theChild) + { return aShell.FaceRefIds.Length() + static_cast(aRefIdx); + } ++aRefIdx; } } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefsView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefsView.cxx index 0d12b777c7..6e8d6ebc07 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefsView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefsView.cxx @@ -200,7 +200,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::FaceOp { static const NCollection_DynamicArray anEmpty; if (!theShell.IsValid(myGraph->myData->myIncStorage.NbShells())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Shell(theShell).FaceRefIds; } @@ -211,7 +213,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::WireOp { static const NCollection_DynamicArray anEmpty; if (!theFace.IsValid(myGraph->myData->myIncStorage.NbFaces())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Face(theFace).WireRefIds; } @@ -222,7 +226,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::CoEd { static const NCollection_DynamicArray anEmpty; if (!theWire.IsValid(myGraph->myData->myIncStorage.NbWires())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Wire(theWire).CoEdgeRefIds; } @@ -233,7 +239,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::Shell { static const NCollection_DynamicArray anEmpty; if (!theSolid.IsValid(myGraph->myData->myIncStorage.NbSolids())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Solid(theSolid).ShellRefIds; } @@ -244,7 +252,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::Child { static const NCollection_DynamicArray anEmpty; if (!theCompound.IsValid(myGraph->myData->myIncStorage.NbCompounds())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Compound(theCompound).ChildRefIds; } @@ -255,7 +265,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView:: { static const NCollection_DynamicArray anEmpty; if (!theProduct.IsValid(myGraph->myData->myIncStorage.NbProducts())) + { return anEmpty; + } return myGraph->myData->myIncStorage.Product(theProduct).OccurrenceRefIds; } @@ -492,7 +504,9 @@ const NCollection_DynamicArray& BRepGraph::RefsView::Solid { static const NCollection_DynamicArray anEmpty; if (!theCompSolid.IsValid(myGraph->myData->myIncStorage.NbCompSolids())) + { return anEmpty; + } return myGraph->myData->myIncStorage.CompSolid(theCompSolid).SolidRefIds; } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.cxx index 879d083f07..38cb7ad69b 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.cxx @@ -49,11 +49,15 @@ static TopoDS_Shape reconstructOccurrenceLocal(BRepGraph_ReconstructionContext& { const BRepGraphInc_Storage& aStorage = *theContext.Storage; if (!theOccurrence.IsValid(aStorage.NbOccurrences())) + { return TopoDS_Shape(); + } const BRepGraphInc::OccurrenceDef& anOccurrence = aStorage.Occurrence(theOccurrence); if (anOccurrence.IsRemoved || !anOccurrence.ChildDefId.IsValid()) + { return TopoDS_Shape(); + } TopoDS_Shape aShape; if (anOccurrence.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Product) @@ -72,7 +76,9 @@ static TopoDS_Shape reconstructOccurrenceLocal(BRepGraph_ReconstructionContext& theContext.Regularities); } if (!aShape.IsNull() && !theLocalLocation.IsIdentity()) + { aShape.Move(theLocalLocation); + } return aShape; } @@ -84,18 +90,24 @@ static TopoDS_Shape reconstructProductLocal(BRepGraph_ReconstructionContext& the (void)theParentOccurrence; // Reserved for future parent-occurrence filtering. const BRepGraphInc_Storage& aStorage = *theContext.Storage; if (!theProduct.IsValid(aStorage.NbProducts())) + { return TopoDS_Shape(); + } const BRepGraph_NodeId aProductNode = theProduct; if (!theFilterByParentOccurrence) { if (const TopoDS_Shape* aCached = theContext.Cache.Seek(aProductNode)) + { return *aCached; + } } const BRepGraphInc::ProductDef& aProduct = aStorage.Product(theProduct); if (aProduct.IsRemoved || theContext.ActiveProducts.Contains(theProduct)) + { return TopoDS_Shape(); + } theContext.ActiveProducts.Add(theProduct); @@ -123,7 +135,9 @@ static TopoDS_Shape reconstructProductLocal(BRepGraph_ReconstructionContext& the theContext.Params, theContext.Regularities); if (!aResult.IsNull() && !aRootLocation.IsIdentity()) + { aResult.Move(aRootLocation); + } } else { @@ -152,7 +166,9 @@ static TopoDS_Shape reconstructProductLocal(BRepGraph_ReconstructionContext& the anOccurrenceRef.OccurrenceDefId, anOccurrenceRef.LocalLocation); if (!aChild.IsNull()) + { aBuilder.Add(aCompound, aChild); + } } aResult = aCompound; @@ -160,7 +176,9 @@ static TopoDS_Shape reconstructProductLocal(BRepGraph_ReconstructionContext& the theContext.ActiveProducts.Remove(theProduct); if (!theFilterByParentOccurrence && !aResult.IsNull()) + { theContext.Cache.Bind(aProductNode, aResult); + } return aResult; } @@ -168,7 +186,9 @@ static TopoDS_Shape reconstructShape(BRepGraph_ReconstructionContext& theContext const BRepGraph_NodeId theNode) { if (!theNode.IsValid()) + { return TopoDS_Shape(); + } const BRepGraphInc_Storage& aStorage = *theContext.Storage; switch (theNode.NodeKind) @@ -178,11 +198,15 @@ static TopoDS_Shape reconstructShape(BRepGraph_ReconstructionContext& theContext case BRepGraph_NodeId::Kind::Occurrence: { const BRepGraph_OccurrenceId anOccurrence(theNode); if (!anOccurrence.IsValid(aStorage.NbOccurrences())) + { return TopoDS_Shape(); + } const BRepGraphInc::OccurrenceDef& anOccurrenceDef = aStorage.Occurrence(anOccurrence); if (anOccurrenceDef.IsRemoved || !anOccurrenceDef.ChildDefId.IsValid()) + { return TopoDS_Shape(); + } TopoDS_Shape aShape; if (anOccurrenceDef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Product) @@ -205,7 +229,9 @@ static TopoDS_Shape reconstructShape(BRepGraph_ReconstructionContext& theContext const TopLoc_Location aGlobalLocation = theContext.Graph->Topo().Occurrences().OccurrenceLocation(anOccurrence); if (!aGlobalLocation.IsIdentity()) + { aShape.Move(aGlobalLocation); + } } return aShape; } @@ -241,17 +267,23 @@ static BRepGraph_ReconstructionContext makeReconstructionContext( TopoDS_Shape BRepGraph::ShapesView::Shape(const BRepGraph_NodeId theNode) const { if (!theNode.IsValid()) + { return TopoDS_Shape(); + } // Fast path: if entity was never mutated, return the original shape. const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theNode); if (aDef != nullptr && aDef->IsRemoved) + { return TopoDS_Shape(); + } if (aDef != nullptr && aDef->SubtreeGen == 0) { const TopoDS_Shape* anOrig = FindOriginal(theNode); if (anOrig != nullptr) + { return *anOrig; + } } // Check mutable cache under shared lock with SubtreeGen validation. @@ -259,7 +291,9 @@ TopoDS_Shape BRepGraph::ShapesView::Shape(const BRepGraph_NodeId theNode) const std::shared_lock aReadLock(myGraph->myData->myCurrentShapesMutex); const BRepGraph_Data::CachedShape* aCached = myGraph->myData->myCurrentShapes.Seek(theNode); if (aCached != nullptr && aDef != nullptr && aCached->StoredSubtreeGen == aDef->SubtreeGen) + { return aCached->Shape; + } } // Reconstruct from incidence storage / assembly facade. @@ -302,11 +336,15 @@ bool BRepGraph::ShapesView::HasOriginal(const BRepGraph_NodeId theNode) const const TopoDS_Shape* BRepGraph::ShapesView::FindOriginal(const BRepGraph_NodeId theNode) const { if (!theNode.IsValid()) + { return nullptr; + } const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theNode); if (aDef != nullptr && aDef->IsRemoved) + { return nullptr; + } return myGraph->myData->myIncStorage.FindOriginal(theNode); } @@ -317,7 +355,9 @@ const TopoDS_Shape& BRepGraph::ShapesView::OriginalOf(const BRepGraph_NodeId the { const TopoDS_Shape* aShape = FindOriginal(theNode); if (aShape == nullptr) + { throw Standard_ProgramError("BRepGraph::ShapesView::OriginalOf() - no original shape."); + } return *aShape; } @@ -327,7 +367,9 @@ TopoDS_Shape BRepGraph::ShapesView::Reconstruct(const BRepGraph_NodeId theRoot) { const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theRoot); if (aDef != nullptr && aDef->IsRemoved) + { return TopoDS_Shape(); + } BRepGraph_ReconstructionContext aContext = makeReconstructionContext(myGraph, myGraph->myData->myIncStorage); return reconstructShape(aContext, theRoot); @@ -340,7 +382,9 @@ TopoDS_Shape BRepGraph::ShapesView::Reconstruct(const BRepGraph_NodeId theRoot) BRepGraph_NodeId BRepGraph::ShapesView::FindNode(const TopoDS_Shape& theShape) const { if (theShape.IsNull()) + { return BRepGraph_NodeId(); + } const BRepGraph_NodeId* aNodeId = myGraph->myData->myIncStorage.FindNodeByTShape(theShape.TShape().get()); @@ -348,7 +392,9 @@ BRepGraph_NodeId BRepGraph::ShapesView::FindNode(const TopoDS_Shape& theShape) c { const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(*aNodeId); if (aDef == nullptr || aDef->IsRemoved) + { return BRepGraph_NodeId(); + } return *aNodeId; } return BRepGraph_NodeId(); @@ -359,7 +405,9 @@ BRepGraph_NodeId BRepGraph::ShapesView::FindNode(const TopoDS_Shape& theShape) c bool BRepGraph::ShapesView::HasNode(const TopoDS_Shape& theShape) const { if (theShape.IsNull()) + { return false; + } return FindNode(theShape).IsValid(); } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Tool.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Tool.cxx index 370b5830ca..079ee48810 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Tool.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Tool.cxx @@ -38,7 +38,9 @@ gp_Pnt BRepGraph_Tool::Vertex::Pnt(const BRepGraph& theGraph, { const gp_Pnt& aPnt = theGraph.Topo().Vertices().Definition(theRef.DefId).Point; if (theRef.Location.IsIdentity()) + { return aPnt; + } return aPnt.Transformed(theRef.Location.Transformation()); } @@ -67,7 +69,9 @@ double BRepGraph_Tool::Vertex::Parameter(const BRepGraph& theGraph, const occ::handle aParamLayer = theGraph.LayerRegistry().FindLayer(); if (!aParamLayer.IsNull() && aParamLayer->FindPointOnCurve(theVertex, theEdge, &aParameter)) + { return aParameter; + } throw Standard_NoSuchObject("BRepGraph_Tool::Parameter - no PointOnCurve for this edge"); } @@ -81,7 +85,9 @@ gp_Pnt2d BRepGraph_Tool::Vertex::Parameters(const BRepGraph& theGraph, const occ::handle aParamLayer = theGraph.LayerRegistry().FindLayer(); if (!aParamLayer.IsNull() && aParamLayer->FindPointOnSurface(theVertex, theFace, &aUV)) + { return aUV; + } throw Standard_NoSuchObject("BRepGraph_Tool::Parameters - no PointOnSurface for this face"); } @@ -180,7 +186,9 @@ BRepGraph_VertexId BRepGraph_Tool::Edge::StartVertexId(const BRepGraph& th { const BRepGraph_VertexRefId aRefId = theGraph.Topo().Edges().Definition(theEdge).StartVertexRefId; if (!aRefId.IsValid()) + { return BRepGraph_VertexId(); + } return theGraph.Refs().Vertices().Entry(aRefId).VertexDefId; } @@ -191,7 +199,9 @@ BRepGraph_VertexId BRepGraph_Tool::Edge::EndVertexId(const BRepGraph& theG { const BRepGraph_VertexRefId aRefId = theGraph.Topo().Edges().Definition(theEdge).EndVertexRefId; if (!aRefId.IsValid()) + { return BRepGraph_VertexId(); + } return theGraph.Refs().Vertices().Entry(aRefId).VertexDefId; } @@ -211,10 +221,14 @@ GeomAdaptor_TransformedCurve BRepGraph_Tool::Edge::CurveAdaptor( const BRepGraphInc::Curve3DRep& aCurveRep = theGraph.Topo().Geometry().Curve3DRep(anEdge.Curve3DRepId); if (aCurveRep.IsRemoved) + { return GeomAdaptor_TransformedCurve(); + } const occ::handle& aCurve = aCurveRep.Curve; if (!aCurve.IsNull()) + { return GeomAdaptor_TransformedCurve(aCurve, anEdge.ParamFirst, anEdge.ParamLast, aTrsf); + } } // Fallback: CurveOnSurface from PCurve + surface. @@ -229,7 +243,9 @@ GeomAdaptor_TransformedCurve BRepGraph_Tool::Edge::CurveAdaptor( const BRepGraphInc::SurfaceRep& aSurfaceRep = theGraph.Topo().Geometry().SurfaceRep(aFace.SurfaceRepId); if (aPCurveRep.IsRemoved || aSurfaceRep.IsRemoved) + { return GeomAdaptor_TransformedCurve(); + } const occ::handle& aPCurve = aPCurveRep.Curve; const occ::handle& aSurf = aSurfaceRep.Surface; if (!aPCurve.IsNull() && !aSurf.IsNull()) @@ -255,14 +271,20 @@ GeomAdaptor_TransformedCurve BRepGraph_Tool::Edge::CurveAdaptor(const BRepGraph& { const BRepGraphInc::EdgeDef& anEdge = theGraph.Topo().Edges().Definition(theEdge); if (!anEdge.Curve3DRepId.IsValid()) + { return GeomAdaptor_TransformedCurve(); + } const BRepGraphInc::Curve3DRep& aCurveRep = theGraph.Topo().Geometry().Curve3DRep(anEdge.Curve3DRepId); if (aCurveRep.IsRemoved) + { return GeomAdaptor_TransformedCurve(); + } const occ::handle& aCurve = aCurveRep.Curve; if (aCurve.IsNull()) + { return GeomAdaptor_TransformedCurve(); + } return GeomAdaptor_TransformedCurve(aCurve, anEdge.ParamFirst, anEdge.ParamLast, gp_Trsf()); } @@ -275,7 +297,9 @@ const occ::handle& BRepGraph_Tool::Edge::Curve(const BRepGraph& { const BRepGraph_Curve3DRepId aRepId = theGraph.Topo().Edges().Curve3DRepId(theEdge); if (!aRepId.IsValid()) + { return THE_NULL_CURVE; + } return theGraph.Topo().Geometry().Curve3DRep(aRepId).Curve; } @@ -287,14 +311,20 @@ occ::handle BRepGraph_Tool::Edge::Curve(const BRepGraph& const BRepGraphInc::CoEdgeDef& aCoEdge = theGraph.Topo().CoEdges().Definition(theRef.DefId); const BRepGraphInc::EdgeDef& anEdge = theGraph.Topo().Edges().Definition(aCoEdge.EdgeDefId); if (!anEdge.Curve3DRepId.IsValid()) + { return occ::handle(); + } const BRepGraphInc::Curve3DRep& aCurveRep = theGraph.Topo().Geometry().Curve3DRep(anEdge.Curve3DRepId); if (aCurveRep.IsRemoved) + { return occ::handle(); + } const occ::handle& aCurve = aCurveRep.Curve; if (aCurve.IsNull() || theRef.Location.IsIdentity()) + { return aCurve; + } return occ::down_cast(aCurve->Transformed(theRef.Location.Transformation())); } @@ -308,7 +338,9 @@ const occ::handle& BRepGraph_Tool::Edge::Polygon3D(const BRepGra // Cache-first, persistent fallback via MeshCacheOps. const BRepGraph_Polygon3DRepId aRepId = theGraph.Mesh().Edges().Polygon3DRepId(theEdge); if (!aRepId.IsValid()) + { return THE_NULL_POLYGON3D; + } return theGraph.Mesh().Poly().Polygon3DRep(aRepId).Polygon; } @@ -322,7 +354,9 @@ double BRepGraph_Tool::Vertex::PCurveParameter(const BRepGraph& theGraph const occ::handle aParamLayer = theGraph.LayerRegistry().FindLayer(); if (!aParamLayer.IsNull() && aParamLayer->FindPointOnPCurve(theVertex, theCoEdge, &aParameter)) + { return aParameter; + } throw Standard_NoSuchObject("BRepGraph_Tool::PCurveParameter - no PointOnPCurve for this coedge"); } @@ -359,7 +393,9 @@ GeomAbs_Shape BRepGraph_Tool::Edge::Continuity(const BRepGraph& theGraph, theGraph.LayerRegistry().FindLayer(); if (!aRegularityLayer.IsNull() && aRegularityLayer->FindContinuity(theEdge, theFace1, theFace2, &aContinuity)) + { return aContinuity; + } return GeomAbs_C0; } @@ -508,7 +544,9 @@ const occ::handle& BRepGraph_Tool::CoEdge::PCurve(const BRepGraph& { const BRepGraph_Curve2DRepId aRepId = theGraph.Topo().CoEdges().Curve2DRepId(theCoEdge); if (!aRepId.IsValid()) + { return THE_NULL_PCURVE; + } return theGraph.Topo().Geometry().Curve2DRep(aRepId).Curve; } @@ -519,11 +557,15 @@ const occ::handle& BRepGraph_Tool::CoEdge::PCurve( const BRepGraphInc::CoEdgeDef& theCoEdge) { if (!theCoEdge.Curve2DRepId.IsValid()) + { return THE_NULL_PCURVE; + } const BRepGraphInc::Curve2DRep& aCurveRep = theGraph.Topo().Geometry().Curve2DRep(theCoEdge.Curve2DRepId); if (aCurveRep.IsRemoved) + { return THE_NULL_PCURVE; + } return aCurveRep.Curve; } @@ -592,11 +634,15 @@ const occ::handle& BRepGraph_Tool::CoEdge::PolygonOnSurface( { const BRepGraphInc::CoEdgeDef& aCoEdge = theGraph.Topo().CoEdges().Definition(theCoEdge); if (!aCoEdge.Polygon2DRepId.IsValid()) + { return THE_NULL_POLYGON2D; + } const BRepGraphInc::Polygon2DRep& aPolygonRep = theGraph.Mesh().Poly().Polygon2DRep(aCoEdge.Polygon2DRepId); if (aPolygonRep.IsRemoved) + { return THE_NULL_POLYGON2D; + } return aPolygonRep.Polygon; } @@ -651,7 +697,9 @@ const BRepGraphInc::WireRef* BRepGraph_Tool::Face::OuterWire(const BRepGraph& { const BRepGraphInc::WireRef& aRef = aRefs.Wires().Entry(aWireIt.CurrentId()); if (!aRef.IsRemoved && aRef.IsOuter) + { return &aRef; + } } return nullptr; } @@ -663,7 +711,9 @@ BRepGraph_WireId BRepGraph_Tool::Face::OuterWireId(const BRepGraph& theGra { const BRepGraphInc::WireRef* aOuter = OuterWire(theGraph, theFace); if (aOuter == nullptr) + { return BRepGraph_WireId(); + } return aOuter->WireDefId; } @@ -676,7 +726,9 @@ const occ::handle& BRepGraph_Tool::Face::Surface(const BRepGraph& { const BRepGraph_SurfaceRepId aRepId = theGraph.Topo().Faces().SurfaceRepId(theFace); if (!aRepId.IsValid()) + { return THE_NULL_SURFACE; + } return theGraph.Topo().Geometry().SurfaceRep(aRepId).Surface; } @@ -687,10 +739,14 @@ GeomAdaptor_TransformedSurface BRepGraph_Tool::Face::SurfaceAdaptor(const BRepGr { const BRepGraph_SurfaceRepId aRepId = theGraph.Topo().Faces().SurfaceRepId(theFace); if (!aRepId.IsValid()) + { return GeomAdaptor_TransformedSurface(); + } const occ::handle& aSurf = theGraph.Topo().Geometry().SurfaceRep(aRepId).Surface; if (aSurf.IsNull()) + { return GeomAdaptor_TransformedSurface(); + } return GeomAdaptor_TransformedSurface(aSurf, gp_Trsf()); } @@ -705,10 +761,14 @@ GeomAdaptor_TransformedSurface BRepGraph_Tool::Face::SurfaceAdaptor(const BRepGr { const BRepGraph_SurfaceRepId aRepId = theGraph.Topo().Faces().SurfaceRepId(theFace); if (!aRepId.IsValid()) + { return GeomAdaptor_TransformedSurface(); + } const occ::handle& aSurf = theGraph.Topo().Geometry().SurfaceRep(aRepId).Surface; if (aSurf.IsNull()) + { return GeomAdaptor_TransformedSurface(); + } return GeomAdaptor_TransformedSurface(aSurf, theUFirst, theULast, theVFirst, theVLast, gp_Trsf()); } @@ -724,7 +784,9 @@ const occ::handle& BRepGraph_Tool::Face::Triangulation( const BRepGraph_TriangulationRepId aTriRepId = theGraph.Mesh().Faces().ActiveTriangulationRepId(theFace); if (!aTriRepId.IsValid()) + { return THE_NULL_TRIANGULATION; + } return theGraph.Mesh().Poly().TriangulationRep(aTriRepId).Triangulation; } @@ -747,7 +809,9 @@ void BRepGraph_Tool::Face::Bounds(const BRepGraph& theGraph, theUMin = theUMax = theVMin = theVMax = 0.0; const occ::handle& aSurf = Surface(theGraph, theFace); if (!aSurf.IsNull()) + { aSurf->Bounds(theUMin, theUMax, theVMin, theVMax); + } } //================================================================================================= @@ -761,19 +825,25 @@ occ::handle BRepGraph_Tool::Edge::CurveOnSurface( const BRepGraphInc::FaceDef& aFace = theGraph.Topo().Faces().Definition(theFace); if (!aCoEdge.Curve2DRepId.IsValid() || !aFace.SurfaceRepId.IsValid()) + { return occ::handle(); + } const BRepGraphInc::Curve2DRep& aPCurveRep = theGraph.Topo().Geometry().Curve2DRep(aCoEdge.Curve2DRepId); const BRepGraphInc::SurfaceRep& aSurfaceRep = theGraph.Topo().Geometry().SurfaceRep(aFace.SurfaceRepId); if (aPCurveRep.IsRemoved || aSurfaceRep.IsRemoved) + { return occ::handle(); + } const occ::handle& aPCurve = aPCurveRep.Curve; const occ::handle& aSurf = aSurfaceRep.Surface; if (aPCurve.IsNull() || aSurf.IsNull()) + { return occ::handle(); + } occ::handle aHC2d = new Geom2dAdaptor_Curve(aPCurve, aCoEdge.ParamFirst, aCoEdge.ParamLast); @@ -802,7 +872,9 @@ BRepGraph_FaceId BRepGraph_Tool::Wire::FaceOf(const BRepGraph& theGraph, { const NCollection_DynamicArray& aFaces = theGraph.Topo().Wires().Faces(theWire); if (aFaces.IsEmpty()) + { return BRepGraph_FaceId(); + } return aFaces.First(); } @@ -814,13 +886,17 @@ bool BRepGraph_Tool::Wire::IsOuter(const BRepGraph& theGraph, const BRepGraph_Wi for (const BRepGraph_FaceId& aFaceId : aFaces) { if (!aFaceId.IsValid()) + { continue; + } const BRepGraph::RefsView& aRefs = theGraph.Refs(); for (BRepGraph_RefsWireOfFace aWireIt(theGraph, aFaceId); aWireIt.More(); aWireIt.Next()) { const BRepGraphInc::WireRef& aRef = aRefs.Wires().Entry(aWireIt.CurrentId()); if (!aRef.IsRemoved && aRef.WireDefId == theWire) + { return aRef.IsOuter; + } } } return false; @@ -849,7 +925,9 @@ BRepGraph_TriangulationRepId BRepGraph_Tool::Mesh::CreateTriangulationRep( const occ::handle& theTriangulation) { if (theTriangulation.IsNull()) + { return BRepGraph_TriangulationRepId(); + } const BRepGraph_TriangulationRepId aRepId = theGraph.data()->myIncStorage.AppendTriangulationRep(); @@ -864,7 +942,9 @@ BRepGraph_Polygon3DRepId BRepGraph_Tool::Mesh::CreatePolygon3DRep( const occ::handle& thePolygon) { if (thePolygon.IsNull()) + { return BRepGraph_Polygon3DRepId(); + } const BRepGraph_Polygon3DRepId aRepId = theGraph.data()->myIncStorage.AppendPolygon3DRep(); theGraph.data()->myIncStorage.ChangePolygon3DRep(aRepId).Polygon = thePolygon; @@ -879,7 +959,9 @@ BRepGraph_PolygonOnTriRepId BRepGraph_Tool::Mesh::CreatePolygonOnTriRep( const BRepGraph_TriangulationRepId theTriRepId) { if (thePolygon.IsNull() || !theTriRepId.IsValid()) + { return BRepGraph_PolygonOnTriRepId(); + } const BRepGraph_PolygonOnTriRepId aRepId = theGraph.data()->myIncStorage.AppendPolygonOnTriRep(); BRepGraphInc::PolygonOnTriRep& aRep = theGraph.data()->myIncStorage.ChangePolygonOnTriRep(aRepId); @@ -896,7 +978,9 @@ void BRepGraph_Tool::Mesh::AppendCachedTriangulation(BRepGraph& { const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theFace.IsValid(aStorage.NbFaces()) || !theTriRepId.IsValid()) + { return; + } BRepGraph_MeshCache::FaceMeshEntry& anEntry = theGraph.data()->myMeshCache.ChangeFaceMesh(theFace); anEntry.TriangulationRepIds.Append(theTriRepId); @@ -911,7 +995,9 @@ void BRepGraph_Tool::Mesh::SetCachedActiveIndex(BRepGraph& theGraph, { const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theFace.IsValid(aStorage.NbFaces())) + { return; + } BRepGraph_MeshCache::FaceMeshEntry& anEntry = theGraph.data()->myMeshCache.ChangeFaceMesh(theFace); anEntry.ActiveTriangulationIndex = theActiveIndex; @@ -927,20 +1013,28 @@ void BRepGraph_Tool::Mesh::ClearFaceCache(BRepGraph& theGraph, const BRepGraph_F const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theFace.IsValid(aStorage.NbFaces())) + { return; + } const BRepGraphInc::FaceDef& aFace = aStorage.Face(theFace); for (const BRepGraph_WireRefId& aWireRefId : aFace.WireRefIds) { if (!aWireRefId.IsValid(aStorage.NbWireRefs())) + { continue; + } const BRepGraph_WireId aWireId = aStorage.WireRef(aWireRefId).WireDefId; if (!aWireId.IsValid(aStorage.NbWires())) + { continue; + } const BRepGraphInc::WireDef& aWire = aStorage.Wire(aWireId); for (const BRepGraph_CoEdgeRefId& aCERefId : aWire.CoEdgeRefIds) { if (!aCERefId.IsValid(aStorage.NbCoEdgeRefs())) + { continue; + } const BRepGraph_CoEdgeId aCoEdgeId = aStorage.CoEdgeRef(aCERefId).CoEdgeDefId; aMeshCache.ClearCoEdgeMesh(aCoEdgeId); } @@ -955,7 +1049,9 @@ void BRepGraph_Tool::Mesh::SetCachedPolygon3D(BRepGraph& the { const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theEdge.IsValid(aStorage.NbEdges())) + { return; + } BRepGraph_MeshCache::EdgeMeshEntry& anEntry = theGraph.data()->myMeshCache.ChangeEdgeMesh(theEdge); anEntry.Polygon3DRepId = thePolyRepId; @@ -977,7 +1073,9 @@ void BRepGraph_Tool::Mesh::AppendCachedPolygonOnTri(BRepGraph& { const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theCoEdge.IsValid(aStorage.NbCoEdges()) || !thePolyRepId.IsValid()) + { return; + } BRepGraph_MeshCache::CoEdgeMeshEntry& anEntry = theGraph.data()->myMeshCache.ChangeCoEdgeMesh(theCoEdge); anEntry.PolygonOnTriRepIds.Append(thePolyRepId); @@ -992,7 +1090,9 @@ void BRepGraph_Tool::Mesh::SetCachedPolygon2D(BRepGraph& the { const BRepGraphInc_Storage& aStorage = theGraph.data()->myIncStorage; if (!theCoEdge.IsValid(aStorage.NbCoEdges())) + { return; + } BRepGraph_MeshCache::CoEdgeMeshEntry& anEntry = theGraph.data()->myMeshCache.ChangeCoEdgeMesh(theCoEdge); anEntry.Polygon2DRepId = thePolyRepId; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TopoView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TopoView.cxx index d6360df764..7666ceb6a9 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TopoView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TopoView.cxx @@ -45,7 +45,9 @@ NCollection_DynamicArray collectFaceEdges( NCollection_DynamicArray aResult(THE_TOPOVIEW_FACE_EDGE_BLOCK_SIZE, theAllocator); if (!theFace.IsValid(theGraph.Topo().Faces().Nb())) + { return aResult; + } NCollection_Map anEdgeSet; for (BRepGraph_DefsWireOfFace aWireIt(theGraph, theFace); aWireIt.More(); aWireIt.Next()) @@ -936,13 +938,19 @@ BRepGraph_NodeId BRepGraph::TopoView::ProductOps::ShapeRoot( { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOccDef = aStorage.Occurrence(aRef.OccurrenceDefId); if (anOccDef.IsRemoved) + { continue; + } if (!anOccDef.ChildDefId.IsValid() || BRepGraph_NodeId::IsAssemblyKind(anOccDef.ChildDefId.NodeKind)) + { continue; + } const BRepGraphInc::BaseDef* aRoot = myGraph->Topo().Gen().TopoEntity(anOccDef.ChildDefId); if (aRoot != nullptr && !aRoot->IsRemoved) @@ -972,10 +980,14 @@ bool BRepGraph::TopoView::ProductOps::IsAssembly(const BRepGraph_ProductId thePr { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOccDef = aStorage.Occurrence(aRef.OccurrenceDefId); if (anOccDef.IsRemoved) + { continue; + } if (anOccDef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Product) { return true; @@ -1005,10 +1017,14 @@ bool BRepGraph::TopoView::ProductOps::IsPart(const BRepGraph_ProductId theProduc { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOccDef = aStorage.Occurrence(aRef.OccurrenceDefId); if (anOccDef.IsRemoved) + { continue; + } if (anOccDef.ChildDefId.IsValid() && !BRepGraph_NodeId::IsAssemblyKind(anOccDef.ChildDefId.NodeKind)) { @@ -1040,10 +1056,14 @@ BRepGraph_NodeId BRepGraph::TopoView::ProductOps::ShapeRootNode( { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraphInc::OccurrenceDef& anOccDef = aStorage.Occurrence(aRef.OccurrenceDefId); if (anOccDef.IsRemoved) + { continue; + } if (anOccDef.ChildDefId.IsValid() && !BRepGraph_NodeId::IsAssemblyKind(anOccDef.ChildDefId.NodeKind)) { @@ -1190,10 +1210,14 @@ BRepGraph_ProductId BRepGraph::TopoView::OccurrenceOps::ParentProduct( { const BRepGraphInc::OccurrenceRef& aRef = aStorage.OccurrenceRef(aRefId); if (aRef.IsRemoved || aRef.OccurrenceDefId != theOccurrence) + { continue; + } if (aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Product) + { return BRepGraph_ProductId(); + } const BRepGraph_ProductId aParentProduct = BRepGraph_ProductId::FromNodeId(aRef.ParentId); if (!aParentProduct.IsValid(aStorage.NbProducts()) @@ -1213,7 +1237,9 @@ TopLoc_Location BRepGraph::TopoView::OccurrenceOps::OccurrenceLocation( { const BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!theOccurrence.IsValid(aStorage.NbOccurrences())) + { return TopLoc_Location(); + } // Placement is now on OccurrenceRef::LocalLocation. // Find the OccurrenceRef that owns this OccurrenceDef. @@ -1317,6 +1343,8 @@ bool BRepGraph::TopoView::GenOps::IsRemoved(const BRepGraph_NodeId theNode) cons { const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theNode); if (aDef == nullptr) + { return false; + } return aDef->IsRemoved; } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx index 6c5c05dd8e..bce22b3be3 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx @@ -113,7 +113,9 @@ void transformPolygon3D(const occ::handle& thePoly, const gp_Trs thePoly->Deflection(thePoly->Deflection() * std::abs(theTrsf.ScaleFactor())); NCollection_Array1& aNodes = thePoly->ChangeNodes(); for (int i = aNodes.Lower(); i <= aNodes.Upper(); ++i) + { aNodes.ChangeValue(i).Transform(theTrsf); + } } //! Copy mesh representations from theSource into theDest, optionally transforming them. @@ -172,7 +174,9 @@ void applyMeshCopy(const BRepGraph& theSource, if (aSrcEntry != nullptr && aSrcEntry->IsPresent()) { for (int i = 0; i < aSrcEntry->TriangulationRepIds.Length(); ++i) + { aSrcLODs.Append(aSrcEntry->TriangulationRepIds.Value(i)); + } aSrcActiveIdx = aSrcEntry->ActiveTriangulationIndex; } } @@ -183,14 +187,20 @@ void applyMeshCopy(const BRepGraph& theSource, auto copyOneTri = [&](const BRepGraph_TriangulationRepId aSrcRepId) -> BRepGraph_TriangulationRepId { if (!aSrcRepId.IsValid(aSrcPoly.NbTriangulations())) + { return BRepGraph_TriangulationRepId(); + } if (const BRepGraph_TriangulationRepId* aExisting = aTriRepMap.Seek(aSrcRepId.Index)) + { return *aExisting; + } const occ::handle& aSrcTri = aSrcPoly.TriangulationRep(aSrcRepId).Triangulation; if (aSrcTri.IsNull()) + { return BRepGraph_TriangulationRepId(); + } occ::handle aNewTri = aSrcTri->Copy(); if (theDoTransform) @@ -215,10 +225,14 @@ void applyMeshCopy(const BRepGraph& theSource, { const BRepGraph_TriangulationRepId aNewRepId = copyOneTri(aSrcLODs.Value(i)); if (aNewRepId.IsValid()) + { BRepGraph_Tool::Mesh::AppendCachedTriangulation(theDest, aFaceId, aNewRepId); + } } if (aSrcActiveIdx >= 0) + { BRepGraph_Tool::Mesh::SetCachedActiveIndex(theDest, aFaceId, aSrcActiveIdx); + } } // -- Polygon3D (edges) -- @@ -230,19 +244,27 @@ void applyMeshCopy(const BRepGraph& theSource, const BRepGraph_MeshCache::EdgeMeshEntry* aSrcEdge = theSource.Mesh().Edges().CachedMesh(anEdgeId); if (aSrcEdge == nullptr || !aSrcEdge->IsPresent()) + { continue; + } const BRepGraph_Polygon3DRepId aSrcPolyRepId = aSrcEdge->Polygon3DRepId; if (!aSrcPolyRepId.IsValid(aSrcPoly.NbPolygons3D())) + { continue; + } const occ::handle& aSrcPoly3D = aSrcPoly.Polygon3DRep(aSrcPolyRepId).Polygon; if (aSrcPoly3D.IsNull()) + { continue; + } occ::handle aNewPoly3D = aSrcPoly3D->Copy(); if (theDoTransform) + { transformPolygon3D(aNewPoly3D, theTrsf); + } const BRepGraph_Polygon3DRepId aNewRepId = BRepGraph_Tool::Mesh::CreatePolygon3DRep(theDest, aNewPoly3D); @@ -257,27 +279,37 @@ void applyMeshCopy(const BRepGraph& theSource, const BRepGraph_MeshCache::CoEdgeMeshEntry* aSrcCoEdge = theSource.Mesh().CoEdges().CachedMesh(aCoEdgeId); if (aSrcCoEdge == nullptr || !aSrcCoEdge->IsPresent()) + { continue; + } for (int i = 0; i < aSrcCoEdge->PolygonOnTriRepIds.Length(); ++i) { const BRepGraph_PolygonOnTriRepId aSrcRepId = aSrcCoEdge->PolygonOnTriRepIds.Value(i); if (!aSrcRepId.IsValid(aSrcPoly.NbPolygonsOnTri())) + { continue; + } const BRepGraphInc::PolygonOnTriRep& aSrcRep = aSrcPoly.PolygonOnTriRep(aSrcRepId); if (aSrcRep.Polygon.IsNull()) + { continue; + } occ::handle aNewPoly = aSrcRep.Polygon->Copy(); if (theDoTransform) + { aNewPoly->Deflection(aNewPoly->Deflection() * std::abs(theTrsf.ScaleFactor())); + } // Remap triangulation reference to the newly created dest rep. BRepGraph_TriangulationRepId aNewTriRepId; if (const BRepGraph_TriangulationRepId* aFound = aTriRepMap.Seek(aSrcRep.TriangulationRepId.Index)) + { aNewTriRepId = *aFound; + } const BRepGraph_PolygonOnTriRepId aNewRepId = BRepGraph_Tool::Mesh::CreatePolygonOnTriRep(theDest, aNewPoly, aNewTriRepId); @@ -353,12 +385,16 @@ void applyGeometryTransform(const BRepGraph& theSource, } } if (!theCopyMesh) + { BRepGraph_Tool::Mesh::ClearEdgeCache(theGraph, anEdgeId); + } } // PCurves are in UV space - they are not affected by 3D transforms. if (theCopyMesh) + { applyMeshCopy(theSource, theGraph, theTrsf, true, thePolySource, theSourceCache); + } } } // namespace @@ -377,7 +413,9 @@ void BRepGraph_Transform::applyLocationTransform(BRepGraph& theGraph, const gp_T { const BRepGraphInc::OccurrenceRef& aOccRef = theGraph.Refs().Occurrences().Entry(aRefId); if (aOccRef.IsRemoved) + { continue; + } BRepGraph_MutGuard aMutRef = theGraph.Editor().Occurrences().MutRef(aRefId); theGraph.Editor().Occurrences().SetRefLocalLocation(aMutRef, aLoc * aMutRef->LocalLocation); @@ -393,7 +431,9 @@ BRepGraph BRepGraph_Transform::Perform(const BRepGraph& theGraph, const bool theCopyMesh) { if (!theGraph.IsDone()) + { return BRepGraph(); + } // Determine if we need geometry-level modification (like BRepBuilderAPI_Transform). const bool useGeomModif = @@ -405,7 +445,9 @@ BRepGraph BRepGraph_Transform::Perform(const BRepGraph& theGraph, // Geometry-level: deep-copy then transform geometry handles in-place. BRepGraph aResult = BRepGraph_Copy::Perform(theGraph, true); if (!aResult.IsDone()) + { return aResult; + } applyGeometryTransform(theGraph, aResult, theTrsf, theCopyMesh); return aResult; @@ -415,11 +457,15 @@ BRepGraph BRepGraph_Transform::Perform(const BRepGraph& theGraph, // Matches BRepBuilderAPI_Transform with theCopyGeom=false (shape.Moved(trsf)). BRepGraph aResult = BRepGraph_Copy::Perform(theGraph, false); if (!aResult.IsDone()) + { return aResult; + } applyLocationTransform(aResult, theTrsf); if (theCopyMesh) + { applyMeshCopy(theGraph, aResult, theTrsf, false); + } return aResult; } @@ -432,7 +478,9 @@ BRepGraph BRepGraph_Transform::TransformNode(const BRepGraph& theGraph, const bool theCopyMesh) { if (!theGraph.IsDone()) + { return BRepGraph(); + } const bool useGeomModif = theCopyGeom || theTrsf.IsNegative() @@ -457,7 +505,9 @@ BRepGraph BRepGraph_Transform::TransformNode(const BRepGraph& theGraph, BRepGraph aSubgraph = BRepGraph_Copy::CopyNode(theGraph, theNodeId, theCopyGeom, theCopyMesh, THE_RESERVE_CACHE); if (!aSubgraph.IsDone()) + { return aSubgraph; + } if (useGeomModif) { @@ -471,7 +521,9 @@ BRepGraph BRepGraph_Transform::TransformNode(const BRepGraph& theGraph, { applyLocationTransform(aSubgraph, theTrsf); if (theCopyMesh) + { applyMeshCopy(theGraph, aSubgraph, theTrsf, false); + } } return aSubgraph; } @@ -483,7 +535,9 @@ bool BRepGraph_Transform::MoveRef(BRepGraph& theGraph, const gp_Trsf& theTrsf) { if (std::abs(std::abs(theTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec()) + { return false; + } const TopLoc_Location aLoc = TopLoc_Location(theTrsf); BRepGraph::EditorView& anEditor = theGraph.Editor(); diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.cxx index 9bb39316f9..4b517460ed 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.cxx @@ -124,16 +124,22 @@ void ensureRefUIDReverseIndex(BRepGraph_Data& theData) BRepGraph_UID BRepGraph::UIDsView::Of(const BRepGraph_NodeId theNode) const { if (!theNode.IsValid()) + { return BRepGraph_UID(); + } const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theNode); if (aDef == nullptr || aDef->IsRemoved) + { return BRepGraph_UID(); + } const NCollection_DynamicArray& aVec = myGraph->myData->myIncStorage.UIDs(theNode.NodeKind); if (!theNode.IsValidIn(aVec)) + { return BRepGraph_UID(); + } return aVec.Value(static_cast(theNode.Index)); } @@ -142,16 +148,22 @@ BRepGraph_UID BRepGraph::UIDsView::Of(const BRepGraph_NodeId theNode) const BRepGraph_RefUID BRepGraph::UIDsView::Of(const BRepGraph_RefId theRefId) const { if (!theRefId.IsValid()) + { return BRepGraph_RefUID(); + } const NCollection_DynamicArray& aVec = myGraph->myData->myIncStorage.RefUIDs(theRefId.RefKind); if (!theRefId.IsValidIn(aVec)) + { return BRepGraph_RefUID(); + } const BRepGraphInc::BaseRef& aBase = myGraph->myData->myIncStorage.BaseRef(theRefId); if (aBase.IsRemoved) + { return BRepGraph_RefUID(); + } return aVec.Value(static_cast(theRefId.Index)); } @@ -161,9 +173,13 @@ BRepGraph_RefUID BRepGraph::UIDsView::Of(const BRepGraph_RefId theRefId) const BRepGraph_NodeId BRepGraph::UIDsView::NodeIdFrom(const BRepGraph_UID& theUID) const { if (!theUID.IsValid()) + { return BRepGraph_NodeId(); + } if (theUID.Generation() != myGraph->myData->myGeneration.load()) + { return BRepGraph_NodeId(); + } BRepGraph_Data& aData = *myGraph->myData; ensureUIDReverseIndex(aData); @@ -171,11 +187,15 @@ BRepGraph_NodeId BRepGraph::UIDsView::NodeIdFrom(const BRepGraph_UID& theUID) co std::shared_lock aReadLock(aData.myUIDToNodeIdMutex); const BRepGraph_NodeId* aNodeId = aData.myUIDToNodeId.Seek(theUID); if (aNodeId == nullptr) + { return BRepGraph_NodeId(); + } const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(*aNodeId); if (aDef == nullptr || aDef->IsRemoved) + { return BRepGraph_NodeId(); + } return *aNodeId; } @@ -185,9 +205,13 @@ BRepGraph_NodeId BRepGraph::UIDsView::NodeIdFrom(const BRepGraph_UID& theUID) co BRepGraph_RefId BRepGraph::UIDsView::RefIdFrom(const BRepGraph_RefUID& theUID) const { if (!theUID.IsValid()) + { return BRepGraph_RefId(); + } if (theUID.Generation() != myGraph->myData->myGeneration.load()) + { return BRepGraph_RefId(); + } BRepGraph_Data& aData = *myGraph->myData; ensureRefUIDReverseIndex(aData); @@ -195,11 +219,15 @@ BRepGraph_RefId BRepGraph::UIDsView::RefIdFrom(const BRepGraph_RefUID& theUID) c std::shared_lock aReadLock(aData.myRefUIDToRefIdMutex); const BRepGraph_RefId* aRefId = aData.myRefUIDToRefId.Seek(theUID); if (aRefId == nullptr) + { return BRepGraph_RefId(); + } const BRepGraphInc::BaseRef& aBase = myGraph->myData->myIncStorage.BaseRef(*aRefId); if (aBase.IsRemoved) + { return BRepGraph_RefId(); + } return *aRefId; } @@ -237,17 +265,23 @@ const Standard_GUID& BRepGraph::UIDsView::GraphGUID() const BRepGraph_VersionStamp BRepGraph::UIDsView::StampOf(const BRepGraph_NodeId theNode) const { if (!theNode.IsValid()) + { return BRepGraph_VersionStamp(); + } const NCollection_DynamicArray& aVec = myGraph->myData->myIncStorage.UIDs(theNode.NodeKind); if (!theNode.IsValidIn(aVec)) + { return BRepGraph_VersionStamp(); + } const BRepGraph_UID aUID = aVec.Value(static_cast(theNode.Index)); const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(theNode); if (aDef == nullptr || aDef->IsRemoved) + { return BRepGraph_VersionStamp(); + } return BRepGraph_VersionStamp(aUID, aDef->OwnGen, myGraph->myData->myGeneration.load()); } @@ -257,16 +291,22 @@ BRepGraph_VersionStamp BRepGraph::UIDsView::StampOf(const BRepGraph_NodeId theNo BRepGraph_VersionStamp BRepGraph::UIDsView::StampOf(const BRepGraph_RefId theRefId) const { if (!theRefId.IsValid()) + { return BRepGraph_VersionStamp(); + } const NCollection_DynamicArray& aUIDs = myGraph->myData->myIncStorage.RefUIDs(theRefId.RefKind); if (!theRefId.IsValidIn(aUIDs)) + { return BRepGraph_VersionStamp(); + } const BRepGraphInc::BaseRef& aBase = myGraph->myData->myIncStorage.BaseRef(theRefId); if (aBase.IsRemoved) + { return BRepGraph_VersionStamp(); + } return BRepGraph_VersionStamp(aUIDs.Value(static_cast(theRefId.Index)), aBase.OwnGen, @@ -278,20 +318,28 @@ BRepGraph_VersionStamp BRepGraph::UIDsView::StampOf(const BRepGraph_RefId theRef bool BRepGraph::UIDsView::IsStale(const BRepGraph_VersionStamp& theStamp) const { if (!theStamp.IsValid()) + { return true; + } if (theStamp.myGeneration != myGraph->myData->myGeneration.load()) + { return true; + } if (theStamp.IsEntityStamp()) { const BRepGraph_NodeId aNodeId = NodeIdFrom(theStamp.myUID); if (!aNodeId.IsValid()) + { return true; + } const BRepGraphInc::BaseDef* aDef = myGraph->topoEntity(aNodeId); if (aDef == nullptr || aDef->IsRemoved) + { return true; + } return aDef->OwnGen != theStamp.myMutationGen; } @@ -300,11 +348,15 @@ bool BRepGraph::UIDsView::IsStale(const BRepGraph_VersionStamp& theStamp) const { const BRepGraph_RefId aRefId = RefIdFrom(theStamp.myRefUID); if (!aRefId.IsValid()) + { return true; + } const BRepGraphInc::BaseRef& aRef = myGraph->myData->myIncStorage.BaseRef(aRefId); if (aRef.IsRemoved) + { return true; + } return aRef.OwnGen != theStamp.myMutationGen; } diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Validate.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Validate.cxx index b6310f99f8..ae2470e064 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Validate.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Validate.cxx @@ -37,7 +37,9 @@ namespace bool isValidNodeId(const BRepGraph& theGraph, const BRepGraph_NodeId theId) { if (!theId.IsValid()) + { return false; + } switch (theId.NodeKind) { @@ -356,10 +358,14 @@ void checkReverseIndexConsistency(const BRepGraph& const BRepGraphInc::CoEdgeDef& aCoEdge = theGraph.Topo().CoEdges().Definition(aCR.CoEdgeDefId); if (!aCoEdge.EdgeDefId.IsValid()) + { continue; + } if (!anExpected.IsBound(aCoEdge.EdgeDefId)) + { anExpected.Bind(aCoEdge.EdgeDefId, NCollection_Map()); + } anExpected.ChangeFind(aCoEdge.EdgeDefId).Add(aWireId); } } @@ -379,7 +385,9 @@ void checkReverseIndexConsistency(const BRepGraph& // Build a set from actual wires for comparison. NCollection_Map anActualSet; for (const BRepGraph_WireId& aWireId : aActualWires) + { anActualSet.Add(aWireId); + } if (anActualSet.Extent() != anExpectedCount) { @@ -753,7 +761,9 @@ void checkWireConnectivity(const BRepGraph& BRepGraph_WireExplorer anExp(theGraph, aWireId); if (anExp.NbEdges() < 2) + { continue; + } // Validate all edge indices first. bool aAllValid = true; @@ -769,7 +779,9 @@ void checkWireConnectivity(const BRepGraph& } } if (!aAllValid) + { continue; + } // Check that all consecutive pairs in the ordered sequence are connected. anExp.Reset(); @@ -1021,10 +1033,14 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraphInc::OccurrenceDef& anOcc = aDefs.Occurrences().Definition(anOccRef.OccurrenceDefId); if (anOcc.IsRemoved || anOcc.ChildDefId.NodeKind != BRepGraph_NodeId::Kind::Product) + { continue; + } const BRepGraph_ProductId aChildProdId = BRepGraph_ProductId::FromNodeId(anOcc.ChildDefId); if (!aChildProdId.IsValid(aDefs.Products().Nb())) + { continue; + } if (aChildProdId == aProdId) { aResult.Issues.Append( @@ -1034,7 +1050,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph break; } if (aVisited.Add(aChildProdId)) + { aQueue.Append(aChildProdId); + } } bool aCycleFound = false; @@ -1044,7 +1062,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph ++aHead; const BRepGraphInc::ProductDef& aChildProd = aDefs.Products().Definition(aChildProdId); if (aChildProd.IsRemoved) + { continue; + } for (BRepGraph_RefsOccurrenceOfProduct aRefIt(theGraph, aChildProdId); aRefIt.More(); aRefIt.Next()) { @@ -1053,10 +1073,14 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraphInc::OccurrenceDef& aOcc = aDefs.Occurrences().Definition(aRef.OccurrenceDefId); if (aOcc.IsRemoved || aOcc.ChildDefId.NodeKind != BRepGraph_NodeId::Kind::Product) + { continue; + } const BRepGraph_ProductId aDescProdId = BRepGraph_ProductId::FromNodeId(aOcc.ChildDefId); if (!aDescProdId.IsValid(aDefs.Products().Nb())) + { continue; + } if (aDescProdId == aProdId) { aResult.Issues.Append( @@ -1067,7 +1091,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph break; } if (aVisited.Add(aDescProdId)) + { aQueue.Append(aDescProdId); + } } } } @@ -1088,11 +1114,15 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraphInc::ChildRef& aCR = theGraph.Refs().Children().Entry(anIt.CurrentId()); if (aCR.IsRemoved || aCR.ChildDefId.NodeKind != BRepGraph_NodeId::Kind::Compound || !aCR.ChildDefId.IsValid()) + { continue; + } const BRepGraph_CompoundId aChildCompoundId = BRepGraph_CompoundId::FromNodeId(aCR.ChildDefId); if (!aChildCompoundId.IsValidIn(aDefs.Compounds())) + { continue; + } if (aChildCompoundId == aRootCompoundId) { aResult.Issues.Append( @@ -1102,7 +1132,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph break; } if (aVisited.Add(aChildCompoundId)) + { aQueue.Append(aChildCompoundId); + } } bool aCycleFound = false; @@ -1111,18 +1143,24 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_CompoundId aChildCompoundId = aQueue.Value(aHead); ++aHead; if (aDefs.Compounds().Definition(aChildCompoundId).IsRemoved) + { continue; + } for (BRepGraph_RefsChildOfCompound aRefIt(theGraph, aChildCompoundId); aRefIt.More(); aRefIt.Next()) { const BRepGraphInc::ChildRef& aCR = theGraph.Refs().Children().Entry(aRefIt.CurrentId()); if (aCR.IsRemoved || aCR.ChildDefId.NodeKind != BRepGraph_NodeId::Kind::Compound || !aCR.ChildDefId.IsValid()) + { continue; + } const BRepGraph_CompoundId aDescCompoundId = BRepGraph_CompoundId::FromNodeId(aCR.ChildDefId); if (!aDescCompoundId.IsValidIn(aDefs.Compounds())) + { continue; + } if (aDescCompoundId == aRootCompoundId) { aResult.Issues.Append( @@ -1133,7 +1171,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph break; } if (aVisited.Add(aDescCompoundId)) + { aQueue.Append(aDescCompoundId); + } } } } @@ -1149,7 +1189,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_ChildRefId aChildRefId = aChildRefIt.CurrentId(); const BRepGraphInc::ChildRef& aCR = aRefs.Children().Entry(aChildRefId); if (aCR.IsRemoved) + { continue; + } const BRepGraph_NodeId aParentId = aCR.ParentId; if (!aParentId.IsValid() || aParentId.NodeKind != BRepGraph_NodeId::Kind::Compound || !BRepGraph_CompoundId(aParentId).IsValidIn(aDefs.Compounds()) @@ -1168,7 +1210,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_SolidRefId aSolidRefId = aSolidRefIt.CurrentId(); const BRepGraphInc::SolidRef& aSR = aRefs.Solids().Entry(aSolidRefId); if (aSR.IsRemoved) + { continue; + } if (!aSR.ParentId.IsValid()) { aResult.Issues.Append( @@ -1195,7 +1239,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_ShellRefId aShellRefId = aShellRefIt.CurrentId(); const BRepGraphInc::ShellRef& aRef = aRefs.Shells().Entry(aShellRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Solid || !BRepGraph_SolidId(aP).IsValidIn(aDefs.Solids()) @@ -1212,7 +1258,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_FaceRefId aFaceRefId = aFaceRefIt.CurrentId(); const BRepGraphInc::FaceRef& aRef = aRefs.Faces().Entry(aFaceRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Shell || !BRepGraph_ShellId(aP).IsValidIn(aDefs.Shells()) @@ -1229,7 +1277,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_WireRefId aWireRefId = aWireRefIt.CurrentId(); const BRepGraphInc::WireRef& aRef = aRefs.Wires().Entry(aWireRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Face || !BRepGraph_FaceId(aP).IsValidIn(aDefs.Faces()) @@ -1247,7 +1297,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_CoEdgeRefId aCoEdgeRefId = aCoEdgeRefIt.CurrentId(); const BRepGraphInc::CoEdgeRef& aRef = aRefs.CoEdges().Entry(aCoEdgeRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Wire || !BRepGraph_WireId(aP).IsValidIn(aDefs.Wires()) @@ -1265,7 +1317,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_VertexRefId aVertexRefId = aVertexRefIt.CurrentId(); const BRepGraphInc::VertexRef& aRef = aRefs.Vertices().Entry(aVertexRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Edge || !BRepGraph_EdgeId(aP).IsValidIn(aDefs.Edges()) @@ -1283,7 +1337,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_OccurrenceRefId aOccurrenceRefId = anOccurrenceRefIt.CurrentId(); const BRepGraphInc::OccurrenceRef& aRef = aRefs.Occurrences().Entry(aOccurrenceRefId); if (aRef.IsRemoved) + { continue; + } const BRepGraph_NodeId aP = aRef.ParentId; if (!aP.IsValid() || aP.NodeKind != BRepGraph_NodeId::Kind::Product || !BRepGraph_ProductId(aP).IsValidIn(aDefs.Products()) @@ -1303,7 +1359,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph { const BRepGraphInc::OccurrenceDef& anOcc = anOccIt.Current(); if (anOcc.ChildDefId.NodeKind != BRepGraph_NodeId::Kind::Product) + { continue; + } const BRepGraph_ProductId aChildProductId(anOcc.ChildDefId); if (!aChildProductId.IsValidIn(aDefs.Products()) || aDefs.Products().Definition(aChildProductId).IsRemoved) @@ -1327,7 +1385,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_ChildRefId aChildRefId = aChildRefIt.CurrentId(); const BRepGraphInc::ChildRef& aCR = aRefs.Children().Entry(aChildRefId); if (aCR.IsRemoved) + { continue; + } if (aCR.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Solid && aCR.ChildDefId.IsValid()) { aCompoundOwnedSolids.Add(BRepGraph_SolidId::FromNodeId(aCR.ChildDefId)); @@ -1339,7 +1399,9 @@ BRepGraph_Validate::Result BRepGraph_Validate::Perform(const BRepGraph& theGraph const BRepGraph_SolidRefId aSolidRefId = aSolidRefIt.CurrentId(); const BRepGraphInc::SolidRef& aSR = aRefs.Solids().Entry(aSolidRefId); if (aSR.IsRemoved) + { continue; + } if (aSR.SolidDefId.IsValid() && aCompoundOwnedSolids.Contains(aSR.SolidDefId)) { aResult.Issues.Append( diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.cxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.cxx index 7be1a0b21e..1844ce4aef 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.cxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.cxx @@ -171,7 +171,9 @@ BRepGraph_ChildRefId appendChildRef(BRepGraphInc_Storage& theStorage anEntry.Orientation = theRef.Orientation; anEntry.LocalLocation = theRef.Location; if (theParentId.NodeKind == BRepGraph_NodeId::Kind::Compound) + { theStorage.ChangeCompound(BRepGraph_CompoundId(theParentId)).ChildRefIds.Append(aRefId); + } return aRefId; } @@ -290,10 +292,14 @@ static bool extractStoredPCurves( TopLoc_Location aFaceLoc; const occ::handle& aSurf = BRep_Tool::Surface(theFace, aFaceLoc); if (aSurf.IsNull()) + { return false; + } const occ::handle aTEdge = occ::down_cast(theEdge.TShape()); if (aTEdge.IsNull()) + { return false; + } const NCollection_List>& aCurves = aTEdge->Curves(); const bool aReversed = (theEdge.Orientation() == TopAbs_REVERSED); @@ -323,9 +329,13 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface()) + { continue; + } if (aCR->IsCurveOnSurface(aSurf, aExpectedLoc)) + { return anExtractFromCR(aCR); + } } // Pass 1b: match using raw TFace.Location (preserves datum pointers). @@ -343,9 +353,13 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface()) + { continue; + } if (aCR->IsCurveOnSurface(aSurf, aRawExpectedLoc)) + { return anExtractFromCR(aCR); + } } } } @@ -356,7 +370,9 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface() || aCR->Surface() != aSurf) + { continue; + } return anExtractFromCR(aCR); } @@ -372,9 +388,13 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface()) + { continue; + } if (aCR->IsCurveOnSurface(theOrigSurface, aExpectedLoc)) + { return anExtractFromCR(aCR); + } } // Pass 3a.5: raw TFace.Location match on original surface. { @@ -386,9 +406,13 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface()) + { continue; + } if (aCR->IsCurveOnSurface(theOrigSurface, aRawExpectedLoc)) + { return anExtractFromCR(aCR); + } } } } @@ -396,7 +420,9 @@ static bool extractStoredPCurves( for (const occ::handle& aCR : aCurves) { if (!aCR->IsCurveOnSurface() || aCR->Surface() != theOrigSurface) + { continue; + } return anExtractFromCR(aCR); } } @@ -449,7 +475,9 @@ const BRepGraph_NodeId* findExistingNode(const BRepGraphInc_Storage& theStorage, { const BRepGraph_NodeId* anExisting = theStorage.FindNodeByTShape(theShape.TShape().get()); if (anExisting != nullptr && anExisting->NodeKind == theExpectedKind) + { return anExisting; + } return nullptr; } @@ -465,11 +493,15 @@ BRepGraph_VertexId registerOrReuseVertex(BRepGraphInc_Storage& theStorage, const double theTolerance) { if (theVertex.IsNull()) + { return BRepGraph_VertexId(); + } const BRepGraph_NodeId* anExisting = findExistingNode(theStorage, theVertex, BRepGraph_NodeId::Kind::Vertex); if (anExisting != nullptr) + { return BRepGraph_VertexId(*anExisting); + } const BRepGraph_VertexId aVtxId = theStorage.AppendVertex(); BRepGraphInc::VertexDef& aVtxEnt = theStorage.ChangeVertex(aVtxId); @@ -485,7 +517,9 @@ BRepGraph_VertexId registerOrReuseVertex(BRepGraphInc_Storage& theStorage, const TopoDS_Vertex& theVertex) { if (theVertex.IsNull()) + { return BRepGraph_VertexId(); + } return registerOrReuseVertex(theStorage, theVertex, rawVertexPoint(theVertex), @@ -502,7 +536,9 @@ occ::handle applyRepresentationLocation(const occ::handle& theGeom, const TopLoc_Location& theCombinedLoc) { if (theGeom.IsNull()) + { return theGeom; + } // Do NOT use theCombinedLoc.IsIdentity() as an early return - TopLoc_Location // chain composition can structurally cancel to Identity (empty chain) even when // the actual repLoc (theShapeLoc^-1 * theCombinedLoc) is non-Identity. @@ -510,7 +546,9 @@ occ::handle applyRepresentationLocation(const occ::handle& theGeom, // form inverse pairs that cancel in Multiplied(). const TopLoc_Location aRepLoc = theShapeLoc.Inverted() * theCombinedLoc; if (aRepLoc.IsIdentity()) + { return theGeom; + } return occ::down_cast(theGeom->Transformed(aRepLoc.Transformation())); } @@ -521,21 +559,31 @@ static occ::handle applyRepLocationToPolygon3D( const TopLoc_Location& theCombinedLoc) { if (thePolygon3D.IsNull()) + { return thePolygon3D; + } const TopLoc_Location aRepLoc = theShapeLoc.Inverted() * theCombinedLoc; if (aRepLoc.IsIdentity()) + { return thePolygon3D; + } const gp_Trsf& aTrsf = aRepLoc.Transformation(); const NCollection_Array1& aNodes = thePolygon3D->Nodes(); NCollection_Array1 aNewNodes(aNodes.Lower(), aNodes.Upper()); for (int aNodeIdx = aNodes.Lower(); aNodeIdx <= aNodes.Upper(); ++aNodeIdx) + { aNewNodes.SetValue(aNodeIdx, aNodes.Value(aNodeIdx).Transformed(aTrsf)); + } occ::handle aTransPoly; if (thePolygon3D->HasParameters()) + { aTransPoly = new Poly_Polygon3D(aNewNodes, thePolygon3D->Parameters()); + } else + { aTransPoly = new Poly_Polygon3D(aNewNodes); + } aTransPoly->Deflection(thePolygon3D->Deflection()); return aTransPoly; } @@ -560,11 +608,15 @@ BRepGraph_SurfaceRepId getOrCreateSurfaceRep(BRepGraphInc_Storage& th const occ::handle& theSurface) { if (theSurface.IsNull()) + { return BRepGraph_SurfaceRepId(); + } const Geom_Surface* aPtr = theSurface.get(); const BRepGraph_SurfaceRepId* anExisting = theDedup.Surfaces.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_SurfaceRepId aRepId = theStorage.AppendSurfaceRep(); BRepGraphInc::SurfaceRep& aRep = theStorage.ChangeSurfaceRep(aRepId); aRep.Surface = theSurface; @@ -578,11 +630,15 @@ BRepGraph_Curve3DRepId getOrCreateCurve3DRep(BRepGraphInc_Storage& theS const occ::handle& theCurve) { if (theCurve.IsNull()) + { return BRepGraph_Curve3DRepId(); + } const Geom_Curve* aPtr = theCurve.get(); const BRepGraph_Curve3DRepId* anExisting = theDedup.Curves3D.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_Curve3DRepId aRepId = theStorage.AppendCurve3DRep(); BRepGraphInc::Curve3DRep& aRep = theStorage.ChangeCurve3DRep(aRepId); aRep.Curve = theCurve; @@ -596,11 +652,15 @@ BRepGraph_Curve2DRepId getOrCreateCurve2DRep(BRepGraphInc_Storage& th const occ::handle& theCurve) { if (theCurve.IsNull()) + { return BRepGraph_Curve2DRepId(); + } const Geom2d_Curve* aPtr = theCurve.get(); const BRepGraph_Curve2DRepId* anExisting = theDedup.Curves2D.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_Curve2DRepId aRepId = theStorage.AppendCurve2DRep(); BRepGraphInc::Curve2DRep& aRep = theStorage.ChangeCurve2DRep(aRepId); aRep.Curve = theCurve; @@ -615,11 +675,15 @@ BRepGraph_TriangulationRepId getOrCreateTriangulationRep( const occ::handle& theTriangulation) { if (theTriangulation.IsNull()) + { return BRepGraph_TriangulationRepId(); + } const Poly_Triangulation* aPtr = theTriangulation.get(); const BRepGraph_TriangulationRepId* anExisting = theDedup.Triangulations.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_TriangulationRepId aRepId = theStorage.AppendTriangulationRep(); BRepGraphInc::TriangulationRep& aRep = theStorage.ChangeTriangulationRep(aRepId); aRep.Triangulation = theTriangulation; @@ -633,11 +697,15 @@ BRepGraph_Polygon3DRepId getOrCreatePolygon3DRep(BRepGraphInc_Storage& const occ::handle& thePolygon) { if (thePolygon.IsNull()) + { return BRepGraph_Polygon3DRepId(); + } const Poly_Polygon3D* aPtr = thePolygon.get(); const BRepGraph_Polygon3DRepId* anExisting = theDedup.Polygons3D.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_Polygon3DRepId aRepId = theStorage.AppendPolygon3DRep(); BRepGraphInc::Polygon3DRep& aRep = theStorage.ChangePolygon3DRep(aRepId); aRep.Polygon = thePolygon; @@ -651,11 +719,15 @@ BRepGraph_Polygon2DRepId getOrCreatePolygon2DRep(BRepGraphInc_Storage& const occ::handle& thePolygon) { if (thePolygon.IsNull()) + { return BRepGraph_Polygon2DRepId(); + } const Poly_Polygon2D* aPtr = thePolygon.get(); const BRepGraph_Polygon2DRepId* anExisting = theDedup.Polygons2D.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_Polygon2DRepId aRepId = theStorage.AppendPolygon2DRep(); BRepGraphInc::Polygon2DRep& aRep = theStorage.ChangePolygon2DRep(aRepId); aRep.Polygon = thePolygon; @@ -672,11 +744,15 @@ BRepGraph_PolygonOnTriRepId getOrCreatePolygonOnTriRep( const BRepGraph_TriangulationRepId theTriRepId) { if (thePolygon.IsNull()) + { return BRepGraph_PolygonOnTriRepId(); + } const Poly_PolygonOnTriangulation* aPtr = thePolygon.get(); const BRepGraph_PolygonOnTriRepId* anExisting = theDedup.PolygonsOnTri.Seek(aPtr); if (anExisting != nullptr) + { return *anExisting; + } const BRepGraph_PolygonOnTriRepId aRepId = theStorage.AppendPolygonOnTriRep(); BRepGraphInc::PolygonOnTriRep& aRep = theStorage.ChangePolygonOnTriRep(aRepId); aRep.Polygon = thePolygon; @@ -694,7 +770,9 @@ BRepGraph_EdgeId registerExtractedEdge(BRepGraphInc_Storage& theStorage, const BRepGraph_NodeId* anExisting = findExistingNode(theStorage, theEdgeData.Shape, BRepGraph_NodeId::Kind::Edge); if (anExisting != nullptr) + { return BRepGraph_EdgeId(*anExisting); + } const BRepGraph_EdgeId anEdgeId = theStorage.AppendEdge(); BRepGraphInc::EdgeDef& anEdgeEnt = theStorage.ChangeEdge(anEdgeId); @@ -764,7 +842,9 @@ bool makeAuxChildRef(const BRepGraphInc_Storage& theStorage, { const BRepGraph_NodeId* aChildNodeId = theStorage.FindNodeByTShape(theChild.TShape().get()); if (aChildNodeId == nullptr) + { return false; + } theRef.DefId = *aChildNodeId; theRef.Orientation = theChild.Orientation(); theRef.Location = theChild.Location(); @@ -786,7 +866,9 @@ static void edgeVertices(const TopoDS_Edge& theE for (TopoDS_Iterator aVIt(theEdge, false, false); aVIt.More(); aVIt.Next()) { if (aVIt.Value().ShapeType() != TopAbs_VERTEX) + { continue; + } const TopoDS_Vertex aVertex = TopoDS::Vertex(aVIt.Value()); if (aVertex.Orientation() == TopAbs_FORWARD) { @@ -926,7 +1008,9 @@ static void extractEdgeInFace(ExtractedEdge& theEdgeData, } if (!theEdgeData.PCurve2d.IsNull() && !theFaceSurface.IsNull()) + { BRep_Tool::UVPoints(aFwdEdge, theForwardFace, theEdgeData.PCUV1, theEdgeData.PCUV2); + } // For seam edges, extract reversed parameter range. // The reversed edge accesses PCurve2/PCurve (swapped), so Range gives the same values. @@ -969,7 +1053,9 @@ static void extractEdgeInFace(ExtractedEdge& theEdgeData, occ::handle aPolyOnSurfRev = BRep_Tool::PolygonOnSurface(aRevEdge, theForwardFace); if (!aPolyOnSurfRev.IsNull() && aPolyOnSurfRev != theEdgeData.PolyOnSurf) + { theEdgeData.PolyOnSurfReversed = aPolyOnSurfRev; + } } } } @@ -1016,7 +1102,9 @@ void extractFaceData(FaceLocalData& theData) continue; } if (aChild.ShapeType() != TopAbs_WIRE) + { continue; + } const TopoDS_Wire& aWire = TopoDS::Wire(aChild); ExtractedWire aWireData; @@ -1027,7 +1115,9 @@ void extractFaceData(FaceLocalData& theData) { const TopoDS_Shape& anEdgeShape = anEdgeIt.Value(); if (anEdgeShape.ShapeType() != TopAbs_EDGE) + { continue; + } ExtractedEdge& anEdgeData = aWireData.Edges.Appended(); extractEdgeInFace(anEdgeData, TopoDS::Edge(anEdgeShape), @@ -1097,7 +1187,9 @@ void registerFaceData(BRepGraphInc_Storage& theStorage, // Shared faces (same TShape referenced multiple times in a shell) must NOT // duplicate wire/edge/coedge data on the single FaceDef. if (!aIsNewFaceDef) + { continue; + } for (const ExtractedWire& aWireData : aData.Wires) { @@ -1215,7 +1307,9 @@ void registerFaceData(BRepGraphInc_Storage& theStorage, const bool hasSeamCoEdge = aSeamCoEdgeId.IsValid(); TopoDS_Edge aRevEdge; if (hasSeamCoEdge) + { aRevEdge = TopoDS::Edge(anEdgeData.Shape.Reversed()); + } if (aFaceDef.TriangulationRepId.IsValid()) { @@ -1237,7 +1331,9 @@ void registerFaceData(BRepGraphInc_Storage& theStorage, occ::handle aTriCopy = aTri->Copy(); const gp_Trsf& aTrsf = aRepLoc.Transformation(); for (int aNodeIdx = 1; aNodeIdx <= aTriCopy->NbNodes(); ++aNodeIdx) + { aTriCopy->SetNode(aNodeIdx, aTriCopy->Node(aNodeIdx).Transformed(aTrsf)); + } aTriRepId = getOrCreateTriangulationRep(theStorage, theRepDedup, aTriCopy); aFaceMut.TriangulationRepId = aTriRepId; } @@ -1302,14 +1398,18 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, const TopLoc_Location& theParentGlobalLoc) { if (theCurrentShape.IsNull()) + { return; + } switch (theCurrentShape.ShapeType()) { case TopAbs_COMPOUND: { const TopoDS_Compound& aCompound = TopoDS::Compound(theCurrentShape); if (findExistingNode(theStorage, aCompound, BRepGraph_NodeId::Kind::Compound)) + { break; + } const BRepGraph_CompoundId aCompId = theStorage.AppendCompound(); theStorage.BindTShapeToNode(aCompound.TShape().get(), aCompId); @@ -1335,7 +1435,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, const BRepGraph_NodeId* aChildNodeId = theStorage.FindNodeByTShape(aChild.TShape().get()); if (aChildNodeId != nullptr) + { aChildIdx = aChildNodeId->Index; + } } BRepGraphInc::NodeInstance aRef; @@ -1351,7 +1453,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, case TopAbs_COMPSOLID: { const TopoDS_CompSolid& aCompSolid = TopoDS::CompSolid(theCurrentShape); if (findExistingNode(theStorage, aCompSolid, BRepGraph_NodeId::Kind::CompSolid)) + { break; + } const BRepGraph_CompSolidId aCSolidId = theStorage.AppendCompSolid(); theStorage.BindTShapeToNode(aCompSolid.TShape().get(), aCSolidId); @@ -1362,13 +1466,17 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, for (TopoDS_Iterator aChildIt(aCompSolid, false, false); aChildIt.More(); aChildIt.Next()) { if (aChildIt.Value().ShapeType() != TopAbs_SOLID) + { continue; + } traverseHierarchy(theStorage, theFaceData, theRepDedup, aChildIt.Value(), aGlobalLoc); const BRepGraph_NodeId* aSolidNodeId = theStorage.FindNodeByTShape(aChildIt.Value().TShape().get()); if (aSolidNodeId == nullptr) + { continue; + } BRepGraphInc::SolidInstance aRef; aRef.DefId = BRepGraph_SolidId::FromNodeId(*aSolidNodeId); @@ -1382,7 +1490,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, case TopAbs_SOLID: { const TopoDS_Solid& aSolid = TopoDS::Solid(theCurrentShape); if (findExistingNode(theStorage, aSolid, BRepGraph_NodeId::Kind::Solid)) + { break; + } const BRepGraph_SolidId aSolidId = theStorage.AppendSolid(); theStorage.BindTShapeToNode(aSolid.TShape().get(), aSolidId); @@ -1399,7 +1509,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, { const BRepGraph_NodeId* aShellNodeId = theStorage.FindNodeByTShape(aChild.TShape().get()); if (aShellNodeId == nullptr) + { continue; + } BRepGraphInc::ShellInstance aRef; aRef.DefId = BRepGraph_ShellId::FromNodeId(*aShellNodeId); @@ -1423,7 +1535,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, case TopAbs_SHELL: { const TopoDS_Shell& aShell = TopoDS::Shell(theCurrentShape); if (findExistingNode(theStorage, aShell, BRepGraph_NodeId::Kind::Shell)) + { break; + } const BRepGraph_ShellId aShellId = theStorage.AppendShell(); BRepGraphInc::ShellDef& aShellEnt = theStorage.ChangeShell(aShellId); @@ -1468,7 +1582,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, case TopAbs_WIRE: { const TopoDS_Wire& aWire = TopoDS::Wire(theCurrentShape); if (findExistingNode(theStorage, aWire, BRepGraph_NodeId::Kind::Wire)) + { break; + } const BRepGraph_WireId aWireId = theStorage.AppendWire(); BRepGraphInc::WireDef& aWireEnt = theStorage.ChangeWire(aWireId); @@ -1479,7 +1595,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, for (TopoDS_Iterator anEdgeIt(aWire, false, false); anEdgeIt.More(); anEdgeIt.Next()) { if (anEdgeIt.Value().ShapeType() != TopAbs_EDGE) + { continue; + } const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeIt.Value()); // Recurse to create the edge entity (with dedup). @@ -1509,7 +1627,9 @@ void traverseHierarchy(BRepGraphInc_Storage& theStorage, case TopAbs_EDGE: { const TopoDS_Edge& anEdge = TopoDS::Edge(theCurrentShape); if (findExistingNode(theStorage, anEdge, BRepGraph_NodeId::Kind::Edge)) + { break; + } const BRepGraph_EdgeId anEdgeId = theStorage.AppendEdge(); BRepGraphInc::EdgeDef& anEdgeEnt = theStorage.ChangeEdge(anEdgeId); @@ -1604,12 +1724,16 @@ static void appendUniqueRootNode(NCollection_DynamicArray& the const BRepGraph_NodeId& theNodeId) { if (!theNodeId.IsValid()) + { return; + } for (const BRepGraph_NodeId& aRoot : theRoots) { if (aRoot == theNodeId) + { return; + } } theRoots.Append(theNodeId); } @@ -1625,7 +1749,9 @@ void flattenForAppend(BRepGraphInc_Storage& theStorage, NCollection_DynamicArray* theAppendedRoots) { if (theCurrentShape.IsNull()) + { return; + } switch (theCurrentShape.ShapeType()) { @@ -1680,12 +1806,18 @@ void populateRegularityLayer(BRepGraphInc_Storage& theSt const occ::handle& theTmpAlloc) { if (theRegularityLayer == nullptr) + { return; + } if (theOldNbEdges == 0) + { theRegularityLayer->Clear(); + } if (!theExtractRegularities) + { return; + } // Surface-to-face map covers all faces (new edges may reference old faces). NCollection_DataMap aSurfToFaceIdx(1, theTmpAlloc); @@ -1694,12 +1826,16 @@ void populateRegularityLayer(BRepGraphInc_Storage& theSt { const TopoDS_Shape* anOrigFace = theStorage.FindOriginal(aFaceId); if (anOrigFace == nullptr || anOrigFace->IsNull()) + { continue; + } TopLoc_Location aLoc; occ::handle aRawSurf = BRep_Tool::Surface(TopoDS::Face(*anOrigFace), aLoc); if (!aRawSurf.IsNull()) + { aSurfToFaceIdx.TryBind(aRawSurf.get(), aFaceId); + } } // Only process new edges in incremental mode. @@ -1708,32 +1844,44 @@ void populateRegularityLayer(BRepGraphInc_Storage& theSt { const TopoDS_Shape* anOrigShape = theStorage.FindOriginal(anEdgeId); if (anOrigShape == nullptr || anOrigShape->IsNull()) + { continue; + } const TopoDS_Edge& anEdge = TopoDS::Edge(*anOrigShape); const occ::handle aTEdge = occ::down_cast(anEdge.TShape()); if (aTEdge.IsNull()) + { continue; + } for (const occ::handle& aCRep : aTEdge->Curves()) { if (aCRep.IsNull()) + { continue; + } const occ::handle aCon2S = occ::down_cast(aCRep); if (aCon2S.IsNull()) + { continue; + } const Geom_Surface* aSurf1Ptr = aCon2S->Surface().get(); const Geom_Surface* aSurf2Ptr = aCon2S->Surface2().get(); if (aSurf1Ptr == nullptr || aSurf2Ptr == nullptr) + { continue; + } const BRepGraph_FaceId* aFaceIdx1 = aSurfToFaceIdx.Seek(aSurf1Ptr); const BRepGraph_FaceId* aFaceIdx2 = aSurfToFaceIdx.Seek(aSurf2Ptr); if (aFaceIdx1 == nullptr || aFaceIdx2 == nullptr) + { continue; + } theRegularityLayer->SetRegularity(anEdgeId, *aFaceIdx1, *aFaceIdx2, aCon2S->Continuity()); } @@ -1749,12 +1897,18 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage const occ::handle& theTmpAlloc) { if (theParamLayer == nullptr) + { return; + } if (theOldNbVertices == 0) + { theParamLayer->Clear(); + } if (!theExtractVertexPointReps) + { return; + } NCollection_DataMap aCurveToEdgeDef(1, theTmpAlloc); const uint32_t aNbEdges = theStorage.NbEdges(); @@ -1763,7 +1917,9 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage { const TopoDS_Shape* anOrigEdge = theStorage.FindOriginal(anEdgeId); if (anOrigEdge == nullptr || anOrigEdge->IsNull()) + { continue; + } double aFirst = 0.0; double aLast = 0.0; @@ -1771,7 +1927,9 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage occ::handle aRawCurve = BRep_Tool::Curve(TopoDS::Edge(*anOrigEdge), aLoc, aFirst, aLast); if (!aRawCurve.IsNull()) + { aCurveToEdgeDef.TryBind(aRawCurve.get(), anEdgeId); + } } NCollection_DataMap aSurfToFaceDef(1, theTmpAlloc); @@ -1801,11 +1959,15 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage { const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aCoEdgeId); if (!aCoEdge.Curve2DRepId.IsValid() || !aCoEdge.FaceDefId.IsValid(theStorage.NbFaces())) + { continue; + } const occ::handle& aPCurve = theStorage.Curve2DRep(aCoEdge.Curve2DRepId).Curve; if (aPCurve.IsNull()) + { continue; + } NCollection_DynamicArray* aCoEdges = aPCurveToCoEdges.ChangeSeek(aPCurve.get()); @@ -1827,25 +1989,33 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage { const TopoDS_Shape* aVtxShape = theStorage.FindOriginal(aVertexId); if (aVtxShape == nullptr || aVtxShape->IsNull()) + { continue; + } const TopoDS_Vertex& aVertex = TopoDS::Vertex(*aVtxShape); const occ::handle& aTVertex = occ::down_cast(aVertex.TShape()); if (aTVertex.IsNull()) + { continue; + } for (const occ::handle& aPtRep : aTVertex->Points()) { if (aPtRep.IsNull()) + { continue; + } if (const occ::handle aPOC = occ::down_cast(aPtRep)) { const BRepGraph_NodeId* anEdgeId = aCurveToEdgeDef.Seek(aPOC->Curve().get()); if (anEdgeId != nullptr) + { theParamLayer->SetPointOnCurve(aVertexId, BRepGraph_EdgeId::FromNodeId(*anEdgeId), aPOC->Parameter()); + } } else if (const occ::handle aPOCS = occ::down_cast(aPtRep)) @@ -1853,7 +2023,9 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage const NCollection_DynamicArray* aCandidates = aPCurveToCoEdges.Seek(aPOCS->PCurve().get()); if (aCandidates == nullptr) + { continue; + } const Geom_Surface* aSurfacePtr = aPOCS->Surface().get(); BRepGraph_CoEdgeId aMatchedCoEdge; @@ -1861,7 +2033,9 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage { const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aCoEdgeId); if (!aCoEdge.FaceDefId.IsValidIn(aFaceRawSurfaces)) + { continue; + } if (aFaceRawSurfaces.Value(static_cast(aCoEdge.FaceDefId.Index)) == aSurfacePtr) { aMatchedCoEdge = aCoEdgeId; @@ -1870,7 +2044,9 @@ void populateParamLayer(BRepGraphInc_Storage& theStorage } if (aMatchedCoEdge.IsValid()) + { theParamLayer->SetPointOnPCurve(aVertexId, aMatchedCoEdge, aPOCS->Parameter()); + } } else if (const occ::handle aPOS = occ::down_cast(aPtRep)) @@ -1925,7 +2101,9 @@ void BRepGraphInc_Populate::Perform(BRepGraphInc_Storage& theStorage, theStorage.Clear(); if (theShape.IsNull()) + { return; + } // Use temporary allocator if provided, else default. // Must NOT use the storage's persistent allocator for scratch data. @@ -1962,7 +2140,9 @@ void BRepGraphInc_Populate::Perform(BRepGraphInc_Storage& theStorage, const BRepGraph_NodeId aParentId(aCompoundId); const TopoDS_Shape* aCompOrig = theStorage.myOriginalShapes.Seek(aParentId); if (aCompOrig == nullptr) + { continue; + } uint32_t aRefOrd = 0; for (TopoDS_Iterator aChildIt(*aCompOrig, false, false); aChildIt.More(); aChildIt.Next()) @@ -1976,7 +2156,9 @@ void BRepGraphInc_Populate::Perform(BRepGraphInc_Storage& theStorage, { BRepGraphInc::ChildRef& aCandidate = theStorage.ChangeChildRef(aChildRefId); if (aCandidate.ParentId != aParentId || aCandidate.IsRemoved) + { continue; + } if (aCurrentOrd == aRefOrd) { aRef = &aCandidate; @@ -1986,7 +2168,9 @@ void BRepGraphInc_Populate::Perform(BRepGraphInc_Storage& theStorage, } if (aRef == nullptr) + { break; + } if (!aRef->ChildDefId.IsValid()) { @@ -1994,7 +2178,9 @@ void BRepGraphInc_Populate::Perform(BRepGraphInc_Storage& theStorage, theStorage.myTShapeToNodeId.Seek(aChildIt.Value().TShape().get()); if (aNodeId != nullptr && aNodeId->NodeKind == shapeTypeToNodeKind(aChildIt.Value().ShapeType())) + { aRef->ChildDefId = *aNodeId; + } } ++aRefOrd; } @@ -2027,7 +2213,9 @@ void BRepGraphInc_Populate::AppendFlattened( const occ::handle& theTmpAlloc) { if (theShape.IsNull()) + { return; + } // Use temporary allocator if provided, else default. // Must NOT use the storage's persistent allocator for scratch data. @@ -2115,7 +2303,9 @@ void BRepGraphInc_Populate::Append(BRepGraphInc_Storage& const occ::handle& theTmpAlloc) { if (theShape.IsNull()) + { return; + } const occ::handle& aTmpAlloc = !theTmpAlloc.IsNull() ? theTmpAlloc : NCollection_BaseAllocator::CommonBaseAllocator(); @@ -2167,7 +2357,9 @@ void BRepGraphInc_Populate::Append(BRepGraphInc_Storage& const BRepGraph_NodeId aCompoundNode = BRepGraph_NodeId(aCompoundId); const TopoDS_Shape* aCompOrig = theStorage.myOriginalShapes.Seek(aCompoundNode); if (aCompOrig == nullptr) + { continue; + } const BRepGraphInc::CompoundDef& aCompDef = theStorage.Compound(aCompoundId); const size_t aNbOwnedRefs = aCompDef.ChildRefIds.Size(); @@ -2176,7 +2368,9 @@ void BRepGraphInc_Populate::Append(BRepGraphInc_Storage& for (TopoDS_Iterator aChildIt(*aCompOrig, false, false); aChildIt.More(); aChildIt.Next()) { if (aRefOrd >= aNbOwnedRefs) + { break; + } const BRepGraph_ChildRefId aOwnedRefId = aCompDef.ChildRefIds.Value(aRefOrd); BRepGraphInc::ChildRef& aRef = theStorage.ChangeChildRef(aOwnedRefId); @@ -2192,7 +2386,9 @@ void BRepGraphInc_Populate::Append(BRepGraphInc_Storage& theStorage.myTShapeToNodeId.Seek(aChildIt.Value().TShape().get()); if (aNodeId != nullptr && aNodeId->NodeKind == shapeTypeToNodeKind(aChildIt.Value().ShapeType())) + { aRef.ChildDefId = *aNodeId; + } } ++aRefOrd; } diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Reconstruct.cxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Reconstruct.cxx index 0005d5188e..97f9526047 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Reconstruct.cxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Reconstruct.cxx @@ -40,12 +40,16 @@ static void restoreEdgeRegularities(const BRepGraph_LayerRegularity* theRegulari TopoDS_Edge& theEdgeShape) { if (theRegularities == nullptr) + { return; + } const BRepGraph_LayerRegularity::EdgeRegularities* aRegularities = theRegularities->FindEdgeRegularities(theEdgeId); if (aRegularities == nullptr) + { return; + } for (const BRepGraph_LayerRegularity::RegularityEntry& aRegEntry : aRegularities->Entries) { @@ -70,15 +74,21 @@ static void restoreVertexPointReps(const BRepGraphInc_Storage& theStorage, BRep_Builder& theBuilder) { if (theParams == nullptr || !theVertexId.IsValid(theStorage.NbVertices())) + { return; + } const BRepGraph_LayerParam::VertexParams* aParams = theParams->FindVertexParams(theVertexId); if (aParams == nullptr || aParams->IsEmpty()) + { return; + } const TopoDS_Shape* aVtxCached = theCache.Seek(theVertexId); if (aVtxCached == nullptr || aVtxCached->IsNull()) + { return; + } const BRepGraphInc::VertexDef& aVtxDef = theStorage.Vertex(theVertexId); TopoDS_Vertex aVtxShape = TopoDS::Vertex(*aVtxCached); @@ -87,10 +97,12 @@ static void restoreVertexPointReps(const BRepGraphInc_Storage& theStorage, { const TopoDS_Shape* anEdgeCached = theCache.Seek(aPOC.EdgeDefId); if (anEdgeCached != nullptr && !anEdgeCached->IsNull()) + { theBuilder.UpdateVertex(aVtxShape, aPOC.Parameter, TopoDS::Edge(*anEdgeCached), aVtxDef.Tolerance); + } } for (const BRepGraph_LayerParam::PointOnSurfaceEntry& aPOS : aParams->PointsOnSurface) @@ -109,10 +121,14 @@ static void restoreVertexPointReps(const BRepGraphInc_Storage& theStorage, for (const BRepGraph_LayerParam::PointOnPCurveEntry& aPOPC : aParams->PointsOnPCurve) { if (!aPOPC.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aPOPC.CoEdgeDefId); if (!aCoEdge.Curve2DRepId.IsValid()) + { continue; + } const TopoDS_Shape* anEdgeCached = theCache.Seek(aCoEdge.EdgeDefId); const TopoDS_Shape* aFaceCached = theCache.Seek(aCoEdge.FaceDefId); @@ -146,14 +162,18 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the const BRepGraph_LayerRegularity* theRegularities) { if (!theNode.IsValid()) + { return TopoDS_Shape(); + } Cache::TempScope aTempScope(theCache); // Check cache first. const TopoDS_Shape* aCached = theCache.Seek(theNode); if (aCached != nullptr) + { return *aCached; + } BRep_Builder aBB; TopoDS_Shape aResult; @@ -180,9 +200,13 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const occ::handle& aCurve3d = theStorage.Curve3DRep(anEdge.Curve3DRepId).Curve; if (!aCurve3d.IsNull()) + { aBB.MakeEdge(aNewEdge, aCurve3d, TopLoc_Location(), anEdge.Tolerance); + } else + { aBB.MakeEdge(aNewEdge); + } } else { @@ -201,7 +225,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { aStartVtx.Orientation(TopAbs_FORWARD); if (!aStartVR.LocalLocation.IsIdentity()) + { aStartVtx.Location(aStartVR.LocalLocation); + } aBB.Add(aNewEdge, aStartVtx); } } @@ -214,7 +240,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { anEndVtx.Orientation(TopAbs_REVERSED); if (!anEndVR.LocalLocation.IsIdentity()) + { anEndVtx.Location(anEndVR.LocalLocation); + } aBB.Add(aNewEdge, anEndVtx); } } @@ -226,7 +254,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { aVtx.Orientation(aVR.Orientation); if (!aVR.LocalLocation.IsIdentity()) + { aVtx.Location(aVR.LocalLocation); + } aBB.Add(aNewEdge, aVtx); } } @@ -236,10 +266,14 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the const occ::handle& aPolygon3D = theStorage.Polygon3DRep(anEdge.Polygon3DRepId).Polygon; if (!aPolygon3D.IsNull()) + { aBB.UpdateEdge(aNewEdge, aPolygon3D, TopLoc_Location()); + } } if (anEdge.IsClosed) + { aNewEdge.Closed(true); + } aResult = aNewEdge; break; } @@ -252,22 +286,30 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const BRepGraphInc::CoEdgeRef& aCoEdgeRef = theStorage.CoEdgeRef(aCoEdgeRefId); if (aCoEdgeRef.IsRemoved || !aCoEdgeRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(BRepGraph_CoEdgeId(aCoEdgeRef.CoEdgeDefId)); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid(theStorage.NbEdges())) + { continue; + } TopoDS_Shape anEdge = Node(theStorage, aCoEdge.EdgeDefId, theCache); if (!anEdge.IsNull()) { anEdge.Orientation(aCoEdge.Orientation); if (!aCoEdgeRef.LocalLocation.IsIdentity()) + { anEdge.Location(aCoEdgeRef.LocalLocation); + } aBB.Add(aNewWire, anEdge); } } if (aWire.IsClosed) + { aNewWire.Closed(true); + } aResult = aNewWire; break; } @@ -286,14 +328,18 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const BRepGraphInc::FaceRef& aRef = theStorage.FaceRef(aFaceRefId); if (aRef.IsRemoved || !aRef.FaceDefId.IsValid(theStorage.NbFaces())) + { continue; + } TopoDS_Shape aFace = FaceWithCache(theStorage, aRef.FaceDefId, theCache, theParams, theRegularities); if (!aFace.IsNull()) { aFace.Orientation(aRef.Orientation); if (!aRef.LocalLocation.IsIdentity()) + { aFace.Location(aRef.LocalLocation); + } aBB.Add(aNewShell, aFace); } } @@ -307,12 +353,16 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { aChild.Orientation(aRef.Orientation); if (!aRef.LocalLocation.IsIdentity()) + { aChild.Location(aRef.LocalLocation); + } aBB.Add(aNewShell, aChild); } } if (aShell.IsClosed) + { aNewShell.Closed(true); + } aResult = aNewShell; break; } @@ -325,14 +375,18 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const BRepGraphInc::ShellRef& aShellRef = theStorage.ShellRef(aShellRefId); if (aShellRef.IsRemoved || !aShellRef.ShellDefId.IsValid(theStorage.NbShells())) + { continue; + } TopoDS_Shape aShell = Node(theStorage, aShellRef.ShellDefId, theCache, theParams, theRegularities); if (!aShell.IsNull()) { aShell.Orientation(aShellRef.Orientation); if (!aShellRef.LocalLocation.IsIdentity()) + { aShell.Location(aShellRef.LocalLocation); + } aBB.Add(aNewSolid, aShell); } } @@ -345,7 +399,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { aChild.Orientation(aCR.Orientation); if (!aCR.LocalLocation.IsIdentity()) + { aChild.Location(aCR.LocalLocation); + } aBB.Add(aNewSolid, aChild); } } @@ -361,14 +417,18 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const BRepGraphInc::ChildRef& aRef = theStorage.ChildRef(aChildRefId); if (aRef.IsRemoved || !aRef.ChildDefId.IsValid()) + { continue; + } TopoDS_Shape aChild = Node(theStorage, aRef.ChildDefId, theCache, theParams, theRegularities); if (!aChild.IsNull()) { aChild.Orientation(aRef.Orientation); if (!aRef.LocalLocation.IsIdentity()) + { aChild.Location(aRef.LocalLocation); + } aBB.Add(aNewComp, aChild); } } @@ -384,14 +444,18 @@ TopoDS_Shape BRepGraphInc_Reconstruct::Node(const BRepGraphInc_Storage& the { const BRepGraphInc::SolidRef& aRef = theStorage.SolidRef(aSolidRefId); if (aRef.IsRemoved || !aRef.SolidDefId.IsValid(theStorage.NbSolids())) + { continue; + } TopoDS_Shape aSolid = Node(theStorage, aRef.SolidDefId, theCache, theParams, theRegularities); if (!aSolid.IsNull()) { aSolid.Orientation(aRef.Orientation); if (!aRef.LocalLocation.IsIdentity()) + { aSolid.Location(aRef.LocalLocation); + } aBB.Add(aNewCS, aSolid); } } @@ -421,7 +485,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( const BRepGraph_LayerRegularity* theRegularities) { if (!theFaceId.IsValid(theStorage.NbFaces())) + { return TopoDS_Shape(); + } Cache::TempScope aTempScope(theCache); @@ -429,7 +495,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( BRepGraph_NodeId aFaceNodeId = theFaceId; const TopoDS_Shape* aCachedFace = theCache.Seek(aFaceNodeId); if (aCachedFace != nullptr) + { return *aCachedFace; + } BRep_Builder aBB; const BRepGraphInc::FaceDef& aFace = theStorage.Face(theFaceId); @@ -437,13 +505,19 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( // Resolve surface from rep storage (may be null for bare topology faces). occ::handle aFaceSurface; if (aFace.SurfaceRepId.IsValid()) + { aFaceSurface = theStorage.SurfaceRep(aFace.SurfaceRepId).Surface; + } TopoDS_Face aNewFace; if (!aFaceSurface.IsNull()) + { aBB.MakeFace(aNewFace, aFaceSurface, TopLoc_Location(), aFace.Tolerance); + } else + { aBB.MakeFace(aNewFace); + } // Attach triangulation. if (aFace.TriangulationRepId.IsValid()) @@ -456,7 +530,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( aTriList.Append(aTri); const occ::handle& aTFace = occ::down_cast(aNewFace.TShape()); if (!aTFace.IsNull()) + { aTFace->Triangulations(aTriList, aTri); + } } } @@ -465,7 +541,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( BRepGraph_NodeId anEdgeNodeId = theEdgeId; const TopoDS_Shape* aCached = theCache.Seek(anEdgeNodeId); if (aCached != nullptr) + { return TopoDS::Edge(*aCached); + } const BRepGraphInc::EdgeDef& anEdge = theStorage.Edge(theEdgeId); TopoDS_Edge aNewEdge; @@ -478,9 +556,13 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { const occ::handle& aCurve3d = theStorage.Curve3DRep(anEdge.Curve3DRepId).Curve; if (!aCurve3d.IsNull()) + { aBB.MakeEdge(aNewEdge, aCurve3d, TopLoc_Location(), anEdge.Tolerance); + } else + { aBB.MakeEdge(aNewEdge); + } } else { @@ -493,11 +575,15 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( // Vertices (also cached). const auto aGetOrBuildVertex = [&](const BRepGraph_VertexId theVtxId) -> TopoDS_Shape { if (!theVtxId.IsValid()) + { return TopoDS_Shape(); + } BRepGraph_NodeId aVtxNodeId = theVtxId; const TopoDS_Shape* aVtxCached = theCache.Seek(aVtxNodeId); if (aVtxCached != nullptr) + { return *aVtxCached; + } const BRepGraphInc::VertexDef& aVtx = theStorage.Vertex(theVtxId); TopoDS_Vertex aNewVtx; aBB.MakeVertex(aNewVtx, aVtx.Point, aVtx.Tolerance); @@ -513,7 +599,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { aStartVtx.Orientation(TopAbs_FORWARD); if (!aStartVR.LocalLocation.IsIdentity()) + { aStartVtx.Location(aStartVR.LocalLocation); + } aBB.Add(aNewEdge, aStartVtx); } } @@ -525,7 +613,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { anEndVtx.Orientation(TopAbs_REVERSED); if (!anEndVR.LocalLocation.IsIdentity()) + { anEndVtx.Location(anEndVR.LocalLocation); + } aBB.Add(aNewEdge, anEndVtx); } } @@ -537,7 +627,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { aVtx.Orientation(aVR.Orientation); if (!aVR.LocalLocation.IsIdentity()) + { aVtx.Location(aVR.LocalLocation); + } aBB.Add(aNewEdge, aVtx); } } @@ -548,13 +640,17 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( const occ::handle& aPolygon3D = theStorage.Polygon3DRep(anEdge.Polygon3DRepId).Polygon; if (!aPolygon3D.IsNull()) + { aBB.UpdateEdge(aNewEdge, aPolygon3D, TopLoc_Location()); + } } restoreEdgeRegularities(theRegularities, theEdgeId, theCache, aBB, aNewEdge); if (anEdge.IsClosed) + { aNewEdge.Closed(true); + } theCache.Bind(anEdgeNodeId, aNewEdge); return aNewEdge; @@ -577,10 +673,14 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( const bool theAddToWire) { const BRepGraphInc::CoEdgeRef& aCoEdgeRef = theStorage.CoEdgeRef(theCoEdgeRefId); if (aCoEdgeRef.IsRemoved || !aCoEdgeRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { return; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(aCoEdgeRef.CoEdgeDefId); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid(theStorage.NbEdges())) + { return; + } TopoDS_Edge anEdge = aGetOrBuildEdge(aCoEdge.EdgeDefId); if (theAddToWire) @@ -588,7 +688,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( TopoDS_Edge anEdgeInWire = anEdge; anEdgeInWire.Orientation(aCoEdge.Orientation); if (!aCoEdgeRef.LocalLocation.IsIdentity()) + { anEdgeInWire.Location(aCoEdgeRef.LocalLocation); + } aBB.Add(aNewWire, anEdgeInWire); } @@ -604,7 +706,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( // stored_loc = aEdgeInFaceLoc^-1 // Later, BRep_Tool search computes the same loc from face/wire/edge context. OK if (!aEdgeInFaceLoc.IsIdentity()) + { anEdge.Location(aEdgeInFaceLoc); + } // Collect PCurve(s): primary from this coedge, seam from paired coedge. occ::handle aPC1, aPC2; @@ -642,6 +746,7 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( if (!aPC1.IsNull() && !aPC2.IsNull()) { if (aHasUV) + { aBB.UpdateEdge(anEdge, aPC1, aPC2, @@ -650,8 +755,11 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( anEdgeEnt.Tolerance, aUV1, aUV2); + } else + { aBB.UpdateEdge(anEdge, aPC1, aPC2, aFaceSurface, TopLoc_Location(), anEdgeEnt.Tolerance); + } aBB.Range(anEdge, aFaceSurface, TopLoc_Location(), aPCFirst, aPCLast); // Restore seam continuity (UpdateEdge creates CurveOnClosedSurface with C0). @@ -678,6 +786,7 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( else if (!aPC1.IsNull()) { if (aHasUV) + { aBB.UpdateEdge(anEdge, aPC1, aFaceSurface, @@ -685,8 +794,11 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( anEdgeEnt.Tolerance, aUV1, aUV2); + } else + { aBB.UpdateEdge(anEdge, aPC1, aFaceSurface, TopLoc_Location(), anEdgeEnt.Tolerance); + } aBB.Range(anEdge, aFaceSurface, TopLoc_Location(), aPCFirst, aPCLast); } else if (!aPC2.IsNull()) @@ -701,7 +813,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( const occ::handle& aPolyOnSurf = theStorage.Polygon2DRep(aCoEdge.Polygon2DRepId).Polygon; if (!aPolyOnSurf.IsNull()) + { aBB.UpdateEdge(anEdge, aPolyOnSurf, aFaceSurface, TopLoc_Location()); + } } // Attach PolygonOnTriangulation from CoEdge. @@ -714,13 +828,17 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( const occ::handle& aTri = theStorage.TriangulationRep(aPolyOnTriRep.TriangulationRepId).Triangulation; if (!aTri.IsNull()) + { aBB.UpdateEdge(anEdge, aPolyOnTriRep.Polygon, aTri, TopLoc_Location()); + } } } // Reset temporary edge location after all UpdateEdge calls. if (!aEdgeInFaceLoc.IsIdentity()) + { anEdge.Location(TopLoc_Location()); + } }; if (aCachedWire != nullptr) @@ -759,32 +877,46 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { const BRepGraphInc::WireRef& aWireRef = theStorage.WireRef(aWireRefId); if (aWireRef.IsRemoved || !aWireRef.WireDefId.IsValid(theStorage.NbWires())) + { continue; + } TopoDS_Wire aWire = aBuildWireForFace(aWireRef.WireDefId, aWireRef.LocalLocation); aWire.Orientation(aWireRef.Orientation); if (!aWireRef.LocalLocation.IsIdentity()) + { aWire.Location(aWireRef.LocalLocation); + } if (aWireRef.IsOuter) { if (anOuterWire.IsNull()) + { anOuterWire = aWire; + } continue; } anInnerWires.Append(aWire); } if (!anOuterWire.IsNull()) + { aBB.Add(aNewFace, anOuterWire); + } for (const TopoDS_Wire& anInnerWire : anInnerWires) + { aBB.Add(aNewFace, anInnerWire); + } // Add direct INTERNAL/EXTERNAL vertex children. for (const BRepGraph_VertexRefId& aVRefId : aFace.VertexRefIds) { if (!aVRefId.IsValid(theStorage.NbVertexRefs())) + { continue; + } const BRepGraphInc::VertexRef& aVR = theStorage.VertexRef(aVRefId); if (aVR.IsRemoved || !aVR.VertexDefId.IsValid()) + { continue; + } const BRepGraphInc::VertexDef& aVtxEnt = theStorage.Vertex(aVR.VertexDefId); BRepGraph_NodeId aVtxId = aVR.VertexDefId; const TopoDS_Shape* aVtxCached = theCache.Seek(aVtxId); @@ -802,7 +934,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( } aVtxShape.Orientation(aVR.Orientation); if (!aVR.LocalLocation.IsIdentity()) + { aVtxShape.Location(aVR.LocalLocation); + } aBB.Add(aNewFace, aVtxShape); } @@ -813,31 +947,41 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( { const BRepGraphInc::WireRef& aWireRef = theStorage.WireRef(aWireRefId); if (aWireRef.IsRemoved || !aWireRef.WireDefId.IsValid(theStorage.NbWires())) + { continue; + } const BRepGraphInc::WireDef& aWireEnt = theStorage.Wire(aWireRef.WireDefId); for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aWireEnt.CoEdgeRefIds) { const BRepGraphInc::CoEdgeRef& aCoEdgeRef = theStorage.CoEdgeRef(aCoEdgeRefId); if (aCoEdgeRef.IsRemoved || !aCoEdgeRef.CoEdgeDefId.IsValid(theStorage.NbCoEdges())) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theStorage.CoEdge(BRepGraph_CoEdgeId(aCoEdgeRef.CoEdgeDefId)); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid(theStorage.NbEdges())) + { continue; + } const BRepGraphInc::EdgeDef& anEdgeEnt = theStorage.Edge(aCoEdge.EdgeDefId); if (anEdgeEnt.StartVertexRefId.IsValid()) { const BRepGraph_VertexId aVertexId = theStorage.VertexRef(anEdgeEnt.StartVertexRefId).VertexDefId; if (aProcessedVertices.Add(aVertexId)) + { restoreVertexPointReps(theStorage, theParams, aVertexId, theCache, aBB); + } } if (anEdgeEnt.EndVertexRefId.IsValid()) { const BRepGraph_VertexId aVertexId = theStorage.VertexRef(anEdgeEnt.EndVertexRefId).VertexDefId; if (aProcessedVertices.Add(aVertexId)) + { restoreVertexPointReps(theStorage, theParams, aVertexId, theCache, aBB); + } } } } @@ -845,7 +989,9 @@ TopoDS_Shape BRepGraphInc_Reconstruct::FaceWithCache( // NaturalRestriction must be set AFTER wires are added // (BRep_Builder::Add may reset the flag). if (aFace.NaturalRestriction) + { aBB.NaturalRestriction(aNewFace, true); + } aNewFace.Orientation(TopAbs_FORWARD); theCache.Bind(aFaceNodeId, aNewFace); diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_ReverseIndex.cxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_ReverseIndex.cxx index 3ed9c016f8..59df5e775e 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_ReverseIndex.cxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_ReverseIndex.cxx @@ -30,7 +30,9 @@ BRepGraph_VertexId resolveVertexDefId( const T theRefId) { if (!theRefId.IsValid(static_cast(theVertexRefs.Size()))) + { return BRepGraph_VertexId(); + } return theVertexRefs.Value(static_cast(theRefId.Index)).VertexDefId; } @@ -40,11 +42,17 @@ bool containsIndexInTable(const NCollection_DynamicArray(theIdx.Size()))) + { return false; + } const NCollection_DynamicArray& aVec = theIdx.Value(static_cast(theKey.Index)); for (const TVal& anElem : aVec) + { if (anElem == theVal) + { return true; + } + } return false; } @@ -170,13 +178,19 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::EdgeDef& anEdge = theEdges.Value(static_cast(anEdgeId.Index)); if (anEdge.IsRemoved) + { continue; + } const BRepGraph_VertexId aStartVtx = resolveVertexDefId(theVertexRefs, anEdge.StartVertexRefId); const BRepGraph_VertexId anEndVtx = resolveVertexDefId(theVertexRefs, anEdge.EndVertexRefId); if (aStartVtx.IsValid() && aStartVtx.Index + 1 > aNewVertexCapacity) + { aNewVertexCapacity = aStartVtx.Index + 1; + } if (anEndVtx.IsValid() && anEndVtx.Index + 1 > aNewVertexCapacity) + { aNewVertexCapacity = anEndVtx.Index + 1; + } } // Pre-size all outer vectors to their known key range. @@ -195,13 +209,19 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::EdgeDef& anEdge = theEdges.Value(static_cast(anEdgeId.Index)); if (anEdge.IsRemoved) + { continue; + } const BRepGraph_VertexId aStartVtx = resolveVertexDefId(theVertexRefs, anEdge.StartVertexRefId); const BRepGraph_VertexId anEndVtx = resolveVertexDefId(theVertexRefs, anEdge.EndVertexRefId); if (aStartVtx.IsValid()) + { appendDirect(myVertexToEdges, aStartVtx.Index, anEdgeId); + } if (anEndVtx.IsValid() && anEndVtx != aStartVtx) + { appendDirect(myVertexToEdges, anEndVtx.Index, anEdgeId); + } } // Edge -> Wires: iterate wire entities and their CoEdgeRefIds for O(1) parent lookup. @@ -210,19 +230,27 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aWireId.Index)); if (aWire.IsRemoved) + { continue; + } for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aWire.CoEdgeRefIds) { if (!aCoEdgeRefId.IsValid(static_cast(theCoEdgeRefs.Size()))) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(static_cast(theCoEdges.Size()))) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid()) + { continue; + } appendDirect(myEdgeToWires, aCoEdge.EdgeDefId.Index, aWireId); } } @@ -234,9 +262,13 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aCoEdgeId.Index)); if (aCoEdge.IsRemoved) + { continue; + } if (aCoEdge.EdgeDefId.IsValid()) + { appendDirect(myEdgeToCoEdges, aCoEdge.EdgeDefId.Index, aCoEdgeId); + } } myNbIndexedCoEdges = static_cast(theCoEdges.Size()); @@ -246,11 +278,15 @@ void BRepGraphInc_ReverseIndex::Build( for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdges); ++anEdgeId) { if (theEdges.Value(static_cast(anEdgeId.Index)).IsRemoved) + { continue; + } const NCollection_DynamicArray* aCoEdgeIdxs = seekVec(myEdgeToCoEdges, anEdgeId.Index); if (aCoEdgeIdxs == nullptr) + { continue; + } const size_t aNbCE = aCoEdgeIdxs->Size(); // Collect face indices from coedges (stack-allocated for small counts). @@ -261,10 +297,14 @@ void BRepGraphInc_ReverseIndex::Build( const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aCoEdgeId.Index)); if (aCoEdge.FaceDefId.IsValid()) + { aFaces[aNbFaces++] = aCoEdge.FaceDefId.Index; + } } if (aNbFaces == 0) + { continue; + } std::sort(static_cast(aFaces), static_cast(aFaces) + aNbFaces); @@ -286,16 +326,24 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::FaceDef& aFace = theFaces.Value(static_cast(aFaceId.Index)); if (aFace.IsRemoved) + { continue; + } for (const BRepGraph_WireRefId& aWireRefId : aFace.WireRefIds) { if (!aWireRefId.IsValid(static_cast(theWireRefs.Size()))) + { continue; + } const BRepGraphInc::WireRef& aRef = theWireRefs.Value(static_cast(aWireRefId.Index)); if (aRef.IsRemoved || !aRef.WireDefId.IsValid(static_cast(theWires.Size()))) + { continue; + } if (theWires.Value(static_cast(aRef.WireDefId.Index)).IsRemoved) + { continue; + } appendDirect(myWireToFaces, aRef.WireDefId.Index, aFaceId); } } @@ -306,16 +354,24 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::ShellDef& aShell = theShells.Value(static_cast(aShellId.Index)); if (aShell.IsRemoved) + { continue; + } for (const BRepGraph_FaceRefId& aFaceRefId : aShell.FaceRefIds) { if (!aFaceRefId.IsValid(static_cast(theFaceRefs.Size()))) + { continue; + } const BRepGraphInc::FaceRef& aRef = theFaceRefs.Value(static_cast(aFaceRefId.Index)); if (aRef.IsRemoved || !aRef.FaceDefId.IsValid(static_cast(theFaces.Size()))) + { continue; + } if (theFaces.Value(static_cast(aRef.FaceDefId.Index)).IsRemoved) + { continue; + } appendDirect(myFaceToShells, aRef.FaceDefId.Index, aShellId); } } @@ -326,17 +382,25 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::SolidDef& aSolid = theSolids.Value(static_cast(aSolidId.Index)); if (aSolid.IsRemoved) + { continue; + } for (const BRepGraph_ShellRefId& aShellRefId : aSolid.ShellRefIds) { if (!aShellRefId.IsValid(static_cast(theShellRefs.Size()))) + { continue; + } const BRepGraphInc::ShellRef& aRef = theShellRefs.Value(static_cast(aShellRefId.Index)); if (aRef.IsRemoved || !aRef.ShellDefId.IsValid(static_cast(theShells.Size()))) + { continue; + } if (theShells.Value(static_cast(aRef.ShellDefId.Index)).IsRemoved) + { continue; + } appendDirect(myShellToSolids, aRef.ShellDefId.Index, aSolidId); } } @@ -359,39 +423,61 @@ void BRepGraphInc_ReverseIndex::Build( const BRepGraphInc::CompoundDef& aComp = theCompounds.Value(static_cast(aCompoundId.Index)); if (aComp.IsRemoved) + { continue; + } for (const BRepGraph_ChildRefId& aChildRefId : aComp.ChildRefIds) { const uint32_t aChildRefIdx = aChildRefId.Index; if (aChildRefIdx >= theChildRefs.Size()) + { continue; + } const BRepGraphInc::ChildRef& aRef = theChildRefs.Value(static_cast(aChildRefIdx)); if (aRef.IsRemoved || !aRef.ChildDefId.IsValid()) + { continue; + } if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Solid && aRef.ChildDefId.Index < theSolids.Size()) + { appendDirect(myCompoundsOfSolid, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Shell && aRef.ChildDefId.Index < theShells.Size()) + { appendDirect(myCompoundsOfShell, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Face && aRef.ChildDefId.Index < theFaces.Size()) + { appendDirect(myCompoundsOfFace, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Compound && aRef.ChildDefId.Index < theCompounds.Size()) + { appendDirect(myCompoundsOfCompound, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::CompSolid && aRef.ChildDefId.Index < theCompSolids.Size()) + { appendDirect(myCompoundsOfCompSolid, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Wire && aRef.ChildDefId.Index < theWires.Size()) + { appendDirect(myCompoundsOfWire, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Edge && aRef.ChildDefId.Index < theEdges.Size()) + { appendDirect(myCompoundsOfEdge, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Vertex && aRef.ChildDefId.Index < theVertices.Size()) + { appendDirect(myCompoundsOfVertex, aRef.ChildDefId.Index, aCompoundId); + } } } @@ -403,17 +489,25 @@ void BRepGraphInc_ReverseIndex::Build( const BRepGraphInc::CompSolidDef& aCS = theCompSolids.Value(static_cast(aCompSolidId.Index)); if (aCS.IsRemoved) + { continue; + } for (const BRepGraph_SolidRefId& aSolidRefId : aCS.SolidRefIds) { if (!aSolidRefId.IsValid(static_cast(theSolidRefs.Size()))) + { continue; + } const BRepGraphInc::SolidRef& aRef = theSolidRefs.Value(static_cast(aSolidRefId.Index)); if (aRef.IsRemoved || !aRef.SolidDefId.IsValid(static_cast(theSolids.Size()))) + { continue; + } if (theSolids.Value(static_cast(aRef.SolidDefId.Index)).IsRemoved) + { continue; + } appendDirect(myCompSolidsOfSolid, aRef.SolidDefId.Index, aCompSolidId); } } @@ -424,17 +518,25 @@ void BRepGraphInc_ReverseIndex::Build( { const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aWireId.Index)); if (aWire.IsRemoved) + { continue; + } for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aWire.CoEdgeRefIds) { if (!aCoEdgeRefId.IsValid(static_cast(theCoEdgeRefs.Size()))) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(static_cast(theCoEdges.Size()))) + { continue; + } if (theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)).IsRemoved) + { continue; + } appendDirect(myCoEdgeToWires, aRef.CoEdgeDefId.Index, aWireId); } } @@ -480,13 +582,19 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::EdgeDef& anEdge = theEdges.Value(static_cast(anEdgeId.Index)); if (anEdge.IsRemoved) + { continue; + } const BRepGraph_VertexId aStartVtx = resolveVertexDefId(theVertexRefs, anEdge.StartVertexRefId); const BRepGraph_VertexId anEndVtx = resolveVertexDefId(theVertexRefs, anEdge.EndVertexRefId); if (aStartVtx.IsValid() && aStartVtx.Index + 1 > aNewVertexCapacity) + { aNewVertexCapacity = aStartVtx.Index + 1; + } if (anEndVtx.IsValid() && anEndVtx.Index + 1 > aNewVertexCapacity) + { aNewVertexCapacity = anEndVtx.Index + 1; + } } // Extend outer vectors if needed (pre-size for new key ranges). @@ -512,13 +620,19 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::EdgeDef& anEdge = theEdges.Value(static_cast(anEdgeId.Index)); if (anEdge.IsRemoved) + { continue; + } const BRepGraph_VertexId aStartVtx = resolveVertexDefId(theVertexRefs, anEdge.StartVertexRefId); const BRepGraph_VertexId anEndVtx = resolveVertexDefId(theVertexRefs, anEdge.EndVertexRefId); if (aStartVtx.IsValid()) + { appendUnique(myVertexToEdges, aStartVtx.Index, anEdgeId); + } if (anEndVtx.IsValid() && anEndVtx != aStartVtx) + { appendUnique(myVertexToEdges, anEndVtx.Index, anEdgeId); + } } // Edge -> Wires: iterate only new wire entities and their CoEdgeRefIds. @@ -527,19 +641,27 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aWireId.Index)); if (aWire.IsRemoved) + { continue; + } for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aWire.CoEdgeRefIds) { if (!aCoEdgeRefId.IsValid(static_cast(theCoEdgeRefs.Size()))) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(static_cast(theCoEdges.Size()))) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid()) + { continue; + } appendUnique(myEdgeToWires, aCoEdge.EdgeDefId.Index, aWireId); } } @@ -556,9 +678,13 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aCoEdgeId.Index)); if (aCoEdge.IsRemoved) + { continue; + } if (aCoEdge.EdgeDefId.IsValid()) + { appendUnique(myEdgeToCoEdges, aCoEdge.EdgeDefId.Index, aCoEdgeId); + } } myNbIndexedCoEdges = static_cast(theCoEdges.Size()); @@ -568,17 +694,25 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aWireId.Index)); if (aWire.IsRemoved) + { continue; + } for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aWire.CoEdgeRefIds) { if (!aCoEdgeRefId.IsValid(static_cast(theCoEdgeRefs.Size()))) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef = theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(static_cast(theCoEdges.Size()))) + { continue; + } if (theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)).IsRemoved) + { continue; + } appendUnique(myCoEdgeToWires, aRef.CoEdgeDefId.Index, aWireId); } } @@ -587,11 +721,15 @@ void BRepGraphInc_ReverseIndex::BuildDelta( for (BRepGraph_EdgeId anEdgeId(theOldNbEdges); anEdgeId.IsValid(aNbEdges); ++anEdgeId) { if (theEdges.Value(static_cast(anEdgeId.Index)).IsRemoved) + { continue; + } const NCollection_DynamicArray* aCoEdgeIdxs = seekVec(myEdgeToCoEdges, anEdgeId.Index); if (aCoEdgeIdxs == nullptr) + { continue; + } const size_t aNbCE = aCoEdgeIdxs->Size(); NCollection_LocalArray aFaces(aNbCE); @@ -601,10 +739,14 @@ void BRepGraphInc_ReverseIndex::BuildDelta( const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aCoEdgeId.Index)); if (aCoEdge.FaceDefId.IsValid()) + { aFaces[aNbFaces++] = aCoEdge.FaceDefId.Index; + } } if (aNbFaces == 0) + { continue; + } std::sort(static_cast(aFaces), static_cast(aFaces) + aNbFaces); @@ -625,16 +767,24 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::FaceDef& aFace = theFaces.Value(static_cast(aFaceId.Index)); if (aFace.IsRemoved) + { continue; + } for (const BRepGraph_WireRefId& aWireRefId : aFace.WireRefIds) { if (!aWireRefId.IsValid(static_cast(theWireRefs.Size()))) + { continue; + } const BRepGraphInc::WireRef& aRef = theWireRefs.Value(static_cast(aWireRefId.Index)); if (aRef.IsRemoved || !aRef.WireDefId.IsValid(static_cast(theWires.Size()))) + { continue; + } if (theWires.Value(static_cast(aRef.WireDefId.Index)).IsRemoved) + { continue; + } appendUnique(myWireToFaces, aRef.WireDefId.Index, aFaceId); } } @@ -645,16 +795,24 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::ShellDef& aShell = theShells.Value(static_cast(aShellId.Index)); if (aShell.IsRemoved) + { continue; + } for (const BRepGraph_FaceRefId& aFaceRefId : aShell.FaceRefIds) { if (!aFaceRefId.IsValid(static_cast(theFaceRefs.Size()))) + { continue; + } const BRepGraphInc::FaceRef& aRef = theFaceRefs.Value(static_cast(aFaceRefId.Index)); if (aRef.IsRemoved || !aRef.FaceDefId.IsValid(static_cast(theFaces.Size()))) + { continue; + } if (theFaces.Value(static_cast(aRef.FaceDefId.Index)).IsRemoved) + { continue; + } appendUnique(myFaceToShells, aRef.FaceDefId.Index, aShellId); } } @@ -665,24 +823,34 @@ void BRepGraphInc_ReverseIndex::BuildDelta( { const BRepGraphInc::SolidDef& aSolid = theSolids.Value(static_cast(aSolidId.Index)); if (aSolid.IsRemoved) + { continue; + } for (const BRepGraph_ShellRefId& aShellRefId : aSolid.ShellRefIds) { if (!aShellRefId.IsValid(static_cast(theShellRefs.Size()))) + { continue; + } const BRepGraphInc::ShellRef& aRef = theShellRefs.Value(static_cast(aShellRefId.Index)); if (aRef.IsRemoved || !aRef.ShellDefId.IsValid(static_cast(theShells.Size()))) + { continue; + } if (theShells.Value(static_cast(aRef.ShellDefId.Index)).IsRemoved) + { continue; + } appendUnique(myShellToSolids, aRef.ShellDefId.Index, aSolidId); } } uint32_t anOldNbCompounds = theOldNbCompounds; if (anOldNbCompounds > theCompounds.Size()) + { anOldNbCompounds = 0; + } // Compound -> child reverse indices: // 1) process all refs of newly appended compound parents @@ -694,39 +862,61 @@ void BRepGraphInc_ReverseIndex::BuildDelta( const BRepGraphInc::CompoundDef& aComp = theCompounds.Value(static_cast(aCompoundId.Index)); if (aComp.IsRemoved) + { continue; + } for (const BRepGraph_ChildRefId& aChildRefId : aComp.ChildRefIds) { const uint32_t aChildRefIdx = aChildRefId.Index; if (aChildRefIdx >= theChildRefs.Size()) + { continue; + } const BRepGraphInc::ChildRef& aRef = theChildRefs.Value(static_cast(aChildRefIdx)); if (aRef.IsRemoved || !aRef.ChildDefId.IsValid()) + { continue; + } if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Solid && aRef.ChildDefId.Index < theSolids.Size()) + { appendUnique(myCompoundsOfSolid, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Shell && aRef.ChildDefId.Index < theShells.Size()) + { appendUnique(myCompoundsOfShell, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Face && aRef.ChildDefId.Index < theFaces.Size()) + { appendUnique(myCompoundsOfFace, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Compound && aRef.ChildDefId.Index < theCompounds.Size()) + { appendUnique(myCompoundsOfCompound, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::CompSolid && aRef.ChildDefId.Index < theCompSolids.Size()) + { appendUnique(myCompoundsOfCompSolid, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Wire && aRef.ChildDefId.Index < theWires.Size()) + { appendUnique(myCompoundsOfWire, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Edge && aRef.ChildDefId.Index < theEdges.Size()) + { appendUnique(myCompoundsOfEdge, aRef.ChildDefId.Index, aCompoundId); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Vertex && aRef.ChildDefId.Index < theVertices.Size()) + { appendUnique(myCompoundsOfVertex, aRef.ChildDefId.Index, aCompoundId); + } } } @@ -735,7 +925,9 @@ void BRepGraphInc_ReverseIndex::BuildDelta( // so cost stays O(delta refs) regardless of pre-existing graph size. uint32_t aOldNbChildRefs = theOldNbChildRefs; if (aOldNbChildRefs > theChildRefs.Size()) + { aOldNbChildRefs = 0; + } const uint32_t aNbChildRefs = static_cast(theChildRefs.Size()); for (BRepGraph_ChildRefId aChildRefId(aOldNbChildRefs); aChildRefId.IsValid(aNbChildRefs); ++aChildRefId) @@ -743,49 +935,73 @@ void BRepGraphInc_ReverseIndex::BuildDelta( const BRepGraphInc::ChildRef& aRef = theChildRefs.Value(static_cast(aChildRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || !aRef.ChildDefId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Compound) + { continue; + } const uint32_t aCompoundIdx = aRef.ParentId.Index; if (aCompoundIdx >= theCompounds.Size() || aCompoundIdx >= anOldNbCompounds) + { continue; + } const BRepGraphInc::CompoundDef& aComp = theCompounds.Value(static_cast(aCompoundIdx)); if (aComp.IsRemoved) + { continue; + } if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Solid && aRef.ChildDefId.Index < theSolids.Size()) + { appendUnique(myCompoundsOfSolid, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Shell && aRef.ChildDefId.Index < theShells.Size()) + { appendUnique(myCompoundsOfShell, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Face && aRef.ChildDefId.Index < theFaces.Size()) + { appendUnique(myCompoundsOfFace, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Compound && aRef.ChildDefId.Index < theCompounds.Size()) + { appendUnique(myCompoundsOfCompound, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::CompSolid && aRef.ChildDefId.Index < theCompSolids.Size()) + { appendUnique(myCompoundsOfCompSolid, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Wire && aRef.ChildDefId.Index < theWires.Size()) + { appendUnique(myCompoundsOfWire, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Edge && aRef.ChildDefId.Index < theEdges.Size()) + { appendUnique(myCompoundsOfEdge, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } else if (aRef.ChildDefId.NodeKind == BRepGraph_NodeId::Kind::Vertex && aRef.ChildDefId.Index < theVertices.Size()) + { appendUnique(myCompoundsOfVertex, aRef.ChildDefId.Index, BRepGraph_CompoundId(aCompoundIdx)); + } } uint32_t anOldNbCompSolids = theOldNbCompSolids; if (anOldNbCompSolids > theCompSolids.Size()) + { anOldNbCompSolids = 0; + } // CompSolid -> Solid reverse index: // 1) process all refs of newly appended compsolid parents @@ -797,17 +1013,25 @@ void BRepGraphInc_ReverseIndex::BuildDelta( const BRepGraphInc::CompSolidDef& aCS = theCompSolids.Value(static_cast(aCompSolidId.Index)); if (aCS.IsRemoved) + { continue; + } for (const BRepGraph_SolidRefId& aSolidRefId : aCS.SolidRefIds) { if (!aSolidRefId.IsValid(static_cast(theSolidRefs.Size()))) + { continue; + } const BRepGraphInc::SolidRef& aRef = theSolidRefs.Value(static_cast(aSolidRefId.Index)); if (aRef.IsRemoved || !aRef.SolidDefId.IsValid(static_cast(theSolids.Size()))) + { continue; + } if (theSolids.Value(static_cast(aRef.SolidDefId.Index)).IsRemoved) + { continue; + } appendUnique(myCompSolidsOfSolid, aRef.SolidDefId.Index, aCompSolidId); } } @@ -816,7 +1040,9 @@ void BRepGraphInc_ReverseIndex::BuildDelta( // pre-existing compsolid parent. Iterate only [theOldNbSolidRefs, NbSolidRefs). uint32_t aOldNbSolidRefs = theOldNbSolidRefs; if (aOldNbSolidRefs > theSolidRefs.Size()) + { aOldNbSolidRefs = 0; + } const uint32_t aNbSolidRefs = static_cast(theSolidRefs.Size()); for (BRepGraph_SolidRefId aSolidRefId(aOldNbSolidRefs); aSolidRefId.IsValid(aNbSolidRefs); ++aSolidRefId) @@ -824,16 +1050,22 @@ void BRepGraphInc_ReverseIndex::BuildDelta( const BRepGraphInc::SolidRef& aRef = theSolidRefs.Value(static_cast(aSolidRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || !aRef.SolidDefId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::CompSolid) + { continue; + } const uint32_t aCompSolidIdx = aRef.ParentId.Index; if (aCompSolidIdx >= theCompSolids.Size() || aCompSolidIdx >= anOldNbCompSolids || !aRef.SolidDefId.IsValid(static_cast(theSolids.Size()))) + { continue; + } const BRepGraphInc::CompSolidDef& aCS = theCompSolids.Value(static_cast(aCompSolidIdx)); if (aCS.IsRemoved || theSolids.Value(static_cast(aRef.SolidDefId.Index)).IsRemoved) + { continue; + } appendUnique(myCompSolidsOfSolid, aRef.SolidDefId.Index, BRepGraph_CompSolidId(aCompSolidIdx)); } @@ -1400,18 +1632,28 @@ bool BRepGraphInc_ReverseIndex::Validate( theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Wire || !aRef.CoEdgeDefId.IsValid()) + { continue; + } if (aRef.ParentId.Index >= theWires.Size() || aRef.CoEdgeDefId.Index >= theCoEdges.Size()) + { return false; + } const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aRef.ParentId.Index)); if (aWire.IsRemoved) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)); if (aCoEdge.IsRemoved || !aCoEdge.EdgeDefId.IsValid()) + { return false; + } if (!containsIndexInTable(myEdgeToWires, aCoEdge.EdgeDefId, BRepGraph_WireId(aRef.ParentId))) + { return false; + } } // Check: for each active coedge ref entry, coedge->wire reverse entry must exist. @@ -1421,18 +1663,28 @@ bool BRepGraphInc_ReverseIndex::Validate( theCoEdgeRefs.Value(static_cast(aCoEdgeRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Wire || !aRef.CoEdgeDefId.IsValid()) + { continue; + } if (aRef.ParentId.Index >= theWires.Size() || aRef.CoEdgeDefId.Index >= theCoEdges.Size()) + { return false; + } const BRepGraphInc::WireDef& aWire = theWires.Value(static_cast(aRef.ParentId.Index)); if (aWire.IsRemoved) + { continue; + } const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aRef.CoEdgeDefId.Index)); if (aCoEdge.IsRemoved) + { continue; + } if (!containsIndexInTable(myCoEdgeToWires, aRef.CoEdgeDefId, BRepGraph_WireId(aRef.ParentId))) + { return false; + } } // Check: for each edge's start/end vertex, vertex->edge reverse entry must exist. @@ -1441,18 +1693,24 @@ bool BRepGraphInc_ReverseIndex::Validate( { const BRepGraphInc::EdgeDef& anEdge = theEdges.Value(static_cast(anEdgeId.Index)); if (anEdge.IsRemoved) + { continue; + } const BRepGraph_VertexId aStartVtx = resolveVertexDefId(theVertexRefs, anEdge.StartVertexRefId); const BRepGraph_VertexId anEndVtx = resolveVertexDefId(theVertexRefs, anEdge.EndVertexRefId); if (aStartVtx.IsValid()) { if (!containsIndexInTable(myVertexToEdges, aStartVtx, anEdgeId)) + { return false; + } } if (anEndVtx.IsValid() && anEndVtx != aStartVtx) { if (!containsIndexInTable(myVertexToEdges, anEndVtx, anEdgeId)) + { return false; + } } } @@ -1462,9 +1720,13 @@ bool BRepGraphInc_ReverseIndex::Validate( { const BRepGraphInc::CoEdgeDef& aCoEdge = theCoEdges.Value(static_cast(aCoEdgeId.Index)); if (aCoEdge.IsRemoved || !aCoEdge.FaceDefId.IsValid()) + { continue; + } if (!containsIndexInTable(myEdgeToFaces, aCoEdge.EdgeDefId, aCoEdge.FaceDefId)) + { return false; + } } // Check: for each wire ref entry, wire->face reverse entry must exist. @@ -1474,14 +1736,22 @@ bool BRepGraphInc_ReverseIndex::Validate( const BRepGraphInc::WireRef& aRef = theWireRefs.Value(static_cast(aWireRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Face || !aRef.WireDefId.IsValid()) + { continue; + } if (aRef.ParentId.Index >= theFaces.Size() || aRef.WireDefId.Index >= theWires.Size()) + { return false; + } const BRepGraphInc::FaceDef& aFace = theFaces.Value(static_cast(aRef.ParentId.Index)); if (aFace.IsRemoved || theWires.Value(static_cast(aRef.WireDefId.Index)).IsRemoved) + { continue; + } if (!containsIndexInTable(myWireToFaces, aRef.WireDefId, BRepGraph_FaceId(aRef.ParentId))) + { return false; + } } // Check: for each face ref entry, face->shell reverse entry must exist. @@ -1491,15 +1761,23 @@ bool BRepGraphInc_ReverseIndex::Validate( const BRepGraphInc::FaceRef& aRef = theFaceRefs.Value(static_cast(aFaceRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Shell || !aRef.FaceDefId.IsValid()) + { continue; + } if (aRef.ParentId.Index >= theShells.Size() || aRef.FaceDefId.Index >= theFaces.Size()) + { return false; + } const BRepGraphInc::ShellDef& aShell = theShells.Value(static_cast(aRef.ParentId.Index)); if (aShell.IsRemoved || theFaces.Value(static_cast(aRef.FaceDefId.Index)).IsRemoved) + { continue; + } if (!containsIndexInTable(myFaceToShells, aRef.FaceDefId, BRepGraph_ShellId(aRef.ParentId))) + { return false; + } } // Check: for each shell ref entry, shell->solid reverse entry must exist. @@ -1509,15 +1787,23 @@ bool BRepGraphInc_ReverseIndex::Validate( const BRepGraphInc::ShellRef& aRef = theShellRefs.Value(static_cast(aShellRefId.Index)); if (aRef.IsRemoved || !aRef.ParentId.IsValid() || aRef.ParentId.NodeKind != BRepGraph_NodeId::Kind::Solid || !aRef.ShellDefId.IsValid()) + { continue; + } if (aRef.ParentId.Index >= theSolids.Size() || aRef.ShellDefId.Index >= theShells.Size()) + { return false; + } const BRepGraphInc::SolidDef& aSolid = theSolids.Value(static_cast(aRef.ParentId.Index)); if (aSolid.IsRemoved || theShells.Value(static_cast(aRef.ShellDefId.Index)).IsRemoved) + { continue; + } if (!containsIndexInTable(myShellToSolids, aRef.ShellDefId, BRepGraph_SolidId(aRef.ParentId))) + { return false; + } } // Check: for each solid ref entry, solid->compsolid reverse entry must exist. @@ -1577,49 +1863,65 @@ bool BRepGraphInc_ReverseIndex::Validate( if (!containsIndexInTable(myCompoundsOfSolid, BRepGraph_SolidId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Shell: if (!containsIndexInTable(myCompoundsOfShell, BRepGraph_ShellId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Face: if (!containsIndexInTable(myCompoundsOfFace, BRepGraph_FaceId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Compound: if (!containsIndexInTable(myCompoundsOfCompound, BRepGraph_CompoundId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::CompSolid: if (!containsIndexInTable(myCompoundsOfCompSolid, BRepGraph_CompSolidId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Wire: if (!containsIndexInTable(myCompoundsOfWire, BRepGraph_WireId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Edge: if (!containsIndexInTable(myCompoundsOfEdge, BRepGraph_EdgeId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; case BRepGraph_NodeId::Kind::Vertex: if (!containsIndexInTable(myCompoundsOfVertex, BRepGraph_VertexId(aRef.ChildDefId), BRepGraph_CompoundId(aRef.ParentId))) + { return false; + } break; default: return false; @@ -1975,11 +2277,15 @@ bool BRepGraphInc_ReverseIndex::Validate( for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId2 : aWire.CoEdgeRefIds) { if (aCoEdgeRefId2.Index >= theCoEdgeRefs.Size()) + { continue; + } const BRepGraphInc::CoEdgeRef& aRef2 = theCoEdgeRefs.Value(static_cast(aCoEdgeRefId2.Index)); if (aRef2.IsRemoved || !aRef2.CoEdgeDefId.IsValid()) + { continue; + } if (aRef2.CoEdgeDefId.Index == aCoEdgeId2.Index) { aFound = true; diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx index 225f07284d..a11a395bc4 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx @@ -261,21 +261,37 @@ const BRepGraphInc::BaseRef& BRepGraphInc_Storage::BaseRef(const BRepGraph_RefId using TypeId = std::remove_cv_t; if constexpr (std::is_same_v) + { return findInStore(myShellRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myFaceRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myWireRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myCoEdgeRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myVertexRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(mySolidRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myChildRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return findInStore(myOccurrenceRefs, theTypedId); + } Standard_ASSERT_RETURN(false, "BaseRef: unsupported ref id type", nullptr); }; @@ -298,21 +314,37 @@ BRepGraphInc::BaseRef& BRepGraphInc_Storage::ChangeBaseRef(const BRepGraph_RefId using TypeId = std::remove_cv_t; if constexpr (std::is_same_v) + { return changeFindInStore(myShellRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myFaceRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myWireRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myCoEdgeRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myVertexRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(mySolidRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myChildRefs, theTypedId); + } else if constexpr (std::is_same_v) + { return changeFindInStore(myOccurrenceRefs, theTypedId); + } Standard_ASSERT_RETURN(false, "ChangeBaseRef: unsupported ref id type", nullptr); }; @@ -365,27 +397,49 @@ bool BRepGraphInc_Storage::MarkRemoved(const BRepGraph_NodeId theNodeId) using TypeId = std::remove_cv_t; if constexpr (std::is_same_v) + { return myVertices.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myEdges.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCoEdges.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myWires.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myFaces.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myShells.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return mySolids.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCompounds.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCompSolids.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myProducts.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myOccurrences.MarkRemoved(theTypedId); + } Standard_ASSERT_RETURN(false, "MarkRemoved: unsupported node id type", false); }; @@ -401,21 +455,37 @@ bool BRepGraphInc_Storage::MarkRemovedRef(const BRepGraph_RefId theRefId) using TypeId = std::remove_cv_t; if constexpr (std::is_same_v) + { return myShellRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myFaceRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myWireRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCoEdgeRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myVertexRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return mySolidRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myChildRefs.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myOccurrenceRefs.MarkRemoved(theTypedId); + } Standard_ASSERT_RETURN(false, "MarkRemovedRef: unsupported ref id type", false); }; @@ -431,19 +501,33 @@ bool BRepGraphInc_Storage::MarkRemovedRep(const BRepGraph_RepId theRepId) using TypeId = std::remove_cv_t; if constexpr (std::is_same_v) + { return mySurfaces.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCurves3D.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myCurves2D.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myTriangulationsRep.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myPolygons3D.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myPolygons2D.MarkRemoved(theTypedId); + } else if constexpr (std::is_same_v) + { return myPolygonsOnTri.MarkRemoved(theTypedId); + } Standard_ASSERT_RETURN(false, "MarkRemovedRep: unsupported rep id type", false); }; @@ -480,74 +564,146 @@ void BRepGraphInc_Storage::BuildReverseIndex() myPolygons2D.NbActive = 0; myPolygonsOnTri.NbActive = 0; for (BRepGraph_VertexId aId = BRepGraph_VertexId::Start(); aId.IsValid(myVertices.Nb()); ++aId) + { if (!myVertices.Get(aId).IsRemoved) + { ++myVertices.NbActive; + } + } for (BRepGraph_EdgeId aId = BRepGraph_EdgeId::Start(); aId.IsValid(myEdges.Nb()); ++aId) + { if (!myEdges.Get(aId).IsRemoved) + { ++myEdges.NbActive; + } + } for (BRepGraph_CoEdgeId aId = BRepGraph_CoEdgeId::Start(); aId.IsValid(myCoEdges.Nb()); ++aId) + { if (!myCoEdges.Get(aId).IsRemoved) + { ++myCoEdges.NbActive; + } + } for (BRepGraph_WireId aId = BRepGraph_WireId::Start(); aId.IsValid(myWires.Nb()); ++aId) + { if (!myWires.Get(aId).IsRemoved) + { ++myWires.NbActive; + } + } for (BRepGraph_FaceId aId = BRepGraph_FaceId::Start(); aId.IsValid(myFaces.Nb()); ++aId) + { if (!myFaces.Get(aId).IsRemoved) + { ++myFaces.NbActive; + } + } for (BRepGraph_ShellId aId = BRepGraph_ShellId::Start(); aId.IsValid(myShells.Nb()); ++aId) + { if (!myShells.Get(aId).IsRemoved) + { ++myShells.NbActive; + } + } for (BRepGraph_SolidId aId = BRepGraph_SolidId::Start(); aId.IsValid(mySolids.Nb()); ++aId) + { if (!mySolids.Get(aId).IsRemoved) + { ++mySolids.NbActive; + } + } for (BRepGraph_CompoundId aId = BRepGraph_CompoundId::Start(); aId.IsValid(myCompounds.Nb()); ++aId) + { if (!myCompounds.Get(aId).IsRemoved) + { ++myCompounds.NbActive; + } + } for (BRepGraph_CompSolidId aId = BRepGraph_CompSolidId::Start(); aId.IsValid(myCompSolids.Nb()); ++aId) + { if (!myCompSolids.Get(aId).IsRemoved) + { ++myCompSolids.NbActive; + } + } for (BRepGraph_ProductId aId = BRepGraph_ProductId::Start(); aId.IsValid(myProducts.Nb()); ++aId) + { if (!myProducts.Get(aId).IsRemoved) + { ++myProducts.NbActive; + } + } for (BRepGraph_OccurrenceId aId = BRepGraph_OccurrenceId::Start(); aId.IsValid(myOccurrences.Nb()); ++aId) + { if (!myOccurrences.Get(aId).IsRemoved) + { ++myOccurrences.NbActive; + } + } for (BRepGraph_SurfaceRepId aId = BRepGraph_SurfaceRepId::Start(); aId.IsValid(mySurfaces.Nb()); ++aId) + { if (!mySurfaces.Get(aId).IsRemoved) + { ++mySurfaces.NbActive; + } + } for (BRepGraph_Curve3DRepId aId = BRepGraph_Curve3DRepId::Start(); aId.IsValid(myCurves3D.Nb()); ++aId) + { if (!myCurves3D.Get(aId).IsRemoved) + { ++myCurves3D.NbActive; + } + } for (BRepGraph_Curve2DRepId aId = BRepGraph_Curve2DRepId::Start(); aId.IsValid(myCurves2D.Nb()); ++aId) + { if (!myCurves2D.Get(aId).IsRemoved) + { ++myCurves2D.NbActive; + } + } for (BRepGraph_TriangulationRepId aId = BRepGraph_TriangulationRepId::Start(); aId.IsValid(myTriangulationsRep.Nb()); ++aId) + { if (!myTriangulationsRep.Get(aId).IsRemoved) + { ++myTriangulationsRep.NbActive; + } + } for (BRepGraph_Polygon3DRepId aId = BRepGraph_Polygon3DRepId::Start(); aId.IsValid(myPolygons3D.Nb()); ++aId) + { if (!myPolygons3D.Get(aId).IsRemoved) + { ++myPolygons3D.NbActive; + } + } for (BRepGraph_Polygon2DRepId aId = BRepGraph_Polygon2DRepId::Start(); aId.IsValid(myPolygons2D.Nb()); ++aId) + { if (!myPolygons2D.Get(aId).IsRemoved) + { ++myPolygons2D.NbActive; + } + } for (BRepGraph_PolygonOnTriRepId aId = BRepGraph_PolygonOnTriRepId::Start(); aId.IsValid(myPolygonsOnTri.Nb()); ++aId) + { if (!myPolygonsOnTri.Get(aId).IsRemoved) + { ++myPolygonsOnTri.NbActive; + } + } } //================================================================================================= diff --git a/src/ModelingData/TKBRep/BRepLProp/BRepLProp.cxx b/src/ModelingData/TKBRep/BRepLProp/BRepLProp.cxx index 944c744ae1..e1bc1cc703 100644 --- a/src/ModelingData/TKBRep/BRepLProp/BRepLProp.cxx +++ b/src/ModelingData/TKBRep/BRepLProp/BRepLProp.cxx @@ -39,17 +39,29 @@ GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, GeomAbs_Shape cont1 = C1.Continuity(), cont2 = C2.Continuity(); int n1 = 0, n2 = 0; if (cont1 >= 5) + { n1 = 3; + } else if (cont1 == 4) + { n1 = 2; + } else if (cont1 == 2) + { n1 = 1; + } if (cont2 >= 5) + { n2 = 3; + } else if (cont2 == 4) + { n2 = 2; + } else if (cont2 == 2) + { n2 = 1; + } BRepLProp_CLProps clp1(C1, u1, n1, tl); BRepLProp_CLProps clp2(C2, u2, n2, tl); if (!(clp1.Value().IsEqual(clp2.Value(), tl))) @@ -62,9 +74,13 @@ GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, d1 = clp1.D1(); d2 = clp2.D1(); if (C1.Edge().Orientation() == TopAbs_REVERSED) + { d1.Reverse(); + } if (C2.Edge().Orientation() == TopAbs_REVERSED) + { d2.Reverse(); + } if (d1.IsEqual(d2, tl, ta)) { cont = GeomAbs_C1; @@ -74,9 +90,13 @@ GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, clp1.Tangent(dir1); clp2.Tangent(dir2); if (C1.Edge().Orientation() == TopAbs_REVERSED) + { dir1.Reverse(); + } if (C2.Edge().Orientation() == TopAbs_REVERSED) + { dir2.Reverse(); + } if (dir1.IsEqual(dir2, ta)) { cont = GeomAbs_G1; @@ -100,7 +120,9 @@ GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, const TopoDS_Edge& E1 = C1.Edge(); const TopoDS_Edge& E2 = C2.Edge(); if (E1.IsSame(E2) && C1.IsPeriodic() && cont >= GeomAbs_G1) + { cont = GeomAbs_CN; + } return cont; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools.cxx index 1cb8f11bfa..3c9b6d5c9c 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools.cxx @@ -501,7 +501,9 @@ void BRepTools::UpdateFaceUVPoints(const TopoDS_Face& theF) const occ::handle& TE = *((occ::handle*)&aE.TShape()); if (TE->Locked()) + { return; + } const TopLoc_Location aELoc = aLoc.Predivided(aE.Location()); // Edge representations @@ -525,14 +527,20 @@ void BRepTools::UpdateFaceUVPoints(const TopoDS_Face& theF) bool BRepTools::Compare(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2) { if (V1.IsSame(V2)) + { return true; + } gp_Pnt p1 = BRep_Tool::Pnt(V1); gp_Pnt p2 = BRep_Tool::Pnt(V2); double l = p1.Distance(p2); if (l <= BRep_Tool::Tolerance(V1)) + { return true; + } if (l <= BRep_Tool::Tolerance(V2)) + { return true; + } return false; } @@ -590,7 +598,9 @@ void BRepTools::Map3DEdges(const TopoDS_Shape& for (Ex.Init(S, TopAbs_EDGE); Ex.More(); Ex.Next()) { if (!BRep_Tool::Degenerated(TopoDS::Edge(Ex.Current()))) + { M.Add(Ex.Current()); + } } } @@ -651,7 +661,9 @@ bool BRepTools::Write(const TopoDS_Shape& theShape, bool isGood = (aStream->good() && !aStream->eof()); if (!isGood) + { return isGood; + } BRepTools_ShapeSet SS(theWithTriangles, theWithNormals); SS.SetFormatNb(theVersion); @@ -690,7 +702,9 @@ bool BRepTools::Read(TopoDS_Shape& Sh, BRepTools_ShapeSet SS(B); SS.Read(*aStream, theProgress); if (!SS.NbShapes()) + { return false; + } SS.Read(Sh, *aStream); return true; } @@ -700,7 +714,9 @@ bool BRepTools::Read(TopoDS_Shape& Sh, void BRepTools::Clean(const TopoDS_Shape& theShape, const bool theForce) { if (theShape.IsNull()) + { return; + } BRep_Builder aBuilder; occ::handle aNullTriangulation; @@ -731,7 +747,9 @@ void BRepTools::Clean(const TopoDS_Shape& theShape, const bool theForce) const occ::handle& aTriangulation = BRep_Tool::Triangulation(aFace, aLoc); if (aTriangulation.IsNull()) + { continue; + } // Nullify edges // Theoretically, the edges on the face (with surface) may have no geometry @@ -805,7 +823,9 @@ void BRepTools::Clean(const TopoDS_Shape& theShape, const bool theForce) void BRepTools::CleanGeometry(const TopoDS_Shape& theShape) { if (theShape.IsNull()) + { return; + } BRep_Builder aBuilder; @@ -876,7 +896,9 @@ void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S) { occ::handle aSurface = CurveRep->Surface(); if (!UsedSurfaces.Contains(aSurface)) + { ToRemove = true; + } } else if (CurveRep->IsRegularity()) { @@ -886,9 +908,13 @@ void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S) } if (ToRemove) + { lcr.Remove(itrep); + } else + { itrep.Next(); + } } } } @@ -1213,9 +1239,13 @@ void BRepTools::DetectClosedness(const TopoDS_Face& theFace, bool& theUclosed, b gp_Pnt2d Point2 = PCurve2->Value(fpar); bool IsUiso = (std::abs(Point1.X() - Point2.X()) > std::abs(Point1.Y() - Point2.Y())); if (IsUiso) + { theUclosed = true; + } else + { theVclosed = true; + } } } } @@ -1347,12 +1377,18 @@ static void findInternalsToKeep( findInternalsToKeep(aSS, theAllNonInternals, theAllInternals, theShapesToKeep); if (aSS.Orientation() == TopAbs_INTERNAL) + { theAllInternals.Add(aSS); + } else + { theAllNonInternals.Add(aSS); + } if (theAllNonInternals.Contains(aSS) && theAllInternals.Contains(aSS)) + { theShapesToKeep.Add(aSS); + } } } @@ -1389,12 +1425,16 @@ static bool removeInternals( if (aSS.Orientation() == TopAbs_INTERNAL) { if (!theShapesToKeep || !theShapesToKeep->Contains(aSS)) + { aLRemove.Append(aSS); + } } else { if (removeInternals(*(TopoDS_Shape*)&aSS, theShapesToKeep)) + { aLRemove.Append(aSS); + } } } @@ -1428,7 +1468,9 @@ void BRepTools::RemoveInternals(TopoDS_Shape& theS, const bool theForce) NCollection_Map anAllNonInternals, anAllInternals; findInternalsToKeep(theS, anAllNonInternals, anAllInternals, aMKeep); if (aMKeep.Extent()) + { pMKeep = &aMKeep; + } } removeInternals(theS, pMKeep); @@ -1440,7 +1482,9 @@ void BRepTools::CheckLocations(const TopoDS_Shape& theS, NCollection_List& theProblemShapes) { if (theS.IsNull()) + { return; + } NCollection_IndexedMap aMapS; TopExp::MapShapes(theS, aMapS, false, false); diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_CopyModification.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_CopyModification.cxx index e00e08487f..59f0597d76 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_CopyModification.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_CopyModification.cxx @@ -41,7 +41,9 @@ bool BRepTools_CopyModification::NewSurface(const TopoDS_Face& theFace, theRevWires = theRevFace = false; if (!theSurf.IsNull() && myCopyGeom) + { theSurf = occ::down_cast(theSurf->Copy()); + } return true; } @@ -60,11 +62,15 @@ bool BRepTools_CopyModification::NewTriangulation(const TopoDS_Face& theTri = BRep_Tool::Triangulation(theFace, aLoc); if (theTri.IsNull()) + { return false; + } // mesh is copied if and only if the geometry need to be copied too if (myCopyGeom) + { theTri = theTri->Copy(); + } return true; } @@ -80,7 +86,9 @@ bool BRepTools_CopyModification::NewCurve(const TopoDS_Edge& theEdge, theTol = BRep_Tool::Tolerance(theEdge); if (!theCurve.IsNull() && myCopyGeom) + { theCurve = occ::down_cast(theCurve->Copy()); + } return true; } @@ -99,11 +107,15 @@ bool BRepTools_CopyModification::NewPolygon(const TopoDS_Edge& theEdge thePoly = BRep_Tool::Polygon3D(theEdge, aLoc); if (thePoly.IsNull()) + { return false; + } // polygon is copied if and only if the geometry need to be copied too if (myCopyGeom) + { thePoly = thePoly->Copy(); + } return true; } @@ -124,11 +136,15 @@ bool BRepTools_CopyModification::NewPolygonOnTriangulation( thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aTria, aLoc); if (thePoly.IsNull()) + { return false; + } // polygon is copied if and only if the geometry need to be copied too if (myCopyGeom) + { thePoly = thePoly->Copy(); + } return true; } @@ -157,7 +173,9 @@ bool BRepTools_CopyModification::NewCurve2d(const TopoDS_Edge& theEdge, theCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast); if (!theCurve.IsNull() && myCopyGeom) + { theCurve = occ::down_cast(theCurve->Copy()); + } return true; } @@ -170,7 +188,9 @@ bool BRepTools_CopyModification::NewParameter(const TopoDS_Vertex& theVertex, double& theTol) { if (theVertex.IsNull()) + { return false; // infinite edge may have Null vertex + } theTol = BRep_Tool::Tolerance(theVertex); thePnt = BRep_Tool::Parameter(theVertex, theEdge); diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_Debug.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_Debug.cxx index 074ee061f8..04e35b39b0 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_Debug.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_Debug.cxx @@ -33,9 +33,13 @@ const char* BRepTools_Write(const char* theFileStr, void* theShapePtr) { OCC_CATCH_SIGNALS if (BRepTools::Write(*(TopoDS_Shape*)theShapePtr, theFileStr)) + { return theFileStr; + } else + { return "Error: write failed"; + } } catch (Standard_Failure const& anException) { @@ -56,7 +60,7 @@ const char* BRepTools_Dump(void* theShapePtr) std::cout << "\n\n"; BRepTools::Dump(*(TopoDS_Shape*)theShapePtr, std::cout); - std::cout << std::endl; + std::cout << '\n'; return "Shape dumped to std::cout"; } @@ -81,7 +85,7 @@ const char* BRepTools_DumpLoc(void* theLocationPtr) TopTools_LocationSet LS; LS.Add(*(TopLoc_Location*)theLocationPtr); LS.Dump(std::cout); - std::cout << std::endl; + std::cout << '\n'; return "Location dumped to std::cout"; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_GTrsfModification.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_GTrsfModification.cxx index 4763935664..f09ec18d0d 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_GTrsfModification.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_GTrsfModification.cxx @@ -97,6 +97,7 @@ bool BRepTools_GTrsfModification::NewSurface(const TopoDS_Face& F, { occ::handle S2 = occ::down_cast(S); for (int i = 1; i <= S2->NbUPoles(); i++) + { for (int j = 1; j <= S2->NbVPoles(); j++) { gp_XYZ coor(S2->Pole(i, j).Coord()); @@ -104,11 +105,13 @@ bool BRepTools_GTrsfModification::NewSurface(const TopoDS_Face& F, gp_Pnt P(coor); S2->SetPole(i, j, P); } + } } else if (TheTypeS == STANDARD_TYPE(Geom_BezierSurface)) { occ::handle S2 = occ::down_cast(S); for (int i = 1; i <= S2->NbUPoles(); i++) + { for (int j = 1; j <= S2->NbVPoles(); j++) { gp_XYZ coor(S2->Pole(i, j).Coord()); @@ -116,6 +119,7 @@ bool BRepTools_GTrsfModification::NewSurface(const TopoDS_Face& F, gp_Pnt P(coor); S2->SetPole(i, j, P); } + } } else { @@ -342,6 +346,8 @@ bool BRepTools_GTrsfModification::NewPolygonOnTriangulation( thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aT, aLoc); if (!thePoly.IsNull()) + { thePoly = thePoly->Copy(); + } return true; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_History.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_History.cxx index ffa85dc491..fb396665b4 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_History.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_History.cxx @@ -185,7 +185,9 @@ bool BRepTools_History::IsRemoved(const TopoDS_Shape& theInitial) const void BRepTools_History::Merge(const occ::handle& theHistory23) { if (!theHistory23.IsNull()) + { Merge(*theHistory23.get()); + } } //================================================================================================= @@ -193,8 +195,10 @@ void BRepTools_History::Merge(const occ::handle& theHistory23 void BRepTools_History::Merge(const BRepTools_History& theHistory23) { if (!(theHistory23.HasModified() || theHistory23.HasGenerated() || theHistory23.HasRemoved())) + { // nothing to merge return; + } // Propagate R23 directly and M23 and G23 fully to M12 and G12. // Remember the propagated shapes. diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_Modifier.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_Modifier.cxx index 10c87da17c..dd95526eec 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_Modifier.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_Modifier.cxx @@ -122,7 +122,9 @@ void BRepTools_Modifier::Perform(const occ::handle& M, FillNewSurfaceInfo(M); if (!myMutableInput) + { CreateOtherVertices(aMVE, aMEF, M); + } bool aNewGeom; Rebuild(myShape, M, aNewGeom, aPS.Next()); @@ -260,7 +262,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, aNSinfo.myToler); result.Location(S.Location(), false); if (aNSinfo.myRevFace) + { ResOr = TopAbs_REVERSED; + } // set specifics flags of a Face B.NaturalRestriction(TopoDS::Face(result), BRep_Tool::NaturalRestriction(TopoDS::Face(S))); } @@ -269,8 +273,10 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, occ::handle aTriangulation; if (M->NewTriangulation(TopoDS::Face(S), aTriangulation)) { - if (rebuild) // the copied face already exists => update it + if (rebuild) + { // the copied face already exists => update it B.UpdateFace(TopoDS::Face(result), aTriangulation); + } else { // create new face with bare triangulation B.MakeFace(TopoDS::Face(result), aTriangulation); @@ -313,8 +319,10 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, occ::handle aPolygon; if (M->NewPolygon(TopoDS::Edge(S), aPolygon)) { - if (rebuild) // the copied edge already exists => update it + if (rebuild) + { // the copied edge already exists => update it B.UpdateEdge(TopoDS::Edge(result), aPolygon, S.Location()); + } else { // create new edge with bare polygon B.MakeEdge(TopoDS::Edge(result), aPolygon); @@ -338,7 +346,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, int aShapeCount = 0; { for (it.Initialize(S, false); it.More(); it.Next()) + { ++aShapeCount; + } } Message_ProgressScope aPS(theProgress, "Converting SubShapes", aShapeCount); @@ -358,7 +368,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, } } if (theNewGeom) + { myHasNewGeom.Add(S); + } // make an empty copy if (rebuild && !newgeom) @@ -389,7 +401,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, TopoDS_Face face = TopoDS::Face(S); TopAbs_Orientation fcor = face.Orientation(); if (fcor != TopAbs_REVERSED) + { fcor = TopAbs_FORWARD; + } TopExp_Explorer ex(face.Oriented(fcor), TopAbs_EDGE); for (; ex.More(); ex.Next()) @@ -425,7 +439,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, TopLoc_Location aLoc; TopoDS_Shape resface = (myMap.IsBound(face) ? myMap(face) : face); if (resface.IsNull()) + { resface = face; + } occ::handle aSurf = BRep_Tool::Surface(TopoDS::Face(resface), aLoc); // check other faces sharing the same surface TopExp_Explorer aExpF(myShape, TopAbs_FACE); @@ -433,10 +449,14 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, { TopoDS_Face anOther = TopoDS::Face(aExpF.Current()); if (anOther.IsSame(face)) + { continue; + } TopoDS_Shape resface2 = (myMap.IsBound(anOther) ? myMap(anOther) : anOther); if (resface2.IsNull()) + { resface2 = anOther; + } TopLoc_Location anOtherLoc; occ::handle anOtherSurf = BRep_Tool::Surface(TopoDS::Face(resface2), anOtherLoc); @@ -444,7 +464,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, { TopExp_Explorer aExpE(anOther, TopAbs_EDGE); for (; aExpE.More() && !isClosed; aExpE.Next()) + { isClosed = edge.IsSame(aExpE.Current()); + } } } } @@ -463,7 +485,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, CurE.Orientation(TopAbs_FORWARD); curve2d1 = BRep_Tool::CurveOnSurface(CurE, CurF, f, l); if (curve2d1.IsNull()) + { curve2d1 = new Geom2d_Line(gp::OX2d()); + } B.UpdateEdge(CurE, curve2d1, curve2d, CurF, 0.); } else @@ -471,7 +495,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, CurE.Orientation(TopAbs_REVERSED); curve2d1 = BRep_Tool::CurveOnSurface(CurE, CurF, f, l); if (curve2d1.IsNull()) + { curve2d1 = new Geom2d_Line(gp::OX2d()); + } B.UpdateEdge(CurE, curve2d, curve2d1, CurF, 0.); } currcurv = BRep_Tool::CurveOnSurface(CurE, CurF, f, l); @@ -542,13 +568,19 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, BRep_Tool::Triangulation(TopoDS::Face(myMap(face)), aLocation); TopoDS_Edge aNewEdge = TopoDS::Edge(myMap(edge)); if (aPolyOnTria_2.IsNull()) + { B.UpdateEdge(aNewEdge, aPolyOnTria_1, aNewFaceTria, aLocation); + } else { if (edge.Orientation() == TopAbs_FORWARD) + { B.UpdateEdge(aNewEdge, aPolyOnTria_1, aPolyOnTria_2, aNewFaceTria, aLocation); + } else + { B.UpdateEdge(aNewEdge, aPolyOnTria_2, aPolyOnTria_1, aNewFaceTria, aLocation); + } } } } @@ -562,7 +594,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, const TopoDS_Edge& edge = TopoDS::Edge(S); TopAbs_Orientation edor = edge.Orientation(); if (edor != TopAbs_REVERSED) + { edor = TopAbs_FORWARD; + } TopExp_Explorer ex(edge.Oriented(edor), TopAbs_VERTEX); while (ex.More()) { @@ -588,7 +622,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, aLocalVertex.Orientation(vtxrelat); // B.UpdateVertex(TopoDS::Vertex(myMap(vertex).Oriented(vtxrelat)), if (myMutableInput || !aLocalVertex.IsSame(vertex)) + { B.UpdateVertex(aLocalVertex, param, TopoDS::Edge(result), tol); + } ex.Next(); } } @@ -600,7 +636,9 @@ bool BRepTools_Modifier::Rebuild(const TopoDS_Shape& S, result.Infinite(S.Infinite()); } else + { result = S; + } // Set flag of the shape. result.Orientation(ResOr); @@ -633,7 +671,9 @@ void BRepTools_Modifier::CreateNewVertices( myHasNewGeom.Add(aV); } else if (myMutableInput) + { myMap(aV) = aV.Oriented(TopAbs_FORWARD); + } } } @@ -751,7 +791,9 @@ void BRepTools_Modifier::CreateOtherVertices( { const TopoDS_Edge& anE = TopoDS::Edge(it.Value()); if (myNCInfo.IsBound(anE) && !myNCInfo(anE).myCurve.IsNull()) + { toReplace = true; + } if (!toReplace) { @@ -776,9 +818,13 @@ void BRepTools_Modifier::CreateOtherVertices( } } if (toReplace) + { aNewV = TopoDS::Vertex(aV.EmptyCopied()); + } else + { aNewV = aV; + } aNewV.Orientation(TopAbs_FORWARD); myMap(aV) = aNewV; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_NurbsConvertModification.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_NurbsConvertModification.cxx index 5472d03e6a..812b35a09e 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_NurbsConvertModification.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_NurbsConvertModification.cxx @@ -183,11 +183,13 @@ static bool newParameter(const gp_Pnt2d& theUV, int aMinInd = 0; double aMinSqDist = Precision::Infinite(); for (int anIndex = 1; anIndex <= anExt.NbExt(); ++anIndex) + { if (anExt.SquareDistance(anIndex) < aMinSqDist) { aMinSqDist = anExt.SquareDistance(anIndex); aMinInd = anIndex; } + } if (aMinSqDist < theTol * theTol) { theParam = anExt.Point(aMinInd).Parameter(); @@ -263,13 +265,21 @@ bool BRepTools_NurbsConvertModification::NewSurface(const TopoDS_Face& F S->Bounds(surfU1, surfU2, surfV1, surfV2); if (std::abs(U1 - surfU1) <= TolPar) + { U1 = surfU1; + } if (std::abs(U2 - surfU2) <= TolPar) + { U2 = surfU2; + } if (std::abs(V1 - surfV1) <= TolPar) + { V1 = surfV1; + } if (std::abs(V2 - surfV2) <= TolPar) + { V2 = surfV2; + } if (!IsUp) { @@ -287,18 +297,24 @@ bool BRepTools_NurbsConvertModification::NewSurface(const TopoDS_Face& F { double Up = S->UPeriod(); if (U2 - U1 > Up) + { U2 = U1 + Up; + } } if (IsVp) { double Vp = S->VPeriod(); if (V2 - V1 > Vp) + { V2 = V1 + Vp; + } } if (std::abs(surfU1 - U1) > Tol || std::abs(surfU2 - U2) > Tol || std::abs(surfV1 - V1) > Tol || std::abs(surfV2 - V2) > Tol) + { S = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2); + } S->Bounds(surfU1, surfU2, surfV1, surfV2); S = GeomConvert::SurfaceToBSplineSurface(S); @@ -335,7 +351,9 @@ static bool IsConvert(const TopoDS_Edge& E) { occ::handle GC = occ::down_cast(itcr.Value()); if (GC.IsNull() || !GC->IsCurveOnSurface()) + { continue; + } occ::handle aSurface = GC->Surface(); occ::handle aCurve2d = GC->PCurve(); isConvert = ((!aSurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) @@ -370,7 +388,9 @@ bool BRepTools_NurbsConvertModification::NewTriangulation(const TopoDS_Face& gp_Pnt2d aUV = theTri->UVNode(anInd); gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y()); if (newUV(aPoint, aNewSurf, aTol, aUV)) + { theTri->SetUVNode(anInd, aUV); + } } } } @@ -425,10 +445,14 @@ bool BRepTools_NurbsConvertModification::NewCurve(const TopoDS_Edge& E, { } else + { C = new Geom_TrimmedCurve(C, f, l); + } } else + { C = new Geom_TrimmedCurve(C, f, l); + } // modification for WOK++ HP porting (fbi 14/03/97) // gp_Trsf trsf(L); @@ -548,9 +572,13 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E if (!C2d->IsPeriodic()) { if (fc - f2d > Precision::PConfusion()) + { f2d = fc; + } if (l2d - lc > Precision::PConfusion()) + { l2d = lc; + } } C2d = new Geom2d_TrimmedCurve(C2d, f2d, l2d); @@ -567,7 +595,9 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E C3d = BRep_Tool::Curve(E, f3d, l3d); } if (C3d.IsNull()) + { return false; + } GeomAdaptor_Curve G3dAC(C3d, f3d, l3d); occ::handle G3dAHC = new GeomAdaptor_Curve(G3dAC); @@ -600,7 +630,9 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E { occ::handle aNewS = BRep_Tool::Surface(newF); if (!aNewS.IsNull()) + { S = aNewS; + } } S->Bounds(Uinf, Usup, Vinf, Vsup); // Uinf -= 1e-9; Usup += 1e-9; Vinf -= 1e-9; Vsup += 1e-9; @@ -759,9 +791,13 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E occ::handle S; if (newF.IsNull()) + { S = BRep_Tool::Surface(F); + } else + { S = BRep_Tool::Surface(newF); + } // double newTol = BRepTools::EvalAndUpdateTol(newE, C3d, Curve2d, S, f3d, l3d); if (newTol > Tol) @@ -819,9 +855,13 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E if (uperiod < (Usup + 2 * u - Uinf)) { if (uperiod <= (Usup - Uinf)) + { u = 0; + } else + { u = (uperiod - (Usup - Uinf)) * 0.5; + } } } if (S->IsVPeriodic()) @@ -830,9 +870,13 @@ bool BRepTools_NurbsConvertModification::NewCurve2d(const TopoDS_Edge& E if (vperiod < (Vsup + 2 * v - Vinf)) { if (vperiod <= (Vsup - Vinf)) + { v = 0; + } else + { v = (vperiod - (Vsup - Vinf)) * 0.5; + } } } GeomAdaptor_Surface GAS(S, Uinf - u, Usup + u, Vinf - v, Vsup + v); @@ -936,7 +980,9 @@ bool BRepTools_NurbsConvertModification::NewParameter(const TopoDS_Vertex& V, { Tol = BRep_Tool::Tolerance(V); if (BRep_Tool::Degenerated(E)) + { return false; + } gp_Pnt pnt = BRep_Tool::Pnt(V); P = BRep_Tool::Parameter(V, E); diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_PurgeLocations.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_PurgeLocations.cxx index 639e9ffd41..eb0f95f98e 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_PurgeLocations.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_PurgeLocations.cxx @@ -44,7 +44,9 @@ bool BRepTools_PurgeLocations::Perform(const TopoDS_Shape& theShape) const TopLoc_Location& aLoc = myLocations.Location(ind); if (aLoc.IsIdentity()) + { break; + } const gp_Trsf& aTrsf = aLoc.Transformation(); bool isBadTrsf = @@ -195,6 +197,8 @@ TopoDS_Shape BRepTools_PurgeLocations::ModifiedShape(const TopoDS_Shape& theInit { TopoDS_Shape aShape = theInitShape; if (myMapNewShapes.IsBound(theInitShape)) + { aShape = myMapNewShapes.Find(theInitShape); + } return aShape; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_Quilt.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_Quilt.cxx index 343126910d..c6a0f3d894 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_Quilt.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_Quilt.cxx @@ -353,7 +353,9 @@ bool BRepTools_Quilt::IsCopied(const TopoDS_Shape& S) const return !S.IsSame(myBounds.FindFromKey(S)); } else + { return false; + } } //================================================================================================= @@ -403,8 +405,10 @@ TopoDS_Shape BRepTools_Quilt::Shells() const const TopoDS_Shape& Shape = myBounds.FindFromIndex(ii); // it.Value(); if (Shape.ShapeType() == TopAbs_FACE) { - for (TopExp_Explorer aExpEdg(Shape, TopAbs_EDGE); aExpEdg.More(); aExpEdg.Next()) // gka + for (TopExp_Explorer aExpEdg(Shape, TopAbs_EDGE); aExpEdg.More(); aExpEdg.Next()) + { // gka EdgesFaces.Add(aExpEdg.Current()); + } TopoDS_Shell SH; TopAbs_Orientation NewO; @@ -417,9 +421,13 @@ TopoDS_Shape BRepTools_Quilt::Shells() const { SH = TopoDS::Shell(M(E)); if (SH.Orientation() == E.Orientation()) + { NewO = TopAbs::Reverse(Shape.Orientation()); + } else + { NewO = Shape.Orientation(); + } MF.Bind(Shape, SH.Oriented(NewO)); break; @@ -456,7 +464,9 @@ TopoDS_Shape BRepTools_Quilt::Shells() const // Compare the orientation of E in SH and in oldshell. TopAbs_Orientation anOrien = E.Orientation(); if (MF(Shape).Orientation() == TopAbs_REVERSED) + { anOrien = TopAbs::Reverse(anOrien); + } bool Rev = (anOrien == oldShell.Orientation()); // if rev = True oldShell has to be reversed. @@ -468,9 +478,13 @@ TopoDS_Shape BRepTools_Quilt::Shells() const TopAbs_Orientation NewOFo; // update the orientation of Fo in SH. if (Rev) + { NewOFo = TopAbs::Reverse(MF(Fo).Orientation()); + } else + { NewOFo = MF(Fo).Orientation(); + } MF.Bind(Fo, SH.Oriented(NewOFo)); // B.Add (SH.Oriented(TopAbs_FORWARD),Fo.Oriented(NewO)); @@ -486,16 +500,22 @@ TopoDS_Shape BRepTools_Quilt::Shells() const // TopTools_ShapeMapHasher>::Iterator itm(M); // itm.More(); ) { if (!M.IsBound(aexp.Current())) + { continue; + } const TopoDS_Shape& ae = aexp.Current(); TopoDS_Shape as = M.Find(ae); if (as.IsSame(oldShell)) { // update the orientation of free edges in SH. if (Rev) + { NewO = TopAbs::Reverse(as.Orientation()); + } else + { NewO = as.Orientation(); + } M.Bind(ae, SH.Oriented(NewO)); } @@ -506,10 +526,14 @@ TopoDS_Shape BRepTools_Quilt::Shells() const // Test if SH is always orientable. TopAbs_Orientation anOrien = E.Orientation(); if (MF(Shape).Orientation() == TopAbs_REVERSED) + { anOrien = TopAbs::Reverse(anOrien); + } if (M(E).Orientation() == anOrien) + { SH.Orientable(false); + } // remove the edge from M (no more a free edge) M.UnBind(E); @@ -518,11 +542,17 @@ TopoDS_Shape BRepTools_Quilt::Shells() const { NewO = E.Orientation(); if (MF(Shape).Orientation() == TopAbs_REVERSED) + { NewO = TopAbs::Reverse(NewO); + } if (!E.IsNull()) + { M.Bind(E, SH.Oriented(NewO)); + } else + { continue; + } } } @@ -530,7 +560,9 @@ TopoDS_Shape BRepTools_Quilt::Shells() const SH.Free(false); } else + { MapOtherShape.Add(Shape); + } // it.Next(); } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_ReShape.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_ReShape.cxx index c2b723e003..6b074d5734 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_ReShape.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_ReShape.cxx @@ -73,21 +73,28 @@ static void CopyRanges(const TopoDS_Shape& toedge, { occ::handle fromGC = occ::down_cast(fromitcr.Value()); if (fromGC.IsNull()) + { continue; + } bool isC3d = fromGC->IsCurve3D(); if (isC3d) { if (fromGC->Curve3D().IsNull()) + { continue; + } } else { if (fromGC->PCurve().IsNull()) + { continue; + } } // clang-format off - if ( ! isC3d && ! fromGC->IsCurveOnSurface()) continue; // only 3d curves and pcurves are treated + if ( ! isC3d && ! fromGC->IsCurveOnSurface()) { continue; // only 3d curves and pcurves are treated +} // clang-format on occ::handle surface; @@ -105,14 +112,20 @@ static void CopyRanges(const TopoDS_Shape& toedge, { toGC = occ::down_cast(toitcr.Value()); if (toGC.IsNull()) + { continue; + } if (isC3d) { if (!toGC->IsCurve3D()) + { continue; + } } else if (!toGC->IsCurveOnSurface() || surface != toGC->Surface() || L != toGC->Location()) + { continue; + } double first = fromGC->First(); double last = fromGC->Last(); double len = last - first; @@ -155,7 +168,9 @@ void BRepTools_ReShape::replace(const TopoDS_Shape& ashape, TopoDS_Shape shape = ashape; TopoDS_Shape newshape = anewshape; if (shape.IsNull() || shape == newshape) + { return; + } if (shape.Orientation() == TopAbs_REVERSED) { @@ -204,14 +219,18 @@ void BRepTools_ReShape::replace(const TopoDS_Shape& ashape, { const TopoDS_Shape aNext = Value(aProbe); if (aNext.IsNull() || aNext.IsSame(aProbe)) + { break; + } if (aNext.IsPartner(shape)) { aCycle = true; break; } if (!aSeen.Add(aNext.TShape())) + { break; // existing cycle in data - not ours to introduce, bail + } aProbe = aNext; } if (aCycle) @@ -238,7 +257,9 @@ bool BRepTools_ReShape::IsRecorded(const TopoDS_Shape& ashape) const shape.Location(nullLoc); } if (shape.IsNull()) + { return false; + } return myShapeToReplacement.IsBound(shape); } @@ -248,7 +269,9 @@ TopoDS_Shape BRepTools_ReShape::Value(const TopoDS_Shape& ashape) const { TopoDS_Shape res; if (ashape.IsNull()) + { return res; + } TopoDS_Shape shape = ashape; if (myConsiderLocation) { @@ -272,16 +295,22 @@ TopoDS_Shape BRepTools_ReShape::Value(const TopoDS_Shape& ashape) const } // for INTERNAL/EXTERNAL, since they are not fully supported, keep orientation if (shape.Orientation() == TopAbs_INTERNAL || shape.Orientation() == TopAbs_EXTERNAL) + { res.Orientation(shape.Orientation()); + } if (myConsiderLocation) { // sln 29.11.01 Bug22: Recalculate location of resulting shape in accordance with // whether result is from map or not if (fromMap) + { res.Location(ashape.Location() * res.Location(), false); + } else + { res.Location(ashape.Location(), false); + } } return res; @@ -292,7 +321,9 @@ TopoDS_Shape BRepTools_ReShape::Value(const TopoDS_Shape& ashape) const TopoDS_Shape BRepTools_ReShape::ValueLeaf(const TopoDS_Shape& theShape) const { if (theShape.IsNull()) + { return TopoDS_Shape(); + } // Track visited shapes by their underlying TShape. Rationale: the replacement map keys // entries via TopTools_ShapeMapHasher (orientation-ignoring IsSame) and, when @@ -308,9 +339,13 @@ TopoDS_Shape BRepTools_ReShape::ValueLeaf(const TopoDS_Shape& theShape) const { const TopoDS_Shape aNext = Value(aCurrent); if (aNext.IsNull()) + { return aNext; + } if (aNext.IsSame(aCurrent)) + { return aNext; + } if (!aVisited.Add(aNext.TShape())) { // Cycle in replacement data - return current best to avoid looping. @@ -352,9 +387,13 @@ int BRepTools_ReShape::Status(const TopoDS_Shape& ashape, TopoDS_Shape& newsh, c if (res > 0) { if (newsh.IsNull()) + { res = -1; + } else if (newsh.IsEqual(shape)) + { res = 0; + } else if (last && ((myConsiderLocation && !newsh.IsPartner(shape)) || (!myConsiderLocation && !newsh.IsSame(shape)))) @@ -367,9 +406,13 @@ int BRepTools_ReShape::Status(const TopoDS_Shape& ashape, TopoDS_Shape& newsh, c // not correspond to way of storing information in the maps. newsh = Apply(shape, TopAbs_SHAPE); if (newsh.IsNull()) + { res = -1; + } if (newsh.IsEqual(shape)) + { res = 0; + } } } if (myConsiderLocation && !newsh.IsNull()) @@ -445,7 +488,9 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& { myStatus = EncodeStatus(0); // ShapeExtend::EncodeStatus ( ShapeExtend_OK ); if (shape.IsNull()) + { return shape; + } // apply direct replacement TopoDS_Shape newsh = Value(shape); @@ -461,7 +506,9 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& // stack, its replacement must be a compound that transitively contains it. // Return the direct replacement without descending to break the cycle. if (theInFlight.Contains(shape.TShape())) + { return newsh; + } // if shape replaced, apply modifications to the result recursively if ((myConsiderLocation && !newsh.IsPartner(shape)) @@ -476,9 +523,13 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& TopAbs_ShapeEnum st = shape.ShapeType(); if (st > until || (st == until && until > TopAbs_COMPOUND)) + { return newsh; // stopping criteria + } if (st == TopAbs_VERTEX || st == TopAbs_SHAPE) + { return shape; + } // define allowed types of components // fix for SAMTECH bug OCC322 about absent internal vertices after sewing. /* @@ -512,8 +563,10 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& newsh = applyImpl(sh, until, theInFlight); if (newsh != sh) { - if (myStatus & EncodeStatus(4)) // ShapeExtend::DecodeStatus ( myStatus, ShapeExtend_DONE4 ) ) + if (myStatus & EncodeStatus(4)) + { // ShapeExtend::DecodeStatus ( myStatus, ShapeExtend_DONE4 ) ) locStatus |= EncodeStatus(4); //|= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 ); + } modif = true; } if (newsh.IsNull()) @@ -522,7 +575,9 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& continue; } if (isEmpty) + { isEmpty = false; + } locStatus |= EncodeStatus(3); // ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 ); if (st == TopAbs_COMPOUND || newsh.ShapeType() == sh.ShapeType()) { // fix for SAMTECH bug OCC322 about absent internal vertices after sewing. @@ -534,15 +589,19 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& { const TopoDS_Shape& subsh = subit.Value(); // clang-format off - if ( subsh.ShapeType() == sh.ShapeType() ) B.Add ( result, subsh );//fix for SAMTECH bug OCC322 about absent internal vertices after sewing. - else locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 ); + if ( subsh.ShapeType() == sh.ShapeType() ) { B.Add ( result, subsh );//fix for SAMTECH bug OCC322 about absent internal vertices after sewing. + } else { locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 ); +} } - if ( ! nitems ) locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 ); + if ( ! nitems ) { locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 ); +} // clang-format on } theInFlight.Remove(shape.TShape()); if (!modif) + { return shape; + } // For empty topological containers (any kind of shape except vertex, edge // and face) we have to produce an empty result @@ -567,7 +626,9 @@ TopoDS_Shape BRepTools_ReShape::applyImpl(const TopoDS_Shape& } } else if (st == TopAbs_WIRE || st == TopAbs_SHELL) + { result.Closed(BRep_Tool::IsClosed(result)); + } result.Orientation(orien); } @@ -607,7 +668,9 @@ TopoDS_Vertex BRepTools_ReShape::CopyVertex(const TopoDS_Vertex& theV, B.UpdateVertex(aVertexCopy, theNewPos, aNewTol); if (!isRecorded) + { Replace(theV, aVertexCopy); + } return aVertexCopy; } diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_ShapeSet.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_ShapeSet.cxx index 9280ffc711..a6b067eeb4 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_ShapeSet.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_ShapeSet.cxx @@ -161,7 +161,9 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S) myCurves2d.Add(CR->PCurve()); ChangeLocations().Add(CR->Location()); if (CR->IsCurveOnClosedSurface()) + { myCurves2d.Add(CR->PCurve2()); + } } else if (CR->IsRegularity()) { @@ -192,7 +194,9 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S) myNodes.Add(CR->PolygonOnTriangulation()); ChangeLocations().Add(CR->Location()); if (CR->IsPolygonOnClosedTriangulation()) + { myNodes.Add(CR->PolygonOnTriangulation2()); + } } else if (CR->IsPolygonOnSurface()) { @@ -200,7 +204,9 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S) myPolygons2D.Add(CR->Polygon()); ChangeLocations().Add(CR->Location()); if (CR->IsPolygonOnClosedSurface()) + { myPolygons2D.Add(CR->Polygon2()); + } } } itrc.Next(); @@ -225,7 +231,9 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S) { // for XML Persistence occ::handle Tr = TF->Triangulation(); if (!Tr.IsNull()) + { myTriangulations.Add(Tr, needNormals); + } } ChangeLocations().Add(TF->Location()); @@ -254,23 +262,33 @@ void BRepTools_ShapeSet::WriteGeometry(Standard_OStream& OS, myCurves2d.Write(OS, aPS.Next(20)); if (aPS.UserBreak()) + { return; + } myCurves.Write(OS, aPS.Next(20)); if (aPS.UserBreak()) + { return; + } WritePolygon3D(OS, true, aPS.Next(10)); if (aPS.UserBreak()) + { return; + } WritePolygonOnTriangulation(OS, true, aPS.Next(10)); if (aPS.UserBreak()) + { return; + } mySurfaces.Write(OS, aPS.Next(20)); if (aPS.UserBreak()) + { return; + } WriteTriangulation(OS, true, aPS.Next(20)); } @@ -285,23 +303,33 @@ void BRepTools_ShapeSet::ReadGeometry(Standard_IStream& IS, myCurves2d.Read(IS, aPS.Next(20)); if (aPS.UserBreak()) + { return; + } myCurves.Read(IS, aPS.Next(20)); if (aPS.UserBreak()) + { return; + } ReadPolygon3D(IS, aPS.Next(15)); if (aPS.UserBreak()) + { return; + } ReadPolygonOnTriangulation(IS, aPS.Next(15)); if (aPS.UserBreak()) + { return; + } mySurfaces.Read(IS, aPS.Next(15)); if (aPS.UserBreak()) + { return; + } ReadTriangulation(IS, aPS.Next(15)); } @@ -384,7 +412,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O } if (!PR->Location().IsIdentity()) + { OS << " location " << Locations().Index(PR->Location()); + } OS << "\n"; itrp.Next(); @@ -400,11 +430,17 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O // Dump the curve geometry OS << " Tolerance : " << TE->Tolerance() << "\n"; if (TE->SameParameter()) + { OS << " same parametrisation of curves\n"; + } if (TE->SameRange()) + { OS << " same range on curves\n"; + } if (TE->Degenerated()) + { OS << " degenerated\n"; + } double first, last; NCollection_List>::Iterator itrc = TE->Curves(); @@ -419,7 +455,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O { OS << " - Curve 3D : " << myCurves.Index(CR->Curve3D()); if (!CR->Location().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location()); + } OS << ", range : " << first << " " << last << "\n"; } } @@ -437,7 +475,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O } OS << " on surface " << mySurfaces.Index(CR->Surface()); if (!CR->Location().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location()); + } OS << ", range : " << first << " " << last << "\n"; occ::handle COS = occ::down_cast(CR); @@ -459,10 +499,14 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O PrintRegularity(CR->Continuity(), OS); OS << " on surfaces : " << mySurfaces.Index(CR->Surface()); if (!CR->Location().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location()); + } OS << ", " << mySurfaces.Index(CR->Surface2()); if (!CR->Location2().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location2()); + } OS << "\n"; } else if (CR->IsPolygon3D()) @@ -472,7 +516,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O { OS << " - Polygon 3D : " << myPolygons3D.FindIndex(CR->Polygon3D()); if (!CR->Location().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location()); + } } } else if (CR->IsPolygonOnTriangulation()) @@ -484,7 +530,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O } OS << " on triangulation " << myTriangulations.FindIndex(CR->Triangulation()); if (!CR->Location().IsIdentity()) + { OS << " location " << Locations().Index(CR->Location()); + } OS << "\n"; } itrc.Next(); @@ -496,7 +544,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O const TopoDS_Face& F = TopoDS::Face(S); if (BRep_Tool::NaturalRestriction(F)) + { OS << "NaturalRestriction\n"; + } // Dump the surface geometry occ::handle TF = occ::down_cast(S.TShape()); @@ -505,7 +555,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O OS << " Tolerance : " << TF->Tolerance() << "\n"; OS << " - Surface : " << mySurfaces.Index(TF->Surface()); if (!S.Location().IsIdentity()) + { OS << " location " << Locations().Index(S.Location()); + } OS << "\n"; } if (!(TF->Triangulation()).IsNull()) @@ -513,7 +565,9 @@ void BRepTools_ShapeSet::DumpGeometry(const TopoDS_Shape& S, Standard_OStream& O // Dump the triangulation OS << " - Triangulation : " << myTriangulations.FindIndex(TF->Triangulation()); if (!S.Location().IsIdentity()) + { OS << " location " << Locations().Index(TF->Location()); + } OS << "\n"; } } @@ -605,9 +659,13 @@ void BRepTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S, Standard_OStream& occ::handle GC = occ::down_cast(itrc.Value()); GC->Range(first, last); if (!CR->IsCurveOnClosedSurface()) + { OS << "2 "; // -2- Curve on surf + } else + { OS << "3 "; // -3- Curve on closed surf + } OS << " " << myCurves2d.Index(CR->PCurve()); if (CR->IsCurveOnClosedSurface()) { @@ -666,9 +724,13 @@ void BRepTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S, Standard_OStream& occ::handle PT = occ::down_cast(itrc.Value()); if (!CR->IsPolygonOnClosedTriangulation()) + { OS << "6 "; // -6- Polygon on triangulation + } else + { OS << "7 "; // -7- Polygon on closed triangulation + } OS << " " << myNodes.FindIndex(PT->PolygonOnTriangulation()); if (CR->IsPolygonOnClosedTriangulation()) { @@ -817,7 +879,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // Modified by Sergey KHROMOV - Wed Apr 24 13:59:09 2002 Begin if (myCurves.Curve(c).IsNull()) + { break; + } // Modified by Sergey KHROMOV - Wed Apr 24 13:59:13 2002 End occ::handle POC = new BRep_PointOnCurve(p1, myCurves.Curve(c), L); @@ -830,7 +894,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // Modified by Sergey KHROMOV - Wed Apr 24 13:59:09 2002 Begin if (myCurves2d.Curve2d(pc).IsNull() || mySurfaces.Surface(s).IsNull()) + { break; + } // Modified by Sergey KHROMOV - Wed Apr 24 13:59:13 2002 End occ::handle POC = @@ -845,7 +911,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // Modified by Sergey KHROMOV - Wed Apr 24 13:59:09 2002 Begin if (mySurfaces.Surface(s).IsNull()) + { break; + } // Modified by Sergey KHROMOV - Wed Apr 24 13:59:13 2002 End occ::handle POC = @@ -941,12 +1009,15 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // Modified by Sergey KHROMOV - Wed Apr 24 12:11:16 2002 Begin if (myCurves2d.Curve2d(pc).IsNull() || (closed && myCurves2d.Curve2d(pc2).IsNull()) || mySurfaces.Surface(s).IsNull()) + { break; + } // Modified by Sergey KHROMOV - Wed Apr 24 12:11:17 2002 End if (closed) { if (FormatNb() == TopTools_FormatVersion_VERSION_2) + { myBuilder.UpdateEdge(E, myCurves2d.Curve2d(pc), myCurves2d.Curve2d(pc2), @@ -955,13 +1026,16 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, tol, aPf, aPl); + } else + { myBuilder.UpdateEdge(E, myCurves2d.Curve2d(pc), myCurves2d.Curve2d(pc2), mySurfaces.Surface(s), Locations().Location(l), tol); + } myBuilder.Continuity(E, mySurfaces.Surface(s), @@ -973,6 +1047,7 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, else { if (FormatNb() == TopTools_FormatVersion_VERSION_2) + { myBuilder.UpdateEdge(E, myCurves2d.Curve2d(pc), mySurfaces.Surface(s), @@ -980,12 +1055,15 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, tol, aPf, aPl); + } else + { myBuilder.UpdateEdge(E, myCurves2d.Curve2d(pc), mySurfaces.Surface(s), Locations().Location(l), tol); + } } myBuilder.Range(E, mySurfaces.Surface(s), Locations().Location(l), first, last); break; @@ -995,7 +1073,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, IS >> s >> l >> s2 >> l2; // Modified by Sergey KHROMOV - Wed Apr 24 12:39:13 2002 Begin if (mySurfaces.Surface(s).IsNull() || mySurfaces.Surface(s2).IsNull()) + { break; + } // Modified by Sergey KHROMOV - Wed Apr 24 12:39:14 2002 End myBuilder.Continuity(E, mySurfaces.Surface(s), @@ -1010,9 +1090,11 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // szy-02.05.2004 // myBuilder.UpdateEdge(E,occ::down_cast(myPolygons3D(c))); if (c > 0 && c <= myPolygons3D.Extent()) + { myBuilder.UpdateEdge(E, occ::down_cast(myPolygons3D(c)), Locations().Location(l)); + } break; case 6: @@ -1028,19 +1110,23 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, { if (t > 0 && t <= myTriangulations.Extent() && pt > 0 && pt <= myNodes.Extent() && pt2 > 0 && pt2 <= myNodes.Extent()) + { myBuilder.UpdateEdge(E, occ::down_cast(myNodes(pt)), occ::down_cast(myNodes(pt2)), myTriangulations.FindKey(t), Locations().Location(l)); + } } else { if (t > 0 && t <= myTriangulations.Extent() && pt > 0 && pt <= myNodes.Extent()) + { myBuilder.UpdateEdge(E, occ::down_cast(myNodes(pt)), myTriangulations.FindKey(t), Locations().Location(l)); + } } // range @@ -1097,7 +1183,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // BUC60769 if (val == 2) + { break; + } char string[260]; IS.getline(string, 256, '\n'); @@ -1108,7 +1196,9 @@ void BRepTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T, // cas triangulation s = atoi(&string[2]); if (s > 0 && s <= myTriangulations.Extent()) + { myBuilder.UpdateFace(TopoDS::Face(S), myTriangulations.FindKey(s)); + } } // else IS.seekg(pos); } @@ -1179,7 +1269,9 @@ void BRepTools_ShapeSet::WritePolygonOnTriangulation(Standard_OStream& Message_ProgressScope aPS(theProgress, "Polygons On Triangulation", nbpOntri); if (Compact) + { OS << "PolygonOnTriangulations " << nbpOntri << "\n"; + } else { OS << " -------\n"; @@ -1198,24 +1290,36 @@ void BRepTools_ShapeSet::WritePolygonOnTriangulation(Standard_OStream& OS << " " << i << " : PolygonOnTriangulation with " << Nodes.Length() << " Nodes\n"; } else + { OS << Nodes.Length() << " "; + } if (!Compact) + { OS << " "; + } for (j = 1; j <= Nodes.Length(); j++) + { OS << Nodes.Value(j) << " "; + } OS << "\n"; // writing parameters: Param = Poly->Parameters(); if (Compact) + { OS << "p "; + } // write the deflection if (!Compact) + { OS << " Deflection : "; + } OS << Poly->Deflection() << " "; if (!Compact) + { OS << "\n"; + } if (!Param.IsNull()) { @@ -1224,15 +1328,23 @@ void BRepTools_ShapeSet::WritePolygonOnTriangulation(Standard_OStream& OS << " Parameters :"; } else + { OS << "1 "; + } if (!Compact) + { OS << " "; + } for (j = 1; j <= Param->Length(); j++) + { OS << Param->Value(j) << " "; + } OS << "\n"; } else + { OS << "0 \n"; + } } } @@ -1251,7 +1363,9 @@ void BRepTools_ShapeSet::ReadPolygonOnTriangulation(Standard_IStream& char buffer[255]; IS >> buffer; if (strstr(buffer, "PolygonOnTriangulations") == nullptr) + { return; + } int i, j, val, nbpol = 0, nbnodes = 0; int hasparameters; double par; @@ -1285,7 +1399,9 @@ void BRepTools_ShapeSet::ReadPolygonOnTriangulation(Standard_IStream& Poly = new Poly_PolygonOnTriangulation(Nodes, Param1); } else + { Poly = new Poly_PolygonOnTriangulation(Nodes); + } Poly->Deflection(def); // } // else { @@ -1309,7 +1425,9 @@ void BRepTools_ShapeSet::WritePolygon3D(Standard_OStream& OS, Message_ProgressScope aPS(theProgress, "3D Polygons", nbpol); if (Compact) + { OS << "Polygon3D " << nbpol << "\n"; + } else { OS << " -------\n"; @@ -1334,39 +1452,57 @@ void BRepTools_ShapeSet::WritePolygon3D(Standard_OStream& OS, // write the deflection if (!Compact) + { OS << "Deflection : "; + } OS << P->Deflection() << "\n"; // write the nodes if (!Compact) + { OS << "\nNodes :\n"; + } int i1, nbNodes = P->NbNodes(); const NCollection_Array1& Nodes = P->Nodes(); for (j = 1; j <= nbNodes; j++) { if (!Compact) + { OS << std::setw(10) << j << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << Nodes(j).X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << Nodes(j).Y() << " "; if (!Compact) + { OS << std::setw(17); + } OS << Nodes(j).Z(); if (!Compact) + { OS << "\n"; + } else + { OS << " "; + } } OS << "\n"; if (P->HasParameters()) { if (!Compact) + { OS << "\nParameters :\n"; + } const NCollection_Array1& Param = P->Parameters(); for (i1 = 1; i1 <= nbNodes; i1++) { @@ -1396,7 +1532,9 @@ void BRepTools_ShapeSet::ReadPolygon3D(Standard_IStream& IS, IS >> buffer; if (strstr(buffer, "Polygon3D") == nullptr) + { return; + } occ::handle P; IS >> nbpol; // OCC19559 @@ -1424,7 +1562,9 @@ void BRepTools_ShapeSet::ReadPolygon3D(Standard_IStream& IS, P = new Poly_Polygon3D(Nodes, Param); } else + { P = new Poly_Polygon3D(Nodes); + } P->Deflection(d); myPolygons3D.Add(P); } @@ -1442,7 +1582,9 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS, Message_ProgressScope aPS(theProgress, "Triangulations", nbtri); if (Compact) + { OS << "Triangulations " << nbtri << "\n"; + } else { OS << " -------\n"; @@ -1480,78 +1622,120 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS, // write the deflection if (!Compact) + { OS << " Deflection : "; + } OS << T->Deflection() << "\n"; // write the 3d nodes if (!Compact) + { OS << "\n3D Nodes :\n"; + } nbNodes = T->NbNodes(); for (j = 1; j <= nbNodes; j++) { const gp_Pnt aNode = T->Node(j); if (!Compact) + { OS << std::setw(10) << j << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << aNode.X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode.Y() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode.Z(); if (!Compact) + { OS << "\n"; + } else + { OS << " "; + } } if (T->HasUVNodes()) { if (!Compact) + { OS << "\nUV Nodes :\n"; + } for (j = 1; j <= nbNodes; j++) { const gp_Pnt2d aNode2d = T->UVNode(j); if (!Compact) + { OS << std::setw(10) << j << " : "; + } if (!Compact) + { OS << std::setw(17); + } OS << aNode2d.X() << " "; if (!Compact) + { OS << std::setw(17); + } OS << aNode2d.Y(); if (!Compact) + { OS << "\n"; + } else + { OS << " "; + } } } if (!Compact) + { OS << "\nTriangles :\n"; + } nbTriangles = T->NbTriangles(); for (j = 1; j <= nbTriangles; j++) { if (!Compact) + { OS << std::setw(10) << j << " : "; + } T->Triangle(j).Get(n1, n2, n3); if (!Compact) + { OS << std::setw(10); + } OS << n1 << " "; if (!Compact) + { OS << std::setw(10); + } OS << n2 << " "; if (!Compact) + { OS << std::setw(10); + } OS << n3; if (!Compact) + { OS << "\n"; + } else + { OS << " "; + } } if (FormatNb() >= TopTools_FormatVersion_VERSION_3) @@ -1559,7 +1743,9 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS, if (T->HasNormals() && toWriteNormals) { if (!Compact) + { OS << "\nNormals :\n"; + } for (j = 1; j <= nbNodes; j++) { if (!Compact) @@ -1604,7 +1790,9 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, IS >> buffer; if (strstr(buffer, "Triangulations") == nullptr) + { return; + } IS >> nbtri; // OCC19559 diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_Substitution.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_Substitution.cxx index 90112a317f..72b7f05255 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_Substitution.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_Substitution.cxx @@ -51,7 +51,9 @@ void BRepTools_Substitution::Substitute(const TopoDS_Shape& OS void BRepTools_Substitution::Build(const TopoDS_Shape& S) { if (IsCopied(S)) + { return; + } BRep_Builder B; TopoDS_Iterator iteS(S.Oriented(TopAbs_FORWARD)); @@ -120,10 +122,12 @@ void BRepTools_Substitution::Build(const TopoDS_Shape& S) { if (NewS.ShapeType() == TopAbs_WIRE || NewS.ShapeType() == TopAbs_SHELL || NewS.ShapeType() == TopAbs_SOLID || NewS.ShapeType() == TopAbs_COMPOUND) + { //----------------------------------------------------------------- // Wire,Solid,Shell,Compound must have subshape else they disappear //----------------------------------------------------------------- NewS.Nullify(); + } } } NCollection_List L; @@ -132,7 +136,9 @@ void BRepTools_Substitution::Build(const TopoDS_Shape& S) // so NewS is bound with orientation FORWARD. //------------------------------------------------------- if (!NewS.IsNull()) + { L.Append(NewS.Oriented(TopAbs_FORWARD)); + } Substitute(S, L); } @@ -143,12 +149,18 @@ bool BRepTools_Substitution::IsCopied(const TopoDS_Shape& S) const if (myMap.IsBound(S)) { if (myMap(S).IsEmpty()) + { return true; + } else + { return !S.IsSame(myMap(S).First()); + } } else + { return false; + } } //================================================================================================= diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_TrsfModification.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_TrsfModification.cxx index 2bb8cb083a..a8c9068168 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_TrsfModification.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_TrsfModification.cxx @@ -330,12 +330,16 @@ bool BRepTools_TrsfModification::NewCurve2d(const TopoDS_Edge& E, } GeomAdaptor_Surface GAsurf(S); if (GAsurf.GetType() == GeomAbs_Plane) + { return false; + } double f, l; occ::handle NewC = BRep_Tool::CurveOnSurface(E, F, f, l); if (NewC.IsNull()) + { return false; + } double newf, newl; @@ -352,9 +356,13 @@ bool BRepTools_TrsfModification::NewCurve2d(const TopoDS_Edge& E, if (!NewC->IsPeriodic()) { if (fc - f > Precision::PConfusion()) + { f = fc; + } if (l - lc > Precision::PConfusion()) + { l = lc; + } if (std::abs(l - f) < Precision::PConfusion()) { if (std::abs(f - fc) < Precision::PConfusion() && !Precision::IsInfinite(lc)) @@ -408,7 +416,9 @@ bool BRepTools_TrsfModification::NewParameter(const TopoDS_Vertex& V, double& Tol) { if (V.IsNull()) + { return false; // infinite edge may have Null vertex + } TopLoc_Location loc; Tol = BRep_Tool::Tolerance(V); diff --git a/src/ModelingData/TKBRep/BRepTools/BRepTools_WireExplorer.cxx b/src/ModelingData/TKBRep/BRepTools/BRepTools_WireExplorer.cxx index f94ce3a3fb..4335c1f94a 100644 --- a/src/ModelingData/TKBRep/BRepTools/BRepTools_WireExplorer.cxx +++ b/src/ModelingData/TKBRep/BRepTools/BRepTools_WireExplorer.cxx @@ -96,7 +96,9 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, const TopoDS_Face& F) myDoubles.Clear(); if (W.IsNull()) + { return; + } double UMin(0.0), UMax(0.0), VMin(0.0), VMax(0.0); if (!F.IsNull()) @@ -129,7 +131,9 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, myDoubles.Clear(); if (W.IsNull()) + { return; + } myFace = F; double dfVertToler = 0.; @@ -150,11 +154,15 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, { // Use tolerance of edges for (TopoDS_Iterator it(W); it.More(); it.Next()) + { dfVertToler = std::max(BRep_Tool::Tolerance(TopoDS::Edge(it.Value())), dfVertToler); + } if (dfVertToler < Precision::Confusion()) + { // empty wire return; + } } myTolU = 2. * aGAS.UResolution(dfVertToler); myTolV = 2. * aGAS.VResolution(dfVertToler); @@ -169,16 +177,24 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, double a = aD1U.Magnitude(); if (a <= Precision::Confusion()) + { tol1 = maxtol; + } else + { tol1 = std::min(maxtol, dfVertToler / a); + } aGAS.D1(UMin, VMax, aP, aD1U, aD1V); a = aD1U.Magnitude(); if (a <= Precision::Confusion()) + { tol2 = maxtol; + } else + { tol2 = std::min(maxtol, dfVertToler / a); + } myTolU = 2. * std::max(tol1, tol2); } @@ -228,7 +244,9 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, if (!V1.IsNull()) { if (!myMap.IsBound(V1)) + { myMap.Bind(V1, empty); + } myMap(V1).Append(E); // add or remove in the vertex map @@ -258,12 +276,16 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, if (Eori == TopAbs_FORWARD) { if (aF == -Precision::Infinite()) + { anInfEmap.Add(E); + } } else { // Eori == TopAbs_REVERSED if (aL == Precision::Infinite()) + { anInfEmap.Add(E); + } } } it.Next(); @@ -275,7 +297,9 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, while (it2.More()) { if (!emap.Add(it2.Value())) + { myDoubles.Add(it2.Value()); + } it2.Next(); } @@ -343,9 +367,13 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, } if (V1.IsNull()) + { return; + } if (!myMap.IsBound(V1)) + { return; + } NCollection_List& l = myMap(V1); myEdge = TopoDS::Edge(l.First()); @@ -417,9 +445,13 @@ void BRepTools_WireExplorer::Next() } if (myEdge.Orientation() == TopAbs_FORWARD) + { aPrevPar = aPar12; + } else + { aPrevPar = aPar11; + } if (aNextEdge.Orientation() == TopAbs_FORWARD) { @@ -506,9 +538,13 @@ void BRepTools_WireExplorer::Next() // Get 2D point equals to < myVertex > in 2D for current edge. gp_Pnt2d PRef; if (myEdge.Orientation() == TopAbs_REVERSED) + { aPCurve->D0(dfFPar, PRef); + } else + { aPCurve->D0(dfLPar, PRef); + } // Get next 2D point from current edge's PCurve with parameter // F + dP (REV) or L - dP (FOR) @@ -569,9 +605,13 @@ void BRepTools_WireExplorer::Next() if (aVert1.IsSame(aVert2) == isDegenerated) { if (E.Orientation() == TopAbs_REVERSED) + { aPCurve->D0(dfLPar, aPEb); + } else + { aPCurve->D0(dfFPar, aPEb); + } if (std::abs(dfLPar - dfFPar) > Precision::PConfusion()) { @@ -587,9 +627,13 @@ void BRepTools_WireExplorer::Next() gp_Vec2d aD; aPCurve->D1(aEPm, aPEe, aD); if (E.Orientation() == TopAbs_REVERSED) + { aPEe.SetXY(aPEb.XY() - aD.XY()); + } else + { aPEe.SetXY(aPEb.XY() + aD.XY()); + } if (aPEb.SquareDistance(aPEe) <= gp::Resolution()) { @@ -606,7 +650,9 @@ void BRepTools_WireExplorer::Next() { double d = PRef.SquareDistance(aPEb); if (d <= Precision::PConfusion()) + { d = 0.; + } if (std::abs(aPEb.X() - PRef.X()) < myTolU && std::abs(aPEb.Y() - PRef.Y()) < myTolV) { if (d <= dmin) @@ -629,7 +675,9 @@ void BRepTools_WireExplorer::Next() dmin = RealLast(); } else + { break; + } } // for iDone if (kMin == 0) @@ -678,7 +726,9 @@ TopAbs_Orientation BRepTools_WireExplorer::Orientation() const while (it.More()) { if (myVertex.IsSame(it.Value())) + { return it.Value().Orientation(); + } it.Next(); } throw Standard_NoSuchObject("BRepTools_WireExplorer::Orientation"); @@ -766,7 +816,9 @@ double GetNextParamOnPC(const occ::handle& aPC, startPar += dP; aPC->D0(startPar, pnt); if (std::abs(aPRef.X() - pnt.X()) < tolU && std::abs(aPRef.Y() - pnt.Y()) < tolV) + { continue; + } else { result = startPar; @@ -776,10 +828,14 @@ double GetNextParamOnPC(const occ::handle& aPC, } if (!nextPntOnEdge) + { result = lP; + } if (result > lP) + { result = lP; + } } else { @@ -791,7 +847,9 @@ double GetNextParamOnPC(const occ::handle& aPC, startPar -= dP; aPC->D0(startPar, pnt); if (std::abs(aPRef.X() - pnt.X()) < tolU && std::abs(aPRef.Y() - pnt.Y()) < tolV) + { continue; + } else { result = startPar; @@ -801,10 +859,14 @@ double GetNextParamOnPC(const occ::handle& aPC, } if (!nextPntOnEdge) + { result = fP; + } if (result < fP) + { result = fP; + } } return result; diff --git a/src/ModelingData/TKBRep/BinTools/BinTools.cxx b/src/ModelingData/TKBRep/BinTools/BinTools.cxx index 687ec441c5..9f4440c627 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools.cxx @@ -110,7 +110,9 @@ Standard_IStream& BinTools::GetShortReal(Standard_IStream& theIS, float& theValu Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, int& aValue) { if (!IS.read((char*)&aValue, sizeof(int))) + { throw Storage_StreamTypeMismatchError(); + } #ifdef DO_INVERSE aValue = InverseInt(aValue); #endif @@ -122,7 +124,9 @@ Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, int& aValue) Standard_IStream& BinTools::GetExtChar(Standard_IStream& IS, char16_t& theValue) { if (!IS.read((char*)&theValue, sizeof(char16_t))) + { throw Storage_StreamTypeMismatchError(); + } #ifdef DO_INVERSE theValue = InverseExtChar(theValue); #endif @@ -181,7 +185,9 @@ bool BinTools::Write(const TopoDS_Shape& theShape, aFileSystem->OpenOStream(theFile, std::ios::out | std::ios::binary); aStream->precision(15); if (aStream.get() == nullptr || !aStream->good()) + { return false; + } Write(theShape, *aStream, theWithTriangles, theWithNormals, theVersion, theRange); aStream->flush(); diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_Curve2dSet.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_Curve2dSet.cxx index f04393ae6d..d88fe080a6 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_Curve2dSet.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_Curve2dSet.cxx @@ -181,7 +181,9 @@ static BinTools_OStream& operator<<(BinTools_OStream& OS, const occ::handlePole(i); // Pnt2d if (aRational) + { OS << B->Weight(i); // Real + } } return OS; } @@ -210,7 +212,9 @@ static BinTools_OStream& operator<<(BinTools_OStream& OS, const occ::handlePole(i); // Pnt2d if (aRational) + { OS << B->Weight(i); + } } for (i = 1; i <= aNbKnots; i++) @@ -301,8 +305,8 @@ void BinTools_Curve2dSet::WriteCurve2d(const occ::handle& C, BinTo catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_Curve2dSet::WriteCurve2d(..)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_Curve2dSet::WriteCurve2d(..)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -429,13 +433,19 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); // Pnt2d if (rational) + { BinTools::GetReal(IS, weights(i)); + } } if (rational) + { B = new Geom2d_BezierCurve(poles, weights); + } else + { B = new Geom2d_BezierCurve(poles); + } return IS; } @@ -466,7 +476,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); // Pnt2d if (rational) + { BinTools::GetReal(IS, weights(i)); + } } NCollection_Array1 knots(1, nbknots); @@ -479,9 +491,13 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle BinTools_CurveSet::Curve(const int I) const return dummy; } else + { return occ::down_cast(myMap(I)); + } } //================================================================================================= @@ -186,7 +188,9 @@ static BinTools_OStream& operator<<(BinTools_OStream& OS, const occ::handlePole(i); // Pnt if (aRational) + { OS << B->Weight(i); // Real + } } return OS; } @@ -215,7 +219,9 @@ static BinTools_OStream& operator<<(BinTools_OStream& OS, const occ::handlePole(i); // Pnt if (aRational) + { OS << B->Weight(i); + } } for (i = 1; i <= aNbKnots; i++) @@ -306,8 +312,8 @@ void BinTools_CurveSet::WriteCurve(const occ::handle& C, BinTools_OS catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_CurveSet::WriteCurve(..)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_CurveSet::WriteCurve(..)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -436,14 +442,20 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); // Pnt if (rational) + { // weights(i); BinTools::GetReal(IS, weights(i)); + } } if (rational) + { B = new Geom_BezierCurve(poles, weights); + } else + { B = new Geom_BezierCurve(poles); + } return IS; } @@ -474,7 +486,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); // Pnt if (rational) + { BinTools::GetReal(IS, weights(i)); + } } NCollection_Array1 knots(1, nbknots); @@ -487,9 +501,13 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle>(double& theValue) { if (!myStream->read((char*)&theValue, sizeof(double))) + { throw Storage_StreamTypeMismatchError(); + } myPosition += sizeof(double); #if DO_INVERSE theValue = InverseReal(theValue); @@ -145,7 +147,9 @@ BinTools_IStream& BinTools_IStream::operator>>(double& theValue) BinTools_IStream& BinTools_IStream::operator>>(int& theValue) { if (!myStream->read((char*)&theValue, sizeof(int))) + { throw Storage_StreamTypeMismatchError(); + } myPosition += sizeof(int); #if DO_INVERSE theValue = InverseInt(theValue); @@ -161,7 +165,9 @@ BinTools_IStream& BinTools_IStream::operator>>(gp_Pnt& theValue) for (int aCoord = 1; aCoord <= 3; aCoord++) { if (!myStream->read((char*)&aValue, sizeof(double))) + { throw Storage_StreamTypeMismatchError(); + } #if DO_INVERSE aValue = InverseReal(aValue); #endif diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_LocationSet.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_LocationSet.cxx index bb67d67c0c..2afbae037b 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_LocationSet.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_LocationSet.cxx @@ -90,10 +90,14 @@ void BinTools_LocationSet::Clear() int BinTools_LocationSet::Add(const TopLoc_Location& L) { if (L.IsIdentity()) + { return 0; + } int n = myMap.FindIndex(L); if (n > 0) + { return n; + } TopLoc_Location N = L; do { @@ -109,9 +113,13 @@ const TopLoc_Location& BinTools_LocationSet::Location(const int I) const { static TopLoc_Location identity; if (I == 0) + { return identity; + } else + { return myMap(I); + } } //================================================================================================= @@ -119,7 +127,9 @@ const TopLoc_Location& BinTools_LocationSet::Location(const int I) const int BinTools_LocationSet::Index(const TopLoc_Location& L) const { if (L.IsIdentity()) + { return 0; + } return myMap.FindIndex(L); } @@ -176,8 +186,8 @@ void BinTools_LocationSet::Write(Standard_OStream& OS) const catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_LocatioSet::Write(..)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_LocatioSet::Write(..)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -195,7 +205,7 @@ void BinTools_LocationSet::Read(Standard_IStream& IS) if (IS.fail() || (strcmp(buffer, "Locations"))) { Standard_SStream aMsg; - aMsg << "BinTools_LocationSet::Read: Not a location table" << std::endl; + aMsg << "BinTools_LocationSet::Read: Not a location table" << '\n'; throw Standard_Failure(aMsg.str().c_str()); return; } @@ -234,18 +244,20 @@ void BinTools_LocationSet::Read(Standard_IStream& IS) else { Standard_SStream aMsg; - aMsg << "Unexpected location's type = " << aTypLoc << std::endl; + aMsg << "Unexpected location's type = " << aTypLoc << '\n'; throw Standard_Failure(aMsg.str().c_str()); } if (!L.IsIdentity()) + { myMap.Add(L); + } } } catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_LocationSet::Read(..)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_LocationSet::Read(..)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeReader.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeReader.cxx index 617eea21e6..4237225dd1 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeReader.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeReader.cxx @@ -62,7 +62,9 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) uint64_t aPosition = theStream.Position(); const BinTools_ObjectType& aType = theStream.ReadType(); if (aType == BinTools_ObjectType_EmptyShape || aType == BinTools_ObjectType_EndShape) + { return aResult; + } if (theStream.IsReference()) { @@ -106,8 +108,10 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) while (theStream) { uint8_t aPrsType = theStream.ReadByte(); - if (aPrsType == 0) // end of the cycle + if (aPrsType == 0) + { // end of the cycle break; + } double aParam = theStream.ReadReal(); occ::handle aPR; switch (aPrsType) @@ -115,27 +119,33 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) case 1: { occ::handle aCurve = ReadCurve(theStream); if (!aCurve.IsNull()) + { aPR = new BRep_PointOnCurve(aParam, aCurve, anEmptyLoc); + } break; } case 2: { occ::handle aCurve2d = ReadCurve2d(theStream); occ::handle aSurface = ReadSurface(theStream); if (!aCurve2d.IsNull() && aSurface.IsNull()) + { aPR = new BRep_PointOnCurveOnSurface(aParam, aCurve2d, aSurface, anEmptyLoc); + } break; } case 3: { double aParam2 = theStream.ReadReal(); occ::handle aSurface = ReadSurface(theStream); if (!aSurface.IsNull()) + { aPR = new BRep_PointOnSurface(aParam, aParam2, aSurface, anEmptyLoc); + } break; } default: { Standard_SStream aMsg; aMsg << "BinTools_ShapeReader::Read: UnExpected BRep_PointRepresentation = " - << aPrsType << std::endl; + << aPrsType << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -163,7 +173,9 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) { uint8_t aPrsType = theStream.ReadByte(); //{0|1|2|3|4|5|6|7} if (aPrsType == 0) + { break; + } switch (aPrsType) { case 1: // -1- Curve 3D @@ -203,7 +215,9 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) aBuilder.Continuity(aE, aSurface, aSurface, *aLoc, *aLoc, aReg); } else + { aBuilder.UpdateEdge(aE, aCurve2d_1, aSurface, *aLoc, aTol); + } aBuilder.Range(aE, aSurface, *aLoc, aFirst, aLast); } break; @@ -216,7 +230,9 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) occ::handle aSurface2 = ReadSurface(theStream); const TopLoc_Location* aLoc2 = ReadLocation(theStream); if (!aSurface1.IsNull() && !aSurface2.IsNull()) + { aBuilder.Continuity(aE, aSurface1, aSurface2, *aLoc1, *aLoc2, aReg); + } break; } case 5: // -5- Polygon3D @@ -232,19 +248,25 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) bool aClosed = (aPrsType == 7); occ::handle aPoly2, aPoly1 = ReadPolygon(theStream); if (aClosed) + { aPoly2 = ReadPolygon(theStream); + } occ::handle aTriangulation = ReadTriangulation(theStream); const TopLoc_Location* aLoc = ReadLocation(theStream); if (aClosed) + { aBuilder.UpdateEdge(aE, aPoly1, aPoly2, aTriangulation, *aLoc); + } else + { aBuilder.UpdateEdge(aE, aPoly1, aTriangulation, *aLoc); + } // range break; } default: { Standard_SStream aMsg; - aMsg << "Unexpected Curve Representation =" << aPrsType << std::endl; + aMsg << "Unexpected Curve Representation =" << aPrsType << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -263,8 +285,10 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) const TopLoc_Location* aLoc = ReadLocation(theStream); aBuilder.UpdateFace(aF, aSurface, *aLoc, aTol); aBuilder.NaturalRestriction(aF, aNatRes); - if (theStream.ReadByte() == 2) // triangulation + if (theStream.ReadByte() == 2) + { // triangulation aBuilder.UpdateFace(aF, ReadTriangulation(theStream)); + } break; } case TopAbs_SHELL: @@ -281,7 +305,7 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) break; default: { Standard_SStream aMsg; - aMsg << "Unexpected topology type = " << aShapeType << std::endl; + aMsg << "Unexpected topology type = " << aShapeType << '\n'; throw Standard_Failure(aMsg.str().c_str()); break; } @@ -290,8 +314,8 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_ShapeReader::Read" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_ShapeReader::Read" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } // read flags and subs @@ -299,7 +323,9 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape(BinTools_IStream& theStream) theStream.ReadBools(aFree, aMod, aChecked, anOrient, aClosed, anInf, aConv); // sub-shapes for (TopoDS_Shape aSub = ReadShape(theStream); !aSub.IsNull(); aSub = ReadShape(theStream)) + { aBuilder.Add(aResult, aSub); + } aResult.Free(aFree); aResult.Modified(aMod); aResult.Checked(aChecked); @@ -322,13 +348,17 @@ const TopLoc_Location* BinTools_ShapeReader::ReadLocation(BinTools_IStream& theS uint64_t aPosition = theStream.Position(); const BinTools_ObjectType& aType = theStream.ReadType(); if (aType == BinTools_ObjectType_EmptyLocation || aType == BinTools_ObjectType_LocationEnd) + { return anEmptyLoc; + } if (theStream.IsReference()) { uint64_t aRef = theStream.ReadReference(); const TopLoc_Location* aFound = myLocationPos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position const TopLoc_Location* aResult = ReadLocation(theStream); @@ -347,7 +377,9 @@ const TopLoc_Location* BinTools_ShapeReader::ReadLocation(BinTools_IStream& theS { for (const TopLoc_Location* aNextLoc = ReadLocation(theStream); !aNextLoc->IsIdentity(); aNextLoc = ReadLocation(theStream)) + { aLoc = aNextLoc->Powered(theStream.ReadInteger()) * aLoc; + } } myLocationPos.Bind(aPosition, aLoc); return myLocationPos.Seek(aPosition); @@ -364,8 +396,10 @@ occ::handle BinTools_ShapeReader::ReadCurve(BinTools_IStream& theStr { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = myCurvePos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadCurve(theStream); @@ -391,8 +425,10 @@ occ::handle BinTools_ShapeReader::ReadCurve2d(BinTools_IStream& th { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = myCurve2dPos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadCurve2d(theStream); @@ -418,8 +454,10 @@ occ::handle BinTools_ShapeReader::ReadSurface(BinTools_IStream& th { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = mySurfacePos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadSurface(theStream); @@ -445,8 +483,10 @@ occ::handle BinTools_ShapeReader::ReadPolygon3d(BinTools_IStream { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = myPolygon3dPos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadPolygon3d(theStream); @@ -460,12 +500,16 @@ occ::handle BinTools_ShapeReader::ReadPolygon3d(BinTools_IStream aResult->Deflection(theStream.ReadReal()); NCollection_Array1& aNodes = aResult->ChangeNodes(); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream >> aNodes.ChangeValue(aNodeIter); + } if (aHasParameters) { NCollection_Array1& aParam = aResult->ChangeParameters(); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream >> aParam.ChangeValue(aNodeIter); + } } myPolygon3dPos.Bind(aPosition, aResult); } @@ -484,8 +528,10 @@ occ::handle BinTools_ShapeReader::ReadPolygon( { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = myPolygonPos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadPolygon(theStream); @@ -496,14 +542,18 @@ occ::handle BinTools_ShapeReader::ReadPolygon( int aNbNodes = theStream.ReadInteger(); aResult = new Poly_PolygonOnTriangulation(aNbNodes, false); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { aResult->SetNode(aNodeIter, theStream.ReadInteger()); + } aResult->Deflection(theStream.ReadReal()); if (theStream.ReadBool()) { occ::handle> aParams = new NCollection_HArray1(1, aNbNodes); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream >> aParams->ChangeValue(aNodeIter); + } aResult->SetParameters(aParams); } myPolygonPos.Bind(aPosition, aResult); @@ -522,8 +572,10 @@ occ::handle BinTools_ShapeReader::ReadTriangulation(BinTools { // get by reference uint64_t aRef = theStream.ReadReference(); const occ::handle* aFound = myTriangulationPos.Seek(aRef); - if (aFound) // the location is already retrieved + if (aFound) + { // the location is already retrieved return *aFound; + } uint64_t aCurrent = theStream.Position(); theStream.GoTo(aRef); // go to the referenced position aResult = ReadTriangulation(theStream); @@ -538,7 +590,9 @@ occ::handle BinTools_ShapeReader::ReadTriangulation(BinTools aResult = new Poly_Triangulation(aNbNodes, aNbTriangles, aHasUV, aHasNormals); aResult->Deflection(theStream.ReadReal()); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { aResult->SetNode(aNodeIter, theStream.ReadPnt()); + } if (aHasUV) { gp_Pnt2d anUV; diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeSet.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeSet.cxx index 94b52b917a..2b4bb87725 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeSet.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeSet.cxx @@ -78,7 +78,9 @@ void BinTools_ShapeSet::Clear() int BinTools_ShapeSet::Add(const TopoDS_Shape& theShape) { if (theShape.IsNull()) + { return 0; + } myLocations.Add(theShape.Location()); TopoDS_Shape aS2 = theShape; aS2.Location(TopLoc_Location()); @@ -87,7 +89,9 @@ int BinTools_ShapeSet::Add(const TopoDS_Shape& theShape) { AddShape(aS2); for (TopoDS_Iterator its(aS2, false, false); its.More(); its.Next()) + { Add(its.Value()); + } anIndex = myShapes.Add(aS2); } return anIndex; @@ -181,7 +185,9 @@ void BinTools_ShapeSet::AddShape(const TopoDS_Shape& S) myCurves2d.Add(CR->PCurve()); ChangeLocations().Add(CR->Location()); if (CR->IsCurveOnClosedSurface()) + { myCurves2d.Add(CR->PCurve2()); + } } else if (CR->IsRegularity()) { @@ -212,7 +218,9 @@ void BinTools_ShapeSet::AddShape(const TopoDS_Shape& S) myNodes.Add(CR->PolygonOnTriangulation()); ChangeLocations().Add(CR->Location()); if (CR->IsPolygonOnClosedTriangulation()) + { myNodes.Add(CR->PolygonOnTriangulation2()); + } } else if (CR->IsPolygonOnSurface()) { @@ -220,7 +228,9 @@ void BinTools_ShapeSet::AddShape(const TopoDS_Shape& S) myPolygons2D.Add(CR->Polygon()); ChangeLocations().Add(CR->Location()); if (CR->IsPolygonOnClosedSurface()) + { myPolygons2D.Add(CR->Polygon2()); + } } } itrc.Next(); @@ -245,7 +255,9 @@ void BinTools_ShapeSet::AddShape(const TopoDS_Shape& S) { occ::handle Tr = TF->Triangulation(); if (!Tr.IsNull()) + { myTriangulations.Add(Tr, needNormals); + } } ChangeLocations().Add(TF->Location()); @@ -260,19 +272,29 @@ void BinTools_ShapeSet::WriteGeometry(Standard_OStream& OS, Message_ProgressScope aPS(theRange, "Writing geometry", 6); myCurves2d.Write(OS, aPS.Next()); if (!aPS.More()) + { return; + } myCurves.Write(OS, aPS.Next()); if (!aPS.More()) + { return; + } WritePolygon3D(OS, aPS.Next()); if (!aPS.More()) + { return; + } WritePolygonOnTriangulation(OS, aPS.Next()); if (!aPS.More()) + { return; + } mySurfaces.Write(OS, aPS.Next()); if (!aPS.More()) + { return; + } WriteTriangulation(OS, aPS.Next()); } @@ -297,7 +319,9 @@ void BinTools_ShapeSet::Write(Standard_OStream& OS, const Message_ProgressRange& WriteGeometry(OS, aPS.Next()); if (!aPS.More()) + { return; + } //----------------------------------------- // write the shapes @@ -358,7 +382,9 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (lv > 0) { for (lv--; lv > 0 && (vers[lv] == '\r' || vers[lv] == '\n'); lv--) + { vers[lv] = '\0'; + } } for (int i = BinTools_FormatVersion_LOWER; i <= BinTools_FormatVersion_UPPER; ++i) @@ -378,7 +404,7 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (IS.fail()) { std::cout << "BinTools_ShapeSet::Read: File was not written with this version of the topology" - << std::endl; + << '\n'; return; } @@ -392,7 +418,9 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& Message_ProgressScope aPSouter(theRange, "Reading", 2); ReadGeometry(IS, aPSouter.Next()); if (!aPSouter.More()) + { return; + } //----------------------------------------- // read the shapes //----------------------------------------- @@ -402,7 +430,7 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (IS.fail() || strcmp(buffer, "TShapes")) { Standard_SStream aMsg; - aMsg << "BinTools_ShapeSet::Read: Not a TShape table" << std::endl; + aMsg << "BinTools_ShapeSet::Read: Not a TShape table" << '\n'; throw Standard_Failure(aMsg.str().c_str()); return; } @@ -425,8 +453,10 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& void BinTools_ShapeSet::Write(const TopoDS_Shape& S, Standard_OStream& OS) { if (S.IsNull()) + { OS << '*'; + } else { // {TopAbs_FORWARD, TopAbs_REVERSED, TopAbs_INTERNAL, TopAbs_EXTERNAL} @@ -460,7 +490,9 @@ void BinTools_ShapeSet::ReadFlagsAndSubs(TopoDS_Shape& S, { ReadSubs(SS, IS, nbShapes); if (!SS.IsNull()) + { AddShapes(S, SS); + } } while (!SS.IsNull()); S.Free(aFree); @@ -477,11 +509,13 @@ void BinTools_ShapeSet::ReadFlagsAndSubs(TopoDS_Shape& S, // check if (FormatNb() == BinTools_FormatVersion_VERSION_1) + { if (T == TopAbs_FACE) { const TopoDS_Face& F = TopoDS::Face(S); BRepTools::Update(F); } + } } //================================================================================================= @@ -491,7 +525,9 @@ void BinTools_ShapeSet::ReadSubs(TopoDS_Shape& S, Standard_IStream& IS, const in char aChar = '\0'; IS >> aChar; if (aChar == '*') + { S = TopoDS_Shape(); + } else { TopAbs_Orientation anOrient; @@ -515,23 +551,33 @@ void BinTools_ShapeSet::ReadGeometry(Standard_IStream& IS, const Message_Progres Message_ProgressScope aPS(theRange, "Reading geometry", 6); myCurves2d.Read(IS, aPS.Next()); if (!aPS.More()) + { return; + } myCurves.Read(IS, aPS.Next()); if (!aPS.More()) + { return; + } ReadPolygon3D(IS, aPS.Next()); if (!aPS.More()) + { return; + } ReadPolygonOnTriangulation(IS, aPS.Next()); if (!aPS.More()) + { return; + } mySurfaces.Read(IS, aPS.Next()); if (!aPS.More()) + { return; + } ReadTriangulation(IS, aPS.Next()); } @@ -639,11 +685,15 @@ void BinTools_ShapeSet::WriteShape(const TopoDS_Shape& S, Standard_OStream& OS) occ::handle GC = occ::down_cast(itrc.Value()); GC->Range(first, last); if (!CR->IsCurveOnClosedSurface()) + { // -2- Curve on surf OS << (uint8_t)2; + } else + { // -3- Curve on closed surf OS << (uint8_t)3; + } BinTools::PutInteger(OS, myCurves2d.Index(CR->PCurve())); if (CR->IsCurveOnClosedSurface()) { //+ int|char @@ -706,11 +756,15 @@ void BinTools_ShapeSet::WriteShape(const TopoDS_Shape& S, Standard_OStream& OS) occ::handle PT = occ::down_cast(itrc.Value()); if (!CR->IsPolygonOnClosedTriangulation()) + { // -6- Polygon on triangulation OS << (uint8_t)6; + } else + { // -7- Polygon on closed triangulation OS << (uint8_t)7; + } BinTools::PutInteger(OS, myNodes.FindIndex(PT->PolygonOnTriangulation())); if (CR->IsPolygonOnClosedTriangulation()) @@ -751,17 +805,21 @@ void BinTools_ShapeSet::WriteShape(const TopoDS_Shape& S, Standard_OStream& OS) BinTools::PutInteger(OS, myTriangulations.FindIndex(TF->Triangulation())); } else + { OS << (uint8_t)1; + } } else + { OS << (uint8_t)0; // without triangulation + } } } catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_ShapeSet::WriteGeometry(S,OS)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_ShapeSet::WriteGeometry(S,OS)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -808,7 +866,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS { val = (int)IS.get(); // case {0|1|2|3} if (val > 0 && val <= 3) + { BinTools::GetReal(IS, p1); + } } else { @@ -823,7 +883,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS IS.seekg(aPos); val = (int)IS.get(); if (val > 0 && val <= 3) + { BinTools::GetReal(IS, p1); + } } } occ::handle PR; @@ -835,7 +897,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS case 1: { BinTools::GetInteger(IS, c); if (myCurves.Curve(c).IsNull()) + { break; + } occ::handle POC = new BRep_PointOnCurve(p1, myCurves.Curve(c), L); PR = POC; } @@ -845,7 +909,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS BinTools::GetInteger(IS, pc); BinTools::GetInteger(IS, s); if (myCurves2d.Curve2d(pc).IsNull() || mySurfaces.Surface(s).IsNull()) + { break; + } occ::handle POC = new BRep_PointOnCurveOnSurface(p1, @@ -860,7 +926,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS BinTools::GetReal(IS, p2); BinTools::GetInteger(IS, s); if (mySurfaces.Surface(s).IsNull()) + { break; + } occ::handle POC = new BRep_PointOnSurface(p1, p2, mySurfaces.Surface(s), L); @@ -871,7 +939,7 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS default: { Standard_SStream aMsg; aMsg << "BinTools_SurfaceSet::ReadGeometry: UnExpected BRep_PointRepresentation = " - << val << std::endl; + << val << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -978,7 +1046,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS if (myCurves2d.Curve2d(pc).IsNull() || (closed && myCurves2d.Curve2d(pc2).IsNull()) || mySurfaces.Surface(s).IsNull()) + { break; + } if (closed) { @@ -1043,7 +1113,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS BinTools::GetInteger(IS, s2); BinTools::GetInteger(IS, l2); if (mySurfaces.Surface(s).IsNull() || mySurfaces.Surface(s2).IsNull()) + { break; + } myBuilder.Continuity(E, mySurfaces.Surface(s), mySurfaces.Surface(s2), @@ -1064,7 +1136,9 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS closed = (val == 7); BinTools::GetInteger(IS, pt); if (closed) + { BinTools::GetInteger(IS, pt2); + } BinTools::GetInteger(IS, t); BinTools::GetInteger(IS, l); @@ -1087,7 +1161,7 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS break; default: { Standard_SStream aMsg; - aMsg << "Unexpected Curve Representation =" << val << std::endl; + aMsg << "Unexpected Curve Representation =" << val << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -1165,7 +1239,7 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS default: { Standard_SStream aMsg; - aMsg << "Unexpected topology type = " << T << std::endl; + aMsg << "Unexpected topology type = " << T << '\n'; throw Standard_Failure(aMsg.str().c_str()); break; } @@ -1174,8 +1248,8 @@ void BinTools_ShapeSet::ReadShape(const TopAbs_ShapeEnum T, Standard_IStream& IS catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_ShapeSet::ReadGeometry(S,OS)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_ShapeSet::ReadGeometry(S,OS)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeWriter.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeWriter.cxx index ed13d69856..1ad87feb54 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_ShapeWriter.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_ShapeWriter.cxx @@ -156,9 +156,13 @@ void BinTools_ShapeWriter::WriteShape(BinTools_OStream& theStream, const TopoDS_ occ::handle GC = occ::down_cast(aCR); GC->Range(aFirst, aLast); if (!aCR->IsCurveOnClosedSurface()) + { theStream << (uint8_t)2; // -2- Curve on surf + } else + { theStream << (uint8_t)3; // -3- Curve on closed surf + } WriteCurve(theStream, aCR->PCurve()); if (aCR->IsCurveOnClosedSurface()) @@ -196,13 +200,19 @@ void BinTools_ShapeWriter::WriteShape(BinTools_OStream& theStream, const TopoDS_ occ::handle aPT = occ::down_cast(aCR); if (!aCR->IsPolygonOnClosedTriangulation()) + { theStream << (uint8_t)6; // -6- Polygon on triangulation + } else + { theStream << (uint8_t)7; // -7- Polygon on closed triangulation + } WritePolygon(theStream, aPT->PolygonOnTriangulation()); if (aCR->IsPolygonOnClosedTriangulation()) + { WritePolygon(theStream, aPT->PolygonOnTriangulation2()); + } // edge triangulation does not need normals WriteTriangulation(theStream, aPT->Triangulation(), false); WriteLocation(theStream, aCR->Location()); @@ -233,10 +243,14 @@ void BinTools_ShapeWriter::WriteShape(BinTools_OStream& theStream, const TopoDS_ && (IsWithNormals() || aTF->Surface().IsNull())); } else + { theStream << (uint8_t)1; + } } else + { theStream << (uint8_t)0; // without triangulation + } } break; default: { @@ -246,8 +260,8 @@ void BinTools_ShapeWriter::WriteShape(BinTools_OStream& theStream, const TopoDS_ catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_ShapeWriter::WriteShape" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_ShapeWriter::WriteShape" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } theStream.PutBools(aShape.Free(), @@ -259,7 +273,9 @@ void BinTools_ShapeWriter::WriteShape(BinTools_OStream& theStream, const TopoDS_ aShape.Convex()); // process sub-shapes for (TopoDS_Iterator aSub(aShape, false, false); aSub.More(); aSub.Next()) + { WriteShape(theStream, aSub.Value()); + } theStream << BinTools_ObjectType_EndShape; } @@ -313,8 +329,8 @@ void BinTools_ShapeWriter::WriteLocation(BinTools_OStream& theStream, catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_ShapeWriter::WriteLocation" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_ShapeWriter::WriteLocation" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -405,12 +421,16 @@ void BinTools_ShapeWriter::WritePolygon(BinTools_OStream& theSt theStream << aNbNodes << thePolygon->HasParameters() << thePolygon->Deflection(); const NCollection_Array1& aNodes = thePolygon->Nodes(); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream << aNodes.Value(aNodeIter); + } if (thePolygon->HasParameters()) { const NCollection_Array1& aParam = thePolygon->Parameters(); for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream << aParam.Value(aNodeIter); + } } } @@ -436,16 +456,22 @@ void BinTools_ShapeWriter::WritePolygon(BinTools_OStream& const NCollection_Array1& aNodes = thePolygon->Nodes(); theStream << aNodes.Length(); for (int aNodeIter = 1; aNodeIter <= aNodes.Length(); ++aNodeIter) + { theStream << aNodes.Value(aNodeIter); + } theStream << thePolygon->Deflection(); if (const occ::handle>& aParam = thePolygon->Parameters()) { theStream << true; for (int aNodeIter = 1; aNodeIter <= aParam->Length(); ++aNodeIter) + { theStream << aParam->Value(aNodeIter); + } } else + { theStream << false; + } } void BinTools_ShapeWriter::WriteTriangulation( @@ -473,17 +499,23 @@ void BinTools_ShapeWriter::WriteTriangulation( theStream << theNeedToWriteNormals << theTriangulation->Deflection(); // write the 3d nodes for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream << theTriangulation->Node(aNodeIter); + } // theStream.write ((char*)(theTriangulation->InternalNodes().value(0)) , sizeof (gp_Pnt) * // aNbNodes); if (theTriangulation->HasUVNodes()) { for (int aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter) + { theStream << theTriangulation->UVNode(aNodeIter); + } } for (int aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter) + { theStream << theTriangulation->Triangle(aTriIter); + } if (theNeedToWriteNormals) { diff --git a/src/ModelingData/TKBRep/BinTools/BinTools_SurfaceSet.cxx b/src/ModelingData/TKBRep/BinTools/BinTools_SurfaceSet.cxx index 54ee6358ac..28af081d59 100644 --- a/src/ModelingData/TKBRep/BinTools/BinTools_SurfaceSet.cxx +++ b/src/ModelingData/TKBRep/BinTools/BinTools_SurfaceSet.cxx @@ -272,7 +272,9 @@ static BinTools_OStream& operator<<(BinTools_OStream& OS, const occ::handlePole(i, j); // Pnt if (urational || vrational) + { OS << S->Weight(i, j); // Real + } } } @@ -379,8 +381,8 @@ void BinTools_SurfaceSet::WriteSurface(const occ::handle& S, BinTo catch (Standard_Failure const& anException) { Standard_SStream aMsg; - aMsg << "EXCEPTION in BinTools_SurfaceSet::WriteSurface(..)" << std::endl; - aMsg << anException << std::endl; + aMsg << "EXCEPTION in BinTools_SurfaceSet::WriteSurface(..)" << '\n'; + aMsg << anException << '\n'; throw Standard_Failure(aMsg.str().c_str()); } } @@ -433,7 +435,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, gp_Ax3& A3) IS >> P >> A >> AX >> AY; gp_Ax3 ax3(P, A, AX); if (AY.DotCross(A, AX) < 0) + { ax3.YReverse(); + } A3 = ax3; return IS; } @@ -555,14 +559,20 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle gp::Resolution()) + { aVFirst.Normalize(); + } if (aVLast.SquareMagnitude() > gp::Resolution()) + { aVLast.Normalize(); + } // Reference: inverse circle (normal = (0,1,0)), evaluated at the same parameters const gp_Ax2 anAx2Ref(gp_Pnt(1., 0., 0.), gp_Dir(0., 1., 0.), gp_Dir(0., 0., -1.)); @@ -156,9 +164,13 @@ TEST(BRepAdaptor_CompCurve_Test, OCC30869_ReversedEdgeBoundaryPoints) aCircleRef->D1(t1, aRefP1, aRefV1); aCircleRef->D1(t2, aRefP2, aRefV2); if (aRefV1.SquareMagnitude() > gp::Resolution()) + { aRefV1.Normalize(); + } if (aRefV2.SquareMagnitude() > gp::Resolution()) + { aRefV2.Normalize(); + } const double aTol = 1.e-7; EXPECT_NEAR(aPFirst.X(), aRefP1.X(), aTol) << "First point X"; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx index 32ea7da578..35a3525970 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx @@ -73,7 +73,9 @@ static int countSubShapes(const TopoDS_Shape& theShape, TopAbs_ShapeEnum theType { int aCount = 0; for (TopExp_Explorer anExp(theShape, theType); anExp.More(); anExp.Next()) + { ++aCount; + } return aCount; } @@ -429,7 +431,9 @@ TEST(BRepGraphIncTest, Box_ReverseIndex_EdgesToFaces) for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdges); ++anEdgeId) { if (aStorage.Edge(anEdgeId).IsDegenerate) + { continue; + } const NCollection_DynamicArray* aFaces = aStorage.ReverseIndex().FacesOfEdge(anEdgeId); EXPECT_TRUE(aFaces != nullptr) << "Edge " << anEdgeId.Index << " not in any face"; @@ -533,7 +537,9 @@ TEST(BRepGraphIncTest, Box_CoEdgeCount) const NCollection_DynamicArray* aCoEdgeIdxs = aStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdgeIdxs != nullptr) + { aCoEdgeCount += aCoEdgeIdxs->Length(); + } } EXPECT_EQ(aCoEdgeCount, 24); } @@ -555,7 +561,9 @@ TEST(BRepGraphIncTest, Cylinder_HasSeamEdges) const NCollection_DynamicArray* aCoEdgeIdxs = aStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdgeIdxs == nullptr) + { continue; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdgeIdxs) { const BRepGraphInc::CoEdgeDef& aCE = aStorage.CoEdge(aCoEdgeId); @@ -586,7 +594,9 @@ TEST(BRepGraphIncTest, Cylinder_SeamEdge_ReverseIndex_NoDuplicateFace) const NCollection_DynamicArray* aFaces = aStorage.ReverseIndex().FacesOfEdge(anEdgeId); if (aFaces == nullptr) + { continue; + } for (int i = 0; i < aFaces->Length(); ++i) { for (int j = i + 1; j < aFaces->Length(); ++j) @@ -703,24 +713,24 @@ TEST(BRepGraphIncTest, Cylinder_RoundTrip_BRepDump) ++aLineNo; if (anOrigLine != aReconLine) { - std::cout << "BRep diff at line " << aLineNo << ":" << std::endl; - std::cout << " ORIG: " << anOrigLine << std::endl; - std::cout << " RECON: " << aReconLine << std::endl; + std::cout << "BRep diff at line " << aLineNo << ":" << '\n'; + std::cout << " ORIG: " << anOrigLine << '\n'; + std::cout << " RECON: " << aReconLine << '\n'; ++aDiffCount; } } std::cout << "Total " << aDiffCount << " line differences. " << "Orig size=" << anOrigStream.str().size() - << " Recon size=" << aReconStream.str().size() << std::endl; + << " Recon size=" << aReconStream.str().size() << '\n'; } else { - std::cout << "BRep dumps are IDENTICAL (size=" << anOrigStream.str().size() << ")" << std::endl; + std::cout << "BRep dumps are IDENTICAL (size=" << anOrigStream.str().size() << ")" << '\n'; } const double anOrigArea = computeArea(aCyl); const double aReconArea = computeArea(aRecon); - std::cout << "Orig area=" << anOrigArea << " Recon area=" << aReconArea << std::endl; + std::cout << "Orig area=" << anOrigArea << " Recon area=" << aReconArea << '\n'; EXPECT_NEAR(aReconArea, anOrigArea, Precision::Confusion()); } @@ -900,10 +910,14 @@ TEST(BRepGraphIncTest, EdgeMultipleInternalVertices_AllCaptured) { if (aStorage.VertexRef(anEdgeEnt.InternalVertexRefIds.Value(j)).Orientation == TopAbs_INTERNAL) + { aHasInternal = true; + } if (aStorage.VertexRef(anEdgeEnt.InternalVertexRefIds.Value(j)).Orientation == TopAbs_EXTERNAL) + { aHasExternal = true; + } } EXPECT_TRUE(aHasInternal); EXPECT_TRUE(aHasExternal); @@ -1320,7 +1334,9 @@ TEST(BRepGraphIncTest, ReverseIndex_CoEdgeToWire_IsPopulated) { const BRepGraphInc::CoEdgeDef& aCE = aStorage.CoEdge(aCoEdgeId); if (aCE.IsRemoved) + { continue; + } const NCollection_DynamicArray* aWires = aStorage.ReverseIndex().WiresOfCoEdge(aCoEdgeId); EXPECT_NE(aWires, nullptr) << "CoEdge " << aCoEdgeId.Index << " not in any wire"; @@ -1461,7 +1477,9 @@ TEST(BRepGraphIncTest, ReverseIndex_AfterEditorMutations_StaysConsistent) const NCollection_DynamicArray aWireRefs = BRepGraph_TestTools::WireRefsOfFace(aGraph, aFaceId); if (aWireRefs.IsEmpty()) + { continue; + } ASSERT_TRUE(aGraph.Editor().Faces().RemoveWire(aFaceId, aWireRefs.Value(0))); break; } @@ -1510,10 +1528,14 @@ TEST(BRepGraphIncTest, ReverseIndex_BulkBuild_TwiceProducesEqualState) aStorageB.ReverseIndex().WiresOfEdge(anEdgeId); ASSERT_EQ(aWiresA == nullptr, aWiresB == nullptr); if (aWiresA == nullptr) + { continue; + } ASSERT_EQ(aWiresA->Size(), aWiresB->Size()); for (size_t i = 0; i < aWiresA->Size(); ++i) + { EXPECT_EQ(aWiresA->Value(i), aWiresB->Value(i)); + } const NCollection_DynamicArray* aFacesA = aStorageA.ReverseIndex().FacesOfEdge(anEdgeId); @@ -1521,10 +1543,14 @@ TEST(BRepGraphIncTest, ReverseIndex_BulkBuild_TwiceProducesEqualState) aStorageB.ReverseIndex().FacesOfEdge(anEdgeId); ASSERT_EQ(aFacesA == nullptr, aFacesB == nullptr); if (aFacesA == nullptr) + { continue; + } ASSERT_EQ(aFacesA->Size(), aFacesB->Size()); for (size_t i = 0; i < aFacesA->Size(); ++i) + { EXPECT_EQ(aFacesA->Value(i), aFacesB->Value(i)); + } } } @@ -1544,11 +1570,19 @@ TEST(BRepGraphIncTest, ReverseIndex_EdgeOpsAdd_BindsStartEndVertices) bool foundV0 = false, foundV1 = false; for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV0)) + { if (aE == anEdge) + { foundV0 = true; + } + } for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV1)) + { if (aE == anEdge) + { foundV1 = true; + } + } EXPECT_TRUE(foundV0); EXPECT_TRUE(foundV1); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1568,9 +1602,13 @@ TEST(BRepGraphIncTest, ReverseIndex_RemoveEdge_UnbindsStartEndVertices) aGraph.Editor().Gen().RemoveNode(BRepGraph_NodeId(anEdge)); for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV0)) + { EXPECT_NE(aE, anEdge); + } for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV1)) + { EXPECT_NE(aE, anEdge); + } EXPECT_TRUE(aGraph.ValidateReverseIndex()); } @@ -1592,11 +1630,19 @@ TEST(BRepGraphIncTest, ReverseIndex_SetRefVertexDefId_RebindsVertexToEdges) bool stillUnderV0 = false, foundUnderV2 = false; for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV0)) + { if (aE == anEdge) + { stillUnderV0 = true; + } + } for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV2)) + { if (aE == anEdge) + { foundUnderV2 = true; + } + } EXPECT_FALSE(stillUnderV0); EXPECT_TRUE(foundUnderV2); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1649,11 +1695,19 @@ TEST(BRepGraphIncTest, ReverseIndex_SetRefWireDefId_RebindsWireToFaces) bool oldStillBound = false, newBound = false; for (const BRepGraph_FaceId& f : aGraph.Topo().Wires().Faces(aOldWire)) + { if (f == aFace0) + { oldStillBound = true; + } + } for (const BRepGraph_FaceId& f : aGraph.Topo().Wires().Faces(aNewWire)) + { if (f == aFace0) + { newBound = true; + } + } EXPECT_FALSE(oldStillBound); EXPECT_TRUE(newBound); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1731,11 +1785,19 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEdgeDefIdOnCoEdge_RebindsEdgeToCoEdges) bool oldHasCoEdge = false, newHasCoEdge = false; for (const BRepGraph_CoEdgeId& aC : aGraph.Topo().Edges().CoEdges(anOldEdge)) + { if (aC == aCoEdge) + { oldHasCoEdge = true; + } + } for (const BRepGraph_CoEdgeId& aC : aGraph.Topo().Edges().CoEdges(aNewEdge)) + { if (aC == aCoEdge) + { newHasCoEdge = true; + } + } EXPECT_FALSE(oldHasCoEdge); EXPECT_TRUE(newHasCoEdge); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1760,13 +1822,17 @@ TEST(BRepGraphIncTest, ReverseIndex_SetFaceDefIdOnCoEdge_LastBondCheck) { const NCollection_DynamicArray& aCEs = aGraph.Topo().Edges().CoEdges(aE); if (aCEs.Size() < 2) + { continue; + } NCollection_DataMap aSeenFace; for (const BRepGraph_CoEdgeId& aCE : aCEs) { const BRepGraphInc::CoEdgeDef& aD = aGraph.Topo().CoEdges().Definition(aCE); if (!aD.FaceDefId.IsValid()) + { continue; + } if (aSeenFace.IsBound(aD.FaceDefId.Index)) { aSeamEdge = aE; @@ -1784,8 +1850,12 @@ TEST(BRepGraphIncTest, ReverseIndex_SetFaceDefIdOnCoEdge_LastBondCheck) // The seam-pair partner of aSeamCoEdge still binds (aSeamEdge, aSeamFace). bool stillBound = false; for (const BRepGraph_FaceId& f : aGraph.Topo().Edges().Faces(aSeamEdge)) + { if (f == aSeamFace) + { stillBound = true; + } + } EXPECT_TRUE(stillBound); EXPECT_TRUE(aGraph.ValidateReverseIndex()); } @@ -1809,7 +1879,9 @@ TEST(BRepGraphIncTest, ReverseIndex_SetFaceDefIdOnCoEdge_OnlyBondUnbinds) aGraph.Editor().CoEdges().SetFaceDefId(aCoEdge, BRepGraph_FaceId()); for (const BRepGraph_FaceId& f : aGraph.Topo().Edges().Faces(anEdge)) + { EXPECT_NE(f, anOldFace); + } EXPECT_TRUE(aGraph.ValidateReverseIndex()); } @@ -1834,11 +1906,19 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEndVertexRefId_RebindsVertexToEdges) bool stillUnderV1 = false, foundUnderV2 = false; for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV1)) + { if (aE == anEdge) + { stillUnderV1 = true; + } + } for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aV2)) + { if (aE == anEdge) + { foundUnderV2 = true; + } + } EXPECT_FALSE(stillUnderV1); EXPECT_TRUE(foundUnderV2); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1902,11 +1982,19 @@ TEST(BRepGraphIncTest, ReverseIndex_SetChildRefChildDefId_CrossKindRebinds) const BRepGraph_SolidId anOldSolid = BRepGraph_SolidId::FromNodeId(anOldChild); bool oldStill = false, newBound = false; for (const BRepGraph_CompoundId& c : aGraph.Topo().Solids().Compounds(anOldSolid)) + { if (c == aCompound0) + { oldStill = true; + } + } for (const BRepGraph_CompoundId& c : aGraph.Topo().Shells().Compounds(aShell)) + { if (c == aCompound0) + { newBound = true; + } + } EXPECT_FALSE(oldStill); EXPECT_TRUE(newBound); EXPECT_TRUE(aGraph.ValidateReverseIndex()); @@ -1932,7 +2020,9 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEdgeDefIdOnCoEdge_LastBondInWireCheck) { const NCollection_DynamicArray& aCEs = aGraph.Topo().Edges().CoEdges(aE); if (aCEs.Size() < 2) + { continue; + } NCollection_DataMap aSeenWire; for (const BRepGraph_CoEdgeId& aCE : aCEs) { @@ -1950,7 +2040,9 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEdgeDefIdOnCoEdge_LastBondInWireCheck) aSeenWire.Bind(aW.Index, aCE); } if (aSeamEdge.IsValid()) + { break; + } } } ASSERT_TRUE(aSeamEdge.IsValid()) << "cylinder must have a wire with two coedges of same edge"; @@ -1958,11 +2050,13 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEdgeDefIdOnCoEdge_LastBondInWireCheck) // Pick a different edge to redirect to. BRepGraph_EdgeId aTargetEdge; for (BRepGraph_EdgeId aE(0); aE.IsValid(aGraph.Topo().Edges().Nb()); ++aE) + { if (aE != aSeamEdge) { aTargetEdge = aE; break; } + } ASSERT_TRUE(aTargetEdge.IsValid()); aGraph.Editor().CoEdges().SetEdgeDefId(aSeamCoEdge, aTargetEdge); @@ -1970,8 +2064,12 @@ TEST(BRepGraphIncTest, ReverseIndex_SetEdgeDefIdOnCoEdge_LastBondInWireCheck) // The OTHER coedge of aSeamWire still references aSeamEdge -> wire still bound. bool stillBound = false; for (const BRepGraph_WireId& aW : aGraph.Topo().Edges().Wires(aSeamEdge)) + { if (aW == aSeamWire) + { stillBound = true; + } + } EXPECT_TRUE(stillBound); EXPECT_TRUE(aGraph.ValidateReverseIndex()); } @@ -2022,6 +2120,8 @@ TEST(BRepGraphIncTest, ReverseIndex_RemoveRef_UnbindsByKind) ASSERT_TRUE(aGraph.Editor().Gen().RemoveRef(aFaceRefId)); for (const BRepGraph_ShellId& aShellId : aGraph.Topo().Faces().Shells(aFaceId)) + { EXPECT_NE(aShellId, BRepGraph_ShellId::Start()); + } EXPECT_TRUE(aGraph.ValidateReverseIndex()); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx index a7b54b8625..d9bc5116c3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx @@ -82,7 +82,7 @@ double runBenchmark(const char* theLabel, Func theFunc) const double anAvg = aTotal / static_cast(THE_MEASURE_ITERS); std::cout << "[ PERF ] " << theLabel << ": avg " << anAvg << " s over " << THE_MEASURE_ITERS - << " iters" << std::endl; + << " iters" << '\n'; return anAvg; } @@ -196,7 +196,7 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Reconstruct_RoundTrip) }); const double aPerFace = aAvg / static_cast(aNbFaces); - std::cout << "[ PERF ] Reconstruct per-face avg: " << aPerFace << " s" << std::endl; + std::cout << "[ PERF ] Reconstruct per-face avg: " << aPerFace << " s" << '\n'; EXPECT_GT(aAvg, 0.0); } @@ -222,6 +222,6 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_SpatialQuery_Throughput) }); const double aPerQuery = aAvg / static_cast(aNbFaces); - std::cout << "[ PERF ] SpatialQuery per-face avg: " << aPerQuery << " s" << std::endl; + std::cout << "[ PERF ] SpatialQuery per-face avg: " << aPerQuery << " s" << '\n'; EXPECT_GT(aAvg, 0.0); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx index 96893a3c75..d9203f558c 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx @@ -1248,9 +1248,13 @@ TEST(BRepGraph_BuildTest, RegularityLayer_EdgeMutation_InvalidatesBindings) { const BRepGraph_FaceId aFace = aGraph.Topo().CoEdges().Definition(aCoEdgeId).FaceDefId; if (!aFace.IsValid()) + { continue; + } if (!aFace1.IsValid()) + { aFace1 = aFace; + } else if (aFace != aFace1) { aFace2 = aFace; @@ -1258,7 +1262,9 @@ TEST(BRepGraph_BuildTest, RegularityLayer_EdgeMutation_InvalidatesBindings) } } if (!aFace1.IsValid() || !aFace2.IsValid()) + { continue; + } aRegularityLayer->SetRegularity(anEdgeId, aFace1, aFace2, GeomAbs_C1); aRegularity.FaceEntity1 = aFace1; aRegularity.FaceEntity2 = aFace2; @@ -1303,9 +1309,13 @@ TEST(BRepGraph_BuildTest, RegularityLayer_FaceMutation_InvalidatesBindings) { const BRepGraph_FaceId aFace = aGraph.Topo().CoEdges().Definition(aCoEdgeId).FaceDefId; if (!aFace.IsValid()) + { continue; + } if (!aFace1.IsValid()) + { aFace1 = aFace; + } else if (aFace != aFace1) { aFace2 = aFace; @@ -1313,7 +1323,9 @@ TEST(BRepGraph_BuildTest, RegularityLayer_FaceMutation_InvalidatesBindings) } } if (!aFace1.IsValid() || !aFace2.IsValid()) + { continue; + } aRegularityLayer->SetRegularity(anEdgeId, aFace1, aFace2, GeomAbs_C1); aRegularity.FaceEntity1 = aFace1; aRegularity.FaceEntity2 = aFace2; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx index 0a83ba2523..0c13c5cbdf 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx @@ -708,12 +708,16 @@ TEST(BRepGraph_BuilderTest, RemoveSolid_CascadesToFaces) // All shells should be removed. const int aNbShells = aGraph.Topo().Shells().Nb(); for (BRepGraph_ShellId aShellId(0); aShellId.IsValid(aNbShells); ++aShellId) + { EXPECT_TRUE(aGraph.Topo().Gen().IsRemoved(aShellId)); + } // All faces should be removed. const int aNbFaces = aGraph.Topo().Faces().Nb(); for (BRepGraph_FaceId aFaceId(0); aFaceId.IsValid(aNbFaces); ++aFaceId) + { EXPECT_TRUE(aGraph.Topo().Gen().IsRemoved(aFaceId)); + } } TEST(BRepGraph_BuilderTest, RemoveSubgraph_SharedFace_PreservesSharedEdgesAndVertices) @@ -745,18 +749,24 @@ TEST(BRepGraph_BuilderTest, RemoveSubgraph_SharedFace_PreservesSharedEdgesAndVer // Other faces must remain active. for (int aIdx = 1; aIdx < aNbFaces; ++aIdx) + { EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(BRepGraph_FaceId(aIdx))); + } // All 12 edges of a box are shared by exactly 2 faces. // Removing 1 face leaves each shared edge with at least 1 active parent face. // Therefore all edges must remain active. for (int aIdx = 0; aIdx < aNbEdges; ++aIdx) + { EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(BRepGraph_EdgeId(aIdx))); + } // All 8 vertices of a box are shared by 3 edges. All edges are still active, // so all vertices must remain active. for (int aIdx = 0; aIdx < aNbVertices; ++aIdx) + { EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(BRepGraph_VertexId(aIdx))); + } } // ============================================================ @@ -806,7 +816,9 @@ TEST(BRepGraph_BuilderTest, SharedEdges_AdjacentBoxFaces) NCollection_DynamicArray aShared = aGraph.Topo().Faces().SharedEdges(aFaceA, aFaceB, aGraph.Allocator()); if (!aShared.IsEmpty()) + { ++aSharingPairs; + } } } // A box has 12 edges, each shared by 2 faces, so 12 sharing pairs. @@ -867,7 +879,9 @@ TEST(BRepGraph_BuilderTest, EdgesOfFace_Box_HasEdges) BRepGraph_NodeId::Kind::Edge); anExp.More(); anExp.Next()) + { ++aNbEdges; + } EXPECT_EQ(aNbEdges, 4); } @@ -885,7 +899,9 @@ TEST(BRepGraph_BuilderTest, VerticesOfEdge_Box_HasTwoVertices) BRepGraph_NodeId::Kind::Vertex); anExp.More(); anExp.Next()) + { ++aNbVertices; + } EXPECT_EQ(aNbVertices, 2); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx index 47f9d95aa5..f117b710ab 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx @@ -75,7 +75,9 @@ TEST(BRepGraph_ChildExplorerTest, Box_EdgeOccurrences_Count24) BRepGraph_NodeId::Kind::Edge); anExp.More(); anExp.Next()) + { ++aCount; + } // 12 edges x 2 faces each = 24 edge occurrences. EXPECT_EQ(aCount, 24); } @@ -94,7 +96,9 @@ TEST(BRepGraph_ChildExplorerTest, Box_FaceOccurrences_Count6) BRepGraph_NodeId::Kind::Face); anExp.More(); anExp.Next()) + { ++aFaceCount; + } EXPECT_EQ(aFaceCount, 6); } @@ -136,7 +140,9 @@ TEST(BRepGraph_ChildExplorerTest, Face_EdgeOccurrences_4) BRepGraph_NodeId::Kind::Edge); anExp.More(); anExp.Next()) + { ++aCount; + } EXPECT_EQ(aCount, 4); } @@ -404,7 +410,9 @@ TEST(BRepGraph_ChildExplorerTest, Compound_FaceCount) BRepGraph_NodeId::Kind::Face); anExp.More(); anExp.Next()) + { ++aCount; + } EXPECT_EQ(aCount, 12); // 6 + 6 faces } @@ -454,7 +462,9 @@ TEST(BRepGraph_ChildExplorerTest, DeepCompound_NoStackOverflow) BRepGraph_NodeId::Kind::Face); anExp.More(); anExp.Next()) + { ++aCount; + } EXPECT_EQ(aCount, 6); } @@ -469,7 +479,9 @@ TEST(BRepGraph_ChildExplorerTest, Recreate_ResetAndReexplore) int aFaceCount = 0; BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_SolidId::Start(), BRepGraph_NodeId::Kind::Face); for (; anExp.More(); anExp.Next()) + { ++aFaceCount; + } EXPECT_EQ(aFaceCount, 6); // Recreate targeting edges. @@ -479,7 +491,9 @@ TEST(BRepGraph_ChildExplorerTest, Recreate_ResetAndReexplore) BRepGraph_NodeId::Kind::Edge); anEdgeExp.More(); anEdgeExp.Next()) + { ++aEdgeCount; + } EXPECT_EQ(aEdgeCount, 24); } @@ -545,7 +559,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_CountAndOrder) { const BRepGraphInc::FaceRef& aRef = aGraph.Refs().Faces().Entry(aFaceRefId); if (!aRef.IsRemoved) + { anExpectedFaceIds.Append(aRef.FaceDefId.Index); + } } NCollection_DynamicArray anActualFaceIds; @@ -560,7 +576,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_CountAndOrder) ASSERT_EQ(anActualFaceIds.Length(), anExpectedFaceIds.Length()); for (int i = 0; i < anExpectedFaceIds.Length(); ++i) + { EXPECT_EQ(anActualFaceIds.Value(i), anExpectedFaceIds.Value(i)); + } } TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_ExposeParentAndRef) @@ -869,9 +887,13 @@ TEST(BRepGraph_ChildExplorerTest, Recursive_SharedProduct_ChildrenHaveDistinctCo { ASSERT_EQ(anIt.Current().DefId, BRepGraph_NodeId(BRepGraph_SolidId::Start())); if (aCount == 0) + { aLoc1 = anIt.Current().Location; + } else if (aCount == 1) + { aLoc2 = anIt.Current().Location; + } ++aCount; } @@ -950,7 +972,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_HighFanout_DirectChildrenComple constexpr int THE_NB_CHILDREN = 80; for (int i = 0; i < THE_NB_CHILDREN; ++i) + { aBuilder.Add(aComp, BRepPrimAPI_MakeBox(1.0 + i, 2.0, 3.0).Shape()); + } BRepGraph aGraph; aGraph.Clear(); @@ -964,7 +988,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_HighFanout_DirectChildrenComple BRepGraph_NodeId::Kind::Solid); anIt.More(); anIt.Next()) + { ++aCount; + } EXPECT_EQ(aCount, THE_NB_CHILDREN); } @@ -977,7 +1003,9 @@ TEST(BRepGraph_ChildExplorerTest, HighFanout_CompletesAllChildren) aBB.MakeCompound(aComp); constexpr int THE_NB_CHILDREN = 500; for (int i = 0; i < THE_NB_CHILDREN; ++i) + { aBB.Add(aComp, BRepPrimAPI_MakeBox(1, 1, 1).Shape()); + } BRepGraph aGraph; aGraph.Clear(); @@ -991,7 +1019,9 @@ TEST(BRepGraph_ChildExplorerTest, HighFanout_CompletesAllChildren) BRepGraph_NodeId::Kind::Face); anExp.More(); anExp.Next()) + { ++aFaceCount; + } // Each box has 6 faces. EXPECT_EQ(aFaceCount, THE_NB_CHILDREN * 6); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx index fc8d14264b..306a62698a 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx @@ -86,7 +86,9 @@ int countHistoryRecordsByOp(const BRepGraph& theGraph, const TCollection_AsciiSt for (size_t aRecIdx = 0; aRecIdx < theGraph.History().NbRecords(); ++aRecIdx) { if (theGraph.History().Record(aRecIdx).OperationName == theOp) + { ++aCount; + } } return aCount; } @@ -182,19 +184,27 @@ TEST(BRepGraph_CompactTest, IndexDensity_NoGaps) for (BRepGraph_VertexId aVertexId = BRepGraph_VertexId::Start(); aVertexId.IsValid(aGraph.Topo().Vertices().Nb()); ++aVertexId) + { EXPECT_FALSE(aGraph.Topo().Vertices().Definition(aVertexId).IsRemoved); + } for (BRepGraph_EdgeId anEdgeId = BRepGraph_EdgeId::Start(); anEdgeId.IsValid(aGraph.Topo().Edges().Nb()); ++anEdgeId) + { EXPECT_FALSE(aGraph.Topo().Edges().Definition(anEdgeId).IsRemoved); + } for (BRepGraph_FaceId aFaceId = BRepGraph_FaceId::Start(); aFaceId.IsValid(aGraph.Topo().Faces().Nb()); ++aFaceId) + { EXPECT_FALSE(aGraph.Topo().Faces().Definition(aFaceId).IsRemoved); + } for (BRepGraph_WireId aWireId = BRepGraph_WireId::Start(); aWireId.IsValid(aGraph.Topo().Wires().Nb()); ++aWireId) + { EXPECT_FALSE(aGraph.Topo().Wires().Definition(aWireId).IsRemoved); + } } TEST(BRepGraph_CompactTest, CrossReferences_Valid) @@ -609,7 +619,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) const BRepGraphInc::EdgeDef& anEdge = aGraph.Topo().Edges().Definition(BRepGraph_EdgeId::Start()); if (anEdge.StartVertexRefId.IsValid()) + { aVertexRefId = anEdge.StartVertexRefId; + } } // CoEdgeRef - from Face 1 wire (Face 0 will be removed before compact). @@ -621,7 +633,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) const BRepGraphInc::WireRef& aWireRef = aGraph.Refs().Wires().Entry(aFace.WireRefIds.First()); const BRepGraphInc::WireDef& aWire = aGraph.Topo().Wires().Definition(aWireRef.WireDefId); if (!aWire.CoEdgeRefIds.IsEmpty()) + { aCoEdgeRefId = aWire.CoEdgeRefIds.First(); + } } } @@ -631,7 +645,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) { const BRepGraphInc::FaceDef& aFace = aGraph.Topo().Faces().Definition(BRepGraph_FaceId(1)); if (!aFace.WireRefIds.IsEmpty()) + { aWireRefId = aFace.WireRefIds.First(); + } } // FaceRef - from Shell, pointing to Face 1 (skip Face 0 whose ref will be removed). @@ -650,7 +666,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) } } if (aFaceRefId.IsValid()) + { break; + } } } @@ -666,22 +684,34 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) break; } if (aShellRefId.IsValid()) + { break; + } } } // Capture RefUIDs before compact. BRepGraph_RefUID aVertexRefUID, aCoEdgeRefUID, aWireRefUID, aFaceRefUID, aShellRefUID; if (aVertexRefId.IsValid()) + { aVertexRefUID = aGraph.UIDs().Of(aVertexRefId); + } if (aCoEdgeRefId.IsValid()) + { aCoEdgeRefUID = aGraph.UIDs().Of(aCoEdgeRefId); + } if (aWireRefId.IsValid()) + { aWireRefUID = aGraph.UIDs().Of(aWireRefId); + } if (aFaceRefId.IsValid()) + { aFaceRefUID = aGraph.UIDs().Of(aFaceRefId); + } if (aShellRefId.IsValid()) + { aShellRefUID = aGraph.UIDs().Of(aShellRefId); + } // Remove one face to trigger compaction. aGraph.Editor().Gen().RemoveNode(BRepGraph_FaceId::Start()); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx index b1f9a027a2..0bcf7e4662 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx @@ -226,7 +226,9 @@ TEST_F(BRepGraph_ConvenienceTest, FindPCurve_WithOrientation_SeamEdge) { const BRepGraphInc::CoEdgeDef& aCE = aDefs.CoEdges().Definition(aCoEdgeId); if (!aCE.SeamPairId.IsValid()) + { continue; + } // Found seam edge - verify FindPCurve returns distinct entries for each orientation. const BRepGraph_FaceId aFaceDefId = aCE.FaceDefId; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx index 0eb179ce28..34ed18d76c 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx @@ -83,7 +83,9 @@ TEST(BRepGraph_CopyTest, CopyBox_FaceCount) int aNbFaces = 0; for (TopExp_Explorer anExp(aCopy, TopAbs_FACE); anExp.More(); anExp.Next()) + { ++aNbFaces; + } EXPECT_EQ(aNbFaces, 6); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx index 8ad47fb811..b4d07cdd12 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx @@ -121,7 +121,9 @@ int nbPCurveEntries(const BRepGraph& theGraph) const BRepGraphInc::CoEdgeDef& aCE = theGraph.Topo().CoEdges().Definition(aCoEdgeIdxs.Value(i)); if (aCE.FaceDefId.IsValid()) + { ++aCount; + } } } return aCount; @@ -1556,7 +1558,9 @@ TEST(BRepGraph_DeduplicateTest, BackRefs_CurveRewrite_UpdatesEdgeDefUsers) const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId(); const occ::handle& aCurve = BRepGraph_Tool::Edge::Curve(aGraph, anEdgeId); if (!aCurve.IsNull()) + { aDistinctCurves.Add(aCurve.get()); + } } // After dedup, 4 canonical curves should remain (from 8 originally). EXPECT_EQ(aDistinctCurves.Extent(), 4); @@ -2182,11 +2186,15 @@ TEST(BRepGraph_DeduplicateTest, WireDedup_PreservesShellAuxChildRefs) const BRepGraphInc::ChildRef& aRef = aGraph.Refs().Children().Entry(aSh.AuxChildRefIds.Value(aRefIdx)); if (aRef.IsRemoved) + { continue; + } const BRepGraphInc::WireDef& aWireDef = aGraph.Topo().Wires().Definition(BRepGraph_WireId(aRef.ChildDefId)); if (!aWireDef.IsRemoved) + { ++aNbActiveAuxChildren; + } } } EXPECT_EQ(aNbActiveAuxChildren, 1) << "AuxChildRef points to a removed wire after dedup"; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx index 330d74d510..ad6f58503f 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx @@ -119,16 +119,24 @@ public: bool HasImmediateEventFor(BRepGraph_NodeId theNode) const { for (const BRepGraph_NodeId& anEvent : myImmediateEvents) + { if (anEvent == theNode) + { return true; + } + } return false; } bool HasBatchEventFor(BRepGraph_NodeId theNode) const { for (const BRepGraph_NodeId& anEvent : myBatchEvents) + { if (anEvent == theNode) + { return true; + } + } return false; } @@ -136,8 +144,12 @@ public: { int aCount = 0; for (const BRepGraph_NodeId& anEvent : myImmediateEvents) + { if (anEvent.NodeKind == theKind) + { ++aCount; + } + } return aCount; } @@ -536,7 +548,9 @@ TEST_F(BRepGraph_EventBusTest, KindBit_Helpers) // 8 distinct bits set. int aBitCount = 0; for (int v = aAll; v != 0; v >>= 1) + { aBitCount += (v & 1); + } EXPECT_EQ(aBitCount, 8); } @@ -560,7 +574,9 @@ TEST_F(BRepGraph_EventBusTest, RefKindBit_Helpers) | BRepGraph_Layer::RefKindBit(Kind::Child) | BRepGraph_Layer::RefKindBit(Kind::Occurrence); int aBitCount = 0; for (int v = aAll; v != 0; v >>= 1) + { aBitCount += (v & 1); + } EXPECT_EQ(aBitCount, 8); } @@ -667,9 +683,13 @@ TEST_F(BRepGraph_EventBusTest, LayerIterator_RangeFor) BRepGraph_LayerIterator(myGraph.LayerRegistry())) { if (aLayer == aLayer1) + { hasL1 = true; + } if (aLayer == aLayer2) + { hasL2 = true; + } ++aCount; } EXPECT_EQ(aCount, 2); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx index fc50880fca..b38ee1877f 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx @@ -75,7 +75,9 @@ bool applyOne(BRepGraph& theGraph, std::mt19937& theRng) auto pickActiveEdge = [&](BRepGraph_EdgeId& theOut) -> bool { if (aNbEdges <= 0) + { return false; + } std::uniform_int_distribution aDist(0, aNbEdges - 1); for (int aTry = 0; aTry < 8; ++aTry) { @@ -91,7 +93,9 @@ bool applyOne(BRepGraph& theGraph, std::mt19937& theRng) auto pickActiveVertex = [&](BRepGraph_VertexId& theOut) -> bool { if (aNbVertices <= 0) + { return false; + } std::uniform_int_distribution aDist(0, aNbVertices - 1); for (int aTry = 0; aTry < 8; ++aTry) { @@ -110,7 +114,9 @@ bool applyOne(BRepGraph& theGraph, std::mt19937& theRng) case MutationKind::BumpEdgeTolerance: { BRepGraph_EdgeId anEdgeId; if (!pickActiveEdge(anEdgeId)) + { return false; + } BRepGraph_MutGuard aMut = theGraph.Editor().Edges().Mut(anEdgeId); theGraph.Editor().Edges().SetTolerance(aMut, aMut->Tolerance + 1.0e-4); return true; @@ -118,7 +124,9 @@ bool applyOne(BRepGraph& theGraph, std::mt19937& theRng) case MutationKind::MutateVertexPoint: { BRepGraph_VertexId aVtxId; if (!pickActiveVertex(aVtxId)) + { return false; + } BRepGraph_MutGuard aMut = theGraph.Editor().Vertices().Mut(aVtxId); const gp_Pnt aOld = aMut->Point; std::uniform_real_distribution aDist(-0.1, 0.1); @@ -129,11 +137,15 @@ bool applyOne(BRepGraph& theGraph, std::mt19937& theRng) } case MutationKind::BumpFaceTolerance: { if (aNbFaces <= 0) + { return false; + } std::uniform_int_distribution aDist(0, aNbFaces - 1); BRepGraph_FaceId aFaceId(aDist(theRng)); if (theGraph.Topo().Faces().Definition(aFaceId).IsRemoved) + { return false; + } BRepGraph_MutGuard aMut = theGraph.Editor().Faces().Mut(aFaceId); theGraph.Editor().Faces().SetTolerance(aMut, aMut->Tolerance + 1.0e-4); return true; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx index cf4faa4de7..6adfec9723 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx @@ -136,7 +136,9 @@ TEST(BRepGraph_GeometryTest, Sphere_AllFacesShareSurface) const BRepGraph_FaceId aFaceId = aFaceIt.CurrentId(); if (BRepGraph_Tool::Face::HasSurface(aGraph, aFaceId) && BRepGraph_Tool::Face::Surface(aGraph, aFaceId).get() == aFirstSurf.get()) + { ++aSameCount; + } } EXPECT_EQ(aSameCount, aGraph.Topo().Faces().Nb()); } @@ -780,7 +782,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_WithOrientation) { const BRepGraphInc::CoEdgeDef& aCE = aGraph.Topo().CoEdges().Definition(aCoEdgeId); if (!aCE.SeamPairId.IsValid()) + { continue; + } // This is a seam edge - test oriented overload. const BRepGraph_FaceId aFaceId(aCE.FaceDefId.Index); @@ -846,7 +850,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_DistinguishesOrientati { const BRepGraphInc::CoEdgeDef& aCE = aGraph.Topo().CoEdges().Definition(aCoEdgeId); if (!aCE.SeamPairId.IsValid()) + { continue; + } // Seam edge: same face, two orientations. const BRepGraph_FaceId aFaceId = aCE.FaceDefId; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx index b7d432c72a..a5f8f07858 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx @@ -114,9 +114,13 @@ TEST_F(BRepGraph_HistoryTest, FindDerived_ChainABC_ContainsBAndC) for (const BRepGraph_NodeId& aDerivedId : aDerived) { if (aDerivedId == anEdge1) + { hasEdge1 = true; + } if (aDerivedId == anEdge2) + { hasEdge2 = true; + } } EXPECT_TRUE(hasEdge1); EXPECT_TRUE(hasEdge2); @@ -228,9 +232,13 @@ TEST_F(BRepGraph_HistoryTest, ApplyModification_MultipleReplacements) for (const BRepGraph_NodeId& aDerivedId : aDerived) { if (aDerivedId == aNew1) + { hasNew1 = true; + } if (aDerivedId == aNew2) + { hasNew2 = true; + } } EXPECT_TRUE(hasNew1); EXPECT_TRUE(hasNew2); @@ -494,12 +502,18 @@ TEST_F(BRepGraph_HistoryTest, SplitEdge_IgnoresRemovedCoEdgeRefEntries) { const BRepGraphInc::CoEdgeRef& aRef = myGraph.Refs().CoEdges().Entry(aRefId); if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(myGraph.Topo().CoEdges().Nb())) + { continue; + } const BRepGraph_NodeId anId(myGraph.Topo().CoEdges().Definition(aRef.CoEdgeDefId).EdgeDefId); if (anId == aSubA) + { hasSubA = true; + } if (anId == aSubB) + { hasSubB = true; + } } EXPECT_TRUE(hasSubA); EXPECT_TRUE(hasSubB); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx index 40a7eb54fb..2b24737c5c 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx @@ -85,46 +85,62 @@ TEST_F(BRepGraph_MutationGenTest, SubtreeGen_PropagatedParent_Incremented) for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next()) { if (aWireIt.Current().SubtreeGen > 0u) + { aAnyWireSubtreeIncremented = true; + } } EXPECT_TRUE(aAnyWireSubtreeIncremented); // Verify parent OwnGen did NOT change (split behavior). for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next()) + { EXPECT_EQ(aWireIt.Current().OwnGen, 0u); + } bool aAnyFaceSubtreeIncremented = false; for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next()) { if (aFaceIt.Current().SubtreeGen > 0u) + { aAnyFaceSubtreeIncremented = true; + } } EXPECT_TRUE(aAnyFaceSubtreeIncremented); for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next()) + { EXPECT_EQ(aFaceIt.Current().OwnGen, 0u); + } bool aAnyShellSubtreeIncremented = false; for (BRepGraph_ShellIterator aShellIt(myGraph); aShellIt.More(); aShellIt.Next()) { if (aShellIt.Current().SubtreeGen > 0u) + { aAnyShellSubtreeIncremented = true; + } } EXPECT_TRUE(aAnyShellSubtreeIncremented); for (BRepGraph_ShellIterator aShellIt(myGraph); aShellIt.More(); aShellIt.Next()) + { EXPECT_EQ(aShellIt.Current().OwnGen, 0u); + } bool aAnySolidSubtreeIncremented = false; for (BRepGraph_SolidIterator aSolidIt(myGraph); aSolidIt.More(); aSolidIt.Next()) { if (aSolidIt.Current().SubtreeGen > 0u) + { aAnySolidSubtreeIncremented = true; + } } EXPECT_TRUE(aAnySolidSubtreeIncremented); for (BRepGraph_SolidIterator aSolidIt(myGraph); aSolidIt.More(); aSolidIt.Next()) + { EXPECT_EQ(aSolidIt.Current().OwnGen, 0u); + } } TEST_F(BRepGraph_MutationGenTest, SubtreeGen_DeferredPropagatedParent_Incremented) @@ -134,10 +150,14 @@ TEST_F(BRepGraph_MutationGenTest, SubtreeGen_DeferredPropagatedParent_Incremente myGraph.Topo().Edges().Definition(BRepGraph_EdgeId::Start()).OwnGen; NCollection_DynamicArray aWireSubtreeGensBefore; for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next()) + { aWireSubtreeGensBefore.Append(aWireIt.Current().SubtreeGen); + } NCollection_DynamicArray aFaceSubtreeGensBefore; for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next()) + { aFaceSubtreeGensBefore.Append(aFaceIt.Current().SubtreeGen); + } // Deferred mutation + flush. myGraph.Editor().BeginDeferredInvalidation(); @@ -151,17 +171,25 @@ TEST_F(BRepGraph_MutationGenTest, SubtreeGen_DeferredPropagatedParent_Incremente // At least one parent wire must have SubtreeGen incremented vs its baseline. bool aAnyWireSubtreeIncremented = false; for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next()) + { if (aWireIt.Current().SubtreeGen > aWireSubtreeGensBefore.Value(static_cast(aWireIt.CurrentId().Index))) + { aAnyWireSubtreeIncremented = true; + } + } EXPECT_TRUE(aAnyWireSubtreeIncremented); // At least one parent face must have SubtreeGen incremented vs its baseline. bool aAnyFaceSubtreeIncremented = false; for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next()) + { if (aFaceIt.Current().SubtreeGen > aFaceSubtreeGensBefore.Value(static_cast(aFaceIt.CurrentId().Index))) + { aAnyFaceSubtreeIncremented = true; + } + } EXPECT_TRUE(aAnyFaceSubtreeIncremented); } @@ -189,7 +217,9 @@ TEST_F(BRepGraph_MutationGenTest, RepMutation_Curve3DPropagatesSubtreeGenToEdge) const BRepGraph_EdgeId anEdgeId(0); const BRepGraph_Curve3DRepId aCurveId = myGraph.Topo().Edges().Definition(anEdgeId).Curve3DRepId; if (!aCurveId.IsValid()) + { return; // Skip degenerate edges without 3D curves. + } EXPECT_EQ(myGraph.Topo().Edges().Definition(anEdgeId).OwnGen, 0u); EXPECT_EQ(myGraph.Topo().Edges().Definition(anEdgeId).SubtreeGen, 0u); @@ -212,7 +242,9 @@ TEST_F(BRepGraph_MutationGenTest, RepMutation_Curve2DPropagatesSubtreeGenToCoEdg { const BRepGraph_Curve2DRepId aCurveId = aCoEdgeIt.Current().Curve2DRepId; if (!aCurveId.IsValid()) + { continue; + } const BRepGraph_CoEdgeId aCoEdgeId = aCoEdgeIt.CurrentId(); EXPECT_EQ(aCoEdgeIt.Current().OwnGen, 0u); @@ -238,7 +270,9 @@ TEST_F(BRepGraph_MutationGenTest, RepMutation_TriangulationPropagatesSubtreeGenT { const BRepGraphInc::FaceDef& aFace = aFaceIt.Current(); if (!aFace.TriangulationRepId.IsValid()) + { continue; + } const BRepGraph_FaceId aFaceId = aFaceIt.CurrentId(); const BRepGraph_TriangulationRepId aTriId = aFace.TriangulationRepId; @@ -265,7 +299,9 @@ TEST_F(BRepGraph_MutationGenTest, RepMutation_Polygon3DPropagatesSubtreeGenToEdg { const BRepGraph_Polygon3DRepId aPolyId = anEdgeIt.Current().Polygon3DRepId; if (!aPolyId.IsValid()) + { continue; + } const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId(); EXPECT_EQ(anEdgeIt.Current().OwnGen, 0u); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_PermissionUpdate_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_PermissionUpdate_Test.cxx index 546fb7d370..a0b98424de 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_PermissionUpdate_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_PermissionUpdate_Test.cxx @@ -78,18 +78,26 @@ TEST(BRepGraph_PermissionUpdateTest, RemoveRef_OccurrenceRef_PreservesProductToO bool aFoundBefore = false; for (const BRepGraph_OccurrenceId& anId : aGraph.Topo().Products().Instances(aChild)) + { if (anId == aOccId) + { aFoundBefore = true; + } + } EXPECT_TRUE(aFoundBefore) << "Occurrence must be indexed under referenced product before remove"; EXPECT_TRUE(aGraph.Editor().Gen().RemoveRef(BRepGraph_RefId(aOccRefId))); for (const BRepGraph_OccurrenceId& anId : aGraph.Topo().Products().Instances(aChild)) + { EXPECT_NE(anId, aOccId) << "RemoveRef must drop the referenced-product entry"; + } // The wrong-key bug would also leave a stale entry under the parent product id. for (const BRepGraph_OccurrenceId& anId : aGraph.Topo().Products().Instances(aParent)) + { EXPECT_NE(anId, aOccId) << "Bug: Unbind happened against parent product key"; + } } // B2: removing one CoEdgeRef must leave the wire's other usages of the same edge @@ -123,8 +131,12 @@ TEST(BRepGraph_PermissionUpdateTest, RemoveRef_CoEdge_PreservesEdgeToWireWhenSib auto containsWire = [&](const BRepGraph_EdgeId theE) -> bool { for (const BRepGraph_WireId& aW : aGraph.Topo().Edges().Wires(theE)) + { if (aW == aWireId) + { return true; + } + } return false; }; ASSERT_TRUE(containsWire(aEdge)) << "Edge->Wire reverse must be present before removal"; @@ -166,8 +178,12 @@ TEST(BRepGraph_PermissionUpdateTest, SetRefVertexDefId_SelfLoopSibling_KeepsRevI ASSERT_TRUE(aOldV.IsValid()); bool aOldStillIndexed = false; for (const BRepGraph_EdgeId& aE : aGraph.Topo().Vertices().Edges(aOldV)) + { if (aE == aEdge) + { aOldStillIndexed = true; + } + } EXPECT_TRUE(aOldStillIndexed) << "Vold must remain in EdgesOfVertex(Vold) after start-side rebind"; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx index 37d1cdbff2..26462535c3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx @@ -112,13 +112,17 @@ TEST(BRepGraph_PolygonTest, Polygon3D_Captured_WhenPresent) for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::HasPolygon3D(aGraph, anEdgeIt.CurrentId())) + { ++aNbPoly3DGraph; + } } for (TopExp_Explorer anExp(aBox, TopAbs_EDGE); anExp.More(); anExp.Next()) { TopLoc_Location aLoc; if (!BRep_Tool::Polygon3D(TopoDS::Edge(anExp.Current()), aLoc).IsNull()) + { ++aNbPoly3DOrig; + } } EXPECT_EQ(aNbPoly3DGraph, aNbPoly3DOrig) << "Graph Polygon3D count should match BRep_Tool::Polygon3D count"; @@ -127,7 +131,9 @@ TEST(BRepGraph_PolygonTest, Polygon3D_Captured_WhenPresent) for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (!BRepGraph_Tool::Edge::HasPolygon3D(aGraph, anEdgeIt.CurrentId())) + { continue; + } TopoDS_Shape aReconEdge = aGraph.Shapes().Reconstruct(anEdgeIt.CurrentId()); ASSERT_FALSE(aReconEdge.IsNull()); TopLoc_Location aPolyLoc; @@ -213,12 +219,16 @@ TEST(BRepGraph_PolygonTest, PolyOnTri_Roundtrip_PreservedOnReconstruct) TopLoc_Location aTriLoc; occ::handle aTri = BRep_Tool::Triangulation(aFace, aTriLoc); if (aTri.IsNull()) + { continue; + } TopLoc_Location aPolyLoc; occ::handle aPolyOnTri = BRep_Tool::PolygonOnTriangulation(anEdge, aTri, aPolyLoc); if (!aPolyOnTri.IsNull()) + { ++aNbReconPolyOnTri; + } } } @@ -279,7 +289,9 @@ TEST(BRepGraph_PolygonTest, VertexPointRepresentations_StructurallyValid) double aLast = 0.0; TopLoc_Location aLoc; if (BRep_Tool::Curve(anEdge, aLoc, aFirst, aLast).IsNull()) + { continue; + } for (TopoDS_Iterator aVtxIt(anEdge, false, false); aVtxIt.More(); aVtxIt.Next()) { @@ -319,7 +331,9 @@ TEST(BRepGraph_PolygonTest, VertexPointRepresentations_StructurallyValid) double aLast = 0.0; occ::handle aPCurve = BRep_Tool::CurveOnSurface(anEdge, aFace, aFirst, aLast); if (aPCurve.IsNull()) + { continue; + } aBuilder.UpdateEdge(anEdge, aPCurve, aFace, BRep_Tool::Tolerance(anEdge)); aBuilder.Range(anEdge, aFace, aFirst, aLast); @@ -358,18 +372,26 @@ TEST(BRepGraph_PolygonTest, VertexPointRepresentations_StructurallyValid) const BRepGraph_VertexId aVertexId = aVertexIt.CurrentId(); const BRepGraph_LayerParam::VertexParams* aParams = aParamLayer->FindVertexParams(aVertexId); if (aParams == nullptr) + { continue; + } aNbPointsOnCurve += aParams->PointsOnCurve.Length(); aNbPointsOnSurface += aParams->PointsOnSurface.Length(); aNbPointsOnPCurve += aParams->PointsOnPCurve.Length(); // Validate that any captured entries have valid def references. for (const BRepGraph_LayerParam::PointOnCurveEntry& anEntry : aParams->PointsOnCurve) + { EXPECT_TRUE(anEntry.EdgeDefId.IsValid()); + } for (const BRepGraph_LayerParam::PointOnSurfaceEntry& anEntry : aParams->PointsOnSurface) + { EXPECT_TRUE(anEntry.FaceDefId.IsValid()); + } for (const BRepGraph_LayerParam::PointOnPCurveEntry& anEntry : aParams->PointsOnPCurve) + { EXPECT_TRUE(anEntry.CoEdgeDefId.IsValid()); + } } EXPECT_GT(aNbPointsOnSurface, 0); @@ -393,11 +415,15 @@ TEST(BRepGraph_PolygonTest, EdgeRegularity_MatchesOriginal) const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); const occ::handle& aTEdge = occ::down_cast(anEdge.TShape()); if (aTEdge.IsNull()) + { continue; + } for (const occ::handle& aCRep : aTEdge->Curves()) { if (!occ::down_cast(aCRep).IsNull()) + { ++aNbOrigReg; + } } } @@ -450,7 +476,9 @@ TEST(BRepGraph_PolygonTest, SeamEdge_PolyOnTri_TwoEntries) const BRepGraphInc::CoEdgeDef& aCE = aGraph.Topo().CoEdges().Definition(aCoEdgeId); const int aFaceIdx = aCE.FaceDefId.Index; if (!aFaceCounts.IsBound(aFaceIdx)) + { aFaceCounts.Bind(aFaceIdx, 0); + } aFaceCounts.ChangeFind(aFaceIdx) += 1; } for (const auto& [aFaceIdx, aCount] : aFaceCounts.Items()) @@ -462,7 +490,9 @@ TEST(BRepGraph_PolygonTest, SeamEdge_PolyOnTri_TwoEntries) } } if (aFoundSeam) + { break; + } } // Seam edges on cylinder lateral face should produce two PolyOnTri entries. EXPECT_TRUE(aFoundSeam) << "Meshed cylinder should have seam edge with two PolyOnTri entries"; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx index 50204b3e3b..0dcbb04093 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx @@ -250,7 +250,9 @@ TEST(BRepGraph_ReconstructTest, Edge_HasCurve_NonNull) for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::Degenerated(aGraph, anEdgeIt.CurrentId())) + { continue; + } TopoDS_Shape aReconEdge = aGraph.Shapes().Reconstruct(BRepGraph_NodeId(anEdgeIt.CurrentId())); TopLoc_Location aLoc; @@ -276,7 +278,9 @@ TEST(BRepGraph_ReconstructTest, Edge_ParameterRange_Preserved) for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::Degenerated(aGraph, anEdgeIt.CurrentId())) + { continue; + } TopoDS_Shape aReconEdge = aGraph.Shapes().Reconstruct(BRepGraph_NodeId(anEdgeIt.CurrentId())); TopLoc_Location aLoc; @@ -341,7 +345,9 @@ TEST(BRepGraph_ReconstructTest, Face_PCurvesPresent_OnAllEdges) { const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); if (BRep_Tool::Degenerated(anEdge)) + { continue; + } double aFirst = 0.0; double aLast = 0.0; @@ -505,7 +511,9 @@ TEST(BRepGraph_ReconstructTest, Reconstruct_Edge_ValidShape) for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::Degenerated(aGraph, anEdgeIt.CurrentId())) + { continue; + } TopoDS_Shape aRecon = aGraph.Shapes().Reconstruct(BRepGraph_NodeId(anEdgeIt.CurrentId())); EXPECT_FALSE(aRecon.IsNull()); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx index c9b9b6c178..ea4563bdee 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx @@ -37,7 +37,9 @@ int countInlineFaceRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_ShellIterator aShellIt(theGraph); aShellIt.More(); aShellIt.Next()) + { aNb += BRepGraph_TestTools::CountFaceRefsOfShell(theGraph, aShellIt.CurrentId()); + } return aNb; } @@ -45,7 +47,9 @@ int countInlineWireRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_FaceIterator aFaceIt(theGraph); aFaceIt.More(); aFaceIt.Next()) + { aNb += BRepGraph_TestTools::CountWireRefsOfFace(theGraph, aFaceIt.CurrentId()); + } return aNb; } @@ -53,7 +57,9 @@ int countInlineCoEdgeRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_WireIterator aWireIt(theGraph); aWireIt.More(); aWireIt.Next()) + { aNb += BRepGraph_TestTools::CountCoEdgeRefsOfWire(theGraph, aWireIt.CurrentId()); + } return aNb; } @@ -64,13 +70,19 @@ int countInlineVertexRefs(const BRepGraph& theGraph) { const BRepGraphInc::EdgeDef& anEdge = anEdgeIt.Current(); if (anEdge.StartVertexRefId.IsValid()) + { ++aNb; + } if (anEdge.EndVertexRefId.IsValid()) + { ++aNb; + } aNb += anEdge.InternalVertexRefIds.Length(); } for (BRepGraph_FaceIterator aFaceIt(theGraph); aFaceIt.More(); aFaceIt.Next()) + { aNb += aFaceIt.Current().VertexRefIds.Length(); + } return aNb; } @@ -78,7 +90,9 @@ int countInlineShellRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_SolidIterator aSolidIt(theGraph); aSolidIt.More(); aSolidIt.Next()) + { aNb += BRepGraph_TestTools::CountShellRefsOfSolid(theGraph, aSolidIt.CurrentId()); + } return aNb; } @@ -86,7 +100,9 @@ int countInlineSolidRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_CompSolidIterator aCSIt(theGraph); aCSIt.More(); aCSIt.Next()) + { aNb += BRepGraph_TestTools::CountSolidRefsOfCompSolid(theGraph, aCSIt.CurrentId()); + } return aNb; } @@ -94,11 +110,17 @@ int countInlineChildRefs(const BRepGraph& theGraph) { int aNb = 0; for (BRepGraph_CompoundIterator aCompIt(theGraph); aCompIt.More(); aCompIt.Next()) + { aNb += BRepGraph_TestTools::CountChildRefsOfParent(theGraph, aCompIt.CurrentId()); + } for (BRepGraph_ShellIterator aShellIt(theGraph); aShellIt.More(); aShellIt.Next()) + { aNb += BRepGraph_TestTools::CountChildRefsOfParent(theGraph, aShellIt.CurrentId()); + } for (BRepGraph_SolidIterator aSolidIt(theGraph); aSolidIt.More(); aSolidIt.Next()) + { aNb += BRepGraph_TestTools::CountChildRefsOfParent(theGraph, aSolidIt.CurrentId()); + } return aNb; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_RefTestTools.hxx b/src/ModelingData/TKBRep/GTests/BRepGraph_RefTestTools.hxx index 341f00f68f..ddcbe4af2f 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_RefTestTools.hxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_RefTestTools.hxx @@ -40,7 +40,9 @@ inline NCollection_DynamicArray CoEdgeRefsOfWire( { const BRepGraphInc::CoEdgeRef& aRef = aRefs.CoEdges().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -66,7 +68,9 @@ inline NCollection_DynamicArray WireRefsOfFace( { const BRepGraphInc::WireRef& aRef = aRefs.Wires().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -90,7 +94,9 @@ inline bool FaceUsesWire(const BRepGraph& theGraph, for (const BRepGraph_WireRefId& aWireRefId : aWireRefs) { if (aRefs.Wires().Entry(aWireRefId).WireDefId == theWireId) + { return true; + } } return false; } @@ -109,7 +115,9 @@ inline NCollection_DynamicArray FaceRefsOfShell( { const BRepGraphInc::FaceRef& aRef = aRefs.Faces().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -135,7 +143,9 @@ inline NCollection_DynamicArray ShellRefsOfSolid( { const BRepGraphInc::ShellRef& aRef = aRefs.Shells().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -161,7 +171,9 @@ inline NCollection_DynamicArray SolidRefsOfCompSolid( { const BRepGraphInc::SolidRef& aRef = aRefs.Solids().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -187,7 +199,9 @@ inline NCollection_DynamicArray ChildRefsOfParent( { const BRepGraphInc::ChildRef& aRef = aRefs.Children().Entry(aRefId); if (aRef.ParentId == theParentId && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -219,7 +233,9 @@ inline NCollection_DynamicArray CoEdgeRefsOfWire( { const BRepGraphInc::CoEdgeRef& aRef = theStorage.CoEdgeRef(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -245,7 +261,9 @@ inline NCollection_DynamicArray WireRefsOfFace( { const BRepGraphInc::WireRef& aRef = theStorage.WireRef(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -270,7 +288,9 @@ inline bool FaceUsesWire(const BRepGraphInc_Storage& theStorage, { const BRepGraphInc::WireRef& aWireRef = theStorage.WireRef(aWireRefId); if (aWireRef.WireDefId == theWireId) + { return true; + } } return false; } @@ -288,7 +308,9 @@ inline NCollection_DynamicArray FaceRefsOfShell( { const BRepGraphInc::FaceRef& aRef = theStorage.FaceRef(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -314,7 +336,9 @@ inline NCollection_DynamicArray ShellRefsOfSolid( { const BRepGraphInc::ShellRef& aRef = theStorage.ShellRef(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -340,7 +364,9 @@ inline NCollection_DynamicArray SolidRefsOfCompSolid( { const BRepGraphInc::SolidRef& aRef = theStorage.SolidRef(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -365,7 +391,9 @@ inline NCollection_DynamicArray ChildRefsOfParent( { const BRepGraphInc::ChildRef& aRef = theStorage.ChildRef(aRefId); if (aRef.ParentId == theParentId && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -389,7 +417,9 @@ inline BRepGraph_WireId OuterWireOfFace(const BRepGraphInc_Storage& theStorage, { const BRepGraphInc::WireRef& aWireRef = theStorage.WireRef(aWireRefId); if (aWireRef.IsOuter) + { return aWireRef.WireDefId; + } } return BRepGraph_WireId(); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx index 2af8b92732..7bf19412c8 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx @@ -155,7 +155,9 @@ TEST(BRepGraph_ScenarioMatrix, Box_MutateVertex_ValidateReconstructPopulateRound { const TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current()); if (BRep_Tool::Pnt(aVtx).SquareDistance(aMutatedPt) < Precision::SquareConfusion()) + { aFoundMutatedVertex = true; + } } EXPECT_TRUE(aFoundMutatedVertex) << "Reconstructed solid must contain a vertex at the mutated point - " @@ -213,7 +215,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdge_MutationAndBothSubsystemsConsis const NCollection_DynamicArray* aCoEdges = aOrigStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdges == nullptr) + { continue; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdges) { if (aOrigStorage.CoEdge(aCoEdgeId).SeamPairId.IsValid()) @@ -266,7 +270,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdge_MutationAndBothSubsystemsConsis const NCollection_DynamicArray* aCoEdges = aReconStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdges == nullptr) + { continue; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdges) { if (aReconStorage.CoEdge(aCoEdgeId).SeamPairId.IsValid()) @@ -587,7 +593,9 @@ TEST(BRepGraph_ScenarioMatrix, Compound_BoxAndCylinder_MutationReconstructAreaRe const NCollection_DynamicArray* aCoEdges = aBaseStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdges == nullptr) + { continue; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdges) { if (aBaseStorage.CoEdge(aCoEdgeId).SeamPairId.IsValid()) @@ -651,7 +659,9 @@ TEST(BRepGraph_ScenarioMatrix, Compound_BoxAndCylinder_MutationReconstructAreaRe const NCollection_DynamicArray* aCoEdges = aReconStorage.ReverseIndex().CoEdgesOfEdge(anEdgeId); if (aCoEdges == nullptr) + { continue; + } for (const BRepGraph_CoEdgeId& aCoEdgeId : *aCoEdges) { if (aReconStorage.CoEdge(aCoEdgeId).SeamPairId.IsValid()) @@ -829,13 +839,17 @@ TEST(BRepGraph_ScenarioMatrix, Compound_MixedAtomicChildren_ReverseIndexCoverage aBB.MakeCompound(aShellContainer); TopExp_Explorer aShellExp(aBox, TopAbs_SHELL); if (aShellExp.More()) + { aFreeSh = aShellExp.Current(); + } } TopoDS_Shape aFreeFace; { TopExp_Explorer aFaceExp(aBox, TopAbs_FACE); if (aFaceExp.More()) + { aFreeFace = aFaceExp.Current(); + } } TopoDS_Edge aFreeEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, 0), gp_Pnt(10, 0, 0)); TopoDS_Vertex aFreeVertex; @@ -999,7 +1013,9 @@ TEST(BRepGraph_ScenarioMatrix, Sphere_SeamCoEdgePair_Bidirectional) { const BRepGraphInc::CoEdgeDef& aCoEdge = aStorage.CoEdge(aCoEdgeId); if (!aCoEdge.SeamPairId.IsValid()) + { continue; + } ++aNbPairedCoEdges; ASSERT_TRUE(aCoEdge.SeamPairId.IsValid(aStorage.NbCoEdges())); @@ -1033,7 +1049,9 @@ TEST(BRepGraph_ScenarioMatrix, Sphere_SeamCoEdgePair_Bidirectional) { const BRepGraphInc::CoEdgeDef& aCoEdge = aReconStorage.CoEdge(aCoEdgeId); if (!aCoEdge.SeamPairId.IsValid()) + { continue; + } ++aNbPairedAfter; const BRepGraphInc::CoEdgeDef& aPaired = aReconStorage.CoEdge(aCoEdge.SeamPairId); EXPECT_EQ(aPaired.SeamPairId, aCoEdgeId) @@ -1128,7 +1146,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_AuditStable) } } if (aSeamEdgeId.IsValid()) + { break; + } } ASSERT_TRUE(aSeamEdgeId.IsValid()) << "Cylinder must carry at least one seam edge"; @@ -1162,7 +1182,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_AuditStable) { const BRepGraphInc::CoEdgeDef& aCoEdge = aGraph.Topo().CoEdges().Definition(aCoEdgeId); if (!aCoEdge.SeamPairId.IsValid()) + { continue; + } const BRepGraphInc::CoEdgeDef& aPaired = aGraph.Topo().CoEdges().Definition(aCoEdge.SeamPairId); EXPECT_EQ(aPaired.SeamPairId, aCoEdgeId) @@ -1203,7 +1225,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_CoEdgeFaceIncidence) } } if (aSeamEdgeId.IsValid()) + { break; + } } ASSERT_TRUE(aSeamEdgeId.IsValid()); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx index 2f46a34062..e0e2972fde 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx @@ -166,7 +166,9 @@ TEST_F(BRepGraph_SharingTest, SharedEdge_IncidenceRefs_DifferentOrientation) const NCollection_DynamicArray& aCoEdgeIdxs = myGraph.Topo().Edges().CoEdges(anEdgeId); if (aCoEdgeIdxs.Length() < 2) + { continue; + } // Check if coedges reference different faces. const BRepGraph_NodeId aFace0 = myGraph.Topo().CoEdges().Definition(aCoEdgeIdxs.Value(0)).FaceDefId; @@ -191,7 +193,9 @@ TEST_F(BRepGraph_SharingTest, NonClosedEdge_StartEnd_Different) const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId(); const BRepGraphInc::EdgeDef& aDef = anEdgeIt.Current(); if (aDef.IsDegenerate) + { continue; + } // Box edges are not closed, so start and end vertex defs must differ const BRepGraph_VertexId aStartVtx = BRepGraph_Tool::Edge::StartVertexRef(myGraph, anEdgeId).VertexDefId; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx index 8dab418d9c..0882427c51 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx @@ -1045,7 +1045,9 @@ TEST_F(BRepGraphTest, FindPCurve_ValidPair) const BRepGraph_WireId anOuterWire = BRepGraph_TestTools::OuterWireOfFace(myGraph, aFaceIt.CurrentId()); if (!anOuterWire.IsValid()) + { continue; + } const NCollection_DynamicArray aCoEdgeRefs = BRepGraph_TestTools::CoEdgeRefsOfWire(myGraph, anOuterWire); for (const BRepGraph_CoEdgeRefId& aCoEdgeRefId : aCoEdgeRefs) @@ -1053,7 +1055,9 @@ TEST_F(BRepGraphTest, FindPCurve_ValidPair) const BRepGraphInc::CoEdgeRef& aCR = myGraph.Refs().CoEdges().Entry(aCoEdgeRefId); const BRepGraphInc::CoEdgeDef& aCoEdge = myGraph.Topo().CoEdges().Definition(aCR.CoEdgeDefId); if (BRepGraph_Tool::Edge::Degenerated(myGraph, BRepGraph_EdgeId(aCoEdge.EdgeDefId))) + { continue; + } const BRepGraphInc::CoEdgeDef* aPCurveEntry = BRepGraph_Tool::Edge::FindPCurve(myGraph, BRepGraph_EdgeId(aCoEdge.EdgeDefId), @@ -1068,17 +1072,29 @@ TEST_F(BRepGraphTest, UID_Unique) { NCollection_Map aUIDSet; for (BRepGraph_SolidIterator aSolidIt(myGraph); aSolidIt.More(); aSolidIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(aSolidIt.CurrentId())))); + } for (BRepGraph_ShellIterator aShellIt(myGraph); aShellIt.More(); aShellIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(aShellIt.CurrentId())))); + } for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(aFaceIt.CurrentId())))); + } for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(aWireIt.CurrentId())))); + } for (BRepGraph_EdgeIterator anEdgeIt(myGraph); anEdgeIt.More(); anEdgeIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(anEdgeIt.CurrentId())))); + } for (BRepGraph_VertexIterator aVertexIt(myGraph); aVertexIt.More(); aVertexIt.Next()) + { EXPECT_TRUE(aUIDSet.Add(myGraph.UIDs().Of(BRepGraph_NodeId(aVertexIt.CurrentId())))); + } // Surface/Curve geometry UIDs are no longer separate nodes; geometry is stored inline on defs. } @@ -1360,9 +1376,13 @@ TEST_F(BRepGraphTest, ParallelBuild_CompoundOfFaces) aBuilder.MakeCompound(aCompound); for (TopExp_Explorer anExp(aBox1.Shape(), TopAbs_FACE); anExp.More(); anExp.Next()) + { aBuilder.Add(aCompound, anExp.Current()); + } for (TopExp_Explorer anExp(aBox2.Shape(), TopAbs_FACE); anExp.More(); anExp.Next()) + { aBuilder.Add(aCompound, anExp.Current()); + } BRepGraph aGraph; aGraph.Clear(); @@ -1452,9 +1472,13 @@ TEST_F(BRepGraphTest, ReconstructFace_AfterEdgeReplace_ContainsNewEdge) occ::handle aCurve = BRep_Tool::Curve(TopoDS::Edge(anExp.Current()), aLoc, aFirst, aLast); if (!aCurve.IsNull() && !aNewCurve.IsNull() && aCurve.get() == aNewCurve.get()) + { isNewFound = true; + } if (!aCurve.IsNull() && !anOldCurve.IsNull() && aCurve.get() == anOldCurve.get()) + { isOldFound = true; + } } EXPECT_TRUE(isNewFound) << "New edge curve not found in reconstructed face"; EXPECT_FALSE(isOldFound) << "Old edge curve still present in reconstructed face"; @@ -1467,7 +1491,9 @@ TEST_F(BRepGraphTest, ReconstructShape_SolidRoot_SameFaceCount) int aFaceCount = 0; for (TopExp_Explorer anExp(aReconstructed, TopAbs_FACE); anExp.More(); anExp.Next()) + { ++aFaceCount; + } EXPECT_EQ(aFaceCount, 6); } @@ -1819,7 +1845,9 @@ TEST_F(BRepGraphTest, ApplyModification_MultiStepChain_FindOriginalTracesBack) for (const BRepGraph_NodeId& aDerivedId : aDerived) { if (aDerivedId == anEdge2) + { isEdge2Found = true; + } } EXPECT_TRUE(isEdge2Found) << "Edge2 not found in FindDerived(Edge0)"; @@ -1829,7 +1857,9 @@ TEST_F(BRepGraphTest, ApplyModification_MultiStepChain_FindOriginalTracesBack) for (const BRepGraph_NodeId& aDerivedId : aDerived1) { if (aDerivedId == anEdge2) + { isEdge2FromEdge1 = true; + } } EXPECT_TRUE(isEdge2FromEdge1) << "Edge2 not found in FindDerived(Edge1)"; } @@ -2260,7 +2290,9 @@ TEST_F(BRepGraphTest, EdgeDef_HasValidCurve3d) for (BRepGraph_EdgeIterator anEdgeIt(myGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::Degenerated(myGraph, anEdgeIt.CurrentId())) + { continue; + } EXPECT_TRUE(BRepGraph_Tool::Edge::HasCurve(myGraph, anEdgeIt.CurrentId())) << "Edge " << anEdgeIt.CurrentId().Index << " has no Curve3D rep"; @@ -2323,16 +2355,22 @@ TEST_F(BRepGraphTest, DetectToleranceConflicts_ManualConflict_Detected) { if (BRepGraph_Tool::Edge::Degenerated(myGraph, anEdgeId) || !BRepGraph_Tool::Edge::HasCurve(myGraph, anEdgeId)) + { continue; + } for (BRepGraph_EdgeId anOtherId(anEdgeId.Index + 1); anOtherId.IsValid(aNbEdges); ++anOtherId) { if (BRepGraph_Tool::Edge::Degenerated(myGraph, anOtherId) || !BRepGraph_Tool::Edge::HasCurve(myGraph, anOtherId)) + { continue; + } if (BRepGraph_Tool::Edge::Curve(myGraph, anEdgeId).get() != BRepGraph_Tool::Edge::Curve(myGraph, anOtherId).get()) + { continue; + } // Set very different tolerances on two edges sharing the same curve. myGraph.Editor().Edges().SetTolerance(anEdgeId, 0.001); @@ -2522,7 +2560,9 @@ TEST_F(BRepGraphTest, Face_InnerWireRefs_BoxHasNone) for (const BRepGraph_WireRefId& aWireRefId : aWireRefs) { if (!myGraph.Refs().Wires().Entry(aWireRefId).IsOuter) + { ++aNonOuterCount; + } } EXPECT_EQ(aNonOuterCount, 0) << "Box face " << aFaceIt.CurrentId().Index << " should have no inner wires"; @@ -2561,7 +2601,9 @@ TEST_F(BRepGraphTest, Edge_ParamRange_ValidBounds) for (BRepGraph_EdgeIterator anEdgeIt(myGraph); anEdgeIt.More(); anEdgeIt.Next()) { if (BRepGraph_Tool::Edge::Degenerated(myGraph, anEdgeIt.CurrentId())) + { continue; + } const auto [aFirst, aLast] = BRepGraph_Tool::Edge::Range(myGraph, anEdgeIt.CurrentId()); EXPECT_LT(aFirst, aLast) << "Edge " << anEdgeIt.CurrentId().Index << " has invalid parameter range [" << aFirst << ", " << aLast << "]"; @@ -2748,7 +2790,9 @@ TEST_F(BRepGraphTest, ReconstructShape_ShellRoot_SameFaceCount) int aFaceCount = 0; for (TopExp_Explorer aFaceExp(aReconstructed, TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) + { ++aFaceCount; + } EXPECT_EQ(aFaceCount, 6); } @@ -2784,7 +2828,9 @@ TEST_F(BRepGraphTest, Wire_OuterWireIdx_MatchesFaceDef) EXPECT_TRUE(anOuterWire.IsValid()) << "Face " << aFaceIt.CurrentId().Index << " has no outer wire"; if (!anOuterWire.IsValid()) + { continue; + } EXPECT_LT(anOuterWire.Index, myGraph.Topo().Wires().Nb()) << "Face " << aFaceIt.CurrentId().Index << " outer wire index out of range"; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx index a4e5253216..9e09cc2a3e 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx @@ -74,7 +74,9 @@ TEST_F(BRepGraph_QuerySurfaceTest, Face_Bounds_CylinderFaceReturnsSurfaceBounds) for (BRepGraph_FaceId aFaceId(0); aFaceId.IsValid(aNbFaces); ++aFaceId) { if (!BRepGraph_Tool::Face::HasSurface(myCylGraph, aFaceId)) + { continue; + } double uMin = 0.0, uMax = 0.0, vMin = 0.0, vMax = 0.0; BRepGraph_Tool::Face::Bounds(myCylGraph, aFaceId, uMin, uMax, vMin, vMax); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx index bb410f3db1..151a9c23f3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx @@ -57,7 +57,9 @@ NCollection_DynamicArray coEdgeRefsOfWire(const BRepGraph { const BRepGraphInc::CoEdgeRef& aRef = aRefs.CoEdges().Entry(aRefId); if (aRef.ParentId == aParentNode && !aRef.IsRemoved) + { aRefIds.Append(aRefId); + } } return aRefIds; } @@ -696,7 +698,9 @@ TEST(BRepGraph_ValidateTest, Audit_DetectsOrphanWireRef_AfterFaceRemoval) const BRepGraph_WireRefId aRefId(aRefIdx); const BRepGraphInc::WireRef& aRef = aRefs.Wires().Entry(aRefId); if (aRef.IsRemoved) + { continue; + } BRepGraph_MutGuard aMut = aGraph.Editor().Wires().MutRef(aRefId); aMut.Internal().ParentId = BRepGraph_NodeId(BRepGraph_NodeId::Kind::Face, 9999); aDidCorrupt = true; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx index 556d2362a1..ee09bc4eee 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx @@ -553,7 +553,9 @@ TEST_F(BRepGraph_ViewsTest, AttrsView_CacheKindIter_RangeFor) for (const occ::handle& aKind : myGraph.Cache().CacheKindIter(aFaceId)) { if (!aKind.IsNull() && aKind->ID() == testUserAttrKind()->ID()) + { hasUserKind = true; + } ++aCount; } EXPECT_EQ(aCount, 1); @@ -599,7 +601,9 @@ TEST_F(BRepGraph_ViewsTest, AttrsView_CacheKindIter_RefId_RangeFor) for (const occ::handle& aKind : myGraph.Cache().CacheKindIter(aRef)) { if (!aKind.IsNull() && aKind->ID() == testUserAttrKind()->ID()) + { hasUserKind = true; + } ++aCount; } EXPECT_EQ(aCount, 1); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx index 70c672185b..8fb55bb5c4 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx @@ -128,7 +128,9 @@ TEST_F(BRepGraph_WireExplorerTest, Reset_RestartsIteration) // Consume all edges. while (anExp.More()) + { anExp.Next(); + } EXPECT_FALSE(anExp.More()); // Reset and verify re-iteration works. diff --git a/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx index ab46e46816..cea31ad1a3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepTools_ReShape_Test.cxx @@ -169,7 +169,9 @@ TEST(BRepTools_ReShapeTest, Apply_DiamondSharingIsProcessedCorrectly) EXPECT_FALSE(anExp.Current().TShape() == aV2.TShape()) << "Original v2 must have been replaced on every diamond arm"; if (anExp.Current().TShape() == aV2Repl.TShape()) + { ++aNbReplVertices; + } } EXPECT_GE(aNbReplVertices, 2) << "Replacement must appear on both arms of the diamond"; } @@ -283,13 +285,17 @@ TEST(BRepTools_ReShapeTest, Apply_SharedEdgeAcrossTwoParents) { EXPECT_FALSE(anExp.Current().TShape() == aE1.TShape()); if (anExp.Current().TShape() == aE1New.TShape()) + { aFoundNewInA = true; + } } for (TopExp_Explorer anExp(aResultB, TopAbs_EDGE); anExp.More(); anExp.Next()) { EXPECT_FALSE(anExp.Current().TShape() == aE1.TShape()); if (anExp.Current().TShape() == aE1New.TShape()) + { aFoundNewInB = true; + } } EXPECT_TRUE(aFoundNewInA); EXPECT_TRUE(aFoundNewInB); diff --git a/src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx b/src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx index f3a18b56d4..7f076a30d0 100644 --- a/src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx @@ -211,7 +211,9 @@ TEST(TopoDS_Iterator_Test, ReInitialization) // Count first compound int aCount1 = 0; for (; anIt.More(); anIt.Next()) + { ++aCount1; + } EXPECT_EQ(aCount1, 3); // Re-initialize with second compound @@ -220,7 +222,9 @@ TEST(TopoDS_Iterator_Test, ReInitialization) // Count second compound int aCount2 = 0; for (; anIt.More(); anIt.Next()) + { ++aCount2; + } EXPECT_EQ(aCount2, 5); } diff --git a/src/ModelingData/TKBRep/TopExp/TopExp.cxx b/src/ModelingData/TKBRep/TopExp/TopExp.cxx index c9ea15b4f0..aab531d2b2 100644 --- a/src/ModelingData/TKBRep/TopExp/TopExp.cxx +++ b/src/ModelingData/TKBRep/TopExp/TopExp.cxx @@ -70,7 +70,9 @@ void TopExp::MapShapes(const TopoDS_Shape& S M.Add(S); TopoDS_Iterator It(S, cumOri, cumLoc); for (; It.More(); It.Next()) + { MapShapes(It.Value(), M); + } } //================================================================================================= @@ -95,7 +97,9 @@ void TopExp::MapShapesAndAncestors( { int index = M.FindIndex(exs.Current()); if (index == 0) + { index = M.Add(exs.Current(), empty); + } M(index).Append(anc); exs.Next(); } @@ -108,7 +112,9 @@ void TopExp::MapShapesAndAncestors( { int index = M.FindIndex(ex.Current()); if (index == 0) + { index = M.Add(ex.Current(), empty); + } ex.Next(); } } @@ -136,15 +142,23 @@ void TopExp::MapShapesAndUniqueAncestors( { int index = M.FindIndex(exs.Current()); if (index == 0) + { index = M.Add(exs.Current(), empty); + } NCollection_List& aList = M(index); // check if anc already exists in a list NCollection_List::Iterator it(aList); for (; it.More(); it.Next()) + { if (useOrientation ? anc.IsEqual(it.Value()) : anc.IsSame(it.Value())) + { break; + } + } if (!it.More()) + { aList.Append(anc); + } exs.Next(); } exa.Next(); @@ -156,7 +170,9 @@ void TopExp::MapShapesAndUniqueAncestors( { int index = M.FindIndex(ex.Current()); if (index == 0) + { M.Add(ex.Current(), empty); + } ex.Next(); } } @@ -169,7 +185,9 @@ TopoDS_Vertex TopExp::FirstVertex(const TopoDS_Edge& E, const bool CumOri) while (ite.More()) { if (ite.Value().Orientation() == TopAbs_FORWARD) + { return TopoDS::Vertex(ite.Value()); + } ite.Next(); } return TopoDS_Vertex(); @@ -183,7 +201,9 @@ TopoDS_Vertex TopExp::LastVertex(const TopoDS_Edge& E, const bool CumOri) while (ite.More()) { if (ite.Value().Orientation() == TopAbs_REVERSED) + { return TopoDS::Vertex(ite.Value()); + } ite.Next(); } return TopoDS_Vertex(); @@ -220,10 +240,14 @@ void TopExp::Vertices(const TopoDS_Edge& E, } if (!isFirstDefined) + { Vfirst.Nullify(); + } if (!isLastDefined) + { Vlast.Nullify(); + } } //================================================================================================= @@ -240,16 +264,24 @@ void TopExp::Vertices(const TopoDS_Wire& W, TopoDS_Vertex& Vfirst, TopoDS_Vertex { const TopoDS_Edge& E = TopoDS::Edge(it.Value()); if (E.Orientation() == TopAbs_REVERSED) + { TopExp::Vertices(E, V2, V1); + } else + { TopExp::Vertices(E, V1, V2); + } // add or remove in the vertex map V1.Orientation(TopAbs_FORWARD); V2.Orientation(TopAbs_REVERSED); if (!vmap.Add(V1)) + { vmap.Remove(V1); + } if (!vmap.Add(V2)) + { vmap.Remove(V2); + } it.Next(); } @@ -267,14 +299,22 @@ void TopExp::Vertices(const TopoDS_Wire& W, TopoDS_Vertex& Vfirst, TopoDS_Vertex NCollection_Map::Iterator ite(vmap); while (ite.More() && ite.Key().Orientation() != TopAbs_FORWARD) + { ite.Next(); + } if (ite.More()) + { Vfirst = TopoDS::Vertex(ite.Key()); + } ite.Initialize(vmap); while (ite.More() && ite.Key().Orientation() != TopAbs_REVERSED) + { ite.Next(); + } if (ite.More()) + { Vlast = TopoDS::Vertex(ite.Key()); + } } } diff --git a/src/ModelingData/TKBRep/TopExp/TopExp_Explorer.cxx b/src/ModelingData/TKBRep/TopExp/TopExp_Explorer.cxx index 846ea67e10..f1285bb0bd 100644 --- a/src/ModelingData/TKBRep/TopExp/TopExp_Explorer.cxx +++ b/src/ModelingData/TKBRep/TopExp/TopExp_Explorer.cxx @@ -82,7 +82,9 @@ void TopExp_Explorer::Init(const TopoDS_Shape& S, } if (toFind == TopAbs_SHAPE) + { hasMore = false; + } else { TopAbs_ShapeEnum ty = S.ShapeType(); @@ -127,7 +129,9 @@ void TopExp_Explorer::Next() } } else + { myStack[myStackTop].Next(); + } for (;;) { @@ -157,7 +161,9 @@ void TopExp_Explorer::Next() { popIterator(); if (myStackTop < 0) + { break; + } myStack[myStackTop].Next(); } } @@ -185,7 +191,9 @@ void TopExp_Explorer::Clear() // Reset live iterators to release shape references immediately, // but keep the array allocation to avoid Reallocate(0)/Reallocate(N) cycles. for (int i = myStackTop; i >= 0; --i) + { myStack[i] = TopoDS_Iterator(); + } myStackTop = -1; hasMore = false; } diff --git a/src/ModelingData/TKBRep/TopTools/TopTools_LocationSet.cxx b/src/ModelingData/TKBRep/TopTools/TopTools_LocationSet.cxx index a80507e7c0..f6718cb5c0 100644 --- a/src/ModelingData/TKBRep/TopTools/TopTools_LocationSet.cxx +++ b/src/ModelingData/TKBRep/TopTools/TopTools_LocationSet.cxx @@ -39,10 +39,14 @@ void TopTools_LocationSet::Clear() int TopTools_LocationSet::Add(const TopLoc_Location& L) { if (L.IsIdentity()) + { return 0; + } int n = myMap.FindIndex(L); if (n > 0) + { return n; + } TopLoc_Location N = L; do { @@ -58,7 +62,9 @@ const TopLoc_Location& TopTools_LocationSet::Location(const int I) const { static TopLoc_Location identity; if (I <= 0 || I > myMap.Extent()) + { return identity; + } return myMap(I); } @@ -67,7 +73,9 @@ const TopLoc_Location& TopTools_LocationSet::Location(const int I) const int TopTools_LocationSet::Index(const TopLoc_Location& L) const { if (L.IsIdentity()) + { return 0; + } return myMap.FindIndex(L); } @@ -79,31 +87,43 @@ static void WriteTrsf(const gp_Trsf& T, Standard_OStream& OS, const bool compact gp_Mat M = T.VectorialPart(); if (!compact) + { OS << "( "; + } OS << std::setw(15) << M(1, 1) << " "; OS << std::setw(15) << M(1, 2) << " "; OS << std::setw(15) << M(1, 3) << " "; OS << std::setw(15) << V.Coord(1) << " "; if (!compact) + { OS << " )"; + } OS << "\n"; if (!compact) + { OS << "( "; + } OS << std::setw(15) << M(2, 1) << " "; OS << std::setw(15) << M(2, 2) << " "; OS << std::setw(15) << M(2, 3) << " "; OS << std::setw(15) << V.Coord(2) << " "; if (!compact) + { OS << " )"; + } OS << "\n"; if (!compact) + { OS << "( "; + } OS << std::setw(15) << M(3, 1) << " "; OS << std::setw(15) << M(3, 2) << " "; OS << std::setw(15) << M(3, 3) << " "; OS << std::setw(15) << V.Coord(3) << " "; if (!compact) + { OS << " )"; + } OS << "\n"; } @@ -136,7 +156,9 @@ void TopTools_LocationSet::Dump(Standard_OStream& OS) const { OS << "Complex : L" << myMap.FindIndex(L1); if (p != 1) + { OS << "^" << p; + } while (!L2.IsIdentity()) { L1 = L2.FirstDatum(); @@ -144,7 +166,9 @@ void TopTools_LocationSet::Dump(Standard_OStream& OS) const L2 = L2.NextLocation(); OS << " * L" << myMap.FindIndex(L1); if (p != 1) + { OS << "^" << p; + } } OS << "\n"; } @@ -219,7 +243,6 @@ static void ReadTrsf(gp_Trsf& T, Standard_IStream& IS) GeomTools::GetReal(IS, V[2]); T.SetValues(V1[0], V1[1], V1[2], V[0], V2[0], V2[1], V2[2], V[1], V3[0], V3[1], V3[2], V[2]); - return; } //================================================================================================= @@ -234,7 +257,7 @@ void TopTools_LocationSet::Read(Standard_IStream& IS, const Message_ProgressRang IS >> buffer; if (strcmp(buffer, "Locations")) { - std::cout << "Not a location table " << std::endl; + std::cout << "Not a location table " << '\n'; return; } @@ -271,6 +294,8 @@ void TopTools_LocationSet::Read(Standard_IStream& IS, const Message_ProgressRang } if (!L.IsIdentity()) + { myMap.Add(L); + } } } diff --git a/src/ModelingData/TKBRep/TopTools/TopTools_ShapeSet.cxx b/src/ModelingData/TKBRep/TopTools/TopTools_ShapeSet.cxx index 1b937e29a4..3bc065bf41 100644 --- a/src/ModelingData/TKBRep/TopTools/TopTools_ShapeSet.cxx +++ b/src/ModelingData/TKBRep/TopTools/TopTools_ShapeSet.cxx @@ -80,7 +80,9 @@ void TopTools_ShapeSet::Clear() int TopTools_ShapeSet::Add(const TopoDS_Shape& S) { if (S.IsNull()) + { return 0; + } myLocations.Add(S.Location()); TopoDS_Shape S2 = S; S2.Location(TopLoc_Location()); @@ -90,7 +92,9 @@ int TopTools_ShapeSet::Add(const TopoDS_Shape& S) AddGeometry(S2); for (TopoDS_Iterator its(S2, false, false); its.More(); its.Next()) + { Add(its.Value()); + } index = myShapes.Add(S2); } return index; @@ -133,65 +137,101 @@ static void PrintShapeEnum(const TopAbs_ShapeEnum T, Standard_OStream& S, bool C case TopAbs_VERTEX: if (C) + { S << "Ve"; + } else + { S << "VERTEX "; + } break; case TopAbs_EDGE: if (C) + { S << "Ed"; + } else + { S << "EDGE "; + } break; case TopAbs_WIRE: if (C) + { S << "Wi"; + } else + { S << "WIRE "; + } break; case TopAbs_FACE: if (C) + { S << "Fa"; + } else + { S << "FACE "; + } break; case TopAbs_SHELL: if (C) + { S << "Sh"; + } else + { S << "SHELL "; + } break; case TopAbs_SOLID: if (C) + { S << "So"; + } else + { S << "SOLID "; + } break; case TopAbs_COMPSOLID: if (C) + { S << "CS"; + } else + { S << "COMPSOLID"; + } break; case TopAbs_COMPOUND: if (C) + { S << "Co"; + } else + { S << "COMPOUND "; + } break; case TopAbs_SHAPE: if (C) + { S << "Sp"; + } else + { S << "SHAPE"; + } break; } } @@ -205,30 +245,46 @@ static void PrintOrientation(const TopAbs_Orientation O, Standard_OStream& S, bo case TopAbs_FORWARD: if (C) + { S << "+"; + } else + { S << "FORWARD"; + } break; case TopAbs_REVERSED: if (C) + { S << "-"; + } else + { S << "REVERSED"; + } break; case TopAbs_INTERNAL: if (C) + { S << "i"; + } else + { S << "INTERNAL"; + } break; case TopAbs_EXTERNAL: if (C) + { S << "e"; + } else + { S << "EXTERNAL"; + } break; } } @@ -418,7 +474,9 @@ void TopTools_ShapeSet::Dump(Standard_OStream& OS) const PrintOrientation(sub.Orientation(), OS, true); OS << nbShapes - myShapes.FindIndex(sub.Located(TopLoc_Location())) + 1; if (!sub.Location().IsIdentity()) + { OS << "(L" << myLocations.Index(sub.Location()) << ")"; + } OS << " "; its.Next(); } @@ -541,7 +599,9 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS, const Message_ProgressRange& OS.imbue(anOldLocale); if (aPS.UserBreak()) + { OS << "Interrupted by the user\n"; + } } //================================================================================================= @@ -568,15 +628,23 @@ static TopAbs_ShapeEnum ReadShapeEnum(Standard_IStream& IS) case 'S': if (buffer[1] == 'h') + { return TopAbs_SHELL; + } else + { return TopAbs_SOLID; + } case 'C': if (buffer[1] == 'S') + { return TopAbs_COMPSOLID; + } else + { return TopAbs_COMPOUND; + } } return TopAbs_COMPOUND; } @@ -606,7 +674,9 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (lv > 0) { for (lv--; lv > 0 && (vers[lv] == '\r' || vers[lv] == '\n'); lv--) + { vers[lv] = '\0'; + } } for (int i = TopTools_FormatVersion_LOWER; i <= TopTools_FormatVersion_UPPER; ++i) { @@ -625,7 +695,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& } while (!IS.fail()); if (IS.fail()) { - std::cout << "File was not written with this version of the topology" << std::endl; + std::cout << "File was not written with this version of the topology" << '\n'; IS.imbue(anOldLocale); return; } @@ -640,7 +710,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (aPS.UserBreak()) { - std::cout << "Interrupted by the user" << std::endl; + std::cout << "Interrupted by the user" << '\n'; // restore LC_NUMERIC to the previous value IS.imbue(anOldLocale); return; @@ -653,7 +723,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& if (aPS.UserBreak()) { - std::cout << "Interrupted by the user" << std::endl; + std::cout << "Interrupted by the user" << '\n'; IS.imbue(anOldLocale); return; } @@ -666,7 +736,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& IS >> buffer; if (strcmp(buffer, "TShapes")) { - std::cout << "Not a TShape table" << std::endl; + std::cout << "Not a TShape table" << '\n'; // restore LC_NUMERIC to the previous value IS.imbue(anOldLocale); return; @@ -695,7 +765,9 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& { Read(SS, IS, nbShapes); if (!SS.IsNull()) + { AddShapes(S, SS); + } } while (!SS.IsNull()); S.Free(buffer[0] == '1'); @@ -712,7 +784,9 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& // check if (myFormatNb == TopTools_FormatVersion_VERSION_1) + { Check(T, S); + } myShapes.Add(S); } @@ -721,7 +795,9 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& IS.imbue(anOldLocale); if (aPS.UserBreak()) - std::cout << "Interrupted by the user" << std::endl; + { + std::cout << "Interrupted by the user" << '\n'; + } } //================================================================================================= @@ -729,12 +805,16 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange& void TopTools_ShapeSet::Dump(const TopoDS_Shape& S, Standard_OStream& OS) const { if (S.IsNull()) + { OS << "Null shape\n"; + } OS << "Shape : " << myShapes.FindIndex(S.Located(TopLoc_Location())); OS << ", "; PrintOrientation(S.Orientation(), OS, false); if (!S.Location().IsIdentity()) + { OS << ", location : " << myLocations.Index(S.Location()); + } OS << "\n"; } @@ -743,7 +823,9 @@ void TopTools_ShapeSet::Dump(const TopoDS_Shape& S, Standard_OStream& OS) const void TopTools_ShapeSet::Write(const TopoDS_Shape& S, Standard_OStream& OS) const { if (S.IsNull()) + { OS << "*"; + } else { PrintOrientation(S.Orientation(), OS, true); @@ -771,7 +853,9 @@ void TopTools_ShapeSet::Read(TopoDS_Shape& S, Standard_IStream& IS, const int nb char buffer[255]; IS >> buffer; if (buffer[0] == '*') + { S = TopoDS_Shape(); + } else { S = myShapes(nbshapes - atoi(buffer + 1) + 1); diff --git a/src/ModelingData/TKBRep/TopoDS/TopoDS_Builder.cxx b/src/ModelingData/TKBRep/TopoDS/TopoDS_Builder.cxx index c88a4abe3c..73027e0e38 100644 --- a/src/ModelingData/TKBRep/TopoDS/TopoDS_Builder.cxx +++ b/src/ModelingData/TKBRep/TopoDS/TopoDS_Builder.cxx @@ -75,12 +75,16 @@ void TopoDS_Builder::Add(TopoDS_Shape& aShape, const TopoDS_Shape& aComponent) c // compute the relative Orientation if (aShape.Orientation() == TopAbs_REVERSED) + { aChild.Reverse(); + } // and the Relative Location const TopLoc_Location& aLoc = aShape.Location(); if (!aLoc.IsIdentity()) + { aChild.Move(aLoc.Inverted(), false); + } // Add to the subshapes list TopoDS_TShape* aTShape = aShape.TShape().get(); @@ -108,7 +112,9 @@ void TopoDS_Builder::Remove(TopoDS_Shape& aShape, const TopoDS_Shape& aComponent // compute the relative Orientation and Location of aComponent TopoDS_Shape S = aComponent; if (aShape.Orientation() == TopAbs_REVERSED) + { S.Reverse(); + } S.Location(S.Location().Predivided(aShape.Location()), false); TopoDS_TShape* aTShape = aShape.TShape().get(); diff --git a/src/ModelingData/TKBRep/TopoDS/TopoDS_Iterator.cxx b/src/ModelingData/TKBRep/TopoDS/TopoDS_Iterator.cxx index cfc625f69c..f1d913f27e 100644 --- a/src/ModelingData/TKBRep/TopoDS/TopoDS_Iterator.cxx +++ b/src/ModelingData/TKBRep/TopoDS/TopoDS_Iterator.cxx @@ -24,14 +24,22 @@ void TopoDS_Iterator::Initialize(const TopoDS_Shape& S, const bool cumOri, const bool cumLoc) { if (cumLoc) + { myLocation = S.Location(); + } else + { myLocation.Identity(); + } if (cumOri) + { myOrientation = S.Orientation(); + } else + { myOrientation = TopAbs_FORWARD; + } if (S.IsNull()) { @@ -66,5 +74,7 @@ void TopoDS_Iterator::updateCurrentShape() myShape = myIterator.Value(); myShape.Orientation(TopAbs::Compose(myOrientation, myShape.Orientation())); if (!myLocation.IsIdentity()) + { myShape.Move(myLocation, false); + } } diff --git a/src/ModelingData/TKG2d/Adaptor2d/Adaptor2d_OffsetCurve.cxx b/src/ModelingData/TKG2d/Adaptor2d/Adaptor2d_OffsetCurve.cxx index b46ba095a9..30df6e2111 100644 --- a/src/ModelingData/TKG2d/Adaptor2d/Adaptor2d_OffsetCurve.cxx +++ b/src/ModelingData/TKG2d/Adaptor2d/Adaptor2d_OffsetCurve.cxx @@ -152,14 +152,20 @@ int Adaptor2d_OffsetCurve::NbIntervals(const GeomAbs_Shape S) const { GeomAbs_Shape Sh; if (S >= GeomAbs_C2) + { Sh = GeomAbs_CN; + } else + { Sh = (GeomAbs_Shape)((int)S + 2); + } int nbInter = myCurve->NbIntervals(Sh); if (nbInter == 1) + { return nbInter; + } NCollection_Array1 T(1, nbInter + 1); @@ -167,10 +173,14 @@ int Adaptor2d_OffsetCurve::NbIntervals(const GeomAbs_Shape S) const int first = 1; while (T(first) <= myFirst) + { first++; + } int last = nbInter + 1; while (T(last) >= myLast) + { last--; + } return (last - first + 2); } @@ -180,9 +190,13 @@ void Adaptor2d_OffsetCurve::Intervals(NCollection_Array1& TI, const Geom { GeomAbs_Shape Sh; if (S >= GeomAbs_C2) + { Sh = GeomAbs_CN; + } else + { Sh = (GeomAbs_Shape)((int)S + 2); + } int nbInter = myCurve->NbIntervals(Sh); @@ -198,10 +212,14 @@ void Adaptor2d_OffsetCurve::Intervals(NCollection_Array1& TI, const Geom int first = 1; while (T(first) <= myFirst) + { first++; + } int last = nbInter + 1; while (T(last) >= myLast) + { last--; + } int i = TI.Lower(), j; for (j = first - 1; j <= last + 1; j++) @@ -236,7 +254,9 @@ bool Adaptor2d_OffsetCurve::IsClosed() const else { if (myCurve->Continuity() == GeomAbs_C0) + { return false; + } else { if (myCurve->IsClosed()) @@ -249,7 +269,9 @@ bool Adaptor2d_OffsetCurve::IsClosed() const && !(Dummy[0].IsOpposite(Dummy[1], Precision::Angular())); } else + { return false; + } } } } @@ -575,7 +597,9 @@ static int nbPoints(const occ::handle& theCurve) } if (nbs > 300) + { nbs = 300; + } return nbs; } diff --git a/src/ModelingData/TKG2d/GTests/Geom2d_BSplineCurve_Test.cxx b/src/ModelingData/TKG2d/GTests/Geom2d_BSplineCurve_Test.cxx index 89e10eff2c..abf7b5ae56 100644 --- a/src/ModelingData/TKG2d/GTests/Geom2d_BSplineCurve_Test.cxx +++ b/src/ModelingData/TKG2d/GTests/Geom2d_BSplineCurve_Test.cxx @@ -276,7 +276,9 @@ TEST_F(Geom2d_BSplineCurve_Test, PeriodicCurve) NCollection_Array1 aKnots(1, 6); for (int i = 1; i <= 6; ++i) + { aKnots(i) = (i - 1) * 0.2; + } NCollection_Array1 aMults(1, 6); aMults.Init(1); diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx index c2d877efc5..c0287b5c3e 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx @@ -69,9 +69,13 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() < 2) + { throw Standard_ConstructionError("BSpline curve: at least 2 poles required"); + } if (CKnots.Length() != CMults.Length()) + { throw Standard_ConstructionError("BSpline curve: Knot and Mult array size mismatch"); + } for (int I = CKnots.Lower(); I < CKnots.Upper(); I++) { @@ -82,7 +86,9 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() != BSplCLib::NbPoles(Degree, Periodic, CMults)) + { throw Standard_ConstructionError("BSpline curve: # Poles and degree mismatch"); + } } //! Check rationality of an array of weights @@ -179,7 +185,9 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve(const NCollection_Array1& Pol CheckCurveData(Poles, Knots, Mults, Degree, Periodic); if (Weights.Length() != Poles.Length()) + { throw Standard_ConstructionError("Geom2d_BSplineCurve: Weights and Poles array size mismatch"); + } int i; for (i = Weights.Lower(); i <= Weights.Upper(); i++) @@ -228,7 +236,9 @@ int Geom2d_BSplineCurve::MaxDegree() void Geom2d_BSplineCurve::IncreaseDegree(const int Degree) { if (Degree == myDeg) + { return; + } if (Degree < myDeg || Degree > Geom2d_BSplineCurve::MaxDegree()) { @@ -270,9 +280,13 @@ void Geom2d_BSplineCurve::IncreaseDegree(const int Degree) myDeg = Degree; myPoles = std::move(npoles); if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myKnots = std::move(nknots); myMults = std::move(nmults); updateKnots(); @@ -297,7 +311,9 @@ void Geom2d_BSplineCurve::IncreaseMultiplicity(const int I1, const int I2, const NCollection_Array1 m(I1, I2); int i; for (i = I1; i <= I2; i++) + { m(i) = M - myMults.Value(i); + } InsertKnots(k, m, Epsilon(1.), true); } @@ -342,10 +358,14 @@ void Geom2d_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, nbknots, Epsilon, Add)) + { throw Standard_ConstructionError("Geom2d_BSplineCurve::InsertKnots"); + } if (nbpoles == myPoles.Length()) + { return; + } NCollection_Array1 npoles(1, nbpoles); NCollection_Array1 nknots(1, nbknots); @@ -372,9 +392,13 @@ void Geom2d_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, Epsilon, Add); if (myRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(npoles.Length()); + } myPoles = std::move(npoles); myKnots = std::move(nknots); myMults = std::move(nmults); @@ -386,7 +410,9 @@ void Geom2d_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, bool Geom2d_BSplineCurve::RemoveKnot(const int Index, const int M, const double Tolerance) { if (M < 0) + { return true; + } int I1 = FirstUKnotIndex(); int I2 = LastUKnotIndex(); @@ -400,7 +426,9 @@ bool Geom2d_BSplineCurve::RemoveKnot(const int Index, const int M, const double int step = myMults.Value(Index) - M; if (step <= 0) + { return true; + } NCollection_Array1 npoles(1, oldpoles.Length() - step); @@ -431,9 +459,13 @@ bool Geom2d_BSplineCurve::RemoveKnot(const int Index, const int M, const double } if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(npoles.Length()); + } myPoles = std::move(npoles); myKnots = std::move(nknots); myMults = std::move(nmults); @@ -448,10 +480,14 @@ bool Geom2d_BSplineCurve::RemoveKnot(const int Index, const int M, const double void Geom2d_BSplineCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, const double Weight) { if (Index < 0 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: InsertPoleAfter: Index and #pole mismatch"); + } if (Weight <= gp::Resolution()) + { throw Standard_ConstructionError("BSpline curve: InsertPoleAfter: Weight too small"); + } if (myKnotSet == GeomAbs_NonUniform || myKnotSet == GeomAbs_PiecewiseBezier) { @@ -476,7 +512,9 @@ void Geom2d_BSplineCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, co const NCollection_Array1& cmults = myMults; for (i = 2; i <= nbknots; i++) + { nmults(i) = 1; + } nmults(1) = cmults(1); nmults(nbknots + 1) = cmults(nbknots); @@ -487,12 +525,16 @@ void Geom2d_BSplineCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, co // insert the pole for (i = 1; i <= Index; i++) + { npoles(i) = cpoles(i); + } npoles(Index + 1) = P; for (i = Index + 1; i <= nbpoles; i++) + { npoles(i + 1) = cpoles(i); + } // Insert the weight @@ -504,25 +546,41 @@ void Geom2d_BSplineCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, co nweights.Resize(1, nbpoles + 1, false); for (i = 1; i <= Index; i++) + { if (IsRational()) + { nweights(i) = myWeights.Value(i); + } else + { nweights(i) = 1.; + } + } nweights(Index + 1) = Weight; for (i = Index + 1; i <= nbpoles; i++) + { if (IsRational()) + { nweights(i + 1) = myWeights.Value(i); + } else + { nweights(i + 1) = 1.; + } + } } myPoles = std::move(npoles); if (rat) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myRational = rat; myKnots = std::move(nknots); myMults = std::move(nmults); @@ -542,13 +600,19 @@ void Geom2d_BSplineCurve::InsertPoleBefore(const int Index, const gp_Pnt2d& P, c void Geom2d_BSplineCurve::RemovePole(const int Index) { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: RemovePole: Index and #pole mismatch"); + } if (myPoles.Length() <= 2) + { throw Standard_ConstructionError("BSpline curve: RemovePole: #pole is already minimum"); + } if (myKnotSet == GeomAbs_NonUniform || myKnotSet == GeomAbs_PiecewiseBezier) + { throw Standard_ConstructionError("BSpline curve: RemovePole: bad knotSet type"); + } int i; NCollection_Array1 nknots(1, myKnots.Length() - 1); @@ -567,18 +631,26 @@ void Geom2d_BSplineCurve::RemovePole(const int Index) NCollection_Array1 npoles(1, myPoles.Upper() - 1); for (i = 1; i < Index; i++) + { npoles(i) = myPoles.Value(i); + } for (i = Index; i <= npoles.Length(); i++) + { npoles(i) = myPoles.Value(i + 1); + } NCollection_Array1 nweights; if (IsRational()) { nweights.Resize(1, npoles.Length(), false); for (i = 1; i < Index; i++) + { nweights(i) = myWeights.Value(i); + } for (i = Index; i <= nweights.Length(); i++) + { nweights(i) = myWeights.Value(i + 1); + } } myPoles = std::move(npoles); @@ -587,7 +659,9 @@ void Geom2d_BSplineCurve::RemovePole(const int Index) myWeights = std::move(nweights); myRational = Rational(myWeights); if (!myRational) + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } } else { @@ -606,12 +680,18 @@ void Geom2d_BSplineCurve::Reverse() BSplCLib::Reverse(myMults); int last; if (myPeriodic) + { last = myFlatKnots.Upper() - myDeg - 1; + } else + { last = myPoles.Upper(); + } BSplCLib::Reverse(myPoles, last); if (myRational) + { BSplCLib::Reverse(myWeights, last); + } updateKnots(); } @@ -627,7 +707,9 @@ double Geom2d_BSplineCurve::ReversedParameter(const double U) const void Geom2d_BSplineCurve::Segment(const double aU1, const double aU2, const double theTolerance) { if (aU2 < aU1) + { throw Standard_DomainError("Geom2d_BSplineCurve::Segment"); + } double NewU1, NewU2; double U, DU = 0, aDDU = 0; @@ -645,9 +727,13 @@ void Geom2d_BSplineCurve::Segment(const double aU1, const double aU2, const doub double Period = LastParameter() - FirstParameter(); DU = U2 - U1; if (DU - Period > Precision::PConfusion()) + { throw Standard_DomainError("Geom2d_BSplineCurve::Segment"); + } if (DU > Period) + { DU = Period; + } aDDU = DU; } @@ -790,9 +876,13 @@ void Geom2d_BSplineCurve::Segment(const double aU1, const double aU2, const doub myMults = std::move(nmults); myPoles = std::move(npoles); if (myRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myMaxDerivInvOk = false; updateKnots(); } @@ -802,12 +892,16 @@ void Geom2d_BSplineCurve::Segment(const double aU1, const double aU2, const doub void Geom2d_BSplineCurve::SetKnot(const int Index, const double K) { if (Index < 1 || Index > myKnots.Length()) + { throw Standard_OutOfRange("BSpline curve: SetKnot: Index and #knots mismatch"); + } double DK = std::abs(Epsilon(K)); if (Index == 1) { if (K >= myKnots.Value(2) - DK) + { throw Standard_ConstructionError("BSpline curve: SetKnot: K out of range"); + } } else if (Index == myKnots.Length()) { @@ -858,12 +952,16 @@ void Geom2d_BSplineCurve::SetPeriodic() NCollection_Array1 cknots(1, last - first + 1); for (int k = first; k <= last; k++) + { cknots(k - first + 1) = myKnots(k); + } myKnots = std::move(cknots); NCollection_Array1 cmults(1, last - first + 1); for (int k = first; k <= last; k++) + { cmults(k - first + 1) = myMults(k); + } cmults(1) = cmults(cmults.Upper()) = std::min(myDeg, std::max(cmults(1), cmults(cmults.Upper()))); myMults = std::move(cmults); @@ -872,9 +970,13 @@ void Geom2d_BSplineCurve::SetPeriodic() myPoles.Resize(1, nbp, true); if (myRational) + { myWeights.Resize(1, nbp, true); + } else + { myWeights = BSplCLib::UnitWeights(nbp); + } myPeriodic = true; @@ -887,13 +989,17 @@ void Geom2d_BSplineCurve::SetPeriodic() void Geom2d_BSplineCurve::SetOrigin(const int Index) { if (!myPeriodic) + { throw Standard_NoSuchObject("Geom2d_BSplineCurve::SetOrigin"); + } int i, k; int first = FirstUKnotIndex(); int last = LastUKnotIndex(); if ((Index < first) || (Index > last)) + { throw Standard_DomainError("Geom2d_BSplineCurve::SetOrigin"); + } int nbknots = myKnots.Length(); int nbpoles = myPoles.Length(); @@ -920,7 +1026,9 @@ void Geom2d_BSplineCurve::SetOrigin(const int Index) int index = 1; for (i = first + 1; i <= Index; i++) + { index += myMults.Value(i); + } // set the poles and weights NCollection_Array1 npoles(1, nbpoles); @@ -963,9 +1071,13 @@ void Geom2d_BSplineCurve::SetOrigin(const int Index) myKnots = std::move(nknots); myMults = std::move(nmults); if (myRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(nbpoles); + } myMaxDerivInvOk = false; updateKnots(); } @@ -1002,9 +1114,13 @@ void Geom2d_BSplineCurve::SetNotPeriodic() myRational ? &nweights : BSplCLib::NoWeights()); myPoles = std::move(npoles); if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myMults = std::move(nmults); myKnots = std::move(nknots); myPeriodic = false; @@ -1018,7 +1134,9 @@ void Geom2d_BSplineCurve::SetNotPeriodic() void Geom2d_BSplineCurve::SetPole(const int Index, const gp_Pnt2d& P) { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: SetPole: index and #pole mismatch"); + } myPoles.SetValue(Index, P); myMaxDerivInvOk = false; } @@ -1036,10 +1154,14 @@ void Geom2d_BSplineCurve::SetPole(const int Index, const gp_Pnt2d& P, const doub void Geom2d_BSplineCurve::SetWeight(const int Index, const double W) { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: SetWeight: Index and #pole mismatch"); + } if (W <= gp::Resolution()) + { throw Standard_ConstructionError("BSpline curve: SetWeight: Weight too small"); + } bool rat = IsRational() || (std::abs(W - 1.) > gp::Resolution()); @@ -1057,7 +1179,9 @@ void Geom2d_BSplineCurve::SetWeight(const int Index, const double W) { rat = Rational(myWeights); if (!rat) + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } } myRational = rat; @@ -1173,7 +1297,9 @@ void Geom2d_BSplineCurve::updateKnots() } if (MaxKnotMult == 0) + { mySmooth = GeomAbs_CN; + } else { switch (myDeg - MaxKnotMult) diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve_1.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve_1.cxx index f02c282aaa..c1dc923520 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve_1.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve_1.cxx @@ -76,13 +76,19 @@ bool Geom2d_BSplineCurve::IsG1(const double theTf, const double theTl, const dou const double aTpar = Knot(aNKnot); if (aTpar < theTf) + { continue; + } if (aTpar > theTl) + { break; + } int mult = Multiplicity(aNKnot); if (mult < aDeg) + { continue; + } gp_Pnt2d aP1, aP2; gp_Vec2d aV1, aV2; @@ -95,11 +101,15 @@ bool Geom2d_BSplineCurve::IsG1(const double theTf, const double theTl, const dou } if (std::abs(aV1.Angle(aV2)) > theAngTol) + { return false; + } } if (!IsPeriodic()) + { return true; + } const double aFirstParam = FirstParameter(), aLastParam = LastParameter(); @@ -125,7 +135,9 @@ bool Geom2d_BSplineCurve::IsG1(const double theTf, const double theTl, const dou } if (std::abs(aV1.Angle(aV2)) > theAngTol) + { return false; + } return true; } @@ -174,7 +186,9 @@ gp_Pnt2d Geom2d_BSplineCurve::EvalD0(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots.Value(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D0(aNewU, aSpanIndex, myDeg, myPeriodic, myPoles, Weights(), myKnots, &myMults, P); return P; @@ -196,7 +210,9 @@ Geom2d_Curve::ResD1 Geom2d_BSplineCurve::EvalD1(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots.Value(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D1(aNewU, aSpanIndex, @@ -227,7 +243,9 @@ Geom2d_Curve::ResD2 Geom2d_BSplineCurve::EvalD2(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots.Value(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D2(aNewU, aSpanIndex, @@ -259,7 +277,9 @@ Geom2d_Curve::ResD3 Geom2d_BSplineCurve::EvalD3(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots.Value(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D3(aNewU, aSpanIndex, @@ -281,7 +301,9 @@ Geom2d_Curve::ResD3 Geom2d_BSplineCurve::EvalD3(const double U) const gp_Vec2d Geom2d_BSplineCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } gp_Vec2d aEvalRepResult; if (Geom2dEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) @@ -299,9 +321,13 @@ gp_Vec2d Geom2d_BSplineCurve::EvalDN(const double U, const int N) const gp_Pnt2d Geom2d_BSplineCurve::EndPoint() const { if (myMults.Value(myKnots.Upper()) == myDeg + 1) + { return myPoles.Value(myPoles.Upper()); + } else + { return Value(LastParameter()); + } } //================================================================================================= @@ -309,9 +335,13 @@ gp_Pnt2d Geom2d_BSplineCurve::EndPoint() const int Geom2d_BSplineCurve::FirstUKnotIndex() const { if (myPeriodic) + { return 1; + } else + { return BSplCLib::FirstUKnotIndex(myDeg, myMults); + } } //================================================================================================= @@ -343,7 +373,9 @@ void Geom2d_BSplineCurve::Knots(NCollection_Array1& K) const Standard_DomainError_Raise_if(K.Lower() < myKnots.Lower() || K.Upper() > myKnots.Upper(), "Geom2d_BSplineCurve::Knots"); for (int anIdx = K.Lower(); anIdx <= K.Upper(); anIdx++) + { K(anIdx) = myKnots.Value(anIdx); + } } const NCollection_Array1& Geom2d_BSplineCurve::Knots() const @@ -358,7 +390,9 @@ void Geom2d_BSplineCurve::KnotSequence(NCollection_Array1& K) const Standard_DomainError_Raise_if(K.Lower() < myFlatKnots.Lower() || K.Upper() > myFlatKnots.Upper(), "Geom2d_BSplineCurve::KnotSequence"); for (int anIdx = K.Lower(); anIdx <= K.Upper(); anIdx++) + { K(anIdx) = myFlatKnots.Value(anIdx); + } } const NCollection_Array1& Geom2d_BSplineCurve::KnotSequence() const @@ -371,9 +405,13 @@ const NCollection_Array1& Geom2d_BSplineCurve::KnotSequence() const int Geom2d_BSplineCurve::LastUKnotIndex() const { if (myPeriodic) + { return myKnots.Length(); + } else + { return BSplCLib::LastUKnotIndex(myDeg, myMults); + } } //================================================================================================= @@ -595,9 +633,13 @@ const NCollection_Array1& Geom2d_BSplineCurve::Poles() const gp_Pnt2d Geom2d_BSplineCurve::StartPoint() const { if (myMults.Value(1) == myDeg + 1) + { return myPoles.Value(1); + } else + { return Value(FirstParameter()); + } } //================================================================================================= @@ -607,9 +649,13 @@ double Geom2d_BSplineCurve::Weight(const int Index) const Standard_OutOfRange_Raise_if(Index < 1 || Index > myPoles.Length(), "Geom2d_BSplineCurve::Weight"); if (IsRational()) + { return myWeights.Value(Index); + } else + { return 1.; + } } //================================================================================================= @@ -618,19 +664,25 @@ void Geom2d_BSplineCurve::Weights(NCollection_Array1& W) const { Standard_DimensionError_Raise_if(W.Length() != myPoles.Length(), "Geom2d_BSplineCurve::Weights"); if (IsRational()) + { W = myWeights; + } else { int i; for (i = W.Lower(); i <= W.Upper(); i++) + { W(i) = 1.; + } } } const NCollection_Array1* Geom2d_BSplineCurve::Weights() const { if (IsRational()) + { return &myWeights; + } return BSplCLib::NoWeights(); } @@ -646,7 +698,9 @@ bool Geom2d_BSplineCurve::IsRational() const void Geom2d_BSplineCurve::Transform(const gp_Trsf2d& T) { for (int I = 1; I <= myPoles.Length(); I++) + { myPoles(I).Transform(T); + } myMaxDerivInvOk = false; } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx index 7250c20b82..6bef13fcb9 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx @@ -63,7 +63,9 @@ static bool Rational(const NCollection_Array1& W) { rat = std::abs(W(i) - W(i + 1)) > gp::Resolution(); if (rat) + { break; + } } return rat; } @@ -74,7 +76,9 @@ Geom2d_BezierCurve::Geom2d_BezierCurve(const NCollection_Array1& Poles { int nbpoles = Poles.Length(); if (nbpoles < 2 || nbpoles > (Geom2d_BezierCurve::MaxDegree() + 1)) + { throw Standard_ConstructionError(); + } // init non rational init(Poles, nullptr); @@ -87,10 +91,14 @@ Geom2d_BezierCurve::Geom2d_BezierCurve(const NCollection_Array1& Poles { int nbpoles = Poles.Length(); if (nbpoles < 2 || nbpoles > (Geom2d_BezierCurve::MaxDegree() + 1)) + { throw Standard_ConstructionError(); + } if (Weights.Length() != nbpoles) + { throw Standard_ConstructionError(); + } for (int i = 1; i <= nbpoles; i++) { @@ -129,7 +137,9 @@ Geom2d_BezierCurve::Geom2d_BezierCurve(const Geom2d_BezierCurve& theOther) void Geom2d_BezierCurve::Increase(const int Deg) { if (Deg == Degree()) + { return; + } Standard_ConstructionError_Raise_if(Deg < Degree() || Deg > Geom2d_BezierCurve::MaxDegree(), "Geom2d_BezierCurve::Increase"); @@ -198,12 +208,16 @@ void Geom2d_BezierCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, con NCollection_Array1 npoles(1, nbpoles + 1); for (i = 1; i <= Index; i++) + { npoles(i) = myPoles(i); + } npoles(Index + 1) = P; for (i = Index + 1; i <= nbpoles; i++) + { npoles(i + 1) = myPoles(i); + } // Insert the weight bool rat = IsRational() || std::abs(Weight - 1.) > gp::Resolution(); @@ -213,18 +227,30 @@ void Geom2d_BezierCurve::InsertPoleAfter(const int Index, const gp_Pnt2d& P, con NCollection_Array1 nweights(1, nbpoles + 1); for (i = 1; i <= Index; i++) + { if (IsRational()) + { nweights(i) = myWeights(i); + } else + { nweights(i) = 1.; + } + } nweights(Index + 1) = Weight; for (i = Index + 1; i <= nbpoles; i++) + { if (IsRational()) + { nweights(i + 1) = myWeights(i); + } else + { nweights(i + 1) = 1.; + } + } init(npoles, &nweights); } @@ -257,10 +283,14 @@ void Geom2d_BezierCurve::RemovePole(const int Index) NCollection_Array1 npoles(1, nbpoles - 1); for (i = 1; i < Index; i++) + { npoles(i) = myPoles(i); + } for (i = Index + 1; i <= nbpoles; i++) + { npoles(i - 1) = myPoles(i); + } // Remove the weight if (IsRational()) @@ -268,10 +298,14 @@ void Geom2d_BezierCurve::RemovePole(const int Index) NCollection_Array1 nweights(1, nbpoles - 1); for (i = 1; i < Index; i++) + { nweights(i) = myWeights(i); + } for (i = Index + 1; i <= nbpoles; i++) + { nweights(i - 1) = myWeights(i); + } init(npoles, &nweights); } @@ -394,7 +428,9 @@ void Geom2d_BezierCurve::SetWeight(const int Index, const double Weight) { // a weight of 1. does not turn to rational if (std::abs(Weight - 1.) <= gp::Resolution()) + { return; + } // Becoming rational: copy non-owning view to owned array. myWeights = NCollection_Array1(myWeights); @@ -409,7 +445,9 @@ void Geom2d_BezierCurve::SetWeight(const int Index, const double Weight) myWeights = BSplCLib::UnitWeights(nbpoles); } else + { myRational = true; + } myMaxDerivInvOk = false; } @@ -520,7 +558,9 @@ Geom2d_Curve::ResD3 Geom2d_BezierCurve::EvalD3(const double U) const gp_Vec2d Geom2d_BezierCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } gp_Vec2d aEvalRepResult; if (Geom2dEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) @@ -591,9 +631,13 @@ double Geom2d_BezierCurve::Weight(const int Index) const { Standard_OutOfRange_Raise_if(Index < 1 || Index > myPoles.Length(), "Geom2d_BezierCurve::Weight"); if (IsRational()) + { return myWeights(Index); + } else + { return 1.; + } } //================================================================================================= @@ -604,11 +648,15 @@ void Geom2d_BezierCurve::Weights(NCollection_Array1& W) const int nbpoles = NbPoles(); Standard_DimensionError_Raise_if(W.Length() != nbpoles, "Geom2d_BezierCurve::Weights"); if (IsRational()) + { W = myWeights; + } else { for (int i = 1; i <= nbpoles; i++) + { W(i) = 1.; + } } } @@ -619,7 +667,9 @@ void Geom2d_BezierCurve::Transform(const gp_Trsf2d& T) int nbpoles = NbPoles(); for (int i = 1; i <= nbpoles; i++) + { myPoles(i).Transform(T); + } ClearEvalRepresentation(); myMaxDerivInvOk = false; } @@ -720,13 +770,17 @@ const NCollection_Array1& Geom2d_BezierCurve::Multiplicities() const static const auto THE_DATA = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = {i + 1, i + 1}; + } return anArr; }(); static const auto THE_MULTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = NCollection_Array1(THE_DATA[i][0], 1, 2); + } return anArr; }(); return THE_MULTS[myPoles.Length() - 1]; @@ -741,7 +795,9 @@ const NCollection_Array1& Geom2d_BezierCurve::KnotSequence() const static const auto THE_FKNOTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 1; i <= BSplCLib::MaxDegree(); ++i) + { anArr[i] = NCollection_Array1(BSplCLib::FlatBezierKnots(i), 1, 2 * (i + 1)); + } return anArr; }(); return THE_FKNOTS[myPoles.Length() - 1]; diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_Circle.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_Circle.cxx index ade14a668b..655403f01d 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_Circle.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_Circle.cxx @@ -198,7 +198,9 @@ Geom2d_Curve::ResD3 Geom2d_Circle::EvalD3(const double U) const gp_Vec2d Geom2d_Circle::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } return ElCLib::CircleDN(U, pos, radius, N); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_Ellipse.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_Ellipse.cxx index 5a07b3869f..12a712817d 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_Ellipse.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_Ellipse.cxx @@ -103,9 +103,13 @@ void Geom2d_Ellipse::SetElips2d(const gp_Elips2d& E) void Geom2d_Ellipse::SetMajorRadius(const double MajorRadius) { if (MajorRadius < minorRadius) + { throw Standard_ConstructionError(); + } else + { majorRadius = MajorRadius; + } } //================================================================================================= @@ -210,9 +214,13 @@ double Geom2d_Ellipse::MinorRadius() const double Geom2d_Ellipse::Parameter() const { if (majorRadius == 0.0) + { return 0.0; + } else + { return (minorRadius * minorRadius) / majorRadius; + } } //================================================================================================= @@ -289,7 +297,9 @@ Geom2d_Curve::ResD3 Geom2d_Ellipse::EvalD3(const double U) const gp_Vec2d Geom2d_Ellipse::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } return ElCLib::EllipseDN(U, pos, majorRadius, minorRadius, N); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_Hyperbola.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_Hyperbola.cxx index eb229b1844..e6062da4cf 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_Hyperbola.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_Hyperbola.cxx @@ -68,7 +68,9 @@ Geom2d_Hyperbola::Geom2d_Hyperbola(const Ax2d& A, minorRadius(MinorRadius) { if (MajorRadius < 0.0 || MinorRadius < 0.0) + { throw Standard_ConstructionError(); + } pos = gp_Ax22d(A, Sense); } @@ -81,7 +83,9 @@ Geom2d_Hyperbola::Geom2d_Hyperbola(const gp_Ax22d& Axis, minorRadius(MinorRadius) { if (MajorRadius < 0.0 || MinorRadius < 0.0) + { throw Standard_ConstructionError(); + } pos = Axis; } @@ -99,9 +103,13 @@ void Geom2d_Hyperbola::SetHypr2d(const gp_Hypr2d& H) void Geom2d_Hyperbola::SetMajorRadius(const double MajorRadius) { if (MajorRadius < 0.0) + { throw Standard_ConstructionError(); + } else + { majorRadius = MajorRadius; + } } //================================================================================================= @@ -109,9 +117,13 @@ void Geom2d_Hyperbola::SetMajorRadius(const double MajorRadius) void Geom2d_Hyperbola::SetMinorRadius(const double MinorRadius) { if (MinorRadius < 0.0) + { throw Standard_ConstructionError(); + } else + { minorRadius = MinorRadius; + } } //================================================================================================= @@ -317,7 +329,9 @@ Geom2d_Curve::ResD3 Geom2d_Hyperbola::EvalD3(const double U) const gp_Vec2d Geom2d_Hyperbola::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } return ElCLib::HyperbolaDN(U, pos, majorRadius, minorRadius, N); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_Line.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_Line.cxx index 97279b9d38..2a929fda61 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_Line.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_Line.cxx @@ -221,11 +221,17 @@ Geom2d_Curve::ResD3 Geom2d_Line::EvalD3(const double U) const gp_Vec2d Geom2d_Line::EvalDN(const double, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } if (N == 1) + { return gp_Vec2d(pos.Direction()); + } else + { return gp_Vec2d(0.0, 0.0); + } } //================================================================================================= @@ -240,7 +246,9 @@ void Geom2d_Line::Transform(const Trsf2d& T) double Geom2d_Line::TransformedParameter(const double U, const gp_Trsf2d& T) const { if (Precision::IsInfinite(U)) + { return U; + } return U * std::abs(T.ScaleFactor()); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_OffsetCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_OffsetCurve.cxx index b71d8eea15..eab64d4cbe 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_OffsetCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_OffsetCurve.cxx @@ -222,7 +222,9 @@ gp_Pnt2d Geom2d_OffsetCurve::EvalD0(const double theU) const const Geom2d_Curve::ResD1 aBasisD1 = basisCurve->EvalD1(theU); gp_Pnt2d aValue = aBasisD1.Point; if (!Geom2d_OffsetCurveUtils::CalculateD0(aValue, aBasisD1.D1, offsetValue)) + { throw Geom2d_UndefinedValue("Geom2d_OffsetCurve::EvalD0"); + } return aValue; } @@ -240,7 +242,9 @@ Geom2d_Curve::ResD1 Geom2d_OffsetCurve::EvalD1(const double theU) const gp_Pnt2d aValue = aBasisD2.Point; gp_Vec2d aD1 = aBasisD2.D1; if (!Geom2d_OffsetCurveUtils::CalculateD1(aValue, aD1, aBasisD2.D2, offsetValue)) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalD1"); + } return Geom2d_Curve::ResD1{aValue, aD1}; } @@ -269,10 +273,14 @@ Geom2d_Curve::ResD2 Geom2d_OffsetCurve::EvalD2(const double theU) const aD3, aDummyD4, isDirectionChange)) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalD2"); + } } if (!Geom2d_OffsetCurveUtils::CalculateD2(aValue, aD1, aD2, aD3, isDirectionChange, offsetValue)) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalD2"); + } return Geom2d_Curve::ResD2{aValue, aD1, aD2}; } @@ -302,7 +310,9 @@ Geom2d_Curve::ResD3 Geom2d_OffsetCurve::EvalD3(const double theU) const aD3, aD4, isDirectionChange)) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalD3"); + } } if (!Geom2d_OffsetCurveUtils::CalculateD3(aValue, aD1, @@ -311,7 +321,9 @@ Geom2d_Curve::ResD3 Geom2d_OffsetCurve::EvalD3(const double theU) const aD4, isDirectionChange, offsetValue)) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalD3"); + } return Geom2d_Curve::ResD3{aValue, aD1, aD2, aD3}; } @@ -320,7 +332,9 @@ Geom2d_Curve::ResD3 Geom2d_OffsetCurve::EvalD3(const double theU) const gp_Vec2d Geom2d_OffsetCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative("Geom2d_OffsetCurve::EvalDN"); + } gp_Vec2d aEvalRepResult; if (Geom2dEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) { diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_Parabola.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_Parabola.cxx index 58c360fd85..96846f4252 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_Parabola.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_Parabola.cxx @@ -95,7 +95,9 @@ Geom2d_Parabola::Geom2d_Parabola(const Ax2d& D, const Pnt2d& F) void Geom2d_Parabola::SetFocal(const double Focal) { if (Focal < 0.0) + { throw Standard_ConstructionError(); + } focalLength = Focal; } @@ -228,7 +230,9 @@ Geom2d_Curve::ResD3 Geom2d_Parabola::EvalD3(const double U) const gp_Vec2d Geom2d_Parabola::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom2d_UndefinedDerivative(); + } return ElCLib::ParabolaDN(U, pos, focalLength, N); } @@ -245,7 +249,9 @@ void Geom2d_Parabola::Transform(const Trsf2d& T) double Geom2d_Parabola::TransformedParameter(const double U, const gp_Trsf2d& T) const { if (Precision::IsInfinite(U)) + { return U; + } return U * std::abs(T.ScaleFactor()); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_TrimmedCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_TrimmedCurve.cxx index 12ccdc6d19..0ae07de18b 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_TrimmedCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_TrimmedCurve.cxx @@ -59,13 +59,19 @@ Geom2d_TrimmedCurve::Geom2d_TrimmedCurve(const occ::handle& C, uTrim2(U2) { if (C.IsNull()) + { throw Standard_ConstructionError("Geom2d_TrimmedCurve:: C is null"); + } // kill trimmed basis curves occ::handle T = occ::down_cast(C); if (!T.IsNull()) + { basisCurve = occ::down_cast(T->BasisCurve()->Copy()); + } else + { basisCurve = occ::down_cast(C->Copy()); + } SetTrim(U1, U2, Sense, theAdjustPeriodic); } @@ -96,7 +102,9 @@ void Geom2d_TrimmedCurve::SetTrim(const double U1, { bool sameSense = true; if (U1 == U2) + { throw Standard_ConstructionError("Geom2d_TrimmedCurve::U1 == U2"); + } double Udeb = basisCurve->FirstParameter(); double Ufin = basisCurve->LastParameter(); @@ -110,11 +118,13 @@ void Geom2d_TrimmedCurve::SetTrim(const double U1, uTrim1 = U1; uTrim2 = U2; if (theAdjustPeriodic) + { ElCLib::AdjustPeriodic(Udeb, Ufin, std::min(std::abs(uTrim2 - uTrim1) / 2, Precision::PConfusion()), uTrim1, uTrim2); + } } else { @@ -138,7 +148,9 @@ void Geom2d_TrimmedCurve::SetTrim(const double U1, } if (!sameSense) + { Reverse(); + } } //================================================================================================= @@ -187,7 +199,9 @@ bool Geom2d_TrimmedCurve::IsClosed() const const double aLength = LastParameter() - FirstParameter(); if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return Value(FirstParameter()).SquareDistance(Value(LastParameter())) <= Precision::Computational(); @@ -203,7 +217,9 @@ bool Geom2d_TrimmedCurve::IsPeriodic() const const double aLength = LastParameter() - FirstParameter(); if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return false; } diff --git a/src/ModelingData/TKG2d/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx b/src/ModelingData/TKG2d/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx index 7752af51ae..81cbabc721 100644 --- a/src/ModelingData/TKG2d/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx +++ b/src/ModelingData/TKG2d/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx @@ -173,14 +173,20 @@ GeomAbs_Shape Geom2dAdaptor_Curve::LocalContinuity(const double U1, const double if (std::abs(newFirst - TK(Index1 + 1)) < Precision::PConfusion()) { if (Index1 < Nb) + { Index1++; + } } if (std::abs(newLast - TK(Index2)) < Precision::PConfusion()) + { Index2--; + } int MultMax; // beware of periodic curves. if (aBSpline->IsPeriodic() && Index1 == Nb) + { Index1 = 1; + } if ((Index2 - Index1 <= 0) && (!aBSpline->IsPeriodic())) { @@ -192,7 +198,9 @@ GeomAbs_Shape Geom2dAdaptor_Curve::LocalContinuity(const double U1, const double for (int i = Index1 + 1; i <= Index2; i++) { if (TM(i) > MultMax) + { MultMax = TM(i); + } } MultMax = aBSpline->Degree() - MultMax; } @@ -586,7 +594,9 @@ bool Geom2dAdaptor_Curve::IsClosed() const return (Pd.Distance(Pf) <= Precision::Confusion()); } else + { return false; + } } //================================================================================================= @@ -615,11 +625,13 @@ void Geom2dAdaptor_Curve::RebuildCache(const double theParameter) const int aDeg = aBezier->Degree(); NCollection_Array1 aFlatKnots(BSplCLib::FlatBezierKnots(aDeg), 1, 2 * (aDeg + 1)); if (aBezierData.Cache.IsNull()) + { aBezierData.Cache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots, aBezier->Poles(), aBezier->Weights()); + } aBezierData.Cache->BuildCache(theParameter, aFlatKnots, aBezier->Poles(), aBezier->Weights()); } else if (myTypeCurve == GeomAbs_BSplineCurve) @@ -628,11 +640,13 @@ void Geom2dAdaptor_Curve::RebuildCache(const double theParameter) const auto& aBSplineData = std::get(myCurveData); const auto& aBSpline = aBSplineData.Curve; if (aBSplineData.Cache.IsNull()) + { aBSplineData.Cache = new BSplCLib_Cache(aBSpline->Degree(), aBSpline->IsPeriodic(), aBSpline->KnotSequence(), aBSpline->Poles(), aBSpline->Weights()); + } aBSplineData.Cache->BuildCache(theParameter, aBSpline->KnotSequence(), aBSpline->Poles(), @@ -653,17 +667,25 @@ bool Geom2dAdaptor_Curve::IsBoundary(const double theU, int& theSpanStart, int& { aBSpline->LocateU(myFirst, PosTol, theSpanStart, theSpanFinish); if (theSpanStart < 1) + { theSpanStart = 1; + } if (theSpanStart >= theSpanFinish) + { theSpanFinish = theSpanStart + 1; + } } else if (theU == myLast) { aBSpline->LocateU(myLast, PosTol, theSpanStart, theSpanFinish); if (theSpanFinish > aBSpline->NbKnots()) + { theSpanFinish = aBSpline->NbKnots(); + } if (theSpanStart >= theSpanFinish) + { theSpanStart = theSpanFinish - 1; + } } return true; } @@ -721,7 +743,9 @@ gp_Pnt2d Geom2dAdaptor_Curve::EvalD0(const double theU) const } auto& aBezierData = std::get(myCurveData); if (aBezierData.Cache.IsNull()) + { RebuildCache(U); + } aBezierData.Cache->D0(U, P); return P; } @@ -740,7 +764,9 @@ gp_Pnt2d Geom2dAdaptor_Curve::EvalD0(const double theU) const else { if (aBSplineData.Cache.IsNull() || !aBSplineData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplineData.Cache->D0(U, P); } return P; @@ -811,7 +837,9 @@ Geom2d_Curve::ResD1 Geom2dAdaptor_Curve::EvalD1(const double theU) const } auto& aBezierData = std::get(myCurveData); if (aBezierData.Cache.IsNull()) + { RebuildCache(U); + } aBezierData.Cache->D1(U, aResult.Point, aResult.D1); return aResult; } @@ -830,7 +858,9 @@ Geom2d_Curve::ResD1 Geom2dAdaptor_Curve::EvalD1(const double theU) const else { if (aBSplineData.Cache.IsNull() || !aBSplineData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplineData.Cache->D1(U, aResult.Point, aResult.D1); } return aResult; @@ -904,7 +934,9 @@ Geom2d_Curve::ResD2 Geom2dAdaptor_Curve::EvalD2(const double theU) const } auto& aBezierData = std::get(myCurveData); if (aBezierData.Cache.IsNull()) + { RebuildCache(U); + } aBezierData.Cache->D2(U, aResult.Point, aResult.D1, aResult.D2); return aResult; } @@ -923,7 +955,9 @@ Geom2d_Curve::ResD2 Geom2dAdaptor_Curve::EvalD2(const double theU) const else { if (aBSplineData.Cache.IsNull() || !aBSplineData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplineData.Cache->D2(U, aResult.Point, aResult.D1, aResult.D2); } return aResult; @@ -1020,7 +1054,9 @@ Geom2d_Curve::ResD3 Geom2dAdaptor_Curve::EvalD3(const double theU) const } auto& aBezierData = std::get(myCurveData); if (aBezierData.Cache.IsNull()) + { RebuildCache(U); + } aBezierData.Cache->D3(U, aResult.Point, aResult.D1, aResult.D2, aResult.D3); return aResult; } @@ -1040,7 +1076,9 @@ Geom2d_Curve::ResD3 Geom2dAdaptor_Curve::EvalD3(const double theU) const else { if (aBSplineData.Cache.IsNull() || !aBSplineData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplineData.Cache->D3(U, aResult.Point, aResult.D1, aResult.D2, aResult.D3); } return aResult; @@ -1114,7 +1152,9 @@ gp_Vec2d Geom2dAdaptor_Curve::EvalDN(const double theU, const int theN) const return std::get(myCurveData).Curve->LocalDN(U, aStart, aFinish, N); } else + { return myCurve->EvalDN(U, N); + } } case GeomAbs_OffsetCurve: { @@ -1152,9 +1192,13 @@ double Geom2dAdaptor_Curve::Resolution(const double Ruv) const case GeomAbs_Circle: { double R = std::get(myCurveData).Radius(); if (R > Ruv / 2.) + { return 2 * std::asin(Ruv / (2 * R)); + } else + { return 2 * M_PI; + } } case GeomAbs_Ellipse: { return Ruv / std::get(myCurveData).MajorRadius(); @@ -1229,11 +1273,17 @@ gp_Parab2d Geom2dAdaptor_Curve::Parabola() const int Geom2dAdaptor_Curve::Degree() const { if (myTypeCurve == GeomAbs_BezierCurve) + { return occ::down_cast(myCurve)->Degree(); + } else if (myTypeCurve == GeomAbs_BSplineCurve) + { return std::get(myCurveData).Curve->Degree(); + } else + { throw Standard_NoSuchObject(); + } } //================================================================================================= @@ -1256,11 +1306,17 @@ bool Geom2dAdaptor_Curve::IsRational() const int Geom2dAdaptor_Curve::NbPoles() const { if (myTypeCurve == GeomAbs_BezierCurve) + { return occ::down_cast(myCurve)->NbPoles(); + } else if (myTypeCurve == GeomAbs_BSplineCurve) + { return std::get(myCurveData).Curve->NbPoles(); + } else + { throw Standard_NoSuchObject(); + } } //================================================================================================= @@ -1268,7 +1324,9 @@ int Geom2dAdaptor_Curve::NbPoles() const int Geom2dAdaptor_Curve::NbKnots() const { if (myTypeCurve != GeomAbs_BSplineCurve) + { throw Standard_NoSuchObject("Geom2dAdaptor_Curve::NbKnots"); + } return std::get(myCurveData).Curve->NbKnots(); } @@ -1296,7 +1354,9 @@ static int nbPoints(const occ::handle& theCurve) int nbs = 20; if (theCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) + { nbs = 2; + } else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) { nbs = 3 + occ::down_cast(theCurve)->NbPoles(); @@ -1306,7 +1366,9 @@ static int nbPoints(const occ::handle& theCurve) nbs = occ::down_cast(theCurve)->NbKnots(); nbs *= occ::down_cast(theCurve)->Degree(); if (nbs < 2.0) + { nbs = 2; + } } else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) { @@ -1320,7 +1382,9 @@ static int nbPoints(const occ::handle& theCurve) return std::max(nbs, nbPoints(aCurve)); } if (nbs > 300) + { nbs = 300; + } return nbs; } diff --git a/src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_BSplineCurve.cxx b/src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_BSplineCurve.cxx index 41706ed743..c853ca9caa 100644 --- a/src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_BSplineCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_BSplineCurve.cxx @@ -40,7 +40,9 @@ struct CurveData bool extractCurveData(const occ::handle& theGeom, CurveData& theData) { if (theGeom.IsNull()) + { return false; + } theData.FlatKnots = &theGeom->KnotSequence(); theData.Poles = &theGeom->Poles(); @@ -95,9 +97,13 @@ inline int countSpanSize(const NCollection_Array1& theParams, aSpan, aAdjusted); if (aSpan == theTargetSpan) + { ++aCount; + } else + { break; + } } return aCount; } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx index eea3e25f9a..a803ff363f 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx @@ -168,9 +168,13 @@ static void Hunt(const NCollection_Array1& Arr, const double Coord, int& } if (std::abs(Coord - Arr(i)) < Tol) + { Iloc = i; + } else if (std::abs(Coord - Arr(i)) > Tol) + { throw Standard_NotImplemented("Adaptor3d_CurveOnSurface:Hunt"); + } } //================================================================================================= @@ -224,9 +228,13 @@ static void FindBounds(const NCollection_Array1& Arr, if (N == Bound1) { if (std::abs(Der) > Tol) + { DerNull = false; + } if (std::abs(Der) <= Tol) + { DerNull = true; + } Bound1 = N; Bound2 = N + 1; return; @@ -234,9 +242,13 @@ static void FindBounds(const NCollection_Array1& Arr, if (N == Bound2) { if (std::abs(Der) > Tol) + { DerNull = false; + } if (std::abs(Der) <= Tol) + { DerNull = true; + } Bound1 = N - 1; Bound2 = N; return; @@ -296,7 +308,9 @@ static void Locate1Coord(const int Index, i = Lo; while ((std::abs(BSplC->Knot(i) - Comp1) > Tol) && (i != Up)) + { i++; + } cur = BSplC->Knot(i); if (std::abs(Comp1 - cur) <= Tol) @@ -370,7 +384,9 @@ static void Locate1Coord(const int Index, f = BSplC->Knot(i); l = BSplC->Knot(i + 1); if (f < Comp1 && l > Comp1) + { break; + } i++; } ReverseParam(f, l, f, l); @@ -580,7 +596,9 @@ static void Locate1Coord(const int Index, } } else + { ReverseParam(f, l, f, l); + } if (i != Up) { @@ -915,7 +933,9 @@ void Adaptor3d_CurveOnSurface::Load(const occ::handle& S) { mySurface = S; if (!myCurve.IsNull()) + { EvalKPart(); + } } //================================================================================================= @@ -973,10 +993,14 @@ GeomAbs_Shape Adaptor3d_CurveOnSurface::Continuity() const GeomAbs_Shape ContC = myCurve->Continuity(); GeomAbs_Shape ContSu = mySurface->UContinuity(); if (ContSu < ContC) + { ContC = ContSu; + } GeomAbs_Shape ContSv = mySurface->VContinuity(); if (ContSv < ContC) + { ContC = ContSv; + } return ContC; } @@ -988,15 +1012,18 @@ static void AddIntervals(const occ::handle>& thePa double theTol) { if (!theRoots.IsDone() || theRoots.IsAllNull()) + { return; + } int nsol = theRoots.NbSolutions(); for (int i = 1; i <= nsol; i++) { double param = theRoots.Value(i); - if (param - theParameters->Value(1) - < theTol) // skip param if equal to or less than theParameters(1) + if (param - theParameters->Value(1) < theTol) + { // skip param if equal to or less than theParameters(1) continue; + } for (int j = 2; j <= theParameters->Length(); ++j) { double aDelta = theParameters->Value(j) - param; @@ -1005,8 +1032,10 @@ static void AddIntervals(const occ::handle>& thePa theParameters->InsertBefore(j, param); break; } - else if (aDelta >= -theTol) // param == theParameters(j) within Tol + else if (aDelta >= -theTol) + { // param == theParameters(j) within Tol break; + } } } } @@ -1016,7 +1045,9 @@ static void AddIntervals(const occ::handle>& thePa int Adaptor3d_CurveOnSurface::NbIntervals(const GeomAbs_Shape S) const { if (S == myIntCont && !myIntervals.IsNull()) + { return myIntervals->Length() - 1; + } int nu, nv, nc; nu = mySurface->NbUIntervals(S); @@ -1074,7 +1105,9 @@ int Adaptor3d_CurveOnSurface::NbIntervals(const GeomAbs_Shape S) const // contains only one value, therefore it is necessary to add second // value into aIntervals which will be equal first value. if (aIntervals->Length() == 1) + { aIntervals->Append(aIntervals->Value(1)); + } const_cast(this)->myIntervals = aIntervals; const_cast(this)->myIntCont = S; @@ -1119,7 +1152,9 @@ bool Adaptor3d_CurveOnSurface::IsClosed() const bool Adaptor3d_CurveOnSurface::IsPeriodic() const { if (myType == GeomAbs_Circle || myType == GeomAbs_Ellipse) + { return true; + } return myCurve->IsPeriodic(); } @@ -1129,7 +1164,9 @@ bool Adaptor3d_CurveOnSurface::IsPeriodic() const double Adaptor3d_CurveOnSurface::Period() const { if (myType == GeomAbs_Circle || myType == GeomAbs_Ellipse) + { return (2. * M_PI); + } return myCurve->Period(); } @@ -1142,9 +1179,13 @@ gp_Pnt Adaptor3d_CurveOnSurface::EvalD0(const double theU) const gp_Pnt2d Puv; if (myType == GeomAbs_Line) + { P = ElCLib::Value(theU, myLin); + } else if (myType == GeomAbs_Circle) + { P = ElCLib::Value(theU, myCirc); + } else { myCurve->D0(theU, Puv); @@ -1181,9 +1222,13 @@ Geom_Curve::ResD1 Adaptor3d_CurveOnSurface::EvalD1(const double theU) const aRes.D1.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); } else if (myType == GeomAbs_Line) + { ElCLib::D1(theU, myLin, aRes.Point, aRes.D1); + } else if (myType == GeomAbs_Circle) + { ElCLib::D1(theU, myCirc, aRes.Point, aRes.D1); + } else { myCurve->D1(theU, Puv, Duv); @@ -1229,7 +1274,9 @@ Geom_Curve::ResD2 Adaptor3d_CurveOnSurface::EvalD2(const double theU) const aRes.D2.SetCoord(0., 0., 0.); } else if (myType == GeomAbs_Circle) + { ElCLib::D2(theU, myCirc, aRes.Point, aRes.D1, aRes.D2); + } else { myCurve->D2(theU, UV, DW, D2W); @@ -1280,7 +1327,9 @@ Geom_Curve::ResD3 Adaptor3d_CurveOnSurface::EvalD3(const double theU) const aRes.D3.SetCoord(0., 0., 0.); } else if (myType == GeomAbs_Circle) + { ElCLib::D3(theU, myCirc, aRes.Point, aRes.D1, aRes.D2, aRes.D3); + } else { myCurve->D3(theU, UV, DW, D2W, D3W); @@ -1395,7 +1444,9 @@ int Adaptor3d_CurveOnSurface::NbPoles() const int Adaptor3d_CurveOnSurface::NbKnots() const { if (mySurface->GetType() == GeomAbs_Plane) + { return myCurve->NbKnots(); + } else { throw Standard_NoSuchObject(); @@ -1508,7 +1559,9 @@ void Adaptor3d_CurveOnSurface::EvalKPart() { myType = CTy; if (myType == GeomAbs_Circle) + { myCirc = to3d(mySurface->Plane(), myCurve->Circle()); + } else if (myType == GeomAbs_Line) { gp_Pnt P; @@ -1639,7 +1692,9 @@ void Adaptor3d_CurveOnSurface::EvalKPart() Tr.Multiply(P.Y()); myLin.Translate(Tr); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { myLin.Reverse(); + } } else if (STy == GeomAbs_Cone) { @@ -1651,7 +1706,9 @@ void Adaptor3d_CurveOnSurface::EvalKPart() Tr.Multiply(P.Y()); myLin.Translate(Tr); if (D.IsOpposite(gp::DY2d(), Precision::Angular())) + { myLin.Reverse(); + } } else if (STy == GeomAbs_Torus) { @@ -1688,7 +1745,9 @@ void Adaptor3d_CurveOnSurface::EvalFirstLastSurf() myCurve->D1(FirstPar, UV, DUV); if (DUV.Magnitude() <= Tol) + { Ok = false; + } if (Ok) { @@ -1730,7 +1789,9 @@ void Adaptor3d_CurveOnSurface::EvalFirstLastSurf() DUV.Reverse(); // We want the other part if (DUV.Magnitude() <= Tol) + { Ok = false; + } if (Ok) { diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_HSurfaceTool.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_HSurfaceTool.cxx index 57cadf27e2..87d8f513fe 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_HSurfaceTool.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_HSurfaceTool.cxx @@ -81,9 +81,13 @@ int Adaptor3d_HSurfaceTool::NbSamplesU(const occ::handle& S, const double ul = LastUParameter(S); n *= (int)((u2 - u1) / (ul - uf)); if (n > nbs || n > 50) + { n = nbs; + } if (n < 5) + { n = 5; + } } return n; } @@ -100,9 +104,13 @@ int Adaptor3d_HSurfaceTool::NbSamplesV(const occ::handle& S, const double vl = LastVParameter(S); n *= (int)((v2 - v1) / (vl - vf)); if (n > nbs || n > 50) + { n = nbs; + } if (n < 5) + { n = 5; + } } return n; } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_InterFunc.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_InterFunc.cxx index a62976f118..f5721429ac 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_InterFunc.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_InterFunc.cxx @@ -29,7 +29,9 @@ Adaptor3d_InterFunc::Adaptor3d_InterFunc(const occ::handle& C myFix(Fix) { if (Fix != 1 && Fix != 2) + { throw Standard_ConstructionError(); + } } bool Adaptor3d_InterFunc::Value(const double X, double& F) @@ -37,9 +39,13 @@ bool Adaptor3d_InterFunc::Value(const double X, double& F) gp_Pnt2d C; myCurve2d->D0(X, C); if (myFix == 1) + { F = C.X() - myFixVal; + } else + { F = C.Y() - myFixVal; + } return true; } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx index f35cf46dce..317f83064f 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx @@ -228,7 +228,9 @@ GeomAbs_Shape Adaptor3d_IsoCurve::Continuity() const int Adaptor3d_IsoCurve::NbIntervals(const GeomAbs_Shape S) const { if (myIso == GeomAbs_NoneIso) + { throw Standard_NoSuchObject(); + } bool UIso = (myIso == GeomAbs_IsoU); int nbInter = UIso ? mySurface->NbVIntervals(S) : mySurface->NbUIntervals(S); @@ -236,19 +238,29 @@ int Adaptor3d_IsoCurve::NbIntervals(const GeomAbs_Shape S) const NCollection_Array1 T(1, nbInter + 1); if (UIso) + { mySurface->VIntervals(T, S); + } else + { mySurface->UIntervals(T, S); + } if (nbInter == 1) + { return nbInter; + } int first = 1; while (T(first) <= myFirst) + { first++; + } int last = nbInter + 1; while (T(last) >= myLast) + { last--; + } return (last - first + 2); } @@ -257,7 +269,9 @@ int Adaptor3d_IsoCurve::NbIntervals(const GeomAbs_Shape S) const void Adaptor3d_IsoCurve::Intervals(NCollection_Array1& TI, const GeomAbs_Shape S) const { if (myIso == GeomAbs_NoneIso) + { throw Standard_NoSuchObject(); + } bool UIso = (myIso == GeomAbs_IsoU); int nbInter = UIso ? mySurface->NbVIntervals(S) : mySurface->NbUIntervals(S); @@ -265,9 +279,13 @@ void Adaptor3d_IsoCurve::Intervals(NCollection_Array1& TI, const GeomAbs NCollection_Array1 T(1, nbInter + 1); if (UIso) + { mySurface->VIntervals(T, S); + } else + { mySurface->UIntervals(T, S); + } if (nbInter == 1) { @@ -278,10 +296,14 @@ void Adaptor3d_IsoCurve::Intervals(NCollection_Array1& TI, const GeomAbs int first = 1; while (T(first) <= myFirst) + { first++; + } int last = nbInter + 1; while (T(last) >= myLast) + { last--; + } int i = TI.Lower(), j; for (j = first - 1; j <= last + 1; j++) diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_TopolTool.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_TopolTool.cxx index 4bd49fcd13..e415d4e88c 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_TopolTool.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_TopolTool.cxx @@ -739,7 +739,9 @@ static void Analyse(const NCollection_Array2& array2, } } if (locnbch > nbch) + { nbch = locnbch; + } } } myNbSamplesU = nbch + 5; @@ -812,11 +814,15 @@ void Adaptor3d_TopolTool::ComputeSamplePoints() nbsv = myS->NbVKnots(); nbsv *= myS->VDegree(); if (nbsv < 4) + { nbsv = 4; + } nbsu = myS->NbUKnots(); nbsu *= myS->UDegree(); if (nbsu < 4) + { nbsu = 4; + } } break; case GeomAbs_Cylinder: @@ -841,9 +847,13 @@ void Adaptor3d_TopolTool::ComputeSamplePoints() //-- if (nbsu < 6) + { nbsu = 6; + } if (nbsv < 6) + { nbsv = 6; + } if (typS == GeomAbs_BSplineSurface) { @@ -951,13 +961,21 @@ void Adaptor3d_TopolTool::SamplePoint(const int i, gp_Pnt2d& P2d, gp_Pnt& P3d) bool Adaptor3d_TopolTool::DomainIsInfinite() { if (Precision::IsNegativeInfinite(Uinf)) + { return (true); + } if (Precision::IsPositiveInfinite(Usup)) + { return (true); + } if (Precision::IsNegativeInfinite(Vinf)) + { return (true); + } if (Precision::IsPositiveInfinite(Vsup)) + { return (true); + } return (false); } @@ -1109,8 +1127,6 @@ void Adaptor3d_TopolTool::SamplePnts(const double theDefl, const int theNUmin, c { myVPars->SetValue(i, t); } - - return; } //================================================================================================= @@ -1248,9 +1264,13 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, for (i = ui1 + 1; i <= ui2; ++i) { if (i == ui2) + { t2 = usup; + } else + { t2 = aBS->UKnot(i); + } dt = (t2 - t1) / nbi; j = 1; do @@ -1289,9 +1309,13 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, for (i = vi1 + 1; i <= vi2; ++i) { if (i == vi2) + { t2 = vsup; + } else + { t2 = aBS->VKnot(i); + } dt = (t2 - t1) / nbi; j = 1; do @@ -1340,7 +1364,9 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, // const gp_Lin& lin = MkLin.Value(); if (p1.SquareDistance(p2) <= tol) + { continue; + } gp_Lin lin(p1, gp_Dir(gp_Vec(p1, p2))); bool ok = true; @@ -1357,7 +1383,9 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, double d = lin.SquareDistance(pp); if (d <= aDefl2) + { continue; + } ok = false; break; @@ -1379,14 +1407,20 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, } if (k >= nbsu) + { bCont = false; + } } } myNbSamplesU = 0; for (i = 1; i <= nbsu; i++) + { if (anUFlg(i)) + { myNbSamplesU++; + } + } if (myNbSamplesU < myMinPnts) { @@ -1402,11 +1436,17 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, // insert in bigger segment i = 2; while (!anUFlg(i++)) + { ; + } if (i < nbsu / 2) + { j = std::min(i + (nbsu - i) / 2, nbsu - 1); + } else + { j = std::max(i / 2, 2); + } } anUFlg(j) = true; myNbSamplesU = myMinPnts; @@ -1437,7 +1477,9 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, gp_Pnt p2 = myS->Value(t1, t2); if (p1.SquareDistance(p2) <= tol) + { continue; + } // gce_MakeLin MkLin(p1, p2); // const gp_Lin& lin = MkLin.Value(); gp_Lin lin(p1, gp_Dir(gp_Vec(p1, p2))); @@ -1455,7 +1497,9 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, double d = lin.SquareDistance(pp); if (d <= aDefl2) + { continue; + } ok = false; break; @@ -1477,14 +1521,20 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, } if (k >= nbsv) + { bCont = false; + } } } myNbSamplesV = 0; for (i = 1; i <= nbsv; i++) + { if (aVFlg(i)) + { myNbSamplesV++; + } + } if (myNbSamplesV < myMinPnts) { @@ -1501,11 +1551,17 @@ void Adaptor3d_TopolTool::BSplSamplePnts(const double theDefl, // insert in bigger segment i = 2; while (!aVFlg(i++)) + { ; + } if (i < nbsv / 2) + { j = std::min(i + (nbsv - i) / 2, nbsv - 1); + } else + { j = std::max(i / 2, 2); + } } myNbSamplesV = myMinPnts; aVFlg(j) = true; @@ -1627,9 +1683,13 @@ void Adaptor3d_TopolTool::GetConeApexParam(const gp_Cone& theC, double& theU, do } if (theU < -1.e-16) + { theU += (M_PI + M_PI); + } else if (theU < 0) + { theU = 0; + } theV = sin(SAngle) * (Ploc.X() * cos(theU) + Ploc.Y() * sin(theU) - Radius) + cos(SAngle) * Ploc.Z(); diff --git a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx index 9060359c92..2c21a28920 100644 --- a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx +++ b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_ApproxAFunction.cxx @@ -156,7 +156,9 @@ static void PrepareConvert(const int NumCurves, // Init Continuity.Init(0); if (ContinuityOrder == 0) + { return; + } for (icurve = 1; icurve < NumCurves; icurve++) { @@ -194,17 +196,21 @@ static void PrepareConvert(const int NumCurves, double f2_divizor = TrueIntervals(icurve + 2) - TrueIntervals(icurve + 1); double fract1, fract2; - if (std::abs(f1_divizor) < Toler) // this is to avoid divizion by zero + if (std::abs(f1_divizor) < Toler) + { // this is to avoid divizion by zero // in this case fract1 = 5.14755758946803e-85 facteur1 = 0.0; + } else { fract1 = f1_dividend / f1_divizor; facteur1 = std::pow(fract1, iordre); } if (std::abs(f2_divizor) < Toler) + { // in this case fract2 = 6.77193633669143e-313 facteur2 = 0.0; + } else { fract2 = f2_dividend / f2_divizor; @@ -229,7 +235,9 @@ static void PrepareConvert(const int NumCurves, Suivant(idim) = diff * normal2; // And a second check on the upper bound of the generated error if (Prec(idim) > eps || Suivant(idim) > eps) + { isCi = false; + } } else { @@ -254,7 +262,9 @@ static void PrepareConvert(const int NumCurves, Prec(idim) = diff * normal1; Suivant(idim) = diff * normal2; if (Prec(idim) > eps || Suivant(idim) > eps) + { isCi = false; + } } else { @@ -277,7 +287,9 @@ static void PrepareConvert(const int NumCurves, Prec(idim) = diff * normal1; Suivant(idim) = diff * normal2; if (Prec(idim) > eps || Suivant(idim) > eps) + { isCi = false; + } } else { @@ -543,7 +555,9 @@ void AdvApprox_ApproxAFunction::Approximation( // IDIM += NDSES; // HP port: the compiler refuses branching if (goto_fin_de_boucle) + { continue; + } for (IS = 1; IS <= TotalNumSS; IS++) { ErrorMaxArray.SetValue(IS + (NumCurves - 1) * TotalNumSS, Approx.MaxError(IS)); @@ -554,9 +568,11 @@ void AdvApprox_ApproxAFunction::Approximation( occ::handle> HJacCoeff = Approx.Coefficients(); TheDeg = Approx.Degree(); if (isCut && (TheDeg < 2 * ContinuityOrder + 1)) + { // To avoid noisy derivatives at the ends, and maintain correct // continuity on the resulting BSpline. TheDeg = 2 * ContinuityOrder + 1; + } NumCoeffPerCurveArray(NumCurves) = TheDeg + 1; NCollection_Array1 Coefficients(0, (TheDeg + 1) * TotalDimension - 1); @@ -580,7 +596,6 @@ void AdvApprox_ApproxAFunction::Approximation( // fin_de_boucle: // {;} end of the while loop } - return; } //================================================================================================= @@ -652,7 +667,9 @@ void AdvApprox_ApproxAFunction::Perform(const int Num1DSS, { if (Num1DSS < 0 || Num2DSS < 0 || Num3DSS < 0 || Num1DSS + Num2DSS + Num3DSS <= 0 || myLast < myFirst || myMaxDegree < 1 || myMaxSegments < 0) + { throw Standard_ConstructionError(); + } if (myMaxDegree > 14) { myMaxDegree = 14; @@ -954,7 +971,9 @@ void AdvApprox_ApproxAFunction::Poles(const int Index, NCollection_Array1Array1()); + } return 0; } @@ -1053,31 +1072,31 @@ double AdvApprox_ApproxAFunction::AverageError(const int D, const int Index) con void AdvApprox_ApproxAFunction::Dump(Standard_OStream& o) const { int ii; - o << "Dump of ApproxAFunction" << std::endl; + o << "Dump of ApproxAFunction" << '\n'; if (myNumSubSpaces[0] > 0) { - o << "Error(s) 1d = " << std::endl; + o << "Error(s) 1d = " << '\n'; for (ii = 1; ii <= myNumSubSpaces[0]; ii++) { - o << " " << MaxError(1, ii) << std::endl; + o << " " << MaxError(1, ii) << '\n'; } } if (myNumSubSpaces[1] > 0) { - o << "Error(s) 2d = " << std::endl; + o << "Error(s) 2d = " << '\n'; for (ii = 1; ii <= myNumSubSpaces[1]; ii++) { - o << " " << MaxError(2, ii) << std::endl; + o << " " << MaxError(2, ii) << '\n'; } } if (myNumSubSpaces[2] > 0) { - o << "Error(s) 3d = " << std::endl; + o << "Error(s) 3d = " << '\n'; for (ii = 1; ii <= myNumSubSpaces[2]; ii++) { - o << " " << MaxError(3, ii) << std::endl; + o << " " << MaxError(3, ii) << '\n'; } } } diff --git a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx index 6a4d5305f7..dcdaab7efb 100644 --- a/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx +++ b/src/ModelingData/TKG3d/AdvApprox/AdvApprox_SimpleApprox.cxx @@ -115,11 +115,17 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime { Evaluator(&Dimension, FirstLast, ¶m, &derive, pResult, &ErrorCode); if (ErrorCode != 0) + { return; // Evaluation error + } if (derive >= 1) + { Result *= Fact; + } if (derive == 2) + { Result *= Fact; + } for (idim = 1; idim <= myTotalDimension; idim++) { myFirstConstr->SetValue(idim, derive, Result(idim)); @@ -130,11 +136,17 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime { Evaluator(&Dimension, FirstLast, ¶m, &derive, pResult, &ErrorCode); if (ErrorCode != 0) + { return; // Evaluation error + } if (derive >= 1) + { Result *= Fact; + } if (derive == 2) + { Result *= Fact; + } for (idim = 1; idim <= myTotalDimension; idim++) { myLastConstr->SetValue(idim, derive, Result(idim)); @@ -168,7 +180,9 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime tip = alin * ti + blin; Evaluator(&Dimension, FirstLast, &tip, &derive, pFti, &ErrorCode); if (ErrorCode != 0) + { return; // Evaluation error + } for (idim = 1; idim <= myTotalDimension; idim++) { mySomTab->SetValue(i_idim, Fti(idim)); @@ -183,7 +197,9 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime tin = -alin * ti + blin; Evaluator(&Dimension, FirstLast, &tin, &derive, pFti, &ErrorCode); if (ErrorCode != 0) + { return; // Evaluation error + } PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension, Coef1[0], Rpti(1)); ti = -ti; PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension, Coef1[0], Rmti(1)); @@ -203,7 +219,9 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime tip = blin; Evaluator(&Dimension, FirstLast, &tip, &derive, pFti, &ErrorCode); if (ErrorCode != 0) + { return; // Evaluation error + } PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension, Coef1[0], Rpti(1)); for (idim = 1; idim <= myTotalDimension; idim++) { @@ -279,7 +297,9 @@ void AdvApprox_SimpleApprox::Perform(const NCollection_Array1& LocalDime double* JacSS = (double*)&JacCoeff.Value(RangJacCoeff); myJacPol.ReduceDegree(Dim, MaxDegree, LocalTolerancesArray(numss), JacSS[0], NewDegree, MaxErr); if (NewDegree > NewDegreeMax) + { NewDegreeMax = NewDegree; + } RangSS = RangSS + Dim; RangJacCoeff = RangJacCoeff + (myWorkDegree + 1) * Dim; } @@ -371,9 +391,9 @@ double AdvApprox_SimpleApprox::AverageError(const int Index) const void AdvApprox_SimpleApprox::Dump(Standard_OStream& o) const { int ii; - o << "Dump of SimpleApprox " << std::endl; + o << "Dump of SimpleApprox " << '\n'; for (ii = 1; ii <= myTotalNumSS; ii++) { - o << "Error " << MaxError(ii) << std::endl; + o << "Error " << MaxError(ii) << '\n'; } } diff --git a/src/ModelingData/TKG3d/GTests/GeomEval_TBezierSurface_Test.cxx b/src/ModelingData/TKG3d/GTests/GeomEval_TBezierSurface_Test.cxx index 42b4321ecb..03042ad8c3 100644 --- a/src/ModelingData/TKG3d/GTests/GeomEval_TBezierSurface_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/GeomEval_TBezierSurface_Test.cxx @@ -42,8 +42,12 @@ GeomEval_TBezierSurface createSpherePatch() NCollection_Array2 aPoles(1, 3, 1, 3); // All poles default to origin (0,0,0) for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(0.0, 0.0, 0.0)); + } + } // P(1,2) = (0,0,1) corresponds to 1*sin(v) -> Z component aPoles.SetValue(1, 2, gp_Pnt(0.0, 0.0, 1.0)); // P(2,3) = (0,1,0) corresponds to sin(u)*cos(v) -> Y component @@ -88,8 +92,12 @@ TEST(GeomEval_TBezierSurfaceTest, Construction_InvalidParams_Throws) // Even number of poles in U (not odd) NCollection_Array2 aPoles(1, 2, 1, 3); for (int i = 1; i <= 2; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(double(i), double(j), 0.0)); + } + } EXPECT_THROW(GeomEval_TBezierSurface(aPoles, 1.0, 1.0), Standard_ConstructionError); } diff --git a/src/ModelingData/TKG3d/GTests/GeomGridEval_BezierSurface_Test.cxx b/src/ModelingData/TKG3d/GTests/GeomGridEval_BezierSurface_Test.cxx index 9c135a1729..b854117770 100644 --- a/src/ModelingData/TKG3d/GTests/GeomGridEval_BezierSurface_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/GeomGridEval_BezierSurface_Test.cxx @@ -134,8 +134,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeD2) { NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -165,8 +169,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeD3) { NCollection_Array2 aPoles(1, 4, 1, 4); for (int i = 1; i <= 4; ++i) + { for (int j = 1; j <= 4; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i - 1, j - 1, std::sin((i - 1) * 0.5 + (j - 1) * 0.5))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -206,8 +214,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_U1V0) { NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -230,8 +242,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_U0V1) { NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -254,8 +270,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_U2V0) { NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -278,8 +298,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_U1V1) { NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -303,8 +327,12 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_BeyondDegree) // Biquadratic Bezier (degree 2 in both directions) NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles.SetValue(i, j, gp_Pnt(i, j, std::sin(i + j))); + } + } occ::handle aBezier = new Geom_BezierSurface(aPoles); GeomGridEval_BezierSurface anEval(aBezier); @@ -350,7 +378,9 @@ TEST(GeomGridEval_BezierSurfaceTest, DerivativeDN_RationalSurface) for (int aNV = 0; aNV <= 1; ++aNV) { if (aNU + aNV == 0) + { continue; + } NCollection_Array2 aGrid = anEval.EvaluateGridDN(aParams, aParams, aNU, aNV); diff --git a/src/ModelingData/TKG3d/GTests/Geom_BSplineCurve_Test.cxx b/src/ModelingData/TKG3d/GTests/Geom_BSplineCurve_Test.cxx index d66ecaa077..7211e2da7c 100644 --- a/src/ModelingData/TKG3d/GTests/Geom_BSplineCurve_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/Geom_BSplineCurve_Test.cxx @@ -334,7 +334,9 @@ TEST_F(Geom_BSplineCurve_Test, PeriodicCurve) NCollection_Array1 aKnots(1, 6); for (int i = 1; i <= 6; ++i) + { aKnots(i) = (i - 1) * 0.2; + } NCollection_Array1 aMults(1, 6); aMults.Init(1); @@ -612,7 +614,9 @@ TEST_F(Geom_BSplineCurve_Test, PeriodicCurve_SetOrigin) NCollection_Array1 aKnots(1, 6); for (int i = 1; i <= 6; ++i) + { aKnots(i) = (i - 1) * 0.2; + } NCollection_Array1 aMults(1, 6); aMults.Init(1); diff --git a/src/ModelingData/TKG3d/GTests/Geom_BSplineSurface_Test.cxx b/src/ModelingData/TKG3d/GTests/Geom_BSplineSurface_Test.cxx index b48cc61152..48664ac0e9 100644 --- a/src/ModelingData/TKG3d/GTests/Geom_BSplineSurface_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/Geom_BSplineSurface_Test.cxx @@ -418,9 +418,13 @@ TEST_F(Geom_BSplineSurface_Test, PeriodicSurface_SetUNotPeriodic) // U-periodic surface: degree 2, 4 U-knots of mult 1 -> NbUPoles = 1+2 = 3 NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles(i, j) = gp_Pnt(std::cos(2.0 * M_PI * (i - 1) / 3.0), std::sin(2.0 * M_PI * (i - 1) / 3.0), j * 0.5); + } + } NCollection_Array1 anUKnots(1, 4); anUKnots(1) = 0.0; @@ -455,9 +459,13 @@ TEST_F(Geom_BSplineSurface_Test, PeriodicSurface_SetVNotPeriodic) // V-periodic surface: degree 2, 4 V-knots of mult 1 -> NbVPoles = 1+2 = 3 NCollection_Array2 aPoles(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) + { aPoles(i, j) = gp_Pnt(i * 0.5, std::cos(2.0 * M_PI * (j - 1) / 3.0), std::sin(2.0 * M_PI * (j - 1) / 3.0)); + } + } NCollection_Array1 anUKnots(1, 2); anUKnots(1) = 0.0; @@ -574,11 +582,13 @@ TEST_F(Geom_BSplineSurface_Test, SetWeightRow) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(i, j, (i == 2 && j == 2) ? 1.0 : 0.0); aWeights(i, j) = 1.0; } + } aWeights(2, 2) = 2.0; NCollection_Array1 anUKnots(1, 2), aVKnots(1, 2); @@ -612,11 +622,13 @@ TEST_F(Geom_BSplineSurface_Test, SetWeightCol) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(i, j, (i == 2 && j == 2) ? 1.0 : 0.0); aWeights(i, j) = 1.0; } + } aWeights(2, 2) = 2.0; NCollection_Array1 anUKnots(1, 2), aVKnots(1, 2); @@ -701,12 +713,14 @@ TEST_F(Geom_BSplineSurface_Test, RationalSurface_SetUNotPeriodic) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(std::cos(2.0 * M_PI * (i - 1) / 3.0), std::sin(2.0 * M_PI * (i - 1) / 3.0), j * 0.5); aWeights(i, j) = 1.0 + 0.5 * (i - 1); } + } NCollection_Array1 anUKnots(1, 4); anUKnots(1) = 0.0; @@ -751,12 +765,14 @@ TEST_F(Geom_BSplineSurface_Test, RationalSurface_SetVNotPeriodic) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(i * 0.5, std::cos(2.0 * M_PI * (j - 1) / 3.0), std::sin(2.0 * M_PI * (j - 1) / 3.0)); aWeights(i, j) = 1.0 + 0.5 * (j - 1); } + } NCollection_Array1 anUKnots(1, 2); anUKnots(1) = 0.0; @@ -837,11 +853,13 @@ TEST_F(Geom_BSplineSurface_Test, RationalSurface_UIso) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(i, j, (i + j) * 0.1); aWeights(i, j) = 1.0 + 0.5 * ((i - 1) + (j - 1)); } + } NCollection_Array1 anUKnots(1, 2), aVKnots(1, 2); anUKnots(1) = 0.0; @@ -945,11 +963,15 @@ TEST_F(Geom_BSplineSurface_Test, OCC30990_CacheConsistencyAtKnots) const int aNbV = 5; NCollection_Array2 aPoles(1, aNbU, 1, aNbV); for (int i = 1; i <= aNbU; ++i) + { for (int j = 1; j <= aNbV; ++j) + { aPoles(i, j) = gp_Pnt(static_cast(i - 1), static_cast(j - 1), std::sin(static_cast(i) * 0.5) * std::cos(static_cast(j) * 0.7)); + } + } // Knot vector in U: [0, 0.25, 0.5, 0.75, 1] with multiplicities [4, 1, 1, 1, 4] NCollection_Array1 aUKnots(1, 5); @@ -999,7 +1021,9 @@ TEST_F(Geom_BSplineSurface_Test, OCC30990_CacheConsistencyAtKnots) const gp_Pnt aP2 = aAdaptor.Value(aUknot, aV); if (aP1.X() != aP2.X() || aP1.Y() != aP2.Y() || aP1.Z() != aP2.Z()) + { ++aNbErr; + } } } @@ -1019,7 +1043,9 @@ TEST_F(Geom_BSplineSurface_Test, OCC30990_CacheConsistencyAtKnots) const gp_Pnt aP2 = aAdaptor.Value(aU, aVknot); if (aP1.X() != aP2.X() || aP1.Y() != aP2.Y() || aP1.Z() != aP2.Z()) + { ++aNbErr; + } } } diff --git a/src/ModelingData/TKG3d/GTests/Geom_BezierCurve_Test.cxx b/src/ModelingData/TKG3d/GTests/Geom_BezierCurve_Test.cxx index ccbc704749..27d44a2542 100644 --- a/src/ModelingData/TKG3d/GTests/Geom_BezierCurve_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/Geom_BezierCurve_Test.cxx @@ -533,7 +533,9 @@ TEST(Geom_BezierCurveTest, OCC2569_DegreeEqualsNbPolesMinusOne) const int aNbPoles = 26; NCollection_Array1 aPoles(1, aNbPoles); for (int i = 1; i <= aNbPoles; ++i) + { aPoles.SetValue(i, gp_Pnt(i + 10, i * 2 + 20, i * 3 + 45)); + } Handle(Geom_BezierCurve) aCurve = new Geom_BezierCurve(aPoles); ASSERT_FALSE(aCurve.IsNull()); @@ -547,7 +549,9 @@ TEST(Geom_BezierCurveTest, OCC2569_ThrowsForTooManyPoles) const int aNbPoles = 29; NCollection_Array1 aPoles(1, aNbPoles); for (int i = 1; i <= aNbPoles; ++i) + { aPoles.SetValue(i, gp_Pnt(i + 10, i * 2 + 20, i * 3 + 45)); + } EXPECT_THROW(new Geom_BezierCurve(aPoles), Standard_Failure); } diff --git a/src/ModelingData/TKG3d/GTests/Geom_BezierSurface_Test.cxx b/src/ModelingData/TKG3d/GTests/Geom_BezierSurface_Test.cxx index cc86e20a87..b507ac63ee 100644 --- a/src/ModelingData/TKG3d/GTests/Geom_BezierSurface_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/Geom_BezierSurface_Test.cxx @@ -493,11 +493,13 @@ TEST_F(Geom_BezierSurface_Test, RationalSegment) NCollection_Array2 aPoles(1, 3, 1, 3); NCollection_Array2 aWeights(1, 3, 1, 3); for (int i = 1; i <= 3; ++i) + { for (int j = 1; j <= 3; ++j) { aPoles(i, j) = gp_Pnt(i, j, (i + j) * 0.1); aWeights(i, j) = 1.0 + 0.3 * ((i - 1) + (j - 1)); } + } occ::handle aSurf = new Geom_BezierSurface(aPoles, aWeights); EXPECT_TRUE(aSurf->IsURational() || aSurf->IsVRational()); diff --git a/src/ModelingData/TKG3d/GTests/Geom_OffsetSurface_Test.cxx b/src/ModelingData/TKG3d/GTests/Geom_OffsetSurface_Test.cxx index b03c0ac41d..17cbc71fd0 100644 --- a/src/ModelingData/TKG3d/GTests/Geom_OffsetSurface_Test.cxx +++ b/src/ModelingData/TKG3d/GTests/Geom_OffsetSurface_Test.cxx @@ -776,7 +776,9 @@ TEST(Geom_OffsetSurface_Derivatives, Cylinder_DN_Consistency) for (int Nv = 0; Nv <= 3; ++Nv) { if (Nu + Nv == 0 || Nu + Nv > 3) + { continue; + } gp_Vec aDN1 = anOffsetAdaptor.DN(u, v, Nu, Nv); gp_Vec aDN2 = anEquivAdaptor.DN(u, v, Nu, Nv); EXPECT_TRUE(VectorsEqual(aDN1, aDN2, aTol)) diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx index c93dab6b6e..a1fb0c8810 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx @@ -72,9 +72,13 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() < 2) + { throw Standard_ConstructionError("BSpline curve: at least 2 poles required"); + } if (CKnots.Length() != CMults.Length()) + { throw Standard_ConstructionError("BSpline curve: Knot and Mult array size mismatch"); + } for (int I = CKnots.Lower(); I < CKnots.Upper(); I++) { @@ -85,7 +89,9 @@ static void CheckCurveData(const NCollection_Array1& CPoles, } if (CPoles.Length() != BSplCLib::NbPoles(Degree, Periodic, CMults)) + { throw Standard_ConstructionError("BSpline curve: # Poles and degree mismatch"); + } } //! Check rationality of an array of weights @@ -183,18 +189,24 @@ Geom_BSplineCurve::Geom_BSplineCurve(const NCollection_Array1& Poles, CheckCurveData(Poles, Knots, Mults, Degree, Periodic); if (Weights.Length() != Poles.Length()) + { throw Standard_ConstructionError("Geom_BSplineCurve: Weights and Poles array size mismatch"); + } int i; for (i = Weights.Lower(); i <= Weights.Upper(); i++) { if (Weights(i) <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BSplineCurve: Weights values too small"); + } } // check really rational if (CheckRational) + { myRational = Rational(Weights); + } // copy arrays @@ -231,7 +243,9 @@ int Geom_BSplineCurve::MaxDegree() void Geom_BSplineCurve::IncreaseDegree(const int Degree) { if (Degree == myDeg) + { return; + } ClearEvalRepresentation(); @@ -271,9 +285,13 @@ void Geom_BSplineCurve::IncreaseDegree(const int Degree) myDeg = Degree; myPoles = std::move(npoles); if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myKnots = std::move(nknots); myMults = std::move(nmults); updateKnots(); @@ -298,7 +316,9 @@ void Geom_BSplineCurve::IncreaseMultiplicity(const int I1, const int I2, const i NCollection_Array1 m(I1, I2); int i; for (i = I1; i <= I2; i++) + { m(i) = M - myMults.Value(i); + } InsertKnots(k, m, Epsilon(1.), true); } @@ -346,10 +366,14 @@ void Geom_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, nbknots, Epsilon, Add)) + { throw Standard_ConstructionError("Geom_BSplineCurve::InsertKnots"); + } if (nbpoles == myPoles.Length()) + { return; + } ClearEvalRepresentation(); @@ -378,9 +402,13 @@ void Geom_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, Epsilon, Add); if (myRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(npoles.Length()); + } myPoles = std::move(npoles); myKnots = std::move(nknots); myMults = std::move(nmults); @@ -392,7 +420,9 @@ void Geom_BSplineCurve::InsertKnots(const NCollection_Array1& Knots, bool Geom_BSplineCurve::RemoveKnot(const int Index, const int M, const double Tolerance) { if (M < 0) + { return true; + } int I1 = FirstUKnotIndex(); int I2 = LastUKnotIndex(); @@ -410,7 +440,9 @@ bool Geom_BSplineCurve::RemoveKnot(const int Index, const int M, const double To int step = myMults.Value(Index) - M; if (step <= 0) + { return true; + } NCollection_Array1 npoles(1, oldpoles.Length() - step); @@ -443,9 +475,13 @@ bool Geom_BSplineCurve::RemoveKnot(const int Index, const int M, const double To ClearEvalRepresentation(); if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(npoles.Length()); + } myPoles = std::move(npoles); myKnots = std::move(nknots); myMults = std::move(nmults); @@ -464,12 +500,18 @@ void Geom_BSplineCurve::Reverse() BSplCLib::Reverse(myMults); int last; if (myPeriodic) + { last = myFlatKnots.Upper() - myDeg - 1; + } else + { last = myPoles.Upper(); + } BSplCLib::Reverse(myPoles, last); if (myRational) + { BSplCLib::Reverse(myWeights, last); + } updateKnots(); } @@ -485,7 +527,9 @@ double Geom_BSplineCurve::ReversedParameter(const double U) const void Geom_BSplineCurve::Segment(const double U1, const double U2, const double theTolerance) { if (U2 < U1) + { throw Standard_DomainError("Geom_BSplineCurve::Segment"); + } ClearEvalRepresentation(); @@ -503,9 +547,13 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t double Period = LastParameter() - FirstParameter(); DU = U2 - U1; if (DU - Period > Precision::PConfusion()) + { throw Standard_DomainError("Geom_BSplineCurve::Segment"); + } if (DU > Period) + { DU = Period; + } aDDU = DU; } @@ -561,8 +609,10 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t index, U); // Test if the insertion is OK, shift otherwise. - if (std::abs(myKnots.Value(index + 1) - U) <= Eps) // <= to be consistent with InsertKnots + if (std::abs(myKnots.Value(index + 1) - U) <= Eps) + { // <= to be consistent with InsertKnots index++; + } SetOrigin(index); SetNotPeriodic(); NewU2 = NewU1 + DU; @@ -574,11 +624,15 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t int ToU2 = myKnots.Upper(); BSplCLib::LocateParameter(myDeg, myKnots, myMults, NewU1, myPeriodic, FromU1, ToU2, index1, U); if (std::abs(myKnots.Value(index1 + 1) - U) <= Eps) + { index1++; + } BSplCLib::LocateParameter(myDeg, myKnots, myMults, NewU2, myPeriodic, FromU1, ToU2, index2, U); if (std::abs(myKnots.Value(index2 + 1) - U) <= Eps || index2 == index1) + { index2++; + } int nbknots = index2 - index1 + 1; @@ -586,8 +640,10 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t NCollection_Array1 nmults(1, nbknots); // to restore changed U1 - if (DU > 0) // if was periodic + if (DU > 0) + { // if was periodic DU = NewU1 - U1; + } int i, k = 1; for (i = index1; i <= index2; i++) @@ -646,9 +702,13 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t myMults = std::move(nmults); myPoles = std::move(npoles); if (myRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myMaxDerivInvOk = false; updateKnots(); @@ -659,12 +719,16 @@ void Geom_BSplineCurve::Segment(const double U1, const double U2, const double t void Geom_BSplineCurve::SetKnot(const int Index, const double K) { if (Index < 1 || Index > myKnots.Length()) + { throw Standard_OutOfRange("BSpline curve: SetKnot: Index and #knots mismatch"); + } double DK = std::abs(Epsilon(K)); if (Index == 1) { if (K >= myKnots.Value(2) - DK) + { throw Standard_ConstructionError("BSpline curve: SetKnot: K out of range"); + } } else if (Index == myKnots.Length()) { @@ -718,12 +782,16 @@ void Geom_BSplineCurve::SetPeriodic() NCollection_Array1 cknots(1, last - first + 1); for (int k = first; k <= last; k++) + { cknots(k - first + 1) = myKnots(k); + } myKnots = std::move(cknots); NCollection_Array1 cmults(1, last - first + 1); for (int k = first; k <= last; k++) + { cmults(k - first + 1) = myMults(k); + } cmults(1) = cmults(cmults.Upper()) = std::min(myDeg, std::max(cmults(1), cmults(cmults.Upper()))); myMults = std::move(cmults); @@ -732,9 +800,13 @@ void Geom_BSplineCurve::SetPeriodic() myPoles.Resize(1, nbp, true); if (myRational) + { myWeights.Resize(1, nbp, true); + } else + { myWeights = BSplCLib::UnitWeights(nbp); + } myPeriodic = true; @@ -747,7 +819,9 @@ void Geom_BSplineCurve::SetPeriodic() void Geom_BSplineCurve::SetOrigin(const int Index) { if (!myPeriodic) + { throw Standard_NoSuchObject("Geom_BSplineCurve::SetOrigin"); + } ClearEvalRepresentation(); @@ -756,7 +830,9 @@ void Geom_BSplineCurve::SetOrigin(const int Index) int last = LastUKnotIndex(); if ((Index < first) || (Index > last)) + { throw Standard_DomainError("Geom_BSplineCurve::SetOrigin"); + } int nbknots = myKnots.Length(); int nbpoles = myPoles.Length(); @@ -783,7 +859,9 @@ void Geom_BSplineCurve::SetOrigin(const int Index) int index = 1; for (i = first + 1; i <= Index; i++) + { index += myMults.Value(i); + } // set the poles and weights NCollection_Array1 newpoles(1, nbpoles); @@ -835,14 +913,20 @@ void Geom_BSplineCurve::SetOrigin(const int Index) void Geom_BSplineCurve::SetOrigin(const double U, const double Tol) { if (!myPeriodic) + { throw Standard_NoSuchObject("Geom_BSplineCurve::SetOrigin"); + } // Is U within the period? double uf = FirstParameter(), ul = LastParameter(); double u = U, period = ul - uf; while (Tol < (uf - u)) + { u += period; + } while (Tol > (ul - u)) + { u -= period; + } if (std::abs(U - u) > Tol) { // Reparametrize the curve @@ -859,7 +943,9 @@ void Geom_BSplineCurve::SetOrigin(const double U, const double Tol) } // For periodic curve, uf and ul represent the same point if (std::abs(U - uf) < Tol || std::abs(U - ul) < Tol) + { return; + } int fk = myKnots.Lower(), lk = myKnots.Upper(), ik = 0; double delta = RealLast(); @@ -876,7 +962,9 @@ void Geom_BSplineCurve::SetOrigin(const double U, const double Tol) { InsertKnot(U); if (delta < 0.) + { ik++; + } } SetOrigin(ik); } @@ -914,9 +1002,13 @@ void Geom_BSplineCurve::SetNotPeriodic() myRational ? &nweights : BSplCLib::NoWeights()); myPoles = std::move(npoles); if (IsRational()) + { myWeights = std::move(nweights); + } else + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } myMults = std::move(nmults); myKnots = std::move(nknots); myPeriodic = false; @@ -931,7 +1023,9 @@ void Geom_BSplineCurve::SetNotPeriodic() void Geom_BSplineCurve::SetPole(const int Index, const gp_Pnt& P) { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: SetPole: index and #pole mismatch"); + } ClearEvalRepresentation(); myPoles.SetValue(Index, P); myMaxDerivInvOk = false; @@ -950,10 +1044,14 @@ void Geom_BSplineCurve::SetPole(const int Index, const gp_Pnt& P, const double W void Geom_BSplineCurve::SetWeight(const int Index, const double W) { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("BSpline curve: SetWeight: Index and #pole mismatch"); + } if (W <= gp::Resolution()) + { throw Standard_ConstructionError("BSpline curve: SetWeight: Weight too small"); + } ClearEvalRepresentation(); @@ -973,7 +1071,9 @@ void Geom_BSplineCurve::SetWeight(const int Index, const double W) { rat = Rational(myWeights); if (!rat) + { myWeights = BSplCLib::UnitWeights(myPoles.Length()); + } } myRational = rat; @@ -1088,7 +1188,9 @@ void Geom_BSplineCurve::updateKnots() } if (MaxKnotMult == 0) + { mySmooth = GeomAbs_CN; + } else { switch (myDeg - MaxKnotMult) diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve_1.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve_1.cxx index 4f90e01d97..318c7152a6 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve_1.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve_1.cxx @@ -75,13 +75,19 @@ bool Geom_BSplineCurve::IsG1(const double theTf, const double theTl, const doubl const double aTpar = Knot(aNKnot); if (aTpar < theTf) + { continue; + } if (aTpar > theTl) + { break; + } int mult = Multiplicity(aNKnot); if (mult < aDeg) + { continue; + } gp_Pnt aP1, aP2; gp_Vec aV1, aV2; @@ -94,11 +100,15 @@ bool Geom_BSplineCurve::IsG1(const double theTf, const double theTl, const doubl } if (std::abs(aV1.Angle(aV2)) > theAngTol) + { return false; + } } if (!IsPeriodic()) + { return true; + } const double aFirstParam = FirstParameter(), aLastParam = LastParameter(); @@ -124,7 +134,9 @@ bool Geom_BSplineCurve::IsG1(const double theTf, const double theTl, const doubl } if (std::abs(aV1.Angle(aV2)) > theAngTol) + { return false; + } return true; } @@ -173,7 +185,9 @@ gp_Pnt Geom_BSplineCurve::EvalD0(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D0(aNewU, aSpanIndex, myDeg, myPeriodic, myPoles, Weights(), myKnots, &myMults, P); return P; @@ -195,7 +209,9 @@ Geom_Curve::ResD1 Geom_BSplineCurve::EvalD1(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D1(aNewU, aSpanIndex, @@ -226,7 +242,9 @@ Geom_Curve::ResD2 Geom_BSplineCurve::EvalD2(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D2(aNewU, aSpanIndex, @@ -258,7 +276,9 @@ Geom_Curve::ResD3 Geom_BSplineCurve::EvalD3(const double U) const PeriodicNormalization(aNewU); BSplCLib::LocateParameter(myDeg, myKnots, &myMults, U, myPeriodic, aSpanIndex, aNewU); if (aNewU < myKnots(aSpanIndex)) + { aSpanIndex--; + } BSplCLib::D3(aNewU, aSpanIndex, @@ -280,7 +300,9 @@ Geom_Curve::ResD3 Geom_BSplineCurve::EvalD3(const double U) const gp_Vec Geom_BSplineCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) @@ -298,9 +320,13 @@ gp_Vec Geom_BSplineCurve::EvalDN(const double U, const int N) const gp_Pnt Geom_BSplineCurve::EndPoint() const { if (myMults(myKnots.Upper()) == myDeg + 1) + { return myPoles(myPoles.Upper()); + } else + { return Value(LastParameter()); + } } //================================================================================================= @@ -308,9 +334,13 @@ gp_Pnt Geom_BSplineCurve::EndPoint() const int Geom_BSplineCurve::FirstUKnotIndex() const { if (myPeriodic) + { return 1; + } else + { return BSplCLib::FirstUKnotIndex(myDeg, myMults); + } } //================================================================================================= @@ -342,7 +372,9 @@ void Geom_BSplineCurve::Knots(NCollection_Array1& K) const Standard_DomainError_Raise_if(K.Lower() < myKnots.Lower() || K.Upper() > myKnots.Upper(), "Geom_BSplineCurve::Knots"); for (int anIdx = K.Lower(); anIdx <= K.Upper(); anIdx++) + { K(anIdx) = myKnots(anIdx); + } } const NCollection_Array1& Geom_BSplineCurve::Knots() const @@ -357,7 +389,9 @@ void Geom_BSplineCurve::KnotSequence(NCollection_Array1& K) const Standard_DomainError_Raise_if(K.Lower() < myFlatKnots.Lower() || K.Upper() > myFlatKnots.Upper(), "Geom_BSplineCurve::KnotSequence"); for (int anIdx = K.Lower(); anIdx <= K.Upper(); anIdx++) + { K(anIdx) = myFlatKnots(anIdx); + } } const NCollection_Array1& Geom_BSplineCurve::KnotSequence() const @@ -370,9 +404,13 @@ const NCollection_Array1& Geom_BSplineCurve::KnotSequence() const int Geom_BSplineCurve::LastUKnotIndex() const { if (myPeriodic) + { return myKnots.Length(); + } else + { return BSplCLib::LastUKnotIndex(myDeg, myMults); + } } //================================================================================================= @@ -587,9 +625,13 @@ const NCollection_Array1& Geom_BSplineCurve::Poles() const gp_Pnt Geom_BSplineCurve::StartPoint() const { if (myMults(1) == myDeg + 1) + { return myPoles(1); + } else + { return Value(FirstParameter()); + } } //================================================================================================= @@ -598,9 +640,13 @@ double Geom_BSplineCurve::Weight(const int Index) const { Standard_OutOfRange_Raise_if(Index < 1 || Index > myPoles.Length(), "Geom_BSplineCurve::Weight"); if (IsRational()) + { return myWeights(Index); + } else + { return 1.; + } } //================================================================================================= @@ -609,20 +655,26 @@ void Geom_BSplineCurve::Weights(NCollection_Array1& W) const { Standard_DimensionError_Raise_if(W.Length() != myPoles.Length(), "Geom_BSplineCurve::Weights"); if (IsRational()) + { W = myWeights; + } else { int i; for (i = W.Lower(); i <= W.Upper(); i++) + { W(i) = 1.; + } } } const NCollection_Array1* Geom_BSplineCurve::Weights() const { if (IsRational()) + { return &myWeights; + } return BSplCLib::NoWeights(); } @@ -639,7 +691,9 @@ void Geom_BSplineCurve::Transform(const gp_Trsf& T) { ClearEvalRepresentation(); for (int I = 1; I <= myPoles.Length(); I++) + { myPoles.ChangeValue(I).Transform(T); + } myMaxDerivInvOk = false; } @@ -783,7 +837,9 @@ bool Geom_BSplineCurve::IsEqual(const occ::handle& theOther, } if (!myRational) + { return true; + } for (int aWeightIter = 1; aWeightIter <= myWeights.Length(); ++aWeightIter) { diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx index e18851da49..3566d5182f 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx @@ -95,10 +95,14 @@ static void CheckSurfaceData(const NCollection_Array2& SPoles, } if (SPoles.ColLength() != BSplCLib::NbPoles(UDegree, UPeriodic, SUMults)) + { throw Standard_ConstructionError("Geom_BSplineSurface: # U Poles and degree mismatch"); + } if (SPoles.RowLength() != BSplCLib::NbPoles(VDegree, VPeriodic, SVMults)) + { throw Standard_ConstructionError("Geom_BSplineSurface: # V Poles and degree mismatch"); + } } //================================================================================================= @@ -240,12 +244,16 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2& Poles // check weights if (Weights.ColLength() != Poles.ColLength()) + { throw Standard_ConstructionError( "Geom_BSplineSurface: U Weights and Poles array size mismatch"); + } if (Weights.RowLength() != Poles.RowLength()) + { throw Standard_ConstructionError( "Geom_BSplineSurface: V Weights and Poles array size mismatch"); + } int i, j; for (i = Weights.LowerRow(); i <= Weights.UpperRow(); i++) @@ -253,7 +261,9 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2& Poles for (j = Weights.LowerCol(); j <= Weights.UpperCol(); j++) { if (Weights(i, j) <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BSplineSurface: Weights values too small"); + } } } @@ -357,7 +367,9 @@ void Geom_BSplineSurface::IncreaseDegree(const int UDegree, const int VDegree) if (UDegree != myUDeg) { if (UDegree < myUDeg || UDegree > Geom_BSplineSurface::MaxDegree()) + { throw Standard_ConstructionError("Geom_BSplineSurface::IncreaseDegree: bad U degree value"); + } ClearEvalRepresentation(); @@ -420,7 +432,9 @@ void Geom_BSplineSurface::IncreaseDegree(const int UDegree, const int VDegree) if (VDegree != myVDeg) { if (VDegree < myVDeg || VDegree > Geom_BSplineSurface::MaxDegree()) + { throw Standard_ConstructionError("Geom_BSplineSurface::IncreaseDegree: bad V degree value"); + } ClearEvalRepresentation(); @@ -499,7 +513,9 @@ void Geom_BSplineSurface::IncreaseUMultiplicity(const int FromI1, const int ToI2 NCollection_Array1 k(myUKnots(FromI1), FromI1, ToI2); NCollection_Array1 m(FromI1, ToI2); for (int i = FromI1; i <= ToI2; i++) + { m(i) = M - myUMults.Value(i); + } InsertUKnots(k, m, Epsilon(1.), true); } @@ -521,7 +537,9 @@ void Geom_BSplineSurface::IncreaseVMultiplicity(const int FromI1, const int ToI2 NCollection_Array1 k(myVKnots(FromI1), FromI1, ToI2); NCollection_Array1 m(FromI1, ToI2); for (int i = FromI1; i <= ToI2; i++) + { m(i) = M - myVMults.Value(i); + } InsertVKnots(k, m, Epsilon(1.), true); } @@ -542,9 +560,13 @@ void Geom_BSplineSurface::segment(const double U1, { double aUPeriod = myUKnots.Last() - myUKnots.First(); if (deltaU - aUPeriod > Precision::PConfusion()) + { throw Standard_DomainError("Geom_BSplineSurface::Segment"); + } if (deltaU > aUPeriod) + { deltaU = aUPeriod; + } } double deltaV = V2 - V1; @@ -552,9 +574,13 @@ void Geom_BSplineSurface::segment(const double U1, { double aVPeriod = myVKnots.Last() - myVKnots.First(); if (deltaV - aVPeriod > Precision::PConfusion()) + { throw Standard_DomainError("Geom_BSplineSurface::Segment"); + } if (deltaV > aVPeriod) + { deltaV = aVPeriod; + } } double NewU1, NewU2, NewV1, NewV2; @@ -638,7 +664,9 @@ void Geom_BSplineSurface::segment(const double U1, index, U); if (std::abs(myUKnots.Value(index + 1) - U) <= EpsU) + { index++; + } SetUOrigin(index); SetUNotPeriodic(); } @@ -657,7 +685,9 @@ void Geom_BSplineSurface::segment(const double U1, index1U, U); if (std::abs(myUKnots.Value(index1U + 1) - U) <= EpsU) + { index1U++; + } BSplCLib::LocateParameter(myUDeg, myUKnots, myUMults, @@ -668,7 +698,9 @@ void Geom_BSplineSurface::segment(const double U1, index2U, U); if (std::abs(myUKnots.Value(index2U + 1) - U) <= EpsU || index2U == index1U) + { index2U++; + } int nbuknots = index2U - index1U + 1; @@ -701,7 +733,9 @@ void Geom_BSplineSurface::segment(const double U1, index, V); if (std::abs(myVKnots.Value(index + 1) - V) <= EpsV) + { index++; + } SetVOrigin(index); SetVNotPeriodic(); } @@ -720,7 +754,9 @@ void Geom_BSplineSurface::segment(const double U1, index1V, V); if (std::abs(myVKnots.Value(index1V + 1) - V) <= EpsV) + { index1V++; + } BSplCLib::LocateParameter(myVDeg, myVKnots, myVMults, @@ -731,7 +767,9 @@ void Geom_BSplineSurface::segment(const double U1, index2V, V); if (std::abs(myVKnots.Value(index2V + 1) - V) <= EpsV || index2V == index1V) + { index2V++; + } int nbvknots = index2V - index1V + 1; @@ -824,7 +862,9 @@ void Geom_BSplineSurface::Segment(const double U1, const double theVTolerance) { if ((U2 < U1) || (V2 < V1)) + { throw Standard_DomainError("Geom_BSplineSurface::Segment"); + } double aMaxU = std::max(std::abs(U2), std::abs(U1)); double EpsU = std::max(Epsilon(aMaxU), theUTolerance); @@ -846,7 +886,9 @@ void Geom_BSplineSurface::CheckAndSegment(const double U1, { if ((U2 < U1) || (V2 < V1)) + { throw Standard_DomainError("Geom_BSplineSurface::CheckAndSegment"); + } double aMaxU = std::max(std::abs(U2), std::abs(U1)); double EpsU = std::max(Epsilon(aMaxU), theUTolerance); @@ -869,14 +911,18 @@ void Geom_BSplineSurface::CheckAndSegment(const double U1, void Geom_BSplineSurface::SetUKnot(const int UIndex, const double K) { if (UIndex < 1 || UIndex > myUKnots.Length()) + { throw Standard_OutOfRange("Geom_BSplineSurface::SetUKnot: Index and #knots mismatch"); + } int NewIndex = UIndex; double DU = std::abs(Epsilon(K)); if (UIndex == 1) { if (K >= myUKnots.Value(2) - DU) + { throw Standard_ConstructionError("Geom_BSplineSurface::SetUKnot: K out of range"); + } } else if (UIndex == myUKnots.Length()) { @@ -959,7 +1005,9 @@ void Geom_BSplineSurface::SetUKnot(const int UIndex, const double K, const int M void Geom_BSplineSurface::SetVKnot(const int VIndex, const double K) { if (VIndex < 1 || VIndex > myVKnots.Length()) + { throw Standard_OutOfRange("Geom_BSplineSurface::SetVKnot: Index and #knots mismatch"); + } int NewIndex = VIndex + myVKnots.Lower() - 1; double DV = std::abs(Epsilon(K)); if (VIndex == 1) @@ -1117,7 +1165,9 @@ void Geom_BSplineSurface::updateUKnots() } if (MaxKnotMult == 0) + { myUSmooth = GeomAbs_CN; + } else { switch (myUDeg - MaxKnotMult) @@ -1163,7 +1213,9 @@ void Geom_BSplineSurface::updateVKnots() } if (MaxKnotMult == 0) + { myVSmooth = GeomAbs_CN; + } else { switch (myVDeg - MaxKnotMult) @@ -1201,8 +1253,10 @@ void Geom_BSplineSurface::PeriodicNormalization(double& Uparameter, double& Vpar Period = aMaxVal - aMinVal; if (Period <= eps) + { throw Standard_OutOfRange( "Geom_BSplineSurface::PeriodicNormalization: Uparameter is too great number"); + } bool isLess, isGreater; isLess = aMinVal - Uparameter > 0; @@ -1223,8 +1277,10 @@ void Geom_BSplineSurface::PeriodicNormalization(double& Uparameter, double& Vpar Period = aMaxVal - aMinVal; if (Period <= eps) + { throw Standard_OutOfRange( "Geom_BSplineSurface::PeriodicNormalization: Vparameter is too great number"); + } bool isLess, isGreater; isLess = aMinVal - Vparameter > 0; @@ -1244,7 +1300,9 @@ void Geom_BSplineSurface::PeriodicNormalization(double& Uparameter, double& Vpar void Geom_BSplineSurface::SetWeight(const int UIndex, const int VIndex, const double Weight) { if (Weight <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BSplineSurface::SetWeight: Weight too small"); + } if (UIndex < 1 || UIndex > myPoles.ColLength() || VIndex < 1 || VIndex > myPoles.RowLength()) { throw Standard_OutOfRange("Geom_BSplineSurface::SetWeight: Index and #pole mismatch"); @@ -1258,7 +1316,9 @@ void Geom_BSplineSurface::SetWeight(const int UIndex, const int VIndex, const do myWeights(UIndex + myWeights.LowerRow() - 1, VIndex + myWeights.LowerCol() - 1) = Weight; Rational(myWeights, myURational, myVRational); if (!myURational && !myVRational) + { myWeights = BSplSLib::UnitWeights(myPoles.ColLength(), myPoles.RowLength()); + } myMaxDerivInvOk = false; } @@ -1295,7 +1355,9 @@ void Geom_BSplineSurface::SetWeightCol(const int VIndex, // Check if it is rational Rational(myWeights, myURational, myVRational); if (!myURational && !myVRational) + { myWeights = BSplSLib::UnitWeights(myPoles.ColLength(), myPoles.RowLength()); + } myMaxDerivInvOk = false; } @@ -1334,7 +1396,9 @@ void Geom_BSplineSurface::SetWeightRow(const int UIndex, // Check if it is rational Rational(myWeights, myURational, myVRational); if (!myURational && !myVRational) + { myWeights = BSplSLib::UnitWeights(myPoles.ColLength(), myPoles.RowLength()); + } myMaxDerivInvOk = false; } diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface_1.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface_1.cxx index b205c0e419..f30eb6bf1d 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface_1.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface_1.cxx @@ -279,7 +279,9 @@ Geom_Surface::ResD3 Geom_BSplineSurface::EvalD3(const double U, const double V) gp_Vec Geom_BSplineSurface::EvalDN(const double U, const double V, const int Nu, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalSurfaceDN(myEvalRep, U, V, Nu, Nv, aEvalRepResult)) @@ -882,7 +884,9 @@ const NCollection_Array1& Geom_BSplineSurface::VMultiplicities() const double Geom_BSplineSurface::Weight(const int UIndex, const int VIndex) const { if (!(myURational || myVRational)) + { return 1.0; + } Standard_OutOfRange_Raise_if(UIndex < 1 || UIndex > myWeights.ColLength() || VIndex < 1 || VIndex > myWeights.RowLength(), " "); @@ -910,7 +914,9 @@ void Geom_BSplineSurface::Weights(NCollection_Array2& W) const const NCollection_Array2* Geom_BSplineSurface::Weights() const { if (myURational || myVRational) + { return &myWeights; + } return BSplSLib::NoWeights(); } @@ -939,12 +945,16 @@ void Geom_BSplineSurface::SetUPeriodic() NCollection_Array1 cknots(1, last - first + 1); for (int k = first; k <= last; k++) + { cknots(k - first + 1) = myUKnots(k); + } myUKnots = std::move(cknots); NCollection_Array1 cmults(1, last - first + 1); for (int k = first; k <= last; k++) + { cmults(k - first + 1) = myUMults(k); + } cmults(1) = cmults(cmults.Upper()) = std::min(myUDeg, std::max(cmults(1), cmults(cmults.Upper()))); myUMults = std::move(cmults); @@ -978,12 +988,16 @@ void Geom_BSplineSurface::SetVPeriodic() NCollection_Array1 cknots(1, last - first + 1); for (int k = first; k <= last; k++) + { cknots(k - first + 1) = myVKnots(k); + } myVKnots = std::move(cknots); NCollection_Array1 cmults(1, last - first + 1); for (int k = first; k <= last; k++) + { cmults(k - first + 1) = myVMults(k); + } cmults(1) = cmults(cmults.Upper()) = std::min(myVDeg, std::max(cmults(1), cmults(cmults.Upper()))); myVMults = std::move(cmults); @@ -1012,7 +1026,9 @@ void Geom_BSplineSurface::SetVPeriodic() void Geom_BSplineSurface::SetUOrigin(const int Index) { if (!myUPeriodic) + { throw Standard_NoSuchObject("Geom_BSplineSurface::SetUOrigin: surface is not U periodic"); + } ClearEvalRepresentation(); @@ -1021,7 +1037,9 @@ void Geom_BSplineSurface::SetUOrigin(const int Index) int last = LastUKnotIndex(); if ((Index < first) || (Index > last)) + { throw Standard_DomainError("Geom_BSplineCurve::SetUOrigin: Index out of range"); + } int nbknots = myUKnots.Length(); int nbpoles = myPoles.ColLength(); @@ -1048,7 +1066,9 @@ void Geom_BSplineSurface::SetUOrigin(const int Index) int index = 1; for (i = first + 1; i <= Index; i++) + { index += myUMults.Value(i); + } // set the poles and weights int nbvp = myPoles.RowLength(); @@ -1112,7 +1132,9 @@ void Geom_BSplineSurface::SetUOrigin(const int Index) void Geom_BSplineSurface::SetVOrigin(const int Index) { if (!myVPeriodic) + { throw Standard_NoSuchObject("Geom_BSplineSurface::SetVOrigin: surface is not V periodic"); + } ClearEvalRepresentation(); @@ -1121,7 +1143,9 @@ void Geom_BSplineSurface::SetVOrigin(const int Index) int last = LastVKnotIndex(); if ((Index < first) || (Index > last)) + { throw Standard_DomainError("Geom_BSplineCurve::SetVOrigin: Index out of range"); + } int nbknots = myVKnots.Length(); int nbpoles = myPoles.RowLength(); @@ -1148,7 +1172,9 @@ void Geom_BSplineSurface::SetVOrigin(const int Index) int index = 1; for (i = first + 1; i <= Index; i++) + { index += myVMults.Value(i); + } // set the poles and weights int nbup = myPoles.ColLength(); @@ -1324,14 +1350,18 @@ void Geom_BSplineSurface::SetVNotPeriodic() bool Geom_BSplineSurface::IsUClosed() const { if (myUPeriodic) + { return true; + } double aU1, aU2, aV1, aV2; Bounds(aU1, aU2, aV1, aV2); occ::handle aCUF = UIso(aU1); occ::handle aCUL = UIso(aU2); if (aCUF.IsNull() || aCUL.IsNull()) + { return false; + } occ::handle aBsF = occ::down_cast(aCUF); occ::handle aBsL = occ::down_cast(aCUL); return (!aBsF.IsNull() && !aBsL.IsNull() && aBsF->IsEqual(aBsL, Precision::Confusion())); @@ -1342,14 +1372,18 @@ bool Geom_BSplineSurface::IsUClosed() const bool Geom_BSplineSurface::IsVClosed() const { if (myVPeriodic) + { return true; + } double aU1, aU2, aV1, aV2; Bounds(aU1, aU2, aV1, aV2); occ::handle aCVF = VIso(aV1); occ::handle aCVL = VIso(aV2); if (aCVF.IsNull() || aCVL.IsNull()) + { return false; + } occ::handle aBsF = occ::down_cast(aCVF); occ::handle aBsL = occ::down_cast(aCVL); return (!aBsF.IsNull() && !aBsL.IsNull() && aBsF->IsEqual(aBsL, Precision::Confusion())); @@ -1374,9 +1408,13 @@ bool Geom_BSplineSurface::IsVPeriodic() const int Geom_BSplineSurface::FirstUKnotIndex() const { if (myUPeriodic) + { return 1; + } else + { return BSplCLib::FirstUKnotIndex(myUDeg, myUMults); + } } //================================================================================================= @@ -1384,9 +1422,13 @@ int Geom_BSplineSurface::FirstUKnotIndex() const int Geom_BSplineSurface::FirstVKnotIndex() const { if (myVPeriodic) + { return 1; + } else + { return BSplCLib::FirstUKnotIndex(myVDeg, myVMults); + } } //================================================================================================= @@ -1394,9 +1436,13 @@ int Geom_BSplineSurface::FirstVKnotIndex() const int Geom_BSplineSurface::LastUKnotIndex() const { if (myUPeriodic) + { return myUKnots.Length(); + } else + { return BSplCLib::LastUKnotIndex(myUDeg, myUMults); + } } //================================================================================================= @@ -1404,9 +1450,13 @@ int Geom_BSplineSurface::LastUKnotIndex() const int Geom_BSplineSurface::LastVKnotIndex() const { if (myVPeriodic) + { return myVKnots.Length(); + } else + { return BSplCLib::LastUKnotIndex(myVDeg, myVMults); + } } //================================================================================================= @@ -1526,12 +1576,18 @@ void Geom_BSplineSurface::UReverse() BSplCLib::Reverse(myUKnots); int last; if (myUPeriodic) + { last = myUFlatKnots.Upper() - myUDeg - 1; + } else + { last = myPoles.UpperRow(); + } BSplSLib::Reverse(myPoles, last, true); if (myURational || myVRational) + { BSplSLib::Reverse(myWeights, last, true); + } updateUKnots(); } @@ -1551,12 +1607,18 @@ void Geom_BSplineSurface::VReverse() BSplCLib::Reverse(myVKnots); int last; if (myVPeriodic) + { last = myVFlatKnots.Upper() - myVDeg - 1; + } else + { last = myPoles.UpperCol(); + } BSplSLib::Reverse(myPoles, last, false); if (myURational || myVRational) + { BSplSLib::Reverse(myWeights, last, false); + } updateVKnots(); } @@ -1818,10 +1880,14 @@ void Geom_BSplineSurface::InsertUKnots(const NCollection_Array1& Knots, nbknots, ParametricTolerance, Add)) + { throw Standard_ConstructionError("Geom_BSplineSurface::InsertUKnots"); + } if (nbpoles == myPoles.ColLength()) + { return; + } ClearEvalRepresentation(); @@ -1895,10 +1961,14 @@ void Geom_BSplineSurface::InsertVKnots(const NCollection_Array1& Knots, nbknots, ParametricTolerance, Add)) + { throw Standard_ConstructionError("Geom_BSplineSurface::InsertVKnots"); + } if (nbpoles == myPoles.RowLength()) + { return; + } ClearEvalRepresentation(); @@ -1957,7 +2027,9 @@ void Geom_BSplineSurface::InsertVKnots(const NCollection_Array1& Knots, bool Geom_BSplineSurface::RemoveUKnot(const int Index, const int M, const double Tolerance) { if (M < 0) + { return true; + } int I1 = FirstUKnotIndex(); int I2 = LastUKnotIndex(); @@ -1973,7 +2045,9 @@ bool Geom_BSplineSurface::RemoveUKnot(const int Index, const int M, const double int step = myUMults.Value(Index) - M; if (step <= 0) + { return true; + } NCollection_Array2 npoles(1, myPoles.ColLength() - step, 1, myPoles.RowLength()); const int aNewUKnotLen = (M == 0) ? myUKnots.Length() - 1 : myUKnots.Length(); @@ -1996,7 +2070,9 @@ bool Geom_BSplineSurface::RemoveUKnot(const int Index, const int M, const double nknots, nmults, Tolerance)) + { return false; + } myWeights = std::move(nweights); } else @@ -2015,7 +2091,9 @@ bool Geom_BSplineSurface::RemoveUKnot(const int Index, const int M, const double nknots, nmults, Tolerance)) + { return false; + } myWeights = BSplSLib::UnitWeights(npoles.ColLength(), npoles.RowLength()); } @@ -2034,7 +2112,9 @@ bool Geom_BSplineSurface::RemoveUKnot(const int Index, const int M, const double bool Geom_BSplineSurface::RemoveVKnot(const int Index, const int M, const double Tolerance) { if (M < 0) + { return true; + } int I1 = FirstVKnotIndex(); int I2 = LastVKnotIndex(); @@ -2050,7 +2130,9 @@ bool Geom_BSplineSurface::RemoveVKnot(const int Index, const int M, const double int step = myVMults.Value(Index) - M; if (step <= 0) + { return true; + } NCollection_Array2 npoles(1, myPoles.ColLength(), 1, myPoles.RowLength() - step); const int aNewVKnotLen = (M == 0) ? myVKnots.Length() - 1 : myVKnots.Length(); @@ -2073,7 +2155,9 @@ bool Geom_BSplineSurface::RemoveVKnot(const int Index, const int M, const double nknots, nmults, Tolerance)) + { return false; + } myWeights = std::move(nweights); } else @@ -2092,7 +2176,9 @@ bool Geom_BSplineSurface::RemoveVKnot(const int Index, const int M, const double nknots, nmults, Tolerance)) + { return false; + } myWeights = BSplSLib::UnitWeights(npoles.ColLength(), npoles.RowLength()); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx index 71c7cdfc45..994036558f 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx @@ -65,7 +65,9 @@ static bool Rational(const NCollection_Array1& W) { rat = std::abs(W(i) - W(i + 1)) > gp::Resolution(); if (rat) + { break; + } } return rat; } @@ -89,7 +91,9 @@ Geom_BezierCurve::Geom_BezierCurve(const NCollection_Array1& Poles) { int nbpoles = Poles.Length(); if (nbpoles < 2 || nbpoles > (Geom_BezierCurve::MaxDegree() + 1)) + { throw Standard_ConstructionError(); + } // init non rational init(Poles, nullptr); @@ -103,11 +107,15 @@ Geom_BezierCurve::Geom_BezierCurve(const NCollection_Array1& Poles, // copy the poles int nbpoles = Poles.Length(); if (nbpoles < 2 || nbpoles > (Geom_BezierCurve::MaxDegree() + 1)) + { throw Standard_ConstructionError(); + } // check the weights if (Weights.Length() != nbpoles) + { throw Standard_ConstructionError(); + } for (int i = 1; i <= nbpoles; i++) { @@ -133,10 +141,14 @@ Geom_BezierCurve::Geom_BezierCurve(const NCollection_Array1& Poles, void Geom_BezierCurve::Increase(const int Deg) { if (Deg == Degree()) + { return; + } if (Deg < Degree() || Deg > Geom_BezierCurve::MaxDegree()) + { throw Standard_ConstructionError("Geom_BezierCurve::Increase"); + } const int aDeg = myPoles.Length() - 1; @@ -200,10 +212,14 @@ void Geom_BezierCurve::InsertPoleAfter(const int Index, const gp_Pnt& P, const d int nbpoles = NbPoles(); if (nbpoles >= Geom_BezierCurve::MaxDegree() || Weight <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BezierCurve::InsertPoleAfter"); + } if (Index < 0 || Index > nbpoles) + { throw Standard_OutOfRange("Geom_BezierCurve::InsertPoleAfter"); + } int i; @@ -211,12 +227,16 @@ void Geom_BezierCurve::InsertPoleAfter(const int Index, const gp_Pnt& P, const d NCollection_Array1 npoles(1, nbpoles + 1); for (i = 1; i <= Index; i++) + { npoles(i) = myPoles(i); + } npoles(Index + 1) = P; for (i = Index + 1; i <= nbpoles; i++) + { npoles(i + 1) = myPoles(i); + } // Insert the weight bool rat = IsRational() || std::abs(Weight - 1.) > gp::Resolution(); @@ -226,18 +246,30 @@ void Geom_BezierCurve::InsertPoleAfter(const int Index, const gp_Pnt& P, const d NCollection_Array1 nweights(1, nbpoles + 1); for (i = 1; i <= Index; i++) + { if (IsRational()) + { nweights(i) = myWeights(i); + } else + { nweights(i) = 1.; + } + } nweights(Index + 1) = Weight; for (i = Index + 1; i <= nbpoles; i++) + { if (IsRational()) + { nweights(i + 1) = myWeights(i); + } else + { nweights(i + 1) = 1.; + } + } init(npoles, &nweights); } @@ -268,10 +300,14 @@ void Geom_BezierCurve::RemovePole(const int Index) int nbpoles = NbPoles(); if (nbpoles <= 2) + { throw Standard_ConstructionError("Geom_BezierCurve::RemovePole"); + } if (Index < 1 || Index > nbpoles) + { throw Standard_OutOfRange("Geom_BezierCurve::RemovePole"); + } int i; @@ -279,10 +315,14 @@ void Geom_BezierCurve::RemovePole(const int Index) NCollection_Array1 npoles(1, nbpoles - 1); for (i = 1; i < Index; i++) + { npoles(i) = myPoles(i); + } for (i = Index + 1; i <= nbpoles; i++) + { npoles(i - 1) = myPoles(i); + } // Remove the weight if (IsRational()) @@ -290,10 +330,14 @@ void Geom_BezierCurve::RemovePole(const int Index) NCollection_Array1 nweights(1, nbpoles - 1); for (i = 1; i < Index; i++) + { nweights(i) = myWeights(i); + } for (i = Index + 1; i <= nbpoles; i++) + { nweights(i - 1) = myWeights(i); + } init(npoles, &nweights); } @@ -385,7 +429,9 @@ void Geom_BezierCurve::Segment(const double U1, const double U2) void Geom_BezierCurve::SetPole(const int Index, const gp_Pnt& P) { if (Index < 1 || Index > NbPoles()) + { throw Standard_OutOfRange("Geom_BezierCurve::SetPole"); + } myPoles(Index) = P; @@ -411,9 +457,13 @@ void Geom_BezierCurve::SetWeight(const int Index, const double Weight) int nbpoles = NbPoles(); if (Index < 1 || Index > nbpoles) + { throw Standard_OutOfRange("Geom_BezierCurve::SetWeight"); + } if (Weight <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BezierCurve::SetWeight"); + } // compute new rationality bool wasrat = IsRational(); @@ -421,7 +471,9 @@ void Geom_BezierCurve::SetWeight(const int Index, const double Weight) { // a weight of 1. does not turn to rational if (std::abs(Weight - 1.) <= gp::Resolution()) + { return; + } // Becoming rational: copy non-owning view to owned array. myWeights = NCollection_Array1(myWeights); @@ -436,7 +488,9 @@ void Geom_BezierCurve::SetWeight(const int Index, const double Weight) myWeights = BSplCLib::UnitWeights(nbpoles); } else + { myRational = true; + } myMaxDerivInvOk = false; } @@ -547,7 +601,9 @@ Geom_Curve::ResD3 Geom_BezierCurve::EvalD3(const double U) const gp_Vec Geom_BezierCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) @@ -603,7 +659,9 @@ int Geom_BezierCurve::NbPoles() const const gp_Pnt& Geom_BezierCurve::Pole(const int Index) const { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("Geom_BezierCurve::Pole"); + } return myPoles(Index); } @@ -612,7 +670,9 @@ const gp_Pnt& Geom_BezierCurve::Pole(const int Index) const void Geom_BezierCurve::Poles(NCollection_Array1& P) const { if (P.Length() != myPoles.Length()) + { throw Standard_DimensionError("Geom_BezierCurve::Poles"); + } P = myPoles; } @@ -628,11 +688,17 @@ const NCollection_Array1& Geom_BezierCurve::Poles() const double Geom_BezierCurve::Weight(const int Index) const { if (Index < 1 || Index > myPoles.Length()) + { throw Standard_OutOfRange("Geom_BezierCurve::Weight"); + } if (IsRational()) + { return myWeights(Index); + } else + { return 1.; + } } //================================================================================================= @@ -642,13 +708,19 @@ void Geom_BezierCurve::Weights(NCollection_Array1& W) const int nbpoles = NbPoles(); if (W.Length() != nbpoles) + { throw Standard_DimensionError("Geom_BezierCurve::Weights"); + } if (IsRational()) + { W = myWeights; + } else { for (int i = 1; i <= nbpoles; i++) + { W(i) = 1.; + } } } @@ -659,7 +731,9 @@ void Geom_BezierCurve::Transform(const gp_Trsf& T) int nbpoles = NbPoles(); for (int i = 1; i <= nbpoles; i++) + { myPoles(i).Transform(T); + } ClearEvalRepresentation(); myMaxDerivInvOk = false; } @@ -762,13 +836,17 @@ const NCollection_Array1& Geom_BezierCurve::Multiplicities() const static const auto THE_DATA = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = {i + 1, i + 1}; + } return anArr; }(); static const auto THE_MULTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = NCollection_Array1(THE_DATA[i][0], 1, 2); + } return anArr; }(); return THE_MULTS[myPoles.Length() - 1]; @@ -783,7 +861,9 @@ const NCollection_Array1& Geom_BezierCurve::KnotSequence() const static const auto THE_FKNOTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 1; i <= BSplCLib::MaxDegree(); ++i) + { anArr[i] = NCollection_Array1(BSplCLib::FlatBezierKnots(i), 1, 2 * (i + 1)); + } return anArr; }(); return THE_FKNOTS[myPoles.Length() - 1]; diff --git a/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx index c5e36e1653..48749fb04e 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx @@ -282,7 +282,9 @@ static void DeletePoleCol(const NCollection_Array2& Poles, { RowIndex = NewPoles.LowerRow(); if (ColIndex == Index) + { Offset = 1; + } while (RowIndex <= NewPoles.UpperRow()) { NewPoles(RowIndex, ColIndex) = Poles(RowIndex, ColIndex + Offset); @@ -307,7 +309,9 @@ static void DeleteRatPoleCol(const NCollection_Array2& Poles, { RowIndex = NewPoles.LowerRow(); if (ColIndex == Index) + { Offset = 1; + } while (RowIndex <= NewPoles.UpperRow()) { NewPoles(RowIndex, ColIndex) = Poles(RowIndex, ColIndex + Offset); @@ -331,7 +335,9 @@ static void DeletePoleRow(const NCollection_Array2& Poles, { ColIndex = NewPoles.LowerCol(); if (RowIndex == Index) + { Offset = 1; + } while (ColIndex <= NewPoles.UpperCol()) { NewPoles(RowIndex, ColIndex) = Poles(RowIndex + Offset, ColIndex); @@ -356,7 +362,9 @@ static void DeleteRatPoleRow(const NCollection_Array2& Poles, { ColIndex = NewPoles.LowerCol(); if (RowIndex == Index) + { Offset = 1; + } while (ColIndex <= NewPoles.UpperCol()) { NewPoles(RowIndex, ColIndex) = Poles(RowIndex + Offset, ColIndex); @@ -534,7 +542,9 @@ void Geom_BezierSurface::Increase(const int UDeg, const int VDeg) int IncUDeg = UDeg - oldUDeg; int IncVDeg = VDeg - oldVDeg; if (IncUDeg == 0 && IncVDeg == 0) + { return; + } if (IncUDeg > 0) { @@ -643,7 +653,9 @@ void Geom_BezierSurface::InsertPoleColAfter(const int VI const NCollection_Array1& CPoles) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Length() != myPoles.ColLength()) { throw Standard_ConstructionError(); @@ -679,7 +691,9 @@ void Geom_BezierSurface::InsertPoleColAfter(const int VI const NCollection_Array1& CPoleWeights) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Length() != myPoles.ColLength() || CPoleWeights.Length() != CPoles.Length()) { throw Standard_ConstructionError(); @@ -742,7 +756,9 @@ void Geom_BezierSurface::InsertPoleRowAfter(const int UI const NCollection_Array1& CPoles) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Length() != myPoles.RowLength()) { throw Standard_ConstructionError(); @@ -778,7 +794,9 @@ void Geom_BezierSurface::InsertPoleRowAfter(const int UI const NCollection_Array1& CPoleWeights) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Length() != myPoles.RowLength() || CPoleWeights.Length() != CPoles.Length()) { throw Standard_ConstructionError(); @@ -840,9 +858,13 @@ void Geom_BezierSurface::InsertPoleRowBefore(const int U void Geom_BezierSurface::RemovePoleCol(const int VIndex) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (myPoles.RowLength() <= 2) + { throw Standard_ConstructionError(); + } int NbUPoles = myPoles.ColLength(); int NbVPoles = myPoles.RowLength(); @@ -855,9 +877,13 @@ void Geom_BezierSurface::RemovePoleCol(const int VIndex) DeleteRatPoleCol(myPoles, myWeights, VIndex, npoles, nweights); Rational(nweights, myURational, myVRational); if (myURational || myVRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplSLib::UnitWeights(NbUPoles, NbVPoles - 1); + } } else { @@ -873,9 +899,13 @@ void Geom_BezierSurface::RemovePoleCol(const int VIndex) void Geom_BezierSurface::RemovePoleRow(const int UIndex) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange(); + } if (myPoles.ColLength() <= 2) + { throw Standard_ConstructionError(); + } int NbUPoles = myPoles.ColLength(); int NbVPoles = myPoles.RowLength(); @@ -889,9 +919,13 @@ void Geom_BezierSurface::RemovePoleRow(const int UIndex) Rational(nweights, myURational, myVRational); if (myURational || myVRational) + { myWeights = std::move(nweights); + } else + { myWeights = BSplSLib::UnitWeights(NbUPoles - 1, NbVPoles); + } } else { @@ -914,7 +948,9 @@ void Geom_BezierSurface::Segment(const double U1, const double U2, const double NCollection_Array2 aCoefs(1, aMaxDegree + 1, 1, aMinDegree + 1); NCollection_Array2 aWCoefs; if (rat) + { aWCoefs.Resize(1, aMaxDegree + 1, 1, aMinDegree + 1, false); + } const double uparameter_11 = 0.5; const double uspanlenght_11 = 0.5; @@ -966,16 +1002,24 @@ void Geom_BezierSurface::Segment(const double U1, const double U2, const double { NCollection_Array2 aTransposed(1, UDegree() + 1, 1, VDegree() + 1); for (int ii = 1; ii <= UDegree() + 1; ii++) + { for (int jj = 1; jj <= VDegree() + 1; jj++) + { aTransposed(ii, jj) = aCoefs(jj, ii); + } + } aCoefs = std::move(aTransposed); if (rat) { NCollection_Array2 aWTransposed(1, UDegree() + 1, 1, VDegree() + 1); for (int ii = 1; ii <= UDegree() + 1; ii++) + { for (int jj = 1; jj <= VDegree() + 1; jj++) + { aWTransposed(ii, jj) = aWCoefs(jj, ii); + } + } aWCoefs = std::move(aWTransposed); } } @@ -1003,7 +1047,9 @@ void Geom_BezierSurface::Segment(const double U1, const double U2, const double void Geom_BezierSurface::SetPole(const int UIndex, const int VIndex, const gp_Pnt& P) { if (UIndex < 1 || UIndex > myPoles.ColLength() || VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } myPoles(UIndex, VIndex) = P; myMaxDerivInvOk = false; @@ -1018,9 +1064,13 @@ void Geom_BezierSurface::SetPole(const int UIndex, { if (Weight <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BezierSurface::SetPole"); + } if (UIndex < 1 || UIndex > myPoles.ColLength() || VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange("Geom_BezierSurface::SetPole"); + } myPoles(UIndex, VIndex) = P; @@ -1034,7 +1084,9 @@ void Geom_BezierSurface::SetPoleCol(const int VIndex, const NCollection_Array1& CPoleWeights) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Lower() < 1 || CPoles.Lower() > myPoles.ColLength() || CPoles.Upper() < 1 || CPoles.Upper() > myPoles.ColLength() || CPoleWeights.Lower() != CPoles.Lower() @@ -1056,7 +1108,9 @@ void Geom_BezierSurface::SetPoleCol(const int VIndex, void Geom_BezierSurface::SetPoleCol(const int VIndex, const NCollection_Array1& CPoles) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Lower() < 1 || CPoles.Lower() > myPoles.ColLength() || CPoles.Upper() < 1 || CPoles.Upper() > myPoles.ColLength()) @@ -1075,11 +1129,15 @@ void Geom_BezierSurface::SetPoleCol(const int VIndex, const NCollection_Array1& CPoles) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Lower() < 1 || CPoles.Lower() > myPoles.RowLength() || CPoles.Upper() < 1 || CPoles.Upper() > myPoles.RowLength()) + { throw Standard_ConstructionError(); + } for (int I = CPoles.Lower(); I <= CPoles.Upper(); I++) { @@ -1095,7 +1153,9 @@ void Geom_BezierSurface::SetPoleRow(const int UIndex, const NCollection_Array1& CPoleWeights) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange(); + } if (CPoles.Lower() < 1 || CPoles.Lower() > myPoles.RowLength() || CPoles.Upper() < 1 || CPoles.Upper() > myPoles.RowLength() || CPoleWeights.Lower() != CPoles.Lower() @@ -1119,10 +1179,14 @@ void Geom_BezierSurface::SetPoleRow(const int UIndex, void Geom_BezierSurface::SetWeight(const int UIndex, const int VIndex, const double Weight) { if (Weight <= gp::Resolution()) + { throw Standard_ConstructionError("Geom_BezierSurface::SetWeight"); + } if (UIndex < 1 || UIndex > myPoles.ColLength() || VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } // compute new rationality bool wasrat = (myURational || myVRational); @@ -1130,7 +1194,9 @@ void Geom_BezierSurface::SetWeight(const int UIndex, const int VIndex, const dou { // a weight of 1. does not turn to rational if (std::abs(Weight - 1.) <= gp::Resolution()) + { return; + } // owned copy from non-owning view myWeights = NCollection_Array2(myWeights); @@ -1154,7 +1220,9 @@ void Geom_BezierSurface::SetWeightCol(const int VIndex, const NCollection_Array1& CPoleWeights) { if (VIndex < 1 || VIndex > myPoles.RowLength()) + { throw Standard_OutOfRange(); + } if (CPoleWeights.Length() != myPoles.ColLength()) { @@ -1195,7 +1263,9 @@ void Geom_BezierSurface::SetWeightRow(const int UIndex, const NCollection_Array1& CPoleWeights) { if (UIndex < 1 || UIndex > myPoles.ColLength()) + { throw Standard_OutOfRange("Geom_BezierSurface::SetWeightRow"); + } if (CPoleWeights.Lower() < 1 || CPoleWeights.Lower() > myPoles.RowLength() || CPoleWeights.Upper() < 1 || CPoleWeights.Upper() > myPoles.RowLength()) { @@ -1602,7 +1672,9 @@ gp_Vec Geom_BezierSurface::EvalDN(const double U, const double V, const int Nu, } if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } gp_Vec Derivative; if (myURational || myVRational) { @@ -1712,9 +1784,13 @@ occ::handle Geom_BezierSurface::UIso(const double U) const VCurvePoles, &VCurveWeights); if (myURational) + { UIsoCurve = new Geom_BezierCurve(VCurvePoles, VCurveWeights); + } else + { UIsoCurve = new Geom_BezierCurve(VCurvePoles); + } } else { @@ -1760,9 +1836,13 @@ occ::handle Geom_BezierSurface::VIso(const double V) const VCurvePoles, &VCurveWeights); if (myVRational) + { VIsoCurve = new Geom_BezierCurve(VCurvePoles, VCurveWeights); + } else + { VIsoCurve = new Geom_BezierCurve(VCurvePoles); + } } else { @@ -1790,9 +1870,13 @@ double Geom_BezierSurface::Weight(const int UIndex, const int VIndex) const " "); if (myURational || myVRational) + { return myWeights(UIndex, VIndex); + } else + { return 1; + } } //================================================================================================= @@ -1803,9 +1887,13 @@ void Geom_BezierSurface::Weights(NCollection_Array2& W) const || W.ColLength() != myPoles.ColLength(), " "); if (myURational || myVRational) + { W = myWeights; + } else + { W.Init(1.); + } } //================================================================================================= @@ -2030,13 +2118,17 @@ const NCollection_Array1& Geom_BezierSurface::UMultiplicities() const static const auto THE_DATA = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = {i + 1, i + 1}; + } return anArr; }(); static const auto THE_MULTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = NCollection_Array1(THE_DATA[i][0], 1, 2); + } return anArr; }(); return THE_MULTS[myPoles.ColLength() - 1]; @@ -2051,13 +2143,17 @@ const NCollection_Array1& Geom_BezierSurface::VMultiplicities() const static const auto THE_DATA = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = {i + 1, i + 1}; + } return anArr; }(); static const auto THE_MULTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 0; i < THE_MAX_SIZE; ++i) + { anArr[i] = NCollection_Array1(THE_DATA[i][0], 1, 2); + } return anArr; }(); return THE_MULTS[myPoles.RowLength() - 1]; @@ -2072,7 +2168,9 @@ const NCollection_Array1& Geom_BezierSurface::UKnotSequence() const static const auto THE_FKNOTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 1; i <= BSplCLib::MaxDegree(); ++i) + { anArr[i] = NCollection_Array1(BSplCLib::FlatBezierKnots(i), 1, 2 * (i + 1)); + } return anArr; }(); return THE_FKNOTS[myPoles.ColLength() - 1]; @@ -2087,7 +2185,9 @@ const NCollection_Array1& Geom_BezierSurface::VKnotSequence() const static const auto THE_FKNOTS = []() { std::array, THE_MAX_SIZE> anArr; for (int i = 1; i <= BSplCLib::MaxDegree(); ++i) + { anArr[i] = NCollection_Array1(BSplCLib::FlatBezierKnots(i), 1, 2 * (i + 1)); + } return anArr; }(); return THE_FKNOTS[myPoles.RowLength() - 1]; diff --git a/src/ModelingData/TKG3d/Geom/Geom_Circle.cxx b/src/ModelingData/TKG3d/Geom/Geom_Circle.cxx index 359b6f7984..6a4f728717 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Circle.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Circle.cxx @@ -62,7 +62,9 @@ Geom_Circle::Geom_Circle(const Ax2& A2, const double R) { if (R < 0.0) + { throw Standard_ConstructionError(); + } pos = A2; } @@ -130,7 +132,9 @@ void Geom_Circle::SetRadius(const double R) { if (R < 0.0) + { throw Standard_ConstructionError(); + } radius = R; } @@ -180,7 +184,9 @@ Geom_Curve::ResD3 Geom_Circle::EvalD3(const double U) const gp_Vec Geom_Circle::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } return ElCLib::CircleDN(U, pos, radius, N); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_ConicalSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_ConicalSurface.cxx index fb056a0502..0032d6e2c6 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_ConicalSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_ConicalSurface.cxx @@ -69,7 +69,9 @@ Geom_ConicalSurface::Geom_ConicalSurface(const Ax3& A3, const double Ang, const if (R < 0.0 || std::abs(Ang) <= gp::Resolution() || std::abs(Ang) >= M_PI / 2.0 - gp::Resolution()) + { throw Standard_ConstructionError(); + } pos = A3; } @@ -171,7 +173,9 @@ void Geom_ConicalSurface::SetRadius(const double R) { if (R < 0.0) + { throw Standard_ConstructionError(); + } radius = R; } @@ -315,7 +319,9 @@ Geom_Surface::ResD3 Geom_ConicalSurface::EvalD3(const double U, const double V) gp_Vec Geom_ConicalSurface::EvalDN(const double U, const double V, const int Nu, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } if (Nv > 1) { return Vec(0.0, 0.0, 0.0); @@ -355,7 +361,9 @@ void Geom_ConicalSurface::Transform(const Trsf& T) void Geom_ConicalSurface::TransformParameters(double&, double& V, const gp_Trsf& T) const { if (!Precision::IsInfinite(V)) + { V *= std::abs(T.ScaleFactor()); + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_CylindricalSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_CylindricalSurface.cxx index 2574b9cd94..ee9e81a81e 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_CylindricalSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_CylindricalSurface.cxx @@ -76,7 +76,9 @@ Geom_CylindricalSurface::Geom_CylindricalSurface(const Ax3& A3, const double R) { if (R < 0.0) + { throw Standard_ConstructionError(); + } pos = A3; } @@ -273,7 +275,9 @@ gp_Vec Geom_CylindricalSurface::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } if (Nv > 1) { @@ -315,7 +319,9 @@ void Geom_CylindricalSurface::Transform(const Trsf& T) void Geom_CylindricalSurface::TransformParameters(double&, double& V, const gp_Trsf& T) const { if (!Precision::IsInfinite(V)) + { V *= std::abs(T.ScaleFactor()); + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_Ellipse.cxx b/src/ModelingData/TKG3d/Geom/Geom_Ellipse.cxx index 5e7fb5b4f2..fc4dfbf015 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Ellipse.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Ellipse.cxx @@ -127,9 +127,13 @@ void Geom_Ellipse::SetMajorRadius(const double MajorRadius) { if (MajorRadius < minorRadius) + { throw Standard_ConstructionError(); + } else + { majorRadius = MajorRadius; + } } //================================================================================================= @@ -226,7 +230,9 @@ Geom_Curve::ResD3 Geom_Ellipse::EvalD3(const double U) const gp_Vec Geom_Ellipse::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } return ElCLib::EllipseDN(U, pos, majorRadius, minorRadius, N); } @@ -283,9 +289,13 @@ double Geom_Ellipse::Parameter() const { if (majorRadius == 0.0) + { return 0.0; + } else + { return (minorRadius * minorRadius) / majorRadius; + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_ExtrusionUtils.pxx b/src/ModelingData/TKG3d/Geom/Geom_ExtrusionUtils.pxx index 7ca39fb030..383793e0eb 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_ExtrusionUtils.pxx +++ b/src/ModelingData/TKG3d/Geom/Geom_ExtrusionUtils.pxx @@ -157,9 +157,13 @@ inline gp_Vec CalculateDN(const gp_Vec& theCurveDN, const int theDerV) { if (theDerV == 0) + { return theCurveDN; + } else if (theDerU == 0 && theDerV == 1) + { return gp_Vec(theDir); + } return gp_Vec(0.0, 0.0, 0.0); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_Hyperbola.cxx b/src/ModelingData/TKG3d/Geom/Geom_Hyperbola.cxx index a9a3df4b13..56dbed38ac 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Hyperbola.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Hyperbola.cxx @@ -131,9 +131,13 @@ void Geom_Hyperbola::SetMajorRadius(const double MajorRadius) { if (MajorRadius < 0.0) + { throw Standard_ConstructionError(); + } else + { majorRadius = MajorRadius; + } } //================================================================================================= @@ -142,9 +146,13 @@ void Geom_Hyperbola::SetMinorRadius(const double MinorRadius) { if (MinorRadius < 0.0) + { throw Standard_ConstructionError(); + } else + { minorRadius = MinorRadius; + } } //================================================================================================= @@ -261,7 +269,9 @@ Geom_Curve::ResD3 Geom_Hyperbola::EvalD3(const double U) const gp_Vec Geom_Hyperbola::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } return ElCLib::HyperbolaDN(U, pos, majorRadius, minorRadius, N); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_Line.cxx b/src/ModelingData/TKG3d/Geom/Geom_Line.cxx index 2143d5ea77..b11d4ce24e 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Line.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Line.cxx @@ -207,11 +207,17 @@ Geom_Curve::ResD3 Geom_Line::EvalD3(const double U) const gp_Vec Geom_Line::EvalDN(const double, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } if (N == 1) + { return gp_Vec(pos.Direction()); + } else + { return gp_Vec(0.0, 0.0, 0.0); + } } //================================================================================================= @@ -219,7 +225,9 @@ gp_Vec Geom_Line::EvalDN(const double, const int N) const double Geom_Line::TransformedParameter(const double U, const gp_Trsf& T) const { if (Precision::IsInfinite(U)) + { return U; + } return U * std::abs(T.ScaleFactor()); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_OffsetCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_OffsetCurve.cxx index 7cbef0c2a2..b4ee1f0bc7 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_OffsetCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_OffsetCurve.cxx @@ -269,7 +269,9 @@ gp_Pnt Geom_OffsetCurve::EvalD0(const double theU) const const Geom_Curve::ResD1 aBasisD1 = basisCurve->EvalD1(theU); gp_Pnt aValue = aBasisD1.Point; if (!Geom_OffsetCurveUtils::CalculateD0(aValue, aBasisD1.D1, direction.XYZ(), offsetValue)) + { throw Geom_UndefinedValue("Geom_OffsetCurve::EvalD0"); + } return aValue; } @@ -287,7 +289,9 @@ Geom_Curve::ResD1 Geom_OffsetCurve::EvalD1(const double theU) const gp_Pnt aValue = aBasisD2.Point; gp_Vec aD1 = aBasisD2.D1; if (!Geom_OffsetCurveUtils::CalculateD1(aValue, aD1, aBasisD2.D2, direction.XYZ(), offsetValue)) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalD1"); + } return Geom_Curve::ResD1{aValue, aD1}; } @@ -316,7 +320,9 @@ Geom_Curve::ResD2 Geom_OffsetCurve::EvalD2(const double theU) const aD3, aDummyD4, isDirectionChange)) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalD2"); + } } if (!Geom_OffsetCurveUtils::CalculateD2(aValue, aD1, @@ -325,7 +331,9 @@ Geom_Curve::ResD2 Geom_OffsetCurve::EvalD2(const double theU) const direction.XYZ(), offsetValue, isDirectionChange)) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalD2"); + } return Geom_Curve::ResD2{aValue, aD1, aD2}; } @@ -355,7 +363,9 @@ Geom_Curve::ResD3 Geom_OffsetCurve::EvalD3(const double theU) const aD3, aD4, isDirectionChange)) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalD3"); + } } if (!Geom_OffsetCurveUtils::CalculateD3(aValue, aD1, @@ -365,7 +375,9 @@ Geom_Curve::ResD3 Geom_OffsetCurve::EvalD3(const double theU) const direction.XYZ(), offsetValue, isDirectionChange)) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalD3"); + } return Geom_Curve::ResD3{aValue, aD1, aD2, aD3}; } @@ -374,7 +386,9 @@ Geom_Curve::ResD3 Geom_OffsetCurve::EvalD3(const double theU) const gp_Vec Geom_OffsetCurve::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative("Geom_OffsetCurve::EvalDN"); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalCurveDN(myEvalRep, U, N, aEvalRepResult)) { diff --git a/src/ModelingData/TKG3d/Geom/Geom_OffsetCurveUtils.pxx b/src/ModelingData/TKG3d/Geom/Geom_OffsetCurveUtils.pxx index 087da55250..640fc003c3 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_OffsetCurveUtils.pxx +++ b/src/ModelingData/TKG3d/Geom/Geom_OffsetCurveUtils.pxx @@ -469,7 +469,9 @@ bool EvaluateD2(double theU, { gp_Vec aDummyD4; if (!AdjustDerivative(*theBasisCurve, 3, theU, theD1, theD2, aD3, aDummyD4, isDirectionChange)) + { return false; + } } return CalculateD2(theValue, theD1, theD2, aD3, theDir.XYZ(), theOffset, isDirectionChange); @@ -511,7 +513,9 @@ bool EvaluateD3(double theU, if (theD1.SquareMagnitude() <= gp::Resolution()) { if (!AdjustDerivative(*theBasisCurve, 4, theU, theD1, theD2, theD3, aD4, isDirectionChange)) + { return false; + } } return CalculateD3(theValue, diff --git a/src/ModelingData/TKG3d/Geom/Geom_OffsetSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_OffsetSurface.cxx index 438d368011..d9fd29ccdb 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_OffsetSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_OffsetSurface.cxx @@ -238,7 +238,9 @@ void Geom_OffsetSurface::SetBasisSurface(const occ::handle& S, // Raise exception if still C0 if (isC0) + { throw Standard_ConstructionError("Offset with no C1 Surface"); + } } if (isTrimmed) @@ -464,7 +466,9 @@ Geom_Surface::ResD3 Geom_OffsetSurface::EvalD3(const double U, const double V) c gp_Vec Geom_OffsetSurface::EvalDN(const double U, const double V, const int Nu, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative("Geom_OffsetSurface::EvalDN"); + } #ifdef CHECK if (!(basisSurf->IsCNu(Nu) && basisSurf->IsCNv(Nv))) { @@ -864,7 +868,9 @@ occ::handle Geom_OffsetSurface::Surface() const { // Returns an equivalent non-offset surface if it exists for this offset surface. if (offsetValue == 0.0) + { return basisSurf; // Direct case - no offset + } constexpr double Tol = Precision::Confusion(); occ::handle Result, Base; diff --git a/src/ModelingData/TKG3d/Geom/Geom_OffsetSurfaceUtils.pxx b/src/ModelingData/TKG3d/Geom/Geom_OffsetSurfaceUtils.pxx index f85aec6f8c..9ec0e2b247 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_OffsetSurfaceUtils.pxx +++ b/src/ModelingData/TKG3d/Geom/Geom_OffsetSurfaceUtils.pxx @@ -83,9 +83,13 @@ inline bool IsSingular(const gp_Vec& theD1U, double aD1UNorm2 = aD1U.SquareMagnitude(); double aD1VNorm2 = aD1V.SquareMagnitude(); if (aD1UNorm2 > 1.0) + { aD1U /= std::sqrt(aD1UNorm2); + } if (aD1VNorm2 > 1.0) + { aD1V /= std::sqrt(aD1VNorm2); + } gp_Vec aNorm = aD1U.Crossed(aD1V); return aNorm.SquareMagnitude() <= theTol * theTol; @@ -108,9 +112,13 @@ inline bool ComputeNormal(const gp_Vec& theD1U, double aD1UNorm2 = aD1U.SquareMagnitude(); double aD1VNorm2 = aD1V.SquareMagnitude(); if (aD1UNorm2 > 1.0) + { aD1U /= std::sqrt(aD1UNorm2); + } if (aD1VNorm2 > 1.0) + { aD1V /= std::sqrt(aD1VNorm2); + } theNormal = aD1U.Crossed(aD1V); if (theNormal.SquareMagnitude() <= theTol * theTol) @@ -318,7 +326,9 @@ bool ComputeDerivatives(int theMaxOrder, if (theNU <= theNV) { for (int i = 0; i <= theMaxOrder + 1 + theNU; i++) + { for (int j = i; j <= theMaxOrder + theNV + 1; j++) + { if (i + j > theMinOrder) { gp_Vec aOscDN = theOscSurf->EvalDN(theU, theV, i, j); @@ -333,11 +343,15 @@ bool ComputeDerivatives(int theMaxOrder, DerSurfL.SetValue(j, i, aOscDNji); } } + } + } } else { for (int j = 0; j <= theMaxOrder + 1 + theNV; j++) + { for (int i = j; i <= theMaxOrder + theNU + 1; i++) + { if (i + j > theMinOrder) { gp_Vec aOscDN = theOscSurf->EvalDN(theU, theV, i, j); @@ -352,15 +366,23 @@ bool ComputeDerivatives(int theMaxOrder, DerSurfL.SetValue(j, i, aOscDNji); } } + } + } } for (int i = 0; i <= theMaxOrder + theNU; i++) + { for (int j = 0; j <= theMaxOrder + theNV; j++) { if (theAlongU) + { theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurfL, theDerSurf)); + } if (theAlongV) + { theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, theDerSurf, DerSurfL)); + } } + } } else { @@ -381,8 +403,12 @@ bool ComputeDerivatives(int theMaxOrder, } } for (int i = 0; i <= theMaxOrder + theNU; i++) + { for (int j = 0; j <= theMaxOrder + theNV; j++) + { theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, theDerSurf)); + } + } } return true; } @@ -427,13 +453,17 @@ bool ReplaceDerivative(double theU, { aStep = Precision::Confusion() * theDU.Magnitude(); if (aStep > theUMax - theUMin) + { aStep = (theUMax - theUMin) / 100.; + } } else { aStep = Precision::Confusion() * theDV.Magnitude(); if (aStep > theVMax - theVMin) + { aStep = (theVMax - theVMin) / 100.; + } } // Step away from current parametric coordinates and calculate derivatives once again. @@ -447,13 +477,17 @@ bool ReplaceDerivative(double theU, { aU = theU + aStepSign * aStep; if (aU < theUMin || aU > theUMax) + { continue; + } } else { aV = theV + aStepSign * aStep; if (aV < theVMin || aV > theVMax) + { continue; + } } Geom_Surface::ResD1 aD1Result = theBasisSurf->EvalD1(aU, aV); @@ -629,7 +663,9 @@ bool EvaluateD0(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -646,7 +682,9 @@ bool EvaluateD0(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } gp_Dir aNormal; @@ -814,9 +852,13 @@ bool EvaluateD1(double theU, double aD1UNorm2 = aD1U.SquareMagnitude(); double aD1VNorm2 = aD1V.SquareMagnitude(); if (aD1UNorm2 > 1.0) + { aD1U /= std::sqrt(aD1UNorm2); + } if (aD1VNorm2 > 1.0) + { aD1V /= std::sqrt(aD1VNorm2); + } bool isSingular = false; const int aMaxOrder = 3; @@ -905,7 +947,9 @@ bool EvaluateD1(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -922,7 +966,9 @@ bool EvaluateD1(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } gp_Dir aNormal; @@ -975,7 +1021,9 @@ bool EvaluateD1(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -992,7 +1040,9 @@ bool EvaluateD1(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } CSLib::Normal(aMaxOrder, aDerNUV, @@ -1212,7 +1262,9 @@ bool EvaluateD2(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -1229,7 +1281,9 @@ bool EvaluateD2(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } // Compute normal using CSLib (second call with MaxOrder) @@ -1463,7 +1517,9 @@ bool EvaluateD3(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -1480,7 +1536,9 @@ bool EvaluateD3(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } // Compute normal using CSLib (second call with MaxOrder) @@ -1666,7 +1724,9 @@ bool EvaluateDN(double theU, aOscSurf, aDerNUV, aDerSurf)) + { return false; + } } else { @@ -1683,7 +1743,9 @@ bool EvaluateDN(double theU, aDummy, aDerNUV, aDerSurf)) + { return false; + } } // Compute normal with CSLib diff --git a/src/ModelingData/TKG3d/Geom/Geom_OsculatingSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_OsculatingSurface.cxx index 115ef855d4..60e624ca79 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_OsculatingSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_OsculatingSurface.cxx @@ -167,7 +167,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double #endif if (IsAlongU() && IsAlongV()) + { clearOsculFlags(); + } if ((IsAlongU() && InitSurf->VDegree() > 1) || (IsAlongV() && InitSurf->UDegree() > 1)) { @@ -189,7 +191,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(V1, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "1.k = " << k << std::endl; @@ -200,9 +204,13 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double S = L; } if (OsculSurf) + { myOsculSurf1.Append(L); + } else + { clearOsculFlags(); + } if (myAlong[1] && OsculSurf) { S = InitSurf; @@ -215,7 +223,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(V2, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "2.k = " << k << std::endl; @@ -243,7 +253,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(V2, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "2.k = " << k << std::endl; @@ -259,7 +271,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double myKdeg.Append(k); } else + { clearOsculFlags(); + } } } } @@ -278,7 +292,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(U1, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "1.k = " << k << std::endl; @@ -289,9 +305,13 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double S = L; } if (OsculSurf) + { myOsculSurf1.Append(L); + } else + { clearOsculFlags(); + } if (myAlong[3] && OsculSurf) { S = InitSurf; @@ -303,7 +323,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(U2, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "2.k = " << k << std::endl; @@ -331,7 +353,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double { OsculSurf = buildOsculatingSurface(U2, UKnot, VKnot, S, L); if (!OsculSurf) + { break; + } k++; #ifdef OCCT_DEBUG std::cout << "2.k = " << k << std::endl; @@ -347,7 +371,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double myKdeg.Append(k); } else + { clearOsculFlags(); + } } } } @@ -359,7 +385,9 @@ void Geom_OsculatingSurface::Init(const occ::handle& theBS, double } } else + { clearOsculFlags(); + } } //================================================================================================= @@ -388,13 +416,21 @@ bool Geom_OsculatingSurface::UOsculatingSurface(double BSplCLib::Hunt(UKnots, theU, NU); BSplCLib::Hunt(VKnots, theV, NV); if (NU < 1) + { NU = 1; + } if (NU >= NbUK) + { NU = NbUK - 1; + } if (NbVK == 2 && NV == 1) + { // Need to find the closest end if (VKnots(NbVK) - theV > theV - VKnots(1)) + { isToSkipSecond = true; + } + } } else { @@ -414,7 +450,9 @@ bool Geom_OsculatingSurface::UOsculatingSurface(double // to the original. This happens when (v-t)^k is negative, i.e. // difference between degrees (k) is odd and t is the last parameter if (myKdeg.Value(NU) % 2) + { theT = true; + } theL = myOsculSurf2.Value(NU); along = true; } @@ -448,13 +486,21 @@ bool Geom_OsculatingSurface::VOsculatingSurface(double BSplCLib::Hunt(UKnots, theU, NU); BSplCLib::Hunt(VKnots, theV, NV); if (NV < 1) + { NV = 1; + } if (NV >= NbVK) + { NV = NbVK - 1; + } if (NbUK == 2 && NU == 1) + { // Need to find the closest end if (UKnots(NbUK) - theU > theU - UKnots(1)) + { isToSkipSecond = true; + } + } } else { @@ -471,7 +517,9 @@ bool Geom_OsculatingSurface::VOsculatingSurface(double if (myAlong[3] && (NU == NbUK - 1) && !isToSkipSecond) { if (myKdeg.Value(NV) % 2) + { theT = true; + } theL = myOsculSurf2.Value(NV); along = true; } @@ -587,9 +635,13 @@ bool Geom_OsculatingSurface::buildOsculatingSurface(double theParam, bool IsUNegative = theParam > ucacheparameter + uspanlength / 2; if (IsAlongU() && (theParam > vcacheparameter + vspanlength / 2)) + { vcacheparameter = vcacheparameter + vspanlength; + } if (IsAlongV() && (theParam > ucacheparameter + uspanlength / 2)) + { ucacheparameter = ucacheparameter + uspanlength; + } BSplSLib::BuildCache(ucacheparameter, vcacheparameter, @@ -615,26 +667,38 @@ bool Geom_OsculatingSurface::buildOsculatingSurface(double theParam, if (udeg > vdeg) { for (n = 1; n <= (int)udeg + 1; n++) + { for (m = 1; m <= (int)vdeg; m++) + { OscCoeff(n, m) = cachepoles(n, m + 1); + } + } } else { for (n = 1; n <= (int)udeg + 1; n++) + { for (m = 1; m <= (int)vdeg; m++) + { OscCoeff(n, m) = cachepoles(m + 1, n); + } + } } if (IsVNegative) + { PLib::VTrimming(-1, 0, OscCoeff, PLib::NoWeights2()); + } index = 1; for (n = 1; n <= (int)udeg + 1; n++) + { for (m = 1; m <= (int)vdeg; m++) { Coefficients->ChangeValue(index++) = OscCoeff(n, m).X(); Coefficients->ChangeValue(index++) = OscCoeff(n, m).Y(); Coefficients->ChangeValue(index++) = OscCoeff(n, m).Z(); } + } } if (IsAlongV()) @@ -642,31 +706,47 @@ bool Geom_OsculatingSurface::buildOsculatingSurface(double theParam, if (udeg > vdeg) { for (n = 1; n <= (int)udeg; n++) + { for (m = 1; m <= (int)vdeg + 1; m++) + { OscCoeff(n, m) = cachepoles(n + 1, m); + } + } } else { for (n = 1; n <= (int)udeg; n++) + { for (m = 1; m <= (int)vdeg + 1; m++) + { OscCoeff(n, m) = cachepoles(m, n + 1); + } + } } if (IsUNegative) + { PLib::UTrimming(-1, 0, OscCoeff, PLib::NoWeights2()); + } index = 1; for (n = 1; n <= (int)udeg; n++) + { for (m = 1; m <= (int)vdeg + 1; m++) { Coefficients->ChangeValue(index++) = OscCoeff(n, m).X(); Coefficients->ChangeValue(index++) = OscCoeff(n, m).Y(); Coefficients->ChangeValue(index++) = OscCoeff(n, m).Z(); } + } } if (IsAlongU()) + { MaxVDegree--; + } if (IsAlongV()) + { MaxUDegree--; + } UContinuity = -1; VContinuity = -1; @@ -727,7 +807,9 @@ bool Geom_OsculatingSurface::isQPunctual(const occ::handle& theS, std::cout << " D1NormMax = " << D1NormMax << std::endl; #endif if (D1NormMax > theTolMax || D1NormMax < theTolMin) + { Along = false; + } } else { @@ -742,7 +824,9 @@ bool Geom_OsculatingSurface::isQPunctual(const occ::handle& theS, std::cout << " D1NormMax = " << D1NormMax << std::endl; #endif if (D1NormMax > theTolMax || D1NormMax < theTolMin) + { Along = false; + } } return Along; } diff --git a/src/ModelingData/TKG3d/Geom/Geom_Parabola.cxx b/src/ModelingData/TKG3d/Geom/Geom_Parabola.cxx index 545352619e..a912d7a92b 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Parabola.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Parabola.cxx @@ -63,7 +63,9 @@ Geom_Parabola::Geom_Parabola(const Ax2& A2, const double Focal) { if (Focal < 0.0) + { throw Standard_ConstructionError(); + } pos = A2; } @@ -139,7 +141,9 @@ void Geom_Parabola::SetFocal(const double Focal) { if (Focal < 0.0) + { throw Standard_ConstructionError(); + } focalLength = Focal; } @@ -201,7 +205,9 @@ Geom_Curve::ResD3 Geom_Parabola::EvalD3(const double U) const gp_Vec Geom_Parabola::EvalDN(const double U, const int N) const { if (N < 1) + { throw Geom_UndefinedDerivative(); + } return ElCLib::ParabolaDN(U, pos, focalLength, N); } @@ -238,7 +244,9 @@ void Geom_Parabola::Transform(const Trsf& T) double Geom_Parabola::TransformedParameter(const double U, const gp_Trsf& T) const { if (Precision::IsInfinite(U)) + { return U; + } return U * std::abs(T.ScaleFactor()); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_Plane.cxx b/src/ModelingData/TKG3d/Geom/Geom_Plane.cxx index bc186f43a2..da24655c90 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Plane.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Plane.cxx @@ -242,7 +242,9 @@ Geom_Surface::ResD3 Geom_Plane::EvalD3(const double U, const double V) const gp_Vec Geom_Plane::EvalDN(const double, const double, const int Nu, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } if (Nu == 0 && Nv == 1) { return Vec(pos.YDirection()); @@ -275,9 +277,13 @@ occ::handle Geom_Plane::VIso(const double V) const void Geom_Plane::TransformParameters(double& U, double& V, const gp_Trsf& T) const { if (!Precision::IsInfinite(U)) + { U *= std::abs(T.ScaleFactor()); + } if (!Precision::IsInfinite(V)) + { V *= std::abs(T.ScaleFactor()); + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_RectangularTrimmedSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_RectangularTrimmedSurface.cxx index 44bbc78757..9dcbbbe344 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_RectangularTrimmedSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_RectangularTrimmedSurface.cxx @@ -53,11 +53,17 @@ occ::handle Geom_RectangularTrimmedSurface::Copy() const occ::handle S; if (isutrimmed && isvtrimmed) + { S = new RectangularTrimmedSurface(basisSurf, utrim1, utrim2, vtrim1, vtrim2, true, true); + } else if (isutrimmed) + { S = new RectangularTrimmedSurface(basisSurf, utrim1, utrim2, true, true); + } else if (isvtrimmed) + { S = new RectangularTrimmedSurface(basisSurf, vtrim1, vtrim2, false, true); + } return S; } @@ -85,9 +91,13 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface( // kill trimmed basis surfaces occ::handle T = occ::down_cast(S); if (!T.IsNull()) + { basisSurf = occ::down_cast(T->BasisSurface()->Copy()); + } else + { basisSurf = occ::down_cast(S->Copy()); + } occ::handle O = occ::down_cast(basisSurf); if (!O.IsNull()) @@ -113,9 +123,13 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface( // kill trimmed basis surfaces occ::handle T = occ::down_cast(S); if (!T.IsNull()) + { basisSurf = occ::down_cast(T->BasisSurface()->Copy()); + } else + { basisSurf = occ::down_cast(S->Copy()); + } occ::handle O = occ::down_cast(basisSurf); if (!O.IsNull()) @@ -219,7 +233,9 @@ void Geom_RectangularTrimmedSurface::SetTrim(const double U1, else { if (U1 == U2) + { throw Standard_ConstructionError("Geom_RectangularTrimmedSurface::U1==U2"); + } if (basisSurf->IsUPeriodic()) { @@ -251,8 +267,10 @@ void Geom_RectangularTrimmedSurface::SetTrim(const double U1, } if ((Udeb - utrim1 > Precision::PConfusion()) || (utrim2 - Ufin > Precision::PConfusion())) + { throw Standard_ConstructionError( "Geom_RectangularTrimmedSurface::U parameters out of range"); + } } } @@ -266,7 +284,9 @@ void Geom_RectangularTrimmedSurface::SetTrim(const double U1, else { if (V1 == V2) + { throw Standard_ConstructionError("Geom_RectangularTrimmedSurface::V1==V2"); + } if (basisSurf->IsVPeriodic()) { @@ -298,15 +318,21 @@ void Geom_RectangularTrimmedSurface::SetTrim(const double U1, } if ((Vdeb - vtrim1 > Precision::PConfusion()) || (vtrim2 - Vfin > Precision::PConfusion())) + { throw Standard_ConstructionError( "Geom_RectangularTrimmedSurface::V parameters out of range"); + } } } if (!UsameSense) + { UReverse(); + } if (!VsameSense) + { VReverse(); + } } //================================================================================================= @@ -396,7 +422,9 @@ gp_Vec Geom_RectangularTrimmedSurface::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } return basisSurf->EvalDN(U, V, Nu, Nv); } @@ -481,9 +509,13 @@ void Geom_RectangularTrimmedSurface::Transform(const Trsf& T) bool Geom_RectangularTrimmedSurface::IsUPeriodic() const { if (!basisSurf->IsUPeriodic()) + { return false; + } if (!isutrimmed) + { return true; + } const double aPeriod = basisSurf->UPeriod(); const double aLength = utrim2 - utrim1; return aLength > Precision::PConfusion() @@ -502,9 +534,13 @@ double Geom_RectangularTrimmedSurface::UPeriod() const bool Geom_RectangularTrimmedSurface::IsVPeriodic() const { if (!basisSurf->IsVPeriodic()) + { return false; + } if (!isvtrimmed) + { return true; + } const double aPeriod = basisSurf->VPeriod(); const double aLength = vtrim2 - vtrim1; return aLength > Precision::PConfusion() @@ -523,14 +559,18 @@ double Geom_RectangularTrimmedSurface::VPeriod() const bool Geom_RectangularTrimmedSurface::IsUClosed() const { if (!isutrimmed) + { return basisSurf->IsUClosed(); + } if (basisSurf->IsUPeriodic()) { const double aPeriod = basisSurf->UPeriod(); const double aLength = utrim2 - utrim1; if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return false; } @@ -540,14 +580,18 @@ bool Geom_RectangularTrimmedSurface::IsUClosed() const bool Geom_RectangularTrimmedSurface::IsVClosed() const { if (!isvtrimmed) + { return basisSurf->IsVClosed(); + } if (basisSurf->IsVPeriodic()) { const double aPeriod = basisSurf->VPeriod(); const double aLength = vtrim2 - vtrim1; if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return false; } diff --git a/src/ModelingData/TKG3d/Geom/Geom_SphericalSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_SphericalSurface.cxx index bc0147c66d..d7c5114fef 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_SphericalSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_SphericalSurface.cxx @@ -61,7 +61,9 @@ Geom_SphericalSurface::Geom_SphericalSurface(const Ax3& A, const double R) { if (R < 0.0) + { throw Standard_ConstructionError(); + } pos = A; } @@ -271,7 +273,9 @@ gp_Vec Geom_SphericalSurface::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } return ElSLib::SphereDN(U, V, pos, radius, Nu, Nv); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfLinearExtrusion.cxx b/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfLinearExtrusion.cxx index 16f0625748..d1f11214f6 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfLinearExtrusion.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfLinearExtrusion.cxx @@ -248,7 +248,9 @@ gp_Vec Geom_SurfaceOfLinearExtrusion::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalSurfaceDN(myEvalRep, U, V, Nu, Nv, aEvalRepResult)) @@ -356,7 +358,9 @@ void Geom_SurfaceOfLinearExtrusion::TransformParameters(double& U, { U = basisCurve->TransformedParameter(U, T); if (!Precision::IsInfinite(V)) + { V *= std::abs(T.ScaleFactor()); + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfRevolution.cxx b/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfRevolution.cxx index 144cb4f11b..b74ca130fd 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfRevolution.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_SurfaceOfRevolution.cxx @@ -334,7 +334,9 @@ gp_Vec Geom_SurfaceOfRevolution::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } gp_Vec aEvalRepResult; if (GeomEval_RepUtils::TryEvalSurfaceDN(myEvalRep, U, V, Nu, Nv, aEvalRepResult)) { @@ -399,10 +401,14 @@ occ::handle Geom_SurfaceOfRevolution::VIso(const double V) const Rep = gp_Ax2(C, direction, D); } else + { Rep = gp_Ax2(C, direction); + } } else + { Rep = gp_Ax2(Pc, direction); + } Circ = new Geom_Circle(Rep, Rad); return Circ; @@ -417,7 +423,9 @@ void Geom_SurfaceOfRevolution::Transform(const Trsf& T) direction.Transform(T); basisCurve->Transform(T); if (T.ScaleFactor() * T.HVectorialPart().Determinant() < 0.) + { UReverse(); + } } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Geom/Geom_ToroidalSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_ToroidalSurface.cxx index 780b7786db..7a1c1ad121 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_ToroidalSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_ToroidalSurface.cxx @@ -157,9 +157,13 @@ void Geom_ToroidalSurface::SetMajorRadius(const double MajorRadius) { if (MajorRadius - minorRadius <= gp::Resolution()) + { throw Standard_ConstructionError(); + } else + { majorRadius = MajorRadius; + } } //================================================================================================= @@ -168,9 +172,13 @@ void Geom_ToroidalSurface::SetMinorRadius(const double MinorRadius) { if (MinorRadius < 0.0 || majorRadius - MinorRadius <= gp::Resolution()) + { throw Standard_ConstructionError(); + } else + { minorRadius = MinorRadius; + } } //================================================================================================= @@ -278,7 +286,9 @@ gp_Vec Geom_ToroidalSurface::EvalDN(const double U, const int Nv) const { if (Nu + Nv < 1 || Nu < 0 || Nv < 0) + { throw Geom_UndefinedDerivative(); + } return ElSLib::TorusDN(U, V, pos, majorRadius, minorRadius, Nu, Nv); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_TrimmedCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_TrimmedCurve.cxx index 0dc9a922ef..20930fcd86 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_TrimmedCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_TrimmedCurve.cxx @@ -62,9 +62,13 @@ Geom_TrimmedCurve::Geom_TrimmedCurve(const occ::handle& C, // kill trimmed basis curves occ::handle T = occ::down_cast(C); if (!T.IsNull()) + { basisCurve = occ::down_cast(T->BasisCurve()->Copy()); + } else + { basisCurve = occ::down_cast(C->Copy()); + } SetTrim(U1, U2, Sense, theAdjustPeriodic); } @@ -95,7 +99,9 @@ void Geom_TrimmedCurve::SetTrim(const double U1, { bool sameSense = true; if (U1 == U2) + { throw Standard_ConstructionError("Geom_TrimmedCurve::U1 == U2"); + } double Udeb = basisCurve->FirstParameter(); double Ufin = basisCurve->LastParameter(); @@ -109,11 +115,13 @@ void Geom_TrimmedCurve::SetTrim(const double U1, uTrim1 = U1; uTrim2 = U2; if (theAdjustPeriodic) + { ElCLib::AdjustPeriodic(Udeb, Ufin, std::min(std::abs(uTrim2 - uTrim1) / 2, Precision::PConfusion()), uTrim1, uTrim2); + } } else @@ -132,7 +140,9 @@ void Geom_TrimmedCurve::SetTrim(const double U1, } if ((Udeb - uTrim1 > Precision::PConfusion()) || (uTrim2 - Ufin > Precision::PConfusion())) + { throw Standard_ConstructionError("Geom_TrimmedCurve::parameters out of range"); + } } if (!sameSense) { @@ -150,7 +160,9 @@ bool Geom_TrimmedCurve::IsClosed() const const double aLength = LastParameter() - FirstParameter(); if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return StartPoint().SquareDistance(EndPoint()) <= Precision::Computational(); } @@ -165,7 +177,9 @@ bool Geom_TrimmedCurve::IsPeriodic() const const double aLength = LastParameter() - FirstParameter(); if (aLength > Precision::PConfusion() && std::abs(std::remainder(aLength, aPeriod)) <= Precision::PConfusion()) + { return true; + } } return false; } diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor.cxx index bee67303b3..05d17528bb 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor.cxx @@ -148,7 +148,9 @@ occ::handle GeomAdaptor::MakeSurface(const Adaptor3d_Surface& HS, } if (S.IsNull() || !theTrimFlag) + { return S; + } // trim the surface if necassary. double U1, U2, V1, V2; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx index d7e804f798..664ab4fae9 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx @@ -171,14 +171,20 @@ GeomAbs_Shape GeomAdaptor_Curve::LocalContinuity(const double U1, const double U if (std::abs(newFirst - TK(Index1 + 1)) < Precision::PConfusion()) { if (Index1 < Nb) + { Index1++; + } } if (std::abs(newLast - TK(Index2)) < Precision::PConfusion()) + { Index2--; + } int MultMax; // Handle periodic curves. if ((aBSpl->IsPeriodic()) && (Index1 == Nb)) + { Index1 = 1; + } if ((Index2 - Index1 <= 0) && (!aBSpl->IsPeriodic())) { @@ -190,7 +196,9 @@ GeomAbs_Shape GeomAdaptor_Curve::LocalContinuity(const double U1, const double U for (int i = Index1 + 1; i <= Index2; i++) { if (TM(i) > MultMax) + { MultMax = TM(i); + } } MultMax = aBSpl->Degree() - MultMax; } @@ -325,7 +333,9 @@ void GeomAdaptor_Curve::load(const occ::handle& C, GeomAbs_Shape GeomAdaptor_Curve::Continuity() const { if (myTypeCurve == GeomAbs_BSplineCurve) + { return LocalContinuity(myFirst, myLast); + } if (myTypeCurve == GeomAbs_OffsetCurve) { @@ -434,8 +444,12 @@ int GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const NCollection_Array1 rdfInter(1, 1 + iNbBasisInt); C.Intervals(rdfInter, BaseS); for (iInt = 1; iInt <= iNbBasisInt; iInt++) + { if (rdfInter(iInt) > myFirst && rdfInter(iInt) < myLast) + { myNbIntervals++; + } + } } // akm 05/04/02 ^^^ return myNbIntervals; @@ -527,8 +541,12 @@ void GeomAdaptor_Curve::Intervals(NCollection_Array1& T, const GeomAbs_S NCollection_Array1 rdfInter(1, 1 + iNbBasisInt); C.Intervals(rdfInter, BaseS); for (iInt = 1; iInt <= iNbBasisInt; iInt++) + { if (rdfInter(iInt) > myFirst && rdfInter(iInt) < myLast) + { T(++myNbIntervals) = rdfInter(iInt); + } + } } // old - myNbIntervals = C.NbIntervals(BaseS); // old - C.Intervals(T, BaseS); @@ -592,11 +610,13 @@ void GeomAdaptor_Curve::RebuildCache(const double theParameter) const int aDeg = aBezier->Degree(); NCollection_Array1 aFlatKnots(BSplCLib::FlatBezierKnots(aDeg), 1, 2 * (aDeg + 1)); if (aCache.IsNull()) + { aCache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots, aBezier->Poles(), aBezier->Weights()); + } aCache->BuildCache(theParameter, aFlatKnots, aBezier->Poles(), aBezier->Weights()); } else if (myTypeCurve == GeomAbs_BSplineCurve) @@ -606,11 +626,13 @@ void GeomAdaptor_Curve::RebuildCache(const double theParameter) const const auto& aBSpl = aBSplData.Curve; auto& aCache = aBSplData.Cache; if (aCache.IsNull()) + { aCache = new BSplCLib_Cache(aBSpl->Degree(), aBSpl->IsPeriodic(), aBSpl->KnotSequence(), aBSpl->Poles(), aBSpl->Weights()); + } aCache->BuildCache(theParameter, aBSpl->KnotSequence(), aBSpl->Poles(), aBSpl->Weights()); } } @@ -627,17 +649,25 @@ bool GeomAdaptor_Curve::IsBoundary(const double theU, int& theSpanStart, int& th { aBSpl->LocateU(myFirst, PosTol, theSpanStart, theSpanFinish); if (theSpanStart < 1) + { theSpanStart = 1; + } if (theSpanStart >= theSpanFinish) + { theSpanFinish = theSpanStart + 1; + } } else if (theU == myLast) { aBSpl->LocateU(myLast, PosTol, theSpanStart, theSpanFinish); if (theSpanFinish > aBSpl->NbKnots()) + { theSpanFinish = aBSpl->NbKnots(); + } if (theSpanStart >= theSpanFinish) + { theSpanStart = theSpanFinish - 1; + } } return true; } @@ -679,7 +709,9 @@ gp_Pnt GeomAdaptor_Curve::EvalD0(const double theU) const } auto& aCache = std::get(myCurveData).Cache; if (aCache.IsNull()) + { RebuildCache(U); + } aCache->D0(U, P); return P; } @@ -698,7 +730,9 @@ gp_Pnt GeomAdaptor_Curve::EvalD0(const double theU) const else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplData.Cache->D0(U, P); } return P; @@ -761,7 +795,9 @@ Geom_Curve::ResD1 GeomAdaptor_Curve::EvalD1(const double theU) const } auto& aCache = std::get(myCurveData).Cache; if (aCache.IsNull()) + { RebuildCache(U); + } aCache->D1(U, aResult.Point, aResult.D1); return aResult; } @@ -780,7 +816,9 @@ Geom_Curve::ResD1 GeomAdaptor_Curve::EvalD1(const double theU) const else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplData.Cache->D1(U, aResult.Point, aResult.D1); } return aResult; @@ -845,7 +883,9 @@ Geom_Curve::ResD2 GeomAdaptor_Curve::EvalD2(const double theU) const } auto& aCache = std::get(myCurveData).Cache; if (aCache.IsNull()) + { RebuildCache(U); + } aCache->D2(U, aResult.Point, aResult.D1, aResult.D2); return aResult; } @@ -864,7 +904,9 @@ Geom_Curve::ResD2 GeomAdaptor_Curve::EvalD2(const double theU) const else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplData.Cache->D2(U, aResult.Point, aResult.D1, aResult.D2); } return aResult; @@ -947,7 +989,9 @@ Geom_Curve::ResD3 GeomAdaptor_Curve::EvalD3(const double theU) const } auto& aCache = std::get(myCurveData).Cache; if (aCache.IsNull()) + { RebuildCache(U); + } aCache->D3(U, aResult.Point, aResult.D1, aResult.D2, aResult.D3); return aResult; } @@ -967,7 +1011,9 @@ Geom_Curve::ResD3 GeomAdaptor_Curve::EvalD3(const double theU) const else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U)) + { RebuildCache(U); + } aBSplData.Cache->D3(U, aResult.Point, aResult.D1, aResult.D2, aResult.D3); } return aResult; @@ -1035,7 +1081,9 @@ gp_Vec GeomAdaptor_Curve::EvalDN(const double theU, const int theN) const return std::get(myCurveData).Curve->LocalDN(U, aStart, aFinish, N); } else + { return myCurve->EvalDN(U, N); + } } case GeomAbs_OffsetCurve: { @@ -1074,9 +1122,13 @@ double GeomAdaptor_Curve::Resolution(const double R3D) const case GeomAbs_Circle: { double R = std::get(myCurveData).Radius(); if (R > R3D / 2.) + { return 2 * std::asin(R3D / (2 * R)); + } else + { return 2 * M_PI; + } } case GeomAbs_Ellipse: { return R3D / std::get(myCurveData).MajorRadius(); @@ -1151,11 +1203,17 @@ gp_Parab GeomAdaptor_Curve::Parabola() const int GeomAdaptor_Curve::Degree() const { if (myTypeCurve == GeomAbs_BezierCurve) + { return occ::down_cast(myCurve)->Degree(); + } else if (myTypeCurve == GeomAbs_BSplineCurve) + { return std::get(myCurveData).Curve->Degree(); + } else + { throw Standard_NoSuchObject(); + } } //================================================================================================= @@ -1178,11 +1236,17 @@ bool GeomAdaptor_Curve::IsRational() const int GeomAdaptor_Curve::NbPoles() const { if (myTypeCurve == GeomAbs_BezierCurve) + { return occ::down_cast(myCurve)->NbPoles(); + } else if (myTypeCurve == GeomAbs_BSplineCurve) + { return std::get(myCurveData).Curve->NbPoles(); + } else + { throw Standard_NoSuchObject(); + } } //================================================================================================= @@ -1190,7 +1254,9 @@ int GeomAdaptor_Curve::NbPoles() const int GeomAdaptor_Curve::NbKnots() const { if (myTypeCurve != GeomAbs_BSplineCurve) + { throw Standard_NoSuchObject("GeomAdaptor_Curve::NbKnots"); + } return std::get(myCurveData).Curve->NbKnots(); } @@ -1199,7 +1265,9 @@ int GeomAdaptor_Curve::NbKnots() const occ::handle GeomAdaptor_Curve::Bezier() const { if (myTypeCurve != GeomAbs_BezierCurve) + { throw Standard_NoSuchObject("GeomAdaptor_Curve::Bezier"); + } return occ::down_cast(myCurve); } @@ -1208,7 +1276,9 @@ occ::handle GeomAdaptor_Curve::Bezier() const occ::handle GeomAdaptor_Curve::BSpline() const { if (myTypeCurve != GeomAbs_BSplineCurve) + { throw Standard_NoSuchObject("GeomAdaptor_Curve::BSpline"); + } return std::get(myCurveData).Curve; } @@ -1218,6 +1288,8 @@ occ::handle GeomAdaptor_Curve::BSpline() const occ::handle GeomAdaptor_Curve::OffsetCurve() const { if (myTypeCurve != GeomAbs_OffsetCurve) + { throw Standard_NoSuchObject("GeomAdaptor_Curve::OffsetCurve"); + } return occ::down_cast(myCurve); } diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx index 5159a653b5..3918f559fd 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx @@ -123,12 +123,18 @@ GeomAbs_Shape LocalContinuity(int Degree, BSplCLib::LocateParameter(Degree, TK, TM, PLast, IsPeriodic, 1, Nb, Index2, newLast); constexpr double EpsKnot = Precision::PConfusion(); if (std::abs(newFirst - TK(Index1 + 1)) < EpsKnot) + { Index1++; + } if (std::abs(newLast - TK(Index2)) < EpsKnot) + { Index2--; + } // Handle periodic curves. if ((IsPeriodic) && (Index1 == Nb)) + { Index1 = 1; + } if (Index2 != Index1) { @@ -136,11 +142,15 @@ GeomAbs_Shape LocalContinuity(int Degree, for (i = Index1 + 1; i <= Index2; i++) { if (TM(i) > Multmax) + { Multmax = TM(i); + } } Multmax = Degree - Multmax; if (Multmax <= 0) + { return GeomAbs_C0; + } switch (Multmax) { case 1: @@ -514,7 +524,9 @@ void GeomAdaptor_Surface::load(const occ::handle& S, mySurfaceData = std::move(anOffsetData); } else + { mySurfaceType = GeomAbs_OtherSurface; + } } } @@ -644,7 +656,9 @@ int GeomAdaptor_Surface::NbUIntervals(const GeomAbs_Shape S) const occ::down_cast(mySurface); GeomAdaptor_Curve myBasisCurve(myExtSurf->BasisCurve(), myUFirst, myULast); if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) + { return myBasisCurve.NbIntervals(S); + } break; } case GeomAbs_OffsetSurface: { @@ -700,7 +714,9 @@ int GeomAdaptor_Surface::NbVIntervals(const GeomAbs_Shape S) const occ::down_cast(mySurface); GeomAdaptor_Curve myBasisCurve(myRevSurf->BasisCurve(), myVFirst, myVLast); if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) + { return myBasisCurve.NbIntervals(S); + } break; } case GeomAbs_OffsetSurface: { @@ -890,12 +906,16 @@ occ::handle GeomAdaptor_Surface::VTrim(const double First, bool GeomAdaptor_Surface::IsUClosed() const { if (!mySurface->IsUClosed()) + { return false; + } double U1, U2, V1, V2; mySurface->Bounds(U1, U2, V1, V2); if (mySurface->IsUPeriodic()) + { return (std::abs(std::abs(U1 - U2) - std::abs(myUFirst - myULast)) < Precision::PConfusion()); + } return (std::abs(U1 - myUFirst) < Precision::PConfusion() && std::abs(U2 - myULast) < Precision::PConfusion()); @@ -906,12 +926,16 @@ bool GeomAdaptor_Surface::IsUClosed() const bool GeomAdaptor_Surface::IsVClosed() const { if (!mySurface->IsVClosed()) + { return false; + } double U1, U2, V1, V2; mySurface->Bounds(U1, U2, V1, V2); if (mySurface->IsVPeriodic()) + { return (std::abs(std::abs(V1 - V2) - std::abs(myVFirst - myVLast)) < Precision::PConfusion()); + } return (std::abs(V1 - myVFirst) < Precision::PConfusion() && std::abs(V2 - myVLast) < Precision::PConfusion()); @@ -961,6 +985,7 @@ void GeomAdaptor_Surface::RebuildCache(const double theU, const double theV) con NCollection_Array1 aFlatKnotsU(BSplCLib::FlatBezierKnots(aDegU), 1, 2 * (aDegU + 1)); NCollection_Array1 aFlatKnotsV(BSplCLib::FlatBezierKnots(aDegV), 1, 2 * (aDegV + 1)); if (aBezData.Cache.IsNull()) + { aBezData.Cache = new BSplSLib_Cache(aDegU, aBezier->IsUPeriodic(), aFlatKnotsU, @@ -968,6 +993,7 @@ void GeomAdaptor_Surface::RebuildCache(const double theU, const double theV) con aBezier->IsVPeriodic(), aFlatKnotsV, aBezier->Weights()); + } aBezData.Cache ->BuildCache(theU, theV, aFlatKnotsU, aFlatKnotsV, aBezier->Poles(), aBezier->Weights()); } @@ -977,6 +1003,7 @@ void GeomAdaptor_Surface::RebuildCache(const double theU, const double theV) con auto& aBSplData = std::get(mySurfaceData); const auto& aBSpl = aBSplData.Surface; if (aBSplData.Cache.IsNull()) + { aBSplData.Cache = new BSplSLib_Cache(aBSpl->UDegree(), aBSpl->IsUPeriodic(), aBSpl->UKnotSequence(), @@ -984,6 +1011,7 @@ void GeomAdaptor_Surface::RebuildCache(const double theU, const double theV) con aBSpl->IsVPeriodic(), aBSpl->VKnotSequence(), aBSpl->Weights()); + } aBSplData.Cache->BuildCache(theU, theV, aBSpl->UKnotSequence(), @@ -1025,7 +1053,9 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(const double theU, const double theV) const } auto& aCache = std::get(mySurfaceData).Cache; if (aCache.IsNull()) + { RebuildCache(U, V); + } aCache->D0(U, V, P); return P; } @@ -1036,7 +1066,9 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(const double theU, const double theV) const } auto& aCache = std::get(mySurfaceData).Cache; if (aCache.IsNull() || !aCache->IsCacheValid(U, V)) + { RebuildCache(U, V); + } aCache->D0(U, V, P); return P; } @@ -1048,7 +1080,9 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(const double theU, const double theV) const } const auto& anExtData = std::get(mySurfaceData); if (!Geom_ExtrusionUtils::D0(U, V, *anExtData.BasisCurve, anExtData.Direction, P)) + { throw Geom_UndefinedValue("GeomAdaptor_Surface::EvalD0: evaluation failed"); + } return P; } @@ -1059,7 +1093,9 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(const double theU, const double theV) const } const auto& aRevData = std::get(mySurfaceData); if (!Geom_RevolutionUtils::D0(U, V, *aRevData.BasisCurve, aRevData.Axis, P)) + { throw Geom_UndefinedValue("GeomAdaptor_Surface::EvalD0: evaluation failed"); + } return P; } @@ -1070,7 +1106,9 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(const double theU, const double theV) const } const auto& anOffData = std::get(mySurfaceData); if (!offsetD0(U, V, anOffData, P)) + { throw Geom_UndefinedValue("GeomAdaptor_Surface::EvalD0: evaluation failed"); + } return P; } @@ -1139,7 +1177,9 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(const double theU, const double } auto& aCache = std::get(mySurfaceData).Cache; if (aCache.IsNull()) + { RebuildCache(U, V); + } aCache->D1(U, V, aResult.Point, aResult.D1U, aResult.D1V); return aResult; } @@ -1151,11 +1191,15 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(const double theU, const double auto& aBSplData = std::get(mySurfaceData); const auto& aBSpl = aBSplData.Surface; if ((USide != 0 || VSide != 0) && IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + { aBSpl->LocalD1(u, v, Ideb, Ifin, IVdeb, IVfin, aResult.Point, aResult.D1U, aResult.D1V); + } else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U, V)) + { RebuildCache(U, V); + } aBSplData.Cache->D1(U, V, aResult.Point, aResult.D1U, aResult.D1V); } return aResult; @@ -1174,7 +1218,9 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(const double theU, const double aResult.Point, aResult.D1U, aResult.D1V)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD1: evaluation failed"); + } return aResult; } @@ -1191,7 +1237,9 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(const double theU, const double aResult.Point, aResult.D1U, aResult.D1V)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD1: evaluation failed"); + } return aResult; } @@ -1202,7 +1250,9 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(const double theU, const double } const auto& anOffData = std::get(mySurfaceData); if (!offsetD1(u, v, anOffData, aResult.Point, aResult.D1U, aResult.D1V)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD1: evaluation failed"); + } return aResult; } @@ -1301,7 +1351,9 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double } auto& aCache = std::get(mySurfaceData).Cache; if (aCache.IsNull()) + { RebuildCache(U, V); + } aCache ->D2(U, V, aResult.Point, aResult.D1U, aResult.D1V, aResult.D2U, aResult.D2V, aResult.D2UV); return aResult; @@ -1314,6 +1366,7 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double auto& aBSplData = std::get(mySurfaceData); const auto& aBSpl = aBSplData.Surface; if ((USide != 0 || VSide != 0) && IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + { aBSpl->LocalD2(u, v, Ideb, @@ -1326,10 +1379,13 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double aResult.D2U, aResult.D2V, aResult.D2UV); + } else { if (aBSplData.Cache.IsNull() || !aBSplData.Cache->IsCacheValid(U, V)) + { RebuildCache(U, V); + } aBSplData.Cache->D2(U, V, aResult.Point, @@ -1358,7 +1414,9 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double aResult.D2U, aResult.D2V, aResult.D2UV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD2: evaluation failed"); + } return aResult; } @@ -1378,7 +1436,9 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double aResult.D2U, aResult.D2V, aResult.D2UV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD2: evaluation failed"); + } return aResult; } @@ -1397,7 +1457,9 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(const double theU, const double aResult.D2U, aResult.D2V, aResult.D2UV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD2: evaluation failed"); + } return aResult; } @@ -1522,6 +1584,7 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(const double theU, const double else { if (IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + { aBSpl->LocalD3(u, v, Ideb, @@ -1538,6 +1601,7 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(const double theU, const double aResult.D3V, aResult.D3UUV, aResult.D3UVV); + } else { return aBSpl->EvalD3(u, v); @@ -1566,7 +1630,9 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(const double theU, const double aResult.D3V, aResult.D3UUV, aResult.D3UVV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD3: evaluation failed"); + } return aResult; } @@ -1590,7 +1656,9 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(const double theU, const double aResult.D3V, aResult.D3UUV, aResult.D3UVV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD3: evaluation failed"); + } return aResult; } @@ -1613,7 +1681,9 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(const double theU, const double aResult.D3V, aResult.D3UUV, aResult.D3UVV)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalD3: evaluation failed"); + } return aResult; } @@ -1665,13 +1735,19 @@ gp_Vec GeomAdaptor_Surface::EvalDN(const double theU, } const auto& aBSpl = std::get(mySurfaceData).Surface; if ((USide == 0) && (VSide == 0)) + { return aBSpl->EvalDN(u, v, Nu, Nv); + } else { if (IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + { return aBSpl->LocalDN(u, v, Ideb, Ifin, IVdeb, IVfin, Nu, Nv); + } else + { return aBSpl->EvalDN(u, v, Nu, Nv); + } } } @@ -1683,7 +1759,9 @@ gp_Vec GeomAdaptor_Surface::EvalDN(const double theU, const auto& anExtData = std::get(mySurfaceData); gp_Vec aDN; if (!Geom_ExtrusionUtils::DN(u, *anExtData.BasisCurve, anExtData.Direction, Nu, Nv, aDN)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalDN: evaluation failed"); + } return aDN; } @@ -1695,7 +1773,9 @@ gp_Vec GeomAdaptor_Surface::EvalDN(const double theU, const auto& aRevData = std::get(mySurfaceData); gp_Vec aDN; if (!Geom_RevolutionUtils::DN(u, v, *aRevData.BasisCurve, aRevData.Axis, Nu, Nv, aDN)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalDN: evaluation failed"); + } return aDN; } @@ -1707,7 +1787,9 @@ gp_Vec GeomAdaptor_Surface::EvalDN(const double theU, const auto& anOffData = std::get(mySurfaceData); gp_Vec aDN; if (!offsetDN(u, v, anOffData, Nu, Nv, aDN)) + { throw Geom_UndefinedDerivative("GeomAdaptor_Surface::EvalDN: evaluation failed"); + } return aDN; } @@ -1747,21 +1829,27 @@ double GeomAdaptor_Surface::UResolution(const double R3d) const occ::handle S(occ::down_cast(mySurface)); const double R = S->MajorRadius() + S->MinorRadius(); if (R > Precision::Confusion()) + { Res = R3d / (2. * R); + } break; } case GeomAbs_Sphere: { occ::handle S(occ::down_cast(mySurface)); const double R = S->Radius(); if (R > Precision::Confusion()) + { Res = R3d / (2. * R); + } break; } case GeomAbs_Cylinder: { occ::handle S(occ::down_cast(mySurface)); const double R = S->Radius(); if (R > Precision::Confusion()) + { Res = R3d / (2. * R); + } break; } case GeomAbs_Cone: { @@ -1800,7 +1888,9 @@ double GeomAdaptor_Surface::UResolution(const double R3d) const } if (Res <= 1.) + { return 2. * std::asin(Res); + } return 2. * M_PI; } @@ -1821,14 +1911,18 @@ double GeomAdaptor_Surface::VResolution(const double R3d) const occ::handle S(occ::down_cast(mySurface)); const double R = S->MinorRadius(); if (R > Precision::Confusion()) + { Res = R3d / (2. * R); + } break; } case GeomAbs_Sphere: { occ::handle S(occ::down_cast(mySurface)); const double R = S->Radius(); if (R > Precision::Confusion()) + { Res = R3d / (2. * R); + } break; } case GeomAbs_SurfaceOfExtrusion: @@ -1856,7 +1950,9 @@ double GeomAdaptor_Surface::VResolution(const double R3d) const } if (Res <= 1.) + { return 2. * std::asin(Res); + } return 2. * M_PI; } @@ -1866,7 +1962,9 @@ double GeomAdaptor_Surface::VResolution(const double R3d) const gp_Pln GeomAdaptor_Surface::Plane() const { if (mySurfaceType != GeomAbs_Plane) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Plane"); + } return std::get(mySurfaceData); } @@ -1875,7 +1973,9 @@ gp_Pln GeomAdaptor_Surface::Plane() const gp_Cylinder GeomAdaptor_Surface::Cylinder() const { if (mySurfaceType != GeomAbs_Cylinder) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Cylinder"); + } return std::get(mySurfaceData); } @@ -1884,7 +1984,9 @@ gp_Cylinder GeomAdaptor_Surface::Cylinder() const gp_Cone GeomAdaptor_Surface::Cone() const { if (mySurfaceType != GeomAbs_Cone) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Cone"); + } return std::get(mySurfaceData); } @@ -1893,7 +1995,9 @@ gp_Cone GeomAdaptor_Surface::Cone() const gp_Sphere GeomAdaptor_Surface::Sphere() const { if (mySurfaceType != GeomAbs_Sphere) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Sphere"); + } return std::get(mySurfaceData); } @@ -1902,7 +2006,9 @@ gp_Sphere GeomAdaptor_Surface::Sphere() const gp_Torus GeomAdaptor_Surface::Torus() const { if (mySurfaceType != GeomAbs_Torus) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Torus"); + } return std::get(mySurfaceData); } @@ -1911,9 +2017,13 @@ gp_Torus GeomAdaptor_Surface::Torus() const int GeomAdaptor_Surface::UDegree() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->UDegree(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->UDegree(); + } if (mySurfaceType == GeomAbs_SurfaceOfExtrusion) { return std::get(mySurfaceData).BasisCurve->Degree(); @@ -1926,9 +2036,13 @@ int GeomAdaptor_Surface::UDegree() const int GeomAdaptor_Surface::NbUPoles() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->NbUPoles(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->NbUPoles(); + } if (mySurfaceType == GeomAbs_SurfaceOfExtrusion) { return std::get(mySurfaceData).BasisCurve->NbPoles(); @@ -1941,9 +2055,13 @@ int GeomAdaptor_Surface::NbUPoles() const int GeomAdaptor_Surface::VDegree() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->VDegree(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->VDegree(); + } if (mySurfaceType == GeomAbs_SurfaceOfRevolution) { return std::get(mySurfaceData).BasisCurve->Degree(); @@ -1956,9 +2074,13 @@ int GeomAdaptor_Surface::VDegree() const int GeomAdaptor_Surface::NbVPoles() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->NbVPoles(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->NbVPoles(); + } if (mySurfaceType == GeomAbs_SurfaceOfRevolution) { return std::get(mySurfaceData).BasisCurve->NbPoles(); @@ -1971,7 +2093,9 @@ int GeomAdaptor_Surface::NbVPoles() const int GeomAdaptor_Surface::NbUKnots() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->NbUKnots(); + } if (mySurfaceType == GeomAbs_SurfaceOfExtrusion) { return std::get(mySurfaceData).BasisCurve->NbKnots(); @@ -1984,7 +2108,9 @@ int GeomAdaptor_Surface::NbUKnots() const int GeomAdaptor_Surface::NbVKnots() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->NbVKnots(); + } throw Standard_NoSuchObject("GeomAdaptor_Surface::NbVKnots"); } @@ -1993,9 +2119,13 @@ int GeomAdaptor_Surface::NbVKnots() const bool GeomAdaptor_Surface::IsURational() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->IsURational(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->IsURational(); + } return false; } @@ -2004,9 +2134,13 @@ bool GeomAdaptor_Surface::IsURational() const bool GeomAdaptor_Surface::IsVRational() const { if (mySurfaceType == GeomAbs_BSplineSurface) + { return std::get(mySurfaceData).Surface->IsVRational(); + } if (mySurfaceType == GeomAbs_BezierSurface) + { return occ::down_cast(mySurface)->IsVRational(); + } return false; } @@ -2015,7 +2149,9 @@ bool GeomAdaptor_Surface::IsVRational() const occ::handle GeomAdaptor_Surface::Bezier() const { if (mySurfaceType != GeomAbs_BezierSurface) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Bezier"); + } return occ::down_cast(mySurface); } @@ -2024,7 +2160,9 @@ occ::handle GeomAdaptor_Surface::Bezier() const occ::handle GeomAdaptor_Surface::BSpline() const { if (mySurfaceType != GeomAbs_BSplineSurface) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::BSpline"); + } return std::get(mySurfaceData).Surface; } @@ -2033,7 +2171,9 @@ occ::handle GeomAdaptor_Surface::BSpline() const gp_Ax1 GeomAdaptor_Surface::AxeOfRevolution() const { if (mySurfaceType != GeomAbs_SurfaceOfRevolution) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::AxeOfRevolution"); + } return occ::down_cast(mySurface)->Axis(); } @@ -2042,7 +2182,9 @@ gp_Ax1 GeomAdaptor_Surface::AxeOfRevolution() const gp_Dir GeomAdaptor_Surface::Direction() const { if (mySurfaceType != GeomAbs_SurfaceOfExtrusion) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::Direction"); + } return occ::down_cast(mySurface)->Direction(); } @@ -2052,11 +2194,17 @@ occ::handle GeomAdaptor_Surface::BasisCurve() const { occ::handle C; if (mySurfaceType == GeomAbs_SurfaceOfExtrusion) + { C = occ::down_cast(mySurface)->BasisCurve(); + } else if (mySurfaceType == GeomAbs_SurfaceOfRevolution) + { C = occ::down_cast(mySurface)->BasisCurve(); + } else + { throw Standard_NoSuchObject("GeomAdaptor_Surface::BasisCurve"); + } return occ::handle(new GeomAdaptor_Curve(C)); } @@ -2065,7 +2213,9 @@ occ::handle GeomAdaptor_Surface::BasisCurve() const occ::handle GeomAdaptor_Surface::BasisSurface() const { if (mySurfaceType != GeomAbs_OffsetSurface) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::BasisSurface"); + } return new GeomAdaptor_Surface(occ::down_cast(mySurface)->BasisSurface(), myUFirst, myULast, @@ -2078,7 +2228,9 @@ occ::handle GeomAdaptor_Surface::BasisSurface() const double GeomAdaptor_Surface::OffsetValue() const { if (mySurfaceType != GeomAbs_OffsetSurface) + { throw Standard_NoSuchObject("GeomAdaptor_Surface::BasisSurface"); + } return occ::down_cast(mySurface)->Offset(); } @@ -2108,7 +2260,9 @@ bool GeomAdaptor_Surface::IfUVBound(const double U, int IVdeb, IVfin; aBSpl->LocateV(V, PosTol, IVdeb, IVfin, false); if (IVdeb == IVfin) + { Local = true; + } Span(VSide, IVdeb, IVfin, IVdeb, IVfin, aVFKIndx, aVLKIndx); IOutDeb = Ideb; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx index c4ecd73f9a..4de8a5cfc7 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx @@ -91,7 +91,9 @@ void GeomAdaptor_SurfaceOfLinearExtrusion::Load(const occ::handleLine().Direction(); if (!myDirection.IsParallel(D, Precision::Angular())) + { return GeomAbs_Plane; + } break; } case GeomAbs_Circle: { gp_Dir D = (myBasisCurve->Circle()).Axis().Direction(); if (myDirection.IsParallel(D, Precision::Angular())) + { return GeomAbs_Cylinder; + } else if (myDirection.IsNormal(D, Precision::Angular())) + { return GeomAbs_Plane; + } break; } case GeomAbs_Ellipse: { gp_Dir D = (myBasisCurve->Ellipse()).Axis().Direction(); if (myDirection.IsNormal(D, Precision::Angular())) + { return GeomAbs_Plane; + } break; } case GeomAbs_Parabola: { gp_Dir D = (myBasisCurve->Parabola()).Axis().Direction(); if (myDirection.IsNormal(D, Precision::Angular())) + { return GeomAbs_Plane; + } break; } case GeomAbs_Hyperbola: { gp_Dir D = (myBasisCurve->Hyperbola()).Axis().Direction(); if (myDirection.IsNormal(D, Precision::Angular())) + { return GeomAbs_Plane; + } break; } @@ -344,7 +358,9 @@ gp_Pln GeomAdaptor_SurfaceOfLinearExtrusion::Plane() const myBasisCurve->D1(prm, P, D1u); newZ = D1u.Normalized().Crossed(myDirection); if (newZ.Magnitude() > 1.e-12) + { break; + } } gp_Ax3 Ax3(P, gp_Dir(newZ), gp_Dir(D1u)); if (myDirection.Dot(Ax3.YDirection()) < 0.) diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index 2bb1ac52d5..afd613e7e8 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -90,7 +90,9 @@ void GeomAdaptor_SurfaceOfRevolution::Load(const occ::handle& C { myBasisCurve = C; if (myHaveAxis) + { Load(myAxis); // to evaluate the new myAxeRev. + } } //================================================================================================= @@ -134,14 +136,22 @@ void GeomAdaptor_SurfaceOfRevolution::Load(const gp_Ax1& V) if (GetType() == GeomAbs_Cone) { if (gp_Lin(myAxis).Distance(P) <= Precision::Confusion()) + { Q = ElCLib::Value(1., myBasisCurve->Line()); + } else + { Q = P; + } } else if (Precision::IsInfinite(First)) + { Q = P; + } else + { Q = Value(0., First); + } } gp_Dir DZ = myAxis.Direction(); @@ -182,7 +192,9 @@ void GeomAdaptor_SurfaceOfRevolution::Load(const gp_Ax1& V) { gp_Dir DC = (myBasisCurve->Circle()).Axis().Direction(); if ((Ox.Crossed(Oz)).Dot(DC) < 0.) + { myAxeRev.ZReverse(); + } } } @@ -376,7 +388,9 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const } } else if (myAxis.IsNormal(Axe, TolAng)) + { return GeomAbs_Plane; + } else { double uf = myBasisCurve->FirstParameter(); @@ -401,7 +415,9 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const } } else if (projlen <= TolConf) + { return GeomAbs_Plane; + } } gp_Vec V(myAxis.Location(), myBasisCurve->Line().Location()); gp_Vec W(Axe.Direction()); @@ -426,9 +442,13 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const // if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) + { return GeomAbs_SurfaceOfRevolution; + } else if (aLin.Distance(aLC) <= TolConf) + { return GeomAbs_Sphere; + } else { MajorRadius = aLin.Distance(aLC); @@ -461,7 +481,9 @@ gp_Pln GeomAdaptor_SurfaceOfRevolution::Plane() const gp_Pnt P(myAxis.Location().XYZ() + aDot * myAxis.Direction().XYZ()); Axe.SetLocation(P); if (Axe.XDirection().Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) + { Axe.XReverse(); + } return gp_Pln(Axe); } @@ -497,7 +519,9 @@ gp_Cone GeomAdaptor_SurfaceOfRevolution::Cone() const t /= ldir.Dot(Axe.XDirection()); OP0.Add(-t * gp_Vec(ldir)); if (OP0.Dot(Axe.Direction()) > 0.) + { Angle = -Angle; + } } return gp_Cone(Axe, Angle, R); } diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx index 26da21a773..b7587b9622 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx @@ -69,9 +69,13 @@ void GeomAdaptor_TransformedCurve::Intervals(NCollection_Array1& theT, const GeomAbs_Shape theS) const { if (myConSurf.IsNull()) + { myCurve.Intervals(theT, theS); + } else + { myConSurf->Intervals(theT, theS); + } } //================================================================================================== @@ -100,9 +104,13 @@ gp_Lin GeomAdaptor_TransformedCurve::Line() const { gp_Lin aL; if (myConSurf.IsNull()) + { aL = myCurve.Line(); + } else + { aL = myConSurf->Line(); + } aL.Transform(myTrsf); return aL; } @@ -113,9 +121,13 @@ gp_Circ GeomAdaptor_TransformedCurve::Circle() const { gp_Circ aC; if (myConSurf.IsNull()) + { aC = myCurve.Circle(); + } else + { aC = myConSurf->Circle(); + } aC.Transform(myTrsf); return aC; } @@ -126,9 +138,13 @@ gp_Elips GeomAdaptor_TransformedCurve::Ellipse() const { gp_Elips aE; if (myConSurf.IsNull()) + { aE = myCurve.Ellipse(); + } else + { aE = myConSurf->Ellipse(); + } aE.Transform(myTrsf); return aE; } @@ -139,9 +155,13 @@ gp_Hypr GeomAdaptor_TransformedCurve::Hyperbola() const { gp_Hypr aH; if (myConSurf.IsNull()) + { aH = myCurve.Hyperbola(); + } else + { aH = myConSurf->Hyperbola(); + } aH.Transform(myTrsf); return aH; } @@ -152,9 +172,13 @@ gp_Parab GeomAdaptor_TransformedCurve::Parabola() const { gp_Parab aP; if (myConSurf.IsNull()) + { aP = myCurve.Parabola(); + } else + { aP = myConSurf->Parabola(); + } aP.Transform(myTrsf); return aP; } @@ -165,9 +189,13 @@ occ::handle GeomAdaptor_TransformedCurve::Bezier() const { occ::handle aBC; if (myConSurf.IsNull()) + { aBC = myCurve.Bezier(); + } else + { aBC = myConSurf->Bezier(); + } return myTrsf.Form() == gp_Identity ? aBC : occ::down_cast(aBC->Transformed(myTrsf)); } @@ -178,9 +206,13 @@ occ::handle GeomAdaptor_TransformedCurve::BSpline() const { occ::handle aBS; if (myConSurf.IsNull()) + { aBS = myCurve.BSpline(); + } else + { aBS = myConSurf->BSpline(); + } return myTrsf.Form() == gp_Identity ? aBS : occ::down_cast(aBS->Transformed(myTrsf)); } @@ -190,7 +222,9 @@ occ::handle GeomAdaptor_TransformedCurve::BSpline() const occ::handle GeomAdaptor_TransformedCurve::OffsetCurve() const { if (!Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve) + { throw Standard_NoSuchObject("GeomAdaptor_TransformedCurve::OffsetCurve"); + } occ::handle anOffC = myCurve.OffsetCurve(); return myTrsf.Form() == gp_Identity @@ -204,9 +238,13 @@ gp_Pnt GeomAdaptor_TransformedCurve::EvalD0(const double theU) const { gp_Pnt aP; if (myConSurf.IsNull()) + { aP = myCurve.EvalD0(theU); + } else + { myConSurf->D0(theU, aP); + } aP.Transform(myTrsf); return aP; } @@ -217,9 +255,13 @@ Geom_Curve::ResD1 GeomAdaptor_TransformedCurve::EvalD1(const double theU) const { Geom_Curve::ResD1 aRes; if (myConSurf.IsNull()) + { aRes = myCurve.EvalD1(theU); + } else + { myConSurf->D1(theU, aRes.Point, aRes.D1); + } aRes.Point.Transform(myTrsf); aRes.D1.Transform(myTrsf); return aRes; @@ -231,9 +273,13 @@ Geom_Curve::ResD2 GeomAdaptor_TransformedCurve::EvalD2(const double theU) const { Geom_Curve::ResD2 aRes; if (myConSurf.IsNull()) + { aRes = myCurve.EvalD2(theU); + } else + { myConSurf->D2(theU, aRes.Point, aRes.D1, aRes.D2); + } aRes.Point.Transform(myTrsf); aRes.D1.Transform(myTrsf); aRes.D2.Transform(myTrsf); @@ -246,9 +292,13 @@ Geom_Curve::ResD3 GeomAdaptor_TransformedCurve::EvalD3(const double theU) const { Geom_Curve::ResD3 aRes; if (myConSurf.IsNull()) + { aRes = myCurve.EvalD3(theU); + } else + { myConSurf->D3(theU, aRes.Point, aRes.D1, aRes.D2, aRes.D3); + } aRes.Point.Transform(myTrsf); aRes.D1.Transform(myTrsf); aRes.D2.Transform(myTrsf); @@ -262,9 +312,13 @@ gp_Vec GeomAdaptor_TransformedCurve::EvalDN(const double theU, const int theN) c { gp_Vec aV; if (myConSurf.IsNull()) + { aV = myCurve.EvalDN(theU, theN); + } else + { aV = myConSurf->DN(theU, theN); + } aV.Transform(myTrsf); return aV; } diff --git a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineCurve.cxx b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineCurve.cxx index c7b7488bcf..cad02011d2 100644 --- a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineCurve.cxx +++ b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineCurve.cxx @@ -40,7 +40,9 @@ struct CurveData bool extractCurveData(const occ::handle& theGeom, CurveData& theData) { if (theGeom.IsNull()) + { return false; + } theData.FlatKnots = &theGeom->KnotSequence(); theData.Poles = &theGeom->Poles(); @@ -96,7 +98,9 @@ inline int countSpanSize(const NCollection_Array1& theParams, for (int i = theStartIdx + 1; i < aNb; ++i) { if (theParams.Value(aLower + i) >= aNextKnot) + { break; + } ++aCount; } return aCount; @@ -116,9 +120,13 @@ inline int countSpanSize(const NCollection_Array1& theParams, aSpan, aAdjusted); if (aSpan == theTargetSpan) + { ++aCount; + } else + { break; + } } return aCount; } diff --git a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineSurface.cxx b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineSurface.cxx index 3f46041f26..371a14652d 100644 --- a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineSurface.cxx +++ b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_BSplineSurface.cxx @@ -45,7 +45,9 @@ struct SurfaceData bool extractSurfaceData(const occ::handle& theGeom, SurfaceData& theData) { if (theGeom.IsNull()) + { return false; + } theData.UFlatKnots = &theGeom->UKnotSequence(); theData.VFlatKnots = &theGeom->VKnotSequence(); @@ -104,7 +106,9 @@ inline int countSpanSize(const NCollection_Array1& theParams, for (int i = theStartIdx + 1; i < aNb; ++i) { if (theParams.Value(aLower + i) >= aNextKnot) + { break; + } ++aCount; } return aCount; @@ -124,9 +128,13 @@ inline int countSpanSize(const NCollection_Array1& theParams, aSpan, aAdjusted); if (aSpan == theTargetSpan) + { ++aCount; + } else + { break; + } } return aCount; } diff --git a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_OffsetCurve.cxx b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_OffsetCurve.cxx index a2e506e6b8..8fa3aae851 100644 --- a/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_OffsetCurve.cxx +++ b/src/ModelingData/TKG3d/GeomGridEval/GeomGridEval_OffsetCurve.cxx @@ -46,7 +46,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid( const GeomGridEval::CurveD1& aBasis = aBasisD1.Value(i); gp_Pnt aP = aBasis.Point; if (!Geom_OffsetCurveUtils::CalculateD0(aP, aBasis.D1, aDirXYZ, myOffset)) + { return NCollection_Array1(); + } aResult.SetValue(i, aP); } @@ -84,7 +86,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid gp_Pnt aP = aBasis.Point; gp_Vec aD1 = aBasis.D1; if (!Geom_OffsetCurveUtils::CalculateD1(aP, aD1, aBasis.D2, aDirXYZ, myOffset)) + { return NCollection_Array1(); + } aResult.ChangeValue(i) = {aP, aD1}; } @@ -137,7 +141,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid aD3, aDummyD4, isDirectionChange)) + { return NCollection_Array1(); + } } if (!Geom_OffsetCurveUtils::CalculateD2(aP, @@ -147,7 +153,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid aDirXYZ, myOffset, isDirectionChange)) + { return NCollection_Array1(); + } aResult.ChangeValue(i) = {aP, aD1, aD2}; } @@ -202,7 +210,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid aD3, aD4, isDirectionChange)) + { return NCollection_Array1(); + } } if (!Geom_OffsetCurveUtils::CalculateD3(aP, @@ -213,7 +223,9 @@ NCollection_Array1 GeomGridEval_OffsetCurve::EvaluateGrid aDirXYZ, myOffset, isDirectionChange)) + { return NCollection_Array1(); + } aResult.ChangeValue(i) = {aP, aD1, aD2, aD3}; } diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx index 2806f8e552..b2746b3580 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx @@ -207,9 +207,13 @@ void AdvApp2Var_ApproxAFunc2Var::Init() ndu = std::max(myMaxDegInU + 1, 2 * iu + 2); ndv = std::max(myMaxDegInV + 1, 2 * iv + 2); if (ndu < 2 * iu + 2) + { throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : UMaxDegree Error"); + } if (ndv < 2 * iv + 2) + { throw Standard_ConstructionError("AdvApp2Var_ApproxAFunc2Var : VMaxDegree Error"); + } myPrecisionCode = std::max(0, std::min(myPrecisionCode, 3)); AdvApp2Var_Context Conditions(ifav, iu, @@ -386,26 +390,42 @@ void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& NumDec = 0; if (((NbPatch + NbV) <= myMaxPatches) && ((NbPatch + NbU) > myMaxPatches) && (Umore)) + { NumDec = 1; + } if (((NbPatch + NbV) > myMaxPatches) && ((NbPatch + NbU) <= myMaxPatches) && (Vmore)) + { NumDec = 2; + } if (((NbPatch + NbV) <= myMaxPatches) && ((NbPatch + NbU) <= myMaxPatches)) { if (Umore) + { NumDec = 3; + } if ((NbV > NbU) && Vmore) + { NumDec = 4; + } } if ((NbU + 1) * (NbV + 1) <= myMaxPatches) { if (!Umore && !Vmore) + { NumDec = 0; + } if (Umore && !Vmore) + { NumDec = 3; + } if (!Umore && Vmore) + { NumDec = 4; + } if (Umore && Vmore) + { NumDec = 5; + } } // approximation of the square @@ -495,26 +515,42 @@ void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& NumDec = 0; if (((NbPatch + NbV) <= myMaxPatches) && ((NbPatch + NbU) > myMaxPatches) && (Umore)) + { NumDec = 1; + } if (((NbPatch + NbV) > myMaxPatches) && ((NbPatch + NbU) <= myMaxPatches) && (Vmore)) + { NumDec = 2; + } if (((NbPatch + NbV) <= myMaxPatches) && ((NbPatch + NbU) <= myMaxPatches)) { if (Umore) + { NumDec = 3; + } if ((NbV > NbU) && Vmore) + { NumDec = 4; + } } if ((NbU + 1) * (NbV + 1) <= myMaxPatches) { if (!Umore && !Vmore) + { NumDec = 0; + } if (Umore && !Vmore) + { NumDec = 1; + } if (!Umore && Vmore) + { NumDec = 2; + } if (Umore && Vmore) + { NumDec = 5; + } } // approximation of the square @@ -527,7 +563,9 @@ void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& myResult(FirstNA).MakeApprox(myConditions, myConstraints, NumDec); } if (NumDec >= 3) + { NumDec = NumDec - 2; + } // evaluation of the criterion on the square if (myResult(FirstNA).HasResult()) @@ -535,7 +573,9 @@ void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& Crit.Value(myResult(FirstNA), myConditions); CritValue = myResult(FirstNA).CritValue(); if (m1 < CritValue) + { m1 = CritValue; + } } // is it necessary to cut ? decision = myResult(FirstNA).CutSense(Crit, NumDec); @@ -1117,54 +1157,51 @@ double AdvApp2Var_ApproxAFunc2Var::CritError(const int Dimension, const int SSPI void AdvApp2Var_ApproxAFunc2Var::Dump(Standard_OStream& o) const { int iesp = 1, NbKU, NbKV, ik; - o << std::endl; + o << '\n'; if (!myHasResult) { - o << "No result" << std::endl; + o << "No result" << '\n'; } else { o << "There is a result"; if (myDone) { - o << " within the requested tolerance " << my3DTolerances->Value(iesp) << std::endl; + o << " within the requested tolerance " << my3DTolerances->Value(iesp) << '\n'; } else if (my3DMaxError->Value(iesp) > my3DTolerances->Value(iesp)) { - o << " WITHOUT the requested tolerance " << my3DTolerances->Value(iesp) << std::endl; + o << " WITHOUT the requested tolerance " << my3DTolerances->Value(iesp) << '\n'; } else { - o << " WITHOUT the requested continuities " << std::endl; + o << " WITHOUT the requested continuities " << '\n'; } - o << std::endl; - o << "Result max error :" << my3DMaxError->Value(iesp) << std::endl; - o << "Result average error :" << my3DAverageError->Value(iesp) << std::endl; - o << "Result max error on U frontiers :" << my3DUFrontError->Value(iesp) << std::endl; - o << "Result max error on V frontiers :" << my3DVFrontError->Value(iesp) << std::endl; - o << std::endl; - o << "Degree of Bezier patches in U : " << myDegreeInU << " in V : " << myDegreeInV - << std::endl; - o << std::endl; + o << '\n'; + o << "Result max error :" << my3DMaxError->Value(iesp) << '\n'; + o << "Result average error :" << my3DAverageError->Value(iesp) << '\n'; + o << "Result max error on U frontiers :" << my3DUFrontError->Value(iesp) << '\n'; + o << "Result max error on V frontiers :" << my3DVFrontError->Value(iesp) << '\n'; + o << '\n'; + o << "Degree of Bezier patches in U : " << myDegreeInU << " in V : " << myDegreeInV << '\n'; + o << '\n'; occ::handle S = occ::down_cast(mySurfaces->Value(iesp)); - o << "Number of poles in U : " << S->NbUPoles() << " in V : " << S->NbVPoles() << std::endl; - o << std::endl; + o << "Number of poles in U : " << S->NbUPoles() << " in V : " << S->NbVPoles() << '\n'; + o << '\n'; NbKU = S->NbUKnots(); NbKV = S->NbVKnots(); - o << "Number of knots in U : " << NbKU << std::endl; + o << "Number of knots in U : " << NbKU << '\n'; for (ik = 1; ik <= NbKU; ik++) { - o << " " << ik << " : " << S->UKnot(ik) << " mult : " << S->UMultiplicity(ik) - << std::endl; + o << " " << ik << " : " << S->UKnot(ik) << " mult : " << S->UMultiplicity(ik) << '\n'; } - o << std::endl; - o << "Number of knots in V : " << NbKV << std::endl; + o << '\n'; + o << "Number of knots in V : " << NbKV << '\n'; for (ik = 1; ik <= NbKV; ik++) { - o << " " << ik << " : " << S->VKnot(ik) << " mult : " << S->VMultiplicity(ik) - << std::endl; + o << " " << ik << " : " << S->VKnot(ik) << " mult : " << S->VMultiplicity(ik) << '\n'; } - o << std::endl; + o << '\n'; } } diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Context.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Context.cxx index 77cc2fe781..08dc366c58 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Context.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Context.cxx @@ -24,7 +24,9 @@ static bool lesparam(const int iordre, const int ncflim, const int icodeo, int& // jacobi degree ndgjac = ncflim; // it always keeps a reserve coefficient if (icodeo < 0) + { return false; + } if (icodeo > 0) { ndgjac += (9 - (iordre + 1)); // iordre rescales the frequences upwards @@ -170,7 +172,9 @@ AdvApp2Var_Context::AdvApp2Var_Context(const int // myNbURoot,myJDegU aCoeffLimit = nlimu; if (aCoeffLimit < 2 * iu + 2) + { aCoeffLimit = 2 * iu + 2; + } if (!lesparam(iu, aCoeffLimit, iprecis, NbPntU, JDegU)) { throw Standard_ConstructionError("AdvApp2Var_Context"); @@ -178,7 +182,9 @@ AdvApp2Var_Context::AdvApp2Var_Context(const int myNbURoot = NbPntU; myJDegU = JDegU; if (iu > -1) + { NbPntU = myNbURoot - 2; + } // myJMaxU int aSize = JDegU - 2 * iu - 1; @@ -190,7 +196,9 @@ AdvApp2Var_Context::AdvApp2Var_Context(const int // myNbVRoot,myJDegV aCoeffLimit = nlimv; if (aCoeffLimit < 2 * iv + 2) + { aCoeffLimit = 2 * iv + 2; + } if (!lesparam(iv, aCoeffLimit, iprecis, NbPntV, JDegV)) { throw Standard_ConstructionError("AdvApp2Var_Context"); @@ -198,7 +206,9 @@ AdvApp2Var_Context::AdvApp2Var_Context(const int myNbVRoot = NbPntV; myJDegV = JDegV; if (iv > -1) + { NbPntV = myNbVRoot - 2; + } // myJMaxV aSize = JDegV - 2 * iv - 1; @@ -268,7 +278,9 @@ AdvApp2Var_Context::AdvApp2Var_Context(const int { aTolMin = ITol->Value(anSSPIndex) / aWeight; if (aTolMin < FTol->Value(anSSPIndex, aTolIndex)) + { FTol->SetValue(anSSPIndex, aTolIndex, aTolMin); + } CTol->SetValue(anSSPIndex, aTolIndex, aTolMin); } } diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Iso.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Iso.cxx index b3dff381b6..ca68b853f4 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Iso.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Iso.cxx @@ -147,7 +147,9 @@ void AdvApp2Var_Iso::MakeApprox(const AdvApp2Var_Context& Conditions, UVFONC[1] = myU1; NBROOT = (Conditions.URoots())->Length(); if (myExtremOrder > -1) + { NBROOT -= 2; + } ROOTLG = (double*)&HUROOT->ChangeArray1()(HUROOT->Lower()); NDGJAC = Conditions.UJacDeg(); NCFLIM = Conditions.ULimit(); @@ -160,7 +162,9 @@ void AdvApp2Var_Iso::MakeApprox(const AdvApp2Var_Context& Conditions, UVFONC[3] = myV1; NBROOT = (Conditions.VRoots())->Length(); if (myExtremOrder > -1) + { NBROOT -= 2; + } ROOTLG = (double*)&HVROOT->ChangeArray1()(HVROOT->Lower()); NDGJAC = Conditions.VJacDeg(); NCFLIM = Conditions.VLimit(); @@ -291,9 +295,13 @@ void AdvApp2Var_Iso::MakeApprox(const AdvApp2Var_Context& Conditions, goto FINISH; } if (NCOEFF <= ncfapp) + { NCOEFF = ncfapp; + } if (ierapp == -1) + { IERCOD = -1; + } // return constraints of order 0 to IORDRE of extremities int ider, jpos = HCONTR1->Lower(); for (ider = 0; ider <= IORDRE; ider++) @@ -420,7 +428,9 @@ void AdvApp2Var_Iso::ResetApprox() void AdvApp2Var_Iso::OverwriteApprox() { if (myHasResult) + { myApprIsDone = true; + } } //================================================================================================= @@ -498,9 +508,13 @@ double AdvApp2Var_Iso::V1() const int AdvApp2Var_Iso::UOrder() const { if (Type() == GeomAbs_IsoU) + { return myDerivOrder; + } else + { return myExtremOrder; + } } //================================================================================================= @@ -508,9 +522,13 @@ int AdvApp2Var_Iso::UOrder() const int AdvApp2Var_Iso::VOrder() const { if (Type() == GeomAbs_IsoV) + { return myDerivOrder; + } else + { return myExtremOrder; + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_MathBase.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_MathBase.cxx index 44b4b8871b..8c74f5b009 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_MathBase.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_MathBase.cxx @@ -9523,7 +9523,6 @@ void AdvApp2Var_MathBase::mmwprcs_(double* epsil1, mmprcsn_.eps4 = *epsil4; mmprcsn_.niterm = *niter1; mmprcsn_.niterr = *niter2; - return; } /* mmwprcs_ */ //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Patch.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Patch.cxx index 8f69c4c91d..0d42671591 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Patch.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_Patch.cxx @@ -113,12 +113,16 @@ void AdvApp2Var_Patch::Discretise(const AdvApp2Var_Context& Conditions UROOT = (double*)&HUROOT->ChangeArray1()(HUROOT->Lower()); NBPNTU = (Conditions.URoots())->Length(); if (myOrdInU > -1) + { NBPNTU -= 2; + } double* VROOT; VROOT = (double*)&HVROOT->ChangeArray1()(HVROOT->Lower()); NBPNTV = (Conditions.VRoots())->Length(); if (myOrdInV > -1) + { NBPNTV -= 2; + } // data stored in the Framework Constraints cad Nodes and Isos // C1, C2, C3 and C4 are dimensionnes in FORTRAN with (NDIMEN,IORDRU+2,IORDRV+2) @@ -771,10 +775,14 @@ void AdvApp2Var_Patch::MakeApprox(const AdvApp2Var_Context& Conditions, NDIMSE = 3; NBPNTU = (Conditions.URoots())->Length(); if (myOrdInU > -1) + { NBPNTU -= 2; + } NBPNTV = (Conditions.VRoots())->Length(); if (myOrdInV > -1) + { NBPNTV -= 2; + } NCFLMU = Conditions.ULimit(); NCFLMV = Conditions.VLimit(); NDegU = NCFLMU - 1; @@ -978,7 +986,9 @@ void AdvApp2Var_Patch::ResetApprox() void AdvApp2Var_Patch::OverwriteApprox() { if (myHasResult) + { myApprIsDone = true; + } } //================================================================================================= @@ -1071,9 +1081,13 @@ int AdvApp2Var_Patch::NbCoeffInV() const void AdvApp2Var_Patch::ChangeNbCoeff(const int NbCoeffU, const int NbCoeffV) { if (myNbCoeffInU < NbCoeffU) + { myNbCoeffInU = NbCoeffU; + } if (myNbCoeffInV < NbCoeffV) + { myNbCoeffInV = NbCoeffV; + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_SysBase.cxx b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_SysBase.cxx index f6f7835b12..affe032101 100644 --- a/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_SysBase.cxx +++ b/src/ModelingData/TKGeomBase/AdvApp2Var/AdvApp2Var_SysBase.cxx @@ -2271,12 +2271,16 @@ int AdvApp2Var_SysBase::mcrfill_(int* size, void* tin, void* tout) char* jmin = static_cast(tin); char* jmout = static_cast(tout); if (mcrfill_ABS(jmout - jmin) >= *size) + { memcpy(tout, tin, *size); + } else if (tin > tout) { int n = *size; while (n-- > 0) + { *jmout++ = *jmin++; + } } else { @@ -2284,7 +2288,9 @@ int AdvApp2Var_SysBase::mcrfill_(int* size, void* tin, void* tout) jmin += n; jmout += n; while (n-- > 0) + { *--jmout = *--jmin; + } } return 0; } @@ -2359,7 +2365,9 @@ int mcrgetv_(int* sz, intptr_t* iad, int* ier) *ier = 0; *iad = (intptr_t)Standard::Allocate(*sz); if (!*iad) + { *ier = 1; + } return 0; } diff --git a/src/ModelingData/TKGeomBase/AppCont/AppCont_LeastSquare.cxx b/src/ModelingData/TKGeomBase/AppCont/AppCont_LeastSquare.cxx index 1eada11383..e68cffc898 100644 --- a/src/ModelingData/TKGeomBase/AppCont/AppCont_LeastSquare.cxx +++ b/src/ModelingData/TKGeomBase/AppCont/AppCont_LeastSquare.cxx @@ -69,13 +69,17 @@ void AppCont_LeastSquare::FixSingleBorderPoint(const AppCont_Function& the // from the third iteration if (anIter > 2 && aCurrDist / aPrevDist > 10.0) + { break; + } } aPrevP = aTabP; aPrevP2d = aTabP2d; aPrevDist = aCurrDist; if (aPrevDist <= eps) + { break; + } } theFix2d = aPrevP2d; theFix = aPrevP; @@ -128,14 +132,18 @@ AppCont_LeastSquare::AppCont_LeastSquare(const AppCont_Function& SSP, { Ok = SSP.D1(U0, aTabV2d, aTabV); if (!Ok) + { myFirstC = AppParCurves_PassPoint; + } } if (myLastC == AppParCurves_TangencyPoint) { Ok = SSP.D1(U1, aTabV2d, aTabV); if (!Ok) + { myLastC = AppParCurves_PassPoint; + } } // Compute control points params on which approximation will be built. @@ -270,17 +278,25 @@ AppCont_LeastSquare::AppCont_LeastSquare(const AppCont_Function& SSP, for (k = 1; k <= myNbP; k++) { if (aFixP(k).Distance(aTabP(k)) > 0.1) + { (aFixP(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1), myPoles(1, i2 + 2)); + } else + { (aTabP(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1), myPoles(1, i2 + 2)); + } i2 += 3; } for (k = 1; k <= myNbP2d; k++) { if (aFixP2d(k).Distance(aTabP2d(k)) > 0.1) + { (aFixP2d(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1)); + } else + { (aTabP2d(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1)); + } i2 += 2; } @@ -305,17 +321,25 @@ AppCont_LeastSquare::AppCont_LeastSquare(const AppCont_Function& SSP, for (k = 1; k <= myNbP; k++) { if (aFixP(k).Distance(aTabP(k)) > 0.1) + { (aFixP(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1), myPoles(classe, i2 + 2)); + } else + { (aTabP(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1), myPoles(classe, i2 + 2)); + } i2 += 3; } for (k = 1; k <= myNbP2d; k++) { if (aFixP2d(k).Distance(aTabP2d(k)) > 0.1) + { (aFixP2d(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1)); + } else + { (aTabP2d(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1)); + } i2 += 2; } diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx index 283188c8a4..39461f2bf9 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_LinearCriteria.cxx @@ -191,7 +191,9 @@ occ::handle>>> AppDef_L AssemblyTable() const { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::AssemblyTable"); + } int NbDim = myCurve->Dimension(), NbElm = myCurve->NbElements(), nc1 = order(myCurve->Base()) + 1; int MxDeg = myCurve->Base().WorkDegree(); @@ -231,7 +233,9 @@ occ::handle>>> AppDef_L { GlobIndex = new NCollection_HArray1(0, MxDeg); for (i = 0; i < nc1; i++) + { GlobIndex->SetValue(i, gi0 + i); + } gi0 = MxDeg - 2 * nc1 + 1; for (i = nc1; i < 2 * nc1; i++) @@ -257,7 +261,9 @@ occ::handle>>> AppDef_L Aux = AssTable->Value(1, el); GlobIndex = new NCollection_HArray1(0, MxDeg); for (i = 0; i <= MxDeg; i++) + { GlobIndex->SetValue(i, Aux->Value(i) + NbGlobVar); + } AssTable->SetValue(dim, el, GlobIndex); } NbGlobVar += gi0; @@ -271,14 +277,18 @@ occ::handle>>> AppDef_L occ::handle> AppDef_LinearCriteria::DependenceTable() const { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::DependenceTable"); + } int Dim = myCurve->Dimension(); occ::handle> DepTab = new NCollection_HArray2(1, Dim, 1, Dim, 0); int i; for (i = 1; i <= Dim; i++) + { DepTab->SetValue(i, i, 1); + } return DepTab; } @@ -293,7 +303,9 @@ int AppDef_LinearCriteria::QualityValues(const double J1min, double& J3) { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::QualityValues"); + } int NbDim = myCurve->Dimension(), NbElm = myCurve->NbElements(); @@ -353,9 +365,13 @@ int AppDef_LinearCriteria::QualityValues(const double J1min, if ((ValCri[i] < 0.8 * myEstimation[i]) && (myEstimation[i] > JEsMin[i])) { if (ICDANA < 1) + { ICDANA = 1; + } if (ValCri[i] < 0.1 * myEstimation[i]) + { ICDANA = 2; + } myEstimation[i] = std::max(1.05 * ValCri[i], JEsMin[i]); } } @@ -430,14 +446,18 @@ void AppDef_LinearCriteria::ErrorValues(double& MaxError, double& AverageError) { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::ErrorValues"); + } int NbDim = myCurve->Dimension(); int myNbP2d = AppDef_MyLineTool::NbP2d(mySSP), myNbP3d = AppDef_MyLineTool::NbP3d(mySSP); if (NbDim != (2 * myNbP2d + 3 * myNbP3d)) + { throw Standard_DomainError("AppDef_LinearCriteria::ErrorValues"); + } NCollection_Array1 TabP3d(1, std::max(1, myNbP3d)); NCollection_Array1 TabP2d(1, std::max(1, myNbP2d)); @@ -469,9 +489,13 @@ void AppDef_LinearCriteria::ErrorValues(double& MaxError, } if (myNbP3d == 0) + { AppDef_MyLineTool::Value(mySSP, i, TabP2d); + } else + { AppDef_MyLineTool::Value(mySSP, i, TabP3d, TabP2d); + } for (ipnt = 1; ipnt <= myNbP2d; ipnt++) { P2d.SetCoord(BasePoint(c0 + 1), BasePoint(c0 + 2)); @@ -493,10 +517,14 @@ void AppDef_LinearCriteria::Hessian(const int Element, math_Matrix& H) { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::Hessian"); + } if (DependenceTable()->Value(Dimension1, Dimension2) == 0) + { throw Standard_DomainError("AppDef_LinearCriteria::Hessian"); + } int // NbDim = myCurve->Dimension(), MxDeg = myCurve->Base().WorkDegree(), @@ -536,7 +564,9 @@ void AppDef_LinearCriteria::Hessian(const int Element, // BuilCache if (myE != Element) + { BuildCache(Element); + } // Compute the least square Hessian for (ii = 1, ipnt = IF; ipnt <= IL; ipnt++, ii += (MxDeg + 1)) @@ -593,12 +623,16 @@ void AppDef_LinearCriteria::Hessian(const int Element, void AppDef_LinearCriteria::Gradient(const int Element, const int Dimension, math_Vector& G) { if (myCurve.IsNull()) + { throw Standard_DomainError("AppDef_LinearCriteria::ErrorValues"); + } int myNbP2d = AppDef_MyLineTool::NbP2d(mySSP), myNbP3d = AppDef_MyLineTool::NbP3d(mySSP); if (Dimension > (2 * myNbP2d + 3 * myNbP3d)) + { throw Standard_DomainError("AppDef_LinearCriteria::ErrorValues"); + } NCollection_Array1 TabP3d(1, std::max(1, myNbP3d)); NCollection_Array1 TabP2d(1, std::max(1, myNbP2d)); @@ -612,9 +646,13 @@ void AppDef_LinearCriteria::Gradient(const int Element, const int Dimension, mat IndCrd = Dimension % 3; IndPnt = Dimension / 3; if (IndCrd == 0) + { IndCrd = 3; + } else + { IndPnt++; + } } else { @@ -622,9 +660,13 @@ void AppDef_LinearCriteria::Gradient(const int Element, const int Dimension, mat IndCrd = (Dimension - 3 * myNbP3d) % 2; IndPnt = (Dimension - 3 * myNbP3d) / 2; if (IndCrd == 0) + { IndCrd = 2; + } else + { IndPnt++; + } } NCollection_Array1& Knots = myCurve->Knots(); @@ -644,7 +686,9 @@ void AppDef_LinearCriteria::Gradient(const int Element, const int Dimension, mat int ipnt, k, i, ii, i0 = G.Lower(), di = myPntWeight.Lower() - myParameters->Lower(); if (myE != Element) + { BuildCache(Element); + } G.Init(0.); @@ -661,15 +705,21 @@ void AppDef_LinearCriteria::Gradient(const int Element, const int Dimension, mat else { if (myNbP3d == 0) + { AppDef_MyLineTool::Value(mySSP, ipnt, TabP2d); + } else + { AppDef_MyLineTool::Value(mySSP, ipnt, TabP3d, TabP2d); + } Pnt = TabP2d(IndPnt).Coord(IndCrd); } curcoeff = Pnt * myPntWeight(di + ipnt); for (i = 0; i <= MxDeg; i++, ii++) + { G(i0 + i) += BV[ii] * curcoeff; + } } G *= 2. * myQuadraticWeight; @@ -703,7 +753,9 @@ void AppDef_LinearCriteria::InputVector( { GlobIndex = AssTable->Value(dim, el); for (i = 0; i <= MxDeg; i++) + { CoeffEl(i, dim) = X(i0 + GlobIndex->Value(i)); + } } myCurve->SetDegree(el, MxDeg); myCurve->SetElement(el, CoeffEl); @@ -719,9 +771,13 @@ void AppDef_LinearCriteria::SetWeight(const double QuadraticWeight, const double percentJ3) { if (QuadraticWeight < 0. || QualityWeight < 0.) + { throw Standard_DomainError("AppDef_LinearCriteria::SetWeight"); + } if (percentJ1 < 0. || percentJ2 < 0. || percentJ3 < 0.) + { throw Standard_DomainError("AppDef_LinearCriteria::SetWeight"); + } myQuadraticWeight = QuadraticWeight; myQualityWeight = QualityWeight; @@ -765,11 +821,15 @@ void AppDef_LinearCriteria::BuildCache(const int Element) if ((t > UFirst && t <= ULast) || (Element == 1 && t == UFirst)) { if (IF == 0) + { IF = ipnt; + } IL = ipnt; } else if (t > ULast) + { break; + } } if (IF != 0) diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiLine.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiLine.cxx index 69a0d5458c..cc290ba1e1 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiLine.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiLine.cxx @@ -25,7 +25,9 @@ AppDef_MultiLine::AppDef_MultiLine() = default; AppDef_MultiLine::AppDef_MultiLine(const int NbMult) { if (NbMult < 0) + { throw Standard_ConstructionError(); + } tabMult = new NCollection_HArray1(1, NbMult); } @@ -94,8 +96,8 @@ AppDef_MultiPointConstraint AppDef_MultiLine::Value(const int Index) const void AppDef_MultiLine::Dump(Standard_OStream& o) const { - o << "AppDef_MultiLine dump:" << std::endl; + o << "AppDef_MultiLine dump:" << '\n'; // AppDef_MultiPointConstraint MP = tabMult->Value(1); - o << "It contains " << tabMult->Length() << " MultiPointConstraint" << std::endl; + o << "It contains " << tabMult->Length() << " MultiPointConstraint" << '\n'; // o << MP->NbPoints() << " 3d and " << MP->NbPoints2d() << std::endl; } diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiPointConstraint.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiPointConstraint.cxx index 627cc8c4ce..4da657d507 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiPointConstraint.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_MultiPointConstraint.cxx @@ -215,7 +215,9 @@ AppDef_MultiPointConstraint::AppDef_MultiPointConstraint( void AppDef_MultiPointConstraint::SetTang(const int Index, const gp_Vec& Tang) { if (tabTang.IsNull()) + { tabTang = new NCollection_HArray1(1, nbP); + } if ((Index <= 0) || (Index > nbP)) { throw Standard_OutOfRange(); @@ -235,7 +237,9 @@ gp_Vec AppDef_MultiPointConstraint::Tang(const int Index) const void AppDef_MultiPointConstraint::SetTang2d(const int Index, const gp_Vec2d& Tang2d) { if (tabTang2d.IsNull()) + { tabTang2d = new NCollection_HArray1(1, nbP2d); + } if ((Index <= nbP) || (Index > nbP + nbP2d)) { @@ -256,7 +260,9 @@ gp_Vec2d AppDef_MultiPointConstraint::Tang2d(const int Index) const void AppDef_MultiPointConstraint::SetCurv(const int Index, const gp_Vec& Curv) { if (tabCurv.IsNull()) + { tabCurv = new NCollection_HArray1(1, nbP); + } if ((Index <= 0) || (Index > nbP)) { throw Standard_OutOfRange(); @@ -276,7 +282,9 @@ gp_Vec AppDef_MultiPointConstraint::Curv(const int Index) const void AppDef_MultiPointConstraint::SetCurv2d(const int Index, const gp_Vec2d& Curv2d) { if (tabCurv2d.IsNull()) + { tabCurv2d = new NCollection_HArray1(1, nbP2d); + } if ((Index <= nbP) || (Index > nbP + nbP2d)) { throw Standard_OutOfRange(); @@ -305,5 +313,5 @@ bool AppDef_MultiPointConstraint::IsCurvaturePoint() const void AppDef_MultiPointConstraint::Dump(Standard_OStream& o) const { - o << "AppDef_MultiPointConstraint dump:" << std::endl; + o << "AppDef_MultiPointConstraint dump:" << '\n'; } diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_MyLineTool.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_MyLineTool.cxx index 8ac3113632..8454643aff 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_MyLineTool.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_MyLineTool.cxx @@ -101,7 +101,9 @@ bool AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, return true; } else + { return false; + } } bool AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, @@ -120,7 +122,9 @@ bool AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, return true; } else + { return false; + } } bool AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, @@ -144,7 +148,9 @@ bool AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, return true; } else + { return false; + } } AppDef_MultiLine AppDef_MyLineTool::MakeMLBetween(const AppDef_MultiLine& theML, @@ -184,7 +190,9 @@ bool AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, return true; } else + { return false; + } } bool AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, @@ -203,7 +211,9 @@ bool AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, return true; } else + { return false; + } } bool AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, @@ -228,5 +238,7 @@ bool AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, return true; } else + { return false; + } } diff --git a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx index a23435df44..1dd17739c9 100644 --- a/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx +++ b/src/ModelingData/TKGeomBase/AppDef/AppDef_Variational.cxx @@ -94,16 +94,24 @@ AppDef_Variational::AppDef_Variational( { // Verifications: if (myMaxDegree < 1) + { throw Standard_DomainError(); + } myMaxDegree = std::min(30, myMaxDegree); // if (myMaxSegment < 1) + { throw Standard_DomainError(); + } // if (myWithMinMax != 0 && myWithMinMax != 1) + { throw Standard_DomainError(); + } if (myWithCutting != 0 && myWithCutting != 1) + { throw Standard_DomainError(); + } // myIsOverConstr = false; myIsCreated = false; @@ -140,7 +148,9 @@ AppDef_Variational::AppDef_Variational( myParameters = new NCollection_HArray1(myFirstPoint, myLastPoint); myNbPoints = myLastPoint - myFirstPoint + 1; if (myNbPoints <= 0) + { throw Standard_ConstructionError(); + } // myTabPoints = new NCollection_HArray1(1, myDimension * myNbPoints); // @@ -226,7 +236,9 @@ void AppDef_Variational::Init() myNbConstraints = myConstraints->Length(); if (myNbConstraints < 0) + { throw Standard_ConstructionError(); + } myTypConstraints = new NCollection_HArray1(1, std::max(1, 2 * myNbConstraints)); myTabConstraints = @@ -262,9 +274,13 @@ void AppDef_Variational::Init() myTypConstraints->SetValue(index++, 0); myNbPassPoints++; if (myNbP2d != 0) + { jndex = jndex + 4 * myNbP2d; + } if (myNbP3d != 0) + { jndex = jndex + 6 * myNbP3d; + } break; case AppParCurves_TangencyPoint: myTypConstraints->SetValue(index++, ipoint); @@ -273,7 +289,9 @@ void AppDef_Variational::Init() if (myNbP2d != 0 && myNbP3d == 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV2d)) + { throw Standard_ConstructionError(); + } for (jp2d = 1; jp2d <= myNbP2d; jp2d++) { Vt2d = TabV2d.Value(jp2d); @@ -287,7 +305,9 @@ void AppDef_Variational::Init() if (myNbP3d != 0 && myNbP2d == 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV3d)) + { throw Standard_ConstructionError(); + } for (jp3d = 1; jp3d <= myNbP3d; jp3d++) { Vt3d = TabV3d.Value(jp3d); @@ -304,7 +324,9 @@ void AppDef_Variational::Init() if (myNbP3d != 0 && myNbP2d != 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV3d, TabV2d)) + { throw Standard_ConstructionError(); + } for (jp3d = 1; jp3d <= myNbP3d; jp3d++) { Vt3d = TabV3d.Value(jp3d); @@ -336,16 +358,22 @@ void AppDef_Variational::Init() if (myNbP2d != 0 && myNbP3d == 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV2d)) + { throw Standard_ConstructionError(); + } if (!AppDef_MyLineTool::Curvature(mySSP, ipoint, TabV2dcurv)) + { throw Standard_ConstructionError(); + } for (jp2d = 1; jp2d <= myNbP2d; jp2d++) { Vt2d = TabV2d.Value(jp2d); Vt2d.Normalize(); Vc2d = TabV2dcurv.Value(jp2d); if (std::abs(std::abs(Vc2d.Angle(Vt2d)) - M_PI / 2.) > Precision::Angular()) + { throw Standard_ConstructionError(); + } myTabConstraints->SetValue(jndex++, Vt2d.X()); myTabConstraints->SetValue(jndex++, Vt2d.Y()); myTabConstraints->SetValue(jndex++, Vc2d.X()); @@ -357,16 +385,22 @@ void AppDef_Variational::Init() if (myNbP3d != 0 && myNbP2d == 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV3d)) + { throw Standard_ConstructionError(); + } if (!AppDef_MyLineTool::Curvature(mySSP, ipoint, TabV3dcurv)) + { throw Standard_ConstructionError(); + } for (jp3d = 1; jp3d <= myNbP3d; jp3d++) { Vt3d = TabV3d.Value(jp3d); Vt3d.Normalize(); Vc3d = TabV3dcurv.Value(jp3d); if (!(Vc3d.Normalized()).IsNormal(Vt3d, Precision::Angular())) + { throw Standard_ConstructionError(); + } myTabConstraints->SetValue(jndex++, Vt3d.X()); myTabConstraints->SetValue(jndex++, Vt3d.Y()); myTabConstraints->SetValue(jndex++, Vt3d.Z()); @@ -379,16 +413,22 @@ void AppDef_Variational::Init() if (myNbP3d != 0 && myNbP2d != 0) { if (!AppDef_MyLineTool::Tangency(mySSP, ipoint, TabV3d, TabV2d)) + { throw Standard_ConstructionError(); + } if (!AppDef_MyLineTool::Curvature(mySSP, ipoint, TabV3dcurv, TabV2dcurv)) + { throw Standard_ConstructionError(); + } for (jp3d = 1; jp3d <= myNbP3d; jp3d++) { Vt3d = TabV3d.Value(jp3d); Vt3d.Normalize(); Vc3d = TabV3dcurv.Value(jp3d); if (!(Vc3d.Normalized()).IsNormal(Vt3d, Precision::Angular())) + { throw Standard_ConstructionError(); + } myTabConstraints->SetValue(jndex++, Vt3d.X()); myTabConstraints->SetValue(jndex++, Vt3d.Y()); myTabConstraints->SetValue(jndex++, Vt3d.Z()); @@ -403,7 +443,9 @@ void AppDef_Variational::Init() Vt2d.Normalize(); Vc2d = TabV2dcurv.Value(jp2d); if (std::abs(std::abs(Vc2d.Angle(Vt2d)) - M_PI / 2.) > Precision::Angular()) + { throw Standard_ConstructionError(); + } myTabConstraints->SetValue(jndex++, Vt2d.X()); myTabConstraints->SetValue(jndex++, Vt2d.Y()); myTabConstraints->SetValue(jndex++, Vc2d.X()); @@ -420,9 +462,13 @@ void AppDef_Variational::Init() // OverConstraint Detection int MaxSeg; if (myWithCutting) + { MaxSeg = myMaxSegment; + } else + { MaxSeg = 1; + } if (((myMaxDegree - myNivCont) * MaxSeg - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) @@ -444,7 +490,9 @@ void AppDef_Variational::Approximate() { if (!myIsCreated) + { throw StdFail_NotDone(); + } double WQuadratic, WQuality; @@ -461,7 +509,9 @@ void AppDef_Variational::Approximate() TheMotor(mySmoothCriterion, WQuadratic, WQuality, TheCurve, Ecarts); if (myWithMinMax && myTolerance < myMaxError) + { Adjusting(mySmoothCriterion, WQuadratic, WQuality, TheCurve, Ecarts); + } //--------------------------------------------------------------------- @@ -495,7 +545,9 @@ void AppDef_Variational::Approximate() int ii; for (ii = 1; ii <= NbElem; ii++) + { NbCoeffPtr->SetValue(ii, TheCurve->Degree(ii) + 1); + } for (ii = PolynomialIntervalsPtr->LowerRow(); ii <= PolynomialIntervalsPtr->UpperRow(); ii++) { @@ -635,7 +687,9 @@ bool AppDef_Variational::IsOverConstrained() const AppParCurves_MultiBSpCurve AppDef_Variational::Value() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myMBSpCurve; } @@ -645,7 +699,9 @@ AppParCurves_MultiBSpCurve AppDef_Variational::Value() const double AppDef_Variational::MaxError() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myMaxError; } @@ -655,7 +711,9 @@ double AppDef_Variational::MaxError() const int AppDef_Variational::MaxErrorIndex() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myMaxErrorIndex; } @@ -665,7 +723,9 @@ int AppDef_Variational::MaxErrorIndex() const double AppDef_Variational::QuadraticError() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myCriterium[0]; } @@ -676,7 +736,9 @@ void AppDef_Variational::Distance(math_Matrix& mat) { if (!myIsDone) + { throw StdFail_NotDone(); + } int ipoint, jp2d, jp3d, index; NCollection_Array1 TabP3d(1, std::max(1, myNbP3d)); NCollection_Array1 TabP2d(1, std::max(1, myNbP2d)); @@ -706,9 +768,13 @@ void AppDef_Variational::Distance(math_Matrix& mat) if (myNbP2d != 0) { if (myNbP3d == 0) + { AppDef_MyLineTool::Value(mySSP, ipoint, TabP2d); + } else + { AppDef_MyLineTool::Value(mySSP, ipoint, TabP3d, TabP2d); + } for (jp2d = 1; jp2d <= myNbP2d; jp2d++) { @@ -726,7 +792,9 @@ void AppDef_Variational::Distance(math_Matrix& mat) double AppDef_Variational::AverageError() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myAverageError; } @@ -736,7 +804,9 @@ double AppDef_Variational::AverageError() const const occ::handle>& AppDef_Variational::Parameters() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myParameters; } @@ -746,7 +816,9 @@ const occ::handle>& AppDef_Variational::Parameters() const occ::handle>& AppDef_Variational::Knots() const { if (!myIsDone) + { throw StdFail_NotDone(); + } return myKnots; } @@ -758,7 +830,9 @@ void AppDef_Variational::Criterium(double& VFirstOrder, double& VThirdOrder) const { if (!myIsDone) + { throw StdFail_NotDone(); + } VFirstOrder = myCriterium[1]; VSecondOrder = myCriterium[2]; VThirdOrder = myCriterium[3]; @@ -835,47 +909,40 @@ int AppDef_Variational::NbIterations() const // void AppDef_Variational::Dump(Standard_OStream& o) const { - o << " \nVariational Smoothing " << std::endl; - o << " Number of multipoints " << myNbPoints << std::endl; - o << " Number of 2d par multipoint " << myNbP2d << std::endl; - o << " Number of 3d per multipoint " << myNbP3d << std::endl; - o << " Number of PassagePoint " << myNbPassPoints << std::endl; - o << " Number of TangencyPoints " << myNbTangPoints << std::endl; - o << " Number of CurvaturePoints " << myNbCurvPoints << std::endl; + o << " \nVariational Smoothing " << '\n'; + o << " Number of multipoints " << myNbPoints << '\n'; + o << " Number of 2d par multipoint " << myNbP2d << '\n'; + o << " Number of 3d per multipoint " << myNbP3d << '\n'; + o << " Number of PassagePoint " << myNbPassPoints << '\n'; + o << " Number of TangencyPoints " << myNbTangPoints << '\n'; + o << " Number of CurvaturePoints " << myNbCurvPoints << '\n'; o << " \nTolerance " << o.setf(std::ios::scientific) << std::setprecision(3) << std::setw(9) << myTolerance; if (WithMinMax()) { - o << " as Max Error." << std::endl; + o << " as Max Error." << '\n'; } else { - o << " as size Error." << std::endl; + o << " as size Error." << '\n'; } o << "CriteriumWeights : " << myPercent[0] << " , " << myPercent[1] << " , " << myPercent[2] - << std::endl; + << '\n'; if (myIsDone) { - o << " MaxError " << std::setprecision(3) << std::setw(9) << myMaxError - << std::endl; - o << " Index of MaxError " << myMaxErrorIndex << std::endl; - o << " Average Error " << std::setprecision(3) << std::setw(9) << myAverageError - << std::endl; - o << " Quadratic Error " << std::setprecision(3) << std::setw(9) << myCriterium[0] - << std::endl; - o << " Tension Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[1] - << std::endl; - o << " Flexion Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[2] - << std::endl; - o << " Jerk Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[3] - << std::endl; - o << " NbSegments " << myKnots->Length() - 1 << std::endl; + o << " MaxError " << std::setprecision(3) << std::setw(9) << myMaxError << '\n'; + o << " Index of MaxError " << myMaxErrorIndex << '\n'; + o << " Average Error " << std::setprecision(3) << std::setw(9) << myAverageError << '\n'; + o << " Quadratic Error " << std::setprecision(3) << std::setw(9) << myCriterium[0] << '\n'; + o << " Tension Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[1] << '\n'; + o << " Flexion Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[2] << '\n'; + o << " Jerk Criterium " << std::setprecision(3) << std::setw(9) << myCriterium[3] << '\n'; + o << " NbSegments " << myKnots->Length() - 1 << '\n'; } else { - o << (myIsOverConstr ? " The problem is overconstraint" : " Error in approximation") - << std::endl; + o << (myIsOverConstr ? " The problem is overconstraint" : " Error in approximation") << '\n'; } } @@ -915,7 +982,9 @@ bool AppDef_Variational::SetMaxDegree(const int Degree) if (((Degree - myNivCont) * myMaxSegment - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) + { return false; + } else { myMaxDegree = Degree; @@ -935,7 +1004,9 @@ bool AppDef_Variational::SetMaxSegment(const int NbSegment) && ((myMaxDegree - myNivCont) * NbSegment - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) + { return false; + } else { myMaxSegment = NbSegment; @@ -966,7 +1037,9 @@ bool AppDef_Variational::SetContinuity(const GeomAbs_Shape C) if (((myMaxDegree - NivCont) * myMaxSegment - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) + { return false; + } else { myContinuity = C; @@ -997,8 +1070,9 @@ bool AppDef_Variational::SetWithCutting(const bool Cutting) if (((myMaxDegree - myNivCont) * myKnots->Length() - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) + { return false; - + } else { myWithCutting = Cutting; @@ -1011,8 +1085,9 @@ bool AppDef_Variational::SetWithCutting(const bool Cutting) if (((myMaxDegree - myNivCont) * myMaxSegment - myNbPassPoints - 2 * myNbTangPoints - 3 * myNbCurvPoints) < 0) + { return false; - + } else { myWithCutting = Cutting; @@ -1030,7 +1105,9 @@ void AppDef_Variational::SetCriteriumWeight(const double Percent1, const double Percent3) { if (Percent1 < 0 || Percent2 < 0 || Percent3 < 0) + { throw Standard_DomainError(); + } double Total = Percent1 + Percent2 + Percent3; myPercent[0] = Percent1 / Total; myPercent[1] = Percent2 / Total; @@ -1045,9 +1122,13 @@ void AppDef_Variational::SetCriteriumWeight(const double Percent1, void AppDef_Variational::SetCriteriumWeight(const int Order, const double Percent) { if (Percent < 0) + { throw Standard_DomainError(); + } if (Order < 1 || Order > 3) + { throw Standard_ConstructionError(); + } myPercent[Order - 1] = Percent; double Total = myPercent[0] + myPercent[1] + myPercent[2]; myPercent[0] = myPercent[0] / Total; @@ -1113,11 +1194,17 @@ void AppDef_Variational::TheMotor(occ::handle& J, J2min = J3min = (e1 + 1.e-8) * 1.e-6; if (e1 < J1min) + { e1 = J1min; // Like in + } if (e2 < J2min) + { e2 = J2min; // MOTLIS + } if (e3 < J3min) + { e3 = J3min; + } J->SetEstimation(e1, e2, e3); @@ -1166,7 +1253,9 @@ void AppDef_Variational::TheMotor(occ::handle& J, ICDANA = J->QualityValues(J1min, J2min, J3min, VALCRI[0], VALCRI[1], VALCRI[2]); if (ICDANA > 0) + { lconst = true; + } J->ErrorValues(ERRMAX, ERRQUA, ERRMOY); @@ -1189,34 +1278,58 @@ void AppDef_Variational::TheMotor(occ::handle& J, 2); } else + { NewTi = CurrentTi; + } // (1.4) Progression's test iprog = 0; if ((EROLD > WQuality) && (ERRMAX < 0.95 * EROLD)) + { iprog++; + } if ((EROLD > WQuality) && (ERRMAX < 0.8 * EROLD)) + { iprog++; + } if ((EROLD > WQuality) && (ERRMAX < WQuality)) + { iprog++; + } if ((EROLD > WQuality) && (ERRMAX < 0.99 * EROLD) && (ERRMAX < 1.1 * WQuality)) + { iprog++; + } if (VALCRI[0] < 0.975 * VOCRI[0]) + { iprog++; + } if (VALCRI[0] < 0.9 * VOCRI[0]) + { iprog++; + } if (VALCRI[1] < 0.95 * VOCRI[1]) + { iprog++; + } if (VALCRI[1] < 0.8 * VOCRI[1]) + { iprog++; + } if (VALCRI[2] < 0.95 * VOCRI[2]) + { iprog++; + } if (VALCRI[2] < 0.8 * VOCRI[2]) + { iprog++; + } if ((VOCRI[1] > SmallestValue) && (VOCRI[2] > SmallestValue)) { if ((VALCRI[1] / VOCRI[1] + 2 * VALCRI[2] / VOCRI[2]) < 2.8) + { iprog++; + } } if (iprog < 2 && NbEst == 0) @@ -1310,7 +1423,9 @@ void AppDef_Variational::TheMotor(occ::handle& J, ICDANA = J->QualityValues(J1min, J2min, J3min, VALCRI[0], VALCRI[1], VALCRI[2]); if (ICDANA > 0) + { lconst = true; + } J->GetEstimation(e1, e2, e3); // (2.5) Optimization of ti by orthogonal projection @@ -1332,20 +1447,32 @@ void AppDef_Variational::TheMotor(occ::handle& J, if (NbrConstraint < NbrPnt) { if ((ERRMAX > WQuality) && (ERRMAX > 1.05 * EROLD)) + { iregre++; + } if ((ERRMAX > WQuality) && (ERRMAX > 2 * EROLD)) + { iregre++; + } if ((EROLD > WQuality) && (ERRMAX <= 0.5 * EROLD)) + { iregre--; + } } double E1, E2, E3; J->GetEstimation(E1, E2, E3); if ((VALCRI[0] > E1) && (VALCRI[0] > 1.1 * VOCRI[0])) + { iregre++; + } if ((VALCRI[1] > E2) && (VALCRI[1] > 1.1 * VOCRI[1])) + { iregre++; + } if ((VALCRI[2] > E3) && (VALCRI[2] > 1.1 * VOCRI[2])) + { iregre++; + } if (iregre >= 2) { @@ -1366,7 +1493,9 @@ void AppDef_Variational::TheMotor(occ::handle& J, CurrentTi = NewTi; } if (Iter >= myNbIterations) + { ToOptim = false; + } } // (3) Optional splitting @@ -1403,7 +1532,9 @@ void AppDef_Variational::TheMotor(occ::handle& J, SplitCurve(CCurrent, CurrentTi->Array1(), EpsLength, CNew, iscut); if (!iscut) + { again = false; + } else { CCurrent = CNew; @@ -1447,9 +1578,13 @@ L8000: myMaxError = ERRMAX; myMaxErrorIndex = NumPnt; if (NbrPnt > NbrConstraint) + { myAverageError = ERRMOY / (NbrPnt - NbrConstraint); + } else + { myAverageError = ERRMOY / NbrConstraint; + } delete TheAssembly; } @@ -1478,7 +1613,9 @@ void AppDef_Variational::Optimization(occ::handle& J, // Updating Assembly if (ToAssemble) + { A.NullifyMatrix(); + } A.NullifyVector(); for (el = 1; el <= NbElm; el++) @@ -1487,7 +1624,9 @@ void AppDef_Variational::Optimization(occ::handle& J, { J->Hessian(el, 1, 1, H); for (dim = 1; dim <= NbDim; dim++) + { A.AddMatrix(el, dim, dim, H); + } } for (dim = 1; dim <= NbDim; dim++) @@ -1533,12 +1672,18 @@ void AppDef_Variational::Optimization(occ::handle& J, { while ((Icnt < NbConstr) && (Parameters(p0 + myTypConstraints->Value(2 * Icnt - 1)) <= TabInt(el))) + { Icnt++; + } point = p0 + myTypConstraints->Value(2 * Icnt - 1); if (Parameters(point) <= TabInt(el) || Parameters(point) >= TabInt(el + 1)) + { Curve->ReduceDegree(el, EpsDeg, Newdeg, MaxError); + } else if (Curve->Degree(el) < MxDeg) + { Curve->SetDegree(el, MxDeg); + } } } } @@ -1611,15 +1756,21 @@ void AppDef_Variational::Project(const occ::handle& C, } if (std::abs(F2) < Eps) + { EnCour = false; + } else { // Formula of Newton x(k+1) = x(k) - F(x(k))/F'(x(k)) TNew -= F1 / F2; if (TNew < 0.) + { TNew = 0.; + } if (TNew > 1.) + { TNew = 1.; + } // Analysis of result @@ -1643,13 +1794,19 @@ void AppDef_Variational::Project(const occ::handle& C, Dist = Dist0; } else if (Ecart <= Seuil) + { // Convergence NItCv++; + } else + { NItCv = 0; + } if ((NItCv >= 2) || (Iter >= NbIterations)) + { EnCour = false; + } } } @@ -1703,7 +1860,9 @@ void AppDef_Variational::ACR(occ::handle& Curve, ICnt = 1; } else + { PCnt = TiLast + 1; + } UOld = 0.; @@ -1740,7 +1899,9 @@ void AppDef_Variational::ACR(occ::handle& Curve, UNew /= CbLong; while (Knots(IElm + 1) < TPara && IElm < KLast - 1) + { IElm++; + } // (2.4) Update the splitting parameters DTInv = 1. / (TPara - TOld); @@ -1776,7 +1937,9 @@ void AppDef_Variational::ACR(occ::handle& Curve, // VTest += (ii + 1) * DeltaT; VTest += std::ceil((TPara - VTest + Eps) / DeltaT) * DeltaT; if (VTest > 1. - Eps) + { VTest = 1.; + } } } } @@ -1823,13 +1986,19 @@ static int NearIndex(const double T, { Imidl = (Ibeg + Ifin) / 2; if ((T >= TabPar(Ibeg)) && (T <= TabPar(Imidl))) + { Ifin = Imidl; + } else + { Ibeg = Imidl; + } } if (std::abs(T - TabPar(Ifin)) < Eps) + { return Ifin; + } return Ibeg; } @@ -1870,24 +2039,34 @@ static void GettingKnots(const NCollection_Array1& TabPar, Ipt1 = NearIndex(OldKnots(i0), TabPar, Eps, Flag); if (Flag != 0) + { Ipt1 = TabPar.Lower(); + } Ipt2 = NearIndex(OldKnots(i1), TabPar, Eps, Flag); if (Flag != 0) + { Ipt2 = TabPar.Upper(); + } if (Ipt2 - Ipt1 >= 1) { Ipt = (Ipt1 + Ipt2) / 2; if (2 * Ipt == Ipt1 + Ipt2) + { TPar = 2. * TabPar(Ipt); + } else + { TPar = TabPar(Ipt) + TabPar(Ipt + 1); + } NewKnots(NbElm) = (OldKnots(i0) + OldKnots(i1) + TPar) / 4.; } else + { NewKnots(NbElm) = (OldKnots(i0) + OldKnots(i1)) / 2.; + } } } } @@ -1930,14 +2109,20 @@ void AppDef_Variational::SplitCurve(const occ::handle& InCurve, int i, i0 = OutKnots.Lower(); for (i = InKnots.Lower(); i <= InKnots.Upper(); i++) + { OutKnots(i) = InKnots(i); + } for (i = NbElmOld + 1; i <= NbElm; i++) + { OutKnots(i + i0) = NewKnots(i); + } std::sort(OutKnots.begin(), OutKnots.end()); } else + { iscut = false; + } } //================================================================================================= @@ -1969,19 +2154,29 @@ void AppDef_Variational::InitSmoothCriterion() double WQuadratic, WQuality; if (!myWithMinMax && myTolerance != 0.) + { WQuality = myTolerance; + } else if (myTolerance == 0.) + { WQuality = 1.; + } else + { WQuality = std::max(myTolerance, Eps2 * Length); + } int NbConstr = myNbPassPoints + myNbTangPoints + myNbCurvPoints; WQuadratic = std::sqrt((double)(myNbPoints - NbConstr)) * WQuality; if (WQuadratic > Eps3) + { WQuadratic = 1. / WQuadratic; + } if (WQuadratic == 0.) + { WQuadratic = std::max(std::sqrt(E1), 1.); + } mySmoothCriterion->SetWeight(WQuadratic, WQuality, myPercent[0], myPercent[1], myPercent[2]); @@ -2006,8 +2201,6 @@ void AppDef_Variational::InitSmoothCriterion() } mySmoothCriterion->SetCurve(TheCurve); - - return; } // @@ -2039,16 +2232,22 @@ void AppDef_Variational::InitParameters(double& Length) } if (Length <= Eps1) + { throw Standard_ConstructionError("AppDef_Variational::InitParameters"); + } for (ipoint = myFirstPoint + 1; ipoint <= myLastPoint - 1; ipoint++) + { myParameters->SetValue(ipoint, myParameters->Value(ipoint) / Length); + } myParameters->SetValue(myLastPoint, 1.); // With few points there is likely underestimation ... if (myNbPoints < 10) + { Length *= (1. + 0.1 / (myNbPoints - 1)); + } } // @@ -2088,7 +2287,9 @@ void AppDef_Variational::InitCriterionEstimations(const double Length, // Modified by skv - Fri Apr 8 14:58:12 2005 OCC8559 End if (Delta <= Eps1) + { Delta = 1.; + } E2 = VScnd1.Norm2() * Delta; @@ -2110,7 +2311,9 @@ void AppDef_Variational::InitCriterionEstimations(const double Length, EstSecnd(ipnt + 1, VTang1, VTang3, Length, VScnd2); } else + { EstSecnd(ipnt + 1, VTang1, VTang2, Length, VScnd2); + } E2 += VScnd1.Norm2() * Delta; E3 += (Delta > Eps1) ? VScnd2.Subtracted(VScnd3).Norm2() / (4. * Delta) : 0.; @@ -2123,7 +2326,9 @@ void AppDef_Variational::InitCriterionEstimations(const double Length, EstSecnd(ipnt + 1, VTang2, VTang1, Length, VScnd3); } else + { EstSecnd(ipnt + 1, VTang2, VTang3, Length, VScnd3); + } E2 += VScnd2.Norm2() * Delta; E3 += (Delta > Eps1) ? VScnd3.Subtracted(VScnd1).Norm2() / (4. * Delta) : 0.; @@ -2136,7 +2341,9 @@ void AppDef_Variational::InitCriterionEstimations(const double Length, EstSecnd(ipnt + 1, VTang3, VTang2, Length, VScnd1); } else + { EstSecnd(ipnt + 1, VTang3, VTang1, Length, VScnd1); + } E2 += VScnd3.Norm2() * Delta; E3 += (Delta > Eps1) ? VScnd1.Subtracted(VScnd2).Norm2() / (4. * Delta) : 0.; @@ -2144,14 +2351,18 @@ void AppDef_Variational::InitCriterionEstimations(const double Length, CurrPoint++; if (CurrPoint == 4) + { CurrPoint = 1; + } } // ========== Treatment of last point ================= Delta = .5 * (myParameters->Value(myLastPoint) - myParameters->Value(myLastPoint - 1)); if (Delta <= Eps1) + { Delta = 1.; + } double aux; @@ -2200,7 +2411,9 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const { // Estimation at first point if (myNbPoints < 3) + { Wpnt = 0.; + } else { @@ -2217,7 +2430,9 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const double V1 = Pnt2.Subtracted(Pnt1).Norm(); double V2 = 0.; if (V1 > Eps1) + { V2 = Pnt3.Subtracted(Pnt2).Norm(); + } if (V2 > Eps1) { double d = V1 / (V1 + V2), d1; @@ -2237,7 +2452,9 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const { // Estimation at last point if (myNbPoints < 3) + { Wpnt = 0.; + } else { @@ -2255,7 +2472,9 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const double V1 = Pnt2.Subtracted(Pnt1).Norm(); double V2 = 0.; if (V1 > Eps1) + { V2 = Pnt3.Subtracted(Pnt2).Norm(); + } if (V2 > Eps1) { double d = V1 / (V1 + V2), d1; @@ -2285,9 +2504,13 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const double Vnorm = VTang.Norm(); if (Vnorm <= EpsNorm) + { VTang.Init(0.); + } else + { VTang /= Vnorm; + } // Estimation with constraints @@ -2303,7 +2526,9 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const { while (myTypConstraints->Value(2 * IdCnt - 1) < ipnt && IdCnt <= NbConstr) + { IdCnt++; + } if ((myTypConstraints->Value(2 * IdCnt - 1) == ipnt) && (myTypConstraints->Value(2 * IdCnt) >= 1)) { @@ -2312,13 +2537,17 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const for (i = 1; i <= myNbP3d; i++) { for (int j = 1; j <= 3; j++) + { VCnt(++k) = myTabConstraints->Value(++i0); + } i0 += 3; } for (i = 1; i <= myNbP2d; i++) { for (int j = 1; j <= 2; j++) + { VCnt(++k) = myTabConstraints->Value(++i0); + } i0 += 2; } } @@ -2328,18 +2557,26 @@ void AppDef_Variational::EstTangent(const int ipnt, math_Vector& VTang) const double Denom = Wpnt + Wcnt; if (Denom == 0.) + { Denom = 1.; + } else + { Denom = 1. / Denom; + } VTang = (Wpnt * VTang + Wcnt * VCnt) * Denom; Vnorm = VTang.Norm(); if (Vnorm <= EpsNorm) + { VTang.Init(0.); + } else + { VTang /= Vnorm; + } } // @@ -2360,16 +2597,26 @@ void AppDef_Variational::EstSecnd(const int ipnt, double aux; if (ipnt == myFirstPoint) + { aux = myParameters->Value(ipnt + 1) - myParameters->Value(ipnt); + } else if (ipnt == myLastPoint) + { aux = myParameters->Value(ipnt) - myParameters->Value(ipnt - 1); + } else + { aux = myParameters->Value(ipnt + 1) - myParameters->Value(ipnt - 1); + } if (aux <= Eps) + { aux = 1.; + } else + { aux = 1. / aux; + } VScnd = (VTang2 - VTang1) * aux; @@ -2387,7 +2634,9 @@ void AppDef_Variational::EstSecnd(const int ipnt, { while (myTypConstraints->Value(2 * IdCnt - 1) < ipnt && IdCnt <= NbConstr) + { IdCnt++; + } if ((myTypConstraints->Value(2 * IdCnt - 1) == ipnt) && (myTypConstraints->Value(2 * IdCnt) >= 2)) @@ -2397,14 +2646,18 @@ void AppDef_Variational::EstSecnd(const int ipnt, for (i = 1; i <= myNbP3d; i++) { for (int j = 1; j <= 3; j++) + { VCnt(++k) = myTabConstraints->Value(++i0); + } i0 += 3; } i0--; for (i = 1; i <= myNbP2d; i++) { for (int j = 1; j <= 2; j++) + { VCnt(++k) = myTabConstraints->Value(++i0); + } i0 += 2; } } @@ -2414,9 +2667,13 @@ void AppDef_Variational::EstSecnd(const int ipnt, double Denom = Wpnt + Wcnt; if (Denom == 0.) + { Denom = 1.; + } else + { Denom = 1. / Denom; + } VScnd = (Wpnt * VScnd + (Wcnt * Length) * VCnt) * Denom; } @@ -2441,7 +2698,9 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, } if (ORCMx > myMaxDegree - myNivCont) + { throw Standard_ConstructionError("AppDef_Variational::InitCutting"); + } int NLibre = std::max(myMaxDegree - myNivCont - (myMaxDegree + 1) / 4, myNivCont + 1); @@ -2455,7 +2714,9 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, } if (NbElem > myMaxSegment) + { throw Standard_ConstructionError("AppDef_Variational::InitCutting"); + } aCurve = new FEmTool_Curve(myDimension, NbElem, aBase, CurvTol); @@ -2476,7 +2737,9 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, IndEl++; NbEl++; if (NPlus == 0) + { NCnt--; + } while (NDeb < NCnt && IDeb < IFin) { @@ -2489,12 +2752,16 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, NDeb = 0; if (NPlus == 1 && myParameters->Value(myTypConstraints->Value(2 * IDeb - 1)) > Knot(IndEl - 1)) + { Knot(IndEl) = myParameters->Value(myTypConstraints->Value(2 * IDeb - 1)); + } else + { Knot(IndEl) = (myParameters->Value(myTypConstraints->Value(2 * IDeb - 1)) + myParameters->Value(myTypConstraints->Value(2 * IDeb + 1))) / 2; + } } else { @@ -2504,10 +2771,14 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, NPlus--; if (NPlus == 0) + { NCnt--; + } if (NbElem - NbEl == 1) + { break; + } NbEl++; @@ -2528,11 +2799,15 @@ void AppDef_Variational::InitCutting(const PLib_HermitJacobi& aBase, { NFin -= NCnt; if (myParameters->Value(myTypConstraints->Value(2 * IFin - 1)) < Knot(IUpper - IndEl + 1)) + { Knot(IUpper + 1 - IndEl) = myParameters->Value(myTypConstraints->Value(2 * IFin - 1)); + } else + { Knot(IUpper + 1 - IndEl) = (myParameters->Value(myTypConstraints->Value(2 * IFin - 1)) + myParameters->Value(myTypConstraints->Value(2 * IFin - 3))) / 2; + } } } } @@ -2625,9 +2900,13 @@ void AppDef_Variational::Adjusting(occ::handle& J, CNew = new FEmTool_Curve(myDimension, TheCurve->NbElements() + 1, TheCurve->Base(), CurvTol); for (i = 1; i <= numint; i++) + { CNew->Knots()(i) = TheCurve->Knots()(i); + } for (i = numint + 1; i <= TheCurve->Knots().Length(); i++) + { CNew->Knots()(i + 1) = TheCurve->Knots()(i); + } CNew->Knots()(numint + 1) = tpara; } @@ -2699,10 +2978,14 @@ static bool NotParallel(gp_Vec& T, gp_Vec& V) V = T; V.SetX(V.X() + 1.); if (V.CrossMagnitude(T) > 1.e-12) + { return true; + } V.SetY(V.Y() + 1.); if (V.CrossMagnitude(T) > 1.e-12) + { return true; + } V.SetZ(V.Z() + 1.); return V.CrossMagnitude(T) > 1.e-12; } @@ -2984,7 +3267,9 @@ void AppDef_Variational::AssemblingConstraints(const occ::handle& { curdim++; if (k > 1) + { R1 = R2 = 0.; + } A.AddConstraint(IndexOfConstraint, curel, curdim, myTfthet->Value(jt + k) * V2, R1); A.AddConstraint(IndexOfConstraint + 1, curel, @@ -3011,7 +3296,9 @@ void AppDef_Variational::AssemblingConstraints(const occ::handle& { curdim++; if (k > 1) + { R1 = 0.; + } A.AddConstraint(IndexOfConstraint, curel, curdim, myTfthet->Value(jt + k) * V2, R1); } IndexOfConstraint += Ng2d; @@ -3031,7 +3318,9 @@ bool AppDef_Variational::InitTthetaF(const int ndimen, const int jndex) { if ((ndimen < 2) || (ndimen > 3)) + { return false; + } gp_Vec T, V; gp_Vec theta1, theta2; gp_Vec F; @@ -3042,9 +3331,13 @@ bool AppDef_Variational::InitTthetaF(const int ndimen, T.SetX(myTabConstraints->Value(jndex)); T.SetY(myTabConstraints->Value(jndex + 1)); if (ndimen == 3) + { T.SetZ(myTabConstraints->Value(jndex + 2)); + } else + { T.SetZ(0.); + } if (ndimen == 2) { V.SetX(0.); @@ -3052,8 +3345,12 @@ bool AppDef_Variational::InitTthetaF(const int ndimen, V.SetZ(1.); } if (ndimen == 3) + { if (!NotParallel(T, V)) + { return false; + } + } theta1 = V ^ T; theta1.Normalize(); myTtheta->SetValue(begin, theta1.X()); diff --git a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves.cxx b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves.cxx index fe30058b0d..08700dc882 100644 --- a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves.cxx +++ b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves.cxx @@ -246,8 +246,12 @@ void AppParCurves::SplineFunction(const int nbpoles, } for (j = 1; j < oldkindex - deg; j++) + { A(i, j) = DA(i, j) = 0.0; + } for (j = oldkindex + 1; j <= nbpoles; j++) + { A(i, j) = DA(i, j) = 0.0; + } } } diff --git a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiBSpCurve.cxx b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiBSpCurve.cxx index 33119a2256..bd8f90c81c 100644 --- a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiBSpCurve.cxx +++ b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiBSpCurve.cxx @@ -279,9 +279,9 @@ void AppParCurves_MultiBSpCurve::D2(const int CuIndex, void AppParCurves_MultiBSpCurve::Dump(Standard_OStream& o) const { - o << "AppParCurves_MultiBSpCurve dump:" << std::endl; - o << " It contains " << NbCurves() << " BSpline curves " << std::endl; - o << " The poles are: " << std::endl; + o << "AppParCurves_MultiBSpCurve dump:" << '\n'; + o << " It contains " << NbCurves() << " BSpline curves " << '\n'; + o << " The poles are: " << '\n'; /* for (int i = 1; i <= NbCurves(); i++) { o << " Curve No. " << i << std::endl; if (Dimension(i) == 3) { diff --git a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiCurve.cxx b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiCurve.cxx index e5c3847f66..7eef69c1ca 100644 --- a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiCurve.cxx +++ b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiCurve.cxx @@ -56,7 +56,9 @@ int AppParCurves_MultiCurve::Dimension(const int Index) const int AppParCurves_MultiCurve::NbCurves() const { if (tabPoint.IsNull()) + { return 0; + } AppParCurves_MultiPoint MP = tabPoint->Value(1); return MP.NbPoints() + MP.NbPoints2d(); } @@ -64,7 +66,9 @@ int AppParCurves_MultiCurve::NbCurves() const int AppParCurves_MultiCurve::NbPoles() const { if (tabPoint.IsNull()) + { return 0; + } return tabPoint->Length(); } @@ -148,7 +152,9 @@ void AppParCurves_MultiCurve::Transform(const int CuIndex, const double dz) { if (Dimension(CuIndex) != 3) + { throw Standard_OutOfRange(); + } for (int i = 1; i <= tabPoint->Length(); i++) { @@ -163,7 +169,9 @@ void AppParCurves_MultiCurve::Transform2d(const int CuIndex, const double dy) { if (Dimension(CuIndex) != 2) + { throw Standard_OutOfRange(); + } for (int i = 1; i <= tabPoint->Length(); i++) { @@ -175,7 +183,9 @@ void AppParCurves_MultiCurve::Value(const int CuIndex, const double U, gp_Pnt& P { if (Dimension(CuIndex) != 3) + { throw Standard_OutOfRange(); + } NCollection_Array1 TabPoles(1, tabPoint->Length()); @@ -289,10 +299,10 @@ void AppParCurves_MultiCurve::D2(const int CuIndex, void AppParCurves_MultiCurve::Dump(Standard_OStream& o) const { - o << "AppParCurves_MultiCurve dump:" << std::endl; + o << "AppParCurves_MultiCurve dump:" << '\n'; o << " It contains " << NbCurves() << " Bezier curves of degree " << tabPoint->Length() - 1 - << std::endl; - o << " The poles are: " << std::endl; + << '\n'; + o << " The poles are: " << '\n'; /* for (int i = 1; i <= NbCurves(); i++) { o << " Curve No. " << i << std::endl; if (Dimension(i) == 3) { diff --git a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiPoint.cxx b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiPoint.cxx index cc964a6f8d..b21d7c4ed9 100644 --- a/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiPoint.cxx +++ b/src/ModelingData/TKGeomBase/AppParCurves/AppParCurves_MultiPoint.cxx @@ -110,7 +110,9 @@ void AppParCurves_MultiPoint::Transform(const int CuIndex, const double dz) { if (Dimension(CuIndex) != 3) + { throw Standard_OutOfRange(); + } gp_Pnt P, newP; P = Point(CuIndex); @@ -125,7 +127,9 @@ void AppParCurves_MultiPoint::Transform2d(const int CuIndex, const double dy) { if (Dimension(CuIndex) != 2) + { throw Standard_OutOfRange(); + } gp_Pnt2d P, newP; P = Point2d(CuIndex); @@ -163,19 +167,19 @@ const gp_Pnt2d& AppParCurves_MultiPoint::Point2d(const int Index) const void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const { - o << "AppParCurves_MultiPoint dump:" << std::endl; + o << "AppParCurves_MultiPoint dump:" << '\n'; const int aNbPnts3D = NbPoints(), aNbPnts2D = NbPoints2d(); - o << "It contains " << aNbPnts3D << " 3d points and " << aNbPnts2D << " 2d points." << std::endl; + o << "It contains " << aNbPnts3D << " 3d points and " << aNbPnts2D << " 2d points." << '\n'; if (aNbPnts3D > 0) { for (int i = tabPoint->Lower(); i <= tabPoint->Upper(); i++) { - o << "3D-Point #" << i << std::endl; + o << "3D-Point #" << i << '\n'; - o << " Pole x = " << (tabPoint->Value(i) /*->Point(j)*/).X() << std::endl; - o << " Pole y = " << (tabPoint->Value(i) /*->Point(j)*/).Y() << std::endl; - o << " Pole z = " << (tabPoint->Value(i) /*->Point(j)*/).Z() << std::endl; + o << " Pole x = " << (tabPoint->Value(i) /*->Point(j)*/).X() << '\n'; + o << " Pole y = " << (tabPoint->Value(i) /*->Point(j)*/).Y() << '\n'; + o << " Pole z = " << (tabPoint->Value(i) /*->Point(j)*/).Z() << '\n'; } } @@ -183,10 +187,10 @@ void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const { for (int i = tabPoint2d->Lower(); i <= tabPoint2d->Upper(); i++) { - o << "2D-Point #" << i << std::endl; + o << "2D-Point #" << i << '\n'; - o << " Pole x = " << (tabPoint2d->Value(i) /*->Point2d(j)*/).X() << std::endl; - o << " Pole y = " << (tabPoint2d->Value(i) /*->Point2d(j)*/).Y() << std::endl; + o << " Pole x = " << (tabPoint2d->Value(i) /*->Point2d(j)*/).X() << '\n'; + o << " Pole y = " << (tabPoint2d->Value(i) /*->Point2d(j)*/).Y() << '\n'; } } } diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_Curve2d.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_Curve2d.cxx index 88e94fa65b..15e13649e9 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_Curve2d.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_Curve2d.cxx @@ -156,7 +156,9 @@ Approx_Curve2d::Approx_Curve2d(const occ::handle& C2D, NCollection_Array1 Poles1dV(1, aNbPoles); aApprox.Poles1d(2, Poles1dV); for (int i = 1; i <= aNbPoles; i++) + { Poles2d.SetValue(i, gp_Pnt2d(Poles1dU.Value(i), Poles1dV.Value(i))); + } occ::handle> Knots = aApprox.Knots(); occ::handle> Mults = aApprox.Multiplicities(); diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_Curve3d.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_Curve3d.cxx index d9682cc44e..259fb17ebc 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_Curve3d.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_Curve3d.cxx @@ -183,8 +183,8 @@ double Approx_Curve3d::MaxError() const void Approx_Curve3d::Dump(Standard_OStream& o) const { - o << "******* Dump of ApproxCurve *******" << std::endl; - o << "*******Degree " << Curve()->Degree() << std::endl; - o << "*******NbSegments " << Curve()->NbKnots() - 1 << std::endl; - o << "*******Error " << MaxError() << std::endl; + o << "******* Dump of ApproxCurve *******" << '\n'; + o << "*******Degree " << Curve()->Degree() << '\n'; + o << "*******NbSegments " << Curve()->NbKnots() - 1 << '\n'; + o << "*******Error " << MaxError() << '\n'; } diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_CurveOnSurface.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_CurveOnSurface.cxx index c6736467c2..29d6332671 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_CurveOnSurface.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_CurveOnSurface.cxx @@ -366,15 +366,23 @@ void Approx_CurveOnSurface::Perform(const int theMaxSegments, myError3d = 0.0; if (theOnly3d && theOnly2d) + { throw Standard_ConstructionError(); + } GeomAbs_Shape aContinuity = theContinuity; if (aContinuity == GeomAbs_G1) + { aContinuity = GeomAbs_C1; + } else if (aContinuity == GeomAbs_G2) + { aContinuity = GeomAbs_C2; + } else if (aContinuity > GeomAbs_C2) + { aContinuity = GeomAbs_C2; // Restriction of AdvApprox_ApproxAFunction + } occ::handle TrimmedC2D = myC2D->Trim(myFirst, myLast, Precision::PConfusion()); @@ -403,11 +411,17 @@ void Approx_CurveOnSurface::Perform(const int theMaxSegments, Approx_CurveOnSurface_Eval EvalCvOnSurf(HCOnS, TrimmedC2D, myFirst, myLast); AdvApprox_EvaluatorFunction* EvalPtr; if (theOnly3d) + { EvalPtr = &Eval3dCvOnSurf; + } else if (theOnly2d) + { EvalPtr = &Eval2dCvOnSurf; + } else + { EvalPtr = &EvalCvOnSurf; + } // Initialization for 2d approximation if (!theOnly3d) @@ -423,17 +437,25 @@ void Approx_CurveOnSurface::Perform(const int theMaxSegments, if (mySurf->UContinuity() == GeomAbs_C0) { if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, true, Precision::Angular())) + { TolU = std::min(1.e-3, 1.e3 * TolU); + } if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, true, Precision::Confusion())) + { TolU = std::min(1.e-3, 1.e2 * TolU); + } } if (mySurf->VContinuity() == GeomAbs_C0) { if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, false, Precision::Angular())) + { TolV = std::min(1.e-3, 1.e3 * TolV); + } if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, false, Precision::Confusion())) + { TolV = std::min(1.e-3, 1.e2 * TolV); + } } OneDTol->SetValue(1, TolU); @@ -518,7 +540,9 @@ void Approx_CurveOnSurface::Perform(const int theMaxSegments, NCollection_Array1 Poles1dV(1, aNbPoles); aApprox.Poles1d(2, Poles1dV); for (int i = 1; i <= aNbPoles; i++) + { Poles2d.SetValue(i, gp_Pnt2d(Poles1dU.Value(i), Poles1dV.Value(i))); + } myCurve2d = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree); myError2dU = aApprox.MaxError(1, 1); @@ -587,14 +611,18 @@ bool Approx_CurveOnSurface::isIsoLine(const occ::handle& theC { occ::handle aBSpline2d = theC2D->BSpline(); if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2) + { return false; // Not a line or uneven parameterization. + } aLoc2d = aBSpline2d->Pole(1); // Vector should be non-degenerated. gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2)); if (aVec2d.SquareMagnitude() < Precision::Confusion()) + { return false; // Degenerated spline. + } aDir2d = aVec2d; isAppropriateType = true; @@ -603,21 +631,27 @@ bool Approx_CurveOnSurface::isIsoLine(const occ::handle& theC { occ::handle aBezier2d = theC2D->Bezier(); if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2) + { return false; // Not a line or uneven parameterization. + } aLoc2d = aBezier2d->Pole(1); // Vector should be non-degenerated. gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2)); if (aVec2d.SquareMagnitude() < Precision::Confusion()) + { return false; // Degenerated spline. + } aDir2d = aVec2d; isAppropriateType = true; } if (!isAppropriateType) + { return false; + } // Check line to be vertical or horizontal. if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular())) @@ -652,10 +686,14 @@ bool Approx_CurveOnSurface::buildC3dOnIsoLine(const occ::handle aGeomAdapter = occ::down_cast(mySurf); if (aGeomAdapter.IsNull()) + { return false; + } if (mySurf->GetType() == GeomAbs_Sphere) + { return false; + } // Extract isoline occ::handle aSurf = aGeomAdapter->Surface(); @@ -696,7 +734,9 @@ bool Approx_CurveOnSurface::buildC3dOnIsoLine(const occ::handleUIso(theParam); if (isToTrim) + { aC3d = new Geom_TrimmedCurve(aC3d, aV1Param, aV2Param); + } } else { @@ -726,13 +766,17 @@ bool Approx_CurveOnSurface::buildC3dOnIsoLine(const occ::handleVIso(theParam); if (isToTrim) + { aC3d = new Geom_TrimmedCurve(aC3d, aU1Param, aU2Param); + } } // Convert arbitrary curve type to the b-spline. myCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular); if (!theIsForward) + { myCurve3d->Reverse(); + } // Rebuild parameterization for the 3d curve to have the same parameterization with // a two-dimensional curve. diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_CurvilinearParameter.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_CurvilinearParameter.cxx index 24ddfb2719..ebaa612855 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_CurvilinearParameter.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_CurvilinearParameter.cxx @@ -122,7 +122,9 @@ void Approx_CurvilinearParameter_EvalCurv::Evaluate(int* Dimension, } for (i = 0; i <= 2; i++) + { Result[i] = Res(i); + } } Approx_CurvilinearParameter::Approx_CurvilinearParameter(const occ::handle& C3D, @@ -275,7 +277,9 @@ void Approx_CurvilinearParameter_EvalCurvOnSurf::Evaluate(int* Dimension, } for (i = 0; i <= 4; i++) + { Result[i] = Res(i); + } } Approx_CurvilinearParameter::Approx_CurvilinearParameter(const occ::handle& C2D, @@ -364,10 +368,14 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const occ::handle> Knots = aApprox.Knots(); occ::handle> Mults = aApprox.Multiplicities(); int Degree = aApprox.Degree(); @@ -450,7 +458,9 @@ void Approx_CurvilinearParameter_EvalCurvOn2Surf::Evaluate(int* Dimension, } for (i = 0; i <= 6; i++) + { Result[i] = Res(i); + } } Approx_CurvilinearParameter::Approx_CurvilinearParameter( @@ -545,10 +555,14 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter( aApprox.Poles(1, Poles); aApprox.Poles1d(1, Poles1d); for (i = 1; i <= NbPoles; i++) + { Poles2d(i).SetX(Poles1d(i)); + } aApprox.Poles1d(2, Poles1d); for (i = 1; i <= NbPoles; i++) + { Poles2d(i).SetY(Poles1d(i)); + } occ::handle> Knots = aApprox.Knots(); occ::handle> Mults = aApprox.Multiplicities(); int Degree = aApprox.Degree(); @@ -556,10 +570,14 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter( myCurve2d1 = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree); aApprox.Poles1d(3, Poles1d); for (i = 1; i <= NbPoles; i++) + { Poles2d(i).SetX(Poles1d(i)); + } aApprox.Poles1d(4, Poles1d); for (i = 1; i <= NbPoles; i++) + { Poles2d(i).SetY(Poles1d(i)); + } myCurve2d2 = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree); } myMaxError2d1 = std::max(aApprox.MaxError(1, 1), aApprox.MaxError(1, 2)); @@ -648,12 +666,16 @@ double Approx_CurvilinearParameter::MaxError2d2() const void Approx_CurvilinearParameter::Dump(Standard_OStream& o) const { - o << "Dump of Approx_CurvilinearParameter" << std::endl; + o << "Dump of Approx_CurvilinearParameter" << '\n'; if (myCase == 2 || myCase == 3) - o << "myMaxError2d1 = " << myMaxError2d1 << std::endl; + { + o << "myMaxError2d1 = " << myMaxError2d1 << '\n'; + } if (myCase == 3) - o << "myMaxError2d2 = " << myMaxError2d2 << std::endl; - o << "myMaxError3d = " << myMaxError3d << std::endl; + { + o << "myMaxError2d2 = " << myMaxError2d2 << '\n'; + } + o << "myMaxError3d = " << myMaxError3d << '\n'; } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_CurvlinFunc.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_CurvlinFunc.cxx index 87a8d1cff5..4b40a1c88b 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_CurvlinFunc.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_CurvlinFunc.cxx @@ -72,12 +72,18 @@ static void findfourpoints(const double, int i, j; int NbInt = Si->Length() - 1; if (NbInt < 3) + { throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter"); + } if (NInterval < 1) + { NInterval = 1; + } else if (NInterval > NbInt - 2) + { NInterval = NbInt - 2; + } for (i = 0; i < 4; i++) { @@ -247,7 +253,9 @@ void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C, double Len = Si->Value(Si->Upper()); for (i = Si->Lower(); i <= Si->Upper(); i++) + { Si->ChangeValue(i) /= Len; + } // TODO - fields should be mutable const_cast(this)->myPrevS = myFirstS; @@ -335,19 +343,27 @@ void Approx_CurvlinFunc::Intervals(NCollection_Array1& T, const GeomAbs_ GeomLib::FuseIntervals(T1, T2, Fusion); for (i = 1; i <= Fusion.Length(); i++) + { T.ChangeValue(i) = Fusion.Value(i); + } } for (i = 1; i <= T.Length(); i++) + { T.ChangeValue(i) = GetSParameter(T.Value(i)); + } } void Approx_CurvlinFunc::Trim(const double First, const double Last, const double Tol) { if (First < 0 || Last > 1) + { throw Standard_OutOfRange("Approx_CurvlinFunc::Trim"); + } if ((Last - First) < Tol) + { return; + } double FirstU, LastU; Adaptor3d_CurveOnSurface CurOnSur; @@ -483,16 +499,22 @@ double Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C, InitChron(chr_uparam); #endif if (S < 0 || S > 1) + { throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter"); + } if (NumberOfCurve == 1) { InitUArray = myUi_1; InitSArray = mySi_1; if (myCase == 3) + { Length = myLength1; + } else + { Length = myLength; + } } else { @@ -504,13 +526,17 @@ double Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C, NbInt = InitUArray->Length() - 1; if (S == 1) + { NInterval = NbInt - 1; + } else { for (i = 0; i < NbInt; i++) { if ((InitSArray->Value(i) <= S && S < InitSArray->Value(i + 1))) + { break; + } } NInterval = i; } @@ -559,7 +585,9 @@ bool Approx_CurvlinFunc::EvalCase1(const double S, NCollection_Array1& Result) const { if (myCase != 1) + { throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase1"); + } gp_Pnt C; gp_Vec dC_dU, dC_dS, d2C_dU2, d2C_dS2; @@ -613,7 +641,9 @@ bool Approx_CurvlinFunc::EvalCase2(const double S, NCollection_Array1& Result) const { if (myCase != 2) + { throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase2"); + } bool Done; @@ -627,7 +657,9 @@ bool Approx_CurvlinFunc::EvalCase3(const double S, NCollection_Array1& Result) { if (myCase != 3) + { throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase3"); + } NCollection_Array1 tmpRes1(0, 4), tmpRes2(0, 4); bool Done; @@ -663,9 +695,13 @@ bool Approx_CurvlinFunc::EvalCurOnSur(const double S, Adaptor3d_CurveOnSurface CurOnSur(myC2D1, mySurf1); U = GetUParameter(CurOnSur, S, 1); if (myCase == 3) + { Length = myLength1; + } else + { Length = myLength; + } } else if (NumberOfCurve == 2) { @@ -676,7 +712,9 @@ bool Approx_CurvlinFunc::EvalCurOnSur(const double S, Length = myLength2; } else + { throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCurOnSur"); + } double Mag, dU_dS, d2U_dS2, dV_dU, dW_dU, dV_dS, dW_dS, d2V_dS2, d2W_dS2, d2V_dU2, d2W_dU2; gp_Pnt2d C2D; diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_MCurvesToBSpCurve.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_MCurvesToBSpCurve.cxx index 1b8509e548..5544869e0b 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_MCurvesToBSpCurve.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_MCurvesToBSpCurve.cxx @@ -181,27 +181,39 @@ void Approx_MCurvesToBSpCurve::Perform(const NCollection_Sequence Toler) + { param -= func / func_derivative; + } param = std::max(param, Curve.FirstParameter()); param = std::min(param, Curve.LastParameter()); @@ -210,9 +212,13 @@ static bool Check(const NCollection_Array1& FlatKnots, double FirstPar = cons.FirstParameter(); double LastPar = cons.LastParameter(); if (aParamFirst < FirstPar) + { aParamFirst = FirstPar; + } if (aParamLast > LastPar) + { aParamLast = LastPar; + } double d2 = 0.0; // Maximum square deviation on the samples. const double d = tol; @@ -238,7 +244,9 @@ static bool Check(const NCollection_Array1& FlatKnots, gp_Pnt Pcons = cons.Value(tcons); double temp = Pc3d.SquareDistance(Pcons); if (temp > d2) + { d2 = temp; + } } tol = sqrt(d2); @@ -249,7 +257,9 @@ static bool Check(const NCollection_Array1& FlatKnots, const double aCurrentParam = Poles(i); if (aPreviousParam > aCurrentParam) + { return false; + } } return (tol <= d || tol > 0.8 * oldtol); @@ -381,7 +391,9 @@ void Approx_SameParameter::Build(const double Tolerance) // The loop is organized over number of poles. GeomAbs_Shape aContinuity = myHCurve2d->Continuity(); if (aContinuity > GeomAbs_C1) + { aContinuity = GeomAbs_C1; + } double besttol2 = aData.myTol * aData.myTol, tolsov = Precision::Infinite(); bool interpolok = false, hasCountChanged = false; @@ -462,7 +474,9 @@ void Approx_SameParameter::Build(const double Tolerance) } if (!interpolok) + { hasCountChanged = IncreaseNbPoles(Poles, FlatKnots, aData, besttol2); + } } while (!interpolok && hasCountChanged); if (!myDone) @@ -579,9 +593,13 @@ bool Approx_SameParameter::IncreaseInitialNbSamples(Approx_SameParameter_Data& t int inter = 1; while (inter <= NbInt && aC1Intervals(inter) <= theData.myC3dPF + myDeltaMin) + { inter++; + } while (NbInt > 0 && aC1Intervals(NbInt) >= theData.myC3dPL - myDeltaMin) + { NbInt--; + } // Compute new parameters. NCollection_Sequence aNewPar; @@ -670,7 +688,9 @@ bool Approx_SameParameter::CheckSameParameter(Approx_SameParameter_Data& theData if (isUseParam) { if (dmax2 < dist2) + { dmax2 = dist2; + } initp = previousp = theData.myPC3d[count] = theData.myPC3d[ii]; theData.myPC2d[count] = theData.myPC2d[ii]; count++; @@ -679,7 +699,9 @@ bool Approx_SameParameter::CheckSameParameter(Approx_SameParameter_Data& theData // Local search: local extrema and iterative projection algorithm. if (!isProjOk) + { initp = theData.myPC3d[ii]; + } isProjOk = isSameParam = false; Projector.Perform(Pcons, initp); if (Projector.IsDone()) @@ -705,8 +727,10 @@ bool Approx_SameParameter::CheckSameParameter(Approx_SameParameter_Data& theData // Whole parameter space search using general extrema. Extrema_ExtPC PR(Pcons, *myC3d, theData.myC3dPF, theData.myC3dPL, theData.myTol); - if (!PR.IsDone() || PR.NbExt() == 0) // Lazy evaluation is used. + if (!PR.IsDone() || PR.NbExt() == 0) + { // Lazy evaluation is used. continue; + } const int aNbExt = PR.NbExt(); int anIndMin = 0; @@ -758,9 +782,13 @@ bool Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSurface& theCO myC3d->D1(aParamFirst, aPnt, aVec); double aMagnitude = aVecConS.Magnitude(); if (aMagnitude > aSmallMagnitude) + { theFirstTangent = aVec.Magnitude() / aMagnitude; + } else + { return false; + } // Last point. const double aParamLast = myC3d->LastParameter(); @@ -769,9 +797,13 @@ bool Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSurface& theCO aMagnitude = aVecConS.Magnitude(); if (aMagnitude > aSmallMagnitude) + { theLastTangent = aVec.Magnitude() / aMagnitude; + } else + { return false; + } return true; } @@ -846,7 +878,9 @@ bool Approx_SameParameter::IncreaseNbPoles(const NCollection_Array1& the newcount++; if (theData.myNbPnt - ii + newcount == myMaxArraySize) + { continue; + } BSplCLib::Eval(0.5 * (theData.myPC3d[ii] + theData.myPC3d[ii + 1]), false, @@ -871,7 +905,9 @@ bool Approx_SameParameter::IncreaseNbPoles(const NCollection_Array1& the curp = Projector.Point().Parameter(); double dist_2 = Projector.SquareDistance(); if (dist_2 > theBestSqTol) + { theBestSqTol = dist_2; + } projok = true; } else @@ -908,7 +944,9 @@ bool Approx_SameParameter::IncreaseNbPoles(const NCollection_Array1& the newcount++; if (theData.myNbPnt - n + newcount == myMaxArraySize) + { continue; + } double ucons = 0.5 * (theData.myPC2d[n] + theData.myPC2d[n + 1]); double uc3d = 0.5 * (theData.myPC3d[n] + theData.myPC3d[n + 1]); @@ -921,7 +959,9 @@ bool Approx_SameParameter::IncreaseNbPoles(const NCollection_Array1& the curp = Projector.Point().Parameter(); double dist_2 = Projector.SquareDistance(); if (dist_2 > theBestSqTol) + { theBestSqTol = dist_2; + } projok = true; } else diff --git a/src/ModelingData/TKGeomBase/Approx/Approx_SweepApproximation.cxx b/src/ModelingData/TKGeomBase/Approx/Approx_SweepApproximation.cxx index 5cac28d076..c0957dd0be 100644 --- a/src/ModelingData/TKGeomBase/Approx/Approx_SweepApproximation.cxx +++ b/src/ModelingData/TKGeomBase/Approx/Approx_SweepApproximation.cxx @@ -101,8 +101,12 @@ void Approx_SweepApproximation::Perform(const double First, myFunc->GetTolerance(BoundTol, Tol3d, TolAngular, ThreeDTol->ChangeArray1()); for (ii = 1; ii <= Num3DSS; ii++) + { if (ThreeDTol->Value(ii) < Tol3dMin) + { Tol3dMin = ThreeDTol->Value(ii); + } + } if (myFunc->IsRational()) { @@ -198,7 +202,9 @@ void Approx_SweepApproximation::Perform(const double First, myDWeigths->ChangeArray1(), myD2Weigths->ChangeArray1()); if (!B) + { continuity = GeomAbs_C1; + } } // Checks if myFunc->D1 is implemented if (continuity == GeomAbs_C1) @@ -214,7 +220,9 @@ void Approx_SweepApproximation::Perform(const double First, myWeigths->ChangeArray1(), myDWeigths->ChangeArray1()); if (!B) + { continuity = GeomAbs_C0; + } } // So that F was at least 20 times more exact than its approx @@ -725,7 +733,9 @@ double Approx_SweepApproximation::MaxErrorOnSurf() const { err = (Size * MError1d->Value(ii) + MError3d->Value(ii)) / Wmin(ii); if (err > MaxError) + { MaxError = err; + } } } else @@ -734,7 +744,9 @@ double Approx_SweepApproximation::MaxErrorOnSurf() const { err = MError3d->Value(ii); if (err > MaxError) + { MaxError = err; + } } } return MaxError; @@ -833,10 +845,10 @@ double Approx_SweepApproximation::TolCurveOnSurf(const int Index) const void Approx_SweepApproximation::Dump(Standard_OStream& o) const { - o << "Dump of SweepApproximation" << std::endl; + o << "Dump of SweepApproximation" << '\n'; if (done) { - o << "Error 3d = " << MaxErrorOnSurf() << std::endl; + o << "Error 3d = " << MaxErrorOnSurf() << '\n'; if (Num2DSS > 0) { @@ -845,12 +857,16 @@ void Approx_SweepApproximation::Dump(Standard_OStream& o) const { o << Max2dError(ii); if (ii < Num2DSS) - o << " , " << std::endl; + { + o << " , " << '\n'; + } } - std::cout << std::endl; + std::cout << '\n'; } - o << tabVKnots->Length() - 1 << " Segment(s) of degree " << vdeg << std::endl; + o << tabVKnots->Length() - 1 << " Segment(s) of degree " << vdeg << '\n'; } else - std::cout << " Not Done " << std::endl; + { + std::cout << " Not Done " << '\n'; + } } diff --git a/src/ModelingData/TKGeomBase/BndLib/BndLib.cxx b/src/ModelingData/TKGeomBase/BndLib/BndLib.cxx index a4e7bdfd7c..ab55bebcf8 100644 --- a/src/ModelingData/TKGeomBase/BndLib/BndLib.cxx +++ b/src/ModelingData/TKGeomBase/BndLib/BndLib.cxx @@ -151,23 +151,35 @@ static void OpenMin(const gp_Dir& V, Bnd_Box& B) if (V.IsParallel(gp::DX(), Precision::Angular())) { if (V.X() > 0.) + { B.OpenXmin(); + } else + { B.OpenXmax(); + } } else if (V.IsParallel(gp::DY(), Precision::Angular())) { if (V.Y() > 0.) + { B.OpenYmin(); + } else + { B.OpenYmax(); + } } else if (V.IsParallel(gp::DZ(), Precision::Angular())) { if (V.Z() > 0.) + { B.OpenZmin(); + } else + { B.OpenZmax(); + } } else { @@ -186,23 +198,35 @@ static void OpenMax(const gp_Dir& V, Bnd_Box& B) if (V.IsParallel(gp::DX(), Precision::Angular())) { if (V.X() > 0.) + { B.OpenXmax(); + } else + { B.OpenXmin(); + } } else if (V.IsParallel(gp::DY(), Precision::Angular())) { if (V.Y() > 0.) + { B.OpenYmax(); + } else + { B.OpenYmin(); + } } else if (V.IsParallel(gp::DZ(), Precision::Angular())) { if (V.Z() > 0.) + { B.OpenZmax(); + } else + { B.OpenZmin(); + } } else { @@ -249,16 +273,24 @@ static void OpenMin(const gp_Dir2d& V, Bnd_Box2d& B) if (V.IsParallel(gp::DX2d(), Precision::Angular())) { if (V.X() > 0.) + { B.OpenXmin(); + } else + { B.OpenXmax(); + } } else if (V.IsParallel(gp::DY2d(), Precision::Angular())) { if (V.Y() > 0.) + { B.OpenYmin(); + } else + { B.OpenYmax(); + } } else { @@ -276,16 +308,24 @@ static void OpenMax(const gp_Dir2d& V, Bnd_Box2d& B) if (V.IsParallel(gp::DX2d(), Precision::Angular())) { if (V.X() > 0.) + { B.OpenXmax(); + } else + { B.OpenXmin(); + } } else if (V.IsParallel(gp::DY2d(), Precision::Angular())) { if (V.Y() > 0.) + { B.OpenYmax(); + } else + { B.OpenYmin(); + } } else { @@ -871,7 +911,9 @@ void BndLib::Add(const gp_Parab& P, const double P1, const double P2, const doub { B.Add(ElCLib::Value(P2, P)); if (P1 * P2 < 0) + { B.Add(ElCLib::Value(0., P)); + } } } B.Enlarge(Tol); @@ -937,7 +979,9 @@ void BndLib::Add(const gp_Parab2d& P, { B.Add(ElCLib::Value(P2, P)); if (P1 * P2 < 0) + { B.Add(ElCLib::Value(0., P)); + } } } B.Enlarge(Tol); @@ -1070,7 +1114,9 @@ void BndLib::Add(const gp_Hypr2d& H, { B.Add(ElCLib::Value(P2, H)); if (P1 * P2 < 0) + { B.Add(ElCLib::Value(0., H)); + } } } B.Enlarge(Tol); @@ -1519,7 +1565,9 @@ void BndLib::Add(const gp_Torus& S, const double Ri = S.MinorRadius(); if (Fi2 < Fi1) + { return; + } if (Ra < Ri) { diff --git a/src/ModelingData/TKGeomBase/CPnts/CPnts_MyRootFunction.cxx b/src/ModelingData/TKGeomBase/CPnts/CPnts_MyRootFunction.cxx index 7d8e51f5b5..6fe78c1d13 100644 --- a/src/ModelingData/TKGeomBase/CPnts/CPnts_MyRootFunction.cxx +++ b/src/ModelingData/TKGeomBase/CPnts/CPnts_MyRootFunction.cxx @@ -41,9 +41,13 @@ bool CPnts_MyRootFunction::Value(const double X, double& F) math_GaussSingleIntegration Length; if (myTol <= 0) + { Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder); + } else + { Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol); + } if (Length.IsDone()) { @@ -66,9 +70,13 @@ bool CPnts_MyRootFunction::Values(const double X, double& F, double& Df) math_GaussSingleIntegration Length; if (myTol <= 0) + { Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder); + } else + { Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol); + } if (Length.IsDone()) { diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_CurveTool.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_CurveTool.cxx index 29559c99d8..705fa056f7 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_CurveTool.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_CurveTool.cxx @@ -27,9 +27,13 @@ bool Extrema_CurveTool::IsPeriodic(const Adaptor3d_Curve& C) { GeomAbs_CurveType aType = GetType(C); if (aType == GeomAbs_Circle || aType == GeomAbs_Ellipse) + { return true; + } else + { return C.IsPeriodic(); + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC.cxx index 7f7f6ef0b9..135a99b244 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC.cxx @@ -195,30 +195,54 @@ void Extrema_ExtCC::Perform() U22 = mySup[1]; if (!Precision::IsInfinite(U11)) + { myP1f = Extrema_CurveTool::Value(*myC[0], U11); + } if (!Precision::IsInfinite(U12)) + { myP1l = Extrema_CurveTool::Value(*myC[0], U12); + } if (!Precision::IsInfinite(U21)) + { myP2f = Extrema_CurveTool::Value(*myC[1], U21); + } if (!Precision::IsInfinite(U22)) + { myP2l = Extrema_CurveTool::Value(*myC[1], U22); + } if (Precision::IsInfinite(U11) || Precision::IsInfinite(U21)) + { mydist11 = RealLast(); + } else + { mydist11 = myP1f.SquareDistance(myP2f); + } if (Precision::IsInfinite(U11) || Precision::IsInfinite(U22)) + { mydist12 = RealLast(); + } else + { mydist12 = myP1f.SquareDistance(myP2l); + } if (Precision::IsInfinite(U12) || Precision::IsInfinite(U21)) + { mydist21 = RealLast(); + } else + { mydist21 = myP1l.SquareDistance(myP2f); + } if (Precision::IsInfinite(U12) || Precision::IsInfinite(U22)) + { mydist22 = RealLast(); + } else + { mydist22 = myP1l.SquareDistance(myP2l); + } // Depending on the types of curves, the algorithm is chosen: //- _ExtElC, when one of the curves is a line and the other is elementary, @@ -316,7 +340,9 @@ bool Extrema_ExtCC::IsParallel() const double Extrema_ExtCC::SquareDistance(const int N) const { if ((N < 1) || (N > NbExt())) + { throw Standard_OutOfRange(); + } return mySqDist.Value(N); } @@ -325,7 +351,9 @@ double Extrema_ExtCC::SquareDistance(const int N) const int Extrema_ExtCC::NbExt() const { if (!myDone) + { throw StdFail_NotDone(); + } return mySqDist.Length(); } @@ -373,7 +401,9 @@ void Extrema_ExtCC::PrepareParallelResult(const double theUt11, const double theSqDist) { if (!myIsParallel) + { return; + } const GeomAbs_CurveType aType1 = Extrema_CurveTool::GetType(*myC[0]); const GeomAbs_CurveType aType2 = Extrema_CurveTool::GetType(*myC[1]); @@ -447,9 +477,13 @@ void Extrema_ExtCC::PrepareParallelResult(const double theUt11, if (Precision::IsInfinite(theUt11)) { if (isOpposite) + { aProjRng12.Add(Precision::Infinite()); + } else + { aProjRng12.Add(-Precision::Infinite()); + } } else { @@ -461,9 +495,13 @@ void Extrema_ExtCC::PrepareParallelResult(const double theUt11, if (Precision::IsInfinite(theUt12)) { if (isOpposite) + { aProjRng12.Add(-Precision::Infinite()); + } else + { aProjRng12.Add(Precision::Infinite()); + } } else { diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC2d.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC2d.cxx index 113c67e362..e5a2796966 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC2d.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCC2d.cxx @@ -170,7 +170,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2); } break; @@ -230,7 +232,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2); } break; @@ -294,7 +298,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, 0., Period2); } break; @@ -357,7 +363,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, 0., Period2); } break; @@ -411,7 +419,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, 0., Period2); } break; @@ -428,10 +438,14 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1, const double U1, cons aParamSolver->Perform(); double Period1 = 0.; if (Extrema_Curve2dTool::IsPeriodic(C1)) + { Period1 = Extrema_Curve2dTool::Period(C1); + } double Period2 = 0.; if (Extrema_Curve2dTool::IsPeriodic(*myC)) + { Period2 = Extrema_Curve2dTool::Period(*myC); + } Results(*aParamSolver, U11, U12, U21, U22, Period1, Period2); } break; @@ -450,9 +464,13 @@ bool Extrema_ExtCC2d::IsDone() const double Extrema_ExtCC2d::SquareDistance(const int N) const { if (!myDone) + { throw StdFail_NotDone(); + } if ((N <= 0) || (N > mynbext)) + { throw Standard_OutOfRange(); + } return mySqDist.Value(N); } @@ -461,7 +479,9 @@ double Extrema_ExtCC2d::SquareDistance(const int N) const int Extrema_ExtCC2d::NbExt() const { if (!myDone) + { throw StdFail_NotDone(); + } return mynbext; } @@ -470,9 +490,13 @@ int Extrema_ExtCC2d::NbExt() const void Extrema_ExtCC2d::Points(const int N, Extrema_POnCurv2d& P1, Extrema_POnCurv2d& P2) const { if (!myDone) + { throw StdFail_NotDone(); + } if ((N <= 0) || (N > mynbext)) + { throw Standard_OutOfRange(); + } P1 = mypoints.Value(2 * N - 1); P2 = mypoints.Value(2 * N); } @@ -527,19 +551,27 @@ void Extrema_ExtCC2d::Results(const Extrema_ExtElC2d& AlgExt, { U = P1.Parameter(); if (Period1 != 0.0) + { U = ElCLib::InPeriod(U, Ut11, Ut11 + Period1); + } U2 = P2.Parameter(); if (Period2 != 0.0) + { U2 = ElCLib::InPeriod(U2, Ut21, Ut21 + Period2); + } } else { U2 = P1.Parameter(); if (Period2 != 0.0) + { U2 = ElCLib::InPeriod(U2, Ut21, Ut21 + Period2); + } U = P2.Parameter(); if (Period1 != 0.0) + { U = ElCLib::InPeriod(U, Ut11, Ut11 + Period1); + } } if ((U >= Ut11 - Precision::PConfusion()) && (U <= Ut12 + Precision::PConfusion()) && (U2 >= Ut21 - Precision::PConfusion()) && (U2 <= Ut22 + Precision::PConfusion())) @@ -597,10 +629,14 @@ void Extrema_ExtCC2d::Results(const Extrema_ECC2d& AlgExt, AlgExt.Points(i, P1, P2); U = P1.Parameter(); if (Period1 != 0.0) + { U = ElCLib::InPeriod(U, Ut11, Ut11 + Period1); + } U2 = P2.Parameter(); if (Period2 != 0.0) + { U2 = ElCLib::InPeriod(U2, Ut21, Ut21 + Period2); + } if ((U >= Ut11 - Precision::PConfusion()) && (U <= Ut12 + Precision::PConfusion()) && (U2 >= Ut21 - Precision::PConfusion()) && (U2 <= Ut22 + Precision::PConfusion())) @@ -627,7 +663,9 @@ void Extrema_ExtCC2d::Results(const Extrema_ECC2d& AlgExt, bool Extrema_ExtCC2d::IsParallel() const { if (!myDone) + { throw StdFail_NotDone(); + } return myIsPar; } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCS.cxx index 56619b91de..a042c60631 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtCS.cxx @@ -139,7 +139,9 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d case GeomAbs_Plane: myExtElCS.Perform(C.Line(), myS->Plane()); if (myExtElCS.IsParallel()) + { break; + } [[fallthrough]]; case GeomAbs_Torus: @@ -192,9 +194,13 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d } if (myS->IsUPeriodic()) + { NbU = 13; + } if (myS->IsVPeriodic()) + { NbV = 13; + } if (clast - cfirst <= Precision::Confusion()) { @@ -322,7 +328,9 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d for (i = 0; i < 2; ++i) { if (Precision::IsInfinite(aT[i])) + { continue; + } aPOnC[i] = C.Value(aT[i]); switch (myStype) @@ -367,26 +375,38 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d double aDiff = aDist[0] - aDist[1]; // Both computed -> take only minimal if (std::abs(aDiff) < Precision::Confusion()) + { // Add both bAdd[0] = bAdd[1] = true; + } else if (aDiff < 0) + { // Add first bAdd[0] = true; + } else + { // Add second bAdd[1] = true; + } } else if (aDist[0] >= 0.) + { // Add first bAdd[0] = true; + } else if (aDist[1] >= 0.) + { // Add second bAdd[1] = true; + } for (i = 0; i < 2; ++i) { if (bAdd[i]) + { AddSolution(C, aT[i], U[i], V[i], aPOnC[i], aPOnS[i], aDist[i]); + } } } } @@ -451,7 +471,9 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d gp_Pnt aPnt = C.Value(T); aProjPS.Perform(aPnt); if (!aProjPS.IsDone()) + { continue; + } int NbProj = aProjPS.NbExt(), jmin = 0; double MinSqDist = RealLast(); for (j = 1; j <= NbProj; j++) @@ -474,9 +496,13 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, const double Uinf, const d for (i = SolNumber + 1; i <= mySqDist.Length(); i++) { if (mySqDist(i) < mySqDist(imin)) + { imin = i; + } if (mySqDist(i) > mySqDist(imax)) + { imax = i; + } } if (mySqDist.Length() > SolNumber + 2) { @@ -560,11 +586,17 @@ bool Extrema_ExtCS::AddSolution(const Adaptor3d_Curve& theCurve, double T = aT, U = aU, V = aV; if (theCurve.IsPeriodic()) + { T = ElCLib::InPeriod(T, myucinf, myucinf + theCurve.Period()); + } if (myS->IsUPeriodic()) + { U = ElCLib::InPeriod(U, myuinf, myuinf + myS->UPeriod()); + } if (myS->IsVPeriodic()) + { V = ElCLib::InPeriod(V, myvinf, myvinf + myS->VPeriod()); + } Extrema_POnCurv aPC; Extrema_POnSurf aPS; diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC.cxx index 4d7944acd0..d6637e1810 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC.cxx @@ -363,7 +363,9 @@ bool Extrema_ExtElC::PlanarLineCircleExtrema(const gp_Lin& theLin, const gp_Circ const gp_Dir &aDirC = theCirc.Axis().Direction(), &aDirL = theLin.Direction(); if (std::abs(aDirC.Dot(aDirL)) > Precision::Angular()) + { return false; + } // The line is in the circle-plane completely //(or parallel to the circle-plane). @@ -397,7 +399,9 @@ bool Extrema_ExtElC::PlanarLineCircleExtrema(const gp_Lin& theLin, const gp_Circ myDone = anExt2d.IsDone() || anInters.IsDone(); if (!myDone) + { return true; + } const int aNbExtr = anExt2d.NbExt(); const int aNbSol = anInters.NbPoints(); @@ -694,15 +698,25 @@ Extrema_ExtElC::Extrema_ExtElC(const gp_Lin& C1, const gp_Elips& C2) double aEps = 1.e-12; // if (fabs(A5) <= aEps) + { A5 = 0.; + } if (fabs(A1) <= aEps) + { A1 = 0.; + } if (fabs(A2) <= aEps) + { A2 = 0.; + } if (fabs(A3) <= aEps) + { A3 = 0.; + } if (fabs(A4) <= aEps) + { A4 = 0.; + } // ExtremaExtElC_TrigonometricRoots Sol(A1, A2, A3, A4, A5, 0., M_PI + M_PI); if (!Sol.IsDone()) diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC2d.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC2d.cxx index 948dabcef3..3c8a57e1ea 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC2d.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElC2d.cxx @@ -139,10 +139,14 @@ Method: teta[0] = M_PI / 2.0; } else + { teta[0] = std::atan(-Dx / Dy); + } teta[1] = teta[0] + M_PI; if (teta[0] < 0.0) + { teta[0] = teta[0] + 2.0 * M_PI; + } P2 = ElCLib::Value(teta[0], C2); U1 = (gp_Vec2d(O1, P2)).Dot(D); @@ -190,11 +194,15 @@ Extrema_ExtElC2d::Extrema_ExtElC2d(const gp_Lin2d& C1, const gp_Elips2d& C2) teta[0] = M_PI / 2.0; } else + { teta[0] = std::atan(-Dx * r2 / (Dy * r1)); + } teta[1] = teta[0] + M_PI; if (teta[0] < 0.0) + { teta[0] += 2.0 * M_PI; + } P2 = ElCLib::Value(teta[0], C2); U1 = (gp_Vec2d(O1, P2)).Dot(D); P1 = ElCLib::Value(U1, C1); @@ -240,11 +248,15 @@ Extrema_ExtElC2d::Extrema_ExtElC2d(const gp_Lin2d& C1, const gp_Hypr2d& C2) return; } if (std::abs(R - r * Dx / Dy) < RealEpsilon()) + { return; + } v2 = (R + r * Dx / Dy) / (R - r * Dx / Dy); if (v2 > 0.0) + { U2 = std::log(std::sqrt(v2)); + } P2 = ElCLib::Value(U2, C2); U1 = (gp_Vec2d(C1.Location(), P2)).Dot(D); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElCS.cxx index bb4eb92797..e1a5d01096 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElCS.cxx @@ -257,7 +257,9 @@ void Extrema_ExtElCS::Perform(const gp_Lin& C, const gp_Sphere& S) myPoint2 = new NCollection_HArray1(1, myNbExt); } else + { myNbExt += ExPS.NbExt(); + } for (i = aStartIdx + 1; i <= myNbExt; i++) { @@ -408,7 +410,9 @@ void Extrema_ExtElCS::Perform(const gp_Circ& C, const gp_Cylinder& S) Extrema_ExtElC anExtC(anAxis, C, 0.); if (!anExtC.IsDone()) + { return; + } bool isParallel = false; @@ -585,8 +589,10 @@ void Extrema_ExtElCS::Perform(const gp_Circ& C, const gp_Sphere& S) gp_Pln CPln(C.Location(), C.Axis().Direction()); IntAna_QuadQuadGeo anInter(CPln, S); if (!anInter.IsDone()) + { // not done return; + } if (anInter.TypeInter() != IntAna_Circle) { @@ -631,8 +637,10 @@ void Extrema_ExtElCS::Perform(const gp_Circ& C, const gp_Sphere& S) && anExtC.NbExt() > 0; // Check that some solutions have been found // clang-format on if (!isExtremaCircCircValid) + { // not done return; + } myDone = true; @@ -644,7 +652,9 @@ void Extrema_ExtElCS::Perform(const gp_Circ& C, const gp_Sphere& S) { double aSqDist = anExtC.SquareDistance(i); if (aSqDist < aMinSqDist) + { aMinSqDist = aSqDist; + } } // Collect all solutions close to the minimal one @@ -653,7 +663,9 @@ void Extrema_ExtElCS::Perform(const gp_Circ& C, const gp_Sphere& S) { double aDiff = anExtC.SquareDistance(i) - aMinSqDist; if (aDiff < Precision::SquareConfusion()) + { aSols.Append(i); + } } // Save all minimal solutions @@ -757,7 +769,9 @@ bool Extrema_ExtElCS::IsDone() const int Extrema_ExtElCS::NbExt() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return myNbExt; } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElSS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElSS.cxx index fdfb1b59b8..416f52bec3 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElSS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtElSS.cxx @@ -135,14 +135,18 @@ bool Extrema_ExtElSS::IsDone() const bool Extrema_ExtElSS::IsParallel() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return myIsPar; } int Extrema_ExtElSS::NbExt() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return myNbExt; } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElC.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElC.cxx index 6149262269..522fc564ff 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElC.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElC.cxx @@ -139,9 +139,13 @@ Method: constexpr double aAngTol = Precision::Angular(); if (Usol[0] + M_PI < aAngTol) + { Usol[0] = -M_PI; + } else if (Usol[0] - M_PI > -aAngTol) + { Usol[0] = M_PI; + } Usol[1] = Usol[0] + M_PI; @@ -158,9 +162,13 @@ Method: ElCLib::AdjustPeriodic(Uinf, Uinf + 2 * M_PI, TolU, myuinf, Usol[0]); ElCLib::AdjustPeriodic(Uinf, Uinf + 2 * M_PI, TolU, myuinf, Usol[1]); if (((Usol[0] - 2 * M_PI - Uinf) < TolU) && ((Usol[0] - 2 * M_PI - Uinf) > -TolU)) + { Usol[0] = Uinf; + } if (((Usol[1] - 2 * M_PI - Uinf) < TolU) && ((Usol[1] - 2 * M_PI - Uinf) > -TolU)) + { Usol[1] = Uinf; + } // 3- Calculate extrema in [Umin,Umax] ... @@ -245,7 +253,9 @@ Method: double ko2 = (B * B - A * A) / 2., ko3 = -B * Y, ko4 = A * X; if (std::abs(ko3) < 1.e-16 * std::max(std::abs(ko2), std::abs(ko3))) + { ko3 = 0.0; + } // math_TrigonometricFunctionRoots Sol(0.,(B*B-A*A)/2.,-B*Y,A*X,0.,Uinf,Usup); math_TrigonometricFunctionRoots Sol(0., ko2, ko3, ko4, 0., Uinf, Usup); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElS.cxx index d0acd2210a..83c5600672 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPElS.cxx @@ -174,7 +174,9 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, const gp_Cone& S, const double To DirZ = (A < 0 ? -OZ : OZ); } else + { DirZ = gp_Vec(M, O); + } // Projection of P in the reference plane of the cone ... double Zp = gp_Vec(O, P).Dot(OZ); @@ -182,7 +184,9 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P, const gp_Cone& S, const double To gp_Pnt Pp = P.Translated(OZ.Multiplied(-Zp)); gp_Vec OPp(O, Pp); if (OPp.SquareMagnitude() < Tol * Tol) + { return; + } double U1, V1, U2, V2; bool Same = DirZ.Dot(MP) >= 0.0; U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp, myZ); //-M_PI D2prev || D2e > D2next); + } else + { notFound = (D2e < D2prev || D2e < D2next); + } if (notFound && (D2e < D2next && isMin)) { @@ -129,9 +133,13 @@ void Extrema_ExtPExtS::MakePreciser(double& U, Pnext = ProjectPnt(OrtogSection, myDirection, GetValue(U + step, myC)); D2next = P.SquareDistance(Pnext); if (isMin) + { notFound = D2e > D2next; + } else + { notFound = D2e < D2next; + } } } } @@ -279,7 +287,9 @@ void Extrema_ExtPExtS::Perform(const gp_Pnt& P) Extrema_ExtPElC anExt; PerformExtPElC(anExt, Pp, myC, mytolu); if (!anExt.IsDone()) + { return; + } gp_Ax2 anOrtogSection(P, myDirection); double U, V; @@ -425,7 +435,6 @@ void Extrema_ExtPExtS::Perform(const gp_Pnt& P) } } myDone = true; - return; } //============================================================================= @@ -444,9 +453,13 @@ int Extrema_ExtPExtS::NbExt() const throw StdFail_NotDone(); } if (myIsAnalyticallyComputable) + { return myNbExt; + } else + { return myExtPS.NbExt(); + } } //============================================================================= @@ -458,12 +471,16 @@ double Extrema_ExtPExtS::SquareDistance(const int N) const throw Standard_OutOfRange(); } if (myIsAnalyticallyComputable) + { // modified by NIZHNY-MKK Thu Sep 18 14:48:39 2003.BEGIN // return myValue[N]; return mySqDist[N - 1]; - // modified by NIZHNY-MKK Thu Sep 18 14:48:42 2003.END + // modified by NIZHNY-MKK Thu Sep 18 14:48:42 2003.END + } else + { return myExtPS.SquareDistance(N); + } } //============================================================================= @@ -482,7 +499,9 @@ const Extrema_POnSurf& Extrema_ExtPExtS::Point(const int N) const } // modified by NIZHNY-MKK Thu Sep 18 14:47:43 2003.END else + { return myExtPS.Point(N); + } } //============================================================================= diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPRevS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPRevS.cxx index ac87a887da..dc9efcf59b 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPRevS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPRevS.cxx @@ -53,7 +53,9 @@ static gp_Ax2 GetPosition( { OO = gp_Vec(L.Location(), ElCLib::Value(100, L)); if (N.IsParallel(OO, Precision::Angular())) + { return gp_Ax2(); // Line and axe of revolution coincide + } } N ^= OO; } @@ -90,7 +92,9 @@ static bool HasSingularity(const GeomAdaptor_SurfaceOfRevolution& S) P = C->Value(C->FirstParameter()); if (L.SquareDistance(P) < Precision::SquareConfusion()) + { return true; + } P = C->Value(C->LastParameter()); @@ -187,13 +191,17 @@ static bool IsExtremum(const double U, E = S->Value(U, V); Dist2 = P.SquareDistance(E); if (IsMin) + { return (Dist2 < P.SquareDistance(S->Value(U + 1, V)) && Dist2 < P.SquareDistance(S->Value(U - 1, V)) && Dist2 < P.SquareDistance(S->Value(U, IsVSup ? V - 1 : V + 1))); + } else + { return (Dist2 > P.SquareDistance(S->Value(U + 1, V)) && Dist2 > P.SquareDistance(S->Value(U - 1, V)) && Dist2 > P.SquareDistance(S->Value(U, IsVSup ? V - 1 : V + 1))); + } } //================================================================================================= @@ -311,8 +319,10 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) double OPdir = gp_Vec(O, P).Dot(Dir); gp_Pnt Pp = P.Translated(Dir.Multiplied(-OPdir)); - if (O.IsEqual(Pp, Precision::Confusion())) // P is on the AxeOfRevolution + if (O.IsEqual(Pp, Precision::Confusion())) + { // P is on the AxeOfRevolution return; + } double U, V; gp_Pnt P1, Ppp; @@ -326,7 +336,9 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) { Ppp = Pp.Translated(Z.Multiplied(-OPpz)); if (O.IsEqual(Ppp, Precision::Confusion())) + { U = M_PI / 2; + } else { U = gp_Vec(O, Ppp).AngleWithRef(gp_Vec(O, Pp), Dir); @@ -337,9 +349,13 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) if (U != M_PI / 2) { if (std::abs(OPq.Magnitude()) <= gp::Resolution()) + { OPq = gp_Vec(O, myS->Value(M_PI / 2, anACurve->LastParameter() / 10)); + } if (OPpp.AngleWithRef(OPq, Dir) < 0) + { U += M_PI; + } } gp_Trsf T; @@ -419,7 +435,9 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) V = newV; if (!IsExtremum(U, V, P, myS.get(), E, Dist2, false, anExt.IsMin(i))) + { continue; + } } else { @@ -476,7 +494,9 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) V = newV; if (!IsExtremum(U, V, P, myS.get(), E, Dist2, true, anExt.IsMin(i))) + { continue; + } } else if (V < myvinf) { @@ -505,7 +525,9 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P) V = newV; if (!IsExtremum(U, V, P, myS.get(), E, Dist2, false, anExt.IsMin(i))) + { continue; + } } else { @@ -549,9 +571,13 @@ double Extrema_ExtPRevS::SquareDistance(const int N) const throw Standard_OutOfRange(); } if (myIsAnalyticallyComputable) + { return mySqDist[N - 1]; + } else + { return myExtPS.SquareDistance(N); + } } //================================================================================================= @@ -563,7 +589,11 @@ const Extrema_POnSurf& Extrema_ExtPRevS::Point(const int N) const throw Standard_OutOfRange(); } if (myIsAnalyticallyComputable) + { return myPoint[N - 1]; + } else + { return myExtPS.Point(N); + } } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPS.cxx index 67a40d0fda..fcea42c862 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtPS.cxx @@ -62,7 +62,9 @@ static bool IsoIsDeg(const Adaptor3d_Surface& S, } if (D1NormMax > TolMax || D1NormMax < TolMin) + { Along = false; + } } } else @@ -82,7 +84,9 @@ static bool IsoIsDeg(const Adaptor3d_Surface& S, } if (D1NormMax > TolMax || D1NormMax < TolMin) + { Along = false; + } } } return Along; @@ -100,9 +104,13 @@ void Extrema_ExtPS::TreatSolution(const Extrema_POnSurf& PS, const double Val) // Handle trimmed surfaces. if (U > myusup + mytolu) + { U -= myS->UPeriod(); + } if (U < myuinf - mytolu) + { U += myS->UPeriod(); + } } if (myS->IsVPeriodic()) { @@ -110,9 +118,13 @@ void Extrema_ExtPS::TreatSolution(const Extrema_POnSurf& PS, const double Val) // Handle trimmed surfaces. if (V > myvsup + mytolv) + { V -= myS->VPeriod(); + } if (V < myvinf - mytolv) + { V += myS->VPeriod(); + } } if ((myuinf - U) <= mytolu && (U - myusup) <= mytolu && (myvinf - V) <= mytolv && (V - myvsup) <= mytolv) @@ -202,13 +214,21 @@ void Extrema_ExtPS::Initialize(const Adaptor3d_Surface& theS, myvsup = theVsup; if (Precision::IsNegativeInfinite(myuinf)) + { myuinf = -1e10; + } if (Precision::IsPositiveInfinite(myusup)) + { myusup = 1e10; + } if (Precision::IsNegativeInfinite(myvinf)) + { myvinf = -1e10; + } if (Precision::IsPositiveInfinite(myvsup)) + { myvsup = 1e10; + } mytolu = theTolU; mytolv = theTolV; @@ -230,9 +250,13 @@ void Extrema_ExtPS::Initialize(const Adaptor3d_Surface& theS, } if (bUIsoIsDeg) + { nbU = 300; + } if (bVIsoIsDeg) + { nbV = 300; + } myExtPS.Initialize(*myS, nbU, nbV, myuinf, myusup, myvinf, myvsup, mytolu, mytolv); @@ -350,21 +374,27 @@ bool Extrema_ExtPS::IsDone() const double Extrema_ExtPS::SquareDistance(const int N) const { if ((N < 1) || (N > NbExt())) + { throw Standard_OutOfRange(); + } return mySqDist.Value(N); } int Extrema_ExtPS::NbExt() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return mySqDist.Length(); } const Extrema_POnSurf& Extrema_ExtPS::Point(const int N) const { if ((N < 1) || (N > NbExt())) + { throw Standard_OutOfRange(); + } return myPoints.Value(N); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtSS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtSS.cxx index 26e43a48b1..5b83b4d5f8 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtSS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_ExtSS.cxx @@ -143,13 +143,21 @@ void Extrema_ExtSS::Perform(const Adaptor3d_Surface& S1, PS1.Parameter(U1, V1); PS2.Parameter(U2, V2); if (S1.IsUPeriodic()) + { U1 = ElCLib::InPeriod(U1, myuinf1, myuinf1 + S1.UPeriod()); + } if (S1.IsVPeriodic()) + { V1 = ElCLib::InPeriod(V1, myvinf1, myvinf1 + S1.VPeriod()); + } if (myS2->IsUPeriodic()) + { U2 = ElCLib::InPeriod(U2, myuinf2, myuinf2 + myS2->UPeriod()); + } if (myS2->IsVPeriodic()) + { V2 = ElCLib::InPeriod(V2, myvinf2, myvinf2 + myS2->VPeriod()); + } if ((myuinf1 - U1) <= mytolS1 && (U1 - myusup1) <= mytolS1 && (myvinf1 - V1) <= mytolS1 && (V1 - myvsup1) <= mytolS1 @@ -184,13 +192,21 @@ void Extrema_ExtSS::Perform(const Adaptor3d_Surface& S1, PS1.Parameter(U1, V1); PS2.Parameter(U2, V2); if (S1.IsUPeriodic()) + { U1 = ElCLib::InPeriod(U1, myuinf1, myuinf1 + S1.UPeriod()); + } if (S1.IsVPeriodic()) + { V1 = ElCLib::InPeriod(V1, myvinf1, myvinf1 + S1.VPeriod()); + } if (myS2->IsUPeriodic()) + { U2 = ElCLib::InPeriod(U2, myuinf2, myuinf2 + myS2->UPeriod()); + } if (myS2->IsVPeriodic()) + { V2 = ElCLib::InPeriod(V2, myvinf2, myvinf2 + myS2->VPeriod()); + } if ((myuinf1 - U1) <= mytolS1 && (U1 - myusup1) <= mytolS1 && (myvinf1 - V1) <= mytolS1 && (V1 - myvsup1) <= mytolS1 && (myuinf2 - U2) <= mytolS2 && (U2 - myusup2) <= mytolS2 @@ -247,7 +263,9 @@ bool Extrema_ExtSS::IsDone() const bool Extrema_ExtSS::IsParallel() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return myIsPar; } @@ -264,7 +282,9 @@ double Extrema_ExtSS::SquareDistance(const int N) const int Extrema_ExtSS::NbExt() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return mySqDist.Length(); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtCS.cxx index 51fb30670b..909c43c543 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtCS.cxx @@ -95,7 +95,9 @@ int Extrema_FuncExtCS::NbEquations() const bool Extrema_FuncExtCS::Value(const math_Vector& UV, math_Vector& F) { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } myt = UV(1); myU = UV(2); @@ -130,7 +132,9 @@ bool Extrema_FuncExtCS::Derivatives(const math_Vector& UV, math_Matrix& DF) bool Extrema_FuncExtCS::Values(const math_Vector& UV, math_Vector& F, math_Matrix& Df) { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } myt = UV(1); myU = UV(2); @@ -167,7 +171,9 @@ bool Extrema_FuncExtCS::Values(const math_Vector& UV, math_Vector& F, math_Matri int Extrema_FuncExtCS::GetStateNumber() { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } // comparison of solution with previous solutions constexpr double tol2d = Precision::SquarePConfusion(); int i = 1, nbSol = mySqDist.Length(); @@ -177,10 +183,14 @@ int Extrema_FuncExtCS::GetStateNumber() aT -= myt; aT *= aT; if (aT <= tol2d) + { break; + } } if (i <= nbSol) + { return 0; + } mySqDist.Append(myP1.SquareDistance(myP2)); myPoint1.Append(Extrema_POnCurv(myt, myP1)); myPoint2.Append(Extrema_POnSurf(myU, myV, myP2)); @@ -199,7 +209,9 @@ int Extrema_FuncExtCS::NbExt() const double Extrema_FuncExtCS::SquareDistance(const int N) const { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } return mySqDist.Value(N); } @@ -208,7 +220,9 @@ double Extrema_FuncExtCS::SquareDistance(const int N) const const Extrema_POnCurv& Extrema_FuncExtCS::PointOnCurve(const int N) const { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } return myPoint1.Value(N); } @@ -217,6 +231,8 @@ const Extrema_POnCurv& Extrema_FuncExtCS::PointOnCurve(const int N) const const Extrema_POnSurf& Extrema_FuncExtCS::PointOnSurface(const int N) const { if (!myCinit || !mySinit) + { throw Standard_TypeMismatch(); + } return myPoint2.Value(N); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtSS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtSS.cxx index db48350557..30c79ed186 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtSS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncExtSS.cxx @@ -109,7 +109,9 @@ int Extrema_FuncExtSS::NbEquations() const bool Extrema_FuncExtSS::Value(const math_Vector& UV, math_Vector& F) { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } myU1 = UV(1); myV1 = UV(2); myU2 = UV(3); @@ -142,7 +144,9 @@ bool Extrema_FuncExtSS::Derivatives(const math_Vector& UV, math_Matrix& Df) bool Extrema_FuncExtSS::Values(const math_Vector& UV, math_Vector& F, math_Matrix& Df) { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } myU1 = UV(1); myV1 = UV(2); myU2 = UV(3); @@ -187,7 +191,9 @@ bool Extrema_FuncExtSS::Values(const math_Vector& UV, math_Vector& F, math_Matri int Extrema_FuncExtSS::GetStateNumber() { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } mySqDist.Append(myP1.SquareDistance(myP2)); myPoint1.Append(Extrema_POnSurf(myU1, myV1, myP1)); @@ -207,7 +213,9 @@ int Extrema_FuncExtSS::NbExt() const double Extrema_FuncExtSS::SquareDistance(const int N) const { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } return mySqDist.Value(N); } @@ -216,7 +224,9 @@ double Extrema_FuncExtSS::SquareDistance(const int N) const const Extrema_POnSurf& Extrema_FuncExtSS::PointOnS1(const int N) const { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } return myPoint1.Value(N); } @@ -225,6 +235,8 @@ const Extrema_POnSurf& Extrema_FuncExtSS::PointOnS1(const int N) const const Extrema_POnSurf& Extrema_FuncExtSS::PointOnS2(const int N) const { if (!myS1init || !myS2init) + { throw Standard_TypeMismatch(); + } return myPoint2.Value(N); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSDist.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSDist.cxx index f50d134b49..9db9896b1c 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSDist.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSDist.cxx @@ -39,7 +39,9 @@ int Extrema_FuncPSDist::NbVariables() const bool Extrema_FuncPSDist::Value(const math_Vector& X, double& F) { if (!IsInside(X)) + { return false; + } F = mySurf.Value(X(1), X(2)).SquareDistance(myP); @@ -52,7 +54,9 @@ bool Extrema_FuncPSDist::Gradient(const math_Vector& X, math_Vector& G) { if (!IsInside(X)) + { return false; + } gp_Pnt aP; gp_Vec Du1s, Dv1s; @@ -71,7 +75,9 @@ bool Extrema_FuncPSDist::Gradient(const math_Vector& X, math_Vector& G) bool Extrema_FuncPSDist::Values(const math_Vector& X, double& F, math_Vector& G) { if (!IsInside(X)) + { return false; + } gp_Pnt aP; gp_Vec Du1s, Dv1s; diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSNorm.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSNorm.cxx index fd83582fa1..08b01fce3d 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSNorm.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_FuncPSNorm.cxx @@ -83,7 +83,9 @@ int Extrema_FuncPSNorm::NbEquations() const bool Extrema_FuncPSNorm::Value(const math_Vector& UV, math_Vector& F) { if (!myPinit || !mySinit) + { throw Standard_TypeMismatch(); + } myU = UV(1); myV = UV(2); gp_Vec Dus, Dvs; @@ -110,7 +112,9 @@ bool Extrema_FuncPSNorm::Derivatives(const math_Vector& UV, math_Matrix& Df) bool Extrema_FuncPSNorm::Values(const math_Vector& UV, math_Vector& F, math_Matrix& Df) { if (!myPinit || !mySinit) + { throw Standard_TypeMismatch(); + } myU = UV(1); myV = UV(2); gp_Vec Dus, Dvs, Duus, Dvvs, Duvs; @@ -135,7 +139,9 @@ bool Extrema_FuncPSNorm::Values(const math_Vector& UV, math_Vector& F, math_Matr int Extrema_FuncPSNorm::GetStateNumber() { if (!myPinit || !mySinit) + { throw Standard_TypeMismatch(); + } // comparison of solution with previous solutions int i = 1, nbSol = mySqDist.Length(); constexpr double tol2d = Precision::PConfusion() * Precision::PConfusion(); @@ -145,10 +151,14 @@ int Extrema_FuncPSNorm::GetStateNumber() double aU, aV; myPoint(i).Parameter(aU, aV); if (((myU - aU) * (myU - aU) + (myV - aV) * (myV - aV)) <= tol2d) + { break; + } } if (i <= nbSol) + { return 0; + } mySqDist.Append(myPs.SquareDistance(myP)); myPoint.Append(Extrema_POnSurf(myU, myV, myPs)); return 0; @@ -166,7 +176,9 @@ int Extrema_FuncPSNorm::NbExt() const double Extrema_FuncPSNorm::SquareDistance(const int N) const { if (!myPinit || !mySinit) + { throw Standard_TypeMismatch(); + } return mySqDist.Value(N); } @@ -175,6 +187,8 @@ double Extrema_FuncPSNorm::SquareDistance(const int N) const const Extrema_POnSurf& Extrema_FuncPSNorm::Point(const int N) const { if (!myPinit || !mySinit) + { throw Standard_TypeMismatch(); + } return myPoint.Value(N); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtCS.cxx index 427cc479f6..b96251a7cb 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtCS.cxx @@ -43,30 +43,50 @@ const double HyperbolaLimit = 23.; // ln(MaxParamVal) static bool IsQuadric(const GeomAbs_SurfaceType theSType) { if (theSType == GeomAbs_Plane) + { return true; + } if (theSType == GeomAbs_Cylinder) + { return true; + } if (theSType == GeomAbs_Cone) + { return true; + } if (theSType == GeomAbs_Sphere) + { return true; + } if (theSType == GeomAbs_Torus) + { return true; + } return false; } static bool IsConic(const GeomAbs_CurveType theCType) { if (theCType == GeomAbs_Line) + { return true; + } if (theCType == GeomAbs_Circle) + { return true; + } if (theCType == GeomAbs_Ellipse) + { return true; + } if (theCType == GeomAbs_Hyperbola) + { return true; + } if (theCType == GeomAbs_Parabola) + { return true; + } return false; } @@ -86,7 +106,9 @@ static double GetCurvMaxParamVal(const Adaptor3d_Curve& theC) aBC = aTC->BasisCurve(); } if (aBC->IsKind(STANDARD_TYPE(Geom_Hyperbola))) + { return HyperbolaLimit; + } } return MaxParamVal; } @@ -447,7 +469,9 @@ void Extrema_GenExtCS::GlobMinGenCS(const Adaptor3d_Curve& theC, double aCU1 = aMinTUV(1); for (int aCUI = 0; aCUI <= aNewCsample; aCUI++, aCU1 += aStepCU) + { aCurvPnts.SetValue(aCUI, theC.Value(aCU1)); + } PSO_Particle* aParticle = aParticles.GetWorstParticle(); // Select specified number of particles from pre-computed set of samples @@ -593,11 +617,15 @@ void Extrema_GenExtCS::GlobMinConicS(const Adaptor3d_Curve& theC, theC.D1(aCT, aPOnC, aDT); double aSqDist = aPOnC.SquareDistance(aPOnS); if (aSqDist <= Precision::SquareConfusion()) + { return; + } gp_Vec aN = aDU.Crossed(aDV); if (aN.SquareMagnitude() < Precision::SquareConfusion()) + { return; + } gp_Vec PcPs(aPOnC, aPOnS); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtPS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtPS.cxx index 4e4f11b733..e22509a09f 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtPS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenExtPS.cxx @@ -111,7 +111,9 @@ bool Bnd_SphereUBTreeSelectorMin::Accept(const int& theInd) { mySol = aSph; if (aCurDist < myMinDist) + { myMinDist = aCurDist; + } return true; } @@ -156,7 +158,9 @@ bool Bnd_SphereUBTreeSelectorMax::Accept(const int& theInd) { mySol = aSph; if (aCurDist > myMaxDist) + { myMaxDist = aCurDist; + } return true; } @@ -330,7 +334,9 @@ inline static void fillParams(const NCollection_Array1& theKnots for (; i < theKnots.Length() && theKnots(i) < (theParMax - Precision::PConfusion()); i++) { if (theKnots(i + 1) < theParMin + Precision::PConfusion()) + { continue; + } double aStep = (theKnots(i + 1) - theKnots(i)) / std::max(theDegree, 2); int k = 1; @@ -338,7 +344,9 @@ inline static void fillParams(const NCollection_Array1& theKnots { double aPar = theKnots(i) + k * aStep; if (aPar > theParMax - Precision::PConfusion()) + { break; + } if (aPar > aPrevPar + Precision::PConfusion()) { aParams.Append(aPar); @@ -350,10 +358,14 @@ inline static void fillParams(const NCollection_Array1& theKnots int nbPar = aParams.Length(); // in case of an insufficient number of points the grid will be built later if (nbPar < theSample) + { return; + } theParams = new NCollection_HArray1(1, nbPar); for (i = 0; i < nbPar; i++) + { theParams->SetValue(i + 1, aParams(i)); + } } void Extrema_GenExtPS::GetGridPoints(const Adaptor3d_Surface& theSurf) @@ -381,7 +393,9 @@ void Extrema_GenExtPS::GetGridPoints(const Adaptor3d_Surface& theSurf) { occ::handle aBezier = theSurf.Bezier(); if (aBezier.IsNull()) + { return; + } NCollection_Array1 aUKnots(1, 2); NCollection_Array1 aVKnots(1, 2); @@ -416,17 +430,27 @@ void Extrema_GenExtPS::GetGridPoints(const Adaptor3d_Surface& theSurf) } } if (anArrKnots.IsNull()) + { return; + } if (theSurf.GetType() == GeomAbs_SurfaceOfRevolution) + { fillParams(anArrKnots->Array1(), aDegree, myvmin, myvsup, myVParams, myvsample); + } else + { fillParams(anArrKnots->Array1(), aDegree, myumin, myusup, myUParams, myusample); + } } // update the number of points in sample if (!myUParams.IsNull()) + { myusample = myUParams->Length(); + } if (!myVParams.IsNull()) + { myvsample = myVParams->Length(); + } } /* @@ -519,7 +543,9 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt& thePoint) myUParams = new NCollection_HArray1(1, myusample); double U = U0; for (int NoU = 1; NoU <= myusample; NoU++, U += PasU) + { myUParams->SetValue(NoU, U); + } } if (myVParams.IsNull()) @@ -532,7 +558,9 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt& thePoint) myVParams = new NCollection_HArray1(1, myvsample); double V = V0; for (int NoV = 1; NoV <= myvsample; NoV++, V += PasV) + { myVParams->SetValue(NoV, V); + } } // If flag was changed and extrema not reinitialized Extrema would fail @@ -811,13 +839,17 @@ static void CorrectNbSamples(const Adaptor3d_Surface& theS, { int aMult = RealToInt(std::log(aRatio)); if (aMult > 1) + { theNbV *= aMult; + } } else if (aRatio < 0.1) { int aMult = RealToInt(-std::log(aRatio)); if (aMult > 1) + { theNbV *= aMult; + } } } @@ -825,7 +857,9 @@ void Extrema_GenExtPS::BuildTree() { // if tree already exists, assume it is already correctly filled if (!mySphereUBTree.IsNull()) + { return; + } if (myS->GetType() == GeomAbs_BSplineSurface) { @@ -834,9 +868,13 @@ void Extrema_GenExtPS::BuildTree() int aVValue = aBspl->VDegree() * aBspl->NbVKnots(); // 300 is value, which is used for singular points (see Extrema_ExtPS.cxx::Initialize(...)) if (aUValue > myusample) + { myusample = std::min(aUValue, 300); + } if (aVValue > myvsample) + { myvsample = std::min(aVValue, 300); + } } // CorrectNbSamples(*myS, myumin, myusup, myusample, myvmin, myvsup, myvsample); @@ -856,9 +894,13 @@ void Extrema_GenExtPS::BuildTree() int NoU, NoV; double U = U0, V = V0; for (NoU = 1; NoU <= myusample; NoU++, U += PasU) + { myUParams->SetValue(NoU, U); + } for (NoV = 1; NoV <= myvsample; NoV++, V += PasV) + { myVParams->SetValue(NoV, V); + } // Build UB-tree with surface points for fast proximity search. // Use optimized grid evaluator with span-based caching for B-spline surfaces. @@ -917,7 +959,9 @@ void Extrema_GenExtPS::SetFlag(const Extrema_ExtFlag F) void Extrema_GenExtPS::SetAlgo(const Extrema_ExtAlgo A) { if (myAlgo != A) + { myInit = false; + } myAlgo = A; } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtCS.cxx index 8b0ac614e6..38323a2cca 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtCS.cxx @@ -88,7 +88,9 @@ void Extrema_GenLocateExtCS::Perform(const Adaptor3d_Curve& C, math_FunctionSetRoot SR(F, Tol); SR.Perform(F, Start, BInf, BSup); if (!SR.IsDone()) + { return; + } mySqDist = F.SquareDistance(1); myPoint1 = F.PointOnCurve(1); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtPS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtPS.cxx index 08a9784e4d..de4cfbe61d 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtPS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtPS.cxx @@ -84,7 +84,9 @@ bool Extrema_GenLocateExtPS::IsMinDist(const gp_Pnt& theP, for (iv = -1; iv <= 1; ++iv) { if (iu == 0 && iv == 0) + { continue; + } v = theV0 + iv * dv; if (!theS.IsVPeriodic()) @@ -94,7 +96,9 @@ bool Extrema_GenLocateExtPS::IsMinDist(const gp_Pnt& theP, } double d = theP.SquareDistance(theS.Value(u, v)); if (d < d0) + { return false; + } } } return true; @@ -156,7 +160,9 @@ void Extrema_GenLocateExtPS::Perform(const gp_Pnt& theP, math_FRPR aSolver1(F, aRelTol); aSolver1.Perform(F, aStart); if (!aSolver1.IsDone()) + { return; + } aSolver1.Location(aResPnt); mySqDist = aSolver1.Minimum(); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtSS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtSS.cxx index b322d8b803..14eb4f7a74 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtSS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GenLocateExtSS.cxx @@ -95,7 +95,9 @@ void Extrema_GenLocateExtSS::Perform(const Adaptor3d_Surface& S1, math_FunctionSetRoot SR(F, Tol); SR.Perform(F, Start, BInf, BSup); if (!SR.IsDone()) + { return; + } mySqDist = F.SquareDistance(1); myPoint1 = F.PointOnS1(1); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCC.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCC.cxx index 3270c56c8e..407a699cd6 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCC.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCC.cxx @@ -222,9 +222,13 @@ int Extrema_GlobOptFuncCCC0::NbVariables() const bool Extrema_GlobOptFuncCCC0::Value(const math_Vector& X, double& F) { if (myType == 1) + { return _Value(*myC1_3d, *myC2_3d, X, F); + } else + { return _Value(*myC1_2d, *myC2_2d, X, F); + } } // C1 @@ -265,9 +269,13 @@ int Extrema_GlobOptFuncCCC1::NbVariables() const bool Extrema_GlobOptFuncCCC1::Value(const math_Vector& X, double& F) { if (myType == 1) + { return _Value(*myC1_3d, *myC2_3d, X, F); + } else + { return _Value(*myC1_2d, *myC2_2d, X, F); + } } //================================================================================================= @@ -275,9 +283,13 @@ bool Extrema_GlobOptFuncCCC1::Value(const math_Vector& X, double& F) bool Extrema_GlobOptFuncCCC1::Gradient(const math_Vector& X, math_Vector& G) { if (myType == 1) + { return _Gradient(*myC1_3d, *myC2_3d, X, G); + } else + { return _Gradient(*myC1_2d, *myC2_2d, X, G); + } } //================================================================================================= @@ -325,9 +337,13 @@ int Extrema_GlobOptFuncCCC2::NbVariables() const bool Extrema_GlobOptFuncCCC2::Value(const math_Vector& X, double& F) { if (myType == 1) + { return _Value(*myC1_3d, *myC2_3d, X, F); + } else + { return _Value(*myC1_2d, *myC2_2d, X, F); + } } //================================================================================================= @@ -335,9 +351,13 @@ bool Extrema_GlobOptFuncCCC2::Value(const math_Vector& X, double& F) bool Extrema_GlobOptFuncCCC2::Gradient(const math_Vector& X, math_Vector& G) { if (myType == 1) + { return _Gradient(*myC1_3d, *myC2_3d, X, G); + } else + { return _Gradient(*myC1_2d, *myC2_2d, X, G); + } } //================================================================================================= @@ -356,9 +376,13 @@ bool Extrema_GlobOptFuncCCC2::Values(const math_Vector& X, { bool isHessianComputed = false; if (myType == 1) + { isHessianComputed = _Hessian(*myC1_3d, *myC2_3d, X, H); + } else + { isHessianComputed = _Hessian(*myC1_2d, *myC2_2d, X, H); + } return (Value(X, F) && Gradient(X, G) && isHessianComputed); } diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCQuadric.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCQuadric.cxx index 4627cfd1fe..43531d193d 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCQuadric.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCQuadric.cxx @@ -194,7 +194,9 @@ bool Extrema_GlobOptFuncCQuadric::Value(const math_Vector& X, double& F) { double ct; if (!checkInputData(X, ct)) + { return false; + } value(ct, F); return !Precision::IsInfinite(F); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCS.cxx index 4ba5a45d91..8216c8a011 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncCS.cxx @@ -120,7 +120,9 @@ bool Extrema_GlobOptFuncCS::Value(const math_Vector& X, double& F) { double cu, su, sv; if (!checkInputData(X, cu, su, sv)) + { return false; + } value(cu, su, sv, F); return true; @@ -132,7 +134,9 @@ bool Extrema_GlobOptFuncCS::Gradient(const math_Vector& X, math_Vector& G) { double cu, su, sv; if (!checkInputData(X, cu, su, sv)) + { return false; + } gradient(cu, su, sv, G); return true; @@ -144,7 +148,9 @@ bool Extrema_GlobOptFuncCS::Values(const math_Vector& X, double& F, math_Vector& { double cu, su, sv; if (!checkInputData(X, cu, su, sv)) + { return false; + } value(cu, su, sv, F); gradient(cu, su, sv, G); @@ -157,7 +163,9 @@ bool Extrema_GlobOptFuncCS::Values(const math_Vector& X, double& F, math_Vector& { double cu, su, sv; if (!checkInputData(X, cu, su, sv)) + { return false; + } value(cu, su, sv, F); gradient(cu, su, sv, G); diff --git a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncConicS.cxx b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncConicS.cxx index ec513d1808..0f2451cc25 100644 --- a/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncConicS.cxx +++ b/src/ModelingData/TKGeomBase/Extrema/Extrema_GlobOptFuncConicS.cxx @@ -174,7 +174,9 @@ bool Extrema_GlobOptFuncConicS::Value(const math_Vector& X, double& F) { double su, sv; if (!checkInputData(X, su, sv)) + { return false; + } value(su, sv, F); return !Precision::IsInfinite(F); diff --git a/src/ModelingData/TKGeomBase/ExtremaPC/ExtremaPC_BSplineCurve.cxx b/src/ModelingData/TKGeomBase/ExtremaPC/ExtremaPC_BSplineCurve.cxx index 547b1f2290..17c095adf1 100644 --- a/src/ModelingData/TKGeomBase/ExtremaPC/ExtremaPC_BSplineCurve.cxx +++ b/src/ModelingData/TKGeomBase/ExtremaPC/ExtremaPC_BSplineCurve.cxx @@ -70,17 +70,23 @@ math_Vector ExtremaPC_BSplineCurve::buildKnotAwareParams() const double aSpanLo = std::max(aKnotLo, theUMin); double aSpanHi = std::min(aKnotHi, theUMax); if (aSpanHi <= aSpanLo) + { continue; + } double aStep = (aSpanHi - aSpanLo) / aSamplesPerSpan; for (int j = 1; j < aSamplesPerSpan; ++j) { double aU = aSpanLo + j * aStep; if (aU > theUMin && aU < theUMax) + { aParams.Append(aU); + } } if (aKnotHi > theUMin && aKnotHi < theUMax) + { aParams.Append(aKnotHi); + } } aParams.Append(theUMax); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Assembly.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Assembly.cxx index b00965b557..336fc45d07 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Assembly.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Assembly.cxx @@ -39,6 +39,7 @@ static int MinIndex( Imin = T->Value(nvarl); for (dim = diml; dim <= dimu; dim++) + { for (el = ell; el <= elu; el++) { T = Table->Value(dim, el); @@ -49,6 +50,7 @@ static int MinIndex( Imin = std::min(Imin, T->Value(nvar)); } } + } return Imin; } @@ -68,6 +70,7 @@ static int MaxIndex( Imax = T->Value(nvarl); for (dim = diml; dim <= dimu; dim++) + { for (el = ell; el <= elu; el++) { T = Table->Value(dim, el); @@ -78,6 +81,7 @@ static int MaxIndex( Imax = std::max(Imax, T->Value(nvar)); } } + } return Imax; } @@ -104,6 +108,7 @@ FEmTool_Assembly::FEmTool_Assembly( occ::handle> T; for (dim = diml; dim <= dimu; dim++) + { for (el = ell; el <= elu; el++) { @@ -113,7 +118,9 @@ FEmTool_Assembly::FEmTool_Assembly( Imin = T->Value(nvarl) + I0; for (nvar = nvarl; nvar <= nvaru; nvar++) + { Imin = std::min(Imin, T->Value(nvar) + I0); + } for (nvar = nvarl; nvar <= nvaru; nvar++) { @@ -121,6 +128,7 @@ FEmTool_Assembly::FEmTool_Assembly( FirstIndexes(i) = std::min(FirstIndexes(i), Imin); } } + } H = new FEmTool_ProfileMatrix(FirstIndexes); @@ -143,7 +151,9 @@ void FEmTool_Assembly::AddMatrix(const int Element, { if (myDepTable(Dimension1, Dimension2) == 0) + { throw Standard_DomainError("FEmTool_Assembly::AddMatrix"); + } const NCollection_Array1& T1 = myRefTable->Value(Dimension1, Element)->Array1(); const NCollection_Array1& T2 = myRefTable->Value(Dimension2, Element)->Array1(); @@ -187,7 +197,9 @@ void FEmTool_Assembly::AddVector(const int Element, const int Dimension, const m int i; for (i = nvarl; i <= nvaru; i++) + { B(T(i)) += Vec(i0 + i); + } } //================================================================================================= @@ -257,7 +269,9 @@ bool FEmTool_Assembly::Solve() BlockBeg = BlockEnd + 1; } else + { i = j; + } } } @@ -287,13 +301,19 @@ bool FEmTool_Assembly::Solve() } } if (!Zero) + { break; + } } if (!Zero) + { break; + } } if (!Zero) + { break; + } } if (!Zero) { @@ -325,7 +345,9 @@ bool FEmTool_Assembly::Solve() const occ::handle>& a = Iter.Value(); for (j = a->Lower(); j <= a->Upper(); j++) + { gi(j) = a->Value(j); // gi - full line of G + } } // -1 t H->Solve(gi, qi); // solving H*qi = gi, qi is column of H G @@ -347,8 +369,10 @@ bool FEmTool_Assembly::Solve() const occ::handle>& a = Iter.Value(); for (j = a->Lower(); j <= a->Upper(); j++) + { m += qi(j) * a->Value(j); // scalar product of - // k-th line of G and i-th column of H-1 Gt + } + // k-th line of G and i-th column of H-1 Gt } GHGt->ChangeValue(k, i) = m; @@ -375,10 +399,14 @@ bool FEmTool_Assembly::Solve() void FEmTool_Assembly::Solution(math_Vector& Solution) const { if (!IsSolved) + { throw StdFail_NotDone("FEmTool_Assembly::Solution"); + } if (G.IsEmpty()) + { H->Solve(B, Solution); + } else { @@ -400,8 +428,10 @@ void FEmTool_Assembly::Solution(math_Vector& Solution) const const occ::handle>& a = Iter.Value(); for (j = a->Lower(); j <= a->Upper(); j++) + { m += v1(j) * a->Value(j); // scalar product - // G v1 + } + // G v1 } v2(i) = m - C.Value(i); @@ -423,7 +453,9 @@ void FEmTool_Assembly::Solution(math_Vector& Solution) const const occ::handle>& a = Iter.Value(); for (j = a->Lower(); j <= a->Upper(); j++) + { v1(j) -= l(i) * a->Value(j); + } } } @@ -460,7 +492,9 @@ void FEmTool_Assembly::NullifyConstraint() C.SetValue(i, 0.); for (Iter.Initialize(G.Value(i)); Iter.More(); Iter.Next()) + { Iter.Value()->Init(0.); + } } } @@ -541,9 +575,13 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, // merge new and first segment Coeff = new NCollection_HArray1(Imin, Aux2->Upper()); for (i = Imin; i <= Aux2->Lower() - 1; i++) + { Coeff->SetValue(i, 0.); + } for (i = Aux2->Lower(); i <= Aux2->Upper(); i++) + { Coeff->SetValue(i, Aux2->Value(i)); + } L.First() = Coeff; } } @@ -561,9 +599,13 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, // merge new and last segment Coeff = new NCollection_HArray1(Aux1->Lower(), Imax); for (i = Aux1->Lower(); i <= Aux1->Upper(); i++) + { Coeff->SetValue(i, Aux1->Value(i)); + } for (i = Aux1->Upper() + 1; i <= Imax; i++) + { Coeff->SetValue(i, 0.); + } L.Last() = Coeff; } } @@ -572,12 +614,18 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, // merge s1 and new Coeff = new NCollection_HArray1(Aux1->Lower(), Imax); for (i = Aux1->Lower(); i <= Aux1->Upper(); i++) + { Coeff->SetValue(i, Aux1->Value(i)); + } for (i = Aux1->Upper() + 1; i <= Imax; i++) + { Coeff->SetValue(i, 0.); + } Iter.Initialize(L); for (i = 1; i < s1; Iter.Next(), i++) + { ; + } Iter.ChangeValue() = Coeff; } else if (Imin > Aux1->Upper() && Imax >= Aux2->Lower()) @@ -585,12 +633,18 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, // merge new and first segment Coeff = new NCollection_HArray1(Imin, Aux2->Upper()); for (i = Imin; i <= Aux2->Lower() - 1; i++) + { Coeff->SetValue(i, 0.); + } for (i = Aux2->Lower(); i <= Aux2->Upper(); i++) + { Coeff->SetValue(i, Aux2->Value(i)); + } Iter.Initialize(L); for (i = 1; i < s2; Iter.Next(), i++) + { ; + } Iter.ChangeValue() = Coeff; } else if (Imin > Aux1->Upper() && Imax < Aux2->Lower()) @@ -600,7 +654,9 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, Coeff->Init(0.); Iter.Initialize(L); for (i = 1; i < s1; Iter.Next(), i++) + { ; + } L.InsertAfter(Coeff, Iter); } else @@ -608,14 +664,22 @@ void FEmTool_Assembly::AddConstraint(const int IndexofConstraint, // merge s1, new, s2 and remove s2 Coeff = new NCollection_HArray1(Aux1->Lower(), Aux2->Upper()); for (i = Aux1->Lower(); i <= Aux1->Upper(); i++) + { Coeff->SetValue(i, Aux1->Value(i)); + } for (i = Aux1->Upper() + 1; i <= Aux2->Lower() - 1; i++) + { Coeff->SetValue(i, 0.); + } for (i = Aux2->Lower(); i <= Aux2->Upper(); i++) + { Coeff->SetValue(i, Aux2->Value(i)); + } Iter.Initialize(L); for (i = 1; i < s1; Iter.Next(), i++) + { ; + } Iter.ChangeValue() = Coeff; Iter.Next(); L.Remove(Iter); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx index 78387da37e..d63d54b6cc 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_Curve.cxx @@ -64,7 +64,9 @@ void FEmTool_Curve::SetElement(const int IndexOfElement, const NCollection_Array { int i, j, degBase, deg; if (IndexOfElement > myNbElements || IndexOfElement < 1) + { throw Standard_OutOfRange(); + } degBase = myBase.WorkDegree(); deg = myDegree(IndexOfElement); int iBase = (IndexOfElement - 1) * (degBase + 1) * myDimension, i1 = iBase - myDimension, @@ -74,7 +76,9 @@ void FEmTool_Curve::SetElement(const int IndexOfElement, const NCollection_Array i1 += myDimension; i2++; for (j = 1; j <= myDimension; j++) + { myCoeff(i1 + j) = Coeffs(i2, j1 + j); + } } double stenor = (myKnots->Value(IndexOfElement + 1) - myKnots->Value(IndexOfElement)) / 2., mfact; @@ -103,7 +107,9 @@ void FEmTool_Curve::GetElement(const int IndexOfElement, NCollection_Array2 myNbElements || IndexOfElement < 1) + { throw Standard_OutOfRange(); + } degBase = myBase.WorkDegree(); deg = myDegree(IndexOfElement); int iBase = (IndexOfElement - 1) * (degBase + 1) * myDimension, i1 = iBase - myDimension, @@ -113,7 +119,9 @@ void FEmTool_Curve::GetElement(const int IndexOfElement, NCollection_Array2Value(IndexOfElement + 1) - myKnots->Value(IndexOfElement)), mfact; @@ -140,11 +148,17 @@ void FEmTool_Curve::GetPolynom(NCollection_Array1& Coeffs) int IndexOfElement, i, di = Coeffs.Lower() - myPoly.Lower(); for (IndexOfElement = 1; IndexOfElement <= myNbElements; IndexOfElement++) + { if (!HasPoly.Value(IndexOfElement)) + { Update(IndexOfElement, 0); + } + } for (i = myPoly.Lower(); i <= myPoly.Upper(); i++) + { Coeffs(di + i) = myPoly(i); + } } //================================================================================================= @@ -159,14 +173,22 @@ void FEmTool_Curve::D0(const double U, NCollection_Array1& Pnt) { // Search the span if (U <= myKnots->Value(2)) + { myIndex = 1; + } else { for (myIndex = 2; myIndex <= myNbElements; myIndex++) + { if (U >= myKnots->Value(myIndex) && U <= myKnots->Value(myIndex + 1)) + { break; + } + } if (myIndex > myNbElements) + { myIndex = myNbElements; + } } Uf = myKnots->Value(myIndex); Ul = myKnots->Value(myIndex + 1); @@ -177,7 +199,9 @@ void FEmTool_Curve::D0(const double U, NCollection_Array1& Pnt) deg = myDegree(myIndex); if (!HasPoly.Value(myIndex)) + { Update(myIndex, 0); + } // Parameter normalization: S [-1, 1] S = (2 * U - USum) * Denom; @@ -201,14 +225,22 @@ void FEmTool_Curve::D1(const double U, NCollection_Array1& Vec) { // Search the span if (U <= myKnots->Value(2)) + { myIndex = 1; + } else { for (myIndex = 2; myIndex <= myNbElements; myIndex++) + { if (U >= myKnots->Value(myIndex) && U <= myKnots->Value(myIndex + 1)) + { break; + } + } if (myIndex > myNbElements) + { myIndex = myNbElements; + } } Uf = myKnots->Value(myIndex); Ul = myKnots->Value(myIndex + 1); @@ -219,7 +251,9 @@ void FEmTool_Curve::D1(const double U, NCollection_Array1& Vec) deg = myDegree(myIndex); if (!HasDeri.Value(myIndex)) + { Update(myIndex, 1); + } // Parameter normalization: S [-1, 1] S = (2 * U - USum) * Denom; @@ -232,7 +266,9 @@ void FEmTool_Curve::D1(const double U, NCollection_Array1& Vec) S = 2 * Denom; for (i = Vec.Lower(); i <= Vec.Upper(); i++) + { Vec(i) *= S; + } } //================================================================================================= @@ -247,14 +283,22 @@ void FEmTool_Curve::D2(const double U, NCollection_Array1& Vec) { // Search the span if (U <= myKnots->Value(2)) + { myIndex = 1; + } else { for (myIndex = 2; myIndex <= myNbElements; myIndex++) + { if (U >= myKnots->Value(myIndex) && U <= myKnots->Value(myIndex + 1)) + { break; + } + } if (myIndex > myNbElements) + { myIndex = myNbElements; + } } Uf = myKnots->Value(myIndex); Ul = myKnots->Value(myIndex + 1); @@ -265,7 +309,9 @@ void FEmTool_Curve::D2(const double U, NCollection_Array1& Vec) deg = myDegree(myIndex); if (!HasSecn.Value(myIndex)) + { Update(myIndex, 2); + } // Parameter normalization: S [-1, 1] S = (2 * U - USum) * Denom; @@ -279,7 +325,9 @@ void FEmTool_Curve::D2(const double U, NCollection_Array1& Vec) S = 4 * Denom * Denom; for (i = Vec.Lower(); i <= Vec.Upper(); i++) + { Vec(i) *= S; + } } //================================================================================================= @@ -288,25 +336,47 @@ void FEmTool_Curve::Length(const double FirstU, const double LastU, double& Leng { int Low, High, deg, degBase, i, Ptr; if (FirstU > LastU) + { throw Standard_OutOfRange("FEmTool_Curve::Length"); + } if (myKnots->Value(1) > FirstU) + { Low = 1; + } else + { for (Low = 1; Low <= myNbElements; Low++) + { if (FirstU >= myKnots->Value(Low) && FirstU <= myKnots->Value(Low + 1)) + { break; + } + } + } if (Low > myNbElements) + { Low = myNbElements; + } if (myKnots->Value(1) > LastU) + { High = 1; + } else + { for (High = Low; High <= myNbElements; High++) + { if (LastU >= myKnots->Value(High) && LastU <= myKnots->Value(High + 1)) + { break; + } + } + } if (myKnots->Value(myNbElements + 1) < LastU) + { High = myNbElements; + } double Li; degBase = myBase.WorkDegree(); @@ -325,7 +395,9 @@ void FEmTool_Curve::Length(const double FirstU, const double LastU, double& Leng deg = myDegree(Low); if (!HasPoly(Low)) + { Update(Low, 0); + } PLib::EvalLength(deg, myDimension, myPoly(Ptr), FirstS, LastS, Length); return; } @@ -334,7 +406,9 @@ void FEmTool_Curve::Length(const double FirstU, const double LastU, double& Leng Ptr = (Low - 1) * (degBase + 1) * myDimension + 1; if (!HasPoly(Low)) + { Update(Low, 0); + } if (FirstS < -1.) { PLib::EvalLength(deg, myDimension, myPoly(Ptr), FirstS, -1., Li); @@ -356,7 +430,9 @@ void FEmTool_Curve::Length(const double FirstU, const double LastU, double& Leng Ptr = (High - 1) * (degBase + 1) * myDimension + 1; if (!HasPoly(High)) + { Update(High, 0); + } if (LastS > 1.) { PLib::EvalLength(deg, myDimension, myPoly(Ptr), 1., LastS, Li); @@ -381,7 +457,9 @@ void FEmTool_Curve::Length(const double FirstU, const double LastU, double& Leng Ptr = (i - 1) * (degBase + 1) * myDimension + 1; deg = myDegree(i); if (!HasPoly(i)) + { Update(i, 0); + } PLib::EvalLength(deg, myDimension, myPoly(Ptr), -1., 1., Li); myLength(i) = Li; } @@ -420,7 +498,9 @@ void FEmTool_Curve::SetDegree(const int IndexOfElement, const int Degree) myLength(IndexOfElement) = -1; } else if (Degree > myBase.WorkDegree()) + { throw Standard_OutOfRange("FEmTool_Curve::SetDegree"); + } } //================================================================================================= @@ -475,7 +555,9 @@ void FEmTool_Curve::Update(const int Index, const int Order) i1 += myDimension; i2 += myDimension; for (j = 1; j <= myDimension; j++) + { myDeri(i1 + j) = i * myPoly.Value(i2 + j); + } } HasDeri(Index) = 1; } @@ -488,7 +570,9 @@ void FEmTool_Curve::Update(const int Index, const int Order) i1 += myDimension; i2 += myDimension; for (j = 1; j <= myDimension; j++) + { myDsecn(i1 + j) = i * myDeri.Value(i2 + j); + } } HasSecn(Index) = 1; } diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx index f2e4d6253e..9cd13536fa 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ElementsOfRefMatrix.cxx @@ -24,7 +24,9 @@ FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const PLib_HermitJacobi : myBase(TheBase) { if (DerOrder < 0 || DerOrder > 3) + { throw Standard_ConstructionError("FEmTool_ElementsOfRefMatrix"); + } myDerOrder = DerOrder; myNbEquations = (myBase.WorkDegree() + 2) * (myBase.WorkDegree() + 1) / 2; @@ -43,7 +45,9 @@ int FEmTool_ElementsOfRefMatrix::NbEquations() const bool FEmTool_ElementsOfRefMatrix::Value(const math_Vector& X, math_Vector& F) { if (F.Length() < myNbEquations) + { throw Standard_OutOfRange("FEmTool_ElementsOfRefMatrix::Value"); + } double u = X(X.Lower()); NCollection_Array1 Basis(0, myBase.WorkDegree()), Aux(0, myBase.WorkDegree()); @@ -66,11 +70,13 @@ bool FEmTool_ElementsOfRefMatrix::Value(const math_Vector& X, math_Vector& F) int i, j, ii = 0; for (i = 0; i <= myBase.WorkDegree(); i++) + { for (j = i; j <= myBase.WorkDegree(); j++) { F(F.Lower() + ii) = Basis(i) * Basis(j); ii++; } + } return true; } diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx index 389d66686c..ce9a08c1a9 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearFlexion.cxx @@ -48,7 +48,9 @@ FEmTool_LinearFlexion::FEmTool_LinearFlexion(const int WorkDegree, { // Calculating RefMatrix if (WorkDegree > WDeg) + { throw Standard_ConstructionError("Degree too high"); + } Order = myOrder; int DerOrder = 2; PLib_HermitJacobi theBase(WDeg, ConstraintOrder); @@ -78,7 +80,9 @@ FEmTool_LinearFlexion::FEmTool_LinearFlexion(const int WorkDegree, occ::handle> FEmTool_LinearFlexion::DependenceTable() const { if (myCoeff.IsNull()) + { throw Standard_DomainError("FEmTool_LinearFlexion::DependenceTable"); + } occ::handle> DepTab = new NCollection_HArray2(myCoeff->LowerCol(), myCoeff->UpperCol(), @@ -87,7 +91,9 @@ occ::handle> FEmTool_LinearFlexion::DependenceTable() c 0); int i; for (i = myCoeff->LowerCol(); i <= myCoeff->UpperCol(); i++) + { DepTab->SetValue(i, i, 1); + } return DepTab; } @@ -113,13 +119,17 @@ double FEmTool_LinearFlexion::Value() k1 = (i <= myOrder) ? i : i - myOrder - 1; mfact = std::pow(coeff, k1); for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim) * mfact; + } } for (i = degH + 1; i <= deg; i++) { for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim); + } } for (dim = 1; dim <= NbDim; dim++) @@ -128,13 +138,17 @@ double FEmTool_LinearFlexion::Value() { Jline = 0.5 * RefMatrix(i, i) * NewCoeff(dim, i); for (j = 0; j < i; j++) + { Jline += RefMatrix(i, j) * NewCoeff(dim, j); + } J += Jline * NewCoeff(dim, i); } } if (J < 0.) + { J = 0.; + } return cteh3 * J; } @@ -147,10 +161,14 @@ void FEmTool_LinearFlexion::Hessian(const int Dimension1, const int Dimension2, if (Dimension1 < DepTab->LowerRow() || Dimension1 > DepTab->UpperRow() || Dimension2 < DepTab->LowerCol() || Dimension2 > DepTab->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearJerk::Hessian"); + } if (DepTab->Value(Dimension1, Dimension2) == 0) + { throw Standard_DomainError("FEmTool_LinearJerk::Hessian"); + } int deg = std::min(RefMatrix.UpperRow(), H.RowNumber() - 1), degH = std::min(2 * myOrder + 1, deg); @@ -170,7 +188,9 @@ void FEmTool_LinearFlexion::Hessian(const int Dimension1, const int Dimension2, k2 = (j <= myOrder) ? j : j - myOrder - 1; H(i, j) = mfact * std::pow(coeff, k2) * RefMatrix(i, j); if (i != j) + { H(j, i) = H(i, j); + } } // Hermite*Jacobi part of matrix for (j = degH + 1; j <= deg; j++) @@ -186,7 +206,9 @@ void FEmTool_LinearFlexion::Hessian(const int Dimension1, const int Dimension2, { H(i, j) = cteh3 * RefMatrix(i, j); if (i != j) + { H(j, i) = H(i, j); + } } } } @@ -196,7 +218,9 @@ void FEmTool_LinearFlexion::Hessian(const int Dimension1, const int Dimension2, void FEmTool_LinearFlexion::Gradient(const int Dimension, math_Vector& G) { if (Dimension < myCoeff->LowerCol() || Dimension > myCoeff->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearFlexion::Gradient"); + } int deg = std::min(G.Length() - 1, myCoeff->ColLength() - 1); @@ -204,7 +228,9 @@ void FEmTool_LinearFlexion::Gradient(const int Dimension, math_Vector& G) math_Matrix H(0, deg, 0, deg); int i, i1 = myCoeff->LowerRow(); for (i = 0; i <= deg; i++) + { X(i) = myCoeff->Value(i1 + i, Dimension); + } Hessian(Dimension, Dimension, H); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx index 63c51e00a4..3183fe9ddb 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearJerk.cxx @@ -45,7 +45,9 @@ FEmTool_LinearJerk::FEmTool_LinearJerk(const int WorkDegree, const GeomAbs_Shape if (myOrder != Order) { if (WorkDegree > WDeg) + { throw Standard_ConstructionError("Degree too high"); + } Order = myOrder; int DerOrder = 3; @@ -78,7 +80,9 @@ FEmTool_LinearJerk::FEmTool_LinearJerk(const int WorkDegree, const GeomAbs_Shape occ::handle> FEmTool_LinearJerk::DependenceTable() const { if (myCoeff.IsNull()) + { throw Standard_DomainError("FEmTool_LinearJerk::DependenceTable"); + } occ::handle> DepTab = new NCollection_HArray2(myCoeff->LowerCol(), myCoeff->UpperCol(), @@ -87,7 +91,9 @@ occ::handle> FEmTool_LinearJerk::DependenceTable() cons 0); int i; for (i = myCoeff->LowerCol(); i <= myCoeff->UpperCol(); i++) + { DepTab->SetValue(i, i, 1); + } return DepTab; } @@ -111,13 +117,17 @@ double FEmTool_LinearJerk::Value() k1 = (i <= myOrder) ? i : i - myOrder - 1; mfact = std::pow(coeff, k1); for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim) * mfact; + } } for (i = degH + 1; i <= deg; i++) { for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim); + } } for (dim = 1; dim <= NbDim; dim++) @@ -129,11 +139,15 @@ double FEmTool_LinearJerk::Value() Jline = 0.5 * RefMatrix(i, i) * NewCoeff(dim, i); for (j = 0; j < i; j++) + { Jline += RefMatrix(i, j) * NewCoeff(dim, j); + } J += Jline * NewCoeff(dim, i); if (J < 0.) + { J = 0.; + } } } @@ -147,10 +161,14 @@ void FEmTool_LinearJerk::Hessian(const int Dimension1, const int Dimension2, mat if (Dimension1 < DepTab->LowerRow() || Dimension1 > DepTab->UpperRow() || Dimension2 < DepTab->LowerCol() || Dimension2 > DepTab->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearJerk::Hessian"); + } if (DepTab->Value(Dimension1, Dimension2) == 0) + { throw Standard_DomainError("FEmTool_LinearJerk::Hessian"); + } int deg = std::min(RefMatrix.UpperRow(), H.RowNumber() - 1), degH = std::min(2 * myOrder + 1, deg); @@ -172,7 +190,9 @@ void FEmTool_LinearJerk::Hessian(const int Dimension1, const int Dimension2, mat k2 = (j <= myOrder) ? j : j - myOrder - 1; H(i1, j1) = mfact * std::pow(coeff, k2) * RefMatrix(i, j); if (i != j) + { H(j1, i1) = H(i1, j1); + } j1++; } // Hermite*Jacobi part of matrix @@ -195,7 +215,9 @@ void FEmTool_LinearJerk::Hessian(const int Dimension1, const int Dimension2, mat { H(i1, j1) = cteh3 * RefMatrix(i, j); if (i != j) + { H(j1, i1) = H(i1, j1); + } j1++; } i1++; @@ -205,14 +227,18 @@ void FEmTool_LinearJerk::Hessian(const int Dimension1, const int Dimension2, mat void FEmTool_LinearJerk::Gradient(const int Dimension, math_Vector& G) { if (Dimension < myCoeff->LowerCol() || Dimension > myCoeff->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearJerk::Gradient"); + } int deg = std::min(G.Length() - 1, myCoeff->ColLength() - 1); math_Vector X(0, deg); int i, i1 = myCoeff->LowerRow(); for (i = 0; i <= deg; i++) + { X(i) = myCoeff->Value(i1 + i, Dimension); + } math_Matrix H(0, deg, 0, deg); Hessian(Dimension, Dimension, H); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx index d686e23308..7f95d12365 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_LinearTension.cxx @@ -47,7 +47,9 @@ FEmTool_LinearTension::FEmTool_LinearTension(const int WorkDegree, { // Calculating RefMatrix if (WorkDegree > WDeg) + { throw Standard_ConstructionError("Degree too high"); + } Order = myOrder; int DerOrder = 1; PLib_HermitJacobi theBase(WDeg, ConstraintOrder); @@ -76,7 +78,9 @@ FEmTool_LinearTension::FEmTool_LinearTension(const int WorkDegree, occ::handle> FEmTool_LinearTension::DependenceTable() const { if (myCoeff.IsNull()) + { throw Standard_DomainError("FEmTool_LinearTension::DependenceTable"); + } occ::handle> DepTab = new NCollection_HArray2(myCoeff->LowerCol(), myCoeff->UpperCol(), @@ -85,7 +89,9 @@ occ::handle> FEmTool_LinearTension::DependenceTable() c 0); int i; for (i = 1; i <= myCoeff->RowLength(); i++) + { DepTab->SetValue(i, i, 1); + } return DepTab; } @@ -109,13 +115,17 @@ double FEmTool_LinearTension::Value() k1 = (i <= myOrder) ? i : i - myOrder - 1; mfact = std::pow(coeff, k1); for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim) * mfact; + } } for (i = degH + 1; i <= deg; i++) { for (dim = 1; dim <= NbDim; dim++) + { NewCoeff(dim, i) = myCoeff->Value(j0 + i, dim); + } } for (dim = 1; dim <= NbDim; dim++) @@ -127,7 +137,9 @@ double FEmTool_LinearTension::Value() Jline = 0.5 * RefMatrix(i, i) * NewCoeff(dim, i); for (j = 0; j < i; j++) + { Jline += RefMatrix(i, j) * NewCoeff(dim, j); + } J += Jline * NewCoeff(dim, i); } @@ -143,10 +155,14 @@ void FEmTool_LinearTension::Hessian(const int Dimension1, const int Dimension2, if (Dimension1 < DepTab->LowerRow() || Dimension1 > DepTab->UpperRow() || Dimension2 < DepTab->LowerCol() || Dimension2 > DepTab->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearTension::Hessian"); + } if (DepTab->Value(Dimension1, Dimension2) == 0) + { throw Standard_DomainError("FEmTool_LinearTension::Hessian"); + } int deg = std::min(RefMatrix.UpperRow(), H.RowNumber() - 1), degH = std::min(2 * myOrder + 1, deg); @@ -168,7 +184,9 @@ void FEmTool_LinearTension::Hessian(const int Dimension1, const int Dimension2, k2 = (j <= myOrder) ? j : j - myOrder - 1; H(i1, j1) = mfact * std::pow(coeff, k2) * RefMatrix(i, j); if (i != j) + { H(j1, i1) = H(i1, j1); + } j1++; } // Hermite*Jacobi part of matrix @@ -191,7 +209,9 @@ void FEmTool_LinearTension::Hessian(const int Dimension1, const int Dimension2, { H(i1, j1) = cteh3 * RefMatrix(i, j); if (i != j) + { H(j1, i1) = H(i1, j1); + } j1++; } i1++; @@ -201,14 +221,18 @@ void FEmTool_LinearTension::Hessian(const int Dimension1, const int Dimension2, void FEmTool_LinearTension::Gradient(const int Dimension, math_Vector& G) { if (Dimension < myCoeff->LowerCol() || Dimension > myCoeff->UpperCol()) + { throw Standard_OutOfRange("FEmTool_LinearTension::Gradient"); + } int deg = std::min(G.Length() - 1, myCoeff->ColLength() - 1); math_Vector X(0, deg); int i, i1 = myCoeff->LowerRow(); for (i = 0; i <= deg; i++) + { X(i) = myCoeff->Value(i1 + i, Dimension); + } math_Matrix H(0, deg, 0, deg); Hessian(Dimension, Dimension, H); diff --git a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ProfileMatrix.cxx b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ProfileMatrix.cxx index 49539e763b..27587857e7 100644 --- a/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ProfileMatrix.cxx +++ b/src/ModelingData/TKGeomBase/FEmTool/FEmTool_ProfileMatrix.cxx @@ -43,17 +43,25 @@ FEmTool_ProfileMatrix::FEmTool_ProfileMatrix(const NCollection_Array1& Firs NextCoeff = new NCollection_HArray1(1, profile(2, FirstIndexes.Length())); for (i = 1, k = 1; i <= FirstIndexes.Length(); i++) + { for (j = FirstIndexes(i); j <= i; j++) { for (l = i + 1; l <= FirstIndexes.Length() && j < FirstIndexes(l); l++) + { ; + } if (l > FirstIndexes.Length()) + { NextCoeff->SetValue(k, 0); + } else + { NextCoeff->SetValue(k, l); + } k++; } + } ProfileMatrix = new NCollection_HArray1(1, profile(2, FirstIndexes.Length())); SMatrix = new NCollection_HArray1(1, profile(2, FirstIndexes.Length())); @@ -107,7 +115,9 @@ bool FEmTool_ProfileMatrix::Decompose() Kj = j - profile(1, j); Sum = 0; for (k = DiagAddr - profile(1, j); k < DiagAddr; k++) + { Sum += SMA[k] * SMA[k]; + } a = PM[DiagAddr] - Sum; if (a < Eps) @@ -146,7 +156,9 @@ bool FEmTool_ProfileMatrix::Decompose() void FEmTool_ProfileMatrix::Solve(const math_Vector& B, math_Vector& X) const { if (!IsDecomp) + { throw StdFail_NotDone("Decomposition must be done"); + } int i, j, jj, DiagAddr, CurrAddr; double Sum; @@ -166,7 +178,9 @@ void FEmTool_ProfileMatrix::Solve(const math_Vector& B, math_Vector& X) const DiagAddr = profile(2, i); Sum = 0; for (j = i - profile(1, i), jj = DiagAddr - (i - j); j < i; j++, jj++) + { Sum += SMA[jj] * x[j]; + } x[i] = (b[i] - Sum) / SMA[DiagAddr]; } @@ -224,7 +238,9 @@ void FEmTool_ProfileMatrix::Multiplied(const math_Vector& X, math_Vector& MX) co DiagAddr = profile(2, i); m[i] = 0; for (j = i - profile(1, i), jj = DiagAddr - (i - j); j <= i; j++, jj++) + { m[i] += PM[jj] * x[j]; + } CurrAddr = DiagAddr; for (j = NC[CurrAddr]; j > 0; j = NC[CurrAddr]) @@ -252,7 +268,9 @@ bool FEmTool_ProfileMatrix::IsInProfile(const int i, const int j) const return (i - j) <= profile(1, i); } else if ((j - i) <= profile(1, j)) + { return true; + } return false; } @@ -260,34 +278,44 @@ bool FEmTool_ProfileMatrix::IsInProfile(const int i, const int j) const void FEmTool_ProfileMatrix::OutM() const { int i, j; - std::cout << "Matrix A" << std::endl; + std::cout << "Matrix A" << '\n'; for (i = 1; i <= RowNumber(); i++) { for (j = 1; j < i - profile(1, i); j++) + { std::cout << "0 "; + } for (j = profile(2, i) - profile(1, i); j <= profile(2, i); j++) + { std::cout << ProfileMatrix->Value(j) << " "; - std::cout << std::endl; + } + std::cout << '\n'; } - std::cout << "NextCoeff" << std::endl; + std::cout << "NextCoeff" << '\n'; for (i = 1; i <= profile(2, RowNumber()); i++) + { std::cout << NextCoeff->Value(i) << " "; - std::cout << std::endl; + } + std::cout << '\n'; } void FEmTool_ProfileMatrix::OutS() const { int i, j; - std::cout << "Matrix S" << std::endl; + std::cout << "Matrix S" << '\n'; for (i = 1; i <= RowNumber(); i++) { for (j = 1; j < i - profile(1, i); j++) + { std::cout << "0 "; + } for (j = profile(2, i) - profile(1, i); j <= profile(2, i); j++) + { std::cout << SMatrix->Value(j) << " "; - std::cout << std::endl; + } + std::cout << '\n'; } } diff --git a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction.cxx b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction.cxx index aea5e35b5b..b323887319 100644 --- a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction.cxx +++ b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction.cxx @@ -41,7 +41,9 @@ GCPnts_DistFunction::GCPnts_DistFunction(const Adaptor3d_Curve& theCurve, bool GCPnts_DistFunction::Value(const double X, double& F) { if (X < myU1 || X > myU2) + { return false; + } // F = -myLin.SquareDistance(myCurve.Value(X)); return true; diff --git a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction2d.cxx b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction2d.cxx index eda4329aea..9d20915fa5 100644 --- a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction2d.cxx +++ b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_DistFunction2d.cxx @@ -41,7 +41,9 @@ GCPnts_DistFunction2d::GCPnts_DistFunction2d(const Adaptor2d_Curve2d& theCurve, bool GCPnts_DistFunction2d::Value(const double X, double& F) { if (X < myU1 || X > myU2) + { return false; + } // gp_Pnt2d aP2d = myCurve.Value(X); F = -myLin.SquareDistance(aP2d); diff --git a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_TangentialDeflection.cxx b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_TangentialDeflection.cxx index 0d25c4e0c6..fa3d0f7ba0 100644 --- a/src/ModelingData/TKGeomBase/GCPnts/GCPnts_TangentialDeflection.cxx +++ b/src/ModelingData/TKGeomBase/GCPnts/GCPnts_TangentialDeflection.cxx @@ -425,17 +425,25 @@ void GCPnts_TangentialDeflection::initialize(const TheCurve& theC, case GeomAbs_BSplineCurve: { Handle(typename GCPnts_TCurveTypes::BSplineCurve) aBS = theC.BSpline(); if (aBS->NbPoles() == 2) + { PerformLinear(theC); + } else + { PerformCurve(theC); + } break; } case GeomAbs_BezierCurve: { Handle(typename GCPnts_TCurveTypes::BezierCurve) aBZ = theC.Bezier(); if (aBZ->NbPoles() == 2) + { PerformLinear(theC); + } else + { PerformCurve(theC); + } break; } default: { @@ -500,7 +508,9 @@ double GCPnts_TangentialDeflection::ArcAngularStep(const double theRadius, // It is not suitable to consider min size greater than 1/4 arc len. if (theMinLength > aPrecision) + { aMinSizeAng = std::min(theMinLength / theRadius, M_PI_2); + } } Du = 2.0 * std::acos(Du); Du = std::max(std::min(Du, theAngularDeflection), aMinSizeAng); @@ -640,9 +650,13 @@ void GCPnts_TangentialDeflection::PerformCurve(const TheCurve& theC) } if (Du > Dusave) + { Du = Dusave; + } else + { Dusave = Du; + } if (Du < myUTol) { @@ -821,9 +835,13 @@ void GCPnts_TangentialDeflection::PerformCurve(const TheCurve& theC) { Du += (Du - Dusave) * (Du / Dusave); if (Du > 1.5 * Dusave) + { Du = 1.5 * Dusave; + } if (Du < 0.75 * Dusave) + { Du = 0.75 * Dusave; + } } } else @@ -831,9 +849,13 @@ void GCPnts_TangentialDeflection::PerformCurve(const TheCurve& theC) // Angle is the splitting criterion Du += (Du - Dusave) * (Du / Dusave); if (Du > 1.5 * Dusave) + { Du = 1.5 * Dusave; + } if (Du < 0.75 * Dusave) + { Du = 0.75 * Dusave; + } } } diff --git a/src/ModelingData/TKGeomBase/GProp/GProp_GProps.cxx b/src/ModelingData/TKGeomBase/GProp/GProp_GProps.cxx index 1d44584263..a8f36fff18 100644 --- a/src/ModelingData/TKGeomBase/GProp/GProp_GProps.cxx +++ b/src/ModelingData/TKGeomBase/GProp/GProp_GProps.cxx @@ -42,7 +42,9 @@ GProp_GProps::GProp_GProps(const gp_Pnt& SystemLocation) void GProp_GProps::Add(const GProp_GProps& Item, const double Density) { if (Density <= gp::Resolution()) + { throw Standard_DomainError(); + } if (loc.Distance(Item.loc) <= gp::Resolution()) { gp_XYZ GXYZ = (Item.g.XYZ()).Multiplied(Item.dim * Density); diff --git a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_BezierCurve_Test.cxx b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_BezierCurve_Test.cxx index 2483e48b55..a4343039ff 100644 --- a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_BezierCurve_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_BezierCurve_Test.cxx @@ -594,7 +594,9 @@ TEST_F(ExtremaPC_BezierCurveTest, VerifyExtremumCondition) // Skip boundary points where derivative condition may not hold // Use generous tolerance since boundary extrema are valid but don't satisfy F=0 if (aU < 0.01 || aU > 0.99) + { continue; + } aInteriorCount++; diff --git a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_Comparison_Test.cxx b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_Comparison_Test.cxx index 6f895495ba..66479c0225 100644 --- a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_Comparison_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_Comparison_Test.cxx @@ -422,7 +422,7 @@ TEST_F(ExtremaPC_ComparisonTest, BSpline_MultiSpan) double aNewMinDist = std::sqrt(aNewResult.MinSquareDistance()); double aOldMinDist = std::sqrt(aOldMinSqDist); std::cout << " [INFO] BSpline_MultiSpan: Old min dist = " << aOldMinDist - << ", New min dist = " << aNewMinDist << std::endl; + << ", New min dist = " << aNewMinDist << '\n'; } } diff --git a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_ExtendedGeometry_Test.cxx b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_ExtendedGeometry_Test.cxx index aa405888f2..c77883aa41 100644 --- a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_ExtendedGeometry_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_ExtendedGeometry_Test.cxx @@ -896,7 +896,9 @@ TEST_F(ExtremaPC_ExtendedGeometryTest, Random_Circle_100Points) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone()) + { continue; + } if (aNewResult.IsDone() && aNewResult.NbExt() > 0) { @@ -940,7 +942,9 @@ TEST_F(ExtremaPC_ExtendedGeometryTest, Random_Ellipse_100Points) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone()) + { continue; + } if (aNewResult.IsDone() && aNewResult.NbExt() > 0) { @@ -985,10 +989,14 @@ TEST_F(ExtremaPC_ExtendedGeometryTest, Random_Parabola_100Points) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone() || anOldExtPC.NbExt() == 0) + { continue; + } if (!aNewResult.IsDone() || aNewResult.NbExt() == 0) + { continue; + } ++aValidCount; diff --git a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_SearchMode_Test.cxx b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_SearchMode_Test.cxx index 83d0ae318d..15e0c1233a 100644 --- a/src/ModelingData/TKGeomBase/GTests/ExtremaPC_SearchMode_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/ExtremaPC_SearchMode_Test.cxx @@ -868,7 +868,9 @@ TEST_F(ExtremaPC_SearchModeTest, Circle_RandomPoints_MinMode) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone()) + { continue; + } ASSERT_TRUE(aNewResult.IsDone()) << "Iteration " << i; @@ -899,7 +901,9 @@ TEST_F(ExtremaPC_SearchModeTest, Circle_RandomPoints_MaxMode) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone()) + { continue; + } ASSERT_TRUE(aNewResult.IsDone()) << "Iteration " << i; @@ -930,7 +934,9 @@ TEST_F(ExtremaPC_SearchModeTest, Ellipse_RandomPoints_MinMode) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone()) + { continue; + } ASSERT_TRUE(aNewResult.IsDone()) << "Iteration " << i; @@ -977,10 +983,14 @@ TEST_F(ExtremaPC_SearchModeTest, BSpline_RandomPoints_MinMode) Extrema_ExtPC anOldExtPC(aPoint, anAdaptor); if (!anOldExtPC.IsDone() || anOldExtPC.NbExt() == 0) + { continue; + } if (!aNewResult.IsDone() || aNewResult.NbExt() == 0) + { continue; + } ++aTestCount; diff --git a/src/ModelingData/TKGeomBase/GTests/GeomLProp_CurAndInf2d_Test.cxx b/src/ModelingData/TKGeomBase/GTests/GeomLProp_CurAndInf2d_Test.cxx index e4ca5c2acf..02e0cd5b00 100644 --- a/src/ModelingData/TKGeomBase/GTests/GeomLProp_CurAndInf2d_Test.cxx +++ b/src/ModelingData/TKGeomBase/GTests/GeomLProp_CurAndInf2d_Test.cxx @@ -110,9 +110,13 @@ TEST_F(GeomLProp_CurAndInf2dTest, Ellipse_PerformCurExt_Types) { const LProp_CIType aType = aAnalyzer.Type(i); if (aType == LProp_MinCur) + { ++aNbMin; + } else if (aType == LProp_MaxCur) + { ++aNbMax; + } } EXPECT_EQ(aNbMin, 2); EXPECT_EQ(aNbMax, 2); diff --git a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert.cxx b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert.cxx index 2ea8b3903b..d7472423d7 100644 --- a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert.cxx +++ b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert.cxx @@ -110,11 +110,15 @@ occ::handle Geom2dConvert::SplitBSplineCurve( int TheFirst = C->FirstUKnotIndex(); int TheLast = C->LastUKnotIndex(); if (FromK1 == ToK2) + { throw Standard_DomainError(); + } int FirstK = std::min(FromK1, ToK2); int LastK = std::max(FromK1, ToK2); if (FirstK < TheFirst || LastK > TheLast) + { throw Standard_OutOfRange(); + } occ::handle NewCurve = occ::down_cast(C->Copy()); @@ -123,12 +127,16 @@ occ::handle Geom2dConvert::SplitBSplineCurve( if (C->IsPeriodic()) { if (!SameOrientation) + { NewCurve->Reverse(); + } } else { if (FromK1 > ToK2) + { NewCurve->Reverse(); + } } return NewCurve; } @@ -153,12 +161,16 @@ occ::handle Geom2dConvert::SplitBSplineCurve( if (C->IsPeriodic()) { if (!SameOrientation) + { C1->Reverse(); + } } else { if (FromU1 > ToU2) + { C1->Reverse(); + } } return C1; @@ -187,9 +199,13 @@ occ::handle Geom2dConvert::CurveToBSplineCurve( if (!Curv->IsPeriodic()) { if (U1 < Curv->FirstParameter()) + { U1 = Curv->FirstParameter(); + } if (U2 > Curv->LastParameter()) + { U2 = Curv->LastParameter(); + } } if (Curv->IsKind(STANDARD_TYPE(Geom2d_Line))) @@ -342,9 +358,13 @@ occ::handle Geom2dConvert::CurveToBSplineCurve( int MaxSegments = 16, MaxDegree = 14; Geom2dConvert_ApproxCurve ApprCOffs(C, Tol2d, Order, MaxSegments, MaxDegree); if (ApprCOffs.HasResult()) + { TheCurve = ApprCOffs.Curve(); + } else + { throw Standard_ConstructionError(); + } } else @@ -410,9 +430,13 @@ occ::handle Geom2dConvert::CurveToBSplineCurve( int MaxSegments = 16, MaxDegree = 14; Geom2dConvert_ApproxCurve ApprCOffs(C, Tol2d, Order, MaxSegments, MaxDegree); if (ApprCOffs.HasResult()) + { TheCurve = ApprCOffs.Curve(); + } else + { throw Standard_ConstructionError(); + } } else @@ -450,7 +474,9 @@ public: theResult = aPoint.Coord(2); } else + { theErrorCode = 1; + } } private: @@ -504,8 +530,12 @@ static occ::handle MultNumandDenom(const occ::handle resFlatKnots(1, resNbPoles + degree + 1); BSplCLib::KnotSequence(resKnots->Array1(), resMults->Array1(), resFlatKnots); for (ii = 1; ii <= BS->NbPoles(); ii++) + { for (jj = 1; jj <= 2; jj++) + { BSPoles(ii).SetCoord(jj, BSPoles(ii).Coord(jj) * BSWeights(ii)); + } + } // POP for NT Geom2dConvert_law_evaluator ev(anAncore); BSplCLib::FunctionMultiply(ev, @@ -525,8 +555,12 @@ static occ::handle MultNumandDenom(const occ::handleArray1(), resMults->Array1(), degree); return res; @@ -547,9 +581,13 @@ static void Pretreatment(NCollection_Array1>& t a = tab(i)->Weight(1); if ((tab(i)->Weight(2) == a) && (tab(i)->Weight(tab(i)->NbPoles() - 1) == a) && (tab(i)->Weight(tab(i)->NbPoles()) == a)) + { for (j = 1; j <= tab(i)->NbPoles(); j++) + { tab(i)->SetWeight(j, tab(i)->Weight(j) / a); + } + } } } } @@ -573,7 +611,9 @@ static bool NeedToBeTreated(const occ::handle& BS) || (BS->Weight(BS->NbPoles()) > (1 + Precision::Confusion()))); } else + { return false; + } } //================================================================================================= @@ -604,11 +644,13 @@ static int Indexmin(const NCollection_Array1>& degree = tab(0)->Degree(); for (i = 0; i <= tab.Length() - 1; i++) + { if (tab(i)->Degree() <= degree) { degree = tab(i)->Degree(); index = i; } + } return index; } @@ -636,7 +678,9 @@ static void ReorderArrayOfG1(NCollection_Array1 tabbisG1(i) = tabG1(i); } else + { ArraybisOfCurves(i) = ArrayOfCurves(i); + } } for (i = 0; i <= (ArrayOfCurves.Length() - (StartIndex + 2)); i++) @@ -661,7 +705,9 @@ static void ReorderArrayOfG1(NCollection_Array1 tabG1(i) = tabbisG1(i - (ArrayOfCurves.Length() - (StartIndex + 1))); } else + { ArrayOfCurves(i) = ArraybisOfCurves(i - (ArrayOfCurves.Length() - (StartIndex + 1))); + } } } @@ -799,7 +845,9 @@ static GeomAbs_Shape Continuity(const occ::handle& C1, } } else + { throw Standard_Failure("Courbes non jointives"); + } return cont; } @@ -877,16 +925,20 @@ void Geom2dConvert::ConcatG1( First = ArrayOfCurves(i)->FirstParameter(); if (Continuity(ArrayOfCurves(i - 1), ArrayOfCurves(i), PreLast, First, true, true) < GeomAbs_C0) - // clang-format off - throw Standard_ConstructionError("Geom2dConvert curves not C0") ; //renvoi d'une erreur - // clang-format on + { + throw Standard_ConstructionError("Geom2dConvert curves not C0"); // renvoi d'une erreur + } else { if (Continuity(ArrayOfCurves(i - 1), ArrayOfCurves(i), PreLast, First, true, true) >= GeomAbs_G1) + { tabG1(i - 1) = true; // True=Continuite G1 + } else + { tabG1(i - 1) = false; + } } } PreLast = ArrayOfCurves(i)->LastParameter(); @@ -896,10 +948,14 @@ void Geom2dConvert::ConcatG1( { // Determination of Wire characteristics nb_vertexG1 = 0; while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } nb_group++; if (index == 0) + { nb_vertex_group0 = nb_vertexG1; + } index = index + 1 + nb_vertexG1; } @@ -923,14 +979,18 @@ void Geom2dConvert::ConcatG1( { Curve1 = ArrayOfCurves(nb_curve - 1); if (Curve1->Degree() > Geom2d_BSplineCurve::MaxDegree() / 2) + { ClosedFlag = false; + } } if ((nb_group == 1) && (ClosedFlag)) { // treatment of a particular case indexmin = Indexmin(ArrayOfCurves); if (indexmin != (ArrayOfCurves.Length() - 1)) + { ReorderArrayOfG1(ArrayOfCurves, local_tolerance, tabG1, indexmin, ClosedTolerance); + } Curve2 = ArrayOfCurves(0); for (j = 1; j <= nb_curve - 1; j++) { // secondary loop inside each group @@ -965,7 +1025,9 @@ void Geom2dConvert::ConcatG1( NCollection_Array1 Curve1Poles(Curve1->Poles()); for (ii = 1; ii <= Curve1->NbKnots(); ii++) + { KnotC1Mults(ii) = (Curve1->Degree() + KnotC1Mults(ii)); + } NCollection_Array1 FlatKnots(1, Curve1FlatKnots.Length() @@ -976,8 +1038,12 @@ void Geom2dConvert::ConcatG1( int aStatus; const NCollection_Array1& Curve1Weights = Curve1->WeightsArray(); for (ii = 1; ii <= Curve1->NbPoles(); ii++) + { for (jj = 1; jj <= 2; jj++) + { Curve1Poles(ii).SetCoord(jj, Curve1Poles(ii).Coord(jj) * Curve1Weights(ii)); + } + } // POP for NT Geom2dConvert_reparameterise_evaluator ev(aPolynomialCoefficient); BSplCLib::FunctionReparameterise(ev, @@ -1017,8 +1083,12 @@ void Geom2dConvert::ConcatG1( // aStatus // ); for (ii = 1; ii <= NewPoles.Length(); ii++) + { for (jj = 1; jj <= 2; jj++) + { NewPoles(ii).SetCoord(jj, NewPoles(ii).Coord(jj) / NewWeights(ii)); + } + } Curve1 = new Geom2d_BSplineCurve(NewPoles, NewWeights, KnotC1, KnotC1Mults, aNewCurveDegree); } @@ -1026,7 +1096,9 @@ void Geom2dConvert::ConcatG1( fusion = C.Add(Curve1, local_tolerance(j - 1)); // merge two adjacent curves if (!fusion) + { throw Standard_ConstructionError("Geom2dConvert Concatenation Error"); + } Curve2 = C.BSplineCurve(); } Curve2->SetPeriodic(); // single C1 curve @@ -1037,29 +1109,39 @@ void Geom2dConvert::ConcatG1( } else - // clang-format off - for (i=0;i<=nb_group-1;i++){ //main loop on each group of - nb_vertexG1=0; //internal G1 continuity - - while (((index+nb_vertexG1)<=nb_curve-2)&&(tabG1(index+nb_vertexG1))) - nb_vertexG1++; - - for (j=index;j<=index+nb_vertexG1;j++){ //boucle secondaire a l'interieur de chaque groupe - Curve1=ArrayOfCurves(j); - - if (index==j) //initialisation en debut de groupe - ArrayOfConcatenated->SetValue(i,Curve1); - else{ - Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); - fusion=C.Add(Curve1,ArrayOfToler(j-1)); //fusion de deux courbes adjacentes - // clang-format on + { + for (i = 0; i <= nb_group - 1; i++) + { // main loop on each group of + nb_vertexG1 = 0; // internal G1 continuity + + while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { + nb_vertexG1++; + } + + for (j = index; j <= index + nb_vertexG1; j++) + { // boucle secondaire a l'interieur de chaque groupe + Curve1 = ArrayOfCurves(j); + + if (index == j) + { // initialisation en debut de groupe + ArrayOfConcatenated->SetValue(i, Curve1); + } + else + { + Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); + fusion = C.Add(Curve1, ArrayOfToler(j - 1)); // fusion de deux courbes adjacentes + if (!fusion) + { throw Standard_ConstructionError("Geom2dConvert Concatenation Error"); + } ArrayOfConcatenated->SetValue(i, C.BSplineCurve()); } } index = index + 1 + nb_vertexG1; } + } } //================================================================================================= @@ -1121,9 +1203,9 @@ void Geom2dConvert::ConcatC1( ArrayOfToler(i - 1), AngularTolerance) < GeomAbs_C0) - // clang-format off - throw Standard_ConstructionError("Geom2dConvert curves not C0") ; //renvoi d'une erreur - // clang-format on + { + throw Standard_ConstructionError("Geom2dConvert curves not C0"); // renvoi d'une erreur + } else { if (Continuity(ArrayOfCurves(i - 1), @@ -1135,9 +1217,13 @@ void Geom2dConvert::ConcatC1( ArrayOfToler(i - 1), AngularTolerance) >= GeomAbs_G1) + { tabG1(i - 1) = true; // True=Continuite G1 + } else + { tabG1(i - 1) = false; + } } } PreLast = ArrayOfCurves(i)->LastParameter(); @@ -1147,10 +1233,14 @@ void Geom2dConvert::ConcatC1( { // Determination of Wire characteristics nb_vertexG1 = 0; while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } nb_group++; if (index == 0) + { nb_vertex_group0 = nb_vertexG1; + } index = index + 1 + nb_vertexG1; } @@ -1174,7 +1264,9 @@ void Geom2dConvert::ConcatC1( { Curve1 = ArrayOfCurves(nb_curve - 1); if (Curve1->Degree() > Geom2d_BSplineCurve::MaxDegree() / 2) + { ClosedFlag = false; + } } if ((nb_group == 1) && (ClosedFlag)) @@ -1183,7 +1275,9 @@ void Geom2dConvert::ConcatC1( ArrayOfIndices->SetValue(1, 0); indexmin = Indexmin(ArrayOfCurves); if (indexmin != (ArrayOfCurves.Length() - 1)) + { ReorderArrayOfG1(ArrayOfCurves, local_tolerance, tabG1, indexmin, ClosedTolerance); + } for (j = 0; j <= nb_curve - 1; j++) { // secondary loop inside each group if (NeedToBeTreated(ArrayOfCurves(j))) @@ -1191,12 +1285,16 @@ void Geom2dConvert::ConcatC1( Curve1 = MultNumandDenom(Hermit::Solution(ArrayOfCurves(j)), ArrayOfCurves(j)); } else + { Curve1 = ArrayOfCurves(j); + } const int aNewCurveDegree = 2 * Curve1->Degree(); - if (j == 0) // initialisation en debut de groupe + if (j == 0) + { // initialisation en debut de groupe Curve2 = Curve1; + } else { if ((j == (nb_curve - 1)) && (NeedDoubleDegRepara)) @@ -1228,7 +1326,9 @@ void Geom2dConvert::ConcatC1( NCollection_Array1 Curve1Poles(Curve1->Poles()); for (ii = 1; ii <= Curve1->NbKnots(); ii++) + { KnotC1Mults(ii) = (Curve1->Degree() + KnotC1Mults(ii)); + } NCollection_Array1 FlatKnots(1, Curve1FlatKnots.Length() @@ -1239,8 +1339,12 @@ void Geom2dConvert::ConcatC1( int aStatus; const NCollection_Array1& Curve1Weights = Curve1->WeightsArray(); for (ii = 1; ii <= Curve1->NbPoles(); ii++) + { for (jj = 1; jj <= 2; jj++) + { Curve1Poles(ii).SetCoord(jj, Curve1Poles(ii).Coord(jj) * Curve1Weights(ii)); + } + } // POP for NT Geom2dConvert_reparameterise_evaluator ev(aPolynomialCoefficient); BSplCLib::FunctionReparameterise(ev, @@ -1263,7 +1367,9 @@ void Geom2dConvert::ConcatC1( for (ii = 1; ii <= NewPoles.Length(); ii++) { for (jj = 1; jj <= 2; jj++) + { NewPoles(ii).SetCoord(jj, NewPoles(ii).Coord(jj) / NewWeights(ii)); + } } Curve1 = new Geom2d_BSplineCurve(NewPoles, NewWeights, KnotC1, KnotC1Mults, aNewCurveDegree); @@ -1272,7 +1378,9 @@ void Geom2dConvert::ConcatC1( fusion = C.Add(Curve1, local_tolerance(j - 1)); // merge two adjacent curves if (!fusion) + { throw Standard_ConstructionError("Geom2dConvert Concatenation Error"); + } Curve2 = C.BSplineCurve(); } } @@ -1284,52 +1392,66 @@ void Geom2dConvert::ConcatC1( } else + { // clang-format off for (i=0;i<=nb_group-1;i++){ //boucle principale sur chaque groupe de // clang-format on nb_vertexG1 = 0; // continuite interne G1 while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } if ((!ClosedFlag) || (nb_group == 1)) { // Filling the array of preserved indices k++; ArrayOfIndices->SetValue(k - 1, index); if (k == nb_group) + { ArrayOfIndices->SetValue(k, 0); + } } else { k++; ArrayOfIndices->SetValue(k - 1, index + nb_vertex_group0 + 1); if (k == nb_group) + { ArrayOfIndices->SetValue(k, nb_vertex_group0 + 1); + } } // clang-format off for (j=index;j<=index+nb_vertexG1;j++){ //boucle secondaire a l'interieur de chaque groupe // clang-format on if (NeedToBeTreated(ArrayOfCurves(j))) + { Curve1 = MultNumandDenom(Hermit::Solution(ArrayOfCurves(j)), ArrayOfCurves(j)); + } else + { Curve1 = ArrayOfCurves(j); + } - if (index == j) // initialisation en debut de groupe + if (index == j) + { // initialisation en debut de groupe ArrayOfConcatenated->SetValue(i, Curve1); + } else { Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); - // clang-format off - fusion=C.Add(Curve1,ArrayOfToler(j-1)); //fusion de deux courbes adjacentes - // clang-format on + fusion = C.Add(Curve1, ArrayOfToler(j - 1)); // fusion de deux courbes adjacentes if (!fusion) + { throw Standard_ConstructionError("Geom2dConvert Concatenation Error"); + } ArrayOfConcatenated->SetValue(i, C.BSplineCurve()); } } index = index + 1 + nb_vertexG1; } + } } //================================================================================================= @@ -1349,7 +1471,9 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(occ::handle& for (i = BS->FirstUKnotIndex() + 1; i <= (BS->LastUKnotIndex() - 1); i++) { if (BSMults(i) == BS->Degree()) + { nbcurveC1++; + } } nbcurveC1 = std::min(nbcurveC1, BS->NbKnots() - 1); @@ -1360,7 +1484,9 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(occ::handle& NCollection_Array1 ArrayOfToler(0, nbcurveC1 - 2); for (i = 0; i <= nbcurveC1 - 2; i++) + { ArrayOfToler(i) = tolerance; + } U2 = BS->FirstParameter(); j = BS->FirstUKnotIndex() + 1; for (i = 0; i < nbcurveC1; i++) @@ -1368,7 +1494,9 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(occ::handle& U1 = U2; while (j < BS->LastUKnotIndex() && BSMults(j) < BS->Degree()) + { j++; + } U2 = BSKnots(j); j++; @@ -1404,7 +1532,9 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(occ::handle& { fusion = C.Add(ArrayOfConcatenated->Value(i), tolerance, true); if (!fusion) + { throw Standard_ConstructionError("Geom2dConvert Concatenation Error"); + } } } BS = C.BSplineCurve(); @@ -1441,7 +1571,9 @@ void Geom2dConvert::C0BSplineToArrayOfC1BSplineCurve( for (i = BS->FirstUKnotIndex(); i <= (BS->LastUKnotIndex() - 1); i++) { if (BSMults(i) == BS->Degree()) + { nbcurveC1++; + } } nbcurveC1 = std::min(nbcurveC1, BS->NbKnots() - 1); @@ -1452,14 +1584,18 @@ void Geom2dConvert::C0BSplineToArrayOfC1BSplineCurve( NCollection_Array1 ArrayOfToler(0, nbcurveC1 - 2); for (i = 0; i <= nbcurveC1 - 2; i++) + { ArrayOfToler(i) = Tolerance; + } U2 = BS->FirstParameter(); j = BS->FirstUKnotIndex() + 1; for (i = 0; i < nbcurveC1; i++) { U1 = U2; while (j < BS->LastUKnotIndex() && BSMults(j) < BS->Degree()) + { j++; + } U2 = BSKnots(j); j++; occ::handle BSbis = occ::down_cast(BS->Copy()); diff --git a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxArcsSegments.cxx b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxArcsSegments.cxx index 18f84406dd..befefe8ad5 100644 --- a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxArcsSegments.cxx +++ b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxArcsSegments.cxx @@ -89,7 +89,9 @@ Geom2dConvert_ApproxArcsSegments::Geom2dConvert_ApproxArcsSegments( mySeqCurves.Append(aCurve); aCurve = makeCircle(aPP, myExt[1]); if (!aCurve.IsNull()) + { mySeqCurves.Append(aCurve); + } } } break; @@ -101,7 +103,9 @@ Geom2dConvert_ApproxArcsSegments::Geom2dConvert_ApproxArcsSegments( if (myStatus == StatusNotDone) { if (!mySeqCurves.IsEmpty()) + { myStatus = StatusOK; + } else { // std::cout << "GeomConv2d_Approx: no geometry converted." << std::endl; @@ -123,7 +127,9 @@ occ::handle Geom2dConvert_ApproxArcsSegments::makeCircle( GC_MakeArcOfCircle2d aMakeArc1(theFirst.Point(), aPointM, theLast.Point()); if (aMakeArc1.IsDone()) + { aResult = aMakeArc1.Value(); + } // else // std::cout << "makeCircle(): Circle not built" << std::endl; return aResult; @@ -144,9 +150,13 @@ bool Geom2dConvert_ApproxArcsSegments::makeArc(const Geom2dConvert_PPoint& const gp_XY aDelta = aP2 - aP1; double aSense = aVec ^ aDelta; if (aSense > Precision::Angular()) + { aSense = 1.; + } else if (aSense < -Precision::Angular()) + { aSense = -1.; + } else { // std::cout << "makeArc(): Arc Not Built" << std::endl; @@ -184,8 +194,10 @@ bool Geom2dConvert_ApproxArcsSegments::makeArc(const Geom2dConvert_PPoint& } if (fabs(anAlpha1 - anAlpha2) < 1e-100) + { // very small value, just to avoid exact match return false; + } // Reverse the circle if the sense is negative if (aSense < 0.) @@ -216,14 +228,18 @@ occ::handle Geom2dConvert_ApproxArcsSegments::makeLine( gp_XY aSlope = theLast.Point() - theFirst.Point(); if (fabs(aSlope.SquareModulus()) < gp::Resolution()) + { return aResult; + } gp_Dir2d aDirLine(aSlope); if (isCheck) { if (theFirst.D1().SquareModulus() < gp::Resolution() || theLast.D1().SquareModulus() < gp::Resolution()) + { return aResult; + } // Angular continuity (G1) is only checked when the end of the line is not // on the extremity of the curve @@ -289,9 +305,11 @@ bool Geom2dConvert_ApproxArcsSegments::makeFreeform() Geom2dConvert_PPoint& aParam0 = seqParamPoints.ChangeValue(i); Geom2dConvert_PPoint& aParam1 = seqParamPoints.ChangeValue(i + 1); if (aParam0 != aParam1) + { // linear part of the curve lies between odd and even values of i. // parameters from parameter's sequence. aLineCurve = makeLine(aParam0, aParam1, false); + } aSeqLinearParts.Append(aLineCurve); } @@ -303,9 +321,11 @@ bool Geom2dConvert_ApproxArcsSegments::makeFreeform() const int aLastInd = mySeqCurves.Length(); isDone = makeApproximation(*aPrevParam, seqParamPoints(i)); if (isDone && aLastInd && mySeqCurves.Length() > aLastInd) + { isDone = checkContinuity(mySeqCurves.Value(aLastInd), mySeqCurves.Value(aLastInd + 1), myAngleTolerance); + } if (!isDone) { myStatus = StatusError; @@ -315,7 +335,9 @@ bool Geom2dConvert_ApproxArcsSegments::makeFreeform() const occ::handle& aCurve = aSeqLinearParts.Value((i + 1) / 2); if (!aCurve.IsNull()) + { mySeqCurves.Append(aCurve); + } else { Geom2dConvert_PPoint& aParam0 = seqParamPoints.ChangeValue(i); @@ -323,9 +345,11 @@ bool Geom2dConvert_ApproxArcsSegments::makeFreeform() const int aLastInd = mySeqCurves.Length(); isDone = makeApproximation(aParam0, aParam1); if (isDone && aLastInd && mySeqCurves.Length() > aLastInd) + { isDone = checkContinuity(mySeqCurves.Value(aLastInd), mySeqCurves.Value(aLastInd + 1), myAngleTolerance); + } if (!isDone) { @@ -346,7 +370,9 @@ bool Geom2dConvert_ApproxArcsSegments::makeFreeform() Geom2dConvert_PPoint aPPoint(0.5 * (myExt[0].Parameter() + myExt[1].Parameter()), myCurve); isDone = makeApproximation(myExt[0], aPPoint); if (isDone) + { isDone = makeApproximation(aPPoint, myExt[1]); + } } else { @@ -475,7 +501,9 @@ void Geom2dConvert_ApproxArcsSegments::getLinearParts( { aLastInflParam = aCurParam; if (i > 1) + { aFirstInflParam = findInflection(aCurParam, mySeqParams(i - 1)); + } indStartLinear = i; } } @@ -501,9 +529,13 @@ Geom2dConvert_PPoint Geom2dConvert_ApproxArcsSegments::findInflection( { // 3 iterations aTest = (aLower + anUpper) * 0.5; if (isInflectionPoint(aTest, theParamIsInfl, myCurve, myAngleTolerance)) + { aLower = aTest; + } else + { anUpper = aTest; + } } return Geom2dConvert_PPoint(aTest, myCurve); } @@ -524,7 +556,9 @@ bool Geom2dConvert_ApproxArcsSegments::makeApproximation(Geom2dConvert_PPoint& t const occ::handle aCurve = makeLine(theFirstParam, theLastParam, true); isDone = !aCurve.IsNull(); if (isDone && mySeqCurves.Length()) + { isDone = checkContinuity(mySeqCurves.Last(), aCurve, myAngleTolerance); + } if (isDone || aDistance < Precision::Confusion()) { mySeqCurves.Append(aCurve); @@ -542,7 +576,9 @@ bool Geom2dConvert_ApproxArcsSegments::makeApproximation(Geom2dConvert_PPoint& t myCurve); isDone = makeApproximation(theFirstParam, aParaM); if (isDone) + { isDone = makeApproximation(aParaM, theLastParam); + } } } return isDone; @@ -570,15 +606,21 @@ bool Geom2dConvert_ApproxArcsSegments::calculateBiArcs(Geom2dConvert_PPoint& the const gp_Vec2d aDelta(aPnt[1] - aPnt[0]); double anAngle1 = aDelta.Angle(gp_Vec2d(aDir[0])); if (anAngle1 < 0.) + { anAngle1 = -anAngle1; + } double anAngle2 = aDelta.Angle(gp_Vec2d(aDir[1])); if (anAngle2 < 0.) + { anAngle2 = -anAngle2; + } // in the case when two angles are equal one arc can be built. double anAngleThreshold(Precision::Angular() * 10.); if (theFirstParam != myExt[0] || theLastParam != myExt[1]) + { anAngleThreshold = myAngleTolerance * 0.1; + } if (fabs(anAngle1 - anAngle2) < anAngleThreshold) { occ::handle aCurve; @@ -586,7 +628,9 @@ bool Geom2dConvert_ApproxArcsSegments::calculateBiArcs(Geom2dConvert_PPoint& the // the created arc is rejected. Geom2dConvert_PPoint aLastParam(theLastParam); if (!makeArc(theFirstParam, aLastParam, true, aCurve)) + { return false; + } if (checkCurve(aCurve, theFirstParam.Parameter(), aLastParam.Parameter())) { theLastParam = aLastParam; @@ -621,7 +665,9 @@ bool Geom2dConvert_ApproxArcsSegments::calculateBiArcs(Geom2dConvert_PPoint& the const double aB1 = ad1 / (ad1 + ad2); if (fabs(aB1 - 0.5) < 0.0001) + { return false; + } gp_XY aXY[2] = {aPnt[0] + aDir[0].XY() * ad12 * ad1 / (ad12 + ad1 + ad2), aPnt[1] + aDir[1].XY() * ad12 * ad2 / (ad12 + ad1 + ad2)}; @@ -633,10 +679,14 @@ bool Geom2dConvert_ApproxArcsSegments::calculateBiArcs(Geom2dConvert_PPoint& the // building first arc from biarc. occ::handle aCurve1, aCurve2; if (!makeArc(theFirstParam, aParamMidArc, true, aCurve1)) + { return false; + } if (!checkCurve(aCurve1, theFirstParam.Parameter(), aParamMidArc.Parameter())) + { return false; + } // building second arc from biarc. if (makeArc(theLastParam, aParamMidArc, false, aCurve2)) @@ -696,7 +746,9 @@ bool Geom2dConvert_ApproxArcsSegments::checkCurve(const occ::handle aCurve1 = aCurve; occ::handle aTrCurve = occ::down_cast(aCurve); if (!aTrCurve.IsNull()) + { aCurve1 = aTrCurve->BasisCurve(); + } gp_Lin2d aLin2d; gp_Circ2d aCirc2d; occ::handle aGeomLine = occ::down_cast(aCurve1); bool isLine = (!aGeomLine.IsNull()); bool isCircle = (!isLine); if (isLine) + { aLin2d = aGeomLine->Lin2d(); + } else { occ::handle aGeomCircle = occ::down_cast(aCurve1); isCircle = (!aGeomCircle.IsNull()); if (isCircle) + { aCirc2d = aGeomCircle->Circ2d(); + } else + { return false; + } } // calculation of the max deflection points from CurveAdaptor from Geom curve. @@ -733,7 +793,9 @@ bool Geom2dConvert_ApproxArcsSegments::checkCurve(const occ::handle (theLastParam + Precision::PConfusion())) + { continue; + } // getting point from adaptor curve by specified parameter. gp_Pnt2d aPointAdaptor(0., 0.); diff --git a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx index 1a4eb7cdd9..3005647eb3 100644 --- a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx +++ b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx @@ -204,6 +204,6 @@ double Geom2dConvert_ApproxCurve::MaxError() const void Geom2dConvert_ApproxCurve::Dump(Standard_OStream& o) const { - o << "******* Dump of ApproxCurve *******" << std::endl; - o << "******* Error " << MaxError() << std::endl; + o << "******* Dump of ApproxCurve *******" << '\n'; + o << "******* Error " << MaxError() << '\n'; } diff --git a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx index 781b762786..348d6b7db7 100644 --- a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx +++ b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx @@ -32,7 +32,9 @@ Geom2dConvert_BSplineCurveKnotSplitting::Geom2dConvert_BSplineCurveKnotSplitting { if (ContinuityRange < 0) + { throw Standard_RangeError(); + } int FirstIndex = BasisCurve->FirstUKnotIndex(); int LastIndex = BasisCurve->LastUKnotIndex(); diff --git a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx index 4c29c78059..1bc744c6f7 100644 --- a/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx +++ b/src/ModelingData/TKGeomBase/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx @@ -32,7 +32,9 @@ Geom2dConvert_BSplineCurveToBezierCurve::Geom2dConvert_BSplineCurveToBezierCurve // last pole (equal to first one) is missing; // poles recomputation using default boor scheme is fails. if (myCurve->IsPeriodic()) + { myCurve->SetNotPeriodic(); + } double Uf = myCurve->FirstParameter(); double Ul = myCurve->LastParameter(); myCurve->Segment(Uf, Ul); @@ -50,7 +52,9 @@ Geom2dConvert_BSplineCurveToBezierCurve::Geom2dConvert_BSplineCurveToBezierCurve const double ParametricTolerance) { if (U2 - U1 < ParametricTolerance) + { throw Standard_DomainError("GeomConvert_BSplineCurveToBezierSurface"); + } double Uf = U1, Ul = U2; double PTol = ParametricTolerance / 2; @@ -58,20 +62,26 @@ Geom2dConvert_BSplineCurveToBezierCurve::Geom2dConvert_BSplineCurveToBezierCurve int I1, I2; myCurve = occ::down_cast(BasisCurve->Copy()); if (myCurve->IsPeriodic()) + { myCurve->SetNotPeriodic(); + } myCurve->LocateU(U1, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (myCurve->Knot(I1) > U1) + { Uf = myCurve->Knot(I1); + } } myCurve->LocateU(U2, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (myCurve->Knot(I1) < U2) + { Ul = myCurve->Knot(I1); + } } myCurve->Segment(Uf, Ul); @@ -132,7 +142,9 @@ void Geom2dConvert_BSplineCurveToBezierCurve::Knots(NCollection_Array1& { int ii, kk; for (ii = 1, kk = TKnots.Lower(); ii <= myCurve->NbKnots(); ii++, kk++) + { TKnots(kk) = myCurve->Knot(ii); + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BSplineSurface.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BSplineSurface.cxx index ccf0d97ae1..6d7b82da77 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BSplineSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BSplineSurface.cxx @@ -50,7 +50,9 @@ void ComputePolesIndexes(const NCollection_Array1& theKnots, theOutMaxIdx = BSplCLib::PoleIndex(theDegree, theOutMaxIdx, theIsPeriodic, theMults) + 1; theOutMaxIdx += theDegree - aMultiplier; if (!theIsPeriodic) + { theOutMaxIdx = std::min(theOutMaxIdx, theMaxPoleIdx); + } } } // namespace @@ -130,13 +132,17 @@ Bnd_Box GeomBndLib_BSplineSurface::Box(double theUMin, { int anIP = anI; if (isUPeriodic && anIP > aNbUPoles) + { anIP = anIP - aNbUPoles; + } for (int aJ = aVMinIdx; aJ <= aVMaxIdx; aJ++) { int aJP = aJ; if (isVPeriodic && aJP > aNbVPoles) + { aJP = aJP - aNbVPoles; + } aBox.Add(aPoles(anIP, aJP)); } @@ -239,9 +245,13 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aP.Coord(aK + 1)) + { aCoordMin[aK] = aP.Coord(aK + 1); + } if (aCoordMax[aK] < aP.Coord(aK + 1)) + { aCoordMax[aK] = aP.Coord(aK + 1); + } } // U-midpoint deflection. @@ -253,12 +263,18 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aPM.Coord(aK + 1)) + { aCoordMin[aK] = aPM.Coord(aK + 1); + } if (aCoordMax[aK] < aPM.Coord(aK + 1)) + { aCoordMax[aK] = aPM.Coord(aK + 1); + } const double aDiff = std::abs(aD.Coord(aK + 1)); if (aDeflMax[aK] < aDiff) + { aDeflMax[aK] = aDiff; + } } } // V-midpoint deflection. @@ -270,12 +286,18 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aPM.Coord(aK + 1)) + { aCoordMin[aK] = aPM.Coord(aK + 1); + } if (aCoordMax[aK] < aPM.Coord(aK + 1)) + { aCoordMax[aK] = aPM.Coord(aK + 1); + } const double aDiff = std::abs(aD.Coord(aK + 1)); if (aDeflMax[aK] < aDiff) + { aDeflMax[aK] = aDiff; + } } } } @@ -287,7 +309,9 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, { double aDiff = aDeflMax[aK]; if (aDiff <= anEps) + { continue; + } double aCMin = aCoordMin[aK]; double aCMax = aCoordMax[aK]; @@ -311,7 +335,9 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, anEps, true); if (aLocMin < aCMin) + { aCMin = aLocMin; + } } else if (aCMax - aPnts(anI, aJ).Coord(aK + 1) < aDiff) { @@ -329,7 +355,9 @@ Bnd_Box GeomBndLib_BSplineSurface::BoxOptimal(double theUMin, anEps, false); if (aLocMax > aCMax) + { aCMax = aLocMax; + } } } } diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BezierSurface.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BezierSurface.cxx index 677bb0e946..12a5efe903 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BezierSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_BezierSurface.cxx @@ -154,9 +154,13 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aP.Coord(aK + 1)) + { aCoordMin[aK] = aP.Coord(aK + 1); + } if (aCoordMax[aK] < aP.Coord(aK + 1)) + { aCoordMax[aK] = aP.Coord(aK + 1); + } } // U-midpoint deflection. @@ -168,12 +172,18 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aPM.Coord(aK + 1)) + { aCoordMin[aK] = aPM.Coord(aK + 1); + } if (aCoordMax[aK] < aPM.Coord(aK + 1)) + { aCoordMax[aK] = aPM.Coord(aK + 1); + } const double aDiff = std::abs(aD.Coord(aK + 1)); if (aDeflMax[aK] < aDiff) + { aDeflMax[aK] = aDiff; + } } } // V-midpoint deflection. @@ -185,12 +195,18 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, for (int aK = 0; aK < 3; ++aK) { if (aCoordMin[aK] > aPM.Coord(aK + 1)) + { aCoordMin[aK] = aPM.Coord(aK + 1); + } if (aCoordMax[aK] < aPM.Coord(aK + 1)) + { aCoordMax[aK] = aPM.Coord(aK + 1); + } const double aDiff = std::abs(aD.Coord(aK + 1)); if (aDeflMax[aK] < aDiff) + { aDeflMax[aK] = aDiff; + } } } } @@ -202,7 +218,9 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, { const double aDiff = aDeflMax[aK]; if (aDiff <= anEps) + { continue; + } double aCMin = aCoordMin[aK]; double aCMax = aCoordMax[aK]; @@ -226,7 +244,9 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, anEps, true); if (aLocMin < aCMin) + { aCMin = aLocMin; + } } else if (aCMax - aPnts(anI, aJ).Coord(aK + 1) < aDiff) { @@ -244,7 +264,9 @@ Bnd_Box GeomBndLib_BezierSurface::BoxOptimal(double theUMin, anEps, false); if (aLocMax > aCMax) + { aCMax = aLocMax; + } } } } diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Cone.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Cone.cxx index 6fc6026ba1..5bfd509124 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Cone.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Cone.cxx @@ -91,9 +91,13 @@ Bnd_Box GeomBndLib_Cone::Box(double theUMin, const gp_Circ aC = ElSLib::ConeVIso(aCone.Position(), aCone.RefRadius(), aCone.SemiAngle(), 0.); if (aC.Radius() > Precision::Confusion()) + { aBox.Add(GeomBndLib_Circle::Box(aC, theUMin, theUMax, 0.)); + } else + { aBox.Add(aC.Location()); + } GeomBndLib_InfiniteHelpers::OpenMinMax(aDir, aBox); } else @@ -110,9 +114,13 @@ Bnd_Box GeomBndLib_Cone::Box(double theUMin, const gp_Circ aC = ElSLib::ConeVIso(aCone.Position(), aCone.RefRadius(), aCone.SemiAngle(), 0.); if (aC.Radius() > Precision::Confusion()) + { aBox.Add(GeomBndLib_Circle::Box(aC, theUMin, theUMax, 0.)); + } else + { aBox.Add(aC.Location()); + } GeomBndLib_InfiniteHelpers::OpenMinMax(aDir, aBox); } else if (Precision::IsPositiveInfinite(theVMax)) diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OffsetCurve.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OffsetCurve.cxx index e160de6ef5..03b3e26835 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OffsetCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OffsetCurve.cxx @@ -180,17 +180,29 @@ Bnd_Box GeomBndLib_OffsetCurve::Box(double theU1, double theU2, double theTol) c } if (isOpenXmin) + { aBox.OpenXmin(); + } if (isOpenXmax) + { aBox.OpenXmax(); + } if (isOpenYmin) + { aBox.OpenYmin(); + } if (isOpenYmax) + { aBox.OpenYmax(); + } if (isOpenZmin) + { aBox.OpenZmin(); + } if (isOpenZmax) + { aBox.OpenZmax(); + } aBox.Enlarge(theTol); return aBox; diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve.cxx index b3035f41e2..faa889b257 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve.cxx @@ -108,9 +108,13 @@ Bnd_Box GeomBndLib_OtherCurve::BoxOptimal(double theU1, double theU2, double the for (int k = 0; k < 3; ++k) { if (CoordMin[k] > P.Coord(k + 1)) + { CoordMin[k] = P.Coord(k + 1); + } if (CoordMax[k] < P.Coord(k + 1)) + { CoordMax[k] = P.Coord(k + 1); + } } if (i > 1) { @@ -120,12 +124,18 @@ Bnd_Box GeomBndLib_OtherCurve::BoxOptimal(double theU1, double theU2, double the for (int k = 0; k < 3; ++k) { if (CoordMin[k] > P.Coord(k + 1)) + { CoordMin[k] = P.Coord(k + 1); + } if (CoordMax[k] < P.Coord(k + 1)) + { CoordMax[k] = P.Coord(k + 1); + } double d = std::abs(aD.Coord(k + 1)); if (DeflMax[k] < d) + { DeflMax[k] = d; + } } } } @@ -135,7 +145,9 @@ Bnd_Box GeomBndLib_OtherCurve::BoxOptimal(double theU1, double theU2, double the { double d = DeflMax[k]; if (d <= eps) + { continue; + } double CMin = CoordMin[k]; double CMax = CoordMax[k]; for (int i = 1; i <= Nu; ++i) @@ -147,7 +159,9 @@ Bnd_Box GeomBndLib_OtherCurve::BoxOptimal(double theU1, double theU2, double the double cmin = GeomBndLib_OptimizationHelpers::AdjustExtrCurve(C, umin, umax, CMin, k + 1, eps, true); if (cmin < CMin) + { CMin = cmin; + } } else if (CMax - aPnts(i).Coord(k + 1) < d) { @@ -156,7 +170,9 @@ Bnd_Box GeomBndLib_OtherCurve::BoxOptimal(double theU1, double theU2, double the double cmax = GeomBndLib_OptimizationHelpers::AdjustExtrCurve(C, umin, umax, CMax, k + 1, eps, false); if (cmax > CMax) + { CMax = cmax; + } } } CoordMin[k] = CMin; diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve2d.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve2d.cxx index 820cea3659..93f99e738b 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve2d.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherCurve2d.cxx @@ -249,9 +249,13 @@ Bnd_Box2d GeomBndLib_OtherCurve2d::BoxOptimal(double theU1, double theU2, double for (int k = 0; k < 2; ++k) { if (CoordMin[k] > P.Coord(k + 1)) + { CoordMin[k] = P.Coord(k + 1); + } if (CoordMax[k] < P.Coord(k + 1)) + { CoordMax[k] = P.Coord(k + 1); + } } if (i > 1) { @@ -261,12 +265,18 @@ Bnd_Box2d GeomBndLib_OtherCurve2d::BoxOptimal(double theU1, double theU2, double for (int k = 0; k < 2; ++k) { if (CoordMin[k] > P.Coord(k + 1)) + { CoordMin[k] = P.Coord(k + 1); + } if (CoordMax[k] < P.Coord(k + 1)) + { CoordMax[k] = P.Coord(k + 1); + } double d = std::abs(aD.Coord(k + 1)); if (DeflMax[k] < d) + { DeflMax[k] = d; + } } } } @@ -276,7 +286,9 @@ Bnd_Box2d GeomBndLib_OtherCurve2d::BoxOptimal(double theU1, double theU2, double { double d = DeflMax[k]; if (d <= eps) + { continue; + } double CMin = CoordMin[k]; double CMax = CoordMax[k]; for (int i = 1; i <= Nu; ++i) @@ -287,7 +299,9 @@ Bnd_Box2d GeomBndLib_OtherCurve2d::BoxOptimal(double theU1, double theU2, double double umax = theU1 + std::min(Nu - 1, i) * du; double cmin = AdjustExtr2dCurve(C, umin, umax, CMin, k + 1, eps, true); if (cmin < CMin) + { CMin = cmin; + } } else if (CMax - aPnts(i).Coord(k + 1) < d) { @@ -295,7 +309,9 @@ Bnd_Box2d GeomBndLib_OtherCurve2d::BoxOptimal(double theU1, double theU2, double double umax = theU1 + std::min(Nu - 1, i) * du; double cmax = AdjustExtr2dCurve(C, umin, umax, CMax, k + 1, eps, false); if (cmax > CMax) + { CMax = cmax; + } } } CoordMin[k] = CMin; diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherSurface.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherSurface.cxx index 42a199152e..643e88d45d 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_OtherSurface.cxx @@ -125,9 +125,13 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, for (int k = 0; k < 3; ++k) { if (CoordMin[k] > P.Coord(k + 1)) + { CoordMin[k] = P.Coord(k + 1); + } if (CoordMax[k] < P.Coord(k + 1)) + { CoordMax[k] = P.Coord(k + 1); + } } // U-midpoint deflection. @@ -139,12 +143,18 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, for (int k = 0; k < 3; ++k) { if (CoordMin[k] > PM.Coord(k + 1)) + { CoordMin[k] = PM.Coord(k + 1); + } if (CoordMax[k] < PM.Coord(k + 1)) + { CoordMax[k] = PM.Coord(k + 1); + } const double d = std::abs(aD.Coord(k + 1)); if (DeflMax[k] < d) + { DeflMax[k] = d; + } } } // V-midpoint deflection. @@ -156,12 +166,18 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, for (int k = 0; k < 3; ++k) { if (CoordMin[k] > PM.Coord(k + 1)) + { CoordMin[k] = PM.Coord(k + 1); + } if (CoordMax[k] < PM.Coord(k + 1)) + { CoordMax[k] = PM.Coord(k + 1); + } const double d = std::abs(aD.Coord(k + 1)); if (DeflMax[k] < d) + { DeflMax[k] = d; + } } } } @@ -173,7 +189,9 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, { double d = DeflMax[k]; if (d <= eps) + { continue; + } double CMin = CoordMin[k]; double CMax = CoordMax[k]; @@ -197,7 +215,9 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, eps, true); if (cmin < CMin) + { CMin = cmin; + } } else if (CMax - aPnts(i, j).Coord(k + 1) < d) { @@ -215,7 +235,9 @@ Bnd_Box GeomBndLib_OtherSurface::BoxOptimal(double theUMin, eps, false); if (cmax > CMax) + { CMax = cmax; + } } } } diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola.cxx index f42347ab11..5922a1abe2 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola.cxx @@ -85,7 +85,9 @@ Bnd_Box GeomBndLib_Parabola::Box(const gp_Parab& theParab, { aBox.Add(ElCLib::Value(theU2, theParab)); if (theU1 * theU2 < 0) + { aBox.Add(ElCLib::Value(0., theParab)); + } } } aBox.Enlarge(theTol); diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola2d.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola2d.cxx index 047e22f29a..da39bfe745 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola2d.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_Parabola2d.cxx @@ -79,7 +79,9 @@ Bnd_Box2d GeomBndLib_Parabola2d::Box(const gp_Parab2d& theParab, { aBox.Add(ElCLib::Value(theU2, theParab)); if (theU1 * theU2 < 0) + { aBox.Add(ElCLib::Value(0., theParab)); + } } } aBox.Enlarge(theTol); diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SplineHelpers.pxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SplineHelpers.pxx index f9a89a0e20..04ad7018c6 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SplineHelpers.pxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SplineHelpers.pxx @@ -165,7 +165,9 @@ inline void ComputePoleIndexRange(const NCollection_Array1& theKnots, theOutMaxIdx = BSplCLib::PoleIndex(theDegree, theOutMaxIdx, theIsPeriodic, theMults) + 1; theOutMaxIdx += theDegree - aMultiplier; if (!theIsPeriodic) + { theOutMaxIdx = std::min(theOutMaxIdx, theMaxPoleIdx); + } } //! Reduce box using a selected range of poles [theMinIdx, theMaxIdx]. @@ -183,7 +185,9 @@ void ReduceSplineBox(const NCollection_Array1& thePoles, { int anI = anIdx; if (anI > thePoles.Upper()) + { anI -= aNbPoles; + } aPolesBox.Add(thePoles.Value(anI)); } @@ -241,7 +245,9 @@ TBox BezierCurveBox(const occ::handle& theGeom, aBz->Segment(theU1, theU2); TBox aBox; for (int anI = 1; anI <= aBz->NbPoles(); ++anI) + { aBox.Add(aBz->Pole(anI)); + } aBox.Enlarge(theTol); return aBox; } @@ -288,7 +294,9 @@ TBox BSplineCurveBox(const occ::handle& theGeom, double aSegmentTol = 2. * Precision::PConfusion(); const double aMinDiff = std::min(aDirectDiff, std::min(aCrossPeriodDiff1, aCrossPeriodDiff2)); if (aMinDiff < aSegmentTol) + { aSegmentTol = aMinDiff * 0.01; + } aBs->Segment(aU1, aU2, aSegmentTol); const int aK1 = aBs->FirstUKnotIndex(); @@ -335,7 +343,9 @@ TBox BSplineCurveBox(const occ::handle& theGeom, aBs->Segment(aU1, aU2, 2.0 * Precision::PConfusion()); TBox aBox; for (int anI = 1; anI <= aBs->NbPoles(); ++anI) + { aBox.Add(aBs->Pole(anI)); + } aBox.Enlarge(theTol); return aBox; } @@ -360,10 +370,14 @@ TBox BSplineCurveBox(const occ::handle& theGeom, { const double aLast = (aK < aKMax) ? std::min(aU2, aKnots(aK)) : aU2; if (aLast > aFirst + Precision::PConfusion()) + { aTol = std::max(FillBox(aB1, aGACurve, aFirst, aLast, aDegree), aTol); + } aFirst = aLast; if (aFirst >= aU2 - Precision::PConfusion()) + { break; + } } TBox aBox; if (!aB1.IsVoid()) @@ -412,15 +426,23 @@ TBox CurveBoxOptimal(TAdaptor& theAdaptor, const double aU = theU1 + aJ * aDU; const TPoint aP = theAdaptor.EvalD0(aU); if constexpr (std::is_same_v) + { aPnts(anI) = aP.XYZ(); + } else + { aPnts(anI) = aP.XY(); + } for (int aK = 0; aK < NDim; ++aK) { if (aCoordMin[aK] > aP.Coord(aK + 1)) + { aCoordMin[aK] = aP.Coord(aK + 1); + } if (aCoordMax[aK] < aP.Coord(aK + 1)) + { aCoordMax[aK] = aP.Coord(aK + 1); + } } if (anI > 1) { @@ -428,18 +450,28 @@ TBox CurveBoxOptimal(TAdaptor& theAdaptor, const TPoint aPMid = theAdaptor.EvalD0(aU - aDU2); TCoord aD; if constexpr (std::is_same_v) + { aD = aPMid.XYZ() - aPm; + } else + { aD = aPMid.XY() - aPm; + } for (int aK = 0; aK < NDim; ++aK) { if (aCoordMin[aK] > aPMid.Coord(aK + 1)) + { aCoordMin[aK] = aPMid.Coord(aK + 1); + } if (aCoordMax[aK] < aPMid.Coord(aK + 1)) + { aCoordMax[aK] = aPMid.Coord(aK + 1); + } const double aDiff = std::abs(aD.Coord(aK + 1)); if (aDeflMax[aK] < aDiff) + { aDeflMax[aK] = aDiff; + } } } } @@ -449,7 +481,9 @@ TBox CurveBoxOptimal(TAdaptor& theAdaptor, { const double aDiff = aDeflMax[aK]; if (aDiff <= anEps) + { continue; + } double aCMin = aCoordMin[aK]; double aCMax = aCoordMax[aK]; for (int anI = 1; anI <= aNbSamples; ++anI) @@ -466,7 +500,9 @@ TBox CurveBoxOptimal(TAdaptor& theAdaptor, anEps, true); if (aLocMin < aCMin) + { aCMin = aLocMin; + } } else if (aCMax - aPnts(anI).Coord(aK + 1) < aDiff) { @@ -480,7 +516,9 @@ TBox CurveBoxOptimal(TAdaptor& theAdaptor, anEps, false); if (aLocMax > aCMax) + { aCMax = aLocMax; + } } } aCoordMin[aK] = aCMin; diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfExtrusion.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfExtrusion.cxx index 5104af48bb..051a4c51b9 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfExtrusion.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfExtrusion.cxx @@ -49,23 +49,41 @@ Bnd_Box buildExtrusionBox(const Bnd_Box& theCurveBox, { // Propagate curve openness through the extrusion rather than returning whole space. if (theCurveBox.IsOpenXmin()) + { aBox.OpenXmin(); + } if (theCurveBox.IsOpenXmax()) + { aBox.OpenXmax(); + } if (theCurveBox.IsOpenYmin()) + { aBox.OpenYmin(); + } if (theCurveBox.IsOpenYmax()) + { aBox.OpenYmax(); + } if (theCurveBox.IsOpenZmin()) + { aBox.OpenZmin(); + } if (theCurveBox.IsOpenZmax()) + { aBox.OpenZmax(); + } if (isVMinInf && isVMaxInf) + { GeomBndLib_InfiniteHelpers::OpenMinMax(theDir, aBox); + } else if (isVMinInf) + { GeomBndLib_InfiniteHelpers::OpenMin(theDir, aBox); + } else if (isVMaxInf) + { GeomBndLib_InfiniteHelpers::OpenMax(theDir, aBox); + } if (theCurveBox.HasFinitePart()) { const auto [aXmin, aXmax, aYmin, aYmax, aZmin, aZmax] = theCurveBox.FinitePart().Get(); @@ -158,13 +176,21 @@ Bnd_Box GeomBndLib_SurfaceOfExtrusion::Box(double theUMin, const double aFirst = aBasisCurve->FirstParameter(); const double aLast = aBasisCurve->LastParameter(); if (aCurveU1 < aFirst) + { aCurveU1 = aFirst; + } else if (aCurveU1 > aLast) + { aCurveU1 = aLast; + } if (aCurveU2 < aFirst) + { aCurveU2 = aFirst; + } else if (aCurveU2 > aLast) + { aCurveU2 = aLast; + } if (aCurveU1 > aCurveU2) { const double aTmp = aCurveU1; @@ -214,13 +240,21 @@ Bnd_Box GeomBndLib_SurfaceOfExtrusion::BoxOptimal(double theUMin, const double aFirst = aBasisCurve->FirstParameter(); const double aLast = aBasisCurve->LastParameter(); if (aCurveU1 < aFirst) + { aCurveU1 = aFirst; + } else if (aCurveU1 > aLast) + { aCurveU1 = aLast; + } if (aCurveU2 < aFirst) + { aCurveU2 = aFirst; + } else if (aCurveU2 > aLast) + { aCurveU2 = aLast; + } if (aCurveU1 > aCurveU2) { const double aTmp = aCurveU1; diff --git a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfRevolution.cxx b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfRevolution.cxx index ed1dd462ec..3db901ffde 100644 --- a/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfRevolution.cxx +++ b/src/ModelingData/TKGeomBase/GeomBndLib/GeomBndLib_SurfaceOfRevolution.cxx @@ -88,7 +88,9 @@ static Bnd_Box buildRevolutionBox(const Bnd_Box& theCurveBox, const double aYVals[2] = {aYmin, aYmax}; const double aZVals[2] = {aZmin, aZmax}; for (int ix = 0; ix < 2; ++ix) + { for (int iy = 0; iy < 2; ++iy) + { for (int iz = 0; iz < 2; ++iz) { addRevolutionCircle(theOrigin, @@ -98,20 +100,34 @@ static Bnd_Box buildRevolutionBox(const Bnd_Box& theCurveBox, theUMax, aBox); } + } + } } // Propagate curve openness: open directions remain open after revolution. if (theCurveBox.IsOpenXmin()) + { aBox.OpenXmin(); + } if (theCurveBox.IsOpenXmax()) + { aBox.OpenXmax(); + } if (theCurveBox.IsOpenYmin()) + { aBox.OpenYmin(); + } if (theCurveBox.IsOpenYmax()) + { aBox.OpenYmax(); + } if (theCurveBox.IsOpenZmin()) + { aBox.OpenZmin(); + } if (theCurveBox.IsOpenZmax()) + { aBox.OpenZmax(); + } aBox.Enlarge(theTol); return aBox; } @@ -125,7 +141,9 @@ static Bnd_Box buildRevolutionBox(const Bnd_Box& theCurveBox, const double aZVals[2] = {aZmin, aZmax}; for (int ix = 0; ix < 2; ++ix) + { for (int iy = 0; iy < 2; ++iy) + { for (int iz = 0; iz < 2; ++iz) { addRevolutionCircle(theOrigin, @@ -135,6 +153,8 @@ static Bnd_Box buildRevolutionBox(const Bnd_Box& theCurveBox, theUMax, aBox); } + } + } aBox.Enlarge(theTol); return aBox; @@ -174,13 +194,21 @@ Bnd_Box GeomBndLib_SurfaceOfRevolution::Box(double theUMin, if (!aBasisCurve->IsPeriodic()) { if (aVMin < aVFirst) + { aVMin = aVFirst; + } else if (aVMin > aVLast) + { aVMin = aVLast; + } if (aVMax < aVFirst) + { aVMax = aVFirst; + } else if (aVMax > aVLast) + { aVMax = aVLast; + } if (aVMin > aVMax) { const double aTmp = aVMin; @@ -232,13 +260,21 @@ Bnd_Box GeomBndLib_SurfaceOfRevolution::BoxOptimal(double theUMin, if (!aBasisCurve->IsPeriodic()) { if (aVMin < aVFirst) + { aVMin = aVFirst; + } else if (aVMin > aVLast) + { aVMin = aVLast; + } if (aVMax < aVFirst) + { aVMax = aVFirst; + } else if (aVMax > aVLast) + { aVMax = aVLast; + } if (aVMin > aVMax) { const double aTmp = aVMin; diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert.cxx index 8c4c7c44d0..6a883c6368 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert.cxx @@ -93,11 +93,15 @@ occ::handle GeomConvert::SplitBSplineCurve( int TheFirst = C->FirstUKnotIndex(); int TheLast = C->LastUKnotIndex(); if (FromK1 == ToK2) + { throw Standard_DomainError(); + } int FirstK = std::min(FromK1, ToK2); int LastK = std::max(FromK1, ToK2); if (FirstK < TheFirst || LastK > TheLast) + { throw Standard_DomainError(); + } occ::handle C1 = occ::down_cast(C->Copy()); @@ -106,12 +110,16 @@ occ::handle GeomConvert::SplitBSplineCurve( if (C->IsPeriodic()) { if (!SameOrientation) + { C1->Reverse(); + } } else { if (FromK1 > ToK2) + { C1->Reverse(); + } } return C1; } @@ -135,12 +143,16 @@ occ::handle GeomConvert::SplitBSplineCurve( if (C->IsPeriodic()) { if (!SameOrientation) + { C1->Reverse(); + } } else { if (FromU1 > ToU2) + { C1->Reverse(); + } } return C1; @@ -167,9 +179,13 @@ occ::handle GeomConvert::CurveToBSplineCurve( if (!Curv->IsPeriodic()) { if (U1 < Curv->FirstParameter()) + { U1 = Curv->FirstParameter(); + } if (U2 > Curv->LastParameter()) + { U2 = Curv->LastParameter(); + } } if (Curv->IsKind(STANDARD_TYPE(Geom_Line))) @@ -314,7 +330,9 @@ occ::handle GeomConvert::CurveToBSplineCurve( ElCLib::AdjustPeriodic(Uf, Ul, Precision::Confusion(), U1, U2); if (std::abs(U1 - Uf) <= Precision::Confusion() && std::abs(U2 - Ul) <= Precision::Confusion()) + { TheCurve->SetNotPeriodic(); + } } /////////////////////////////////////////////// TheCurve->Segment(U1, U2); @@ -326,9 +344,13 @@ occ::handle GeomConvert::CurveToBSplineCurve( int MaxSegments = 16, MaxDegree = 14; GeomConvert_ApproxCurve ApprCOffs(C, Tol3d, Order, MaxSegments, MaxDegree); if (ApprCOffs.HasResult()) + { TheCurve = ApprCOffs.Curve(); + } else + { throw Standard_ConstructionError(); + } } else { @@ -418,9 +440,13 @@ occ::handle GeomConvert::CurveToBSplineCurve( int MaxSegments = 16, MaxDegree = 14; GeomConvert_ApproxCurve ApprCOffs(C, Tol3d, Order, MaxSegments, MaxDegree); if (ApprCOffs.HasResult()) + { TheCurve = ApprCOffs.Curve(); + } else + { throw Standard_ConstructionError(); + } } else { @@ -457,7 +483,9 @@ public: theResult = aPoint.Coord(2); } else + { theErrorCode = 1; + } } private: @@ -485,7 +513,9 @@ static occ::handle MultNumandDenom(const occ::handleNbKnots()); if ((end_value - start_value) / 5 < tolerance) + { tolerance = (end_value - start_value) / 5; + } NCollection_Array1 aKnots(a->Knots()); const NCollection_Array1& aPoles = a->Poles(); @@ -513,8 +543,12 @@ static occ::handle MultNumandDenom(const occ::handle resFlatKnots(1, resNbPoles + degree + 1); BSplCLib::KnotSequence(resKnots->Array1(), resMults->Array1(), resFlatKnots); for (ii = 1; ii <= BS->NbPoles(); ii++) + { for (jj = 1; jj <= 3; jj++) + { BSPoles(ii).SetCoord(jj, BSPoles(ii).Coord(jj) * BSWeights(ii)); + } + } // POP for WNT GeomConvert_law_evaluator ev(anAncore); @@ -536,8 +570,12 @@ static occ::handle MultNumandDenom(const occ::handleArray1(), resMults->Array1(), degree); return res; @@ -558,9 +596,13 @@ static void Pretreatment(NCollection_Array1>& tab a = tab(i)->Weight(1); if ((tab(i)->Weight(2) == a) && (tab(i)->Weight(tab(i)->NbPoles() - 1) == a) && (tab(i)->Weight(tab(i)->NbPoles()) == a)) + { for (j = 1; j <= tab(i)->NbPoles(); j++) + { tab(i)->SetWeight(j, tab(i)->Weight(j) / a); + } + } } } } @@ -584,7 +626,9 @@ static bool NeedToBeTreated(const occ::handle& BS) || (BS->Weight(BS->NbPoles()) > (1 + Precision::Confusion()))); } else + { return false; + } } //================================================================================================= @@ -615,11 +659,13 @@ static int Indexmin(const NCollection_Array1>& ta degree = tab(0)->Degree(); for (i = 0; i <= tab.Length() - 1; i++) + { if (tab(i)->Degree() <= degree) { degree = tab(i)->Degree(); index = i; } + } return index; } @@ -649,7 +695,9 @@ static void ReorderArrayOfG1Curves( tabbisG1(i) = tabG1(i); } else + { ArraybisOfCurves(i) = ArrayOfCurves(i); + } } for (i = 0; i <= (ArrayOfCurves.Length() - (StartIndex + 2)); i++) @@ -674,7 +722,9 @@ static void ReorderArrayOfG1Curves( tabG1(i) = tabbisG1(i - (ArrayOfCurves.Length() - (StartIndex + 1))); } else + { ArrayOfCurves(i) = ArraybisOfCurves(i - (ArrayOfCurves.Length() - (StartIndex + 1))); + } } } @@ -745,13 +795,19 @@ void GeomConvert::ConcatG1( Cont = GeomLProp::Continuity(ArrayOfCurves(i - 1), ArrayOfCurves(i), PreLast, First, true, true); if (Cont < GeomAbs_C0) + { throw Standard_ConstructionError("GeomConvert curves not C0"); + } else { if (Cont >= GeomAbs_G1) + { tabG1(i - 1) = true; // True=G1 continuity + } else + { tabG1(i - 1) = false; + } } } PreLast = ArrayOfCurves(i)->LastParameter(); @@ -761,10 +817,14 @@ void GeomConvert::ConcatG1( { // determination of the Wire features nb_vertexG1 = 0; while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } nb_group++; if (index == 0) + { nb_vertex_group0 = nb_vertexG1; + } index = index + 1 + nb_vertexG1; } @@ -790,14 +850,18 @@ void GeomConvert::ConcatG1( { Curve1 = ArrayOfCurves(nb_curve - 1); if (Curve1->Degree() > Geom2d_BSplineCurve::MaxDegree() / 2) + { ClosedG1Flag = false; + } } if ((nb_group == 1) && (ClosedG1Flag)) { // treatment of a particular case indexmin = Indexmin(ArrayOfCurves); if (indexmin != (ArrayOfCurves.Length() - 1)) + { ReorderArrayOfG1Curves(ArrayOfCurves, local_tolerance, tabG1, indexmin, ClosedTolerance); + } Curve2 = ArrayOfCurves(0); for (j = 1; j <= nb_curve - 1; j++) { // secondary loop inside each group @@ -831,7 +895,9 @@ void GeomConvert::ConcatG1( NCollection_Array1 Curve1Poles(Curve1->Poles()); for (ii = 1; ii <= Curve1->NbKnots(); ii++) + { KnotC1Mults(ii) = (Curve1->Degree() + KnotC1Mults(ii)); + } NCollection_Array1 FlatKnots(1, Curve1FlatKnots.Length() @@ -842,8 +908,12 @@ void GeomConvert::ConcatG1( int aStatus; const NCollection_Array1& Curve1Weights = Curve1->WeightsArray(); for (ii = 1; ii <= Curve1->NbPoles(); ii++) + { for (jj = 1; jj <= 3; jj++) + { Curve1Poles(ii).SetCoord(jj, Curve1Poles(ii).Coord(jj) * Curve1Weights(ii)); + } + } // POP for WNT GeomConvert_reparameterise_evaluator ev(aPolynomialCoefficient); // BSplCLib::FunctionReparameterise(reparameterise_evaluator, @@ -866,8 +936,12 @@ void GeomConvert::ConcatG1( NewWeights, aStatus); for (ii = 1; ii <= NewPoles.Length(); ii++) + { for (jj = 1; jj <= 3; jj++) + { NewPoles(ii).SetCoord(jj, NewPoles(ii).Coord(jj) / NewWeights(ii)); + } + } Curve1 = new Geom_BSplineCurve(NewPoles, NewWeights, KnotC1, KnotC1Mults, 2 * Curve1->Degree()); } @@ -875,7 +949,9 @@ void GeomConvert::ConcatG1( fusion = C.Add(Curve1, local_tolerance(j - 1)); // merge of two consecutive curves if (!fusion) + { throw Standard_ConstructionError("GeomConvert Concatenation Error"); + } Curve2 = C.BSplineCurve(); } Curve2->SetPeriodic(); @@ -886,33 +962,39 @@ void GeomConvert::ConcatG1( } else + { // clang-format off for (i=0;i<=nb_group-1;i++){ //principal loop on each G1 continuity // clang-format on nb_vertexG1 = 0; // group while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } for (j = index; j <= index + nb_vertexG1; j++) { // secondary loop inside each group Curve1 = ArrayOfCurves(j); - if (index == j) // initialisation at the beginning of the loop + if (index == j) + { // initialisation at the beginning of the loop ArrayOfConcatenated->SetValue(i, Curve1); + } else { GeomConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); - // clang-format off - fusion=C.Add(Curve1,ArrayOfToler(j-1)); //merge of two consecutive curves - // clang-format on + fusion = C.Add(Curve1, ArrayOfToler(j - 1)); // merge of two consecutive curves if (!fusion) + { throw Standard_ConstructionError("GeomConvert Concatenation Error"); + } ArrayOfConcatenated->SetValue(i, C.BSplineCurve()); } } index = index + 1 + nb_vertexG1; } + } } //================================================================================================= @@ -979,13 +1061,19 @@ void GeomConvert::ConcatC1( local_tolerance(i - 1), AngularTolerance); if (Cont < GeomAbs_C0) + { throw Standard_ConstructionError("GeomConvert curves not C0"); + } else { if (Cont >= GeomAbs_G1) + { tabG1(i - 1) = true; // True=G1 continuity + } else + { tabG1(i - 1) = false; + } } } PreLast = ArrayOfCurves(i)->LastParameter(); @@ -995,10 +1083,14 @@ void GeomConvert::ConcatC1( { // determination of the Wire features nb_vertexG1 = 0; while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } nb_group++; if (index == 0) + { nb_vertex_group0 = nb_vertexG1; + } index = index + 1 + nb_vertexG1; } @@ -1026,7 +1118,9 @@ void GeomConvert::ConcatC1( { Curve1 = ArrayOfCurves(nb_curve - 1); if (Curve1->Degree() > Geom2d_BSplineCurve::MaxDegree() / 2) + { ClosedG1Flag = false; + } } if ((nb_group == 1) && (ClosedG1Flag)) @@ -1035,16 +1129,24 @@ void GeomConvert::ConcatC1( ArrayOfIndices->SetValue(1, 0); indexmin = Indexmin(ArrayOfCurves); if (indexmin != (ArrayOfCurves.Length() - 1)) + { ReorderArrayOfG1Curves(ArrayOfCurves, local_tolerance, tabG1, indexmin, ClosedTolerance); + } for (j = 0; j <= nb_curve - 1; j++) { // secondary loop inside each group if (NeedToBeTreated(ArrayOfCurves(j))) + { Curve1 = MultNumandDenom(Hermit::Solution(ArrayOfCurves(j)), ArrayOfCurves(j)); + } else + { Curve1 = ArrayOfCurves(j); + } - if (j == 0) // initialisation at the beginning of the loop + if (j == 0) + { // initialisation at the beginning of the loop Curve2 = Curve1; + } else { if ((j == (nb_curve - 1)) && (NeedDoubleDegRepara)) @@ -1076,7 +1178,9 @@ void GeomConvert::ConcatC1( NCollection_Array1 Curve1Poles(Curve1->Poles()); for (ii = 1; ii <= Curve1->NbKnots(); ii++) + { KnotC1Mults(ii) = (Curve1->Degree() + KnotC1Mults(ii)); + } NCollection_Array1 FlatKnots(1, Curve1FlatKnots.Length() @@ -1087,8 +1191,12 @@ void GeomConvert::ConcatC1( int aStatus; const NCollection_Array1& Curve1Weights = Curve1->WeightsArray(); for (ii = 1; ii <= Curve1->NbPoles(); ii++) + { for (jj = 1; jj <= 3; jj++) + { Curve1Poles(ii).SetCoord(jj, Curve1Poles(ii).Coord(jj) * Curve1Weights(ii)); + } + } // POP for WNT GeomConvert_reparameterise_evaluator ev(aPolynomialCoefficient); @@ -1111,8 +1219,12 @@ void GeomConvert::ConcatC1( NewWeights, aStatus); for (ii = 1; ii <= NewPoles.Length(); ii++) + { for (jj = 1; jj <= 3; jj++) + { NewPoles(ii).SetCoord(jj, NewPoles(ii).Coord(jj) / NewWeights(ii)); + } + } Curve1 = new Geom_BSplineCurve(NewPoles, NewWeights, KnotC1, KnotC1Mults, 2 * Curve1->Degree()); } @@ -1120,7 +1232,9 @@ void GeomConvert::ConcatC1( fusion = C.Add(Curve1, local_tolerance(j - 1)); // merge of two consecutive curves if (!fusion) + { throw Standard_ConstructionError("GeomConvert Concatenation Error"); + } Curve2 = C.BSplineCurve(); } } @@ -1132,50 +1246,66 @@ void GeomConvert::ConcatC1( } else + { // clang-format off for (i=0;i<=nb_group-1;i++){ //principal loop on each G1 continuity // clang-format on nb_vertexG1 = 0; // group while (((index + nb_vertexG1) <= nb_curve - 2) && (tabG1(index + nb_vertexG1))) + { nb_vertexG1++; + } if ((!ClosedG1Flag) || (nb_group == 1)) { // filling of the array of index which are kept k++; ArrayOfIndices->SetValue(k - 1, index); if (k == nb_group) + { ArrayOfIndices->SetValue(k, 0); + } } else { k++; ArrayOfIndices->SetValue(k - 1, index + nb_vertex_group0 + 1); if (k == nb_group) + { ArrayOfIndices->SetValue(k, nb_vertex_group0 + 1); + } } for (j = index; j <= index + nb_vertexG1; j++) { // secondary loop inside each group if (NeedToBeTreated(ArrayOfCurves(j))) + { Curve1 = MultNumandDenom(Hermit::Solution(ArrayOfCurves(j)), ArrayOfCurves(j)); + } else + { Curve1 = ArrayOfCurves(j); + } - if (index == j) // initialisation at the beginning of the loop + if (index == j) + { // initialisation at the beginning of the loop ArrayOfConcatenated->SetValue(i, Curve1); + } else { // Merge of two consecutive curves. GeomConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); fusion = C.Add(Curve1, local_tolerance(j - 1), true); if (!fusion) + { throw Standard_ConstructionError("GeomConvert Concatenation Error"); + } ArrayOfConcatenated->SetValue(i, C.BSplineCurve()); } } index = index + 1 + nb_vertexG1; } + } } //================================================================================================= @@ -1199,7 +1329,9 @@ void GeomConvert::C0BSplineToC1BSplineCurve(occ::handle& BS, { fusion = C.Add(ArrayOfConcatenated->Value(i), tolerance); if (!fusion) + { throw Standard_ConstructionError("GeomConvert Concatenation Error"); + } } } BS = C.BSplineCurve(); @@ -1235,7 +1367,9 @@ void GeomConvert::C0BSplineToArrayOfC1BSplineCurve( for (i=BS->FirstUKnotIndex() ;i<=(BS->LastUKnotIndex()-1);i++){ //give the number of C1 curves // clang-format on if (BSMults(i) == BS->Degree()) + { nbcurveC1++; + } } if (nbcurveC1 > 1) @@ -1244,8 +1378,10 @@ void GeomConvert::C0BSplineToArrayOfC1BSplineCurve( NCollection_Array1 ArrayOfToler(0, nbcurveC1 - 2); for (i = 0; i <= nbcurveC1 - 2; i++) + { // filling of the array of tolerances ArrayOfToler(i) = tolerance; + } // with the variable tolerance U2 = BS->FirstParameter(); j = BS->FirstUKnotIndex() + 1; @@ -1255,7 +1391,9 @@ void GeomConvert::C0BSplineToArrayOfC1BSplineCurve( U1 = U2; // with the curves C1 segmented while (BSMults(j) < BS->Degree() && j < BS->LastUKnotIndex()) + { j++; + } U2 = BSKnots(j); j++; occ::handle BSbis = occ::down_cast(BS->Copy()); diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_1.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_1.cxx index ea9ca53f29..20f8d313f1 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_1.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_1.cxx @@ -87,7 +87,9 @@ occ::handle GeomConvert::SplitBSplineSurface( int LastU = S->LastUKnotIndex(); int LastV = S->LastVKnotIndex(); if (FromUK1 == ToUK2 || FromVK1 == ToVK2) + { throw Standard_DomainError(); + } int FirstUK = std::min(FromUK1, ToUK2); int LastUK = std::max(FromUK1, ToUK2); int FirstVK = std::min(FromVK1, ToVK2); @@ -104,22 +106,30 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsUPeriodic()) { if (!SameUOrientation) + { S1->UReverse(); + } } else { if (FromUK1 > ToUK2) + { S1->UReverse(); + } } if (S->IsVPeriodic()) { if (!SameVOrientation) + { S1->VReverse(); + } } else { if (FromVK1 > ToVK2) + { S1->VReverse(); + } } return S1; } @@ -134,7 +144,9 @@ occ::handle GeomConvert::SplitBSplineSurface( const bool SameOrientation) { if (FromK1 == ToK2) + { throw Standard_DomainError(); + } occ::handle S1 = occ::down_cast(S->Copy()); @@ -146,7 +158,9 @@ occ::handle GeomConvert::SplitBSplineSurface( int FirstUK = std::min(FromK1, ToK2); int LastUK = std::max(FromK1, ToK2); if (FirstUK < FirstU || LastUK > LastU) + { throw Standard_DomainError(); + } S1->Segment(S1->UKnot(FirstUK), S1->UKnot(LastUK), @@ -156,12 +170,16 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsUPeriodic()) { if (!SameOrientation) + { S1->UReverse(); + } } else { if (FromK1 > ToK2) + { S1->UReverse(); + } } } else @@ -172,7 +190,9 @@ occ::handle GeomConvert::SplitBSplineSurface( int FirstVK = std::min(FromK1, ToK2); int LastVK = std::max(FromK1, ToK2); if (FirstVK < FirstV || LastVK > LastV) + { throw Standard_DomainError(); + } S1->Segment(S1->UKnot(S1->FirstUKnotIndex()), S1->UKnot(S1->LastUKnotIndex()), @@ -182,12 +202,16 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsVPeriodic()) { if (!SameOrientation) + { S1->VReverse(); + } } else { if (FromK1 > ToK2) + { S1->VReverse(); + } } } return S1; @@ -218,22 +242,30 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsUPeriodic()) { if (!SameUOrientation) + { NewSurface->UReverse(); + } } else { if (FromU1 > ToU2) + { NewSurface->UReverse(); + } } if (S->IsVPeriodic()) { if (!SameVOrientation) + { NewSurface->VReverse(); + } } else { if (FromV1 > ToV2) + { NewSurface->VReverse(); + } } return NewSurface; } @@ -266,12 +298,16 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsUPeriodic()) { if (!SameOrientation) + { NewSurface->UReverse(); + } } else { if (FromParam1 > ToParam2) + { NewSurface->UReverse(); + } } } else @@ -286,12 +322,16 @@ occ::handle GeomConvert::SplitBSplineSurface( if (S->IsUPeriodic()) { if (!SameOrientation) + { NewSurface->UReverse(); + } } else { if (FromParam1 > ToParam2) + { NewSurface->UReverse(); + } } } return NewSurface; @@ -351,7 +391,9 @@ occ::handle GeomConvert::SurfaceToBSplineSurface( Surf = S; } else + { S = Surf; + } } if (Surf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) @@ -695,22 +737,34 @@ occ::handle GeomConvert::SurfaceToBSplineSurface( if (!BS->IsUPeriodic()) { if (U1 < umin) + { U1 = umin; + } if (U2 > umax) + { U2 = umax; + } } if (!BS->IsVPeriodic()) { if (V1 < vmin) + { V1 = vmin; + } if (V2 > vmax) + { V2 = vmax; + } } if (BS->IsUPeriodic() || BS->IsVPeriodic()) + { BS->CheckAndSegment(U1, U2, V1, V2); + } else + { BS->Segment(U1, U2, V1, V2); + } TheSurface = BS; } @@ -721,9 +775,13 @@ occ::handle GeomConvert::SurfaceToBSplineSurface( GeomAbs_Shape cont; GeomAdaptor_Surface AS(Sr); if (AS.NbUIntervals(GeomAbs_C2) > 1 || AS.NbVIntervals(GeomAbs_C2) > 1) + { cont = GeomAbs_C1; + } else + { cont = GeomAbs_C2; + } MaxSeg = 4 * (AS.NbUIntervals(GeomAbs_CN) + 1) * (AS.NbVIntervals(GeomAbs_CN) + 1); GeomConvert_ApproxSurface BSpS(Sr, Tol3d, cont, cont, MaxDegree, MaxDegree, MaxSeg, 1); TheSurface = BSpS.Surface(); diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxCurve.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxCurve.cxx index 7f421991d1..3625953978 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxCurve.cxx @@ -203,6 +203,6 @@ double GeomConvert_ApproxCurve::MaxError() const void GeomConvert_ApproxCurve::Dump(Standard_OStream& o) const { - o << "******* Dump of ApproxCurve *******" << std::endl; - o << "*******Error " << MaxError() << std::endl; + o << "******* Dump of ApproxCurve *******" << '\n'; + o << "*******Error " << MaxError() << '\n'; } diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxSurface.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxSurface.cxx index f1e1ed856c..521278ba82 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_ApproxSurface.cxx @@ -461,14 +461,14 @@ double GeomConvert_ApproxSurface::MaxError() const void GeomConvert_ApproxSurface::Dump(Standard_OStream& o) const { - o << std::endl; + o << '\n'; if (!myHasResult) { - o << "No result" << std::endl; + o << "No result" << '\n'; } else { - o << "Result max error :" << myMaxError << std::endl; + o << "Result max error :" << myMaxError << '\n'; } - o << std::endl; + o << '\n'; } diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveKnotSplitting.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveKnotSplitting.cxx index 12f91780b4..ca6606ddf6 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveKnotSplitting.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveKnotSplitting.cxx @@ -32,7 +32,9 @@ GeomConvert_BSplineCurveKnotSplitting::GeomConvert_BSplineCurveKnotSplitting( { if (ContinuityRange < 0) + { throw Standard_RangeError(); + } int FirstIndex = BasisCurve->FirstUKnotIndex(); int LastIndex = BasisCurve->LastUKnotIndex(); diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveToBezierCurve.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveToBezierCurve.cxx index 92c5c5aee2..4a81aba999 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveToBezierCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineCurveToBezierCurve.cxx @@ -45,7 +45,9 @@ GeomConvert_BSplineCurveToBezierCurve::GeomConvert_BSplineCurveToBezierCurve( const double ParametricTolerance) { if (U2 - U1 < ParametricTolerance) + { throw Standard_DomainError("GeomConvert_BSplineCurveToBezierSurface"); + } double Uf = U1, Ul = U2; double PTol = ParametricTolerance / 2; @@ -57,14 +59,18 @@ GeomConvert_BSplineCurveToBezierCurve::GeomConvert_BSplineCurveToBezierCurve( if (I1 == I2) { // We are on the knot if (myCurve->Knot(I1) > U1) + { Uf = myCurve->Knot(I1); + } } myCurve->LocateU(U2, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (myCurve->Knot(I1) < U2) + { Ul = myCurve->Knot(I1); + } } myCurve->Segment(Uf, Ul); @@ -125,7 +131,9 @@ void GeomConvert_BSplineCurveToBezierCurve::Knots(NCollection_Array1& TK { int ii, kk; for (ii = 1, kk = TKnots.Lower(); ii <= myCurve->NbKnots(); ii++, kk++) + { TKnots(kk) = myCurve->Knot(ii); + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineSurfaceToBezierSurface.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineSurfaceToBezierSurface.cxx index bf02d319e1..25ab1801ef 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineSurfaceToBezierSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_BSplineSurfaceToBezierSurface.cxx @@ -50,7 +50,9 @@ GeomConvert_BSplineSurfaceToBezierSurface::GeomConvert_BSplineSurfaceToBezierSur const double ParametricTolerance) { if ((U2 - U1 < ParametricTolerance) || (V2 - V1 < ParametricTolerance)) + { throw Standard_DomainError("GeomConvert_BSplineSurfaceToBezierSurface"); + } double Uf = U1, Ul = U2, Vf = V1, Vl = V2, PTol = ParametricTolerance / 2; int I1, I2; @@ -61,28 +63,36 @@ GeomConvert_BSplineSurfaceToBezierSurface::GeomConvert_BSplineSurfaceToBezierSur if (I1 == I2) { // We are on the knot if (mySurface->UKnot(I1) > U1) + { Uf = mySurface->UKnot(I1); + } } mySurface->LocateU(U2, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (mySurface->UKnot(I1) < U2) + { Ul = mySurface->UKnot(I1); + } } mySurface->LocateV(V1, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (mySurface->VKnot(I1) > V1) + { Vf = mySurface->VKnot(I1); + } } mySurface->LocateV(V2, PTol, I1, I2); if (I1 == I2) { // We are on the knot if (mySurface->VKnot(I1) < V2) + { Vl = mySurface->VKnot(I1); + } } mySurface->Segment(Uf, Ul, Vf, Vl); @@ -161,7 +171,9 @@ void GeomConvert_BSplineSurfaceToBezierSurface::UKnots(NCollection_Array1NbUKnots(); ii++, kk++) + { TKnots(kk) = mySurface->UKnot(ii); + } } //================================================================================================= @@ -170,7 +182,9 @@ void GeomConvert_BSplineSurfaceToBezierSurface::VKnots(NCollection_Array1NbVKnots(); ii++, kk++) + { TKnots(kk) = mySurface->VKnot(ii); + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompBezierSurfacesToBSplineSurface.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompBezierSurfacesToBSplineSurface.cxx index 1980f67dd0..401341320f 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompBezierSurfacesToBSplineSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompBezierSurfacesToBSplineSurface.cxx @@ -88,7 +88,9 @@ GeomConvert_CompBezierSurfacesToBSplineSurface::GeomConvert_CompBezierSurfacesTo V1 = vec.Magnitude(); // if the parameterization is too strange we keep the pseudo-length if ((V1 > 1000 * L1) || (V1 < L1 * 1.e-3)) + { V1 = L1; + } for (ii = 2; ii < myUKnots->Length(); ii++) { @@ -103,9 +105,13 @@ GeomConvert_CompBezierSurfacesToBSplineSurface::GeomConvert_CompBezierSurfacesTo // Compute the ratio, avoiding degenerate cases... if ((V2 > 1000 * L2) || (V2 < L2 * 1.e-3)) + { V2 = L2; + } if ((V3 > 1000 * L2) || (V3 < L2 * 1.e-3)) + { V3 = L2; + } Ratio = 1; if ((V1 > Precision::Confusion()) && (V2 > Precision::Confusion())) @@ -141,7 +147,9 @@ GeomConvert_CompBezierSurfacesToBSplineSurface::GeomConvert_CompBezierSurfacesTo V1 = vec.Magnitude(); // if the parameterization is too strange we keep the pseudo-length if ((V1 > 1000 * L1) || (V1 < L1 * 1.e-3)) + { V1 = L1; + } for (jj = 2; jj < myVKnots->Length(); jj++) { @@ -156,9 +164,13 @@ GeomConvert_CompBezierSurfacesToBSplineSurface::GeomConvert_CompBezierSurfacesTo // Compute the ratio, avoiding degenerate cases... if ((V2 > 1000 * L2) || (V2 < L2 * 1.e-3)) + { V2 = L2; + } if ((V3 > 1000 * L2) || (V3 < L2 * 1.e-3)) + { V3 = L2; + } Ratio = 1; if ((V1 > Precision::Confusion()) && (V2 > Precision::Confusion())) @@ -193,9 +205,13 @@ GeomConvert_CompBezierSurfacesToBSplineSurface::GeomConvert_CompBezierSurfacesTo myVDegree); if (RemoveKnots) + { minus = 0; + } else + { minus = 1; + } for (ii = myUKnots->Length() - 1; ii > 1; ii--) { diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompCurveToBSplineCurve.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompCurveToBSplineCurve.cxx index c42c4a25dd..de03ee4253 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompCurveToBSplineCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CompCurveToBSplineCurve.cxx @@ -97,9 +97,13 @@ bool GeomConvert_CompCurveToBSplineCurve::Add(const occ::handle& Fi { eps = Epsilon(std::abs(Noeuds(ii - 1))); if (eps < 5.e-10) + { eps = 5.e-10; + } if (Noeuds(ii) - Noeuds(ii - 1) <= eps) { Noeuds(ii) += eps; @@ -212,7 +218,9 @@ void GeomConvert_CompCurveToBSplineCurve::Add(occ::handle& Fi Noeuds(jj) = Ratio2 * SecondCurve->Knot(ii) - Delta2; eps = Epsilon(std::abs(Noeuds(jj - 1))); if (eps < 5.e-10) + { eps = 5.e-10; + } if (Noeuds(jj) - Noeuds(jj - 1) <= eps) { Noeuds(jj) += eps; diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CurveToAnaCurve.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CurveToAnaCurve.cxx index 92af567a61..866ec0d41d 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CurveToAnaCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_CurveToAnaCurve.cxx @@ -72,7 +72,9 @@ bool GeomConvert_CurveToAnaCurve::ConvertToAnalytical(const double t double& NewL) { if (myCurve.IsNull()) + { return false; + } occ::handle aCurve = myCurve; while (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) @@ -85,7 +87,9 @@ bool GeomConvert_CurveToAnaCurve::ConvertToAnalytical(const double t ComputeCurve(aCurve, tol, F, L, NewF, NewL, myGap, myConvType, myTarget); if (C.IsNull()) + { return false; + } theResultCurve = C; return true; } @@ -98,13 +102,16 @@ bool GeomConvert_CurveToAnaCurve::IsLinear(const NCollection_Array1& aPo { int nbPoles = aPoles.Length(); if (nbPoles < 2) + { return false; + } double dMax = 0; int iMax1 = 0, iMax2 = 0; int i; for (i = 1; i < nbPoles; i++) + { for (int j = i + 1; j <= nbPoles; j++) { double dist = aPoles(i).SquareDistance(aPoles(j)); @@ -115,9 +122,12 @@ bool GeomConvert_CurveToAnaCurve::IsLinear(const NCollection_Array1& aPo iMax2 = j; } } + } if (dMax < Precision::SquareConfusion()) + { return false; + } double tol2 = tolerance * tolerance; gp_Vec avec(aPoles(iMax1), aPoles(iMax2)); @@ -129,9 +139,13 @@ bool GeomConvert_CurveToAnaCurve::IsLinear(const NCollection_Array1& aPo { double dist = alin.SquareDistance(aPoles(i)); if (dist > tol2) + { return false; + } if (dist > aMax) + { aMax = dist; + } } Deviation = sqrt(aMax); @@ -166,7 +180,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeLine( { occ::handle line; if (curve.IsNull()) + { return line; + } line = occ::down_cast(curve); // who knows if (!line.IsNull()) { @@ -179,7 +195,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeLine( gp_Pnt P1 = curve->Value(c1); gp_Pnt P2 = curve->Value(c2); if (P1.SquareDistance(P2) < Precision::SquareConfusion()) + { return line; + } cf = c1; cl = c2; @@ -214,7 +232,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeLine( } } if (!IsLinear(Poles->Array1(), tolerance, Deviation)) + { return line; // non + } gp_Lin alin = GetLine(P1, P2, cf, cl); line = new Geom_Line(alin); return line; @@ -230,19 +250,29 @@ bool GeomConvert_CurveToAnaCurve::GetCircle(gp_Circ& crc, // Control if points are not aligned (should be done by MakeCirc double aMaxCoord = std::sqrt(Precision::Infinite()); if (std::abs(P0.X()) > aMaxCoord || std::abs(P0.Y()) > aMaxCoord || std::abs(P0.Z()) > aMaxCoord) + { return false; + } if (std::abs(P1.X()) > aMaxCoord || std::abs(P1.Y()) > aMaxCoord || std::abs(P1.Z()) > aMaxCoord) + { return false; + } if (std::abs(P2.X()) > aMaxCoord || std::abs(P2.Y()) > aMaxCoord || std::abs(P2.Z()) > aMaxCoord) + { return false; + } // Building the circle gce_MakeCirc mkc(P0, P1, P2); if (!mkc.IsDone()) + { return false; + } crc = mkc.Value(); if (crc.Radius() < gp::Resolution()) + { return false; + } // Align to P0 gp_Pnt PC = crc.Location(); gp_Ax2 axe = crc.Position(); @@ -282,7 +312,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeCircle( gp_Circ crc; if (!GetCircle(crc, P0, P1, P2)) + { return circ; + } // Reste a controler que c est bien un cercle : prendre 20 points double du = (c2 - c1) / 20; @@ -294,9 +326,13 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeCircle( gp_Pnt PP = c3d->Value(u); double dist = crc.Distance(PP); if (dist > tol) + { return circ; // not done + } if (dist > aMax) + { aMax = dist; + } } Deviation = aMax; @@ -309,7 +345,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeCircle( // first parameter should be closed to zero if (std::abs(cf) < Precision::PConfusion() || std::abs(PI2 - cf) < Precision::PConfusion()) + { cf = 0.; + } double cm = ElCLib::Parameter(crc, c3d->Value((c1 + c2) / 2.)); cm = ElCLib::InPeriod(cm, cf, cf + PI2); @@ -329,29 +367,39 @@ static bool IsArrayPntPlanar(const occ::handle>& HAP { int size = HAP->Length(); if (size < 3) + { return false; + } gp_Pnt P1 = HAP->Value(1); gp_Pnt P2 = HAP->Value(2); gp_Pnt P3 = HAP->Value(3); double dist1 = P1.Distance(P2); double dist2 = P1.Distance(P3); if (dist1 < prec || dist2 < prec) + { return false; + } gp_Vec V1(P1, P2); gp_Vec V2(P1, P3); if (V1.IsParallel(V2, prec)) + { return false; + } gp_Vec NV = V1.Crossed(V2); int i; for (i = 1; i <= 3; ++i) { if (Precision::IsInfinite(NV.Coord(i))) + { return false; + } } if (NV.Magnitude() < gp::Resolution()) + { return false; + } if (size > 3) { @@ -365,7 +413,9 @@ static bool IsArrayPntPlanar(const occ::handle>& HAP } gp_Vec VN(P1, PN); if (!NV.IsNormal(VN, prec)) + { return false; + } } } Norm = NV; @@ -442,7 +492,9 @@ static bool ConicDefinition(const double a, double cprim = (a + c - auxil) / 2.; if (std::abs(aprim) < gp::Resolution() || std::abs(cprim) < gp::Resolution()) + { return false; + } term1 = -gdet / (aprim * pdet); term2 = -gdet / (cprim * pdet); @@ -450,7 +502,9 @@ static bool ConicDefinition(const double a, if (IsEllip) { if (term1 <= eps || term2 <= eps) + { return false; + } Xax = cost; Yax = sint; Rmin = sqrt(term1); @@ -464,7 +518,9 @@ static bool ConicDefinition(const double a, else if (term1 <= eps) { if (-term1 <= eps || term2 <= eps) + { return false; + } Xax = -sint; Yax = cost; Rmin = sqrt(-term1); @@ -473,7 +529,9 @@ static bool ConicDefinition(const double a, else { if (term1 <= eps || -term2 <= eps) + { return false; + } Xax = cost; Yax = sint; Rmin = sqrt(-term2); @@ -520,7 +578,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeEllipse( c2n = c2 - (c2 - c1) / 5; } else + { c2n = c2; + } // gp_XYZ aBC; occ::handle> AP = new NCollection_HArray1(1, 5); @@ -542,11 +602,15 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeEllipse( } gp_Dir ndir; if (!IsArrayPntPlanar(AP, ndir, prec)) + { return res; + } if (std::abs(ndir.X()) < gp::Resolution() && std::abs(ndir.Y()) < gp::Resolution() && std::abs(ndir.Z()) < gp::Resolution()) + { return res; + } gp_Ax3 AX(gp_Pnt(0, 0, 0), ndir); gp_Trsf Tr; @@ -572,7 +636,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeEllipse( math_Gauss aSolver(Dt); if (!aSolver.IsDone()) + { return res; + } aSolver.Solve(F, Sl); @@ -627,9 +693,13 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeEllipse( double aPar = ElCLib::Parameter(anEllipse, PP); double dist = gell->Value(aPar).Distance(PP); if (dist > tol) + { return res; // not done + } if (dist > param2) + { param2 = dist; + } } Deviation = param2; @@ -641,7 +711,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeEllipse( // first parameter should be closed to zero if (std::abs(cf) < Precision::PConfusion() || std::abs(PI2 - cf) < Precision::PConfusion()) + { cf = 0.; + } double cm = ElCLib::Parameter(anEllipse, c3d->Value((c1 + c2) / 2.)); cm = ElCLib::InPeriod(cm, cf, cf + PI2); @@ -682,7 +754,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeCurve( std::array, 3> newc3d = {}; occ::handle c3d = theC3d; if (c3d.IsNull()) + { return c3d; + } gp_Pnt P1 = c3d->Value(c1); gp_Pnt P2 = c3d->Value(c2); gp_Pnt P3 = c3d->Value(c1 + (c2 - c1) / 2); @@ -782,7 +856,9 @@ occ::handle GeomConvert_CurveToAnaCurve::ComputeCurve( for (int i = 0; i < 3; ++i) { if (newc3d[i].IsNull()) + { continue; + } if (d[i] < dd) { dd = d[i]; diff --git a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_SurfToAnaSurf.cxx b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_SurfToAnaSurf.cxx index 172268992b..38fd59b011 100644 --- a/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_SurfToAnaSurf.cxx +++ b/src/ModelingData/TKGeomBase/GeomConvert/GeomConvert_SurfToAnaSurf.cxx @@ -62,16 +62,22 @@ void GeomConvert_SurfToAnaSurf::CheckVTrimForRevSurf( const occ::handle& aBC = aRevSurf->BasisCurve(); occ::handle aLine = occ::down_cast(aBC); if (aLine.IsNull()) + { return; + } const gp_Ax1& anAxis = aRevSurf->Axis(); gp_Lin anALin(anAxis); Extrema_ExtElC anExtLL(aLine->Lin(), anALin, Precision::Angular()); if (!anExtLL.IsDone() || anExtLL.IsParallel()) + { return; + } int aNbExt = anExtLL.NbExt(); if (aNbExt == 0) + { return; + } int i; int imin = 0; @@ -84,13 +90,17 @@ void GeomConvert_SurfToAnaSurf::CheckVTrimForRevSurf( } } if (imin == 0) + { return; + } Extrema_POnCurv aP1, aP2; anExtLL.Points(imin, aP1, aP2); double aVExt = aP1.Parameter(); if (aVExt <= V1 || aVExt >= V2) + { return; + } if (aVExt - V1 > V2 - aVExt) { @@ -198,7 +208,9 @@ occ::handle GeomConvert_SurfToAnaSurf::TryCylinerCone( gp_Ax3 Axes; double semiangle = gp_Vec(isoline).Angle(gp_Vec(P3, P1)); if (semiangle > M_PI / 2) + { semiangle = M_PI - semiangle; + } if (R1 > R3) { radius = R3; @@ -304,7 +316,9 @@ bool GeomConvert_SurfToAnaSurf::GetCylByLS( // math_Matrix aDirMatrix(1, aNbVar, 1, aNbVar, 0.0); for (i = 1; i <= aNbVar; i++) + { aDirMatrix(i, i) = 1.0; + } // Set search direction for location to be perpendicular to axis to avoid // searching along axis @@ -545,7 +559,9 @@ occ::handle GeomConvert_SurfToAnaSurf::TryTorusSphere( GeomAbs_Circle); if (Crv1.IsNull() || Crv2.IsNull() || !Crv1->IsKind(STANDARD_TYPE(Geom_Circle)) || !Crv2->IsKind(STANDARD_TYPE(Geom_Circle))) + { return newSurface; + } occ::handle aCircle1 = occ::down_cast(Crv1); occ::handle aCircle2 = occ::down_cast(Crv2); @@ -554,7 +570,9 @@ occ::handle GeomConvert_SurfToAnaSurf::TryTorusSphere( // check radiuses if ((std::abs(R - R1) > toler) || (std::abs(R - R2) > toler)) + { return newSurface; + } // get centers of the major radius gp_Pnt aPnt1, aPnt2, aPnt3; @@ -574,13 +592,17 @@ occ::handle GeomConvert_SurfToAnaSurf::TryTorusSphere( gp_Ax3 Axes(circle->Circ().Location(), MainDir); occ::handle anObject = new Geom_SphericalSurface(Axes, R); if (!anObject.IsNull()) + { newSurface = anObject; + } return newSurface; } if (!GeomConvert_CurveToAnaCurve::GetCircle(circ, aPnt1, aPnt2, aPnt3) /*, d0, d1, eps)*/) + { return newSurface; + } double aMajorR = circ.Radius(); gp_Pnt aCenter = circ.Location(); @@ -686,7 +708,9 @@ double GeomConvert_SurfToAnaSurf::ComputeGap(const occ::handle& th double dis = P3d.Distance(P3d2); if (dis > aGap) + { aGap = dis; + } if (aGap > theTol) { @@ -882,7 +906,9 @@ occ::handle GeomConvert_SurfToAnaSurf::ConvertToAnalytical(const d double diagonal = mySurf->Value(U1, V1).Distance(mySurf->Value((U1 + U2), (V1 + V2) / 2)); double twist = 1000; if (toler > diagonal / twist) + { toler = diagonal / twist; + } isurf = 1; // set cylinder bool aCylinderConus = false; @@ -979,8 +1005,10 @@ occ::handle GeomConvert_SurfToAnaSurf::ConvertToAnalytical(const d // try when V isolines is with same radius occ::handle anObject = TryTorusSphere(mySurf, Vcircle, Ucircle, V1, V2, U1, U2, toler, true); - if (anObject.IsNull()) // try when U isolines is with same radius + if (anObject.IsNull()) + { // try when U isolines is with same radius anObject = TryTorusSphere(mySurf, Ucircle, Vcircle, U1, U2, V1, V2, toler, false); + } if (!anObject.IsNull()) { @@ -1050,7 +1078,9 @@ occ::handle GeomConvert_SurfToAnaSurf::ConvertToAnalytical(const d for (isurf = 0; isurf < 5; ++isurf) { if (newSurf[isurf].IsNull()) + { continue; + } dd[isurf] = ComputeGap(aTempS, U1, U2, V1, V2, newSurf[isurf], toler); if (dd[isurf] <= toler) { @@ -1089,7 +1119,9 @@ bool GeomConvert_SurfToAnaSurf::IsSame(const occ::handle& S1, // only elementary surfaces are processed if (!S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) || !S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { return false; + } occ::handle anAdaptor1 = new GeomAdaptor_Surface(S1); occ::handle anAdaptor2 = new GeomAdaptor_Surface(S2); @@ -1125,7 +1157,9 @@ bool GeomConvert_SurfToAnaSurf::IsSame(const occ::handle& S1, } if (!interii.IsDone()) + { return false; + } IntAna_ResultType aTypeRes = interii.TypeInter(); @@ -1137,13 +1171,17 @@ bool GeomConvert_SurfToAnaSurf::IsSame(const occ::handle& S1, bool GeomConvert_SurfToAnaSurf::IsCanonical(const occ::handle& S) { if (S.IsNull()) + { return false; + } if (S->IsKind(STANDARD_TYPE(Geom_Plane)) || S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || S->IsKind(STANDARD_TYPE(Geom_ConicalSurface)) || S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) + { return true; + } return false; } diff --git a/src/ModelingData/TKGeomBase/GeomLProp/GeomLProp.cxx b/src/ModelingData/TKGeomBase/GeomLProp/GeomLProp.cxx index 5dbb576a97..3a2a2a6522 100644 --- a/src/ModelingData/TKGeomBase/GeomLProp/GeomLProp.cxx +++ b/src/ModelingData/TKGeomBase/GeomLProp/GeomLProp.cxx @@ -121,17 +121,29 @@ GeomAbs_Shape GeomLProp::Continuity(const occ::handle& C1, } int n1 = 0, n2 = 0; if (cont1 >= 5) + { n1 = 3; + } else if (cont1 == 4) + { n1 = 2; + } else if (cont1 == 2) + { n1 = 1; + } if (cont2 >= 5) + { n2 = 3; + } else if (cont2 == 4) + { n2 = 2; + } else if (cont2 == 2) + { n2 = 1; + } GeomLProp_CLProps clp1(C1, u1, n1, tl); GeomLProp_CLProps clp2(C2, u2, n2, tl); if (!(clp1.Value().IsEqual(clp2.Value(), tl))) @@ -144,9 +156,13 @@ GeomAbs_Shape GeomLProp::Continuity(const occ::handle& C1, d1 = clp1.D1(); d2 = clp2.D1(); if (r1) + { d1.Reverse(); + } if (r2) + { d2.Reverse(); + } if (d1.IsEqual(d2, tl, ta)) { cont = GeomAbs_C1; @@ -156,9 +172,13 @@ GeomAbs_Shape GeomLProp::Continuity(const occ::handle& C1, clp1.Tangent(dir1); clp2.Tangent(dir2); if (r1) + { dir1.Reverse(); + } if (r2) + { dir2.Reverse(); + } if (dir1.IsEqual(dir2, ta)) { cont = GeomAbs_G1; diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib.cxx index 58089905dd..656398ba2d 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib.cxx @@ -848,7 +848,9 @@ void GeomLib::SameRange(const double Tolerance, occ::handle& NewCurvePtr) { if (CurvePtr.IsNull()) + { throw Standard_Failure(); + } if (std::abs(LastOnCurve - RequestedLast) <= Tolerance && std::abs(FirstOnCurve - RequestedFirst) <= Tolerance) { @@ -1019,21 +1021,27 @@ void GeomLib_CurveOnSurfaceEvaluator::Evaluate(int*, /*Dimension*/ TrimCurve->D0((*Parameter), Point); for (int ii = 0; ii < 3; ii++) + { Result[ii] = Point.Coord(ii + 1); + } } if (*DerivativeRequest == 1) { gp_Vec Vector; TrimCurve->D1((*Parameter), Point, Vector); for (int ii = 0; ii < 3; ii++) + { Result[ii] = Vector.Coord(ii + 1); + } } if (*DerivativeRequest == 2) { gp_Vec Vector, VecBis; TrimCurve->D2((*Parameter), Point, VecBis, Vector); for (int ii = 0; ii < 3; ii++) + { Result[ii] = Vector.Coord(ii + 1); + } } ReturnCode[0] = 0; } @@ -1204,7 +1212,9 @@ void GeomLib::AdjustExtremity(occ::handle& Curve, // Interpolation of constraints math_Matrix Mat(1, 4, 1, 4); if (!PLib::HermiteCoefficients(0., 1., 1, 1, Mat)) + { throw Standard_ConstructionError(); + } for (jj = 1; jj <= 4; jj++) { @@ -1227,9 +1237,13 @@ void GeomLib::AdjustExtremity(occ::handle& Curve, aDef = new (Geom_BSplineCurve)(PolesDef, K, M, 3); if (aIn->Degree() < 3) + { aIn->IncreaseDegree(3); + } else + { aDef->IncreaseDegree(aIn->Degree()); + } for (ii = 2; ii < aIn->NbKnots(); ii++) { @@ -1237,7 +1251,9 @@ void GeomLib::AdjustExtremity(occ::handle& Curve, } if (aDef->NbPoles() != aIn->NbPoles()) + { throw Standard_ConstructionError("Inconsistent poles's number"); + } for (ii = 1; ii <= aDef->NbPoles(); ii++) { @@ -1256,7 +1272,9 @@ void GeomLib::ExtendCurveToPoint(occ::handle& Curve, const bool After) { if (Continuity < 1 || Continuity > 3) + { return; + } int size = Continuity + 2; double Ubord, Tol = 1.e-6; math_Matrix MatCoefs(1, size, 1, size); @@ -1353,9 +1371,13 @@ void GeomLib::ExtendCurveToPoint(occ::handle& Curve, Cont(1) = p0.XYZ(); Cont(2) = d1.XYZ() * Lambda; if (Continuity >= 2) + { Cont(3) = d2.XYZ() * std::pow(Lambda, 2); + } if (Continuity >= 3) + { Cont(4) = d3.XYZ() * std::pow(Lambda, 3); + } Cont(size) = Point.XYZ(); NCollection_Array1 ExtrapPoles(1, size); @@ -1383,7 +1405,9 @@ void GeomLib::ExtendCurveToPoint(occ::handle& Curve, // Concatenation Ok = Concat.Add(Bezier, Tol, After); if (!Ok) + { throw Standard_ConstructionError("ExtendCurveToPoint"); + } Curve = Concat.BSplineCurve(); } @@ -1396,7 +1420,9 @@ static bool ExtendKPart(occ::handle& Surface, { if (Surface.IsNull()) + { return false; + } bool Ok = true; double Uf, Ul, Vf, Vl; @@ -1413,9 +1439,13 @@ static bool ExtendKPart(occ::handle& Surface, { case GeomAbs_Plane: { if (After) + { Ul += Length; + } else + { Uf -= Length; + } Surface = new (Geom_RectangularTrimmedSurface)(Support, Uf, Ul, Vf, Vl); break; } @@ -1432,9 +1462,13 @@ static bool ExtendKPart(occ::handle& Surface, case GeomAbs_Cylinder: case GeomAbs_SurfaceOfExtrusion: { if (After) + { Vl += Length; + } else + { Vf -= Length; + } Surface = new (Geom_RectangularTrimmedSurface)(Support, Uf, Ul, Vf, Vl); break; } @@ -1455,7 +1489,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, const bool After) { if (Continuity < 0 || Continuity > 3) + { return; + } int Cont = Continuity; // Kpart ? @@ -1480,14 +1516,22 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, const occ::handle& aSurf = Surface; // to resolve ambiguity GeomConvert_ApproxSurface theApprox(aSurf, Tol, UCont, VCont, degU, degV, nmax, thePrec); if (theApprox.HasResult()) + { BS = theApprox.Surface(); + } else + { BS = GeomConvert::SurfaceToBSplineSurface(Surface); + } } if (InU && (BS->UDegree() < Continuity + 1)) + { BS->IncreaseDegree(Continuity + 1, BS->VDegree()); + } if (!InU && (BS->VDegree() < Continuity + 1)) + { BS->IncreaseDegree(BS->UDegree(), Continuity + 1); + } // if BS was periodic in the extension direction, it will no longer be if ((InU && (BS->IsUPeriodic())) || (!InU && (BS->IsVPeriodic()))) @@ -1504,7 +1548,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, constexpr double EpsW = 10 * Precision::PConfusion(); int gap = 3; if (rational) + { gap++; + } int Cdeg = 0, Cdim = 0, NbP = 0, Ksize = 0, Psize = 1; int ii, jj, ipole, Kount; @@ -1537,15 +1583,23 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, // the flat knots Ksize = NbP + Cdeg + 1; if (InU) + { FKnots = new NCollection_HArray1(BS->UKnotSequence()); + } else + { FKnots = new NCollection_HArray1(BS->VKnotSequence()); + } // the parameter of the connection knot if (After) + { Tbord = FKnots->Value(FKnots->Upper() - Cdeg); + } else + { Tbord = FKnots->Value(FKnots->Lower() + Cdeg); + } // the poles Psize = Cdim * NbP; @@ -1561,7 +1615,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, Poles->SetValue(ipole + 1, BS->Pole(ii, jj).Y()); Poles->SetValue(ipole + 2, BS->Pole(ii, jj).Z()); if (rational) + { Poles->SetValue(ipole + 3, BS->Weight(ii, jj)); + } ipole += gap; } } @@ -1576,7 +1632,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, Poles->SetValue(ipole + 1, BS->Pole(ii, jj).Y()); Poles->SetValue(ipole + 2, BS->Pole(ii, jj).Z()); if (rational) + { Poles->SetValue(ipole + 3, BS->Weight(ii, jj)); + } ipole += gap; } } @@ -1686,9 +1744,13 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, // We increase the degree of the border iso to bring the poles of the surface closer // And we retry if (InU) + { BS->IncreaseDegree(BS->UDegree(), BS->VDegree() + 2); + } else + { BS->IncreaseDegree(BS->UDegree() + 2, BS->VDegree()); + } } } @@ -1774,7 +1836,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, NCollection_Array2& NewW = NewWeights->ChangeArray2(); if (!rational) + { NewW.Init(1.); + } bool NullWeight = false; if (InU) @@ -1791,7 +1855,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, { ww = PRes(indice + 3); if (std::abs(ww - 1.0) < EpsW) + { ww = 1.0; + } if (ww < EpsW) { NullWeight = true; @@ -1819,7 +1885,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, { ww = PRes(indice + 3); if (std::abs(ww - 1.0) < EpsW) + { ww = 1.0; + } if (ww < EpsW) { NullWeight = true; @@ -1851,9 +1919,13 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, // Compute the degrees of the result. int Usize = BS->NbUKnots(), Vsize = BS->NbVKnots(), UDeg, VDeg; if (InU) + { Usize++; + } else + { Vsize++; + } NCollection_Array1 UKnots(1, Usize); NCollection_Array1 VKnots(1, Vsize); NCollection_Array1 UMults(1, Usize); @@ -1861,7 +1933,9 @@ void GeomLib::ExtendSurfByLength(occ::handle& Surface, NCollection_Array1 FKRes(1, NbKnots); for (ii = 1; ii <= NbKnots; ii++) + { FKRes(ii) = FK(ii); + } if (InU) { @@ -1913,7 +1987,9 @@ void GeomLib::Inertia(const NCollection_Array1& Points, int i, nb = Points.Length(); GB.SetCoord(0., 0., 0.); for (i = 1; i <= nb; i++) + { GB += Points(i).XYZ(); + } GB /= nb; @@ -2054,18 +2130,23 @@ static bool CanBeTreated(occ::handle& BSurf) bool AlreadyTreated = true; if (!BSurf->IsURational() || (BSurf->IsUPeriodic())) + { return false; + } else { lambda = (BSurf->Weight(1, 1) / BSurf->Weight(BSurf->NbUPoles(), 1)); // clang-format off - for (i=1;i<=BSurf->NbVPoles();i++) //test of the proportionnality of the denominator on the boundaries + for (i=1;i<=BSurf->NbVPoles();i++) { //test of the proportionnality of the denominator on the boundaries // clang-format on if ((BSurf->Weight(1, i) / (lambda * BSurf->Weight(BSurf->NbUPoles(), i)) < (1 - Precision::Confusion())) || (BSurf->Weight(1, i) / (lambda * BSurf->Weight(BSurf->NbUPoles(), i)) > (1 + Precision::Confusion()))) + { return false; + } + } i = 1; while ((AlreadyTreated) && (i <= BSurf->NbVPoles())) { // tests if the surface has already been treated @@ -2075,11 +2156,15 @@ static bool CanBeTreated(occ::handle& BSurf) < (1 - Precision::Confusion())) || ((BSurf->Weight(BSurf->NbUPoles() - 1, i) / (BSurf->Weight(BSurf->NbUPoles(), i))) > (1 + Precision::Confusion()))) + { AlreadyTreated = false; + } i++; } if (AlreadyTreated) + { return false; + } } return true; } @@ -2123,9 +2208,13 @@ static bool CheckIfKnotExists(const NCollection_Array1& surface_knots, c { int i; for (i = 1; i <= surface_knots.Length(); i++) + { if ((surface_knots(i) - Precision::Confusion() <= knot) && (surface_knots(i) + Precision::Confusion() >= knot)) + { return true; + } + } return false; } @@ -2189,6 +2278,7 @@ static void BuildFlatKnot(const NCollection_Array1& surface_knot else { if ((CheckIfKnotExists(surface_knots, knotmin)) && (!CheckIfKnotExists(surface_knots, knotmax))) + { AddAKnot(surface_knots, surface_mults, knotmax, @@ -2196,10 +2286,12 @@ static void BuildFlatKnot(const NCollection_Array1& surface_knot finalsurface_degree, ResultKnots, ResultMults); + } else { if ((!CheckIfKnotExists(surface_knots, knotmin)) && (CheckIfKnotExists(surface_knots, knotmax))) + { AddAKnot(surface_knots, surface_mults, knotmin, @@ -2207,6 +2299,7 @@ static void BuildFlatKnot(const NCollection_Array1& surface_knot finalsurface_degree, ResultKnots, ResultMults); + } else { if ((!CheckIfKnotExists(surface_knots, knotmin)) @@ -2273,7 +2366,9 @@ static void FunctionMultiply(occ::handle& BSurf, BuildFlatKnot(Knots, Mults, 0, 3, knotmin, knotmax, NewKnots, NewMults); for (i = 1; i <= NewMults->Length(); i++) + { length += NewMults->Value(i); + } NCollection_Array1 FlatKnots(1, length); BSplCLib::KnotSequence(NewKnots->ChangeArray1(), NewMults->ChangeArray1(), FlatKnots); @@ -2297,12 +2392,16 @@ static void FunctionMultiply(occ::handle& BSurf, newvmults); length = 0; for (i = 1; i <= newumults->Length(); i++) + { length += newumults->Value(i); + } new_num_u_poles = (length - BSurf->UDegree() - 3 - 1); NCollection_Array1 newuflatknots(1, length); length = 0; for (i = 1; i <= newvmults->Length(); i++) + { length += newvmults->Value(i); + } new_num_v_poles = (length - 2 * BSurf->VDegree() - 1); NCollection_Array1 newvflatknots(1, length); @@ -2331,7 +2430,9 @@ static void FunctionMultiply(occ::handle& BSurf, NewDenominator, status); if (status != 0) + { throw Standard_ConstructionError("GeomLib Multiplication Error"); + } for (i = 1; i <= new_num_u_poles; i++) { for (j = 1; j <= new_num_v_poles; j++) @@ -2389,13 +2490,21 @@ static void CancelDenominatorDerivative1D(occ::handle& BSur BSurf->UDegree()); Hermit::Solutionbis(BCurve, x, y, Precision::Confusion(), Precision::Confusion()); if (x < uknotmin) + { uknotmin = x; // uknotmin,uknotmax:extremal knots + } if ((x != 1.0) && (x > uknotmax)) + { uknotmax = x; + } if ((y != 0.0) && (y < uknotmin)) + { uknotmin = y; + } if (y > uknotmax) + { uknotmax = y; + } } FunctionMultiply(BSurf, uknotmin, uknotmax); // multiplication @@ -2414,7 +2523,9 @@ void GeomLib::CancelDenominatorDerivative(occ::handle& BSur { if (udirection && !vdirection) + { CancelDenominatorDerivative1D(BSurf); + } else { if (!udirection && vdirection) @@ -2612,7 +2723,9 @@ void GeomLib::IsClosed(const occ::handle& S, [[fallthrough]]; case GeomAbs_Cylinder: { if (Precision::IsInfinite(v1)) + { v1 = 0.; + } gp_Pnt p1 = aGAS.Value(u1, v1); gp_Pnt p2 = aGAS.Value(u2, v1); isUClosed = p1.SquareDistance(p2) <= Tol2; @@ -2764,7 +2877,9 @@ bool GeomLib::IsBSplUClosed(const occ::handle& S, occ::handle aCUF = S->UIso(U1); occ::handle aCUL = S->UIso(U2); if (aCUF.IsNull() || aCUL.IsNull()) + { return false; + } double Tol2 = 2. * Tol; occ::handle aBsF = occ::down_cast(aCUF); occ::handle aBsL = occ::down_cast(aCUL); @@ -2785,7 +2900,9 @@ bool GeomLib::IsBSplVClosed(const occ::handle& S, occ::handle aCVF = S->VIso(V1); occ::handle aCVL = S->VIso(V2); if (aCVF.IsNull() || aCVL.IsNull()) + { return false; + } double Tol2 = 2. * Tol; occ::handle aBsF = occ::down_cast(aCVF); occ::handle aBsL = occ::down_cast(aCVL); @@ -2806,7 +2923,9 @@ bool GeomLib::IsBzUClosed(const occ::handle& S, occ::handle aCUF = S->UIso(U1); occ::handle aCUL = S->UIso(U2); if (aCUF.IsNull() || aCUL.IsNull()) + { return false; + } double Tol2 = 2. * Tol; occ::handle aBzF = occ::down_cast(aCUF); occ::handle aBzL = occ::down_cast(aCUL); @@ -2826,7 +2945,9 @@ bool GeomLib::IsBzVClosed(const occ::handle& S, occ::handle aCVF = S->VIso(V1); occ::handle aCVL = S->VIso(V2); if (aCVF.IsNull() || aCVL.IsNull()) + { return false; + } double Tol2 = 2. * Tol; occ::handle aBzF = occ::down_cast(aCVF); occ::handle aBzL = occ::down_cast(aCVL); @@ -2857,7 +2978,9 @@ static bool CompareWeightPoles(const NCollection_Array1& thePoles1 gp_XYZ aPole1 = thePoles1.Value(i).XYZ() * aW1; gp_XYZ aPole2 = thePoles2.Value(i).XYZ() * aW2; if (!aPole1.IsEqual(aPole2, theTol)) + { return false; + } } // return true; @@ -2888,14 +3011,18 @@ bool GeomLib::isIsoLine(const occ::handle& theC2D, { occ::handle aBSpline2d = theC2D->BSpline(); if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2) + { return false; // Not a line or uneven parameterization. + } aLoc2d = aBSpline2d->Pole(1); // Vector should be non-degenerated. gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2)); if (aVec2d.SquareMagnitude() < Precision::Confusion()) + { return false; // Degenerated spline. + } aDir2d = aVec2d; isAppropriateType = true; @@ -2904,21 +3031,27 @@ bool GeomLib::isIsoLine(const occ::handle& theC2D, { occ::handle aBezier2d = theC2D->Bezier(); if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2) + { return false; // Not a line or uneven parameterization. + } aLoc2d = aBezier2d->Pole(1); // Vector should be non-degenerated. gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2)); if (aVec2d.SquareMagnitude() < Precision::Confusion()) + { return false; // Degenerated spline. + } aDir2d = aVec2d; isAppropriateType = true; } if (!isAppropriateType) + { return false; + } // Check line to be vertical or horizontal. if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular())) @@ -2955,10 +3088,14 @@ occ::handle GeomLib::buildC3dOnIsoLine(const occ::handle aGeomAdapter = occ::down_cast(theSurf); if (aGeomAdapter.IsNull()) + { return occ::handle(); + } if (theSurf->GetType() == GeomAbs_Sphere) + { return occ::handle(); + } // Extract isoline occ::handle aSurf = aGeomAdapter->Surface(); @@ -2999,7 +3136,9 @@ occ::handle GeomLib::buildC3dOnIsoLine(const occ::handleUIso(theParam); if (isToTrim) + { aC3d = new Geom_TrimmedCurve(aC3d, aV1Param, aV2Param); + } } else { @@ -3029,14 +3168,18 @@ occ::handle GeomLib::buildC3dOnIsoLine(const occ::handleVIso(theParam); if (isToTrim) + { aC3d = new Geom_TrimmedCurve(aC3d, aU1Param, aU2Param); + } } // Convert arbitrary curve type to the b-spline. occ::handle aCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular); if (!theIsForward) + { aCurve3d->Reverse(); + } // Rebuild parameterization for the 3d curve to have the same parameterization with // a two-dimensional curve. @@ -3070,7 +3213,9 @@ occ::handle GeomLib::buildC3dOnIsoLine(const occ::handle theTolerance) + { return occ::handle(); + } return aCurve3d; } diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Check2dBSplineCurve.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Check2dBSplineCurve.cxx index 93e0d711ef..ea6b0989c4 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Check2dBSplineCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Check2dBSplineCurve.cxx @@ -50,7 +50,9 @@ GeomLib_Check2dBSplineCurve::GeomLib_Check2dBSplineCurve( tangent = gp_Vec2d(myCurve->Pole(1), myCurve->Pole(2)); tangent_magnitude = tangent.Magnitude(); if (tangent_magnitude > myTolerance) + { tangent_normalized = tangent / tangent_magnitude; + } for (ii = 3; ii <= num_poles; ii++) { @@ -63,7 +65,9 @@ GeomLib_Check2dBSplineCurve::GeomLib_Check2dBSplineCurve( double CrossProd = tangent_normalized ^ avector_normalized; if (std::abs(CrossProd) > CrossProdTol) + { break; + } value = tangent.Dot(a_vector); if (value < 0.0e0) @@ -79,7 +83,9 @@ GeomLib_Check2dBSplineCurve::GeomLib_Check2dBSplineCurve( tangent = gp_Vec2d(myCurve->Pole(num_poles), myCurve->Pole(num_poles - 1)); tangent_magnitude = tangent.Magnitude(); if (tangent_magnitude > myTolerance) + { tangent_normalized = tangent / tangent_magnitude; + } for (ii = num_poles - 2; ii >= 1; ii--) { @@ -92,7 +98,9 @@ GeomLib_Check2dBSplineCurve::GeomLib_Check2dBSplineCurve( double CrossProd = tangent_normalized ^ avector_normalized; if (std::abs(CrossProd) > CrossProdTol) + { break; + } value = tangent.Dot(a_vector); if (value < 0.0e0) diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckBSplineCurve.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckBSplineCurve.cxx index 65f731e41f..bdedeb3954 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckBSplineCurve.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckBSplineCurve.cxx @@ -49,7 +49,9 @@ GeomLib_CheckBSplineCurve::GeomLib_CheckBSplineCurve(const occ::handlePole(1), myCurve->Pole(2)); tangent_magnitude = tangent.Magnitude(); if (tangent_magnitude > myTolerance) + { tangent_normalized = tangent / tangent_magnitude; + } for (ii = 3; ii <= num_poles; ii++) { @@ -63,7 +65,9 @@ GeomLib_CheckBSplineCurve::GeomLib_CheckBSplineCurve(const occ::handle CrossProdSqTol) + { break; + } value = tangent.Dot(a_vector); if (value < 0.0e0) @@ -79,7 +83,9 @@ GeomLib_CheckBSplineCurve::GeomLib_CheckBSplineCurve(const occ::handlePole(num_poles), myCurve->Pole(num_poles - 1)); tangent_magnitude = tangent.Magnitude(); if (tangent_magnitude > myTolerance) + { tangent_normalized = tangent / tangent_magnitude; + } for (ii = num_poles - 2; ii >= 1; ii--) { @@ -93,7 +99,9 @@ GeomLib_CheckBSplineCurve::GeomLib_CheckBSplineCurve(const occ::handle CrossProdSqTol) + { break; + } value = tangent.Dot(a_vector); if (value < 0.0e0) diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckCurveOnSurface.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckCurveOnSurface.cxx index 9d7c242910..695a0a409f 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckCurveOnSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_CheckCurveOnSurface.cxx @@ -78,7 +78,9 @@ public: { OCC_CATCH_SIGNALS if (!CheckParameter(theX)) + { return false; + } const gp_Pnt aP1(myCurve1.Value(theX)), aP2(myCurve2.Value(theX)); @@ -564,7 +566,9 @@ int FillSubIntervals(const occ::handle& theCurve3d, int anIndex3D = anArrKnots3D->Lower(), anIndex2D = anArrKnots2D->Lower(); if (theSubIntervals) + { theSubIntervals->ChangeValue(aNbSubIntervals) = theFirst; + } while ((anIndex3D <= anIndMax3D) && (anIndex2D <= anIndMax2D)) { @@ -578,7 +582,9 @@ int FillSubIntervals(const occ::handle& theCurve3d, aNbSubIntervals++; if (theSubIntervals) + { theSubIntervals->ChangeValue(aNbSubIntervals) = aVal3D; + } } anIndex3D++; @@ -595,7 +601,9 @@ int FillSubIntervals(const occ::handle& theCurve3d, aNbSubIntervals++; if (theSubIntervals) + { theSubIntervals->ChangeValue(aNbSubIntervals) = aVal2D; + } } anIndex2D++; @@ -603,7 +611,9 @@ int FillSubIntervals(const occ::handle& theCurve3d, } if (theSubIntervals) + { theSubIntervals->ChangeValue(aNbSubIntervals + 1) = theLast; + } if (!aBS3DCurv.IsNull()) { @@ -641,7 +651,9 @@ bool PSO_Perform(GeomLib_CheckCurveOnSurface_TargetFunc& theFunction, { const double aDeltaParam = theParSup(1) - theParInf(1); if (aDeltaParam < Precision::PConfusion()) + { return false; + } math_Vector aStepPar(1, 1); aStepPar(1) = theEpsilon * aDeltaParam; @@ -658,12 +670,16 @@ bool PSO_Perform(GeomLib_CheckCurveOnSurface_TargetFunc& theFunction, { double aVal = RealLast(); if (!theFunction.Value(aPrm, aVal)) + { continue; + } PSO_Particle* aParticle = aParticles.GetWorstParticle(); if (aVal > aParticle->BestDistance) + { continue; + } aParticle->Position[0] = aPrm; aParticle->BestPosition[0] = aPrm; diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_DenominatorMultiplier.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_DenominatorMultiplier.cxx index 15f821f73a..140e3c2a0c 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_DenominatorMultiplier.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_DenominatorMultiplier.cxx @@ -34,7 +34,9 @@ GeomLib_DenominatorMultiplier::GeomLib_DenominatorMultiplier( { int i; for (i = 1; i <= KnotVector.Length(); i++) + { myKnotFlatVector.SetValue(i, KnotVector(i)); + } } //================================================================================================= @@ -119,7 +121,9 @@ double GeomLib_DenominatorMultiplier::Value(const double UParameter, const doubl NCollection_Array1 Polesenv(0, 5); // poles of a(u,v) for (i = 0; i <= 5; i++) + { Polesenv(i) = 0.0; + } Polesenv(0) = Duminv; Polesenv(1) = Duminv - dDduuminv / B1prim0; Polesenv(4) = lambda * lambda * (Dumaxv - dDduumaxv / Bprelastprim1); @@ -189,6 +193,8 @@ double GeomLib_DenominatorMultiplier::Value(const double UParameter, const doubl Polesenv(3) = Polesenv(2); } for (i = 0; i <= 5; i++) + { Buv += Polesenv(i) * value(i); + } return Buv; } diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_IsPlanarSurface.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_IsPlanarSurface.cxx index 47c3be07cb..654fe852f3 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_IsPlanarSurface.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_IsPlanarSurface.cxx @@ -57,9 +57,13 @@ static bool Controle(const NCollection_Array1& Poles, double Angle1 = du.Angle(DX); double Angle2 = du.Angle(DY); if (Angle1 > M_PI / 2) + { Angle1 = M_PI - Angle1; + } if (Angle2 > M_PI / 2) + { Angle2 = M_PI - Angle2; + } if (Angle2 < Angle1) { du = DY; @@ -67,9 +71,13 @@ static bool Controle(const NCollection_Array1& Poles, DX = du; } if (DX.Angle(DU) > M_PI / 2) + { DX.Reverse(); + } if (DY.Angle(DV) > M_PI / 2) + { DY.Reverse(); + } gp_Ax3 axe(Bary, DX ^ DY, DX); Plan.SetPosition(axe); @@ -193,7 +201,9 @@ GeomLib_IsPlanarSurface::GeomLib_IsPlanarSurface(const occ::handle IsPlan = Controle(C, myPlan, Tol); } else + { IsPlan = false; + } break; } @@ -231,7 +241,9 @@ GeomLib_IsPlanarSurface::GeomLib_IsPlanarSurface(const occ::handle IsPlan = Controle(C, myPlan, Tol); } else + { IsPlan = false; + } break; } @@ -267,6 +279,8 @@ bool GeomLib_IsPlanarSurface::IsPlanar() const const gp_Pln& GeomLib_IsPlanarSurface::Plan() const { if (!IsPlan) + { throw StdFail_NotDone(" GeomLib_IsPlanarSurface"); + } return myPlan; } diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_LogSample.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_LogSample.cxx index 2e64f6d422..1456f8c0ab 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_LogSample.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_LogSample.cxx @@ -33,11 +33,17 @@ double GeomLib_LogSample::GetParameter(const int Index) const double aA, aB; Bounds(aA, aB); if (Index == 1) + { return aA; + } else if (Index == aN) + { return aB; + } else + { throw Standard_OutOfRange("GeomLib_LogSample::GetParameter"); + } } double v = myF + std::exp(myexp * Index); diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_PolyFunc.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_PolyFunc.cxx index 3aac73a157..d21b8d8278 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_PolyFunc.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_PolyFunc.cxx @@ -22,7 +22,9 @@ GeomLib_PolyFunc::GeomLib_PolyFunc(const math_Vector& Coeffs) : myCoeffs(1, Coeffs.Length() - 1) { // Construct the derivative polynomial for (int ii = 1; ii <= myCoeffs.Length(); ii++) + { myCoeffs(ii) = ii * Coeffs(ii + 1); + } } bool GeomLib_PolyFunc::Value(const double X, double& F) diff --git a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Tool.cxx b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Tool.cxx index 63ee6ac27b..e3f7c7a56e 100644 --- a/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Tool.cxx +++ b/src/ModelingData/TKGeomBase/GeomLib/GeomLib_Tool.cxx @@ -40,7 +40,9 @@ bool GeomLib_Tool::Parameter(const occ::handle& Curve, double& U) { if (Curve.IsNull()) + { return false; + } // U = 0.; double aTol = MaxDist * MaxDist; @@ -49,11 +51,15 @@ bool GeomLib_Tool::Parameter(const occ::handle& Curve, Extrema_ExtPC extrema(Point, aGAC); // if (!extrema.IsDone()) + { return false; + } // int n = extrema.NbExt(); if (n <= 0) + { return false; + } // int i = 0, iMin = 0; double Dist2Min = RealLast(); @@ -86,7 +92,9 @@ bool GeomLib_Tool::Parameters(const occ::handle& Surface, double& V) { if (Surface.IsNull()) + { return false; + } // U = 0.; V = 0.; @@ -98,11 +106,15 @@ bool GeomLib_Tool::Parameters(const occ::handle& Surface, Extrema_ExtPS extrema(Point, aGAS, aTolU, aTolV, Extrema_ExtFlag_MIN); // if (!extrema.IsDone()) + { return false; + } // int n = extrema.NbExt(); if (n <= 0) + { return false; + } // double Dist2Min = RealLast(); int i = 0, iMin = 0; @@ -134,7 +146,9 @@ bool GeomLib_Tool::Parameter(const occ::handle& Curve, double& U) { if (Curve.IsNull()) + { return false; + } // U = 0.; double aTol = MaxDist * MaxDist; @@ -142,10 +156,14 @@ bool GeomLib_Tool::Parameter(const occ::handle& Curve, Geom2dAdaptor_Curve aGAC(Curve); Extrema_ExtPC2d extrema(Point, aGAC); if (!extrema.IsDone()) + { return false; + } int n = extrema.NbExt(); if (n <= 0) + { return false; + } int i = 0, iMin = 0; double Dist2Min = RealLast(); for (i = 1; i <= n; i++) diff --git a/src/ModelingData/TKGeomBase/GeomProjLib/GeomProjLib.cxx b/src/ModelingData/TKGeomBase/GeomProjLib/GeomProjLib.cxx index dc5cef6ae0..16b131b3ff 100644 --- a/src/ModelingData/TKGeomBase/GeomProjLib/GeomProjLib.cxx +++ b/src/ModelingData/TKGeomBase/GeomProjLib/GeomProjLib.cxx @@ -280,7 +280,9 @@ occ::handle GeomProjLib::Project(const occ::handle& C, // ici, on a toujours un type BSpline. if (Approx.IsDone() && Approx.HasResult()) + { GC = Approx.Curve3d(); + } } return GC; diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools.cxx index d77b4435e1..a27050c0d4 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools.cxx @@ -76,7 +76,9 @@ void GeomTools::Read(occ::handle& C, Standard_IStream& IS) void GeomTools::SetUndefinedTypeHandler(const occ::handle& aHandler) { if (!aHandler.IsNull()) + { theActiveHandler = aHandler; + } } //================================================================================================= diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Curve2dSet.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Curve2dSet.cxx index bc7e209db9..5133b9d51b 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Curve2dSet.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Curve2dSet.cxx @@ -76,7 +76,9 @@ int GeomTools_Curve2dSet::Add(const occ::handle& S) occ::handle GeomTools_Curve2dSet::Curve2d(const int I) const { if (I <= 0 || I > myMap.Extent()) + { return occ::handle(); + } return occ::down_cast(myMap(I)); } @@ -94,7 +96,9 @@ static void Print(const gp_Pnt2d P, Standard_OStream& OS, const bool compact) { OS << P.X(); if (!compact) + { OS << ","; + } OS << " "; OS << P.Y(); OS << " "; @@ -106,7 +110,9 @@ static void Print(const gp_Dir2d D, Standard_OStream& OS, const bool compact) { OS << D.X(); if (!compact) + { OS << ","; + } OS << " "; OS << D.Y(); OS << " "; @@ -117,19 +123,29 @@ static void Print(const gp_Dir2d D, Standard_OStream& OS, const bool compact) static void Print(const occ::handle& L, Standard_OStream& OS, const bool compact) { if (compact) + { OS << LINE << " "; + } else + { OS << "Line"; + } gp_Lin2d C2d = L->Lin2d(); if (!compact) + { OS << "\n Origin :"; + } Print(C2d.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C2d.Direction(), OS, compact); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -138,25 +154,39 @@ static void Print(const occ::handle& L, Standard_OStream& OS, const static void Print(const occ::handle& C, Standard_OStream& OS, const bool compact) { if (compact) + { OS << CIRCLE << " "; + } else + { OS << "Circle"; + } gp_Circ2d C2d = C->Circ2d(); if (!compact) + { OS << "\n Center :"; + } Print(C2d.Location(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C2d.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C2d.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radius :"; + } OS << C2d.Radius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -165,29 +195,45 @@ static void Print(const occ::handle& C, Standard_OStream& OS, con static void Print(const occ::handle& E, Standard_OStream& OS, const bool compact) { if (compact) + { OS << ELLIPSE << " "; + } else + { OS << "Ellipse"; + } gp_Elips2d C2d = E->Elips2d(); if (!compact) + { OS << "\n Center :"; + } Print(C2d.Location(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C2d.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C2d.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radii :"; + } OS << C2d.MajorRadius(); if (!compact) + { OS << ","; + } OS << " "; OS << C2d.MinorRadius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -196,25 +242,39 @@ static void Print(const occ::handle& E, Standard_OStream& OS, co static void Print(const occ::handle& P, Standard_OStream& OS, const bool compact) { if (compact) + { OS << PARABOLA << " "; + } else + { OS << "Parabola"; + } gp_Parab2d C2d = P->Parab2d(); if (!compact) + { OS << "\n Center :"; + } Print(C2d.Location(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C2d.Axis().XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C2d.Axis().YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Focal :"; + } OS << C2d.Focal(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -223,29 +283,45 @@ static void Print(const occ::handle& P, Standard_OStream& OS, c static void Print(const occ::handle& H, Standard_OStream& OS, const bool compact) { if (compact) + { OS << HYPERBOLA << " "; + } else + { OS << "Hyperbola"; + } gp_Hypr2d C2d = H->Hypr2d(); if (!compact) + { OS << "\n Center :"; + } Print(C2d.Location(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C2d.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C2d.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radii :"; + } OS << C2d.MajorRadius(); if (!compact) + { OS << ","; + } OS << " "; OS << C2d.MinorRadius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -256,37 +332,55 @@ static void Print(const occ::handle& B, const bool compact) { if (compact) + { OS << BEZIER << " "; + } else + { OS << "BezierCurve"; + } bool rational = B->IsRational(); if (compact) + { OS << (rational ? 1 : 0) << " "; + } else { if (rational) + { OS << " rational"; + } } // poles and weights int i, degree = B->Degree(); if (!compact) + { OS << "\n Degree :"; + } OS << degree << " "; for (i = 1; i <= degree + 1; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } Print(B->Pole(i), OS, compact); if (rational) + { OS << " " << B->Weight(i); + } if (compact) + { OS << " "; + } } if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -297,26 +391,38 @@ static void Print(const occ::handle& B, const bool compact) { if (compact) + { OS << BSPLINE << " "; + } else + { OS << "BSplineCurve"; + } bool rational = B->IsRational(); if (compact) + { OS << (rational ? 1 : 0) << " "; + } else { if (rational) + { OS << " rational"; + } } bool periodic = B->IsPeriodic(); if (compact) + { OS << (periodic ? 1 : 0) << " "; + } else { if (periodic) + { OS << " periodic"; + } } // poles and weights @@ -325,47 +431,73 @@ static void Print(const occ::handle& B, nbpoles = B->NbPoles(); nbknots = B->NbKnots(); if (!compact) + { OS << "\n Degree "; + } else + { OS << " "; + } OS << degree; if (!compact) + { OS << ","; + } OS << " "; OS << nbpoles; if (!compact) + { OS << " Poles,"; + } OS << " "; OS << nbknots << " "; if (!compact) + { OS << " Knots"; + } if (!compact) + { OS << "Poles :\n"; + } for (i = 1; i <= nbpoles; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } else + { OS << " "; + } Print(B->Pole(i), OS, compact); if (rational) + { OS << " " << B->Weight(i); + } } OS << "\n"; if (!compact) + { OS << "Knots :\n"; + } for (i = 1; i <= nbknots; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } else + { OS << " "; + } OS << B->Knot(i) << " " << B->Multiplicity(i); } if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -376,14 +508,22 @@ static void Print(const occ::handle& C, const bool compact) { if (compact) + { OS << TRIMMED << " "; + } else + { OS << "Trimmed curve\n"; + } if (!compact) + { OS << "Parameters : "; + } OS << C->FirstParameter() << " " << C->LastParameter() << "\n"; if (!compact) + { OS << "Basis curve :\n"; + } GeomTools_Curve2dSet::PrintCurve2d(C->BasisCurve(), OS, compact); } @@ -394,14 +534,22 @@ static void Print(const occ::handle& C, const bool compact) { if (compact) + { OS << OFFSET << " "; + } else + { OS << "OffsetCurve"; + } if (!compact) + { OS << "Offset : "; + } OS << C->Offset() << "\n"; if (!compact) + { OS << "Basis curve :\n"; + } GeomTools_Curve2dSet::PrintCurve2d(C->BasisCurve(), OS, compact); } @@ -597,13 +745,19 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); if (rational) + { GeomTools::GetReal(IS, weights(i)); + } } if (rational) + { B = new Geom2d_BezierCurve(poles, weights); + } else + { B = new Geom2d_BezierCurve(poles); + } return IS; } @@ -626,7 +780,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); if (rational) + { GeomTools::GetReal(IS, weights(i)); + } } NCollection_Array1 knots(1, nbknots); @@ -639,9 +795,13 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> buffer; if (strcmp(buffer, "Curve2ds")) { - std::cout << "Not a Curve2d table" << std::endl; + std::cout << "Not a Curve2d table" << '\n'; return; } diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_CurveSet.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_CurveSet.cxx index 1ebba67f64..3bff6b90ab 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_CurveSet.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_CurveSet.cxx @@ -76,7 +76,9 @@ int GeomTools_CurveSet::Add(const occ::handle& C) occ::handle GeomTools_CurveSet::Curve(const int I) const { if (I <= 0 || I > myMap.Extent()) + { return occ::handle(); + } return occ::down_cast(myMap(I)); } @@ -93,11 +95,15 @@ static void Print(const gp_Pnt& P, Standard_OStream& OS, const bool compact) { OS << P.X(); if (!compact) + { OS << ","; + } OS << " "; OS << P.Y(); if (!compact) + { OS << ","; + } OS << " "; OS << P.Z(); OS << " "; @@ -109,11 +115,15 @@ static void Print(const gp_Dir& D, Standard_OStream& OS, const bool compact) { OS << D.X(); if (!compact) + { OS << ","; + } OS << " "; OS << D.Y(); if (!compact) + { OS << ","; + } OS << " "; OS << D.Z(); OS << " "; @@ -124,19 +134,29 @@ static void Print(const gp_Dir& D, Standard_OStream& OS, const bool compact) static void Print(const occ::handle& L, Standard_OStream& OS, const bool compact) { if (compact) + { OS << LINE << " "; + } else + { OS << "Line"; + } gp_Lin C = L->Lin(); if (!compact) + { OS << "\n Origin :"; + } Print(C.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C.Direction(), OS, compact); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -145,28 +165,44 @@ static void Print(const occ::handle& L, Standard_OStream& OS, const b static void Print(const occ::handle& CC, Standard_OStream& OS, const bool compact) { if (compact) + { OS << CIRCLE << " "; + } else + { OS << "Circle"; + } gp_Circ C = CC->Circ(); if (!compact) + { OS << "\n Center :"; + } Print(C.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radius :"; + } OS << C.Radius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -175,32 +211,50 @@ static void Print(const occ::handle& CC, Standard_OStream& OS, cons static void Print(const occ::handle& E, Standard_OStream& OS, const bool compact) { if (compact) + { OS << ELLIPSE << " "; + } else + { OS << "Ellipse"; + } gp_Elips C = E->Elips(); if (!compact) + { OS << "\n Center :"; + } Print(C.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radii :"; + } OS << C.MajorRadius(); if (!compact) + { OS << ","; + } OS << " "; OS << C.MinorRadius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -209,28 +263,44 @@ static void Print(const occ::handle& E, Standard_OStream& OS, cons static void Print(const occ::handle& P, Standard_OStream& OS, const bool compact) { if (compact) + { OS << PARABOLA << " "; + } else + { OS << "Parabola"; + } gp_Parab C = P->Parab(); if (!compact) + { OS << "\n Center :"; + } Print(C.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Focal :"; + } OS << C.Focal(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -239,32 +309,50 @@ static void Print(const occ::handle& P, Standard_OStream& OS, con static void Print(const occ::handle& H, Standard_OStream& OS, const bool compact) { if (compact) + { OS << HYPERBOLA << " "; + } else + { OS << "Hyperbola"; + } gp_Hypr C = H->Hypr(); if (!compact) + { OS << "\n Center :"; + } Print(C.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(C.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(C.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(C.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radii :"; + } OS << C.MajorRadius(); if (!compact) + { OS << ","; + } OS << " "; OS << C.MinorRadius(); if (!compact) + { OS << "\n"; + } OS << "\n"; } @@ -273,38 +361,56 @@ static void Print(const occ::handle& H, Standard_OStream& OS, co static void Print(const occ::handle& B, Standard_OStream& OS, const bool compact) { if (compact) + { OS << BEZIER << " "; + } else + { OS << "BezierCurve"; + } bool rational = B->IsRational(); if (compact) + { OS << (rational ? 1 : 0) << " "; + } else { if (rational) + { OS << " rational"; + } } // poles and weights int i, degree = B->Degree(); if (!compact) + { OS << "\n Degree :"; + } OS << degree << " "; for (i = 1; i <= degree + 1; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } Print(B->Pole(i), OS, compact); if (rational) + { OS << " " << B->Weight(i); + } if (compact) + { OS << " "; + } } OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -312,26 +418,38 @@ static void Print(const occ::handle& B, Standard_OStream& OS, static void Print(const occ::handle& B, Standard_OStream& OS, const bool compact) { if (compact) + { OS << BSPLINE << " "; + } else + { OS << "BSplineCurve"; + } bool rational = B->IsRational(); if (compact) + { OS << (rational ? 1 : 0) << " "; + } else { if (rational) + { OS << " rational"; + } } bool periodic = B->IsPeriodic(); if (compact) + { OS << (periodic ? 1 : 0) << " "; + } else { if (periodic) + { OS << " periodic"; + } } // poles and weights @@ -340,47 +458,71 @@ static void Print(const occ::handle& B, Standard_OStream& OS, nbpoles = B->NbPoles(); nbknots = B->NbKnots(); if (!compact) + { OS << "\n Degree "; + } else + { OS << " "; + } OS << degree; if (!compact) + { OS << ","; + } OS << " "; OS << nbpoles; if (!compact) + { OS << " Poles,"; + } OS << " "; OS << nbknots << " "; if (!compact) + { OS << " Knots\n"; + } if (!compact) + { OS << "Poles :\n"; + } for (i = 1; i <= nbpoles; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } else + { OS << " "; + } Print(B->Pole(i), OS, compact); if (rational) + { OS << " " << B->Weight(i); + } } OS << "\n"; if (!compact) + { OS << "Knots :\n"; + } for (i = 1; i <= nbknots; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } OS << " " << B->Knot(i) << " " << B->Multiplicity(i); } OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -388,14 +530,22 @@ static void Print(const occ::handle& B, Standard_OStream& OS, static void Print(const occ::handle& C, Standard_OStream& OS, const bool compact) { if (compact) + { OS << TRIMMED << " "; + } else + { OS << "Trimmed curve\n"; + } if (!compact) + { OS << "Parameters : "; + } OS << C->FirstParameter() << " " << C->LastParameter() << "\n"; if (!compact) + { OS << "Basis curve :\n"; + } GeomTools_CurveSet::PrintCurve(C->BasisCurve(), OS, compact); } @@ -404,18 +554,28 @@ static void Print(const occ::handle& C, Standard_OStream& OS, static void Print(const occ::handle& C, Standard_OStream& OS, const bool compact) { if (compact) + { OS << OFFSET << " "; + } else + { OS << "OffsetCurve"; + } if (!compact) + { OS << "Offset : "; + } OS << C->Offset() << "\n"; if (!compact) + { OS << "Direction : "; + } Print(C->Direction(), OS, compact); OS << "\n"; if (!compact) + { OS << "Basis curve :\n"; + } GeomTools_CurveSet::PrintCurve(C->BasisCurve(), OS, compact); } @@ -612,13 +772,19 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); if (rational) + { GeomTools::GetReal(IS, weights(i)); + } } if (rational) + { B = new Geom_BezierCurve(poles, weights); + } else + { B = new Geom_BezierCurve(poles); + } return IS; } @@ -642,7 +808,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i); if (rational) + { GeomTools::GetReal(IS, weights(i)); + } } NCollection_Array1 knots(1, nbknots); @@ -655,9 +823,13 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> buffer; if (strcmp(buffer, "Curves")) { - std::cout << "Not a Curve table" << std::endl; + std::cout << "Not a Curve table" << '\n'; return; } diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Debug.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Debug.cxx index aadbf18069..71ece4b6a3 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Debug.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_Debug.cxx @@ -45,7 +45,7 @@ const char* GeomTools_Dump(void* theHandlePtr) { std::cout << "\n\n"; GeomTools_SurfaceSet::PrintSurface(GS, std::cout); - std::cout << std::endl; + std::cout << '\n'; return "Found Geom_Surface, see dump in std::cout"; } @@ -54,7 +54,7 @@ const char* GeomTools_Dump(void* theHandlePtr) { std::cout << "\n\n"; GeomTools_CurveSet::PrintCurve(GC, std::cout); - std::cout << std::endl; + std::cout << '\n'; return "Found Geom_Curve, see dump in std::cout"; } @@ -63,7 +63,7 @@ const char* GeomTools_Dump(void* theHandlePtr) { std::cout << "\n\n"; GeomTools_Curve2dSet::PrintCurve2d(GC2d, std::cout); - std::cout << std::endl; + std::cout << '\n'; return "Found Geom2d_Curve, see dump in std::cout"; } diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_SurfaceSet.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_SurfaceSet.cxx index 92a83172d8..32364cd1d3 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_SurfaceSet.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_SurfaceSet.cxx @@ -81,7 +81,9 @@ int GeomTools_SurfaceSet::Add(const occ::handle& S) occ::handle GeomTools_SurfaceSet::Surface(const int I) const { if (I <= 0 || I > myMap.Extent()) + { return occ::handle(); + } return occ::down_cast(myMap(I)); } @@ -98,11 +100,15 @@ static void Print(const gp_Pnt& P, Standard_OStream& OS, const bool compact) { OS << P.X(); if (!compact) + { OS << ","; + } OS << " "; OS << P.Y(); if (!compact) + { OS << ","; + } OS << " "; OS << P.Z(); OS << " "; @@ -114,11 +120,15 @@ static void Print(const gp_Dir& D, Standard_OStream& OS, const bool compact) { OS << D.X(); if (!compact) + { OS << ","; + } OS << " "; OS << D.Y(); if (!compact) + { OS << ","; + } OS << " "; OS << D.Z(); OS << " "; @@ -129,26 +139,40 @@ static void Print(const gp_Dir& D, Standard_OStream& OS, const bool compact) static void Print(const occ::handle& S, Standard_OStream& OS, const bool compact) { if (compact) + { OS << PLANE << " "; + } else + { OS << "Plane"; + } gp_Pln P = S->Pln(); if (!compact) + { OS << "\n Origin :"; + } Print(P.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(P.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(P.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(P.YAxis().Direction(), OS, compact); OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -158,29 +182,45 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << CYLINDER << " "; + } else + { OS << "CylindricalSurface"; + } gp_Cylinder P = S->Cylinder(); if (!compact) + { OS << "\n Origin :"; + } Print(P.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(P.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(P.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(P.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radius :"; + } OS << P.Radius(); OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -190,33 +230,51 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << CONE << " "; + } else + { OS << "ConicalSurface"; + } gp_Cone P = S->Cone(); if (!compact) + { OS << "\n Origin :"; + } Print(P.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(P.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(P.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(P.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radius :"; + } OS << P.RefRadius(); OS << "\n"; if (!compact) + { OS << "\n Angle :"; + } OS << P.SemiAngle(); OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -226,29 +284,45 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << SPHERE << " "; + } else + { OS << "SphericalSurface"; + } gp_Sphere P = S->Sphere(); if (!compact) + { OS << "\n Center :"; + } Print(P.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(P.Position().Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(P.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(P.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radius :"; + } OS << P.Radius(); OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -258,29 +332,45 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << TORUS << " "; + } else + { OS << "ToroidalSurface"; + } gp_Torus P = S->Torus(); if (!compact) + { OS << "\n Origin :"; + } Print(P.Location(), OS, compact); if (!compact) + { OS << "\n Axis :"; + } Print(P.Axis().Direction(), OS, compact); if (!compact) + { OS << "\n XAxis :"; + } Print(P.XAxis().Direction(), OS, compact); if (!compact) + { OS << "\n YAxis :"; + } Print(P.YAxis().Direction(), OS, compact); if (!compact) + { OS << "\n Radii :"; + } OS << P.MajorRadius() << " " << P.MinorRadius(); OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -290,15 +380,23 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << LINEAREXTRUSION << " "; + } else + { OS << "SurfaceOfLinearExtrusion"; + } if (!compact) + { OS << "\n Direction :"; + } Print(S->Direction(), OS, compact); if (!compact) + { OS << "\n Basis curve : "; + } OS << "\n"; GeomTools_CurveSet::PrintCurve(S->BasisCurve(), OS, compact); } @@ -310,18 +408,28 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << REVOLUTION << " "; + } else + { OS << "SurfaceOfRevolution"; + } if (!compact) + { OS << "\n Origin :"; + } Print(S->Location(), OS, compact); if (!compact) + { OS << "\n Direction :"; + } Print(S->Direction(), OS, compact); if (!compact) + { OS << "\n Basis curve : "; + } OS << "\n"; GeomTools_CurveSet::PrintCurve(S->BasisCurve(), OS, compact); } @@ -333,25 +441,37 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << BEZIER << " "; + } else + { OS << "BezierSurface"; + } bool urational = S->IsURational(); bool vrational = S->IsVRational(); if (compact) + { OS << (urational ? 1 : 0) << " "; + } else { if (urational) + { OS << " urational"; + } } if (compact) + { OS << (vrational ? 1 : 0) << " "; + } else { if (vrational) + { OS << " vrational"; + } } if (!compact) @@ -359,9 +479,13 @@ static void Print(const occ::handle& S, bool uclosed = S->IsUClosed(); bool vclosed = S->IsVClosed(); if (uclosed) + { OS << " uclosed"; + } if (vclosed) + { OS << " vclosed"; + } } // poles and weights @@ -369,7 +493,9 @@ static void Print(const occ::handle& S, udegree = S->UDegree(); vdegree = S->VDegree(); if (!compact) + { OS << "\n Degrees :"; + } OS << udegree << " " << vdegree << " "; for (i = 1; i <= udegree + 1; i++) @@ -377,18 +503,26 @@ static void Print(const occ::handle& S, for (j = 1; j <= vdegree + 1; j++) { if (!compact) + { OS << "\n " << std::setw(2) << i << ", " << std::setw(2) << j << " : "; + } Print(S->Pole(i, j), OS, compact); if (urational || vrational) + { OS << " " << S->Weight(i, j); + } if (compact) + { OS << " "; + } } OS << "\n"; } OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -398,42 +532,62 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << BSPLINE << " "; + } else + { OS << "BSplineSurface"; + } bool urational = S->IsURational(); bool vrational = S->IsVRational(); if (compact) + { OS << (urational ? 1 : 0) << " "; + } else { if (urational) + { OS << " urational"; + } } if (compact) + { OS << (vrational ? 1 : 0) << " "; + } else { if (vrational) + { OS << " vrational"; + } } bool uperiodic = S->IsUPeriodic(); bool vperiodic = S->IsVPeriodic(); if (compact) + { OS << (uperiodic ? 1 : 0) << " "; + } else { if (uperiodic) + { OS << " uperiodic"; + } } if (compact) + { OS << (vperiodic ? 1 : 0) << " "; + } else { if (vperiodic) + { OS << " vperiodic"; + } } if (!compact) @@ -441,9 +595,13 @@ static void Print(const occ::handle& S, bool uclosed = S->IsUClosed(); bool vclosed = S->IsVClosed(); if (uclosed) + { OS << " uclosed"; + } if (vclosed) + { OS << " vclosed"; + } } // poles and weights @@ -455,52 +613,76 @@ static void Print(const occ::handle& S, nbuknots = S->NbUKnots(); nbvknots = S->NbVKnots(); if (!compact) + { OS << "\n Degrees :"; + } OS << udegree << " " << vdegree << " "; if (!compact) + { OS << "\n NbPoles :"; + } OS << nbupoles << " " << nbvpoles << " "; if (!compact) + { OS << "\n NbKnots :"; + } OS << nbuknots << " " << nbvknots << " "; if (!compact) + { OS << "\n Poles :\n"; + } for (i = 1; i <= nbupoles; i++) { for (j = 1; j <= nbvpoles; j++) { if (!compact) + { OS << "\n " << std::setw(2) << i << ", " << std::setw(2) << j << " : "; + } Print(S->Pole(i, j), OS, compact); if (urational || vrational) + { OS << " " << S->Weight(i, j); + } if (compact) + { OS << " "; + } } OS << "\n"; } OS << "\n"; if (!compact) + { OS << "\n UKnots :\n"; + } for (i = 1; i <= nbuknots; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } OS << S->UKnot(i) << " " << S->UMultiplicity(i) << "\n"; } OS << "\n"; if (!compact) + { OS << "\n VKnots :\n"; + } for (i = 1; i <= nbvknots; i++) { if (!compact) + { OS << "\n " << std::setw(2) << i << " : "; + } OS << S->VKnot(i) << " " << S->VMultiplicity(i) << "\n"; } OS << "\n"; if (!compact) + { OS << "\n"; + } } //================================================================================================= @@ -510,17 +692,25 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << RECTANGULAR << " "; + } else + { OS << "RectangularTrimmedSurface"; + } double U1, U2, V1, V2; S->Bounds(U1, U2, V1, V2); if (!compact) + { OS << "\nParameters : "; + } OS << U1 << " " << U2 << " " << V1 << " " << V2 << "\n"; if (!compact) + { OS << "BasisSurface :\n"; + } GeomTools_SurfaceSet::PrintSurface(S->BasisSurface(), OS, compact); } @@ -531,15 +721,23 @@ static void Print(const occ::handle& S, const bool compact) { if (compact) + { OS << OFFSET << " "; + } else + { OS << "OffsetSurface"; + } if (!compact) + { OS << "\nOffset : "; + } OS << S->Offset() << "\n"; if (!compact) + { OS << "BasisSurface :\n"; + } GeomTools_SurfaceSet::PrintSurface(S->BasisSurface(), OS, compact); } @@ -671,7 +869,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, gp_Ax3& A3) IS >> P >> A >> AX >> AY; gp_Ax3 ax3(P, A, AX); if (AY.DotCross(A, AX) < 0) + { ax3.YReverse(); + } A3 = ax3; return IS; } @@ -778,14 +978,20 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i, j); if (urational || vrational) + { GeomTools::GetReal(IS, weights(i, j)); + } } } if (urational || vrational) + { S = new Geom_BezierSurface(poles, weights); + } else + { S = new Geom_BezierSurface(poles); + } return IS; } @@ -811,7 +1017,9 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle> poles(i, j); if (urational || vrational) + { GeomTools::GetReal(IS, weights(i, j)); + } } } @@ -832,6 +1040,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS, occ::handle>(Standard_IStream& IS, occ::handle>(Standard_IStream& IS, occ::handle> buffer; if (strcmp(buffer, "Surfaces")) { - std::cout << "Not a surface table" << std::endl; + std::cout << "Not a surface table" << '\n'; return; } diff --git a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_UndefinedTypeHandler.cxx b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_UndefinedTypeHandler.cxx index 61f8cbc0c9..a7bf04f55e 100644 --- a/src/ModelingData/TKGeomBase/GeomTools/GeomTools_UndefinedTypeHandler.cxx +++ b/src/ModelingData/TKGeomBase/GeomTools/GeomTools_UndefinedTypeHandler.cxx @@ -30,9 +30,13 @@ void GeomTools_UndefinedTypeHandler::PrintCurve(const occ::handle& / const bool compact) const { if (!compact) + { OS << "****** UNKNOWN CURVE TYPE ******\n"; + } else - std::cout << "****** UNKNOWN CURVE TYPE ******" << std::endl; + { + std::cout << "****** UNKNOWN CURVE TYPE ******" << '\n'; + } } //================================================================================================= @@ -51,9 +55,13 @@ void GeomTools_UndefinedTypeHandler::PrintCurve2d(const occ::handle& Herm, { BS->LocateU(Ux, 0.0, I1, I2); // localization of the inserted knots if (Uy != 0.0) + { BS->LocateU(Uy, 0.0, I3, I4); + } } - if (I1 == I2) // definition and filling of the + if (I1 == I2) + { // definition and filling of the if ((I3 == I4) || (I3 == 0)) { // array of knots Knots = new NCollection_HArray1(1, BS->NbKnots()); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } } else { Knots = new NCollection_HArray1(1, BS->NbKnots() + 1); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Uy); } + } else { if ((I3 == I4) || (I3 == 0)) { Knots = new NCollection_HArray1(1, BS->NbKnots() + 1); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Ux); } else { Knots = new NCollection_HArray1(1, BS->NbKnots() + 2); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Ux); Knots->SetValue(BS->NbKnots() + 2, Uy); } @@ -276,32 +288,42 @@ static void PolyTest(const NCollection_Array1& Herm, { if (Polesinit(0).Y() >= (1 / TolPoles) * Polesinit(3).Y() || Polesinit(0).Y() <= TolPoles * Polesinit(3).Y()) + { throw Standard_DimensionError("Hermit Impossible Tolerance"); + } if ((max == 0) || (max == 3)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - TolPoles * Polemax)); + } } else if ((max == 1) || (max == 2)) { if ((min == 0) || (min == 3)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - (1 / TolPoles) * Polemin)); + } } else { if ((TolPoles * Polemax < Polesinit(0).Y()) && (TolPoles * Polemax < Polesinit(3).Y())) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - TolPoles * Polemax)); + } mark = 1; } if ((1 / TolPoles * Polemin > Polesinit(0).Y()) && (1 / TolPoles * Polemin > Polesinit(3).Y()) && (mark == 0)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - 1 / TolPoles * Polemin)); + } mark = 1; } if (mark == 0) @@ -315,18 +337,22 @@ static void PolyTest(const NCollection_Array1& Herm, if (boucle == 2) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole3 * (std::pow(10.0, (-0.5 * std::log10(TolPoles) - a / 2.0))))); + } } else if (boucle == 1) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole0 * (std::pow(10.0, (a / 2.0 + 0.5 * std::log10(TolPoles)))))); + } dercas = 1; } } @@ -336,18 +362,22 @@ static void PolyTest(const NCollection_Array1& Herm, if (boucle == 2) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole0 * (std::pow(10.0, (-0.5 * std::log10(TolPoles) - a / 2.0))))); + } } else if (boucle == 1) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole3 * (std::pow(10.0, (a / 2.0 + 0.5 * std::log10(TolPoles)))))); + } dercas = 1; } } @@ -360,7 +390,9 @@ static void PolyTest(const NCollection_Array1& Herm, if (!SignDenom(Polesinit)) // inversion of the polynome sign { for (index = 0; index <= 3; index++) + { Polesinit(index).SetCoord(0.0, -Polesinit(index).Y()); + } } // loop of positivity @@ -368,50 +400,76 @@ static void PolyTest(const NCollection_Array1& Herm, { Us1 = Polesinit(0).Y() / (Polesinit(0).Y() - Polesinit(1).Y()); if (boucle == 2) + { Us1 = Us1 * knots(2); + } if (boucle == 1) + { if (Ux != 0.0) + { Us1 = Us1 * Ux; + } + } BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); if (I1 < 2) + { U4 = Us1; + } else + { U4 = knots(I1); + } } if ((Polesinit(1).Y() >= 0.0) && (Polesinit(2).Y() < 0.0)) { Us2 = Polesinit(2).Y() / (Polesinit(2).Y() - Polesinit(3).Y()); if (boucle == 2) + { Us2 = knots(knots.Length() - 1) + Us2 * (1 - knots(knots.Length() - 1)); + } if (boucle == 1) + { if (Ux != 0.0) + { Us2 = Uy + Us2 * (1 - Uy); + } + } BSplCLib::LocateParameter(3, knots, Us2, false, 1, knots.Length(), I1, Us2); if (I1 >= (knots.Length() - 1)) + { U5 = Us2; + } else + { U5 = knots(I1 + 1); + } } if (dercas == 1) + { boucle++; + } if ((Polesinit(1).Y() < 0.0) && (Polesinit(2).Y() < 0.0)) { Us1 = Polesinit(0).Y() / (Polesinit(0).Y() - Polesinit(1).Y()); Us2 = Polesinit(2).Y() / (Polesinit(2).Y() - Polesinit(3).Y()); if (boucle != 0) + { if (Ux != 0.0) { Us1 = Us1 * Ux; Us2 = Uy + Us2 * (1 - Uy); } + } if (Us2 <= Us1) { BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); - if (knots(I1) >= Us2) // insertion of one knot for the two poles + if (knots(I1) >= Us2) + { // insertion of one knot for the two poles U4 = knots(I1); + } else { if (I1 >= 2) @@ -424,22 +482,32 @@ static void PolyTest(const NCollection_Array1& Herm, cas = 1; } } - if (cas == 0) // insertion of only one new knot + if (cas == 0) + { // insertion of only one new knot U4 = (Us1 + Us2) / 2; + } } } else { // insertion of two knots BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); if (I1 >= 2) + { U4 = knots(I1); + } else + { U4 = Us1; + } BSplCLib::LocateParameter(3, knots, Us2, false, 1, knots.Length(), I3, Us2); if (I3 < (BS->NbKnots() - 1)) + { U5 = knots(I3 + 1); + } else + { U5 = Us2; + } } } } @@ -476,7 +544,9 @@ static void PolyTest(const NCollection_Array1& Herm, { BS->LocateU(Ux, 0.0, I1, I2); // localization of the inserted knots if (Uy != 0.0) + { BS->LocateU(Uy, 0.0, I3, I4); + } } if (I1 == I2) // definition and filling of the @@ -485,13 +555,17 @@ static void PolyTest(const NCollection_Array1& Herm, { // array of knots Knots = new NCollection_HArray1(1, BS->NbKnots()); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } } else { Knots = new NCollection_HArray1(1, BS->NbKnots() + 1); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Uy); } } @@ -501,14 +575,18 @@ static void PolyTest(const NCollection_Array1& Herm, { Knots = new NCollection_HArray1(1, BS->NbKnots() + 1); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Ux); } else { Knots = new NCollection_HArray1(1, BS->NbKnots() + 2); for (i = 1; i <= BS->NbKnots(); i++) + { Knots->SetValue(i, BS->Knot(i)); + } Knots->SetValue(BS->NbKnots() + 1, Ux); Knots->SetValue(BS->NbKnots() + 2, Uy); } @@ -538,25 +616,33 @@ static void PolyTest(const NCollection_Array1& Herm, { if (Polesinit(0).Y() >= (1 / TolPoles) * Polesinit(3).Y() || Polesinit(0).Y() <= TolPoles * Polesinit(3).Y()) + { throw Standard_DimensionError("Hermit Impossible Tolerance"); + } if ((max == 0) || (max == 3)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - TolPoles * Polemax)); + } } else if ((max == 1) || (max == 2)) { if ((min == 0) || (min == 3)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - (1 / TolPoles) * Polemin)); + } } else { if ((TolPoles * Polemax < Polesinit(0).Y()) && (TolPoles * Polemax < Polesinit(3).Y())) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - TolPoles * Polemax)); + } mark = 1; } @@ -564,7 +650,9 @@ static void PolyTest(const NCollection_Array1& Herm, && (1 / TolPoles * Polemin > Polesinit(3).Y()) && (mark == 0)) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord(0.0, (Polesinit(i).Y() - 1 / TolPoles * Polemin)); + } mark = 1; } if (mark == 0) @@ -578,18 +666,22 @@ static void PolyTest(const NCollection_Array1& Herm, if (boucle == 2) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole3 * (std::pow(10.0, (-0.5 * std::log10(TolPoles) - a / 2.0))))); + } } else if (boucle == 1) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole0 * (std::pow(10.0, (a / 2.0 + 0.5 * std::log10(TolPoles)))))); + } dercas = 1; } } @@ -599,18 +691,22 @@ static void PolyTest(const NCollection_Array1& Herm, if (boucle == 2) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole0 * (std::pow(10.0, (-0.5 * std::log10(TolPoles) - a / 2.0))))); + } } else if (boucle == 1) { for (i = 0; i <= 3; i++) + { Polesinit(i).SetCoord( 0.0, Polesinit(i).Y() - (Pole3 * (std::pow(10.0, (a / 2.0 + 0.5 * std::log10(TolPoles)))))); + } dercas = 1; } } @@ -623,7 +719,9 @@ static void PolyTest(const NCollection_Array1& Herm, if (!SignDenom(Polesinit)) // inversion of the polynome sign { for (index = 0; index <= 3; index++) + { Polesinit(index).SetCoord(0.0, -Polesinit(index).Y()); + } } // positivity loop @@ -631,50 +729,76 @@ static void PolyTest(const NCollection_Array1& Herm, { Us1 = Polesinit(0).Y() / (Polesinit(0).Y() - Polesinit(1).Y()); if (boucle == 2) + { Us1 = Us1 * knots(2); + } if (boucle == 1) + { if (Ux != 0.0) + { Us1 = Us1 * Ux; + } + } BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); if (I1 < 2) + { U4 = Us1; + } else + { U4 = knots(I1); + } } if ((Polesinit(1).Y() >= 0.0) && (Polesinit(2).Y() < 0.0)) { Us2 = Polesinit(2).Y() / (Polesinit(2).Y() - Polesinit(3).Y()); if (boucle == 2) + { Us2 = knots(knots.Length() - 1) + Us2 * (1 - knots(knots.Length() - 1)); + } if (boucle == 1) + { if (Ux != 0.0) + { Us2 = Uy + Us2 * (1 - Uy); + } + } BSplCLib::LocateParameter(3, knots, Us2, false, 1, knots.Length(), I1, Us2); if (I1 >= (knots.Length() - 1)) + { U5 = Us2; + } else + { U5 = knots(I1 + 1); + } } if (dercas == 1) + { boucle++; + } if ((Polesinit(1).Y() < 0.0) && (Polesinit(2).Y() < 0.0)) { Us1 = Polesinit(0).Y() / (Polesinit(0).Y() - Polesinit(1).Y()); Us2 = Polesinit(2).Y() / (Polesinit(2).Y() - Polesinit(3).Y()); if (boucle != 0) + { if (Ux != 0.0) { Us1 = Us1 * Ux; Us2 = Uy + Us2 * (1 - Uy); } + } if (Us2 <= Us1) { BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); - if (knots(I1) >= Us2) // insertion of one knot for the two poles + if (knots(I1) >= Us2) + { // insertion of one knot for the two poles U4 = knots(I1); + } else { if (I1 >= 2) @@ -687,22 +811,32 @@ static void PolyTest(const NCollection_Array1& Herm, cas = 1; } } - if (cas == 0) // insertion of only one new knot + if (cas == 0) + { // insertion of only one new knot U4 = (Us1 + Us2) / 2; + } } } else { // insertion of two knots BSplCLib::LocateParameter(3, knots, Us1, false, 1, knots.Length(), I1, Us1); if (I1 >= 2) + { U4 = knots(I1); + } else + { U4 = Us1; + } BSplCLib::LocateParameter(3, knots, Us2, false, 1, knots.Length(), I3, Us2); if (I3 < (BS->NbKnots() - 1)) + { U5 = knots(I3 + 1); + } else + { U5 = Us2; + } } } } @@ -715,10 +849,14 @@ static void PolyTest(const NCollection_Array1& Herm, static void InsertKnots(occ::handle& BS, const double U4, const double U5) { - if (U4 != 0.0) // insertion of :0 knot if U4=0 - BS->InsertKnot(U4); // 1 knot if U4=U5 - if ((U5 != 1.0) && (U5 != U4)) // 2 knots otherwise + if (U4 != 0.0) + { // insertion of :0 knot if U4=0 + BS->InsertKnot(U4); // 1 knot if U4=U5 + } + if ((U5 != 1.0) && (U5 != U4)) + { // 2 knots otherwise BS->InsertKnot(U5); + } } //======================================================================= @@ -777,6 +915,7 @@ occ::handle Hermit::Solution(const occ::handle Hermit::Solution(const occ::handle Hermit::Solution(const occ::handleKnot(2) < TolKnots) - || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) // checking of the knots tolerance + if ((BS2->Knot(2) < TolKnots) || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) + { // checking of the knots tolerance throw Standard_DimensionError("Hermit Impossible Tolerance"); + } else { - if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) // test on the final inserted knots + if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) + { // test on the final inserted knots InsertKnots(BS1, BS2->Knot(2), 1.0); + } else { if ((Upos1 == 0.0) && (Utol1 == 0.0) && (Uint1 == 0.0)) + { InsertKnots(BS1, BS2->Knot(BS2->NbKnots() - 1), 1.0); + } else + { InsertKnots(BS1, BS2->Knot(BS2->NbKnots() - 1), BS2->Knot(2)); + } } MovePoles(BS1); // relocation of the no-contrained knots } @@ -878,6 +1025,7 @@ occ::handle Hermit::Solution(const occ::handle Hermit::Solution(const occ::handle Hermit::Solution(const occ::handleKnot(2) < TolKnots) - || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) // checking of the knots tolerance + if ((BS2->Knot(2) < TolKnots) || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) + { // checking of the knots tolerance throw Standard_DimensionError("Hermit Impossible Tolerance"); + } else { - if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) // test on the final inserted knots + if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) + { // test on the final inserted knots InsertKnots(BS1, BS2->Knot(2), 1.0); + } else { if ((Upos1 == 0.0) && (Utol1 == 0.0) && (Uint1 == 0.0)) + { InsertKnots(BS1, BS2->Knot(BS2->NbKnots() - 1), 1.0); + } else + { InsertKnots(BS1, BS2->Knot(BS2->NbKnots() - 1), BS2->Knot(2)); + } } MovePoles(BS1); // relocation of the no-contrained knots } @@ -979,6 +1135,7 @@ void Hermit::Solutionbis(const occ::handle& BS, InsertKnots(BS2, Upos1, Upos2); // and insertion if (Upos1 != 0.0) + { if (Upos2 != 1.0) { Ux = std::min(Upos1, Upos2); @@ -989,6 +1146,7 @@ void Hermit::Solutionbis(const occ::handle& BS, Ux = Upos1; Uy = Upos1; } + } else { Ux = Upos2; @@ -1023,17 +1181,22 @@ void Hermit::Solutionbis(const occ::handle& BS, } InsertKnots(BS2, Utol1, Utol2); } - if ((BS2->Knot(2) < TolKnots) - || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) // checking of the knots tolerance + if ((BS2->Knot(2) < TolKnots) || (BS2->Knot(BS2->NbKnots() - 1) > (1 - TolKnots))) + { // checking of the knots tolerance throw Standard_DimensionError("Hermit Impossible Tolerance"); + } else { - if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) // test on the final inserted knots + if ((Upos2 == 1.0) && (Utol2 == 1.0) && (Uint2 == 1.0)) + { // test on the final inserted knots Knotmin = BS2->Knot(2); + } else { if ((Upos1 == 0.0) && (Utol1 == 0.0) && (Uint1 == 0.0)) + { Knotmax = BS2->Knot(BS2->NbKnots() - 1); + } else { Knotmin = BS2->Knot(2); diff --git a/src/ModelingData/TKGeomBase/IntAna/IntAna_Curve.cxx b/src/ModelingData/TKGeomBase/IntAna/IntAna_Curve.cxx index 74c44ec4e2..3d84fe43bd 100644 --- a/src/ModelingData/TKGeomBase/IntAna/IntAna_Curve.cxx +++ b/src/ModelingData/TKGeomBase/IntAna/IntAna_Curve.cxx @@ -351,7 +351,9 @@ void IntAna_Curve::InternalUVValue(const double theta, const double aTolD = 2.0 * aDT * std::abs(B * aDB - 2.0 * (A * aDC + C * aDA)); if (aDiscriminant < aTolD) + { aDiscriminant = 0.0; + } if (std::abs(A) <= Precision::PConfusion()) { @@ -408,7 +410,9 @@ bool IntAna_Curve::D1u(const double theta, gp_Pnt& Pt, gp_Vec& Vec) // Pt = Value(theta); if (std::abs(A) < 1.0e-7 || std::abs(SigneSqrtDis) < 1.0e-10) + { return (false); + } //-- Approximation of the derivative (better than the mathematical computation!) double dtheta = (DomainSup - DomainInf) * 1.0e-6; @@ -491,13 +495,19 @@ void IntAna_Curve::FindParameter(const gp_Pnt& theP, NCollection_List& t for (int i = 0; i < aMaxPar; i++) { if (aParams[i] > myLastParameter) + { break; + } if (aParams[i] < myFirstParameter) + { continue; + } if (i && (aParams[i] - aParams[i - 1]) < Precision::PConfusion()) + { continue; + } double U = 0.0, V = 0.0, A = 0.0, B = 0.0, C = 0.0, sint = 0.0, cost = 0.0, SigneSqrtDis = 0.0; InternalUVValue(aParams[i], U, V, A, B, C, cost, sint, SigneSqrtDis); @@ -505,9 +515,13 @@ void IntAna_Curve::FindParameter(const gp_Pnt& theP, NCollection_List& t double aSqTol; if (aParams[i] == aTheta || (TwoCurves && aParams[i] == DomainSup + DomainSup - aTheta)) + { aSqTol = InternalPrecision; + } else + { aSqTol = aSqTolPrecision; + } if (aP.SquareDistance(theP) < aSqTol) { diff --git a/src/ModelingData/TKGeomBase/IntAna/IntAna_IntQuadQuad.cxx b/src/ModelingData/TKGeomBase/IntAna/IntAna_IntQuadQuad.cxx index 4ada8fc265..64fbefa9c9 100644 --- a/src/ModelingData/TKGeomBase/IntAna/IntAna_IntQuadQuad.cxx +++ b/src/ModelingData/TKGeomBase/IntAna/IntAna_IntQuadQuad.cxx @@ -68,7 +68,9 @@ static void AddSpecialPoints(const IntAna_Quadric& theQuad, const NCollection_List& aLSP = theQuad.SpecialPoints(); if (aLSP.IsEmpty()) + { return; + } double aU = 0.0, aV = 0.0; double aMaxDelta = 0.0; @@ -1609,7 +1611,7 @@ void IntAna_IntQuadQuad::Parameters(const int, // i, double&, double&) const { - std::cout << "IntAna_IntQuadQuad::Parameters(...) is not yet implemented" << std::endl; + std::cout << "IntAna_IntQuadQuad::Parameters(...) is not yet implemented" << '\n'; } /********************************************************************************* diff --git a/src/ModelingData/TKGeomBase/IntAna/IntAna_QuadQuadGeo.cxx b/src/ModelingData/TKGeomBase/IntAna/IntAna_QuadQuadGeo.cxx index e5f8d042b5..4a80b7cc0b 100644 --- a/src/ModelingData/TKGeomBase/IntAna/IntAna_QuadQuadGeo.cxx +++ b/src/ModelingData/TKGeomBase/IntAna/IntAna_QuadQuadGeo.cxx @@ -270,7 +270,9 @@ double EstimDist(const gp_Cone& theCon1, const gp_Cone& theCon2) gce_MakePln aMkPln(aPA1, aPA2, aP3); if (!aMkPln.IsDone()) + { return Precision::Infinite(); + } const gp_Pln& aPln = aMkPln.Value(); @@ -628,7 +630,9 @@ void IntAna_QuadQuadGeo::Perform(const gp_Pln& P, dir1 = dd1; } else + { dir1 = axec.Direction(); + } } else if (std::abs(dist) < radius) { @@ -1006,7 +1010,9 @@ void IntAna_QuadQuadGeo::Perform(const gp_Pln& P, const gp_Sphere& S) pt1.SetCoord(X - dist * A, Y - dist * B, Z - dist * C); dir1 = P.Axis().Direction(); if (!P.Direct()) + { dir1.Reverse(); + } dir2 = P.Position().XDirection(); param1 = std::sqrt(radius * radius - dist * dist); } @@ -1198,7 +1204,9 @@ void IntAna_QuadQuadGeo::Perform(const gp_Cylinder& Cyl1, const gp_Cylinder& Cyl double R1_RmR = R1 / RmR; if (R1 < R2) + { R1_RmR = -R1_RmR; + } pt1.SetCoord(P1.X() + R1_RmR * (P2.X() - P1.X()), P1.Y() + R1_RmR * (P2.Y() - P1.Y()), @@ -2074,9 +2082,13 @@ void IntAna_QuadQuadGeo::Perform(const gp_Sphere& Sph1, const gp_Sphere& Sph2, c nbint = 1; double t2; if (R1 == Rmax) + { t2 = (R1 + (R2 + dO1O2)) * 0.5; + } else + { t2 = (-R1 + (dO1O2 - R2)) * 0.5; + } pt1.SetCoord(O1.X() + t2 * Dir.X(), O1.Y() + t2 * Dir.Y(), O1.Z() + t2 * Dir.Z()); } @@ -2672,13 +2684,17 @@ gp_Pnt IntAna_QuadQuadGeo::Point(const int n) const throw Standard_DomainError(); } if (param1 == 0.0) + { return (pt1); + } return (pt2); } else if (typeres == IntAna_Point) { if (n == 1) + { return (pt1); + } return (pt2); } @@ -2723,7 +2739,9 @@ gp_Circ IntAna_QuadQuadGeo::Circle(const int n) const throw Standard_DomainError(); } if (param2 == 0.0) + { return (gp_Circ(DirToAx2(pt1, dir1), param1)); + } return (gp_Circ(DirToAx2(pt2, dir2), param2)); } else if ((n > nbint) || (n < 1) || (typeres != IntAna_Circle)) diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_2.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_2.cxx index de03b38459..55a2c1005b 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_2.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_2.cxx @@ -180,7 +180,9 @@ void IntAna2d_AnaIntersection::Perform(const gp_Circ2d& C1, const gp_Circ2d& C2) nbp = 1; gp_Vec2d ax(C1.Location(), C2.Location()); if (C1.Radius() < C2.Radius()) + { ax.Reverse(); + } gp_Vec2d Ox1(C1.XAxis().Direction()); gp_Vec2d Ox2(C2.XAxis().Direction()); diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_5.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_5.cxx index 2e1a366f25..e76ab593d5 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_5.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_5.cxx @@ -56,7 +56,7 @@ void IntAna2d_AnaIntersection::Perform(const gp_Circ2d& Circle, const IntAna2d_C if (!Sol.IsDone()) { - std::cout << "\n\nmath_TrigonometricFunctionRoots -> NotDone\n\n" << std::endl; + std::cout << "\n\nmath_TrigonometricFunctionRoots -> NotDone\n\n" << '\n'; done = false; return; } @@ -76,7 +76,9 @@ void IntAna2d_AnaIntersection::Perform(const gp_Circ2d& Circle, const IntAna2d_C ty = radius * std::sin(S); Coord_Ancien_Repere(tx, ty, Axe_rep); if (!CIsDirect) + { S = M_PI + M_PI - S; + } lpnt[i - 1].SetValue(tx, ty, S); } Traitement_Points_Confondus(nbp, lpnt); diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_6.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_6.cxx index 341623c816..942c23d99a 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_6.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_6.cxx @@ -76,7 +76,9 @@ void IntAna2d_AnaIntersection::Perform(const gp_Elips2d& Elips, const IntAna2d_C ty = minor_radius * std::sin(S); Coord_Ancien_Repere(tx, ty, Axe_rep); if (!EIsDirect) + { S = M_PI + M_PI - S; + } lpnt[i - 1].SetValue(tx, ty, S); } Traitement_Points_Confondus(nbp, lpnt); diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_7.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_7.cxx index d1ec930e6f..ee023bdfa1 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_7.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_7.cxx @@ -71,7 +71,9 @@ void IntAna2d_AnaIntersection::Perform(const gp_Parab2d& P, const IntAna2d_Conic ty = S; Coord_Ancien_Repere(tx, ty, Axe_rep); if (!PIsDirect) + { S = -S; + } lpnt[i - 1].SetValue(tx, ty, S); } Traitement_Points_Confondus(nbp, lpnt); diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_8.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_8.cxx index d768c93e29..9b031ab529 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_8.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_AnaIntersection_8.cxx @@ -110,7 +110,9 @@ void IntAna2d_AnaIntersection::Perform(const gp_Hypr2d& H, const IntAna2d_Conic& Coord_Ancien_Repere(tx, ty, Axe_rep); S = std::log(S); if (!HIsDirect) + { S = -S; + } lpnt[nb_sol_valides - 1].SetValue(tx, ty, S); } } diff --git a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_Outils.cxx b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_Outils.cxx index 13a365484d..b6f4b1408e 100644 --- a/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_Outils.cxx +++ b/src/ModelingData/TKGeomBase/IntAna2d/IntAna2d_Outils.cxx @@ -70,7 +70,9 @@ MyDirectPolynomialRoots::MyDirectPolynomialRoots(const double A4, nbsol++; } if (nbp & 1) + { PbPossible = true; + } } else { @@ -196,7 +198,9 @@ MyDirectPolynomialRoots::MyDirectPolynomialRoots(const double A4, //-- At least as many as the complete polynomial //-- for (nbsol = 0; nbsol < NbsolPolyComplet || std::abs(val[nbsol]) < Epsilon(10000.0); nbsol++) + { ; + } //-- std::cout<<" IntAna2d : nbsol:"<LastVParameter()), FuncTol); if (!aPrjPS.IsDone()) + { continue; + } POnS = aPrjPS.Solution(); Sol = gp_Pnt(POnS.X(), P.X(), POnS.Y()); isDone = true; @@ -398,7 +406,9 @@ static bool ExactBound(gp_Pnt& Sol, gp_Pnt2d(t2, Surface->LastUParameter()), FuncTol); if (!aPrjPS.IsDone()) + { continue; + } POnS = aPrjPS.Solution(); Sol = gp_Pnt(POnS.X(), POnS.Y(), P.X()); isDone = true; @@ -450,7 +460,9 @@ static void DichExactBound(gp_Pnt& Sol, V0 = Sol.Z(); } else + { aNotSol = t; + } } #ifdef OCCT_DEBUG_CHRONO ResultChron(chr_dicho_bound, t_dicho_bound); @@ -510,12 +522,18 @@ static bool InitialPoint(const gp_Pnt& Point, FuncTol, true); if (aPrjPS.IsDone()) + { if (argmin == 0 || aExtPS.SquareDistance(i) < aExtPS.SquareDistance(argmin)) + { argmin = i; + } + } } } if (argmin == 0) + { return false; + } else { Extrema_POnSurf POnS = aExtPS.Point(argmin); @@ -664,10 +682,14 @@ void ProjLib_CompProjectedCurve::Init() for (i = 2; i <= Nend; i++) { if (CExt.SquareDistance(i) < min_val2) + { min_val2 = CExt.SquareDistance(i); + } } if (min_val2 > myMaxDist * myMaxDist) + { return; // No near solution -> exit. + } } } @@ -701,12 +723,16 @@ void ProjLib_CompProjectedCurve::Init() // to avoid infinite computation in some difficult cases. new_part = false; if (t > FirstU && std::abs(t - prevDeb) <= Precision::PConfusion()) + { SameDeb = true; + } while (t <= LastU && !new_part && !FromLastU && !SameDeb) { prevDeb = t; if (t == LastU) + { FromLastU = true; + } bool initpoint = false; double U = 0., V = 0.; gp_Pnt CPoint; @@ -769,14 +795,18 @@ void ProjLib_CompProjectedCurve::Init() { d1(t, U, V, D, myCurve, mySurface); if (D.X() < 0) + { U = aUppBorder.X(); + } } else if ((std::abs(U - aUppBorder.X()) < mySurface->UResolution(Precision::PConfusion())) && mySurface->IsUPeriodic()) { d1(t, U, V, D, myCurve, mySurface); if (D.X() > 0) + { U = aLowBorder.X(); + } } if ((std::abs(V - aLowBorder.Y()) < mySurface->VResolution(Precision::PConfusion())) @@ -784,14 +814,18 @@ void ProjLib_CompProjectedCurve::Init() { d1(t, U, V, D, myCurve, mySurface); if (D.Y() < 0) + { V = aUppBorder.Y(); + } } else if ((std::abs(V - aUppBorder.Y()) <= mySurface->VResolution(Precision::PConfusion())) && mySurface->IsVPeriodic()) { d1(t, U, V, D, myCurve, mySurface); if (D.Y() > 0) + { V = aLowBorder.Y(); + } } } @@ -832,7 +866,9 @@ void ProjLib_CompProjectedCurve::Init() else { if (t == LastU) + { break; + } t += Step; if (t > LastU) { @@ -842,7 +878,9 @@ void ProjLib_CompProjectedCurve::Init() } } if (!new_part) + { break; + } // We have found a new continuous part occ::handle> hSeq = new NCollection_HSequence(); @@ -852,7 +890,9 @@ void ProjLib_CompProjectedCurve::Init() prevTriple = Triple; if (Triple.X() == LastU) + { break; // return; + } // Computation of WalkStep gp_Vec D1, D2; @@ -861,15 +901,21 @@ void ProjLib_CompProjectedCurve::Init() MagnD1 = D1.Magnitude(); MagnD2 = D2.Magnitude(); if (MagnD2 < Precision::Confusion()) + { WalkStep = MaxStep; + } else + { WalkStep = std::min(MaxStep, std::max(MinStep, 0.1 * MagnD1 / MagnD2)); + } Step = WalkStep; t = Triple.X() + Step; if (t > LastU) + { t = LastU; + } double prevStep = Step; double U0, V0; @@ -906,7 +952,9 @@ void ProjLib_CompProjectedCurve::Init() if ((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) + { mySequence->Value(myNbCurves)->Append(Triple); + } if ((LastU - Triple.X()) < Tol) { t = LastU + 1; @@ -932,7 +980,9 @@ void ProjLib_CompProjectedCurve::Init() { Step = Step + LastU - t; if (std::abs(Step - SaveStep) <= Precision::PConfusion()) + { Step = GlobalMinStep; // to avoid looping + } t = LastU; } } @@ -977,7 +1027,9 @@ void ProjLib_CompProjectedCurve::Init() if ((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) + { mySequence->Value(myNbCurves)->Append(Triple); + } if (t == LastU) { t = LastU + 1; @@ -988,9 +1040,13 @@ void ProjLib_CompProjectedCurve::Init() MagnD1 = D1.Magnitude(); MagnD2 = D2.Magnitude(); if (MagnD2 < Precision::Confusion()) + { WalkStep = MaxStep; + } else + { WalkStep = std::min(MaxStep, std::max(MinStep, 0.1 * MagnD1 / MagnD2)); + } Step = WalkStep; t += Step; @@ -1040,11 +1096,15 @@ void ProjLib_CompProjectedCurve::Init() myNbCurves--; } else + { ipart++; + } } if (myNbCurves == 0) + { return; + } // 2. Removing common parts of bounds for (i = 1; i < myNbCurves; i++) @@ -1169,7 +1229,9 @@ void ProjLib_CompProjectedCurve::Init() void ProjLib_CompProjectedCurve::Perform() { if (myNbCurves == 0) + { return; + } bool approx2d = myProj2d; bool approx3d = myProj3d; @@ -1240,7 +1302,9 @@ void ProjLib_CompProjectedCurve::Perform() Ufin = -Ufin; } else + { Dir = gp_Dir2d(gp_Dir2d::D::Y); + } PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(UIso, 0), Dir), Udeb, Ufin); HPCur = new Geom2dAdaptor_Curve(PCur2d); } @@ -1259,7 +1323,9 @@ void ProjLib_CompProjectedCurve::Perform() Ufin = -Ufin; } else + { Dir = gp_Dir2d(gp_Dir2d::D::X); + } PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(0, VIso), Dir), Udeb, Ufin); HPCur = new Geom2dAdaptor_Curve(PCur2d); } @@ -1360,7 +1426,9 @@ void ProjLib_CompProjectedCurve::SetContinuity(const GeomAbs_Shape theContinuity void ProjLib_CompProjectedCurve::SetMaxDegree(const int theMaxDegree) { if (theMaxDegree < 1) + { return; + } myMaxDegree = theMaxDegree; } @@ -1369,7 +1437,9 @@ void ProjLib_CompProjectedCurve::SetMaxDegree(const int theMaxDegree) void ProjLib_CompProjectedCurve::SetMaxSeg(const int theMaxSeg) { if (theMaxSeg < 1) + { return; + } myMaxSeg = theMaxSeg; } @@ -1435,7 +1505,9 @@ int ProjLib_CompProjectedCurve::NbCurves() const void ProjLib_CompProjectedCurve::Bounds(const int Index, double& Udeb, double& Ufin) const { if (Index < 1 || Index > myNbCurves) + { throw Standard_NoSuchObject(); + } Udeb = mySequence->Value(Index)->Value(1).X(); Ufin = mySequence->Value(Index)->Value(mySequence->Value(Index)->Length()).X(); } @@ -1445,7 +1517,9 @@ void ProjLib_CompProjectedCurve::Bounds(const int Index, double& Udeb, double& U bool ProjLib_CompProjectedCurve::IsSinglePnt(const int Index, gp_Pnt2d& P) const { if (Index < 1 || Index > myNbCurves) + { throw Standard_NoSuchObject(); + } P = gp_Pnt2d(mySequence->Value(Index)->Value(1).Y(), mySequence->Value(Index)->Value(1).Z()); return mySnglPnts->Value(Index); } @@ -1455,7 +1529,9 @@ bool ProjLib_CompProjectedCurve::IsSinglePnt(const int Index, gp_Pnt2d& P) const bool ProjLib_CompProjectedCurve::IsUIso(const int Index, double& U) const { if (Index < 1 || Index > myNbCurves) + { throw Standard_NoSuchObject(); + } U = mySequence->Value(Index)->Value(1).Y(); return myUIso->Value(Index); } @@ -1465,7 +1541,9 @@ bool ProjLib_CompProjectedCurve::IsUIso(const int Index, double& U) const bool ProjLib_CompProjectedCurve::IsVIso(const int Index, double& V) const { if (Index < 1 || Index > myNbCurves) + { throw Standard_NoSuchObject(); + } V = mySequence->Value(Index)->Value(1).Z(); return myVIso->Value(Index); } @@ -1505,8 +1583,12 @@ void ProjLib_CompProjectedCurve::D0(const double U, gp_Pnt2d& P) const int End = mySequence->Value(i)->Length(); for (j = 1; j < End; j++) + { if ((U >= mySequence->Value(i)->Value(j).X()) && (U <= mySequence->Value(i)->Value(j + 1).X())) + { break; + } + } // U0 = mySequence->Value(i)->Value(j).Y(); // V0 = mySequence->Value(i)->Value(j).Z(); @@ -1526,9 +1608,13 @@ void ProjLib_CompProjectedCurve::D0(const double U, gp_Pnt2d& P) const else { if (j == 1) + { j = 2; + } if (j > mySequence->Value(i)->Length() - 2) + { j = mySequence->Value(i)->Length() - 2; + } gp_Vec2d I1, I2, I3, I21, I22, I31, Y1, Y2, Y3, Y4, Res; double X1, X2, X3, X4; @@ -1558,14 +1644,22 @@ void ProjLib_CompProjectedCurve::D0(const double U, gp_Pnt2d& P) const V0 = Res.Y(); if (U0 < mySurface->FirstUParameter()) + { U0 = mySurface->FirstUParameter(); + } else if (U0 > mySurface->LastUParameter()) + { U0 = mySurface->LastUParameter(); + } if (V0 < mySurface->FirstVParameter()) + { V0 = mySurface->FirstVParameter(); + } else if (V0 > mySurface->LastVParameter()) + { V0 = mySurface->LastVParameter(); + } } // End of cubic interpolation @@ -1578,7 +1672,9 @@ void ProjLib_CompProjectedCurve::D0(const double U, gp_Pnt2d& P) const gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), FuncTol); if (aPrjPS.IsDone()) + { P = aPrjPS.Solution(); + } else { gp_Pnt thePoint = myCurve->Value(U); @@ -1589,15 +1685,21 @@ void ProjLib_CompProjectedCurve::D0(const double U, gp_Pnt2d& P) const // Search for the nearest solution which is also a normal projection Nend = aExtPS.NbExt(); for (k = 2; k <= Nend; k++) + { if (aExtPS.SquareDistance(k) < aExtPS.SquareDistance(imin)) + { imin = k; + } + } const Extrema_POnSurf& POnS = aExtPS.Point(imin); double ParU, ParV; POnS.Parameter(ParU, ParV); P.SetCoord(ParU, ParV); } else + { P.SetCoord(U0, V0); + } } } @@ -1628,7 +1730,9 @@ void ProjLib_CompProjectedCurve::D2(const double t, gp_Pnt2d& P, gp_Vec2d& V1, g gp_Vec2d ProjLib_CompProjectedCurve::DN(const double t, const int N) const { if (N < 1) + { throw Standard_OutOfRange("ProjLib_CompProjectedCurve : N must be greater than 0"); + } else if (N == 1) { gp_Pnt2d P; @@ -1644,7 +1748,9 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const double t, const int N) const return V2; } else if (N > 2) + { throw Standard_NotImplemented("ProjLib_CompProjectedCurve::DN"); + } return gp_Vec2d(); } @@ -1677,10 +1783,14 @@ GeomAbs_Shape ProjLib_CompProjectedCurve::Continuity() const GeomAbs_Shape ContC = myCurve->Continuity(); GeomAbs_Shape ContSu = mySurface->UContinuity(); if (ContSu < ContC) + { ContC = ContSu; + } GeomAbs_Shape ContSv = mySurface->VContinuity(); if (ContSv < ContC) + { ContC = ContSv; + } return ContC; } @@ -1690,7 +1800,9 @@ GeomAbs_Shape ProjLib_CompProjectedCurve::Continuity() const double ProjLib_CompProjectedCurve::MaxDistance(const int Index) const { if (Index < 1 || Index > myNbCurves) + { throw Standard_NoSuchObject(); + } return myMaxDistance->Value(Index); } @@ -1709,7 +1821,9 @@ void ProjLib_CompProjectedCurve::Intervals(NCollection_Array1& T, const GeomAbs_Shape S) const { if (myTabInt.IsNull()) + { BuildIntervals(S); + } T = myTabInt->Array1(); } @@ -1787,9 +1901,13 @@ void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const Ur = mySequence->Value(i)->Value(j + 1).Y(); if (std::abs(Ul - CutPntsU(k)) <= myTolU) + { TUdisc.Append(mySequence->Value(i)->Value(j).X()); + } else if (std::abs(Ur - CutPntsU(k)) <= myTolU) + { TUdisc.Append(mySequence->Value(i)->Value(j + 1).X()); + } else if ((Ul < CutPntsU(k) && CutPntsU(k) < Ur) || (Ur < CutPntsU(k) && CutPntsU(k) < Ul)) { double V; @@ -1801,9 +1919,13 @@ void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const Triple = mySequence->Value(i)->Value(j); d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); if (std::abs(D.X()) < Precision::Confusion()) + { Tol = myTolU; + } else + { Tol = std::min(myTolU, myTolU / std::abs(D.X())); + } Tl = mySequence->Value(i)->Value(j).X(); Tr = mySequence->Value(i)->Value(j + 1).X(); @@ -1855,9 +1977,13 @@ void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const Vr = mySequence->Value(i)->Value(j + 1).Z(); if (std::abs(Vl - CutPntsV(k)) <= myTolV) + { TVdisc.Append(mySequence->Value(i)->Value(j).X()); + } else if (std::abs(Vr - CutPntsV(k)) <= myTolV) + { TVdisc.Append(mySequence->Value(i)->Value(j + 1).X()); + } else if ((Vl < CutPntsV(k) && CutPntsV(k) < Vr) || (Vr < CutPntsV(k) && CutPntsV(k) < Vl)) { double U; @@ -1869,9 +1995,13 @@ void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const Triple = mySequence->Value(i)->Value(j); d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); if (std::abs(D.Y()) < Precision::Confusion()) + { Tol = myTolV; + } else + { Tol = std::min(myTolV, myTolV / std::abs(D.Y())); + } Tl = mySequence->Value(i)->Value(j).X(); Tr = mySequence->Value(i)->Value(j + 1).X(); @@ -2072,7 +2202,9 @@ void ProjLib_CompProjectedCurve::UpdateTripleByTrapCriteria(gp_Pnt& thePoint) co } if (!isProblemsPossible) + { return; + } double U, V; bool isDone = InitialPoint(myCurve->Value(thePoint.X()), @@ -2086,7 +2218,9 @@ void ProjLib_CompProjectedCurve::UpdateTripleByTrapCriteria(gp_Pnt& thePoint) co myMaxDist); if (!isDone) + { return; + } // Restore original position in case of period jump. if (mySurface->IsUPeriodic() @@ -2198,7 +2332,9 @@ void FindSplitPoint(SplitDS& theSplitDS, const double theMinParam, const double theSplitDS.myExtPS->Perform(aPOnC2.Value()); if (!theSplitDS.myExtPS->IsDone()) + { return; + } // Find point with the minimal Euclidean distance to avoid // false positive points detection. diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApprox.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApprox.cxx index 7afefb571b..543edac0ed 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApprox.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApprox.cxx @@ -165,10 +165,14 @@ static gp_Pnt2d Function_Value(const double U, S = M_PI + S; } if (S > U1 || S < U2) + { S = ElCLib::InPeriod(S, U1, U2); + } } if (T < V1 || T > V2) + { T = ElCLib::InPeriod(T, V1, V2); + } } return gp_Pnt2d(S, T); @@ -213,7 +217,9 @@ static bool Function_D1(const double U, double Nv = D1V.SquareMagnitude(); if (Nu < Epsilon(1.) || Nv < Epsilon(1.)) + { return false; + } dU /= Nu; dV /= Nv; @@ -350,7 +356,9 @@ static void Function_SetUVBounds(double& myU1, for (double par = W1 + Step; par <= W2; par += Step) { if (!isclandper) + { par += Step; + } P = myCurve->Value(par); ElSLib::Parameters(Cone, P, U, V); U += Delta; @@ -360,16 +368,24 @@ static void Function_SetUVBounds(double& myU1, if (((IsEqual(U, (2 * M_PI), 1.e-10) && (U1 >= 0. && U1 <= M_PI)) && (IsEqual(U, Ul, 1.e-10) && !IsEqual(Uf, 0., 1.e-10))) && isclandper) + { U = 0.0; + } else { // Protection against first-last point on seam. if (isFirst) + { U1 = 2 * M_PI; + } else if (par + Step >= W2) + { U = 0.0; + } else + { Delta -= 2 * M_PI; + } } U += Delta; d = U - U1; @@ -379,16 +395,24 @@ static void Function_SetUVBounds(double& myU1, if (((IsEqual(U, 0., 1.e-10) && (U1 >= M_PI && U1 <= (2 * M_PI))) && (IsEqual(U, Ul, 1.e-10) && !IsEqual(Uf, (2 * M_PI), 1.e-10))) && isclandper) + { U = 2 * M_PI; + } else { // Protection against first-last point on seam. if (isFirst) + { U1 = 0.0; + } else if (par + Step >= W2) + { U = 2 * M_PI; + } else + { Delta += 2 * M_PI; + } } U += Delta; d = U - U1; @@ -410,13 +434,19 @@ static void Function_SetUVBounds(double& myU1, if (std::abs(pmin - W1) > Precision::PConfusion() && std::abs(pmin - W2) > Precision::PConfusion()) + { myU1 -= dmax * .5; + } if (std::abs(pmax - W1) > Precision::PConfusion() && std::abs(pmax - W2) > Precision::PConfusion()) + { myU2 += dmax * .5; + } if ((myU1 >= 0. && myU1 <= 2 * M_PI) && (myU2 >= 0. && myU2 <= 2 * M_PI)) + { UCouture = false; + } else { U = (myU1 + myU2) / 2.; @@ -536,10 +566,14 @@ static void Function_SetUVBounds(double& myU1, if (std::abs(pmin - W1) > Precision::PConfusion() && std::abs(pmin - W2) > Precision::PConfusion()) + { myU1 -= dmax * .5; + } if (std::abs(pmax - W1) > Precision::PConfusion() && std::abs(pmax - W2) > Precision::PConfusion()) + { myU2 += dmax * .5; + } if ((myU1 >= 0. && myU1 <= 2 * M_PI) && (myU2 >= 0. && myU2 <= 2 * M_PI)) { @@ -597,11 +631,17 @@ static void Function_SetUVBounds(double& myU1, if ((D / A) < 0.) { if ((R - std::abs(D / A)) > Tol) + { NbSolutions = 2; + } else if (std::abs(R - std::abs(D / A)) < Tol) + { NbSolutions = 1; + } else + { NbSolutions = 0; + } } } } @@ -612,7 +652,9 @@ static void Function_SetUVBounds(double& myU1, if (std::abs(delta) < Tol * Tol) { if (A * D > 0.) + { NbSolutions = 1; + } } else if (delta > 0) { @@ -621,11 +663,15 @@ static void Function_SetUVBounds(double& myU1, xx = -A * D + delta; // if (xx > Tol) + { NbSolutions++; + } xx = -A * D - delta; // if (xx > Tol) + { NbSolutions++; + } } } // @@ -813,10 +859,14 @@ static void Function_SetUVBounds(double& myU1, if (std::abs(pmin - W1) > Precision::PConfusion() && std::abs(pmin - W2) > Precision::PConfusion()) + { myU1 -= dmax * .5; + } if (std::abs(pmax - W1) > Precision::PConfusion() && std::abs(pmax - W2) > Precision::PConfusion()) + { myU2 += dmax * .5; + } if ((myU1 >= 0. && myU1 <= 2 * M_PI) && (myU2 >= 0. && myU2 <= 2 * M_PI)) { @@ -914,16 +964,24 @@ static void Function_SetUVBounds(double& myU1, if (std::abs(pminU - W1) > Precision::PConfusion() && std::abs(pminU - W2) > Precision::PConfusion()) + { myU1 -= dmaxU * .5; + } if (std::abs(pmaxU - W1) > Precision::PConfusion() && std::abs(pmaxU - W2) > Precision::PConfusion()) + { myU2 += dmaxU * .5; + } if (std::abs(pminV - W1) > Precision::PConfusion() && std::abs(pminV - W2) > Precision::PConfusion()) + { myV1 -= dmaxV * .5; + } if (std::abs(pmaxV - W1) > Precision::PConfusion() && std::abs(pmaxV - W2) > Precision::PConfusion()) + { myV2 += dmaxV * .5; + } if ((myU1 >= 0. && myU1 <= 2 * M_PI) && (myU2 >= 0. && myU2 <= 2 * M_PI)) { @@ -993,14 +1051,22 @@ public: myIsPeriodic[1] = mySurface->IsVPeriodic(); if (myIsPeriodic[0]) + { myPeriod[0] = mySurface->UPeriod(); + } else + { myPeriod[0] = 0.0; + } if (myIsPeriodic[1]) + { myPeriod[1] = mySurface->VPeriod(); + } else + { myPeriod[1] = 0.0; + } } void PeriodInformation(const int theDimIdx, bool& IsPeriodic, double& thePeriod) const override @@ -1288,9 +1354,13 @@ void ProjLib_ComputeApprox::Perform(const occ::handle& C, NbKnots = Conv.NbKnots(); if (NbPoles <= 0 || NbPoles > 100000) + { return; + } if (NbKnots <= 0 || NbKnots > 100000) + { return; + } NCollection_Array1 NewPoles(1, NbPoles); NCollection_Array1 NewKnots(1, NbKnots); @@ -1409,7 +1479,9 @@ void ProjLib_ComputeApprox::Perform(const occ::handle& C, if (!myBSpline.IsNull()) { if (du != 0. || dv != 0.) + { myBSpline->Translate(gp_Vec2d(du, dv)); + } if (ToMirror) { gp_Ax2d Axe(gp_Pnt2d(0., 0.), gp_Dir2d(gp_Dir2d::D::X)); diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx index a14c2e82dd..05d8c14161 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx @@ -157,10 +157,14 @@ static double anOrthogSqValue(const gp_Pnt& aBasePnt, gp_Vec aBaseVec(aBasePnt, aProjPnt); if (aSu.SquareMagnitude() > Precision::SquareConfusion()) + { aSu.Normalize(); + } if (aSv.SquareMagnitude() > Precision::SquareConfusion()) + { aSv.Normalize(); + } double aFirstPart = aSu.Dot(aBaseVec); double aSecondPart = aSv.Dot(aBaseVec); @@ -189,7 +193,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Pnt aPnt; theData.mySurf->D0(p2d.X(), theU, aPnt); if (aPnt.SquareDistance(p) < aSurfPntDist) + { p2d.SetY(theU); + } } if (std::abs(p2d.Y() - Vinf) < Precision::PConfusion() @@ -199,7 +205,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Pnt aPnt; theData.mySurf->D0(theU, p2d.Y(), aPnt); if (aPnt.SquareDistance(p) < aSurfPntDist) + { p2d.SetX(theU); + } } int decalU = 0, decalV = 0; @@ -217,9 +225,13 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Cylinder Cylinder = theData.mySurf->Cylinder(); ElSLib::Parameters(Cylinder, p, S, T); if (U0 < Uinf) + { decalU = -int((Uinf - U0) / (2 * M_PI)) - 1; + } if (U0 > Usup) + { decalU = int((U0 - Usup) / (2 * M_PI)) + 1; + } S += decalU * 2 * M_PI; break; } @@ -227,9 +239,13 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Cone Cone = theData.mySurf->Cone(); ElSLib::Parameters(Cone, p, S, T); if (U0 < Uinf) + { decalU = -int((Uinf - U0) / (2 * M_PI)) - 1; + } if (U0 > Usup) + { decalU = int((U0 - Usup) / (2 * M_PI)) + 1; + } S += decalU * 2 * M_PI; break; } @@ -237,22 +253,34 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Sphere Sphere = theData.mySurf->Sphere(); ElSLib::Parameters(Sphere, p, S, T); if (U0 < Uinf) + { decalU = -int((Uinf - U0) / (2 * M_PI)) - 1; + } if (U0 > Usup) + { decalU = int((U0 - Usup) / (2 * M_PI)) + 1; + } S += decalU * 2 * M_PI; if (V0 < Vinf) + { decalV = -int((Vinf - V0) / (2 * M_PI)) - 1; + } if (V0 > (Vsup + (Vsup - Vinf))) + { decalV = int((V0 - Vsup + (Vsup - Vinf)) / (2 * M_PI)) + 1; + } T += decalV * 2 * M_PI; if (0.4 * M_PI < std::abs(U0 - S) && std::abs(U0 - S) < 1.6 * M_PI) { T = M_PI - T; if (U0 < S) + { S -= M_PI; + } else + { S += M_PI; + } } break; } @@ -260,13 +288,21 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) gp_Torus Torus = theData.mySurf->Torus(); ElSLib::Parameters(Torus, p, S, T); if (U0 < Uinf) + { decalU = -int((Uinf - U0) / (2 * M_PI)) - 1; + } if (U0 > Usup) + { decalU = int((U0 - Usup) / (2 * M_PI)) + 1; + } if (V0 < Vinf) + { decalV = -int((Vinf - V0) / (2 * M_PI)) - 1; + } if (V0 > Vsup) + { decalV = int((V0 - Vsup) / (2 * M_PI)) + 1; + } S += decalU * 2 * M_PI; T += decalV * 2 * M_PI; break; @@ -285,7 +321,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) if (U0 < Uinf) { if (!uperiod) + { U0 = Uinf; + } else { decalU = int((Uinf - U0) / uperiod) + 1; @@ -295,7 +333,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) if (U0 > Usup) { if (!uperiod) + { U0 = Usup; + } else { decalU = -(int((U0 - Usup) / uperiod) + 1); @@ -305,7 +345,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) if (V0 < Vinf) { if (!vperiod) + { V0 = Vinf; + } else { decalV = int((Vinf - V0) / vperiod) + 1; @@ -315,7 +357,9 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) if (V0 > Vsup) { if (!vperiod) + { V0 = Vsup; + } else { decalV = -int((V0 - Vsup) / vperiod) - 1; @@ -327,21 +371,37 @@ static gp_Pnt2d Function_Value(const double theU, const aFuncStruct& theData) double uLittle = (Usup - Uinf) / 10, vLittle = (Vsup - Vinf) / 10; double uInfLi = 0, vInfLi = 0, uSupLi = 0, vSupLi = 0; if ((U0 - Uinf) > uLittle) + { uInfLi = U0 - uLittle; + } else + { uInfLi = Uinf; + } if ((V0 - Vinf) > vLittle) + { vInfLi = V0 - vLittle; + } else + { vInfLi = Vinf; + } if ((Usup - U0) > uLittle) + { uSupLi = U0 + uLittle; + } else + { uSupLi = Usup; + } if ((Vsup - V0) > vLittle) + { vSupLi = V0 + vLittle; + } else + { vSupLi = Vsup; + } GeomAdaptor_Surface SurfLittle; if (Type == GeomAbs_BSplineSurface) @@ -583,7 +643,9 @@ static occ::handle Concat(const occ::handleNbPoles(); @@ -701,12 +763,16 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::Perform( InitialCurve2d->Intervals(Inter2d, GeomAbs_C1); j = 1; for (i = 1, j = 1; i <= nbInter; i++) + { if (std::abs(Inter.Value(i) - Inter2d.Value(j)) < ParamTol) { if (j > nbInter2d) + { break; + } j++; } + } if (j != (nbInter2d + 1)) { C2dIsToCompute = true; @@ -888,7 +954,9 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::Perform( { AHC2d = BuildInitialCurve2d(Curve, S); if (!myProjIsDone) + { return occ::handle(); + } } return ProjectUsingInitialCurve2d(AHC, S, AHC2d); } @@ -974,9 +1042,13 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (std::abs(Sloc - S) > M_PI) { if (Sloc > S) + { usens++; + } else + { usens--; + } } Pts2d(i).SetCoord(S + usens * 2 * M_PI, T); } @@ -997,9 +1069,13 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (std::abs(Sloc - S) > M_PI) { if (Sloc > S) + { usens++; + } else + { usens--; + } } Pts2d(i).SetCoord(S + usens * 2 * M_PI, T); } @@ -1021,21 +1097,33 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (1.6 * M_PI < std::abs(Sloc - S)) { if (Sloc > S) + { usens += 2; + } else + { usens -= 2; + } } if (1.6 * M_PI > std::abs(Sloc - S) && std::abs(Sloc - S) > 0.4 * M_PI) { vparit = !vparit; if (Sloc > S) + { usens++; + } else + { usens--; + } if (std::abs(Tloc - Vsup) < (Vsup - Vinf) / 5) + { vsens++; + } else + { vsens--; + } } if (vparit) { @@ -1063,16 +1151,24 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (std::abs(Sloc - S) > M_PI) { if (Sloc > S) + { usens++; + } else + { usens--; + } } if (std::abs(Tloc - T) > M_PI) { if (Tloc > T) + { vsens++; + } else + { vsens--; + } } Pts2d(i).SetCoord(S + usens * 2 * M_PI, T + vsens * 2 * M_PI); } @@ -1102,7 +1198,9 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial { double aSqDist = aExtPS.SquareDistance(i); if (aSqDist < aMinSqDist) + { aMinSqDist = aSqDist; + } } } if (aMinSqDist > DistTol3d2) // try to project with less tolerance @@ -1142,7 +1240,9 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } } if (!isSame) + { Sols.Append(p2d); + } } if (Dist2Min > aExtPS.SquareDistance(i)) { @@ -1153,7 +1253,9 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } if (Sols.Length() > 1) + { areManyZeros = true; + } if (Dist2Min <= DistTol3d2) { @@ -1175,7 +1277,9 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial const gp_Pnt2d& aP2 = Sols.Value(j); double aDist2 = aP1.SquareDistance(aP2); if (aDist2 > Dist2Max) + { Dist2Max = aDist2; + } } } double aMaxT2 = std::max(TolU, TolV); @@ -1303,6 +1407,7 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial // U1 and V1 are the points for construction of poles myDist = Dist2Min; for (i = 2; i <= NbOfPnts; i++) + { if (myProjIsDone) { myProjIsDone = false; @@ -1353,16 +1458,24 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (uperiod > 0. && std::abs(U0 - LocalU) >= uperiod / 2.) { if (LocalU > U0) + { usens = -1; + } else + { usens = 1; + } } if (vperiod > 0. && std::abs(V0 - LocalV) >= vperiod / 2.) { if (LocalV > V0) + { vsens = -1; + } else + { vsens = 1; + } } U0 = LocalU; V0 = LocalV; @@ -1412,14 +1525,19 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial aUinf = Surf->FirstUParameter(); aUsup = Surf->LastUParameter(); if ((aUsup - U0) > (U0 - aUinf)) + { Uaux = 2 * aUinf - U0 + uperiod; + } else + { Uaux = 2 * aUsup - U0 - uperiod; + } Extrema_GenLocateExtPS locext(*Surf, TolU, TolV); locext.Perform(pntproj, Uaux, V0); if (locext.IsDone()) + { if (locext.SquareDistance() < DistTol3d2) { // OCC217 // if (locext.SquareDistance() < Tol3d * Tol3d) { @@ -1429,9 +1547,13 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } (locext.Point()).Parameter(u, v); if ((aUsup - U0) > (U0 - aUinf)) + { usens--; + } else + { usens++; + } U0 = u; V0 = v; U1 = U0 + usens * uperiod; @@ -1439,6 +1561,7 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial Pts2d(i).SetCoord(U1, V1); myProjIsDone = true; } + } } if (!myProjIsDone && vperiod) { @@ -1446,14 +1569,19 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial aVinf = Surf->FirstVParameter(); aVsup = Surf->LastVParameter(); if ((aVsup - V0) > (V0 - aVinf)) + { Vaux = 2 * aVinf - V0 + vperiod; + } else + { Vaux = 2 * aVsup - V0 - vperiod; + } Extrema_GenLocateExtPS locext(*Surf, TolU, TolV); locext.Perform(pntproj, U0, Vaux); if (locext.IsDone()) + { if (locext.SquareDistance() < DistTol3d2) { // OCC217 // if (locext.SquareDistance() < Tol3d * Tol3d) { @@ -1463,9 +1591,13 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } (locext.Point()).Parameter(u, v); if ((aVsup - V0) > (V0 - aVinf)) + { vsens--; + } else + { vsens++; + } U0 = u; V0 = v; U1 = U0 + usens * uperiod; @@ -1473,23 +1605,33 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial Pts2d(i).SetCoord(U1, V1); myProjIsDone = true; } + } } if (!myProjIsDone && uperiod && vperiod) { double Uaux, Vaux; if ((Usup - U0) > (U0 - Uinf)) + { Uaux = 2 * Uinf - U0 + uperiod; + } else + { Uaux = 2 * Usup - U0 - uperiod; + } if ((Vsup - V0) > (V0 - Vinf)) + { Vaux = 2 * Vinf - V0 + vperiod; + } else + { Vaux = 2 * Vsup - V0 - vperiod; + } Extrema_GenLocateExtPS locext(*Surf, TolU, TolV); locext.Perform(pntproj, Uaux, Vaux); if (locext.IsDone()) + { if (locext.SquareDistance() < DistTol3d2) { // if (locext.SquareDistance() < Tol3d * Tol3d) { @@ -1499,13 +1641,21 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } (locext.Point()).Parameter(u, v); if ((Usup - U0) > (U0 - Uinf)) + { usens--; + } else + { usens++; + } if ((Vsup - V0) > (V0 - Vinf)) + { vsens--; + } else + { vsens++; + } U0 = u; V0 = v; U1 = U0 + usens * uperiod; @@ -1513,6 +1663,7 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial Pts2d(i).SetCoord(U1, V1); myProjIsDone = true; } + } } if (!myProjIsDone) { @@ -1522,11 +1673,13 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial Dist2Min = ext.SquareDistance(1); int aGoodValue = 1; for (j = 2; j <= ext.NbExt(); j++) + { if (Dist2Min > ext.SquareDistance(j)) { Dist2Min = ext.SquareDistance(j); aGoodValue = j; } + } if (Dist2Min < DistTol3d2) { // if (Dist2Min < Tol3d * Tol3d) { @@ -1568,7 +1721,10 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial } } else + { break; + } + } } } // -- Pnts2d is transformed into Geom2d_BSplineCurve, with the help of Param and Mult @@ -1583,25 +1739,39 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::BuildInitial if (uperiod) { if (TestU < Uinf - TolU) + { sense = 1.; + } else if (TestU > Usup + TolU) + { sense = -1; + } while (TestU < Uinf - TolU || TestU > Usup + TolU) + { TestU += sense * uperiod; + } } if (vperiod) { sense = 0.; if (TestV < Vinf - TolV) + { sense = 1.; + } else if (TestV > Vsup + TolV) + { sense = -1.; + } while (TestV < Vinf - TolV || TestV > Vsup + TolV) + { TestV += sense * vperiod; + } } gp_Vec2d Offset(TestU - MidPoint.X(), TestV - MidPoint.Y()); if (std::abs(Offset.X()) > gp::Resolution() || std::abs(Offset.Y()) > gp::Resolution()) + { myBSpline->Translate(Offset); + } ////////////////////////////////////////// Geom2dAdaptor_Curve GAC(myBSpline); occ::handle IC2d = new Geom2dAdaptor_Curve(GAC); @@ -1746,12 +1916,18 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::ProjectUsi myProjIsDone = true; } else + { break; + } } else + { break; + } if (!myProjIsDone) + { break; + } } if (myProjIsDone) { @@ -1791,14 +1967,22 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::ProjectUsi myProjIsDone = true; } else + { break; + } } else + { break; + } if (myProjIsDone) + { myProjIsDone = false; + } else + { break; + } } if (myProjIsDone) { @@ -1862,12 +2046,18 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::ProjectUsi myProjIsDone = true; } else + { break; + } } else + { break; + } if (!myProjIsDone) + { break; + } } if (myProjIsDone) { @@ -1907,14 +2097,22 @@ occ::handle ProjLib_ComputeApproxOnPolarSurface::ProjectUsi myProjIsDone = true; } else + { break; + } } else + { break; + } if (myProjIsDone) + { myProjIsDone = false; + } else + { break; + } } if (myProjIsDone) { diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cone.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cone.cxx index 45159c8765..906d9b26ee 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cone.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cone.cxx @@ -143,16 +143,22 @@ void ProjLib_Cone::Project(const gp_Circ& C) U = std::atan2(y, x); } if (U < 0.) + { U += 2 * M_PI; + } V = z / std::cos(myCone.SemiAngle()); gp_Pnt2d P2d1(U, V); gp_Dir2d D2d; if (ZCone.Dot(ZCir) > 0.) + { D2d.SetCoord(1., 0.); + } else + { D2d.SetCoord(-1., 0.); + } myLin = gp_Lin2d(P2d1, D2d); isDone = true; diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cylinder.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cylinder.cxx index 800766a7c7..e2af4a1259 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cylinder.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Cylinder.cxx @@ -98,7 +98,9 @@ void ProjLib_Cylinder::Project(const gp_Lin& L) // In other cases, the projection is wrong. if (L.Direction().XYZ().CrossSquareMagnitude(myCylinder.Position().Direction().XYZ()) > Precision::Angular() * Precision::Angular()) + { return; + } myType = GeomAbs_Line; @@ -125,7 +127,9 @@ void ProjLib_Cylinder::Project(const gp_Circ& C) const gp_Ax2& aCircPos = C.Position(); if (aCylPos.Direction().XYZ().CrossSquareMagnitude(aCircPos.Direction().XYZ()) > Precision::Angular() * Precision::Angular()) + { return; + } myType = GeomAbs_Line; @@ -139,9 +143,13 @@ void ProjLib_Cylinder::Project(const gp_Circ& C) gp_Pnt2d P2d1(U, V); gp_Dir2d D2d; if (ZCyl.Dot(aCircPos.Direction()) > 0.) + { D2d.SetCoord(1., 0.); + } else + { D2d.SetCoord(-1., 0.); + } myLin = gp_Lin2d(P2d1, D2d); isDone = true; diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_PrjResolve.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_PrjResolve.cxx index 26aea4a126..447b2b2ac3 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_PrjResolve.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_PrjResolve.cxx @@ -30,7 +30,9 @@ ProjLib_PrjResolve::ProjLib_PrjResolve(const Adaptor3d_Curve& C, myFix(Fix) { if (myFix > 3 || myFix < 1) + { throw Standard_ConstructionError(); + } mySolution = gp_Pnt2d(0., 0.); myCurve = &C; mySurface = &S; @@ -99,7 +101,9 @@ void ProjLib_PrjResolve::Perform(const double t, S1.Perform(F, Start, BInf, BSup); if (!S1.IsDone()) + { return; + } } mySolution.SetXY(F.Solution().XY()); @@ -113,16 +117,26 @@ void ProjLib_PrjResolve::Perform(const double t, ExtraV = 2. * Tol2d.Y(); // } if (mySolution.X() > Inf.X() - Tol2d.X() && mySolution.X() < Inf.X()) + { mySolution.SetX(Inf.X()); + } if (mySolution.X() > Sup.X() && mySolution.X() < Sup.X() + Tol2d.X()) + { mySolution.SetX(Sup.X()); + } if (mySolution.Y() > Inf.Y() - Tol2d.Y() && mySolution.Y() < Inf.Y()) + { mySolution.SetY(Inf.Y()); + } if (mySolution.Y() > Sup.Y() && mySolution.Y() < Sup.Y() + Tol2d.Y()) + { mySolution.SetY(Sup.Y()); + } if (mySolution.X() < Inf.X() - ExtraU || mySolution.X() > Sup.X() + ExtraU || mySolution.Y() < Inf.Y() - ExtraV || mySolution.Y() > Sup.Y() + ExtraV) + { myDone = false; + } else if (FuncTol > 0) { math_Vector X(1, 2, 0.), FVal(1, 2, 0.); @@ -134,7 +148,9 @@ void ProjLib_PrjResolve::Perform(const double t, if (!SR.IsDone()) { if ((FVal(1) * FVal(1) + FVal(2) * FVal(2)) > FuncTol) + { myDone = false; + } } } } @@ -147,6 +163,8 @@ bool ProjLib_PrjResolve::IsDone() const gp_Pnt2d ProjLib_PrjResolve::Solution() const { if (!IsDone()) + { throw StdFail_NotDone(); + } return mySolution; } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx index a14f6e860b..0882e8bfc5 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx @@ -784,7 +784,9 @@ void ProjLib_ProjectOnPlane::Load(const occ::handle& C, { occ::handle aResultCurve = GeomCirclePtr; if (aResultCurve.IsNull()) + { aResultCurve = GeomEllipsePtr; + } // start and end parameters of the projected curve double aParFirst = myCurve->FirstParameter(); double aParLast = myCurve->LastParameter(); @@ -793,7 +795,9 @@ void ProjLib_ProjectOnPlane::Load(const occ::handle& C, GeomLib_Tool::Parameter(aResultCurve, aPntFirst, Precision::Confusion(), myFirstPar); GeomLib_Tool::Parameter(aResultCurve, aPntLast, Precision::Confusion(), myLastPar); while (myLastPar <= myFirstPar) + { myLastPar += myResult->Period(); + } } } break; @@ -996,9 +1000,13 @@ const occ::handle& ProjLib_ProjectOnPlane::GetResult() const double ProjLib_ProjectOnPlane::FirstParameter() const { if (myKeepParam || myIsApprox) + { return myCurve->FirstParameter(); + } else + { return myFirstPar; + } } //================================================================================================= @@ -1006,9 +1014,13 @@ double ProjLib_ProjectOnPlane::FirstParameter() const double ProjLib_ProjectOnPlane::LastParameter() const { if (myKeepParam || myIsApprox) + { return myCurve->LastParameter(); + } else + { return myLastPar; + } } //================================================================================================= @@ -1060,9 +1072,13 @@ bool ProjLib_ProjectOnPlane::IsClosed() const bool ProjLib_ProjectOnPlane::IsPeriodic() const { if (myIsApprox) + { return false; + } else + { return myCurve->IsPeriodic(); + } } //================================================================================================= @@ -1075,9 +1091,13 @@ double ProjLib_ProjectOnPlane::Period() const } if (myIsApprox) + { return false; + } else + { return myCurve->Period(); + } } //================================================================================================= @@ -1185,7 +1205,9 @@ GeomAbs_CurveType ProjLib_ProjectOnPlane::GetType() const gp_Lin ProjLib_ProjectOnPlane::Line() const { if (myType != GeomAbs_Line) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Line"); + } return myResult->Line(); } @@ -1195,7 +1217,9 @@ gp_Lin ProjLib_ProjectOnPlane::Line() const gp_Circ ProjLib_ProjectOnPlane::Circle() const { if (myType != GeomAbs_Circle) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Circle"); + } return myResult->Circle(); } @@ -1205,7 +1229,9 @@ gp_Circ ProjLib_ProjectOnPlane::Circle() const gp_Elips ProjLib_ProjectOnPlane::Ellipse() const { if (myType != GeomAbs_Ellipse) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Ellipse"); + } return myResult->Ellipse(); } @@ -1215,7 +1241,9 @@ gp_Elips ProjLib_ProjectOnPlane::Ellipse() const gp_Hypr ProjLib_ProjectOnPlane::Hyperbola() const { if (myType != GeomAbs_Hyperbola) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Hyperbola"); + } return myResult->Hyperbola(); } @@ -1225,7 +1253,9 @@ gp_Hypr ProjLib_ProjectOnPlane::Hyperbola() const gp_Parab ProjLib_ProjectOnPlane::Parabola() const { if (myType != GeomAbs_Parabola) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Parabola"); + } return myResult->Parabola(); } @@ -1235,12 +1265,18 @@ gp_Parab ProjLib_ProjectOnPlane::Parabola() const int ProjLib_ProjectOnPlane::Degree() const { if ((GetType() != GeomAbs_BSplineCurve) && (GetType() != GeomAbs_BezierCurve)) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Degree"); + } if (myIsApprox) + { return myResult->Degree(); + } else + { return myCurve->Degree(); + } } //================================================================================================= @@ -1248,12 +1284,18 @@ int ProjLib_ProjectOnPlane::Degree() const bool ProjLib_ProjectOnPlane::IsRational() const { if ((GetType() != GeomAbs_BSplineCurve) && (GetType() != GeomAbs_BezierCurve)) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:IsRational"); + } if (myIsApprox) + { return myResult->IsRational(); + } else + { return myCurve->IsRational(); + } } //================================================================================================= @@ -1261,12 +1303,18 @@ bool ProjLib_ProjectOnPlane::IsRational() const int ProjLib_ProjectOnPlane::NbPoles() const { if ((GetType() != GeomAbs_BSplineCurve) && (GetType() != GeomAbs_BezierCurve)) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:NbPoles"); + } if (myIsApprox) + { return myResult->NbPoles(); + } else + { return myCurve->NbPoles(); + } } //================================================================================================= @@ -1274,12 +1322,18 @@ int ProjLib_ProjectOnPlane::NbPoles() const int ProjLib_ProjectOnPlane::NbKnots() const { if (GetType() != GeomAbs_BSplineCurve) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:NbKnots"); + } if (myIsApprox) + { return myResult->NbKnots(); + } else + { return myCurve->NbKnots(); + } } //================================================================================================= @@ -1287,7 +1341,9 @@ int ProjLib_ProjectOnPlane::NbKnots() const occ::handle ProjLib_ProjectOnPlane::Bezier() const { if (myType != GeomAbs_BezierCurve) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:Bezier"); + } return myResult->Bezier(); } @@ -1297,7 +1353,9 @@ occ::handle ProjLib_ProjectOnPlane::Bezier() const occ::handle ProjLib_ProjectOnPlane::BSpline() const { if (myType != GeomAbs_BSplineCurve) + { throw Standard_NoSuchObject("ProjLib_ProjectOnPlane:BSpline"); + } return myResult->BSpline(); } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnSurface.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnSurface.cxx index 326a220048..3e1b7be2ab 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnSurface.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnSurface.cxx @@ -50,7 +50,7 @@ static gp_Pnt OnSurface_Value(const double U, } if (Index == 0) { - std::cout << " Extrema non trouve pour U = " << U << std::endl; + std::cout << " Extrema non trouve pour U = " << U << '\n'; return gp_Pnt(0., 0., 0.); } else diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectedCurve.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectedCurve.cxx index bb19c7fd82..c60ce2cac8 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectedCurve.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectedCurve.cxx @@ -103,7 +103,9 @@ static bool IsoIsDeg(const Adaptor3d_Surface& S, } if (D1NormMax > TolMax || D1NormMax < TolMin) + { Along = false; + } } else { @@ -116,7 +118,9 @@ static bool IsoIsDeg(const Adaptor3d_Surface& S, } if (D1NormMax > TolMax || D1NormMax < TolMin) + { Along = false; + } } return Along; } @@ -573,7 +577,9 @@ void ProjLib_ProjectedCurve::Perform(const occ::handle& C) } } else + { Vsingular[0] = ElCLib::Parameter(L, P); + } // SingularCase[0] = 3; } @@ -598,7 +604,9 @@ void ProjLib_ProjectedCurve::Perform(const occ::handle& C) } } else + { Vsingular[1] = ElCLib::Parameter(L, P); + } // SingularCase[1] = 4; } } @@ -716,7 +724,9 @@ void ProjLib_ProjectedCurve::Perform(const occ::handle& C) Comp.SetBndPnt(myBndPnt); Comp.Perform(myCurve, mySurface); if (Comp.Bezier().IsNull() && Comp.BSpline().IsNull()) + { return; // advanced projector has been failed too + } myResult.Done(); occ::handle aRes; if (Comp.BSpline().IsNull()) @@ -784,14 +794,20 @@ void ProjLib_ProjectedCurve::Perform(const occ::handle& C) const double aSurfFirstPar[2] = {mySurface->FirstUParameter(), mySurface->FirstVParameter()}; double aSurfPeriod[2] = {0.0, 0.0}; if (isPeriodic[0]) + { aSurfPeriod[0] = mySurface->UPeriod(); + } if (isPeriodic[1]) + { aSurfPeriod[1] = mySurface->VPeriod(); + } for (int anIdx = 1; anIdx <= 2; anIdx++) { if (!isPeriodic[anIdx - 1]) + { continue; + } if (myResult.GetType() == GeomAbs_BSplineCurve) { @@ -815,12 +831,18 @@ void ProjLib_ProjectedCurve::Perform(const occ::handle& C) int((aPnt2d.Coord(anIdx) - aSurfFirstPar[anIdx - 1]) / aSurfPeriod[anIdx - 1]); if (aPnt2d.Coord(anIdx) - aSurfFirstPar[anIdx - 1] < 0.0) + { aMapKey--; + } if (aMap.IsBound(aMapKey)) + { aMap.ChangeFind(aMapKey)++; + } else + { aMap.Bind(aMapKey, 1); + } } } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Projector.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Projector.cxx index 1d6d2c5462..8915bd04f9 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Projector.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Projector.cxx @@ -89,7 +89,9 @@ void ProjLib_Projector::SetPeriodic() const gp_Lin2d& ProjLib_Projector::Line() const { if (myType != GeomAbs_Line) + { throw Standard_NoSuchObject("ProjLib_Projector::Line"); + } return myLin; } @@ -98,7 +100,9 @@ const gp_Lin2d& ProjLib_Projector::Line() const const gp_Circ2d& ProjLib_Projector::Circle() const { if (myType != GeomAbs_Circle) + { throw Standard_NoSuchObject("ProjLib_Projector::Circle"); + } return myCirc; } @@ -107,7 +111,9 @@ const gp_Circ2d& ProjLib_Projector::Circle() const const gp_Elips2d& ProjLib_Projector::Ellipse() const { if (myType != GeomAbs_Ellipse) + { throw Standard_NoSuchObject("ProjLib_Projector::Ellipse"); + } return myElips; } @@ -116,7 +122,9 @@ const gp_Elips2d& ProjLib_Projector::Ellipse() const const gp_Hypr2d& ProjLib_Projector::Hyperbola() const { if (myType != GeomAbs_Hyperbola) + { throw Standard_NoSuchObject("ProjLib_Projector::Hyperbola"); + } return myHypr; } @@ -125,7 +133,9 @@ const gp_Hypr2d& ProjLib_Projector::Hyperbola() const const gp_Parab2d& ProjLib_Projector::Parabola() const { if (myType != GeomAbs_Parabola) + { throw Standard_NoSuchObject("ProjLib_Projector::Parabola"); + } return myParab; } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Sphere.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Sphere.cxx index 6510fbd711..507856ab63 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Sphere.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Sphere.cxx @@ -80,9 +80,13 @@ static gp_Pnt2d EvalPnt2d(const gp_Vec& P, const gp_Sphere& Sp) } if (Z > 1.) + { Z = 1.; + } else if (Z < -1.) + { Z = -1.; + } V = std::asin(Z); return gp_Pnt2d(U, V); @@ -139,9 +143,13 @@ void ProjLib_Sphere::Project(const gp_Circ& C) // so V2 = PI - V2; P2d2.SetX(P2d1.X()); if (P2d2.Y() < 0.) + { P2d2.SetY(-M_PI - P2d2.Y()); + } else + { P2d2.SetY(M_PI - P2d2.Y()); + } } else { @@ -158,7 +166,9 @@ void ProjLib_Sphere::Project(const gp_Circ& C) // P2d(U,V) :first point of the PCurve. double U = Xs.AngleWithRef(Xc, Xs ^ Ys); if (U < 0) + { U += 2 * M_PI; + } double Z = gp_Vec(O, C.Location()).Dot(Zs); double V = std::asin(Z / mySphere.Radius()); P2d1 = gp_Pnt2d(U, V); @@ -222,7 +232,9 @@ void ProjLib_Sphere::SetInBounds(const double U) Axis = gp_Ax2d(gp_Pnt2d(0., -M_PI / 2.), gp::DX2d()); } else + { return; + } Trsf.SetMirror(Axis); myLin.Transform(Trsf); diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Torus.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Torus.cxx index c91454de69..675de5d0f9 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Torus.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_Torus.cxx @@ -131,11 +131,15 @@ void ProjLib_Torus::Project(const gp_Circ& C) // Normally std::abs( P1.X() - P2.X()) = PI/2 // If != PI/2, we crossed the period => Reverse the Direction if (std::abs(P1.X() - P2.X()) > M_PI) + { V2d.Reverse(); + } gp_Dir2d D2(V2d); if (P1.X() < 0) + { P1.SetX(2 * M_PI + P1.X()); + } myLin = gp_Lin2d(P1, D2); } else @@ -143,12 +147,16 @@ void ProjLib_Torus::Project(const gp_Circ& C) // Iso U -> U = angle( Xt, OC) double U = Xt.AngleWithRef(OC, Xt ^ Yt); if (U < 0.) + { U += 2 * M_PI; + } // Origin of the line double V1 = OC.AngleWithRef(Xc, OC ^ Zt); if (V1 < 0.) + { V1 += 2 * M_PI; + } gp_Pnt2d P1(U, V1); diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource.cxx index 10edf16b74..07e4c8dfde 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource.cxx @@ -45,7 +45,9 @@ bool MeshVS_DataSource::GetNormal(const int Id, double& nz) const { if (Max <= 0) + { return false; + } MeshVS_Buffer aCoordsBuf(3 * Max * sizeof(double)); NCollection_Array1 Coords(aCoordsBuf, 1, 3 * Max); @@ -55,7 +57,9 @@ bool MeshVS_DataSource::GetNormal(const int Id, bool res = false; if (!GetGeom(Id, true, Coords, nbNodes, Type)) + { return res; + } if (Type == MeshVS_ET_Face && nbNodes >= 3) { @@ -111,10 +115,14 @@ bool MeshVS_DataSource::GetNormalsByElement(const int bool res = false; if (MaxNodes <= 0) + { return res; + } if (!GetGeom(Id, true, Coords, NbNodes, Type)) + { return res; + } int aNbNormals = NbNodes; @@ -122,7 +130,9 @@ bool MeshVS_DataSource::GetNormalsByElement(const int if (Type == MeshVS_ET_Volume) { if (!Get3DGeom(Id, NbNodes, aTopo)) + { return res; + } // calculate number of normals for faces of volume aNbNormals = aTopo->Upper() - aTopo->Lower() + 1; } @@ -133,11 +143,13 @@ bool MeshVS_DataSource::GetNormalsByElement(const int bool allNormals = (Type == MeshVS_ET_Face && IsNodal); // Try returning nodal normals if possible for (int k = 1; k <= NbNodes && allNormals; k++) + { allNormals = GetNodeNormal(k, Id, aNormals->ChangeValue(3 * k - 2), aNormals->ChangeValue(3 * k - 1), aNormals->ChangeValue(3 * k)); + } // Nodal normals not available or not needed if (!allNormals) @@ -199,7 +211,9 @@ bool MeshVS_DataSource::GetNormalsByElement(const int } // if ( !allNormals ) if (res || allNormals) + { Normals = aNormals; + } return (res || allNormals); } @@ -298,7 +312,9 @@ Bnd_Box MeshVS_DataSource::GetBoundingBox() const { int aKey = anIter.Key(); if (!GetGeom(aKey, false, aCoords, nbNodes, aType)) + { continue; + } aBox.Add(gp_Pnt(aCoordsBuf[0], aCoordsBuf[1], aCoordsBuf[2])); } } diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource3D.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource3D.cxx index a50888efba..1386e96a63 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource3D.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DataSource3D.cxx @@ -24,13 +24,17 @@ occ::handle>> MeshVS_DataSource3D: const int BasePoints) const { if (myPrismTopos.IsBound(BasePoints)) + { return myPrismTopos.Find(BasePoints); + } else { occ::handle>> result = CreatePrismTopology(BasePoints); if (!result.IsNull()) + { ((MeshVS_DataSource3D*)this)->myPrismTopos.Bind(BasePoints, result); + } return result; } } @@ -41,13 +45,17 @@ occ::handle>> MeshVS_DataSource3D: const int BasePoints) const { if (myPyramidTopos.IsBound(BasePoints)) + { return myPyramidTopos.Find(BasePoints); + } else { occ::handle>> result = CreatePyramidTopology(BasePoints); if (!result.IsNull()) + { ((MeshVS_DataSource3D*)this)->myPyramidTopos.Bind(BasePoints, result); + } return result; } } diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DeformedDataSource.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DeformedDataSource.cxx index 093adf1738..31202b1432 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_DeformedDataSource.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_DeformedDataSource.cxx @@ -51,13 +51,17 @@ bool MeshVS_DeformedDataSource::GetGeom(const int ID, { if (myNonDeformedDataSource.IsNull() || !myNonDeformedDataSource->GetGeom(ID, IsElement, Coords, NbNodes, Type)) + { return false; + } if (Type == MeshVS_ET_Node) { gp_Vec Vect; if (!GetVector(ID, Vect)) + { return false; + } shiftCoord(Coords, 1, myMagnify * Vect); } else @@ -65,12 +69,16 @@ bool MeshVS_DeformedDataSource::GetGeom(const int ID, MeshVS_Buffer aNodesBuf(NbNodes * sizeof(int)); NCollection_Array1 aNodes(aNodesBuf, 1, NbNodes); if (!myNonDeformedDataSource->GetNodesByElement(ID, aNodes, NbNodes)) + { return false; + } for (int i = 1; i <= NbNodes; i++) { gp_Vec Vect; if (!GetVector(aNodes(i), Vect)) + { return false; + } shiftCoord(Coords, i, myMagnify * Vect); } } @@ -84,9 +92,13 @@ bool MeshVS_DeformedDataSource::GetGeomType(const int ID, MeshVS_EntityType& Type) const { if (myNonDeformedDataSource.IsNull()) + { return false; + } else + { return myNonDeformedDataSource->GetGeomType(ID, IsElement, Type); + } } //================================================================================================= @@ -97,9 +109,13 @@ bool MeshVS_DeformedDataSource::Get3DGeom( occ::handle>>& Data) const { if (myNonDeformedDataSource.IsNull()) + { return false; + } else + { return myNonDeformedDataSource->Get3DGeom(ID, NbNodes, Data); + } } //================================================================================================= @@ -107,9 +123,13 @@ bool MeshVS_DeformedDataSource::Get3DGeom( void* MeshVS_DeformedDataSource::GetAddr(const int ID, const bool IsElement) const { if (myNonDeformedDataSource.IsNull()) + { return nullptr; + } else + { return myNonDeformedDataSource->GetAddr(ID, IsElement); + } } //================================================================================================= @@ -119,9 +139,13 @@ bool MeshVS_DeformedDataSource::GetNodesByElement(const int ID, int& NbNodes) const { if (myNonDeformedDataSource.IsNull()) + { return false; + } else + { return myNonDeformedDataSource->GetNodesByElement(ID, NodeIDs, NbNodes); + } } //================================================================================================= @@ -129,9 +153,13 @@ bool MeshVS_DeformedDataSource::GetNodesByElement(const int ID, const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const { if (myNonDeformedDataSource.IsNull()) + { return myEmptyMap; + } else + { return myNonDeformedDataSource->GetAllNodes(); + } } //================================================================================================= @@ -139,9 +167,13 @@ const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllElements() const { if (myNonDeformedDataSource.IsNull()) + { return myEmptyMap; + } else + { return myNonDeformedDataSource->GetAllElements(); + } } //================================================================================================= @@ -164,7 +196,9 @@ bool MeshVS_DeformedDataSource::GetVector(const int ID, gp_Vec& Vect) const { bool aRes = myVectors.IsBound(ID); if (aRes) + { Vect = myVectors.Find(ID); + } return aRes; } @@ -174,9 +208,13 @@ void MeshVS_DeformedDataSource::SetVector(const int ID, const gp_Vec& Vect) { bool aRes = myVectors.IsBound(ID); if (aRes) + { myVectors.ChangeFind(ID) = Vect; + } else + { myVectors.Bind(ID, Vect); + } } //================================================================================================= @@ -199,9 +237,13 @@ occ::handle MeshVS_DeformedDataSource::GetNonDeformedDataSour void MeshVS_DeformedDataSource::SetMagnify(const double theMagnify) { if (theMagnify <= 0) + { myMagnify = 1.0; + } else + { myMagnify = theMagnify; + } } //================================================================================================= diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_Drawer.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_Drawer.cxx index 683ec17782..0c4d980aa3 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_Drawer.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_Drawer.cxx @@ -40,9 +40,13 @@ void MeshVS_Drawer::Assign(const occ::handle& aDrawer) void MeshVS_Drawer::SetInteger(const int Key, const int Value) { if (myIntegers.IsBound(Key)) + { myIntegers.ChangeFind(Key) = Value; + } else + { myIntegers.Bind(Key, Value); + } } //================================================================================================= @@ -50,9 +54,13 @@ void MeshVS_Drawer::SetInteger(const int Key, const int Value) void MeshVS_Drawer::SetDouble(const int Key, const double Value) { if (myDoubles.IsBound(Key)) + { myDoubles.ChangeFind(Key) = Value; + } else + { myDoubles.Bind(Key, Value); + } } //================================================================================================= @@ -60,9 +68,13 @@ void MeshVS_Drawer::SetDouble(const int Key, const double Value) void MeshVS_Drawer::SetBoolean(const int Key, const bool Value) { if (myBooleans.IsBound(Key)) + { myBooleans.ChangeFind(Key) = Value; + } else + { myBooleans.Bind(Key, Value); + } } //================================================================================================= @@ -70,9 +82,13 @@ void MeshVS_Drawer::SetBoolean(const int Key, const bool Value) void MeshVS_Drawer::SetColor(const int Key, const Quantity_Color& Value) { if (myColors.IsBound(Key)) + { myColors.ChangeFind(Key) = Value; + } else + { myColors.Bind(Key, Value); + } } //================================================================================================= @@ -80,9 +96,13 @@ void MeshVS_Drawer::SetColor(const int Key, const Quantity_Color& Value) void MeshVS_Drawer::SetMaterial(const int Key, const Graphic3d_MaterialAspect& Value) { if (myMaterials.IsBound(Key)) + { myMaterials.ChangeFind(Key) = Value; + } else + { myMaterials.Bind(Key, Value); + } } //================================================================================================= @@ -90,9 +110,13 @@ void MeshVS_Drawer::SetMaterial(const int Key, const Graphic3d_MaterialAspect& V void MeshVS_Drawer::SetAsciiString(const int Key, const TCollection_AsciiString& Value) { if (myAsciiString.IsBound(Key)) + { myAsciiString.ChangeFind(Key) = Value; + } else + { myAsciiString.Bind(Key, Value); + } } //================================================================================================= @@ -101,7 +125,9 @@ bool MeshVS_Drawer::GetInteger(const int Key, int& Value) const { bool aRes = myIntegers.IsBound(Key); if (aRes) + { Value = myIntegers.Find(Key); + } return aRes; } @@ -111,7 +137,9 @@ bool MeshVS_Drawer::GetDouble(const int Key, double& Value) const { bool aRes = myDoubles.IsBound(Key); if (aRes) + { Value = myDoubles.Find(Key); + } return aRes; } @@ -121,7 +149,9 @@ bool MeshVS_Drawer::GetBoolean(const int Key, bool& Value) const { bool aRes = myBooleans.IsBound(Key); if (aRes) + { Value = myBooleans.Find(Key); + } return aRes; } @@ -131,7 +161,9 @@ bool MeshVS_Drawer::GetColor(const int Key, Quantity_Color& Value) const { bool aRes = myColors.IsBound(Key); if (aRes) + { Value = myColors.Find(Key); + } return aRes; } @@ -141,7 +173,9 @@ bool MeshVS_Drawer::GetMaterial(const int Key, Graphic3d_MaterialAspect& Value) { bool aRes = myMaterials.IsBound(Key); if (aRes) + { Value = myMaterials.Find(Key); + } return aRes; } @@ -151,7 +185,9 @@ bool MeshVS_Drawer::GetAsciiString(const int Key, TCollection_AsciiString& Value { bool aRes = myAsciiString.IsBound(Key); if (aRes) + { Value = myAsciiString.Find(Key); + } return aRes; } @@ -161,7 +197,9 @@ bool MeshVS_Drawer::RemoveInteger(const int Key) { bool aRes = myIntegers.IsBound(Key); if (aRes) + { myIntegers.UnBind(Key); + } return aRes; } @@ -171,7 +209,9 @@ bool MeshVS_Drawer::RemoveDouble(const int Key) { bool aRes = myDoubles.IsBound(Key); if (aRes) + { myDoubles.UnBind(Key); + } return aRes; } @@ -181,7 +221,9 @@ bool MeshVS_Drawer::RemoveBoolean(const int Key) { bool aRes = myBooleans.IsBound(Key); if (aRes) + { myBooleans.UnBind(Key); + } return aRes; } @@ -191,7 +233,9 @@ bool MeshVS_Drawer::RemoveColor(const int Key) { bool aRes = myColors.IsBound(Key); if (aRes) + { myColors.UnBind(Key); + } return aRes; } @@ -201,7 +245,9 @@ bool MeshVS_Drawer::RemoveMaterial(const int Key) { bool aRes = myMaterials.IsBound(Key); if (aRes) + { myMaterials.UnBind(Key); + } return aRes; } @@ -211,6 +257,8 @@ bool MeshVS_Drawer::RemoveAsciiString(const int Key) { bool aRes = myAsciiString.IsBound(Key); if (aRes) + { myAsciiString.UnBind(Key); + } return aRes; } diff --git a/src/Visualization/TKMeshVS/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/Visualization/TKMeshVS/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index 9464369040..38e0bbf534 100644 --- a/src/Visualization/TKMeshVS/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx +++ b/src/Visualization/TKMeshVS/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx @@ -66,11 +66,15 @@ void MeshVS_ElementalColorPrsBuilder::Build(const occ::handle aDrawer = GetDrawer(); if (aSource.IsNull() || aDrawer.IsNull()) + { return; + } int aMaxFaceNodes; if (!aDrawer->GetInteger(MeshVS_DA_MaxFaceNodes, aMaxFaceNodes) && aMaxFaceNodes <= 0) + { return; + } NCollection_DataMap* anElemColorMap = (NCollection_DataMap*)&myElemColorMap1; @@ -87,14 +91,18 @@ void MeshVS_ElementalColorPrsBuilder::Build(const occ::handle